Repository navigation
feat(sandbox): native sandboxes with per-machine repository caches - #1258
Open
crispinhu27 wants to merge 10 commits into
Open
crispinhu27 wants to merge 10 commits into
crispinhu27 wants to merge 10 commits into
Conversation
Docker sandboxes embed their Dockerfile and native sandboxes carry only environment variables; the local sandbox type, Dockerfile and environment assets and install scripts are removed. Native sandboxes run on any execution machine with its own toolchains. Each Runner and the platform host keep a bare cache per repository, refreshed outside the sandbox; native SOP checkouts and conversation agents clone from it with --shared, and checkpoints copy the borrowed objects in. 设置 → AI 助手 can prefer a sandbox kind for conversation workspaces. Migration 040 moves Dockerfiles into sandboxes, turns local sandboxes into native ones and drops install scripts and PATH.
4 of 11 tasks
The sandbox editor, its list, 设置 → AI 助手 and the workbench picker call the two kinds Docker and 系统轻量隔离 (Lightweight system isolation in English). The SOP wizard no longer filters local sandboxes, which now read as native.
The platform sends <root>/ws as the cwd of Codex app-server threads. Docker and bwrap map that path onto the run workspace; seatbelt cannot, so a native conversation on macOS started in a read-only directory and the agent could not check repositories out. Stdin to a seatbelt conversation process now names the run workspace instead.
Keep native workspace preferences alongside the approval review settings, including when older clients save other preferences.
Reserve 040 for the approval settings migration. Apply 041 explicitly and roll back sandbox data changes on conflicts instead of silently dropping unused Dockerfiles.
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 changed
Native sandboxes replace local sandboxes and carry only environment variables. The
localsandbox type is removed. A native sandbox runs on whichever machine executes the work: a user's execution machine, a cloud runner or the platform host. It uses that machine's own toolchains. Environment install scripts,$PREFIXand install PATH entries are gone. Settings such asJAVA_HOMEgo into the sandbox's environment variables, and MCP servers are installed the way native sandboxes already installed them. SOPs and conversation workspaces can use Docker or native sandboxes. The default sandbox isgeneric-docker, andAGENTFLOW_LOCAL_SANDBOXis removed. Sandboxes no longer name an execution machine or per-machine repository paths, so a native sandbox is not tied to one machine.Native workspaces check repositories out from a per-machine repository cache.
<workspace root>/.repository-cache/<repository id>.git. It is fetched outside the sandbox under a lock and never garbage-collected.git clone --sharedof the refreshed cache, with origin set back to the repository URL. If the cache cannot be used, the checkout falls back to a full clone. Docker sandboxes keep full clones.$LOOPFORGE_REPOSITORY_CACHEfirst. The cache is read-only inside the sandbox (seatbelt rules,--ro-bind-tryunder bwrap).repack -a -d, then dropalternates), so checkpoints restore on machines without the cache.Users can prefer a sandbox kind for conversation workspaces. 设置 → AI 助手 gains 「对话工作区 → 倾向的沙箱」 (Docker, native, or left to the agent), stored per user as
workspaceDriver. When a conversation has no fixed environment, the agent sees that kind first in its choices and opens it when it names no sandbox. It still switches when only another environment has the toolchain a task needs. The workbench environment picker also lists native sandboxes, grouped by kind.Docker sandboxes carry their own Dockerfile. A docker sandbox now stores its Dockerfile (content plus build-context files). Separately shared Dockerfile and environment assets no longer exist. In the console, 环境资产 becomes 沙箱管理 without type tabs. The sandbox editor edits the Dockerfile inline for docker and only environment variables for native. Its isolation options, the 设置 → AI 助手 preference and the workbench picker call the two kinds 「Docker」 and 「系统轻量隔离」 (Lightweight system isolation in English). Old
#dockerfiles/#environmentslinks redirect there.Scope
Compatibility
/api/dockerfiles,/api/environmentsand their assistant and MCP tools are removed.PUT /api/sandboxestakesdockerfile {content, files}in place ofdockerfileId. It rejectsdriver: localand ignoresinstall,runnerId,baseDirandrepositoryPaths.bootstrapno longer returnsdockerfilesorenvironments.docs/api/registry.mdandCHANGELOG.mdare updated.041_native_sandbox_inline_assets.sql). For Compose upgrades, stop the old platform with./start.sh stop platform, back up the database with MySQL still running, then apply migration 041 with./start.sh migrate-sandboxesbefore starting the upgraded platform. Apply the SQL directly for external MySQL deployments. Fresh installations seed sandboxes with inline Dockerfiles. Migration 041 performs these changes.localsandboxes to native and removes legacy install scripts, asset references and nativePATHoverrides.localtogeneric-docker.assistant_preferences.workspace_driverand carries a savedlocalpreference forward asnative.localsandbox reads as native. A run frozen with alocalsandbox asks to be started again with a native one.e2e-nativesandbox it creates in its own project. The browser job installs bubblewrap for it and pulls the pinned platform image forgeneric-docker, as a Compose install does.first-runbuilds this checkout instead of pulling the pinned release whenever the schema scripts differ from that release's tag, because the released image uses the previous catalog format.Validation
After merging
main, the assistant preferences tests verified the sandbox choice alongside the approval reviewer settings, including saves from older clients. Docker MySQL 8.4 covered legacy conversion, Dockerfile ID collisions, transaction rollback and repeated migration. The repository cache tests passed withsafe.bareRepository=explicit. All 12 catalog API cases passed against a fresh local platform, and the desktop settings navigation case passed three consecutive Chromium runs.Run on macOS (arm64), Go 1.26, Node 22, after squashing and rebasing onto current
main(v0.4.1):TestLocalWorkspaceGitDiscoveryCannotReachParent,TestHostInsteadOfUsernamePromptThenAskPassandTestProcessSandboxPathsProfilesAndCommands(which assumes Linux) fail the same way on a cleanmaincheckout on this machine.gitwork);runtime);engine,runner);httpapi).localsandbox and a native sandbox with an install script. Both became env-only native sandboxes, and the welcome SOP moved togeneric-docker.PUT /api/sandboxesrejectslocal, and keeps onlyenvironmentfor native.$LOOPFORGE_REPOSITORY_CACHE, branched and committed; writes to the cache were denied. The checkpoint after each turn copied the borrowed objects in and droppedalternates, and the clone passedgit fsck --fullwith the cache moved away.<root>/wsunder seatbelt (it also does so onmain): the platform sends that path as the app-server thread cwd, which Docker and bwrap map onto the run workspace but seatbelt cannot. Stdin to a seatbelt conversation process now names the run workspace instead (e49cddc5).bash scripts/scan-secrets.sh: the gitleaks binary is Linux-only;python3 scripts/test-install.py: its Linux/Docker installer cases fail on macOS, as on main;Safety
Supersedes #1202, which was closed when its branch was renamed.