From 5ce0e81a64b7376f492a66cd96813946e0033a5d Mon Sep 17 00:00:00 2001 From: Mohammad Abdul Sahil <127765312+abdulsaheel@users.noreply.github.com> Date: Sat, 5 Dec 2026 15:34:01 +0530 Subject: [PATCH 1/3] luteal flags: skip closed cycles over the 60 day cap (missed log, not a cycle) --- lib/src/onehz/wellness/temp_health.dart | 3 +++ test/luteal_flags_test.dart | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/lib/src/onehz/wellness/temp_health.dart b/lib/src/onehz/wellness/temp_health.dart index aeecc7c..d9d6bba 100644 --- a/lib/src/onehz/wellness/temp_health.dart +++ b/lib/src/onehz/wellness/temp_health.dart @@ -21,6 +21,7 @@ import '../types.dart'; import '../util.dart'; import '../foundations/baseline.dart'; +import 'cycle_lengths.dart' show cycleLengthImplausibleGapDays; // --------------------------------------------------------------------------- // 1. Skin-temp z-score illness flag (cycle-aware) @@ -314,6 +315,8 @@ List lutealFlags(List dates, List cycleStartDates) { ? starts[si + 1].difference(starts[si]).inDays.toDouble() : medianGap; if (len == null || len < 15) continue; + // a gap past the cycle cap is a missed log, not a cycle + if (len > cycleLengthImplausibleGapDays) continue; if (elapsed > 1.5 * len) continue; // stale log, not a long luteal phase if (elapsed >= len / 2) out[i] = true; } diff --git a/test/luteal_flags_test.dart b/test/luteal_flags_test.dart index 03e8945..51db134 100644 --- a/test/luteal_flags_test.dart +++ b/test/luteal_flags_test.dart @@ -25,6 +25,12 @@ void main() { [false, true, false]); }); + test('a gap over the cycle cap is a missed log, not a luteal phase', () { + expect( + lutealFlags(['2026-11-10'], ['2026-09-01', '2026-09-29', '2026-12-22']), + [false]); + }); + test('one logged start has no length to count with', () { expect(lutealFlags(['2026-02-20'], ['2026-01-01']), [false]); }); From bf8d49ba588c8b848754bd075404672b56117a9e Mon Sep 17 00:00:00 2001 From: Mohammad Abdul Sahil <127765312+abdulsaheel@users.noreply.github.com> Date: Sat, 5 Dec 2026 15:35:06 +0530 Subject: [PATCH 2/3] luteal flags: pin the 60 day boundary, document the cap --- lib/src/onehz/wellness/temp_health.dart | 3 +++ test/luteal_flags_test.dart | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/lib/src/onehz/wellness/temp_health.dart b/lib/src/onehz/wellness/temp_health.dart index d9d6bba..f92652c 100644 --- a/lib/src/onehz/wellness/temp_health.dart +++ b/lib/src/onehz/wellness/temp_health.dart @@ -278,6 +278,9 @@ Metric> menstrualCoverline( /// so the open cycle contributes nothing rather than a guess. One completed /// cycle is enough to give the open one a length. /// +/// A closed cycle longer than the 60 day cap is a missed log and counts for +/// nothing. +/// /// A date more than 1.5 cycles past its start is a lapse in logging, not a /// four-week luteal phase — it stops counting. List lutealFlags(List dates, List cycleStartDates) { diff --git a/test/luteal_flags_test.dart b/test/luteal_flags_test.dart index 51db134..932a209 100644 --- a/test/luteal_flags_test.dart +++ b/test/luteal_flags_test.dart @@ -31,6 +31,13 @@ void main() { [false]); }); + test('a closed cycle of exactly the cap still counts', () { + // 01-01 to 03-02 is 60 days: second half starts at day 30 + expect( + lutealFlags(['2026-01-20', '2026-02-15'], ['2026-01-01', '2026-03-02']), + [false, true]); + }); + test('one logged start has no length to count with', () { expect(lutealFlags(['2026-02-20'], ['2026-01-01']), [false]); }); From 3f2ae4b0054fd139122dd0d4a504b0ba1b392b41 Mon Sep 17 00:00:00 2001 From: Mohammad Abdul Sahil <127765312+abdulsaheel@users.noreply.github.com> Date: Sun, 6 Dec 2026 15:28:26 +0530 Subject: [PATCH 3/3] registry: list cycle_lengths under stress_illness, temp_health imports it --- lib/src/onehz/registry/group_registry.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/src/onehz/registry/group_registry.dart b/lib/src/onehz/registry/group_registry.dart index ee2c717..c534cf7 100644 --- a/lib/src/onehz/registry/group_registry.dart +++ b/lib/src/onehz/registry/group_registry.dart @@ -330,6 +330,7 @@ const GroupRegistry kAnalyticsGroupRegistry = GroupRegistry(1, [ 'lib/src/onehz/incremental_core.dart', 'lib/src/onehz/wellness/anomaly.dart', 'lib/src/onehz/wellness/changepoint.dart', + 'lib/src/onehz/wellness/cycle_lengths.dart', 'lib/src/onehz/wellness/readiness_composite.dart', 'lib/src/onehz/wellness/temp_circadian.dart', 'lib/src/onehz/wellness/temp_health.dart',