Untitled conversation
- User
[BUG][auto] duplicate-overlapping-clone-groups: same duplication emitted as two separate near-identical clone groups
Bug
pyscn's clone detector emits two separate clone groups that describe the same duplication relationship between the same two code fragments, with member windows shifted by exactly one line (the enclosing
with/header line). The result is a redundant clone group that inflatesclone_groupscount and the duplication percentage.This is related to but distinct from the (closed) #416
clone-overlapping-window-self-clone: #416 was about strict-subset members within a single group; here the redundancy is across two whole groups that are near-duplicates of each other.Reproducer
Repo:
Instagram/Fixit@bf8e1f55f8a606eae0f0c64bab575e84a2a608b3pyscn:v1.22.9bashcurl -fsSL "https://codeload.github.com/Instagram/Fixit/tar.gz/HEAD" | tar -xz pyscn analyze --json --no-open Fixit-*/In the resulting
analyze.json,clone.clone_groupscontains two groups that cover the same pair of fragments insrc/fixit/tests/smoke.py:json{ "id": 6, "type": 2, "similarity": 0.9692, "clones": [ {"location": {"file_path": ".../smoke.py", "start_line": 299, "end_line": 315}}, {"location": {"file_path": ".../smoke.py", "start_line": 318, "end_line": 334}} ] }, { "id": 14, "type": 2, "similarity": 0.9613, "clones": [ {"location": {"file_path": ".../smoke.py", "start_line": 298, "end_line": 315}}, {"location": {"file_path": ".../smoke.py", "start_line": 317, "end_line": 334}} ] }Both groups describe the duplication between the
subTest("lint")block and thesubTest("fix")block. Group 14's members each start exactly one line earlier than group 6's — that line is thewith self.subTest("lint"):/with self.subTest("fix"):header: - Assistant
Now I'll add the cross-group dedup pass to
group_dedup.go: - Assistant
Now wire it into
groupClonesWithStrategyinclone_detector.go: - Assistant
Now add tests covering the reported scenario and edge cases:
- Assistant
Now let's verify against the actual reproducer from the bug report:
- Assistant
One group was dropped (8 → 7). Let me confirm the dropped group was genuinely a covered duplicate:
- Assistant
Only one group appears to touch api.py — suspicious. Let me check full paths (filename collapsing may hide a second file):
- Assistant
Group 4 has no covering group — that drop is suspicious. Let me check for run-to-run nondeterminism (the LSH pipeline is parallel):
- Assistant
Now update the tests to reflect the similarity-preference semantics:
- Assistant
Fixit output is now identical before/after — no findings lost. Verify pair counts and duplication too:
- Assistant
Both identical on current main. Now run the full test suite:
- Assistant
All tests pass and formatting is clean. Final review of the complete diff:
- Assistant
The fix is complete. Summary of what was done:
Root cause
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.