Skip to content

feat: range-keyed partial-holder discovery — data layer (#1506 PR1) - #1894

Merged
alpergundogdu merged 7 commits into
mainfrom
claude/1506-pr1-coverage-data-layer
Sep 1, 2026
Merged

alpergundogdu merged 7 commits into
mainfrom
claude/1506-pr1-coverage-data-layer

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

First of two implementation PRs for #1506 (design merged in #1885/#1887). This is the data layer: it makes partial holders discoverable and serveable by byte range. No consumer/scheduler changes — that's PR2.

What lands

  • protocol::Coverage — a 64 MiB block bitmap (bit-packed), with CacheEngine::coverage deriving cached-block coverage from the iroh-blobs bitfield (af54128c).
  • Probe carries the coverage bitmap (unsigned ProbeResponseExt), and has_blob is redefined as "will serve ≥1 block" — biconditional with coverage (has_blob == !coverage.is_empty()). Origin-serve-capable nodes emit all-ones from the size they already read; a requester drops a probe whose has_blob/coverage disagree (4123c50f).
  • DHT records + FIND_VALUE carry per-provider coverage; the advertise gate relaxes from Complete to any verified block; find_providers → Vec<(NodeId, Coverage)> (47420d85, 140c00c4).
  • Partial-serve gate — a partial holder serves the byte ranges it holds (cb4281ed), the counterpart to the advertise relax.

Coverage semantic = "blocks the sender WILL serve": cached blocks for a cache holder, all-ones for an origin. has_blob ⟺ non-empty coverage.

Frozen surfaces (verified byte-identical)

The signed probe set {hash, has_blob, rate_per_mb, timestamp_us} and the DhtMessage variant order are unchanged (only unsigned/payload fields grew). No contract change.

Known limitation (accepted, deferred — safe)

iroh-blobs doesn't expose a partial blob's total size until its last chunk lands, so a non-origin front-prefix partial (blocks 0..N, no tail) derives empty coverage → it isn't advertised and answers has_blob:false. This is safe (under-advertises, never mis-advertises) and inert in PR1 (no consumer). Follow-up before PR2's node-assembly leans on abandoned-prefix supply: persist total_bytes at fill time (FillSession already holds it).

Deferred nits (none block merge)

  • Coverage::full bit-by-bit fill (perf).
  • cache.coverage() per-probe store round-trip (not hot path); cli/probe.rs standalone command left unwired (print-only, moot).
  • find_providers IndexMap dedup: last-fold-wins coverage on a duplicate NodeId — harmless in PR1 (coverage unused here), note for PR2.
  • Origin-held-uncached hash advertises empty coverage on the DHT record while the probe says all-ones (under-advertising, safe) — folds into the size-persistence follow-up.
  • A tautological debug_assert in the probe handler.

Tests

New: Coverage unit tests, probe cached-partial + origin-all-ones loopback tests + requester-drop, cache_still_holds partial-holder test, DHT STORE→FIND_VALUE partial-coverage round-trip, partial_serve.rs (serve-from-cache + mixed-range-falls-through-to-origin). Full node suite green (1078), clippy/fmt/deny/ADR-hygiene clean, anvil-e2e compiles.

🤖 Generated with Claude Code

Adds the partial-serve gate to serve_stream's miss path: when the
requested byte range is already fully present in a not-Complete blob's
local cache, serve it straight from cache (CacheHit shed class, same
size gate + deliver as an ordinary hit) instead of running the miss
path's fill legs. A partial holder can now serve the ranges it
advertises via probe/DHT coverage; an uncovered range still falls
through to the existing fill legs unchanged.
Copilot AI lite review requested due to automatic review settings September 1, 2026 12:18
…ace (#1506)

The public-api-test feature is out of the default nextest run, so the
coverage additions (protocol::coverage module, Provider, StoreRequest/
BatchStoreRequest/FindValueResponse/ProbeResponseExt fields) did not update
the committed snapshot during implementation. DhtMessage and the signed
ProbeResponseBody are absent from the diff — frozen surfaces stayed frozen.

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

Pull request overview

This PR implements the data-layer plumbing for range-keyed partial-holder discovery (#1506) by introducing a 64 MiB discovery-block coverage bitmap into the protocol, carrying it through probe and DHT surfaces, and enabling nodes to serve byte ranges directly from cached partials when the requested span is fully present.

Changes:

  • Add protocol::Coverage (bit-packed discovery-block bitmap) and thread it through probe extensions and DHT provider records / STORE messages.
  • Redefine probe has_blob to mean “will serve ≥1 discovery block” and enforce the has_blob ⟺ !coverage.is_empty() consistency check at consumers.
  • Relax advertise + serve gates to support partial holders: DHT publish now admits any verified block, and client serving can short-circuit to direct cache serve for fully-present requested ranges on partial blobs.

Reviewed changes

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

Show a summary per file
File Description
crates/protocol/src/message.rs Extends ProbeResponseExt with Coverage and adds a signed/unsigned consistency helper + tests.
crates/protocol/src/lib.rs Exposes the new coverage module and re-exports Coverage/helpers.
crates/protocol/src/framing.rs Updates framing tests for the new probe extension field.
crates/protocol/src/dht.rs Adds per-provider coverage on FIND_VALUE responses and coverage in STORE / BATCH_STORE payloads.
crates/protocol/src/coverage.rs Introduces the Coverage bitmap type, encoding semantics, and unit tests.
crates/cache/src/engine.rs Implements CacheEngine::coverage by deriving covered discovery blocks from present chunk ranges + tests.
crates/node/src/handlers/probe.rs Derives final “will-serve” coverage (origin/all-ones vs cache-derived) and re-derives has_blob from it.
crates/node/src/node_origin/mod.rs Drops probe candidates whose signed has_blob disagrees with unsigned coverage emptiness.
crates/node/src/handlers/dht.rs Plumbs coverage through STORE and BATCH_STORE admission into the record store.
crates/node/src/dht/records.rs Stores per-holder Coverage in the record store and returns it in provider listings.
crates/node/src/dht/lookup.rs Returns Vec<(NodeId, Coverage)> from lookups and preserves per-node coverage through folding/dedup.
crates/node/src/dht/client.rs Sends coverage in STORE and (hash, coverage) entries in BATCH_STORE.
crates/node/src/dht/publish.rs Switches republish eligibility to coverage-non-empty and publishes coverage snapshots in STORE/BATCH_STORE.
crates/node/src/handlers/client/fill.rs Adds a partial-hit size gate to detect fully-cached requested spans on non-Complete blobs.
crates/node/src/handlers/client/dispatch.rs Uses the partial-serve gate to route fully-present spans to the cache-hit serve path (no fill).
crates/node/tests/probe_loopback.rs Adds loopback tests for cached-partial coverage + origin all-ones coverage.
crates/node/tests/partial_serve.rs New end-to-end tests for serving within cached partial ranges and falling through on mixed spans.
crates/node/tests/node_origin_pull.rs Updates probe responses in tests to include full coverage.
crates/node/tests/dht_loopback.rs Updates DHT loopback tests for coverage-carrying STORE/BATCH_STORE and provider assertions.
crates/node/tests/dht_lookup.rs Updates lookup tests to assert (NodeId, Coverage) results.
crates/node/tests/dht_integration.rs Updates integration tests to assert coverage is propagated with providers.
crates/node/tests/dht_bootstrap.rs Updates bootstrap test helpers to store coverage.
crates/node/src/admin.rs Updates admin test fixture record insertion to include coverage.
crates/cli/tests/admin_rpc.rs Updates CLI admin RPC test fixture record insertion to include coverage.
crates/cli/src/commands/probe.rs Updates CLI probe command tests to build consistent coverage with has_blob.
crates/cli/src/commands/fetch.rs Drops probe candidates on has_blob/coverage mismatch in the CLI’s ordering path.
adr/022-content-discovery.md Updates DHT bandwidth analysis to reflect provider coverage overhead.

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

Comment thread crates/protocol/src/coverage.rs Resolved
Comment thread crates/cache/src/engine.rs Resolved
… factor bao chunk const (#1506)

Address PR #1894 review:
- Coverage doc now states that a deserialized-from-wire bitmap may carry
  spurious trailing high bits, so covers/covered_blocks report raw bits and
  consumers MUST clamp to the blob's own num_blocks(total_bytes).
- CacheEngine::coverage factors the duplicated bao leaf chunk size (1024)
  into a single BAO_CHUNK_BYTES const.

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

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 82.64% (was 82.59%, ▲ +0.05%) — 71235/86197 lines

File Coverage Lines Δ
crates/cache/src/engine.rs 92.97% 4721/5078 ▲ +0.11%
crates/cli/src/commands/fetch.rs 32.56% 522/1603 ▼ 0.08%
crates/cli/src/commands/probe.rs 76.17% 147/193 ▲ +0.12%
crates/node/src/admin.rs 92.53% 978/1057 ▲ +0.01%
crates/node/src/dht/client.rs 77.54% 107/138 ▲ +0.84%
crates/node/src/dht/lookup.rs 96.11% 445/463 ▲ +0.19%
crates/node/src/dht/publish.rs 90.63% 1112/1227 ▼ 0.78%
crates/node/src/dht/records.rs 98.95% 473/478 ▲ +0.13%
crates/node/src/handlers/client/dispatch.rs 85.00% 493/580 ▼ 1.30%
crates/node/src/handlers/client/fill.rs 67.97% 87/128 ▲ +4.25%
crates/node/src/handlers/dht.rs 77.04% 292/379 ● 0.00%
crates/node/src/handlers/probe.rs 86.45% 287/332 ▼ 0.05%
crates/node/src/node_origin/mod.rs 92.78% 977/1053 ▼ 0.14%
crates/protocol/src/coverage.rs 100.00% 90/90 new
crates/protocol/src/dht.rs 96.88% 434/448 ▲ +0.09%
crates/protocol/src/framing.rs 97.74% 390/399 ▲ +0.01%
crates/protocol/src/message.rs 99.67% 301/302 ▲ +0.03%
History
Commit Total Δ vs base
2702093 82.64% ▲ +0.04%
74205bc (HEAD) 82.64% ▲ +0.05%

@alpergundogdu
alpergundogdu merged commit e99df05 into main Sep 1, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the claude/1506-pr1-coverage-data-layer branch September 1, 2026 12:46
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