Founder Notes
Frozen Data, Running Clock
A continuous integration pipeline started failing on work that could not have caused it. Several dozen tests in one suite, all reporting the same thing: a record that should have been accepted was refused.
That is a specific and alarming failure. The suite covers a component that decides whether a record is still in force, and "should have been allowed, was denied" is the exact signature of that component breaking. I spent the first stretch of the investigation looking at the thing the tests were pointing at.
It was fine. It had been fine all along.
What the fixture actually said
The harness that builds the test data had a constant at the top holding a specific instant — a real calendar date, written out in full, about a month in the past. Every record the harness described as currently valid was seeded to expire thirty days after that instant.
The component under test did not read that constant. It read the clock.
So for thirty days the arrangement worked perfectly, and on the thirty-first it stopped, because the records the harness called valid had genuinely expired. The component looked at them, correctly concluded they were no longer in force, and refused them. Every assertion expecting acceptance failed. The tests were not detecting a regression. They were reporting, accurately, that expired things are expired.
I checked the alternatives before touching anything, because a conclusion that convenient deserves suspicion. A clean checkout of the mainline, with none of my work on it, failed identically. An earlier pipeline run from my own branch, from before I had touched dependencies at all, resolved to the same dependency set and failed the same way. The pipeline configuration was byte-identical to the mainline's. There was nowhere left for the explanation to hide.
The mainline's last green run had finished about an hour before the deadline.
Freezing half of it
The intent behind that constant was good. Tests that read the wall clock are flaky, so you pin time and make the run reproducible. That is correct practice.
But a test involving time has at least two terms: when the data claims to be, and when the system thinks it is. Pinning one of them does not remove time from the test. It converts time from something that varies into something that runs out.
A literal date plus a relative offset is not a frozen clock. It is an interval with an end, written in a place nobody will think to look for an expiry. The suite had not been made deterministic. It had been given a deadline, silently, by someone reaching for determinism — and the value that set the deadline looked exactly like the kind of constant you skim past.
The two honest options are to fix both ends or neither. Anchor the data to the same instant the system reads, so the relationship between them holds forever; or let both float against the real clock, so the data is always the right distance from now. What you cannot do is fix one end of a comparison and leave the other running.
Who pays
The part that stayed with me is not the bug. It is the billing.
Nothing was wrong on the day that constant was written. Whoever wrote it saw a green suite, and it stayed green through every change they made afterward. The cost was real but unbilled, accruing quietly against a date nobody had recorded as significant.
It came due on an ordinary afternoon, and it attached itself to whoever happened to be pushing. That was me, and I had just landed a large piece of unrelated work — which made the most plausible reading of the evidence, by a wide margin, that I had broken it. The next person to push would have inherited the same accusation, with nothing in their change to explain it.
A latent failure with a date on it does not merely fail. It selects a defendant, and it tends to select the one least likely to be responsible, because whoever planted it stopped touching that code long ago.
There is a smaller trap on the way out. Once you understand the cause, the fastest repair is to make the failing cases pass — and in a suite about whether things are still in force, "make the refusals stop" sits one careless edit away from a component that refuses nothing. So the fix has to be checked against the cases that are supposed to fail, not only the ones that are supposed to succeed. Green is not the target. Green for the right reason is.
The general form
If you pin time in a test, pin every term that time touches.
Determinism is a property of a relationship, not of a value. A constant is only as fixed as the thing it is compared against, and a constant compared against a moving quantity is not a constant at all — it is a countdown with good posture. The moment you write a real date into a fixture and derive anything from it by addition, you have created an expiry. The only question left is who will be standing there when it arrives.