fix(rees): replace greedy duplication-delta assignment with maximum matching - #4961
Conversation
…atching assignSurvivors used a first-come-first-claimed greedy walk to pair old duplicate blocks with surviving new occurrences. In an asymmetric scenario where one old block matches multiple new occurrences but a sibling old block matches only one of them, the greedy walk could let the first grab the occurrence the second needed, under-reporting a still-present duplicate pair as resolved. Replaces it with Kuhn's algorithm (an O(V*E) augmenting-path search) over the old/new candidate graph, computed in two phases so the existing abort-signal contract is unchanged: phase 1 builds the full adjacency matrix (the only part that calls longestSharedRun, so the only part that can be aborted), phase 2 runs the augmenting-path search purely over that already-known matrix. An abort during phase 1 discards everything rather than matching over incomplete candidacy data. Adds a regression test reproducing the exact asymmetric scenario (#4812), plus odd-count and phase-1-abort edge cases, and removes the "greedy (not globally optimal)" v1-limitation caveat from the analyzer's docs.notes in all three registration sites now that the gap is closed.
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
gittensory-ui | 5db4b9c | Commit Preview URL Branch Preview URL |
Jul 11 2026, 03:45 AM |
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-11 03:51:02 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 6 non-blocking
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
Visual preview
Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|


Summary
assignSurvivors's greedy, order-dependent old-to-new block assignment in theduplicationDeltaREES analyzer with a true maximum bipartite matching (Kuhn's algorithm, an O(V·E) augmenting-path search over the old/new candidate graph).longestSharedRun, so the only part that can be aborted); phase 2 runs the augmenting-path search purely over that already-known, in-memory matrix.docs.notesin all three analyzer-registration sites now that the gap is closed —registry.ts(the source of truth), andanalyzer-metadata.json+apps/gittensory-ui/src/lib/rees-analyzers.ts, both regenerated vianpm run metadata(not hand-edited, since both are machine-generated fromregistry.ts).Closes #4812
Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #4812).Validation
Ran the full local gate synchronously, in this order, all green:
git diff --checknpm run actionlintnpm run typechecknpm run test:coverage— 702 files / 13920 tests passed (root suite;review-enrichment/srcitself is outside Codecov'ssrc/**patch-coverage scope, so I additionally hand-verified 100% branch coverage of the newassignSurvivorscode via Node's--experimental-test-coverage/ raw V8 coverage output — the only uncovered branches in the file are two pre-existing, unrelated lines inscanDuplicationDeltathat I did not touch)npm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderate— 0 vulnerabilitiesAll of the above ran as part of one full
npm run test:cipass (green end to end), plus these REES-specific commands the change also requires:npm run rees:test— review-enrichment's own full suite (build + sourcemap validation +generate-analyzer-metadata.mjs --check+node --test): 1315/1315 passing after rebasing onto latestmain.npx tsx scripts/check-engine-parity.ts— clean, no drift.Safety
docs.notesis descriptive text, not an API contract.docs.notesstring changed); this repo's screenshot-table gate is also presently unconfigured/disabled regardless of path.Notes
assignSurvivorsinreview-enrichment/src/analyzers/duplication-delta.tsfor the full rationale.[true, false]there (B incorrectly reported as still-duplicated), not the optimal[true, true].longestSharedRunitself) — full branch coverage of the new code.duplication-delta.test.tssuite (31 tests) passes unchanged.