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