fix(agent-isolation): let prek and uv run inside the sandbox - #1359
Merged
Merged
Conversation
Claude Code does not apply the home-directory allowRead / allowWrite entries from the committed .claude/settings.json, the same behaviour behind apache#197. Inside the sandbox ~/.local/bin, ~/.local/share/uv, ~/.cache and ~/.gitconfig stay denied, so `prek` and `uv` are not found and agents fall back to a sandbox bypass to run the hooks. sandbox-add-project-root.sh now also writes those dev-tool paths, as absolute paths, into each worktree's gitignored .claude/settings.local.json, where the harness does apply them: ~/.gitconfig, ~/.config/git, ~/.cache, ~/.local/share/uv and ~/.local/bin readable, the cache and uv dirs writable. It never adds the credential paths the committed list also names (~/.config/gh, ~/.config/apache-magpie, ~/.gnupg). --no-tool-paths keeps the old project-root-only behaviour. - sandbox-troubleshooting.md gains an entry for the failure, and sandbox-error-hint.sh points "command not found: prek|uv|uvx" at it. - setup-isolated-setup-verify check 8 reports the missing tool paths as a warning; install step P.2 and the agent-isolation spec describe the new paths. - The verify step-1 fixtures that model a helper-written file carry the tool paths, and a new case covers them being absent. Generated-by: Claude Opus 5
potiuk
force-pushed
the
fix/sandbox-tool-paths-local-settings
branch
from
September 23, 2026 14:52
a66a1e8 to
150dfed
Compare
potiuk
added a commit
to potiuk/magpie
that referenced
this pull request
Sep 23, 2026
The doctor skill's probes are meant to move in lock-step with the sandbox troubleshooting catalogue, but apache#1359 added the "prek or uv not found inside the sandbox" entry without a matching probe. Probe 7 (probe-7-dev-tools.sh) checks that prek and uv run inside the sandbox and can write ~/.cache. Inside the sandbox a read-denied ~/.local/bin looks exactly like an absent one, so when neither tool is found it reads the worktree's settings.local.json to tell a missing grant (warn) from a tool that is not installed (skip). - The error-hint hook and the setup doc now count seven probes, and the doc's hint table gains the prek / uv signature from apache#1359. - The troubleshooting entry no longer says the new paths apply only from the next session: the harness picks up settings.local.json changes on the next sandboxed command. - The interpret-probes eval grows a dev_tools_status field and a case-16 fixture for the missing grant. Generated-by: Claude Code (Opus 5)
15 tasks
potiuk
added a commit
that referenced
this pull request
Sep 23, 2026
The doctor skill's probes are meant to move in lock-step with the sandbox troubleshooting catalogue, but #1359 added the "prek or uv not found inside the sandbox" entry without a matching probe. Probe 7 (probe-7-dev-tools.sh) checks that prek and uv run inside the sandbox and can write ~/.cache. Inside the sandbox a read-denied ~/.local/bin looks exactly like an absent one, so when neither tool is found it reads the worktree's settings.local.json to tell a missing grant (warn) from a tool that is not installed (skip). - The error-hint hook and the setup doc now count seven probes, and the doc's hint table gains the prek / uv signature from #1359. - The troubleshooting entry no longer says the new paths apply only from the next session: the harness picks up settings.local.json changes on the next sandboxed command. - The interpret-probes eval grows a dev_tools_status field and a case-16 fixture for the missing grant. Generated-by: Claude Code (Opus 5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sandbox.filesystem.allowRead/allowWriteentries from the committed.claude/settings.json. This is the same behaviour as setup-isolated-setup-install: "." in allowRead does not cover CWD; need defensive abs-path resolution at install time #197, where the committed"."entry was dropped. Inside the sandbox~/.local/bin,~/.local/share/uv,~/.cacheand~/.gitconfigstay denied.prekanduvare then "command not found", and agents fall back to a sandbox bypass to run the hooks, which runs working-tree hook code with full access to$HOME. The Claude Code docs sayallowReadmerges across every scope, so this is harness behaviour rather than a documented contract.sandbox-add-project-root.shnow also writes those dev-tool paths, as absolute paths, into each worktree's gitignored.claude/settings.local.json, where the harness does apply them.~/.gitconfig,~/.config/git,~/.cache,~/.local/share/uv,~/.local/bin.~/.cache,~/.local/share/uv.~/.config/gh,~/.config/apache-magpie(the Gmail OAuth token) and~/.gnupg, which the same harness behaviour currently keeps out of sandboxed Bash.--no-tool-pathskeeps the old project-root-only behaviour.sandbox-troubleshooting.mdentry covers the failure.sandbox-error-hint.shmapscommand not found: prek|uv|uvxto that entry.setup-isolated-setup-verifycheck 8 reports missing tool paths as ⚠.agent-isolation-sandboxspec describe the new paths.Type of change
.claude/skills/<name>/) — eval fixtures updated belowtools/<system>/*.md)tools/*/withpyproject.toml)docs/,README.md,CONTRIBUTING.md)projects/_template/)prek, workflows, validators)Test plan
prek run --all-filespasses excepttools/container-gatewaypytest.tests/test_daemon.py::test_run_unlinks_pid_file_before_closing_the_lock_fdfails the same way onmain, on files this PR does not touch.tools/agent-isolation:uv run pytest, 262+ passed. There are 6 new helper tests (tool paths added, write paths exact, credential paths never added, idempotent, existing entries kept in place,--no-tool-paths) and 4 new hint tests (zsh / bash /uvxsignatures, look-alike commands stay silent).~/.local/bin,~/.cache,~/.local/share/uvand~/.gitconfigare denied in the sandbox, whilesettings.local.jsonand user-scope entries are applied.magpie-run-evals.sh(claude -p).setup-isolated-setup-install: 13/13.setup-isolated-setup-verify: 12/15. The 3 failures (step-1 case-7 on check 10a; step-2 case-3 and case-5) fail identically withmain'sSKILL.md, so they are not caused by this change.step-1-classify/case-8-tool-paths-missing(check 8 ⚠). The step-1 fixtures that model a helper-writtensettings.local.json(cases 1, 3, 4, 7) now carry the tool paths.RFC-AI-0004 compliance
prekwith the sandbox bypassed, and adds no credential path or network reach.settings.local.json, which the harness write-denies from inside the sandbox; the operator runs it from a terminal or approves the bypass.Linked issues
Refs #197
Notes for reviewers (optional)
.claude/settings.jsonstill lists the~/entries. They cost nothing where they are ignored, and keeping them means they take effect if the harness starts applying project-scope allows as documented.sandbox-troubleshooting.mdasks each entry to get a doctor probe as well as a hint-hook branch. This PR adds the hint branch and the verify check; aprek --version-in-sandbox probe insetup-isolated-setup-doctoris left for a follow-up.tools/spec-loop/.last-syncis not bumped. Only theagent-isolation-sandboxspec is updated, by hand, for this change.Generative AI disclosure: this change was prepared with Claude Code (Claude Opus 5) and reviewed by the author before submission.
🤖 Generated with Claude Code