Model/backend/documents_parser/tests
Khalim Conn-Kowlessar e3dc0b28f5 Slice 58: secondary fuel cost routes through lodged secondary_fuel_type
Two coupled bugs surfaced by cert 001479's mains-gas-fire secondary
heating (Summary §14.1 lodges "SAP code 605, Flush fitting live effect
gas fire" → fuel 26 mains gas):

1. **Mapper**: `_map_elmhurst_sap_heating` only set
   `secondary_heating_type` (the SAP code int) — `secondary_fuel_type`
   stayed None. The Summary PDF doesn't lodge the fuel int separately;
   it has to be derived from the SAP code range. Add
   `_elmhurst_secondary_fuel_from_sap_code`: codes 601-630 → 26
   (mains gas); other codes return None (the cascade defaults to
   electric, matching cohort 000490 SAP code 691 electric panel).

2. **Cascade**: `_fuel_cost` in cert_to_inputs hardcoded
   `secondary_high_rate_gbp_per_kwh = other_uses_gbp_per_kwh` (the
   standard-electricity tariff) regardless of `secondary_fuel_type`.
   For gas secondaries this charged 1846 kWh/yr at electric rate
   (£0.132/kWh = £243) instead of gas rate (£0.0348/kWh = £64) —
   a ~£175/yr ECF distortion ≈ 9 SAP points on cert 001479. Route
   the cost through `table_32_unit_price_p_per_kwh(secondary_fuel)`
   when lodged.

Worksheet line (242) confirms the gas pricing:
  `Space heating - secondary  2025.93  3.4800  70.5022`

Cert 001479 chain pin delta narrows: SAP_continuous 61.39 → 70.64
(was −7.62 vs 69.0094, now +1.63 — overshooting target by 1.63 SAP).
The remaining overshoot maps to the cascade's ~16 W/K HLC undercount
(cascade HLP 2.89 vs worksheet 3.13 × TFA) — work for follow-up
slices.

Cohort 6 chain certs still green at 1e-4 (all-electric or no-
secondary). Golden cohort: cert 0300-2747 (mains-gas secondary)
SAP residual tightens −7 → +2 — biggest single SAP improvement on
the golden cohort to date; pin updated and notes annotated. Other
7 golden certs unchanged (None or electric secondary fuel). Pyright
net-zero (35 baseline each on mapper.py + cert_to_inputs.py).

Chain pin `test_summary_001479_full_chain_sap_matches_worksheet_pdf_
exactly` is the load-bearing RED — committed failing per TDD; closes
to GREEN once the HLC undercount lands.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-24 22:54:00 +00:00
..
fixtures Slice 54: Elmhurst mapper sets extensions_count from len(survey.extensions) 2026-05-24 22:15: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 51: Summary_000516 chain pins SAP at 1e-4; roof-window separation 2026-05-24 21:16: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_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 58: secondary fuel cost routes through lodged secondary_fuel_type 2026-05-24 22:54:00 +00:00