From 48d169fe7cd7efe1d83b48e11a0e7f3774f3123b Mon Sep 17 00:00:00 2001 From: "ccf-lisa[bot]" <286799724+ccf-lisa[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:19:16 -0300 Subject: [PATCH 1/3] fix(provider-github): let a workflow run supersede before it has jobs 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 --- .../provider-github/LLD/github-provider.md | 4 +- internal/provider/github/effects_ci.go | 4 +- internal/provider/github/effects_ci_test.go | 5 +- internal/provider/github/observe.go | 52 ++++++++++++------- internal/provider/github/observe_test.go | 42 ++++++++++++++- 5 files changed, 82 insertions(+), 25 deletions(-) diff --git a/design/workstreams/provider-github/LLD/github-provider.md b/design/workstreams/provider-github/LLD/github-provider.md index f3d6aee5..8eabc20c 100644 --- a/design/workstreams/provider-github/LLD/github-provider.md +++ b/design/workstreams/provider-github/LLD/github-provider.md @@ -161,7 +161,7 @@ Implemented in GH-S1-T04; the details are in [§Decisions taken in GH-S1-T04](#d - **GraphQL by hand, no new dependency.** The queries are constants in `observe.go`, posted by the new `tokens.Minter.GraphQL(ctx, token, op, query, vars, out)` and decoded with `encoding/json`, rather than through `githubv4`: errors then map like every other call (HTTP errors as in T01; a response with `errors` is a `*tokens.GraphQLError`, `NOT_FOUND` → `ErrNotFound`, `FORBIDDEN` → `tokens.ErrForbidden` and `provider.ErrForbidden`, a permission problem callers can tell from a transient one, `RATE_LIMITED` → `*provider.RetryableError`), the recorded responses under `testdata/graphql` are plain JSON, and `githubtest` answers by operation name. **A response with errors fails even with partial data**: an observation missing a field could make a rule merge. The endpoint is `/graphql`, or `https:///api/graphql` for a GHE REST base `…/api/v3` (`tokens.GraphQLURL`). `tokens` also gained `Do` (any method with an installation token, optional body and decoding), `NextPage` (the Link `rel="next"` query), and 410 (a deleted issue) now maps to `ErrNotFound`. - **`Observe(ref)`** is one `Observe` query on `repository.issueOrPullRequest(number)`, so a ref of the other kind (an issue ref naming a PR) is `ErrNotFound`, as the fake does, and an empty kind is filled in. Follow-up queries (`ObserveComments`, `ObserveThreads`, by node ID and cursor) read comments and review threads past the first 100, up to 10 more pages each (`ObserveComments` went with the markers' read-back: [§P3](#decisions-taken-with-p3-no-list-no-marker-read-back)). Labels (first 100), sub-issues (GitHub caps them at 100) and reviews (`last: 100`, not the LLD's 20, so an old approval isn't cut off by a chatty review) are one page. - Issue: state, labels, author, `subIssues` → `SubIssues`, `closedByPullRequestsReferences` (open and closed) → `LinkedPRs`, `comments.totalCount` → `Comments`. - - PR: `isDraft`, `headRefOid`, `baseRefName`, labels, author, `mergedAt`, `mergeCommit` (only once merged). `checks` rolls up the last commit's check suites that have check runs, **keeping only the latest suite of each workflow** (fx/checks-latest-suite): a GitHub Actions suite's kind is its App, workflow and event (`app{databaseId}`, `workflowRun{workflow{databaseId}, event}`); the latest is the highest workflow run number, then the newest `createdAt`, then the highest `databaseId`, and a suite with runs isn't superseded by a later one without. A suite whose workflow can't be told (no App, a null `workflowRun`: another App's suite such as CodeRabbit's, or an Actions suite whose run was deleted; a null `workflow`) is **never superseded and supersedes nothing**, so a failing suite can't hide behind an unrelated green one. So a run cancelled by its concurrency group, or a failed run re-triggered by a later green one, no longer turns a green PR into `failure` (compliance-framework/api#584: a cancelled `preview` run beside its green successor). A re-run (`rerun-failed-jobs`, re-run all jobs) is a new attempt of the same workflow run and GitHub keeps it in the same check suite, whose status and conclusion are the latest attempt's (checked on GitHub: a run's `check_suite_id` is unchanged by a re-run, and that suite went from failure to success), so attempts need no handling. The event is part of the kind because a `push` and a `pull_request` run of one workflow are separate checks (separate concurrency groups in practice): a failing `push` run isn't hidden by a green `pull_request` one. Of the kept suites: `failure` once one concluded failing (failure, timed out, cancelled, action required, startup failure, stale), else `pending` while one runs, else `success` (success, neutral, skipped); `settled` for `success` and `failure`; no such suite leaves `checks` empty. **Not `statusCheckRollup`** (fx/gh-observe-perms): it also covers commit statuses (`statuses: read`), which the Apps aren't granted, and check suites are what `pr.checks.completed` reports, so commit statuses don't count. `approvedBy` is each reviewer's **latest opinion** (`APPROVED`, `CHANGES_REQUESTED`, `DISMISSED`; comments and pending reviews don't change it) when it is an approval, at that review's commit, sorted. The factory's Apps map to their identity (`ccf-factory-reviewer[bot]` → `reviewer`, `ccf-factory[bot]` → `author`, from the slugs T02 learns), anyone else to their login; a deleted account counts for nobody. `unresolvedThreads` counts `isResolved: false` across all pages. + - PR: `isDraft`, `headRefOid`, `baseRefName`, labels, author, `mergedAt`, `mergeCommit` (only once merged). `checks` rolls up the last commit's check suites, **keeping only the latest suite of each workflow** (fx/checks-latest-suite): a GitHub Actions suite's kind is its App, workflow and event (`app{databaseId}`, `workflowRun{workflow{databaseId}, event}`); the latest is the highest workflow run number, then the newest `createdAt`, then the highest `databaseId`. **A suite of a known kind takes part whether or not it has check runs yet** (fx/checks-supersede-without-jobs): a workflow run's suite exists before its jobs do, so a later run supersedes from its creation and counts as `pending` until it concludes. Skipping it until its first job started let the run it superseded count as the latest in between: on compliance-framework/api#587 (v0.6.0), `preview` run 388's suite was created at 12:56:43 and run 387 (4 check runs) was cancelled at 12:56:44; the observation on 387's `check_suite` webhook at 12:56:48 still saw no check runs in 388's suite (its first job started at 12:56:47), so it rolled up `failure, settled` and a catalog rule dispatched a fix on a PR that went green at 12:57:05. A kind-known suite completed without check runs counts by its conclusion: GitHub completes a run without creating jobs when it failed to start (`startup_failure`, an invalid workflow file), was cancelled before a job started (`cancelled`, by a concurrency group whose later run then supersedes it) or awaits approval (`action_required`); none passed, so none is ignored. A suite whose workflow can't be told (no App, a null `workflowRun`: another App's suite such as CodeRabbit's, or an Actions suite whose run was deleted; a null `workflow`) is **never superseded and supersedes nothing**, so a failing suite can't hide behind an unrelated green one; it counts only with check runs, because GitHub leaves such a suite queued for every App that could run checks (Actions with no workflow for the event) and those never complete. So a run cancelled by its concurrency group, or a failed run re-triggered by a later green one, no longer turns a green PR into `failure` (compliance-framework/api#584: a cancelled `preview` run beside its green successor). A re-run (`rerun-failed-jobs`, re-run all jobs) is a new attempt of the same workflow run and GitHub keeps it in the same check suite, whose status and conclusion are the latest attempt's (checked on GitHub: a run's `check_suite_id` is unchanged by a re-run, and that suite went from failure to success), so attempts need no handling. The event is part of the kind because a `push` and a `pull_request` run of one workflow are separate checks (separate concurrency groups in practice): a failing `push` run isn't hidden by a green `pull_request` one. Of the kept suites: `failure` once one concluded failing (failure, timed out, cancelled, action required, startup failure, stale), else `pending` while one runs, else `success` (success, neutral, skipped); `settled` for `success` and `failure`; no such suite leaves `checks` empty. **Not `statusCheckRollup`** (fx/gh-observe-perms): it also covers commit statuses (`statuses: read`), which the Apps aren't granted, and check suites are what `pr.checks.completed` reports, so commit statuses don't count. `approvedBy` is each reviewer's **latest opinion** (`APPROVED`, `CHANGES_REQUESTED`, `DISMISSED`; comments and pending reviews don't change it) when it is an approval, at that review's commit, sorted. The factory's Apps map to their identity (`ccf-factory-reviewer[bot]` → `reviewer`, `ccf-factory[bot]` → `author`, from the slugs T02 learns), anyone else to their login; a deleted account counts for nobody. `unresolvedThreads` counts `isResolved: false` across all pages. - Author: `:` with REST's spelling (GraphQL's Bot `ccf-factory` is `ccf-factory[bot]`, as in webhooks), `isBot`, and `isFactory`/`identity` for the factory's Apps; nil for a deleted account. - Projections (removed with P3: [§P3](#decisions-taken-with-p3-no-list-no-marker-read-back)): the v1 markers among the comments **written by the projecting App** (the author identity); a look-alike by anyone else, or a marker of another version, is ignored (the latter with a warning). Of two markers for one work item the oldest comment wins. Comment bodies are read only for that and never returned. - **Other kinds**, because the work-item view and the rule controller's probe treat any error but `ErrNotFound` as fatal: a `repo` link (an event without an object) is open, or closed once archived (`ObserveRepo`, `metadata: read`); releases and deployments are immutable records, `closed` with no call. Any other kind is `ErrInvalid`. @@ -200,7 +200,7 @@ P3 §No rebuild from markers removed the work-item rebuild, the only reader of ` ## Decisions taken in fx/ci-rerun-effect -- **`ci.rerun`** (`effects_ci.go`) re-runs CI on a PR so an agent can treat a failure as a flake. It acts on a **PR** (in `prOps`: an issue target is `ErrInvalid`, an issue number `ErrNotFound`), as the request's identity with **`{actions: write, pull_requests: read}`** on the repo. Only the `ccf-factory` App (author) is meant to have Actions: write, so a reviewer task asking for it fails at the mint with `ErrInvalid`. Steps: read the PR (closed or merged: `ErrInvalid`) for its head SHA; list the head's workflow runs (`GET …/actions/runs?head_sha=`, `per_page=100`, up to 5 pages); keep the **latest run per workflow and event** (`latestRuns`: the same superseding rule and `runOrder` as `checksOf`, so a run its concurrency group cancelled isn't re-run when a later run of that workflow exists); of those, take the ones `completed` with `failure`, `timed_out`, `cancelled` or `startup_failure`. **A run whose `run_attempt` is `MaxRunAttempts` (3) or more is skipped**: the provider never takes a run past its third attempt, a safety net for rule-driven use. `failure` and `timed_out` get `rerun-failed-jobs`; `cancelled` and `startup_failure` get `rerun` (a run cancelled by its concurrency group, or one that failed to start, can have no failed job). **A run GitHub refuses** (403 or 422 on its re-run: over 30 days old, already re-running, …) **is skipped and the others are still re-run**. If at least one run was re-run, the op succeeds, and when some were skipped (refused or capped) the outcome is `partially-rerun: skipped run (refused|attempt ), …`. If nothing was re-run and something was refused, the op is `ErrInvalid` with every refusal. Otherwise, with nothing to re-run (green, running or capped), it succeeds with outcome **`nothing-to-rerun`**. The result's object is the PR and its URL the PR's checks page. +- **`ci.rerun`** (`effects_ci.go`) re-runs CI on a PR so an agent can treat a failure as a flake. It acts on a **PR** (in `prOps`: an issue target is `ErrInvalid`, an issue number `ErrNotFound`), as the request's identity with **`{actions: write, pull_requests: read}`** on the repo. Only the `ccf-factory` App (author) is meant to have Actions: write, so a reviewer task asking for it fails at the mint with `ErrInvalid`. Steps: read the PR (closed or merged: `ErrInvalid`) for its head SHA; list the head's workflow runs (`GET …/actions/runs?head_sha=`, `per_page=100`, up to 5 pages); keep the **latest run per workflow and event** (`latestRuns`: the same superseding rule and `runOrder` as `checksOf`, so a run its concurrency group cancelled isn't re-run when a later run of that workflow exists; the runs API lists a run from its creation, jobs or not, so a later run without jobs yet supersedes here as it does in `checksOf`); of those, take the ones `completed` with `failure`, `timed_out`, `cancelled` or `startup_failure`. **A run whose `run_attempt` is `MaxRunAttempts` (3) or more is skipped**: the provider never takes a run past its third attempt, a safety net for rule-driven use. `failure` and `timed_out` get `rerun-failed-jobs`; `cancelled` and `startup_failure` get `rerun` (a run cancelled by its concurrency group, or one that failed to start, can have no failed job). **A run GitHub refuses** (403 or 422 on its re-run: over 30 days old, already re-running, …) **is skipped and the others are still re-run**. If at least one run was re-run, the op succeeds, and when some were skipped (refused or capped) the outcome is `partially-rerun: skipped run (refused|attempt ), …`. If nothing was re-run and something was refused, the op is `ErrInvalid` with every refusal. Otherwise, with nothing to re-run (green, running or capped), it succeeds with outcome **`nothing-to-rerun`**. The result's object is the PR and its URL the PR's checks page. - **Idempotency: once per task per key on the Effector path; per (key, head SHA) in the provider.** On the agent path, `CreateEffect` (`internal/server/effects.go`) replays any recorded `effectID(task, key)` before the provider is called, and every successful Apply is recorded (`nothing-to-rerun` included). So **`--key k` acts once per task**, whatever the head. To re-run a new head in the same task, use a per-head key (`--key rerun-`, as the catalog does) or omit `--key` (each successful call then gets a fresh key). This is the contract; the head SHA is deliberately not folded into the server's effect key. In the provider, the effective key is `@`, and the Conn remembers the effective keys it re-ran something with (`rerunLog`, the last 1024): the same key on the same head is a replay (`Replayed`, nothing posted). That covers what the store doesn't: a rule's effect is applied before it is recorded and again when its reconcile retries (rule keys are per event), and an Effector call whose Apply succeeded but whose record failed is applied again. A re-run leaves nothing on GitHub that could carry the key (the endpoints take no body), so the replay can't be read back from GitHub as the other ops' are. Nothing to re-run isn't remembered. The memory belongs to the process: a replay it has forgotten still posts nothing while the runs it re-ran are queued or running, because only completed runs are re-run. A retry inside `Apply` (rate limit, 5xx) re-lists the runs, so a run re-run before the failure is queued by then and isn't posted again. - **Errors.** A 404 (the PR or a run) is `ErrNotFound`. A 403 that isn't a rate limit is `ErrInvalid`. When GitHub says the integration can't access the resource, or the installation wasn't granted the permission at the mint, the message names **Actions: write** (or **Pull requests: read** for the PR read). Any other 403 (a run over 30 days old, a run already running) keeps GitHub's message. A 422 is `ErrInvalid`. On a run's re-run, 403 and 422 skip that run rather than fail the op (see above). Rate limits and 5xx are retried, as for the other ops. - **Deploy prerequisite.** The `ccf-factory` App needs **Actions: write**, a manual change in the GitHub App's settings that each installation then accepts (see [rollout.md §GitHub Apps](../../poc-rollout/LLD/rollout.md)). diff --git a/internal/provider/github/effects_ci.go b/internal/provider/github/effects_ci.go index bab68c0a..564ff381 100644 --- a/internal/provider/github/effects_ci.go +++ b/internal/provider/github/effects_ci.go @@ -231,7 +231,9 @@ func (c *Conn) headRuns(ctx context.Context, tok, repo, sha string) ([]ghWorkflo // latestRuns are the runs no later run of the same workflow and event supersedes, in their // order: checksOf's rule for check suites (a run cancelled by its concurrency group, or -// re-triggered, is superseded by the later run). +// re-triggered, is superseded by the later run). The runs API lists a run from its creation, +// before it has jobs, so a later run supersedes here from the start as its suite does in +// latestSuites. func latestRuns(runs []ghWorkflowRun) []ghWorkflowRun { kind := func(r ghWorkflowRun) string { return strconv.FormatInt(r.WorkflowID, 10) + "/" + r.Event } order := func(r ghWorkflowRun) runOrder { return runOrder{number: r.RunNumber, created: r.CreatedAt, id: r.ID} } diff --git a/internal/provider/github/effects_ci_test.go b/internal/provider/github/effects_ci_test.go index b7a38ef3..e5664c07 100644 --- a/internal/provider/github/effects_ci_test.go +++ b/internal/provider/github/effects_ci_test.go @@ -133,7 +133,10 @@ func TestApplyCIRerunNothing(t *testing.T) { } e.srv.AddWorkflowRuns(docs, wfRun(1, ciWorkflow, 10, "completed", "failure"), wfRun(2, ciWorkflow, 11, "completed", "success"), // superseded failure - wfRun(3, preview, 20, "queued", ""), wfRun(4, lint, 30, "completed", "skipped")) + wfRun(3, preview, 20, "queued", ""), wfRun(4, lint, 30, "completed", "skipped"), + // compliance-framework/api#587: a run its concurrency group cancelled, superseded by a + // later run that has no jobs yet (the runs API lists it all the same). + wfRun(5, preview, 19, "completed", "cancelled")) if res, err := c.Apply(ctx, ciRerun("")); err != nil || res.Outcome != github.OutcomeNothingToRerun || res.Replayed { t.Fatalf("green and running: %+v, %v", res, err) } diff --git a/internal/provider/github/observe.go b/internal/provider/github/observe.go index 8346c002..f073928c 100644 --- a/internal/provider/github/observe.go +++ b/internal/provider/github/observe.go @@ -402,14 +402,15 @@ func prObservation(o *gqlObject, bots map[string]string) *provider.PRObservation // combined state does: "failure" once a suite concluded failing (failure, timed out, // cancelled, action required, startup failure, stale), else "pending" while one hasn't // concluded, else "success" (success, neutral, skipped); settled for success and failure. -// Suites without check runs don't count: GitHub leaves one queued for every App that could -// run checks (Actions with no workflow for the event), and they never complete. No suite -// with runs leaves checks empty. The first 100 suites are read (one page; a commit has one per -// App and workflow run). +// A suite whose workflow can't be told and that has no check runs doesn't count: GitHub leaves +// one queued for every App that could run checks (Actions with no workflow for the event), and +// they never complete. No suite that counts leaves checks empty. The first 100 suites are read +// (one page; a commit has one per App and workflow run). // // Only the latest suite of each workflow counts (latestSuites): a workflow run superseded by a // later run of the same workflow for the same event (a concurrency group cancelling it, a -// re-trigger) no longer makes a green PR "failure". Re-running a run (rerun-failed-jobs, re-run +// re-trigger) no longer makes a green PR "failure", even while the later run has no check runs +// yet: it counts as pending until its jobs conclude (compliance-framework/api#587). Re-running a run (rerun-failed-jobs, re-run // all jobs) is a new attempt of the same run, and GitHub reports it in the same check suite, // whose status and conclusion are the latest attempt's (checked against a re-run on GitHub: // the run's check_suite_id is the same suite, which went from failure to success), so a @@ -446,19 +447,31 @@ func checksOf(suites []gqlCheckSuite) provider.Checks { return provider.Checks{State: "success", Settled: true} } -// latestSuites are the suites with check runs that no later suite of the same kind supersedes, -// in their order. A suite's kind (suiteKind) is its App, workflow and event: only workflow runs -// (GitHub Actions) supersede each other. Of a kind, the latest is the highest run number, then -// the newest createdAt, then the highest databaseId. A suite whose workflow can't be told (no -// App, no workflow run: another App's suite, or an Actions suite whose run was deleted; or a -// run without its workflow) is its own kind: it always counts and supersedes nothing, so a -// failing suite can't hide behind an unrelated green one. +// latestSuites are the suites that count, in their order: of each kind (suiteKind: its App, +// workflow and event; only workflow runs, GitHub Actions, supersede each other) the latest +// suite, and every suite whose kind can't be told that has check runs. Of a kind, the latest is +// the highest run number, then the newest createdAt, then the highest databaseId. +// +// A suite of a known kind takes part with or without check runs. A workflow run's suite exists +// before its jobs do, so the later run of a re-triggered workflow (a concurrency group +// cancelling the earlier one) supersedes it from the start and counts as pending until it +// concludes; skipping it until its first job started let the cancelled run count as the latest +// in between (compliance-framework/api#587: run 388's suite was created before run 387 was +// cancelled, and had no check runs yet when 387's check_suite webhook was observed). A completed +// one without check runs counts by its conclusion: GitHub completes a run without creating jobs +// when it failed to start (startup_failure: an invalid workflow file), was cancelled before a job +// started (cancelled: by its concurrency group, which then has a later run that supersedes it) +// or awaits approval (action_required); none of them passed, and ignoring it would let an older +// run of the same workflow, or nothing, stand for it. +// +// A suite whose workflow can't be told (no App, no workflow run: another App's suite, or an +// Actions suite whose run was deleted; or a run without its workflow) is its own kind: it counts +// when it has check runs and supersedes nothing, so a failing suite can't hide behind an +// unrelated green one. Without check runs it doesn't count: those are GitHub's placeholders, +// one queued for every App that could run checks, which never complete. func latestSuites(suites []gqlCheckSuite) []gqlCheckSuite { latest := map[string]int{} // kind → index of its latest suite for i, s := range suites { - if s.CheckRuns.TotalCount == 0 { - continue - } kind, ok := suiteKind(s) if !ok { continue @@ -469,11 +482,12 @@ func latestSuites(suites []gqlCheckSuite) []gqlCheckSuite { } var out []gqlCheckSuite for i, s := range suites { - if s.CheckRuns.TotalCount == 0 { - continue - } - if kind, ok := suiteKind(s); ok && latest[kind] != i { + kind, ok := suiteKind(s) + switch { + case ok && latest[kind] != i: continue // superseded + case !ok && s.CheckRuns.TotalCount == 0: + continue // a placeholder } out = append(out, s) } diff --git a/internal/provider/github/observe_test.go b/internal/provider/github/observe_test.go index c37f6582..20ed620e 100644 --- a/internal/provider/github/observe_test.go +++ b/internal/provider/github/observe_test.go @@ -366,7 +366,7 @@ func TestObserveChecks(t *testing.T) { suite := func(status, conclusion string, runs int) githubtest.CheckSuite { return githubtest.CheckSuite{Status: status, Conclusion: conclusion, Runs: runs} } - // The Apps and workflows of compliance-framework/api#584's head commit. + // The Apps and workflows of compliance-framework/api#584's and api#587's head commits. const ( actions = 15368 coderabbit = 347564 @@ -447,9 +447,47 @@ func TestObserveChecks(t *testing.T) { {"the latest run in progress, an older one failed", []githubtest.CheckSuite{ run(ciWF, 10, 1, "COMPLETED", "FAILURE", 3), run(ciWF, 11, 2, "IN_PROGRESS", "", 3), }, provider.Checks{State: "pending"}}, - {"a later run without check runs doesn't supersede", []githubtest.CheckSuite{ + // A workflow run's suite exists before its jobs: without check runs yet it still + // supersedes, and counts as pending. + {"api#587: a cancelled run superseded by one without jobs yet", []githubtest.CheckSuite{ + app(coderabbit, 1, "COMPLETED", "SKIPPED", 1), + run(previewWF, 387, 2, "COMPLETED", "CANCELLED", 4), + run(ciWF, 2530, 3, "COMPLETED", "SUCCESS", 10), + run(previewWF, 388, 4, "IN_PROGRESS", "", 0), + }, provider.Checks{State: "pending"}}, + {"api#587: the later run then passed", []githubtest.CheckSuite{ + app(coderabbit, 1, "COMPLETED", "SKIPPED", 1), + run(previewWF, 387, 2, "COMPLETED", "CANCELLED", 4), + run(ciWF, 2530, 3, "COMPLETED", "SUCCESS", 10), + run(previewWF, 388, 4, "COMPLETED", "SUCCESS", 4), + }, provider.Checks{State: "success", Settled: true}}, + {"a later queued run without check runs supersedes a failed one", []githubtest.CheckSuite{ run(ciWF, 10, 1, "COMPLETED", "FAILURE", 3), run(ciWF, 11, 2, "QUEUED", "", 0), + }, provider.Checks{State: "pending"}}, + {"a later run without check runs supersedes a green one too", []githubtest.CheckSuite{ + run(ciWF, 10, 1, "COMPLETED", "SUCCESS", 3), run(ciWF, 11, 2, "QUEUED", "", 0), + }, provider.Checks{State: "pending"}}, + {"an earlier run without check runs is superseded", []githubtest.CheckSuite{ + run(ciWF, 10, 1, "COMPLETED", "CANCELLED", 0), run(ciWF, 11, 2, "COMPLETED", "SUCCESS", 3), + }, provider.Checks{State: "success", Settled: true}}, + {"only a run without check runs: pending", []githubtest.CheckSuite{run(ciWF, 10, 1, "QUEUED", "", 0)}, provider.Checks{State: "pending"}}, + // A run completed without jobs counts by its conclusion. + {"the latest run failed to start", []githubtest.CheckSuite{ + run(ciWF, 10, 1, "COMPLETED", "SUCCESS", 3), run(ciWF, 11, 2, "COMPLETED", "STARTUP_FAILURE", 0), + }, provider.Checks{State: "failure", Settled: true}}, + {"the latest run cancelled before a job started", []githubtest.CheckSuite{ + run(ciWF, 10, 1, "COMPLETED", "SUCCESS", 3), run(ciWF, 11, 2, "COMPLETED", "CANCELLED", 0), }, provider.Checks{State: "failure", Settled: true}}, + {"the latest run completed without jobs, passing", []githubtest.CheckSuite{ + run(ciWF, 10, 1, "COMPLETED", "FAILURE", 3), run(ciWF, 11, 2, "COMPLETED", "SUCCESS", 0), + }, provider.Checks{State: "success", Settled: true}}, + // A suite whose workflow can't be told counts only with check runs: GitHub's placeholders. + {"an Actions placeholder without a workflow run is ignored", []githubtest.CheckSuite{ + run(ciWF, 10, 1, "COMPLETED", "SUCCESS", 3), app(actions, 2, "QUEUED", "", 0), app(coderabbit, 3, "QUEUED", "", 0), + }, provider.Checks{State: "success", Settled: true}}, + {"a run with a null workflow and no check runs is ignored", []githubtest.CheckSuite{ + run(ciWF, 10, 1, "COMPLETED", "SUCCESS", 3), noWorkflow(run(ciWF, 11, 2, "QUEUED", "", 0)), + }, provider.Checks{State: "success", Settled: true}}, {"another event's run of the same workflow still counts", []githubtest.CheckSuite{ event(run(ciWF, 10, 1, "COMPLETED", "FAILURE", 3), "push"), run(ciWF, 11, 2, "COMPLETED", "SUCCESS", 3), }, provider.Checks{State: "failure", Settled: true}}, From bd0ffe04a0f0db939d46e97c897c7d5cc89ffbb0 Mon Sep 17 00:00:00 2001 From: "ccf-lisa[bot]" <286799724+ccf-lisa[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:20:06 -0300 Subject: [PATCH 2/3] docs(provider-github): rewrap checksOf and qualify the concurrency-cancel case Co-Authored-By: Claude Opus 5.5 --- .../provider-github/LLD/github-provider.md | 2 +- internal/provider/github/observe.go | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/design/workstreams/provider-github/LLD/github-provider.md b/design/workstreams/provider-github/LLD/github-provider.md index 8eabc20c..baee4f00 100644 --- a/design/workstreams/provider-github/LLD/github-provider.md +++ b/design/workstreams/provider-github/LLD/github-provider.md @@ -161,7 +161,7 @@ Implemented in GH-S1-T04; the details are in [§Decisions taken in GH-S1-T04](#d - **GraphQL by hand, no new dependency.** The queries are constants in `observe.go`, posted by the new `tokens.Minter.GraphQL(ctx, token, op, query, vars, out)` and decoded with `encoding/json`, rather than through `githubv4`: errors then map like every other call (HTTP errors as in T01; a response with `errors` is a `*tokens.GraphQLError`, `NOT_FOUND` → `ErrNotFound`, `FORBIDDEN` → `tokens.ErrForbidden` and `provider.ErrForbidden`, a permission problem callers can tell from a transient one, `RATE_LIMITED` → `*provider.RetryableError`), the recorded responses under `testdata/graphql` are plain JSON, and `githubtest` answers by operation name. **A response with errors fails even with partial data**: an observation missing a field could make a rule merge. The endpoint is `/graphql`, or `https:///api/graphql` for a GHE REST base `…/api/v3` (`tokens.GraphQLURL`). `tokens` also gained `Do` (any method with an installation token, optional body and decoding), `NextPage` (the Link `rel="next"` query), and 410 (a deleted issue) now maps to `ErrNotFound`. - **`Observe(ref)`** is one `Observe` query on `repository.issueOrPullRequest(number)`, so a ref of the other kind (an issue ref naming a PR) is `ErrNotFound`, as the fake does, and an empty kind is filled in. Follow-up queries (`ObserveComments`, `ObserveThreads`, by node ID and cursor) read comments and review threads past the first 100, up to 10 more pages each (`ObserveComments` went with the markers' read-back: [§P3](#decisions-taken-with-p3-no-list-no-marker-read-back)). Labels (first 100), sub-issues (GitHub caps them at 100) and reviews (`last: 100`, not the LLD's 20, so an old approval isn't cut off by a chatty review) are one page. - Issue: state, labels, author, `subIssues` → `SubIssues`, `closedByPullRequestsReferences` (open and closed) → `LinkedPRs`, `comments.totalCount` → `Comments`. - - PR: `isDraft`, `headRefOid`, `baseRefName`, labels, author, `mergedAt`, `mergeCommit` (only once merged). `checks` rolls up the last commit's check suites, **keeping only the latest suite of each workflow** (fx/checks-latest-suite): a GitHub Actions suite's kind is its App, workflow and event (`app{databaseId}`, `workflowRun{workflow{databaseId}, event}`); the latest is the highest workflow run number, then the newest `createdAt`, then the highest `databaseId`. **A suite of a known kind takes part whether or not it has check runs yet** (fx/checks-supersede-without-jobs): a workflow run's suite exists before its jobs do, so a later run supersedes from its creation and counts as `pending` until it concludes. Skipping it until its first job started let the run it superseded count as the latest in between: on compliance-framework/api#587 (v0.6.0), `preview` run 388's suite was created at 12:56:43 and run 387 (4 check runs) was cancelled at 12:56:44; the observation on 387's `check_suite` webhook at 12:56:48 still saw no check runs in 388's suite (its first job started at 12:56:47), so it rolled up `failure, settled` and a catalog rule dispatched a fix on a PR that went green at 12:57:05. A kind-known suite completed without check runs counts by its conclusion: GitHub completes a run without creating jobs when it failed to start (`startup_failure`, an invalid workflow file), was cancelled before a job started (`cancelled`, by a concurrency group whose later run then supersedes it) or awaits approval (`action_required`); none passed, so none is ignored. A suite whose workflow can't be told (no App, a null `workflowRun`: another App's suite such as CodeRabbit's, or an Actions suite whose run was deleted; a null `workflow`) is **never superseded and supersedes nothing**, so a failing suite can't hide behind an unrelated green one; it counts only with check runs, because GitHub leaves such a suite queued for every App that could run checks (Actions with no workflow for the event) and those never complete. So a run cancelled by its concurrency group, or a failed run re-triggered by a later green one, no longer turns a green PR into `failure` (compliance-framework/api#584: a cancelled `preview` run beside its green successor). A re-run (`rerun-failed-jobs`, re-run all jobs) is a new attempt of the same workflow run and GitHub keeps it in the same check suite, whose status and conclusion are the latest attempt's (checked on GitHub: a run's `check_suite_id` is unchanged by a re-run, and that suite went from failure to success), so attempts need no handling. The event is part of the kind because a `push` and a `pull_request` run of one workflow are separate checks (separate concurrency groups in practice): a failing `push` run isn't hidden by a green `pull_request` one. Of the kept suites: `failure` once one concluded failing (failure, timed out, cancelled, action required, startup failure, stale), else `pending` while one runs, else `success` (success, neutral, skipped); `settled` for `success` and `failure`; no such suite leaves `checks` empty. **Not `statusCheckRollup`** (fx/gh-observe-perms): it also covers commit statuses (`statuses: read`), which the Apps aren't granted, and check suites are what `pr.checks.completed` reports, so commit statuses don't count. `approvedBy` is each reviewer's **latest opinion** (`APPROVED`, `CHANGES_REQUESTED`, `DISMISSED`; comments and pending reviews don't change it) when it is an approval, at that review's commit, sorted. The factory's Apps map to their identity (`ccf-factory-reviewer[bot]` → `reviewer`, `ccf-factory[bot]` → `author`, from the slugs T02 learns), anyone else to their login; a deleted account counts for nobody. `unresolvedThreads` counts `isResolved: false` across all pages. + - PR: `isDraft`, `headRefOid`, `baseRefName`, labels, author, `mergedAt`, `mergeCommit` (only once merged). `checks` rolls up the last commit's check suites, **keeping only the latest suite of each workflow** (fx/checks-latest-suite): a GitHub Actions suite's kind is its App, workflow and event (`app{databaseId}`, `workflowRun{workflow{databaseId}, event}`); the latest is the highest workflow run number, then the newest `createdAt`, then the highest `databaseId`. **A suite of a known kind takes part whether or not it has check runs yet** (fx/checks-supersede-without-jobs): a workflow run's suite exists before its jobs do, so a later run supersedes from its creation and counts as `pending` until it concludes. Skipping it until its first job started let the run it superseded count as the latest in between: on compliance-framework/api#587 (v0.6.0), `preview` run 388's suite was created at 12:56:43 and run 387 (4 check runs) was cancelled at 12:56:44; the observation on 387's `check_suite` webhook at 12:56:48 still saw no check runs in 388's suite (its first job started at 12:56:47), so it rolled up `failure, settled` and a catalog rule dispatched a fix on a PR that went green at 12:57:05. A kind-known suite completed without check runs counts by its conclusion: GitHub completes a run without creating jobs when it failed to start (`startup_failure`, an invalid workflow file), was cancelled before a job started (`cancelled`, usually by its concurrency group; a later run of the same workflow and event then supersedes it) or awaits approval (`action_required`); none passed, so none is ignored. A suite whose workflow can't be told (no App, a null `workflowRun`: another App's suite such as CodeRabbit's, or an Actions suite whose run was deleted; a null `workflow`) is **never superseded and supersedes nothing**, so a failing suite can't hide behind an unrelated green one; it counts only with check runs, because GitHub leaves such a suite queued for every App that could run checks (Actions with no workflow for the event) and those never complete. So a run cancelled by its concurrency group, or a failed run re-triggered by a later green one, no longer turns a green PR into `failure` (compliance-framework/api#584: a cancelled `preview` run beside its green successor). A re-run (`rerun-failed-jobs`, re-run all jobs) is a new attempt of the same workflow run and GitHub keeps it in the same check suite, whose status and conclusion are the latest attempt's (checked on GitHub: a run's `check_suite_id` is unchanged by a re-run, and that suite went from failure to success), so attempts need no handling. The event is part of the kind because a `push` and a `pull_request` run of one workflow are separate checks (separate concurrency groups in practice): a failing `push` run isn't hidden by a green `pull_request` one. Of the kept suites: `failure` once one concluded failing (failure, timed out, cancelled, action required, startup failure, stale), else `pending` while one runs, else `success` (success, neutral, skipped); `settled` for `success` and `failure`; no such suite leaves `checks` empty. **Not `statusCheckRollup`** (fx/gh-observe-perms): it also covers commit statuses (`statuses: read`), which the Apps aren't granted, and check suites are what `pr.checks.completed` reports, so commit statuses don't count. `approvedBy` is each reviewer's **latest opinion** (`APPROVED`, `CHANGES_REQUESTED`, `DISMISSED`; comments and pending reviews don't change it) when it is an approval, at that review's commit, sorted. The factory's Apps map to their identity (`ccf-factory-reviewer[bot]` → `reviewer`, `ccf-factory[bot]` → `author`, from the slugs T02 learns), anyone else to their login; a deleted account counts for nobody. `unresolvedThreads` counts `isResolved: false` across all pages. - Author: `:` with REST's spelling (GraphQL's Bot `ccf-factory` is `ccf-factory[bot]`, as in webhooks), `isBot`, and `isFactory`/`identity` for the factory's Apps; nil for a deleted account. - Projections (removed with P3: [§P3](#decisions-taken-with-p3-no-list-no-marker-read-back)): the v1 markers among the comments **written by the projecting App** (the author identity); a look-alike by anyone else, or a marker of another version, is ignored (the latter with a warning). Of two markers for one work item the oldest comment wins. Comment bodies are read only for that and never returned. - **Other kinds**, because the work-item view and the rule controller's probe treat any error but `ErrNotFound` as fatal: a `repo` link (an event without an object) is open, or closed once archived (`ObserveRepo`, `metadata: read`); releases and deployments are immutable records, `closed` with no call. Any other kind is `ErrInvalid`. diff --git a/internal/provider/github/observe.go b/internal/provider/github/observe.go index f073928c..8f61471e 100644 --- a/internal/provider/github/observe.go +++ b/internal/provider/github/observe.go @@ -410,11 +410,12 @@ func prObservation(o *gqlObject, bots map[string]string) *provider.PRObservation // Only the latest suite of each workflow counts (latestSuites): a workflow run superseded by a // later run of the same workflow for the same event (a concurrency group cancelling it, a // re-trigger) no longer makes a green PR "failure", even while the later run has no check runs -// yet: it counts as pending until its jobs conclude (compliance-framework/api#587). Re-running a run (rerun-failed-jobs, re-run -// all jobs) is a new attempt of the same run, and GitHub reports it in the same check suite, -// whose status and conclusion are the latest attempt's (checked against a re-run on GitHub: -// the run's check_suite_id is the same suite, which went from failure to success), so a -// re-run that passed counts as passed without any attempt handling here. +// yet: it counts as pending until it concludes (compliance-framework/api#587). Re-running a +// run (rerun-failed-jobs, re-run all jobs) is a new attempt of the same run, and GitHub reports +// it in the same check suite, whose status and conclusion are the latest attempt's (checked +// against a re-run on GitHub: the run's check_suite_id is the same suite, which went from +// failure to success), so a re-run that passed counts as passed without any attempt handling +// here. // // Check suites are what checks: read reaches, and what pr.checks.completed (check_suite // webhooks) reports; commit statuses (the statuses API) aren't read: the App isn't granted @@ -460,9 +461,9 @@ func checksOf(suites []gqlCheckSuite) provider.Checks { // cancelled, and had no check runs yet when 387's check_suite webhook was observed). A completed // one without check runs counts by its conclusion: GitHub completes a run without creating jobs // when it failed to start (startup_failure: an invalid workflow file), was cancelled before a job -// started (cancelled: by its concurrency group, which then has a later run that supersedes it) -// or awaits approval (action_required); none of them passed, and ignoring it would let an older -// run of the same workflow, or nothing, stand for it. +// started (cancelled: usually by its concurrency group, and a later run of the same workflow +// and event then supersedes it) or awaits approval (action_required); none of them passed, and +// ignoring it would let an older run of the same workflow, or nothing, stand for it. // // A suite whose workflow can't be told (no App, no workflow run: another App's suite, or an // Actions suite whose run was deleted; or a run without its workflow) is its own kind: it counts From bb4e5d0856342b63654c1d8acada409f18a26e8d Mon Sep 17 00:00:00 2001 From: "ccf-lisa[bot]" <286799724+ccf-lisa[bot]@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:31:10 -0300 Subject: [PATCH 3/3] test(provider-github): cover a zero-job run awaiting approval; document what consumers see Co-Authored-By: Claude Opus 5.5 --- design/workstreams/provider-github/LLD/github-provider.md | 2 +- internal/provider/github/observe_test.go | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/design/workstreams/provider-github/LLD/github-provider.md b/design/workstreams/provider-github/LLD/github-provider.md index baee4f00..9ba162d0 100644 --- a/design/workstreams/provider-github/LLD/github-provider.md +++ b/design/workstreams/provider-github/LLD/github-provider.md @@ -161,7 +161,7 @@ Implemented in GH-S1-T04; the details are in [§Decisions taken in GH-S1-T04](#d - **GraphQL by hand, no new dependency.** The queries are constants in `observe.go`, posted by the new `tokens.Minter.GraphQL(ctx, token, op, query, vars, out)` and decoded with `encoding/json`, rather than through `githubv4`: errors then map like every other call (HTTP errors as in T01; a response with `errors` is a `*tokens.GraphQLError`, `NOT_FOUND` → `ErrNotFound`, `FORBIDDEN` → `tokens.ErrForbidden` and `provider.ErrForbidden`, a permission problem callers can tell from a transient one, `RATE_LIMITED` → `*provider.RetryableError`), the recorded responses under `testdata/graphql` are plain JSON, and `githubtest` answers by operation name. **A response with errors fails even with partial data**: an observation missing a field could make a rule merge. The endpoint is `/graphql`, or `https:///api/graphql` for a GHE REST base `…/api/v3` (`tokens.GraphQLURL`). `tokens` also gained `Do` (any method with an installation token, optional body and decoding), `NextPage` (the Link `rel="next"` query), and 410 (a deleted issue) now maps to `ErrNotFound`. - **`Observe(ref)`** is one `Observe` query on `repository.issueOrPullRequest(number)`, so a ref of the other kind (an issue ref naming a PR) is `ErrNotFound`, as the fake does, and an empty kind is filled in. Follow-up queries (`ObserveComments`, `ObserveThreads`, by node ID and cursor) read comments and review threads past the first 100, up to 10 more pages each (`ObserveComments` went with the markers' read-back: [§P3](#decisions-taken-with-p3-no-list-no-marker-read-back)). Labels (first 100), sub-issues (GitHub caps them at 100) and reviews (`last: 100`, not the LLD's 20, so an old approval isn't cut off by a chatty review) are one page. - Issue: state, labels, author, `subIssues` → `SubIssues`, `closedByPullRequestsReferences` (open and closed) → `LinkedPRs`, `comments.totalCount` → `Comments`. - - PR: `isDraft`, `headRefOid`, `baseRefName`, labels, author, `mergedAt`, `mergeCommit` (only once merged). `checks` rolls up the last commit's check suites, **keeping only the latest suite of each workflow** (fx/checks-latest-suite): a GitHub Actions suite's kind is its App, workflow and event (`app{databaseId}`, `workflowRun{workflow{databaseId}, event}`); the latest is the highest workflow run number, then the newest `createdAt`, then the highest `databaseId`. **A suite of a known kind takes part whether or not it has check runs yet** (fx/checks-supersede-without-jobs): a workflow run's suite exists before its jobs do, so a later run supersedes from its creation and counts as `pending` until it concludes. Skipping it until its first job started let the run it superseded count as the latest in between: on compliance-framework/api#587 (v0.6.0), `preview` run 388's suite was created at 12:56:43 and run 387 (4 check runs) was cancelled at 12:56:44; the observation on 387's `check_suite` webhook at 12:56:48 still saw no check runs in 388's suite (its first job started at 12:56:47), so it rolled up `failure, settled` and a catalog rule dispatched a fix on a PR that went green at 12:57:05. A kind-known suite completed without check runs counts by its conclusion: GitHub completes a run without creating jobs when it failed to start (`startup_failure`, an invalid workflow file), was cancelled before a job started (`cancelled`, usually by its concurrency group; a later run of the same workflow and event then supersedes it) or awaits approval (`action_required`); none passed, so none is ignored. A suite whose workflow can't be told (no App, a null `workflowRun`: another App's suite such as CodeRabbit's, or an Actions suite whose run was deleted; a null `workflow`) is **never superseded and supersedes nothing**, so a failing suite can't hide behind an unrelated green one; it counts only with check runs, because GitHub leaves such a suite queued for every App that could run checks (Actions with no workflow for the event) and those never complete. So a run cancelled by its concurrency group, or a failed run re-triggered by a later green one, no longer turns a green PR into `failure` (compliance-framework/api#584: a cancelled `preview` run beside its green successor). A re-run (`rerun-failed-jobs`, re-run all jobs) is a new attempt of the same workflow run and GitHub keeps it in the same check suite, whose status and conclusion are the latest attempt's (checked on GitHub: a run's `check_suite_id` is unchanged by a re-run, and that suite went from failure to success), so attempts need no handling. The event is part of the kind because a `push` and a `pull_request` run of one workflow are separate checks (separate concurrency groups in practice): a failing `push` run isn't hidden by a green `pull_request` one. Of the kept suites: `failure` once one concluded failing (failure, timed out, cancelled, action required, startup failure, stale), else `pending` while one runs, else `success` (success, neutral, skipped); `settled` for `success` and `failure`; no such suite leaves `checks` empty. **Not `statusCheckRollup`** (fx/gh-observe-perms): it also covers commit statuses (`statuses: read`), which the Apps aren't granted, and check suites are what `pr.checks.completed` reports, so commit statuses don't count. `approvedBy` is each reviewer's **latest opinion** (`APPROVED`, `CHANGES_REQUESTED`, `DISMISSED`; comments and pending reviews don't change it) when it is an approval, at that review's commit, sorted. The factory's Apps map to their identity (`ccf-factory-reviewer[bot]` → `reviewer`, `ccf-factory[bot]` → `author`, from the slugs T02 learns), anyone else to their login; a deleted account counts for nobody. `unresolvedThreads` counts `isResolved: false` across all pages. + - PR: `isDraft`, `headRefOid`, `baseRefName`, labels, author, `mergedAt`, `mergeCommit` (only once merged). `checks` rolls up the last commit's check suites, **keeping only the latest suite of each workflow** (fx/checks-latest-suite): a GitHub Actions suite's kind is its App, workflow and event (`app{databaseId}`, `workflowRun{workflow{databaseId}, event}`); the latest is the highest workflow run number, then the newest `createdAt`, then the highest `databaseId`. **A suite of a known kind takes part whether or not it has check runs yet** (fx/checks-supersede-without-jobs): a workflow run's suite exists before its jobs do, so a later run supersedes from its creation and counts as `pending` until it concludes. Skipping it until its first job started let the run it superseded count as the latest in between: on compliance-framework/api#587 (v0.6.0), `preview` run 388's suite was created at 12:56:43 and run 387 (4 check runs) was cancelled at 12:56:44; the observation on 387's `check_suite` webhook at 12:56:48 still saw no check runs in 388's suite (its first job started at 12:56:47), so it rolled up `failure, settled` and a catalog rule dispatched a fix on a PR that went green at 12:57:05. A kind-known suite completed without check runs counts by its conclusion: GitHub completes a run without creating jobs when it failed to start (`startup_failure`, an invalid workflow file), was cancelled before a job started (`cancelled`, usually by its concurrency group; a later run of the same workflow and event then supersedes it) or awaits approval (`action_required`); none passed, so none is ignored. So consumers now see `failure, settled` for a fork PR awaiting workflow approval (`action_required`), for every PR while a workflow file on the default branch is invalid (`startup_failure`), and for 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 it); where the run had jobs these were already `failure`. Kept on review: fork PRs get no `pr.checks.completed`, and the catalog rules that act on `failure` are for the factory's own PRs. A suite whose workflow can't be told (no App, a null `workflowRun`: another App's suite such as CodeRabbit's, or an Actions suite whose run was deleted; a null `workflow`) is **never superseded and supersedes nothing**, so a failing suite can't hide behind an unrelated green one; it counts only with check runs, because GitHub leaves such a suite queued for every App that could run checks (Actions with no workflow for the event) and those never complete. So a run cancelled by its concurrency group, or a failed run re-triggered by a later green one, no longer turns a green PR into `failure` (compliance-framework/api#584: a cancelled `preview` run beside its green successor). A re-run (`rerun-failed-jobs`, re-run all jobs) is a new attempt of the same workflow run and GitHub keeps it in the same check suite, whose status and conclusion are the latest attempt's (checked on GitHub: a run's `check_suite_id` is unchanged by a re-run, and that suite went from failure to success), so attempts need no handling. The event is part of the kind because a `push` and a `pull_request` run of one workflow are separate checks (separate concurrency groups in practice): a failing `push` run isn't hidden by a green `pull_request` one. Of the kept suites: `failure` once one concluded failing (failure, timed out, cancelled, action required, startup failure, stale), else `pending` while one runs, else `success` (success, neutral, skipped); `settled` for `success` and `failure`; no such suite leaves `checks` empty. **Not `statusCheckRollup`** (fx/gh-observe-perms): it also covers commit statuses (`statuses: read`), which the Apps aren't granted, and check suites are what `pr.checks.completed` reports, so commit statuses don't count. `approvedBy` is each reviewer's **latest opinion** (`APPROVED`, `CHANGES_REQUESTED`, `DISMISSED`; comments and pending reviews don't change it) when it is an approval, at that review's commit, sorted. The factory's Apps map to their identity (`ccf-factory-reviewer[bot]` → `reviewer`, `ccf-factory[bot]` → `author`, from the slugs T02 learns), anyone else to their login; a deleted account counts for nobody. `unresolvedThreads` counts `isResolved: false` across all pages. - Author: `:` with REST's spelling (GraphQL's Bot `ccf-factory` is `ccf-factory[bot]`, as in webhooks), `isBot`, and `isFactory`/`identity` for the factory's Apps; nil for a deleted account. - Projections (removed with P3: [§P3](#decisions-taken-with-p3-no-list-no-marker-read-back)): the v1 markers among the comments **written by the projecting App** (the author identity); a look-alike by anyone else, or a marker of another version, is ignored (the latter with a warning). Of two markers for one work item the oldest comment wins. Comment bodies are read only for that and never returned. - **Other kinds**, because the work-item view and the rule controller's probe treat any error but `ErrNotFound` as fatal: a `repo` link (an event without an object) is open, or closed once archived (`ObserveRepo`, `metadata: read`); releases and deployments are immutable records, `closed` with no call. Any other kind is `ErrInvalid`. diff --git a/internal/provider/github/observe_test.go b/internal/provider/github/observe_test.go index 20ed620e..f91d2408 100644 --- a/internal/provider/github/observe_test.go +++ b/internal/provider/github/observe_test.go @@ -478,6 +478,9 @@ func TestObserveChecks(t *testing.T) { {"the latest run cancelled before a job started", []githubtest.CheckSuite{ run(ciWF, 10, 1, "COMPLETED", "SUCCESS", 3), run(ciWF, 11, 2, "COMPLETED", "CANCELLED", 0), }, provider.Checks{State: "failure", Settled: true}}, + {"the latest run awaits approval", []githubtest.CheckSuite{ + run(ciWF, 10, 1, "COMPLETED", "SUCCESS", 3), run(ciWF, 11, 2, "COMPLETED", "ACTION_REQUIRED", 0), + }, provider.Checks{State: "failure", Settled: true}}, {"the latest run completed without jobs, passing", []githubtest.CheckSuite{ run(ciWF, 10, 1, "COMPLETED", "FAILURE", 3), run(ciWF, 11, 2, "COMPLETED", "SUCCESS", 0), }, provider.Checks{State: "success", Settled: true}},