feat(enrichment): full-file / near-verbatim duplication scan (#1520) - #1620
feat(enrichment): full-file / near-verbatim duplication scan (#1520)#1620dale053 wants to merge 3 commits into
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Caution 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 🛑 Gittensory review — closed
🛑 Closed — AI reviewers agree on a likely critical defect: review-enrichment/src/types.ts:103 leaves `DuplicationFinding` unterminated, so `CodeownersFinding` is parsed inside it and the file is syntactically invalid. — Resolve the flagged defect, or override if the AI reviewers are mistaken, then re-run the gate.; Readiness score is below the configured threshold — Address the short explicit PR panel actions, then re-run the gate. Review summary Blockers
Why this is blocked
Nits — 6 non-blocking
Review context
Contributor next steps
Signal definitions
Review detailsGenerated from public PR metadata and the diff. Advisory only; deterministic signals remain authoritative. This change adds a duplication analyzer, wires it into the enrichment orchestrator, extends the findings contract, and renders duplication findings in the brief. The analyzer logic is bounded and fail-safe, but the submitted post-change files do not parse because two new blocks are left unterminated. Until those braces are restored, the package cannot build or run the new tests. Blockers
Nits (5)
🟩 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.
|
…-duplication findings
Signed-off-by: dale053 <star05223@outlook.com>
JSONbored
left a comment
There was a problem hiding this comment.
merge conflicts, please resubmit with all issues resolved. many of the analyzers issues touch similar files so the risk for churn does exist.
Summary
DuplicationFindingtype andduplicationkey toBriefFindingsinreview-enrichment/src/types.ts.review-enrichment/src/analyzers/verbatim-duplication.ts: winnowing k-gram fingerprinting (k=8, w=4) over PR-added hunks vs the same-language repo tree atheadSha. Two-phase: cheap whole-file containment gate (≥ 65%), then a sliding-window line scan to localize the source citation. Bounded at 150 files / 64 KB per file / 512 KB total / 8 concurrent blob fetches / 10 findings. Fail-safe on missing token, missing sha, or any network error.src/brief.tsANALYZERS registry with abort-signal forwarding.### Near-verbatim code duplicationblock insrc/render.ts, citingheadFile:headLine duplicates sourceFile:sourceLine (~N lines, X% match)usingsafeCodeSpanfor both paths.node:testunit and integration tests covering all exported functions, the render block, and the orchestrator wiring.Closes #1520. Parent: #1499.
Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocally; global coverage stays at or above 97% for lines, statements, functions, and branches (aim for 98%+ branch coverage locally so CI variance does not fail near the threshold)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=moderateIf any required check was skipped, explain why:
test:coverage,ui:*,build:mcp, etc.) is not applicable to this change: all code lives insidereview-enrichment/, which is a standalone Node service with its own build and test pipeline (npm testinsidereview-enrichment/). All 58 tests pass (npm testinreview-enrichment/), including the 14 new duplication-analyzer tests. The root-level CI checks listed above are for the Cloudflare Worker and do not coverreview-enrichment/.Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.No auth/CORS/session changes. No UI changes. The
githubTokenfromEnrichRequestis used only in theAuthorizationheader for GitHub API calls and is never logged or included in any finding output. The render block usessafeCodeSpanfor all file paths (same pattern as every other analyzer).UI Evidence
No UI changes.
Notes
review-enrichment/service sits outside the main gittensory vitest/Codecov scope (per the issue: "outside the engine tsc/vitest/codecov scope"). Coverage is validated by the service's ownnode:testsuite.findBestSourceLinetest uses a loose line-range assertion (>= 1 && <= 6) because multiple overlapping windows can legitimately score identically on the containment metric; the important invariant is that a match is found and the returned line is within the region containing the duplicated code.