Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,26 @@ async def lifespan(app: FastAPI):


@app.get("/health")
def health(): return {"status": "ok"}
def health():
return {"status": "ok"} # liveness — am I up?


@app.get("/health/ready")
def ready(request: Request):
# readiness — can I actually serve a claim? check deps.
checks = {}
try:
checks["mcp_host"] = bool(request.app.state.host.tools)
except Exception:
checks["mcp_host"] = False
try:
from services.index.store import get_index
get_index().describe_index_stats()
checks["pinecone"] = True
except Exception:
checks["pinecone"] = False
ok = all(checks.values())
return {"status": "ready" if ok else "degraded", "checks": checks}


@app.middleware("http")
Expand Down
15 changes: 15 additions & 0 deletions services/common/log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import logging
import sys

import structlog

logging.basicConfig(format="%(message)s", stream=sys.stdout, level=logging.INFO)
structlog.configure(processors=[
structlog.processors.add_log_level,
structlog.processors.TimeStamper(fmt="iso"),
structlog.processors.JSONRenderer(), # machine-readable JSON lines
])
log = structlog.get_logger()

# usage anywhere:
# log.info("claim_decided", claim_id=cid, decision=d, approver=a, latency_ms=ms)
Loading