haystack_core/graph/mod.rs
1//! In-memory entity graph with indexed querying, change tracking, and thread-safe access.
2//!
3//! The graph module provides a high-performance entity store optimized for
4//! the Haystack read/write/subscribe pattern:
5//!
6//! - [`EntityGraph`] — The core graph store with entities, indexes, and query engine.
7//! Supports bitmap tag indexes, B-tree value indexes, bidirectional ref adjacency,
8//! and optional CSR representation for cache-friendly traversal.
9//! - [`SharedGraph`] — Thread-safe wrapper (`Arc<RwLock<EntityGraph>>`) for concurrent access
10//! from server handlers, WebSocket watches, and federation sync.
11//! - [`GraphDiff`] / [`DiffOp`] — Change tracking entries (add/update/remove) stored in
12//! a bounded changelog for incremental sync and watch notification.
13//!
14//! ## Submodules
15//!
16//! | Module | Description |
17//! |--------|-------------|
18//! | [`entity_graph`] | Core `EntityGraph` with CRUD, filter queries, namespace-aware evaluation |
19//! | [`shared`] | `SharedGraph` — concurrent read/write access with `parking_lot::RwLock` |
20//! | [`bitmap`] | `TagBitmapIndex` — bitset-per-tag for O(popcount) Has/Missing filters |
21//! | [`value_index`] | `ValueIndex` — B-tree indexes for range queries (`temp > 72`) |
22//! | [`adjacency`] | `RefAdjacency` — bidirectional `HashMap<SmallVec>` for ref edges |
23//! | [`csr`] | `CSRAdjacency` — Compressed Sparse Row format for read-heavy traversal |
24//! | [`columnar`] | `ColumnarStore` — struct-of-arrays entity storage for scan-heavy workloads |
25//! | [`changelog`] | `GraphDiff` / `DiffOp` — bounded change log with version tracking |
26//! | [`query_planner`] | Two-phase query: bitmap acceleration → AST evaluation on candidates |
27
28pub mod adjacency;
29pub mod bitmap;
30pub mod changelog;
31pub mod columnar;
32pub mod csr;
33pub mod entity_graph;
34pub mod query_planner;
35pub mod shared;
36pub mod snapshot;
37pub mod subscriber;
38pub mod value_index;
39
40pub use changelog::{ChangelogGap, DEFAULT_CHANGELOG_CAPACITY, DiffOp, GraphDiff};
41pub use entity_graph::{EntityGraph, GraphError, HierarchyNode};
42pub use shared::SharedGraph;
43pub use snapshot::{SnapshotError, SnapshotMeta, SnapshotReader, SnapshotWriter};
44pub use subscriber::GraphSubscriber;