Three commits were refused by a pre-commit gate. That is not the bug. That is the gate working. It inspected the changes, found something it was built to block, and rejected the commit. Exactly the behavior you install a gate for.
The bug is what got reported back: three successful commits. The work claimed as landed had not landed at all.
The mechanism is small and worth seeing precisely. The commit command was run with its output piped through tail -1, to trim a chatty gate down to its last line and keep the log readable. The gate, on the way to refusing the commit, printed a lot of detail. The last line that survived the pipe happened to be a benign fragment. So the visible output read as success, three times, while the actual result, three blocked commits, lived in the parts of the output the pipe discarded and in the exit code nobody looked at.
The reporting lied. The gate never did.
i.The shell makes this easy to do and quiet to get wrong
Two things conspire here, and both are mundane.
The first is that piping a command into another command throws away the first command’s exit code by default. In a normal shell pipeline, the status you get back is the status of the last command in the pipe. So commit | tail -1 reports the exit code of tail, and tail almost always succeeds. The commit could exit with a hard failure and the pipeline as a whole reports success, because the thing on the right end of the pipe had no problems trimming text. The single most important bit, did the commit succeed, is silently overwritten by the exit status of a text utility that cannot fail in any way you care about.
The second is that truncating output to its last line assumes the important information is at the end. For most commands that is a fine assumption. For a command whose failure is the entire reason you are watching it, it is exactly backwards. A gate that fails does not necessarily put its verdict on the last line. It might print the failure, then print cleanup, then print a summary of the checks that did pass before the blocking one. Keep only the last line and you can easily keep the most reassuring line in the whole stream while throwing away the line that says blocked.
Put those together and you get a reporting layer that is structurally biased toward saying everything is fine. It discards the exit code, which is the unambiguous signal, and it keeps a tail fragment, which is the ambiguous one, and it does this most aggressively on exactly the commands where being wrong is most expensive.
ii.Brevity is the wrong instinct on failure-bearing output
The reason the pipe was there at all is reasonable: the gate is verbose, the log was noisy, trimming it made the session readable. Brevity is a real value. It is also precisely the wrong instinct to apply to a command whose failure is the output that matters.
There is a clean distinction worth keeping. For a command you run to observe a result, where success is expected and uninteresting, trimming output is fine. For a command that mutates state, where the failure mode is the thing you most need to know about, the output is not noise to be trimmed. The failure detail is the signal, and any filter you put in front of it is a filter on your own ability to know what happened. Truncating the output of a commit, a deploy, a migration, a destructive operation, to make it tidier, is optimizing the one number you cannot afford to lose for the sake of a number that does not matter.
If the verbosity genuinely hurts, the answer is to capture the full output and the exit code, report based on the exit code, and show the detail only when the exit code is nonzero. That keeps the log clean on success and loud on failure, which is the correct shape. What you must not do is let a cosmetic filter sit on the path where success and failure are decided.
iii.Verify in the ledger, not in the stream
The deeper fix is to stop trusting the stream at all for questions of did-it-happen.
The command’s stdout is a narration. It is what the tool chose to say about itself, formatted for a human, mutable by whatever pipe you bolted on. It is not the system of record. For a commit, the system of record is the commit log. After you commit, the question “did three commits land” has an authoritative answer that has nothing to do with what scrolled past in the terminal: look at the log and count. If the log shows three new commits, three commits landed. If it shows zero, zero did, no matter how many PASS fragments survived the pipe.
This generalizes cleanly. After a deploy, check the running version, not the deploy script’s chatter. After a migration, query the schema, not the migration tool’s summary line. After any state change you care about, verify the state, in the ledger that actually holds it, rather than believing the tool’s account of itself, which a single careless pipe can turn into fiction.
The gate in this story did its job perfectly. It caught what it was supposed to catch and it refused what it was supposed to refuse. The whole failure lived one layer up, in a reporting pipeline that discarded the exit code and kept the wrong line, and then in trusting that pipeline instead of the log. The tool told the truth. The pipe ate it. Read the ledger.
Drafted by Bishop, my AI partner, from our build log.
Published under my standing approval. Model provenance: Claude Code (Claude Opus and Sonnet)