Plan: Stream Object-Store Downloads — Download GETs Move to the Standard Class (#1572)
- Archive record
- Status
- Errata
- Context
- Decisions
- D1 —
Store::get_stream: one head, then lazy ranged reads whose frames are forwarded, never collected - D2 — One response helper, eight swaps, no compression on attachments
- D3 — The edges stream; the caller pairing splits head from body
- D4 — The class shrinks by deletion and is pinned
- D5 — Pins at three levels, each proving what only it can
- D6 — Client surface, once
- D1 —
- Units — each
Relates to #1572; U2Closes #1572; U0 → U1 → U2 - Test matrix (by risk)
- Verification
- Rollout + risks
- Rulings (approved 2026-09-19, plan mode)
- Review log
Archive record
Merge requests: !1671 (U0 plan page + ADR-068 § Amendment — #1572 Proposed, Relates #1572) + !1674 (U1, Closes #1946) + !1675 (U2, Closes #1947 / #1572)
2026-09-20 — rev 3 approved in plan mode 2026-09-19 after a contextless round 1 (5 blockers) and the maintainer’s
plan-mode gate (14 findings + 8 corrections): the nine download GETs that rode ADR-068’s Extended (300 s) ceiling only
because their handlers buffered the whole blob before the response head (reporting ncands\|afcars/{id}/export/download,
cases contact / court-order / report attachments, placement home + portal documents, exchange ICPC attachments, the
intake partner proxy) stream end to end and are Standard by absence — 20 s to the response head, the body outside the
ceiling: Store::get_stream does ONE head() then lazy 8 MiB ranged get_opts reads carrying if_match: e_tag whose
transport frames are forwarded, never collected (no allocation proportional to the object or the chunk; a failed chunk,
a foreign overwrite’s 412 or a mid-stream delete ENDS the body short of Content-Length — no status changes after the
head); ONE craig_api::download::download_response helper (Content-Length / Content-Type / Content-Disposition /
Cache-Control: no-store + the outcome guard download_stream_outcome_total\{outcome = completed \| failed \| abandoned})
behind all eight backend handlers; attachment downloads exempt from the CompressionLayer on both surfaces
(NotForAttachments) so Content-Length survives; the six edge proxies (craig-web ×4, craig-portal, intake’s partner
route) stream on a dedicated idle-bounded client (build_streaming_client: connect 5 s, read_timeout =
DOWNLOAD_IDLE_BUDGET 120 s, derived from and const-asserted against the store’s DEFAULT_CHUNK_DEADLINE 100 s, NO
total; the head under DEFAULT_TIMEOUT at the BFF, intake’s Standard ceiling) through the BFF Transport::get_stream → UpstreamDownload (get_bytes
deleted), forwarding the backend’s headers; the nine Extended download rows deleted and pinned by
every_extended_row_is_a_post ×5, so EXTENDED_CALLER_BUDGET pairs uploads + the two export POSTs only; pins at four
levels — the on-demand ObjectStore double (exact demand at the poll boundary), the hermetic helper router, the
devstack-gated cases route legs (gated release, producer-lead bound, HEAD → zero range reads, DELETE mid-download, the
Garage 64 MiB leg) and the per-edge hold_release_upstream fixture a buffering route cannot pass. Rulings: R1 ranged
chunks + if_match, the edge budget derived from the chunk deadline; R2 the compression exemption + no-store; R3 pins
at three levels, no Toxiproxy leg; R4 backend HEAD issues zero range reads, the edges forward the GET; R5 SyncWrapper;
R6 the stalled downstream reader is #1951. ADR-068 § Amendment — #1572 Accepted (no new ADR); 14 errata recorded on the
page; follow-ups #1948 (Range), #1949 (trailing digest), #1950 (rules export CD fix:), #1951, #1953 (request id on
the span), #1954 (fix(bff) caller label), #1955 (census the streaming client sites).
Status
Done (2026-09-20) — !1675
- Anchors
-
#1572 (epic &97; children U1 #1946, U2 #1947 — U2 closes the anchor), ADR-068 § Amendment — #1572 (Proposed at U0 — the class-table row, the streamed-body doctrine, the CLI correction, the BFF pairing paragraph; Accepted at U2; no new ADR), ADR-068 § Amendment — #1571 (the two export POSTs flipped to Extended with "streaming stays #1572"), ADR-062 (§U digest-first uploads — the write-time digest the read path does not repeat), ADR-067 (
StoreOp::Getfault hook; the #1504 / #1523 store timeout + retry posture), #1404 (the ADR-068 program), #1948 / #1949 / #1950 / #1951 (follow-ups filed at U0), #933 (the intake proxy’s redaction, untouched).
Errata
Erratum (2026-09-19): U1’s outcome guard logs a body-stream failure inside the request span (method / route), NOT with
the X-Request-Id correlation id — the id lives in request extensions and on no span (D1 overstated it); recording it
on the request span is #1953. Closed by #1953: otel_propagation records the id on the http_request span as
request_id.
Erratum (2026-09-19): the outcome counter has a third value, abandoned (the client went away before the body ended),
beside completed / failed (D1 named two).
Erratum (2026-09-20): Transport::new(http, streaming_http) is LITERAL (D3) — the two mains build the second client with craig_common::http::build_streaming_client; a test site passes one bare client twice unless it exercises get_stream; the test-only #[derive(Default)] stays, its streaming client carrying no idle bound (E1).
Erratum (2026-09-20): Transport::get_bytes is deleted LAST, by the integrator, after every caller moved to get_stream; its two transport tests are REPLACED (get_stream_hands_back_5xx_as_data_not_error, get_stream_head_timeout_is_transport_error), never dropped (E2).
Erratum (2026-09-20): intake layers Extension<StreamingHttp> on the PARTNER nest only — the one nest serving download_attachment — and carries it on RouterConfig for the router tests; D3’s "the attachments nest and the partner nest" overstated it (the public attachments nest has no download route); NotForAttachments is wired as compress_when(DefaultPredicate::new().and(NotForAttachments)), craig-api’s shape (E3).
Erratum (2026-09-20): the four craig-web routes forward the BACKEND’s Content-Type (UpstreamDownload.content_type) — a visible pre-1.0 change on ALL FOUR: the two attachment routes lose the constant application/octet-stream, the two export routes go from the web constant text/plain; charset=utf-8 to the backend’s bare text/plain (download_response forwards reporting’s literal verbatim); safe under the edge-wide nosniff layer + Content-Disposition: attachment (E4).
Erratum (2026-09-20): intake’s 2xx download bodies stream through a download-only relay that forwards Content-Type / Content-Disposition / Content-Length / Cache-Control; the buffered #933 redaction path (relay_response) stays for non-2xx and for the upload / delete verbs; the change carries intake’s api/attachments.rs past B1’s 500 raw lines, so the download handler + its relay move to a new sibling module attachment_download (registered in api/mod.rs) rather than trimming tests; intake adds NO head timeout — its Standard 20 s request ceiling bounds the head (ceiling_middleware awaits next.run, i.e. the head, never a streamed body) while DEFAULT_TIMEOUT is the BFF’s head bound (E5).
Erratum (2026-09-20): get_stream’s head-timeout branch records the outbound sample itself (`record_completed(caller, target, "GET", 0, elapsed)) under the transport’s existing literal caller label "craig-web" — the portal mislabel is pre-existing and filed as #1954, not fixed here — and returns a plain anyhow::Error with no UpstreamError on the chain (→ UpstreamTransport → 502, the routes' generic flash unchanged) (E6).
Erratum (2026-09-20): the EDGE fixture is NOT a raw TcpListener writer (D5 named the wrong precedent): it is U1’s hold-then-release axum upstream (crates/craig-api/tests/download_response.rs) lifted into craig_test_lib::hold_release_upstream (DownloadPlan / HoldReleaseUpstream — the head + the first half, a gate, the rest on release(); the body fed from a channel) so the four edge crates share ONE copy; the idle budget is injected through build_streaming_client_with_idle(name, ver, idle) — the ONE read_timeout site — and build_streaming_client calls it with DOWNLOAD_IDLE_BUDGET (E7).
Erratum (2026-09-20): the xtask reqwest-builder allowlist for crates/craig-common/src/http.rs stays at 1 (D3 said 1 → 2): the lint counts Client::builder() AST sites and a private base_builder single-sources the shared policy for both public builders (E7, lint).
Erratum (2026-09-20): the EDGE pins are per ROUTE in-process router tests (craig-web ×4 — the crate’s first route-level download tests — craig-portal ×1, intake ×1) polled frame by frame (http_body_util::BodyExt::frame in craig-web; std::future::poll_fn + HttpBody::poll_frame — the same primitive, no new dev-dep — in the portal and intake): head-before-body against the held upstream, Content-Length / Content-Type / Content-Disposition / Cache-Control: no-store forwarded, the non-2xx arm on its existing oracle; the stall past the budget and the short-stall recovery run once per edge CRATE (one shared client); the BFF transport carries the five get_stream_* legs; every budget under test is INJECTED (nextest terminates a test at 120 s) (E8).
Erratum (2026-09-20): contested-surfaces.toml is re-pointed at the oracle text and the test id only (get_stream_hands_back_5xx_as_data_not_error); registering the build_streaming_client sites as census surfaces is #1955 (E9).
Erratum (2026-09-20): the const-assert pins the DEFAULT only (DEFAULT_CHUNK_DEADLINE ≤ DOWNLOAD_IDLE_BUDGET, in craig-store beside the const — the existing dependency direction); a raised request_timeout_secs is caught at boot by ONE tracing::warn! in Store::build naming both numbers and the constraint request_timeout_secs ≤ 36 (3 × 36 + 10 = 118 ≤ 120), which the deployment guide states (E10).
Erratum (2026-09-20): edge HEAD is unchanged (R4) — the edges forward the GET they issue today; backend HEAD landed in U1 (E11).
Context
ADR-068 (#1404) classed every download GET Extended (300 s) because the handlers buffer the whole blob before the
response head (Store::get → Bytes → Body::from), and the ceiling bounds request processing only up to the response
head (crates/craig-common/src/ceiling.rs, ADR-068 D1a). #1572 is the recorded follow-up: stream the body, so the
download routes rejoin Standard (20 s), the RAM spike goes, and EXTENDED_CALLER_BUDGET remains only for uploads.
A five-lane census, an anchor verifier, a design pass and the maintainer’s gate (2026-09-19) established:
The store.
-
One wrapper:
crates/craig-store/src/store.rsinner: Arc<dyn ObjectStore>;getcollapsesGetResultwith.bytes()and dropsmeta; nothing in the workspace streams or ranges a read. -
object_store0.13.2:GetOptions { range: Some(GetRange::Bounded(a..b)), if_match },ObjectMeta { size, e_tag }; a streaming GET already RESUMES body errors by ETag-ranged re-requests inside its retry budget (retry_streamin object_store’s client/get.rs);collect_byteskeeps its first two frames while filling a range-sized buffer (≈ 2× the range). -
The S3 client:
ClientOptions::with_timeout(request_timeout_secs)(default 30 s) is a TOTAL per-request deadline that runs until the body has finished; the retry policy is FIXED at 2 retries withretry_timeout = 3 × request_timeout(#1523).ClientOptionshas no idle timeout; disabling the total one re-opens the #1504 hang. The fault hookinjected_store_fault(StoreOp::Get)runs before the read. -
Store::getkeeps two whole-bytes callers:verify_stored_blob(crates/craig-store/src/attempts.rs) and retention boot (crates/craig-retention/src/boot.rs). The store exposes an overwritingputas well asput_create, and Garage ignores the create precondition; the protection is the digest-and-generation invariant — every legitimate writer of a key already passed the SAME declared digest, so writes converge byte-identical. Deleting an attachment removes the blob immediately after the row (best_effort_blob_delete).
The eight object_store-backed download handlers (all Body::from(data)):
-
reporting
services/craig-reporting/src/api/afcars.rs(download_export) andncands_export.rs; casesservices/craig-cases/src/api/contact_attachments.rs,court_orders.rs,report_attachments.rs; placementservices/craig-placement/src/api/home_documents.rs,portal_documents.rs(audits viaaudit_read(.., DocumentDownload)AFTER the fetch, before the response; another subject’s unit / document is 404 by contract); exchangeservices/craig-exchange/src/api/icpc/attachments.rs. -
Content-Disposition via
craig_store::content_disposition_attachment, Content-Type from the DB row or a constant;Content-Lengtharrives today from axum’s exact size hint on the buffered body; none setsETagorCache-Control; none supportsRange; none re-verifies a digest at read. -
The shared backend
CompressionLayer::new()(crates/craig-api/src/lib.rs; intake’s own inservices/craig-intake/ src/main.rs) stripsContent-Lengthfrom any response it compresses when the caller offersAccept-Encoding— on EVERY service. tower-http 0.6.8 offerscompress_when(predicate); craig-common already depends on tower-http. -
StoreError → ApiErrorlogs storage failures and HTTP metrics finish at the response head (crates/craig-api/src/http_observability.rs) — neither sees a failure inside a streamed body. -
B1 (500 raw lines per
services//src/api/.rs) hascourt_orders.rsat exactly 500 lines. -
Out of scope: the rules export (
services/craig-rules/src/api.rs, DB JSON, already Standard; its raw-name Content-Disposition is #1950); security’sreview_evidence.object_key(no download route).
The four edges, six download routes (each buffers, then the browser response buffers again):
-
BFF
get_bytes(crates/craig-bff/src/transport.rs):.timeout(EXTENDED_CALLER_BUDGET),.bytes(), on the transport’s ONE 30 s-total client (craig_common::build_shared_client,DEFAULT_TIMEOUT).send_with_metrics(crates/craig-common/src/telemetry.rs) records the outbound sample only aftersend().awaitreturns. An untyped transport failure isBffApiError::UpstreamTransport→ 502; the download routes themselves answer a generic failure flash + redirect. -
craig-web ×4:
routes/cases/contacts.rs,routes/placement/documents.rs,routes/reporting/afcars.rs,routes/reporting/ncands.rs; craig-portal ×1:documents.rs→relay_bytes(Cache-Control: no-storeis portal-global); intake ×1:services/craig-intake/src/api/attachments.rson the shared client (Extension<reqwest::Client>), ownership 404 before any forward,relay_responsecopies only CT + CD and readsresp.bytes()after the #933 redaction. -
reqwest0.12.28:ClientBuilder::read_timeout(per read, reset after each successful read; it runs only while the body is polled) beside the totaltimeout;bytes_stream()needs the DISABLEDstreamfeature, butreqwest::Bodyimplementshttp_body::Body<Data = Bytes>, soaxum::body::Body::new(http::Response::<reqwest::Body>::from(resp) .into_body())streams without enabling anything. Client construction is allowlisted by count inxtask/src/cmd/lints.rs. -
No server-side write-progress timeout exists (hyper 1 ships none); a reader that stops consuming holds the connection today too, while the buffered
Vecis written.
The ceiling side.
-
CeilingClass = Standard | Extended;EXTENDED_REQUEST_CEILING300 s,EXTENDED_CALLER_BUDGET310 s. Nine Extended download GET rows, bare(Method, template, class)tuples: cases ×3, exchange ×1, intake ×1, placement ×2, reporting ×2 (services/*/src/api/ceilings.rs); the other Extended rows are upload POSTs and the two reporting export POSTs. The coverage guard is one-directional — deleting rows fails nothing. -
ADR-068 D1a pairs "CLI export fetches" with the Extended budget — false in code (the CLI has no download commands; its one export fetch is the Standard rules JSON). axum routes HEAD to the GET handler and strips the body; hyper h1 keeps
Content-Lengthfor HEAD.
Tests and precedents.
-
Download tests assert status + byte equality;
craig_test_lib::ServiceClient::get_bytesDISCARDS headers; the e2e specs assert a download event / non-empty body / content-type; k6 hits no download. -
The cases keyed harness (
build_with_store(authz, store)+serve(),services/craig-cases/tests/api/ keyed_harness.rs) clones a throwaway DB from the TEST-PLANE Postgres — everytests/apisuite is devstack-gated; the only infrastructure-free level is a craig-store test on a double viaStore::from_parts(featuretest-util).contested-surfaces.tomlnames the BFFget_bytes5xx test. Garage legs:crates/craig-store/tests/ garage_put_create.rs.
Decisions
D1 — Store::get_stream: one head, then lazy ranged reads whose frames are forwarded, never collected
-
pub async fn get_stream(&self, path) → Result<StoredObject, StoreError>;StoredObject { size: u64, e_tag: Option<String>, body: SyncWrapper<BoxStream<'static, Result<Bytes, StoreError>>> }(sync_wrapper1.0.2 is in the lock via axum and is axum-core’s own idiom; the field isSyncby forbidding shared access — the type complies with "public types are `Send + Sync`"; the consumer `into_inner()`s it once). -
Head: ONE
head()after theStoreOp::Getfault hook;NotFound→ 404, other errors asget. -
Body:
chunk_ranges(size, chunk)(a pure fn) drives atry_unfold; each chunk is ONEget_opts(range, if_match: e_tag)whoseinto_stream()FRAMES are forwarded as they arrive (try_flatten) — never.bytes(), so no allocation proportional to the object OR the chunk exists; in-flight bytes are transport frames, bounded by the chunk boundary.STREAM_CHUNK_BYTES = 8 MiBproduction; atest-utilget_stream_with_chunk(path, chunk)seam. -
Bounds: each chunk request keeps the existing 30 s total timeout and retry policy, and object_store’s own
retry_streamresumes a broken body by ETag range inside that budget; the worst case with NO bytes flowing is the retry budget, so craig-store exposeschunk_deadline(&StoreConfig) = retry_timeout + MARGINandDEFAULT_CHUNK_DEADLINE(3 × 30 s + 10 s = 100 s) — the number the edges' idle budget is derived from (D3). -
if_matchon every chunk: an overwrite mid-stream answers 412 and the body ENDS rather than splicing two versions (the digest-and-generation invariant makes designed overwrites byte-identical;if_matchcovers the foreign one). A failed chunk, a 412, or a blob deleted mid-stream (the real DELETE removes it at once) ends the body — hyper closes the connection; no status can change after the head. -
Observability: the body stream runs under the handler’s span (
tracing::Instrumenton the stream) and every stream error is logged aterrorwith the correlation id; adownload_stream_outcome_total{outcome=completed|failed}counter is bumped at stream end by an inspect / drop guard in the helper (D2) — the head-scoped HTTP metrics and theApiErrorconversion never see body failures. -
Store::getstays for the two whole-bytes callers, documented "never from a handler". -
Rejected:
into_stream()on the whole object (cut by the 30 s total; resumes at most inside one retry budget); a second client with the total disabled (re-opens #1504); collecting chunks (2× memory).
D2 — One response helper, eight swaps, no compression on attachments
-
craig_api::download::download_response(StoredObject, filename, content_type) → Response:Content-Length: size(PRESERVING what the buffered body’s size hint gave — the header is not new on the wire), Content-Type, Content-Disposition,Cache-Control: no-store(R2), the outcome guard, andBody::from_stream(obj.body.into_inner()). -
Each handler replaces its fetch + header block with
get_stream+ the helper — every handler SHRINKS (court_orders.rsstays under B1). Authz / parent-check order unchanged; the portalaudit_readstays betweenget_streamand the response (a read that later truncates is still an audited read — recorded). -
Compression: a
craig_common::http::NotForAttachmentspredicate (any response carryingContent-Disposition) is applied viacompress_whento BOTH compression layers (craig-api, intake), soContent-Lengthsurvives on every surface; text exports lose gzip (recorded). The header is the client’s progress + h1 truncation signal, not the only truncation detector. -
Out of scope:
ETag,Range/Accept-Ranges(#1948).Cache-Control: no-storerides the helper AND the edges (UpstreamDownload.cache_control; intake’s allowlist gains it; portal already global), each with a test. -
HEAD on a BACKEND route costs DB + authz + one
head()and zero range reads. The edges forward HEAD upstream as the GET they issue today (an edge HEAD starts one upstream GET whose body is dropped — recorded, unchanged).
D3 — The edges stream; the caller pairing splits head from body
-
crates/craig-common/src/ceiling.rsgainsDOWNLOAD_IDLE_BUDGET = 120 s; craig-store const-assertsDEFAULT_CHUNK_DEADLINE ≤ DOWNLOAD_IDLE_BUDGET(a chunk that is retrying is never cut by the edge).crates/craig-common/src/http.rsgainsbuild_streaming_client(name, ver)=connect_timeout(5 s)
read_timeout(DOWNLOAD_IDLE_BUDGET)+ NO total timeout + the shared redirect / UA policy (the lint allowlist count 1 → 2). The Standard head bound is the existingDEFAULT_TIMEOUT(30 s). -
BFF:
Transport::new(http, streaming_http);get_bytesis DELETED, replaced byget_stream(base, path, user) → anyhow::Result<UpstreamDownload>,UpstreamDownload { status: StatusCode, content_type: Option<HeaderValue>, content_disposition: Option<HeaderValue>, content_length: Option<u64>, cache_control: Option<HeaderValue>, body: reqwest::Body }. Any upstream status is DATA;Erris transport-only.send()runs undertokio::time::timeout(DEFAULT_TIMEOUT); onElapsedthe transport records the outbound sample itself (metrics::http_client::record_completed(caller, target, method, 0, elapsed)) and returns a plainanyhow::Errorwith noUpstreamErroron the chain — the untyped class the general classifier maps to 502 and the download routes turn into their existing generic-failure flash + redirect, unchanged. The body reaches axum asBody::new(http::Response::from(resp).into_body()). -
craig-web ×4 and craig-portal ×1 forward status + the headers + the body; non-2xx handling unchanged (a non-2xx head never streams). Intake ×1:
Extension<StreamingHttp>(pub struct StreamingHttp(pub reqwest::Client)) layered where the shared client is today (the attachments nest and the partner nest);with_service_identitykept; 2xx bodies stream throughrelay_response; the #933 redaction of non-2xx (buffered.text()) untouched. -
Guarantee stated honestly: the UPSTREAM side is idle-bounded end to end; a DOWNSTREAM reader that stops consuming holds the connection as any slow client does today (no server-side write-progress timeout exists) — R6 / #1951.
-
Rejected: enabling reqwest’s
streamfeature; keepingget_bytesbesideget_stream; a total 310 s body budget.
D4 — The class shrinks by deletion and is pinned
The nine Extended download GET rows are deleted (eight in U1, intake’s in U2); the Extended table keeps upload POSTs
the two export POSTs; each service’s ceiling_table_tests gains every_extended_row_is_a_post; the ceiling.rs
docs, the ceilings.rs headers and the BFF transport doc are restated. ADR-068 § Amendment — #1572: the class-table
row; the doctrine ("the ceiling bounds the response head; a streamed body is bounded upstream by chunk deadlines and
an edge idle budget derived from them, never a total budget"); the CLI correction; the BFF pairing paragraph.
D5 — Pins at three levels, each proving what only it can
-
STORE (infrastructure-free,
crates/craig-store/tests/get_stream.rs): the doublecraig_test_lib::store_double:: OnDemandStoreimplements the FULLObjectStoretrait (get_optshonouringoptions.range; unused methods returnErr(object_store::Error::NotImplemented); the "range reads" counter keys onoptions.range.is_some()because the defaultheadroutes throughget_opts(head: true)), yielding frames only when polled and blocking frame k on a test signal. Pins: exact demand at the polling boundary (nothing produced before the first poll; N polls ⇒ exactly N frames); frames forwarded unmerged; the exact emitted prefix on an error at frame k;if_match == e_tagon every chunk;chunk_rangescovers[0, size)with no gap / overlap (proptest incl. 0, 1, k·chunk ± 1); chunk-concatenation equalsgetfor random objects up to 40 MiB with a 1 MiB chunk. -
ROUTE (devstack-gated like every
tests/apisuite;services/craig-cases/tests/api/attachments_streaming.rs, registered intests/api.rs; the harness onfrom_parts(OnDemandStore)): head-before-body with the fault release GATED on the client’s acknowledgement of status + headers; backpressure over a 256 MiB logical object with a slow reader —produced_bytes − consumed_bytes ≤ STREAM_CHUNK_BYTES + 8 MiB(one chunk boundary plus the documented socket / hyper buffers; the object never materialises); HEAD → headers, empty body, zero range reads; truncation through the REAL DELETE route mid-download (the body ends; the next GET is 404); 404 athead(); the per-route authz oracle UNCHANGED (403 fleet-typed for cases / placement home / exchange / reporting; 404 existence-denial for the portal) each with a zero-store-access assertion; plus one#[ignore = "requires devstack"]Garage leg (64 MiB viaput_create+ the raw row; first chunk before completion; byte-exact). -
EDGE (per edge implementation — web ×4, portal, intake — on a raw
tokio::net::TcpListenerupstream fixture, thecrates/craig-common/src/http.rstest pattern): the fixture writes200+Content-Length: N+ the first half, WAITS until the downstream test client has read the head and first bytes, then releases the rest — a buffering route cannot pass; a progressing stream with the idle budget injected to 500 ms and frames every 300 ms for 2 s completes (idle resets per frame; no total); a stall past the injected budget ends the body (get_stream_body_stall_ends_at_read_timeout); a stall SHORTER than the budget recovers (retry survival);get_stream_head_timeout_is_transport_errorasserts the metric sample AND the untyped class; the 5xx-as-data leg is re-targeted; intake’s cross-partner 404 unchanged. -
Header assertions on all EIGHT routes use the header-bearing test-lib helper (D6), not
get_bytes.
D6 — Client surface, once
craig_test_lib::download_stream(&ServiceClient, path) → anyhow::Result<DownloadHead>, DownloadHead { status:
StatusCode, headers: HeaderMap, response: reqwest::Response } (chunks via .chunk()), on a client without a total
timeout; the buffering helpers stay for byte-equality legs. api-docs regen per unit; route-to-client-method.toml
unchanged; contested-surfaces.toml re-pointed at the replacing test with its oracle text (U2). Pre-1.0 CHANGELOG
Changed: download routes Standard-classed (20 s to the response head; bodies stream under chunk deadlines + an edge
idle budget), attachment downloads exempt from compression, Cache-Control: no-store, the BFF get_bytes removed.
Units — each Relates to #1572; U2 Closes #1572; U0 → U1 → U2
| MR | Issue | Scope | W |
|---|---|---|---|
U0 |
#1572 |
This page (Active nav), ADR-068 § Amendment — #1572 (Proposed), epic &97 + children + follow-ups (#1948 |
1 |
U1 |
#1946 |
craig-store |
5 |
U2 |
#1947 |
|
3 |
Every MR carries its own CHANGELOG.adoc == Unreleased entry (U0 the plan; U1 the class shrink + compression
exemption; U2 the edges + get_bytes removal). Every new test carries its // @axis: tag. U1 alone is deploy-safe
(the BFF keeps its 310 s buffered proxy until U2); the reverse order is not.
Test matrix (by risk)
-
Evil: another actor’s document → the route’s EXISTING oracle (403 typed / 404 existence-denial) with zero store access; unknown object key → 404, no bytes;
Rangerequest header ignored (200 + full body); the portal audits once per request; intake’s non-2xx stays redacted while 2xx streams byte-exact; anif_match412 mid-stream ends the body. -
Sad: (i) missing at
head()→ 404; (ii) S3 error at head → 500 (unchanged mapping); (iii) error at frame k → exactly k frames then a client-side transport error, status was 200, the failure logged with the correlation id and countedfailed; (iv) a chunk retrying inside its deadline is never cut by the edge (the const-assert + the short-stall recovery leg); (v) a stall past the idle budget ends the body at the edge; (vi) a slow upstream HEAD pastDEFAULT_TIMEOUT→ the metric sample + the generic failure flash; (vii) the real DELETE mid-download → truncation, then 404; (viii)getstill verifies digests forverify_stored_blob. -
Concurrency: two concurrent streams of one object → both byte-exact; four concurrent slow readers keep the byte-counter bound; the head-before-body pin holds under the gated release.
-
Happy: eight routes → 200 +
Content-Length == size+ CT + CD +Cache-Control: no-store(viadownload_stream) + byte-exact body (via the buffering helpers); each of the six edge routes proves streaming on the gated fixture; the ceiling tables ×5 passevery_extended_row_is_a_post; backend HEAD → headers + empty body + zero range reads; a gzip-capable client still receivesContent-Lengthon a download on both surfaces. -
Property:
chunk_rangestotal and gap-free; chunk-concatenation equalsget; frames forwarded unmerged;Content-Length == size == bytes readon every completed stream.
Verification
-
Per MR: fmt, clippy (the 40-line
too_many_linesbound holds forget_stream,chunk_ranges, the helper and every handler), the budgets (B1 — every handler edit is a net shrink; B2 / B3a / B7 / B8 at their locks),contested-census, api-docs regen + drift gate,check-docs,plan-lint, the pre-push battery. -
After U1:
rg -n 'object_store\.get\(|store\.get\(' services/*/src/api→ 0;rg -n 'Method::GET'over the four services'ceilings.rs→ 0;rg -n 'collect_bytes|\.bytes\(\)' crates/craig-store/src/store.rs→ onlyget. -
After U2:
rg -n 'get_bytes' crates/craig-bff services/craig-web/src services/craig-portal/src services/craig-intake/src→ 0;rg -n 'EXTENDED_CALLER_BUDGET' crates services→post_extended,post_multipart, the intake upload forward;rg -n 'Method::GET' services/*/src/api/ceilings.rs→ 0. -
Live probe after U1: a 10 MiB attachment with
curl -N --compressedshows headers immediately,Content-Lengthpresent, and streams; deleting the attachment mid-download ends the body; a HEAD issues no range read.
Rollout + risks
-
No migration, no S2S change, no ruleset change. U1 first, U2 second.
-
Pre-1.0
Changed: external download callers see Standard (20 s to the response head; bodies stream — set an idle budget ≥ 120 s, not a total); text exports are no longer gzip-compressed. -
A stalled S3 chunk surfaces as a truncated download after its retry budget, not a 504 — recorded in the ADR and the deployment guide, and visible in
download_stream_outcome_total+ the correlated error line. -
One S3 request per 8 MiB chunk (a 200 MiB export = 25 requests).
-
A downstream reader that stops consuming holds a connection (as today); #1951 is the fleet-wide follow-up.
-
The portal audit precedes the body (unchanged semantics, now visible).
Rulings (approved 2026-09-19, plan mode)
R1 ranged 8 MiB chunks with frames forwarded and if_match per chunk; the edge idle budget (120 s) derived from and
const-asserted against the store’s chunk deadline — not a second S3 client with the total timeout disabled. R2
Content-Length preserved by exempting attachment downloads from compression on both surfaces — not a contract
qualified to uncompressed responses; Cache-Control: no-store set by the helper and carried through every edge. R3
pins at three levels — store-level exact demand on the on-demand double, devstack-gated route legs with gated fault
release and byte-counter backpressure, per-edge streaming fixtures a buffering route cannot pass, one Garage 64 MiB
leg — not a Toxiproxy leg. R4 backend routes issue zero range reads on HEAD; the edges keep forwarding the GET they
issue today — not a HEAD-preserving edge path. R5 StoredObject wraps its stream in sync_wrapper::SyncWrapper — not
a Send-only carve-out. R6 the downstream stalled-reader guarantee is narrowed to the upstream side and the
fleet-wide server-side write-progress timeout is #1951 — not added in this plan.
Recorded as decisions with their rejected alternatives: the CLI untouched and the ADR sentence corrected (D4); the
test-lib keeps buffering helpers plus download_stream, the Standard head bound is DEFAULT_TIMEOUT (D3 / D6); no
digest re-verification on the read path (#1949) (D2); three MRs with intake’s proxy + ceiling row in U2 (Units).
Review log
Rev 1 went to a contextless round 1 (no-ship — 5 blockers, folded into rev 2); rev 2 took the maintainer’s plan-mode gate (14 findings + 8 corrections, each verified against source and folded into rev 3); rev 3 was approved 2026-09-19.
| Round | Vendor | Resolved model | Verdict |
|---|---|---|---|
1 |
Anthropic — three fresh contextless lens subagents (conventions, implementability, readability + anchors), the four plan-lifecycle questions, over the plan + the rules |
Claude Fable 5.1 |
no-ship (2026-09-19; Q1: |
2 |
open — run by the maintainer through another vendor’s model |
open |
open |