fix: alcoholNightFlag missing whole-bpm quantum guard on RHR - #66
Conversation
same gap illness_cusum just got patched for. a quantized-but-nonzero RHR baseline (alternating 54/55/56, sd ~0.76) let a small +3bpm night fabricate an extreme z and clear mdc trivially. add the same dispersionBelowQuantum(rhrHistory, 1.0) guard, abstain the RHR axis when it fires. rmssd untouched, it's not quantized this way. widened the shared test fixture (was itself sub-quantum) so the heavy/moderate/light tests keep testing real signal, and added a regression test for the abstain case.
|
Warning Review limit reachedNext included review available in 36 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (2)
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. Comment |
There was a problem hiding this comment.
Sorry @abdulsaheel, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 6 days and 18 hours by commenting @sourcery-ai review. Upgrade to get a review now.
Reviewer's GuidePrevents whole-bpm RHR quantization noise from creating extreme z-scores and false alcohol-night classifications by mirroring the existing dispersion-below-quantum guard, with targeted fixture updates and an abstention regression test. Sequence diagram for guarded alcohol-night RHR evaluationsequenceDiagram
participant Caller
participant alcoholNightFlag
participant Baseline as robustBaseline
participant Quantum as dispersionBelowQuantum
participant MDC as mdc
Caller->>alcoholNightFlag: alcoholNightFlag(...)
alcoholNightFlag->>Baseline: robustBaseline(rhrHistory)
alcoholNightFlag->>Quantum: dispersionBelowQuantum(rhrHistory, _rhrQuantum)
alt RHR dispersion below 1 bpm
alcoholNightFlag->>alcoholNightFlag: rhrZ = null
alcoholNightFlag->>alcoholNightFlag: rhrMdc = null
alcoholNightFlag->>alcoholNightFlag: rhrUp = false
else RHR dispersion is resolvable
alcoholNightFlag->>Baseline: modZ(tonight.rhr)
alcoholNightFlag->>MDC: mdc(rhrBase)
end
alcoholNightFlag-->>Caller: Metric<EventState> with abstention note when guarded
Flow diagram for whole-bpm RHR abstentionflowchart TD
A["Nightly RHR and history"] --> B["dispersionBelowQuantum(rhrHistory, _rhrQuantum)"]
B -->|"below 1 bpm"| C["rhrZ = null; rhrMdc = null"]
B -->|"resolvable dispersion"| D["rhrBase.modZ(tonight.rhr); mdc(rhrBase)"]
C --> E["rhrUp remains false; RHR axis abstained"]
D --> F["RHR signal can contribute to alcoholNightFlag"]
E --> G["RMSSD continues independently"]
F --> H["EventState and explanatory note"]
G --> H
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
same gap illness_cusum just got fixed for (8368d5e). alcoholNightFlag standardizes tonight's rhr against
robustBaseline(rhrHistory)via modZ/mdc with no dispersionBelowQuantum check. a whole-bpm baseline like alternating 54/55/56 has sd ~0.76, under the 1bpm quantum but nonzero, so it passes the mad!=0 check and a normal +3bpm night blows up into an extreme z, clears mdc, and can push the alcohol band into moderate/heavy off rounding noise.fix mirrors illness_cusum almost exactly:
dispersionBelowQuantum(rhrHistory, 1.0)guard, null out rhrZ/rhrMdc when it fires (rhrUp stays false, everything downstream is already null-safe), note gets a short suffix saying why. rmssd untouched, not quantized this way.also widened the shared alcohol-night test fixture (it was itself sub-quantum, would've broken the heavy/moderate/light tests once the guard landed) and added a regression test for the abstain case.
not wired into the app (file's own header says so), zero blast radius.
Summary by Sourcery
Guard alcohol-night RHR standardization against sub-quantum baseline dispersion while continuing to evaluate RMSSD normally.
Bug Fixes:
Enhancements:
Tests: