Repository navigation
feat(sandbox): per-sandbox cpu and memory limits - #213
Merged
Merged
Conversation
SandboxConfig gains optional cpus/memoryMiB with shared range validation; the vz provider prefers them over its provider-wide defaults, and the add dialog offers the fields on macOS only — WSL limits are VM-global (.wslconfig) and bubblewrap has no cgroup plumbing here, so offering them elsewhere would be a lie. Memory is entered in GB and stored as MiB. The main process re-validates on the IPC boundary, and a hand-edited store value that fails validation falls back to the provider defaults rather than dropping the sandbox. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
Phase 4c, item 3 — the last of the 4c work that can be built and verified from here.
What
SandboxConfiggains optionalcpus/memoryMiB, plussandboxResourcesValidand the sharedSANDBOX_CPUS_RANGE(1–32) /SANDBOX_MEMORY_MIB_RANGE(1–64 GiB). Ceilings keep an unbootable VM (0 CPUs, 64 MiB) or an oversubscribed host out of the persisted config.config.cpus ?? options.cpus ?? 4)..wslconfig) and bubblewrap has no cgroup plumbing here, so offering the fields on those platforms would promise something the backend can't deliver. Memory is entered in GB (a MiB box invites 4-digit typing) and stored as MiB, which is what the VM config wants.sandbox-addnow takes a thirdresourcesargument), and a hand-edited store entry that fails validation falls back to provider defaults rather than dropping the sandbox from the list.The app-side validator is a small mirror in
app/src/sandbox/resources.ts— the app package must not import the node-flavored@codev/sandbox, the same rule that givessandbox/types.tsits own copy of the wire types.Tests
sandboxResourcesValidmatrix (empty, valid, both ceilings, zero, over-max, fractional, under-min memory, NaN)vm.jsonstill 4 CPUs / 4096 MiB; a new test asserts per-sandbox 8 / 16384 overrides provider defaults of 2 / 2048CHANGELOG entry added; the renderer-slice DIVERGENCES row notes the new i18n keys.
4c status after this
🤖 Generated with Claude Code