Replace the two parallel odds/Elo mechanisms with one model: every strength
source (raw Elo, projected wins, projected table points, futures odds) converts
to an Elo, those blend by weight into a single Elo, and that one Elo feeds every
simulator. This supersedes the earlier source-priority + per-match probability
blend approach.
Resolution (app/services/simulations/input-policy.ts):
- SimulatorInputPolicy gains baseEloPriority (order among the substitutable base
sources: raw Elo / projected wins / projected table points) and oddsWeight
(0–1). resolveSourceElos/resolveRatings now compute baseElo, derive an
odds Elo via convertFuturesToElo, and blend: 0 = base only, 1 = futures
override, between = weighted blend (method "blend").
- Drops the odds-inclusive sourceEloPriority and the prefersFuturesOdds helper.
Simulators consume the single resolved Elo:
- UCL, World Cup, NCAA Football, MLB drop their separate normalized-odds signal,
convertFuturesToElo calls, and per-match probability blend; they read the
resolved sourceElo (preserving each sim's hardcoded fallback Elo table). The
optional SimulationContext oddsWeight plumbing (types.ts/runner.ts) is removed.
- UCL is routed through the central blend (requiredInputs sourceElo, derivable
from sourceOdds) so any entered Elo and futures blend uniformly.
- College hockey already blends odds into Elo internally (and uses NPI rank the
central resolver can't), so its central oddsWeight is set to 0 to avoid
double-counting; the simulator is unchanged.
Manifest: per-profile oddsWeight defaults (World Cup/UCL/MLB 0.3, NCAA FB 0.4,
college hockey 0; global default 0.3).
UI: the Input Policy card exposes one "Futures vs. Elo — Odds Blend Weight"
control; the /admin/simulators inventory badge shows the effective blend
("Elo only" / "NN% blend" / "overrides Elo") with the odds participant count.
Tests: input-policy blend math (0/0.5/1) for Elo and ratings, baseEloPriority
and oddsWeight parsing/clamping, manifest per-profile weights; obsolete
source-priority and oddsWeight-context tests removed/replaced.
Note: this intentionally shifts the calibrated EV outputs of the four sims that
previously blended at the probability level (accepted in design discussion).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QhNeB7gN6VKene7sdbBVQT
64 lines
2.9 KiB
TypeScript
64 lines
2.9 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");
|
|
}
|
|
});
|
|
|
|
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,
|
|
});
|
|
});
|
|
});
|