cb3237cdce
The pricing Desk showcase hardcoded an alt-line ladder (1.5 A +7.1% / 2.5 A+ +11.4% / 4.5 C -3.8%), QUARTER-KELLY 2.4%, and PARLAY φ 0.34 — a mocked demo selling something we weren't proving. - deskShowcaseService reads the pre-graded snapshot for a real A/B prop's alt-line ladder (prefers the one with the most grade variation — the most compelling real example). Edge per rung shows only when it's a plausible market value; the inflated (model-line)/line artifact on small lines is guarded to "—" rather than shown as a fake +91%. - PARLAY φ is now REAL: the model's same-team correlation (0.34, mirroring the frontend parlayMath team constant) computed for TWO REAL same-team legs, named. No real same-team pair on the board → the tile hides, never an invented number. - QUARTER-KELLY tile is REMOVED: the snapshot has no odds, so a real quarter-Kelly % can't be computed here — a fabricated 2.4% is worse than nothing. Kelly stays a real in-app Desk feature; the showcase just doesn't fake it. - DeskShowcase is now a client component fetching /api/desk-showcase; when the board has no real ladder the whole visuals column hides (real-or-hidden, same law as the hero). The pitch copy is unchanged. 5 service tests. Change-affected suites green, web build exit 0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
64 lines
3.2 KiB
JavaScript
64 lines
3.2 KiB
JavaScript
'use strict';
|
|
|
|
// Item 6 (Truth-Everywhere Part 2) — the Desk showcase renders REAL snapshot
|
|
// data (alt-line ladder + same-team correlation) or hides. No mocked numbers.
|
|
|
|
const { getDeskShowcase, __internals } = require('../../src/services/deskShowcaseService');
|
|
|
|
const cacheFrom = (map) => async (k) => (k in map ? map[k] : null);
|
|
const grade = (o) => ({
|
|
player_name: o.player, stat_type: o.stat || 'hits', grade: o.grade,
|
|
team: o.team || null, alt_lines: o.alt || [],
|
|
});
|
|
|
|
describe('getDeskShowcase', () => {
|
|
test('renders a real A/B ladder; inflated edges are guarded to null', async () => {
|
|
const cacheGet = cacheFrom({ 'snapshot:mlb:latest': { grades: [
|
|
grade({ player: 'Vary', stat: 'strikeouts', grade: 'A', alt: [
|
|
{ line: 4.5, grade: 'A', edge_pct: 8.2 }, { line: 6.5, grade: 'B', edge_pct: 3.1, base: true }, { line: 8.5, grade: 'C', edge_pct: 91.3 },
|
|
] }),
|
|
] } });
|
|
const out = await getDeskShowcase({ cacheGet, sports: ['mlb'] });
|
|
expect(out.available).toBe(true);
|
|
expect(out.ladder.player).toBe('Vary');
|
|
expect(out.ladder.rungs.map((r) => r.grade)).toEqual(['A', 'B', 'C']); // sorted by line
|
|
expect(out.ladder.rungs[0].edge).toBe(8.2); // sane edge kept
|
|
expect(out.ladder.rungs[2].edge).toBeNull(); // 91.3% guarded (artifact, not a market edge)
|
|
expect(out.kelly).toBeNull(); // no odds → never a fabricated %
|
|
});
|
|
|
|
test('prefers the ladder with the MOST grade variation (best real example)', async () => {
|
|
const cacheGet = cacheFrom({ 'snapshot:mlb:latest': { grades: [
|
|
grade({ player: 'Flat', grade: 'B', alt: [{ line: 0.5, grade: 'B' }, { line: 1.5, grade: 'B' }] }),
|
|
grade({ player: 'Varies', grade: 'A', alt: [{ line: 0.5, grade: 'A' }, { line: 1.5, grade: 'C' }] }),
|
|
] } });
|
|
const out = await getDeskShowcase({ cacheGet, sports: ['mlb'] });
|
|
expect(out.ladder.player).toBe('Varies');
|
|
});
|
|
|
|
test('parlay φ is REAL — the model correlation for two real same-team legs', async () => {
|
|
const cacheGet = cacheFrom({ 'snapshot:mlb:latest': { grades: [
|
|
grade({ player: 'Alice', grade: 'A', team: 'NYY', alt: [{ line: 0.5, grade: 'A' }, { line: 1.5, grade: 'B' }] }),
|
|
grade({ player: 'Bob', grade: 'B', team: 'NYY', alt: [{ line: 0.5, grade: 'B' }, { line: 1.5, grade: 'C' }] }),
|
|
] } });
|
|
const out = await getDeskShowcase({ cacheGet, sports: ['mlb'] });
|
|
expect(out.parlay).toEqual({ value: 0.34, legs: ['Alice', 'Bob'], team: 'NYY' });
|
|
});
|
|
|
|
test('no same-team pair → parlay null (never an invented correlation)', async () => {
|
|
const cacheGet = cacheFrom({ 'snapshot:mlb:latest': { grades: [
|
|
grade({ player: 'Solo', grade: 'A', team: 'NYY', alt: [{ line: 0.5, grade: 'A' }, { line: 1.5, grade: 'C' }] }),
|
|
] } });
|
|
const out = await getDeskShowcase({ cacheGet, sports: ['mlb'] });
|
|
expect(out.parlay).toBeNull();
|
|
});
|
|
|
|
test('no A/B ladder anywhere → { available:false } (visuals hide)', async () => {
|
|
const cacheGet = cacheFrom({ 'snapshot:mlb:latest': { grades: [
|
|
grade({ player: 'Weak', grade: 'D', alt: [{ line: 0.5, grade: 'D' }] }),
|
|
] } });
|
|
const out = await getDeskShowcase({ cacheGet, sports: ['mlb'] });
|
|
expect(out).toEqual({ available: false });
|
|
});
|
|
});
|