[Review] moodToScore neutral-fallback (returns 3 for unknown moods) silently distorts the mood-trend signal #178
Labels
No labels
blocked:depends-p1
blocked:gate-research
blocked:lint-failed
blocked:needs-decision
blocked:needs-human
blocked:verify-failed
bug
data-loss
documentation
enhancement
feature-request
in-progress
needs-decompose
needs-triage
pwa
quickfix
security
security/high
security/medium
test
test-coverage
triage-approved
vault
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Mark/kimi_agent_kin_app_sync#178
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Finding
src/lib/intimate-state-engine.ts:182-192:But at line 200 (inside
computeMoodTrend):If a user types a freeform mood the engine doesn't recognize (e.g. "anxious", "exhausted", a non-English word, or a future mood string not in the lookup table), the engine treats it as a neutral
3. Combined with a known mood later in the window, the average gets pulled toward neutral without any signal that an unknown mood was present.Why this matters
moodToScorefunction returnsnullfor unknowns (correct behavior). The downstream consumer?? 3overrides that null with neutral.Suggested fix
Two viable approaches; pick one and document the choice:
A. Drop unknowns —
score: moodToScore(i.mood)(no fallback). Update the filter at line 196 to.filter((i) => i.mood && i.date && moodToScore(i.mood) != null). Unknown moods don't enter the trend. The "stable" direction then reflects only known moods.B. Score unknowns explicitly as low (1) — preserves the entry's signal that "something negative happened" without claiming the user was neutral. Use
?? 1instead of?? 3.Either way, the schema should also be updated to constrain
moodtoVaultMoodValue | string(already typed that way invault-db.ts:42) and the UI should validate against the known list at entry time, so unknown moods only appear via legacy/migration paths.Severity
Medium. Signal integrity issue. The mood trend is a primary user-facing insight — silently neutering unknown moods makes the feature less trustworthy for users who use non-standard vocab.
Discovered by
Manual code review pass over #168, 2026-09-14.