Repository navigation
Description
Summary
Add a decdn: URI scheme so one string names a blob, a whole bundle, or one file inside a bundle, with an optional namespace hint. Parsing lives in decdn-client; a new decdn get <URI> command routes a URI to the blob or bundle pull path and replaces decdn fetch and decdn bundle pull.
The URI is client-side syntax only. It resolves to what the wire already carries (a BLAKE3 hash plus the namespace_id routing hint), so nodes and the protocol do not change.
Grammar
decdn:<hash>[/<path>][?ns=<id>]
| URI | Meaning | decdn get runs |
|---|---|---|
decdn:<hash> |
the raw blob | the blob fetch |
decdn:<hash>/ |
the whole bundle whose manifest has this hash | the bundle pull |
decdn:<hash>/a/b.txt |
one entry of that bundle | the bundle pull, that entry only |
any of the above ?ns=42 |
same, with the namespace routing hint | same |
<hash>: 64 lowercase hex characters, bare. Nob3:or0xprefix: a:would make the form ambiguous, and one spelling keeps URIs comparable. Parsing accepts uppercase hex and emits lowercase.- No
//. The URI has no authority part (likemagnet:/urn:). This sidesteps host rules: a 64-character hex hash exceeds the 63-character DNS label limit, and ab3:prefix would read as a port. - The trailing
/marks a bundle. The URI author knows whether they published a bundle, so the URI states it. The client never sniffs content to decide: a bundle manifest is plain JSON (adr/appendix-bundles.md) with nothing decdn-specific in its bytes, so another tool's JSON can look like one. <path>is the manifest entry's relative POSIX path, percent-encoded per segment (RFC 3986pchar). It matches exactly one manifestpath, literally.nsis the namespace id in decimal. Absent means no namespace (namespace 0, ADR 002).ns=0is rejected, the same as--namespace 0today. The hash is the identity and the namespace is only a routing hint (ADR 002), so it sits in the query, not the path.- Unknown query keys are an error (pre-mainnet: no forward-compat leniency).
Misuse is cheap and self-explaining
decdn:<hash>/on a non-manifest blob: the manifest parse fails with an error that says to drop the trailing/to fetch the raw blob.decdn:<hash>on a bundle manifest: returns the manifest JSON bytes. That is also how to fetch a raw manifest on purpose.
Implementation notes (from investigation)
Parser in decdn-client. A small public type, for example:
pub struct DecdnUri {
pub hash: [u8; 32],
pub target: UriTarget, // Blob | Bundle | BundleEntry(String)
pub namespace: Option<u64>,
}
impl FromStr for DecdnUri { .. }
impl Display for DecdnUri { .. } // canonical form; round-trips- Parse by hand: strip
decdn:, split at the first?, then at the first/. Theurlcrate treatsdecdn:<hash>/a/bas an opaque-path URL (path_segments()returnsNone), so it adds nothing here. - Reuse the hex parsing behind
decdn_client::bundle::parse_hash(crates/client/src/bundle.rs:72) but without its0x/b3:prefixes. - Validate the decoded entry path with the same rules the manifest applies (relative, no
.., no root, UTF-8). nsparsing must matchparse_fetch_namespace_id(crates/common/src/cli/fetch.rs:365):u64, non-zero. The wire field is[u8; 32](crates/protocol/src/client.rs:205) and the on-chain id isuint256; the URI inherits the CLI's existingu64bound.- Being public, the new type updates the
decdn-clientpublic_apisnapshot.
Single-entry bundle pull. bundle pull has no exact-path selector today. It has --include globs (EntryFilter, crates/cli/src/commands/bundle_pull.rs:73). A URI path must match literally, and a real filename can contain glob metacharacters ([, ], *, ?, {). So the URI route either escapes the path with globset::escape before handing it to --include, or adds an exact-path filter to EntryFilter. The escape is enough.
CLI: decdn get <URI> -o <OUT>. A new top-level command takes a URI and dispatches on its target:
Blobruns the blob fetch.-ois the destination file, or-for stdout.Bundleruns the bundle pull over every entry.-ois the output directory.BundleEntry(path)runs the bundle pull with an include filter of exactly that path.-ois the output directory, and the file lands at<OUT>/<path>, the same as a full pull.- The URI's
nsbecomes the namespace hint.gethas no--namespaceflag: the URI is the single source. getflattens the sharedClientFetchArgs(crates/common/src/cli/fetch.rs), so discovery, chain, pool and capability flags work as they do today.getcalls the same library paths (BundlePullerand the fetch driver), so it adds no new pull behavior.
get replaces decdn fetch and decdn bundle pull. Both commands, their --hash flags, FetchArgs, BundlePullArgs and the bundle subcommand group are deleted in the same PR. No aliases (pre-mainnet: no compatibility shims). Every capability carries over:
| Today | Under get |
|---|---|
fetch --hash H -o file |
get decdn:H -o file |
fetch --hash H -o - (stdout) |
get decdn:H -o - |
bundle pull --hash H -o dir |
get decdn:H/ -o dir |
--namespace N |
?ns=N in the URI |
--include, --exclude, --select, --dry-run, --json |
same flags on get |
--jobs, --max-lane-streams, --overwrite |
same flags on get |
bundle pull -i <manifest file> |
dropped: origin import publishes the manifest, so pull it by hash |
Flag rules:
- The bundle-only flags (
--include,--exclude,--select,--dry-run,--json,--jobs,--max-lane-streams,--overwrite) are an error on a blob URI (decdn:<hash>). --include,--excludeand--selectare an error on an entry URI (decdn:<hash>/a/b.txt): the URI already selects one entry.-o -(stdout) is accepted only for a blob URI.
Callers to update.
decdn: e2e testscli_fetch_recovers_one_holder,cli_fetch_multi_source,cli_fetch_resume,cli_fetch_topup,cli_fetch_stdout,cli_bundle_pull_pool_id,cli_bundle_pull_multi_source,cli_bundle_pull_range_dedup,peer_store_probeless;crates/cli/tests/fetch_node_dir_guard.rs;crates/cli/src/commands/bundle_pull/tests.rsand thefetchcommand tests;README.md,docs/runbook.md,docker/README.decdn.md,CLAUDE.md(the command list in the Status note);crates/client/src/lib.rscrate docs that name the two commands.website:components/site/HeroTerminal.tsxand anywebsite/docs/page that showsdecdn fetchordecdn bundle pull.sponsord(separate PR, lands with thedecdnrelease that shipsget):crates/sponsord-onramp/assets/decdn.shand its PowerShell twin print abundle pullcommand, checked bytests/installer_sh.rsandtests/installer_ps1.rs;README.md,AGENTS.md,docs/installer.md,docs/integrator.md,docs/architecture.md.
Acceptance
DecdnUriparses and round-trips every row of the table above, plus percent-encoded paths, uppercase hex, and?ns=.- Rejects:
b3:/0xprefixes, wrong hash length, non-hex,ns=0, non-decimalns, unknown query keys,../ empty / absolute entry paths, a//form. decdn getroutes each URI kind to the right pull and passes the namespace through.decdn fetchanddecdn bundle pullno longer exist;decdn --helplistsget.- Every e2e and CLI test above runs through
getand passes, with the same coverage (multi-source, resume, top-up, stdout, range dedup, pool id). - The flag rules above are enforced with clear errors.
- A URI entry path containing glob metacharacters pulls exactly that entry.
decdn:<hash>/on a non-manifest blob fails with the drop-the-slash hint.
🤖 Generated with Claude Code
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsDone
Activity
[-]client: decdn: URI scheme for blobs, bundles and bundle entries[/-][+]cli: decdn get <decdn: URI> replaces fetch and bundle pull[/+]feat(client): parse and print `decdn:` URIs (#2455)
feat(cli): `decdn gateway` serves `decdn:` URIs to a browser over loo…
docs(adr): define the `decdn:` URI in appendix-bundles (#2449)
feat(cli): add `decdn get <decdn: URI>` over fetch and bundle pull (#…
feat(cli): `decdn gateway` serves `decdn:` URIs to a browser with sco…
feat(cli)!: decdn get replaces decdn fetch and decdn bundle pull (#2461)
feat(try-it): show the decdn: URI installer one-liner (#307)