Zenith Logic Foundry

Internals: RocksDB Key Layout

All durable state lives in one RocksDB database under a prefix-partitioned key space. Storage::put_raw/scan_prefix guard the graph/lifecycle prefixes so raw writes cannot corrupt them.

Core graph records

Prefix Content
node:{id} Node (labels + properties + version + timestamps), bincode
edge:{source}:{type}:{target} Edge + properties, bincode
ver:{id}:{version} Node property version (temporal reads)

Secondary indexes

Prefix Content
idx:label:{label}:{id} Label -> node
idx:edge_type:{type}:{source}:{target} Edge-type -> edge
idx:edge_out:{source}:{type}:{target} Source -> outgoing edges
idx:edge_in:{target}:{type}:{source} Target -> incoming edges
idx:property:{encoded_key}:{encoded_value}:{id} Property key/value -> entity
meta:predicate:{kind}:{name} Compact label / property / edge-type metadata for registry population

Lifecycle and bulk

Prefix Content
entity-state:{...} Mutation sequence / lifecycle state
outbox:{...} Mutation events for index catch-up
bulk-session:{...} Offline bulk-pack session state

Prolog layer

Prefix Content
rule:{name}/{arity}:{nanos} Compiled rule artifact (bincode)
strat:{name}/{arity}:{nanos} Signed dependencies of the paired rule
fact:v1:{len}:{name}/{arity}:{identity} FactStore logical fact (bincode term); {len} is the UTF-8 byte length of the predicate name, making the predicate prefix unambiguous
meta:capability:{name} Enabled optional capability

Tabling

Prefix Content
table:meta:{fingerprint} Persisted table metadata (state, dependencies)
table:answer:{fingerprint}: Persisted table answers
table:revdep:fact/predicate/rule/table:{fingerprint}: Reverse dependencies for selective invalidation

Retrieval indexes

Prefix Content
projection:{namespace}:artifact/:active: Retrieval projections (index manifests)
temporal: Temporal event / validity stores (zlf-index, RocksDB)
vector: Exact vector store (zlf-index, RocksDB); HNSW lives in a separate filesystem index

BM25 is not in RocksDB: it is a Tantivy index in a separate directory (zlf-index::BM25Index).