Model/backend/documents_parser/tests
Khalim Conn-Kowlessar 37c1635c9d Slice S0380.129: heating-systems corpus residual-pin regression guard
The 001431 corpus at `sap worksheets/heating systems examples/` now
has a permanent test module pinning cascade-vs-worksheet residuals
across all 41 populated heating-system variants. The corpus is a
controlled-variable test set — same dwelling (semi-detached, TFA 90 m²,
age G, W6 9BF, Elmhurst P960 worksheet format) under different heating
configurations — so every cascade-vs-worksheet residual is fully
attributable to the heating subsystem.

`test_heating_systems_corpus_residual_matches_pin` is parametrised by
variant folder name. Per variant it:

  1. Extracts Block 11a (individual) or Block 11b (community) pins
     from the P960 PDF — continuous SAP (`SAP value` row), total fuel
     cost (255)/(355), CO2 (272/372/382/383), PE (286/386/486/483).
  2. Routes the Summary PDF through ElmhurstSiteNotesExtractor →
     EpcPropertyDataMapper.from_elmhurst_site_notes → cert_to_inputs
     → calculate_sap_from_inputs.
  3. Asserts each of the four cascade outputs sits within an absolute
     tolerance of the pinned residual.

Tolerances are tight (SAP ±0.001, cost ±£0.01, CO2 ±0.1 kg/yr, PE
±0.1 kWh/yr) — the *expected residual* moves toward 0 as heating-
cascade gaps close; the *tolerance* never widens. Per
[[feedback-zero-error-strict]] + [[feedback-golden-residuals-near-zero]].

Pins captured at HEAD `729ee29c` (post-S0380.128). All 41 pass.
Smallest residual: `solid fuel 8` +0.87 SAP / −£20 cost (closest to
closure). First negative ΔSAP: `community heating 6` −6.87 SAP / +£158
cost (heat-pump heat network — only variant where cascade UNDERshoots
the worksheet).

Extended handover suite at HEAD post-slice: **873 pass, 0 fail**
(was 832 + 41 new parametrised cases).

Pyright net-zero on new file (0 → 0).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-01 16:28:48 +00:00
..
fixtures Slice S0380.52: cert 000565 Elmhurst-only mapper-driven cascade pin + glazing-label coverage 2026-06-01 16:28:47 +00:00
__init__.py Map to RdSapSiteNotes from site notes JSON 🟥 2026-04-16 13:54:03 +00:00
test_elmhurst_end_to_end.py Slice S0380.17: map Elmhurst §11 glazing-type labels to SAP10 codes 2026-06-01 16:28:46 +00:00
test_elmhurst_extractor.py extract window frame details from elmhurst site notes 🟥 2026-04-27 15:50:25 +00:00
test_end_to_end.py P6.1 follow-on: unbox BuildingPartIdentifier at backend boundaries 2026-05-20 09:58:23 +00:00
test_extractor.py Handle wall thickness "Unmeasurable" 🟩 2026-04-30 16:41:16 +00:00
test_heating_systems_corpus.py Slice S0380.129: heating-systems corpus residual-pin regression guard 2026-06-01 16:28:48 +00:00
test_pdf.py rename example site notes to PasHub_ and add Elmhurst example 2026-04-24 13:01:51 +00:00
test_summary_pdf_mapper_chain.py Slice S0380.128: extractor §14.0 closure falls back to "14.1 Community Heating" 2026-06-01 16:28:48 +00:00