Skip to main content

Module protocol

Module protocol 

Source
Expand description

Wire types for the sqryd daemon IPC.

Every type in this module serialises as UTF-8 JSON through serde. The wire format is versioned via the envelope_version field on DaemonHelloResponse / ShimRegisterAck; clients negotiate compatibility during the handshake before issuing any JSON-RPC request or entering the shim byte-pump.

§JSON-RPC 2.0 conformance

  • Requests and responses carry the mandatory "jsonrpc": "2.0" tag enforced by JsonRpcVersion’s manual serde impls.
  • Response ids follow the spec exactly: a response to a request with a missing/invalid id MUST carry id: null; Option<JsonRpcId> on JsonRpcResponse::id is NOT marked skip_serializing_if, so None serialises as JSON null instead of being omitted.
  • Batches are implemented in the sqry-daemon router; this module only provides the single-request envelope types.

§shim/register

ShimRegister / ShimProtocol / ShimRegisterAck are the Phase 8c shim handshake wire types. The router in sqry-daemon discriminates on the very first frame:

  • If the frame object has both protocol + pid keys (shim-shaped), the router enters the shim path and deserialises as ShimRegister with deny_unknown_fields. On deserialisation failure (e.g. extra keys from the hello shape, or an unknown protocol variant) the server writes ShimRegisterAck{ accepted: false, reason: Some(..) } and closes. Not a JSON-RPC -32600 — the shim client expects a ShimRegisterAck as the first response, so the wire-form stays coherent.
  • Otherwise the router falls through to the DaemonHello path (JSON-RPC). A frame with neither shape is rejected with -32600 Invalid Request and id: null.

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.
LoadResult
daemon/load success result payload.
LogicalWorkspaceWire
Wire-form summary of a LogicalWorkspace, attached to DaemonHello / daemon/load payloads. Carries the workspace identity plus the canonical source-root paths the client wants the daemon to bind under a single grouping workspace_id.
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.
ShimRegister
Shim registration header sent as the first frame by a sqry lsp --daemon or sqry mcp --daemon process. The router in sqry-daemon shape-discriminates between DaemonHello and this type using #[serde(deny_unknown_fields)].
ShimRegisterAck
Server’s reply to ShimRegister. If accepted is false the server closes the connection after sending the ack and the shim client surfaces reason to its parent process. When accepted is true, reason is omitted from the wire form (skip-if-none).
SourceRootBinding
STEP_11_4 — per-source-root binding inside a LogicalWorkspaceWire.
WorkspaceId
32-byte stable identity for a logical workspace, byte-identical to sqry_core::workspace::WorkspaceId.
WorkspaceIndexStatus
Aggregate status of a logical workspace, returned by daemon/workspaceStatus { workspace_id }.
WorkspaceSourceRootStatus
Aggregate status of a single source root inside a logical workspace. Mirrors the per-source-root subset of WorkspaceStatus so cross-repo MCP / LSP queries can render a per-source-root state without paying the cost of the full daemon/status snapshot.

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.
RebuildStatus
Status of a daemon/rebuild invocation (cluster-G §2.4).
ShimProtocol
Which client protocol the shim will pump bytes for. Phase 8c surface.
WorkspaceState
Six-state workspace lifecycle per plan Task 6 Step 1 and Amendment 2 §G.5 / §G.7.

Constants§

ENVELOPE_VERSION
Version of the daemon wire envelope (DaemonHelloResponse::envelope_version, ShimRegisterAck::envelope_version).