feat(enrichment): revert-recurrence detector for re-introduced revert…#1687
feat(enrichment): revert-recurrence detector for re-introduced revert…#1687dale053 wants to merge 8 commits into
Conversation
…ed code (JSONbored#1514) Adds a REES analyzer that fetches per-file commit history from the GitHub commits API, identifies revert commits (message starts with "Revert"), fetches their diffs, and intersects the lines they removed with the lines being added by the current PR. A hit indicates known-problematic code is being re-introduced without addressing the original reason it was reverted. - New `RevertRecurrenceFinding` interface and `revertRecurrence` key in `BriefFindings` - Pure helper exports (`isRevertMessage`, `extractAddedLines`, `extractRemovedLines`) enable direct unit testing without network mocks - Fail-safe: non-ok responses, network throws, and non-array commit-list responses all degrade silently to empty findings - Bounded: MAX_FILES=10, MAX_COMMITS_PER_FILE=30, MAX_REVERT_CHECKS_PER_FILE=5, MAX_FINDINGS=15; MIN_MATCH_LINES=2 + MIN_LINE_LEN=8 suppress coincidental hits - Auth header included when `githubToken` is present; omitted for public repos - 70 tests all passing; all new branches covered
Signed-off-by: dale053 <[email protected]>
|
Caution 🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥 🛑 Gittensory review result - reject/close recommended
🛑 Suggested Action - Reject/Close — AI reviewers agree on a likely critical defect: review-enrichment/src/types.ts:111 leaves `RevertRecurrenceFinding` unclosed, so `ProvenanceFinding` is parsed inside the previous interface and the file is invalid TypeScript. — Resolve the flagged defect, or override if the AI reviewers are mistaken, then re-run the gate. Review updated: 2026-06-29 11:16:22 UTC Review summary Blockers
Nits — 4 non-blocking
Why this is blocked
Review context
Contributor next steps
Signal definitions
🟩 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
revertRecurrenceanalyzer to the review-enrichment service (REES) that detects when a PR re-introduces code that was previously reverted — a known-problematic path being re-trodden without addressing the original reason it was walked back."Revert"), fetches their diffs, and intersects the lines they removed with the lines being added by the current PR. A match is reported as aRevertRecurrenceFinding.promptSectionunder"### Re-introduced reverted code (known-problematic path re-trodden)"and in the structuredfindings.revertRecurrencearray.MAX_FILES=10,MAX_COMMITS_PER_FILE=30,MAX_REVERT_CHECKS_PER_FILE=5,MAX_FINDINGS=15. Requires at leastMIN_MATCH_LINES=2non-trivial lines (MIN_LINE_LEN=8) to suppress coincidental hits on common structural patterns.Closes #1514
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;codecov/patchrequires ≥97% coverage of the lines AND branches you changed (aim for 98%+ on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.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:
npm run typecheckandnpm run ui:typecheckreport 28 and 5 pre-existing errors respectively (missing optional self-host packages:pg,ioredis,@sentry/node,@cloudflare/puppeteer,@testing-library/react). These errors are identical onmainbefore this PR and are unrelated to the changes here. Zero new type errors introduced.review-enrichment/which is outside the main vitest coverage scope (src/**) and the Codecovincludepath. The enrichment test suite (node --testinreview-enrichment/) runs 70 tests, all passing, with every new branch inrevert-recurrence.tscovered.Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots. — N/A: no visible UI changes.UI Evidence
N/A — no visible UI, frontend, docs, or extension changes.
Notes
githubTokenfromEnrichRequestwhen present (addsAuthorization: Bearer …header); omits the header for public repos where no token is provided.RevertRecurrenceFinding— no code content is ever captured or rendered, preserving the same value-redaction principle used by the secret analyzer.Array.isArrayguard inlistFileCommitsensures that a mocked or unexpected non-array response from the GitHub API does not propagate as an uncaughtTypeErrorintobuildBrief, keeping the analyzer isolated from upstream format surprises.