Skip to content

fix(node,cache): reach the directory origin when DHT holders are partial-only - #2201

Merged
thiras merged 1 commit into
mainfrom
fix/2195-origin-supplement-partial-holders
Sep 28, 2026
Merged

thiras merged 1 commit into
mainfrom
fix/2195-origin-supplement-partial-holders

Conversation

@thiras

@thiras thiras commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

What

A serve-miss whose DHT answer names only partial holders reaches the namespace's origin instead of truncating the client's stream.

Since #2188 a DHT answer can name only partial holders. discover read the on-chain origin directory only when the DHT answer was empty, so the ranged assembly ran out of candidates for the blocks no partial held. assemble ended Unavailable and the client got a short stream after ok: true (nbg1 → ash1 partial, bcl origin never tried; trace 16caa1b033e23a288fbb817859e22f28).

  • Origin supplement (node_origin/mod.rs): on the ranged pull leg (ProbeGather::CoverageUnion), a probe round whose holders don't span the blob is followed by a round over the origin-directory candidates it did not probe. That includes an origin the DHT named but that fell past the probe_fanout cut. The buffered fill path (EarlyExit, namespace 0) is unchanged.
  • Cache hits (pull_leg.rs): a probe-cache entry that doesn't span the blob counts as a miss on the ranged leg and runs a fresh lookup.
  • Partial holders report their size (CacheEngine::coverage_sized → handlers/probe.rs). Before, a partial's probe carried total_bytes: None, so a set of partials that covered every block between them never counted as spanning. There is no wire change: ProbeResponseExt.total_bytes already exists, and ADR 005 already asks nodes to include it when known.
  • Refusal before commit (window.rs step 6c): before signing ok: true, the serve leg checks, against the signed total_bytes, that its candidates cover the part of the pull range it doesn't hold. If they don't, the client gets a signed miss it can fail over on, not a truncated stream.
  • Diagnosable failures: AssembleOutcome::Unavailable(UnavailableCause) covers four causes (every covering candidate faulted, no progress, uncovered range, reassign budget), with a warn! in run_pull_leg. New debug! lines cover the supplement's outcome and rejected cache entries.
  • Docs: ADR 022 gains the partial-coverage fallback and the refusal-before-commit rule. ADRs 001 and 039, architecture.md, appendix-observability.md (the cache-miss case and one latency sample per round) and the stale "only when the DHT is empty" comments are updated to match.

Closes #2195

Reviewer notes

  • Start with probe_and_rank / probe_round in node_origin/mod.rs, then pull_range_uncovered in handlers/client/window.rs.
  • The supplement is decided after probing, not in discover. The DHT coverage hint has no block count, and only a probe reports the blob size.
  • Probe counts: each round takes its own probe_fanout, so a supplemented miss probes at most 2× probe_fanout peers. decdn_probe_collection_latency_seconds records one sample per round, so a supplemented miss records two; this is documented in the metric doc and the appendix row.
  • The refusal check runs the same uncovered-range test assemble applies in its first round (ranged_pull::uncovered), against the signed size. It refuses like the step-6b error branch does. A store read fault fails open.
  • Lint allow: serve_via_window_pull_through gets clippy::cognitive_complexity (26/25) next to its existing too_many_lines. The numbered steps are one ordered sequence before the signed commit.
  • No new metrics: failures are already counted by outbound_stream_ended(false) / serve_stream_node_fault, and the new detail goes to logs.

Verification

  • cargo fmt -- --check
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo nextest run -p decdn-node -p decdn-cache: 1927 passed
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --document-private-items
  • pre-commit run --all-files
  • contracts/ changed: n/a
  • User-visible change: CHANGELOG.md entry added
  • Design change: ADR 022 updated (plus 001, 039, architecture, observability appendix)
  • PR title uses an allowed type, with a lowercase subject

New tests, which stayed green over --stress-count 20:

  • node_origin_pull.rs, six serve_miss_discovery_case scenarios: a partial-only DHT answer, a partial-only cache entry, a cache entry that covers every block (a hit, no probes), DHT holders that already cover every block (no second round), an origin past the probe cut, and no candidate able to cover the range (refused before commit). Each asserts the probe-round count, and the cache cases also assert hits and misses.
  • Mutation-checked: reverting the probe-cut fix, the span guard, or the refusal check each fails its test.
  • Unit tests:
    • a specific UnavailableCause per exit, including a new test for the every-candidate-faulted case;
    • coverage_spans;
    • coverage_sized;
    • a partial holder's probe response carries its size.

Retries noted: one earlier full-suite run needed a retry on origin_range_pull::cold_out_of_bounds_range_is_refused_before_signing (it passed 30 of 30 under stress). That file doesn't use NodeOrigin, so the new check never runs there.

🤖 Generated with Claude Code

…ial-only

Since #2188 a DHT answer can name only partial holders. `discover` read the
on-chain origin directory only when the DHT answer was empty, so the ranged
assembly ran out of candidates for the blocks no partial held and the client
got a truncated stream after `ok: true`.

On the ranged pull leg, a probe round whose holders do not span the blob is
followed by a round over the origin-directory candidates it did not probe,
an origin past the `probe_fanout` cut among them. A probe-cache entry that
does not span the blob counts as a miss there. A partial holder's probe now
carries the blob size (`CacheEngine::coverage_sized`), so a set of partials
that covers every block counts as spanning.

Before signing `ok: true` the serve leg checks, against the signed size, that
its candidates cover the part of the pull range it does not hold, and refuses
with a signed miss when they do not. `AssembleOutcome::Unavailable` carries
its cause, logged with a `warn!`. ADR 022 gains the partial-coverage fallback
and the refusal-before-commit rule; ADRs 001 and 039, architecture.md and the
observability appendix follow.

Closes #2195

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

🟢 Approval recommended

The remaining documentation issue is a minor nit and does not block approval.

Review effort: Lite
Findings: None

What changed in this PR

Fixes ranged serve-misses by supplementing partial DHT results with origin candidates and refusing incomplete pulls before stream commitment.

Changes:

  • Adds coverage-aware origin fallback and cache validation.
  • Reports partial-holder sizes and adds pre-commit refusal checks.
  • Updates diagnostics, tests, documentation, and changelog.
File Description
crates/​node/​tests/​probe_loopback.rs Verifies partial probe-size reporting.
crates/​node/​tests/​node_origin_pull.rs Adds discovery and refusal regression tests.
crates/​node/​src/​runtime/​mod.rs Documents origin-directory wiring.
crates/​node/​src/​node_origin/​ranged_pull.rs Adds failure causes and coverage checks.
crates/​node/​src/​node_origin/​pull_leg.rs Validates cache coverage and logs failures.
crates/​node/​src/​node_origin/​mod.rs Adds coverage tracking and origin supplementation.
crates/​node/​src/​metrics.rs Documents probe-round metrics.
crates/​node/​src/​handlers/​probe.rs Reports partial-holder sizes.
crates/​node/​src/​handlers/​client/​window.rs Adds pre-commit coverage refusal.
crates/​node/​src/​dht/​origin.rs Updates origin-directory documentation.
crates/​cache/​src/​engine.rs Adds sized coverage derivation; minor documentation clarification remains.
CHANGELOG.md Records the fix.
adr/​architecture.md Updates architecture documentation.
adr/​appendix-observability.md Updates observability semantics.
adr/​039-multi-source-parallel-fetch.md Documents pull-leg behavior.
adr/​022-content-discovery.md Defines partial-coverage fallback and refusal.
adr/​001-network.md Updates network fallback documentation.

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

@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

The overall line coverage in commit acc5d34 in the fix/2195-origin-supp... branch remains at 86%, unchanged from commit 8102004 in the main branch.

Show a line coverage summary of the most impacted files.
File main 8102004 fix/2195-origin-supp... acc5d34 +/-
crates/client/src/streamer.rs 92% 91% -1%
crates/node/src.../ranged_pull.rs 100% 99% -1%
crates/node/src...e_origin/mod.rs 91% 91% 0%
crates/node/src...gin/pull_leg.rs 89% 89% 0%
crates/node/src/runtime/mod.rs 51% 51% 0%
crates/cache/src/engine.rs 94% 94% 0%
crates/node/src...ndlers/probe.rs 88% 88% 0%
crates/node/src...lient/window.rs 71% 72% +1%
crates/incentiv...eth_identity.rs 98% 99% +1%

@thiras
thiras merged commit 0cf9688 into main Sep 28, 2026
31 checks passed
@thiras
thiras deleted the fix/2195-origin-supplement-partial-holders branch September 28, 2026 04:23
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.

node: a DHT answer with only partial holders skips the origin-directory fallback, so the ranged miss fails

2 participants