Model/infrastructure/postgres
Khalim Conn-Kowlessar d66f7eed84 feat(modelling): plan/recommendation SQLModel mirrors + PlanRepository (#1157)
Slice 3 of #1157. Persists a Plan and its Plan Measures to the live
plan / recommendation tables via SQLModel mirrors (ADR-0017).

- infrastructure/postgres/plan_table.py: PlanRow (`plan`) + RecommendationRow
  (`recommendation`) mirrors. RecommendationRow adds the new `plan_id` FK
  (ON DELETE CASCADE) linking each Plan Measure to its Plan, replacing the
  plan_recommendations m2m for new writes. from_domain mappers convert CO2
  kg → tonnes to match the live column contract and derive post_epc_rating
  from the rounded SAP. Only the impact + cost + identity columns the tracer
  fills are declared; energy/bill, U-value, valuation, labour, plan_type are
  left to later slices.
- PlanRepository port + PlanPostgresRepository.save(plan, *, property_id,
  scenario_id, portfolio_id, is_default) -> plan id. Idempotent replace:
  deleting the Plan cascades to its recommendation rows via plan_id, so a
  re-run overwrites (ADR-0012). No commit — the UoW owns the transaction.

2 tests (persist + idempotent re-run); pyright strict clean; 73 pass across
repositories/modelling/orchestration with no regressions.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 11:51:02 +00:00
..
__init__.py added postcode splitter rewrite to ddd 2026-05-19 16:35:09 +00:00
config.py added postcode splitter rewrite to ddd 2026-05-19 16:35:09 +00:00
engine.py tests wrong environemnt 2026-05-29 16:17:06 +00:00
epc_property_table.py feat(epc): persist renewable_heat_incentive — full round-trip equality (#1137) 2026-06-01 16:28:48 +00:00
landlord_built_form_type_override_table.py pr review, move domain and orhcestration 2026-06-01 14:00:31 +00:00
landlord_override_enums.py landlord overrid orchestration 2026-05-26 15:27:45 +00:00
landlord_property_type_override_table.py pr review, move domain and orhcestration 2026-06-01 14:00:31 +00:00
landlord_roof_type_override_table.py pr review, move domain and orhcestration 2026-06-01 14:00:31 +00:00
landlord_wall_type_override_table.py pr review, move domain and orhcestration 2026-06-01 14:00:31 +00:00
plan_table.py feat(modelling): plan/recommendation SQLModel mirrors + PlanRepository (#1157) 2026-06-03 11:51:02 +00:00
product_table.py feat(modelling): ProductRepository + Postgres materials-table source 2026-06-03 08:32:38 +00:00
property_baseline_performance_table.py feat(baseline): wire BillDerivation into the orchestrator and persist the Bill (ADR-0014) 2026-06-02 18:51:18 +00:00
property_table.py refactor(property): PropertyRow.id non-Optional (PR #1139 review) 2026-06-01 16:28:48 +00:00
scenario_table.py feat(modelling): domain Scenario + ScenarioPostgresRepository (#1157) 2026-06-03 11:19:52 +00:00
solar_table.py feat(ingestion): relocate EpcClientService to infrastructure + SolarRepo (#1133) 2026-06-01 16:28:48 +00:00
subtask_table.py added postcode splitter rewrite to ddd 2026-05-19 16:35:09 +00:00
task_table.py added postcode splitter rewrite to ddd 2026-05-19 16:35:09 +00:00