mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
Three tightly-coupled fixes that close another big chunk of cert
001479's API-path SAP gap.
(1) Surface human-readable strings on SapBuildingPart from API ints
The API mapper sets `bp.floor_construction_type` and `bp.roof_
construction_type` strings via int→string lookups so the cascade
fixes from Slices 88 + 89 also apply to the API path:
- `_API_FLOOR_CONSTRUCTION_TO_STR`: 1=Solid, 2=Suspended timber
(drives `u_floor`'s suspended-branch selection)
- `_API_ROOF_CONSTRUCTION_TO_STR`: 1=Flat, 3=Pitched no-loft,
4=Pitched-access-to-loft, 5=Vaulted, 8=Pitched-sloping-ceiling
(drives the cos(30°) inclined-surface factor)
(2) Pre-1950 PS sloping ceiling → thickness=0 (port Slice 57)
`_api_resolve_sloping_ceiling_thickness` mirrors Slice 57's Elmhurst-
mapper logic: when a PS pitched-sloping-ceiling roof (API code 8)
carries no insulation thickness on a pre-1950 dwelling (age bands
A-D), set thickness=0 so the cascade returns the uninsulated U=2.30
rather than the age-band-default (e.g. U=0.40 for age C).
(3) Cascade: per-bp `roof_thickness=0` overrides global "insulated"
description
For cert 001479 the API's `epc.roofs` carries two descriptions
(Main's "Pitched, 300mm loft insulation" + Ext1's "Pitched,
insulated") which the cascade joined into a global
`roof_description`. `u_roof`'s Table 18 footnote (2) ("assumed
insulation if described as insulated") then incorrectly upgraded
Ext2's explicitly-uninsulated thickness=0 to ins_mm=50 → U=0.68
instead of 2.30. Fix: in `heat_transmission.py` per-bp roof loop,
drop `roof_description` when the per-bp `roof_thickness` is
explicitly 0. The per-bp thickness lodgement is the authoritative
signal; the global description is for cases where no thickness was
lodged at all.
Impact on cert 001479 API path (cumulative through Slice 91):
Before Slice 87: +3.0752 SAP delta
After Slice 90: +1.5298 (party wall enum fix)
After Slice 91: +1.0970 (descriptive strings + roof desc fix)
Roof W/K is now EXACT for cert 001479 (10.3438 = worksheet target).
Golden cert residual updates: 8 of 10 expectations shifted by
Slices 87-91 cascade improvements:
0240: SAP -10→-13, PE -2.05→+10.45, CO2 -0.04→+0.59
6035: SAP -4→ -5, PE +34.02→+34.50, CO2 +0.76→+0.77
7536: SAP +3→ +2, PE -22.53→-15.83, CO2 -0.60→-0.42
8135: SAP unchanged, PE -16.51→-16.37, CO2 unchanged
2130: SAP unchanged, PE -51.90→-51.10, CO2 +0.14→+0.15
0240/6035/7536: spec-compliance shifts (more accurate U-values
move further from the assessor's lodged SAP, because the
assessor's SAP was itself produced with the same incorrect
paths the cascade previously matched).
Pyright: mapper.py 33 → 33; heat_transmission.py 13 → 13;
test_golden_fixtures.py 0 → 0.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| domain | ||
| fetchers | ||
| repos | ||
| utils | ||
| README.md | ||
Shared packages
Workspace packages consumed by services/*. Each package is its own Python distribution with its own pyproject.toml; services import via the workspace dependency mechanism ({ workspace = true }).
| Package | Purpose |
|---|---|
domain/ |
Shared domain types — Property, BaselinePerformance, Plan, Scenario, EpcPropertyData, etc. No persistence, no IO, no business logic. |
repos/ |
Persistence layer — one repo per aggregate. Owns the SQL. Depends on domain. |
fetchers/ |
External API clients (gov EPC, Ofgem, Google Solar, etc.). Depend on domain for response shapes. |
utils/ |
Cross-cutting infra — logging, S3, CloudWatch URL builders, SQS task helpers. |
Adding a new shared package
Only when a real second consumer materialises. Don't pre-shatter (repos-epc, repos-property, ...) — split when a deployment needs to drop a dep, not before.
See ../ara_backend_design.md §11 for the broader monorepo layout and ../CONTEXT.md for the domain glossary that names the types living in domain/.