judge_error_rate.py¶
scripts/judge_error_rate.py
The share of judge calls that errored, over a graded run.
main
int judge_error_rate.main()
Print the rate and its denominator.
scripts/judge_error_rate.py:98
Called by test_a_run_with_nothing_graded_refuses, test_above_threshold_withholds_and_exits_nonzero
Source · 44 lines
def main() -> int:
"""THE THRESHOLD IS AN ARGUMENT WITH A DEFAULT, not a constant, because the 2% in the 1.2.0
pre-registration is that run's declaration rather than a property of grading.
@brief Report the judge error rate.
@return Exit code.
@version 1
"""
parser = argparse.ArgumentParser(prog="judge_error_rate", description=__doc__)
parser.add_argument("run", type=Path, help="a run directory, e.g. acceptance/runs/<name>")
parser.add_argument("--threshold", type=float, default=2.0, help="percent that fails the run")
args = parser.parse_args()
samples, errors, cells, unreadable = tally(args.run)
if not cells:
print(f"REFUSED — no grade sidecars under {args.run}", file=sys.stderr)
return 2
rate = 100.0 * errors / samples if samples else 0.0
voted, split = splits(args.run)
print(f"cells graded {cells}")
print(f"judge samples {samples}")
print(f"errored {errors}")
print(f"rate {rate:.2f}% (threshold {args.threshold:.2f}%)")
## PRINTED BESIDE THE ERROR RATE because they answer different questions about the same
## instrument: how often it failed to answer, and how often it disagreed with itself. The
## Sonnet-graded comparison figure is quoted so the number means something to a reader who
## has only this output. NOT a noise floor — see `splits`.
if voted:
print(
f"split decisions {split}/{voted} voted {100.0 * split / voted:.1f}% "
f"(1.1.0 under claude-sonnet-4-5-20250929: 146/936, 15.6%)"
)
## REPORTED, NEVER ABSORBED. An unreadable sidecar is a cell nobody graded, and folding it in
## as zero errors would make an empty grid the cleanest one on this measure.
if unreadable:
print(f"UNREADABLE {len(unreadable)} sidecar(s), excluded from the rate")
for path in unreadable:
print(f" {path}")
if rate > args.threshold:
print("DEGRADED — above threshold; the quality figure is withheld")
return 1
return 0
Activity · 24 steps
Flows
splits
tuple[int, int] judge_error_rate.splits(Path root)
How many voted decisions had their samples disagree.
scripts/judge_error_rate.py:61
Called by main, test_split_rate_counts_only_voted_decisions, test_the_1_1_0_split_rate_is_reproducible
Calls none
Source · 34 lines
def splits(root: Path) -> tuple[int, int]:
"""THE ONE NOISE INDICATOR A SINGLE GRADING PASS CAN GIVE. A floor needs two passes over
identical answers; the 1.2.0 run has one, and it changed the judge from
`claude-sonnet-4-5-20250929` to `claude-sonnet-5-5`. Whether the new judge disagrees with
ITSELF more often is visible without a second pass: on the 1.1.0 grid, 146 of 936 voted
decisions split, 15.6%.
VOTED DECISIONS ONLY. A single-sample decision cannot split, so including it would dilute
the rate by however many marks the rubric left unvoted — turning a fact about the judge into
a fact about the weights.
IT IS NOT A NOISE FLOOR and must not be reported as one. It measures within-call-set
disagreement on one pass, not pass-to-pass movement in the score.
@brief Voted and split decision counts.
@return Voted, split.
@version 2
"""
voted = split = 0
for path in sorted(root.glob("*/answers/*.grade.json")):
try:
record = json.loads(path.read_text("utf-8"))
except (OSError, ValueError):
continue
for decision in record.get("decisions", []):
if int(decision.get("samples", 0)) <= 1:
continue
voted += 1
agreement = decision.get("agreement")
if agreement is not None and float(agreement) < 1.0:
split += 1
return voted, split
Activity · 14 steps
Flows
tally
tuple[int, int, int, list[Path]] judge_error_rate.tally(Path root)
One run's error tally, read from its grade sidecars.
scripts/judge_error_rate.py:34
Called by main, test_an_unreadable_sidecar_is_not_zero_errors, test_rate_is_errors_over_samples_and_names_both, test_the_published_1_1_0_rate_is_reproducible
Calls none
Source · 20 lines
def tally(root: Path) -> tuple[int, int, int, list[Path]]:
"""@brief Sum samples and errors over every decision.
@return Samples, errors, cells, unreadable.
@version 1
"""
samples = errors = cells = 0
unreadable: list[Path] = []
for path in sorted(root.glob("*/answers/*.grade.json")):
try:
record = json.loads(path.read_text("utf-8"))
except (OSError, ValueError):
unreadable.append(path)
continue
cells += 1
for decision in record.get("decisions", []):
samples += int(decision.get("samples", 0))
errors += int(decision.get("errors", 0))
return samples, errors, cells, unreadable