Fire the resting-HR drift alert that was only ever declared - #121
Open
ak710 wants to merge 1 commit into
Open
Conversation
restingHRDrift has been a CoachAnomalyKind since the proactive-alert path landed, with a comment explaining why nothing raised it: the detector reads a 12-hour context packet, and drift is only meaningful against a multi-day baseline. But the baseline already exists — RestingHRBaselineService learns and persists it — so the packet just needed to carry it in. The night and the baseline are both measured as the interpolated 10th percentile of heart rate, sharing RestingHRBaselineService's own percentile helper. Comparing a night's mean against a 30-day percentile would have produced a difference that was mostly an artefact of the two formulas. The night is bounded by the sleep session rather than a fixed clock window, so a late night or a shift schedule is measured over the hours actually slept. Fires at +5 bpm and only upward — a resting HR below baseline is usually good news and not worth an unprompted alert. Gated on an established baseline, at least 10 overnight samples (a YCBT ring floors its interval at 30 minutes, so a full night is only ~14 there against ~84 on a 5-minute Colmi), and a night no more than two days old. Ordered last of the three detectors: a short night usually raises resting HR too, so when both trip the sleep alert names the cause while drift would only restate its consequence. Every threshold is documented in docs/project/anomaly-alerts.md, which also covers the two detectors that were already shipping but undocumented. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 3, 2026
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.
Closes #112
Merge order: 2 of 9. Branches off
main, independent of #120.What
restingHRDrifthas been aCoachAnomalyKindsince the proactive-alert path landed, with a comment explaining why nothing raised it: the detector reads a 12-hour packet, and drift needs a multi-day baseline. ButRestingHRBaselineServicealready learns and persists that baseline — it just never reached the packet.Design notes
RestingHRBaselineService's own helper (made internal, with the percentile constant named). Comparing a night's mean against a 30-day percentile would produce a difference that is mostly an artefact of the two formulas.Docs
docs/project/anomaly-alerts.mdis new and documents all three detectors — the two that were already shipping were undocumented.Testing
PulseLoopTests/RestingHRDriftTests.swift— 11 tests covering the threshold knots, both precedence cases, and the builder's percentile/sample-floor behaviour. Full suite green (882).