Skip to content

An open-source, faster Devin alternative

TypeScript

align cell naming

Brian Reardonf14f8a2e9b35
diff --git a/cloudflare-workers/api-edge/src/index.ts b/cloudflare-workers/api-edge/src/index.ts
index 3b4467ef..5418b444 100644
--- a/cloudflare-workers/api-edge/src/index.ts
+++ b/cloudflare-workers/api-edge/src/index.ts
@@ -145,25 +145,25 @@ function isHealthy(cell: CellRow, nowSec: number): boolean {
// Continent buckets used by distanceRank when cells span clouds. Coarse on
// purpose — we just need "near" vs "far" for the cascade. Unknown regions
// fall through to tier 3 (global).
+//
+// Region names follow the cell-id convention: AWS-style hyphenated form for
+// every cloud (e.g., Azure's westus2 is mapped to us-west-2 at provision
+// time, so the cells table never sees the cloud-native variant). One table
+// for all clouds.
const REGION_CONTINENT: Record<string, string> = {
- // Azure NA
- westus: "na", westus2: "na", westus3: "na",
- eastus: "na", eastus2: "na", centralus: "na", northcentralus: "na", southcentralus: "na",
- canadacentral: "na", canadaeast: "na",
- // Azure EU
- westeurope: "eu", northeurope: "eu", francecentral: "eu", germanywestcentral: "eu",
- uksouth: "eu", ukwest: "eu",
- // Azure APAC
- japaneast: "ap", japanwest: "ap", koreacentral: "ap",
- southeastasia: "ap", eastasia: "ap",
- australiaeast: "ap", australiasoutheast: "ap",
- // AWS NA
- "us-east-1": "na", "us-east-2": "na", "us-west-1": "na", "us-west-2": "na",
- "ca-central-1": "na",
- // AWS EU
- "eu-west-1": "eu", "eu-west-2": "eu", "eu-central-1": "eu", "eu-north-1": "eu",
- // AWS APAC
- "ap-southeast-1": "ap", "ap-southeast-2": "ap", "ap-northeast-1": "ap", "ap-northeast-2": "ap",
+ // North America
+ "us-east-1": "na", "us-east-2": "na",
+ "us-west-1": "na", "us-west-2": "na", "us-west-3": "na",
+ "us-central-1": "na", "us-north-central-1": "na", "us-south-central-1": "na",
+ "ca-central-1": "na", "ca-east-1": "na",
+ // Europe
+ "eu-west-1": "eu", "eu-west-2": "eu", "eu-west-3": "eu",
+ "eu-north-1": "eu", "eu-central-1": "eu", "eu-south-1": "eu",
+ "uk-south-1": "eu", "uk-west-1": "eu",
+ // Asia / Pacific
+ "ap-southeast-1": "ap", "ap-southeast-2": "ap",
+ "ap-northeast-1": "ap", "ap-northeast-2": "ap", "ap-northeast-3": "ap",
+ "ap-east-1": "ap", "ap-south-1": "ap",
};
// Tier distance from `a` to `b`. Lower is closer.
diff --git a/cloudflare-workers/api-edge/wrangler.toml b/cloudflare-workers/api-edge/wrangler.toml
index 56b67f0f..9ad975c2 100644
--- a/cloudflare-workers/api-edge/wrangler.toml
+++ b/cloudflare-workers/api-edge/wrangler.toml
@@ -54,4 +54,4 @@ WORKER_ENV = "dev"
# validates cell selections against this list; each cell's base_url comes from
# the D1 `cells` table (see schema.sql + scripts/seed_dev_xcell.sh).
# Cross-cell testbed: dev2 (Azure westus2) + dev3 (AWS us-east-1).
-CELLS = "azure-westus2-cell-b,aws-us-east-1-cell-a"
+CELLS = "azure-us-west-2-b,aws-us-east-1-a"
diff --git a/deploy/aws/create-aws-dev3.sh b/deploy/aws/create-aws-dev3.sh
index 93aeb4c6..c1c12ec2 100755
--- a/deploy/aws/create-aws-dev3.sh
+++ b/deploy/aws/create-aws-dev3.sh
@@ -45,7 +45,7 @@ AMI_OWNER="099720109477"
AMI_FILTER="ubuntu/images/hvm-ssd-gp3/ubuntu-noble-24.04-amd64-server-*"
# CF-cutover specifics (cell ID encodes cloud + region for clarity)
-CELL_ID="aws-us-east-1-cell-a"
+CELL_ID="aws-us-east-1-a"
CF_EVENT_ENDPOINT="https://opensandbox-events-ingest-dev.brian-124.workers.dev/ingest"
SSH_KEY="$HOME/.ssh/opensandbox-digger.pem"
diff --git a/deploy/azure/create-azure-dev2.sh b/deploy/azure/create-azure-dev2.sh
index ce972244..ed411204 100644
--- a/deploy/azure/create-azure-dev2.sh
+++ b/deploy/azure/create-azure-dev2.sh
@@ -45,7 +45,12 @@ ADMIN_USER="azureuser"
DOMAIN="dev2.opensandbox.ai"
# CF-cutover specifics — point dev2 at the global CF Workers we already deployed.
-CELL_ID="azure-westus2-cell-b"
+# Cell-id format: <cloud>-<aws-style-region>-<slot>. Azure-native region name
+# (REGION above) stays for `az` CLI calls; CELL_REGION is the normalized form
+# we store in the global cell registry + the CP/worker's runtime "region" so
+# every cell parses the same way regardless of cloud.
+CELL_ID="azure-us-west-2-b"
+CELL_REGION="us-west-2"
CF_EVENT_ENDPOINT="https://opensandbox-events-ingest-dev.brian-124.workers.dev/ingest"
# State file (separate from prod's so the two stacks never collide)
@@ -348,7 +353,7 @@ WKSETUP
set_kv server-redis-url "redis://localhost:6379"
set_kv server-jwt-secret "$JWT_SECRET"
set_kv server-api-key "$API_KEY"
- set_kv server-region "$REGION"
+ set_kv server-region "$CELL_REGION"
set_kv server-sandbox-domain "$DOMAIN"
set_kv server-cell-id "$CELL_ID"
set_kv server-cf-event-endpoint "$CF_EVENT_ENDPOINT"
@@ -360,7 +365,7 @@ WKSETUP
set_kv worker-jwt-secret "$JWT_SECRET"
set_kv worker-database-url "postgres://opensandbox:$PG_PASSWORD@$CP_PRIVATE_IP:5432/opensandbox?sslmode=disable"
set_kv worker-redis-url "redis://$CP_PRIVATE_IP:6379"
- set_kv worker-region "$REGION"
+ set_kv worker-region "$CELL_REGION"
set_kv worker-cell-id "$CELL_ID"
set_kv worker-max-capacity "10"
set_kv worker-default-sandbox-memory-mb "1024"
diff --git a/docs/dev-cutover-runbook.md b/docs/dev-cutover-runbook.md
index f7c4d8e8..2d624687 100644
--- a/docs/dev-cutover-runbook.md
+++ b/docs/dev-cutover-runbook.md
@@ -13,7 +13,7 @@ and the migration risks we expect to bite.
| Item | Value |
| --- | --- |
-| Cell ID | `azure-westus2-cell-a` |
+| Cell ID | `azure-us-west-2-a` (old dev cluster, OPENSANDBOX-PROD westus2) — current testbeds are `azure-us-west-2-b` (dev2) and `aws-us-east-1-a` (dev3) |
| Regional CP hostname | `dev.opensandbox.ai` (unchanged, DNS-only proxy off) |
| Edge Worker hostname | `app.dev.opensandbox.ai` (after DNS) — interim: `opensandbox-edge-dev.brian-124.workers.dev` |
| Events ingest hostname | `events.dev.opensandbox.ai` (after DNS) — interim: `opensandbox-events-ingest-dev.brian-124.workers.dev` |
@@ -100,7 +100,7 @@ parity has been clean for 24h+.
- [ ] CreditAccount DOs lazy-init verified (first `/check` reads from D1 `orgs.free_credits_remaining_cents`)
- [ ] Dev PG basebackup snapshot taken (point-of-no-return marker for week 5)
- [ ] Dev CP restarted with new env vars set:
- - `OPENSANDBOX_CELL_ID=azure-westus2-cell-a`
+ - `OPENSANDBOX_CELL_ID=azure-us-west-2-a`
- `OPENSANDBOX_CF_EVENT_ENDPOINT=https://opensandbox-events-ingest-dev.brian-124.workers.dev/ingest`
- `OPENSANDBOX_CF_EVENT_SECRET=<EVENT_SECRET>`
- `OPENSANDBOX_CF_ADMIN_SECRET=<CF_ADMIN_SECRET>`
diff --git a/docs/multi-cloud.md b/docs/multi-cloud.md
index b70fad6b..ca34bde1 100644
--- a/docs/multi-cloud.md
+++ b/docs/multi-cloud.md
@@ -43,14 +43,22 @@ Everything else:
## Cell ID format
-`{cloud}-{region}-cell-{slot}`, e.g.:
-- `azure-eastus2-cell-a` (production)
-- `azure-westus2-cell-b` (dev2)
-- `aws-us-east-1-cell-a` (dev3, when provisioned)
-- `gcp-us-central1-cell-a` (future)
+`{cloud}-{region}-{slot}`, with region in **AWS-style hyphenated form** for
+every cloud (Azure's `westus2` normalizes to `us-west-2`, `eastus2` to
+`us-east-2`, etc.). One parse for all clouds — no per-cloud lookup table.
+The slot is `a`/`b`/`c`/... distinguishing multiple cells in the same region.
+
+Examples:
+- `azure-us-east-2-a` (production)
+- `azure-us-west-2-b` (dev2)
+- `aws-us-east-1-a` (dev3)
+- `gcp-us-central-1-a` (future)
Cell ID is the only routing identity. Workers, events, sandboxes, all
-namespaced by `cell_id` everywhere.
+namespaced by `cell_id` everywhere. The Azure-native region name (e.g.
+`westus2`) is only used as the `--location` for `az` CLI calls during
+provisioning; the cell registry, capability tokens, and event envelopes
+see only the normalized form.
## Adding a new cloud (checklist)
diff --git a/internal/compute/pool.go b/internal/compute/pool.go
index 496824f2..b7ce0c7c 100644
--- a/internal/compute/pool.go
+++ b/internal/compute/pool.go
@@ -29,8 +29,8 @@ type MachineOpts struct {
// cloud means writing a new Pool; the CP doesn't change.
type WorkerSpec struct {
// Cell + region identity
- CellID string // "{cloud}-{region}-cell-{slot}", e.g. "azure-westus2-cell-b"
- Region string // e.g. "westus2", "us-east-1"
+ CellID string // "{cloud}-{region}-{slot}", e.g. "azure-us-west-2-b"
+ Region string // AWS-style hyphenated, e.g. "us-west-2", "us-east-1"
// Connectivity back to the control plane
DatabaseURL string
diff --git a/internal/config/config.go b/internal/config/config.go
index 08d9f11b..affcaf3e 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -131,7 +131,10 @@ type Config struct {
// Cell identity. Full deployment identifier used in Redis stream keys, event
// envelopes, and CF routing. Replaces Region for cell-aware code paths.
- // Format: "{cloud}-{region}-cell-{slot}", e.g. "azure-westus2-cell-a".
+ // Format: "{cloud}-{region}-{slot}", with region in AWS-style hyphenated
+ // form (Azure's westus2 normalizes to us-west-2) so cells parse identically
+ // across clouds. Example: "azure-us-west-2-b". The slot (a/b/c/...)
+ // distinguishes multiple cells in the same region.
CellID string
// CF events-ingest endpoint. When set, the regional control plane runs an
diff --git a/internal/controlplane/cf_event_client.go b/internal/controlplane/cf_event_client.go
index 61c6bf9a..2d9f77b7 100644
--- a/internal/controlplane/cf_event_client.go
+++ b/internal/controlplane/cf_event_client.go
@@ -18,7 +18,7 @@ import (
// events-ingest Worker.
//
// Headers:
-// - X-Cell-Id full deployment identifier (e.g. azure-westus2-cell-a)
+// - X-Cell-Id full deployment identifier (e.g. azure-us-west-2-b)
// - X-Timestamp unix seconds (used in signature, validated ±5min on the receiver)
// - X-Signature hex HMAC-SHA256(secret, fmt.Sprintf("%d.%s", timestamp, body))
//
diff --git a/scripts/seed_dev_xcell.sh b/scripts/seed_dev_xcell.sh
index 922c9d20..650ab2c9 100755
--- a/scripts/seed_dev_xcell.sh
+++ b/scripts/seed_dev_xcell.sh
@@ -27,8 +27,8 @@ DEV2_CP_URL="${1:?usage: seed_dev_xcell.sh <DEV2_CP_URL> [DEV3_CP_URL]}"
DEV3_CP_URL="${2:-http://DEV3-CP-NOT-PROVISIONED-YET:8080}"
# Fixed test fixtures — deterministic so the smoke test knows exactly what to send.
-ORG_A_ID="aaaaaaaa-0000-0000-0000-000000000001" # home_cell = azure-westus2-cell-b
-ORG_B_ID="bbbbbbbb-0000-0000-0000-000000000001" # home_cell = aws-us-east-1-cell-a
+ORG_A_ID="aaaaaaaa-0000-0000-0000-000000000001" # home_cell = azure-us-west-2-b
+ORG_B_ID="bbbbbbbb-0000-0000-0000-000000000001" # home_cell = aws-us-east-1-a
USER_ID="cccccccc-0000-0000-0000-000000000001"
KEY_A_ID="a11ce11a-0000-0000-0000-000000000001"
KEY_B_ID="b11ce11b-0000-0000-0000-000000000001"
@@ -49,9 +49,12 @@ trap 'rm -f "$SQL_FILE"' EXIT
cat > "$SQL_FILE" <<SQL
-- Cells: the two regional control planes the edge will route between.
+-- Cell-id format: <cloud>-<aws-style-region>-<slot>. Azure regions are
+-- normalized to AWS form (westus2 → us-west-2) so distance ranking has
+-- one table for all clouds.
INSERT OR REPLACE INTO cells (cell_id, cloud, region, base_url, status, created_at) VALUES
- ('azure-westus2-cell-b', 'azure', 'westus2', '${DEV2_CP_URL}', 'active', strftime('%s','now')),
- ('aws-us-east-1-cell-a', 'aws', 'us-east-1', '${DEV3_CP_URL}', 'active', strftime('%s','now'));
+ ('azure-us-west-2-b', 'azure', 'us-west-2', '${DEV2_CP_URL}', 'active', strftime('%s','now')),
+ ('aws-us-east-1-a', 'aws', 'us-east-1', '${DEV3_CP_URL}', 'active', strftime('%s','now'));
-- One user, owner of both test orgs.
INSERT OR REPLACE INTO users (id, email, name, created_at) VALUES
@@ -60,8 +63,8 @@ INSERT OR REPLACE INTO users (id, email, name, created_at) VALUES
-- Two orgs, each homed in a different cell — so a create with each org's key
-- exercises a different cell.
INSERT OR REPLACE INTO orgs (id, name, slug, plan, home_cell, is_personal, owner_user_id, created_at, updated_at) VALUES
- ('${ORG_A_ID}', 'X-Cell Test A (dev2)', 'xcell-test-a', 'pro', 'azure-westus2-cell-b', 0, '${USER_ID}', strftime('%s','now'), strftime('%s','now')),
- ('${ORG_B_ID}', 'X-Cell Test B (dev3)', 'xcell-test-b', 'pro', 'aws-us-east-1-cell-a', 0, '${USER_ID}', strftime('%s','now'), strftime('%s','now'));
+ ('${ORG_A_ID}', 'X-Cell Test A (dev2)', 'xcell-test-a', 'pro', 'azure-us-west-2-b', 0, '${USER_ID}', strftime('%s','now'), strftime('%s','now')),
+ ('${ORG_B_ID}', 'X-Cell Test B (dev3)', 'xcell-test-b', 'pro', 'aws-us-east-1-a', 0, '${USER_ID}', strftime('%s','now'), strftime('%s','now'));
INSERT OR REPLACE INTO org_memberships (org_id, user_id, role, created_at) VALUES
('${ORG_A_ID}', '${USER_ID}', 'owner', strftime('%s','now')),
@@ -74,18 +77,18 @@ INSERT OR REPLACE INTO api_keys (id, org_id, created_by, key_hash, key_prefix, n
SQL
echo "Applying seed to D1 '${D1_DB}' (remote)..."
-echo " cell azure-westus2-cell-b -> ${DEV2_CP_URL}"
-echo " cell aws-us-east-1-cell-a -> ${DEV3_CP_URL}"
+echo " cell azure-us-west-2-b -> ${DEV2_CP_URL}"
+echo " cell aws-us-east-1-a -> ${DEV3_CP_URL}"
wrangler d1 execute "$D1_DB" --remote --file "$SQL_FILE"
cat <<DONE
Seed applied. Test credentials:
- Org A (home_cell=azure-westus2-cell-b, expect sandbox on dev2):
+ Org A (home_cell=azure-us-west-2-b, expect sandbox on dev2):
X-API-Key: ${KEY_A_PLAINTEXT}
- Org B (home_cell=aws-us-east-1-cell-a, expect sandbox on dev3):
+ Org B (home_cell=aws-us-east-1-a, expect sandbox on dev3):
X-API-Key: ${KEY_B_PLAINTEXT}
If dev3 isn't provisioned yet, re-run this with its real CP URL once it is: