Repository navigation
feat(node): stream bounded and resumed cache-miss requests through the two-leg spine - #2064
Merged
Merged
Conversation
…e two-leg spine (#2060) Co-Authored-By: Claude Opus 5 <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
…of closing it Co-Authored-By: Claude Opus 5 <[email protected]>
The pull leg's window is paid / divisor, but served_paid is an absolute content frontier seeded at the request's byte_offset. Subtract the session's served start so a resumed request ramps from the floor instead of opening credit_max before its first voucher. Co-Authored-By: Claude Opus 5 <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Every voucher opens about one chunk of room and wakes the pull, so a fast origin was driven in one-chunk draws. Once the window has ramped past PULL_WINDOW_FLOOR, wait until half of it is free (unless a serve leg is parked at the frontier, or the gap remainder is smaller); the exposure bound is unchanged and the draw count drops from total / CHUNK_BYTES to about 2 * total / window. At the floor the minimum is zero, so the floor's rounding slack stays drawable. Refs #2061. Co-Authored-By: Claude Opus 5 <[email protected]>
…r draw Origin::fetch_range returns the data span only; the outboard comes from fetch_outboard, which the dispatch serviceability probe already performs. BackendSource carries that outboard and hands it to origin_encode_range on every draw. Refs #2061. Co-Authored-By: Claude Opus 5 <[email protected]>
serve_leg maps paid wire back to content from the group-aligned fetch start and guards an attached observer's frontier extension; both spine functions refuse an out-of-bounds range before signing and price their floor guard at the request's aligned span. Co-Authored-By: Claude Opus 5 <[email protected]>
…e two-leg spine Dispatch routes every authorized miss — whole blob, bounded range, or resumed tail — into serve_via_backend_origin / serve_via_window_pull_through. The signed StreamResponse goes out before the fill; the pull leg fetches only the span's missing chunk groups; the serve leg streams them as they land. The buffered try_range_pull_through tier, which downloaded, verified and imported a whole requested span before answering, is gone. Closes #2060 Co-Authored-By: Claude Opus 5 <[email protected]>
…fill registry The throwaway (0,0) open claims a fill and drops it. The real (0,total) open parks in serve_audit behind the same hash's in-flight admission, then attaches to the live fill (its teardown is then not last-out) or owns a fresh one after the teardown — never a dying session. Registry unit tests pin both claim orderings; two integration tests drive the CLI's exact sequence on a multi-draw and a single-draw blob. Co-Authored-By: Claude Opus 5 <[email protected]>
pull_through_range / range_pull_attempt / origin_fetch_range_bytes / RangePullOutcome have no caller: the node serves every ranged miss through the two-leg spine, whose BackendSource uses origin_encode_range. present_ranges tests admit their partial spans directly. Co-Authored-By: Claude Opus 5 <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Co-Authored-By: Claude Opus 5 <[email protected]>
Coverage reportTotal: 83.40% (was 83.39%, ▲ +0.01%) — 84547/101370 lines
History
|
…wn span FillRegistry::claim attached any request whose range a live fill covered, even when the request started past that fill's paid frontier. The pull runs one window past served_paid and parks, and an observer's payments extend the paid prefix only once it reaches the observer's start, so with the owner not paying — the CLI's throwaway prelude open on every cold entry, or any stalled client — the observer starved until its own stall budget expired. The anvil journey bundle_pull_reuses_unchanged_and_splices_changed hit this on the spliced tail (4 MiB in) of b.bin: 30 s stall, twice. A live session is now an attach candidate only when the request starts at or behind its paid frontier; otherwise the request owns its own span and the two fills coexist under the hash. Pinned by a registry test and a node integration test that keeps a never-paying opener connected while the tail request is served beside it. Closes #2062 Co-Authored-By: Claude Opus 5 <[email protected]>
…stream-bounded-miss Keeps main's streaming, window-bounded origin_range_wire / OriginRangeCursor as the own-origin pull leg and drops this branch's buffered origin_encode_range. The buffered pull_through_range tier that #2066 windowed is deleted again: with every miss routed through the two-leg spine it has no caller, so its RangePullOutcome, second semaphore and tests go with it. The cursor now takes the outboard dispatch already probed instead of fetching it on every draw, so a fill reads {H}.obao4 once (own_origin_miss_fetches_the_outboard_once_across_draws holds against the windowed reader). Co-Authored-By: Claude Opus 5 <[email protected]>
… degraded node CacheEngine::origin_size advances the origin chain past a per-origin fault but surfaces the last one when no origin answers, mirroring origin_fetch_outboard_bytes — reviving dispatch's #1129 latch arm, which was dead: a node whose own origin timed out terminally refused CacheMiss (NotFound) instead of InternalError. Both dispatch probe-fault arms now warn and count node_pull_through_errors, so a broken own origin is visible even while the peer spine masks it. Co-Authored-By: Claude Fable 5 <[email protected]>
…as a decline
A truncated {H}.obao4 under the size cap passed origin_fetch_outboard_bytes,
so dispatch signed ok: true and every stream for the hash then hard-failed
on the first draw's verify — and a broken origin permanently shadowed a
healthy later one. The probe now compares against expected_outboard_len
and treats a mismatch as a decline that advances the origin chain, so the
node degrades to the buffered whole-blob path before signing. The wire's
in-draw length check stays as the backstop.
Co-Authored-By: Claude Fable 5 <[email protected]>
…own-origin gate hardened The peer path's pre-signature RangeNotSatisfiable gate judged the counterparty's unverified handshake total — the deflation twin of the #1895 inflation attack: an under-reporting holder makes every relay refuse valid bounded/resumed requests with a client-attributable error. The gate is gone; a total that cannot satisfy the request surfaces in serve_leg's own bounds check as a pull-attributed stream fault. The own-origin twin keeps its gate (the total is this node's own probe) and runs it BEFORE the floor guard, so an out-of-bounds range answers RangeNotSatisfiable rather than InsufficientDeposit; its floor guard now prices against the probed total, so a resumed tail span-caps too. New tests: a cold out-of-bounds miss refuses pre-signature and the released floor reservation does not leak; a window-poor pool is served for a coverable span and refused for the whole blob. Co-Authored-By: Claude Fable 5 <[email protected]>
…id frontier The #2062 attach refusal trades duplicate origin egress for liveness; it was invisible. FillRegistry now carries the cache metrics handle and bumps decdn_cache_fill_not_coalesced_total (plus a debug line with the frontier gap) at the skip site, claim's doc states the frontier precondition its rule list omitted, and window.rs's coalescing promise names the same carve-out instead of an unconditional no-double-spend. A concurrent same-group admit test pins that overlapping fills stay byte-exact (#2069 §4). Co-Authored-By: Claude Fable 5 <[email protected]>
…and the wire docs ADR 038 no longer specs a buffered third route for bounded origin-cold requests; dispatch's miss-tier block names the whole-blob fallback tiers its overclaim hid; the own-origin opener serves the request, not the whole blob; serve_leg's guard rationale states the real invariant (byte_offset >= fetch_start); origin_range_wire's doc drops the fetched outboard and the second pool; ADR 037's streams-while-fills bullet separates credit-window draws from 4 MiB fetch windows and names the minimum-draw exceptions; acceptance item 12 is split into ASD-STE100 sentences; the e2e crate's dead range-tier naming points at the spine. Co-Authored-By: Claude Fable 5 <[email protected]>
…essure PaceDecision::Wait carries its cause: the minimum-draw batching pause (#2061) is healthy pipelining, but it was bumping node_pull_through_window_paused — inverting that metric's documented meaning (a flat zero means the window never binds). The node hook now counts batching in the new decdn_node_pull_min_draw_waits_total and window binding where it was. The half-window pacer test asserts the cause. origin_fetch_outboard_bytes regains a metering assertion: the one-per-fill outboard read lands in pull_through_bytes. Observability appendix rows added for both new counters. Co-Authored-By: Claude Fable 5 <[email protected]>
- Peer path: a bounded, unaligned leaf→B→A miss is byte-exact and B's recorded upstream spend is exactly the aligned span's bao wire, with the head never pulled (the leg that fronts real USDC). - The resumed peer test drains and byte-compares the tail instead of stopping at the signed header, via the new leaf_ranged_paid_pull. - The #2062 attach arm end-to-end: a mid-blob open behind a paying owner's frontier attaches (fill_not_coalesced stays 0), the overlap is fetched once, and the guarded frontier extension wedges neither client. - The outboard-once test gains a draw-count ceiling (#2061 §2), so a regression to chunk-sized draws fails loudly. - A no-Range origin that passes the outboard probe is pinned: the stream fails cleanly after ok: true with nothing mis-cached (#2069 §3). Co-Authored-By: Claude Fable 5 <[email protected]>
…ion ref Co-Authored-By: Claude Opus 5 <[email protected]>
The outboard-once threading (BackendSource / origin_range_wire / OriginRangeCursor::open taking a pre-read outboard), the WindowPacer half-window minimum draw, the PaceDecision::Wait cause and its decdn_node_pull_min_draw_waits_total counter, and the tests and ADR sentences that assert them leave this branch; #2061 ships on its own. The origin_range.rs dead-field and single-pool doc cleanups that the tier deletion caused stay, as does RampPacer::paid_base. Co-Authored-By: Claude Opus 5 <[email protected]>
alpergundogdu
left a comment
Contributor
There was a problem hiding this comment.
Comprehensive review — the PR is solid and mergeable. The two-leg-spine refactor holds up under close reading:
range_out_of_boundsmirrorsdecdn_bao_range::align_range's bound check across the edge cases (empty blob, tail reads, overflow).RampPacer::paid_base = session.served_start()and theserved_paid − paid_baseramp math are consistent withFillSession::starting_at; the serve leg'sextend_served_from(fetch_start, …)with a group-aligned anchor is a genuine fix (content_paid_frontierneeds a group-aligned anchor), not a regression.- The fill-registry frontier exclusion (
fetch_start > served_paid()⇒ own your own span) correctly fixes the #2062 starvation and itsfill_not_coalescedmetric is wired throughFillRegistry::with_metrics. origin_sizesurfacing a trailing transport fault asErr(reviving the #1129 latch) and the exact-length outboard gate are handled correctly by the dispatchfault_seenlatch.- The
b14fe85revert of the #2061 min-draw work is clean — no danglingmin_draw/PaceDecision::Wait-cause references remain.
One low-severity defect, inline on metrics.rs: the newly added serve_cache_* counter family is never incremented in production, so all three counters export a permanent 0 — which reintroduces the exact ambiguity the docstrings say the family exists to remove. Observability only; no serving/payment correctness impact.
Generated by Claude Code
Gas snapshotNo gas changes vs base. |
Contracts coverageLine coverage: 90.63% (2399/2647 lines) |
8 of 9 tasks
thiras
pushed a commit
that referenced
this pull request
Sep 26, 2026
…iew (#2162) * fix(cache,node): close the two-leg spine residuals from the #2064 review - Encode-task panic: the range-wire encode catches its own unwind and parks a CacheError::Store carrying the panic message; UnfinishedGuard now covers cancel only. The own-origin pull leg logs a Store fault in the chain as an internal fault (error!), not as a local-origin fault. - Observability: decdn_cache_range_pull_permit_waits_total counts draws that find the range-pull pool full, with a warning past 10 s; the pacer hook records decdn_node_pull_through_wait_seconds per pause and warns once past 30 s. Registry rows and dashboard targets added. - No-Range origin: origin_range_serviceable probes the first chunk group before the node signs, so an origin that publishes {H}.obao4 but declines Range degrades to the buffered whole-blob pull. A per-origin latch makes the probe free once an origin has served a clean range window. - Refused attach: an already-present overlap is never re-fetched (the owner's gaps come from missing_ranges), so no smarter attach rule helps without reintroducing starvation. fill_not_coalesced now counts once per claim and only when the skipped fill overlaps the request. Closes #2069 Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs(changelog): note the two-leg spine residual fixes Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(cache,node): address #2162 review findings - Add CacheError::Internal for code bugs (caught encode panic, broken reader invariant, closed permit pool). The own-origin pull leg flags only Internal as a code bug; a store fault such as a full disk stays Store. - Key the range-probe latch on the origin that served the outboard, not on the outboard cache, which never holds an empty outboard (blobs of one chunk group) or one over 256 MiB. The probe hands that outboard to the cursor, so it no longer reads an uncacheable outboard twice. - A wrong-length first window advances the origin chain instead of shadowing a healthy later origin. - Record a pull pause's length from a drop guard, so a cancelled pause is observed too; log full error chains; debug-log a range decline. - Tests: small-blob latch, range-declining and short-first-window origins ahead of a healthy one, permit wait past the warning, a range-probe timeout refusing InternalError, and the degrade test tied to the probe. - Docs: ADR 037 serviceability and fallback conditions, stale comments. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2060. #2061 (outboard once per fill, minimum draw) is deliberately NOT in this PR — it ships separately; until it lands, the spine re-reads
{H}.obao4per draw and draws per voucher asmainalready does for whole-blob misses. Also fixes #2062 (the anvil journeybundle_pull_reuses_unchanged_and_splices_changedhit it on every cold spliced tail once bounded requests routed through the spine). Follow-up filed: #2063.On a cold miss the CLI's real request is
byte_len = total_bytes, which dispatch routed totry_range_pull_through: download the whole span + outboard into memory, verify, import, and only then signStreamResponse. No timeout, no keepalive — a multi-GiB file trips the client's 30 s stall clock while the node is still buffering.Every authorized miss — whole blob, bounded, resumed — now takes the two-leg spine (
serve_via_backend_origin/serve_via_window_pull_through): sign first, pull only the span's missing chunk groups in credit-window draws, stream each verified group as it lands. The buffered range tier andCacheEngine::pull_through_rangeare deleted.Spine hardening that the offset-0 gate had been hiding:
RampPacerramps onserved_paid − served_start, so a resumed request does not opencredit_maxbefore its first voucher.serve_legmaps paid wire back to content from the group-aligned fetch start and guards an attached observer's frontier extension.RangeNotSatisfiablebefore signing and price their floor guard at the request's aligned span.Throwaway-then-real open, and the stalled owner.
FillRegistry::claimnow attaches a request to a live fill only when the request starts at or behind that fill's paid frontier; a request ahead of it owns its own span, so a tail request no longer starves behind a never-paying opener (pinned by a registry test and an integration test that keeps the opener connected). The CLI's(0,0)prelude open followed by the real(0,total)open is pinned against the fill registry in both claim orderings (attach to a live fill; own a fresh one after teardown). Measured while writing the test: the real open parks inserve_audit→ iroh-blobsstatus(hash)behind the throwaway's in-flight admission of the same hash, so it never sees a dying session — but its TTFB is delayed by the throwaway's first draw. Recorded on #2063, whose fix removes the prelude claim.Tests: CLI-shaped
(0, total)and unaligned-offset misses stream via the own-origin tier; the mixed present/absent range pulls only the missing group; a resumed node→node miss is served by the fused path; two throwaway-open sequences (multi-draw and single-draw); the resumed-offset-refused test is flipped and the range-tier cache tests are gone. Full workspace: 3573 passed (one unrelatedwarn_throttletiming test retried once).🤖 Generated with Claude Code
Review fixes (four-agent review, second push)
origin_sizesurfaces the last transport fault when no origin answers, so a node whose own origin is broken refusesInternalError, notNotFound(Reactive pull-through: a hard origin/store fault terminates as a signed CacheMiss (NotFound), not InternalError — both tiers #1129); both probe-fault arms warn and countnode_pull_through_errors.{H}.obao4is a decline that advances the origin chain — the node degrades to the buffered path instead of signingok: trueand hard-failing every stream.RangeNotSatisfiableon a peer-claimed total was the deflation twin of the Node-to-node size-claim gate lets a holder centralize traffic (refuse-on-claim → refuse-on-received-bytes) #1895 attack; the own-origin gate (own probe) stays, now ahead of the floor guard and priced against the real total.decdn_cache_fill_not_coalesced_total+ docs state the frontier precondition; concurrent same-group admits pinned idempotent.Rangeorigin pinned fail-clean.Gate on the fixed branch: fmt, clippy
-D warnings, doc-D warnings, crate edges, 3606 workspace tests, 64 anvil journeys.