Sprint 20: The Shadow Logger & Diagnostic Observability
With our core game loop and economic mechanics locked down, Sprint 20 establishes a robust, enterprise-grade telemetry, audit, and diagnostic observability layer. This ensures absolute visibility into our high-velocity, serverless-deployed digital economy without introducing runtime latency.🛠 Context & Required Skills for AI Agents
When working inside this context:- Zero-Trust Administrative Claims: Administrative actions, such as fetching unredacted solution vectors, must never expose client-side Firestore rules bypasses. Rely on secure Express APIs that verify session-based administrative claims.
- Non-Blocking Observability: Diagnostic operations must execute asynchronously in the background. Never let telemetry operations delay or block the HTTP boundary handshake.
🗺 Sprint 20 Roadmap
[x] Phase 0: Database & Schema Provisioning
- Objective: Set up necessary database schema modifications to support admin flags and verbose log collection.
- Tasks:
- Added the
is_adminboolean column to thePlayerAccountPostgres model. - Programmatically provisioned the
VerboseDebugLogstable inside the Google Cloud BigQuery data warehouse.
- Added the
[x] Phase 1: The HTTP Boundary (Shadow Middleware)
- Objective: Establish global route request and response payload capturing.
- Tasks:
- Created global Express middleware
shadowLoggerto interceptreq.bodyand hookres.jsonpayloads. - Calculated exact route execution latencies using
process.hrtime()and emitted flat Newline Delimited JSON (NDJSON) with appropriate GCP severities.
- Created global Express middleware
[x] Phase 2: The Database Boundary (Prisma Hooking)
- Objective: Globally trace database query execution timings and queries.
- Tasks:
- Enforced a central Prisma client configuration with strict connection pool limits (
max: 1) suitable for serverless scale. - Built a global
$extendsquery hook to audit query timings and emit structured logs tostdout.
- Enforced a central Prisma client configuration with strict connection pool limits (
[x] Phase 3: The BigQuery Debug Sink
- Objective: Construct an asynchronous, non-blocking telemetry log pipeline.
- Tasks:
- Built background-scheduled
TelemetryQueueutilizing the BigQuery Storage Write API. - Added coordinate clamping breach checks that trigger
severity: "WARNING"anomaly logs. - Hooked unhandled route exceptions to stream error call-stacks with
severity: "ERROR"to BigQuery.
- Built background-scheduled
[x] Phase 4: Client-Side “God Mode” Overlay
- Objective: Provide administrative visual tools in the Arena while preserving zero-trust security.
- Tasks:
- Refactored
bouncer.jssession resolution to injectreq.isAdminclaims on authenticated request sessions. - Implemented secure API endpoint
GET /debate/admin-vectorsto fetch active News Stub solution coordinate shifts. - Developed and conditionally rendered the glassmorphic
<AdminDebugPanel />diagnostics overlay for authenticated administrators.
- Refactored