Guardrails are code, and code has bugs

When the AI makes a mistake in our codebase, I don't just fix the mistake. I fix whatever let it slip through. A missing test becomes a test. A mistake we keep catching in review becomes a lint rule. A dangerous shell command becomes a hook that blocks it and names the safe alternative. That's the part that compounds. Every fix protects every future change.

It took us a while to learn the second half. Guardrails are code, and code has bugs.

CrowdStrike is my favourite example. People describe the July 2024 outage as a missing guardrail. CrowdStrike actually had one. A content validator checked every rapid-response update before release. The new template type defined 21 input fields, and the validator checked updates against those 21. The sensor code only ever supplied 20. The validator shared the exact mismatch it was supposed to catch, passed the bad file, and Microsoft counted 8.5 million Windows machines down.

A guardrail that shares the blind spot of the thing it guards gives you confidence and no protection. That's worse than no guardrail, because nobody checks the guardrail itself.

Two validators that shared the blind spot of the thing they checked
Two validators that shared the blind spot of the thing they checked

We learned this on our own platform in June. Every change our agents write gets reviewed by a panel of four AI reviewers. Each runs a different model, so they don't share blind spots. A loader bug quietly stripped each reviewer's model setting and made all four inherit the model of the agent running the review. For weeks we believed four independent reviews ran on every branch. In reality one model was reviewing its own work four times. Nothing failed. Every review passed exactly the way it was supposed to.

The fix registered each reviewer with its declared model directly, so the setting can't be stripped on the way in. The more important change was making the collapse visible. The runtime now warns the moment a reviewer's model degrades or the reviewer list comes up empty. A guardrail that stops guarding now makes noise instead of silence.

So I treat guardrails like production code. They live in the same repository and ship through the same review. Every lint rule has its own tests, and those tests fail when the rule stops catching the case it was written for. The AI reviewing a change runs on a different model than the one that wrote it. A guardrail that blocks the agent prints the reason and the safe command, so the agent fixes the mistake instead of fighting the wall.

The collapse also taught us where to aim those tests. A test that checks a rule on its own would have passed all through June. The bug lived in how the reviewers got loaded. So the test that guards the panel now loads the reviewers the way production does and asserts each one keeps the model it declared. A guardrail test has to fail when the guardrail stops working in production.

Treating guardrails like code also means they pile up like code. Every bad habit an agent showed between April and October left a rule behind, and we never deleted any of them. By November our agents worked inside more than seventy reply lints and shell hooks. Nobody could say which ones still caught real mistakes and which had decayed into ceremony.

In November we wired a counter onto every guardrail and audited thirty days of production fires. The survival rule was blunt. Zero catches in thirty days meant deletion, unless the rule was the only thing standing between us and a data leak, an irreversible write, or a dropped message.

Four reply lints failed. One had never fired at all. Two forced agents to pass a dispatch flag our backend silently ignored. The fourth kept rejecting work over a flag that never left the local binary, so every fire burned a retry and changed nothing downstream. A shell hook that checked cloud account profiles had blocked over 1,200 harmless local commands in the same thirty days, including ones that only printed a version number. We deleted the four lints with their tests and docs, narrowed the hook, and finished the day around six hundred lines lighter.

The deletions matter as much as the additions. A false block costs a retry, a few minutes, and a little trust. Multiply that by thousands of tasks a week and the guardrail becomes the bug. A rule nobody can justify with a single catch is ceremony, and ceremony is what teams learn to ignore.

The order matters too. We kept the rules that guard what can't be undone, even when they never fired, because the one catch that matters may come next year. Every other rule stays only when production evidence shows that it catches a real failure.

AI lets us move quickly when controls catch real failures and we test, measure, and prune those controls like production code. Every surviving guardrail now logs every fire on every task, so the next pruning pass starts from numbers.