Repository navigation
fix(code-review): show BHA the old version of moved files - #320
Merged
Merged
Conversation
PLN-2214 PR 3 (ISS-12737): pair moved-and-edited files at 30% similarity, write the old file's patch as partition context, fold it into the BHA cache key. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…ile-context # Conflicts: # CHANGELOG.md
…ile-context # Conflicts: # CHANGELOG.md
…ile-context # Conflicts: # CHANGELOG.md
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.
Campaign chunk C3 of 3 (sequential, last): show Bug Hunter A the old version of moved-and-edited files.
Implements PLN-2214 · PR 3 for ISS-12737 (plan). Builds on #315 and #319 (merged).
code-review3.12.1 → 3.12.2.Why
When a file is moved and heavily edited, git's default rename detection (50% similarity) reports a deletion plus an addition. Since #319, deleted files no longer go to Bug Hunter A, so it sees the moved file as brand new and can't notice behaviour dropped in the move.
A dry run over recent merged PRs found this in about 1–2% of PRs:
What changes
parse-diffruns one extragit diff --name-status -M30%. Each deleted file that pairs with an added file only at the looser threshold is recorded asdiff_data.moved_from[<new>] = <old>.files_to_reviewandfile_statusesare unchanged, and the key is emitted only when non-empty.partitionwrites the old file's patch topatches_p<N>_context.txtfor each partition holding a paired file, and recordsmoved_fromandcontext_patchon that partition entry.context_patch, Bug Hunter A gets a<moved_from_context>element. It is reference only: compare it with the new file to find behaviour dropped in the move, and point findings at the new file. The pairing is heuristic and the old file may be unrelated.Acceptance ledger
11 criteria: 10 met, 1 met differently, 0 not met.
The met-differently criterion ("BHA reports the dropped guard on the new file") needed a live review, so the build proved only the parts that don't need one. It was then proven live: a headless
/code-review:startloading this branch's plugin (--plugin-dir) on a test repo wheresrc/store.pywas moved tosrc/persistence/records.py(R038, so default detection reports a delete plus an add) and itsif record is None: raise KeyError(key)guard was dropped.moved_fromrecorded the pair.patches_p0_context.txtheld the whole old file, guard included. It was Bug Hunter A's only view of the guard, since the main patch has nostore.pyhunk.records.py:17, and the verifier confirmed it at HIGH. The review used the full fleet, not the fast path.Deviations from the plan
moved_fromholds only pairs whose new path isaddedand old pathremovedat default similarity. Renames git already detects are diffed in place, so a context patch would be empty.compute-hasheswas left alone; the per-file BHA key is computed in cache-check and cache-update, so the old file's patch is folded in there.context_patchinpartitions.jsonrather than a file on disk, so a stale context file from an earlier run can't be picked up.uncached_diff_data.jsonalso carriesmoved_from.Review
/code-review:deep: APPROVED. All 7 reviewers ran (Bug Hunter A and B, Unified Auditor, Design Critic, three domain critics). One verified finding, downgraded to LOW:_write_per_partition_patchesaddsmoved_fromandcontext_patchto the caller's partition dicts as a side effect. Declined. It is documented, confined to one private helper with a single caller, and partly intentional: only the writer knows whether the context file was written. Moving it would reshape the helper's return type and tests with no behaviour change.No code changed after review, so no re-review was needed. Both the review and the live run used this branch's in-repo helpers because
CLAUDE_PLUGIN_ROOTwas empty; the separate pipeline-bugs PR fixes that.origin/mainwas merged in to resolve a CHANGELOG-only conflict with vibe v1.0.60 and v1.0.61; all entries were kept verbatim.Verification
uv run pytest plugins/code-review/tools/python/ -q: 1441 passed, 3 skipped (also after the main merge).uv run ruff check .: pass.uv run pyright: 0 errors.Still owed
Nothing. This is the last chunk of PLN-2214.
Version note: #321 released 3.12.1 first, so this PR was re-synced with
mainand re-bumped to 3.12.2. Its changelog entry was regenerated with/update-documentation, and tests, ruff and pyright pass on the merged tree (1464 passed). #321 and this PR change different functions incode_review_helpers.py, so none of their changes overlap.