engram

Data Model

SQLite tables and data structures in engram

Data Model

Engram stores all data in SQLite (WAL mode) at ~/.engram/memories.db.

memories

The primary records table.

FieldTypeDescription
idTEXT PKRecord UUID
memory_typeTEXTdecision, pattern, bugfix, context, antipattern, insight
contextTEXTSituation or context
actionTEXTAction or decision
resultTEXTResult
scoreREALQuality score (0.0-1.0)
embedding_contextBLOBContext embedding vector
embedding_actionBLOBAction embedding vector
embedding_resultBLOBResult embedding vector
indexedBOOLEANWhether indexed in HNSW
tagsTEXTJSON array of tags
projectTEXTProject identifier
parent_idTEXTParent record (causal chain)
source_idsTEXTSource record IDs (for insights)
insight_typeTEXTInsight type (cluster, temporal, causal)
created_atTEXTCreation date (ISO 8601)
updated_atTEXTLast update date
used_countINTEGERNumber of times used in search
last_used_atTEXTLast used timestamp
superseded_byTEXTReplacement record ID (from consolidation)

memories_fts

FTS5 virtual table for full-text search via BM25.

CREATE VIRTUAL TABLE memories_fts USING fts5(
    context,
    action,
    result,
    content='memories',
    content_rowid='rowid'
);

Indexes three text fields of each record. Used for the sparse component of hybrid search.

q_table

Q-Learning router table. Stores values for 4 independent levels.

FieldTypeDescription
router_levelTEXTLevel: search, llm, context, proactivity
stateTEXTState (mode: debug, architecture, coding, review, plan, routine)
actionTEXTAction (level-dependent)
valueREALQ-value
update_countINTEGERNumber of updates

Actions by level:

LevelActions
searchhigh_threshold, medium_threshold, low_threshold
llmcheap, balanced, expensive
contextraw, summarize
proactivitypassive, proactive

consolidation_log

Audit trail for consolidation operations.

FieldTypeDescription
idINTEGER PKAutoincrement
actionTEXTOperation type (merge, delete, archive)
sourceTEXTSource (auto, user)
detailsTEXTJSON with operation details
created_atTEXTOperation date

feedback_tracking

Tracks the feedback loop for Q-Learning.

FieldTypeDescription
memory_idTEXTRecord UUID
searched_atTEXTWhen the record was shown in search results
judgedBOOLEANWhether the record was rated via judge

Cycle: memory_search marks shown records -> memory_judge sets judged = true -> memory_status shows pending_judgments.

recommendations

Trainer recommendations pending approval.

FieldTypeDescription
target_idTEXTTarget record UUID
actionTEXTRecommended action
reasoningTEXTReasoning

metrics

Metrics from trainer (aggregates).

FieldTypeDescription
nameTEXTMetric name
valueREALValue

SQLite WAL mode

The database operates in WAL (Write-Ahead Logging) mode:

  • Crash-safe writes with data integrity guarantees
  • Concurrent reads during writes
  • Single memories.db file + auxiliary memories.db-wal and memories.db-shm