Guides / releases / unreleased · Edit on GitHub

Unreleased (post v0.4.19)

<!-- Add bullets here during development; move to docs/releases/v0.4.x.md at tag time. -->

Clone detection (#37)

First-class rgctl clones — whole-function and sub-function duplicate detection, distinct from semantic query. Query-time / sidecars only (no default discover cost; Gate A unchanged). Does not write clone edges into graph.snapshot.bin.

rgctl discover .                      # exact / bloom
rgctl discover . --with-cfg           # faster fragment path (CFG archive)

rgctl -f json clones --mode exact --min-loc 5 --exclude test
rgctl -f json clones --mode bloom --threshold 0.85 --exclude test
rgctl -f json clones --mode fragment --seed src/Foo.java:40-52
rgctl -f json clones --mode fragment --seed PaymentService::processRefund --lines 45-55

Modes

ModeUnitSignalHonesty
exact (default)Whole functionEqual non-empty code_hash (Type-1)Exact body match
bloomWhole functiontoken_bloom Jaccard (LSH bands; default threshold 0.85)candidates: true — noisy near-dupes
fragmentSub-function (3–15 stmts)CFG SESE hammocks + 1-WL structural hashSchema v2; structural match (rename-tolerant kinds)

Reserved (error): semantic / structural as clone modes.

Exact & bloom

  • Filters: --min-loc (default 5), --exclude (path component match — test ≠ rgctl-tests), --lang.
  • Symbol-scoped: rgctl clones SYMBOL [--file|--class|--line] (same QE as callers).
  • Sidecars: .rgctl/clones.json, .rgctl/clones.bloom.json (digest-keyed; --no-write / --no-cache).

Fragment (SESE + 1-WL)

  • Requires useful CFG: prefer discover --with-cfg (archive fast path); otherwise on-demand parse for bloom-pruned candidates.
  • Seed: --seed <SYMBOL|file:start-end> and/or --lines START-END; bounds --min-statements / --max-statements (defaults 3 / 15).
  • Two-stage retrieval: function token_bloom coarse filter → SESE + 1-WL on candidates.
  • Sidecar: .rgctl/clones.fragment.json.
  • Analysis crates: sese, wl_hash, fragment_clones (+ post-dominator helpers).

Docs & agents

  • Guide: Clone detection
  • Design: clone-detection-design.md
  • JSON API §16b; skill encyclopedia + workflows recipes
  • Fixture / tests: rgctl-tests/clone-exact, tests/clone_exact_integration.rs, tests/clones_integration.rs