feat: implement CCW contests#14
Conversation
…e problem ids of solved questions
…g contestId and false WA verdicts
feat: CF Sync Engine & Validation Matrix (Stage 2) - CompleteResolves #5 OverviewThis PR implements the complete Codeforces Sync Engine and Validation Matrix as defined in Stage 2. It integrates perfectly with the Base Infrastructure and Redis Pub/Sub layers created in Stage 1 to provide a robust, rate-limited, and fault-tolerant submission validation backend for the Elite contests. Key Implementations 🚀
Testing & Verification ✅
Note for Handoff
|
Stage 3: The Room Engine (Blitz Format)OverviewStage 3 implemented the core real-time game loop for the Blitz contest format. It seamlessly connects MongoDB for persistent storage, Redis for high-speed ephemeral state tracking, BullMQ for background tasks, and Server-Sent Events (SSE) for real-time frontend updates. Key Components Implemented1. Room Creation (
|
Stage 4: Arena Format (Simultaneous Reveal & Atomic Claims)OverviewStage 4 introduces the Arena contest format. Unlike Blitz where problems are revealed sequentially, Arena reveals all problems simultaneously. It allows participants to independently choose which problem to tackle. To prevent race conditions when two players attempt to solve the same problem at the exact same time, a Lua-scripted atomic claim mechanism was integrated directly into Redis. Key Components Implemented1. Simultaneous Reveal & Initialization (
|
Stage 5: Team Multi-User Logic (1v1 & 3v3 Support)OverviewStage 5 introduces team-based multiplayer support for contest rooms. The architecture now supports both individual (1v1) and team (3v3) matches through a unified team abstraction layer. Teams coordinate via Redis Sets to ensure all members are ready before the room starts, and any team member's submission increments the shared team score. The implementation maintains complete backward compatibility with existing 1v1 functionality—internally, 1v1 matches are treated as 1-member teams. Key Components Implemented1. Team Size Validation & Flexible Configuration (route.ts)
2. Team-Based Ready Check Coordination (route.ts)
3. Team-Aware Score Aggregation (route.ts + cfSyncWorker.ts)
4. MongoDB Schema Extensions (ContestTeam.ts + ContestSubmission.ts)
5. Robust Error Handling & Authorization
Testing & Verification PerformedExecuted comprehensive test suites with all 24 critical tests passing (100% pass rate):
Bug Fixes & Improvements Applied✅ Fixed: ContestProblemSet Unique Index Conflict
✅ Fixed: BullMQ Invalid Job ID Format
✅ Fixed: Hardcoded Team Array Indices
✅ Fixed: Inflexible Room Validation
Backward Compatibility ✅
|
…ion wizard (Stage 6A) - Update Mongoose models (CustomContest, ContestPreset, ContestRoom, ContestRound, ContestStanding) to support bracket formats, description, team size constraints, and status states (draft, registration, active, completed). - Create administrative APIs for contest presets (/api/contests/presets) and specific preset interactions including retrieval, updates, and archival. - Build premium dark-themed preset management view (/admin/contests/presets) with functional modals for CRUD and archiving. - Implement multi-step Tournament Creation Wizard (/admin/contests/new) with step validation server actions and a live progress tracker. - Design Solo/Team registration API endpoint (/api/contests/[id]/register) that performs validation checks and triggers background solved history prefetching. - Create status transition API endpoint (/api/contests/[id]/status) to manage the tournament state chain and emit updates via SSE. - Setup a prefetch worker job handler in cfSyncWorker.ts to resolve Codeforces solved lists in the background. - Integrate preset management and tournament wizard cards directly onto the Admin dashboard home page (/admin). - Add automated verification test script (scripts/test-stage6a.ts) covering the test plan gates. - Resolve Next.js 15+ dynamic route signature compatibility and parameter types.
Stage 6A ImplementationResolves #9 1. Schema & Model Enhancements
2. API Endpoints
3. UI Component Additions
4. Background Workers & Verification
|
- Bracket generation (generateBracket) with seeding, bye handling, round/room creation - Bracket advancement (advanceWinner) with auto-seeding to next round - Round completion detection (checkRoundCompletion) with SETNX race lock - Manual walkover (processWalkover) with audit trail - Bracket snapshot (getBracketSnapshot) for SSE broadcast - API routes: POST /api/contests/:id/bracket/generate, POST /api/contests/rooms/:id/walkover - Reconciliation worker bracket advancement hook - ContestRoom 'pending' status for empty bracket room slots - CustomContest winnerName field for display
closes #4
STAGE1_DONE.md
pr_description.md