Layer 3 Step 2: archetype-aware CHALLENGER, measured not claimed
The champion (probabilityEstimator -> p_win) keeps serving and grading users, completely unchanged. The challenger is a second probability computed from the same inputs at the same instant, landing on the same ledger row so it joins to the same outcome and the same close. Identical conditions, one difference — the only clean A/B. NOTHING IS CLAIMED. Running a challenger is honest beta; asserting it is better before the settled ledger says so is not. Promotion stays a later decision gated on Brier and calibration over sufficient segmented volume. INTERPRETABLE, NOT A RE-ESTIMATION. The challenger is the champion's probability adjusted by the Layer-2 axes, applied in log-odds space so a nudge cannot push past 0 or 1 and means the same thing at p=0.5 as at p=0.9. Every deviation is attributable to a named axis and a signed nudge, stored as challenger_adjustments, and the total is capped at 0.45 log-odds — a lean on a real signal, never a re-forecast. Only mechanically obvious stat/axis relationships are mapped; a speculative mapping would be the same guessing this layer exists to replace. IDENTICAL WHERE THERE IS NO SIGNAL, by construction. An unremarkable player, a thin sample, an unmapped stat or a missing classification all return the champion's probability byte-for-byte with an empty adjustment list and a stated reason. The experiment therefore differs only where archetype-awareness could possibly help or hurt, with no dilution from rows the treatment never touched. Induced on real players. Judge home runs over: 0.42 -> 0.447, via BOMBER +0.22 and WHIFF RISK -0.11 — two real opposing signals netting positive. The same prop under mirrors it exactly to -0.027. Judge strikeouts: delta exactly 0, because WHIFF RISK and GRINDER cancel — an honest "no lean" with both signals still recorded. Skubal strikeouts over: 0.60 -> 0.702 via WHIFF, TRAPDOOR and CANNON all aligned; his hits-allowed goes the other way, 0.50 -> 0.392, because a strikeout arm makes hits less likely. Josh Bell and a 12-PA sample are untouched. Isolation is structural: adjust() is pure, the champion field is read and never written, the served snapshot payload is still the untouched champion object, and a challenger failure is caught so it can never break the pipeline it is measured inside. Statcast aggregates load once per snapshot run rather than per prop, so grade-time I/O stays at zero. Migration 034. Tests 3634 passed / 295 suites, web build exit 0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VCNgGSt5qvcLxaeQqa7Zpj
This commit is contained in:
@@ -206,6 +206,32 @@ const ACTIVE_SPORTS = ['mlb', 'nba', 'wnba', 'soccer'];
|
||||
* opts (all injectable): getOdds, gradeAndCacheSlate, resolveStats, classify,
|
||||
* cacheGet, cacheSet, now, nowMs.
|
||||
*/
|
||||
/**
|
||||
* Statcast aggregates for the season, indexed by our player key. One read per
|
||||
* snapshot run (~1,350 rows / 5 MB), reused for every grade — the alternative
|
||||
* is a per-prop lookup inside a tight grading loop.
|
||||
*/
|
||||
async function loadStatcastRows(sport) {
|
||||
try {
|
||||
const sb = require('../utils/supabase').getSupabaseServiceClient();
|
||||
if (!sb) return null;
|
||||
const { data, error } = await sb.from('statcast_aggregates')
|
||||
.select('*').eq('sport', sport).limit(5000);
|
||||
if (error || !data) return null;
|
||||
const map = new Map();
|
||||
for (const r of data) {
|
||||
if (!r.player_key) continue;
|
||||
// A two-way player has two rows; the one with the larger sample is the
|
||||
// profile his props are about far more often than not.
|
||||
const prev = map.get(r.player_key);
|
||||
const size = Number(r.sample_pa || r.sample_ip || 0);
|
||||
const prevSize = prev ? Number(prev.sample_pa || prev.sample_ip || 0) : -1;
|
||||
if (!prev || size > prevSize) map.set(r.player_key, r);
|
||||
}
|
||||
return map;
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
async function runSnapshot(sport, opts = {}) {
|
||||
const sp = String(sport || '').toLowerCase();
|
||||
const deps = {
|
||||
@@ -490,6 +516,29 @@ async function runSnapshot(sport, opts = {}) {
|
||||
// Session 64 — retention persists HERE, after enrichment, so archetype/team/
|
||||
// opponent are populated. Feature values were captured at grade time and are
|
||||
// NOT touched by the merge (mergeEnrichment only fills the three null fields).
|
||||
// Session 71 — CHAMPION / CHALLENGER. The challenger is computed here, where
|
||||
// the archetype resolve already happened, so grade-time I/O stays at zero.
|
||||
// `enriched` (champion p_win) is READ, never written: the serving projection
|
||||
// is untouched, and the challenger rides alongside it to the ledger.
|
||||
let withChallenger = enriched;
|
||||
try {
|
||||
const challenger = deps.challenger || require('./challengerProjection');
|
||||
const axes = deps.archetypeAxes || require('./archetypeAxes');
|
||||
const rowsByKey = await (deps.loadStatcast || loadStatcastRows)(sp);
|
||||
if (rowsByKey && rowsByKey.size) {
|
||||
const classifyFor = (playerName) => {
|
||||
const row = rowsByKey.get(nameKey(playerName || ''));
|
||||
return row ? axes.classifyPlayer(row) : null;
|
||||
};
|
||||
withChallenger = challenger.attachChallenger(enriched, classifyFor);
|
||||
const moved = withChallenger.filter((g) => g.challenger_delta).length;
|
||||
console.log(`[challenger] ${sp} — ${moved}/${withChallenger.length} grades adjusted by archetype`);
|
||||
}
|
||||
} catch (e) {
|
||||
// The challenger must NEVER break the pipeline it is measured inside.
|
||||
console.warn(`[challenger] ${sp} skipped:`, e.message);
|
||||
}
|
||||
|
||||
await persistRetention(enriched);
|
||||
|
||||
// Line deltas vs the previous snapshot's locked lines.
|
||||
@@ -523,7 +572,7 @@ async function runSnapshot(sport, opts = {}) {
|
||||
// Best-effort: the ledger must never break the snapshot.
|
||||
let ledgerWritten = 0;
|
||||
try {
|
||||
const rec = await deps.ledger.recordPipelineGrades(sp, enriched, props, { now: deps.now });
|
||||
const rec = await deps.ledger.recordPipelineGrades(sp, withChallenger, props, { now: deps.now });
|
||||
ledgerWritten = rec.written || 0;
|
||||
await deps.ledger.captureClosing(sp, props);
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user