mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 07:42:23 +00:00
refactor(backup): let the account-settings domain own the User column verdicts
The SETTING verdicts are now the keys of the codec table, so a column becomes a setting by getting a codec and nothing else has to name it. The verdicts for every other User column move beside it into account-settings-classes.ts, and the restore half into account-settings-restore.ts. The backup plan keeps the model verdicts. The classification guard now also refuses a column that has both a codec and another verdict, since the composed table would quietly carry it as a setting.
This commit is contained in:
1 parent
66f8b18cf8
commit
dcf49dd14e
11 files changed
+329
-340
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$comment": "Production files over 800 lines and their length. Maintained by src/__tests__/source-size-ratchet.test.ts.",
|
||||
"count": 129,
|
||||
"total": 156466,
|
||||
"total": 156231,
|
||||
"entries": {
|
||||
"app/api/dashboard/summary/route.ts": 1032,
|
||||
"app/api/documents/inbound/route.ts": 811,
|
||||
@@ -68,7 +68,7 @@
|
||||
"lib/dashboard/snapshot.ts": 1549,
|
||||
"lib/day/records.ts": 1175,
|
||||
"lib/doctor-report/collect.ts": 803,
|
||||
"lib/export/backup-plan.ts": 1089,
|
||||
"lib/export/backup-plan.ts": 854,
|
||||
"lib/export/coach-backup.ts": 1070,
|
||||
"lib/export/full-backup-payload.ts": 1520,
|
||||
"lib/export/profile-backup.ts": 1019,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"$comment": "Comment lines that open with a release version, per file under src/. Maintained by src/__tests__/version-stamp-ratchet.test.ts.",
|
||||
"count": 2962,
|
||||
"total": 10592,
|
||||
"total": 10588,
|
||||
"entries": {
|
||||
"__tests__/account-payload-consumer-guard.test.ts": 2,
|
||||
"__tests__/acting-account-boundary-guard.test.ts": 7,
|
||||
@@ -2042,7 +2042,7 @@
|
||||
"lib/export/__tests__/records-backup.test.ts": 2,
|
||||
"lib/export/__tests__/restore-backup-round-trip.test.ts": 1,
|
||||
"lib/export/account-settings-backup.ts": 2,
|
||||
"lib/export/backup-plan.ts": 13,
|
||||
"lib/export/backup-plan.ts": 9,
|
||||
"lib/export/coach-backup.ts": 13,
|
||||
"lib/export/full-backup-payload.ts": 8,
|
||||
"lib/export/intraday-profile-backup.ts": 1,
|
||||
|
||||
@@ -25,7 +25,7 @@ const SEALED_ALLOWED: Readonly<Record<string, string>> = {
|
||||
"lib/insights/cached-text-cipher.ts": "the one module that owns the column",
|
||||
"lib/crypto/encrypted-columns.ts":
|
||||
"the registry of every ciphertext-bearing column",
|
||||
"lib/export/backup-plan.ts":
|
||||
"lib/export/account-settings-classes.ts":
|
||||
"the backup classification names every User column",
|
||||
"lib/data-wipe/wipe-plan.ts": "the wipe reset names every User column",
|
||||
};
|
||||
|
||||
@@ -5,8 +5,10 @@
|
||||
* The account row mixes the person's choices with sign-in credentials,
|
||||
* provider keys, the operator's policy for the account and the host's own
|
||||
* cursors, so it cannot have one verdict the way a model does. A column added
|
||||
* tomorrow has to land in `USER_COLUMN_BACKUP_CLASS` (`src/lib/export/
|
||||
* backup-plan.ts`) or this fails naming it: a new preference that silently
|
||||
* tomorrow gets a verdict in the account-settings domain — a codec in
|
||||
* `src/lib/export/account-settings-backup.ts` makes it a setting, an entry in
|
||||
* `src/lib/export/account-settings-classes.ts` gives it any other verdict —
|
||||
* or this fails naming it: a new preference that silently
|
||||
* stays behind on a restore, or a new secret that silently rides along in
|
||||
* every backup file, are the two failures this exists to stop.
|
||||
*
|
||||
@@ -17,8 +19,11 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { parseWipeSchema } from "@/__tests__/helpers/wipe-schema-shape";
|
||||
import { USER_COLUMN_BACKUP_CLASS } from "@/lib/export/backup-plan";
|
||||
import { ACCOUNT_SETTING_COLUMNS } from "@/lib/export/account-settings-backup";
|
||||
import {
|
||||
ACCOUNT_SETTING_COLUMNS,
|
||||
USER_COLUMN_BACKUP_CLASS,
|
||||
} from "@/lib/export/account-settings-backup";
|
||||
import { USER_COLUMNS_OUTSIDE_SETTINGS } from "@/lib/export/account-settings-classes";
|
||||
|
||||
const columns = parseWipeSchema().get("User")?.scalars ?? [];
|
||||
const classified = USER_COLUMN_BACKUP_CLASS as Readonly<Record<string, string>>;
|
||||
@@ -31,9 +36,9 @@ describe("User column backup classification", () => {
|
||||
expect(
|
||||
unclassified,
|
||||
"these User columns have no backup verdict. Add each to " +
|
||||
"USER_COLUMN_BACKUP_CLASS as SETTING, CREDENTIAL, IDENTITY or " +
|
||||
"OPERATIONAL, and if it is a SETTING give it a codec in " +
|
||||
"account-settings-backup.ts",
|
||||
"account-settings-classes.ts as CREDENTIAL, IDENTITY or " +
|
||||
"OPERATIONAL, or give it a codec in account-settings-backup.ts, " +
|
||||
"which makes it a SETTING",
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -42,6 +47,17 @@ describe("User column backup classification", () => {
|
||||
expect(Object.keys(classified).filter((c) => !known.has(c))).toEqual([]);
|
||||
});
|
||||
|
||||
it("gives no column both a codec and another verdict", () => {
|
||||
// The composed table spreads the settings over the other verdicts, so a
|
||||
// column in both would silently travel as a setting.
|
||||
expect(ACCOUNT_SETTING_COLUMNS.length).toBeGreaterThan(50);
|
||||
expect(
|
||||
ACCOUNT_SETTING_COLUMNS.filter((column) =>
|
||||
Object.hasOwn(USER_COLUMNS_OUTSIDE_SETTINGS, column),
|
||||
),
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it("carries exactly the columns classified as settings", () => {
|
||||
expect([...ACCOUNT_SETTING_COLUMNS].sort()).toEqual(
|
||||
Object.entries(classified)
|
||||
|
||||
Reference in new issue
Block a user