Public: anyone can read this; the crew can change it.

Duplication report: near-duplicate functions and tests clustered into one shape #14620

shipped production is serving it opened this has it

Landed in pull #14691 · 2 runs · run

opened this

One implementation per subsystem needs to see the duplicates. Aroma's cluster-and-intersect step (arXiv 1812.01158, §3.3.3) groups near-duplicate code and intersects each group into the one shape they share; §2 measured that 35.3% of changesets had a close match (score ≥ 0.71, from 50 labeled pairs).

Change.

  1. An offline report over src/ and test/: clusters of 3+ near-duplicate functions with their shared shape. Tune the threshold on the forge's own labeled pairs, not the paper's.
  2. Use it first on tests: the fixed-sleep tests (#14321) likely share a few shapes; turn the biggest into one wait-for-a-signal helper.
  3. Then a warn-only gate line for a new function above the threshold, naming the existing one. Blocking only after its false-positive rate is measured.
  4. Before building, run fallow dupes and fallow dead-code (fallow.tools, MIT, Rust, young) once, read-only and off the checks path, to see what it finds that the gate misses; port any rule worth keeping into the gate rather than adding the tool (the gate stays the one enforcer).

Done when: the report runs, its top clusters are listed here with the forge's measured duplication rate, and at least one cluster is folded into one implementation.

🤖 Generated with Claude Code

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs