A cohort is a snapshot_id, not a date slice of one

Found by cross-checking the observer against an independent SQL derivation of
the same natural cohort instead of accepting its own answer.

The 2026-08-31 03:00Z run held 1,970 rows across TWO game_dates — 1,572 on
08-31 and 398 on 08-30, the late slot spanning midnight ET. The observer
selected the head row's date and filtered to it, so it measured 646 of the 801
eligible keys and reported HEALTHY. Both slices happened to be fully covered,
so the verdict was right by luck; a date slice with zero lineage would have
been invisible behind it.

The audit now covers the whole snapshot_id and reports every game_date it
spans. A test builds the real two-date shape with one slice uncovered and
requires PARTIAL_COVERAGE.

Suite 397/5,499/0 · 15/15 teeth.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CQJeAG8vcDoL5zkiaJyVb8
This commit is contained in:
Kev
2026-08-30 23:10:41 -04:00
parent 1bdc3baec7
commit 1728ce4fac
2 changed files with 31 additions and 3 deletions
+11 -3
View File
@@ -190,6 +190,7 @@ async function auditLatestCohort(sport, deps = {}) {
const supabase = getClient();
if (!supabase) return Object.freeze({ audit_available: false, reason: 'no_supabase_env', sport: sp, health: HEALTH.AUDIT_UNAVAILABLE });
// The head identifies the COHORT (snapshot_id), not one date within it.
const { data: head, error: headErr } = await supabase
.from('model_snapshots')
.select('snapshot_id, game_date, captured_at, code_sha')
@@ -202,15 +203,22 @@ async function auditLatestCohort(sport, deps = {}) {
const h = head[0];
const { paginate } = require('../utils/safePaginate');
// A COHORT IS A snapshot_id, NOT A DATE SLICE OF ONE.
//
// Measured on the 2026-08-31 03:00Z run: the cohort held 1,970 rows across
// TWO game_dates (1,572 on 08-31 and 398 on 08-30, the late slot spanning
// midnight ET). Filtering to the head row's date measured 646 of 801
// eligible keys and still reported HEALTHY — so a whole date slice with
// zero lineage would have been invisible. The audit covers the cohort.
const rows = await paginate(() => supabase
.from('model_snapshots')
.select(AUDIT_COLUMNS)
.eq('snapshot_id', h.snapshot_id)
.eq('sport', sp)
.eq('game_date', h.game_date), { key: 'id', label: 'lineageCoverage.auditLatestCohort' });
.eq('sport', sp), { key: 'id', label: 'lineageCoverage.auditLatestCohort' });
const audit = auditRows(rows, {
snapshot_id: h.snapshot_id, sport: sp, game_date: h.game_date,
snapshot_id: h.snapshot_id, sport: sp,
game_date: [...new Set(rows.map((r) => r.game_date))].sort().join(','),
code_sha: h.code_sha, captured_at: h.captured_at,
retention_terminal: deps.retentionTerminal ?? null,
});