Commit graph

10 commits

Author SHA1 Message Date
1978d3d421 docs(01-05): complete Blind Structure + Chip Sets + Templates plan
- SUMMARY.md with self-check passed
- STATE.md updated: plan 6 of 14, 36% progress, 4 decisions added
- ROADMAP.md updated: 5/14 plans complete
- REQUIREMENTS.md: 15 requirements marked complete (BLIND-01-06, CHIP-01-04, FIN-01,02,05,06,10)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 04:02:11 +01:00
7dbb4cab1a feat(01-05): add built-in templates, seed data, wizard tests, and template tests
- Built-in blind structures: Turbo (15min), Standard (20min), Deep Stack (30min), WSOP-style (60min, BB ante)
- Built-in payout structure: Standard with 4 entry-count brackets (8-20, 21-30, 31-40, 41+)
- Built-in buy-in configs: Basic 200 DKK through WSOP 1000 DKK with rake splits
- 4 built-in tournament templates composing above building blocks
- 005_builtin_templates.sql seed migration (INSERT OR IGNORE, safe to re-run)
- Wizard tests: standard, various player counts, denomination alignment, edge cases
- Template tests: create/expand/duplicate/save-as/delete-builtin/list

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:59:34 +01:00
dd2f9bbfd9 feat(01-03): implement PIN auth routes, JWT HS256 enforcement, and auth tests
- Add auth HTTP handlers (login, me, logout) with proper JSON responses
- Enforce HS256 via jwt.WithValidMethods to prevent algorithm confusion attacks
- Add context helpers for extracting operator ID and role from JWT claims
- Add comprehensive auth test suite (11 unit tests + 6 integration tests)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:59:05 +01:00
ae90d9bfae feat(01-04): add clock warnings, API routes, tests, and server wiring
- Clock API routes: start, pause, resume, advance, rewind, jump, get, warnings
- Role-based access control (floor+ for mutations, any auth for reads)
- Clock state persistence callback to DB on meaningful changes
- Blind structure levels loaded from DB on clock start
- Clock registry wired into HTTP server and cmd/leaf main
- 25 tests covering: state machine, countdown, pause/resume, auto-advance,
  jump, rewind, hand-for-hand, warnings, overtime, crash recovery, snapshot
- Fix missing crypto/rand import in auth/pin.go (Rule 3 auto-fix)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:56:23 +01:00
99545bd128 feat(01-05): implement building block CRUD and API routes
- ChipSetService with full CRUD, duplication, builtin protection
- BlindStructure service with level validation and CRUD
- PayoutStructure service with bracket/tier nesting and 100% sum validation
- BuyinConfig service with rake split validation and all rebuy/addon fields
- TournamentTemplate service with FK validation and expanded view
- WizardService generates blind structures from high-level inputs
- API routes: /chip-sets, /blind-structures, /payout-structures, /buyin-configs, /tournament-templates
- All mutations require admin role, reads require floor+
- Wired template routes into server protected group

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:55:47 +01:00
9ce05f6c67 feat(01-04): implement clock engine state machine, ticker, and registry
- ClockEngine with full state machine (stopped/running/paused transitions)
- Level management: load, advance, rewind, jump, hand-for-hand mode
- Drift-free ticker at 100ms with 1/sec broadcast (10/sec in final 10s)
- ClockRegistry for multi-tournament support (thread-safe)
- ClockSnapshot for reconnecting clients (CLOCK-09)
- Configurable overtime mode (repeat/stop)
- Crash recovery via RestoreState (resumes as paused for safety)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:51:07 +01:00
16caa12d64 feat(01-01): implement core infrastructure — NATS, LibSQL, WebSocket hub, HTTP server
- Embedded NATS server with JetStream (sync_interval=always per Jepsen 2025)
- AUDIT and STATE JetStream streams for tournament event durability
- NATS publisher with UUID validation to prevent subject injection
- WebSocket hub with JWT auth (query param), tournament-scoped broadcasting
- Origin validation and slow-consumer message dropping
- chi HTTP router with middleware (logger, recoverer, request ID, CORS, body limits)
- Server timeouts: ReadHeader 10s, Read 30s, Write 60s, Idle 120s, MaxHeader 1MB
- MaxBytesReader middleware for request body limits (1MB default)
- JWT auth middleware with HMAC-SHA256 validation
- Role-based access control (admin > floor > viewer)
- Health endpoint reporting all subsystem status (DB, NATS, WebSocket)
- SvelteKit SPA served via go:embed with fallback routing
- Signal-driven graceful shutdown in reverse startup order
- 9 integration tests covering all verification criteria

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:42:42 +01:00
0afa04a473 feat(01-02): implement migration runner with FTS5, seed data, and dev seed
- Statement-splitting migration runner for go-libsql compatibility
  (go-libsql does not support multi-statement Exec)
- FTS5 virtual table on player names with sync triggers
- Default seed data: DKK venue settings, Standard and Copenhagen chip sets
- Dev-only seed: default admin operator (PIN: 1234, bcrypt hashed)
- Dev mode flag (--dev) controls dev seed application
- First-run setup detection when no operators exist
- Single connection forced during migration for table visibility
- Idempotent: second startup skips all applied migrations

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:37:22 +01:00
af13732b2b feat(01-01): initialize Go module, dependency tree, and project scaffold
- Go module at github.com/felt-app/felt with go-libsql pinned to commit hash
- Full directory structure per research recommendations (cmd/leaf, internal/*, frontend/)
- Makefile with build, run, run-dev, test, frontend, all, clean targets
- LibSQL database with WAL mode, foreign keys, and embedded migration runner
- SvelteKit SPA stub served via go:embed
- Package stubs for all internal packages (server, nats, store, auth, clock, etc.)
- go build and go vet pass cleanly

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:34:44 +01:00
17dbfc6dc0 feat(01-02): design initial database schema migration
- 23 tables covering venue settings, chip sets, blind structures, payout structures,
  buy-in configs, tournament templates, tournaments, players, tables, seating,
  transactions, bubble prizes, audit trail, and operators
- All financial columns use INTEGER (int64 cents, never REAL/FLOAT)
- Audit trail append-only enforced by SQLite triggers (reject UPDATE except undone_by, reject DELETE)
- All tournament-specific tables reference tournament_id for multi-tournament support
- Comprehensive indexes on foreign keys and common query patterns
- Players table with UUID PK for cross-venue portability

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 03:31:01 +01:00