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
+27 -2
View File
@@ -37,6 +37,8 @@ interface Player {
interface ScanResponse {
grade: string;
// Session 58 (work-order 1.5) — the model refused: no projection, no read.
insufficient_data?: boolean;
projection?: number;
confidence?: number;
sample_size?: number;
@@ -266,7 +268,8 @@ export default function ScanPage() {
return;
}
setResult(data);
bumpScanCount();
// Session 58 — a refused read (insufficient data) doesn't burn a scan.
if (!data.insufficient_data) bumpScanCount();
trackScanCompleted({
sport,
player: selectedPlayer,
@@ -689,9 +692,31 @@ export default function ScanPage() {
</div>
)}
{/* Session 58 (work-order 1.5) — the honest refusal. When the model has
no projection there is NO read: no grade letter, no fake +0% edge,
and nothing writes to the ledger. A refused read builds more trust
than a hollow one. */}
{result && result.insufficient_data && (
<div
className="surface scanlines"
style={{ marginTop: 32, padding: 32, textAlign: 'center', border: '1px solid var(--border-hi)', borderRadius: 10, display: 'grid', gap: 10, justifyItems: 'center' }}
>
<p className="mono" style={{ fontSize: 12, fontWeight: 800, letterSpacing: '0.14em', color: 'var(--amber)' }}>
INSUFFICIENT DATA NO READ
</p>
<p style={{ color: 'var(--text-1)', fontSize: 14, maxWidth: 460 }}>
The model has no projection for this prop, so it refuses to grade it.
No number gets invented here that&apos;s the deal.
</p>
<button onClick={reset} className="btn-ghost" style={{ marginTop: 6, padding: '10px 18px' }}>
Read another prop
</button>
</div>
)}
{/* Grade result — VYNDR 2.0 ProcessingGrade → GradeResultCard (Session 35).
Engine output is mapped to the §7 contract and tier-gated by the adapter. */}
{result && (
{result && !result.insufficient_data && (
<div style={{ marginTop: 32, display: 'grid', gap: 16 }}>
<ProcessingGrade
key={`${selectedPlayer}-${stat}-${line}-${direction}`}