Skip to content

Drain Axum after-response identity tasks on SIGTERM - #1636

Open
prk-Jr wants to merge 15 commits into
feat/1574-axum-shared-identityfrom
feat/1575-drain-after-response
Open

prk-Jr wants to merge 15 commits into
feat/1574-axum-shared-identityfrom
feat/1575-drain-after-response

Conversation

@prk-Jr

@prk-Jr prk-Jr commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Test, document and specify the Axum SIGTERM drain of identity after-response work, using Run Axum identity through the shared application #1646's shared runner (IdentityApp::schedule_after_response / run_after_response_lookups) instead of a second runner of this PR's own.
  • Register follow-up work only when finalize issued a follow-up write permit, so a skipped navigation never holds the shutdown drain. schedule_after_response checks the permit with the new EcContext::has_after_response_permit() and returns whether it registered; the runner still takes the permit itself.
  • Fastly is unchanged: it keeps its per-request post-send gate and the same shared runner.

Part of #1575.

Stack: merges #1646 (feat/1574-axum-shared-identity) at 000e6f694, which already contains the current #1635 and #1637 heads. Proposed base: feat/1574-axum-shared-identity.

Dependency: EdgeZero rc/identity 9d02d7b3185b49e81d9ac972ca3feef932ed848a (R2, IABTechLab/edgezero#490), unchanged and identical to #1646.

Reconciliation with #1646

#1646 and this PR both added a core AfterResponseLookups and runner. #1646's survives, because it already serves Fastly post-delivery, the Axum publisher path and the shared EC route.

Removed from this PR Replaced by (#1646)
core ec/after_response.rs AfterResponseLookups, capture, run core ec/app/lookups.rs AfterResponseLookups, IdentityApp::run_after_response_lookups
Axum after_response::schedule_lookups and prepare_after_response_lookups (dispatch_fallback) IdentityApp::schedule_after_response, called from Axum dispatch_ec_route and core ec_route
schedule_lookups returning Err(EdgeError) without a scheduler schedule_after_response returns false and logs the error
.with_proxy_marker(false) on the Axum task client Already disabled by Axum's request_outbound_client (platform.rs:110, asserted at :185)

Exactly one AfterResponseLookups type remains. PENDING_LIFECYCLE_MOVE stays &[].

Changes

File Change
crates/trusted-server-core/src/ec/mod.rs has_after_response_permit(): a check that leaves the permit in place
crates/trusted-server-core/src/ec/app/lifecycle.rs schedule_after_response skips registration without work or permit and returns whether it registered (#[must_use])
crates/trusted-server-core/src/ec/app/route.rs, crates/trusted-server-adapter-axum/src/app.rs Discard the returned flag explicitly; failures are logged inside
crates/trusted-server-core/src/settings.rs Document the whole-task Axum budget and shared shutdown grace
crates/trusted-server-adapter-fastly/src/post_delivery.rs, src/app.rs Drop the unused settings parameter from the post-delivery wrapper
crates/trusted-server-adapter-axum/src/after_response_drain_tests.rs, src/lib.rs Real-process SIGTERM and registration tests, ported to #1646's runner
docs/guide/native-rc-demo.md Shared grace, whole-task budget and permit-gated registration
Spec and plan Reconciliation note recording the runner change

Requirements status (#1575)

Part of #1575, not Closes.

Acceptance criterion Status in this PR Where the rest lands
ID-5 on Axum: SIGTERM waits for registered after-response work Met. A registered lookup and guarded follow-up write finish within the configured grace, after the response is delivered (sigterm_drains_the_registered_lookup_and_guarded_write_after_response) —
ID-5 on Fastly: a follow-up write recorded after send is in the record before the next navigation Unchanged. Fastly keeps its post-send gate and the shared runner's consent, live-row and generation guards —
AX-1: an ECS-style stop during a request with a pending record write completes the request and the write, and CI runs that test Not in this PR. The drain tests use a fixture store to control timing #1579, implemented in #1654 (stop during a pending record write, in CI)
AX-1: startup with a missing secret exits non-zero before the port opens Superseded by #1142. The health and startup-failure contract now in the base replaces this: the server stays up, /health answers 200, and /ready and every other route answer 503. Only EdgeZero provider-preparation failures exit before listening #1142
ID-5 on Cloudflare (waitUntil) Not in this PR; behavior unchanged #1588
ID-5 on Spin: the follow-up write lands before the response Not in this PR; behavior unchanged #1589

Spec

Design · Plan. Both end with a reconciliation note for the runner change.

Test plan

Local results on 551419068 (Rust 1.98.1, isolated Viceroy 0.21.0):

Local check Result
Axum drain and registration tests (after_response_drain_tests), run 3 times 10 passed each run
cargo test-axum 132 passed
Fastly adapter tests (isolated Viceroy 0.21.0) 254 passed
Native core ec:: tests 693 passed
Integration adapter_identity_guard 9 passed
cargo clippy-axum, cargo clippy-fastly, Rust and docs formatting Clean
Mutation: drop the permit check in schedule_after_response work_without_a_permit_registers_nothing and cloning_a_context_does_not_duplicate_a_follow_up_permit fail; restored
  • Hosted checks on 551419068.

The registered-task fixture proves the response completes before the guarded write and the process exits within its grace. The disabled-registration control shows response drain without the lookup or write. A 450 ms held response plus an 850 ms task under a 1 s shared grace cancels the write rather than granting a second grace. The task budget cancels independently of shutdown, and a client disconnect still releases registered work.

Checklist

  • Spec and plan linked, with a reconciliation note
  • Changes follow repository conventions
  • No production unwrap(); uses log macros
  • New behavior has focused tests
  • No secrets or credentials committed
  • EdgeZero crates and lockfile match Run Axum identity through the shared application #1646's R2 revision

@prk-Jr prk-Jr self-assigned this Nov 19, 2026
@prk-Jr prk-Jr linked an issue Nov 19, 2026 that may be closed by this pull request
3 tasks
@prk-Jr
prk-Jr added this pull request to stack #1638 November 19, 2026 13:00
@prk-Jr
prk-Jr marked this pull request as ready for review November 20, 2026 09:59
@prk-Jr

prk-Jr commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator Author

@aram356 this PR covers the A3 part of #1575: after-response work on Axum is drained on SIGTERM, and Fastly keeps its post-send path. I've asked on #1575 to narrow its checklist:

After that, this PR can close #1575. The EdgeZero pin is now R2 (rc/identity 9d02d7b3), the same as #1635, and CI is green.

Brings #1635, which now carries the identity integration chain (dhruv8sh's
spine with the core identity app, the protected native Geo from #1532, the
identity conformance suite from #1613, the certificate-check statement from
#1616, the health and startup-failure contract from #1617 applied to the
native production runner, and the creative-proxy identity disclosure policy
from #1615), into the after-response task drain on SIGTERM.

Docs: the production startup guide keeps the base's boundary, where a store
the selected provider cannot prepare stops the process before it listens and
a missing or invalid config value or secret leaves only the probes
answering, and adds the PR's shared shutdown grace for in-flight requests
and registered after-response tasks, its whole-task identity budget and its
A2/A8 activation note.

Tests: the PR's Axum after-response fixtures build GeoInfo with the base's
optional city, continent, coordinates and metro code. The values are
unchanged.

Code merges without conflict: the PR's Axum fallback scheduling, its shared
core runner and its Fastly post-delivery changes compile on the base's
identity app, conformance hook and failure router. Cargo.lock is the base's
plus the PR's trusted-server-identity-providers dev-dependency edge for the
Axum crate.
Brings #1532's rename of the native Geo profile variable to
TRUSTED_SERVER__NATIVE_GEO_PROFILE_FILE and #1617's bash 3.2 fix for the
smoke credentials expansion into the after-response task drain. The merge
is clean. Cargo.lock is unchanged from the PR's previous merge.
@aram356
aram356 removed this pull request from stack #1638 November 24, 2026 06:29
@aram356
aram356 added this pull request to stack #1658 November 24, 2026 06:29
aram356 added a commit that referenced this pull request Nov 24, 2026
Brings in, through #1636 (cf1102c):
- dhruv8sh's spine on #1489: #1639 (738ba34), #1640 (46530d8),
  #1612 (36e35f8), #1628 (384a481) and #1623 (6fd236e).
- #1531 (47411de) and #1532 (4d17086, which renames the native Geo
  profile variable to TRUSTED_SERVER__NATIVE_GEO_PROFILE_FILE).
- #1613 (2415b7d), then #1616 (c142e87), #1617 (b91770e) and
  #1615 (255c390), restacked on #1613.
- #1635 (06b4044), restacked on #1615, and #1636 (cf1102c).

Each conflict was resolved in the PR that sits higher. This merge is clean.
@aram356

aram356 commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#1608), I pushed de20e4d51 and cf1102c1e, merges of #1635's new heads. docs/guide/native-rc-demo.md keeps the base's startup boundary and adds this PR's shared SIGTERM grace, whole-task identity budget and activation note. The two GeoInfo fixtures in after_response/tests.rs use #1532's optional fields with the same values.

Adopt #1646's shared after-response runner and drop this PR's duplicate:
core ec::after_response's AfterResponseLookups and run, and Axum's
schedule_lookups and prepare_after_response_lookups. schedule_after_response
now checks the follow-up permit before registering and returns whether it
registered, so a skipped navigation never holds the shutdown drain. Port
the SIGTERM drain and registration tests to that runner, deriving the
re-executed child test name from the module path.
@prk-Jr
prk-Jr removed this pull request from stack #1658 November 25, 2026 14:44
@prk-Jr
prk-Jr changed the base branch from feat/1573-axum-production-serving to feat/1574-axum-shared-identity November 25, 2026 14:44
Pick up the native container test fix (4f4c036), which expects the
#1142 failure router for invalid config and missing secrets.
Pick up the container test correction (71a573a): operational probes
skip finalization, so the snapshot header is asserted on the page.
#1636 stays on #1646 and keeps #1646's shared after-response runner, as
5514190 adopts it. This merge brings #1646's chain head (b5a5f62), which
merges #1642's chain head (f654f67) and, through it, the identity chain
below: #1506's repin of EdgeZero to rc/identity at d063a8e7 and main's
Fastly SDK 0.13.3 upgrade (#1671), #1488's hashed-email intake and owned
request signals, #1489's mirrored UID expiry and request time, the identity
spine, the Axum serving line (#1613, #1616, #1617, #1615, #1635, #1637 and
#1627, with #1627's merge of #1625) and the held line from #1533 to #1642.

The merge had no textual conflicts. #1646's chain head gives its
AfterResponseLookups #1488's Referer and Accept-Language, which
prepare_after_response_lookups copies and run_after_response_lookups passes
to providers, so this PR's drain-test helper lookups_for, which copies the
request signals the shared runner hands to providers, copies those two
headers as well.

The chain's #1489 also passes finalize a FinalizeRequest, so the drain
tests' two ec_finalize_response calls pass one with the current request
time, which the navigation's page-load write needs before it issues the
follow-up permit the tests drive.
aram356 added a commit that referenced this pull request Nov 25, 2026
This brings in 1f054c6 from #1488, which forwards ortb2.user.ext.eids
from the Prebid config into the auction EIDs, and a99dd66, a62601b,
d1eb75f and 394892b from #1489, which cap mirrored UID expiry at 30
days from the UTC day start and pass the request time into finalize. They
arrive through the chain's merges into #1639, #1640, #1612, #1628, #1623,
#1531, #1532, #1533, #1534, #1536, #1535, #1537, #1539, #1538, #1540,
#1566, #1624, #1641, #1642 and #1646, with #1646's move of the request
time into IdentityApp::finalize. It also brings d5276ee, which publishes
the native AWS runtime files without GNU mv -T, and Christian's merge
5597d3e of #1538 into #1540, through #1566's merge.

The base now also carries the Axum serving line (#1613, #1616, #1617, #1615,
#1635, #1637 and #1627), which #1533 merged, and #1627's b958107, which
decodes the Spin discovery document with Response::json, and #1627's merge
of #1625 (006b45e), which pins Wrangler for the Cloudflare smoke and CI.

This PR already carries #1646's head 461aa0d, so the merge adds only
#1646's new merge 166944769 of #1642 and the chain below it, including the
identity conformance check that now strips the mirrored UID's exp.

It also brings b2d4bfd from #1488, which records the known UID hashes
on lookup results with a setter, so the provider IDs the write planner
logs are not derived from them.

Restacking on the Axum serving line conflicts in the Axum startup tests,
where #1617 waits for /ready, since liveness stays up after a caught
initialization failure, and this PR rewrites the wait to retry a port
collision and to require the child's own ready lifecycle event.

Axum startup tests: wait_ready keeps this PR's collision retry and
lifecycle check, then probes #1617's /ready and returns the /health
response once the child is ready.

The fixture drains each child's output through this PR's log readers, so
#1617's assert_serves_failure_router reaps the stopped child and reads
those captured logs instead of collecting the pipes, which the readers
already own.

The base now also carries #1506's repin of EdgeZero to rc/identity at
d063a8e7 and its merge of main's Fastly SDK 0.13.3 upgrade (#1671): fastly
0.13.3, url 2.5.9 and Viceroy 0.22.0.

This PR now stacks on #1661 instead of #1646, so rc/identity can take both
as plain merges. #1661 sits on #1656 and #1626, which sit on #1646, so the
merge also brings #1626 (provider opt-outs and legacy EID expiry on Fastly
and Axum), #1656 (the configurable Edge Cookie browser gate) and #1661
(refusing EC creation when a trusted JA4 contradicts the User-Agent).

Fastly identity conformance fixture: #1661 records each scenario's runtime
TLS JA4 through a RuntimeTlsJa4 middleware in place of derived device
signals, takes the User-Agent from the scenario and drops the browser flag.
This PR adds geo consent requests with their own trusted client IP settings
and no browser device signals. The merge assembles the conformance app with
#1661's middleware and keeps this PR's geo_configured flag and
producer_settings. It sends the scenario's User-Agent unless the API request
supplies one, and inserts the scenario's JA4 only for requests without a geo
consent exchange, because this PR derived device signals only for those.

The base now also carries #1627's 4d0c1a2, which renames the generic
runtime KV store to trusted_server_runtime_kv, #1488's a610152 and
9104fd3, which add hashed-email intake for the LiveRamp and ID5
identity providers, #1646's aa31559, which gates identity writes for
rejected clients, and #1626's d07f789, which withholds a mirrored UID
while another source owner is opted out.

Fastly conformance JA4: the rebuilt #1661 merge supplies a trusted Python
JA4 behind the Chrome User-Agent for #1646's known non-browser API
requests, and this PR inserts the scenario's JA4 only without a geo
consent exchange, with its producer_settings. The merge keeps both: a
known non-browser request gets the Python JA4, any other request the
scenario's JA4 unless it is a geo consent exchange.

This PR's head moves to e8015ca, its clean merge of #1646's aa31559,
which the base already carries, so it adds no change beyond the base.

Axum lib.rs: the base now carries #1636, through #1626's merge of it, whose
after_response_drain_tests module sits where this PR adds its
geo_conformance module. The crate keeps both test modules.
aram356 added a commit that referenced this pull request Nov 25, 2026
…1622 into rc/identity

#1622 (244ca26) now carries the whole chain, each PR merging the one below
it:

- #1506 (c197404) repins EdgeZero to rc/identity at d063a8e7, which
  carries EdgeZero main's Fastly SDK 0.13.3 upgrade through every EdgeZero PR
  here, and merges Trusted Server main's upgrade (#1671): fastly 0.13.3, url
  2.5.9 and Viceroy 0.22.0.
- #1614, #1525, #1526, #1487 and #1488 take it in turn. #1488 also adds
  b2d4bfd, which records known UID hashes with a setter.
- #1489, the identity spine (#1639, #1640, #1612, #1628 and #1623), #1531 and
  #1532.
- The Axum serving line: #1613, #1616, #1617, #1615, #1635, #1637 and #1627,
  chained, with #1627's b958107 decoding the Spin discovery document with
  Response::json and #1627's merge of #1625, which brings #1625's Wrangler pin
  into the chain.
- The held line on #1627: #1533, #1534, #1536, #1535, #1537, #1539, #1538,
  #1540, #1566, #1624, #1641, #1642 and #1646. #1646 keeps its own shared
  after-response runner in ec::app::lookups.
- #1636 (72096cd) on #1646 (b5a5f62), draining Axum
  after-response identity tasks on SIGTERM through #1646's shared runner.
- The EC route line on #1636: #1626 (067531e), which merges #1636, the
  draft #1656, #1661, #1662 and #1622, and through #1622's merge of it,
  #1620's round-6 head.

Each conflict was resolved in the PR that sits higher. This merge is clean.

Since the last update the chain also takes #1488's hashed-email intake
(a610152 and 9104fd3) and its POST, body and header options for the
status call (f063a76), #1627's split of the generic runtime KV store into
trusted_server_runtime_kv (4d0c1a2), #1646's gate on identity writes for
rejected clients (aa31559) its native container test of the failure router
(4f4c036) and that test's header check on an ordinary route (71a573a),
#1626's withholding of a mirrored UID while another source owner is opted
out (d07f789), and #1617's description of the Axum startup failure router
(6d174a8) and of the startup failures that still exit before listening
(4c07cad). #1636 no longer sits in the Axum serving line; it arrives
through #1626, which merges it on top of #1646. Its new head adopts #1646's
after-response runner in place of the one rc/identity took with cf1102c.

Cloudflare guide: #1627's merge of #1625 now keeps both #1625's tool version
clause and #1627's TRUSTED_SERVER_RUNTIME_KV binding in the smoke paragraph,
and fixes #1625's smoke script test for #1617's Python floor and Worker
build, and #1537's merge fixes its ts stub for #1537's storage template
step, so this merge needs no resolution.
@aram356

aram356 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#1608), I pushed 72096cd1f, a merge of #1646's new head b5a5f62f8 onto this PR's 515708fb4. This PR stays on #1646 and keeps #1646's shared after-response runner, as 551419068 adopts it. The merge brings #1646's new head, which merges #1642's new head and, through it, the chain below: #1506's repin of EdgeZero to rc/identity at d063a8e7 with main's Fastly SDK upgrade (#1671), #1488's hashed-email intake and owned request signals, #1489's mirrored UID expiry cap and request time, the Axum serving line (#1613, #1616, #1617, #1615, #1635, #1637 and #1627, with #1627's merge of #1625) and #1533 to #1642.

The merge had no textual conflicts. Two test edits in after_response_drain_tests.rs:

In rc/identity this PR now arrives through #1626, which merges it, and rc/identity now uses #1646's after-response runner in place of the one it took with cf1102c1e.

#1646's new head 9f648f6 brings #1537's b181544, "Accept any Fastly EC
store link name at startup", which #1537's owner merged up through #1539,
#1538 and #1540. The merge is clean.
@aram356

aram356 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#1608), I pushed 1fb5bc3b5, a merge of #1646's new head 9f648f694. It brings #1537's b181544a0, "Accept any Fastly EC store link name at startup", which #1537's owner merged up through #1539, #1538 and #1540. The merge had no conflicts.

Takes #1646's new head 9333826, which carries #1506's repin of EdgeZero to
rc/identity at 459bd27d (42e0c46): PR 275 at 0e2a58ae, the stack's test
fixes and EdgeZero 536's bounded record update, RecordHandle::update.

The merge is clean.
@aram356

aram356 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#1608), I pushed 3c6b34c54, a merge of #1646's new head 933382699, which brings #1506's repin of EdgeZero to rc/identity at 459bd27d (42e0c46c7): EdgeZero #275 at 0e2a58ae, the EdgeZero stack's test fixes and EdgeZero #536's bounded record update, RecordHandle::update. The merge had no conflicts.

#1660 now sits above this PR and sends its follow-up write through EcKvStore::update. Its merge 173d6d06f adds an update implementation to this PR's after_response_drain_tests fixture store: without it the fixture's write fell back to last-write-wins, skipped the guarded insert that records and holds the write, and four drain tests failed on #1660. The fixture's update follows EdgeZero's RecordHandle::update contract over its own lookup and insert. The change is in #1660's commit, not on this branch; please check it there.

#1646's new head 4f1c155 brings #1539's cf4e815, "Expect the failure router in the native container test", and #1646's a18abf4, "Compare undeclared Axum KV stores with assert_eq". The merge is clean.
@aram356

aram356 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#1608), I pushed ee3a9afc8, a merge of #1646's new head 4f1c15544, which brings #1539's cf4e815d4, the native container test's failure-router expectation, and #1646's a18abf428, the reworked KV check in the store metadata test. The only change to this PR's tree is that store test. The merge had no conflicts.

@dhruv8sh dhruv8sh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This PR changes IdentityApp::schedule_after_response in three ways. It checks for a follow-up permit before registering work, it returns whether a task was registered, and that return value is now #[must_use]. It also adds a has_after_response_permit check that doesn't use up the permit, and it removes the unused _settings parameter from Fastly's run_after_response_lookups. Finally, it adds subprocess SIGTERM drain tests for Axum, plus some documentation. Nothing here blocks merging. The one concern is that the new subprocess tests might be flaky.

Non-blocking

🤔 thinking

  • Subprocess drain tests rely on tight wall-clock margins — see inline at crates/trusted-server-adapter-axum/src/after_response_drain_tests.rs:691

Cross-cutting / body-level findings

  • 👍 The permit check matches the shared runner and fixes a drain stall — The new permit check does the same thing as the shared runner in lookups.rs:307, which skips work when there is no permit. So the only change in behaviour is that skipped navigations no longer register a task that would do nothing. Those empty tasks can no longer hold up the shutdown drain, which is correct. The call sites in the Axum and Fastly adapters are updated consistently.

CI Status

  • release scripts: PASS
  • integration tests: PASS
  • CLAUDE.md symlink guard: PASS
  • format-docs: PASS
  • integration tests (Fastly EC lifecycle): PASS
  • health-startup (cloudflare): PASS
  • health-startup (spin): PASS
  • browser integration tests: PASS
  • health-startup (axum): PASS
  • format-typescript: PASS
  • worker-deadlines (spin): PASS
  • Native provider acceptance script: PASS
  • trace runtime and browser acceptance: PASS
  • vitest: PASS
  • worker-deadlines (cloudflare): PASS
  • cargo test (axum native): PASS
  • cargo test (cross-adapter parity): PASS
  • cargo test (ts CLI, native) (ubuntu-latest): PASS
  • docs-proposal scripts: PASS
  • record-provider-image: PASS
  • cargo test: PASS
  • cargo fmt: PASS
  • HTML EOF runtime (Fastly): PASS
  • cargo check/build/test (spin native + wasm32-wasip1): PASS
  • CI Node pin guard: PASS
  • ts dev lint domains (changed lines): PASS
  • Fastly response diff script: PASS
  • stock-celld-records: PASS
  • health-startup (fastly): PASS
  • prepare integration artifacts: PASS
  • cargo test (ts CLI, native) (macos-latest): PASS
  • cargo check (cloudflare native + wasm32-unknown-unknown): PASS
  • local-provider-image: PASS

app.wait_marker("registered");
let start = app.terminate();
thread::sleep(Duration::from_millis(450));
app.release();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 thinking — Subprocess drain tests rely on tight wall-clock margins

This test, like the other subprocess tests, depends on tight wall-clock timing. The grace period is 1 s, the parent sleeps 450 ms, the task delay is 850 ms, and exited allows only 300 ms of slack. On a loaded CI runner, a slow child start or slow scheduling could change which happens first: the grace period running out or the task finishing.

Running::start also has a small race. It reserves a port, drops the listener, and only after that does the child bind to the port.

Consider widening the margins. Or gate each stage with marker files, as hold-write does, instead of relying on the delays alone. Either way, whether the test passes would no longer depend on how fast the runner is.

Takes #1646's new head 6b4a5fd, which carries #1506's repin of EdgeZero to
rc/identity at 1619078a (8edc50e), a revert that removes EdgeZero 522
(portable Fastly record providers) and 524 (outbound mTLS client
identities).

The merge is clean.
@aram356

aram356 commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

For the identity integration branch (#1608), I pushed 73a36a94a.

Takes #1646's new head 6b4a5fd, which carries #1506's repin of EdgeZero to rc/identity at 1619078a (8edc50e), a revert that removes IABTechLab/edgezero#522 (portable Fastly record providers) and IABTechLab/edgezero#524 (outbound mTLS client identities).

The merge is clean.

@ChristianPavilonis ChristianPavilonis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed against #1646 at 6b4a5fdc0. The permit gate preserves the shared runner and I found no production regression in this diff. I ran cargo test-axum --offline --locked --lib after_response_drain_tests on the exact PR head: 10 passed, with the subprocess entry point intentionally ignored by the parent test run. The inline comments cover places where the tests can pass without proving the stated contract, stale design docs, and optional cleanup. The fixture proves a guarded write can complete on SIGTERM; the production binary and record-provider check remains separate in #1654.

}
fs::write(root.join("registered"), b"request-held")
.expect("should expose request stage");
while !root.join("release").exists() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R1. Check task start while the response body is still pending

This gate holds the handler, not the body. After it opens, the handler returns a complete string body, and the parent independently blocks the write until it reads the response. A task that starts at handler return, before Hyper releases the body, could pass both assertions. Could the fixture return a streaming body with the final frame held? Read the first frame, assert no task-start marker while the final frame is pending, then release it and retain the lookup and write checks.

app.release();
complete_response(&mut stream);
app.wait_marker("writing");
thread::sleep(Duration::from_millis(180));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R2. Observe the task timeout before sending SIGTERM

The assertions only observe a clean exit and no completed write after SIGTERM. I exercised the same fixture child with a deliberately wrong 500 ms budget: the assertions still held, even though cancellation happened after SIGTERM. With the intended 100 ms budget, EdgeZero logged cancellation before the signal. Wait for that 100 ms diagnostic or a fixture cancellation marker while the child is still running, then send SIGTERM.

app.release();
complete_response(&mut stream);
assert!(
!app.exited(start, Duration::from_secs(1)),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R3. Require grace exhaustion, not just an unsuccessful exit

The normal fixture hit grace_exhausted at about 1,008 ms. As a control, a second SIGTERM after the write started caused forced_stop at about 463 ms and satisfied the same assertions. Check reason=grace_exhausted in the captured log so an early failure cannot count as hitting the shared deadline. Returning ExitStatus from the wait helper would also make the current success check explicit.

)
.expect("should build fixture identity");
assert!(
!identity.schedule_after_response(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R4. Isolate the no-work guard

This passes even if work.is_none() is removed: the default context has no permit, and there's no scheduler to count any attempt. Use the permit-bearing registration fixture, pass None for work and supply the counting scheduler. Assert that it receives zero calls.

## Dependency and rollout

All six EdgeZero crates use `rc/identity` revision
`9d02d7b3185b49e81d9ac972ca3feef932ed848a`, matching #1635 and the rest of the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R5. Put the current stack and implementation first

The spec and companion plan describe the old #1635 base and a runner this PR no longer adds. The reconciliation notes correct some of that, but both docs still say 9d02d7b3 matches the base. The live #1646 base and this head both pin 1619078a. Lead with the current #1646 design, link to the workspace pin, and label any retained #1635 material as historical. No dependency change is needed.

Comment on lines +997 to +999
/// response has been sent. On Axum this also bounds the complete registered
/// task, including row reads and the guarded follow-up write. Shutdown may
/// cancel it sooner when the shared grace expires.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R6. Clarify when the Axum task timer starts

The preceding sentence describes the lookup clock. Axum's whole-task timer starts earlier, at body release, before the live-row read.

Suggested change
/// response has been sent. On Axum this also bounds the complete registered
/// task, including row reads and the guarded follow-up write. Shutdown may
/// cancel it sooner when the shared grace expires.
/// response has been sent. On Axum, the same value also limits the full
/// task from response-body release, including row reads and the guarded
/// follow-up write. The shared shutdown grace may cancel the task sooner.

///
/// Returns whether a task was registered. A missing scheduler or a rejected
/// registration is logged and drops the work without running it.
#[must_use = "returns whether follow-up work was registered; failures are already logged"]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R7. Optional: keep the registration outcome internal

Both production callers discard the new #[must_use] result; only the tests observe it. The flag is useful for synchronous test assertions. If you prefer to keep the existing API, the tests can instead assert scheduler calls and task effects, and this method can still log registration failures and return ().

trusted_server_identity_providers::partner_registry(&settings.ec)
.expect("should build partners"),
);
let coordinator = Arc::new(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R8. Optional: share the eligible identity setup

The runtime fixture and registration_case build the same partner, coordinator, consented row, and finalize inputs. A shared setup helper would keep their eligibility assumptions in sync. Keep each scenario's client, timing, and choice to finalize visible at the call site.

}

impl Running {
fn start(delay: u64, budget: u64, enabled: bool, grace: u64) -> Self {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

R9. Optional: make the fixture's timing units explicit

delay and budget are milliseconds; grace is seconds. All are positional u64s, and callers restate the grace when they check exit. Named Duration fields would prevent swapping the units and let the exit check reuse the grace used to launch the child.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drain after-response tasks on SIGTERM

4 participants