The previous commit gated the simulator re-run on a `bracketAware` flag set only on afl_bracket and llws_bracket, on the claim that every other simulator was bracket-blind and would resurrect eliminated teams if re-run. That claim was wrong. Eleven more read playoff_matches and honor isComplete/winnerId already: ucl, ncaam, ncaaw (both via ncaa-basketball), nba, nhl, snooker, world_cup, darts, cs2_major, college_hockey and nll. All thirteen are now flagged, so any sport with a bracket the simulator can read absorbs a result by re-running that simulator rather than through ICM. Two simulators are deliberately left off. playoff_bracket and ncaa_football_bracket declare a "bracket" setup section but never read playoff_matches, so re-running them really would re-draw the field. That mismatch runs the other way too — world_cup, darts_bracket and cs2_major_qualifying_points read the bracket without declaring the section — so setupSections is not a usable signal here and the flag stays separate from it, with both facts written down on the flag. The EV-source condition is also gone. It only asked whether the existing EVs came from a simulation, which protected nothing: the alternative to re-running was never leaving them alone, it was the ICM branch overwriting them anyway. Given two overwrites, the bracket-aware one wins regardless of what wrote them. Tests: a bracket-blind simulator still goes through ICM, futures-odds EVs no longer divert a bracket-aware season away from the re-run, and the bracket-aware set is pinned in the manifest test so a new simulator is an explicit decision rather than a default. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VPxDnSEKVoKx9HFcQ6gmcS
91 lines
4 KiB
TypeScript
91 lines
4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import * as schema from "~/database/schema";
|
|
import { SIMULATOR_MANIFEST } from "../manifest";
|
|
import { SIMULATOR_TYPES } from "../registry";
|
|
import { getSimulatorInputPolicy } from "../input-policy";
|
|
import { assertRegistrySchemaDriftFree } from "~/models/simulator";
|
|
|
|
describe("simulator manifest", () => {
|
|
it("has a manifest profile for every registered simulator type", () => {
|
|
expect(Object.keys(SIMULATOR_MANIFEST).toSorted()).toEqual([...SIMULATOR_TYPES].toSorted());
|
|
});
|
|
|
|
it("keeps the registry and database enum in sync", () => {
|
|
expect([...schema.simulatorTypeEnum.enumValues].toSorted()).toEqual([...SIMULATOR_TYPES].toSorted());
|
|
});
|
|
|
|
it("assertRegistrySchemaDriftFree does not throw when registry and schema are aligned", async () => {
|
|
await expect(assertRegistrySchemaDriftFree()).resolves.toBeUndefined();
|
|
});
|
|
|
|
it("documents admin setup requirements for all profiles", () => {
|
|
for (const simulatorType of SIMULATOR_TYPES) {
|
|
const profile = SIMULATOR_MANIFEST[simulatorType];
|
|
expect(profile.displayName).toBeTruthy();
|
|
expect(profile.description).toBeTruthy();
|
|
expect(Array.isArray(profile.requiredInputs)).toBe(true);
|
|
expect(Array.isArray(profile.optionalInputs)).toBe(true);
|
|
expect(profile.setupSections.length).toBeGreaterThan(0);
|
|
expect(profile.defaultConfig).toBeTypeOf("object");
|
|
}
|
|
});
|
|
|
|
// updateProbabilitiesAfterResult sends a season down the re-run path or the ICM path purely
|
|
// on this flag, and getting it wrong is silent in both directions: set it on a simulator
|
|
// that re-plays decided games and eliminated teams come back to life; leave it off a
|
|
// bracket-aware one and ICM keeps reporting placement floors as worth less than the points
|
|
// already awarded. Pinning the set makes a new simulator an explicit decision rather than a
|
|
// default. To add one, confirm it reads playoff_matches AND honors isComplete/winnerId.
|
|
it("pins which simulators are bracket-aware", () => {
|
|
const bracketAware = SIMULATOR_TYPES.filter((t) => SIMULATOR_MANIFEST[t].bracketAware);
|
|
expect(bracketAware.toSorted()).toEqual(
|
|
[
|
|
"afl_bracket",
|
|
"college_hockey_bracket",
|
|
"cs2_major_qualifying_points",
|
|
"darts_bracket",
|
|
"llws_bracket",
|
|
"nba_bracket",
|
|
"ncaam_bracket",
|
|
"ncaaw_bracket",
|
|
"nhl_bracket",
|
|
"nll_bracket",
|
|
"snooker_bracket",
|
|
"ucl_bracket",
|
|
"world_cup",
|
|
].toSorted()
|
|
);
|
|
});
|
|
|
|
it("only derives inputs from declared optional inputs", () => {
|
|
for (const simulatorType of SIMULATOR_TYPES) {
|
|
const profile = SIMULATOR_MANIFEST[simulatorType];
|
|
for (const alternatives of Object.values(profile.derivableInputs ?? {})) {
|
|
for (const alternative of alternatives ?? []) {
|
|
expect(profile.optionalInputs).toContain(alternative);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
it("exposes the per-profile futures blend weight through the input policy", () => {
|
|
expect(getSimulatorInputPolicy(SIMULATOR_MANIFEST.ncaa_football_bracket.defaultConfig).oddsWeight).toBe(0.4);
|
|
expect(getSimulatorInputPolicy(SIMULATOR_MANIFEST.world_cup.defaultConfig).oddsWeight).toBe(0.3);
|
|
expect(getSimulatorInputPolicy(SIMULATOR_MANIFEST.ucl_bracket.defaultConfig).oddsWeight).toBe(0.3);
|
|
// College hockey blends odds internally, so the central blend is disabled.
|
|
expect(getSimulatorInputPolicy(SIMULATOR_MANIFEST.college_hockey_bracket.defaultConfig).oddsWeight).toBe(0);
|
|
// Every profile resolves to the default base-Elo priority unless overridden.
|
|
expect(getSimulatorInputPolicy(SIMULATOR_MANIFEST.nba_bracket.defaultConfig).baseEloPriority)
|
|
.toEqual(["sourceElo", "projectedWins", "projectedTablePoints"]);
|
|
});
|
|
|
|
it("keeps EPL projection and match parity as separate config knobs", () => {
|
|
expect(SIMULATOR_MANIFEST.epl_standings.defaultConfig).toMatchObject({
|
|
parityFactor: 400,
|
|
matchParityFactor: 400,
|
|
averageOpponentElo: 1500,
|
|
baseDrawRate: 0.26,
|
|
drawDecay: 0.002,
|
|
});
|
|
});
|
|
});
|