gNode

FCALL Cookbook: Polyglot Integration Reference

@PRIME: gNode-FCALL|ValKey-functions|XADD-XREADGROUP|multi-language|
        service-topology|geometric-discover|staleness|health-stream|
        circuit-breaker|pub-sub|cache-ops
@AUDIENCE: developers-integrating-with-gNode-from-any-language
@PREREQUISITE: CONTRACT.md|running-gNode-daemon|registered-site

§0 SYSTEM IDENTITY

This cookbook provides copy-pasteable examples for the 10 most common gNode operations in 6 languages: CLI (valkey-cli), Python (redis-py), Node.js (ioredis), PHP (gNode-Client + raw), Rust (redis-rs), and Go (go-redis).

All examples assume:


§1 CONNECTION

Authentication

gNode uses ACL-based auth. Never use the --pass CLI flag with long hex passwords — use the REDISCLI_AUTH environment variable.

CLI:

# ALWAYS use the secure wrapper script
./scripts/valkey-cli-secure.sh PING

# Or manually (for one-off commands):
export REDISCLI_AUTH="$(cat .gnode/valkey_client_staging_my_app.password)"
valkey-cli -p 47445 --user gnode_client_staging_my_app PING

Python (redis-py):

import redis

r = redis.Redis(
    host='127.0.0.1',
    port=47445,
    username='gnode_client_staging_my_app',
    password=open('.gnode/valkey_client_staging_my_app.password').read().strip(),
    decode_responses=True
)
assert r.ping()

Node.js (ioredis):

const Redis = require('ioredis');
const fs = require('fs');

const client = new Redis({
  host: '127.0.0.1',
  port: 47445,
  username: 'gnode_client_staging_my_app',
  password: fs.readFileSync('.gnode/valkey_client_staging_my_app.password', 'utf8').trim(),
});

PHP (gNode-Client):

// gNode-Client handles connection automatically via site.env
$gnode = new \gNode\Client\GNodeClient();
// All FCALL/XADD operations go through $gnode->execute($command, $params)

Rust (redis-rs):

use redis::Client;

let password = std::fs::read_to_string(".gnode/valkey_client_staging_my_app.password")
    .expect("read password")
    .trim()
    .to_string();
let client = Client::open(format!(
    "redis://gnode_client_staging_my_app:{}@127.0.0.1:47445",
    password
))?;
let mut conn = client.get_connection()?;

Go (go-redis):

import "github.com/redis/go-redis/v9"

password, _ := os.ReadFile(".gnode/valkey_client_staging_my_app.password")
rdb := redis.NewClient(&redis.Options{
    Addr:     "127.0.0.1:47445",
    Username: "gnode_client_staging_my_app",
    Password: strings.TrimSpace(string(password)),
})

§2 Register Entity

Declare a service on the constellation's one topology by name. The daemon encodes the axis words; a word it does not know, or a number in place of a word, is refused.

Send the register_service command via stream.

CLI:

# Via stream command
./scripts/valkey-cli-secure.sh XADD {staging_my_app}:gnode:unified:production '*' \
  id "reg-$(date +%s)" \
  cmd "register_service" \
  params '{"id":"MyService","shape":"app","environment":"production","axes":{"protocol":"gnode_stream","latency_class":"responsive"},"metadata":{"type":"worker","version":"1.0"}}' \
  t "c" \
  ss "staging_my_app" \
  sn "node-1"

Python:

import json, time

# Via stream (recommended)
r.xadd('{staging_my_app}:gnode:unified:production', {
    'id': f'reg-{int(time.time())}',
    'cmd': 'register_service',
    'params': json.dumps({
        'id': 'MyService',
        'shape': 'app', 'axes': {'protocol': 'gnode_stream', 'latency_class': 'responsive'},
        'metadata': {'type': 'worker'}
    }),
    't': 'c', 'ss': 'staging_my_app', 'sn': 'node-1'
})

Node.js:

await client.xadd('{staging_my_app}:gnode:unified:production', '*',
  'id', `reg-${Date.now()}`,
  'cmd', 'register_service',
  'params', JSON.stringify({
    id: 'MyService',
    shape: 'app', axes: { protocol: 'gnode_stream', latency_class: 'responsive' },
    metadata: { type: 'worker' }
  }),
  't', 'c', 'ss', 'staging_my_app', 'sn', 'node-1'
);

PHP (gNode-Client):

$gnode->execute('register_service', [
    'id' => 'MyService',
    'shape' => 'app', 'axes' => ['protocol' => 'gnode_stream', 'latency_class' => 'responsive'],
    'metadata' => ['type' => 'worker'],
]);

Rust:

use redis::Commands;

redis::cmd("XADD")
    .arg("{staging_my_app}:gnode:unified:production")
    .arg("*")
    .arg("id").arg(format!("reg-{}", chrono::Utc::now().timestamp()))
    .arg("cmd").arg("register_service")
    .arg("params").arg(serde_json::json!({
        "id": "MyService",
        "shape": "app", "axes": {"protocol": "gnode_stream", "latency_class": "responsive"},
        "metadata": {"type": "worker"}
    }).to_string())
    .arg("t").arg("c").arg("ss").arg("staging_my_app").arg("sn").arg("node-1")
    .query::<String>(&mut conn)?;

Go:

params, _ := json.Marshal(map[string]interface{}{
    "id":           "MyService",
    "shape": "app", "axes": map[string]string{"protocol": "gnode_stream", "latency_class": "responsive"},
    "metadata":     map[string]string{"type": "worker"},
})
rdb.XAdd(ctx, &redis.XAddArgs{
    Stream: "{staging_my_app}:gnode:unified:production",
    Values: map[string]interface{}{
        "id":     fmt.Sprintf("reg-%d", time.Now().Unix()),
        "cmd":    "register_service",
        "params": string(params),
        "t":      "c",
        "ss":     "staging_my_app",
        "sn":     "node-1",
    },
}).Result()

§3 Discover by Capability

Find the entities of a layer whose facets and axis ranges match, in one index query on the one topology.

CLI:

./scripts/valkey-cli-secure.sh XADD {staging_my_app}:gnode:unified:production '*' \
  id "disc-$(date +%s)" \
  cmd "geometric_discover" \
  params '{"layer":"app","facets":{"protocol":["gnode_stream"]},"limit":5}' \
  t "c" \
  ss "staging_my_app" \
  sn "node-1"

Python:

r.xadd('{staging_my_app}:gnode:unified:production', {
    'id': f'disc-{int(time.time())}',
    'cmd': 'geometric_discover',
    'params': json.dumps({
        'layer': 'app', 'facets': {'protocol': ['gnode_stream']},
        'limit': 5
    }),
    't': 'c', 'ss': 'staging_my_app', 'sn': 'node-1'
})

Node.js:

await client.xadd('{staging_my_app}:gnode:unified:production', '*',
  'id', `disc-${Date.now()}`,
  'cmd', 'geometric_discover',
  'params', JSON.stringify({
    layer: 'app', facets: { protocol: ['gnode_stream'] },
    limit: 5
  }),
  't', 'c', 'ss', 'staging_my_app', 'sn', 'node-1'
);

PHP (gNode-Client):

$results = $gnode->execute('geometric_discover', [
    'layer' => 'app', 'facets' => ['protocol' => ['gnode_stream']],
    'limit' => 5,
]);

Rust:

use redis::Commands;

redis::cmd("XADD")
    .arg("{staging_my_app}:gnode:unified:production")
    .arg("*")
    .arg("id").arg(format!("disc-{}", chrono::Utc::now().timestamp()))
    .arg("cmd").arg("geometric_discover")
    .arg("params").arg(serde_json::json!({
        "layer": "app", "facets": {"protocol": ["gnode_stream"]},
        "limit": 5
    }).to_string())
    .arg("t").arg("c").arg("ss").arg("staging_my_app").arg("sn").arg("node-1")
    .query::<String>(&mut conn)?;

Go:

params, _ := json.Marshal(map[string]interface{}{
    "layer": "app", "facets": map[string][]string{"protocol": {"gnode_stream"}},
    "limit":        5,
})
rdb.XAdd(ctx, &redis.XAddArgs{
    Stream: "{staging_my_app}:gnode:unified:production",
    Values: map[string]interface{}{
        "id":     fmt.Sprintf("disc-%d", time.Now().Unix()),
        "cmd":    "geometric_discover",
        "params": string(params),
        "t":      "c",
        "ss":     "staging_my_app",
        "sn":     "node-1",
    },
}).Result()

§4 Describe Entity

Get detailed description of a registered service entity: axes, edges, placements, health.

CLI (via stream):

./scripts/valkey-cli-secure.sh XADD {staging_my_app}:gnode:unified:production '*' \
  id "desc-$(date +%s)" \
  cmd "service_describe" \
  params '{"entity_id":"MyService"}' \
  t "c" \
  ss "staging_my_app" \
  sn "node-1"

CLI (direct FCALL — raw entity without enrichment):

./scripts/valkey-cli-secure.sh FCALL GNODE_TOPO_GET_ENTITY 1 \
  "{geodineum}:gnode:constellation" "MyService"

Python:

# Via stream (recommended — includes health)
r.xadd('{staging_my_app}:gnode:unified:production', {
    'id': f'desc-{int(time.time())}',
    'cmd': 'service_describe',
    'params': json.dumps({'entity_id': 'MyService'}),
    't': 'c', 'ss': 'staging_my_app', 'sn': 'node-1'
})

# Direct FCALL (raw entity data only)
raw = r.fcall('GNODE_TOPO_GET_ENTITY', 1,
    '{geodineum}:gnode:constellation', 'MyService')
entity = json.loads(raw)

Node.js:

// Via stream
await client.xadd('{staging_my_app}:gnode:unified:production', '*',
  'id', `desc-${Date.now()}`,
  'cmd', 'service_describe',
  'params', JSON.stringify({ entity_id: 'MyService' }),
  't', 'c', 'ss', 'staging_my_app', 'sn', 'node-1'
);

// Direct FCALL
const raw = await client.call('FCALL', 'GNODE_TOPO_GET_ENTITY', 1,
  '{geodineum}:gnode:constellation', 'MyService');

PHP (gNode-Client):

// Via gNode-Client
$info = $gnode->execute('service_describe', ['entity_id' => 'MyService']);

// Direct FCALL
$raw = $gnode->fcall('GNODE_TOPO_GET_ENTITY', ['{geodineum}:gnode:constellation'], ['MyService']);

Rust:

use redis::Commands;

// Via stream (recommended — includes health)
redis::cmd("XADD")
    .arg("{staging_my_app}:gnode:unified:production")
    .arg("*")
    .arg("id").arg(format!("desc-{}", chrono::Utc::now().timestamp()))
    .arg("cmd").arg("service_describe")
    .arg("params").arg(serde_json::json!({"entity_id": "MyService"}).to_string())
    .arg("t").arg("c").arg("ss").arg("staging_my_app").arg("sn").arg("node-1")
    .query::<String>(&mut conn)?;

// Direct FCALL (raw entity data only)
let raw: String = redis::cmd("FCALL")
    .arg("GNODE_TOPO_GET_ENTITY")
    .arg(1)
    .arg("{geodineum}:gnode:constellation")
    .arg("MyService")
    .query(&mut conn)?;
let entity: serde_json::Value = serde_json::from_str(&raw)?;

Go:

// Via stream (recommended — includes health)
params, _ := json.Marshal(map[string]string{"entity_id": "MyService"})
rdb.XAdd(ctx, &redis.XAddArgs{
    Stream: "{staging_my_app}:gnode:unified:production",
    Values: map[string]interface{}{
        "id":     fmt.Sprintf("desc-%d", time.Now().Unix()),
        "cmd":    "service_describe",
        "params": string(params),
        "t":      "c",
        "ss":     "staging_my_app",
        "sn":     "node-1",
    },
}).Result()

// Direct FCALL (raw entity data only)
raw, err := rdb.FCall(ctx, "GNODE_TOPO_GET_ENTITY",
    []string{"{geodineum}:gnode:constellation"},
    "MyService",
).Result()

§5 Send Command via Stream

The universal pattern for sending any command to gNode via the unified stream.

Stream key format: {service_id}:gnode:unified:{environment} (the braces are literal)

Fields: Field Required Description
id Yes Unique command ID (client-generated)
cmd Yes Command name (case-insensitive)
params Yes JSON-encoded parameters
_gh No Routing hint (e.g., "inference")
t Yes Message type, c for a command: an entry without a known type is acknowledged and dropped
ss Yes Source site (your service id)
sn Yes Source node

CLI:

./scripts/valkey-cli-secure.sh XADD {staging_my_app}:gnode:unified:production '*' \
  id "cmd-$(date +%s)" \
  cmd "ping" \
  params '{}' \
  t "c" \
  ss "staging_my_app" \
  sn "node-1"

Python:

cmd_id = f'cmd-{int(time.time() * 1000)}'
r.xadd('{staging_my_app}:gnode:unified:production', {
    'id': cmd_id,
    'cmd': 'status',
    'params': '{}',
    't': 'c', 'ss': 'staging_my_app', 'sn': 'node-1'
})

Node.js:

const cmdId = `cmd-${Date.now()}`;
await client.xadd('{staging_my_app}:gnode:unified:production', '*',
  'id', cmdId,
  'cmd', 'status',
  'params', '{}',
  't', 'c', 'ss', 'staging_my_app', 'sn', 'node-1'
);

Rust:

use redis::Commands;

let cmd_id = format!("cmd-{}", chrono::Utc::now().timestamp_millis());
redis::cmd("XADD")
    .arg("{staging_my_app}:gnode:unified:production")
    .arg("*")
    .arg("id").arg(&cmd_id)
    .arg("cmd").arg("status")
    .arg("params").arg("{}")
    .arg("t").arg("c").arg("ss").arg("staging_my_app").arg("sn").arg("node-1")
    .query::<String>(&mut conn)?;

Go:

cmdId := fmt.Sprintf("cmd-%d", time.Now().UnixMilli())
rdb.XAdd(ctx, &redis.XAddArgs{
    Stream: "{staging_my_app}:gnode:unified:production",
    Values: map[string]interface{}{
        "id":     cmdId,
        "cmd":    "status",
        "params": "{}",
        "t":      "c",
        "ss":     "staging_my_app",
        "sn":     "node-1",
    },
}).Result()

§6 Read Response

The daemon writes the response of a command to the polling key {ss}:res:{id} (ss and id as sent) with a 10-second TTL; poll it within a few seconds. Do not read the unified stream for it: that stream is the daemon's own input, read in the consumer groups gnode-daemon and gnode-workers. The JSON is {id, status: "ok"|"error", result, error, timestamp}.

CLI:

./scripts/valkey-cli-secure.sh GET '{staging_my_app}:res:reg-1700000000'

Python:

import json, time

def await_response(r, site, cmd_id, timeout=5.0):
    key = f'{{{site}}}:res:{cmd_id}'
    deadline = time.time() + timeout
    while time.time() < deadline:
        raw = r.get(key)
        if raw:
            return json.loads(raw)
        time.sleep(0.05)
    return None

Node.js:

async function awaitResponse(client, site, cmdId, timeoutMs = 5000) {
  const key = `{${site}}:res:${cmdId}`;
  const deadline = Date.now() + timeoutMs;
  while (Date.now() < deadline) {
    const raw = await client.get(key);
    if (raw) return JSON.parse(raw);
    await new Promise(r => setTimeout(r, 50));
  }
  return null;
}

PHP (gNode-Client): $gnode->execute(...) sends the command and polls this key for you.


§7 Publish Broadcast

Publish a message to a pub/sub channel with history and rate limiting.

CLI:

./scripts/valkey-cli-secure.sh FCALL GNODE_PUBSUB_PUBLISH 1 \
  "{staging_my_app}:pubsub" \
  "topology_updates" \
  '{"event":"service_registered","service_id":"MyService","timestamp":1708234567}'

Python:

result = r.fcall('GNODE_PUBSUB_PUBLISH', 1,
    '{staging_my_app}:pubsub',
    'topology_updates',
    json.dumps({
        'event': 'service_registered',
        'service_id': 'MyService',
        'timestamp': int(time.time())
    })
)

Node.js:

const result = await client.call('FCALL', 'GNODE_PUBSUB_PUBLISH', 1,
  '{staging_my_app}:pubsub',
  'topology_updates',
  JSON.stringify({
    event: 'service_registered',
    service_id: 'MyService',
    timestamp: Date.now()
  })
);

PHP (gNode-Client):

$gnode->fcall('GNODE_PUBSUB_PUBLISH', ['{staging_my_app}:pubsub'], [
    'topology_updates',
    json_encode(['event' => 'service_registered', 'service_id' => 'MyService'])
]);

Rust:

use redis::Commands;

let message = serde_json::json!({
    "event": "service_registered",
    "service_id": "MyService",
    "timestamp": std::time::SystemTime::now()
        .duration_since(std::time::UNIX_EPOCH)
        .unwrap_or_default()
        .as_secs()
});
let result: String = redis::cmd("FCALL")
    .arg("GNODE_PUBSUB_PUBLISH")
    .arg(1)
    .arg("{staging_my_app}:pubsub")
    .arg("topology_updates")
    .arg(message.to_string())
    .query(&mut conn)?;

Go:

message, _ := json.Marshal(map[string]interface{}{
    "event":      "service_registered",
    "service_id": "MyService",
    "timestamp":  time.Now().Unix(),
})
result, err := rdb.FCall(ctx, "GNODE_PUBSUB_PUBLISH",
    []string{"{staging_my_app}:pubsub"},
    "topology_updates",
    string(message),
).Result()

§8 Cache Get/Set

Atomic cache operations with optional TTL.

CLI:

# Set with 300s TTL
./scripts/valkey-cli-secure.sh FCALL GNODE_CACHE_SET 1 \
  "{staging_my_app}:cache" "user:123:profile" '{"name":"Alice"}' 300

# Get
./scripts/valkey-cli-secure.sh FCALL GNODE_CACHE_GET 1 \
  "{staging_my_app}:cache" "user:123:profile"

Python:

# Set
r.fcall('GNODE_CACHE_SET', 1,
    '{staging_my_app}:cache',
    'user:123:profile',
    json.dumps({'name': 'Alice'}),
    300  # TTL seconds
)

# Get
cached = r.fcall('GNODE_CACHE_GET', 1,
    '{staging_my_app}:cache',
    'user:123:profile'
)
if cached:
    data = json.loads(cached)

Node.js:

// Set
await client.call('FCALL', 'GNODE_CACHE_SET', 1,
  '{staging_my_app}:cache', 'user:123:profile',
  JSON.stringify({ name: 'Alice' }), 300);

// Get
const cached = await client.call('FCALL', 'GNODE_CACHE_GET', 1,
  '{staging_my_app}:cache', 'user:123:profile');

PHP (gNode-Client):

// Set
$gnode->fcall('GNODE_CACHE_SET', ['{staging_my_app}:cache'], [
    'user:123:profile', json_encode(['name' => 'Alice']), 300
]);

// Get
$cached = $gnode->fcall('GNODE_CACHE_GET', ['{staging_my_app}:cache'], [
    'user:123:profile'
]);

Rust:

use redis::Commands;

// Set with 300s TTL
redis::cmd("FCALL")
    .arg("GNODE_CACHE_SET")
    .arg(1)
    .arg("{staging_my_app}:cache")
    .arg("user:123:profile")
    .arg(serde_json::json!({"name": "Alice"}).to_string())
    .arg(300)
    .query::<String>(&mut conn)?;

// Get
let cached: Option<String> = redis::cmd("FCALL")
    .arg("GNODE_CACHE_GET")
    .arg(1)
    .arg("{staging_my_app}:cache")
    .arg("user:123:profile")
    .query(&mut conn)?;
if let Some(val) = cached {
    let data: serde_json::Value = serde_json::from_str(&val)?;
}

Go:

// Set with 300s TTL
rdb.FCall(ctx, "GNODE_CACHE_SET",
    []string{"{staging_my_app}:cache"},
    "user:123:profile",
    `{"name":"Alice"}`,
    300,
).Result()

// Get
cached, err := rdb.FCall(ctx, "GNODE_CACHE_GET",
    []string{"{staging_my_app}:cache"},
    "user:123:profile",
).Result()
if err == nil {
    var data map[string]interface{}
    json.Unmarshal([]byte(fmt.Sprint(cached)), &data)
}

§9 Circuit Breaker

Three-state circuit breaker (CLOSED → OPEN → HALF_OPEN) for resilient service communication.

CLI:

# Check if circuit is open (returns JSON with state)
./scripts/valkey-cli-secure.sh FCALL GNODE_RESILIENCE_CIRCUIT_CHECK 1 \
  "{staging_my_app}:resilience" "payment-gateway"

# Record success (closes circuit if half-open)
./scripts/valkey-cli-secure.sh FCALL GNODE_RESILIENCE_CIRCUIT_SUCCESS 1 \
  "{staging_my_app}:resilience" "payment-gateway"

# Record failure (may trip circuit open)
./scripts/valkey-cli-secure.sh FCALL GNODE_RESILIENCE_CIRCUIT_FAILURE 1 \
  "{staging_my_app}:resilience" "payment-gateway"

Python:

# Check before calling external service
state = json.loads(r.fcall('GNODE_RESILIENCE_CIRCUIT_CHECK', 1,
    '{staging_my_app}:resilience', 'payment-gateway'))

if state.get('allowed'):
    try:
        result = call_payment_gateway()
        r.fcall('GNODE_RESILIENCE_CIRCUIT_SUCCESS', 1,
            '{staging_my_app}:resilience', 'payment-gateway')
    except Exception:
        r.fcall('GNODE_RESILIENCE_CIRCUIT_FAILURE', 1,
            '{staging_my_app}:resilience', 'payment-gateway')
else:
    # Circuit is OPEN — use fallback
    result = use_cached_response()

Node.js:

const state = JSON.parse(await client.call('FCALL', 'GNODE_RESILIENCE_CIRCUIT_CHECK', 1,
  '{staging_my_app}:resilience', 'payment-gateway'));

if (state.allowed) {
  try {
    const result = await callPaymentGateway();
    await client.call('FCALL', 'GNODE_RESILIENCE_CIRCUIT_SUCCESS', 1,
      '{staging_my_app}:resilience', 'payment-gateway');
  } catch (e) {
    await client.call('FCALL', 'GNODE_RESILIENCE_CIRCUIT_FAILURE', 1,
      '{staging_my_app}:resilience', 'payment-gateway');
  }
}

PHP (gNode-Client):

$state = json_decode($gnode->fcall('GNODE_RESILIENCE_CIRCUIT_CHECK',
    ['{staging_my_app}:resilience'], ['payment-gateway']), true);

if ($state['allowed']) {
    try {
        $result = callPaymentGateway();
        $gnode->fcall('GNODE_RESILIENCE_CIRCUIT_SUCCESS',
            ['{staging_my_app}:resilience'], ['payment-gateway']);
    } catch (\Exception $e) {
        $gnode->fcall('GNODE_RESILIENCE_CIRCUIT_FAILURE',
            ['{staging_my_app}:resilience'], ['payment-gateway']);
    }
}

Rust:

use redis::Commands;

// Check before calling external service
let state_json: String = redis::cmd("FCALL")
    .arg("GNODE_RESILIENCE_CIRCUIT_CHECK")
    .arg(1)
    .arg("{staging_my_app}:resilience")
    .arg("payment-gateway")
    .query(&mut conn)?;
let state: serde_json::Value = serde_json::from_str(&state_json)?;

if state["allowed"].as_bool().unwrap_or(false) {
    match call_payment_gateway() {
        Ok(result) => {
            redis::cmd("FCALL")
                .arg("GNODE_RESILIENCE_CIRCUIT_SUCCESS")
                .arg(1)
                .arg("{staging_my_app}:resilience")
                .arg("payment-gateway")
                .query::<String>(&mut conn)?;
        }
        Err(_) => {
            redis::cmd("FCALL")
                .arg("GNODE_RESILIENCE_CIRCUIT_FAILURE")
                .arg(1)
                .arg("{staging_my_app}:resilience")
                .arg("payment-gateway")
                .query::<String>(&mut conn)?;
        }
    }
}

Go:

// Check before calling external service
stateJSON, err := rdb.FCall(ctx, "GNODE_RESILIENCE_CIRCUIT_CHECK",
    []string{"{staging_my_app}:resilience"},
    "payment-gateway",
).Result()

var state map[string]interface{}
json.Unmarshal([]byte(fmt.Sprint(stateJSON)), &state)

if allowed, ok := state["allowed"].(bool); ok && allowed {
    if err := callPaymentGateway(); err == nil {
        rdb.FCall(ctx, "GNODE_RESILIENCE_CIRCUIT_SUCCESS",
            []string{"{staging_my_app}:resilience"},
            "payment-gateway",
        ).Result()
    } else {
        rdb.FCall(ctx, "GNODE_RESILIENCE_CIRCUIT_FAILURE",
            []string{"{staging_my_app}:resilience"},
            "payment-gateway",
        ).Result()
    }
}

§10 Health Update

High-frequency health metrics sent to the health stream. Uses compressed field names for bandwidth. The daemon acknowledges these entries without reading them: its load figures come from its own observations of reply latency, so a self-report is telemetry for other readers of the stream, not an input to routing.

Stream key: {service_id}:gnode:health (ONE per site, no environment suffix)

Fields: Field Description
t Type: "lu" (load_update)
si Service ID
l Load factor (0.0-1.0)
cpu CPU usage (0.0-1.0)
mem Memory usage (0.0-1.0)
rq Active request count
lat Avg latency (ms)
err Error rate (0.0-1.0)
ts Unix timestamp (seconds)

CLI:

./scripts/valkey-cli-secure.sh XADD {staging_my_app}:gnode:health '*' \
  t "lu" \
  si "MyService" \
  l "0.35" \
  cpu "0.42" \
  mem "0.28" \
  rq "12" \
  lat "8" \
  err "0.001" \
  ts "$(date +%s)"

Python:

r.xadd('{staging_my_app}:gnode:health', {
    't': 'lu',
    'si': 'MyService',
    'l': '0.35',
    'cpu': '0.42',
    'mem': '0.28',
    'rq': '12',
    'lat': '8',
    'err': '0.001',
    'ts': str(int(time.time()))
})

Node.js:

await client.xadd('{staging_my_app}:gnode:health', '*',
  't', 'lu',
  'si', 'MyService',
  'l', '0.35',
  'cpu', '0.42',
  'mem', '0.28',
  'rq', '12',
  'lat', '8',
  'err', '0.001',
  'ts', Math.floor(Date.now() / 1000).toString()
);

PHP (gNode-Client):

// gNode-Client provides a high-level helper
$gnode->sendHealthUpdate([
    'service_id' => 'MyService',
    'load' => 0.35,
    'cpu' => 0.42,
    'memory' => 0.28,
    'active_requests' => 12,
    'avg_latency_ms' => 8,
    'error_rate' => 0.001,
]);

Rust:

redis::cmd("XADD")
    .arg("{staging_my_app}:gnode:health")
    .arg("*")
    .arg("t").arg("lu")
    .arg("si").arg("MyService")
    .arg("l").arg("0.35")
    .arg("cpu").arg("0.42")
    .arg("mem").arg("0.28")
    .arg("rq").arg("12")
    .arg("lat").arg("8")
    .arg("err").arg("0.001")
    .arg("ts").arg(std::time::SystemTime::now()
        .duration_since(std::time::UNIX_EPOCH)
        .unwrap_or_default()
        .as_secs()
        .to_string())
    .query::<String>(&mut conn)?;

Go:

rdb.XAdd(ctx, &redis.XAddArgs{
    Stream: "{staging_my_app}:gnode:health",
    Values: map[string]interface{}{
        "t":   "lu",
        "si":  "MyService",
        "l":   "0.35",
        "cpu": "0.42",
        "mem": "0.28",
        "rq":  "12",
        "lat": "8",
        "err": "0.001",
        "ts":  fmt.Sprintf("%d", time.Now().Unix()),
    },
}).Result()

Quick Reference Table

Operation Method Key/Stream
Register entity XADD cmd=register_service {service_id}:gnode:unified:{env}
Discover XADD cmd=geometric_discover {service_id}:gnode:unified:{env}
Describe entity XADD cmd=service_describe {service_id}:gnode:unified:{env}
Raw entity get FCALL GNODE_TOPO_GET_ENTITY {<c>}:gnode:constellation
Send command XADD {service_id}:gnode:unified:{env}
Read response GET {service_id}:res:{id}
Pub/sub publish FCALL GNODE_PUBSUB_PUBLISH {service_id}:pubsub
Cache get/set FCALL GNODE_CACHE_GET/SET {service_id}:cache
Circuit breaker FCALL GNODE_RESILIENCE_CIRCUIT_* {service_id}:resilience
Health update XADD {service_id}:gnode:health