Skip to content

fix: supersede stale PR CI and bound job runtimes - #4281

Merged
kunchenguid merged 1 commit into
mainfrom
fm/fm-ci-supersession-timeouts-r1
Sep 12, 2026
Merged

kunchenguid merged 1 commit into
mainfrom
fm/fm-ci-supersession-timeouts-r1

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Intent

Captain authorized (2026-09-12): ship two firstmate CI safeguards in ONE no-mistakes PR, motivated by the GitHub Actions starvation incident in which firstmate CI load starved no-mistakes of hosted runners (refined cause: about 63 old runs reactivated in a burst on 2026-09-12 plus heavy CI fan-out with no per-PR supersession).

Deliver exactly these two changes, nothing more:

  1. Per-PR CI supersession: firstmate .github/workflows/ci.yml currently has no concurrency deduplication, so superseded PR heads keep consuming runners. Add per-PR concurrency grouping so a newer push to the same PR cancels that PR's in-progress CI runs, WITHOUT breaking or cancelling main push CI.
  2. Explicit job timeouts: several firstmate CI jobs are currently unbounded (no timeout-minutes) and can hang indefinitely. Add reasonable timeout caps as hang tripwires on the currently-unbounded jobs, aligned with the incident report's recommendations.

Out of scope - do NOT do any of these in this PR: fork approval policy changes, auto-closing PRs, a path-filter fast path, runner infrastructure, bulk historical rerun tooling, redesigning no-mistakes-required.yml, or touching any other repository. Do not lower the already-bounded shard caps (10/30/75) without evidence.

The authoritative incident analysis and recommendations are in data/fm-actions-starvation-safeguards-s1/report.md (a private firstmate-home report, not in this repository). Its substance, as the captain's ask by reference:

  • The report's recommended concurrency-group pattern is exactly: group "ci-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}" with cancel-in-progress "${{ github.event_name == 'pull_request' }}". For PRs this keeps the newest run and keys on the PR number rather than contributor branch names; for main and other non-PR events the unique run id preserves all existing main validation instead of silently dropping pending commits.
  • The report explicitly warns NOT to apply the same simple group to the compliance workflow (no-mistakes-required.yml), whose event-specific groups deliberately preserve independent evidence under fork approval.
  • The report's proposed initial caps for the currently unbounded firstmate jobs are 25 minutes for lint (whose measured executions are 14-16 minutes, so the cap is a tripwire with deliberate margin) and 5 minutes each for the coverage guard, the repo invariants, and the timing aggregate. It says to keep the existing parallel (10), serial (30), Herdr (75 plus its 20-minute step) and macOS (10) bounds unchanged in this first patch.

The PR description must cite that report path and explain both the concurrency-group choice (and why it supersedes PR runs without cancelling main push) and the chosen timeout values.

What Changed

  • Add the concurrency group recommended by data/fm-actions-starvation-safeguards-s1/report.md, grouping pull-request runs by PR number while using unique run IDs and disabled cancellation for main pushes.
  • Add timeout tripwires of 25 minutes for lint and 5 minutes each for coverage, timing aggregation, and repository invariants, while preserving existing bounded lane caps.
  • Add workflow contract tests for concurrency and timeout behavior, and document PR supersession in CONTRIBUTING.md.

Risk Assessment

✅ Low: The change exactly applies the authorized per-PR concurrency group and four timeout caps while preserving existing bounded jobs and main-push behavior.

Testing

Targeted semantic tests resolved PR and push concurrency contexts, verified all timeout caps, reproduced the baseline's missing safeguards, confirmed existing 10/30/75-minute bounds remained unchanged, and found no compliance-workflow change; actual GitHub-hosted cancellation and timeout behavior could not be driven locally.

  • Live validation: ⚠️ no-surface - 0 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A contributor pushes a newer head to one PR and its older in-progress CI run is cancelled without affecting another PR ⏸️ untested no This requires a disposable GitHub PR, Actions runner access, and permission to push successive heads while observing concurrent runs; provide those credentials and authority to drive it live.
Two pushes to main retain independent CI runs and neither run is cancelled ⏸️ untested no Live validation requires authority to push multiple commits to main and inspect GitHub Actions; this test phase has neither that authority nor permission to push.
The formerly unbounded lint, coverage, aggregate, and invariants jobs terminate at their 25/5/5/5-minute tripwires ⏸️ untested no Actual timeout enforcement occurs only on GitHub-hosted runners and would require authorized deliberately hanging workflow runs; provide a disposable repository or PR and Actions access.
Existing parallel, serial, Herdr, and macOS jobs retain their 10/30/75/10-minute bounds ⏸️ untested no The parsed workflow confirms the configured values, but observing their enforcement requires GitHub-hosted Actions runs and repository write authority.
The compliance workflow retains its independent grouping behavior ⏸️ untested no This is an unchanged declarative workflow boundary with no local runtime surface; live confirmation requires fork-approval GitHub events and Actions inspection permissions.
The pull request description cites data/fm-actions-starvation-safeguards-s1/report.md and explains the grouping and timeout rationale ⏸️ untested no PR creation and description management belong to the outer pipeline phase; provide an existing PR URL and read access, or validate after the outer executor creates it.
Evidence: CI workflow semantic contract and baseline comparison

Source: CI workflow semantic contract and baseline comparison

$ bash tests/fm-ci-workflow.test.sh
ok - a newer push to one PR supersedes that PR's in-flight CI
ok - distinct PRs get distinct concurrency groups
ok - every main push keeps its own group and is never cancelled
ok - every ci.yml job carries a finite timeout
ok - the incident's unbounded jobs keep their recommended caps
ok - the already-measured lane bounds are unchanged

$ semantic baseline/target comparison via Ruby YAML consumer
base.concurrency=nil
base.timeout.lint=nil
base.timeout.test-coverage=nil
base.timeout.tests-timing-aggregate=nil
base.timeout.invariants=nil
base.timeout.tests-portable-parallel-1=10
base.timeout.tests-portable-parallel-2=10
base.timeout.tests-portable-serial=30
base.timeout.tests-herdr=75
base.timeout.macos-stock-bash=10
target.concurrency={"group"=>"ci-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.run_id }}", "cancel-in-progress"=>"${{ github.event_name == 'pull_request' }}"}
target.timeout.lint=25
target.timeout.test-coverage=5
target.timeout.tests-timing-aggregate=5
target.timeout.invariants=5
target.timeout.tests-portable-parallel-1=10
target.timeout.tests-portable-parallel-2=10
target.timeout.tests-portable-serial=30
target.timeout.tests-herdr=75
target.timeout.macos-stock-bash=10
- Outcome: ⚠️ 2 warnings across 1 run (1m7s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 2 warnings
  • ⚠️ .github/workflows/ci.yml:15 - The change is GitHub Actions configuration only, so local testing cannot demonstrate actual run cancellation or timeout enforcement. A disposable PR with permission to push replacement heads and inspect Actions runs is required for live evidence.
  • ⚠️ this change has no live-validatable surface; proceed without live validation? (0 of 6 scenarios were driven live against the product); A contributor pushes a newer head to one PR and its older in-progress CI run is cancelled without affecting another PR: This requires a disposable GitHub PR, Actions runner access, and permission to push successive heads while observing concurrent runs; provide those credentials and authority to drive it live.; Two pushes to main retain independent CI runs and neither run is cancelled: Live validation requires authority to push multiple commits to main and inspect GitHub Actions; this test phase has neither that authority nor permission to push.; The formerly unbounded lint, coverage, aggregate, and invariants jobs terminate at their 25/5/5/5-minute tripwires: Actual timeout enforcement occurs only on GitHub-hosted runners and would require authorized deliberately hanging workflow runs; provide a disposable repository or PR and Actions access.; Existing parallel, serial, Herdr, and macOS jobs retain their 10/30/75/10-minute bounds: The parsed workflow confirms the configured values, but observing their enforcement requires GitHub-hosted Actions runs and repository write authority.; The compliance workflow retains its independent grouping behavior: This is an unchanged declarative workflow boundary with no local runtime surface; live confirmation requires fork-approval GitHub events and Actions inspection permissions.; The pull request description cites data/fm-actions-starvation-safeguards-s1/report.md and explains the grouping and timeout rationale: PR creation and description management belong to the outer pipeline phase; provide an existing PR URL and read access, or validate after the outer executor creates it.
  • Live validation: ⚠️ no-surface - 0 of 6 scenarios driven live against the product
Scenario Result Live Evidence
A contributor pushes a newer head to one PR and its older in-progress CI run is cancelled without affecting another PR ⏸️ untested no This requires a disposable GitHub PR, Actions runner access, and permission to push successive heads while observing concurrent runs; provide those credentials and authority to drive it live.
Two pushes to main retain independent CI runs and neither run is cancelled ⏸️ untested no Live validation requires authority to push multiple commits to main and inspect GitHub Actions; this test phase has neither that authority nor permission to push.
The formerly unbounded lint, coverage, aggregate, and invariants jobs terminate at their 25/5/5/5-minute tripwires ⏸️ untested no Actual timeout enforcement occurs only on GitHub-hosted runners and would require authorized deliberately hanging workflow runs; provide a disposable repository or PR and Actions access.
Existing parallel, serial, Herdr, and macOS jobs retain their 10/30/75/10-minute bounds ⏸️ untested no The parsed workflow confirms the configured values, but observing their enforcement requires GitHub-hosted Actions runs and repository write authority.
The compliance workflow retains its independent grouping behavior ⏸️ untested no This is an unchanged declarative workflow boundary with no local runtime surface; live confirmation requires fork-approval GitHub events and Actions inspection permissions.
The pull request description cites data/fm-actions-starvation-safeguards-s1/report.md and explains the grouping and timeout rationale ⏸️ untested no PR creation and description management belong to the outer pipeline phase; provide an existing PR URL and read access, or validate after the outer executor creates it.
  • bash tests/fm-ci-workflow.test.sh
  • Ruby YAML semantic comparison of .github/workflows/ci.yml at base c191eacd36a9a44db0fb1888c67fe3dbfe534919 and target
  • git diff --name-only c191eacd36a9a44db0fb1888c67fe3dbfe534919..2a8e3531a183ac17f04fe01c631ae8843dcfeb7a -- .github/workflows/no-mistakes-required.yml
  • git status --short
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.