Repository navigation
fix: refuse to compare Inspect runs scored at different numeric pass thresholds
evalarc.results_diff.diff(baseline, current) now refuses to compare two Inspect runs whose numeric scores were judged against different pass thresholds. The Inspect loader turns every finite numeric score that is not a bool into a pass or a fail, using the threshold given to load_results(path, threshold=...). Before this fix, a baseline loaded at 0.8 compared with a current run loaded at 0.5 could report checks as improved, or pass the gate, when behavior had not changed. The report also showed only the current threshold. The new check runs after the existing format and task checks. It is implemented by the helpers _is_numeric_score, _has_numeric_scores and _require_same_numeric_threshold in src/evalarc/results_diff.py. When it fires, diff() raises ValueError('inputs are not comparable: numeric pass threshold 0.8 (baseline) != 0.5 (current); numeric Inspect scores were judged against different pass thresholds. Load both runs with the same threshold.') and returns no partial result. These cases are unchanged: equal thresholds (1 and 1.0 count as equal); Inspect runs with only letter-grade, boolean or missing score values; a baseline dict without a threshold key; and all promptfoo and JUnit comparisons. docs/ci-gate.md documents the rule and how to fix it. Checks the controller ran on candidate eca495b against base 01cd565: the acceptance-before run of tests/test_feature_ab24ecf56e51.py exited 1 (1 failed, 9 passed). The failing test was test_mismatched_numeric_thresholds_are_not_comparable, with DID NOT RAISE ValueError, which shows the test detects the defect. On the candidate commit, these all exited 0: the new test file, the full python -m pytest -q, ruff check ., ruff format --check ., scripts/build_site.py and scripts/check_site.cjs. An earlier controller run had failed ruff format --check on results_diff.py; the final run passes it.
Use it
Prerequisites: run from the EvalArc repository root in the environment used for python -m pytest (evalarc importable).
SYNTHETIC example: both files are copies of the bundled example with every per-sample score value set to 0.7. They are not real provider exports.
python - <<'PY'
import json
from pathlib import Path
from evalarc.results_diff import diff, load_results
doc = json.loads(Path('examples/results-diff/inspect/baseline.json').read_text())
changed = 0
def numeric(node):
global changed
if isinstance(node, dict):
scores = node.get('scores')
if isinstance(scores, dict):
for score in scores.values():
if isinstance(score, dict) and 'value' in score:
score['value'] = 0.7
changed += 1
for child in node.values():
numeric(child)
elif isinstance(node, list):
for child in node:
numeric(child)
numeric(doc)
if not changed:
raise SystemExit('no per-sample scores found; use the pattern in tests/test_feature_ab24ecf56e51.py')
for name in ('synthetic-baseline.json', 'synthetic-current.json'):
Path(name).write_text(json.dumps(doc))
try:
diff(load_results(Path('synthetic-baseline.json'), threshold=0.8),
load_results(Path('synthetic-current.json'), threshold=0.5))
print('unexpected: no error')
except ValueError as error:
print('refused:', error)
Fix: load both runs with the same threshold
result = diff(load_results(Path('synthetic-baseline.json'), threshold=0.8),
load_results(Path('synthetic-current.json'), threshold=0.8))
print('gate_passed:', result['gate_passed'], 'threshold:', result['numeric_pass_threshold'])
PY
rm synthetic-baseline.json synthetic-current.json
Behavioral tests the controller ran:
python -m pytest -q tests/test_feature_ab24ecf56e51.py
Scope and upgrade
The rule covers only the Inspect format, inside diff(). It applies to Python API callers and to any other code that calls diff(). cli.py was not inspected. It is unverified whether the CLI can load the two files at different thresholds, or whether it reports this ValueError with exit 2 like the task-mismatch error; that remains an inference. A current run dict without a threshold key keeps its existing behavior, because diff() reads current['threshold'] directly. NaN and inf are excluded from the rule to match _inspect_passed, but no test exercises that. The tests use synthetic Inspect logs derived from the bundled example. They prove the rule on those inputs only. They do not prove behavior on real provider exports or any broader accuracy. The usage script was written for this delivery and was not executed by the controller. Its score-rewriting step assumes the example stores per-sample scores as a dict of objects with a value field. If it finds none, it stops with a message instead of guessing. The controller's final log excerpt does not include the full-suite pass count, so only exit code 0 is claimed. The browser evidence comes from the existing showcase regression checks (build_site.py plus check_site.cjs at widths 1440, 390 and 320, with keyboard and offline cases), which passed. They are not a visual review of this feature. This change has no UI, and no screenshots were reviewed. No CLI flag, new gate state, schema key or loader change was added.
Nothing needs migrating: no data, schema or dependency changed, and existing diff.json files stay valid. These comparisons produce the same results as before: equal thresholds, categorical or boolean Inspect scorers, and all promptfoo and JUnit comparisons. If you compared Inspect runs with numeric scores at different thresholds, diff() now raises an explicit ValueError instead of returning a verdict. To fix it, reload both runs with the same threshold. Because CLI behavior was not verified, check any CI script that wraps the CLI for how it surfaces this error. To roll back, revert commit eca495b. No stored artifacts are affected.
Verification
- Source: #95
- Version:
0.22.1 - Verified source commit:
5ac4e64f7c05b26f80f221ea015933981e832e2e - Behavioral acceptance and the repository's release checks passed.
Authored and reviewed with agent assistance; no human review is claimed.