Skip to main content

SummaryMemory

Trait SummaryMemory 

Source
pub trait SummaryMemory: Send + Sync {
    // Required methods
    fn get_latest<'life0, 'life1, 'async_trait>(
        &'life0 self,
        scope: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<(String, String)>, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn store<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        scope: &'life1 str,
        summary: &'life2 str,
        source: &'life3 str,
    ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn history<'life0, 'life1, 'async_trait>(
        &'life0 self,
        scope: &'life1 str,
        limit: usize,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String, u64)>, StoreError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Compressed / summary memory.

Stores timestamped summaries of conversations, projects, or other scopes. Each summary is associated with a source (e.g. the raw conversation ID that was summarised) and a monotonic timestamp. The latest summary can be retrieved quickly, and the full history can be inspected.

§Typical backends

  • SQLite table with (scope, summary, source, created_at).
  • Document database (MongoDB, CouchDB) with scope-based indexing.
  • Append-only log file.

§Examples

use xz_memory_engine::layered::traits::SummaryMemory;
use xz_memory_core::StoreError;

async fn example(store: &dyn SummaryMemory) -> Result<(), StoreError> {
    store.store("sess-1", "User asked about weather and travel.",
                "raw-sess-1").await?;
    let latest = store.get_latest("sess-1").await?;
    assert!(latest.is_some());
    let history = store.history("sess-1", 10).await?;
    assert!(!history.is_empty());
    Ok(())
}

Required Methods§

Source

fn get_latest<'life0, 'life1, 'async_trait>( &'life0 self, scope: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<Option<(String, String)>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve the most recent summary for a scope.

Returns None if no summary exists. The tuple is (summary_text, source_id).

Source

fn store<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, scope: &'life1 str, summary: &'life2 str, source: &'life3 str, ) -> Pin<Box<dyn Future<Output = Result<(), StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Store a new summary for a scope.

Each call creates a new entry; previous summaries are preserved and can be retrieved via history.

Source

fn history<'life0, 'life1, 'async_trait>( &'life0 self, scope: &'life1 str, limit: usize, ) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String, u64)>, StoreError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Return the summary history for a scope, newest first.

Each entry is (summary_text, source_id, timestamp) where the timestamp is a Unix epoch in milliseconds.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§