pub struct MemoryStore { /* private fields */ }Expand description
Store para operaciones de memoria.
Implementations§
Source§impl MemoryStore
impl MemoryStore
Sourcepub fn new(conn: Arc<Mutex<Connection>>) -> Self
pub fn new(conn: Arc<Mutex<Connection>>) -> Self
Crea un nuevo MemoryStore.
Sourcepub fn with_crypto(self, crypto: Arc<Mutex<CryptoEngine>>) -> Self
pub fn with_crypto(self, crypto: Arc<Mutex<CryptoEngine>>) -> Self
Asigna el motor de encriptación.
Sourcepub async fn index_embedding(
&self,
memory: &Memory,
engine: &Arc<EmbeddingEngine>,
embedding_store: &EmbeddingStore,
) -> Result<()>
pub async fn index_embedding( &self, memory: &Memory, engine: &Arc<EmbeddingEngine>, embedding_store: &EmbeddingStore, ) -> Result<()>
Indexa embedding para una memoria.
Sourcepub async fn reindex_embeddings(
&self,
project: &str,
engine: &Arc<EmbeddingEngine>,
embedding_store: &EmbeddingStore,
) -> Result<ReindexStats>
pub async fn reindex_embeddings( &self, project: &str, engine: &Arc<EmbeddingEngine>, embedding_store: &EmbeddingStore, ) -> Result<ReindexStats>
Reindexa todas las memorias sin embedding.
Sourcepub fn save(
&self,
input: CreateMemoryInput,
engine: Option<Arc<EmbeddingEngine>>,
embedding_store: Option<EmbeddingStore>,
) -> Result<Memory>
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.
Sourcepub fn update(&self, id: Uuid, input: UpdateMemoryInput) -> Result<Memory>
pub fn update(&self, id: Uuid, input: UpdateMemoryInput) -> Result<Memory>
Update a memory by ID. Increments revision_count.
Sourcepub fn delete(&self, id: Uuid, hard: bool) -> Result<()>
pub fn delete(&self, id: Uuid, hard: bool) -> Result<()>
Soft-delete a memory (default). Hard-delete if hard=true.
Sourcepub fn get(&self, id: Uuid) -> Result<Option<Memory>>
pub fn get(&self, id: Uuid) -> Result<Option<Memory>>
Get a memory by ID, incrementing access_count. Ignores soft-deleted.
Sourcepub fn list(
&self,
project: &str,
memory_type: Option<&MemoryType>,
importance: Option<&Importance>,
scope: Option<&Scope>,
limit: u32,
offset: u32,
) -> Result<Vec<Memory>>
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.
Sourcepub fn context(
&self,
project: &str,
scope: Option<&Scope>,
limit: u32,
) -> Result<Vec<Memory>>
pub fn context( &self, project: &str, scope: Option<&Scope>, limit: u32, ) -> Result<Vec<Memory>>
Get recent memories for context (session injection). Ignores soft-deleted.
Sourcepub fn stats(&self, project: &str) -> Result<MemoryStats>
pub fn stats(&self, project: &str) -> Result<MemoryStats>
Get stats for a project.
Sourcepub fn list_projects(&self) -> Result<Vec<ProjectSummary>>
pub fn list_projects(&self) -> Result<Vec<ProjectSummary>>
List all projects with summary.
Sourcepub fn project_exists(&self, project: &str) -> Result<bool>
pub fn project_exists(&self, project: &str) -> Result<bool>
Check if a project exists.
Sourcepub fn search(
&self,
query: &SearchQuery,
weights: &SearchWeights,
semantic_scores: Option<&HashMap<Uuid, f32>>,
) -> Result<Vec<SearchResult>>
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.
Sourcepub fn search_reranked(
&self,
query: &SearchQuery,
weights: &SearchWeights,
semantic_scores: Option<&HashMap<Uuid, f32>>,
engine: &Arc<EmbeddingEngine>,
) -> Result<Vec<SearchResult>>
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.
Sourcepub fn row_to_memory(row: &Row<'_>) -> Result<Memory, Error>
pub fn row_to_memory(row: &Row<'_>) -> Result<Memory, Error>
Maps a SQL row to a Memory struct. Public for use by MCP tools.
Sourcepub fn save_prompt(&self, input: CreatePromptInput) -> Result<UserPrompt>
pub fn save_prompt(&self, input: CreatePromptInput) -> Result<UserPrompt>
Guarda un prompt de usuario.
Sourcepub fn create_relation(
&self,
input: CreateRelationInput,
) -> Result<MemoryRelation>
pub fn create_relation( &self, input: CreateRelationInput, ) -> Result<MemoryRelation>
Crea una relación entre dos memorias.
Sourcepub fn save_batch(
&self,
inputs: Vec<CreateMemoryInput>,
engine: Option<Arc<EmbeddingEngine>>,
embedding_store: Option<EmbeddingStore>,
) -> Result<(Vec<Memory>, Vec<Memory>)>
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.
Sourcepub fn delete_relation(&self, relation_id: Uuid) -> Result<bool>
pub fn delete_relation(&self, relation_id: Uuid) -> Result<bool>
Elimina una relación por su ID.
Sourcepub fn audit(&self, project: &str, days_threshold: u32) -> Result<AuditReport>
pub fn audit(&self, project: &str, days_threshold: u32) -> Result<AuditReport>
Ejecuta una auditoría de calidad sobre un proyecto.
Sourcepub fn find_duplicates_semantic(
&self,
project: &str,
threshold: f64,
embedding_store: &EmbeddingStore,
) -> Result<Vec<DuplicateGroup>>
pub fn find_duplicates_semantic( &self, project: &str, threshold: f64, embedding_store: &EmbeddingStore, ) -> Result<Vec<DuplicateGroup>>
Encuentra duplicados semánticos usando embeddings.
Sourcepub fn add_feedback(
&self,
memory_id: Uuid,
is_useful: bool,
reason: Option<&str>,
) -> Result<i64>
pub fn add_feedback( &self, memory_id: Uuid, is_useful: bool, reason: Option<&str>, ) -> Result<i64>
Registra feedback sobre una memoria.
Sourcepub fn deprecate(
&self,
memory_id: Uuid,
reason: &str,
supersedes_id: Option<Uuid>,
) -> Result<Memory>
pub fn deprecate( &self, memory_id: Uuid, reason: &str, supersedes_id: Option<Uuid>, ) -> Result<Memory>
Marca una memoria como deprecada.
Sourcepub fn get_graph(&self, project: &str) -> Result<GraphData>
pub fn get_graph(&self, project: &str) -> Result<GraphData>
Obtiene el grafo de conocimiento de un proyecto.
Sourcepub fn summarize(
&self,
project: &str,
session_id: Option<Uuid>,
) -> Result<SummaryResult>
pub fn summarize( &self, project: &str, session_id: Option<Uuid>, ) -> Result<SummaryResult>
Genera un resumen ejecutivo de un proyecto o sesión.
Sourcepub fn inject_context(
&self,
project: &str,
file: Option<&str>,
limit: u32,
) -> Result<String>
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.
Sourcepub fn forget_project(&self, project: &str) -> Result<u32>
pub fn forget_project(&self, project: &str) -> Result<u32>
Elimina todas las memorias de un proyecto (hard delete).
Sourcepub fn health(&self, project: Option<&str>) -> Result<HealthReport>
pub fn health(&self, project: Option<&str>) -> Result<HealthReport>
Reporte de salud del sistema.
Sourcepub fn remind(
&self,
project: &str,
importance: &Importance,
) -> Result<Vec<Memory>>
pub fn remind( &self, project: &str, importance: &Importance, ) -> Result<Vec<Memory>>
Retorna memorias críticas/high como recordatorios.
Sugiere tags basados en tags existentes y contenido.
Sourcepub fn knowledge_gaps(&self, project: &str) -> Result<KnowledgeGapsReport>
pub fn knowledge_gaps(&self, project: &str) -> Result<KnowledgeGapsReport>
Analiza brechas de conocimiento en un proyecto.
Sourcepub fn encrypt_existing(&self, memory_id: Uuid) -> Result<Memory>
pub fn encrypt_existing(&self, memory_id: Uuid) -> Result<Memory>
Encripta una memoria existente in-place.
Sourcepub fn decrypt_existing(&self, memory_id: Uuid) -> Result<Memory>
pub fn decrypt_existing(&self, memory_id: Uuid) -> Result<Memory>
Desencripta una memoria encriptada (permanentemente).
Sourcepub fn capture_passive(
&self,
text: &str,
project: &str,
session_id: Option<Uuid>,
engine: Option<Arc<EmbeddingEngine>>,
embedding_store: Option<EmbeddingStore>,
) -> Result<Vec<Memory>>
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.
Sourcepub fn detect_conflict_candidates(
&self,
memory: &Memory,
) -> Result<Vec<ConflictCandidate>>
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.
Sourcepub fn list_conflict_candidates(
&self,
project: &str,
status: Option<&str>,
limit: u32,
) -> Result<Vec<ConflictCandidate>>
pub fn list_conflict_candidates( &self, project: &str, status: Option<&str>, limit: u32, ) -> Result<Vec<ConflictCandidate>>
Lista candidatos de conflicto pendientes.
Sourcepub fn judge_conflict(
&self,
candidate_id: i64,
judged_relation: &str,
reasoning: &str,
judged_by: &str,
) -> Result<ConflictJudgment>
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.
Sourcepub fn get_existing_relations(
&self,
memory_id_a: Uuid,
memory_id_b: Uuid,
) -> Result<Vec<MemoryRelation>>
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.
pub fn get_conflict_context( &self, source_id: Uuid, target_id: Uuid, ) -> Result<String>
Auto Trait Implementations§
impl Freeze for MemoryStore
impl RefUnwindSafe for MemoryStore
impl Send for MemoryStore
impl Sync for MemoryStore
impl Unpin for MemoryStore
impl UnsafeUnpin for MemoryStore
impl UnwindSafe for MemoryStore
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
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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