Fix the ROOT: bind props to their real game, never date by the grade clock

Order 1.5 Phase 1. PropLine emits NO commence_time (grep-verified: zero
hits in proplineAdapter), so ledgerService's
`dateET(prop.game_time) || dateET(gradedTs)` always fell through to the
GRADE timestamp — and a 01:00/03:00 UTC snapshot is 21:00/23:00 ET the
PREVIOUS day. Tonight's props were filed under yesterday, settlement
correctly found no game there, and Order 1's void logic turned that into
64 destroyed results.

gameBinder.attachGameTimes() now matches every prop to a scheduled game by
TEAMS across the plausible ET window (grade date, +1, -1) and attaches the
GAME'S OWN time/date/id. It runs in snapshotService before grading and
before the ledger write, so ledger, retention and settlement all inherit
the correct date from one place.

HARD CONTRACT: an unbindable prop returns NOTHING. ledgerService no longer
has a grade-clock fallback — a row with no real game time is SKIPPED and
counted, because a mis-dated row is fabricated data and the ledger holds
real values or nothing. A slate that binds nothing pages.

DOUBLEHEADERS are reported, never guessed: two games with the same teams
on one date mark the binding `ambiguous` so settlement can decline rather
than attribute a prop to the wrong game. (Real example already in the
data: mlb:2026-07-11:MilwaukeeBrewers@PittsburghPirates(Game1).)

Also fixes retention, which had the SAME bug from last night — I had
dated model_snapshots rows with the snapshot clock. Rows now take the ET
date of the bound game_time.

Suite 282/3381 green, build exit 0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SmNjJAwEnqHPtXbvSZR8kA
This commit is contained in:
Kev
2026-07-20 03:25:01 -04:00
parent 270c4db47a
commit 1bcdd8b305
5 changed files with 284 additions and 2 deletions
+12 -1
View File
@@ -185,6 +185,7 @@ function oddsForSide(prop, side) {
*/
function rowsFromSnapshot(sport, grades, oddsProps, nowIso) {
const sp = String(sport || '').toLowerCase();
let skippedUnbound = 0;
const byKey = indexProps(oddsProps);
const rows = [];
for (const g of grades || []) {
@@ -199,7 +200,14 @@ function rowsFromSnapshot(sport, grades, oddsProps, nowIso) {
if (line == null) continue; // no real captured line → no row
const prop = byKey[`${nameKey(player)}|${stat}`] || null;
const gradedTs = locked.timestamp || nowIso;
const gameDate = dateET(prop && prop.game_time) || dateET(gradedTs) || todayET();
// Session 64 (Order 1.5) — a game date comes from the GAME, never from the
// grade clock. The old `|| dateET(gradedTs) || todayET()` fallback is what
// filed tonight's props under yesterday and made settlement impossible.
// gameBinder attaches game_time upstream; if a prop still has none, the
// row is UNRESOLVED and is skipped — the ledger holds real values or
// nothing, and a mis-dated row is fabricated data.
const gameDate = dateET(prop && prop.game_time) || (prop && prop.game_date) || null;
if (!gameDate) { skippedUnbound += 1; continue; }
const { team, opponent } = teamOpponentFor(g, prop);
rows.push({
team,
@@ -226,6 +234,9 @@ function rowsFromSnapshot(sport, grades, oddsProps, nowIso) {
game_date: gameDate,
});
}
if (skippedUnbound > 0) {
console.warn(`[ledger] ${skippedUnbound} ${sp} rows SKIPPED — no real game time; refusing to date them from the grade clock`);
}
return rows;
}