Repository navigation
Description
Context
When a node has a cache miss and must fill the request from origin, the origin pull-through engine fetches the entire blob, even when the in-flight request only needs a byte range (e.g. the second GB of a multi-GB file). The node pays full origin egress (S3/R2/B2 metered bandwidth) and spends disk/time on bytes the client never asked for. For a client that wanted one GB of a large object, this is unrecouped origin cost on every cold range request.
ADR 037 (#723, completed) already addressed the node→node side of this — its window-paced pull-through plus iroh-blobs partial blobs + bao verified-streaming make a partially-held blob first-class and bound speculative loss to pull_ahead_bytes. But ADR 037's mechanism only applies when the upstream is a cdn/dht/v1 peer (another iroh-blobs node that can serve verified chunk ranges against the root hash). The origin tier — opaque S3/HTTP/B2 backends serving raw bytes by hash — is untouched and remains strictly whole-blob.
Evidence in code
Origintrait is whole-blob only.crates/cache/src/origin/mod.rs:230—fetch(&self, hash: Hash, max_bytes: u64).max_bytesis an advisory cap, not a range selector. Nooffset/start/end/range parameter exists anywhere in the trait or adapters.- HTTP adapter (
crates/cache/src/origin/http.rs) builds{base_url}/{blake3_hex}and reads the body start→EOF. NoRangerequest header, noContent-Rangehandling. - S3 adapter (
crates/cache/src/origin/s3.rs) issuesGetObjectwith noRangeset — serves the whole object. - Filesystem adapter (
crates/cache/src/origin/fs.rs) opens the file and reads from byte 0; no seek/offset. - Engine (
crates/cache/src/engine.rspull_through/pull_through_attempt) receives the full stream, computes BLAKE3 over all received bytes, verifies against the requested hash, then commits.get(hash)takes a hash only — no range — and returns the fullBytes.
The hard part: verifying a partial range from a raw origin
Content is BLAKE3-addressed and the node MUST verify received bytes against the content address. For a node→node pull this is solved by bao verified streaming (the peer is an iroh-blobs store that produces the hash-tree). A raw origin serves opaque bytes by hash with no bao outboard, so a node cannot verify a sub-range [a, b) against the BLAKE3 root without the hash-tree — which today only exists after the whole blob has been fetched and imported at least once. This is the core design question, not just a missing HTTP header. Candidate directions to evaluate:
- Origin serves the bao outboard alongside data (e.g. a sibling key
{hash}.obao4+ HTTPRangeon the data object). Cleanest verification story; requires an origin-side publishing convention and anOrigintrait that can request the outboard + a range. Raises the SSRF/redirect surface already noted in Origin pull-through SSRF + metrics_bind non-loopback warning #579 for an additional request. - Fetch-whole-once, range-serve-after. Build the outboard on first full pull, then serve ranges from the cached partial. Does nothing for the cold case the user is worried about (the first range request still pulls the whole file).
- Lean on ADR 012 chunk/manifest granularity. Large files are already split into 256 MiB chunk-blobs at ingest with a manifest (ADR 012 §256 MiB / §manifest), each chunk independently BLAKE3-addressed. "The second GB" of a manifest-published file is ~4 distinct chunk-blobs, each pulled whole (256 MiB), not the whole multi-GB file. This substantially bounds the worst case for manifest content — the residual exposure is (a) single-large-blob publishes that skip the manifest, and (b) sub-256-MiB ranges. Worth deciding explicitly whether origin range-pull is even needed given chunking, or whether we just document chunking as the answer and tighten the max-blob cap.
- Require bao-encoded origins. Origins store/serve bao-encoded blobs natively; node range-fetches with inline verification. Strongest guarantee, heaviest publishing requirement.
Interaction with existing economic guards
The unrecouped-leech budget and per-peer share ratio from ADR 037 / #821 bound how much speculative pull-through a node absorbs, but they bound it in served-vs-pulled bytes — a whole-blob origin pull to serve a one-GB range still burns the budget on bytes the client never requested. Range-scoped origin pulls would make those caps tighter/cheaper, so this composes with rather than duplicates that work.
Scope / questions for an ADR
This is primarily a design / missing-decision item (likely an amendment to ADR 037 §pull-through and/or ADR 005 §protocol, possibly a new ADR — next number 038):
- Do we add a range-capable
Origin::fetch(e.g.fetch(hash, range, max_bytes)), and which adapters support it (HTTPRange, S3GetObject.range, fsseek)? - How is a partial range from a raw origin verified against the BLAKE3 root — outboard-alongside-data (option 1), or do we declare chunking (option 3) the sanctioned answer and not add origin ranges?
- If we add it: how does a client-side range request (the
cdn/client/v1StreamRequest.byte_offsetalready exists in ADR 005) propagate down to a range-scoped origin pull rather than a whole-blob pull? - SSRF/redirect hardening (Origin pull-through SSRF + metrics_bind non-loopback warning #579) for any second request (outboard fetch) and for
Rangerequests.
Out of scope
- Range-addressed DHT discovery (advertising "I hold bytes [a,b) of H") — explicitly deferred in ADR 037 §Range-addressed discovery deferred and Regional locality: latency-driven proxy warming bootstraps the first regional cache copy #723.
- Node→node partial serving — already first-class via ADR 037 / bao.
References
crates/cache/src/origin/mod.rs,origin/http.rs,origin/s3.rs,origin/fs.rs,engine.rs- ADR 037 (window-paced pull-through, partial blobs first-class — node→node)
- ADR 012 (256 MiB chunk + manifest model; multi-channel range download)
- ADR 005 (
StreamRequest.byte_offset, iroh-blobs verified streaming wrap) - Regional locality: latency-driven proxy warming bootstraps the first regional cache copy #723 (ADR 037), No
require_authorized_originequivalent on the cache-miss pull-through path: operators cannot opt out of relaying/warming unclaimed content #821 (pull-through authorized-origin gate), Origin pull-through SSRF + metrics_bind non-loopback warning #579 (origin pull-through SSRF)
Filed from a repository investigation; scoping a decision before the cdn/client/v1 paid-delivery handler (TODO #317) lands the origin range path.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
github-actions commentedon Jun 5, 2026
🎯 Triage report
This is a well-scoped design/missing-decision issue filed by a collaborator identifying that the origin pull-through path (
Origintrait + all three adapters) is strictly whole-blob with no range capability, unlike the node→node path which gained partial-blob/bao verified-streaming support via ADR 037. The core blocker is verification: a raw origin serves opaque bytes with no bao outboard, so range verification against the BLAKE3 root requires either an out-of-band outboard fetch or reliance on ADR 012 chunking (which already bounds the worst case for manifest content to ~256 MiB per chunk). The issue cleanly enumerates four design directions and their trade-offs. No implementation work can start without an ADR decision.📊 Assessment
enhancement,adr-review,economics,technical,missing-decisionare all accurate and sufficient🔗 Similar issues
require_authorized_originequivalent on the cache-miss pull-through path: operators cannot opt out of relaying/warming unclaimed content #821 (related) — Authorized-origin gate on the same cache-miss pull-through path; samecrates/cacheengine, adjacent policy concern, not duplicate💡 Notes and suggestions
Decision gate before implementation: The four candidate directions in §The hard part map to meaningfully different implementation and publishing-convention costs:
.obao4+ HTTP Range): Cleanest verification; requires origin publishing convention change and adds a second request (SSRF surface — see Origin pull-through SSRF + metrics_bind non-loopback warning #579).Origintrait needsfetch_outboard(hash)+fetch_range(hash, range).max_blob_sizecap to prevent non-manifest single-blob publishes from re-exposing the problem. This should be evaluated first; it may fully satisfy the constraint for PoC-scale.Suggested ADR 038 scope: A single decision record that (a) evaluates options 1–4 against the BLAKE3 verification constraint, (b) records whether option 3 is sufficient or whether an
offset/range extension to theOrigintrait is warranted, and (c) defines the propagation path fromStreamRequest.byte_offset(ADR 005) down to a range-scoped origin pull if option 1 is chosen.Code entry points for implementation (whichever direction):
crates/cache/src/origin/mod.rs—Origin::fetchsignature (line ~230)crates/cache/src/origin/http.rs— addRange: bytes=start-endheadercrates/cache/src/origin/s3.rs— populateGetObjectRequest.rangecrates/cache/src/origin/fs.rs—seek(SeekFrom::Start(offset))crates/cache/src/engine.rs—pull_through/pull_through_attemptto accept optional range and route partial import through iroh-blobs bao outboard pathDependency ordering: Block this on the
cdn/client/v1paid-delivery handler (#317) only for end-to-end wiring; the ADR andOrigintrait extension can proceed independently.Add this agentic workflows to your repo
To install this agentic workflow, run
alpergundogdu commentedon Jun 5, 2026
Scoping: amendments, not a new ADR — but validate the unknowns first
Mapped the surface. This lands as amendments to existing ADRs (037 owns pull-through; 005/012 are conditional), not a new ADR. The mechanism looks straightforward, but it rests on two things we have not verified — a bao/iroh-blobs capability and a wire-protocol fork — so we should validate those before drafting the amendment text.
Where it amends (and what's notably not in an ADR)
cdn/dht/v1path, verifying each chunk against the root hash" (037:57) and "bao verified-streaming make a partially-held blob first-class" (037:59). Nowhere does it cover a raw origin (S3/HTTP/B2), which has no bao tree. The amendment adds an explicit origin-tier subsection defining how a ranged origin fetch is verified. The economic caps (pull_ahead_bytes,max_unrecouped_leech_bytes,share_ratio, 037:84–98) are pure byte-counters and compose unchanged — a range-scoped pull just shrinks the "pulled" side.Origintrait is in no ADR. Origin status is governance-only (OriginAssignment; "the protocol does not distinguish origin from cache at probe time", 005:53–55, 011:456). The adapter contract (fetch(hash, max_bytes)incrates/cache/src/origin/mod.rs:230) is pure implementation. So adding a range parameter is a code change, and its verification contract gets written into the new ADR 037 origin subsection rather than a standalone ADR.The decision fork that determines blast radius
The biggest scoping question: do we need sub-blob ranges at all, or does chunk-granularity already cover the demand?
cdn/client/v2.StreamRequest{hash, [a,b)}): this is where the protocol modification bites.byte_offsettoday is resume-only START with no END (005:167); expressing a bounded range needs a new field. Per ADR 013 an optional field is Tier-1 (no ALPN bump), but a range bound is billing-relevant and ADR 013 has no "must-understand optional field" notion — an old node that ignores it over-delivers/over-bills with no slash evidence. To be enforceable it must join the signed field set, which is Tier-3 →cdn/client/v2(013:332–358, 005:375). That's a real protocol bump, so we should only take this branch if chunking is demonstrably insufficient.Missing parts to validate before writing amendments
[a,b)against rootHusing a separately supplied outboard, and — critically — that a bao outboard is self-verifying againstH(so an origin can serve an untrusted outboard and the node validates range + outboard againstHin one step). If that property holds, the raw-origin verification story is clean; if not, the whole feature needs a different design. Validate the exact iroh-blobs/bao API (decode_ranges/ export-with-outboard /.obao4format).{hash}.obao4?) and the fallback when it's absent (degrade to whole-blob pull). Decide whether requiring outboards at origin is acceptable.cdn/client/v2are even in scope.total_bytesvs range length, voucher metering scoped to[a,b), and the ADR 013 "must-understand" gap if we go sub-blob.Rangerequests (redirect policy already hardened for the data fetch; a second request reopens it).Proposing we resolve #1 and #3 first (a spike on the iroh-blobs bao API + a call on whether chunk-granularity suffices), since together they decide whether this is a small two-ADR amendment or a
cdn/client/v2protocol change. Will draft the amendment text once those are settled.Generated by Claude Code
alpergundogdu commentedon Jun 5, 2026
Correction: ignore the protocol-bump logistics above
cdn/client/v1isn't on testnet yet, so breaking changes are fine — there's nocdn/client/v2, no Tier-3 ceremony, no signed-field/"must-understand" gymnastics. If we want a range bound onStreamRequest, we just add it in place (and put it in the signed set directly). Scratch that whole branch of the previous comment.That collapses the decision fork: the chunk-vs-sub-blob choice is now purely a design-merit call, not a cost/blast-radius one. Both options are cheap.
byte_len/end) toStreamRequestalongside the existingbyte_offset, signed, done. The only real work is the origin-tier verification (the bao-outboard question, validation item Add devcontainer for secure Claude Code sessions #1) and the cache-engine/Origin::fetchrange plumbing.Revised validation priority: the protocol shape is no longer a blocker, so the only load-bearing unknowns left are the origin-side ones — #1 (does bao let us verify a range against a self-verifying, externally-supplied outboard) and #2 (outboard availability/serving for a cold blob). Resolve those two and the amendment is writable; the
StreamRequestchange is mechanical. ADR 037 still owns the origin-tier subsection; ADR 012 documents chunking; ADR 005'sStreamRequestgets the new field as a straight breaking edit; ADR 022 unchanged.(Couldn't edit the prior comment in place — the GitHub tooling here only supports adding comments, not editing — so treat this as superseding its "decision fork that determines blast radius" and "missing parts" §3/§4 protocol bits.)
Generated by Claude Code
fix(cache,adr): address PR #961 review — total_bytes semantics, Bytes…
test(protocol): update public-API snapshot for StreamRequest.byte_len…
feat(cache,protocol): range origin pull-through — ADR decision + bao …
feat(cache): wire range_pull helper into origin adapters and engine (#…
fix(node): reject out-of-bounds ranges before signing; review fixes (#…
test(node): harden range-pull e2e helper and pin OOB reject reason (#823
feat(node): origin-tier range pull-through on cdn/client/v1 (#823, #990…
feat(protocol): bao verified-range streaming on cdn/client/v1 (#915)
feat(protocol): bao verified-range streaming on cdn/client/v1 (#915) (#…