Skip to content

ci: collapse superseded main-push runs without cancelling the running one - #23069

Merged
Git-on-my-level merged 2 commits into
mainfrom
lane/ci-economy
Oct 21, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
lane/ci-economy

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

What changed and why

At 14:20–14:52Z on 2026-10-21 the prod deploy job (gcp_backend.yml deploy) 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 with cancel-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)

Workflow Push trigger Concurrency before Concurrency after
CodeQL not a workflow: GitHub default setup, weekly schedule (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. n/a unchanged
Desktop Swift CI (desktop-swift-ci.yml) push main, unfiltered (kept) per-SHA group desktop-swift-${{ pr || github.sha }}, cancel on PR only unchanged — already implements no-starvation; per-SHA keying is load-bearing for plan-desktop-release.py exact-SHA evidence
Desktop Checks (desktop-checks.yml) push main, unfiltered → path-filtered (detect-changes agent-runtime superset) pr || ref group, cancel-in-progress: true (newer merge cancelled the running run) same group, cancel-in-progress: ${{ github.event_name == 'pull_request' }}
Mobile App Checks (mobile-app-checks.yml) push main, unfiltered (kept — see below) non-PR key run-{run_id}, cancel on PR only push key github.sha (per-SHA, like desktop-swift-ci); cron/dispatch keep per-run groups; cancel on PR only. Not collapsed — see review round 1 below
Repo Checks (repo-checks.yml) push main, unfiltered (metadata/code lane split kept) pr || ref + lane group, cancel-in-progress: true same group, cancel on PR only
Backend Checks (backend-checks.yml) push main, unfiltered (job-level detect-changes gating already skips heavy jobs) pr || ref group, cancel-in-progress: true same group, cancel on PR only
Backend Unit Tests (backend-unit-tests.yml) push main, already path-filtered (48 filters) non-PR key run-{run_id} (no collapsing), cancel-in-progress: true push key github.ref (guarded by event_name == 'push'); manual dispatch keeps per-run group; cancel on PR only
Backend Hermetic E2E (backend-hermetic-e2e.yml) push main, PR, schedule, merge_group, unfiltered non-PR key run-{run_id}, cancel on PR only push key github.ref (guarded by event_name == 'push'); cron/dispatch/merge-queue keep per-run groups; cancel on PR only
Web Checks (web-checks.yml) push main, unfiltered → path-filtered (web trees superset) pr || ref group, cancel-in-progress: true same group, cancel on PR only
Python CLI (python-cli-ci.yml) push main, already path-filtered none new: python-cli-ci- group, PR-number / github.ref key, cancel on PR only

All changed groups keep the nightly-{run_id} suffix so nightly workflow_call runs stay isolated; the nightly itself is untouched.

Required checks and why path filters are safe here

Branch protection on main requires exactly one check: Mobile Release Eligibility (no rulesets add more). It is a job in mobile-app-checks.yml, whose pull_request trigger 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), so mobile-app-checks must not gain push paths — a skipped push would leave that SHA without release proof. For the same reason desktop-swift-ci keeps its unfiltered push (plan-desktop-release.py requires 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 a cancelled check that no rerun can re-mint (admission requires attempt 1; push events do not replay). Both evidence workflows therefore key push runs on github.sha so 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, and main_nightly_full.yml are untouched; their concurrency semantics are load-bearing.

Review round 1 (Luna/grok, FIX-FIRST → fixed in ddbdfaa2d1c)

  • P1 mobile-app-checks: ref-keyed push group let a newer push, the 04:41 cron, or a dispatch evict the newest pending push run → unrecoverable loss of first-attempt per-SHA Mobile Release Eligibility proof. Fixed: push runs key on github.sha; cron/dispatch keep per-run groups.
  • P2 backend-hermetic-e2e / backend-unit-tests: cron/dispatch shared the push group and could evict (or be evicted by) a push run, leaving a cancelled push check that fails scripts/pre_push_ci_verified.py. Fixed: ref collapse guarded by github.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, including ci-budget (validated against origin/main base), ci-budget-fixtures, main-push-ci-economy-contract, backend-workflow-contracts, runner-cost policy, apt/checkout bounds.
  • backend/test.sh with BACKEND_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-setup confirmed CodeQL is default-setup weekly, not a workflow.

Tests

The new .github/scripts/test_main_push_ci_economy.py is the regression test for this change (wired as main-push-ci-economy-contract in .github/checks-manifest.yaml, triggered by every workflow it guards). It would have caught both pre-existing failure shapes: unconditional cancel-in-progress: true on a main-push workflow, and a run-{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: true shapes 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.yaml refreshed for the two narrowed push triggers (desktop-checks, web-checks) with rationale lines; check_ci_budget.py passes against origin/main.

… 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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T16:36:22.739843Z ddbdfaa New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread .github/workflows/mobile-app-checks.yml Outdated
# 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' }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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' }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

Comment thread .github/workflows/mobile-app-checks.yml Outdated
# 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' }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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' }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 17cae1b into main Oct 21, 2026
68 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/ci-economy branch October 21, 2026 16:57
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