mission smart ops

Guide for mission smart ops

Mission SMART-OPS: AI-Powered Player Support

Overview

Implemented an intelligent ticket management system for Game Masters and Support Agents. The system leverages Cloudflare Workers for AI processing (Gemini), Cloudflare D1 for active ticket storage, and CockroachDB for archival.

Architecture

  1. Ticket Intelligence (loh-cf-workers/ticket-api)
    • Worker: Handles CRUD for tickets, AI analysis, and archival cron jobs.
    • LLM Integration: Uses Gemini to auto-classify ticket severity (P0-P3) and recommend resolutions based on Ticket content + Player Context.
    • Storage: D1 (support_tickets, ticket_notes, ticket_activity).
    • Archival: Automated job moves closed tickets > 30 days to CockroachDB via loh-apis.
  2. Player Context (loh-apis)
    • Rust API: Aggregates player data from CockroachDB (players, users, stats).
    • Endpoint: GET /api/ops/support/player-context/:id
    • Archival: POST /api/ops/support/archive-tickets receives bulk tickets from the worker.
  3. Support UI (loh-ops-tools)
    • Dashboard: app/tools/tickets/page.tsx - List, filter, severity tracking.
    • Detail View: app/tools/tickets/[id]/page.tsx - Chat, Notes, AI Insights, Player Context side-panel.
    • RBAC: Restricted to SUPPORT, ADMIN, SUPER_ADMIN.

Changes

loh-ops-tools (Next.js)

  • [NEW] app/tools/tickets/page.tsx: Main dashboard.
  • [NEW] app/tools/tickets/[id]/page.tsx: Detailed ticket view.
  • [MODIFY] app/layout.tsx: Added "Tickets" to navigation.
  • [NEW] migrations/0006_support_tickets.sql: D1 Schema.

loh-cf-workers (Cloudflare Workers)

  • [NEW] ticket-api/: Full worker implementation.
    • src/index.ts: Main logic & cron.
    • src/analyze-ticket.ts: Classification logic.
    • src/recommend-fix.ts: RAG logic.
    • src/risk-score.ts: Risk assessment.

loh-apis (Rust)

  • [NEW] api-ops/src/handlers/support.rs: Handlers for context & archival.
  • [MODIFY] api-ops/src/handlers/mod.rs: Registered module.
  • [MODIFY] server/src/main.rs: Registered routes & initialized Redis (for AppState).
  • [NEW] migrations/20260117013500_create_archived_tickets.up.sql: DB Schema for archival.

Verification

  • Compilation:
    • loh-apis: cargo check -p api-ops -p server ✅ Passed.
    • loh-cf-workers: Checked logic manually, setup is standard.
    • loh-ops-tools: TypeScript code added, standard Next.js flow.
  • Unit Tests:
    • loh-apis: tests::support::test_player_context_serialization ✅ Passed.
    • loh-apis: tests::support::test_archived_ticket_structure ✅ Passed.

Next Steps for User

  1. Apply Migrations:
    • D1: cd loh-ops-tools && npm run db:migrate:local (or wrangler d1 migrations apply)
    • Backend: cd loh-backend/rust-engine && cargo run --bin migrate
  2. Deploy Worker:
    • cd loh-cf-workers/ticket-api
    • npm install
    • npx wrangler deploy
  3. Run Dev Servers:
    • Start loh-apis, loh-ops-tools and verify UI.