aucourt-ingest/aucourt_ingest/api/dependencies.py
slothitude f799b41ed9 Resolve all deferred audit findings: type safety, async, isolation, dates
- #11 VectorIndexProtocol for typed duck-typing of vector_index param
- #10 Wrap all sync VectorIndex.query() calls in asyncio.to_thread
- #9 Make vector_search async (consistent with to_thread wrapping)
- #12 Replace module-level singleton with app.state.query_service
- #13 InMemoryGraphDB.close(destroy=False) guard for test safety
- #14 Parse dates with datetime.fromisoformat in list_cases sort

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-30 12:20:56 +10:00

14 lines
377 B
Python

"""FastAPI dependency providers."""
from __future__ import annotations
from fastapi import Request
from aucourt_ingest.api.service import QueryService
def get_query_service(request: Request) -> QueryService:
svc = request.app.state.query_service
if svc is None:
raise RuntimeError("QueryService not initialised — call create_app() first")
return svc