Repository navigation
fix(run-claude-cli): stop on a 403 instead of handing off - #841
Conversation
A key leg refused with API status 401 or 402 still hands off to the role's subscription job. A 403 (permission_error) no longer does: the key reached the API but may not use the resource, a key or workspace setting the owner fixes, and a handoff would hide it. The run stops with class auth and handoff false. The launcher's error line, the job summary's new Error cell and the log record now carry api_error_status and, read from the CLI's own error text under closed patterns, the error type, error.details.error_code and request_id. report-lane-outcome's record prints error-type=, error-code= and request-id= on a failure. The docs no longer call lane role keys whole-account keys with no per-key scope; they point at the authentication, model-config and API errors pages instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
creditStopText ran before the numeric-status check, so a 403 whose text and SDK error matched a credit stop became class credit-stop and handed off to the subscription. It now returns null for any 403, so a 403 stays class auth, does not hand off, and is reported with its error facts. The public-log comments in classify.cjs now name the closed-pattern error facts read from the CLI's own text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Claude finished @kyle-sexton's task in 1m 40s —— View job Security review complete
No security issues found. What was reviewed: the full diff against
claude-lane-summary: lane=claude-security-review sha=d75fdf793e8e9928664e522651ba8c86bfd6a40d run=39544958991 |
gitleaks' generic-api-key rule read the API errors page's example request id after `request-id=` as a key in two test lines. The fixtures now use req_fake0000000000000000, and .gitleaksignore records the two findings in the earlier commit by fingerprint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d75fdf793e
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
claude-security-review has reviewed this pull request through d2bf938; a later push is reviewed from there. |
|
Claude finished @kyle-sexton's task in 4m 20s —— View job Code review complete
Scope: code-review lane only (security findings are out of scope here since Checks performed:
No correctness or maintainability findings. The 403-vs-401/402 split is implemented consistently everywhere it's referenced ( claude-lane-summary: lane=claude-review sha=46b6b10f55ab85852a1c1d07eb7dc0ec61955712 run=39545120033 |
|
Claude finished @kyle-sexton's task in 2m 53s —— View job Security review completeIncremental review scoped to changes since
Findings: none. What changed here is test-fixture-only: the real-looking example I checked this for the things that matter from a security standpoint:
No logic, auth, or injection surface in this slice — it's test data and a secret-scanner suppression list, and both check out. (GitHub Actions hardening, if any, is zizmor's lane and out of scope here.) claude-lane-summary: lane=claude-security-review sha=46b6b10f55ab85852a1c1d07eb7dc0ec61955712 run=39545120033 |
|
claude-review has reviewed this pull request through d2bf938; a later push is reviewed from there. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Claude finished @kyle-sexton's task in 3m 10s —— View job Code review complete
Scope: incremental review of the two files changed since What I checked:
Finding (1, Suggestion/maintainability): posted inline on I could not run claude-lane-summary: lane=claude-review sha=d254db291f254c43579c619bfac97431705fe4d8 run=39602962977 |
|
Claude finished @kyle-sexton's task in 1m 38s —— View job Security review completeIncremental review scoped to changes since
Findings: none. This slice is the fix for Codex's earlier P2 finding on this PR ("Extract error facts from error-variant result messages"): What I checked:
No logic, auth, or injection surface introduced by this slice. claude-lane-summary: lane=claude-security-review sha=d254db291f254c43579c619bfac97431705fe4d8 run=39602962977 |
…readers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Claude finished @kyle-sexton's task in 34s —— View job Security review completeIncremental review scoped to changes since
Findings: none. This slice is the pure refactor addressing the earlier code-review duplication finding: the three-source "CLI-only text" assembly ( What I checked:
No logic, auth, or injection surface touched by this slice. claude-lane-summary: lane=claude-security-review sha=d2bf938fc6860f7fdd1c4e521f7f07e8902a14b0 run=39603758962 |
|
Claude finished @kyle-sexton's task in 1m 2s —— View job Code review complete
Scope: incremental review of the one file changed since What changed: this commit extracts the shared No findings. Verified:
This closes out the maintainability suggestion from the prior review round cleanly. claude-lane-summary: lane=claude-review sha=d2bf938fc6860f7fdd1c4e521f7f07e8902a14b0 run=39603758962 |
…832) Refs: melodic-software/ci-workflows#840 Refs: melodic-software/ci-workflows#841 ## Summary Registers ci-workflows [v0.58.0](https://github.com/melodic-software/ci-workflows/releases/tag/v0.58.0) (`5e18f3d6cebd6fa5e66b0941ee0f7ed6ba288d6c`) contracts for `intake-triage.yml` and `intake-label-needs-triage.yml`, so [claude-code-plugins#8800](melodic-software/claude-code-plugins#8800) can repin both intake callers from v0.56.0 (`1bb8953`) to v0.58.0 and intake gets the 401/402 subscription handoff. **Owner review needed.** Unlike #829, `intake-triage` is not byte-identical to the SHA its copied entry reviewed. Its contract surface is unchanged, but its steps changed, so the gate cannot auto-approve it and the copy rests on the review below. The README rollout line says "sign-off pending"; replace it with "signed off by hand on <date>" when you sign off. ## Fix - `components/runner-policy/policy.json`: verbatim copies of the v0.56.0 (`1bb8953`) entries at `5e18f3d6`, for `intake-triage` and `intake-label-needs-triage`. No input, secret mapping, caller permission or routing is added or widened. - `components/runner-policy/README.md`: the v0.58.0 rollout line, sign-off pending. - `components/runner-policy/runner-policy.test.mjs`: a test that both v0.58.0 entries equal their v0.56.0 entries and are the only two keys at that SHA. ### Review basis Git blob SHAs (`git rev-parse <sha>:.github/workflows/<file>`): | File | `1bb8953` (v0.56.0) | `5e18f3d6` (v0.58.0) | |---|---|---| | `intake-label-needs-triage.yml` | `8d274a66` | `8d274a66` | | `intake-triage.yml` | `d79b7e9e` | `8ff8eac3` | `intake-label-needs-triage.yml` is byte-identical, so its copy has the same basis as #829. For `intake-triage.yml`, parsing both versions and comparing them structurally: `on.workflow_call` inputs (except the `cli-version` description), secrets and outputs are identical, as are the top-level permissions and every job's `permissions` and `runs-on`. The two jobs that hold `issues: write`, `apply` and `skipped`, are identical in full. The `claude`, `subscription` and `status` jobs changed (ci-workflows#840, #841). Please review these changes: 1. **CLI default goes from the pinned `2.1.304` to `latest`.** When the caller passes no `cli-version` and sets no `CLAUDE_LANE_CLI_VERSION` variable, run-claude-cli now installs whatever npm resolves as latest at run time, with a Claude credential in its environment ([L200](https://github.com/melodic-software/ci-workflows/blob/5e18f3d6cebd6fa5e66b0941ee0f7ed6ba288d6c/.github/workflows/intake-triage.yml#L200), [L527](https://github.com/melodic-software/ci-workflows/blob/5e18f3d6cebd6fa5e66b0941ee0f7ed6ba288d6c/.github/workflows/intake-triage.yml#L527), [L1053](https://github.com/melodic-software/ci-workflows/blob/5e18f3d6cebd6fa5e66b0941ee0f7ed6ba288d6c/.github/workflows/intake-triage.yml#L1053)). The contract does not model this. It is a supply-chain change. 2. **The subscription token is used in more cases.** The secret mapping is unchanged, but the `subscription` job, which holds `CLAUDE_CODE_OAUTH_TOKEN`, now runs when `handoff == 'true'`: after a credit stop as before, and also when the API refuses the key with status 401 or 402. A 403 stops the run ([L855](https://github.com/melodic-software/ci-workflows/blob/5e18f3d6cebd6fa5e66b0941ee0f7ed6ba288d6c/.github/workflows/intake-triage.yml#L855)). 3. A new `handoff` job output on `claude` and `subscription` ([L340](https://github.com/melodic-software/ci-workflows/blob/5e18f3d6cebd6fa5e66b0941ee0f7ed6ba288d6c/.github/workflows/intake-triage.yml#L340), [L866](https://github.com/melodic-software/ci-workflows/blob/5e18f3d6cebd6fa5e66b0941ee0f7ed6ba288d6c/.github/workflows/intake-triage.yml#L866)). These are job outputs, not `workflow_call` outputs. 4. `fallback-reason: auth` in the subscription job's lane record ([L1295](https://github.com/melodic-software/ci-workflows/blob/5e18f3d6cebd6fa5e66b0941ee0f7ed6ba288d6c/.github/workflows/intake-triage.yml#L1295)), and a status-job warning and `class=auth` when the key was refused ([L1671](https://github.com/melodic-software/ci-workflows/blob/5e18f3d6cebd6fa5e66b0941ee0f7ed6ba288d6c/.github/workflows/intake-triage.yml#L1671)). The contract has no allowlist entry for the `skipped-label` input. That was already true at v0.56.0, and this PR leaves it unchanged. ## Verification - `npm run test:runner-policy`: 324 pass, 0 fail, including `✔ both intake contracts at the v0.58.0 tag copy their v0.56.0 entries forward verbatim`. - `npm run lint:runner-policy`: `Runner policy passed.` - End to end, against a temp copy of the claude-code-plugins#8800 worktree's `.github` with both intake callers repinned to `5e18f3d6` (`--repository-visibility public`): - with #8800's vendored `runner-policy.mjs` and policy: two `runner-target-contract` failures, `intake-label-needs-triage` ("carries a reviewed allowedCallerPermissions grant; its steps cannot be proven unchanged by this surface diff, so auto-approval is declined") and `intake-triage` ("inputs changed since the previously reviewed ...intake-triage.yml@182aca3..."), and no others; - with the vendored `runner-policy.mjs` and `--policy` set to this branch's `policy.json`: `Runner policy passed.`; - with this branch's `runner-policy.mjs` and `policy.json`: `Runner policy passed.` - lefthook pre-commit (typos, editorconfig, markdownlint, gitleaks, biome): clean. ## Related - [claude-code-plugins#8800](melodic-software/claude-code-plugins#8800) can repin to v0.58.0 once this merges and syncs. - v0.58.0 also changes `pr-review.yml` and `pr-review-security.yml` (4 lines each). This PR adds no contracts for them. #8800 calls both at v0.55.0 (`3a2c748`), which already has contracts. - Precedent: #829 (v0.56.0 verbatim copies), #828. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Refs: #840
Summary
Owner decision (2026-10-21, ledger Q38-Q39): the run-claude-cli auth handoff added in #840 (released as v0.57.0) still hands off from a role's API key to its subscription token on numeric API status 401 or 402, but no longer on 403.
permission_error) stops the run with classauthandhandoffset tofalse. The key reached the API but may not use the resource. That is a key or workspace setting the owner fixes, and a handoff would hide it.error.details.error_code(when present) andrequest_idnow show in the step's::errorline, in a new Error cell in the job summary, in the JSONL log record, and in report-lane-outcome's lane record (error-type=,error-code=,request-id=).Fix
run-claude-cli/lane.cjs:NEXT_STEPS.auth.statusesis now[401, 402]. The class's note says that 401 or 402 hands off and a 403 stops.legRecordaddsapi_error_status,error_type,error_codeandrequest_id.summaryTablegains an Error column, andrun's final error line ends with the same tokens.report-lane-outcome/classify.cjs: newapiErrorFacts. It reads the CLI's own error text only, from a failed run with no tool call, every assistant message an SDK error and zero output tokens (the check moved out ofcreditStopTextintocliOnlyRun). Each value is kept only when it matches a closed pattern.readRunRecordcarries the facts, andrecordTokensprints them only on a failure.handoffoutput is still written after the step files are restored.fallback-reasonstill acceptsauth, and intake-triage still gates onhandoff == 'true'.action.yml, the README, and the intake-triage comments.Verification
node --test .github/actions/run-claude-cli/*.test.cjs: 68/68.node --test .github/actions/report-lane-outcome/*.test.cjs: 52/52.node --test .github/scripts/*.test.cjs: 548/548. These are the commands in pr-require-checks.yml.permission_error, the error_code and the request_id. A 403 whose errors[] text namesauthentication_errorstill does not hand off, and a 401 whose errors[] text namespermission_errorstill does. With model output present, no facts are read. Values outside the closed patterns are dropped.runon a 403 throws the exact error line and writes the summary cell and the log record. The report-lane-outcome record carries the three tokens and none of the error message text. The 403 fixture follows the error shape on the API errors page, and its error_code value is made up.statusesfails 3 tests..github/scripts/**, which this change does not touch.Related
🤖 Generated with Claude Code