Skip to content

fix(recovery): preserve signed zero in forecast clamp - #1442

Merged
ryanbr merged 1 commit into
ryanbr:mainfrom
bhelm:fix/recovery-forecast-signed-zero
Aug 19, 2026
Merged

ryanbr merged 1 commit into
ryanbr:mainfrom
bhelm:fix/recovery-forecast-signed-zero

Conversation

@bhelm

@bhelm bhelm commented Aug 19, 2026

Copy link
Copy Markdown

What this PR does

Defines and implements one exact cross-platform contract for RecoveryForecaster.clamp: for finite ordered bounds, a value numerically equal to an inclusive bound is already in range, so clamp returns x itself and preserves its IEEE-754 signed-zero bit. This removes the Swift/Kotlin drift reported in bhelm#56 with the minimal mirrored production change.

Mirrored tests cover all four x = ±0.0 lower/upper boundary shapes and adjacent below/interior/above ordinary values.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation
  • CI / tooling

How it was tested

  • Red first on the fork baseline: the new focused Swift and Kotlin tests both failed against the original implementations on the signed-zero bit assertions.
  • Clean branch created from current origin/main (d347cbf668ee619dcd0850ed94bacdec461b87b9).
  • Focused Swift test passed on this upstream branch: 1 test, 0 failures.
  • Focused Android test passed on this upstream branch under JDK 17 with one worker, no parallel execution, in-process Kotlin compilation, and -Xmx1536m.
  • The equivalent fork branch passed the full StrandAnalytics suite (1,436 tests, 2 skipped, 0 failures) and full Android :app:testFullDebugUnitTest.
  • Independent delta review found no P0/P1/P2 issues in the documented finite lo <= hi domain, and verified the fork/upstream patch IDs are identical.

Checklist

  • Swift package tests pass for any package I touched (swift test in Packages/<name>) — focused test passed here; full suite passed on the equivalent fork patch and CI will run this branch
  • Android unit tests pass if I touched android/ (./gradlew testFullDebugUnitTest) — focused test passed here; full suite passed on the equivalent fork patch and CI will run this branch
  • No new build warnings introduced
  • UI changes use only StrandDesign tokens — no hardcoded colors, fonts, or spacing
  • No hardcoded hex frame bytes; protocol facts live in the schema / decoders
  • Follows the conventions in docs/CONTRIBUTING.md
  • I did not commit generated output (Strand.xcodeproj/) or any secrets/keystores

Related issues

Addresses bhelm#56

@ryanbr
ryanbr merged commit 9e51ec7 into ryanbr:main Aug 19, 2026
14 checks passed
@bhelm
bhelm deleted the fix/recovery-forecast-signed-zero branch September 15, 2026 22:35
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.

2 participants