Skip to content

Fix tournament bracket corruption after started mutations - #19

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-268b
Draft

Fix tournament bracket corruption after started mutations#19
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-correctness-bugs-268b

Conversation

@cursor

@cursor cursor Bot commented May 24, 2026

Copy link
Copy Markdown

Bug and impact

  • Editing a completed earlier category knockout match could reset its direct child but leave deeper completed matches (for example the final/champion) intact with stale winners, corrupting persisted bracket results.
  • Several destructive roster/group write paths still allowed changes after tournament start: single guest deletion, new team creation, group rebalance, and team group changes. These could desync teams, entries, classification matches, standings, and fixtures mid-event.

Root cause

  • recomputeCategoryBracketAfterWinnerChange built the completed-match winner map once, so downstream matches continued to trust winners from matches that were being reset in the same operation.
  • Recent started guards were applied to sibling endpoints but not to all write paths that mutate teams/entries/group assignments.

Fix

  • Recompute category bracket invalidation to a fixed point, excluding already-invalidated matches from winner/loser maps before applying resets and slot updates.
  • Block post-start group rebalance/team creation/team group changes/single guest deletion with the existing tournament-started invariant, plus a defensive match-lock check in rebalance.
  • Add regression tests for transitive bracket reset and rebalance start guard.

Validation

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

Co-authored-by: Octavio Frangipani <octapf@users.noreply.github.com>
@vercel

vercel Bot commented May 24, 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 24, 2026 10:41am

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