Skip to content

feat: protect later file changes from undo - #61

Merged
he-yufeng merged 2 commits into
mainfrom
feat/safe-undo-20261114
Nov 17, 2026
Merged

he-yufeng merged 2 commits into
mainfrom
feat/safe-undo-20261114

Conversation

@he-yufeng

@he-yufeng he-yufeng commented Nov 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

/undo now protects work that landed after an agent edit instead of silently replacing it with an older snapshot.

Each checkpoint records both the previous bytes and the bytes produced by the edit. Before undoing, CoreCoder compares the current file with that recorded result. If a manual edit or bash changed the file again, it keeps the newer contents and the checkpoint and explains why the restore was skipped. A file removed along with its parent tree still restores as before. Existing checkpoint files without the new field remain readable.

This stays inside the existing checkpoint stack and the two file-writing tools. It adds no new command, dependency or background service.

Validation

The three new conflict regressions fail on current main: undo overwrites a later manual edit, deletes a created file after it was replaced, and loses the retained checkpoint sequence. A legacy-format compatibility case passes before and after.

On this branch:

  • Focused checkpoint, file-tool and slash-command coverage: 73 passed.
  • Full offline suite after merging current main: 360 passed, with the live smoke test excluded.
  • ruff check corecoder tests: passed.
  • git diff --check: passed.

The README badges, prose, per-file counts, test total and package description are updated from the current tree. No live model or external service was used.

Merge update

Merged current main in 96160d9aaf75b60bb30627c13d7ad4c38666dffa, including #64's rolling-summary fix. The conflicts were limited to documentation counts. Both feature sets and both regression suites remain in the combined tree. The README and package counts were recomputed from the merged source: 1,515 engine LoC, 3,343 physical package lines, 2,762 net lines and 360 offline tests. ruff check corecoder tests passes. Full-file ruff format still reports the same pre-existing formatting drift seen on both parents; no broad reformatting was added.

Record the bytes produced by each file mutation alongside its prior
state. Before restoring a checkpoint, compare an existing file with that
recorded result and keep both the file and checkpoint when they differ.
Legacy checkpoints remain readable, and a deleted parent tree can still
be restored as before.

The manual-edit, replaced-created-file and retained-checkpoint cases
fail on main. The full offline suite passes 357 tests with one opt-in
skip, and ruff check corecoder tests passes. README line counts and test
totals are updated from the current tree.
# Conflicts:
#	README.md
#	README_CN.md
#	article/00-index.md
#	article/00-index_EN.md
@he-yufeng
he-yufeng merged commit 8df74b8 into main Nov 17, 2026
14 checks passed
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