forked from Rockachopa/Timmy-time-dashboard
Structured self-test framework that probes 6 capabilities (tool use, multistep planning, memory read/write, self-coding, lightning econ) in round-robin. Reuses existing infra: event_log for persistence, create_task() for upgrade proposals, capture_error() for crash handling, and in-memory circuit breaker for failure tracking. - src/timmy/loop_qa.py: Capability enum, 6 async probes, orchestrator - src/dashboard/routes/loop_qa.py: JSON + HTMX health endpoints - HTMX partial polls every 30s on the health panel - Background scheduler in app.py lifespan - 25 tests covering probes, orchestrator, health snapshot, routes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35 lines
978 B
Python
35 lines
978 B
Python
"""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},
|
|
)
|