mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-16 07:13:29 +00:00
Report every restored section, disclose export decrypt losses, re-fold on zone change
- The restore summary counts practitioners, encounters, the three link tables, and vaccinations — restored in full since 08-01 but absent from the report, so a file carrying visits or an Impfpass read as if those sections were empty. - A portable export that cannot open a field's ciphertext still nulls it fail-soft, but now names the loss in the file's own decryptFailures manifest — an export with a lost emergency note is no longer byte-identical to one where the note was never written. - A timezone change enqueues the medication-compliance re-fold: the rollup keys its rows by the local day minted under the OLD zone, and the coverage probe compares counts, not keys, so nothing else could notice the stale bucketing.
This commit is contained in:
1 parent
ac44b35867
commit
97cb63a77f
7 files changed
+237
No files matched your search
@@ -387,6 +387,51 @@ describe("backupPayloadSchema — v1.28 backup-completeness domains", () => {
|
||||
expect(summary.familyHistory).toBe(0);
|
||||
expect(summary.documents).toBe(0);
|
||||
});
|
||||
|
||||
// Watched red: with the v1.37.19 section counts removed from
|
||||
// `summarizeBackup` (the pre-fix shape stopped at healthScoreRecords),
|
||||
// every assertion below fails — a file carrying visits or an Impfpass
|
||||
// was restored in full but reported as if those sections were empty.
|
||||
it("summarizeBackup counts practitioners, encounters, links, and vaccinations", () => {
|
||||
const ts = "2026-05-08T07:00:00.000Z";
|
||||
const parsed = backupPayloadSchema.parse({
|
||||
schemaVersion: "1",
|
||||
exportedAt: ts,
|
||||
userId: "u1",
|
||||
practitioners: [
|
||||
{ id: "pr-1", name: "Praxis", createdAt: ts, updatedAt: ts },
|
||||
],
|
||||
encounters: [
|
||||
{
|
||||
id: "en-1",
|
||||
occurredAt: ts,
|
||||
status: "DONE",
|
||||
kind: "ROUTINE",
|
||||
createdAt: ts,
|
||||
updatedAt: ts,
|
||||
},
|
||||
],
|
||||
encounterDocumentLinks: [
|
||||
{ encounterId: "en-1", targetId: "doc-1", createdAt: ts },
|
||||
],
|
||||
encounterLabLinks: [
|
||||
{ encounterId: "en-1", targetId: "lab-1", createdAt: ts },
|
||||
],
|
||||
encounterConditionLinks: [],
|
||||
vaccinations: [
|
||||
{ id: "va-1", occurredAt: ts, createdAt: ts, updatedAt: ts },
|
||||
],
|
||||
vaccinationDocumentLinks: [
|
||||
{ vaccinationId: "va-1", targetId: "doc-1", createdAt: ts },
|
||||
],
|
||||
});
|
||||
const summary = summarizeBackup(parsed);
|
||||
expect(summary.practitioners).toBe(1);
|
||||
expect(summary.encounters).toBe(1);
|
||||
expect(summary.encounterLinks).toBe(2);
|
||||
expect(summary.vaccinations).toBe(1);
|
||||
expect(summary.vaccinationLinks).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("backupPayloadSchema — canonical v2 identity compatibility", () => {
|
||||
|
||||
@@ -1108,6 +1108,10 @@ export const backupPayloadSchema = z
|
||||
vaccinations: z.array(vaccinationBackupSchema).default([]),
|
||||
vaccinationDocumentLinks: z.array(vaccinationLinkBackupSchema).default([]),
|
||||
manifest: backupManifestSchema.nullable().default(null),
|
||||
// v1.37.19 (A6-9) — field paths a PORTABLE export could not decrypt
|
||||
// (fail-soft nulls). Disclosed in the file so a nulled field is
|
||||
// distinguishable from one never written. Empty/absent on DR payloads.
|
||||
decryptFailures: z.array(z.string()).default([]),
|
||||
})
|
||||
.passthrough()
|
||||
.superRefine((payload, ctx) => {
|
||||
@@ -1175,6 +1179,16 @@ export interface BackupSummary {
|
||||
intradayProfiles: number;
|
||||
/** Local days whose health score was written down as it was shown. */
|
||||
healthScoreRecords: number;
|
||||
/** v1.37.19 (A6-8) — the visit address book. */
|
||||
practitioners: number;
|
||||
/** v1.37.19 (A6-8) — doctor visits, planned and past. */
|
||||
encounters: number;
|
||||
/** v1.37.19 (A6-8) — the three encounter link tables, summed. */
|
||||
encounterLinks: number;
|
||||
/** v1.37.19 (A6-8) — immunization log entries. */
|
||||
vaccinations: number;
|
||||
/** v1.37.19 (A6-8) — vaccination↔document links. */
|
||||
vaccinationLinks: number;
|
||||
}
|
||||
|
||||
export function summarizeBackup(payload: BackupPayload): BackupSummary {
|
||||
@@ -1214,6 +1228,18 @@ export function summarizeBackup(payload: BackupPayload): BackupSummary {
|
||||
correlationPatterns: payload.correlationPatterns.length,
|
||||
intradayProfiles: payload.intradayProfiles.length,
|
||||
healthScoreRecords: payload.healthScoreRecords.length,
|
||||
// v1.37.19 (A6-8) — the sections restored since 08-01 were written and
|
||||
// restored but absent from this report, so the admin's "what did I just
|
||||
// restore" answer silently under-counted a file that carried visits or
|
||||
// an Impfpass.
|
||||
practitioners: payload.practitioners.length,
|
||||
encounters: payload.encounters.length,
|
||||
encounterLinks:
|
||||
payload.encounterDocumentLinks.length +
|
||||
payload.encounterLabLinks.length +
|
||||
payload.encounterConditionLinks.length,
|
||||
vaccinations: payload.vaccinations.length,
|
||||
vaccinationLinks: payload.vaccinationDocumentLinks.length,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user