Repository navigation
Description
Problem
decdn-client can only download single blobs. The bundle pull exists only inside the decdn CLI crate. That affects any application embedding deCDN that needs to pull a bundle. The first one is decdn/sponsord's decdn-sponsored.
The SDK's entry points are Downloader and Streamer, for one blob or a set of blobs. Its crate docs leave seven setup steps to the application: buyer key, pool, endpoint, discovery and probe, lane building, fetch, and recording settlement. Everything that makes up a bundle pull lives in crates/cli (about 7.7k lines):
bundle_pull.rs: resuming from on-disk state, materializing by hash group, reusing identical files from a verified donor,--select, run planningbundle_manifest.rs,bundle_cache.rs: fetching and saving the manifestcli_sources.rs: building lanes, the funder, recovery, persisting watermarkschain_ctx.rs,buyer_store.rs,pull_progress.rs
This has two consequences:
- Embedders have to spawn the CLI.
decdn-sponsoredbuilds adecdn bundle pullargument vector (crates/decdn-sponsored/src/decdn.rs) and runsdecdnas a child process. That makes decdn's CLI flags an untyped contract with software already in the field: a renamed flag breaks sponsored downloads at runtime, not at compile time. It also ships two binaries, each with its own pinnedSHA256SUMS, and copies the node's expiry margin by hand (NODE_EXPIRY_MARGIN_SECS, Derive the wrapper's capability reuse margin from the node's expiry margin sponsord#10). - ADR 039 § Client SDK funding signal can't be used for bundles. That ADR has a delegated client's application get new capabilities "from a sponsor gateway" and swap them into the
CredentialSlot. The CLI "swaps in no new credential" (cli_sources.rs,credentials()), so a sponsored bundle pull that runs low on capability fails, and the user has to re-run the command to get a new key and capability through the onramp. The SDK already has the slot, the running-low signal and retirement at a voucher boundary. No bundle-level caller can reach them.
Proposed solution
Move the bundle pull into decdn-client as a public, bundle-level API. Make decdn bundle pull a thin caller of it.
Rough shape (names are illustrative):
- A
BundlePuller(or similar) taking: the manifest hash, an output directory, an optional namespace, an optional selection, the chain/deployment context, a data dir for the peer and buyer stores, and the funding source. The funding source is either a self-owned pool or a delegatedCredentialSlotthat the application keeps. - Progress reported through a callback or event stream (
PullProgressevents), not drawn to the terminal. The CLI keeps its rendering inpull_progress.rs/tab_progress.rs. - Typed outcomes: done,
FundingNeeded(asfetch.rsmaps it today), interrupted, or failed. That way an embedder can react without parsing stderr. - The running-low signal reachable from the bundle level, so the application can swap credentials mid-pull without restarting.
- No CLI dependencies in
decdn-client(no clap and noBundlePullArgsin the API).decdn_common::clistays the CLI's concern.
Out of scope: any change to the wire protocol, the economics or the contracts. This changes where existing code lives and what the SDK makes public.
Follow-up downstream (sponsord, not this repo): decdn-sponsored links the new API directly, refreshes its capability through the onramp on the running-low signal, and stops shipping decdn in its installer and image.
Alternatives considered
- Fold
decdn-sponsoredinto thedecdnCLI (decdn bundle pull --sponsor <onramp>). This removes the argv contract, butdecdnwould have to own the onramp's HTTP API: shared wire types, plus an ADR to describe that API. sponsord already depends on decdn, so this risks a dependency cycle between the two repos. It would also put one publisher-side product inside the protocol CLI. - Have sponsord reimplement bundle pull on the current SDK. That duplicates about 7.7k lines, which would drift from the CLI with every change.
- Keep spawning the CLI. This works today, but keeps the problems above.
Related: #1021 (made discovery, probe, endpoint and provider public in the client).
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Projects
- StatusShow more project fieldsDone
Activity
thiras commentedon Oct 12, 2026
Downstream consumer: decdn/sponsord#68 (decdn-sponsored pulls in-process and swaps credentials on the running-low signal).
thiras commentedon Oct 12, 2026
Tracking: PR 1/3 is #2434 (the network leg moves into
decdn-client). Out of scope here and filed separately: #2435 (a delegated client's lane watermarks are never persisted).feat(client): add a public bundle pull, decdn_client::bundle
feat(client): let a delegated bundle pull swap credentials mid-run
refactor(client): move the paid fetch's network leg into decdn-client (…
feat(client): add a public bundle pull, decdn_client::bundle
feat(client): let a delegated bundle pull swap credentials mid-run
feat(client): add a public bundle pull, decdn_client::bundle (#2436)
feat(client): let a delegated bundle pull swap credentials mid-run
feat(client): let a delegated bundle pull swap credentials mid-run (#…