Architecture
System Overview
- HTTP API:
/v1/retain,/v1/recall,/v1/reflect,/v1/graph, plus bank-scoped equivalents and registry CRUD under/v1/{tenant}/banks[/{bank_id}]. - Storage: PostgreSQL + pgvector (semantic similarity).
- Embeddings: OpenAI-compatible API (LM Studio, mlx_lm, llama.cpp server).
- Reranker: cross-encoder/ms-marco-MiniLM-L-6-v2 via Docker service.
- Surgeon: Next.js visualizer at port 8889 (3D synapse graph + management UI).
Crates
| Crate | Purpose |
|---|---|
zoidmatter-core | Memory types, bank schema, priority stack |
zoidmatter-missions | Retain operations, fact consolidation |
zoidmatter-recall | Query pipeline, conflict resolution |
zoidmatter-api | HTTP server and CLI |
zoidmatter-engine | Fact extraction, chunking, embeddings |
zoidmatter-db | PostgreSQL backend with migrations |
zoidmatter-ast | AST engine — code understanding at LOD 0/1/2 |
Data Flow
- Retain — content is extracted, chunked, embedded, and stored under a bank's
bank_id. A post-retain pipeline may auto-consolidate or synthesize related memories. - Recall — an embedding search (plus BM25 fallback) pulls candidate lanes, which are fused by the priority stack and re-ranked. Invariants are evaluated before any conflict resolution.
- Reflect / Consolidation — a budgeted background scheduler merges duplicates, resolves contradictions, and synthesizes higher-level mental models.
Key Design Decisions
Why invariants beat prompt engineering
Models abandon architectural constraints under pressure. The invariant pre-check gate fires before model output — structural enforcement, not a prompt you can argue away.
Why memory is multi-bank, but code understanding isn't
Memory (facts, mental models, invariants) is isolated per bank. AST/code cards stay global by design: cross-LOD synthesis requires all levels of detail observable in the same consolidation pass, and a codebase's structure isn't tenant data — LOD is metadata, not a partition boundary.