"""GET /health -- passive health-check endpoint. Returns a structured snapshot covering service health (process, cycle lag, queue state) and data health (last compare result, drift traces, dead rows). HTTP status follows the body's ``status`` field so off-the-shelf monitors that alert on status code work without parsing JSON: * ``200`` -- healthy * ``503`` -- degraded or unhealthy This keeps "service unreachable" (network/down) distinguishable from "service up but needs attention" (200 would conflate them). """ from __future__ import annotations from fastapi import APIRouter, Depends, Response from ..deps import get_checker from ...health import HealthChecker router = APIRouter() @router.get("/health", summary="Sync service health check") def health(response: Response, checker: HealthChecker = Depends(get_checker)) -> dict: snap = checker.snapshot() # Map body status to HTTP code for code-based alerting. if snap["status"] != "healthy": response.status_code = 503 return snap