Skip to content

[bug]Fix rewind of tracked checkpoint deletions#1408

Open
stale2000 wants to merge 1 commit into
entireio:mainfrom
stale2000:codex/fix-rewind-tracked-deletes
Open

[bug]Fix rewind of tracked checkpoint deletions#1408
stale2000 wants to merge 1 commit into
entireio:mainfrom
stale2000:codex/fix-rewind-tracked-deletes

Conversation

@stale2000

@stale2000 stale2000 commented Jun 10, 2026

Copy link
Copy Markdown

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 rewind is 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 HEAD but absent from the checkpoint. That could leave stale files on disk after rewind.

Concrete example

Start with the current branch containing two tracked files:

HEAD / working tree before rewind
├── keep.txt
└── delete-me.txt

The selected checkpoint represents this state:

checkpoint tree
└── keep.txt

delete-me.txt is not in the checkpoint because it had been deleted when the checkpoint was created.

Old behavior after rewind:

working tree after rewind, before this fix
├── keep.txt        restored correctly
└── delete-me.txt   BUG: stale tracked file remained

New behavior after rewind:

working tree after rewind, with this fix
└── keep.txt

Why deletion is safe here

This does not blindly delete arbitrary files. The new deletion pass is scoped to files that are:

  • tracked by the current HEAD commit, meaning the current branch commit contains that path
  • absent from the selected checkpoint tree
  • outside protected paths such as .git, .entire, and agent config directories

Existing untracked-file protections still apply. Untracked files that existed at session start are preserved, and ignored directories are not walked.

What changed

  • Rewind now compares tracked HEAD paths with the selected checkpoint tree before restoring present files.
  • Tracked files missing from the checkpoint are removed from the working tree.
  • PreviewRewind reports those tracked deletions so interactive users can see the files that will be removed.
  • Added a regression test for a checkpoint that deletes a tracked file.

Verification

  • mise run lint
  • go test ./cmd/entire/cli/strategy -run 'TestShadowStrategy_(PreviewRewind|Rewind_)' -count=1
  • go test ./cmd/entire/cli/strategy ./cmd/entire/cli/checkpoint

Notes

Full mise run check was attempted, but currently fails in unrelated date-sensitive test TestRunAuthStatus_RendersSessionsTable: expected 2026-01-01, output rendered 2026-01-31. Strategy/checkpoint tests passed during that run.

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
@stale2000 stale2000 requested a review from a team as a code owner June 10, 2026 22:42
@stale2000 stale2000 changed the title Fix rewind of tracked checkpoint deletions [bug]Fix rewind of tracked checkpoint deletions Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant