Repository navigation
fix(runner): Claude sandbox failure detection, settings.json env fallback, and FORCE_COLOR test fix - #313
Conversation
Merge Protections🟢 All 2 merge protections satisfied — ready to merge. Show 2 satisfied protections🟢 Queue ready pull requestsAutomatically queue non-draft pull requests targeting main after verify and live-gate pass on the head and every review thread is resolved.
🟢 🚦 Auto-queueWhen all merge protections are satisfied and these conditions match, this pull request will be queued automatically.
|
Live evidence: Open Pstack
|
🛑 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 WalkthroughThis PR fixes three issues in the external Claude runner. First, it adds
Advisories (2)
Since the last review
Repair promptRead the
Details
Reviewed the whole pull request. @unfret review · @unfret status · @unfret help |
There was a problem hiding this comment.
🛑 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
Live evidence: Open Pstack
|
✅ Merged into
|
Live evidence: Open Pstack
|
There was a problem hiding this comment.
🛑 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
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_URLandANTHROPIC_AUTH_TOKENare read fromsettings.jsonas a pair only when the process environment sets neither key. Taking them as a pair prevents accidentally sending asettings.jsonauth token to a shell-supplied base URL (or vice versa).Evidence
FORCE_COLOR=1 bun test plugins/pstack/skills/poteto-mode/scripts/runner/run.test.ts --test-name-pattern 'Codex parent sandbox diagnostics'failed 4 of 13 tests because Bun wrappedconsole.erroroutput in ANSI color codes.After (Make sandbox diagnostic fixtures independent of forced terminal color #304): 13 pass, 0 fail under
FORCE_COLOR=1;beforeEachpinsFORCE_COLOR=1so CI always exercises forced color.claude -p --output-format jsonemitted only the finalresultobject (is_error: false), so an external Claude lane whose Bash commands all failed at sandbox setup exited 0 withstatus: "complete".After (runner: Claude lane whose sandboxed commands all fail is still recorded as complete #297):
--verboseemits the JSON event array, andparse()classifies all-failed Bash calls matchingapply-seccomp:orbwrap:aschild-failed(exit 70), preserving metadata and bounded evidence and omittingout.md. Verified with 7 table tests inclaude.test.tsand an end-to-end linked-worktreerunLanetest inrun.test.ts.--setting-sources projectprevented Claude runner children from readingANTHROPIC_BASE_URLandANTHROPIC_AUTH_TOKENfrom<config-home>/settings.json.After (Pass Claude connection environment from user settings to runner children #307):
connectionDefaultsreads only those two keys when unset in the shell, keeps missing files and non-Claude adapters unchanged, throws a sanitized error on invalid JSON without leaking contents, and is covered by 9childEnvironmentandrunLanetests confirming the token is absent from receipts and sidecars.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?,childEnvironmentmerge order,model-catalog.mdnotes, and runner tests change. Native Claude agents and all other providers are unchanged.Acceptance criteria
FORCE_COLOR=1 bun run testand pinFORCE_COLOR=1in theCodex parent sandbox diagnosticstest group — verified locally and inrun.test.ts.--verboseevent array and classify all-failed Bash sandbox startup errors (apply-seccomp:,bwrap:) aschild-failed/70 without writingout.md— verified inclaude.test.tsandrun.test.ts. (The complementaryinterrogate/SKILL.mdcoverage wording is deferred to the upstream sync PR Sync Cursor pstack to 0.15.50 and adopt new role defaults capped at xhigh #310 so this PR stays focused on the runner.)ANTHROPIC_BASE_URLandANTHROPIC_AUTH_TOKENfrom<CLAUDE_CONFIG_DIR or ~/.claude>/settings.jsonenvwhen unset in process env, honorsCLAUDE_CONFIG_DIR, ignores missing settings, sanitizes invalid JSON errors, and keeps tokens out of receipts/sidecars — verified inrun.test.ts.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 0Planned live gate (2 sessions, run on
pro14):--feature codex:runner --runner-route claude:opus@lowNot verified
apply-seccomp:/bwrap:sandbox failure (runner: Claude lane whose sandboxed commands all fail is still recorded as complete #297): requires an Ubuntu/AppArmor host restricting unprivileged userns; verified via unit and end-to-end fake-CLI tests.settings.jsonenv(Pass Claude connection environment from user settings to runner children #307): our verification hosts use standard Claude logins; verified via fake-CLI end-to-end tests asserting token absence from receipts and sidecars.