Skip to content

[P2] Raw recovery overload can score without the required HRV baseline #40

Open

Description

@bhelm

Summary

The public recovery overload that accepts optional driver baselines documents the HRV baseline as required. However, hrvBaseline may be absent while the separate hrvBaselineUsable flag defaults to true.

Another optional term can therefore produce a Charge score without any HRV term.

Minimal reproduction

hrv = 50
rhr = 60
resp = nil
hrvBaseline = nil
rhrBaseline = nil
respBaseline = nil
sleepPerf = 0.85
hrvBaselineUsable = default (true)

Observed behavior

Both Swift and Kotlin return approximately 57.932425214874954. Under the documented contract the result should be nil/null.

Cause

The cold-start guard checks only hrvBaselineUsable; it does not require hrvBaseline. The missing HRV term is skipped and sleepPerf becomes the only weighted term.

Impact

A public caller can produce a plausible Charge score without the model's dominant required driver. Known production paths use the stricter baseline-state overload, so this is P2 rather than P1.

Acceptance criteria

  • Return nil/null whenever the required HRV baseline is absent, or make absence unrepresentable.
  • Preserve cold-start behavior for present but unusable baselines.
  • Preserve scores for valid usable baselines.
  • Add paired tests with each optional driver present while HRV baseline is absent.

This is pure analytics behavior; no hardware testing is required.

Activity

  1. bhelm commented on Sep 7, 2026

    @bhelm
    OwnerAuthor

    PR opened upstream: ryanbr#1978 — the raw RecoveryScorer.recovery(…) overload now returns
    nil/null when the HRV baseline is absent instead of scoring from the remaining optional
    drivers, mirrored in Swift and Kotlin with paired tests.

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