Commit Graph
82 Commits
Author SHA1 Message Date
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
DorianandClaude Opus 4.6 d98b264935 fix: bound rate limiter maps to prevent memory growth
Add MAX_MAP_SIZE (10,000) cap to botHitCounts Map. During the 5-minute
cleanup interval, evict oldest entries when the map exceeds the limit.
Export cleanupInterval handle for graceful shutdown.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:41:57 +00:00
DorianandClaude Opus 4.6 f62323c59f refactor: structured logging across server
Create server/src/lib/logger.ts with info/warn/error methods that add
[botfights:tag] timestamps. Replace bare console.log/warn/error calls
in index.ts, seed.ts, routes/fights.ts, engine/queue.ts, engine/mock.ts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:41:23 +00:00
DorianandClaude Opus 4.6 7bd110684d fix: track and clear all intervals and event listeners
- FightPage.vue: store SSE listener refs in array, removeEventListener
  on each before close() in disconnectSSE()
- FightScene.ts: add cleanupTimers Set with trackedInterval/trackedTimeout
  helpers; replace key setInterval calls (projectile trails, entrance
  flames, talking animation, exhaust effects, dimensional shift, hole
  fade) with tracked versions; clear all on scene destroy()
- rate-limit.ts: export cleanupInterval handle for graceful shutdown

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:39:11 +00:00
DorianandClaude Opus 4.6 010e18fbd3 refactor: eliminate any types across server and TTS worker
- app.ts: type serveFile context parameter as Hono Context
- bets.ts: replace catch(err: any) with err: unknown + narrowing
- fight-loop.ts: type pickMatchup style as union literal, replace
  as any casts with proper result type
- tts-worker.ts: import KokoroTTS type, use ProgressInfo inference

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:34:11 +00:00
DorianandClaude Opus 4.6 156c727f82 feat: ranked queue Elo-bracket matchmaking and harder prompts
Elo-bracket matchmaking: prefer ±200, widen by 100 every 15s of waiting.
Add pickRankedChallenge() that filters to creative/open-ended only, never
multiple choice. Show ranked queue status, wait estimate, and "HARDER
PROMPTS" notice on JoinBoutPage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:18:23 +00:00
DorianandClaude Opus 4.6 e229bfb8fc feat: season leaderboard with toggle and countdown
Add GET /api/bots/leaderboard?season=current endpoint. LeaderboardPage
now toggles between "This Season" and "All Time" views. Shows season
name, countdown timer, and top 3 placement badges.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:16:04 +00:00
DorianandClaude Opus 4.6 ecac2bf246 feat: season framework with 2-week auto-rotation
Create seasons engine with getCurrentSeason(), getSeasonLeaderboard(),
and resetSeasonElo(). 20 Bitcoin-themed season names. Add currentSeason
column to fights table, set on fight creation. Elo soft-reset formula:
finalElo * 0.6 + 1200 * 0.4.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:13:44 +00:00
DorianandClaude Opus 4.6 d22d739666 feat: zap the winner button with lightning animation
Add ZAP WINNER button in FightViewer after fight ends. Server endpoint
POST /api/payments/zap increments zapsReceived on winner bot. Show zap
count on bot profile page. Add zaps_received column with migration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:10:46 +00:00
DorianandClaude Opus 4.6 d1fe4d6e83 feat: Nostr profile enrichment with caching
Fetch full kind:0 metadata (display_name, about, banner, nip05) from
relays with a 5-min TTL cache. Show Nostr banner, display name, and
NIP-05 on bot profile pages. Expose ownerPubkey in stats API.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:07:09 +00:00
DorianandClaude Opus 4.6 7761f713d7 feat: publish notable fight results to Nostr relays
NIP-01 kind:1 notes posted for KOs, perfects, upsets, and big Elo
swings. Includes bot names, Elo changes, arena, and replay link.
Configurable via BOTFIGHTS_NOSTR_RELAYS and BOTFIGHTS_NOSTR_NSEC env
vars. Silently skips if NSEC not set.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 20:01:11 +00:00
DorianandClaude Opus 4.6 005a7942fb feat: wire bet settlement into fight finalization
Lock bets when fight goes live, settle all bets atomically when fight
ends. Winners get Cashu payout tokens, losers forfeit. Draws refund
all bets. Settlement results persisted to bets table.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 19:57:00 +00:00
DorianandClaude Opus 4.6 fd22b126e7 feat: spectator reactions with floating emoji particles
POST /api/fights/:fightId/react endpoint accepts emoji reactions (fist,
fire, skull, 100, clown), aggregates counts, broadcasts via SSE.
Reaction bar added to FightViewer with floating emoji particles that
rise and fade. Live fight views receive reactions via SSE in real-time.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 19:51:13 +00:00
DorianandClaude Opus 4.6 610e799605 feat: SSE live fight spectating with spectator count
Enable real-time fight spectating for all live fights (not just human
fights). Multiple spectators can watch simultaneously via SSE. Spectator
count is tracked per-fight and broadcast with every SSE event.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 19:46:39 +00:00
DorianandClaude Opus 4.6 e12fb94ae7 feat: omni-morph sprite swap, bullet time showboats, music tuning, server hardening
- Creator omni-morph now generates actual sprite sheets for morphed archetypes
- 3 new Creator showboats: bullet time attack, ₿ throne summon, disco dance
- Music: subtle tempo shift (+10 BPM max), longer phrases (8/16/24 bars),
  smoother crossfades, less chaotic hi-hat at high intensity
- Server: security headers, body size limit, production error masking,
  CORS origin warning, graceful shutdown with drain
- Payments: atomic consume (eliminates SELECT/UPDATE race), release reverts DB
- Fight loop: round events for live TUI, retro displayPrompt
- Frontend: pass pubkey in payment/queue requests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 16:23:47 +00:00
DorianandClaude Opus 4.6 9287fd1783 fix: TTS sentence cutoff + simplified retro challenge prompt
TTS fixes:
- Remove 60-char truncation in FightViewer — let speakAnswer handle limits
- Smart truncation at sentence boundaries (period, comma, etc.) up to 200 chars
- Chrome keepalive: periodic pause/resume prevents silent 15s cutoff bug
- Deduplicated cleanup logic in speakAsync/speakAsyncWithRate

Retro mode:
- Simplified challenge prompt from verbose wall of text to clean 3-line format

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 15:32:29 +00:00
DorianandClaude Opus 4.6 da14ca81ee security: redact hidden retro combos from all public docs
Remove all super/ultra combo inputs, exact damage values, discovery
multiplier (1.5x), and Konami Code from BOT_SETUP.md, bot-guide.md,
docs.ts API, and example bot. Bots now only see basic/standard moves
and must discover hidden combos through experimentation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 14:54:54 +00:00
DorianandClaude Opus 4.6 f1fe798442 docs: add retro mode docs, bot guide, sprite guide
Update BOT_SETUP.md with full retro mode combo reference, scoring,
and strategy tips. Add docs/bot-guide.md as a standalone developer
guide covering all challenge types including retro mode. Add
docs/sprite-guide.md and sprite-reference.html for custom sprite
creation. Update docs.ts API endpoint and Python example bot with
retro_mode handling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 14:43:34 +00:00
DorianandClaude Opus 4.6 1f8e8569ef feat: retro mode — arcade combo round with gamepad overlays
Every fight now includes one Retro Mode round where bots submit
gamepad combo inputs (↑↓←→ A B). 24 moves across 4 tiers: basic
(always shown), standard (partially revealed), super (must discover),
and ultra (KONAMI CODE for 50 dmg). Discovery bonus gives 1.5x damage.

Includes pixel-art gamepad overlays (P1/P2) with animated button
presses, retro-specific narrations, and mock bot combo responses
scaled by ELO.

Also adds loops/plan.md with 11-phase production hardening roadmap.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 14:13:47 +00:00