π§ Cognitive Memory¶
Persona, Dream, Wander, Decide, Express are experimental β see Experimental pathways.
The Founding Distinction (MF-001)
A database returns what was written. A memory engine reconstructs what is reachable from a cue at this moment β under decay, association, and tier physics β without losing a live trace because the first index was the wrong one.
As formalized in the Memory Fundamentals Specification, the identity of a memory engine is its recall algebra, not its storage topology. Spector implements this model as a single off-heap engram substrate with multiple access paths.
The 4-Tier Memory Architecture¶
Rather than treating memory as an undifferentiated vector store, Spector organizes traces across four cognitive tiers to address distinct operational retention windows, access frequencies, and consolidation dynamics:
Volatile, limited-capacity buffer for the current task context. Operates as a circular buffer where the oldest entries are automatically evicted when capacity is reached.
- Capacity: Configurable (default: 100 records)
- Storage: In-memory segment (volatile)
- Use case: "What was the user just talking about?"
Time-stamped event records representing autobiographical history. Partitioned by day and backed by memory-mapped files for persistence across restarts. Supports Reflect consolidation into semantic memory.
- Capacity: Scalable via time-partitioning (benchmarked at 100k, 1M, 10M engrams; bounded recall fan-out)
- Storage: High-performance memory-mapped partitions (persistent)
- Use case: "What error did we debug yesterday?"
Distilled, permanent world knowledge and facts. Created by consolidation (Reflect cycles) from episodic clusters, or directly by the user. Supports two modes:
- Partitioned Mode (default): Rolling partition files with parallel retrieval.
-
Single-File Mode: In-memory slab for light deployments.
-
Capacity: Scalable in partitioned mode (configurable per-partition, default: 10,000 records; multi-partition scaling tested to 10M)
- Recall: Parallel scan across partitions using virtual threads
- Compaction: Per-partition rebuilds performed live during operation
- Use case: "The user prefers dark mode."
Learned procedures, rules, and behavioral guidelines. A small, append-only store for rules that shape the agent's reasoning.
- Capacity: Configurable (default: 500 records)
- Storage: In-memory segment (persistent via write-ahead log replay)
- Use case: "Always use exponential backoff for retries."
π§ Which Memory Tier & Pathway Do I Need?¶
Choosing the right memory tier ensures optimal signal-to-noise ratio, hardware cache efficiency, and retention physics. Use this interactive decision tree and comparison matrix to select the right tier and retrieval pathway for your agent:
flowchart TD
START(["π§ Ingesting or Recalling Knowledge"]) --> Q1{"What is the operational lifecycle of this trace?"}
Q1 -->|"Current prompt / dialogue turn<br/>(Volatile buffer)"| T_WM["π§ͺ Working Memory<br/><b>rememberWorking(...)</b><br/>β’ Circular volatile buffer<br/>β’ Sub-microsecond seek<br/>β’ Auto-evicts oldest entries"]
Q1 -->|"Timestamped event / agent action<br/>(Autobiographical journal)"| T_EM["π Episodic Memory<br/><b>rememberEpisodic(...)</b><br/>β’ Daily memory-mapped partition<br/>β’ Power-law temporal decay<br/>β’ Consolidated during sleep"]
Q1 -->|"Distilled fact / user preference<br/>(Permanent world knowledge)"| T_SE["𧬠Semantic Memory<br/><b>rememberSemantic(...)</b><br/>⒠Zero-GC off-heap partitions<br/>⒠Parallel SIMD vector scan<br/>⒠Enduring cross-session facts"]
Q1 -->|"Operational rule / tool constraint<br/>(Behavioral guidelines)"| T_PR["βοΈ Procedural Memory<br/><b>rememberProcedural(...)</b><br/>β’ Append-only WAL store<br/>β’ Deterministic constraint check<br/>β’ Pinned across all sessions"]
T_WM --> P_SELECT{"How will this trace be queried?"}
T_EM --> P_SELECT
T_SE --> P_SELECT
T_PR --> P_SELECT
P_SELECT -->|"Associative cue + temporal context"| PW_FUSED["β‘ 6-Phase Fused Recall<br/>Bloom filter + valence + decay + SIMD distance"]
P_SELECT -->|"Direct pointer / known Engram ID"| PW_DIRECT["π― Direct Engram Seek<br/>Zero-allocation offset seek (~150ns)"]
P_SELECT -->|"Entity relationship or causal flow"| PW_GRAPH["πΈοΈ Cognitive Graph Recall<br/>Hebbian association + Temporal chains"]
P_SELECT -->|"Corroboration from multiple events"| PW_MULTI["π Multi-Evidence Recall<br/>Cross-episode fact synthesis & clustering"]
classDef working fill:#2563eb18,stroke:#3b82f6,stroke-width:1.5px
classDef episodic fill:#10b98118,stroke:#10b981,stroke-width:1.5px
classDef semantic fill:#8b5cf618,stroke:#8b5cf6,stroke-width:1.5px
classDef procedural fill:#f59e0b18,stroke:#f59e0b,stroke-width:1.5px
class T_WM working
class T_EM episodic
class T_SE semantic
class T_PR procedural Tier Decision Matrix¶
| Tier | Substrate & Storage | Retention & Eviction | Latency (p50) | Ingestion Verb | Best-Fit Agent Scenarios |
|---|---|---|---|---|---|
| π§ͺ Working | Volatile off-heap circular ring | FIFO eviction on capacity overflow | ~100ns | rememberWorking | Multi-turn chat context, scratchpads, intermediate plan steps |
| π Episodic | Mapped binary partition files (.seg) | Time-partitioned (empirically benchmarked to 10M engrams), Reflect consolidation | <1ms | rememberEpisodic | Interaction logs, tool execution traces, temporal user events |
| 𧬠Semantic | Partitioned zero-GC off-heap slabs | Permanent, compacted during offline/online cycles | 1.01ms | rememberSemantic | User preferences, distilled facts, codebase knowledge, ontology |
| βοΈ Procedural | Persistent append-only WAL segment | Permanent, deterministic ordering, high salience | <200ns | rememberProcedural | System prompt constraints, tool policies, safety guidelines |
Cognitive Architecture Mapping¶
As established in the Memory Fundamentals Specification (MF-001), Spector models cognitive subsystems as concrete operational mechanisms addressing specific retrieval and retention requirements:
graph TB
subgraph "π§ Spector Memory"
SM[SpectorMemory<br/>FaΓ§ade]:::core --> CT[RememberPathway<br/>Pathway: Remember]:::core
SM --> RP[RecallPathway<br/>Pathway: Recall]:::core
subgraph "Cortex β Tier Stores"
NK[NamespaceKernel<br/>EngramMemory]:::core --> WM[Working<br/>Working tier]:::working
NK --> EM[Episodic<br/>Episodic tier]:::episodic
NK --> SE[Semantic<br/>Semantic tier]:::semantic
NK --> PR[Procedural<br/>Procedural tier]:::procedural
end
subgraph "Synapse β Scoring"
CS[CognitiveScorer<br/>6-phase SIMD]:::synapse --> STE[SynapticTagEncoder<br/>Bloom Filter]:::synapse
CS --> DS[DecayStrategy<br/>Temporal Decay]:::synapse
end
subgraph "Neuromodulators"
SD[SurpriseDetector<br/>Dopamine]:::synapse --> FP[FlashbulbPolicy]:::synapse
VT[ValenceTracker<br/>Amygdala]:::synapse
HP[HabituationPenalty<br/>Anti-filter bubble]:::synapse
SS[SuppressionSet<br/>Inhibition]:::synapse
end
subgraph "3-Layer Cognitive Graph"
HG[HebbianGraph<br/>Layer 1: Association]:::core
TC[TemporalChain<br/>Layer 2: Causal]:::core
HEG[HyperEntityGraph<br/>Layer 3: Event-Episode]:::core
ED[EntityDirectory<br/>Identity Registry]:::core
CA[CoActivationMemory<br/>STDP Learning]:::core
end
subgraph "Consolidation"
RD[ReflectDaemon<br/>Reflect Consolidation]:::core
TCC[VacuumCompactor<br/>Tombstone census only]:::core
end
CT --> NK
RP --> CS
RP --> NK
RP --> HG
RP --> TC
RP --> ED
RP --> HEG
end What Makes This Different¶
Every AI memory solution today wraps a scripting layer around Postgres/pgvector or a standard vector database. They suffer from:
- Network latency: 50-200ms per query (HTTP β DB β HTTP)
- Global Interpreter Lock: Sequential embedding and scoring under a lock
- The truncation trap: Candidate generation by a single signal (typically cosine top-K) followed by post-filtering, permanently dropping high-importance or emotionally salient memories with lower initial cosine similarity.
Spector Memory collapses the entire cognitive stack onto a zero-overhead, off-heap memory store with hardware-accelerated scoring. The result:
| Metric | Traditional Python Layer | Spector Memory |
|---|---|---|
| Query latency | 50-200ms | Ultra-low latency β |
| GC pauses | Unpredictable | β€0.01% (100% off-heap) β |
| Scoring pipeline | Post-filter (lossy) | Fused SIMD (lossless) |
| Concurrent queries | Lock-limited | 61,000 QPS (Virtual Threads) β |
| Memory per record | ~500B (Object wrappers) | Compact binary header + vector |
β Measured on Intel Core Ultra 9 285K, Java 25, AVX2. See Benchmarks.
Explore the Documentation¶
-
System Architecture
Package hierarchy, data flow diagrams, and extensibility model
-
Recall Pathway & 6-Phase Scoring
Deep dive into the SIMD hot-loop: tombstone β tags β valence β importance β L2 β fused score
-
3-Layer Cognitive Graph
Hebbian association, temporal causal chains, and event-episode hyperedges β three graph structures that augment vector recall with multi-hop reasoning, integrated with a central EntityDirectory
-
Cognitive Subsystems
Principled cognitive subsystems mapped to code: Cortex, Hippocampus, Synapse, Dopamine, Amygdala, Habituation, Inhibition
-
Performance & SIMD
Benchmark results, SIMD kernel throughput, optimization techniques, virtual thread scaling
-
Off-Heap Panama Design
Zero-GC architecture, MemorySegment lifecycle, mmap partitions, 64-byte CognitiveRecord binary format
-
Cognitive Evaluation
Detailed test methodology, evaluation results, statistical comparisons, and the Mike Thompson dataset
-
API Reference
SpectorMemory.Builder, RecallOptions, CognitiveResult, MemoryType β full method signatures