mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
First slice of the per-stage batch-transaction refactor (ADR-0012). A UnitOfWork is the single transaction a stage runs its batch in: a context manager exposing the DB repos bound to one session, committing once on `commit()` and rolling back on exception or exit-without-commit (all-or-nothing per batch, fail noisily). - `UnitOfWork` (port): `property` / `epc` / `solar` / `baseline` repos + `commit()` / `rollback()`; `__exit__` rolls back uncommitted work. - `PostgresUnitOfWork(session_factory)`: opens a Session from an injected factory (a module-scoped engine + sessionmaker in prod, so the pool is reused across warm invocations), binds the Postgres repos to it, closes on exit. Not yet wired into any orchestrator — that lands in the Baseline / Ingestion refactor slices. 3 tests against ephemeral PG (commit durable across units; exception rolls back; no-commit persists nothing). pyright strict clean; AAA. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| applications | ||
| domain | ||
| infrastructure | ||
| orchestration | ||
| repositories | ||
| utilities | ||
| __init__.py | ||
| conftest.py | ||