Skip to content

Let main's nightly CI run finish instead of cancelling it - #296

Merged
max-sixty merged 2 commits into
mainfrom
fix/main-ci-gate-starvation
Sep 5, 2026
Merged

max-sixty merged 2 commits into
mainfrom
fix/main-ci-gate-starvation

Conversation

@leaf-agent

@leaf-agent leaf-agent commented Sep 5, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Main's complete nightly suite takes 22–41 minutes, while commits reached main every 10 minutes at the median. With cancel-in-progress: true, each push cancelled the run in flight and its replacement was usually cancelled in turn: over the 44-hour history Tend measured, 39 of 56 main CI runs were cancelled and only 16 reached a verdict.

  • Keep one main CI run at a time, but let the running one finish.
  • Retain GitHub's default single pending slot, so a newer head replaces a superseded pending run rather than growing an unbounded queue.
  • Bound the complete test job at 105 minutes and lint at 15 minutes, including setup, so a pre-suite wedge cannot occupy the concurrency group for GitHub's six-hour default.

GitHub's concurrency contract documents this exact behavior: cancel-in-progress: false preserves the running member, while a new pending member still replaces the previous pending member. The useful post-merge measure is completed main verdicts per hour of merge activity; the cancellation share will remain nonzero because superseded pending runs are recorded as cancelled.

More completed red runs will also start tend-ci-fix more often. That is the intended reporting path; deduplicating those generated fix runs, if needed, belongs in Tend's generated workflow rather than this repository-local scheduling fix.

Verification

  • uv run pre-commit run --files .github/workflows/ci.yaml
  • PR lint and test checks

This was written by Codex on behalf of max-sixty

@leaf-agent leaf-agent left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing my own PR, so this is a COMMENT rather than a verdict. The flip itself looks right and the arithmetic behind it holds — re-pulling main's ci history independently, the most recent ~300 runs give 27 cancelled to 3 failure and no successes at all, so the starvation is real and this is the one knob that fixes it without giving up the one-run-at-a-time ceiling #179 asked for. Three things the description gets ahead of itself on; none of them blocks the flip.

The stated post-landing check is wrong. The body says cancellations "should fall to roughly the wedge-and-force-push cases", but the workflow comment in the same diff already says why they won't: GitHub cancels the superseded pending run, and that cancellation is a real run record with conclusion cancelled. At the body's own numbers — 25-minute runs under a 10-minute merge cadence — one to two pending runs are superseded per completed run, so the cancelled share falls from ~70% to maybe ~55%, not to near zero. Records of that shape are already in the history: main has a ci run created at 2026-09-05T05:25:16Z and cancelled nine seconds later. Anyone verifying against the criterion as written would read a still-cancellation-heavy history as "it didn't work". The measure that actually discriminates is ci runs on main reaching a success or failure conclusion per hour of merge activity: ~0.36/h today (16 verdicts over 44h), and it should land near 2/h.

A wedge now holds the group for up to six hours rather than ten minutes. ci.yaml puts timeout-minutes on the two suite steps only — neither the test job nor the lint job declares a job-level timeout-minutes, and the steps ahead of the suite are untimed: Install Chromium headless shell runs playwright install --with-deps chromium --only-shell, and lint is pre-commit/[email protected] with nothing around it. A hang in either rides GitHub's 360-minute job default. Under cancel-in-progress: true the next push cleared that within the 10-minute median; queueing means main can go six hours with no verdict while pending runs churn — the failure mode this PR exists to remove. The comment's claim that the flip "is also what makes the 90-minute step timeout below reachable" holds only for the steps that have a timeout. A job-level timeout-minutes on each of the two jobs closes it, and is the change I'd want alongside this one.

tend-ci-fix fires on every completed failure and has no concurrency group. It triggers on workflow_run for ci with conclusion == 'failure' on main. Today ~16 main runs reach a verdict per 44 hours; after this, about one per half hour of merge activity, at a failure rate the history puts near 80% (13 of 16). That is the intended consequence — main's red should be reported, and per running-tend a red ci on main is live — but it multiplies ci-fix sessions roughly fivefold, and with no concurrency group two sessions can work the same red main and open near-duplicate PRs. Most of main's failures are the read-before-ready class that skill describes, so the added sessions will skew toward flakes. Worth watching after this lands; tend-ci-fix.yaml is tend-generated, so the remedy is upstream rather than here.

@leaf-agent

Copy link
Copy Markdown
Collaborator Author

Actioning my own review as the PR author.

Post-landing check — the description was wrong and is now rewritten. Counting cancellations can't discriminate: superseded pending runs are recorded as cancelled too, so the share stays high and only changes shape. Today 35 of the 38 cancellations are in-flight kills (median 10 min) and only 3 are the sub-minute supersession shape; after this it should be the reverse. The criterion is now verdicts per hour of merge activity — 0.36/h today, ~2/h expected.

Job timeouts — landed in fe506048, and the description now covers them as part of the PR rather than as a follow-up.

tend-ci-fix volume — no change here; it's a consequence of letting main's failures be reported at all, and tend-ci-fix.yaml is tend-generated, so any remedy is upstream. Recorded in the description so it's visible at merge time rather than only in this review.

@max-sixty
max-sixty merged commit 0b9a8da into main Sep 5, 2026
3 checks passed
@max-sixty
max-sixty deleted the fix/main-ci-gate-starvation branch September 5, 2026 07:06
max-sixty added a commit that referenced this pull request Sep 17, 2026
The nightly-marked modules ran only on the daily cron, so a regression
in one of them could sit on main for up to a day. `nightly` now also
runs on a push to main, once `lint` and `test` are green, and its
failure fails the `ci` run that `tend-ci-fix` watches.

One automatic complete suite holds a runner at a time. A running suite
is never cancelled, and a newer commit replaces the pending entry, so a
busy main gets the suite on its tip rather than working through
superseded commits. A dispatch keeps a slot per ref, as it had before
this job took a group of its own: it is the base-SHA control `CLAUDE.md`
prescribes for judging a red branch, and behind main's queue the next
merge would replace it before it started.

Two consequences follow. A push to main no longer cancels the previous
push's run, because a red branch is judged against the base SHA's result
and with `nightly` in the run the next merge would end a complete suite
partway through. And the job's guard names the results that may proceed
rather than excluding `failure`, because a job killed by its own
`timeout-minutes` concludes `cancelled` — measured on `astral-sh/uv-dev`
job 103562310904, which ran 6h00m15s and concluded `cancelled` — and a
wedged everyday gate would otherwise send an hour of complete suite
after it.

## The cost this accepts

#296 shipped this same arrangement when the suite was 22-41 minutes, and
named the cost then: GitHub records a superseded pending entry as a
cancelled run, and `tend-ci-fix` acts on a cancellation as it does on a
failure. Confirmed here on run 35019690790, where `tend-mention`'s
`handle` job was cancelled after nine seconds with no runner assigned
and the run concluded `cancelled` alongside a successful `verify`. The
suite is 66-86 minutes now, so at the recent push cadence roughly 55-60%
of main's pushes would produce one, against a baseline of about 40%.

`running-tend` gains the field that separates the two cancelled shapes,
since a `nightly` that wedges to its own 135-minute bound also concludes
`cancelled` and is very much something to fix: a replaced entry never
started and so carries no runner, while a timed-out one holds one.

<details>
<summary>Verification</summary>

- `pre-commit run --all-files` clean, actionlint included.
- 548 passed across `test_interact_layer.py`,
`test_interact_document.py`, `test_interact_product.py` and
`test_interact_session.py` — the modules whose tests read `ci.yaml`
against `CLAUDE.md`.
- The `if` was walked against real runs for each trigger: run
35087200567 confirms `lint` and `test` both conclude `skipped` on the
schedule, which is what the `success`-or-`skipped` guard admits.

</details>

> _This was written by Claude Code on behalf of max-sixty_

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.

2 participants