Skip to main content

ContextMemoryBackend

Trait ContextMemoryBackend 

Source
pub trait ContextMemoryBackend: Send + Sync {
    // Required methods
    fn load_persona_facts<'a>(
        &'a self,
        min_confidence: f64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemPersonaFact>, Box<dyn Error + Send + Sync>>> + Send + 'a>>;
    fn load_trajectory_entries<'a>(
        &'a self,
        tier: Option<&'a str>,
        top_k: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemTrajectoryEntry>, Box<dyn Error + Send + Sync>>> + Send + 'a>>;
    fn load_tree_nodes<'a>(
        &'a self,
        level: u32,
        top_k: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemTreeNode>, Box<dyn Error + Send + Sync>>> + Send + 'a>>;
    fn load_summaries<'a>(
        &'a self,
        conversation_id: i64,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemSummary>, Box<dyn Error + Send + Sync>>> + Send + 'a>>;
    fn retrieve_reasoning_strategies<'a>(
        &'a self,
        query: &'a str,
        top_k: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemReasoningStrategy>, Box<dyn Error + Send + Sync>>> + Send + 'a>>;
    fn mark_reasoning_used<'a>(
        &'a self,
        ids: &'a [String],
    ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'a>>;
    fn retrieve_corrections<'a>(
        &'a self,
        query: &'a str,
        limit: usize,
        min_score: f32,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemCorrection>, Box<dyn Error + Send + Sync>>> + Send + 'a>>;
    fn recall<'a>(
        &'a self,
        query: &'a str,
        limit: usize,
        router: Option<&'a dyn AsyncMemoryRouter>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemRecalledMessage>, Box<dyn Error + Send + Sync>>> + Send + 'a>>;
    fn recall_graph_facts<'a>(
        &'a self,
        query: &'a str,
        params: GraphRecallParams<'a>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemGraphFact>, Box<dyn Error + Send + Sync>>> + Send + 'a>>;
    fn search_session_summaries<'a>(
        &'a self,
        query: &'a str,
        limit: usize,
        current_conversation_id: Option<i64>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemSessionSummary>, Box<dyn Error + Send + Sync>>> + Send + 'a>>;
    fn search_document_collection<'a>(
        &'a self,
        collection: &'a str,
        query: &'a str,
        top_k: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<MemDocumentChunk>, Box<dyn Error + Send + Sync>>> + Send + 'a>>;
}
Expand description

Abstraction over SemanticMemory that zeph-context uses for all memory operations during context assembly.

Defined in Layer 0 (zeph-common) so that zeph-context (Layer 1) can hold Option<Arc<dyn ContextMemoryBackend>> without importing zeph-memory. zeph-core (Layer 4) provides the concrete implementation that wraps SemanticMemory.

All async methods use Pin<Box<dyn Future<...>>> for dyn-compatibility.

Required Methods§

Source

fn load_persona_facts<'a>( &'a self, min_confidence: f64, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemPersonaFact>, Box<dyn Error + Send + Sync>>> + Send + 'a>>

Load persona facts with at least min_confidence.

Source

fn load_trajectory_entries<'a>( &'a self, tier: Option<&'a str>, top_k: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemTrajectoryEntry>, Box<dyn Error + Send + Sync>>> + Send + 'a>>

Load top_k trajectory entries for the given tier filter (e.g. "procedural").

Source

fn load_tree_nodes<'a>( &'a self, level: u32, top_k: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemTreeNode>, Box<dyn Error + Send + Sync>>> + Send + 'a>>

Load top_k memory tree nodes at the given level.

Source

fn load_summaries<'a>( &'a self, conversation_id: i64, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemSummary>, Box<dyn Error + Send + Sync>>> + Send + 'a>>

Load all summaries for the given conversation (raw row ID).

Source

fn retrieve_reasoning_strategies<'a>( &'a self, query: &'a str, top_k: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemReasoningStrategy>, Box<dyn Error + Send + Sync>>> + Send + 'a>>

Retrieve the top-top_k reasoning strategies for query.

Source

fn mark_reasoning_used<'a>( &'a self, ids: &'a [String], ) -> Pin<Box<dyn Future<Output = Result<(), Box<dyn Error + Send + Sync>>> + Send + 'a>>

Mark reasoning strategies as used (fire-and-forget; best-effort).

Source

fn retrieve_corrections<'a>( &'a self, query: &'a str, limit: usize, min_score: f32, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemCorrection>, Box<dyn Error + Send + Sync>>> + Send + 'a>>

Retrieve corrections similar to query, up to limit with min_score.

Source

fn recall<'a>( &'a self, query: &'a str, limit: usize, router: Option<&'a dyn AsyncMemoryRouter>, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemRecalledMessage>, Box<dyn Error + Send + Sync>>> + Send + 'a>>

Recall semantically similar messages for query, up to limit.

Source

fn recall_graph_facts<'a>( &'a self, query: &'a str, params: GraphRecallParams<'a>, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemGraphFact>, Box<dyn Error + Send + Sync>>> + Send + 'a>>

Recall graph facts for query with view-aware enrichment.

Source

fn search_session_summaries<'a>( &'a self, query: &'a str, limit: usize, current_conversation_id: Option<i64>, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemSessionSummary>, Box<dyn Error + Send + Sync>>> + Send + 'a>>

Search cross-session summaries for query, excluding current_conversation_id.

Source

fn search_document_collection<'a>( &'a self, collection: &'a str, query: &'a str, top_k: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<MemDocumentChunk>, Box<dyn Error + Send + Sync>>> + Send + 'a>>

Search a named document collection for query, returning top_k chunks.

Implementors§