Skip to content

cleanup(data): correct polling KDoc and position-range sentinel - #1332

Merged
9thLevelSoftware merged 1 commit into
mainfrom
cursor/polling-engine-kdoc-and-max-sentinel-e989
Oct 23, 2026
Merged

9thLevelSoftware merged 1 commit into
mainfrom
cursor/polling-engine-kdoc-and-max-sentinel-e989

Conversation

@9thLevelSoftware

Copy link
Copy Markdown
Owner

Summary

  • MetricPollingEngine's class KDoc now matches the loops in code. The monitor poll has no delay on success and is rate-limited by the BLE round trip (~10-20 ms, same as startMonitorPolling). The diagnostic poll is 2 Hz / 500 ms (BleConstants.Timing.DIAGNOSTIC_POLL_INTERVAL_MS). Heuristic (4 Hz / 250 ms) and heartbeat (0.5 Hz / 2000 ms) were already correct.
  • stopAll logs the workout position range through HandleStateDetector.hasObservedPositionRange(). That compares maxPositionSeen with UNSET_MAX_POSITION_MM (-Double.MAX_VALUE), the sentinel used to initialize and reset the field. Double.MIN_VALUE is the smallest positive double, so it never matched that sentinel.

Behavior

The check only decides whether stopAll emits the WORKOUT ANALYSIS info log. stopPolling and the connection manager call stopAll and do not read the result. Nothing in the UI or persistence reads minPositionSeen / maxPositionSeen; both are updated together from Float cable positions.

A finite sample moves both extremes off their sentinels, so a real workout still prints the range. A Float position cannot equal -Double.MAX_VALUE or Double.MIN_VALUE, so this does not change that log for trainer positions. The corrected guard skips the log when the maximum is still unset.

Test

HandleStateDetectorTest.position range stays unobserved until a sample leaves both sentinels covers the unset sentinels, an all-negative sample, and reset. :shared:testAndroidHostTest for HandleStateDetectorTest and MetricPollingEngineTest passed.

Open in Web Open in Cursor 

The polling-engine KDoc claimed a 1 Hz diagnostic loop and a 10-20 Hz
monitor loop. Diagnostic polling waits 500 ms, and the monitor loop has
no success delay (~10-20 ms). stopAll also treated Double.MIN_VALUE as
the unset maximum, which never matches the -Double.MAX_VALUE sentinel.

Co-authored-by: Devil <9thLevelSoftware@users.noreply.github.com>
@9thLevelSoftware
9thLevelSoftware marked this pull request as ready for review October 23, 2026 14:31
Copilot AI balanced review requested due to automatic review settings October 23, 2026 14:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@kilo-code-bot

kilo-code-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • shared/src/commonMain/kotlin/com/devil/phoenixproject/data/ble/HandleStateDetector.kt
  • shared/src/commonMain/kotlin/com/devil/phoenixproject/data/ble/MetricPollingEngine.kt
  • shared/src/commonTest/kotlin/com/devil/phoenixproject/data/ble/HandleStateDetectorTest.kt

Reviewed by minimax-m3 · Input: 61.9K · Output: 9K · Cached: 523.4K

Review guidance: REVIEW.md from base branch main

@9thLevelSoftware
9thLevelSoftware merged commit ae80cdc into main Oct 23, 2026
11 checks passed
@9thLevelSoftware
9thLevelSoftware deleted the cursor/polling-engine-kdoc-and-max-sentinel-e989 branch October 23, 2026 16:40
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.

3 participants