Repository navigation
ci: collapse superseded main-push runs without cancelling the running one - #23069
Conversation
… one
At 14:20-14:52Z on 2026-10-21 the prod deploy job waited ~30 min for a
runner: five main merges in a few minutes each started the full Desktop,
Mobile, Repo, Backend and E2E sets, and every run on an older main SHA was
superseded and wasted.
Heavy main-push workflows now share one ref-keyed concurrency group per
workflow with `cancel-in-progress: ${{ github.event_name == 'pull_request' }}`.
PR pushes still supersede that PR's older run. On main the running run
finishes and GitHub replaces only the pending run, so a merge burst costs
one running + one newest-pending run per workflow and the newest main SHA
always gets a complete run.
- backend-checks, desktop-checks, web-checks, repo-checks: an unconditional
`cancel-in-progress: true` let a newer main merge cancel the running
run; it is now conditional on pull_request.
- backend-unit-tests, backend-hermetic-e2e, mobile-app-checks: the non-PR
group fallback was `run-{run_id}`, which gave every main push its own
group so superseded suites all ran; it is now `github.ref`.
- python-cli-ci: had no concurrency; adds the same shape.
- desktop-swift-ci: unchanged. Its per-SHA main keying is load-bearing
(plan-desktop-release.py requires exact-SHA checks) and its
cancel-in-progress is already conditional.
- CodeQL is GitHub default setup (weekly schedule, no workflow file);
nothing to edit.
Push path filters on desktop-checks and web-checks mirror the
detect-changes supersets that gate their jobs, so a main push outside the
component skips the workflow. mobile-app-checks and desktop-swift-ci keep
unfiltered push triggers: mobile release admission and desktop release
planning consume their push-event runs on the exact source SHA, so a
skipped push would leave that SHA unreleasable. The nightly workflow_call
runs keep their unique `nightly-{run_id}` group suffix and are unaffected.
Deploy workflows, release-eligibility, firestore index reconcile and the
nightly are untouched. .github/scripts/test_main_push_ci_economy.py locks
these invariants and the untouched set; ci-budget.yaml records the two
narrowed push triggers.
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: bece18d2a5
ℹ️ 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".
| # newest pending main SHA runs next. The newest main SHA therefore always | ||
| # carries a complete push-event run, which mobile release admission | ||
| # (verify_mobile_release_admission.py) requires as its per-SHA proof. | ||
| group: mobile-app-checks-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref }}-${{ inputs.nightly_main_sha != '' && format('nightly-{0}', github.run_id) || 'normal' }} |
There was a problem hiding this comment.
Isolate non-push runs from mobile release evidence
Key scheduled and manually dispatched runs separately from main pushes. If one run is active and a main-push run is pending, the 04:41 schedule or a workflow_dispatch on main enters this same refs/heads/main-normal group and replaces that pending push. The latest SHA then has no successful push-event Mobile Release Eligibility run, while .github/scripts/collect_mobile_release_admission.py requires an exact-SHA, first-attempt run whose event is push; this can permanently block a tag from mobile release admission. GitHub concurrency retains only one pending run, so only push events should use the collapsing ref-keyed group.
AGENTS.md reference: .github/AGENTS.md:L19-L21
Useful? React with 👍 / 👎.
| # newest pending main SHA runs next, so a burst of merges no longer queues | ||
| # a full superseded suite for every intermediate SHA. Merge-queue attempts | ||
| # key on their unique gh-readonly-queue refs and stay independent. | ||
| group: backend-hermetic-e2e-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref }}-${{ inputs.nightly_main_sha != '' && format('nightly-{0}', github.run_id) || 'normal' }} |
There was a problem hiding this comment.
Preserve scheduled hermetic gauntlet runs
Give schedule and workflow_dispatch runs per-run concurrency keys instead of grouping every non-PR event by github.ref. On the default branch they share refs/heads/main-normal with push runs, so a main push arriving while the scheduled gauntlet is pending replaces it, silently dropping the daily coverage and its failure-issue reconciliation; conversely, the schedule can replace a pending post-merge run. The ref-keyed collapsing behavior should apply only to push events because GitHub retains just one pending member of a concurrency group.
AGENTS.md reference: .github/AGENTS.md:L19-L21
Useful? React with 👍 / 👎.
| # newest pending main SHA runs next. The newest main SHA therefore always | ||
| # carries a complete push-event run, which mobile release admission | ||
| # (verify_mobile_release_admission.py) requires as its per-SHA proof. | ||
| group: mobile-app-checks-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || github.ref }}-${{ inputs.nightly_main_sha != '' && format('nightly-{0}', github.run_id) || 'normal' }} |
There was a problem hiding this comment.
Preserve cumulative mobile scope after collapsing pushes
Run the full mobile suite for a collapsed main run, or compute its scope from the last completed run rather than HEAD~1. If run A is active, push B with an iOS change is pending, and push C with only an unrelated backend change arrives, C replaces B in this group; C's detect-changes invocation then examines only B...C, skips every mobile-heavy job, and can still publish a successful exact-SHA Mobile Release Eligibility aggregate. Release admission therefore accepts C even though the mobile changes inherited from B never completed their required coverage. This follows directly from GitHub retaining only one pending run rather than accumulating the displaced run's scope.
AGENTS.md reference: .github/AGENTS.md:L19-L21
Useful? React with 👍 / 👎.
…oups Review round 1 on #23069 (FIX-FIRST) found two correctness issues in the collapse change: P1 mobile-app-checks: a ref-keyed non-PR group let any newer event in the group (a newer push, the 04:41 cron, a manual dispatch) replace the newest *pending* push run. Mobile release admission requires a first-attempt push-event Mobile Release Eligibility success on the exact release SHA; a replaced pending run leaves a cancelled check that no rerun can re-mint (attempt 2 does not count, push events do not replay). Push runs now key on github.sha like desktop-swift-ci, and cron/dispatch keep per-run groups. P2 backend-hermetic-e2e / backend-unit-tests: with the plain github.ref fallback, the daily cron or a manual dispatch joined the push group and could evict the newest pending push run (or be evicted by one), leaving a cancelled push check that fails scripts/pre_push_ci_verified.py for that SHA. The ref collapse is now guarded by github.event_name == 'push' so only push events share the ref group; cron, dispatch and merge-queue attempts keep per-run groups. Manual backend-unit-tests dispatches regain their independent result. test_main_push_ci_economy.py is updated to lock the three shapes: push-only workflows collapse on the plain ref; scheduled/dispatched workflows guard the collapse to push events; both release-evidence workflows keep per-SHA push keys. backend test_workflow_contracts.py pins the push-guarded form.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ddbdfaa2d1
ℹ️ 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".
| # the push group would let a cron evict the newest pending push run (or a | ||
| # push evict the day's gauntlet), and a cancelled push check fails | ||
| # scripts/pre_push_ci_verified.py for that SHA. | ||
| group: backend-hermetic-e2e-${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.pull_request.number) || (github.event_name == 'push' && github.ref) || format('run-{0}', github.run_id) }}-${{ inputs.nightly_main_sha != '' && format('nightly-{0}', github.run_id) || 'normal' }} |
There was a problem hiding this comment.
Accumulate scope before collapsing diff-based main runs
When run A is active, a backend-changing push B is pending, and push C arrives before A finishes, this ref-keyed group replaces B with C; however, the scope job still diffs only C's push range via github.event.before, so if C is unrelated to backend/, it emits applies=false and B's inherited backend changes receive no hermetic E2E coverage. The same mismatch affects the newly collapsed backend-checks.yml, repo-checks.yml, and cross-component web-checks.yml groups because their shared detector uses HEAD~1; either compute the newest run's scope from the last completed run or avoid collapsing these diff-scoped workflows.
AGENTS.md reference: .github/AGENTS.md:L19-L21
Useful? React with 👍 / 👎.
What changed and why
At 14:20–14:52Z on 2026-10-21 the prod deploy job (
gcp_backend.ymldeploy) waited ~30 min for a runner after five main merges in a few minutes each fanned out the full Desktop, Mobile, Repo, Backend and E2E sets — every run on an older main SHA was superseded and wasted. Heavy main-push CI workflows now collapse superseded main runs without starving or cancelling: one ref-keyed concurrency group per workflow withcancel-in-progress: ${{ github.event_name == 'pull_request' }}. A newer main push replaces only the pending run in the group, so the running one finishes and the newest main SHA runs next; PR pushes still cancel that PR's older run. Named by David on 10-21 ("have glm do the structural fix").Workflow table (before → after)
code-scanning/default-setup: state=configured, schedule=weekly). No workflow file exists, so there is nothing to edit and it does not contribute to main-push contention.desktop-swift-ci.yml)desktop-swift-${{ pr || github.sha }}, cancel on PR onlyplan-desktop-release.pyexact-SHA evidencedesktop-checks.yml)pr || refgroup,cancel-in-progress: true(newer merge cancelled the running run)cancel-in-progress: ${{ github.event_name == 'pull_request' }}mobile-app-checks.yml)run-{run_id}, cancel on PR onlygithub.sha(per-SHA, like desktop-swift-ci); cron/dispatch keep per-run groups; cancel on PR only. Not collapsed — see review round 1 belowrepo-checks.yml)pr || ref+ lane group,cancel-in-progress: truebackend-checks.yml)pr || refgroup,cancel-in-progress: truebackend-unit-tests.yml)run-{run_id}(no collapsing),cancel-in-progress: truegithub.ref(guarded byevent_name == 'push'); manual dispatch keeps per-run group; cancel on PR onlybackend-hermetic-e2e.yml)run-{run_id}, cancel on PR onlygithub.ref(guarded byevent_name == 'push'); cron/dispatch/merge-queue keep per-run groups; cancel on PR onlyweb-checks.yml)pr || refgroup,cancel-in-progress: truepython-cli-ci.yml)python-cli-ci-group, PR-number /github.refkey, cancel on PR onlyAll changed groups keep the
nightly-{run_id}suffix so nightlyworkflow_callruns stay isolated; the nightly itself is untouched.Required checks and why path filters are safe here
Branch protection on
mainrequires exactly one check: Mobile Release Eligibility (no rulesets add more). It is a job inmobile-app-checks.yml, whosepull_requesttrigger is unfiltered and unchanged — so merges are unaffected. It is also consumed from push-event runs on the exact release SHA (verify_mobile_release_admission.py:mobile_aggregate.event == "push",head_sha == source_sha), somobile-app-checksmust not gain pushpaths— a skipped push would leave that SHA without release proof. For the same reasondesktop-swift-cikeeps its unfiltered push (plan-desktop-release.pyrequires its checks on the exact source SHA; "skipped and absent checks" do not qualify). Desktop Checks and Web Checks push runs have no such consumer, so they gain push path filters mirroring the detect-changes filters that gate their jobs.How release eligibility still gets a complete run on the newest main SHA
Release Eligibility (
release-eligibility.yml) is untouched and re-runs the canonical deterministic checks itself (run_checks.py) on the exact checked-out SHA — it never depended on other workflows' push conclusions. Mobile and desktop release admission consume push-event runs per exact SHA, and GitHub concurrency replaces a pending run with a newer one in the same group, leaving acancelledcheck that no rerun can re-mint (admission requires attempt 1; push events do not replay). Both evidence workflows therefore key push runs ongithub.shaso no main SHA's push run is ever evicted: Desktop Swift CI already did, and Mobile App Checks now does (review round 1, P1). Mobile's expensive jobs are path-gated inside the workflow, so a non-app merge costs only the detect + aggregate jobs. Deploy workflows,gcp_firestore_indexes.yml, andmain_nightly_full.ymlare untouched; their concurrency semantics are load-bearing.Review round 1 (Luna/grok, FIX-FIRST → fixed in
ddbdfaa2d1c)github.sha; cron/dispatch keep per-run groups.cancelledpush check that failsscripts/pre_push_ci_verified.py. Fixed: ref collapse guarded bygithub.event_name == 'push'; cron, dispatch and merge-queue attempts keep per-run groups.Product invariants affected
none — CI orchestration only, no product path changes.
How it was verified
python3 .github/scripts/test_main_push_ci_economy.py(new contract test): 7/7 pass — asserts every group expression exactly across three shapes (push-only ref collapse; push-guarded collapse for scheduled/dispatched workflows; per-SHA push keys for the two release-evidence workflows), cancel-in-progress conditional, nightly isolation, path-filter mirrors, the two unfiltered-push exceptions, and byte-stable concurrency for the untouched deploy/nightly/eligibility workflows.run_checks.py --lane ci --changed-files <diff>: 43/43 manifest checks pass, includingci-budget(validated againstorigin/mainbase),ci-budget-fixtures,main-push-ci-economy-contract,backend-workflow-contracts, runner-cost policy, apt/checkout bounds.backend/test.shwithBACKEND_UNIT_TEST_FILE_LIST=tests/unit/test_workflow_contracts.py: 94/94 pass (updated pin for backend-unit-tests' push-guarded group).check-deployment-concurrency.py: OK (28 persistent writers) — deploy groups untouched.actionlint -shellcheck ""on all eight edited workflows: clean.gh api repos/BasedHardware/omi/branches/main/protection(read-only): required contexts = ["Mobile Release Eligibility"];gh api repos/BasedHardware/omi/code-scanning/default-setupconfirmed CodeQL is default-setup weekly, not a workflow.Tests
The new
.github/scripts/test_main_push_ci_economy.pyis the regression test for this change (wired asmain-push-ci-economy-contractin.github/checks-manifest.yaml, triggered by every workflow it guards). It would have caught both pre-existing failure shapes: unconditionalcancel-in-progress: trueon a main-push workflow, and arun-{run_id}non-PR key that lets superseded suites all run.UI evidence
UI-Evidence: none -- CI workflow orchestration only; no user-facing surface changed.
Failure-Class: none
New guards
Incident this guard would have caught: the 2026-10-21 14:20–14:52Z prod-deploy runner starvation, where five rapid main merges queued superseded full CI suites fleet-wide (also evidenced by the unconditional
cancel-in-progress: trueshapes this test now rejects). Not a shared primitive because the invariant is specific to workflow YAML semantics that no existing check (ci-budget, deployment-concurrency, actionlint) models: those validate cost inventories, deploy locks, and expression syntax, not main-push supersession behavior.Scoped cleanups
.github/ci-budget.yamlrefreshed for the two narrowed push triggers (desktop-checks, web-checks) with rationale lines;check_ci_budget.pypasses againstorigin/main.