mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
The export panel rendered twenty data switches and eight of them changed nothing. The grouped selection folded down to twelve flat flags and dropped oxygen saturation, body fat, body composition, resting heart rate, HRV, VO2 max, steps and distance on the way, so a user who switched any of them off still exported the readings in the PDF, in the FHIR bundle, in the package, through a clinician share link and over MCP. Each one now resolves to a flag the aggregator reads, and the rows are excluded at the query rather than fetched and dropped. Three more controls were untruthful in their own way: - The medications switch documented itself as excluding all medication data and excluded the adherence figures only. The drug list and the per-dose administration ledger rode along regardless. Both follow the switch now; the rows are still read, because compliance and the GLP-1 block are computed from them, and they no longer leave the aggregator. - Allergies and family history were gated for the PDF and fetched unconditionally for the FHIR bundle, so a package could carry a compliant PDF and a violating bundle in the same zip. The reads are gated, and a deselected section is not read at all. - The PHQ-9, GAD-7, WHO-5 and SCI screening totals had no per-report control. They rode the mental-health module alone, which has been default-on since v1.29.1, so depression and anxiety screeners reached FHIR bundles, share links and the MCP doctor-visit resource on accounts that never chose to send them. They get their own section key, defaulting off, with the module gate kept as the second lock, and the stale privacy-by-default comment that argued otherwise is corrected. The share link's FHIR promise is removed rather than implemented. The create form offered a toggle and a resource-type picker, the values were persisted and badged on the finished link, and the API description called the toggle a REST reachability switch, while no route has ever answered a share token with FHIR or any other machine-readable format. Serving one is a feature with real security surface and does not belong in a correctness fix. The toggle, the picker, the badge and both claims are gone; the create schema rejects the two keys instead of accepting and ignoring them; the columns stay, unread, so no data is destroyed to undo a promise. Two files are split along seams this change already touched. The measurement-type gating maps and the filter that reads them leave the aggregator for their own module, so the query gate and the output gate cannot disagree; the export panel's control shape and the selection it builds leave the component, so the selection contract can be extended without the rendering. Three accepted-and-discarded wire keys (activity energy, GLP-1, side effects) are dropped: nothing rendered them and nothing read them.
prisma/
The database layer. HealthLog runs PostgreSQL 16 via Prisma 7. This directory holds the single schema file and the forward-only migration history; the generated client is emitted elsewhere.
Contents
schema.prisma— 61 models, one file.cuid()primary keys,snake_casecolumns via@map(...), encrypted columns mostly suffixed*Encrypted(search the file; there are 24 encrypted column references). Thegenerator clientblock emits to../src/generated/prisma(imported as@/generated/prisma).migrations/— numbered, forward-only SQL migrations (0001_…upward).migration_lock.tomlpins the provider topostgresql.
Migration workflow
# author a migration from a schema edit
pnpm dlx prisma migrate dev --name <short_snake_case_name>
# regenerate the client after any schema change
pnpm dlx prisma generate
Number a new migration with the next free prefix. The production entrypoint runs prisma migrate deploy on boot, so every migration must apply cleanly forward — there is no down-migration path. Always include the migration file in the same change as the schema edit.
Conventions
- Encryption is fail-closed:
*Encryptedcolumns are written through@/lib/crypto(AES-256-GCM, versioned key ids); never store plaintext in an encrypted column. Key rotation isscripts/rotate-encryption-key.ts+docs/ops/encryption-key-rotation.md. - The generated client under
src/generated/prismais build output — do not edit it. - Schema-touching changes that affect the API surface must regenerate
docs/api/openapi.yaml(see../CLAUDE.md).
Related: ../src/lib/README.md (db.ts, rollups/), ../docs/ops/ (migrations + backup runbooks).