test(strategy): prove dangling checkpoint trailer for IDLE + empty FilesTouched#1704
Draft
Soph wants to merge 1 commit into
Draft
test(strategy): prove dangling checkpoint trailer for IDLE + empty FilesTouched#1704Soph wants to merge 1 commit into
Soph wants to merge 1 commit into
Conversation
…lesTouched Add a failing (RED) regression test reproducing the silent prepare/post-commit mismatch: when a turn arrives without a TurnStart, the session stays IDLE with empty persisted FilesTouched and no shadow branch. PrepareCommitMsg still adds an Entire-Checkpoint trailer (it re-extracts edited files from the live transcript and overlaps them with staged files), but PostCommit computes filesTouchedBefore only from persisted FilesTouched for non-ACTIVE sessions and never feeds committed files into the overlap check. hasNew collapses to false and/or the overlap guard rejects condensation, so no checkpoint is materialized — the commit keeps a trailer pointing at nothing (dangling trailer). The test asserts the invariant the fix must restore: every trailer PrepareCommitMsg writes must correspond to a materialized checkpoint after PostCommit. It fails at that invariant on current code; the premise (trailer added via live transcript) and the two related existing IDLE tests still pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Entire-Checkpoint: 01KX6BJH6R8KQAAWRCDJC0V8GZ
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new strategy-layer regression test that reproduces a prepare-commit-msg vs post-commit mismatch where a commit can gain an Entire-Checkpoint trailer that points to a checkpoint that is never materialized locally (dangling trailer), particularly for IDLE sessions with empty FilesTouched.
Changes:
- Introduces a new (currently failing) regression test that sets up an IDLE session with no shadow branch and relies on live-transcript file extraction to trigger trailer insertion.
- Asserts the invariant that if
PrepareCommitMsgwrites anEntire-Checkpointtrailer,PostCommitmust materialize the corresponding checkpoint and metadata branch.
Comment on lines
+55
to
+57
| func TestPostCommit_IdleSession_NewLiveTranscriptEdits_DanglingTrailer(t *testing.T) { | ||
| dir := setupGitRepo(t) | ||
| t.Chdir(dir) |
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.
What
Adds a RED regression test that reproduces and proves a silent
prepare-commit-msg/post-commitmismatch: a commit can end up carrying anEntire-Checkpointtrailer that points at a checkpoint that was never materialized locally (a dangling trailer).This is a test-only, TDD-first PR — the test is intentionally failing and documents the invariant a follow-up fix must restore. CI will be red until the fix lands.
New file:
cmd/entire/cli/strategy/phase_postcommit_dangling_trailer_test.go→TestPostCommit_IdleSession_NewLiveTranscriptEdits_DanglingTrailer.Scenario (reconstructed from a real Pi session)
state.FilesTouched, stampsLastCheckpointID), then goes IDLE.SaveStepnever repopulatesFilesTouched. No shadow branch exists for the new edits yet.Root cause
PrepareCommitMsgre-extracts the edited files from the live transcript (sessionHasNewContentFromLiveTranscript), overlaps them with the staged files, and adds the trailer.PostCommitcomputesfilesTouchedBeforeonly from persistedstate.FilesTouchedfor non-ACTIVE sessions (the active-only fallback inmanual_commit_hooks.go:1246-1252) and never passes the committed files as an overlap signal. WithFilesTouchedempty and no staged files,hasNewcollapses to false and/or the guard inshouldCondenseWithOverlapCheck(len(filesTouchedBefore)==0 → return false) rejects condensation.Net: the commit keeps the trailer, but no checkpoint is ever written for it.
What the test proves
PrepareCommitMsgadds the trailer purely from the live transcript (log:prepare-commit-msg: trailer added ... checkpoint_id=...).PostCommit,entire/checkpoints/v1does not exist andLastCheckpointIDstays pinned to the prior checkpoint. The trailer dangles.Notes for the fix (out of scope here)
TestPostCommit_IdleSession_NoTranscriptFallbackForCarryForwardexplicitly asserts IDLE sessions must NOT re-extract from the transcript (it guards an earlier carry-forward + 3s sentinel-wait regression). A naive "always re-extract for IDLE" fix would re-break it.Verification
mise run fmt/mise run lint→ clean (0 issues).🤖 Generated with Claude Code
Note
Low Risk
Test-only addition with no production or hook behavior changes; CI failure is intentional until a separate fix.
Overview
Adds an intentionally failing regression test in
phase_postcommit_dangling_trailer_test.gothat locks in the invariant: ifPrepareCommitMsgadds anEntire-Checkpointtrailer,PostCommitmust materialize that checkpoint.The test simulates an IDLE session after condensation (
FilesTouchedcleared, priorLastCheckpointIDset) where new edits exist only in the live Gemini transcript (noTurnStart, no shadow branch).PrepareCommitMsgstill adds the trailer via live-transcript overlap with staged files;PostCommitcurrently skips condensation, soentire/checkpoints/v1is never created andLastCheckpointIDstays on the old ID—a dangling trailer. Comments point at a follow-up fix (e.g. persist prepare-hook association) without naively re-breakingTestPostCommit_IdleSession_NoTranscriptFallbackForCarryForward.Test-only change; CI is expected to stay red until the behavior fix lands.
Reviewed by Cursor Bugbot for commit c511f36. Configure here.