Agentic engineering / Field essay SFP1

Run an AI software factory like an engineering org.

Reading every diff fails at agent velocity. I tier models across a build DAG and make each stage prove its work, from a red test to a canary.

Published

ESSAY
FIELD ESSAY SFP1 / AGENTIC ENGINEERING
THE OVERVIEW FILMWatch the full argument

Run an AI software factory like an engineering org

"I read every diff" is the most common safety claim I hear from teams running coding agents, and it is the one I trust least. It was a fine control when a person wrote a few changes a day. Point several agents at a backlog and the diffs arrive faster than anyone can read them with care. The reading still happens. It just turns into skimming, and a skimmed approval leaves the same mark in the history as a careful one.

So I do not design a software factory around a person reading output. I design it the way a working engineering org is designed: individual contributors who write, leads who review above the writer's level, managers who decide scope and staffing, and a release process that asks for evidence at each step. The agents fill those seats. Several models check each other's work, and every stage has to hand the next stage something it can check.

People call the multi-model part wasteful. It only looks wasteful if your mental model is "prompt an agent, merge what comes back". No engineering org ships that way with humans. This essay is the whole method: how I tier models across a build, the seven verification stages in order, and the disciplines I require of every agent.

Reading every diff is a control that degrades without telling you

The trouble with human diff review at agent velocity is that it fails quietly. There is no error when a reviewer's attention drops. The approval count goes up, the queue goes down, and the dashboard looks healthier on the day the review got worse.

A diff also shows only what changed. It does not show whether the tests can fail, whether they ran, whether the flow works in a browser, or how the change behaves under real traffic.

I still want people in the factory. I want them where judgment is scarce: scope, architecture, the risky boundaries, and the disagreements the machines cannot settle. I make the case for where human review belongs in a sibling essay, An agentic coding pipeline you can trust: where I put the proof. This one covers the rest: who writes, who checks, in what order, and what each owes the next.

A factory is an org, and an org verifies by rank

Think about how a competent human team handles a change. A junior engineer writes it. A senior engineer reviews it, and nobody calls that review waste. A lead decided beforehand that the task was junior-sized. If it touches payments, security gets a look. Then CI, staging, QA, and a staged rollout. Each step catches a different class of failure, and each costs less than the failure would.

A software factory has the same seats:

  • Managers plan. They pressure-test the scope and the architecture, break the work into a build DAG, and decide what level of talent each piece needs.
  • ICs write. They take one chunk, write the failing test, write the code, and produce the evidence.
  • Leads review. They sit a tier above the writer, attack the work, and send it back with reasons.
  • Specialists red-team the changes where a mistake is expensive.
  • Release runs the checks no model's opinion can replace: CI, a real browser, a real production tenant, real traffic in a small dose.

The planning pair sets the tier before anyone writes code

The build starts with two top-tier models working as a pair, and they do not write code. One drafts. The other attacks. They work through three documents: the scope, the statement of work, and the architecture.

They use web search, and that matters. A model's memory of a library, an API, or a platform limit is a snapshot from when its training ended. The pair checks current documentation, versions, and known problems before the plan depends on them.

The adversarial half has one question: what breaks this? I want it looking for the missing negative case, the contract two components read differently, the requirement that cannot be tested as written, and the chunk that is secretly three chunks.

The output is a build DAG: chunks of work with their dependencies, each small enough to verify alone. Then the pair does a manager's job and assigns each chunk a difficulty and a starting model tier.

  • Simple work starts on a lighter, faster tier. Wiring, renames, a well-specified endpoint, a test for a known behavior. The checks downstream catch what the light tier gets wrong.
  • Harder work starts on a strong mid-high tier by default. Logic with several interacting conditions, changes across module boundaries, anything where a plausible wrong answer is easy to produce.
  • Rare, undecomposable, critical work starts on a frontier tier. If a chunk cannot be split and a wrong answer is costly, I start it at the top. If many chunks land here, the decomposition is weak, and it goes back to the planning pair.

The shape of what the pair hands down, as an illustration and not a real plan:

# illustration only
chunk                        difficulty   writer     reviewer                 red team
add export button + route    low          light      mid-high                 no
quota calculation rewrite    medium       mid-high   frontier                 no
tenant permission check      high         mid-high   frontier                 yes
ledger reconciliation core   critical     frontier   frontier, other family   yes

Which provider fills each tier is a budget question. I work across Anthropic, OpenAI, Grok, and Gemini, and the mix depends on what a project can spend and which subscriptions are already paid for. Each offers something like a light tier, a strong workhorse tier, and a frontier tier, whether the family is Claude, GPT, Grok, or Gemini. I keep no ranking of which is best, because that shifts with every release and with the task. The method needs two things from the lineup: at least two tiers, and ideally two families.

The reviewer steps up a tier and crosses a family

Step up a tier. The reviewer should be stronger than the writer. This is the lead and IC relationship. A reviewer at the writer's level tends to find the writer's reasoning persuasive, because it is roughly the reasoning it would have produced. A stronger reviewer has a better chance of seeing the case the writer did not consider.

Cross a model family when you can. Models from one family share training lineage, and with it habits, blind spots, and a sense of what "looks right". A same-family reviewer is more likely to accept the wrong assumption the writer made, for the same reason the writer made it. A different family fails differently, and uncorrelated failure is the whole point of a second check.

That makes a same-family reviewer a weaker default, though not a worthless one. If the budget covers one provider, step up a tier inside it and demand harder evidence from the review: mutants built, tests rerun, findings tied to lines. A same-family review that ships evidence beats a cross-family review that ships adjectives. When I have the choice, I take both.

Stage 1: a red test, tests that can fail, and a build

The writer's first artifact is a failing test. Before any implementation, the agent writes a test that expresses the requirement and runs it against the current code. It must go red, and the red run is stored.

What it catches. The agent that misunderstood the task, and the test that cannot see the bug. If the test passes before the fix exists, it is not testing the fix.

That second failure has a name: the vacuous test. A test that can pass while the bug still exists is not evidence of anything. It asserts that a call returned without checking what it returned, or checks a mock the code never reaches, or runs zero cases and exits clean. "Non-vacuous" means the test has been seen to fail for the right reason, and that it would fail again if the behavior broke. The full argument is in Before you trust a green test, prove it can fail.

The stage also requires a build. Agents will report success on code that does not compile in a clean checkout, because their own session had state the checkout lacks.

What a skip costs. Everything downstream. Every later stage stands on the test suite. If the tests are decoration, CI is a green light wired to nothing.

What proof looks like. The red run against the prior commit, the green run after, the counts of tests declared and tests reported, and a build log from a clean environment.

Stage 2: cross-model adversarial review, with a human only on non-convergence

Now the lead reads it. The reviewer gets an adversarial brief: find what is wrong, do not confirm what is right. It receives the chunk's spec, the diff, and the stage 1 evidence, not the writer's opinion of its own work.

I ask for more than reading. The reviewer reruns the tests instead of trusting stored output, builds its own mutants (small deliberate breaks in the code) and confirms the suite kills them, and checks the change against each acceptance criterion. It returns a verdict with blockers tied to specific lines and failing cases.

The fix loop. Blockers go back to the writer. The writer first adds a test that reproduces each finding and shows it red, then fixes, then resubmits. A fix is a change, so it re-enters at stage 1. The loop has a budget: a small fixed number of rounds, set in advance.

Human escalation happens on non-convergence, and only then. Non-convergence means one of three things. The loop budget ran out with blockers still open. The writer and reviewer disagree about whether something is a defect, and neither can produce a test that settles it. Or each round surfaces new blockers, which usually means the chunk is harder than its tier, or the spec is ambiguous.

Before a person sees it, the chunk usually steps up a writer tier and tries once more, because the starting tier was only a guess. When the chunk does reach a person, it arrives as a packet: the disputed point, both positions, and the evidence each side produced. One narrow question with evidence is a far better use of a person than a stack of diffs that were fine. I go deeper on the handoff itself in When should an AI agent hand off to a human?.

What a skip costs. Shared misunderstanding ships. The writer's code and tests come from one reading of the task. If that reading is wrong, both are wrong in the same direction and stage 1 stays green.

What proof looks like. The reviewer's model and tier on record, checked against what was assigned. The mutants it built and their results. Each blocker, and the commit and test that closed it.

Stage 3: a dedicated red team where the damage is expensive

Stage 2 asks "is this correct?" Stage 3 asks "how do I abuse this?" Those are different jobs, and a general reviewer asked to do both does the second one lightly.

The trigger is the surface the change touches. If it touches any of these, it gets a dedicated adversarial pass:

  • Security: authentication, secrets, input handling.
  • Permissions: who can see or do what, especially across tenants.
  • Boundaries: between services, between user data and instructions, between a sandbox and the host.
  • System: process control, file operations, migrations, anything destructive.
  • Firmware: code where a bad release cannot simply be rolled back.
  • Money: charges, credits, ledgers.

The planning pair tags these chunks in the DAG, so the trigger does not depend on the writer noticing that its own change is dangerous.

The red-team agent tries to break the change: the privilege it can escalate, the check it can skip, the retry that charges twice. Each finding comes back as a reproducing test, and the fix loop is the same as stage 2.

The red team itself needs limits. An agent told to exercise a destructive path will exercise it, so every probe declares its worst case and its bound before it runs. See A red team needs a blast radius.

What a skip costs. A wrong button color is caught by a user and fixed in an hour. A cross-tenant read is caught by someone else.

What proof looks like. The list of attacks attempted, including the ones that failed to break anything. A red-team report that says only "no issues found" is narration. One that lists what it tried and what stopped each attempt is evidence.

Stage 4: CI lint and tests, then staging

Everything so far ran in the agents' own environments. CI is the first run on neutral ground: a clean checkout, pinned dependencies, the full suite and the linters, not just the tests the writer thought were relevant.

What it catches. The change that works only in the writer's session, the test that passed on leftover state, and the breakage between chunks that were each verified alone. Skip it and those surface later, where they cost more to diagnose.

The gate here must read what ran, not what was reported. An exit code of zero with tests filtered out or missing from the count is not a pass. The gate compares expected tests against executed tests and treats "could not verify" as its own outcome, separate from pass. That argument is in A merge gate must prove the tests ran.

When CI refuses, it says why in terms the writer can act on: which test, which count, which rule. A bare red X sends an agent guessing, and a guessing agent's cheapest move is to weaken the test.

A CI pass deploys the change to staging. A CI failure goes back to the writer and re-enters at stage 1.

What proof looks like. The CI run tied to the exact commit, with executed, skipped, and filtered counts, and the staging deploy tied to that same commit.

Stage 5: headed click-tests on staging, with proof

A green suite says the functions work. It does not say a person can complete the task. So an agent opens a real, headed browser against staging and uses the feature the way a user would: signs in, clicks through the changed flow, tries the wrong input, resizes the window, uses the keyboard.

Headed matters. A visible window with real focus and real pointer clicks is closer to what a user has, so the button that exists in the DOM but sits under a banner fails here as it would for a person.

The click-tester should not be the writer. It gets the acceptance criteria, not the implementation, so it tests what was asked for.

With proof. The tester returns a trace: screenshots or a recording at each step, the actions taken, what it expected and what it saw, and the console and network errors along the way. "I tested the flow and it works" does not close the stage.

The fix loop. Each failed step becomes a ticket with the trace attached. A fixer agent reproduces it, writes the failing test where one can exist, fixes it, and the change goes back through stages 1 to 4. Then the tester reruns the whole flow.

What a skip costs. You ship features that pass every test and do not work. The unit suite is green and the save button does nothing.

Stage 6: the prod QA tenant, clicked through again

Now the same style of headed click-test runs in production, inside a tenant that exists only for QA. It is real production infrastructure with a fake customer on it. The test looks like stage 5. It differs in what it can prove.

Staging is where it is safe to be rough. The data is disposable. The tester can try destructive paths and bad inputs, and fail repeatedly while fix loops run, with no customer near it. Staging proves the feature works.

The prod QA tenant is where the environment is real. Staging is never production. Config, secrets, data volume, and feature flags differ, and third-party integrations point at sandboxes. The QA tenant runs the release on the actual production stack. It proves the feature works in the place it has to.

The QA tenant run is narrower. It sticks to the changed flows plus a short smoke path, uses only its own tenant's data, and stays away from anything that would touch a real customer or move real money. Destructive probing belongs to staging.

The fix loop is the same shape, with one addition. A failure here that staging missed means staging differs from production in a way that matters. That difference gets its own ticket.

What a skip costs. Your first test of production config is a customer.

What proof looks like. The same kind of headed trace, tied to the production release version and the QA tenant.

Stage 7: canary, then live

After all of that, the change goes to a small share of real traffic, and I watch it for a set window before it goes to everyone.

Why, after six stages? Because every stage before this one tested what somebody thought to test. The planning pair imagined the cases, the reviewer imagined the attacks, the click-tester followed the criteria. Real users arrive with data nobody generated, sequences nobody scripted, old clients, odd accounts, and load. A QA tenant has one fake customer. Production has all the real ones.

The rules are set before the deploy: the traffic share, the window, the signals watched (error rates, latency, the business metric the change could hurt), and the threshold that triggers rollback. The rollback fires automatically. When many releases are moving in a day, one shared halt condition beats a dozen private ones, which I cover in Many releases a day, one stop sign.

What a skip costs. Every user becomes the canary at once, for the one class of failure nobody imagined.

What proof looks like. The canary window on record: the start, the end, the share, the signals compared against baseline, and the promote or rollback decision with the numbers that drove it.

The disciplines I require of every agent

I require five habits, and I enforce them with gates where I can, not with requests.

Maintain a write-ahead log. Before an agent acts, it writes down what it is about to do. After, it records what happened: what was tried, what landed, what failed, and what was not proved. The WAL exists for two readers. The first is the next session. Sessions end, crash, and compact their context, and the one that picks the work up should resume from recorded facts, not from a summary. The second is the reviewer, who can see the dead ends, the skipped checks, and the claims with no evidence behind them. The "not proved" entries are the most valuable lines in the log, because they tell the lead exactly where to look.

Update the tickets. The ticket is the org's shared state, and the WAL is the agent's private one. When a chunk changes state, the ticket changes, with a link to the evidence. Status gets written from the record of what happened, never from an agent's recollection, for the reasons in Write the status from the ledger, not from memory. When tickets lag the work, every manager, human or model, plans against fiction.

Supply proofs. Every claim of completion carries an artifact a second party can check without trusting the claimant.

Write non-vacuous tests. Every test must be able to fail for the reason it exists. Red first, on record.

Create and kill mutants. After the tests pass, the agent deliberately breaks the code in small ways (flip a comparison, drop a check, return early) and reruns the suite. Each break is a mutant. A killed mutant is one the tests caught. A surviving mutant is a hole: a behavior the code has and no test defends. The agent reports kills and survivors by name, then writes the test that kills each survivor or explains why the mutant is equivalent. Mutation testing is the mechanical answer to "are these tests any good".

Proof is an artifact a second party can check

Proof is something a reviewer can verify without believing the author. Narration is the author's account of what happened.

Narration Proof
"Tests pass." Red run on the old commit, green run on the new one, declared and executed counts.
"Reviewed, looks good." The reviewer's model and tier, its mutants, each blocker and the commit that closed it.
"Tested in the browser." A headed trace: steps, screenshots, expected versus observed.
"Canary was healthy." The window, the traffic share, the signals versus baseline.

Narration is usually accurate. The trouble is that an accurate account and an inaccurate one read identically, and agents write fluent, confident summaries either way. Proof lets the factory stop caring how confident the summary sounds.

This is also what replaces reading every diff. A person can audit a chunk's proof packet faster than they can read its code with care, and the packet answers questions the diff cannot.

Why the extra passes are not waste

A change in this factory costs a writer, a stronger reviewer, sometimes a red team, a click-tester twice, and fix loops: several model runs where a "prompt and merge" shop spends one. Run a second model over a change and you have paid for a code review. Skip it and you have a team with no senior engineers. The spend is the right trade, for three reasons.

First, the tiering pays for the checking. Most chunks are written on a lighter tier, and the expensive models read small diffs and evidence instead of writing everything.

Second, the alternative is not free. It is paid later, by a person, at a worse rate: debugging in production, unwinding a bad charge, explaining a data leak.

Third, it is how the work scales at all. A human reading every diff caps the factory at one person's attention. Structured verification caps it at budget, and budget can be planned.

This is not perfect. No human dev team is perfect either. Senior reviewers miss things, QA misses things, canaries pass releases that fail a week later. A model reviewer can share a blind spot with the writer even across families, and a click-tester can miss the flow nobody wrote down. I do not claim the pipeline catches everything. I claim each stage catches a different class of failure, each leaves evidence, and when something escapes, the record shows which stage should have caught it.

How I would know it is working

  • Escapes are traceable. When a defect reaches production, I can name the stage that should have caught it and read that stage's proof to see why it did not.
  • Stage 2 finds real blockers. If cross-model review passes everything on the first round, the reviewer is too agreeable or the brief is too soft. Plant a known defect and see whether it comes back.
  • Escalations are few and specific. Too many means tiers are too low or specs are vague. None, ever, means non-convergence is being papered over.
  • A new session can resume from the WAL alone. If it cannot, the log is decoration.

Checklist

  1. Have a top-tier pair attack the scope, SOW, and architecture, with web search for anything the plan depends on.
  2. Break the build into a DAG. Give each chunk a difficulty and a starting tier: light for simple, mid-high by default, frontier only for rare critical work that cannot be split.
  3. Tag every chunk that touches security, permissions, boundaries, system, firmware, or money for a dedicated, bounded red team.
  4. Require a stored red test before the fix, tests that can fail, and a clean build.
  5. Review one tier up, across a model family where the budget allows, with reviewer-built mutants.
  6. Cap the fix loop. Escalate to a person only on non-convergence, with both sides' evidence.
  7. Make CI read executed counts, refuse with a reason, and deploy to staging only on a real pass.
  8. Click-test in a headed browser on staging, then narrowly in a prod QA tenant, each with a trace.
  9. Canary with the window, signals, and rollback threshold written down first. Then go live.
  10. Require of every agent: a WAL, updated tickets, proofs, non-vacuous tests, and mutants created and killed. Close stages only on proof.

How this was verified

This essay states a working method: how I design and run a software factory, and what I require of the agents in it. It is not a lab study. I ran no new experiment for it, it reports no measured defect rates or savings, and the table and the tiering block are illustrations, not output from a real build. The practices it points to (failing tests first, mutation testing, bounded red teams, ledger-based status, merge gates) are argued with their own evidence in the linked essays.

CONNECTED READINGForward and back
Keep reading

The answer deserves
another experiment.

Back to the journal