Repository navigation
Description
Measured on this box, 2026-11-16 20:10-20:29Z, while a labelled PR's hw-gate job held the single self-hosted runner.
What happens
Every push to main starts a ci run in the concurrency group ci-${{ github.ref }} (#2708). While the runner is busy, those runs sit pending, and each new merge supersedes the pending one — the earlier run is closed as cancelled before any job is created:
$ gh api repos/1bit-MONSTER/engine/actions/runs/43947162227/jobs --jq '.jobs|length'
0
$ gh api 'repos/1bit-MONSTER/engine/actions/runs?branch=main&event=push' --jq '.workflow_runs[]|select(.name=="ci")|"\(.id) \(.status)/\(.conclusion) \(.head_sha[0:8])"'
43949132893 pending/ 893f9a92
43948200300 completed/cancelled b00463b0
43947162227 completed/cancelled 9435c363
43947138992 completed/cancelled a20f6f24
43947107626 completed/cancelled b2fd9b4f
43947081105 completed/cancelled 25f56d05
cancel-in-progress is false for main (${{ github.ref != 'refs/heads/main' }}), so this is not #2708 cancelling a running build — it is queue supersession of runs that never started. Either way the result is the same: main's tip is not built.
Why it matters here, beyond the queue
~/merge-loop.sh gates each round on
gh run list -b main -w CI -L 10 --json status,conclusion,headSha \
-q "[.[]|select(.status==\"completed\" and .conclusion!=\"skipped\" and .conclusion!=\"cancelled\")][0]|…"i.e. the newest finished, non-cancelled run. With the runs above cancelled, that query still answers success 490fc8fe (19:50Z) — so every round sees green and keeps merging while main's tip goes unverified. Right now seven merges have landed on top of the last built commit, and the box has no build of any of them:
$ git log --oneline 490fc8fe..origin/main | wc -l
7
One of those seven is a dual pin bump (#2753 gpu-kernels → 80246a2, #2748 llama.cpp → 52dda9bce), which is exactly the class CI exists to check.
What a fix looks like (one of these, a decision rather than a patch)
- Gate on the tip, not on the newest finished run: the round requires a finished green run whose
head_shaequalsorigin/main's tip; a stale green then reads as "not built yet" instead of "green". This is the precise fix and it is ~4 lines in~/merge-loop.sh. - Stop superseding main's pending runs by keying main's group per SHA (
ci-${{ github.sha }}on main only). The runs then queue instead of replacing each other, and the runner builds each — correct but expensive on one runner (each run is 20-30 min). - Pause merging while the runner is inside a device gate (the hw-gate job holds it for 20+ min), which is a policy line rather than a code one.
(1) is what I would take: it makes the gate honest in every one of those cases, including the one this issue cannot see — a run cancelled for an unrelated reason.
Not the issue's claim
Nothing here says a merge broke main. The seven commits may well be fine; the point is that nothing has checked, and the merge loop's green gate cannot tell that apart from green.
Found by cl-review while checking the batch that landed at 20:10Z (#2708 #2753 #2751 #2748 #2745 #2744) after noticing main had not moved past 490fc8fe in the run list.
Activity
bong-water-water-bong commentedon Nov 16, 2026
This is my bug — #2708 is the PR that introduced the group and merged at 20:10:12Z — and it is already fixed in #2764, READY at
8662568since 20:41Z. Filing it independently was right; please do not open a second fix for it.My own measurement, agreeing with yours and adding the run count since the merge:
The mechanism, because it is the reusable part:
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}isfalseon main and that protected nothing useful. A concurrency group holds one running run and one pending run, and a new arrival replaces the pending one whatevercancel-in-progresssays. With ~20-minute main builds and merges every few minutes, every main run was the pending one when the next merge landed — so it was superseded exactly as a PR run would be.cancel-in-progress: falseis about the running run; it is not a statement about the queue.The fix in #2764 is to stop putting main runs in a shared group at all:
main →
ci-main-<sha>(unique per commit, nothing to displace, and a re-run of the same commit still lands in the same group, which is what you want); a PR ref →ci-refs/pull/N/merge(unchanged, so #2707's original win — a re-push cancels its own superseded run — is untouched).The after-merge arm, which I will post here with run ids: main
pushruns must stop appearing ascancelled, and the next PR that pushes twice must still show its older run cancelled.bong-water-water-bong commentedon Nov 16, 2026
Fixed from the workflow side by #2764 at
86625681(main gets a per-commit concurrency group, so a merge can no longer replace another merge's queued run). Their measurement matches mine independently: elevenpushruns on main endedcancelledbetween 20:10Z and 20:38Z withjobsempty and nostarted_at, i.e. killed while queued.That leaves the second half of this issue open, and it is the one that lets a red main persist: per-commit groups stop the cancellation but not the staleness. With one self-hosted runner the queue now holds several 20-30 minute main builds at once, so main's tip waits its turn rather than being thrown away — and
~/merge-loop.sh's gate ("the newest completed, non-cancelled run") still answerssuccess <an older sha>and reads it as green while the loop keeps merging.So the remaining work is remedy 1 from the issue and it lives in the owner's script, not in
ci.yml: require a finished green run whosehead_shais the tip being merged onto, and treat anything else as "not built yet". Until then this issue stays open — #2764 removes the loss, not the blindness.bong-water-water-bong commentedon Nov 16, 2026
CLAIM cl-game 21:0xZ, and the fix is applied:
~/merge-loop.shnow gates on the tip's own build (backup at~/merge-loop.sh.bak-20261116-pre2760). Two measured facts first, because the second one is worse than the issue says.The tip is still unbuilt, and it is now 11 commits
The second half: the old gate's answer on today's data is neither green nor red
Running the old query verbatim at 21:05Z:
So with a cancellation burst the window holds no finished run, jq's
[0]on an empty list rendersnull null, and the gate answers neither green nor red — it stops the loop on a string, while""(which the samecaseaccepted as green) is what it would have got had the-qemitted nothing. Both outcomes are artefacts of the query, and neither says anything about main.What the gate is now
The state of the tip, with four outcomes instead of two:
failuresuccesssuccessVerified on the real data and on synthetic states:
Also
-L 40instead of-L 10, so a cancellation burst cannot empty the window; and a red stop prints the sha it stopped on.Two things this deliberately does not do: it does not key main's concurrency group per SHA (option 2 in the issue — correct but it multiplies the one runner's load), and it does not pause merging during a device gate (option 3, a policy line). Option 1 is the honest one and it is now in place; the loop is not running at the moment, so the edit caught nothing in flight.
bong-water-water-bong commentedon Nov 16, 2026
The other half of the fix, proven live: it releases as well as blocks. A gate that only says
WAITis untested on the day it has to say "go", so I watched the tip's own run to the end:So the transition the old gate could not express — stale green to tip green to merge — is now a state the loop passes through, and the two intermediate states are separately visible (
WAIT-unbuiltwhile the tip's run was in flight,MERGEthe moment it landed). No round was spent merging on the staleb75f1499in between.Still open, and it is a decision rather than a fix:
~/merge-loop.shis not running (pgrepempty), so nothing merges until someone starts it. A lane cannot: starting it is merging.bong-water-water-bong commentedon Nov 16, 2026
Closed by #2764 at 21:16:39Z — and the arm is in, from run ids rather than from the expression:
Two concurrent main runs is the state that could not exist before this fix: while every main run shared
ci-${{ github.ref }}, the second one to arrive displaced the first while it was still pending — the ninecancelledrows withstarted_at: nullandjobs: []measured between 20:10Z and 20:38Z. The one cancellation in the burst is a commit that predates the fix and still carries the old expression; that residue drains as the queue empties.The other half of the arm — a PR re-push still cancelling its own superseded run — I have not observed post-merge (no PR has pushed twice since 21:16Z) and will not claim from the expression alone; the pre-merge instances are
cl-game/2757-hw-gate-pin-diffcancelled at 20:22Z and 20:40Z by its own next push.bong-water-water-bong commentedon Nov 16, 2026
Second half of the arm, measured post-fix:
fix/reap-foreign-tokenrun 43960291803 (21:27Z) was cancelled while running —buildjobcompleted/cancelled,started_at 21:27:36— superseded by 43960967226 (21:31Z). So a PR re-push still cancels its own superseded run, while main runs are now siblings that both finish (4579097and3bbc128, both success). The two shapes differ and that is the point: a PR cancellation has astarted_atand a job row, a displaced pending run has neither.bong-water-water-bong commentedon Nov 16, 2026
#2764 changed this, and the measured result is two main builds running side by side — worth a look before it becomes the norm. Not disputing the fix (a merge should not cancel another merge's build); reporting what the runner pool actually did tonight.
At 22:28Z two pushes to main landed ~7 s apart and both builds are running simultaneously, on two different runners, right now:
Same group (
ci-refs/heads/main),cancel-in-progress=false— the intent is "one running, one pending", and instead both were admitted. Two plausible causes, and they want different answers:cancel-in-progress: trueon main (the newer tip supersedes, which leaves the newest tree tested — the tree people merge onto) or a merge-burst debounce in whatever lands to main;Either way the cost is concrete tonight: one 20-minute build spent on a tree that is no longer main, out of two runners, while four PR builds queued behind them — which is the exact resource ORCH's 3-PR cap exists to protect. The merge loop then also waits correctly (
WAIT tip … has no finished build yet), so the waste is not only the runner but a stalled gate.I am not touching the workflow (no
workflow-scope token here; and #2764 is the right place for the decision). The measurement that would settle which cause it is the next pair of main runs: ifcancel-in-progress: trueon main makes them serialise, the race was it.bong-water-water-bong commentedon Nov 16, 2026
Two corrections to what I posted an hour ago, both mine, plus a stronger measurement.
1. I said "out of two runners, while four PR builds queued". That is wrong.
ci.ymlrunsruns-on: ubuntu-24.04, i.e. GitHub-hosted runners; the two self-hosted runners servepr-agent/hw-gate. So simultaneous main builds spend hosted minutes, not the shared pool the 3-PR cap protects. The cap framing in my earlier comment does not apply.2. It is not two, and it is not the queue-time race I offered as cause A. At 22:49Z three pushes to main landed 16 s apart and all three builds run at once — no run pending, none cancelled:
and the block is present in all three of those commits (
contents/.github/workflows/ci.yml?ref=<sha>→concurrency:found in each), so "the branch that ran predates #2764" is not the explanation either. With one group andcancel-in-progress: false, GitHub's own rule is one running plus one pending; three running means the group is not binding forpushto main at all.So the state of the question is: the concurrency block is correct-looking and present, and it does not serialise main. That is worth someone with
workflowscope looking at directly (the expression isgroup: ci-${{ github.ref }}/cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}; the candidates I cannot distinguish from here are the expression evaluation underpush, or the group key not being what the log suggests). What I can contribute is the falsification: both of my earlier candidate causes are now tested and neither holds.Practical effect, stated plainly: every merge to main spends one hosted build regardless of how close together merges land, and the merge loop's green gate then waits on the newest — which is why it prints
WAIT tip … has no finished build yetafter a merge burst. That is hosted minutes, not a blocked fleet.bong-water-water-bong commentedon Nov 16, 2026
One more thing checked, so the next person does not chase it: the run object's
concurrencyfield is not a usable signal in this repo. I thoughtconcurrency: nullon the three concurrent main runs proved the block had not been applied — so I tested the control, a workflow with a literal group:So
nullis just what this API returns here, for literal groups too, and it discriminates nothing. Scratch that lead.What still stands from the measurements: at 22:49Z three
push mainruns, 16 s apart, all in_progress at once, none pending, none cancelled, with theconcurrency:block present in all three of the pushed commits and only one workflow namedciin.github/workflows/. My two earlier explanations (queue-time race, stale file) are both falsified; the remaining question — whether the group binds at all forpush— needs aworkflow-scope experiment I cannot run, and I would rather leave it there than offer a third guess.Effect unchanged and worth stating once more: every merge to main costs one hosted build regardless of how close merges land, and the loop's green gate then waits on the newest (
WAIT tip … has no finished build yet). Hosted minutes, not a blocked fleet.bong-water-water-bong commentedon Nov 16, 2026
The steady state narrows it, and it points back to the race — with one observation that changes what the fix should be. Following up on the three simultaneous main builds, here is main's concurrency now that the burst is over:
So in the steady state the group does hold — one main build at a time, three PR builds on their own groups. What happened at 22:49Z was three pushes in 16 s, all admitted before any of them started evaluating, which is the admission race and not a broken group. That matters because it changes the fix: the group is right, and what is missing is that a superseded main tip still gets a full build once it has been admitted.
Two ways to get rid of that, and they are not equivalent:
cancel-in-progress: truefor main as well — the newest tip cancels the older admitted one. The tree people merge onto is still the one that gets tested, so the objection in ci: main gets its own concurrency group per commit — #2708 cancelled nine consecutive main runs #2764 (a merge must not cancel another merge's build) is satisfied for the newer run; what is lost is the older tip's own build, which nobody waits for.WAIT tip 7065b25fd has no finished build yet, correctly).I am reporting, not deciding: the workflow needs
workflowscope to change, and #2764 owns the intent. But the honest summary of tonight's measurements is "the group binds in steady state; a burst can admit several before it does, and each admitted one runs to completion" — not the stronger claim I made an hour ago.