The skill engine: built, gated by construction, and Stage A honestly lost
Built src/services/model/ -- the forward, archetype-selected, skill-based projection, as a challenger. The champion is untouched. featureRegistry makes "earn its place or it's out" structural rather than aspirational: CANDIDATE / PROVEN / DEAD per feature per sport, liveFeatures() returns PROVEN only, promotion requires n>=200 with positive lift and a CI excluding zero, and there is deliberately no override argument. It ships with exactly ONE proven feature -- the incumbent counter, because it is the only one with a measurement. A test asserts that with only PROVEN features allowed the projection returns null, so an unproven model cannot reach a user by accident. The three champion adjustment layers are registered DEAD with their reasons so they cannot be silently rebuilt. skillProjection is a PA outcome tree: K and BB combined by log5 odds-ratio against league (both identities unit-tested), then archetype-weighted contact quality against contact allowed, then Binomial(PA, p_hit) mixed over a PA distribution. Archetype is a FEATURE SELECTOR, not a nudge -- BOMBER reads barrels at 0.50 and ground-ball speed at 0.00, GHOST inverts it -- and a test locks that the same hitter read two ways moves more than 0.15. STAGE A: IT LOSES. Out-of-sample on 570 settled hits props with 91.9% opposing-pitcher coverage, resolution 0.0499 against the champion's 0.166, delta -0.116 with CI [-0.189, -0.043]. It is not selective either: its eight most confident picks hit 50%, a lift of -0.065. Not promoted. The gate did its job on its first real test, which is the point of having built it that way. Two false starts, both recorded because they nearly produced a wrong verdict: statcast_aggregates stores PERCENTAGES, so raw rows made bip = 1-29.6-17.1 and refused 568 of 576 -- the honest-absent guards made a units bug loud instead of silent, and the conversion now lives at one chokepoint. And the first run resolved an opposing pitcher for 1 of 570 rows, because ledger team/opponent are NULL, so it would have reported "skill-v1 loses" while measuring a batter-only model with no matchup in it at all. The verdict above is from the corrected run. The loss is real but partial: park was passed as 1.0, handedness and opportunity_drift never fired, PA is season-PA over a constant, and the skill profiles carry no recency at all while the champion has a last-5 term. Also fixed: the Statcast nightly refresh was unreachable code. It sat inside tick() below "if (!HOURS_UTC.includes(h)) return" while testing h === 11, so it had never run once; the aggregates were 13 days stale and both of its alerts were in the same dead branch. It now runs on its own tick, and the test that passed happily throughout -- it only checked the string existed -- is replaced by one that asserts it is not behind the guard. 4,182 tests green (333 suites); web build exit 0. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W1sivYNqY2TS5ftykmHBU9
This commit is contained in:
@@ -212,10 +212,31 @@ describe('scheduler + route wiring', () => {
|
||||
it('is server-scheduled with a kill switch', () => {
|
||||
const s = read('src/snapshotScheduler.js');
|
||||
expect(s).toContain('STATCAST_HOUR_UTC');
|
||||
expect(s).toMatch(/process\.env\.STATCAST !== '0'/);
|
||||
expect(s).toMatch(/process\.env\.STATCAST === '0'/); // kill switch, early-return form
|
||||
expect(s).toContain('refreshSeason');
|
||||
});
|
||||
|
||||
it('RUNS ON ITS OWN TICK — not behind the snapshot-hours guard', () => {
|
||||
// THE REGRESSION THIS LOCKS (found 2026-08-03): the refresh used to live
|
||||
// inside `tick()`, BELOW `if (!HOURS_UTC.includes(h)) return`. HOURS_UTC is
|
||||
// 14,19,22,1,3 and the block tests h === STATCAST_HOUR_UTC (default 11), so
|
||||
// the guard could never admit the hour it waited for. It was unreachable
|
||||
// code that had never run once, and the aggregates sat 13 days stale while
|
||||
// every consumer served them as current. The previous assertion here passed
|
||||
// the entire time, because it only checked that the STRING existed.
|
||||
const s = read('src/snapshotScheduler.js');
|
||||
const statcastTick = s.slice(s.indexOf('const statcastTick'));
|
||||
expect(statcastTick.length).toBeGreaterThan(0);
|
||||
// Its own tick, registered on the interval alongside the others.
|
||||
expect(s).toMatch(/void statcastTick\(\)/);
|
||||
// And it must NOT be reachable only via the snapshot-hours guard.
|
||||
// Scope to the snapshot tick's OWN body (it ends where refreshTick begins),
|
||||
// so the statcastTick doc comment above it cannot satisfy this by accident.
|
||||
const tickBody = s.slice(s.indexOf('const tick = async'), s.indexOf('const refreshTick'));
|
||||
expect(tickBody).toContain('HOURS_UTC.includes(h)'); // the guard is still there
|
||||
expect(tickBody).not.toContain('STATCAST_HOUR_UTC'); // and statcast is NOT behind it
|
||||
});
|
||||
|
||||
it('pages on BOTH a failed run and silent staleness', () => {
|
||||
const s = read('src/snapshotScheduler.js');
|
||||
expect(s).toMatch(/Statcast refresh failed/);
|
||||
|
||||
Reference in New Issue
Block a user