Commit graph

6896 commits

Author SHA1 Message Date
Jun-te Kim
d4c120ede7
Merge pull request #1271 from Hestia-Homes/feature/task-handler-clean
Feature/task handler clean
2026-06-23 16:47:33 +01:00
Jun-te Kim
a7d3e00178 32 2026-06-23 15:42:00 +00:00
Jun-te Kim
119ff3740c fix(task_handler): persist cloud_logs_url for modelling_e2e
@task_handler never built or passed cloud_logs_url, so every app using
it (incl. modelling_e2e) ran run_subtask with the None default and the
CloudWatch deep-link was never saved onto the SubTask. @subtask_handler
did this correctly.

Extract the URL builder into a shared utilities/aws_lambda/cloud_logs.py
(public cloudwatch_url()), use it from both handlers, and pass the URL
into run_subtask from @task_handler. Add regression tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 15:42:00 +00:00
Daniel Roth
4e3eb52a37
Merge pull request #1268 from Hestia-Homes/feature/hyde_make_it_more_accurate_with_tests
Feature/hyde make it more accurate with tests
2026-06-23 16:08:05 +01:00
Jun-te Kim
5737923622 32 and delete in plan 2026-06-23 15:01:34 +00:00
Jun-te Kim
6ee2f6257a fix(mapper): close modelling_e2e cohort mapping gaps (built_form, PV-list, windows-dict)
Closes the mapper-coverage gaps surfaced by the modelling_e2e prediction-cohort
failures (portfolio 796):

- built_form (SAP-16.0): derive from dwelling_type in _normalize_sap_schema_16_x
  (Mid-terrace->4, End-terrace->3, Semi-detached->2, Detached->1; flats->modal 4).
  ML-only field (SAP calc never reads it) so SAP- and gate-neutral. 5 flat certs
  that omitted built_form now map.
- photovoltaic_supply as a measured-array LIST: routed all pre-21 RdSAP mappers
  (17.0/17.1/18.0/19.0/20.0.0) through _map_schema_21_pv, whose list branch is now
  dict-tolerant (_pv_array_field reads dict OR dataclass). They capture the PV
  arrays like 21.0.x instead of raising "'list' object has no attribute
  none_or_no_details" and sinking the whole cohort.
- windows-as-dict (16.x): handled in the normalizer (not just windows-as-list).

Genuinely-sparse certs (omit door_count/habitable/glazed_area) remain fail-loud;
the gate-regressing multiple_glazed_proportion default and the recursive
RdSAP-21.0.0 ADR-0028 alignment are left fail-loud + flagged for review (worklist).

+5 regression tests; component-accuracy gate 26/26; 0 new pyright errors.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 14:51:40 +00:00
Daniel Roth
f09f01adbf
Merge pull request #1266 from Hestia-Homes/feature/hyde_make_it_more_accurate_with_tests
test for 16
2026-06-23 15:20:17 +01:00
Jun-te Kim
c12bfc7413 test for 16 2026-06-23 14:11:30 +00:00
Jun-te Kim
3c45a30890
Merge pull request #1264 from Hestia-Homes/feature/hyde_make_it_more_accurate_with_tests
Feature/hyde make it more accurate with tests
2026-06-23 14:31:45 +01:00
Jun-te Kim
2b0cb180bf update air permebility 2026-06-23 13:21:31 +00:00
Jun-te Kim
60ec922430 fix regression tests 2026-06-23 13:17:23 +00:00
Jun-te Kim
666cf30437 gated propertly 2026-06-23 13:16:34 +00:00
Jun-te Kim
22b92f968e
Merge pull request #1263 from Hestia-Homes/feature/hyde_make_it_more_accurate_with_tests
data types
2026-06-23 13:50:45 +01:00
Jun-te Kim
00af7b5a54 data types 2026-06-23 12:42:53 +00:00
Jun-te Kim
1a080254e7
Merge pull request #1261 from Hestia-Homes/feature/e2e-runs
Feature/e2e runs
2026-06-23 12:24:18 +01:00
Khalim Conn-Kowlessar
c3422704f5 revert epc timeout to 10s 2026-06-23 11:19:23 +00:00
Khalim Conn-Kowlessar
52e5a4d402 Merge remote-tracking branch 'origin/main' into feature/e2e-runs 2026-06-23 11:05:15 +00:00
Khalim Conn-Kowlessar
efaff228ac feat(scripts): add --from-db re-model path + raise EPC API timeout
- run_modelling_e2e --from-db re-models from already-persisted inputs (reads
  each Property's Effective EPC + planning protections + solar from the DB) and
  skips every live fetcher — zero gov-API calls. With --persist it re-writes the
  Plan and, for lodged-EPC Properties, the Baseline. Self-contained loop; the
  live-fetch path is untouched. Makes local re-runs instant and avoids tripping
  the gov API's per-IP rate limit (6000 req / 5 min) during iteration.
- EpcClientService.REQUEST_TIMEOUT 10s -> 30s: a cold per-UPRN search can exceed
  10s and the old timeout turned it into a timeout-then-retry; 30s rides it out.

Note: an open perf question remains — modelling is fast in isolation (<0.5s/
property) but a long-lived --persist run shows ~1 min/property; suspected in the
persist path (plan.save / baseline) or connection handling, NOT the API. Left
mid-diagnosis for handover.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 11:05:06 +00:00
Daniel Roth
ad86f34701
Merge pull request #1259 from Hestia-Homes/e2e-modelling-handler-returns-taskid
Task Handler handler returns task ID and subtask ID. Also remove broken recommendation
2026-06-23 11:41:38 +01:00
Daniel Roth
c49e1f60a2 dont consider system tune up recommendations - causes error 2026-06-23 10:36:27 +00:00
Daniel Roth
0a3b827be2 task handler returns task and subtask IDs 2026-06-23 10:33:38 +00:00
Daniel Roth
2c8a8358b4
Merge pull request #1258 from Hestia-Homes/feature/hyde_make_it_more_accurate_with_tests
updated sap scaema to take in inputs
2026-06-23 11:30:40 +01:00
Jun-te Kim
210ca6397f updated sap scaema to take in inputs 2026-06-23 10:22:40 +00:00
Daniel Roth
95d6ee1a33
Merge pull request #1256 from Hestia-Homes/feature/deploy-e2e-modeller
Actually deploy e2e modelling lambda
2026-06-23 09:51:41 +01:00
Daniel Roth
e949490b20 actually deploy lambda 2026-06-23 08:46:23 +00:00
Daniel Roth
04aa5db1e2
Merge pull request #1253 from Hestia-Homes/feature/trigger-e2e-lamnda
e2e lambda
2026-06-23 09:40:27 +01:00
Daniel Roth
625edbefa4 trigger workflows 2026-06-23 08:26:19 +00:00
Khalim Conn-Kowlessar
4ce2a71871 feat(scripts): one-pass e2e run — baseline + plans + prediction + recovery
Make run_modelling_e2e the single script that does everything for a portfolio,
so the 291-property run needs one invocation with per-property recovery (no
all-or-nothing chunking):

- On --persist, a lodged-EPC Property now also gets its Baseline Performance
  row written via PropertyBaselineOrchestrator (per Property, so one bad cert
  does not abort the batch). Predicted (EPC-less) Properties have no lodged
  figures, so they get a Plan but no baseline row.
- The run CSV gains api_sap (register) vs baseline_sap (calculator) + sap_delta,
  so calculator-vs-API divergence is reviewable per property.

Fill the off-catalogue overlay for the measures the live material catalogue
cannot price, so they stop crashing the run:

- double_glazing (£550/window) and secondary_glazing (£400/window): priced
  per window (the generator multiplies by single-glazed window count, matching
  the legacy window_glazing). Grounded in 2025/26 UK installed costs; per-window
  is the right unit for windows (fixed per-unit install dominates) — per-m2 fits
  walls/floors, not glazing.
- gas_boiler_upgrade / system_tune_up / system_tune_up_zoned: these are priced
  off the heating rate sheet (Products()), with get() reading the catalogue only
  for an id — so the overlay entry exists to satisfy that lookup (material_id
  stays None, as with ASHP); the rate sheet remains authoritative.

Validated on a 12-property sample (incl. a secondary-glazing case and a
SAP-Schema-16.2 cert): 12/12 baseline rows + plans, 0 errors.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 08:24:03 +00:00
Khalim Conn-Kowlessar
564a2ee78f Merge remote-tracking branch 'origin/main' into feature/e2e-runs
# Conflicts:
#	scripts/run_modelling_e2e.py
2026-06-23 07:49:22 +00:00
Daniel Roth
6b8eb88a38 increase lambda timeout to maximum 2026-06-22 16:17:30 +00:00
Daniel Roth
f1a2bbc467 list of properties when triggering locally 2026-06-22 16:13:10 +00:00
Daniel Roth
25c695186b measured excluded plus get geospatial nearby stuff working 2026-06-22 16:12:16 +00:00
Daniel Roth
7e5af6c8f4 process multiple properties in one message 2026-06-22 15:46:18 +00:00
Daniel Roth
5ecb47d46c Merge branch 'main' into feature/trigger-e2e-lamnda 2026-06-22 14:55:16 +00:00
Daniel Roth
2156109e99 concurrency = 2 2026-06-22 14:54:23 +00:00
Daniel Roth
94debe57be
Merge pull request #1254 from Hestia-Homes/feature/hyde_make_it_more_accurate_with_tests
neighbouring properties added
2026-06-22 15:54:08 +01:00
Daniel Roth
233dace245 2 concurrent executions 2026-06-22 14:49:28 +00:00
Daniel Roth
307217eb5d dry run true 2026-06-22 14:45:14 +00:00
Daniel Roth
8ee53a3a95 persist EPC data 2026-06-22 14:45:03 +00:00
Jun-te Kim
9c89a0e680 neighbouring properties added 2026-06-22 14:38:00 +00:00
Daniel Roth
dc830fea63 various fixes 2026-06-22 14:21:52 +00:00
Daniel Roth
409fb8485c local handler 2026-06-22 13:43:52 +00:00
Daniel Roth
c45a27adb0 move handler stuff to applications directory 2026-06-22 13:35:23 +00:00
Daniel Roth
a54671e569 don't use ARG in dockerfile 2026-06-22 13:26:57 +00:00
Daniel Roth
d05e5bd1f3 new application to trigger e2e for a single property and scenario 2026-06-22 12:54:53 +00:00
Jun-te Kim
2afa7acea4
Merge pull request #1251 from Hestia-Homes/feature/hyde_make_it_more_accurate_with_tests
Feature/hyde make it more accurate with tests
2026-06-22 10:04:28 +01:00
Jun-te Kim
1b53c57a07 re run ddd tests 2026-06-22 08:52:45 +00:00
Jun-te Kim
eeec3972fe
Merge pull request #1252 from Hestia-Homes/feature/per-cert-mapper-validation
Feature/per cert mapper validation
2026-06-22 09:38:27 +01:00
Khalim Conn-Kowlessar
a9632937d5 fix(ventilation): use lodged extract-fan count when known, not max(lodged, age default) (RdSAP 10 §4.1 Table 5, PDF p.28)
Table 5 reads "Number of extract fans if known; if number is unknown:
[age-band default]" — the default is an UNKNOWN-fallback, NOT a floor. The
cascade applied `max(lodged, table_5_default)`, flooring a genuinely-lodged
count up to the age-band minimum: e.g. an age H-M dwelling lodging 2 extract
fans was billed at the 6-8-room default of 3, over-counting ventilation line
(8) and the heat-loss coefficient. Fixed to `lodged if lodged > 0 else
default` (a lodged 0 is the Elmhurst/RdSAP "unknown" form → default; any
positive count is taken literally).

Surfaced by Khalim's Elmhurst stress worksheet (simulated case 46): this was
its last ventilation residual — our Jan effective ACH 9.14 -> 9.0748 (exact
match to the accredited worksheet), SAP 29 -> 30 = Elmhurst, cost £1496 vs
£1493. Corpus IMPROVED: within-0.5 71.6% -> 72.5%, MAE 0.819 -> 0.815 (the
max-flooring over-counted ventilation on every cert lodging fans below its
age default). Floor ratcheted 0.71 -> 0.72. pyright not installed locally.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 06:22:26 +00:00
Khalim Conn-Kowlessar
34e52a893c fix(heating): assume portable-electric secondary for unheated habitable rooms (SAP 10.2 Appendix A.2.2)
When the main heating system does not heat every habitable room (heated rooms
< habitable rooms), SAP 10.2 Appendix A.2.2 assumes the unheated rooms are
served by a portable-electric secondary heater, so the Table 11 secondary
fraction (0.10 for a boiler main) must be costed at the electricity tariff —
even when the cert lodges no explicit secondary system.

`_secondary_fraction` previously returned 0 unless a secondary was lodged or
the main was a forced-secondary electric-storage code, dropping the assumed
secondary and billing 100% of space heat to the (cheaper) main fuel — an
over-rate. Added an `unheated_habitable_rooms` trigger plus
`_has_unheated_habitable_rooms(epc)`, which prefers the lodged
`any_unheated_rooms` flag and guards the gov-API `heated_rooms_count == 0`
"not provided" sentinel. The secondary fuel/efficiency cascade already
defaults to portable electric (code 693) when no secondary code is lodged.

Worksheet-validated on simulated case 46 (heated 4 < habitable 7, no lodged
secondary): the assumed 10% electric secondary (2289 kWh, ~£260) lifted our
SAP 39 -> 29.35 vs accredited Elmhurst 30 (cost £1502 vs £1493, within 0.6%).

Corpus UNCHANGED (71.6% / MAE 0.819): all 17 corpus certs with heated <
habitable already lodge an explicit secondary description, so the gov-API
path was already costing it; this only adds the assumed secondary where none
is lodged (Elmhurst / reduced-field path). pyright not installed locally.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-21 06:15:37 +00:00