mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 23:33:29 +00:00
feat(coach): goal / if-then plan memory + locale-keyed dashboard snapshot
Add a CoachPlan model: durable, user-scoped if-then implementation plans the Coach proposes and the user confirms. The background memory-refresh pass extracts plans the user agreed to and writes them as "proposed"; only the user-facing PATCH on /api/coach/plans/[id] activates one. The free-text cue / action / target are encrypted at rest with the shared Bytes codec; metric, status and dates stay plain so the injection picker ranks without a per-row decrypt. Active plans fold into the Coach snapshot's memory block and survive the prompt-budget drop alongside facts. List, confirm and soft-delete routes are Coach-gated and narrow the owner from the session. Key the dashboard-snapshot query cell by locale so a locale switch reads freshly localised tile copy on its own cell instead of serving the prior locale's prose until the slot goes stale. The zero-arg key stays byte-identical, so every prefix-based invalidation keeps reaching the locale-keyed cells; the offline-banner and preloader match on the prefix. Migration 0194 (additive CREATE TABLE). Encryption-rotation registry and script cover the three new Bytes columns.
This commit is contained in:
1 parent
ee704cacab
commit
dcbac63fdf
20 files changed
+2162
-14
No files matched your search
@@ -32,6 +32,39 @@ describe("queryKeys factory", () => {
|
||||
expect(queryKeys.dashboardSnapshot()).toEqual(["dashboard", "snapshot"]);
|
||||
});
|
||||
|
||||
// v1.21.3 (b) — the snapshot key takes an optional `locale` segment so a
|
||||
// locale switch reads freshly-localised prose on its own cell. The zero-arg
|
||||
// call MUST stay byte-identical to the legacy literal so every prefix-based
|
||||
// invalidation bundle + zero-arg reader keeps prefix-matching the new cells.
|
||||
it("threads an optional locale segment through dashboardSnapshot", () => {
|
||||
expect(queryKeys.dashboardSnapshot("en")).toEqual([
|
||||
"dashboard",
|
||||
"snapshot",
|
||||
"en",
|
||||
]);
|
||||
expect(queryKeys.dashboardSnapshot("de")).toEqual([
|
||||
"dashboard",
|
||||
"snapshot",
|
||||
"de",
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps the zero-arg dashboardSnapshot call byte-identical to the legacy literal", () => {
|
||||
expect(queryKeys.dashboardSnapshot()).toEqual(["dashboard", "snapshot"]);
|
||||
expect(queryKeys.dashboardSnapshot(undefined)).toEqual([
|
||||
"dashboard",
|
||||
"snapshot",
|
||||
]);
|
||||
});
|
||||
|
||||
it("makes a zero-arg dashboardSnapshot key a prefix of a locale-keyed cell", () => {
|
||||
// TanStack `invalidateQueries({ queryKey })` matches by prefix, so a
|
||||
// zero-arg invalidate must reach every locale-keyed snapshot cell.
|
||||
const zeroArg = queryKeys.dashboardSnapshot();
|
||||
const localeKeyed = queryKeys.dashboardSnapshot("en");
|
||||
expect(localeKeyed.slice(0, zeroArg.length)).toEqual(zeroArg);
|
||||
});
|
||||
|
||||
it("threads the slim slice through queryKeys.analytics", () => {
|
||||
expect(queryKeys.analytics("summaries")).toEqual([
|
||||
"analytics",
|
||||
|
||||
Reference in new issue
Block a user