mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 15:23:29 +00:00
fix(cycle): scope symptothermal to the current cycle, unify luteal clamp, widen fertile + crosstab coverage
The symptothermal layer ran against the full day-log history: detectTempShift returned the earliest 3-over-6 rise and detectMucusPeak the last egg-white day across all cycles, so a multi-cycle user with historical BBT confirmed a months-old ovulation and the predicted next-period start landed in the past. Scope the temperature/mucus detectors to the current cycle window [lastConfirmedStart − BBT_WINDOW, today], take the latest qualifying temp shift, and reject any confirmation whose next-start is already in the past. Resolve luteal length through a single clamp. The predictor clamped to [10,16] while the calendar adapter and phase mapper used the raw stored value, so the ovulation dot and the OVULATORY band could land on different days for an out-of-clamp profile. Export resolveLuteal/clampLuteal, route buildCalendar, buildPhaseCycles and phaseForDay through it, and tighten the profile-prefs Zod bound to the same [10,16] range. Show the fertile window for AVOID_PREGNANCY as well as TRYING_TO_CONCEIVE per the algorithm spec; it stays hidden for GENERAL_HEALTH/PERIMENOPAUSE. Bound the day-log reads on the calendar and insights routes to the rendered span plus the symptothermal lookback instead of the full history; cycle-length stats already run off the MenstrualCycle rows. Add mood and blood glucose as phase-crosstab outcome metrics under the same FDR and per-group day floors. Mood is read from MoodEntry and injected as a synthetic channel since it is not a measurement row. Add multi-cycle, luteal-clamp and fertile-window fixtures. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
ac13dd28ed
commit
15bece9849
13 files changed
+354
-36
No files matched your search
@@ -176,7 +176,9 @@ export const cyclePrefsSchema = z
|
||||
sensitiveCategoryEncryption: z.boolean().optional(),
|
||||
typicalCycleLength: z.number().int().min(15).max(60).nullable().optional(),
|
||||
typicalPeriodLength: z.number().int().min(1).max(15).nullable().optional(),
|
||||
lutealPhaseLength: z.number().int().min(8).max(20).nullable().optional(),
|
||||
// Bound matches the engine clamp [LUTEAL_MIN, LUTEAL_MAX] (§4) so the
|
||||
// stored value never silently snaps in the predictor (QA HIGH).
|
||||
lutealPhaseLength: z.number().int().min(10).max(16).nullable().optional(),
|
||||
})
|
||||
.refine((v) => Object.keys(v).length > 0, {
|
||||
message: "At least one preference field is required",
|
||||
|
||||
Reference in new issue
Block a user