Skip to content

fix(power): enforce saving cadence for automatic sync triggers - #2837

Draft
fadkeprasad wants to merge 1 commit into
ryanbr:mainfrom
fadkeprasad:fix/power-saving-event-sync-floor
Draft

fadkeprasad wants to merge 1 commit into
ryanbr:mainfrom
fadkeprasad:fix/power-saving-event-sync-floor

Conversation

@fadkeprasad

Copy link
Copy Markdown

What this PR does

Power saving stretches the periodic history timer to 45 minutes, or 60 minutes with Low refresh, but Apple's live strap events still reach requestSync(.strap) through a 90-second floor. Repeated events can bypass the selected saving cadence.

Pass the active saving interval into BackfillPolicy.shouldRun on both platforms. Periodic and strap-event attempts use the greater of that interval and their existing empty-history backoff. Synthetic events every 90 seconds over two hours now permit starts at 3600 and 7200 seconds with Low refresh, rather than all 80 attempts.

  • With saving inactive, the existing event floor remains unchanged.
  • Low-battery saving still requires the strap to be at/below its threshold and not reported charging. Low refresh applies at any charge.
  • Manual sync, reconnect/foreground recovery, the first sync and bounded backlog continuations retain their policies.
  • No new BLE command, payload, polling, stream change or storage change.
  • Android has no current production STRAP caller; its policy twin stays aligned. Both platforms also protect against a previously armed periodic timer firing before a newly active saving interval.

Refs #1430.

Type of change

  • Bug fix

How it was tested

  • macOS app build and 34 focused StrandTests pass: BackfillPolicyTests, LowRefreshCadenceTests and Whoop5BatteryBackfillThrottleTests.
  • NOOPiOS generic-device build passes, including embedded watch targets. Signing disabled.
  • Android production/test Kotlin compile and 34 focused JVM tests pass: BackfillPolicyTest, LowRefreshCadenceTest and ConnectionPriorityTest. Initial run used --no-build-cache --rerun-tasks.
  • Compiled production Swift oracle covers 5,760 decisions across triggers, time boundaries, first sync, empty streaks, clock trust and saving floors. Both platform tests pin the same SHA-256. A negative control restoring the old gate changes that digest and reproduces the bypass.
  • Doc-comment lint, diff-scoped i18n audit, parity ratchet against upstream main and git diff --check pass.
  • No package sources changed; package suites and the full app/Android suites were not run.

Hardware validation

Draft pending a charged WHOOP 5.0 run. Existing local strap logs show frequent event-triggered history attempts, but predate the saving-setting change and do not prove an energy benefit. This patch has not been installed on a phone or validated on a physical strap. No battery-life improvement or sole cause of an individual discharge is claimed. Raw health data and private logs are not included.

Checklist

  • Swift/Kotlin policy parity checked with a compiled oracle
  • Focused Android and Apple tests passed
  • Apple app targets compiled
  • No UI or protocol literals changed
  • No generated output, secrets or private captures committed

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