Repository navigation
fix(reporting): pin one exact Mermaid runtime for every CDN renderer - #177
Conversation
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 1
Reviewed head 489e654c against base 6f801e04. I found no code defects. There are two P3 corrections to the PR's hash-binding table, which is a deliverable of #171. Both are text fixes unless you prefer to revert the comment edit in finding 2.
Findings
P3: src/harness/web_fetch/report_version.py:43: the table says the rescoring hash is "never verified afterwards", but it is read and compared.
_verify_scores compares each row's scoring.source_sha256 with the release's scoring_source_sha256, and rescoring.py:143-152 includes web_fetch/report.py in that value. The PR's conclusion still holds, because the comparison is between two stored values and never rehashes the current report.py. Editing the renderer therefore cannot change the outcome for existing rows.
Fix: reword the row to something like "Compared only with the stored release hash, never with the current source; this edit changes the value new rescores record, not the result for existing records."
P3: src/harness/trajectory_replay/webarena_report_visual.py:428: this file is hash-bound, and the table does not list it.
Visual receipts store checker_sources(Path(__file__)), and receipt_is_current rejects a mismatch (reporting/visual.py:116). This one-word comment edit therefore makes every existing replay visual receipt stale, including one for an unrebuilt report. No evidence breaks, because webarena_report_package.py:37-38 reruns the gate at packaging, but the table's only replay row says "None found".
Fix: add a row for this file, or revert the comment edit. The old comment was only slightly out of date.
What I verified
Scope
- A repository-wide search finds one Mermaid CDN URL, in
src/harness/reporting/mermaid.py, and otherwise only test controls. scripts/moli_report/index.htmlandlexbench/pack.pyload a retained local file. That file is hash-checked inlexbench/report.py:1570, was left alone, and is tracked by open issue #175.Closes #171is justified.
Integrity
- I downloaded
[email protected]/dist/mermaid.min.jsand recomputed the SHA-384, which matchesMERMAID_INTEGRITY. - Its SHA-256 starts with
a43bc1afand differs from the Lexbench digest, as the PR and #175 state.
Golden changes
- I built base and head with
GOLDEN_KEEPand randiff -rq. Only the five file differences the PR describes appear:environment.htmlanden/environment.htmlin both replay snapshots, andweb-search/manifest.json. - The manifest differs only in
renderer_sha256. Every other route in the ten snapshots is byte-identical, including theweb_fetchandweb_searchloader pages.
Replay loader change
- The old module script is replaced by a classic inline script placed after the
.mermaidnode, so the query at parse time still finds the node. The slicing marker for the Rainbond branch was updated. - A failed load leaves the fallback visible, as before.
- The visual gate's
local_pageaborts all remote requests, so it measures the fallback both before and after this change. The move away from a module script, which could delayDOMContentLoaded, causes no gate timing regression.
Rendering
- I opened the synthetic
environment.htmlanden/environment.htmlin Chrome at 1280 and 390 widths, with light and dark colour schemes emulated and the CDN request served from the downloaded file. - Each run rendered 7 nodes, hid the fallback, showed no horizontal overflow and raised no page errors. The page's
data-themestayedlightin all runs, so Mermaid's dark theme was not exercised. - The non-Rainbond
flowchart LRpath is not in the golden fixtures. I rendered an abridged approximation of it, using the same syntax forms with Chinese labels, against 11.4.1 and it parsed.
Tests fail without the fix
- With the new owner, test file and
golden_snapshots.pycopied onto the base renderers,test_only_the_owner_names_a_mermaid_urland bothtest_trajectory_replay_reportcases fail. - The golden failure names
mermaid@11/dist/mermaid.esm.min.mjs.
Other hash bindings
- The pre-change SHA-256 of none of the four edited source files appears anywhere in the base tree, including
evaluation/,research/andconfigs/. collection_implementation()excludes the renderer andharness/reporting/, so the new module does not affect cohort resume.SCORING_SOURCE_FILESis limited to scorer modules.renderer_sha256inweb_search/report.py:1326is only stamped, and thepresentation_refreshvalue only selects pages to re-render, as the PR says.
Local runs and CI
- Both ruff gates pass.
- 95 tests pass across
test_golden_reports,test_report_mermaid_pin,test_webarena_reportandtest_webarena_visual_check. - 95 more pass across
test_file_report_reason,test_explicit_utf8_ioandweb_search/test_runner. - I did not run the full suite locally. All CI checks pass on this head, including "Tests and static checks", "Installation and packaging" and "Rendered reference and report checks". The PR is mergeable and its base matches current main.
|
Review round 1: Fixed
Disputed: nothing. |
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 2
Reviewed head a0a991c3 against base 6f801e04, which is still the head of main. I found no defects at any severity.
Round 1 follow-up
webarena_report_visual.pynow matchesmain, so existing replay visual receipts stay current. The "Mermaid module" comment at line 428 is slightly dated, but it stays on purpose to keep those bytes.- The PR's hash-binding table now has the corrected rescoring wording and a row for the visual checker.
What I verified
Shared owner and scope
- A repository-wide search finds a Mermaid CDN URL only in
reporting/mermaid.pyand in the negative controls intests/test_report_mermaid_pin.py. report_explainer.pyonly emits<pre class="mermaid">and relies on theweb_fetchloaders. Browser Use loads no Mermaid runtime.- The Lexbench runtime is vendored and SHA-256 bound, has no CDN URL, and is tracked in open follow-up #175.
Closes #171is accurate under the issue's scope.
Integrity digest
- I downloaded
[email protected]/dist/mermaid.min.jsand computed its SHA-384. It matchesMERMAID_INTEGRITY.
Old and new loader bytes
- At the base commit, the
web_fetchandweb_searchloaders used the same URL, digest and attribute order that the owner now emits. - I built golden routes at base and head with
GOLDEN_KEEPand compared them. Only these routes differ:environment.htmlanden/environment.htmlintrajectory-replay-passandtrajectory-replay-failmanifest.jsoninweb-search, where the only changed key isrenderer_sha256
- Those differences match the PR's explanation. The routes in
wcxb,web-fetch,webmainbench-sampleandweb-searchthat carry the pinned loader are byte-identical to base.
Replay loader behaviour
- I opened the golden
environment.htmlanden/environment.htmlin Chrome, with the CDN request served from the downloaded file:
| CDN response | Diagram | Fallback |
|---|---|---|
| Real file | Renders with 7 nodes | Hidden |
| Tampered file | Rejected on integrity | Visible |
| Blocked request | Not loaded | Visible |
- The Rainbond script reuses the same block and sits after its
<pre>, so running it during parsing is safe. - Moving from a module script to a dynamically inserted classic script changes
DOMContentLoadedtiming, but this does not affect the visual gate.local_pageaborts non-local requests, so the gate exercises the fallback either way.
Move to 11.4.1
- Both replay flowcharts render on 11.4.1 in both languages: the
flowchart TDRainbond diagram and theflowchart LRtopology, which the PR's browser check did not cover. Rendering was the only thing checked for theflowchart LRtopology; it was not opened at report-page level.
Test strength
- I changed
web_search/report.pyto loadmermaid@11. Bothtest_only_the_owner_names_a_mermaid_urlandtest_web_search_reportfailed, the second one through the newcheck_goldenrule. I then restored the file.
Hash bindings
- The base-commit SHA-256 of each of the three renderers appears nowhere in the tracked files at base.
template_identityrecords paths only.renderer_sha256inreport_build.pyis only used to decide whether to re-render, as the PR says.
Local gates
- Both lint runs pass.
tests/test_golden_reports.py,tests/test_report_mermaid_pin.py,tests/trajectory_replay/test_webarena_report.pyandtests/trajectory_replay/test_webarena_visual_check.py: 95 passed.
CI at a0a991c3
- Tests and static checks, Installation and packaging, Rendered reference and report checks, and Python 3.11 all succeeded.
Not run
- The full test suite locally (CI ran it).
- The report visual release gates.
- A dark-theme or narrow-width browser check.
…rrent Visual receipts bind this file through checker_sources, so a comment-only edit made existing replay receipts stale for no functional gain.
a0a991c to
9cfafa9
Compare
Issues
Closes #171
Follow-up: #175 (the hash-bound vendored Lexbench runtime, left alone here).
Summary
src/harness/reporting/mermaid.pynow owns one exact Mermaid version (11.4.1), its URL and its Subresource Integrity digest. The three renderers that load Mermaid from a CDN all use it.trajectory_replay/webarena_report.pyimportfrommermaid@11, no version pin, no integrityweb_fetch/report.py(2 loaders)web_search/report.pyThe issue listed all three as
mermaid@11. Only the replay renderer was actually unpinned.Subresource Integrity: it applies to all three. A dynamic ESM
importcannot carry integrity, so the replay page moved to the same classic script loader the other reports already use. I downloaded[email protected]/dist/mermaid.min.jsand confirmed its SHA-384 matches the digest.Replay diagrams move to 11.4.1.
mermaid@11resolved to the newest 11.x release, so newly built replay reports now use an older runtime than before. The two replay flowcharts use only plain nodes and labelled edges. Stored and published reports are not rebuilt.Rejecting an unpinned URL:
unpinned_mermaid_urlsflags any Mermaid URL other than the pinned one.tests/test_report_mermaid_pin.pyhas negative controls for a bare, major-only,latest, wrong-version, protocol-relative and other-CDN URL. It also fails if any source undersrc/harnessorscriptsother than the owner names a Mermaid URL.check_goldennow runs the same check on every generated HTML and JS route, so all report tracks are covered at the built-output level.Hash-bound sources
I checked each renderer before editing it.
src/harness/lexbench/report.pyand the retainedmermaid.min.jsweb_search/report.pyrenderer_sha256is stamped into each newmanifest.jsonand never compared against a stored value.collection_implementation()excludes this file, so frozen run contracts are unaffectedmanifest.jsonchanges (below)web_fetch/report.py,presentation_refresh.renderer_sha256web_fetch/report.py, rescoringscoring.source_sha256_verify_scorescompares it only with the stored release hash, never with the current sourcetrajectory_replay/webarena_report.pytrajectory_replay/webarena_report_visual.pychecker_sources, andreceipt_is_currentrejects a mismatchNone of the three current renderer hashes appears under
evaluation/,research/orconfigs/. Scoring source hashes do not cover these renderers, so measured evidence, frozen profiles and receipts are untouched.Because the version now lives outside
web_fetch/report.pyandweb_search/report.py, a future version bump in the owner would not change those two hashes. The same already applies to their other imported modules, such asreport_style.py.Golden route changes
I built the base commit and this branch with
GOLDEN_KEEPand compared them withdiff -r. These are the only differences:trajectory-replay-pass,trajectory-replay-failenvironment.html,en/environment.htmlmermaid@11ESM import to the pinned loader with integrityweb-searchmanifest.jsonrenderer_sha256value changes, becauseweb_search/report.pywas edited. No rendered page changeswcxb,web-fetch,webmainbench-sample,webmainbench-full,browser-use-*,public-webarenaand all other routes are byte-identical.Test plan
ruff checkruns pass.tests/test_golden_reports.pyandtests/test_report_mermaid_pin.pypass after the snapshot update. Before the update, exactly the three snapshots above failed.tests/trajectory_replay,tests/web_search,test_source_language_policy,test_report_software_versions,test_scoring,test_local_audit,test_file_report_reason,test_webmainbench_report,test_webmainbench_full_report, together with the two files above: 2843 passed, 5 skipped.node tests/test_report_ui.mjsandnode tests/test_report_loader.mjspass.en/environment.htmlin Chromium at one desktop width, light theme only, with the CDN request served from the downloaded file:tests/test_golden_reports.py,tests/test_report_mermaid_pin.pyandtests/trajectory_replay/test_webarena_report.pypass (71 passed). The earlier wider runs above were not repeated.