Skip to content

refactor(web-fetch): move Web Fetch scripts to subcommands - #181

Merged
lanyue-llk merged 5 commits into
mainfrom
refactor/web-fetch-subcommands
Nov 3, 2026
Merged

lanyue-llk merged 5 commits into
mainfrom
refactor/web-fetch-subcommands

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 #179.

Summary

23 Web Fetch scripts become subcommands of python -m harness.web_fetch, using the router table from #145. One more script, headless_worker.py, is removed because nothing ran it. No old names remain as aliases.

Removed script Command
run_headless_benchmark.py headless-run
capture_headless_browser_observations.py headless-observations
assemble_headless.py headless-assemble
check_headless_evidence.py headless-check
package_headless_resources.py headless-resources
review_headless_results.py review-headless
review_result_anomalies.py review-anomalies
merge_result_review_revision.py review-merge
rebase_blind_result_review.py review-rebase
rescore_content.py content-rescore
revise_body_scoring.py scoring-revision
revise_reference_evidence.py reference-revision
finalize_reference_checks.py reference-finalize
append_dynamic_content.py dynamic-append
merge_dynamic_supplement.py dynamic-merge
build_native_dns.py native-dns
check_report_revision.py report-revision-check
check_diagnostic_report.py diagnostic-check
check_publication_bundle.py site-bundle-check
package_artifact_site.py site-package
publish_artifact_site.py site-publish
verify_artifact_site.py site-verify
import_benchmark_env.py import-env
headless_worker.py none; the provider and the resource container run providers/headless_worker.py directly

The Makefile, guides, skill reference, SECURITY.md, configs/report-templates.json, public_webarena/release.py, tests/package_smoke.py and the tests move in this change. scripts/README.md now lists only the scripts that stay.

Behavior worth reviewing

  • Default root is the working directory. Six scripts passed their checkout as the default root: site-package, site-publish, site-verify, site-bundle-check, report-revision-check and headless-observations. The commands use each owner's existing default, the working directory, as wcxb-publish did in refactor(web-fetch): move WCXB and WebMainBench scripts to subcommands #145. Make targets and release.py run from the checkout, so they behave the same. Elsewhere, pass the path or run from the checkout.
  • import-env keeps the repository .env default. Its default target is harness.web_fetch.config.ROOT / ".env", the file load_runtime_env reads, from any working directory. A test covers it.
  • Three commands parse in cli.py. reference-finalize, native-dns and diagnostic-check had their parsers in the script. capture_source_identity hashes reference_lifecycle.py and network_dns.py, so their parsers cannot move there. The third sits beside them for consistency, as in refactor(trajectory-replay): replace curated scripts with one subcommand CLI #176. reference-finalize keeps its exit status of 1 for an unverified result, and a test covers it.
  • Module entries removed. python -m harness.web_fetch.headless_runner, .scoring_revision and .reference_revision are gone, because the guide now shows the subcommands. .rescoring keeps its block because that file hashes its own bytes into each rescore receipt.
  • headless-run is now documented. The only mention of the old script was a translation entry whose key no longer matches any text in report.py, which names run_certified_benchmark.py instead. I removed that dead entry, which changes no golden route, and HEADLESS.md now names the command and says its output is diagnostic only.
  • A publish credential test changed. It used to import the scripts. It now runs --help for each publish, verify and bundle command through the router and still fails on any token read or created file. The source check for load_runtime_env now reads report_publish.py and publication_verify.py, because cli.py imports that function for run.

Golden snapshot changed: web-fetch

Only report-manifest.json changes, because the manifest embeds the template registry and its diagnostic_check, snapshot_audit_package and snapshot_audit_publish commands changed. Regenerated with UPDATE_GOLDEN=1. No HTML route and no other snapshot changed.

Latency guard

competing_benchmark_pids needs no change. All its script markers name scripts that stay, and no other process marker or path check named a removed script. A test now fails if the bound certifiers stop naming run_benchmark.py, build_report.py, check_report.py or check_report_links.py, or if one of those scripts disappears.

Left in place

Kept Reason
run_benchmark.py, build_report.py, check_report.py, check_report_links.py The hash-bound data/latency-certifiers/*.py.txt files match running processes against these paths, the same rule #145 applied. check_report_links.py is also shared with other tracks.
run_certified_benchmark.py evaluation/risk-control/run-profile.json and risk_control.py name it as the certified entry point.
collect_source_evidence.py, audit_initial_references.py research/initial-reference-audit.json binds their hashes.
import_reference_inputs.py The error text in lexbench_webfetch/inputs.py names it. That file's current hash is the after_sha256 in code-migration.json, so the text cannot change.
restore_report_content.py Owned by harness.reporting, not this track.
add_provider_results.py, certify_headless_cases.py, project_headless_provider.py, build_postcheck_observations.py, check_resource_links.py, select_headless_speed_cases.py, package_headless_speed.py, assemble_webfetch_dataset.py, assemble_webfetch_refresh.py, audit_fixed_native_comparison.py, probe_cowagent_text.py, the three result-review shard tools, authorize_artifact_site.py, rename_artifact_site.py Pending a decision in #151.

No workflow calls a moved script, so .github/workflows/ needed no change.

Effects on existing evidence

  • Stored evidence: none is rewritten. report.py, rescoring.py, reference_lifecycle.py, network_dns.py, review_execution.py, result_review.py and browser_observations.py are byte-identical to main.
  • runtime_source_sha256: runner.py hashes every .py file under harness/web_fetch, so new runs record a new value, as after any earlier change there. A run started before this change cannot resume after it.
  • Report templates: configs/report-templates.json changed, as in refactor(web-fetch): move WCXB and WebMainBench scripts to subcommands #145 and refactor(trajectory-replay): replace curated scripts with one subcommand CLI #176. A private report-content-binding.json may declare its hash under authority. No binding in Git names it, so I could not check a real one.
  • Receipts outside Git: I could not check them.

Reference search

Searching all tracked files for the removed script names leaves two local aliases in tests, neither of which refers to a script: run_headless_benchmark in tests/test_reference_inputs.py and rescore_content in tests/test_scoring.py.

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.
  • tests/test_golden_reports.py: 10 passed after regenerating web-fetch.
  • Full suite from this worktree, after the last code change: 67 failed, 19573 passed, 60 skipped.
    • I grouped the failures by error message rather than comparing against a run of main. Most are Historical benchmark source is not recorded in the dataset lock, the nested-worktree cause described in refactor(web-fetch): move WCXB and WebMainBench scripts to subcommands #145.
    • The others I saw are a missing node_modules/node-html-markdown, a missing evaluation/popular-sites/current-report.json, and tests on the known local macOS failure list.
    • No failure output mentions a new command name or a missing script path.
    • A clean run from a copy outside the worktree was blocked by the sandbox, so CI is the gate for this.
  • make -n import-env report-check PROFILE=/p.json prints the new commands.
  • tests/test_web_fetch_owner_commands.py now checks that every new command's --help comes from its owner.
  • tests/package_smoke.py was edited but not run locally. The "Installation and packaging" check runs it.
  • Not run: real provider calls, publication, or a real report build against measured evidence.
  • After review round 1: ruff passed; tests/test_golden_reports.py with the config, accounts, env-file, owner-command, headless, runtime-entrypoint and path-privacy tests gave 335 passed and 1 failed (test_converter_shared_and_nonzero_not_converted, on the known local failure list). test_optimized_python_rejects_invalid_inventory now passes locally with reference inputs installed.
  • 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 · a39075b

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: a39075ba. CI on this head passes: Tests and static checks, Installation and packaging, and Rendered reference and report checks.

Findings

P2: import-env can write credentials to a file the runner never reads
src/harness/web_fetch/cli.py:81, src/harness/web_fetch/accounts.py:114

  • Problem: the old script always defaulted --target to the checkout's .env. The router calls main_import_credentials() with no default, so the target is now Path.cwd() / ".env". load_runtime_env still reads ROOT / ".env" (config.py:72). Run from any other directory, the command reports success, copies live credentials into that directory, and later runs do not see them. I confirmed this from a temporary directory: the command reported its target as <tmp>/.env. The .gitignore entry only protects copies inside the repository.
  • The PR lists this as a default-root change, but it differs from the other six. Those commands fail on missing inputs or write non-secret output. This one duplicates a secret. The Path.cwd() fallback was also unused until now, because the only entry point always passed a target.
  • Fix: default the target to harness.web_fetch.config.ROOT / ".env", the file load_runtime_env reads, and add a test that runs the command from another directory. package_smoke.py passes --target explicitly, so it does not cover the default.

P2: the headless guide still says a script runs the moved stage
src/harness/web_fetch/HEADLESS.md:188

  • Problem: "headless_runner.py owns cohort selection, execution and implementation checks. The command in scripts/ delegates to it." That command was run_headless_benchmark.py, which this PR removes. No file in scripts/ calls headless_runner now. run_certified_benchmark.py calls certification.main. The name search in the PR's reference check could not find this sentence because it does not name the script.
  • Fix: name headless-run, for example "python -m harness.web_fetch headless-run runs it."

P3: the documented headless-check --rescore command always fails (already on main)
src/harness/web_fetch/HEADLESS.md:354, :373; src/harness/web_fetch/headless_runner.py:316

  • Problem: check_evidence raises Rescoring requires an explicit report_profile whenever --report-profile is absent, even without --rescore. The guide command omits the flag, so it fails before any evidence check. The cohort rejection described at line 373 is never reached in that form either. I reproduced this at this head.
  • The same check explains why test_optimized_python_rejects_invalid_inventory fails on main wherever the reference inputs are installed. Its CI pass is not evidence for headless-check.
  • This PR did not cause it, but it rewrites both guide lines. Fix: add --report-profile PROFILE to the guide and to that test, here or in a follow-up issue.

Verified with no defect

  • Router mapping: each of the 23 commands points at the function its old script called. reference-finalize keeps exit status 1 for an unverified result, and the three parsers moved into cli.py match the old scripts.
  • Argument handling: owners get the same arguments through sys.argv. No owner under harness/web_fetch or harness/reporting reads sys.argv[0] for other uses.
  • headless_worker.py removal: the provider, the runner hash and the resource container all use providers/headless_worker.py. The resource Dockerfile only copies scripts/.
  • Remaining references: the removed script names appear in no tracked file except two test aliases and same-named functions.
  • Hash bindings: the f877f6a6 SHA-256 of every changed or deleted non-test file appears in no tracked file, so no hash in Git binds the old bytes. rescoring.py is the only changed-scope module that hashes its own file, and it keeps its block. capture_source_identity covers no changed file.
  • Kept scripts: I checked the named authorities: run-profile.json, initial-reference-audit.json, the inputs.py after_sha256 in code-migration.json, and the latency certifier markers. The pending scripts match #151. No Web Fetch script is left unclassified.
  • Process markers: no marker in competing_benchmark_pids or the other ps/pgrep callers names a removed script.
  • Credentials: the publish commands do not call load_runtime_env through the router. --help for site-publish, site-verify and site-bundle-check creates no files in a clean directory and home. Adding a load_token call to publication_verify.main made the rewritten credential test fail.
  • Golden snapshots: only report-manifest.json in web-fetch changed, which matches the template registry edit. The removed translation key has no matching text in report.py.
  • Workflows: nothing under .github/workflows/ changed, and no workflow calls a moved script.

Tests run locally at this head

  • Both ruff gates passed.
  • tests/test_golden_reports.py and the affected test modules ran. The only failures are on the known local macOS list: test_optimized_python_rejects_invalid_inventory (it also fails on f877f6a6), test_converter_shared_and_nonzero_not_converted and four test_ci_gate.py cases.
  • Not run: real provider calls or publication.

@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 · 0e766eb

No findings in this incremental review.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

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

  • P2, import-env default target (aefd538d). The default is now harness.web_fetch.config.ROOT / ".env", the file load_runtime_env reads. A new test in tests/test_config.py runs the command through the router from another directory, then checks that load_runtime_env sees the value and that the working directory stays empty. The test fails when the old Path.cwd() default is restored. I also removed the unused default_target parameter.
  • P2, stale scripts/ sentence in HEADLESS.md (b34da42e). The guide now names python -m harness.web_fetch headless-run.
  • P3, headless-check without a profile (0e766eb0). The guide commands and test_optimized_python_rejects_invalid_inventory now pass --report-profile, and the guide says the option is always required. The test now reaches Task inventory differs and passes locally with reference inputs installed. CI skips it when those inputs are absent.

I updated the PR body to match the new import-env default.

@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: 0e766eb0, based on current main (f877f6a6). CI on this head passes: Tests and static checks, Installation and packaging, Rendered reference and report checks, and Python 3.11.

Findings

P3: one new guide line shows a bare python command
scripts/README.md:6

  • Problem: this PR adds "Track stages run as python -m harness.<track> <command>." Issue #179 and AGENTS.md require uv run --frozen python. All the other track sections in this file use that form, starting at line 32. This is the only new command in the diff with a bare python.
  • Fix: change it to uv run --frozen python -m harness.<track> <command>.

I found no correctness, evidence or scope defects.

Round 1 fixes

All three hold.

  • import-env default: the target is now config.ROOT / ".env", the file load_runtime_env reads. I restored the old Path.cwd() default and the new test failed, so it does guard this.
  • Headless guide sentence: it now names headless-run.
  • --report-profile: check_evidence does raise without it, and the guide now says so. The test still reaches Task inventory differs, because that check runs before the profile is read. That test skipped in my run because reference inputs are not installed in this worktree, so I read the code path but did not run it.

What I verified

  • Removed scripts: the diff removes all 24 scripts in the PR table. No tracked file names any of them, and the only remaining headless_worker.py references are to providers/headless_worker.py. The installed lexbench_webfetch package names none of them either.
  • Hash bindings: I hashed the main version of each removed script and each modified file, then searched the tracked tree for those hashes. There were no hits. I also searched lexbench_webfetch for the removed scripts and the main changed sources (not the tests), with no hits. capture_source_identity covers no file this PR changes.
  • Kept scripts:
    • None of the 24 removed scripts is on the #151 pending list.
    • research/initial-reference-audit.json binds collect_source_evidence.py and audit_initial_references.py.
    • The lexbench_webfetch/inputs.py error text names import_reference_inputs.py, and that file's hash is in code-migration.json.
  • Process markers: the certifier markers name only scripts that stay. headless-observations matches on browser profile flags, not script paths.
  • Old and new behaviour:
    • I compared each removed script with its router entry. Only the disclosed default-root change differs. Where that default matters, a missing source or authority file should stop the command rather than give a false pass.
    • reference-finalize keeps its exit status of 1 and diagnostic-check keeps its parser error.
    • None of the owner modules I checked reads sys.argv directly.
    • rescoring.py uses multiprocessing. By my reading of multiprocessing.spawn, -m with a .__main__ module is safe. I did not run this path.
  • Credentials: with a sentinel .env in the checkout, importing the router and running site-verify --help left the environment unchanged.
  • Guides: every flag shown for a moved command in the changed guides, the skill reference and configs/report-templates.json exists in that command's --help.
  • Translation entry: the removed key does not match the current report.py text.
  • Golden snapshot: only report-manifest.json changes in web-fetch, as the PR says.

Local runs

  • Ruff: both commands passed.
  • Golden, owner-command, config, entry-point, publish, package, privacy, report-check, headless and template tests: 441 passed, 5 skipped, 1 failed.
  • The failure is test_migrated_roots_and_worker_paths. It compares /tmp with /private/tmp, which comes from where this worktree sits on macOS. The PR does not touch that assertion, and the full suite passes in CI.

I did not make provider calls, publish anything or build a report from measured evidence.

Outside this PR

report.py is unchanged here, and its headless reproduction sentence that names run_certified_benchmark.py has no exact entry in the translation catalog, and no phrase entry matches it. The English edition of that page may therefore show Chinese text. This already happens on main, and I did not render the page. It may deserve its own issue.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 2:

Fixed (ed7f82c): scripts/README.md line 6 now says uv run --frozen python -m harness.<track> <command>. test_command_inventory_runs_track_stages_through_the_locked_runtime guards the inventory, and it fails against the previous text.

Disputed: nothing.

Not changed, because this PR's diff does not add these lines:

  • docs/architecture.md:213 and src/harness/benchmarks/cards/webmainbench.md:47 still show a bare python -m harness.... Both predate this PR.
  • src/harness/web_fetch/WEBMAINBENCH.md:108 and :112 also show the bare form, but on purpose: that block documents the installed-package commands.

Local results: ruff passes, and tests/test_web_fetch_owner_commands.py, tests/test_documented_paths.py and tests/test_golden_reports.py pass (110 tests). Golden snapshots are unchanged.

@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 skipped · ed7f82c

No reviewable content was selected for this run.

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

Reviewed head: ed7f82c5. No defects found.

What I verified

  • Removed scripts: a whole-word search of all tracked files, and of the installed lexbench_webfetch, finds no reference to any of the 24 removed scripts. The hits that remain are module and function names, such as providers/headless_worker.py and finalize_reference_checks, plus the two test aliases the PR names.
  • Router parity: I compared every removed script with its router entry.
    • reference-finalize keeps exit status 1 for an unverified result.
    • diagnostic-check keeps its one-output rule.
    • No other removed script used a return value as its exit status.
    • No owner reads sys.argv[0] or records it.
  • headless_worker.py: the provider and the resource container both run providers/headless_worker.py directly, so nothing depended on the removed script.
  • Module entries: nothing runs -m harness.web_fetch.headless_runner, .scoring_revision or .reference_revision now. Neither of those last two files reads its own bytes for a binding.
  • Hash bindings:
    • The base-commit SHA-256 of every modified or deleted file under scripts, src and configs appears in no tracked file.
    • cli.py in code-migration.json is the LexBench file, not this one.
    • capture_source_identity covers no file this PR changed.
  • Kept scripts: research/initial-reference-audit.json names the two audit scripts, lexbench_webfetch/inputs.py names import_reference_inputs.py and code-migration.json binds that file's hash. The scripts left for #151 match its list.
  • Default root: with no path given, the moved commands use the working directory. Most then fail if run outside the checkout, because their inputs are missing; site-verify --export is the exception and writes to publish/ in that directory. release.py passes cwd=ROOT, and the Make targets run from the checkout.
  • Earlier rounds: the fixes hold. import-env targets config.ROOT / ".env", the HEADLESS.md wording and --report-profile commands are correct, and scripts/README.md uses uv run --frozen python. No added line in the diff uses a bare python command.
  • Golden snapshots: only the report-manifest.json hash in tests/golden/web-fetch.json changes, which is the change the PR explains.
  • Scope: "Closes #179" is accurate. No workflow file changed, and the diff has no private data or attribution lines.

Test results

  • Lint: both ruff gates pass.
  • Targeted tests, first set: 486 passed, 1 failed. This set covers golden reports, owner commands, config, entry points, publish and package, headless, documented paths, the public WebArena release and checkout precedence.
  • The one failure: test_config.py::test_migrated_roots_and_worker_paths compares /tmp/... with /private/tmp/.... That comes from my worktree sitting under a symlinked path, and the test passes in CI.
  • Targeted tests, second set: 168 passed, 5 skipped. This set covers packaging hygiene, external local report, browser reference scope, headless report and reference inputs.
  • Commands: --help works from outside the checkout for the router, native-dns and reference-finalize. make -n report-check and make -n import-env print the new commands.
  • CI on ed7f82c5: all pass, including "Tests and static checks", "Installation and packaging" and "Rendered reference and report checks".

Not run

No real provider calls, publication, or report build against measured evidence. Receipts outside Git could not be checked, as the PR says.

Noted, not raised as a finding

No production caller now passes the root= or authority_root= keyword to report_publish.main, publication_verify.main, publication_check.main or report_check.revision_main, so those parameters are unused. browser_observations.py is hash-bound and has to keep its own, and a test still passes root= to report_package.main. A partial cleanup would make these owners inconsistent and change no behaviour, so I would leave it for a later cleanup.

lanyue-llk added a commit that referenced this pull request Nov 3, 2026
@lanyue-llk
lanyue-llk force-pushed the refactor/web-fetch-subcommands branch from ed7f82c to 8250e40 Compare November 3, 2026 19:55

@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 · 8250e40

No findings in this review.

@lanyue-llk
lanyue-llk merged commit 2c8a694 into main Nov 3, 2026
7 checks passed
@lanyue-llk
lanyue-llk deleted the refactor/web-fetch-subcommands branch November 3, 2026 20:03
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.

Move Web Fetch scripts to subcommands

1 participant