Skip to content

feat(cli): make decdn get -o optional with per-target defaults - #2466

Merged
thiras merged 3 commits into
mainfrom
ccr-b4d05c65-qxlowy
Oct 16, 2026
Merged

thiras merged 3 commits into
mainfrom
ccr-b4d05c65-qxlowy

Conversation

@alpergundogdu

@alpergundogdu alpergundogdu commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

What

decdn get no longer requires -o. Without it, the destination follows the URI target:

URI Default destination
decdn:<hash> ./<hash>
decdn:<hash>/ .
decdn:<hash>/<path> ./<name> (last segment of <path>, no parent dirs)

When -o is omitted, the command prints Downloading to <absolute path> on stderr before the pull starts. It does not print it under --json or --dry-run.

Without -o, a bundle or entry pull refuses an entry path that already holds a file no earlier pull recorded in .decdn-manifest.json, unless --overwrite. The dry run refuses the same way. This keeps a bare decdn get decdn:<h>/x/config.json from replacing the user's own ./config.json.

Reviewer notes

  • get.rs resolves a Destination { path, entry_name }. entry_name is the URI path's last segment, set only for an entry URI without -o. fetch::fetch takes the resolved file path, and bundle_pull::bundle_pull takes the Destination. Everything that read args.output now reads the resolved path instead.
  • EntryFilter::landing_as renames the one kept entry to entry_name; a filter with no entry URI drops the name. Live pulls and --dry-run see the same layout.
  • New decdn_client::bundle::unrecorded_paths (public API snapshot updated) backs the refusal. The engine also reserves .decdn-manifest.json and .decdn-bundles/ like .decdn-partial/, so no entry lands on the pull's own state.
  • An explicit -o behaves exactly as before. An entry URI with -o dir still lands at dir/<path>.
  • A default bundle or entry pull writes its state (.decdn-manifest.json, .decdn-bundles/, .decdn-partial/) into the current directory, the same as -o . does today.
  • ADR appendix-bundles.md gains a "Default destination" bullet.

Verification

  • cargo fmt -- --check
  • cargo clippy -p decdn-cli -p decdn-common --all-targets: clean
  • cargo test -p decdn-cli --lib: 655 passed, including new tests for the defaults, the explicit -o, and entry flattening (cargo nextest is not installed in this environment)
  • cargo test -p decdn-cli --test get_node_dir_guard
  • CARGO_BUILD_WARNINGS=deny cargo doc -p decdn-cli -p decdn-common --no-deps --document-private-items
  • User-visible change: CHANGELOG.md entry added
  • Design change: ADR in adr/ updated

🤖 Generated with Claude Code

https://claude.ai/code/session_01GBt8wsxcjbQhMTA9JwZAvQ


Generated by Claude Code

Without -o, a blob lands at ./<hash>, a bundle in ., and an entry URI at
./<name> (the last segment of its path, without its parent directories).
The command names the destination on stderr before the pull starts,
except under --json or --dry-run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GBt8wsxcjbQhMTA9JwZAvQ
Copilot AI balanced review requested due to automatic review settings October 15, 2026 09:49

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.

🟢 Approval recommended

The optional--o defaults are fully and correctly wired through every call site, flattening cannot collide, and the behavior is covered by new unit tests and consistent docs/ADR/CHANGELOG updates.

0 open findings

What changed in this PR

This PR makes the -o flag of decdn get optional. When omitted, the destination is derived from the decdn: URI's target: a blob lands at ./<hash>, a whole bundle in ., and a single entry at ./<name> (the entry path's last segment, flattened with no parent directories). The command announces the resolved destination on stderr before pulling (suppressed under --json/--dry-run). This is a client-side CLI ergonomics change in the cli crate; it adds no protocol, on-chain, or economic surface.

Changes:

  • GetArgs.output becomes Option<PathBuf>; a new Destination { root, flatten } resolver (get.rs) computes the per-target default and the user-facing path.
  • fetch::fetch now takes a resolved output: &Path; bundle_pull::bundle_pull takes a &Destination, with flatten threaded onto EntryFilter so one entry's path is cut to its file name for live pulls and --dry-run alike.
  • Docs updated: GetArgs/module docstrings, CHANGELOG.md, and adr/appendix-bundles.md gain a "Default destination" bullet; new unit tests cover the defaults, explicit -o, and entry flattening.
File Description
crates/​common/​src/​cli/​get.rs Makes output an Option<PathBuf> and documents the per-target defaults.
crates/​cli/​src/​commands/​get.rs Adds Destination::of/shown, the stderr announcement, and updates the stdout (-o -) guard for the optional flag.
crates/​cli/​src/​commands/​fetch.rs fetch takes the resolved output: &Path; doc wording updated.
crates/​cli/​src/​commands/​bundle_pull.rs Threads the resolved out/Destination through the pull, adds flatten + flatten_entry.
crates/​cli/​src/​commands/​get/​tests.rs New tests for default resolution and explicit -o.
crates/​cli/​src/​commands/​bundle_pull/​tests.rs Updates callers for the new signature; adds a flatten test.
CHANGELOG.md Documents the optional--o behavior.
adr/​appendix-bundles.md Adds the "Default destination" bullet.

Verification notes: all args.output reads on GetArgs are correctly converted to Option accesses; the two remaining args.output reads in fetch.rs belong to BlobFetch (a PathBuf), not GetArgs. The gateway builds BlobFetch directly, so it is unaffected. Flattening only ever applies to entry URIs, which keep exactly one entry, so no filename collision is possible. --dry-run shares the same filter path, so its layout matches live pulls. The ADR edit documents a pure local-UX default and introduces no enforceable/on-chain mechanism.

🧠 Review effort: Balanced


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

@github-code-quality

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

Copy link
Copy Markdown

Code coverage overview

Languages: Rust, Solidity

Rust / code-coverage/cargo-llvm-cov

main 4857690 ccr-b4d05c65-qxlowy 95f68bb +/-
75% 75% 0%
View coverage of the 10 most impacted files.
File main 4857690 ccr-b4d05c65-qxlowy 95f68bb +/-
crates/cli/src/commands/get.rs 100% 96% -4%
crates/client/src/lib.rs 89% 88% -1%
crates/node/src...s/client/mod.rs 90% 89% -1%
crates/client/s...undle/engine.rs 61% 61% 0%
crates/protocol/src/framing.rs 93% 93% 0%
crates/cache/src/engine.rs 91% 91% 0%
crates/cli/src/...ommands/node.rs 59% 60% +1%
crates/cli/src/.../bundle_pull.rs 54% 55% +1%
crates/cli/src/...mmands/fetch.rs 51% 52% +1%
crates/client/src/bundle.rs 18% 22% +4%

Solidity / code-coverage/forge

main 4857690 ccr-b4d05c65-qxlowy 95f68bb +/-
92% 92% 0%

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


Updated October 16, 2026 09:36 UTC

Without -o, a bundle or entry pull writes into the current directory,
which the user did not choose. The engine fetches over a file whose bytes
differ from its entry's, so a bare `decdn get decdn:<h>/x/config.json`
replaced the user's own ./config.json. A pull without -o now refuses any
entry path that holds a file no earlier pull recorded, unless
--overwrite; the dry run refuses the same way. The new
`decdn_client::bundle::unrecorded_paths` names those paths.

The pull's own state paths (.decdn-manifest.json, .decdn-bundles/) are
reserved like .decdn-partial/, so a flattened entry cannot land on them.

Destination now carries the entry's landing name, taken once from the
URI path's last segment, in place of a flatten flag; EntryFilter takes it
through a setter that drops it without an entry URI. The stderr line
names the absolute destination. Docs, ADR, CHANGELOG and README follow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

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.

4 participants