Skip to main content

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, and bidirectional ref adjacency.
8//! - [`SharedGraph`] — Thread-safe wrapper (`Arc<RwLock<EntityGraph>>`) for concurrent access
9//!   from server handlers and WebSocket watches.
10//! - [`GraphDiff`] / [`DiffOp`] — Change tracking entries (add/update/remove) stored in
11//!   a bounded changelog for incremental sync and watch notification.
12//!
13//! ## Submodules
14//!
15//! | Module | Description |
16//! |--------|-------------|
17//! | [`entity_graph`] | Core `EntityGraph` with CRUD, filter queries, namespace-aware evaluation |
18//! | [`shared`] | `SharedGraph` — concurrent read/write access with `parking_lot::RwLock` |
19//! | [`bitmap`] | `TagBitmapIndex` — bitset-per-tag for O(popcount) Has/Missing filters |
20//! | [`value_index`] | `ValueIndex` — B-tree indexes for range queries (`temp > 72`) |
21//! | [`adjacency`] | `RefAdjacency` — bidirectional `HashMap<SmallVec>` for ref edges |
22//! | [`changelog`] | `GraphDiff` / `DiffOp` — bounded change log with version tracking |
23
24pub mod adjacency;
25pub mod bitmap;
26pub mod changelog;
27pub mod entity_graph;
28pub mod shared;
29pub mod subscriber;
30pub mod value_index;
31
32pub use changelog::{ChangelogGap, DEFAULT_CHANGELOG_CAPACITY, DiffOp, GraphDiff};
33pub use entity_graph::{EntityGraph, GraphError, HierarchyNode};
34pub use shared::SharedGraph;
35pub use subscriber::GraphSubscriber;