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§
Sourcefn store_window(&mut self, w: &CsiWindow) -> Result<EmbeddingId, RvcsiError>
fn store_window(&mut self, w: &CsiWindow) -> Result<EmbeddingId, RvcsiError>
Store the embedding of w, returning its newly-minted id.
Sourcefn store_event(&mut self, e: &CsiEvent) -> Result<EmbeddingId, RvcsiError>
fn store_event(&mut self, e: &CsiEvent) -> Result<EmbeddingId, RvcsiError>
Store the embedding of e, returning its newly-minted id.
Sourcefn query_similar(
&self,
query: &[f32],
k: usize,
) -> Result<Vec<SimilarHit>, RvcsiError>
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.
Sourcefn set_baseline(
&mut self,
room: &str,
version: &str,
embedding: Vec<f32>,
) -> Result<(), RvcsiError>
fn set_baseline( &mut self, room: &str, version: &str, embedding: Vec<f32>, ) -> Result<(), RvcsiError>
Set (or replace) the baseline embedding for room at version.
Sourcefn compute_drift(
&self,
room: &str,
current: &[f32],
threshold: f32,
) -> Result<Option<DriftReport>, RvcsiError>
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.
Provided Methods§
Sourcefn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Whether RfMemoryStore::len is zero.