Repository navigation
Backend_Telemetry
backend/ is the FastAPI bridge between the cognitive loop and the Face & Brain UI. The loop POSTs
telemetry in; the UI reads it over REST and a WebSocket stream.
-
backend/server/app.py— the FastAPI app; serves the built UI (frontend/dist) in packaged mode. -
backend/server/hub.py— the WebSocket hub: buffers state and fans it out to connected clients. -
backend/server/bridge.py— the in-processjs_apibridge used by the native (pywebview) window, which needs no open port at all. -
backend/server/state.py— canonical serialized runtime state. -
backend/server/schema.py+generate_telemetry_ts.py— the telemetry schema, from which the frontend's TypeScript types are generated (one source of truth for both sides). -
backend/server/lifecycle.py/launcher.py/tray.py— startup/shutdown wiring and the desktop tray.
Most frame fields are latest-wins blobs the hub overwrites (schema.LATEST_WINS_KEYS). Four are
append rings, where arrival order is the point and the delta carries only what is new: logs,
memory, metrics (as chart points), and voice — the transcript of Orrin's own utterances that
the UI's Voice room renders. The hub seeds its voice ring from the durable
voice_transcript.jsonl, so opening the room shows what he already said this life rather than
waiting on the next line.
backend/server/routers/ splits the API by surface: telemetry (read state), control
(stop/steer — gate with ORRIN_CONTROL_TOKEN), memory, cognition, agent, settings
(provider keys → OS keychain), quality_standard (ratification UI), diagnostics,
runtime_coupling, source, and update.
backend/server/auth.py enforces three independent tokens, all zero-config on loopback:
-
ORRIN_READ_TOKEN— required for REST + WebSocket reads from non-loopback clients (frontend sendsVITE_READ_TOKEN). -
ORRIN_INGEST_TOKEN— required onPOST /ingestso a remote-exposed backend only accepts telemetry from the real loop. -
ORRIN_CONTROL_TOKEN— required on/api/control/*(e.g. the Stop button).
ORRIN_EXTRA_ORIGINS allowlists additional browser origins (tunnels); the local Vite origin and
the backend host are trusted automatically.
- Native bridge mode (default, packaged): pywebview window + in-process bridge, no port.
-
Browser/API mode: backend binds
ORRIN_BACKEND_HOST/ORRIN_BACKEND_PORT(dev default 8800; native mode uses an OS-assigned free port unless pinned). -
Prometheus (opt-in):
ORRIN_METRICS=1starts the exporter inobservability/(Docker pins9100).
-
backend/server/— everything above -
frontend/src/lib/— the client that consumes the stream -
docs/CONFIGURATION.md— ports, tokens, and remote-access detail
- Cognitive Loop
- Workspace & Ignition
- Binding & Writeback
- Thinking & Action Selection
- Learning & Adaptation
- Effect Ledger
- Quality Standard
- Expression Membrane
- Self-Code
- Native Language Model
- Existence & Lifecycle