From 0655bf5cdf103b508b1bbd91b4445d233347cd5d Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Tue, 20 Oct 2026 22:04:59 -0400 Subject: [PATCH 1/6] feat(run-claude-cli): hand off a rejected key and default the CLI to latest - A key leg that ends in class `auth` (key disabled or deleted) now hands off to the subscription job like a credit stop. A new `handoff` output (`true`/`false`) carries the decision; `lane-class` keeps `auth`, so the job summary, the log record (`next: subscription`) and the step's error annotation name the dead key. A rejected subscription token hands off nothing. - One table in lane.cjs (NEXT_STEPS) maps each class to its handoff and summary note. The credit-stop note now says the credits are used up, the subscription job runs, and the owner rotates a key by hand when needed; no note mentions a spend limit. - `cli-version` defaults to `latest` again, and intake-triage falls back to `latest`; an exact version still installs that version. - README documents the `handoff` output and the two-job gate on it. Callers that gate on `lane-class == 'credit-stop'` keep today's behavior until they gate on `handoff == 'true'`. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NY1V8t81GkG6jWNPVFjaca --- .github/actions/run-claude-cli/action.yml | 33 +++-- .github/actions/run-claude-cli/lane.cjs | 61 +++++++--- .github/actions/run-claude-cli/lane.test.cjs | 119 +++++++++++++++++-- .github/workflows/intake-triage.yml | 9 +- README.md | 38 +++--- 5 files changed, 197 insertions(+), 63 deletions(-) diff --git a/.github/actions/run-claude-cli/action.yml b/.github/actions/run-claude-cli/action.yml index bd6642b8..b4c5ceec 100644 --- a/.github/actions/run-claude-cli/action.yml +++ b/.github/actions/run-claude-cli/action.yml @@ -3,10 +3,11 @@ description: >- Run one prompt with headless `claude -p` for an agent-mode CI lane, on a Linux runner, on exactly one credential: set `api-key` or `subscription-token`, never both (the action fails closed otherwise). A - key leg that ends in a credit stop (classify.cjs isCreditStop) sets - lane-class `credit-stop`; a caller that falls back to the subscription - runs it as a second job on a fixed GitHub-hosted runner, gated on that - exact value (see the README's two-job pattern), never in this job. + key leg that ends in a credit stop (classify.cjs isCreditStop, lane-class + `credit-stop`) or a rejected key (lane-class `auth`) sets handoff `true`; + a caller that falls back to the subscription runs it as a second job on a + fixed GitHub-hosted runner, gated on that exact value (see the README's + two-job pattern), never in this job. The leg's CLI environment has every credential and file-command variable removed and its one credential set, and the CLI runs with `--restricted` and `--strict-mcp-config`; the step's GITHUB_ENV, GITHUB_PATH, GITHUB_OUTPUT, @@ -122,15 +123,14 @@ inputs: default: "" cli-version: description: >- - An exact major.minor.patch, or `latest`, which resolves the newest - @anthropic-ai/claude-code release with `npm view` at run time. The - default is pinned to 2.1.304 (`npm view @anthropic-ai/claude-code - version`, 2026-10-20). The resolved version is logged and output. The + `latest` (the default) resolves the newest @anthropic-ai/claude-code + release with `npm view` at run time; an exact major.minor.patch + reproduces a run. The resolved version is logged and output. The install fails unless `npm audit signatures` verifies the wrapper and platform packages and the binary matches the release's GPG-signed manifest.json, so the version must be 2.1.89 or later. required: false - default: 2.1.304 + default: latest watchdog-max-wait-ms: description: CLAUDE_CODE_RETRY_WATCHDOG_MAX_WAIT_MS, the most each request waits out 429 and 529 errors. required: false @@ -146,10 +146,10 @@ outputs: lane-class: description: >- The leg's failure class; empty on success. `credit-stop` (key leg only) - means the caller may run the subscription leg in a separate job; a - caller that does not reports it as `rate-limit`, the class - report-lane-outcome knows. Otherwise it is report-lane-outcome's - class: a failed install or integrity check reports `install-failed`, + means the key's credits are used up; a caller that does not fall back + reports it as `rate-limit`, the class report-lane-outcome knows. + `auth` means the credential was rejected (disabled or deleted). + Otherwise it is report-lane-outcome's class: a failed install or integrity check reports `install-failed`, and any other failure before the leg ran, or a leg whose stdout passes 256 MiB, reports `other`. Report this class; do not reclassify execution-file, which cannot see the credit-stop or leg-timeout rules. Set after the step @@ -159,6 +159,13 @@ outputs: || (steps.isolation.outcome == 'success' && steps.install.outcome == 'failure' && 'install-failed') || (steps.run.outcome != 'success' && 'other') || '' }} + handoff: + description: >- + `true` when a key leg ended in `credit-stop` or `auth`, so the caller + may run the subscription leg in a separate job; `false` otherwise; + empty when the step failed before the leg ran. lane-class keeps the + reason. Set after the step files are restored, so the leg cannot set it. + value: ${{ steps.run.outputs.handoff }} lane-resets: description: ISO 8601 time the blocking limit lifts, when the CLI's structured output gives it; else empty. value: ${{ steps.run.outputs.lane-resets }} diff --git a/.github/actions/run-claude-cli/lane.cjs b/.github/actions/run-claude-cli/lane.cjs index c8281a7b..d832ea86 100644 --- a/.github/actions/run-claude-cli/lane.cjs +++ b/.github/actions/run-claude-cli/lane.cjs @@ -15,8 +15,9 @@ // Security contract: // - One leg per invocation: readConfig fails closed unless exactly one of // the two credentials is set. A caller that falls back to the -// subscription after a key-leg credit stop runs a second job, on a fresh -// runner, gated on this one's lane-class output being `credit-stop`. +// subscription after a key leg hands off (a credit stop or a rejected +// key, NEXT_STEPS) runs a second job, on a fresh runner, gated on this +// one's handoff output being `true`. // - legEnv copies the step environment and removes every credential and // file-command VARIABLE, then sets the leg's one credential. That is a // denylist, not a sandbox: code the leg runs (a Bash tool call, a hook) @@ -130,18 +131,43 @@ const UNSAFE_VARIABLES = new Set([ "NODE_EXTRA_CA_CERTS", "NODE_TLS_REJECT_UNAUTHORIZED", ]); -// The job summary's closed token per class: the named stop and its recovery. -const SUMMARY_NOTES = { - "": "", - "credit-stop": "credit stop: add Console credit or raise the spend limit", - "rate-limit": "limit stop: rerun after the reset", - auth: "credential unusable: replace the secret", - overloaded: "API overloaded: rerun later", - "max-turns": "turn cap: raise max-turns or narrow the task", - timeout: "leg timeout: raise leg-timeout-minutes or narrow the task", - other: "see the step log", +// What each class means for the run. `handoff`: a key leg that ends in it +// hands the run to the caller's subscription job. `note`: the job summary's +// closed token, the named stop and what happens next. +const NEXT_STEPS = { + "": { handoff: false, note: "" }, + "credit-stop": { + handoff: true, + note: "credits used up: the subscription job runs; the owner rotates a key by hand when needed", + }, + auth: { + handoff: true, + note: "credential rejected (disabled or deleted): the owner replaces the secret by hand", + }, + "rate-limit": { handoff: false, note: "limit stop: rerun after the reset" }, + overloaded: { handoff: false, note: "API overloaded: rerun later" }, + "max-turns": { + handoff: false, + note: "turn cap: raise max-turns or narrow the task", + }, + timeout: { + handoff: false, + note: "leg timeout: raise leg-timeout-minutes or narrow the task", + }, + other: { handoff: false, note: "see the step log" }, }; +function nextStep(failureClass) { + return Object.hasOwn(NEXT_STEPS, failureClass) + ? NEXT_STEPS[failureClass] + : NEXT_STEPS.other; +} + +// Only a key leg hands off: the subscription leg is the last one. +function handsOff(leg, failureClass) { + return leg.leg === "api-key" && nextStep(failureClass).handoff; +} + class LaneError extends Error { constructor(message) { super(message); @@ -262,8 +288,7 @@ function readConfig(env) { } // `latest` asks the registry for the newest release; anything else must be an -// exact version (the action's cli-version input defaults to a pinned one). -// Either way the value passes the shared exact-version check before it is +// exact version. Either way the value passes the shared exact-version check before it is // installed. function resolveCliVersion(input, npmView) { const wanted = (input ?? "").trim() || "latest"; @@ -690,8 +715,7 @@ function runLeg( messages: judged.messages, failureClass: judged.failureClass, resets: judged.resets, - // A credit stop hands the run to the caller's subscription job. - next: judged.failureClass === "credit-stop" ? "subscription" : null, + next: handsOff(leg, judged.failureClass) ? "subscription" : null, message, }); } finally { @@ -706,6 +730,7 @@ function runLeg( records: [record], outputs: { "lane-class": judged.failureClass, + handoff: String(handsOff(leg, judged.failureClass)), "lane-resets": judged.resets ?? "", "lane-turns": run.turns === null ? "" : String(run.turns), "lane-models": run.models.join(","), @@ -721,11 +746,9 @@ function summaryTable(records) { String(value ?? "") .replaceAll("|", "\\|") .replaceAll("`", "'"); - const note = (failureClass) => - SUMMARY_NOTES[failureClass] ?? SUMMARY_NOTES.other; const rows = records.map( (r) => - `| ${r.leg} | ${cell(r.secret)} | ${cell(r.class || "success")} | ${cell(r.num_turns)} | ${cell(r.denials.count)} | ${cell(r.resets)} | ${cell(r.next)} | ${cell(note(r.class))} |`, + `| ${r.leg} | ${cell(r.secret)} | ${cell(r.class || "success")} | ${cell(r.num_turns)} | ${cell(r.denials.count)} | ${cell(r.resets)} | ${cell(r.next)} | ${cell(nextStep(r.class).note)} |`, ); return [ "| Leg | Secret | Class | Turns | Denials | Resets | Next | Stop |", diff --git a/.github/actions/run-claude-cli/lane.test.cjs b/.github/actions/run-claude-cli/lane.test.cjs index 4e2e7a6d..806951a2 100644 --- a/.github/actions/run-claude-cli/lane.test.cjs +++ b/.github/actions/run-claude-cli/lane.test.cjs @@ -308,6 +308,7 @@ test("a key-leg credit stop ends the run with lane-class credit-stop and runs no [["KEY", ["ANTHROPIC_API_KEY"]]], ); assert.equal(outputs["lane-class"], "credit-stop"); + assert.equal(outputs.handoff, "true"); assert.equal(outputs.credential, KEY_NAME); assert.deepEqual( records.map((r) => [r.leg, r.secret, r.class, r.next]), @@ -334,14 +335,39 @@ test("a credit-stop-shaped failure on the subscription leg is never credit-stop" assert.equal(outputs.credential, TOKEN_NAME); }); -test("an auth failure on the key leg ends the run with its class", () => { - const { outputs, calls } = runCase({ key: AUTH }); +test("a rejected key hands off to the subscription job and keeps class auth", () => { + const { outputs, calls, records } = runCase({ key: AUTH }); assert.deepEqual( calls.map((c) => c.leg), ["KEY"], ); assert.equal(outputs["lane-class"], "auth"); + assert.equal(outputs.handoff, "true"); assert.equal(outputs.credential, KEY_NAME); + assert.deepEqual( + records.map((r) => [r.class, r.next]), + [["auth", "subscription"]], + ); +}); + +test("a rejected subscription token, the last leg, hands off nothing", () => { + const { outputs, records } = runCase({ sub: AUTH }); + assert.equal(outputs["lane-class"], "auth"); + assert.equal(outputs.handoff, "false"); + assert.equal(records[0].next, null); +}); + +test("a key leg hands off on no other failure class", () => { + for (const [name, key, extra] of [ + ["max-turns", MAX_TURNS, {}], + ["rate-limit", SESSION_LIMIT, {}], + ["timeout", SUCCESS, { keySleep: true, legTimeoutMs: 300 }], + ]) { + const { outputs, records } = runCase({ key, ...extra }); + assert.equal(outputs["lane-class"], name, name); + assert.equal(outputs.handoff, "false", name); + assert.equal(records[0].next, null, name); + } }); test("max-turns and timeout on the key leg end the run with their class", () => { @@ -365,6 +391,7 @@ test("a key-leg success writes the outputs from that leg", () => { ); assert.deepEqual(outputs, { "lane-class": "", + handoff: "false", "lane-resets": "", "lane-turns": "3", "lane-models": "claude-sonnet-5", @@ -891,6 +918,20 @@ test("cli-version latest resolves from npm view; exact versions pass; others fai ); }); +test("the action's cli-version default resolves the newest release from npm view", () => { + const { parseWorkflow } = require("../../scripts/workflow-yaml.cjs"); + const action = parseWorkflow( + fs.readFileSync(path.join(__dirname, "action.yml"), "utf8"), + ); + let viewed = 0; + const version = resolveCliVersion(action.inputs["cli-version"].default, () => { + viewed += 1; + return "2.1.999\n"; + }); + assert.equal(version, "2.1.999"); + assert.equal(viewed, 1); +}); + function configEnv(overrides = {}) { const prompt = path.join(root, "config-prompt.md"); fs.writeFileSync(prompt, "Do the task.\n"); @@ -1136,9 +1177,35 @@ test("run on a key-leg credit stop sets lane-class credit-stop and starts no sub const summaryText = fs.readFileSync(env.GITHUB_STEP_SUMMARY, "utf8"); assert.match( summaryText, - /\| 1 \| AUTOMATIONS_CLAUDE_API_KEY \| credit-stop \| .* \| subscription \| credit stop: add Console credit or raise the spend limit \|/u, + /\| 1 \| AUTOMATIONS_CLAUDE_API_KEY \| credit-stop \| .* \| subscription \| credits used up: the subscription job runs; the owner rotates a key by hand when needed \|/u, ); assert.equal(summaryText.includes("Credit balance"), false); + assert.equal(readOutputs(env.GITHUB_OUTPUT).handoff, "true"); +}); + +test("run on a rejected key sets handoff and a summary row that names the dead key", () => { + const dir = path.join(root, "run-auth"); + const env = runEnv(dir, {}); + env.FAKE_KEY = legFile(dir, "key.jsonl", AUTH); + env.FAKE_KEY_EXIT = "1"; + assert.throws( + () => run(env), + /intake ended class=auth on AUTOMATIONS_CLAUDE_API_KEY/u, + ); + const outputs = readOutputs(env.GITHUB_OUTPUT); + assert.equal(outputs["lane-class"], "auth"); + assert.equal(outputs.handoff, "true"); + const summaryText = fs.readFileSync(env.GITHUB_STEP_SUMMARY, "utf8"); + assert.match( + summaryText, + /\| 1 \| AUTOMATIONS_CLAUDE_API_KEY \| auth \| .* \| subscription \| credential rejected \(disabled or deleted\): the owner replaces the secret by hand \|/u, + ); + const [record] = fs + .readFileSync(outputs["log-file"], "utf8") + .trim() + .split("\n") + .map((l) => JSON.parse(l)); + assert.deepEqual([record.class, record.next], ["auth", "subscription"]); }); test("run refuses both credentials before any leg starts", () => { @@ -1162,15 +1229,29 @@ test("the summary shows a closed token per class and never a record's message", next: null, message: "::error::planted CLI text", }); - const table = summaryTable( - ["", "auth", "timeout", "max-turns", "overloaded", "other", "unknown"].map( - record, - ), - ); + const classes = [ + "", + "credit-stop", + "auth", + "rate-limit", + "timeout", + "max-turns", + "overloaded", + "other", + "unknown", + "constructor", + ]; + const table = summaryTable(classes.map(record)); assert.equal(table.includes("planted"), false); assert.match(table, /\| success \| 0 \| 0 \| \| \| \|$/mu); - assert.match(table, /\| auth \| .* \| credential unusable: replace the secret \|/u); + assert.match( + table, + /\| auth \| .* \| credential rejected \(disabled or deleted\): the owner replaces the secret by hand \|/u, + ); assert.match(table, /\| unknown \| .* \| see the step log \|/u); + assert.match(table, /\| constructor \| .* \| see the step log \|/u); + // No spend limits exist to raise: credits are bought, with auto-reload off. + assert.doesNotMatch(table, /spend limit/iu); }); test("run refuses a loader, TLS or proxy variable before any leg", () => { @@ -1557,6 +1638,26 @@ test("install verifies both packages and the signed binary, then writes the outp assert.ok(out.includes(`cli-path=${cliPath}\n`)); }); +test("install with an exact cli-version installs that version and asks npm view nothing", () => { + const world = installWorld({ input: "2.1.305" }); + world.run(); + const npm = world.calls.filter((c) => c.command === "npm"); + assert.deepEqual( + npm.map((c) => c.args[0]), + ["--version", "install", "audit"], + ); + assert.equal(npm[1].args.at(-1), "@anthropic-ai/claude-code@2.1.305"); + assert.ok( + world.calls.some( + (c) => + c.command === "curl" && + c.args.at(-1) === + "https://downloads.claude.ai/claude-code-releases/2.1.305/manifest.json", + ), + ); + assert.match(fs.readFileSync(world.output, "utf8"), /^cli-version=2\.1\.305$/mu); +}); + // Each case fails the install step, so no output is written and the run step, // which runs the leg, never starts. for (const [name, options, pattern] of [ diff --git a/.github/workflows/intake-triage.yml b/.github/workflows/intake-triage.yml index d79b7e9e..4b04937f 100644 --- a/.github/workflows/intake-triage.yml +++ b/.github/workflows/intake-triage.yml @@ -126,8 +126,7 @@ name: intake-triage # # CLI VERSION: run-claude-cli installs the Claude Code CLI at run time. # `cli-version`, else the caller repo's CLAUDE_LANE_CLI_VERSION variable, -# else the pinned 2.1.304 (`npm view @anthropic-ai/claude-code version`, -# 2026-10-20), selects it: `latest` or an exact version. `stable` and +# else `latest`, selects it: `latest` or an exact version. `stable` and # `bundled`, which the claude-code-action lane took, run `latest` with a # warning. # @@ -193,7 +192,7 @@ on: description: >- Claude Code CLI to run: latest or an exact major.minor.patch (stable and bundled run latest with a warning). Empty falls back to the - CLAUDE_LANE_CLI_VERSION variable, then the pinned 2.1.304. + CLAUDE_LANE_CLI_VERSION variable, then latest. type: string default: "" claude-args: @@ -519,7 +518,7 @@ jobs: ESCALATION_LABEL: ${{ inputs.escalation-label }} FLOOR_LABEL: ${{ inputs.floor-label }} BASE_ARGS: ${{ inputs.claude-args }} - CLI_VERSION: ${{ inputs.cli-version || vars.CLAUDE_LANE_CLI_VERSION || '2.1.304' }} + CLI_VERSION: ${{ inputs.cli-version || vars.CLAUDE_LANE_CLI_VERSION || 'latest' }} REPOSITORY: ${{ github.repository }} ISSUE_NUMBER: ${{ steps.issue.outputs.number }} ISSUE_FILE: ${{ steps.fetch.outputs.issue-file }} @@ -1044,7 +1043,7 @@ jobs: ESCALATION_LABEL: ${{ inputs.escalation-label }} FLOOR_LABEL: ${{ inputs.floor-label }} BASE_ARGS: ${{ inputs.claude-args }} - CLI_VERSION: ${{ inputs.cli-version || vars.CLAUDE_LANE_CLI_VERSION || '2.1.304' }} + CLI_VERSION: ${{ inputs.cli-version || vars.CLAUDE_LANE_CLI_VERSION || 'latest' }} REPOSITORY: ${{ github.repository }} ISSUE_NUMBER: ${{ steps.issue.outputs.number }} ISSUE_FILE: ${{ steps.fetch.outputs.issue-file }} diff --git a/README.md b/README.md index 3f428e17..b06b5f4d 100644 --- a/README.md +++ b/README.md @@ -603,13 +603,16 @@ consumer to audit it. so none of the three lanes double-report). - `.github/actions/run-claude-cli` — runs one prompt with headless `claude -p` for an agent-mode lane on a Linux runner, installing the Claude Code CLI - version `cli-version` names (an exact version, pinned by default, or - `latest`). Each invocation runs one leg on one + version `cli-version` names (`latest` by default, or an exact version). + Each invocation runs one leg on one credential: pass exactly one of `api-key` and `subscription-token`, or - the action fails closed. A key leg that ends in a credit stop - (report-lane-outcome's opt-in `credit-stop` class) sets `lane-class` to - `credit-stop`; any other failure sets its own class, so a broken key stays - visible instead of spending the subscription. A caller that falls back to + the action fails closed. A key leg hands off to the subscription, output + `handoff` set to `true`, when it ends in a credit stop (report-lane-outcome's + opt-in `credit-stop` class: the role's credits are used up) or with its key + rejected (`auth`: the key was disabled or deleted). `lane-class` keeps + `credit-stop` or `auth`, so the job summary and the log name the reason and + a dead key stays visible. Any other failure hands off nothing. Rotating a + key stays the owner's manual step. A caller that falls back to the subscription does so in a second job (the two-job pattern below); a caller that does not reports `credit-stop` as `rate-limit`. The leg's CLI environment has every credential and workflow file-command variable @@ -655,12 +658,12 @@ consumer to audit it. **Two-job pattern for the subscription fallback.** Two legs in one job would share the runner user, the filesystem and the environment, so the fallback runs on a new VM. Job A runs the key leg with `api-key` only - (`continue-on-error: true` on the step) and exposes `lane-class` as a job - output. Job B runs the subscription leg with `subscription-token` only. - Only job B references the OAuth secret, and it: + (`continue-on-error: true` on the step) and exposes `handoff` and + `lane-class` as job outputs. Job B runs the subscription leg with + `subscription-token` only. Only job B references the OAuth secret, and it: - declares `needs: A` and - `if: needs.A.outputs.lane-class == 'credit-stop'`, an exact compare, + `if: needs.A.outputs.handoff == 'true'`, an exact compare, and never writes job A's outputs into a `run:` script; - runs on a fixed GitHub-hosted label (`runs-on: ubuntu-24.04`), never a caller-supplied runner; @@ -669,14 +672,16 @@ consumer to audit it. - reads only trusted inputs: no artifact download from job A and no cache restore. - Job A skips its outcome step on a credit stop, so whichever job triaged + Job A skips its outcome step on a handoff, so whichever job triaged reports. Job B passes report-lane-outcome's `fallback-reason`, `credit-stop` or `no-key` from job A's `lane-class` and key presence, so - its record says why it ran. A status job that needs both reads job B's - outcome when it ran, else job A's: one lane record per run. A lane that writes does it in a + its record says why it ran; report-lane-outcome takes no `auth` reason + yet, so a rejected key shows only in job A's summary, log and annotation. + A status job that needs both reads job B's outcome when it ran, else job A's: one lane record per run. A lane that writes does it in a separate job with no model that needs both and reads job B's outputs when it ran, else job A's, so the write happens once. - `intake-triage.yml` is the reference implementation. + `intake-triage.yml` is the reference implementation; it still gates job B + on `lane-class == 'credit-stop'`, so it does not hand off on `auth` yet. - `.github/actions/apply-claude-managed-settings` — writes the root-owned `/etc/claude-code/managed-settings.json` that pins `apiKeyHelper` and `env.ANTHROPIC_BASE_URL`, disables bypassPermissions mode and sets @@ -1095,9 +1100,8 @@ GitHub continues the normal weekly patching of each hosted image generation. is missing, so the result does not depend on whether `intake-label-needs-triage` ran first. It runs through `.github/actions/run-claude-cli` (lane `intake`, funding `role` default - `automations`), which installs the Claude Code CLI at run time - (`cli-version`, else the `CLAUDE_LANE_CLI_VERSION` variable, else the - pinned version in the workflow). + `automations`), which installs the newest Claude Code CLI at run time + (`cli-version`, else the `CLAUDE_LANE_CLI_VERSION` variable, else `latest`). `claude-args` may set only `--model`, `--effort` and `--max-turns`. The caller grants `contents: read` and `issues: write` and passes the role's `CLAUDE_API_KEY` and `CLAUDE_CODE_OAUTH_TOKEN` (at least one). The key From 47c14a7f08adde7e585d7581c54a00bd4c46042f Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Tue, 20 Oct 2026 22:08:57 -0400 Subject: [PATCH 2/6] feat(intake-triage): hand off to the subscription job on a rejected key - intake-triage gates its subscription job on the key job's `handoff` output (`== 'true'`) or an empty key, and both model jobs expose `handoff`. The key job's outcome and extract steps skip on a handoff, so a rejected key (`auth`) now falls back like a credit stop. - The subscription job passes `fallback-reason` `credit-stop`, `auth` or `no-key`; report-lane-outcome accepts `auth`, so the lane record names a dead key (`fallback=auth`). - The status job reports `auth` when the key was rejected and the subscription token is empty. - README: the reference implementation now hands off on `auth`, and the record tokens list `fallback=auth`. - lane.test.cjs: mark the overflow stub's unused parameters. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NY1V8t81GkG6jWNPVFjaca --- .../actions/report-lane-outcome/action.yml | 3 +- .../actions/report-lane-outcome/classify.cjs | 4 +- .../report-lane-outcome/classify.test.cjs | 6 +- .../report-lane-outcome/outcome-step.test.cjs | 23 ++++- .github/actions/run-claude-cli/lane.test.cjs | 2 +- .github/scripts/intake-triage-legs.test.cjs | 94 ++++++++++++------- .github/workflows/intake-triage.yml | 43 +++++---- README.md | 16 ++-- 8 files changed, 125 insertions(+), 66 deletions(-) diff --git a/.github/actions/report-lane-outcome/action.yml b/.github/actions/report-lane-outcome/action.yml index b588fb17..e0c31b73 100644 --- a/.github/actions/report-lane-outcome/action.yml +++ b/.github/actions/report-lane-outcome/action.yml @@ -82,7 +82,8 @@ inputs: fallback-reason: description: >- Why this run used a fallback credential: `credit-stop` (the key job - credit-stopped) or `no-key` (the key was empty). Printed as + credit-stopped), `auth` (the key job's key was rejected, disabled or + deleted) or `no-key` (the key was empty). Printed as `fallback=` right after `credential=`. Empty prints nothing; any other value fails the step before it reports. required: false diff --git a/.github/actions/report-lane-outcome/classify.cjs b/.github/actions/report-lane-outcome/classify.cjs index bf2951f2..659730c0 100644 --- a/.github/actions/report-lane-outcome/classify.cjs +++ b/.github/actions/report-lane-outcome/classify.cjs @@ -262,8 +262,8 @@ const MODEL_PATTERN = /^[\w.:@[\]-]{1,100}$/u; const COUNT_PATTERN = /^\d{1,6}$/u; const WINDOW_PATTERN = /^[a-z0-9_]{1,40}$/u; // Why a subscription job ran in the two-job pattern: the key job's credit -// stop, or no key at all (ci-workflows#806). -const FALLBACK_REASONS = ["credit-stop", "no-key"]; +// stop, its key rejected (disabled or deleted), or no key at all. +const FALLBACK_REASONS = ["credit-stop", "auth", "no-key"]; // SDK `resetsAt` is epoch time; a value past 1e12 can only be milliseconds. function isoFromEpoch(value) { diff --git a/.github/actions/report-lane-outcome/classify.test.cjs b/.github/actions/report-lane-outcome/classify.test.cjs index 3bd05b50..234f42ff 100644 --- a/.github/actions/report-lane-outcome/classify.test.cjs +++ b/.github/actions/report-lane-outcome/classify.test.cjs @@ -486,9 +486,13 @@ test("record tokens: a fallback reason prints right after the credential, only f recordTokens(run, { credential, fallbackReason: "no-key" }), "credential=AUTOMATIONS_CLAUDE_CODE_OAUTH_TOKEN fallback=no-key turns=4", ); + assert.equal( + recordTokens(run, { credential, fallbackReason: "auth" }), + "credential=AUTOMATIONS_CLAUDE_CODE_OAUTH_TOKEN fallback=auth turns=4", + ); for (const forged of [ "", - "auth", + "Auth", "Credit-Stop", " no-key", "credit-stop\n::error::x", diff --git a/.github/actions/report-lane-outcome/outcome-step.test.cjs b/.github/actions/report-lane-outcome/outcome-step.test.cjs index e253240f..1a44f9f2 100644 --- a/.github/actions/report-lane-outcome/outcome-step.test.cjs +++ b/.github/actions/report-lane-outcome/outcome-step.test.cjs @@ -468,12 +468,30 @@ test("a fallback reason rides beside the credential on the notice and the class assert.doesNotMatch(none.notices[0], /fallback=/u); }); -test("a fallback reason outside credit-stop and no-key fails the step and reports nothing", async () => { +test("an auth fallback reason, a rejected key, is recorded beside the credential", async () => { + const succeeded = writeExecutionFile([ + { type: "result", subtype: "success", is_error: false, num_turns: 2 }, + ]); + const run = await runOutcome({ + outcome: "success", + executionFile: succeeded, + credential: "AUTOMATIONS_CLAUDE_CODE_OAUTH_TOKEN", + fallbackReason: "auth", + }); + assert.deepEqual(run.failed, []); + assert.equal(run.notices.length, 1); + assert.match( + run.notices[0], + / credential=AUTOMATIONS_CLAUDE_CODE_OAUTH_TOKEN fallback=auth turns=2\b/u, + ); +}); + +test("a fallback reason outside credit-stop, auth and no-key fails the step and reports nothing", async () => { const file = writeExecutionFile([ { type: "result", subtype: "success", is_error: false, num_turns: 5 }, ]); for (const outcome of ["success", "failure"]) { - for (const fallbackReason of ["auth", "Credit-Stop", " credit-stop"]) { + for (const fallbackReason of ["Auth", "Credit-Stop", " credit-stop"]) { const run = await runOutcome({ outcome, executionFile: file, @@ -483,6 +501,7 @@ test("a fallback reason outside credit-stop and no-key fails the step and report assert.equal(run.failed.length, 1, label); assert.match(run.failed[0], /credit-stop/u, label); assert.match(run.failed[0], /no-key/u, label); + assert.match(run.failed[0], /\bauth\b/u, label); assert.deepEqual(run.notices, [], label); assert.deepEqual(run.errors, [], label); assert.deepEqual(run.warnings, [], label); diff --git a/.github/actions/run-claude-cli/lane.test.cjs b/.github/actions/run-claude-cli/lane.test.cjs index 806951a2..4b5726f7 100644 --- a/.github/actions/run-claude-cli/lane.test.cjs +++ b/.github/actions/run-claude-cli/lane.test.cjs @@ -794,7 +794,7 @@ test("a process the leg leaves behind cannot add a lane-class after the launcher test("stdout is captured in memory and a maxBuffer overflow is class other", () => { const seen = []; - const spawn = (command, args, options) => { + const spawn = (_command, _args, options) => { seen.push(options); const overflow = new Error("spawnSync ENOBUFS"); overflow.code = "ENOBUFS"; diff --git a/.github/scripts/intake-triage-legs.test.cjs b/.github/scripts/intake-triage-legs.test.cjs index b92c7ff0..d97a4c21 100644 --- a/.github/scripts/intake-triage-legs.test.cjs +++ b/.github/scripts/intake-triage-legs.test.cjs @@ -3,8 +3,9 @@ // The intake lane runs the API key and the subscription token in separate // jobs (ci-workflows#799). The claude job holds only the key; the // claude-subscription job holds only the token, runs on a fixed GitHub-hosted -// runner only after a key credit stop (or with no key), repeats the claude -// job's hardening, and takes nothing from it but two compared outputs. Both +// runner only after the key job hands off (a credit stop or a rejected key) +// or with no key, repeats the claude job's hardening, and takes nothing from +// it but compared outputs. Both // model jobs are read-only (ci-workflows#804): one apply job with no model // writes the triage of whichever leg triaged. The status job reports one // outcome: the subscription job's when it ran, red when the apply job failed. @@ -60,31 +61,47 @@ test("the subscription job runs on a fixed GitHub-hosted label, after the claude assert.equal(subscription.name, "claude-intake-triage-subscription"); }); -test("the subscription job starts only on an exact credit-stop or an empty key", () => { +test("the subscription job starts only on an exact handoff or an empty key", () => { const starts = (outputs) => Boolean(evaluate(subscription.if, { needs: { claude: { outputs } } })); + for (const laneClass of ["credit-stop", "auth"]) { + assert.equal( + starts({ + handoff: "true", + "lane-class": laneClass, + "credential-present": "true", + }), + true, + laneClass, + ); + } assert.equal( - starts({ "lane-class": "credit-stop", "credential-present": "true" }), - true, - ); - assert.equal( - starts({ "lane-class": "", "credential-present": "false" }), + starts({ handoff: "", "lane-class": "", "credential-present": "false" }), true, ); - for (const laneClass of [ - "", - "rate-limit", - "auth", - "other", - "credit-stop-x", - " credit-stop", - ]) { + // The handoff alone decides: a lane-class with no handoff starts nothing. + for (const laneClass of ["credit-stop", "auth", "rate-limit", "other", ""]) { assert.equal( - starts({ "lane-class": laneClass, "credential-present": "true" }), + starts({ + handoff: "false", + "lane-class": laneClass, + "credential-present": "true", + }), false, laneClass, ); } + for (const handoff of ["", "True", "true ", "1"]) { + assert.equal( + starts({ + handoff, + "lane-class": "auth", + "credential-present": "true", + }), + false, + JSON.stringify(handoff), + ); + } // A failed or cancelled claude job never starts it: the if has no status // function, so success() applies. assert.doesNotMatch(subscription.if, /always\(\)|failure\(\)|cancelled\(\)/u); @@ -105,6 +122,7 @@ test("the subscription job downloads nothing from the claude job and never write // The subscription job's outcome step names why it ran (ci-workflows#806). const FALLBACK_REASON = "${{ needs.claude.outputs.lane-class == 'credit-stop' && 'credit-stop' || " + + "needs.claude.outputs.lane-class == 'auth' && 'auth' || " + "needs.claude.outputs.credential-present == 'false' && 'no-key' || '' }}"; test("the subscription job repeats the claude job's steps but for the credential and the fallback reason", () => { @@ -148,7 +166,7 @@ test("the subscription job repeats the claude job's steps but for the credential ); }); -test("the subscription job's lane record names the credit stop or the empty key it ran for", () => { +test("the subscription job's lane record names the credit stop, the rejected key or the empty key it ran for", () => { const value = subscription.steps.find((step) => step.id === "review-outcome") .with["fallback-reason"]; const reason = (outputs) => @@ -163,34 +181,33 @@ test("the subscription job's lane record names the credit stop or the empty key ); assert.equal( reason({ "lane-class": "auth", "credential-present": "true" }), - "", + "auth", ); }); -test("a key credit stop skips the claude job's outcome and extract steps", () => { +test("a handoff skips the claude job's outcome and extract steps", () => { const byId = (id) => claude.steps.find((step) => step.id === id); const extract = byId("extract"); - const steps = (laneClass, present = "true") => ({ + const steps = (handoff, present = "true") => ({ compose: { outcome: "success" }, credential: { outputs: { present } }, - claude: { outputs: { "lane-class": laneClass } }, + claude: { outputs: { handoff } }, }); for (const step of [byId("review-outcome"), extract]) { assert.equal( - Boolean(evaluate(step.if, { steps: steps("credit-stop") })), + Boolean(evaluate(step.if, { steps: steps("true") })), false, step.name, ); - assert.equal( - Boolean(evaluate(step.if, { steps: steps("") })), - true, - step.name, - ); - assert.equal( - Boolean(evaluate(step.if, { steps: steps("auth") })), - true, - step.name, - ); + // No handoff, or a step that failed before the leg ran: the claude job + // reports. + for (const handoff of ["false", ""]) { + assert.equal( + Boolean(evaluate(step.if, { steps: steps(handoff) })), + true, + `${step.name} ${JSON.stringify(handoff)}`, + ); + } assert.equal( Boolean(evaluate(step.if, { steps: steps("", "false") })), false, @@ -284,6 +301,17 @@ test("an empty secret in the job that should triage fails with a fixed class", ( "triage-failed": "true", "failure-class": "rate-limit", }); + // A rejected key with no subscription token stays an auth failure. + const deadKeyNoToken = report({ + KEY_CLASS: "auth", + SUB_RESULT: "success", + SUB_PRESENT: "false", + }); + assert.equal(deadKeyNoToken.code, 1); + assert.deepEqual(deadKeyNoToken.outputs, { + "triage-failed": "true", + "failure-class": "auth", + }); // Both secrets empty. const neither = report({ KEY_PRESENT: "false", diff --git a/.github/workflows/intake-triage.yml b/.github/workflows/intake-triage.yml index 4b04937f..da0a587a 100644 --- a/.github/workflows/intake-triage.yml +++ b/.github/workflows/intake-triage.yml @@ -43,14 +43,16 @@ name: intake-triage # without all three. It turns on the CLI's subprocess credential scrub # and puts exactly one Claude credential in the CLI environment. # - The API key runs in the claude job. The subscription token runs only in -# the claude-subscription job, and only when the claude job's lane-class -# output is exactly `credit-stop` or its key was empty. That job runs on -# a fresh ubuntu-24.04 GitHub-hosted runner, never the caller's runner -# input, repeats every hardening step, and takes nothing from the claude -# job but that output and the credential-present flag: no artifact, no -# cache. lane-class is set by run-claude-cli after it restores the step -# files, so the model cannot set it; a forged credit stop would cost only -# subscription usage. Either secret may be empty, not both. +# the claude-subscription job, and only when the claude job's handoff +# output is exactly `true` (the key's credits are used up, lane-class +# `credit-stop`, or the key was rejected, lane-class `auth`) or its key +# was empty. That job runs on a fresh ubuntu-24.04 GitHub-hosted runner, +# never the caller's runner input, repeats every hardening step, and +# takes nothing from the claude job but those outputs and the +# credential-present flag: no artifact, no cache. handoff and lane-class +# are set by run-claude-cli after it restores the step files, so the +# model cannot set them; a forged handoff would cost only subscription +# usage. Either secret may be empty, not both. # - The model jobs cannot write: their token has contents: read and # issues: read, and `cache-mode: none` closes the Actions cache, which # a workflow_dispatch run could otherwise write. The run-claude-cli step's @@ -332,6 +334,7 @@ jobs: cache-mode: none outputs: lane-class: ${{ steps.claude.outputs.lane-class }} + handoff: ${{ steps.claude.outputs.handoff }} credential-present: ${{ steps.credential.outputs.present }} triage-failed: ${{ steps.review-outcome.outputs.review-failed }} failure-class: ${{ steps.claude.outputs.lane-class || steps.review-outcome.outputs.failure-class }} @@ -748,7 +751,7 @@ jobs: - name: Report triage outcome id: review-outcome - if: steps.credential.outputs.present == 'true' && steps.claude.outputs.lane-class != 'credit-stop' + if: steps.credential.outputs.present == 'true' && steps.claude.outputs.handoff != 'true' uses: $/.github/actions/report-lane-outcome with: outcome: ${{ steps.claude.outcome }} @@ -767,7 +770,7 @@ jobs: # reason, turns and denied tool names go to this job's summary only. - name: Extract the triage id: extract - if: always() && steps.compose.outcome == 'success' && steps.credential.outputs.present == 'true' && steps.claude.outputs.lane-class != 'credit-stop' + if: always() && steps.compose.outcome == 'success' && steps.credential.outputs.present == 'true' && steps.claude.outputs.handoff != 'true' uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: EXECUTION_FILE: ${{ steps.claude.outputs.execution-file }} @@ -839,14 +842,14 @@ jobs: # The subscription leg, as its own job on a fresh VM: the claude job's # processes, files and environment do not reach it. Its steps repeat the # claude job's but for the credential (a test holds them equal), so the - # hardening runs again before the checkout. It reads two outputs of the + # hardening runs again before the checkout. It reads three outputs of the # claude job, each compared to a fixed string here and never written into # a run: script, and nothing else from that job. It does not use # inputs.runner: a caller's runner could keep state between jobs. subscription: name: claude-intake-triage-subscription needs: claude - if: needs.claude.outputs.lane-class == 'credit-stop' || needs.claude.outputs.credential-present == 'false' + if: needs.claude.outputs.handoff == 'true' || needs.claude.outputs.credential-present == 'false' runs-on: ubuntu-24.04 timeout-minutes: 16 # The model's job reads and never writes: the token can read the issue @@ -857,6 +860,7 @@ jobs: cache-mode: none outputs: lane-class: ${{ steps.claude.outputs.lane-class }} + handoff: ${{ steps.claude.outputs.handoff }} credential-present: ${{ steps.credential.outputs.present }} triage-failed: ${{ steps.review-outcome.outputs.review-failed }} failure-class: ${{ steps.claude.outputs.lane-class || steps.review-outcome.outputs.failure-class }} @@ -1273,7 +1277,7 @@ jobs: - name: Report triage outcome id: review-outcome - if: steps.credential.outputs.present == 'true' && steps.claude.outputs.lane-class != 'credit-stop' + if: steps.credential.outputs.present == 'true' && steps.claude.outputs.handoff != 'true' uses: $/.github/actions/report-lane-outcome with: outcome: ${{ steps.claude.outcome }} @@ -1285,7 +1289,7 @@ jobs: max-turns: ${{ steps.compose.outputs.max-turns }} known-failure-class: ${{ steps.claude.outputs.lane-class }} # Why this job ran, for the run's one lane record (ci-workflows#806). - fallback-reason: ${{ needs.claude.outputs.lane-class == 'credit-stop' && 'credit-stop' || needs.claude.outputs.credential-present == 'false' && 'no-key' || '' }} + fallback-reason: ${{ needs.claude.outputs.lane-class == 'credit-stop' && 'credit-stop' || needs.claude.outputs.lane-class == 'auth' && 'auth' || needs.claude.outputs.credential-present == 'false' && 'no-key' || '' }} # No model runs here. It reduces the run to the job outputs the apply # job reads: the result subtype, the error flag and the denial count, @@ -1294,7 +1298,7 @@ jobs: # reason, turns and denied tool names go to this job's summary only. - name: Extract the triage id: extract - if: always() && steps.compose.outcome == 'success' && steps.credential.outputs.present == 'true' && steps.claude.outputs.lane-class != 'credit-stop' + if: always() && steps.compose.outcome == 'success' && steps.credential.outputs.present == 'true' && steps.claude.outputs.handoff != 'true' uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 env: EXECUTION_FILE: ${{ steps.claude.outputs.execution-file }} @@ -1659,10 +1663,15 @@ jobs: job=$KEY_RESULT present=$KEY_PRESENT failed=$KEY_FAILED class=$KEY_CLASS fi # A triage job with an empty secret did not triage: after a key credit - # stop that is a limit stop, otherwise both secrets were empty. + # stop that is a limit stop, after a rejected key it is that auth + # failure, otherwise both secrets were empty. if [ "$present" = false ]; then failed=true - if [ "$KEY_CLASS" = credit-stop ]; then class=rate-limit; else class=other; fi + case "$KEY_CLASS" in + credit-stop) class=rate-limit ;; + auth) class=auth ;; + *) class=other ;; + esac fi # A failed or cancelled write fails the record like a failed leg. if [ "$job" = success ]; then diff --git a/README.md b/README.md index b06b5f4d..000619af 100644 --- a/README.md +++ b/README.md @@ -674,14 +674,12 @@ consumer to audit it. Job A skips its outcome step on a handoff, so whichever job triaged reports. Job B passes report-lane-outcome's `fallback-reason`, - `credit-stop` or `no-key` from job A's `lane-class` and key presence, so - its record says why it ran; report-lane-outcome takes no `auth` reason - yet, so a rejected key shows only in job A's summary, log and annotation. + `credit-stop`, `auth` or `no-key` from job A's `lane-class` and key + presence, so its record says why it ran, a dead key included. A status job that needs both reads job B's outcome when it ran, else job A's: one lane record per run. A lane that writes does it in a separate job with no model that needs both and reads job B's outputs when it ran, else job A's, so the write happens once. - `intake-triage.yml` is the reference implementation; it still gates job B - on `lane-class == 'credit-stop'`, so it does not hand off on `auth` yet. + `intake-triage.yml` is the reference implementation. - `.github/actions/apply-claude-managed-settings` — writes the root-owned `/etc/claude-code/managed-settings.json` that pins `apiKeyHelper` and `env.ANTHROPIC_BASE_URL`, disables bypassPermissions mode and sets @@ -1105,8 +1103,8 @@ GitHub continues the normal weekly patching of each hosted image generation. `claude-args` may set only `--model`, `--effort` and `--max-turns`. The caller grants `contents: read` and `issues: write` and passes the role's `CLAUDE_API_KEY` and `CLAUDE_CODE_OAUTH_TOKEN` (at least one). The key - runs in the `claude-intake-triage` job; after its credit stop, or with no - key, the token runs in the `claude-intake-triage-subscription` job on + runs in the `claude-intake-triage` job; after it hands off (a credit stop + or a rejected key), or with no key, the token runs in the `claude-intake-triage-subscription` job on `ubuntu-24.04` (the two-job pattern above); `claude-intake-triage-apply` writes whichever job triaged, and `claude-intake-triage-status` reports the one outcome. The workflow @@ -1272,8 +1270,8 @@ reached; re-run after it resets" (the `class=rate-limit` token is unchanged). Every outcome annotation, and a notice on a run that completed, also carries the run record as bare tokens, each omitted when unknown: `turns=`, `max-turns=` (the `max-turns` input), `credential=` (the -`credential` input), `fallback=credit-stop` or `fallback=no-key` (the -`fallback-reason` input, which rejects any other value), +`credential` input), `fallback=credit-stop`, `fallback=auth` or +`fallback=no-key` (the `fallback-reason` input, which rejects any other value), `models=` and, on `class=rate-limit`, `resets=` and `resets-window=` from the run's newest `rejected` `rate_limit_event` (none without one), the time also From bf46bf2831fbdb1f879f4ead12eacef9579c8155 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Tue, 20 Oct 2026 22:22:53 -0400 Subject: [PATCH 3/6] test(run-claude-cli): say why no summary note names a spend limit Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NY1V8t81GkG6jWNPVFjaca --- .github/actions/run-claude-cli/lane.test.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/run-claude-cli/lane.test.cjs b/.github/actions/run-claude-cli/lane.test.cjs index 4b5726f7..e79c7f53 100644 --- a/.github/actions/run-claude-cli/lane.test.cjs +++ b/.github/actions/run-claude-cli/lane.test.cjs @@ -1250,7 +1250,7 @@ test("the summary shows a closed token per class and never a record's message", ); assert.match(table, /\| unknown \| .* \| see the step log \|/u); assert.match(table, /\| constructor \| .* \| see the step log \|/u); - // No spend limits exist to raise: credits are bought, with auto-reload off. + // No note tells the owner to raise a spend limit: the owner runs none. assert.doesNotMatch(table, /spend limit/iu); }); From ca3938a2c3a04f471c742bdb8cab89a415da3876 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Tue, 20 Oct 2026 22:31:17 -0400 Subject: [PATCH 4/6] fix(run-claude-cli): hand off on auth only for API status 401 or 402 - A key leg in class `auth` hands off only when the last message's numeric api_error_status is 401 or 402. A 403 (permission_error) keeps class `auth` and fails the run. The decision never reads an error-type string, so errors[] text naming permission_error cannot trigger a handoff. - intake-triage's status job warns whenever the key job's class is `auth`, naming the class and telling the owner to replace the secret, so a refused key stays visible when the subscription job then triages green. - Comments in intake-triage.yml and action.yml state the new scope. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NY1V8t81GkG6jWNPVFjaca --- .github/actions/run-claude-cli/action.yml | 16 +++-- .github/actions/run-claude-cli/lane.cjs | 34 ++++++++--- .github/actions/run-claude-cli/lane.test.cjs | 62 +++++++++++++++++++- .github/scripts/intake-triage-legs.test.cjs | 24 ++++++++ .github/workflows/intake-triage.yml | 32 ++++++---- README.md | 8 ++- 6 files changed, 143 insertions(+), 33 deletions(-) diff --git a/.github/actions/run-claude-cli/action.yml b/.github/actions/run-claude-cli/action.yml index b4c5ceec..6d46af24 100644 --- a/.github/actions/run-claude-cli/action.yml +++ b/.github/actions/run-claude-cli/action.yml @@ -4,7 +4,8 @@ description: >- Linux runner, on exactly one credential: set `api-key` or `subscription-token`, never both (the action fails closed otherwise). A key leg that ends in a credit stop (classify.cjs isCreditStop, lane-class - `credit-stop`) or a rejected key (lane-class `auth`) sets handoff `true`; + `credit-stop`) or a key the API refused with status 401 or 402 (lane-class + `auth`) sets handoff `true`; a caller that falls back to the subscription runs it as a second job on a fixed GitHub-hosted runner, gated on that exact value (see the README's two-job pattern), never in this job. @@ -148,9 +149,10 @@ outputs: The leg's failure class; empty on success. `credit-stop` (key leg only) means the key's credits are used up; a caller that does not fall back reports it as `rate-limit`, the class report-lane-outcome knows. - `auth` means the credential was rejected (disabled or deleted). - Otherwise it is report-lane-outcome's class: a failed install or integrity check reports `install-failed`, - and any other failure before the leg ran, or a leg whose stdout passes + `auth` means the credential is unusable: API status 401 (disabled or + deleted), 402 (billing) or 403 (permission). Otherwise it is + report-lane-outcome's class: a failed install or integrity check + reports `install-failed`, and any other failure before the leg ran, or a leg whose stdout passes 256 MiB, reports `other`. Report this class; do not reclassify execution-file, which cannot see the credit-stop or leg-timeout rules. Set after the step files are restored, so the leg cannot set it. @@ -161,8 +163,10 @@ outputs: || '' }} handoff: description: >- - `true` when a key leg ended in `credit-stop` or `auth`, so the caller - may run the subscription leg in a separate job; `false` otherwise; + `true` when a key leg ended in `credit-stop`, or in `auth` with the + numeric API status 401 or 402, so the caller may run the subscription + leg in a separate job; `false` otherwise, a 403 included, which fails + the run instead; empty when the step failed before the leg ran. lane-class keeps the reason. Set after the step files are restored, so the leg cannot set it. value: ${{ steps.run.outputs.handoff }} diff --git a/.github/actions/run-claude-cli/lane.cjs b/.github/actions/run-claude-cli/lane.cjs index d832ea86..e774bef9 100644 --- a/.github/actions/run-claude-cli/lane.cjs +++ b/.github/actions/run-claude-cli/lane.cjs @@ -15,8 +15,8 @@ // Security contract: // - One leg per invocation: readConfig fails closed unless exactly one of // the two credentials is set. A caller that falls back to the -// subscription after a key leg hands off (a credit stop or a rejected -// key, NEXT_STEPS) runs a second job, on a fresh runner, gated on this +// subscription after a key leg hands off (a credit stop, or class auth +// with api_error_status 401 or 402, NEXT_STEPS) runs a second job, on a fresh runner, gated on this // one's handoff output being `true`. // - legEnv copies the step environment and removes every credential and // file-command VARIABLE, then sets the leg's one credential. That is a @@ -132,17 +132,22 @@ const UNSAFE_VARIABLES = new Set([ "NODE_TLS_REJECT_UNAUTHORIZED", ]); // What each class means for the run. `handoff`: a key leg that ends in it -// hands the run to the caller's subscription job. `note`: the job summary's -// closed token, the named stop and what happens next. +// hands the run to the caller's subscription job; `statuses`, when set, +// narrows that to these numeric api_error_status values, never an error-type +// string, which errors[] text could carry. `note`: the job summary's closed +// token, the named stop and what happens next. const NEXT_STEPS = { "": { handoff: false, note: "" }, "credit-stop": { handoff: true, note: "credits used up: the subscription job runs; the owner rotates a key by hand when needed", }, + // 401 (key disabled or deleted) and 402 (billing) hand off; 403 + // (permission_error) fails the run. auth: { handoff: true, - note: "credential rejected (disabled or deleted): the owner replaces the secret by hand", + statuses: [401, 402], + note: "credential unusable (rejected, unpaid or not permitted): the owner replaces the secret by hand", }, "rate-limit": { handoff: false, note: "limit stop: rerun after the reset" }, overloaded: { handoff: false, note: "API overloaded: rerun later" }, @@ -164,8 +169,11 @@ function nextStep(failureClass) { } // Only a key leg hands off: the subscription leg is the last one. -function handsOff(leg, failureClass) { - return leg.leg === "api-key" && nextStep(failureClass).handoff; +// `apiErrorStatus` is the last message's numeric api_error_status. +function handsOff(leg, failureClass, apiErrorStatus) { + const step = nextStep(failureClass); + if (leg.leg !== "api-key" || !step.handoff) return false; + return step.statuses === undefined || step.statuses.includes(apiErrorStatus); } class LaneError extends Error { @@ -662,6 +670,7 @@ function runLeg( const modes = []; let record; let judged; + let handoff = false; try { const readOnly = readOnlyPaths( config, @@ -706,6 +715,13 @@ function runLeg( maxTurns: config.maxTurns, }); } + // The same message classify.cjs reads its status from. + const status = judged.messages.at(-1)?.api_error_status; + handoff = handsOff( + leg, + judged.failureClass, + Number.isInteger(status) ? status : null, + ); record = legRecord({ config, leg, @@ -715,7 +731,7 @@ function runLeg( messages: judged.messages, failureClass: judged.failureClass, resets: judged.resets, - next: handsOff(leg, judged.failureClass) ? "subscription" : null, + next: handoff ? "subscription" : null, message, }); } finally { @@ -730,7 +746,7 @@ function runLeg( records: [record], outputs: { "lane-class": judged.failureClass, - handoff: String(handsOff(leg, judged.failureClass)), + handoff: String(handoff), "lane-resets": judged.resets ?? "", "lane-turns": run.turns === null ? "" : String(run.turns), "lane-models": run.models.join(","), diff --git a/.github/actions/run-claude-cli/lane.test.cjs b/.github/actions/run-claude-cli/lane.test.cjs index e79c7f53..dd40d4ad 100644 --- a/.github/actions/run-claude-cli/lane.test.cjs +++ b/.github/actions/run-claude-cli/lane.test.cjs @@ -350,6 +350,64 @@ test("a rejected key hands off to the subscription job and keeps class auth", () ); }); +// An auth leg with the given numeric status, or none, and errors[] entries. +// The 402 and 403 bodies follow the published error table +// (platform.claude.com/docs/en/api/errors): billing_error and +// permission_error. +function authLeg({ status, errors }) { + return [ + result({ + ...(errors ? { subtype: "error_during_execution", errors } : {}), + is_error: true, + num_turns: 0, + result: "API Error", + ...(status === undefined ? {} : { api_error_status: status }), + usage: { input_tokens: 0, output_tokens: 0 }, + }), + ]; +} + +test("a key refused with 401 or 402 hands off; a 403 keeps class auth and fails the run", () => { + for (const [status, handoff] of [ + [401, "true"], + [402, "true"], + [403, "false"], + ]) { + const { outputs, records } = runCase({ key: authLeg({ status }) }); + assert.equal(outputs["lane-class"], "auth", String(status)); + assert.equal(outputs.handoff, handoff, String(status)); + assert.equal( + records[0].next, + handoff === "true" ? "subscription" : null, + String(status), + ); + } +}); + +test("a 403 whose errors[] text names another type does not hand off", () => { + const { outputs } = runCase({ + key: authLeg({ + status: 403, + errors: ['{"type":"error","error":{"type":"authentication_error"}}'], + }), + }); + assert.equal(outputs["lane-class"], "auth"); + assert.equal(outputs.handoff, "false"); +}); + +test("permission_error in errors[] text alone, with no numeric status, does not hand off", () => { + const { outputs, records } = runCase({ + key: authLeg({ + errors: [ + 'model text: {"type":"error","error":{"type":"permission_error"}}', + ], + }), + }); + assert.equal(outputs["lane-class"], "auth"); + assert.equal(outputs.handoff, "false"); + assert.equal(records[0].next, null); +}); + test("a rejected subscription token, the last leg, hands off nothing", () => { const { outputs, records } = runCase({ sub: AUTH }); assert.equal(outputs["lane-class"], "auth"); @@ -1198,7 +1256,7 @@ test("run on a rejected key sets handoff and a summary row that names the dead k const summaryText = fs.readFileSync(env.GITHUB_STEP_SUMMARY, "utf8"); assert.match( summaryText, - /\| 1 \| AUTOMATIONS_CLAUDE_API_KEY \| auth \| .* \| subscription \| credential rejected \(disabled or deleted\): the owner replaces the secret by hand \|/u, + /\| 1 \| AUTOMATIONS_CLAUDE_API_KEY \| auth \| .* \| subscription \| credential unusable \(rejected, unpaid or not permitted\): the owner replaces the secret by hand \|/u, ); const [record] = fs .readFileSync(outputs["log-file"], "utf8") @@ -1246,7 +1304,7 @@ test("the summary shows a closed token per class and never a record's message", assert.match(table, /\| success \| 0 \| 0 \| \| \| \|$/mu); assert.match( table, - /\| auth \| .* \| credential rejected \(disabled or deleted\): the owner replaces the secret by hand \|/u, + /\| auth \| .* \| credential unusable \(rejected, unpaid or not permitted\): the owner replaces the secret by hand \|/u, ); assert.match(table, /\| unknown \| .* \| see the step log \|/u); assert.match(table, /\| constructor \| .* \| see the step log \|/u); diff --git a/.github/scripts/intake-triage-legs.test.cjs b/.github/scripts/intake-triage-legs.test.cjs index d97a4c21..9f62a42c 100644 --- a/.github/scripts/intake-triage-legs.test.cjs +++ b/.github/scripts/intake-triage-legs.test.cjs @@ -325,6 +325,30 @@ test("an empty secret in the job that should triage fails with a fixed class", ( }); }); +test("an unusable key warns the owner to replace the secret, even when the subscription job triaged", () => { + const warning = /^::warning[^:]*::class=auth: .*replace the secret/mu; + const fellBack = report({ + KEY_CLASS: "auth", + SUB_RESULT: "success", + SUB_PRESENT: "true", + SUB_FAILED: "false", + }); + assert.equal(fellBack.code, 0); + assert.match(fellBack.stdout, warning); + // A 403 does not hand off: the key job alone reports, red, and still warns. + const refused = report({ + KEY_RESULT: "success", + KEY_FAILED: "true", + KEY_CLASS: "auth", + }); + assert.equal(refused.code, 1); + assert.match(refused.stdout, warning); + for (const keyClass of ["", "credit-stop", "rate-limit", "other"]) { + const run = report({ KEY_CLASS: keyClass, KEY_FAILED: "false" }); + assert.doesNotMatch(run.stdout, /::warning/u, keyClass); + } +}); + test("the status job prints and writes only closed values", () => { const forged = report({ KEY_RESULT: "failure", diff --git a/.github/workflows/intake-triage.yml b/.github/workflows/intake-triage.yml index da0a587a..9e6e4341 100644 --- a/.github/workflows/intake-triage.yml +++ b/.github/workflows/intake-triage.yml @@ -45,8 +45,8 @@ name: intake-triage # - The API key runs in the claude job. The subscription token runs only in # the claude-subscription job, and only when the claude job's handoff # output is exactly `true` (the key's credits are used up, lane-class -# `credit-stop`, or the key was rejected, lane-class `auth`) or its key -# was empty. That job runs on a fresh ubuntu-24.04 GitHub-hosted runner, +# `credit-stop`, or the API refused the key with status 401 or 402, +# lane-class `auth`; a 403 fails the run instead) or its key was empty. That job runs on a fresh ubuntu-24.04 GitHub-hosted runner, # never the caller's runner input, repeats every hardening step, and # takes nothing from the claude job but those outputs and the # credential-present flag: no artifact, no cache. handoff and lane-class @@ -84,7 +84,7 @@ name: intake-triage # comment, needs_human) checked against the job's allowlist and enums. # - Only the claude-intake-triage-apply job writes, and it runs no model. # It takes the subscription job's outputs when that job ran, else the -# claude job's, so a credit stop applies once. It takes the issue from +# claude job's, so a handoff applies once. It takes the issue from # the event or the issue-number input, never from a job output, and # rebuilds the allowlist, Issue Types and work classes itself. It keeps # labels that are in the caller's allowlist AND exist in the repository @@ -139,9 +139,10 @@ name: intake-triage # legs' outputs in that run hold, so a rerun of it alone reapplies the same # triage, editing the lane's earlier comment. # -# `claude-intake-triage` triages on the API key; after a credit stop (or with -# no key) `claude-intake-triage-subscription` triages on the subscription -# token instead. `claude-intake-triage-apply` applies the triage of the job +# `claude-intake-triage` triages on the API key; after it hands off (a credit +# stop, or the key refused with API status 401 or 402) or with no key, +# `claude-intake-triage-subscription` triages on the subscription token +# instead. A 403 does not hand off. `claude-intake-triage-apply` applies the triage of the job # that triaged, and `claude-intake-triage-status` reads all three and goes red # when the triage or its write failed. Never make that check required. # `claude-intake-triage-skipped` runs only when the author gate skipped the @@ -713,9 +714,9 @@ jobs: # continue-on-error keeps an infrastructure failure, which run-claude-cli # reports by failing this step, from ending the job before the outcome - # and extract steps run; the status job carries the red. A credit stop - # (key only) skips the outcome and extract steps: the subscription job - # triages instead. The outcome step's step-timeout-minutes repeats + # and extract steps run; the status job carries the red. A handoff (key + # only: a credit stop, or class auth with API status 401 or 402) skips + # the outcome and extract steps: the subscription job triages instead. The outcome step's step-timeout-minutes repeats # timeout-minutes. The step's env holds no GitHub token, and the tools # are Read, Grep and Glob only: no Bash, so no gh and no commands. - name: Claude intake triage @@ -1239,9 +1240,9 @@ jobs: # continue-on-error keeps an infrastructure failure, which run-claude-cli # reports by failing this step, from ending the job before the outcome - # and extract steps run; the status job carries the red. A credit stop - # (key only) skips the outcome and extract steps: the subscription job - # triages instead. The outcome step's step-timeout-minutes repeats + # and extract steps run; the status job carries the red. A handoff (key + # only: a credit stop, or class auth with API status 401 or 402) skips + # the outcome and extract steps: the subscription job triages instead. The outcome step's step-timeout-minutes repeats # timeout-minutes. The step's env holds no GitHub token, and the tools # are Read, Grep and Glob only: no Bash, so no gh and no commands. - name: Claude intake triage @@ -1662,8 +1663,13 @@ jobs: else job=$KEY_RESULT present=$KEY_PRESENT failed=$KEY_FAILED class=$KEY_CLASS fi + # An unusable key stays visible even when the subscription job then + # triaged and the run is green. + if [ "$KEY_CLASS" = auth ]; then + echo "::warning title=claude-intake-triage key::class=auth: the API refused the key; the owner must replace the secret." + fi # A triage job with an empty secret did not triage: after a key credit - # stop that is a limit stop, after a rejected key it is that auth + # stop that is a limit stop, after an unusable key it is that auth # failure, otherwise both secrets were empty. if [ "$present" = false ]; then failed=true diff --git a/README.md b/README.md index 000619af..9d6a5a28 100644 --- a/README.md +++ b/README.md @@ -609,9 +609,11 @@ consumer to audit it. the action fails closed. A key leg hands off to the subscription, output `handoff` set to `true`, when it ends in a credit stop (report-lane-outcome's opt-in `credit-stop` class: the role's credits are used up) or with its key - rejected (`auth`: the key was disabled or deleted). `lane-class` keeps - `credit-stop` or `auth`, so the job summary and the log name the reason and - a dead key stays visible. Any other failure hands off nothing. Rotating a + refused by the API with numeric status 401 (disabled or deleted) or 402 + (billing), class `auth`. A 403 (permission) is `auth` too but hands off + nothing: it fails the run. `lane-class` keeps `credit-stop` or `auth`, so + the job summary and the log name the reason and a dead key stays visible. + Any other failure hands off nothing. Rotating a key stays the owner's manual step. A caller that falls back to the subscription does so in a second job (the two-job pattern below); a caller that does not reports `credit-stop` as `rate-limit`. The leg's CLI From b7f27f9926be759238cef37b553f4a3b04427161 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Tue, 20 Oct 2026 23:25:48 -0400 Subject: [PATCH 5/6] fix(run-claude-cli): hand off on auth status 403 too A key leg in class `auth` now hands off on numeric api_error_status 401, 402 or 403. The decision still reads only the numeric status, so errors[] text with no status never hands off. lane-class stays `auth` and the intake status job still warns the owner to replace the secret. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NY1V8t81GkG6jWNPVFjaca --- .github/actions/run-claude-cli/action.yml | 10 ++++----- .github/actions/run-claude-cli/lane.cjs | 10 ++++----- .github/actions/run-claude-cli/lane.test.cjs | 22 +++++++------------- .github/scripts/intake-triage-legs.test.cjs | 3 ++- .github/workflows/intake-triage.yml | 17 ++++++++------- README.md | 6 +++--- 6 files changed, 30 insertions(+), 38 deletions(-) diff --git a/.github/actions/run-claude-cli/action.yml b/.github/actions/run-claude-cli/action.yml index 6d46af24..4bc904d9 100644 --- a/.github/actions/run-claude-cli/action.yml +++ b/.github/actions/run-claude-cli/action.yml @@ -4,8 +4,8 @@ description: >- Linux runner, on exactly one credential: set `api-key` or `subscription-token`, never both (the action fails closed otherwise). A key leg that ends in a credit stop (classify.cjs isCreditStop, lane-class - `credit-stop`) or a key the API refused with status 401 or 402 (lane-class - `auth`) sets handoff `true`; + `credit-stop`) or a key the API refused with status 401, 402 or 403 + (lane-class `auth`) sets handoff `true`; a caller that falls back to the subscription runs it as a second job on a fixed GitHub-hosted runner, gated on that exact value (see the README's two-job pattern), never in this job. @@ -164,10 +164,8 @@ outputs: handoff: description: >- `true` when a key leg ended in `credit-stop`, or in `auth` with the - numeric API status 401 or 402, so the caller may run the subscription - leg in a separate job; `false` otherwise, a 403 included, which fails - the run instead; - empty when the step failed before the leg ran. lane-class keeps the + numeric API status 401, 402 or 403, so the caller may run the + subscription leg in a separate job; `false` otherwise; empty when the step failed before the leg ran. lane-class keeps the reason. Set after the step files are restored, so the leg cannot set it. value: ${{ steps.run.outputs.handoff }} lane-resets: diff --git a/.github/actions/run-claude-cli/lane.cjs b/.github/actions/run-claude-cli/lane.cjs index e774bef9..4f3c85ea 100644 --- a/.github/actions/run-claude-cli/lane.cjs +++ b/.github/actions/run-claude-cli/lane.cjs @@ -16,8 +16,8 @@ // - One leg per invocation: readConfig fails closed unless exactly one of // the two credentials is set. A caller that falls back to the // subscription after a key leg hands off (a credit stop, or class auth -// with api_error_status 401 or 402, NEXT_STEPS) runs a second job, on a fresh runner, gated on this -// one's handoff output being `true`. +// with api_error_status 401, 402 or 403, NEXT_STEPS) runs a second job, +// on a fresh runner, gated on this one's handoff output being `true`. // - legEnv copies the step environment and removes every credential and // file-command VARIABLE, then sets the leg's one credential. That is a // denylist, not a sandbox: code the leg runs (a Bash tool call, a hook) @@ -142,11 +142,11 @@ const NEXT_STEPS = { handoff: true, note: "credits used up: the subscription job runs; the owner rotates a key by hand when needed", }, - // 401 (key disabled or deleted) and 402 (billing) hand off; 403 - // (permission_error) fails the run. + // 401 (key disabled or deleted), 402 (billing) and 403 (permission) hand + // off; an auth class with no numeric status does not. auth: { handoff: true, - statuses: [401, 402], + statuses: [401, 402, 403], note: "credential unusable (rejected, unpaid or not permitted): the owner replaces the secret by hand", }, "rate-limit": { handoff: false, note: "limit stop: rerun after the reset" }, diff --git a/.github/actions/run-claude-cli/lane.test.cjs b/.github/actions/run-claude-cli/lane.test.cjs index dd40d4ad..3dc93f8e 100644 --- a/.github/actions/run-claude-cli/lane.test.cjs +++ b/.github/actions/run-claude-cli/lane.test.cjs @@ -367,32 +367,24 @@ function authLeg({ status, errors }) { ]; } -test("a key refused with 401 or 402 hands off; a 403 keeps class auth and fails the run", () => { - for (const [status, handoff] of [ - [401, "true"], - [402, "true"], - [403, "false"], - ]) { +test("a key refused with 401, 402 or 403 hands off and keeps class auth", () => { + for (const status of [401, 402, 403]) { const { outputs, records } = runCase({ key: authLeg({ status }) }); assert.equal(outputs["lane-class"], "auth", String(status)); - assert.equal(outputs.handoff, handoff, String(status)); - assert.equal( - records[0].next, - handoff === "true" ? "subscription" : null, - String(status), - ); + assert.equal(outputs.handoff, "true", String(status)); + assert.equal(records[0].next, "subscription", String(status)); } }); -test("a 403 whose errors[] text names another type does not hand off", () => { +test("a 403 whose errors[] text names another type still hands off by its status", () => { const { outputs } = runCase({ key: authLeg({ status: 403, - errors: ['{"type":"error","error":{"type":"authentication_error"}}'], + errors: ['{"type":"error","error":{"type":"rate_limit_error"}}'], }), }); assert.equal(outputs["lane-class"], "auth"); - assert.equal(outputs.handoff, "false"); + assert.equal(outputs.handoff, "true"); }); test("permission_error in errors[] text alone, with no numeric status, does not hand off", () => { diff --git a/.github/scripts/intake-triage-legs.test.cjs b/.github/scripts/intake-triage-legs.test.cjs index 9f62a42c..3523a7ce 100644 --- a/.github/scripts/intake-triage-legs.test.cjs +++ b/.github/scripts/intake-triage-legs.test.cjs @@ -335,7 +335,8 @@ test("an unusable key warns the owner to replace the secret, even when the subsc }); assert.equal(fellBack.code, 0); assert.match(fellBack.stdout, warning); - // A 403 does not hand off: the key job alone reports, red, and still warns. + // An auth class with no numeric status does not hand off: the key job + // alone reports, red, and still warns. const refused = report({ KEY_RESULT: "success", KEY_FAILED: "true", diff --git a/.github/workflows/intake-triage.yml b/.github/workflows/intake-triage.yml index 9e6e4341..33ce1f43 100644 --- a/.github/workflows/intake-triage.yml +++ b/.github/workflows/intake-triage.yml @@ -45,9 +45,10 @@ name: intake-triage # - The API key runs in the claude job. The subscription token runs only in # the claude-subscription job, and only when the claude job's handoff # output is exactly `true` (the key's credits are used up, lane-class -# `credit-stop`, or the API refused the key with status 401 or 402, -# lane-class `auth`; a 403 fails the run instead) or its key was empty. That job runs on a fresh ubuntu-24.04 GitHub-hosted runner, -# never the caller's runner input, repeats every hardening step, and +# `credit-stop`, or the API refused the key with status 401, 402 or +# 403, lane-class `auth`) or its key was empty. That job runs on a +# fresh ubuntu-24.04 GitHub-hosted runner, never the caller's runner +# input, repeats every hardening step, and # takes nothing from the claude job but those outputs and the # credential-present flag: no artifact, no cache. handoff and lane-class # are set by run-claude-cli after it restores the step files, so the @@ -140,9 +141,9 @@ name: intake-triage # triage, editing the lane's earlier comment. # # `claude-intake-triage` triages on the API key; after it hands off (a credit -# stop, or the key refused with API status 401 or 402) or with no key, -# `claude-intake-triage-subscription` triages on the subscription token -# instead. A 403 does not hand off. `claude-intake-triage-apply` applies the triage of the job +# stop, or the key refused with API status 401, 402 or 403) or with no +# key, `claude-intake-triage-subscription` triages on the subscription token +# instead. `claude-intake-triage-apply` applies the triage of the job # that triaged, and `claude-intake-triage-status` reads all three and goes red # when the triage or its write failed. Never make that check required. # `claude-intake-triage-skipped` runs only when the author gate skipped the @@ -715,7 +716,7 @@ jobs: # continue-on-error keeps an infrastructure failure, which run-claude-cli # reports by failing this step, from ending the job before the outcome # and extract steps run; the status job carries the red. A handoff (key - # only: a credit stop, or class auth with API status 401 or 402) skips + # only: a credit stop, or class auth with API status 401-403) skips # the outcome and extract steps: the subscription job triages instead. The outcome step's step-timeout-minutes repeats # timeout-minutes. The step's env holds no GitHub token, and the tools # are Read, Grep and Glob only: no Bash, so no gh and no commands. @@ -1241,7 +1242,7 @@ jobs: # continue-on-error keeps an infrastructure failure, which run-claude-cli # reports by failing this step, from ending the job before the outcome # and extract steps run; the status job carries the red. A handoff (key - # only: a credit stop, or class auth with API status 401 or 402) skips + # only: a credit stop, or class auth with API status 401-403) skips # the outcome and extract steps: the subscription job triages instead. The outcome step's step-timeout-minutes repeats # timeout-minutes. The step's env holds no GitHub token, and the tools # are Read, Grep and Glob only: no Bash, so no gh and no commands. diff --git a/README.md b/README.md index 9d6a5a28..243490a5 100644 --- a/README.md +++ b/README.md @@ -609,9 +609,9 @@ consumer to audit it. the action fails closed. A key leg hands off to the subscription, output `handoff` set to `true`, when it ends in a credit stop (report-lane-outcome's opt-in `credit-stop` class: the role's credits are used up) or with its key - refused by the API with numeric status 401 (disabled or deleted) or 402 - (billing), class `auth`. A 403 (permission) is `auth` too but hands off - nothing: it fails the run. `lane-class` keeps `credit-stop` or `auth`, so + refused by the API with numeric status 401 (disabled or deleted), 402 + (billing) or 403 (permission), class `auth`; an error-type string with no + numeric status hands off nothing. `lane-class` keeps `credit-stop` or `auth`, so the job summary and the log name the reason and a dead key stays visible. Any other failure hands off nothing. Rotating a key stays the owner's manual step. A caller that falls back to From 7946d5956f0124bdb632f222d8277fb32a9fb2e2 Mon Sep 17 00:00:00 2001 From: Kyle Sexton <153232337+kyle-sexton@users.noreply.github.com> Date: Tue, 20 Oct 2026 23:36:15 -0400 Subject: [PATCH 6/6] docs(run-claude-cli): state the auth handoff statuses and the 403 reason - report-lane-outcome's `auth` fallback reason (and the FALLBACK_REASONS comment) now name the statuses: 401 disabled or deleted, 402 billing, 403 permission. - run-claude-cli's `handoff` output and the README say why a 403 hands off: lane role keys are whole-account Console keys with no per-key scope, so a 403 means the key or its workspace is misconfigured; the run hands off so the lane keeps running, and the status job warns on every such run until the owner replaces the key. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01NY1V8t81GkG6jWNPVFjaca --- .github/actions/report-lane-outcome/action.yml | 5 +++-- .github/actions/report-lane-outcome/classify.cjs | 2 +- .github/actions/run-claude-cli/action.yml | 9 +++++++-- README.md | 8 ++++++-- 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/actions/report-lane-outcome/action.yml b/.github/actions/report-lane-outcome/action.yml index e0c31b73..330f14ff 100644 --- a/.github/actions/report-lane-outcome/action.yml +++ b/.github/actions/report-lane-outcome/action.yml @@ -82,8 +82,9 @@ inputs: fallback-reason: description: >- Why this run used a fallback credential: `credit-stop` (the key job - credit-stopped), `auth` (the key job's key was rejected, disabled or - deleted) or `no-key` (the key was empty). Printed as + credit-stopped), `auth` (the API refused the key job's key with status + 401, disabled or deleted; 402, billing; or 403, permission) or `no-key` + (the key was empty). Printed as `fallback=` right after `credential=`. Empty prints nothing; any other value fails the step before it reports. required: false diff --git a/.github/actions/report-lane-outcome/classify.cjs b/.github/actions/report-lane-outcome/classify.cjs index 659730c0..0565bf8b 100644 --- a/.github/actions/report-lane-outcome/classify.cjs +++ b/.github/actions/report-lane-outcome/classify.cjs @@ -262,7 +262,7 @@ const MODEL_PATTERN = /^[\w.:@[\]-]{1,100}$/u; const COUNT_PATTERN = /^\d{1,6}$/u; const WINDOW_PATTERN = /^[a-z0-9_]{1,40}$/u; // Why a subscription job ran in the two-job pattern: the key job's credit -// stop, its key rejected (disabled or deleted), or no key at all. +// stop, its key refused with API status 401, 402 or 403, or no key at all. const FALLBACK_REASONS = ["credit-stop", "auth", "no-key"]; // SDK `resetsAt` is epoch time; a value past 1e12 can only be milliseconds. diff --git a/.github/actions/run-claude-cli/action.yml b/.github/actions/run-claude-cli/action.yml index 4bc904d9..653297ad 100644 --- a/.github/actions/run-claude-cli/action.yml +++ b/.github/actions/run-claude-cli/action.yml @@ -165,8 +165,13 @@ outputs: description: >- `true` when a key leg ended in `credit-stop`, or in `auth` with the numeric API status 401, 402 or 403, so the caller may run the - subscription leg in a separate job; `false` otherwise; empty when the step failed before the leg ran. lane-class keeps the - reason. Set after the step files are restored, so the leg cannot set it. + subscription leg in a separate job; `false` otherwise; empty when the + step failed before the leg ran. A 403 hands off too: lane role keys + are whole-account Console keys with no per-key scope, so a 403 means + the key or its workspace is misconfigured; the run hands off so the + lane keeps running, and the caller's status job warns on every such + run until the owner replaces the key. lane-class keeps the reason. + Set after the step files are restored, so the leg cannot set it. value: ${{ steps.run.outputs.handoff }} lane-resets: description: ISO 8601 time the blocking limit lifts, when the CLI's structured output gives it; else empty. diff --git a/README.md b/README.md index 243490a5..c6f703e3 100644 --- a/README.md +++ b/README.md @@ -611,8 +611,12 @@ consumer to audit it. opt-in `credit-stop` class: the role's credits are used up) or with its key refused by the API with numeric status 401 (disabled or deleted), 402 (billing) or 403 (permission), class `auth`; an error-type string with no - numeric status hands off nothing. `lane-class` keeps `credit-stop` or `auth`, so - the job summary and the log name the reason and a dead key stays visible. + numeric status hands off nothing. Lane role keys are whole-account Console + keys with no per-key scope, so a 403 means the key or its workspace is + misconfigured: the run hands off so the lane keeps running, and the status + job warns on every such run until the owner replaces the key. + `lane-class` keeps `credit-stop` or `auth`, so the job summary and the log + name the reason and a dead key stays visible. Any other failure hands off nothing. Rotating a key stays the owner's manual step. A caller that falls back to the subscription does so in a second job (the two-job pattern below);