mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 23:12:04 +00:00
feat: lay down the shared v1.42 contract
Land every file the v1.42 work shares before any of it is built, so the parts built side by side never edit the same file. Schema and migrations 0379-0386: the HEALTH_CONNECT measurement source, ImportJob.kind, the air-quality columns and the per-user switch on the environment tables, sealed environment locations with nullable plaintext, managed-profile handover links, the per-type HealthKit arrival ledger, lab unit-conversion provenance, and user-defined vaccines. Every new column is annotated for the column-reader sweep. HEALTH_CONNECT reaches every exhaustive list: the source labels, the read enum (not the write allowlist), the source-priority ladder cap, now the number of sources rather than a fixed eight, and the write-path smoke test. RMSSD gets its own priority class and a 300 ms ceiling. The batch syncTrigger gains `manual`, with its label on the Apple Health card. Queues for the Health Connect import, the compaction-tombstone purge and the measurement-table maintenance are registered with stub handlers; host-metric sampling moves to every five minutes. Environment and work_mem variables reach the compose whitelist, the production example and the manifest. The proxy admits the handover link and redirects it at the edge, and the Health Connect upload bypasses the proxy body limit. The new routes answer 501 behind their final authentication and are published in the contract; backup, wipe and key rotation classify the new models and columns; the seven message bundles carry the base copy. Guards that list release-pending keys and columns fail once an entry is wired, so those lists empty themselves before the tag. Also re-anchor a login-throttle fixture to the wall clock, where its expiry is compared, and re-base the aggregate bundle cap on a measured 12 KB of new locale strings.
This commit is contained in:
1 parent
125b15bfb7
commit
e63be67b5a
82 files changed
+5099
-727
No files matched your search
@@ -104,6 +104,8 @@ describe("DELETE /api/admin/data leaves nothing it promised to delete", () => {
|
||||
dateOfBirth: new Date("1990-01-01T00:00:00Z"),
|
||||
telegramBotToken: "secret-token",
|
||||
telegramEnabled: true,
|
||||
// Off, so the reset back to the default (on) is visible below.
|
||||
environmentAirQualityEnabled: false,
|
||||
locale: "en",
|
||||
unitPreference: "metric",
|
||||
},
|
||||
@@ -269,7 +271,12 @@ describe("DELETE /api/admin/data leaves nothing it promised to delete", () => {
|
||||
value === 0 ||
|
||||
(Array.isArray(value) && value.length === 0) ||
|
||||
value === "aggregated" ||
|
||||
value === "disconnected";
|
||||
value === "disconnected" ||
|
||||
// A column whose reset is a non-empty default (v1.42: the
|
||||
// air-quality switch resets to on) is cleared when it holds
|
||||
// exactly that default.
|
||||
(typeof value === "boolean" &&
|
||||
(USER_RESET as Record<string, unknown>)[column] === value);
|
||||
if (!cleared) stillSet.push(`${column} = ${JSON.stringify(value)}`);
|
||||
}
|
||||
expect(
|
||||
|
||||
@@ -3502,6 +3502,48 @@ const COLUMN_EXCLUSIONS: Readonly<Record<string, string>> = {
|
||||
"insert stamp of a symptom link; no reader, the illness day log's own timestamps travel",
|
||||
};
|
||||
|
||||
/**
|
||||
* Columns a release adds ahead of the backup ends that carry them, so the
|
||||
* packages built in parallel on its branch each own their own section of the
|
||||
* export and the restore. NOT an exclusion: each entry names the package that
|
||||
* carries it, and the companion assertion fails as soon as an entry's column
|
||||
* starts coming back, so the entry has to go in the change that carries it.
|
||||
* The list is empty again before the release is tagged.
|
||||
*/
|
||||
const ENVIRONMENT_V142 =
|
||||
"v1.42 (#615): the environment section carries the air-quality columns and the sealed location";
|
||||
const LABS_V142 =
|
||||
"v1.42 (#1095): the lab section carries the conversion provenance";
|
||||
const RELEASE_PENDING_COLUMNS: Readonly<Record<string, string>> = {
|
||||
"EnvironmentContext.aodMax": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.apparentMax": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.aqDomain": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.aqFetchedAt": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.aqHours": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.coMean": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.dustMax": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.eaqiMax": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.no2Mean": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.o3Max8h": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.pm10Mean": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.pm25Max": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.pm25Mean": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.pollenAlderMax": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.pollenBirchMax": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.pollenGrassMax": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.pollenMugwortMax": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.pollenOliveMax": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.pollenRagweedMax": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.so2Mean": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.usaqiMax": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.uvIndexMax": ENVIRONMENT_V142,
|
||||
"EnvironmentContext.locationEncrypted": ENVIRONMENT_V142,
|
||||
"EnvironmentTravelLocation.locationEncrypted": ENVIRONMENT_V142,
|
||||
"Biomarker.analyteKey": LABS_V142,
|
||||
"LabResult.sourceValue": LABS_V142,
|
||||
"LabResult.sourceUnit": LABS_V142,
|
||||
};
|
||||
|
||||
/**
|
||||
* Columns every reader parses through one function before using, compared
|
||||
* through that same function: the restore writes the parsed form.
|
||||
@@ -3915,11 +3957,15 @@ describe("every column of every two-ended model survives a real restore", () =>
|
||||
// data model that stopped being read.
|
||||
expect(compared).toBeGreaterThanOrEqual(620);
|
||||
expect(
|
||||
lost,
|
||||
lost.filter((key) => !(key in RELEASE_PENDING_COLUMNS)),
|
||||
"these columns left with a value and came back without it. Carry each " +
|
||||
"through the export and the restore, or name it in COLUMN_EXCLUSIONS " +
|
||||
"with the reason the restore is right to drop it",
|
||||
).toEqual([]);
|
||||
expect(
|
||||
Object.keys(RELEASE_PENDING_COLUMNS).filter((key) => !lost.includes(key)),
|
||||
"these RELEASE_PENDING_COLUMNS entries come back now — drop them",
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it("notices a column nobody told it about", () => {
|
||||
@@ -3958,6 +4004,7 @@ describe("every column of every two-ended model survives a real restore", () =>
|
||||
);
|
||||
const stale = [
|
||||
...Object.keys(COLUMN_EXCLUSIONS),
|
||||
...Object.keys(RELEASE_PENDING_COLUMNS),
|
||||
...Object.keys(READ_THROUGH),
|
||||
...Object.keys(FILL_OVERRIDES),
|
||||
].filter((key) => !known.has(key));
|
||||
|
||||
@@ -311,6 +311,28 @@ const SOURCE_CASES = {
|
||||
expect(verdict.status).toBe("inserted");
|
||||
},
|
||||
},
|
||||
// v1.42 — Health Connect rows enter through the import worker, which writes
|
||||
// each sample through the shared external-measurement reconciliation
|
||||
// service. Until the worker lands, the case drives that service directly,
|
||||
// the same narrowest production path the STRAVA case uses.
|
||||
HEALTH_CONNECT: {
|
||||
expectedType: "PULSE",
|
||||
expectedExternalId: "hc:source-smoke-health-connect",
|
||||
write: async () => {
|
||||
const verdict = await getPrismaClient().$transaction((tx) =>
|
||||
reconcileExternalMeasurement(tx, {
|
||||
userId: USER_ID,
|
||||
type: "PULSE",
|
||||
source: "HEALTH_CONNECT",
|
||||
value: 64,
|
||||
unit: "bpm",
|
||||
measuredAt: new Date("2026-07-20T08:13:00.000Z"),
|
||||
externalId: "hc:source-smoke-health-connect",
|
||||
}),
|
||||
);
|
||||
expect(verdict.status).toBe("inserted");
|
||||
},
|
||||
},
|
||||
// v1.38.x — the third-party ingest token. Written through the ordinary
|
||||
// single-entry POST, because that IS the production path: the route reads
|
||||
// the credential and resolves the source itself. The body names none — one
|
||||
@@ -405,9 +427,9 @@ describe("MeasurementSource write paths against real Postgres", () => {
|
||||
});
|
||||
}
|
||||
|
||||
expect(sourceCases).toHaveLength(15);
|
||||
expect(sourceCases).toHaveLength(16);
|
||||
expect(await prisma.measurement.count({ where: { userId: USER_ID } })).toBe(
|
||||
15,
|
||||
16,
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -102,6 +102,8 @@ describe("DELETE /api/settings/data leaves nothing it promised to delete", () =>
|
||||
fullName: "Seeded Name",
|
||||
insurerName: "Seeded Insurer",
|
||||
stravaAthleteId: "12345",
|
||||
// Off, so the reset back to the default (on) is visible below.
|
||||
environmentAirQualityEnabled: false,
|
||||
thresholdsJson: { sys: 130 },
|
||||
onboardingCompletedAt: new Date(),
|
||||
passwordHash: "argon2-placeholder",
|
||||
@@ -229,7 +231,11 @@ describe("DELETE /api/settings/data leaves nothing it promised to delete", () =>
|
||||
value === 0 ||
|
||||
(Array.isArray(value) && value.length === 0) ||
|
||||
value === "aggregated" ||
|
||||
value === "disconnected";
|
||||
value === "disconnected" ||
|
||||
// A column whose reset is a non-empty default (v1.42: the air-quality
|
||||
// switch resets to on) is cleared when it holds exactly that default.
|
||||
(typeof value === "boolean" &&
|
||||
(USER_RESET as Record<string, unknown>)[column] === value);
|
||||
if (!cleared) stillSet.push(`${column} = ${JSON.stringify(value)}`);
|
||||
}
|
||||
expect(
|
||||
|
||||
Reference in new issue
Block a user