docs(adr): propose backend DB-pool access unification (ADR 0016)#106
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ADR 0016 (status Proposed, docs-only) for consolidation audit item #11.
Problem
Three coexisting pool-acquire idioms, all resolving to the same pool:
request.app.state.pool.acquire()(deps.py 1, blog.py 7)_pool.acquire()(main.py, 30 sites)_pool()doingfrom main import _pool(auth.py, 8 sites)Plus the
main<->authimport cycle (main.py:46imports 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 frommain, so auth.py can drop the lazyfrom main import _poolwith no cycle.app.state.poolstays 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