Skip to content

refactor(browser-use): replace report scripts with one subcommand CLI - #143

Merged
lanyue-llk merged 6 commits into
mainfrom
refactor/browser-use-subcommand-cli
Nov 3, 2026
Merged

lanyue-llk merged 6 commits into
mainfrom
refactor/browser-use-subcommand-cli

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 #100. This PR covers the Browser Use track only. Remaining work, moved to #155:

  • Subcommand CLIs for the other tracks (Web Fetch, WebMainBench, WCXB, Trajectory Replay, headless)
  • Console scripts in pyproject.toml
  • Moving logic out of the larger scripts, and moving the moli_report assets into a package

Summary

Six scripts become subcommands of python -m harness.browser_use <command>, using the router pattern from #139. No old names remain as aliases.

Removed script New command Owner
scripts/build_browser_use_report.py report report.main
scripts/check_browser_use_report.py check report_check.main
scripts/check_browser_use_visual.py visual report_visual.main
scripts/review_browser_use_results.py review review.main (argument parsing moved here from the script)
scripts/package_browser_use_artifact_site.py package report_package.main
scripts/publish_browser_use_artifact_site.py publish report_publish.cli

The Makefile, configs/report-templates.json, docs/benchmarks.md, docs/report-hosting.md, examples/browser_use/README.md, scripts/README.md and the tests all move to the new commands. No skill or workflow names these scripts.

Differences from the Web Search router

  • Arguments go through sys.argv. Visual receipts hash report_visual.py, so its main() cannot gain an argv parameter without failing every existing receipt. That file is byte-identical in this PR. The router sets sys.argv for the owner and restores it afterwards.
  • The explicit resolve_template("browser-use") call is gone. The build script called it before parsing arguments. build_report still resolves the same template through template_identity, so a bad registry entry still fails the build. report --help no longer depends on it.

Golden snapshots changed: browser-use-pass and browser-use-fail

Only data/summary.json and report-data.json change in each snapshot. Both record template.entrypoint, which now reads src/harness/browser_use/cli.py. resolve_template requires that path to exist, so the old value could not stay.

To confirm nothing else moved, I substituted the old entry point back into the new bytes. All four files then hash to the previously committed snapshot values. No HTML route changes, and no other track's snapshot changes.

Please review: the report check is less strict

report_check used to compare the whole template identity, including entrypoint. Left as it was, that check would reject any report built before this PR with "report bypasses the maintained Browser Use template", which also blocks package.

It now binds track and renderer through check_template_identity, so reports built earlier stay valid and a different renderer is still rejected. The trade-off is that entrypoint is no longer enforced for this track. A report without a profile hash has nothing to bind, so the gate returns before it reads the template registry, which wheels do not bundle. tests/browser_use/test_report_check.py runs check() on a synthetic built report in both directions: a different renderer, a different track or a missing template is rejected, and the old entry point gets past the gate. That test is the only remaining mention of a removed script name.

Left in place

  • scripts/build_browser_use_replay_seeds.py: it calls harness.trajectory_replay, so it belongs to the Trajectory Replay track.
  • python -m harness.browser_use.runner (used by examples/browser_use/run.sh): it is not a script in scripts/, and webmainbench_latency_correction.py plus the hash-bound certifier copies under src/harness/web_fetch/data/latency-certifiers/ match that exact command line to detect competing benchmark work. Moving it to a run subcommand would break that detection.
  • if __name__ block in src/harness/browser_use/report_visual.py: visual receipts hash this file through checker_sources, so removing the block would fail every existing receipt. It stays the only leftover python -m harness.browser_use.<report owner> route, and nothing calls it. The blocks in report.py, report_check.py, report_package.py and report_publish.py are removed.
  • No workflow calls these scripts, and no hash-bound source list names them, so nothing had to stay for those reasons.

Reference search

grep -rnIE "(build_browser_use_report|check_browser_use_visual|check_browser_use_report|package_browser_use_artifact|publish_browser_use_artifact|review_browser_use_results)" . (excluding .git, .venv and __pycache__) returns one line:

tests/browser_use/test_report_check.py:200:  "entrypoint": "scripts/build_browser_use_report.py"}

This is the fixture for a report built before the move.

Test plan

Run locally with the shared locked environment on Python 3.11:

  • ruff check --config 'include=["*.py"]' --select F,TID252 . and ruff check: passed.
  • pytest tests/test_golden_reports.py tests/browser_use tests/test_runtime_entrypoints.py tests/test_public_report_language.py tests/test_report_templates.py tests/test_documented_paths.py tests/test_packaging_hygiene.py tests/test_reporting_visual.py tests/test_reporting_publication.py tests/benchmarks/test_checkout_entrypoint_precedence.py -n 2: 549 passed, 1 failed.
    • The failure was the Browser Use case of test_report_entrypoints_reject_unknown_language_before_loading_evidence. Its subprocess imported another checkout's editable install. The test now puts this checkout's src first on PYTHONPATH.
  • After that fix, pytest tests/test_public_report_language.py tests/browser_use/test_cli.py tests/browser_use/test_report_check.py tests/test_golden_reports.py -n 2: 91 passed. I did not repeat the larger run.

After review round 1 (same environment, using PYTHONPATH with this checkout's src first): both ruff commands passed, and the larger pytest command above reported 554 passed, 63 subtests passed. Golden snapshots did not change in this round. As a negative control, disabling the check_template_identity(audit) call in check() made the three rejection cases of the new test fail.

Limits of the local run:

  • In the first run the sandbox refused a PYTHONPATH prefix on commands, so I used pytest's -o "pythonpath=src .", and subprocess-based tests may have imported the other checkout. The round 1 run above did not have that limit.
  • tests/package_smoke.py was edited but not run locally. The "Installation and packaging" CI job covers it.
  • I did not run the full suite locally, or a real report build, visual gate or publish against measured evidence.

@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 · 663fc2b

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 663fc2bd. Six findings: three P2 and three P3. None is a data or CI break.

Findings

P2: src/harness/browser_use/report_check.py:349 makes the registry lookup unconditional
The old gate was audit.get("profile_sha256") and audit.get("template") != template_identity("browser-use"), which short-circuits, so a report with no profile hash never read the registry. The new helper calls template_identity before testing profile_sha256. In a wheel install configs/report-templates.json is not bundled, so check (and package, which calls it) on a report without a profile hash now raises FileNotFoundError. It previously got past this gate. I confirmed this by making template_identity raise and calling check_template_identity({}), which propagates the error. A checkout is unaffected, and the case is narrow, but this PR should not change it.
Fix: return early when profile_sha256 is falsy, before resolving the template, and add that case to the test.

P2: src/harness/browser_use/report_check.py:494 has no test on the relaxed gate's call site
The PR says test_report_check.py covers both directions, but that test (line 197) only calls the helper. I deleted check_template_identity(audit) from check() and ran tests/browser_use tests/test_golden_reports.py tests/test_report_templates.py: 330 passed. So nothing shows that check() still rejects a different renderer, or that a report recording the old entry point gets through check(). This PR deliberately weakens this gate, and AGENTS.md asks for negative controls on release gates.
Fix: add a check()-level test that reaches the gate with a wrong renderer (rejected) and with the old entrypoint value (gets past the gate).

P2: report.py:3868, report_check.py:997, report_package.py:112 and report_publish.py:413 keep module entry points beside the router
python -m harness.browser_use.report_check and its siblings still work as second entry points to the same commands, with their own usage names. Nothing in the Makefile, docs, tests or examples calls them. The Web Search owners have no such blocks, because that router is the only way in. AGENTS.md asks for one supported entry point and removal of superseded ones.
Fix: remove these four blocks. Keep report_visual.py:264, since that file is hash-bound through checker_sources, and say so in the PR.

P3: scripts/README.md:84 overstates who uses the commands
It says make browser-use-* and docs/benchmarks.md use all six commands. Neither one reaches publish. The row removed from the pending-decision table was the only place that said what publishes this report.
Fix: state that publish runs only as a direct command after packaging, or document it in docs/benchmarks.md next to package.

P3: tests/test_public_report_language.py:234 matches "replay" against the whole path
For the Web Fetch case entry[0] is an absolute path, so a checkout whose path contains "replay" takes the replay branch. It then calls importorskip and passes --results instead of --evidence. The old code tested only the script name.
Fix: add the flag to the parametrize row, or test Path(entry[0]).name.

P3: docs/report-hosting.md:39 shows a bare python -m command
AGENTS.md allows repository Python only through make or uv run --frozen python, and #139 fixed the same wording in its docs. scripts/README.md in this PR already uses the frozen form.
Fix: write uv run --frozen python -m harness.browser_use report.

Verified, no defect

  • Scope: the six listed scripts were the only ones in scripts/ calling harness.browser_use. build_browser_use_replay_seeds.py imports harness.trajectory_replay. "Part of #100" is correct, and the remaining list matches the issue.
  • References: the PR's search reproduces, with the same single fixture line, across .agents, .github and docs. No workflow or skill names the scripts.
  • Argument passing: with a fake owner, the router preserved the exact order of repeated options, positionals containing spaces, --x=1, values equal to command names, and -- on Python 3.11.
  • Hash bindings: checker_sources binds only report_visual.py and reporting/visual.py, and both are byte-identical. No profile or receipt tracked in Git binds report_check.py, review.py or the registry. reporting/assets.py lets a content binding hash any repository file under authority, so a binding kept outside Git could name the registry; I cannot see those from here, and #139 changed the same file. The hash-bound certifier copies match -m harness.browser_use.runner, so the new report command is not treated as competing benchmark work.
  • Golden snapshots: I rebuilt both Browser Use fixtures. Only data/summary.json and report-data.json differ from the base snapshots, and substituting the old entry point back reproduces the base hashes.
  • Removed scripts: none had a sys.path bootstrap, so moving to -m loses no checkout precedence. Nothing else in src reads template.entrypoint.
  • Local runs: ruff passed. tests/test_golden_reports.py tests/browser_use tests/test_runtime_entrypoints.py tests/test_public_report_language.py tests/test_report_templates.py tests/test_documented_paths.py tests/test_packaging_hygiene.py tests/test_reporting_visual.py tests/test_reporting_publication.py tests/benchmarks/test_checkout_entrypoint_precedence.py tests/test_shared_hash_json_helpers.py: 637 passed.
  • CI on this head: Tests and static checks, Installation and packaging, and Rendered reference and report checks all pass, so none of these findings shows up as a CI failure.

Not verified

I did not run a real report build, visual gate, package or publish against measured evidence. I also did not run check() to completion on a report that records the old entry point. That claim rests on reading the code and on the helper-level test.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 1: all six findings are fixed, none disputed.

Finding Fix Commit
P2 check_template_identity read the registry before testing profile_sha256 The gate returns first when there is no profile hash. A helper test makes the registry lookup raise 1323251
P2 the gate's call site had no test New check()-level test on a synthetic built report: a wrong renderer, a wrong track or no template is rejected, and the old entry point reaches the next check. With the call disabled, the three rejection cases fail a037124
P2 second entry points beside the router Removed the __main__ blocks from report.py, report_check.py, report_package.py and report_publish.py 8e40768
P3 replay branch matched the absolute path Replay is now a flag in the parametrize row 821dd62
P3 scripts/README.md overstated who uses publish It now lists what Make and docs/benchmarks.md each run, and says publish runs directly after package d1075ad
P3 bare python -m in docs/report-hosting.md Now uv run --frozen python -m harness.browser_use report d1075ad

report_visual.py keeps its __main__ block because visual receipts hash that file through checker_sources. The PR body records this.

Locally, both ruff commands passed, and pytest on the targets in the PR's test plan reported 554 passed, 63 subtests passed. Golden snapshots did not change in this round.

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

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 d1075ad4. No defects found. There are no findings to fix.

Round 1 fixes

All six fixes are in place. I tested the code fixes by reverting each one:

Round 1 finding Check Result
Template lookup without a profile hash Removed the early return test_template_gate_needs_no_registry_without_a_profile_hash fails
Gate call site in check() Removed the check_template_identity(audit) call The three rejection cases fail
Gate binds the renderer only Added entrypoint back to the compared keys The old-entry-point case fails
Second entry points Searched for __name__ blocks and callers Only __main__.py, report_visual.py and runner.py keep a block, and nothing calls the removed routes
replay test flag, scripts/README.md, docs/report-hosting.md Read the changes Correct

Other checks

  • Router: all six commands run from outside the repository, and --help shows the public command name. Making publish resolve to main instead of cli, or not restoring sys.argv, each fails a test.
  • Review command: review.main parses arguments the same way as the deleted script, including the default selection path relative to the working directory. Binding the wrong selection hash fails a test.
  • Build through the router: on the synthetic fixture, main(["report", ...]) produced a report tree byte-identical to a direct build_report call (231 files).
  • Golden snapshots: I set the registry back to the old entry point and restored the base snapshots, and both Browser Use snapshots then passed. The only change is template.entrypoint, as the PR says, and no other track's snapshot moved.
  • Hash bindings: checker_sources hashes only report_visual.py and reporting/visual.py, and neither changed in this PR. No evaluation file, certifier or source list under src/, scripts/, evaluation/ or configs/ names a removed script or an edited Browser Use module.
  • harness.browser_use.runner: leaving it in place is justified, because webmainbench_latency_correction.py and the hash-bound certifier copies match that exact command line.
  • References: git grep for the six removed script names returns only the fixture in tests/browser_use/test_report_check.py. No skill or workflow names them.
  • Makefile: a dry run of browser-use-release-check runs check, check_report_links.py and visual in the expected order.
  • Scope: "Part of #100" is accurate, and the remaining work is listed.

Tests and CI

  • Both ruff commands pass.
  • pytest tests/test_golden_reports.py tests/browser_use tests/test_runtime_entrypoints.py tests/test_public_report_language.py tests/test_report_templates.py tests/test_documented_paths.py tests/test_packaging_hygiene.py tests/test_reporting_visual.py tests/test_reporting_publication.py -n 2: 510 passed, 63 subtests passed.
  • All CI checks pass on this head, including "Tests and static checks" and "Installation and packaging".

Not run

I did not run the full suite locally, the visual gate, publish, or a build against measured evidence. A report built before this PR was only simulated, by the fixture with the old entrypoint value.

Notes for the author and owner

  • PR body, not a finding: the quoted reference-search line says test_report_check.py:200, but the mention is now at line 202. The result itself is still correct.
  • Owner decision: the PR already flags that report_check no longer enforces entrypoint for this track. I think the trade-off is sound, because enforcing it would reject every report built earlier. Trajectory Replay still compares the full identity, so the two tracks now differ.

@lanyue-llk
lanyue-llk force-pushed the refactor/browser-use-subcommand-cli branch from d1075ad to 501649e Compare November 3, 2026 08:30

@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 · 501649e

No findings in this review.

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.

Replace about 170 wrapper scripts with per-track subcommand CLIs

1 participant