Commit graph

17 commits

Author SHA1 Message Date
75ccb6f735 feat(01-09): implement tournament lifecycle, multi-tournament, ICM, and chop/deal
- TournamentService with create-from-template, start, pause, resume, end, cancel
- Auto-close when 1 player remains, with CheckAutoClose hook
- TournamentState aggregation for WebSocket full-state snapshot
- ActivityEntry feed converting audit entries to human-readable items
- MultiManager with ListActiveTournaments for lobby view (MULTI-01/02)
- ICM calculator: exact Malmuth-Harville for <=10, Monte Carlo for 11+ (FIN-11)
- ChopEngine with ICM, chip-chop, even-chop, custom, and partial-chop deals
- DealProposal workflow: propose, confirm, cancel with audit trail
- Tournament API routes for lifecycle, state, activity, and deal endpoints
- deal_proposals migration (007) for storing chop proposals

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 07:58:11 +01:00
8b4b131371 feat(01-07): add player API routes, ranking tests, CSV export safety
- PlayerHandler with all CRUD routes and tournament player operations
- Buy-in flow: register + financial engine + auto-seat suggestion
- Bust flow: hitman selection + bounty transfer + re-ranking
- Undo bust with full re-ranking and rankings response
- Rankings API endpoint returning derived positions
- QR code endpoint returns PNG image with Cache-Control header
- CSV import via multipart upload (admin only)
- Player merge endpoint (admin only)
- CSV export safety: formula injection neutralization (tab-prefix =,+,-,@)
- Ranking tests: bust order, undo re-ranking, early undo, re-entry,
  deal positions, auto-close, concurrent busts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 04:35:05 +01:00
93736287ae feat(01-07): implement player CRUD, search, merge, CSV import, QR codes
- PlayerService with CRUD, FTS5 typeahead search, duplicate merge, CSV import
- CSV import safety limits: 10K rows, 20 columns, 1K chars/field
- QR code generation per player using skip2/go-qrcode library
- Tournament player operations: register, bust, undo bust
- TournamentPlayerDetail with computed investment, net result, action history
- RankingEngine derives positions from ordered bust-out list (never stored)
- RecalculateAllRankings for undo consistency
- All mutations record audit entries and broadcast via WebSocket

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 04:32:13 +01:00
2d3cb0ac9e feat(01-08): implement balance engine, break table, and seating API routes
- TDA-compliant balance engine with live-adaptive suggestions
- Break table distributes players evenly across remaining tables
- Stale suggestion detection and invalidation on state changes
- Full REST API for tables, seating, balancing, blueprints, hand-for-hand
- 15 tests covering balance, break table, auto-seat, and dealer button

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 04:24:52 +01:00
56a7ef1e31 docs(01-13): complete Layout Shell plan
- SUMMARY.md with all accomplishments and deviation documentation
- STATE.md updated: plan 8/14, 50% progress, decisions, session
- ROADMAP.md updated: 7/14 plans complete
- REQUIREMENTS.md: UI-01 through UI-04, UI-07, UI-08 marked complete

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 04:15:37 +01:00
51153df8dd feat(01-06): implement financial transaction engine
- ProcessBuyIn with late registration cutoff and admin override
- ProcessRebuy with limit, level/time cutoff, and chip threshold checks
- ProcessAddOn with window validation and single-use enforcement
- ProcessReEntry requiring busted status with player reactivation
- ProcessBountyTransfer with PKO half-split and fixed bounty modes
- UndoTransaction reversing all financial effects
- IsLateRegistrationOpen checking both level AND time cutoffs
- GetSeasonReserves for season withholding tracking
- Rake split transactions per category (house, staff, league, season_reserve)
- Full audit trail integration for every transaction
- WebSocket broadcast for real-time updates
- 14 passing tests covering all flows

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 04:11:58 +01:00
e947ab1c47 feat(01-08): implement table management, auto-seating, blueprints, and hand-for-hand
- TableService with CRUD, AssignSeat, AutoAssignSeat (fills evenly), MoveSeat, SwapSeats
- Dealer button tracking with SetDealerButton and AdvanceDealerButton (skips empty seats)
- Hand-for-hand mode with per-table completion tracking and clock integration
- BlueprintService with CRUD, SaveBlueprintFromTournament, CreateTablesFromBlueprint
- Migration 006 adds hand_for_hand_hand_number and hand_completed columns

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 04:10:28 +01:00
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