# How Mneme governs AI-generated code before the model writes a line

> Source: <https://dev.to/mnemehq/how-mneme-governs-ai-generated-code-before-the-model-writes-a-line-2noa>
> Published: 2026-06-29 13:58:30+00:00

LLMs start every call from zero. They reintroduce a library you dropped six months ago, rebuild a component you chose to keep small, and contradict decisions your team already settled. Each violation reads as reasonable on its own. Stack them across a week of agent sessions and you get architectural drift.

Mneme works at the prompt boundary. It reads the decisions your project already made and checks the task against them before the model generates anything. The repo ships Layer 1: local-repo, single-developer, project-scoped governance. Here is the shape.

Five stages, running locally in under two minutes:

```
project_memory.json → MemoryStore → Retriever → ContextBuilder → LLMAdapter → Evaluator
```

`project_memory.json`

`MemoryStore`

`Retriever`

`ContextBuilder`

`LLMAdapter`

`Evaluator`

A second path adds `conflict_detector`

, which scans the response after generation, and an ADR compiler (`adr_parser`

then `adr_compiler`

) that turns ADR files with YAML frontmatter into the corpus and resolves precedence between decisions that disagree.

The demo runs each task twice, once with no governance and once with the corpus enforced, so you read the delta yourself.

RAG retrieves documents to inform an answer. Mneme retrieves decisions to constrain one.

| RAG | Mneme | |
|---|---|---|
| Input | Documents, chunks, embeddings | Rules, constraints, decision records |
| Goal | Inform the response | Shape the response |
| Output | The model knows more | The model follows what you decided |
| Test | "Did it cite the right source?" | "Did it respect the constraint?" |

No vector store, no agent loop. The corpus stays small, structured, and yours.

The freeze pins the retrieval mechanics, enforcement semantics, and benchmark methodology at commit `e73ff7d`

. The open exit criterion is real-world validation with design partners. Several things sit outside the wedge on purpose, not on a backlog:

The benchmark carries the same restraint. It is a regression instrument, not a generalization claim: canned model responses, fixed retrieval, two-layer scoring, today at 7/7 scenarios and recall@3 = 1.00. Its job is to make any change to retrieval or enforcement visible, so no regression lands unseen.

Layer 1, the benchmark suite, and an example corpus are public at ** https://github.com/MnemeHQ/mneme**. The concepts behind the design (governance before generation, architectural drift, verification contracts) are defined at
