Repository navigation
feat: range-keyed partial-holder discovery — consumers (#1506 PR2) - #1898
Conversation
…coverage planner (#1506)
… loop (#1506) Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ve loop (#1506) Co-Authored-By: Claude Opus 4.8 <[email protected]>
…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.
There was a problem hiding this comment.
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.
Coverage reportTotal: 82.87% (was 80.30%, ▲ +2.57%) — 72713/87740 lines
History
|
…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]>
Review: coverage-aware consumers (#1506 PR2)Read-only review of the full branch against 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. CriticalC1 — the node ranged loop declines
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 "runs are SEQUENTIAL, so two lanes never pay concurrently" ( Same root cause, second symptom: Fix: thread a C2 — planned runs are never clamped to
This is live on the node: Client-side the same defect is latent: both callers pass C3 — the cache size change makes the node advertise blocks it then refuses to serve.
Before this PR both used Fix: make Important
Minor
What holds upVerified rather than assumed: untrusted- Suggested sequence
🤖 Review generated with Claude Code |
…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]>
…bly + coverage-scheduler paths (#1506)
|
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, Critical
Important — Fan-out — Tests — Canon — One awareness note: the public-API snapshot now lists the 🤖 Generated with Claude Code |
There was a problem hiding this comment.
🔵 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_segmentscomputesrank_posviarank.iter().position(..)inside the per-block, per-candidatemin_by_keyclosure. That makes planning O(blocks × candidates × rank_len) and does repeated linear scans ofrank. Precompute aHashMap<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
…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]>
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_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).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 theobserve()bitfield, notstatus()— so abandoned-prefix partials (no tail chunk) advertise. Read-only; no persistence needed (spike-confirmedbitfield.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 byspread_segments, coverage-filtered steal,Work::retireanti-hang).0dcd5418— thread real per-holder coverage intoSourceLane.coverage(closes an inert-client-channel gap the review caught: coverage was measured but dropped before the scheduler).Correctness (final-review verified)
(signer,provider)lane at a time, one shared pool); client keepsper_source_inflight=1+ one-node-per-operator; the planner assigns each block to exactly one source (no overlapping lanes, no double-pay).Coverageuntrusted-bits contract honored — both consumers bound queries tonum_blocks(total_bytes), so a lying holder's trailing bits can't inject phantom coverage.split_evenly(client).Follow-ups / deferred nits (none block merge)
PeerRunSinktwo-lane wiring (needs aDISCOVERY_BLOCK_BYTEStest override; the logic is unit-tested viaRunSinkfakes).BAO_CHUNK_BYTES(1024) is duplicated across a few sites; aDISCOVERY_BLOCK_BYTESoverride seam would also let the loopback land — cosmetic.Per-task and whole-branch reviews clean; clippy
--workspace --all-targets -D warnings0; all task suites green (node suite, 240/240 client-pull, 683 client-pull+cli, anvil-e2e compile gate).🤖 Generated with Claude Code