Skip to content

fix(review): kill diff-only false-positives (source-first diff + brace-aware parse) - #1110

Merged
JSONbored merged 1 commit into
mainfrom
fix/review-accuracy-diff-parse
Jun 23, 2026
Merged

fix(review): kill diff-only false-positives (source-first diff + brace-aware parse)#1110
JSONbored merged 1 commit into
mainfrom
fix/review-accuracy-diff-parse

Conversation

@JSONbored

Copy link
Copy Markdown
Owner

From the reviewbot→gittensory accuracy-gap audit. Targets the #1528 class (model hallucinates 'missing import/undefined symbol' on code it can't see).

GAP-1 (the #1528 root): buildAiReviewDiff was a blind 60k head-slice that break-dropped whole files — so the file defining a symbol could vanish while another referenced it (survived even with grounding on). Ported reviewbot's diff.ts → new guarded src/review/review-diff.ts: source-first ordering, hunk-aware reduction, always-list dropped files, 60k→80k budget.

GAP-3: parseModelReview's greedy regex swallowed the model's <think> scratchpad with the verdict → corrupted reviews. Ported reviewbot's brace-depth-aware extractLastJsonObject.

Full suite green (3499). New tests cover both.

…er + brace-aware JSON parse (#accuracy-gap-1, #accuracy-gap-3)

Two reviewbot-parity fixes from the accuracy-gap audit, targeting the metagraphed #1528 class
(model hallucinates 'missing import / undefined symbol' on code it cannot see).

GAP-1 (the #1528 root): buildAiReviewDiff was a blind 60k head-slice that break-DROPPED whole files
in stored order — no source-first ordering, no hunk-aware reduction. On a multi-file PR the file that
DEFINES a symbol could be dropped while another referenced it, so the reviewer 'saw' an undefined
symbol (survived even with full-file grounding on). Port reviewbot src/core/diff.ts into a new guarded
src/review/review-diff.ts: order SOURCE first (lockfiles/generated/docs/tests drop first), reduce
oversized patches hunk-aware (keep highest-signal hunks) instead of dropping, always list patch-less/
over-budget files with counts, and raise the budget 60k->80k (the 120B models are 128k-context).

GAP-3: parseModelReview used a greedy /{[\s\S]*\}/ that spanned first-{ to last-} and swallowed the
gpt-oss/nemotron <think> scratchpad object together with the verdict, silently corrupting/dropping
reviews. Port reviewbot's brace-depth-aware, string-safe extractLastJsonObject (returns the LAST
complete top-level object).

Full suite green (3499). New: review-diff.test.ts (source survives over lockfiles under tight budget;
patch-less file listed; hunk-aware reduction) + ai-review.test.ts scratchpad+fenced regression tests.
@JSONbored
JSONbored merged commit bcc4702 into main Jun 23, 2026
@JSONbored
JSONbored deleted the fix/review-accuracy-diff-parse branch June 23, 2026 22:03
@dosubot dosubot Bot added the size:L label Jun 23, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.90%. Comparing base (e626c7b) to head (760ab3a).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/review/review-diff.ts 88.88% 0 Missing and 6 partials ⚠️
src/services/ai-review.ts 91.30% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1110      +/-   ##
==========================================
- Coverage   94.92%   94.90%   -0.03%     
==========================================
  Files         153      154       +1     
  Lines       18559    18623      +64     
  Branches     6711     6737      +26     
==========================================
+ Hits        17618    17674      +56     
  Misses        390      390              
- Partials      551      559       +8     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant