Model/tests/repositories/property
Jun-te Kim 17b9ae08eb Hold one DB connection per modelling_e2e invocation
The modelling_e2e Lambda held up to ~4 concurrent Postgres connections per
invocation: the read Session stayed open across the write loop (the catalogue
was queried live and overrides were read per-Property), each per-Property Unit
of Work opened a second, and the TaskOrchestrator ran on its own NullPool
engine — so the pool needed pool_size=2 + max_overflow=1 just for the modelling
work. Under 32 concurrent containers that approached RDS max_connections.

Restructure the handler to read everything up front — overrides, Scenario, an
in-memory catalogue snapshot, and stored Solar — through one short-lived read
Session, close it, then write each Property in a sequential Unit of Work. The
read and write Sessions no longer overlap, so the engine drops to pool_size=1,
max_overflow=0. Fold the orchestrator onto the same pooled engine: its repos
commit on every save, releasing the connection between bookkeeping calls, so it
holds none during the work. One invocation now uses one connection at a time.

The catalogue becomes a per-invocation snapshot (MaterialSnapshotRepository),
mirroring ProductPostgresRepository.get exactly — same drift mapping, lowest-id
pick, and errors — but priced after the Session closes. Transaction isolation
is preserved: per-Property writes and orchestrator bookkeeping keep their own
independent transactions, just drawn sequentially from a single connection.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-24 16:58:21 +00:00
..
__init__.py feat(property): Property aggregate + PropertyRepository (#1132) 2026-05-30 19:39:54 +00:00
test_in_memory_property_overrides_reader.py Hold one DB connection per modelling_e2e invocation 2026-06-24 16:58:21 +00:00
test_landlord_override_overlays.py Route a main_heating_system override row through its overlay mapper 🟥 2026-06-19 14:06:04 +00:00
test_override_backed_prediction_attributes_reader.py Resolve a Property's prediction attributes from landlord overrides in gov-code space 🟩 2026-06-16 15:18:44 +00:00
test_override_component_consistency.py Silence untyped SAEnum.enums access in the consistency guard 🟪 2026-06-19 18:19:32 +00:00
test_property_overrides_postgres_reader.py Read a Property's resolved landlord overrides as a faithful value-space snapshot 🟩 2026-06-16 15:14:53 +00:00
test_property_postgres_overlay_hydration.py Hydrate landlord-override overlays onto the Property from property_overrides 🟩 2026-06-16 17:29:31 +00:00
test_property_repository.py feat(modelling): mark a Property as run via has_recommendations + updated_at 2026-06-16 23:34:33 +00:00