Skip to main content

17 Phase-4 Hard Rules

The HIPAA remediation plan (Spec 001 Phase 4) identified 17 high-risk anti-patterns and hardened the codebase against re-introduction. Each rule has:

  • A T-id (the remediation task that fixed it)
  • A compliance probe (in compliance-checklist.yml)
  • A path trigger (the source files that would regress it)
  • A CI gate (pre-edit hook + post-merge probe)
#RuleT-id / ProbePath that triggers the probe
1Service refuses start on placeholder secrets (FR-004a)T398 / p4_1apps/api/src/config/required-secrets.ts, apps/api/src/main.ts
2No DEV_BYPASS_AMR code pathT400 / p4_2apps/api/src/modules/auth/
3No hardcoded Epic OAuth secret fallbackT402 / p4_3apps/api/src/modules/ehr/
4Every $regex callsite uses escapeRegex()T403 / p4_4apps/api/src/modules/, escape-regex.ts
5Sign-out sweeps browser persistence + clipboardT404 / p4_5apps/web/src/lib/auth/signout-cleanup.ts
6BAA registry has all vendors for staging + prodT405 / p4_6apps/api/src/config/baa-registry.yml
7ML de-identification before LLM callT406 / p4_7apps/ml/services/deidentify.py
8CSP nonce reaches inline RSC scripts (FR-030)T407 / p4_8apps/web/src/middleware.ts, apps/web/src/app/layout.tsx
9No DLP_INTERCEPTOR_DISABLED code pathT408 / p4_9apps/api/src/common/dlp/
10LLM fallback emits audit event + HCP toast (FR-021a)T409 / p4_10apps/ml/services/llm_client.py, LLMFallbackToast.tsx
11MSAL cacheLocation: 'memoryStorage'T410 / p4_11apps/web/src/lib/auth/msal-config.ts
12Prompt-injection sanitizer covers G-01..G-20T411 / p4_12apps/ml/services/sanitize.py
13useIdleSignOut mounted on DashboardShell (FR-009h)T412 / p4_13apps/web/src/components/layout/
14Unknown KEK wrap alg throws in prod (FR-005g)T413 / p4_14apps/api/src/common/crypto/field-encryption.service.ts
15llm_call_logs metadata anonymized at 30d (FR-023e)T414 / p4_15apps/ml/services/llm_retention.py
16Phase-4 verification procedure doc currentT415 / p4_16docs/compliance/phase-4-verification-procedure.md
17Gitleaks full-history secret scan scheduledT399 / p4_17.github/workflows/secret-scan.yml
18Mongo client options via pure helperT401 / p4_18apps/api/src/config/mongodb.module.ts

How they're enforced

hipaa-phase-4-preflight

The mandatory before_plan + before_implement hook (.specify/extensions.yml, optional: false). Refuses implementation if:

  • Plan's § HIPAA Phase 4 Touchpoints section is missing
  • Any of the 17 rules has a blank row (must be YES or NO)
  • Any YES row doesn't name a task-id that exists in tasks.md

See /hipaa-phase-4-preflight.

hipaa-phase-verify

Run phase-exit verification for a named phase (1, 2, or 3):

  • Executes the phase's Success Criteria probes
  • Confirms brought-forward items (runbook, pen test, BAA registry)
  • Produces go/no-go report

Use before any phase-exit review. See /hipaa-phase-verify.

Full verification procedure

docs/compliance/phase-4-verification-procedure.md (authoritative) walks through each of the 17 rules + the probe command + expected output + rollback procedure.