← All articles

Control Doesn't Go Away, It Concentrates

What changes in code review when an agent can only build with pieces that obey laws, and the four places where that argument breaks

16 min readsoftware-engineeringcode-reviewfunctional-programmingagents

Machine-translated from Spanish. Read the original

ByFederico Sawady O'ConnorRagnagrok Academy

A few days ago, thinking out loud about all this, I asked myself a question that seemed too good to be true. If an agent can only put code together from a small set of pieces, and every piece obeys laws that have been checked, do we still need to review every line it writes so carefully?

The short answer is no, but not for the reason it seems. You don't review less; you review something else, somewhere else. And it's worth doing the math carefully, because the sloppy version of this idea is dangerous. It sounds like "the pieces are safe, so the code is safe," and that's false in a very concrete way.

In The Art of Building with Smart Pieces: Combinators in the Age of LLMs I wrote about combinators and laws from the side of whoever generates the code, where a model that assembles valid pieces has less room to make things up. This article is about the other side, the side of whoever reviews it.

The bottleneck is whoever reads

An agent can write more code in an afternoon than a team reviews in a week. In “Code Is Cheap”: The Modern Fallacy That Could Cost a Fortune I said that a team's speed isn't set by the tool but by the feedback loop. With agents, the slowest link in that loop is usually a person reading a diff, that is, the list of changes someone proposes, line by line, with additions in green and deletions in red.

That reading costs, roughly, in proportion to the number of lines. Every line is a place where something can be wrong, such as a rounding, a mixed-up currency or a call in the wrong place. If the code grows, the cost of reviewing it grows with it. To say "grows at the rate of", we computer scientists have a notation, big O. Reviewing code written without constraints is O(lines).

What you buy is review that grows with abstractions

The proposal is to change what that cost depends on.

Suppose the delicate parts of the system—money, the states of a voucher, what happens inside and outside a transaction—can only be expressed through a small vocabulary of pieces, and every piece obeys stated, checked laws. Then review splits in two:

  • The pieces are reviewed with paranoia, once. There are few of them and they change little.
  • The places where they're used are reviewed more lightly, forever, because what can go wrong there is a small, known set.

The cost stops growing with lines and starts growing with the number of abstractions, that is, it goes from O(lines) to O(abstractions). In a growing codebase, and even more so if agents write a good part of it, that difference is enormous.

This way of thinking isn't new. In computer security it has had a name for more than forty years, the trusted computing base, or TCB. The term already appears in a 1979 MITRE report, and it became famous with the security evaluation criteria the US Department of Defense published in 1983 and reissued in 1985, the Orange Book. Butler Lampson, Martín Abadi, Michael Burrows and Edward Wobber described it in 1991, citing that book, with a precision I love:

A small amount of software and hardware that security depends on and that we distinguish from a much larger amount that can misbehave without affecting security.

Correction (November 25, 2026). The first version said the term TCB comes from the 1985 Orange Book and that Lampson and his coauthors defined it in 1991. The term is already in a 1979 report by Grace Nibaldi for MITRE, the Orange Book came out in 1983 and the 1985 edition is the reissue, and Lampson and his coauthors don't define it, they cite it from the Orange Book. The idea and the sentence still hold. I found it in a review of the series.

The whole idea is in that sentence. It's not about the rest of the system behaving well. It's about it being able to misbehave without breaking what matters. That's why you want the trusted part to be as small as possible, because it's the only thing you have to audit thoroughly.

A small vocabulary of pieces with laws is exactly that, applied to the domain's rules instead of to security.

What it looks like, in PHP

The case is the usual one, the gift card platform built on Laravel that I used in First the Filter, Then the Generator. I'm choosing PHP on purpose. It's where the system lives, and it's the language where this idea gets the least help, because there's no compiler enforcing the laws. If it works here, it works anywhere.

The most profitable piece in any system that touches money is a type for money. Amounts go in whole cents, never in decimal numbers—the computer can't represent 0.10 exactly with those numbers, and cents get lost little by little—and the currency goes inside the amount. And you need an operation to split, such as a discount across several products, a commission or a payment between merchants. That operation has a law, namely that the parts add up to the original amount.

The code below calls the type Dinero (Spanish for money), the currency Moneda, and the split operation repartir; its $pesos are the weights of each part, not Argentine pesos.

final readonly class Dinero
{
    private function __construct(public int $centavos, public Moneda $moneda) {}

    public static function de(int $centavos, Moneda $moneda): self
    {
        return new self($centavos, $moneda);
    }

    public function mas(Dinero $otro): self
    {
        if ($otro->moneda !== $this->moneda) {
            throw new InvalidArgumentException('Different currencies cannot be added');
        }
        return new self($this->centavos + $otro->centavos, $this->moneda);
    }

    /**
     * Splits the amount in proportion to $pesos.
     * Law: the parts add up to the original amount. Not a single cent is created or lost.
     */
    public function repartir(array $pesos): array
    {
        $total = array_sum($pesos);
        $partes = array_map(fn ($p) => intdiv($this->centavos * $p, $total), $pesos);
        // Whatever was lost to rounding is handed out one cent at a time.
        $sobran = $this->centavos - array_sum($partes);
        for ($i = 0; $i < $sobran; $i++) {
            $partes[$i]++;
        }
        return array_map(fn ($c) => new self($c, $this->moneda), $partes);
    }
}

Even if you don't read PHP, the idea is easy to follow. To split, say, $100.01 into parts of 35 and 965 (a 3.5% commission), each part is computed rounding down, you count how many cents were left over by the rounding, and you hand them out one by one. Nobody can build a Dinero without a currency, add pesos to dollars, or pass it an amount with decimals (with PHP's strict mode on, that's an error).

Now look at the comment on repartir. It states a law. Is it true?

That law is a sentence in a comment. PHP doesn't read it. The only way to know whether it holds is to try to break it. That's a property test (which I talked about in QuickCheck vs. Traditional Testing as a Deterministic Harness in the GenAI Era), which instead of trying two or three examples by hand generates thousands of random cases and checks the rule on each one. In a real project I'd use a library for this; to show the idea, a loop is enough:

// The law, as a test: ten thousand random amounts and splits.
for ($i = 0; $i < 10_000; $i++) {
    $monto = Dinero::de(random_int(-1_000_000, 1_000_000), Moneda::ARS);
    $pesos = array_map(fn () => random_int(1, 100), range(1, random_int(1, 6)));
    $suma = array_reduce($monto->repartir($pesos), fn ($a, $b) => $a->mas($b), Dinero::de(0, Moneda::ARS));
    if ($suma != $monto) {
        printf("Failure: %d split into [%s] adds up to %d\n", $monto->centavos, implode(', ', $pesos), $suma->centavos);
        exit(1);
    }
}

I ran it, and it fails right away:

Failure: -304503 split into [76, 17] adds up to -304502

The comment was lying. With negative amounts—a refund, a credit note—PHP's integer division rounds toward zero, which for a negative number means up. The parts end up slightly closer to zero than they should be, the count of "leftover" cents comes out negative, and the loop that hands them out never runs. The smallest case that breaks it is splitting one negative cent into two equal parts, and the result is zero and zero. A cent that vanishes.

The fix is two lines, which hand out the leftovers with their sign.

        for ($i = 0; $i < abs($sobran); $i++) {
            $partes[$i] += $sobran <=> 0;
        }

With that, the test passes ten thousand cases per run. And look at what happens now to the code that uses the piece. Before, a sale's commission was computed like this:

$comision = round($venta->total * 0.035, 2);
$aComercio = $venta->total - $comision;

And now like this:

[$comision, $aComercio] = $venta->total->repartir([35, 965]);

Reviewing the first version means thinking about rounding, about decimal numbers, about whether the two amounts add up to what they should. In the second, none of that is needed, because those are guarantees of the piece, which was already reviewed and tested once. The only thing left to review is the intent. Is the commission 3.5%? And does the platform or the merchant keep the cent left over when the amount doesn't divide evenly? repartir gives it to the first part, so putting the commission first or second is a business decision. A person has to answer those questions anyway. The difference is that now they're the only ones.

The test for whether a piece pays off

Not every abstraction buys you this. Many only add a level of indirection, one more layer to read to understand what's going on. To tell them apart there's a simple test, which is naming the diff that can no longer be written.

piece what can no longer be written
Dinero an amount without a currency; pesos added to dollars; cents in a decimal number
repartir a split that creates or loses a cent
transaction boundary a call to the payment provider inside a database transaction
idempotency retrying an operation that, when repeated, charges twice
specifications a database query that says one thing and a business rule that says another

If you can't fill in the second column for a piece, it doesn't go in. It isn't buying guarantees, only distance between the reader and what's actually happening.

An honest caveat about "can no longer be written." In Haskell or Rust, several of those rows simply wouldn't compile. In PHP, most of them mean something else, namely that an analysis tool like PHPStan flags it before running, or that it blows up the first time it executes. That's weaker. But it's far stronger than code where every line can round its own way.

Where the argument breaks

So far the idea sounds great. It has four limits, and the first one matters most.

1. Laws constrain composition, not meaning

That repartir doesn't lose cents says nothing about whether you should have been splitting at all. Laws guarantee that the pieces fit well together; they don't guarantee you built what you were supposed to build.

And in a payments system, the expensive bugs are almost all of that second kind. “You had to check the gift card's expiration before applying the discount.” An agent can write code that respects every law, passes every check, and is completely wrong. Worse still, it's harder to spot, because it looks tidy. Code built from pieces with laws looks like well-thought-out code, and that lowers the reviewer's guard. That kind of error doesn't get one cent cheaper.

2. The guarantee holds up to the border

Every place where the pieces touch the outside world—the database, the payment provider's API, the cache, the job queue—is a hole. And in a payments application, the error-prone lines are concentrated right there, out of proportion to their size. The pieces guarantee the inside of the pipe. I wrote about the border with the untyped world, and why you want it narrow and well guarded, in Type Systems for Machines That Program.

3. An untested law is a comment

We already saw it with repartir, but there's one more detail. If the test's generator had produced only positive amounts—the first thing that comes to mind, because money “is positive”—the buggy version would have passed ten thousand cases per run, forever, and the law would have stayed false. I checked.

In PHP there's no compiler paying for the laws, which leaves the test as the only guarantee. So “you don't need that much control over those lines” is true exactly to the extent that the generated cases really cover the possible ones. Not one bit more.

4. The error moves to the choice

With thirty pieces a new error shows up, the error of using the wrong one. Validating a form by stopping at the first error, or collecting them all to show them together; splitting with the commission first or second. Review goes from “is this line right?” to “is this the right piece?” It's a cheaper question. It isn't free.

The one that bites with agents is the erosion of the vocabulary

What makes review cheap is that the vocabulary is small and known. And that's exactly what agents tend to erode.

There's a benchmark from this year that measures it well, SlopCodeBench, by Gabriel Orlanski and colleagues. Instead of asking an agent to solve a problem in one go, it asks it to extend its own solution over and over, as happens in a real project (36 problems, 196 checkpoints, 15 agents). They measured two forms of degradation, structural erosion (complexity piling up in a few places) and verbosity (redundant code). Erosion grew in 77% of trajectories and verbosity in 75.5%. Compared with 473 Python repositories written by people, the agents' code came out 2.3 times more verbose and 2 times more eroded, and the human repositories degrade less often and by less over their history.

The figure that interests me most is another one. Explicitly asking the agent to care about quality reduced initial verbosity and erosion by up to a third, but didn't change the rate at which they degrade.

In a codebase with its own vocabulary, I know what shape that redundancy takes, which is a third variant of repartir that rounds just slightly differently, written because the agent didn't find the first one, or it didn't suit it. And with that, you lose the property you were buying. You're left with the worst of both worlds, an O(lines) review plus a home-grown vocabulary nobody on the team fully knows.

That's why the rules for admitting a new piece aren't an academic refinement but what holds up the economics of the whole idea. A piece gets in if you can name the diff that can no longer be written, if its law is stated, and if it has a test that tries to break it. And, as that figure showed, asking for it in the prompt isn't enough. In Convincing a Machine I said that what must always hold goes into a mechanism that can't be talked out of it, and this is one of those things. It can be as simple as putting the pieces in their own directory and requiring, through the repository's branch protection, that any change there be approved by a person (on GitHub, that's what a CODEOWNERS file does). The agent can use the vocabulary as much as it wants. Growing it, no.

What changes in practice

First, what's worth measuring changes. Not “how many lines were moved to the new style,” but how much of the risky surface can only be expressed through the pieces, that is, how much of the money handling, the state changes and the borders with the world has to go through them. 90% of the code migrated with one stray round() in the settlement buys nothing.

Second, how you review changes:

  • The pieces are reviewed as critical code, slowly and with suspicion.
  • The places where they're used are reviewed for intent, not mechanics, by asking whether this is the right piece and whether this is the business rule.
  • The mechanics are delegated to PHPStan and the property tests.

And third, the laws and their tests are written by a person. If the same agent that later writes the code writes them, you're measuring with a ruler made by the one being measured.

That's exactly where human attention is best spent if agents write the volume.

The honest version

Back to the opening question, do we still need to review every line so carefully? No. But control doesn't go away. It concentrates. It goes from being spread over every line to sitting in three places:

  1. The pieces, which are few and get reviewed thoroughly.
  2. The borders, where the pieces touch the world and their guarantees end.
  3. The specification, that is, whether what was built with the pieces is what should have been built.

Those three still need a human head. Everything else doesn't. And it's the same picture as in First the Filter, Then the Generator, with a small core where the risk lives, guarded with everything we have, and around it a large shell where the agent can work calmly, because mistakes there show up right away and don't break what matters.


References

  • Department of Defense (1985). Trusted Computer System Evaluation Criteria (the Orange Book). DoD 5200.28-STD. First issued as CSC-STD-001-83, 1983.
  • Lampson, B., Abadi, M., Burrows, M. and Wobber, E. (1991). Authentication in Distributed Systems: Theory and Practice. SOSP '91. Extended version in ACM Transactions on Computer Systems, 10(4), 1992. DOI · PDF of the 1991 version
  • Nibaldi, G. H. (1979). Specification of a Trusted Computing Base (TCB). MITRE, M79-228. DTIC
  • Orlanski, G., Roy, D., Yun, A., Shin, C., Gu, A., Ge, A., Adila, D., Roberts, N., Sala, F. and Albarghouthi, A. (2026). SlopCodeBench: Benchmarking How Coding Agents Degrade Over Long-Horizon Iterative Tasks. arXiv:2603.24755
  • GitHub. About code owners. Documentation
The code

Everything this article claims, in code that runs. Clone it, break it, open an issue.

Ragnagrok/control-doesnt-go-away-it-concentrates
Support the blog

If this article was useful to you, you can sponsor the blog on GitHub. It helps me keep writing.