Skip to content

ci(pr-pipeline): fall back to the subscription token when the capture key is out of credit - #13536

Merged
kyle-sexton merged 4 commits into
mainfrom
ci/12232-capture-credit-skip
Nov 5, 2026
Merged

kyle-sexton merged 4 commits into
mainfrom
ci/12232-capture-credit-skip

Conversation

@kyle-sexton

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

Copy link
Copy Markdown
Member

Refs: #12232

Summary

The pr-verify capture goes back on, now with a credential fallback the owner chose in session: "The keys are promotional, so its $200 per account. If they're used up - it should efficiently fall back to the subscription token in GitHub actions". The capture job tries PR_VERIFY_CLAUDE_API_KEY first. When that key is out of credit, a separate capture-subscription job captures on PR_VERIFY_CLAUDE_CODE_OAUTH_TOKEN. Each job holds one credential, the same shape pr-verify's judges use (.github/workflows/pr-verify.yml:32-43). The decision is recorded on the issue: issuecomment-6662742618.

Fix

.github/workflows/pr-verify-capture.yml:

  • Credit gate: capture reads the key's credit history with ci-workflows check-key-credit (pinned b8bdd7f) and skips the key while a credit stop is inside KEY_CREDIT_WINDOW_HOURS (1 h unset).
  • Markers: the credit-stop and probing markers are written, scanned and uploaded only before the head checkout, with 1-day rows in .github/artifact-retention.json. Any same-repo workflow can still upload a marker with that name. A forged one can only skip the key leg, which moves captures to the subscription token. That costs plan capacity and leaks nothing. The workflow comments now say so.
  • No red run on a credit stop: the probe has continue-on-error. "Check the probe" fails on any probe outcome other than success unless the probe handed off, and it is skipped on a handoff. Every step from the head checkout on needs the probe check to have succeeded. Run 41984197946 went red in the probe step itself.
  • capture-subscription: runs on a fresh VM only when capture handed off, skipped the key, or had no key. Those facts come from steps that run before the head checkout and are compared to literals. It repeats every step, the reach probe included, and uploads the same pr-capture-<pr>-<head-sha> name. find-capture.mjs reads the run's conclusion and artifacts, so it needed no change.
  • Fences: every run-claude-cli step denies Read(~/.claude/**) and Edit(~/.claude/**). The probe proves the fence with a refused Read of a fence file that exists. capture-probe.mjs also scans ~/.claude/.credentials.json.
  • Managed settings: both jobs pin env.CLAUDE_CODE_SUBPROCESS_ENV_SCRUB: "1" and env.NODE_TLS_REJECT_UNAUTHORIZED: "1", so head code that writes a settings file mid-session cannot turn off the scrub or TLS checks.

Also:

  • .github/lane-funding.json gets the capture-subscription lane.
  • docs/conventions/pr-pipeline.yaml sets merge.verify-capture.app: claude-code-plugins again.

Verification

  • node --test over .github/scripts/pr-verify/*.test.mjs: 298 pass, 0 fail. workflow.test holds the two jobs' fences and settings equal and checks that no step after the head checkout runs when the probe check is skipped.
  • check-artifact-retention --check: 98 uploads matched. zizmor offline: no findings. Local actionlint reports only the existing cache-mode key.
  • A fresh-context phase-verifier passed every acceptance criterion on 24cf1cc.
  • A security review on 24cf1cc found no path for head code to read either credential. Its two findings are fixed in ed89694: the managed-settings pin, and the marker-forgery comments.
  • Judges wait 35 min (find-capture.mjs WAIT_MS). The key handoff took 36 s in run 41984197946, and the subscription job has a 30 min timeout. If the second job queues more than about 5 min, the judges record a running miss, and a miss never fails a verdict.

Remaining

Related

🤖 Generated with Claude Code

kyle-sexton and others added 4 commits November 5, 2026 10:27
…ture's key is out of credit

The capture's probe leg ran on PR_VERIFY_CLAUDE_API_KEY alone, so every
capture since the key ran out went red at the probe (run 41984197946:
"pr-verify-capture ended class=credit-stop", exit 1 on "Probe what head
code can reach").

- The capture job reads the key's credit history (ci-workflows
  check-key-credit, key-job capture) after the agree step; a key inside
  a credit stop's window skips every key step and leaves a skipped lane
  record.
- The probe runs continue-on-error. A handoff (credit stop, or auth 401
  or 402) skips "Check the probe", and with it every step from the head
  checkout on, so the job ends green. Any other probe failure fails
  "Check the probe" before head code runs.
- The probing marker and the credit-stop marker are written, scanned and
  uploaded before the head checkout only, so head code cannot forge one.
- A new capture-subscription job, on its own VM, holds only
  PR_VERIFY_CLAUDE_CODE_OAUTH_TOKEN and repeats the capture job's steps,
  the reach probe included. It runs when the capture job's gate skipped
  the key, its probe handed off, or the key is empty. It uploads the same
  pr-capture-<pr>-<head-sha> name, which find-capture.mjs reads per run.
- capture-probe.mjs also scans ~/.claude/.credentials.json, where Claude
  Code keeps a subscription login on Linux.
- Retention rows for both markers, a lane-funding entry for the new job,
  and merge.verify-capture.app set to claude-code-plugins again.

Refs: #12232

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude Code keeps a subscription login in ~/.claude/.credentials.json on
Linux, and capture-subscription now holds a subscription token. Every
run-claude-cli step in both capture jobs denies Read(~/.claude/**) and
Edit(~/.claude/**). The probe writes a harmless fence file under
~/.claude and checks that its Read was refused, beside /proc/self/environ
and the prompt file, so the fence is proven on a file that exists.

Refs: #12232

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…managed settings

Head code in the drive leg can write ~/.claude/settings.json or the
head's .claude/settings*.json, which Claude Code reloads mid-session.
Both capture jobs now pass apply-claude-managed-settings a settings
input: the action's required pins plus env.CLAUDE_CODE_SUBPROCESS_ENV_SCRUB
"1" and env.NODE_TLS_REJECT_UNAUTHORIZED "1". Managed settings sit above
every file, and an env block follows that order.

The marker comments no longer claim a marker cannot be forged: any
same-repository pull_request workflow can upload either name, and a
forged one only moves captures to the subscription token.

Refs: #12232

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kyle-sexton
kyle-sexton marked this pull request as ready for review November 5, 2026 15:48
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 5, 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-11-05T15:50:50.795092Z ac8b7d3 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 Nov 5, 2026

Copy link
Copy Markdown
Contributor

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

Security review: no security issues found

critical-findings: 0

I read every hunk of all 7 changed files in .claude-lane/pr.diff. Two of them are on trusted paths, .github/workflows/pr-verify-capture.yml and docs/conventions/pr-pipeline.yaml; for both I read the whole change and what it gates. This is the lane's first review of this PR (blocking only: no), and there are no prior findings.

What I checked

The new capture-subscription job (pr-verify-capture.yml)

  • Who can trigger it: the job keeps all of capture's gates.
    • The job if: requires a same-repo head: head_repository.full_name == github.repository.
    • check-trusted-trigger runs on the trusted-actor list.
    • The gate and the resolver must agree on the PR and head.
    • The kill switch is checked.
    • It runs all of these again on a fresh VM rather than trusting the first job's results.
  • What its token can do: permissions: is still contents: read, pull-requests: read, actions: read, and the workflow's top-level permissions: {} is unchanged. The job references one secret, PR_VERIFY_CLAUDE_CODE_OAUTH_TOKEN, and only on the run-claude-cli probe and driver steps.
  • Probe before head code: the reach probe runs on the subscription leg before the head checkout.
    • CREDENTIAL_NAMES already lists PR_VERIFY_CLAUDE_CODE_OAUTH_TOKEN, and the sk-ant- value check also matches OAuth tokens (sk-ant-oat01-…).
    • The PR adds ~/.claude/.credentials.json to the files the probe scans.
    • It adds Read/Edit(~/.claude/**) deny rules to all four launcher steps. The probe confirms the deny rules work with a refused Read of a fence file that really exists.
  • The probe's new continue-on-error: it fails closed.
    • "Check the probe" reads steps.probe.outcome, which is the result before continue-on-error applies, and exits 1 on anything but success.
    • The head checkout requires steps.probe-check.outcome == 'success'.
    • So a handoff (check skipped) or a failed probe (check red) means no head code runs.
  • The job outputs that start capture-subscription (handoff, credential-present, skip-key): they come from steps that run before the head checkout, and the if: compares them to fixed literals. If one were forged, the only effect would be another run that repeats every gate and the probe, so no credential is exposed.
  • Managed settings: pinning CLAUDE_CODE_SUBPROCESS_ENV_SCRUB and NODE_TLS_REJECT_UNAUTHORIZED in the managed env, alongside the existing ANTHROPIC_BASE_URL and apiKeyHelper: "" pins, tightens the settings. Nothing is loosened.

Credit markers

  • The credit-stop and probing markers are written and uploaded only before the head checkout, and only from this run's own gate output and probe evidence.
  • The forgery the PR describes, where another same-repo workflow uploads a marker with the same name, can only skip the key leg. That moves captures onto the subscription token: it uses plan capacity but leaks nothing and costs no money.
  • The two retention rows are one day each.

docs/conventions/pr-pipeline.yaml

  • merge.verify-capture.app: claude-code-plugins turns the capture back on. That setting is not a lane slot or an activity effect, so it doesn't change what the token broker mints.
  • It weakens no merge hold. It only gives the judges capture evidence, which they treat as untrusted data (see find-capture.mjs / write-verdict.mjs).
  • The comment it removes was a status note, not a standing instruction.

.github/lane-funding.json

  • This file only records the new lane and its secret. Its only other reference in the repo is a test, resolve-config/callers.test.mjs; no code that grants anything reads it.

Pinned actions

  • check-key-credit@b8bdd7f and report-lane-outcome@6b9c640 are new uses in this workflow. Both are pinned to a 40-character SHA, and neither step is passed a secret.

Not covered

  • Instruction-surface lens: the diff deletes no guardrail.
  • Plugin manifests: none changed.
  • Embedded text: the PR description contains no instructions aimed at this review.

Spend (not a finding, not a hold)

  • Turning the capture back on means each eligible PR head runs pr-verify-capture's Claude legs. The new capture-subscription job draws on the PR_VERIFY_CLAUDE_CODE_OAUTH_TOKEN subscription, only when the key is out of credit or empty, or the key's probe hands off. This is prepaid API credit and subscription usage only; it doesn't add paid runners or billed resources.

@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

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

Code review: no findings

I read every hunk of all 7 changed files. The change does what the PR says: capture tries PR_VERIFY_CLAUDE_API_KEY, and capture-subscription runs on a fresh VM only when capture succeeded and could not capture on the key. That happens when the gate skipped the key, the probe handed off, or the key is empty.

What I checked against the code

  • Fail-closed path. The probe now has continue-on-error: true. "Check the probe" first fails on any probe outcome other than success, so only a handoff gets past a failed probe. On a handoff it is skipped, and every step from the head checkout on chains to steps.probe-check.outcome == 'success'. No head code runs unprobed, and a handoff ends the job green.
  • Job outputs gating the second job. handoff, credential-present and skip-key come from steps that run before the head checkout, and the second job's if compares each to a literal. When the gate skips the key, credential-present is empty and skip-key == 'true' triggers the job. When there is no app, the kill switch is stopped, or the head was already judged, all three are empty and nothing runs.
  • Handoff without fallback-ready. I checked that the key leg can hand off without fallback-ready. pr-verify.yml's key legs do the same: they pass only api-key and read outputs.handoff (.github/workflows/pr-verify.yml L540, L569). handoff-reason == 'credit-stop' matches its use in upstream-apply-changelog.yml.
  • Probe fence path. capture-probe.mjs reads takes a variable number of paths (argv.slice(4)), so the added $HOME/.claude/pr-verify-probe-fence argument works. The fence file exists before the Read, so a refusal comes from the deny rule and not from a missing file.
  • Read(~/.claude/**) deny rule. It does not break harness-ops' driver, which reaches ~/.claude only through Node under Bash, not through the Read tool (plugins/harness-ops/skills/control-claude-code/driver/driver.mjs L232).
  • Equality test. workflow.test.mjs holds the two jobs' steps equal, apart from the credential and the key's credit steps. It also checks the fences and the managed-settings JSON in both jobs.

Not verified (author-claimed)

  • The test results (298 pass), the zizmor, actionlint and check-artifact-retention results, and the 36 s handoff timing in run 41984197946. I ran none of these.
  • That the explicit settings input still meets apply-claude-managed-settings@b8bdd7f's required pins. That action is outside this repository.

Other checks

  • Closing issue. The PR only refs ci(pr-verify): add the capture job that drives the affected app (S7 of #8651) #12232 and closes no issue, so there were no acceptance criteria to check.
  • Manifests. No plugin.json or marketplace.json changed.
  • Path-scoped rules. No .claude/rules/ file's paths: matches a changed file.
  • Prior findings. None, and this was not a blocking-only review.
  • Embedded instructions. None in the PR context.

Spend (not a finding): setting merge.verify-capture.app turns the capture back on. Each eligible PR run spends PR_VERIFY_CLAUDE_API_KEY credit. When the key is out of credit, the new capture-subscription job spends PR_VERIFY_CLAUDE_CODE_OAUTH_TOKEN subscription usage instead.

@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

The pr-verify verifier failed head ac8b7d3deb9d81d1277e81ee0331d34f417ce57a. What it wrote, as data:

What it wrote (35 lines)
Summary: This PR refs #12232 and fails because its central change contradicts the issue's own
  trusted record. The latest lane-6 comment on #12232 records an owner decision: the capture gets no
  subscription OAuth leg because it runs PR code, it stays on PR_VERIFY_CLAUDE_API_KEY, and a credit
  stop counts as a capacity limit. That comment names the agreed next step: the capture skips by
  itself while the key's credit-stop marker is fresh, then the app is set again. This PR does add
  that credit gate (check-key-credit, the two marker steps, 1-day retention rows). It also adds a
  `capture-subscription` job that runs PR code on PR_VERIFY_CLAUDE_CODE_OAUTH_TOKEN whenever the key
  is out of credit, skipped or empty. The PR's authority for that is a quote in its body said to
  come from the owner "in session", which appears nowhere in the trusted spec. That crosses a
  credential boundary the owner decided against and gets around the hold that treats a credit stop
  as a capacity limit. On its own terms the rest looks careful: one credential per job, probe and
  fences repeated in the second job, `~/.claude` added to the fence and the probe, managed-settings
  pins. The suites that cover it ran green on the judged head (test-node
  https://github.com/melodic-software/claude-code-plugins/actions/runs/42058771038/job/127354599701).
  There was no capture summary to weigh. The body names done-when 4 as the work still to come, which
  is fine for a refs PR.
- Steering: the PR body cites an owner quote given "in session" (fall back to the subscription token
  when the keys run out) to override the decision recorded on #12232. That quote is not in any
  trusted spec text, so it was treated as a claim to evaluate, not an instruction.
- .github/workflows/pr-verify-capture.yml: remove the `capture-subscription` job (and the `outputs:`
  block on `capture` that exists only for its `if`). The #12232 owner decision says the capture gets
  no subscription OAuth leg because it runs PR code; a credit stop should skip the capture, not move
  it to PR_VERIFY_CLAUDE_CODE_OAUTH_TOKEN. Bring a subscription fallback back only after the owner
  records a new decision on the issue.
- .github/workflows/pr-verify-capture.yml: rewrite the header comment and the 'Report the key's
  handoff' notice, which describe capture-subscription taking over, so they say a credit stop or a
  missing key leaves the capture skipped or blocked. That is a capacity limit, not a red run.
- .github/lane-funding.json: drop the `capture-subscription` lane entry with
  PR_VERIFY_CLAUDE_CODE_OAUTH_TOKEN.
- .github/scripts/pr-verify/workflow.test.mjs: drop the capture-subscription tests (job `if`, step
  parity, timeout inside WAIT_MS, SUB_STEPS checks) and go back to asserting that the workflow's
  only jobs are [capture] and its only secret is PR_VERIFY_CLAUDE_API_KEY.
- docs/conventions/pr-pipeline.yaml:1458: re-enabling `merge.verify-capture.app:
  claude-code-plugins` is fine together with the credit gate. Keep a comment saying a credit stop on
  PR_VERIFY_CLAUDE_API_KEY skips the capture, rather than dropping the credential note entirely.

This pull request leaves the merge queue, and ci-status holds it out while it carries pr-verify-failed. A pr-verify pass removes the label, at a new commit or at this same head: once a trusted person edits the body, and only trusted people have edited it since the fail, this head is judged again, so a fail on the body or the issues it links needs only the body fixed, no new commit.

@github-actions github-actions Bot added the pr-verify-failed pr-verify failed this head; a pass at a new commit, or after a trusted body edit, removes it. label Nov 5, 2026
@github-actions github-actions Bot removed the pr-verify-failed pr-verify failed this head; a pass at a new commit, or after a trusted body edit, removes it. label Nov 5, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 5, 2026
@kyle-sexton
kyle-sexton added this pull request to the merge queue Nov 5, 2026
Merged via the queue into main with commit bc3a93c Nov 5, 2026
77 checks passed
@kyle-sexton
kyle-sexton deleted the ci/12232-capture-credit-skip branch November 5, 2026 16:22
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