gitcortex-core
Shared types and the GraphStore trait for the GitCortex ecosystem.
This crate is the protocol layer — it defines every data structure that flows between the indexer, the store, and the MCP server, and the trait that any storage backend must implement. It has no I/O and no async code, making it safe to use in any context.
Add to your project
[]
= "0.2"
What's in this crate
Graph types
The core graph is made of Nodes and Edges.
use ;
use ;
// Every named entity in the codebase is a Node
let node = Node ;
Node kinds
| Kind | What it represents |
|---|---|
Function |
Free-standing function |
Method |
Function inside a class / impl block |
Struct |
Struct, class, data type |
Trait |
Rust trait |
Interface |
TypeScript / Go / Java interface |
Enum |
Enum declaration |
EnumMember |
Variant inside an enum |
Module |
Module, package, namespace |
TypeAlias |
Type alias |
Constant |
Constant or static value |
Macro |
Rust macro |
Property |
Class property, getter/setter |
Annotation |
Decorator or annotation declaration |
File |
Source file |
Folder |
Directory in the repo tree |
Edge kinds
| Kind | What it represents |
|---|---|
Calls |
Function calls another function |
Contains |
File → Module, Struct → Method, etc. |
Implements |
Struct/class implements a trait/interface |
Inherits |
Class extends another class |
Uses |
A type is used as a parameter or return type |
Imports |
Import / use declaration |
Annotated |
Symbol is decorated by an annotation |
Throws |
Method throws an exception type |
Node metadata
Every node carries structured flags collected during AST parsing:
GraphDiff — the unit of incremental change
The indexer produces a GraphDiff for each commit. Applying it to the store brings the graph up to date.
use GraphDiff;
let mut base = default;
let per_file_diff = GraphDiff ;
base.merge; // combine per-file diffs before a single store write
Unresolved cross-file edges are carried as deferred lists (deferred_calls, deferred_uses, etc.). The store resolves them against its full existing data after the new nodes are inserted.
GraphStore trait
Any storage backend implements this trait. The included KuzuGraphStore (in gitcortex-store) is the local embedded backend.
use GraphStore;
// Write
store.apply_diff?;
store.set_last_indexed_sha?;
// Read
let nodes = store.lookup_symbol?;
let callers = store.find_callers?;
let callees = store.find_callees?;
let defs = store.list_definitions?;
let path = store.trace_path?;
let ctx = store.symbol_context?;
let subgraph = store.get_subgraph?;
let unused = store.find_unused_symbols?;
let diff = store.branch_diff?;
let sha = store.last_indexed_sha?;
All methods take a branch parameter — each branch has an independent graph.
Error type
All public APIs return Result<T, GitCortexError>. The error type covers git failures, parse errors, store errors, and I/O errors.
use GitCortexError;
match result
Building a custom backend
Implement GraphStore to swap in any storage system:
use GraphStore;
The indexer and MCP server are decoupled from the backend through this trait. Swapping the backend requires no changes to either.
Supported languages
Node and edge kinds are language-neutral. Language-specific semantics are mapped to these kinds by the parsers in gitcortex-indexer:
- Rust — structs, traits, impl blocks, macros
- Python — classes, protocols, decorators, generators
- TypeScript / JavaScript — classes, interfaces, arrow functions, JSX
- Go — structs, interfaces, methods, packages
- Java — classes, interfaces, annotations, throws clauses
License
MIT — free for commercial and open-source use.