Governed Python agent — from bad code to compliant output.
A Python coding agent proposes a locally reasonable but architecturally invalid import. Mneme retrieves the relevant ADR, blocks the violation, injects the decision context, and the agent retries with correct code. This is the product loop in full.
The product loop
Governance is only useful if it fires before bad code reaches review. The loop below is how Mneme closes that gap: the constraint lives in a compiled ADR, surfaces at generation time, and the agent corrects itself without human intervention.
- Agent proposes code
- Mneme checks against compiled governance corpus
- ADR-005 fires — decision ID and rationale surface
- Retry context injected to agent
- Agent retries —
mneme check --mode strictpasses
See it live — namespace violation caught and corrected
The animation below runs a real governance scenario: the agent writes an import that looks correct from its training data but violates ADR-005. Mneme catches it, surfaces the decision, and the agent retries with compliant code.
MnemeHQ is the GitHub org, the website, and the LinkedIn page — so an agent confidently writes from MnemeHQ.memory_store import …. The decision declares MnemeHQ a forbidden dependency; the installable package namespace is mneme.Retry context contains: ADR-005 decision ID · forbidden token (MnemeHQ) · compliant alternative (mneme) · constraint rationale from the compiled corpus.
Why this matters
AI agents infer from training data. MnemeHQ appears everywhere as the brand — the GitHub org, the website, the LinkedIn page. When asked to work with the Mneme library, an agent confidently writes from MnemeHQ.memory_store import MemoryStore. It is a locally reasonable guess. It is also architecturally invalid.
Mneme separates brand identity from package namespace through ADR-005: an enforceable architectural decision compiled into project_memory.json. The constraint is not a linting rule. It fires before the code reaches review, surfaces the decision ID and rationale, and the agent corrects itself. The result is governed output — not probabilistic compliance.
The governance loop works because ADR-005 was compiled. The ADR compiler reads docs/adr/, parses the ## Constraints section of ADR-005, and emits the FORBID_DEPENDENCY: MnemeHQ directive into project_memory.json. Without that step, the namespace constraint is documentation. With it, the constraint is infrastructure. See how ADRs become the governance corpus →
Run it yourself
git clone https://github.com/TheoV823/mneme
cd mneme/mneme-project-memory
pip install -e .
python examples/demo-adr-import.py
Expected output (abbreviated)
-- Step 4: Enforcement check (namespace violation)
WARN [ADR-005] constraint "no MnemeHQ" -- trigger: mnemehq
Brand vs Package Namespace Enforcement
Result: WARN
The walkthrough runs the ADR compiler, applies decisions to a fresh memory file, then enforces against a namespace violation so ADR-005 fires on the wrong import path.
Video walkthrough
Prefer video? The animation above covers the mechanism; the walkthrough below narrates the full scenario end-to-end.