Skip to main content

MemoryRepository

Trait MemoryRepository 

Source
pub trait MemoryRepository: Send + Sync {
    // Required methods
    fn apply<'life0, 'async_trait>(
        &'life0 self,
        change_set: MemoryChangeSet,
    ) -> Pin<Box<dyn Future<Output = Result<MemoryChangeResult, MemoryRepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        namespace: &'life1 MemoryNamespace,
        node_id: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<Option<MemoryNode>, MemoryRepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn query<'life0, 'async_trait>(
        &'life0 self,
        query: MemoryQuery,
    ) -> Pin<Box<dyn Future<Output = Result<MemoryQueryResult, MemoryRepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn record_admission<'life0, 'async_trait>(
        &'life0 self,
        event: MemoryAccessEvent,
    ) -> Pin<Box<dyn Future<Output = Result<(), MemoryRepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn record_use<'life0, 'async_trait>(
        &'life0 self,
        event: MemoryAccessEvent,
    ) -> Pin<Box<dyn Future<Output = Result<(), MemoryRepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn usage_summary<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        namespace: &'life1 MemoryNamespace,
        node_id: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<MemoryUsageSummary, MemoryRepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;

    // Provided methods
    fn snapshot_namespace<'life0, 'async_trait>(
        &'life0 self,
        request: MemorySnapshotRequest,
    ) -> Pin<Box<dyn Future<Output = Result<MemoryNamespaceSnapshot, MemoryRepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn namespace_change_token<'life0, 'life1, 'async_trait>(
        &'life0 self,
        namespace: &'life1 MemoryNamespace,
    ) -> Pin<Box<dyn Future<Output = Result<Option<MemoryNamespaceChangeToken>, MemoryRepositoryError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Repository contract for evidence-backed durable memory.

Required Methods§

Source

fn apply<'life0, 'async_trait>( &'life0 self, change_set: MemoryChangeSet, ) -> Pin<Box<dyn Future<Output = Result<MemoryChangeResult, MemoryRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Atomically apply a bounded, revision-checked change set.

Source

fn get<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, namespace: &'life1 MemoryNamespace, node_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Option<MemoryNode>, MemoryRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Read one node from an exact namespace without recording access.

Source

fn query<'life0, 'async_trait>( &'life0 self, query: MemoryQuery, ) -> Pin<Box<dyn Future<Output = Result<MemoryQueryResult, MemoryRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Query one exact namespace without mutating repository state.

Source

fn record_admission<'life0, 'async_trait>( &'life0 self, event: MemoryAccessEvent, ) -> Pin<Box<dyn Future<Output = Result<(), MemoryRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Record that the host admitted the current active node revision into a model context.

Source

fn record_use<'life0, 'async_trait>( &'life0 self, event: MemoryAccessEvent, ) -> Pin<Box<dyn Future<Output = Result<(), MemoryRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Record that the host cited, selected, or otherwise used a node.

Source

fn usage_summary<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, namespace: &'life1 MemoryNamespace, node_id: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<MemoryUsageSummary, MemoryRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Return explicit admission and use counts for a node.

Provided Methods§

Source

fn snapshot_namespace<'life0, 'async_trait>( &'life0 self, request: MemorySnapshotRequest, ) -> Pin<Box<dyn Future<Output = Result<MemoryNamespaceSnapshot, MemoryRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Capture one complete, bounded, deterministic namespace view.

The default implementation is exact below the ordinary query horizon. Backends that can atomically enumerate larger views should override it.

Source

fn namespace_change_token<'life0, 'life1, 'async_trait>( &'life0 self, namespace: &'life1 MemoryNamespace, ) -> Pin<Box<dyn Future<Output = Result<Option<MemoryNamespaceChangeToken>, MemoryRepositoryError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Return an optional exact-namespace change token.

Some opts into the MemoryNamespaceChangeToken contract: every novel successful apply that changes node state in this namespace must publish a different token at the same linearization point. Tokens must remain stable across reads, idempotent replay, access events, and durable restart. Backends that cannot make those guarantees return None.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§