PHI crypto release gate — Implementation Plan
For agentic workers: Implement task-by-task; wire hard-fail into the existing promotion path.
Version: 1.0
Last Updated: 2026-07-20 11:51:34
Goal: Hard-block production release when PHI encryption keys cannot decrypt durable ciphertext (availability + Terms / operator-blindness integrity).
Architecture: Pure health check in services/phi_crypto_health.py (counts only, no PHI in output). CLI under backend/tools/. PowerShell wrapper invoked from Docker UAT (push-to-production.ps1) and VPS pre/post redeploy (deploy.ps1). CI covers the checker with synthetic ciphertext.
Tech Stack: Python 3.12, psycopg async, Fernet MultiFernet, PowerShell deploy scripts.
Global Constraints
Section titled “Global Constraints”- Never print plaintext PHI, ciphertext, or raw key material.
- Exit code 0 = healthy; non-zero = block release.
- Do not auto-re-encrypt during deploy; repair is a separate deliberate operator action.
- Presence of
PHI_*env vars is insufficient — decrypt proof is required.
- Service + CLI + unit tests
-
scripts/verify-phi-crypto-health.ps1(inline/SCP fallback for pre-image) - Wire
push-to-production.ps1(Docker UAT) anddeploy.ps1(pre + post) - Tighten
production-phi-pin.ps1when keys already set - Document in doc 11, doc 20 §6.4 / §2b, Phase-I checklist, runbook
Verified 2026-07-20: unit tests 6/6; VPS gate PASS; local lyncareos_dev PASS after index repair. Docker UAT may FAIL until its volume ciphertext matches compose PHI keys — that is intentional hard-fail.
Config ↔ durable state register (doc 11)
Section titled “Config ↔ durable state register (doc 11)”| Gate | Status |
|---|---|
| PHI encrypt/decrypt + email_idx | This plan — hard fail |
MFA key vs mfa_secret | Follow-on |
| Stripe live/test key consistency | Partial (secrets audit) |
| Restore-to-dev PHI key match | Documented warning only |