Repository navigation
test(sleep): pin the #277 tuned deep-boundary values directly (the #310 golden didn't lock them) - #311
Merged
Conversation
…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).
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):deepGateThresh == 0.25and the exact deep transition row,private→internalto 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
testFullDebugUnitTestgreen; sensitivity confirmed by reverting each constant.SleepStagerV2Testsruns in swift-packages CI (StrandAnalytics needs macOS).