Skip to content

feat(cli): allow origin import --move with --optimize - #2113

Merged
alpergundogdu merged 1 commit into
mainfrom
claude/move-optimize-incompatibility-08f9e0
Sep 22, 2026
Merged

alpergundogdu merged 1 commit into
mainfrom
claude/move-optimize-incompatibility-08f9e0

Conversation

@alpergundogdu

Copy link
Copy Markdown
Contributor

What

decdn origin import --move --optimize was rejected up front. The only reason: the chunk-hint pass re-opened the source file after the whole-file blob was written, and --move renames the source into the store, leaving nothing to re-open.

This makes the chunk pass read the just-written stored object at its content-addressed path instead. The store copy always exists after import_one_file (a move renames the source in; a copy stages it there), so --optimize and --move now compose for free.

Why it's safe

  • Chunking the immutable, content-addressed stored bytes rules out the read race the old two-source-pass code had to guard against. The consistency check is kept but now only catches a corrupt stored object (whole-file pass wrote X, chunk pass read Y).
  • The stored bytes are byte-identical to the source (content-addressed), so the emitted chunk hints describe exactly the stored blob.

Changes

  • Read the chunk-hint pass from {base}/{shard}/{hash} (via shard_prefix) rather than re-opening the source.
  • Drop the --move + --optimize guard in origin_import.
  • Replace the rejection test with optimize_and_move_compose, which asserts the source is moved away, the whole-file blob lands at its content address, and the manifest carries chunk hints.

Testing

cargo nextest run -p decdn-cli --test origin_import — 17/17 pass. cargo clippy -p decdn-cli --all-targets --all-features and cargo fmt --check clean.

🤖 Generated with Claude Code

The chunk-hint pass re-opened the source file after the whole-file blob
was written, so `--move` (which renames the source into the store) left
nothing for it to re-open. That was the only reason `--optimize` and
`--move` were rejected together.

Read the chunk pass from the just-written stored object at its
content-addressed path instead. The store copy always exists after
`import_one_file` — a move renames the source in, a copy stages it there
— so the two flags now compose. Chunking the immutable stored bytes also
rules out the read race the old two-source-pass code had to guard
against; the consistency check now only catches a corrupt stored object.

Drop the up-front guard and replace its rejection test with a positive
test that `--optimize --move` moves the source away, stores the
whole-file blob at its content address, and emits chunk hints.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Copilot AI lite review requested due to automatic review settings September 22, 2026 13:30

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.

Copilot review overview

🟢 Approval recommended

The change is narrowly scoped, aligns with the PR’s stated safety argument, and is covered by an updated integration test exercising the new --move --optimize behavior.

Review effort: Lite
Findings: None

What changed in this PR

This PR enables decdn origin import --move --optimize by changing the --optimize chunk-hint pass to read from the just-written content-addressed object in the origin store (instead of re-opening the source file, which no longer exists after --move).

Changes:

  • Remove the up-front rejection of --move combined with --optimize in origin_import.
  • Update optimized import to chunk the stored object at {base}/{shard_prefix}/{hash} and keep a consistency check (whole-file write vs chunk pass read).
  • Replace the prior “rejected” integration test with optimize_and_move_compose, asserting the source is moved away and the manifest contains chunk hints.
File Description
crates/​cli/​src/​commands/​origin.rs Switch optimized chunk-hint read to the stored object path and drop the --move+--optimize incompatibility guard.
crates/​cli/​tests/​origin_import.rs Update the integration test to validate --move --optimize succeeds and emits chunk hints while moving the source away.

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

@github-actions

Copy link
Copy Markdown

Coverage report

Total: 83.69% (was 83.69%, ● 0.00%) — 86764/103674 lines

File Coverage Lines Δ
crates/cli/src/commands/origin.rs 86.43% 637/737 ▼ 0.02%
History
Commit Total Δ vs base
1bf82b5 (HEAD) 83.69% ● 0.00%

@alpergundogdu
alpergundogdu merged commit c77d111 into main Sep 22, 2026
26 checks passed
@alpergundogdu
alpergundogdu deleted the claude/move-optimize-incompatibility-08f9e0 branch September 22, 2026 13:45
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.

2 participants