A stigmergic memory palace engine — fully local, private, self-optimizing AI memory that runs in a browser tab, on a server, or on an edge device. No cloud. No API keys. No data exfiltration.
A spatial memory system where Wings contain Rooms, Rooms hold Closets, and Closets store Drawers — each level a first-class graph node with pheromone trails.
Connects rooms within the same wing. Navigate between subjects in one domain.
Connects rooms across different wings. Cross-domain discoveries live here.
Links drawers to knowledge graph entities. Memory ↔ concept bridges.
Auto-computed semantic similarity between drawers. Cost inversely proportional to similarity.
Knowledge graph edges: causes, inhibits, correlates_with, instance_of, and more.
GraphPalace combines graph databases, stigmergy, active inference, and on-device embeddings into one self-optimizing system.
5-type pheromone system on nodes and edges creates an adaptive, self-optimizing knowledge landscape. Paths that work get reinforced. Old trails fade naturally.
Wings → Rooms → Closets → Drawers as first-class graph nodes, not metadata tags. Halls connect within wings; tunnels cross between them.
Composite cost model: 40% semantic similarity + 30% pheromone guidance + 30% structural weight. Context-adaptive weights per task type.
Karl Friston's Expected Free Energy minimization. Bayesian beliefs, softmax action selection, temperature annealing. 5 archetypes from Explorer to Specialist.
Runs in a browser tab (WASM), on a server, or an edge device. No cloud, no API keys, no data exfiltration. Your memories stay yours.
Full Model Context Protocol interface: palace navigation, memory CRUD, knowledge graph, stigmergy controls, agent diaries, import/export.
Temporal entity-relationship triples with confidence scores, valid_from/valid_to timestamps, and contradiction detection. Causal chains up to 5 hops.
TF-IDF + sparse random projection (384-dim) in pure Rust — zero model files, zero API calls. Optional ONNX backend for all-MiniLM-L6-v2. Measured 96% recall@5.
A teachable file any LLM loads to learn palace navigation — Cypher patterns, pheromone semantics, tool reference, and example workflows.
Pure Rust semantic embeddings — no model files, no API calls. TF-IDF tokenization + sparse random projection gives 96% recall@5, matching MemPalace's 96.6% target.
Automatic SIMILAR_TO edges between semantically related drawers — A* navigates meaning connections, not just structural hierarchy.
Inspired by ant colony optimization and adapted from STAN_X v8 — five pheromone types encode what the swarm has learned about the palace.
cost(edge) = 0.4 × C_semantic + 0.3 × C_pheromone + 0.3 × C_structural
Semantic similarity guides toward the goal. Pheromone trails encode collective intelligence. Structural weights respect the graph topology. Together they create paths that are meaningful, proven, and architecturally sound.
Thirteen crates forming the complete GraphPalace system — 680 tests, zero failures, building on Kuzu's embedded graph engine.
A detailed feature comparison against existing AI memory systems.
| Feature | MemPalace | Mem0 | Zep / Graphiti | GraphPalace |
|---|---|---|---|---|
| Storage | ChromaDB (flat vectors) | LLM-extracted facts | Neo4j (graph) | Property graph + vectors + FTS |
| Retrieval | Cosine + metadata | LLM retrieval | Graph traversal | Stigmergic A* (semantic + pheromone + structural) |
| Intelligence | None (passive) | LLM-dependent | Entity resolution | Active Inference agents |
| Spatial Hierarchy | ✓ Wings/Rooms/Closets/Drawers | ✗ | ✗ | ✓ First-class graph nodes |
| Knowledge Graph | ✓ SQLite triples | ✗ | ✓ Neo4j | ✓ Temporal triples in Kuzu |
| Pheromones | ✗ | ✗ | ✗ | ✓ 5 types, auto-decay |
| Self-Optimizing | ✗ | ✗ | ✗ | ✓ Paths improve with use |
| Runs Where | Local Python | Cloud only | Cloud or self-host | Browser / Edge / Server (WASM) |
| Privacy | ✓ Fully local | ✗ Cloud | ⚠ Self-host available | ✓ Zero-cloud, zero-API |
| LLM Integration | ✓ MCP (19 tools) | ✓ API | ✓ API | ✓ MCP (28 tools) + skills.md |
| Measured Recall@10 | 96.6% (LongMemEval) | Varies (LLM-dependent) | Varies | 96% (TF-IDF, no model) |
| Search Latency | ~100ms | Cloud RTT | ~50-200ms | 5-21 µs (A* pathfinding) |
| Cost | Free | $19-249/mo | $25+/mo | Free (MIT license) |
Real benchmark results from gp-bench — no projections, no estimates. Every number measured.
| Engine | Recall@1 | Recall@5 | Recall@10 | Recall@20 | MRR |
|---|---|---|---|---|---|
| Mock (FNV-1a hash) | 54% | 54% | 54% | 54% | 0.54 |
| TF-IDF (real semantics) | 96% | 96% | 96% | 100% | 0.96 |
| Target (MemPalace) | — | — | 96.6% | — | — |
| Scenario | Success Rate | Avg Latency | vs. Target |
|---|---|---|---|
| Same-Wing | 100% | 8–21 µs | <200ms ✅ (10,000× under) |
| Cross-Wing | 100% | 5–13 µs | <500ms ✅ (38,000× under) |
| General (random) | 25–32% | 10–85 µs | Exploratory |
Pheromone mass: 0 → 76,424 with periodic decay. Stable convergence dynamics.
96% recall with zero model files • 5–21 µs pathfinding • 48K ops/sec throughput • 100% soak stability
All measurements from gp-bench running on standard hardware. No cherry-picking, no projections.
All ten phases complete. 13 crates, 680 tests, 21,167 LOC — from foundation to benchmarks.
Fork Kuzu, Rust workspace, gp-core (types, schema, config), gp-embeddings (ONNX), gp-stigmergy, gp-pathfinding, gp-agents, gp-mcp, gp-wasm stubs. 7 crates, 224 tests, 5,800 LOC.
Cypher query generation (10 query types), bulk decay operations, position-weighted path rewards, edge cost recomputation. +38 tests.
PalaceGraph benchmark infrastructure, full hierarchy traversal tests, cross-wing tunnels, pheromone effects, context-adaptive weights. +21 tests.
NEW gp-swarm crate: SwarmCoordinator (sense→decide→act→update), 3-criteria ConvergenceDetector, interest scoring, decay scheduling. +50 tests.
JSON-RPC 2.0 MCP server, 28-tool dispatch, dynamic PALACE_PROTOCOL prompt with live stats, 401-line skills.md protocol. +42 tests.
InMemoryPalace engine, full JS API (wasm-bindgen), Web Worker message types, IndexedDB/OPFS persistence layer. +63 tests.
CI/CD (GitHub Actions), 7 doc files (1,540 LOC), CLI stub (12 commands), Python bindings (PyO3), NPM package config, 3 example programs.
NEW gp-storage crate: StorageBackend trait, InMemoryBackend (full CRUD + cosine search), Kuzu C API FFI bindings (feature-gated), schema initialization, palace operations. +60 tests.
NEW gp-palace crate: GraphPalace orchestrator, auto-hierarchy creation, pheromone-boosted search, A* navigation, KG CRUD, export/import (Replace/Merge/Overlay). +63 tests.
NEW gp-bench crate: recall@k (target ≥96.6%), A* pathfinding (target ≥90.9%), throughput benchmarks, Criterion harness, comparison reports (JSON/Markdown). +43 tests.
GraphPalace stands on the shoulders of giants — combining insights from memory science, graph databases, swarm intelligence, and neuroscience.
Verbatim storage philosophy. Palace spatial metaphor. 96.6% LongMemEval recall. Never summarize; store raw, search semantically.
5 pheromone types. Position-weighted rewards. Semantic A* (40/30/30). Active Inference agents. Cosine annealing.
Embedded graph database (163K LOC, MIT). Cypher, native HNSW vector search, FTS, WASM bindings, columnar storage.
Active Inference and Expected Free Energy minimization. Bayesian belief updates. The mathematical foundation for agent curiosity.
Simonides (~500 BC). The original memory palace — spatial organization aids recall. 2,500 years of proven effectiveness.
Modular WASM microservices on edge devices. Sandboxed execution. Patent WO 2024/239068 A1.
An 18-page paper with full methodology, 10 equations, 2 algorithms, 8+ tables, and 19 references — covering architecture, experimental evaluation, and comparison with MemPalace, Mem0, and Zep.
web3guru888 · April 2026 · 18 pages · MIT License