Harden Copilot PR-review JSON parser against resume-fence corruption#8828
Merged
Conversation
The reviewer discarded all 42 findings of a real run (28168894037) and posted 0, because a corrupt fragment was accepted as the report while the real findings-report was dropped during parsing. Two compounding causes: - A bare `json resume fence is injected mid-emission with no Placeholder marker. When it lands inside an unterminated string, Remove-StructuralFences (which preserves in-string fences) cannot clear it, so ConvertFrom-Json rejects the whole document. - The candidate scan accepted the first parseable fragment. The transcript echoes each sub-skill report and bare arrays (e.g. ['articles']) as valid JSON, so a wrong fragment wins and the real report is silently dropped. Fixes: - Add Repair-ResumeFenceJson: a conservative, string-aware splice that clears a bare resume fence only when it sits between an unterminated property and a re-emission of the same key. - Replace first-parseable-wins with a tiered candidate preference: orchestrator-shaped (sub-results/dispatch) > findings-bearing object > any parseable. Leniency is preserved while the correct fragment always wins.
Contributor
Copilot PR ReviewIteration 7 · Outcome: not-applicable
Knowledge source: https://github.com/microsoft/BCQuality@822cae1b2771ac25f665f73369f69093bd4fd630 No findings were posted for this iteration. Orchestrator pre-filter (13 file(s) excluded)
Findings produced by the Copilot CLI agent against BCQuality at |
JesperSchulz
approved these changes
Jun 25, 2026
Aleyenda
approved these changes
Jun 25, 2026
aholstrup1
approved these changes
Jun 26, 2026
gggdttt
pushed a commit
that referenced
this pull request
Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Copilot PR-review reviewer silently posted 0 findings on a run where the agent actually produced 42 (run
28168894037: blocker × 5, major × 24, minor × 13). The job stayed green because "parsed to zero findings" is indistinguishable from "clean PR" — the findings were lost in parsing, not in review.Two compounding causes in
Parse-BCQualityReport:Resume-fence corruption. The agent breaks off mid-emission and resumes by re-opening a bare
```jsonfence with noPlaceholder ...marker. When that fence lands inside an unterminated string,Remove-StructuralFences(which deliberately preserves in-string fences, e.g. a```alsample insuggested-code) cannot clear it, soConvertFrom-Jsonrejects the entire document.Wrong-fragment-wins. The candidate scan accepted the first parseable fragment. The transcript echoes every sub-skill's own JSON report inside fences, and bare arrays (e.g.
['articles']from reasoning text) parse as valid JSON. So when the full document is unparseable, a wrong fragment is accepted and the real report is silently dropped — and because that fragment reportsoutcome: completed/findings: [], it even slips past thefail-on-parse-errorsafeguard.Fix
Repair-ResumeFenceJson(new, third repair path): a conservative, string-aware splice that clears a bare resume fence only when it sits between an unterminated property ("key": "...with an odd count of unescaped quotes) and a re-emission of that same key. That triple signature distinguishes interrupted-emission resumes from ordinary transcript noise. Clean output is never touched (callers try unmodified candidates first).Tiered candidate preference (replaces first-parseable-wins): orchestrator-shaped (
sub-results/dispatch) → findings-bearing object → any parseable candidate. Leniency is preserved, but the correct fragment always wins and bare fragments like['articles']can only be a last-resort fallback.Why both bugs are needed
The most recent production instance had its stray fence between two top-level members (outside any string), which
Remove-StructuralFencesalready clears — so for that case the tiered preference alone recovers all 42 findings.Repair-ResumeFenceJsonadditionally covers the variant where the fence is trapped inside an unterminated string, which the fence-stripper cannot touch.Testing
Validated locally against a regression suite that AST-extracts the parser functions and replays the corruption shapes (resume-fence-in-string, wrong-fragment selection, Placeholder-marker interruption, and the exact production instance with
['articles']+ a stray mid-object fence), plus guards confirming clean reports and legitimate in-string code fences are unaffected — 16/16 assertions pass.Refs AB#640481 (related: AB#638957).