Skip to content

Run WebMainBench and WCXB through Web Fetch benchmark adapters - #351

Merged
lanyue-llk merged 5 commits into
mainfrom
refactor/fetch-run
Nov 24, 2026
Merged

lanyue-llk merged 5 commits into
mainfrom
refactor/fetch-run

Conversation

@lanyue-llk

Copy link
Copy Markdown
Contributor

Purpose

Web Fetch benchmarks get one adapter interface and one run entry. WebMainBench and WCXB stop having their own runner module, method lists, versions and benchmark branches: a registry of BenchmarkAdapters supplies cases, frozen-input serving, scoring and populations, and webstone run --benchmark <name> (plus --certified) selects them.

flowchart LR
    CLI["webstone run --benchmark NAME<br/>(one argument definition)"] --> REG["BENCHMARKS registry<br/>web_fetch/benchmarks.py"]
    CERT["webstone run --certified / run_certified_benchmark.py --benchmark NAME"] --> REG
    REG --> LIVE["default (LiveSuite)<br/>cases: dataset · inputs: live sites · score: score_attempt"]
    REG --> WMB["webmainbench<br/>cases: webmainbench_dataset · score: pinned official calculator"]
    REG --> WCXB["wcxb<br/>cases: wcxb_dataset + profile · score: bound wcxb_metrics"]
    LIVE --> RE["runner.run_evaluation"]
    WMB --> RF["runner.run_frozen_cohort"]
    WCXB --> RF
    RF --> FI["frozen_inputs: loopback HTTPS fixture,<br/>sandbox probe, hosted inline-HTML route"]
Loading

What moved or was removed

  • New web_fetch/benchmarks.py: BENCHMARKS registry with default, webmainbench, wcxb adapters (cases, inputs, score, populations, resolve, certify, capability frozen_inputs). Command choices derive from the registry.
  • web_fetch/webmainbench_runner.py removed. Its parts went to:
    • frozen_inputs.py (benchmark-neutral): fixture_server, verify_loopback_sandbox, fetch_frozen, input contract, hosted inline-HTML route, version check.
    • webmainbench_dataset.py: selected_input, load_source, load_selected_ids, DATASET_SHA256, SCORER_COMMIT (webmainbench_scoring now imports these instead of duplicating them).
    • wcxb_dataset.py: selected_wcxb_input, load_wcxb_source (this also removes the import cycle between the two modules).
    • runner.run_frozen_cohort(benchmark, args): the per-call loop with no benchmark name. It still writes the shard layout every current reader needs (dataset.json, physical-attempts.jsonl, results.jsonl, execution.json, artifacts/), with the same field set.
  • run_evaluation scores through benchmark.score(...) (default LiveSuite, which calls score_attempt).
  • wcxb_scoring.case_metrics and webmainbench_scoring.official_metrics are the per-case scorers, used by both the score stages and the adapters.
  • certification.run_wcxb moved to wcxb_certification.main. certification.main selects a frozen-input certifier with --benchmark and no longer dispatches webmainbench-full / wcxb by argv.
  • Instance data moved out of code:
    • PROVIDERS, WCXB_PROVIDERS removed. The WebMainBench and WCXB profiles' providers are the matrix. Names are validated as safe identifiers present in the provider configuration.
    • EXPECTED_VERSIONS removed. Versions come from --expected-version, the profile (versions / expected_versions) or the provider config's expected_version, which validate() already enforces.
    • case_count != 545 is now the profile's case_count, passed to load_source(expected_count=...).
    • The WCXB certifier's moli / moli-pr643 binary pins become "each build hash the profile pins is measured by exactly one participant" (paired_latency_methods). WCXB runs now pass the profile's timeout_seconds / max_failure_retries explicitly. Both equal the old defaults, 45 and 1.
    • if provider != "kitesurf" / if provider == "obscura" become a declared capability: an engine with a hosted backend (engine_definition(...).hosted) takes the inline-HTML route. Every local engine runs loopback_only with allow_private_network set. Only obscura's command template has that slot, so other engines see no difference.
  • scripts/run_webmainbench_benchmark.py stays, because frozen latency certifiers name it. It is now a thin wrapper of webstone run --benchmark webmainbench.

Breaking changes

Before After
python scripts/run_webmainbench_benchmark.py --provider P --config C ... and python -m harness.web_fetch.webmainbench_runner ... webstone run --benchmark webmainbench --providers P --provider-config C ... (the script remains as a wrapper with the new flags)
python -m harness.web_fetch.webmainbench_runner --benchmark wcxb ... webstone run --benchmark wcxb --providers P --profile ... --case-ids-file ...
run_certified_benchmark.py webmainbench-full ... run_certified_benchmark.py --benchmark webmainbench ... or webstone run --certified --benchmark webmainbench ...
run_certified_benchmark.py wcxb ... run_certified_benchmark.py --benchmark wcxb ... or webstone run --certified --benchmark wcxb ...
webstone webmainbench-full-run (owner command) removed; use webstone run --certified --benchmark webmainbench
webstone run --timeout / --dataset / --provider-config defaults unchanged for the default suite; now resolved from the selected benchmark adapter
webstone run with frozen-only options (--profile, --case-ids-file, ...) on the default suite, or live-only options on a frozen benchmark rejected instead of silently ignored
Python API: webmainbench_runner.*, certification.run_wcxb see "What moved"

Recorded-content changes for new runs only: the dataset.json input_contract.network_policy text says "hosted engines reject subresource types" instead of naming Kitesurf. The ephemeral fixture CA subject names no benchmark. execution.json runner_sha256 now hashes runner.py. Nothing reads these values back. Existing evidence and certificates are untouched.

Not changed / remains (Part of)

  • Web Fetch: benchmark adapter interface; fold WebMainBench and WCXB into the shared run and score stages #322: the frozen-input loop is still a second function next to run_evaluation, not the same loop. Merging them needs one record schema. That means migrating every WebMainBench/WCXB reader (assembly, certification verify_shard, both scorers, report build, case/latency correction), and those readers must keep reading historical shards. Scoring also stays two benchmark-specific stages (webmainbench-score, wcxb-score, webmainbench-full-score) rather than one shared score --benchmark. The two certifiers (webmainbench_certification, wcxb_certification) keep separate code because their certificate formats are hash-bound and verified by current readers.
  • Campaign modules, left for the owner to decide: webmainbench_correction.py ("moli-fixed"), webmainbench_latency_correction.py, webmainbench_latency_diagnostic.py, webmainbench_case_correction.py, and the review_execution.py defaults still name one provider or campaign. These exist for finished WebMainBench correction and latency campaigns. Current authorities (the latency-source registry and the correction binding) bind their receipts but not these modules' code paths for new runs. Only their run invocation was updated here.
  • Web Fetch: one run entry with a shared argument builder #326: one argument definition now serves webstone run for every benchmark, run_certified_benchmark.py --benchmark, and the in-process run_stage used by certifiers. Still separate: scripts/run_benchmark.py (benchmark_runner), the default-suite certifier parser, headless-run and risk-control.
  • report_build.py:1055 (!= 200) and the wcxb_dataset sample-size constants were not touched; they belong to the report lane.

Checks

  • Allowlists: instance-literal 2 modules / 3 entries → unchanged; layering 9 → unchanged. Web Fetch track modules are outside the checks' current scope.
  • Baselines (tests/baselines): unchanged. Goldens: only the reproduction command text changed (see below).
  • uv run --frozen lexbench-webfetch version: scoring_source_sha256 is still 0fe8931734e1ba7282e1e9c8303eea958d20fdcee83d84e87cdc7e08cd08169e. No src/lexbench_webfetch/ or HF card changes.
  • WCXB wcxb_metrics.py (hash-bound) is not edited.
  • New tests/test_web_fetch_benchmarks.py iterates the registry: protocol conformance, frozen hooks, registry-derived choices, both scorers, option rejection and --certified dispatch.

Commands run:

  • make lint-check: passed.
  • uv run --frozen --all-extras python -m pytest tests/baselines tests/test_golden_reports.py tests/test_architecture_*.py: passed. Goldens were refreshed only for the two reproduction-command lines in the WCXB and WebMainBench sample reports. With report.py restored, the old goldens pass, so nothing else in the rendered output changed.
  • Full suite pytest -n 8: 23936 passed, 11 failed. All 11 also fail on base main a0b5b5636 for environment reasons (test_ci_gate, plus test_markdown, test_html_to_markdown and test_headless converter tests that need node).

Part of #338, Part of #322, Part of #326.

@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 · 175b726

This review found 6 issue(s), including 6 blocking issue(s).

selected = selection = None
if profile.case_ids_file:
selected, selection = load_selected_ids(profile.case_ids_file, profile.expected_dataset_sha256)
records = load_source(profile.dataset, selected, profile.expected_dataset_sha256)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
The adapter still calls load_source with its default expected_count=545. The updated certifier accepts any positive profile case_count and validates the source with that count, but its child run reaches this call and rejects every non-545 corpus after preflight succeeds. Propagate the profile's expected count into the child run and this loader (retaining 545 as the historical default) so certified execution uses the same inventory contract as preflight.

Comment on lines +221 to +222
run_frozen_cohort(benchmark, args)
return 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
Frozen runs accept --fail-on-failure but always return success, even when every final provider response has ok=False. Unlike the live path, no outer handler enforces this flag. Return a failure summary from run_frozen_cohort and use it to return a nonzero status when requested, or explicitly reject the unsupported flag rather than silently ignoring it.

"""Prove that the measured child can read the fixture but cannot connect externally."""
parsed = urlsplit(endpoint)
origin = urlsplit(record["url"])
path = origin.path or "/" if preserve_original_origin else "/case/" + record["track_id"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
The origin-preserving probe omits origin.query. For records such as https://example.com/page?id=1 and https://example.com/page?id=2, the fixture marks /page ambiguous and disables its path fallback. The probe therefore gets a 404 and aborts a valid run before measurement. Include the query string in the probe's request target and cover this case with a regression test.

Comment on lines +1269 to +1270
if args.limit:
records = records[: args.limit]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
--limit accepts any integer without validation: zero skips this branch and runs the entire cohort, while a negative value selects all but the last N records. This can issue many unintended provider calls. Validate that an explicitly supplied limit is positive before loading inputs or creating evidence, and distinguish None from zero.

or any(not isinstance(name, str) for name in methods)
or len(set(methods)) != len(methods)
or type(profile.get("case_count")) is not int or profile["case_count"] != 545
or type(profile.get("case_count")) is not int or profile["case_count"] <= 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
Profiles now accept cohorts other than 545 records, and preflight uses that count, but the collection subprocess does not propagate it. WebMainBench.cases() still calls load_source() with its default expected_count=545, so a valid non-545 profile passes preflight and then fails collection. Carry the profile's case_count through the shared run interface and into the adapter's load_source() call.

"-m harness.trajectory_replay",
"scripts/run_webmainbench_benchmark.py",
"-m harness.web_fetch.webmainbench_runner",
"-m harness.web_fetch run",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
The updated isolation check recognizes the module invocation but not the advertised webstone run --benchmark ... console entry point. That entry point runs in-process, so its process command does not contain this marker. A concurrent WebMainBench/WCXB console run can therefore escape both the preflight and polling checks and contaminate certified timing. Include the console invocation in process detection and test both launch forms.

…chmark adapters

Add the Web Fetch benchmark adapter registry (default, webmainbench, wcxb),
move frozen-input serving to frozen_inputs, loaders to their dataset modules,
and the per-call loop to runner.run_frozen_cohort. Method matrices, versions
and counts come from profiles and provider configuration; hosted versus local
network isolation follows the engine capability. webstone run selects the
benchmark with --benchmark and certification with --certified; the WCXB
certifier moves to wcxb_certification.
@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Rebased on main after #345 and #349.

  • certification.py: dropped the webmainbench_runner imports (this PR removes that module) and the stale search_main import that main had already removed.
  • cli.py: main() keeps refactor: shared HTTP/privacy/style modules and uniform webstone <track> <stage> verbs #345's run_stage(STAGES, ...) dispatch and this PR's run --certified hand-off to the certifier. This PR's in-process helper cli.run_stage(argv) shadowed the imported harness.adapters.run_stage, so I renamed it to run_in_process and updated wcxb_certification.py.
  • No golden or baseline refresh beyond this PR's own commit. The allowlists are unchanged, and the scorer hash is still 0fe89317…. The local baselines, golden, architecture, adapters, CLI and every touched test file pass (857 tests).

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

This review found 6 issue(s), including 6 blocking issue(s).

selected = selection = None
if profile.case_ids_file:
selected, selection = load_selected_ids(profile.case_ids_file, profile.expected_dataset_sha256)
records = load_source(profile.dataset, selected, profile.expected_dataset_sha256)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
The adapter still calls load_source with its default expected_count=545. The updated full-cohort certifier accepts profile["case_count"] and uses it for preflight, so a hash-bound corpus with a different declared count passes preflight but its first run subprocess fails here with Expected 545 records. Propagate the declared count/profile from the certifier into this adapter and pass it as expected_count, retaining 545 only as the unprofiled default.

Comment on lines +225 to +226
run_frozen_cohort(benchmark, args)
return 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
Frozen runs accept --fail-on-failure through the shared parser but always return success here, even when every final provider response has ok=False. This makes failure-sensitive automation incorrectly pass. Propagate the final cohort failure status and return a nonzero exit code when requested, or explicitly reject this option for frozen runs rather than silently ignoring it.

"""Prove that the measured child can read the fixture but cannot connect externally."""
parsed = urlsplit(endpoint)
origin = urlsplit(record["url"])
path = origin.path or "/" if preserve_original_origin else "/case/" + record["track_id"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
The original-origin probe omits the URL query. For records such as /search?q=first and /search?q=second, the fixture deliberately disables path-only fallback, so probing /search returns 404 and the hash check aborts a valid run before any provider calls. Include origin.query in the probe request target and add a probe test covering the query-distinguished records already exercised by the fixture tests.

Comment on lines +1253 to +1254
if args.limit:
records = records[: args.limit]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
--limit accepts any integer, but this truthiness check makes --limit 0 execute the entire cohort, while a negative value runs all but the last N cases. Both can unexpectedly trigger many paid provider calls instead of limiting execution. Validate that a supplied limit is positive before preparing the run (or explicitly support zero as an empty selection), and test zero and negative values.

or any(not isinstance(name, str) for name in methods)
or len(set(methods)) != len(methods)
or type(profile.get("case_count")) is not int or profile["case_count"] != 545
or type(profile.get("case_count")) is not int or profile["case_count"] <= 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
Profiles with a non-545 case_count now pass preflight, but the collection subprocess does not receive that count (or the profile). WebMainBench.cases() still calls load_source() with its default expected_count=545, so these newly accepted profiles fail before collection. Pass the profile/count through to the adapter and use it when loading the corpus.

"-m harness.trajectory_replay",
"scripts/run_webmainbench_benchmark.py",
"-m harness.web_fetch.webmainbench_runner",
"-m harness.web_fetch run",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
The process guard misses the newly advertised webstone run --benchmark ... entry point: its process command contains neither this module invocation nor any of the script markers. A concurrent console-script benchmark can therefore run during certified timing without triggering the isolation check. Include console-entry-point invocations in the matcher and test them alongside the module invocation.

…ozen-run flags, guard console runs

The certifier again requires the profile case count the WebMainBench loader
enforces. Frozen runs reject --fail-on-failure instead of ignoring it, --limit
must be positive, and the latency isolation guard also sees console runs
(webstone run / webstone webfetch run).
@lanyue-llk

Copy link
Copy Markdown
Contributor Author

OCR round 1 (ecabb16), fixed in 44bbfff:

  • case_count (benchmarks.py:183 / webmainbench_certification.py:43): fixed. The certifier requires case_count == CASE_COUNT again. Accepting other counts was an unintended relaxation, because the adapter, population and dataset id are all bound to the 545-case corpus.
  • --fail-on-failure ignored on frozen runs: fixed. Frozen benchmarks now reject the flag as "does not apply", the same way other live-only options are rejected.
  • --limit 0 or negative: fixed. The limit must be a positive number, with a test.
  • Latency guard misses console runs: fixed. The guard also matches webstone run and webstone webfetch run , with a test.
  • Original-origin probe omits the query (frozen_inputs.py:259): deferred as P2. This code moved unchanged from webmainbench_runner.py (main has the same omission). Pinned corpora have not hit it, and it fails closed (aborts before measurement) rather than corrupting evidence. It should be a follow-up issue.

@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 · 44bbfff

This review found 2 issue(s), including 2 blocking issue(s).

"""Prove that the measured child can read the fixture but cannot connect externally."""
parsed = urlsplit(endpoint)
origin = urlsplit(record["url"])
path = origin.path or "/" if preserve_original_origin else "/case/" + record["track_id"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
The origin-preserving probe drops the URL query. For valid records such as /search?q=first and /search?q=second, fixture_server() marks the shared path ambiguous and returns 404 for this query-less probe. If the first selected record has such a URL, run_frozen_cohort() aborts before measuring any cases despite the fixture supporting both exact URLs. Append origin.query to the probe request path and add a probe regression test using query-distinguished records (the fixture tests already cover this input).

if (profile.get("schema_version") != 1
or not isinstance(methods, list) or not methods
or any(not isinstance(name, str) or name not in PROVIDERS for name in methods)
or any(not isinstance(name, str) for name in methods)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
Allowing configured participant names here is not sufficient for hosted-engine aliases: _read_profile() still tests engine_definition(name).hosted, and main() makes the same lookup using provider. For a participant named hosted-chrome configured with engine: kitesurf, these lookups return the unregistered (non-hosted) definition, while hosted_html_route() correctly uses the configured engine. Consequently a valid hosted participant without a release version is rejected, or receives an inappropriate --expected-version check. Resolve these capability checks from each participant's provider configuration, rather than its report label.

…nfigured engine

The certifier's release-version requirement and --expected-version hand-off now
use the participant's configured engine, as the hosted HTML route does, rather
than its report label.
@lanyue-llk

Copy link
Copy Markdown
Contributor Author

OCR round 2 (44bbfff), handled in 0d10b13:

  • Hosted capability from the report label (webmainbench_certification.py:41): fixed. The version requirement and the --expected-version hand-off now follow engine_definition(settings[name].get('engine')), which is the same resolution hosted_html_route uses. Current configs keep the same name→engine mapping, so their results do not change.
  • The rest of round 2 repeats round 1 findings already fixed in 44bbfff (case_count, --fail-on-failure, --limit, console guard). The query-less origin probe stays deferred as P2 (code moved unchanged from main).

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

This review found 2 issue(s), including 2 blocking issue(s).

Comment on lines +132 to +133
path_key = (host.casefold(), parsed.path or "/")
key = (*path_key, parsed.query)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
Original-origin fixture keys discard scheme and port, so distinct URLs such as https://example.test/page and https://example.test:8443/page collide and raise the non-unique URL error before the run starts. The dataset loaders do not prohibit these URLs, and lookup also strips the port, so changing only the duplicate check would still serve the wrong body. Preserve the complete origin identity in both registration and HTTP/CONNECT routing.

"""Prove that the measured child can read the fixture but cannot connect externally."""
parsed = urlsplit(endpoint)
origin = urlsplit(record["url"])
path = origin.path or "/" if preserve_original_origin else "/case/" + record["track_id"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bug · medium
The original-origin probe drops the URL query. For the supported cohort shape already covered by test_same_origin_path_uses_exact_frozen_query_without_crossing_cases (/search?q=first and /search?q=second), probing the first record requests /search, which returns 404 because the path fallback is ambiguous. run_frozen_cohort therefore aborts before any measured calls despite a working fixture and sandbox. Include origin.query in the probe request target and add coverage for sandbox verification with query-distinguished records.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

OCR round 3 (0d10b13). Both remaining findings are about frozen-input serving code that this PR moved without changing it from webmainbench_runner.py (main has the same behaviour):

  • the original-origin probe omits the query (frozen_inputs.py:259)
  • the original-origin fixture keys drop scheme and port (frozen_inputs.py:133)

Both fail closed: the run aborts before any measured call, so evidence is not corrupted, and no pinned corpus triggers them. Deferred as P2 follow-ups rather than a third OCR cycle on a behaviour-preserving refactor. Merging on green required checks.

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.

1 participant