Skip to main content

MultiUserMemoryManager

Struct MultiUserMemoryManager 

Source
pub struct MultiUserMemoryManager {
Show 23 fields pub user_memories: Cache<String, Arc<RwLock<MemorySystem>>>, pub audit_logs: Arc<DashMap<String, Arc<RwLock<VecDeque<AuditEvent>>>>>, pub shared_db: Arc<DB>, pub base_path: PathBuf, pub default_config: MemoryConfig, pub audit_log_counter: Arc<AtomicUsize>, pub graph_memories: Cache<String, Arc<RwLock<GraphMemory>>>, pub neural_ner: Arc<NeuralNer>, pub keyword_extractor: Arc<KeywordExtractor>, pub user_evictions: Arc<AtomicUsize>, pub server_config: ServerConfig, pub event_broadcaster: Sender<MemoryEvent>, pub streaming_extractor: Arc<StreamingMemoryExtractor>, pub prospective_store: Arc<ProspectiveStore>, pub todo_store: Arc<TodoStore>, pub file_store: Arc<FileMemoryStore>, pub feedback_store: Arc<RwLock<FeedbackStore>>, pub backup_engine: Arc<ShodhBackupEngine>, pub context_sessions: Arc<ContextSessions>, pub context_broadcaster: Sender<ContextStatus>, pub ab_test_manager: Arc<ABTestManager>, pub session_store: Arc<SessionStore>, pub relevance_engine: Arc<RelevanceEngine>, /* private fields */
}
Expand description

Multi-user memory manager - central state for the server

Fields§

§user_memories: Cache<String, Arc<RwLock<MemorySystem>>>

Per-user memory systems with LRU eviction

§audit_logs: Arc<DashMap<String, Arc<RwLock<VecDeque<AuditEvent>>>>>

Per-user audit logs (in-memory cache)

§shared_db: Arc<DB>

Shared DB for all global stores (todos, reminders, files, feedback, audit)

§base_path: PathBuf

Base storage path

§default_config: MemoryConfig

Default config

§audit_log_counter: Arc<AtomicUsize>

Counter for audit log rotation checks

§graph_memories: Cache<String, Arc<RwLock<GraphMemory>>>

Per-user graph memory systems

§neural_ner: Arc<NeuralNer>

Neural NER for automatic entity extraction

§keyword_extractor: Arc<KeywordExtractor>

Statistical keyword extraction for graph population

§user_evictions: Arc<AtomicUsize>

User eviction counter for metrics

§server_config: ServerConfig

Server configuration

§event_broadcaster: Sender<MemoryEvent>

SSE event broadcaster for real-time dashboard updates

§streaming_extractor: Arc<StreamingMemoryExtractor>

Streaming memory extractor for implicit learning

§prospective_store: Arc<ProspectiveStore>

Prospective memory store for reminders/intentions

§todo_store: Arc<TodoStore>

GTD-style todo store

§file_store: Arc<FileMemoryStore>

File memory store for codebase integration

§feedback_store: Arc<RwLock<FeedbackStore>>

Implicit feedback store for memory reinforcement

§backup_engine: Arc<ShodhBackupEngine>

Backup engine for automated and manual backups

§context_sessions: Arc<ContextSessions>

Context status from Claude Code sessions

§context_broadcaster: Sender<ContextStatus>

SSE broadcaster for context status updates

§ab_test_manager: Arc<ABTestManager>

A/B testing manager for relevance scoring experiments

§session_store: Arc<SessionStore>

Session tracking store

§relevance_engine: Arc<RelevanceEngine>

Shared relevance engine for proactive memory surfacing (entity cache + learned weights persist)

Implementations§

Source§

impl MultiUserMemoryManager

Source

pub fn new(base_path: PathBuf, server_config: ServerConfig) -> Result<Self>

Source

pub fn log_event( &self, user_id: &str, event_type: &str, memory_id: &str, details: &str, )

Log audit event (non-blocking with background persistence)

Source

pub fn emit_event(&self, event: MemoryEvent)

Emit SSE event to all connected dashboard clients

Source

pub fn subscribe_events(&self) -> Receiver<MemoryEvent>

Subscribe to SSE events

Source

pub fn get_history( &self, user_id: &str, memory_id: Option<&str>, ) -> Vec<AuditEvent>

Get audit history for user

Source

pub fn get_user_memory( &self, user_id: &str, ) -> Result<Arc<RwLock<MemorySystem>>>

Get or create memory system for a user

Uses double-checked locking to prevent TOCTOU races where concurrent first-access requests both miss the cache and try to open RocksDB. RocksDB holds exclusive file locks, so the second open would fail.

Source

pub fn evict_user(&self, user_id: &str)

Evict a user’s memory and graph from in-memory caches (releases DB handles). Does NOT delete data — used before restore to release file locks.

Source

pub fn forget_user(&self, user_id: &str) -> Result<()>

Delete user data (GDPR compliance)

Cleans up:

  1. In-memory caches (user_memories, graph_memories)
  2. Shared RocksDB: todos, projects, todo indices, reminders, files, feedback, audit
  3. Per-user filesystem: per-user RocksDB, graph DB, vector indices
Source

pub fn get_stats(&self, user_id: &str) -> Result<MemoryStats>

Get statistics for a user

Source

pub fn list_users(&self) -> Vec<String>

List all users

Source

pub fn list_cached_users(&self) -> Vec<String>

List users currently loaded in the Moka cache (no filesystem scan)

Source

pub fn get_audit_logs(&self, user_id: &str, limit: usize) -> Vec<AuditEvent>

Get audit logs for a user

Source

pub fn flush_all_databases(&self) -> Result<()>

Flush all RocksDB databases

Source

pub fn save_all_vector_indices(&self) -> Result<()>

Save all vector indices to disk

Source

pub fn get_neural_ner(&self) -> Arc<NeuralNer>

Get neural NER for entity extraction

Source

pub fn get_keyword_extractor(&self) -> Arc<KeywordExtractor>

Get keyword extractor for statistical term extraction

Source

pub fn get_user_graph(&self, user_id: &str) -> Result<Arc<RwLock<GraphMemory>>>

Get or create graph memory for a user

Uses the same per-user creation lock as get_user_memory to prevent concurrent RocksDB open races on the graph directory.

Source

pub fn get_user_graph_stats(&self, user_id: &str) -> Result<GraphStats>

Get graph statistics for a user

Source

pub fn run_maintenance_all_users(&self) -> usize

Run maintenance on all cached user memories

Source

pub fn streaming_extractor(&self) -> &Arc<StreamingMemoryExtractor>

Get the streaming extractor

Source

pub fn backup_engine(&self) -> &Arc<ShodhBackupEngine>

Get the backup engine

Source

pub fn ab_test_manager(&self) -> &Arc<ABTestManager>

Get the A/B test manager

Source

pub fn todo_store(&self) -> &Arc<TodoStore>

Get the todo store

Source

pub fn prospective_store(&self) -> &Arc<ProspectiveStore>

Get the prospective store

Source

pub fn file_store(&self) -> &Arc<FileMemoryStore>

Get the file store

Source

pub fn feedback_store(&self) -> &Arc<RwLock<FeedbackStore>>

Get the feedback store

Source

pub fn session_store(&self) -> &Arc<SessionStore>

Get the session store

Source

pub fn context_sessions(&self) -> &Arc<ContextSessions>

Get context sessions

Source

pub fn subscribe_context(&self) -> Receiver<ContextStatus>

Subscribe to context status updates

Source

pub fn broadcast_context(&self, status: ContextStatus)

Broadcast context status update

Source

pub fn server_config(&self) -> &ServerConfig

Get server config

Source

pub fn base_path(&self) -> &Path

Get base path

Source

pub fn user_evictions(&self) -> usize

Get user evictions count

Source

pub fn users_in_cache(&self) -> usize

Get users in cache count

Source

pub fn check_and_emit_due_reminders(&self) -> usize

Active reminder check: scan all users for due reminders, mark them triggered, and emit REMINDER_DUE events to the broadcast channel.

Called by the dedicated 60-second reminder scheduler in main.rs. Returns the number of reminders triggered.

Source

pub fn collect_secondary_store_refs(&self) -> Vec<(String, Arc<DB>)>

Collect references to all secondary store databases for comprehensive backup. All shared stores (todos, prospective, files, feedback, audit) share a single DB, so we return one reference. BackupEngine handles all CFs automatically.

Source

pub fn run_backup_all_users(&self, max_backups: usize) -> usize

Run backups for all active users

Source

pub fn process_experience_into_graph( &self, user_id: &str, experience: &Experience, memory_id: &MemoryId, ) -> Result<()>

Process an experience and extract entities/relationships into the graph

SHO-102: Improved graph building with:

  • Neural NER entities
  • Tags as Technology/Concept entities
  • All-caps terms (API, TUI, NER, etc.)
  • Issue IDs (SHO-XX pattern)
  • Semantic similarity edges between memories

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Sync + Send>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Fruit for T
where T: Send + Downcast,