kglite
Pure-Rust knowledge graph engine — Cypher pipeline, snapshot/working CoW transactions, columnar / mmap / disk storage backends, optional dataset loaders (SEC EDGAR, Sodir, Wikidata). Zero PyO3 in the dependency tree; embed directly from any Rust binary.
Looking for the Python wheel?
pip install kglite— the wheel is a separate PyO3 wrapper (kglite-py) built on top of this crate. See the workspace README for the Python story; this page is the crates.io-side documentation.
Quick start
[]
= "0.10"
use ;
use HashMap;
Verify no Python dep leaked in:
|
What's in it
| Surface | Purpose |
|---|---|
kglite::api::DirGraph |
The in-memory graph. Owned by your binding's graph handle. |
kglite::api::Value |
The Cypher value type — scalars, List, Map, Node, Relationship, Path. |
kglite::api::KgError, KgErrorCode |
Typed error enum (16 variants) for binding-friendly error mapping. |
kglite::api::session::Session / Transaction |
Snapshot/working CoW transaction model with optimistic concurrency control. |
kglite::api::session::execute_read / execute_mut |
The canonical Cypher pipeline — parse, validate, optimise, execute. |
kglite::api::cypher::* |
Lower-level pipeline primitives for building custom orchestrations. |
kglite::api::load_file / save_graph |
.kgl portable graph snapshots — copy, share, reload across bindings. |
kglite::api::build_code_tree |
Tree-sitter codebase parser → graph of Function / Class / Module / Route nodes for 14 languages. |
kglite::api::compute_description / compute_schema |
Schema introspection: XML for LLM system prompts, structured types for programmatic use. |
Transactions
The Session / Transaction types wrap the snapshot/working CoW
- optimistic concurrency control. Pattern: begin, mutate, commit.
On a concurrent-writer conflict, the second commit returns
CommitOutcome::ConflictDetectedand the binding surfaces it to its caller as a retryable error.
use ;
use DirGraph;
use HashMap;
use Arc;
let session = new;
let params: = new;
let opts = ExecuteOptions ;
let mut tx = session.begin;
execute_mut?;
match session.commit
Examples
Three runnable examples ship with the crate:
embedded_basic— load + query. Smallest embedder.embedded_session— two concurrent transactions; OCC catches the conflict.embedded_blueprint— parse the kglite source tree itself, query the resulting graph.
Feature flags
Polars-io style: opt in only to what you use.
| Feature | What it pulls in |
|---|---|
default |
The engine + the code_tree parser. No dataset loaders. |
sec |
SEC EDGAR dataset loader (kglite::datasets::sec::*). |
sodir |
Norwegian Continental Shelf petroleum loader. |
wikidata |
Wikimedia truthy-NT dump fetcher + parser. |
fastembed |
Rust-native ONNX embedder for text_score() semantic search. |
[]
= { = "0.10", = ["sec", "sodir"] }
Documentation
- Rust quickstart — load + query + transaction examples.
- Embedding guide
— workspace layout, the
kglite::api::*surface tour, sketches for cgo / napi / JNI wrappers if you're building a binding in another language. - Session abstraction
— binding-implementer reference for the canonical Cypher pipeline
- CoW transaction model.
- API manifest
— curated inventory of
kglite::api::*items + semver rules. - Per-symbol docs at docs.rs/kglite.
The full kglite docs site at kglite.readthedocs.io has more on the Cypher subset, design rationale, and the protocol-server binaries that ship alongside this crate.
Semver
kglite::api::* items get semver guarantees within a minor
release. Anything outside that surface — kglite::graph::*,
kglite::datatypes::*, raw module paths — is internal and may
move freely between minor releases.
License
MIT — see LICENSE.