Skip to content

Preserve attribution across commit-time line reordering#1967

Open
svarlamov wants to merge 1 commit into
mainfrom
agent/fix-1845-reordered-carryover
Open

Preserve attribution across commit-time line reordering#1967
svarlamov wants to merge 1 commit into
mainfrom
agent/fix-1845-reordered-carryover

Conversation

@svarlamov

@svarlamov svarlamov commented Jul 23, 2026

Copy link
Copy Markdown
Member

Fixes #1845

Summary

  • treat checkpoint and committed snapshots containing the same line multiset as a commit-time reorder instead of three-way merging both insertion positions
  • rebase checkpoint attribution through single-line moves so import sorters preserve ownership
  • retain genuine observed-only reorderings when the committed side is unchanged

Root cause

When a formatter or import sorter reordered AI-added lines after the AI checkpoint but before commit, carryover reconciliation treated the old and new insertion positions as independent changes. The synthetic carryover snapshot duplicated the moved lines. Attribution followed those duplicate ghost lines into INITIAL, leaving the actual committed lines untracked even though the referenced blob still existed.

This is platform-independent and reproduces the macOS reports without requiring pre-v1.6 data or CRLF conversion.

Test coverage

  • added a TestRepo integration regression covering scrambled AI imports sorted before commit
  • verifies pre-commit status reports 4 AI / 0 unknown
  • verifies committed blame and stats remain 4 AI / 0 unknown
  • verifies a clean commit leaves no phantom INITIAL attribution
  • added unit coverage for duplicate lines and observed-only reorder carryover

Validation

  • task test
  • task lint
  • task fmt
  • task build

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@svarlamov svarlamov changed the title Preserve attribution across commit-time line reordering (#1845) Preserve attribution across commit-time line reordering Jul 23, 2026

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

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.

All AI-authored code becomes "untracked" after commit in existing repositories

1 participant