pub trait FactMemory: Send + Sync {
// Required methods
fn remember<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
fact: &'life1 str,
tags: &'life2 [String],
) -> Pin<Box<dyn Future<Output = Result<String, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn recall<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, f32, Vec<String>)>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn forget<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Semantic / tagged fact memory.
Stores discrete facts with optional tags and supports fuzzy retrieval by semantic similarity or keyword match. Designed for knowledge that is ingested, queried, and occasionally pruned — the agent’s long-term general knowledge.
§Typical backends
- Vector database with embedding-based retrieval.
- Hybrid index combining BM25 keyword search and dense embeddings.
- Graph database with tag-based traversal.
§Examples
use xz_memory_engine::layered::traits::FactMemory;
use xz_memory_core::StoreError;
async fn example(store: &dyn FactMemory) -> Result<(), StoreError> {
let id = store.remember("Tokyo is the capital of Japan", &["geography".into()]).await?;
let results = store.recall("capital of Japan", 5).await?;
assert!(!results.is_empty());
store.forget(&id).await?;
Ok(())
}Required Methods§
Sourcefn remember<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
fact: &'life1 str,
tags: &'life2 [String],
) -> Pin<Box<dyn Future<Output = Result<String, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn remember<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
fact: &'life1 str,
tags: &'life2 [String],
) -> Pin<Box<dyn Future<Output = Result<String, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Store a fact with optional tags and return a unique identifier.
The returned String is the backend-assigned ID that can be used
to later forget the fact.
Sourcefn recall<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, f32, Vec<String>)>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn recall<'life0, 'life1, 'async_trait>(
&'life0 self,
query: &'life1 str,
limit: usize,
) -> Pin<Box<dyn Future<Output = Result<Vec<(String, f32, Vec<String>)>, StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Recall facts matching the query.
Returns a vector of (fact_text, relevance_score, tags) tuples
sorted by descending relevance. limit caps the number of results.
Sourcefn forget<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn forget<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Delete a fact by its unique ID.
Removing a non-existent ID should succeed silently (no error).
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".