P2-9: leaderboard stat labels (SB/ER/TB) + FLAG the grade-degradation root cause
DISPLAY FIX (shipped): the league leaderboard rendered raw snake_case
("stolen_bases U0.5", "earned_runs U2.5"). New canonical short-label lib
web/src/lib/statAbbrev.js (one source, CommonJS + unit-tested) maps stat_type
to SB/ER/TB/HR/K/PTS/… and ExploreHub routes through it. Unknown ids upper-case
their words so raw snake_case can never leak again.
FLAG (reported, NOT silently changed — per the audit's instruction): the "B at
45% confidence" is a BACKEND grading issue, diagnosed against live snapshot:
- 25/25 grades mismatch their own confidence vs grade_thresholds.json (B shown
at conf 55 = the B- band; a systematic one-sub-tier gap on every prop). The
surfaced `confidence` is not the probability that derived the letter (likely
the data-sufficiency penalty applied to display-only).
- 9/25 have projection=0 — the MLB feature path feeds 0 instead of refusing
(S58 insufficient_data), which also produces the P1-7 broken edge_pct.
Full write-up + do-not list: specs/audit-data/mlb-grade-degradation.md. NOT
re-lettering or shifting thresholds on the frontend — that would hide the bug.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
# MLB Grade Pipeline Degradation — Backend Finding (2026-07-17)
|
||||||
|
|
||||||
|
Source: phone-audit P1-7 (broken edge board) + P2-9 (B grades at 45% confidence).
|
||||||
|
Diagnosed against LIVE `GET /api/snapshot/mlb` on 2026-07-17. This is a BACKEND
|
||||||
|
grading/feature-pipeline issue, NOT a frontend display bug. The frontend guards
|
||||||
|
(sane-edge cap, statAbbrev) are damage control, not the fix.
|
||||||
|
|
||||||
|
## The evidence (25 live MLB grades)
|
||||||
|
- **projection == 0 for 9/25.** The model has no projection reference for a third
|
||||||
|
of props — a degraded feature path (the S58 insufficient-data refusal should
|
||||||
|
have caught these; instead they graded with projection 0).
|
||||||
|
- **edge_pct on a broken scale.** Distinct values {20, 60, 100, 140}. A real
|
||||||
|
prop-market edge is single-digit %, never past ~40. These are not a market edge
|
||||||
|
(frontend now shows them absent — slateAdapter EDGE_BOARD_SANE_MAX / EdgeCell).
|
||||||
|
- **grade <-> confidence mismatch on 25/25.** Every grade's letter disagrees with
|
||||||
|
its own surfaced `confidence` vs `grade_thresholds.json`:
|
||||||
|
- B shown at confidence 55 -> 55 is the B- band (55-59), not B (60-65).
|
||||||
|
- Systematic ~5-point (one sub-tier) gap on every prop.
|
||||||
|
The surfaced `confidence` is NOT the probability that derived the letter.
|
||||||
|
|
||||||
|
## Likely root cause (to investigate, not yet fixed)
|
||||||
|
1. `confidence` field is post-`apply_data_sufficiency_modifier` (bayesian.py),
|
||||||
|
while the grade letter was assigned from the PRE-penalty prob -> the two
|
||||||
|
disagree by one sub-tier on every prop. Either surface the same value, or
|
||||||
|
re-letter from the penalized confidence. Decide which is the source of truth.
|
||||||
|
2. projection==0 for 9/25: the MLB feature/projection path is feeding 0 instead
|
||||||
|
of refusing (S58 `insufficient_data`). Trace `projectionFor` for MLB props;
|
||||||
|
projection 0 also breaks `computeEdge` (=> the 20/60/100/140 garbage).
|
||||||
|
|
||||||
|
## Do NOT
|
||||||
|
- Do not re-letter or shift thresholds on the frontend (would hide the bug).
|
||||||
|
- Do not "fix" edge display by rescaling 140 -> 14 (guessing the scale is its own
|
||||||
|
fabrication). The number must come out of the pipeline correct.
|
||||||
|
|
||||||
|
## Frontend already shipped (honest guards)
|
||||||
|
- Leaderboard stat labels: `web/src/lib/statAbbrev.js` (raw snake_case -> SB/ER/TB).
|
||||||
|
- Edge board: impossible |edge|>40 rendered absent AND excluded from ranking.
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// P2-9 — the canonical SHORT stat label. Raw snake_case ("stolen_bases U0.5")
|
||||||
|
// on the leaderboard was the display bug; lock the abbreviations the audit named.
|
||||||
|
|
||||||
|
const { statAbbrev, STAT_ABBREV } = require('../../web/src/lib/statAbbrev');
|
||||||
|
|
||||||
|
describe('statAbbrev', () => {
|
||||||
|
test('the audit-named MLB stats map to short labels', () => {
|
||||||
|
expect(statAbbrev('stolen_bases')).toBe('SB');
|
||||||
|
expect(statAbbrev('earned_runs')).toBe('ER');
|
||||||
|
expect(statAbbrev('total_bases')).toBe('TB');
|
||||||
|
expect(statAbbrev('home_runs')).toBe('HR');
|
||||||
|
expect(statAbbrev('strikeouts')).toBe('K');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('NBA stats too', () => {
|
||||||
|
expect(statAbbrev('points')).toBe('PTS');
|
||||||
|
expect(statAbbrev('rebounds')).toBe('REB');
|
||||||
|
expect(statAbbrev('assists')).toBe('AST');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('an unknown id upper-cases its words (never leaks raw snake_case)', () => {
|
||||||
|
expect(statAbbrev('some_new_stat')).toBe('SOME NEW STAT');
|
||||||
|
expect(statAbbrev('some_new_stat')).not.toContain('_');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('null / empty is safe', () => {
|
||||||
|
expect(statAbbrev(null)).toBe('');
|
||||||
|
expect(statAbbrev('')).toBe('');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('no label contains an underscore (all are real abbreviations)', () => {
|
||||||
|
for (const v of Object.values(STAT_ABBREV)) expect(v).not.toContain('_');
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -5,6 +5,7 @@ import SportBadge from '@/components/vyndr/SportBadge';
|
|||||||
import GradeBadge from '@/components/vyndr/GradeBadge';
|
import GradeBadge from '@/components/vyndr/GradeBadge';
|
||||||
import { playerHref } from '@/lib/playerHref';
|
import { playerHref } from '@/lib/playerHref';
|
||||||
import { dedupeLeaders } from '@/lib/playerGrouping';
|
import { dedupeLeaders } from '@/lib/playerGrouping';
|
||||||
|
import { statAbbrev } from '@/lib/statAbbrev';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ExploreHub (Session 42 leaders; Session 60 night2/C — THE AGGREGATOR).
|
* ExploreHub (Session 42 leaders; Session 60 night2/C — THE AGGREGATOR).
|
||||||
@@ -147,7 +148,7 @@ export default function ExploreHub() {
|
|||||||
<span style={{ fontWeight: 700, fontSize: 13, color: '#fff', whiteSpace: 'nowrap' }}>{r.player}</span>
|
<span style={{ fontWeight: 700, fontSize: 13, color: '#fff', whiteSpace: 'nowrap' }}>{r.player}</span>
|
||||||
{r.team && <span className="mono" style={{ fontSize: 10, color: 'var(--text-1)' }}>{r.team}</span>}
|
{r.team && <span className="mono" style={{ fontSize: 10, color: 'var(--text-1)' }}>{r.team}</span>}
|
||||||
</div>
|
</div>
|
||||||
<div className="mono" style={{ textAlign: 'right', fontSize: 12, color: '#C8CCD6' }}>{r.stat} {r.side}{r.line}</div>
|
<div className="mono" style={{ textAlign: 'right', fontSize: 12, color: '#C8CCD6' }}>{statAbbrev(r.stat)} {r.side}{r.line}</div>
|
||||||
<div className="mono" style={{ textAlign: 'right', fontSize: 13, fontWeight: 600, color: 'var(--text-0)' }}>{r.confidence != null ? `${r.confidence}%` : '—'}</div>
|
<div className="mono" style={{ textAlign: 'right', fontSize: 13, fontWeight: 600, color: 'var(--text-0)' }}>{r.confidence != null ? `${r.confidence}%` : '—'}</div>
|
||||||
<div style={{ display: 'flex', justifyContent: 'center' }}><GradeBadge grade={r.grade} size="sm" /></div>
|
<div style={{ display: 'flex', justifyContent: 'center' }}><GradeBadge grade={r.grade} size="sm" /></div>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/**
|
||||||
|
* statAbbrev — the ONE canonical SHORT stat label ("total_bases" -> "TB").
|
||||||
|
*
|
||||||
|
* The compact, mono, grid-aligned surfaces (leaderboard, breadth, top signals)
|
||||||
|
* want abbreviations, not the long "Total Bases" form gradeAdapter.statLabel
|
||||||
|
* emits for the roomy grade card. Raw snake_case ("stolen_bases U0.5") is a
|
||||||
|
* display bug — every ranked/gridded surface routes stat_type through here.
|
||||||
|
*
|
||||||
|
* CommonJS so it's importable by .tsx (allowJs) AND unit-testable by Jest.
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
const STAT_ABBREV = {
|
||||||
|
// MLB — batting
|
||||||
|
total_bases: 'TB', home_runs: 'HR', hits: 'H', rbi: 'RBI', runs: 'R',
|
||||||
|
stolen_bases: 'SB', doubles: '2B', triples: '3B', walks: 'BB', singles: '1B',
|
||||||
|
// MLB — pitching
|
||||||
|
strikeouts: 'K', hits_allowed: 'HA', earned_runs: 'ER', innings_pitched: 'IP',
|
||||||
|
outs: 'OUTS', walks_allowed: 'BB',
|
||||||
|
// NBA / WNBA
|
||||||
|
points: 'PTS', rebounds: 'REB', assists: 'AST', threes: '3PT', steals: 'STL',
|
||||||
|
blocks: 'BLK', pra: 'PRA', turnovers: 'TO', pr: 'PR', pa: 'PA', ra: 'RA',
|
||||||
|
// NHL / soccer (best-effort)
|
||||||
|
shots_on_goal: 'SOG', saves: 'SV', goals: 'G', shots: 'SH',
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Short display label for a stat_type id; unknown ids upper-case the words. */
|
||||||
|
function statAbbrev(stat) {
|
||||||
|
if (!stat) return '';
|
||||||
|
if (STAT_ABBREV[stat]) return STAT_ABBREV[stat];
|
||||||
|
return String(stat).replace(/_/g, ' ').toUpperCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = { STAT_ABBREV, statAbbrev };
|
||||||
Reference in New Issue
Block a user