Commit Graph
100 Commits
Author SHA1 Message Date
DorianandClaude Opus 4.6 8e9285cd50 fix: add missing bets table to migration
The bets schema was defined in schema.ts but never created in
startup.ts, causing crash on index creation referencing bets table.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:32:08 +00:00
DorianandClaude Opus 4.6 3c95adb545 feat: convert all human fights to multiple choice, remove text input
Creative challenges (roast_battle, creative_writing, meme_war,
code_golf, wrestling_match) now auto-generate multiple choice options
from per-type response pools: 1 good answer + 3 weaker distractors.
The free text input UI is commented out but preserved for future use.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:28:22 +00:00
DorianandClaude Opus 4.6 4dc350dc9e test: verify narration variety — no repeats within 5-round fights
Runs 100 simulated fights and verifies 80%+ have zero repeated
narrations across 5 rounds.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:24:42 +00:00
DorianandClaude Opus 4.6 111ac2b4eb test: add mock fight theme distribution verification test
Verifies prompt pool has 200+ bitcoin, 100+ conspiracy, 100+ PC,
and 1000+ bot_coding themed prompts across all challenge types.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:24:08 +00:00
DorianandClaude Opus 4.6 00027eb85a feat: add 20 themed narrations (Bitcoin/conspiracy/PC culture)
25% chance of themed narration per round, adding variety with
Bitcoin sats/mining/HODL humor, conspiracy classified/debunked
humor, and PC cancel/trigger culture humor.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:22:55 +00:00
DorianandClaude Opus 4.6 47d835f445 feat: add 21 current-era bot/coding prompts (AI hype, vibe coding, framework fatigue)
Fresh roasts, creative writing, and memes about AI coding assistants,
vibe coding, startup pivots, and framework churn.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:21:41 +00:00
DorianandClaude Opus 4.6 5ee6b6c88c fix: fight restart bug, mobile TTS, character sizing, bitcoin symbols
- Fix fight replay showing empty scene: validate rounds before playing,
  retry loading fight data up to 5 times when rounds are missing
- Add COOP/COEP headers to production server for SharedArrayBuffer
  (required by Kokoro TTS WASM threading on mobile)
- Add blob: to scriptSrc/workerSrc CSP for Web Worker support
- Fix mobile character cutoff: raise ground line to 0.82, add
  MOBILE_SCALE_CAP (0.55) so fighters never shrink too small
- Add ₿ bitcoin chest badge to all fighter sprites (scales with tier)
- Add sats coin stack on bot profile page proportional to satsWon
- Seed dev tournament with 8 mock bots on startup (dev mode only)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:21:16 +00:00
DorianandClaude Opus 4.6 a10c1c9cb6 feat: add 112 PC culture-themed prompts across all 16 challenge types
Satirical and irreverent — cancel culture, DEI absurdity, trigger
warnings, virtue signaling, safe spaces. Mocking the absurdity,
never punching down.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:20:10 +00:00
DorianandClaude Opus 4.6 bec75e0e82 feat: add 112 conspiracy-themed prompts across all 16 challenge types
Satirical and fun conspiracy culture humor — MK-Ultra, Area 51,
flat earth, tinfoil hats, Bigfoot, UFOs, surveillance. Never endorsing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:17:47 +00:00
DorianandClaude Opus 4.6 7d699b2ed3 feat: add 160 Bitcoin-themed prompts across all 16 challenge types
10 prompts per type covering Bitcoin history, mining, Lightning,
privacy, culture, memes, riddles, and technical knowledge.
Total prompts: 1,485 (253 Bitcoin-themed).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:15:31 +00:00
DorianandClaude Opus 4.6 cb5e5a1cc9 test: add theme selection and prompt tagging verification tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:11:08 +00:00
DorianandClaude Opus 4.6 0c6a775e30 feat: tag all 1,325 prompts with theme (bitcoin/conspiracy/pc_culture/bot_coding)
93 bitcoin, 2 conspiracy, 1 pc_culture, 1,229 bot_coding.
Most existing prompts are tech/general knowledge (bot_coding).
Theme-aware pickChallenge now has data to filter on.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:10:12 +00:00
DorianandClaude Opus 4.6 070e41f97b test: verify all factual answers work with checkAnswer, fix 2 data bugs
- Hash rate question: added ×10^20 notation to answers array
- Phishing question: added correct MC choice text to answers array
- New tests: self-match, case-insensitive, MC correctness validation

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:07:17 +00:00
DorianandClaude Opus 4.6 a4b4963c32 feat: add difficulty field to prompts and wire into fight pacing
Round 1-2 picks easy prompts, 3-4 medium, 5+ hard (when tagged).
Graceful fallback to any prompt when no difficulty-tagged prompts exist.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:05:21 +00:00
DorianandClaude Opus 4.6 8d0eb4b5f9 feat: add narrations for all 16 challenge types, eliminate generic fallback
Add dedicated narrations for: magic_duel, sports_showdown, vehicle_mayhem,
nature_clash, animal_kingdom, hack_battle (6 per type, 36 new narrations).
All 16 challenge types now have themed narrations — no generic fallback needed.
Add narration variety test verifying >1 unique narration per type.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 08:00:06 +00:00
DorianandClaude Opus 4.6 3b863d1f5f feat: add theme system, improve creative scoring spam detection
Theme system (Section 5.1):
- Add PromptTheme type ('bitcoin' | 'conspiracy' | 'pc_culture' | 'bot_coding')
- Add optional theme field to PromptEntry interface
- pickChallenge now accepts optional theme bias, picks target theme with
  30/20/20/30 distribution, prefers themed prompts when available
- challenges-extra.ts now imports PromptEntry type from challenge-data.ts

Creative scoring improvements (Section 7.2):
- Detect repeated phrases via trigram analysis (>25% duplicate = spam)
- Detect question echo (answer copies prompt back)
- Detect all-caps spam (>80% uppercase letters)
- Detect punctuation-only spam (<30% letter content)
- Minimum word count threshold (< 3 words = low score)
- 5 new tests: repeated phrases, question echo, all-caps, short answer, legit short

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 07:56:51 +00:00
DorianandClaude Opus 4.6 2ceef08f55 feat: add CI workflow, lifecycle integration tests, and mark completed plan items
- Add GitHub Actions CI: test, typecheck, lint on push/PR to main
- Add fight lifecycle integration tests: full pipeline, ELO advantage,
  combo scaling, type exhaustion, answer verification (7 tests)
- Kaplay already lazy-loaded via route-level code splitting
- Total: 135 tests across 7 test files

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 07:53:40 +00:00
DorianandClaude Opus 4.6 4074ef94eb feat: add leaderboard cache, performance benchmarks, and verify SSE cleanup
- Add 30s TTL leaderboard cache with invalidation on fight completion
- Add scoreRound performance benchmark: 1000 rounds in <100ms
- Add checkAnswer performance benchmark: 1000 checks in <50ms
- Add adversarial regex backtracking test for checkAnswer
- Verify SSE cleanup: connections, IP counters, spectator counts, event listeners
  all properly decremented in finally block on disconnect

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 07:50:46 +00:00
DorianandClaude Opus 4.6 7d9b8b1dbf chore: add ESLint with no-floating-promises and no-console rules
Sets up ESLint 10 flat config with @typescript-eslint/no-floating-promises (error)
and no-console (warn, allow warn/error). Fixes all floating promise errors in
server routes, orchestrator reader cleanup, and frontend composables with void operator.
Game engine files get warning-level for intentional fire-and-forget async.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 07:47:43 +00:00
DorianandClaude Opus 4.6 5007d009fe test: add unit tests for challenge distribution, ranked challenges, answer edge cases, and mock bot coverage
Covers plan section 4.1: pickChallenge 70/30 distribution, pickRankedChallenge never returns choices,
True/False auto-generation, special characters and long answers, all 16 challenge types produce valid
mock responses, and timeout/error answer verification. 113 → 125 tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 07:42:55 +00:00
DorianandClaude Opus 4.6 46d560af24 fix: replace TTS FIFO cache with LRU eviction, add database indexes
TTS audioCache now tracks lastAccess timestamp per entry and evicts
the least-recently-used entry when full (was FIFO, deleting commonly
used phrases). Adds 6 new database indexes for bets, bot type/active
filtering, payment status lookups, and tournament entries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 07:38:04 +00:00
DorianandClaude Opus 4.6 fbc61ef154 fix: add amount validation for zap and bet endpoints
Validate amountSats is a positive integer (1–1,000,000) on both
/zap and /bets/place endpoints to prevent negative, zero, or
absurdly large amounts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 07:34:51 +00:00
DorianandClaude Opus 4.6 5bfb63aa7f fix: add input validation, Zod schemas, rate limiting, and IP trust
- Add Zod schema for webhook response parsing (orchestrator.ts)
- Add Zod schemas for POST /respond and /react request bodies
- Add safe integer validation for batch count param
- Prefer cf-connecting-ip over spoofable x-forwarded-for
- Add ID format validation on URL params
- Add rate limiting on /auth/login (30/min) and /update (10/min)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 07:30:49 +00:00
DorianandClaude Opus 4.6 276cbd6e31 refactor: replace all hardcoded numbers in scoring.ts with named constants
All magic numbers in scoring.ts now reference constants from
lib/constants.ts: damage multipliers, score thresholds, quality
parameters, narration margins, and rounding factors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 07:26:50 +00:00
DorianandClaude Opus 4.6 1d6826c6e2 test: update arena count assertion from 25 to 40
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 07:21:19 +00:00
DorianandClaude Opus 4.6 7b82803868 fix: allow Google Fonts in CSP so 3D announcement font loads in production
fontSrc blocked fonts.gstatic.com and styleSrc blocked fonts.googleapis.com,
causing Honk font to fail in production. The chromatic aberration pseudo-elements
then appeared as doubled plain text instead of a styled 3D effect.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 07:18:57 +00:00
DorianandClaude Opus 4.6 2f7c10e4b8 fix: defer analytics prepared statements to avoid crash before migrations
The sqlite.prepare() calls ran at module import time, before
runMigrations() created the analytics table, causing a crash loop.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 01:05:47 +00:00
DorianandClaude Opus 4.6 f964274c02 test: payments launch checklist passed
- Added 'consumed' to payment status enum (was missing from schema)
- Fixed orphan recovery to also find 'consumed' payments on restart
- Verified: NWC + Lightning Address wallet connect, invoice creation,
  21-sat entry fee, 42-sat winner payout, Cashu tokens, bet settlement,
  refund on cancelled/timeout, stuck payment recovery

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:43:16 +00:00
DorianandClaude Opus 4.6 69601cce3a feat: automated backup and production monitoring
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:33:35 +00:00
DorianandClaude Opus 4.6 d7d04eb2d7 test: load testing script
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:30:43 +00:00
DorianandClaude Opus 4.6 627a1a0d9e perf: CDN-ready caching headers and compression
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:24:48 +00:00
DorianandClaude Opus 4.6 8be71e9929 fix: admin and docs bugs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:20:00 +00:00
DorianandClaude Opus 4.6 c654ff9f73 feat: interactive bot developer documentation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:18:06 +00:00
DorianandClaude Opus 4.6 e10c1dc8aa feat: privacy-respecting analytics
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:15:20 +00:00
DorianandClaude Opus 4.6 2170e9275c feat: admin dashboard for THE CREATOR
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:12:36 +00:00
DorianandClaude Opus 4.6 e3a4299dae perf: server memory leak audit
Add periodic cleanup of fightReactions Map (clears when >100 entries).
Add RSS/heap logging every 10 fights in fight-loop for memory monitoring.
Set --max-old-space-size=256 in Docker CMD as safety net.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:05:03 +00:00
DorianandClaude Opus 4.6 c8e4fa7a95 perf: SQLite WAL mode and indexes
Add PRAGMA synchronous=NORMAL, temp_store=MEMORY, mmap_size=256MB for
better write throughput and query performance. Create 11 indexes on
commonly queried columns (fights.status, fights.created_at, bots.elo,
rounds.fight_id, payments, tournament_matches). Run PRAGMA optimize
on startup for query planner statistics.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09 00:02:47 +00:00
DorianandClaude Opus 4.6 d8e43d6843 fix: enforce webhook response size limits via named constants
readLimitedBody already enforces 10KB body limit. Answer truncation
(2000 chars) and trash_talk truncation (200 chars) now reference
named constants from lib/constants.ts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 23:40:17 +00:00
DorianandClaude Opus 4.6 7c8e404cf1 refactor: extract magic numbers to named constants
Frontend: choreography selection ratios, morph trigger chances,
creator cameo/ultimate chances, dodge/counter probabilities.
Server: HP, K-factors, Elo divisor, tier thresholds, fight loop interval.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 23:34:05 +00:00
DorianandClaude Opus 4.6 7de503a487 refactor: explicit return types on all public functions
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 21:48:22 +00:00
DorianandClaude Opus 4.6 8d93abf36d refactor: separate challenge data from challenge logic
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 21:45:20 +00:00
DorianandClaude Opus 4.6 4d1e592365 refactor: standardize error handling with toError() helper
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 21:44:17 +00:00
DorianandClaude Opus 4.6 ea716c1f0e refactor: extract pick() helper, deduplicate random selection
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 21:42:11 +00:00
DorianandClaude Opus 4.6 9de36a9349 feat: 15 Bitcoin-themed arenas (40 total)
bitcoin_mine, lightning_node, satoshis_garage, mempool, silk_road_ruins,
block_height_tower, hodl_cave, whale_pool, node_farm, genesis_block,
pizza_day_parlor, difficulty_adjustment, fifty_one_percent,
timechain_temple, nostr_relay_room. Each with unique theme colors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 21:22:37 +00:00
DorianandClaude Opus 4.6 fbaeeb5f93 feat: scale to 1,330 challenge prompts
Add 526 new prompts across all 16 challenge types with heavy
Bitcoin/cypherpunk themes. Factual types include multiple-choice
options. Separate file for maintainability, merged at runtime.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 21:14:26 +00:00
DorianandClaude Opus 4.6 d0f3780518 feat: scheduled daily and weekly tournaments
Lightning Round (daily 8-bot at noon UTC) and The Halvening
(weekly 32-bot Saturday 20:00 UTC). Auto-fills with mock bots,
runs matches via background loop.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 21:02:42 +00:00
DorianandClaude Opus 4.6 b70c49075e feat: tournament API routes
POST /api/tournaments (create, admin-only),
POST /api/tournaments/:id/join, POST /api/tournaments/:id/start,
GET /api/tournaments (list), GET /api/tournaments/:id (bracket).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:58:23 +00:00
DorianandClaude Opus 4.6 c0978ba4c8 feat: tournament engine with single-elimination brackets
Create, join, seed by Elo, generate bracket matches with byes,
advance rounds on fight completion, finish tournament on champion.
Wire into orchestrator fight finalization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:57:23 +00:00
DorianandClaude Opus 4.6 4dfa49c036 feat: tournament DB schema
Add tournaments, tournament_entries, and tournament_matches tables
with Drizzle ORM definitions and SQLite CREATE TABLE migrations.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:54:44 +00:00
DorianandClaude Opus 4.6 38f94c2955 perf: SSE connection pooling and cleanup
Add per-IP SSE connection limit (max 5 concurrent streams). Track
activeSSECount and ssePerIp maps with proper decrement in finally
blocks. Export getActiveSSECount() for admin stats. Change heartbeat
ping from 5s to 15s interval. Connections already clean up on client
disconnect via Hono's streamSSE try/catch/finally pattern.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:49:56 +00:00