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
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13.
Three verified parsing defects, each with a regression test:
GRADE: <4>now parses. All three prompt presets displayGRADE: <{grade}>, but_GRADE_REonly tolerated[. A judge mimicking the displayed delimiters produced an unparseable-verdict error. The regex now accepts</[.GRADE: 4.5used to be recorded as a valid verdict of 4 (regex stopped at the.), and a structured"grade": 4.9was truncated byint(). 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 andRubric.numeric()rejects non-integers (integer-valued floats like4.0still map). The two judge parsers are the onlynumeric()callers, so no other behavior changes._loadsgrabbed\{.*\}greedily (first{to last}), so a valid verdict object followed by chatty prose containing braces failed to parse. Now decodes the first balanced object viajson.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