Skip to content

perf(pr-pipeline): skip pr-feedback-dispatch jobs that can only find nothing - #9345

Merged
kyle-sexton merged 3 commits into
mainfrom
perf/pr-feedback-dispatch-job-gates
Oct 23, 2026
Merged

kyle-sexton merged 3 commits into
mainfrom
perf/pr-feedback-dispatch-job-gates

Conversation

@kyle-sexton

Copy link
Copy Markdown
Member

No related issue: GITHUB_TOKEN pool exhaustion 2026-10-23 05:26Z

Summary

pr-feedback-dispatch starts a runner for every completed review and pr-verify run, and most of those runs read the API once just to learn there is nothing to do. This PR moves two of those decisions into job-level if: gates, so those runs make no API call and start no runner.

Measured from the logs of 164 non-skipped runs, 04:46 to 05:40Z. The cost is the script's own api-calls counter, and setup-node found Node in the tool cache in all 163 logs that reached that step:

Run shape Count GITHUB_TOKEN calls each
post-verify-notes, pr-verify run left no fail verdict 79 1 (artifact list)
of which the pr-verify run was skipped 29 1, now 0
dispatch, PR not opened by the lanes App 54 1 (commits/{sha}/pulls), now 0
dispatch, lanes App PR, no workable thread 11 2 REST + 1 GraphQL
dispatch, lane has not marked the head 1 2
post-verify-notes, 403 during exhaustion 10 1
  • Before: about 1.1 calls per run, roughly 180 REST calls an hour from this workflow. That is about 13% of the repo's ~1,400/h. The workflow leads on run count, not on calls.
  • After: about 83 fewer calls and runner starts per 55 minutes, about 90/h. That leaves roughly 90 calls/h, and non-skipped runs drop from about 169/h to about 75/h.

Fix

  • dispatch also requires startsWith(github.event.workflow_run.head_branch, 'work-resolve-issue/issue-') on the review-run arm. The lanes App opens PRs only from validated lane branches: report-outcome.mjs checks the branch with isLaneBranch before POST /pulls, and all 285 lanes App PRs in this repo match the prefix. The pr-verify arm, whose branch is main, is unchanged. The script still checks the PR author.
  • post-verify-notes also requires conclusion != 'skipped'. A skipped pr-verify run ran no job, so it has no verdict to post. A failure or cancelled run still lists its artifacts.

The pr-merge reads and the dispatch POST are untouched.

Verification

  • node --test .github/scripts/pr-unblock/workflow-gates.test.mjs .github/scripts/pr-unblock/feedback-dispatch.test.mjs .github/actions/resolve-config/feedback-dispatch.test.mjs: 90 pass.
  • The new gate tests fail against the old workflow (2 of 10 fail), so they test the change.
  • The lane-branch test ties the gate's prefix to laneBranchIssue, so renaming the lane branch fails CI instead of silently stopping dispatches.
  • actionlint is clean on the workflow.

Related

  • The diagnosis in progress on GITHUB_TOKEN exhaustion: pr-verify (98/h), pr-require-checks (100/h) and the review lanes (59/h each) spend most of the rest.

🤖 Generated with Claude Code

kyle-sexton and others added 2 commits October 23, 2026 01:51
…nothing

The dispatch job now starts only for review runs on a work-resolve-issue
lane branch, the only branches the lanes App opens PRs from; every other
run spent a runner and one GITHUB_TOKEN read to learn the PR was not the
App's. post-verify-notes no longer starts for a skipped pr-verify run,
which uploaded no verdict to list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review October 23, 2026 05:55
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T05:57:16.586671Z b336dd3 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

claude-review needs no new review of f881750b2b903170d2f6e03b26bb24b45e6656cd: no file of this pull request changed since the review of b336dd3.

No findings. I read the diff and the PR context, and checked the new gates against report-outcome.mjs and the repo's other PR-creation paths. I did not run the tests; the "90 pass" and "2 of 10 fail against the old workflow" results are author-claimed.

Changes reviewed

  • post-verify-notes now also requires conclusion != 'skipped'. A skipped pr-verify run uploaded no verdict, so nothing is lost. Its failure and cancelled runs still list artifacts.
  • dispatch now also requires startsWith(head_branch, 'work-resolve-issue/issue-') on the pull_request arm.

Checks

  • The only POST …/pulls caller outside tests is report-outcome.mjs:1434. It opens PRs from branches checked by isLaneBranch (report-outcome.mjs:857).
  • The other PR creators are dependabot-fragments.yml:126 and release-publish-plugins.yml:303, which open dependabot/* and release/plugins branches. feedback-dispatch.mjs:196 already skips PRs the lanes App did not open. I did not look at which token those two workflows use, so this rests on the author's claim that all 285 lanes App PRs match the prefix.
  • The pr-verify arm is unchanged. A workflow_run run has head_branch of main, and the new test covers that.
  • When post-verify-notes is skipped, head-sha is empty. The second arm requires event == 'pull_request', so a skipped pr-verify run can't start dispatch through it.
  • evaluate() in the test file gains a startsWith rewrite. The [^,]* match is safe because the arguments are a substituted JSON string and a literal.
  • laneBranchIssue is exported from report-outcome.mjs:859. The new test ties the gate's prefix to it, so renaming the lane branch fails the test.

Manifests, hold classes and closing issue

  • No plugin manifests are touched, so there are no manifest <field> lines.
  • No closing issue: the PR says "No related issue".
  • No hold applies. The change only lowers workflow runs and API calls. It adds no model call, trigger or runner, and touches no trust-gate path.

@github-actions

Copy link
Copy Markdown
Contributor

claude-security-review reviewed f881750b2b903170d2f6e03b26bb24b45e6656cd: 0 finding(s), 0 as inline comments.

No security findings in this pull request. I read the full diff and the PR context. I did not read the files outside the diff, such as report-outcome.mjs and the dispatch script.

The change makes two edits to .github/workflows/pr-feedback-dispatch.yml and adds tests in workflow-gates.test.mjs. Both edits only reduce when jobs start.

  • dispatch gate: the review-run arm now also requires head_branch to start with work-resolve-issue/issue-.
    • && binds tighter than ||, so the new clause sits inside the review-run arm. The pr-verify arm, which depends on needs.post-verify-notes.outputs.head-sha, is unchanged.
    • head_branch is attacker-influenced. The check can only stop a dispatch, so a crafted branch name gains nothing. The workflow already restricts to same-repository head repos and github.ref == 'refs/heads/main', and the PR says the script still checks the PR author.
    • The check doesn't add the branch name to any run: block or shell, so it adds no injection surface.
  • post-verify-notes gate: the job now also requires conclusion != 'skipped'. The existing checks that the run is the main branch, the same repository and the pr-verify.yml path are untouched. A skipped pr-verify run has no verdict to post, so a failing verdict can't be hidden this way. failure and cancelled runs still post.
  • Instruction-surface lens: no standing instruction, hook allowlist or guard was removed or softened. The gate narrows which runs reach the script, and the script's own author check remains.
  • Trust-gate paths: the diff touches none of .github/standards/trusted-actors/**, .github/actions/check-trusted-trigger/**, CODEOWNERS or .gitmodules. No hold is needed.
  • Manifests: no plugin.json or marketplace.json files changed, so there are no manifest <field> lines.
  • PR description: it contains no embedded directives.

critical-findings: 0

@kyle-sexton
kyle-sexton added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit 76a2c61 Oct 23, 2026
30 checks passed
@kyle-sexton
kyle-sexton deleted the perf/pr-feedback-dispatch-job-gates branch October 23, 2026 06:21
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.

1 participant