Commit graph

7399 commits

Author SHA1 Message Date
Jun-te Kim
217dcab53e
Merge pull request #1371 from Hestia-Homes/feat/data-export-script
Add data-export script on the new DDD model (replaces principal_pitch/2_export_data.py)
2026-06-30 18:43:21 +01:00
Jun-te Kim
59508eb033 Add scripts/data_exports.py: principal-pitch export on the new DDD model
Replaces sfr/principal_pitch/2_export_data.py, which read the retired
plan_recommendations m2m and recommendation_materials table. The new model
links a recommendation to its plan directly (recommendation.plan_id), keeps
materials inline on the recommendation (material_id), marks the chosen plan
per (scenario, property) with is_default, and stores post-works SAP/EPC and
savings on the plan row (the new SAP calculator's output).

Takes a portfolio id, resolves every modelled scenario (those with plans),
and writes one workbook with a properties sheet per scenario. EPC descriptive
fields are sourced live from the EPC service (property_details_epc is dead);
property_type falls back override -> cert.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:39:46 +00:00
Khalim Conn-Kowlessar
1dc94e7cda Drag heat-network category and a community gas fuel for community boilers 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:39:42 +00:00
Khalim Conn-Kowlessar
098427e620 Drag heat-network category and a community gas fuel for community boilers 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:38:08 +00:00
Khalim Conn-Kowlessar
46f4b2c3a3 Recognise community boilers as a heat-network system 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:37:34 +00:00
Khalim Conn-Kowlessar
c7b2fe7a1b Recognise community boilers as a heat-network system 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:36:41 +00:00
Khalim Conn-Kowlessar
0c12f70589 Drag an air source heat pump's coherent companions 🟩
Heat pump drags category 4 + electricity (29). Meter stays single-rate: a heat
pump does not imply an off-peak tariff the way storage/CPSU do (SAP §12 Rule 3
is conditional), so forcing Dual would mis-bill it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:33:05 +00:00
Khalim Conn-Kowlessar
848252e5d4 Drag an air source heat pump's coherent companions 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:30:38 +00:00
Khalim Conn-Kowlessar
1552e24fa5 Recognise an air source heat pump via the default ASHP code 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:30:00 +00:00
Khalim Conn-Kowlessar
646bff38a6 Recognise an air source heat pump via the default ASHP code 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:28:48 +00:00
Khalim Conn-Kowlessar
dbcd2e3840 Run the fuel-mismatch check on every Property's resolved overrides 🟩
Wire flag_fuel_mismatch into the two override-resolution paths (the property
repository and the modelling-e2e handler), keeping overlays_from a pure mapping.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:21:32 +00:00
Khalim Conn-Kowlessar
13a6a213fb Treat a same-family fuel refinement as consistent, not a mismatch 🟩
Compare fuel families (not exact codes), so a solid-fuel room heater refined to
smokeless/dual/biomass is consistent; only a different family (gas/electric on a
solid heater) is logged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:18:51 +00:00
Khalim Conn-Kowlessar
27f6b8e9ae Treat a same-family fuel refinement as consistent, not a mismatch 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:17:04 +00:00
Khalim Conn-Kowlessar
79fe54a822 Log a landlord fuel that contradicts the heating archetype's natural fuel 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:16:14 +00:00
Khalim Conn-Kowlessar
648013e05c Log a landlord fuel that contradicts the heating archetype's natural fuel 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:15:16 +00:00
Khalim Conn-Kowlessar
6276730cfe A main_fuel override beats a heating archetype's natural-fuel default 🟩
overlays_from now applies main_fuel after main_heating_system (stable sort), so
an explicit landlord fuel wins the natural-fuel default the heating archetype
drags, regardless of override row order. apply_simulations is last-wins.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:06:56 +00:00
Khalim Conn-Kowlessar
260e3cbd32 A main_fuel override beats a heating archetype's natural-fuel default 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 17:04:44 +00:00
Khalim Conn-Kowlessar
56aaace5b1 Default a solid-fuel room heater's natural fuel to house coal 🟩
Solid fuel is ambiguous across coal/wood/smokeless/pellets, so the overlay
defaults to house coal (33, the most common) when no main_fuel override is
given; a specific solid-fuel override still wins by last-wins composition.
Updates the ADR-0041 natural-fuel amendment accordingly (every archetype drags
a natural fuel; solid defaults to coal).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 16:55:57 +00:00
Khalim Conn-Kowlessar
390df5a6bd Default a solid-fuel room heater's natural fuel to house coal 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 16:54:07 +00:00
Khalim Conn-Kowlessar
d5927c68a9 docs: ADR-0041 amendment — natural-fuel coherence
Record the natural-fuel drag-along rule the overlay now implements: drag a fuel
only where the archetype is unambiguous (electric/gas), leave ambiguous
solid/oil room heaters to the main_fuel override, let a present main_fuel
override win by last-wins composition, and LOG (not raise) a landlord fuel that
contradicts the archetype's natural fuel.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 16:46:56 +00:00
Khalim Conn-Kowlessar
d8acc9baa5 Drag electricity as an electric room heater's natural fuel 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 16:46:18 +00:00
Khalim Conn-Kowlessar
5a29238480 Drag electricity as an electric room heater's natural fuel 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 16:45:20 +00:00
Khalim Conn-Kowlessar
0cd30a13e6 Drag a solid-fuel room heater's coherent room-heater companions 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 16:44:04 +00:00
Khalim Conn-Kowlessar
d5280e9d96 Drag a solid-fuel room heater's coherent room-heater companions 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 16:42:48 +00:00
Daniel Roth
afe1801273 implausible-lodged-score check fires for bad upstream EPC data (lodged < 13, gap >= 15) 🟩
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 15:27:19 +00:00
Daniel Roth
e70df63ee6 implausible-lodged-score check fires for bad upstream EPC data (lodged < 13, gap >= 15) 🟥
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 15:26:29 +00:00
Daniel Roth
fe1d04983b effective-lodged-divergence is silent for implausible lodged scores (< 13) 🟩
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 15:25:02 +00:00
Daniel Roth
cf097afc00 effective-lodged-divergence is silent for implausible lodged scores (< 13) 🟥
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 15:24:22 +00:00
Khalim Conn-Kowlessar
f097561160 Recognise a solid-fuel room heater as its own heating archetype 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 14:44:30 +00:00
Khalim Conn-Kowlessar
d51154fe73 Recognise a solid-fuel room heater as its own heating archetype 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 14:43:24 +00:00
Khalim Conn-Kowlessar
72e1e67c6d docs: ADR-0041 — landlord-heating classification targets a complete taxonomy
grill-with-docs output for PRD #1361 Class A. The band-G baselines are not a
fabric/rebaseline bug (walls are correct — landlord asserted as-built); they are
a target-vocabulary gap in the landlord-description heating classifier. The LLM
maps unbounded free-text onto a closed internal taxonomy, but that taxonomy had
9 archetypes vs ~13 RdSAP families, so it overflowed into "Gas CPSU"/storage
(the "convector" collision sent direct-acting room heaters to off-peak storage
403 → SAP ~10).

- ADR-0041: fix the taxonomy not the mapper; unmapped input -> None (keep lodged
  EPC, surface to user), never a forced archetype; heat pumps modellable via a
  default Table 4a code (no PCDB id); community heating via codes 301/302/304
  with a documented DLF-1.50 / boiler-source default.
- CONTEXT.md: sharpen Landlord-Description Classification and the four distinct
  vocabularies (landlord / recognised-internal / lodged / SAP code).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 14:33:54 +00:00
Daniel Roth
851f8150b6 Merge branch 'main' into feature/ventilation-audit-changes 2026-06-30 14:08:16 +00:00
Daniel Roth
a7ecb0eaec add local handler and orchestrator 2026-06-30 13:58:41 +00:00
Daniel Roth
78673e96f7 Mapper reads 'Individual Trickle Vent' label variant 🟩
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 13:44:38 +00:00
Daniel Roth
33061ba347 Mapper reads 'Individual Trickle Vent' label variant 🟥
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 13:43:48 +00:00
Daniel Roth
3461b54498 Mapper falls back to legacy trickle vent label for pre-existing API responses 🟩
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 13:34:57 +00:00
Daniel Roth
093563b0c9 Mapper falls back to legacy trickle vent label for pre-existing API responses 🟥
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 13:34:06 +00:00
Khalim Conn-Kowlessar
4a110d13cd Guard the portfolio audit against the 26m-row recommendation seq-scan
The `recommendation` table (~26m rows) has no index on `plan_id`, so any query
reaching it via `plan_id` — including the audit's own rollup — seq-scans the
whole table and saturates the shared DB (it blocked the DB during the
portfolio-796 audit). Make the audit safe-by-default:

- statement_timeout (120s) on the audit connection — a hard ceiling so a bad
  plan aborts instead of hammering the DB.
- The recommendation rollup (the two solar checks) is now opt-in via
  --with-recommendations, and EXPLAIN-gated: it refuses to run (raising
  RecommendationScanError) when the plan contains a Seq Scan on recommendation,
  which it does on any large portfolio until idx_recommendation_plan_id exists.
- SKILL.md documents the plan_id-no-index trap, the reach-via-property_id /
  EXPLAIN-first / confirm-with-user rules, and the index as the real fix.

Verified on 796/1268: default run is bounded and completes (2,952 anomalies over
31,919 properties); --with-recommendations aborts pre-scan portfolio-wide but is
allowed for a single property.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 13:23:26 +00:00
Daniel Roth
7fcb64bd8c Door columns shift to Q/R/S/T after column P deletion 🟩
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 12:58:46 +00:00
Daniel Roth
372586bb29 Door columns shift to Q/R/S/T after column P deletion 🟥
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 12:58:00 +00:00
Daniel Roth
6cb9800608 Mapper reads new 'Total Trickle Vent Effective Area' label 🟩
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 12:57:26 +00:00
Daniel Roth
54f045f4c6 Mapper reads new 'Total Trickle Vent Effective Area' label 🟥
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 12:56:54 +00:00
Daniel Roth
52749d4931 delete redundant column from spreadsheet 2026-06-30 12:53:29 +00:00
Daniel Roth
550b2ae5e6 revert changes 2026-06-30 11:34:16 +00:00
KhalimCK
ee9a1c4d90
Merge pull request #1364 from Hestia-Homes/audit/schema-mapping-gaps
Audit other schema mappers for the meter/PV drop class — fix full-SAP 18-hour tariff
2026-06-30 11:08:23 +01:00
Daniel Roth
d623a29c2d Merge branch 'main' into audit/schema-mapping-gaps 2026-06-30 10:00:33 +00:00
Daniel Roth
1f0fffe8af Write total trickle vent area to column O; shift door columns to Q/R/S/T 🟩
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 09:59:37 +00:00
Daniel Roth
367fd3664b Write total trickle vent area to column O; shift door columns to Q/R/S/T 🟥
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-30 09:37:55 +00:00
Daniel Roth
fad7bd6e96
Merge pull request #1363 from Hestia-Homes/fix/hyde-portfolio-audit
fix(full-sap): seven mapper/overlay fixes from the portfolio-796 modelling audit
2026-06-30 10:26:17 +01:00
Khalim Conn-Kowlessar
2c851e9e5e Re-baseline pins for full-SAP PV + tariff mapper fixes 🟩
The PV-array (ea7f4f43) and electricity-tariff (6ec09892) mapper fixes shifted
the observed output of five frozen gates that weren't updated alongside:

- has_pv component-accuracy floor 0.9798 -> 0.9697: carrying full-SAP lodged PV
  now reads the true has_pv=True for full-SAP PV dwellings, so the leave-one-out
  scorer's actual changes (ground-truth-method shift, ADR-0037 pattern).
- uprn_10093116528 80->... pin 82 -> 83: tariff=1 (standard) was wrongly read as
  dual/Economy 7; translating to "single" re-prices the gas semi's electricity.
- uprn_10096028301 82 -> 84, uprn_10023444324 80 -> 82 (== lodged 82),
  uprn_10023444320 81 -> 83: now credit the lodged sap_energy_source.pv_arrays
  the schema previously dropped. Comments document the per-cert PV/Elmhurst
  relationship (incl. the mid-floor sibling landing +2 over its lodged integer).

Pre-existing, unrelated failures untouched: the missing
sap_16_0_full_no_floor_dims.json fixture and the RdSAP-21 floor-area test (both
reproduce on origin/main).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-30 09:18:39 +00:00