How HEBBS Works: From Markdown to Memory Palace
The full technical walkthrough: a two-phase ingest pipeline, a RocksDB schema with eight column families, four recall strategies and an agent using all of it in a real conversation loop.
- 4.1 ms
- recall, one turn of the reference sales agent
- 3.2 ms
- remember, same turn
- 0.8 ms
- subscribe, same turn
- 8
- RocksDB column families, one embedded instance
This is the map of the engine: how markdown becomes memories, where each index lives on disk, and what each recall strategy costs.
Two-phase ingest
Phase 1 is cheap. It walks the vault, takes a SHA-256 of each file, skips files whose checksum matches the manifest, splits the rest into sections at ## headings, and marks each section ContentStale, Synced or Orphaned. The manifest is written to a temp file and renamed, so a kill between any two steps leaves it intact. Phase 2 is expensive. It batch-embeds stale sections with a local ONNX model (EmbeddingGemma-300M, 768 dimensions), at most 256 sections per batch, L2-normalizes, writes to RocksDB, and turns wiki-links into RELATED_TO edges.
Storage layout
| Column family | Key | Holds |
|---|---|---|
| default | 0x01 + memory_id (16 B) | Bitcode-encoded memory record |
| temporal | entity_id + 0xFF + timestamp_us (big-endian u64) | memory_id; range scan gives an entity's history in order |
| vectors | 0x00 + memory_id | f32 embedding, 3,072 bytes at 768 dimensions |
| graph | 0xF0 + source + type + target, mirrored under 0xF1 | 12 bytes: confidence f32, timestamp u64 |
| vectors_associative | memory_id | Second embedding used by analogical recall |
| pending | pending id | Contradiction candidates awaiting review |
| query_log | query id | Recall queries with strategy, weights, result count |
| meta | name | Schema version, sweep cursors, auto-forget candidates |
Storing every edge twice, forward and reverse, makes "what did this cause" and "what caused this" the same O(log n + k) prefix scan. RocksDB runs with bloom filters at 10 bits per key, a 256 MB shared LRU block cache, 64 MB write buffers, LZ4 compression and Zstd on the bottom level. There is no application-level lock around the database handle.
Recall cost by strategy
- Similarity: embed the cue, search HNSW (M=16, 32 links at layer 0, ef_construction=200, ef_search=100). O(log n * ef_search).
- Temporal: range scan on the temporal column family. O(log n + k). Entity-filtered searches oversample 4x.
- Causal: resolve a seed, then walk typed edges forward, backward or both, to a bounded depth (maximum 10).
- Analogical: HNSW at twice the beam width, then rerank by a blend of embedding and structural similarity controlled by alpha.
Every strategy feeds one composite score over relevance, recency, importance and reinforcement, with weights set per call.
Process model
A single daemon listens on a Unix socket with length-prefixed JSON (4-byte big-endian length, 16 MiB maximum). It loads the embedding model once, opens vault databases on demand, closes idle ones, and exits after 5 minutes without use. The latencies above come from one conversation turn of our reference agent, which calls recall with two strategies and top_k=10, feeds the user text to a subscription, and stores extracted memories.
