Skip to main content

MemoryGraph

Trait MemoryGraph 

Source
pub trait MemoryGraph {
    type Error: Into<VectorStoreError>;

    // Required methods
    fn memory_card_count(&self) -> Result<usize, Self::Error>;
    fn all_memory_cards(&self) -> Result<Vec<MemoryCard>, Self::Error>;
    fn entity_memories(
        &self,
        entity: &str,
    ) -> Result<Vec<MemoryCard>, Self::Error>;
    fn current_memory(
        &self,
        entity: &str,
        slot: &str,
    ) -> Result<Option<MemoryCard>, Self::Error>;
    fn entity_preferences(
        &self,
        entity: &str,
    ) -> Result<Vec<MemoryCard>, Self::Error>;
    fn memory_timeline(
        &self,
        entity: &str,
    ) -> Result<Vec<MemoryCard>, Self::Error>;

    // Provided method
    fn cards_for_query(
        &self,
        query: &str,
    ) -> Result<Vec<MemoryCard>, Self::Error> { ... }
}
Expand description

Read-side abstraction over a structured-memory store.

Implementations expose entity / slot / value cards with versioning, polarity, and provenance. The default crate::MemvidStore implementation backs all six methods with the memvid .mv2 memories track.

Required Associated Types§

Source

type Error: Into<VectorStoreError>

Error returned by graph queries. Must be convertible to rig::vector_store::VectorStoreError when used with an adapter that exposes a rig::vector_store::VectorStoreIndex (such as crate::MemoryCardContext).

Required Methods§

Source

fn memory_card_count(&self) -> Result<usize, Self::Error>

Total number of cards currently stored.

Source

fn all_memory_cards(&self) -> Result<Vec<MemoryCard>, Self::Error>

Snapshot of every card. Used by selection strategies that need to filter / sort across the whole set.

Source

fn entity_memories(&self, entity: &str) -> Result<Vec<MemoryCard>, Self::Error>

All cards for entity. Empty Vec for unknown entities.

Source

fn current_memory( &self, entity: &str, slot: &str, ) -> Result<Option<MemoryCard>, Self::Error>

Most recent non-retracted value for entity/slot, if any.

Source

fn entity_preferences( &self, entity: &str, ) -> Result<Vec<MemoryCard>, Self::Error>

Preference-kind cards for entity.

Source

fn memory_timeline(&self, entity: &str) -> Result<Vec<MemoryCard>, Self::Error>

Event-kind cards for entity in chronological order.

Provided Methods§

Source

fn cards_for_query(&self, query: &str) -> Result<Vec<MemoryCard>, Self::Error>

Cards whose entity mentions appear in query (case-insensitive whole-word match). The default implementation snapshots the entire archive via MemoryGraph::all_memory_cards and filters in pure Rust, which is correct but clones every card; backends backed by a graph store should override this to filter behind their own locking / indexing and avoid the intermediate full-archive allocation.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§