Repository navigation
Conversation
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
cc4b1ab0-14cf-46f7-a6b8-303016a4ab4b
📒 Files selected for processing: 23
skill-guides/orca-cli.mdsrc/cli/bundled-skill-guides.tssrc/cli/handlers/worktree-create-recipe.tssrc/cli/handlers/worktree.tssrc/cli/index-worktree-create-recipe.test.tssrc/cli/specs/core.tssrc/main/ephemeral-vm-cli-workspace-create.tssrc/main/ephemeral-vm-environment-provision.tssrc/main/ephemeral-vm-recipe-workspace-create.test.tssrc/main/ephemeral-vm-recipe-workspace-create.tssrc/main/ipc/ephemeral-vm.tssrc/main/provisioned-root-checkout.tssrc/main/runtime/orca-runtime-get-status.tssrc/main/runtime/orca-runtime.tssrc/main/runtime/rpc/methods/agent-launch-target-authorization.tssrc/main/runtime/rpc/methods/worktree-provisioned-root-method.tssrc/main/runtime/rpc/methods/worktree-recipe-create-method.test.tssrc/main/runtime/rpc/methods/worktree.tssrc/main/runtime/runtime-rpc/runtime-rpc-long-poll.tssrc/main/startup/main-process-runtime-service.tssrc/shared/rpc-contract/worktree-create-params.tssrc/shared/rpc-contract/worktree-provisioned-root-params.tssrc/shared/worktree-recipe-create-capability.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| provision: () => | ||
| provisionRecipeEnvironment( | ||
| store, | ||
| userDataPath, | ||
| { | ||
| repoId: repo.id, | ||
| recipeId: recipe.id, | ||
| workspaceName: params.name, | ||
| projectId, | ||
| branch: branchName, | ||
| ref: params.baseBranch | ||
| }, | ||
| pluginRecipes | ||
| ), |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Pass a cancellation signal into recipe provisioning.
provisionRecipeEnvironment accepts options.signal, but this call passes no options. The recipe flow has three phases: VM provisioning, the remote projectHostSetup.setupExistingFolder call, and worktree.adoptProvisionedRoot. Each remote call has its own 600 s budget. The CLI waits a total of 600 s (timeoutMs: 600_000 in src/cli/handlers/worktree-create-recipe.ts).
If the CLI times out or the user interrupts it, the host continues. It creates the VM and the remote workspace, but the caller never receives recipeEnvironmentId. The CLI does not send a clientMutationId, so a retry is not deduplicated and provisions a second machine. The first VM stays running and incurs cost, and the user does not know about it.
Wire the RPC abort signal from the long-poll context through createManagedRecipeWorkspace into createCliRecipeWorkspace. Pass it to provisionRecipeEnvironment. The existing catch in createProvisionedRecipeWorkspace then destroys the VM on abort. If the long-poll path does not supply context.signal for worktree.create, add that wiring. Alternatively, have the CLI send a clientMutationId so a retry joins the in-flight create.
🔧 Sketch
--- "a/src/main/ephemeral-vm-cli-workspace-create.ts"
+++ "b/src/main/ephemeral-vm-cli-workspace-create.ts"
@@ -54,20 +54,21 @@
return createProvisionedRecipeWorkspace(
{ params, branchName, projectId },
{
provision: () =>
provisionRecipeEnvironment(
store,
userDataPath,
{
repoId: repo.id,
recipeId: recipe.id,
workspaceName: params.name,
projectId,
branch: branchName,
ref: params.baseBranch
},
- pluginRecipes
+ pluginRecipes,
+ args.signal ? { signal: args.signal } : {}
),
call: (environmentId, method, payload) =>
callRuntimeEnvironment(userDataPath, `id:${environmentId}`, method, payload, 600_000),
attach: (runtimeId, workspaceId) => {Also add signal?: AbortSignal to the createCliRecipeWorkspace args. Thread context.signal from the worktree.create handler through createManagedRecipeWorkspace and the registered creator.
|
Strong +1. This is the missing piece for my setup, and I'd use it the day it lands. Use case: I run an orchestrator agent, a skill driving orca orchestration task-create / worker-start, that fans tickets out to 10–15 worker agents. Running all of them on one laptop melts it: the harness, Docker, test suites and frontend builds compete for the same CPUs. Paired servers (worker-start --on ) already move workers onto a fixed box. What I can't do from the CLI is give each worker its own throwaway VM, which is exactly what environmentRecipes do from the desktop dialog. What I'd need from the CLI path:
Happy to test against Fly or Vercel Sandbox once it's in a build. |
|
+1, really looking forward to seeing this merged. Thank you so much! |
|
+1 |
|
@nwparker I need this and #28435 for a controller setup (#30422): a headless Are you planning to rebase them? If not, I can port both onto current |
|
@nwparker thanks for landing #36838. One more question about this PR and #28435. Host-side recipe create and host-side destroy are the two things a headless controller still lacks: a phone or laptop can't create a VM workspace through it, and removing one leaves the VM running. Both PRs now conflict with Would you rather finish them yourself, or should I port both onto current |
|
Thanks @nwparker for all the work here, and @jutaz for offering to port it. Whichever path is easier for you works for me. I'm not trying to rush anything, just adding a data point. My use case is similar to @ArturMakowski 's above. I use boat.dev, and with this PR an orchestrator skill could create each worktree independently on its own boat.dev sandbox, all running in parallel. That would let Orca drive hundreds of worktrees at once. On a local machine I hit resource limits long before that, and creating recipe workspaces by hand from the desktop composer doesn't scale. With This PR (create) and #28435 (destroy) are exactly the two pieces needed for that loop. Once a rebased build is available, I'm happy to test it end to end against a boat.dev recipe and report back. |
|
@nwparker I've ported this onto current
The two stay independently mergeable, as you split them, and they merge cleanly in either order. Both have open questions for you in their Review sections, notably the |
`orca worktree create --recipe <id>` creates the workspace on a new environment from one of the repo's environment recipes, and `orca vm recipe list` shows which recipes it accepts. The desktop app on the provisioning computer runs the same main-side provisioning the composer uses (write-ahead record, per-step timeouts, cancellation), registers the project on the environment's Orca server, then creates (orca-worktree) or adopts (provisioned-root) the workspace there. Named progress steps ride on long-poll keepalive frames, so the CLI prints them to stderr; older CLIs ignore them. A failure after the VM exists destroys it through the shared cleanup and returns recipe_workspace_create_failed with the failed step, the recipe failure code and whether the destroy finished. Ctrl+C aborts the request and destroys a started environment. Paired devices cannot start a recipe create. Hosts advertise worktree.recipe-create.v1 only when the desktop wires the recipe service, so orcad and older hosts are refused before anything runs. Based on #39228 by jutaz, a port of #28439. Co-authored-by: Justas Brazauskas <[email protected]>
* feat(cli): create workspaces on environment recipes `orca worktree create --recipe <id>` creates the workspace on a new environment from one of the repo's environment recipes, and `orca vm recipe list` shows which recipes it accepts. The desktop app on the provisioning computer runs the same main-side provisioning the composer uses (write-ahead record, per-step timeouts, cancellation), registers the project on the environment's Orca server, then creates (orca-worktree) or adopts (provisioned-root) the workspace there. Named progress steps ride on long-poll keepalive frames, so the CLI prints them to stderr; older CLIs ignore them. A failure after the VM exists destroys it through the shared cleanup and returns recipe_workspace_create_failed with the failed step, the recipe failure code and whether the destroy finished. Ctrl+C aborts the request and destroys a started environment. Paired devices cannot start a recipe create. Hosts advertise worktree.recipe-create.v1 only when the desktop wires the recipe service, so orcad and older hosts are refused before anything runs. Based on #39228 by jutaz, a port of #28439. Co-authored-by: Justas Brazauskas <[email protected]> * fix(cli): report the VM outcome when connecting fails; record no cross-host parent * fix(vm-recipes): destroy the VM when recording its environment fails; reset exitCode in CLI tests * perf(types): keep recipe orchestration out of the runtime's type graph --------- Co-authored-by: Justas Brazauskas <[email protected]>
`orca worktree create --on <target>` picks where a workspace runs. - An existing host (local, ssh:<id>, runtime:<id>, a host name) works exactly like --host. - A provider target creates a new host for the workspace first: recipe:<id> (orca.yaml environment recipe) or plugin:<plugin>/<id> (approved plugin recipe). provider:<id> is reserved for built-in providers. - `orca provider list/show/doctor` shows and checks providers, with versioned JSON (schemaVersion 1, allow-listed fields). Provider creates: - run through the same main-side provisioning the desktop uses (write-ahead record, step timeouts, cancellation) and the shared cleanup - send an idempotency key, keyed by target, so a retry returns the same workspace - report named steps (and the new host's id as soon as it's recorded) on long-poll keepalive frames, printed as text or NDJSON on stderr - fail with host_create_failed, whose data says the step, the provider's failure code and whether the new host was destroyed Exit codes for provider creates: 2 invalid input, 4 the workspace exists but a follow-up failed, 5 a host may still be running. Plain creates keep exit 1. Based on #39228 by jutaz, a port of #28439. Co-authored-by: Justas Brazauskas <[email protected]>
`orca worktree create --on <target>` picks where a workspace runs. - An existing host (local, ssh:<id>, runtime:<id>, a host name) works exactly like --host. - A provider target creates a new host for the workspace first: recipe:<id> (orca.yaml environment recipe) or plugin:<plugin>/<id> (approved plugin recipe). - `orca provider list/show/doctor` shows and checks providers, with versioned JSON (schemaVersion 1, allow-listed fields). Provider creates: - run through the same main-side provisioning the desktop uses (write-ahead record, step timeouts, cancellation) and the shared cleanup - send an idempotency key, keyed by target, so a retry returns the same workspace - report named steps (and the new host's id as soon as it's recorded) on long-poll keepalive frames, printed as text or NDJSON on stderr - fail with host_create_failed, whose data says the step, the provider's failure code and whether the new host was destroyed Exit codes for provider creates: 2 invalid input, 4 the workspace exists but a follow-up failed, 5 a host may still be running. Plain creates keep exit 1. Based on #39228 by jutaz, a port of #28439. Co-authored-by: Justas Brazauskas <[email protected]>
ELI5
An agent can create its own VM or sandbox workspace with
orca worktree create --recipe <id>, then start work there without opening the desktop composer.What Changed
The CLI verifies recipe support, then asks the provisioning host to run the selected
environmentRecipesentry. The host reuses desktop provisioning, connects to the managed Orca server, registers the checkout, and adopts its primary root at the pinned source commit and requested branch. The result includesrecipeEnvironmentIdfor follow-up commands. With--agent, the CLI launches on that server using the existing agent launch flow, including model, effort, prompt delivery, and safe replay.Why
Recipe provisioning was available only from the desktop composer. Sharing provisioning and checked-root adoption keeps the CLI and desktop behavior aligned instead of introducing a separate VM implementation. Capability checks prevent older hosts from silently ignoring the recipe and creating a local checkout. Agent recovery commands address the existing remote workspace, avoiding a second provisioning attempt.
Linked Issue
Refs #17292 and #17026. Implements the creation half of #17026 using the current managed-server architecture. Environment teardown is handled separately in #28435; both PRs target main independently.
Visual Proof
N/A — CLI/RPC change; no renderer components or layouts change.
Testing
124 tests passed across recipe orchestration, CLI recipe selection/agent launch, existing CLI create/parent/host flows, IPC provisioning/cancellation, pinned-ref selection, root verification/adoption, RPC dispatch, and long-poll transport. Full
pnpm tc, changed-code quality, RPC parameter catalog, bundled skill guide, and skill manifest checks passed on macOS. Real cloud infrastructure and Windows/Linux execution were not exercised.Review
Provisioning stays on the host that owns the recipe; checkout adoption and agents run on the serving host. Failed setup/adoption triggers destroy and retains any failed-cleanup record. Provider references, CLI provenance, comments and parent lineage are preserved.
recipeIdand adoption provenance are optional wire fields. Only provisioned-root SSH recipes are supported, matching the reference PR; sparse checkout and forced repo setup are refused before provisioning. The recipe create script owns setup.Agent skill upstream boundary
Notes
CLI recipe creation must run against the provisioning host, without an environment/pairing selector. Direct
agent.launchrequests embedding a recipe are refused; the CLI performs creation followed by launch on the existing remote workspace. CI covers the full build and broader checks.Checklist
N/Awith reason