Repository navigation
feat(sandbox): native sandboxes with per-machine repository caches - #1202
Closed
crispinhu27 wants to merge 8 commits into
Closed
crispinhu27 wants to merge 8 commits into
crispinhu27 wants to merge 8 commits into
Conversation
…andboxes Local sandboxes are now for conversation workspaces only. Each one is bound to one execution machine and its owner, and opens git worktrees of that machine's own checkouts (per-repository paths, or a clone under ~/.loopforge/local). Native tools inside the workspace follow Claude Code's default permission rules for every CLI. SOPs can no longer use local; the default SOP sandbox is generic-docker and AGENTFLOW_LOCAL_SANDBOX is removed. Migration 040 moves the built-in SOPs to generic-docker. A sandbox now carries its own Dockerfile (docker) or install script (native) instead of referencing separately shared Dockerfile and environment assets. The 环境资产 page becomes 沙箱管理 without type tabs, and /api/dockerfiles, /api/environments and their assistant tools are removed. Migration 041, run by the installer and ./start.sh pull, copies existing recipes into their sandboxes, wraps unused ones as sandboxes of their own and drops the old tables. The runner protocol is unchanged. BREAKING CHANGE: /api/dockerfiles and /api/environments are removed; PUT /api/sandboxes takes dockerfile and install in place of dockerfileId and environmentId. Unbound local sandboxes must be re-saved by the machine owner.
…om source SOPs can no longer use local sandboxes, so the e2e suite defaults to e2e-native, a native sandbox it creates in its own project. The browser job installs bubblewrap for it, and the public specs save their SOPs on generic-docker. The first-run job installs the pinned release with this checkout's schema scripts. Migration 041 changes the schema in a way the 0.4.0 image cannot read, so the job now builds this checkout whenever the schema scripts differ from the pinned tag.
…sandbox bwrap mounted its private /tmp after binding the workspace, so a workspace under the host /tmp was hidden and every command failed to chdir. The private /tmp now comes first. Engine, API and runner tests run SOP nodes in the test-native sandbox. On Linux their t.TempDir fixtures lived under the host /tmp, which the sandbox hides by design, so those test binaries now keep TMPDIR outside /tmp. The baseline-align test uses test-native instead of the removed local sandbox.
Shared schedule admission checked a sandbox's Dockerfile and environment as separate assets. Recipes now live in the sandbox, so the sandbox check covers them. Test fixtures that still used the removed local sandbox for SOPs now use test-native, and cloning a generic SOP onto local is refused.
crispinhu27
force-pushed
the
feat/local-sandbox-runner-worktree
branch
from
November 22, 2026 10:08
de22db9 to
a6481c9
Compare
…andbox A native sandbox gives every command a private /tmp, so the cloud-path test keeps its marker in the workspace there and in /tmp only for containers.
The welcome SOP now runs in generic-docker. Without AGENTFLOW_ISOLATED_IMAGE the browser job built that image during the acceptance specs and they timed out; it now pulls the image pinned in compose.yaml, as a Compose installation does.
…open A local workspace now starts empty like Docker and native ones. Each turn's repository list names the machine's checkout of every repository (localPath), so repositories added after the workspace opened get worktrees too, and the agent adds them only when a task needs them instead of cloning into the workspace. Runner cleanup still prunes the worktrees it removes.
Settings → AI 助手 gains a 对话工作区 preference (workspaceDriver: docker, native, local or empty). The assistant lists that kind first and opens it when it names no environment; session pins still win. The workbench environment picker now lists native sandboxes and usable local sandboxes.
4 of 11 tasks
Collaborator
Author
|
Superseded by #1258. After discussion this change was redesigned: local sandboxes are removed, native sandboxes carry only environment variables, and native workspaces clone from a per-machine repository cache. Renaming the branch to |
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. 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.040_native_sandbox_inline_assets.sql) runs from the installer and./start.sh pullviascripts/install-schema-extensions.sh. It:localsandboxes into native ones;PATHfrom native sandbox variables (PATH is not rejected on later saves);localtogeneric-docker;assistant_preferences.workspace_driver(startup AutoMigrate adds it too);dockerfilesandenvironmentstables.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 cannot read migration 040.Validation
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.clone --sharedfrom$LOOPFORGE_REPOSITORY_CACHEgave a checkout with origin on the repository URL and alternates pointing at the cache. Writing into the cache was denied.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