Repository navigation
feat(node): gate reactive pull-through on authorized origin (#821) - #917
Conversation
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]>
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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(defaultfalse) and wires it into runtime bring-up and config resolution. - Adds a pull-initiation gate in
ClientHandler::serve_stream, plus a new reject counterdecdn_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.
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]>
Coverage reportTotal: 85.68% (was 85.70%, ▼ 0.01%) — 37189/43403 lines
History
|
Closes #821.
Problem
Prefetch has an opt-in
prefetch.require_authorized_origingate, 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;ContentBlacklistis 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.
Design decisions (all per the issue's recommended defaults)
false— preserves the permissionless cache role; no network-behavior change.ContentBlacklist's job.namespaceId == 0(default-open) counts as authorized — identical to the prefetch gate (reuses the sameOriginDirectory).Change
cache.pull_through_require_authorized_origin(defaultfalse). Whentrue, thecdn/client/v1handler refuses to initiate an upstream pull (and its cache-warming write) for a hash whose namespace has no currently-authorized origin viaOriginAssignment.getOrigins(namespaceId), returning a signedNotFound. Reuses the prefetch gate'sOriginDirectory— namespace /namespaceId == 0default-open / fail-closed-on-RPC-loss semantics included. New metricdecdn_serve_stream_rejected_unauthorized_origin_totaldistinguishes gate refusals from plain misses (both collapse toNotFoundon the wire).Tests
pull_origin_gate_decisionunit test on the gate predicate (unattached → allow; opted-in + no origin → block; opted-in + authorized → allow). The wireNotFoundis indistinguishable from a plain miss, so the predicate is the honest seam to test.cargo clippy --all-targets+cargo nextest(162 node tests) green; all pre-commit hooks (incl. ADR reference hygiene) pass.🤖 Generated with Claude Code