Skip to content

Accuracy check: compare only the time both devices were on - #44

Merged
gabrielbr merged 1 commit into
mainfrom
ccr-67ccb970-dqwwqd
Oct 23, 2026
Merged

gabrielbr merged 1 commit into
mainfrom
ccr-67ccb970-dqwwqd

Conversation

@gabrielbr

Copy link
Copy Markdown
Owner

Problem. A device that ran flat or was put on the charger partway through a day still passed the 500-step "worn" test. The other device then read as over-counting by everything after that point. For example, if the ring dies at 15:00, the reference shows 9,000 steps against the ring's 4,000, and the check reports "ring counts 55% fewer".

The same happened to sleep: a watch going flat at 03:00 made the ring look like it over-reports sleep. These days also fed into the consistent-bias verdict, so they could produce a false correction.

Fix

  • Detecting when a device was off. AccuracyComparison.offGaps finds each device's off stretches: more than 90 min with no heart rate, steps, sleep or SpO₂ from it.
    • A device is judged only if it logs heart rate at least every 75 min (judgeable).
    • Otherwise quiet and off look alike, so the device is taken as worn throughout, which is the previous behaviour.
  • Daily totals.
    • A day with any off stretch compares steps and distance only over the time both devices covered (amountWithin). The reference's records and the ring's 15-minute buckets are both cut to those shared hours.
    • Active calories can't be cut, because the ring keeps one daily figure, so they are dropped for that day.
    • A day with fewer than 12 shared hours doesn't count at all.
  • Nights. If either device was off for 15 min or more inside the span both nights cover, the night is dropped for sleep, resting HR and HRV.
  • HR and SpO₂. Unchanged. They pair readings taken minutes apart, so off time already produced no pairs.
  • Report notes.
    • New notes partly:, night_off: and shared: say which device was off and from when, and translate to pt-BR.
    • A counted partial day shows the hours it was compared over.
  • Tests. Unit tests cover gap detection, cadence judging, cutting totals to the shared hours, and merging overlapping gaps.
  • Docs. The plan doc's "As built" section and AGENTS.md are updated.

Generated by Claude Code

A flat battery or a charge mid-day passed the 500-step worn test, so the other device read as
over-counting by everything after. Each device's off stretches now come from gaps in its own
data; partly worn days are compared over the shared hours (or dropped under 12), and nights
either device stopped inside are dropped for sleep, resting HR and HRV.

Claude-Session: https://claude.ai/code/session_01P1t1aUqSUPd3whKXmgVm7w
@gabrielbr
gabrielbr merged commit 0d0756d into main Oct 23, 2026
2 checks passed
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.

2 participants