#!/usr/bin/env python3 import os import time from fastapi import FastAPI from pydantic import BaseModel APP_NAME = os.getenv("APP_NAME", "HiveSeedAPI") START_TS = time.time() app = FastAPI(title=APP_NAME) class Health(BaseModel): status: str uptime_seconds: float class Ready(BaseModel): ready: bool reason: str | None = None @app.get("/healthz", response_model=Health) def healthz() -> Health: return Health(status="ok", uptime_seconds=time.time() - START_TS) @app.get("/readyz", response_model=Ready) def readyz() -> Ready: # Minimal readiness: enumerations exist or DRY_RUN enabled base = os.path.join(os.path.dirname(__file__), "..", "..", "daemon", "enumerations") files = [ os.path.join(base, "math_model_500.txt"), os.path.join(base, "agent_500.txt"), os.path.join(base, "language_500.txt"), os.path.join(base, "prophecy_500.txt"), ] if all(os.path.isfile(p) for p in files): return Ready(ready=True) if os.getenv("DRY_RUN", "0").lower() in {"1", "true", "yes", "on"}: return Ready(ready=True, reason="DRY_RUN enabled") return Ready(ready=False, reason="Enumerations missing; run make enumerations")