Skip to content

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.

  • 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.
  1. Service + CLI + unit tests
  2. scripts/verify-phi-crypto-health.ps1 (inline/SCP fallback for pre-image)
  3. Wire push-to-production.ps1 (Docker UAT) and deploy.ps1 (pre + post)
  4. Tighten production-phi-pin.ps1 when keys already set
  5. 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)”
GateStatus
PHI encrypt/decrypt + email_idxThis plan — hard fail
MFA key vs mfa_secretFollow-on
Stripe live/test key consistencyPartial (secrets audit)
Restore-to-dev PHI key matchDocumented warning only