How 28naem-del/mnemosyne works
1. What this repository is
Mnemosyne is a TypeScript/Node.js memory subsystem for AI agents, packaged as a library rather than an app. Its architecture is split into layered memory services: ingestion, retrieval, graph enrichment, caching/broadcast, and self-improvement. The public entrypoint is src/index.ts, with higher-level agent-facing tools under src/tools.
2. Primary runtime boundary
The only hard dependency is Qdrant for vector storage and similarity search. Redis is optional but powers the L1/L2 cache and pub/sub broadcast. FalkorDB is optional and provides the temporal knowledge graph. This means the repo can run in a minimal vector-only mode or a fuller multi-agent mode depending on config.
3. Storage and search core
src/core holds the low-level primitives: embeddings, BM25 support, deduplication, Qdrant access, and security filtering. This layer is the foundation for both write and read paths; it isolates vector DB interaction from the cognitive logic above it.
4. Ingestion pipeline
src/pipeline is the write path. Inputs pass through security filtering, embedding, dedup/merge, extraction/classification, then into storage and downstream enrichment. The README describes this as a zero-LLM, multi-step ingestion pipeline that produces structured memory records quickly and deterministically.
5. Memory classification and normalization
Pipeline modules like classifier.ts, extraction.ts, and extractor.ts turn raw text into typed memory objects. The repo’s memory model includes urgency, domain, type, confidence, and temporal fields, which later drive ranking and graph behavior. This is where unstructured text becomes durable memory metadata.
6. Knowledge graph layer
src/graph is the optional relational layer. It handles auto-linking, activation/pathing, and temporal sequences over entities and memories. In architecture terms, the graph is not the primary store; it is an enrichment and navigation layer attached to memories already stored in Qdrant.
7. Recall and ranking path
Retrieval is handled primarily in src/cognitive, with cache support from src/cache. The read path is: cache lookup, embedding, vector search, intent-aware scoring, diversity reranking, then optional graph enrichment and reasoning. This layer is where multi-signal ranking, recency/importance weighting, confidence, and query intent are combined.
8. Cache and broadcast
src/cache/layer-cache.ts implements the two-tier cache strategy, while src/broadcast handles cross-agent propagation. Redis is the boundary here: it provides both short-lived recall acceleration and real-time fan-out for memory events, enabling multiple agent instances to stay in sync.
9. Cognitive/self-improvement layer
src/cognitive contains the higher-order memory behaviors: decay, consolidation, confidence, intent, sentiment, preferences, proactive recall, lesson extraction, pattern mining, and Theory of Mind. Conceptually, this layer sits above storage and retrieval and continually re-weights or reshapes memory based on usage and feedback.
10. Agent-facing tools
src/tools is the main integration surface for external agent frameworks. It exposes operations such as store, recall, forget, feedback, consolidate, preferences, lessons, patterns, and mesh blocks. These tools are thin orchestration wrappers over the pipeline, cognitive, graph, cache, and broadcast subsystems.
11. Multi-agent mesh features
The broadcast and tools packages together enable shared-state behavior across agents: shared memory blocks, cross-agent synthesis, and awareness queries about what another agent knows. This is the repository’s main distributed-systems boundary, and it depends on Redis-backed messaging plus shared persistence services.
12. Project structure and validation
examples/ shows integration usage, while tests/ focuses on core behaviors like BM25, configuration, recall, and storage. CI is GitHub Actions-based, with Docker assets for local deployment. The architecture is therefore library-first, service-backed, and validated around retrieval/storage correctness rather than UI or HTTP concerns.
Main entry points: pipeline/index.ts Pipeline · core/index.ts Core · tools/index.ts Tools · src/index.ts Public API
Components 21
src
Core library implementation
- Public API · Library entrypoint that re-exports the main memory system
src/index.ts - Config · Runtime configuration and service wiring
src/config.ts - Core · Low-level embeddings, BM25, deduplication, Qdrant access, and security filtering
src/core/index.ts - Embeddings · Embedding generation used by ingestion and recall
src/core/embeddings.ts - BM25 · Sparse lexical scoring support for retrieval
src/core/bm25.ts - Qdrant · Primary persistent vector store and similarity search boundary
src/core/qdrant.ts - Security · Input and retrieval safety filtering
src/core/security.ts - Pipeline · Write path that transforms raw input into structured memory
src/pipeline/index.ts - Classifier · Assigns memory types, urgency, domain, and confidence
src/pipeline/classifier.ts - Extraction · Turns raw text into structured memory records
src/pipeline/extraction.ts - Graph · Optional relational layer for linking and temporal navigation
src/graph/index.ts - Auto-link · Creates relationships between related memories and entities
src/graph/autolink.ts - FalkorDB · Optional temporal knowledge graph backend
src/graph/falkordb.ts - Cache · L1/L2 cache interface for recall acceleration
src/cache/layer-cache.ts - Broadcast · Cross-agent memory propagation and synthesis
src/broadcast/index.ts - Cognitive · Decay, consolidation, intent, confidence, recall, and self-improvement behaviors
src/cognitive/index.ts - Recall · Read-path scoring and result assembly
src/cognitive/retrieval.ts - Consolidation · Promotes and reshapes memory based on usage and feedback
src/cognitive/consolidation.ts - Tools · Agent-facing operations for store, recall, forget, feedback, and memory mining
src/tools/index.ts
docs
Repository documentation and examples
- Examples · Integration examples for basic, Redis, and FalkorDB setups
examples/README.md
infra
Build, release, and deployment assets
- Deploy · Container and compose assets for local deployment
docker-compose.yml
Connections 29
- Public API → Config: loads · Entry point wires runtime configuration
- Public API → Core: exposes · Public API re-exports storage/search primitives
- Public API → Pipeline: exposes · Public API exposes ingestion workflow
- Public API → Cognitive: exposes · Public API exposes higher-order memory behaviors
- Public API → Tools: exposes · Public API exposes agent-facing tools
- Pipeline → Security: filters · Write path begins with safety filtering
- Pipeline → Embeddings: embeds · Pipeline vectorizes incoming content
- Pipeline → Classifier: classifies · Pipeline assigns memory metadata
- Pipeline → Extraction: normalizes · Pipeline converts text into structured memory
- Pipeline → Core: stores · Structured memories are persisted through the core layer
- Core → Qdrant: persists · Core owns the hard vector-store dependency
- Core → BM25: ranks · Core combines sparse lexical scoring with vector retrieval
- Core → Embeddings: uses · Core shares embedding primitives with ingestion and recall
- Core → Security: guards · Core applies filtering around stored/retrieved content
- Cognitive → Recall: coordinates · Cognitive layer orchestrates read-path ranking
- Cognitive → Consolidation: learns · Cognitive layer updates memory importance over time
- Recall → Cache: checks · Recall consults the cache before vector search
- Recall → Core: queries · Recall uses core search primitives
- Recall → Graph: enriches · Recall can add graph-based context
- Graph → Auto-link: links · Graph layer builds relationships between memories
- Graph → FalkorDB: stores · Optional graph backend for temporal knowledge
- Broadcast → Cache: shares · Broadcasting complements cache-backed shared state
- Broadcast → Tools: powers · Agent tools expose shared-memory operations
- Tools → Pipeline: stores via · Store tool invokes ingestion pipeline
- Tools → Recall: recalls via · Recall tool invokes ranked retrieval
- Tools → Consolidation: consolidates · Tools expose consolidation workflows
- Examples → Tools: demonstrates · Examples show how to use the agent-facing API
- Deploy → Qdrant: deploys with · Local deployment includes the vector store service
- Deploy → FalkorDB: optionally deploys · Compose setup can include the graph backend