Public: anyone can read this; the crew can change it.
A check's scratch path is short enough for unix sockets: the crew's sandbox starts inside a hosted forge's check #13759
A crew run's temp directory, where Claude Code's sockets live, no longer falls back to a check's long scratch path. Inside a hosted forge's check it now goes under /tmp. test/crew-sandbox.test.ts passes here (33 tests), and tsc and the gate are clean.
stopped closed without shipping deploy f74c9c1
4 earlier comments
A crew run's temp directory, where Claude Code's sockets live, no longer falls back to a check's long scratch path. Inside a hosted forge's check it now goes under /tmp. test/crew-sandbox.test.ts passes here (33 tests), and tsc and the gate are clean. I haven't seen it pass in a check on a hosted forge, which is what the issue's "done when" asks for.
Cause. When the data directory path was too long, runTmpDir in src/crew/sandbox.ts moved the run's temp directory to tmpdir()/fr-<id>. Inside a hosted forge's check, tmpdir() is itself a long scratch path, so the sockets were truncated again and the mux socket failed with EADDRINUSE.
Change.
- A new
shortTemp()keepstmpdir()only when<temp>/fr-<id>plus a socket name fits in 107 characters. Otherwise it uses/tmp. tempDeniednow also denies other runs'fr-*directories in/tmpwhen the run's temp has moved there.sweepRunTmpsweeps/tmpas well astmpdir().- A new test uses a check-like long scratch path and asserts the run temp is
/tmp/fr-<id>with a socket path of at most 107 characters. - I edited an existing test, "in a long temp directory holding the data directory…". It asserted that the run temp stays beside the data in the long temp, which was the bug, so it now expects
/tmp/fr-….
Not done. I used /tmp rather than a new /run/forge/<id>. /run/forge doesn't exist and needs privileges to create, and /tmp is writable in checks and cells and already holds these directories. I didn't verify the issue's "two files, 32 tests" claim; I only ran test/crew-sandbox.test.ts. The sandbox here can't use bwrap, so the sandbox-enforcing tests are not exercised.
I've pushed nothing for #13759. No failed check is recorded for its head, and I found no defect in the change.
Before I pushed, the type check, the gate and test/crew-sandbox.test.ts (33 tests) were green here. The forge will check the head again by itself. If that run is red on a named test, I'll fix that test's assertion.
I merged main into the branch and pushed it. The merge went through with no conflicts, and neither scripts/gate.ts nor test/gate-update-pull.test.ts has conflict markers.
What the pull changes: the short-path temp directory a run uses now stays short when a check's scratch temp is long. Sockets go under /tmp rather than the scratch path. The change is in src/crew/sandbox.ts, with its test in test/crew-sandbox.test.ts.
Checks after the merge:
bun scripts/gate.ts --fixleft nothing to commit.bun x tsc --noEmitwas clean.test/gate-update-pull.test.tspassed (6 tests).test/crew-sandbox.test.tspassed (33 tests).
I did not run the other 354 test files scripts/fast.ts picked, because they were estimated at about 30 minutes, over its 5-minute budget. The forge runs the full check on this push.
A background bun test over that fast-picked list was still running when I pushed. I didn't wait for its result, so those tests are unverified here.
I merged main into this branch and pushed. Main had already fixed #13752 more thoroughly, so this pull no longer adds any change of its own.
Main's version of src/crew/sandbox.ts and test/crew-sandbox.test.ts is what's there now. It falls back through the temp directory, then a checked short root, then a listing guard, and has its own tests. Before committing I compared the merged tree with main's and they are identical. I kept main's side rather than blending the two versions, because mine only added a fixed /tmp fallback that main's logic already covers.
bun x tsc --noEmit is clean. test/crew-sandbox.test.ts and test/sandbox-short-root.test.ts pass (43 tests, 0 failures).
A person may want to close this pull as redundant instead of merging it.
A crew run's temp directory, where Claude Code's sockets live, no longer falls back to a check's long scratch path. Inside a hosted forge's check it now goes under
/tmp.test/crew-sandbox.test.tspasses here (33 tests), andtscand the gate are clean. I haven't seen it pass in a check on a hosted forge, which is what the issue's "done when" asks for.Cause. When the data directory path was too long,
runTmpDirinsrc/crew/sandbox.tsmoved the run's temp directory totmpdir()/fr-<id>. Inside a hosted forge's check,tmpdir()is itself a long scratch path, so the sockets were truncated again and the mux socket failed with EADDRINUSE.Change.
shortTemp()keepstmpdir()only when<temp>/fr-<id>plus a socket name fits in 107 characters. Otherwise it uses/tmp.tempDeniednow also denies other runs'fr-*directories in/tmpwhen the run's temp has moved there.sweepRunTmpsweeps/tmpas well astmpdir()./tmp/fr-<id>with a socket path of at most 107 characters./tmp/fr-….Not done. I used
/tmprather than a new/run/forge/<id>./run/forgedoesn't exist and needs privileges to create, and/tmpis writable in checks and cells and already holds these directories. I didn't verify the issue's "two files, 32 tests" claim; I only rantest/crew-sandbox.test.ts. The sandbox here can't use bwrap, so the sandbox-enforcing tests are not exercised.Closes #13752