Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,99 @@
# Tasks: Wave C-3 — enhanced leaderboard + persistence + replay + tournament
## 0. Pre-flight
- [x] `pwd && git worktree list && git status` in isolated worktree.
- [x] §0a Sync: fast-forward worktree to genesis tip; confirm Wave-B
matchmaking/performance available.
- [x] Read CLAUDE.md, openspec/AGENTS.md, existing src structure.
- [x] Read upstream reference under
`/mnt/s/web/suaveplan/packages/universal/game-server/src/enhanced/`.
## 1. Error registry
- [x] Append 22 codes to `GAME_SERVER_CODES` (`LEADERBOARD_*`,
`PERSISTENCE_*`, `REPLAY_*`, `TOURNAMENT_*`, `INVALID_BRACKET_*`).
- [x] Extend `game-server-error.test.ts` with assertions on each new code.
## 2. Leaderboard
- [x] `leaderboard-manager.types.ts` — `RankingMode`, `LeaderboardConfig`,
`ScoreSubmission`, `LeaderboardEntry`, `LeaderboardManagerConfig`,
`LeaderboardStats`, Zod schemas.
- [x] `leaderboard-manager.ts` — multi-board manager with score/wins/elo,
ascending/descending, ranks, eviction, OTel counters, injectable
`Clock`.
- [x] `leaderboard-manager.test.ts` — 100% coverage incl. error paths.
- [x] `leaderboard-manager.md` — six sections, ≥200 words.
- [x] `index.ts` barrel.
## 3. Persistence
- [x] `game-persistence.types.ts` — `SaveMetadata`, `Snapshot`,
`HistoryEntry`, `SaveRecord`, `SaveResult`, `LoadResult`,
`GamePersistenceConfig`, `PersistenceStats`, Zod schemas.
- [x] `game-persistence.ts` — save / load / delete / snapshot / restore
via injectable `StorageLike`; OTel counters + histogram; injectable
`Clock` + `IdGenerator`.
- [x] `game-persistence.test.ts` — 100% coverage incl. corrupt data,
failing storage, history trim.
- [x] `game-persistence.md` — six sections, ≥200 words.
- [x] `index.ts` barrel.
## 4. Replay recorder
- [x] `replay-recorder.types.ts` — `RecordingStatus`, `RecordedInput`,
`RecordedSnapshot`, `ReplayMetadata`, `ReplayData`,
`ReplayRecorderConfig`, `RecordingStats`, Zod schemas.
- [x] `replay-recorder.ts` — start / pause / resume / tick / record /
stop with monotonic sequence, auto-snapshot interval, paused-time
accounting; injectable `Clock` + `IdGenerator`; OTel counters.
- [x] `replay-recorder.test.ts` — 100% coverage incl. buffer overflow
and FSM rejections.
- [x] `replay-recorder.md` — six sections, ≥200 words.
- [x] `index.ts` barrel.
## 5. Replay player
- [x] `replay-player.types.ts` — `PlaybackStatus`, `PlaybackSpeed`,
`PlaybackPosition`, `ReplayPlayerConfig`, Zod schemas.
- [x] `replay-player.ts` — tick-driven player with step / seek / speed,
snapshot-aware backward step, loop, observer listeners; OTel
counters.
- [x] `replay-player.test.ts` — 100% coverage incl. unloaded paths,
unsupported version, end-of-replay.
- [x] `replay-player.md` — six sections, ≥200 words.
- [x] `index.ts` barrel.
## 6. Tournament
- [x] `tournament-manager.types.ts` — `BracketType`, `TournamentStatus`,
`MatchStatus`, `Participant`, `Match`, `Round`, `Standing`,
`Tournament`, `TournamentConfig`, Zod schemas.
- [x] `tournament-bracket.internal.ts` — pure bracket-builders
(`buildSingleElim`, `buildRoundRobin`, `shuffleWithRng`,
`padToPowerOfTwo`, `roundName`).
- [x] `tournament-standings.internal.ts` — pure standings helpers
(`applyStanding`, `markEliminated`, `findMatch`,
`markRoundCompleteIfDone`).
- [x] `tournament-manager.ts` — register / start / record / cancel with
bye propagation, seeded shuffle via injectable `Rng`, injectable
`Clock` + `IdGenerator`, OTel counter.
- [x] `tournament-manager.test.ts` — 100% coverage via the public surface.
- [x] `tournament-manager.md` + `tournament-bracket.internal.md` +
`tournament-standings.internal.md` — six sections each, ≥200 words.
- [x] `index.ts` barrel.
## 7. Package surface
- [x] Extend `package.json` `exports` with five new subpath blocks.
- [x] No edits to `src/index.ts` (orchestrator wave consolidates).
## 8. Verification
- [x] `bunx turbo lint typecheck test --filter=@suaveplan/game-server` green.
- [x] `bunx turbo test:coverage --filter=@suaveplan/game-server` at
100/100/100/100 on touched modules.
- [x] Zero `from 'vitest'` / `from 'bun:test'` under
`src/enhanced/`.
- [x] Zero `biome-ignore` / `TODO` / `FIXME` / `XXX` under `src/enhanced/`.