Skip to content

fix(runner): Claude sandbox failure detection, settings.json env fallback, and FORCE_COLOR test fix - #313

Merged
mergify[bot] merged 6 commits into
mainfrom
fix/297-claude-runner-fixes
Dec 1, 2026
Merged

mergify[bot] merged 6 commits into
mainfrom
fix/297-claude-runner-fixes

Conversation

@ericlitman

Copy link
Copy Markdown
Owner

Closes #297
Closes #304
Closes #307

Summary

 runner/
 ├── registry/contract.ts
 │   + environmentDefaults?(source): host-derived fallback defaults (keeps environment() pure)
 ├── run.ts
 │   childEnvironment(): { ...environmentDefaults(source), ...filteredSource, ...policySet }
 ├── providers/claude.ts
 │   + launch.argv: "--verbose" right after "--output-format", "json"
 │   + parse(): sandboxStartFailure(events) -> child-failed when every Bash call fails with apply-seccomp:/bwrap:
 │   + connectionDefaults(source): reads ANTHROPIC_BASE_URL + ANTHROPIC_AUTH_TOKEN as a pair from <config-home>/settings.json env
 └── run.test.ts
     + Codex sandbox diagnostic fakes use process.stderr.write + beforeEach sets FORCE_COLOR=1
     + Top-level beforeEach isolates CLAUDE_CONFIG_DIR to non-existent scratch path
 references/model-catalog.md (regenerated)

Design note on #307: ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN are read from settings.json as a pair only when the process environment sets neither key. Taking them as a pair prevents accidentally sending a settings.json auth token to a shell-supplied base URL (or vice versa).

Evidence

Merge Danger

Door: two-way. Reverting the three commits restores the prior Claude adapter and test fixtures with no sheet or schema migration.

Blast Radius: narrow. Only the external Claude runner adapter (claude.ts), ProviderAdapter.environmentDefaults?, childEnvironment merge order, model-catalog.md notes, and runner tests change. Native Claude agents and all other providers are unchanged.

Acceptance criteria

Gate results

Run on head fe9e3ef01b16e3bd0619aab8d4cfa2ad2a7ffed9:

  • bun run test: exit 0 (526 pass, 0 fail)
  • FORCE_COLOR=1 bun run test: exit 0 (526 pass, 0 fail)
  • bun run typecheck: exit 0 (tsc --noEmit)
  • bun run static: exit 0 (219 pass, 0 fail)
  • claude plugin validate plugins/pstack: exit 0

Planned live gate (2 sessions, run on pro14):

  • --feature codex:runner --runner-route claude:opus@low

Not verified

ericlitman and others added 3 commits December 1, 2026 08:32
…CE_COLOR (#304)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…iled (#297)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ner children (#307)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mergify

mergify Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 All 2 merge protections satisfied — ready to merge.

Show 2 satisfied protections

🟢 Queue ready pull requests

Automatically queue non-draft pull requests targeting main after verify and live-gate pass on the head and every review thread is resolved.

  • #review-threads-unresolved = 0
  • -draft
  • check-success=live-gate
  • check-success=verify

🟢 🚦 Auto-queue

When all merge protections are satisfied and these conditions match, this pull request will be queued automatically.

  • -files~=^\.github/
  • base = main

@ericlitman

Copy link
Copy Markdown
Owner Author

Live evidence: Open Pstack

  • Candidate SHA: fe9e3ef01b16e3bd0619aab8d4cfa2ad2a7ffed9
  • Base SHA: faf512125b11f4a30f55c4eaf8a709a890668406
  • Result: FAILED — verification did not complete; rerun required
  • Self-test: not requested
  • Planned sessions: 2 (limit 12)
  • Publisher revision: faf512125b11f4a30f55c4eaf8a709a890668406
  • Evidence-set SHA-256: af0ae98efaf5888d0b51d337333354bd199d916c129e0c0e91699689caca6556
  • Policy: every new head requires a fresh run; this verifier does not change PR state, queue, or merge.

@unfret-eal

unfret-eal Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

🛑 7 blocking findings

🔴 Critical · A settings token can be sent to a project-configured endpoint

🔴 High · Verbose Claude output persists secrets returned by tools

🔴 High · Claude launch exposes secret-bearing helper commands in process arguments

🔴 High · Settings fallback imports a gateway URL but drops its API key

🟡 Medium · Verbose transcripts can turn unrelated Claude failures into unavailable-model receipts

🟡 Medium · A relative Claude config home is resolved from the wrong working directory

🟡 Medium · A command's own bubblewrap error discards a valid Claude reply

Walkthrough

This PR fixes three issues in the external Claude runner. First, it adds `--verbose` so Claude emits its full event array, and the parser now reports a lane as `child-failed` (exit 70, no `out.md`) when every Bash call fails to start its sandbox with an `apply-seccomp:` or `bwrap:` line; previously such lanes were recorded as complete. Second, because `--setting-sources project` hides user settings, a new optional `hostConfig` adapter hook reads `&lt;CLAUDE_CONFIG_DIR or ~/.claude&gt;/settings.json` and supplies `ANTHROPIC_BASE_URL`/`ANTHROPIC_AUTH_TOKEN` as child-environment defaults when the shell sets no connection or auth keys. It also forwards `apiKeyHelper` through inline `--settings`, redacted in receipt argv. Third, it makes the Codex sandbox diagnostic tests independent of `FORCE_COLOR`. The diff goes further than the PR description, which presents the settings fallback as only two keys: the `apiKeyHelper` forwarding and `receiptArgv` redaction are additional behavior. Tests use fake CLIs; the author reports real seccomp/bwrap hosts and real gateways as unverified.

Area What changes Review notes
Claude sandbox failure detection Adds `--verbose` to the Claude argv and a `sandboxStartFailure` check that classifies runs as child-failed only when every Bash tool result is an error matching `apply-seccomp:`/`bwrap:`. Adds table tests in claude.test.ts and an end-to-end linked-worktree test in run.test.ts. A command's own bubblewrap error discards a valid Claude reply
Verbose Claude output persists secrets returned by tools
Verbose transcripts can turn unrelated Claude failures into unavailable-model receipts
Settings.json connection fallback Adds a `hostConfig` contract hook and `LaunchHostConfig`. `childEnvironment` now layers settings-derived defaults under inherited and policy-set variables. Claude reads its settings file synchronously and throws a sanitized error on invalid JSON. It forwards `apiKeyHelper` via `--settings` and redacts it in receipts. Adds tests for precedence, missing files, invalid JSON, and token absence from receipts and streams. A settings token can be sent to a project-configured endpoint
Settings fallback imports a gateway URL but drops its API key
Claude launch exposes secret-bearing helper commands in process arguments
A relative Claude config home is resolved from the wrong working directory
Test fixtures and docs Codex diagnostic fakes switch to `process.stderr.write`, and that group pins `FORCE_COLOR=1`. The run tests isolate `CLAUDE_CONFIG_DIR` to a scratch path. `model-catalog.md` gains notes describing the new behaviors.
Advisories (2)
  • 🔵 Low · A blocking settings file prevents the runner from honoring cancellation · plugins/pstack/skills/poteto-mode/scripts/runner/providers/claude.ts:172
    The new synchronous settings read blocks the event loop if `settings.json` is a FIFO with no writer. The launcher then cannot handle SIGTERM or reach its explicit deadline check to write a terminal receipt and clean up. This is limited to non-regular settings files; ordinary local JSON files do not present this failure. Also reported for this defect: - A blocking settings file prevents deadline and cancellation handling (plugins/pstack/skills/poteto-mode/scripts/runner/providers/claude.ts:172): If fallback is active and `settings.json` is a FIFO with no writer, `readFileSync()` blocks before the runner checks its deadline or processes cancellation. The run cannot write a terminal receipt or clean up normally. This is limited to a blocking non-regular settings path; ordinary JSON files do not trigger it. - A blocking settings file prevents timeout and cancellation (plugins/pstack/skills/poteto-mode/scripts/runner/providers/claude.ts:172): The new synchronous settings read blocks before the runner reaches its deadline and cancellation checks. If `settings.json` is a FIFO with no writer, the lane ignores the explicit deadline and cannot process SIGTERM or write a terminal receipt. A focused check required SIGKILL and left an empty receipt. This is limited to non-regular settings files; ordinary local JSON files do not trigger it.
    Not blocking because: Requires a blocking non-regular file such as a FIFO with no writer at Claude's settings.json path; regular local JSON settings files do not stall setup or cancellation.
  • 🔵 Low · Verbose progress can push the actual failure out of receipt evidence · plugins/pstack/skills/poteto-mode/scripts/runner/providers/claude.ts:241
    For a nonzero exit with no stderr diagnostic, the runner keeps only the first 4,000 characters of stdout as failure evidence. When a verbose turn emits a long tool result before a terminal API error, the receipt keeps the unrelated progress and drops the actual error. A fake turn with a long `Read` result and a terminal HTTP 401 produced the correct `child-failed` status but omitted the 401 from `error.evidence`; the full error was only in the sidecar.
    Not blocking because: The lane still reports child-failed and preserves the full output in the stdout sidecar; only the 4,000-character receipt evidence snippet truncates the trailing error.
Since the last review
  • Fixed: Claude settings fallback can send a shell API key to the wrong gateway. Why: Fixed at current head: hostConfig now checks AUTH_KEYS (including ANTHROPIC_API_KEY) in source and skips reading user settings when ANTHROPIC_API_KEY is set in the shell, covered by claude.test.ts.
  • Still open: Verbose Claude output persists secrets returned by tools
  • Still open: Verbose transcripts can turn unrelated Claude failures into unavailable-model receipts
  • Still open: A relative Claude config home is resolved from the wrong working directory
  • New: Claude launch exposes secret-bearing helper commands in process arguments
  • Still open: A command's own bubblewrap error discards a valid Claude reply
  • Fixed: One startup failure is enough to discard a reply when other Bash commands ran. Why: Fixed at current head: sandboxStartFailure now requires every Bash tool_result to have is_error === true and match SANDBOX_START_FAILURE, returning null if any Bash result does not match, covered by claude.test.ts.
  • New: Settings fallback imports a gateway URL but drops its API key
  • New: A settings token can be sent to a project-configured endpoint
Repair prompt

Read the Unfret check run for ericlitman/open-pstack#313 at head e87f1d243dc65f1a3334945b56445daec0eaba8d (run panel:e87f1d243dc65f1a3334945b56445daec0eaba8d:Y9LsAC6NRsz:JHvSmg2RXjo, check). Use the check's App id and GET /repos/ericlitman/open-pstack/check-runs/142705218057; its output.text contains the structured result. Compare it with the current code and head, verify that each listed mandatory finding still applies, repair only those that do, honor the repository constraints, and validate the changes. Leave advisories and accepted risks alone. A manually resolved thread is not a waiver.

Details
Lane / stage Model Effort Outcome Duration
broad-gpt-5.6-sol-xhigh / review openai/gpt-6.2-sol → gpt-6.2-sol · primary xhigh succeeded 4 min 29 s
focal-gpt-5.6-sol-xhigh copy / review openai/gpt-6.2-sol → gpt-6.2-sol · primary xhigh succeeded 5 min 51 s
focal-gpt-5.6-sol-xhigh copy 2 / review openai/gpt-6.2-sol → gpt-6.2-sol · primary xhigh succeeded 5 min 33 s
judge / judge gemini-4-neon-low → gemini-4-neon · primary low succeeded 1 min 41 s

Reviewed the whole pull request.
3 reviewers finished.
Commit e87f1d2.
Check run.
Run: GET /unfret/run/panel:e87f1d243dc65f1a3334945b56445daec0eaba8d:Y9LsAC6NRsz:JHvSmg2RXjo.

@unfret review · @unfret status · @unfret help

@unfret-eal unfret-eal Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 6 blocking findings
🔴 Critical · Claude settings fallback can send a shell API key to the wrong gateway
🔴 High · Verbose Claude output persists secrets returned by tools
🟡 Medium · Verbose transcripts can turn unrelated Claude failures into unavailable-model receipts
🟡 Medium · A relative Claude config home is resolved from the wrong working directory
🟡 Medium · One startup failure is enough to discard a reply when other Bash commands ran
🟡 Medium · A command's own bubblewrap error is mistaken for Claude sandbox startup failure
Check

…quire every Bash call to match sandbox failure
@ericlitman

Copy link
Copy Markdown
Owner Author

Live evidence: Open Pstack

  • Candidate SHA: 872807b6dc70bc327845aed76976e317a29d750a
  • Base SHA: faf512125b11f4a30f55c4eaf8a709a890668406
  • Result: PASSED — named features verified
  • Self-test: not requested
  • Planned sessions: 2 (limit 12)
  • Publisher revision: a362079f54319db5e0d475a87f7177746c0a1979
  • Evidence-set SHA-256: 68f9b9780f80d2455f0aa6fd5fd4bc7b5deff476e1930845d9fa47eb4467733b
  • Installation (codex): CLI codex-cli 0.172.0, plugin 1.21.0, candidate 872807b6dc70bc327845aed76976e317a29d750a, tree 55060babf28bd0e4df2acd99837f79404b7fb44718604c1c458a21106621f9d3.
  • Observation (codex / runner): surface codex exec --json with the run-owned candidate installation; action recipe runner: route-1, linked-worktree-writer; result passed 10 assertions; ids retained privately; 10 assertions machine-checked; transcript SHA-256 cd8d52b899c7440872744e18109913206e2338c1ccfdcde8033770db977e4364; artifact-set SHA-256 24882f56d497600250fded0af9463dc1b1c570f3a5a388a87a37d69ecaf02fe3.
  • Policy: every new head requires a fresh run; this verifier does not change PR state, queue, or merge.

@mergify

mergify Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

✅ Merged into main as 97ee870 at 14:18 UTC

4 min in the queue, 4 min of it CI.

So far

  • ✅ Entered the queue Tue 1 Dec, 14:14 · rule default · triggered by merge protections
  • ✅ Passed · in place
  • ✅ Merged 14:18 · 97ee870 · merge
8 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule Protect main
  • #review-threads-unresolved = 0 · required by Merge Protections rule Queue ready pull requests
  • -draft · required by Merge Protections rule Queue ready pull requests
  • check-success=live-gate · required by Merge Protections rule Queue ready pull requests
  • check-success=verify · required by Merge Protections rule Queue ready pull requests
  • any of · required by GitHub repository ruleset rule Protect main:
    • check-success = @github-actions/verify
    • check-neutral = @github-actions/verify
    • check-skipped = @github-actions/verify
  • any of · required by GitHub repository ruleset rule Protect main:
    • check-success = live-gate
    • check-neutral = live-gate
    • check-skipped = live-gate
  • any of · required by GitHub repository ruleset rule Review gate:
    • check-success = @mergify/Mergify Merge Protections
    • check-neutral = @mergify/Mergify Merge Protections
    • check-skipped = @mergify/Mergify Merge Protections

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Dec 1, 2026
@ericlitman

Copy link
Copy Markdown
Owner Author

Live evidence: Open Pstack

  • Candidate SHA: e87f1d243dc65f1a3334945b56445daec0eaba8d
  • Base SHA: a362079f54319db5e0d475a87f7177746c0a1979
  • Result: PASSED — named features verified
  • Self-test: not requested
  • Planned sessions: 2 (limit 12)
  • Publisher revision: a362079f54319db5e0d475a87f7177746c0a1979
  • Evidence-set SHA-256: 3c1b539268e17dd0cd562fa1fdb31dab2b2786d9e3f46861eb5ecb841a2bf0ff
  • Installation (codex): CLI codex-cli 0.172.0, plugin 1.21.0, candidate e87f1d243dc65f1a3334945b56445daec0eaba8d, tree 718f4a5a260e234f41a6ec41eddd7253b6ea1e4cfafac841c7f3bbacf0274f8c.
  • Observation (codex / runner): surface codex exec --json with the run-owned candidate installation; action recipe runner: route-1, linked-worktree-writer; result passed 10 assertions; ids retained privately; 10 assertions machine-checked; transcript SHA-256 270c842e80c1a52a770c5673b86a86a6198d70d339044842d86c661cc9953adf; artifact-set SHA-256 c29ed1354df9a9dbea3ae22549a087ae24105b0d9a5f64b3daa14b383a9486dc.
  • Policy: every new head requires a fresh run; this verifier does not change PR state, queue, or merge.

@mergify
mergify Bot merged commit 97ee870 into main Dec 1, 2026
5 of 6 checks passed
@mergify mergify Bot removed the queued label Dec 1, 2026

@unfret-eal unfret-eal Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛑 7 blocking findings
🔴 Critical · A settings token can be sent to a project-configured endpoint
🔴 High · Verbose Claude output persists secrets returned by tools
🔴 High · Claude launch exposes secret-bearing helper commands in process arguments
🔴 High · Settings fallback imports a gateway URL but drops its API key
🟡 Medium · Verbose transcripts can turn unrelated Claude failures into unavailable-model receipts
🟡 Medium · A relative Claude config home is resolved from the wrong working directory
🟡 Medium · A command's own bubblewrap error discards a valid Claude reply
Check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant