Skip to content

feat(node): gate reactive pull-through on authorized origin (#821) - #917

Merged
thiras merged 3 commits into
mainfrom
claude/heuristic-volhard-c7ef1e
Jun 16, 2026
Merged

thiras merged 3 commits into
mainfrom
claude/heuristic-volhard-c7ef1e

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

Closes #821.

Problem

Prefetch has an opt-in prefetch.require_authorized_origin gate, but the reactive cache-miss pull-through path was permissionless with no equivalent knob — a node would relay and warm-cache any hash a paying client requested, even content with no DAO-ratified origin. Operators who (for policy/legal reasons) don't want to be a relay/cache for unclaimed content had no way to opt out. The seed-leech caps bound economic exposure, not content authorization; ContentBlacklist is a reactive denylist, not a proactive default-deny posture.

The ADRs were also inconsistent: ADR 022 §Scope and limits said pull-through was "unaffected by these knobs" while ADR 037 line 72 asserted the gate "composes ... where an operator wants the additional restriction." Never specified.

The triage marked this "not suitable for a coding agent / handler doesn't exist yet" — but #856 has since landed the window-paced pull-through handler and #820 wired the OriginDirectory registry-cache, so the gate's two preconditions are now met and it's implementable end-to-end.

Design decisions (all per the issue's recommended defaults)

  1. Default false — preserves the permissionless cache role; no network-behavior change.
  2. Pull-initiation gate only — a range already held is still served; refusing held blobs stays ContentBlacklist's job.
  3. Small ADR amendment, no new ADR — reconciles ADR 022 §Scope and limits ↔ ADR 037 §Seed-leech caps.
  4. namespaceId == 0 (default-open) counts as authorized — identical to the prefetch gate (reuses the same OriginDirectory).

Change

cache.pull_through_require_authorized_origin (default false). When true, the cdn/client/v1 handler refuses to initiate an upstream pull (and its cache-warming write) for a hash whose namespace has no currently-authorized origin via OriginAssignment.getOrigins(namespaceId), returning a signed NotFound. Reuses the prefetch gate's OriginDirectory — namespace / namespaceId == 0 default-open / fail-closed-on-RPC-loss semantics included. New metric decdn_serve_stream_rejected_unauthorized_origin_total distinguishes gate refusals from plain misses (both collapse to NotFound on the wire).

Tests

  • pull_origin_gate_decision unit test on the gate predicate (unattached → allow; opted-in + no origin → block; opted-in + authorized → allow). The wire NotFound is indistinguishable from a plain miss, so the predicate is the honest seam to test.
  • Metrics test extended to cover the new reject counter.
  • Full workspace cargo clippy --all-targets + cargo nextest (162 node tests) green; all pre-commit hooks (incl. ADR reference hygiene) pass.

🤖 Generated with Claude Code

Prefetch has an opt-in `require_authorized_origin` gate, but the reactive
cache-miss pull-through path was permissionless with no equivalent knob, so
operators could not opt out of relaying/warming unclaimed content. ADR 022
said pull-through was "unaffected by these knobs" while ADR 037 asserted the
gate "composes"; the two were never reconciled.

Add `cache.pull_through_require_authorized_origin` (default `false`, so the
permissionless cache role is unchanged). When enabled, the `cdn/client/v1`
handler refuses to initiate an upstream pull — and the cache-warming write it
would drive — for a hash whose namespace has no currently-authorized origin,
returning a signed `NotFound`. It reuses the prefetch gate's `OriginDirectory`
(namespace / `namespaceId == 0` default-open / fail-closed-on-RPC semantics),
and is a pull-*initiation* gate only: a range already held is still served —
refusing held content stays `ContentBlacklist`'s job.

Reconcile ADR 022 §Scope and limits and ADR 037 §Seed-leech caps accordingly.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings June 15, 2026 15:23

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request implements an opt-in content-authorization gate on the reactive cache-miss pull-through path (pull_through_require_authorized_origin). When enabled, the node refuses to initiate an upstream pull (and its cache-warming write) for a hash whose namespace has no currently-authorized origin, returning NotFound to the client. This includes updates to ADR documentation, configuration parsing, client handler logic, metrics tracking, and associated tests. I have no feedback to provide as there are no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

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

Adds an opt-in operator policy gate to the node’s reactive cache-miss pull-through path so that, when enabled, the cdn/client/v1 handler will refuse to initiate an upstream pull (and cache-warming write) for hashes whose namespace has no currently-authorized origin—while preserving today’s permissionless default behavior.

Changes:

  • Introduces cache.pull_through_require_authorized_origin (default false) and wires it into runtime bring-up and config resolution.
  • Adds a pull-initiation gate in ClientHandler::serve_stream, plus a new reject counter decdn_serve_stream_rejected_unauthorized_origin_total.
  • Reconciles ADR 022/037 language to explicitly describe the new opt-in reactive-path authorization gate and its relationship to seed-leech caps.

Reviewed changes

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

Show a summary per file
File Description
crates/node/tests/sighup_signal.rs Updates test resolved config to include the new cache knob default.
crates/node/src/runtime/reload.rs Ensures reload-state test fixtures include the new resolved cache field.
crates/node/src/runtime/mod.rs Wires the gate into runtime bring-up by attaching the origin directory to the client handler when enabled.
crates/node/src/metrics.rs Adds a new serve-stream reject counter and extends metrics tests accordingly.
crates/node/src/handlers/client.rs Implements the reactive pull-through origin-authorization gate, new reject reason, unit test seam, and metric bump.
crates/common/src/config/types.rs Adds the new TOML config field and documents semantics/fail-closed behavior.
crates/common/src/config/resolved.rs Adds the resolved boolean field and documents runtime semantics.
crates/common/src/config/mod.rs Resolves the new cache config field with default false.
crates/cli/tests/config_validate.rs Updates config validation test fixture to include the new resolved field.
adr/037-regional-proxy-warming.md Clarifies seed-leech caps vs. content authorization, and specifies the new opt-in gate.
adr/022-content-discovery.md Updates scope/limits text to reflect that reactive pull-through is permissionless by default but can be opt-in gated (per ADR 037).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/common/src/config/types.rs Resolved
Comment thread crates/common/src/config/resolved.rs Resolved
alpergundogdu and others added 2 commits June 15, 2026 17:06
Resolve config-schema conflicts: main wrapped the seed-leech cache knobs in
the Bytes/Percent newtypes; keep those and carry the new
pull_through_require_authorized_origin field (#821) alongside them.
…pull-through (#821)

Per PR review: the gate is attached only when node_to_node_pull_through_enabled
is set, so document that dependency on both the TOML and resolved config fields.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@github-actions

Copy link
Copy Markdown

Coverage report

Total: 85.68% (was 85.70%, ▼ 0.01%) — 37189/43403 lines

File Coverage Lines Δ
crates/common/src/config/mod.rs 96.82% 6083/6283 ● 0.00%
crates/common/src/config/resolved.rs 100.00% 35/35 ● 0.00%
crates/node/src/handlers/client.rs 77.30% 848/1097 ▼ 0.12%
crates/node/src/metrics.rs 82.97% 794/957 ▲ +0.09%
crates/node/src/runtime/mod.rs 48.95% 888/1814 ▼ 0.05%
crates/node/src/runtime/reload.rs 95.23% 1456/1529 ▲ +0.01%
History
Commit Total Δ vs base
809b9aa (HEAD) 85.68% ▼ 0.01%

@thiras
thiras merged commit 416db49 into main Jun 16, 2026
20 checks passed
@thiras
thiras deleted the claude/heuristic-volhard-c7ef1e branch June 16, 2026 19:58
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.

No require_authorized_origin equivalent on the cache-miss pull-through path: operators cannot opt out of relaying/warming unclaimed content

3 participants