brackt/app/services/simulations/__tests__
Claude adceda3aca
Fix auto racing sims ignoring championship standings
The IndyCar simulator gave a near-clinched championship leader ~60% to win
the title. It was reporting the futures odds and nothing else.

`event_type` has no race value, so a season_standings calendar (F1, IndyCar)
is stored as `schedule_event` rows — the admin default for that scoring
pattern. The simulator skipped exactly those rows when counting races, so it
saw zero remaining races, took the branch labelled "pre-season", and never
looked at `participant_season_results`. Since `sourceOdds` is an admin input
that is never auto-refreshed, the output was whatever the market said months
ago. With a realistic late-season field (leader on 601 pts vs 480, 2 races
left, stale futures at -300) the old path returns ~55%; counting the races
returns 100.0%.

- Add `countSeasonRaces` in a new leaf model. A race is every event except
  `final_standings`, and completion is inferred from the event date, since
  nobody marks rows labelled "Non-Scoring" complete. Its own module because
  `scoring-event.ts` reaches back into `simulator.ts` through
  `scoring-calculator`.
- Split "season over" from "pre-season". Both had `remainingRaces === 0`, so
  a finished season reverted to an odds draw instead of reporting the final
  standings.
- Warn when a season has championship points but no calendar, in the
  simulator and as a non-blocking readiness warning on the setup page.
- Replace proportional vig removal with a power devig. Dividing every runner
  by the same book sum guts the favourite in a 27-driver market: a 75%
  implied favourite came out at 55%, a -20000 near-lock at 95%. Power devig
  gives 69.5% and 99.3%. Unpriced drivers now floor at the bottom of the
  market instead of being handed 1/N.
- Move the race points tables to their own module so tests can read them
  without tripping the manifest/registry import cycle.

The existing tests missed all of this because their event fixtures used
`eventType: "race"`, which is not a value the enum has. Rebuilt on real enum
values, plus a regression test for the reported case.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TUcV7KenckF893zQ46EDXt
2026-08-17 00:36:20 +00:00
..
afl-simulator.test.ts Add projected-wins input mode to admin Elo Ratings page (#306) 2026-04-17 12:40:08 -07:00
auto-racing-simulator.test.ts Fix auto racing sims ignoring championship standings 2026-08-17 00:36:20 +00:00
brackt-simulator.test.ts Add Brackt as a league-private meta-sport (#200) (#377) 2026-05-04 20:31:44 -07:00
college-hockey-simulator.test.ts Fix college hockey bracket resolution (#396) 2026-05-08 12:29:39 -07:00
cs-major-simulator.test.ts Unify majors: score once, fan out across windows + tennis bracket EV 2026-06-22 20:32:22 -07:00
darts-simulator.test.ts Fix simulator correctness bugs and reduce test iteration counts (#61) 2026-05-31 17:39:43 +00:00
epl-simulator.test.ts Fix simulator correctness bugs and reduce test iteration counts (#61) 2026-05-31 17:39:43 +00:00
golf-simulator.test.ts Add not-participating exclusion support for event results (#446) 2026-05-19 11:13:32 -07:00
input-policy.test.ts claude/fix-lint-errors-n48594 (#111) 2026-06-26 07:26:55 +00:00
llws-simulator.test.ts Add LLWS 20-team double-elimination bracket 2026-08-03 18:06:56 +00:00
manifest.test.ts claude/clever-archimedes-dvye42 (#110) 2026-06-26 05:16:54 +00:00
mlb-simulator.test.ts Fix MLB simulator: projected wins drive seeding, perf fix, + surface simulate errors (#65) 2026-06-01 20:50:03 +00:00
mls-simulator.test.ts Add MLS standings sync and fix simulator conference resolution (#423) 2026-05-14 15:39:40 -07:00
nba-simulator.test.ts fix: NBA play-in bracket advancement bugs (#292) 2026-04-12 22:25:32 -07:00
ncaa-football-simulator.test.ts claude/clever-archimedes-dvye42 (#110) 2026-06-26 05:16:54 +00:00
ncaam-simulator.test.ts Upgrade NCAA preseason simulators (#419) 2026-05-12 22:26:25 -07:00
ncaaw-simulator.test.ts Upgrade NCAA preseason simulators (#419) 2026-05-12 22:26:25 -07:00
nfl-simulator.test.ts Add NFL season + playoffs Monte Carlo simulator (#272) 2026-04-07 09:39:34 -04:00
nhl-simulator.test.ts claude/probability-config-review-1tdolw (#119) 2026-06-30 23:24:48 +00:00
nll-simulator.test.ts Add NLL box lacrosse simulator implementation plan and preseason-draftability guidance (#417) 2026-05-12 14:22:34 -07:00
runner.test.ts claude/fix-lint-errors-n48594 (#111) 2026-06-26 07:26:55 +00:00
simulator-config.test.ts Fix college hockey bracket resolution (#396) 2026-05-08 12:29:39 -07:00
snooker-simulator.test.ts Add snooker bracket simulator and Elo ratings admin UI, fixes #119 2026-03-23 08:24:28 -07:00
tennis-simulator.test.ts Unify majors: score once, fan out across windows + tennis bracket EV 2026-06-22 20:32:22 -07:00
ucl-simulator.test.ts Fix oxlint warnings: no-shadow, consistent-function-scoping, no-non-null-assertion, and others (#196) 2026-03-21 10:59:51 -07:00
wnba-simulator.test.ts Fix simulator brackets: NHL bracket-aware mode, MLB/NBA/WNBA sourceElo support (#358) 2026-04-30 08:33:57 -07:00
world-cup-simulator.test.ts Reflect group stage in World Cup sim; seed R32 from real 2026 bracket 2026-06-23 12:15:45 -07:00