Commit Graph
23501 Commits
Author SHA1 Message Date
Neil 5feaf7df7c Merge pull request #801 from nwparker/cloud/no-cross-request-promises
fix(cloud): WORKER-XREQ-PROMISE module caches hold settled values, never another request's in-flight promise
2026-11-15 14:22:50 -08:00
Neil fc5c502bb5 fix(cloud): WORKER-XREQ-PROMISE module caches hold settled values, never another request's in-flight promise
Egress proxy secret routes (custom-base-URL keys, OPENAI_BASE_URL) hung until the client gave up
(dev, proxy mode, 2026-11-15). The Worker was invoked (tail: `canceled`, wall 65 s, CPU 3 ms, no log
line) and was waiting, never reaching its upstream fetch. GitHub routes on the same sandbox answered.

An isolate serves many requests, and a promise one request starts is bound to that request's I/O. If
that request is cancelled while the promise waits on D1, KMS or fetch, the promise never settles, and
every later request awaiting the same cached promise hangs. Several module-level caches shared
in-flight promises: the KMS keyring (forever, per isolate), decrypted provider keys and account
credentials (per minute), the relay's ID token mint, the App's pending-request owners, create timing
and share-link lookups.

They now cache settled values only (settled-cache.ts and the same pattern inline). A request that
misses loads for itself; a cold isolate may run a few duplicate loads.
2026-11-15 14:20:14 -08:00
Neil cd778ffc80 Merge pull request #800 from nwparker/cloud/egress-probe-modes
ci(cloud): egress probe in proxy and firewall modes (streams, uploads, WS, git, latency)
2026-11-15 13:57:15 -08:00
Neil da7fa7e164 Merge pull request #799 from nwparker/cloud/egress-review-fixes
fix(cloud): EGRESS review F1–F3 before any firewall canary
2026-11-15 13:54:44 -08:00
Neil 46a1c8d79f ci(cloud): egress probe in proxy and firewall modes, with streams, uploads, WebSocket, git and latency
Workstream C of the egress migration. `scripts/egress-probe.ts --mode proxy|firewall|both` flips the
same two dev workspaces with the operator egress-mode route and runs every check in each mode. Each
request is a Node fetch (undici, like the agents) with a 30 s limit, so the transform body hang shows
up as a named failure. New coverage:
- a chunked stream, a 1 MB upload and a WebSocket upgrade through the swap;
- a placeholder sent to an unrelated host must arrive unswapped;
- the WebSocket host fails closed;
- the LFS batch API, git fetch, push and delete;
- the App-repo clone through the desktop's create.
Latency is reported per class (median/p90). The terminal wait is now 15 min, and a project whose
clone failed is registered as a folder, so the checks still run.

On dev at 2cc12610 (A2+A3), firewall mode passes 22/22. Proxy-mode findings went to gh-access.
2026-11-15 13:54:30 -08:00
Neil 99ae1d0be7 fix(cloud): EGRESS review F1–F3 before any firewall canary
Security review of A1/A2 (egress-docs):
- F1: the Copilot PAT never reaches the firewall. Eligibility is decided per secret
  (firewallEligibleSecret): no credential the proxy narrows on any host (response filtering,
  paths, per-host paths). Before, its Copilot API host entries had no paths and compiled to
  transforms, putting a user's GitHub PAT in the policy store.
- F2: claims are ordered but landed writes weren't. After a write, if a newer generation was
  claimed meanwhile, the write is redone from current state, so a stale compile (say from before a
  share) is never the last to land.
- F3: a config-hash change fails closed only when it removes access or custody (firewall to proxy,
  a firewall class removed, an account provider turned off, open to limited). Anything else retries
  via policy_stale_at, so a deploy during a provider blip can't sleep every workspace. The stamp now
  carries the deciding inputs; a pre-F3 bare-hash stamp is retried.
2026-11-15 13:32:38 -08:00
Neil 1d93777378 Merge pull request #798 from nwparker/cloud/egress-firewall-a3
feat(cloud): EGRESS firewall mode puts every Codex call on the firewall (no relay)
2026-11-15 13:28:57 -08:00
Neil 9d2210f681 Merge pull request #797 from nwparker/cloud/codex-swap-off-dev
chore(cloud): CODEX-FIREWALL-SWAP off on dev until the transform-hijack probe passes
2026-11-15 13:26:24 -08:00
Neil b96f01598a feat(cloud): EGRESS firewall mode puts every Codex call on the firewall (no relay)
Egress firewall migration, workstream A3 (design §1). In EGRESS_SWAP_MODE=firewall the Codex account
token is swapped at the firewall on every Codex path, exact paths only (the hot calls plus the
catalog GETs); anything else with the placeholder gets the 403. Nothing forwards to the egress proxy,
so the ChatGPT relay is unused for these sandboxes.

Codex's own refresh of its placeholder login (POST auth.openai.com/oauth/token) is answered by the
firewall itself with the placeholder login again; the real token is refreshed centrally on schedule.
The #776 alias (CODEX_EGRESS_SWAP=firewall in proxy mode) is unchanged: hot paths at the firewall,
the rest through the proxy.
2026-11-15 13:22:57 -08:00
Neil 7df451ae3a Merge pull request #796 from nwparker/cloud/egress-firewall-a2
feat(cloud): EGRESS firewall mode for model keys, the Claude sign-in and the GitHub App token
2026-11-15 13:22:40 -08:00
Neil 0280b1732f chore(cloud): CODEX-FIREWALL-SWAP off on dev until the transform-hijack probe passes
A real ChatGPT token is stored on dev; the firewall swap stays off (proxy + relay) until the
Host/SNI binding probe shows a transform can't be reached through another destination.
2026-11-15 13:19:37 -08:00
Neil 1089e9abe7 Merge pull request #793 from nwparker/cloud/clone-dup-extraheader
fix(cloud): a background clone sends one Authorization header, not two
2026-11-15 13:16:32 -08:00
Neil 646df8839f feat(cloud): EGRESS firewall mode for model keys, the Claude sign-in and the GitHub App token
Egress firewall migration, workstream A2 (design §1, §3, §4, §7 of
.context/cloud/reports/egress-firewall-migration.md). Behind EGRESS_SWAP_MODE=firewall (per sandbox:
sandboxes.egress_swap_mode); proxy mode is unchanged.

- Firewall mode compiles the real values into the sandbox policy: model keys (every header form the
  client sends, mapped to the same form of the key), the Claude sign-in, and the GitHub App token
  (git Basic on github.com, Bearer/token on api.github.com). The 403 rule still ends every
  credential host.
- Fail closed: a key no longer usable, or an account that no longer applies (signed out, revoked,
  owner changed, shared, provider off), is answered by the firewall itself (provider-shaped
  signed-out body, or the keys-withheld body), never forwarded with its placeholder.
- Stays on the egress proxy: Cursor's key exchange (W1: the reply is filtered), the Copilot PAT on
  api.github.com (W2: a prefix scope can't be pinned at the firewall), member identities (W3).
- EGRESS_FIREWALL_CLASSES narrows the classes (model_key, claude, codex, github_app); a removed
  class goes back to the proxy.
- policy_config_hash: each apply stamps a hash of the operator inputs; reconcile re-applies a
  running sandbox whose hash differs (a kill switch reaches every live policy within one tick) or
  whose last write failed (policy_stale_at).
- In firewall mode an env refresh always applies the policy (a key edited in place, a share).
- POST /v1/internal/sandboxes/:id/egress-mode {mode: proxy|firewall|null}: one sandbox's mode,
  applied at once (leaving the firewall fails closed).
2026-11-15 13:14:54 -08:00
Neil e8e8a9c651 Merge pull request #795 from nwparker/cloud/egress-compile
refactor(cloud): EGRESS-COMPILE every live policy write goes through applySandboxPolicy
2026-11-15 13:13:47 -08:00
Neil d96bd810a5 Merge pull request #794 from nwparker/cloud/create-gh-live-apply
feat(cloud): CREATE-GH-STEP wizard applies a mid-create grant live (on #771)
2026-11-15 13:11:37 -08:00
Neil 053e4bad38 fix(cloud): a background clone sends one Authorization header, not two
The desktop's create (clone-progress) runs the workspace clone detached. orca-sandbox-start then writes
the same extraheader into ~/.gitconfig, and http.<url>.extraheader is a list. So the clone's later
requests (the blobless clone's checkout fetch, and the retry clone) carried Authorization twice. The
firewall answered 400 and nothing reached the egress proxy. The clone failed with "could not fetch
... from promisor remote", and an App-installed private repo opened empty.

Reproduced on dev: `git -c extraheader=<A> ls-remote` with the global header set gives 400, and with
`-c extraheader=` first it gives rc 0. The prelude's git auth now clears the list before adding its
header. Worker-only (the prelude ships per create), so the VM scripts stamp is unchanged. Found by the
egress probe, after #790 fixed the proxy side.
2026-11-15 13:05:20 -08:00
Neil fc5bf21604 refactor(cloud): EGRESS-COMPILE every live policy write goes through applySandboxPolicy
Egress firewall migration, workstream A1 (design: .context/cloud/reports/egress-firewall-migration.md
§2, §7). No behaviour change in proxy mode.

- compileSandboxPolicy(deps, row): the whole policy from current state (git token, member
  identities, firewall account tokens, keys). A pure read of credentials.
- applySandboxPolicy(deps, row, reason): the one live writer. Serialised per sandbox in the isolate
  and ordered across isolates by sandboxes.policy_generation (compare-and-swap): an older compile
  never lands over a newer one. 3 tries; a failed widening write marks policy_stale_at (reconcile
  retries); a failed narrowing write (revoke, share, uninstall, kill switch, ...) sleeps the
  sandbox so a real credential is never left live. Logs the provider code only.
- refreshGitCredentials, env refresh, egress hosts and the Codex refresh push all go through it;
  rewriteLivePolicy stays as a deprecated alias.
- EGRESS_SWAP_MODE + sandboxes.egress_swap_mode with egressSwapModeFor(deps, row); firewall mode
  implies the Codex firewall swap (CODEX_EGRESS_SWAP becomes an alias).
- Migration 0065: policy_generation, policy_stale_at, egress_swap_mode, policy_config_hash.
- The Codex refresh push no longer logs String(error).
2026-11-15 13:05:08 -08:00
Neil eedd261136 Merge pull request #776 from nwparker/cloud/codex-firewall-swap
feat(cloud): CODEX-FIREWALL-SWAP Codex's hot calls swap at the sandbox firewall
2026-11-15 13:04:19 -08:00
Neil ef2bdb7747 feat(cloud): CREATE-GH-STEP a grant during create reaches the sandbox before Open (live refresh by environment or sandbox id)
The wizard's applyCloudGitHubAccessToSandbox stub now calls #771's live refresh. Its IPC also
resolves the sandbox by the create's server environment (owned runtime record) or a GitHub-only
create's sandbox id (validated shape; the control plane's owner check is the guard), since the
create has no sidebar workspace yet.
2026-11-15 12:59:03 -08:00
Neil f0e2d41d17 Merge remote-tracking branch 'private/cloud/integration' into cloud/codex-firewall-swap
# Conflicts:
#	cloud/apps/sandbox-control/src/index.ts
#	cloud/apps/sandbox-control/src/lifecycle.ts
2026-11-15 12:57:31 -08:00
Neil 6b25d9702f Merge pull request #771 from nwparker/cloud/live-git-access
fix(cloud): LIVE-GIT-ACCESS a GitHub App install reaches a running workspace without a restart
2026-11-15 12:56:42 -08:00
Neil 43f771f217 Merge pull request #790 from nwparker/cloud/egress-proxy-booting
fix(sandbox-control): CLONE-BEFORE-RUNNING the egress proxy serves a booting VM its own routes
2026-11-15 12:47:41 -08:00
Neil 689a547069 fix(sandbox-control): CLONE-BEFORE-RUNNING the egress proxy serves a booting VM its own routes
A fresh workspace on an App-installed private repo opened empty. Its clone runs before the control
plane records the row running (the create's prelude, or the background clone right after ready). The
egress proxy refused every row that wasn't `running`, so github.com's forwarded git got
`remote: sandbox_not_running` (403). A wake's git before its running claim hit the same refusal.
Found by the dev egress probe (#786).

The proxy now serves `creating` and `resuming` rows as well as `running`. Only the sandbox that
Vercel's OIDC token names gets them, and only that row's routes. Suspending, suspended, archived,
destroying, destroyed and failed rows are still refused. Tests cover each state, the create-time
clone and the wake-time git before the claim, and a booting VM presenting another sandbox's
placeholder.
2026-11-15 12:43:35 -08:00
Neil e00dab0808 Merge remote-tracking branch 'private/cloud/integration' into cloud/codex-firewall-swap
# Conflicts:
#	cloud/apps/sandbox-control/image/vm-scripts.generated.ts
2026-11-15 12:42:55 -08:00
Neil c272bc2ca4 Merge remote-tracking branch 'private/cloud/integration' into cloud/live-git-access 2026-11-15 12:42:00 -08:00
Neil 19e501d749 Merge pull request #786 from nwparker/cloud/boot-twice-ci
ci(cloud): boot-twice image check and a dev egress release probe
2026-11-15 12:41:35 -08:00
Neil 0f40137bb9 Merge pull request #788 from nwparker/cloud/memguard-prompt-banner
feat(cloud): guard-kill banner follows the kill (focus/typing status refresh)
2026-11-15 04:12:27 -08:00
Neil ddbc12131e ci(cloud): egress probe through the control plane and orca CLI; boot-twice premerge step
The egress probe now needs no Vercel token. It uses dev workspaces with a dev-JWK user, runs its
commands in a workspace terminal through the shipped orca CLI's pairing code, and uses
postman-echo.com as the echo host for bogus keys. It covers the custom-base-URL swap,
chatgpt.com through the relay, api.github.com, #758 anonymous git and the App repo clone.
Premerge runs boot-twice-check.sh for image/** changes. The step has its own omarchy slot and
a 10 min limit, and fails open with a warning without Docker.
2026-11-15 04:09:58 -08:00
Neil 1117d3a9b6 ci(cloud): boot-twice image check and a dev egress release probe
Boot-twice (image/boot-twice/): provisions the golden image in a container with the real
provision-golden.sh, then boots the same disk twice through the control plane's own boot steps
(entry-point probe, startOrcad with the workspace prelude, ensureEntryPoints). Each start is a new
kernel boot id. The second boot runs offline behind a DNS sink, and must install, fetch and redo
nothing (docker diff allowlist, logged lookups, sampled command lines). It must come up, carry
this tree's entry points and stamp, and match every manifest version pin. ~15 s cached, ~5 min
cold. It catches the pre-#781 OpenCode first run that repeated on every wake.
Workflow: cloud-vm-boot-twice.yml (PRs touching image/**, GHA layer cache).

Egress probe (scripts/egress-probe.ts): against dev, with bogus tokens and an echo sandbox.
Firewall layer: egressPolicy()'s real policy forwards placeholders for chatgpt.com,
api.anthropic.com, api.github.com and github.com with other auth headers untouched. Credential
hosts fail closed, and anonymous git works without an App token (#758). Swap layer: the dev egress
proxy swaps a bogus ANTHROPIC_API_KEY in for its placeholder on a custom base URL, and leaks no
Vercel hop headers. Workflow: cloud-egress-probe.yml (dispatch + nightly; skips without secrets).

Fix found by the harness: provision-golden.sh linked a release bundle's runtimes dir, and every
VM script's `find .../runtimes -type f` skips a symlinked start point, so --release goldens had
no node. Move the tree instead. No entry-point change (stamp unchanged).
2026-11-15 04:09:57 -08:00
Neil 49d0f0baf5 Merge pull request #784 from nwparker/cloud/opencode-seed-fallback
fix(cloud): OpenCode first run falls back to the plugin-aware install without the seed
2026-11-15 04:09:38 -08:00
Neil 4b7ab8bcb9 merge cloud/integration; regenerate VM scripts 2026-11-15 04:06:25 -08:00
Neil 249f81ceef refactor(cloud): drop the renderer's own guard-kill notice; main's OOM tracker already observes every status read 2026-11-15 04:05:47 -08:00
Neil 4cd19efcfd feat(cloud): guard-kill banner follows the kill: any status read raises it; focus or typing re-reads the active cloud workspace
MEMGUARD follow-up. orca-memguard already rewrites its state file at the kill, so the next metrics
probe carries it; the desktop now asks sooner and acts on the first read that shows it.
- Any status read (panel poll, row mount, wake) that shows a newer guard kill raises the notice
  directly, with the same count main's OOM tracker uses, so a dismissal holds for both.
- Window focus or a keydown re-reads the active running cloud workspace, at most once per 15 s.
2026-11-15 04:02:54 -08:00
Neil ee7fba26e2 Merge pull request #787 from nwparker/cloud/create-step-watch
chore(sandbox-control): name the step a stuck create waits in
2026-11-15 04:00:53 -08:00
Neil f75ab574eb Merge pull request #780 from nwparker/cloud/vm-memory-guard
feat(cloud): VM memory guard, /dev/shm at half of RAM, memory-pressure signal
2026-11-15 03:58:07 -08:00
Neil de49dd979f chore(sandbox-control): log the step a create waits in before it starts (CREATE-STEP-WATCH) 2026-11-15 03:50:45 -08:00
Neil 5a0927a2d4 Merge remote-tracking branch 'private/cloud/integration' into cloud/vm-memory-guard
# Conflicts:
#	cloud/apps/sandbox-control/image/vm-scripts.generated.ts
2026-11-15 03:49:16 -08:00
Neil 4939c2c878 Merge pull request #785 from nwparker/cloud/in-vm-signin-followups
feat(cloud): sign in inside the workspace: Claude's own sign-in screens, chat sign-in state, keys copy
2026-11-15 03:37:40 -08:00
Neil 5681f9499f Merge remote-tracking branch 'private/cloud/integration' into cloud/vm-memory-guard
# Conflicts:
#	cloud/apps/sandbox-control/image/vm-scripts.generated.ts
2026-11-15 03:34:17 -08:00
Neil 12389ecdbf feat(cloud): signing in inside the workspace opens on the agent's own sign-in, in terminals and chats
- sandbox-control: an agent the person signs in inside each workspace gets mode 'inside' (keys
  dropped as before) and the session env carries ORCA_SIGN_IN_INSIDE=<agents> (ORCA_*: never in
  shells). The VM env script then leaves Claude's first-run onboarding unmarked while there is no
  login in the workspace, so Claude opens on its own sign-in screens instead of 'Not logged in';
  once ~/.claude/.credentials.json exists it is marked as usual. No golden rotation: the env
  script reaches older snapshots through the boot-time entry-point refresh.
- Structured chats: a 'not signed in' verdict or start failure for such an agent reads
  '{{agent}} needs you to sign in inside this workspace' with 'Open terminal to sign in', which
  opens a terminal tab on the workspace running the agent's login (claude auth login, codex login
  --device-auth), instead of the Orca-account Renew advice.
- Copy: the choice's detail adds 'Team API keys won't be used for this agent.' (strip, Settings
  row, and the Settings button's tooltip).
2026-11-15 03:29:37 -08:00
Neil db9691e4a6 fix(cloud): boots from snapshots without the OpenCode seed keep the plugin-aware first run 2026-11-15 03:26:27 -08:00
Neil 5fe6f01f24 Merge pull request #781 from nwparker/cloud/opencode-seeded-deps
perf(cloud): seed OpenCode's config-dir install from the image
2026-11-15 03:24:33 -08:00
Neil c4a65079df Merge pull request #782 from nwparker/cloud/agent-still-starting
feat(terminal): "Still starting <agent>…" past 10 s
2026-11-15 03:18:06 -08:00
Neil 5e245104e9 refactor(cloud): VM metrics and memory wire schemas in their own module (wire file size limit) 2026-11-15 03:16:59 -08:00
Neil 8f32582e36 feat(terminal): the agent starting overlay says "Still starting <agent>…" past 10 s 2026-11-15 03:14:19 -08:00
Neil fea70d5b9b Merge pull request #779 from nwparker/cloud/in-vm-signin
feat(cloud): sign in inside the workspace (per agent, Orca stores nothing)
2026-11-15 03:14:13 -08:00
Neil 10e26123c6 fix(cloud): memguard desktop pieces under file-size limits; catalog keys 2026-11-15 03:13:40 -08:00
Neil 554bf8fd98 perf(cloud): the image carries OpenCode's config-dir install; a fresh home gets a copy, so the first launch never fetches 2026-11-15 03:10:34 -08:00
Neil d1bdfc909b feat(cloud): VM memory guard, /dev/shm at half of RAM, and a memory-pressure signal
MEMGUARD. A build or test that eats a cloud VM's memory now costs that process, not the workspace.

- orca-memguard (new VM entry point, root via sudo from orca-sandbox-start): ranks processes for the
  kernel OOM killer (Orca runtime -900, terminal shells and agent CLIs -500, everything else 500),
  stops the largest unprotected process when MemAvailable drops under 8% and records it, adds 2 GiB
  swap files on demand (up to 1.5x RAM) and drops them after 10 quiet minutes, and remounts /dev/shm
  at 50% of RAM (the provider mounts 64 MB). Reaches old snapshots through the entry-point refresh.
- orca-sandbox-drain releases on-demand swap before a stop so it doesn't ride the snapshot.
- Status read: the VM metrics probe reads the guard's state; status gains an optional memory
  {pressure, guardKills, lastGuardVictim, ...} (metrics keeps its strict shape for older desktops).
- Desktop: guard kills count in the OOM tracker and show 'Orca stopped <process> to keep the
  workspace responsive' with a Machine size action; the sidebar row gets a quiet memory mark under
  pressure (amber when critical).
2026-11-15 03:09:39 -08:00
Neil 3e427dc6e1 chore(sandbox-control): agent_sources migration is 0063 (0062 is taken) 2026-11-15 03:00:14 -08:00