Skip to main content

Module ipc

Module ipc 

Source
Expand description

IPC surface of the sqryd daemon.

Task 8 Phase 8a wires the wire format, framing, version handshake, request validator, and the first four daemon management methods (daemon/status, daemon/load, daemon/unload, daemon/stop) that together give a CLI client a fully usable remote-control channel.

§Module layout

§Concurrency

The accept loop and every per-connection task are spawned on the current Tokio runtime. The router holds no locks across .await points; crate::workspace::WorkspaceManager-mutating method handlers use tokio::task::spawn_blocking when they call sync long-running operations (e.g. crate::workspace::WorkspaceManager::get_or_load). §J.4 lock order (workspaces → rebuild_lane → admission) is preserved: no IPC-owned lock is ever acquired.

§Shutdown

IPC server construction takes a tokio_util::sync::CancellationToken. The daemon/stop method and Task 9’s signal handler both flip the token; the accept loop observes cancellation in a biased tokio::select! arm and drains active connections for up to crate::config::DaemonConfig::ipc_shutdown_drain_secs before returning.

Re-exports§

pub use server::IpcServer;
pub use shim_registry::ShimConnEntry;
pub use shim_registry::ShimConnId;
pub use shim_registry::ShimHandle;
pub use shim_registry::ShimRegistry;

Modules§

framing
Re-exports from sqry_daemon_protocol::framing.
protocol
Re-exports from sqry_daemon_protocol::protocol.
server
IPC accept loop.
shim_registry
Shim-connection registry.
tool_core
Shared tool-dispatch core used by both the JSON-RPC path (ipc::methods::tool_dispatch::classify_and_build) and the MCP host path (mcp_host::DaemonMcpHandler::call_tool, U8).
validation
JSON-RPC 2.0 request validator.

Structs§

CancelRebuildResult
daemon/cancel_rebuild success result payload.
DaemonHello
Pre-handshake header sent as the very first frame by a CLI client. The server responds with DaemonHelloResponse before the JSON-RPC request loop begins.
DaemonHelloResponse
Server’s reply to DaemonHello. If compatible is false the server closes the connection immediately after the frame is sent.
JsonRpcError
JSON-RPC 2.0 error payload.
JsonRpcRequest
JSON-RPC 2.0 request.
JsonRpcResponse
JSON-RPC 2.0 response. id is Option<JsonRpcId> with no skip_serializing_if — the None case serialises as JSON null, which is exactly what the spec demands for parse-error and invalid-request responses.
JsonRpcVersion
JSON-RPC "2.0" version tag. Manual serde impls enforce exact string match on the wire so malformed requests never leak into the method dispatcher.
RebuildResult
daemon/rebuild success result payload (schema_version 2 — see cluster-G §2.4).
ResponseEnvelope
Uniform successful-response wrapper. Every successful method response is serialised as ResponseEnvelope<T> at the JSON-RPC result field — clients can rely on the ResponseMeta shape being present on every successful reply regardless of method.
ResponseMeta
Metadata attached to every successful response. For Phase 8a management methods the staleness fields are always absent (stale = false, no last_good_at, no last_error, workspace_state = None). Phase 8b populates them from the server-side ServeVerdict for tool-method responses.

Enums§

JsonRpcId
JSON-RPC id: null, integer (signed or unsigned), or string. I64 covers i64::MIN..=i64::MAX; U64 covers i64::MAX + 1..=u64::MAX. Serde’s untagged deserialize tries variants in order so 0..=i64::MAX lands in I64 and i64::MAX + 1..=u64::MAX in U64.
JsonRpcPayload
Tagged success-or-error payload. Serde untagged so the wire form is {... "result": ...} or {... "error": ...}, never both.