// Canonical Fase 1–5 + ESK 6.1 compliance fixture for the Rust↔Python
// golden-IR parity gate. Every language-level primitive from the plan
// appears at least once so a byte-identical diff across runtimes is a
// non-trivial signal.
//
// DO NOT edit this file casually — it is snapshotted against both Python
// and Rust IR generators. Any legitimate change must regenerate both
// goldens in tests/parity/.

type PatientRecord compliance [HIPAA, GDPR] {
  id:   String
  ssn:  String
}

type ClinicalTrial compliance [HIPAA, GxP] {
  trial_id:       String
  participant_id: String
}

flow SummarizeRecord(id: String) -> PatientRecord {
  step Review {
    ask: "Summarize"
    output: PatientRecord
  }
}

shield PHIShield {
  scan:      [prompt_injection, pii_leak]
  on_breach: quarantine
  severity:  critical
  redact:    [ssn]
  compliance: [HIPAA, GDPR, SOC2]
}

axonendpoint PatientAPI {
  method:  POST
  path:    "/patients"
  body:    PatientRecord
  execute: SummarizeRecord
  output:  FlowEnvelope<PatientRecord>
  shield:  PHIShield
  compliance: [HIPAA, GDPR]
}

resource Ehr { kind: postgres endpoint: "ehr.internal:5432" lifetime: linear }
resource Cache { kind: redis lifetime: affine }

fabric ClinicalCloud { provider: aws region: "us-east-1" zones: 3 }

manifest Prod {
  resources: [Ehr, Cache]
  fabric:    ClinicalCloud
  region:    "us-east-1"
  zones:     3
  compliance: [HIPAA, GDPR, SOC2]
}

observe Health from Prod {
  sources:         [prometheus, cloudwatch, healthcheck]
  quorum:          2
  timeout:         5s
  on_partition:    fail
  certainty_floor: 0.95
}

reconcile Reconciler {
  observe:     Health
  threshold:   0.9
  tolerance:   0.05
  on_drift:    provision
  max_retries: 5
}

lease EhrWrite {
  resource:  Ehr
  duration:  30m
  acquire:   on_demand
  on_expire: release
}

observe CacheHealth from Prod {
  sources: [cw2]
  quorum:  1
}

ensemble ClusterTruth {
  observations:   [Health, CacheHealth]
  quorum:         2
  aggregation:    byzantine
  certainty_mode: harmonic
}

session DbSession {
  client: [send Query, receive Result, end]
  server: [receive Query, send Result, end]
}

topology ProdTopology {
  nodes: [Ehr, Cache, ClinicalCloud, Prod, Health]
  edges: [Health -> Ehr : DbSession]
}

immune Vigil {
  watch:       [Health]
  sensitivity: 0.85
  scope:       tenant
  tau:         60s
}

reflex QuarantineBurst {
  trigger:  Vigil
  on_level: believe
  action:   quarantine
  scope:    tenant
  sla:      1ms
}

heal AutoPatch {
  source:      Vigil
  on_level:    speculate
  mode:        human_in_loop
  scope:       tenant
  review_sla:  1h
  max_patches: 3
}

// §λ-L-E Fase 9 — UI cognitiva declarativa.
// PatientRecord is HIPAA+GDPR, so PatientCard REQUIRES a shield whose
// `compliance` set covers those two classes (PHIShield does).

flow SummarizeRecordUI(rec: PatientRecord) -> PatientRecord {
  step Review {
    ask: "Summarize"
    output: PatientRecord
  }
}

component PatientCard {
  renders:     PatientRecord
  via_shield:  PHIShield
  on_interact: SummarizeRecordUI
  render_hint: card
}

view ClinicianDashboard {
  title:      "Clinician Dashboard"
  components: [PatientCard]
  route:      "/clinician"
}
