brackt/app/lib
Claude 75960a8826
All checks were successful
🚀 Deploy / 🧪 Test (pull_request) Successful in 3m5s
🚀 Deploy / ʦ🔍 Typecheck & Lint (pull_request) Successful in 1m20s
🚀 Deploy / 🐳 Build (pull_request) Has been skipped
🚀 Deploy / 🚀 Deploy (pull_request) Has been skipped
Fix review findings in the tie-split ledger and backfill
A review of the previous two commits found five defects in the new ledger
writer and backfill, plus one pre-existing scoring bug the refactor
exposed.

season_standings ties were never split. processSeasonStandings
deliberately writes the same finalPosition to every driver in a tied group
-- its comment says "the scoring system will handle averaging" -- but no
path ever did, so two drivers tied for 3rd each banked the full 50 instead
of the published 45. This predates the tie-split work; the original
cascade had only bracket and qualifying_points arms. Introduce
usesSharedPlacementSplit as the single definition of which patterns record
ties as a repeated placement, and route both calculatePickPoints and every
caller-side gate through it. The caller gates matter as much as the
helper: a gate left hardcoded to qualifying_points silently passes a tie
count of 1, which reads as "no tie" and makes the fix inert.

The ledger anchor picked the wrong event. Ordering on completedAt with no
isComplete filter ranked never-completed events first, because drizzle's
desc() emits a bare desc and Postgres orders DESC as NULLS FIRST.
Restrict to completed events and order explicitly with NULLS LAST plus a
stable tiebreak. The anchor is also no longer load-bearing for
idempotence: stale event-level rows for the sports season are cleared
before writing, so a re-run whose anchor moved replaces rather than
duplicates.

A ledger failure could abort finalization. The call sat unguarded after
the season was already marked completed, so a throw in any of its queries
would skip the standings recalculation and the Discord notification. Guard
both call sites the way the probability refresh directly below already is.

Rows could be mislabelled permanently. The backfill passed no eventName,
and the upsert never rewrote scoringEventName. Derive the label from the
scoring pattern inside the writer so omitting it is impossible, and
refresh it on conflict so existing rows can be repaired.

The backfill damaged unrelated leagues. recalculateStandings rewrites
previousRank, so sweeping every season wiped rank-movement arrows league
wide, including leagues holding no tie at all. Scope it to seasons
drafting from a sports season that actually contains a tied placement, and
correct the docblock that called it a pure recompute.

Also drops the inert Number.EPSILON guard from calculateAveragedPoints
(EPSILON is below the ULP for any value >= 2, and integer averages landing
on .5 are exactly representable) and extracts countSharedPlacements so the
ledger writer stops re-querying rows it already holds.

Every fix is covered by a test confirmed to fail when that fix alone is
reverted.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019LZLF1PAfeKdpYog3NKtyz
2026-08-23 01:57:54 +00:00
..
__tests__ Fix review findings in the tie-split ledger and backfill 2026-08-23 01:57:54 +00:00
audit-log-display.ts Add Brackt as a league-private meta-sport (#200) (#377) 2026-05-04 20:31:44 -07:00
auth-client.ts Migrate authentication from Clerk to BetterAuth (#324) 2026-04-24 22:00:49 -07:00
auth.server.ts Add branded dark-themed HTML email template (#402) 2026-05-10 11:18:57 -07:00
auth.ts Migrate authentication from Clerk to BetterAuth (#324) 2026-04-24 22:00:49 -07:00
avatar-colors.ts Add Storybook stories for new components from staged changes (#321) 2026-04-23 22:09:25 -07:00
avatar-data.ts Add Cloudinary-backed avatar system (#385) 2026-05-06 14:47:37 -07:00
bracket-layout.ts Only derive feeders where the halving rule actually holds 2026-08-21 18:18:05 +00:00
bracket-templates.ts Fix final rankings for double-elimination brackets 2026-08-03 18:33:22 +00:00
brand.ts New design (#309) 2026-04-23 13:14:55 -07:00
cloudinary-url.ts Add Cloudinary-backed avatar system (#385) 2026-05-06 14:47:37 -07:00
cloudinary.server.ts Add Cloudinary sports icon uploads (#393) 2026-05-07 16:07:34 -07:00
color-hash.ts User/chris/bracket UI redesign (#95) 2026-03-09 22:44:33 -07:00
corona-states.ts Unify tie-split point math across every screen 2026-08-23 01:57:54 +00:00
cron-auth.ts Debug sync-and-simulate cron job: surface curl output and log auth failures 2026-06-10 16:50:30 +00:00
date-utils.ts claude/practical-newton-4v041g (#98) 2026-06-18 02:33:05 +00:00
draft-eligibility.ts Show why a participant is ineligible to draft (#378) 2026-05-04 21:54:14 -07:00
draft-order.ts Fix draft order initialization for teams added mid-season (#449) 2026-05-19 18:22:47 -07:00
draft-timer.ts Fix draft pause clock: use Math.ceil consistently via shared msToSeconds helper 2026-06-06 16:39:53 -07:00
email.server.ts Add branded dark-themed HTML email template (#402) 2026-05-10 11:18:57 -07:00
event-utils.ts claude/funny-maxwell-vcyb19 (#91) 2026-06-15 22:05:25 +00:00
fifa-2026-bracket.ts Reflect group stage in World Cup sim; seed R32 from real 2026 bracket 2026-06-23 12:15:45 -07:00
fifa-2026-third-place-allocation.ts Reflect group stage in World Cup sim; seed R32 from real 2026 bracket 2026-06-23 12:15:45 -07:00
flag-generator.ts Add Cloudinary-backed avatar system (#385) 2026-05-06 14:47:37 -07:00
flag-types.ts Add Cloudinary-backed avatar system (#385) 2026-05-06 14:47:37 -07:00
fuzzy-match.ts Add golf qualifying points simulator (Plackett-Luce Monte Carlo) (#223) 2026-03-24 21:46:02 -07:00
landing-data.ts Add Storybook stories for new components from staged changes (#321) 2026-04-23 22:09:25 -07:00
llws-bracket.ts Lay out brackets from the feeder graph 2026-08-21 17:50:59 +00:00
logger.ts Replace console.* with structured logger, fix no-inferrable-types (closes #98) (#199) 2026-03-21 13:41:39 -07:00
normalize-team-name.ts Auto-populate & auto-score tennis Grand Slam brackets from Wikipedia 2026-06-26 21:48:00 -07:00
overnight-pause.ts Add overnight pause for draft timers (#335) 2026-04-26 22:31:52 -07:00
owner-map.ts Migrate authentication from Clerk to BetterAuth (#324) 2026-04-24 22:00:49 -07:00
parse-results-text.ts feat: batch qualifying results entry (#290) 2026-04-12 14:52:22 -07:00
scoring-types.ts feat: Add scoring rules editor to league settings and creation pages 2025-10-29 00:04:27 -07:00
season-helpers.server.ts Add oxlint linting setup with zero errors (#194) 2026-03-21 09:44:05 -07:00
sport-icon-cleanup.server.ts Harden sport icon cleanup (#397) 2026-05-08 21:19:09 -07:00
sport-icon-url.ts Add Cloudinary sports icon uploads (#393) 2026-05-07 16:07:34 -07:00
standings-display.ts Show tied ranks with T prefix across standings and Discord (#239) 2026-03-27 20:45:15 -07:00
tournament-identity.ts Canonical tournament layer: 2026-05-01 21:04:48 -07:00
unmatched-team-reconciliation.ts Improve unmatched team reconciliation UX (#425) 2026-05-14 16:45:02 -07:00
utils.ts feat: add theme system with dark mode support and navbar component 2025-10-10 23:30:26 -07:00
wizard-state.ts Add auto-start draft at scheduled time (#437) (#438) 2026-05-16 23:37:29 -07:00