Repository navigation
perf(pr-require-checks): read the run's workflow and the pull request over GraphQL - #836
Conversation
… over GraphQL ci-status and pr-contract drew every read from the repository token's REST bucket, which runs out during bursts of pull request CI while the GraphQL bucket sits mostly free. - gh-api.sh: `gh_api POST graphql` fails on any `errors` entry, whatever gh's exit status; a `RATE_LIMITED` error on HTTP 200 is classified, reported, waited out and failed closed exactly like a REST rate limit. - aggregate-results: this run's workflow id comes from `resource(url:)`, checked to be this WorkflowRun, instead of `actions/runs/<id>`. - check-contract: the pull request and its comments come from one query; a missing field or an incomplete label page fails closed, a Bot login gets its REST `[bot]` suffix back, and comments past one page fall back to REST. Status lists, run listings, the writer run and every jobs read stay on REST: GraphQL exposes no status ids or history, no run_started_at, head SHA filter, or per-attempt jobs. Closes #808 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aphQL call `GET repos/.../actions/runs/4242` also matches this run's jobs read, so the two assertions held whether or not the workflow read happened. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Claude finished @kyle-sexton's task in 4m 27s —— View job Claude code review —
|
|
Claude finished @kyle-sexton's task in 2m 20s —— View job Security review complete
No security issues found. This PR moves two reads (the run's workflow in
claude-lane-summary: lane=claude-security-review sha=3b28094a38647558b06ea7d7453a046181513683 run=39507478753 |
|
claude-security-review has reviewed this pull request through 553d7fc; a later push is reviewed from there. |
|
claude-review has reviewed this pull request through 553d7fc; a later push is reviewed from there. |
…wo fail-closed reads - gh-api.sh: a status line that does not yield a three-digit status leaves GH_HTTP_STATUS empty rather than carrying arbitrary text. - aggregate-results: a resource with this run's databaseId but another type fails closed. - check-contract: a FORBIDDEN error beside a complete pull request fails closed even when gh exits 0. Refs: #808 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Claude finished @kyle-sexton's task in 50s —— View job Claude security review —
|
|
Claude finished @kyle-sexton's task in 5m 22s —— View job Claude code review —
|
A GraphQL error under a malformed status line reports an unknown status instead of the line's text. Refs: #808 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Claude finished @kyle-sexton's task in 1m 22s —— View job Claude security review —
|
|
Claude finished @kyle-sexton's task in 1m 52s —— View job Claude code review —
|
…829) Refs: melodic-software/ci-workflows#818 Refs: melodic-software/ci-workflows#819 ## Summary Registers ci-workflows [v0.56.0](https://github.com/melodic-software/ci-workflows/releases/tag/v0.56.0) (`1bb8953644d16f21d10718962c6702f01ea3308a`) contracts for `intake-triage.yml` and `intake-label-needs-triage.yml`. [claude-code-plugins#8800](melodic-software/claude-code-plugins#8800) repins both intake callers to that SHA, and its runner-policy gate fails with `runner-target-contract: the reusable workflow path@SHA has no reviewed runner-input contract (auto-approval declined: ... carries a reviewed allowedCallerPermissions grant; its steps cannot be proven unchanged by this surface diff, so auto-approval is declined)` for both. **Owner sign-off pending.** The README rollout line says "sign-off pending"; replace it with "signed off by hand on <date>" when you sign off. ## Fix - `components/runner-policy/policy.json`: - `intake-triage.yml@1bb8953`: a verbatim copy of the v0.55.0 entry (`3a2c748`). - `intake-label-needs-triage.yml@1bb8953`: a verbatim copy of the v0.42.0 entry (`182aca3`), the newest reviewed SHA for that file. - `components/runner-policy/README.md`: the v0.56.0 rollout line, sign-off pending. - `components/runner-policy/runner-policy.test.mjs`: a test that both v0.56.0 entries equal their source entries and that they are the only two keys at that SHA. ### Byte-identity evidence Git blob SHA of each file, from `gh api repos/melodic-software/ci-workflows/contents/.github/workflows/<file>?ref=<sha> --jq .sha`: | File | `182aca3` | `3a2c748` (v0.55.0) | `1bb8953` (v0.56.0) | |---|---|---|---| | `intake-triage.yml` | `fa4e86f8` | `d79b7e9e` | `d79b7e9e` | | `intake-label-needs-triage.yml` | `8d274a66` | `8d274a66` | `8d274a66` | `gh api repos/melodic-software/ci-workflows/compare/3a2c748...1bb8953` is one commit ([ci-workflows#836](melodic-software/ci-workflows#836)) touching nine files, all under `.github/actions/pr-require-checks/` plus `README.md`; neither intake file is among them. Against `182aca3`, the compare lists `intake-triage.yml` as modified (that file's reviewed SHA is `3a2c748`, not `182aca3`) and not `intake-label-needs-triage.yml`. No input, secret, caller permission, or `runs-on` routing changes. ## Verification - `npm run test:runner-policy`: 323 pass, 0 fail, including `✔ both intake contracts at the v0.56.0 tag copy their reviewed entries forward verbatim`. Adding an input to the new `intake-label-needs-triage` entry makes that test fail. - `npm run lint:runner-policy`: `Runner policy passed.` - Against the claude-code-plugins#8800 worktree (`--repository-visibility public`, worktree not modified): - with its vendored policy: the two `runner-target-contract` failures above, and no others; - with `--policy` set to this branch's `policy.json`: `Runner policy passed.`; - with this branch's `runner-policy.mjs` and `policy.json`: `Runner policy passed.` - Every other ci-workflows reusable that #8800 calls stays on a SHA that already has a contract (`pr-review` and `pr-review-security` at v0.48.0, `maintenance-check-links-online` at v0.55.0). The other v0.56.0 pins are composite actions, which need no contract. - lefthook pre-commit (typos, editorconfig, markdownlint, gitleaks, biome): clean. ## Related - [claude-code-plugins#8800](melodic-software/claude-code-plugins#8800) passes its runner-policy gate once this merges and syncs. - Precedent: #828 (v0.55.0 verbatim copies), #811, #802. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Tje1j8KEYaYSxYe8RgJ3Lw --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Closes #808
Summary
ci-status (
aggregate-results) and pr-contract (check-contract) now get the reads GraphQL can serve from GraphQL, which has its own rate limit. GraphQL reports a primary rate limit as HTTP 200 with an error. The sharedgh-api.shhelper now classifies that response, reports it, waits it out and fails closed, the same as a REST rate limit.Fix
gh-api.sh:gh_api POST graphql ...fails on anyerrorsentry, whatever gh's exit status, and its data is never read.GH_HTTP_STATUScomes from the response status line,GH_MESSAGEfrom the first error, andGH_GRAPHQL_ERROR_TYPESlists the error types.RATE_LIMITED,x-ratelimit-remaining: 0,retry-after, or a rate-limit message classifies the error asrate-limit. It is then reported and waited out withinrate-limit-wait-seconds, and fails closed if it outlasts that wait.FORBIDDENclassifies aspermission.200, but you will receive an error message, and the value of thex-ratelimit-remainingheader will be0." That page does not name theRATE_LIMITEDtype; this PR adds the type rule because the issue names it.aggregate-results:resolve_workflow_idused to readactions/runs/<this run>, the read behind most of the 403s in perf(pr-require-checks): fold ci-status and pr-contract REST reads into one GraphQL query per job #808. It now readsresource(url: <run URL>) { ... on WorkflowRun { databaseId workflow { databaseId } } }.__typenameisWorkflowRunanddatabaseIdequalsGITHUB_RUN_ID. Anullresult, which GraphQL returns with no error for a URL it cannot resolve, fails closed.workflow_id374434959 over REST andworkflow.databaseId374434959 over GraphQL.check-contract: the pull request and its comments are now read in one query, which replaces RESTpulls/Nand the comments listing.labels, orlabels.totalCountabove the nodes returned fails the step closed. Ado-not-mergelabel beyond the first page can therefore never pass.[bot]suffix. Live, PR build: bump the github-actions group across 4 directories with 5 updates #749 readsdependabotover GraphQL anddependabot[bot]over REST, so the suffix is added back forexempt-authors.action.ymlrate-limit-wait-secondsdescriptions and the check-contract README now describe the GraphQL path.scan_lineandnegation_triggerare byte-identical toorigin/main.Stays on REST, and why (references: Actions objects, Checks objects, Commits objects):
commits/<sha>/statuseslist.StatusContexthas nodatabaseId, andStatus.contextsis documented only as "The individual status contexts for this commit", with no full history. The newest bot entry by id, which keeps a forged user success from shadowing the bot's verdict, cannot be selected.actions/workflows/<id>/runs?head_sha=listings (the wait, the yield, the newer-verdict check, the re-run).WorkflowRunhas no status, head SHA orrun_started_at, andWorkflow.runstakes no head-SHA filter.actions/runs/<writer>. It needsrun_started_at, whichWorkflowRunlacks.actions/jobs/<id>,runs/<id>/jobs?filter=latest,attempts/1/jobs):CheckRunhas no runner name, which the fallback identity key needs.resource(url:)returnednullfor a check-run URL in a live probe.CheckRunFilter.checkType: LATEST("The latest check run") equals RESTfilter=latest.CheckRunnorCheckSuiteexposes an attempt.verify_writer_stepandjob_shape.Security review still owed. The issue requires one for any change to how the carried-writer verification reads its data.
verify_carried_writercompares the writer's workflow against the idresolve_workflow_idreturns, and that id now comes from GraphQL. The checks above (type, run id, numeric) keep it failing closed, but this PR has not had that review yet.Verification
bash .github/actions/pr-require-checks/aggregate-results/run.test.sh: all pass. No existingrun_caseexit code changed. Existing cases that faulted the own-run read now fault the GraphQL key.bash .github/actions/pr-require-checks/check-contract/run.test.sh: all pass, with no existing exit code changed. Fixtures now come from the GraphQL shape seen live.REST call counts, measured by running the same cases against
origin/main(8b41a59):New tests, each shown to fail under a mutant of the code it guards:
(rate-limit), waited out and retried; fails closed when it persists or the wait exceeds the cap. Fails with theerrorsdetection removed, and the ci-status case (type only, no header or message) fails with theRATE_LIMITEDtype rule removed.nullpull request fails closed. These fail when the field checks are replaced with// ""and// []defaults, and the label-page case also fails when only the completeness check is removed.nullrun fails closed.exempt-authors(fails without the[bot]suffix).The
FORBIDDEN→permissionrule has no test.CI under
GITHUB_TOKEN: the full run's ci-status job loggedpr-contract: the PR body satisfies the issue-linkage contract., which needs the GraphQL pull request read, andFailed run(s) of this workflow on b41e242... to consider for a re-run: none., which prints only after the GraphQL run read returns a workflow id. Neither step logged a warning.shellcheck --rcfile .shellcheckrc(0.11.0),shfmt -d(3.14.1), andactionlintare clean.node --test .github/scripts/*.test.cjs: 535 pass.Related
gh-api.sh).check-contractandaggregate-resultsare separate steps in the ci-status job, so this is one GraphQL query per step, not one per job.🤖 Generated with Claude Code