Repository navigation
Web Fetch record schemas, one score entry, shared run arguments and certification - #371
Conversation
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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.
| try: | ||
| port = parsed.port | ||
| except ValueError: | ||
| port = None | ||
| return scheme, (parsed.hostname or "").casefold(), port or DEFAULT_PORTS.get(scheme) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
099519f to
a2346bc
Compare
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"]What changed
src/harness/record_schema.py(shared):RecordSchemabinds the common roles (method, case, elapsed time, evidence binding, verdict) onto each track's field names;validate_records/read_recordsvalidate a file. A record may nameschema: "<name>/<version>"; records without it (every existing run and shard) are read as version 1. Web Fetch declares its schemas inweb_fetch/models.py; WCXB's scored row schema lives inwcxb_scoring.py. Validation runs inrunner.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.scoretakes--benchmarkand--certified; a frozen-input benchmark's adapter (score_stage) dispatches to its scorer.benchmarks.certify_methodsis 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(nomoli/moli-fixed/six-method literals);webmainbench-content-reviewrequires--provider. The WebMainBench profile no longer has to declare 545 cases.config.RUN_OPTIONSis the one definition of the shared run options;webstone run,scripts/run_benchmark.py, the default certifier,headless-runandrisk-controlselect from it and sharecheck_run_arguments.--profileso the run loads the declaredcase_count;webmainbench_assemblypassesexpected_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-reviewrequires--provider(wasmoli-fixedby default).Remaining (not in this PR)
runner.run_frozen_cohortstays separate fromrun_evaluation. Merging changes the frozen shard layout that WebMainBench and WCXB certificates bind (verify_shard, WCXBvalidate_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.pyvalidates 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.mdstill nameswebmainbench-score; the card is published to Hugging Face and is left unchanged under the lane rules.Allowlists
Baselines
wcxb.jsonandwebmainbench-sample.jsonchange only the digests of theirreproduce/pages (both languages), which print the new score command. All other baselines are unchanged.Verification
uv run --frozen lexbench-webfetch version: scoring-source hash0fe8931734e1ba7282e1e9c8303eea958d20fdcee83d84e87cdc7e08cd08169ebefore 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.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