Skip to content

test(sleep): pin the #277 tuned deep-boundary values directly (the #310 golden didn't lock them) - #311

Merged
ryanbr merged 1 commit into
mainfrom
sleepv2-pin-constants-directly
Jul 12, 2026
Merged

ryanbr merged 1 commit into
mainfrom
sleepv2-pin-constants-directly

Conversation

@ryanbr

@ryanbr ryanbr commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Re-review follow-up to #310.

The finding

#310's frozen golden does not guard the #277 tuned constants. Reverting deepGateThresh 0.25→0.20, the deep emission weights, OR the deep transition row all still reproduce the exact golden hypnogram — only a gross change (e.g. forcing deep out) fails it. The crafted night's phases are stark enough that the fine tune moves no boundary; a golden only discriminates where the input sits near a decision boundary. So the golden's real value is locking the recipe's end-to-end shape + full-path Swift/Kotlin parity, not the exact values.

The fix

A direct, input-independent guard on both platforms (tunedDeepBoundaryConstantsArePinned / testTunedDeepBoundaryConstantsArePinned):

  • asserts deepGateThresh == 0.25 and the exact deep transition row,
  • a row-sum == 1.0 invariant over the whole matrix (catches a renormalisation typo in the hand-edited row),
  • widens the two Kotlin constants private→internal to match Swift's already-internal statics (byte-parity-neutral).

Verified sensitive: reverting deepGateThresh (→1 failure) or breaking the transition row now fails the direct test — the guarantee the golden couldn't give. The golden's doc comment is corrected to state what it actually locks, and its Kotlin name changed to frozenGoldenHypnogramPinsTheRecipeShapeAndParity.

The inline deep emission weights aren't named constants, so they remain guarded only at the gross level by the golden (noted in-test) — pinning them would mean extracting them to constants, a separate hot-path change.

Verification

  • Kotlin: testFullDebugUnitTest green; sensitivity confirmed by reverting each constant.
  • Swift: SleepStagerV2Tests runs in swift-packages CI (StrandAnalytics needs macOS).

…lden alone didn't lock them)

Re-review of #310 found its frozen golden does NOT actually guard the #277 tuned
constants: reverting deepGateThresh 0.25->0.20, the deep emission weights, OR the
deep transition row all still reproduce the exact golden hypnogram (only a gross
change, e.g. forcing deep out, fails it). The crafted night's phases are stark
enough that the fine tune moves no boundary — a golden only discriminates where the
input sits near a decision boundary. So the golden's real value is locking the
recipe's end-to-end SHAPE + full-path Swift/Kotlin parity, not the exact values.

Adds a direct, input-independent guard on both platforms
(tunedDeepBoundaryConstantsArePinned / testTunedDeepBoundaryConstantsArePinned):
asserts deepGateThresh == 0.25 and the exact deep transition row, plus a row-sum==1.0
invariant over the whole matrix (catches a renormalisation typo in the hand-edited
row). Widens the two Kotlin constants private->internal to match Swift's already-
internal statics (byte-parity-neutral). Verified sensitive: reverting deepGateThresh
or breaking the transition row now fails the direct test. The golden's doc comment is
corrected to say what it locks (shape + parity + gross regressions), and its Kotlin
name changed to frozenGoldenHypnogramPinsTheRecipeShapeAndParity.

The inline deep emission weights aren't named constants, so they remain guarded only
at the gross level by the golden (noted in-test).

Kotlin: testFullDebugUnitTest green. Swift: swift-packages CI (StrandAnalytics needs macOS).
@ryanbr
ryanbr merged commit 2e379db into main Jul 12, 2026
8 checks passed
@ryanbr
ryanbr deleted the sleepv2-pin-constants-directly branch July 12, 2026 05:50
DX23876 pushed a commit to DX23876/noop that referenced this pull request Jul 22, 2026
…the golden alone didn't lock them) (ryanbr#311)

Re-review of ryanbr#310 found its frozen golden does NOT actually guard the ryanbr#277 tuned
constants: reverting deepGateThresh 0.25->0.20, the deep emission weights, OR the
deep transition row all still reproduce the exact golden hypnogram (only a gross
change, e.g. forcing deep out, fails it). The crafted night's phases are stark
enough that the fine tune moves no boundary — a golden only discriminates where the
input sits near a decision boundary. So the golden's real value is locking the
recipe's end-to-end SHAPE + full-path Swift/Kotlin parity, not the exact values.

Adds a direct, input-independent guard on both platforms
(tunedDeepBoundaryConstantsArePinned / testTunedDeepBoundaryConstantsArePinned):
asserts deepGateThresh == 0.25 and the exact deep transition row, plus a row-sum==1.0
invariant over the whole matrix (catches a renormalisation typo in the hand-edited
row). Widens the two Kotlin constants private->internal to match Swift's already-
internal statics (byte-parity-neutral). Verified sensitive: reverting deepGateThresh
or breaking the transition row now fails the direct test. The golden's doc comment is
corrected to say what it locks (shape + parity + gross regressions), and its Kotlin
name changed to frozenGoldenHypnogramPinsTheRecipeShapeAndParity.

The inline deep emission weights aren't named constants, so they remain guarded only
at the gross level by the golden (noted in-test).

Kotlin: testFullDebugUnitTest green. Swift: swift-packages CI (StrandAnalytics needs macOS).
simoncad7 pushed a commit to simoncad7/noop that referenced this pull request Aug 17, 2026
…the golden alone didn't lock them) (ryanbr#311)

Re-review of ryanbr#310 found its frozen golden does NOT actually guard the ryanbr#277 tuned
constants: reverting deepGateThresh 0.25->0.20, the deep emission weights, OR the
deep transition row all still reproduce the exact golden hypnogram (only a gross
change, e.g. forcing deep out, fails it). The crafted night's phases are stark
enough that the fine tune moves no boundary — a golden only discriminates where the
input sits near a decision boundary. So the golden's real value is locking the
recipe's end-to-end SHAPE + full-path Swift/Kotlin parity, not the exact values.

Adds a direct, input-independent guard on both platforms
(tunedDeepBoundaryConstantsArePinned / testTunedDeepBoundaryConstantsArePinned):
asserts deepGateThresh == 0.25 and the exact deep transition row, plus a row-sum==1.0
invariant over the whole matrix (catches a renormalisation typo in the hand-edited
row). Widens the two Kotlin constants private->internal to match Swift's already-
internal statics (byte-parity-neutral). Verified sensitive: reverting deepGateThresh
or breaking the transition row now fails the direct test. The golden's doc comment is
corrected to say what it locks (shape + parity + gross regressions), and its Kotlin
name changed to frozenGoldenHypnogramPinsTheRecipeShapeAndParity.

The inline deep emission weights aren't named constants, so they remain guarded only
at the gross level by the golden (noted in-test).

Kotlin: testFullDebugUnitTest green. Swift: swift-packages CI (StrandAnalytics needs macOS).
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