Session 58: Phase 1 — Truth Infrastructure (2327 tests)

ledger_entries is live (migration 019 applied to prod, RLS + NULLS NOT
DISTINCT dedupe verified against the real database). Every grade now
persists, settles against the real result, and carries closing-line value.

- ledgerService: pipeline pre-grade upserts (public model record, user_id
  null, idempotent), closing capture on every snapshot (last write before
  game start = the close), settlement with SIGNED CLV (over = locked -
  closing; beat/faded/flat), 30d model aggregate with the hard n>=20 rule.
- Write paths: snapshotService -> ledger (priority path); Next /api/scan ->
  ledger for authenticated users only (anon never touches the public
  record). Refused reads write nothing and don't burn a scan.
- Honest refusal (work-order 1.5): no projection => insufficient_data,
  grade null, "INSUFFICIENT DATA - no read" UI. The web gradeAdapter no
  longer displays the line as the model projection (the audit's
  model==line / +0% edge degenerate); the card renders absent states.
  projectionFor is sport-aware (l5 -> l20 -> {stat}_per_90 -> xG).
- /ledger: MY READS | MODEL tabs; model header shows hit% + beat-close%
  only at n>=20, else RECORD BUILDING + live pending count. ModelRecord
  deferred-render strip on landing + player hero. CLV + outcome chips,
  revised_from_grade strikethrough (Phase 2.5 ready).
- SYNC (Task 5): thresholds vs SNAPSHOT_EXPECTED_INTERVAL (normal <1.5x,
  amber >=1.5x, STALE red >=3x) via /api/snapshot/summary.
- Phase 2.5 logged in specs/vyndr-roadmap.md (build after Phase 3).
- Data-semantics hardening: strict null-safe numeric parsing everywhere a
  market value is handled (Number(null)===0 would have fabricated lines).

Backend 2309 -> 2327 tests (201 suites), web build exit 0.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Kev
2026-07-10 21:34:26 -04:00
parent 2c79373a3b
commit d296e40cb6
29 changed files with 1578 additions and 223 deletions
+38 -3
View File
@@ -4,9 +4,44 @@
2026-07-10
## Current Phase
SHIP BUILD v57.0 — Phase 0 "Kill the Lies" (work order, Jul 10 live audit):
every fabricated UI element deleted or rewired to real data. Next: Phase 1
(ledger persistence + settlement — the truth infrastructure).
SHIP BUILD v58.0 — Phase 1 "Truth Infrastructure": ledger_entries live in
Supabase (migration applied + RLS verified), both write paths wired, nightly
settlement + CLV, /ledger MY READS | MODEL tabs, honest scan refusals.
Next: work-order Phase 2 (slate UX) + Phase 3 (mobile), then Phase 2.5.
## Session 58 (2026-07-10) — SHIPPED ✅ PHASE 1: TRUTH INFRASTRUCTURE
Backend 2309 → **2327 tests** (+18), 201 suites. Web build clean (exit 0).
Spec: `specs/phase-1-truth-infrastructure.md`. Migration
`supabase/migrations/019_ledger_entries.sql` APPLIED to prod (betonblk) —
dedupe (`UNIQUE NULLS NOT DISTINCT`) + RLS verified live (anon reads public
rows only; anon INSERT rejected 42501).
- **ledgerService** — recordPipelineGrades (public model record, idempotent
ignoreDuplicates upsert), captureClosing (every snapshot overwrites today's
closing_line/odds from the real feed; last write before game start = close),
settleLedger (outcome + actual + SIGNED CLV: over = lockedclosing),
getModelAggregate (30d; percentages NULL under 20 settles). No-ops without
SUPABASE env. `Number(null)===0` fabrication bug caught by tests → strict
numOrNull everywhere.
- **Write paths:** snapshotService → ledger (user_id null, priority path);
Next /api/scan → ledger row for AUTHED users only (anon would pollute the
public record). Refused reads write NOTHING (no scan_history either) and
don't burn a scan.
- **Honest refusal (work-order 1.5):** analyzeViaEngine1 returns
`insufficient_data: true, grade: null` when the model has no projection
(l5→l20→{stat}_per_90→xG for soccer). The web gradeAdapter no longer
displays the LINE as the projection (the audit's model==line degenerate);
GradeResultCard renders "—" absent states; scan page renders
"INSUFFICIENT DATA — NO READ".
- **/ledger:** MY READS | MODEL tabs; model header shows "H-M · X% HIT ·
Y% BEAT CLOSE" only at n≥20, else "RECORD BUILDING" + pending count.
ModelRecord component mounted on landing + player hero (deferred-render).
- **SYNC (Task 5):** thresholds vs SNAPSHOT_EXPECTED_INTERVAL (default
18000s): normal <1.5x · amber ≥1.5x · STALE red ≥3x.
- **Phase 2.5 LOGGED** in specs/vyndr-roadmap.md (intraday refresh +
STEAM/VALUE/revision handling; build after Phase 3).
- **Settle trigger:** scheduler settle pass + POST /api/internal/ledger/settle.
## Session 57 (2026-07-10) — SHIPPED ✅ PHASE 0: KILL THE LIES