Skip to content

feat(cli): decdn get streams one bundle entry to stdout with -o - - #2467

Merged
thiras merged 2 commits into
mainfrom
claude/decdn-single-file-blob-e32099
Oct 16, 2026
Merged

thiras merged 2 commits into
mainfrom
claude/decdn-single-file-blob-e32099

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

decdn get 'decdn:<hash>/<path>' -o - | mpv - failed with "-o - (stdout) takes a blob URI". An entry URI names exactly one file, so it streams to stdout like a blob now.

  • Route: an entry URI with -o - runs the blob fetch. The fetch reads the bundle manifest into memory, finds the entry, and streams its blob to stdout. Both fetches run on one FetchHost and one Payer, so they share one pool. This is the route the gateway already takes for an entry. An entry URI without -o still goes to the bundle pull and lands at ./<name> (feat(cli): make decdn get -o optional with per-target defaults #2466).
  • Manifest cap: the manifest fetch clamps --max-blob-mb to MAX_MANIFEST_BYTES (64 MiB, the constant the gateway uses, now shared from fetch.rs). So the lanes request and pay for no more than a manifest can be. A larger blob fails with a hint to drop the path.
  • One unlock: the keystore Payer keeps the loaded signer in a OnceCell, so the manifest fetch and the entry fetch prompt for the password once.
  • Flags: -o - on a whole bundle (decdn:<hash>/) is still an error. Bundle-only flags (--jobs, --overwrite, --json, ...) are an error on an entry URI to stdout, since that run is one blob. bundle_pull itself refuses -o -, so a misroute fails rather than making a directory -.
  • Errors: an entry-fetch error names the entry and its blob hash. A malformed entry hash names its entry.
  • Docs: GetArgs help, CHANGELOG, the README get table, and adr/appendix-bundles.md § Pull name the new -o - form.

Commits

  1. feat(cli): decdn get streams one bundle entry to stdout with -o -: the feature, rebased onto feat(cli): make decdn get -o optional with per-target defaults #2466 (-o is optional; fetch takes the resolved Destination path).
  2. fix(cli): bound and label the entry-to-stdout manifest fetch: review fixes. They add the manifest cap clamp, entry-error context, a separate manifest timings event, the bundle_pull guard, tests and docs.

Reviewer notes

  • The manifest fetch logs its own fetch timings event with output="manifest". The command's own event reports the entry's first byte on stdout.
  • If a funding recovery replaces the pool during the manifest fetch, the command ends with the new pool named, as for any -o - stream. A re-run picks up the new pool.
  • The gateway reads manifests the same way. It does not clamp max_blob_mb yet, so an oversized "manifest" there still pays up to the cap before it fails. That is out of scope here.

Test plan

  • cargo nextest run -p decdn-cli -p decdn-common (1283 passed). It covers:
    • the routing and flag rules, including an entry URI without -o
    • entry_hash: picks the named entry, missing entry, not a manifest, malformed hash
    • the ManifestBuf 64 MiB boundary
  • cargo nextest run -p decdn-e2e --features anvil-e2e -E 'binary(cli_fetch_stdout)': both tests pass. For the entry test:
    • the manifest lists a decoy entry before the target, and stdout must equal the target byte for byte
    • the watermark must cover the manifest and the entry
    • the run must read the keystore password once, counted through an unused --keystore-password-file warning
    • Mutation-checked: with the OnceCell removed, it fails with "read the keystore password 2 times".
  • cargo clippy --workspace --all-targets --all-features -D warnings, cargo fmt --check, cargo doc with warnings denied, pre-commit hooks

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings October 15, 2026 13:53
@github-code-quality

github-code-quality Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust

Rust / code-coverage/cargo-llvm-cov

main e2b59e9 claude/decdn-single-... 4e09454 +/-
75% 75% 0%
View coverage of the 5 most impacted files.
File main e2b59e9 claude/decdn-single-... 4e09454 +/-
crates/cli/src/...mmands/fetch.rs 52% 50% -2%
crates/client/src/lib.rs 89% 88% -1%
crates/cache/src/engine.rs 91% 91% 0%
crates/cli/src/.../bundle_pull.rs 55% 55% 0%
crates/cli/src/commands/get.rs 96% 97% +1%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 16, 2026 10:20 UTC

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The change alters the shared keystore-unlock and paid-fetch flow (new multi-fetch payment path plus the Payer OnceCell refactor affecting all blob fetches), which is financially sensitive and warrants human confirmation despite no concrete defects found.

0 open findings

What changed in this PR

This PR extends decdn get so that an entry URI (decdn:<hash>/<path>) can be streamed to stdout with -o -, matching the behavior already available for raw blob URIs (e.g. decdn get 'decdn:<hash>/<path>' -o - | mpv -). Because an entry URI names exactly one file, routing it through the single-blob fetch path is a natural fit. Previously this combination errored with "-o - (stdout) takes a blob URI".

The entry-to-stdout run reads the bundle manifest into memory (capped at the shared MAX_MANIFEST_BYTES, 64 MiB), looks up the entry's blob hash, and streams that blob to stdout — both fetches share one FetchHost and one Payer/pool. The keystore Payer now caches its loaded signer in a OnceCell, so the two fetches prompt for the password once.

Changes:

  • Route an entry URI with -o - to fetch::fetch, which reads the manifest then streams the entry blob to stdout (new fetch_target/entry_hash/ManifestBuf).
  • Make the keystore Payer load and reuse its signer via a tokio::sync::OnceCell so multiple fetches unlock once; share MAX_MANIFEST_BYTES from fetch.rs (removed from gateway.rs).
  • Update flag validation (-o - now valid for an entry URI; bundle-only flags rejected on entry-to-stdout) plus help/doc text and unit + e2e tests.
File Description
crates/​cli/​src/​commands/​fetch.rs Adds fetch_target/entry_hash/ManifestBuf, refactors fetch to route via uri, and makes the keystore Payer load its signer once through a OnceCell; defines shared MAX_MANIFEST_BYTES.
crates/​cli/​src/​commands/​get.rs Routes an entry URI with -o - to the blob fetch (streams_one_blob/is_stdout) and relaxes/updates -o - flag validation.
crates/​cli/​src/​commands/​gateway.rs Imports MAX_MANIFEST_BYTES from fetch.rs instead of defining its own copy.
crates/​common/​src/​cli/​get.rs Documents the new -o - form for an entry URI in help text.
crates/​cli/​src/​commands/​get/​tests.rs Adds unit tests for entry-to-stdout routing and the bundle-flag rejection rule.
crates/​e2e/​tests/​cli_fetch_stdout.rs Parametrizes the stdout e2e test over blob vs. entry targets and seeds a manifest blob.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

alpergundogdu and others added 2 commits October 16, 2026 13:10
`decdn get decdn:<hash>/<path> -o -` reads the bundle manifest into
memory and streams that entry's blob to stdout, on one fetch host and
one payer. The keystore payer unlocks once across both fetches. A whole
bundle (`decdn:<hash>/`) still needs an output directory, and the
bundle-only flags are an error on an entry URI to stdout.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`decdn get decdn:<h>/<path> -o -` reads the manifest, then streams the
entry. Review fixes to that route:

- The manifest fetch clamps --max-blob-mb to the 64 MiB manifest cap,
  so the lanes request and pay for no more than a manifest can be. A
  larger blob fails with a hint to drop the path.
- An entry-fetch error names the entry and its blob hash. Without it, a
  missing entry blob reads "check the hash" about the manifest hash the
  user typed.
- The manifest fetch logs its own `fetch timings` event
  (output="manifest"), so the command's time to first byte is the
  entry's first byte on stdout.
- bundle_pull refuses `-o -`, so a misroute cannot make a directory `-`.
- Unit tests for the entry lookup and the ManifestBuf cap. The e2e lists
  a decoy entry first, asserts the watermark covers both fetches, and
  counts password reads through an unused password file (a per-fetch
  unlock fails it).
- CHANGELOG, README `get` table, and adr/appendix-bundles.md § Pull
  name the route. Stale one-fetch comments are fixed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras
thiras force-pushed the claude/decdn-single-file-blob-e32099 branch from 02ddd48 to 4e09454 Compare October 16, 2026 10:12
@thiras
thiras merged commit 75d8b1a into main Oct 16, 2026
31 checks passed
@thiras
thiras deleted the claude/decdn-single-file-blob-e32099 branch October 16, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants