Repository navigation
feat(metrics): add Clone-family clustering and opt-in near-clone detection - #204
Merged
Merged
Conversation
Cluster overlapping and transitively related exact Clone group fragments across three or more locations into unified Clone families using connected components (union-find) in crates/metrics, ordered worst-first by unique duplicated lines without double-counting and with deterministic canonical location ordering and stable FindingIds. Expose Clone families across TOON, JSON, SARIF, Markdown, diff, and codeint mcp while preserving existing Duplication and Verbosity ratios and Reference ranges identically. Closes #196
… gating Add opt-in shingle/Jaccard near-clone detection configured via duplication.near_clones (default false) and duplication.min_similarity (default 0.85, validated in (0, 1]) in codeint.json and schema/codeint.schema.json. Use deterministic MinHash/LSH candidate pruning over normalized tokens with import-or-export exclusions and minimum token/distinct-token guards, report similarity ratios and percentages across JSON, TOON, SARIF, Markdown, diff, and codeint mcp, cluster overlapping exact and near-clone fragments into Clone families with stable FindingIds, gate new near-clone Regressions in codeint diff, and keep Verbosity coupled only to exact Clone groups. Closes #197
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Clone-family clustering (grouping 3+ overlapping or transitively related exact or near-clone fragments into worst-first Clone families across TOON, JSON, SARIF, Markdown, and MCP without double-counting) and opt-in bounded shingle/MinHash/LSH near-clone detection (
duplication.near_clones,duplication.min_similarity) withcodeint diffRegression gating while keeping exact Clone groups as the default.Closes #174
Closes #196
Closes #197
Tier
Tier 3 from the tier check:
crates/cli/tests/check.rsupdates the unknown-key error assertion to include the newduplicationkey incodeint.json.Task
Spec #174 and sub-issues #196, #197:
duplication.near_clones,duplication.min_similarityin(0.0, 1.0]), similarity ratios in reports, Clone-family integration, andcodeint diffRegression gating (Opt-in shingle-based near-clone detection (near_clones,min_similarity) and diff gating #197)Fail-first test
crates/metrics/src/duplication.rs(three_copies_across_files_form_one_clone_family_in_canonical_order,near_clones_enabled_catches_one_line_edit_with_similarity_and_keeps_exact_lines_separate) andcrates/cli/tests/diff.rs(diff_gates_new_near_clones_and_classifies_unchanged_near_clones_by_stable_id)Checks
cargo test --workspace --lockedcargo clippy --workspace --all-targets -- -D warningscargo fmt --checkcodeint diff 0e8977elefthookpre-commit and commit-msgcargo run --package xtask -- merged-result)Safety proof
duplication.near_clones: false), exact Clone group ratios and Verbosity remain strictly unchanged, andclone_familiesis omitted from JSON/TOON when empty.crates/metrics/src/duplication.rs(near_clones_off_by_default_leaves_edited_copy_undetected),crates/cli/tests/check.rs(143/143),crates/cli/tests/diff.rs, andcrates/cli/tests/mcp.rsall pass with zero regressions oncodeint diff 0e8977e.interrogate: Round 1 Independent Review + adversarialinterrogatecaught 7 verified issues, all fixed with regression tests in7d5e5bband merged withmain(0e8977e) at3514efb. Round 2 clean rerun verified all 7 fixes and caught 1 saved-report parity edge case (codeint report --format sarifleaking raw memberCloneGroups for truncated families ranked past top 20), fixed in8dfebcfvia optionalunlisted_clone_family_group_ids. Round 3 clean rerun on8dfebcfpassed with Verdict: PASS (0 open verified findings).Runtime evidence
End-to-end CLI and MCP integration tests executed the compiled
codeintbinary on revision8dfebcfacross multi-file TypeScript/Rust fixtures and temporary Git repositories (check,diff,mcp,referencetest suites all passed, andcodeint diff 0e8977eexited 0 with zero regressions).Gaps