Skip to content

fix(reporting): pin one exact Mermaid runtime for every CDN renderer - #177

Merged
lanyue-llk merged 2 commits into
mainfrom
fix/report-mermaid-exact-version
Nov 3, 2026
Merged

lanyue-llk merged 2 commits into
mainfrom
fix/report-mermaid-exact-version

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

What, why and how of this PR

Issues

Closes #171

Follow-up: #175 (the hash-bound vendored Lexbench runtime, left alone here).

Summary

src/harness/reporting/mermaid.py now 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.

Renderer Before After
trajectory_replay/webarena_report.py import from mermaid@11, no version pin, no integrity Classic script from the shared owner, with integrity
web_fetch/report.py (2 loaders) Own copies of the 11.4.1 URL and digest Shared owner, same bytes
web_search/report.py Own copy of the 11.4.1 URL and digest Shared owner, same bytes

The issue listed all three as mermaid@11. Only the replay renderer was actually unpinned.

Subresource Integrity: it applies to all three. A dynamic ESM import cannot 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.js and confirmed its SHA-384 matches the digest.

Replay diagrams move to 11.4.1. mermaid@11 resolved 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_urls flags any Mermaid URL other than the pinned one.

  • tests/test_report_mermaid_pin.py has negative controls for a bare, major-only, latest, wrong-version, protocol-relative and other-CDN URL. It also fails if any source under src/harness or scripts other than the owner names a Mermaid URL.
  • check_golden now 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.

Source Binding Effect of this change
src/harness/lexbench/report.py and the retained mermaid.min.js The build rejects a runtime whose SHA-256 differs from a hard-coded digest Left alone. It has no CDN URL and is already exact, but its bytes differ from jsDelivr 11.4.1. See #175
web_search/report.py renderer_sha256 is stamped into each new manifest.json and never compared against a stored value. collection_implementation() excludes this file, so frozen run contracts are unaffected The golden manifest.json changes (below)
web_fetch/report.py, presentation_refresh.renderer_sha256 Compared only to decide whether saved result pages get re-rendered The next local presentation refresh of a current-snapshot report re-renders all its result pages, as with any edit to this file. No scores or calls change
web_fetch/report.py, rescoring scoring.source_sha256 Written as provenance when rescoring runs. _verify_scores compares it 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
trajectory_replay/webarena_report.py None found None
trajectory_replay/webarena_report_visual.py Visual receipts store its hash through checker_sources, and receipt_is_current rejects a mismatch Left alone. Not edited, so existing replay visual receipts stay current

None of the three current renderer hashes appears under evaluation/, research/ or configs/. 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.py and web_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 as report_style.py.

Golden route changes

I built the base commit and this branch with GOLDEN_KEEP and compared them with diff -r. These are the only differences:

Snapshot Route Why
trajectory-replay-pass, trajectory-replay-fail environment.html, en/environment.html The topology script changes from the mermaid@11 ESM import to the pinned loader with integrity
web-search manifest.json Only the renderer_sha256 value changes, because web_search/report.py was edited. No rendered page changes

wcxb, web-fetch, webmainbench-sample, webmainbench-full, browser-use-*, public-webarena and all other routes are byte-identical.

Test plan

  • Lint gate: both ruff check runs pass.
  • tests/test_golden_reports.py and tests/test_report_mermaid_pin.py pass 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.mjs and node tests/test_report_loader.mjs pass.
  • Opened the synthetic replay en/environment.html in Chromium at one desktop width, light theme only, with the CDN request served from the downloaded file:
    • Real file: the diagram renders with 7 nodes and the fallback is hidden.
    • Tampered file: the browser rejects it on integrity and the fallback stays visible.
    • Blocked request: the fallback stays visible.
  • After removing the comment edit from the visual checker: lint gate passes, and tests/test_golden_reports.py, tests/test_report_mermaid_pin.py and tests/trajectory_replay/test_webarena_report.py pass (71 passed). The earlier wider runs above were not repeated.
  • Not run locally: the full test suite and the report visual release gates. CI runs the full suite.

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Review complete · 489e654

No findings in this review.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.html and lexbench/pack.py load a retained local file. That file is hash-checked in lexbench/report.py:1570, was left alone, and is tracked by open issue #175. Closes #171 is justified.

Integrity

  • I downloaded [email protected]/dist/mermaid.min.js and recomputed the SHA-384, which matches MERMAID_INTEGRITY.
  • Its SHA-256 starts with a43bc1af and differs from the Lexbench digest, as the PR and #175 state.

Golden changes

  • I built base and head with GOLDEN_KEEP and ran diff -rq. Only the five file differences the PR describes appear: environment.html and en/environment.html in both replay snapshots, and web-search/manifest.json.
  • The manifest differs only in renderer_sha256. Every other route in the ten snapshots is byte-identical, including the web_fetch and web_search loader pages.

Replay loader change

  • The old module script is replaced by a classic inline script placed after the .mermaid node, 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_page aborts all remote requests, so it measures the fallback both before and after this change. The move away from a module script, which could delay DOMContentLoaded, causes no gate timing regression.

Rendering

  • I opened the synthetic environment.html and en/environment.html in 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-theme stayed light in all runs, so Mermaid's dark theme was not exercised.
  • The non-Rainbond flowchart LR path 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.py copied onto the base renderers, test_only_the_owner_names_a_mermaid_url and both test_trajectory_replay_report cases 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/ and configs/.
  • collection_implementation() excludes the renderer and harness/reporting/, so the new module does not affect cohort resume.
  • SCORING_SOURCE_FILES is limited to scorer modules.
  • renderer_sha256 in web_search/report.py:1326 is only stamped, and the presentation_refresh value 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_report and test_webarena_visual_check.
  • 95 more pass across test_file_report_reason, test_explicit_utf8_io and web_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.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 1:

Fixed

  • Visual checker hash binding: a0a991c reverts the one-word comment edit in webarena_report_visual.py. The file is now identical to main, so existing replay visual receipts stay current. The hash-binding table has a new row for this file.
  • Rescoring hash wording: the table row now says _verify_scores compares scoring.source_sha256 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. This was a PR text change, so it has no commit.

Disputed: nothing.

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Review complete · a0a991c

No findings in this review.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py now matches main, 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.py and in the negative controls in tests/test_report_mermaid_pin.py.
  • report_explainer.py only emits <pre class="mermaid"> and relies on the web_fetch loaders. 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 #171 is accurate under the issue's scope.

Integrity digest

  • I downloaded [email protected]/dist/mermaid.min.js and computed its SHA-384. It matches MERMAID_INTEGRITY.

Old and new loader bytes

  • At the base commit, the web_fetch and web_search loaders used the same URL, digest and attribute order that the owner now emits.
  • I built golden routes at base and head with GOLDEN_KEEP and compared them. Only these routes differ:
    • environment.html and en/environment.html in trajectory-replay-pass and trajectory-replay-fail
    • manifest.json in web-search, where the only changed key is renderer_sha256
  • Those differences match the PR's explanation. The routes in wcxb, web-fetch, webmainbench-sample and web-search that carry the pinned loader are byte-identical to base.

Replay loader behaviour

  • I opened the golden environment.html and en/environment.html in 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 DOMContentLoaded timing, but this does not affect the visual gate. local_page aborts 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 TD Rainbond diagram and the flowchart LR topology, which the PR's browser check did not cover. Rendering was the only thing checked for the flowchart LR topology; it was not opened at report-page level.

Test strength

  • I changed web_search/report.py to load mermaid@11. Both test_only_the_owner_names_a_mermaid_url and test_web_search_report failed, the second one through the new check_golden rule. 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_identity records paths only.
  • renderer_sha256 in report_build.py is 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.py and tests/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.

lanyue-llk added a commit that referenced this pull request Nov 3, 2026
…rrent

Visual receipts bind this file through checker_sources, so a comment-only
edit made existing replay receipts stale for no functional gain.
@lanyue-llk
lanyue-llk force-pushed the fix/report-mermaid-exact-version branch from a0a991c to 9cfafa9 Compare November 3, 2026 17:14

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Review complete · 9cfafa9

No findings in this review.

@lanyue-llk
lanyue-llk merged commit f1b9cb0 into main Nov 3, 2026
7 checks passed
@lanyue-llk
lanyue-llk deleted the fix/report-mermaid-exact-version branch November 3, 2026 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pin one exact Mermaid version across report renderers

1 participant