Part V · Contracts · Plate 01
Thalamus HTTP API
1. Thalamus HTTP Relay Contract (node-d:18000)
Illustrative deployment: node names, ports, model ids and seed-service counts in this section describe an example topology, not a live inventory or required hardware. Configure actual endpoints and discover available models through the documented interfaces. Wire formats and endpoint-resolution rules are the contract; the example fleet is not a default configuration.
1.1 Endpoint Resolution Order (THALAMUS_URL)
Every CNS organ (Engram, Axon, Soma, Cortex) requires an explicit endpoint. There is no default endpoint and no default model name in any organ. Cortex's direct route exists only when CORTEX_FALLBACK_* is configured. The precedence chain is:
- Explicit tool/organ override environment variable (
ENGRAM_EMBEDDING_ENDPOINT,ENGRAM_RERANKER_ENDPOINT,AXON_EMBED_URL,AXON_RERANK_URL). - Explicit manifest/CLI configuration (
retrieval.embedding_endpoint,retrieval.reranker.endpoint,--embed-url,--rerank-url). THALAMUS_URLenvironment variable ({THALAMUS_URL}/v1/embeddings,{THALAMUS_URL}/v1/rerank,{THALAMUS_URL}/v1/systemone,{THALAMUS_URL}/v1/chat/completions), for examplehttp://thalamus.example:18000.
With none of these set, a remote provider is an error that names the missing setting (Engram, Axon) or an unrouted route that makes no request (Cortex); local providers (local-hash, Axon auto/local) never leave the machine. The address of the Thalamus this deployment uses is this deployment's configuration and lives under deploy/fleet/.
No implicit fallback. Soma (§5.2), cns and the Pi extension require the operator's explicit relay configuration. With THALAMUS_URL unset:
cns statusprints[1] Thalamus : not configured (THALAMUS_URL not set) WARN; if nothing else is red, the result isSTATUS: WARN, exit 0 (neither red nor green).cns initmakes no relay request and writes Git hooks carrying no address.cns gatewith rubric opt-in printsrubric: not evaluated (THALAMUS_URL not set)and exits 3.- The Pi extension sets no
THALAMUS_URLfor itself or its spawned gate and registers nothalamusprovider.
cns init and cns curate: axon anchors embed runs only when THALAMUS_URL or AXON_EMBED_URL is set; otherwise they print embed: not configured.
cns init renders .engram/ote.toml from harnesses/pi/ote.example.toml, never copying template endpoints:
- With
THALAMUS_URL, it setsretrieval.embedding_endpointto${THALAMUS_URL}/v1/embeddingsandretrieval.reranker.endpointto${THALAMUS_URL}/v1/rerank. - Without it, every
retrieval*table is replaced by local-only configuration (embedding_provider = "local-hash", rerankerenabled = false,provider = "none"), and init reports this. - Any other URL remaining in the rendered manifest makes init refuse to write it and name the URL. An existing
.engram/ote.tomlis never rewritten.
1.2 Data-Plane Endpoints
| Endpoint | Plane | Target Models & Nodes | Request / Response Contract |
|---|---|---|---|
POST /v1/chat/completions |
Plane::Intelligence (system2) |
Qwen/Qwen3.8-Flash-Next on node-a, node-b, node-c (:8000) |
OpenAI-compatible JSON or SSE stream. Supports x-session-id / x-agent-session-id header or deterministic prompt-prefix SHA-256 session pinning. Emits x-thalamus-node, x-thalamus-sticky-hit, x-thalamus-work-stolen, and x-thalamus-queue-wait-ms response headers. |
POST /v1/systemone (alias /v1/system1/decide) |
Plane::Verification (system1) |
clef-flash on node-d:8000 |
Stateless rubric evaluation. Request: {"model": "clef-flash", "state": "<diff or context>", "questions": {"q1": {"type": "noul" \| "choice" \| "score", "question": "<rubric>"}}}. Response: {"model": "clef-flash", "answers": {"q1": {"type": "noul", "noul": 0.0001}}, "usage": {...}}. |
POST /v1/embeddings |
Plane::Knowledge (retrieval) |
qwen3-embedding-8b on node-d:8001 |
OpenAI-compatible batch embedding request: {"model": "qwen3-embedding-8b", "input": ["..."]}. Returns 4096-dim (or caller-sliced/L2-normalized) float vectors in data[].embedding. |
POST /v1/rerank (alias /rerank) |
Plane::Knowledge (retrieval) |
qwen3-reranker-8b on node-d:8002 |
Cross-encoder scoring: {"model": "qwen3-reranker-8b", "query": "...", "documents": ["..."]}. Returns {"results": [{"index": 0, "relevance_score": 0.9805, ...}]}. |
1.3 Control-Plane Endpoints
GET /admin/v1/status(aliasGET /lb/status): Returns live cluster health across all 6 seed services (3System 2 nodes +3co-locatednode-dcognitive servers), active session pins, work-steal counters, admission queue wait metrics, and per-node Prometheus KV-cache telemetry.GET /admin/v1/members: Lists registered seed and dynamic cluster members from the configuredmembers.jsonstate file (for example~/.local/state/thalamus/members.json).POST /admin/v1/register&POST /admin/v1/drain: Dynamic node self-registration and graceful drain control.GET /health:status,healthy_members,total_members, and (S8)telemetry, which isenabled (<path>),degraded (<n> write error(s), ...)ordisabled (<reason>). A disabled or degraded store never changes routing and never changesstatus; readers that care about history must readtelemetry(see 1.4).name_conflicts(Thalamus, S2 part C): an array of strings, one per model id or alias declared on more than one plane (including names a probe learned from an upstream), each sentence naming both members. Reader:cns status[1] (S2 task 57, landed in S7): a non-empty list renders[1] Thalamus : WARN name-conflicts (<n>)followed by onename-conflict: <entry>line per entry (control characters shown as spaces), andSTATUS: WARN (thalamus: name-conflicts (<n>) ...)when nothing is red; an empty list isONLINE; on an unhealthy Thalamus the list is still shown and the line staysUNHEALTHY(red); a field that is not an array of strings isUNREADABLE name_conflicts(red); a Thalamus without the field is not reported.
1.4 Durable Request Telemetry ($THALAMUS_STATE_DIR/telemetry.db, S8)
Writer: thalamus serve (one row per completed request, written off the routing path). Reader: thalamus replay --since <ts> [--node <name>] [--json], which reads the file directly and works while Thalamus is down. Routing never reads this data.
| Column | Type | Meaning |
|---|---|---|
ts |
INTEGER |
Completion time, unix milliseconds. |
node / plane |
TEXT |
Member that served the request; intelligence, verification or knowledge. |
session_fp |
TEXT |
First 16 hex chars of SHA-256 of the session id; NULL on stateless planes. The id itself is never stored. |
ttft_ms / latency_ms |
REAL |
Time to first token (NULL when unknown) and total latency. |
prompt_tokens / completion_tokens |
INTEGER |
From the upstream usage block; NULL for streamed responses. |
kv_hit |
INTEGER |
1 if prompt_tokens_details.cached_tokens > 0, 0 if it was zero, NULL when the upstream reported nothing. |
error |
TEXT |
http_<status> for status >= 400, else NULL. |
stolen |
INTEGER |
1 if contention-aware work stealing moved the session. |
Retention: --telemetry-retention-days (default 30), applied at startup and hourly against the wall clock. Rows stamped in the future are kept and counted in /health (telemetry_detail.future_dated_rows). replay exit codes: 0 ok, 1 unreadable, 2 bad arguments, 3 absent (no telemetry.db).