Repository navigation
fix(insights): rank the Rest outcome on the Rest score, strap-only nights included - #2940
Open
matthiasthomas wants to merge 2 commits into
Open
matthiasthomas wants to merge 2 commits into
matthiasthomas wants to merge 2 commits into
Conversation
Insights and the Insights Hub picked DailyMetric.efficiency for the outcome they label "Rest". That is a different metric from the sleep_performance score Apple's Insights ranks, and normally a 0-1 fraction formatted as a whole percent, so group means read about "1%" and deltas rounded to zero. The Rest/Charge correlation and Rest experiments read the same column. Both screens now read Rest through resolvedSeries with the active strap id, the read Trends, Today and Health already use, so the outcome is 0-100 and a night without a Rest score is absent. The dose model is unaffected: its documented outcomes are Charge and HRV. Apple's Insights still reads only the imported series, so strap-only nights have a Rest outcome on Android and none there. That is left unchanged here. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Insights and the Insights Hub read the imported sleep_performance series alone, so a strap-only wearer had no Rest effects, Rest/Charge relationship or Rest experiments while Today and Trends showed a Rest score. That read predates on-device Rest (it landed two days before v2.6.0) and was copied into the Hub later. Both screens now load every outcome through one shared read. Rest goes through resolvedSeries, the same read Android's Insights uses: the import wins, else the on-device composite, else the composite derived from the day's totals. Charge, HRV and RHR are unchanged. The ryanbr#833 snapshot stays correct: the engine derives Rest from the daily row it persists in the same transaction, so a re-scored night moves refreshSeq. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
n1c
pushed a commit
to n1c/noop
that referenced
this pull request
Nov 26, 2026
…n the Rest score, strap-only nights included ryanbr#2940 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CZyrZuBf2575a3s8MZTqNZ
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.
What this PR does
Makes the "Rest" outcome in Insights and the Insights Hub the Rest score on both platforms, for the same nights.
Android picked
DailyMetric.efficiencyfor the outcome it labels "Rest". That is a different metric, normally a 0–1 fraction shown as a whole percent, so group means read about "1%" and deltas rounded to zero. The Rest ↔ Charge relationship and Rest experiments read the same column.Apple ranked the right metric but read only the imported
sleep_performanceseries. A strap-only wearer had no Rest effects, relationship or experiments, while Today and Trends showed a Rest score for the same nights. The comment calls this import-only because there was "no daily column"; it landed in v1.80, two days before v2.6.0 added on-device Rest, and was later copied into the Hub.Fix: both platforms resolve Rest through
resolvedSeries: the import wins, else the on-device composite, else the composite derived from the day's totals. A night without a Rest score is absent and never falls back to efficiency.Scope:
Repository.insightsOutcomeDays.refreshSeq.Type of change
How it was tested
InsightsRestOutcomeTests(Swift) andInsightsRestOutcomeTest(Kotlin) cover imported, computed and derived nights after a strap re-add, a night without Rest, the other three outcomes, and a ranked effect end to end. The Swift side also pins that a re-scored night drops the snapshot.StrandTests(macOS): 2,272 tests. The only failures are the two timezone tests fix(dates): show day-keyed dates on their own day in every time zone #2723 fixes; they also fail without this change.NOOPiOSbuilds.testFullDebugUnitTest: 6,643 tests, 2 failures, both inRecoveryDriversTest, which also fail locally without these changes.InsightsScreenoutcome enum is private, so its half is checked as source. No BLE path is touched.Checklist
swift testinPackages/<name>): n/a, no package touchedandroid/: all but the 2RecoveryDriversTestfailures aboveStrandDesigntokens: n/a, no styling changedocs/CONTRIBUTING.mdStrand.xcodeproj/) or any secrets/keystoresRelated issues
None found.
🤖 Generated with Claude Code