← Back to Pull requests

fix(flows): bound compatibility JSON recovery work #653

Closed
unknown closed this pull request without merging on Sep 21, 2026 03:38 UTC
View on GitHub
unknown unknown commented on Sep 20, 2026 22:01 UTC
Author

Compatibility JSON recovery used to collect every balanced candidate before parsing, repeatedly scanning overlapping suffixes. Delimiter-heavy assistant output could block the process with quadratic work even when a valid earlier candidate was available.

Parse candidates lazily and share a work budget proportional to input length across both balanced scanning and native JSON parsing. Reserve candidate parsing work before allocating a slice. This replaces the proposed 1 MiB / 256-start cutoffs: large prose, large embedded objects, and late valid candidates remain supported. Candidate order and independent string-state behavior are preserved.

Compatibility recovery is deliberately bounded: repeated malformed or ambiguous prefixes can exhaust the budget before a later valid object. That returns the existing parse error. Direct and fenced JSON parsing remain unrestricted by this recovery budget. The behavior and tradeoff are documented in docs/flows.md.

Built public dist/flows.js before/after proof on macOS / Node 26.8.2, with separate deadline-bounded child processes:

| Input | Main 4e4dcf5 | Candidate |
| --- | --- | --- |
| 100,000 unmatched opening braces | Exceeded 2 seconds | Rejected in 9 ms |
| 100,000 nested invalid arrays | Exceeded 2 seconds | Rejected in 21 ms |
| More than 1 MiB of prose, then valid JSON | Parsed | Parsed |
| 1,000 invalid candidates, then valid JSON | Parsed | Parsed |
| Large direct, fenced, and embedded JSON | Parsed | Parsed |

Seven focused parser regressions passed, covering candidate precedence, escapes, nested recovery, cheap large/late candidates, both scan/parse exhaustion, and the documented ambiguous-prefix tradeoff. Independent source-blind validation passed 39 consumer probes, including large Unicode prose and varied delimiter inputs. The isolated final branch review found no actionable findings.

Linux / Node 24.18.1 / pnpm 11.26.0: pnpm install --frozen-lockfile && pnpm run check && pnpm run check:docs passed. Full suite: 1,702 passed, two skipped. All configured coverage gates passed. Exact-head CI passed all applicable checks.

Maintainer completed the rework on the original contributor PR. Thanks @SebTardif for identifying the issue and the initial lazy-parsing change.

Diff: 290 lines (+217 / -73) across 3 files Reviewer: steipete Review duration: 337m
All Vouch review confidence checks passed
Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.40 · 290 lines diff across 3 files
0.40
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.339
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #653"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 39.9% (MEDIUM) · Higher = larger blast radius
39.9%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 15.7% · Safe to merge
15.7%
Repository