Skip to content

refactor(cloud-agent): remove shared sandbox allocation - #9781

Merged
eshurakov merged 1 commit into
mainfrom
eshurakov/remove-shared-sandbox
Nov 4, 2026
Merged

eshurakov merged 1 commit into
mainfrom
eshurakov/remove-shared-sandbox

Conversation

@eshurakov

Copy link
Copy Markdown
Contributor

Summary

One sandbox serves one workspace. #9689 already made cloudflare-shared unselectable, so this PR removes the shared sandbox code that nothing reaches now. Users see no difference.

  • generateSandboxId and selectControlPlaneSandbox derive only per-session keys. An explicit cloudflare-shared allocation fails with the retired-allocation message.
  • Remove the shared route (shared-sandbox-route.ts), the SHARED_SANDBOX_OVERRIDES KV binding and PER_SESSION_SANDBOX_ORG_IDS.
  • Remove the shared-only subagent and spawn-authority checks from registration. A recorded shared kind in the operation ledger now fails with the retired-allocation message instead of a replay.
  • The spec, docs/control-plane.md and the related READMEs now state that one sandbox serves one workspace.

Stored data still decodes. The cloudflare-shared allocation, the shared sandbox kind, the metadata sandboxRoute and the legacy shared key classes stay in the schemas as legacy decode only. Those sessions ran on the retired Cloudflare Sandbox runtime, so they already stop with the retired-runtime message. Saved settings, environments and triggers that name the shared allocation use the default.

No PostgreSQL migration and no public API change.

Verification

  • cloud-agent-next typecheck and lint pass.
  • Unit tests: 6570 passed.
  • Workers integration tests (after pnpm run build:wrapper): 790 passed, 2 skipped.
  • worker-utils tests: 1198 passed.
  • E2E and web tests were not run.

Visual Changes

N/A

Reviewer Notes

  • After deploy, delete the SHARED_SANDBOX_OVERRIDES KV namespace and the PER_SESSION_SANDBOX_ORG_IDS secret.
  • worker-configuration.d.ts was edited by hand. Its header hash is stale; regenerate it with the private env file.
  • Existing bug, not changed here: admin container telemetry (apps/web/src/routers/admin/session-container-telemetry.ts) labels every sbx- ID as "Shared container". The fix must read the stored sandbox kind, because the ID prefix does not identify it.
  • The trigger and start schemas still accept cloudflare-shared, and the request then fails as retired. Narrowing them changes catalog.json, so it is left for a separate change.
  • The worktree-deletion shared action and the session-ingest kind: 'shared' mean sibling chats in one workspace, not a shared sandbox. They are not changed.

@kilo-code-bot

kilo-code-bot Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

Re-reviewed the rebased HEAD (42d4b62) after the branch was replayed onto a newer main (including the portable-SCM/credential-admission refactor): the shared-sandbox removal stays internally consistent, removed symbols and bindings have no live references, and every new-session path is forced to an isolated sbx-/ses- identity while legacy shared metadata remains decode-only and compute-blocked by the retired-runtime check.

Assumptions: [INFERENCE] A ledger row recorded before neutral sbx- keys — a legacy org-/usr-/bot-/ubt- key with no recorded sandboxKind/sandboxAllocation — would pass rebuildRecordedSessionAllocation (only a recorded kind shared is rejected) and could re-register on that legacy key, but only with provider cloudflare, which retiredRuntimeMessage blocks from compute; no current code path was found that records such a row. selectControlPlaneSandbox is still asserted with the removed botId: undefined key in src/session/session-prepare.test.ts (unchanged line; loose matcher ignores it). E2E and web suites were not executed in this review; findings are from static inspection of the current tree.

Files Reviewed (51 files)
  • .specs/cloud-agent-session.md
  • docs/byoc-vercel-implementation-plan.md
  • packages/worker-utils/src/sandbox-allocation.ts
  • services/cloud-agent-next/.dev.vars.example
  • services/cloud-agent-next/docs/control-plane.md
  • services/cloud-agent-next/docs/runtime-rollout.md
  • services/cloud-agent-next/src/cloud-agent-authority.test.ts
  • services/cloud-agent-next/src/cloud-agent-authority.ts
  • services/cloud-agent-next/src/persistence/session-metadata.ts
  • services/cloud-agent-next/src/router/handlers/session-management.ts
  • services/cloud-agent-next/src/router/handlers/session-worktree.test.ts
  • services/cloud-agent-next/src/router/handlers/session-worktree.ts
  • services/cloud-agent-next/src/sandbox-id.test.ts
  • services/cloud-agent-next/src/sandbox-id.ts
  • services/cloud-agent-next/src/sandbox-placement.test.ts
  • services/cloud-agent-next/src/sandbox-placement.ts
  • services/cloud-agent-next/src/sandbox-selection.test.ts
  • services/cloud-agent-next/src/sandbox-selection.ts
  • services/cloud-agent-next/src/session-prepare.test.ts
  • services/cloud-agent-next/src/session/control-plane-session-input.test.ts
  • services/cloud-agent-next/src/session/session-prepare.test.ts
  • services/cloud-agent-next/src/session/session-registration-metadata.ts
  • services/cloud-agent-next/src/session/session-registration-origin.test.ts
  • services/cloud-agent-next/src/session/session-registration.ts
  • services/cloud-agent-next/src/shared-sandbox-route.test.ts (deleted)
  • services/cloud-agent-next/src/shared-sandbox-route.ts (deleted)
  • services/cloud-agent-next/src/types.ts
  • services/cloud-agent-next/test/e2e/README.md
  • services/cloud-agent-next/test/e2e/deploy/README.md
  • services/cloud-agent-next/test/e2e/deploy/render-e2e-worker-config.mjs
  • services/cloud-agent-next/test/e2e/lifecycle.ts
  • services/cloud-agent-next/test/fixtures/hosted-workspace-contract/README.md
  • services/cloud-agent-next/test/integration/control-plane-scope-handle.test.ts
  • services/cloud-agent-next/test/integration/control-plane-session-v2-interactions.test.ts
  • services/cloud-agent-next/test/integration/control-plane-session-v2-management.test.ts
  • services/cloud-agent-next/test/integration/control-plane-session-v2-rpc.test.ts
  • services/cloud-agent-next/test/integration/control-plane-session-v2-transport.test.ts
  • services/cloud-agent-next/test/integration/control-plane-status-badge-v2.test.ts
  • services/cloud-agent-next/test/integration/control-plane-terminal-v2.test.ts
  • services/cloud-agent-next/test/integration/control-plane-worktree-changes-v2.test.ts
  • services/cloud-agent-next/test/integration/control-plane-worktree-deletion-v2.test.ts
  • services/cloud-agent-next/test/integration/kilo-facade-cold-runtime.test.ts
  • services/cloud-agent-next/test/integration/kilo-facade-native-fence.test.ts
  • services/cloud-agent-next/test/integration/kilo-facade-system-feed.test.ts
  • services/cloud-agent-next/test/integration/sandbox-control-v2-runtime-proxy.test.ts
  • services/cloud-agent-next/test/integration/shared-sandbox-route.test.ts (deleted)
  • services/cloud-agent-next/test/unit/render-e2e-worker-config.test.ts
  • services/cloud-agent-next/worker-configuration.d.ts
  • services/cloud-agent-next/wrangler.e2e-workers.jsonc
  • services/cloud-agent-next/wrangler.jsonc
  • services/cloud-agent-next/wrangler.test.jsonc
Previous Review Summary (commit 8143640)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 8143640)

Status: No Issues Found | Recommendation: Merge

Executive Summary

The shared-sandbox removal is internally consistent: new-session paths reject cloudflare-shared, stored metadata still decodes legacy shared identities, and retired-runtime checks close the remaining authority paths.

Assumptions: [INFERENCE] A ledger row recorded before neutral sbx- keys, with a legacy usr-/org- key and no recorded sandboxKind/sandboxAllocation, would not hit the new recorded-shared guard in rebuildRecordedSessionAllocation; such rows, if any remain inside ledger retention, would still be rebuilt on a cloudflare (retired) provider, which retiredRuntimeMessage blocks from compute. No current code path was found that records such a row. Legacy shared sessions could not be exercised end to end, and tests were reviewed statically rather than executed.

Files Reviewed (51 files)
  • .specs/cloud-agent-session.md
  • docs/byoc-vercel-implementation-plan.md
  • packages/worker-utils/src/sandbox-allocation.ts
  • services/cloud-agent-next/.dev.vars.example
  • services/cloud-agent-next/docs/control-plane.md
  • services/cloud-agent-next/docs/runtime-rollout.md
  • services/cloud-agent-next/src/cloud-agent-authority.test.ts
  • services/cloud-agent-next/src/cloud-agent-authority.ts
  • services/cloud-agent-next/src/persistence/session-metadata.ts
  • services/cloud-agent-next/src/router/handlers/session-management.ts
  • services/cloud-agent-next/src/router/handlers/session-worktree.test.ts
  • services/cloud-agent-next/src/router/handlers/session-worktree.ts
  • services/cloud-agent-next/src/sandbox-id.test.ts
  • services/cloud-agent-next/src/sandbox-id.ts
  • services/cloud-agent-next/src/sandbox-placement.test.ts
  • services/cloud-agent-next/src/sandbox-placement.ts
  • services/cloud-agent-next/src/sandbox-selection.test.ts
  • services/cloud-agent-next/src/sandbox-selection.ts
  • services/cloud-agent-next/src/session-prepare.test.ts
  • services/cloud-agent-next/src/session/control-plane-session-input.test.ts
  • services/cloud-agent-next/src/session/session-prepare.test.ts
  • services/cloud-agent-next/src/session/session-registration-metadata.ts
  • services/cloud-agent-next/src/session/session-registration-origin.test.ts
  • services/cloud-agent-next/src/session/session-registration.ts
  • services/cloud-agent-next/src/shared-sandbox-route.test.ts (deleted)
  • services/cloud-agent-next/src/shared-sandbox-route.ts (deleted)
  • services/cloud-agent-next/src/types.ts
  • services/cloud-agent-next/test/e2e/README.md
  • services/cloud-agent-next/test/e2e/deploy/README.md
  • services/cloud-agent-next/test/e2e/deploy/render-e2e-worker-config.mjs
  • services/cloud-agent-next/test/e2e/lifecycle.ts
  • services/cloud-agent-next/test/fixtures/hosted-workspace-contract/README.md
  • services/cloud-agent-next/test/integration/control-plane-scope-handle.test.ts
  • services/cloud-agent-next/test/integration/control-plane-session-v2-interactions.test.ts
  • services/cloud-agent-next/test/integration/control-plane-session-v2-management.test.ts
  • services/cloud-agent-next/test/integration/control-plane-session-v2-rpc.test.ts
  • services/cloud-agent-next/test/integration/control-plane-session-v2-transport.test.ts
  • services/cloud-agent-next/test/integration/control-plane-status-badge-v2.test.ts
  • services/cloud-agent-next/test/integration/control-plane-terminal-v2.test.ts
  • services/cloud-agent-next/test/integration/control-plane-worktree-changes-v2.test.ts
  • services/cloud-agent-next/test/integration/control-plane-worktree-deletion-v2.test.ts
  • services/cloud-agent-next/test/integration/kilo-facade-cold-runtime.test.ts
  • services/cloud-agent-next/test/integration/kilo-facade-native-fence.test.ts
  • services/cloud-agent-next/test/integration/kilo-facade-system-feed.test.ts
  • services/cloud-agent-next/test/integration/sandbox-control-v2-runtime-proxy.test.ts
  • services/cloud-agent-next/test/integration/shared-sandbox-route.test.ts (deleted)
  • services/cloud-agent-next/test/unit/render-e2e-worker-config.test.ts
  • services/cloud-agent-next/worker-configuration.d.ts
  • services/cloud-agent-next/wrangler.e2e-workers.jsonc
  • services/cloud-agent-next/wrangler.jsonc
  • services/cloud-agent-next/wrangler.test.jsonc

Reviewed by deepseek-flash-latest · Input: 134.5K · Output: 20K · Cached: 3.7M

Review guidance: REVIEW.md from base branch main

One sandbox serves one workspace. Nothing creates an owner-scoped shared
sandbox any more:

- generateSandboxId and selectControlPlaneSandbox derive only per-session
  keys and reject an explicit cloudflare-shared allocation.
- Remove the shared route, its failover KV namespace binding
  (SHARED_SANDBOX_OVERRIDES) and PER_SESSION_SANDBOX_ORG_IDS.
- Remove the shared-only subagent and spawn-authority checks from
  registration; a recorded shared kind in the operation ledger now fails
  with the retired-allocation message instead of being replayed.

Stored data keeps decoding: the cloudflare-shared allocation, the shared
sandbox kind, the metadata sandboxRoute and the legacy shared key classes
stay in the schemas as legacy decode only. Such sessions ran on the retired
Cloudflare Sandbox runtime, so they already stop with the retired-runtime
message; saved settings, environments and triggers that name the shared
allocation fall through to the default.
@eshurakov
eshurakov force-pushed the eshurakov/remove-shared-sandbox branch from 8143640 to 42d4b62 Compare November 4, 2026 15:37
@eshurakov
eshurakov added this pull request to the merge queue Nov 4, 2026
Merged via the queue into main with commit 59a5df9 Nov 4, 2026
82 checks passed
@eshurakov
eshurakov deleted the eshurakov/remove-shared-sandbox branch November 4, 2026 16:35
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.

2 participants