Expand description
Server-side session state — shared across all connections.
Structs§
- Approval
Gate - Builder for constructing a
ServerStatewith embedder-supplied dependencies. Embedders (e.g.tokhn-daemon) use this to inject their own memgine handle and other shared infrastructure; the Approval-gate policy for high-risk WS methods. - Chat
Collector - An in-process
agent.chatcollector entry: the sink thattry_forward_agent_chat_eventfeeds, plus the host client whose disconnect should abandon it. Holding the sole sender here means dropping the entry closes the stream, so the collecting task wakes immediately instead of waiting out its timeout. - Chat
Goal State - Host-visible standing goal for a chat session.
goal.setstores this keyed bysession_id;agents.chatreuses it for that session when the turn does not pass an inlinegoal. - Chat
Session - In-flight
agents.chatsession bookkeeping. Created when a host client callsagents.chat, removed when the agent emits a terminalagent.chat.event(kind: "done"or"error"), when either side disconnects, or when the host cancels viaagents.chat.cancel. - Chat
Stream Chunk - One normalized chunk of an
agent.chatstream, delivered to an in-processchat_collectorssink (the A2A bridge). Atokenchunk carries adelta; a terminal chunk haskind"done"(success),"error"(witherrortext), or"auth_required"(withmessagetext — the turn was refused because of the Parslee account, and nothing follows it on the wire). - Client
Session - Per-client session.
- Last
Chat Turn - The last assistant turn a chat session produced, remembered so the next
user turn can be classified against it (the conversation-outcome signal).
The
trace_id/model_idare carried straight from theInferenceResultthat produced the turn — never reconstructed from message order — so credit always lands on the exact model/trace that generated the judged turn. - OrgSync
Holder - The opted-in shared org-scope delivery subsystem + which org it serves. See
ServerState::org_sync. Held behind the samestd::sync::Mutexas the personal subsystem holder (init is serialized by the oplog’s advisory lock); the subsystem itself lives behind atokio::sync::Mutex. - RunMeta
- Daemon-side record of a single agent run (agent run tracing, U1).
- Server
State - Global server state shared across all connections.
- Server
State Config - standalone
car-serverbinary usesServerState::standalonewhich callswith_configunder the hood. - Substrate
Shadow Executor - Executor wrapper used only by substrate-bound sessions
(
session.bindSubstrate). It is the low-blast-radius “option (a)” fromdocs/execution-substrate.md§3: keep the existingshare_with_fallback(ws_executor)composition intact for connector routes and host tool callbacks, but for the bare substrate-owned built-in names ([SUBSTRATE_OWNED_TOOLS]) return an"unknown tool: <name>"error so the engine’s dispatch (executor.rs) takes thefall_throughbranch and routes those names to the runtime’s bound substrate (the connector/VMcar_engine::McpSubstrate) instead of the WS client. - WsChannel
- Shared write half of the WebSocket, plus pending callback channels.
writeis type-erased viaWsSinkso the dispatcher can run against any transport-specific WebSocketStream (TCP or UDS today; axum-bridged in future) without templatizing every consumer. - WsMemgine
Ingest Sink - Per-meeting fanout sink that ingests transcript text into a
session-scoped memgine using the
Arc<tokio::sync::Mutex<...>>wrapper, then forwards every event upstream untouched. - WsTool
Executor - Tool executor that sends callbacks to the client over WebSocket.
- WsVoice
Event Sink - Voice event sink that forwards events to a specific WebSocket client
as
voice.eventJSON-RPC notifications.
Enums§
- A2aRoute
Auth - Server-side credentials for continuing an A2A-owned A2UI surface.
- Record
RunTurns Outcome - Outcome of
ServerState::record_run_turns— distinguishes the three reasons a batch can fail to land so the caller maps each to the rightruns.record_turnsdrop reason (ADV-1). Before this enum the function returned a bareusize(the new total, or0for “nothing appended”), which collapsed an under-lock CEILING refusal and an unknown/terminal run into the same0— the handler then mislabeled a ceiling refusal asrun_terminal. - RunReservation
Constants§
- DEFAULT_
TOOL_ TIMEOUT_ MS - Default ceiling for the daemon→host
tools.executecallback wait when an action carries no explicittimeout_ms. Overridable viaCAR_TOOL_TIMEOUT(seconds). Raised from the old hardcoded 60s — real tools (build steps, CLI drivers, slow APIs) routinely run longer, and a 60s ceiling reaped them regardless of the agent’s budget (Parslee-ai/car#259). - RECORD_
TURNS_ RUN_ CEILING - Per-run turn ceiling — a runaway-loop backstop sized well above any
healthy main-agent-only cycle (tens of turns), never a trimmer. This is
a TRUE hard cap, and it is enforced HERE — inside
ServerState::record_run_turns, under therunslock — not only in the WS handler’s pre-check. The handler keeps a fast-path pre-check off a lock-free snapshot, but the dispatcher spawns a task per frame, so pipelinedruns.record_turnsbatches can all read a sub-ceiling snapshot and pass that pre-check before any of them appends. Only the under-lock check below is atomic with the append, so it is the one that actually bounds the run (ADV-1). A batch that would take the run PAST this many recorded turns is refused WHOLE. - RUN_
COMPLETE_ GRACE - Grace window applied on disconnect before a still-open run is marked
Incomplete(agent run tracing, U1 — R5). Short on purpose: it only has to cover the gap between a healthyruns.completebeing dispatched on a spawned task and its terminal record landing, not any real work. Long enough to absorb that scheduling jitter, short enough that a genuinely abandoned run is reportedIncompletepromptly. - RUN_
DISCONNECT_ CLEANUP_ TIMEOUT - Per-run observation bound for disconnect cleanup: the ten-second resume lease, two bounded five-second journal acknowledgement attempts (the second is an exact retry after durability-unknown), and scheduler headroom. Cleanup never clears the run or binding unless an acknowledgement arrives.
- RUN_
RESUME_ LEASE - Bounded in-process lease for a disconnected run whose producer negotiated
runs.resume.v1. Ten seconds leaves practical headroom for a loaded Mac’s Python controller to establish a fresh local socket, authenticate, and negotiate capabilities without turning this into restart recovery. Runs without the capability keep the original 250 ms behavior; an unclaimed resumable run still becomesIncomplete. - SESSION_
HALTED_ REASON - Stable admission reason returned after a callback terminally halts its
WebSocket session. The halt is intentionally connection-local and dies on
reconnect; durable run outcomes remain the responsibility of
runs.complete.
Type Aliases§
- WsSink
- Type-erased WebSocket sink. The dispatch loop accepts either a
WebSocketStream<TcpStream>(the legacy car-server TCP listener) or aWebSocketStream<UnixStream>(the daemon-as-default UDS listener) — both implementSink<Message, Error = WsError>after the tungstenite handshake. Erasing the type here avoids cascading a generic parameter through every WsChannel / Session / ServerState touchpoint in the dispatcher.