feat(state): let the hub declare what instance it is
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Build and Publish Multi-Context Image / build-and-push (push) Successful in 24s

Answering on a port was the only evidence callers had that they had reached
the authoritative hub. A local cache and central both served port 8000,
separated only by IP family, and every default reached the cache for seven
weeks (ADR-010).

Adds instance_role and instance_label, surfaced on /state/health. The default
is "unknown" on purpose: an instance that has not declared itself is not the
primary. Production values declare primary/railiance01; the chart default
stays unknown because a chart can be installed anywhere.

statehub status now prints which instance answered.

Refs CUST-WP-0067-T03

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

Assistant: claude-code
Assistant-Model: opus
Assistant-Process: 2583210@bnt-lap001
Assistant-Session: f2bff2d5-e9b2-4338-92ca-10282a927006
This commit is contained in:
tegwick 2026-08-25 10:36:37 +02:00
parent b28493a676
commit 19fab26746
6 changed files with 32 additions and 1 deletions

View file

@ -7,6 +7,7 @@ from sqlalchemy import func, select, text
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import noload, selectinload
from api.config import settings
from api.database import get_session
from api.flow_defs import assertion_result_to_dict, load_flow
from api.models.capability_request import CapabilityRequest
@ -1108,7 +1109,13 @@ async def get_next_steps(session: AsyncSession = Depends(get_session)) -> list[N
async def health_check(session: AsyncSession = Depends(get_session)) -> dict:
try:
await session.execute(text("SELECT 1"))
return {"status": "ok", "db": "connected"}
return {
"status": "ok",
"db": "connected",
# Identity, so a caller can verify it reached the hub it meant to.
"instance_role": settings.instance_role,
"instance_label": settings.instance_label,
}
except Exception as exc:
return JSONResponse(
status_code=503,