Session 55: Self-learning loop + real-time layer (2274 tests)
Product overhaul core — the two transformative, differentiated systems: Self-learning loop (Phase 2): outcomeService settles locked snapshot grades against real MLB Stats API results → hit/miss/push, rolling accuracy by grade tier (30d window). Idempotent, injectable, unit-tested. New GET /api/accuracy + /api/ledger/accuracy + internal settle triggers + cron hook. AccuracyBadge (dashboard/scan/landing) is honest — "LEARNING" below MIN_SAMPLE, never a fake number. Settled HIT/MISS chips overlay the live slate. Real-time layer (Phase 1): Slate silent 60s auto-refresh (no flash, no wipe on transient blips) + "SIGNAL LIVE · UPDATED Xs ago" freshness strip; Ticker LIVE badge that flashes on fresh events. Landing (Phase 3): TopSignals shows tonight's real top-3 A-rated grades + live accuracy — the product shown, not described. Founder pricing: FOUNDER_CODE_EXPIRY default 2026-06-30 → 2026-12-31 (had lapsed, disabling every founder code + the ClaimMeter pitch). That expiry — not a tier change — was the real cause of the 4 stripe test failures. Backend 2255 (4 failing) → 2274 (all green; +19 new, +4 fixed). Web build exit 0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -619,6 +619,45 @@ snapshot, locked to the line, and read from cache.
|
||||
regression"). "kill conditions" is still legit IN-APP product copy (help/pricing/
|
||||
scan) — only the social meta was cleaned.
|
||||
|
||||
## Self-Learning Loop + Real-Time Layer (Session 55 — non-obvious)
|
||||
- **`outcomeService.settleSnapshot(sport, deps)`** is the self-learning loop:
|
||||
reads `snapshot:{sport}:latest`, settles each locked grade vs the REAL result
|
||||
from `mlbStatsAdapter.getPlayerStats().last10` (game-log row whose `date`
|
||||
matches the graded date — UTC **or** ET, to cover late-game rollover), records
|
||||
hit/miss/push, and writes `outcomes:{sport}:log` + `accuracy:{sport}` +
|
||||
`accuracy:overall`. **Idempotent** — dedupe key is `nameKey|stat|line|side|date`;
|
||||
re-running never double-counts. Presence of a game-log row ⇒ the game is FINAL
|
||||
(no separate status check). NBA/WNBA have no free settled-result feed → they
|
||||
stay `pending` (never throw). If you add an MLB stat_type, add it to
|
||||
`MLB_LOG_FIELD` in outcomeService (a LOCAL copy — settlement is decoupled from
|
||||
featureCache's map on purpose) or its props won't settle.
|
||||
- **Accuracy pct EXCLUDES pushes** (`hits/(hits+misses)`); `sample` counts pushes.
|
||||
Grade buckets: `A+` stands alone, then first-letter (`A-`/`A`→A, `B±`/`B`→B).
|
||||
30-day trailing window keyed off each outcome's game `date`.
|
||||
- **The cron settles BEFORE it grades** (`snapshotScheduler` tick): settle
|
||||
yesterday's now-completed games, then grade today's fresh slate. Trigger
|
||||
manually via internal `POST /api/internal/outcomes/all` (same key as snapshot).
|
||||
- **`GET /api/accuracy`** (public, cached) + **`GET /api/ledger/accuracy`**
|
||||
(buckets — the pre-existing Next `ledger/accuracy` proxy finally has a writer).
|
||||
Browser reaches them via `web/src/app/api/accuracy/route.ts` (new proxy) — same
|
||||
S25 rule.
|
||||
- **`AccuracyBadge`** (`@/components/vyndr`) is HONEST: `< MIN_SAMPLE` (8 settled)
|
||||
→ "MODEL · LEARNING" (amber), else "A-RATED · X% HIT · 30D" (green). Pass
|
||||
`sport=` for a sport-specific record. Self-hides only when the fetch fails/empty.
|
||||
- **Settled outcomes overlay the live slate:** `GET /api/snapshot/:sport` merges
|
||||
`outcomes:{sport}:log` onto grades (`outcome:{result,actual}`), threaded through
|
||||
`slateAdapter.buildPlayerStripsFromProps` → `StatStrip.OutcomeChip` (`✓ HIT (2)`
|
||||
/ `✕ MISS`). A settled prop hides its "+parlay" / BOOK-IT chips (the bet is over).
|
||||
- **Real-time Slate:** `fetchSlate(tab, silent=true)` polls every 60s WITHOUT the
|
||||
skeleton flash and NEVER wipes a good view on a transient empty result (guard:
|
||||
`if (silent && allGames.length===0) return`). The "SIGNAL LIVE · UPDATED Xs ago"
|
||||
strip uses `lastRefreshed` + a 15s `nowTick`. Ticker has an anchored LIVE badge
|
||||
that flashes on a new head event.
|
||||
- **Founder pricing:** `stripeService` `FOUNDER_CODE_EXPIRY` default is now
|
||||
`2026-12-31` (was `2026-06-30`, which had lapsed and disabled every founder code
|
||||
+ the ClaimMeter pitch). That expiry lapsing — NOT a tier-limit change — was the
|
||||
cause of the "4 stripe test failures." Operators override via `FOUNDER_CODE_EXPIRY`.
|
||||
|
||||
## Active Skills
|
||||
- vyndr-voice (all user-facing output)
|
||||
- prop-analysis (grading methodology)
|
||||
|
||||
Reference in New Issue
Block a user