Skip to content

Store baseline counts and fix dataset-aware reruns - #24

Merged
Burdantes merged 2 commits into
mainfrom
codex/n-baseline-rerun-fixes
Aug 15, 2026
Merged

Store baseline counts and fix dataset-aware reruns#24
Burdantes merged 2 commits into
mainfrom
codex/n-baseline-rerun-fixes

Conversation

@Burdantes

@Burdantes Burdantes commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

What changed

  • Adds the stored n_baseline count alongside n_dayof in Step 07 without adding another partition scan.
  • Adds the idempotent production schema migration and bootstrap ordering.
  • Makes table reruns substitute the selected dataset and fail non-zero when any date fails.

Why

The original Step 0 branch was squash-merged in #23, then these two follow-up commits were added to that already-merged branch. Reusing it made GitHub compare the pre-squash history again and produced merge conflicts. This PR reapplies only the two new commits on current main.

Impact

Consumers can use detector-aligned stored sufficiency counts instead of recomputing them from the large event partition. Reruns now target the requested dataset safely.

Validation

  • 44 focused tests passed.
  • Ruff checks passed.
  • Ruff formatting check passed.
  • git diff --check passed.
  • The focused tests ran locally in the existing Python 3.11 virtual environment. Full local collection requires the repository's declared Python 3.14 runtime; GitHub CI ran the complete lint/type/test job under the supported environment and passed.

Burdantes and others added 2 commits August 14, 2026 23:12
…cy counts

n_dayof already told a consumer how many day-of measurements a group had; there
was no companion for the baseline window, so anything needing both re-derived
them by aggregating events_with_as_and_geoloc itself. The dashboard did that on
every page load -- 8 GiB for a 7-day range, 84 GiB for 90 days, against a table
of 10.4 billion rows -- and did it on a coarser key (short city) than the
detector groups on, which is the same pooling that let a 6-measurement group
pass a 20-measurement threshold on its neighbours' totals.

- dayof_counts becomes group_counts and emits both counts from ONE pass, with
  the window split moved from WHERE into COUNTIF. No new scan of the partition:
  the reference count to events_with_as_and_geoloc is unchanged at 7.
- n_baseline is threaded through resolved/unresolved/combined to final_result
  and added to the INSERT column list, last, matching where ALTER TABLE ADD
  COLUMN puts it on the live tables.
- add_n_baseline_column.sql joins bootstrap_tables.DDL_FILES. This is load
  bearing: create_events_explained_daily.sql is CREATE TABLE IF NOT EXISTS, a
  no-op on the existing table, so nothing else would ever add the column and
  step 07's INSERT would fail against it.
- verify_group_identity check 4 now also flags a NULL n_baseline. Zero is a
  legitimate value there (a group with no trailing measurements), so only NULL
  counts as a fault.

Verified against hermes_union 2026-08-12: the refactored COUNTIF reproduces the
stored n_dayof on 2728 of 2728 rows, zero disagreements, zero unmatched.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Burdantes
Burdantes marked this pull request as ready for review August 15, 2026 13:24
@Burdantes
Burdantes merged commit 34d505b into main Aug 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant