Model/datatypes/epc
Khalim Conn-Kowlessar fbbdca49ca Slice 90: API mapper translates party_wall_construction → SAP10 enum
The GOV.UK API `party_wall_construction` field uses a different enum
from the regular `wall_construction` field — RdSAP 10 Table 15 (p.31
"U-values of party walls") defines 5 categories that the API encodes
as integer codes 0..5 plus a "NA" string for extensions without a
party wall. The cascade's `u_party_wall` consumes the SAP10
`wall_construction` enum directly, so passing the raw API code gave
wildly wrong U-values (API code 2 = "Cavity masonry unfilled" →
should produce U=0.5, but cascade interpreted code 2 as SAP10
WALL_STONE_SANDSTONE → 0.0 W/m²K).

Impact on cert 001479 (the only golden fixture with party=2 lodged):

  Before: party_walls = 0.00 W/K (cascade applied U=0.0)
  After:  party_walls = 16.21 W/K (cascade applies U=0.5)

  API mapper → cascade SAP delta:
  Before Slice 90: +3.0752
  After  Slice 90: +1.5298

The remaining party-wall shortfall (16.21 vs target 17.07 W/K, -0.87
W/K) is the room_height_m +0.25 SAP convention not yet applied to
the API path — Slice 92 will close that.

Translation table (per `_API_PARTY_WALL_CONSTRUCTION_TO_SAP10`):
  0 → None (no party wall present; party_wall_length=0 anyway)
  1 → SAP10 code 3 (Solid Brick) → u_party_wall = 0.0
  2 → SAP10 code 4 (Cavity)      → u_party_wall = 0.5
  3 → SAP10 code 4 (Cavity)      → cascade emits 0.5 (TODO: 0.2 for
                                    cavity filled needs cascade extension)
  4 → None (Unable, house)       → u_party_wall default 0.25
  5 → None (Unable, flat)        → TODO: spec says 0.0 for flats

Schema change: `SapBuildingPart.party_wall_construction` is now
`Optional[Union[int, str]]` (was `Union[int, str]`) — the "0 sentinel
for Unable" convention was already in cohort hand-builts but the type
forbade the cleaner `None` representation. To preserve the dataclass
"no-default after default" rule, `sap_floor_dimensions` gets a
`field(default_factory=list)`.

Translation applied across all 6 from_rdsap_schema_* mappers + the
flagship `from_rdsap_schema_21_0_1` used by 001479.

Pyright: mapper.py 35 → 33 (cleared 7 cohort party_wall type errors
that were pre-existing, balanced against the schema change). Cohort
cascade pins remain GREEN (66 of 66); no new test regression.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-25 21:21:52 +00:00
..
domain Slice 90: API mapper translates party_wall_construction → SAP10 enum 2026-05-25 21:21:52 +00:00
loaders demo generated for use in address2uprn 2026-05-08 14:48:15 +00:00
schema Slice 44: flat_roof_insulation_thickness mapper fix — surface lodged value on SapBuildingPart 2026-05-24 15:28:10 +00:00
search bolstering testing 2026-04-28 13:46:09 +00:00
surveys Slice 53: Summary_000487 chain pins SAP at 1e-4 — last cohort cert closed 2026-05-24 21:42:42 +00:00
__init__.py testing out rebaselining 2026-02-12 22:25:03 +00:00
construction_age_band.py testing out rebaselining 2026-02-12 22:25:03 +00:00
efficiency.py beginning to assembly the parity class 2026-02-04 18:34:59 +00:00
floor.py preparing partiy class 2026-02-05 08:54:27 +00:00
fuel.py beginning to assembly the parity class 2026-02-04 18:34:59 +00:00
heating_controls.py beginning to assembly the parity class 2026-02-04 18:34:59 +00:00
hotwater.py beginning to assembly the parity class 2026-02-04 18:34:59 +00:00
main_heating.py beginning to assembly the parity class 2026-02-04 18:34:59 +00:00
property_type_built_form.py beginning to assembly the parity class 2026-02-04 18:34:59 +00:00
roof.py beginning to assembly the parity class 2026-02-04 18:34:59 +00:00
walls.py beginning to assembly the parity class 2026-02-04 18:34:59 +00:00
windows.py testing out rebaselining 2026-02-12 22:25:03 +00:00