Skip to content

ci: cancel superseded pull request validation runs - #69

Merged
EvanAgee merged 4 commits into
mainfrom
fm/fm-cancel-superseded-ci
Aug 31, 2026
Merged

EvanAgee merged 4 commits into
mainfrom
fm/fm-cancel-superseded-ci

Conversation

@EvanAgee

@EvanAgee EvanAgee commented Aug 31, 2026 •

Copy link
Copy Markdown
Owner

Intent

Stop old builds from running against code nobody will ship. Add GitHub Actions concurrency cancellation to Firstmate pull-request validation workflows. Use github.workflow plus github.head_ref, with github.run_id as the fallback, so only a newer run of the same workflow on the same branch cancels the older run and push, schedule, or manual events remain independent. Do not change what any check does or which checks are required. Do not add cancellation to deployment or release workflows. Leave risky workflows alone and list them in the pull-request body. Preserve the specialized no-mistakes-required body-event grouping because it protects opened and edited events. Acceptance requires proof on a real pull request that a second commit cancels a still-running older run, proof that a mixed-event workflow fallback still runs, and proof that unrelated workflows do not share groups.

What Changed

  • Add per-workflow concurrency groups to CI and Unslop so newer runs for the same pull request cancel older in-progress validation, while CI push runs remain independent through a run ID fallback.
  • Add parsed-workflow contract coverage for cancellation boundaries and register it with the pure contract unit tests.
  • Leave no-mistakes-required.yml and windows-herdr-spike.yml unchanged, preserving the body-event grouping and manual Windows automation workflow.

Risk Assessment

✅ Low: Captain, the change is limited to two validation workflows, keeps unrelated events independent, and leaves the specialized no-mistakes grouping unchanged.

Testing

No baseline commands were supplied. The focused regression failed against the base and passed against the target, proving same-PR grouping, independent non-PR fallbacks, unrelated workflow isolation, and unchanged workflow behavior outside concurrency. The runner test also passed. Evidence logs were captured, but no screenshot or live cancellation artifact was possible because no pull request or Actions run exists yet.

Evidence: Concurrency behavior transcript

Source: Concurrency behavior transcript

Firstmate workflow concurrency test evidence
Date: 2026-08-31
Base: 494c72d039a3161b6a2985ba94d99171f88a8789
Target: df3c8592d35671a2d38ee3b4a8b96a67fa7eae3f

Base config check
Command: bash tests/fm-workflow-concurrency.test.sh <base-workflows>

not ok - CI has no concurrency policy
exit_status=1

Target config check
Command: bash tests/fm-workflow-concurrency.test.sh .github/workflows <base-workflows>

ok - standard workflow triggers, permissions, and jobs are unchanged
ok - specialized, deployment, release, and manual workflows are unchanged
scenario                  | resolved concurrency group
--------------------------+---------------------------
older CI run for PR 73    | CI-73
newer CI run for PR 73    | CI-73
CI run for separate PR 74 | CI-74
Unslop run for PR 73      | Unslop-73
CI push run 2001          | CI-2001
CI push run 2002          | CI-2002
ok - standard validation concurrency resolves to the intended cancellation boundaries

Focused repository runner
Command: bin/fm-test-run.sh tests/fm-workflow-concurrency.test.sh

FM_TEST_BEGIN 2026-08-31T14:39:42Z tests/fm-workflow-concurrency.test.sh family=pure-contract-unit expected_gate_skip=none
scenario                  | resolved concurrency group
--------------------------+---------------------------
older CI run for PR 73    | CI-73
newer CI run for PR 73    | CI-73
CI run for separate PR 74 | CI-74
Unslop run for PR 73      | Unslop-73
CI push run 2001          | CI-2001
CI push run 2002          | CI-2002
ok - standard validation concurrency resolves to the intended cancellation boundaries
FM_TEST_END 2026-08-31T14:39:43Z tests/fm-workflow-concurrency.test.sh exit=0 duration_ms=901 gate_skip=false
Evidence: Live GitHub availability check

Source: Live GitHub availability check

Live GitHub evidence availability
Date: 2026-08-31
Repository: kunchenguid/firstmate
Branch: fm/fm-cancel-superseded-ci
Target: df3c8592d35671a2d38ee3b4a8b96a67fa7eae3f

Command: gh-axi pr list --head fm/fm-cancel-superseded-ci --state all --limit 20

count: 0
pull_requests: []

Command: gh-axi run list --commit df3c8592d35671a2d38ee3b4a8b96a67fa7eae3f --limit 20

count: 0
runs: []

Command: gh-axi run list --branch fm/fm-cancel-superseded-ci --limit 20

count: 0
runs: []

The branch has no pull request or Actions run yet, so GitHub cannot show a cancelled superseded run during this pre-PR test phase.
- Outcome: ⚠️ 1 warning across 1 run (12m51s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed (2) ✅
  • 🚨 .github/workflows/ci.yml:13 - The criterion says “only a newer run of the same workflow on the same branch cancels the older run,” but github.head_ref contains only the short branch name. Two contributors using patch-1 in separate forks both compute CI-patch-1, so the newer run cancels the unrelated pull request’s checks. The same collision exists in .github/workflows/unslop.yml:11. If fork isolation is required, include the pull request head repository identity while retaining the workflow, head-ref, and run-ID fallback behavior.

🔧 Fix: Captain, isolate validation concurrency groups by fork
1 error still open:

  • 🚨 .github/workflows/ci.yml:13 - GitHub treats concurrency groups as case-insensitive, while branch names may differ by case. Pull requests from the same repository on Feature and feature therefore share a group, allowing one PR to cancel the other's checks. This violates the requirement that only runs from the same branch cancel each other. Add the pull request number, with github.run_id as its non-PR fallback, as another group component in both workflows while retaining the required workflow, repository, and branch components. GitHub concurrency documentation and branch-name guidance confirm the conflicting case behavior. The same defect appears in .github/workflows/unslop.yml:11.

🔧 Fix: Captain, use PR numbers for case-safe validation concurrency
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 warning
  • ⚠️ The required real pull-request cancellation proof is unavailable because this branch and target commit have no pull request or GitHub Actions runs. Proceed to the PR phase and capture a still-running older run being cancelled by a second commit before accepting the change.
  • git archive 494c72d039a3161b6a2985ba94d99171f88a8789 .github/workflows | tar -x -C /tmp/fm-workflow-concurrency-01M1C0T2MQFS6RYYXA02QHY5CA
  • bash tests/fm-workflow-concurrency.test.sh /tmp/fm-workflow-concurrency-01M1C0T2MQFS6RYYXA02QHY5CA/.github/workflows (expected base failure)
  • bash tests/fm-workflow-concurrency.test.sh .github/workflows /tmp/fm-workflow-concurrency-01M1C0T2MQFS6RYYXA02QHY5CA/.github/workflows
  • bin/fm-test-run.sh tests/fm-workflow-concurrency.test.sh
  • bin/fm-test-run.sh tests/fm-test-run.test.sh
  • gh-axi pr list --head fm/fm-cancel-superseded-ci --state all --limit 20
  • gh-axi run list --commit df3c8592d35671a2d38ee3b4a8b96a67fa7eae3f --limit 20
  • gh-axi run list --branch fm/fm-cancel-superseded-ci --limit 20
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Summary by CodeRabbit

  • CI Improvements

    • Updated validation workflows to automatically cancel older in-progress runs when a newer run starts for the same pull request or execution context.
  • Tests

    • Added coverage to verify workflow concurrency behavior and ensure unrelated workflow configuration remains unchanged.

## What's going on (plain English)

A newer commit makes the old pull request build obsolete. Stop that old build while keeping each workflow isolated from the others.
@coderabbitai

coderabbitai Bot commented Aug 31, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 443e84ce-2e8b-42b1-8a53-f105480fea5a

📥 Commits

Reviewing files that changed from the base of the PR and between 494c72d and 12c6c2b.

📒 Files selected for processing (4)
  • .github/workflows/ci.yml
  • .github/workflows/unslop.yml
  • bin/fm-test-run.sh
  • tests/fm-workflow-concurrency.test.sh

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The standard CI and Unslop workflows now cancel superseded runs within the same pull request or run group. A new contract test validates group resolution, workflow integrity, and test-runner selection.

Changes

Workflow concurrency controls

Layer / File(s) Summary
Configure workflow concurrency
.github/workflows/ci.yml, .github/workflows/unslop.yml
Both workflows group runs by workflow name and pull request number, or by run ID for non-pull-request runs. New runs cancel in-progress runs in the same group.
Validate concurrency behavior
bin/fm-test-run.sh, tests/fm-workflow-concurrency.test.sh
The test runner includes the new contract test. The test validates workflow settings, resolves representative event contexts, checks workflow integrity, and reports the resolved groups.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: 🔵 Low · up to 12c6c

CI and Unslop validation now cancel superseded pull-request runs while keeping unrelated workflows and non-pull-request runs independent. The change is mergeable with owner awareness that required-check results after cancellation and replacement should be validated on a live pull request.

Suggested reviewers: kunchenguid

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: cancelling superseded pull request validation runs in CI.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (2 skipped: 2 …
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (2 skipped: 2 unsupported.)

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fm/fm-cancel-superseded-ci

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@EvanAgee EvanAgee added the agent-pr-watched An agent merge watch is armed on this PR label Aug 31, 2026
@EvanAgee
EvanAgee merged commit 965aca3 into main Aug 31, 2026
37 checks passed
@EvanAgee
EvanAgee deleted the fm/fm-cancel-superseded-ci branch August 31, 2026 15:10
EvanAgee added a commit that referenced this pull request Sep 22, 2026
Add the changed-code Unslop ratchet for pushes and pull requests.
Expose portable serial shard estimates and fail when their modeled work approaches the root's CI cap.

Refs #6
Refs #23
Refs #69

## What I walked

I used scratch home `/Users/evanagee/.treehouse/firstmate-df5ff1/11/firstmate/.fm-c7-walk.qZO8LO/home` and a scratch Git repository beneath the same run directory.

`FM_HOME="$walk_home" BASE_SHA="$base_sha" HEAD_SHA="$head_sha" RUNNER_TEMP="$walk_runner" GITHUB_OUTPUT="$walk_root/github-output" bash "$walk_root/find.sh"`

Output:

    Supported code changed; unslop will run.

`FM_HOME="$walk_home" npm_config_prefix="$walk_home/npm" PATH="$walk_home/npm/bin:$PATH" bash "$walk_root/install.sh"`

Output:

    added 4 packages in 3s
    unslop 0.1.7
    Version: 1.50.0

`FM_HOME="$walk_home" PATH="$walk_home/npm/bin:$PATH" BASE_SHA="$base_sha" HEAD_SHA="$head_sha" RUNNER_TEMP="$walk_runner" GITHUB_WORKSPACE="$walk_repo" bash "$walk_root/gate.sh"`

Output:

    Scanning 1 changed code file(s):
      ./src/math.ts
    Findings in changed files at head (all severities):
    []
    No newly introduced error-tier gateable findings; pre-existing findings stay report-only.

`actionlint -no-color -shellcheck= -pyflakes= .github/workflows/unslop.yml` exited 0.

`bin/fm-test-run.sh --check-coverage`

Output:

    FM_TEST_COVERAGE ok total=236 parallel=24 parallel_max_ms=417163 parallel_imbalance_ms=2894 parallel_unhinted=0 serial=196 serial_shards=9 serial_unhinted=20 herdr=16

`bin/fm-test-run.sh --serial-shard-budget`

Output:

    FM_TEST_SERIAL_BUDGET shard=1of9 estimated_ms=703017
    FM_TEST_SERIAL_BUDGET shard=2of9 estimated_ms=703010
    FM_TEST_SERIAL_BUDGET shard=3of9 estimated_ms=703027
    FM_TEST_SERIAL_BUDGET shard=4of9 estimated_ms=703027
    FM_TEST_SERIAL_BUDGET shard=5of9 estimated_ms=703028
    FM_TEST_SERIAL_BUDGET shard=6of9 estimated_ms=703008
    FM_TEST_SERIAL_BUDGET shard=7of9 estimated_ms=703017
    FM_TEST_SERIAL_BUDGET shard=8of9 estimated_ms=703010
    FM_TEST_SERIAL_BUDGET shard=9of9 estimated_ms=703035

`PATH="$PWD/.fm-c7-tools:$PATH" bin/fm-test-run.sh --lane portable-parallel-1 --fail-on-gate-skip 'Pi extension typecheck prerequisite not found'`

Output:

    FM_TEST_SUMMARY total=11 failed=0 skipped_gate=0 duration_ms=1240073

After rebasing onto the latest `origin/c/main`, I reran the runner, Unslop workflow, CI policy, and captain-hold fixture tests individually. All four passed. The changed Unslop test also passed inside `portable-serial-7of9`; that lane retained only the documented macOS baseline failures in `fm-remote-herdr-guard.test.sh` and `fm-documentation-audiences.test.sh`. The changed captain-hold fixture passed inside `portable-parallel-2`; that lane retained the documented root baseline failure in `fm-arm-pretool-check.test.sh`.

The GitHub-hosted workflow run remains proven only by the `c/main` CI run after Firstmate lands this branch.

## Port record

The root already had two portable parallel lanes, nine portable serial shards, the Herdr family, matrix-to-runner coverage checks, finite timeout tiers, and pull-request supersession that preserves every main push.
I adopted the root's job names, nine-shard count, current timing hints, 30-minute normal-job cap, and event-specific concurrency policy.
I ported the changed-code Unslop ratchet, including renamed-file baselines and push event refs, plus the serial budget report and cap guard.
I dropped the fork's eight-shard layout, 15-minute serial cap, and unconditional cancellation spelling because the root's current layout and push-preserving policy are newer.
After C4 landed, I adapted the captain-hold merge fixture to its required review-thread read by returning the root's zero-thread response.
The separate preceding commit repairs the pre-existing SC1010 baseline in the captain-hold fixture, as approved outside C7's scope.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-pr-watched An agent merge watch is armed on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant