← McWelling Todman

Verifying Urithiru

Urithiru gives coding agents one container per project. It began as the container layer of Syl, my agent harness. I pulled it out so other harnesses could share it.

Sharing is the hard part. Several agents can use one container. If one of them decides wrong, it deletes another's work. So I held it to a formal bar. Here is how that went.

What it does

Urithiru starts, resumes and removes a Podman or Docker container for each project. It runs commands in it with timeouts, memory and CPU limits, and out-of-memory detection. Cancelling a command stops everything the command started.

It knows nothing about agents, models or terminals, so any harness can use it. Syl uses it in production. It also has a command line and an MCP server. An agent that finds a tool missing can install it mid-session and get back a diff to the project's config for its user to review.

The name comes from Sanderson's Stormlight Archive: a tower that houses every order of Radiants.

The method

I followed Marc Brooker's correctness approach for modern systems software. The person owns what must be true: the properties, and the assumptions each one needs. Agents write the code and a stack of checks against that spec. Then each check is broken on purpose, to show it can fail.

I owned the spec. I signed off on every revision, chose to model the fix before writing it, decided what came next and approved every merge. Claude Code agents wrote the drafts, code, models, proofs, simulations and docs.

Formal verification, briefly

Tests check the cases you think of. Formal verification checks a claim against every case, or proves no case can break it. It needs a precise statement of what must be true and a tool that checks the reasoning mechanically.

The tools here:

Each layer covers a gap in the one before. The spec says what must be true. The model shows the design keeps it, in every state and at any size. The refinement and the code proofs tie the design to the Rust. The simulation covers the I/O. The mutants show every layer can fail.

No layer is enough alone. Together they shrink what you have to trust to a short list: the spec and its assumptions, Lean's kernel, the Rust-to-Lean translation, and the I/O that is only simulated. The repo's ledger names every item.

The spec

The spec has 13 properties and 17 assumptions. It took six revisions. One property: no session loses its container to another client.

Model the old code first

Before fixing anything, we modelled the code as it was. Each suspected cause got its own model, and each model produced a trace showing the failure.

Then we modelled the fix before writing it. The model changed the design. The essential fix was a session guard. Two fixes I had planned turned out not to matter to any property, so we didn't build them.

The checks

What it found

Eight bugs, all fixed:

  1. Another client could remove a container mid-session, four different ways.
  2. A fresh start on Podman also removed other projects' containers.
  3. Clients with different settings took turns recreating each other's container.
  4. Two non-UTF-8 paths could get the same container name. A proof found it.
  5. Trimming whitespace could remove a different project's old container. A proof found it.
  6. A failed podman start was ignored, so start "succeeded" with the container stopped.
  7. A fork bomb beat the cleanup. Simulation found it. The fix stops the container first, then kills.
  8. On macOS, inherited pipes hung reads past any timeout.

Check the checkers

The checks had holes too. The proof gate passed a goal the solver had crashed on. It missed failed goals under one locale, which hid a missing clause in an invariant. And it stopped catching unfinished proofs after Lean changed the quotes in a warning.

Now each gate has its own mutant, a planted failure it must catch.

What's still open

The repo's ledger lists what is proved, what is only tested and what is assumed.

Lessons