Skip to main content
Developer & Creator Documentation

Operations Runbook, Complete .env Dictionary & 5-Rung Verification Ladder

curl -fsS https://www.yourplayground.games/api/health

Open AI Studio Direct-Answer FAQ Hub Machine-Readable Corpus (/llms-full.txt)

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 with node:test, node:vm, structuredClone, and AbortSignal.timeout).
  • Google Cloud Authentication (for live Vertex AI synthesis):
  • Workstation / Staging: Authenticated gcloud CLI (gcloud auth login + gcloud auth application-default login with access to project ids-hybrid-model, location: 'global'). If ADC encounters Workspace invalid_rapt, vertexAiService.mjs fails over automatically to gcloud auth print-access-token cached for 45 minutes.
  • Cloud Run / GKE / Compute Engine Production: Attach a dedicated least-privilege IAM Service Account (roles/aiplatform.user on project ids-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

VariableDefault ValueValidation / FormatOperational Purpose
PORT9033Integer 0..65535TCP port bound by server.mjs (9033 canonical local port)
CANONICAL_URL (alias SITE_URL)https://www.yourplayground.gamesValid http(s):// originCanonical base URL for SEO/GEO/AEO/AIO outputs and IndexNow payloads
STORAGE_DIR./storageRelative or absolute pathRoot 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_SECRETSESSION_SECRET>= 32 random bytes (hex/base64)Dedicated HMAC-SHA256 key signing single-use adGrantToken tokens

2.2 Google Cloud Vertex AI (ids-hybrid-model)

VariableDefault ValueValidation / FormatOperational Purpose
GOOGLE_CLOUD_PROJECT (alias VERTEX_PROJECT_ID)ids-hybrid-modelGCP Project IDTarget Google Cloud project for @google/genai Vertex AI requests
GOOGLE_CLOUD_LOCATION (alias VERTEX_LOCATION)globalGCP Region / globalVertex AI serving endpoint location
VERTEX_DEFAULT_MODELgemini-4-neonRegistered ID in TEXT_MODELSPrimary active game coding model (XHIGH supported)
VERTEX_REPAIR_MODELgemini-4-carbonRegistered ID in TEXT_MODELSAutomatic 1-shot structural & V8 vm.Script forensic repair model

2.3 Web Monetization (Google AdSense & VAST 4.2)

VariableDefault ValueValidation / FormatOperational Purpose
ADSENSE_PUBLISHER_ID (alias ADSENSE_CLIENT_ID)"" (test mode)ca-pub-16digits or pub-16digitsInjects 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 IDSwitches adsenseMode to 'live' when paired with ADSENSE_PUBLISHER_ID
ADSENSE_DISPLAY_SLOT_ID (alias ADSENSE_BANNER_SLOT)""Numeric AdSense slot IDOptional non-stage showcase/category banner unit
AD_WATCH_DURATION_SECONDS50..300 secondsRequired elapsed watch duration before adGrantToken issuance (15–30 recommended in prod)
VAST_REWARD_TAG_URL""Valid https:// URLGoogle IMA HTML5 SDK VAST 4.2 / GAM H5 Games Ads rewarded video tag URL

2.4 Analytics, Consent Mode v2, Search Verification & IndexNow

VariableDefault ValueValidation RegexOperational Purpose
GA_MEASUREMENT_ID""/^G-[A-Z0-9]{4,32}$/iGoogle Analytics 4 stream ID (strictly honors ypg_consent_v2 Consent Mode v2)
GTM_CONTAINER_ID""/^GTM-[A-Z0-9]{4,32}$/iGoogle 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 strippedRenders <meta name="google-site-verification" content="...">
BING_SITE_VERIFICATION""Control/quote strippedRenders <meta name="msvalidate.01" content="...">
YANDEX_SITE_VERIFICATION""Control/quote strippedRenders <meta name="yandex-verification" content="...">
INDEXNOW_KEY""/^[a-zA-Z0-9-]{8,128}$/Served dynamically at /indexnow.txt and /${INDEXNOW_KEY}.txt
INDEXNOW_ENABLEDfalse'true' + valid INDEXNOW_KEYEnables non-blocking POST https://api.indexnow.org/indexnow on game publish

2.5 Optional Google OAuth 2.0, Firebase & Mobile AdMob

VariableDefault ValueSurfaceOperational Purpose
GOOGLE_CLIENT_ID (alias GOOGLE_OAUTH_CLIENT_ID)"" (test mode)Web BackendGoogle OAuth 2.0 Web Client ID
GOOGLE_CLIENT_SECRET (alias GOOGLE_OAUTH_CLIENT_SECRET)"" (test mode)Web BackendGoogle OAuth 2.0 Web Client Secret (switches authMode to 'google_oauth')
GOOGLE_REDIRECT_URIhttp://localhost:9033/auth/google/callbackWeb BackendAuthorized OAuth callback (https://www.yourplayground.games/auth/google/callback in prod)
ALLOW_TEST_AUTHtrue (when OAuth unset)Web BackendKeep false in public production so /api/auth/test-login returns 403 TEST_AUTH_DISABLED
FIREBASE_PROJECT_ID—Mobile / Cloud SyncFirebase project ID (GoogleService-Info.plist / google-services.json)
FIREBASE_APP_CHECK_ENFORCEtrue (prod)Mobile API GatewayVerifies X-Firebase-AppCheck DeviceCheck / Play Integrity tokens
ADMOB_IOS_APP_ID / ADMOB_ANDROID_APP_ID(Google Test IDs in Debug)iOS / Android BuildNative Google Mobile Ads SDK application identifiers
ADMOB_IOS_REWARDED_ID / ADMOB_ANDROID_REWARDED_ID(Google Test IDs in Debug)iOS / Android BuildProduction 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:

  1. Preserve Origin Cache-Control on HTML & /sw.js: Never configure CDN edge rules to "Cache Everything" on HTML routes (/, /showcase, /categories*, /games/*, /faq) or /sw.js. They must retain Cache-Control: no-store, no-cache, must-revalidate so newly published games, updated UI builds, and session states appear instantaneously without Ghost-UI staleness.
  2. Cache Immutable Static Bundles Only: CDN edge caching is safe on /vendor/*, /brand/*, and /creatives/* (public, max-age=3600).
  3. Bumping Service Worker Generation: If static CSS/JS shell contracts ever undergo a breaking structural revision, increment CACHE_NAME in public/sw.js (e.g., 'ypg-shell-v2' → 'ypg-shell-v3'). On next page load, the browser fetches /sw.js uncached, runs self.skipWaiting(), purges every old cache bucket (keys.filter((k) => k !== CACHE_NAME)), and claims active tabs cleanly.
  4. Persistent Volume Durability: Mount STORAGE_DIR onto a POSIX/NTFS volume supporting atomic same-filesystem rename(2) and fsync(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 in package.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, and tests/unit/ssr-seo-views.test.mjs:
  • Atomic JSON concurrent lock contention & Windows retry tests.
  • Linear-time O(N) gameSanitizer.mjs ReDoS timing, mXSS foreign SVG/MathML stripping, CSS3 <bad-url-token> scrubbing, ECMA-262 module healing, and V8 vm.Script validation.
  • Vertex AI 8-model clamping, thought-part filtering, and 45-minute gcloud CLI 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.mjs against an isolated temporary storageDir (zero mutation of live storage/), verifying end-to-end parity across Express 5 middleware, cookies, OAuth/test auth, ad-gate unlock, game synthesis, SSR HTML5 views, JSON-LD @graph validity, 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.mjs across Tiers 1–4) plus real headless Chromium desktop (1440x900) and mobile (390x844) screenshot capture and OOPIF YourPlaygroundSDK behavioral 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.png and docs/UI/Yapay Zekâ Evrenini Oyna ve Yarat-1.png.

Rung 5 — Untouched-Boundary & SHA-256 Provenance Audit

  • Verify git status cleanliness 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,971 bytes)
  • docs/UI/Yapay Zekâ Evrenini Oyna ve Yarat-1.png: 9941B38AA52EA25E4BA802F55F85E6FFD3AF49FC... (2,302,623 bytes)