Repository navigation
refactor(browser-use): replace report scripts with one subcommand CLI - #143
Conversation
There was a problem hiding this comment.
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/callingharness.browser_use.build_browser_use_replay_seeds.pyimportsharness.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,.githuband 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_sourcesbinds onlyreport_visual.pyandreporting/visual.py, and both are byte-identical. No profile or receipt tracked in Git bindsreport_check.py,review.pyor the registry.reporting/assets.pylets a content binding hash any repository file underauthority, 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 newreportcommand is not treated as competing benchmark work. - Golden snapshots: I rebuilt both Browser Use fixtures. Only
data/summary.jsonandreport-data.jsondiffer from the base snapshots, and substituting the old entry point back reproduces the base hashes. - Removed scripts: none had a
sys.pathbootstrap, so moving to-mloses no checkout precedence. Nothing else insrcreadstemplate.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.
|
Review round 1: all six findings are fixed, none disputed.
Locally, both ruff commands passed, and |
lanyue-llk
left a comment
There was a problem hiding this comment.
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
--helpshows the public command name. Makingpublishresolve tomaininstead ofcli, or not restoringsys.argv, each fails a test. - Review command:
review.mainparses 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 directbuild_reportcall (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_sourceshashes onlyreport_visual.pyandreporting/visual.py, and neither changed in this PR. No evaluation file, certifier or source list undersrc/,scripts/,evaluation/orconfigs/names a removed script or an edited Browser Use module. harness.browser_use.runner: leaving it in place is justified, becausewebmainbench_latency_correction.pyand the hash-bound certifier copies match that exact command line.- References:
git grepfor the six removed script names returns only the fixture intests/browser_use/test_report_check.py. No skill or workflow names them. - Makefile: a dry run of
browser-use-release-checkrunscheck,check_report_links.pyandvisualin 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_checkno longer enforcesentrypointfor 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.
d1075ad to
501649e
Compare
Issues
Closes #100. This PR covers the Browser Use track only. Remaining work, moved to #155:
pyproject.tomlmoli_reportassets into a packageSummary
Six scripts become subcommands of
python -m harness.browser_use <command>, using the router pattern from #139. No old names remain as aliases.scripts/build_browser_use_report.pyreportreport.mainscripts/check_browser_use_report.pycheckreport_check.mainscripts/check_browser_use_visual.pyvisualreport_visual.mainscripts/review_browser_use_results.pyreviewreview.main(argument parsing moved here from the script)scripts/package_browser_use_artifact_site.pypackagereport_package.mainscripts/publish_browser_use_artifact_site.pypublishreport_publish.cliThe Makefile,
configs/report-templates.json,docs/benchmarks.md,docs/report-hosting.md,examples/browser_use/README.md,scripts/README.mdand the tests all move to the new commands. No skill or workflow names these scripts.Differences from the Web Search router
sys.argv. Visual receipts hashreport_visual.py, so itsmain()cannot gain anargvparameter without failing every existing receipt. That file is byte-identical in this PR. The router setssys.argvfor the owner and restores it afterwards.resolve_template("browser-use")call is gone. The build script called it before parsing arguments.build_reportstill resolves the same template throughtemplate_identity, so a bad registry entry still fails the build.report --helpno longer depends on it.Golden snapshots changed:
browser-use-passandbrowser-use-failOnly
data/summary.jsonandreport-data.jsonchange in each snapshot. Both recordtemplate.entrypoint, which now readssrc/harness/browser_use/cli.py.resolve_templaterequires 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_checkused to compare the whole template identity, includingentrypoint. Left as it was, that check would reject any report built before this PR with "report bypasses the maintained Browser Use template", which also blockspackage.It now binds
trackandrendererthroughcheck_template_identity, so reports built earlier stay valid and a different renderer is still rejected. The trade-off is thatentrypointis 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.pyrunscheck()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 callsharness.trajectory_replay, so it belongs to the Trajectory Replay track.python -m harness.browser_use.runner(used byexamples/browser_use/run.sh): it is not a script inscripts/, andwebmainbench_latency_correction.pyplus the hash-bound certifier copies undersrc/harness/web_fetch/data/latency-certifiers/match that exact command line to detect competing benchmark work. Moving it to arunsubcommand would break that detection.if __name__block insrc/harness/browser_use/report_visual.py: visual receipts hash this file throughchecker_sources, so removing the block would fail every existing receipt. It stays the only leftoverpython -m harness.browser_use.<report owner>route, and nothing calls it. The blocks inreport.py,report_check.py,report_package.pyandreport_publish.pyare removed.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,.venvand__pycache__) returns one line: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 .andruff 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.test_report_entrypoints_reject_unknown_language_before_loading_evidence. Its subprocess imported another checkout's editable install. The test now puts this checkout'ssrcfirst onPYTHONPATH.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
PYTHONPATHwith this checkout'ssrcfirst): both ruff commands passed, and the largerpytestcommand above reported 554 passed, 63 subtests passed. Golden snapshots did not change in this round. As a negative control, disabling thecheck_template_identity(audit)call incheck()made the three rejection cases of the new test fail.Limits of the local run:
PYTHONPATHprefix 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.pywas edited but not run locally. The "Installation and packaging" CI job covers it.