Skip to content

[P2] Recovery trace rounds negative half-ties differently on Swift and Kotlin #38

Closed

Description

@bhelm

Summary

The byte-aligned Recovery diagnostic trace uses different rounding rules for negative half-ties. A skin-temperature term of exactly -0.125 is rendered as -0.13 by Swift and -0.12 by Kotlin.

The Charge score itself is unchanged; this is a P2 parity bug in diagnostic output.

Minimal reproduction

Call recoveryTrace with a usable HRV baseline and:

skinTempDev = 0.125

The skin-temperature scale is 1.0, so the traced term is exactly -0.125.

Observed behavior

Platform Rendered value
Swift -0.13
Kotlin -0.12

Cause

Swift's default Double.rounded() handles this negative half-tie away from zero. Kotlin's Math.round handles it toward positive infinity.

Impact

Recovery traces are intended to be byte-aligned and fixture-testable across platforms. This creates false drift reports, although the Charge score itself is unchanged.

Acceptance criteria

  • Choose and document one common trace-rounding rule.
  • Emit identical strings for positive and negative half-ties, including ±0.125.
  • Preserve non-tie trace values and the returned Charge score.
  • Add an exact differential fixture for the complete trace.

This is fully reproducible with unit tests; no hardware testing is required.

Activity

  1. bhelm commented on Aug 19, 2026

    @bhelm
    OwnerAuthor

    Resolved and differentially verified.

    • The focused Swift/Kotlin production fix was merged in fix(recovery): align trace half-tie rounding #48.
    • The exact cross-platform regression case was added in test(parity): roll out Recovery trace #50.
    • Recovery trace results matched in all 20 trace cases; the full pilot matched in 277/277 cases.
    • The negative half-tie is asserted as an exact ordered trace string (z=-0.13) while the Recovery score remains unchanged.
    • Fresh llvm-cov/JaCoCo verification passed, and independent score/text mutants were detected on both platforms.

    The separate signed-zero and huge-finite formatting boundary remains tracked in #47.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions