Skip to content

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

Merged
alpergundogdu merged 1 commit into
claude/trusting-raman-1b3304from
claude/streamer-multi-source-failover
Sep 22, 2026
Merged

alpergundogdu merged 1 commit into
claude/trusting-raman-1b3304from
claude/streamer-multi-source-failover

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Stacked on #2110 (which is stacked on #2108). Phase 2 of the Downloader/Streamer core-unification.

What & why

Replaces the Streamer's single-source drive with the consumption-paced multi_source_fetch (from #2110), so a stream fetches its front across a small, bounded set of provider candidates and fails over between them — one resilience/verify path, the same core the Downloader will use.

  • 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, Client: implement proxy-warming trigger #1174), resuming from the store's verified frontier — 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 doesn't finalize, so the stream leaves the store at .partial (a stream isn't kept as a file); the reader reads its checkpointed present frontier as before.

Tests

  • New: a mid-stream candidate fault fails over and the drained stream is BLAKE3-identical (the faulty candidate delivered a prefix first, proving mid-stream failover).
  • Behavior-preserving: the existing drain / tampered-tail / cache-hit / bounded-read-ahead tests all still pass on the multi-source core (single-candidate case). Full client-pull suite: 319/319.

Note on fan-out under a small window (per the design spec)

spread_segments seeds at 64 MiB-block granularity, so for a large blob with two whole-blob holders they split front/back and under a small window the back lane parks — the front is single-lane + failover + a pipelined second lane. Blobs ≤64 MiB get true 2-lane front fan-out. Concurrent front fan-out on a large blob needs a steal-preference-under-window tweak; deferred (single-lane-front + failover is a fine first cut, and the lane cap is just a number when we want to revisit).

Follow-up

  • Phase 3: Downloader reshaped onto this core as a wrapper (uncapped fan-out + dedup pre-seed).
  • Phase 4: CLI rewiring.

Design spec: ~/Workspace/decdn/specs/2026-09-22-multi-source-core-and-face-unification-design.md.

🤖 Generated with Claude Code

…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]>
Copilot AI lite review requested due to automatic review settings September 22, 2026 11:53

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 Streamer cache-miss path should validate empty candidate sets and a zero lane cap up front to avoid deferred “first read” failures and surprising tunable behavior.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 Medium severity

Open (1)
What changed in this PR

This PR continues the client-pull “core unification” work by moving the Streamer off the single-source drive path and onto the consumption-paced multi_source_fetch scheduler, enabling bounded parallelism and mid-stream candidate failover while keeping VerifiedReader semantics (only verified bytes are readable).

Changes:

  • Refactors Streamer to accept a Vec<StreamCandidate> (per-provider source + (ctx, ledger)) and to drive multi_source_fetch with ConsumptionPacing and a WindowPacer(read_ahead).
  • Adds PullConfig::streamer_lane_cap (default 2) to cap Streamer front fan-out and exports the new default constant.
  • Adds a new unit test that injects a mid-stream candidate fault and asserts failover still yields byte-identical output.
File Description
crates/​client-pull/​src/​streamer.rs Switches Streamer over to multi-source fetching with consumption pacing, lane cap, and failover; adds a failover test.
crates/​client-pull/​src/​lib.rs Re-exports StreamCandidate and DEFAULT_STREAMER_LANE_CAP for downstream use.
crates/​client-pull/​src/​config.rs Adds streamer_lane_cap tunable and its default constant to PullConfig.

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

Comment on lines +173 to +182
let ms = MultiSourceConfig {
// Small, bounded front parallelism: a paced stream wants a little
// same-region fan-out and free failover, not a full download's striping.
max_sources: lane_cap.max(1),
// The Streamer parks lanes on the consumer cursor — a full read-ahead
// window is not a stall — so the no-verified-progress watchdog is off. A
// genuinely silent source instead trips its own per-stream throughput
// floor mid-read and is reassigned that way.
unit_deadline: Duration::ZERO,
};
Base automatically changed from claude/multi-source-consumption-pacing to claude/trusting-raman-1b3304 September 22, 2026 12:44
@alpergundogdu
alpergundogdu merged commit 59dcf2b into claude/trusting-raman-1b3304 Sep 22, 2026
1 check passed
@alpergundogdu
alpergundogdu deleted the claude/streamer-multi-source-failover branch September 22, 2026 12:44
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.

2 participants