# Consumer Health UAT Scenarios

User Acceptance Testing for the Ontology Layer + Medical Vertical.

## Prerequisites

1. StemeDB running: `cargo run -p stemedb-api`
2. Ontology crate built: `cargo build -p stemedb-ontology`
3. Pharma CLI available: `cargo build --bin pharma-ingest`

## Week 4 Milestone: Automated UAT Infrastructure

**Status:** ✅ **VERIFIED** - All Scenarios Passing (2026-02-05)

**Verification Results:**
```
╔══════════════════════════════════════════════════════════════╗
║  Consumer Health UAT - Week 4 Validation                   ║
╚══════════════════════════════════════════════════════════════╝
  ✓ GLP-1 Muscle Loss Contradiction - PASS
  ✓ Gastroparesis Multi-Source - PASS
  ✓ Layered Consensus - PASS
  ✓ Time Travel Query - SKIP (deferred)
╔══════════════════════════════════════════════════════════════╗
║  Results: 4 passed, 0 failed, 0 skipped
╚══════════════════════════════════════════════════════════════╝
```

**Deliverables:**
- **Integration Test Suite:** `crates/stemedb-ontology/tests/consumer_health_uat.rs`
  - Real Ed25519 v1 signing (not dummy signatures)
  - 4 automated UAT scenarios
  - ~17 seconds end-to-end runtime
- **API Readiness Validator:** `validate_api_readiness.sh`
- **Execution Plan:** [WEEK4_EXECUTION_PLAN.md](./WEEK4_EXECUTION_PLAN.md)

### Quick Start (Automated Testing)

```bash
# 1. Start API with fresh database
rm -rf data/ && cargo run -p stemedb-api &
sleep 5

# 2. Run all automated UAT scenarios
STEMEDB_API_URL=http://localhost:18180 cargo test --test consumer_health_uat run_all_uat_scenarios -- --ignored --nocapture

# 3. Run individual scenario
STEMEDB_API_URL=http://localhost:18180 cargo test --test consumer_health_uat uat_glp1_muscle_loss_contradiction -- --ignored --nocapture
```

See [WEEK4_EXECUTION_PLAN.md](./WEEK4_EXECUTION_PLAN.md) for detailed execution instructions.

## Scenario Overview

### GLP-1 Living Systematic Review Scenarios

| Scenario | File | Tests |
|----------|------|-------|
| Muscle Loss Contradiction | `glp1-muscle-loss-contradiction.md` | Skeptic Lens conflict detection |
| FDA Label Paradigm Shift | `glp1-fda-label-paradigm-shift.md` | Epoch supersession O(1) |
| Pre-print vs Peer Review | `glp1-preprint-vs-peer-review.md` | Multi-sig weighting |
| Semantic Decay | `glp1-semantic-decay.md` | 73-day half-life |
| Visual Anchoring | `glp1-visual-anchoring.md` | pHash validation |

### Consumer Health Intelligence Scenarios

| Scenario | File | Tests |
|----------|------|-------|
| Gastroparesis Multi-Source | `gastroparesis-multi-source.md` | Source-class hierarchy |
| Anecdotal Signal Precedence | `anecdotal-signal-precedence.md` | Cluster escalation |
| Guidance Change Propagation | `guidance-change-propagation.md` | "What changed since?" |
| Layered Consensus | `layered-consensus.md` | Per-tier positions |
| Time Travel Query | `time-travel-query.md` | as_of snapshot |
| Disagreement Dashboard | `disagreement-dashboard.md` | Resolved/Active/Emerging |

## Running Scenarios

Each scenario file contains:
1. **Scenario description** - What we're testing
2. **Test matrix** - Expected vs actual results
3. **Commands** - Exact curl/CLI commands to run
4. **Sign-off checklist** - Manual verification points

### Example Workflow

```bash
# 1. Start StemeDB
cargo run --bin stemedb-api &

# 2. Run a scenario
# Follow commands in glp1-muscle-loss-contradiction.md

# 3. Record results
# Update the test matrix with actual values

# 4. Archive results
cp glp1-muscle-loss-contradiction.md results/2024-XX-XX-muscle-loss.md
```

## Weekly Execution Schedule

| Week | Scenarios | Why |
|------|-----------|-----|
| 1 | (none) | Building domain definition |
| 2 | (none) | Building extractor |
| 3 | `glp1-muscle-loss-contradiction` | First conflict demo |
| 4 | `gastroparesis-multi-source`, `layered-consensus` | Source hierarchy |
| 5 | `glp1-fda-label-paradigm-shift` | Epochs |
| 6 | Full suite | Integration validation |

## Success Criteria

From **GLP-1 Living Review**:
- Query `muscle_sparing_effect` with Skeptic lens returns `conflict_score > 0.5`
- Epoch supersession invalidates assertions O(1), not O(N)
- Multi-sig: Lancet reviewer signature has higher weight

From **Consumer Health Intelligence**:
- Tier 0 (FDA) wins over 100x Tier 5 (Reddit) volume
- `lens=layered-consensus` returns per-tier positions
- Source-aware decay: NEJM 8mo old ~0.87 effective; Reddit 26mo old expired
