generated from john/python-template
1.2 KiB
1.2 KiB
ADR-0001: Lifespan-owned runtime resources
- Status: accepted
- Date: 2026-06-25
Context
MVP initialized core runtime resources (database engine and worker dependencies) through module-level globals and startup side effects. REQ-7 requires lifespan-owned runtime resources with explicit ownership and cleanup.
Decision
Adopt lifespan-owned runtime resource initialization in transcription.app:
- Initialize database runtime during app lifespan startup.
- Store runtime handles on
app.state. - Pass runtime-owned dependencies (engine) to worker startup.
- Dispose runtime resources explicitly during lifespan shutdown.
Consequences
Positive
- Explicit startup and shutdown ownership.
- Predictable cleanup ordering.
- Reduced hidden global side effects.
Tradeoffs
- Minor wiring complexity in app startup.
- Some call-sites still support fallback lazy initialization for compatibility.
Alternatives Considered
- Keep module-level global ownership
- Rejected: conflicts with
REQ-7and increases ambiguity.
- Rejected: conflicts with
- Introduce full async DB stack immediately
- Rejected for Step 1: too broad for architecture-consolidation scope.