Skip to content

fix(cli): prevent destructive overwrites - #131

Merged
vinceblock99 merged 3 commits into
chore/delete-noop-cli-surfacefrom
chore/remove-data-loss-surface
Jul 28, 2026
Merged

vinceblock99 merged 3 commits into
chore/delete-noop-cli-surfacefrom
chore/remove-data-loss-surface

Conversation

@vinceblock99

@vinceblock99 vinceblock99 commented Jul 24, 2026 •

Copy link
Copy Markdown
Contributor

What

  • Removed move --force and made atomic move reject moves when the final target already exists.
  • Removed stash --include-untracked because it did not remove untracked files from the working tree.
  • Made memory new --id reject an ID that already exists.

Why

These commands could overwrite data or claim work was done when it was not. They now fail safely instead.

Test

  • cargo fmt --all -- --check
  • cargo clippy --workspace -- -D warnings
  • cargo test --workspace
  • Harness suite 06: 88/88
  • Manually verified that existing move targets and duplicate memory IDs are preserved.

Depends on #130.

Stop-the-bleeding for verified data-loss paths (deeper behavior fixes
for revise rollback and stash deletion capture are tracked separately):

- move --force removed: disk rename ran before the tracking update,
  which always fails on a tracked destination — the destination file
  was deleted from disk, unrecoverable for add-only/untracked targets.
- move now refuses ANY existing file at the resolved destination,
  tracked or untracked — fs::rename replaced it silently with exit 0.
  Moving into an existing directory still works (the check runs on the
  resolved <dir>/<filename> path). Run-level regression tests cover the
  untracked-destination, tracked-destination, and move-into-directory
  cases.
- stash --include-untracked/-u removed: copied untracked files into the
  stash sidecar but never cleaned them from the working copy, while
  printing 'restored to clean state'. Untracked files are now simply
  left alone (suite 06 pins the behavior and rejects the removed flag).
- memory new --id errors when the id already exists instead of silently
  replacing a possibly-attested memory; regression test asserts the
  original content survives. Follow-up: fold the existence check into
  the vault_store transaction to close the check-then-write window.

Verified kept: view switch --stash works end-to-end for modified files;
it inherits stash's missing deletion capture (behavior-fix PR).
The guard added alongside the --force removal used Path::exists(), which
is wrong in two directions.

Case-only rename regressed. On case-insensitive filesystems (APFS, NTFS)
'file.txt' exists whenever 'File.txt' does, so 'atomic move File.txt
file.txt' returned exit 2. It worked before this stack -- is_tracked is
case-sensitive and rename(2) handles case-only renames -- and --force was
removed in the same commit, leaving no way through. Canonicalize both
sides and allow the move when they resolve to the same entry.

Dangling symlinks were still clobbered. exists() follows the link and
reports false for a broken one, so rename destroyed it -- contradicting
the guard's own 'refuse ANY existing file' comment. Use symlink_metadata.

Both reproduced against the built binary before and after. Regression
tests added for each; the untracked- and tracked-destination guards are
unchanged and still refuse (exit 2, contents intact).
@vinceblock99
vinceblock99 force-pushed the chore/delete-noop-cli-surface branch from 6ac6b50 to c43fd8a Compare July 24, 2026 19:23
@vinceblock99
vinceblock99 force-pushed the chore/remove-data-loss-surface branch from 1bd5099 to c256372 Compare July 24, 2026 19:23
@vinceblock99 vinceblock99 changed the title chore(cli): remove data-loss surface pending real fixes [draft]chore(cli): remove data-loss surface pending real fixes Jul 27, 2026
@vinceblock99 vinceblock99 changed the title [draft]chore(cli): remove data-loss surface pending real fixes fix(cli): prevent destructive overwrites Jul 27, 2026
@vinceblock99
vinceblock99 merged commit 3917f93 into chore/delete-noop-cli-surface Jul 28, 2026
vinceblock99 added a commit that referenced this pull request Jul 28, 2026
* chore(cli): delete no-op and unimplemented command surface

Per the project rule: if a command surface doesn't work, delete it
rather than implement it. Every removal below was verified against the
real binary — the flag either had no effect, always errored, or printed
a not-implemented notice.

Removed:
- log --path: parsed, printed 'not yet fully implemented', never filtered
- stash show --patch: printed 'Full diff output not yet implemented'
- unrecord [CHANGE]: positional always errored 'not yet supported'
- diff --cached (hidden) and diff --view: parsed but never read
- change --show-hunks: parsed but never read (hunks always print)
- insert/from-view/tag/pick --deps: SetTrue with default_value=true is
  an inert toggle; dependency-following stays always on
- insert pick --allow-conflicts: run_pick never read it (kept for the
  other insert modes, where it works)
- tag create --author/--view: parsed but never read; tag always used
  the current view and identity author (parse_author was test-only)
- identity default --clear --usage: warned 'not yet supported'; the
  combination is now a clap conflict error instead of a silent no-op
- vault summaries --json: output is always JSON; flag did nothing

Deliberately NOT removed: the deprecated 'vault intent' family — it
works, the embedded vault skills/prompts installed into every new
project still teach it, and the canonical 'atomic intent' commands are
not output-compatible. Removing it needs a migration PR that also
updates the embedded skill content (vault_defaults.rs). Harness suites
14/16 were still migrated to the canonical commands, which coexist.

Surface test: 198 public command paths / 169 leaves, unchanged.

* docs(cli): stop advertising surface this PR deleted

Three module-doc usage blocks still listed flags removed in this commit:
change --show-hunks, log --path, vault summaries --json. Leaving them
documented is the same advertise-what-does-not-work problem the
deletions exist to fix.

Also correct intent/mod.rs and intent/show.rs, which described the
`atomic vault intent` tree as removed. Review reversed that removal --
the tree still ships, marked DEPRECATED, and cannot go until a
migration updates the vault skills embedded in vault_defaults.rs.

* test(cli): preserve supported compatibility surface

* fix(cli): prevent destructive overwrites (#131)

* chore(cli): remove data-loss surface and refuse destructive moves

Stop-the-bleeding for verified data-loss paths (deeper behavior fixes
for revise rollback and stash deletion capture are tracked separately):

- move --force removed: disk rename ran before the tracking update,
  which always fails on a tracked destination — the destination file
  was deleted from disk, unrecoverable for add-only/untracked targets.
- move now refuses ANY existing file at the resolved destination,
  tracked or untracked — fs::rename replaced it silently with exit 0.
  Moving into an existing directory still works (the check runs on the
  resolved <dir>/<filename> path). Run-level regression tests cover the
  untracked-destination, tracked-destination, and move-into-directory
  cases.
- stash --include-untracked/-u removed: copied untracked files into the
  stash sidecar but never cleaned them from the working copy, while
  printing 'restored to clean state'. Untracked files are now simply
  left alone (suite 06 pins the behavior and rejects the removed flag).
- memory new --id errors when the id already exists instead of silently
  replacing a possibly-attested memory; regression test asserts the
  original content survives. Follow-up: fold the existence check into
  the vault_store transaction to close the check-then-write window.

Verified kept: view switch --stash works end-to-end for modified files;
it inherits stash's missing deletion capture (behavior-fix PR).

* fix(cli): close two holes in the move destination guard

The guard added alongside the --force removal used Path::exists(), which
is wrong in two directions.

Case-only rename regressed. On case-insensitive filesystems (APFS, NTFS)
'file.txt' exists whenever 'File.txt' does, so 'atomic move File.txt
file.txt' returned exit 2. It worked before this stack -- is_tracked is
case-sensitive and rename(2) handles case-only renames -- and --force was
removed in the same commit, leaving no way through. Canonicalize both
sides and allow the move when they resolve to the same entry.

Dangling symlinks were still clobbered. exists() follows the link and
reports false for a broken one, so rename destroyed it -- contradicting
the guard's own 'refuse ANY existing file' comment. Use symlink_metadata.

Both reproduced against the built binary before and after. Regression
tests added for each; the untracked- and tracked-destination guards are
unchanged and still refuse (exit 2, contents intact).

* docs(cli): simplify safety comments
@vinceblock99
vinceblock99 deleted the chore/remove-data-loss-surface branch August 12, 2026 13:15
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.

1 participant