Skip to content

Web Extract report variants on the shared report template - #370

Merged
lanyue-llk merged 3 commits into
mainfrom
refactor/extract-report
Nov 24, 2026
Merged

lanyue-llk merged 3 commits into
mainfrom
refactor/extract-report

Conversation

@lanyue-llk

Copy link
Copy Markdown
Contributor

Purpose

Port Web Extract's report onto the shared report template (#337, #331) and remove the product field names from shared Extract report and analysis code (#324).

flowchart TB
    T["reporting/templates.py<br/>roles · slots · Variant(options) · check_page"] --> ET["web_extract/template.py<br/>TrackTemplate web-extract/1<br/>product · product-progress · record-cohort · suite"]
    ET --> P["report.page()<br/>one shell: role, body slot, intro slot,<br/>notice and navigation from variant options"]
    PF["web_extract/product_fields.py<br/>DECLARED · REPORTED · REPORTED_DERIVED · NUMERIC<br/>(from the fixed-field benchmark adapter)"] --> R["report.py / analysis.py"]
    R --> P
    P --> M["manifest.template = owner + base/track/variant versions"]
    M --> C["check_template_pages(): recorded variant + check_page per page"]
Loading

What changed

  • Track template (web_extract/template.py): the four report modes are registered variants (product, product-progress, record-cohort, suite). The variant's options now decide what were mode branches in page(): which slot holds the authored intro (lead, or summary after the home comparison), the evidence-state notice and results label, and the suite's external navigation and root-relative links. configs/report-templates.json lists the same variant names, and a test keeps the two equal. The base Variant gains a generic options mapping.
  • One shell, slotted pages: page() gives <main> its data-page-role and places the body and intro into the slots of that role. Intro placement is checked through the slots (intro_is_correctly_placed, INTRO_SELECTOR). Manifests (product, record cohort and suite) record {track, renderer, entrypoint, base, base_version, track_template, track_version, variant, variant_version}. check_template_pages() verifies the recorded variant and every page's role and slot order. It runs in the reader contract and in the suite check, with negative controls in tests/web_extract/test_report_template.py.
  • Builds from data alone: report --content is now optional. The product shape renders from --run and the profile. With no bound prices, the price tables say no price contract is bound, and a release check refuses such a report. Declaring prices for only some participants is still refused at build time.
  • Product field names come from web_extract/product_fields.py, which derives them from the fixed-field benchmark adapter (DECLARED, REPORTED, REPORTED_DERIVED, NUMERIC from the schema). report.py and analysis.py no longer spell out price/sku/availability/OutOfStock; labels come from catalog keys built from the field name. These declarations sit beside dataset.py because dataset.py's bytes are bound into frozen cohort plans through dataset_registry_sha256.
  • Extract's catalog already went through reporting/locales.translate. The only new key is price_not_declared.

Allowlists

Instance-literal: 1 → 1. Layering: 0 → 0.

Baselines

All four Extract baselines keep identical scored evidence and identical page headings and tables. Only the route digests changed, for reader pages and manifests: <main data-page-role>, the <div data-slot> wrappers, and the template record in the manifest.

Breaking changes

  • Extract reports built before this change fail check ("does not record its template"). Rebuild them from their evidence.
  • configs/report-templates.json web-extract variants are now product, product-progress, record-cohort, suite. Its build example uses --run and no longer --content.

Not done (remaining for #324)

  • The product and record-cohort data assembly is still two bodies (_build_product, build_record_cohort). They now share the shell, slots, intro placement and template checks, but each still loads and projects its evidence differently. Merging them needs a common evidence model, which is a separate change.
  • analysis.py still imports swde.record_value_key. Moving it would change swde.py, whose bytes are bound into cohorts as adapter_sha256.
  • Extract does not yet fill the reproduce and changes roles; the variants declare them absent. Authored page bodies still share the generated body slot. Record cohorts still require content, because it declares their participants and prices.

Verification

  • uv run --frozen --all-extras python -m pytest tests/web_extract tests/baselines tests/test_report_templates.py tests/test_report_template_contract.py tests/test_architecture_*.py -n 8 --dist worksteal: passed
  • make lint-check: passed. Scoring sources are untouched.

Part of #337, #331, #324

@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 · 6357b0a

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

Comment thread src/harness/web_extract/report.py Outdated
return document.main.find(True, recursive=False) is slot
core = slot.find_previous_sibling()
return (core is not None and core.get("data-slot") == "core-comparison"
and core.find_all(True, recursive=False)[-1] is home_comparison_end(core))

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
An empty core-comparison wrapper makes this index raise IndexError instead of returning False and producing the intended intro-placement validation error. check_page() checks slot names/order but does not reject empty slots, and verify_page_intros() also calls this function directly. Guard the direct-child list before accessing its last element; add a negative test with an empty core slot followed by an intact summary intro.

Comment thread src/harness/web_extract/template.py Outdated
"field-extraction-cohort": "record-cohort",
"field-extraction-suite": "suite",
}
READER_ROUTES = tuple(key for key, _, _ in _READER_PAGES)

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: READER_ROUTES is never referenced anywhere in the repository; report generation and validation still use their existing route inventories. Remove this unused declaration, or use it as the shared route inventory if that was its intended purpose.

Comment thread src/harness/web_extract/template.py Outdated

def intro_slot(route, mode):
"""The slot that holds a page's authored introduction in this variant."""
return variant_for_mode(mode).options["intro_slots"].get(route, "lead")

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 default lead slot is not valid for the review role, whose only slots are summary and notes. An authored pages.review.intro is accepted by authored_intro() and passed to page(), but now causes compose() to raise ValueError: Page role review has no slot lead. Provide a supported intro/body slot arrangement for review pages (and update placement validation accordingly) so previously supported review introductions still render.

@lanyue-llk
lanyue-llk force-pushed the refactor/extract-report branch from 6357b0a to 1800f27 Compare November 24, 2026 13:11
@lanyue-llk

Copy link
Copy Markdown
Contributor Author

OCR findings addressed in the latest head: (1) intro_is_correctly_placed guards an empty core-comparison slot and returns False (negative test added); (2) unused READER_ROUTES removed; (3) review pages place an authored intro in the role's first content slot (summary) before the generated body (notes), with a test. Baselines: only the review page digests changed (body slot).

@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 · 1800f27

No findings in this review.

…track template

Extract's page shell now fills base-template roles and slots; the product,
progress, record-cohort and suite shapes are registered variants whose
options (intro slot, evidence-state notice, external navigation) replace
mode branches. Manifests record the template and checks verify each page's
role and slot order. Product reports build from the run alone: content is
optional and an unbound price contract renders as declared-absent until a
release requires prices.
@lanyue-llk
lanyue-llk force-pushed the refactor/extract-report branch from 1800f27 to 783556a Compare November 24, 2026 13:27

@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 · 783556a

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.

1 participant