noteflowai/evalarc · 0.23.5 · 2026-11-27

fix: name the malformed field when an Inspect log's results headline section crashes the loader

load_results reads Inspect .json logs and .eval archives, and evalarc diff calls it. Its headline block used to fail with an internal AttributeError, KeyError or TypeError on seven malformed values in a log's results section. Each now raises a ValueError. The message names the field path, the value's JSON type and the recovery step, which is to re-export the log with inspect log dump. The paths are results, results.scores, results.scores[N], results.headline, results.headline.metric, results.scores[N].metrics[K] and results.scores[N].name. Metric names in messages go through the existing _shown_id helper, so an ESC character appears as \x1b. Each check runs only where the old code raised, and in the same order. Logs that loaded before load the same way and keep the same headline, including the recorded examples (0.625 and 0.8125). An .eval archive gives the same message through its header.json. evalarc diff exits 2 with the message on stderr, creates no --output folder and leaves an existing --markdown file unchanged. On the base commit, the same CLI case already exited 2, but stderr showed only the internal text "evalarc: 'str' object has no attribute 'get'". docs/ci-gate.md lists this case under exit code 2.

Use it

Prerequisites: a checkout of evalarc at commit 933328b6 with the package installed (for example pip install -e .). Run the commands from the repository root.

Step 1. Create a synthetic broken input. This copies the recorded example log and replaces its results section by hand. It is not a real Inspect export.

python - <<'EOF'
import json
doc = json.load(open("examples/results-diff/inspect/baseline.json"))
doc["results"] = {"scores": {"match": {}}}
json.dump(doc, open("broken-current.json", "w"))
EOF

Step 2. Run the gate:

evalarc diff examples/results-diff/inspect/baseline.json broken-current.json --output review
echo "exit $?"

Expected result: stderr shows a line starting "evalarc: Inspect log field results.scores must be an array (got object)" that ends with the inspect log dump recovery step. The command prints exit 2 and creates no review/ folder.

Step 3 (optional). Run the acceptance tests:

python -m pytest -q tests/test_feature_7dbc22414404.py

Scope

Scope: one entry point (load_results, and evalarc diff through it) and one input (the Inspect results section of .json logs and of .eval header.json). Only the seven crashes the old code actually reached are fixed. These values are still not checked: groups after the selected group, unselected metric entries, a marker in a log with empty or absent scores, and a truthy metrics value that is not an object (it still skips or crashes as before). The types of the marker's score and of group names are not checked either. eval.config, the promptfoo loader and the JUnit loader are unchanged. Falsy values of the wrong type are still treated as absent. Evidence: the controller ran the checks. I ran nothing myself. The acceptance tests are synthetic edits of the recorded example logs, not real damaged exports. On the base commit, tests/test_feature_7dbc22414404.py had 13 failures and 13 passes; the failures were the crash cases. On candidate 933328b6, the controller ran that file, the full pytest suite, ruff check, ruff format --check, scripts/build_site.py and scripts/check_site.cjs, and all exited 0. This resolves the earlier ruff format failure. The supplied log excerpt does not include pass counts for the candidate run. The CLI exit-2 path is tested only for the results.scores-is-an-object case. The other six cases are tested through load_results only. Passing these tests shows these inputs behave as specified. It does not prove that every malformed log is handled. Browser: check_site.cjs ran the existing showcase regression checks at 1440, 390 and 320 px widths, with keyboard and offline variants. This change adds no UI, and I reviewed no screenshots of it.

Upgrade and rollback

This is a patch-level fix with no new options, output fields or dependencies. A log that loaded before loads the same way and keeps its headline. A log that hit one of the seven covered crashes now gets a ValueError naming the bad field. Through evalarc diff, that log exits 2 with that message. In the one CLI case tested on the base commit, the exit code was already 2 and only the message changed. Scripts that match the old internal error text on stderr need updating. To roll back, revert commit 933328b6. No stored data or report format changes.

Source commit: 480d1ab40164934cec123b343eb0cb774b78f849