Skip to content

fix(ble): pair WHOOP4 clock correlation with its capture wall, not now - #1427

Merged
ryanbr merged 1 commit into
mainfrom
fix/whoop4-clock-correlation-stale-wall
Aug 18, 2026
Merged

ryanbr merged 1 commit into
mainfrom
fix/whoop4-clock-correlation-stale-wall

Conversation

@ryanbr

@ryanbr ryanbr commented Aug 18, 2026

Copy link
Copy Markdown
Owner

The bug (found tracing a v10.1.1-staging strap log)

The Android backfiller clock correlation is re-seeded on every offload from (strapNewestTs, now). WHOOP4 doesn't re-fetch GET_DATA_RANGE at each offload (only WHOOP5 does), so strapNewestTs stays frozen between fetches while now advances — inflating the offset by all the elapsed wall time since the last fetch. Straight from the log:

13:49:33  device=1787017727  offset 46s      ← true RTC skew, right after GET_DATA_RANGE
14:20:01  device=1787017727  offset 1874s    ← device frozen, offset grew with wall time
14:49:09  device=1787017727  offset 3622s
14:50:18  device=1787017727  offset 3691s     ← ~1h of pure staleness

The offset should be the strap's constant RTC skew (~46s), not a number that climbs with elapsed time.

The fix

Capture the wall clock at the same instant strapNewestTs is read from the GET_DATA_RANGE reply, and pair that with the device time when seeding the correlation — instead of a later now. The offset then reflects the true skew regardless of how stale strapNewestTs is. No extra BLE round-trip.

Scope (deliberately narrow)

Validation

Compiles clean (compileFullDebugKotlin). BLE path → hardware-confirmed by a strap log showing the offset holding at the true ~46s skew across an offload burst (per CLAUDE.md's BLE-validation rule; no CI/unit coverage for the CoreBluetooth path).

The Android backfiller clock correlation is re-seeded on every offload from
(strapNewestTs, now). WHOOP4 does not re-fetch GET_DATA_RANGE at each offload
(only WHOOP5 does), so strapNewestTs stays frozen between fetches while `now`
advances — inflating the offset by all the elapsed wall time since the last
fetch. A strap log shows it climbing 46s → ~3700s over ~30 min, snapping back to
~46s only when a fresh GET_DATA_RANGE lands.

Pair strapNewestTs with the wall clock captured at the SAME instant it was read
from the GET_DATA_RANGE reply, so the offset stays the strap RTC skew regardless
of how stale strapNewestTs is — no extra BLE round-trip.

Scope: the offset is a no-op for type-47 historical records (they carry their own
unix timestamp), so stored offload data is unaffected — this corrects the
REALTIME_RAW_DATA fallback stamping and, importantly, the strap-log diagnostics
that the inflated offset was making unreadable. Android-only: Swift reads the
real clock via GET_CLOCK and derives its strapNewestTs fallback ONCE (sticky), so
it does not have this per-offload re-seed inflation.

Validation: compiles clean; BLE-path, so hardware-confirmed by a strap log
showing the offset holding at the true ~46s skew (per CLAUDE.md BLE rule).
@ryanbr
ryanbr merged commit 9c33a6f into main Aug 18, 2026
3 checks passed
@ryanbr
ryanbr deleted the fix/whoop4-clock-correlation-stale-wall branch August 18, 2026 03:34
ryanbr added a commit that referenced this pull request Aug 18, 2026
Build numbers only. MARKETING_VERSION / versionName stay 10.1.1 — the staging
line is one above the latest release (v10.1.0) and holds there until 10.1.1
actually ships.

versionCode 341 -> 342 and CURRENT_PROJECT_VERSION 223 -> 224, both +1 past the
previous staging build so a sideloaded update installs in place rather than
being refused as a downgrade.

Picks up since the last testing build (f2271cd): backup build provenance
(#1422), the CTL/ATL/TSB training-load engine (#1423) and its Trends card
(#1425), sleep-vs-wake HR contrast (#1424), the v20 optical decoder + CRC gate
(#895), the Sleep UI split (#1426), the WHOOP4 clock-correlation fix (#1427),
the settings waist-row layout + copy fix (#1428), hourly Apple step import
(#1429), Low refresh (#1430), and Power saving moving into More with a 35%
ceiling (#1431).
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