Skip to content

feat(cli,client): stripe a range-dedup entry's ranges across its holders - #2143

Merged
thiras merged 2 commits into
mainfrom
feat/stripe-range-set
Sep 24, 2026
Merged

thiras merged 2 commits into
mainfrom
feat/stripe-range-set

Conversation

@thiras

@thiras thiras commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Refs #2123 (bullet: stripe a range set across providers)

A range-dedup entry paid for its scattered complement over one provider's link, even when several holders were probed (the gpt-oss original/model.safetensors case in #2119). The entry now stripes its ranges across its admitted full holders.

Design

  • Who stripes (stripe_order): the probed holders whose coverage spans the whole blob, admitted as the multi-source fan-out admits (admit_sources): one node per operator, at most --max-sources.
    • Only with multi-source on, and only when at least two holders are admitted. Otherwise the order and behaviour are unchanged: plain single-source failover.
    • Partial holders and proxy-warming non-holders stay failover reserve, so no striped range lands on a node that lacks it.
  • Client: drive_range_lanes fills a range set across several RangeLanes (source, ctx, ledger, width) from one gap queue into one store.
    • Each gap is filled on one lane from start to end, because the paid frontier is per ledger.
    • A lane that faults retires, and the missing rest of its gap goes back to the front of the queue for the other lanes.
    • A terminal fault (retry_disposition) stops every lane.
    • The first gap waits for the lane that holds the primed first leg, so the primed pull is adopted.
    • RangeSetOutcome reports each lane's fault and the drive's result.
    • drive_range_set is now the one-lane case. Its behaviour is unchanged, and all its existing tests pass as they are.
  • CLI.
    • FetchPrelude no longer owns a store. A range-dedup entry opens one ClientRangedStore, and every session of every drive writes into it. Before this, each session opened its own store on the staging path, and two concurrent writers would overwrite each other's .ranges record.
    • drive_stripe runs the entry's sessions under one drive-level floor and one top-up budget, then settles each lane.
      • A lane that served every gap in a drive that filled every range settles at committed. Any other lane settles at the armed settlement, as multi_lane_watermarks does.
      • A lane is blamed for its own fault. When no lane faulted, every lane is blamed for a drive-level failure (the floor).
  • Walker (SessionWalk):
    • It opens the stripe up front and drops a faulted lane.
    • A failure no lane owns (a floor trip) fails over every open session.
    • When no striped session is left, it falls back to the reserve one candidate at a time.
    • Only the last session a pass opens primes the first leg, so the primed pull does not go stale while the other sessions open (PRIMED_MAX_IDLE).
    • Pinned --node-id, K=1 open/drive order, and error text are unchanged, and the existing walker tests pass.
  • Every leg now checks the provider's signed size against the store's before it reads a byte (SignedSizeMismatch, in fill_gap). Unprimed stripe sessions skip the first-open size check, so without this a wrong manifest size would fail bao verification on every lane. That would blame honest peers and start useless retry rounds. The mismatch is not blamed on the peer and starts no retry round.

Review follow-ups (folded into this commit)

An independent review pass found:

  • Settling at committed on a voucher rejection could land below another gap's armed voucher on the same lane. It now always settles high unless the lane was clean.
  • The unprimed-session size gap described above. The fix is the leg-level check.

Known trade-off

  • A floor trip drops every open striped session for the rest of the entry, the same way K=1 dropped its one session. Later drives of that entry (a deferred fallback, a self-heal) can then use only the reserve. That is the conservative reading of "the providers were too slow". Say so if you'd rather keep the stripe and only retry.
  • A single large gap (the whole-blob self-heal) is not split across lanes. Splitting would break priming adoption. The scattered complement is the case this targets.

Tests

  • driver.rs:
    • a_range_set_spreads_its_gaps_across_lanes
    • a_faulted_lane_retires_and_the_others_fill_its_gaps
    • a_terminal_fault_stops_every_lane
    • a_set_every_lane_fails_is_left_unfinished
    • only_the_lane_that_takes_the_first_gap_opens_it
    • several_lanes_without_a_shared_pool_is_an_error
    • a_leg_whose_signed_size_disagrees_with_the_store_is_refused
    • Requeue, first-gap hold and terminal halt are each mutation-checked, and 15 stress runs were stable.
  • bundle_pull.rs:
    • stripe_order_* (2 tests).
    • New walker tests: stripe opened up front with the last open primed, a faulted lane dropped then the reserve used, a drive-level failure failing every lane over, a stripe member that does not open.
    • FakeSessions adapted, and the 4 existing walker tests are unchanged.
  • New anvil e2e cli_bundle_pull_stripes_a_complement_across_two_holders: two bonded holders, discovered pull.
    • Byte-exact output.
    • The two lanes bill exactly a's whole file plus b's complement once.
    • Both holders serve some of b's ranges.
    • Opens across both nodes equal the paid legs (the primed leg is adopted).
    • It fails with striping forced off, and passed 5/5 runs.

Local verification

  • Workspace clippy -D warnings --all-targets --all-features, rustdoc -D warnings and fmt all pass. The public-api snapshot is regenerated.
  • nextest -p decdn-client -p decdn-cli -p decdn-common --all-features: 1667 pass.
  • -p decdn-node: 1265 pass.
    • In one full run, client_loopback::a_warm_peer_source_drives_a_range_set_on_one_connection and node_origin_pull::concurrent_pulls_resume_at_their_own_frontier_not_the_channels each failed once, then passed on retry.
    • Neither reproduced in two more full runs with --retries 0 or in 25 isolated runs of the loopback test.
    • The second is a known flake on main. For the first I have no failure message, and I did not prove it unrelated.
  • anvil e2e (cli_bundle_pull_range_dedup, cli_bundle_pull_multi_source, cli_fetch_multi_source, cli_fetch_resume): 11 pass.

Not yet confirmed on testnet. Only bcl holds the gpt-oss blob today. A second full holder is needed to see the complement stripe there.

🤖 Generated with Claude Code

Copilot AI lite review requested due to automatic review settings September 24, 2026 08:12
@thiras thiras self-assigned this Sep 24, 2026
@github-code-quality

github-code-quality Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit 6d291fc in the feat/stripe-range-se... branch remains at 85%, unchanged from commit f34e543 in the main branch.

Show a line coverage summary of the most impacted files.
File main f34e543 feat/stripe-range-se... 6d291fc +/-
crates/cli/src/...mmands/fetch.rs 54% 52% -2%
crates/node/src...gin/pull_leg.rs 89% 88% -1%
crates/client/src/lib.rs 93% 93% 0%
crates/cache/src/engine.rs 94% 94% 0%
crates/client/src/driver.rs 97% 97% 0%
crates/client/src/scheduler.rs 95% 95% 0%
crates/client/src/discovery.rs 98% 98% 0%
crates/cli/src/.../bundle_pull.rs 76% 77% +1%

Updated September 24, 2026 09:47 UTC

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

Critical error-handling and peer-blame issues, plus a moderate failover issue, remain unresolved.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity

Open (2)
What changed in this PR

Adds range-dedup striping across admitted full holders using shared storage, multi-lane driving, failover, and signed-size validation.

Changes:

  • Adds multi-lane range driving and settlement.
  • Updates bundle holder admission, session striping, and failover.
  • Adds tests, API snapshots, changelog, and ADR updates.

Review findings:

  • Critical: local I/O failures may incorrectly blame healthy peers.
  • Critical: one-lane post-completion faults may be swallowed.
  • Moderate: ownerless drive failures must clear all open sessions.
  • Nits: fix changelog wording and add unprimed size-mismatch coverage.
File Description
crates/​e2e/​tests/​cli_bundle_pull_range_dedup.rs Adds striped-holder end-to-end coverage.
crates/​common/​src/​cli/​fetch.rs Documents max_sources usage.
crates/​client/​tests/​snapshots/​public_api__public_api.snap Updates the public API snapshot.
crates/​client/​src/​scheduler.rs Adds stoppable multi-source fetching.
crates/​client/​src/​ranged_store.rs Fixes empty-prefix presence tracking.
crates/​client/​src/​lib.rs Exports new client APIs and errors.
crates/​client/​src/​driver.rs Implements multi-lane driving and size checks.
crates/​client/​src/​downloader.rs Adds stoppable downloader support.
crates/​cli/​src/​commands/​fetch.rs Adds shared-store striping and lane settlement.
crates/​cli/​src/​commands/​bundle_pull.rs Adds holder striping and session failover.
CHANGELOG.md Documents behavior changes and fixes.
adr/​appendix-bundles.md Updates bundle range-dedup design.
adr/​039-multi-source-parallel-fetch.md Documents the multi-source throughput floor.

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

Comment thread crates/cli/src/commands/fetch.rs Outdated
Comment on lines +2883 to +2884
let collective = outcome.drive_error().is_some_and(blames_the_peer)
&& (0..lanes.len()).all(|i| outcome.lane_fault(i).is_none());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 6d291fc, which came after this review. drive_stripe now blames every lane only when the drive error is the floor (EntryStalled). A local store, flush or finalize fault blames no peer. SessionWalk also ends on a local disk fault (is_local_disk_fault) and does not fail over to the reserve. Covered by session_walk_stops_on_a_local_disk_fault.

Comment thread crates/client/src/driver.rs Outdated
Comment on lines +789 to +794
if !self.unfinished {
return Ok(());
}
let decisive = self.faults.into_iter().flatten().reduce(keep_decisive);
Err(decisive.unwrap_or_else(|| anyhow::anyhow!("the range set was left unfinished")))
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 6d291fc, a little more broadly than suggested. A drive now fails when every lane faulted, not only when faults.len() == 1, and it is then not finalized. For one lane this restores the old drive_range_set contract. For several lanes it means a drive where every lane faulted, including after its bytes landed, reports a failure, so each lane settles high. A multi-lane drive where some lane served cleanly still succeeds. Regression test: a_fault_after_the_last_byte_fails_a_pooled_one_lane_drive (a fault in finish after the last byte). It fails without the fix.

@thiras

thiras commented Sep 24, 2026

Copy link
Copy Markdown
Contributor Author

Multi-agent review follow-up, 52c822b. It ran code, tests, silent failures, comments and type design over the whole branch.

Fixed

  • Regression: a pooled one-lane drive (a bundle pull whole-file entry) whose leg faulted in the closing voucher exchange, after its last byte, returned Ok and settled the lane at committed. A drive whose every lane faulted now fails and is not finalized. Regression test a_fault_after_the_last_byte_fails_a_pooled_one_lane_drive is mutation-checked.
  • Blame: only a floor trip (EntryStalled) blames every striped lane. A local fault of the drive (store query, flush, finalize) blames none.
  • Walker:
    • A local disk fault ends the walk, as a terminal fault does, instead of paying first legs on the reserve.
    • A session with no fault report is dropped.
    • An error that rules out a retry round is no longer overwritten by a later transient one (keep_walk_error).
  • Logging: each lane fault is logged with its provider, including in a drive that succeeds. Worker store errors fold through keep_decisive and are no longer dropped.
  • Guard: drive_range_lanes refuses more than one lane with takes_first.
  • Comment fixes: settle rationale, pinned reopen, the stripe-of-one order, the module doc, the ADR and CHANGELOG.

New tests: the regression above, a parked lane that wakes to fill a faulted lane's gap (under a timeout), settles_clean, the walker stopping on a terminal fault and on a local disk fault, and keep_walk_error.

Left as is

  • No unit test for the floor wiring in multi_source_download, or for a store query that fails during requeue. Both need infrastructure the unit tests do not have.
  • On the whole-blob path, SignedSizeMismatch is still not blamed on the peer. That is lenient, not unsafe.
  • takes_first stays a per-lane flag, guarded at runtime, and is not turned into an index.

Local runs: clippy, rustdoc and fmt pass. 1673 client/cli/common tests, 1265 node tests (no flakes this run) and 11 anvil e2e tests pass.

@thiras
thiras force-pushed the feat/stripe-range-set branch from 52c822b to c4919dd Compare September 24, 2026 09:09
thiras and others added 2 commits September 24, 2026 12:38
A range-dedup entry paid for its scattered complement over one
provider's link even when several holders were probed.

- client: `drive_range_lanes` fills a range set across several
  `RangeLane`s from one gap queue. A lane that faults retires and its
  gap's missing rest goes back to the queue. A terminal fault stops
  every lane. The first gap waits for the lane that holds the primed
  first leg. `RangeSetOutcome` reports each lane's fault and the drive's
  result. `drive_range_set` is the one-lane case.
- cli: `FetchPrelude` no longer owns a store. A range-dedup entry opens
  one ranged store that every session of every drive writes into.
  `drive_stripe` runs the entry's sessions under one drive-level floor
  and one top-up budget, then settles each lane at its armed cumulative
  unless its voucher was rejected.
- bundle pull: `stripe_order` puts the admitted full holders first (one
  per operator, at most --max-sources, with multi-source on).
  `SessionWalk` opens the stripe up front, drops a faulted lane, fails
  every lane over on a drive-level failure, and falls back to the
  reserve one candidate at a time. Only the last session a pass opens
  primes the first leg.

Refs #2123

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
- A drive whose every lane faulted fails, even when its bytes landed: a
  fault in the closing voucher exchange can leave a voucher armed. A
  pooled one-lane drive returned Ok there and settled the lane low. It is
  not finalized either.
- Only a floor trip blames every striped lane; a local fault of the drive
  blames none. Each lane fault is logged with its provider. Worker store
  errors fold through keep_decisive instead of being dropped.
- SessionWalk ends on a local disk fault as on a terminal one, treats a
  session with no fault report as faulted, and keeps an error that rules
  out a retry round over a later transient one.
- drive_range_lanes refuses more than one lane that takes the first gap.
- Doc fixes: settle rationale, pinned reopen, RangeTargets stripe of one,
  the module doc's CLI callers, the ADR and CHANGELOG stripe failover.

Refs #2123

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@thiras
thiras force-pushed the feat/stripe-range-set branch from c4919dd to 6d291fc Compare September 24, 2026 09:41
@thiras
thiras merged commit 763ba0d into main Sep 24, 2026
28 checks passed
@thiras
thiras deleted the feat/stripe-range-set branch September 24, 2026 09:56
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