mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 07:42:23 +00:00
Merge branch 'fix/v1437-data' into release/v1.43.7
This commit is contained in:
commit
dee6a27ae4
100 files changed
+2314
-506
No files matched your search
@@ -0,0 +1,26 @@
|
||||
-- The cached AI insights payload moves to AES-256-GCM at rest.
|
||||
--
|
||||
-- `users.insights_cached_text` held the model's last full reading of the
|
||||
-- account in the clear: the daily briefing, the per-domain status text and the
|
||||
-- recommendations. It was the last readable column of that kind on the user
|
||||
-- row. From this release every write goes to `insights_cached_text_encrypted`
|
||||
-- (binary layout, purpose-bound label) and leaves the readable column NULL.
|
||||
--
|
||||
-- SQL cannot encrypt, so this migration only adds the ciphertext column and
|
||||
-- the discovery index. The boot-time `free-text-encryption-backfill` job seals
|
||||
-- the existing rows one at a time and nulls the readable value in the same
|
||||
-- transaction; it is fail-closed, so a missing or malformed key leaves the row
|
||||
-- untouched and the job retries. Readers fall back to the readable column until
|
||||
-- the backfill has reached a row. The readable column is dropped in a later
|
||||
-- release, once the backfill reports nothing left on every instance.
|
||||
--
|
||||
-- Additive only: no table rewrite, no data change.
|
||||
|
||||
ALTER TABLE "users" ADD COLUMN "insights_cached_text_encrypted" BYTEA;
|
||||
|
||||
-- Partial index on exactly the backfill's discovery predicate, so the boot
|
||||
-- scan is index-only and shrinks to nothing as the backfill converges (the
|
||||
-- 0357 precedent).
|
||||
CREATE INDEX IF NOT EXISTS "users_insights_cached_text_backfill_idx"
|
||||
ON "users" ("id")
|
||||
WHERE "insights_cached_text" IS NOT NULL;
|
||||
+12
-1
@@ -136,7 +136,18 @@ model User {
|
||||
useCentralCodex Boolean @default(false) @map("use_central_codex")
|
||||
insightsPrivacyMode String @default("aggregated") @map("insights_privacy_mode") // "aggregated" | "raw"
|
||||
insightsCachedAt DateTime? @map("insights_cached_at")
|
||||
insightsCachedText String? @map("insights_cached_text") // cached JSON output
|
||||
/// @internal: legacy plaintext cache of the AI insights payload, read only
|
||||
/// as a fallback for rows the free-text encryption backfill has not reached
|
||||
/// yet (v1.43.7). Every write since then goes to `insightsCachedTextEncrypted`
|
||||
/// and leaves this NULL; the backfill seals and nulls it on the old rows.
|
||||
/// DROP this column in a later release, once the backfill reports zero
|
||||
/// remaining rows on every instance.
|
||||
insightsCachedText String? @map("insights_cached_text")
|
||||
/// v1.43.7 — the cached AI insights payload (briefing, per-domain readings,
|
||||
/// recommendations; JSON), AES-256-GCM binary layout under
|
||||
/// `INSIGHTS_CACHED_TEXT_AAD`. Read and written only through
|
||||
/// `src/lib/insights/cached-text-cipher.ts`.
|
||||
insightsCachedTextEncrypted Bytes? @map("insights_cached_text_encrypted")
|
||||
// Language the cached text was generated in. The cache is one slot per
|
||||
// user, so a reader in another language must not be served it: the
|
||||
// snapshot briefing lift and the advisor read treat a tag that differs
|
||||
|
||||
Reference in new issue
Block a user