The number that may only go down
Agents rebuilt our tool's architecture in two weeks, under one file of numbers they were not allowed to raise. The numbers went up anyway — mostly when we started counting something honestly

In the first half of November, Mikoshi took its own code apart. The old split into src and scripts stopped making sense once the factory started shipping inside the package, so the code is being regrouped into modules, one per concept, each with a public contract. About 350 commits in two weeks. Agents wrote nearly all of them, card by card, in parallel.
A refactor at that speed has one obvious failure mode. Every card makes its own change look cleaner, and the whole quietly gets worse. Nobody sees it, because nobody reads 350 diffs.
So the refactor runs under a ratchet.
One file of numbers
contract/ratchet.json is a flat list of counters. CI recomputes every one of them on every pull request. If any number comes out higher than the file says, the check fails.
There are four kinds of counter:
- lines — non-test files over 800 lines, and how long each one is
- overlaps — places where the same concept is implemented more than once, summed per concept
- law gaps — places where a rule the factory must obey is not yet enforced, each tied to the card that will close it
- boundaries — imports that cross a module boundary the module spec does not allow
The rule is in the merge policy, not in anyone’s head. A card that lowers a number merges like any other card; an agent can carry it all the way to main. A card that raises a number, or adds a new one, goes to the owner — under every delegation and every standing decision. Since 6 November that has been the one direction an agent cannot merge on its own.
- card
- CI recounts
- lower: merges
- higher: owner
How fast it went down
From the first commit of the file to the last one before this post:
| Counter | Start | Now |
|---|---|---|
| lines, files over 800 | 8,541 in 7 files | 5,840 in 5 files |
| overlaps | 450 | 484 |
| law gaps | 52 | 42 |
| boundary imports | 1,232 in 281 rows | 1,099 in 247 rows |
Two of those rows look like failure. Overlaps ended higher than they started. Law gaps barely moved. Neither is what it looks like.
Four ways it went up
The ratchet only turns one way for agents. It still turned back, in four different ways, and none of them was an accident.
Law gaps appeared at 52. The counter did not exist until 10 November. Agents brought it down to 37 in a day. Then a card registered a new law — that a stalled review must be noticed — and the count jumped to 51. The gaps were there before. The law that made them visible was not.
Overlaps jumped from 217 to 686. On 11 November a card added a new concept to the count: everything that reads the bus. Hundreds of places were reading it their own way. Nothing new was duplicated that day. We just started looking at a kind of duplication we had been walking past.
A file crossed 800 lines. On 12 November one card taught owner decisions to close the wait they answer. It pushed one module over the line and grew another that was already past it. That is the case the ratchet exists for: a real increase, stopped at the gate, and let through by a person who decided it was worth it. Within three days both files were split and off the list.
Boundaries arrived at 1,232. The module spec started being enforced on 12 November, and the first count was simply the size of the problem. Since then it has drifted up by a few imports more than once. Part of that is a hole we cut on purpose. When a card moves a file from one module to another, imports that were fine inside the old module can become cross-module ones without anybody writing a new line. The ratchet lets such a row grow only if the total does not, and every import in it already existed on the commit the card branched from. A new import is still the owner’s.
- new counter or concept
- number jumps
- agents walk it down
Getting the counting right
The counter itself needed three fixes before it told the truth.
At first it counted overlaps per file. An agent that moved a duplicate from one file to another raised one number and lowered another, and the check read that as growth. Now each concept is one number, the sum over all files.
Then the ownership moves. A card that moved files between modules turned an internal import into a cross-module one and was blocked for something it did not write. That is where the rule about imports existing on the base commit came from.
Then CI. Locally the ratchet compares against the merge base with main. In CI the checkout is two commits deep and the head is a merge commit, so it now reads the first parent. When it cannot find the base at all and a row grew, it fails and says why, instead of assuming nothing moved.
None of these were in the plan. Each one came from a card that was blocked when it should not have been.
What it bought
The number that matters is not in the table. The ratchet file changed 81 times in those two weeks, out of roughly 350 merges. About twenty of those changes raised a number or added one. Everything else lowered something, and merged without a person reading it. The file says the structure got better, not worse.
A rule like “do not make the architecture worse” is useless to an agent. It has no way to check it. A file of numbers that CI recomputes is a rule it can check on every single card — and that a person only has to look at when the numbers move the wrong way.
The interesting part is that they did move the wrong way, more than once. Only one kind of jump meant the code had actually got worse. In the others, what changed was how much of it we could see.