Skip to content

feat: range-keyed partial-holder discovery — consumers (#1506 PR2) - #1898

Merged
alpergundogdu merged 18 commits into
mainfrom
claude/1506-pr2-consumers
Sep 2, 2026
Merged

alpergundogdu merged 18 commits into
mainfrom
claude/1506-pr2-consumers

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Closes #1506

Second of two implementation PRs for #1506 (PR1 = the data layer, merged in #1894). This PR makes the two fetch consumers coverage-aware, so disjoint ranges source from covering holders. Built task-by-task with a review gate after each and a final whole-branch review (READY-WITH-NITS).

Two channels, by design (they need opposite things)

  • Node ranged-drive loop (node_origin/ranged_pull.rs + PeerRunSink): on a cache miss, the node assembles a blob across partial holders — one sequential voucher lane per covered range, sharing a continuous demand window (served_paid/RampPacer), with repair-by-replan. It never touches the scheduler: the node serves in-order within a small credit window, so parallel fan-out buys nothing there. Uses the concentrate + sticky planner (minimize node flips / mid-stream serve pauses).
  • Client scheduler (multi_source_fetch): admits partial holders and assigns each 64 MiB block only to a covering source, spreading for parallelism, with coverage-filtered tail-steal. Uses the spread planner.

Both consume the same Coverage (PR1) via a shared planner (client-pull/coverage_plan.rs).

Commits

  • 6853137b — fix(cache): derive coverage size from the observe() bitfield, not status() — so abandoned-prefix partials (no tail chunk) advertise. Read-only; no persistence needed (spike-confirmed bitfield.size() is the full size).
  • 5e0b98a9 (+a8239782) — coverage planner: covering_sources + plan_covered_runs (node) + spread_segments (client).
  • 94dbec3e — node pull candidates carry probe-confirmed coverage.
  • 54afacd1 (+da59d859) — node ranged-drive loop; shared-pool exhaustion treated as terminal.
  • 13f99ef0 — client admits partial holders (Probed.coverage).
  • 8379b06f — client scheduler coverage-aware (seed by spread_segments, coverage-filtered steal, Work::retire anti-hang).
  • 0dcd5418 — thread real per-holder coverage into SourceLane.coverage (closes an inert-client-channel gap the review caught: coverage was measured but dropped before the scheduler).

Correctness (final-review verified)

  • Both channels functional end-to-end — real partial coverage reaches assignment on the node and client paths.
  • Payment safe — node runs are strictly sequential (one (signer,provider) lane at a time, one shared pool); client keeps per_source_inflight=1 + one-node-per-operator; the planner assigns each block to exactly one source (no overlapping lanes, no double-pay).
  • Coverage untrusted-bits contract honored — both consumers bound queries to num_blocks(total_bytes), so a lying holder's trailing bits can't inject phantom coverage.
  • No full-holder regression — a single whole-holder collapses to one run (node) / the eager fan-out is preserved via split_evenly (client).
  • No contract change; wire is unchanged (PR2 is pure consumer orchestration over PR1's data).

Follow-ups / deferred nits (none block merge)

Per-task and whole-branch reviews clean; clippy --workspace --all-targets -D warnings 0; all task suites green (node suite, 240/240 client-pull, 683 client-pull+cli, anvil-e2e compile gate).

🤖 Generated with Claude Code

alpergundogdu and others added 9 commits September 1, 2026 13:57
…uler lanes (#1506)

failover_order now keeps a node_id -> Coverage map built from the probed
holders (B1) before it collapses Vec<Probed> into Vec<NodeCandidate>, and
ResolvedTargets/try_multi_source_fetch(_from_admitted) carry it through to
the SourceLane builder. Each lane looks up its real measured coverage by
node_id (lane_coverage helper), falling back to Coverage::full only for a
proxy-warming source or the pinned --node-id path (both mean "will serve
any range"). bundle_pull reuses the same ResolvedTargets it already built
via probe_and_order, so it gets real coverage for free.

Previously every lane was handed Coverage::full regardless of what the
probe measured, so the coverage-aware scheduler (B2) never actually saw a
partial holder on a real fetch.
Copilot AI lite review requested due to automatic review settings September 1, 2026 15:50

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.

Pull request overview

Implements range/coverage-aware consumption of #1506’s discovery Coverage bitmap across both fetch “consumers”: the node’s sequential ranged-drive cache-miss assembly path and the client’s multi-source scheduler, so disjoint discovery-block ranges are sourced from covering partial holders.

Changes:

  • Add a shared, pure coverage planner (client-pull/coverage_plan.rs) with a “concentrate + sticky” node planner and a “spread” client planner.
  • Teach the node miss-pull leg to handshake for total_bytes, then assemble missing ranges across partial holders via sequential per-run payment lanes.
  • Make the client scheduler coverage-aware: seed work from coverage-based block assignment, constrain tail-steal to coverable ranges, and thread measured per-holder coverage through CLI lane building.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/node/tests/node_origin_pull.rs Updates test fixtures to provide full-blob Coverage for cache-hit candidates.
crates/node/src/selection.rs Extends Candidate with probe-fresh Coverage and adds a regression test that ranking carries it through.
crates/node/src/node_origin/ranged_pull.rs Adds the pure ranged assembly loop over RunSink, with unit tests for planning/repair/sequencing.
crates/node/src/node_origin/pull_leg.rs Reworks pull leg to handshake total_bytes then assemble via ranged-drive runs with per-run payment lanes.
crates/node/src/node_origin/mod.rs Threads probe-confirmed coverage into candidates and probe cache entries.
crates/node/src/dht/probe_cache.rs Stores unsigned Coverage alongside the cached probe triple for range planning on cache hits.
crates/client-pull/src/segment.rs Refactors segmentation helpers (split_evenly) and adds coverage-filtered steal_split.
crates/client-pull/src/scheduler.rs Makes multi-source scheduling coverage-aware (spread seed + coverage-filtered steal + retire cleanup).
crates/client-pull/src/lib.rs Exposes the new coverage planner and re-exports its key types/functions.
crates/client-pull/src/discovery.rs Adds Probed.coverage and tests that partial holders are admitted and preserve their measured coverage.
crates/client-pull/src/coverage_plan.rs New shared coverage planner implementing node “concentrate” and client “spread” assignment.
crates/cli/src/commands/fetch.rs Threads measured per-holder coverage into scheduler lanes via a coverage_by_node map.
crates/cli/src/commands/bundle_pull.rs Passes coverage map into the multi-source fetch path for bundle pulls.
crates/cache/src/engine.rs Derives coverage size from observe() bitfield (not status()), enabling front-prefix partials to advertise coverage.

💡 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/scheduler.rs Resolved
Comment thread crates/cache/src/engine.rs Resolved
@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.87% (was 80.30%, ▲ +2.57%) — 72713/87740 lines

File Coverage Lines Δ
crates/cache/src/engine.rs 93.04% 4814/5174 ▲ +1.54%
crates/cli/src/commands/bundle_pull.rs 52.07% 553/1062 ▲ +2.91%
crates/cli/src/commands/fetch.rs 33.88% 560/1653 ▼ 6.10%
crates/client-pull/src/coverage_plan.rs 98.52% 467/474 new
crates/client-pull/src/discovery.rs 96.49% 825/855 ▲ +0.12%
crates/client-pull/src/driver.rs 90.98% 878/965 new
crates/client-pull/src/lib.rs 89.66% 1743/1944 ▼ 0.11%
crates/client-pull/src/scheduler.rs 93.42% 1675/1793 new
crates/client-pull/src/segment.rs 94.18% 178/189 new
crates/node/src/buyer_ledgers.rs 100.00% 109/109 ● 0.00%
crates/node/src/dht/probe_cache.rs 96.30% 156/162 ▲ +0.07%
crates/node/src/handlers/client/fill.rs 68.70% 90/131 ▲ +12.36%
crates/node/src/node_origin/mod.rs 92.91% 1009/1086 new
crates/node/src/node_origin/pull_leg.rs 83.81% 678/809 new
crates/node/src/node_origin/ranged_pull.rs 99.20% 249/251 new
crates/node/src/selection.rs 97.24% 422/434 ▼ 0.05%
crates/protocol/src/coverage.rs 100.00% 109/109 new
History
Commit Total Δ vs base
0dcd541 82.77% ▲ +0.13%
7703c39 82.77% ▲ +0.13%
d0fea18 (HEAD) 82.87% ▲ +2.57%

…overage doc (#1506)

Address PR #1898 review:
- multi_source_fetch now caps lanes to max_sources at entry (no-op on the
  normal path since admit_sources already caps, but keeps the config knob
  authoritative if a caller passes an un-capped lane set).
- CacheEngine::coverage doc no longer says it reads status() for the size;
  it derives the size from the observe() bitfield via present_ranges, so a
  front-prefix partial reports its covered blocks.

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

yigitdot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Review: coverage-aware consumers (#1506 PR2)

Read-only review of the full branch against main — three specialized agents (client scheduler, node pull-leg, test coverage) plus a direct pass over the planner, cache, probe handler, and node call sites. Every finding below was re-verified against source rather than taken from the PR description.

Verdict: needs changes before merge. The design is sound and the planner unit tests are genuinely good — the problems cluster in the wiring, which is the part with no tests.

Critical

C1 — the node ranged loop declines SharedPool, so every run after the first believes the whole pool is unspent.

pull_leg.rs:757 calls drive(...), which hardcodes pool = None (client-pull/src/driver.rs:409). The solvency gate is then ctx.deposit - committed.amount (driver.rs:529, spent = identity at driver.rs:484), and both halves are wrong here:

  • ctx.deposit is the gross pool deposit — pin_ctx builds it via PoolContext::for_pool(state, ..) (buyer_channel.rs:294-324), never net of spend.
  • committed.amount comes from lane_ledger, keyed LaneKey { pool_id, signer, provider } — per provider.

buyer_channel.rs:276 already has the real invariant in committed_amount(state): sum last_amount over every lane. Nothing on the drive path reads it.

Scenario: 128 MiB blob, A holds block 0, B holds block 1. Run 1 spends 90% of the pool against A. Run 2 opens B, whose ledger committed.amount == 0, so remaining_deposit is the full deposit. The pacer never returns Refuse, the clean pre-flight PoolExhausted never fires, and the node dials B and signs a voucher the pool cannot back — taking upstream SpendingCapExhausted mid-stream, with the downstream client already being served. That is exactly the case run_fault_is_terminal (pull_leg.rs:868) exists to make cheap and terminal.

"runs are SEQUENTIAL, so two lanes never pay concurrently" (pull_leg.rs:443) answers the race, not the accounting. The client scheduler solves this correctly with SharedPool.spent summing every lane (scheduler.rs:909-914).

Same root cause, second symptom: DriveCounters::new() is constructed inside each drive call (driver.rs:391), so with pool = None the pacer reads a per-run topups_used. MAX_REACTIVE_TOPUPS = 1 is documented as the budget for "ONE call" of the node miss-pull driver, justified by cost (node_origin/funder.rs:36-51). One serve-miss across K sources can now escrow K on-chain topUp transactions and serialize K settle waits in front of one waiting client.

Fix: thread a SharedPool into the ranged loop drive calls — spent summing every lane (reuse committed_amount), a shared topups_used, and credit writing a landed top-up back.

C2 — planned runs are never clamped to [offset, offset+len).

run_from emits whole 64 MiB block spans; plan_covered_runs takes no offset/len and assemble never clamps. The gap only selects blocks.

This is live on the node: window.rs:807 sets pull_range = Some((req.byte_offset, req.byte_len)), and for FillClaim::Mixed, Some((remainder_offset, remainder_len)) at window.rs:820. So a remainder of [65 MiB, 66 MiB) plans a run of (offset: 64 MiB, len: 64 MiB) and drive_run calls drive(..., run.offset, run.len, ..) over the whole block — pulling and paying for bytes the attached sibling claim owns and is concurrently pulling, which is the double-spend the coalescing registry (#305) prevents. On a plain ranged request the practical bound is the RampPacer credit window, but the run then cannot report Filled, so the assembly ends via cancellation instead of completion — the upstream provider loses its Delivered score and a lane is held open until the serve leg cancels.

Client-side the same defect is latent: both callers pass offset = 0, len = total_bytes, but multi_source_fetch is pub, re-exported at lib.rs:84, and its docstring promises [offset, offset+len).

C3 — the cache size change makes the node advertise blocks it then refuses to serve.

6853137b switches CacheEngine::coverage to size from the observe() bitfield so a front-prefix partial advertises block 0. But the serve gate still sizes from status(): partial_hit_size (handlers/client/fill.rs:279) does self.cache.inspect(hash).await.ok()?.size_bytes?, and inspect maps BlobStatus::Partial { size } straight through (engine.rs:2524) — None for a front-prefix partial. Its own docstring says so.

Before this PR both used status() and agreed, so the block was simply never advertised. Now the node answers has_blob: true for a blob it declines to serve. A mid-fill node is the common case, so both consumers plan runs onto a holder that refuses (dial + pool open + reassign churn), and if it is the sole coverer the result is Unavailable / "all sources failed". Repeated advertise-then-decline is also the reputation hazard the origin-only-policy comment in probe.rs calls out.

Fix: make partial_hit_size use the same size source as coverage(), and add a cache test asserting the two agree on a front-prefix partial. It fails today.

Important

  • PROBE_EARLY_EXIT_CANDIDATES = 3 defeats the headline case. probe_and_rank stops at 3 answers (node_origin/mod.rs:811-818, selection.rs:47). The ranged loop does not need one working provider, it needs a candidate set whose coverage union spans the request. A 3-block blob where the first three responders all hold block 0 stops the round and the serve fails, while the block-1/2 holder was in the same fanout. The stated rationale at selection.rs:43-48 is now false either way.
  • assemble has no no-progress guard (ranged_pull.rs:96-137). surviving shrinks only on Reassign, so a round of Filled runs that does not shrink the gap re-plans identically forever. I traced this as latent, not live — BudgetPacer::Done requires cleared >= requested with paid_frontier clamped to delivered_frontier (driver.rs:559) — but the loop rests on an unstated invariant (runs union uncovered covers gap) that plan_covered_runs does not enforce for chunks past num_blocks. No FakeSink disposition can express "reports Filled, admits nothing".
  • Cancellation is not checked before the per-run lane open. drive_run runs open_or_reuse_pool (pull_leg.rs:655) — which can escrow a fresh openPool or fire the proactive low-water topUp — plus bind_upstream_ctx and missing_ranges before reaching the select! that watches cancel. On main there was one open, before the drive; now one per run, so a cancelled assembly can still land an on-chain tx for a client that is gone.
  • Client fan-out regression (scheduler.rs:879-889). spread_segments assigns each block to the covering candidate with the fewest blocks, tie-broken by rank; with all-full holders every block ties, so assignment is strict round-robin and no run ever coalesces. Each run is one block and k = all lanes, giving B x N pending segments where initial_segments gave N. With max_sources = 4 and multi_source_min_bytes = 67_108_864, a 1 GB blob across 4 full holders goes from 4 stream opens to 64. Invisible to the suite: two_sources_fetch_large_blob_byte_identical uses exactly 64 MiB, the one case where runs.len() == 1. Separately, seeding splits the block-aligned run rather than the real gap, so a resume with a small missing tail collapses to single-source (three lanes hit gaps.is_empty() at scheduler.rs:614 and idle).
  • The reassign tail has no attempt budget. handshake_from_candidates still respects MAX_PROVIDER_ATTEMPTS = 3, but the tail walks every survivor — up to 10 on the probe-cache path — each costing a resolve, econ gate, pool open, dial, and drain_abandoned, in front of a client whose stream is already open.
  • AssembleOutcome::Unavailable cannot answer NotFound. ranged_pull.rs:56 and pull_leg.rs:455 both claim the pre-Distribute serve load + revenue across partial holders (range-keyed discovery over obao4) #1506 signed NotFound. window.rs:269-279 signs and writes ok: true before spawning the pull thread at window.rs:295, so every mark_ended(Err(..)) is after the write and the client sees a truncated stream — dispatch.rs:155 says so directly. Fix the comments; if a clean refusal is wanted, open_pull_leg must check the coverage union before returning Ok.
  • The two riskiest mechanisms have zero tests. Work::retire — the headline anti-hang measure — has only doc, definition, and one call site; all three new coverage tests are all-lanes-healthy. PeerRunSink (the whole +482-line paid half: lane open, econ gate, voucher payment, scoring, watermark, cancel, classification) is exercised only by pre-existing single-holder tests, while all six assemble tests use FakeSink. C1, C2 and the cancel bug all live in that untested half, so deferring the loopback to test(node): two-holder loopback for the ranged-drive assembly path (#1506 PR2 A2 follow-up) #1897 hides exactly the defects that matter. One question only a loopback settles: handshake_total_bytes opens whole-blob (byte_offset == 0, byte_len == 0), but the seller gate is partial_hit_size(hash, 0, 0) and byte_len == 0 means "to blob_size" — requiring the whole blob present. A purely-partial holder may never answer the handshake at all.

Minor

  • Present-tense-canon violations (CLAUDE.md, explicit rule): ranged_pull.rs:3 ("no longer targets"), ranged_pull.rs:56 / pull_leg.rs:456 ("the pre-Distribute serve load + revenue across partial holders (range-keyed discovery over obao4) #1506 signed NotFound"), pull_leg.rs:567 ("the single-source leg it replaces"), probe_cache.rs:105-111 (a paragraph justifying a deletion), segment.rs:101 ("as the old byte-count-only initial split always did before coverage existed"), scheduler.rs:873, scheduler.rs:1082.
  • Stale docs this PR falsifies itself: node_origin/mod.rs:999 still says the cache stores "only the ADR triple"; selection.rs:721 and discovery.rs call the ranged-drive loop "a later task"; scheduler.rs:9 says each block goes to exactly one covering source, contradicted by the k fan-out.
  • probe_cache.rs drops both documented Implement lean positive probe cache (15s TTL, no evidence retention) #1165 evidence-retention guards (the Copy derive and the size_of <= 48 assert), leaving only the write-site literal. Reasonable, but worth explicit sign-off.
  • Never-covered blocks surface as "all sources failed; N bytes unfetched" with no lane faults recorded. No source failed — none ever held those blocks. Different owner-side remedy, deserves its own message.
  • Work::retire drops a pending entry whole rather than splitting at coverage boundaries, turning partial availability into full failure.
  • Coverage::full(1) in node_origin_pull.rs:891 is a magic constant that breaks silently if a fixture blob ever exceeds 64 MiB.
  • Test memory: a_block_only_the_all_ones_source_covers_is_served_by_it builds a 192 MiB blob cloned into three ScriptedSources (~768 MiB resident); its sibling is ~384 MiB. Likely CI OOM/flake under nextest default concurrency.
  • Two soft tests: coverage_constrained_steal_parks_instead_of_taking_uncoverable_work goes vacuous if the 200 ms slow_to_start loses the race; the all() assertions in a_block_only_the_all_ones_source_covers_is_served_by_it pass trivially if A or B opened nothing (the sibling guards this with opened_bytes() > 0).
  • Pre-existing, not introduced: requeue_missing clears the in-flight slot before pushing the remainder, so all_idle() is briefly true mid-requeue and a healthy peer can break and orphan recoverable work. Identical on main, but this PR rewrites the area and claims to close the anti-hang gap.

What holds up

Verified rather than assumed: untrusted-Coverage handling is correctly bounded by num_blocks(total_bytes) in both consumers; no overlapping assignment from the steal path (predicate before argmax, trim and cancel under one lock, every incomplete-trim branch declines); PoolExhausted really is terminal on every path (nothing adds .context(..) between fill_gap and drive_run); no behavior dropped in the 253 deleted lines (reputation scoring, classify_pull_failure, is_bao_corruption, ADR 041 debit_speculative, SettleOnDrop, ConnDrain, mark_ended semantics all reproduced per run); anti-panic policy clean throughout; the demand window is coherent across runs with no boundary stall. The concentrate planner tests (stickiness, boundary flip, gap-skip contiguity, single-middle-block) test the contract rather than the implementation, and both lane_coverage branches are covered.

Suggested sequence

  1. Block on C1-C3.
  2. Fix the early-exit bound, the no-progress guard, the cancel check, and the reassign budget — each small and local.
  3. Land the two-holder loopback (test(node): two-holder loopback for the ranged-drive assembly path (#1506 PR2 A2 follow-up) #1897) in this PR, not after it, plus a Work::retire fault test and a Filled-but-no-progress test.
  4. Re-plan the fan-out regression — gap-intersected runs plus a fan-out cap is a design decision, not a patch.
  5. Sweep the canon/stale-doc violations.

🤖 Review generated with Claude Code

alpergundogdu and others added 6 commits September 1, 2026 18:53
…are solvency and top-up budget (#1506)

The node's ranged-drive loop assembles a blob across partial holders as a
sequence of `drive` calls, each opening its own per-provider lane but all
drawing on ONE shared buyer pool. Every call passed `pool = None`, selecting
the single-source solvency model: `deposit - this_lane_committed`. A later
run's fresh lane sees its own `committed == 0`, believes the whole deposit is
unspent, and signs a voucher the pool cannot back -> mid-stream
`SpendingCapExhausted` while the downstream client is being served. The same
per-run `DriveCounters` also made the reactive-top-up budget per-run, so a
K-source miss could escrow K on-chain `topUp` txs for one serve.

Thread an `Option<&SharedPool>` through `drive` into `fill_gap` (single-source
callers pass `None`). The node builds one `SharedPool` view per run over
assembly-wide state:
- `spent`: the whole-pool committed amount, summed across every live lane
  ledger for the pool via new `BuyerLedgers::pool_committed`, including the
  run's own seeded lane -- so each run gates on the true aggregate spend.
- `topups_used`: one `AtomicU32` on `PeerRunSink`, shared across every run, so
  the reactive-top-up budget spans the whole assembly.
- `credit`: writes a landed top-up's new deposit to the run's ctx; a later run
  re-reads it from the persisted pool row `open_or_reuse_pool` refreshed.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…are actually served (#1506)

C3 (human review): the node advertised a front-prefix partial's blocks
(coverage sizes from the observe() bitfield) but partial_hit_size sized
from inspect()/status(), which iroh-blobs leaves None until the tail chunk
validates — so the serve gate declined the very blocks just advertised.
partial_hit_size now derives the size from the same bitfield source
(present_ranges().size()), keeping the fully-present gating intact. New
test asserts coverage() and the partial-serve size source agree on a
front-prefix partial (fails before this fix).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…esce client fan-out (#1506)

C2: run_from now clamps every CoveredRun to the byte extent the gap
actually misses inside its discovery block(s), so a partial in-block
gap (e.g. a Mixed remainder [65 MiB, 66 MiB)) plans a run of exactly
that slice instead of the whole 64 MiB block — no over-pull, no
over-pay, no double-fetch of a sibling's bytes. Applies to both the
node concentrate planner and the client spread planner.

Fan-out: spread_segments assigns blocks stickily under a fair-share
cap, so a large gap across N full holders plans ~N contiguous runs
(one span per source) instead of one run per block. The scheduler
seeds pending from those runs under a GLOBAL fan-out budget
(lanes.len()), splitting largest-first only to reach idle lanes rather
than multiplying every run by holder count — so a large multi-block
blob seeds ~N spans, never blocks×N, while a small blob or resume tail
still spreads across the covering lanes.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…budget guards on the ranged loop (#1506)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
…:retire fault coverage (#1506)

Paid-half integration coverage landed in-PR (review ask): a gated
(test-support) DISCOVERY_BLOCK_BYTES override (production reads the const,
byte-identical) lets a loopback drive tiny blocks;
two_partial_holders_assemble_over_the_real_paid_path assembles A:{block0} +
B:{block1} across two sequential PeerRunSink voucher lanes on ONE shared
pool over a 32 KiB blob, ending Complete with each holder paid only for its
block (exercises C1 shared-pool + C2 clamp end-to-end);
retire_drops_only_entries_no_surviving_lane_covers covers Work::retire when
a lane exits. Regenerates the protocol public_api snapshot for
discovery_block_bytes(). Covers #1897.

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

Copy link
Copy Markdown
Contributor Author

Thanks for this — it caught real bugs, including a payment-correctness one (C1) that my own review passes missed. All findings are addressed on the branch; a final whole-rework re-review came back READY (payment safety re-verified end-to-end, no new breakage, --features public-api-test 158/158).

Critical

  • C1 (shared-pool solvency) — dcd8a617: the ranged loop now injects a SharedPool into every run's drive; spent reads the whole-pool aggregate (ledgers.pool_committed(pool_id), all providers incl. in-flight), topups_used is one shared AtomicU32, credit propagates. Run N's gate now subtracts runs 1..N-1's cumulative spend.
  • C2 (runs unclamped) — 48fafc18: gap_extent clamps every run to gap ∩ request in both planners — [65 MiB, 66 MiB) plans (65 MiB, 1 MiB), not a whole block.
  • C3 (advertise-then-decline) — f54034f1: partial_hit_size sizes from the observe() bitfield (present_ranges().size()), agreeing with coverage(); a cache test asserts the agreement on a front-prefix partial.

Important — 1775b060: I1 union-aware ProbeGather::CoverageUnion on the assembly path (early-exit kept for single-source); I2 assemble no-progress guard (+ termination test); I3 cancel-check before the per-run lane open; I4 MAX_REASSIGN_ATTEMPTS budget (+ cap test); I5 corrected the false "signed NotFound" comments to "truncated stream after ok:true".

Fan-out — 48fafc18: coalesced global-budget seeding — a large multi-block gap across N full holders opens ~N streams, not block×N, and a resume tail still spreads (three tests).

Tests — 46971ace: the two-holder two_partial_holders_assemble_over_the_real_paid_path loopback drives the real PeerRunSink (two sequential lanes, one shared pool, per-block payment asserted) via a test-support-gated DISCOVERY_BLOCK_BYTES override (prod reads the const, byte-identical, can't leak) — this is the previously-untested paid half where C1/C2/cancel lived. Work::retire fault test added. This covers #1897 (closes on merge).

Canon — e6c0f7ab: swept the changelog-voice comments and the three stale docs (probe-cache "only the ADR triple", ranged-loop "later task", scheduler "exactly one covering source").

One awareness note: the public-API snapshot now lists the test-support symbols (TestBlockSizeGuard, override_discovery_block_bytes_for_test) — a consequence of the pre-existing .all_features(true) render, not a behavior change.

🤖 Generated with Claude Code

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.

🔵 Needs a closer look

It rewires core node/client fetch orchestration and payment-lane execution paths, so it warrants final human review despite strong test coverage.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

crates/client-pull/src/coverage_plan.rs:252

  • spread_segments computes rank_pos via rank.iter().position(..) inside the per-block, per-candidate min_by_key closure. That makes planning O(blocks × candidates × rank_len) and does repeated linear scans of rank. Precompute a HashMap<source_ix, rank_pos> once and look up positions in O(1) during the assignment loop.
  • Files reviewed: 14/14 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

alpergundogdu and others added 2 commits September 2, 2026 10:40
…nment (#1506)

Address PR #1898 review: spread_segments recomputed each candidate's rank
position with a linear rank.iter().position() scan inside the per-block,
per-candidate min_by_key closure (O(blocks * candidates * rank_len)). Invert
rank into a HashMap<source_ix, rank_pos> once and look up in O(1) —
behaviour-identical, all 15 coverage_plan tests green. Also silence a
default-build-only missing_const_for_fn on chunks_per_block (it cannot be
const under the test-support feature).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@alpergundogdu
alpergundogdu merged commit d0da97c into main Sep 2, 2026
27 checks passed
@alpergundogdu
alpergundogdu deleted the claude/1506-pr2-consumers branch September 2, 2026 10:45
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.

Distribute serve load + revenue across partial holders (range-keyed discovery over obao4)

3 participants