Skip to content

fix(nodes): bound node Claude clearEnv to the node protocol allowlist - #20

Merged
tomorrowflow merged 1 commit into
mainfrom
fix/node-claude-clear-env
Oct 9, 2026
Merged

tomorrowflow merged 1 commit into
mainfrom
fix/node-claude-clear-env

Conversation

@tomorrowflow

Copy link
Copy Markdown
Owner

Problem

Every node-placed Claude run fails on a Gateway with an Anthropic auth profile:

cli terminal failure: provider=claude-cli ... error=Error: INVALID_REQUEST: clearEnv must be a bounded array

With a selected Claude credential, executePreparedCliRun forwards the backend's whole clearEnv (CLAUDE_CLI_CLEAR_ENV, 41 keys) to the node. The node's decoder (src/node-host/invoke-agent-cli-claude-params.ts) accepts at most its own 40-key clear allowlist, and two Gateway keys are not on it at all: MAX_THINKING_TOKENS and CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING.

This surfaced on the first live dev-loop ticket (Workboard node-claude target → mac-factory). The M1 test kit had no Anthropic profile, so the slice 1/2 proofs never took the selected-auth path.

Solution

  • Export the node clear allowlist as the protocol contract NODE_CLAUDE_CLEAR_ENV_KEYS.
  • Filter the Gateway's nodeClearEnv against it in src/agents/cli-runner/execute.ts.

The fix is Gateway-side on purpose: deployed nodes (mac-factory runs 2026.10.2) keep their 40-key allowlist and work without an upgrade. Widening the node list instead would still be rejected by every deployed node. The two dropped keys are never forwarded in env to nodes (NODE_CLAUDE_FORWARD_ENV_KEYS has only the context-window keys), so nothing the Gateway sets is affected.

execute.ts → node-agent-cli-runtime.ts is the only path that sends clearEnv to a node; node-claude-skill-runtime.ts only checks command policy.

Evidence

  • New src/agents/cli-runner/execute.node-clear-env.test.ts: node placement with a selected credential and the node list plus MAX_THINKING_TOKENS, then the captured wire params go through the node's own decodeClaudeCliNodeRunParams.
    • Fails without the fix (expected [ … (40) ] to deeply equal [ … (39) ]), passes with it.
    • pnpm test src/agents/cli-runner/execute.node-clear-env.test.ts --maxWorkers=1: 1 test, ~33 s wall time (mostly the shared harness import; the test itself takes milliseconds).
  • src/agents/cli-runner.spawn.test.ts (38) and src/node-host/invoke-agent-cli-claude.test.ts (34) pass.
  • pnpm tsgo:core passes; oxlint is clean on the changed files.
  • Inherited reds, unchanged by this PR:
    • check:test-mock-exports (3 hits in untouched files)
    • tsgo:core:test (src/gateway/node-agent-cli-runtime.test.ts isWebchatConnect)
  • autoreview (Codex, P1): scoped-clean.
  • Live proof follows after deploy: re-run Workboard card 0e028045 (voice-diary DOC-7) on mac-factory.

🤖 Generated with Claude Code

With a selected Claude auth profile the Gateway forwarded the backend's whole
clearEnv list (41 keys, including MAX_THINKING_TOKENS and
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING) to paired nodes. Nodes accept only
their 40-key clear allowlist, so every node-placed Claude run on a Gateway
with an Anthropic auth profile failed with "clearEnv must be a bounded array".

Export the node allowlist as the protocol contract and filter what the
Gateway sends against it. Deployed nodes keep working without an upgrade.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@tomorrowflow
tomorrowflow merged commit 620944c into main Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant