Skip to content

MUL-8510: fix(ghsnapshot): drop cancelled workflow runs that a newer run of the same workflow replaced from the PR rollup - #9860

Merged
Bohan-J merged 4 commits into
mainfrom
fix/ghsnapshot-superseded-check-suites
Nov 3, 2026
Merged

Bohan-J merged 4 commits into
mainfrom
fix/ghsnapshot-superseded-check-suites

Conversation

@Bohan-J

@Bohan-J Bohan-J commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

What does this PR do?

When the same workflow runs twice on one PR head and the first run is cancelled (cancel-in-progress, a re-trigger on edited), the PR rollup stays FAILURE after the newer run goes green, so a --until-pr checks wakeup never fires.

/commits/{sha}/check-runs?filter=latest only drops older attempts inside one check suite. Each workflow run is its own suite, so the cancelled run's check runs stay in the response next to the newer run's, and rollupContexts fails on them.

This PR drops a cancelled run's check suite from the snapshot only when the Actions API confirms that a newer run of the same workflow for the same event replaced it on the same head. It also requires that the newer run has already reported check runs and is either finished or still has one running, so the rollup reads PENDING rather than passing before the replacement reports.

A run that concluded failure is never dropped. A cancellation with no replacement still fails. A run of a different workflow, or of the same workflow for a different event (for example push vs pull_request), never replaces another one.

Permissions

Only the Actions API says which workflow and event a check suite belongs to. The Checks API has no such field: check suites and check runs carry the app, the suite ID and the job name, and external_id changes on every run. GraphQL CheckSuite.workflowRun also needs Actions read. Matching by app and check name alone (the first version of this PR, and #9837) can drop a cancelled CI run because an unrelated workflow passed a job with the same name, which reports a false success.

So the fix uses the optional Actions read permission:

  • With it, the snapshot reads GET /actions/runs?head_sha=… once, and only when a failing Actions check sits beside another Actions check suite. PRs with one run per workflow, or with only passing checks, make the same requests as before.
  • Without it, nothing is dropped and the behavior is unchanged from main. Nothing fails and no request is made. The token's granted permissions come from the installation-token response, so no extra call is needed to find out.

The GitHub integration docs (all five languages) list Actions as optional and say what it changes.

Related Issue

Closes #9830

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Changes Made

  • server/internal/integrations/ghsnapshot/client.go: keep the permissions map from the installation-token response with the cached token, and add tokenCanRead.
  • server/internal/integrations/ghsnapshot/snapshot.go: decode check_suite.id and app.slug on check runs. fetchSupersededSuites reads the head's workflow runs (Actions read only), groups them by (workflow_id, event), and returns the check suites of cancelled runs that the newest run of their group replaced, subject to the conditions above. The workflow-runs list gets the same head, duplicate-ID and pagination checks as the other collections. A failed read rejects the snapshot, so the last-known snapshot stays, as for any other fetch error.
  • server/internal/integrations/ghsnapshot/rest_snapshot_test.go: TestFetchPRSnapshotRESTSupersededSuites covers:
  • apps/docs/content/docs/github-integration*.mdx: optional Actions read permission.

How to Test

cd server
go test -race ./internal/integrations/ghsnapshot/

Known limits:

  • Installations without Actions read keep today's behavior. The fix only takes effect after the App owner adds the permission and each installation approves it.
  • If the newer run finished all its current jobs but hasn't created the next one yet, the cancelled run is kept and the rollup stays FAILURE until the next refresh. This is unchanged from today.

Checklist

  • I have run tests locally and they pass
  • I have added or updated tests where applicable
  • I have updated relevant documentation to reflect my changes
  • I have considered and documented any risks above

AI Disclosure

AI tool used: Multica Agent

Prompt / approach: Checked the reporter's analysis against live GitHub API responses (multica, vite, aiohttp, pip), replayed candidate rules on real check data, then changed the rule to confirm workflow identity after review found that check names can collide across workflows.

Bohan-J and others added 2 commits November 3, 2026 14:34
…ed out of the rollup

filter=latest only drops older attempts inside one check suite. A second
workflow run on the same head is a separate suite, so a cancelled earlier
run kept the rollup at FAILURE after the newer run went green, and a
--until-pr checks wakeup never fired.

A suite is dropped only when GitHub concluded it cancelled and a newer
suite from the same app reports a check with the same name. The suites
list is read only when such a repeat exists.

Closes #9830

Co-authored-by: multica-agent <github@multica.ai>
…ropping them

Matching a cancelled check suite to a newer one by app and check name
could drop a run of one workflow because an unrelated workflow passed a
job with the same name, reporting a false success.

Only the Actions API says which workflow and event a check suite belongs
to. When the installation token has the optional Actions read permission,
read the head's workflow runs and drop a cancelled run only when a newer
run of the same workflow for the same event has reported checks and is
finished or still running. Without that permission nothing is dropped, as
before. Document the optional permission.

Co-authored-by: multica-agent <github@multica.ai>
@vercel

vercel Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
multica-docs Ready Ready Preview Nov 3, 2026 7:03am UTC

Request Review

@Bohan-J Bohan-J changed the title MUL-8510: fix(ghsnapshot): leave cancelled check suites that a newer run replaced out of the rollup MUL-8510: fix(ghsnapshot): drop cancelled workflow runs that a newer run of the same workflow replaced from the PR rollup Nov 3, 2026
@Bohan-J
Bohan-J merged commit 82492f9 into main Nov 3, 2026
17 checks passed
adambenhassen pushed a commit to adambenhassen/multica that referenced this pull request Nov 5, 2026
…run of the same workflow replaced from the PR rollup (multica-ai#9860)

* fix(ghsnapshot): leave cancelled check suites that a newer run replaced out of the rollup

filter=latest only drops older attempts inside one check suite. A second
workflow run on the same head is a separate suite, so a cancelled earlier
run kept the rollup at FAILURE after the newer run went green, and a
--until-pr checks wakeup never fired.

A suite is dropped only when GitHub concluded it cancelled and a newer
suite from the same app reports a check with the same name. The suites
list is read only when such a repeat exists.

Closes multica-ai#9830

Co-authored-by: multica-agent <github@multica.ai>

* fix(ghsnapshot): confirm replaced runs by workflow and event before dropping them

Matching a cancelled check suite to a newer one by app and check name
could drop a run of one workflow because an unrelated workflow passed a
job with the same name, reporting a false success.

Only the Actions API says which workflow and event a check suite belongs
to. When the installation token has the optional Actions read permission,
read the head's workflow runs and drop a cancelled run only when a newer
run of the same workflow for the same event has reported checks and is
finished or still running. Without that permission nothing is dropped, as
before. Document the optional permission.

Co-authored-by: multica-agent <github@multica.ai>

* test(ghsnapshot): drop the reviews route reverted on main

Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: multica-agent <github@multica.ai>
(cherry picked from commit 82492f9)
EulerBlind pushed a commit to EulerBlind/multica that referenced this pull request Nov 6, 2026
…run of the same workflow replaced from the PR rollup (multica-ai#9860)

* fix(ghsnapshot): leave cancelled check suites that a newer run replaced out of the rollup

filter=latest only drops older attempts inside one check suite. A second
workflow run on the same head is a separate suite, so a cancelled earlier
run kept the rollup at FAILURE after the newer run went green, and a
--until-pr checks wakeup never fired.

A suite is dropped only when GitHub concluded it cancelled and a newer
suite from the same app reports a check with the same name. The suites
list is read only when such a repeat exists.

Closes multica-ai#9830

Co-authored-by: multica-agent <github@multica.ai>

* fix(ghsnapshot): confirm replaced runs by workflow and event before dropping them

Matching a cancelled check suite to a newer one by app and check name
could drop a run of one workflow because an unrelated workflow passed a
job with the same name, reporting a false success.

Only the Actions API says which workflow and event a check suite belongs
to. When the installation token has the optional Actions read permission,
read the head's workflow runs and drop a cancelled run only when a newer
run of the same workflow for the same event has reported checks and is
finished or still running. Without that permission nothing is dropped, as
before. Document the optional permission.

Co-authored-by: multica-agent <github@multica.ai>

* test(ghsnapshot): drop the reviews route reverted on main

Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: multica-agent <github@multica.ai>
(cherry picked from commit 82492f9)

This branch was successfully deployed

1 active deployment
Preview – multica-docs — 39811f3d Deployed Nov 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant