Skip to content

feat(client-pull): add Downloader and Streamer consumption faces over a unified multi-source core - #2108

Merged
thiras merged 20 commits into
mainfrom
claude/trusting-raman-1b3304
Sep 22, 2026
Merged

thiras merged 20 commits into
mainfrom
claude/trusting-raman-1b3304

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Adds two consumption primitives to client-pull — a Downloader (fetch a bundle or blob to files, full-throughput) and a Streamer (stream one blob's verified front, consumption-paced) — as two faces over one shared multi-source engine. Collapses the former stack (was #2108 → #2110 → #2111 → #2112) into this single "surface" PR; the CLI rewiring lands separately.

No wire change; client-pull stays iroh-blobs/aws-free (check_crate_edges.py clean). Everything here is new API with no consumers yet — the CLI is untouched.

The surface, bottom-up

Foundations

  • WarmConnection — one dialled cdn/client/v1 connection reused across many hashes (fresh open_bi per hash, no wire change); UpstreamPull tears down only its stream when the connection is borrowed.
  • PullConfig — injected zero-config tunables (read_ahead_bytes, streamer_lane_cap), each defaulting; construction is const (no network/chain).
  • ByteSink + BlobCache — pure output/cache traits (no blob store), NoCache default.

One engine, two faces

  • Shared core: multi_source_fetch (fan-out + tail-steal + shared-pool failover into one ClientRangedStore) gained a ConsumptionPacing seam — a downstream cursor + pacing-wait threaded to its per-lane workers — so it can be bounded to a read-ahead window ahead of a live consumer. None = the eager unbounded fetch (every existing caller unchanged).
  • Streamer — fetches its front across a small bounded candidate set (streamer_lane_cap, default 2), paced on the consumer cursor, with candidate failover (resume from the store's verified frontier, never re-paying). VerifiedReader is a tokio::io::AsyncRead clamped to the checkpointed verified frontier by construction — a tampered chunk group errors the stream, never yields unverified bytes. Verified blobs tee to the injected cache.
  • Downloader — the download half of the same core: uncapped fan-out, no consumption pacing, promotes each finished blob to a file. Failover for free; a resumed .partial (a bundle layer's chunk-hint dedup) re-pulls only its complement.

Design decisions

  • Downloader ↔ bundles/full-throughput, Streamer ↔ fetch-like single blob (no dedup). Both configure the one core; the Streamer caps + paces, the Downloader uncaps + runs flat out — one resilience/verify/failover path, not two engines.
  • spread_segments seeds at 64 MiB-block granularity, so concurrent front fan-out on a large blob under a small window needs a later steal-preference tweak; ≤64 MiB blobs already fan out. Streamer ships single-lane-front + failover + a pipelined second lane, which is fine for streaming (noted for a follow-up).

Deferred (follow-ups)

  • CLI rewiring (next PR): bundle pull→Downloader, decdn fetch -o -→Streamer (stdout), decdn fetch -o file→Downloader.
  • Concurrent front fan-out on large blobs (steal-preference-under-window); T7 K-provider warm set; Streamer partial-prefix cache reuse.

Tests

WarmConnection reuse (one dial, two hashes); PullConfig defaults/purity; sink/cache round-trips; scheduler consumption-pacing (window gates a lane on the consumer cursor); Streamer drain BLAKE3-identical / tampered-never-surfaces / full-cache-hit / bounded read-ahead / mid-stream candidate failover; Downloader BLAKE3-identical / two-candidate striping / pre-seeded-prefix dedup / empty-set precondition. Full client-pull suite green (321).

🤖 Generated with Claude Code

alpergundogdu and others added 5 commits September 22, 2026 09:48
…ion)

Add WarmConnection: a caller-owned cdn/client/v1 connection dialled once and
reused across many hashes, opening a fresh bi-stream per hash (one stream = one
hash, no wire change). open_stream takes a ConnSource (dial a fresh one-shot
connection or reuse a warm one); open_progressive_pull keeps the dial path and
open_progressive_pull_on opens a pull on a warm connection. UpstreamPull now
tracks whether it owns its connection: an owned one-shot dial is closed on the
pull's terminal method, while a borrowed warm connection is left open for the
next hash — only the current stream is torn down. The warm connection closes
once, on its own Drop.

Test: two distinct hashes fetched back-to-back over one WarmConnection dial the
connection exactly once (client_loopback::two_hashes_reuse_one_warm_connection).

Part of #1848 (T1).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Add config::PullConfig, the injected tunables the consumption faces
(Downloader, Streamer, #1848) share. It holds only tunables, each with a
sensible default, so PullConfig::default() is the whole configuration a caller
needs; the required per-fetch inputs (identity, connection, spend budget,
providers) stay on the engine's existing params, which is why PullConfig
constructs with no network or chain access (proven by a const construction).

The first tunable is the Streamer's read_ahead_bytes bound (default 16 MiB);
more fields are added as Downloader (T4) and Streamer (T6) grow to consume them.
The payment interval stays the fixed protocol const CHUNK_BYTES, not a tunable.

Part of #1848 (T2).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Add the output side of a fetch to sink.rs (#1848 T3):

- ByteSink: where the engine writes verified content bytes, at absolute
  offsets, so an out-of-order multi-source fetch lands each range at its
  position. The Downloader backs it with a file.
- BlobCache: the injected (hash, offset) content cache the Streamer consults
  and fills. Pure — it names no blob store — so client-pull stays
  iroh-blobs-free; a blob-store-backed impl is injected from above. The default
  is the no-op NoCache (never hits, never stores).

Both use the crate's boxed-future async-trait shape (SinkFuture). Test doubles
VecByteSink and MemoryBlobCache ship under test-util for the Downloader/Streamer
suites. check_crate_edges.py still passes (decdn-cli closure clean).

Part of #1848 (T3).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Add the Downloader consumption face (#1848 T4): fetch a set of content-addressed
blobs — a bundle, or a single blob — to files in a directory. It is an
output+scheduling adapter over the ONE paid pull engine, not a second engine:
each (hash, total_bytes) entry opens a ClientRangedStore beside dir/<hex> and
drives only its missing ranges through driver::drive, which bao-verifies every
byte on ingest and promotes .partial to the final file on completion. So writes
land out-of-order at their offsets, a resumed download re-pulls only what it
lacks, and a bundle layer above can pre-seed held ranges (its chunk-hint dedup)
into the store so the same drive fills only the complement.

Bundles are the main scenario (a bundle is a set of entries → one file each,
named by content-address hex; a single blob is a bundle of one). The pull
machinery (source, pacer, funder, ctx, ledger) is injected and shared across
every entry, so one provider connection and one payment channel serve a whole
bundle. fetch_to_dir takes &PullConfig for symmetry with the Streamer; the
Downloader fetches at full throughput, so no tunable changes its behaviour yet.

decdn fetch / bundle pull are rewired onto this in later PRs.

Part of #1848 (T4).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…etch)

Add the Streamer consumption face (#1848 T5+T6): stream one blob's verified,
contiguous front to a consumer as it arrives, paced by how fast the consumer
reads — the fetch-like, single-blob face (no chunk dedup, unlike the Downloader).

One engine, two faces: the Streamer configures the SAME paid pull engine, not a
second one. It drives the fetch through driver::drive with a WindowPacer whose
window is PullConfig::read_ahead_bytes and whose downstream frontier is the
CONSUMER'S read cursor — the bounded-read-ahead mode the driver already supports
(window_pacer_gates_on_injected_served_paid), so T5 needs no engine change. The
pull never runs more than one read-ahead window ahead of what the consumer has
read, so a viewer who stops after five minutes never fetches (or pays for) the
whole two-hour movie; that read-ahead bound IS the outstanding-spend bound.

VerifiedReader is the tokio::io::AsyncRead the caller drains. It cooperatively
polls the drive future inside poll_read and reads only the store's CHECKPOINTED
present frontier, so it is clamped to the verified contiguous frontier by
construction — a tampered chunk group fails the pull and surfaces as a read error
rather than ever reaching the consumer. On a clean finish the whole verified blob
is teed to the injected BlobCache; a revisit whose cache already holds the blob
serves straight from memory and never touches the network.

Tests: drained stream BLAKE3-identical; a tampered tail never surfaces (verified
prefix only, then an error); a full cache hit fetches nothing; a slow consumer
holds the in-flight bytes within the read-ahead bound.

decdn fetch is rewired onto this in a later PR.

Part of #1848 (T5, T6).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 22, 2026 09:48
@alpergundogdu alpergundogdu changed the title feat(client-pull): Downloader + Streamer consumption faces over the paid pull engine (#1848) feat(client-pull): add Downloader and Streamer consumption faces over the paid pull engine (#1848) Sep 22, 2026
@alpergundogdu alpergundogdu reopened this Sep 22, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The new Streamer currently masks store errors and has a cursor-advance edge case that can break invariants, which should be fixed before merging.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

This PR extends crates/client-pull with two new “consumption faces” over the existing paid pull engine: a multi-blob Downloader for fetching bundles to disk and a single-blob, consumption-paced Streamer that exposes a verified AsyncRead (VerifiedReader). It also adds supporting primitives (WarmConnection, PullConfig, and sink/cache traits) and a node loopback test that pins warm connection reuse across hashes.

Changes:

  • Add WarmConnection + open_progressive_pull_on path to reuse one QUIC connection across multiple hash pulls.
  • Introduce consumption primitives: Downloader (bundle/file) and Streamer/VerifiedReader (single-blob, bounded read-ahead).
  • Add output/cache abstractions (ByteSink, BlobCache) and tests, plus a node loopback test to assert connection reuse.
File Description
crates/​node/​tests/​support/​mod.rs Adds a server helper that counts accepted connections for warm-connection reuse tests.
crates/​node/​tests/​client_loopback.rs Adds a loopback test proving two hashes reuse a single warm connection.
crates/​client-pull/​src/​streamer.rs New Streamer/VerifiedReader implementation and tests for consumption-paced verified streaming.
crates/​client-pull/​src/​sink.rs Adds ByteSink/BlobCache traits and test doubles, plus cache/sink tests.
crates/​client-pull/​src/​lib.rs Exposes new modules/types, adds warm-connection open path, and adjusts pull teardown semantics.
crates/​client-pull/​src/​downloader.rs New Downloader implementation and a file-output test.
crates/​client-pull/​src/​connection.rs New WarmConnection abstraction that owns connection lifetime across pulls.
crates/​client-pull/​src/​config.rs New zero-config PullConfig with default read-ahead tuning and purity tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/client-pull/src/streamer.rs Resolved
Comment thread crates/client-pull/src/streamer.rs Resolved
Comment thread crates/client-pull/src/sink.rs Resolved
@github-actions

github-actions Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 83.97% (was 83.85%, ▲ +0.13%) — 89550/106640 lines

File Coverage Lines Δ
crates/cli/src/commands/fetch.rs 54.09% 1533/2834 ▼ 0.02%
crates/client-pull/src/config.rs 100.00% 24/24 new
crates/client-pull/src/connection.rs 90.00% 18/20 new
crates/client-pull/src/downloader.rs 94.13% 353/375 new
crates/client-pull/src/lib.rs 90.96% 2093/2301 ▲ +0.28%
crates/client-pull/src/scheduler.rs 94.16% 2207/2344 ▲ +0.24%
crates/client-pull/src/sink.rs 94.38% 252/267 ▼ 3.62%
crates/client-pull/src/streamer.rs 89.71% 671/748 new
History
Commit Total Δ vs base
2e61752 83.81% ▲ +0.95%
037c8cc 83.82% ▲ +0.08%
fd71689 83.81% ▲ +0.11%
329e70d 83.81% ▲ +0.95%
d79cfb9 83.82% ▲ +0.13%
e89d925 83.82% ▲ +0.13%
71df694 83.92% ▲ +0.12%
a857b97 83.95% ▲ +0.10%
05bf6ad (HEAD) 83.97% ▲ +0.13%

alpergundogdu and others added 2 commits September 22, 2026 11:10
…amer

Address Copilot review on #2108:

- present_frontier no longer swallows a present_ranges() fault as "nothing
  present" (which could stall the reader or look like early EOF); it returns a
  Result and the read future surfaces it to the consumer.
- The cursor advance converts the read length to u64 BEFORE handing out bytes
  and fails loudly on the (practically impossible) overflow, so the cursor can
  never desynchronize from bytes already delivered.
- BlobCache docs now state the actual behaviour: a whole-blob cache hit serves
  without fetching, anything less is refetched in full (store resume, not the
  cache, avoids re-pulling a partial prefix today); partial-prefix complement is
  noted as a planned enhancement.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Thread a ConsumptionPacing seam through multi_source_fetch to its per-lane
workers, so a Streamer can bound a multi-source fetch to one read-ahead window
ahead of a live consumer's read cursor — the keystone that lets the Downloader
and Streamer become two configs over the one multi-source core instead of two
engines.

fill_gap already took `downstream` + `pacing_wait`; the scheduler just didn't
pass them. Now multi_source_fetch (and run_worker) take
`pacing: Option<&ConsumptionPacing>` and thread it to each worker's fill_gap. A
WindowPacer then gates every lane against the shared consumer cursor: a lane
whose delivered frontier runs a window past the cursor waits until the consumer
reads more. `None` (every existing caller) keeps the eager, unbounded fan-out
verbatim — the whole existing scheduler suite is unchanged.

Test: a 1-lane fetch under WindowPacer + an injected consumer cursor completes
byte-identical ONLY by parking on a full window and being unstuck via the pacing
hook (proven to fail with cursor=0 when the seam is not threaded).

Follow-up (Phase 2): the Streamer replaces its single-source drive with this
consumption-paced multi_source_fetch (candidate failover + small-cap fan-out).

Part of the Downloader/Streamer core-unification (spec
2026-09-22-multi-source-core-and-face-unification-design).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ailover (#1848)

Phase 2: replace the Streamer's single-source `drive` with the consumption-paced
`multi_source_fetch`, so a stream fetches its front across a small, bounded set
of provider candidates and fails over between them.

- Streamer::new now takes a Vec<StreamCandidate> (source + paying ctx/ledger per
  provider) instead of one source. It drives multi_source_fetch with a
  WindowPacer(read_ahead) + the consumer cursor as the downstream frontier
  (ConsumptionPacing), capped to PullConfig::streamer_lane_cap (new tunable,
  default 2). VerifiedReader is unchanged.
- A candidate that faults mid-stream is dropped and its remainder reassigned to
  another (shared-pool free failover, #1174), resuming from the store's verified
  frontier so no delivered byte is re-pulled or re-paid.
- The no-verified-progress watchdog is off (unit_deadline ZERO): a paced stream
  parks lanes on the consumer cursor, which is not a stall — a genuinely silent
  source trips its own per-stream throughput floor instead. multi_source_fetch
  does not finalize, so the stream leaves the store at .partial (a stream is not
  kept as a file); the reader reads its checkpointed present frontier as before.

Tests: a mid-stream candidate fault fails over and the drained stream is
BLAKE3-identical (faulty candidate delivered a prefix first); the existing drain
/ tampered / cache / bounded tests all still pass on the multi-source core.

Stacked on the Phase 1 scheduler change. Follow-up (Phase 3): Downloader
reshaped onto this core as a wrapper (uncapped fan-out + dedup pre-seed).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…up) (#1848)

Phase 3: reshape the Downloader onto the same shared core the Streamer uses,
uncapped for full-throughput download.

- Downloader::new now takes a Vec<StreamCandidate> (the shared provider-candidate
  type) instead of one source + pacer + ctx + ledger. fetch_to_dir builds one
  lane per candidate and drives each entry across them through multi_source_fetch
  with a BudgetPacer, no consumption pacing, and max_sources = every candidate
  (uncapped fan-out), then finalizes — promoting .partial to the file. So the two
  faces are now one engine: the Streamer caps the fan-out and paces on the
  consumer cursor; the Downloader uncaps it and runs full throughput.
- Failover comes for free (shared-pool reassign, #1174). A resumed download — an
  existing .partial, e.g. a bundle layer's chunk-hint dedup pre-seeded into it —
  re-pulls only its missing ranges.

Tests: two candidates stripe one blob BLAKE3-identical with both contributing; a
pre-seeded prefix is fetched only as its complement (dedup/resume); the
single-candidate BLAKE3-identical path is unchanged (no regression). Full
client-pull suite 321/321.

Stacked on the Phase 2 Streamer change. Follow-up (Phase 4): CLI rewiring
(bundle pull -> Downloader, decdn fetch -o - -> Streamer, decdn fetch -o file ->
Downloader).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Address Copilot review on #2112: `fetch_to_dir` now fails with a clear
"needs at least one provider candidate" error before opening any store or
building empty lane sets, instead of surfacing a less obvious fault deep inside
multi_source_fetch on the first entry. Test locks the behaviour.

(The other finding — an unused `RangedStore` import — is a false positive: the
import is used by `store.finalize()`, a `RangedStore` trait method, and clippy
under -D warnings is clean.)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu alpergundogdu changed the title feat(client-pull): add Downloader and Streamer consumption faces over the paid pull engine (#1848) feat(client-pull): add Downloader and Streamer consumption faces over a unified multi-source core (#1848) Sep 22, 2026
@alpergundogdu alpergundogdu changed the title feat(client-pull): add Downloader and Streamer consumption faces over a unified multi-source core (#1848) feat(client-pull): add Downloader and Streamer consumption faces over a unified multi-source core Sep 22, 2026
…tatic)

The Streamer required S: BlobSource + 'static, which the tests met (ScriptedSource
is 'static) but a real PeerSource — which borrows &Endpoint — does not. Relax it:
VerifiedReader / LiveReader gain a lifetime 'a, the drive future is boxed as
`+ 'a` instead of 'static, and Streamer::open returns VerifiedReader<'a> with
S: 'a, F: 'a. The store-read future still captures an Arc and stays 'static.

This unblocks wiring the Streamer into `decdn fetch` (a borrowing PeerSource);
behaviour is unchanged and the whole streamer/downloader suite still passes.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It reshapes the core UpstreamPull connection-teardown contract that all production paid-pull paths depend on and adds substantial new streaming/scheduling surface, warranting human review despite the changes appearing correct and well-tested.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
Resolved since last review (3)

Comment thread crates/client-pull/src/sink.rs Resolved
alpergundogdu and others added 3 commits September 22, 2026 14:09
…tion consumer

The ByteSink module and trait docs claimed the Downloader "backs this with a
file", but the Downloader writes its output through a ClientRangedStore (which
promotes the verified .partial to the final file on finalize), never through
ByteSink; the only implementor is a test Vec. Reword both doc sites to describe
current behavior per the repo's present-tense-canon rule: ByteSink is an output
seam with no production consumer yet, and the Streamer is what drives BlobCache.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
… faces (#1848)

`StreamCandidate` gains an optional `coverage` field: the candidate's measured
block coverage for the blob being fetched (#1506), or `None` to treat it as a
full holder. Both faces build their lanes through a shared `source_lanes`
helper that threads each candidate's coverage into its `SourceLane` (a `None`
candidate maps to `Coverage::full` sized to the blob), replacing the hardcoded
full-coverage assumption in `run_drive` and `fetch_to_dir`.

This closes the no-regression gap before the CLI adopts the faces: today the
inline multi-source path threads each node's real probed coverage, so a partial
holder is never asked for a range it does not hold; without this the faces would
ask a partial holder for its missing ranges.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
`fetch_to_dir` takes an optional `on_progress: Option<&ProgressCallback>` and
forwards it into `multi_source_fetch`, so a CLI drawing a download bar gets the
core's verified CONTENT progress for the entry currently fetching —
`(position, total_bytes)`, both content bytes, resetting per entry. A
single-entry download uses it directly; a multi-entry caller accumulates
completed entries' totals itself. Previously the on_progress slot was hardcoded
`None`, leaving the download face with no way to report progress.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
alpergundogdu and others added 6 commits September 22, 2026 15:50
…1848)

Add `Downloader::fetch_to_paths(&[DownloadTarget], config, on_progress)`: each
`DownloadTarget { hash, total_bytes, dest }` is fetched to its own `dest` path,
with the `.partial` store and the promoted final file keyed by that name, so the
finished file IS `dest` — no post-finalize rename, and a resumed download
re-pulls only what it lacks. `fetch_to_dir` becomes a thin convenience over it
that names each file by content-address hex under a directory (behavior
unchanged).

This is the surface the CLI needs to become a thin layer over the face: `decdn
fetch -o <file>` writes one blob to that path, and `bundle pull` writes each
entry to its manifest path.

Also add `PullConfig::download_unit_deadline` (default 30s) and have the
Downloader read it as the per-lane stall watchdog, replacing the hardcoded
constant — so a CLI caller can keep honoring `--unit-deadline-ms`.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…istry (#1848)

`Downloader::fetch_to_paths` gains an `ledgers: Option<&LaneLedgers>` parameter,
threaded into `multi_source_fetch`. With a shared registry the core reads and
credits EVERY lane registered across the run for its deposit-solvency view, so
concurrent bundle entries drawing on ONE on-chain pool cannot jointly over-draw
it; `None` folds only this fetch's own lanes, the right view for a solo
download. `fetch_to_dir` delegates with `None`.

This is the last surface `bundle pull` needs to run its per-entry whole-file
fetch through the Downloader face (4a).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ng sink (#1848)

On a clean finish the `Streamer` teed the whole verified blob to its cache for a
revisit — `store.read(0, total)` into one `Bytes`, then `cache.put`. That ran
unconditionally, so `decdn fetch -o -` (which passes `NoCache`) read the entire
blob into memory at the end of the stream just to hand it to a no-op cache and
drop it, spiking a huge blob's whole size into RAM and defeating the point of a
consumption-paced stream.

`BlobCache` gains a `caches()` predicate (default `true`); `NoCache` returns
`false`, and the tee's whole-blob read is now gated on it. A real cache still
gets teed; a no-op one never triggers the read, so the stream stays
memory-bounded (one read-ahead window) end to end.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Resolve the #2116 × #1848 overlap in client-pull:
- lib.rs re-exports: keep both the #1848 `downloader::{DownloadTarget,
  Downloader}` line and #2116's added `WaitReason` on the `driver` re-export.
- #2116 gave `PacingWait::wait` a third `reason: WaitReason` arg (metering
  only). Update the two #1848 impls to the new signature: `ConsumedWait`
  (streamer.rs) and the `BumpConsumer` test double (scheduler.rs), taking
  `_reason` since neither meters.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Resolve the #2121 × #1848 re-export overlap in client-pull/lib.rs: keep the
#1848 `scheduler::ConsumptionPacing`, `sink::{BlobCache, ByteSink, NoCache,
SinkFuture}`, and `streamer::{StreamCandidate, Streamer, VerifiedReader}`
re-exports, and add #2121's new `source::SourceFuture`. scheduler.rs
auto-merged.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…parked lane on a front fault

The Streamer's fetch advanced only inside VerifiedReader::poll_read, and
only once the buffered bytes were drained. While a slow or paused
consumer held the reader, an open paid leg sent no vouchers and read no
bytes, so the node's proof-read timeout or the client's own stall and
throughput floors faulted the lane.

Streamer::open now returns the reader plus a StreamDrive future the
caller polls for the whole stream (StreamDrive::alongside runs a read
loop beside it). The read-ahead window, not the reads, bounds how far it
runs. The reader waits on the drive's progress wakeups and reads the
verified prefix in bounded chunks. A drive dropped early ends the reader
with an error instead of a hang.

Under consumption pacing, a lane parked on a full window held a range
that the consumer could never reach once a lane nearer the front
faulted: its re-queued remainder had no free worker, and the stream hung
with no bytes out. A parked lane now hands its range back when an
earlier range it can serve waits in the queue, and a paced fetch picks
the lowest-offset range first.

read_ahead_bytes below PULL_WINDOW_FLOOR is raised to it; a smaller
window could floor a lane's room to zero before the first byte and
park forever.

Tests: front-lane fault with a far-parked peer (hung before), a paused
consumer still fills one window and no more, a sub-floor read-ahead
completes, and the bounded read-ahead check at the effective floor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZoHLSQnBwMc7sibyFC9E7
@thiras
thiras merged commit 4db4e17 into main Sep 22, 2026
25 checks passed
@thiras
thiras deleted the claude/trusting-raman-1b3304 branch September 22, 2026 20:22
thiras pushed a commit that referenced this pull request Sep 22, 2026
…es (#1848) (#2114)

* feat(client-pull): reuse a warm connection across hashes (WarmConnection)

Add WarmConnection: a caller-owned cdn/client/v1 connection dialled once and
reused across many hashes, opening a fresh bi-stream per hash (one stream = one
hash, no wire change). open_stream takes a ConnSource (dial a fresh one-shot
connection or reuse a warm one); open_progressive_pull keeps the dial path and
open_progressive_pull_on opens a pull on a warm connection. UpstreamPull now
tracks whether it owns its connection: an owned one-shot dial is closed on the
pull's terminal method, while a borrowed warm connection is left open for the
next hash — only the current stream is torn down. The warm connection closes
once, on its own Drop.

Test: two distinct hashes fetched back-to-back over one WarmConnection dial the
connection exactly once (client_loopback::two_hashes_reuse_one_warm_connection).

Part of #1848 (T1).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(client-pull): add PullConfig zero-config tunables scaffold

Add config::PullConfig, the injected tunables the consumption faces
(Downloader, Streamer, #1848) share. It holds only tunables, each with a
sensible default, so PullConfig::default() is the whole configuration a caller
needs; the required per-fetch inputs (identity, connection, spend budget,
providers) stay on the engine's existing params, which is why PullConfig
constructs with no network or chain access (proven by a const construction).

The first tunable is the Streamer's read_ahead_bytes bound (default 16 MiB);
more fields are added as Downloader (T4) and Streamer (T6) grow to consume them.
The payment interval stays the fixed protocol const CHUNK_BYTES, not a tunable.

Part of #1848 (T2).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(client-pull): add ByteSink output + injected BlobCache traits

Add the output side of a fetch to sink.rs (#1848 T3):

- ByteSink: where the engine writes verified content bytes, at absolute
  offsets, so an out-of-order multi-source fetch lands each range at its
  position. The Downloader backs it with a file.
- BlobCache: the injected (hash, offset) content cache the Streamer consults
  and fills. Pure — it names no blob store — so client-pull stays
  iroh-blobs-free; a blob-store-backed impl is injected from above. The default
  is the no-op NoCache (never hits, never stores).

Both use the crate's boxed-future async-trait shape (SinkFuture). Test doubles
VecByteSink and MemoryBlobCache ship under test-util for the Downloader/Streamer
suites. check_crate_edges.py still passes (decdn-cli closure clean).

Part of #1848 (T3).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(client-pull): add Downloader (bundle/blob fetch-to-dir face)

Add the Downloader consumption face (#1848 T4): fetch a set of content-addressed
blobs — a bundle, or a single blob — to files in a directory. It is an
output+scheduling adapter over the ONE paid pull engine, not a second engine:
each (hash, total_bytes) entry opens a ClientRangedStore beside dir/<hex> and
drives only its missing ranges through driver::drive, which bao-verifies every
byte on ingest and promotes .partial to the final file on completion. So writes
land out-of-order at their offsets, a resumed download re-pulls only what it
lacks, and a bundle layer above can pre-seed held ranges (its chunk-hint dedup)
into the store so the same drive fills only the complement.

Bundles are the main scenario (a bundle is a set of entries → one file each,
named by content-address hex; a single blob is a bundle of one). The pull
machinery (source, pacer, funder, ctx, ledger) is injected and shared across
every entry, so one provider connection and one payment channel serve a whole
bundle. fetch_to_dir takes &PullConfig for symmetry with the Streamer; the
Downloader fetches at full throughput, so no tunable changes its behaviour yet.

decdn fetch / bundle pull are rewired onto this in later PRs.

Part of #1848 (T4).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(client-pull): add Streamer + VerifiedReader (consumption-paced fetch)

Add the Streamer consumption face (#1848 T5+T6): stream one blob's verified,
contiguous front to a consumer as it arrives, paced by how fast the consumer
reads — the fetch-like, single-blob face (no chunk dedup, unlike the Downloader).

One engine, two faces: the Streamer configures the SAME paid pull engine, not a
second one. It drives the fetch through driver::drive with a WindowPacer whose
window is PullConfig::read_ahead_bytes and whose downstream frontier is the
CONSUMER'S read cursor — the bounded-read-ahead mode the driver already supports
(window_pacer_gates_on_injected_served_paid), so T5 needs no engine change. The
pull never runs more than one read-ahead window ahead of what the consumer has
read, so a viewer who stops after five minutes never fetches (or pays for) the
whole two-hour movie; that read-ahead bound IS the outstanding-spend bound.

VerifiedReader is the tokio::io::AsyncRead the caller drains. It cooperatively
polls the drive future inside poll_read and reads only the store's CHECKPOINTED
present frontier, so it is clamped to the verified contiguous frontier by
construction — a tampered chunk group fails the pull and surfaces as a read error
rather than ever reaching the consumer. On a clean finish the whole verified blob
is teed to the injected BlobCache; a revisit whose cache already holds the blob
serves straight from memory and never touches the network.

Tests: drained stream BLAKE3-identical; a tampered tail never surfaces (verified
prefix only, then an error); a full cache hit fetches nothing; a slow consumer
holds the in-flight bytes within the read-ahead bound.

decdn fetch is rewired onto this in a later PR.

Part of #1848 (T5, T6).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix(client-pull): surface store errors + fail-loud cursor in the Streamer

Address Copilot review on #2108:

- present_frontier no longer swallows a present_ranges() fault as "nothing
  present" (which could stall the reader or look like early EOF); it returns a
  Result and the read future surfaces it to the consumer.
- The cursor advance converts the read length to u64 BEFORE handing out bytes
  and fails loudly on the (practically impossible) overflow, so the cursor can
  never desynchronize from bytes already delivered.
- BlobCache docs now state the actual behaviour: a whole-blob cache hit serves
  without fetching, anything less is refetched in full (store resume, not the
  cache, avoids re-pulling a partial prefix today); partial-prefix complement is
  noted as a planned enhancement.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(client-pull): consumption-pace the multi-source scheduler (#1848)

Thread a ConsumptionPacing seam through multi_source_fetch to its per-lane
workers, so a Streamer can bound a multi-source fetch to one read-ahead window
ahead of a live consumer's read cursor — the keystone that lets the Downloader
and Streamer become two configs over the one multi-source core instead of two
engines.

fill_gap already took `downstream` + `pacing_wait`; the scheduler just didn't
pass them. Now multi_source_fetch (and run_worker) take
`pacing: Option<&ConsumptionPacing>` and thread it to each worker's fill_gap. A
WindowPacer then gates every lane against the shared consumer cursor: a lane
whose delivered frontier runs a window past the cursor waits until the consumer
reads more. `None` (every existing caller) keeps the eager, unbounded fan-out
verbatim — the whole existing scheduler suite is unchanged.

Test: a 1-lane fetch under WindowPacer + an injected consumer cursor completes
byte-identical ONLY by parking on a full window and being unstuck via the pacing
hook (proven to fail with cursor=0 when the seam is not threaded).

Follow-up (Phase 2): the Streamer replaces its single-source drive with this
consumption-paced multi_source_fetch (candidate failover + small-cap fan-out).

Part of the Downloader/Streamer core-unification (spec
2026-09-22-multi-source-core-and-face-unification-design).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(client-pull): Streamer on the multi-source core with candidate failover (#1848)

Phase 2: replace the Streamer's single-source `drive` with the consumption-paced
`multi_source_fetch`, so a stream fetches its front across a small, bounded set
of provider candidates and fails over between them.

- Streamer::new now takes a Vec<StreamCandidate> (source + paying ctx/ledger per
  provider) instead of one source. It drives multi_source_fetch with a
  WindowPacer(read_ahead) + the consumer cursor as the downstream frontier
  (ConsumptionPacing), capped to PullConfig::streamer_lane_cap (new tunable,
  default 2). VerifiedReader is unchanged.
- A candidate that faults mid-stream is dropped and its remainder reassigned to
  another (shared-pool free failover, #1174), resuming from the store's verified
  frontier so no delivered byte is re-pulled or re-paid.
- The no-verified-progress watchdog is off (unit_deadline ZERO): a paced stream
  parks lanes on the consumer cursor, which is not a stall — a genuinely silent
  source trips its own per-stream throughput floor instead. multi_source_fetch
  does not finalize, so the stream leaves the store at .partial (a stream is not
  kept as a file); the reader reads its checkpointed present frontier as before.

Tests: a mid-stream candidate fault fails over and the drained stream is
BLAKE3-identical (faulty candidate delivered a prefix first); the existing drain
/ tampered / cache / bounded tests all still pass on the multi-source core.

Stacked on the Phase 1 scheduler change. Follow-up (Phase 3): Downloader
reshaped onto this core as a wrapper (uncapped fan-out + dedup pre-seed).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(client-pull): Downloader on the multi-source core (fan-out + dedup) (#1848)

Phase 3: reshape the Downloader onto the same shared core the Streamer uses,
uncapped for full-throughput download.

- Downloader::new now takes a Vec<StreamCandidate> (the shared provider-candidate
  type) instead of one source + pacer + ctx + ledger. fetch_to_dir builds one
  lane per candidate and drives each entry across them through multi_source_fetch
  with a BudgetPacer, no consumption pacing, and max_sources = every candidate
  (uncapped fan-out), then finalizes — promoting .partial to the file. So the two
  faces are now one engine: the Streamer caps the fan-out and paces on the
  consumer cursor; the Downloader uncaps it and runs full throughput.
- Failover comes for free (shared-pool reassign, #1174). A resumed download — an
  existing .partial, e.g. a bundle layer's chunk-hint dedup pre-seeded into it —
  re-pulls only its missing ranges.

Tests: two candidates stripe one blob BLAKE3-identical with both contributing; a
pre-seeded prefix is fetched only as its complement (dedup/resume); the
single-candidate BLAKE3-identical path is unchanged (no regression). Full
client-pull suite 321/321.

Stacked on the Phase 2 Streamer change. Follow-up (Phase 4): CLI rewiring
(bundle pull -> Downloader, decdn fetch -o - -> Streamer, decdn fetch -o file ->
Downloader).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix(client-pull): reject an empty Downloader candidate set early

Address Copilot review on #2112: `fetch_to_dir` now fails with a clear
"needs at least one provider candidate" error before opening any store or
building empty lane sets, instead of surfacing a less obvious fault deep inside
multi_source_fetch on the first entry. Test locks the behaviour.

(The other finding — an unused `RangedStore` import — is a false positive: the
import is used by `store.finalize()`, a `RangedStore` trait method, and clippy
under -D warnings is clean.)

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* refactor(client-pull): let VerifiedReader borrow its sources (drop 'static)

The Streamer required S: BlobSource + 'static, which the tests met (ScriptedSource
is 'static) but a real PeerSource — which borrows &Endpoint — does not. Relax it:
VerifiedReader / LiveReader gain a lifetime 'a, the drive future is boxed as
`+ 'a` instead of 'static, and Streamer::open returns VerifiedReader<'a> with
S: 'a, F: 'a. The store-read future still captures an Arc and stays 'static.

This unblocks wiring the Streamer into `decdn fetch` (a borrowing PeerSource);
behaviour is unchanged and the whole streamer/downloader suite still passes.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* docs(client-pull): describe ByteSink as it is — a seam with no production consumer

The ByteSink module and trait docs claimed the Downloader "backs this with a
file", but the Downloader writes its output through a ClientRangedStore (which
promotes the verified .partial to the final file on finalize), never through
ByteSink; the only implementor is a test Vec. Reword both doc sites to describe
current behavior per the repo's present-tense-canon rule: ByteSink is an output
seam with no production consumer yet, and the Streamer is what drives BlobCache.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(client-pull): thread per-candidate coverage into the consumption faces (#1848)

`StreamCandidate` gains an optional `coverage` field: the candidate's measured
block coverage for the blob being fetched (#1506), or `None` to treat it as a
full holder. Both faces build their lanes through a shared `source_lanes`
helper that threads each candidate's coverage into its `SourceLane` (a `None`
candidate maps to `Coverage::full` sized to the blob), replacing the hardcoded
full-coverage assumption in `run_drive` and `fetch_to_dir`.

This closes the no-regression gap before the CLI adopts the faces: today the
inline multi-source path threads each node's real probed coverage, so a partial
holder is never asked for a range it does not hold; without this the faces would
ask a partial holder for its missing ranges.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(client-pull): give the Downloader a progress hook (#1848)

`fetch_to_dir` takes an optional `on_progress: Option<&ProgressCallback>` and
forwards it into `multi_source_fetch`, so a CLI drawing a download bar gets the
core's verified CONTENT progress for the entry currently fetching —
`(position, total_bytes)`, both content bytes, resetting per entry. A
single-entry download uses it directly; a multi-entry caller accumulates
completed entries' totals itself. Previously the on_progress slot was hardcoded
`None`, leaving the download face with no way to report progress.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(cli): stream decdn fetch -o - to stdout over the Streamer face (#1848)

`decdn fetch -o -` now streams a blob's bao-verified bytes straight to stdout
through the `decdn_client_pull::Streamer` consumption face, instead of writing a
file literally named `-`. A file named `-` is still writable as `./-`.

The path is thin over the face: it builds the candidate lanes exactly as the
multi-source file path does (per-provider pool, ctx, ledger, real probed
coverage threaded into each StreamCandidate), then opens a VerifiedReader and
copies it to stdout. Only bao-verified bytes ever reach the pipe (safe to
`| tar x`); the fetch is consumption-paced, so a slow or early-quit consumer
stops the pull — and the spend — within one read-ahead window; a candidate that
faults mid-stream fails over to another with no re-pull or re-pay. There is no
resume-to-disk on a pipe. Progress draws on stderr and is suppressed when stdout
is not a TTY, so a piped consumer sees clean bytes. Each lane's voucher
watermark is persisted after the stream, exactly as the file path does — the
face does not persist, so this thin CLI layer keeps doing it.

Verified end-to-end (`cli_fetch_stdout`, anvil-gated): a real paid stream to a
real node produces byte-identical stdout and a non-zero persisted watermark.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix(cli): fail over the stdout stream's header probe across candidates (#1848)

Address review of the `decdn fetch -o -` path:

- Clamp `--max-sources` to at least one when admitting sources, so `0` no longer
  yields an empty admitted set (an immediate "no candidate holders" error) — the
  Streamer already caps at >=1 lane.
- Learn `total_bytes` by failing over the header-only open ACROSS the admitted
  lanes until one answers, instead of only probing the first. An unreachable or
  refusing first holder no longer sinks the whole stream when others are healthy,
  so `-o -` gets candidate failover end to end.
- Do not suppress a candidate for an `InsufficientDeposit` refusal (our deposit
  vs the node's floor, not a peer fault), mirroring `open_fetch_prelude`.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(client-pull): let the Downloader fetch to caller-chosen paths (#1848)

Add `Downloader::fetch_to_paths(&[DownloadTarget], config, on_progress)`: each
`DownloadTarget { hash, total_bytes, dest }` is fetched to its own `dest` path,
with the `.partial` store and the promoted final file keyed by that name, so the
finished file IS `dest` — no post-finalize rename, and a resumed download
re-pulls only what it lacks. `fetch_to_dir` becomes a thin convenience over it
that names each file by content-address hex under a directory (behavior
unchanged).

This is the surface the CLI needs to become a thin layer over the face: `decdn
fetch -o <file>` writes one blob to that path, and `bundle pull` writes each
entry to its manifest path.

Also add `PullConfig::download_unit_deadline` (default 30s) and have the
Downloader read it as the per-lane stall watchdog, replacing the hardcoded
constant — so a CLI caller can keep honoring `--unit-deadline-ms`.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(cli): route decdn fetch -o file through the Downloader face (#1848)

The multi-source engagement for `decdn fetch -o <file>` now runs through the
`decdn_client_pull::Downloader` face instead of the CLI calling
`multi_source_fetch` inline. `download_to_file` applies the same gate (pre-probe
and authoritative-header size checks), builds one payment lane per admitted
candidate, then hands the candidate set to `Downloader::fetch_to_paths` with the
output path — the face stripes across the holders, fails over between them,
bao-verifies every byte, and promotes the `.partial` beside `--output` to
`--output` (keyed by that name, so resume is unchanged). `--unit-deadline-ms` is
honored via `PullConfig::download_unit_deadline`, and each lane's watermark is
persisted after, exactly as before.

When the gate declines (blob below the fan-out floor, or fewer than two
operator-distinct holders), it returns `Ok(None)` and the single-source failover
loop and store-fast-path rediscovery run unchanged — no regression.

The stdout path (4b) and this file path now share three helpers:
`build_admitted_lanes_and_total` (lane build + header-probe failover),
`split_face_lanes` (MultiLane -> StreamCandidate + watermark handle), and
`persist_face_watermarks`. The now-unused `try_multi_source_fetch` wrapper is
removed; `bundle pull` keeps using `try_multi_source_fetch_from_admitted`.

Verified end-to-end (anvil): cli_fetch_multi_source (the file path's multi-source
engagement, now through the Downloader), cli_fetch_resume, cli_fetch_topup,
cli_fetch_delegated, and cli_fetch_stdout all pass.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(client-pull): let the Downloader share a bundle run's ledger registry (#1848)

`Downloader::fetch_to_paths` gains an `ledgers: Option<&LaneLedgers>` parameter,
threaded into `multi_source_fetch`. With a shared registry the core reads and
credits EVERY lane registered across the run for its deposit-solvency view, so
concurrent bundle entries drawing on ONE on-chain pool cannot jointly over-draw
it; `None` folds only this fetch's own lanes, the right view for a solo
download. `fetch_to_dir` delegates with `None`.

This is the last surface `bundle pull` needs to run its per-entry whole-file
fetch through the Downloader face (4a).

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* feat(cli): route bundle pull's whole-file fetch through the Downloader (#1848)

`bundle pull`'s per-entry whole-file multi-source engagement now runs through the
`Downloader` face, the last CLI fetch path still calling `multi_source_fetch`
inline. Its `try_multi_source` hands its already-admitted candidate set — plus
the bundle-wide open lock and shared `LaneLedgers` registry — to the new shared
`fetch::multi_source_download`, which builds one lane per candidate, applies the
authoritative header size gate, and fetches to the entry's staging path via
`Downloader::fetch_to_paths` (threading the shared registry so concurrent entries
keep one solvency view of the deposit). The range-dedup / chunk-hint splice path
(`drive_ranges_ordered`) is untouched, so chunk-hint dedup keeps working exactly
as before; the whole-file path is the one that now goes through the face.

Refactor: `download_to_file` (4c) and bundle now share `multi_source_download`;
the shared `build_admitted_lanes_and_total` grew `open_lock`/`ledgers`
parameters. The inline `try_multi_source_fetch_from_admitted` and its
`lane_watermarks` helper — the last direct `multi_source_fetch` callers in the
CLI — are removed. Every CLI fetch path (`decdn fetch -o -`, `-o <file>`, and
`bundle pull`) now goes through a consumption face.

Verified end-to-end (anvil), no regression: cli_bundle_pull_multi_source (the
whole-file path, now through the Downloader), _pool_id, _range_dedup (dedup,
self-heal, from-optimize, cross-run reuse, shared-lane concurrency), plus
cli_fetch_multi_source and cli_fetch_resume.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix(client-pull): don't materialize the whole blob to tee a non-caching sink (#1848)

On a clean finish the `Streamer` teed the whole verified blob to its cache for a
revisit — `store.read(0, total)` into one `Bytes`, then `cache.put`. That ran
unconditionally, so `decdn fetch -o -` (which passes `NoCache`) read the entire
blob into memory at the end of the stream just to hand it to a no-op cache and
drop it, spiking a huge blob's whole size into RAM and defeating the point of a
consumption-paced stream.

`BlobCache` gains a `caches()` predicate (default `true`); `NoCache` returns
`false`, and the tee's whole-blob read is now gated on it. A real cache still
gets teed; a no-op one never triggers the read, so the stream stays
memory-bounded (one read-ahead window) end to end.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix(client-pull): drive the Streamer apart from its reads; unwedge a parked lane on a front fault

The Streamer's fetch advanced only inside VerifiedReader::poll_read, and
only once the buffered bytes were drained. While a slow or paused
consumer held the reader, an open paid leg sent no vouchers and read no
bytes, so the node's proof-read timeout or the client's own stall and
throughput floors faulted the lane.

Streamer::open now returns the reader plus a StreamDrive future the
caller polls for the whole stream (StreamDrive::alongside runs a read
loop beside it). The read-ahead window, not the reads, bounds how far it
runs. The reader waits on the drive's progress wakeups and reads the
verified prefix in bounded chunks. A drive dropped early ends the reader
with an error instead of a hang.

Under consumption pacing, a lane parked on a full window held a range
that the consumer could never reach once a lane nearer the front
faulted: its re-queued remainder had no free worker, and the stream hung
with no bytes out. A parked lane now hands its range back when an
earlier range it can serve waits in the queue, and a paced fetch picks
the lowest-offset range first.

read_ahead_bytes below PULL_WINDOW_FLOOR is raised to it; a smaller
window could floor a lane's room to zero before the first byte and
park forever.

Tests: front-lane fault with a far-parked peer (hung before), a paused
consumer still fills one window and no more, a sub-floor read-ahead
completes, and the bounded read-ahead check at the effective floor.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZoHLSQnBwMc7sibyFC9E7

* fix(cli): drive the stdout stream beside the copy; build fan-out lanes after the size gate

`decdn fetch -o -` now runs the Streamer's drive beside the stdout copy
(StreamDrive::alongside), so a blocked pipe no longer stops an open paid
leg from paying and draining; the read-ahead window bounds how far it
runs ahead.

The stream also honors the multi-source kill switch (one lane at a time,
the other holders stay failover candidates), draws its bar only when
stderr is a terminal, and annotates an unbound-namespace cache miss on
failure like the file path.

probe_admitted_total builds lanes one candidate at a time and stops at
the first holder that answers the header open. The file download and
bundle pull build the remaining lanes only once the authoritative size
gate engages, so a declined fan-out opens no extra pool and takes no
extra open_lock turn.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01AZoHLSQnBwMc7sibyFC9E7

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants