← Back to Pull requests

fix(zebralogicbench): keep braces inside strings out of the object scan #2030

Merged
simin-yuan merged 3 files (123 lines) on Nov 10, 2026 07:07 UTC
View on GitHub
simin-yuan simin-yuan commented on Nov 09, 2026 09:24 UTC
Author

Problem

Fixes #2026.

ZebraLogicBenchAdapter.extract_answer finds the answer by scanning the whole completion for the last balanced {...} run and passing that slice to json.loads. The scan keeps a stack of brace positions but has no notion of JSON string literals or escapes, so a { or } inside a string value is treated as structure:

  • a lone { inside a value (e.g. "the set {A, B} is open") empties the extraction;

  • a lone } truncates it to an inner object that is not the answer.
  • match_score then feeds filtered_prediction or '{}' to process_results, so a valid answer is scored as unanswered and counted in no_answer_num and the cell_acc denominator.

    Fix

    Track string state (and backslash escapes) in the same scan: a brace is only structural when it appears outside a string literal. No change to the JSON normalisation or the scoring path.

    Tests

    tests/benchmark/test_zebralogic_braces_in_strings.py:

  • opening brace inside a string value does not reset the object;

  • closing brace inside a string value does not truncate the answer;

  • an escaped quote before a brace does not leak string state.
  • python -m pytest tests/benchmark/test_zebralogic_braces_in_strings.py \
      tests/benchmark/test_zebralogic_unparsed_answers.py -q
    4 passed
    

    The existing unparsed-answer behaviour (counts toward the totals) is unchanged.

    AI assistance: prepared with an AI coding agent (DSH); I ran the tests above and can explain every change.

    Diff: 123 lines (+121 / -2) across 3 files Reviewer: Yunnglin Review duration: 1302m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.35) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.35 · 123 lines diff across 3 files
    0.35
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.288
    Real PR Conversation Timeline
    1 item
    "Review active on #2030"
    general weight: 0.35
    Reviewers
    Assignees
    simin-yuan simin-yuan
    Labels
    risk: low confidence: 46.7% 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: 34.8% (LOW) · Higher = larger blast radius
    34.8%
    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: 46.7% · Lower = rushed or shallow review
    46.7%
    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: 18.5% · Safe to merge
    18.5%