Skip to content

fix(cli,common): fetch bootstraps cold content from origins instead of bailing on empty holders (#1911) - #1912

Merged
alpergundogdu merged 2 commits into
mainfrom
claude/issue-1911-pr-32d7dd
Sep 2, 2026
Merged

alpergundogdu merged 2 commits into
mainfrom
claude/issue-1911-pr-32d7dd

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Closes #1911.

Problem

decdn fetch auto-discovery bailed the moment no probed node held the blob in its cache store (holders.is_empty()), even while holding a pool of reachable, bonded non-holders it could stream from. In a caching network this is a bootstrap paradox: every object is born origin-only with zero cache holders — the normal first-fetch state of all content — so a holders-only fetch can never trigger the first pull that populates any cache.

The serve side already does the right thing (the issue's explicit---node-id repro streams straight from the node's fs origin). The bug was entirely client-side candidate selection: the discarded non-holder entries each already carried the exact {node_id, eth_address} the working explicit path consumes.

has_blob is engine.has() = cache store only; a has_blob:false node can still serve an authorized miss via pull-through from its own configured origin (or node-to-node). Treating a false has_blob as "cannot serve me" was a false negative.

Change

In crates/cli/src/commands/fetch.rs (probe_and_order / failover_order):

  • Keep every reachable, verified, consistent non-holder as a pull-through serve target — not only when proxy warming is enabled. The bootstrap fallback is decoupled from the warming optimization, so --proxy-warming false can't reintroduce the bug.
  • Fall back to the non-holders (nearest RTT first) as the failover order when no holder answers. The set is already bounded by select_candidates/SELECT_K, so an empty-holders fetch never sprays every registered node. The healthy holders-present path — holder ranking and proxy-warming leads — is untouched, so the tuned multi-source path is unchanged.
  • Error only in the genuinely terminal case: neither a cache holder nor a reachable non-holder answered. The message no longer says "nobody holds it" when the real cause is unreachable or misconfigured (unverifiable) candidates. A genuine miss at the origin still surfaces from the delivery failover loop.

Also reconciles the --namespace help text (the issue's side-finding) with actual serve behavior: an absent namespace disables routing to a namespace's authorized origin set, but the serving node's own configured origin stays a serve target either way (namespace_id is a routing hint, not a serve gate — ADR 002).

Net effect

A node that is an authorized origin for content serves it on demand from its durable on-disk copy via plain decdn fetch — no publish → prefetch → pin cycle, no out-of-band warming.

Tests

  • New unit tests on the pure failover_order: empty-holders falls back to non-holders nearest-RTT-first (independent of proxy warming), and empty+empty yields an empty order (the terminal case probe_and_order turns into an error).
  • Full suites green: decdn-cli, decdn-common, decdn-client-pull (1130 tests). Workspace clippy --all-targets --all-features, the RUSTDOCFLAGS=-D warnings doc gate, and cargo fmt --check all clean.

Note: this fix is purely client-side selection logic, covered precisely by the failover_order unit tests; the node-side origin serve it relies on is already proven by the origin_stream_while_store / g_origin_01_publish e2e and the issue's explicit-node repro. A gated anvil-e2e test that fetches an origin-only blob via auto-discovery (no --node-id) is a natural follow-up.

🤖 Generated with Claude Code

…f bailing on empty holders (#1911)

`decdn fetch` auto-discovery bailed the moment no probed node held the blob in
its cache store (`holders.is_empty()`), discarding a pool of reachable, bonded
non-holders it could stream from. In a caching network that is a bootstrap
paradox: every object is born origin-only with zero cache holders — the normal
first-fetch state of all content — so a holders-only fetch could never trigger
the first pull that populates any cache. A `has_blob:false` from the cache store
is not proof of un-serveability: the node can still serve an authorized miss via
pull-through from its own configured origin (or node-to-node).

Client-side candidate selection now:

- Keeps every reachable, verified, consistent non-holder as a pull-through serve
  target, not only when proxy warming is enabled. The bootstrap fallback is
  independent of the warming optimization, so `--proxy-warming false` cannot
  reintroduce the bug.
- Falls back to the non-holders (nearest RTT first, already bounded by
  `select_candidates`/`SELECT_K`) as the failover order when no holder answers.
  The healthy holders-present path — holder ranking and proxy-warming leads — is
  untouched.
- Errors only in the genuinely terminal case: neither a cache holder nor a
  reachable non-holder answered. The message no longer reads "nobody holds it"
  when the real cause is unreachable or misconfigured (unverifiable) candidates.

Also reconciles the `--namespace` help text with actual serve behavior: an absent
namespace disables routing to a namespace's authorized origin set, but the
serving node's own configured origin stays a serve target either way
(`namespace_id` is a routing hint, not a serve gate — ADR 002).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 2, 2026 15:08

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.

🟡 Changes recommended

The new terminal error helper’s documentation/branching can still misattribute mixed “unreachable vs. unverifiable vs. unusable” probe outcomes, and should be adjusted for accuracy before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR fixes decdn fetch auto-discovery candidate selection so cold (origin-only) blobs can be fetched by falling back to reachable non-holder nodes as pull-through serve targets, instead of failing when no cache holder answers. It also updates the CLI --namespace help text in common to match actual serve behavior around namespace routing vs. local origin serving.

Changes:

  • Keep reachable, verified non-holders as valid serve targets and use them as the failover order when no holders respond.
  • Refine the “no serve target” terminal error path to only trigger when no holder and no reachable non-holder exists.
  • Update FetchArgs::namespace help text to clarify that omitting --namespace disables routing to DAO-authorized origin sets but does not disable the serving node’s own configured origin.
File summaries
File Description
crates/common/src/cli/fetch.rs Updates --namespace help text to reflect namespace routing semantics vs. local origin serving.
crates/cli/src/commands/fetch.rs Changes probe ordering logic to fall back to reachable non-holders for cold-blob bootstrapping; adds unit tests for the new ordering behavior.
Review details

Suppressed comments (1)

crates/cli/src/commands/fetch.rs:307

  • no_serve_target_error currently treats any unverifiable > 0 as the primary terminal failure and returns a chain-config-focused message even when only some candidates answered (others timed out or returned unusable probe data). This can mislead operators; consider distinguishing: (1) all answers unverifiable, (2) all candidates unreachable, and (3) mixed/unusable answers with counts.
    if unverifiable > 0 {
        return anyhow::anyhow!(
            "{unverifiable} of {probe_count} probed node(s) answered, but their probe \
             signatures did not recover to the operator address each is registered \
             under. That is usually local configuration rather than missing content: \
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

Comment thread crates/cli/src/commands/fetch.rs Resolved
…e-target error (#1911)

The terminal error's doc and message treated the failure as only "unreachable"
or "unverifiable", but the selection loop also drops a candidate that answered
with a has_blob/coverage mismatch. When such a drop leaves no holder and no
non-holder, the message now names both the unreachable and the answered-but-
unusable counts instead of implying a silently unreachable set.

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

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown

Coverage report

Total: 82.70% (was 82.70%, ▼ 0.01%) — 74110/89618 lines

File Coverage Lines Δ
crates/cli/src/commands/fetch.rs 35.29% 608/1723 ▲ +1.41%
crates/common/src/cli/fetch.rs 96.22% 178/185 ● 0.00%
History
Commit Total Δ vs base
7c0b269 (HEAD) 82.70% ▼ 0.01%

@alpergundogdu
alpergundogdu merged commit 6f923af into main Sep 2, 2026
25 checks passed
@alpergundogdu
alpergundogdu deleted the claude/issue-1911-pr-32d7dd branch September 2, 2026 15:30
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.

fetch bails when no node caches the blob (holders.is_empty) — a caching network can't bootstrap cold content from origins

2 participants