release/v1.28.31 — heart-rate history keeps its daily shape#477
Merged
Conversation
Long-term retention for the dense intra-day tier (PULSE, HRV, SpO2) folds to per-local-hour means instead of a single daily mean: the last 14 days keep every raw sample, older days keep up to 24 points per metric — the day's shape survives permanently at ~9k rows/metric/year. Hourly rows key as stats:<HK>:<YYYY-MM-DD>T<HH> anchored at local HH:30, adopt-in-place against both unique indexes with the P2002 retry outside the transaction. The pre-fold DAY-rollup recompute extends to HRV (mean fidelity, not only min/max) and the post-fold recompute is gone for the whole tier. Derived resting rows for proxy users still mint from the day's raw samples. A one-shot rebuild reconstructs the hourly shape for every already-folded day from the soft-deleted raw samples and retires the daily row in the same transaction — at no instant are both grains live, so no AVG-over-live-rows reader can double-count. Boot discovery pairs live daily-grain rows with surviving tombstones (parameter-bound SQL, pinned against real Postgres) and converges to zero once converted; days whose tombstones were pruned keep their daily mean. PULSE/SpO2 DAY buckets keep the true pre-fold stats; HRV DAY buckets recompute from the hourly rows (strictly better than the collapsed fold-time bucket); WEEK/MONTH/YEAR respans enqueue whole-bucket recomputes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Dense intra-day retention (PULSE / HRV / SpO2) now folds to hourly means instead of a single daily mean — the day's shape survives permanently (up to 24 points/day ≈ 9k rows/metric/year), while the last 14 days keep every raw sample as before.
Fold changes
stats:<HK>:<YYYY-MM-DD>T<HH>, local HH:30 anchor; stays understats:so the idempotency predicate keeps holding; never collides with the daily shape or iOS ISO-instant wire ids.One-shot history rebuild (pg-boss, boot-discovered, once per install)
Consumers audited: stress engine, readiness, coincident-deviation, day-detail chart paths — none assume one row per out-of-window day.
Gate: typecheck, lint, 13537 unit tests, dense-tier integration suites (real Postgres, both P2002 vectors + atomic retirement + convergence), prettier, knip, build, openapi:check — all green.