Operations Runbook, Complete .env Dictionary & 5-Rung Verification Ladder
Document ID: YPG-OPS-010 | Index: docs/README.md
Canonical Origin: https://www.yourplayground.games | Local Daemon Port: http://localhost:9033
Primary Modules: server.mjs, src/config/env.mjs, public/sw.js, package.json
1. Runtime Prerequisites & Local / Production Startup
1.1 System Requirements
- Node.js:
>= 22.0.0(verified on Node.js v22 / v24 native ESM withnode:test,node:vm,structuredClone, andAbortSignal.timeout). - Google Cloud Authentication (for live Vertex AI synthesis):
- Workstation / Staging: Authenticated
gcloudCLI (gcloud auth login+gcloud auth application-default loginwith access to projectids-hybrid-model,location: 'global'). If ADC encounters Workspaceinvalid_rapt,vertexAiService.mjsfails over automatically togcloud auth print-access-tokencached for 45 minutes. - Cloud Run / GKE / Compute Engine Production: Attach a dedicated least-privilege IAM Service Account (
roles/aiplatform.useron projectids-hybrid-model)—service account metadata tokens never suffer human RAPT expiration.
1.2 Standard Operational Commands
# 1. Install locked dependencies cleanly
npm ci
# 2. Seed or refresh canonical 100% English showcase games (idempotent atomic writes)
npm run seed
# 3. Start production HTTP server on port 9033 (http://localhost:9033)
npm start
# 4. Start development server with automatic file-watch reload
npm run dev
# 5. Verify live health probe
curl -fsS http://localhost:9033/api/health
2. Complete .env Configuration Reference
Parsed and sanitized dynamically on every request via getEnv() in src/config/env.mjs so runtime configuration overrides take effect deterministically without editing source code.
2.1 Core Runtime, Storage & Cryptographic Secrets
| Variable | Default Value | Validation / Format | Operational Purpose |
|---|---|---|---|
PORT | 9033 | Integer 0..65535 | TCP port bound by server.mjs (9033 canonical local port) |
CANONICAL_URL (alias SITE_URL) | https://www.yourplayground.games | Valid http(s):// origin | Canonical base URL for SEO/GEO/AEO/AIO outputs and IndexNow payloads |
STORAGE_DIR | ./storage | Relative or absolute path | Root directory for catalog.json, users.json, sessions.json, and games/<slug>/* |
SESSION_SECRET | (dev fallback only) | >= 32 random bytes (hex/base64) | MUST override in production: HMAC-SHA256 key signing ypg_sid, ypg_vid, and ypg_oauth_state |
AD_HMAC_SECRET | SESSION_SECRET | >= 32 random bytes (hex/base64) | Dedicated HMAC-SHA256 key signing single-use adGrantToken tokens |
2.2 Google Cloud Vertex AI (ids-hybrid-model)
| Variable | Default Value | Validation / Format | Operational Purpose |
|---|---|---|---|
GOOGLE_CLOUD_PROJECT (alias VERTEX_PROJECT_ID) | ids-hybrid-model | GCP Project ID | Target Google Cloud project for @google/genai Vertex AI requests |
GOOGLE_CLOUD_LOCATION (alias VERTEX_LOCATION) | global | GCP Region / global | Vertex AI serving endpoint location |
VERTEX_DEFAULT_MODEL | gemini-4-neon | Registered ID in TEXT_MODELS | Primary active game coding model (XHIGH supported) |
VERTEX_REPAIR_MODEL | gemini-4-carbon | Registered ID in TEXT_MODELS | Automatic 1-shot structural & V8 vm.Script forensic repair model |
2.3 Web Monetization (Google AdSense & VAST 4.2)
| Variable | Default Value | Validation / Format | Operational Purpose |
|---|---|---|---|
ADSENSE_PUBLISHER_ID (alias ADSENSE_CLIENT_ID) | "" (test mode) | ca-pub-16digits or pub-16digits | Injects AdSense <meta>, adsbygoogle.js, and live /ads.txt seller line |
ADSENSE_SLOT_ID (aliases ADSENSE_REWARD_SLOT_ID, ADSENSE_REWARD_SLOT) | "" (test mode) | Numeric AdSense slot ID | Switches adsenseMode to 'live' when paired with ADSENSE_PUBLISHER_ID |
ADSENSE_DISPLAY_SLOT_ID (alias ADSENSE_BANNER_SLOT) | "" | Numeric AdSense slot ID | Optional non-stage showcase/category banner unit |
AD_WATCH_DURATION_SECONDS | 5 | 0..300 seconds | Required elapsed watch duration before adGrantToken issuance (15–30 recommended in prod) |
VAST_REWARD_TAG_URL | "" | Valid https:// URL | Google IMA HTML5 SDK VAST 4.2 / GAM H5 Games Ads rewarded video tag URL |
2.4 Analytics, Consent Mode v2, Search Verification & IndexNow
| Variable | Default Value | Validation Regex | Operational Purpose |
|---|---|---|---|
GA_MEASUREMENT_ID | "" | /^G-[A-Z0-9]{4,32}$/i | Google Analytics 4 stream ID (strictly honors ypg_consent_v2 Consent Mode v2) |
GTM_CONTAINER_ID | "" | /^GTM-[A-Z0-9]{4,32}$/i | Google Tag Manager container ID |
CLARITY_PROJECT_ID | "" | /^[a-zA-Z0-9_-]{4,64}$/ | Microsoft Clarity behavioral heatmap/session project ID |
GOOGLE_SITE_VERIFICATION | "" | Control/quote stripped | Renders <meta name="google-site-verification" content="..."> |
BING_SITE_VERIFICATION | "" | Control/quote stripped | Renders <meta name="msvalidate.01" content="..."> |
YANDEX_SITE_VERIFICATION | "" | Control/quote stripped | Renders <meta name="yandex-verification" content="..."> |
INDEXNOW_KEY | "" | /^[a-zA-Z0-9-]{8,128}$/ | Served dynamically at /indexnow.txt and /${INDEXNOW_KEY}.txt |
INDEXNOW_ENABLED | false | 'true' + valid INDEXNOW_KEY | Enables non-blocking POST https://api.indexnow.org/indexnow on game publish |
2.5 Optional Google OAuth 2.0, Firebase & Mobile AdMob
| Variable | Default Value | Surface | Operational Purpose |
|---|---|---|---|
GOOGLE_CLIENT_ID (alias GOOGLE_OAUTH_CLIENT_ID) | "" (test mode) | Web Backend | Google OAuth 2.0 Web Client ID |
GOOGLE_CLIENT_SECRET (alias GOOGLE_OAUTH_CLIENT_SECRET) | "" (test mode) | Web Backend | Google OAuth 2.0 Web Client Secret (switches authMode to 'google_oauth') |
GOOGLE_REDIRECT_URI | http://localhost:9033/auth/google/callback | Web Backend | Authorized OAuth callback (https://www.yourplayground.games/auth/google/callback in prod) |
ALLOW_TEST_AUTH | true (when OAuth unset) | Web Backend | Keep false in public production so /api/auth/test-login returns 403 TEST_AUTH_DISABLED |
FIREBASE_PROJECT_ID | — | Mobile / Cloud Sync | Firebase project ID (GoogleService-Info.plist / google-services.json) |
FIREBASE_APP_CHECK_ENFORCE | true (prod) | Mobile API Gateway | Verifies X-Firebase-AppCheck DeviceCheck / Play Integrity tokens |
ADMOB_IOS_APP_ID / ADMOB_ANDROID_APP_ID | (Google Test IDs in Debug) | iOS / Android Build | Native Google Mobile Ads SDK application identifiers |
ADMOB_IOS_REWARDED_ID / ADMOB_ANDROID_REWARDED_ID | (Google Test IDs in Debug) | iOS / Android Build | Production AdMob Rewarded Video unit IDs with SSV enabled |
3. Production Reverse-Proxy, TLS & Zero-Ghost-UI Cache Hygiene
When deploying behind Cloudflare, Google Cloud Load Balancing, or NGINX in front of Node.js :9033:
- Preserve Origin
Cache-Controlon HTML &/sw.js: Never configure CDN edge rules to "Cache Everything" on HTML routes (/,/showcase,/categories*,/games/*,/faq) or/sw.js. They must retainCache-Control: no-store, no-cache, must-revalidateso newly published games, updated UI builds, and session states appear instantaneously without Ghost-UI staleness. - Cache Immutable Static Bundles Only: CDN edge caching is safe on
/vendor/*,/brand/*, and/creatives/*(public, max-age=3600). - Bumping Service Worker Generation: If static CSS/JS shell contracts ever undergo a breaking structural revision, increment
CACHE_NAMEinpublic/sw.js(e.g.,'ypg-shell-v2'→'ypg-shell-v3'). On next page load, the browser fetches/sw.jsuncached, runsself.skipWaiting(), purges every old cache bucket (keys.filter((k) => k !== CACHE_NAME)), and claims active tabs cleanly. - Persistent Volume Durability: Mount
STORAGE_DIRonto a POSIX/NTFS volume supporting atomic same-filesystemrename(2)andfsync(2)(never split temporary files across separate mount points).
4. The 5-Rung Deterministic Verification Ladder
Every code, asset, or infrastructure change must ascend all five verification rungs sequentially before release sign-off. If any rung fails twice consecutively on the same strategy, halt blind retries immediately (2-Strike Causal Circuit Breaker), diagnose the cross-layer root cause, and implement a structural fix.
flowchart LR
R1["Rung 1<br/>UTF-8 No-BOM &<br/>Static Syntax Hygiene"] --> R2["Rung 2<br/>Unit & Adversarial<br/>Edge Suites"]
R2 --> R3["Rung 3<br/>Cross-Module Integration<br/>Contract Parity"]
R3 --> R4["Rung 4<br/>Live :9033 + Headless Chromium<br/>Desktop/Mobile & OOPIF E2E"]
R4 --> R5["Rung 5<br/>Post-Edit Diff &<br/>docs/UI SHA-256 Audit"]
Rung 1 — Structural, Encoding & Static Parse Hygiene
- Verify zero UTF-8 BOM (
0xEF 0xBB 0xBF), clean LF line endings, valid JSON inpackage.json/storage/*.json, and clean Node.js ESM syntax (node --check server.mjs src/**/*.mjs).
Rung 2 — Unit & Adversarial Edge Suites (npm run test:unit)
- Executes
tests/unit/m1-foundation.test.mjs,tests/unit/backend-services.test.mjs, andtests/unit/ssr-seo-views.test.mjs: - Atomic JSON concurrent lock contention & Windows retry tests.
- Linear-time
O(N)gameSanitizer.mjsReDoS timing, mXSS foreign SVG/MathML stripping, CSS3<bad-url-token>scrubbing, ECMA-262 module healing, and V8vm.Scriptvalidation. - Vertex AI 8-model clamping, thought-part filtering, and 45-minute
gcloudCLI fallback coalescing. - Ad-gate clock-skew, actor binding, non-burning input-validation ordering, and single-use JTI replay rejection.
Rung 3 — Full-Platform Cross-Boundary Integration (npm run test:integration)
- Executes
tests/integration/full-platform.test.mjsagainst an isolated temporarystorageDir(zero mutation of livestorage/), verifying end-to-end parity across Express 5 middleware, cookies, OAuth/test auth, ad-gate unlock, game synthesis, SSR HTML5 views, JSON-LD@graphvalidity, and/robots.txt//sitemap.xml//llms*.txt//.well-known/*discovery outputs.
Rung 4 — Live :9033 Runtime, Opaque-Box E2E & Firsthand Pixel Inspection (npm run test:e2e)
- Executes the 168-test opaque-box suite (
tests/e2e/run-e2e.mjsacross Tiers 1–4) plus real headless Chromium desktop (1440x900) and mobile (390x844) screenshot capture and OOPIFYourPlaygroundSDKbehavioral verification: - Zero console errors, zero uncaught page errors, zero horizontal overflow, non-overlapping Consent Mode v2 banner, active 60 FPS canvas rendering, and side-by-side 1:1 visual comparison against
docs/UI/your_playgrpound_games_design_1.pnganddocs/UI/Yapay Zekâ Evrenini Oyna ve Yarat-1.png.
Rung 5 — Untouched-Boundary & SHA-256 Provenance Audit
- Verify
git statuscleanliness outside authorized paths, zero leftover scratch artifacts, and exact SHA-256 bit-for-bit preservation of protected visual anchors (docs/UI/*): docs/UI/your_playgrpound_games_design_1.png:ACCA31B4AE1CF937EDB649C8C2FBAF8BF13BE733...(2,806,971bytes)docs/UI/Yapay Zekâ Evrenini Oyna ve Yarat-1.png:9941B38AA52EA25E4BA802F55F85E6FFD3AF49FC...(2,302,623bytes)