Free proof surface: /record — tier-record-forward, honest CLV building panel

Presentation over existing endpoints. src/ untouched (git diff empty): no grade,
model or ledger change. Pricing/migration are Builds 2/3.

TIER-RECORD-FORWARD. /record reads the canonical public aggregates (/api/accuracy
+ /api/ledger/model) and prints them as-is. B 60% n512 and C 57% n413 ship with C
honestly BELOW B; A (n2), D (n5) and F (n5) render HOLLOW with their real sample
instead of a rate. Sport slicing (all/mlb/wnba) is client-side because the
endpoints ignore ?sport= — mlb 526 @62%, wnba 411 @54% come from the sports map.

THE LOAD-BEARING RULE, enforced in lib/proofRecord.js and locked by tests: where
the source withholds a percentage it stays null. A is 1/2 and therefore 50% is
derivable — a test asserts we do NOT derive it, because the API withheld it on
purpose (n < 20).

CLV IS AN HONEST ABSENCE, NOT A NUMBER. beat_close_pct is null because
clvCaptureReliable() has not passed. The panel says "NOT PUBLISHED YET" and
explains that any percentage printed today would be measuring our collection gaps
as much as our edge; it surfaces the accruing sample (937) but no rate. Tests
assert the panel never falls back to clv_beat/clv_sample (34/937 = 3.6%) and that
the serialized panel contains no "3.6" — that number is computable and would be
wrong, which is the exact fabrication this surface exists to refuse. The panel is
built to receive a real number later without a redesign.

HELD, and named on the page rather than faked: calibration and accuracy-over-time
are absent because there is no honest source (no claimed-vs-actual endpoint;
window_days fixed at 30 with no series). The page says so, and says it is not
because they are unflattering.

A page-level test asserts no hard-coded percentage exists in the markup, so no
figure can drift from the aggregate, and that the page never touches /api/snapshot
or itemized rows — the Build-1 gate holds and the exploit stays dead.

Floor: 320 suites / 3986 tests green (16 new), web build exit 0.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QJs13VsyiSKYQP6rj3NNmc
This commit is contained in:
Kev
2026-07-31 07:53:44 -04:00
parent 4c302b5722
commit 5930f18d81
5 changed files with 364 additions and 2 deletions
+100
View File
@@ -0,0 +1,100 @@
'use strict';
/**
* FREE PROOF RECORD (2026-07-31) — display model for the public record surface.
*
* 🔴 THE ONE LAW: this module READS the canonical aggregates and never recomputes
* a prettier version. Where the source says `pct: null` it stays HOLLOW — it is
* null because the sample is under the threshold, and dividing hits/total here
* would manufacture a number the API deliberately withheld. No rounding, no
* smoothing, no "provisional" figure anywhere.
*
* Sources (both public, both already honest):
* /api/accuracy -> overall + byGrade + per-sport `sports` map
* /api/ledger/model -> aggregate (by_tier, clv_*)
*/
/** Strict pass-through: a real number stays, anything else is ABSENT (never 0). */
function pctOrNull(v) {
return typeof v === 'number' && Number.isFinite(v) ? v : null;
}
/**
* tierRows(byGrade, minSample) — one row per grade tier, in tier order.
* `hollow: true` means the source withheld a percentage; we show the sample and
* say so, rather than inventing a rate off a 2-row bucket.
*/
const TIER_ORDER = ['A+', 'A', 'B', 'C', 'D', 'F'];
function tierRows(byGrade, minSample) {
const src = byGrade && typeof byGrade === 'object' ? byGrade : {};
const min = Number.isFinite(Number(minSample)) ? Number(minSample) : 20;
const keys = TIER_ORDER.filter((k) => src[k]).concat(
Object.keys(src).filter((k) => !TIER_ORDER.includes(k)),
);
return keys.map((tier) => {
const b = src[tier] || {};
const total = Number(b.total) || 0;
const pct = pctOrNull(b.pct);
return {
tier,
total,
hits: Number(b.hits) || 0,
misses: Number(b.misses) || 0,
pct, // null => hollow, NEVER derived here
hollow: pct === null,
belowThreshold: total < min,
};
});
}
/**
* clvPanel(aggregate) — the honest CLV state.
*
* 🔴 NEVER RETURNS A NUMBER when the guard hasn't passed. `beat_close_pct` is
* null because `clvCaptureReliable()` is false — the capture instrument is not
* yet trustworthy — NOT because the division wasn't done. `clv_beat/clv_sample`
* (34/937 = 3.6%) is computable and would be WRONG; publishing it, even labelled
* "provisional", is the fabrication this surface exists to refuse.
*/
function clvPanel(aggregate) {
const a = aggregate && typeof aggregate === 'object' ? aggregate : {};
const published = pctOrNull(a.beat_close_pct);
if (published !== null) {
return { publishable: true, beatClosePct: published, sample: Number(a.clv_sample) || 0 };
}
return {
publishable: false,
beatClosePct: null, // stays null — no fallback, no estimate
sample: Number(a.clv_sample) || 0,
reason: 'capture_reliability', // the named guard, shown to the reader
};
}
/** Per-sport rows straight from the `sports` map — no re-derivation. */
function sportRows(sports) {
const src = sports && typeof sports === 'object' ? sports : {};
return Object.keys(src).map((sport) => {
const s = src[sport] || {};
return {
sport,
sample: Number(s.sample) || 0,
pct: pctOrNull((s.overall || {}).pct),
byGrade: s.byGrade || {},
minSample: Number(s.min_sample) || 20,
};
});
}
/** Client-side slice: the endpoints ignore ?sport=, so filtering happens here. */
function sliceFor(accuracy, sport) {
const d = accuracy && typeof accuracy === 'object' ? accuracy : {};
if (!sport || sport === 'all') {
const o = d.overall || {};
return { sample: Number(o.sample) || 0, pct: pctOrNull((o.overall || {}).pct),
byGrade: o.byGrade || {}, minSample: Number(o.min_sample) || 20 };
}
const s = (d.sports || {})[sport] || {};
return { sample: Number(s.sample) || 0, pct: pctOrNull((s.overall || {}).pct),
byGrade: s.byGrade || {}, minSample: Number(s.min_sample) || 20 };
}
module.exports = { pctOrNull, tierRows, clvPanel, sportRows, sliceFor, TIER_ORDER };