Repository navigation
fix(sleep): recover unmatched off-wrist tails from sustained HR - #2585
Merged
Merged
Conversation
…ence The contract pinned `dailyMetrics: persistedDailies` as a literal. Per-day windowing for preserveUnscoredHistory replaced that argument with a ternary, so the literal went missing and the test went red while the invariant it exists to protect was intact: both branches still read only the snapshot-protected copy. Pin both branches instead. That dailiesByDay groups from persistedDailies covers the per-day path, and the ternary's else covers the wide path. Mutation-checked in both directions: grouping from raw dailies, and writing raw dailies in the wide branch, each turn the test red. That is wider than the literal it replaces, which only ever pinned the wide branch. The assertNotIn over the derivations is untouched. That is the assertion keeping a legacy snapshot from masquerading as a value recalculated against today's baselines, and it never stopped passing.
3 of 5 tasks
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.
Stacked rebase of #2375 by @fadkeprasad, replayed onto current
mainso their four commits keep theirauthorship, plus one commit from me repinning a contract test.
Their work is unchanged. Unmatched
WRIST_OFFtails are closed from sustained valid HR (five minutes,30 to 220 bpm, no gap over five seconds, invalid samples reset the run), returning the first observed
sample of the confirmed run rather than inventing a boundary, with the Kotlin twin line for line
equivalent. The history repair is one-shot, reentrancy-guarded, foreground-only, and marks its flags
only inside the post-persistence callback, so a busy, cancelled or failed attempt leaves the work
pending.
preserveUnscoredHistoryalso stops the existing Effort repair replacing an entire historicalwindow, which is a data-loss fix riding along inside a sleep change.
The parity authority is theirs as well: reciprocal twin claims re-formed the
offWristIntervalspair atits new arity and paired both
WristWearRecoveryfiles, so the identity change took no debt.Why this branch rather than a merge of #2375
parity-governancewas red ontest_rr_legacy_preservation_contract, which pinneddailyMetrics: persistedDailiesas a literal. Per-day windowing replaced that argument with a ternary.The invariant was never broken:
dailiesByDaygroups frompersistedDailies, there is exactly onepersistComputedScorescall site, and theassertNotInover the derivations never stopped passing.The repin cannot land on its own, because
mainstill has the old literal and the new assertions wouldnot match there. It has to travel with the Swift change, and a contributor should not have to carry a
workflow defect, so I added it here instead of asking for another push.
Why it stayed hidden for eight days
That test reads product source but sits behind
parity-governance.yml'sTools/parity_*path filter,and the core
tools-pythonstep collects withfind . -maxdepth 1fromTools, soTools/tests/**is not in it either. The ternary landed on 2026-09-21 and the test did not run once until
Tools/parity_dispositions.jsonwas touched seven days later. Same shape as #2582 and #1691, trackedseparately and deliberately not widened here.
Verification, on this exact tree
test_rr_legacy_preservation_contract: 2/2 OK, mutation-checked both ways. Grouping from rawdailies, and writing rawdailiesin the wide branch, each turn it red. The literal it replacesonly ever pinned the wide branch, so this is wider.
parity_ratchet.py --base origin/main:errors=049e2237was cleanStill unmeasured, and carried over from review: elapsed time for a full foreground
historyDays: 4000repair on WHOOP 5 or MG with deep history, where R-R window reuse is disabled for the whole family.
Correct and retrying either way, so not gating, but it wants a real device.
Credit to @fadkeprasad.