The Deterministic Harness for AI Engineering

AI agents write the code. MechaLinters provide the armor.

AI coding agents can generate whole features in thirty seconds—and open five subtle architectural or security holes along the way. A mechalinter is a really powerful, automated program that encodes arbitrarily complex linting rules into it, in order to provide deterministic feedback to an AI agent.

The Real-World Dilemma

Why LLMs Reviewing LLMs Never Works

The software industry's top practitioners have run into the exact same brick wall: when you try to police non-deterministic coding agents with more non-deterministic prompts, entropy wins.

ThePrimeagen @ThePrimeagen
View on X →

“i have yet to fully figure this out. The problem is that there is an infinite amount of bad things. Agents write more detail aware code than humans, just fall apart at big picture stuff. its wild.

Something that i have been trying lately is to do Laws where i try to do really high level activities and then ask for regular scans. Even when i ask for this, and even when i have a second agent check per pr, I always get new results every time.”

David Cramer (zeeg) Founder, Sentry · @zeeg
View on X →

“One of the biggest challenges I’ve grappled with lately is how to create determinism where it otherwise doesn’t exist. How do I get an agent to behave like I would, without me telling it to?”

The Core Takeaway: You cannot solve stochastic drift with more stochasticity. A system prompt saying “please adhere to our security laws” or a second AI reviewer in CI gives you new hallucinations on every run. To tame an AI agent, you must evaluate it against a mechanical, binary, compiler-grade truth.
The Core Definition

What is a MechaLinter?

Traditional linters (like ESLint, RuboCop, or Flake8) check syntax, naming conventions, and AST micro-styles. They tell you if you used single quotes or left trailing whitespace. That is child’s play.

A MechaLinter is an automated, domain-aware enforcement program built specifically for the age of AI coding agents. It encodes arbitrarily complex, systemic engineering rules—multi-tenant data boundaries, route authorization matrices, schema encryption parity, and architectural layer isolation—into a deterministic binary oracle.

When an AI agent touches code, the mechalinter runs statically in milliseconds and behaviorally in test suites. It gives the agent explicit, line-numbered, unambiguous failure reasons:

$ mechalinter verify STDERR
FAIL: Missing tenant scoping in app/controllers/invoices_controller.rb:14
  -> Route: GET /invoices/:id
  -> Violation: Bare ActiveRecord query `Invoice.find(params[:id])`
  -> Requirement: Must use `current_tenant.invoices.find(...)` as declared in config/mecha_tenant.yml
  -> Status: Build blocked. Remediation required.

The Contrast: Why Existing Approaches Fail

Approach Determinism Scope AI Feedback Quality
Prompt Engineering
SYSTEM_PROMPT.md
~40% (Stochastic) Vague “best practices” Subject to context window exhaustion and forgetfulness.
Secondary LLM PR Bot
AI Code Reviewer
~60% (Drifting) Surface-level diffs “I always get new results every time.” False positives and missed breaches.
Traditional Linters
ESLint / RuboCop
100% Deterministic Syntax & Style nits Cannot see cross-file boundaries, tenant scopes, or database ciphertexts.
MechaLinters
Domain Armor
100% Deterministic Architectural Invariants & Security Exact file, line number, and remediation contract. Agent iterates to green in seconds.
The Anatomy

The 4 Pillars of a MechaLinter

How do you build a harness that an autonomous coding agent can never outsmart, ignore, or accidentally bypass?

PILLAR 01

Single Source of Truth (Central Registries)

AI agents fail when critical architecture is scattered across 200 files in senior engineers’ heads. A MechaLinter moves the entire policy into a single, clean declarative registry (e.g., config/mecha_*.yml). The agent reads one manifest to know 100% of the rules before touching a line of code.

PILLAR 02

Closed by Default

Open-by-default is suicide for AI workflows. In a MechaLinter, everything is locked down until explicitly registered. Add a route? It is forbidden until declared. Add a database column? Migration fails until classified. Add a model? Tenant isolation is required unless justified.

PILLAR 03

Compiler-Grade Binary Feedback

Agents thrive on compiler errors. They iterate against them with robotic persistence. A MechaLinter inspects ASTs, symbol tables, route dictionaries, and schema dumps. It returns pass/fail with absolute mathematical precision. Zero conversational vagueness.

PILLAR 04

Behavioral CI Attack Probers

Static analysis is half the battle; runtime reality is the other half. Every MechaLinter includes a test suite component that actively probes and attacks the running application—spoofing tenant IDs, testing ciphertext entropy, and attempting privilege escalation against the declared contract.

Reference Implementation

MechaRuby: The Flagship MechaLinter Ecosystem

The pioneer of the mechalinter philosophy is MechaRuby—a suite of closed-by-default, AI-first security and architecture gems for Ruby on Rails.

mecha_authorize — Closed-by-Default Route Authorization

Central route registry, static AST controller auditing, and automated route permission probers.

GitHub · mecha_authorize →

When an AI agent adds a controller action, Rails exposes it immediately. mecha_authorize requires every route in the app to be declared in config/mecha_authorize.yml.

If an agent adds an action without updating the registry, bin/rails mecha_authorize:verify halts the build in 20 milliseconds, pinpointing the exact controller and missing permission declaration.

config/mecha_authorize.yml YAML
admin/billing:
  index:   ["role:super_admin", "role:finance"]
  refund:  ["role:super_admin"]
webhooks/stripe:
  receive: ["public:webhook_signature"]

mecha_tenant — Closed-by-Default Multi-Tenant Data Isolation

Guarantees zero cross-tenant leaks by binding model AST queries to tenant-scoped contracts.

GitHub · mecha_tenant →

Multi-tenant data leaks are the #1 risk of AI coding. An agent forgets current_organization.invoices and writes Invoice.find(params[:id]), exposing client data across boundaries.

mecha_tenant enforces tenant boundaries mechanically. Any model querying tenant-isolated tables without tenant scoping triggers an immediate AST violation.

config/mecha_tenant.yml YAML
tenancy_key: "organization_id"
models:
  Invoice:
    isolated: true
    tenant_association: "organization"
  SystemAuditLog:
    isolated: false
    comment: "Global operational log spanning all accounts"

mecha_encrypt — Closed-by-Default Database Encryption

100% schema parity verification, ciphertext validation, and plaintext justification requirements.

GitHub · mecha_encrypt →

When an AI agent runs a database migration, did it just store API keys, bank tokens, or social security numbers in plaintext?

mecha_encrypt audits 100% of your database schema. Every column must be cataloged in config/mecha_encrypt.yml. If a column is unencrypted, the developer (or agent) must supply a written architectural justification.

$ bin/rails mecha_encrypt:verify CLI
Running MechaEncrypt static database & model audit...
  -> 24 tables audited (198 columns checked)
  -> 42 encrypted columns, 9 deterministic, 147 unencrypted
✓ Static database encryption audit passed: 0 unregistered columns.
Running behavioral ciphertext & index safety tests...
✓ All encryption invariants and B-tree index checks passed.
The Manifesto

Why Compiler Engineering Beats Prompt Engineering

The future belongs to developers who write the harnesses, not developers who babysit prompts.

01 / SPEED

Unshackled Velocity

When you have mechanical guardrails, you don’t need to fear the speed of AI agents. You can let them rip at 10x velocity because you know the boundaries cannot break without failing the build.

02 / ZERO SLOP

No Ambient Drift

AI models tend to copy-paste bad habits and drift toward local optima. A MechaLinter cuts down ambient drift instantly by rejecting code that violates architectural purity.

03 / UNIVERSAL

Cross-Language Paradigm

While MechaRuby leads the charge in Rails, the MechaLinter movement is growing across TypeScript/Node, Rust, Go, and Python. Every stack needs deterministic feedback loops for coding agents.

Ready to Build with Real Armor?

Stop hoping your AI agent remembers the rules. Start enforcing them with deterministic mechanical proof. Join the MechaLinters movement today.