mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 23:52:24 +00:00
refactor(insights): drop the readable cached-text column
Every write has gone to insights_cached_text_encrypted since 0411, and the boot-time free-text backfill sealed the rows written before it. Migration 0430 drops insights_cached_text and the backfill index that served it. A host that skipped the intervening releases loses only a cache of model output; the next warm writes a fresh, sealed payload. The cipher module now reads and writes the sealed column only, the backfill job loses its insights step, and consent withdrawal, the wipe plan, the backup plan and the session projection follow the schema. Backups never carried the column, and restore ignores unknown account settings; a round-trip test now proves an old backup naming the field still restores cleanly. The access guard pins exact counts for where the sealed name may appear. Fixtures, the demo seed and the demo migration script seed the sealed column instead of plaintext.
This commit is contained in:
1 parent
45da8ae971
commit
9941db1549
49 files changed
+381
-497
No files matched your search
@@ -536,6 +536,38 @@ describe("backup round trip — export, wire schema, restore", () => {
|
||||
expect(res.status).toBe(200);
|
||||
});
|
||||
|
||||
// Files written before v1.44.0 can name the readable insights cache the
|
||||
// release dropped (migration 0430), at the top level or among the account
|
||||
// settings. The column is gone, so the restore must neither fail on the name
|
||||
// nor try to write it.
|
||||
it("restores a file that still names the dropped readable insights cache", async () => {
|
||||
const { payload } = await buildFullBackupPayload(
|
||||
sourceClient() as never,
|
||||
OWNER,
|
||||
{ purpose: "disaster-recovery" },
|
||||
);
|
||||
const legacy: Record<string, unknown> = {
|
||||
...payload,
|
||||
insightsCachedText: JSON.stringify({ dailyBriefing: { p: "old" } }),
|
||||
accountSettings: {
|
||||
...((payload.accountSettings as Record<string, unknown> | null) ?? {}),
|
||||
insightsCachedText: JSON.stringify({ dailyBriefing: { p: "old" } }),
|
||||
},
|
||||
};
|
||||
|
||||
const { res, written } = await roundTrip({}, legacy);
|
||||
|
||||
expect(res.status).toBe(200);
|
||||
for (const w of written) {
|
||||
expect(
|
||||
Object.keys(w.data),
|
||||
`${w.model}.${w.op} must not write the dropped column`,
|
||||
).not.toContain("insightsCachedText");
|
||||
}
|
||||
// The rest of the file still lands.
|
||||
expect(written.some((w) => w.model === "userHealthProfile")).toBe(true);
|
||||
});
|
||||
|
||||
it("writes the durable self-context back with its ciphertext intact", async () => {
|
||||
const { written } = await roundTrip();
|
||||
|
||||
@@ -785,7 +817,7 @@ describe("backup round trip — export, wire schema, restore", () => {
|
||||
(w) =>
|
||||
w.model === "user" &&
|
||||
w.op === "update" &&
|
||||
"insightsCachedText" in w.data,
|
||||
"insightsCachedTextEncrypted" in w.data,
|
||||
);
|
||||
expect(
|
||||
userUpdate,
|
||||
@@ -794,7 +826,6 @@ describe("backup round trip — export, wire schema, restore", () => {
|
||||
// The language tag is cleared with the text: an empty slot carries
|
||||
// no language, and the next write tags it afresh.
|
||||
expect(userUpdate!.data).toEqual({
|
||||
insightsCachedText: null,
|
||||
insightsCachedTextEncrypted: null,
|
||||
insightsCachedAt: null,
|
||||
insightsCachedLocale: null,
|
||||
@@ -831,7 +862,7 @@ describe("backup round trip — export, wire schema, restore", () => {
|
||||
(w) =>
|
||||
w.model === "user" &&
|
||||
w.op === "update" &&
|
||||
"insightsCachedText" in w.data,
|
||||
"insightsCachedTextEncrypted" in w.data,
|
||||
);
|
||||
expect(
|
||||
userUpdate,
|
||||
|
||||
@@ -948,7 +948,6 @@ export const USER_COLUMN_BACKUP_CLASS = {
|
||||
|
||||
// ── Operational ───────────────────────────────────────────────────────────
|
||||
insightsCachedAt: "OPERATIONAL",
|
||||
insightsCachedText: "OPERATIONAL",
|
||||
insightsCachedTextEncrypted: "OPERATIONAL",
|
||||
insightsCachedLocale: "OPERATIONAL",
|
||||
insightsSnapshotHash: "OPERATIONAL",
|
||||
|
||||
Reference in new issue
Block a user