fallow icon indicating copy to clipboard operation
fallow copied to clipboard

audit: a renamed clone file with a line shift in the other instance reports the group as introduced

Open BartWaardenburg opened this issue 3 weeks ago • 0 comments

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.ts and src/f3.ts each hold the same 14-line function compute.
  • src/f3.ts imports one export of src/f0.ts and one export of src/f1.ts, on two lines.

Head commit:

  • git mv src/f0.ts src/r0.ts
  • git rm src/f1.ts
  • src/f3.ts imports only from ./r0, so its copy of compute starts 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-regressions holds the failed case, so the harness replays it on each run.

BartWaardenburg avatar Nov 13 '26 19:11 BartWaardenburg