Item 6 — Desk showcase renders REAL data (or hides), kills the mocked ladder

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>
This commit is contained in:
Kev
2026-07-18 01:42:16 -04:00
parent 9b9aab4262
commit cb3237cdce
6 changed files with 287 additions and 51 deletions
+1
View File
@@ -217,6 +217,7 @@ app.use('/api/internal', internalRoutes);
app.use('/api/partners', require('./routes/partners'));
app.use('/api/founders', require('./routes/founders'));
app.use('/api/hero-prop', require('./routes/heroProp'));
app.use('/api/desk-showcase', require('./routes/deskShowcase'));
// Session 10 — Sentry's Express error handler catches uncaught
// errors from every route mounted above. Must come AFTER routes but
+26
View File
@@ -0,0 +1,26 @@
'use strict';
/**
* GET /api/desk-showcase (Truth-Everywhere Part 2, item 6) — REAL data for the
* pricing Desk showcase (alt-line ladder + same-team correlation). Public,
* cache-only. { available:false } when the board has nothing → the visuals hide.
*/
const express = require('express');
const { createRateLimit } = require('../middleware/rateLimit');
const deskShowcaseService = require('../services/deskShowcaseService');
const router = express.Router();
router.use(createRateLimit({ windowMs: 60_000, max: 60 }));
router.get('/', async (req, res) => {
try {
const data = await deskShowcaseService.getDeskShowcase({});
res.set('Cache-Control', 'public, max-age=300');
return res.json(data);
} catch (err) {
console.error('[desk-showcase]', err.message);
return res.status(200).json({ available: false });
}
});
module.exports = router;
+98
View File
@@ -0,0 +1,98 @@
'use strict';
/**
* deskShowcaseService (Truth-Everywhere Part 2, item 6) — REAL data for the
* pricing-page Desk showcase. The ladder/Kelly/phi were hardcoded mocks; this
* feeds the flagship demo from the pre-graded snapshot, or returns nothing so
* the visuals HIDE (real-or-hidden, same law as the hero). No grading, no
* credits — cache reads only.
*
* - ladder: a real A/B graded prop's alt-line ladder (line + grade; the edge
* is shown only when it's a plausible market value, else omitted — the
* (model-line)/line metric is huge on 0.5-lines and would look fake).
* - parlay: the model's real same-team correlation (0.34, mirrors the frontend
* parlayMath team constant) computed for TWO REAL same-team A/B legs. No
* real pair on the board → null (hidden), never an invented number.
* - kelly: null — the snapshot carries no odds, so a real quarter-Kelly % can't
* be computed here. The tile hides rather than show a fabricated 2.4%.
*/
const DEFAULT_SPORTS = ['nba', 'wnba', 'mlb', 'soccer'];
const TEAM_CORRELATION = 0.34; // mirrors web parlayMath: same-team pairwise phi
const SANE_EDGE_MAX = 40; // beyond this the (model-line)/line value isn't a market edge
const isAB = (g) => /^[AB]/.test(String(g || '').trim().toUpperCase());
const distinctGrades = (ladder) => new Set((ladder || []).map((r) => r.grade)).size;
function rungsOf(alt) {
return (alt || [])
.filter((r) => r && Number.isFinite(Number(r.line)) && r.grade)
.map((r) => {
const edge = Number(r.edge_pct);
return {
line: Number(r.line),
grade: r.grade,
base: !!r.base,
// guard the small-line artifact: show an edge only when it's plausible
edge: Number.isFinite(edge) && Math.abs(edge) <= SANE_EDGE_MAX ? Math.round(edge * 10) / 10 : null,
};
})
.sort((a, b) => a.line - b.line);
}
async function getDeskShowcase(deps = {}) {
const cacheGet = deps.cacheGet || require('../utils/redis').cacheGet;
const sports = deps.sports || DEFAULT_SPORTS;
const ab = [];
for (const sport of sports) {
let grades = null;
const snap = await cacheGet(`snapshot:${sport}:latest`);
if (snap && Array.isArray(snap.grades)) grades = snap.grades;
else {
const env = await cacheGet(`grades:${sport}`);
if (env && Array.isArray(env.grades)) grades = env.grades;
}
for (const g of grades || []) {
if (!g || g.insufficient_data || !isAB(g.grade)) continue;
ab.push({ g, sport });
}
}
// Ladder: prefer the prop whose ladder shows the MOST grade variation (the
// most compelling REAL example — "A here, C there"), then longest ladder.
let best = null, bestScore = -1;
for (const { g, sport } of ab) {
const rungs = rungsOf(g.alt_lines);
if (rungs.length < 2) continue;
const score = distinctGrades(rungs) * 100 + rungs.length;
if (score > bestScore) { bestScore = score; best = { g, sport, rungs }; }
}
if (!best) return { available: false };
const ladder = {
player: best.g.player_name || best.g.player || null,
stat_type: best.g.stat_type || best.g.stat || null,
sport: best.sport,
rungs: best.rungs,
};
// Parlay phi: two REAL A/B legs on the same (non-null) team.
let parlay = null;
const byTeam = {};
for (const { g } of ab) {
const t = g.team ? String(g.team) : null;
const name = g.player_name || g.player;
if (!t || !name) continue;
(byTeam[t] = byTeam[t] || []).push(name);
}
for (const [team, names] of Object.entries(byTeam)) {
const uniq = [...new Set(names)];
if (uniq.length >= 2) { parlay = { value: TEAM_CORRELATION, legs: [uniq[0], uniq[1]], team }; break; }
}
return { available: true, ladder, parlay, kelly: null };
}
module.exports = { getDeskShowcase, __internals: { rungsOf, isAB, SANE_EDGE_MAX, TEAM_CORRELATION } };