## Phase 90: ML Sovereignty — Alignment & Safety Training

Build safety guardrails and alignment training pipelines to ensure all
self-hosted models meet Oshun's safety standards.

---

### 90.1 Safety Models & Guardrails

#### 90.1.1 Safety Infrastructure

- [x] **90.1.1.1** Integrate Llama Guard 4 as primary guardrail model (12B,
      natively multimodal text+image, MLCommons hazards taxonomy, single GPU)
- [x] **90.1.1.2** Integrate Granite Guardian for RAG hallucination detection
      (0.854 AUC — SOTA hallucination, 0.871 risk detection)
- [x] **90.1.1.3** Build Constitutional AI training pipeline with Oshun-specific
      principles (safety, helpfulness, honesty, privacy, fairness — per domain
      customization)
- [x] **90.1.1.4** Build red-team automation pipeline (auto-generate adversarial
      prompts → test model → classify failures → add to safety training →
      retrain → repeat)
- [x] **90.1.1.5** Implement RLAIF pipeline using Oshun's own models as judges
      (eliminate external API dependency for preference labeling)
- [x] **90.1.1.6** Build jailbreak detection fine-tuning pipeline (collect
      attempts from production + synthetic → train detection model → deploy as
      input guardrail)
- [x] **90.1.1.7** Build prompt injection detection model (fine-tune classifier
      on injection attempts from Kuan Yin + synthetic generation)
- [x] **90.1.1.8** Implement safety benchmark continuous evaluation (TruthfulQA,
      BBQ, RealToxicityPrompts — run on every model version)
- [x] **90.1.1.9** Build deepfake detection pipeline (integrate Deepfake-o-Meter
      framework with 18+ detection models across image/video/audio)
- [x] **90.1.1.10** Build NSFW content classifier fine-tuning pipeline for
      Aphrodite domain (domain-specific boundary calibration)
- [x] **90.1.1.11** Implement NeMo Guardrails integration (Content Safety NIM +
      Topic Control NIM + Jailbreak Detection NIM)
- [x] **90.1.1.12** Build multi-lingual safety evaluation for Ghanaian languages
      (safety benchmarks adapted for Twi, Ewe, Ga, Hausa)

#### 90.1.2 Content Provenance, Watermarking & IP Compliance

- [x] **90.1.2.1** Build text watermarking system for LLM outputs (statistical
      watermark embedding during token generation: green/red list method, robust
      to paraphrasing, detectable without model access, configurable strength,
      per-model watermark keys)
- [x] **90.1.2.2** Build image/audio watermarking for generated media (invisible
      watermark embedding in Isis-generated images and Euterpe audio, robust to
      compression/cropping/transcoding, detection API endpoint)
- [x] **90.1.2.3** Integrate C2PA Content Credentials for all generated content
      (embed provenance manifests: creation tool, AI model used, generation
      parameters, timestamp — for images, audio, video from Isis/Euterpe/Psyche,
      EU AI Act Article 50 compliance)
- [x] **90.1.2.4** Build copyright compliance system for generated content
      (training data license tracking from 87.2.1.5 → output license
      attribution, near-duplicate detection against copyrighted works, opt-out
      compliance)
- [x] **90.1.2.5** Build IP risk scoring for generated outputs (similarity
      scoring against known copyrighted works per domain, automated flagging
      above configurable threshold, per-domain IP policy enforcement)

#### 90.1.3 Domain-Specific Safety & Output Validation

- [x] **90.1.3.1** Build per-domain safety policy framework (domain-specific
      risk taxonomies and enforcement rules: medical with clinical safety,
      financial with regulatory compliance, creative with content boundaries —
      policy-grounded guardrails)
- [x] **90.1.3.2** Implement domain-aware guardrail routing (route safety checks
      through domain-specific policy evaluators based on request context: Hathor
      creative vs Sophia research vs Aphrodite adult — different thresholds per
      domain)
- [x] **90.1.3.3** Build output validation and compliance layer (schema
      conformance for structured outputs, format validation for domain-specific
      outputs, factual grounding verification for RAG responses, citation
      accuracy checking, hallucination detection beyond Granite Guardian)

---

## Completion evidence

All 20 locally actionable items are implemented in
`libs/nous/training/src/phase-90-*.ts`. The capability catalog maintains an
exact one-to-one mapping from every checklist ID to implementation and automated
verification. Tests cover model bindings, sovereign training loops, governance
gates, watermarking and C2PA delegation, IP policy, domain routing, structured
output validation, grounding, and citation verification.

Verification: `nx test nous-training`, `nx lint nous-training`,
`nx build nous-training`, and `nx typecheck nous-training`.
