Skip to content

Backups: never prune a file's original backup before anything else - #534

Draft
raiseCatError wants to merge 1 commit into
fix/host-probe-late-replies-20261029from
fix/backup-retention-originals-20261029
Draft

raiseCatError wants to merge 1 commit into
fix/host-probe-late-replies-20261029from
fix/backup-retention-originals-20261029

Conversation

@raiseCatError

Copy link
Copy Markdown
Owner

Stacked on #533.

Bug (found in headless acceptance QA of /changes; repro iso/retention.mjs): above 200 entries, the journal prunes oldest first. It kept only the newest 20 reset/restore/manual entries and the newest entry per (source, path). So two appearance edits of kitty.conf followed by 260 automatic cursor-shader writes pruned the first kitty.conf backup, the only copy of the user's config from before NMSh touched it. On the maintainer's real machine NMSh wrote 16 cursor-shader backups in about 75 s, so 200 entries is roughly 15 minutes of such activity.

Fix (src/backups/journal.ts): the oldest entry of every file path is pruned only as a last resort, after every unprotected entry has gone. Existing guarantees are unchanged, including the tiny-cap case in "the newest source/path anchor is retained…".

Tests

  • New: tests/backupsJournal.test.ts "a burst of automatic writes to another file never prunes the original backup…". It fails without the fix and passes with it.
  • backupsJournal, backupsRestore, backupsPanels: 45/45.
  • configurationPersistence, shellFrameworks, starshipConfigAdapter: 26/26.
  • tsc is clean.
  • Repro at the real cap (200): before the fix only the second appearance backup was kept; now both are.

Other findings from the same QA, not fixed here (follow-ups):

  • D2: theme-bridge/ledger.json is rewritten on every launch without a backup, so most entries show "edited since". Restoring an older entry reverts the ledger and drops vim ownership.
  • D3: one unreadable recorded path (a directory replaced by a file) makes every later config write fail ("A configuration parent is not a directory"), and /changes names neither the entry nor the cause.
  • D4: an entry left prepared by a killed write is not flagged as interrupted.
  • D5: labels like "appends 2 lines at the end" or "1 files" name no tool or file.
  • D6: a reset records two near-duplicate entries, and the footer says "Enter confirm write" on steps that only advance.
  • D7: "NMSh settings → defaults" also resets onboarding flags and sets updateMode to automatic.

Pruning (oldest first above 200 entries) kept only recent protected
entries and the newest entry per source/path. A burst of automatic
writes (cursor shaders: 16 in 75 s on a real session) could push out
the first backup of the terminal's main config, the only copy of what
it was before NMSh. The oldest entry of every file path is now pruned
only as a last resort, after every unprotected entry.

This branch has not been deployed

No deployments
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