Skip to content

feat: delete backup-less configs on remove and restore (revert #196)#201

Closed
quickbeard wants to merge 1 commit into
mainfrom
feat/remove-deletes-codev-authored-configs
Closed

feat: delete backup-less configs on remove and restore (revert #196)#201
quickbeard wants to merge 1 commit into
mainfrom
feat/remove-deletes-codev-authored-configs

Conversation

@quickbeard

@quickbeard quickbeard commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Note: this PR previously implemented a marker-based "delete only CoDev-authored configs" approach. That has been superseded — force-pushed to a full revert of #196 per the decision that remove/restore should mean "I want this machine without CoDev", full stop.

What

Restores the pre-#196 behavior: when a config file has no *.backup alongside it, restoreKind deletes the live file instead of keeping it. Applies to both codevhub remove and codevhub restore (shared restoreKind, as it was before #196).

Why

#196 changed this on the grounds that "deleting a config we can't prove predated CoDev is destructive." That's true, and it is now the accepted trade-off. Both entry points mean "I want this machine without CoDev": remove is an uninstall and confirms before running, and restore is an explicit request for the pre-CoDev state. ensureBackup only skips the backup step when there was nothing to back up, so "no file" is a legitimate pre-CoDev state.

Accepted consequences, documented in code and AGENTS.md rather than "fixed":

  • A config the user hand-wrote after install has no backup either, and is deleted too — including for a tool CoDev never configured, since remove and the bare restore sweep all five tools unconditionally.
  • Claude's ~/.claude.json and ~/.claude/.credentials.json ride along in the same length-3 bundle, so a backup-less one goes even though it may hold Claude's own project history or a login made after install.

Everything #196 changed, reverted

#196 touched more than the delete itself. All of it is reverted:

Behavior Pre-#196 (restored here) #196
No-backup branch rmSync the live file keep it
RestoreStatus deleted-live kept-live
Sweep exit code a delete counts as action → exit 0 only restored counts → an all-deleted run would exit 1 "No backups found"
runRestoreOrDelete deleted N file(s) (no backup) runRestoreOrKeep, kept N …
keptPaths plumbing didn't exist StepResult + RemoveResult fields
RemoveApp hint didn't exist "delete manually for a clean state" list
Dedup comments "second iteration would delete what the first restored" "would redundantly re-report"

The last three matter beyond naming: keptPaths and the hint are dead code once nothing is ever kept, and the dedup guard on TOOLS/SWEEP_TOOLS is load-bearing again — a second visit really would delete the file the first visit just restored.

Two deliberate deviations from the pre-#196 code

  1. The sweep no longer deletes silently. Pre-feat: keep backup-less configs on restore instead of deleting them #196 it printed only No backup at <backup>. and never mentioned the deletion. It now prints No backup at <backup>; deleted <path>. — same behavior, honest output.
  2. Fixes a stale AGENTS.md claim that runRestore "treats a missing backup as an error and exits 1". It returns 0 unconditionally, and did before this change too — the docs had drifted from the code.

Verification

pnpm fix / typecheck / test (912 passing) / build all green. The 7 pre-existing tests that pinned #196's keep behavior failed as expected and were reverted to their pre-#196 assertions.

Added a test for the sweep exit code, which nothing covered: only deletes, zero restores → exit 0. That's the case that distinguishes the two regimes (#196 would exit 1 there), and it's mutation-tested against #196's counting.

Drove the real built binary against throwaway HOMEs:

codevhub remove --yes — every backup-less file deleted (CoDev's settings.json, .claude.json with project history, .credentials.json with a live login, the user's own marker-less ~/.codex/config.toml, opencode.json, config.yaml); the one file with a backup restored to the user's original; ~/.codev-hub wiped; no "delete manually" hint.

codevhub restorerestore claude deleted settings.json + .credentials.json, exit 0; a sweep that only deleted exited 0; a sweep with nothing to do still exited 1 with "No backups found."

🤖 Generated with Claude Code

Restores the pre-#196 behavior: when a config file has no `*.backup`
alongside it, `restoreKind` deletes the live file rather than keeping it.
Both entry points mean "I want this machine without CoDev" — `codevhub
remove` is an uninstall (and confirms first), and `codevhub restore` is an
explicit request for the pre-CoDev state — so both are destructive by
construction.

#196 changed this on the grounds that deleting a config we can't prove
predated CoDev is destructive. That is true, and it is now the accepted
trade-off: a config the user hand-wrote after install has no backup either
and is deleted too, including for a tool CoDev never configured. Claude's
~/.claude.json and .credentials.json ride along in the same length-3
bundle and are deleted the same way, even though they may hold project
history or a post-install login.

Beyond the delete itself, this reverts every behavior #196 introduced:

- `RestoreStatus` "kept-live" → "deleted-live".
- The sweep counts a delete as action again, so a run that only deleted
  exits 0 instead of falsely reporting "No backups found" (that message is
  now reserved for an all-noop run).
- `runRestoreOrKeep` → `runRestoreOrDelete`, reporting "deleted N file(s)
  (no backup)".
- Drops `StepResult.keptPaths` / `RemoveResult.keptPaths` and RemoveApp's
  "delete manually for a clean state" hint — dead once nothing is kept.
- Restores the dedup comments on TOOLS / SWEEP_TOOLS, which are
  load-bearing again: a second visit really would delete the file the
  first visit just restored.

Two deliberate deviations from the pre-#196 code:

- The sweep's message named the backup but never said it deleted anything.
  Silent deletion is worth saying out loud, so it now prints "No backup at
  <backup>; deleted <path>."
- Fixes a stale AGENTS.md claim that `runRestore` exits 1 on a missing
  backup. It returns 0, and did before this change too.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@quickbeard
quickbeard force-pushed the feat/remove-deletes-codev-authored-configs branch from 29ced70 to 50333b0 Compare July 17, 2026 04:18
@quickbeard quickbeard changed the title feat: delete CoDev-authored configs on remove instead of keeping them feat: delete backup-less configs on remove and restore (revert #196) Jul 17, 2026
@quickbeard quickbeard closed this Jul 17, 2026
@quickbeard
quickbeard deleted the feat/remove-deletes-codev-authored-configs branch July 17, 2026 04:22
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