Model/backend/documents_parser
Khalim Conn-Kowlessar 19e23d0c31 Slice S0380.2: surface main_heating_category=4 for PCDB heat-pump indices
Extends `_elmhurst_main_heating_category` in
`datatypes/epc/domain/mapper.py` so a PCDB index that resolves to a
Table 362 record (heat pumps only) yields category 4 — the SAP 10.2
Table 4a code that gates the Appendix N3.6/N3.7 heat-pump cascade
(`cert_to_inputs.py` lines 1896, 2005, 2057, 2104 all branch on
`main_heating_category == 4`).

Authoritative signal: PCDB Table 362 is heat-pumps-only, so
membership IS the heat-pump answer. `heat_pump_record(pcdb_id)`
(introduced for the API path's cohort closure) returns the typed
record or None; a non-None return is sufficient. No fuel-type
belt-and-braces is needed — Table 362 membership is unambiguous,
unlike the gas-boiler branch which uses fuel type to disambiguate
PCDB Table 105 records.

Forcing function (Slice S0380.1): cert 0380 Summary cascade SAP
moves from 33.7920 (Δ -54.7184) to 81.7528 (Δ -6.7576) — closes
~88% of the gap. Remaining -6.76 SAP is the next workstream:
cylinder / HW cascade, PV array surfacing, secondary-heating routing
(per HANDOVER_CERT_0380_SUMMARY_PATH.md debug order steps 3–4).

Added focused unit test
`test_summary_0380_main_heating_category_is_heat_pump` that pins the
contract at the mapper boundary (idx 104568 → category 4), so future
debuggers can localise regressions before walking the full chain.

Architectural note: introduces the first
`datatypes/epc/domain/mapper.py → domain/sap10_calculator/tables/pcdb`
import. PCDB is BRE reference data shared by both layers; treating it
as importable shared reference is the lighter alternative to either
(a) duplicating an HP-PCDB-IDs frozenset in the mapper or (b) hoisting
PCDB into a new shared package.

Pyright baseline preserved:
  datatypes/epc/domain/mapper.py: 32 errors (no new errors introduced)
  backend/documents_parser/tests/test_summary_pdf_mapper_chain.py: 0 errors

Regression suite: 670 pass + 11 fail (vs handover baseline 669 + 10 —
net +1 pass for the new GREEN unit test, +1 fail still being the
Slice 1 chain test that this slice does not yet fully close).

Spec refs:
- SAP 10.2 Table 4a (main heating category codes — code 4 = heat pump)
- SAP 10.2 Appendix N3.6/N3.7 (heat-pump space-heating efficiency
  with PSR interpolation, routed via the category-4 gate)
- BRE PCDB Table 362 (heat-pump records — pcdb_id 104568 = Mitsubishi
  Ecodan PUZ-WM50VHA, the cert 0380 main heating appliance)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-01 16:28:46 +00:00
..
handler address JTK review comments 2026-04-20 15:11:17 +00:00
tests Slice S0380.2: surface main_heating_category=4 for PCDB heat-pump indices 2026-06-01 16:28:46 +00:00
__init__.py Map to RdSapSiteNotes from site notes JSON 🟥 2026-04-16 13:54:03 +00:00
db_writer.py include updating epc_property_data to pashub to ara workflow 2026-04-29 09:55:14 +00:00
elmhurst_extractor.py Slice 99d: surface PV array from Elmhurst Summary §19.0 2026-06-01 16:28:45 +00:00
extractor.py Handle wall thickness "Unmeasurable" 🟩 2026-04-30 16:41:16 +00:00
local_runner.py update local runner to work for elmhurst 2026-04-24 14:01:36 +00:00
parser.py load ecmk site notes to db 2026-04-29 11:20:47 +00:00
pdf.py update local runner to work for elmhurst 2026-04-24 14:01:36 +00:00