Repository navigation
Web Fetch report model, variant registry and track template - #375
Conversation
There was a problem hiding this comment.
This review found 2 issue(s), including 2 blocking issue(s).
| if args.variant: | ||
| print(VARIANTS[args.variant].check(args.root, source_spec=args.source_spec, | ||
| authority_root=args.authority_root, | ||
| profile_path=args.profile)) | ||
| return |
There was a problem hiding this comment.
The variant branch silently ignores --visual-receipt, --presentation-binding and --source-dataset. These options are still accepted by argparse, but this return bypasses both receipt generation and the validation that consumes the bindings/source dataset, so a command can report success without performing explicitly requested checks. Reject these combinations with parser.error if the variant checker cannot support them, or execute/forward the requested checks. Add a CLI regression test for combined options.
| selected = (variant(declared) if declared in VARIANTS | ||
| else variant_for_kind(profile.get('comparison_kind')) if request.profile else None) |
There was a problem hiding this comment.
An explicitly declared but unregistered profile variant is silently ignored here. For example, {"variant": "certifed"} selects certified, and --variant certified is accepted despite contradicting the profile declaration. This can run a different build adapter instead of reporting the configuration error. Resolve any non-null declaration through variant(declared) so unknown names raise VariantUsageError; use the comparison-kind fallback only when no variant is declared. Add coverage for an unknown declaration both with and without an explicit CLI variant.
generate() takes a ReportModel (participants, report-only suites, result rows, manifests, render options and source admission) validated on construction. The participant-label and suite ContextVars are gone; the renderer derives its scope from the model through rendering(). The saved-matrix generator moves to its adapter module, removing the renderer's reverse import.
Each build mode is a ReportVariant in report_variants.py declaring the arguments it accepts and requires, its languages, the comparison kinds that select it, and its input adapter. scripts/build_report.py is a thin entry: the profile (variant, else comparison_kind) or one --variant selects the build. The evidence-kind dispatch in report_build, the sample check in report_check and the reliability rule in report_package read the registry instead of comparing kinds. The saved-matrix check moves to check_report.py.
template.py declares the Web Fetch page sets as base-template roles and registers one template variant per build variant (refreshes render the local audit). Every page writer marks its route's role; certified, local-audit, diagnostic and snapshot-audit manifests record base, track and variant versions, and their release checks verify page roles and slot order through the shared check_page.
…the recorded template
…manifests without a recorded variant
8b47099 to
ae48485
Compare
There was a problem hiding this comment.
This review found 4 issue(s), including 4 blocking issue(s).
| if args.variant: | ||
| print(VARIANTS[args.variant].check(args.root, source_spec=args.source_spec, | ||
| authority_root=args.authority_root, | ||
| profile_path=args.profile)) | ||
| return |
There was a problem hiding this comment.
The new variant branch silently skips explicitly requested checks: --visual-receipt, --presentation-binding, and --source-dataset are neither forwarded nor rejected before returning. For example, a valid sample report checked with --variant webmainbench-sample --source-dataset <different-dataset> can report PASS without checking the supplied frozen dataset, unlike the normal path. Reject unsupported option combinations (including --source-spec for variants that ignore it), or run the requested validations before returning.
There was a problem hiding this comment.
Fixed in 91e1a9a with a regression test.
| print(VARIANTS[args.variant].check(args.root, source_spec=args.source_spec, | ||
| authority_root=args.authority_root, | ||
| profile_path=args.profile)) |
There was a problem hiding this comment.
Resolve a relative --profile against --authority-root before dispatching the variant check, as check() does. _check_webmainbench_sample forwards this path unchanged to check_sample_report, which reads it relative to the working directory and derives its authority directory from profile_path.parent.parent. Consequently, --variant webmainbench-sample --authority-root /external/bundle --profile evaluation/current-report.json reads the local profile/history (or fails with FileNotFoundError) instead of checking against the requested bundle.
There was a problem hiding this comment.
Fixed in 91e1a9a with a regression test.
| if (self.dataset.get('comparison', {}).get('publication_state') == 'final_saved_results' | ||
| and self.source_admission != canonical_json_sha256([self.dataset, self.records])): | ||
| raise ValueError('Final saved results require source-backed admission') |
There was a problem hiding this comment.
The admission check only protects the inputs at construction time. dataset and records (including nested dictionaries) are retained by reference despite frozen=True, and generate() only checks the model's type. A caller can construct an admitted model, change a saved verdict through the original records list, and render it without the projection hash being checked again. This loses the previous render-boundary integrity check for final_saved_results. Revalidate the admission against the current inputs at the start of generate() before any renderer mutations, or retain a deeply immutable validated snapshot. Add a regression test that mutates a result after model construction and verifies rendering rejects it.
There was a problem hiding this comment.
Fixed in 91e1a9a with a regression test.
| selected = (variant(declared) if declared in VARIANTS | ||
| else variant_for_kind(profile.get('comparison_kind')) if request.profile else None) |
There was a problem hiding this comment.
An explicit but unregistered profile variant is silently discarded here. For example, {"variant": "diagnostic-cohort"} selects certified rather than raising a usage error, so a typo can route the request into the wrong build mode. Only fall back to comparison_kind when no variant is declared; otherwise resolve it through variant(declared) and add a regression test for an unknown declaration.
There was a problem hiding this comment.
Fixed in 91e1a9a with a regression test.
… variants and post-admission edits
There was a problem hiding this comment.
This review found 3 issue(s), including 3 blocking issue(s).
| if (len({suite.id for suite in self.suites}) != len(self.suites) | ||
| or len(grouped) != len(set(grouped)) or set(grouped) != case_ids): | ||
| raise ValueError('Report suites must partition every case exactly once') |
There was a problem hiding this comment.
Declared suite membership is validated here but is not used to select ranking populations. active_tracks() uses Suite.case_ids, whereas saved_suite_ranking() and the overview select cases with report_family(case) == suite.id. Thus a model with cases in the web family and a valid custom suite containing those cases passes validation but renders an empty suite ranking. Either derive the renderer's report-family mapping from the declared suites or reject mismatches at this boundary; partition validation alone does not guarantee correct results.
There was a problem hiding this comment.
Fixed in e2595a7 with a regression test.
| entry=_render_model(Path(out),model.dataset,model.records,model.manifests,model=model) | ||
| _write_uncalled_participants(Path(out),model) |
There was a problem hiding this comment.
Write the uncalled-participant routes before English generation and language-contract finalization. _render_model() already calls write_english_report(), which discovers the Chinese HTML files present at that point. On a fresh build with include_english=True, participants without records therefore get only a Chinese provider page, while the English tables and language switch link to a nonexistent English counterpart. On a rebuild, an old provider page can instead be translated before this code replaces it.
There was a problem hiding this comment.
Fixed in e2595a7 with a regression test.
| language=f'''<a href="{safe_href(counterpart)}">{('中文' if english else 'English')}</a>''' | ||
| footer=(report_text('en' if english else 'zh')('scores_apply_to_the_frozen_inputs_and', 'Scores apply to the frozen inputs and methods declared in this report. They do not represent the live web or the official WebMainBench leaderboards.')) | ||
| page=f'''<!doctype html><html lang="{('en' if english else 'zh-CN')}"><head><meta name="webstone-report" content="1"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>{esc(title)} · Web Fetch</title><link rel="stylesheet" href="{base}assets/style.css"><script src="{base}assets/report.js" defer></script></head><body><header class="top"><nav class="wrap">{brand}{nav}{language}<button class="theme-toggle" onclick="theme()">{report_text('en' if english else 'zh')('toggle_theme', 'Theme')}</button></nav></header><main>{body}</main><footer class="wrap source-note"><p>{footer}</p></footer></body></html>''' | ||
| page=f'''<!doctype html><html lang="{('en' if english else 'zh-CN')}"><head><meta name="webstone-report" content="1"><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>{esc(title)} · Web Fetch</title><link rel="stylesheet" href="{base}assets/style.css"><script src="{base}assets/report.js" defer></script></head><body><header class="top"><nav class="wrap">{brand}{nav}{language}<button class="theme-toggle" onclick="theme()">{report_text('en' if english else 'zh')('toggle_theme', 'Theme')}</button></nav></header><main{role_attribute(path)}>{body}</main><footer class="wrap source-note"><p>{footer}</p></footer></body></html>''' |
There was a problem hiding this comment.
The new attribute breaks the WebMainBench sample release gate. validate_sample_content() in webmainbench_report_check.py extracts the bound guide with re.search(r'<main>(.*)</main>', page, re.S), and check_sample_report() calls it unconditionally. This writer now emits <main data-page-role="interpretation"> for guide/index.html, so extraction returns None and newly generated sample reports fail with “Sample guide differs from bound content”. Update the extraction to accept attributes while preserving the exact inner-content comparison, and add a generated-guide validation regression test.
There was a problem hiding this comment.
Fixed in e2595a7 with a regression test.
…o report families, read role-marked guides
There was a problem hiding this comment.
✅ Re-review complete · e2595a7
No findings in this incremental review.
Purpose
Web Fetch report builds had no input schema:
generate()took dicts plus nine keyword flags, the saved-matrix adapter set renderer ContextVars (_REPORT_PROVIDER_LABELS,_REPORT_SUITES) from outside, the renderer imported back from the saved-matrix module, andscripts/build_report.pychose among ~10 modes with hand-written exclusion lists. This PR implements steps 1–3 of #328 (spec: Report templates, rules 3, 4, 7, 10): one validated report model, a variant registry that every entry point reads, and Web Fetch on the shared track template.New structure
flowchart TB CLI["scripts/build_report.py (thin)<br/>--profile / --variant / --input"] --> REG CHK["scripts/check_report.py<br/>--variant saved-matrix"] --> REG subgraph REG["report_variants.py: VARIANTS registry"] direction LR V1["certified"] --- V2["webmainbench-sample"] --- V3["wcxb"] --- V4["webmainbench-full"] V5["local-audit"] --- V6["diagnostic-cohorts"] --- V7["published-snapshot-audit"] V8["public-benchmark-research"] --- V9["saved-matrix"] --- V10["refresh-presentation / refresh-review"] end REG -- "accepts / requires / languages /<br/>comparison_kinds / check / render_evidence" --> B["report_build · report_check · report_package"] B --> M["report_model.py<br/>ReportModel: participants, suites, records,<br/>manifests, RenderOptions, source admission"] SM["report_saved_matrix.py<br/>(adapter, owns generate_saved_matrix)"] --> M M --> R["report.generate(out, model)<br/>one entry; rendering(model) scope"] R --> T["template.py: TrackTemplate webfetch/1<br/>page sets → base roles; variants"] T --> OUT["pages: main[data-page-role]<br/>manifest.template = base, track, variant + versions"] OUT --> RC["release checks: check_template_pages → shared check_page"]What changed
report_model.py).generate(out, model)takes aReportModelvalidated on construction: dataset with cases, result rows, manifests, declared participants (with labels; a participant without results still gets its route), report-only suites (must partition the cases),RenderOptions(scoped-refresh rules and unknown attempt/case ids checked here), and the saved-matrix source admission (afinal_saved_resultsdataset renders only with the projection hash its source validation admitted). The_REPORT_PROVIDER_LABELSand_REPORT_SUITESContextVars are removed; renderer state is derived from the model byrendering(model)only.generate_saved_matrixmoves intoreport_saved_matrix.py(its adapter), which removesreport.py's reverse imports; the uncalled-participant pages it used to patch in afterwards are written bygeneratefrom the model.report_saved_composition.pyusesrendering(model)instead of setting three ContextVars.report_variants.py). Each build mode is aReportVariantdeclaring accepted/required arguments, supported languages, the comparison kinds that select it, and its input adapter; optionalcheck,render_evidence,canonical_inputs,reliability_recordandrendershooks replace kind comparisons inreport_build.build_report(WebMainBench sample dispatch),report_check.check/check_revision(sample release check) andreport_package(reliability requirement).scripts/build_report.pyis a 40-line entry: the profile selects the variant (variant, elsecomparison_kind), or one--variant; contradictions are usage errors.configs/report-templates.jsonlists the registered variants (a test keeps them equal).template.py).TrackTemplate("webfetch", 1)maps the standard page set and the complete-cohort page set to base roles, with one template variant per build variant (refreshes renderlocal-audit; the snapshot audit addsaudit/to review;webmainbench-fulldeclares review absent). Every page writer (write, the WCXB, WebMainBench sample/full and research writers) marksmain[data-page-role]. Certified, local-audit, diagnostic and snapshot-audit manifests record base/track/variant versions; their release checks runcheck_template_pages(recorded variant, page roles, slot order via sharedcheck_page).Removed:
report._REPORT_PROVIDER_LABELS,report._REPORT_SUITES,report.generate_saved_matrix,report_saved_matrix.render_saved_with_standard_generatorand_require_final_projection, all mode flags and exclusion lists inscripts/build_report.py, the WebMainBench kind branches inreport_build,report_check(2) andreport_package.Breaking changes
scripts/build_report.py:--local-audit,--diagnostic-cohorts,--webmainbench-full→--variant local-audit|diagnostic-cohorts|webmainbench-full;--saved-matrix SPEC,--public-benchmark-research FILE,--refresh-presentation BINDING,--refresh-review BINDING→--variant <name> --input <file>;--wcxbremoved (the WCXB profile selects the variant;--variant wcxbstill asserts it).scripts/build_report.py --check-saved-matrix REPORT [--source-spec SPEC]→scripts/check_report.py REPORT --variant saved-matrix [--source-spec SPEC].harness.web_fetch.report.generate(out, dataset, records, manifests, **flags)→generate(out, report_model(dataset, records, manifests, **flags));generate_saved_matrixis imported fromharness.web_fetch.report_saved_matrix.base,base_version,track_template,track_version,variant,variant_version; certified/local-audit/snapshot-audit reports built before this change failcheck_report.py("no recorded variant; rebuild it"), as any registry change already required. Diagnostic reports without a recorded variant keep their previous check.Allowlists
Instance-literal: 1 → 1 entry (
harness.reporting.visual, untouched). Layering: 0 → 0. No shared module changed.Baselines
web-fetch.json,wcxb.json,webmainbench-sample.json,webmainbench-full.json: route digests only. The sole byte change isdata-page-role="…"on the<main>of each template page: withrole_attribute()stubbed to"", all four baseline tests pass against the old snapshots unchanged. Headings, table cells, records and summaries are identical. Other tracks' baselines are unchanged.lexbench_webfetchscoring sources are untouched.Verification
uv run --frozen --all-extras python -m pytest tests -n 8 --dist worksteal— 21596 passed after the follow-up fix (2 failures in the first run: a private JSON reader flagged bytest_shared_hash_json_helpersand a manifest assertion; both fixed)uv run --frozen --all-extras python -m pytest tests/baselines tests/test_architecture_layering.py tests/test_architecture_instance_literals.py tests/test_report_template_contract.py -n 8— passedtests/test_web_fetch_report_variants.py: profile selection (declared variant, comparison kind, explicit conflict), undeclared/missing arguments, one variant per comparison kind, registry ↔ template ↔configs/report-templates.json, and negative controls for the release check (wrong role, reordered slots, version drift, unrecorded template, missing page).make lint-check— passed.Not in this PR (remaining)
report.py; they now share the template page roles, but are not yetviews()hooks on the benchmark adapters with one renderer path. Kind branches forrisk_control_100_moli,uniform_native_local_measurement,headless_*andsynthetic_browser_reportremain inreport_build/report_check.methods.pykeeps three label/record ContextVars aroundgenerate, andreport.pykeeps one internal render scope (now derived only from the model).check_template_pages; Web Fetch does not yet go throughreporting.release_check.validate_release.report-translations.json, one-report regex rules inreport_i18n.py,messages.jsondefect prose, and the hardcoded provider labels/slug pattern inreport_saved_composition._model_fetch_badges. Moving them needs each published report's bound content (outside Git) updated first.Part of #328, #337, #331