Repository navigation
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Reviewer's GuideImplementationDecode and emit the gen4 GET_CLOCK sub-second word only when the epoch is plausible, the opcode is gen4, the payload is long enough, and the value is below 32768.
TestsCover a real gen4 reply, accepted and rejected sub-second boundaries, truncated or implausible replies, and gen5 compatibility.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="lib/src/control.dart" line_range="1025-1026" />
<code_context>
+ // half 0), and only with it do the clock-offset bounds the replies give
+ // ([sec + subsec/32768 - t_reply, ... - t_write]) agree within a day.
+ // Anything >= 32768 is not that count, so it is not emitted.
+ if (!profile.isGen5 && payload.length >= at + 8) {
+ final sub = u32(payload, at + 4);
+ if (sub < 32768) dec['clock_subsec'] = sub;
+ }
</code_context>
<issue_to_address>
**Gen5 reply gains a false fraction**
When a gen5 `Cmd.getClockGen5` reply is parsed with the default gen4 profile and its payload has at least two trailing bytes beyond the normal gen5 reply, `op` selects the gen5 layout at `payload[3]`, but `!profile.isGen5` treats the reply as gen4. With a gen5 reply parsed using the default gen4 profile and at least two trailing payload bytes, `u32(payload, at + 4)` combines the gen5 u16 fraction with those bytes and can emit a bogus `clock_subsec`.
Require `op == Cmd.getClock` as well as a gen4 profile before decoding the gen4 sub-second word.
</issue_to_address>Sourcery assessment
Approval pending. 1 finding to address first.
Blocking findings: lib/src/control.dart:1026
Code: emits
clock_subsec(gen4 only, when < 32768, only with a plausibleclock_epoch); test uses one real reply body(strap clock value only, no health data).
dart analyzeclean,dart testall passed.The gen4 GET_CLOCK (0x0B) reply body is
[u32 sec][u32 subsec](control.dart already notes this) but only the secondsare emitted. On our WHOOP 4.0 the subsec word is always < 32768 (17 replies; upper half 0) and is read as 1/32768 s, the same unit as
the record/event sub-second fields: with it, the bounds each reply puts on strap−laptop clock offset
([sec+subsec/32768 − t_reply, … − t_write]) intersect on each of the four days with more than one reply (9, 3, 2 and 2
replies). Whole seconds alone do not intersect on two of them, and milliseconds on none. These bounds alone would also
allow 1/65536 s; 1/32768 rests on all 17 values being below 32768 and on the record/event sub-second unit.
🤖 Generated with Claude Code
Summary by Sourcery
Expose validated gen4 clock sub-second precision while preserving existing epoch decoding and gen5 behavior.
New Features:
clock_subsecwhen the value is valid and the clock epoch is plausible.Enhancements:
Tests: