Skip to content

Persist the WHOOP 5/MG raw-IMU offload buffer (#423) - #675

Merged
ryanbr merged 4 commits into
mainfrom
feat/raw-imu-offload-capture-423
Jul 20, 2026
Merged

Persist the WHOOP 5/MG raw-IMU offload buffer (#423)#675
ryanbr merged 4 commits into
mainfrom
feat/raw-imu-offload-capture-423

Conversation

@ryanbr

@ryanbr ryanbr commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Refs #423. Draft — minimal, receive-side, no arming.

The finding that reframes #423

#423 is scoped around the live raw-accel stream (arm cmd 81, which the 5/MG allowlist drops; the full IMU stream is firmware-refused). But Whoop5RawImu's own header — validated on 1423 real 5.0 buffers — establishes that the connect-time offload burst already carries a full 100 Hz 6-axis IMU (accel + gyro, 1244-B buffer). NOOP already receives and decodes it (PuffinDeepBufferLog runs Whoop5RawImu.decode), and just logs a summary — no arming needed, nothing persisted. This PR adds the missing persistence, which delivers #423's core goal (6-axis IMU on a 5.0) without touching the BLE-send path at all.

What this does

  • rawImuSample table — one row per strap-second, a packed i16 LE BLOB of the six wire columns (ax…az,gx…gz). Room MIGRATION_20_21 + GRDB v28-raw-imu, byte-identical shape + encoding so a .noopbak round-trips. Whoop5RawImu.rawColumns() keeps the offsets in one place on both platforms.
  • Gated + receive-side — persists at the same deep-buffer seam that already decodes, behind the existing raw-capture toggle (noopPuffinCapture), dispatched off the BLE thread. No BLE command is sent anywhere in this diff.
  • Bounded — rolling retention to the newest ~1 h (3600 rows ≈ 4 MB), so an enabled capture can't balloon the DB during a multi-day offload replay.
  • Instrument-first — decode → store → nothing consumes it yet (no steps/sleep gating), per the derived-signal rule.

What's deliberately out of scope (stays #423's strap-side work)

  • Arming (cmd 81 / un-silencing the 4.0 flood) — the hard-rules BLE write that needs your real 5/MG to validate. This PR makes NOOP capture the offload IMU it already receives; it does not turn any stream on.
  • WHOOP 4.0 type-43 live raw — Swift means it, Android doesn't decode it; a separate change (needs un-silencing).

Verification

Note for #423

Since the offload path already delivers 6-axis IMU arming-free, the live-stream probe may be unnecessary for the core goal — worth folding into the issue.

ryanbr added 4 commits July 20, 2026 18:11
NOOP already decodes the strap's connect-time 1244-B deep buffer — a full
100 Hz 6-axis IMU second (Whoop5RawImu, validated on 1423 real 5.0 buffers)
— but only logs a summary to JSONL; no queryable samples survive. This adds
the missing persistence.

Key point for #423: this needs NO arming. The live raw stream (cmd 81, the
allowlist gap) is firmware-refused for full IMU, but the OFFLOAD buffer
already carries accel AND gyro and NOOP already receives + decodes it — so
the whole gated-probe saga is sidesteppable for the core goal.

- New rawImuSample table (packed i16 LE BLOB of the 6 wire columns, PK
  deviceId,ts): Room MIGRATION_20_21 + GRDB v28-raw-imu, byte-identical
  shape/encoding so a .noopbak round-trips. Whoop5RawImu.rawColumns() keeps
  the offsets in one place (both platforms).
- Gated on the existing raw-capture toggle (noopPuffinCapture); persists at
  the same deep-buffer seam that already decodes, IO/Task-dispatched off the
  BLE thread. Receive-side only — NO BLE command is sent anywhere.
- Bounded: rolling retention to the newest ~1 h (3600 rows ≈ 4 MB) so an
  enabled capture can't balloon the DB during a multi-day offload replay.
- Instrument-first: decode -> store -> nothing consumes it yet (no steps/
  sleep gating), per the derived-signal rule.

Verified: Android compileFullDebugKotlin + RawImuMigrationTest (SQL pin,
version pair, i16 pack round-trip, rawColumns extraction, insert+prune) +
the data test package. iOS is app-target Swift (Linux can't build) — the
data layer mirrors ppgWaveformSample exactly; compiles on the app-build run.

Refs #423.

Author: ryanbr <mp3geek@gmail.com>
app-build caught it: StreamStore.packImuColumns is module-internal (like
packPpgSamples), so the Collector in the Strand module couldn't call it.
Pass the raw [Int16] columns to insertRawImu and pack inside WhoopStore —
mirrors how insert() packs ppgWaveform. No stored-bytes change.

Author: ryanbr <mp3geek@gmail.com>
On-device validation aid: confirm the offload IMU is arriving + decoding
(and flag a store failure) from the accessible strap log, without pulling
the puffin-deepbuffers.jsonl. Throttled (first buffer, then every 500) so a
large offload can't flood the log; gated behind raw capture like the rest.
Android only — iOS already logs every decoded IMU buffer to that JSONL.

Author: ryanbr <mp3geek@gmail.com>
CI (WhoopStore swift test) caught it: rawImuSample is deviceId-keyed but was
missing from the device-scoped delete set, so "delete all of this device's
data" / device removal would leave the raw IMU behind — the exact
delete-means-gone privacy defect that guard exists to prevent.

- Swift: add rawImuSample to DeviceRegistryStore.deviceScopedTables.
- Android: add DeviceRegistryDao.deleteRawImuFor + wire it into
  DeviceRegistry.deleteDeviceData; update the three FakeDao test doubles and
  the pinned expected-tables set.

Verified: Android compileFullDebugKotlin + DeviceRegistryTest + RawImuMigrationTest
+ the data package. Swift fix re-runs on Swift Packages CI.

Author: ryanbr <mp3geek@gmail.com>
@ryanbr
ryanbr merged commit e56f45c into main Jul 20, 2026
9 checks passed
@ryanbr
ryanbr deleted the feat/raw-imu-offload-capture-423 branch July 20, 2026 15:22
ryanbr added a commit that referenced this pull request Jul 20, 2026
Marketing version stays 9.0.3; Android versionCode 296->297 and iOS
CURRENT_PROJECT_VERSION 206->207 so the new staging build installs over the
previous one. Content since the last testing build: Health Connect writeback
failure surfacing (#672), SpO2/respiration empty-track explanation (#673),
WHOOP 5/MG raw-IMU offload persist (#675), hide stale sleep recompute entries
(#679), Oura activity MET research corpus + cap/rotation (#676/#680), trend
chart date alignment (#528), and corrupt-DB quarantine preservation (#681).
DX23876 pushed a commit to DX23876/noop that referenced this pull request Jul 22, 2026
Capture the 100 Hz 6-axis IMU the 5/MG already offloads (Whoop5RawImu) into a new gated, bounded rawImuSample table (Room MIGRATION_20_21 + GRDB v28), receive-side only — no arming. Default-off (noopPuffinCapture), rolling ~1h retention, wired into device-data deletion, with a throttled strap-log heartbeat. Instrument-first; nothing consumes it yet. Refs ryanbr#423.
DX23876 pushed a commit to DX23876/noop that referenced this pull request Jul 22, 2026
Marketing version stays 9.0.3; Android versionCode 296->297 and iOS
CURRENT_PROJECT_VERSION 206->207 so the new staging build installs over the
previous one. Content since the last testing build: Health Connect writeback
failure surfacing (ryanbr#672), SpO2/respiration empty-track explanation (ryanbr#673),
WHOOP 5/MG raw-IMU offload persist (ryanbr#675), hide stale sleep recompute entries
(ryanbr#679), Oura activity MET research corpus + cap/rotation (ryanbr#676/ryanbr#680), trend
chart date alignment (ryanbr#528), and corrupt-DB quarantine preservation (ryanbr#681).
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