Skip to content

Editor

Protocol

Editor requests, responses, events, transports, access tokens, and audit records.

Headers

File Description Provides
access_token.h The secrets of the AI control protocol: what a token grants, how one is generated, where it is written for clients, and the comparisons that do not leak it: every place that holds a token against text a client sent uses one of the constant_time_ functions below. The protocol server owns the tokens; nothing here logs or stores one.
audit_log.h The audit log of the AI control protocol: one line of JSON per command a transport client had dispatched, appended to <project>/.conjure/ai_audit.log. The protocol server owns the log and decides what is recorded; this class formats a record, keeps tokens out of it and keeps the files bounded. Main thread only. audit_entry
audit_log
event_broadcaster.h Events: one monotonic sequence shared by every client, a subscription bitmask per client (default everything except log and command.executed) and a sink per client that receives the protocol_event. The protocol server registers its remote clients here; the local UI and the headless runner register with in-process sinks. event_broadcaster
event_broadcaster::client
line_splitter.h Newline framing: bytes arrive in arbitrary chunks; complete lines come out one at a time with a trailing '\r' removed. A single line that grows past the limit without a newline is replaced by an OVERSIZED marker at its position in the stream and sets the overflow flag: the transport answers MESSAGE_TOO_LARGE and disconnects the client; the rest of the oversized line is discarded until the next newline. The limit applies to one line only, never to the complete lines that were framed but not yet taken. line_splitter
line_splitter::framed_line
loopback_transport.h The in-process transport: tests and the AI session panel connect a loopback_client, write lines into it and read the responses and events back, all on the main thread (a mutex still guards the queues so a test may drive a client from a job). loopback_client
loopback_transport
protocol_message.h The wire messages: newline-delimited JSON, UTF-8, at most MAX_MESSAGE_BYTES per line. Requests carry a caller id (integer, string or null, echoed verbatim), a command name and an object of arguments; responses echo the id and carry either a result or an error; events carry the monotonic sequence number and the frame they were emitted in. protocol_event
protocol_request
protocol_response
protocol_server.h The protocol server: owns the transports, the per-client state (access, open transaction bookkeeping is the undo stack's), parses inbound lines into requests, serialises responses and events, applies the token handshake, the first-line rule, the MESSAGE_TOO_LARGE disconnect and the backlog policy (drop log events above 8 MiB, disconnect above 64 MiB), and keeps the audit log of the commands its clients had dispatched. Main thread only: the transports report connects and disconnects through poll() on that thread (the stdio reader thread only fills its own queue), so the client list and the counts read from it need no lock. client_state
protocol_server
protocol_transport.h A transport moves complete lines between clients and the protocol server on the main thread: poll() reports connects, lines and disconnects since the last call; send() queues a line; flush() writes what the peer accepts without blocking. Client ids come from the server through the allocator so every transport's clients share one id space. inbound_line
protocol_transport

Breakdown

The protocol exposes editor commands through newline-delimited JSON requests, responses, and events. protocol_message defines the messages, line_splitter handles framing, and protocol_transport separates message delivery from command processing. loopback_transport supports in-process clients and tests.

protocol_server coordinates clients, dispatch, replies, and transport lifecycle. Access tokens establish per-client access levels, audit_log records command activity, and event_broadcaster delivers subscriptions. These are editor services implemented by conjure::editor_core.

Important

Keep access-token values out of logs, command replies, events, and audit records. The access checks and redaction helpers belong to the protocol implementation; callers should use them consistently.

See Editor Architecture for the handshake, transport behaviour, access checks, and audit lifecycle.