gitcortex-store
KuzuDB-backed graph store for GitCortex. Implements the GraphStore trait from gitcortex-core with a local embedded database — one database file per repository, with independent per-branch node and edge tables inside it. No server process, no external dependencies.
Add to your project
[]
= "0.2"
= "0.2"
Quick start
use KuzuGraphStore;
use GraphStore;
use Path;
// Open or create the database for the repo at this path
let mut store = open?;
// Apply a diff produced by gitcortex-indexer
store.apply_diff?;
store.set_last_indexed_sha?;
// Query
let nodes = store.lookup_symbol?;
let callers = store.find_callers?;
Where data is stored
The database lives in your home directory, never in the repo:
~/.local/share/gitcortex/{repo_id}/
graph.kuzu # KuzuDB database (all branches in one file)
schema_version # schema version marker for auto-migration
main.sha # last indexed SHA for branch "main"
feat__auth.sha # last indexed SHA for branch "feat/auth"
These files are machine-local and should never be committed.
Branch isolation
Each branch gets its own node and edge tables inside the single database file. Switching branches in the query API is as simple as passing a different branch name — no file switching, no re-opening the database.
// Query the same symbol across two branches
let on_main = store.lookup_symbol?;
let on_feat = store.lookup_symbol?;
Branch names are normalised automatically: / becomes __, leading digits are prefixed, so feat/my-branch becomes the table prefix feat__my_branch internally.
Schema versioning
If the on-disk schema doesn't match the current version, the store automatically wipes all data for that repo and prints a message:
gitcortex: schema version mismatch (expected 4); wiping graph store for re-index
The next gcx hook (or store.apply_diff) triggers a full re-index from scratch.
Full API
All methods are from the GraphStore trait in gitcortex-core:
use GraphStore;
use Path;
// Write
store.apply_diff?;
store.set_last_indexed_sha?;
// Basic lookups
let nodes = store.lookup_symbol?; // exact match
let nodes = store.lookup_symbol?; // fuzzy (substring)
let defs = store.list_definitions?;
let all = store.list_all_nodes?;
let edges = store.list_all_edges?;
// Caller / callee traversal
let callers = store.find_callers?; // 1 hop
let deep = store.find_callers_deep?; // up to 3 hops
let callees = store.find_callees?; // forward, 2 hops
// Structural queries
let impls = store.find_implementors?;
let path = store.trace_path?; // shortest BFS path
let sub = store.get_subgraph?; // 2-hop neighbourhood
let ctx = store.symbol_context?; // callers + callees + used_by
let range = store.list_symbols_in_range?;
let dead = store.find_unused_symbols?;
// Branch diff
let diff = store.branch_diff?; // nodes/edges added or removed
// Index state
let sha = store.last_indexed_sha?; // None if never indexed
Multi-hop results
find_callers_deep, find_callees return a CallersDeep struct:
Symbol context
symbol_context gives a 360° view of a single symbol:
Subgraph
get_subgraph returns all nodes and edges within N hops of a seed symbol:
let sub = store.get_subgraph?;
println!;
// direction options: "in" (callers only), "out" (callees only), "both"
Using without gitcortex-indexer
The store is independent of the indexer. You can build GraphDiff values manually and apply them directly — useful for testing or custom import pipelines:
use ;
use ;
use KuzuGraphStore;
use GraphStore;
let mut store = open?;
let node = Node ;
let diff = GraphDiff ;
store.apply_diff?;
Testing
The round-trip tests in tests/round_trip.rs demonstrate the full write→read cycle:
cargo test -p gitcortex-store
Each test uses a tempfile::TempDir so tests are fully isolated. Because KuzuDB cannot open the same database path from multiple processes simultaneously, tests that open different databases run in parallel safely; tests sharing a path must be serialised.
Dependencies
| Crate | Purpose |
|---|---|
gitcortex-core |
Shared graph types and GraphStore trait |
kuzu |
Embedded graph database |
dashmap |
Concurrent map for in-memory branch metadata caching |
tracing |
Structured logging for slow query diagnostics |
License
MIT — free for commercial and open-source use.