Skip to content

fix(client,cli): log each lane fault where it happens and grow a busy lane for its remainder - #2231

Merged
thiras merged 3 commits into
mainfrom
fix/2230-leg-fault-log-and-lane-growth
Sep 29, 2026
Merged

thiras merged 3 commits into
mainfrom
fix/2230-leg-fault-log-and-lane-growth

Conversation

@thiras

@thiras thiras commented Sep 29, 2026

Copy link
Copy Markdown
Contributor

What

A lane that faulted mid-pull logged nothing, and its re-queued remainder waited until a busy surviving lane finished its own range. One provider loss became a silent serial tail: 6 min on 998030 in the 2026-09-29 Mistral run.

  • Fault logs in place. The multi-source scheduler and drive_range_lanes now warn where a lane faults, with provider, hash, range, bytes landed and error. This includes the serial and store-error paths. A remainder that no lane can grow for is logged at info.
  • Lane growth. When no idle worker can take a faulted lane's remainder, the live lanes that cover it are asked in lane order for one more stream each, until the remainder has a taker.
    • SourceLane gains widen: Option<&LaneWiden>, and StreamCandidate gains widen.
    • bundle pull grants the extra streams from the provider's free --max-lane-streams permits and never waits for one.
  • Extra-stream faults stay contained. A fault on an extra stream stops only that stream. It does not retire the lane, fail the drive, blame the node or drop the session, and it asks for no regrow.
    • The stripe drive reports it through RangeSetOutcome::lane_extra_fault, so the lane still settles at its armed settlement.
    • A lane's last live worker faults for the lane.
  • Grant release. A grant comes back when its worker stops, when a stop or terminal fault drops that worker, and when the fetch ends before the worker starts.
  • Proof-stall line. A leg phase (unpolled, pay or read) that runs past 5 s logs at debug, so the next 10 s proof gap names its phase.
  • ADR 039 now states the one-additional-stream exception: the concurrency invariants, reassignment, per_source_inflight and AC 5.

Refs #2230. Item 4 of the issue, the root cause of the 10 s proof gap, stays open. This PR adds the debug line that item needs.

Reviewer notes

  • Read first:
    • scheduler.rs: Growth::request, hand_off_faulted, record_lane_fault, WorkerHold, and the FuturesUnordered join that starts granted workers. Work is now indexed by worker slot, with lane_of and lane-level retired.
    • driver.rs: the drive_range_lanes fault branch. Whether a fault counts as an extra fault or the lane's is decided under the queue lock, where an idle worker leaves its lane.
  • Payment safety:
    • Same-lane streams share one ledger, which serializes voucher issuance (ADR 003 § Concurrent Streams).
    • The multi-source path always settles at settlement().
    • The stripe path settles non-clean on any fault, including an extra fault.
  • Unchanged on purpose: decdn fetch, the Streamer and the Downloader pass no widen, so they behave as before. Only bundle pull grows lanes.
  • Follow-up, not in this PR: restructure Work's parallel per-slot vectors into a Vec<Slot>.
  • One flake seen: during development, forced_steal_no_double_pay_on_multi_thread_runtime failed once, under load. It then passed 6 runs alone and 4 full-suite runs, 1268 tests each. I believe it is timing-sensitive and unrelated to this change, but I did not prove that.

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets -- -D warnings. I did not run --all-features: the anvil-e2e targets are not linted in CI.
  • cargo nextest run -p decdn-client -p decdn-cli: 1270 passed
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • cargo nextest run -p decdn-client --features public-api-test --test public_api, with the .snap regenerated
  • pre-commit run --all-files
  • Each new behaviour test was mutation-checked: it fails when the fix it covers is disabled.
  • User-visible change: CHANGELOG.md entry added (BREAKING, for the new decdn-client fields)
  • Design change: ADR 039 updated
  • PR title uses an allowed type with a lowercase subject
  • Live testnet run: a Mistral bundle pull with an earlier build of this branch took 9m47s, with 0 failed and the same byte counts as before.
    • The new fault WARN fired, for bcl on ad7f7e.
    • Growth did not fire in that run, probably because fra1 had no free permit, and the log could not show why. This PR adds the info line that now reports that case.
    • All three proof stalls were read phase, with nothing or under one chunk unproved.
    • The review-driven fixes came after that run, so this final build has not had a live run.

🤖 Generated with Claude Code

… lane for its remainder

A lane that faulted mid-pull logged nothing, and its re-queued remainder
waited until a busy surviving lane finished its own range, so one provider
loss became a silent serial tail (#2230).

- Log each lane fault in place (provider, hash, range, bytes landed, error)
  in the multi-source scheduler and in drive_range_lanes, including the
  serial and store-error paths. A remainder no lane can grow for logs at
  info.
- When no idle worker can take a faulted lane's remainder, ask the live
  lanes that cover it, in lane order, for one more stream each until it has
  a taker. SourceLane gains `widen: Option<&LaneWiden>` and StreamCandidate
  `widen`; bundle pull grants the streams from the provider's free
  --max-lane-streams permits and never waits.
- A fault on such an additional stream stops only that stream: it does not
  retire the lane, fail the drive, blame the node or drop the session, and
  asks for no regrow. The stripe drive keeps it apart
  (RangeSetOutcome::lane_extra_fault) so the lane still settles at its
  armed settlement. A lane's last live worker faults for the lane.
- Grants are released when their worker stops, when a stop or terminal
  fault drops it, and when the fetch ends before it starts.
- A leg phase (unpolled, pay, read) that runs past 5 s logs at debug, to
  name the next 10 s proof gap.
- ADR 039 states the one-additional-stream exception.

Refs #2230

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 04:13
@thiras thiras self-assigned this Sep 29, 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

Lane retirement and coverage-agnostic growth contain concurrency paths that can bypass intended reassignment.

Review effort: Balanced
Findings: 2 Medium severity

Open (2)
What changed in this PR

Adds lane-fault diagnostics and dynamically widens busy lanes to process faulted remainders.

Changes:

  • Logs lane faults and proof-stall phases.
  • Adds bounded extra-stream growth for bundle pull.
  • Updates settlement behavior, tests, public API, changelog, and ADR 039.
File Description
CHANGELOG.md Documents breaking client API changes.
adr/​039-multi-source-parallel-fetch.md Specifies the lane-growth exception.
crates/​cli/​src/​commands/​bundle_pull.rs Grants bounded extra stream permits.
crates/​cli/​src/​commands/​fetch.rs Wires widening and extra-fault settlement.
crates/​client/​examples/​common/​mod.rs Updates example construction.
crates/​client/​src/​downloader.rs Updates test candidates.
crates/​client/​src/​driver.rs Adds fault logging and range-lane growth.
crates/​client/​src/​endpoint.rs Updates receive-window documentation.
crates/​client/​src/​lib.rs Adds proof-stall diagnostics and exports.
crates/​client/​src/​scheduler.rs Adds multi-source lane widening and tests.
crates/​client/​src/​source.rs Extends fault-injection test support.
crates/​client/​src/​streamer.rs Propagates widening hooks into lanes.
crates/​client/​tests/​snapshots/​public_api__public_api.snap Records public API additions.

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

Comment thread crates/client/src/driver.rs Resolved
Comment thread crates/client/src/scheduler.rs Resolved
@github-code-quality

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

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit c75a10e in the fix/2230-leg-fault-l... branch remains at 86%, unchanged from commit cff5fb1 in the main branch.

Show a line coverage summary of the most impacted files.
File main cff5fb1 fix/2230-leg-fault-l... c75a10e +/-
crates/node/src/dht/publish.rs 92% 92% 0%
crates/cli/src/.../bundle_pull.rs 77% 77% 0%
crates/cli/src/...mmands/fetch.rs 54% 54% 0%
crates/client/src/source.rs 93% 93% 0%
crates/client/src/lib.rs 92% 92% 0%
crates/protocol/src/framing.rs 97% 97% 0%
crates/client/src/driver.rs 97% 97% 0%
crates/client/s...c/downloader.rs 97% 97% 0%
crates/client/src/scheduler.rs 95% 96% +1%
crates/client/src/streamer.rs 91% 92% +1%

Updated September 29, 2026 05:25 UTC

…tch growth to ranges by coverage

- drive_range_lanes: a lane's own fault retires it under the queue lock,
  before its gap's rest goes back, and a worker re-checks retirement under
  that lock before it takes a gap. A sibling worker of the faulted lane can
  no longer take the rest and reopen the provider that just faulted.
- Scheduler growth: match each pending range to an idle worker that covers
  it, one worker per range, and ask only lanes that cover a still-unserved
  range for it. An idle worker that covers a different range no longer
  hides the faulted remainder, and a grant no longer goes to a lane that
  cannot serve it.

Refs #2230

Co-Authored-By: Claude Opus 5.5 <[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

🟡 Changes recommended

Reserved first units can suppress required growth, and configurable sampling can miss the promised pre-timeout diagnostic.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
Resolved since last review (2)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Decouple 5-second read diagnostics from configurable sampler timing

crates/​client/​src/​lib.rs:3250

The 5-second read diagnostic is only checked on the throughput sampler, whose period is window / 8. Since PullDeadlines::new accepts any nonzero window and the CLI exposes it through --stall-timeout-ms, a window above 40 seconds logs later than 5 seconds, and above 80 seconds the node's 10-second proof timeout can fire before this branch runs at all. Race the read against an independent 5-second timer rather than piggybacking on the configurable floor sampler.

Comment thread crates/client/src/scheduler.rs Resolved
…read stall line on its own

- Scheduler growth: a slot with a reserved first unit takes that unit next,
  so it no longer counts as the idle taker of a faulted lane's remainder.
- The `read` proof-stall debug line runs on its own 5 s timer instead of
  the throughput-floor sampler, whose period follows the configurable
  stall window and can fall after the node's 10 s proof timeout.

Refs #2230

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras

thiras commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

On the "previously missed" item (lib.rs:3250, the read stall line tied to the sampler): fixed in c75a10e. The line now runs on its own sleep_until(read_started + 5 s) arm in the read select!, so it no longer depends on the window / 8 sampler period.

@thiras
thiras merged commit 74e2cd4 into main Sep 29, 2026
30 checks passed
@thiras
thiras deleted the fix/2230-leg-fault-log-and-lane-growth branch September 29, 2026 05:30
alpergundogdu added a commit that referenced this pull request Sep 29, 2026
A lane that faulted mid-range re-queued its remainder, which then waited
for a busy lane to finish its whole range: one lost node became a serial
tail.

- `LaneWiden` (new) pairs a non-waiting `grow` hook with a `release` hook,
  on `StreamCandidate::widen`. When a lane faults and a pending range has no
  idle taker, `acquire` asks the busy lanes that cover it, in lane order, for
  one extra stream. A lane runs at most one extra worker. It shares the
  lane's `(ctx, ledger)`, takes one piece, never steals, and gives its grant
  back when it stops, however it stops.
- A fault on an extra stream stops only that stream: it neither cools the
  node nor asks for more growth. A fatal fault still ends the acquire.
- `SourceSet::record_fault` logs each lane fault at info with the provider,
  the blob, the lane's range (`LaneRange`), the bytes landed and the error.
  A remainder no lane can take logs at info.
- Bundle pull grants extra streams from the provider's free
  `--max-lane-streams` permits and never waits.
- ADR 039 states the one-additional-stream exception.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alpergundogdu added a commit that referenced this pull request Sep 29, 2026
…r, and fix stale docs

- `AcquireEnv::max_blob_bytes` (with `Downloader::max_blob_bytes` and
  `Streamer::max_blob_bytes`; the CLI passes `--max-blob-mb`) clamps a size
  claim to the cap before the store or any coverage bitmap is sized, and
  growth never raises the bound past it. A bound at the cap with no size
  proven ends the item with `BlobTooLarge`.
- An extra stream whose lane's own worker has stopped is the lane's last
  live worker: its fault is recorded and cools the node (#2231).
- `ClientRangedStore::set_bound` does nothing once a size is proven.
- A pinned `--node-id` builds its targets in `pinned_targets`; tests pin
  that it and the peer-store fast path carry no size hint.
- Docs: `build_completed_updates` gets its doc back; the scheduler, the
  open-lock and the first-claim docs, and ADR 039, state the current rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alpergundogdu added a commit that referenced this pull request Sep 29, 2026
Rewrite the comments of this range in present tense without em-dashes or
the plan label: a size is a first claim, a hint, never a store key. Name
the first claim in first_open, the bundle range driver, the bundles
appendix and ADR 037. Add the missing CHANGELOG items: one connection per
node per command, the extra lane stream (#2231), the 1..=64 bound of
--max-lane-streams, the finalize retry and the decdn-client SDK breaks.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
alpergundogdu added a commit that referenced this pull request Sep 29, 2026
The two #2231 outage tests order B's own-leg fault and its extra
stream's fault on explicit gates instead of timing. ScriptedSource
gains holding_fault(nth, gate): a refusal waits inside open, and a
parked mid-range fault waits after the reader's last byte, until the
gate opens. The own leg's fault is released once the extra stream has
opened, and the extra's fault once the own worker's fault is recorded.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
thiras pushed a commit that referenced this pull request Sep 30, 2026
…as a hint (#2239)

* feat(client): classify fetch faults for the acquire loop

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

* feat(client): track command-wide peer health with cooling backoff

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

* feat(client): stop a fetch on idle time, not attempt count

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

* feat(client): add a retry-safe SourceSet behind a SourceProvider seam

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

* fix(client): make SourceSet's unanimous stops back off and cover mixed verdicts

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

* test(client): script a source that faults once and recovers

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

* refactor(client): make the multi-source scheduler an acquire loop over a SourceSet

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

* fix(client): stop a priced-out acquire and tighten its lane tests

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

* refactor(client,node,cli,common): run the faces and decdn fetch on acquire

Move the Downloader and Streamer faces onto acquire over a SourceSet, add
first_open (a signed header-only open with acquire's recovery), and add the
CLI's SourceProvider (CliSources). decdn fetch (file and stdout) learns the
blob's signed size through first_open, then runs one acquire under a
StopPolicy: a terminal waits, a script gives up after 10 minutes, and
--give-up-after-secs overrides both. A give-up exits 75.

Delete multi_source_fetch, multi_source_fetch_until, SourceLane,
MultiSourceConfig, download_first_unit, PullConfig::download_unit_deadline,
the fetch_over failover loop and rediscovery pass, the multi-source gate,
CLI lane priming, and the --stall-timeout-ms, --unit-deadline-ms,
--min-throughput-bps, --multi-source-min-bytes and --[no-]multi-source flags.
The node's ranged assembly and the driver classify faults with classify.

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

* fix(cli,client,node): keep typed errors on stdout and never wait for a lane permit

- StreamDrive keeps the fetch's typed error (take_error), and decdn fetch -o -
  surfaces it in place of the reader's message, so a give-up exits 75 and the
  remedy hints attach.
- The stop clock holds while a stream waits on its consumer (ClockHold), so a
  paused downstream is not a stall.
- A CLI lane takes its provider's stream permit without waiting, the first
  open's lanes included; a taken cap fails the build and the source set backs
  it off.
- The node's ranged assembly reassigns an open-time InsufficientDeposit; only
  a fatal fault or PoolExhausted ends it.
- Drop ResolvedTargets::skipped_registry_read, Probed::total_bytes and the
  Downloader's unused PullConfig parameter; fix stale docs.

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

* fix(cli,client): bound the consumer clock hold and park only the answering lane

- A lane parked on the consumer holds the stop clock only while verified
  bytes sit unread ahead of the cursor. Once the consumer has read everything
  present, the clock runs, so a gap whose only holder is dead ends in GaveUp.
- The first open parks only the lane that answered; every other lane drops
  with its lease, freeing its provider's stream permit for sibling entries.
- Fix a stale Probed::coverage doc and an em-dash in the delegated remedy.

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

* test(e2e): a sole holder that restarts mid-fetch still finishes it (#1174)

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

* docs(adr): describe fetch recovery as one acquire loop

ADR 037 and ADR 039 described fetch recovery as sequential
single-source failover, a multi-source engagement gate with a size
floor, and separate stall/throughput-floor deadlines. Rewrite those
passages to describe the single acquire loop: per-holder cooling
(2 s doubling to 60 s, reset on a verified byte), a fixed 10 s lane
watchdog, 5 s-5 min rediscovery backoff, and a whole-fetch stop
policy (no limit on a terminal, 10 min for a script,
--give-up-after-secs override). Multi-source always runs; a single
holder is a lane set of size one, not a separate code path.

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

* docs(adr): state the acquire loop's stop conditions exactly

The fetch-recovery rewrite in adr/039-multi-source-parallel-fetch.md
named "a shared-pool exhaustion" as a stop condition, which is not
one, and omitted the size-cap, disk-fault, and no-affordable-holder
cases. State the five faults that end a fetch, and the separate
no-holder-has-the-blob condition, exactly. Reword the two Negative
consequences bullets that still assumed a single-source path exists.
Split the semicolon-joined sentences added in the previous commit,
and remove the two remaining em-dashes on lines that commit touched.

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

* docs(adr): define the item scope of a fetch stop

"item" appeared in the fault-list passage with no definition. Define
it before its first use: one blob the command fetches, an entry in a
bundle pull, or the whole fetch for decdn fetch.

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

* refactor(cli): run bundle pull entries and the manifest through acquire

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

* chore(cli): drop the retry-round bar fold and a stale e2e comment

The bundle pull total bar no longer folds a file's landed prefix across
retry rounds: every fetch of an entry reports into one bar. The e2e
multi-source comment names the acquire loop.

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

* refactor(cli,client): fetch range-dedup entries through acquire and delete the range-lane engine

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

* fix(cli,client): admit one node per operator and drop dead warm-connection code

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

* fix(client): count NotFound as absent only for non-holders after repeats

On the wire NotFound also means load shed, a per-signer cap, or a pool
the node cannot confirm yet. A probed holder (or a pinned --node-id)
that answers NotFound now only cools; a pull-through target is marked
absent after three NotFound answers with no verified byte between them.
The NoSourceHasBlob stop carries the last absent refusal as its source,
so the CLI's cache-miss hints still attach.

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

* fix(cli,client): resolve holders under the acquire recovery

A sole holder that was down when decdn fetch or a bundle entry started
made the command exit 1 at once, because the initial holder resolution
sat outside the recovery loop. A resolution that fails for any reason but
the configuration (missing capacity_bond, a malformed --node-id, probe
signatures that do not recover) now starts with no holder, and the loop
discovers with backoff under the stop policy.

first_open runs discovery beside its attempt in one select!, so a slow
discovery never holds back a source whose cooldown ended, and an empty
holder set discovers until one appears. signed_size hands the holders its
discovery found on to the fetch. A Downloader accepts an empty holder
set; StaticSources refuses one instead.

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

* fix(client): drain lane builds before acquire returns

acquire dropped lane builds still in flight when it returned. A build can
be in the middle of the CLI's low-water topUp, which escrows funds the
buyer store never records. On every exit the loop now stops its lanes and
awaits each build still in flight, for at most 30 s; a lane built there
never starts and drops at once.

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

* fix(client): read sibling top-ups, grace the first byte, print give-ups exactly

- The acquire loop reads the pool deposit as the larger of its own watch
  and every started lane's context, so a top-up a sibling bundle entry
  credits to the shared lanes reaches it.
- A leg's first byte gets a 30 s grace before the 10 s lane watchdog
  applies, so a cold miss whose first byte waits on the node's upstream
  is not a stall.
- GaveUp prints whole minutes only for an exact minute; 90 s prints as
  "90s", not "1m".

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

* fix(cli,client): cap lanes by --max-sources and refresh rediscovered nodes

- Downloader::new takes the lane cap explicitly. The CLI passes
  --max-sources and keeps every other holder as a reserve, so a holder
  discovery adds later can take a free lane; the cap no longer shrinks to
  the starting holder count.
- holders_from replaces an operator's stored node on rediscovery, so the
  next lane build dials the node the latest probe ranked. A lane already
  built keeps its node.

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

* fix(cli): re-key a fetch away from a wrong-size signer

decdn fetch keyed its store once, from the nearest holder's header. A
holder that signs a wrong size then wedged the fetch: its own bytes never
verify, and every other holder is excluded as wrong-size.

The download now names the provider that signed its size. When every
other known holder signs a different size and the signer delivered no
verified byte, the SourceSet ends the target with NoSourceAgreesOnSize.
decdn fetch then excludes that signer, persists what the lanes paid,
discards the wrong-size .partial, and runs the first open again from the
next holder, at most once per distinct signer. Bundle entries keep their
manifest size.

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

* refactor(client): drop the dead first-unit priming

No caller primes a lane's first unit any more, so the reservation path is
unreachable. Delete StreamCandidate::first_unit, stream_first_unit, the
scheduler's reserve_first_units / honours_first_unit and Work::first, and
their tests. PrimedSource stays: the node's pull leg primes through it.

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

* docs: point comments at ADR 039 and fix stale text

- Replace every "spec §" reference in code comments and rustdoc with an
  ADR 039 section, or drop it where no ADR section applies. The working
  spec is not in the repo.
- ADR 039: a fetch with no usable source waits for one and stops only on
  a fault the user must fix, a unanimous verdict, or the stop policy
  (acceptance criterion 3 and the failure-handling text); lanes join as
  sources become usable instead of all up front; the client cools a
  faulted source and never drops it; drop the segment-size rule the code
  does not have.
- ADR 037: the failure stamp feeds the next run's fast path; in-run
  cooling is the in-memory PeerHealth.
- Fix the stale ScriptedSource::stall_after doc and the bundle multi-source
  e2e header.

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

* feat(node,client): serve a range up to the blob's end instead of refusing it

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

* fix(cache,node): clamp a requested range on the cache-miss tiers too

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

* test(node): pin the clamped relay outcome and the uncovered-range refusal

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

* refactor(client): key the ranged store by offset and verify each leg under its own claim

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

* fix(client): verify an existing final file and heal a truncated partial

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

* test(client): pin the final-file and truncation heals and keep the hash off the runtime

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

* refactor(client,cli,node): drop size consensus

A size claim is a hint the acquire loop corrects, so nothing votes on it.

- Delete `SignedSizeMismatch`, `Fault::WrongSize` and `NoSourceAgreesOnSize`.
- `SourceSet` loses its wrong-size set, `mark_wrong_size`, `size_signer`,
  `set_size_signer` and the outvoted-signer verdict. The absent logic stays.
- `DownloadTarget` loses `size_signer`; `decdn fetch` loses the rekey path
  (`download_rekeying`, `discard_partial`) and `ClientRangedStore::discard`.
- `acquire` no longer requires the target size to equal the store's bound,
  so a resumed record whose bound differs from the hint is accepted.
- The node's pull leg drops its `WrongSize` arm.

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

* refactor(client,cli): grow a hinted size from discovered bytes

A size claim is the planner's first bound, and `acquire` corrects it.

- Grow: when every byte below the bound is present and no leg proved the
  size, the bound grows to `grown_bound`: max(bound + SEED, C0 + 2 * extra),
  rounded up to SEED (one discovery block). The new region is replanned.
- Shrink: a leg that verifies the final chunk of its sender's claim moves
  the store's bound there; the loop clips pending and in-flight work to it
  and cancels a lane whose unit starts past it. `fill_gap` reads the bound
  on each pass and ends its gap there.
- A whole-blob target completes once a size is proven and every byte below
  it is present. The streamer ends at the proven size and tees
  `[0, proven)` to the cache. The fetch bar follows the bound, and the
  summary prints the finished file's size.
- Coverage is a preference (#2225): a pending piece no running lane covers
  goes to any lane, which serves it by pull-through.
- Store errors are ours (#2213): a store read error in the watchdog or the
  gap loop is a `LocalPullFault`, so it ends the acquire as a command fatal
  and never cools the node.
- Bundle pull prints `<path>: manifest says X bytes, the blob is Y bytes`
  for an entry whose blob differs from its manifest, without failing it,
  and accepts the landed file by its record's hash on the next run.
- `forced_steal_does_not_double_fetch_the_stolen_tail` gates the slow
  source until the fast one has stolen, so it no longer depends on timing.

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

* refactor(client,cli): take the first size claim from the probe hint (#2218)

- `discovery::Probed` carries `total_bytes`, the probe's unsigned size hint.
- `ResolvedTargets::size_hint` is the nearest probed holder's hint;
  `CliSources::holders_from` keeps it.
- `CliSources::first_claim` (was `signed_size`) returns the hint with no
  whole-blob open. Only a set with no hint (a pinned `--node-id`, the
  peer-store fast path) opens one pull for the header's size.
- A bundle entry keeps its manifest size as the first claim.

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

* fix(client,cli): grow a busy lane for a faulted lane's remainder (#2231)

A lane that faulted mid-range re-queued its remainder, which then waited
for a busy lane to finish its whole range: one lost node became a serial
tail.

- `LaneWiden` (new) pairs a non-waiting `grow` hook with a `release` hook,
  on `StreamCandidate::widen`. When a lane faults and a pending range has no
  idle taker, `acquire` asks the busy lanes that cover it, in lane order, for
  one extra stream. A lane runs at most one extra worker. It shares the
  lane's `(ctx, ledger)`, takes one piece, never steals, and gives its grant
  back when it stops, however it stops.
- A fault on an extra stream stops only that stream: it neither cools the
  node nor asks for more growth. A fatal fault still ends the acquire.
- `SourceSet::record_fault` logs each lane fault at info with the provider,
  the blob, the lane's range (`LaneRange`), the bytes landed and the error.
  A remainder no lane can take logs at info.
- Bundle pull grants extra streams from the provider's free
  `--max-lane-streams` permits and never waits.
- ADR 039 states the one-additional-stream exception.

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

* fix(cli): serialize a solo fetch's pool open across its lanes

With the first claim taken from the probe hint, `decdn fetch` builds every
lane at once, and each lane opens or reuses the one pool on-chain. Without a
lock those builds raced, and in `cli_fetch_multi_source` one lane's build
lost every time, so the small blob finished on the other lane alone. The
fetch now holds an open lock, as a bundle pull does, so the open-or-reuse
runs one lane at a time.

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

* docs(adr): state the size hint and coverage preference in ADR 039

- The size of a blob is a hint: the first claim comes from the probe, a
  header or a manifest, and the client grows or shrinks it as legs verify.
  A size disagreement never ends the fetch; the rekey text is gone.
- Coverage is a preference: when no running lane covers a pending block,
  any running lane takes it.

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

* fix(client,cli): cap the first size claim, charge a lane's last worker, and fix stale docs

- `AcquireEnv::max_blob_bytes` (with `Downloader::max_blob_bytes` and
  `Streamer::max_blob_bytes`; the CLI passes `--max-blob-mb`) clamps a size
  claim to the cap before the store or any coverage bitmap is sized, and
  growth never raises the bound past it. A bound at the cap with no size
  proven ends the item with `BlobTooLarge`.
- An extra stream whose lane's own worker has stopped is the lane's last
  live worker: its fault is recorded and cools the node (#2231).
- `ClientRangedStore::set_bound` does nothing once a size is proven.
- A pinned `--node-id` builds its targets in `pinned_targets`; tests pin
  that it and the peer-store fast path carry no size hint.
- Docs: `build_completed_updates` gets its doc back; the scheduler, the
  open-lock and the first-claim docs, and ADR 039, state the current rules.

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

* fix(client): charge a node once per outage and enforce the cap on a proven size

- `acquire` keeps the providers charged a fault since their last verified
  byte. An extra stream's fault after its lane's own worker stopped cools
  the node only when the node is not already charged for this outage.
- A proven size past `max_blob_bytes` ends the item with `BlobTooLarge`: a
  cap off the chunk-group grid lets a leg that ends at it prove a size up to
  one group past it.
- Tests: one charge per outage, a blob exactly at the cap, and a proven size
  past an unaligned cap. `ScriptedSource::delaying_open` holds one open.
- Rewrap a long `fetch_over` doc line; ADR 039 drops "signed" from the
  size-disagreement sentence and states the once-per-outage charge.

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

* docs(adr): a blob's size is a hint that a verified final chunk proves

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

* feat(client,cli): reuse one connection per node for the whole command

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

* fix(client,cli): unpin a faulted connection by instance and bound the lane stream cap

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

* fix(client): finish a resumed store whose bound exceeds the first claim

A whole-blob target cut from the first claim C0 was not a tail when a
resumed record's bound or proven size was past C0, so acquire returned
with [0, C0) present and finalize failed Incomplete on every rerun.
Want::new now takes C0: a range that reaches min(C0, bound) is a tail and
runs to the bound.

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

* fix(client): treat a peer's size claim as a source fault everywhere

A node that signed a size of zero for a bounded open failed the wire
bound's alignment, and the error carried LocalPullFault, so one node
ended the whole command. The open now refuses any range that asks for
bytes at or past the signed size with ResumeOffsetPastEnd, and
aligned_wire_len no longer marks its errors local: every input to it is
the peer's signed size or our own cap.

A leg that proves a smaller size between a caller's bound read and its
missing-ranges query no longer turns into a fatal RangeOutOfBounds: the
query re-reads the bound and clips to it (missing_below_bound). The
ClientRangedStore contract stays strict, as the shared conformance suite
requires.

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

* fix(client): keep overshoot refusals from marking a node absent

A bound that overshoots the blob sends pieces past its true end, and an
honest pull-through node refuses them with NotFound. Those refusals
counted toward ABSENT_AFTER_NOT_FOUND, so honest nodes could be marked
absent and the item could end with a wrong "check the hash". A lane
fault now carries LaneRange::past_end: the faulted piece starts at or past
the proven size, or with none proven at or past min(first claim, bound).
Such a NotFound still cools the node and never counts toward absent.

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

* fix(client): retry once after a finalize hash mismatch and flush on every error exit

A finalize whose whole-file hash does not match clears every claim and
keeps the file. The Downloader now runs acquire and finalize once more,
so bytes that drifted on disk after they verified are fetched again in
the same command; a second mismatch ends the target. Every bundle drive
and fetch finalizes through the Downloader, so they all get the retry.

Acquire flushes the present record once after its loop on any error, so
the ? exits (clip, regrow, missing_chunks, all_present) keep the bytes
that landed recorded for a resume.

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

* fix(cli): give the parked header lane its widen hook

build() returned the lane the first open parked before it set the
stream-cap widen hook. The hook is now set on every lane build() returns
that does not carry one, the parked lane included, so a faulted lane's
remainder can take an extra stream on it.

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

* fix(client): clamp a ranged-store query's end to the bound

ClientRangedStore::missing_ranges and read align with
align_range_clamped, as the node's store does: an end past the bound
clamps to it, so a bound that shrinks under a caller that read it first
does not fail the query. A start at or past the bound stays an alignment
error, as the shared conformance suite requires.

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

* docs: canonicalize the size-by-growth comments, ADRs and CHANGELOG

Rewrite the comments of this range in present tense without em-dashes or
the plan label: a size is a first claim, a hint, never a store key. Name
the first claim in first_open, the bundle range driver, the bundles
appendix and ADR 037. Add the missing CHANGELOG items: one connection per
node per command, the extra lane stream (#2231), the 1..=64 bound of
--max-lane-streams, the finalize retry and the decdn-client SDK breaks.

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

* docs: drop the last em-dashes and size-key wording

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

* test(client): make the outage-charge tests deterministic

The two #2231 outage tests order B's own-leg fault and its extra
stream's fault on explicit gates instead of timing. ScriptedSource
gains holding_fault(nth, gate): a refusal waits inside open, and a
parked mid-range fault waits after the reader's last byte, until the
gate opens. The own leg's fault is released once the extra stream has
opened, and the extra's fault once the own worker's fault is recorded.

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

* fix(client): steal half of a lane's missing remainder, not of its picked range

`steal_split` split a lane's picked range at its midpoint. Once the victim
had delivered past that midpoint, the stolen half held the victim's whole
missing remainder: the trimmed victim re-queued nothing, stole back half of
the thief's range, and the two lanes cancelled each other's legs before any
voucher, halving each round.

The argmax and the split now count each in-flight range's missing bytes,
read from a store snapshot taken before the pick. The thief takes the
aligned second half of the victim's missing remainder, the victim is
trimmed to end at that split, and a split that would leave the victim no
missing byte declines the steal. A steal and a cancelled leg's requeue log
at debug.

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

---------

Co-authored-by: Claude Opus 5.5 <[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.

2 participants