[bug]Fix rewind of tracked checkpoint deletions#1408
Open
stale2000 wants to merge 1 commit into
Open
Conversation
Checkpoint trees record deletions by omission, so rewind must reconcile tracked HEAD paths against the selected checkpoint before restoring files that are present. Without that pass, a file deleted by the checkpoint can remain in the working tree and silently produce a mixed state. Constraint: Rewind must avoid go-git hard reset/checkout paths that can delete ignored infrastructure directories Rejected: Preserve tracked files absent from the checkpoint | this keeps data but violates rewind's selected-checkpoint file-state contract Confidence: high Scope-risk: narrow Directive: Keep tracked-delete preview and restore behavior aligned; checkpoint omission is the deletion signal Tested: mise run lint Tested: go test ./cmd/entire/cli/strategy -run 'TestShadowStrategy_(PreviewRewind|Rewind_)' -count=1 Tested: go test ./cmd/entire/cli/strategy ./cmd/entire/cli/checkpoint Not-tested: mise run check currently fails in TestRunAuthStatus_RendersSessionsTable expecting 2026-01-01 while output renders 2026-01-31 Entire-Checkpoint: 73b83f41aa8f
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.
Entire Logs: https://entire.io/gh/stale2000/cli/session/019eb3a9-4eee-7440-ac23-ca4fbe5cdd38
COMMENTS:
I'm having a difficult time wrapping my head around this bug, but the logs pretty clearly keep insisting that there is an issue. It might be better to use this as a guideline to implement a fix because I don't really understand how the fix works.
What was broken
entire rewindis supposed to make the working tree match the selected checkpoint. Checkpoint trees represent deleted files the same way Git trees do: the deleted path is simply absent from the tree.Before this change, rewind only deleted extra untracked files and then restored files that were present in the checkpoint tree. It did not remove tracked files that were present in the current branch
HEADbut absent from the checkpoint. That could leave stale files on disk after rewind.Concrete example
Start with the current branch containing two tracked files:
The selected checkpoint represents this state:
delete-me.txtis not in the checkpoint because it had been deleted when the checkpoint was created.Old behavior after rewind:
New behavior after rewind:
Why deletion is safe here
This does not blindly delete arbitrary files. The new deletion pass is scoped to files that are:
HEADcommit, meaning the current branch commit contains that path.git,.entire, and agent config directoriesExisting untracked-file protections still apply. Untracked files that existed at session start are preserved, and ignored directories are not walked.
What changed
HEADpaths with the selected checkpoint tree before restoring present files.PreviewRewindreports those tracked deletions so interactive users can see the files that will be removed.Verification
mise run lintgo test ./cmd/entire/cli/strategy -run 'TestShadowStrategy_(PreviewRewind|Rewind_)' -count=1go test ./cmd/entire/cli/strategy ./cmd/entire/cli/checkpointNotes
Full
mise run checkwas attempted, but currently fails in unrelated date-sensitive testTestRunAuthStatus_RendersSessionsTable: expected2026-01-01, output rendered2026-01-31. Strategy/checkpoint tests passed during that run.