Session 52: Coming Soon teaser + infrastructure verification (2239 tests)

Phase 1 — Push-to-Book teaser (feature not live; teaser only):
- StatStrip: "BOOK IT ⟶" per graded prop (hover: "Push-to-Book coming soon").
- GradeResultCard: "PUSH-TO-BOOK · COMING SOON" footer.

Phase 2 — infrastructure verification:
- snapshotScheduler logs armed AND disarmed state (incl SNAPSHOT_CRON) so
  container logs disambiguate off-vs-crashed.
- NEW GET /api/internal/snapshot/status (internal-key gated): cron_armed,
  cron_hours_utc, last_snapshot per sport (gradeCount/deltaCount), redis_keys
  existence map, ticker_count. The post-deploy pipeline health probe.
- Finding: Redis AOF/RDB persistence is a server-side (Coolify) config the app
  can't set/verify — documented.

Phase 3 — delta pipeline (verified sound, no fix needed):
- runSnapshot already rotates :latest->:previous and diffs locked lines; added
  opt-in SNAPSHOT_DEBUG=1 [deltas] log + a trace test asserting :previous is
  preserved verbatim and the delta math is correct.

Backend 2234 -> 2239 tests (+5), 192 suites. Web build clean (exit 0).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kev
2026-06-19 13:55:39 -04:00
parent f0674ca07d
commit cdedecf55b
12 changed files with 221 additions and 5 deletions
+31 -2
View File
@@ -4,8 +4,37 @@
2026-06-18
## Current Phase
SHIP BUILD v51.0 — Team Hub: /team/[abbr] roster with archetypes, season stats,
graded props; clickable team abbrs on every game card. Research depth.
SHIP BUILD v52.0 — Push-to-Book "Coming Soon" teaser + infrastructure
verification (snapshot status probe, scheduler logs, delta pipeline confirmed).
## Session 52 (2026-06-19) — SHIPPED ✅ TEASER + INFRA VERIFICATION
Backend 2234 → **2239 tests** (+5), 192 suites. Web build clean (exit 0).
### Phase 1 — Push-to-Book teaser (feature NOT live; teaser only)
- `StatStrip`: a `BookItTeaser` ("BOOK IT ⟶", hover tooltip "Push-to-Book coming
soon — connect your sportsbook") after the parlay "+" on every graded prop.
- `GradeResultCard`: a "PUSH-TO-BOOK · COMING SOON" footer section.
### Phase 2 — infrastructure verification
- `snapshotScheduler` now logs BOTH states: armed (`[snapshotScheduler] armed —
SNAPSHOT_CRON=1, hours=…`) and disarmed (so container logs disambiguate
off-vs-crashed). Test asserts the armed log.
- NEW `GET /api/internal/snapshot/status` (internal-key gated): `{ cron_armed,
cron_hours_utc, last_snapshot:{sport:{updated_at,gradeCount,deltaCount}},
redis_keys:{…:bool}, ticker_count }`. The single probe to verify the pipeline
post-deploy.
- REDIS PERSISTENCE FINDING: the app uses `REDIS_URL` (ioredis) — AOF/RDB
persistence is a server-side (Coolify Redis) config the app can't set/verify.
If snapshot keys vanish on restart, enable persistence on the Redis instance.
### Phase 3 — delta pipeline (verified sound; no fix needed)
`runSnapshot` already reads `:latest` as prev → `computeLineDeltas(enriched,
prev.grades)` → writes old→`:previous`, new→`:latest`. So deltas populate on the
2nd+ run. Added an opt-in debug log (`SNAPSHOT_DEBUG=1`) + a trace test asserting
`:previous` is preserved verbatim and the delta math is correct.
## Session 51 (2026-06-19) — SHIPPED ✅ TEAM HUB
## Session 51 (2026-06-19) — SHIPPED ✅ TEAM HUB
+16
View File
@@ -577,6 +577,22 @@ snapshot, locked to the line, and read from cache.
`vyndr/GameCard`'s `TeamLink` (stops propagation from the open-game handler).
The roster "+" reuses the Parlay Lab (`useParlay`/`legKey`).
## Infra Verification (Session 52 — non-obvious)
- **`GET /api/internal/snapshot/status`** (internal-key gated) is the post-deploy
health probe: `{ cron_armed, cron_hours_utc, last_snapshot, redis_keys,
ticker_count }`. Use it to confirm the snapshot pipeline is alive without
shelling into the container.
- **Scheduler logs both states** on start: armed (`[snapshotScheduler] armed —
SNAPSHOT_CRON=…`) and disarmed. If you see neither in container logs,
`startSnapshotScheduler()` isn't being called.
- **`SNAPSHOT_DEBUG=1`** turns on a per-run `[deltas]` log in `computeLineDeltas`
(off by default — it's a hot path). Confirms a previous snapshot exists to diff.
- **Redis persistence is NOT app-controlled.** ioredis connects via `REDIS_URL`;
AOF/RDB is a server-side Coolify config. Snapshot keys disappearing on restart
= the Redis instance has persistence off, not a code bug.
- **Push-to-Book is a TEASER only** — "BOOK IT ⟶" (StatStrip) + "PUSH-TO-BOOK ·
COMING SOON" (GradeResultCard) advertise an unbuilt feature. No backend.
## Active Skills
- vyndr-voice (all user-facing output)
- prop-analysis (grading methodology)
+43
View File
@@ -104,6 +104,49 @@ router.post('/snapshot/all', async (req, res) => {
}
});
/**
* GET /api/internal/snapshot/status (Session 52) — verification probe. Reports
* whether the in-process cron is armed, the freshest snapshot per sport, which
* pipeline Redis keys exist, and the ticker item count. Read-only; safe to poll.
* GET vs the POST /snapshot/:sport below — no route collision.
*/
router.get('/snapshot/status', async (req, res) => {
const { cacheGet } = require('../utils/redis');
const { HOURS_UTC } = require('../snapshotScheduler');
const SPORTS = ['mlb', 'nba', 'wnba'];
try {
const redis_keys = {};
const last_snapshot = {};
for (const sp of SPORTS) {
const latestKey = `snapshot:${sp}:latest`;
const prevKey = `snapshot:${sp}:previous`;
const gradesKey = `grades:${sp}`;
const [latest, prev, grades] = await Promise.all([cacheGet(latestKey), cacheGet(prevKey), cacheGet(gradesKey)]);
redis_keys[latestKey] = !!latest;
redis_keys[prevKey] = !!prev;
redis_keys[gradesKey] = !!grades;
if (latest) {
last_snapshot[sp] = {
updated_at: latest.updated_at || null,
gradeCount: Array.isArray(latest.grades) ? latest.grades.length : 0,
deltaCount: Array.isArray(latest.deltas) ? latest.deltas.length : 0,
};
}
}
const ticker = await cacheGet('ticker:items');
redis_keys['ticker:items'] = !!ticker;
return res.json({
cron_armed: process.env.SNAPSHOT_CRON === '1',
cron_hours_utc: HOURS_UTC,
last_snapshot,
redis_keys,
ticker_count: Array.isArray(ticker) ? ticker.length : 0,
});
} catch (err) {
return res.status(500).json({ ok: false, error: err.message });
}
});
router.post('/snapshot/:sport', async (req, res) => {
const snapshot = require('../services/snapshotService');
try {
+5
View File
@@ -81,6 +81,11 @@ function gradedAtFor(g, oddsByKey, ts) {
function computeLineDeltas(current, previous) {
const prevMap = {};
for (const p of previous || []) prevMap[propKey(p)] = p;
// Session 52 — opt-in verification log (SNAPSHOT_DEBUG=1). Confirms the delta
// pipeline has a previous snapshot to diff against; off by default (hot path).
if (process.env.SNAPSHOT_DEBUG === '1') {
console.log(`[deltas] diffing ${(current || []).length} current vs ${(previous || []).length} previous locked lines`);
}
const out = [];
for (const c of current || []) {
const prev = prevMap[propKey(c)];
+9 -2
View File
@@ -18,7 +18,14 @@ const HOURS_UTC = (process.env.SNAPSHOT_HOURS_UTC || '14,19,22,1,3')
.filter((n) => Number.isInteger(n) && n >= 0 && n <= 23);
function startSnapshotScheduler(opts = {}) {
if (process.env.SNAPSHOT_CRON !== '1') return null;
if (process.env.SNAPSHOT_CRON !== '1') {
// Session 52 — log the disarmed state so container logs make it unambiguous
// that the in-process cron is intentionally off (vs. crashed/missing).
if (process.env.NODE_ENV !== 'test') {
console.log(`[snapshotScheduler] disarmed — SNAPSHOT_CRON=${process.env.SNAPSHOT_CRON ?? 'unset'} (in-process cron off; use external cron → POST /api/internal/snapshot/all)`);
}
return null;
}
const runAll = opts.runAllSnapshots || require('./services/snapshotService').runAllSnapshots;
const now = opts.now || (() => new Date());
let lastFiredSlot = null;
@@ -42,7 +49,7 @@ function startSnapshotScheduler(opts = {}) {
const interval = setInterval(tick, 60_000);
if (interval.unref) interval.unref();
console.log(`[snapshot] scheduler armed for UTC hours: ${HOURS_UTC.join(', ')}`);
console.log(`[snapshotScheduler] armed — SNAPSHOT_CRON=${process.env.SNAPSHOT_CRON}, hours=${HOURS_UTC.join(',')} UTC`);
return { interval, tick };
}
+54
View File
@@ -0,0 +1,54 @@
// Session 52 — GET /api/internal/snapshot/status (verification probe).
const express = require('express');
const request = require('supertest');
const mockCacheGet = jest.fn();
jest.mock('../../src/utils/redis', () => ({
cacheGet: (...a) => mockCacheGet(...a),
cacheSet: jest.fn(),
}));
beforeEach(() => {
jest.resetAllMocks();
process.env.VYNDR_INTERNAL_KEY = 'test-internal-key-9999';
});
function mountApp() {
delete require.cache[require.resolve('../../src/routes/internal')];
const internalRoutes = require('../../src/routes/internal');
const app = express();
app.use(express.json());
app.use('/api/internal', internalRoutes);
return app;
}
describe('GET /api/internal/snapshot/status', () => {
it('requires the internal key', async () => {
const res = await request(mountApp()).get('/api/internal/snapshot/status');
expect(res.status).toBe(401);
});
it('reports cron state, last snapshot, redis keys, ticker count', async () => {
process.env.SNAPSHOT_CRON = '1';
mockCacheGet.mockImplementation(async (key) => {
if (key === 'snapshot:mlb:latest') return { updated_at: '2026-06-19T18:00:00Z', grades: [{}, {}, {}], deltas: [{}] };
if (key === 'grades:mlb') return { grades: [{}, {}, {}] };
if (key === 'ticker:items') return [{ type: 'SCAN' }, { type: 'ALERT' }];
return null;
});
const res = await request(mountApp())
.get('/api/internal/snapshot/status')
.set('x-internal-key', 'test-internal-key-9999');
expect(res.status).toBe(200);
expect(res.body.cron_armed).toBe(true);
expect(res.body.last_snapshot.mlb.gradeCount).toBe(3);
expect(res.body.last_snapshot.mlb.deltaCount).toBe(1);
expect(res.body.redis_keys['snapshot:mlb:latest']).toBe(true);
expect(res.body.redis_keys['snapshot:mlb:previous']).toBe(false);
expect(res.body.ticker_count).toBe(2);
delete process.env.SNAPSHOT_CRON;
});
});
+22
View File
@@ -0,0 +1,22 @@
// Session 52 — Push-to-Book "Coming Soon" teaser (source-asserted).
const fs = require('fs');
const path = require('path');
const WEB = path.join(__dirname, '..', '..', 'web', 'src');
const read = (rel) => fs.readFileSync(path.join(WEB, rel), 'utf8');
describe('BOOK IT teaser', () => {
it('StatStrip renders the "BOOK IT" teaser on graded props', () => {
const src = read('components/vyndr/StatStrip.tsx');
expect(src).toContain('BookItTeaser');
expect(src).toContain('BOOK IT ⟶');
expect(src).toContain('Push-to-Book coming soon');
expect(src).toContain('<BookItTeaser p={p} />');
});
it('GradeResultCard renders "PUSH-TO-BOOK · COMING SOON"', () => {
const src = read('components/vyndr/GradeResultCard.tsx');
expect(src).toContain('PUSH-TO-BOOK · COMING SOON');
expect(src).toContain('Connect DraftKings, FanDuel, BetMGM');
});
});
+10
View File
@@ -14,6 +14,16 @@ describe('startSnapshotScheduler', () => {
expect(HOURS_UTC).toEqual([14, 19, 22, 1, 3]);
});
it('logs an armed startup message including SNAPSHOT_CRON when started', () => {
process.env.SNAPSHOT_CRON = '1';
const spy = jest.spyOn(console, 'log').mockImplementation(() => {});
const sched = startSnapshotScheduler({ runAllSnapshots: jest.fn(), now: () => new Date(Date.UTC(2026, 5, 18, 12, 30, 0)) });
expect(spy).toHaveBeenCalledWith(expect.stringContaining('[snapshotScheduler] armed'));
expect(spy).toHaveBeenCalledWith(expect.stringContaining('SNAPSHOT_CRON=1'));
spy.mockRestore();
if (sched && sched.interval && sched.interval.unref) clearInterval(sched.interval);
});
it('fires runAllSnapshots at a scheduled hour, once per slot', async () => {
process.env.SNAPSHOT_CRON = '1';
const runAllSnapshots = jest.fn(async () => [{ sport: 'mlb', status: 'ok' }]);
+5
View File
@@ -123,10 +123,15 @@ describe('runSnapshot (fully injected)', () => {
{ player: 'Aaron Judge', stat_type: 'total_bases', line, direction: 'over', grade: 'A+', confidence: 80 },
])(sport, props, opts);
await svc.runSnapshot('mlb', d);
const firstLatest = cache.store['snapshot:mlb:latest'];
line = 2.5; // line moved +1.0
const r2 = await svc.runSnapshot('mlb', d);
expect(cache.store['snapshot:mlb:previous']).toBeTruthy();
expect(r2.deltas).toBe(1);
// Session 52 trace: the previous snapshot is preserved verbatim so the next
// run can diff against the exact locked lines (the delta pipeline's input).
expect(cache.store['snapshot:mlb:previous']).toEqual(firstLatest);
expect(cache.store['snapshot:mlb:latest'].deltas[0]).toMatchObject({ delta: 1, gradedLine: 1.5, currentLine: 2.5 });
});
it('pushes ticker events (capped) into ticker:items', async () => {
+1 -1
View File
File diff suppressed because one or more lines are too long
@@ -274,6 +274,16 @@ export default function GradeResultCard({
<VBtn variant="outline" style={{ flex: 1 }} onClick={() => onAddToParlay && onAddToParlay(d)}>+ Add to Parlay</VBtn>
{onReadAnother && <VBtn variant="ghost" small onClick={onReadAnother}>Read Another </VBtn>}
</div>
{/* 10. PUSH-TO-BOOK teaser (Session 52) — feature not live yet. */}
<div style={{ borderTop: '1px solid var(--border)', padding: '12px 20px 16px', textAlign: 'center', background: 'var(--bg-2)' }}>
<span className="mono" style={{ color: 'var(--text-2)', fontSize: 11, letterSpacing: '0.06em' }}>
PUSH-TO-BOOK · COMING SOON
</span>
<div style={{ fontSize: 12, color: 'var(--text-1)', marginTop: 4 }}>
One tap from grade to bet slip. Connect DraftKings, FanDuel, BetMGM.
</div>
</div>
</div>
);
}
+15
View File
@@ -82,6 +82,19 @@ export default function StatStrip({
</button>
);
};
// Session 52 — Push-to-Book teaser on graded props (feature not live yet).
const BookItTeaser = ({ p }: { p: StripProp }) => {
if (!p.grade) return null;
return (
<span
className="mono"
title="Push-to-Book coming soon — connect your sportsbook"
style={{ fontSize: 9, fontWeight: 700, letterSpacing: '0.06em', color: 'var(--text-2)', cursor: 'default', padding: '2px 5px', borderRadius: 4, border: '1px solid var(--border)', opacity: 0.6 }}
>
BOOK IT
</span>
);
};
const last10Str = typeof last10 === 'string'
? last10
: Array.isArray(last10)
@@ -172,6 +185,7 @@ export default function StatStrip({
<span className="mono" style={{ display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 11, color: '#B8BCC8' }}>
{p.stat} {p.side}{p.line} {p.grade && <GradeBadge grade={p.grade} size="sm" />}
<ParlayBtn p={p} />
<BookItTeaser p={p} />
</span>
</span>
))}
@@ -196,6 +210,7 @@ export default function StatStrip({
<span style={{ color: '#fff' }}>{p.stat} {p.side}{p.line}</span>
{p.grade && <GradeBadge grade={p.grade} size="sm" />}
<ParlayBtn p={p} />
<BookItTeaser p={p} />
{p.gradedAt?.ago && (
<span style={{ color: 'var(--text-2)' }}>
Graded {p.gradedAt.ago}{p.gradedAt.odds != null ? ` at ${p.gradedAt.odds}` : ''}