domain: reflective derivations — foundation for the Daily Anchor / feedback loop#13
domain: reflective derivations — foundation for the Daily Anchor / feedback loop#13TargiX wants to merge 1 commit into
Conversation
Anchor captures a rich daily signal — 2D mood (energy×valence), sleep, habits, intention, journal — but derives almost nothing back: selectors.ts only knows "ritual done?" and a streak count. That give-without-get is why the product feels truncated. This adds lib/domain/reflection.ts: pure, unit-tested derivations that turn the captured data into gentle, factual signals a calm UI can surface — reflections, not grades: - moodOf / moodShift within-day mood movement (morning → evening) - averageValence mood level over a window - moodDirection rising / steady / falling (trend, not snapshot) - activeDays consistency: shown up N of last M days - averageSleepHours sleep level over a window - consecutiveLowSleepNights "third short night in a row", streak-style - habitCounts per-habit completions over a window No UI yet — this is the provable foundation for the Home "Daily Anchor" card. 18 new tests, full suite 71 green, tsc clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR introduces a new reflection domain module that exports ten pure functions for analyzing mood trends, sleep patterns, engagement metrics, and habit completion across a sliding window of day entries. All functions operate on immutable day-entry maps and include comprehensive Vitest coverage. ChangesReflection and Mood Analysis Domain
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Зачем
Anchor собирает богатый дневной сигнал (2D-настроение energy×valence, сон, привычки, intention, journal), но возвращает почти ничего: во всём
lib/единственные деривации — «ритуал сделан?» + стрик. Этот дисбаланс «отдаёшь и не получаешь» и создаёт ощущение обрубка.Это фундамент для замыкания петли — без UI, чисто провабельный слой. Спокойные отражения, а не оценки.
Что добавлено (
lib/domain/reflection.ts)moodShiftaverageValencemoodDirectionactiveDaysaverageSleepHoursconsecutiveLowSleepNightshabitCountsВсе функции чистые, в стиле существующего
selectors.ts, считают по уже собираемым полям — никаких изменений модели данных и поведения приложения.Проверки
reflection.test.ts), весь сьют 71 зелёныйtsc --noEmitчисто🤖 Generated with Claude Code
Summary by CodeRabbit