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
framing— 4-byte little-endian length-prefix codec.protocol— wire types:protocol::DaemonHello,protocol::DaemonHelloResponse,protocol::ResponseEnvelope,protocol::ResponseMeta,protocol::JsonRpcRequest,protocol::JsonRpcResponse,protocol::JsonRpcError,protocol::JsonRpcId.validation— JSON-RPC 2.0 request validator.- [
path_policy] — canonicalisation policy forcrate::workspace::WorkspaceKeyconstruction from user paths. shim_registry— shim-connection registry (Phase 8c public surface).server—server::IpcServeraccept loop (UDS + named pipe).- [
router] — connection router + batch dispatch. - [
methods] — one module per JSON-RPC method handler.
§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§
- Cancel
Rebuild Result daemon/cancel_rebuildsuccess result payload.- Daemon
Hello - Pre-handshake header sent as the very first frame by a CLI client.
The server responds with
DaemonHelloResponsebefore the JSON-RPC request loop begins. - Daemon
Hello Response - Server’s reply to
DaemonHello. Ifcompatibleisfalsethe server closes the connection immediately after the frame is sent. - Json
RpcError - JSON-RPC 2.0 error payload.
- Json
RpcRequest - JSON-RPC 2.0 request.
- Json
RpcResponse - JSON-RPC 2.0 response.
idisOption<JsonRpcId>with noskip_serializing_if— theNonecase serialises as JSONnull, which is exactly what the spec demands for parse-error and invalid-request responses. - Json
RpcVersion - 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. - Rebuild
Result daemon/rebuildsuccess result payload (schema_version 2 — see cluster-G §2.4).- Response
Envelope - Uniform successful-response wrapper. Every successful method
response is serialised as
ResponseEnvelope<T>at the JSON-RPCresultfield — clients can rely on theResponseMetashape being present on every successful reply regardless of method. - Response
Meta - 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-sideServeVerdictfor tool-method responses.
Enums§
- Json
RpcId - JSON-RPC id:
null, integer (signed or unsigned), or string.I64coversi64::MIN..=i64::MAX;U64coversi64::MAX + 1..=u64::MAX. Serde’s untagged deserialize tries variants in order so0..=i64::MAXlands inI64andi64::MAX + 1..=u64::MAXinU64. - Json
RpcPayload - Tagged success-or-error payload. Serde
untaggedso the wire form is{... "result": ...}or{... "error": ...}, never both.