Skip to content

refactor(web-search): replace report scripts with one subcommand CLI - #139

Merged
lanyue-llk merged 4 commits into
mainfrom
refactor/web-search-subcommand-cli
Nov 3, 2026
Merged

lanyue-llk merged 4 commits into
mainfrom
refactor/web-search-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 Web Search report scripts only. Remaining:

  • The per-track CLIs for Web Fetch scripts, Browser Use, Browser Trajectory Replay and WebMainBench/WCXB.
  • A pyproject.toml console script for this track (see "Left out on purpose").
  • The scripts/moli_report/ move, and the logic-heavy scripts the issue names.
  • src/harness/web_search/visual.py line 63 still says regenerate with check_search_report_visual.py. Receipts bind that file's hash, so correct the message in a change that already has to invalidate them.

Summary

Replaces five Web Search scripts with one entry point:

Removed Now
scripts/build_search_report.py uv run --frozen python -m harness.web_search report
scripts/check_search_report_visual.py uv run --frozen python -m harness.web_search visual
scripts/judge_search_relevance.py uv run --frozen python -m harness.web_search judge
scripts/review_search_results.py uv run --frozen python -m harness.web_search review
scripts/publish_search_report.py uv run --frozen python -m harness.web_search publish

No aliases remain. Each command's options are unchanged, and review keeps its freeze, run and collect commands.

One behavior change: checkout precedence. The removed scripts put the checkout's src/ first with sys.path.insert, so they ran checkout code even over a noneditable installed package. python -m has no such step: it resolves harness from sys.path, so an environment holding a noneditable older package runs that package's __main__. A guard in this checkout cannot fix that, because it would never be loaded. These commands therefore rely on the editable install that uv run --frozen provides, and the track guide says so.

cli.py routes each command to the existing main(argv) of the module that owns it, instead of moving every option into one parser as harness.web_fetch does. That is deliberate:

  • Report bytes stay stable. The Web Search manifest records renderer_sha256, the hash of report.py, and the golden snapshot covers that manifest. Editing report.py would change generated output for a change that has no reader-visible effect.
  • Imports stay lazy. Only the selected command's module is imported, so publish dependencies and similar are not loaded for other commands.

The router also sets sys.argv[0] while the owner runs, so owner --help and errors print the public command name. It restores the value afterwards.

Effects on existing evidence

None. visual.py, report.py, pages.py, runner.py and pyproject.toml are byte-identical to main, so visual receipts, renderer hashes and collection resume bindings keep verifying.

Left out on purpose

  • Console script: the issue also proposes one in pyproject.toml. collection_implementation() freezes that file's hash and resume rejects drift, so editing it would block resuming an interrupted Web Search collection. Adding one is an owner decision, and it can be done when no collection is in flight.
  • .github/workflows/: no workflow calls any of the five scripts, so no workflow change was needed.
  • harness.web_search.runner and harness.web_search.example: these module entry points are outside this item's five scripts.

Reference search

Searched the whole working tree (excluding .git, .venv, node_modules and __pycache__) for the five removed names. After this change there is 1 match: src/harness/web_search/visual.py:63, the regenerate message listed under remaining work. References migrated:

File Change
src/harness/web_search/README.md Commands updated; command table added
examples/web_search/README.md Check command
configs/report-templates.json build, check, release_check; entrypoint is now src/harness/web_search/cli.py
.agents/skills/benchmark-report/SKILL.md Judge command
scripts/README.md Web Search inventory replaced by a pointer to the guide
tests/benchmarks/test_checkout_entrypoint_precedence.py Search help case now runs the module with src listed before a stale wheel

The Makefile, CI workflows, docs/ and the root READMEs had no references. Supported entry points for this track's reports are now the five commands above.

Test plan

Local, Python 3.11 shared environment:

  • Ruff lint gate (both commands): passed.
  • pytest tests/web_search tests/test_golden_reports.py tests/test_report_templates.py tests/test_wcxb_participant_registry.py tests/benchmarks/test_checkout_entrypoint_precedence.py -n 2, with this checkout's src on PYTHONPATH: 590 passed.
  • Golden snapshots: unchanged, including web-search.
  • Reproduced the precedence limit by hand: with only a stale package on PYTHONPATH, python -S -m harness.web_search report --help ran the stale __main__.
  • git diff 27401304 -- src/harness/web_search/visual.py is empty.
  • New tests/web_search/test_cli.py covers help for every command under its public name, nested review commands, missing and unknown commands, unknown options reaching the owner, a real report --check on the synthetic example, and the template registry.
  • tests/package_smoke.py now runs python -m harness.web_search report --help from the installed package. It was not run locally; the "Installation and packaging" check runs it.
  • CI: see the checks on this PR.

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

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

Head reviewed: 5e6209d6. No P0 defects. CI is green. Four findings, listed most severe first.

Findings

P1: src/harness/web_search/visual.py:63: a message-only edit invalidates visual receipts.

  • Problem: producer_sources() binds this file's SHA-256, and verify() rejects any receipt whose producer_sources differ. Rewording one error message therefore makes every existing Web Search visual receipt fail report --release-check and a new publish, for a change with no reader-visible effect. This track's rule is that receipts must keep verifying and that a change which would invalidate them is deferred, not done. The PR discloses the effect but still makes the change. Practical impact looks low: the check fails closed, recapture needs no provider calls, and I found no Web Search visual receipt in the one local data home I could check. Other hosts are unknown.
  • Fix: revert this line so visual.py stays byte-identical, and list the stale message under the remaining work in ## Issues, to change the next time visual.py legitimately changes. Correct the reference-search section, which would then report one match. If the owner prefers the clean message over receipt stability, record that decision in the PR.

P2: tests/benchmarks/test_checkout_entrypoint_precedence.py:89: the new test does not prove what its name says, and the PR does not disclose the lost guard.

  • Problem: test_search_cli_help_uses_checkout_over_noneditable_wheel puts src first in PYTHONPATH itself, so the checkout wins because of the test's setup, not because of the entry point. The removed scripts did guarantee this with sys.path.insert(0, src). I confirmed the change: with PYTHONPATH holding only a stale harness.web_search package and -S, python -m harness.web_search report --help ran the stale __main__ and printed its marker. harness.web_fetch has the same property and the issue asks for this form, so the design is acceptable. However, the PR's "Options and behavior of each command are unchanged" is not accurate for this case. A non-editable install now silently supplies the renderer and scorer code in place of the checkout. The removed scripts also leave the SCRIPTS parametrization, so nothing guards this path for the track.
  • Fix: rename the test to what it checks (for example, the help command runs from source with site hooks disabled), and state in the PR that the checkout-precedence guarantee no longer applies to these five commands and that they rely on the uv run editable install. If precedence must hold, add a guard in the shared entry path and a test that uses only the stale wheel on PYTHONPATH.

P2: PR body, "Effects on existing evidence": the publish --resume claim is wrong.

  • Problem: the PR says a receipt must be recaptured before publish --resume. report_visual.verify is called only from prepare (publication.py:41), which --resume skips. verify_plan compares only the frozen copy's manifest_sha256 and its bound hash, so a resume is unaffected by the visual.py hash. The affected paths are report --release-check and a new publish. Recapturing for a resume would also be pointless, because the plan binds its frozen copy under inputs/.
  • Fix: correct that sentence if the visual.py edit stays, or remove it with the revert above.

P3: src/harness/web_search/README.md:27-31,53,79,151,222,252 and .agents/skills/benchmark-report/SKILL.md:92: new command text omits uv run --frozen.

  • Problem: the old prose named script paths, while the new text gives literal python -m ... commands, including a complete copyable visual command at line 79. AGENTS.md says to run repository Python only through make or uv run --frozen python, and never to fall back to system Python.
  • Fix: use uv run --frozen python -m harness.web_search ... in runnable commands, at least the visual and full-gate commands on line 79 and the table.

What I verified

  • References: no match for the five removed names anywhere in the tree, including .github/, .agents/, docs/ and the Makefile, so the PR's search result holds. No workflow called them.
  • Argument forwarding: the router passed arguments unchanged, in order, through a stubbed owner. Cases covered positionals, --opt=value, --, negative numbers, empty strings, repeated options, -h, --he and values equal to a command name. An option placed before the command is also forwarded (--check report), which is harmless because the owner still validates it.
  • Dispatch: the five owners accept argv, and judge maps to judge_main. Return values are dropped as the old scripts dropped them, so exit codes do not regress. Nothing else under harness/web_search or harness/reporting reads sys.argv, so changing argv[0] is safe. Importing cli loads only harness, harness.web_search and harness.web_search.cli, so the lazy-import claim holds.
  • Hash bindings: report.py, pages.py, runner.py, pyproject.toml and uv.lock are unchanged. collection_implementation() names individual files, so adding cli.py and __main__.py does not affect resume.
  • Scope: Part of #100 is correct. The console-script deferral is justified because pyproject.toml is in collection_implementation().
  • Local tests (Python 3.11): both ruff commands passed. tests/web_search, tests/test_golden_reports.py, tests/test_report_templates.py, tests/test_wcxb_participant_registry.py and tests/benchmarks/test_checkout_entrypoint_precedence.py: 590 passed, 0 failed. This includes the test_offline_imports.py case the PR reported as a local failure, which passes when PYTHONPATH selects the checkout. No golden snapshot changed.
  • scripts/report_template.py web-search: prints the migrated commands.
  • CI for this head: Tests and static checks, Installation and packaging, and Rendered reference and report checks all pass. The failures above are not CI failures.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 1 fixes, on head 813bb1d.

Fixed

  • P1, visual.py hash (5a0e5c5): restored the file byte for byte, so existing visual receipts keep verifying. The stale script name in its regenerate message is now listed under remaining work, and the reference search reports that one match.
  • P2, precedence test (7d8375d): renamed to test_search_cli_help_runs_from_src_listed_before_installed_wheel, which is what it checks. I did not add a guard: with python -m, a stale package's __main__ runs before any checkout code loads, so a guard in this checkout would never execute. The PR body and the track guide now state that these commands rely on the uv run --frozen editable install. I reproduced the stale __main__ case by hand.
  • P2, publish --resume sentence: removed from the PR body together with the revert. That section now says there is no effect on existing evidence.
  • P3, command text (813bb1d): runnable commands in src/harness/web_search/README.md, .agents/skills/benchmark-report/SKILL.md and scripts/README.md now use uv run --frozen python -m harness.web_search.

Disputed

None.

@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 · 813bb1d

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

Head reviewed: 813bb1d3. No defects found.

Round 1 fixes

  • visual.py hash: the file is byte-identical to main (git diff 27401304 HEAD is empty), so existing visual receipts keep verifying. report.py, pages.py, runner.py and pyproject.toml are also unchanged.
  • Precedence test: the new name matches what the test does, and the PR body and track guide disclose the reliance on the editable install. uv.lock records the project as editable, which supports that statement. I agree a guard cannot help, because a stale package's __main__ runs before any checkout code loads.
  • publish --resume sentence: it is gone from the PR body. "Effects on existing evidence" now says none, which matches the unchanged files above.
  • Command text: runnable commands in the track guide, the skill and scripts/README.md use uv run --frozen python -m harness.web_search.

What I verified

  • References: the only remaining match for the five removed names is src/harness/web_search/visual.py:63, as the PR lists. On main, those names appeared in the seven files the PR migrated or lists, and not in the Makefile, workflows or docs/. No workflow called them.
  • Hash bindings: nothing under evaluation/ or src/harness binds the edited docs or configs/report-templates.json. This does not cover private evidence outside the repository.
  • Dispatch: an end-to-end run of the synthetic example with report --check passed. scripts/report_template.py web-search prints the migrated commands. Each command imports only what it needs, so the lazy-import claim holds.
  • Usage names on other Python versions: the sys.argv[0] approach depends on how argparse picks its default program name. I ran a small stand-in package on 3.13: it printed the public name. I could not run 3.14 here, so I read the CPython 3.14 _prog_name source. It falls back to basename(sys.argv[0]) when argv[0] differs from the module origin, so the public name should hold there too.
  • Commits and scope: there are no attribution lines in the commits. Part of #100 is correct, and the remaining list and the console-script deferral match the issue and the collection_implementation() binding.

Local checks (Python 3.11)

  • Both ruff commands passed.
  • tests/web_search, tests/test_golden_reports.py, tests/test_report_templates.py, tests/test_wcxb_participant_registry.py and tests/benchmarks/test_checkout_entrypoint_precedence.py: 590 passed, 0 failed.
  • No golden snapshot is in the diff.
  • I did not run the real visual capture or publish, which need a browser and a site target. publish and review were checked through help and routing only.

CI for this head

Passing: Tests and static checks, Installation and packaging, Rendered reference and report checks, Python 3.11.

@lanyue-llk
lanyue-llk force-pushed the refactor/web-search-subcommand-cli branch from 813bb1d to ef23b27 Compare November 3, 2026 06:23

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

No findings in this review.

A message-only edit changed the visual.py hash that receipts bind, which would
fail every existing receipt at report --release-check and a new publish. Restore
the file byte for byte. The stale script name in its regenerate message stays
until a change that already has to invalidate these receipts.
The test puts src first on PYTHONPATH, so it cannot show checkout precedence over
a noneditable wheel. A module entry point cannot provide that either, because the
installed package would already be the one running. Rename the test and state the
reliance on the uv run editable install in the track guide.
AGENTS.md requires make or uv run --frozen python, so command text must not read
as a bare python invocation.
lanyue-llk added a commit that referenced this pull request Nov 3, 2026
@lanyue-llk
lanyue-llk force-pushed the refactor/web-search-subcommand-cli branch from ef23b27 to b59b0a3 Compare November 3, 2026 06:51

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

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