Skip to content

refactor(reporting): move inline report CSS and JavaScript into package assets - #198

Merged
lanyue-llk merged 4 commits into
mainfrom
refactor/report-inline-assets
Nov 3, 2026
Merged

lanyue-llk merged 4 commits into
mainfrom
refactor/report-inline-assets

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 #196

Two renderers stay inline because a recorded hash binds them; that work is tracked in #197. See "Left alone" below.

Summary

Inline CSS and JavaScript now live in package asset files, and each renderer loads them. Rendered bytes do not change, so no golden snapshot changed.

Renderer New asset files
trajectory_replay/webarena_report.py trajectory_replay/assets/webarena-report.css, webarena-report.js, webarena-article.css, webarena-catalog.css
trajectory_replay/public_webarena/report.py trajectory_replay/assets/public-webarena-report.css, public-webarena-benchmark-tabs.js, public-webarena-comparison.js, public-webarena-execution-filter.js
trajectory_replay/report.py trajectory_replay/assets/curated-report.css, curated-execution-filter.js
Both of the above trajectory_replay/assets/suite-filter.js, evidence-dialog.js (the two copies were identical)
browser_use/report.py browser_use/assets/report.css, report.js, evidence-viewer.js
web_fetch/report_style.py web_fetch/assets/report-style.css
web_search/comparison.py web_search/assets/comparison.css, comparison.js
web_search/delivery.py web_search/assets/delivery-bridge.js, delivery-loader.js
trajectory_replay/report_compaction.py trajectory_replay/assets/compact-detail-loader.js, compact-evidence-loader.js, compact-data-fetch-adapter.js
  • webarena_report.py used to patch its strings with replace and +=, so its assets store the final values.
  • public-webarena-comparison.js takes the engine list through the __ENGINE_LIST__ placeholder, the same way the execution filter already does.
  • The delivery and compaction scripts take their translated label, shard count, route and error prefix through placeholders. Python keeps the small HTML shells around them.
  • report_style.py was not named in the issue, but it is entirely CSS. comparison.py holds 12k characters of CSS and JavaScript.

Packaging

pyproject.toml is hash-bound by collection_implementation, so it is not edited, and no declared pattern covers .css. The assets are declared with recursive-include in MANIFEST.in. setuptools ships those package files in both the sdist and the wheel.

  • verify_package_tree in tests/package_smoke.py now reads those lines, so the exact-inventory and byte checks of an installed wheel cover the assets.
  • A new verify_report_assets step checks that installed renderers load their assets from the package.
  • A new test requires every report file under assets/ or templates/, not only .css and .js, to be declared. Removing the *.png token from MANIFEST.in now fails it.
  • verify_report_assets also requires the Browser Use figure and loads the delivery and compaction scripts.

Two files were already missing from the wheel and are fixed by the same lines:

  • web_fetch/templates/interpretation-headless.css, which report_explainer.py reads.
  • browser_use/assets/webarena-autonomous-evaluation-flow.png, the Browser Use methodology figure.

Other changes

  • source_policy.py now also checks the comparison and delivery assets, so moving them does not bypass the no-Chinese check on Search renderers.
  • test_report_ui.mjs runs the shipped report.js instead of extracting it from Python source with a regex.
  • software_identity already hashes .css and .js. The new assets are added to its build-identity test.

Left alone

  • web_fetch/report.py and web_search/report.py: their source hashes are recorded. report_build.py records presentation_refresh.renderer_sha256, rescoring.py includes report.py in source_sha256, and web_search/report.py records renderer_sha256. Moving the blobs would take presentation code out of those hashes, and a later style change would not refresh Web Fetch details. Move web_fetch and web_search report.py blobs once renderer hashes cover assets #197 tracks the decision.
  • environments/webarena/map_detail.py: its small style block belongs to an environment page, not a report renderer.
  • Small inline snippets: those under about 600 characters stay in place, such as base-URL bootstraps and the 225-character style in the compaction evidence page. The remaining long strings in webarena_report.py are HTML with interpolated values.
  • JavaScript that is not report output: the release-check probes in browser_use/report_visual.py, trajectory_replay/webarena_report_visual.py and web_search/visual.py, and page scripts used during execution such as playwright_tool.py, never reach a rendered page. They are outside Move inline report CSS and JavaScript into package assets #196.

Test plan

Run locally with the shared locked environment:

  • Lint gate: both ruff commands pass.
  • tests/test_golden_reports.py passes with no snapshot changes, along with test_packaging_hygiene, test_package_contents, test_report_software_versions, test_source_language_policy, test_documented_paths, test_report_presentation, test_webmainbench_report, test_report_templates, test_runtime_entrypoints, tests/browser_use, tests/trajectory_replay and tests/web_search: 3260 passed, 5 skipped. This run came before the one-token *.png addition to MANIFEST.in.
  • node tests/browser_use/test_report_ui.mjs passes.
  • One-off check for code the goldens do not cover: comparison and report_style constants equal the base commit's values. The AST of trajectory_replay/report.py equals the base commit's once its assets are inlined again.
  • One-off check with optional dependencies blocked: the renderers that verify_report_assets imports load without them.
  • Built an sdist, then a wheel from that sdist, with setuptools.build_meta: all new .css and .js assets are in the wheel. This build also came before the *.png addition, so CI's package check is the first to confirm the figure.

After review round 1:

  • Lint gate: both ruff commands pass.
  • tests/test_golden_reports.py, test_packaging_hygiene, test_package_contents, test_report_software_versions, test_source_language_policy, test_documented_paths, test_explicit_utf8_io, tests/web_search and test_report_compaction: 737 passed. No snapshot changed.
  • Negative control: with *.png removed from MANIFEST.in, test_every_report_asset_is_declared_for_the_wheel fails.
  • One-off check: BRIDGE, LOADER, both compaction loaders in both languages and for both route kinds, and the fetch adapter equal the base commit's output byte for byte.
  • verify_report_assets passes against the checkout. The figure in a real wheel is confirmed by CI's package check.
  • CI on the new head: "Tests and static checks" and "Installation and packaging" pass. The earlier test_native_cdp_port failure did not recur; this PR does not touch that test or its code.

@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 · 78e857d

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 78e857db. The move itself is byte-exact and the wheel is correct. Two P2 findings remain, and the required CI job is red on a test this PR does not touch.

Findings

P2: Closes #196 leaves JavaScript blobs in report code without disclosing them

  • Where: src/harness/web_search/delivery.py:19 (BRIDGE, 1,597 characters), src/harness/web_search/delivery.py:53 (LOADER, 1,620 characters), and src/harness/trajectory_replay/report_compaction.py:60-100 (_loader, _raw_evidence_loader, _data_fetch_adapter; the last has about 1,450 literal characters).
  • Problem: the PR's "Left alone" section says only inline snippets under about 600 characters stay in place, apart from the named exceptions. These are larger, ship into report pages and are in none of those exceptions, and #197 covers only the two report.py files. source_policy.py lists delivery.py under CATALOG_RENDERERS, so it is renderer code. I found no recorded source hash for either file. BRIDGE and LOADER are plain constants, so they are the same kind of move as comparison.py.
  • Fix: move BRIDGE and LOADER to web_search/assets/. If any delivery asset is added, also add it to CATALOG_RENDERERS, as was done for comparison. Then either move the report_compaction.py loaders with placeholders, or list them under "Left alone" with the reason (interpolated values) and add them to a follow-up issue linked from the PR.

P2: the Browser Use figure fix in the wheel has no regression guard

  • Where: MANIFEST.in:11 and tests/test_packaging_hygiene.py:50.
  • Problem: the PR reports browser_use/assets/webarena-autonomous-evaluation-flow.png as a wheel bug and fixes it with one *.png token, but nothing fails if that token is removed. I removed it and ran test_packaging_hygiene and test_package_contents: 75 passed. verify_package_tree derives its expected files from the same MANIFEST.in line, and verify_report_assets does not check the figure, so the install smoke would not catch it either. METHODOLOGY_FIGURE in browser_use/report.py:102 needs this file in an installed package.
  • Fix: add assert (package_root / 'browser_use/assets/webarena-autonomous-evaluation-flow.png').is_file() to verify_report_assets, or add *.png under browser_use/assets to the hygiene test.

CI on 78e857db

  • Passing: "Installation and packaging", "Rendered reference and report checks".
  • Failing: "Tests and static checks" (and "Python 3.11"): 1 failed, 19734 passed. The failure is tests/test_native_cdp_port.py::test_port_check_ignores_the_log_of_an_earlier_attempt with DID NOT RAISE RuntimeError.
  • Attribution: this does not look caused by the PR. The diff touches neither that test nor web_fetch/providers, the file passed 3 of 3 local runs at this head, and the last three main CI runs are green. It looks like an intermittent failure in a test that starts real processes, but I did not establish the mechanism. The job needs a rerun before this PR counts as green.

Verified with no defect

  • Asset bytes, by source comparison: I compared each asset with the base commit's AST string constants. All match exactly, including {{/}} unescaping, \\d to \d, trailing newlines and the surrounding <style>/<script> text. public-webarena-comparison.js matches on both sides of __ENGINE_LIST__. The JSON escaping of the engine list differs between the two scripts in the same way it did before.
  • Asset bytes, at runtime: values are identical at the base commit and at head for webarena _assets() CSS and JS (after the old replace and += patches), CATALOG_REPORT_CSS, report_style.STYLE, comparison.STYLE and SCRIPT, Browser Use REPORT_STYLE and REPORT_JS, and _evidence_viewer_page().
  • Hash bindings: pyproject.toml and setup.py are unchanged. collection_implementation does not list any changed file, and renderer_sha256 and rescoring source_sha256 bind only the report.py files this PR leaves alone. runtime_source_sha256 globs web_fetch/**/*.py, so its value changes with report_style.py. It is written into new run manifests and I found no code recomputing it against frozen evidence, though I only sampled its consumers in refresh_assembly.py and local_execution_contract.py.
  • Packaging: I built an sdist and then a wheel from it with setuptools.build_meta. All new .css and .js assets, the figure and interpretation-headless.css are present. This closes the gap the PR's test plan notes about the *.png token. verify_package_tree and verify_report_assets pass against the unpacked wheel, and browser_use.report and webarena_report import from it.
  • New test: test_manifest_declared_assets_are_required_in_the_installed_package has real missing and changed controls.
  • Local checks: both ruff gates pass, node --check passes on every new .js, and tests/browser_use/test_report_ui.mjs passes. test_golden_reports, test_packaging_hygiene, test_package_contents, test_report_software_versions, test_source_language_policy, test_documented_paths, test_report_presentation and test_report_templates gave 228 passed, with no snapshot changes in the diff.
  • Scope of browser_use/report.py: the edit is limited to the blob lines.
  • Follow-up: #197 exists and accurately describes the report.py hash reason.

Observation, not a finding

harness/lexbench/template/ (app.js, style.css, index.html, messages.json) is also absent from the wheel. This predates the PR, and lexbench/report.py:143-145 already says the default template needs a checkout. The new hygiene test matches assets/ and templates/, so it does not cover this singular template/ directory.

@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.

✅ Re-review complete · b6f7aad

No findings in this incremental review.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Round 1 review fixes, all on head b6f7aad. Neither finding is disputed.

Undisclosed JavaScript blobs (P2)

  • e4f6993 moves BRIDGE and LOADER from web_search/delivery.py to web_search/assets/ and adds both files to CATALOG_RENDERERS.
  • b6f7aad moves the three report_compaction.py scripts to trajectory_replay/assets/, passing interpolated values through placeholders. _javascript_source had no other use, so it is removed.
  • All of this output equals the base commit's byte for byte (one-off check), and no golden snapshot changed.
  • The PR body's "Left alone" list now names the remaining inline code: the 225-character style in the compaction evidence page, and release-check and execution-time JavaScript that never reaches a rendered page.

Browser Use figure not guarded in the wheel (P2)

  • a9caf06 extends the hygiene test from .css and .js to every file under assets/ and templates/, and verify_report_assets now requires the figure. Removing *.png from MANIFEST.in now fails the hygiene test.

CI

  • The earlier failure was test_native_cdp_port.py::test_port_check_ignores_the_log_of_an_earlier_attempt (DID NOT RAISE). This PR does not touch that test or the code it covers, and it passed on the new head. It looks like a timing race in the test: the fake CDP connect can return before the server process exits. I did not change it or reproduce the race.
  • "Tests and static checks" and "Installation and packaging" both pass on b6f7aad.

@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 b6f7aad0 against base f3201951. No defects found. Both round 1 findings are fixed.

Round 1 findings

  • Undisclosed blobs: BRIDGE, LOADER and the three compaction scripts are now assets. A scan of long CSS or JavaScript literals in src/harness finds report-output blobs only in web_fetch/report.py and web_search/report.py, the two files #197 tracks. The rest are the small snippets and non-report scripts named under "Left alone".
  • Figure not guarded in the wheel: removing *.png from MANIFEST.in now fails test_every_report_asset_is_declared_for_the_wheel. verify_report_assets also requires the figure.

Byte equivalence

I compared the two revisions directly, without using the author's check.

  • Every module-level string constant that exists at base hashes the same at head, including the report_style, comparison and delivery constants and REPORT_STYLE and REPORT_JS in browser_use/report.py.
  • _loader (task and result, both languages), _raw_evidence_loader (both languages) and the fetch adapter hash the same as at base.
  • The curated and public WebArena assets match the base literals, including their <style> and <script> boundaries and the __ENGINE_LIST__ positions.
  • webarena_report.py stores final values, but the base CSS and JS started from local literals. No shared style stops propagating.
  • No asset contains a carriage return, and read_text returns the bytes as stored.

Frozen bindings

  • collection_implementation does not name any changed file, and pyproject.toml, uv.lock, evaluation/ and tests/golden/ are unchanged.
  • The recorded renderer hashes read only web_fetch/report.py and web_search/report.py, which this PR does not touch. report_style.py was never in those hashes, so moving its CSS loses no coverage.

Packaging

  • I built an sdist, then a wheel from that sdist. All 23 new assets, the figure and interpretation-headless.css are in the wheel.
  • verify_package_tree and verify_report_assets pass against the unpacked wheel.
  • CI's make package-check log reports the installed-wheel checks passing.

Negative controls

Change Result
Remove *.png from MANIFEST.in Hygiene test fails
Remove the trajectory_replay line from MANIFEST.in Hygiene test fails
Add Chinese text to delivery-bridge.js check_source_languages reports it
Add one space to browser_use/assets/report.css Browser Use goldens fail
Add one space to webarena-report.js Trajectory Replay goldens fail

Tests and CI

  • Both ruff commands pass, and node tests/browser_use/test_report_ui.mjs passes.
  • test_golden_reports, test_packaging_hygiene, test_package_contents, test_report_software_versions, both source-language tests, test_explicit_utf8_io, test_local_path_privacy, test_delivery, test_messages and test_report_compaction: 246 passed, with no snapshot changes.
  • CI on this head: "Tests and static checks", "Installation and packaging" and "Rendered reference and report checks" all pass.

Scope

Closes #196 is accurate. Blobs moved to package assets, rendered bytes are unchanged, the wheel carries the assets, and the packaging check covers them. The two files left alone are disclosed in the PR and tracked in #197, as the issue allows. The assets table in the PR body lists all 23 new files.

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

Renderers now load their stylesheets and scripts from package files, with the rendered bytes unchanged. MANIFEST.in declares the files because pyproject.toml is hash-bound by the search collection implementation.
… the wheel

The hygiene test only covered CSS and JavaScript, and the package tree check derives its inventory from the same MANIFEST.in line, so dropping the PNG token passed. The test now covers all files under assets/ and templates/, and the installed package smoke requires the Browser Use figure.
BRIDGE and LOADER now load from web_search/assets with unchanged bytes. The translated download label stays a placeholder filled from the language catalog, and the source policy checks both files.
The detail loader, evidence loader and fetch adapter now load from trajectory_replay/assets, with shard count, route and localized error passed as placeholders. Their output is unchanged. The installed-package smoke loads these and the delivery scripts.
@lanyue-llk
lanyue-llk force-pushed the refactor/report-inline-assets branch from b6f7aad to e21e3dd Compare November 3, 2026 23:17

@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 · e21e3dd

No findings in this review.

@lanyue-llk
lanyue-llk merged commit 2be092b into main Nov 3, 2026
7 checks passed
@lanyue-llk
lanyue-llk deleted the refactor/report-inline-assets branch November 3, 2026 23:26
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.

Move inline report CSS and JavaScript into package assets

1 participant