feat: duplication family — find_duplicates + drift_clones + find_similar #27

Open
opened 2026-07-20 22:38:21 +02:00 by buildagent · 1 comment
Member

Rank 6 of the 2026-07-20 index-data brainstorm (_prdoc/records/brainstorm-2026-07-20-index-data-catalog.md).

What: one fingerprint mechanism (ordered ref-sequence per symbol) powering three products: exact clone clusters (consolidation worklist), drift_clones (near-clones that have diverged — "copy 2 already differs, here's the behavioral delta"), and a pre-write find_similar point query ("does this helper already exist?") that prevents future duplication.

Why — it found a real bug: relative_path had drifted between index.rs and watcher.rs (Jaccard 0.82) — the watcher copy lacked ParentDir and single-file-root handling; fixed in v0.5.19 by consolidation. Scale: 58 clone clusters / 193 duplicate symbols / ~1,402 redundant lines (the parse() test helper copied 10x; workspace_root copied 6x despite tests/common/mod.rs existing). setup_logging drift (J=0.93) triaged as intentional (--log-json). The existing outline_hash column finds the m0016–m0019 migration template family for free.

Cost: small for exact clusters + find_similar (pure SQL); medium for drift pairs (Jaccard, name-blocked); no new data.

Rank 6 of the 2026-07-20 index-data brainstorm (`_prdoc/records/brainstorm-2026-07-20-index-data-catalog.md`). **What**: one fingerprint mechanism (ordered ref-sequence per symbol) powering three products: exact clone clusters (consolidation worklist), **drift_clones** (near-clones that have diverged — "copy 2 already differs, here's the behavioral delta"), and a pre-write `find_similar` point query ("does this helper already exist?") that prevents future duplication. **Why — it found a real bug**: `relative_path` had drifted between index.rs and watcher.rs (Jaccard 0.82) — the watcher copy lacked `ParentDir` and single-file-root handling; fixed in v0.5.19 by consolidation. Scale: 58 clone clusters / 193 duplicate symbols / ~1,402 redundant lines (the `parse()` test helper copied 10x; `workspace_root` copied 6x despite `tests/common/mod.rs` existing). `setup_logging` drift (J=0.93) triaged as intentional (`--log-json`). The existing `outline_hash` column finds the m0016–m0019 migration template family for free. **Cost**: small for exact clusters + find_similar (pure SQL); medium for drift pairs (Jaccard, name-blocked); no new data.
Author
Member

Triage: P2 — split by agent value

Implement in this order:

  1. find_similar(symbol|span) point query — prevents agents from creating another implementation.
  2. Exact duplicate clusters using existing fingerprints/outline hashes.
  3. Drift-clone analysis only after the first two are measured and trusted.

The first capability should be consumable by context_pack (#35), not required for its v1. Repository-wide clone inventories are secondary to the pre-write question “does this already exist?”. Every similarity result needs the compared evidence/features; avoid an unexplained scalar score.

### Triage: P2 — split by agent value Implement in this order: 1. `find_similar(symbol|span)` point query — prevents agents from creating another implementation. 2. Exact duplicate clusters using existing fingerprints/outline hashes. 3. Drift-clone analysis only after the first two are measured and trusted. The first capability should be consumable by `context_pack` (#35), not required for its v1. Repository-wide clone inventories are secondary to the pre-write question “does this already exist?”. Every similarity result needs the compared evidence/features; avoid an unexplained scalar score.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
h-dv/code-index#27
No description provided.