Skip to content

Fix tournament bracket and group state corruption - #17

Draft
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-correctness-bugs-0064
Draft

Fix tournament bracket and group state corruption#17
cursor[bot] wants to merge 2 commits into
mainfrom
cursor/critical-correctness-bugs-0064

Conversation

@cursor

@cursor cursor Bot commented May 21, 2026

Copy link
Copy Markdown

Bug and impact

  • Editing a completed early-round category knockout match could reset only the directly affected match while leaving completed downstream rounds with stale teams/winners, corrupting bracket state in deeper brackets.
  • Group rebalancing and direct groupIndex team updates remained possible after tournament play had started or matches were already live/completed, desynchronizing team group assignments from already-generated classification matches and corrupting standings/category seeding.

Root cause

  • recomputeCategoryBracketAfterWinnerChange computed winner/loser feeders from a single snapshot and did not invalidate winners for matches reset during the same recomputation pass.
  • rebalanceTournamentTeams and the team PATCH handler lacked the same post-start/locked-match guards used by group randomization.

Fix

  • Recompute category bracket resets iteratively so resetting one match removes its winner/loser as valid inputs and propagates invalidation through all downstream dependents.
  • Block group rebalancing once the tournament has started or any match is in progress/completed, and return a 400 response for rejected rebalance actions.
  • Block team groupIndex PATCH changes after tournament start.
  • Added focused regression tests for transitive bracket reset propagation and rebalance start/locked-match guards.

Validation

  • npm test -- --run tests/knockoutAdvance.test.ts tests/rebalanceTournamentTeams.test.ts
  • npm test
  • npm run typecheck
  • npm run lint (passes with existing warnings)
Open in Web View Automation 

cursoragent and others added 2 commits May 21, 2026 10:08
Co-authored-by: Octavio Frangipani <octapf@users.noreply.github.com>
Co-authored-by: Octavio Frangipani <octapf@users.noreply.github.com>
@vercel

vercel Bot commented May 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
matchpoint Ready Ready Preview, Comment May 21, 2026 11:14am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant