Picture a pull request merging, the pipeline going green, and the deploy job waiting for the security checks on that exact commit before it touches the server. While it waits, a second pull request merges. The checks for the first commit pass, the gate opens, and the server runs git reset --hard origin/main . It is now running the second commit, whose security scan has not finished yet.
Nothing in that sequence is broken in a way a test would notice. The gate did what it was written to do: it found the commit that triggered the workflow and waited for that commit's checks to pass. The deploy script did what it was written to do too, which was to fetch main and reset to it. The gap was between them. One step asked about a commit by its SHA, the next asked git for whatever the branch pointed to at that moment, and on a quiet day those are the same commit. On a busy afternoon they are not.
I found this in a production app I maintain, in a deploy gate I had already fixed once.…