Skip to main content

MemoryStore

Struct MemoryStore 

Source
pub struct MemoryStore { /* private fields */ }
Expand description

Store para operaciones de memoria.

Implementations§

Source§

impl MemoryStore

Source

pub fn new(conn: Arc<Mutex<Connection>>) -> Self

Crea un nuevo MemoryStore.

Source

pub fn with_crypto(self, crypto: Arc<Mutex<CryptoEngine>>) -> Self

Asigna el motor de encriptación.

Source

pub async fn index_embedding( &self, memory: &Memory, engine: &Arc<EmbeddingEngine>, embedding_store: &EmbeddingStore, ) -> Result<()>

Indexa embedding para una memoria.

Source

pub async fn reindex_embeddings( &self, project: &str, engine: &Arc<EmbeddingEngine>, embedding_store: &EmbeddingStore, ) -> Result<ReindexStats>

Reindexa todas las memorias sin embedding.

Source

pub fn save( &self, input: CreateMemoryInput, engine: Option<Arc<EmbeddingEngine>>, embedding_store: Option<EmbeddingStore>, ) -> Result<Memory>

Save a new memory. Handles dedupe, topic_key upserts, and returns the memory. Si engine y embedding_store son proporcionados, intenta indexar el embedding de forma no bloqueante.

Source

pub fn update(&self, id: Uuid, input: UpdateMemoryInput) -> Result<Memory>

Update a memory by ID. Increments revision_count.

Source

pub fn delete(&self, id: Uuid, hard: bool) -> Result<()>

Soft-delete a memory (default). Hard-delete if hard=true.

Source

pub fn restore(&self, id: Uuid) -> Result<Memory>

Restore a soft-deleted memory.

Source

pub fn get(&self, id: Uuid) -> Result<Option<Memory>>

Get a memory by ID, incrementing access_count. Ignores soft-deleted.

Source

pub fn list( &self, project: &str, memory_type: Option<&MemoryType>, importance: Option<&Importance>, scope: Option<&Scope>, limit: u32, offset: u32, ) -> Result<Vec<Memory>>

List memories for a project with optional filters. Ignores soft-deleted.

Source

pub fn context( &self, project: &str, scope: Option<&Scope>, limit: u32, ) -> Result<Vec<Memory>>

Get recent memories for context (session injection). Ignores soft-deleted.

Source

pub fn stats(&self, project: &str) -> Result<MemoryStats>

Get stats for a project.

Source

pub fn list_projects(&self) -> Result<Vec<ProjectSummary>>

List all projects with summary.

Source

pub fn project_exists(&self, project: &str) -> Result<bool>

Check if a project exists.

Source

pub fn search( &self, query: &SearchQuery, weights: &SearchWeights, semantic_scores: Option<&HashMap<Uuid, f32>>, ) -> Result<Vec<SearchResult>>

Search memories using the hybrid search engine. Si se proporcionan scores semánticos, se integran en la puntuación.

Source

pub fn search_reranked( &self, query: &SearchQuery, weights: &SearchWeights, semantic_scores: Option<&HashMap<Uuid, f32>>, engine: &Arc<EmbeddingEngine>, ) -> Result<Vec<SearchResult>>

Search with cross-encoder reranking. When embeddings feature is enabled, re-ranks top results using semantic refinement.

Source

pub fn row_to_memory(row: &Row<'_>) -> Result<Memory, Error>

Maps a SQL row to a Memory struct. Public for use by MCP tools.

Source

pub fn save_prompt(&self, input: CreatePromptInput) -> Result<UserPrompt>

Guarda un prompt de usuario.

Source

pub fn create_relation( &self, input: CreateRelationInput, ) -> Result<MemoryRelation>

Crea una relación entre dos memorias.

Source

pub fn save_batch( &self, inputs: Vec<CreateMemoryInput>, engine: Option<Arc<EmbeddingEngine>>, embedding_store: Option<EmbeddingStore>, ) -> Result<(Vec<Memory>, Vec<Memory>)>

Guarda un lote de memorias, detectando duplicados.

Source

pub fn delete_relation(&self, relation_id: Uuid) -> Result<bool>

Elimina una relación por su ID.

Source

pub fn audit(&self, project: &str, days_threshold: u32) -> Result<AuditReport>

Ejecuta una auditoría de calidad sobre un proyecto.

Source

pub fn find_duplicates_semantic( &self, project: &str, threshold: f64, embedding_store: &EmbeddingStore, ) -> Result<Vec<DuplicateGroup>>

Encuentra duplicados semánticos usando embeddings.

Source

pub fn add_feedback( &self, memory_id: Uuid, is_useful: bool, reason: Option<&str>, ) -> Result<i64>

Registra feedback sobre una memoria.

Source

pub fn deprecate( &self, memory_id: Uuid, reason: &str, supersedes_id: Option<Uuid>, ) -> Result<Memory>

Marca una memoria como deprecada.

Source

pub fn get_graph(&self, project: &str) -> Result<GraphData>

Obtiene el grafo de conocimiento de un proyecto.

Source

pub fn summarize( &self, project: &str, session_id: Option<Uuid>, ) -> Result<SummaryResult>

Genera un resumen ejecutivo de un proyecto o sesión.

Source

pub fn inject_context( &self, project: &str, file: Option<&str>, limit: u32, ) -> Result<String>

Genera un bloque de contexto formateado para inyección en prompts.

Source

pub fn forget_project(&self, project: &str) -> Result<u32>

Elimina todas las memorias de un proyecto (hard delete).

Source

pub fn health(&self, project: Option<&str>) -> Result<HealthReport>

Reporte de salud del sistema.

Source

pub fn remind( &self, project: &str, importance: &Importance, ) -> Result<Vec<Memory>>

Retorna memorias críticas/high como recordatorios.

Source

pub fn suggest_tags( &self, project: &str, title: &str, content: Option<&str>, ) -> Result<Vec<String>>

Sugiere tags basados en tags existentes y contenido.

Source

pub fn knowledge_gaps(&self, project: &str) -> Result<KnowledgeGapsReport>

Analiza brechas de conocimiento en un proyecto.

Source

pub fn encrypt_existing(&self, memory_id: Uuid) -> Result<Memory>

Encripta una memoria existente in-place.

Source

pub fn decrypt_existing(&self, memory_id: Uuid) -> Result<Memory>

Desencripta una memoria encriptada (permanentemente).

Source

pub fn capture_passive( &self, text: &str, project: &str, session_id: Option<Uuid>, engine: Option<Arc<EmbeddingEngine>>, embedding_store: Option<EmbeddingStore>, ) -> Result<Vec<Memory>>

Parsea texto de output de sesión y extrae memorias automáticamente. Busca secciones como ## Key Learnings, ## Decisions, ## Architecture, etc.

Source

pub fn detect_conflict_candidates( &self, memory: &Memory, ) -> Result<Vec<ConflictCandidate>>

Detecta candidatos de conflicto para una memoria recién guardada. Busca por: topic_key compartido, título similar, y mismo project+type.

Source

pub fn list_conflict_candidates( &self, project: &str, status: Option<&str>, limit: u32, ) -> Result<Vec<ConflictCandidate>>

Lista candidatos de conflicto pendientes.

Source

pub fn judge_conflict( &self, candidate_id: i64, judged_relation: &str, reasoning: &str, judged_by: &str, ) -> Result<ConflictJudgment>

Registra el juicio de un LLM/agente sobre un candidato. Si el juicio es conflicts_with/supersedes, actualiza la relación automáticamente.

Source

pub fn get_existing_relations( &self, memory_id_a: Uuid, memory_id_b: Uuid, ) -> Result<Vec<MemoryRelation>>

Obtiene contexto formateado para que un LLM juzgue un par de memorias. Obtiene las relaciones existentes entre dos memorias.

Source

pub fn get_conflict_context( &self, source_id: Uuid, target_id: Uuid, ) -> Result<String>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more