Session 42: Player Intelligence System — archetypes, stat strips, player profile, enhanced cards (2011 tests)

Built from the Claude Design "VYNDR Player Intelligence" bundle (10 sections).

- Archetypes: src/services/archetypeService.js — 41 archetypes (15 NBA / 5
  WNBA-unique / 15 MLB / 6 soccer), classify -> primary+secondary+blend.
  Frontend visual map web/src/lib/archetypes.js (colors verified == backend).
  ArchetypeBadge (full/ghost/tint + glyphs) + ArchetypeBlend (DNA bar).
- StatStrip (compact/expanded): player name once, horizontal mono stats,
  inline GradeBadge props, onPlayerClick -> profile.
- Stats API: extended src/routes/stats.js with /player/:name, /leaders,
  /game/:id (rate-limited). Aggregation in playerIntelService.js (sanitizes
  name param; grades cache; graceful on cold cache). Next proxies added.
- Player Profile /player/[name]: all 9 design sections, graceful empty states.
- Enhanced GameCard (MLB pitchers + player-grouped StatStrips) + GradeResultCard
  (archetype strip + stat context + VYNDR intelligence, optional/self-hiding via
  gradeAdapter.buildIntelFields). Player-name links wired everywhere.
- Settings page replaces the S41 redirect (account/subscription/notifications/
  display/responsible-play/danger-zone with DELETE-gated delete). LINKS to the
  real /settings/security MFA page — does not replace it. + BookChip.
- Bonus: Stats Explorer /explore (real /api/stats/leaders leaderboard); added
  Explore + Settings to Nav MORE.

Deferred (need data pipelines, Session 43): Team Hub, Offseason Intel, Slate
redesign, Stats Explorer sub-panels.

Backend 1940 -> 2011 tests (+71), 157 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-18 11:12:24 -04:00
parent 32069863dc
commit 8bc79f3c38
33 changed files with 2655 additions and 22 deletions
+34
View File
@@ -321,6 +321,40 @@ The 7-session design conversion (3339) is done and parity-verified against §
- **Profile tier** reads from `useAuth().tier` (the nav's source), not the
`/api/user/profile` fetch, so the two can't disagree.
## Player Intelligence System (Session 42 — non-obvious)
Built from the Claude Design "VYNDR Player Intelligence" bundle.
- **Archetypes (41, NOT 45)** — 15 NBA + 5 WNBA-unique + 15 MLB + 6 soccer. The
canonical registry is `src/services/archetypeService.js` (`ARCHETYPES` keyed by
UPPERCASE name; classify/getArchetype). The frontend visual map (color + glyph
SVG + desc) is duplicated in `web/src/lib/archetypes.js` because the browser
can't import the backend; a test asserts the colors MATCH. Colors are unique
WITHIN a sport but REUSED across sports (a TWO-WAY archetype is purple in NBA +
WNBA) — don't "dedupe" them. `classify(sport, stats)` is a feature-scoring
classifier → `{ primary, secondary|null, blend: [{archetype, weight}] }`.
- **StatStrip rule** — player name appears ONCE; stats are horizontal mono runs.
Never stack the name per stat. `components/vyndr/StatStrip.tsx` (compact +
expanded). `vyndr/GameCard` prefers `playerStrips` (grouped) over legacy
per-prop rows; both kept for back-comat.
- **Stats API** — `src/routes/stats.js` ALREADY existed (filters/public/live);
Session 42 ADDED `/player/:name`, `/leaders`, `/game/:id` (don't recreate the
file). Aggregation logic is in `src/services/playerIntelService.js` (testable;
inject `cacheGet`). The name param is sanitized there (strip non-name chars,
cap 60). Reads `grades:{sport}` cache for a player's props. Frontend needs the
Next proxy (`app/api/stats/player|leaders/route.ts`) — Express isn't reachable
from the browser directly (same rule as S25).
- **Player links** — always via `web/src/lib/playerHref.js` → `/player/:name?sport=`.
- **GradeResultCard / gradeAdapter** — new card sections (archetypeBlend, propDNA,
statContext, vyndrIntel) are OPTIONAL + self-hiding; `gradeAdapter.buildIntelFields`
only populates them when the engine supplies `archetype`/`season_avg`/`form`/etc.
They light up once the Session-43 data pipeline feeds them — no empty boxes now.
- **Settings** — `/settings` is now a REAL page (replaced the S41 redirect). It
LINKS to `/settings/security` (the real MFA page) — never overwrite that. Danger
zone delete is gated on `deleteText === 'DELETE'`; there's NO backend deletion
endpoint yet, so the confirmed action surfaces an honest "email support" message
rather than faking success.
- **Components added to the barrel**: ArchetypeBadge, ArchetypeBlend, StatStrip,
BookChip (`@/components/vyndr`). Book brand map = `web/src/lib/books.js`.
## Active Skills
- vyndr-voice (all user-facing output)
- prop-analysis (grading methodology)