"""Loop QA health endpoints — capability self-test status.""" import logging from fastapi import APIRouter, Request from fastapi.responses import HTMLResponse, JSONResponse from dashboard.templating import templates logger = logging.getLogger(__name__) router = APIRouter(tags=["health"]) @router.get("/health/loop-qa") async def loop_qa_health(): """Return HealthSnapshot as JSON.""" from timmy.loop_qa import loop_qa_orchestrator snapshot = loop_qa_orchestrator.get_health_snapshot() return JSONResponse(content=snapshot) @router.get("/health/loop-qa/partial", response_class=HTMLResponse) async def loop_qa_health_partial(request: Request): """Return HTMX partial for the dashboard health panel.""" from timmy.loop_qa import loop_qa_orchestrator snapshot = loop_qa_orchestrator.get_health_snapshot() return templates.TemplateResponse( request, "partials/loop_qa_health.html", {"snapshot": snapshot}, )