fix: keep one assignment per file when merging chunk groups - #68
Merged
Conversation
When a later diff chunk assigned more hunks of a file to a group that already held that file, _merge_chunk_groups appended a second GroupAssignment for the same path. validate_coverage accepted it (each hunk claimed once) but materialize_group_files wrote the file once per assignment, so the last assignment overwrote the first and the earlier hunks were silently missing from the committed branch. - _merge_chunk_groups merges same-path assignments (union of hunks, WHOLE_FILE wins). - materialize_group_files groups assignments by path and writes each file once from the union of their hunks, so duplicates from any source can no longer drop changes.
|
Warning Review limit reachedNext included review available in 48 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Seeding the per-path map with a dict comprehension kept only the last existing assignment for a path, so duplicates already present in the accumulated group (chunk 1 output is stored verbatim) lost hunks. Fold every existing and incoming assignment through _merge_assignment.
vitali87
force-pushed
the
fix/duplicate-file-assignments
branch
from
August 30, 2026 13:24
f106d69 to
10301b4
Compare
# Conflicts: # pr_split/diff_ops/reconstructor.py # tests/test_reconstructor.py
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.
Problem
For diffs that exceed the context window,
_plan_split_chunkedmerges each chunk's groups into the running catalog with_merge_chunk_groups, which didexisting.assignments.extend(cg.assignments). When chunk N+1 assigns more hunks of a file to a group id that already holds that file, the group ends up with twoGroupAssignments for one path, e.g.f.py [0]andf.py [1].validate_coveragepasses (each hunk is claimed exactly once), butmaterialize_group_filesdidresult[path] = apply_hunks(...)per assignment, so the second write replaced the first and hunk 0 was silently missing from the committed sub-PR branch. No error anywhere — the sub-PR just lacks part of the change.Fix
_merge_chunk_groupsnow merges same-path assignments: union ofhunk_indices,WHOLE_FILEwins overPARTIAL_HUNKS.materialize_group_filesgroups assignments by path and writes each file once from the union of every assignment's hunks (_assigned_hunk_indices), so a duplicate from any source (chunk merge, LLM output, hand-edited plan) can no longer drop hunks. Base content is fetched once per file instead of once per assignment.Tests
[0, 1]; WHOLE_FILE + PARTIAL → WHOLE_FILE; unrelated files untouchedgit showruns once); duplicate assignments on a new file produce the full file3 of 5 fail without the fix. 449 tests pass, ruff clean.