Last Friday the build pipeline for Statpro, a sports stats site I build, refused to run, and the error was almost polite: Certified question capacity exceeds safe bound: 1000001. That is one row over a million, the kind of number that makes me suspect an off-by-one before anything real. I went looking for the off-by-one and found a guard that had been correct every day since I wrote it, which turned out to be the problem.
The guard was right
Statpro lets people type a sports question in plain English and publishes the good answers as pages. A question catalog is the list of every question the site is allowed to publish, and the build pipeline generates that list by working out every question the data can answer. Enumerating them all is a step that could run away if something went wrong, so the guard caps it.
Months earlier I'd written that capacity stop, a guard against runaway enumeration, capped at one million rows. It had been sitting at exactly the ceiling of a single question family, meaning one kind of question. The playerOpponents dimension, the family of player-versus-opponent questions, legitimately saturates at 999,999 rows, which is a million divided by three leagues, rounded down, times three. One dimension used the entire safety budget and left every other family zero headroom. Nothing was broken, and the guard fired because the production source had grown to fill the exact hole I'd left. By production source I mean the live stats data the catalog is built from.
It took me a day to see the next part clearly. The guard was correct when I wrote it, it was correct yesterday, and it will be correct tomorrow. What I had built was a countdown timer that I'd mistaken for a wall, and the countdown ran at the growth rate of data I don't control.
The instinct that sizes it wrong
When I write a guard, I reach for a number that feels safe. I look at the current row count, double it for headroom, and round up to a clean power of ten. A million feels generous when the table holds 19,000 rows. The instinct is to size the guard against what I can see.
The production source is a river, though, and what I can see is one snapshot of it. Historical seasons get backfilled and new leagues get added. A dimension that sat at 12,000 rows last quarter can hit 999,999 on the next full compile of the catalog, because a backfill finished somewhere upstream and nobody told me. A guard written against Tuesday's data answers a question about Tuesday, and the system asking it has moved on.
This is the part of solo engineering I find hardest to absorb. Most of my code is fine, and most of my bugs aren't logic errors. They're timers planted by an earlier me who didn't know the data would grow this fast, or grow at all. The failure is a coupling I didn't notice, between a constant I hardcoded and a variable I don't own.
Size it against the design ceiling
The fix sounds obvious afterward, which is to size the guard against the design ceiling. The design ceiling answers a different question: what is the most this system is built to hold, ever, even on its worst day? For my question catalog the answer is nowhere near a million. It's the cross product of every player, every opponent, every season, every league and every stat slice the schema can express. That comes to roughly eight million, and it has the right shape because it's derived from the schema and doesn't come from a row count that changes every week.
What matters is the thing each number is coupled to. A measured stop is coupled to the source, and a design ceiling is coupled to my own schema. I control the schema and I don't control the source. When the source grows, a measured stop shrinks in real terms without telling anyone, and one day it fires on a system that's working exactly as designed. A design ceiling moves only when I change the design, which is the only time it should.
Other numbers on the same clock
Once I'd seen it in the capacity stop, I found it everywhere I'd reached for a "safe" number. I set a cache TTL to an hour because the data felt stable, and then the data started updating every five minutes. I capped a batch size at 500 because the table was small, and then the table got large and the batch became the bottleneck. I set a retry count to three because failures were rare, and then a flaky dependency made three feel like none.
Each of those numbers was reasonable the day I wrote it. Each was also a countdown I couldn't see, because the thing it was sized against kept moving while I treated it as fixed.
So I'm learning, slowly, to ask two things of every constant: what is this number measuring, and does that thing stay put? A number that measures my own design can sit where it is. A number that measures the world will stop being safe long before it stops looking safe, because the world keeps moving.
Why I woke up to an error and nothing worse
This story ends cleanly for the same reason most of my week did. The pipeline is fail-closed by design, so every step produces a verifiable receipt and every receipt gets checked. The capacity stop didn't damage my catalog in silence. It refused to run, printed the exact number that tripped it, and waited. I woke up to an error message when I could have woken up to a quietly broken database.
That's the part I'd pass along to anyone building alone at night. A guard that fires loudly is a gift, and a guard that fires silently is a slower kind of bug. The difference lies less in the guard than in whether anything downstream is listening.
The stop sits at eight million now. I'm under no illusion that eight million is permanent, but this time it's coupled to the right thing. When it fires again, it will be because I changed the design, and the river rising while I'm asleep can no longer trip it.