Skip to content

fix(sandbox): give workspace mounts a 100 GB write quota - #151

Open
chriswritescode-dev wants to merge 1 commit into
mainfrom
fix/sandbox-workspace-mount-quota
Open

chriswritescode-dev wants to merge 1 commit into
mainfrom
fix/sandbox-workspace-mount-quota

Conversation

@chriswritescode-dev

@chriswritescode-dev chriswritescode-dev commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

User description

Summary

msb gives every bind mount a 4 GiB guest-write quota, and inside the sandbox df reports that budget as if it were the whole disk. A large Rust build in the shared project directory exhausts it, writes fail with ENOSPC, and agents report the host disk as full while it has hundreds of GiB free.

Forge now passes quota=100g on writable workspace mounts:

  • SANDBOX_WORKSPACE_QUOTA in src/sandbox/msb.ts, applied by buildMsbCreateArgs; read-only mounts keep the plain :ro suffix.
  • SANDBOX_CONTEXT_NOTE states that df on the project mount reports the quota rather than host free space, and that ENOSPC there means deleting build output.
  • docs/sandbox.md documents the quota and how to apply it to existing sandboxes.

Known limit

msb cannot change a mount on an existing sandbox, so sandboxes created by an earlier Forge build keep their 4 GiB quota until recreated with msb rm <sandbox>, which also removes their Docker and cache disks.

Verification

  • pnpm test --project node test/sandbox: 543 passed
  • pnpm typecheck, pnpm lint clean
  • pnpm docs:api regenerated docs/api/_media/sandbox.md

PR Type

Enhancement, Bug fix


Description

  • Add SANDBOX_WORKSPACE_QUOTA (100g) in src/sandbox/msb.ts

  • Apply quota=100g to every writable workspace mount

    • Keep plain :ro suffix on read-only mounts
    • Raise default 4 GiB msb budget that broke large builds
  • Explain quota, df, and ENOSPC in agent context note

  • Document quota behavior and recreation limit; update tests


Diagram Walkthrough

flowchart LR
  A["SANDBOX_WORKSPACE_QUOTA = 100g"] -- "used by" --> B["buildMsbCreateArgs"]
  B -- "writable mount" --> C["-v host:guest:quota=100g"]
  B -- "read-only mount" --> D["-v host:guest:ro"]
  C -- "explained in" --> E["SANDBOX_CONTEXT_NOTE"]
  C -- "documented in" --> F["docs/sandbox.md"]
  C -- "covered by" --> G["sandbox create-args tests"]
Loading

File Walkthrough

Relevant files
Enhancement
1 files
msb.ts
Add workspace quota constant and emit quota mount suffix 
+8/-1     
Documentation
3 files
context.ts
Explain workspace quota and ENOSPC in sandbox note             
+2/-1     
sandbox.md
Document 100 GB quota and existing sandbox limitation       
+2/-0     
sandbox.md
Regenerated copy of sandbox quota documentation                   
+2/-0     
Tests
3 files
context.test.ts
Test quota wording in sandbox context note                             
+7/-1     
manager-mount-canonicalization.test.ts
Expect quota suffix after host path canonicalization         
+2/-2     
msb-runtime.test.ts
Update create-args expectations for quota mount suffix     
+11/-10 

Comment thread src/sandbox/msb.ts
Comment on lines +258 to +263
args.push(
'-v',
ws.readOnly
? `${ws.hostDir}:${ws.containerDir}:ro`
: `${ws.hostDir}:${ws.containerDir}:quota=${SANDBOX_WORKSPACE_QUOTA}`,
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unverified msb syntax

Every writable mount now gets :quota=100g. If the installed msb does not support this option, or a supported msb version does not, msb create fails and all sandboxed sessions and loops stop working. The diff adds no minimum-version check and no fallback. The tests only compare argument strings, so they cannot catch this. Uncertain: I could not confirm from the diff alone which msb versions accept quota= on -v mounts or whether 100g is a valid unit there.

Comment thread src/sandbox/context.ts
'[Sandbox] This session runs inside a container: bash tool commands execute in that container, not on the host. OS-specific commands or tools may differ from the host system.',
'Environment-specific tooling that is missing or incompatible is not acceptable: install or reinstall the required tooling and dependencies in the container, rerun the intended checks, and do not misreport environment-induced failures as code defects.',
SHARED_WORKSPACE_ARTIFACTS_NOTE,
`The project directory mount has a guest-write quota of ${SANDBOX_WORKSPACE_QUOTA}, so df on it reports that budget rather than the host disk's free space; if writes there fail with "No space left on device", delete build output in the workspace rather than concluding the host disk is full.`,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Misleading note

The note always states a 100g quota. Sandboxes created before this change keep their 4 GiB mounts, as the PR's own docs admit. In those sandboxes the agent is told something that does not match what df shows, and it is only advised to delete build output, never to recreate the sandbox.

@lil-worker-cstech

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
⚠️ Risk level: Medium
✅ Merge recommendation: Needs review
🔎 Failure modes

What: Sandbox creation fails for every writable workspace because the installed msb does not accept the `quota=` volume option or expects a different spelling or unit. Before this PR, the same mount was passed as a bare `host:guest`, which worked.
Where: src/sandbox/msb.ts:buildMsbCreateArgs
Trigger: A user runs an msb release that predates the `-v host:guest:quota=<size>` syntax, or parses `100g` differently.
Detected by: Nothing in this PR. The tests only check the generated argument strings and never run a real `msb create`.
Covered in this PR: No

What: Agents in sandboxes created by an older Forge build are told the workspace quota is 100g, but those sandboxes still have the 4 GiB default. An agent that sees `df` report about 4 GiB may think the note is wrong and keep deleting build output, when the real fix is to recreate the sandbox.
Where: src/sandbox/context.ts:SANDBOX_CONTEXT_NOTE
Trigger: A sandbox created before this change is adopted again after the upgrade.
Detected by: Nothing.
Covered in this PR: No

🧪 PR contains tests
🔒 No security concerns identified

@lil-worker-cstech

Copy link
Copy Markdown
Contributor

PR Code Suggestions ✨

No code suggestions found for the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant