ADR-068: Live-Service Degradation Posture Under DB I/O Stall — Server-Yields-First Typed Failure, Route-Class Request Ceilings, a Phase-Aware DB Error Taxonomy, and Saturation Hysteresis

Status

Accepted (2026-08-23). Design unit of #1404 (epic &83’s last child, outside the &83 program by the ratified boundary — ADR-067 §Open questions). Drafted FIRST per the draft-first path; implemented on feature/1404-degradation-posture. Plan: DB-Degradation Posture (archived). The design survived one internal adversarial review (11 findings) and the maintainer’s external stop-ship review (26 findings); the censuses in the appendices are review outputs, not estimates. Ratified direction (steer 2026-08-16, mode B): server-yields-first typed failure + honest health. Merging this design promotes the C21 pool-contention characterization from report-only to enforcing (contested-surfaces.toml, pool.craig-db.serving-acquire). Amended in part by § Amendment — #1571 (Proposed 2026-09-17; Accepted 2026-09-18 at that plan’s close-out U8, #1940 — plan Background Jobs (#1571), archived): the Batch class is gone — the eight backgrounded engines landed as jobs and CeilingClass is Standard | Extended; D1 / D1a / D1b below are restated to the as-built. Amended in part by § Amendment — #1572 (Proposed 2026-09-19; Accepted 2026-09-20 at that plan’s close-out U2, #1947 — plan Streaming Object-Store Downloads (#1572), archived): the nine download GETs stream and move to Standard — the Extended class keeps only the upload nests and the two reporting export POSTs; the class-table row, the streamed-body sentence and the BFF pairing bullet in D1a are restated below to the as-built. Amended by § Amendment — #2478 (Accepted 2026-11-12, a maintainer ruling): D1’s revisit trigger has fired, and a three-deep synchronous chain is accepted where each inner hop’s budget is const-asserted inside its caller’s.

Context

The 2026-08-11 U4a battery (forensics on #1403) showed the fleet’s actual posture under Postgres I/O stall: POST /v1/cases/persons hung the full 30 seconds until the client timed out; outbox single-row UPDATEs ran 25.6s/17.2s. The arithmetic guarantees the hang:

  • The shared S2S client budget (craig_common::build_shared_client) is 30s total / 5s connect. The session statement_timeout (set once per connection by the pool’s after_connect hook) defaults to 30s. Equal budgets mean the client always eats the whole stall.

  • No inbound request deadline exists anywhere: apply_global_layers has no timeout layer and axum::serve runs bare. The only server-side bounds are the fixed 5s pool-acquire cliff (craig_db::SERVING_ACQUIRE_TIMEOUT, #1160) and the session statement timeout.

  • Error mapping is dishonest about all of it: SQLSTATE 57014 (statement kill) arrives as sqlx::Error::Database → the blanket ApiError::Db → a redacted RFC-9457 500 after up to 30s; sqlx::Error::PoolTimedOut maps to a typed 503 ONLY on the tx-begin path (map_begin_error); everything else — connection loss, commit-phase failures — is a 500 regardless of retry safety or outcome certainty.

A degraded database must never convert into a caseworker-facing raw stall. The server gives up first, typed; already-durable event-pipeline work catches up; health is honest without inviting restart flapping. That is the ratified posture this ADR realizes.

Decision

D1 — Deadline model: the two-inequality rule, enforced by route-class ceilings

Requiring the sum of all inner worst cases to fit under one ceiling is neither achievable nor necessary — every inner budget (pool acquire, statement timeout, authz/rules eval, S2S hop) is itself a fail-fast path that terminates the request with its own typed error. Two inequalities are required, each with explicit margin, and only these:

  1. Specific-beats-generic: each single inner budget + processing margin < the route’s ceiling — when exactly one component is slow, the caller gets that component’s typed error, never the generic ceiling 504.

  2. Server-yields-first: ceiling + client connect + margin < the client’s total budget — the server always answers (typed) before any first-party caller gives up.

The Standard chain:

Bound Value Enforcement

Pool acquire

5s

craig_db::SERVING_ACQUIRE_TIMEOUT — unchanged, fixed (#1160: not a knob)

In-request S2S hop

≤ 8s

tokio::time::timeout at each synchronous in-request S2S call site (census in Appendix A — S2S client census (per-hop budget and synchronous depth))

Per-tx statement budget

10s

SET LOCAL statement_timeout = '10s' inside the craig-api tx funnels, placed AFTER claim_first (see below)

Authz / rules eval budgets

5s (existing defaults)

unchanged; settings load refuses any configured value ≥ 19s

Request ceiling (Standard)

20s

the new ceiling middleware (D1a)

S2S client

30s total / 5s connect

build_shared_client — unchanged; DEFAULT_TIMEOUT exported for the assert chain

Checks: 5+ε<20, 8+ε<20, 10+ε<20, 20+5+5<30. Where both sides are consts the order is pinned by const _: assertions; where one side is a knob it is pinned by settings-load refusal: db_statement_timeout_ms < 10_000 is refused (SET LOCAL would otherwise silently raise an operator-tightened bound — the floor makes the joint decision explicit), and authz_eval_timeout_ms / the rules eval budget are refused at ≥ 19s.

SET LOCAL placement — as-built mechanism: the wrapper cannot inject between the claim and the domain statements (both live inside the handler closure), so the post-claim budget hook lives INSIDE claim_first itself — it applies the SET LOCAL as its final act, after the claim resolves. ADR-062’s claim-first contract is untouched, and the claim INSERT keeps the session-default (30s) lock-wait allowance its duplicate-arbitration math requires. In execute_within_tx (unclaimed): immediately after begin. There is NO opt-out: every HTTP-plane domain statement runs under the 10 s budget; long statements belong to jobs (§ Amendment — #1571, as-built). The original opt-out, claim_first_unbudgeted, served two censused Batch routes — ncands generate’s 10k-row INSERT…UNNEST batches and the subsidy sweep’s pinned-set write; both moved to the worker plane inside their background jobs (#1936, #1939) and the helper was deleted with its last site (#1939). No unbudgeted claim variant survives, claimed or unclaimed.

One recorded interaction: the 8s hop budget sits BELOW the 19s eval-budget caps. Under default configs (5s eval) the callee’s typed 503 always arrives first; a deployment that raises an eval budget past ~7s trades error specificity for the same bounded outcome — the caller’s typed hop 503 fires at 8s while the callee finishes uselessly. Bounded and typed either way; specificity degrades gracefully. The reporting→cases NCANDS export hop IS an 8s hop since #1936: CasesClient::export_ncands pages GET /v1/cases/ncands-export by referral under the fleet S2S_HOP_BUDGET from inside the ncands_generate job (the whole-FFY hop that once carried BATCH_CALLER_BUDGET went with the class).

Session statement_timeout stays 30s by default — it is the worker-plane authority (ADR-062 §H derives the inbox winner-hold math from it). Standard routes that begin() directly on the pool (census: financial adjustments-resolution, placement kinship, cases report-create, among others) ride ceiling-only until migrated to the funnels; the funnels are the new-code convention.

Depth-2 honesty (per-hop margins instead of propagation). Absolute deadline propagation is rejected while the synchronous S2S graph has depth ≤ 2: it is header + re-budgeting machinery on every hop, and it still cannot validate external budgets. Instead every synchronous in-request S2S call carries a per-call budget ≤ 8s (the financial CASES_S2S_DEADLINE precedent), asserted < ceiling. The accepted residue: a downstream service may finish work after its caller has already yielded — inherent to non-propagation; effects are claims-idempotent (ADR-062). Revisit trigger: the graph deepens past 2. The trigger fired at depth 3; § Amendment — #2478 rules on it.

D1a — The ceiling middleware and route classes

The fleet has a real population of legitimately-long synchronous routes, so the ceiling is class-based — ONE global middleware selecting the class per request; never an inner route_layer (an inner layer cannot extend an outer timeout):

Class Ceiling Members Caller budget pairing

Standard

20s

everything not listed below

shared 30s client (inequality 2)

Extended

300s

upload nests (intake signed 30 MiB, cases attachments + contact attachments + court-order documents, placement home documents, exchange ICPC attachments, intake attachment proxies) and, since #1936, the two synchronous reporting export POSTs (ncands|afcars/{id}/export, flipped from the retired Batch class). The download GETs LEFT this row under § Amendment — #1572 (Accepted 2026-09-20): every download handler streams and is Standard by absence — 20 s to the response head, the body outside the ceiling

the specific first-party call sites get per-request .timeout(310s) (EXTENDED_CALLER_BUDGET): the BFF’s post_multipart (upload proxies) + its post_extended on the two export POSTs, and the intake attachment upload forward — never a download (those ride the streaming client: head under DEFAULT_TIMEOUT at the BFF / the Standard ceiling at intake, body under DOWNLOAD_IDLE_BUDGET)

The table is CLOSED at two classes. A third — Batch, 600s, the synchronous admin/batch/federal engines — stood from this ADR’s acceptance until § Amendment — #1571’s close-out (2026-09-18, #1940): its eight members are background jobs (202 + poll), its four FALSE members ride Standard, and the row, CeilingClass::Batch, BATCH_REQUEST_CEILING, BATCH_CALLER_BUDGET, the 4-arg with_durations and the built-in admin-replay entry are deleted — CeilingConfig::production(table) adds nothing behind the service table; an unlisted route is Standard by absence.

A class ceiling without its caller-budget leg is dead policy — the server would keep working for minutes after every first-party caller abandoned at 30s. The two land together.

Mechanics:

  • The table is data on ServerOptions: (Method, route template) → Class, matched at runtime via MatchedPath (the http_metrics_middleware precedent) — never raw path prefixes (dynamic IDs and shared paths across methods make prefixes ambiguous). A coverage test in each service (ceiling_templates_match_registered_routes) fails on any table entry that is not an operation of the service’s OpenAPI document under that method, or whose un-nested path is not a whole string literal of the route-registration source (#3096; a substring match before that, which a longer route containing the path satisfied), so the table cannot go stale silently. It does not see a registration whose method alone changes.

  • Position: innermost of the global layers — inside http_metrics_middleware (which has no drop guard; an outer timeout would leak the in-flight gauge and lose the 504 from the duration histogram) and inside request_id_layer (the problem document carries the correlation id).

  • Implementation: axum::middleware::from_fn + tokio::time::timeout(next.run()) — no new dependencies, no tower feature enables, full control of the RFC-9457 body. The bound is cooperative and covers request processing up to the response head: streamed response bodies are not covered BY DESIGN — since § Amendment — #1572 every download handler streams, and the body is bounded upstream by the store’s chunk deadline and at the edge by DOWNLOAD_IDLE_BUDGET (per read, never a total), and downstream by RESPONSE_WRITE_IDLE_BUDGET (write progress, never a total — #1951) — and a non-yielding CPU section cannot be preempted (none exists on these paths; rules and authz evals carry their own budgets and the ADR-024 wedge deadman).

  • Prod values are consts; a test-injectable seam (the HTTP_DRAIN_DEADLINE / serve_with_listener precedent) lets fault legs run at ~1s.

  • craig-intake does not use ApiServer: the middleware ships as a reusable pub fn and intake installs it in its own stack explicitly. As-built: the whole ceiling module (craig_common::ceiling) lives in craig-common, not craig-api — intake is deliberately craig-api-free (no sqlx on the stateless edge), and craig-api re-exports it; only the pool-acquire leg of inequality 1 is asserted in craig-api (craig-common cannot depend on craig-db). xtask is deliberately craig-common-free (tool-time OUT-class per ADR-067) and, since #1938, mirrors no caller budget: its one long call, the conversion-import finalize, is a POST-once + poll.

  • craig-web (BFF) gets NO inbound ceiling: its handlers legitimately fan out multiple sequential 30s upstream calls; its bound is per-upstream-call. Recorded, not deferred. The BFF is unpaired by design above Extended: it pairs ONLY the Extended budget (post_extended on the two export POSTs and post_multipart on the upload proxies at EXTENDED_CALLER_BUDGET; its download proxies ride the streaming client — head under DEFAULT_TIMEOUT, body under DOWNLOAD_IDLE_BUDGET, § Amendment — #1572) and never carried a Batch leg — its proxies of the once-Batch routes rode the shared 30 s client, which is exactly why those routes became jobs (202 + poll) rather than longer ceilings.

  • External (non-first-party) API consumers cannot be validated at config load. The contract is documented instead: responses are bounded at 20s/300s by class — no route answers past 300s; set client budgets above your class. A backgrounded engine answers 202 inside the Standard ceiling and is polled.

D1b — Cancellation safety (census, not hope)

The ceiling’s cut is mechanically the same event as a client disconnect, which hyper already inflicts on every handler when the peer goes away — the ceiling makes an existing hazard deterministic; it does not create the class. The census:

Sequence class Outcome when cut

Funnel tx routes (all convert-class routes, ADR-062)

drop = rollback; no partial commit; replay-same-id answers from the claim

Direct-begin() routes

drop = rollback (same mechanics, no claim replay)

Single-statement autocommit writes

statement-atomic

Multi-system non-tx sequences (DB row THEN blob delete: contacts, contact/report attachments, court orders)

a cut between the two leaves an orphan blob — the standing convergence owner is the orphan-blob janitor issue #1274 (pre-existing exposure via client disconnect; unchanged by this ADR)

Commit-phase cut

outcome unknown — the D2 db-outcome-unknown class exists precisely for this

Background jobs cut by deploy (the 5s WORKER_DRAIN_DEADLINE; this row replaced "Batch routes cut by deploy", retired with the class by § Amendment — #1571)

the attempt ends interrupted at the engine’s boundary — or crash when the process died first (a heartbeat older than 30s, classified by any replica’s scan); a convergent kind re-queues as attempt + 1 up to max_attempts 3, a consent kind ends failed — the attempt ledger makes the cut VISIBLE through the poll instead of abandoning it (the money engines stay crash-resumable by their own ADRs' contract: ADR-055/056/057)

One sharp edge stated honestly: sqlx 0.8 returns a dropped pooled connection through an unbounded async ping (the connection waits for Postgres ReadyForQuery). Under a wire blackhole a pool slot can therefore wedge past statement_timeout, bounded only by the TCP stack and the pool’s 30-minute max_lifetime. The acquire cliff sheds load meanwhile (typed 503s — the designed degraded capacity). TCP keepalives via PgConnectOptions are enabled if the API offers them (implementation-verified). Health probes avoid this trap entirely by never using the serving pool (D4).

D2 — Phase-aware DB error taxonomy

One context-free mapping cannot be honest: retry safety depends on the request phase, not just the sqlx variant. The classifier is a pure function in craig-common (it must not depend on craig-db — dependency direction), consumed through phase-specific ApiError constructors; the funnels supply the phase.

Phase (constructor) Condition Status / problem type Retry signal

acquire — from_db_acquire

PoolTimedOut, PoolClosed

503 service-unavailable

Retry-After: 5 — ONLY here. The request was refused before any work; retry is truthfully cheap.

statement — from_db_statement

SQLSTATE 57014

504 db-timeout; detail: "canceled — statement timeout or administrative" (57014 is query_canceled, not uniquely a timeout)

none on the wire; in-tx the work is rolled back

statement — from_db_statement

connection family: Io, Tls, SQLSTATE 08*, 57P01/57P02/57P03. Protocol is EXCLUDED — production code synthesizes sqlx::Error::Protocol for serialization failures (subsidy import finalize), which must never read as retryable connection loss

503 db-connection-lost

none

commit — from_db_commit

the connection died during COMMIT (connection family) — the server’s verdict never arrived

503 db-outcome-unknown — the commit may or may not have landed

none — no retry invitation on an unknown outcome. A server-REPORTED commit failure (serialization failure, deferred constraint, statement cancel) means the transaction aborted — outcome KNOWN — and rides the ordinary classifier mapping instead.

any

everything else

500 internal (redacted, unchanged)

—

ceiling middleware

elapsed

504 request-timeout

none

  • The blanket From<sqlx::Error> impl becomes manual and applies the conservative statement-phase mapping — the safety net for unswept sites. The Db field keeps #[source].

  • Full variant decision table (no variant undecided): PoolTimedOut/PoolClosed → acquire-class 503 · Database(code) per the SQLSTATE rows above, other codes → 500 · Io/Tls → db-connection-lost 503 · Protocol → 500 · RowNotFound, TypeNotFound, ColumnIndexOutOfBounds, ColumnNotFound, ColumnDecode, Decode, Encode, Configuration, Migrate, WorkerCrashed, others → 500 (programming/config errors, not degradation).

  • No retry-safety promises ride the wire details: the BFF re-render mints a fresh client_request_id today, and the classifier cannot know route idempotency. Per-class retry semantics are documented HERE; the SDKs (which retry same-id per ADR-062) cite this section. Retry-After is variant-specific — the rules eval-timeout design explicitly declined it (no truthful estimate) and that decision stands.

  • map_begin_error is deleted — subsumed by from_db_acquire; keeping it would be pre-1.0 compat residue. Funnel arms: begin → acquire-phase; domain statements → statement-phase; commit → commit-phase (a connection loss during COMMIT is exactly the outcome-unknown case, today mapped to a plain 500).

  • Coverage is enforced, not promised: a new xtask lint (allowlist + monotonic shrink, the quality-budgets idiom) bans direct ApiError::Db(/Self::Db( construction and sqlx-typed map_err(ApiError::internal) outside craig-common. The implementation sweep works the census in Appendix B — Classifier sweep census (U5; the lint keeps it closed); the lint keeps it closed.

  • Untouched, verified disjoint: craig-security’s dead-letter classify_sqlx (MQ plane) and craig-mq’s inbox savepoint 57014 handling — neither converts into ApiError.

  • OpenAPI: utoipa cannot see middleware. A shared Modify adds the 503/504 problem responses to every operation in every service’s ApiDoc; the committed API pages regenerate in the same commits (#1022 gate).

D2a — Edge pass-through

  • BFF (craig-web): upstream 503 → 503, 504 → 504; all other upstream 5xx stay 502 (correct gateway semantics — 502 means "the upstream failed", 503/504 alone carry retry meaning). UpstreamError::Status carries no headers, so the BFF does NOT forward Retry-After (it renders HTML to humans; recorded). Mutation handlers keep redirect + flash; the flash copy becomes class-appropriate ("busy — try again shortly" vs "timed out"). The download proxy’s 5xx-as-data contract is unchanged (recorded) — on get_stream since § Amendment — #1572 (get_bytes deleted).

  • craig-intake (public portal): the sink stops flattening upstream 503/504 into a redacted 500 — the public edge keeps the typed posture.

  • craig-cases: the rules-upstream guard and the matching-error guard (both have 503-only arms today) extend to 504.

All of this is pre-1.0 breaking and rides the CHANGELOG.

D3 — The honest durability claim

  • Work that was already staged (outbox rows) before or during the stall drains when the DB recovers: the OutboxWorker’s warn-and-retry loop plus lease-healed claims. Delivery is at-least-once with consumer dedup — the outbox’s own contract; this ADR does not upgrade it to exactly-once and no test may claim otherwise.

  • NEW work while the DB is down cannot become durable, and therefore fails typed (503 at the acquire cliff / 504 at the statement kill). There is no queueing fig leaf.

  • Bounds: outbox backlog is bounded by DB disk (the DB-up/broker-down case); the DLX tier (ADR-059) is a consumer-side mechanism, not the pending-outbox path; broker-down ≠ DB-down and keeps its existing posture (ADR-003/ADR-059).

D4 — Health: dedicated-connection probes + saturation hysteresis; readiness unchanged

  • Probes never touch the serving pool. Reachability = a fresh dedicated PgConnection per probe, 2s overall bound including connect (the compose healthcheck window is 3s — the probe must answer inside it). Dropping a non-pooled connection is a socket close — none of the pooled return-ping hazard. This also removes today’s amplification: the unbounded /healthz SELECT 1 through the pool wedges a connection per hit under a wire stall.

  • /readyz semantics unchanged: reachable ⇒ ready. Pool saturation NEVER gates readiness — flipping readiness on latency invites the restart/eviction flapping the ratified direction forbids (ADR-061 alignment). No contradiction with the 2s bound: pool wait cannot affect a dedicated connection.

  • DbSaturation hysteresis, fed by the existing 15s pool-probe loop: a probe is BAD when its acquire wait exceeds 2.5s (half the cliff) or times out; degraded after 2 consecutive BAD (~30s of signal); clears after 4 consecutive OK (~60s). Exposed as the new db_pool_degraded gauge (0/1) and the /healthz database value ok|degraded|error.

  • The probe task decouples from telemetry: today it spawns only when metric registration succeeds and non-otel builds skip it entirely. Functional health cannot depend on observability being compiled in — the probe always runs and feeds health state; metric emission is the optional part. Startup state is ok; the probe task is supervisor-watched (Observed).

  • /livez untouched. The deployment guide gains the db_pool_degraded alert row (the worker-staleness convention’s sibling).

D5 — Load-shed / circuit-break: the pool is the admission control, stated precisely

Judgment-protocols comparison (all in-stack options considered):

Option Verdict

Pool acquire cliff + request ceiling (CHOSEN)

Admission control lives at the constrained resource: the fixed 5s cliff sheds to a typed 503 exactly when DB capacity is exhausted, with no proxy metric to mis-tune; the pool also caps the reconnect herd against a recovering database at max_connections — the breaker’s classic protective role, provided structurally. Zero new dependencies or feature enables. Scale remedy stays capacity + replicas (#1160).

tower LoadShed + ConcurrencyLimit

A second admission bound ABOVE the pool that must be sized against max_connections forever (two knobs that fight); the features are compiled nowhere in the graph today; axum’s Infallible services need HandleErrorLayer plumbing. Rejected as overengineering.

Circuit-breaker crate (failsafe, recloser, …)

A new dependency and per-route trip state duplicating what the acquire cliff provides at the resource itself; its half-open probing is already served by the pool’s bounded reconnects. Rejected.

Stated precisely: the pool is a connection-concurrency cap with a bounded (5s) per-request wait — it is NOT a circuit breaker. It has no open state, no cooldown, no pending-waiter cap: during a full outage every DB-bound request parks one acquire future for ≤ 5s and then fails typed, so at arrival rate R roughly R×5 futures are parked (1,000 rps ⇒ 5,000 parked futures — well inside tokio’s envelope; the arithmetic is the recorded justification for not adding a waiter cap). A hysteresis-driven fast-fail (shed at 0s while db_pool_degraded is set) is explicitly DEFERRED, with its trigger recorded: operators needing sub-5s shed under sustained outage. The per-IP rate limiter (429) and the authz/rules eval budgets keep their existing roles.

Amendment — #1571 — Background jobs; the Batch class retires (Accepted, 2026-09-18)

Standing. Proposed 2026-09-17 with the approved plan; Accepted 2026-09-18 at that plan’s close-out (U8, #1940 — plan Background Jobs (#1571), archived). D1 / D1a / D1b above are restated to the as-built; this section records what changed and how it landed (As-built notes).

Scope — the class table shrank to Standard 20s | Extended 300s. CeilingClass::Batch, BATCH_REQUEST_CEILING, BATCH_CALLER_BUDGET, the 4-arg CeilingConfig::with_durations and the admin-replay auto-entry went with the close-out (U8, #1940), AFTER the admin-replay fix: landed (#1941 — an index / batching defect, not a duration class). Admin-replay is Standard by absence (class_for on a table miss; pinned by admin_replay_is_standard), on the #1941 bound MEASURED on the devstack test plane (PG 18, a 100 000-row scratch outbox, two samples — crates/craig-api/tests/admin_replay_battery.rs::a_full_call_restages_the_cap_under_budget_with_a_resume_cursor): one call re-stages at most RESTAGE_MAX_BATCHES_PER_CALL 20 × RESTAGE_BATCH_ROWS 5 000 = 100 000 rows, each batch its own execute_within_tx under the 10 s domain budget; a full 100 k-row call took 636 / 627 ms wall (≈ 0.63 s), the slowest single batch 33.0 / 30.8 ms (≈ 0.3 % of the 10 s SET LOCAL statement_timeout; the whole call ≈ 6 %), and the (created_at, id) index built in 23.8 / 21.1 ms (≈ 22 ms) — two orders of magnitude inside the 20 s Standard ceiling; a window past the cap is walked by more / resume_from, never by a longer ceiling. Four registered Batch routes were FALSE Batch — the ceiling sheltered nothing — and reverted to Standard with no 202: financial claims/generate and rules promote (execute) ride the BUDGETED claim_first (the 10 s SET LOCAL) inside one short tx; security archive/purge is a bounded slice (PurgeParams 1..=100, selection EMPTY until DFCS names a schedule); reporting afcars/generate was the #949 zero-record stub until P-D2 flipped it to the afcars_generate job (#2144: 202 + Location, the NCANDS shape; its claim transaction stays Standard; P-D4 (#2127) retires the marking-only transmit route). The two reporting export POSTs (ncands|afcars/{id}/export) flipped to Extended, paired with the BFF’s per-request extended budget (streaming downloads landed as #1572 — § Amendment — #1572, Accepted 2026-09-20). The eight remaining engines — placement expiry-sweep/run, security archive/run, rules promote/preview, reporting ncands/generate, financial subsidy-payments/generate, subsidy-imports/{id}/finalize, subsidy-reviews/sweep/preview, sweep/{run_id}/execute — became background jobs on five owning services (placement, security, rules, reporting, financial).

D1a — claim_first_unbudgeted is deleted. Both census sites (ncands generate’s 10 k-row UNNEST, the sweep’s pinned-set write) moved to the worker plane inside their jobs (#1936, #1939 — the helper went with its last site). The invariant is: every HTTP-plane domain statement runs under the 10 s budget; long statements belong to jobs, which ride the session default (30 s, the worker-plane authority). No unbudgeted claim variant survives, claimed or unclaimed.

The reporting → cases hop is no longer a Batch exception. D1’s whole-FFY export hop became PAGED BY REFERRAL (#1936) under a FIXED cohort: GET /v1/cases/ncands-export?ffy&as_of&after&limit≤500 returns whole referrals (never split across pages) from received_at ∈ [ffy) AND created_at ≤ as_of (as_of = the job’s queued_at), ordered (received_at, id), each page under the 8 s S2S hop budget, inside reporting’s job; cases' Batch row and reporting’s hop_budget went with it. Appendix A — S2S client census (per-hop budget and synchronous depth) carries the row.

Background jobs — the model. A job is a LOGICAL resource; executions are ATTEMPTS. Per service, behind ONE craig_api::jobs module (the request_claims ×8 precedent): background_jobs (id = the claim’s entity_id; kind, dedup_key, lease_key, typed input / progress / result, a categorical error, owner_instance, version) plus background_job_attempts (outcome ∈ succeeded | failed | interrupted | crash | lost_proof).

  • Enqueue = the ADR-062 claim transaction, on all eight. Each route takes a REQUIRED client_request_id; claim_first is the tx’s first statement; every CONSENT gate stays synchronous in that tx with its typed 4xx (finalize’s enter_finalizing; sweep execute’s token / CAS / authority refusals); the arbiter is a partial-unique index (jurisdiction, dedup_key) WHERE state IN ('queued','running') → typed 409 job-already-active (problem_types::JOB_ALREADY_ACTIVE); the row is inserted queued; commit; 202 with the JobView body plus Location: /v1/<svc>/jobs/{id}. The same client_request_id replays the SAME job (202 again, whatever its state); a fresh id is a new job.

  • The executor. Per service, owner-pinned, Criticality::Critical (a PROMOTED contested worker anchor); dispatch by lease_key (one running job per key per instance); 4 permits, one RESERVED for consent kinds; a 5 s heartbeat (UPDATE … WHERE id AND state = 'running' AND owner_instance = me; 0 rows ⇒ the engine future is dropped); a 15 s scan, the first at boot; a 30 s stale classification covering running rows (stale heartbeat ⇒ attempt crash) AND queued rows (aged past 30 s ⇒ the owner died between commit and handoff).

  • Consent kinds vs proof-less kinds. import_finalize and sweep_execute carry an in-memory ADR-074 proof that cannot leave the process: a stale queued row is lost_proof — terminal failed; the caller re-POSTs with a fresh id. The six proof-less kinds (expiry_sweep, archive_run, subsidy_generate, ncands_generate, promote_preview, sweep_preview) may be ADOPTED by any replica (CAS owner_instance + version) — the one bounded cross-replica pickup.

  • Recovery. interrupted (the shutdown token at the engine’s boundary inside WORKER_DRAIN_DEADLINE 5 s) and crash re-queue a convergent kind as attempt + 1 up to max_attempts = 3, then failed(exhausted); a consent kind ends failed on its first crash. succeeded and failed are the ONLY terminal states and are IMMUTABLE (the terminal UPDATE is by id + version).

  • Retention is claim-joined, not arithmetic. The pruner (knob CRAIGBACKGROUND_JOBSWINDOW_DAYS, default 31, 0 = disabled) deletes only TERMINAL jobs older than the window whose claim row no longer exists — a claim kept forever keeps its job forever; attempts go with their job.

  • The poll is generic and read-only. GET /v1/<svc>/jobs/{id} → JobView, authorized on a NEW ResourceType::BackgroundJob ({j}-authz-background_job.json ×2, bootstrapped per environment BEFORE the first image that consults it); a deny is the fleet’s typed 403, a missing row 404, no existence collapse; Cache-Control: no-store. No GET writes anything for any kind: the sweep token is an explicit single-use POST …/sweep/runs/{run_id}/token (the job succeeded, the run previewed, started_at + 15 min > now — else 409 sweep-preview-expired; a second call 409 sweep-token-issued; no-store; behind the BFF’s POST CSRF path).

  • The ONE engine change is a &JobBoundary (the CancellationToken + a progress counter — as-built, erratum 2) checked at each engine’s natural boundary (expiry per home, finalize per record, archive per batch, generation per child batch; ncands has none before its commit); archive additionally gains run_passes with its `TableState`s preserved across passes.

  • The drain gap moved and closed. D1b’s "Batch routes cut by deploy" row retired with the class: the 20 s HTTP drain that abandoned a 600 s route became the 5 s worker drain, CLOSED by the attempt ledger + stale classification — a cut job reads interrupted / crash in its attempts and follows the recovery rule above.

Honest residue. No cross-replica pickup for consent kinds — the ADR-074 proof cannot leave process memory, so a stale queued consent row is lost_proof, never adopted (the deferred pickup is a follow-up on the plan; it needs a durable proof this amendment does not design); the sweep run’s non-resumability becomes VISIBLE through the poll (a consented / executing run flips failed, counters PRESERVED); five new BLOCKING worker anchors in the contested census (worker.craig-placement.main.watch.4, worker.craig-security.lib.watch.3, worker.craig-rules.main.watch.3, worker.craig-reporting.main.watch.3, worker.craig-financial.main.watch.3); the sub-second commit-before-handoff window makes lost_proof a new visible failure class (pinned by the plan).

As-built notes (U1–U8; the plan page’s errata, restated). Where a unit’s landing differed from the model above, the as-built reading is the truth:

  • U1 (#1933, the substrate + the placement pilot). Unknown / forged body fields answer the fleet extractor’s 422 validation-failed, not a typed 400. The engine seam is ONE &JobBoundary (the CancellationToken + a progress counter) checked once per home. A queued row’s staleness is measured from its owner’s LAST sign of life — GREATEST(queued_at, heartbeat_at), the owner keep-aliving its own queued backlog every pass — so a row waiting behind a permit or a lease key is never adopted or failed lost_proof while its owner lives. lease_key is NULLABLE. drain_pending is the ONE test seam.

  • U4 (#1936, reporting ncands_generate). The plan’s one lease-less kind. resource is empty (no submission GET exists; the submission id equals the job id in the result). Same-tx completion is the substrate’s complete_in_tx, keyed on (id, running, owner, attempt) — never the version, which the heartbeat bumps. The two export POSTs are Extended, paired with the BFF’s post_extended; afcars/generate rides Standard.

  • U5 (#1937, financial subsidy_generate). The hourly generator tick keeps taking the subsidy-gen lease directly and SKIPS (info) while a job holds it; a job attempt that finds the tick holding it reads waiting_for_lease (D6 wrote the tick as the waiter). claims/generate rides Standard.

  • U6 (#1938, financial import_finalize — the first consent kind). The pass loop ends on ANY batch status other than finalizing (staging = live rejections is a pass-terminal succeeded; aborted is unreachable inside finalize). failed(no_progress) carries NO result (result is present iff succeeded) — remaining_staged / passes ride error.detail. resource_type is the path token financial/subsidy-imports. input is { batch_id, as_of } (the business date captured at enqueue). The xtask tool’s 20-pass loop and mirrored 610 s const are gone (POST-once + poll).

  • U7 (#1939, financial sweep_preview + sweep_execute + the token POST). The token POST consults the supervisor review_sweep Update row AND the background_job read row on the preview job (its creator, or an admin); a run no preview job wrote is 409 sweep-run-state for everyone, and the execute enqueue’s window refusal shares the token POST’s 409 sweep-preview-expired. The preview result is PreviewSweepResult — the pinned sets plus a CLOSED token_state (available | issued | expired) and NO execute_token / expires_at. mark_run_failed PRESERVES counters by COALESCE under the guard state IN ('observed', 'consented', 'executing') — a consented run failed before its attempt started keeps NULL counters, not zeros. claim_first_unbudgeted deleted with its last site.

  • U8 (#1940, the close-out). CeilingClass = Standard | Extended; BATCH_REQUEST_CEILING, BATCH_CALLER_BUDGET, their const-assert, the batch duration, the 4-arg with_durations, the built-in admin-replay entry and CeilingConfig::templates() (zero callers — the coverage guard takes the raw table) deleted; the CLI transport’s post_batch helper + the clients/mod.rs macro arm deleted (zero callers after U2 / U4 / U5); admin-replay Standard by absence with the #1941 bound above; every service ceiling table Batch-free and its coverage test green with zero Batch rows; the post-close-out grep (CeilingClass::Batch|BATCH_REQUEST_CEILING|BATCH_CALLER_BUDGET|post_batch| post_empty_batch over crates / services / xtask) finds nothing.

Amendment — #1572 — Streaming downloads; the download GETs move to Standard (Accepted, 2026-09-20)

Standing. Proposed 2026-09-19 with the approved plan; Accepted 2026-09-20 at that plan’s close-out U2 (#1947 — plan Streaming Object-Store Downloads (#1572), archived; epic &97; U1 #1946 the store + the eight backend handlers, U2 #1947 the edges + this acceptance). D1a’s class table, its streamed-body sentence and its BFF pairing bullet above are restated to the as-built; this section records what changed and why.

Scope — the Extended class keeps only uploads and the two export POSTs. The nine download GET rows (cases ×3, exchange ×1, intake ×1, placement ×2, reporting ×2) leave the Extended table — Standard by absence — because their handlers no longer buffer: Store::get_stream answers the response head after ONE object head() and streams the body as lazy 8 MiB ranged reads whose transport frames are forwarded, never collected (no allocation proportional to the object or the chunk). Each chunk request keeps the store’s existing per-request total timeout and fixed retry policy (#1523), and object_store’s own ETag-ranged body resumption; the worst case with no bytes flowing is the retry budget, exposed as DEFAULT_CHUNK_DEADLINE (100 s). Each service’s ceiling_table_tests gains every_extended_row_is_a_post — the one-directional coverage guard cannot pin a deletion.

The streamed-body doctrine (restated into the D1a "Mechanics" bullet at U2). The ceiling bounds the response head; a streamed body is bounded UPSTREAM by the store’s chunk deadline and, at every first-party edge, by an idle budget derived from it (DOWNLOAD_IDLE_BUDGET 120 s = DEFAULT_CHUNK_DEADLINE 100 s + 20 s headroom, const-asserted DEFAULT_CHUNK_DEADLINE ≤ DOWNLOAD_IDLE_BUDGET in craig-store for the DEFAULT; a raised request_timeout_secs past 36 — 3 × 36 + 10 = 118 ≤ 120 — is ONE tracing::warn! at Store::build, never a refusal) on a dedicated streaming client (craig_common::http::build_streaming_client: connect 5 s, read_timeout = the idle budget, NO total; both public builders share one private base builder, so the lint allowlist stays at one site) with the head awaited under tokio::time::timeout(DEFAULT_TIMEOUT) (30 s) — a head timeout records the outbound sample itself and is the untyped transport class (502 at the BFF). Never a total budget: a total budget on a body re-creates the class on the caller side. A failed chunk, a 412 from if_match, or a blob deleted mid-stream ENDS the body — the connection closes and the client detects truncation by Content-Length; no status can change after the head. Body failures are logged inside the request span (method / route and the X-Request-Id correlation id, recorded on that span as request_id since #1953) and counted (download_stream_outcome_total{outcome = completed | failed | abandoned}, abandoned = the peer dropped the body before either end) because the head-scoped HTTP metrics never see them. The guarantee is two-sided since #1951: DOWNSTREAM, every CRAIG HTTP server (the ApiServer services, craig-intake on its plain and in-process-TLS paths, the BFF edges craig-web and craig-portal, craig-intake-keyring) accepts on craig_common::write_idle, which ends a connection whose writes make no progress for RESPONSE_WRITE_IDLE_BUDGET (120 s, beside the ceilings; re-armed by every accepted write, never a total). The stopped reader’s body is dropped and counts abandoned. hyper 1 has no write timeout, and its HTTP/1 dispatcher stops polling a body whose writes stall, so the bound sits on the connection’s IO, not in a tower layer. It is per connection: an HTTP/2 peer (intake’s TLS ALPN, or h2c prior-knowledge where hyper-util http2 is compiled in) that withholds flow-control credit is not covered.

Content-Length and compression. Attachment downloads are exempted from the backend CompressionLayer on every surface (a NotForAttachments predicate: any response carrying Content-Disposition), so Content-Length — which the buffered body’s size hint already produced — survives streaming; text exports lose gzip. Downloads carry Cache-Control: no-store end to end (the helper sets it; every edge forwards it with Content-Length, Content-Type and Content-Disposition — the portal additionally under its own global no-store layer). The four craig-web download routes now forward the backend’s Content-Type — the attachment routes lose the constant application/octet-stream, the two exports go from text/plain; charset=utf-8 to reporting’s bare text/plain (pre-1.0 Changed; safe under the edge-wide nosniff layer + Content-Disposition: attachment).

Caller pairing correction. The table’s "CLI export fetches" never existed in code: the CLI has no download commands (its one export fetch is the Standard rules JSON over the shared client). The BFF pairs the Extended budget ONLY on post_extended (the two export POSTs) and post_multipart (uploads); its download proxies — craig-web ×4, craig-portal ×1 — ride the streaming client through Transport::new(caller, http, streaming_http) + get_stream(base, path, user) → UpstreamDownload (any upstream status is data; Err is transport-only), and the intake partner proxy through Extension<StreamingHttp> on its partner nest (the BFF’s head under DEFAULT_TIMEOUT, intake’s under its own Standard 20 s ceiling — no separate timeout; the body under DOWNLOAD_IDLE_BUDGET at every edge; a non-2xx head never streams — the flash arms and intake’s #933 buffered redaction are unchanged); the BFF get_bytes is DELETED and intake’s Extended download row with it (every_extended_row_is_a_post ×5). HEAD on a backend download route issues zero range reads; the edges keep forwarding the GET they issue today.

Deferred, each a filed issue. Resumable downloads (Range / Accept-Ranges / If-Range, #1948; since delivered: a single range streams only its slice through Store::get_stream, 2026-11-08); a trailing-digest audit on streamed reads (#1949); the rules export’s raw-name Content-Disposition (fix:, #1950); the fleet-wide server-side write-progress timeout (#1951); the X-Request-Id on the request span so body-failure lines carry it (#1953); the BFF Transport caller label per host — craig-portal’s outbound samples read caller="craig-web" (fix:, #1954); the build_streaming_client sites in the contested census (#1955).

Amendment — #2478 — Depth 3 is accepted under nested, const-asserted budgets (Accepted, 2026-11-12)

Standing. Accepted 2026-11-12 by maintainer ruling on #2478. Documentation only: it rules on a state the code already has and changes no budget.

The trigger fired. D1 rejects absolute deadline propagation "while the synchronous S2S graph has depth ≤ 2" and names its revisit trigger, "the graph deepens past 2". The warm graph has been three deep on every placement-facts read since the federal ICWA-status consult landed (#1993, ADR-073): craig-placement → craig-cases → craig-rules. Appendix A (A.1) is the census that records it. A cold authorization cache adds one hop to any chain into an engine-bearing callee; that predates D1 and is not the depth D1 measured.

Ruling. Deadline propagation stays rejected. A three-deep synchronous chain is accepted when it is contained: the innermost hop’s budget plus the processing margin fits inside the budget of the hop that carries it, and that hop’s partition fits the route’s ceiling, each as a compile-time assertion. Under containment the specific-beats-generic inequality still holds at every level: when the innermost service is the slow one, the middle service’s typed refusal is answered inside the outer hop, so the outer caller reports the hop that failed and never its own ceiling.

The assertions that make it hold (services/craig-placement/src/eligibility.rs, with the budgets they name):

Assertion Values

ICWA_STATUS_BUDGET + MARGIN_MS ⇐ CASES_FACTS_BUDGET: craig-cases' nested consult of craig-rules fails typed inside craig-placement’s child-facts read.

2 s + 2 s ≤ 4 s

CASES_FACTS_BUDGET + RULES_CONSULT_BUDGET + MARGIN_MS < STANDARD_REQUEST_CEILING: an activation’s facts read and its own consult fail typed before the ceiling.

4 s + 4 s + 2 s < 20 s

CASES_FACTS_BUDGET + RULES_CONSULT_BUDGET + MATCHING_CONSULT_BUDGET + MARGIN_MS < STANDARD_REQUEST_CEILING: the facts read, the merged consult and the whole matching fan-out fail typed before the ceiling.

4 s + 4 s + 8 s + 2 s < 20 s

ICWA_STATUS_BUDGET is declared once, in craig-cases-contracts (placement_facts.rs), so the service that spends it and the service that budgets for it read the same constant; craig-cases bounds the consult by the smaller of it and its rules client’s hop budget (icwa_status.rs).

A fourth hop needs a new ruling. Containment divides a fixed budget: every level takes its own margin out of the level above, and the 4 s facts read already leaves its nested consult 2 s. A hop nested inside that consult would have nothing left to be typed within. So a change that would make any synchronous chain four deep, or that nests a second chain three deep without the assertion pair above, does not land on this amendment: it returns to the maintainer, with deadline propagation and a depth cap as the alternatives to weigh.

Consequences

  • Caseworkers and S2S callers see typed, bounded failures — worst-case time-to-error on a Standard route drops from 30s (client transport error) to ≤ 20s (server-typed 504), and for the common single-slow-component cases to 5s/8s/10s with the specific diagnosis.

  • Pre-1.0 breaking changes (CHANGELOG’d): 57014 becomes 504 (was 500-after-30s); PoolTimedOut becomes 503 fleet-wide (was begin-path-only); commit-phase failures become 503 db-outcome-unknown (was 500); BFF/intake/cases edges pass 503/504 through; db_statement_timeout_ms gains a 10s floor.

  • Existing tests pinning 500-on-DB-error or BFF-502 are updated as part of the same change — a legitimate oracle change for a deliberate semantic change, called out per commit (testing-discipline).

  • The C21 pool-contention oracle promotes to load-robust shape assertions (wins < the acquire bound; timeouts ≥ ~the bound — never exact milliseconds, per the harness’s own "load shifts latencies, not counts" note).

  • Filed at acceptance, two since landed: backgrounding the Batch engines (202 + poll — removed the 600s class’s reason to exist) → #1571, LANDED 2026-09-18 (§ Amendment — #1571, Accepted; the class is deleted); streaming object-store downloads → #1572, LANDED 2026-09-20 (§ Amendment — #1572, Accepted; the nine download GETs are Standard by absence, the body outside the ceiling by design). Still deferred as a filed issue: hysteresis fast-fail (#1573; trigger recorded above).

Appendix A — S2S client census (per-hop budget and synchronous depth)

Refreshed 2026-10 (#1781) against every class = "s2s-client" entry in contested-surfaces.toml plus the in-request hops the registry does not anchor. Depth counts the synchronous HTTP hops on the longest chain from the first-party edge (BFF, portal, intake, CLI), the edge → service hop counting 1; cold adds the callee’s authz lazy load when the callee is engine-bearing (cases, composition, exchange, financial, placement, reporting, security — craig-rules reads its own database, so a hop into rules adds nothing). Worker-plane rows count from the worker. An edge hop (A.3) is depth 1; the callee’s own A.1 hops and its cold lazy load continue the chain. A.1 is the population D1’s ≤ 8s rule governs.

A.1 — In-request service-to-service hops

Caller → callee (call) Site · budget const Budget Depth warm / cold Registry id

cases → rules (investigation safety assessment)

services/craig-cases/src/api/investigations/safety.rs · S2S_HOP_BUDGET

8s

2 / 2

s2s-client.craig-cases.rules-engine

cases → rules (screening surface read on a cache miss)

services/craig-cases/src/screening_surface_client.rs · S2S_HOP_BUDGET over mint + GET + body

8s

2 / 2

s2s-client.craig-cases.screening-policy

cases → rules (screening consult, concurrent evaluates)

services/craig-cases/src/api/reports/screening_consult.rs · S2S_HOP_BUDGET

8s

2 / 2

s2s-client.craig-cases.rules-screening

cases → rules (response priority, window, override)

services/craig-cases/src/api/investigations/response.rs · S2S_HOP_BUDGET

8s

2 / 2

s2s-client.craig-cases.rules-response

cases → rules (person-match evaluates, report person suggestions)

services/craig-cases/src/matching/mod.rs (evaluate_all_bounded) · S2S_HOP_BUDGET once over each report entry’s whole fan-out (up to 75 evaluates, 8 in flight), and as each evaluate’s own request timeout (#2283)

8s per entry

2 / 2

s2s-client.craig-cases.rules-engine

cases → rules (person-match ruleset metadata, once per request)

services/craig-cases/src/matching/ruleset_metadata.rs · S2S_HOP_BUDGET

8s

2 / 2

s2s-client.craig-cases.rules-engine

cases → rules (IV-E surface read, per-child consults)

services/craig-cases/src/ive_surface_client.rs, services/craig-cases/src/api/ive_assembly.rs · S2S_HOP_BUDGET

8s

2 / 2

s2s-client.craig-cases.ive-surface (surface read); s2s-client.craig-cases.rules-ive (consults)

cases → rules (ICWA status, nested in the placement-facts read)

services/craig-cases/src/icwa_status.rs · ICWA_STATUS_BUDGET (craig-cases-contracts)

2s

3 / 3

s2s-client.craig-cases.rules-icwa

cases → exchange (SSA screening run: stage, cancel, latest status)

services/craig-cases/src/exchange_client.rs · REQUEST_TIMEOUT, asserted ≤ S2S_HOP_BUDGET in services/craig-cases/src/api/ive_act.rs

5s

2 / 3

s2s-client.craig-cases.exchange

exchange → placement (a partner-reported education record, once per admitted report of the admin collection run, #3188)

services/craig-exchange/src/collections/placement.rs (report_education) · POST_TIMEOUT per report; the run stops after three posts in a row that say the owner is not taking reports, so a dead owner costs three budgets

3s

2 / 3

s2s-client.craig-exchange.placement

exchange → cases (open-stages pages, the admin catch-up walk)

services/craig-exchange/src/triggers/catchup.rs over services/craig-exchange/src/triggers/cases_reads.rs (open_stages) · ASSEMBLY_BUDGET per page

5s

2 / 3

s2s-client.craig-exchange.cases

financial → placement (subsidy eligibility)

services/craig-financial/src/placement_client.rs · REQUEST_TIMEOUT

5s

2 / 3

s2s-client.craig-financial.placement

financial → placement (caregiver bindings, portal payments)

services/craig-financial/src/placement_client.rs · PORTAL_BINDINGS_BUDGET

4s

2 / 3

s2s-client.craig-financial.placement-bindings

financial → cases (child date of birth, subsidy enrollment and activation)

services/craig-financial/src/subsidy/age_check.rs · DOB_S2S_BUDGET

4s

2 / 3

s2s-client.craig-financial.cases

financial → cases (party existence sweep)

services/craig-financial/src/subsidy/party_check.rs · PARTIES_S2S_BUDGET

4s

2 / 3

s2s-client.craig-financial.cases

financial → cases (permanency plan, guardianship activation)

services/craig-financial/src/subsidy/plan_check.rs · PLAN_S2S_BUDGET

4s

2 / 3

s2s-client.craig-financial.cases

financial → rules (subsidy-eligibility consult)

services/craig-financial/src/subsidy/age_check.rs · RULES_CONSULT_BUDGET

4s

2 / 2

s2s-client.craig-financial.rules-eligibility

financial → cases (subsidy import staging: each person, then the household)

services/craig-financial/src/api/subsidy_imports_stage.rs · STAGE_BUDGETS (S2S_HOP_BUDGET per read; the walk of up to 18 reads bounded at 15s, #2476)

8s per read, 15s walk

2 / 3

s2s-client.craig-financial.cases

placement → cases (child placement facts: matching, both activation sites, episodes)

services/craig-placement/src/cases_client.rs · CASES_FACTS_BUDGET

4s

3 / 3

s2s-client.craig-placement.cases

placement → cases (person display names, own principal)

services/craig-placement/src/cases_projection_client.rs · CASES_PROJECTION_BUDGET

4s

2 / 3

s2s-client.craig-placement.cases-projection

placement → security (worker contacts, portal unit detail; degrades)

services/craig-placement/src/security_projection_client.rs · SECURITY_PROJECTION_BUDGET

4s

2 / 3

s2s-client.craig-placement.security-projection

placement → rules (eligibility consult; matching fan-out)

services/craig-placement/src/eligibility.rs · RULES_CONSULT_BUDGET per consult, MATCHING_CONSULT_BUDGET for the whole fan-out

4s / 8s

2 / 2

s2s-client.craig-placement.rules-eligibility

any engine-bearing service → rules (authz ruleset lazy load on a cache miss)

crates/craig-authz/src/engine.rs (lazy_load) over crates/craig-rules-client/src/lib.rs (get_by_name) · LAZY_LOAD_BUDGET (elapse = the typed EvalTimeout 503, #2477)

2s; with the 5s DEFAULT_EVAL_BUDGET a check fits inside a caller’s 8s hop (const-asserted)

the cold column

s2s-client.craig-rules-client.lib

Const-asserted partitions under the 20s Standard ceiling: financial enrollment 5 + 4 + 4 + 4 + 2 < 20 (age_check.rs: placement, DOB, rules, parties, margin); financial guardianship activation 5 + 4 + 4 + 4 + 2 = 19 (plan_check.rs); placement matching 4 + 4 + 8 + 2 = 18 and both activation routes 4 + 4 + 2 = 10 (eligibility.rs); cases screening consult, response priority, the IV-E act and report person suggestions (matching/mod.rs: the metadata read, then one entry’s evaluate fan-out) 2 × 8 + 2 < 20; the nested ICWA hop ICWA_STATUS_BUDGET + MARGIN_MS ⇐ CASES_FACTS_BUDGET (2 + 2 ≤ 4, craig-placement). The authz lazy load composes inside a caller’s hop (LAZY_LOAD_BUDGET + DEFAULT_EVAL_BUDGET < S2S_HOP_BUDGET, 2 + 5 < 8, #2477). The person-suggestions partition covers a craig-rules that stops answering, which refuses at the first entry’s deadline. A report of several entries makes one fan-out per entry in turn, so a craig-rules that answers each inside its budget but slowly can still spend more than the ceiling across entries; no partition bounds that sum.

D1 revisit trigger. D1 rejects deadline propagation "while the synchronous S2S graph has depth ≤ 2" and names the trigger "the graph deepens past 2". The warm graph reached depth 3 with the ICWA consult: placement → cases → rules on every placement-facts read (ADR-073, the #1993 amendment). The trigger has fired; § Amendment — #2478 rules on it. A cold authz cache adds one hop to any chain into an engine-bearing callee; that predates D1 and is not the depth D1 measured. As built, the nested hop is contained: its budget plus the margin fits inside its caller’s hop budget (const-asserted), and the caller’s partition fits the ceiling. The amendment accepts that containment as the answer at depth 3.

A.2 — Worker, job and verifier plane (no inbound request)

Caller → callee (call) Site · budget const Budget Depth warm / cold Registry id

financial → cases (child date of birth, placement-activated billing, MQ inbox)

services/craig-financial/src/inbox/placement_billing.rs · CASES_S2S_DEADLINE

8s

1 / 2

s2s-client.craig-financial.cases

cases → rules (report auto-link, MQ inbox)

services/craig-cases/src/inbox/report_converted.rs · AUTO_LINK_DEADLINE over the pass; inside it the metadata read and each entry’s evaluate fan-out ride S2S_HOP_BUDGET (#2283)

10s pass; 8s per entry

1 / 1

s2s-client.craig-cases.rules-engine

reporting → cases (NCANDS referral pages, ncands_generate job)

services/craig-reporting/src/cases_client.rs · S2S_HOP_BUDGET per page

8s

1 / 2

s2s-client.craig-reporting.cases

reporting → placement, financial, cases (AFCARS producer pages, afcars_generate job)

services/craig-reporting/src/afcars/clients/mod.rs · S2S_HOP_BUDGET per page

8s

1 / 2

s2s-client.craig-reporting.afcars-producers

exchange → cases (SSN custody release and outcome, SSA worker)

services/craig-exchange/src/cases_client.rs · CUSTODY_TIMEOUT_SECS, OUTCOME_TIMEOUT_SECS

5s / 5s

1 / 2

s2s-client.craig-exchange.cases

exchange → cases (trigger outbound-principals reads, send worker)

services/craig-exchange/src/triggers/cases_reads.rs · ASSEMBLY_BUDGET

5s

1 / 2

s2s-client.craig-exchange.cases

cases → rules (screening-surface and IV-E surface verifiers)

services/craig-cases/src/screening_surface_client.rs, services/craig-cases/src/ive_surface_client.rs · S2S_HOP_BUDGET

8s

1 / 1

s2s-client.craig-cases.screening-policy (screening); s2s-client.craig-cases.ive-surface (IV-E)

financial → rules (subsidy authority verifier)

services/craig-financial/src/subsidy/authority/mod.rs · AUTHORITY_VERIFY_BUDGET

4s

1 / 1

s2s-client.craig-financial.rules-authority

reporting → rules (AFCARS surface verifier)

services/craig-reporting/src/afcars_surface/verify.rs · AFCARS_VERIFY_BUDGET

4s

1 / 1

s2s-client.craig-reporting.rules

admin-units snapshot read → security (verifier cadence, event leg; the shared body)

crates/craig-bootstrap/src/admin_units.rs · SNAPSHOT_READ_BUDGET over mint + GET + body

4s

1 / 2

s2s-client.craig-bootstrap.admin-units

cases → security (admin-units snapshot, this service’s own principal)

services/craig-cases/src/lib.rs (build_units_source) · SNAPSHOT_READ_BUDGET

4s

1 / 2

s2s-client.craig-cases.security-admin-units

composition → security (admin-units snapshot, this service’s own principal)

services/craig-composition/src/main.rs (build_units_source) · SNAPSHOT_READ_BUDGET

4s

1 / 2

s2s-client.craig-composition.security-admin-units

exchange → security (admin-units snapshot, this service’s own principal)

services/craig-exchange/src/lib.rs (build_units_source) · SNAPSHOT_READ_BUDGET

4s

1 / 2

s2s-client.craig-exchange.security-admin-units

financial → security (admin-units snapshot, this service’s own principal)

services/craig-financial/src/lib.rs (build_units_source) · SNAPSHOT_READ_BUDGET

4s

1 / 2

s2s-client.craig-financial.security-admin-units

placement → security (admin-units snapshot, this service’s own principal)

services/craig-placement/src/lib.rs (build_units_source) · SNAPSHOT_READ_BUDGET

4s

1 / 2

s2s-client.craig-placement.security-admin-units

reporting → security (admin-units snapshot, this service’s own principal)

services/craig-reporting/src/main.rs (build_units_source) · SNAPSHOT_READ_BUDGET

4s

1 / 2

s2s-client.craig-reporting.security-admin-units

rules → security (admin-units snapshot, this service’s own principal)

services/craig-rules/src/main.rs (build_units_source) · SNAPSHOT_READ_BUDGET

4s

1 / 2

s2s-client.craig-rules.security-admin-units

any engine-bearing service → rules (authz boot fetch, invalidation and TTL refresh)

crates/craig-rules-client/src/lib.rs (list_by_prefix, get_by_name) · none

the shared 30s client

1 / 1

s2s-client.craig-rules-client.lib

A.3 — Edge clients and constructors

Caller → callee Site · budget const Budget Depth Registry id

craig-web BFF Transport → every backend (JSON verbs)

crates/craig-bff/src/transport.rs, built in services/craig-web/src/main.rs · DEFAULT_TIMEOUT / DEFAULT_CONNECT_TIMEOUT; EXTENDED_CALLER_BUDGET on post_extended and post_multipart

30s / 5s connect; 310s

1

s2s-client.craig-web.main

craig-web CompositionClient → composition; plugin fetches → allowlisted hosts

services/craig-web/src/clients/composition.rs; services/craig-web/src/plugins.rs (manifest timeout, default 5s)

30s; 5s

1

s2s-client.craig-web.main

craig-web download proxies (get_stream)

services/craig-web/src/main.rs (build_streaming_client) · head DEFAULT_TIMEOUT, body DOWNLOAD_IDLE_BUDGET per read

30s head; 2 min idle

1

s2s-client.craig-web.downloads

craig-portal Transport → placement, financial

services/craig-portal/src/main.rs · DEFAULT_TIMEOUT / DEFAULT_CONNECT_TIMEOUT

30s / 5s connect

1

s2s-client.craig-portal.main

craig-portal document downloads

services/craig-portal/src/main.rs (build_streaming_client) · head DEFAULT_TIMEOUT, body DOWNLOAD_IDLE_BUDGET

30s head; 2 min idle

1

s2s-client.craig-portal.placement-downloads

craig-cli → every backend

services/craig-cli/src/client/mod.rs · DEFAULT_TIMEOUT / DEFAULT_CONNECT_TIMEOUT

30s / 5s connect

1

s2s-client.craig-cli.mod

craig-intake → cases (report forward, status, owner; JWS replay check) and → security (partner verify, signer key)

services/craig-intake/src/sink/cases_forwarder.rs, services/craig-intake/src/api/jws_replay.rs, services/craig-intake/src/api/partner_auth.rs, services/craig-intake/src/api/signer_auth.rs · the shared client (no hop budget; intake’s own 20s ceiling ends the request)

30s / 5s connect

1

s2s-client.craig-intake.main, s2s-client.craig-intake.main.build_shared_client

craig-intake attachment upload forward → cases

services/craig-intake/src/api/attachments.rs · EXTENDED_CALLER_BUDGET

310s

1

s2s-client.craig-intake.main

craig-intake attachment download proxy

services/craig-intake/src/main.rs (build_streaming_client) · head under intake’s Standard ceiling, body DOWNLOAD_IDLE_BUDGET

20s head; 2 min idle

1

s2s-client.craig-intake.cases-downloads

shared client constructor

crates/craig-bootstrap/src/lib.rs (build_shared_http_client → craig_common::build_shared_client) · DEFAULT_TIMEOUT / DEFAULT_CONNECT_TIMEOUT

30s / 5s connect

none of its own (its consumers' rows)

s2s-client.craig-bootstrap.lib.build_shared_client

admin-units unit-test helper

crates/craig-bootstrap/src/admin_units/tests.rs · test-only

not production

not production

none: the census prunes test-only module files (#2475)

Retired since the last revision: cases → rules via services/craig-cases/src/screening_policy.rs (replaced by the screening surface client, #1672) and reporting → cases detail hydration (cases_client.rs keeps only export_ncands).

Appendix B — Classifier sweep census (U5; the lint keeps it closed)

Site Today

financial subsidy maps ×7 (subsidy_error_map.rs, subsidy_agreements.rs, subsidy_review_sweep.rs ×5)

direct ApiError::Db(…​) wrap

the funnels' own begin/commit arms (crates/craig-api/src/lib.rs)

commit errors → internal

upload_attempts.rs, subsidy_mutations.rs acquire (and, until #1941, crates/craig-api/src/admin_replay.rs — since the fix its count and every re-stage batch run under execute_within_tx, the funnel’s own classifier; re-verified at #1940: no acquire site remains in the module)

→ internal

rules store map (services/craig-rules/src/api.rs + ~20 sites)

→ internal

reporting store maps (~30 sites incl. api/mod.rs rereads)

→ internal

composition src/write_support.rs + read paths (overrides.rs, user_delta.rs)

own begin(); bypasses even today’s PoolTimedOut 503

security archive (src/api/archive.rs, src/store/archive.rs)

→ internal

exchange store maps

→ internal

service error enums: GenerateError, EngineError, AttemptError::Sqlx, WriteError::Db, ArchiveError::Db

Db arms flattened

Alternatives considered

  • Absolute deadline propagation (header + per-statement re-budgeting): rejected at graph depth ≤ 2 — see D1. The revisit trigger fired at depth 3; § Amendment — #2478 keeps the rejection.

  • Lowering the session statement_timeout default so the typed 57014 always beats the ceiling: rejected — the session default is the worker-plane authority and ADR-062’s inbox lock-wait math derives from it; the funnel-scoped SET LOCAL delivers the same ordering on exactly the HTTP tx plane with zero worker blast radius.

  • tower timeout/load-shed layers and breaker crates: see D5.

  • One flat ceiling with per-route exemptions: rejected — the review census showed a real population of legitimate 25s+ routes; exemptions-by-default invert into the Extended/ Batch classes with caller-budget pairing instead.

Edit this page · latest