Skip to content

refactor(llc/api): shared get_session + service_dep DI helper across routers (#9843) - #9994

Merged
mrveiss merged 4 commits into
Dev_new_guifrom
issue-9843
Jun 11, 2026
Merged

mrveiss merged 4 commits into
Dev_new_guifrom
issue-9843

Conversation

@mrveiss

@mrveiss mrveiss commented Jun 11, 2026

Copy link
Copy Markdown
Owner

Thinking Path

8 LLC route modules carried an identical copy-pasted pair: a bare-yield get_session and a lazy_singleton-backed _service(). Consolidated into llc/deps.py — deliberately NOT llc/api/deps.py (importing through llc.api.__init__ re-imports every router and breaks the isolated spec_from_file_location loads in test_routine), and deliberately NOT user_management.database.get_async_session (that one auto-commits; these routers manage transactions explicitly — swapping would change semantics).

What Changed

  • NEW llc/deps.py: shared get_session (bare yield, per-request factory acquisition — exact copy of the removed per-router pattern) + service_dep(service_cls) (lru_cached per class, wraps lazy_singleton)
  • Migrated: approvals, backlog, boards, controls, labels, review_gate_policies, routines, work_items — zero residual local get_session/_service defs
  • NOT migrated (deliberate): companies.py (session-scoped service construction — different shape), budget.py (already uses full-lifecycle get_async_session)
  • Review fixes: stale 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 to get_session docstring

Verification

  • Full llc/tests slice: 54 failed / 739 passed / 30 errors — byte-identical FAILED list pre/post refactor (md5-compared by reviewer); zero new failures
  • test_backlog.py isolated: the DI-dependent test (test_get_backlog_calls_service) passes; 2 remaining failures are pre-existing on base
  • Independent code-reviewer round (REQUEST_CHANGES → all findings fixed); parity verified per-module incl. controls.py partial migration
  • flake8 + py_compile clean

Model Used

Fable 5 (main session) + Sonnet sub-agents (implementation + independent review)

Fixes #9843

🤖 Generated with Claude Code

mrveiss and others added 2 commits June 11, 2026 19:21
…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>
@github-actions

github-actions Bot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

✅ SSOT Configuration Compliance: Passing

🎉 No hardcoded values detected that have SSOT config equivalents!

github-actions Bot and others added 2 commits June 11, 2026 17:11
Applied Black, isort, and autoflake to match code-quality checks.
Triggered by workflow auto-fix-formatting.yml.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
@mrveiss
mrveiss merged commit e04b019 into Dev_new_gui Jun 11, 2026
21 of 22 checks passed
@mrveiss
mrveiss deleted the issue-9843 branch June 11, 2026 18:30
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