Skip to content

[P2] Recovery HR windows document an inclusive end but drop aligned endpoint samples #39

Closed

Description

@bhelm

Summary

restingHR documents and initially filters [start, end], but both it and recoveryIndexSlope use half-open five-minute bins and stop before a bin beginning at end. A sample exactly at an aligned end passes the prefilter and then belongs to no bin.

This is shared Swift/Kotlin behavior, not platform drift.

Minimal reproduction

Resting HR:

start = 0
end = 300
five samples at ts=300, bpm=60

Recovery Index:

start = 0
end = 1800
samples at ts=0,300,600,900,1200,1800

Observed behavior

On both platforms:

  • restingHR returns nil/null; none of the admitted endpoint samples reaches a bin.
  • recoveryIndexSlope returns nil/null; only five bins remain, below the six-bin gate.

Cause

The inclusive prefilter is combined with bins shaped as [t, t+300) and a loop that runs only while t < end.

Impact

An endpoint sample is silently admitted and then ignored. For Recovery Index this can change whether the minimum-bin gate is satisfied.

Acceptance criteria

  • Define either [start, end) everywhere or handle an inclusive final boundary.
  • Make documentation, prefiltering and bin membership consistent.
  • Add paired aligned/non-aligned endpoint tests, including the five/six-bin gate.
  • Preserve identical Swift/Kotlin behavior.

Synthetic timestamp fixtures are sufficient; no hardware testing is required.

Activity

  1. bhelm commented on Sep 7, 2026

    @bhelm
    OwnerAuthor

    Fixed upstream by ryanbr#1927 and ryanbr#1936 (both merged): 1927 closed the final
    resting-HR bin on the window end in the library helpers, and 1936 did the same on the shipped
    SleepStager path (sessionRestingHR / sessionHrvWindows) and deleted the two unused
    RecoveryScorer helpers. A sample landing exactly on the window end is no longer dropped.
    Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions