47f7a85510
Die Ampel-Nachruestung deckte 317/337 vorbestehende ruff-Verstoesse im ganzen Repo auf. Aufgeraeumt: - ruff.toml: intentionale Muster als Projekt-Politik ausgenommen (BLE001 blind-except, S110/S112 try-except-pass/continue, PLW1510 subprocess-best-effort, B008 FastAPI- Depends/File-Idiom, EXE001 Shebang, + wenige Stil-Regeln). __init__.py-Re-Exports geschuetzt (F401). - ruff --fix: 128 mechanische (Import-Sortierung, PEP585/604-Annotationen, tote Imports, ueberfluessige noqa) auto-behoben. - 12 echte Reste von Hand: PERF402/102, PLC3002 (Lambda->walrus), ISC004 (String-Concat geklammert), F841/RUF059 (ungenutzte Vars), PIE810 (startswith-Tuple), UP031 (f-string), UP035 (veraltete typing-Imports). Ergebnis: 'ruff check .' = 0, 'compileall' grün. Kein Verhaltenswechsel (nur Stil/Modernisierung). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
30 lines
886 B
Python
30 lines
886 B
Python
"""Health-/Status-Endpoint — schlanker Lebenszeichen-Check für MC 2.0."""
|
|
|
|
from config import VERSION
|
|
from fastapi import APIRouter
|
|
from pydantic import BaseModel
|
|
from services import gateway, llamaswap
|
|
|
|
router = APIRouter(prefix="/api")
|
|
|
|
|
|
class HealthResponse(BaseModel):
|
|
status: str
|
|
version: str
|
|
engine_reachable: bool
|
|
gateway_reachable: bool
|
|
brain: dict
|
|
|
|
|
|
@router.get("/health", response_model=HealthResponse)
|
|
def health() -> dict:
|
|
return {
|
|
"status": "ok",
|
|
"version": VERSION,
|
|
"engine_reachable": llamaswap.engine_reachable(),
|
|
"gateway_reachable": gateway.gateway_reachable(),
|
|
# Echte Hirn-Bereitschaft: Engine kann erreichbar sein, das Agent-Hirn ('fast') aber tot
|
|
# (Crash/OOM nach Engine-Update). Das wäre sonst ein silent fail (App-Fehler statt Status).
|
|
"brain": llamaswap.brain_status(),
|
|
}
|