Page typeSupporting example RunnabilityScripted reproduction OutcomeDENY

The code works. The architecture is still wrong.

An AI refactor replaces UserRepository with a direct database query inside user.service.ts. Types pass. Tests pass. But the shortcut breaks the data-access boundary that later agents will copy. Mneme names ADR-004 and blocks the change in strict mode.

Boundary enforcement

Working code can still break the architecture.

This trace ends at the block. It shows the failure a team needs to catch, not a made-up recovery.

Decision at stake

ADR-004 · Repository pattern is the only data-access boundary. Services depend on repository interfaces. Direct database imports, raw SQL, and ORM calls stay inside repository implementations.

mneme check --mode strict · repository trace
  1. 01 Decision

    The repository boundary is recorded with a service-layer file scope and explicit anti-patterns.

    ADR-004 · scope: **/*.service.ts
  2. 02 Guidance

    This evidence is a post-generation CI check; it does not contain a pre-flight guidance event.

    Not present in this reproduction
    N/A
  3. 03 Violation

    The service drops its repository dependency and opens a direct SQL path.

    + this.db.query('SELECT * FROM users ...')
  4. 04 Deny / warn

    Strict mode matches the direct access pattern, names the file, and exits non-zero.

    FAIL [ADR-004] · user.service.ts · exit 2
    DENY
  5. 05 Correction

    The evidence does not include the refactor back through UserRepository.

    Not demonstrated
    N/A
  6. 06 Allow

    A clean follow-up check is not part of this supporting example.

    Not demonstrated
    N/A
CLI FAIL maps to the canonical DENY outcome

Run it yourself

Reproduce the strict boundary check

Record ADR-004, save the proposed service diff, and evaluate it in strict mode.

pipx install "mneme-hq>=0.5.1"

mneme check --mode strict \
  --memory .mneme/project_memory.json \
  --input user-service.diff --query "repository data access"
# FAIL [ADR-004] ยท exit 2

This is a command-level reproduction. The page does not claim a bundled corrected fixture.

What happened

The failure is architectural.

Linters, types, and behavior tests can all pass while the service boundary is being dismantled.

The first bypass is the cheapest to stop.

Once direct SQL becomes precedent, later agents copy it and the repository layer stops functioning as a contract.

DENY remains traceable.

The verdict names ADR-004 and the offending file, so an override must become an explicit decision.

Common questions

Why is this a DENY?

Direct data access from a service invalidates the boundary ADR-004 exists to protect. Its downstream cost compounds, so strict mode returns a non-zero failure.

Does the denial block the pull request?

Yes, when mneme check --mode strict is wired into the required CI workflow.

Why are correction and allow absent?

The supplied trace ends at the block. A corrected diff and clean rerun belong in a future reproduction, not in a fabricated ending.

Keep the boundary executable.

Record the pattern once, then enforce it in the editor and at the merge gate.

pipx install "mneme-hq>=0.5.1"
Python 3.11+ · MIT licensed