gNode Client Implementation Keynotes
Architecture primer for implementing a client of the gNode daemon. The precise wire contract is
CONTRACT.md; the command catalogue is gNodeCOMMAND_SCHEMA.md.
Key Stream Connection Pattern
{site_id}:gnode:unified:{environment} # Unified command stream (client → daemon)
{site_id}:res:{request_id} # Per-request response key (daemon → client, polled)
Braces around site_id are literal (Redis Cluster hash-tag routing). The unified stream
is per-DTAP-environment (testing|staging|acceptance|production), not per-node
(gNodeClient::getComputeStream). The health stream is {site_id}:gnode:health.
Multi-Node Architecture
- One daemon instance handles multiple sites' unified streams simultaneously
- Each site/environment pair has an isolated unified stream
- No explicit configuration required for additional nodes
Security Model
- Communication is limited to well-defined ValKey streams and allowlisted FCALL names
- ValKey is the authentication boundary: each site connects as
gnode_client_{site_id}, ACL-scoped to~{site_id}:gnode:* - FCALL names are validated against the allowlist before any wire I/O
Command Format
Commands travel as XADD fields with canonical short names and full command names
(gNodeClient::sendCommand):
{
"t": "c", // Type: command
"id": "example.com:6864...", // Request id (uniqid, site-prefixed)
"c": "geometric_discover", // Full command name (no abbreviation on the wire)
"p": "{\"layer\":\"3\",\"facets\":{...},\"_request_id\":\"...\"}", // JSON-encoded params
"ss": "example.com", // Source site
"sn": "client", // Source node
"ts": "1751500000000" // Unix timestamp, whole MILLISECONDS
}
Long-form aliases (command, params, site_id, ...) are accepted daemon-side
(gNode daemon/src/utils.rs::field_names) but this client always emits the short forms.
Response Format
The daemon writes the response JSON to the per-request response key; the client polls it
via FCALL GNODE_CACHE_GET with exponential backoff (gNodeClient::pollForResponse):
{
"status": "ok", // "ok" or "error"
"result": {}, // Result data (present on success)
"error": null // Error message (present on failure)
}
Command Processing Flow
- Client XADDs command to the unified stream
- Daemon reads command via consumer group
gnode-daemon - Daemon routes the command to its handler
- Daemon writes the response to
{site_id}:res:{request_id} - Client polls the response key until hit or timeout (default 5 s,
timeoutconfig key)
Fallback
The client is FCALL-first. When the daemon or ValKey is unreachable, an optional
Fallback\FallbackHandler executes the supported commands locally (degraded mode); the
first poll timeout sets a sticky daemon-unreachable flag so later commands in the request
fail fast.
Batch Processing
- Correlate commands and responses by their ids
executeBatchstores one request key per command and sends one batch notification
Design Principles
- Resilient design: graceful degradation under failure
- One topology: declare by name; the daemon encodes, the client never codes a coordinate