fix(co-occurrence): clone gate vacuous on .mts/.mjs — CODE_EXT dropped module-suffixed extensions - #305
Conversation
…d module-suffixed extensions The post-filter kept only .ts/.tsx/.js/.jsx, but devkit's own scanRoots (cli, gate-engine) are pure .mts — jscpd tokenizes mts/cts as typescript and mjs/cjs as javascript and reported the clones, then CODE_EXT discarded every one. `guard-clone scan` returned 0 repo-wide while raw jscpd found real clones (verified during #303's gates): a silently dead gate. With the fix the same scan reports 62 cross-file clones (min-tokens 50), dominated by the review/eval vs review/eval/conventions bench+matcher family. Regression tests: .mts and .mjs clone fixtures must block (exit 1). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 18 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…at the tokenizer Two modules using the same shared libs are forced into identical, linter-sorted import blocks — the module system working, not copy-paste debt — and a big enough preamble clears jscpd's 50-token floor on its own, false-blocking any commit touching sibling files once the gate is wired into hooks (post-#305 the repo scan showed two such blocks). Imports are now removed from the token stream itself via jscpd --ignore-pattern (four bounded, comma-free regexes: named/multi-line, default/namespace single-line, side-effect, re-export barrels; dynamic import(...) deliberately matches none). The semantic becomes "clones are measured over non-import code": nothing can ride a preamble over the token floor, and nothing real can hide behind one. A post-hoc fragment classifier was tried first and abandoned after six opus-confirmed reviewer holes across seven gate rounds (ratio leaks, dynamic import absorption, quote-terminated statements, import attributes, ...) — each patch surfaced the next hole because classifying jscpd's token-boundary fragments after the fact is unfixable by construction. The adversarial cases live on as end-to-end gate-contract tests: preamble-only pair passes, a real body behind identical imports still blocks, a duplicated dynamic-import block still blocks. Live scan 62 -> 60; the dropped sync-agents fragment's residual interface dup is sub-floor on its own merits (it only crossed 50 tokens by riding the imports). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…clone-gate ruling (#310) benchmarks-grow-from-telemetry gains its convergence record before the release that ships it: capture loop closed end-to-end (#295/#302/#303/#309, first 8 pure-telemetry rows, corpus 128), label-trust precondition met (#304: κ 0.735 post-triage, 4.2% noise floor; cleanlab floor still pending bench pred_probs), and the Target's c-CRAB/CR-Bench known-answer path recorded as falsified (#307) with the replacement candidates awaiting ratification. New axis clone-gate-non-import-code ([VALIDATED]): clones are measured over non-import code, excluded at the jscpd tokenizer — with the six-hole failure of post-hoc fragment classification recorded as the rejected road so a future simplifier can't silently re-vacuous the gate (#305/#308). Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
…rerequisite (sc-1414) (#311) The repaired clone gate (#305/#308) goes live in consumer hooks at the next release; without a baseline every commit touching a cloned file blocks on debt that predates the gate working. `guard-clone json | guard-dup-allowlist baseline-clones` freezes all 60 as decaying baseline entries (the matcher baseline burn-down pattern). Disposition choice: baseline ALL 60, not just the 43 eval-harness clones — leaving the 16 product clones unbaselined would block unrelated commits touching those files before the dedup work (sc-1414 part 2) lands. Baseline entries decay, so the product clones resurface on schedule; the eval-harness family stays frozen deliberately (deduping it would drift published runner/scorer checkpoint hashes for 2-3 suites — the overrides.mts precedent), as does the deliberate run-review<->bench mirror. Gate verified clean after: scan --gate exit 0. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
The bug (gate integrity hole, flagged by the opus reviewer during #303's gates)
guard-clone scanreported 0 clones repo-wide while raw jscpd found real ones. Root cause: the post-filterCODE_EXT = /\.(tsx?|jsx?)$/kept only.ts/.tsx/.js/.jsx— but devkit's owncloneRoots(inherited fromscanRoots = ["cli", "gate-engine"]) are pure.mts. jscpd tokenizesmts/ctsas typescript andmjs/cjsas javascript and duly reported the clones; the filter then discarded every one. The gate has been silently dead on this repo (and any.mts/.mjsconsumer) since it shipped — the allowlist has zero clone entries because nothing ever surfaced.The fix
CODE_EXT→/\.([cm]?[tj]s|[tj]sx)$/(adds.mts .cts .mjs .cjs, exactly the extensions jscpd tokenizes)..mtsand.mjscross-file clone fixtures must block (exit 1). All 28 detector tests pass; full suite green (182 files / 3087 tests). Empirical repro: identical fixture pair → 1 clone as.ts, 0 as.mtsbefore the fix; 1/1 after,.tsunchanged.What it surfaces (heads-up, not part of this PR)
Repo-wide scan now reports 62 cross-file clones (min-tokens 50), dominated by the
review/evalvsreview/eval/conventionsbench+matcher family (~20 clones — the conventions eval harness is a copy) plus a 23-linesync-agents/sync-skillsblock. Once a release wires the fixed gate into hooks, commits touching those files will block until each clone is fixed or approved. The designed migration path already exists:freezes the pre-existing clones as decaying
baselineentries (same pattern as the matcher baseline burndown). Preference order: dedupe the copied eval harness (real DRY debt), baseline the rest. No baseline is pre-seeded here — running it is a repo-owner call.🤖 Generated with Claude Code