feat(review): deterministic fallback categorization for findings (#2148) - #3934
Conversation
…euristics (JSONbored#2148) Add `inferFindingCategory(body, path)` as the single-sourced deterministic fallback for AI review findings whose category the model omits or garbles. It applies a documented precedence: path signals first (test file → tests, docs file → style, config file → maintainability, via the src/signals path-matchers), then keyword buckets over the body (security → performance → tests → style → maintainability), then a "correctness" default. `classifyFindingCategory` becomes a thin `{ path, body }` adapter delegating to the new function, so every existing fallback site (inline-comment rendering, category tallies/collapsible) gains docs/config path routing without drift and with no behavior change to the parser's tested "absent-when-omitted" contract. Also drops the heavy signals/local-branch import in favor of the path-only matchers. Adds full per-branch tests (every path signal, keyword bucket, and precedence edge). Closes JSONbored#2148. Co-authored-by: Cursor <cursoragent@cursor.com>
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-07 07:17:13 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 5 non-blocking
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.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3934 +/- ##
=======================================
Coverage 93.66% 93.66%
=======================================
Files 372 372
Lines 34856 34859 +3
Branches 12743 12745 +2
=======================================
+ Hits 32649 32652 +3
Misses 1588 1588
Partials 619 619
🚀 New features to boost your workflow:
|
Summary
Implements the deterministic keyword/path fallback categorization from #2148.
inferFindingCategory(body: string, path: string): FindingCategoryinsrc/review/finding-category-classify.ts, using thesrc/signals/path-matchersmatchers (isTestPath,isDocsFile,isConfigFile) plus the existing keyword sets.tests, docs file →style, config file →maintainability(the file the reviewer anchored to is the strongest deterministic signal).security→performance→tests→style→maintainability.correctnesswhen nothing matches.classifyFindingCategory({ path, body })a thin adapter that delegates toinferFindingCategory, so it stays single-sourced and every existing fallback site (inline-comment rendering, category tallies/collapsible) now gains docs/config path routing it previously lacked.signals/local-branchimport in favor of the path-only matchers (also lighter forui:typecheck).Note on "wire in the parser"
The deliverable mentions wiring the fallback "in the parser." The category pipeline landed in #3634 (#1958) after this issue was filed, and it deliberately leaves
categoryabsent on the parsed finding (parseModelReview) so callers that never asked for categories see no field — a contract locked in byai-review.test.ts. The fallback is therefore applied at the resolution boundary (finding.category ?? classifyFindingCategory(...)), i.e. only when the model omits/garbles the category. This PR upgrades that single fallback engine rather than regressing #3634's tested contract; behavior for a present/valid model category is unchanged.Test plan
npx vitest run test/unit/finding-category-classify.test.ts— adds full per-branch coverage: every path signal, every keyword bucket, no-signal default, and precedence edges (path beats keywords; security beats performance).npx vitest run test/unit/finding-category-collapsible.test.ts test/unit/finding-category-tally.test.ts test/unit/inline-comments-select.test.ts test/unit/inline-comments.test.ts test/unit/ai-review.test.ts— all green, no behavior change.npm run typecheckCloses #2148.
Made with Cursor
Made with Cursor