Skip to content

refactor(slashing): retire the phantom-announcement offense - #1512

Merged
thiras merged 7 commits into
mainfrom
claude/phantom-announcement-blacklist-267b72
Jul 29, 2026
Merged

thiras merged 7 commits into
mainfrom
claude/phantom-announcement-blacklist-267b72

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Why

On-chain slashing only binds a forkable node when every signature in the evidence sits on a benefit-taking action (get paid / get selected). Phantom announcement fails that test: its second half is a signed StreamResponse{ok:false}, coerced by nothing — a malicious fork just drops the stream or runs a one-line patch. So the phantom offense could never catch the adversary it targeted; it only ever slashed honest operators running the reference binary. "Advertised but didn't serve" is an availability failure and now lives solely in local reputation (ADR 008).

The other two offenses are sound (their evidence is all benefit-side) and are kept: rate manipulation and blacklist violation.

Commits

  1. refactor(slashing) — phantom removal (contracts + Rust). OffenseType → { RateManipulation, Blacklist }; remove submitPhantomChallenge / NotPhantom / the phantom arm of _verifyPair. Add the s.ok == true guard to rate manipulation — you cannot overcharge on a delivery you declined, so a signed refusal is never rate evidence. This is what makes signing ok:false provably safe. Locked by a new test. Gas snapshot regenerated.
  2. docs(adr) — ADRs + runbook rewritten to two offenses (present-tense canon). adr/_history/ left frozen.
  3. test(e2e) — G-GOV-03 rewrite. The ok:true guard means the old capture (a signed refusal at a raised rate) is now correctly rejected, so the journey captures a real ok:true delivery at the raised rate via a new ClientFixture::capture_delivery_response helper. Validated end-to-end by the anvil e2e (journeys) CI job.
  4. docs — ghost cleanup. Removes "here's what is not an offense" prose left by the ADR pass, and retires decdn_slash_evidence_exposure_total / DecdnSlashEvidenceExposure — a phantom self-detection artifact never emitted by any code (removed from the observability appendix, runbook, Prometheus alert, and Grafana panel).
  5. merge origin/main — integrates feat: origin-aware discovery — advertise origin-held content before pull-through (#1130) #1508/refactor: eliminate on-chain event-log replay across every watcher #1504/build: tighten the release profile to fat LTO and one codegen unit #1509. Also removes feat: origin-aware discovery — advertise origin-held content before pull-through (#1130) #1508's origin-held drop-instead-of-sign block, whose only rationale was avoiding phantom evidence (now inert).
  6. feat(probe) — Phase B: decouple has_blob from the hold budget. With phantom gone the eviction hold is a best-effort availability optimization, not a slash-safety obligation. Budget-exhausted / stake-lane-shed probes now still answer has_blob: true and simply place no hold, so a probe flood can never suppress an honest answer. max_probe_holds == 0 is kept as the operator's explicit opt-out (has_blob: false).

Verification

  • forge build --deny warnings + 795 forge tests; gas snapshot + forge fmt clean.
  • cargo build, clippy, fmt --check clean; 2645 nextest tests pass.
  • Full CI green, including anvil e2e (journeys) and anvil e2e (settlement) and the public API snapshot check.

Deferred follow-up (flagged, not blocking)

With ok:false now inert, the client-pull UpstreamRefused refusal-evidence retention (Kind::Open's stored StreamResponse + evidence()) is dead weight. It is harmless and documented in-code as vestigial; removing it cascades into the e2e refused_stream helper, a client_loopback test, and the public evidence() API, so it is left as a focused standalone cleanup.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Breaking Changes
    • Slashing support now covers only two offenses: rate-manipulation and blacklist violations; phantom challenges/APIs are retired.
    • Probe holds are now best-effort, and rate-manipulation evidence requires successful delivery (ok: true).
  • Documentation
    • Updated protocol, operator guidance/runbooks, and observability docs/alerts to match the revised two-offense model and probe-hold semantics.
  • Tests
    • Updated contract and end-to-end test suites to remove phantom challenge flows and expand real rate-evidence coverage.
  • Chores
    • Refreshed gas-snapshot baselines and monitoring dashboard/alert targets.

alpergundogdu and others added 3 commits July 29, 2026 18:05
On-chain slashing only binds a forkable node when every signature in the
evidence sits on a benefit-taking action (get paid / get selected). Phantom
announcement failed that test: its second half was a signed StreamResponse
{ok:false}, coerced by nothing — a malicious fork just drops the stream — so
the offense only ever slashed honest operators running the reference binary.
"Advertised but didn't serve" is an availability failure and now lives solely
in local reputation (ADR 008).

Contracts:
- OffenseType renumbered to { RateManipulation, Blacklist } (pre-launch, no
  reserved slot).
- Remove submitPhantomChallenge, NotPhantom, and the phantom arm of
  _verifyPair. _verifyPair, SLASH_WINDOW_US, ProbeMsg/StreamMsg, and the
  signature machinery stay — shared with rate manipulation.
- Add the `s.ok == true` guard to rate manipulation: you cannot overcharge on
  a delivery you declined, so a signed refusal is never rate evidence. This is
  what makes signing ok:false provably safe. New test locks it.
- Retarget the commit-reveal/pause vehicle tests to submitRateChallenge; regen
  gas snapshot.

Rust:
- Drop the submitPhantomChallenge binding and the Phantom OffenseType variant;
  move the discriminant docs/constants in lockstep (0=Rate, 1=Blacklist).
- Reword the now-void phantom-slash rationale across the probe/hold/serve
  paths; the 35s probe hold is reframed as an availability feature.
- Rewire the e2e lib (chain.rs) slash inducers to rate manipulation.

Behavior unchanged in this commit beyond the offense removal; the probe-hold
reshape and the e2e G-GOV-03 redesign follow. anvil-e2e gate is red until the
G-GOV-03 rewrite lands next.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Rewrite the ADRs and runbook to reflect two slashing offenses (rate
manipulation, blacklist violation) instead of three. "Advertised but didn't
serve" is documented as a local-reputation matter (ADR 008), not slashable,
and rate manipulation is stated to require a delivery (ok:true). The probe
slash_sig and the 35s probe hold are retained — the hold reframed as an
availability guarantee. No phantom heading was a cross-reference target, so no
anchors break; adr/_history/ is left as a frozen archive.

Touches ADRs 003, 005, 011, 014, 016, 024, 026, 028, 037, README,
architecture, the fraud-detection / observability / operator-key-rotation /
operator-upgrade-path appendices, docs/runbook.md, and CHANGELOG.md.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
The phantom offense is gone, so node A's phantom arc is deleted. Node B's old
capture relied on a signed *refusal* (ok:false) at a raised rate, which the new
`s.ok == true` rate guard correctly rejects — so the journey now captures a real
*delivery* (ok:true) at the raised rate instead.

- Add ClientFixture::capture_delivery_response: reads the daemon's signed
  open-stage StreamResponse{ok:true} for a held blob at a caller-chosen
  timestamp (no payment needed — the open response is signed before any
  voucher), giving the delivery half of a real rate-manipulation pair inside
  the 30s window.
- G-GOV-03 becomes a single-node rate-manipulation journey: probe at the
  configured rate, hot-reload a higher rate, capture the raised-rate delivery,
  then exercise the same real-evidence negatives (out-of-window, forged probe
  sig, forged stream sig, replay), the positive slash, escrow, and the 50/50
  finality split.

Compiles under `--features anvil-e2e` and is clippy-clean; the anvil journey
itself runs in CI.

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

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 05358064-89d4-4088-bd9d-96c7b91ecdc0

📥 Commits

Reviewing files that changed from the base of the PR and between 820a7a2 and 69cf8dc.

📒 Files selected for processing (29)
  • CHANGELOG.md
  • adr/001-network.md
  • adr/003-payments.md
  • adr/005-protocol.md
  • adr/014-on-chain-verification.md
  • adr/028-slashing-appeals.md
  • adr/appendix-blob-cache-eviction.md
  • adr/appendix-observability.md
  • contracts/.gas-snapshot
  • contracts/src/interfaces/ISlashJudge.sol
  • contracts/test/CapacityBond.t.sol
  • contracts/test/InterfaceFreeze.t.sol
  • crates/cache/src/engine.rs
  • crates/cache/src/probe_hold.rs
  • crates/client-pull/src/lib.rs
  • crates/common/src/config/types.rs
  • crates/e2e/src/bindings.rs
  • crates/e2e/tests/g_gov_03_real_evidence.rs
  • crates/node/src/admin.rs
  • crates/node/src/dht/probe_cache.rs
  • crates/node/src/handlers/probe.rs
  • crates/node/src/metrics.rs
  • crates/node/src/node_origin.rs
  • crates/node/src/slash_watcher.rs
  • crates/node/tests/client_loopback.rs
  • crates/node/tests/probe_loopback.rs
  • docs/runbook.md
  • monitoring/grafana-dashboard.json
  • monitoring/prometheus-alerts.yml
🚧 Files skipped from review as they are similar to previous changes (17)
  • crates/e2e/src/bindings.rs
  • crates/node/src/dht/probe_cache.rs
  • crates/node/src/slash_watcher.rs
  • crates/common/src/config/types.rs
  • adr/003-payments.md
  • adr/appendix-observability.md
  • contracts/src/interfaces/ISlashJudge.sol
  • crates/node/src/metrics.rs
  • crates/cache/src/engine.rs
  • adr/028-slashing-appeals.md
  • docs/runbook.md
  • crates/client-pull/src/lib.rs
  • monitoring/grafana-dashboard.json
  • crates/node/tests/probe_loopback.rs
  • crates/node/src/handlers/probe.rs
  • adr/005-protocol.md
  • crates/e2e/tests/g_gov_03_real_evidence.rs

Walkthrough

The change removes phantom-announcement slashing from SlashJudge, leaving rate manipulation and blacklist violation as the two signature-verifiable offenses. It also requires successful higher-rate delivery evidence, changes probe-hold behavior to best-effort availability, rewrites contract and E2E tests, and updates protocol, monitoring, runbook, and ADR documentation.

Changes

Two-offense SlashJudge model

Layer / File(s) Summary
Contract interfaces and verification
contracts/src/SlashJudge.sol, contracts/src/interfaces/ISlashJudge.sol, crates/incentive/src/slash_judge.rs, adr/014-on-chain-verification.md
Removes Phantom and submitPhantomChallenge; rate-manipulation evidence now requires ok == true and a higher stream rate.
Contract and E2E validation
contracts/test/*, crates/e2e/src/*, crates/e2e/tests/*
Updates commit-reveal, ABI, ordinal, signature, timing, replay, and real daemon evidence tests.
Probe availability and holds
crates/cache/*, crates/node/src/handlers/probe.rs, crates/node/tests/probe_loopback.rs, crates/common/src/config/types.rs
Separates blob advertisement from hold placement; exhausted and stake-reserved paths advertise present blobs without consuming holds.
Evidence and refusal semantics
crates/client-pull/src/lib.rs, crates/incentive/src/*, crates/node/src/dht/probe_cache.rs, crates/node/tests/client_loopback.rs
Refusal records are documented as attributable but non-slashing, while rate and blacklist signatures remain on-chain evidence.
Specifications and operations
adr/*, docs/runbook.md, CHANGELOG.md, monitoring/*, crates/node/src/metrics.rs, crates/node/src/slash_watcher.rs
Updates offense counts, persisted ordinals, probe-hold semantics, alerts, dashboards, runbooks, and related ADR references.

Estimated code review effort: 4 (Complex) | ~50 minutes

Sequence Diagram(s)

sequenceDiagram
  participant E2ETest
  participant ClientFixture
  participant Daemon
  participant SlashJudge
  E2ETest->>ClientFixture: capture_delivery_response
  ClientFixture->>Daemon: send StreamRequest
  Daemon-->>ClientFixture: StreamResponse(ok=true, higher rate)
  E2ETest->>SlashJudge: submitRateChallenge(probe, stream, signatures)
  SlashJudge->>SlashJudge: verify signatures, timing, delivery, and rate
  SlashJudge-->>E2ETest: Slashed or validation error
Loading

Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands.

alpergundogdu and others added 2 commits July 29, 2026 18:41
The first ADR pass reframed some deleted phantom sections into prose that
explains what is *not* an offense — a ghost of the removed mechanism that reads
as confusing dead weight to anyone who never knew phantom existed. Delete it and
state only what the protocol does:

- adr/003-payments.md: drop the "Advertised-then-unavailable blob" threat
  subsection (already covered by "Content withholding") and the eviction-hold
  note's "availability/reputation failure" tail.
- adr/005-protocol.md: drop the "…is a local-reputation failure" and "…not
  falsely slashed" asides from the eviction-hold / hold-budget specs.

Also retire `decdn_slash_evidence_exposure_total` / `DecdnSlashEvidenceExposure`
entirely: it was a phantom self-detection signal, never emitted by any Rust
code, and a `has_blob:true` → `ok:false` sequence is now completely benign.
Removed from appendix-observability, the runbook, the Prometheus alert (which
still carried a `slash_risk: phantom_announcement` label), and the Grafana
panel.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
main advanced with #1508 (origin-aware discovery), #1504 (event-log replay
elimination), and #1509. One real conflict + one semantic reconciliation:

- crates/node/src/slash_watcher.rs: #1504 replaced the SlashJudge.Slashed event
  with CapacityBond.SlashRecorded (no offenseType field), so the Phase A test
  fixture edit is obsolete — took main's structure.
- crates/node/src/handlers/client/wire.rs: #1508 added a drop-instead-of-sign
  block for origin-held CacheMiss whose ENTIRE rationale was avoiding
  phantom-announcement evidence. With phantom retired and ok:false inert, that
  defense is unnecessary — removed it so origin-held CacheMiss signs like every
  other refusal. Blacklisted hashes still route to ChainHashDenied via the
  refuses() guard.

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

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Contracts coverage

Line coverage: 89.90% (2510/2792 lines)
▼ -0.02pp vs base (89.92% → 89.90%)
Run: 30494554726

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Coverage report

Total: 80.15% (was 80.21%, ▼ 0.06%) — 54175/67591 lines

File Coverage Lines Δ
crates/cache/src/engine.rs 90.94% 2890/3178 ▲ +0.03%
crates/cache/src/probe_hold.rs 0.00% 0/6 new
crates/client-pull/src/lib.rs 88.64% 1264/1426 ▼ 0.07%
crates/common/src/admin.rs 96.46% 191/198 ● 0.00%
crates/e2e/src/chain.rs 1.64% 21/1280 ▲ +0.02%
crates/e2e/src/client.rs 0.00% 0/414 ● 0.00%
crates/incentive/src/probe_sig.rs 97.46% 230/236 ● 0.00%
crates/incentive/src/stream_sig.rs 97.92% 235/240 ● 0.00%
crates/node/src/admin.rs 95.93% 1201/1252 ● 0.00%
crates/node/src/dht/probe_cache.rs 96.23% 153/159 ● 0.00%
crates/node/src/handlers/client/wire.rs 95.20% 119/125 ▲ +1.26%
crates/node/src/handlers/probe.rs 86.14% 261/303 ▼ 2.16%
crates/node/src/metrics.rs 95.39% 972/1019 ● 0.00%
crates/node/src/node_origin.rs 91.28% 932/1021 ● 0.00%
crates/node/src/slash_watcher.rs 55.66% 246/442 ● 0.00%
History
Commit Total Δ vs base
1b837ad 80.17% ▼ 0.04%
820a7a2 80.18% ▼ 0.03%
69cf8dc (HEAD) 80.15% ▼ 0.06%

With phantom retired, the probe-triggered eviction hold is no longer a
slash-safety obligation — it is a self-interested availability optimization
(keep a just-advertised blob resident for the imminent, paid pull). So the
`has_blob` answer decouples from whether a hold slot is available:

- Budget-exhausted / stake-lane-shed probes now still answer `has_blob: true`
  (the blob is present) and simply place no hold. A probe flood that fills the
  best-effort hold cache can no longer suppress an honest answer — a blob
  evicted before the pull is a reputation miss (ADR 008), never a slash.
- `max_probe_holds == 0` (HoldsDisabled) is kept as the operator's explicit
  opt-out from probe-advertised serving — it still answers `has_blob: false`.
  This is the one knob whose meaning would otherwise vanish.

The hold-not-placed metrics (`probe_hold_unavailable{reason=...}`) still fire;
they now measure forgone holds, not suppressed answers. Docs updated across
probe_hold.rs, metrics.rs, config/types.rs, and ADR 005 §Probe-triggered
eviction hold / §Hold budget. Two probe_loopback tests updated to assert the
new advertise-anyway behavior.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Review follow-up to the phantom-offense retirement. The behaviour change that
rode along with it — probe holds became best-effort, so `BudgetExhausted` and
the stake-lane shed now advertise `has_blob: true` — was correct, but its
justification was wrong and its blast radius under-swept.

The rationale. Five sites justified advertising-without-holding as "a
reputation miss (ADR 008), not a slash". Traced: an evicted-before-pull blob
yields `NotFound` -> `RefusalVerdict::Transient` -> a 30s (peer, hash)
suppression with no `record_outcome`, and `node_origin.rs` says so in as many
words ("without tarring reputation"). Rather than override that deliberate
choice, the claim is struck; every site now states the real cost — one wasted
round trip — and `probe.rs` carries a note so it does not creep back.

Operator-facing docs. `appendix-observability.md` and its four copies (both
Prometheus annotations, the runbook alert list and step 4) still told an
on-call engineer the node answers `has_blob: false` under `exhausted`, and that
"evicted after signing has_blob: true" is unreachable by construction. Both are
now false; the second is the point of the change.

`max_probe_holds = 0`. Six sites newly claimed "every probe answers
has_blob: false". `fold_origin_held` runs after the `HoldsDisabled` arm, so
origin-servable content is still advertised — correctly, since it takes no
hold. Scoped the claim to store-backed content rather than change the code.

Also:

- probe.rs: the stake-lane arm swallowed a cache `Err` in a catch-all with no
  log, while the sibling arm 50 lines below warns on the same condition. Adds
  the `Err` arm; folds three `inspect().ok()` swallows into one logging helper.
- ProbeHoldOutcome: `advertises()` / `hold_placed()` put the has_blob mapping
  back in the type — it had leaked into the caller and the type's own summary
  docs still asserted the retired "only Held" invariant.
- ISlashJudge: the reorder warning named `SlashAppeal`, which is offense-
  agnostic. Replaced with the four sites where the ordinal is actually durable
  (SlashRecord storage, both Slashed events, the evidenceHash preimage keying
  usedEvidenceHash and commitments), and pinned the ordinals in
  InterfaceFreeze.t.sol — selectors are invariant under a reorder.
- ADR 003 §Admission and Priority claimed probe time is the congestion lever
  and that `ok: false` is slash evidence. Both untrue now; congestion moves to
  stream time, which is safe precisely because a refusal is inert.
- ADR 014: `##### Rate manipulation` is a heading again, so the only pair
  offense has a citable anchor; both interface descriptions gained the
  load-bearing `ok == true` predicate.
- Fixtures asserting `offense_type: 2`, a value that no longer names an offense.

Tests. Three probe-hold tests asserted only a counter, so #757 had no
behavioural coverage: a mutation making end-client probes consume reserved
slots left 17/17 green. They now assert `probe_hold_slots_used()` directly and
the mutation fails. Two new tests, each verified to fail against the pre-change
code: a `client_loopback` case pinning that an origin-held serve miss signs a
refusal instead of dropping the stream, and a G-GOV-03 negative feeding a real
daemon-signed `ok: false` to `submitRateChallenge` — isolating the new guard,
and retiring the orphaned `ClientFixture::refused_stream` in the process.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@thiras
thiras merged commit 00139cc into main Jul 29, 2026
25 checks passed
@thiras
thiras deleted the claude/phantom-announcement-blacklist-267b72 branch July 29, 2026 22:09
alpergundogdu added a commit that referenced this pull request Jul 30, 2026
…content (#1130)

The #1130 `origin_held` index is built from `enumerate()` ∪ pins, and neither
http nor s3 enumerates — so for remote origins the index holds *pinned* hashes
only. A non-pinned object sitting in the configured bucket therefore probes
`false` everywhere and `decdn fetch` auto-discovery fails outright, even though
the node could serve it reactively.

Close that gap with a per-probe fallback: when the store and the zero-I/O
`origin_held` index both miss, consult the origin directly with a live
`HEAD`/`HeadObject` (`Origin::size`, no body fetched) and advertise
`has_blob: true` + `total_bytes`. Answers — positive `Present(size)` AND
negative `Absent` — are memoised under one TTL, so a random-hash probe flood
costs at most one origin round-trip per hash per window rather than one per
probe. A slow origin is bounded by a per-probe timeout; on overrun the probe
answers `has_blob: false`, which post-#1512 is never slashable (an unservable
advertisement, or a later `NotFound` on the serve, costs only local reputation).

- `crates/cache/src/origin_probe.rs`: bounded, lazily-expiring TTL memo with an
  injected clock (deterministic unit tests, no new dep, no background sweeper).
- `CacheEngine::origin_probe_size`: refused-guard -> memo -> timeout-bounded live
  `size()` -> memoise; `set_origin_probe_config` installs the knobs once at
  bring-up (restart-required, like `max_probe_holds`).
- probe seam: consulted only when `has_blob` is still false after the index fold.
- config: `cache.origin_probe_ttl_sec` (15), `origin_probe_timeout_ms` (2000),
  `origin_probe_memo_capacity` (4096) across raw + resolved layers, with the
  reload restart-required classification.

Serve-side stream-while-store (the whole-blob TTFB win via a publisher `.obao4`)
is the larger follow-up; this PR is discovery only.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
alpergundogdu added a commit that referenced this pull request Jul 30, 2026
…content (#1130) (#1523)

* refactor: remove the residual authorized-origin content-authorization gate

The `pull_through_require_authorized_origin` gate refused to initiate a backend
pull/warm for a request whose `namespaceId` had no on-chain authorized origin.
But ADR 002 is explicit that the request namespace is a **routing hint, not a
trust anchor** — so using it as a serve-authorization decision was residual: a
husk left after the per-hash on-chain claim layer was removed. ADR 037 already
documented that the gate was namespace-scoped, not operator-scoped (#1368), and
authorized nothing per-content (it admitted a serve for any hash in any namespace
that had *any* registered origin, even one assigned to a different operator).

Remove the gate and everything specific to it: `pull_origin_gate` /
`pull_origin_gate_blocks`, `OriginDirectory::has_origin` (its only consumer),
`ServeRejectReason::UnauthorizedOrigin` and its wire mapping + metric, the
`cache.pull_through_require_authorized_origin` config across all three layers, the
`launch_authorized_origin` e2e fixture, and the three `g_node_08_*` tests that
existed only to exercise the gate.

KEEP the origin directory and `lookup_origins`: that is the legitimate node→node
*routing* mechanism (find which upstream origins to pull from for a namespace),
which ADR 002/022 sanction. Namespace stays routing-only.

Safe by construction: the gate was opt-in and default-off, and the real
protections are untouched — `pull_authorized` (channel ownership, the actual
unpaid-egress guard), the seed-leech caps, `ContentBlacklist`, and BLAKE3
verification. ADRs 037/022/019/011 updated to match.

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

* feat(cache): live http/s3 probe-HEAD discovery for non-pinned origin content (#1130)

The #1130 `origin_held` index is built from `enumerate()` ∪ pins, and neither
http nor s3 enumerates — so for remote origins the index holds *pinned* hashes
only. A non-pinned object sitting in the configured bucket therefore probes
`false` everywhere and `decdn fetch` auto-discovery fails outright, even though
the node could serve it reactively.

Close that gap with a per-probe fallback: when the store and the zero-I/O
`origin_held` index both miss, consult the origin directly with a live
`HEAD`/`HeadObject` (`Origin::size`, no body fetched) and advertise
`has_blob: true` + `total_bytes`. Answers — positive `Present(size)` AND
negative `Absent` — are memoised under one TTL, so a random-hash probe flood
costs at most one origin round-trip per hash per window rather than one per
probe. A slow origin is bounded by a per-probe timeout; on overrun the probe
answers `has_blob: false`, which post-#1512 is never slashable (an unservable
advertisement, or a later `NotFound` on the serve, costs only local reputation).

- `crates/cache/src/origin_probe.rs`: bounded, lazily-expiring TTL memo with an
  injected clock (deterministic unit tests, no new dep, no background sweeper).
- `CacheEngine::origin_probe_size`: refused-guard -> memo -> timeout-bounded live
  `size()` -> memoise; `set_origin_probe_config` installs the knobs once at
  bring-up (restart-required, like `max_probe_holds`).
- probe seam: consulted only when `has_blob` is still false after the index fold.
- config: `cache.origin_probe_ttl_sec` (15), `origin_probe_timeout_ms` (2000),
  `origin_probe_memo_capacity` (4096) across raw + resolved layers, with the
  reload restart-required classification.

Serve-side stream-while-store (the whole-blob TTFB win via a publisher `.obao4`)
is the larger follow-up; this PR is discovery only.

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

* test(node): add origin-probe config fields to the anvil-e2e ResolvedCache literal

The settlement/journeys CI jobs build `decdn-node --features anvil-e2e`, which
compiles `tests/anvil_bringup_shutdown_e2e.rs` — a full `ResolvedCache` literal
the default `cargo nextest` never builds. It was missing the three new
`origin_probe_*` fields (E0063). No logic change.

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

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>
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