Model/datatypes
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
..
epc Slice 90: API mapper translates party_wall_construction → SAP10 enum 2026-05-25 21:21:52 +00:00
magicplan typing and renaming 🟪 2026-05-07 13:26:49 +00:00
__init__.py further breaking up code 2023-07-20 12:24:34 +01:00
datatypes.py further breaking up code 2023-07-20 12:24:34 +01:00
enums.py completed build of new demo portfolio - some fixed required still 2023-11-20 14:42:16 +00:00