Skip to content

Compact mode: fix four restore defects, drop the savings wording - #75

Open
ExJtac wants to merge 1 commit into
mainfrom
fix-compact-restore
Open

ExJtac wants to merge 1 commit into
mainfrom
fix-compact-restore

Conversation

@ExJtac

@ExJtac ExJtac commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Review item 4. One fix, four defects, all in compact mode's on/off/undo path.

What changes

  • a) undo after compact off put the block back. undo now passes over a compact off and the compact on it took out, and reverses the change before them. With nothing before them it says so and changes nothing. Manifests record "compact": "on"/"off"; manifests from 0.9.6/0.9.7 are read by profile and title.
  • b) compact off left an empty file where compact on had created it. It now deletes the file (backed up first). New change kind delete in apply_changes; undo_manifest restores a deleted file and refuses if a new file is in its place.
  • c) Two blocks when setup's rules block was added after a standalone compact block. add_rules_block now moves the compact rules inside the new block, short form: one block, no rule twice.
  • d) Mixed CRLF/LF not restored byte for byte. compact on no longer rewrites any existing line ending (the block uses the file's majority ending). compact off on a file unchanged since compact on puts the backup bytes back. Files are read and written as bytes, so non-UTF-8 bytes survive.
  • Wording: compact mode is "shorter, cleaner reports". No savings claim (bench ratio 0.97).

Tests

  • 17 new tests in tests/test_compact.py (8 line-ending cases parametrized).
  • Full suite: 563 passed, 1 skipped.
  • Network denied (sandbox-exec deny network*, -m 'not p00_outer'): 557 passed, 6 skipped (loopback-only tests), 1 deselected.

Not sure about

  • A file edited between compact on and compact off gets text removal, which cannot tell whether a blank line before the block was there before. Byte-exact restore holds only for the unchanged file.
  • Order compact on → setup → compact off → undo: undo of setup refuses CLAUDE.md (changed since setup), as for any file edited after setup. It does not put the compact block back. Existing behaviour, seen here: the setup steps before that file are already undone when it refuses.

🤖 Generated with Claude Code

- undo after `compact off` no longer puts the block back: undo passes over
  the off switch and the `compact on` it took out, and reverses the change
  before them.
- `compact off` deletes a file that `compact on` created when nothing else
  is in it (backed up first; new "delete" change kind, undo restores it and
  never writes over a new file).
- setup on a file with a standalone compact block leaves one block.
- Mixed CRLF/LF, no final line ending and non-UTF-8 bytes come back byte
  for byte: no existing line ending is rewritten, and off on an unchanged
  file puts the backup back.
- Described as "shorter, cleaner reports"; no saving claimed (bench 0.97).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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