Skip to content

judging: robust verdict parsing — accept GRADE: <n>, reject (don't truncate) fractional grades, balanced JSON extraction - #30

Open
ChrisW09 wants to merge 1 commit into
mainfrom
fix/judge-verdict-parsing
Open

judging: robust verdict parsing — accept GRADE: <n>, reject (don't truncate) fractional grades, balanced JSON extraction#30
ChrisW09 wants to merge 1 commit into
mainfrom
fix/judge-verdict-parsing

Conversation

@ChrisW09

Copy link
Copy Markdown
Collaborator

Fixes #13.

Three verified parsing defects, each with a regression test:

  1. GRADE: <4> now parses. All three prompt presets display GRADE: <{grade}>, but _GRADE_RE only tolerated [. A judge mimicking the displayed delimiters produced an unparseable-verdict error. The regex now accepts </[.
  2. Fractional grades are rejected, not truncated. GRADE: 4.5 used to be recorded as a valid verdict of 4 (regex stopped at the .), and a structured "grade": 4.9 was truncated by int(). Both silently biased scores downward with no error flag, while integer off-scale values (99) were correctly rejected. The regex now captures the fractional part and Rubric.numeric() rejects non-integers (integer-valued floats like 4.0 still map). The two judge parsers are the only numeric() callers, so no other behavior changes.
  3. Balanced JSON extraction. _loads grabbed \{.*\} greedily (first { to last }), so a valid verdict object followed by chatty prose containing braces failed to parse. Now decodes the first balanced object via json.JSONDecoder.raw_decode.

Test: full cafe-core suite — 112 passed (the one failure, test_fit_effects_detects_real_effect, is pre-existing #4, fixed in a separate PR).

🤖 Generated with Claude Code

Three verified parsing defects fixed:

- GRADE regex now accepts the <...> delimiters the prompt templates
  themselves display (GRADE: <{grade}>). Previously 'GRADE: <4>' was an
  unparseable-verdict error while 'GRADE: [4]' parsed.
- Fractional grades (GRADE: 4.5, JSON "grade": 4.9) are rejected as
  off-scale like other invalid values, instead of silently truncated
  toward zero — truncation biased affected scores downward with no
  error flag. Rubric.numeric() now rejects non-integer values.
- Structured-mode JSON extraction decodes the first balanced {...}
  object (json.JSONDecoder.raw_decode) instead of greedily spanning
  first-{ to last-}, so trailing prose containing braces no longer
  breaks a valid verdict object.

Fixes #13

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

judging: verdict parsing rejects or mangles common judge outputs (GRADE: <n>, fractional grades, JSON followed by prose)

1 participant