mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 23:52:24 +00:00
feat(insights): correlate intake, alcohol days, training, rings, State of Mind and room climate
The discovery matrix gains the families people log but could not test: water, caffeine and up to four varying micronutrients from the nutrient log, alcohol days from the mood tag, workout minutes (one per session) and the day's training impulse, exercise, stand and mindful minutes, State of Mind as an outcome, and the overnight room climate against that night's sleep only. Every channel runs through the same seasonal adjustment, effective-n p-value, Benjamini-Hochberg control and effect-size floor, is read only while its module is on, and drops out below the paired-day floor. State of Mind, mindful minutes and alcohol days are statistics for the person: the Coach, the period narrative and the assessment cards drop every pair that touches them, after the shared scan so the remaining pairs keep the statistics the correlations page shows. A guard walks the import closure of the analysis modules and refuses any path to a provider.
This commit is contained in:
1 parent
30248efaf1
commit
faa3ef867b
31 files changed
+1706
-34
No files matched your search
@@ -60,6 +60,8 @@ import {
|
||||
MOVEMENT_AWAY_CHANNEL_KEY,
|
||||
MOVEMENT_DISTANCE_CHANNEL_KEY,
|
||||
DISCOVERY_OUTCOMES,
|
||||
EXTENDED_CHANNEL_KEYS,
|
||||
NUTRIENT_CHANNEL_PREFIX,
|
||||
FACTOR_CHANNEL_PREFIX,
|
||||
} from "@/lib/insights/correlation-discovery";
|
||||
import { DERIVED_METRIC_IDS } from "@/lib/insights/derived/registry";
|
||||
@@ -197,6 +199,9 @@ describe("every surface id names a surface that exists", () => {
|
||||
MOVEMENT_AWAY_CHANNEL_KEY,
|
||||
MOVEMENT_DISTANCE_CHANNEL_KEY,
|
||||
"LAB_DRAWS",
|
||||
...EXTENDED_CHANNEL_KEYS,
|
||||
// The fold target of every `NUTRIENT:<code>` channel.
|
||||
"NUTRIENT",
|
||||
]);
|
||||
for (const id of localIds("correlation")) {
|
||||
expect(channels.has(id), id).toBe(true);
|
||||
@@ -209,6 +214,21 @@ describe("every surface id names a surface that exists", () => {
|
||||
expect(correlationChannelSurfaceId(`${SYMPTOM_CHANNEL_PREFIX}abc`)).toBe(
|
||||
"correlation:SYMPTOM_SEVERITY",
|
||||
);
|
||||
expect(correlationChannelSurfaceId(`${NUTRIENT_CHANNEL_PREFIX}zinc`)).toBe(
|
||||
"correlation:NUTRIENT",
|
||||
);
|
||||
});
|
||||
|
||||
it("every extended channel has an owner or is reviewed as unowned", () => {
|
||||
const unowned = new Set(["EXERCISE_MINUTES", "STAND_MINUTES"]);
|
||||
for (const key of EXTENDED_CHANNEL_KEYS) {
|
||||
if (unowned.has(key)) {
|
||||
expect(surfaceModule(`correlation:${key}`), key).toBeUndefined();
|
||||
} else {
|
||||
expect(surfaceModule(`correlation:${key}`), key).toBeDefined();
|
||||
}
|
||||
}
|
||||
expect(surfaceModule("correlation:NUTRIENT")).toBe("nutrients");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -228,6 +228,24 @@ const STATIC_SURFACE_MODULE = {
|
||||
// v1.43 — the Dawarich movement channels ride the environment module.
|
||||
"correlation:MOVEMENT_AWAY": "environment",
|
||||
"correlation:MOVEMENT_DISTANCE": "environment",
|
||||
// v1.44 — the extended families. Intake rides the opt-in nutrient log (the
|
||||
// `NUTRIENT:<code>` micronutrient channels fold onto `correlation:NUTRIENT`),
|
||||
// alcohol days are read from mood entries' tag, and the two training
|
||||
// channels from the workout record. State of Mind and mindfulness are
|
||||
// self-reports about feeling, so they follow mood. The room climate rides
|
||||
// the environment module like the weather. Exercise and stand minutes are
|
||||
// ambient movement like steps and carry no owner.
|
||||
"correlation:HYDRATION": "nutrients",
|
||||
"correlation:CAFFEINE": "nutrients",
|
||||
"correlation:NUTRIENT": "nutrients",
|
||||
"correlation:ALCOHOL": "mood",
|
||||
"correlation:WORKOUT_MINUTES": "workouts",
|
||||
"correlation:TRAINING_LOAD": "workouts",
|
||||
"correlation:MINDFUL_MINUTES": "mood",
|
||||
"correlation:STATE_OF_MIND_VALENCE": "mood",
|
||||
"correlation:INDOOR_CO2": "environment",
|
||||
"correlation:INDOOR_TEMPERATURE": "environment",
|
||||
"correlation:INDOOR_HUMIDITY": "environment",
|
||||
|
||||
// ── Day view sections (v1.42) ──
|
||||
// The readings carry no owner here: each value follows its own type's
|
||||
@@ -355,5 +373,8 @@ export function correlationChannelSurfaceId(channelKey: string): string {
|
||||
// A person-defined symptom (`SYMPTOM:<id>`, v1.40) rides the illness
|
||||
// module, like the symptom-burden channel it sits beside.
|
||||
if (channelKey.startsWith("SYMPTOM:")) return "correlation:SYMPTOM_SEVERITY";
|
||||
// One micronutrient's intake (`NUTRIENT:<code>`, v1.44) rides the nutrient
|
||||
// log like water and caffeine.
|
||||
if (channelKey.startsWith("NUTRIENT:")) return "correlation:NUTRIENT";
|
||||
return `correlation:${channelKey}`;
|
||||
}
|
||||
Reference in new issue
Block a user