I shipped a Promote button that can never be pressed
Last week an operator opened the dashboard to promote the nightly branch and found the Promote control sitting there, greyed out, with a note explaining that a run was in progress. They waited. It stayed greyed out. They came back later and it was still greyed out, now naming a different run. The feature I had designed, implemented, reviewed, tested, and shipped turned out to be unusable during exactly the period it was built for. This is a write-up of how that happened and what I’m doing about it.
What I built
The promotion step was meant to be simple: move the target branch forward to the source branch’s head, fast-forward only. To keep bad code from being promoted, I added a refusal rule. If the latest run on the source branch, in any repository the project includes or any mirror those repositories declare, was queued, running, waiting for approval, or failed, promotion was refused. The scheduled variant would retry each time it re-read the head, and give up with a warning at the end of the day. The dashboard disabled the button and showed the reason.
Every piece of that worked. The controller computed the refusal correctly. The endpoint reported it. The client rendered the disabled state with the right message. The tests passed. The acceptance criteria were met line by line.
What I missed
The project is made up of several repositories plus a couple of mirrors. Every push to any of them kicks off a run on that repository’s nightly branch. Work lands on nightly continuously, because that is the point of nightly: agent sessions are dispatched all day and each one lands its result there.
So at almost any moment, some repository’s nightly head is under test. My refusal rule said “refuse if any head is under test.” Put those two facts together and the rule reduces to “refuse.” The scheduled retry didn’t help, because it was asking the same question over and over and getting the same answer, until the day ended and it raised an alert about a condition that was never going to clear.
I had written a requirement that, read in isolation, sounds responsible and conservative. I never held it up against the actual tempo of the system it would run in. If I had spent five minutes asking “how often are all heads simultaneously green?” the answer would have been obvious.
What I should have done
The fix, which is now the design, is to stop treating the head as the only candidate for promotion. Instead, promote the source branch’s last good commit: the newest commit on the source whose retained runs all passed, across the primary repository, its mirrors, and the sibling repositories at the commits it pins.
This has a few properties my original design lacked:
- It is always available. As long as any commit on the source has ever passed, there is something to promote. The decision never waits on anything.
- A run in progress doesn’t block anything. It just means the head hasn’t been judged yet, so we promote the commit before it. When the head passes, the next promotion picks it up.
- A failed head is handled the same way. We don’t refuse; we promote the last thing that worked.
- “Nothing to do” is a real state. If the target is already at the last good commit, promotion is a no-op rather than a refusal.
Retrying was a weaker answer than this. A retry depends on the world settling down, and under normal load it doesn’t. The last good commit is already there regardless of what the head is doing.
The pattern I want to name
The uncomfortable part of this is that nothing in our process would have caught it. The implementation satisfied its requirements. Review checked the code against the design. Tests checked the behaviour against the acceptance criteria. All of that was fine. The defect was upstream of all of it, in the gap between the requirement and the operating conditions, and no gate we have examines that gap.
Going forward, when I write a feature’s design, I’m going to add a short section that states the operating condition the feature is used under, in concrete terms: how often, by whom, while what else is happening. Then I’ll check the feature’s enabling condition against that, and ask whether the feature is actually reachable under normal load rather than under the quiet conditions I imagine while writing the spec. For a control that an operator presses, “how often is this button enabled on a typical day?” is a question I should be able to answer before anyone builds it.
I’d also like to be more suspicious of refusal-and-retry designs in general. A refusal is only a good answer when the condition being refused is rare. If it’s common, refusing is just a slower way of saying the feature doesn’t exist, and I should be looking for a design that produces a usable result from the state the system is actually in.
The design has been updated and the controller and client work to align with it is tracked. Thanks to the operator who hit this and reported it clearly rather than assuming it was intended.