Repository navigation
Description
Problem
A node and a client re-pay for bytes they already hold. has() is Complete-only, so any partial hold — interior, prefix, or disjoint — is treated as an empty cache, and every upstream pull threads a single contiguous byte_offset/byte_len. missing_ranges (the disjoint-gap oracle, shipped #1609) is unused. Clients are worse off: with only a .partial length they can't even represent disjoint held ranges, so BitTorrent-style partial state is impossible.
Verified against the code today: holding [K,L) and serving [0,X) re-pulls the whole blob; a prefix [0,K) re-pulls from 0; disjoint holds can't be expressed. All three re-pay for held bytes.
Intent
Satisfy "range R of blob H" by fetching only what you don't already hold+verify — the same stack for node and client — shaped so multi-source parallel (#1164) drops in later.
1. One source-agnostic RangedStore (trait in bao-range)
present_ranges / missing_ranges / admit(range) / read(range) / finalize. Two backends:
- Node — iroh-blobs cache (this is refactor(cache): unify blob ingest behind a range-aware cache API with retained partials #1607; its P1 query oracle shipped as feat(cache): range-aware present_ranges / missing_ranges query #1609; adds durability via retained partials).
- Client — new: a slim
.partial(sparse data) +.partial.obao4(accumulating outboard) + a present-range record.bao-range/bao-treeonly — no iroh-blobs, keepsclient-pullblob-store-free (CLI binary-split regression: publisher links cache crate (iroh-blobs/AWS SDK) #578).
Resume: trust records, verify once. admit only writes bao-verified data and records the range; resume trusts the record (O(1), no re-hash); one valid_ranges sweep at materialization is the wrap-up + safety net, and the stored outboard makes recovery surgical (re-fetch only the bad chunk groups).
2. Gap-driven range-minimized pull (A)
gaps = missing_ranges(H,R) → one contiguous pull per gap (interior→2, prefix→1, disjoint→N), verify in transit, admit. No wire change — disjoint gaps stay a local scheduling concern. Cheapest-first is automatic (the store is the free source). Subsumes today's single-byte_offset resume as the degenerate "one gap" case.
Node is a paced middleman; client is an endpoint. Node serve-miss = window-paced forward walk (draw upstream ≤ pull_ahead_bytes ahead of downstream cleared payment, ADR 037; held segments served free from cache); client = order-free, bounded by its own deposit. Pacing is a third injected axis, alongside sink and presence.
Interfaces / crate placement
RangedStore trait → bao-range (shared leaf). Node backend → cache. Client backend + gap-driven driver (A) → client-pull (reachable from node + cli). The driver takes three pluggable axes: RangedStore, Source (the #1608 BlobSource), Pacer. Mirrors the settled BlobSource placement (#578-clean).
Relationship to existing issues
- refactor(cache): unify blob ingest behind a range-aware cache API with retained partials #1607 — the node
RangedStorebackend (range-aware cache API + retained partials). Component; P1 shipped (feat(cache): range-aware present_ranges / missing_ranges query #1609). - feat(node): unify miss sources behind BlobSource; remove max_blob_size_mb #1608 — A's
Sourceaxis (BlobSource, dropmax_blob_size_mb). Component, node side; lean CLI precursor merged (refactor(cli): route bundle pull through the streaming top-up loop #1612). - ADR 039: rewrite leaner as the single multi-source home, then implement the scheduler #1164 — B, the multi-source parallel scheduler (ADR 039). Follow-on: reuses this design's
RangedStore/Source/Pacer, swapping the sequential per-gap loop for a parallel piece-picker — nothing below the loop changes.
Phasing
P1 RangedStore trait + node backend · P2 client backend (.partial+outboard, conformance-tested against the same suite as the node) · P3 gap-driven driver (A) + Pacer (client first, then node) · P4 extend to bundle pull.
Design worked out 2026-08-05.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
feat(bao-range,cache): add RangedStore trait + node backend (P1 of #1621
feat(client-pull): add ClientRangedStore — client RangedStore backend…
feat(client-pull,cli): range-minimized decdn fetch via gap-driven dri…
refactor(cli): route bundle pull through the gap-driven driver + dele…
feat(cache): node-only ServeStore (observe + encode_range) for the se…
feat(client-pull,cache,node): node serve-miss pull-leg foundation (B2…
feat(node): shared awaiting whole-tree bao outboard for serve-miss (#…
feat(cache,node): capture outboard proof nodes into the serve-miss sh…
feat(node): coherent whole-range bao serve encoder (#1621 B2 part 2, …
fix(node): score decoupled serve-miss upstream corruption + drain on …
test(node): reconcile serve-miss tests to the decoupled pull cadence (#…
feat(node): re-home the seed-leech cap into the decoupled pull leg (#…
fix(node): emit client-abandoned metric on decoupled serve abandon + …
test(node): retire fused-tee tee_finalize_failure from the decoupled …
refactor(node): delete the dead SpanProducer now that the coherent en…
fix(node): address serve-miss review comments — outboard seed, conten…
feat(node): decoupled serve-miss pull+serve legs (#1651)
alpergundogdu commentedon Aug 13, 2026
Complete. All four phases merged:
RangedStoretrait + present/missing oracle inbao-range(feat(cache): range-aware present_ranges / missing_ranges query #1609)..partial+.obao4+ranges backend (crates/client-pull/src/ranged_store.rs, iroh-blobs-free).drive/fill_gap(crates/client-pull/src/driver.rs:239), interior→2 / prefix→1 / disjoint→N gap tests; client via feat(client-pull,cli): range-minimized decdn fetch via gap-driven driver (P3-client of #1621) #1631, node via the two-leg driver (Flow A feat(node): route own-origin serve-miss through the two-leg driver; delete window_forward_loop #1655) + coalescing (B3 feat(node): multi-observer coalescing for the serve-miss (B3, #1656) #1660).bundle pullthrough the samedrive_fetchcore (refactor(cli): route bundle pull through the gap-driven driver + delete the legacy fetch loop (P4 of #1621) #1633).Multi-source parallel (B) stays as the follow-on #1164 / ADR 039. Closing as done.
docs: replace planning labels in comments with plain descriptions (#2126