Architecture

System Overview

Crates

CratePurpose
zoidmatter-coreMemory types, bank schema, priority stack
zoidmatter-missionsRetain operations, fact consolidation
zoidmatter-recallQuery pipeline, conflict resolution
zoidmatter-apiHTTP server and CLI
zoidmatter-engineFact extraction, chunking, embeddings
zoidmatter-dbPostgreSQL backend with migrations
zoidmatter-astAST engine — code understanding at LOD 0/1/2

Data Flow

  1. 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.
  2. 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.
  3. 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.