diff --git a/lib/compute/derivation_engine.dart b/lib/compute/derivation_engine.dart index cdf95040..bef8ab19 100644 --- a/lib/compute/derivation_engine.dart +++ b/lib/compute/derivation_engine.dart @@ -1654,6 +1654,14 @@ import 'substrate.dart'; // change on the affected sub-quantum-dispersion nights, so the bump is real. // kAnalyticsPin/kProtocolPin are UNCHANGED: edge-only fix. // +// 91 → 92 (baevskyStressIndex is now gap-aware): passes `nnTimesMs` at the +// one call site (onehz_pipeline.dart) so a charging/off-wrist hole inside a +// sleep window segments the 256-beat sliding window instead of one window +// straddling the gap and reading the pre/post-gap RR jump as MxDMn — the +// same bug class `cvhrApneaScreen` already had a fix for. Real output change +// for any night that had an internal gap. kAnalyticsPin bumped alongside +// this (analytics PR #70). +// // 90 → 91 (`_resolveOwnership` drops newly-paired devices): once a signal's // `signal_priority` had ANY stored row, a device that started declaring that // signal afterward (paired later, no stored row) was never added to the @@ -1664,7 +1672,7 @@ import 'substrate.dart'; // output change for any user who customized priority for a signal and then // paired another device that also declares it. kAnalyticsPin/kProtocolPin // UNCHANGED: edge-only fix. -const int kAlgoVersion = 91; +const int kAlgoVersion = 92; /// The sibling SHAs this version was derived against, asserted against /// pubspec.yaml in test/db_serve_version_and_reads_test.dart. /// @@ -1833,7 +1841,10 @@ const int kAlgoVersion = 91; // picking one single-device SHA over the other. Verified: `1cf8e61` (this // branch's own pin) IS an ancestor of `fe1464d` — the wearfit protocol // commit is already folded in, nothing is lost by moving to the tip. -const String kAnalyticsPin = '41ac641a94852abec29c287e3d9668f33f7f56c9'; +const String kAnalyticsPin = '1bf9b6233b364bb4cc307e298abda0c97d25aeef'; +// Repinned to analytics PR #70's merged main SHA (was the pre-squash branch +// commit 47847fa, orphaned once the PR squash-merged) — same content, see +// pubspec.yaml's comment for the verification command. // REPIN (this branch, superseded by the merge): polar pmd's own protocol // needs `feat/polar-pmd-protocol` (87ee803), but protocol's own `origin/main` // tip below is THAT SAME PR's merge commit — verified diff --git a/lib/compute/onehz_pipeline.dart b/lib/compute/onehz_pipeline.dart index e21dd1f6..beae36e8 100644 --- a/lib/compute/onehz_pipeline.dart +++ b/lib/compute/onehz_pipeline.dart @@ -456,7 +456,10 @@ Map deriveDayBundle(Map inputJson) { final ac = accelerationCapacity(nn); // Baevsky Stress Index over the sleep NN — resting autonomic tension (a // transparent RR-histogram metric; no ML). Daily resting-stress indicator. - final stress = baevskyStressIndex(nn); + // nnTimesMs lets it segment at a charging/off-wrist gap instead of letting + // a sliding window straddle it (same gap-aware pattern as cvhrApneaScreen + // below). + final stress = baevskyStressIndex(nn, nnTimesMs: nnTimes); // ── RESPIRATION (sleep-windowed) ─────────────────────────────────────────── final resp = nn.length >= 30 diff --git a/pubspec.lock b/pubspec.lock index 188178bb..1dd64c14 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -937,8 +937,8 @@ packages: dependency: "direct main" description: path: "." - ref: "41ac641a94852abec29c287e3d9668f33f7f56c9" - resolved-ref: "41ac641a94852abec29c287e3d9668f33f7f56c9" + ref: "1bf9b6233b364bb4cc307e298abda0c97d25aeef" + resolved-ref: "1bf9b6233b364bb4cc307e298abda0c97d25aeef" url: "https://github.com/OpenStrap/analytics.git" source: git version: "1.0.0" diff --git a/pubspec.yaml b/pubspec.yaml index f7b70c42..ff98bd17 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -434,7 +434,17 @@ dependencies: # Verified against the SHA: # `git show 41ac641:lib/src/onehz/clinical/vo2max.dart | # grep -E 'vo2maxSubmaxEstimate|workout_grade'` - ref: 41ac641a94852abec29c287e3d9668f33f7f56c9 + # + # analytics PR #70 (merged to main @ 1bf9b62): adds optional + # `nnTimesMs` + `maxGapSec` to `baevskyStressIndex`, so a + # charging/off-wrist hole spliced into one sleep-night NN array + # segments before the 256-beat sliding window instead of a straddling + # window reading the pre/post-gap RR jump as MxDMn (same gap-aware + # pattern `cvhrApneaScreen` already has). No-times callers are + # byte-identical. Verified: + # `git show 1bf9b62:lib/src/onehz/clinical/stress_si.dart | + # grep -n 'nnTimesMs\|maxGapSec'` + ref: 1bf9b6233b364bb4cc307e298abda0c97d25aeef # BLE — flutter_blue_plus is the maintained cross-platform GATT client. flutter_blue_plus: ^1.36.8