mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 20:42:43 +00:00
Two suites pin that the windowed slope / r2 / population-sd composed from the rollup accumulators equals the live Postgres REGR_SLOPE / REGR_R2 / STDDEV_POP over the same raw rows. compose-regression.test.ts (container-free) builds per-DAY-bucket accumulators from a raw fixture exactly as the populator's SUM terms do, then asserts composeRegression over those buckets equals a direct OLS over the flat raw rows - the same closed form Postgres folds - on an uneven multi-bucket fixture, plus the coverage contract (NULL accumulator, < 2 readings, and zero-x-variance all return a full miss so the reader falls back to live SQL). rollup-regression-parity.integration.test.ts (real Postgres testcontainer) seeds raw measurements across many uneven DAY buckets, folds the rollups, and compares the accumulator compose to live REGR_*/STDDEV_POP to <= 1e-9: a single-source WEIGHT series, a dual-source RHR series proving the source-collapse runs BEFORE accumulator summation (composed == live WHOOP -only, != the cross-source blend), and a DST-boundary series confirming the UTC epoch-day x-axis parity-matches across the transition. The residual is pure floating-point reassociation (per-bucket-then-window vs flat summation), orders of magnitude below the read tier's rounding.