Files
HealthLog/tests/integration/__golden__/backup-parity/refusals.json
T
Marc-André Bombeck f75337e6f2 feat(measurements): record blood ketones and show the glucose-ketone index (#1367)
Ketones had to live in a custom metric, with the glucose-ketone index typed
in by hand beside it, where it drifted from the readings it came from.

- Type: BLOOD_KETONES (beta-hydroxybutyrate, mmol/L, migration 0496),
  plausible from 0 to 10: the blood ketone meters read 0.0 to 8.0 and print
  HI above it, and a venous value off a lab sheet fits under 10. Zero is a
  real reading. No band, no direction, no personal record, off the Coach
  snapshot and the correlations; readable over MCP and owned by the glucose
  module like glucose.
- Entry: choosing blood ketones in the measurement form also takes the
  glucose from the same fingerstick, in the account's glucose unit. Both
  rows go through the array arm of POST /api/measurements with one
  timestamp, so they land in one transaction or not at all.
- Index: glucose (mg/dL / 18.0182, the tree's one factor) over ketones,
  computed at read time and never stored. Each ketone reading above zero
  pairs with the glucose reading at the same instant, else the nearest one
  within 15 minutes either side; a tie goes to the same source, then to the
  earlier reading. Nothing pairs across a wider gap.
- Surfaces: GET /api/measurements/series takes kind=ketones and
  kind=glucoseKetoneIndex (each point names the paired readings), and the
  day carries glucoseKetoneIndex when both reading types are visible. The
  new Ketones page charts the readings with the index beneath; the day view
  shows the index beside the value tiles; the doctor report, its PDF and the
  clinician share print it in the glucose group when both leaves are chosen,
  since beside the ketones it gives the glucose back.
- FHIR: ketone readings export under LOINC 104816-4 (Beta hydroxybutyrate
  [Moles/volume] in Blood). The index is left out: it has no LOINC term,
  and both readings it is built from are in the bundle.
- The measurement form's action row moved into its own component to keep
  the form inside its size budget.

OpenAPI regenerated; all ten locales; the import unit table lists the type.
2026-11-10 19:28:57 +01:00

807 lines
22 KiB
JSON

{
"undecryptable": {
"outcome": {
"ok": false,
"status": 422,
"code": "backup.payload.undecryptable",
"message": "Backup payload could not be decrypted — either the key that wrote this copy is no longer in ENCRYPTION_KEYS, or the stored copy is not the one that was written. Nothing was changed.",
"meta": {
"errorCode": "backup.payload.undecryptable"
}
},
"progress": [
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": null
}
],
"audit": [
{
"action": "admin.backups.restore.failed",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"reason": "Invalid authentication tag length: 7"
}
}
],
"effects": {
"invalidated": [],
"unitRefresh": [],
"foldRepair": [],
"annotations": [
{
"action": {
"name": "admin.backups.restore"
},
"meta": {
"id": "<id:1>",
"restore_instance_settings": false
}
}
]
}
},
"schemaInvalid": {
"outcome": {
"ok": false,
"status": 422,
"code": "schema_invalid",
"message": "Backup payload failed schema validation"
},
"progress": [
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": null
}
],
"audit": [
{
"action": "admin.backups.restore.failed",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"reason": "schema_invalid",
"message": "measurements.0.type: Invalid option: expected one of \"WEIGHT\"|\"BLOOD_PRESSURE_SYS\"|\"BLOOD_PRESSURE_DIA\"|\"PULSE\"|\"BODY_FAT\"|\"SLEEP_DURATION\"|\"ACTIVITY_STEPS\"|\"BLOOD_GLUCOSE\"|\"TOTAL_BODY_WATER\"|\"BONE_MASS\"|\"OXYGEN_SATURATION\"|\"HEART_RATE_VARIABILITY\"|\"RESTING_HEART_RATE\"|\"ACTIVE_ENERGY_BURNED\"|\"FLIGHTS_CLIMBED\"|\"WALKING_RUNNING_DISTANCE\"|\"VO2_MAX\"|\"BODY_TEMPERATURE\"|\"FAT_FREE_MASS\"|\"FAT_MASS\"|\"MUSCLE_MASS\"|\"SKIN_TEMPERATURE\"|\"PULSE_WAVE_VELOCITY\"|\"VASCULAR_AGE\"|\"VISCERAL_FAT\"|\"AUDIO_EXPOSURE_ENV\"|\"AUDIO_EXPOSURE_HEADPHONE\"|\"TIME_IN_DAYLIGHT\"|\"WALKING_STEADINESS\"|\"AUDIO_EXPOSURE_EVENT\"|\"RESPIRATORY_RATE\"|\"BODY_MASS_INDEX\"|\"LEAN_BODY_MASS\"|\"WALKING_HEART_RATE_AVERAGE\"|\"WALKING_ASYMMETRY\"|\"WALKING_DOUBLE_SUPPORT\"|\"WALKING_STEP_LENGTH\"|\"WALKING_SPEED\"|\"CARDIO_RECOVERY\"|\"WRIST_TEMPERATURE\"|\"FALL_COUNT\"|\"SIX_MINUTE_WALK_DISTANCE\"|\"STAIR_ASCENT_SPEED\"|\"STAIR_DESCENT_SPEED\"|\"BREATHING_DISTURBANCES\"|\"IRREGULAR_RHYTHM_NOTIFICATION\"|\"HIGH_HEART_RATE_EVENT\"|\"LOW_HEART_RATE_EVENT\"|\"WALKING_STEADINESS_EVENT\"|\"BREATHING_DISTURBANCE_EVENT\"|\"RECOVERY_SCORE\"|\"STRESS_SCORE\"|\"STRAIN_SCORE\"|\"HRV_RMSSD\"|\"DAY_STRAIN\"|\"WORKOUT_STRAIN\"|\"SLEEP_PERFORMANCE\"|\"SLEEP_EFFICIENCY\"|\"SLEEP_CONSISTENCY\"|\"SLEEP_NEED\"|\"ENERGY_EXPENDITURE_KJ\"|\"AVERAGE_HEART_RATE\"|\"MAX_HEART_RATE\"|\"SLEEP_DISTURBANCE_COUNT\"|\"ANS_CHARGE\"|\"CARDIO_LOAD\"|\"SLEEP_SCORE\"|\"BODY_TEMPERATURE_DEVIATION\"|\"RESILIENCE\"|\"PHQ9_SCORE\"|\"GAD7_SCORE\"|\"GRIP_STRENGTH\"|\"PAIN_NRS\"|\"WAIST_CIRCUMFERENCE\"|\"WAIST_TO_HEIGHT\"|\"WHO5_SCORE\"|\"SCI_SCORE\"|\"EXERCISE_MINUTES\"|\"STAND_MINUTES\"|\"STAND_HOURS\"|\"MINDFUL_MINUTES\"|\"STATE_OF_MIND_VALENCE\"|\"INDOOR_CO2\"|\"INDOOR_TEMPERATURE\"|\"INDOOR_HUMIDITY\"|\"AFIB_BURDEN\"|\"BODY_BATTERY\"|\"STRESS_LEVEL\"|\"TRAINING_READINESS\"|\"ACUTE_TRAINING_LOAD\"|\"BASAL_ENERGY_BURNED\"|\"BLOOD_KETONES\""
}
}
],
"effects": {
"invalidated": [],
"unitRefresh": [],
"foldRepair": [],
"annotations": [
{
"action": {
"name": "admin.backups.restore"
},
"meta": {
"id": "<id:1>",
"restore_instance_settings": false
}
}
]
}
},
"stableIdMissing": {
"outcome": {
"ok": false,
"status": 422,
"code": "schema_invalid",
"message": "Backup payload failed schema validation"
},
"progress": [
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": null
}
],
"audit": [
{
"action": "admin.backups.restore.failed",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"reason": "schema_invalid",
"message": "measurements.0.id: Canonical v2 measurements require a stable id"
}
}
],
"effects": {
"invalidated": [],
"unitRefresh": [],
"foldRepair": [],
"annotations": [
{
"action": {
"name": "admin.backups.restore"
},
"meta": {
"id": "<id:1>",
"restore_instance_settings": false
}
}
]
}
},
"qualitativeMarkerWithNumbers": {
"outcome": {
"ok": false,
"status": 422,
"code": "schema_invalid",
"message": "Backup payload failed schema validation"
},
"progress": [
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": null
},
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
}
],
"audit": [
{
"action": "admin.backups.restore.failed",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"reason": "schema_invalid",
"message": "[\n {\n \"code\": \"custom\",\n \"path\": [\n \"labResults\",\n 0,\n \"unit\"\n ],\n \"message\": \"A numeric lab reading needs its unit\"\n },\n {\n \"code\": \"custom\",\n \"path\": [\n \"biomarkers\",\n 0,\n \"unit\"\n ],\n \"message\": \"Biomarker \\\"Urine colour\\\" has numeric readings and needs its unit\"\n }\n]"
}
}
],
"effects": {
"invalidated": [],
"unitRefresh": [],
"foldRepair": [],
"annotations": [
{
"action": {
"name": "admin.backups.restore"
},
"meta": {
"id": "<id:1>",
"restore_instance_settings": false
}
}
]
}
},
"incompatibleVersion": {
"outcome": {
"ok": false,
"status": 422,
"code": "incompatible_schema_version",
"message": "Backup schema version '99' is not supported by this server"
},
"progress": [
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": null
},
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
}
],
"audit": [
{
"action": "admin.backups.restore.failed",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"reason": "incompatible_schema_version",
"schemaVersion": "99"
}
}
],
"effects": {
"invalidated": [],
"unitRefresh": [],
"foldRepair": [],
"annotations": [
{
"action": {
"name": "admin.backups.restore"
},
"meta": {
"id": "<id:1>",
"restore_instance_settings": false
}
}
]
}
},
"ownerMismatch": {
"outcome": {
"ok": false,
"status": 409,
"code": "owner_mismatch",
"message": "Backup payload declares a different owner than the backup record"
},
"progress": [
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": null
},
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
}
],
"audit": [
{
"action": "admin.backups.restore.failed",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"reason": "owner_mismatch",
"declaredOwnerId": "someone-else"
}
}
],
"effects": {
"invalidated": [],
"unitRefresh": [],
"foldRepair": [],
"annotations": [
{
"action": {
"name": "admin.backups.restore"
},
"meta": {
"id": "<id:1>",
"restore_instance_settings": false
}
}
]
}
},
"sectionMissing": {
"outcome": {
"ok": false,
"status": 422,
"code": "backup.section.missing",
"message": "Backup is missing documents — the file's own manifest says it carries that section. Nothing was changed. Use a disaster-recovery snapshot, or export the account again.",
"meta": {
"errorCode": "backup.section.missing",
"sections": [
"documents"
]
}
},
"progress": [
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": null
},
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
}
],
"audit": [
{
"action": "admin.backups.restore.start",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"ownerUsername": "round-trip-owner",
"snapshotExportedAt": "2026-07-20T08:00:00.000Z",
"restoreInstanceSettings": false
}
},
{
"action": "admin.backups.restore.failed",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"reason": "section_missing",
"sections": [
"documents"
]
}
}
],
"effects": {
"invalidated": [],
"unitRefresh": [],
"foldRepair": [],
"annotations": [
{
"action": {
"name": "admin.backups.restore"
},
"meta": {
"id": "<id:1>",
"restore_instance_settings": false
}
}
]
}
},
"metadataOnlyDocument": {
"outcome": {
"ok": false,
"status": 422,
"code": "document_ciphertext_missing",
"message": "Document 'metadata-only-document' is metadata-only and cannot be restored"
},
"progress": [
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": null
},
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
}
],
"audit": [
{
"action": "admin.backups.restore.start",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"ownerUsername": "round-trip-owner",
"snapshotExportedAt": "2026-07-20T08:00:00.000Z",
"restoreInstanceSettings": false
}
},
{
"action": "admin.backups.restore.failed",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"reason": "document_ciphertext_missing",
"documentId": "metadata-only-document"
}
}
],
"effects": {
"invalidated": [],
"unitRefresh": [],
"foldRepair": [],
"annotations": [
{
"action": {
"name": "admin.backups.restore"
},
"meta": {
"id": "<id:1>",
"restore_instance_settings": false
}
}
]
}
},
"keyMissing": {
"outcome": {
"ok": false,
"status": 422,
"code": "backup.key.missing",
"message": "This backup holds 1 encrypted value written under encryption key 'v9', which is not in ENCRYPTION_KEYS on this server. Add that key back to ENCRYPTION_KEYS and restart, then try again. Nothing was changed.",
"meta": {
"errorCode": "backup.key.missing",
"keyIds": [
"v9"
]
}
},
"progress": [
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": null
},
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 1
}
],
"audit": [
{
"action": "admin.backups.restore.failed",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"reason": "key_missing",
"missingKeyIds": [
"v9"
],
"unreadableKeyIds": [],
"affectedValues": 1
}
}
],
"effects": {
"invalidated": [],
"unitRefresh": [],
"foldRepair": [],
"annotations": [
{
"action": {
"name": "admin.backups.restore"
},
"meta": {
"id": "<id:1>",
"restore_instance_settings": false
}
}
]
}
},
"intakeForUnknownMedication": {
"outcome": {
"ok": false,
"status": 500,
"code": "transaction_failed",
"message": "The restore could not be written and was rolled back. Nothing was changed.",
"meta": {
"cause": "other"
}
},
"progress": [
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": null
},
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "clearing",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "measurements",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "sections",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
}
],
"audit": [
{
"action": "admin.backups.restore.start",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"ownerUsername": "round-trip-owner",
"snapshotExportedAt": "2026-07-20T08:00:00.000Z",
"restoreInstanceSettings": false
}
},
{
"action": "admin.backups.restore.failed",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"reason": "transaction_failed",
"cause": "other",
"code": null,
"message": "Unknown medication references in intake events: a medication this file never carried. The backup records doses against medications it does not carry."
}
}
],
"effects": {
"invalidated": [],
"unitRefresh": [],
"foldRepair": [],
"annotations": [
{
"action": {
"name": "admin.backups.restore"
},
"meta": {
"id": "<id:1>",
"restore_instance_settings": false
}
},
{
"meta": {
"restoreFailReason": "Unknown medication references in intake events: a medication this file never carried. The backup records doses against medications it does not carry.",
"restoreFailCause": "other",
"restoreFailCode": null,
"restoreTransactionTimeoutMs": 120001
}
}
]
}
},
"labForUnknownMarker": {
"outcome": {
"ok": false,
"status": 500,
"code": "transaction_failed",
"message": "The restore could not be written and was rolled back. Nothing was changed.",
"meta": {
"cause": "other"
}
},
"progress": [
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": null
},
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "clearing",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "measurements",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "sections",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "sections",
"sectionsDone": 1,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "sections",
"sectionsDone": 2,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "sections",
"sectionsDone": 3,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "sections",
"sectionsDone": 4,
"sectionsTotal": 17,
"measurementsTotal": 0
}
],
"audit": [
{
"action": "admin.backups.restore.start",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"ownerUsername": "round-trip-owner",
"snapshotExportedAt": "2026-07-20T08:00:00.000Z",
"restoreInstanceSettings": false
}
},
{
"action": "admin.backups.restore.failed",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"reason": "transaction_failed",
"cause": "other",
"code": null,
"message": "Unknown biomarker reference: a-marker-the-file-never-carried"
}
}
],
"effects": {
"invalidated": [],
"unitRefresh": [],
"foldRepair": [],
"annotations": [
{
"action": {
"name": "admin.backups.restore"
},
"meta": {
"id": "<id:1>",
"restore_instance_settings": false
}
},
{
"meta": {
"restoreFailReason": "Unknown biomarker reference: a-marker-the-file-never-carried",
"restoreFailCause": "other",
"restoreFailCode": null,
"restoreTransactionTimeoutMs": 120001
}
}
]
}
},
"illnessWithUnknownParent": {
"outcome": {
"ok": false,
"status": 500,
"code": "transaction_failed",
"message": "The restore could not be written and was rolled back. Nothing was changed.",
"meta": {
"cause": "other"
}
},
"progress": [
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": null
},
{
"phase": "validating",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "clearing",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "measurements",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "sections",
"sectionsDone": 0,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "sections",
"sectionsDone": 1,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "sections",
"sectionsDone": 2,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "sections",
"sectionsDone": 3,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "sections",
"sectionsDone": 4,
"sectionsTotal": 17,
"measurementsTotal": 0
},
{
"phase": "sections",
"sectionsDone": 5,
"sectionsTotal": 17,
"measurementsTotal": 0
}
],
"audit": [
{
"action": "admin.backups.restore.start",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"ownerUsername": "round-trip-owner",
"snapshotExportedAt": "2026-07-20T08:00:00.000Z",
"restoreInstanceSettings": false
}
},
{
"action": "admin.backups.restore.failed",
"userId": "<actor>",
"details": {
"backupId": "<id:1>",
"ownerId": "round-trip-owner",
"reason": "transaction_failed",
"cause": "other",
"code": null,
"message": "Unknown illness parent: an-episode-the-file-never-carried"
}
}
],
"effects": {
"invalidated": [],
"unitRefresh": [],
"foldRepair": [],
"annotations": [
{
"action": {
"name": "admin.backups.restore"
},
"meta": {
"id": "<id:1>",
"restore_instance_settings": false
}
},
{
"meta": {
"restoreFailReason": "Unknown illness parent: an-episode-the-file-never-carried",
"restoreFailCause": "other",
"restoreFailCode": null,
"restoreTransactionTimeoutMs": 120001
}
}
]
}
}
}