all.sourceall.source

Concepts

The ideas behind Prime's agent memory architecture.

Everything is an Event

Every mutation — creating a node, adding an edge, storing a vector, deleting a memory — is an immutable event in a Write-Ahead Log (WAL). Events are never modified or deleted. This gives you full audit trails, time-travel queries, and crash recovery for free.

prime.node.created  → { id, type, properties, domain }
prime.edge.created  → { source, target, relation }
prime.vector.stored → { embedding, text, metadata }
prime.node.deleted  → { } (soft-delete, preserved in history)

Projections

Projections are materialized views built incrementally from the event stream. Each projection maintains a different index over the same data:

ProjectionWhat it indexesQuery cost
NodeStateNode properties by entity_idO(1)
AdjacencyListOutgoing edges per nodeO(1)
VectorIndexHNSW over embeddingsO(log n)
DomainIndexNodes grouped by domainO(1)
CrossDomainEdges spanning domain boundariesO(1)
CompressedIndexAuto-generated markdown TOCCached

Domains

Every node can be tagged with a domain— a knowledge area like "engineering", "revenue", or "product". Domains power the compressed index and cross-domain reasoning:

  • The compressed index organizes knowledge by domain
  • Cross-domain edges (e.g., revenue → engineering) generate cross-references
  • Questions spanning domains trigger both the index and vector search

Compressed Index

A token-efficient markdown summary (~500-1000 tokens) of everything the agent knows. Organized by domain with cross-references. Auto-generated from projections — no manual maintenance.

This is the key insight from zer0dex: vector similarity finds X orY when you ask "how does X relate to Y?" — rarely both. The compressed index bridges this gap by providing explicit cross-domain pointers, doubling cross-reference accuracy from 37.5% to 80%.

Temporal Queries

Since everything is an event, time-travel is a first-class operation:

  • get_node_as_of(id, timestamp) — reconstruct state at any past point
  • history(id) — full audit trail with timestamps
  • diff(from, to) — what changed between two timestamps
  • neighbors_as_of(id, timestamp) — graph state at a past point

Hybrid Recall

prime_recall combines three retrieval strategies:

  1. Vector similarity — find semantically related facts via HNSW
  2. Graph expansion — follow edges from vector matches to discover connected context
  3. Temporal recency — boost recently stored facts

For cross-domain questions, use prime_context instead — it adds the compressed index excerpt for navigational scaffolding.