feat: delete backup-less configs on remove and restore (revert #196)#201
Closed
quickbeard wants to merge 1 commit into
Closed
feat: delete backup-less configs on remove and restore (revert #196)#201quickbeard wants to merge 1 commit into
quickbeard wants to merge 1 commit into
Conversation
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
force-pushed
the
feat/remove-deletes-codev-authored-configs
branch
from
July 17, 2026 04:18
29ced70 to
50333b0
Compare
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
Restores the pre-#196 behavior: when a config file has no
*.backupalongside it,restoreKinddeletes the live file instead of keeping it. Applies to bothcodevhub removeandcodevhub restore(sharedrestoreKind, 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":
removeis an uninstall and confirms before running, andrestoreis an explicit request for the pre-CoDev state.ensureBackuponly 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":
removeand the barerestoresweep all five tools unconditionally.~/.claude.jsonand~/.claude/.credentials.jsonride 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:
rmSyncthe live fileRestoreStatusdeleted-livekept-liverestoredcounts → an all-deleted run would exit 1 "No backups found"runRestoreOrDeletedeleted N file(s) (no backup)runRestoreOrKeep,kept N …keptPathsplumbingStepResult+RemoveResultfieldsRemoveApphintThe last three matter beyond naming:
keptPathsand the hint are dead code once nothing is ever kept, and the dedup guard onTOOLS/SWEEP_TOOLSis load-bearing again — a second visit really would delete the file the first visit just restored.Two deliberate deviations from the pre-#196 code
No backup at <backup>.and never mentioned the deletion. It now printsNo backup at <backup>; deleted <path>.— same behavior, honest output.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) /buildall 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.jsonwith project history,.credentials.jsonwith 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-hubwiped; no "delete manually" hint.codevhub restore—restore claudedeleted 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