Skip to content

fix: bound live realtimeRr, stop fabricating activity/steps for the historical record family - #21

Merged
abdulsaheel merged 1 commit into
mainfrom
fix/issues
Jul 30, 2026
Merged

fix: bound live realtimeRr, stop fabricating activity/steps for the historical record family#21
abdulsaheel merged 1 commit into
mainfrom
fix/issues

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • realtimeRr (live.dart) accepted any positive int16 as a beat, unlike parseRealtimeHr/parseR24 which both gate on the 200-2500ms physiological range (kMinRrMs/kMaxRrMs). A misaligned or corrupted 0x28 frame could hand an implausible RR value straight into live HRV/breathing-coherence compute (edge's _spotCheckCompute/_breathingCoherenceCompute). Now bounded the same way as the other two decoders.
  • decodeRecord's routing for the v7/v9/v12/v18/v24 historical family (added when those versions were routed through parseR24) hardcoded activity/steps_inc to 0 instead of null. That record family carries no IMU stepping window at all — the same "no usable IMU data" absence the R10 path already distinguishes from a genuine measured-zero reading via null. This was the identical fabrication bug for a different code path.

decode_parity_cases.json

Regenerating the second fix broke 629/2934 frozen parity cases — all exclusively on activity/steps_inc (verified with a throwaway audit script: diffed every case field-by-field, confirmed nothing else in those 629 cases changed, and confirmed the realtimeRr bound fix caused zero fixture divergence since no existing capture has an out-of-range RR value). Patched those 629 cases' expected activity/steps_inc to null. ts/ is archived and was intentionally left untouched.

Test plan

  • dart test — 115 passed (was 106; added a bound-check group for realtimeRr + a null-activity check for the routed historical family)
  • dart analyze — clean

Summary by CodeRabbit

  • Bug Fixes
    • Improved heart-rate interval processing by excluding physiologically invalid R-R intervals.
    • Corrected decoded records without stepping data so missing activity and step values remain unavailable instead of appearing as zero.
    • Ensured real-time heart-rate results return no value when all intervals are invalid.
  • Tests
    • Added regression coverage for invalid interval filtering and preservation of missing activity and step data.

…he historical family

realtimeRr (live.dart) accepted any positive int16 as an RR interval, unlike
parseRealtimeHr and parseR24 which both gate on the 200-2500ms physiological
range. A misaligned or corrupted 0x28 frame could hand an implausible beat
(e.g. 5ms) straight to live HRV/breathing-coherence compute. Now bounded the
same way.

decodeRecord's routing for the v7/v9/v12/v18/v24 historical family hardcoded
activity/steps_inc to 0 instead of null. That record family carries no IMU
stepping window at all, which is the same "no usable IMU data" absence the
R10 path already distinguishes from a measured zero-motion reading — this
was the identical fabrication bug, just left in the block added to route
those versions through parseR24. decode_parity_cases.json regenerated for
the 629 cases this touches (activity/steps_inc only, hand-verified nothing
else in those cases changed); ts/ is archived and was left alone.
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 645d17ee-5b4a-44d6-beb5-e55b6cc1bded

📥 Commits

Reviewing files that changed from the base of the PR and between 5bb8606 and 1e905b4.

📒 Files selected for processing (3)
  • decode_parity_cases.json
  • lib/src/live.dart
  • test/decode_guards_test.dart

📝 Walkthrough

Walkthrough

The decoder now filters realtime R-R intervals by physiological bounds and represents unavailable IMU stepping data as null for applicable historical records. Regression tests cover both behaviors.

Changes

Decoder guard corrections

Layer / File(s) Summary
Realtime R-R physiological bounds
lib/src/live.dart, test/decode_guards_test.dart
realtimeRr accepts only intervals within kMinRrMs..kMaxRrMs; tests cover discarded values, empty results, and parity with parseRealtimeHr.
Absent IMU stepping data
lib/src/live.dart, test/decode_guards_test.dart
Known historical record versions now decode missing IMU stepping fields as null rather than zero, with regression coverage.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the two main changes: bounding realtimeRr and preserving nulls for historical record activity/steps data.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@abdulsaheel
abdulsaheel merged commit 7edcb3e into main Jul 30, 2026
3 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.

1 participant