# Deployment One image (`Dockerfile`: a web build stage, then a Python 3.13 runtime with Node 22 and Chromium, running as a non-root user under tini), two shapes: | Shape | What it runs | Guide | |---|---|---| | **Hugging Face Space** (Docker) + remote browser runner + storage bucket | The running system: Fusion cycles, Agent Studio, the practice pod. Data is saved as an encrypted snapshot to OCI Object Storage or Supabase Storage. | this page, [REMOTE_RUNNER.md](REMOTE_RUNNER.md) | | Docker Compose with Caddy (HTTPS) and Temporal, data on volumes | The practice pod only. **Fusion pods do not run in this shape today**: the Temporal execute activity (`coworker/workflows/activities.py`) starts the local practice pod and has no remote runner, per-area test users or pre-flight. | [deploy/DEPLOY.md](../deploy/DEPLOY.md) | ## Environments Dev, staging and production differ only in settings, never in code: | Setting | Development | Staging / production | |---|---|---| | `FPT_COOKIE_SECURE` | `auto` | `always` | | `FPT_TRUST_PROXY` | `0` | `1` behind a proxy | | `FPT_CORS_ORIGINS` | the Vite dev server | `[]` | | `FPT_API_DOCS` | `1` | `0` | | `FPT_REGISTRATION` / `FPT_REGISTER_ROLE` | as needed | `0`, or `viewer` | | `OCI_STATE_PAR_URL` or `SUPABASE_BUCKET` | own bucket | one bucket per environment, never shared | | `FPT_REMOTE_RUNNER_URL` | none (local browser) | one runner per environment | | `FPT_ENVIRONMENT` | `development` | `staging` / `production` (labels error reports) | Use one Space per environment. Promote by deploying the same commit. ## Hugging Face Space The repository root is the Space: `README.md` front matter sets `sdk: docker` and `app_port: 8800`, and the `Dockerfile` carries the Space settings (viewer sign-ups, trusted proxy, no CORS, docs off, public URL). 1. Space **variables**: - `FRONTIER_BASE_URL`, `FRONTIER_MODEL`, `FPT_ADMIN_EMAILS`, `SUPABASE_URL` (sign-in); - `FPT_FUSION_BASE_URL`, `FPT_FUSION_NAME`, `FPT_FUSION_MODULES`, `FPT_FUSION_RELEASE`; - `FPT_FUSION_AREA_USERS` (JSON, the test user per area, for example `{"PO": "prc_impl"}`; same password) and `FPT_FUSION_WORKERS` (browsers at once on the runner, 1 to 4; default 3); - `FPT_REMOTE_RUNNER_URL` (`https://`), `FPT_BROWSER_RUNS=1`, `FPT_BROWSER_SLOWMO_MS`. 2. Space **secrets**: - `FPT_BOOTSTRAP_ADMIN_USER`, `FPT_BOOTSTRAP_ADMIN_PASSWORD`; - `FPT_STATE_KEY`, the snapshot key (required with OCI, which has no service key to derive one from); - `OCI_STATE_PAR_URL`, the bucket's pre-authenticated request URL (or Supabase Storage, below); - `SUPABASE_ANON_KEY`, `SUPABASE_SERVICE_KEY` (sign-in, and the Supabase store); - `FPT_SECRET_FRONTIER_API_KEY`, `FPT_SECRET_FUSION_USERNAME`, `FPT_SECRET_FUSION_PASSWORD`, `FPT_SECRET_REMOTE_RUNNER_TOKEN`; - optionally `FPT_SECRET_METRICS_TOKEN`, `SENTRY_DSN`. Variables are public on a public Space; anything secret must be a secret. 3. Deploy (next section). The Space builds the image and starts it. 4. Check: `https://.hf.space/api/ready` answers `"ready": true`; sign in; Test environments > Test connection on the Fusion pod shows all three checks. ### Every deploy or restart A Space deploy or restart stops the container. A test run that is running is interrupted, and anything changed since the last save is lost unless it is saved first. 1. **Check that nothing is running.** In the app, Home and Test runs show no run in progress and no pod card shows its screens being read. Or: `GET /api/runs?status=running` and `GET /api/runs?status=queued` return no items, and the runner's `GET https:///healthz` shows `"busy": false`. Wait, or cancel, before going on. 2. **Save the state** and wait for the answer: `POST /api/storage/save` (administrator). It answers `{"saved", "last_saved_at", "bytes"}`; 502 when the save failed, 409 when this server does not save its state. 3. **Deploy**: upload the repository contents, or push to the Space's git remote. 4. **Update the runner** on the same commit: `deploy/runner/sync.sh https://` ([REMOTE_RUNNER.md](REMOTE_RUNNER.md)). Pre-flight stops a Fusion run when the runner has no scenario files. 5. **Check**: `/api/ready`; Settings > Storage and backups shows a save after the start; the runner's `/healthz` shows the deployed commit as `version` and `"cases": true`. **Rollback**: every upload is a commit in the Space repository. Re-upload the previous revision (or revert it in the Space's Files tab), then run `sync.sh` on that commit. The data is untouched because it lives in the bucket. ## Database migrations SQL files in `coworker/platform/migrations/` are applied in order by `python -m coworker setup`, which the container runs at every start. They are forward-only and additive (new tables and columns). To roll back a release that added a migration: restore the snapshot taken before the upgrade (RUNBOOK "Restore"), then deploy the previous image. ## Backups **Space (no disk).** `platform/statesync.py` saves an encrypted archive of `FPT_HOME` (databases, vault, runs, evidence, tickets, screens, library) as `state/latest.bin` in the bucket, with `state/meta.json` beside it. | Store | Settings | |---|---| | OCI Object Storage | `OCI_STATE_PAR_URL`: a pre-authenticated request on one private bucket, access "read and write objects", listing denied (`https://objectstorage..oraclecloud.com/p//n//b//o/`). Used when set. `FPT_STATE_KEY` is required. | | Supabase Storage | `SUPABASE_URL`, `SUPABASE_SERVICE_KEY`, `SUPABASE_BUCKET`. The key is `FPT_STATE_KEY`, or is derived from the service key when that is not set. | When it saves: - every `FPT_STATE_SYNC_INTERVAL` seconds (default 60) when the databases changed; at least every 300 s on OCI (the Always Free tier allows 50,000 requests a month), at least every 10 s on Supabase; - at once when a screen read finishes, a run waits for a person, a run ends, or a run is cancelled; - on shutdown (a forced save, after a running run has stopped at its next step, waiting at most `FPT_SHUTDOWN_RUN_WAIT_S`, default 20 s); - on `POST /api/storage/save`, and with `python -m coworker state push`. A save costs four requests: GET `state/meta.json` (the generation check), PUT `state/history/