Skip to content

docs(adr): propose backend DB-pool access unification (ADR 0016)#106

Merged
miquelmatoses merged 1 commit into
mainfrom
docs/adr-db-pool-unification
Jun 23, 2026
Merged

docs(adr): propose backend DB-pool access unification (ADR 0016)#106
miquelmatoses merged 1 commit into
mainfrom
docs/adr-db-pool-unification

Conversation

@miquelmatoses

Copy link
Copy Markdown
Collaborator

ADR 0016 (status Proposed, docs-only) for consolidation audit item #11.

Problem

Three coexisting pool-acquire idioms, all resolving to the same pool:

  • request DI request.app.state.pool.acquire() (deps.py 1, blog.py 7)
  • module-global _pool.acquire() (main.py, 30 sites)
  • lazy _pool() doing from main import _pool (auth.py, 8 sites)

Plus the main <-> auth import cycle (main.py:46 imports auth at load), which is why auth.py uses the lazy re-import.

Proposal

One canonical deps.get_pool() reading a holder set at startup, importing nothing from main, so auth.py can drop the lazy from main import _pool with no cycle. app.state.pool stays as the request-DI reference for deps.py/blog.py. ~38 call sites change (main.py 30, auth.py 8); behavior-affecting, must land behind backend tests. Runtime equivalence is explicitly UNVERIFIED (LOW) until implemented.

No code or call sites changed in this PR. Implementation is a separate future prompt after operator sign-off; the ADR stays Proposed.

🤖 Generated with Claude Code

Records audit item #11: three coexisting pool-acquire idioms (request DI in
deps.py/blog.py, module-global _pool in main.py x30, lazy `from main import
_pool` in auth.py x8) plus the main<->auth import cycle that forces the lazy
re-import. Proposes one canonical deps.get_pool() accessor reading a holder set
at startup and importing nothing from main, which removes the cycle without
changing startup order. Status Proposed; runtime equivalence is unverified until
implemented behind the backend tests. No call sites changed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@miquelmatoses miquelmatoses merged commit 2d2c3cf into main Jun 23, 2026
7 checks passed
@miquelmatoses miquelmatoses deleted the docs/adr-db-pool-unification branch June 23, 2026 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant