Repository navigation
test: add golden route-hash snapshots for report tracks - #119
Conversation
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
Build each report track's synthetic example and compare every route with a committed SHA-256, so refactors that change rendered output fail the suite. Machine-specific bytes (build paths, digests of path-bearing evidence, clock and host identity) are normalized or pinned before hashing. Refs #88. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Reports record the builder's git revision and source hash, which change with every commit. Pin them so the snapshots only track rendered content. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The runner records a hash of every Web Fetch module in its manifest, so the snapshot changed with any source edit. Replace it with a token. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A reused GOLDEN_KEEP directory kept routes from earlier builds, so diff -r could hide a removed route. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
103735c to
2bd3201
Compare
lanyue-llk
left a comment
There was a problem hiding this comment.
Not mergeable yet: CI is red on the current head (2bd3201). Tests and static checks fails in test_wcxb_report; the other nine snapshots and the rest of the suite pass.
The WCXB snapshot depends on the platform. tests/golden/wcxb.json was generated on macOS and cannot match on Linux (details inline). That also makes this line of the test plan inaccurate: "CI on Linux reproduced the WCXB … digests on the first push". It does not reproduce on the current head.
Everything else looks right:
- The builder-identity pin covers both callers of
software_identity(reporting/versions.pyandweb_fetch/runner.py), so commit-dependent bytes can't leak into the snapshots. - The clock and host pins for Web Fetch are scoped by
monkeypatch. - Extracting
sample_report_inputsleaves the existing test's behaviour unchanged. - I reproduced 10/10 passing locally on macOS (Python 3.11.16, zlib 1.2.12), which is consistent with the diagnosis below.
After the fix, please include the Linux CI run in the test plan as proof that the snapshots are portable.
The WCXB source hash covers the fixture's gzipped pages, and the reproduce and review pages render it, so the WCXB snapshot failed on Linux CI. Two platform-dependent parts of those bytes: - gzip.compress delegates to zlib, which writes the build platform into the header OS byte (19 on macOS, 3 on Linux); GzipFile always writes 255. - Deflate output differs between zlib builds such as zlib-ng; stored (level 0) blocks do not. Co-Authored-By: Claude Opus 5.5 <[email protected]>
c03d844 to
b7ac360
Compare
Summary
Adds golden route-hash snapshots so a refactor that changes rendered report output fails
make test. This is step 0 of the refactor roadmap (#87); the later cleanup PRs rely on it to prove they change no output.Issues
How it works
tests/test_golden_reports.pybuilds the synthetic example of each report track and compares every output file withtests/golden/<build>.json, which maps route → SHA-256. The JSON files are hash bindings, not generated reports (92 KB total).tests/golden_snapshots.pynormalizes machine-specific bytes before hashing:<build-root>;attempts.jsonl/results.jsonby SHA-256, and those files name absolute evidence paths, so their digests become<path-bearing-input-sha256>.harness.reporting.versions.software_identity). Reports record the git revision and source hash, which change with every commit; without the pin, any refactor would rewrite every snapshot.utc_now,monotonic,perf_counter) and the recorded host (platform, hostname, Python version), because run IDs, timestamps, timings and the execution manifest come from them. The runner'sruntime_source_sha256(a hash of every Web Fetch module) is replaced with<source-sha256>.UPDATE_GOLDEN=1rewrites the snapshots. On a mismatch the failure lists changed, added and removed routes. Only hashes are stored, so it cannot print the old text;GOLDEN_KEEP=<dir>keeps the normalized build fordiff -ragainst another revision. CONTRIBUTING.md documents both.Coverage
tests/browser_use/test_report.py::build_browser_use_fixturetests/trajectory_replay/test_webarena_report.py::build_replay_fixturetests/public_webarena_fixture.py::write_report_fixture+stage_reportharness.web_search.exampletests/wcxb_fixture.py::create_report_inputs+generate_wcxbtests/test_webmainbench_report.py::sample_report_inputs(extracted from an inline test body; the test is unchanged)tests/test_webmainbench_full_report.py::render_full_reportrun_evaluationwithFixtureProvider+build_report, English and ChineseNot covered: LexBench (
harness/lexbench/report.py). Itsmain()needs a full saved-profile evidence tree and no test builds one. A builder belongs with the renderer split in #104.The issue's optional "record which translation keys were hit" is left for #99, where it is used.
Test plan
-n 4) gives identical bytes.P50 ms→P50 (ms)in the Web Search report) fails exactlyweb-search: index.html(and the manifest that binds it).test_webmainbench_report,test_webmainbench_full_report,browser_use/test_report,trajectory_replay/test_webarena_report,test_wcxb_report_languages.ruff check(E, F, B, I, UP) is clean on the new files, andmake lint-checkpasses.uv run --frozen --all-extras) match a second environment byte for byte.make test-pythonlocally: 18,798 passed. 14 failures also fail on unmodifiedmainin this macOS setup (Node-based Markdown converter, CI-gate and local-data tests); 2 failed only under-n 8load and pass on rerun.🤖 Generated with Claude Code