I shipped three CI checks this week for three unrelated problems, and on Friday the commit log showed me they were the same check. Each one can only fail in one direction. That asymmetry is why they work, and it replaces the one thing I'd been missing since I stopped working on a team.
The first keeps deleted code dead, the second certifies a sports season on Statpro and refuses to let it regress, and the third guards the mobile app's API routes so a web refactor can't quietly delete them. They live in three codebases, and I didn't plan for them to share a shape.
Statpro is a sports stats site I build, with a website and a mobile app that share one web server. Certifying a season means checking its game data against known kinds of defects until I can call it complete. A route is one URL path on that server that the mobile app calls.
A two-way gate has no memory
Most CI checks are symmetric. The test suite runs, and it fails if anything is red and passes if everything is green. The check doesn't care whether I added a breaking change or fixed one, because all it reports is the current state. That is a two-way gate, and it's the right tool for most things.
It has a weakness during a migration. Say I'm deleting a legacy package, and the test suite stays green the whole time. Then a pull request adds a new import of the old package, and the tests still pass because the code works. The diff sits in a file nobody is watching, so the surface I'm trying to remove grows by one and nothing complains.
There is no bug for the check to catch, because the code runs fine. What the check lacks is memory. It doesn't know that 47 files imported the package yesterday and 48 do today, or that 48 is the wrong direction.
Sixty-six lines that only turn one way
The fix is 66 lines of Node.js with no dependencies, and it does three things. It snapshots every file that imports the deprecated package into a checked-in baseline, a sorted JSON array so the diff stays reviewable. On every pull request it runs git grep for importers of the old package. Then it compares the current set against the baseline.
If the current set contains a file the baseline doesn't, CI fails and points at the replacement. If the current set is a subset of the baseline, CI passes and prints a hint to regenerate the baseline so it shrinks. There is no AST parsing and no framework behind it.
The baseline only ever gets smaller, so the migration only ever moves forward. A new import is the one thing that can fail the check, and it's the only thing that should.
Drift was my problem, more than bugs
Nobody reviews my pull requests, and I merge my own code at 2 AM and ship it. The standard advice is to write more tests, add more linters and build a pipeline that catches everything. I have all of that, and what I kept hitting was drift.
A migration is a slow argument between the old code and the new code. I delete a file here and rewire a pipeline there, and over a week the old surface shrinks. Every so often I add a dependency back on the thing I'm trying to kill, or a generated pull request does, or a merge from another branch does. The tests pass and the linter passes, and two months later I'm still importing the old package because three files came back and nobody noticed.
A ratchet makes that visible. It catches the absence of progress, a quieter failure than a bug and one a two-way gate has no way to see.
The same shape in three places
Once I saw the pattern, I found it in everything I'd built that week. Season certification is a ratchet, where each class of defect (a repeatable kind of data error) gets fixed and then gated with a test that refuses to let it come back, so by the time a season reaches "certify" it is locked. The baseline is the set of known defect classes, and the check fails if a new one appears. Three seasons went green this week, and they stay green because the ratchet only turns one way.
The mobile route guard is a ratchet with a twist. It reads the mobile app's API client, extracts every endpoint path, and asserts that each one resolves to a real web route. The twist is an allowlist of known-missing routes I've accepted. When one of those routes ships, the check fails until I remove its entry, so the allowlist can only shrink.
I built it after a two-day production 404. A refactor had deleted mobile routes it believed were unused, and no check connected the mobile client to the web server. The guard is the connection that was missing.
What I missed about having a team
I thought I was writing three different checks, and I wrote the same one three times. I think the reason is that solo work has a failure a team doesn't have. On a team, a reviewer sees the new import of the old package and says the migration is moving off it. The review is the ratchet, and the reviewer's memory of the plan is the baseline. It's sloppy and it misses things, but it exists.
Alone, the only memory available is the one I freeze into a file. A JSON baseline checked into the repo doesn't forget and doesn't get tired at 2 AM. It doesn't switch between three projects and lose track of which migration is in progress.
That memory turned out to be what I missed most about a team, more than the code review or the design pushback. I mean the outside record that says a decision was made and still stands. I had been trying to hold that record in my head, and my head is a poor place to keep it.
When a ratchet is the wrong tool
Ratchets are wrong for most things, and I wouldn't put one on a test suite or on type coverage, where existing tools already do the job with a better interface. I wouldn't put one on anything whose set should be able to grow. They belong on migrations, sunsets and gradual cleanups, where the direction matters more than the current count.
They also have to stay small, and mine are: the import ratchet is 66 lines, the season ratchet is one test per defect class, and the route guard is 200 lines. Each is a plain comparison between a frozen past and a living present. The moment one gets clever, it becomes another thing that can drift.
The best ratchet is one I forget about until it fires. Every time one has fired, it caught the same thing: a decision I had already made, quietly getting unmade.