Skip to content

ci: a run on main is never superseded, so main is actually measured - #663

Merged
GoKubar merged 1 commit into
mainfrom
ci/main-runs-finish-fable
Sep 15, 2026
Merged

GoKubar merged 1 commit into
mainfrom
ci/main-runs-finish-fable

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

Fourth PR off the red-CI investigation (#659 evidence capture, #660 snapshot gating, #661 timing budgets). This one is the answer to why nobody noticed.

One correction up front, because it changes the fix

The suggested shape was a unique group on main plus cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}. The second half is not needed, and assuming it was the cause would have left the bug in place: cancel-in-progress was never cancelling main. It already reads ${{ github.event_name == 'pull_request' }}, which is false for a push.

The cancellations come from the group key instead. GitHub holds at most one in-progress and one pending run per concurrency group, and cancels the pending one whenever a newer run joins. The key was ci-${{ github.workflow }}-${{ github.ref }} — identical for every push to main. With a mac job that queues for hours on the shared macOS pool and a merge cadence measured in minutes, every merge cancelled the run queued behind the one in progress.

So the fix is to the key alone, and cancel-in-progress is left exactly as it was.

The evidence

Last 40 CI runs on main:

conclusion runs
cancelled 37
failure 1
still running 2

That single failure is run 35022802823 — the one that exposed 35 test failures across 19 cases. It is the only run on main that has reported anything at all.

Looking inside the cancelled ones:

  • 35014851080, 35011692452, 35006167649 — zero jobs ever created. Superseded while still pending; CI did literally nothing for those commits.
  • 35002918548 — 21 jobs queued at 17:44:49, cancelled at 21:06. It held pool slots for 3h20m and reported nothing.

Main's mac health was not red-and-ignored. It was never measured. #490 made a failing swift test able to fail the job; this is why the job so rarely got to run.

The change

main gets a group of its own per run; every other ref keeps the ref key and still collapses onto its newest push.

group: ci-${{ github.workflow }}-${{ github.ref }}${{ github.ref == 'refs/heads/main' && format('-{0}', github.run_id) || '' }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}   # unchanged

perf.yml had the same key and the same, milder symptom — 2 of its last 15 main runs cancelled — and gets the same treatment.

Checked and deliberately not changed, since you asked me to look beyond ci.yml:

  • release.yml — keyed per version/tag (release-<version|ref_name>) with cancel-in-progress: false. Distinct releases never share a key, so there is nothing to supersede. Correct as-is.
  • site.yml — constant publish-website group, cancel-in-progress: false. This is the superseding behaviour, and for a publish it is right: the latest content should win and intermediate publishes should be skipped. Correct as-is.

The cost, stated rather than discovered

Runs on main no longer supersede each other, so a burst of merges is a burst of concurrent macOS jobs. Each run asks for 11 macOS jobs (mac-app, ipad, and nine rust <crate> (macos-15) cells). On a pool that has already been starved once today — 76 queued runs stalling a release for an hour — that is a material risk, and I think it is worth taking:

  • The status quo already consumes the pool. 35002918548 occupied 21 job slots for 3h20m and was then cancelled. We are largely paying for these jobs today and throwing the result away.
  • The alternative — serialising main behind one constant group with cancel-in-progress: false — is exactly the configuration that is failing now. It bounds concurrency to one, and the price is precisely the 37 cancelled runs above.
  • A required check that cannot report is worse than an expensive one. Every PR in the project is blocked behind this signal.

If the pool does become the binding constraint, the lever to reach for is the nine rust <crate> (macos-15) cells — ~9 of the 11 macOS jobs per run, duplicating coverage the ubuntu-latest cells already provide. Dropping or scheduling those on main pushes would cut macOS demand by roughly 80% while keeping mac-app and ipad, which are the jobs that can only run on macOS. I have deliberately not done that here: it is a coverage decision, it belongs in its own reviewable change, and this PR should stay a one-expression fix that is trivial to revert. Restoring the cancellation is the wrong lever — it buys runner time by discarding the signal.

Documentation

docs/ci-cd.md gains a short section recording all three distinct ways this gate reported success it had not earned, so the next person does not re-derive them:

  1. Swallowed failures — swift test | tail meant the step's status came from tail; no number of failures could fail the job (fixed by ci: pipefail, so a failing swift test can actually fail the mac job #490, which immediately exposed 35).
  2. Truncated logs — the printed output is filtered and tailed to 400 lines; the complete output is the mac-swift-test-log artifact.
  3. Cancelled runs — this PR.

It also records the cost and the mitigation lever above, at the point someone would look for them.

Verification

Both workflow files parse as valid YAML. The behavioural change is observable immediately after merge: runs on main stop showing cancelled and start producing mac results — which, until #660 and #661 land, will be honestly red.

Implementation-Agent: claude-fable-5 (Claude Code subagent, linux-primary)

A parallel triage found main's CI runs are almost all `cancelled`. The data:
37 of the last 40 runs on main ended cancelled, one failed, and that one
failure is the run that exposed 35 test failures across 19 cases. Main's mac
health has not been red-and-ignored -- it has been unmeasured.

The mechanism is not `cancel-in-progress`, which already evaluates to false
for a push. It is the concurrency group key. GitHub holds at most one
in-progress and one PENDING run per group and cancels the pending one when a
newer run joins, and the key was the ref -- shared by every push to main. With
a mac job that queues for hours on the shared macOS pool and a merge cadence
in minutes, each push cancelled the run queued behind the one in progress.
Several never created a single job; one sat queued for 3h20m and was then
cancelled, having reported nothing.

So main gets a group per run and everything else keeps the ref key, still
collapsing onto its newest push. perf.yml had the same key and the same
(milder) symptom: 2 of its last 15 main runs cancelled.

Checked and deliberately unchanged: release.yml is keyed per version/tag, so
distinct releases never collide; site.yml's constant `publish-website` group
is correct for a publish, where the latest should win and intermediate
publishes should be skipped.

The cost is real and is written down in docs/ci-cd.md rather than discovered:
main runs no longer supersede each other, so a burst of merges is a burst of
concurrent macOS jobs on a pool that has already been starved once. If the
pool binds, the lever is the nine `rust <crate> (macos-15)` cells that
duplicate the ubuntu ones -- not restoring the cancellation, which buys
runner time by discarding the signal.

The same doc now lists all three ways this gate reported success it had not
earned -- swallowed failures, truncated logs, cancelled runs -- so the next
person does not have to re-derive them.

Implementation-Agent: claude-fable-5 (Claude Code subagent, linux-primary)
Commit-Executor: claude-fable-5 (direct; Cursor usage limit)
Co-authored-by: GoKubar <[email protected]>
@GoKubar
GoKubar merged commit c8e002d into main Sep 15, 2026
18 of 22 checks passed
@GoKubar
GoKubar deleted the ci/main-runs-finish-fable branch September 16, 2026 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant