Revive the dead probability layer + restore grade range ON MERIT
Folds re-sequenced steps 1+2 into one change (Kev's call): same bug
family — features wired to sources that return null.
THE PROBABILITY LAYER WAS DEAD IN PRODUCTION. p_win/ev_pct/kelly/
model_odds/value were absent on 0/8 live grades because
gameLogService.getGameLogs returns null for MLB by construction and
depends on the offline Python service for NBA/WNBA, so meta.gameLogs was
[] for every sport. This was the S46 bug in a second location — that fix
gave featureCache an MLB branch (why grades still worked) but never the
estimator. featureCache.getStatRows now supplies normalized rows
([{date,[statType]:v}], most-recent-first) for every sport, feeding the
estimator AND consistency AND game_count_in_7d from one fetch.
VERIFIED on real props: p_win 25/25 WNBA, 8/8 MLB (was 0).
GRADE RANGE, ON MERIT — never by rescaling (permanent founder ruling:
minting A's without new information is a relabelled B sold as an A and
corrupts an append-only ledger).
- refreshTeamStats wired into runSnapshot — it had ZERO production
callers, so opp_rank_stat was permanently null and a +/-1.0 factor
could never fire. Test-env no-op (opsNotify precedent).
- L20 made SYMMETRIC: both branches were delta +1.0, so the season
baseline could only ever ADD. No negative path was a structural reason
D was unreachable. New l20_contradicts_* carries -1.0.
- game_count_in_7d derived from real logged dates (heavy_workload_7d).
- NOT wired, deliberately, with reasons inline: teamId (no team_id
column; getFeatures reads it top-level; factor also needs a starter-id
list) and season_type (ESPN 2 = REGULAR season; threading it raw would
fire veteran_in_playoffs in July). Dead code dressed as a fix is the
thing we are removing, not adding.
CALIBRATION GUARD (found by verifying, not assuming): consistency CV is
NBA-tuned; for a Poisson-ish stat cv ~ 1/sqrt(mean), so any stat with
mean < 4 auto-classifies boom_bust. First verification run showed 8/8 MLB
props boom_bust — a blanket -1.0 that dropped the board to all-C. Floored
at CONSISTENCY_MIN_MEAN=4 -> 'unknown' below. Absent beats wrong. MLB
low-count stats therefore still get no consistency factor: honest, not
fixed. Scale-free index-of-dispersion classifier is the open follow-up.
CONFIDENCE IS NOT A PROBABILITY: payloads carry confidence_basis:
'grade_band'. Corrected mlb-grade-degradation.md — its "25/25
grade<->confidence agreement" is a TAUTOLOGY (confidence is derived FROM
the letter, so it would report 25/25 even if every grade were wrong), not
a validation. Removed dead mlbGrader.js (referenced only by its own test)
and the stale computeFeatures comment claiming a penalty that never ran.
VERIFICATION (scripts/verify-grade-range.js, real props/logs/engine):
WNBA 25 props B 68%->32%, C 32%->64%, D 0->1 (4%); 11-step spread went
from 2 steps to 5 (C/C+/B-/D). The D is earned: Angel Reese assists o2.5,
p_win 0.365. Nothing flooded — grades got HARDER. A did not emit locally
because opp_rank_stat needs the Redis cache only prod populates (local
ceiling +3.0 vs the +4.5 A needs); reachability is proven arithmetically
and locked in tests. Prod A-emission is the outstanding fingerprint.
MARKETING HOLD: "A-RATED" (AccuracyBadge, TopSignals) is unsupported
until that fingerprint. Confirmed honest fallbacks render today —
/api/ledger/accuracy has B and C buckets only, so the badge shows
"MODEL · 63% HIT" and TopSignals self-hides. Nothing fabricated ships.
Suite 276/3286 green, web build exit 0.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SmNjJAwEnqHPtXbvSZR8kA
This commit is contained in:
@@ -18,7 +18,12 @@
|
||||
* - game logs unavailable → consistency defaults to 'unknown'
|
||||
*
|
||||
* The caller (analyzeViaEngine1) reads the returned `errors` array and
|
||||
* downgrades confidence accordingly via the adapter's reasoning string.
|
||||
* surfaces them in the reasoning string. NOTE (Session 63): this comment used
|
||||
* to claim confidence is "downgraded accordingly" — it never was. No
|
||||
* data-sufficiency penalty exists in the live path; confidence is a pure
|
||||
* function of the grade letter (see gradeAdapter `confidence_basis`). The one
|
||||
* real penalty lived in the dead `mlbGrader.js`, now removed. Insufficient data
|
||||
* produces a REFUSAL (grade null + insufficient_data), not a softened grade.
|
||||
*
|
||||
* ─────────────────────────────────────────────────────────────────────
|
||||
* Signal provenance (Session 15 audit)
|
||||
@@ -170,10 +175,18 @@ async function safeGetTrap(input) {
|
||||
}
|
||||
}
|
||||
|
||||
async function safeGetConsistency({ playerName, sport, statType }) {
|
||||
async function safeGetConsistency({ playerName, sport, statType, statRows }) {
|
||||
const fallback = { consistency: 'unknown', score: null, games: 0 };
|
||||
try {
|
||||
const logs = await gameLogService.getGameLogs(playerName, sport, 20);
|
||||
// Session 63 — normalized rows from the REAL per-sport sources (MLB
|
||||
// statsapi / ESPN gamelog), not the NBA-WNBA-only Python service. This one
|
||||
// call feeds BOTH the consistency factor and (via meta.gameLogs) the
|
||||
// probability estimator, which had no rows at all in production.
|
||||
// `statRows` is passed in by computeFeaturesForProp so the fetch happens
|
||||
// ONCE per prop (it also powers game_count_in_7d, built before features).
|
||||
const logs = Array.isArray(statRows)
|
||||
? statRows
|
||||
: await featureCache.getStatRows(playerName, sport, statType);
|
||||
if (!logs || logs.length === 0) return { result: fallback, gameLogs: [] };
|
||||
const result = await consistencyScore.getConsistency({
|
||||
playerName, sport, statType, gameLogs: logs,
|
||||
@@ -231,8 +244,35 @@ async function computeFeaturesForProp(rawProp = {}) {
|
||||
const game = teamAbbr ? await lookupTodayGame({ sport, teamAbbr }) : null;
|
||||
if (!game) errors.push('no_game_scheduled_today');
|
||||
|
||||
// Session 63 — fetch the normalized per-game rows ONCE. They feed three
|
||||
// consumers that were all starving: the consistency factor, the probability
|
||||
// estimator (via meta.gameLogs), and game_count_in_7d below.
|
||||
const statRows = await featureCache.getStatRows(player, sport, statType);
|
||||
|
||||
const gameContext = {
|
||||
home_away: game ? (game.isHome ? 'home' : 'away') : null,
|
||||
// `game_count_in_7d` gates engine1's heavy_workload_7d (-0.5). Nothing ever
|
||||
// populated it, so that factor could not fire. Derived from real logged
|
||||
// game dates; null (omitted) when we have no dated rows.
|
||||
game_count_in_7d: featureCache.gameCountInWindow(statRows, 7),
|
||||
// DELIBERATELY NOT SET: `teamId`. It was tempting to thread it here to
|
||||
// unlock injuryFeatures, but that would be dead code dressed as a fix —
|
||||
// three things block that factor and none is solved by a teamId here:
|
||||
// 1. getFeatures reads `teamId` as a TOP-LEVEL input, not off gameContext;
|
||||
// 2. `player_id_map` has no team_id column (lookupPlayer selects
|
||||
// espn_id/team_abbr only), so there is no id to pass;
|
||||
// 3. injury_severity_score counts MISSING KNOWN STARTERS and no starter-id
|
||||
// list exists, so it resolves to 0 and engine1's factor (needs >= 2)
|
||||
// still cannot fire.
|
||||
// There is also an unresolved semantic: the factor is documented as
|
||||
// OPPONENT injuries but getFeatures passes `teamId`, with `opponentTeamId`
|
||||
// sitting unused beside it. Left alone on purpose — see
|
||||
// specs/audit-data/grade-collapse.md.
|
||||
// DELIBERATELY NOT SET: `season_type`. engine1's playoff factors gate on
|
||||
// `season_type >= 2`, but ESPN's season_type 2 means REGULAR season — so
|
||||
// threading it raw would fire "veteran_in_playoffs" in July. The factor also
|
||||
// needs career_playoff_games, which only the offline Python service
|
||||
// provides. Left unset on purpose; see specs/audit-data/grade-collapse.md.
|
||||
};
|
||||
|
||||
const features = await safeGetFeatures({
|
||||
@@ -344,7 +384,7 @@ async function computeFeaturesForProp(rawProp = {}) {
|
||||
});
|
||||
|
||||
const { result: consistency, gameLogs } = await safeGetConsistency({
|
||||
playerName: player, sport, statType,
|
||||
playerName: player, sport, statType, statRows,
|
||||
});
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user