Why Spector?¶
The short answer: AI memory requires fusing semantic similarity, temporal decay, emotional valence, and adaptive importance into a single sub-millisecond ranking decision. No existing database — SQL, NoSQL, or vector — can do this. Spector was built from scratch to solve exactly this problem.
The Problem: AI Memory Is Not a Database Problem¶
When an AI agent needs to recall a relevant memory, it must answer a question that no database was designed to handle:
"Of the millions of things I've ever observed, which ones are most relevant right now, considering how similar they are to the current query, how important they were when stored, how they've decayed over time, what emotional tone they carry, and how often they've been recalled before?"
This is fundamentally different from SELECT * FROM memories WHERE topic = 'X' ORDER BY created_at DESC.
Why Not PostgreSQL, Redis, or Elasticsearch?¶
| Dimension | SQL / NoSQL | Spector |
|---|---|---|
| Cache locality | Fields scattered across B-tree pages (4KB+). Each field access causes a cache miss. | 64-byte cache-line-aligned cognitive headers. All scoring fields in one CPU cache line — one cycle. |
| Memory access | JDBC/driver serialization → heap allocation → GC pressure | Zero-copy MemorySegment reads. No heap allocation. 0.01% GC overhead at 1M memories. |
| Cognitive scoring | Impossible in SQL. Power-law decay, Bloom filter tag gating, and SIMD vector distance cannot be expressed in queries or aggregation pipelines. | Natively fused in a single off-heap scan — six sequential phases, each gating before the expensive vector math. |
| Micro-mutations | Every recall-count increment or valence adjustment triggers WAL write amplification and row locking. | Lock-free hardware-level atomic memory swaps. Thousands of concurrent updates with zero contention. |
| Search latency | Low milliseconds (ms) | Microseconds (µs) — 100-1000× faster |
The Key Insight
Spector is not a database with vector search bolted on. It's a cognitive scoring engine where every byte of the storage layout, every SIMD instruction, and every decay function is co-designed for a single purpose: ranking memories the way biological brains do.
Why Not a Vector Database?¶
Vector databases (Pinecone, Weaviate, Qdrant, Milvus, pgvector) solve semantic similarity. But AI memory needs more:
The Truncation Trap: If you retrieve the top-100 nearest vectors and then sort by importance in application code, a critical 6-month-old memory that's slightly less similar than a trivial conversation from 5 minutes ago is irreversibly lost — dropped before your code ever sees it.
Spector eliminates this by fusing all signals into a single scoring pass. Every memory is evaluated against similarity, importance, decay, and valence simultaneously. Nothing is truncated prematurely.
Why Not AI Memory Wrappers?¶
Systems like Mem0, Zep, and Letta add a thin layer over existing databases. They inherit all the database limitations above, plus:
- Network hop tax: Every recall crosses a REST boundary → 1-5ms added
- JSON serialization: GC pressure from parsing/encoding every result
- No hardware co-design: Cannot exploit cache-line alignment, SIMD, or off-heap storage
What Makes Spector Different¶
1. Biologically-Inspired Cognitive Architecture¶
Spector models memory the way brains do — based on peer-reviewed cognitive science:
| Biological System | Spector Implementation | Effect |
|---|---|---|
| Dopamine prediction error | Adaptive surprise detection (z-score) | Novel memories get higher importance automatically |
| Ebbinghaus forgetting curve | Power-law temporal decay (12-bucket table) | Memories fade naturally, frequently-recalled ones persist |
| Bjork Two-Factor theory | Storage strength × retrieval strength | Recalled memories become progressively easier to surface |
| Hebb's rule | Co-activation graph with spreading activation | Related memories cluster and reinforce each other |
| Amygdala | Emotional valence + arousal modulation | High-arousal events resist decay — like flashbulb memories |
| Hippocampal replay | Sleep consolidation cycles | Background process promotes important memories, prunes weak ones |
2. Sub-Millisecond Recall at Scale¶
| Benchmark | Result | Notes |
|---|---|---|
| Cognitive recall at 1M memories | 0.13ms p50 | 15× better than 2ms target |
| Vector search p50 | 88–143µs | 10K–100K docs, HNSW M=16 |
| Peak QPS (16 threads) | 61,011 | Concurrent vectorSearch |
| GC overhead | 0.01% | 1 pause / 100K searches |
| SVASQ-8 compression | 4× smaller | 99.5%+ recall preserved |
3. Zero Dependencies, Flexible Deployment¶
Spector runs anywhere the JVM runs — no Docker, no Python, no external services:
- Embedded library: Add a single JAR to your Java/Kotlin/Scala application
- Standalone server: REST + gRPC + MCP APIs on a single port
- Clustered mode: gRPC fan-out across multiple nodes with namespace sharding
- Kubernetes: Helm chart with horizontal pod autoscaling
- Spring AI / Micronaut: First-class framework integration
4. Built-In MCP Server¶
Spector includes a 13-tool MCP server for AI agent integration — Claude Desktop, Cursor, and custom agents can use cognitive memory out of the box. No wrapper libraries needed.
5. Enterprise-Grade Security¶
Every tenant gets physically separate files with independent encryption keys:
- AES-256-GCM text and WAL encryption (per-tenant keys)
- HMAC blind indexing for tag search over encrypted data
- BYOK — users can supply their own encryption keys; server operators cannot decrypt BYOK data
- File-level isolation — no shared database tables, no
WHERE tenant_id = ?leaks
Comparison Tables¶
vs. Vector Databases¶
| Feature | Spector | Pinecone | Weaviate | Qdrant | Milvus | ChromaDB | pgvector |
|---|---|---|---|---|---|---|---|
| Deployment | Embedded / Standalone / Clustered | Cloud SaaS | Self-hosted / Cloud | Self-hosted / Cloud | Self-hosted / Cloud | Embedded / Server | PostgreSQL extension |
| Language | Java 25 | Managed | Go | Rust | Go/C++ | Python | C |
| Dependencies | Zero (JDK only) | N/A (SaaS) | Docker | Docker | Docker + etcd + MinIO | Python packages | PostgreSQL |
| SIMD acceleration | ✅ AVX2/AVX-512/NEON | ✅ (internal) | ✅ | ✅ | ✅ | ❌ | ✅ (pgvector 0.5+) |
| Off-heap / Zero GC | ✅ Panama FFM | N/A | Partial | ✅ (Rust) | Partial | ❌ | N/A |
| Fused cognitive scoring | ✅ 6-phase pipeline | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Hybrid search | ✅ HNSW + BM25 + RRF | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
| Built-in MCP server | ✅ 13 tools | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Cognitive memory | ✅ 4-tier, bio-inspired | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| Quantization | SVASQ-8/4, IVF-PQ | ✅ | ✅ BQ | ✅ SQ/PQ | ✅ IVF-PQ/SQ | ❌ | ❌ |
| GPU acceleration | ✅ CUDA via Panama | ✅ | ❌ | ❌ | ✅ | ❌ | ❌ |
| License | Apache 2.0 | Proprietary | BSD-3 | Apache 2.0 | Apache 2.0 | Apache 2.0 | PostgreSQL |
vs. AI Memory Systems¶
| Feature | Spector Memory | Mem0 | Letta (MemGPT) | Zep | Stanford Generative Agents |
|---|---|---|---|---|---|
| Temporal decay | ✅ Power-law (configurable) | ❌ None | ❌ Agent-managed | ✅ Limited | ✅ Exponential |
| Recall latency (1M) | 0.13ms | 50–200ms | 100ms+ | 50–150ms | N/A (research) |
| Scoring model | ACT-R inspired | Vector similarity | Agent-managed | Hybrid | Additive |
| Two-Factor strengthening | ✅ Bjork model | ❌ | ❌ | ❌ | ❌ |
| Emotional valence | ✅ Amygdala model | ❌ | ❌ | ❌ | ❌ |
| Salience profiles | ✅ Persona + interest-based | ❌ | ❌ | ❌ | ❌ |
| Sleep consolidation | ✅ Hippocampus model | ❌ | ❌ | ❌ | ❌ |
| Hebbian associations | ✅ Co-activation graph | ❌ | ❌ | ❌ | ❌ |
| Entity knowledge graph | ✅ LLM-powered, open-schema | ❌ | ❌ | ❌ | ❌ |
| GC pressure | 0.01% (off-heap) | High (Python) | High (Python) | Moderate | N/A |
| MCP integration | ✅ Built-in | ❌ | ❌ | ❌ | ❌ |
| Infrastructure | Zero (embedded JVM) | Redis + API | PostgreSQL + API | PostgreSQL + API | Research code |
When to Choose Something Else¶
- You need a managed cloud service with zero ops → Pinecone
- You're building in Python and want the simplest path → ChromaDB
- You already have PostgreSQL and just want to add basic vector search → pgvector
- You need multi-modal search (images, video, audio) → Weaviate, Milvus
📖 Full Benchmark Report → · Performance Tuning → · Cognitive Memory →
Corrections welcome — if any comparison is inaccurate, please open an issue.