Skip to content

Fix fact_check declared values and parse errors, numbered-list choices and get_judge copies - #187

Open
Robrusi wants to merge 1 commit into
devfrom
fix/judge-parsing
Open

Robrusi wants to merge 1 commit into
devfrom
fix/judge-parsing

Conversation

@Robrusi

@Robrusi Robrusi commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Problem

  • fact_check read a declared value with float():
    • "8 300" and "8,5" went ungraded, and a direct classify_fact call crashed on them.
    • "8.300" was read as 8.3, so a correct "8 300 kroner" was graded at full severity.
  • When the judge reply didn't parse, the code-derived grade stood, but "Could not parse judge response" stayed in issues_found and the raw reply stayed in summary.
  • parse_choice did not read past a numbered-list marker, so "1. yes" and "1. yes" gave no choice.
  • get_judge() returned a shallow copy. Changing a nested value such as response_schema changed the registry entry for every later call.

Fix

  • A declared string value is read the way the answer reader reads figures:

    • A space or a full stop between groups of three digits is a thousands separator: "8 300" and "8.300" are 8300.
    • A comma comes before the decimals: "8,5".
    • A first group of zero is read as Python reads it: "0.125".
    • Non-numbers, bools, NaN and infinity are UNGRADED, with a reason.

    The convention is documented in the facts contract.

  • If the reply did not parse, parse_error, issues_found and summary move into judgment["judge_error"].

  • parse_choice skips "1." or "1)" only when the line doesn't start with an option key, so keys like "1", "1b" and "10" still read as keys.

  • get_judge() copies plain dicts, lists, tuples and sets at every depth, and shares every other object (hooks and anything they hold).

Notes:

  • "8,300" now reads as 8.3 and "1.250" as 1250, following the Norwegian convention.
  • A bool value is now ungraded. Dev reads True as 1.
  • No built-in pack fact is a string.
  • parse_choice now applies its existing first-word guess to list items. For example, "1. A-vitamin er lav" reads as A with keys A–E, as unnumbered lines already did.
  • fact_check's experiment fingerprint changes; the other judges' fingerprints don't. choice_match's fingerprint doesn't cover parse_choice, which predates this change.

Testing

  • tests/test_judge_parsing.py has 3 tests: declared values, an unparsed reply and numbered lists.
  • The copy test in tests/test_judge_registry.py also checks a nested schema and a hook that holds a lock.
  • Everything fails on dev except the "0.125" case, which guards the leading-zero rule.
  • Updated tests:
    • J7 in test_audit_regressions_judges.py: "8 300" now grades, so the test uses a value that is not a number.
    • test_checklist_reframing.py: compares with == instead of is.
  • Full suite on Python 3.12: 4231 passed, 14 skipped.

Written by Opus 5.5

fact_check:
- A declared value written as Norwegian text ("8 300", "8,5") went
  ungraded, and "8.300" was read as 8.3, so a correct "8 300 kroner"
  was graded high. A string value is now read the way the answer reader
  reads a figure: a space or a full stop between groups of three digits,
  a comma before the decimals. A first group of zero is never a thousands
  group ("0.125" is 0.125). A value that is not a number (or is a bool,
  NaN or infinity) gives the per-fact outcome UNGRADED with its reason,
  also when classify_fact is called directly, where it used to raise.
  The scenario reason now quotes that reason instead of always blaming
  the fact head. The facts contract in stale_facts documents the
  convention.
- When the judge reply could not be parsed, "Could not parse judge
  response" stood in issues_found and the raw reply in summary beside the
  grade read from the transcript. The parse error now goes to judge_error
  and the code-derived grade stands alone.

choice_match: parse_choice did not read past a numbered-list marker
("1. yes", "**1.** yes", "1. Answer: no"). The marker is now skipped
when the line does not start with an option key itself, so keys such as
"1", "1b" or "10" are still read as keys.

get_judge returned a shallow copy, so changing a nested value such as
response_schema in the returned config changed the registry entry (or
the caller's dict). It now copies plain dicts, lists, tuples and sets at
every depth and shares every other object, so hooks and anything they
hold (a client, a lock) stay the originals.

load_head's torch import is an availability probe; mark it noqa: F401
like the numpy import beside it.

This branch has not been deployed

No deployments
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.

1 participant