Chapter 6 ยท operations
One dev server runs the whole system locally; one GitHub push deploys it to the world. In between: a live ops console, a REST API foundation, an AI layer, and a test pyramid from pure engine units to full headless-browser walks.
The ops + corporate console: live match telemetry, bot health, and an activity feed โ everything the demo runner needs on one screen.

How it works. Polls /api/state every 3 seconds. That endpoint reads the bot match store, recomputes each player's raw/adjusted/progress/verified % server-side (same multipliers as the engine), merges bot heartbeats (fresh if seen < 45s) and the Qalarc Hub health, and returns one JSON. The feed is derived client-side by diffing successive polls โ no server push needed. Degrades gracefully when anything is missing; the corporate tab (org leagues, employer-funded pots, kโฅ5 aggregate-only wellbeing dashboards) renders from the same state.
The match visible in the screenshot was played through the real CommandBus (the /debug simulator) minutes before capture.
apiState() ยท verified end-to-end by apps/figma-app/bots-sim.mjs (plays a match โ asserts /api/state โ asserts the hub renders it)
What. Chat-shaped access to the real CommandBus plus the element gallery. The fastest way to demo the game end-to-end without a phone or a WhatsApp account โ documented in depth in Bots.
git push (main)
โโโถ GitHub Actions: .github/workflows/deploy.yml
โโ bun setup
โโ bash scripts/build-deploy.sh โ assembles deploy/public from the monorepo
โ site โ / ยท design โ /design ยท web app โ /app ยท hub โ /hub ยท debug โ /debug
โ slack โ /slack ยท connect โ /connect ยท demo โ /demo ยท system โ /system
โ figma-app โ /figma-app ยท wiki โ /wiki ยท functions/ โ /api/{ai,state}
โโ wrangler pages deploy โ Cloudflare Pages (project "rwf")
โโ bun test packages/game-core packages/bot-core apps/api โ 122 tests gate every push
~20 seconds later: live at rwf.qalarc.com
How it works. The deploy bundle is assembled by scripts/build-deploy.sh โ pure copies, no per-app build except the web app bundle (Bun build, minified). Pages Functions (deploy/functions/api/) provide the AI proxy and state endpoint in production, mirroring the local serve.ts routes. The local dev story is one command โ bun serve.ts on :4173 serves everything including this wiki at /wiki โ so local and production surface the same paths.
Always-on hosting: the GMKtec minirig kit is prepared (scripts/hosting/ โ install script, systemd units for the Slack bot) for bots that run without a dev machine; see blocker T3 in Status.
What. A unified backend for crews, players, matches and seasons โ the foundation that replaces the app's localStorage and the bots' file state with one source of truth.
How it works. Bun server on :4174 with CORS for the dev origin and production domain. Persistence is a single JSON file (.data/api-db.json) written atomically (tmp + rename) so a crash never corrupts the store. Crew records carry the 5-char join codes (no 0/O/1/I) that match the CREW-XXXX grammar the app and bots already display. The wiring step (app โ API โ bots) is mechanical and tracked as blocker T5.
What. GLM-5.3 behind a server-side proxy โ powers the site's AI guide, the app narrator and the bots' taunts/digest one-liners.
How it works. Clients post to /api/ai; the key lives server-side only (local .env / Pages Function secret) and is never shipped to a client. The proxy injects a system prompt describing the whole product, keeps the last 12 messages, caps content length, rate-limits 60/min, preserves upstream error classes (429 โ 502), and every consumer has a canned fallback โ if the AI is asleep the product still talks. Locally the same endpoint is served by serve.ts; in production by the Pages Function.
aiChat() ยท deploy/functions/api/ai.js ยท packages/bot-core/src/ai.ts (2s timeout + fallback)Unit โ integration โ headless-browser. Every push runs the packaged suites; the E2E walks run on demand and produce the screenshots this wiki is built from.
| Suite | Tests | What it proves | Run |
|---|---|---|---|
| game-core โ ENGINE V4 | 110 | the daily model: createDay/logSet/closeDay, first-to-target wins, bank/fail outcomes, streaks, seasons 1:1, stakes lifecycle, SOT power-up canon (pure-gain steal, shield saves, bomb fuse) | bun test packages/game-core |
| bot-core โ bus + gfamily + SOT additions | 89 | command grammar, aliases, cards, store behaviour, error cards, rematch/nemesis/digest, the daily-model additions | bun test packages/bot-core |
| api โ api.test.ts | 24 | REST routes, crew codes, atomic persistence | bun test apps/api |
| sot (v4) โ e2e.mjs | 120 checks | the full SOT product walk on the real app: onboard โ wizard โ season โ steal โ logs โ Daily Wins โ bombs โ charity resolution โ join flow; language + console gates; zero console errors | bun apps/sot/e2e.mjs |
| sot (v4) โ e2e-states.mjs | 59 checks | the critical states: offline banner + queued logs + badge, reconnect replay, sync conflict + duplicate warning sheets (confirm/undo), rest-day home, winner-known + battle-complete transitions; zero console errors | bun apps/sot/e2e-states.mjs |
| figma-app (v1) โ engine.test.js | 23 | the 300-era engine port matches the spec (incl. power-ups) | bun test apps/figma-app/engine.test.js |
| figma-app (v1) โ e2e / e2e-daily / e2e-squads | 122 + 74 + 90 | the v1 product walks: full journey, the temporal DZ loop with time travel, squads + wagers | bun apps/figma-app/e2e.mjs โฆ |
| board (v2) โ e2e / geom | 56 + 27 | the board presentation + lane geometry (centred, 1.2โ1.4ms frames) | bun apps/board/{e2e,geom}.mjs |
| v3 โ e2e / geom | 69 + 35 | the 3D course + SFX wiring | bun apps/v3/{e2e,geom}.mjs |
| figma-app (v1) โ bots-sim.mjs | โ | plays a real match through the CommandBus then asserts /api/state + the hub render it | bun apps/figma-app/bots-sim.mjs |
| wiki โ walk.mjs | 25 checks | this wiki: 10 pages load with zero console errors, every referenced asset resolves, every PNG decodes | bun apps/wiki/test/walk.mjs |
CI runs the packaged suites on every deploy push โ a red suite blocks nothing at Cloudflare but fails the workflow loudly. The E2E walks are the design contract: if a screen breaks, its screenshot can't be taken. v4's two walks were the wiki's own source material โ 120 + 59 checks re-run for this page's screenshots.