Core Concepts
Memory Engine
The central orchestration layer for the full memory lifecycle.
Overview
The Memory Engine is MetaMemory's central orchestration layer. It manages the full lifecycle of a memory, from creation through retrieval to eventual consolidation, coordinating across multiple subsystems.
Memory Lifecycle
When you create a memory, the engine performs the following steps automatically:
- CRUD storage: persists the memory content and metadata to PostgreSQL via Prisma
- Multi-vector encoding: generates embeddings across four specialized vector spaces (semantic, emotional, process, context)
- Emotional tagging: extracts and encodes emotional state as continuous trajectories
- Graph relationships: identifies entities and creates relationship edges in Neo4j (if configured)
- Episode tracking: associates the memory with an active episode if one exists
Five-Channel Retrieval
When you search, the engine runs five parallel retrieval channels and fuses their results via weighted Reciprocal Rank Fusion (RRF):
- Semantic: cosine similarity on 1536d OpenAI embeddings
- Temporal: recency-weighted scoring with exponential decay
- Emotional: trajectory-level similarity matching
- Keyword: BM25-style lexical matching
- Graph: entity relationship traversal via Neo4j
The fusion weights are adaptive. They start at configured defaults and shift based on retrieval feedback through the adaptive retrieval system.
Initialization
import { MemoryEngine } from 'metamemory';
const engine = new MemoryEngine({
// All configuration options are optional
similarityThreshold: 0.55,
recencyDecayDays: 365,
});
await engine.initialize();The initialize() call connects to all configured backends (PostgreSQL, Pinecone, Redis, Neo4j) and loads any existing strategy state.