Repository navigation
refactor(reporting): move inline report CSS and JavaScript into package assets - #198
Conversation
lanyue-llk
left a comment
There was a problem hiding this comment.
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), andsrc/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.pyfiles.source_policy.pylistsdelivery.pyunderCATALOG_RENDERERS, so it is renderer code. I found no recorded source hash for either file.BRIDGEandLOADERare plain constants, so they are the same kind of move ascomparison.py. - Fix: move
BRIDGEandLOADERtoweb_search/assets/. If anydeliveryasset is added, also add it toCATALOG_RENDERERS, as was done forcomparison. Then either move thereport_compaction.pyloaders 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:11andtests/test_packaging_hygiene.py:50. - Problem: the PR reports
browser_use/assets/webarena-autonomous-evaluation-flow.pngas a wheel bug and fixes it with one*.pngtoken, but nothing fails if that token is removed. I removed it and rantest_packaging_hygieneandtest_package_contents: 75 passed.verify_package_treederives its expected files from the sameMANIFEST.inline, andverify_report_assetsdoes not check the figure, so the install smoke would not catch it either.METHODOLOGY_FIGUREinbrowser_use/report.py:102needs this file in an installed package. - Fix: add
assert (package_root / 'browser_use/assets/webarena-autonomous-evaluation-flow.png').is_file()toverify_report_assets, or add*.pngunderbrowser_use/assetsto 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_attemptwithDID 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 threemainCI 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,\\dto\d, trailing newlines and the surrounding<style>/<script>text.public-webarena-comparison.jsmatches 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 oldreplaceand+=patches),CATALOG_REPORT_CSS,report_style.STYLE,comparison.STYLEandSCRIPT, Browser UseREPORT_STYLEandREPORT_JS, and_evidence_viewer_page(). - Hash bindings:
pyproject.tomlandsetup.pyare unchanged.collection_implementationdoes not list any changed file, andrenderer_sha256and rescoringsource_sha256bind only thereport.pyfiles this PR leaves alone.runtime_source_sha256globsweb_fetch/**/*.py, so its value changes withreport_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 inrefresh_assembly.pyandlocal_execution_contract.py. - Packaging: I built an sdist and then a wheel from it with
setuptools.build_meta. All new.cssand.jsassets, the figure andinterpretation-headless.cssare present. This closes the gap the PR's test plan notes about the*.pngtoken.verify_package_treeandverify_report_assetspass against the unpacked wheel, andbrowser_use.reportandwebarena_reportimport from it. - New test:
test_manifest_declared_assets_are_required_in_the_installed_packagehas real missing and changed controls. - Local checks: both ruff gates pass,
node --checkpasses on every new.js, andtests/browser_use/test_report_ui.mjspasses.test_golden_reports,test_packaging_hygiene,test_package_contents,test_report_software_versions,test_source_language_policy,test_documented_paths,test_report_presentationandtest_report_templatesgave 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.pyhash 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.
There was a problem hiding this comment.
✅ Re-review complete · b6f7aad
No findings in this incremental review.
|
Round 1 review fixes, all on head b6f7aad. Neither finding is disputed. Undisclosed JavaScript blobs (P2)
Browser Use figure not guarded in the wheel (P2)
CI
|
lanyue-llk
left a comment
There was a problem hiding this comment.
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,LOADERand the three compaction scripts are now assets. A scan of long CSS or JavaScript literals insrc/harnessfinds report-output blobs only inweb_fetch/report.pyandweb_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
*.pngfromMANIFEST.innow failstest_every_report_asset_is_declared_for_the_wheel.verify_report_assetsalso 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,comparisonanddeliveryconstants andREPORT_STYLEandREPORT_JSinbrowser_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.pystores 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_textreturns the bytes as stored.
Frozen bindings
collection_implementationdoes not name any changed file, andpyproject.toml,uv.lock,evaluation/andtests/golden/are unchanged.- The recorded renderer hashes read only
web_fetch/report.pyandweb_search/report.py, which this PR does not touch.report_style.pywas 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.cssare in the wheel. verify_package_treeandverify_report_assetspass against the unpacked wheel.- CI's
make package-checklog 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.mjspasses. 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_messagesandtest_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.
…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.
b6f7aad to
e21e3dd
Compare
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.
trajectory_replay/webarena_report.pytrajectory_replay/assets/webarena-report.css,webarena-report.js,webarena-article.css,webarena-catalog.csstrajectory_replay/public_webarena/report.pytrajectory_replay/assets/public-webarena-report.css,public-webarena-benchmark-tabs.js,public-webarena-comparison.js,public-webarena-execution-filter.jstrajectory_replay/report.pytrajectory_replay/assets/curated-report.css,curated-execution-filter.jstrajectory_replay/assets/suite-filter.js,evidence-dialog.js(the two copies were identical)browser_use/report.pybrowser_use/assets/report.css,report.js,evidence-viewer.jsweb_fetch/report_style.pyweb_fetch/assets/report-style.cssweb_search/comparison.pyweb_search/assets/comparison.css,comparison.jsweb_search/delivery.pyweb_search/assets/delivery-bridge.js,delivery-loader.jstrajectory_replay/report_compaction.pytrajectory_replay/assets/compact-detail-loader.js,compact-evidence-loader.js,compact-data-fetch-adapter.jswebarena_report.pyused to patch its strings withreplaceand+=, so its assets store the final values.public-webarena-comparison.jstakes the engine list through the__ENGINE_LIST__placeholder, the same way the execution filter already does.report_style.pywas not named in the issue, but it is entirely CSS.comparison.pyholds 12k characters of CSS and JavaScript.Packaging
pyproject.tomlis hash-bound bycollection_implementation, so it is not edited, and no declared pattern covers.css. The assets are declared withrecursive-includeinMANIFEST.in. setuptools ships those package files in both the sdist and the wheel.verify_package_treeintests/package_smoke.pynow reads those lines, so the exact-inventory and byte checks of an installed wheel cover the assets.verify_report_assetsstep checks that installed renderers load their assets from the package.assets/ortemplates/, not only.cssand.js, to be declared. Removing the*.pngtoken fromMANIFEST.innow fails it.verify_report_assetsalso 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, whichreport_explainer.pyreads.browser_use/assets/webarena-autonomous-evaluation-flow.png, the Browser Use methodology figure.Other changes
source_policy.pynow also checks thecomparisonanddeliveryassets, so moving them does not bypass the no-Chinese check on Search renderers.test_report_ui.mjsruns the shippedreport.jsinstead of extracting it from Python source with a regex.software_identityalready hashes.cssand.js. The new assets are added to its build-identity test.Left alone
web_fetch/report.pyandweb_search/report.py: their source hashes are recorded.report_build.pyrecordspresentation_refresh.renderer_sha256,rescoring.pyincludesreport.pyinsource_sha256, andweb_search/report.pyrecordsrenderer_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.webarena_report.pyare HTML with interpolated values.browser_use/report_visual.py,trajectory_replay/webarena_report_visual.pyandweb_search/visual.py, and page scripts used during execution such asplaywright_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:
tests/test_golden_reports.pypasses with no snapshot changes, along withtest_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_replayandtests/web_search: 3260 passed, 5 skipped. This run came before the one-token*.pngaddition toMANIFEST.in.node tests/browser_use/test_report_ui.mjspasses.comparisonandreport_styleconstants equal the base commit's values. The AST oftrajectory_replay/report.pyequals the base commit's once its assets are inlined again.verify_report_assetsimports load without them.setuptools.build_meta: all new.cssand.jsassets are in the wheel. This build also came before the*.pngaddition, so CI's package check is the first to confirm the figure.After review round 1:
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_searchandtest_report_compaction: 737 passed. No snapshot changed.*.pngremoved fromMANIFEST.in,test_every_report_asset_is_declared_for_the_wheelfails.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_assetspasses against the checkout. The figure in a real wheel is confirmed by CI's package check.test_native_cdp_portfailure did not recur; this PR does not touch that test or its code.