Skip to main content

mentedb_cognitive/
lib.rs

1//! # mentedb-cognitive: Cognitive Engine for MenteDB
2//!
3//! This crate implements the seven cognitive features that distinguish MenteDB
4//! from a conventional vector database. These features run at write time and
5//! read time, giving the engine awareness of the knowledge it holds.
6//!
7//! ## Modules
8//!
9//! - [`interference`]: Detects pairs of memories similar enough to confuse an LLM,
10//!   generates disambiguation text, and reorders context to maximize separation.
11//!
12//! - [`pain`]: Records negative experiences (failed actions, user corrections) as
13//!   pain signals with intensity and decay. Surfaces warnings during context assembly.
14//!
15//! - [`phantom`]: Detects references to entities not present in the knowledge base
16//!   (phantom memories). Flags gaps so the agent can acquire missing knowledge.
17//!
18//! - [`speculative`]: Pre-assembles context windows for predicted upcoming queries
19//!   based on conversation trajectory. Uses Jaccard keyword overlap for cache hits.
20//!
21//! - [`stream`]: Monitors the LLM's output token stream in real time, comparing
22//!   against stored facts to detect contradictions, forgotten knowledge, corrections,
23//!   and reinforcements mid-generation.
24//!
25//! - [`trajectory`]: Tracks the reasoning arc of a conversation as a sequence of
26//!   decision states. Supports resume context generation and next-topic prediction.
27//!
28//! - [`write_inference`]: Runs inference at write time to detect contradictions,
29//!   create relationship edges, mark obsolete memories, adjust confidence, and
30//!   trigger belief propagation automatically.
31
32/// Interference detection between confusable memories.
33pub mod interference;
34/// Pain signal registry for negative experience tracking.
35pub mod pain;
36/// Phantom memory detection for knowledge gaps.
37pub mod phantom;
38/// Speculative context pre assembly cache.
39pub mod speculative;
40/// Real time LLM output stream monitoring.
41pub mod stream;
42/// Conversation trajectory tracking and prediction.
43pub mod trajectory;
44/// Write time inference engine for automatic relationship discovery.
45pub mod write_inference;
46
47pub use interference::{InterferenceDetector, InterferencePair};
48pub use pain::{PainRegistry, PainSignal};
49pub use phantom::{EntityRegistry, PhantomConfig, PhantomMemory, PhantomPriority, PhantomTracker};
50pub use speculative::{CacheEntry, CacheStats, SpeculativeCache};
51pub use stream::{CognitionStream, StreamAlert, StreamConfig, TokenEvent};
52pub use trajectory::{DecisionState, TrajectoryNode, TrajectoryTracker};
53pub use write_inference::{InferredAction, WriteInferenceConfig, WriteInferenceEngine};