Skip to content

perf(ci): read the capture key's credit before the resolver - #16416

Merged
kyle-sexton merged 2 commits into
mainfrom
perf/pr-verify-capture-credit-first
Nov 15, 2026
Merged

kyle-sexton merged 2 commits into
mainfrom
perf/pr-verify-capture-credit-first

Conversation

@kyle-sexton

@kyle-sexton kyle-sexton commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

No related issue: GitHub-token spend cut A1 from the hub's 11-15 spend research

Summary

PR_VERIFY_CLAUDE_API_KEY has been in a credit stop since about 2026-11-14 03Z. Every PR Verify Capture run still ran the resolver, the trigger gate and the match step, then uploaded a "blocked" summary that nothing needs. This change reads the key's credit history first and stops the job there while the key is held off.

Fix

  • In .github/workflows/pr-verify-capture.yml, "Read the key's credit history" now runs right after "Read the capture config" (if: steps.config.outputs.app != ''). It needs nothing from the pull request.
  • "Resolve the pull request" now also requires steps.credit.outputs.next-leg != 'subscription'. With the key held off, the trigger gate, agree, match, key call, model resolve, blocked capture, scan and upload all skip, because they chain off the resolver.
  • A failed or hung credit read (continue-on-error, 2-minute limit) leaves next-leg empty, so the job goes on as before.
  • "Report the skipped key leg" now keys on the read's next-leg == 'subscription' and sits between the read and the resolver. "Check the credential" no longer runs for a held key, so the old trigger could never fire.
  • The probing marker is unchanged and is still written only past the agree step. It needs credential.present == 'true', and the key call sets that only after agree and match. The tests now check this with the expression evaluator.
  • No trigger, permission or trust-path change. The read takes no secret, uses the job's existing actions: read, and runs before any head code, so the split's boundary (header lines 3-11) is unchanged.

Behavior changes to note:

  • While the key is held off, the run uploads no pr-capture-* artifact. The judges' find-capture records the verdict's capture blocked ("left no capture artifact for this head") in place of the R41 reason. During a credit stop that reason is expected and is not an upload fault. The workflow header and the PR pipeline convention's Verifier verdict section say so, and a .changes/pr-pipeline/ patch fragment records it.
  • A docs-only change now records blocked instead of not-applicable while the key is held off, because the match step needs the resolver's SHAs. prompt.md treats both alike: neither is a reason to fail.
  • The skipped-leg lane record now also fires for runs the resolver or match would have stopped, so skip counts per run go up while the key is stopped.

Verification

Calls per Capture job, taken from the job's own "Log the API budget" output in run 43742536648 (key held off):

  • Before: 12 counted job-token requests: 11 REST (2 of them 304 not-modified) and 1 GraphQL.
    • Routes: actions/artifacts 4, actions/runs/{n} 2, commits/{sha}/pulls 2, graphql 1, actions/jobs/{n}/logs 1, actions/runs/{n}/jobs 1, compare 1.
    • The credit read records its calls through check-key-credit's recordBudget, so its 2 artifact-list calls are among the 4 artifact calls.
  • After (key held off): only the credit read's 2 artifact-list calls remain. "Report the skipped key leg", "Log the API budget" and "Pick the next leg" make no REST call. select-model-credential gets no token without key-job.
  • The trade. The saving (12 calls to 2 per Capture job) happens only during credit stops.
    • With the key live, a run that the resolver, the trigger gate or the agree step stops now spends +1 call on the credit read. So does each not-applicable change.
    • That rises to +2 while a stale credit-stop marker is still retained.
    • Applicable runs are unchanged: they already made the read.

Tests:

node --test .github/scripts/pr-verify/workflow.test.mjs
ℹ tests 83
ℹ pass 83
ℹ fail 0

The test-first run, before the workflow change: ℹ fail 3 (the capture gate order, the credit gate's position and condition, and the new credit-stopped walk).

New case: "a key in a credit stop ends the capture at the credit read: no resolver, no GitHub read, no capture upload". It walks every step after the read with next-leg set to subscription. Only "Report the skipped key leg", "Log the API budget" and "Pick the next leg" run. With next-leg empty or key, the resolver runs.

scripts/check-affected.sh --no-fetch --uncommitted: 12 passed, 6 skipped over 2 changed files.

Related

🤖 Generated with Claude Code

While PR_VERIFY_CLAUDE_API_KEY sits in a credit stop, every Capture run
still ran the resolver, the trigger gate and the match step, then
uploaded a blocked summary. The credit read needs nothing of the pull
request, so it now runs right after the capture config. A held key
(next-leg subscription) records the skipped leg and stops there: no
resolver, gate or compare reads and no capture upload. find-capture
then records the verdict's capture blocked by its miss. A failed read
leaves next-leg empty and the job goes on as before.

The probing marker stays past the agree step: the key call, whose
present output it needs, runs only after agree and match.

Run 43742536648 counted 12 job-token requests (11 REST, 1 GraphQL);
with the key held off, only the credit read's 2 artifact-list calls
remain.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-15T19:11:22.915740Z 3de0b91 PR opened
ℹ️ 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 Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

claude-security-review reviewed cf0c9cb4628c704900e92b8c25f00614521de791: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Security review (incremental, blocking only): no security issues found

This review covers only what changed since 3de0b910. This lane already reviewed an earlier head, so it reports only blocking (CRITICAL and IMPORTANT) findings. I read every hunk of all 4 files in scope:

  • .github/workflows/pr-verify-capture.yml (trusted path): only comment lines changed. The header comment now says a credit stop leaves the reason "left no capture artifact for this head". The comment above Report the skipped key leg now says what the skip count measures. No step, if:, permissions:, input, secret or action pin changed. The gating, permissions and trigger checks from the earlier review still hold.
  • .github/scripts/pr-verify/workflow.test.mjs: adds one comment to the test. It ties the empty "Pick the next leg" outputs to select.cjs next() at the pinned 5b5110a. No test logic changed.
  • docs/conventions/pr-pipeline/README.md: rewrites prose in the Verifier verdict section to match the new step order. It deletes no standing instruction or guardrail. It only describes how the credit read and the match step are now ordered.
  • .changes/pr-pipeline/perf-pr-verify-capture-credit-first-1586f6f4.md: a new changelog fragment, prose only.

Checks:

  • No trust control is touched: trusted trigger, lane token, kill switch, broker, and merge holds are all unchanged.
  • No plugin manifest changed.
  • No instruction surface is narrowed.
  • The pull request text contains no embedded directives.

Earlier finding: this lane's last post was a no-findings summary, so there is nothing to carry forward.

Spend: this push adds none. The credit read that now runs earlier, reviewed last round, costs up to 2 REST artifact-list calls per run from the job token's rate budget and bills nothing.

critical-findings: 0

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

claude-review reviewed cf0c9cb4628c704900e92b8c25f00614521de791: read 4 of 4 changed file(s); 0 finding(s), 0 as inline comments.

Code review (incremental, blocking only): cf0c9cb since 3de0b91

No findings. This lane already reviewed an earlier head, so this pass reports blocking findings only. I read every hunk of all 4 files in scope in .claude-lane/incremental.diff.

What changed: this push changes no workflow logic. It edits two comments in pr-verify-capture.yml and one comment in workflow.test.mjs. It also rewrites the Verifier verdict paragraph in docs/conventions/pr-pipeline/README.md and adds a bump: patch changelog fragment.

What I checked:

  • Step order in the convention text: it matches the workflow at head. "Read the key's credit history" (L216) runs right after the capture config and before the resolver (L247-L249). The match step (L313) runs before the key call, "Check the credential" (L375).
  • "Key cannot capture" list: the convention no longer lists "the credit gate skipped it" as a case that uploads a blocked capture. That fits the new early stop.
  • Skipped-leg record comment: it correctly says the record is gated only on steps.credit.outputs.next-leg == 'subscription' (L233-L234).
  • New test comment: it records the assumption my earlier review raised as a note. The test stubs empty outputs for "Pick the next leg", on the assumption that the pinned select.cjs next() returns no next leg for an empty state. The comment says a bump of the pinned version would void that case. I could not read the external action, so this assumption is the author's and unverified.
  • Changelog fragment: bump: patch fits a change to docs and comments only.

Verification: I ran nothing. The test results quoted in the pull request description are the author's claims and unverified.

Verifier dropped 0 of 0 candidates.

Applies the review of #16416. The PR pipeline convention's Verifier
verdict passage still had the match step running before the credit gate
and a credit-gate skip uploading a blocked capture. It now says the job
reads the credit history first and, while the key is held off, uploads
nothing, so the verdict's capture reads blocked with the reason "left
no capture artifact for this head", which is expected during a credit
stop. The workflow header says the same. The skipped-leg comment says
the record now also counts runs the resolver or match would stop. The
early-exit test notes its reliance on select.cjs next() at 5b5110a.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit 03327dc Nov 15, 2026
65 checks passed
@kyle-sexton
kyle-sexton deleted the perf/pr-verify-capture-credit-first branch November 15, 2026 19:33
@github-actions github-actions Bot added the merge-path: owner-agent Post-merge accounting record (README.md, Merge paths) label Nov 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-path: owner-agent Post-merge accounting record (README.md, Merge paths)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant