/** * Memory engine — prediction error gating, HyDE query expansion, * spreading activation, and memory conversion utilities. * * Pure cognitive functions — no storage imports, no side effects. * All state access goes through CortexStore / providers passed as arguments. */ import type { CortexStore } from '../core/store.js'; import type { EmbedProvider } from '../core/embed.js'; import type { LLMProvider } from '../core/llm.js'; import type { Memory, MemorySummary, SearchResult, ActivationResult, GateResult } from '../core/types.js'; /** Similarity threshold above which a new observation is treated as a duplicate. */ export declare const SIMILARITY_MERGE = 0.85; /** Similarity threshold above which a new observation is linked to an existing memory. */ export declare const SIMILARITY_LINK = 0.5; /** Activation score decay factor per hop during spreading activation. */ export declare const ACTIVATION_DECAY = 0.5; /** Maximum BFS depth for spreading activation traversal. */ export declare const MAX_ACTIVATION_DEPTH = 2; /** * Determine how a new observation should be ingested based on similarity * to existing memories. * * - merge (>mergeThreshold): too similar to existing memory (duplicate risk) * - link (>linkThreshold): moderately similar — store and link as related * - novel: nothing close — candidate for a new memory concept * * Thresholds can be overridden per namespace via config. */ export declare function predictionErrorGate(store: CortexStore, embedding: number[], thresholds?: { merge?: number; link?: number; }): Promise; /** * Expand a user query using Hypothetical Document Embeddings (HyDE). * * Instead of embedding the raw query, asks the LLM to generate a * hypothetical passage that would answer the query, then embeds THAT. * This dramatically improves recall for concept-level questions. */ export declare function hydeExpand(query: string, llm: LLMProvider, embed: EmbedProvider): Promise; /** * Starting from a set of initial search results, traverse edges to activate * related concepts via BFS. Returns primary results augmented with activated * neighbors, ranked by combined activation score. * * Activation decays by ACTIVATION_DECAY (0.5) per hop, weighted by edge weight. * Max depth defaults to 2 hops. * * When queryEmbedding is provided, propagation is query-conditioned: branches * whose target memories are more similar to the query receive higher weight, * biasing traversal toward query-relevant parts of the graph (Synapse, 2601.02744). */ export declare function spreadActivation(store: CortexStore, initial: SearchResult[], queryEmbedding?: number[], depth?: number): Promise; /** * GNN-style retrieval: for each candidate, compute aggregated embedding * by weighting with graph neighbors, then re-score against query. * * Algorithm: * 1. Fetch limit*2 initial candidates via ANN search. * 2. For each candidate, fetch up to 5 graph neighbors, compute a * weighted mean embedding (0.6 self + 0.4 mean-neighbors). * 3. Re-score each candidate's aggregated embedding against the query. * 4. Return top `limit` results sorted by aggregated score. * * Candidates with no neighbors fall back to their original ANN score. */ export declare function aggregatedRetrieval(store: CortexStore, queryEmbedding: number[], limit?: number): Promise; /** * Thousand Brains retrieval: run parallel retrievals from multiple query * formulations, vote on which memories appear across threads. * * Algorithm: * 1. Use the LLM to rephrase the query in 3 different ways. * 2. Embed each variant (plus the original) in parallel and run ANN search. * 3. Aggregate results via Borda count — memories appearing in more threads * and at higher ranks score more highly. * 4. Return top `limit` results sorted by consensus count, then Borda score. * * LLM failure is non-fatal: falls back to the original query only. */ export declare function multiAnchorRetrieval(store: CortexStore, embed: EmbedProvider, llm: LLMProvider, queryText: string, limit?: number): Promise; /** * Convert a full Memory to a MemorySummary (strips embedding and other large fields). */ export declare function memoryToSummary(memory: Memory): MemorySummary; //# sourceMappingURL=memory.d.ts.map