Repository navigation
feat(sandbox): Seatbelt backend so sandbox=workspace works on macOS - #524
Merged
Merged
Conversation
macOS ran every shell command on the host: the workspace sandbox was bubblewrap only, so the default `sandbox = "workspace"` fell back with a warning there. `sandbox-exec` (part of macOS) now wraps `bash -c` with a profile that allows everything, then denies file writes outside the project, the temp directories, a few device nodes and the toolchain caches (the bubblewrap list plus ~/Library/Caches). `sandbox_network = false` adds `deny network*`. There is no private /tmp as on Linux; the docs say so. `prepare_with` takes the workspace backend instead of a bwrap bool, so tests reach every branch on any host. Windows still has no backend and follows `sandbox_fallback`; its message no longer says "Linux-only". Co-Authored-By: Claude Fable 5.2 <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ny backend On macOS the workspace backend is Seatbelt, so backend_available() is true without bwrap and the old assertion failed there. Co-Authored-By: Claude Fable 5.2 <[email protected]>
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.
What
sandbox = "workspace"(the default) only had a backend on Linux. On macOS every shell command ran on the host with a one-time warning. This adds a Seatbelt backend:/usr/bin/sandbox-exec -p <profile> bash -c <command>.The profile allows everything, then denies file writes outside:
/private/tmp,/private/var/folders),/dev/null,/dev/tty,/dev/ttys*,/dev/fd, …),~/.cargo,~/.npm, …) plus~/Library/Caches.sandbox_network = falseadds(deny network*).Differences from Linux, documented in the guide: there is no private
/tmp; the host temp directories stay writable.Windows still has no backend and follows
sandbox_fallback. Its message no longer says "Linux-only".Internals
prepare_with/describe_backend_withtake the workspaceBackendinstead of abwrap_availablebool, so tests reach every branch on any host.whycodes doctorprints aseatbelt:line on macOS.Verification
cargo test -p whycodes-sandbox: green on Windows and on Linux (WSL, withbwrap, live tests included).crates/sandbox/src: 0 missed lines in every file (LLVM_COV_FLAGS=-skip-expansions cargo llvm-cov -p whycodes-sandbox).cargo check -p whycodes-sandbox --target aarch64-apple-darwin --tests: compiles.Not verified yet — do not merge before this
The profile has not run on a real Mac. The Mac test host was unreachable and the hosted macOS CI jobs are off (
CI_MULTI_OS).crates/sandbox/tests/live_macos.rsholds the checks to run there:cargo test -p whycodes-sandbox --test live_macosIt checks that the project and
/tmpare writable,git initworks, a write to$HOMEfails, and TCP fails with the network off. A wrong profile would breakbashfor every macOS user on the default config, so this stays a draft until that run is green.🤖 Generated with Claude Code