Repository navigation
feat(gateway)!: capabilities only, scoped by namespace, no loopback token - #2910
Merged
Merged
Conversation
…y modes
The gateway holds at most one pending delegate key: GET /_delegate returns
it until a capability claims it. PUT /_capability takes {"capability"}
only, for a key the gateway holds, one capability per pool per key. The
gateway pays every pull with the first registered capability that no
funding stop retired and that sits outside the node expiry margin, and
serves a cache hit with nothing that can pay. /_delegate, /_capability and
/_status need no token and no Origin; a loopback gateway answers nothing
cross-origin. A public gateway answers the same API on its bare host and
pays with capabilities first, then from its own pool when it names a
keystore.
Removes the per-page scope, x-decdn-host selection, per-site delegate
bounds, the pending-key TTL and the psl dependency.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
A gateway, loopback or public, pays only with the capabilities pool owners
register to its in-memory delegate keys: --keystore and --capability are
refused, it opens no pool and keeps no buyer store past its run. The daily
allowance (--allowance-bytes-per-day, --allowance) is gone; the caps of the
capabilities bound what a gateway spends. A public gateway with nothing
that can pay answers 503 with the canonical decdn: URI. The counter
requests_allowance_exhausted is renamed requests_payment_required, /_status
loses its allowance field, and an active pull's payer is {signer, pool}.
The e2e journeys fund their gateways through decdn_e2e::pool_owner.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…te it A loopback gateway writes no token file and reads no x-decdn-token. Every request passes a browser-header check after the Host check: a cross-site page, an Origin that is none of the gateway's own (the bare host and its site origins), and a browser that sends no Sec-Fetch-Site (an Origin, or a Mozilla/ User-Agent) get 403. A client outside a browser passes. On the bare host, a browser's navigation to a bundle or entry redirects to its site; any other request is served there. Site pages may connect to their own origin only. decdn dashboard reads the gateway's /_status with no token. Moves the SDK pins to decdn/sdk-typescript#28 and decdn/sdk-python#15, whose contract suites pass against this gateway. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 10 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. Updated |
A capability registered with a scope that its pool's owner signed (EIP-712 CapabilityScope, domain decdn-capability-scope) pays only for requests that one of the scope's namespace pointers serves: the pointed bundle on <ns>.<host>. Scoped matches pay before unscoped capabilities. The listing, /_status and the dashboard show each capability's namespaces. `decdn pool assign --namespace` signs the scope and prints the whole PUT /_capability body. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`PUT /_capability` requires `scope`: "any" for a capability that pays for any content, or a pool owner's signed namespace scope. A body with no scope is refused, so no capability pays for everything by accident. `decdn pool assign --any-namespace` prints the "any" registration. A loopback gateway selects a scoped capability by the namespace the request's decdn: URI names (`?ns=`, or the site label). A top-level GET navigation passes its browser check from any site, so a link on any page opens loopback content. The gateway_pointer journey funds its gateway with a namespace-scoped capability. Moves the SDK pins to decdn/sdk-typescript@1dab70e and decdn/sdk-python@3b502a9, which send the scope and map 503 to PAYMENT_REQUIRED. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… scope Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
This was referenced Nov 17, 2026
Open
alpergundogdu
added a commit
that referenced
this pull request
Nov 17, 2026
Takes main's capabilities-only gateway (#2910) as the base and re-applies the governance/payment chain split on top of it: every registered capability resolves its PaymentPool contract with capability_pool(), and its pulls, lanes, payer and retirement are keyed by (contract, pool id, signer). A namespace scope is checked under each candidate contract's scope domain before any chain read. Pointer domains and registry reads use the governance chain. The self-funded pool payer that main deleted stays deleted, including this branch's per-pool funding for it. The e2e pool owner helper takes the --governance-*/--pool flags. Co-Authored-By: Claude Opus 5.5 <[email protected]>
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
decdn gatewayis funded only by capabilities, from outside, so a gateway machine holds no secret and no payment state and can be replaced with nothing to tear down. Five commits:GET /_delegatereturns the gateway's one unclaimed key (the same address until a capability claims it).PUT /_capabilitytakes{"capability"}for a key the gateway holds; a key holds one capability per pool. The gateway pays each pull with the first registered capability that no funding stop retired and that is outside the node expiry margin (one redeem interval + 120 s). Per-pagescope,x-decdn-hostselection, per-site delegate bounds and the pending-key TTL are gone. A cache hit is served with nothing that can pay.--keystore/--capabilityare refused on every gateway; a public gateway answers the capability API on its bare host and pays with capabilities alone (503 with thedecdn:URI when nothing can pay).--allowance-bytes-per-day/--allowanceand every charge path are removed; caps bound spend.requests_allowance_exhaustedis renamedrequests_payment_required.Sec-Fetch-Site: cross-site, a foreignOrigin, or a browser withoutSec-Fetch-Sitegets 403, except a top-levelGETnavigation (Sec-Fetch-Mode: navigate+Sec-Fetch-Dest: document), which passes from anywhere so links open loopback content. Clients outside a browser pass. The dashboard reads/_statuswith no token.PUT /_capabilitytakes a"scope": {"namespaces", "signature"}, an EIP-712CapabilityScope(address signer,bytes32 poolId,uint256[] namespaces)(domaindecdn-capability-scope, verifyingContractPaymentPool) that the pool's owner signs. On a public gateway a scoped capability pays only for requests that one of its namespace pointers serves (the pointed bundle on<ns>.<host>);?ns=and<ns>.<hash32>labels select no scoped capability there. On a loopback gateway, the namespace the request'sdecdn:URI names (?ns=, site label) selects it. Scoped matches pay before"any"ones. The listing,/_statusand the dashboard shownamespaces.decdn pool assign --namespace <id>signs the scope and prints the wholePUTbody. A publisher can fund a shared public gateway (e.g.decdn.link) for its own content only; CORS stays open on public.scopeis required:"any"(pays for any content) or a namespace scope. A body without one gets 422, so nothing pays for everything by accident.decdn pool assign --any-namespaceprints the"any"body. Thegateway_pointerjourney funds its gateway with a real namespace-scoped capability.Docs:
adr/appendix-gateway.md(ASD-STE100, new § Scope),adr/appendix-binaries.md,docker/README.decdn.md, CLI help. E2E journeys fund gateways through the newdecdn_e2e::pool_owner.SDK pins
Moves
.github/sdk-typescript.shato decdn/sdk-typescript#28 (1dab70e) and.github/sdk-python.shato decdn/sdk-python#15 (3b502a9). Land those first. Both SDKs register with a required scope ("any"or{namespaces, signature}), map 503 and 402 toPAYMENT_REQUIRED(POOL_UNFUNDEDis gone), and the TypeScript SDK drops its./nodesubpath. New contract tests in both SDKs run only against gateways after v0.3.1, so release-tag runs are unaffected.Verified locally
CARGO_BUILD_WARNINGS=deny cargo clippy --workspace --all-targets --all-features,cargo docgate,check_crate_edges.py: cleancargo nextest run -p decdn-cli -p decdn-common -p decdn-e2e: 1802 passedgateway_public(2),gateway_pointer,gateway_concurrent_pulls,gateway_sdk(public + loopback),gateway_sdk_python(public + loopback): 8/8 passpnpm test/typecheck/lint: cleancargo denyadvisories fails on RUSTSEC-2026-0387 (crypto-bigintvia alloy), RUSTSEC-2026-0441 (pin-utils) and RUSTSEC-2026-0543 (chrono), all present onmain.Behaviour to review
🤖 Generated with Claude Code