Docs / graph-storage-architecture · Edit on GitHub

rgbuilder-graph Storage Architecture

The rgbuilder-graph crate stores the code knowledge graph: typed nodes and edges, secondary indexes, persistence, and a mini query language. Analysis algorithms live in rgbuilder-analysis.

Layers

LayerModuleRole
Schemaschema.rsNode, Edge, NodeType, EdgeType
Backendbackend/memory.rsMemoryBackend — RwLock maps + indexes
Interningintern.rsArc<str> dedup for index keys
Queryquery.rsFilter language (type:Function, compound |)
Persistencesnapshot.rs, columnar_snapshot.rsv1 bincode / v2 columnar mmap
APIcode_graph.rsCodeGraph wrapper

MemoryBackend

  • Nodes: HashMap<Uuid, Node> under RwLock
  • Edges: Vec<Edge> under RwLock
  • Indexes: name, type, label, property, edge-type
  • Query cache: invalidated on every mutation

Zero-clone APIs for analysis: edge_topology_typed(), for_each_node, find_node_ids_by_*.

Snapshots

FormatVersionOpen cost
JSONlegacyFull parse
bincode mmapv1Deserialize payload
columnar mmapv2Header + indexes only

v2 uses fixed-width rows (64 B node, 40 B edge) + string pool. BLAKE3 content_digest enables cache invalidation.

SQLite (blast-radius only)

rgBuilder does not store the knowledge graph in SQLite. The only SQLite usage is macro_call_index.db in rgbuilder-analysis — a precomputed blast-radius lookup cache written at discover and read by blast-radius T0 (MacroCallLookupDb). GQL, export, and metrics use the columnar mmap graph.

Downstream

MemoryBackend / ColumnarGraphMmap → rgbuilder-analysis::PetGraphView → algorithms

See also: analysis-architecture.md, cli-io-sanity-qe.md.