pub struct RecallEngine { /* private fields */ }Expand description
Hybrid recall engine combining BM25 + vector search.
Wraps a MemoryStore, SearchEngine, VectorStore, and Embedder
to provide fused search at recall time and auto-embedding at write time.
Implementations§
Source§impl RecallEngine
impl RecallEngine
Sourcepub fn new(
store: Arc<MemoryStore>,
search_engine: Arc<SearchEngine>,
vector_store: VectorStore,
embedder: Arc<dyn Embedder>,
config: RecallConfig,
) -> Result<Self>
pub fn new( store: Arc<MemoryStore>, search_engine: Arc<SearchEngine>, vector_store: VectorStore, embedder: Arc<dyn Embedder>, config: RecallConfig, ) -> Result<Self>
Create a new recall engine.
Returns an error if the Tantivy IndexWriter cannot be created.
Sourcepub fn record_relevance_feedback(
&self,
score: f32,
relevant: bool,
) -> Result<usize>
pub fn record_relevance_feedback( &self, score: f32, relevant: bool, ) -> Result<usize>
Record one relevance-feedback sample into the conformal calibrator (V8 S8). Errors honestly when the knob is off — there is no calibrated set to feed.
Sourcepub fn conformal_disclosure(
&self,
results: &mut [RecallResult],
) -> Result<Option<ConformalSetInfo>>
pub fn conformal_disclosure( &self, results: &mut [RecallResult], ) -> Result<Option<ConformalSetInfo>>
Conformal disclosure for a completed search: grades the results
against the calibrated set (marking in_conformal_set) and returns
the set-level info. Ok(None) when the knob is off — no claim is
made at all.
Sourcepub fn config(&self) -> &RecallConfig
pub fn config(&self) -> &RecallConfig
Get the configuration.
Sourcepub fn embedder_is_real(&self) -> bool
pub fn embedder_is_real(&self) -> bool
Whether the embedder is a real backend (not a stub).
When false, hybrid search would produce garbage vectors and
store_with_embedding should be avoided in favor of plain BM25.
Sourcepub fn embedder_probe(&self) -> Result<usize>
pub fn embedder_probe(&self) -> Result<usize>
Probe the configured embedder with one tiny input.
Degradation honesty: a configured embedder that cannot answer (server down, model missing) must not silently downgrade recall. Returns the produced vector length on success.
§Errors
Propagates the embedder’s error (transport, model, dimension).
Sourcepub fn store_with_embedding(
&self,
galaxy: Galaxy,
memory: &Memory,
) -> Result<()>
pub fn store_with_embedding( &self, galaxy: Galaxy, memory: &Memory, ) -> Result<()>
Store a memory with auto-embedding.
- Embeds the content using the configured embedder.
- Stores the memory in the given galaxy.
- Stores the embedding in the Embeddings galaxy.
- Adds the embedding to the vector store.
- Indexes the content in Tantivy.
Sourcepub fn store_batch_with_embedding(
&self,
entries: &[(Galaxy, &Memory)],
) -> Result<usize>
pub fn store_batch_with_embedding( &self, entries: &[(Galaxy, &Memory)], ) -> Result<usize>
Batch-store memories with auto-embedding in a single HTTP call + single Tantivy commit.
Like store_with_embedding but for multiple memories at once:
- Embeds all content via
embed_batch()(single HTTP call). - Stores all memories to LMDB.
- Stores all embeddings.
- Adds all to the vector store.
- Indexes all in Tantivy with a single writer + commit.
Returns the number of memories successfully stored.
Sourcepub fn backfill_embeddings(
&self,
galaxy: Option<Galaxy>,
limit: usize,
dry_run: bool,
) -> Result<BackfillReport>
pub fn backfill_embeddings( &self, galaxy: Option<Galaxy>, limit: usize, dry_run: bool, ) -> Result<BackfillReport>
Backfill per-memory vectors for memories that have none.
Streams the requested galaxies in LMDB key order and collects up to
limit memories lacking a stored embedding (limit == 0 = no cap),
then embeds + persists them, also seeding the in-memory vector index.
The scan opens its own read transaction and the embed/put writes use
their own transactions — no nested LMDB read txns, no full-galaxy
materialization (candidate collection is capped by limit).
dry_run reports candidates without writing.
§Errors
Fails fast when the wired embedder is the stub (backfill would store
noise), matching the embedder_is_real gate used by the write path.
Sourcepub fn hybrid_search(
&self,
query: &str,
limit: usize,
galaxy_filter: Option<Galaxy>,
) -> Vec<RecallResult>
pub fn hybrid_search( &self, query: &str, limit: usize, galaxy_filter: Option<Galaxy>, ) -> Vec<RecallResult>
Hybrid search combining BM25 + vector similarity.
Weights: bm25_weight * BM25 + vector_weight * cosine + importance_weight * importance
Sourcepub fn hybrid_search_with_disclosure(
&self,
query: &str,
limit: usize,
galaxy_filter: Option<Galaxy>,
) -> (Vec<RecallResult>, Option<ConformalSetInfo>)
pub fn hybrid_search_with_disclosure( &self, query: &str, limit: usize, galaxy_filter: Option<Galaxy>, ) -> (Vec<RecallResult>, Option<ConformalSetInfo>)
Hybrid search plus the V8 S8 disclosure: (results, conformal).
conformal is None when WM_RECALL_CONFORMAL_ALPHA is unset —
no calibrated claim exists, so none is made.
Sourcepub fn vector_search(
&self,
query: &str,
limit: usize,
galaxy_filter: Option<Galaxy>,
) -> Vec<RecallResult>
pub fn vector_search( &self, query: &str, limit: usize, galaxy_filter: Option<Galaxy>, ) -> Vec<RecallResult>
Pure vector search (no BM25).
Sourcepub fn text_search(&self, query: &str, limit: usize) -> Vec<RecallResult>
pub fn text_search(&self, query: &str, limit: usize) -> Vec<RecallResult>
Pure BM25 search (no vector).
Sourcepub fn promote_memory(&self, galaxy: Galaxy, id: Uuid) -> Result<bool>
pub fn promote_memory(&self, galaxy: Galaxy, id: Uuid) -> Result<bool>
Promote a memory on recall hit: calls Memory::recall() to apply Hebbian
strengthening and updates accessed_at/access_count/recall_count in the store.
Sourcepub fn is_private(&self, id: Uuid, galaxy: Galaxy) -> bool
pub fn is_private(&self, id: Uuid, galaxy: Galaxy) -> bool
Whether a memory is flagged is_private (missing memories count as
private — they cannot be verified visible).
Sourcepub fn cache_size(&self) -> usize
pub fn cache_size(&self) -> usize
Get the number of cached embeddings.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clear the embedding cache.
Sourcepub fn vector_count(&self) -> usize
pub fn vector_count(&self) -> usize
Get the number of vectors in the vector store.
Auto Trait Implementations§
impl !Freeze for RecallEngine
impl !RefUnwindSafe for RecallEngine
impl !UnwindSafe for RecallEngine
impl Send for RecallEngine
impl Sync for RecallEngine
impl Unpin for RecallEngine
impl UnsafeUnpin for RecallEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more