Skip to content

feat(compute): run cloud workspaces through the Sandbox SDK - #483

Draft
iamnbutler wants to merge 5 commits into
mainfrom
compute-sandboxes
Draft

iamnbutler wants to merge 5 commits into
mainfrom
compute-sandboxes

Conversation

@iamnbutler

Copy link
Copy Markdown
Contributor

Draft, parked for now. This moves cloud workspaces (services/compute) from Cloudflare's container API to the Sandbox SDK, a provider-neutral sandbox API (Cloudflare, Vercel, E2B, Daytona, Modal and others), so teams could run workspaces on providers other than Cloudflare. Related: #58.

The SDK isn't on npm, so it is forked to githubnext/sandbox (branch ace), and its built output is vendored in services/compute/vendor/sandbox-sdk. The fork adds:

  • status(), so the controller can tell whether a sandbox is running without starting it.
  • A Cloudflare stop() that treats the expected Durable Object reset as success.
  • A Cloudflare create() that doesn't wake the container.

What changes in Ace:

  • The controller reaches the runner by running curl against localhost inside the sandbox. Request and reply bodies travel as files, so the runner needs no exposed port on any provider. These calls carry ACE_CONTROL=1 so the checkpoint's idle check ignores them.
  • A workspace counts as running only when the sandbox reports running and the runner answers /health. A container restarted by an image rollout used to look like it was running even though its runner was gone.
  • Start restarts an exited runner in place when the project is still on disk, so work newer than the checkpoint survives. It replaces the sandbox from the checkpoint only when the project is gone.
  • The image builds on cloudflare/sandbox:0.12.9, which the SDK's Cloudflare adapter needs.

Tested against a deployed copy of the service through the host's real compute create, start and stop:

  • Create to connected took 6.5–16.6 s, followed by a real agent run that made a lane commit.
  • Stop/start cycles: stop takes about 5–6 s with a 12 MB checkpoint, and start about 5–9 s. The lane commit and untracked files survived every cycle.
  • After I killed the runner, start restarted it in place and a file written after the checkpoint survived.

Why it's parked: on Cloudflare alone this is a step back from the direct container API.

  • No sizes or resize. The SDK has no portable way to choose resources, so the instance type is fixed in wrangler.jsonc and the size setting is ignored.
  • More hops. Each call to the runner goes through a second Durable Object and Cloudflare's control plane inside the container, plus a shell and curl.
  • An unexplained stop failure. Twice, soon after a deploy, stop failed with Durable Object reset because its code was updated (HTTP 409). The checkpoint had already been saved, and later cycles worked; I couldn't reproduce it on demand.

This is worth merging only once a second provider (Vercel or E2B) runs a workspace through the same controller. If that works, the next steps are adding resources and direct port access to the fork.

Built in Ace

No. Claude Code in a terminal did the research, the SDK fork and the live tests against a deployed spike Worker. The session started there as a research question about GitHub Sandboxes and continued there; Ace wasn't missing anything for this work. Tracked under #5.

Spike: the Compute object drives its workspace through @sandbox-sdk/core
with the Cloudflare adapter instead of ctx.container, so another adapter
can replace it. The controller reaches the runner with shell and file
calls rather than a container port, and marks those calls so the
runner's quiescence check ignores them. The SDK is vendored until it is
published to npm.
Why: services/compute/index.ts | a container restart loses the runner, so running means the sandbox reports running and the runner answers /health
…its workspace

Why: services/compute/index.ts#class Compute | start replaces a running sandbox only when its project is gone, so work newer than the checkpoint is never destroyed

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant