Commit graph

7275 commits

Author SHA1 Message Date
Khalim Conn-Kowlessar
33f9988ac5 Map assessment_type on full-SAP certs 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 20:52:07 +00:00
Khalim Conn-Kowlessar
f568ec00fc Full-SAP certs rebaseline off the lodged SAP-2012 value (downgrade fix) 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 20:43:31 +00:00
Khalim Conn-Kowlessar
5149400f96 Map secondary_heating on full-SAP certs for the calculator 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 20:40:59 +00:00
Khalim Conn-Kowlessar
7b06d9dbab Map secondary_heating on full-SAP certs for the calculator 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 20:40:30 +00:00
Khalim Conn-Kowlessar
bc394ce5f5 Map built_form on full-SAP certs 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 20:38:50 +00:00
Khalim Conn-Kowlessar
d2ede36b41 Map built_form on full-SAP certs 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 20:38:16 +00:00
Khalim Conn-Kowlessar
5c0460cee2 Map property_type on full-SAP certs for correct heat-transmission 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 20:37:34 +00:00
Khalim Conn-Kowlessar
951bee3115 Map property_type on full-SAP certs for correct heat-transmission 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 20:36:38 +00:00
Khalim Conn-Kowlessar
cff5b061a4 Map sap_version on full-SAP certs so pre-SAP10 rebaseline fires 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 20:36:04 +00:00
Khalim Conn-Kowlessar
14c777f37b Map sap_version on full-SAP certs so pre-SAP10 rebaseline fires 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 20:34:35 +00:00
Khalim Conn-Kowlessar
2d18e9a3b0 docs: ADR-0037 + Full-SAP Assessment term for the baseline-downgrade family
Captures the grill-with-docs decisions for the full-SAP-17.1 mapper completion:
rebaseline-to-10.2 (restores Rebaselining trigger (a)), calc-affecting fields
coupled with the sap_version flip, and growing Elmhurst-anchored validation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 20:24:34 +00:00
Daniel Roth
8322c197aa
Merge pull request #1331 from Hestia-Homes/feature/handle-main_heating_category-11
Fix UnmappedSapCode for main_heating_category 11 (electric ceiling heating)
2026-06-25 17:14:55 +01:00
Khalim Conn-Kowlessar
ecb31bf114 Inject Solar throttle gap derived from queue maximum_concurrency
Terraform computes SOLAR_MIN_REQUEST_INTERVAL_SECONDS = N / (0.8 * 600 / 60)
from var.maximum_concurrency (=4.0s at N=32) so the fleet width has one source
of truth and the per-container Solar pacing tracks it automatically.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 16:05:57 +00:00
Khalim Conn-Kowlessar
1e3c401b38 Resolve the Solar throttle gap from env with a 32-wide fallback 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 16:04:39 +00:00
Khalim Conn-Kowlessar
85e203f366 Resolve the Solar throttle gap from env with a 32-wide fallback 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 16:03:42 +00:00
Khalim Conn-Kowlessar
4b9bd495e1 Pace Solar calls per container to stay under the 600 QPM fleet cap 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 16:00:33 +00:00
Daniel Roth
60b4cae498 _secondary_heating_fraction_for_category returns 0.10 for category 11 (electric ceiling heating) 🟩
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-25 15:59:47 +00:00
Daniel Roth
a19b3dada1 _secondary_heating_fraction_for_category returns 0.10 for category 11 (electric ceiling heating) 🟥
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-25 15:59:14 +00:00
Khalim Conn-Kowlessar
48a47590e9 Pace Solar calls per container to stay under the 600 QPM fleet cap 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 15:59:00 +00:00
Daniel Roth
c89ab7692d
Merge pull request #1329 from Hestia-Homes/feature/modelling-e2e-bugs
Fix: synthesise SapFloorDimension for SAP-16.0 flats with missing floor dimensions to unblock roof recommendations
2026-06-25 16:12:46 +01:00
Daniel Roth
5a4285e1b7 Include address and postcode in floor-dims synthesis ValueError for triage
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-25 15:07:07 +00:00
Daniel Roth
8024065d04 Raise ValueError when floor dims absent and synthesis guards cannot fire 🟩
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-25 15:03:03 +00:00
KhalimCK
c1869eb5db
Merge pull request #1327 from Hestia-Homes/fix/solar-429-backoff-jitter
fix(solar): ride out Google Solar 429s with jittered backoff
2026-06-25 16:02:48 +01:00
KhalimCK
2c49ca630c
Merge pull request #1328 from Hestia-Homes/fix/flat-location-banded-string
fix(epc-mapper): coerce banded flat_location "20+" to its floor integer
2026-06-25 16:02:26 +01:00
Daniel Roth
e62e5fbfe4 Add comment explaining floor-dim synthesis guard and bungalow coverage gap
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-25 14:24:59 +00:00
Daniel Roth
76d07dba39 Pin synthesised SapFloorDimension total area and heat-loss perimeter as regression tests 🟩
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-25 14:18:27 +00:00
Daniel Roth
8a909dc15b Mapper synthesises SapFloorDimension for SAP-16.0 flats with empty floor dims 🟩
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-25 14:16:36 +00:00
Daniel Roth
c1e754057b Mapper synthesises SapFloorDimension for SAP-16.0 flats with empty floor dims 🟥
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-25 14:14:03 +00:00
Khalim Conn-Kowlessar
48760971a7 Coerce banded flat_location string to its floor integer 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 12:01:44 +00:00
Khalim Conn-Kowlessar
862a7ccc61 Coerce banded flat_location string to its floor integer 🟥
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 12:00:00 +00:00
Khalim Conn-Kowlessar
440159e7f4 Harden Solar API client against 429s: jitter, Retry-After, bounded backoff 🟩
Route the Google Solar client through the shared call_with_retry with
full jitter (de-synchronises the 32 concurrent containers per Google's
"avoid synchronised requests" guidance), honouring Retry-After, a 60s max
backoff (rides out the 600 QPM per-minute window), and 6 bounded retries.
429/5xx/transport errors are transient; other 4xx propagate immediately;
404-entity-not-found stays BuildingInsightsNotFoundError. On exhaustion a
TransientHttpError surfaces so the subtask fails and is re-triggered (no
silent degrade).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 10:51:23 +00:00
Khalim Conn-Kowlessar
88ed0c2e88 Add opt-in full-jitter backoff to de-synchronise concurrent retries 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 10:45:00 +00:00
Jun-te Kim
1edf2be345
Merge pull request #1326 from Hestia-Homes/feat/modelling-e2e-sqs-batching
Batch postcode groups into SQS messages for modelling_e2e
2026-06-25 11:23:53 +01:00
Jun-te Kim
25fb0a9ebb Batch postcode groups into SQS messages for modelling_e2e
Group pending property IDs by postcode and pack them into ~BATCH_SIZE
messages, never splitting a postcode, so each SQS message drives one
batched modelling_e2e Lambda invocation. Adds a completed-since skip
filter and a properties cap.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-25 10:21:17 +00:00
Jun-te Kim
77133f4b42
Merge pull request #1321 from Hestia-Homes/fix/off-peak-bill-day-night-split
Fix/off peak bill day night split
2026-06-24 20:35:03 +01:00
Jun-te Kim
8e4f067c52
Merge pull request #1324 from Hestia-Homes/perf/modelling-e2e-batch-subtasks
perf(modelling_e2e): batch SubTask bookkeeping to stop per-property DB writes
2026-06-24 20:33:02 +01:00
Jun-te Kim
b1ff711260 perf(modelling_e2e): batch SubTask bookkeeping to stop per-property writes
Even after batching the data writes, the handler still wrote to the DB per
property through the orchestrator's SubTask bookkeeping: create + start +
complete each self-committed, and _cascade re-listed every sibling and re-saved
the parent on every transition — ~5 writes per property plus an O(N^2) cascade.

- TaskOrchestrator.run_subtasks: create all children in one INSERT, run each
  (failures isolated per child), then persist all terminal states in one bulk
  save and cascade the parent once. Children go WAITING -> terminal; the
  transient IN_PROGRESS row is never written.
- SubTaskRepository.create_many / save_many (bulk INSERT / bulk fetch + update).
- _cascade short-circuits when the Task is already FAILED (terminal) — skips the
  sibling roll-up entirely.
- modelling_e2e handler fans out via run_subtasks instead of per-property
  create_child_subtask + run_subtask.

Per N-property batch the SubTask bookkeeping drops from ~5N writes + an O(N^2)
cascade to ~2 writes + 1 cascade.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 19:26:42 +00:00
Jun-te Kim
ba58398997
Merge pull request #1322 from Hestia-Homes/perf/modelling-e2e-batch-rds-main
perf(modelling_e2e): bulk reads and batch writes to cut RDS load
2026-06-24 19:51:41 +01:00
Jun-te Kim
de5e9a2362 perf(modelling_e2e): bulk reads and batch writes to cut RDS load
The handler fired ~2+2N read round-trips and N+N write transactions per
SQS batch, pinning RDS CPU under ~32 concurrent containers on pool_size=1.

Reads: merge the duplicate property query and add overrides_for_many /
SolarRepository.get_many so overrides, solar, and property rows each load
in one query (2+2N -> 3).

Writes: buffer each modelled property's persistence intent in memory
(_PropertyWrite) during the loop, then flush the whole batch in one
PostgresUnitOfWork with a single commit, and run the baseline orchestrator
once for all written ids (N+N -> 2 transactions). Per-property modelling
failures stay isolated in the loop; the batch write is all-or-nothing and
retried via SQS (saves are idempotent upserts).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 18:43:42 +00:00
Khalim Conn-Kowlessar
1da86a6366 Pin end-to-end off-peak day/night bill regression 🟩
An Economy-7 storage dwelling now prices heating at the 0.20-day/0.80-
night blend through cert -> calculator -> bill, instead of raising
UnpricedFuel and aborting the modelling_e2e batch.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 18:05:33 +00:00
Khalim Conn-Kowlessar
81d5429b60 Source every end use's off-peak high-rate fraction from the cert 🟩
Surface the hot-water (Table 13 / HP-DHW), secondary (direct-acting),
main-2 and ALL_OTHER_USES High-Rate Fractions on CalculatorInputs from
the same Table 12a helpers the SAP cost path uses, so Bill Derivation's
day/night split matches the rating's exactly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 17:57:23 +00:00
Khalim Conn-Kowlessar
b58e27f46e Source the off-peak meter flag and main-heating fraction from the cert 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 17:52:39 +00:00
Khalim Conn-Kowlessar
3f5cd550cb Thread the off-peak meter flag and high-rate fractions onto SapResult 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 17:45:29 +00:00
Khalim Conn-Kowlessar
d3a4426ca4 Lock whole-meter off-peak routing and standard-meter no-op 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 17:39:58 +00:00
Khalim Conn-Kowlessar
05977ee3ce Route an off-peak meter's electric end uses to the day/night carrier 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 17:38:37 +00:00
Khalim Conn-Kowlessar
dc55d3b899 Price an off-peak meter line day/night by its high-rate fraction 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 17:24:50 +00:00
Khalim Conn-Kowlessar
1acfc08fce Load the off-peak day/night rate from the committed snapshot 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 17:20:19 +00:00
Daniel Roth
932a252454
Merge pull request #1314 from Hestia-Homes/fix/modelling-e2e-single-connection
Fix modelling_e2e single-connection pool exhaustion (QueuePool timeout)
2026-06-24 18:15:27 +01:00
Khalim Conn-Kowlessar
bda8a3f276 Expose an off-peak meter's standing charge and full day/night blend range 🟩
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 17:14:51 +00:00
Jun-te Kim
fb308cfaea Use NullPool as a graceful ceiling for the one-connection-per-lambda design
The invocation is architecturally one DB connection at a time (read up front,
sequential write Units of Work, overrides resolved on the unit's own session).
Keep that as the design intent, but back it with NullPool instead of a fixed
pool_size=1 pool: each checkout opens a fresh connection and closes it on return,
so there is no pool slot to exhaust.

The difference is the failure mode if a path ever regresses and holds two
Sessions at once. A pool_size=1/max_overflow=0 pool turns that into a hard
30s dead-lock that fails the whole invocation ("QueuePool limit of size 1
overflow 0 reached, connection timed out"). NullPool instead opens a transient
second connection for that instant and the Lambda keeps running. The design
target stays one connection; NullPool just keeps it alive if we slip.

The single-connection invariant itself is still enforced in the Unit of Work
(overrides read on the unit's own session) and pinned by the regression test,
which uses its own strict pool_size=1 engine so it asserts the architecture
regardless of the production NullPool choice.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 17:10:23 +00:00