From f0f9c8d8d7db20bea2b4ff75bf537d600dc93cf8 Mon Sep 17 00:00:00 2001 From: Jun-te Kim Date: Tue, 14 Jul 2026 11:53:18 +0000 Subject: [PATCH] feat(terraform): point modelling_e2e at the historic-EPC backup (ADR-0054) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sets HISTORIC_EPC_S3_ROOT, the env var the handler reads to build the historic-EPC reader. With it set, an EPC-less Property whose expired pre-2012 certificate is in the backup has its prediction conditioned on that certificate and persisted as source="expired" rather than "predicted" — which is what lets reporting tell "no EPC at all" apart from "only an expired one". The bucket comes from the shared remote state rather than a rebuilt string: `retrofit_sap_data_bucket_name` is — despite the name — the retrofit-data- bucket (shared/main.tf:167), and engine and fast-api already read it from that output. modelling_e2e was the outlier hardcoding "retrofit-data-${var.stage}". No IAM change: modelling_e2e_s3_read already grants GetObject + ListBucket across the whole retrofit-data- bucket, which covers historical_epc/. Note this makes 'expired' rows start appearing once deployed. assessment-model's epcSources.ts joins only 'lodged' and 'predicted', so until it addresses the predicted slot — source IN ('predicted','expired') — an 'expired' row matches neither and the home drops out of both the "Homes Without an EPC" and "Expired EPCs" cards. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../terraform/lambda/modelling_e2e/main.tf | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/deployment/terraform/lambda/modelling_e2e/main.tf b/deployment/terraform/lambda/modelling_e2e/main.tf index 4be3bd2a8..9995f7fe4 100644 --- a/deployment/terraform/lambda/modelling_e2e/main.tf +++ b/deployment/terraform/lambda/modelling_e2e/main.tf @@ -24,6 +24,20 @@ locals { # truth. At N=32 → 4.0s. Consumed by the handler's throttle (see # infrastructure/solar/google_solar_api_client.py). solar_min_request_interval_seconds = var.maximum_concurrency / (0.8 * 600 / 60) + + # Root of the expired-EPC backup — the old register's final dump, sharded one + # `{POSTCODE}/data.csv.gz` per postcode under `historical_epc/` in the data bucket. + # Turns on Expired-Enhanced Prediction (ADR-0054): a prediction conditioned by the + # dwelling's expired pre-2012 certificate is persisted as source="expired" rather + # than "predicted", so reporting can tell "no EPC at all" apart from "only an + # expired one". + # + # `retrofit_sap_data_bucket_name` is — despite the name — the `retrofit-data-` + # bucket (shared/main.tf); engine and fast-api already take it from this output rather + # than rebuilding the string, so the bucket name has one source of truth. Reads need no + # IAM change: modelling_e2e_s3_read already grants GetObject + ListBucket across that + # whole bucket, which covers historical_epc/. + historic_epc_s3_root = "s3://${data.terraform_remote_state.shared.outputs.retrofit_sap_data_bucket_name}/historical_epc" } module "lambda" { @@ -55,6 +69,10 @@ module "lambda" { DATA_BUCKET = "retrofit-data-${var.stage}" SOLAR_MIN_REQUEST_INTERVAL_SECONDS = tostring(local.solar_min_request_interval_seconds) + + # Expired-Enhanced Prediction (ADR-0054). Empty ⇒ the handler never builds the + # reader and every prediction stays plain "predicted". + HISTORIC_EPC_S3_ROOT = local.historic_epc_s3_root } }