November 10, 2026

The Rule Was Written Down, and It Still Did Not Run

We run most of the operational layer of a small software company with automation, and much of that layer is governed by rules we wrote ourselves: this message goes out once a day, this kind of work is handed over like that, this request takes that shape. Writing the rule down feels like the end of the job.

Over a few months, three of our rules turned out to be written in places where nothing was obliged to read them. Each one failed in its own way, and more than once the measurement said something different from the explanation we reached for first. Identifiers removed, dates moved.

A guard in the prompt binds only the paths that run it

A scheduled task of ours sends one summary message each morning. It went out twice, to the same person, three times in one week. Each time two sessions were running the same task around a restart, and each time the protection failed differently: a note the second session had not read yet, then a check followed by a send that was not atomic, then a stale session that sent without running the check at all.

All three protections were text a session was expected to follow, and that is the part worth sitting with. The first depended on a note being read in time, the second on a check that two sessions could both pass before either had sent, the third on a session choosing to run the check at all. Whatever the text said, nothing in the send itself had to take part.

Text a session is expected to follow stops only the session that runs it, and a second session on another road sends anyway. Inside the send paths, the sender claims the day atomically before sending, and the tool path gets a check and a marker, so a second session is stopped on either road.

A message could leave on two roads, a sender script and a tool call, and the fix had to cover both. On the script road the decision moved into the sender: it claims the day with an exclusive file create before sending anything, and the loser of the race exits without sending. Two parallel invocations against a stub API produce exit codes 0 and 3, and one message. With the claim disabled the same pair sends two, the control that makes the first number mean something.

The other road got a pair rather than a copy of the same guard: one check refuses a second marked message, another writes the marker after a send that succeeded. That second half closed the hole from the third incident, where the first message left by a road that marked nothing.

Two details from that fix have outlived it. The first is that the two layers were given opposite failure directions, on purpose: the sender fails closed, because the cost of refusing is one retry, while the check on the tool path fails open, because a broken check there would silence the agent. Any exception, and the message goes through. "Fail-closed" is not a virtue you apply evenly; it answers "what does being wrong cost here", and that answer changes per layer.

The second is what the cheap version would have cost. The obvious guard was a time window: block anything in the morning slot once the day is marked. That would also have blocked a reply to the owner's own message inside that window, and a length threshold would have caught any long ordinary reply. The suite pins it: remove the narrow check and exactly the three "never block the person" tests fail. The guard that got built does not charge the user for our deduplication.

A rule can be complete at everyone it binds and missing at whoever decides

The second is about delegation: what work may be handed to another operator, on what branch, through what review. One evening the rule was quoted back, in writing, in the form it had replaced the day before.

The obvious explanation is that nobody reads what we write. The measurement said otherwise. The current rule stood in full, with its reference, in the always-loaded instruction file of six of the parties it binds, and in zero of the files loaded by the party that decides whether to delegate at all. It was complete at every reader who had to comply and absent at the only reader who had to choose.

The current rule stood in full, with its reference, in the always-loaded instruction files of the six parties it binds, and was absent from the always-loaded file of the party that decides whether the rule applies. That party quoted the repealed version from memory.

Those are two different audiences, and distributing a rule instinctively targets the first, because that is who it is about. So the question we ask now, when a rule is written or changed, is really two: who does this bind, and who decides about it? Both need it somewhere they cannot skip.

There is a smaller version of the same mistake one layer up. Our index of past lessons pointed here with a line describing how we found it rather than what it says. A line that reads like history does not announce itself at the moment someone is about to state the rule, which is the only moment it has.

Being in the right place is not enough if something cheaper arrives first

The third one is the least obvious, because the rule was in the right place.

We have an internal interface where a few otherwise reasonable request shapes get rejected, for good reasons. The shapes that pass were measured and written up in the reference document for that interface, whose own summary line says to consult it before hand-writing a request. The next morning the same rejection happened twice more.

The cause was neither carelessness nor a missing document. The instruction file that loads on every run offers ready-to-copy templates for that same interface, and we counted them again while writing this: eight. In a hurry, that is what gets copied, and by the time the reference could come up, the answer is already in your hand.

This is a third failure mode, and it is not the first two: the rule is in the right layer, and it loses a race. So the useful test is not "where is this documented" but "what is the cheapest thing within reach at the moment of the decision". Whatever sits there is the rule actually in force, and the fix is that thing, not a third restatement of the rule.

The rule

Three failures, three checks. In our setup these run before we call a rule written:

Which layer sees every call? Put the enforcement there, not on one way in.

Who does it bind, and who decides about it? Both need it where they cannot miss it.

What is the cheapest thing within reach at the moment of decision? If that still says something else, the rule has not landed.

None of this makes a rule unbreakable. It moves the failure from silent to visible, and visible is the part you can act on. One addition where enforcement ends up in code: give the overrides a counter. A guard that hides how often it fires hides the number you need for the next decision.

See what we build

This content is freely reusable with attribution (CC BY 4.0). Questions: hello@peci.io

← Back to Blog