Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Architecture Overview

System Design

Engram is a distributed memory system that stores entity data in Git refs.

Core Components

┌─────────────────────────────────────────┐
│              CLI Layer                  │
│  (src/cli/*.rs)                        │
└────────────────┬────────────────────────┘
                 │
┌────────────────▼────────────────────────┐
│            Entity Layer                 │
│  (src/entities/*.rs)                   │
│  - Task, Context, Reasoning, Knowledge  │
│  - Theory, StateReflection              │
│  - Session, Workflow, WorkflowInstance  │
│  - ADR, Compliance, Standard, Rule      │
│  - Lesson, Persona, DocFragment         │
│  - EscalationRequest, ExecutionResult   │
│  - AgentSandbox, ProgressiveGateConfig  │
│  - BottleneckReport, DoraMetricsReport  │
│  - TaskDurationReport, StaleTaskReport  │
└────────────────┬────────────────────────┘
                 │
┌────────────────▼────────────────────────┐
│           Storage Layer                │
│  (src/storage/*.rs)                    │
│  - GitRefsStorage (primary)            │
│  - MemoryOnlyStorage (testing)         │
└─────────────────────────────────────────┘

Modules

ModuleDescription
askSemantic search and query engine
cliCommand-line interface
configConfiguration management
enginesWorkflow engine, rule engine, NLQ engine
entitiesAll 23 entity types
errorError types
feedbackStructured feedback interface
locus_cliLocus agent CLI
locus_handlersLocus event handlers
locus_integrationLocus integration layer
locus_tuiTerminal UI (feature-gated)
migrationData migrations
nlqNatural language query processing
perkeepPerkeep backup integration
personasPersona management
sandboxSandbox enforcement (feature-gated)
storageStorage backends
validationInput validation
vectorVector search
versionVersion info

Storage Backends

BackendDescription
GitRefsStoragePrimary — persists to .git/refs/engram/
MemoryOnlyStorageIn-memory for testing

Entity Flow

  1. User creates entity via CLI
  2. Entity is validated
  3. Converted to GenericEntity
  4. Stored in storage backend
  5. Can be retrieved, listed, updated, deleted