fix(flows): bound compatibility JSON recovery work #653
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
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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
steipete
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.jsbefore/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:docspassed. 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.