Skip to content

drift/05: rollingRmssd aligned — (t−w,t], per-window cleaning, no rematching - #25

Merged
bhelm merged 1 commit into
drift/metafrom
drift/05-rmssd-alignment
Aug 18, 2026
Merged

bhelm merged 1 commit into
drift/metafrom
drift/05-rmssd-alignment

Conversation

@bhelm

@bhelm bhelm commented Aug 18, 2026

Copy link
Copy Markdown
Owner

Plan step 5 of #17: the three rollingRmssd divergences the differential pilot (#24) reported as machine diffs, aligned to one convention each. Deliberate behavior change on both platforms.

The conventions

Divergence Decision Who changes
Window boundary [t−w,t] vs (t−w,t] (t−w,t] (the plan's proposal) Swift (> → >= at the left edge)
Cleaning scope: per-window vs global per window — artifact rejection belongs to the window's own local statistics; global cleaning couples distant data Kotlin (global pre-cleaning removed)
Kotlin's value-based timestamp rematching removed entirely — cleaning the window's raw samples directly makes it structurally unnecessary; it was the source of the spurious extra point Kotlin

Proof through the harness (red → green → red-on-revert)

  • Before: SUMMARY cases=14 diffs=3 (measured independently by builder and by the integrating process).
  • After: SUMMARY cases=14 diffs=0 — verified end-to-end with the real Gradle Kotlin runner.
  • Revert probe: undoing only the Swift boundary fix → diffs=1 (exactly rmssd_window_boundary); re-applying → 0.

Behavior change

Rolling-RMSSD timeline values can shift slightly; points near the window edge or the min-beats bar can appear or disappear. In the pilot, Swift lost two 10 ms points at the window boundary; Android lost spurious extra points (117.48 ms, 141.42 ms — the rematching artifact). The nightly, non-rolling HRV computation is untouched.

No existing test pinned the old special-case values (verified deliberately — no test numbers were "dragged along" to match the new behavior). Full suites: Swift 1429 / 2 skipped / 0 failures; Android 3977 / 0 failed / 6 skipped.

Review

Codex review (read-only, independent): green, zero findings — line-by-line value-equality of the two rewritten implementations confirmed (window inclusion, tie-breaks, thinning stride, min-beats counting, rounding, emission order), edge samples at both window edges behave identically, no orphaned helpers left in Kotlin, production callsites degrade cleanly, doc comments mirror-equal.

Part of the drift-control plan in #17. Fixes the #9 class.

🤖 Generated with Claude Code

…ing (#17)

The differential pilot (#24) reported three real divergences in
rollingRmssd; this aligns them to one convention per divergence:

- window boundary: (t - windowSec, ts] on both sides — Swift's left
  edge moves from > to >= (adopting the Kotlin semantics);
- artifact cleaning: locally per window on both sides — Kotlin's
  global pre-cleaning of the whole series is removed (adopting the
  Swift semantics: artifact rejection belongs to the window's own
  local statistics);
- Kotlin's value-based timestamp rematching is removed entirely —
  cleaning the window's raw samples directly makes it structurally
  unnecessary (it was the source of the extra emitted point).

BEHAVIOR CHANGE, both platforms: rolling-RMSSD timeline values can
shift slightly; points near the window edge or the min-beats bar can
appear or disappear. In the pilot, Swift lost two 10 ms points at the
window boundary; Android lost spurious extra points (117.48 ms,
141.42 ms). The nightly, non-rolling HRV computation is untouched.

Proven through the harness: pilot 14 cases / 3 diffs before, 0 after;
reverting the Swift boundary fix alone makes it red again (1 diff),
re-applying returns it to green. No existing test pinned the old
special-case values, so no test numbers were adjusted. Full suites:
Swift 1429 / 2 skipped / 0 failures; Android 3977 / 0 / 6.

Part of the drift-control plan in #17 (step 5). Fixes the #9 class.

Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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