Files
orca/cloud/apps
Neil 44595111e2 fix(sandbox-control): a retried sandbox command never runs twice (agent messages, launches)
Vercel's command POST has no idempotency key, so a retry after a lost answer (dropped connection, gateway
5xx, a Worker that died mid-request) can start the command again (vercel/sandbox#363). Message delivery
did exactly that: a transient failure re-queued the message and the cron typed it into the agent again,
or launched a second agent.

- command-once.ts: an in-VM guard with a per-id ledger (mkdir claim, recorded exit + output). A repeat of
  the same id waits for and replays the first run; a dead first run reports an unknown outcome; a failed
  run is forgotten so a retry runs for real. runCommandOnce retries uncertain provider failures with the
  same id (never a 4xx that proves the command did not start).
- deliverMessage uses msg-<id> for send/launch; an unknown outcome fails the message
  (delivery_outcome_unknown) instead of re-sending.
- POST /messages and POST /sessions take Idempotency-Key (same semantics as workspace create); a session
  create taking over a died attempt replays the first launch.
- The REST client keeps sending each command POST exactly once (test).
2026-11-14 20:57:30 -08:00
..