Skip to main content

RfMemoryStore

Trait RfMemoryStore 

Source
pub trait RfMemoryStore {
    // Required methods
    fn store_window(&mut self, w: &CsiWindow) -> Result<EmbeddingId, RvcsiError>;
    fn store_event(&mut self, e: &CsiEvent) -> Result<EmbeddingId, RvcsiError>;
    fn query_similar(
        &self,
        query: &[f32],
        k: usize,
    ) -> Result<Vec<SimilarHit>, RvcsiError>;
    fn set_baseline(
        &mut self,
        room: &str,
        version: &str,
        embedding: Vec<f32>,
    ) -> Result<(), RvcsiError>;
    fn compute_drift(
        &self,
        room: &str,
        current: &[f32],
        threshold: f32,
    ) -> Result<Option<DriftReport>, RvcsiError>;
    fn len(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A queryable RF-memory store: append window/event embeddings, search by cosine similarity, and track per-room baseline drift.

Implementations are deterministic given the same sequence of operations.

Required Methods§

Source

fn store_window(&mut self, w: &CsiWindow) -> Result<EmbeddingId, RvcsiError>

Store the embedding of w, returning its newly-minted id.

Source

fn store_event(&mut self, e: &CsiEvent) -> Result<EmbeddingId, RvcsiError>

Store the embedding of e, returning its newly-minted id.

Source

fn query_similar( &self, query: &[f32], k: usize, ) -> Result<Vec<SimilarHit>, RvcsiError>

Return up to k stored records most similar to query, by descending cosine similarity. Records whose embedding length differs from query (e.g. events vs. window queries) score 0.0 and so sort last.

Source

fn set_baseline( &mut self, room: &str, version: &str, embedding: Vec<f32>, ) -> Result<(), RvcsiError>

Set (or replace) the baseline embedding for room at version.

Source

fn compute_drift( &self, room: &str, current: &[f32], threshold: f32, ) -> Result<Option<DriftReport>, RvcsiError>

Compare current against room’s baseline. Returns None if there is no baseline for room, otherwise a DriftReport with distance = 1 - cosine_similarity(baseline, current) and exceeded = distance > threshold.

Source

fn len(&self) -> usize

Number of stored records (windows + events; baselines are not counted).

Provided Methods§

Source

fn is_empty(&self) -> bool

Whether RfMemoryStore::len is zero.

Implementors§