Unwrap a code-fenced OpenCode douwebot result, as `PR Review Checks` already does

Merged
DO
22d ago
+77-46

No issue: fixes a douwebot fallback failure seen on #11813.

When the Claude subscription window is rejected, douwebot reruns the review with OpenCode. The model sometimes wraps the JSON object it was asked for in a Markdown code fence (```json ... ```). douwebot_opencode_result.review_result passed that text straight to ReviewResult.model_validate_json, so "Validate completed review" failed with Invalid JSON and no review was published (run 42932731002).

#13182 later added unfenced() to the same module, but only PR Review Checks (run_pr_review_check.py) calls it. This PR makes review_result use it too, so both OpenCode paths accept the same answers. A fenced block that ends the answer is unwrapped, with or without a language tag and with or without prose before it. Text after the fence, a nested fence, an unterminated fence or a single-line fence still fail validation. Code fences inside JSON string values are kept.

unfenced also no longer uses a backtracking regex. On fence-heavy model text that regex was quadratic: 32 KB took 1.5 s. It now finds the closing fence on the last line and scans backwards once for the opening fence, so 1 MB takes about 10 ms. Its results match the old regex on 200,000 generated inputs. PR Review Checks gets the same fix.

Tests in test_douwebot_opencode_result.py cover the accepted and rejected shapes through review_result. All tests in the file share one stream-writing helper.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.

šŸ¤– Generated with Claude Code