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
+20
View File
@@ -354,6 +354,26 @@ describe('coverage observer', () => {
.toEqual([...retention.VALID_LINEAGE_ACTION_FIELDS].sort());
});
test('a cohort spanning two game_dates is audited whole, not one slice', () => {
// The real 2026-08-31 03:00Z shape: a late slot spanning midnight ET. Rows
// from BOTH dates are eligible and both must be counted, or a date slice
// with no lineage stays invisible behind a HEALTHY verdict.
const mk = (d, p, covered) => ({
sport: 'mlb', game_date: d, player_key: p, stat: 'hits', side: 'over',
line: 0.5, published: true,
...(covered ? {
read_id: `r-${p}`, read_natural_key: `mlb|${d}|${p}|hits|over|0.500000`,
lineage_action: 'ORIGIN', claim_digest: 'd', revision_ordinal: 0,
lineage_state: 's', lineage_version: 'lin@1', claim_schema_version: 'claim@1',
digest_algorithm_version: 'sha256-json-sorted@1',
} : {}),
});
const a = coverage.auditRows([mk('2026-08-31', 'a', true), mk('2026-08-30', 'b', false)]);
expect(a.expected_keys).toBe(2);
expect(a.covered_keys).toBe(1);
expect(a.health).toBe(coverage.HEALTH.PARTIAL_COVERAGE);
});
test('an unavailable audit is not a coverage claim', () => {
expect(coverage.classify({ audit_available: false })).toBe(coverage.HEALTH.AUDIT_UNAVAILABLE);
});