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)
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)
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.
The Engrams Runtime (Active Schemas)
Autonomously clusters codebase activity, formalizes triggers and directives, and intercepts agent edits in 1ms with compact mental 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.
$ 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>\""
}
]
} 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:
graph-ontology-and-rebuild 12 decisions · 11 files · 6 days "The knowledge graph validates relationship algebra at link-write time and derives analytics, inverse edges, and code-node enrichment deterministically in memory during rebuild."
"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."
Paths: src/ops/graph, src/ops/link.rs · Tags: graph,
ontology, validation
proposal:1, edit the wording, or reject?
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"}}
}
} $ 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"}
]
} 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 insrc/ops/graph/rebuild.rswithout breaking thesince == HEADguard (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:3returns all 12 linked decisions, contracts, and code symbols in a single payload.
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 3: Cognitive Schema
● active mental modelperformance-rules guided 14 sessions Fires whenever I edit Rust code handling collections & strings
Tier 2: Linked Decisions & Patterns
architectural standardsTier 1: Repository Code Anchors
grounded code realitysrc/ops/schemas/retrieval.rs src/ops/schemas/list.rs src/ops/schemas/gates.rs what-to-build-next Fires when planning releases, evaluating roadmap priorities, or drafting new feature specifications
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.
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 scan2. 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:14. Executes
Tomorrow, your AI touches matching files. engrams advise intercepts the edit in 1ms,
injecting the active schema before a single line is written.
$ engrams advise src/ops/schemas/retrieval.rsThree Operational Levers
Your AI executes the advice automatically. You steer the runtime with three high-leverage commands.
{
"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": [ ... ]
} {
"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"}
]
} {
"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