cgn-kvcached: Multi-tier KV cache daemon

Host-local KV block service with RAM + SSD tiers and cross-node fetch over QUIC (optional RDMA). Feeds prefix-overlap data so cgn-router can schedule onto GPUs that already hold prompt state.

Overview

cgn-kvcached implements Cognitora’s tier-3 / tier-4 cache story from KV tiering: GPU-resident KV stays inside the engine; evicted blocks land in RAM and SSD; misses can pull from peers. Block IDs use BLAKE3-derived addresses (see tiering doc).

Features

  • gRPC cognitora.v1.Kv for router/agent queries
  • QUIC listener for peer fetch ([kv].quic_listen, default 0.0.0.0:7072), authenticated with mTLS
  • RocksDB-backed metadata + SSD layout under [kv].ssd_dir / [kv].index_dir
  • RAM cap via [kv].ram_gib, SSD cap via [kv].ssd_gib
  • Tunable eviction and optional mirror behaviour (see example config and KV tiering)

Architecture

Engine eviction → agent UDS/gRPC → cgn-kvcached (RAM → SSD) ⟷ QUIC peers. The router does not read KV bytes directly; it consumes overlap hints computed from agent + cache metadata.

Configuration (highlights)

KeyTypeDefaultDescription
[kv].listenstring0.0.0.0:7071Kv gRPC service
[kv].quic_listenstring0.0.0.0:7072Peer fetch transport
[kv].allow_insecure_quicboolfalseAllow plain QUIC on a non-loopback listener
[kv].quic_server_namestringcognitoraSAN every peer cert needs under mTLS
[kv].ram_gibu3232RAM tier budget
[kv].ssd_gibu321024SSD tier budget
[kv].ssd_dirpath/var/lib/cognitora/kvCold tier files
[kv].index_dirpath/var/lib/cognitora/indexRocksDB index

Without [security].require_mtls = true, the daemon refuses to start on a non-loopback quic_listen unless allow_insecure_quic is set. With mTLS, issue certificates with the SAN above: cgn-ctl pki bootstrap includes it by default, and --san replaces the defaults, so list it yourself there.

Example

[cluster]
name = "prod"
etcd_endpoints = ["http://etcd:2379"]

[security]
require_mtls = true

[kv]
listen      = "0.0.0.0:7071"
quic_listen = "0.0.0.0:7072"
ram_gib     = 16
ssd_gib     = 512
ssd_dir     = "/var/lib/cognitora/kv/ssd"
index_dir   = "/var/lib/cognitora/kv/index"

Dependencies

  • cgn-agent: publishes residency / eviction events
  • Peer cgn-kvcached instances: for cross-node fills

Operational targets

See latency buckets in KV tiering and SLOs. Cold-cache playbook: Runbook: Cache cold.

Related documentation

Source: rust/services/cgn-kvcached/