mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
Control-plane half of W1, org environment builds (Conductor "Cloud Computer" parity). The desktop settings UI, CLI and disk banner follow in a second PR. - **Org environment**: repos (GitHub, up to 50, each with a default branch), an install script, env var names, and a machine size (Standard 4/8 or Large 8/16; Large bills 2× through the existing usage path). Members can read; owners and admins edit. Edits use optimistic concurrency. - **Versioned builds** (`#N`), with status, live log stream (ndjson), stored log, failure step, duration and snapshot. - Each build boots a throwaway VM from the active golden image, clones every repo, and runs the install script once with `set -euo pipefail`. - It records commits and lockfile blob ids, checks that orcad survived, then saves a manual snapshot. - **Failed builds never replace the active build.** Rollback is instant (`activate`). The newest 5 builds plus the active one keep their snapshots. - **New workspaces boot from the active build** (or a pinned `environmentBuildId`). Existing workspaces keep their build, and destroying a workspace never deletes the shared image. - A first-boot prelude links the prebuilt repo as the project and fast-forwards the requested branch. - A post-checkout hook hard-links the installed dependency folders into each new Orca worktree (about 250 ms). - **Rebuild prompt** (`/staleness`): reports a lockfile change, a moved default branch, a config edit, or a newer base image. It uses the GitHub compare API, or anonymous smart-HTTP plus raw blob hashing when the REST API refuses Worker IPs. - **Repos with no commits** build and open; Orca adds an empty first commit. - **Hardening from the review**: - Recovers a snapshot whose finalize was cut off (adopted by box name). - Bounded log reads on cancel/timeout. - Org secret values are redacted from live and stored logs. - Activation is guarded in SQL. - Build-number races return 409. - Migration `0008_environments.sql`: number claimed in /tmp/vdrv/migrations.claims and already applied to dev D1. It is additive. ## Evidence (real Vercel VMs) Full write-up: `.context/cloud/reports/w1-env-builds.md`. - vercel/ms build: 15.9 s (boot 1.8 s, clone+install 6 s, snapshot 8 s). - Private `nwparker/orca-sandbox-push-test` plus public `vercel/ms` in one environment on the shared dev preview: build succeeded in 18 s, and a workspace created from it was ready in 6.3 s. - Create → orcad ready: | Boots from | p50 | p95 | |---|---|---| | Environment build (n=10, deps installed) | 4.37 s | 8.41 s | | Bare golden image (n=9) | 4.79 s | 7.61 s | - Rollback, creating from build N-1, an empty repo (`rsc/empty`), and staleness `deps_changed` → Rebuild → `up_to_date` were all verified live. ## Tests `cloud/apps/sandbox-control`: 99 vitest tests and typecheck pass. The new `test/environments.test.ts` covers RBAC, build/fail/keep-last-good, concurrent build 409, cancel, live stream, boot from active and pinned builds, rollback, prune, interrupted-snapshot recovery, and staleness.