Skip to main content

Module control

Module control 

Source
Expand description

The control plane (spec 3.2 §7.11).

One API, three transports: a Unix domain socket at the kernel home (macOS, Linux) or a named pipe named after it (Windows, §10 W2), each of which trusts the OS user, and HTTP on loopback or, with authentication, on the network. Surfaces hold no state (K-I17); every control action carries an authenticated subject and is audited as kernel.control (K-I16).

router is the API. adk-rust up merges it into ServerBuilder with add_api_routes, so the server’s auth middleware and RequestContextExtractor apply and the routes are served under /api; ControlPlane serves the same router, under the same /api prefix, on the socket and on ControlPlaneConfig::http when set.

Route (paths, under /api)Purpose
GET /kernel/healthKernelHealth
GET /kernel/processesthe process table, each process with its ProcessView (api::ProcessesQuery)
POST /kernel/processesstart a process of a registered target as the caller (api::SpawnRequest): a turn a surface sends, or a sleeper with a wake set
POST /kernel/processes/{pid}/{kill,nice,suspend,resume}ProcessTable actions
POST /kernel/processes/{pid}/run-now, POST /kernel/triggers/{name}/run-nowrun a cron sleeper or a standing cron trigger now, outside its schedule (api::RunNowRequest, Kernel::run_now); refused while frozen
GET /kernel/eventsthe event bus as server-sent events, from a cursor (api::EventsQuery)
POST /kernel/attach/{session}a surface attaches to a session: transcript cursor, pending holds, process
POST /kernel/sessions/{session}/steersend a message to the running turn of the caller’s session (api::SteerRequest, Kernel::steer): accepted by the turn this replica runs, or handed back to send as the next message
POST /kernel/freeze, POST /kernel/unfreezeKernel::freeze and Kernel::unfreeze; unfreeze only on the socket or pipe, a paired local terminal (RESUME_NOT_HERE_CODE over HTTP, spec 3.3 S-I10)
GET /kernel/agendathe agenda (api::AgendaQuery)
POST /kernel/agenda/{id}/{approve,reject,schedule}Agenda actions as the caller (api::RejectRequest, api::ScheduleRequest)
GET /kernel/drivers, POST /kernel/drivers/{id}/{mount,unmount,restart,reapprove} (feature drivers)the mounted drivers; a mount shown, then approved with confirm (api::MountDriverRequest, spec 3.2 §7.7)
GET /kernel/proc/ledger (feature proc)the content-free ledger, paged by seq, as JSON or as the JSONL cargo adk eval --ledger reads
GET /kernel/proc/baselines, GET /kernel/proc/observations (feature proc)each partition’s last baseline pass, and the observations it offered
POST /kernel/pairing, POST /kernel/pairing/claim, GET /kernel/devices, POST /kernel/devices/{id}/revokedevice pairing (spec 3.3 §10 K2), when ControlPlaneConfig::with_pairing sets it; see pairing
POST /kernel/channels/pair, GET /kernel/channels, POST /kernel/channels/{id}/revoke (feature channels)chat accounts’ pairings (spec 3.3 §10 K1)
GET /kernel/partitionsthe partition table (api::PartitionsResponse, spec 3.2 §7.8)
POST /kernel/partitions, POST /kernel/partitions/{id}/modecreate or replace a partition; set its mode (api::PartitionModeRequest)
GET /kernel/settings[/{partition}], POST /kernel/settings/{partition}/{quiet-time,spending-limit,mode}quiet time, the daily spending limit and the mode while the kernel runs (spec 3.3 §10 K3); see the routes the surfaces need
GET /kernel/away, POST /kernel/away/seen, GET /kernel/away/lines/{seq} (feature proc)“While you were away” over the /proc ledger with a cursor per device (spec 3.3 §10 K4)
GET /kernel/memory, POST /kernel/memory/facts/{id}/{confirm,fix,forget}, POST /kernel/memory/undowhat the agents remember, with provenance, and its corrections (spec 3.3 §10 K5)
GET /kernel/record, GET /kernel/record/checkthe latest actions on record, and the check that the record is complete (spec 3.3 §10 K5)
GET /kernel/commands, POST /kernel/commands/run, GET /kernel/rules/always-allow/{id}, POST /kernel/rules/always-allow/{id}/{prepare,grant}, GET /kernel/sessions/{session}/modethe REPL’s slash commands, “Always allow” and a session’s mode, when ControlPlaneConfig::with_commands sets a host (spec 3.3 §5.2); see CommandHost
POST /kernel/surface/recordsthe records of a surface engine attached to the kernel, on its signed log (spec 3.3 §11); see SurfaceRecord

The approvals inbox, /api/runs, /api/cron, /api/admin/freeze and /hooks/{name} are the existing server routes, unchanged; POST /api/admin/freeze delegates to Kernel::freeze through the kernel’s FreezeDelegate (§10 S4). The socket serves the approvals inbox beside the kernel routes when the kernel has an approval service, so a held call is decided over the socket as over HTTP; decide_guard answers each decision under spec 3.3 §7.2 for the surface the transport is.

§Authentication and audit

Every route needs an authenticated caller: the Option<RequestContext> the server’s auth middleware puts in the request extensions must be Some, or the route answers 401.

TransportCaller
SocketThe OS user, with the operator scope, when the peer’s uid is the socket owner’s; any other peer is refused
Named pipe (Windows)The OS user, with the operator scope, when the token the client opened the pipe with is the kernel’s user; the pipe’s DACL admits that user alone, and any other client is refused
HTTP merged into ServerBuilderWhatever the server’s RequestContextExtractor admits: LoopbackOperatorExtractor, BearerTokenExtractor or an SSO extractor
ControlPlaneConfig::http with an extractorThe extractor’s subject
ControlPlaneConfig::http on loopback without oneLoopback peers as the OS user with the operator scope
ControlPlaneConfig::http beyond loopback without oneRefused at start (K-I18)

The routes that change the kernel — spawn, steer, kill, nice, suspend, resume, freeze, unfreeze, the agenda’s approve, reject and schedule, the driver actions and the partition writes — and the /proc routes, which describe the user’s activity, need the operator scope (403 otherwise), which the socket, the pipe and a loopback bind grant. attach reads only the caller’s own sessions. A ledger read is recorded as kernel.control with action proc.ledger: the ledger leaves the host only through it, and “While you were away” (spec 3.3 §10 K4) serves only the rows of its lines.

A paired device’s token (spec 3.3 §10 K2, S-I7) admits it over HTTP as the person who paired it, only to the routes its scopes open (read, decide, stop; never unfreeze), whatever HTTP admits otherwise: on a loopback HTTP bind a request carrying a device token is the device, not the operator. The socket and the named pipe admit only the kernel’s own OS user, as the operator, and read no Authorization header, so a device token there changes nothing. Pairing never widens the bind.

Every action that changes the kernel or reads a session writes a kernel.control record with subject, transport, action and target to the kernel’s audit trail before it acts (K-I16; spawn records the new pid once it exists and cancels the process when the record fails), and is refused when the record cannot be written under AuditFailureMode::Block, except freeze, which takes effect regardless. Reads of the process table, the partition table, the health and the event stream are authenticated and not recorded.

§The routes the surfaces need

Spec 3.3 §10 K3–K5 adds the routes behind the home’s Today and “Agent Memory and Rules” screens. Reading them needs the operator scope, which a paired device with read has; changing a setting or a memory needs the operator scope and no device token: the person at the kernel’s socket, pipe or loopback, or signed in to the home. A chat channel reaches no kernel route.

RouteReadChangeRecorded as kernel.control
Settings (K3)operator or device readthe person, no devicesettings.quiet_time, settings.spending_limit, settings.mode, with from and to
While you were away (K4)operator or device readits own cursor: operator or device readno
Memory (K5)operator or device readthe person, no devicememory.confirm, memory.fix, memory.forget, memory.undo
Record (K5)operator or device read—no

The settings and cursors live in the ControlStore of ControlPlaneConfig::control_store; the memory and the record are what a MemoryBook and a RecordBook give the kernel, which adk-rust up builds over the harness’s facts and the kernel’s signed audit log.

Re-exports§

pub use crate::error::DECIDE_NOT_HERE_CODE;
pub use crate::error::RESUME_NOT_HERE_CODE;

Modules§

api
Wire types of the control plane (spec 3.2 §7.11). Every payload is camelCase.
paths
The control plane’s route paths, relative to the /api prefix they are served under (spec 3.2 §7.11).

Structs§

AlwaysAllowResponse
The answer of the “Always allow” routes: the words of the rule (spec 3.3 §8.2).
AreaSettings
The settings a person changed for one area while the kernel ran (spec 3.3 §8.1 “Areas”, §10 K3). Each one set replaces, for the area, the value the kernel and the area’s partition record started with, while the area still starts with that value (start); one never set leaves the start value in force.
AreaStart
What an area started with when its settings were last changed (spec 3.3 §10 K3): the values the changes replace.
AwayCursor
How far one viewer of one person has read “While you were away” (spec 3.3 §10 K4): the last /proc ledger row it marked seen.
Change
One setting a person changed while the kernel ran (spec 3.3 §10 K3): the value, and when and by whom it was set.
CommandCall
One run of a command, as the host gets it (spec 3.3 §5.2).
CommandInfo
A slash command the kernel’s host offers (spec 3.3 §5.2).
CommandReach
How the caller of a command reached the kernel (spec 3.3 §5.2): the transport, the paired device whose token admitted it, and the calling process where the transport says. A command reads it to decide what it allows; the run’s record names it.
CommandsResponse
GET /kernel/commands answer (spec 3.3 §5.2).
ControlClient
A client of a running kernel’s control plane (spec 3.2 §7.11), over its Unix socket, its named pipe on Windows (§10 W2) or HTTP. Surfaces hold no state (K-I17): every call reads the kernel.
ControlPlane
The running listeners of a kernel’s control plane (spec 3.2 §7.11): the Unix socket, or on Windows the named pipe ControlPlaneConfig::pipe_name names (§10 W2), and, when ControlPlaneConfig::http is set, an HTTP bind, all serving router under /api, with the approvals inbox beside it when the kernel has an approval service.
ControlPlaneConfig
Where the control plane listens and how it authenticates HTTP callers (spec 3.2 §7.11).
InMemoryControlStore
A ControlStore in process memory (spec 3.3 §10 K3, K4): changed settings and cursors end with the process, so a restart brings back the start settings.
PostgresControlStore
A ControlStore in PostgreSQL, shared by every replica (spec 3.3 §10 K3, K4; feature postgres).
RecordCheck
The answer of the record check (spec 3.3 §5.1 “Every action is on record”): whether the log verifies against its signed checkpoints, how many entries it holds, and the verifier’s own report.
RecordLine
One action on record, as structured fields a surface words as a sentence (“You let Finance send one email, from Telegram”, spec 3.3 §5.1, §11).
RedisControlStore
A ControlStore in Redis, shared by every replica (spec 3.3 §10 K3, K4; feature redis).
RememberedFact
One fact the agents remember (spec 3.3 §5.1 “What your agents remember”).
RunCommandRequest
POST /kernel/commands/run body (spec 3.3 §5.2).
RunCommandResponse
POST /kernel/commands/run answer (spec 3.3 §5.2).
SessionModeResponse
GET /kernel/sessions/{session}/mode answer: the mode of the caller’s session, so a terminal attached to the kernel shows the mode in force and knows whether a change loosens it (spec 3.3 §5.2, §8.1).
SqliteControlStore
A ControlStore in SQLite (spec 3.3 §10 K3, K4; feature sqlite).
SurfaceRecord
POST /kernel/surface/records body: one record of a surface engine attached to the kernel — an answer with the surface and how it was given, Stop all, Resume all, a mode change, a message sent — for the kernel’s signed log (spec 3.3 §11).
TidyUp
One overnight tidy-up of the memory: a consolidation tick (spec 3.2 §7.5, spec 3.3 §8.2 “Undo”).
TidyUpUndo
What undoing a tidy-up did (spec 3.3 §8.2 “Undo”).

Enums§

ControlTransport
The transport a control action arrived on, as the kernel.control audit record names it (spec 3.2 §9.3).
FactOrigin
Where a remembered fact came from, in the home’s words (spec 3.3 §8.1): a known fact reads “You said this”, whether the person said it or confirmed or corrected a guess, and an assumed one “A guess”.

Traits§

CommandHost
What the harness gives the kernel so a surface attached to it runs the REPL’s commands and answers “Always allow” (spec 3.3 §5.2, §7.2). A run’s CommandCall names the caller; the host runs a command in that person’s session only.
ControlStore
Where the control plane keeps AreaSettings and AwayCursors (spec 3.3 §10 K3, K4).
MemoryBook
What the harness gives the kernel so the control plane can show and correct the agents’ memory (spec 3.3 §10 K5). user is the caller; a book answers only that person’s facts, as fact_not_found for anyone else’s.
RecordBook
What the host of the kernel’s audit log gives the control plane to read and check it (spec 3.3 §10 K5).

Functions§

claim_router
The claim route of kernel’s device pairing (spec 3.3 §10 K2) at /api/kernel/pairing/claim, which needs no caller since the code is the credential: merge it with ServerBuilder::add_root_routes, outside the auth middleware and inside the host and origin checks. Empty when the kernel pairs no devices.
decide_guard
kernel’s check of every decision on POST /api/approvals/{id}/decide (spec 3.3 §7.2, §11 S-I11, S-I13): the answer is checked under §7.2 for the surface the server established — the kernel’s socket or pipe as a paired local terminal, a paired device by its kind, an operator credential over HTTP as api — and refused with DECIDE_NOT_HERE_CODE where that surface may not give it; never by a surface a client declares. An admitted decision is recorded before it reaches the inbox, and a suggested agent it answers is added or ended at once as that surface. The kernel’s own control plane installs it; a server that serves the kernel’s inbox installs it with ApprovalEndpoints::with_decide_guard.
guard_devices
app with every request that carries a device token checked against kernel’s pairing first (spec 3.3 §10 K2, S-I7): 401 for an unknown, expired or revoked token, 403 for a route its scopes do not open, a decision it answers on POST /approvals/{id}/decide limited to low and medium risk and recorded. The server’s own routes are those of Pairing::with_device_routes; a decision on one of them is admitted for the server’s engine, which applies what each surface may decide. Layer it on the whole app that serves the kernel’s routes, so no route outside them admits a device either; requests without a device token pass untouched.
router
The control plane’s routes over kernel (spec 3.2 §7.11), relative to the /api prefix: merge them with ServerBuilder::add_api_routes, whose auth middleware puts the caller’s RequestContext in the request extensions. Building them sets Kernel::serves_routes, which tells a web home served beside them to read them.