Skip to content

Report template contract with Web Search as the first track template - #366

Merged
lanyue-llk merged 2 commits into
mainfrom
refactor/reports
Nov 24, 2026
Merged

lanyue-llk merged 2 commits into
mainfrom
refactor/reports

Conversation

@lanyue-llk

Copy link
Copy Markdown
Contributor

Purpose

Define the report template contract from docs/spec.md "Report templates" and prove it on Web Search, the track with the cheapest staged report model. Other tracks (Web Fetch, Web Extract, Browser Use, Trajectory Replay) port onto the same API next.

New structure

flowchart TB
    subgraph Shared["src/harness/reporting/"]
        BT["templates.py<br/>PAGE_ROLES (8 roles, ordered slots)<br/>CONTENT_SLOTS · Page · Variant · TrackTemplate<br/>SectionHook · compose() · check_page() · recorded_variant()"]
        SH["shell.py<br/>page shell · navigation · footer · theme/language links<br/>table · cells · numeric_cell/winners · evidence_link/dialog"]
        LC["locales.py<br/>translate · catalog_text · source_text (one catalog API)"]
    end
    subgraph Search["src/harness/web_search/"]
        TT["template.py<br/>TrackTemplate web-search/1<br/>variants: standard, comparison · HOOK_POINTS"]
        BM["benchmarks.py<br/>SearchBenchmark.views() → SectionHook<br/>metric_kinds · AnswerGrading.explains"]
        BV["benchmark_views.py<br/>factual evidence panel · level charts<br/>MetricKind: factual, target page, site"]
        RP["report.py<br/>page writers return slot fills"]
    end
    BT -- "roles/slots" --> TT
    TT --> RP
    BM -- "views() hooks, metric kinds" --> RP
    BV --> BM
    SH --> RP
    LC --> RP
    RP --> OUT["report: main[data-page-role] + div[data-slot]<br/>manifest.template = base, track, variant + versions"]
    OUT --> CK["check(): recorded_variant + check_page per variant page"]
Loading

What changed

Base template (reporting/templates.py) — page roles home, datasets, methodology, results, interpretation, review, reproduce, changes, each with ordered slots; authored content is allowed only in content slots (lead, summary, findings, notes, history). A Variant must fill or declare absent every role and cannot add one; compose() renders slots in base order and refuses unknown slots; check_page() verifies a page's role, slot order and that authored nodes sit in content slots. TrackTemplate.record() is what the manifest stores; recorded_variant() refuses a different base/track/variant version. SectionHook is the type BenchmarkAdapter.views() returns (added to the protocol; Web Fetch adapters return []).

Shell and catalog — reporting/shell.py holds the page skeleton plus navigation, footer, table, cells, directional highlight cells (numeric_cell/numeric_winners) and evidence link/dialog components, moved out of Search. reporting/locales.py gains source_text() (English source text as key, context|source disambiguation); Search's messages.py is now two thin bindings over it.

Web Search on the template — web_search/template.py replaces pages.py: two registered variants (standard, comparison, selected by authored presentation) mapping every route to a role; configs/report-templates.json lists the same variant names (a test keeps them equal). Every page writer now returns slot fills. With no authored content the build fills every role from data: new generated Review (states no review is recorded), Reproduce (profile counts + documented commands) and Changes (current build only; authored changes section when bound) pages. Footer links come from variant data (pages with nav=False) instead of a presentation branch.

#323 remaining items — via benchmark declarations, not dataset names:

  • comparison.py: factual-only level charts → the factual benchmark's level-findings hook; the factual population-size note → a loop over declared benchmarks; the /scenario judgment key → benchmark_of(case).name plus AnswerGrading.explains.
  • report.py: the factual evidence panel (with the SimpleQA contamination paragraph) → the factual benchmark's evidence-panel hook; scenario/site/factual population summaries and directed-discovery checks → MetricKind declarations registered on the benchmarks (metric_kinds); population validation → MetricKind.validate.

Removed: web_search/pages.py, Search's private table, cells, numeric_cell, numeric_winners, the inline page shell and footer construction in _write_page, the presentation == "comparison-report" branches for footer, language link and notice.

Allowlists

Instance-literal allowlist: 1 → 1 entry (harness.reporting.visual, untouched). Layering allowlist: 0 → 0. The new shared modules name no instance.

Baselines

tests/baselines/web-search.json and web-search-comparison.json changed in presentation structure only. Scored records are identical, and every existing page keeps identical h1–h3 headings and table cells. Route digests changed because:

  • every page's <main> now carries data-page-role and its body sections are wrapped in <div data-slot="…"> in base-template order;
  • navigation lists the new pages; comparison pages get a footer for Method/FAQ, Review, Reproduce and Changes; a Chinese-only comparison build now links to the English not-generated notice, as standard builds already did;
  • new routes review.html, reproduce.html, changes.html (and en/ copies) are the generated defaults for roles Search did not fill;
  • manifest.json records template = {track, renderer, entrypoint, base, base_version, track_template, track_version, variant, variant_version}.

Authored sections on the default home now sit in the summary slot after the generated core comparison, and the dataset page's authored section leads the page; neither baseline example binds those sections.

Breaking changes

  • Web Search reports built before this change fail check/--release-check ("Report manifest does not record its template; rebuild it"). No Search report is bound by a current authority in Git; rebuild from the saved run directory.
  • The Search visual receipt now captures three more route classes per language (review, reproduce, changes), and its producer binding names harness/web_search/template.py instead of pages.py.
  • configs/report-templates.json Search variants are now standard, comparison (the template's registered variants).

Verification

  • uv run --frozen --all-extras python -m pytest tests/web_search tests/baselines tests/test_report_template_contract.py tests/test_report_locales.py tests/test_adapters.py tests/test_web_fetch_benchmarks.py -n 8 --dist worksteal — passed
  • uv run --frozen --all-extras python -m pytest tests -n 8 --dist worksteal — 23788 passed, 1 failed (tests/test_moli_provider.py::...test_cancel_permission_error_preserves_timeout_and_unresolved_worker, a load-sensitive timing test that passes alone and is unrelated); Search, baselines and architecture tests rerun after rebasing on main: passed
  • Negative controls: tests/test_report_template_contract.py (role coverage, unknown slot, slot order, authored content outside a content slot, version drift) and tests/web_search/test_report.py::test_release_check_rejects_pages_that_leave_their_template (reordered slots, wrong role, variant/version drift in the manifest, missing route).
  • make lint-check — passed. Scoring sources in src/lexbench_* untouched.

Closes #323
Part of #337, #331

…ext catalog

Define the page roles, ordered slots and content slots every report fills;
track templates register variants as data, benchmarks contribute
SectionHook views, and check_page/recorded_variant let a release gate
compare built pages with the recorded template. Move the shared page
shell, table, highlight and evidence-link components into reporting/shell.py
and add source_text to the one catalog API in reporting/locales.py.
Search becomes a track template with standard and comparison variants;
page writers return slot fills, the report records its template in the
manifest and check() verifies roles and section order. Review, Reproduce
and Changes render generated defaults without authored content.

Benchmark declarations now own the factual evidence panel, level charts,
population metric kinds, answer-judgment display and population notes, so
comparison and report code no longer name a dataset (#323).

@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 · 81a5acd

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.

Web Search: move provider quirks into adapters and dataset rules into declarations

1 participant