Skip to content

cli: decdn get <decdn: URI> replaces fetch and bundle pull #2449

Closed

Description

@alpergundogdu

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. No b3: or 0x prefix: 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 (like magnet: / urn:). This sidesteps host rules: a 64-character hex hash exceeds the 63-character DNS label limit, and a b3: 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 3986 pchar). It matches exactly one manifest path, literally.
  • ns is the namespace id in decimal. Absent means no namespace (namespace 0, ADR 002). ns=0 is rejected, the same as --namespace 0 today. 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 /. The url crate treats decdn:<hash>/a/b as an opaque-path URL (path_segments() returns None), so it adds nothing here.
  • Reuse the hex parsing behind decdn_client::bundle::parse_hash (crates/client/src/bundle.rs:72) but without its 0x/b3: prefixes.
  • Validate the decoded entry path with the same rules the manifest applies (relative, no .., no root, UTF-8).
  • ns parsing must match parse_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 is uint256; the URI inherits the CLI's existing u64 bound.
  • Being public, the new type updates the decdn-client public_api snapshot.

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:

  • Blob runs the blob fetch. -o is the destination file, or - for stdout.
  • Bundle runs the bundle pull over every entry. -o is the output directory.
  • BundleEntry(path) runs the bundle pull with an include filter of exactly that path. -o is the output directory, and the file lands at <OUT>/<path>, the same as a full pull.
  • The URI's ns becomes the namespace hint. get has no --namespace flag: the URI is the single source.
  • get flattens the shared ClientFetchArgs (crates/common/src/cli/fetch.rs), so discovery, chain, pool and capability flags work as they do today.
  • get calls the same library paths (BundlePuller and 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, --exclude and --select are 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 tests cli_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.rs and the fetch command tests; README.md, docs/runbook.md, docker/README.decdn.md, CLAUDE.md (the command list in the Status note); crates/client/src/lib.rs crate docs that name the two commands.
  • website: components/site/HeroTerminal.tsx and any website/docs/ page that shows decdn fetch or decdn bundle pull.
  • sponsord (separate PR, lands with the decdn release that ships get): crates/sponsord-onramp/assets/decdn.sh and its PowerShell twin print a bundle pull command, checked by tests/installer_sh.rs and tests/installer_ps1.rs; README.md, AGENTS.md, docs/installer.md, docs/integrator.md, docs/architecture.md.

Acceptance

  • DecdnUri parses and round-trips every row of the table above, plus percent-encoded paths, uppercase hex, and ?ns=.
  • Rejects: b3:/0x prefixes, wrong hash length, non-hex, ns=0, non-decimal ns, unknown query keys, .. / empty / absolute entry paths, a // form.
  • decdn get routes each URI kind to the right pull and passes the namespace through.
  • decdn fetch and decdn bundle pull no longer exist; decdn --help lists get.
  • Every e2e and CLI test above runs through get and 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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions