P0-3b/c: consensus grouped by player + ledger cards nest alt lines as a ladder

Completes P0-3 across all three surfaces:
- CONSENSUS VS MODEL (MarketBreadth): dedupe by player+market so Ben Williamson's
  alt-line variants show as ONE consensus row (no per-market cap — a consensus
  table just shouldn't repeat a player).
- LEDGER cards: group by player+market via groupIntoLadders — Alec Bohm's
  strikeout ladder (U1.6/U1.3/O1.5) is now ONE card with the rungs nested (each
  its own side/line + tier-colored grade), not three separate cards.
- playerGrouping reads player OR player_name (ledger rows use player_name) —
  regression-tested so the ledger doesn't silently empty.

The Alt Line Ladder shape is what /pricing already demos; the record now uses it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kev
2026-07-17 01:07:28 -04:00
parent 55f5cdc57d
commit db61876b2f
4 changed files with 49 additions and 12 deletions
+7 -5
View File
@@ -37,8 +37,9 @@ function dedupeLeaders(rows, perMarketCap = 4) {
const marketCount = new Map();
const out = [];
for (const r of Array.isArray(rows) ? rows : []) {
if (!r || !r.player) continue;
const key = playerMarketKey(r.player, r.stat);
const who = r.player || r.player_name;
if (!r || !who) continue;
const key = playerMarketKey(who, r.stat);
if (seen.has(key)) continue; // one row per player+market
const fam = marketFamily(r.stat);
const n = marketCount.get(fam) || 0;
@@ -64,10 +65,11 @@ function groupIntoLadders(rows, betterOf) {
const byKey = new Map();
const order = [];
for (const r of Array.isArray(rows) ? rows : []) {
if (!r || !r.player) continue;
const key = playerMarketKey(r.player, r.stat);
const who = r.player || r.player_name;
if (!r || !who) continue;
const key = playerMarketKey(who, r.stat);
if (!byKey.has(key)) {
byKey.set(key, { player: r.player, stat: r.stat, market: marketFamily(r.stat), primary: r, ladder: [r] });
byKey.set(key, { player: who, stat: r.stat, market: marketFamily(r.stat), primary: r, ladder: [r] });
order.push(key);
} else {
const g = byKey.get(key);