diff --git a/src/k1link/service_watchdog.py b/src/k1link/service_watchdog.py index a2e9cfa..11c5df7 100644 --- a/src/k1link/service_watchdog.py +++ b/src/k1link/service_watchdog.py @@ -157,7 +157,7 @@ class MissionCoreSelfWatchdog: journal: MissionCoreWatchdogJournal | None = None, ) -> None: self.policy = policy or MissionCoreWatchdogPolicy() - self.probe = probe or _mission_core_health_probe( + self.probe = probe or _mission_core_liveness_probe( self.policy.probe_timeout_seconds ) self.request_shutdown = request_shutdown or _process_group_signal(signal.SIGTERM) @@ -232,7 +232,7 @@ def watchdog_enabled(environ: Mapping[str, str] = os.environ) -> bool: return environ.get(WATCHDOG_ENV) == WATCHDOG_ENABLED_VALUE -def _mission_core_health_probe(timeout_seconds: float) -> Probe: +def _mission_core_liveness_probe(timeout_seconds: float) -> Probe: def probe() -> bool: connection = http.client.HTTPConnection( "127.0.0.1", @@ -240,7 +240,7 @@ def _mission_core_health_probe(timeout_seconds: float) -> Probe: timeout=timeout_seconds, ) try: - connection.request("GET", "/api/health", headers={"Connection": "close"}) + connection.request("GET", "/api/liveness", headers={"Connection": "close"}) response = connection.getresponse() payload = response.read(64 * 1024 + 1) except (OSError, TimeoutError, http.client.HTTPException): @@ -256,7 +256,7 @@ def _mission_core_health_probe(timeout_seconds: float) -> Probe: return bool( isinstance(document, dict) and document.get("ok") is True - and document.get("status") == "ok" + and document.get("status") == "alive" and document.get("service") == MISSION_CORE_SERVICE_ID ) diff --git a/src/k1link/web/app.py b/src/k1link/web/app.py index a0e87c6..2b73b9f 100644 --- a/src/k1link/web/app.py +++ b/src/k1link/web/app.py @@ -528,6 +528,17 @@ async def request_validation_error_handler( return JSONResponse(status_code=422, content={"detail": INVALID_REQUEST_DETAIL}) +@app.get("/api/liveness") +async def liveness() -> dict[str, object]: + """Prove only that the canonical event loop is responsive.""" + + return { + "ok": True, + "status": "alive", + "service": "mission-core-control-plane", + } + + @app.get("/api/health") def health() -> dict[str, Any]: return build_runtime_readiness(