Flagship 01 · Centerpiece 5 min read RUNNABLE

# 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.

By Theo Valmis · Published May 2026 · All demos

## 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.

1. Agent proposes code
2. Mneme checks against compiled governance corpus
3. ADR-005 fires — decision ID and rationale surface
4. Retry context injected to agent
5. Agent retries — `mneme check --mode strict` passes

## 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.

ADR-005 separates brand identity from package namespace. `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`.
Agent proposes
mneme check --mode strict
Corrected output — agent retry

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.

Related governance concepts

- Governance before generation

  Enforcement at the point of AI intent, not at the point of human review.

- Deterministic enforcement

  Same input, same verdict — every run, every agent, every consumer. The precondition for auditability.

- Enforcement provenance

  Every verdict traceable back to the authoring ADR. Opaque enforcement is theater.

- Architectural governance

  The system that turns team decisions into machine-evaluable constraints enforced at generation time.

Flagship 02

#### Architectural drift prevention

The failure mode a governance layer exists to prevent. A six-step timeline of compounding divergence without enforcement.

Walk the timeline →
Flagship 03

#### Governance continuity across actors

Where enforcement has to hold once AI execution becomes parallel and persistent. Invariants across actors, sessions, and retries.

See the trace →