Skip to content

Harden patient merge and migration safety - #219

Draft
evangauer wants to merge 2 commits into
mainfrom
codex/daily-driver-trust
Draft

Harden patient merge and migration safety#219
evangauer wants to merge 2 commits into
mainfrom
codex/daily-driver-trust

Conversation

@evangauer

Copy link
Copy Markdown
Owner

What changed

  • repair patient merges by retaining their atomic savepoint while removing an invalid nested transaction-isolation change
  • add real-Postgres coverage for successful merge convergence and rollback after an immutable-evidence failure
  • prove the application role cannot delete finalized SOAP records
  • verify committed migration ordering, SQL hashes, snapshot lineage, and the live Drizzle ledger before and after production/demo migrations

Why

A clinic patient merge could fail because the tenant transaction had already established its RLS context before the nested merge attempted to change transaction isolation. This fix keeps deterministic patient-row locking and the savepoint needed to prevent partial clinical or scheduling writes.

The additional migration and clinical-record checks make deployment fail closed before Dr. Jayne's production account can encounter an unexpected migration lineage or finalized-record deletion regression.

Impact

  • patient merges can complete without the PostgreSQL isolation-level error
  • mid-merge database failures roll all merge writes back
  • finalized SOAP history remains protected
  • production and demo migration workflows stop on journal, hash, lineage, or live-ledger mismatches

No production data, provider API, or clinic account was accessed or mutated while developing this change.

Validation

  • full web suite: 4,038 passed; 8 expected integration skips
  • final focused web run: 91 passed; 2 PostgreSQL integration tests intentionally CI-gated
  • web and database TypeScript checks passed
  • migration integrity contract and static artifact checks passed
  • Prettier, git diff check, and changed-file secret-pattern scan passed

The RLS CI job now runs the patient-merge integration test and live migration-ledger verifier against disposable PostgreSQL before this can be considered deployable.

@vercel

vercel Bot commented Aug 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openvpm-app Ready Ready Preview Aug 16, 2026 11:07pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
openvpm Ignored Ignored Preview Aug 16, 2026 11:07pm

Request Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant