Running an AI-Built Project
Contracts, rulings, planted bugs and gates: notes on knowing that code written by AI agents is right.
Contents
TL;DR: Practices for knowing that code written by AI agents is right, on projects long enough to run in phases and too large for anyone to hold in their head. They come from running Nablaframe through Phases 0 to 7, with AI agents writing almost all of its code, and each example links to its record. The one design idea: no one grades their own work, and every claim traces back to something written down. The practices that paid for themselves: keep the roles apart; ship contracts with failing tests before anyone implements; break a private implementation on purpose to test the tests; and take results only from generated, validated reports on one fixed reference machine. The evidence is one project, with one person deciding, and its first technical report is Nablaframe: Beating the Null Isn’t Enough.
Introduction #
When AI agents write most of the code, the hard part of the project is no longer writing it. It is knowing that what got written is right, and keeping a long project from drifting while nobody holds all of it in their head.
The practices here are meant for projects of that kind: long enough to run in phases, with enough parts that several agents build at once. The worked example throughout is Nablaframe, a small GPT trained from scratch so that its training and forward pass can be replayed and inspected, with Phases 0 to 7 complete. Almost every line of its code was written by AI implementers, against specs and tests written by an AI spec partner, with me deciding what counts, and the numbers below come from its records. Its first technical report, Nablaframe: Beating the Null Isn’t Enough, shows what the process has produced so far.
The one design idea underneath everything: no one grades their own work, and every claim traces back to something written down. Each mechanism below is a hand-off between roles, and each hand-off has a check that catches one kind of failure.
The cast #
Four roles, kept apart on purpose. The separation matters more than any tool.
| Role | Owns | Never does | In Nablaframe |
|---|---|---|---|
| Governor | Rulings, phase sign-off, running the gates | Writes the code | Me |
| Spec partner | Specs, contracts, tests, review, merging | Writes the shipped implementation | One long-running Claude session, on Opus 5.5 by the record from Phase 7’s third delta, when it began committing its own deltas and rulings |
| Implementers | The code for one package, a PR | Changes a contract, a test or a report | Claude Code threads in a Project, one per package, on Opus or Sonnet (see “Which model, and how much effort”) |
| Reference machine | Every gate result | Anything else: no numbers from elsewhere count | My Mac |
The spec partner and the implementers are the same kind of model, but they never share a context. An implementer sees only the repo: the contracts, the spec and the decision log. That is what makes their agreement mean something.
Contracts first: the delta #
The unit of work is a delta: one slice of the spec turned into contracts and failing tests, applied to main before anyone implements it.
A delta ships:
- Contracts as docstrings. Each module’s docstring says exactly what it does, refuses and returns. Docstrings live next to the code, so an implementer can’t miss them and a reviewer can diff them.
- Stubs that raise
NotImplementedError, so the code imports and the tests run. - Tests that fail on the stubs. The delta doc lists exactly which ones: “18 failed, 363 passed” is a precise to-do list, and done means those 18 pass with no skips.
- Exact edits to existing files, made by a script that replaces one quoted passage at a time and stops if a passage is missing or repeated. A delta never rewrites a file wholesale, so
mainnever holds a half-changed contract. - A doc of what was settled. Every reading the spec left open is written down with its reason, so the reviewer rules against text, not memory.
The point is that the implementer’s job is small and checkable. It doesn’t decide what to build; it makes named tests pass without touching the contract.
Testing the tests #
A test suite written by the same model that will be judged by it is easy to fool. So every delta is proven twice before it ships.
- A private reference implementation. The spec partner implements every contract itself, privately, and never ships it. If the reference can’t pass the tests, the contract is wrong or impossible. If it passes, the contract can be met.
- Planted bugs. The reference is then broken on purpose, one plausible bug at a time: an off-by-one, a swapped argument, a strict inequality where the spec says “at most”. Every planted bug must make a test fail. One Phase 7 delta planted 90; each escape became a new test case before shipping.
- Bars that can fail. Some checks are designed to be unable to fail, by accident. One measure capped its count at 8 while the bar asked for “at most 8”; the gate now counts without the cap. A wrong function that only relabelled the right one could never score badly, so it was dropped by a ruling (D58 in the decision log).
The reference has a second use: when an implementer’s PR arrives, both versions run on real trained models, and their outputs have to match value for value.
Rulings #
Every choice that could reasonably go either way becomes a numbered entry in a decision log: its date, the decision, and the evidence it rests on. The project has more than 60. Committing an entry is the ruling, so only the governor does it.
Two rules make the log work:
- Check before you assume. Every role reads the log before treating a choice as open. A settled question isn’t argued again in the next PR.
- Stop and report. When a spec contradicts the code or a ruling, the agent that notices it stops and reports the conflict instead of choosing. The repo’s instructions say so in one line, and the agents follow it.
Most new rulings arrive mid-build, not in planning. One came from a wrong function that could never fail. Another came from tracing what a code change would do to records written a phase earlier. Another came from a gate that couldn’t run as specified (below). Each took the governor a minute to decide, because the options and the evidence arrived written down.
Implementers, PRs and review #
Each implementer is a thread with a fresh context and one package: named files, named tests, and an objective “done when”. Threads that don’t depend on each other run in parallel, each on its own cloud machine; those that do run in waves. A thread opens a draft PR and lists every reading it had to make where the docstring left a choice open.
Review is where the independence pays off. For each PR the spec partner:
- Applies the diff to a fresh clone of
main, and checks that no docstring, test or out-of-scope file moved. - Runs the thread’s named tests, the full lane, and the whole wave applied together.
- Runs the code on real data, where it exists, against the private reference.
- Posts the review as a PR comment, verdict first, with a ruling on each listed reading.
- Merges only when every condition holds: the reviewed commit, only the allowed files, no decision left open, a passing lane, and the governor hasn’t asked to hold it.
Gates and the machine of record #
Tests say the code does what the contract says. Gates say whether the project’s claims hold. A gate is a script that runs on the reference machine, measures something against a bar set from earlier experiments, and writes one report.
- Reports are generated, never edited. A validator rejects any report whose pass or fail disagrees with its own numbers, so a report can’t say pass while its measurements say fail.
- Gates chain. Each refuses to start until the reports it builds on exist and pass.
- Only one machine counts. The cloud machines the agents use are for development. Every number in a report comes from the Mac.
- Results are rebuildable. Records are keyed by their inputs and the code that made them, and the gates recompute and compare hashes.
A case study: eight probe pairs #
One Phase 7 gate traces a small modular-addition model on a fixed probe of 8 input pairs. Before tracing, the engine runs an oracle that requires the model’s plain pass and its recording pass to produce bit-identical logits. That policy was ruled long ago and had held on every model since.
While exercising the gate on a cloud machine, the implementer found the two passes 1 float32 rounding step apart on about a third of the logits. The first suspect was the machine: a different CPU, more threads. A second machine with another CPU gave exactly the same counts, so it wasn’t the hardware. Then the Mac failed too.
The cause was size. Each pair is only 3 tokens, so 8 pairs make 24 rows, and at that size the compiler builds the two passes differently. From 48 pairs the passes agree bit for bit; the earlier models’ probes had never been small enough to notice. A 64-pair probe passed the oracle at all 45 trained checkpoints and an 8-pair probe at none. The ruling (D60 in the decision log): trace 64 pairs and keep the oracle strict. From first report to ruling took an afternoon, and no gate result was ever at risk, because the gate would have failed loudly instead of passing quietly.
Which model, and how much effort #
The roles decide who does a job. A second dial decides how much intelligence the job gets: which model tier, and how much reasoning effort. The size of the task is the wrong axis for setting it. What matters is how expensive the output is to check, and what a wrong output costs downstream.
| Cheap to check | Expensive to check | |
|---|---|---|
| Low consequence | Cheap model, low effort, let it retry. Repo chores, formatting, renames. | Mid model, medium effort, accept imperfection. First drafts, notes, README prose. |
| High consequence | Mid model, high effort, with automated checks. An implementer’s package against its failing tests; data pipelines. | Frontier model, high effort, an independent critique, and my own review. Specs and contracts, experiment design, “is this a real finding?”, anything published. |
The bottom-right cell is where intelligence pays for itself. A bad experimental design burns weeks before anyone notices, and no test catches it. The top-left cell is where it’s easiest to overspend. When a test or a type checker says at once whether the output is right, a cheaper model in a retry loop does the job. This is where the delta pays twice: its failing tests are what let an implementer’s package sit in the cheap-to-check column.
Six rules sit under the grid:
- Spend on the spec, save on execution. An hour of the strongest model on a design makes every later implementation cheaper, because a mid-tier model with a clear spec beats a frontier model guessing at intent.
- Put big models where the output is short. Cost is roughly price per token times tokens generated. A ruling is a few thousand tokens, so the strongest model is cheap there; a long agentic grind is hundreds of thousands, so every tier you drop saves real money.
- Diagnose a failure before escalating. If the agent didn’t know a constraint, fix the context. If it skipped a file or didn’t run the tests, raise the effort. If it had everything and still reasoned wrong, change the model. Two failures at one setting means escalate, not retry a third time.
- Context is usually cheaper than intelligence. The repo’s instructions file, the decision log and the contracts lower the tier everything downstream needs. When a task keeps demanding the strongest model, check first whether something is missing from the context.
- Review costs less than generation. For anything that matters, a critique pass, ideally by a different model than the author, catches more per token than generating again. Ask what is overclaimed, unsupported or wrong, not “any thoughts?”.
- My own attention is the scarcest tier. I read every line in the bottom-right cell, skim the bottom-left, and trust the tests in the top-left.
One consequence runs against intuition: bigger per token can be cheaper per task. On work that stretches a smaller model, the larger one often finishes in fewer tries, and retries, half-done work and my time cleaning up are costs that per-token prices hide.
One phase and one report, as they were routed. Each delta names the model and effort for every implementation thread it starts, so the routing is on record in docs/deltas/, and the first report’s handoff note names the model for each of its steps. Phase 7, crystallize-this with modular addition, shows the implementation side best: by then the routing had settled. Its threads ran on Opus 5.5 and Sonnet 5.5, the current models then; the last delta names them by version. The table takes nine of its twelve threads, in five rows, and the three report steps that needed the most judgement.
| Task | Model | Effort | Why |
|---|---|---|---|
| Report rules: Phase 7’s, and G7.5’s | Sonnet 5.5 | medium | They follow Phase 6’s rules, and a fixture report checks them at once |
| Modular addition: the task, its declaration, every run’s functions | Sonnet 5.5 | high | Fully specified, with known answers to test against |
| crystallize-this’s payloads and badges for the viewer | Sonnet 5.5 | high | Every value is copied from a record, never computed |
| Gate helpers, gates G7.1 to G7.4, G7.5 and the phase summary | Opus 5.5 | high | A gate’s numbers become the record, and a wrong one can still pass |
| crystallize-this: replace a component with an explicit function, measure what changes | Opus 5.5 | high | The core algorithm; tests pin examples, not every case |
| Report: related work, and choosing the headline claims | Fable 5.2 | default | Pure judgement, and a wrong headline costs the whole report; no test can check it |
| Report: the overclaiming review | Fable 5.2 | default | Deciding what the evidence supports; it found controls claimed as new that had prior work |
| Report: the source pass, reading every cited source | Fable 5.2 | default | A different model from the drafter (Opus 5.5), checking each citing sentence against its source |
Around the threads, the spec partner, on Opus 5.5, wrote the contracts and failing tests, broke its private reference with 90 planted bugs in one delta, and reviewed every PR. The gates ran on my Mac, and I ruled the phase complete. The report’s other steps ran on Opus 5.5: re-measuring every claim on new seeds, the full draft and its interactive page, and publishing.
In the grid’s terms, Sonnet was the mid tier, Opus the tier above it and Fable the frontier. Sonnet took what a failing test settles, dropping to medium only where a fixture settles it at once. Opus took the work a wrong answer could slip through. Fable took the judgement no test can check, and the check of a draft another model wrote. No implementation thread needed the smallest tier, low effort or xhigh: the spec had already done the hard thinking. Model names and effort scales change every few months, so it’s worth writing the routing down once, per kind of task, and revisiting it after each release, rather than deciding it task by task.
Handing off between sessions #
A long-running session gets expensive. Each turn re-reads the whole conversation, so the cost of a turn grows with the session’s length and a usage quota runs out faster, and a very long conversation eventually gets summarized, which can drop details. So the long-running spec-partner session keeps the decisions and the coordination, and long, self-contained steps go to fresh sessions, one step per session.
What makes that work is a handoff note: one file that every new session reads first, before the repo’s own instructions. It holds:
- The goal and its limits, including what the work must not claim.
- A table of steps: for each, the model it runs on, its job, and its status, with the files it produced.
- Every decision made so far, dated, so a new session doesn’t reopen a settled question.
- Where everything lives: folders, result files, which version of a document is the source of truth.
- The rules carried over: the repo’s hard rules, what may never go public, and which actions wait for my explicit yes.
- What is already known to be wrong, so the next step starts from the problem and not from a rediscovery.
Every session ends the same way: it updates the note’s status, lists the files it made, and tells me the next step, which model it should run on, which files to attach, and the exact commands to run. That closing reminder is a standing instruction, not something I ask for each time.
Results travel as files, never as conversation. A step writes its numbers to a results file and its verdicts to a short outcome note, and the next session rebuilds its context from those files, the note and the repo, never from an earlier chat. The decision log does the same job across phases. When a step’s output comes back to the main session, it is reviewed like a PR: the re-measuring step, for instance, overturned one of the notebook’s findings, and the correction went into the notebook before anything was written on top of it.
Hand-offs have a cost too. A new session spends its first minutes reading, and some work goes more smoothly in the session that has watched it unfold. In practice I hand off a step when it can be stated in a paragraph with its files listed and its result can be checked from files. Work that needs many small rulings from me, such as rewriting repository history or publishing, stays in the main session. The report went this way over three days and seven steps, each in its own session, with the main session reviewing every result before the next step began.
Where it breaks #
The process has three weak points, and each has shown up in practice.
- One author for the contracts and the review. A blind spot in the spec is likely to be in the tests and the reference too, and independent implementers only partly offset that. In one delta the spec partner declared three threads independent when one depended on another, and shipped a bug in one of its own tests. Both were caught, one by a thread and one by a rerun. The real backstop is the gates, which nobody’s tests can talk past.
- Effects across deltas show up only when someone traces them. Records are keyed partly by the code that built them. A small change to a shared module quietly gave every record from the previous phase a new key, and a planned rerun of that phase’s final gate would have refused to start. Nobody had checked for that until it was traced, and it took a ruling (D59 in the decision log) to route around it.
- The governor is the bottleneck, by design. Rulings and phase sign-offs wait for me, so the loop moves at the pace of my attention, not the machines’. That is deliberate: deciding what counts as done is a judgement, not an optimization. It does mean the work should arrive as a decision with its evidence attached, never as an open question.
Comparing notes #
One project is an example, not a rule. What would turn these notes into guidance is the same few numbers from other projects, side by side. These are the ones worth recording, with Nablaframe’s where its records have them:
- Implementation threads by model and effort. Nablaframe’s Phase 7: twelve threads, seven on Opus at high effort, three on Sonnet at high, two on Sonnet at medium.
- Planted bugs per delta, and how many escaped the tests. Nablaframe: one Phase 7 delta planted 90, and each escape became a new test before shipping.
- Rulings, and when they arose. Nablaframe: more than 60, most of them mid-build rather than in planning.
- Gate failures, sorted by cause: the code, the instrument or the claim. Nablaframe’s eight-probe-pairs case was the instrument.
If you run a project like this, record the same things. A handful of projects side by side would show which of these practices hold in general and which were Nablaframe’s.
Takeaways #
If you run a project of this kind with AI agents doing the building, these are the habits that paid for themselves:
- Keep the roles apart: whoever specifies doesn’t implement, whoever implements doesn’t review, and one human decides.
- Write contracts where the code lives, and ship them with failing tests before anyone implements.
- Prove each contract with a private implementation, then break it on purpose and make sure the tests notice.
- Ask of every bar whether it can fail. If it can’t, it isn’t a bar.
- Keep a decision log, and make “stop and report” the default answer to a contradiction.
- Give implementers small, named jobs and let them list their own readings. Those lists are where the spec’s gaps surface.
- Review on real data, not only on tests, and merge only under written conditions.
- Pick one machine of record, and let only its generated, validated reports state results.
- Make results rebuildable: key everything by its inputs and code, and recompute.
- Route model and effort by how hard the output is to check and what a wrong one costs, not by how big the task is.
- Hand long, self-contained steps to fresh sessions through one written handoff note, and keep every result in a file, not in a conversation.
- Expect the process’s own blind spots. Trace each change’s effect on what already exists before it ships.
Part of Gradprop.
Text and figures: CC BY 4.0. Code: Apache-2.0.