Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

docs(event): the one-page live-ops sheet, and hold the world server's capacity floor

nirholaseb85b51af31a
diff --git a/docs/event-readiness/LIVE-OPS.md b/docs/event-readiness/LIVE-OPS.md
new file mode 100644
index 000000000..40399eb96
--- /dev/null
+++ b/docs/event-readiness/LIVE-OPS.md
@@ -0,0 +1,243 @@
+# LIVE-OPS: $THREE Community Day
+
+One page. Everything an operator needs while the event is running, and nothing else.
+Prepared 2026-08-08. Project `aerial-vehicle-466722-p5`, region `us-central1`.
+
+---
+
+## The link and the release
+
+**Event URL** (the canonical $THREE world, from [README.md](README.md)):
+
+```
+https://three.ws/play?coin=FeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump&name=three.ws&symbol=three&image=%2Fapi%2Fimg%3Furl%3Dhttps%253A%252F%252Fipfs.io%252Fipfs%252Fbafybeihe22b5sxr3ihnxt7pregfieyteqvubqhik3j3y4bbx243xlqjw3q%26seed%3DFeMbDoX7R1Psc4GEcvJdsbNbZA3bfztcyDCatJVJpump
+```
+
+**Live release as of this writing:** `c1e600a04` on revision `three-ws-api-00364-n65`.
+The world server runs an image built 2026-08-06 (revision `three-ws-multiplayer-00010-g89`).
+
+> The release SHA above is NOT the event build. The event features (quest line,
+> photo mode, live event board, `/event` landing page, operator announce, the
+> `/population` endpoints) are committed but unshipped. See
+> [Ship the release](#ship-the-release-owner-gated) at the bottom. Confirm the SHA
+> with `curl -s https://three.ws/api/version` after the deploy and update this line.
+
+---
+
+## Health: three commands that prove the site is up
+
+```bash
+# 1. API alive, and which build is actually serving
+curl -s https://three.ws/api/version
+
+# 2. API subsystems (x402, monitor, speech, alerts) - status must be "ok"
+curl -s https://three.ws/api/healthz | head -c 400
+
+# 3. The world server itself. If this is not {"ok":true}, /play is dead
+# no matter what the site says.
+curl -s https://three-ws-multiplayer-93741856042.us-central1.run.app/health
+```
+
+Continuous version, one terminal, quiet unless something changes:
+
+```bash
+npm run event:watch # every 30s
+npm run event:watch -- --interval 15 # tighter during the opening rush
+npm run event:watch -- --once # single sweep; exit 1 if anything is down
+```
+
+It watches the API, the live release SHA, the `/play` page (including that the
+game bootstrap is still in the HTML), the world server, and the live player
+count. It is plain HTTPS on purpose: it keeps working when `gcloud` auth has
+expired, which it does on its own schedule in this environment.
+
+---
+
+## Logs: two commands for fast triage
+
+```bash
+export PATH="$HOME/google-cloud-sdk/bin:$PATH"
+
+# Errors across the whole fleet, last 6h
+npm run logs:errors
+
+# The world server specifically - join refusals, origin rejections, room churn
+gcloud logging read 'resource.type="cloud_run_revision"
+ resource.labels.service_name="three-ws-multiplayer" severity>=WARNING' \
+ --freshness=1h --limit=50 --project aerial-vehicle-466722-p5
+```
+
+Deeper sweep when the cause is not obvious: `npm run triage:gcp:deep`.
+
+---
+
+## Rollback: pre-filled, per service
+
+**These three revisions are the known-good pre-event state.** They are live right
+now and all report Ready. After tomorrow's release deploy creates new revisions,
+these are what you roll back TO.
+
+```bash
+export PATH="$HOME/google-cloud-sdk/bin:$PATH"
+R="--region us-central1 --project aerial-vehicle-466722-p5"
+
+# API + frontend
+gcloud run services update-traffic three-ws-api $R \
+ --to-revisions=three-ws-api-00364-n65=100
+
+# The /play world server (kicks everyone in-world; they auto-reconnect)
+gcloud run services update-traffic three-ws-multiplayer $R \
+ --to-revisions=three-ws-multiplayer-00010-g89=100
+
+# Redis proxy (presence, durable builds)
+gcloud run services update-traffic three-ws-redis-proxy $R \
+ --to-revisions=three-ws-redis-proxy-00004-bwk=100
+```
+
+Then purge the edge or the CDN keeps serving the bad build:
+
+```bash
+npm run deploy:gcp:purge-cdn
+```
+
+Return to normal afterwards with `--to-latest` instead of `--to-revisions`.
+
+**Rehearsal result (2026-08-08):** every target above exists and reports
+`Ready=True` with 100% of traffic. Traffic was not actually shifted, because
+shifting it and back is itself two world-server restarts on the eve of the event;
+the commands are the same `update-traffic` calls that created the current
+routing, and the revisions are the ones already serving.
+
+---
+
+## Scale: what is set, and how to raise it
+
+Pre-scaled 2026-08-08 (config-only, pre-approved per
+[docs/ops/gcp-credits-plan.md](../ops/gcp-credits-plan.md)):
+
+| Service | min | max | concurrency | CPU / memory | changed from |
+|---|---|---|---|---|---|
+| `three-ws-api` | **6** | 100 | 160 | 2 / 4Gi | min was 2 |
+| `three-ws-multiplayer` | 1 | **1 (hard)** | 1000 | **4 / 8Gi** | was 2 CPU / 4Gi |
+| `three-ws-redis-proxy` | **3** | **10** | 80 | default | was min 2 / max 4 |
+
+```bash
+export PATH="$HOME/google-cloud-sdk/bin:$PATH"
+R="--region us-central1 --project aerial-vehicle-466722-p5"
+
+# More API headroom (safe, instant)
+gcloud run services update three-ws-api $R --min-instances=12 --max-instances=200
+
+# More world-server headroom. NOTE: raise CPU/RAM or concurrency, never max-instances.
+gcloud run services update three-ws-multiplayer $R --cpu=8 --memory=16Gi
+gcloud run services update three-ws-multiplayer $R --concurrency=2000
+```
+
+**`three-ws-multiplayer` max-instances must stay 1.** Colyseus rooms live in one
+process. A second instance is only correct when the room registry and presence
+are shared through Redis *and* each instance is individually addressable so a
+seat reservation lands on the box hosting the room. Cloud Run gives every
+instance the same URL, so instance 2 would silently split players in the same
+world into two invisible crowds. A Memorystore Redis exists
+(`three-ws-redis`, `10.234.231.139:6379`) and `REDIS_URI` would switch the driver
+on, but the addressability half is not solved and the eve of an event is not when
+to find out. Use CPU, memory, and concurrency instead.
+
+---
+
+## Capacity: measured, not assumed
+
+`npm run event:capacity -- --n 400 --ramp 45 --hold 150` against live production,
+2026-08-08:
+
+| | |
+|---|---|
+| requested / joined | 400 / 400 (100%) |
+| held for the full 150s | 400 |
+| join latency | p50 155ms · p95 219ms · max 388ms |
+| mid-run drops | 0 |
+| moves sent / state patches | 269,633 / 415,418 |
+| verdict | PASS on all four thresholds |
+
+The single world instance carried 400 concurrent players walking at 8 Hz with
+zero drops. The known cliff is the concurrency ceiling: at 1000 simultaneous
+connections Cloud Run wants a second instance and `max-instances=1` refuses it.
+If the count approaches that, raise `--concurrency`, not `--max-instances`.
+
+One caveat baked into the harness: at 400 clients its own event loop stalls, so
+the page-latency figure it prints measures the machine running it, not the
+origin. It now prints its own loop lag next to that number and says so. An idle
+`curl` during the same run measured `/play` at a steady 420-490ms.
+
+---
+
+## Known failure modes and what to do
+
+Audits 1-9 did not leave an accepted-risk register, so this is derived from the
+code's own documented landmines plus what was measured on 2026-08-08.
+
+| If this happens | Why | Do this |
+|---|---|---|
+| `/play` loads but nobody sees anyone else | World server restarted or a second instance appeared | `curl .../health`; confirm `max-instances=1`; rollback command above |
+| Players kicked seconds after joining, phones only | Mobile memory kill, not a network fault | `node scripts/play-mobile-repro.mjs` reproduces it; it reads as bytes, not as a networking bug |
+| `/walk` looks completely offline while `/play` works | Someone set `PLAY_GATE_MINT`/`THREE_MINT` on the world server. `/walk` sends no play pass, so every join throws `play_pass_required` (landmine documented in `multiplayer/src/rooms/WalkRoom.js`) | Unset it: `gcloud run services update three-ws-multiplayer $R --remove-env-vars=PLAY_GATE_MINT,THREE_MINT` |
+| NPC / concierge replies slow or absent | Paid LLM tier is degraded today: OpenRouter `402 Payment Required`, OpenAI `429`. Vertex Gemini is healthy and the free-first chain leads, so players still get answers (measured 8-16s first token after live demotions) | Nothing during the event. Topping up OpenRouter is an owner spend decision |
+| Wallet balances read as zero / holder tier collapses to Member | Helius and Alchemy are both `429` today. 6 free rungs plus the QuickNode reserve carry it (proven by poisoning the primary) | `npm run event:failover` to see which rungs are live now |
+| Coin image missing on the event link or OG card | `4everland.io` gateway times out, `gateway.pinata.cloud` is slow (~4s). `api/img.js` races five gateways and takes the first valid one | Nothing. 4 of 5 gateways served the CID on 2026-08-08 |
+| An x402 / boutique payment does not settle | `/api/healthz` shows 50,442 settle failures with `fee_runway_exhausted`. This is settle-floor starvation, which looks identical to "the wallets are dry" and has a different fix | Run the `x402-economy-triage` agent BEFORE concluding anything about wallet balances |
+| Something breaks and nobody is told | **Push alerting does not reach a human.** `TELEGRAM_ALERTS_CHAT_ID` is unset in production, so `/api/healthz` reports `telegram_push: "disabled"` and alerts land only in the `ops_alerts` table. The only Cloud Monitoring policy that emails `[email protected]` is a Blockchain RPC quota alert; there is no Cloud Run uptime or error-rate policy | Keep `npm run event:watch` open on a screen. That is the alerting for this event. See [Open items](#open-items) |
+
+---
+
+## Escalation: which tool for which subsystem
+
+| Subsystem | Tool |
+|---|---|
+| x402 payments, settles, the ring, "wallets are dry" | `x402-economy-triage` agent. Do not diagnose by hand; settle-floor starvation and capital dispersion look the same from outside |
+| Cloud Run, crons, logs, DB migrations, TLS, fleet readiness | `gcp-triage` skill, or `npm run triage:gcp:deep` |
+| Phones dropping out of the world | `node scripts/play-mobile-repro.mjs` |
+| Any page 404/500 across the site | `npm run smoke:prod` |
+| A third-party provider suspected down | `npm run event:failover` |
+| World capacity under a crowd | `npm run event:capacity -- --n <2x current peak>` |
+
+---
+
+## Ship the release (owner-gated)
+
+Two services, two commands. Both need explicit owner approval.
+
+```bash
+# 1. API + frontend (26+ commits ahead of what is live)
+npm run deploy:gcp:full
+
+# 2. The world server - required for the event features and /population.
+# Its image predates every event commit.
+cd multiplayer && ./deploy-cloudrun.sh
+```
+
+`deploy-cloudrun.sh` now defaults to `CPU=4 MEMORY=8Gi` so a redeploy cannot
+silently undo the pre-scaling above. `gcloud run deploy` replaces resource limits
+on every run, so a hotfix deploy with the old defaults would have halved the
+world server's CPU mid-event.
+
+After either deploy: `curl -s https://three.ws/api/version`, then
+`npm run event:watch -- --once`, then update the release SHA at the top of this
+page.
+
+---
+
+## Open items
+
+1. **`TELEGRAM_ALERTS_CHAT_ID` exists nowhere** (not `.env`, not `.env.local`, not
+ the Cloud Run service). Every alerting path in `api/_lib/alerts.js` is already
+ wired behind it; it needs one private chat/DM id, which only the owner can
+ create. Then:
+ `gcloud run services update three-ws-api --region us-central1 --project aerial-vehicle-466722-p5 --update-env-vars=TELEGRAM_ALERTS_CHAT_ID=<id>`
+ (`--update-env-vars`, never `--set-env-vars`.) It must be a private chat: alerts
+ carry stack traces, URLs, and IPs.
+2. **No Cloud Run uptime or error-rate alert policy exists.** Creating one needs a
+ live gcloud credential, which expired mid-session here
+ (`invalid_grant: reauth related error (invalid_rapt)`). Re-auth with
+ `gcloud auth login --no-launch-browser`, then add an uptime check on
+ `https://three.ws/api/healthz` and on the world server's `/health`, both wired
+ to the existing verified `[email protected]` channel.
diff --git a/multiplayer/deploy-cloudrun.sh b/multiplayer/deploy-cloudrun.sh
index ae2364228..a199fdb3b 100755
--- a/multiplayer/deploy-cloudrun.sh
+++ b/multiplayer/deploy-cloudrun.sh
@@ -4,7 +4,7 @@
#
# Cloud Run builds the local Dockerfile via Cloud Build (no local docker push),
# terminates TLS, and hands back a stable https URL. The client connects to the
-# wss:// form of that URL — wire it into pages/play.html's <meta name="game-server">.
+# wss:// form of that URL - wire it into pages/play.html's <meta name="game-server">.
#
# Prereqs (one time):
# gcloud auth login
@@ -24,13 +24,13 @@ PROJECT="$(gcloud config get-value project 2>/dev/null)"
# ── Capacity tunables ──────────────────────────────────────────────────────
# CONCURRENCY is the # of simultaneous connections Cloud Run routes to ONE
-# instance. The platform default is 80 — for a WebSocket server that is a hard
+# instance. The platform default is 80 - for a WebSocket server that is a hard
# ~80-player ceiling, so we raise it well above the per-instance comfort limit.
#
# CPU/MEMORY are the defaults a redeploy applies, so they are not merely a first
# -deploy convenience: `gcloud run deploy` REPLACES the resource limits every
# time. Raising them by hand on the live service (as event pre-scaling did on
-# 2026-08-07) survives exactly until the next deploy from this script, and a
+# 2026-08-08) survives exactly until the next deploy from this script, and a
# mid-event hotfix that silently halves the world server's CPU is the worst
# possible time to discover that. The defaults below are the event-day floor;
# lower them here, not on the service.
@@ -58,7 +58,7 @@ fi
# Durable build storage (Upstash Redis REST). This is SEPARATE from REDIS_URI
# above: REDIS_URI is Colyseus's room-registry/presence Redis for horizontal
# scaling; these two power block-store.js so each coin world's voxel build
-# survives a redeploy/restart. They must be set on THIS Cloud Run service — the
+# survives a redeploy/restart. They must be set on THIS Cloud Run service - the
# same vars on Vercel only reach the Vercel API functions, never this process.
# Pass them through when present in the deploy shell (export them, or source an
# env file, before running this script). For the token, Secret Manager via
@@ -70,7 +70,7 @@ UPSTASH_REDIS_REST_TOKEN="${UPSTASH_REDIS_REST_TOKEN:-}"
# monitor creds are only passed when provided. Applied with --update-env-vars
# (NOT --set-env-vars): a redeploy from a shell without HOLDER_PASS_SECRET or
# the Upstash creds must merge into the service's existing env, never replace
-# it — --set-env-vars silently wipes every var not named here.
+# it - --set-env-vars silently wipes every var not named here.
ENV_VARS="NODE_ENV=production@ALLOWED_ORIGINS=${ALLOWED_ORIGINS}"
[[ -n "${REDIS_URI}" ]] && ENV_VARS="${ENV_VARS}@REDIS_URI=${REDIS_URI}"
[[ -n "${UPSTASH_REDIS_REST_URL}" ]] && ENV_VARS="${ENV_VARS}@UPSTASH_REDIS_REST_URL=${UPSTASH_REDIS_REST_URL}"
@@ -82,7 +82,7 @@ ENV_VARS="NODE_ENV=production@ALLOWED_ORIGINS=${ALLOWED_ORIGINS}"
# --update-env-vars a value already set on the service survives the redeploy,
# so this only bites a FIRST deploy (or a service that never had them).
if [[ -z "${UPSTASH_REDIS_REST_URL}" || -z "${UPSTASH_REDIS_REST_TOKEN}" ]]; then
- echo " ⚠ UPSTASH_REDIS_REST_URL/_TOKEN not set in this shell — kept from the service's current env if present, else builds are MEMORY-ONLY." >&2
+ echo " ⚠ UPSTASH_REDIS_REST_URL/_TOKEN not set in this shell - kept from the service's current env if present, else builds are MEMORY-ONLY." >&2
fi
echo "Deploying '${SERVICE}' to Cloud Run (project=${PROJECT}, region=${REGION})..."
@@ -92,7 +92,7 @@ echo " cpu=${CPU} memory=${MEMORY} concurrency=${CONCURRENCY} instances=${MIN_I
# --no-cpu-throttling : keep CPU allocated between requests so the room
# simulation/patch loop never stalls (the #1 gotcha).
# --concurrency : connections routed per instance. The default 80 is a
-# hard WS-connection ceiling — raised here.
+# hard WS-connection ceiling - raised here.
# --min-instances : rooms live in-memory; keep ≥1 warm so they never
# cold-start away.
# --max-instances : >1 ONLY with REDIS_URI (shared room registry/presence);