⬡ ENGRAMS v0.16.0

The Schema Runtime
for AI Coding Agents.

Static markdown rules bloat your prompt. Flat memory stores sit passively waiting to be queried. Engrams is an active runtime that continuously finds, defines, and refines mental models for your codebase — just like the human brain.

Why a Schema Runtime?

Other tools treat AI context as static text files or dead database records. A runtime is fundamentally different: it actively perceives changes, clusters patterns, and executes directives at the exact point of action.

Vector Databases & ADR Lists (Passive)

Dead history waiting to be searched

Stores hundreds of isolated notes. But the agent has no trigger condition — it doesn't know when a rule applies. It either queries blindly or ignores your history completely.

Prompt Stuffing & .cursorrules (Static)

Brittle, manual, and bloated

Developers manually write rigid text rules that get dumped into every prompt regardless of relevance. Consumes context window space and causes severe attention decay in reasoning models.

How Humans and Agents Build & Use Schemas Together

You never hand-write a schema file. As you and your agent log decisions, patterns, and progress during normal work, Engrams spots the recurring threads at the end of a session, asks the agent the right questions, and lets you approve the mental model in plain words. From the very next session onward, that schema guides your agent automatically and skips tens of thousands of tokens of file reads.

ACT I · AT SESSION CLOSE

Developing a Schema Together

After weeks of building the knowledge graph, the developer closes the session. Nobody stopped to write documentation — Engrams notices 12 uncovered decisions sharing the graph thread across 11 files and 6 days, and prompts the agent with software-lens questions.

⬡ ENGRAMS CLI $ engrams session close --lens software --reads-skipped 12 --tokens-saved 18000

Engrams returns schema_prompts: 12 uncovered decisions ordered in reading sequence, paired with software-lens questions and a ready-to-run propose command:

{
  "schema_value": {
    "guided_retrievals": 4,
    "schemas": [
      {"id": 1, "name": "performance-rules", "guided": 2},
      {"id": 2, "name": "what-to-build-next", "guided": 2}
    ]
  },
  "schema_prompts": [
    {
      "key": "thread:graph",
      "lens": "software",
      "spread": {"notes": 12, "files": 11, "days": 6},
      "questions": [
        "What invariant or rule must always hold true for graph?",
        "Where is the boundary where this rule applies, and what sits outside it?",
        "What breaks if this rule is violated?"
      ],
      "evidence": [
        {"kind": "decision", "id": 18, "anchors": ["src/ops/graph/rel.rs"],
         "summary": "Schema v3: context_links gains origin/weight; canonical relationship algebra"},
        {"kind": "decision", "id": 19, "anchors": ["src/ops/graph/rebuild.rs"],
         "summary": "graph ingest no-ops when since==HEAD (empty window guard)"},
        {"kind": "decision", "id": 21, "anchors": ["src/ops/link.rs"],
         "summary": "Disjoint rel pairs rejected at link add: depends_on vs conflicts_with"},
        {"kind": "decision", "id": 26, "anchors": ["src/ops/graph/rebuild.rs"],
         "summary": "Inference materialized as derived edges via EdgeSource"}
      ],
      "propose_command": "engrams schema propose --thread graph --lens software --members decision:18,decision:20,... --name graph --statement \"<claim>\" --summary \"When <condition>: <directive>\""
    }
  ]
}
🤖 LLM AGENT Synthesizes the 12 notes & runs engrams schema propose

The agent reads the 12 decisions, answers the lens questions, runs schema propose, and presents the proposed mental model to the developer in plain words:

Proposal #1 — graph-ontology-and-rebuild 12 decisions · 11 files · 6 days
CLAIM

"The knowledge graph validates relationship algebra at link-write time and derives analytics, inverse edges, and code-node enrichment deterministically in memory during rebuild."

INSTRUCTION

"When editing graph links, ontology rules, or rebuild analytics: enforce RelSpec domain, range, and disjointness at link write time and keep derived edges and PageRank in the in-memory graph rebuild pass."

SCOPE

Paths: src/ops/graph, src/ops/link.rs · Tags: graph, ontology, validation

Confirm proposal:1, edit the wording, or reject?
👤 DEVELOPER "Confirm proposal:1 and proposal:2"

The agent runs the printed command engrams schema confirm proposal:1. Engrams creates the active schema, links all 12 member decisions, and records its provenance:

{
  "status": "success",
  "schema": {
    "id": 3,
    "name": "graph-ontology-and-rebuild",
    "kind": "schema",
    "member_count": 12,
    "origin": {"proposal_id": 1, "source": {"kind": "thread", "ref": "graph"}}
  }
}
⬡ PRE-EDIT INTERCEPT $ engrams advise src/ops/graph/rebuild.rs

Before the agent edits a single line in src/ops/graph/ (including brand-new files matched via scope.paths), Engrams returns the active schemas ahead of the specific decisions and regex/AST patterns anchored to that territory:

{
  "schemas": [
    {
      "id": 3,
      "name": "graph-ontology-and-rebuild",
      "statement": "The knowledge graph validates relationship algebra at link-write time and derives analytics, inverse edges, and code-node enrichment deterministically in memory during rebuild",
      "summary": "When editing graph links, ontology rules, or rebuild analytics: enforce RelSpec domain, range, and disjointness at link write time and keep derived edges and PageRank in the in-memory graph rebuild pass",
      "scope": {"tags": ["graph", "ontology", "validation"], "paths": ["src/ops/graph", "src/ops/link.rs"]},
      "matched_by": {"via": "member_anchor", "value": "src/ops/graph/rebuild.rs"}
    },
    {
      "id": 1,
      "name": "performance-rules",
      "summary": "Fires whenever I edit Rust code that creates, copies, or hands off collections and strings: the four allocation rules...",
      "matched_by": {"via": "member_anchor", "value": "src/ops"}
    }
  ],
  "constraints": [
    {"type": "decision", "id": 19, "summary": "graph ingest no-ops when since==HEAD (empty window guard)"},
    {"type": "decision", "id": 26, "summary": "Inference materialized as derived edges via EdgeSource: inverse edges first"},
    {"type": "pattern",  "id": 7,  "name": "Borrowed SQL Parameters Only", "severity": "error"},
    {"type": "pattern",  "id": 9,  "name": "Enrich By Move Not get().clone()", "severity": "warn"}
  ]
}
🤖 LLM AGENT Applies guidance immediately · 0 exploratory file reads needed

Guided by graph-ontology-and-rebuild and performance-rules:

  • Right architecture on Turn 1: Keeps new relationship validation in src/ops/link.rs (RelSpec) and materializes derived edges in src/ops/graph/rebuild.rs without breaking the since == HEAD guard (Decision #19).
  • Zero-allocation compliance: Borrows SQL parameters via Vec<&dyn ToSql> and moves temporary lookup maps (Pattern #7, Pattern #9).
  • On-demand drill-down: If the agent needs the full history or progress trail, one call to engrams brief schema:3 returns all 12 linked decisions, contracts, and code symbols in a single payload.
Without Engrams 11 file reads · ~18,400 tokens
→
With Schema Guidance 1ms advise · ~420 tokens · 0 missed invariants

What is a Schema?

A Cognitive Schema is not an isolated note. It is the peak of an architectural pyramid: an active mental model resting on linked decisions and standards, which anchor directly into your concrete repository source code.

TIER 1: REPOSITORY CODE ANCHORS TIER 2: DECISIONS & PATTERNS TIER 3: SCHEMA

Tier 3: Cognitive Schema

● active mental model
performance-rules guided 14 sessions
⚡ TRIGGER

Fires whenever I edit Rust code handling collections & strings

📋 DIRECTIVE
The four allocation rules (borrow params, keep borrowed, consume by move) plus staged checker.

Tier 2: Linked Decisions & Patterns

architectural standards
Decision #88 Borrowed SQL parameters (Vec<&dyn ToSql>)
Decision #91 Static vocabulary returns Cow<str>
Pattern #11 Single-source row projections
Pattern #12 Enrich by move, not get().clone()
Checker Tool engrams check --staged (pre-commit)

Tier 1: Repository Code Anchors

grounded code reality
⚓ src/ops/schemas/retrieval.rs surface_counts · enrich_members
⚓ src/ops/schemas/list.rs resolve_schema · row_json
⚓ src/ops/schemas/gates.rs gates_pass · claimed_territory
STRATEGIC SCHEMA what-to-build-next
● active · guided 16 sessions centroid: roadmap: 1 · planning: 1 · versioning: 1
⚡ MENTAL TRIGGER
When does this mental model activate?

Fires when planning releases, evaluating roadmap priorities, or drafting new feature specifications

📋 CONCEPTUAL DIRECTIVE
What operational paradigm is enforced?

The pack that answers "what should engrams do next?": the 2026 agent-memory research survey (8 saved findings), the decision that turned it into a tiered version-by-version roadmap, and the survey session note. My learn → plan → ship loop — read this before writing any new spec.

🔗 BUNDLED MEMBERS
What decisions, research, and progress notes are unified?
Decision #74: Tiered version roadmap Research: 2026 agent-memory survey (8 findings) Progress: Survey session notes & synthesis Anchor: specs/

Why this is an architectural mental model, not a linter rule

Notice how both schemas capture how an expert thinks: performance-rules doesn't just block a single function call; it packages four architectural decisions, two code files, and a validation checker into an instant zero-allocation posture. what-to-build-next packages a research survey and roadmap decisions into a planning protocol. Your AI receives the complete mental model on Turn 1 before writing a single line of code.

How the Runtime Learns

The human brain doesn't require manual file editing to form intuition. Engrams runs a continuous cognitive loop: perceiving clusters, defining boundaries, adapting to drift, and executing just in time.

1. Finds

As you commit code and log decisions, graph community detection identifies natural clusters of co-edited files and decisions in local SQLite.

$ engrams schema scan

2. Proposes

At session close, Engrams surfaces candidate clusters with ready-to-fill propose commands. Your agent drafts a plain-language claim, trigger-and-rule instruction, and scope over the evidence.

$ engrams schema propose --from decision:88 --statement "..." --trigger "..." --rule "..."

3. Confirms & Refines

You confirm or edit the reviewed proposal (or refine existing schemas with claims and scope paths), while Engrams tracks drift and retrieval telemetry.

$ engrams schema confirm proposal:1

Three Operational Levers

Your AI executes the advice automatically. You steer the runtime with three high-leverage commands.

$ engrams advise src/ops/schemas/retrieval.rs
{
  "schemas": [
    {
      "id": 1,
      "name": "performance-rules",
      "statement": "Hot retrieval and enrichment paths must avoid avoidable allocations and clones",
      "summary": "Fires whenever I edit Rust code that creates, copies, or hands off collections...",
      "scope": {"tags": ["performance", "rust"], "paths": ["src/ops"]},
      "matched_by": {"via": "member_anchor", "value": "src/ops/schemas/retrieval.rs"},
      "guided": 14
    }
  ],
  "constraints": [ ... ]
}
$ engrams schema show performance-rules
{
  "name": "performance-rules",
  "statement": "Hot retrieval and enrichment paths must avoid avoidable allocations and clones",
  "summary": "Fires whenever I edit Rust code that creates, copies, or hands off collections...",
  "scope": {"tags": ["performance", "rust"], "paths": ["src/ops"]},
  "origin": {"proposal_id": 1, "source": {"kind": "candidate", "ref": "decision:88,decision:91"}},
  "guided": 14,
  "members": [
    {"kind": "decision", "id": 88, "summary": "Borrowed SQL parameter lists"},
    {"kind": "decision", "id": 91, "summary": "Static vocabulary returns Cow"}
  ]
}
$ engrams session close --pr 42
{
  "schema_value": {"guided_retrievals": 6, "distinct_schemas": 2, "schemas": [{"id": 1, "name": "performance-rules", "guided": 4}]},
  "schema_prompts": [
    {"key": "candidate:decision:88", "lens": "software", "propose_command": "engrams schema propose --from decision:88 --lens software --name performance-rules --statement \"<claim>\" --summary \"When <condition>: <directive>\""}
  ]
}

Give your AI the mental models it deserves.

Local SQLite engine. 0MB background memory. 1ms query execution.

cargo install engrams-cli or brew install stevebrownlee/tap/engrams