Commit Graph
25 Commits
Author SHA1 Message Date
Neil 134fc24436 feat(cloud): boot-time orcad refresh so environment and older-image workspaces get VM fixes (ENV-STALE)
Golden source builds publish their orcad + in-VM CLI as a commit-pinned bundle (R2, uploaded by the build VM over a signed PUT; the Worker computes the stored sha256). On every boot and wake, before orcad starts and inside the existing orcad phase, a sandbox whose /opt/orca/runtime/orcad/SOURCE_COMMIT differs from its region's active golden fetches that bundle from the control plane's own host (already on the egress allowlist) with a 10-minute signed URL, verifies the sha256 the control plane passes in, checks the commit and node runtime, and swaps orcad + orca-cli atomically. Any failure keeps the old orcad and boot continues; every outcome is logged (runtime_refresh: outcome, from, to, ms). RUNTIME_REFRESH=off is the kill switch. Dev R2 bucket orca-sandbox-runtime-dev.
2026-11-11 03:21:01 -08:00
Neil 0606c25105 Merge pull request #250 from nwparker/cloud/w6-codex-broker
feat(sandbox-control): Codex account broker (contract D11, flag S2)
2026-11-10 05:49:20 -08:00
Neil a4e0b7a656 feat(sandbox-control): GitHub repo access, preselected install URLs, install requests, repository list (NP-4 N2/N3/N12, D2) 2026-11-10 05:19:44 -08:00
Neil 4af8f7fe04 feat(sandbox-control): Codex account broker (contract D11, flag S2)
Codex signs in once via the person's Orca account:
- POST /v1/agent-credentials/codex/broker starts a short-lived broker sandbox (golden image, egress
  auth.openai.com + chatgpt.com only, non-persistent, tagged orcaCodexBroker/orcaInfra so the workspace
  orphan sweep and billing never see it) running `codex login --device-auth` (Codex 0.166), and returns
  {brokerId, verificationUrl, userCode}. GET .../broker/:id -> {status: pending|active|failed}; DELETE
  cancels. On completion the Worker reads auth.json through the files API, stores the tokens
  envelope-encrypted and Personal-only in agent_credentials, and deletes the broker sandbox.
- Lease refresher (cron, every 5 min): refreshes the access token with the refresh token before expiry,
  single-flight per person (D1 lease) with a compare-and-swap write, so a refresh token is spent once and
  a delete or new login is never overwritten (no refresh_token_reused). Failures mark expiring/expired
  (by the real access-token expiry) or revoked (refresh_token_reused/invalidated). A chatgpt.com 401
  triggers a refresh instead of revoking.
- codexAccount AccountProvider: placeholder access token bound to the sandbox id (D14), swapped for the
  real one on chatgpt.com with ChatGPT-Account-Id; never in a shared workspace (D13); kill switch
  AGENT_ACCOUNTS_CODEX_DISABLED=1.
- VM: orca-sandbox-env writes a placeholder ~/.codex/auth.json (no refresh token) from
  ORCA_CODEX_AUTH_PLACEHOLDER, sets a managed HTTPS ChatGPT provider (Codex's Responses WebSocket can't
  pass the egress proxy; verified live), and sets a person's own login aside / restores it.
- Migration 0045_codex_broker (codex_broker_sessions, codex_leases; no token columns).
- Flag S2 on in wrangler.dev.jsonc; absent in prod.
2026-11-10 05:03:50 -08:00
Neil 40b33811b5 Merge pull request #242 from nwparker/cloud/w6-agent-accounts
W6: sign in once via your Orca account — Claude account store + egress-time Source (D10/D11/D13/D14)
2026-11-10 04:48:11 -08:00
Neil ae7750b7af fix(sandbox-control): re-bind the build runner Worker (step 2 of 2 after the delete-class migration) (#240) 2026-11-10 04:24:12 -08:00
Neil a25934cf64 feat(cloud): sign in once via your Orca account (contract D10/D11/D13/D14) — Claude setup-token store (Personal only, flag S1, kill switch), egress-time Source with one stable account placeholder per sandbox, never in shared workspaces; migration 0044 2026-11-10 04:22:16 -08:00
Neil 77af3b072a fix(sandbox-control): unblock dev deploy (10061): apply the build-runner delete-class migration without the binding, step 1 of 2 (#237)
* fix(sandbox-control): unblock dev deploy: apply the build-runner delete-class migration without the binding (step 1 of 2)

* test(sandbox-control): build-runner config test allows the binding-less step of the rollout
2026-11-10 04:17:03 -08:00
Neil b55b368887 fix(sandbox-control): host EnvironmentBuildRunner in its own Worker so control-plane preview URLs work (#234)
Cloudflare generates no preview URLs for a Worker that implements a Durable Object, so every
--preview-alias upload of orca-sandbox-control-dev 404ed. The runner DO moves to
orca-sandbox-build-runner-dev (wrangler.build-runner.dev.jsonc); the control plane binds it with
script_name and deletes its own class (migration env-build-runner-v2). The runner only keeps the
alarm: each step calls back into the control plane's BuildTicker RPC entrypoint, which runs the same
tickBuild with the control plane's D1, provider and secrets, so nothing is duplicated.
2026-11-10 04:08:45 -08:00
Neil d76cb62c57 fix(sandbox-control): keep preview URLs on for the dev Worker (preview aliases 404ed) (#224) 2026-11-10 03:34:07 -08:00
Neil 63b6999dee feat(cloud): pdx1 default region, iad1 fallback, golden per region; Standard = 8 vCPU / 16 GB (U17, U18) (#194)
* feat(cloud): pdx1 default region with iad1 fallback and one golden per region; Standard is 8 vCPU / 16 GB (U17, U18)

- golden_images and environment_builds record their region (0040, backfilled iad1); rotation,
  git-source builds, smoke and activation run per region; lifecycle picks the region's golden.
- New creates default to pdx1; a create with no pinned region falls back to iad1 automatically on a
  capacity/provider error (VERCEL_FALLBACK_REGIONS). Until pdx1 has an image, creates use iad1.
- Environment builds boot and smoke in their own region; workspaces from a build boot there.
- One size: Standard = 8 vCPU / 16 GB (ORCA_CLOUD_SANDBOX_SPEC). Legacy 'large' requests map to
  standard; 0040 rewrites existing large rows.

* merge cloud/integration (ORCA_CLOUD_SANDBOX_SPEC landed in #196)
2026-11-10 01:07:56 -08:00
Neil 0ca83ef860 feat(sandbox-control): dev control plane also trusts staging auth sandbox tokens
Staging sign-in now works end to end in dev without a dev operator key on the user's machine.
Same account ids as billing dev (which trusts staging already); never honored when SANDBOX_ENV=prod;
a staging key cannot pass as the prod issuer.
2026-11-10 00:46:50 -08:00
Neil f2386f9a37 feat(sandbox-control): dev-only SANDBOX_DEV_BILLING_ENFORCE_PREFIX sends one dev account prefix through the real billing gate (#166)
dev:* accounts skip billing on dev, so W9 could not test the gate (no plan refused, active allowed,
grace expiry suspends, at-cap refused) with dev tokens. Dev accounts under the configured prefix now go
to the billing Worker. Honored only when SANDBOX_ENV is exactly 'dev' and only for a specific
sub-prefix (dev:<word>- or dev:<word>:), never all dev accounts; tests cover prod/staging/test being
ignored and over-broad prefixes being rejected. Dev sets dev:billing-test-.
2026-11-09 21:07:28 -08:00
Neil e95a147837 fix(cloud): env builds progress server-side on a Durable Object alarm, not only while streamed (#118)
* fix(sandbox-control): read the orgRole claim that Orca Cloud auth mints (#29)

Auth mints the live org role as orgRole on sandbox tokens (same claim as billing
tokens, stablyai/orca-cloud#695); the verifier read org_role, so admins would
never have been recognized.

* wip(cloud): environment builds control plane

* wip(cloud): environment build boot path, staleness, routes

* wip(cloud): env build tests, anonymous staleness fallback

* wip(cloud): migration 0008 (claimed), quieter recovered clone errors

* fix(cloud): env build review: interrupted-snapshot recovery, bounded log reads, secret redaction, activation guard, hook/prelude fixes

* fix(cloud): wait briefly for the build exit code after its log ends; print the base image and package manager

* wip(desktop): org environments client, IPC, CLI, settings UI, orcad disk usage + low-disk banner

* perf(cloud): smoke-boot each environment build before activating it; skip the redundant prelude fetch

* fix(cloud): a GitHub token error fails the build as github_unavailable instead of cloning anonymously

* perf(cloud): warm pool VMs per hot environment build, so a create from an org environment skips the provider boot

* wip(desktop): cloud environment UI round-3 fixes

* fix(cloud): pool-per-build review: smoke race safety, provider hiccups skip smoke, usage-based hot builds with caps, bounded boots, index

* fix(desktop): Configure with an agent hands the prompt over at launch (trust dialog swallowed the pasted Enter); CLI builds table widths

* polish(desktop): W10 P2s — InlineError action slot, shared focus-ring, copy

* feat(cloud): build event stream heartbeat every 20 s

* fix(desktop): FE review — stable virtualizer, shadow-buffer replays, heartbeat-aware build watch, CLI follower restarts, repo import path checks, poll races

* feat(cloud): meter environment build sandbox time to the member who started it; no setup-script nudge for workspaces booted from an env build

* fix(cloud): environment builds progress server-side on a Durable Object alarm, not only while someone streams their log
2026-11-09 16:26:55 -08:00
Neil fc50ad9466 feat(cloud): per-device sender attestation (orcad orchestration.turnSender, orca sender), root-only member identities + sudo helper, sender-aware git in VMs (default on); terminal-agent sender envelope; follow teammates into chats and chat links; name claim
# Conflicts:
#	cloud/apps/sandbox-control/image/vm-scripts.generated.ts
#	src/renderer/src/components/cloud-workspaces/CloudMemberAvatars.tsx
2026-11-09 07:30:27 -08:00
Neil 777f078c76 feat(cloud): W4 team collaboration on cloud workspaces
## W4: team collaboration on Orca Cloud workspaces

### Control plane (`cloud/apps/sandbox-control`)
- **Registry** (`0024_workspace_registry.sql`, applied on dev D1): owner (reassignable), `created_by`, branch, `visibility` (private default / team), section, last activity, token spend. Reuses 0020's `name`/`archived_at`.
- **Routes under `/v1/team/*`** (W5 owns `/v1/workspaces`): list with Mine/Team/All, By, In, Archived filters; PATCH (rename, share or make private, section, archive, reassign owner); presence heartbeats; wake and lease for teammates; links resolve; org prompts/PR instructions (compare-and-set).
- **Security fix:** `/v1/sandboxes/:id` used to be account-scoped, so any org member could resume a teammate's sandbox and receive its orcad pairing code. It is now owner-only; admins can still suspend and destroy.
- **Per-member, per-device E2EE grants:**
  - The VM mints a single-device orcad offer and seals it to the requesting device's X25519 key.
  - The control plane stores only the orcad device id.
  - Revocation runs `orca pair --revoke`, which closes the device's live sockets, plus an on-disk registry removal.
  - When the VM is asleep, the revoke is queued and applied at boot before orcad starts.
  - Triggers: explicit revoke, making a workspace private, archive, reassign, member removal (internal route), and phone device-session revoke (W8).
  - VMs from older images get the entry points installed on demand.
- **Git as the sender:** a member's own GitHub user-to-server token (App OAuth, envelope-encrypted) is swapped in at egress only for the workspace repo. The VM gets per-member git configs and `orca-git-as`.
- **Cost:** metered compute × billing rate, plus optional token spend.

### orcad (generic)
- New owner-only RPC `pairing.revokeDevice` and `orca pair --revoke <device-id>`: revokes a device and closes its open connections immediately.

### Desktop
- A "Cloud workspaces" section on Home: Team/Mine, By, In and Archived filters; sections; live presence; cost; last activity. Single-click Open on a teammate workspace pairs this device through an E2EE grant. Also a row menu (share/private, move to section, reassign, archive) and copy link.
- Deep links `orca://cloud/w/<id>[/c/<chat>]` (open-url, argv, second instance, sidecar handoff) and the `cloudWorkspace.copyLink` keybinding.
- Messages to agents in shared workspaces carry a sender envelope.
- Uses the W10 shared primitives.
- Two rounds of adversarial design and frontend review.

### Evidence
Real Vercel VMs; see the W4 report. Numbers:
- grant issued in 0.55 s, paired in 1.35 s
- revoke closes the live desktop socket ~30 ms after the PATCH returns
- two members' pushes land on GitHub with their own author identities (shared dev Worker, preview alias w4); a push to another repo gets 403
2026-11-09 06:53:24 -08:00
Neil 484b999dc8 feat(sandbox-control): golden image tracks cloud/integration HEAD (orcad built from source, rebuilt when HEAD touches VM code); sshd in image (#57)
GOLDEN_IMAGE_SOURCE=git:<repo>#<branch>: each cron tick resolves the branch HEAD through the GitHub
App installation on that repo (read-only single-repo token, operator-only request surface) and, when
HEAD differs from the active image's commit and the compare touches VM paths, starts a source build:
fetch the commit, build orcad + bundled orca CLI, provision, then the existing wipe, snapshot, smoke,
atomic activate (previous image kept as rollback). The commit is recorded as bundle_sha256 git:<sha>
(kept through clone refreshes) and in /opt/orca/runtime/orcad/SOURCE_COMMIT. Also (W2): openssh-server
in the image (on demand only), https apt sources, unlocked password field for key-only sshd.
2026-11-09 06:17:08 -08:00
Neil e9f52875cd feat(sandbox-control): routines — schedule/GitHub/webhook triggers, hidden run VMs as the creator, detached headless agent runner, PR/comment posting, per-minute tick with caps, dedupe and crash recovery 2026-11-09 05:37:29 -08:00
Neil 178eaf4ec8 feat(sandbox-control): warm VM pool (SANDBOX_POOL_SIZE); idempotent resume of a running sandbox; github_not_connected before provisioning (#36)
- pool.ts: N standard VMs booted from the current golden with egress denied; create claims one atomically
  (DELETE..RETURNING), applies the caller policy + full lease in parallel, bills from the claim; cron and
  each claim refill; recycled at 20 min, on golden change, pool off or kill switch; fallback to a fresh VM.
- F1: orca-sandbox-start leaked the start-lock fd into orcad, so a second start (resume of a running
  sandbox, retried create) waited 60 s and 502'd. Children now close fd 9; the Worker also reads the
  serving orcad's ready line without the lock (fixes VMs on older images).
- F2: a github.com repo with no App token and no anonymous access fails 409 github_not_connected before
  any VM work.
2026-11-09 04:45:39 -08:00
Neil a2b91b9d47 chore(cloud): dev golden image rebuilt with the secret-store start script (#27) 2026-11-09 03:03:47 -08:00
Neil 0744798c98 fix(cloud): bind GitHub App installations to Orca accounts; kill switch, caps, rate limit; orphan sweep and retention (#24)
Security (B1): repo tokens were minted for any repo.url where the app was installed. Now an
installation must be bound to the caller's account (signed single-use connect state + OAuth proof
that the installer owns the account or is an org admin), tokens are scoped to the one repo and the
binding is re-checked on cached tokens. Operator binding route for support/dev.

Guardrails (B3/G4): D1 kill switch + static flag refuse create/resume/rollover and drain running
sandboxes; global running cap; 3/seat per-account backstop; per-account create rate limit.

Retention (B4/B6): hourly orphan sweep (stop, then delete after grace; partial listings delete
nothing), 30-day deletion after cancel/unpaid with a T-7 warning hook, 90-day idle retention,
104-day provider snapshot expiry backstop, repo_url tombstoned on destroy.
2026-11-09 02:19:25 -08:00
Neil ad6646c303 feat(cloud): org/personal/repo secret store with envelope encryption and session-start injection (#23)
D1 secrets table (migration 0003), AES-256-GCM per-secret DEK wrapped by SECRETS_KEK with
(scope, owner, name) AAD and key-id rotation; write-only /v1/secrets CRUD with org owner/admin
checks; precedence-resolved injection into orcad's env at every boot (no disk, no rebuild);
optional egress placeholder swap for api.anthropic.com / api.openai.com via the forwardURL proxy.
2026-11-09 02:19:24 -08:00
Neil 53d00d1985 fix(cloud): GitHub App setup page, dev-account billing bypass, live push results (#21)
* fix(cloud): GitHub App manifest page uses a visible submit button

* feat(cloud): dev operator accounts bypass billing outside prod; GitHub App push results
2026-11-09 02:19:24 -08:00
Neil 6130c4d793 feat(cloud): GitHub App repo tokens + billing dev wiring for the sandbox control plane (#20)
* feat(cloud): GitHub App installation tokens for sandbox git (manifest flow, minter, policy refresh)

* feat(cloud): billing dev wiring — shared control-plane token via service binding, grace-expired suspensions, standard/large only
2026-11-09 02:19:24 -08:00
Neil 018c986c34 feat(cloud): dev deployment of the sandbox control plane (dev operator keys, dev egress credential) (#17) 2026-11-09 02:19:23 -08:00