Repository navigation
refactor(llc/api): shared get_session + service_dep DI helper across routers (#9843) - #9994
Merged
Merged
Conversation
…routers (#9843) Introduces llc/deps.py with two shared helpers: - get_session(): bare async session (no auto-commit; callers manage transactions explicitly) — exact same lifecycle as the per-router copy-paste it replaces - service_dep(SvcClass): lru_cache-backed factory returning a zero-arg FastAPI Depends-compatible callable per service class Migrated 8 routers: approvals, backlog, boards, controls, labels, review_gate_policies, routines, work_items. companies.py left as-is (session-scoped service construction, different shape). budget.py already used get_async_session (full-lifecycle), no change needed. Placed at llc.deps (not llc.api.deps) to avoid triggering llc.api.__init__ when a router module is loaded in isolation via importlib in tests (which caused a circular import). Tests: 54 failed, 739 passed, 31 errors (identical to pre-refactor baseline). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…ort, document app-wide override (#9843) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
✅ SSOT Configuration Compliance: Passing🎉 No hardcoded values detected that have SSOT config equivalents! |
Applied Black, isort, and autoflake to match code-quality checks. Triggered by workflow auto-fix-formatting.yml. Co-Authored-By: Paperclip <noreply@paperclip.ing>
30 tasks done
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.
Thinking Path
8 LLC route modules carried an identical copy-pasted pair: a bare-yield
get_sessionand alazy_singleton-backed_service(). Consolidated intollc/deps.py— deliberately NOTllc/api/deps.py(importing throughllc.api.__init__re-imports every router and breaks the isolatedspec_from_file_locationloads in test_routine), and deliberately NOTuser_management.database.get_async_session(that one auto-commits; these routers manage transactions explicitly — swapping would change semantics).What Changed
llc/deps.py: sharedget_session(bare yield, per-request factory acquisition — exact copy of the removed per-router pattern) +service_dep(service_cls)(lru_cached per class, wrapslazy_singleton)get_session/_servicedefscompanies.py(session-scoped service construction — different shape),budget.py(already uses full-lifecycleget_async_session)patch('llc.api.backlog.get_async_session_factory')dropped from test_backlog (symbol no longer exists there — test was silently broken in isolation), deps import hoisted to work_items' import block, app-wide-override note added toget_sessiondocstringVerification
llc/testsslice: 54 failed / 739 passed / 30 errors — byte-identical FAILED list pre/post refactor (md5-compared by reviewer); zero new failurestest_backlog.pyisolated: the DI-dependent test (test_get_backlog_calls_service) passes; 2 remaining failures are pre-existing on baseModel Used
Fable 5 (main session) + Sonnet sub-agents (implementation + independent review)
Fixes #9843
🤖 Generated with Claude Code