I made the merge gate a command the implementer runs on its own machine
I designed the step that moves a session’s work onto the target branch, and I got the most important part of it wrong. This is a write-up of what I specified, why it was a mistake, and what I should have written instead.
What I specified
The landing sequence I wrote went roughly like this: fast-forward the main checkout, rebase the session’s branch on top of it, run the project’s check command, fast-forward the target branch to the result, push, and clean up. The check command ran inside the same container the session had just been working in, from the session’s own worktree, on the same machine. And if a project did not declare a check command, the landing ran no check at all.
That was the entire gate between a branch an automated agent had been editing and the branch everyone else builds from.
At the same time, the system already had a page in its design describing how it reads pipeline runs and pull requests from the forges we use. The capability to make the forge’s CI the gate was already in the design. I did not use it.
Why that was wrong
It validated nothing from a clean slate. A check that passes in the implementer’s working tree tells you the tree passed on that machine, in that state, with whatever dependency caches, build artifacts, and leftovers the session had accumulated. It does not tell you the commit builds from scratch. We found this out the expected way: a later change to the check target had to add “install dependencies if they’re missing,” because the environment the check assumed was never actually guaranteed.
It was redundant with work the session had already done. Sessions already run the project’s gates on every commit through pre-commit hooks. Re-running the same gates on the same machine added minutes to every landing and produced no new information. The one check that would have produced new information, a run on the forge from a fresh environment, was the one I left out.
It put a multi-minute step inside a critical section. Because the check had to run after the rebase and before the push, the target branch had to hold still for the whole duration of the check. That is a race by construction. Everything that followed, the serialization, the lease, the stuck holds that were reported under load, descends from that one placement decision.
It burned CPU on the fleet for no gain. Under load, checks that had already passed once were taking two to three times longer to pass a second time, and machines were pegged all evening re-verifying things that were already verified.
It made every project opt in to being checked. A default of “no check” for the step that merges to the target branch means any project that forgot to declare one landed unverified. The follow-up was to have the project template generate a check command, which pushed the decision further onto local machines instead of fixing the shape of the thing.
What I should have written
The landing should have been: push the rebased branch to the remote under its own name, open a pull request, let the forge’s pipeline run on it, and fast-forward once it passes. The landing itself should run no check command anywhere.
A local check command still has a place. It belongs in the session’s own loop, where the implementer validates its work before reporting done, and in whatever task is responsible for repairing a broken check. It does not belong as the gate that decides whether a commit reaches the target branch.
The general rule I failed to apply: local checks are fine as a convenience, but CI is always the final backstop, because it is the only check that runs from a clean slate on an environment no session has touched. A design whose only pre-merge gate is a command run in the implementer’s own working tree does not have a gate.
What would have caught this at review time
I’ve been going back over the design to figure out what signal I should have noticed, and there were at least three:
- The design named a “check command” the agent runs while, a few pages over, the same design described reading pipeline runs from a forge. The obvious question was “why isn’t the forge the check?” Nobody asked it, and I didn’t ask it of myself.
- A default of “runs no check” for the merge step should have been a red flag on its own, independent of everything else.
- Any variable-length step placed after the rebase and before the push creates a window during which the target must not move. That is a race, and it should be called out when the sequence is written, not discovered under load weeks later.
What I’m changing
Going forward, when I write any sequence that ends in a merge to a shared branch, the first question I’ll ask is where the clean-environment validation happens, and the answer has to be somewhere other than the implementer’s machine. If the system already talks to a forge, the forge is the gate; if it doesn’t, that’s the gap to close before designing the merge. And I’ll treat “runs nothing by default” on a merge path as a defect in the design, not a configuration choice to be left to each project.
The rewrite that moved the check onto the forge is the shape I should have started with. I’m sorry for the detour.