audit: a renamed clone file with a line shift in the other instance reports the group as introduced
Problem
fallow audit reports a clone group as introduced when the change renames one file of the group and also moves the clone in the other file by some lines. The clone existed at the base commit, so the group is inherited.
The drift harness found the case in release validation (i4_audit_splits_the_changed_head_findings, FALLOW_DRIFT_SEED=1794592235917689318, FALLOW_DRIFT_CASES=512). Fallow 3.42.0 and 3.43.0 both show it.
Reproduction
Base commit:
src/f0.tsandsrc/f3.tseach hold the same 14-line functioncompute.src/f3.tsimports one export ofsrc/f0.tsand one export ofsrc/f1.ts, on two lines.
Head commit:
git mv src/f0.ts src/r0.tsgit rm src/f1.tssrc/f3.tsimports only from./r0, so its copy ofcomputestarts one line earlier.
Run fallow audit --base HEAD~1 --format json --quiet.
Expected
The clone group src/f3.ts and src/r0.ts has introduced: false, and attribution.duplication_inherited is 1.
Actual
The clone group has introduced: true, attribution.duplication_introduced is 1 and duplication_inherited is 0.
When the head keeps both import lines of src/f3.ts in a different order, so that the clone stays on the same lines, the group is inherited. The rename alone is thus not the cause. The cause is the rename together with a line shift in the other instance.
Impact
With --gate new-only, a rename of a file that holds a clone can fail the audit for a duplication that the change did not create.
Done when
- The case above gives
introduced: false. crates/cli/tests/drift/drift.proptest-regressionsholds the failed case, so the harness replays it on each run.