Model/backend/documents_parser
Khalim Conn-Kowlessar 3e05881042 Slice S0380.58: Elmhurst per-extension Room(s) in Roof extraction + TFA fix
Cert 000565 surfaced a per-extension Room(s) in Roof coverage gap.
§4 Dimensions lodges an RR floor area for every BP (Main + each
extension) and §8.1 lodges full construction details per BP. The
old extractor parsed RR from §4 + §8.1 for Main only — the 4
extensions' RR areas (34 + 5 + 32 + 2 = 73 m²) were silently
dropped, leaving TFA at 246.91 m² vs the worksheet's 319.91 m²
(23% deficit).

Schema:
- `ExtensionPart.room_in_roof: Optional[RoomInRoof] = None` field.
  None for single-storey extensions (no RR lodged); populated for
  every extension that lodges a §4 RR floor area > 0.

Extractor:
- `_room_in_roof_from_bodies(dim_body, rir_body, age_band)`
  parameterises the previously Main-only `_extract_room_in_roof`
  so the same parsing applies to each extension.
- `_extract_extensions` now slices §8.1 by BP (alongside the
  existing §4/§7/§8/§9 slicing) and reads each extension's RR age
  band from §3's "<N>th Ext. Room(s) in Roof <band>" line via a
  new regex.
- A new defensive "§4 lodges RR area but §8.1 has no construction
  details" branch returns a partial `RoomInRoof` with empty surfaces
  so the cascade still attributes the floor area to TFA. (Not
  triggered on 000565 — all 5 BPs lodge construction details — but
  needed for older Elmhurst variants per the existing extractor
  comment style.)

Mapper:
- `_map_elmhurst_building_parts` now passes each extension's
  `room_in_roof` through `_map_elmhurst_room_in_roof` to the
  extension's `SapBuildingPart.sap_room_in_roof`. Previously the
  loop hardcoded the field as None.
- `total_floor_area_m2` derivation now also sums each extension's
  `room_in_roof.floor_area_m2`. Without this, the per-BP RR floor
  area is lodged on the BP but the cert's top-level TFA stays at
  the pre-fix value.

Cert 000565 cascade impact:
- TFA: 246.91 → 319.91 ✓ (matches U985-0001-000565.pdf Block 1)
- space_heating_kwh_per_yr:  Δ −9,107.71 → −1,099.50  (88% reduction)
- main_heating_fuel_kwh_per_yr: Δ −5,357.47 → −646.76  (88% reduction;
    space_heating × 1/HP COP — main_heating tracks space_heating)
- lighting_kwh_per_yr:       Δ −236.19 → +2.18  (essentially closed —
    RdSAP §12-1 lighting is TFA-proportional)
- hot_water_kwh_per_yr:      Δ +214.50 → +271.84
- co2_kg_per_yr:             Δ −1,438.16 → −751.06
- total_fuel_cost_gbp:       Δ −1,055.62 → −564.05
- sap_score_continuous:      Δ +1.70 → +6.75  (cost/TFA dropped because
    cost rose ~14% but TFA rose ~30% — the remaining −564 cost gap
    has to close before SAP catches up)

Single-storey-extension certs: `room_in_roof=None` for each extension
(no §4 RR lodgement), no behavioural change. Cohort regression check:
415 pass + 10 expected 000565 fails — no regression on the 14 Summary
fixtures + JSON fixtures that don't carry per-extension RR.

Pyright net-zero on all 3 touched files (32 / 0 / 0).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-28 22:58:43 +00:00
..
handler address JTK review comments 2026-04-20 15:11:17 +00:00
tests Slice S0380.52: cert 000565 Elmhurst-only mapper-driven cascade pin + glazing-label coverage 2026-05-28 22:03:52 +00:00
__init__.py Map to RdSapSiteNotes from site notes JSON 🟥 2026-04-16 13:54:03 +00:00
db_writer.py include updating epc_property_data to pashub to ara workflow 2026-04-29 09:55:14 +00:00
elmhurst_extractor.py Slice S0380.58: Elmhurst per-extension Room(s) in Roof extraction + TFA fix 2026-05-28 22:58:43 +00:00
extractor.py Handle wall thickness "Unmeasurable" 🟩 2026-04-30 16:41:16 +00:00
local_runner.py update local runner to work for elmhurst 2026-04-24 14:01:36 +00:00
parser.py load ecmk site notes to db 2026-04-29 11:20:47 +00:00
pdf.py update local runner to work for elmhurst 2026-04-24 14:01:36 +00:00