Skip to content

refactor(reports): remove hardcoded leftovers from renderers - #236

Merged
lanyue-llk merged 5 commits into
mainfrom
refactor/remove-hardcoded-leftovers
Nov 4, 2026
Merged

lanyue-llk merged 5 commits into
mainfrom
refactor/remove-hardcoded-leftovers

Conversation

@lanyue-llk

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

Copy link
Copy Markdown
Contributor

What, why and how of this PR

Issues

Closes #97. Everything else it listed is frozen or hash-bound, so it stays:

Closes #98. What stays, and why, is under "Deliberately left":

The inline CSS and JS and the Mermaid pin from #98 are finished, in every track.

Part of #183: network_preflight.py now reads hosted. headless_worker.py and task_outputs.py remain there. #205 is untouched.

Summary

Inline CSS and JavaScript. About 76k characters in web_fetch/report.py and 9k in web_search/report.py move to package assets, as other tracks already do (web_fetch/assets/{report.js,report-extra.css,wcxb.*,webmainbench-full.*,cohort-diagnostic.*}, web_search/assets/{report.css,report.js,native-evidence-result.js}). In WCXB, the old slice and replace calls that patched its script are gone, because the asset holds the final text.

Renderer hashes (the question from #197). A new renderer_sha256() in report_build.py hashes report.py plus the CSS and JS in assets/, so a style change still refreshes Web Fetch details. This also covers report-style.css, which was outside the hash until now. Recorded values stay valid: presentation_refresh.renderer_sha256 is only compared to decide whether to render again, so the first build after this change refreshes, as after any renderer edit. The Web Search renderer_sha256 covers its assets the same way. The source_sha256 in the rescoring.py audit still names report.py only, because CSS and JS cannot change a score.

Measured values.

  • The complete WebMainBench report reads its population from profile["case_count"] and the metric populations from the score summaries' denominators.
  • The public research report reads 1,497/511, 200, 545 and 150 from its research document.
  • "WebMainBench 545" stays as the dataset's name.

Theme key. wmb545-theme becomes webmainbench-theme. A reader's saved theme on that report resets once.

Participant literals. _engine_definition becomes public engine_definition, with no new registry. These now read it instead of testing for kitesurf or chromium: network_preflight.py, report_explainer.py, webmainbench_certification.py and the labels in report.py. report_pricing.py uses native_browser_engine instead of a nine-name set. This can change one case: a browser method outside the old set, such as a new Moli variant, now gets the browser cost table instead of the price comparison. lexbench check --site and MOLI_REPORT_SITE are now required, instead of defaulting to one old report's directory.

Release IDs. first_correction in report_changes.py had no caller, so it and its test are gone, along with 2026-09-03-fairness-correction. webmainbench_correction.py reads hosted for its version argument.

Rendered output

With real populations, output is byte-identical apart from the theme key. I rendered the complete report from the old and new trees, with the fixture set to 545/110/257/179/179. report.js differs only by the theme key, and every HTML page only by the ?v= asset hash that follows it. The public research report built from the real research document is identical except for the source hashes in browser-eval-version.json and report-manifest.json.

Golden changes:

Snapshot Routes Why
webmainbench-full assets/report.js Theme key only
webmainbench-full All 11 HTML routes (index, analysis, cases, dataset, en, guide, history, methodology, reproduce, results, viewer) ?v= hash follows report.js
webmainbench-full index, analysis, guide Also show the fixture's own denominators (1) where literals 545/110/257/179 used to print
web-search manifest.json renderer_sha256 covers the new assets

All other snapshots are unchanged. The moved assets keep their routes (assets/style.css, assets/report.js).

The fixture profile gains case_count: 545, which certification already requires of real profiles.

Deliberately left

Hash-bound or frozen, not edited:

Frozen cohort facts, left as written:

  • HEADLESS_HISTORY_START in report_changes.py. It partitions the 15 releases that predate comparison_kinds. Moving it into the release data would add a key to the public report-changes.json. A bound report-assets/report-changes.json cannot gain the key either, and without it every untagged release would be selected for every cohort.
  • SAMPLE_PROVIDERS, expected_denominators and quality_limits in webmainbench_report_check.py. They are the check's independent expectation, and no profile reaches it. Reading them from the report under check would weaken it.
  • certification.py (moli, moli-pr643 binary bindings), webmainbench_latency_*.py, webmainbench_correction.py, wcxb_latency.py and the 545 checks in report_build.py name cohorts that have already run.

Adapter behaviour, not participant lists: playwright_tool.py, catalog_runner.py, runtime_identity.py, cloudflare.py, public_webarena/qualification.py. A capability table would add as much as it removes.

Needs a new bound content version or a text change:

  • Cohort narrative in generate_webmainbench_full ("七条", "六类", the three Moli versions) and MOLI_TIMING_* in trajectory_replay/report.py. Moving this prose means a new hash-bound report-content edition.
  • The case_count==150 and track_count==6 wording branch in report.py. Removing it changes real output, so it needs an owner decision.
  • Product claims in the report_i18n.py translation regexes and report-translations.json belong to Make English the source language of all report renderers, with Chinese as a catalog #99.

Test plan

Run with the shared locked environment on Python 3.11. Local runs used -o pythonpath="src .", because this session could not set PYTHONPATH. Subprocess tests therefore import the older installed package rather than this checkout.

  • Lint gate (ruff F, TID252 and the default config): passed.
  • tests/test_golden_reports.py: 17 passed after regenerating the two snapshots above.
  • Golden, research, full report, local audit, data home, language policy, packaging, software versions, Web Search and Lexbench verification: 765 passed, 1 failed. The failure is tests/web_search/test_offline_imports.py: its subprocess imports harness.web_search.cli from the older install.
  • Wider run (-k "report or wcxb or webmainbench or pricing or preflight or headless or lexbench or certif or package or language"): 3119 passed, 32 failed, 13 skipped. I re-ran a sample of these (network preflight, runner concurrency, report check owner, headless report, publication privacy) and every error came from the environment: the dataset lock or older CLI of the other checkout. I did not inspect all 32, so CI on Linux is the gate for them.
  • New test_renderer_identity_covers_loaded_assets: an asset edit changes the renderer identity.
  • Round 1 fixes, with PYTHONPATH set to this checkout: golden, report changes, pricing, public report language and the WebMainBench correction and review guard suites gave 124 passed. The lint gate passed.
  • New test_only_browser_only_cohorts_get_the_cost_boundary_table: it fails for ['chromium','moli-candidate'] when a literal set replaces the condition.
  • The correction section of the complete report (including the computed 545/545 line) is not exercised by the fixture, so it was only compiled, not rendered.

@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 · 5cb64fc

No findings in this review.

@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 · 97cef84

No findings in this incremental 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 97cef84e. Three P2 findings and one P3. The code moves are correct; the problems are the Closes claims and one untested behaviour change.

Findings

P2. src/harness/web_fetch/report_changes.py:14,74: Closes #97 misses an item the issue names.
#97 lists "report_changes.py:11,71 hardcodes release IDs". Both are still there (HEADLESS_HISTORY_START and '2026-09-03-fairness-correction'). The PR neither changes them nor mentions them under "Deliberately left", and neither #183 nor #205 covers them. The file is not hash-bound.
Fix: move the two IDs into the release history data the module already reads, if that keeps output identical. Otherwise list them and change to Part of #97.

P2. PR body, ## Issues: Closes #98 is overclaimed.
The issue title and problem list include report prose and product claims in translation regexes. Still present:

  • the report_i18n.py regexes, for example :292 ("这三项在五款中均最低") and :429
  • cohort prose in generate_webmainbench_full (report.py:4129,4134,4137,4180,4191,4206)
  • the case_count==150 and track_count==6 branch (report.py:1882)
  • MOLI_TIMING_* in trajectory_replay/report.py:405,407

Leaving these is reasonable, since they need a new bound content edition, an owner decision or #99. But the body says the prose "has no issue of its own, so reopen #98 if you want it tracked", which makes closing the default and tracking the exception. The rule is that Closes means the issue is complete.
Fix: use Part of #98 and keep the existing list as what remains. No new issue is needed.

P2. src/harness/web_fetch/report_pricing.py:54: the deliberate branch change has no test.
all(native_browser_engine(name) ...) changes behaviour for browser-only cohorts outside the old set. I confirmed that ['chromium','moli-candidate'] and ['moli-pr643'] get the price comparison on main and the cost-boundary table on this head. ['chromium','exa'] still gets the comparison. As a mutation, I restored a literal set in place of the new condition; test_report_pricing.py, test_public_report_language.py and the matching golden tests (-k "pricing or web_fetch or language") still passed. Golden snapshots do not reach this case either.
Fix: add one paired test to tests/test_report_pricing.py that asserts the branch for ['chromium','moli-candidate'] and for ['chromium','exa'].

P3. src/harness/web_fetch/webmainbench_correction.py:343: same literal left unchanged.
provider != "kitesurf" is the same test this PR replaces in webmainbench_certification.py, and the file is not hash-bound.
Fix: use engine_definition(provider).hosted here too, or say why this one differs.

Verified with no defect found

  • Moved assets: JS, EXTRA, STYLE, Web Search STYLE, SCRIPT and EVIDENCE_SCRIPT are equal character for character between main and this head. The cohort diagnostic CSS and JS equal the literals extracted from main with ast. The WCXB golden snapshot is unchanged.
  • Complete report: rendered from both trees with the fixture denominators set to 545/110/257/179/179. All 12 changed files are identical once the theme key and the ?v= hash are normalized, and no files were added or removed.
  • Public research report: rendered from the real research document in both trees, and the output is identical.
  • Correction section: the PR did not render it. I rendered it on this head with a stub correction file, and it works. Its min(...) value could not be checked against real evidence, because none is available in this environment.
  • Literal swaps: only kitesurf sets hosted and only chromium sets playwright_launched, and unregistered names behave as before, so the preflight, explainer, certification and label changes are equivalent.
  • profile["case_count"]: certification requires it to be 545 on real profiles, and the report check requires the expected denominators.
  • renderer_sha256: recorded values are only compared to decide whether to refresh, and nothing verifies them as frozen. headless.py, network_preflight.py, report_pricing.py and ui_check.js are not hash-bound; headless_worker.py and webmainbench_runner.py are untouched.
  • --site and MOLI_REPORT_SITE: no supported caller relied on the old defaults, and the Lexbench README already passes --site and sets the variable.
  • Over-design: none found. asset_text and renderer_sha256 are small and each removes more than it adds.

Tests and CI

  • Lint gate: passed.
  • tests/test_golden_reports.py: 17 passed.
  • Local audit, complete report, public research, data home, tests/web_search, Lexbench verification and software versions: 658 passed.
  • tests/test_report_ui.mjs and tests/test_report_loader.mjs: passed.
  • CI on this head: all checks pass, including "Tests and static checks" and "Installation and packaging".

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 1 follow-up.

Fixed:

  • report_changes.py release IDs: first_correction had no caller, so it, its test and 2026-09-03-fairness-correction are removed (f788e7d). HEADLESS_HISTORY_START stays and is listed in the PR body, because it partitions the releases that predate comparison_kinds. Moving it to the data would add a key to the public report-changes.json, and a bound report-assets/report-changes.json cannot gain that key, so its untagged releases would be selected for every cohort. The PR is therefore Part of #97.
  • Closes #98 overclaim: the PR body now says Part of #98 and lists what remains. No new issue.
  • Pricing branch: a paired test covers ['chromium','moli-candidate'] and ['chromium','exa'] (54b2d59). Restoring a literal set makes it fail.
  • webmainbench_correction.py reads engine_definition(provider).hosted (928da5a).

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.

✅ Re-review complete · 54b2d59

No findings in this incremental 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 54b2d591. No defects found: no P0, P1, P2 or P3 findings.

Round 1 findings

  • report_changes.py: first_correction and its release ID are gone, with no remaining references. I accept the reason for keeping HEADLESS_HISTORY_START: select_cohort_history uses it to partition releases without comparison_kinds, so it cannot move without changing how bound copies are selected. It is listed under what remains in #97.
  • Closes overclaims: the body now says Part of #97 and Part of #98, and the lists match what I found in the code.
  • Pricing branch test: restoring the literal nine-name set makes the ['chromium','moli-candidate'] case fail. I ran this mutation and reverted it.
  • webmainbench_correction.py reads engine_definition(provider).hosted. Only kitesurf is hosted, so behaviour is unchanged.

What I verified

  • Asset moves: I evaluated the old string literals from 35bed218 with ast and compared them to the new assets.
    • report.js and report-extra.css are byte-identical.
    • wcxb.css and wcxb.js are byte-identical after the old slice, replace and append steps.
    • webmainbench-full.css is byte-identical, and webmainbench-full.js differs only by the theme key.
  • Participant swaps:
    • hosted is true only for kitesurf, and playwright_launched only for chromium. Both labels and the kitesurf tests therefore behave as before, including for unregistered variants.
    • Every name in the old pricing set resolves through native_browser_engine. No catalog method outside the old set does, so the branch change only affects registry browser variants, as the body discloses.
  • Measured values:
    • The research document yields 200, 150, 1497 and 511.
    • webmainbench_report_check rejects any summary whose denominators differ from 545/110/257/179/179, so reading them from the first summary is safe for a release.
    • certification requires case_count to be 545.
    • The correction section is not rendered by the fixture, as the body says. I read it instead: prior_moli, content_moli and target_body_count are all defined unconditionally before it.
  • Renderer hash and hash-bound files:
    • renderer_sha256 replaces all three report.py hash uses in report_build.py.
    • The first_correction removal and the _engine_definition rename leave no stale references, including in the frozen latency certifiers.
    • providers/headless.py and network_preflight.py are not hashed by any source binding. headless_worker.py, webmainbench_runner.py and the other listed hash-bound files are untouched.
    • No wmb545-theme reference remains.
  • Goldens: only webmainbench-full (12 routes) and web-search (manifest.json) changed, which matches the table in the body.
  • Simplicity: asset_text, renderer_sha256 and the public engine_definition each replace repeated code. There is no new registry or layer, and I found no simpler form.

Test results

  • Lint gate: passed.
  • Golden, pricing, report changes, complete WebMainBench report, data home, Lexbench verification, local audit and public language tests: 190 passed.
  • test_report_ui.mjs and test_report_loader.mjs: passed.
  • CI on this head: Tests and static checks, Installation and packaging, and Rendered reference and report checks all passed.

lanyue-llk added a commit that referenced this pull request Nov 4, 2026
lanyue-llk added a commit that referenced this pull request Nov 4, 2026
…hort literals out of renderers

Inline CSS and JavaScript in web_fetch/report.py and web_search/report.py now load from package assets, and each renderer hash covers those assets. Complete WebMainBench and public research counts read the profile, score summaries and research document. Hosted and Playwright engine branches read the engine registry, and the Lexbench check no longer defaults to one report's directory.
@lanyue-llk
lanyue-llk force-pushed the refactor/remove-hardcoded-leftovers branch from 54b2d59 to 3e43884 Compare November 4, 2026 09:32

@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 · 3e43884

No findings in this review.

@lanyue-llk
lanyue-llk merged commit 8f2232b into main Nov 4, 2026
7 of 8 checks passed
@lanyue-llk
lanyue-llk deleted the refactor/remove-hardcoded-leftovers branch November 4, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant