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

Show on the map →

Called by test_a_run_with_nothing_graded_refuses, test_above_threshold_withholds_and_exits_nonzero

Calls splits, tally

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
lines 106–106parser = argparse.ArgumentParser(prog="judge_error_rate", description=__doc__)lines 107–107parser.add_argument("run", type=Path, help="a run directory, e.g. acceptance/runs/<name>")lines 108–108parser.add_argument("--threshold", type=float, default=2.0, help="percent that fails the run")lines 109–109args = parser.parse_args()lines 111–111samples, errors, cells, unreadable = tally(args.run)lines 112–112◇ if not cellslines 113–113print(f"REFUSED — no grade sidecars under {args.run}", file=sys.stderr)lines 114–114return 2lines 115–115rate = 100.0 * errors / samples if samples else 0.0lines 116–116voted, split = splits(args.run)lines 117–117print(f"cells graded {cells}")lines 118–118print(f"judge samples {samples}")lines 119–119print(f"errored {errors}")lines 120–120print(f"rate {rate:.2f}% (threshold {args.threshold:.2f}%)")lines 125–125◇ if votedlines 126–129print( 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%)" )lines 132–132◇ if unreadablelines 133–133print(f"UNREADABLE {len(unreadable)} sidecar(s), excluded from the rate")lines 134–134◇ for path in unreadablelines 135–135print(f" {path}")lines 136–136◇ if rate > args.thresholdlines 137–137print("DEGRADED — above threshold; the quality figure is withheld")lines 138–138return 1lines 139–139return 0

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

Show on the map →

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
lines 79–79voted = split = 0lines 80–80◇ for path in sorted(root.glob("*/answers/*.grade.json"))lines 81–81trylines 82–82record = json.loads(path.read_text("utf-8"))lines 83–83except (OSError, ValueError)lines 84–84continuelines 85–85◇ for decision in record.get("decisions", [])lines 86–86◇ if int(decision.get("samples", 0)) <= 1lines 87–87continuelines 88–88voted += 1lines 89–89agreement = decision.get("agreement")lines 90–90◇ if agreement is not None and float(agreement) < 1.0lines 91–91split += 1lines 92–92return voted, split

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

Show on the map →

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

Activity · 13 steps
lines 39–39samples = errors = cells = 0lines 40–40unreadable: list[Path] = []lines 41–41◇ for path in sorted(root.glob("*/answers/*.grade.json"))lines 42–42trylines 43–43record = json.loads(path.read_text("utf-8"))lines 44–44except (OSError, ValueError)lines 45–45unreadable.append(path)lines 46–46continuelines 47–47cells += 1lines 48–48◇ for decision in record.get("decisions", [])lines 49–49samples += int(decision.get("samples", 0))lines 50–50errors += int(decision.get("errors", 0))lines 51–51return samples, errors, cells, unreadable

Flows