fix(colmi): preserve quarter-hour offset in activity buckets (up to ~75% step undercount)#87
Merged
saksham2001 merged 2 commits intoJul 15, 2026
Conversation
The activity-history decoder built each bucket's timestamp as `hour = v[4]/4, minute = 0`, discarding the within-hour quarter (`v[4] % 4`). Daily step/distance totals are the sum of buckets keyed by their start epoch, so all four quarter-hour buckets of an hour collapsed onto HH:00 and overwrote each other — undercounting a normally-worn Colmi/R02 ring's steps and distance by up to ~75%. Set `minute = (v[4] % 4) * 15` so each quarter keeps a distinct epoch. Existing tests passed only because their captured buckets happened to use quarter indices that were exact multiples of 4 (one per hour); add a regression test with two same-hour quarters.
saksham2001
approved these changes
Jul 15, 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.
Bug
ColmiDecoder.decodeActivityHistorybuilt each activity bucket's timestamp ashour = v[4] / 4, minute = 0, dropping the within-hour quarter (v[4] % 4).Daily step/distance totals are computed as the sum of buckets keyed by their start epoch (
ActivityService.applyActivityBucketupserts bystartEpoch). So all four quarter-hour buckets of a given hour collapsed ontoHH:00:00and overwrote each other — only the last-written quarter survived. A normally-worn Colmi/R02 ring that's active in more than one quarter of an hour has its steps and distance undercounted by up to ~75%.Fix
Set
minute = (v[4] % 4) * 15so each quarter-hour bucket keeps a distinct timestamp/epoch. (v[4]is the quarter-of-day index 0…95 →hour = q/4,minute = (q%4)*15.)Why tests didn't catch it
The existing
ColmiDecoderTestshad no coverage for the activity-history bucket path, and the captured fixtures elsewhere used quarter indices that were exact multiples of 4 (one bucket per hour), so no collision occurred. AddedtestActivityHistoryPreservesQuarterHourOffset— two same-hour quarters (6 → 01:30, 7 → 01:45) must decode to distinct timestamps. FullColmiDecoderTestssuite green.Found via a code audit; connected-ring, all Colmi/R02-family users.