Skip to main content

shodh_memory/
lib.rs

1//! Shodh-Memory Library
2//!
3//! Edge-native AI memory system for autonomous agents.
4//! Optimized for deployment on resource-constrained devices.
5//!
6//! # Key Features
7//! - Tiered memory (working/session/long-term) based on cognitive science
8//! - Local vector search (Vamana/DiskANN)
9//! - Local embeddings (MiniLM-L6 via ONNX)
10//! - Knowledge graph for entity relationships
11//!
12//! # Edge Optimizations
13//! - Lazy model loading (reduces startup RAM by ~200MB)
14//! - Configurable thread count for power efficiency
15//! - RocksDB embedded storage (no external database)
16//! - Full offline operation
17
18pub mod ab_testing;
19pub mod auth;
20pub mod backup;
21pub mod config;
22pub mod constants;
23pub mod decay;
24pub mod embeddings;
25pub mod errors;
26pub mod graph_memory;
27pub mod handlers;
28pub mod integrations;
29pub mod memory;
30pub mod metrics;
31pub mod middleware;
32pub mod mif;
33pub mod migration;
34pub mod query_parsing;
35pub mod relevance;
36pub mod serialization;
37pub mod server;
38pub mod similarity;
39pub mod streaming;
40pub mod tracing_setup;
41pub mod validation;
42pub mod vector_db;
43
44/// Bincode 2.x decode with a 10 MB allocation limit.
45///
46/// All RocksDB deserialization MUST use this instead of `bincode::config::standard()`
47/// to prevent OOM crashes from corrupted varint length prefixes. Without a limit,
48/// a corrupted varint can declare multi-exabyte allocations that abort the process.
49///
50/// 10 MB is generous: the largest legitimate record (EntityNode with 384-dim
51/// embedding + metadata) is ~2 KB. Even a Memory with full Experience is under 100 KB.
52pub fn bincode_safe_config() -> impl bincode::config::Config {
53    bincode::config::standard().with_limit::<{ 10 * 1024 * 1024 }>()
54}
55
56// Re-export dependencies to ensure tests/benchmarks use the same version
57pub use chrono;
58pub use parking_lot;
59pub use uuid;
60
61#[cfg(feature = "python")]
62pub mod python;
63
64#[cfg(feature = "zenoh")]
65pub mod zenoh_transport;