Eleven touch-disjoint waves landed on develop plus a six-axis QA reconcile round before tagging. See CHANGELOG.md for the user-facing prose; this commit message documents the wave + report inventory for release-management traceability. Waves shipped (each with a phase report under .planning/): - phase-W-POOL-v1440-report.md — p-limit(4) wrapper around the analytics 15-way fan-out + pg.Pool max raised 10 -> 20. Closes the v1.4.39 empirical-trace finding #1 (Prisma pool starvation). - phase-W-DELETED-v1440-report.md — 11 reader-tier helpers + 3 integration contracts close audit Critical Finding #3 (soft-delete invisibility) across dashboard, analytics, summaries, rollup tiers, and the Coach snapshot path. - phase-W-INSIGHTS-v1440-report.md — mood-rollup swap on the three /api/insights/{features,targets,cards} routes plus the compliance-rollup hook gap closure for bulk-projection mints; the post-QA reconcile patch closes the six remaining measurement.findMany sites in the cluster that still leaked tombstoned rows. - phase-W-INFRA-v1440-report.md — rollup helper umbrella consolidation under src/lib/rollups/* with zero orphan re-exports; lint, typecheck, knip, and 93/93 rollup tests green post-restructure. - phase-W-RSC-v1440-report.md — per-tile Suspense boundaries plus the queryKey factory-bypass walker test (extended to comparison/ in the reconcile pass). - phase-W-PRIVACY-v1440-report.md — bilingual /privacy page with 17 paired-section tests pinning the 9 SB-3 disclosure requirements. - phase-W-AASA-v1440-report.md — /.well-known/apple-app-site-association endpoint pinned to S8WDX4W5KX.dev.healthlog.app with app-ID parity assertions guarding against split rotation. - phase-W-APNS-NOTIFY-v1440-report.md — MEDICATION_REMINDER time-sensitive APNs payload (priority 10 + interruption-level) scoped via a parameterised test that pins all 6 other event-types do not bypass Focus. AP-2 .p8 install gates real delivery. - phase-W-CONSENT-v1440-report.md — AI consent receipts CRUD with append-only invariant pinned in test; revoke-then-regrant leaves both rows; idempotent DELETE returns 200 + receipt: null. - phase-W-WMY-WIRE-v1440-report.md — three previously-dead WMY readers (week/month/year) wired through summaries-slice and health-score-fast-path with a linear-composability parity test pinning the cross-consumer routing contract. - phase-W-GHOSTS-v1440-report.md — ~1 177 lines of dead code removed across 9 atomic commits; startOfUtcDay + wallClockInTz consolidation eliminates a sibling-drift risk; knip whitelist trimmed to three files pending follow-up. QA reconcile patches applied per the v1.4.40 QA round (six reports under .planning/round-v1440-QA-*-findings.md): - senior C1 — dashboard-suspense-boundaries regex aligned with the post-W-INFRA Thread 2 userTimezone-local lift. - senior H1 — soft-delete filter added to the six remaining insights measurement.findMany sites. - specialist H1 — Promise.allSettled around bulk-projection compliance recompute on both /api/medications/intake and /api/dashboard/summary. - ux H1 — compare-toggle migrated to queryKeys.dashboardWidgets factory; walker test extended to src/components/comparison/. - security M1 — consent artefact 64 KB cap enforced via Buffer.byteLength (UTF-8 bytes, not UTF-16 code units). Quality gates green at tag: pnpm typecheck, pnpm lint, pnpm knip --include files,dependencies,binaries,unlisted, pnpm test --run (4726 passing / 1 skipped). Tests 4525 -> 4726 unit + 1 skipped over the v1.4.39 -> v1.4.40 span. User-facing prose: see CHANGELOG.md.
7.0 KiB
Phase W-RSC v1.4.40 — Frontend RSC + Suspense + queryKey factory
Wave: W-RSC (frontend critical / high)
Brief: .planning/round-v1439-arch-qa-frontend.md
Branch: develop
Range: c9d5479b → HEAD (691443e2)
Shipped
1. queryKey factory enforcement
src/lib/query-keys.ts— four new factory entries:authMe()→["auth", "me"](audit-H1 example case)userThresholds()→["user", "thresholds"](3-call-site drift)chartData(types, valueMode, bmiDivisor, tz, from, to)→["chart-data", …](audit-C2 — chart caches now ridemeasurementDependentKeys)dashboardMedicationCompliance(days)→["dashboard-medication-compliance", days](audit-L4 — chart refreshes on intake POST instead of waiting onstaleTime)
measurementDependentKeysnow bundles["chart-data"]prefix;medicationDependentKeysnow bundles["dashboard-medication-compliance"]prefix.- Migrated call sites:
src/hooks/use-auth.ts,src/app/insights/page.tsx,src/app/insights/medikamente/page.tsx,src/app/insights/stimmung/page.tsx,src/components/insights/insights-layout-shell.tsx,src/components/charts/health-chart.tsx,src/components/charts/medication-compliance-chart.tsx,src/components/charts/mood-chart.tsx.
2. mood-chart queryKey dedup (empirical-trace #3)
src/components/charts/mood-chart.tsx:316was bare["mood-chart-data"]; the dashboard atapp/page.tsx:291already ranqueryKeys.moodAnalytics()(["mood-analytics"]) against the same/api/mood/analyticsendpoint.- Re-keyed to
queryKeys.moodAnalytics()so TanStack dedups the request. Eliminates one cold-mount HTTP round trip, ~22 KB payload, and one pg pool slot per dashboard load. - Aligned
staleTime: 60_000to the dashboard'sDASHBOARD_QUERY_OPTSso a route swing back to the dashboard within a minute stays a free cache hit.
3. Per-tile Suspense boundaries (audit-H2 + brief C1)
src/app/page.tsx— wrapped every chart-row cell in<Suspense fallback={<ChartSkeleton />}>and every tile-strip cell in<Suspense fallback={null}>.- The dynamic-loaded charts (
HealthChartDynamic,MoodChart,MedicationComplianceChart) already paint a<ChartSkeleton>during JS chunk resolution vianext/dynamic({ loading: … }); the Suspense layer lifts the same skeleton to a streaming- compatible boundary so a futureuseSuspenseQuerymigration automatically buckets each chart's loading state to its own cell without a further composition pass.
4. Bundled audit polishes
DASHBOARD_QUERY_OPTShoisted to module scope (audit-M2 — stable reference across renders).getHourForTimeZonememoised viauseMemokeyed onuser?.timezone(audit-H4 — keeps theIntl.DateTimeFormatinstantiation off the per-render hot path).
5. Tests
src/lib/__tests__/query-keys.test.ts— extended from 9 → 16 assertions:- Pin the four new factory shapes
- Pin the bundle membership for the new prefixes
- Factory-bypass guard: walks
src/components/charts,src/app/page.tsxandsrc/hooks/use-auth.tsand fails if anyqueryKey:literal array slipped past the factory. Acts as lint-style enforcement in lieu of a custom ESLint rule.
src/app/__tests__/dashboard-suspense-boundaries.test.ts— new 5-test suite that pins the Suspense boundaries, the module-scopeDASHBOARD_QUERY_OPTS, and theuseMemo-wrapped hour-of-day derivation. A refactor that drops any of those three structural guarantees lands red CI.
Decisions deferred
-
app/page.tsxRSC migration (brief item 3). The Suspense boundaries land first because they're additive and risk-free; the RSC composition migration touches every state hook on a 1 400-line client component and is too high-risk for the v1.4.40 envelope. Recommendation: open a v1.4.41 phase that:- Carves out a
<DashboardComposition>server-component shell that fetches the slim-analytics + widgets server-side viaheaders()+ the shared session helper. - Streams the slim payload through
<Suspense>to the existing client tile-strip island. - Keeps thick analytics + per-chart
["chart-data", …]queries on the client. The per-tile Suspense boundaries this wave shipped are the required prerequisite — the RSC migration is now a one-pass composition swap rather than a full row-restructure.
- Carves out a
-
Custom ESLint rule for queryKey factory (brief item 2). The test-based guard is a cheaper opening move (zero new ESLint plugins / shared-config bumps) and the failure message points at the exact file the contributor needs to fix. A v1.4.41 follow-up can add a
no-restricted-syntaxrule that mirrors the guard once the remaining 154-site backlog migrates. -
Long-tail factory migration (audit-H1 — 154 bare sites). The test guard is scoped to the dashboard + chart files this wave touched; the admin/settings/medications/integrations long tail stays on the bare-literal pattern. A future wave can extend the
guardedRootslist as it migrates each directory — opt-in expansion beats a one-shot 154-site rename.
Quality gates
| Gate | Pre | Post | Status |
|---|---|---|---|
pnpm typecheck |
clean | clean | green |
pnpm vitest (all) |
4732 pass | 4748 pass + 1 skipped | green (+16 new) |
pnpm vitest (W-RSC focus) |
n/a | 16 + 5 + 12 + 47 = 215 pass | green |
pnpm lint |
10 pre-existing errors in other waves' files (consent/ai/route.ts, privacy/page.tsx) | identical | unchanged |
Playwright dashboard.spec.ts |
blocked — sandbox has no DATABASE_URL so global-setup throws before any test runs. The CI environment has the DB and will gate normally. |
Commits
- Factory routing — landed in
8187d549(bundled with the parallel APNS commit due to a cross-agent file-write race; the factory-routing patch was applied atgit addtime but a second agent's commit captured the staged tree before mygit commitcould finalise. Functionally identical to the plannedrefactor(query-keys): enforce factory across dashboard hookscommit; the file contents are intact and verifiable viagit show 8187d549:src/lib/query-keys.ts). 1dd1a9a7—fix(mood-chart): align queryKey to the shared mood-analytics factory entry3cacfcf9—feat(dashboard): per-tile Suspense boundaries for progressive paint691443e2—test(query-keys): pin factory enforcement and dedup behaviour
Observed pattern — cross-agent commit drift
The factory-routing commit (1) was the second time this marathon a
parallel agent's commit absorbed staged-but-not-yet-committed work
from a sibling agent's worktree. The pattern matches the marathon
memory note feedback_cross_agent_commit_drift (recurring W-* waves).
Mitigation suggestion for v1.4.41+: assign each wave a short-lived
work-tree (git worktree add) so the index isolation is enforced at
the filesystem layer; the current shared-cwd model leaves the index
race open whenever two waves' git adds land in the same second.