Repository navigation
Cancel superseded pull request runs, and guard that they stay cancelled - #11345
Conversation
runner-pool-probe.yml carried no concurrency block at all. It is triggered by pull_request and fans out to a ten-runner matrix, four of them macOS at 10x the minute rate, so a second push to the same pull request left a full ten-runner matrix measuring a commit nobody will merge. Superseding does not weaken what the probe measures. It compares labels within one dispatch, the ten cells leaving the queue in the same second, so a cancelled older matrix takes a whole self-contained measurement with it rather than half of the current one. Two dispatches were never comparable to each other anyway, because the queue they sampled is not the same queue. The guard is the reason this is more than a three-line fix. test_main_runs_survive_merge_bursts.py already covers the neighbouring question and stops short of this one in two ways. Its scan starts from push: branches: [main], so a workflow triggered only by pull_request is outside it entirely, which is how runner-pool-probe.yml reached main with no block. And it asks whether two commits on a pull request share a group, which is necessary and not sufficient: GitHub discards a pending run when a newer one takes its group, but a run that has already started is only cancelled when cancel-in-progress is truthy, and the started run is the one holding the runners. tests/studio/test_pull_requests_cancel_superseded_runs.py asks the remaining half of every pull-request-triggered workflow: rendered on a pull request ref, does cancel-in-progress evaluate true. Rendered rather than grepped, because the repo's usual form and its reversal are the same tokens in the same order and mean the opposite; the evaluator refuses to guess and a refusal fails loudly. It also asserts the other direction, that a workflow which pushes to main does not cancel there, so fixing this half cannot re-create the merge-burst incident on the way past. The two Kaggle workflows stay exempt with the reason restated in the file: cancelling the runner cannot stop a kernel it has already pushed, and an orphaned kernel bills quota with nobody left to read the result. It runs from workflow-trigger-lint.yml, the one job with no paths filter, because a pull request that edits only a workflow collects no other test that reads one.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 16fb93eb0b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| missing block is not a mis-evaluated expression, and runner-pool-probe.yml reached main | ||
| as one. | ||
| """ | ||
| offenders = sorted(name for name, document in _scanned().items() if not _group(document)) |
There was a problem hiding this comment.
Require pull-request runs to share a concurrency group
For a pull-request-only workflow, group: ${{ github.sha }} together with cancel-in-progress: true passes this assertion and every other test in this file, but each synchronized commit enters a different group, so GitHub never cancels the superseded run. The existing test_a_pull_request_still_gets_latest_only cannot catch this because it scans only workflows that also push to main; render the group for two SHAs across every workflow in _scanned() and require the results to match.
Useful? React with 👍 / 👎.
unslothai#11345 landed tests/studio/test_pull_requests_cancel_superseded_runs.py with one assert the ruff-format-with-kwargs hook rewrites, so main is not a fixed point of its own formatter. That fails tests/test_formatter_fixed_point.py, which is in the "Repo tests (CPU, rest)" shard, and it fails pre-commit.ci on every pull request, since pre-commit.ci runs the hook over all files and reports that it modified one. Neither failure has anything to do with the pull request that sees it. Ran the hook over the file with the pinned ruff (0.6.9, from the hook's own additional_dependencies) and committed what it produced. The file's own eight tests still pass, tests/test_formatter_fixed_point.py goes from 1 failed / 10 passed to 11 passed, and pre-commit run --all-files passes all three hooks.
unslothai#11347) * Correct why a superseded probe matrix is expensive: slots, not minutes The comment unslothai#11345 landed on runner-pool-probe.yml justified cancelling by "four of them macOS at 10x the minute rate". That rate is real but it is not what this costs. These repositories are public, standard GitHub-hosted runners are free for public repositories, and every label in the probe's matrix is a standard runner, so the account's included-minutes meter reads 0 of 3,000 used and will keep reading zero no matter what this workflow does. The 3,000 included minutes apply to private repositories. The real cost is concurrency. Four of the probe's ten cells are macOS, and GitHub caps macOS at five concurrent jobs ACCOUNT-WIDE across every repository -- the same cap test_macos_slots_per_commit.py already exists to protect, and the reason it records median macOS queue waits of 245 minutes. A superseded matrix was holding four of those five slots for up to ten minutes, and the queue it delays belongs to the whole account rather than to this workflow. So the fix is unchanged and the argument for it is stronger. Only the reason is corrected, here and in the guard's docstring, because this repo already treats a workflow comment that claims something untrue as a defect worth a test: see test_no_workflow_claims_a_main_protection_it_does_not_have, written after 27 files carried a comment asserting a protection they did not have. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Give the probe's cost claim a measured number, and guard it * Judge the duration claim per occurrence, not per sentence * Read the occupancy unit off the hold claim itself * Parse what governs a duration, and check the claim against its own measurement * Check every occupancy claim, and let a hung cell say it holds * Recognise the duration's form, then parse it, and fail when it cannot be read * Take the hung-cell exemption on a positive qualifier only * Cover the past tense, and refuse a qualifier that covers one holder of several * Say what cancelling actually saves, and read a number spelled across words * Take the yardstick from the claim's own sentence, and the excuse from its own clause * Read the other slot-taking verbs, and refuse a denied hang as an excuse * Make the third guard demand a positive explanation too * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Replace the prose parser with two mechanical rules * The cells enter the queue together; when they leave is the measurement * A hyphen is a separator, so ten-minute is ten minutes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…ed (unslothai#11345) runner-pool-probe.yml carried no concurrency block at all. It is triggered by pull_request and fans out to a ten-runner matrix, four of them macOS at 10x the minute rate, so a second push to the same pull request left a full ten-runner matrix measuring a commit nobody will merge. Superseding does not weaken what the probe measures. It compares labels within one dispatch, the ten cells leaving the queue in the same second, so a cancelled older matrix takes a whole self-contained measurement with it rather than half of the current one. Two dispatches were never comparable to each other anyway, because the queue they sampled is not the same queue. The guard is the reason this is more than a three-line fix. test_main_runs_survive_merge_bursts.py already covers the neighbouring question and stops short of this one in two ways. Its scan starts from push: branches: [main], so a workflow triggered only by pull_request is outside it entirely, which is how runner-pool-probe.yml reached main with no block. And it asks whether two commits on a pull request share a group, which is necessary and not sufficient: GitHub discards a pending run when a newer one takes its group, but a run that has already started is only cancelled when cancel-in-progress is truthy, and the started run is the one holding the runners. tests/studio/test_pull_requests_cancel_superseded_runs.py asks the remaining half of every pull-request-triggered workflow: rendered on a pull request ref, does cancel-in-progress evaluate true. Rendered rather than grepped, because the repo's usual form and its reversal are the same tokens in the same order and mean the opposite; the evaluator refuses to guess and a refusal fails loudly. It also asserts the other direction, that a workflow which pushes to main does not cancel there, so fixing this half cannot re-create the merge-burst incident on the way past. The two Kaggle workflows stay exempt with the reason restated in the file: cancelling the runner cannot stop a kernel it has already pushed, and an orphaned kernel bills quota with nobody left to read the result. It runs from workflow-trigger-lint.yml, the one job with no paths filter, because a pull request that edits only a workflow collects no other test that reads one.
unslothai#11345 landed tests/studio/test_pull_requests_cancel_superseded_runs.py with one assert the ruff-format-with-kwargs hook rewrites, so main is not a fixed point of its own formatter. That fails tests/test_formatter_fixed_point.py, which is in the "Repo tests (CPU, rest)" shard, and it fails pre-commit.ci on every pull request, since pre-commit.ci runs the hook over all files and reports that it modified one. Neither failure has anything to do with the pull request that sees it. Ran the hook over the file with the pinned ruff (0.6.9, from the hook's own additional_dependencies) and committed what it produced. The file's own eight tests still pass, tests/test_formatter_fixed_point.py goes from 1 failed / 10 passed to 11 passed, and pre-commit run --all-files passes all three hooks.
unslothai#11347) * Correct why a superseded probe matrix is expensive: slots, not minutes The comment unslothai#11345 landed on runner-pool-probe.yml justified cancelling by "four of them macOS at 10x the minute rate". That rate is real but it is not what this costs. These repositories are public, standard GitHub-hosted runners are free for public repositories, and every label in the probe's matrix is a standard runner, so the account's included-minutes meter reads 0 of 3,000 used and will keep reading zero no matter what this workflow does. The 3,000 included minutes apply to private repositories. The real cost is concurrency. Four of the probe's ten cells are macOS, and GitHub caps macOS at five concurrent jobs ACCOUNT-WIDE across every repository -- the same cap test_macos_slots_per_commit.py already exists to protect, and the reason it records median macOS queue waits of 245 minutes. A superseded matrix was holding four of those five slots for up to ten minutes, and the queue it delays belongs to the whole account rather than to this workflow. So the fix is unchanged and the argument for it is stronger. Only the reason is corrected, here and in the guard's docstring, because this repo already treats a workflow comment that claims something untrue as a defect worth a test: see test_no_workflow_claims_a_main_protection_it_does_not_have, written after 27 files carried a comment asserting a protection they did not have. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Give the probe's cost claim a measured number, and guard it * Judge the duration claim per occurrence, not per sentence * Read the occupancy unit off the hold claim itself * Parse what governs a duration, and check the claim against its own measurement * Check every occupancy claim, and let a hung cell say it holds * Recognise the duration's form, then parse it, and fail when it cannot be read * Take the hung-cell exemption on a positive qualifier only * Cover the past tense, and refuse a qualifier that covers one holder of several * Say what cancelling actually saves, and read a number spelled across words * Take the yardstick from the claim's own sentence, and the excuse from its own clause * Read the other slot-taking verbs, and refuse a denied hang as an excuse * Make the third guard demand a positive explanation too * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Replace the prose parser with two mechanical rules * The cells enter the queue together; when they leave is the measurement * A hyphen is a separator, so ten-minute is ten minutes --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
What this fixes
runner-pool-probe.ymlcarried noconcurrency:block at all. It is triggered bypull_requestand fans out to a ten-runner matrix, four of them macOS at 10x the minute rate, so a second push to the same pull request left a full ten-runner matrix measuring a commit nobody will merge.Superseding does not weaken what the probe measures. It compares labels within one dispatch, the ten cells leaving the queue in the same second, so a cancelled older matrix takes a whole self-contained measurement with it rather than half of the current one. Two dispatches were never comparable to each other anyway, because the queue they sampled is not the same queue.
Why this is more than a three-line fix
I audited all 57 workflows here. 43 of the 46 pull-request-triggered ones already cancel correctly, and the two Kaggle exemptions are deliberate and documented. The probe was the only real gap. The question is why nothing caught it.
tests/studio/test_main_runs_survive_merge_bursts.pycovers the neighbouring question and stops short of this one in two ways:push: branches: [main]. A workflow triggered only bypull_requestis outside it entirely, which is howrunner-pool-probe.ymlreached main with no block.cancel-in-progressis truthy, and the started run is the one holding the runners.The guard
tests/studio/test_pull_requests_cancel_superseded_runs.pyasks the remaining half of every pull-request-triggered workflow: rendered on a pull request ref, doescancel-in-progressevaluate true?Rendered rather than grepped.
${{ github.ref != 'refs/heads/main' }}and${{ github.ref == 'refs/heads/main' }}are the same tokens in the same order and mean the opposite, so a substring test calls them both fine. The evaluator refuses to guess, andtest_every_cancel_expression_is_understoodmakes a refusal fail loudly rather than skip.It also asserts the other direction.
test_cancelling_is_still_gated_off_mainrequires that a workflow which pushes to main does not cancel there, so fixing this half cannot re-create the merge-burst incident on the way past.The two Kaggle workflows stay exempt, with the reason restated at the exemption rather than only at their own
concurrency:block: cancelling the runner cannot stop a kernel it has already pushed, and an orphaned kernel bills quota to its own ceiling with nobody left to read the result.It runs from
workflow-trigger-lint.yml, the one job with no paths filter, because a pull request that edits only a workflow collects no other test that reads one.test_this_guard_runs_on_a_workflow_only_pull_requestkeeps it there.Verification
Negative control, with the
runner-pool-probe.ymlfix stashed:The existing workflow-policing guards are unaffected:
Not in scope
unslothai/unsloth-zoohas the same shape and no gap: three of its four pull-request workflows cancel, andgemma4-audio-probe.ymldeclines deliberately because it istypes: [labeled]only and concurrency is claimed before the job-levelif.unslothai/notebooksis clean.unslothai/llama.cpphas one instance of this defect inunsloth-pr-set-lint.yml; its heavyweight upstream workflows all carry upstream's owncancel-in-progress: true.