Repository navigation
fix(provider-github): roll up only the latest check suite per workflow - #281
Merged
Merged
Conversation
A check suite superseded by a later run of the same workflow on the same commit (a concurrency-group cancel, a re-trigger) made a green PR read as checks failure, so pr.checks.completed rules fired on passing PRs (compliance-framework/api#584). Observe now reads each suite's App, workflow run (number, event, workflow) and createdAt/databaseId, and checksOf rolls up only the latest suite per (App, workflow, event), or per App for non-Actions suites. Re-runs keep the same suite, so the latest attempt counts. Observe's token gains actions: read for workflowRun. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A suite with an App but no workflowRun (another App's, or an Actions suite whose run is gone) got the kind "<app>", so unrelated suites superseded each other and a failing one could hide behind a green one. Only suites whose App, workflow and event are known are grouped now; any other suite always counts and supersedes nothing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
checksOfrolled every check suite of a PR's head commit intochecks{state, settled}, so a suite superseded by a later run of the same workflow (a concurrency-group cancel, a re-trigger) turned a green PR intofailure. Real case: compliance-framework/api#584, where a cancelledpreviewrun sits next to its green successor; GitHub shows the PR green, the factory saidfailure, andpr.checks.completedrules (the catalog's bump-fix) would fire on a passing PR.Stack: this is PR 1 of 2. PR 2 (
fx/ci-rerun-effect) adds theci.reruneffect op.Changes
observe.go): each check suite now also readsdatabaseId,createdAt,app { databaseId }andworkflowRun { runNumber event workflow { databaseId } }(field names checked against the live GitHub GraphQL API on api#584).checksOf→latestSuites: of the suites with check runs, only the latest of each workflow is rolled up. Kind = (App, workflow, event) for a GitHub Actions workflow run. A suite whose workflow can't be identified (another App's suite such as CodeRabbit's, an Actions suite with a nullworkflowRun, or a run with a nullworkflow) is never superseded and supersedes nothing. Latest = highest run number, then newestcreatedAt, then highestdatabaseId. The roll-up itself is unchanged (failure > pending > success, same conclusion sets, suites without runs ignored).failure, attempt 2success). The run'scheck_suite_idstays the same, and that suite's conclusion changes to the latest attempt's. So the latest attempt is what counts, with no attempt handling needed. This is recorded in thechecksOfdoc comment.observePermsaddsactions: read(forworkflowRun). Theccf-factoryApp already lists actions R in the LLD's App table, and theserve/tokenstest installations grant it.CheckSuitegainsID,Created,App,Workflow,RunNumber,Event. The fake GraphQL emits them and now requiresactionsforworkflowRun, the same way it checks the other field permissions.github-provider.md): the §Observe field list, the checks roll-up and the Observe token permissions are updated.Decisions
pushrun and apull_requestrun of the same workflow are separate checks, and in practice they are in separate concurrency groups. So a failingpushrun is not hidden by a greenpull_requestrun. The api#584 shape is allpull_request, so it is unaffected.workflowRun(other Apps, or an Actions suite whose run was deleted) or with a nullworkflowalways count and supersede nothing. Grouping them per App would let unrelated suites supersede each other, so a failing one could hide behind a green one.actions: readon Observe's token, with no fallback (confirmed in review). I couldn't check whether GitHub requires it forCheckSuite.workflowRunon a private repo, because public repos answer any token. Asking for it is cheaper than the failure mode where every PR's Observe gets FORBIDDEN. The prod installation already grants Actions: read. After deploy, an installation without Actions: read fails Observe, ReadContent and Project with ErrInvalid (the token mint namesactions, before any GraphQL call;TestObserveFieldPermissionscovers this).Deploy note
ccf-factoryApp must have Actions: read (the LLD already lists it, and the prod installation grants it). An installation without it fails Observe, ReadContent and Project with ErrInvalid after this is deployed.Verification
go test -race ./...: all pass exceptinternal/agent/host/provision TestBaseScriptRuns. That test also fails onmainon macOS (/etc/os-releasemissing). It is environmental and unrelated.make lint: 0 issues.make check-generated,make catalog,make openapi-lint: pass.TestObserveCheckscases:success, settledfailuresuccessfailurependingworkflowRunis never superseded and supersedes nothing, and two of them both countworkflow, in both directionstestdata/graphql/pr-superseded.json(the api#584 suites) with goldentestdata/golden/observe/pr-superseded.json.TestObserveFieldPermissions: also withactionsmissing.Open questions for reviewers
check_suite.completedwebhook'sevent.checks.statefact is still the one completed suite's own conclusion. Rules should readitem.pr.checks.state, which this PR fixes, notevent.checks.state.🤖 Generated with Claude Code