Skip to content

Web Fetch: one render entry, benchmark page-set views and declared comparison kinds - #377

Merged
lanyue-llk merged 9 commits into
mainfrom
refactor/fetch-views
Nov 24, 2026
Merged

lanyue-llk merged 9 commits into
mainfrom
refactor/fetch-views

Conversation

@lanyue-llk

Copy link
Copy Markdown
Contributor

Purpose

Finish the Web Fetch report convergence after #375: every report variant renders through one entry on the track template, benchmark page sets are benchmark views, comparison kinds are declarations, and the remaining instance literals in the latency correction become data.

flowchart LR
  B[scripts/build_report.py] --> V[report_variants: ReportVariant registry]
  V --> R["report.render_report(out, *inputs, variant=)"]
  R -->|variant=None| M[model page set: ReportModel]
  R -->|wcxb / webmainbench-*| H["BENCHMARKS[...].views() → PageSetHook"]
  H --> W[wcxb_report.py / webmainbench_report.py]
  R -->|diagnostic / research| T[track page sets]
  R --> MF[report-manifest.json records template variant]
  K[COMPARISON_KINDS declarations] --> BL[build / check / package / local audit]
  MF --> G[shared release gate + check_template_pages]
Loading

What changed

  • Web Fetch: one report model and a mode registry for report builds #328
    • One render entry render_report(out, *inputs, variant=None). generate, generate_wcxb, generate_webmainbench, generate_webmainbench_full, generate_cohort_diagnostic and generate_public_benchmark_research are removed. WCXB and WebMainBench (sample, full) page sets moved out of report.py (4,651 → 3,127 lines) into wcxb_report.py and webmainbench_report.py. The benchmark adapters contribute them through views() as a new instance-neutral reporting.templates.PageSetHook. Diagnostic and research page sets are track page sets keyed by variant.
    • Non-model variants (WCXB, WebMainBench sample and full, diagnostic, research) now record their template variant in report-manifest.json. check_recorded_template / check_template_pages verify it, and reports built before this change still verify. The Web Fetch check_template_pages now delegates to the shared reporting.release_check.check_template_pages.
    • Comparison-kind branches (uniform_native_local_measurement, web_fetch_diagnostic, headless_html / headless_markdown, synthetic_browser_report, risk_control_100_moli) are now ComparisonKind declarations in report_variants.py. report_build, report_check, report_changes and local_audit read the declared properties. The risk-control certification check and its file list moved into risk_control.py as the declared certification owner.
    • methods.py no longer holds ContextVars. Its four ContextVars (records, execution configs, method registry, measured labels) are now a MethodScope field of the one RenderContext, which moved to report_model.py. rendering() keeps an enclosing method scope.
    • WCXB packaging runs the shared validate_release gate. It gains the shared language and presentation stages, and the stages run in the gate's order.
    • Fixed the WCXB reproduce command: it was missing --profile and wrote to reports/webfetch.
  • Web Fetch: benchmark adapter interface; fold WebMainBench and WCXB into the shared run and score stages #322: webmainbench_latency_correction.py is still needed. evaluation/webmainbench-content-binding.json hash-binds latency-corrections.json (e859d378…) as evidence of the current WebMainBench sample report, and the sample check, build and publication check read it through validate_latency_correction. So the module is kept. Its campaign literals (methods and versions, 200/400/800/1200 counts, rounds, selected round, receipt and certificate kinds, known failures) moved into data/webmainbench-latency-corrections.json. Apply and verify select the campaign from the certificate or receipt kind. The frozen receipts and certifier sources are unchanged.
  • One publisher interface over the publication lifecycles #333: The receipt lifecycle (ReceiptRelease) now rejects an explicit PublicationTarget.title that differs from the release title, and a share_url that differs from the saved receipt or profile link. Before this change, both were silently ignored.
  • Shared release-check and package skeleton #332 (rest, not done): The Web Fetch lazy bundle packager writes a privacy-projected, packed tree and no attestation. package_archive archives the report tree verbatim and writes an attestation, so switching would change the archive bytes and outputs; this PR leaves the packager alone. Lexbench has no directory packager to move; its copytree is a negative-control view.

Breaking changes

  • scripts/run_certified_benchmark.py webmainbench-latency (the latency certifier) now requires --correction <receipt kind>.
  • Python API: harness.web_fetch.report.generate* are replaced by render_report(..., variant=...). report_build.require_risk_control_certification is replaced by require_declared_certification.

Allowlists

Instance literals: 1 → 1. Layering: 0 → 0.

Baselines

The web-fetch baseline is unchanged. The wcxb, webmainbench-sample and webmainbench-full baselines change only in report-manifest.json, which now records the variant (for webmainbench-full it is added to the existing manifest). The WCXB reproduce/index.html (zh and en) also changes because of the command fix. All other routes are byte-identical. The scorer hash is unchanged (0fe89317…).

Verification

  • uv run --frozen --all-extras python -m pytest -n 8 --dist worksteal -q tests: 21,624 passed, 1 failed. The failure is web_extract/test_model_comparison.py::test_unreachable_connection…, which is flaky and passes alone.
  • make lint-check: pass.
  • uv run --frozen lexbench-webfetch version: scoring hash unchanged.

Closes #333
Part of #328
Part of #322
Part of #332

@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 · 2d5c127

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

retry_html=('<details><summary>'+(report_text('zh' if lang == 'zh' else 'en')('earlier_failed_calls', 'Earlier failed calls'))+'</summary><ul>'+''.join(f'<li>#{v["physical_attempt"]} · {v["elapsed_ms"]:,.0f} ms · {esc(v["error_type"])} · {esc(v["error_message"])} · <a href="{esc(v["artifact_path"])}">'+(report_text('zh' if lang == 'zh' else 'en')('raw_response', 'Raw response'))+'</a></li>' for v in retries)+'</ul></details>') if retries else ''
timing_note=('<p class="small muted">'+(report_text('zh' if lang == 'zh' else 'en')('latency_is_from_the_selected_final_crossover', 'Latency is from the selected final crossover round; content and scores are from the original call.'))+' <a href="research/wcxb-full-paired-latency/calls.jsonl">'+(report_text('zh' if lang == 'zh' else 'en')('timing_calls', 'Timing calls'))+'</a></p>') if r.get('latency_source')=='paired_final_round' else ''
panels.append(f'<section class="panel" id="{p}"><h2>{esc(p)} · F1 {fmt(r["f1"])}</h2><p><span class="tag">{esc(diag(lang,"excluded" if case in exclusion_ids else r["diagnosis"]))}</span> · {r["total_elapsed_ms"]:,.0f} ms · {r["physical_attempt_count"]} calls · {esc(r["attempt_id"])}</p>'+timing_note+f'<p>{esc(x["missing"])}: {esc(missing)}</p><p>{esc(x["extra"])}: {esc(extra)}</p>'+snippet_detail+(f'<p class="bad">{esc(x["error"])}: {esc(r["error_type"])}{(" · HTTP "+str(r["status_code"])) if r.get("status_code") else ""}{(" · "+esc(r["error_message"])) if r["error_message"] else ""}</p>' if r['error_type'] else '')+retry_html+f'''<details data-output><summary>{esc(x['output'])} · {r['output_chars']:,} characters</summary><p><a href="{evidence_path}">{report_text('zh' if lang == 'zh' else 'en')('complete_evidence_json', 'Complete evidence JSON')} ↓</a></p><pre data-src="{evidence_path}" data-provider="{p}"></pre></details></section>''')
qualification=(f"""<p class="callout">{report_text('zh' if lang == 'zh' else 'en')('this_reference_was_excluded_before_calls_official', 'This reference was excluded before calls; official raw scores and outputs remain visible, but it does not enter the main quality mean.')} {esc(exclusion_ids[case])}</p>""" if case in exclusion_ids else '')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maintainability · low
Non-blocking: the early continue for excluded cases makes this notice unreachable, so qualification is always empty. The later diagnosis expression's "excluded" branch is likewise unreachable. Remove those dead branches and the empty interpolation while preserving the existing exclusion policy.

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.

Acknowledged (low, non-blocking). This code moved unchanged from report.py; left as is to keep the WCXB page set byte-identical in this refactor.

):
parser.add_argument("--" + name, type=Path, required=True)
args = parser.parse_args(argv)
declared = declared_correction(args.correction)

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 campaign rules are now an external dependency, but certification still freezes and hashes only this Python file (bind_certifier_source). The certificate does not retain or hash the selected declaration, and application reloads it from the current registry. Editing an existing declaration can therefore change how a saved certificate is interpreted without changing its recorded certifier-source hash; the archived Python source is also insufficient to recover the rules used during certification. Retain and hash the selected declaration in new certificates and verify that binding when applying them, while explicitly preserving compatibility with historical certificates.

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.

Fixed in cdc3484: new certificates retain the selected declaration (correction_declaration); applying a certificate rejects a changed declaration; historical certificates without it still apply. Regression test added.

records: list[dict] | None = None, *,
authority_root: Path | None = None, profile_path: Path | None = None) -> None:
root = open_report(root)
check_recorded_template(root)

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
This new check ignores both authority_root and the authority selected by profile_path, so template validation reads configs/report-templates.json and validates its referenced files against the installed/default repository while the rest of this checker uses the caller's authority tree. A report checked with an explicit authority can therefore fail against an unrelated checkout (or be validated against the wrong template). Move this call after repo is resolved and pass authority_root=repo, as the full-report checker does.

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.

Fixed in cdc3484: the recorded variant is now the checkout-independent template identity (base, track and variant versions) and is checked against the template registry in code, so no authority tree is read.

Comment on lines +532 to +534
core_note+=' '+h('timing_corrections_use_preselected_round_physical_calls', 'Timing corrections use preselected round {formal_round}; physical calls and correction receipts remain available.', formal_round=formal_round) if latency_corrected else ''
core_note+=' '+h('timing_corrections_use_preselected_round_physical_calls', 'Timing corrections use preselected round {formal_round}; physical calls and correction receipts remain available.', formal_round=formal_round) if latency_corrected else ''
core_note+=' '+h('timing_corrections_use_preselected_round_physical_calls', 'Timing corrections use preselected round {formal_round}; physical calls and correction receipts remain available.', formal_round=formal_round) if latency_corrected else ''

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 · low
For a report with latency corrections, these three identical appends repeat the same sentence three times in the home-page core-results note (in both languages). Keep just one append.

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.

Fixed in cdc3484: the repeated append is removed.

…tency declarations in certificates, drop a repeated timing note

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

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

repro=f'''<div class="hero"><h1>{esc(x['repro'])}</h1><p>{report_text('zh' if lang == 'zh' else 'en')('versions_and_source_are_bound_by_this', 'Versions and source are bound by this cohort certificate.')}</p></div><section class="panel"><p>WCXB v1.0 test · {case_count} × {len(providers)} · SHA-256 <code>{summary['source_sha256']}</code></p><p>{esc(x['source'])}: <a href="{source_repository}/tree/{source_commit}">GitHub {source_commit[:7]}</a> · <a href="sample-manifest.json">{report_text('zh' if lang == 'zh' else 'en')('full_test_manifest', 'Full test manifest')}</a> · <a href="certification.json">certification.json</a> · <a href="wcxb-score-summary.json">score summary JSON</a></p><div class="scroll"><table><thead><tr><th>{esc(x['provider'])}</th><th>{esc(x['version'])}</th><th>{report_text('zh' if lang == 'zh' else 'en')('route', 'Route')}</th><th>SHA-256</th></tr></thead><tbody>{versions}</tbody></table></div><pre>uv run --frozen python scripts/run_certified_benchmark.py --benchmark wcxb --dataset &lt;WCXB source&gt; --sample-manifest evaluation/public-wcxb-test-qualified.json --output-root &lt;new evidence dir&gt; --env-file .env\nuv run --frozen python -m harness.web_fetch score --benchmark wcxb --source &lt;WCXB source&gt; --sample-manifest evaluation/public-wcxb-test-qualified.json --evidence-root &lt;certified evidence dir&gt;\nuv run --frozen python scripts/build_report.py --profile &lt;WCXB report profile&gt; --evidence &lt;certified evidence dir&gt; --wcxb-source &lt;WCXB source&gt; --output reports/wcxb</pre><p class="small muted">{esc(x['no_review'])}</p></section>'''
page(lang,'reproduce/index.html',x['repro'],repro)
for case,group in sorted(by_case.items()):
if case in exclusion_ids:continue

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maintainability · low
This skip makes the excluded-reference qualification callout and the "excluded" if case in exclusion_ids diagnosis below unreachable. Since the current scoring contract rejects cohorts with exclusions, remove those dead detail-page branches so the renderer does not imply that it displays excluded-reference evidence.

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.

Low/maintainability, same as the earlier note: this branch moved unchanged from report.py and is kept so the WCXB page set stays byte-identical in this refactor; not blocking.

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.

One publisher interface over the publication lifecycles

1 participant