Skip to content

fix(insights): read today's ranked vitals from the ladder-winning source - #1549

Merged
MBombeck merged 7 commits into
mainfrom
fix/today-reads-source-priority
Nov 26, 2026
Merged

MBombeck merged 7 commits into
mainfrom
fix/today-reads-source-priority

Conversation

@MBombeck

Copy link
Copy Markdown
Owner

Readiness, the coincident-deviation flag, the vitals baseline's live fold and the briefing's signals of the day mixed every source of a day for ranked vitals, while the metric page shows the ladder-winning source. Two devices reporting resting heart rate for one date produced a readiness value from their mean and a briefing signal from whichever row sorted last.

readDayAggregates now takes the source-priority blob and keeps each day to its first source in ladder order; readLatestDayMean and the baseline's live fold pass it, and the signals of the day read through canonicalSignalRows.

Test: tests/integration/today-reads-source-priority.test.ts (four of five cases fail on main, all pass here). Unit mocks of the derived metrics now stub the priority load.

Refs #1514

The metric page and the rollups keep each day of a ranked vital to the
source the user put first. Three readers did not: readDayAggregates,
behind readiness's latest-day value, the coincident-deviation flag and
the vitals baseline's live fold, averaged every source of the day; and
the briefing's signals of the day took the raw rows, so the newest row
of any source became today's value. With a ring worn at night and a
watch worn in the day both reporting resting heart rate for one date,
readiness used the mean of the two and moved whenever the lower-ranked
watch revised its estimate, and the briefing could quote the watch.

readDayAggregates takes the user's source-priority blob and, for a type
with a ladder, keeps each day to its first source in ladder order, the
order canonicalMeasurementsCte uses. readLatestDayMean and the baseline's
live fold pass it; the signals of the day read through
canonicalSignalRows, which applies pickCanonicalSourceRows per local day.

Refs #1514
The day readers loaded the source-priority blob once per type, so a
dashboard, digest or health-status request read the same row a dozen
times and went over its statement budget.
A run in the first two minutes after Berlin midnight put the real reading
on yesterday, and the deviation it asserts on was never there.
@MBombeck
MBombeck merged commit 012c0cc into main Nov 26, 2026
40 checks passed
@MBombeck
MBombeck deleted the fix/today-reads-source-priority branch December 1, 2026 09:13
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