Files
openmotion/docs/game-static-play-runbook.md
open-design-crew[bot] 1765dd0b0b [OPEND-5936] OpenGame Stage 1 Cloud Launch: read-only MCP catalog, cookieless static play, 21-section skill & Game Studio (#1198)
* feat(game-static-play): add 274-template R2 zip packaging, cookieless static play deploy, and verification pipeline

* feat(game-skill): port 21-section OpenGame skill with dual-mode workflow and fast-play path

* feat(onboarding): upgrade Cloud MCP install guide and add shared OpenGame prompt builders

* feat(game-catalog): sync 274 official templates, 4 kits, downloads manifest, and game contract

* feat(cloud-mcp): add read-only game catalog, free asset search, guest catalog API, redirects, and Docker packaging

* feat(opengame): enable Stage 1 Game Studio routing, feature flags, and analytics

* feat(opengame): add Stage 1 market, multi-client modal, Cursor HTTP fix, SuperAgent prompt, and i18n

* fix(opengame): align nullable GameCardWithMeta fields and add opengame-catalog MCP capability

* test(mcp-onboarding): update registered public tool count from 22 to 24 for Stage 1 game tools

* chore(game-catalog): register 26 verified live R2 in-repo template bundles in game-downloads.json

* fix(opengame): address Stage 1 review feedback and failing CI lanes

- Send no play URL when GAME_PLAY_PUBLIC_ORIGIN is unset instead of a main-site
  path that no route serves; Studio falls back to bundled in-repo templates
- Keep legacy-host 301 redirects on the configured origin for network-path inputs
- Correct the BlenderKit page host in the asset search allowlist
- Reuse the shared withdrawn list, TOP earning tag, curated order and comparator in Studio
- Remove the unused shared prompt module; the shipped builders stay covered by Studio tests
- Drop the blurred launch backdrop and the in-dialog copy notices in favour of Toasts
- Describe the shipped read-only Game Studio boundary and 24-tool MCP contract in the architecture
- Schedule the game skill and static play suites in CI and budget the three OpenGame events

* fix(game-static-play): retry stalled template bundle downloads before failing the run

* fix(game-asset-search): size the pagination cursor limit for every supported query

A 200-unit query with non-ASCII, control or lone-surrogate characters produced a
cursor longer than the 512-character limit, so nextCursor was rejected by both
the decoder and the public schema. Share one limit derived from the worst-case
JSON/base64url expansion and add a round-trip test for maximum-length queries.

* fix(game-asset-search): accept BlenderKit pages on www.blendkit.com and guide licence checks

www.blenderkit.com now redirects to www.blendkit.com and the upstream catalog
returns that host, so requiring www.blenderkit.com dropped every BlenderKit
result. Restore the live host, pin a real upstream row in tests, and tell
Agents to confirm the licence on the source page when a source omits it.

* fix(deploy): forward game play origin and legacy redirect hosts to the API

deploy/.env.example and deploy/k8s/configmap.yaml declared GAME_PLAY_PUBLIC_ORIGIN
and APP_REDIRECT_FROM_HOSTS, but neither the compose api service nor the reference
api Deployment passed them to the process. Wire both and assert that every
reference ConfigMap key is read by a workload.

* Address review: keep legacy-host writes, enforce play-origin isolation, share catalog constants

- Legacy-host redirects answer GET/HEAD with 301 and every other method with 308,
  so MCP and API writes keep their method and body.
- parseConfig rejects a GAME_PLAY_PUBLIC_ORIGIN that is not https (loopback http
  excepted), carries a path, or shares or sits under the APP_PUBLIC_ORIGIN host.
- The template id pattern, bundle key prefix, withdrawn set and TOP tag predicate
  live in shared/game-contract.ts; static play, deploy/verify scripts and the
  catalog service reuse them and the shared bundle URL builder.
- Remove unused game-contract and model-catalog exports.
- Update the MCP contract, AGENTS.md, README and docs to the 24-name phase-one
  surface and document the read-only OpenGame tools and guest catalog routes.

* fix(game-static-play): make the full play-site upload resumable

Upload through the S3 SDK instead of one aws CLI process per file, skip
objects whose ETag already matches the local MD5, retry each request with
backoff, and write assets before entry pages and the manifest. Give large
bundle downloads time for a slow link. Record the provisioned bucket,
domain and remaining header rule in the runbook.

* feat(game-static-play): harden live play verification and add manual R2 publish workflow

* fix(opengame): raise prompt/remix maxLength for >4k OG-13 test and reset notes on target change

* fix(mcp): register resources/templates/list handler for Codex MCP compliance

* chore(game-catalog): register uploaded tidebreaker bundle for 274/274 R2 CDN parity

---------

Co-authored-by: heggria <bshengtao@gmail.com>
2026-11-30 23:39:22 -08:00

14 KiB

OpenGame Stage 1: Static Playable Domain & 274-Template R2 Runbook

This runbook covers the deterministic, idempotent pipelines for OpenGame Stage 1 (OPEND-5936):

  1. Packaging the 27 in-repo templates into immutable R2/CDN zips so all 274/274 listed official templates are downloadable uniformly from CDN.
  2. Pure-static unpacking & deployment of all 274 official templates to an independent cookieless static playable domain (separate host from APP_PUBLIC_ORIGIN, zero main-site cookies/auth) supporting both desktop iframe embeds and direct mobile browser touch play.
  3. Automated verification of all 274 official templates (including 243 TOP赚钱 templates) and community links.

1. Stage 1 Catalog Audit & 3 Historical 503 Root Causes

Category Count Details
Total dirs in opengame/templates/games/ 277 274 listed + 3 withdrawn
Withdrawn / blacklisted official templates 3 school-tycoon-3d, arrow-pop-clear, shaman-block-pop (excluded from catalog, R2 unified cloud manifest, and static playable routes)
Listed official templates 274 27 in-repo + 247 R2-hosted (243 tagged TOP赚钱; 223 portrait, 51 landscape)
In-repo official templates 27 Local index.html (castle-crush, comet-guard, drift-dash, fruit-gym, gate-legion, glyph-garden, harbor-skirmish, jingyang-ridge, lane-turret, lantern-hop, last-light, lighthouse-log, merge-bakery, neon-drift, night-train, periscope-depth, pin-rescue, rooftop-roast, sky-runner, skyline-courier, slacking-evo, slime-swell, sort-stack, stack-the-moon, starlight-bastion, tidebreaker, tilt-temple). 27/27 are live at HTTP 200 on R2 and recorded in templates/game-downloads.json.
R2-hosted official templates 274 / 274 100% uniform CDN parity: all 274 listed official templates (plus 3 withdrawn = 277 total entries in templates/game-downloads.json) are verified HTTP 200 with exact content-length on open-game/games/objects/<sha256>.zip.
Community external games 23 17 in studio/src/motion/game/community/more-games.json + 6 in gameCatalog.ts (all verified HTTP 200)
Total playable catalog 297 288+ playable games

Root Cause & Fix of the 3 Historical 503 Games

All 3 historical 503 games were external community Vercel deployments authored by @kevin_t_ngo that were listed in studio/src/motion/game/community/more-games.json:

  1. what-the-water-keeps (https://what-the-water-keeps.vercel.app/) — HTTP 503 (x-vercel-error: DEPLOYMENT_PAUSED)
  2. evensong (https://evensong-phi.vercel.app/) — HTTP 503 (x-vercel-error: DEPLOYMENT_PAUSED)
  3. gilt-and-gutter (https://gilt-and-gutter.vercel.app/) — HTTP 503 (x-vercel-error: DEPLOYMENT_PAUSED)

Resolution: Removed from studio/src/motion/game/community/more-games.json (matching opengame PR #182) and enforced by HISTORICAL_503_COMMUNITY_GAME_IDS in shared/game-static-play.ts and scripts/verify-static-game-templates.ts.


2. Environment Variable & URL Contract (Zero Hardcoded Production Domains)

All origins are injected dynamically via environment variables:

Env Var Purpose Example
APP_PUBLIC_ORIGIN Canonical main authenticated app origin https://apps.open-design.ai
GAME_PLAY_PUBLIC_ORIGIN Independent cookieless static playable domain (MUST be a distinct host, never the same host or a subdomain of APP_PUBLIC_ORIGIN) https://<static-play-domain>
GAME_BUNDLE_PUBLIC_ORIGIN Optional override for R2 zip CDN origin (defaults to mediaOrigin in shared/repository-media.ts) https://<releases-cdn-domain>
MOTION_R2_ENDPOINT / MOTION_R2_BUCKET R2 S3 endpoint & bucket for immutable template zips (open-game/games/objects/<sha256>.zip) https://<account>.r2.cloudflarestorage.com
GAME_PLAY_R2_ENDPOINT / GAME_PLAY_R2_BUCKET Dedicated R2 S3 endpoint & bucket backing GAME_PLAY_PUBLIC_ORIGIN https://<account>.r2.cloudflarestorage.com

Canonical static playable URL pattern:

${GAME_PLAY_PUBLIC_ORIGIN}/games/${encodeURIComponent(id)}/index.html
  • Using explicit /index.html works across R2 custom domains, S3/CloudFront, Cloudflare Pages, and Nginx without requiring directory-index rewriting, while keeping relative paths (style.css, ./assets/..., ./src/...) scoped cleanly under /games/<id>/.
  • shared/game-static-play.ts enforces cookieless host isolation (assertDistinctCookielessPlayOrigin) and rejects withdrawn template IDs.

3. One-Command Runbooks

Prerequisites

  • Node.js 22+ (node --experimental-strip-types)
  • For remote R2 uploads only: a scoped R2 access key in AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY. Step 1 --publish also needs aws CLI v2; Step 2 --upload writes through the bundled S3 SDK. Dry-run and local staging require zero cloud credentials.

Step 1 — Package the 27 In-Repo Templates into R2 Zips (274/274 Uniform CDN)

Dry-run & local staging (safe default, zero remote writes):

node --experimental-strip-types scripts/package-in-repo-game-templates.ts \
  --dry-run \
  --output /tmp/opengame-inrepo-stage
  • Produces deterministic deflate zips under /tmp/opengame-inrepo-stage/objects/<sha256>.zip, a unified 274-template manifest at /tmp/opengame-inrepo-stage/game-downloads.unified.json, and an audit report.
  • If a checkout contains unhydrated Git LFS pointers, run git lfs pull first or pass --fallback-source-dir <hydrated-templates-games-dir>.

Production R2 publish (idempotent — skips existing immutable 200 objects, uses --if-none-match '*'):

MOTION_R2_ENDPOINT="https://<account>.r2.cloudflarestorage.com" \
MOTION_R2_BUCKET="<releases-bucket>" \
node --experimental-strip-types scripts/package-in-repo-game-templates.ts \
  --publish \
  --output /tmp/opengame-inrepo-stage

Step 2 — Unpack & Deploy All 274 Official Templates to the Cookieless Static Playable Domain

During unpack, scripts/deploy-static-game-play.ts automatically:

  • Excludes the 3 withdrawn templates (school-tycoon-3d, arrow-pop-clear, shaman-block-pop).
  • Verifies SHA-256 + byte length of every R2 zip (cached in --cache-dir for instant idempotent re-runs).
  • Runs prepareStaticPlayHtml (idempotent mobile <meta name="viewport">, non-intrusive mobile touch guard, and Cocos Creator system.bundle.js chunk-order guard).
  • Runs auditStaticGameFiles on every unpacked game before writing games/<id>/..., manifest.json, and _headers.

Plan-only dry-run (zero downloads, zero writes):

GAME_PLAY_PUBLIC_ORIGIN="https://<static-play-domain>" \
APP_PUBLIC_ORIGIN="https://<app-domain>" \
node --experimental-strip-types scripts/deploy-static-game-play.ts --dry-run

Local staging (prioritize 243 TOP赚钱 first, or omit --top-only for all 274):

GAME_PLAY_PUBLIC_ORIGIN="https://<static-play-domain>" \
APP_PUBLIC_ORIGIN="https://<app-domain>" \
node --experimental-strip-types scripts/deploy-static-game-play.ts \
  --dry-run \
  --cache-dir /tmp/opengame-zip-cache \
  --output /tmp/opengame-static-site

Production upload to the dedicated cookieless static bucket (1-command):

GAME_PLAY_PUBLIC_ORIGIN="https://<static-play-domain>" \
APP_PUBLIC_ORIGIN="https://<app-domain>" \
GAME_PLAY_R2_ENDPOINT="https://<account>.r2.cloudflarestorage.com" \
GAME_PLAY_R2_BUCKET="<static-play-bucket>" \
node --experimental-strip-types scripts/deploy-static-game-play.ts \
  --upload \
  --cache-dir /tmp/opengame-zip-cache \
  --output /tmp/opengame-static-site
  • The full site is about 115k files (2.2 GB). The upload lists the bucket first and skips every object whose ETag already matches the local MD5, so a re-run after an interruption only sends what is missing. --force-upload rewrites everything (use it after changing cache or content-type rules); --upload-concurrency (default 16) sets parallel writes, and each write retries up to six times with backoff.
  • Assets are written first, then every games/<id>/index.html, then manifest.json, so a live page never points at a file that has not arrived yet.
  • Bundle downloads allow two minutes plus time for a 64 KB/s link, so the 30 MB games no longer time out on a slow network; the zip cache makes re-runs resume.

Step 3 — Verify All 274 Official Templates, R2 Bundles & Live Cookieless Domain

Pre-deploy local & R2 verification (checks 274 listed, 243 TOP赚钱, 3 withdrawn excluded, 3 historical 503 community IDs excluded, in-repo audit, staged audit, and R2 HEAD checks):

node --experimental-strip-types scripts/verify-static-game-templates.ts \
  --expect-listed 274 \
  --expect-top-earning 243 \
  --staged-dir /tmp/opengame-static-site \
  --check-r2

Post-deploy live verification (verifies HTTP 200, zero Set-Cookie, no X-Frame-Options: DENY/SAMEORIGIN iframe blockers, all 3 Cloudflare Transform Rule security headers nosniff / no-referrer / cross-origin, 3 withdrawn 404s, valid mobile <meta name="viewport">, optional --check-live-assets referenced-asset HEAD sweep, and live community URLs):

GAME_PLAY_PUBLIC_ORIGIN="https://play.open-design.app" \
APP_PUBLIC_ORIGIN="https://apps.open-design.ai" \
node --experimental-strip-types scripts/verify-static-game-templates.ts \
  --expect-listed 274 \
  --expect-top-earning 243 \
  --check-live \
  --check-live-assets \
  --check-r2 \
  --check-community

Step 4 — One-Click GitHub Actions Workflow (.github/workflows/publish-game-static-play.yml)

Operators can also trigger .github/workflows/publish-game-static-play.yml via workflow_dispatch (safe dry_run: true by default):

  • publish_in_repo_zips (uses existing CLOUDFLARE_R2_RELEASES_AK / SK / URL / BUCKET to upload only missing in-repo zips such as the remaining 92 KB tidebreaker zip to reach 274/274 on releases.open-design.ai).
  • deploy_static_play (uses GAME_PLAY_R2_AK / SK / ENDPOINT / BUCKET + GAME_PLAY_PUBLIC_ORIGIN to sync updated templates to opengame-static-play).
  • verify_live (runs scripts/verify-static-game-templates.ts --expect-listed 274 --expect-top-earning 243 --check-live --check-r2 --check-community).

4. Independent Cookieless Domain Provisioning Spec & Edge Checklist

Production state (provisioned 2026-12-01)

Item Value
Play origin (GAME_PLAY_PUBLIC_ORIGIN) https://play.open-design.app
R2 bucket (GAME_PLAY_R2_BUCKET) opengame-static-play, custom domain play.open-design.app, minimum TLS 1.2
Bucket CORS GET/HEAD from any origin (Studio's code tab reads index.html cross-origin)
Deploy credential Bucket-scoped token with Object Read & Write on opengame-static-play only, expires 2027-06-01. It is not stored in this repository.

Why open-design.app and not open-design.ai: the main site writes JavaScript-readable cookies on the parent domain .open-design.ai (od_attr, od_registration_utm, signals-sdk-user-id, signals-sdk-session-id). A page on any *.open-design.ai host could read them and overwrite them for every other subdomain, and it would count as same-site to apps.open-design.ai and the sign-in service. Sign-in and session cookies are host-only today, but templates run third-party code, and stage 2 will host player-made games, so the play site lives on a separate registrable domain.

Verified live (2026-12-01): Cloudflare Modify Response Header Transform Rule (http.host eq "play.open-design.app") is active and verified across all 274/274 live games (243/243 TOP赚钱, 2,203/2,203 live referenced HTML assets & split-chunk parts, 99/99 Cocos chunk guards, 274/274 mobile viewport & touch guards): X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer, Cross-Origin-Resource-Policy: cross-origin, Access-Control-Allow-Origin: *, zero Set-Cookie, zero X-Frame-Options, and HTTP 404 for all 3 withdrawn templates (school-tycoon-3d, arrow-pop-clear, shaman-block-pop).

Provisioning requirements

  1. Dedicated R2 bucket & custom domain (zero main-site cookies):
    • Create a dedicated Cloudflare R2 bucket (opengame-static-play) and attach an independent custom domain on a registrable domain that carries no main-site cookies (play.open-design.app; never apps.open-design.ai, a subdomain of it, or another *.open-design.ai host while the parent domain carries cookies).
    • Emit zero Set-Cookie response headers on the static play domain.
  2. Iframe & mobile compatibility: Do not set X-Frame-Options: DENY or SAMEORIGIN on /games/*. Apply X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer, and Cross-Origin-Resource-Policy: cross-origin (see generated _headers).
  3. Wire env vars in infra/apps (kubernetes/charts/openmotion/templates/configmap.yaml + values.yaml):
    • Set GAME_PLAY_PUBLIC_ORIGIN to the provisioned cookieless static play origin.
    • Set APP_REDIRECT_FROM_HOSTS (e.g. app.open-design.ai) for 301 redirect to APP_PUBLIC_ORIGIN.
  4. R2 write credentials source:
    • Releases zip bucket (releases.open-design.ai): GitHub Actions secrets CLOUDFLARE_R2_RELEASES_AK, CLOUDFLARE_R2_RELEASES_SK, vars CLOUDFLARE_R2_RELEASES_URL, CLOUDFLARE_R2_RELEASES_BUCKET in nexu-io/openmotion (or OPENGAME_R2_* in nexu-io/opengame). Running Step 1 --publish with these creds uploads only the 1 remaining 92 KB tidebreaker zip and skips all 273 already-published zips idempotently.
    • Static play bucket: issue a scoped R2 API token with write access to <static-play-bucket> and run Step 2 --upload, followed by Step 3 --check-live --check-community.
  5. Cache policy & Rollback: games/*/index.html and manifest.json use public, max-age=300, must-revalidate; hashed/static assets use public, max-age=31536000, immutable or public, max-age=86400. Because R2 zip objects (open-game/games/objects/<sha256>.zip) are immutable and content-addressed, reverting any template is simply re-running deploy-static-game-play.ts --ids <id> --upload against the previous templates/game-downloads.json.