ci: reclaim macOS slots held by runs whose ci-status is already decided
macOS CI concurrency on Blacksmith is roughly ten slots, and a 36-deep macOS queue was observed against it (#13707). A run whose verdict is already decided keeps holding those slots until it finishes or times out.
This is structural, not statistical. ci-status in ci.yml declares needs: [changes, static-preflight, guards, ghosttykit-release-check, cli, web, linux-preflight, macos-debounce, macos, tests] with if: ${{ always() }}, and accepts only success or skipped from each. An app-host unit tests shard concluding failure therefore fails the macos reusable-workflow call and the required check by construction — no later job can take it back. A census of the 299 CI runs created between 2026-09-22T06:05Z and 17:00Z confirms the construction behaves as written: 21 runs had such a shard failure, ci-status concluded failure in all 21, and their sibling macOS jobs burned 1,522 macOS runner-minutes after the verdict was already fixed. One run held four macOS jobs for 353 of them.
Resulting behavior
This lands as a fourth category in scripts/ci/queue_janitor.py (#13721), not as a second janitor. A run is doomed when an app-host unit tests shard has concluded failure while the run still holds macOS jobs. Cancelling it makes ci-status report the failure it was already headed for rather than leaving it pending — verified on cancelled runs 35446690615 and 35445456570, where ci-status completed as failure.
Why the queue janitor and not ci-stale-run-janitor
Reclaiming macOS pool capacity is exactly the queue janitor's charter; ci-stale-run-janitor is about runs abandoned for a day or more, and this rule has nothing to do with age — an earlier draft had to bypass its MIN_AGE_MINUTES entirely, which was the tell. Putting it here means one queue threshold, one priority order, one per-sweep cancel cap and one concurrency group, instead of two workflows holding actions: write with no shared bound and no shared notion of when cancelling is allowed.
The threshold gate is also the right policy on its own terms, not just an inherited constraint: cancelling a doomed run while the pool is idle frees nothing anybody is waiting for and still destroys the remaining shard output. The rule should only fire under contention, which is what CI_JANITOR_QUEUE_THRESHOLD already expresses.
This changes the dry-run posture, deliberately. The queue janitor's scheduled sweeps cancel for real unless vars.CI_JANITOR_DRY_RUN is true; a manual dispatch defaults to a dry run. Shipping a report-only category inside a module whose merged policy is to act would be incoherent, so this category inherits that posture. What bounds it instead is the queue threshold, the per-sweep cap, the ordering below, the repo-variable kill switch, and the exclusions.
Ordered last, and why it needs an exclusion the others do not
Categories (a)–(c) cancel runs nobody will read: an exp/* experiment push, a closed/merged/superseded PR, a full-suite run already replaced by a newer one. A doomed run is different — it is still current, its PR is open, and its remaining shards are still readable output. That makes it the most debatable of the four, so it is spent only after the others, and it carries a fix-branch exclusion:
| Preserved | Why |
|---|---|
| A run repairing the failing job | Its remaining shards are the result someone is waiting on. A PR whose diff touches the shards' own inputs — cmuxTests/, the shard/isolation/compile/grading scripts under scripts/ci/, the known-failure quarantine list, ci-macos.yml — is never cancelled. |
| A fix living entirely in product code | The no-janitor label. Sources/ is deliberately not in the path list: the suite exercises it, but nearly every PR changes it, and a set matching every PR is not a rule. |
continue-on-error failures | The rule reads job conclusions, not step conclusions, and a job whose only failed steps tolerate failure concludes success. A test pins the absence of a job-level continue-on-error on app-host-unit-tests, which the conclusion would not absorb. |
| Re-runs, other workflows, unreadable diffs, undated failures | A re-run replays a subset of jobs, so an older attempt's failure says nothing about this one. An unreadable diff is not evidence that the run is not the fix. A 10-minute grace also keeps the janitor off a run that just turned red. |
Default-branch pushes, merge groups, releases, tags, nightly and TestFlight were already protected by protected_reason; the doomed branch inherits that unchanged.
I checked whether #13721's existing categories need the same exclusion. They do not, and I found no defect: (b) requires the PR to be closed, merged, or superseded by a newer head, and (c) requires a newer CI run already waiting to replace the old one. In every case the result is already unwanted or already being recomputed, so there is no fix-branch to protect. The doomed category is the only one that acts on a live, current run.
One narrowing worth stating: this uses the module's existing is_macos_job (label contains macos) rather than adding tart/m4pro markers. Across every job in the census, the macOS runner labels are blacksmith-6vcpu-macos-15/26 and warp-macos-15/26-arm64 — all matched — and no tart or m4pro label appears at all. Keeping one definition of macOS demand in the module is worth more than markers that match nothing.
Validation
RUNNER_TEMP=/tmp/rt python3 tests/test_ci_queue_janitor.py — 51 tests, all passing (33 pre-existing, 18 new). The pre-existing 33 pass unchanged except for threading the new now argument through two call sites. New coverage: the verified class is doomed; no macOS job left to reclaim is kept; macOS jobs held without a shard failure are kept; a continue-on-error step failure is kept; a fix-branch diff is kept over seven real repair paths; an unreadable or truncated diff, an undated failure, a missing run_attempt and a re-run all fail closed; no-janitor is honoured; earlier categories still win on a closed or superseded PR; and two plan-level tests prove the category is spent last under the shared cap and does not fire below the queue threshold.
Also green: test_ci_workflow_guards_are_wired.py, test_ci_guard_workflow_structure.py (4 passed), test_ci_actionlint_covers_every_workflow.py, and scripts/ci/validate_test_execution_registry.py (223 tests registered — the drift I saw earlier was fixed upstream by #13738).
Live dry run through the real entry point, read-only, 2026-09-22:
$ python3 scripts/ci/queue_janitor.py --dry-run
## CI queue janitor (dry run)
Queued macOS jobs: **8** (threshold 6); running macOS jobs: 13.
No wasteful macOS demand found.
_57 in-flight runs, 14 job listings, 8 PR branches, 18 API calls._
Re-run with --threshold 0 to remove the gate and surface every candidate: still no candidates in any category, doomed included. No live run currently has a failed app-host shard, and #13721 is live and has already been sweeping.
Replayed against real data. The merged classify() with the new category, run read-only over the API payloads of the 21 real CI runs whose app-host shard failed, with every job rewound to the state the API reported 10 minutes after the first failure:
CATEGORY 'doomed' (2):
35735126941 PR#13222 -> `macos / app-host unit tests (4/6)` failed 10m ago, 3 macOS job(s) still held
35736282926 PR#13218 -> `macos / app-host unit tests (3/6)` failed 10m ago, 5 macOS job(s) still held
KEPT (19): 11 repair the failing job -- PR #13643 (fix/app-host-green and three
sibling branches), #13579, #13427, #13414, #13615, #13574, #13263, #13271 --
and 8 have no single open PR for the commit, so the diff cannot be read.
The exclusion is not hypothetical. Run 35738641571 on ci-6134-isolate-ssh-fish-hang was cancelled by hand while this was being designed. It is PR #13408, whose only changed file is cmuxTests/WorkspaceSSHFishShellTests.swift — a fix for "Run SSH fish foreground-auth hang regression", one of the very app-host steps that was failing. The run had to be restarted. That path is now a test case. It is also why the diff test is preferred over a [no-janitor] marker alone: the person fixing a red suite is the least likely to remember a marker.
Considered and rejected: the Linux guard class
A second class was investigated — a run where a Linux guard job (guards / *, Guard status, linux-preflight) failed while macOS jobs are still running. It is structurally sound and larger than the class that ships, and it does not ship. Over the same 299 runs: 66 had a failed Linux guard job, ci-status concluded failure in 66 of 66, and 1,316 macOS runner-minutes sat behind the decided verdict.
Re-run rate is fine. 0 of the 66 guard-failure commits ever got a second CI attempt (15 of 967 runs in the surrounding window are re-runs at all). Guard failures are not routinely re-run as flakes.
The disqualifier is that it cancels in-flight macOS compiles. Linux guards are cheap and fail fast, so they fail while macos-compile-admission is still compiling. At the decision point — first guard failure plus the 10-minute grace — compile admission had already succeeded in 0 of the runs with anything to reclaim, and 1,316 of the 1,316 reclaimable minutes (100%) sat in runs still compiling.
How to read that number. Throughout the measurement window #13709 was open and cross-run compiled-product reuse returned zero hits on pull requests, so those compiles produced nothing another run would consume. #13718 merged at 2026-09-22T17:40Z (3f3e6038) and closed #13709, so reuse is now expected to hit and cancelling mid-compile-admission discards a product other runs would consume. The rule would move a compile onto whoever needs it next rather than save capacity.
Notably #13721 reached the same conclusion independently: its category (c) already refuses to cancel a run whose compile admission is mid-flight, for the same reason. The narrowing that would follow from it — cancel only once compile admission has succeeded — reclaims 0 runs and 0 minutes, because by then the guards have long since concluded. There is no safe subset, so the class is dropped rather than shipped narrow.
The class that ships has no such problem: app-host-unit-tests needs macos-compile-admission to have concluded success, so the compile is finished and published before any shard can fail. Confirmed in 21 of 21 runs in this class.
Remaining gap
The guard class stays unaddressed and it is the larger one. Reclaiming it needs a mechanism this janitor does not have — letting the macOS compile finish and publish while cancelling only the test shards behind it, which the Actions API cannot express as a single run cancellation. That is a separate change, and now that #13718 has landed it should be designed against reuse actually working.
The whole census also predates #13718, so it measures a world in which no pull-request run reused a compiled product. Once reuse starts hitting, macOS job durations and the mix of jobs still running at a shard failure both change, and the 1,522-minute figure should be re-measured. No REUSE_HIT=true has been observed in production yet, so that should wait until one is.
Finally, the rule is by design quiet: it fires only under queue pressure, only after three other categories, and never on a run that is fixing the suite. A predicate that rarely fires is the right trade against one that cancels the run someone is using to make CI green.
🤖 Generated with Claude Code
Summary by CodeRabbit
- CI Improvements
- CI cleanup now cancels obsolete runs associated with closed, merged, or superseded pull requests.
- Added handling for CI runs that are unlikely to succeed after an aged
app-host unit testsfailure, when the relevant code has not changed. - Preserves reruns, opted-out pull requests, incomplete failure data, and runs affecting the failed test shard.
- Cancellation decisions now follow a consistent priority order.