Skip to content

fix(provider-github): let a workflow run supersede before it has jobs - #285

Open
ccf-lisa[bot] wants to merge 3 commits into
mainfrom
fx/checks-supersede-without-jobs
Open

ccf-lisa[bot] wants to merge 3 commits into
mainfrom
fx/checks-supersede-without-jobs

Conversation

@ccf-lisa

@ccf-lisa ccf-lisa Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Task: fx/checks-supersede-without-jobs. Patch-release candidate: the deployed dispatcher is v0.6.0.

Bug (prod, v0.6.0, compliance-framework/api#587)

latestSuites (internal/provider/github/observe.go) dropped every check suite with checkRuns.totalCount == 0 before choosing the latest suite of a kind (App + workflow + event). When a workflow fires twice in quick succession (PR opened + labeled gives two pull_request runs of preview, and the concurrency group cancels the older one), the newer run's suite exists for a few seconds with no check runs. In that window the cancelled run counted as the latest of its kind.

Timeline on api#587, head 820900a:

time event
12:56:43 preview run 388's check suite created
12:56:44 preview run 387 (suite with 4 check runs) CANCELLED by concurrency
12:56:47 run 388's first job starts
12:56:48 check_suite completed webhook for 387; the observation rolls up {state: failure, settled: true}: 388 is skipped (no check runs yet), so 387's CANCELLED is the latest preview
12:57:05 run 388 succeeds; the PR is green

Meanwhile the catalog rule fix-failing-bump had already dispatched a fix on a PR that was green.

Fix

  • A suite whose kind is known (suiteKind ok: App + workflowRun + workflow) now takes part in superseding whether or not it has check runs. It can be the latest of its kind, and as the latest it counts as pending until it concludes. The api#587 observation now gives pending (not settled), so no rule fires.
  • A kind-known suite completed with zero check runs counts by its conclusion. GitHub completes a run without creating jobs in three cases: it failed to start (startup_failure, an invalid workflow file), it was cancelled before a job started (cancelled, usually by its concurrency group, and then a later run of the same workflow and event supersedes it), or it is waiting for approval (action_required). None of these passed. Ignoring the run would let an older run of the same workflow, or nothing, stand in for it.
  • Suites whose kind can't be told and that have no check runs are still ignored. These are GitHub's placeholder suites, queued for every App that could run checks (Actions with no workflow for the event), and they never complete.
  • Updated the checksOf / latestSuites doc comments and the GitHub provider LLD (checks roll-up section and ci.rerun).

ci.rerun (effects_ci.go): not affected

latestRuns uses the same runOrder superseding but reads the Actions runs API (GET …/actions/runs?head_sha=). That API lists a run from the moment it is created, whether or not it has jobs, and latestRuns never filtered on jobs. A queued run 388 therefore already superseded the cancelled 387, and nothing was re-run. No code change: I added a doc line on latestRuns, and TestApplyCIRerunNothing now covers the api#587 shape (cancelled run 19 superseded by queued run 20 of the same workflow, nothing re-run).

Tests

TestObserveChecks (table, through the githubtest GraphQL fake; the fake already serves checkRuns.totalCount and the workflowRun per suite, so no fake change was needed):

  • api#587: run 387 cancelled with 4 runs + run 388 of the same workflow and event, in progress, 0 runs → pending, not settled
  • api#587: run 388 then completed success with runs → success
  • a later queued run with 0 runs supersedes a failed run, and a green one too → pending; an earlier 0-run run is superseded; a lone 0-run run → pending
  • the latest run completed with 0 runs: STARTUP_FAILURE / CANCELLED → failure, SUCCESS → success
  • kind-less 0-run suites (an Actions placeholder without a workflowRun, another App's placeholder, a run with a null workflow) are still ignored
  • replaced a later run without check runs doesn't supersede, which asserted the buggy behaviour; every other case is unchanged

I checked that seven of the new cases fail against the old latestSuites.

Verification

  • make build ✅
  • make check-generated, make lint (0 issues), make catalog (66/66), make openapi-lint ✅
  • make test: everything passes except internal/agent/host/provision TestBaseScriptRuns, which fails locally on macOS only (/etc/os-release is missing). It is unrelated to this change and runs in CI on Linux.

Resolved: kept, reviewed (zero-job runs count by their conclusion)

A workflow run that completes with no jobs used to be ignored. As the latest of its kind it now counts by its conclusion, so these cases now roll up failure, settled:

  • a fork PR waiting for workflow approval (action_required);
  • every PR while a workflow file on the default branch is invalid (startup_failure);
  • a run cancelled before its first job by a concurrency group shared across workflows or events (its successor is another kind, so it doesn't supersede the cancelled run).

Where the run had jobs, these cases were already failure. Review kept the behaviour: GitHub's PR checks show these runs as not passing, and no catalog rule misfires. Fork PRs get no pr.checks.completed, and the rules that act on failure are for the factory's own PRs. TestObserveChecks covers the 0-run ACTION_REQUIRED case, and the LLD names what consumers see.

🤖 Generated with Claude Code

ccf-lisa Bot and others added 3 commits November 26, 2026 10:19
latestSuites dropped every check suite without check runs before picking
the latest suite of a kind, so a re-triggered workflow's newer run did not
supersede the run its concurrency group cancelled until its first job
showed up. In between, the cancelled run counted as the latest and the PR
rolled up failure, settled (compliance-framework/api#587).

A suite of a known kind (App, workflow, event) now takes part with or
without check runs: as the latest it counts as pending until it
concludes, and once completed without jobs (startup failure, cancelled
before a job, awaiting approval) by its conclusion. Kind-less suites
without check runs (GitHub's never-completing placeholders) are still
ignored. ci.rerun's latestRuns reads the runs API, which lists a run
from its creation, so it was not affected; its test now covers the
shape.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ncel case

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nt what consumers see

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

0 participants