Model/backend/documents_parser/tests
Khalim Conn-Kowlessar 9159e91fbc Slice S0380.108: Connected-to-heated-space RR gables deduct from A_RR (RdSAP 10 §3.9.2 + Table 4 row 4)
Closes the largest single localised fabric residual on cert 000565
(roof +1.59 W/K over, area +4.70 m² over) by routing
Connected-gable surfaces through a new `connected_wall` kind that
deducts area from the residual A_RR per the spec but contributes
0 W/K per RdSAP 10 Table 4 row 4.

RdSAP 10 §3.9.2 step (d) (PDF p.23) verbatim:

  "The areas of gable walls are deducted from the calculated total
   RR area, and the remaining area of RR, ARR_final is then
   calculated. This area is treated as roof structure.
       ARR_final = ARR_wall − (ΣARR_common_wall + ΣARR_gable +
                               ΣARR_party + ΣARR_sheltered +
                               ΣARR_connected)"

RdSAP 10 Table 4 row 4 (PDF p.22):

  "ARR_connected — Adjacent to heated space — U-value = 0"

The U=0 means no heat-loss contribution, but the area STILL appears
in the deduction equation as ΣARR_connected. Pre-slice the mapper's
`_map_elmhurst_rir_surface` returned None for Connected gables,
dropping them entirely from `detailed_surfaces` so the cascade
neither billed them nor deducted them. The residual A_RR was
therefore over by their lodged area.

Cert 000565 Ext1 §8.1 lodges (Simplified Type 2):
  Gable Wall 1   L=4.00  H=6.00  Connected  U=0
  Gable Wall 2   L=8.00  H=9.00  Exposed    U=1.70
  Common Wall 1  L=9.00  H=1.00  U=1.70
  Common Wall 2  L=5.00  H=1.80  U=1.70

Gable Wall 1 area via §3.9.2 quadratic:
  A_gable_1 = 4 × (0.25 + 6)
              − (6 − 1)²/2   ← subtract triangle above Common Wall 1
              − (6 − 1.8)²/2 ← subtract triangle above Common Wall 2
            = 25.0 − 12.5 − 8.82
            = 3.68 m²

Pre-slice:
  A_RR shell = 12.5 × √(34 / 1.5) = 59.51 m²
  Σ wall areas = 11.25 + 10.25 + 16.08 = 37.58 m²
  Residual    = 21.93 m² (worksheet: 18.25; over by +3.68)
  Roof W/K = 21.93 × 0.35 = 7.68 (worksheet: 6.39; over by +1.29)

3-layer fix:
1. Mapper `_map_elmhurst_rir_surface` (datatypes/epc/domain/mapper.py)
   now routes "Connected" gable_type to kind="connected_wall" with
   u_value=0 and area via the Simplified Type 2 quadratic correction.
2. Heat transmission `heat_transmission_from_cert` (domain/sap10_
   calculator/worksheet/heat_transmission.py) adds a connected_wall
   branch that deducts area from rr_walls_in_a_rr_area but skips
   walls/party W/K contribution.
3. AAA test pins Ext1 Connected gable area at 3.68 m² and U=0.

Movement at HEAD `b7fa5f74` → post-slice (cert 000565):

Fabric (cascade vs ws):
  walls           602.53 → 602.53 (Δ -1.54 W/K; unchanged)
  roof             52.97 →  51.68 (Δ +1.59 → +0.30 W/K; closes 81%)
  TB              129.35 → 128.80 (Δ +0.70 → +0.15 W/K; closes 79%)
  total area      862.34 → 858.66 (Δ +4.70 → +1.02 m²; closes 78%)
  total W/K       937.40 → 935.54 (Δ +0.33 → -1.52 W/K; sign flips)

End-result pins:
  **sap_score (int)   28 → 29 ✓ EXACT vs ws 29**  (RECOVERED from
                                                   S0380.107 transient
                                                   rounding flip)
  sap_score_continuous 28.4959 → 28.5380 (Δ -0.0128 → +0.0293)
  ecf                   5.3881 →  5.3838 (Δ +0.0015 → -0.0028)
  total_fuel_cost_gbp 4681.39  → 4677.64 (Δ +1.13 → -2.62)
  co2_kg_per_yr      6449.13  → 6444.27 (Δ +1.51 → -3.35)
  space_heating_kwh 59028.80  → 58974.84 (Δ +20.5 → -33.5)
  main_heating_fuel 34722.83  → 34691.09 (Δ +12.0 → -19.7)
  lighting_kwh       1382.67  → 1382.67 (unchanged)
  pumps_fans_kwh ✓ EXACT (unchanged)

Continuous SAP and downstream pins SIGN-FLIPPED again
(cascade was over post-.107, now under post-.108). Per user
direction: transient drift acceptable while closing a true
intermediate-value bug. The remaining net HTC -1.52 W/K is
mostly walls (-1.54 W/K) — closing the Detailed-RR walls
residual is the next leverage front.

Cohort safety: none of the 6 cohort certs lodge a Connected
gable (grep audit across all Summary fixtures). The new
`connected_wall` branch only fires for the cert 000565 Ext1 BP.

Test count: 606 pass + 8 expected 000565 fails → **608 pass +
7 expected 000565 fails** (sap_score back to exact + new
Connected-gable test green). Pyright net-zero per touched
file (57 baseline → 57 post-change).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-30 17:40:42 +00:00
..
fixtures 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
test_elmhurst_end_to_end.py Slice S0380.17: map Elmhurst §11 glazing-type labels to SAP10 codes 2026-05-27 23:05:52 +00:00
test_elmhurst_extractor.py extract window frame details from elmhurst site notes 🟥 2026-04-27 15:50:25 +00:00
test_end_to_end.py P6.1 follow-on: unbox BuildingPartIdentifier at backend boundaries 2026-05-20 09:58:23 +00:00
test_extractor.py Handle wall thickness "Unmeasurable" 🟩 2026-04-30 16:41:16 +00:00
test_pdf.py rename example site notes to PasHub_ and add Elmhurst example 2026-04-24 13:01:51 +00:00
test_summary_pdf_mapper_chain.py Slice S0380.108: Connected-to-heated-space RR gables deduct from A_RR (RdSAP 10 §3.9.2 + Table 4 row 4) 2026-05-30 17:40:42 +00:00