diff --git a/.planning/STATE.md b/.planning/STATE.md index c2b54f361..6cd110c84 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -1,7 +1,7 @@ # v1.4.23 marathon — state log -Status: Wave 4 shipped (OpenAPI gate + Coach schema + native auth + Coolify) -Last update: 2026-05-11T01:15+02:00 +Status: Wave 5 shipped (7 hygiene items + 8 atomic commits) +Last update: 2026-05-11T02:00+02:00 > Previous milestone: v1.4.22 live (image digest > `sha256:865154614303…`, `/api/version=1.4.22`). @@ -148,13 +148,49 @@ Last update: 2026-05-11T01:15+02:00 ## Wave 5 — Hygiene (H1-H7) -- [ ] H1 sentinel parser malformed-enum hardening -- [ ] H2 analytics-route unbounded `findMany` pagination -- [ ] H3 `` controlled-prop refactor -- [ ] H4 per-user prompt-tuning surface (Coach settings cog return) -- [ ] H5 schema drift on `medication_schedules.days_of_week` -- [ ] H6 Pearson p-value normal-approx replacement -- [ ] H7 Coach helpful/unhelpful first-week observation view +- [x] H1 sentinel parser malformed-enum hardening + (`SentinelParseResult.malformedEntries[]` + per-line typed + reasons; chat route splits `coach.keyvalues.parse_partial` from + the full-block `coach.keyvalues.parse_failed`) +- [x] H2 analytics-route unbounded `findMany` pagination + (cursor-paged 5 000-row chunks via `fetchBpSeriesChunked`, + `analytics.bp_in_target.row_count` wide-event meta for slow- + query attribution; integration test seeds 6 000 rows across a + chunk boundary) +- [x] H3 `` controlled-prop refactor + (`useResettableValue` hook + pure `nextResettableValue` helper; + `key={prefill}` removed from the parent mount) +- [x] H4 per-user prompt-tuning surface (Coach settings cog return) + (`User.coachPrefsJson` migration `0038_coach_prefs`; new + `GET/PUT /api/auth/me/coach-prefs`; settings cog opens a + right-edge ``; system-prompt prepends a per-user + OVERRIDE; snapshot reads prefs BEFORE measurement queries so + `excludeMetrics` filters before the snapshot lands) +- [x] H5 schema drift on `medication_schedules.days_of_week` + (decision: deploy — column is referenced by 9 source files + across 4 user-visible surfaces; migration + `0039_medication_schedule_days_of_week`, NULL = daily) +- [x] H6 Pearson p-value normal-approx replacement + (raised `MIN_PAIRED_N` from 14 → 20 — conservative patch; + rigorous incomplete-beta queued as a v1.4.24 candidate) +- [x] H7 Coach helpful/unhelpful first-week observation view + (polymorphic `RecommendationFeedback.target_type` migration + `0040_recommendation_feedback_target_type`; new POST + `/api/insights/chat/messages/:id/feedback`; aggregator slice + `buildCoachFeedbackBuckets` by (promptVersion, tone, verbosity); + admin section `/admin/coach-feedback` with the H7 i18n bundle + both EN + DE) + +W5 commits (8): 58ae9bc, fa07748, 9413d29, 3f60c81, 0eda1de, 1faee95, +05c7f14, plus this STATE tick. + +Test deltas: 2191 → 2223 unit (+32). Integration suite added 3 +files: `coach-prefs`, `coach-feedback`, plus the 6000-row chunk +boundary regression in the existing `bp-in-target` test. + +OpenAPI registry coverage: +3 routes (GET / PUT +`/api/auth/me/coach-prefs`, POST +`/api/insights/chat/messages/{id}/feedback`). ## Wave 6 — Multi-agent QA + Product-Lead review diff --git a/.planning/phase-W5-v1423-report.md b/.planning/phase-W5-v1423-report.md new file mode 100644 index 000000000..7bf795976 --- /dev/null +++ b/.planning/phase-W5-v1423-report.md @@ -0,0 +1,90 @@ +# v1.4.23 Wave 5 — hygiene (H1-H7) + STATE tick + +Closes the seven hygiene items deferred from +`.planning/v1422-backlog.md`. Eight atomic commits; develop branch +clean, all unit + drift gates green. + +## Commits + +1. `58ae9bc` — `feat(coach): partial-malformed observability on + sentinel parser` (H1) +2. `fa07748` — `perf(api): chunked BP aggregate replaces unbounded + findMany` (H2) +3. `9413d29` — `refactor(coach): drawer prefill becomes a controlled + prop` (H3) +4. `3f60c81` — `feat(coach): per-user prompt-tuning surface (settings + cog returns)` (H4 — prisma + route + UI) +5. `0eda1de` — `chore(schema): deploy medication_schedules.days_of_week + column` (H5) +6. `1faee95` — `fix(insights): tighter Pearson surfacing gate (n>=20)` + (H6) +7. `05c7f14` — `feat(coach): per-message thumbs feedback + admin + aggregate view` (H7 — schema + route + UI) +8. (this commit) — `docs(planning): record W5 hygiene wave + STATE + tick` + +## H5 decision + +Deploy the column. `MedicationSchedule.daysOfWeek` is referenced by +nine source files across the form, card, intake list, reminder +dispatcher, and gamification path. Removing it would force a UI +rewrite of the recurrence picker and break existing test fixtures. +Migration `0039_medication_schedule_days_of_week` adds the column +nullable, default NULL. NULL means "daily" — `parseScheduleRecurrence(null)` +already returns the all-7-days set so existing rows get the correct +semantics without backfill. + +## H7 admin view + +Path: `/admin/coach-feedback`. Renders the Coach-only buckets sliced +by (promptVersion, tone, verbosity) with helpful / not-helpful / n / +helpful-rate columns. First useful question it answers in the +v1.4.23 first-week window: "Is the v1.4.22 prose rewrite landing +well, or did the warm tone overshoot?" If the helpful-rate for +PROMPT_VERSION 4.23.x drops below 50% within the first 100 ratings, +v1.4.24 walks the persona back. + +## OpenAPI registry — additions + +Three new routes registered: + +- `GET /api/auth/me/coach-prefs` (H4) +- `PUT /api/auth/me/coach-prefs` (H4) +- `POST /api/insights/chat/messages/{id}/feedback` (H7) + +Spec regenerates without drift; `pnpm openapi:check` passes. + +## Test deltas + +- Unit: 2191 → 2223 (+32) +- Integration: +2 new files (`coach-prefs.test.ts`, + `coach-feedback.test.ts`) plus a 6 000-row chunk-boundary + regression added to `bp-in-target.test.ts` + +## Verification gates + +- `pnpm typecheck` — clean across all 8 commits +- `pnpm lint` — 0 errors, 21 warnings (all pre-existing in + unrelated files) +- `pnpm test --run` — 256 files / 2223 tests passing +- `pnpm openapi:check` — spec in sync + +## Carry-overs + +None — all seven hygiene items shipped. + +## Notes for v1.5 + +- The Pearson surfacing-gate raise (n≥14 → n≥20) means some + borderline correlation cards STOP rendering. If the v1.4.16 B5e + feedback aggregator shows users miss those cards, drop in the + rigorous incomplete-beta replacement in v1.4.24 (queued as the + follow-up). +- The Coach settings cog opens a small surface today (4 controls). + v1.4.24+ can iterate based on the H7 admin dashboard's first-week + signal — the design review pushed back on per-message controls in + v1.4.23, defer that decision to v1.5 P3. +- Per-user `coachPrefsJson` is read on every Coach turn — no caching + layer to invalidate. The settings sheet writes the + `["coach-prefs"]` query cache directly so the next reply honours + the new defaults without a page reload.