João RamiresInstruction manual

Cartridges · After hours

A jail, a factory and an orchestrator

How I let AI coding agents build my software without trusting them: a jail around every agent, a factory that moves their work through gates, and an orchestrator that plans and judges it.

Where
After hours
Status
Building
Year
2026

I let AI agents write most of the code on my machine, and I don’t trust them with it. This framework is how both are true at once. My trading system, Consilium and Beholder are built through it: agents write the code, and I set the goals and make the calls.

The jail

Every agent runs in a jail, on a throwaway clone of its project. The box at its center is ai-jail, an open-source tool by Fabio Akita that puts the agent inside bubblewrap, Landlock and seccomp. I built nine more layers around it and hardened its setup:

  • A separate Unix user with no sudo, so the kernel refuses it my files and my processes.
  • Memory, CPU and disk limits, and a queue when the machine is full, so a runaway build can’t starve my desktop.
  • Firewall rules, so an agent reaches the web and nothing on my home network.
  • A credential proxy. The jail holds only the word “placeholder”; the real token is added outside it.
  • Protected paths, so a branch can’t change what guards the system.
  • An escape test suite that tries to break every guard after each upgrade and every week.1The rule of the repository: a change to a guard ships with a change to the escape test that proves it.

The gate

Work leaves the jail only as a branch, through one door. The door checks the branch and holds any change to a protected path until I type a confirm code at a terminal, which no jailed process can do. Then the merged tree must pass the project’s tests twice before anything lands: in a fresh jail for the jail’s proof, and on the host for the factory’s merge tool.

The factory

The factory moves one OpenSpec change at a time through planning, building, review and merging. A builder writes it in the jail, a jailed reviewer says PASS or BLOCK, and the merge tool refuses unless the tests pass on the merged result. Approvals are commits that carry my words. A project supplies only a profile with its build and test commands, so the factory names no project, and adding a project costs a page of settings.

The gates say no often, and that is their job: about half of the merge runs so far stopped at a gate and never reached main.

The orchestrator

The orchestrator is my main Claude Code session. It writes plans, briefs and reviews, never code. It reads every result as untrusted text, checks each fact, fetches through the gate and reads the diff. In delegation mode it approves for me and records each choice, so it asks me only for real money, secrets, sudo and logins. My decisions, the queue and the lessons live in Consilium, so a new session starts with my rules instead of forgetting them.

What it solves

  • Agents work unattended, and none of them can reach my secrets, my other projects or each other.
  • Nothing lands on main without a review and passing tests on the merged tree.
  • I am asked only for what needs me.

I wrote the whole story, with the faults that shaped each part, in A jail, a factory and an orchestrator for AI coding agents.