Model/domain/sap10_ml/tests
Khalim Conn-Kowlessar aab75cf902 fix(walls): reconcile gov-API wall_construction enum with the calc code-space
The gov-EPC API `wall_construction` enum diverges from the calculator's
internal WALL_* code-space (confirmed by the description-vs-code audit across
the corpus): API 1-5 align (granite/sandstone/solid-brick/cavity/timber), but
API 6=basement, 8=system built, 9=cob — whereas the calc constants are
WALL_SYSTEM_BUILT=6, WALL_COB=7, WALL_PARK_HOME=8, WALL_CURTAIN=9. Codes 8 and
9 therefore fell OUT of u_wall's `known_types` and resolved only via the
`walls[].description` fallback, with two failure modes:

  - System built (API 8): a cert lodging no description silently defaulted to
    cavity (1.5) instead of the system-built U (RdSAP 10 Table 6, e.g. band E
    as-built 1.7). Latent in the corpus (all 43 carry a description) but a
    silent mis-bill waiting to happen.
  - Cob (API 9): a LIVE bug — calc WALL_CURTAIN=9 (set by the Summary path's
    "CW" mapping, paired with a curtain_wall_age) intercepts code 9 in the
    `construction == WALL_CURTAIN` branch, billing the cob wall at the curtain
    default 2.0 regardless of description.

Fix, split by where each can be disambiguated safely:
  - System built: `u_wall` gains `_GOV_API_WALL_CODE_TO_TYPE = {8: WALL_
    SYSTEM_BUILT}`, resolving code 8 directly (calc WALL_PARK_HOME=8 is never
    dispatched, so no collision; gov 6=basement is left to the basement
    machinery — cannot remap 8→6).
  - Cob: translated at the API mapper (`_api_wall_construction_code`, 9 →
    WALL_COB=7) where the source is unambiguously the gov enum — the gov API
    has no curtain code, so an API 9 is always cob. Applied to main + alt
    walls across the from_rdsap_schema_* builders. The Summary path's "CW"→9
    curtain mapping is untouched.

Worksheet harness UNAFFECTED (47/47, 0 divergers — Summary path unchanged).
API gauge 65.1% -> 65.3% within-0.5 (mean|err| 1.075 -> 1.059): the n=1 cob
cert now computes cob instead of curtain. 3 AAA tests (u_wall system-built
without description; mapper cob 9->7; aligned/system/basement pass-through).
pyright net-zero.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-11 10:55:19 +00:00
..
__init__.py refactor: lift-and-shift packages/domain/src/domain/ml → domain/sap10_ml 2026-05-26 13:01:35 +00:00
_fixtures.py fix(water-heating): complete RdSAP Table 28 cylinder-size map (codes 5 + 6) 2026-06-11 10:02:39 +00:00
test_demand.py refactor: lift-and-shift packages/domain/src/domain/ml → domain/sap10_ml 2026-05-26 13:01:35 +00:00
test_ecf.py refactor: lift-and-shift packages/domain/src/domain/ml → domain/sap10_ml 2026-05-26 13:01:35 +00:00
test_envelope.py refactor: lift-and-shift packages/domain/src/domain/ml → domain/sap10_ml 2026-05-26 13:01:35 +00:00
test_rdsap_uvalues.py fix(walls): reconcile gov-API wall_construction enum with the calc code-space 2026-06-11 10:55:19 +00:00
test_sap_efficiencies.py test(efficiency): lock solid-fuel room-heater space eff to Table 4a column (B) 2026-06-10 11:09:12 +00:00
test_transform.py refactor: lift-and-shift packages/domain/src/domain/ml → domain/sap10_ml 2026-05-26 13:01:35 +00:00
test_ventilation.py refactor: lift-and-shift packages/domain/src/domain/ml → domain/sap10_ml 2026-05-26 13:01:35 +00:00