Skip to content

Web Fetch record schemas, one score entry, shared run arguments and certification - #371

Merged
lanyue-llk merged 8 commits into
mainfrom
refactor/fetch2
Nov 24, 2026
Merged

lanyue-llk merged 8 commits into
mainfrom
refactor/fetch2

Conversation

@lanyue-llk

Copy link
Copy Markdown
Contributor

Purpose

Web Fetch lane of the refactor toward docs/spec.md (#336): named, versioned record schemas validated where stages read them, one score entry for every benchmark, one run-argument definition, a shared certification procedure for frozen-input benchmarks, and the three frozen-input defects from #359.

New structure

flowchart LR
    RS["harness.record_schema<br/>RecordSchema + common roles<br/>method, case, elapsed, evidence, verdict"] --> M["web_fetch.models<br/>call_record/1, scored_result/1,<br/>frozen_call_record/1, frozen_result/1,<br/>frozen_scored_result/1"]
    RS --> W["wcxb_scoring<br/>wcxb_scored_result/1"]
    M --> R["Score readers<br/>rescore, WebMainBench and WCXB scorers,<br/>certifiers, assembly"]
    M --> B["Report builder<br/>default, WebMainBench, WCXB"]
    W --> B
    S["webstone webfetch score --benchmark X [--certified]"] --> BA["BENCHMARKS[X].score_stage"]
    BA --> WS["webmainbench_scoring / webmainbench_certification.main_score / wcxb_scoring"]
    C["benchmarks.certify_methods<br/>drift checks, reuse, final recheck"] --> WC["WebMainBench certifier"]
    C --> XC["WCXB certifier"]
    A["config.RUN_OPTIONS<br/>add_run_arguments / check_run_arguments"] --> E["webstone run, run_benchmark.py,<br/>default certifier, headless-run, risk-control"]
Loading

What changed

  • Versioned schemas for the artifacts stages exchange #327 src/harness/record_schema.py (shared): RecordSchema binds the common roles (method, case, elapsed time, evidence binding, verdict) onto each track's field names; validate_records/read_records validate a file. A record may name schema: "<name>/<version>"; records without it (every existing run and shard) are read as version 1. Web Fetch declares its schemas in web_fetch/models.py; WCXB's scored row schema lives in wcxb_scoring.py. Validation runs in runner.load_records (rescore), report_build (default, WebMainBench sample/full and WCXB reports, release check), the WebMainBench scorer, certifier and assembler, and the WCXB scorer. Writers are unchanged, so no record bytes change.
  • Web Fetch: benchmark adapter interface; fold WebMainBench and WCXB into the shared run and score stages #322 score takes --benchmark and --certified; a frozen-input benchmark's adapter (score_stage) dispatches to its scorer. benchmarks.certify_methods is the shared certification loop; WebMainBench and WCXB supply run/verify/drift steps and keep their hash-bound certificate formats. The WebMainBench case correction names its corrected method by --fixed-provider/--runner-provider/--baseline-binary (no moli/moli-fixed/six-method literals); webmainbench-content-review requires --provider. The WebMainBench profile no longer has to declare 545 cases.
  • Web Fetch: one run entry with a shared argument builder #326 config.RUN_OPTIONS is the one definition of the shared run options; webstone run, scripts/run_benchmark.py, the default certifier, headless-run and risk-control select from it and share check_run_arguments.
  • Frozen-input runs: pass the declared case count and keep full origin identity #359 The WebMainBench certifier passes --profile so the run loads the declared case_count; webmainbench_assembly passes expected_count; the isolation probe requests the frozen query; fixture registration and HTTP/CONNECT routing key on scheme, host and port (the probe follows the record's scheme and port).

Breaking changes

  • webstone webfetch webmainbench-score → webstone webfetch score --benchmark webmainbench (same options).
  • webstone webfetch webmainbench-full-score → webstone webfetch score --benchmark webmainbench --certified.
  • webstone webfetch wcxb-score → webstone webfetch score --benchmark wcxb.
  • webstone run --provider-concurrency → --workers.
  • headless-run --config → --provider-config.
  • run_certified_benchmark.py webmainbench-correction: --moli-binary → --baseline-binary (with --runner-provider); a complete correction requires --fixed-provider.
  • webmainbench-content-review requires --provider (was moli-fixed by default).

Remaining (not in this PR)

  • runner.run_frozen_cohort stays separate from run_evaluation. Merging changes the frozen shard layout that WebMainBench and WCXB certificates bind (verify_shard, WCXB validate_calls); with the record schemas in place the next step is a versioned frozen layout written by the shared loop, with the v1 shard readers kept.
  • webmainbench_latency_correction.py validates one historical receipt kind end to end; parametrising it is not cheap and needs the owner decision from Run WebMainBench and WCXB through Web Fetch benchmark adapters #351 (retire or keep).
  • src/harness/benchmarks/cards/webmainbench.md still names webmainbench-score; the card is published to Hugging Face and is left unchanged under the lane rules.

Allowlists

  • instance literals: 1 → 1; layering: 0 → 0.

Baselines

wcxb.json and webmainbench-sample.json change only the digests of their reproduce/ pages (both languages), which print the new score command. All other baselines are unchanged.

Verification

  • uv run --frozen lexbench-webfetch version: scoring-source hash 0fe8931734e1ba7282e1e9c8303eea958d20fdcee83d84e87cdc7e08cd08169e before and after.
  • make lint-check: passed.
  • uv run --frozen --all-extras python -m pytest -n 8 --dist worksteal tests/baselines tests/test_architecture_layering.py tests/test_architecture_instance_literals.py: passed.
  • Full suite before the final rebase: uv run --frozen --all-extras python -m pytest -n 8 --dist worksteal tests — 23008 passed, 78 skipped. After rebasing onto main (test: prune and speed up root tests m-z #365, Report template contract with Web Search as the first track template #366) the touched test modules, baselines and architecture checks pass.

Closes #326
Closes #359
Part of #322
Part of #327

@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 · 099519f

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

rows = []
for index, record in enumerate(records, 1):
declared = record.get("schema") if isinstance(record, dict) else None
schema = known.get(declared) if declared is not None else schemas[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
Validate the schema declaration's type before using it as a dictionary key. A JSON row containing "schema": [] or "schema": {} currently raises TypeError: unhashable type rather than RecordSchemaError, losing the source/row diagnostic and bypassing handlers that catch validation failures as ValueError. Reject non-string declarations explicitly before lookup.

Comment thread src/harness/web_fetch/frozen_inputs.py Outdated
Comment on lines +124 to +128
try:
port = parsed.port
except ValueError:
port = None
return scheme, (parsed.hostname or "").casefold(), port or DEFAULT_PORTS.get(scheme)

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
Only an absent port should resolve to the scheme default. Currently https://example.com:0 normalizes to port 443, and malformed or out-of-range ports do too because ValueError is swallowed. Consequently, requests such as CONNECT example.com:0 or CONNECT example.com:99999 match a fixture registered for port 443, contrary to full-origin routing. Preserve explicit zero with an is None check, reject invalid fixture ports, and reject malformed request authorities rather than mapping them to a valid origin.

if args.baseline_binary:
if args.runner_provider not in selected:
parser.error("--baseline-binary requires --runner-provider to name a source method")
binaries[args.runner_provider] = args.baseline_binary

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
Reject a baseline provider equal to fixed_provider before this assignment. For example, --provider moli --runner-provider moli --baseline-binary baseline --fixed-binary fixed passes the membership checks but replaces the fixed binary in binaries. Consequently fixed is never hash-validated or executed; the later identity check only checks the baseline against the frozen evidence. Require distinct baseline and corrected provider keys so the mandatory fixed binary cannot be silently ignored.

def verify_score(shard: Path, provider: str, case_ids: set[str], scorer: Path, profile: dict) -> dict:
scored = read_jsonl(shard / "scored-results.jsonl")
measured = read_jsonl(shard / "results.jsonl")
scored = read_records(shard / "scored-results.jsonl", FROZEN_SCORED_RESULT)

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
Explicitly schema-tagged inputs cannot complete the scoring pipeline. The scorer now accepts schema: "webfetch.frozen_result/1", but result = {**row, "metrics": metrics} preserves that tag in scored-results.jsonl. This reader (and assembly) accepts only webfetch.frozen_scored_result/1, so it rejects the scorer's output. Transition the tag when scoring and adjust the measured/scored equality checks to account for that transition; add a round-trip test using explicitly tagged records.

…identity

The WebMainBench certifier and assembly pass the profile's case count to
load_source; the isolation probe requests the frozen query; fixture
registration and HTTP/CONNECT routing key on scheme, host and port.
webstone run, scripts/run_benchmark.py, the default certifier, headless-run
and risk-control select their options from config.RUN_OPTIONS and share
the value checks. webstone run --provider-concurrency becomes --workers;
headless-run --config becomes --provider-config.
harness.record_schema binds the common fields (method, case, timing,
evidence, verdict) for every track. Web Fetch declares call record,
scored result and frozen-input schemas; the score, certify, assemble and
report stages validate the files they read. Records without a schema
field are read as version 1, so existing runs and shards stay readable.
…chmark

The benchmark adapter owns its score stage: webstone webfetch score
--benchmark webmainbench scores one shard, --certified scores a certified
cohort, and --benchmark wcxb scores a certified WCXB cohort. The
webmainbench-score, webmainbench-full-score and wcxb-score commands are
removed. Only the reproduce pages of the WCXB and WebMainBench sample
baselines change, because they print the new command.
…Bench corrections

The case correction takes --fixed-provider, --runner-provider and
--baseline-binary instead of fixed moli/moli-fixed names and a six-method
count; webmainbench-content-review requires --provider.
benchmarks.certify_methods owns the method loop: drift checks around each
method, reuse of prior certified shards and the final recheck of every
shard. The WebMainBench and WCXB certifiers supply their run, verify and
drift steps and keep their hash-bound certificate formats.
…ction providers

Reject non-string schema declarations; carry an explicit frozen-result
tag through scoring; resolve only absent ports to the scheme default and
reject malformed ones; refuse a baseline provider equal to the corrected
one.

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

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.

Frozen-input runs: pass the declared case count and keep full origin identity Web Fetch: one run entry with a shared argument builder

1 participant