Skip to content

fix(sbx): allow the sandbox MCP tools on the CLI in the smoke's headless claude run - #564

Merged
pdettori merged 2 commits into
rossoctl:mainfrom
pdettori:fix/sbx-smoke-claude-allow
Oct 21, 2026
Merged

pdettori merged 2 commits into
rossoctl:mainfrom
pdettori:fix/sbx-smoke-claude-allow

Conversation

@pdettori

Copy link
Copy Markdown
Member

What

One flag in the SBX0 live smoke's headless Claude run: --allowedTools 'mcp__sandbox__*'.

Why

Step 5 of deploy/sbx/smoke.sh runs claude -p in a fresh sample repository created by mktemp -d. sbx up writes the sandbox MCP allow (mcp__sandbox__*) into the repo's .claude/settings.json — but headless Claude Code in a workspace whose trust dialog has never been accepted ignores workspace allow entries (workspace deny entries still apply). With no allow in effect, every mcp__sandbox__* call was blocked at the permission gate: the agent exited 0 explaining it couldn't act, and the smoke failed with no call in the flight recorder: claude did not use the sandbox MCP server.

Observed live in the SBX0 acceptance run (2026-10-20); claude's own stderr named it:

Ignoring 1 permissions.allow entry from .claude/settings.json: this workspace has not been trusted.

--allowedTools on the CLI is a session-level allow, not subject to the workspace trust gate, so the step now tests what it means to test — that the agent works through the sandbox MCP — rather than workspace trust state. Local tools stay denied by the workspace deny entries, which untrusted workspaces do honor.

Verified

Re-ran SBX_SMOKE_STEPS=5 against the deployed SBX0 (steps 1–4 and 6 unchanged by this edit): ok 5 - claude fixes the failing test through mocactl sbx mcp; the tree is unchanged until sbx pull --apply.

🤖 Generated with Claude Code

…ess claude run

Headless claude -p in a fresh workspace has not accepted the trust dialog,
and an untrusted workspace's .claude/settings.json allow entries are
ignored (its deny entries are not), so every mcp__sandbox__* call was
blocked at the permission gate: the agent exited 0 having done nothing and
the smoke failed with 'no call in the flight recorder'. Pass
--allowedTools mcp__sandbox__* on the CLI — session-level allows are not
subject to the trust gate — so the run depends on the agent choosing the
sandbox, not on workspace trust state.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori
pdettori requested a review from cwiklik as a code owner October 20, 2026 21:04

@ingpaolodettori-dev ingpaolodettori-dev 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.

Proposed verdict: REQUEST_CHANGES (1 must-fix, 1 suggestion)

One-flag fix to SBX0 live smoke step 5: claude -p now gets --allowedTools 'mcp__sandbox__*', because headless Claude Code in a never-trusted workspace ignores the project's permissions.allow (while still honouring its deny). The diagnosis is sound and the flag is narrow: it allows only the sandbox server's tools (the same pattern as CLAUDE_ALLOW in agent-config.ts), and the workspace deny list still blocks the local tools, so the step still tests "the agent works only through the sandbox". The PR body reports a live re-run of step 5.

Must-fix (CI): deploy-scripts is red at "Run deploy shell tests". deploy/sbx/tests/smoke.test.sh:342 asserts the exact claude command line with grep -qx "claude -p … --mcp-config .mcp.json --strict-mcp-config", and the appended --allowedTools mcp__sandbox__* makes that line no longer match. (I checked the match in bash; the mock claude's own *' --mcp-config .mcp.json --strict-mcp-config '* check at :207 still passes.) Update :342 (and its fail message) to include the flag. Details inline.

Suggestion (docs, outside the diff): the same trust-gate behaviour makes two docs inaccurate:

  • docs/sbx/user-guide.md:113-117 says "Headless use (scripts, CI) works the same way, without the prompts" and shows claude -p … --mcp-config .mcp.json --strict-mcp-config. In a fresh checkout / CI workspace that was never trusted, that command hits exactly the failure this PR fixes: every sandbox call is blocked and the agent exits 0 having done nothing. Add --allowedTools 'mcp__sandbox__*' there with a one-line reason (or tell users to trust the folder once).
  • deploy/sbx/RUNBOOK.md:460 describes step 5's command line without the new flag.

CI: everything else green; check still pending when drafted. Base is main 920fa88 (current). 1 commit, signed off. No .claude/ or .vscode/ changes.

Comment thread deploy/sbx/smoke.sh
# workspace's .claude/settings.json allow entries are ignored (its deny entries are
# not — local tools stay denied), so without this every mcp__sandbox__* call is
# blocked at the permission gate and the agent exits 0 having done nothing.
claude) exec claude -p "$PROMPT" --mcp-config .mcp.json --strict-mcp-config --allowedTools 'mcp__sandbox__*' ;;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

must-fix This breaks deploy/sbx/tests/smoke.test.sh:342, which grep -qxs the exact logged claude command line ending in --strict-mcp-config. With --allowedTools mcp__sandbox__* appended the exact match fails, which is why deploy-scripts is red. Update that assertion (and its fail message) to expect the flag. It's worth keeping the assertion exact so it pins that the allow is the sandbox server only.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 5bc65c3: the assertion now expects the full line ending in --allowedTools mcp__sandbox__* (the * escaped), and the fail message names the sandbox-only allow. Kept -qx exact so it still pins that the allow is the sandbox server only. deploy/sbx/tests/smoke.test.sh runs green locally end to end with the change.

The exact-match assertion pins the headless claude invocation; it broke
when the invocation gained --allowedTools mcp__sandbox__* (the untrusted
workspace fix). Keep it exact, so it still pins that the allow is the
sandbox server only.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
pdettori added a commit to pdettori/moca that referenced this pull request Oct 20, 2026
… OpenCode gap named, the legend matched to the rows

Per review on rossoctl#565: name the exact commits the live acceptance used
(image of main at dc1c25f, worker at f5bf784 = rossoctl#562, step-5 harness at
6aedba0 = rossoctl#564), point every Verified-live row at section 4, state that
the pending OpenCode half is an accepted known gap that does not block
the cohort, and rename the Live (Task 10) legend entry to Verified live
now that no row is pending.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
@pdettori pdettori added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 20, 2026

@ingpaolodettori-dev ingpaolodettori-dev 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.

Follow-up at 5bc65c3: the must-fix from our 6aedba0 review is closed. deploy/sbx/tests/smoke.test.sh:342 now grep -qxes the full logged claude line ending in --allowedTools mcp__sandbox__\*, and the match is still exact, so it still pins that only the sandbox server is allowed. deploy-scripts and the other 13 checks are green. The incremental diff is that one test line. smoke.sh is unchanged since 6aedba0.

Still open, non-blocking (from our previous review, no reply yet): the trust-gate behaviour this PR works around also makes two docs inaccurate:

  • docs/sbx/user-guide.md:113-117 says headless use "works the same way, without the prompts" and shows claude -p … --mcp-config .mcp.json --strict-mcp-config. In a fresh, never-trusted checkout or CI workspace, that command hits exactly the failure fixed here: every sandbox call is blocked and the agent exits 0 having done nothing. Suggest adding --allowedTools 'mcp__sandbox__*' with a one-line reason, here or in a follow-up.
  • deploy/sbx/RUNBOOK.md:460 describes step 5's command line without the new flag.

Author: pdettori (MEMBER — maintainer)
Areas reviewed: Shell (smoke harness + its test)
Agent/IDE config (.claude/.vscode): none
Commits: 2 commits, all signed-off: yes
CI status: passing (14/14)

@pdettori
pdettori merged commit 6e069a3 into rossoctl:main Oct 21, 2026
14 checks passed
@pdettori
pdettori deleted the fix/sbx-smoke-claude-allow branch October 21, 2026 00:46
pdettori added a commit that referenced this pull request Oct 21, 2026
The 1c gate's live rows, verified 2026-10-20 against the deployed
namespace (spec 10.6): the smoke's steps 1-4 and 6 green in the full run,
step 5's Claude Code half green in a re-run of that step after the smoke
harness fix (PR #564; the change touches only the claude invocation), and
the hand checks - the deployed sandbox profile from outside, a tokenless
Exec and a tokenless attach, and the guest's absent network - done at the
same run. Step 5's OpenCode half is still pending (not installed on the
acceptance machine). The run caught one real defect, fixed and merged in
PR #562 with a new regression test.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Paolo Dettori <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants