Repository navigation
fix(cli,client): refuse to replace a file no record vouches for in a default destination - #2476
Merged
Merged
Conversation
… destination Without -o, an entry URI lands at ./<name>, and the skip-cache recorded that file under its flattened name only. A second entry with the same name (decdn:<h>/tokenizer/config.json after decdn:<h>/text_encoder/ config.json), or a second bundle pulled into . with a same-named file, found a recorded file, passed the default-destination check, and fetched over it. Each skip-cache record now names its source: the manifest hash and the entry's manifest path. BundleManifest keeps its blob hash (parse takes it from the bytes), and ManifestEntry::land_at moves an entry to its landing name while it keeps the manifest path. A pull without -o refuses a path whose record names another source, and the error names that source as a decdn: URI. -o and --overwrite still pass. The skip-cache schema is version 2; a version 1 file reads as empty. decdn_client::bundle::foreign_paths replaces unrecorded_paths. Closes #2472 Co-Authored-By: Claude Opus 5.5 <[email protected]>
… wrongly replace Review fixes to the #2472 refusal. A skip-cache record now vouches for a path only when the file still has the recorded size and mtime, and the record names the same entry or holds the same bytes. So: - a new version of a bundle pulled into . replaces only the files it changes, and two entries with identical bytes no longer refuse each other; - a file the user edited after a pull wrote it is refused ("it changed after an earlier `decdn get` wrote it from <uri>"), where the pull replaced it before; - a skip-cache that is there but cannot be used (another version, corrupt, unreadable) is refused naming the cause, instead of claiming no `decdn get` wrote the files; - a path the pull reserves for its own state is left to the engine, which fails that one entry; plan_slots and foreign_paths share one writable_dest predicate. ForeignPath carries a ForeignReason in place of written_from. The engine threads the manifest hash as [u8; 32] and SavedSource::new builds the record's source. Stale docs that named only the unrecorded rule, or called the skip-cache key bundle-relative, are fixed. The range-dedup e2e checks each record's source, and the unit tests cover every reason, land_at twice, and the dry run against another source. Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
🟢 Approval recommended
Only a non-blocking documentation clarification remains; no functional blockers were identified.
1 open finding
What changed in this PR
Protects default decdn get destinations from replacing files written by another bundle entry or modified locally.
Changes:
- Records source manifests and entry paths in skip-cache version 2.
- Adds source-aware refusal checks and explanatory errors.
- Updates tests, public API snapshots, and documentation.
| File | Description |
|---|---|
| README.md | Describes default-destination protection. |
| crates/e2e/tests/cli_bundle_pull_range_dedup.rs | Checks recorded source identity. |
| crates/common/src/cli/get.rs | Updates CLI help. |
| crates/client/tests/snapshots/public_api__public_api.snap | Captures API changes. |
| crates/client/src/bundle/skip_cache/tests.rs | Tests source records and schema errors. |
| crates/client/src/bundle/skip_cache.rs | Adds source tracking and checked loading. |
| crates/client/src/bundle/engine/tests.rs | Tests refusal and source preservation. |
| crates/client/src/bundle/engine.rs | Records sources and shares destination validation. |
| crates/client/src/bundle.rs | Adds source-aware foreign-path checks. |
| crates/cli/src/commands/get.rs | Updates command documentation. |
| crates/cli/src/commands/gateway/tests.rs | Adapts manifest construction. |
| crates/cli/src/commands/bundle_pull/tests.rs | Tests refusal behavior and diagnostics. |
| crates/cli/src/commands/bundle_pull.rs | Integrates checks into live and dry runs. |
| CHANGELOG.md | Documents protection and schema changes. |
| adr/appendix-bundles.md | Defines source-aware replacement rules. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Without -o, a new version of a bundle that changes a file is refused: the changed file matches neither its record's manifest hash nor its file hash. The README and CHANGELOG said such a pull replaces only the changed files, which holds only with -o .. They now say -o . updates a bundle in place and --overwrite fetches every file again. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Code coverage overviewLanguages: Rust Rust / code-coverage/cargo-llvm-cov
View coverage of the 8 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
This was referenced Oct 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What
Without
-o,decdn get decdn:<h>/text_encoder/config.jsonlands at./config.json, and the skip-cache recorded that file only under its landing name. A laterdecdn get decdn:<h>/tokenizer/config.jsonfound a recorded file, passed the #2466 default-destination check, and fetched over it. Two bundles pulled into.with a same-named file hit the same bug.Each
.decdn-manifest.jsonrecord now names its source: the manifest hash and the entry's manifest path. A pull without-orefuses a path unless a record vouches for it. A record vouches for a path when the file still has the recorded size and mtime, and the record names the same entry or holds the same bytes. The error says why it refuses:decdn getwrote the file;decdn getwrote it from<uri>;decdn getwrote it from another entry,<uri>;has version 1; this build reads version 2).-o(including-o .) and--overwritestill let the pull replace the file. Without-o, a new version of a bundle that changes a file is refused;-o .updates it in place, replacing the changed files and skipping the rest.Closes #2472
Reviewer notes
foreign_paths/ForeignReasonincrates/client/src/bundle.rs, andSavedSource/load_checkedincrates/client/src/bundle/skip_cache.rs.BundleManifestkeeps its blob hash, whichparsetakes from the bytes, andnewnow takes the hash.ManifestEntry::land_atmoves an entry to its landing name and keeps the manifest path. The engine passes the hash as[u8; 32]down torecord_one.plan_slotsandforeign_pathsshare onewritable_destcheck, so a path the pull keeps its own state in fails that one entry instead of refusing the whole run.-orefuses the existing files and names the version mismatch.-o .once clears it.decdn-clientpublic API:foreign_paths/ForeignPath/ForeignReasonreplaceunrecorded_paths, plusBundleManifest::hash,ManifestEntry::land_atandmanifest_path. The snapshot is regenerated.ManifestEntry::pathprivate (misusing it today only causes a refusal);BundleManifest::newto tests;?ns=.Verification
cargo fmt -- --check(pre-commit)cargo clippy --workspace --all-targets --all-features -- -D warnings: exit 0cargo nextest run: not the whole workspace. I ran-p decdn-client -p decdn-cli -p decdn-common(2213 passed) and the anvil e2e bundle binaries-p decdn-e2e --features anvil-e2e -E 'binary(/bundle/)'(10 passed, aftercargo build --bin decdn-node --bin decdn).cargo nextest run -p decdn-client --features public-api-test --test public_api: passedCARGO_BUILD_WARNINGS=deny cargo doc --workspace --no-deps --document-private-items: exit 0sourceassertion fails whenrecord_onerecords a wrong bundle hash (checked by mutating it, then reverting).CHANGELOG.mdfeat(cli): make decdn get -o optional with per-target defaults #2466 entry is amended in place (all entries are Unreleased).adr/appendix-bundles.md§ Output directory updated.🤖 Generated with Claude Code