Skip to content

feat!: origins publish all three objects; delete the whole-blob origin fallback - #2922

Merged
thiras merged 6 commits into
mainfrom
claude/github-issue-2913-7f1bc3
Nov 22, 2026
Merged

thiras merged 6 commits into
mainfrom
claude/github-issue-2913-7f1bc3

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Step 1 of #2913 ("Make the outboard required at origins", rule 5).

What changes

  • An origin publishes {H}, {H}.obao4 and {H}.sizeproof. All three are required, and decdn origin import writes all three.

  • Before the first voucher, the node reads one object per hash, {H}.sizeproof, and memoises it. The object states the size and proves it. CacheEngine::origin_presence gives Present(size) / Absent / Fault. Dispatch, the origin-only policy gate, DHT publish and the origin rescan all use it.

  • A miss whose origin is Present always takes the own-origin two-leg serve (serve_via_backend_origin). A missing or broken outboard or data object, or an origin that ignores Range, is an origin fault. The node refuses the stream with a StreamError (InternalError) before any ChunkData (serve_leg::refuse_fill_fault).

  • Deleted:

    • the HEAD probes of the data object and the outboard;
    • origin_outboard_published and its memo;
    • origin_range_serviceable and the post-admission degrade memo;
    • the buffered local-populate tier (local_populate / try_local_populate);
    • the fs/http/s3 whole-blob fetch and the streamed import;
    • CacheEngine::get;
    • origin decompression;
    • buffered_max_bytes.

    The buffered node-to-node pull (populate + the Peer origin) stays; later steps of Simplify the stream open to five rules (follow-up to #2912) #2913 remove it.

  • decdn_cache_hits_total and decdn_cache_bytes_returned_total had no remaining caller, so they are deleted. decdn node top and decdn dashboard read decdn_serve_cache_{hit,partial_hit,miss}_total and decdn_bytes_served_total instead. Partial hits count as hits.

  • Tests:

    • decdn-e2e no longer enables the cache crate's test-util. Its node fixture writes all three origin objects. A journey that needs a warm store calls NodeFixture::warm, which does a paid fetch through the daemon.
    • The node tests are reworked to the new rule. The fallback and degrade tests are deleted or rewritten as fault tests.
  • ADR 005, 037 (the "Fallback is always correct" bullet is gone) and 038, architecture.md, appendix-observability.md, the runbook and CLAUDE.md are updated.

Breaking

  • The config keys cache.origin.decompress and cache.origin_retry.buffered_max_bytes are rejected.
  • An origin without {H}.obao4 and {H}.sizeproof no longer serves. Re-run decdn origin import.
  • decdn node top --json keys changed: serve_cache_hits_total, serve_cache_misses_total, serve_cache_hit_rate, bytes_served_total.
  • The two deleted metrics are still read by panels in the decdn/devops monitoring dashboards. Those panels need a matching change.

Verification

  • cargo fmt --check, cargo clippy --workspace --all-targets --all-features -D warnings, and the cargo doc gate with warnings denied: clean.
  • cargo nextest run --workspace: 6041 passed (1 flaky on retry: a_pull_larger_than_the_working_deposit_tops_up_once_and_completes).
  • cargo nextest run -p decdn-e2e --features anvil-e2e: 134 of 141 passed on the full run. The 7 failures were journeys that assumed a pre-warmed store. They now warm through NodeFixture::warm, and those binaries pass 16/16 on re-run.
  • Dashboard test, typecheck and lint: pass.

Open follow-up

node_origin/mod.rs treats an assigned origin's discovery NotFound as a cold pull-through target. An origin node that holds the blob now answers ok:true from its size proof, so that path now runs only when the origin node's size-proof read faults. Left as is for a later #2913 step.

🤖 Generated with Claude Code

…n fallback

Step 1 of #2913 (rule 5). An origin publishes {H}, {H}.obao4 and
{H}.sizeproof, and all three are required. One memoised {H}.sizeproof read
gives the node presence and a proven size before the first voucher
(CacheEngine::origin_presence). A missing or broken object is an origin
fault: the node refuses the stream with a StreamError before any ChunkData.

Deleted: the data-object and outboard HEAD probes, origin_outboard_published
and its memo, origin_range_serviceable and the degrade memo, the buffered
local populate tier (local_populate), the fs/http/s3 whole-blob fetch and
streamed import, CacheEngine::get, decompression (cache.origin.decompress)
and cache.origin_retry.buffered_max_bytes, and the dead
decdn_cache_hits_total / decdn_cache_bytes_returned_total counters.
decdn node top and decdn dashboard read the serve-path counters instead.

Breaking: config keys cache.origin.decompress and
cache.origin_retry.buffered_max_bytes are rejected; node top JSON keys
changed; origins without {H}.obao4 / {H}.sizeproof no longer serve.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-code-quality

github-code-quality Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main ff7868f claude/github-issue-... 7f687dc +/-
77% 77% 0%
View coverage of the 10 most impacted files.
File main ff7868f claude/github-issue-... 7f687dc +/-
crates/cache/src/origin/mod.rs 60% 47% -13%
crates/node/src/dht/publish.rs 79% 77% -2%
crates/node/src...ent/dispatch.rs 83% 82% -1%
crates/node/src...lient/window.rs 75% 74% -1%
crates/client/src/lib.rs 89% 89% 0%
crates/cache/src/engine.rs 91% 92% +1%
crates/cache/src/origin/fs.rs 74% 76% +2%
crates/cache/src/retry.rs 89% 97% +8%
crates/node/src.../client/fill.rs 72% 82% +10%
crates/cache/src/origin/s3.rs 76% 90% +14%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 22, 2026 02:00 UTC

@yigitdot yigitdot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: head de40683

Important

1. An HTTP 403 on {H}.sizeproof reads as Absent, not Fault

  • crates/cache/src/origin/http.rs:352: missing_or_fault returns Ok(()) on a 403. So fetch_size_proof returns Ok(None), and the hash is Absent.
  • At the base, a 403 on the HEAD of the data object was Permanent, which is a Fault. S3 still faults on AccessDenied, so the adapters disagree.
  • Scenario: credentials are revoked, and the origin answers 403 for every key. The origin-only gate then signs ForeignNamespaceDeclined. The negative TTL memoises Absent. The rescan and the DHT publish drop the content of the operator, and no probe-failure metric counts it.
  • These docs still say a permission decline is an Err: engine.rs:1915-1918, engine.rs:2337-2340, origin/mod.rs:158.
  • Suggested fix: make a 403 on .sizeproof Permanent. The outboard and data reads can keep 403-as-missing.

2. The payer is charged before the node reads the origin, and a range fault never reaches the presence memo

  • Step (4b) origin_range_usable refused the stream before the legs started. This PR deletes it.
  • At head, serve_leg.rs runs acquire_credit_for_leg (which commits the first proof) before the first next_frame_chunks. The node finds a missing {H}.obao4 or {H} only after that. The stream then ends with InternalError and delivered == 0, so the payer pays for credit and gets no bytes.
  • The fault does not reach the presence memo. Present stays memoised under the positive TTL, and the DHT keeps announcing the hash. Each new open repeats ok, pay, refuse.
  • node_pull_through_error does not bump on this path.
  • Options: read the outboard before the node commits credit. Or, on a fault before ChunkData, memoise a Fault and do not count the credit.

3. Retry and the circuit breaker do not cover fs/http/s3 origins

  • run_with_retry_classified and the breakers run only in pull_through (engine.rs:5313). It calls Origin::fetch, and that defaults to NotFound for fs/http/s3.
  • So one S3 503 or one connection reset refuses a paid stream. One 503 on .sizeproof memoises a Fault for the full fault TTL.
  • The cache.origin_retry and cache.circuit_breaker docs (common/src/config/types.rs:395-455) still describe per-origin retry for operator origins.
  • Either wrap the size-proof, outboard and range reads in the retry and breaker, or document that they cover only peer origins.

4. Tests deleted for behaviour that still exists

  • Redirect (SSRF) refusal (302, 301, 307, and a redirect to an internal address). Policy::none() at http.rs:129 has no test now.
  • HTTP headers timeout and chunk-idle timeout (http.rs:322, http.rs:482).
  • There is no node test for a missing data object (a 404 on {H}). BrokenObject covers only the outboard.
  • There is no test for a fault after the first ChunkData (the delivered > 0 branch, serve_leg.rs:286).
  • No test checks that cache.origin.decompress or cache.origin_retry.buffered_max_bytes is rejected. deny_unknown_fields rejects them, but no test asserts it.

5. ADR text

  • ADR 038:45 still describes the deleted fallback (an import that materializes a missing {H}.obao4, "both origin routes"). It contradicts lines 85 and 105 of the same ADR.
  • ADR 005:99 says a missing or broken object gives a StreamError. The next sentence says a missing {H}.sizeproof gives NotFound. Restrict the first sentence to {H} and {H}.obao4.

Suggestions

  • engine.rs:2129: a blob with no .sizeproof leaves the announce set and nothing reports it. Enumeration proves {H} exists, so this is a broken publish. At least warn and count it.
  • CacheEngine::origin_fetch_outboard_bytes and outboard_with_origin (engine.rs:3762-3784) have only test callers now. The tokio-util io feature (Cargo.toml:219-223) has no user.
  • Stale "HEAD/HeadObject" wording:
    • common/src/config/resolved.rs:294,306
    • common/src/config/types.rs:484-507
    • config-types/src/defaults.rs:18,42
    • cli/src/commands/config.rs:1086,1089
    • engine.rs:3022,3027,3776,4980
  • appendix-observability.md:94,139 names a range probe and pull_through_range. Neither exists now.
  • ADR 037:80: drop "exactly as for whole-blob pulls".
  • dispatch.rs:822 cites ADR 005 § Bounded byte ranges. The rule is in § Pull-through.
  • dispatch.rs:818-824: this fault branch (Present, but size_proof gives None) logs nothing.
  • e2e/tests/cli_fetch_multi_source.rs:17,109 says the holders are pre-warmed. Now they serve cold from their own origin.
  • NodeFixture::warm opens one pool per hash. The refuse_fill_fault doc should also list ClientPaymentFault, which passes through too.
  • STE: ADR 037:76, ADR 037:79 and ADR 038:86 each hold two ideas per sentence. dispatch.rs:650 is 102 columns.

Good

  • The deletion is clean: no deleted identifier is left in the tree.
  • The presence memo is sound. It has a TTL for each state, a bound, and single-flight. refuses() runs before the memo.
  • The node verifies every size proof before it trusts it, and all three backends cap the object size. size_proof_tests.rs is thorough.
  • The metric consumers (node top, dashboard, doctor, status) agree.

… 403 sizeproof is a fault

Review follow-up on #2922.

- An HTTP 403 on {H}.sizeproof is a permanent fault, not an absence, so a
  refused origin no longer reads as "not held". The outboard and data
  reads keep reading a 403 as a missing object.
- Every size-proof, outboard and range-window read runs under the origin's
  circuit breaker and cache.origin_retry (ReadGuard). An exhausted transient
  fault stays transient.
- A ranged read that faults after a Present answer memoises a Fault, so the
  next open refuses at open instead of taking a voucher and refusing. The
  own-origin serve counts the refusal in node_pull_through_errors.
- A rescan counts and warns on listed objects with no {H}.sizeproof.
- origin_fetch_outboard_bytes is test-util only; tokio-util drops the io
  feature.
- Tests: HTTP redirect (SSRF) refusal and header/idle timeouts, 403 on the
  size proof, ReadGuard, range-fault memo, missing data object and a fault
  after the first ChunkData at the node, removed config keys rejected.
- ADR 005/037/038, observability appendix, runbook and config docs match.

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

Read deadline expiry fails to record breaker failures, allowing repeated stalled reads, and the self dev-dependency re-enables S3, defeating the store-only feature-isolation check.

2 open issues
What changed in this PR

Implements step 1 of #2913 by requiring three origin objects per blob and removing whole-blob origin fallback. The changes align node serving, test fixtures, configuration, and monitoring with range-based origin delivery.

Changes:

  • Use memoised size proofs for origin presence and stream origin data through verified ranges.
  • Remove origin decompression and buffered-fetch configuration; update fixtures to publish complete origins or explicitly warm caches.
  • Switch CLI and dashboard reporting to serve-path cache hits and wire bytes served.
File Description
docs/​runbook.md Explain size-proof rescan failures and recovery.
crates/​node/​tests/​support/​mod.rs Seed complete origins and provide cache helpers.
crates/​node/​tests/​partial_serve.rs Remove obsolete origin-probe mocks.
crates/​node/​tests/​dht_bootstrap.rs Adapt fixtures to size-proof discovery.
crates/​node/​src/​runtime/​tests.rs Remove decompression configuration from tests.
crates/​node/​src/​runtime/​reload.rs Remove obsolete decompression references.
crates/​node/​src/​runtime/​mod.rs Remove local-populate and decompression wiring.
crates/​node/​src/​node_origin/​pull_leg/​local_pull_leg_tests.rs Adapt local-pull fixtures and assertions.
crates/​node/​src/​node_origin/​mod.rs Simplify origin-fetch outcome matching.
crates/​node/​src/​node_origin/​backend_source/​tests.rs Adapt backend-source fixtures.
crates/​node/​src/​node_origin/​backend_source.rs Propagate range-origin faults directly.
crates/​node/​src/​metrics/​tests.rs Update metric registration and accounting tests.
crates/​node/​src/​metrics.rs Document current serve and origin metrics.
crates/​node/​src/​handlers/​client/​window.rs Remove serviceability probes and meter fill refusals.
crates/​node/​src/​handlers/​client/​serve_leg.rs Refuse fill faults before the first chunk.
crates/​node/​src/​handlers/​client/​mod.rs Remove local-populate dependency fields.
crates/​node/​src/​handlers/​client/​fill.rs Delete buffered local-origin fill helpers.
crates/​node/​src/​dht/​publish.rs Use size-proof origin presence for publishing.
crates/​node/​src/​admin/​tests.rs Seed eviction fixtures directly.
crates/​node/​Cargo.toml Enable cache helpers for tests.
crates/​e2e/​tests/​origin_stream_while_store.rs Replace fallback expectations with origin faults.
crates/​e2e/​tests/​g_node_04_blacklist_compliance.rs Warm stores before compliance scenarios.
crates/​e2e/​tests/​cli_fetch_multi_source.rs Clarify origin-backed source fixtures in comments.
crates/​e2e/​tests/​cli_bundle_pull_range_dedup.rs Warm stores before cache-hit assertions.
crates/​e2e/​src/​node.rs Publish complete origins and add paid warming.
crates/​e2e/​src/​client.rs Update first-frame timeout documentation.
crates/​config-types/​src/​retry/​tests.rs Remove buffered-budget assertions.
crates/​config-types/​src/​retry.rs Remove buffered-fetch configuration.
crates/​config-types/​src/​lib.rs Remove decompression and buffer-default exports.
crates/​config-types/​src/​defaults.rs Describe size-proof probe defaults.
crates/​config-types/​src/​decompress/​tests.rs Delete decompression-policy tests.
crates/​config-types/​src/​decompress.rs Delete decompression-policy type.
crates/​config-types/​README.md Update configuration vocabulary.
crates/​common/​src/​lib.rs Remove decompression from crate documentation.
crates/​common/​src/​config/​types.rs Remove obsolete fields and document origin requirements.
crates/​common/​src/​config/​resolved.rs Remove resolved decompression settings.
crates/​common/​src/​config/​mod.rs Remove obsolete configuration resolution and validation.
crates/​common/​src/​cli/​node.rs Update node top metric descriptions.
crates/​common/​src/​admin.rs Update configuration-type documentation.
crates/​cli/​tests/​origin_import.rs Verify imports through range reads.
crates/​cli/​src/​commands/​node_top/​snapshot_tests.rs Test serve metrics and partial-hit aggregation.
crates/​cli/​src/​commands/​node_top/​render_tests.rs Update displayed metric expectations.
crates/​cli/​src/​commands/​node_top/​parse_tests.rs Update metric parsing fixtures.
crates/​cli/​src/​commands/​node_top/​json_tests.rs Test renamed JSON fields.
crates/​cli/​src/​commands/​node_top/​e2e_tests.rs Exercise serve metrics through real scraping.
crates/​cli/​src/​commands/​node_top.rs Report serve-path hits and wire egress.
crates/​cli/​src/​commands/​doctor/​live/​tests.rs Update metric prefix-collision fixture.
crates/​cli/​src/​commands/​doctor/​live.rs Refresh parser documentation.
crates/​cli/​src/​commands/​dashboard/​status/​tests.rs Update dashboard metric fixtures.
crates/​cli/​src/​commands/​dashboard/​status.rs Clarify hit-rate documentation.
crates/​cli/​src/​commands/​dashboard/​sources.rs Calculate hit rate from serve counters.
crates/​cli/​src/​commands/​config.rs Remove obsolete template settings.
crates/​cli/​dashboard/​src/​fixtures/​dashboard-full.json Rename dashboard metric fields.
crates/​cli/​dashboard/​src/​fixtures/​dashboard-failing.json Rename failure-fixture metric fields.
crates/​cli/​dashboard/​src/​contract.test.ts Check updated dashboard metric keys.
crates/​cli/​dashboard/​src/​components/​NodeHealth.tsx Explain serve-based dashboard values.
crates/​cli/​dashboard/​src/​components/​NodeHealth.test.ts Update component metric fixtures.
crates/​cli/​dashboard/​src/​api.ts Align metric types with backend output.
crates/​cache/​tests/​util/​mod.rs Provide direct store-seeding helpers.
crates/​cache/​tests/​present_ranges.rs Use directly seeded cache fixtures.
crates/​cache/​tests/​origin_runtime_keepalive.rs Exercise range, outboard, and size-proof reads.
crates/​cache/​tests/​held_corruption.rs Replace whole-fetch fixtures with direct seeding.
crates/​cache/​tests/​admit_bao.rs Read admitted blobs through test helpers.
crates/​cache/​src/​retry/​tests.rs Add read-guard retry and breaker tests.
crates/​cache/​src/​outboard_cache.rs Remove serviceability-probe documentation.
crates/​cache/​src/​origin/​tests.rs Delete obsolete fetch-collection tests.
crates/​cache/​src/​origin/​s3/​tests.rs Remove streamed-body error tests.
crates/​cache/​src/​origin/​decompress/​tests.rs Delete decoder-policy tests.
crates/​cache/​src/​origin/​decompress.rs Delete origin decompression implementation.
crates/​cache/​src/​origin_range/​tests.rs Supply read guards in cursor tests.
crates/​cache/​src/​origin_range.rs Guard range reads and expose terminal fault hooks.
crates/​cache/​src/​origin_probe.rs Describe size-proof-based presence memoisation.
crates/​cache/​src/​metrics.rs Remove unused counters and clarify accounting.
crates/​cache/​src/​lib.rs Update cache entry points and exports.
crates/​cache/​src/​error/​tests.rs Remove decompression-error tests.
crates/​cache/​src/​error.rs Remove decoder errors and update fault descriptions.
crates/​cache/​Cargo.toml Remove compression dependencies and add test helpers.
CLAUDE.md Update configuration vocabulary documentation.
Cargo.toml Remove compression dependency and unused streaming feature.
Cargo.lock Reflect dependency removals and test dependency changes.
adr/​architecture.md Describe unpaid size-proof reads.
adr/​appendix-binaries.md Remove decompression-type reference.
adr/​038-bao-verified-range-streaming.md Require origin sidecars and remove fallback descriptions.
adr/​005-protocol.md Specify size-proof discovery and origin fault handling.

Review effort: Balanced

Comment thread crates/cache/Cargo.toml Resolved
Comment thread crates/cache/src/origin_range.rs Resolved
…only test build store-only

Review follow-up on #2922.

- ReadGuard::run takes the read deadline. A read still running at the
  deadline is cut off, recorded as an unavailable origin, and answers
  ReadFailure::Deadline, so an origin that stalls trips its breaker as one
  that errors does. The outboard and range-window budgets
  (guarded_origin_read) and the presence walk hand their deadline to the
  guard instead of wrapping it, so the overall read budget is unchanged.
- The decdn-cache self dev-dependency sets default-features = false, so
  cargo clippy -p decdn-cache --no-default-features --all-targets checks
  the store-only build instead of turning s3 back on.
…et; meter range faults in the cache

Second review pass on #2922.

- The {H}.sizeproof presence read runs once under the origin's breaker,
  with no retry: the presence memo is its retry, and a fast fault leaves
  the walk its time for the next origin.
- ReadGuard takes a Deadline that says whether an overrun is the origin's
  fault. The presence walk charges only the first origin; a later origin
  gets only the time the earlier ones left. A deadline already past reads
  nothing. A Deadline carries the last error, and the walk keeps an
  earlier origin's cause.
- decdn_cache_origin_range_faults_total counts the ranged reads that fault
  after a present size proof. The window.rs bump of
  node_pull_through_errors is gone, so store and process faults no longer
  read as origin faults.
- Tests: a stuck outboard read trips the breaker and counts a timeout and
  a range fault; a window that fails once is retried; a later origin cut
  off by the walk ceiling is not charged; deadline and last-error cases on
  ReadGuard; a pinned-only hash is not counted as unpublished; a 403 on
  range data reads as missing. Range tests use a zero-backoff retry.
- Docs: fault definitions, origin_probe_timeout_ms, the retry and breaker
  scope, metric docs, ADR 005/037, the observability appendix and the
  runbook match the code.
@yigitdot

Copy link
Copy Markdown
Contributor

Second review pass, fixed in e35741f:

  • Presence walk deadline: the {H}.sizeproof read runs once under the breaker (no retry). Only the first origin is charged on a walk overrun, so a healthy fallback origin no longer trips its breaker. A deadline keeps the last error and any earlier origin cause.
  • Metering: the new decdn_cache_origin_range_faults_total counts ranged origin faults. The window.rs bump of node_pull_through_errors is removed, so store and process faults no longer count as origin faults.
  • Tests: the breaker trips on a stuck outboard read, a window that fails once is retried, a later origin is not charged, plus ReadGuard deadline cases and a 403 on range data.
  • Docs: the fault definitions, origin_probe_timeout_ms, the retry and breaker scope, ADR 005/037, the observability appendix and the runbook match the code.

Local: fmt, clippy (workspace and store-only), doc gate, 6074 tests pass.

…913-7f1bc3

# Conflicts:
#	crates/node/src/handlers/client/dispatch.rs
@thiras
thiras enabled auto-merge (squash) November 22, 2026 01:53
@thiras
thiras merged commit de9b90e into main Nov 22, 2026
39 checks passed
@thiras
thiras deleted the claude/github-issue-2913-7f1bc3 branch November 22, 2026 02:05
yigitdot added a commit that referenced this pull request Nov 22, 2026
#2922 made the own-origin fill a ranged drive leg, so the engine cap on the whole-blob fetch no longer bounded it: own origin enforced no max_blob_size at all. The previous commit declined any own-origin blob over the cap, which would make a blob larger than its origin node's cap unservable network-wide while relays with the same cap serve its ranges.

max_blob_size now bounds the bytes of one blob the node holds for both sources:

- BackendSource reports the engine cap, so drive meters the own-origin leg and ends with BlobTooLarge before a leg past the cap.
- The local leg records that stop as FillError::held_bytes_cap, not a local fault, so the serve leg stops with a mid-stream Declined.
- serve_via_backend_origin runs the peer path's pre-commit held-bytes gate (held_cap_reached), in place of the catalog-size gate.
- stop_at_held_cap falls back to the engine cap on an origin-only node.

ADR 005 states one bytes-held rule for both sources; ADR 039 and the observability rows follow.

Closes #2934
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.

4 participants