Skip to content

Fix phantom file carry-forward causing lingering shadow branches#586

Merged
khaong merged 4 commits intomainfrom
alex/more-e2e-fixes
Mar 4, 2026
Merged

Fix phantom file carry-forward causing lingering shadow branches#586
khaong merged 4 commits intomainfrom
alex/more-e2e-fixes

Conversation

@khaong
Copy link
Contributor

@khaong khaong commented Mar 3, 2026

Summary

  • Fixes E2E failures (TestMixedNewAndModifiedFiles, TestPartialStaging) caused by phantom file paths in filesTouched creating infinite carry-forward loops
  • Phantom files are paths captured from agent transcript tool calls that were never actually created on disk (e.g., Gemini writes src/types.go in a tool call but actually creates src/types/types.go for Go package structure)
  • filesWithRemainingAgentChanges now checks shadow tree existence before carrying forward non-committed files — the shadow tree is the ground truth since buildTreeWithChanges already skips non-existent files

Failing E2E runs

Test plan

  • Added TestFilesWithRemainingAgentChanges_PhantomFile unit test
  • All existing tests pass (mise run test:ci)
  • Lint clean (mise run lint)
  • E2E: TestMixedNewAndModifiedFiles and TestPartialStaging should stop failing for gemini-cli

🤖 Generated with Claude Code

Agent transcript parsers capture file paths from all tool calls, including
ones that were attempted but never created on disk (e.g. agent writes
src/types.go but creates src/types/types.go instead). These phantom paths
in FilesTouched caused filesWithRemainingAgentChanges to always return
non-empty results, creating an infinite carry-forward loop where shadow
branches were never cleaned up.

Fix: for non-committed files, also check the shadow branch tree before
carrying forward. buildTreeWithChanges already skips non-existent files,
so the shadow tree is the ground truth of what was actually checkpointed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 95bb0b3d0af0
Copilot AI review requested due to automatic review settings March 3, 2026 05:36
@khaong khaong requested a review from a team as a code owner March 3, 2026 05:36
@cursor
Copy link

cursor bot commented Mar 3, 2026

PR Summary

Medium Risk
Adjusts carry-forward file selection logic used in checkpoint/shadow-branch management; a mistake could cause missed carry-forward or lingering shadow branches, but the change is small and covered by new unit tests.

Overview
Prevents infinite carry-forward loops by changing filesWithRemainingAgentChanges to skip any filesTouched entries that are not present in the shadow tree (treating the shadow tree as the ground truth), including phantom transcript paths and agent-deleted files.

Adds unit coverage for the two edge cases: a phantom path referenced in the transcript but never created, and an uncommitted deletion where the file is absent from the shadow tree.

Written by Cursor Bugbot for commit c283dc8. Configure here.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes carry-forward logic in the manual-commit shadow-branch strategy by preventing “phantom” file paths (captured from agent transcripts but never materialized in the shadow tree) from being repeatedly carried forward, which can create lingering shadow branches and E2E failures.

Changes:

  • Update filesWithRemainingAgentChanges to skip uncommitted paths that aren’t present in the shadow tree (treating the shadow tree as ground truth for what the agent actually produced).
  • Add a unit test covering the phantom-file scenario to prevent infinite carry-forward loops.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
cmd/entire/cli/strategy/content_overlap.go Adds a shadow-tree existence check before carrying forward uncommitted touched paths.
cmd/entire/cli/strategy/content_overlap_test.go Adds a unit test ensuring phantom transcript paths don’t get carried forward.

gtrrz-victor
gtrrz-victor previously approved these changes Mar 3, 2026
khaong and others added 2 commits March 4, 2026 10:57
Move the shadow tree existence check to the top of the loop instead of
nesting it inside the wasCommitted branch. Both code paths (committed
and uncommitted) skip files absent from the shadow tree, so a single
early guard is equivalent and clearer.

Add a test for the uncommitted-deletion scenario to document that
skipping agent-deleted files is intentional (no content on disk to
carry forward).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Entire-Checkpoint: 04e65de01f59
@khaong
Copy link
Contributor Author

khaong commented Mar 4, 2026

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@khaong khaong merged commit 4698d3d into main Mar 4, 2026
4 checks passed
@khaong khaong deleted the alex/more-e2e-fixes branch March 4, 2026 01:48
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.

3 participants