Skip to content

fix(ble): reject incomplete standard heart-rate fields - #2747

Open
UtkuDenizAltiok wants to merge 1 commit into
ryanbr:mainfrom
UtkuDenizAltiok:codex/standard-hr-integrity
Open

UtkuDenizAltiok wants to merge 1 commit into
ryanbr:mainfrom
UtkuDenizAltiok:codex/standard-hr-integrity

Conversation

@UtkuDenizAltiok

@UtkuDenizAltiok UtkuDenizAltiok commented Oct 9, 2026 •

Copy link
Copy Markdown

What this PR does

A truncated Heart Rate Measurement could still publish a plausible heart rate. For example, [08,48] declares a two-byte energy field but contains none; [10,48,00,04,ff] ends with half an R-R word. Reject incomplete declared fields before live-state or collection effects on Apple and Android.

A paired pure protocol predicate gates all three decoders. Existing field decoders, WHOOP 5 raw-millisecond handling, complete-field HR/R-R/contact results, reserved flags, empty R-R compatibility and undeclared trailers remain unchanged. No radio commands, sampling, schema or physiological formulas change.

Type of change

  • Bug fix

How it was tested

  • Directly compiled original/fixed Swift on 1,771,584 inputs: all 1,478,185 complete-field outputs identical; 254,325 previously accepted malformed inputs refused. Original-Swift controls and independent layout masks are pinned on both platforms, covering all 256 flags at lengths 0–64.
  • Original Swift fails two new methods (80 assertions); fixed probe passes. Broken predicate fails 4,240 assertions. Three caller-gate bypasses fail their wiring tests; source restored exactly.
  • Android regression run 37920499670: APK built; 12 tests with exactly the three new methods failing assertions, nine controls passing. Exact restored source passed APK/full JVM task in 37921713840.
  • WhoopProtocol: 817 tests, one existing skip. Full local Apple verification passed: 632/2143/327 package tests, 127 governance, 2282 macOS tests, iOS build and source/i18n/parity gates; one import/two macOS existing skips. No failures or new warning in changed code. Isolated simulator launch/render passed.
  • Core Tools: 156 pass with canonical per-process temporary path. Four unchanged macOS temporary-path alias assertions fail on main and candidate with the default path; both logs retained, no source/assertion changes.
  • No real WHOOP 4.0/5.0/MG observation yet. Verified testing build f519e57b is delivered; normal phone acceptance remains pending. Malformed-packet frequency and physiological accuracy are unmeasured.

Checklist

  • Swift package tests pass for the touched package
  • Android debug APK and full JVM test task pass
  • No new warnings in changed code
  • No UI changes or new device commands
  • Follows docs/CONTRIBUTING.md's BLE safety contract
  • No generated project output, secrets or keystores committed

Evidence

Contract and source comparisons. Source head: d84f5a1.

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