// Package main provides drug assertion builders for P2.2 Conflict Scenarios.
//
// This file contains builders for 3 GLP-1 drugs with genuine pharmaceutical
// data conflicts. The data is based on real FDA labels, clinical trials, and
// patient reports, showcasing how StemeDB handles disagreements between
// authoritative sources.
//
// Target: 150+ assertions across 3 drugs with conflict scores ~0.3-0.8
package main

import (
	"context"
	"fmt"
	"log"

	"github.com/orchard9/stemedb-go/steme"
)

// DrugAssertionConfig holds configuration for building drug assertions.
type DrugAssertionConfig struct {
	// Agent is the agent name from the registry
	Agent string

	// Subject is the assertion subject (e.g., "Semaglutide:ChronicWeightManagement")
	Subject string

	// Predicate is the assertion predicate (e.g., "weight_loss_percent")
	Predicate string

	// Value is the assertion value (Number, Text, or Boolean)
	Value steme.ObjectValue

	// Confidence is the confidence score (0.0 to 1.0)
	Confidence float64

	// Lifecycle is the assertion lifecycle stage
	Lifecycle steme.LifecycleStage

	// Source is the source from the registry
	Source Source
}

// populateDrugConflicts populates all 3 drug conflict scenarios.
func populateDrugConflicts(ctx context.Context, registry *AgentRegistry, baseURL string) {
	fmt.Println("=== P2.2: Populating Drug Conflict Scenarios ===")
	fmt.Println()

	// Semaglutide (core assertions)
	semaglutideCount := populateSemaglutide(ctx, registry, baseURL)
	fmt.Printf("  Semaglutide: %d assertions\n", semaglutideCount)

	// Tirzepatide (core assertions)
	tirzepatideCount := populateTirzepatide(ctx, registry, baseURL)
	fmt.Printf("  Tirzepatide: %d assertions\n", tirzepatideCount)

	// Liraglutide (core assertions)
	liraglutideCount := populateLiraglutide(ctx, registry, baseURL)
	fmt.Printf("  Liraglutide: %d assertions\n", liraglutideCount)

	// Head-to-head comparisons
	comparisonCount := populateComparisons(ctx, registry, baseURL)
	fmt.Printf("  Comparisons: %d assertions\n", comparisonCount)

	// Mechanism/Pharmacology details
	mechanismCount := populateMechanismData(ctx, registry, baseURL)
	fmt.Printf("  Mechanism: %d assertions\n", mechanismCount)

	// Community/Real-world data
	communityCount := populateCommunityData(ctx, registry, baseURL)
	fmt.Printf("  Community: %d assertions\n", communityCount)

	// P2.4: Historical data with lifecycle evolution
	historicalCount := populateHistoricalData(ctx, registry, baseURL)
	fmt.Printf("  Historical: %d assertions\n", historicalCount)

	// P2.3: Cascade invalidation demo data
	cascadeCount := populateCascadeData(ctx, registry, baseURL)
	fmt.Printf("  Cascade Demo: %d assertions\n", cascadeCount)

	total := semaglutideCount + tirzepatideCount + liraglutideCount + comparisonCount + mechanismCount + communityCount + historicalCount + cascadeCount
	fmt.Printf("\n  Total: %d assertions\n", total)
	fmt.Println()
}

// submitAssertion submits a single assertion and returns success.
func submitAssertion(ctx context.Context, registry *AgentRegistry, baseURL string, cfg DrugAssertionConfig) bool {
	signer, ok := registry.signers[cfg.Agent]
	if !ok {
		log.Printf("Warning: Unknown agent %s", cfg.Agent)
		return false
	}

	client := steme.NewClient(baseURL, signer)

	assertion := steme.NewAssertion(cfg.Subject, cfg.Predicate).
		WithObject(cfg.Value).
		WithConfidence(cfg.Confidence).
		WithLifecycle(cfg.Lifecycle).
		WithSourceClass(cfg.Source.Class).
		WithSourceHash(cfg.Source.Hash()).
		Build()

	_, err := client.Assert(ctx, assertion)
	if err != nil {
		log.Printf("Warning: Failed to create assertion %s/%s: %v", cfg.Subject, cfg.Predicate, err)
		return false
	}

	return true
}

// submitAssertions submits a batch of assertions and returns the count.
func submitAssertions(ctx context.Context, registry *AgentRegistry, baseURL string, configs []DrugAssertionConfig) int {
	count := 0
	for _, cfg := range configs {
		if submitAssertion(ctx, registry, baseURL, cfg) {
			count++
		}
	}
	return count
}

// =============================================================================
// SEMAGLUTIDE (Ozempic, Wegovy, Rybelsus)
// =============================================================================

func populateSemaglutide(ctx context.Context, registry *AgentRegistry, baseURL string) int {
	configs := []DrugAssertionConfig{}

	// -------------------------------------------------------------------------
	// CONFLICT 1: Weight Loss % (The Flagship Demo)
	// This is the killer conflict - same metric, different values from different tiers
	// -------------------------------------------------------------------------

	// FDA Wegovy Label (T0): 14.9% from STEP 1 pivotal
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewNumberValue(14.9),
		Confidence: 0.98,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// STEP 1 Trial (T1): 14.9% (CI 13.5-16.4)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Semaglutide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewNumberValue(14.9),
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_STEP_1"],
	})

	// STEP UP Trial (T1): 20.7% at 7.2mg dose (higher dose study)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Semaglutide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewNumberValue(20.7),
		Confidence: 0.92,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_STEP_UP"],
	})

	// Expert (T3): ~15% typical in practice
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Semaglutide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewNumberValue(15.0),
		Confidence: 0.85,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ENDOCRINE_SOCIETY"],
	})

	// Reddit (T5): Anecdotal reports vary wildly
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Semaglutide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewTextValue("Reports range 10-25%, highly variable"),
		Confidence: 0.70,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_OZEMPIC"],
	})

	// -------------------------------------------------------------------------
	// CONFLICT 2: Gastroparesis Risk (Real-World vs Clinical Trial)
	// This demonstrates how clinical trials underreport vs real-world evidence
	// -------------------------------------------------------------------------

	// FDA Label (T0): 0.2% trial incidence
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "gastroparesis_risk",
		Value:      steme.NewNumberValue(0.002), // 0.2%
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// UBC Study (T2): 3x risk vs bupropion-naltrexone
	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Semaglutide",
		Predicate:  "gastroparesis_risk",
		Value:      steme.NewTextValue("3.67x increased risk vs bupropion-naltrexone (HR 3.67, 95% CI 1.15-11.90)"),
		Confidence: 0.88,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["RWE_UBC_GASTROPARESIS"],
	})

	// FAERS Data (T2): Higher signal
	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Semaglutide",
		Predicate:  "gastroparesis_risk",
		Value:      steme.NewTextValue("Elevated reporting rate vs background (PRR 2.8)"),
		Confidence: 0.82,
		Lifecycle:  steme.LifecycleUnderReview,
		Source:     Sources["RWE_FAERS_SEMAGLUTIDE"],
	})

	// Expert (T3): Acknowledgment of signal
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Semaglutide",
		Predicate:  "gastroparesis_risk",
		Value:      steme.NewTextValue("Risk signal acknowledged; monitor patients with pre-existing GI conditions"),
		Confidence: 0.80,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ADA_GUIDELINES"],
	})

	// Reddit (T5): High patient-reported incidence
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Semaglutide",
		Predicate:  "gastroparesis_risk",
		Value:      steme.NewTextValue("Many users report stomach paralysis symptoms; underreported in trials"),
		Confidence: 0.70,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_OZEMPIC"],
	})

	// -------------------------------------------------------------------------
	// CONFLICT 3: Nausea Rate (Investigator vs Patient-Reported)
	// -------------------------------------------------------------------------

	// FDA Label (T0): 44% from clinical trials
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "nausea_rate",
		Value:      steme.NewNumberValue(0.44), // 44%
		Confidence: 0.97,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// STEP 1 Trial (T1): 44.2%
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Semaglutide",
		Predicate:  "nausea_rate",
		Value:      steme.NewNumberValue(0.442),
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_STEP_1"],
	})

	// Real-World (T2): More disruptive
	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Semaglutide",
		Predicate:  "nausea_rate",
		Value:      steme.NewTextValue("Real-world: nausea more severe/disruptive than trial reports suggest"),
		Confidence: 0.78,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["RWE_TRINETX_GLP1"],
	})

	// Reddit (T5): Debilitating for some
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Semaglutide",
		Predicate:  "nausea_rate",
		Value:      steme.NewTextValue("Debilitating for first weeks; many struggle with dose titration"),
		Confidence: 0.68,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_OZEMPIC"],
	})

	// -------------------------------------------------------------------------
	// Efficacy: HbA1c Reduction (T2D indication)
	// -------------------------------------------------------------------------

	// FDA Ozempic Label (T0)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide:Type2Diabetes",
		Predicate:  "hba1c_reduction_percent",
		Value:      steme.NewNumberValue(1.5),
		Confidence: 0.98,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_OZEMPIC_LABEL"],
	})

	// SUSTAIN-6 Trial (T1)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Semaglutide:Type2Diabetes",
		Predicate:  "hba1c_reduction_percent",
		Value:      steme.NewNumberValue(1.4),
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SUSTAIN_6"],
	})

	// -------------------------------------------------------------------------
	// Safety: Cardiovascular Benefit (SELECT Trial)
	// -------------------------------------------------------------------------

	// SELECT Trial (T1): 20% CV event reduction
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Semaglutide:CardiovascularDisease",
		Predicate:  "cardiovascular_events_reduction",
		Value:      steme.NewNumberValue(0.20), // 20% reduction
		Confidence: 0.94,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SELECT"],
	})

	// FDA Label updated (T0)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide:CardiovascularDisease",
		Predicate:  "cardiovascular_events_reduction",
		Value:      steme.NewTextValue("Approved for CV risk reduction in adults with obesity"),
		Confidence: 0.98,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// -------------------------------------------------------------------------
	// Safety: Discontinuation Rate
	// -------------------------------------------------------------------------

	// FDA Label (T0)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "discontinuation_rate_adverse_events",
		Value:      steme.NewNumberValue(0.07), // 7%
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// Real-World (T2): Higher in practice
	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Semaglutide",
		Predicate:  "discontinuation_rate_adverse_events",
		Value:      steme.NewNumberValue(0.15), // 15% in real-world
		Confidence: 0.82,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["RWE_IQVIA_ADHERENCE"],
	})

	// -------------------------------------------------------------------------
	// Additional Safety Predicates
	// -------------------------------------------------------------------------

	// Vomiting rate
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "vomiting_rate",
		Value:      steme.NewNumberValue(0.24), // 24%
		Confidence: 0.97,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// Diarrhea rate
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "diarrhea_rate",
		Value:      steme.NewNumberValue(0.30), // 30%
		Confidence: 0.97,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// Constipation rate
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "constipation_rate",
		Value:      steme.NewNumberValue(0.24), // 24%
		Confidence: 0.97,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// Pancreatitis risk (boxed warning)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "pancreatitis_risk",
		Value:      steme.NewTextValue("Warning: acute pancreatitis observed; discontinue if suspected"),
		Confidence: 0.99,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// Thyroid C-cell tumor warning
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "has_boxed_warning",
		Value:      steme.NewBooleanValue(true),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "boxed_warning_text",
		Value:      steme.NewTextValue("Thyroid C-Cell Tumors: contraindicated in MTC or MEN 2"),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// Gallbladder disease risk
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "gallbladder_disease_risk",
		Value:      steme.NewTextValue("Cholelithiasis/cholecystitis reported; monitor for symptoms"),
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// Hypoglycemia risk
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "hypoglycemia_risk",
		Value:      steme.NewTextValue("Low risk alone; increased when combined with insulin or sulfonylureas"),
		Confidence: 0.96,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_OZEMPIC_LABEL"],
	})

	// Injection site reactions
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "injection_site_reaction_rate",
		Value:      steme.NewNumberValue(0.02), // 2%
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// Muscle loss concerns (emerging)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Semaglutide",
		Predicate:  "muscle_loss_observed",
		Value:      steme.NewTextValue("39% of weight loss from lean mass in STEP 1"),
		Confidence: 0.85,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_STEP_1"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Semaglutide",
		Predicate:  "muscle_loss_observed",
		Value:      steme.NewTextValue("'Ozempic face' and muscle wasting commonly reported"),
		Confidence: 0.65,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_OZEMPIC"],
	})

	// Hair loss reports (anecdotal)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Semaglutide",
		Predicate:  "hair_loss_reported",
		Value:      steme.NewTextValue("Many users report hair thinning/loss, possibly from rapid weight loss"),
		Confidence: 0.60,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_OZEMPIC"],
	})

	// -------------------------------------------------------------------------
	// Mechanism / Pharmacology
	// -------------------------------------------------------------------------

	// Primary target
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide:GLP1R",
		Predicate:  "primary_target",
		Value:      steme.NewTextValue("GLP-1 receptor agonist (94% homology to native GLP-1)"),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// Half-life
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "half_life_hours",
		Value:      steme.NewNumberValue(168), // ~7 days
		Confidence: 0.98,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// Bioavailability (oral)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "bioavailability_percent",
		Value:      steme.NewNumberValue(0.89), // 89% for injection
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// -------------------------------------------------------------------------
	// Regulatory / Approval
	// -------------------------------------------------------------------------

	// FDA approval date (Wegovy for obesity)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "fda_approval_date",
		Value:      steme.NewTextValue("2021-06-04 (Wegovy for chronic weight management)"),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// Approved indications
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "approved_indications",
		Value:      steme.NewTextValue("Chronic weight management (BMI >=30 or >=27 with comorbidity); Type 2 diabetes; CV risk reduction"),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// Max approved dose
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "max_approved_dose_mg",
		Value:      steme.NewNumberValue(2.4), // Wegovy max
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// -------------------------------------------------------------------------
	// STEP 2 Trial Data (T2D population)
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Semaglutide:Type2Diabetes",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewNumberValue(9.6), // Lower in T2D population
		Confidence: 0.94,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_STEP_2"],
	})

	// -------------------------------------------------------------------------
	// Expert Guidelines Integration
	// -------------------------------------------------------------------------

	// ADA recommendation
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Semaglutide:Type2Diabetes",
		Predicate:  "response_rate",
		Value:      steme.NewTextValue("Recommended as first-line injectable for patients with T2D and obesity (ADA 2024)"),
		Confidence: 0.92,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ADA_GUIDELINES"],
	})

	return submitAssertions(ctx, registry, baseURL, configs)
}

// =============================================================================
// TIRZEPATIDE (Mounjaro, Zepbound)
// =============================================================================

func populateTirzepatide(ctx context.Context, registry *AgentRegistry, baseURL string) int {
	configs := []DrugAssertionConfig{}

	// -------------------------------------------------------------------------
	// CONFLICT 3: Weight Loss % (Highest Efficacy GLP-1)
	// -------------------------------------------------------------------------

	// FDA Zepbound Label (T0): 20.9% at 15mg
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewNumberValue(20.9),
		Confidence: 0.98,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// SURMOUNT-1 Trial (T1): 22.5% at 72 weeks
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Tirzepatide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewNumberValue(22.5),
		Confidence: 0.96,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SURMOUNT_1"],
	})

	// 3-Year Extension (T1): 22.9% sustained
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Tirzepatide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewNumberValue(22.9),
		Confidence: 0.93,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SURMOUNT_3YR"],
	})

	// Expert (T3): Best-in-class
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Tirzepatide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewTextValue("Highest efficacy among GLP-1s; ~22% typical at max dose"),
		Confidence: 0.88,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_AACE_OBESITY"],
	})

	// Reddit (T5): Variable reports
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Tirzepatide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewTextValue("Users report 15-30% loss; 'game changer' for some"),
		Confidence: 0.68,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_MOUNJARO"],
	})

	// -------------------------------------------------------------------------
	// CONFLICT 4: Nausea/GI Side Effects (Trade-off)
	// Tirzepatide has highest efficacy but also GI issues
	// -------------------------------------------------------------------------

	// FDA Label (T0): 17% nausea (lower than reported in practice)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "nausea_rate",
		Value:      steme.NewNumberValue(0.17), // 17%
		Confidence: 0.97,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// SURMOUNT-1 (T1): 29.3% all GI AEs
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Tirzepatide",
		Predicate:  "adverse_event_rate",
		Value:      steme.NewTextValue("GI AEs: nausea 24.6%, diarrhea 21.1%, constipation 17.1%"),
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SURMOUNT_1"],
	})

	// Real-World (T2): Higher GI issues
	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Tirzepatide",
		Predicate:  "nausea_rate",
		Value:      steme.NewTextValue("Real-world GI AE rates higher than trials; dose titration critical"),
		Confidence: 0.80,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["RWE_OPTUM_TIRZEPATIDE"],
	})

	// Reddit (T5): Trade-off discussion
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Tirzepatide",
		Predicate:  "nausea_rate",
		Value:      steme.NewTextValue("'Worth it for the weight loss' but GI sides are real; slow titration helps"),
		Confidence: 0.65,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_MOUNJARO"],
	})

	// -------------------------------------------------------------------------
	// Gastroparesis Risk (Tirzepatide)
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "gastroparesis_risk",
		Value:      steme.NewTextValue("Delayed gastric emptying observed; caution with preexisting GI disorders"),
		Confidence: 0.94,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Tirzepatide",
		Predicate:  "gastroparesis_risk",
		Value:      steme.NewTextValue("Similar risk profile to semaglutide; may be higher due to dual agonism"),
		Confidence: 0.78,
		Lifecycle:  steme.LifecycleUnderReview,
		Source:     Sources["RWE_UBC_GASTROPARESIS"],
	})

	// -------------------------------------------------------------------------
	// Efficacy: HbA1c Reduction (T2D)
	// -------------------------------------------------------------------------

	// FDA Mounjaro Label (T0): Best HbA1c reduction
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide:Type2Diabetes",
		Predicate:  "hba1c_reduction_percent",
		Value:      steme.NewNumberValue(2.4), // Best in class
		Confidence: 0.98,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_MOUNJARO_LABEL"],
	})

	// SURMOUNT-2 (T1): T2D population
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Tirzepatide:Type2Diabetes",
		Predicate:  "hba1c_reduction_percent",
		Value:      steme.NewNumberValue(2.1),
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SURMOUNT_2"],
	})

	// Weight loss in T2D
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Tirzepatide:Type2Diabetes",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewNumberValue(15.7), // 15.7% in T2D (lower than non-T2D)
		Confidence: 0.94,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SURMOUNT_2"],
	})

	// -------------------------------------------------------------------------
	// Safety Predicates
	// -------------------------------------------------------------------------

	// Vomiting rate
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "vomiting_rate",
		Value:      steme.NewNumberValue(0.12), // 12%
		Confidence: 0.96,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// Diarrhea rate
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "diarrhea_rate",
		Value:      steme.NewNumberValue(0.21), // 21%
		Confidence: 0.96,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// Constipation rate
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "constipation_rate",
		Value:      steme.NewNumberValue(0.17), // 17%
		Confidence: 0.96,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// Discontinuation rate
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "discontinuation_rate_adverse_events",
		Value:      steme.NewNumberValue(0.06), // 6%
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// Boxed warning (same class)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "has_boxed_warning",
		Value:      steme.NewBooleanValue(true),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "boxed_warning_text",
		Value:      steme.NewTextValue("Thyroid C-Cell Tumors: contraindicated in MTC or MEN 2"),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// Pancreatitis risk
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "pancreatitis_risk",
		Value:      steme.NewTextValue("Acute pancreatitis reported; discontinue if suspected"),
		Confidence: 0.98,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// Injection site reactions
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "injection_site_reaction_rate",
		Value:      steme.NewNumberValue(0.07), // 7%
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// Muscle loss observation
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Tirzepatide",
		Predicate:  "lean_mass_preserved",
		Value:      steme.NewTextValue("Better lean mass preservation than semaglutide (~65% fat loss)"),
		Confidence: 0.82,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SURMOUNT_1"],
	})

	// -------------------------------------------------------------------------
	// Mechanism / Pharmacology
	// -------------------------------------------------------------------------

	// Primary target (dual agonist - unique!)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide:GLP1R",
		Predicate:  "primary_target",
		Value:      steme.NewTextValue("Dual GIP/GLP-1 receptor agonist - first in class"),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// Half-life
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "half_life_hours",
		Value:      steme.NewNumberValue(120), // ~5 days
		Confidence: 0.97,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// -------------------------------------------------------------------------
	// Regulatory / Approval
	// -------------------------------------------------------------------------

	// FDA approval date (Zepbound)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "fda_approval_date",
		Value:      steme.NewTextValue("2023-11-08 (Zepbound for chronic weight management)"),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// Approved indications
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "approved_indications",
		Value:      steme.NewTextValue("Chronic weight management (BMI >=30 or >=27 with comorbidity); Type 2 diabetes"),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// Max approved dose
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "max_approved_dose_mg",
		Value:      steme.NewNumberValue(15.0),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// -------------------------------------------------------------------------
	// Expert Guidelines
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Tirzepatide:ChronicWeightManagement",
		Predicate:  "response_rate",
		Value:      steme.NewTextValue("Preferred for maximum weight loss; consider for patients who failed semaglutide"),
		Confidence: 0.88,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_AACE_OBESITY"],
	})

	return submitAssertions(ctx, registry, baseURL, configs)
}

// =============================================================================
// LIRAGLUTIDE (Victoza, Saxenda)
// =============================================================================

func populateLiraglutide(ctx context.Context, registry *AgentRegistry, baseURL string) int {
	configs := []DrugAssertionConfig{}

	// -------------------------------------------------------------------------
	// Weight Loss % (Established, lower than newer agents)
	// -------------------------------------------------------------------------

	// FDA Saxenda Label (T0): 5-10% range
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewNumberValue(8.0),
		Confidence: 0.97,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// SCALE Trial (T1): 8% at 56 weeks
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Liraglutide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewNumberValue(8.0),
		Confidence: 0.94,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SCALE_OBESITY"],
	})

	// Expert (T3): Established but modest
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Liraglutide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewTextValue("5-10% typical; less effective than semaglutide/tirzepatide"),
		Confidence: 0.85,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ENDOCRINE_SOCIETY"],
	})

	// Reddit (T5): Mixed reviews
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Liraglutide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewTextValue("Results vary 5-15%; many switch to Ozempic for better results"),
		Confidence: 0.65,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_SAXENDA"],
	})

	// -------------------------------------------------------------------------
	// Nausea Rate (Generally better tolerated)
	// -------------------------------------------------------------------------

	// FDA Label (T0): 39%
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "nausea_rate",
		Value:      steme.NewNumberValue(0.39), // 39%
		Confidence: 0.96,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// SCALE Trial (T1)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Liraglutide",
		Predicate:  "nausea_rate",
		Value:      steme.NewNumberValue(0.40), // 40%
		Confidence: 0.94,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SCALE_OBESITY"],
	})

	// Reddit (T5): Manageable
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Liraglutide",
		Predicate:  "nausea_rate",
		Value:      steme.NewTextValue("Generally manageable; easier titration than newer GLP-1s"),
		Confidence: 0.68,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_SAXENDA"],
	})

	// -------------------------------------------------------------------------
	// Gastroparesis Risk (Lower signal)
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "gastroparesis_risk",
		Value:      steme.NewTextValue("Delayed gastric emptying; lower signal than semaglutide"),
		Confidence: 0.92,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Liraglutide",
		Predicate:  "gastroparesis_risk",
		Value:      steme.NewTextValue("Similar risk profile but fewer reports than semaglutide (shorter half-life)"),
		Confidence: 0.82,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["RWE_UBC_GASTROPARESIS"],
	})

	// -------------------------------------------------------------------------
	// Cardiovascular Outcomes (LEADER Trial)
	// -------------------------------------------------------------------------

	// LEADER Trial (T1): CV benefit demonstrated
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Liraglutide:CardiovascularDisease",
		Predicate:  "cardiovascular_events_reduction",
		Value:      steme.NewNumberValue(0.13), // 13% MACE reduction
		Confidence: 0.94,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_LEADER"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Liraglutide:CardiovascularDisease",
		Predicate:  "all_cause_mortality_reduction",
		Value:      steme.NewNumberValue(0.15), // 15% mortality reduction
		Confidence: 0.92,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_LEADER"],
	})

	// FDA Label (T0)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide:CardiovascularDisease",
		Predicate:  "cardiovascular_events_reduction",
		Value:      steme.NewTextValue("Approved for CV risk reduction in T2D with established CVD"),
		Confidence: 0.98,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_VICTOZA_LABEL"],
	})

	// -------------------------------------------------------------------------
	// Efficacy: HbA1c Reduction (T2D)
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide:Type2Diabetes",
		Predicate:  "hba1c_reduction_percent",
		Value:      steme.NewNumberValue(1.2),
		Confidence: 0.97,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_VICTOZA_LABEL"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Liraglutide:Type2Diabetes",
		Predicate:  "hba1c_reduction_percent",
		Value:      steme.NewNumberValue(1.1),
		Confidence: 0.94,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_LEADER"],
	})

	// -------------------------------------------------------------------------
	// Safety Predicates
	// -------------------------------------------------------------------------

	// Vomiting rate
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "vomiting_rate",
		Value:      steme.NewNumberValue(0.16), // 16%
		Confidence: 0.96,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// Diarrhea rate
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "diarrhea_rate",
		Value:      steme.NewNumberValue(0.21), // 21%
		Confidence: 0.96,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// Constipation rate
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "constipation_rate",
		Value:      steme.NewNumberValue(0.19), // 19%
		Confidence: 0.96,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// Discontinuation rate (lower than newer agents)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "discontinuation_rate_adverse_events",
		Value:      steme.NewNumberValue(0.10), // 10%
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// Boxed warning
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "has_boxed_warning",
		Value:      steme.NewBooleanValue(true),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "boxed_warning_text",
		Value:      steme.NewTextValue("Thyroid C-Cell Tumors: contraindicated in MTC or MEN 2"),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// Pancreatitis risk
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "pancreatitis_risk",
		Value:      steme.NewTextValue("Acute pancreatitis reported; discontinue if suspected"),
		Confidence: 0.98,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// Injection site reactions
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "injection_site_reaction_rate",
		Value:      steme.NewNumberValue(0.02), // 2%
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// -------------------------------------------------------------------------
	// Mechanism / Pharmacology
	// -------------------------------------------------------------------------

	// Primary target
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide:GLP1R",
		Predicate:  "primary_target",
		Value:      steme.NewTextValue("GLP-1 receptor agonist (97% homology to native GLP-1)"),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// Half-life (shorter than semaglutide)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "half_life_hours",
		Value:      steme.NewNumberValue(13), // ~13 hours (daily dosing)
		Confidence: 0.98,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// -------------------------------------------------------------------------
	// Regulatory / Approval (First-mover advantage)
	// -------------------------------------------------------------------------

	// FDA approval date (Saxenda)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "fda_approval_date",
		Value:      steme.NewTextValue("2014-12-23 (Saxenda for chronic weight management)"),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// Approved indications
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "approved_indications",
		Value:      steme.NewTextValue("Chronic weight management; Type 2 diabetes; CV risk reduction in T2D"),
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// Max approved dose
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "max_approved_dose_mg",
		Value:      steme.NewNumberValue(3.0), // Saxenda 3.0mg
		Confidence: 1.0,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// -------------------------------------------------------------------------
	// Established Safety Profile (Advantage)
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Liraglutide",
		Predicate:  "serious_adverse_event_rate",
		Value:      steme.NewTextValue("Longest post-market safety record among GLP-1s; well-characterized profile"),
		Confidence: 0.90,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ADA_GUIDELINES"],
	})

	// -------------------------------------------------------------------------
	// Comparison Assertions
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Liraglutide:Placebo:ChronicWeightManagement",
		Predicate:  "superiority_demonstrated",
		Value:      steme.NewBooleanValue(true),
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SCALE_OBESITY"],
	})

	// -------------------------------------------------------------------------
	// Additional Community and Anecdotal Data
	// -------------------------------------------------------------------------

	// Community perspective on tolerability
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Liraglutide",
		Predicate:  "adverse_event_rate",
		Value:      steme.NewTextValue("Daily dosing annoying but side effects manageable for most"),
		Confidence: 0.62,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_SAXENDA"],
	})

	// Discontinuation perspective
	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Liraglutide",
		Predicate:  "discontinuation_rate_adverse_events",
		Value:      steme.NewNumberValue(0.12), // Real-world slightly higher
		Confidence: 0.80,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["RWE_IQVIA_ADHERENCE"],
	})

	return submitAssertions(ctx, registry, baseURL, configs)
}

// =============================================================================
// ADDITIONAL COMPARISON AND CROSS-DRUG ASSERTIONS
// =============================================================================

// populateComparisons adds head-to-head comparison assertions.
func populateComparisons(ctx context.Context, registry *AgentRegistry, baseURL string) int {
	configs := []DrugAssertionConfig{}

	// -------------------------------------------------------------------------
	// Semaglutide vs Placebo
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Semaglutide:Placebo:ChronicWeightManagement",
		Predicate:  "superiority_demonstrated",
		Value:      steme.NewBooleanValue(true),
		Confidence: 0.98,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_STEP_1"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Semaglutide:Placebo:ChronicWeightManagement",
		Predicate:  "relative_efficacy",
		Value:      steme.NewTextValue("12.4% greater weight loss vs placebo (STEP 1)"),
		Confidence: 0.96,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_STEP_1"],
	})

	// -------------------------------------------------------------------------
	// Tirzepatide vs Placebo
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Tirzepatide:Placebo:ChronicWeightManagement",
		Predicate:  "superiority_demonstrated",
		Value:      steme.NewBooleanValue(true),
		Confidence: 0.98,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SURMOUNT_1"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Tirzepatide:Placebo:ChronicWeightManagement",
		Predicate:  "relative_efficacy",
		Value:      steme.NewTextValue("19.5% greater weight loss vs placebo (SURMOUNT-1, 15mg)"),
		Confidence: 0.96,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SURMOUNT_1"],
	})

	// -------------------------------------------------------------------------
	// Tirzepatide vs Semaglutide (Head-to-Head - Real Data!)
	// This is the SURPASS-2 equivalent conflict
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Tirzepatide:Semaglutide:Type2Diabetes",
		Predicate:  "superiority_demonstrated",
		Value:      steme.NewBooleanValue(true),
		Confidence: 0.94,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SURMOUNT_1"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Tirzepatide:Semaglutide:Type2Diabetes",
		Predicate:  "relative_efficacy",
		Value:      steme.NewTextValue("Superior HbA1c and weight reduction vs semaglutide 1mg"),
		Confidence: 0.92,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SURMOUNT_1"],
	})

	// Expert perspective on comparison
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Tirzepatide:Semaglutide:ChronicWeightManagement",
		Predicate:  "relative_efficacy",
		Value:      steme.NewTextValue("Tirzepatide shows ~5-7% greater weight loss; dual mechanism may explain"),
		Confidence: 0.85,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ENDOCRINE_SOCIETY"],
	})

	// Anecdotal comparison
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Tirzepatide:Semaglutide:ChronicWeightManagement",
		Predicate:  "relative_efficacy",
		Value:      steme.NewTextValue("Many switchers report better results on Mounjaro; YMMV"),
		Confidence: 0.60,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_MOUNJARO"],
	})

	// -------------------------------------------------------------------------
	// Liraglutide vs Semaglutide (Older vs Newer)
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Semaglutide:Liraglutide:ChronicWeightManagement",
		Predicate:  "superiority_demonstrated",
		Value:      steme.NewBooleanValue(true),
		Confidence: 0.90,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_AACE_OBESITY"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Semaglutide:Liraglutide:ChronicWeightManagement",
		Predicate:  "relative_efficacy",
		Value:      steme.NewTextValue("Semaglutide ~7% more effective; weekly vs daily dosing preferred"),
		Confidence: 0.88,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ENDOCRINE_SOCIETY"],
	})

	// Reddit perspective
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Semaglutide:Liraglutide:ChronicWeightManagement",
		Predicate:  "relative_efficacy",
		Value:      steme.NewTextValue("Most who tried both prefer Ozempic for convenience and results"),
		Confidence: 0.65,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_OZEMPIC"],
	})

	// -------------------------------------------------------------------------
	// Cost-Effectiveness Comparisons (Real-World Consideration)
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Semaglutide:Placebo:ChronicWeightManagement",
		Predicate:  "cost_effectiveness_ratio",
		Value:      steme.NewTextValue("$13,000-$24,000 per QALY gained (varies by payer perspective)"),
		Confidence: 0.75,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ADA_GUIDELINES"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Tirzepatide:Placebo:ChronicWeightManagement",
		Predicate:  "cost_effectiveness_ratio",
		Value:      steme.NewTextValue("Higher acquisition cost but potentially better ICER due to efficacy"),
		Confidence: 0.70,
		Lifecycle:  steme.LifecycleUnderReview,
		Source:     Sources["EXPERT_AACE_OBESITY"],
	})

	// -------------------------------------------------------------------------
	// Safety Comparisons
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Tirzepatide:Semaglutide:ChronicWeightManagement",
		Predicate:  "relative_safety",
		Value:      steme.NewTextValue("Similar GI AE profile; tirzepatide may have slightly higher initial GI burden"),
		Confidence: 0.80,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ENDOCRINE_SOCIETY"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Tirzepatide:Semaglutide:ChronicWeightManagement",
		Predicate:  "relative_safety",
		Value:      steme.NewTextValue("Discontinuation rates similar (~5-7%); lean mass preservation may favor tirzepatide"),
		Confidence: 0.78,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["RWE_TRINETX_GLP1"],
	})

	return submitAssertions(ctx, registry, baseURL, configs)
}

// =============================================================================
// ADDITIONAL MECHANISM AND PHARMACOLOGY DATA
// =============================================================================

// populateMechanismData adds mechanism of action and pharmacology assertions.
func populateMechanismData(ctx context.Context, registry *AgentRegistry, baseURL string) int {
	configs := []DrugAssertionConfig{}

	// -------------------------------------------------------------------------
	// Semaglutide Mechanism Details
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide:GLP1R",
		Predicate:  "mechanism_of_action",
		Value:      steme.NewTextValue("Activates GLP-1 receptors; increases insulin secretion, decreases glucagon, slows gastric emptying, reduces appetite"),
		Confidence: 0.99,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Semaglutide:GLP1R",
		Predicate:  "receptor_binding_affinity",
		Value:      steme.NewTextValue("High affinity GLP-1R agonist; 94% sequence homology to native GLP-1"),
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_STEP_1"],
	})

	// -------------------------------------------------------------------------
	// Tirzepatide Dual Mechanism (Unique!)
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide:GIPR",
		Predicate:  "mechanism_of_action",
		Value:      steme.NewTextValue("Dual GIP/GLP-1 receptor agonist; GIP activation may enhance insulin sensitivity and fat metabolism"),
		Confidence: 0.98,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Tirzepatide:GIPR",
		Predicate:  "receptor_binding_affinity",
		Value:      steme.NewTextValue("Imbalanced agonist: higher affinity for GIP (5x) than GLP-1 receptor"),
		Confidence: 0.92,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SURMOUNT_1"],
	})

	// Expert interpretation of dual mechanism
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Tirzepatide:GIPR",
		Predicate:  "mechanism_of_action",
		Value:      steme.NewTextValue("GIP component may explain superior efficacy; mechanism still being elucidated"),
		Confidence: 0.82,
		Lifecycle:  steme.LifecycleUnderReview,
		Source:     Sources["EXPERT_ENDOCRINE_SOCIETY"],
	})

	// -------------------------------------------------------------------------
	// Liraglutide Mechanism
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide:GLP1R",
		Predicate:  "mechanism_of_action",
		Value:      steme.NewTextValue("GLP-1 receptor agonist; 97% homology to native GLP-1; acylated for albumin binding"),
		Confidence: 0.99,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	// -------------------------------------------------------------------------
	// Additional Pharmacokinetic Data
	// -------------------------------------------------------------------------

	// Semaglutide PK
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "peak_plasma_concentration_hours",
		Value:      steme.NewNumberValue(24), // 1-3 days
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "protein_binding_percent",
		Value:      steme.NewNumberValue(99.0),
		Confidence: 0.97,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// Tirzepatide PK
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "peak_plasma_concentration_hours",
		Value:      steme.NewNumberValue(24), // ~24 hours
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "protein_binding_percent",
		Value:      steme.NewNumberValue(99.0),
		Confidence: 0.97,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// Liraglutide PK
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "peak_plasma_concentration_hours",
		Value:      steme.NewNumberValue(11), // 8-12 hours
		Confidence: 0.96,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Liraglutide",
		Predicate:  "protein_binding_percent",
		Value:      steme.NewNumberValue(98.0),
		Confidence: 0.97,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_SAXENDA_LABEL"],
	})

	return submitAssertions(ctx, registry, baseURL, configs)
}

// =============================================================================
// ADDITIONAL COMMUNITY AND REAL-WORLD DATA
// =============================================================================

// populateCommunityData adds community and real-world experience assertions.
func populateCommunityData(ctx context.Context, registry *AgentRegistry, baseURL string) int {
	configs := []DrugAssertionConfig{}

	// -------------------------------------------------------------------------
	// Semaglutide Community Insights
	// -------------------------------------------------------------------------

	// PatientsLikeMe data
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Semaglutide:ChronicWeightManagement",
		Predicate:  "response_rate",
		Value:      steme.NewTextValue("Community reports: ~70% achieve >10% weight loss; 30% non-responders"),
		Confidence: 0.72,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["COMMUNITY_PATIENTS_LIKE_ME"],
	})

	// Time to response (real-world)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Semaglutide:ChronicWeightManagement",
		Predicate:  "time_to_response_weeks",
		Value:      steme.NewTextValue("Most see results by week 4-8; full effect at maintenance dose ~4-6 months"),
		Confidence: 0.70,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_OZEMPIC"],
	})

	// Food aversion reports
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Semaglutide",
		Predicate:  "adverse_event_rate",
		Value:      steme.NewTextValue("'Food noise' silencing reported; some develop aversions to fatty/sweet foods"),
		Confidence: 0.65,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_OZEMPIC"],
	})

	// -------------------------------------------------------------------------
	// Tirzepatide Community Insights
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Tirzepatide:ChronicWeightManagement",
		Predicate:  "response_rate",
		Value:      steme.NewTextValue("Community reports: higher super-responder rate (>20% loss) than semaglutide"),
		Confidence: 0.68,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["COMMUNITY_PATIENTS_LIKE_ME"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Tirzepatide:ChronicWeightManagement",
		Predicate:  "time_to_response_weeks",
		Value:      steme.NewTextValue("Rapid initial response; some report 10lbs first month even at 2.5mg"),
		Confidence: 0.66,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_MOUNJARO"],
	})

	// Supply issues (real-world challenge)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Tirzepatide",
		Predicate:  "adverse_event_rate",
		Value:      steme.NewTextValue("Sulfur burps common; injection site reactions more frequent than semaglutide"),
		Confidence: 0.62,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_MOUNJARO"],
	})

	// -------------------------------------------------------------------------
	// Liraglutide Community Insights
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Liraglutide:ChronicWeightManagement",
		Predicate:  "response_rate",
		Value:      steme.NewTextValue("Older but proven; many report steady 1-2 lbs/week loss with diet"),
		Confidence: 0.65,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["COMMUNITY_DIABETES_FORUM"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Liraglutide",
		Predicate:  "adverse_event_rate",
		Value:      steme.NewTextValue("Daily injection burden cited as main drawback vs weekly alternatives"),
		Confidence: 0.68,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_REDDIT_SAXENDA"],
	})

	// -------------------------------------------------------------------------
	// Real-World Adherence Data (Key for Demo)
	// -------------------------------------------------------------------------

	// Semaglutide adherence
	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Semaglutide",
		Predicate:  "response_rate",
		Value:      steme.NewTextValue("12-month persistence: ~55-60% (real-world); higher than liraglutide"),
		Confidence: 0.82,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["RWE_IQVIA_ADHERENCE"],
	})

	// Tirzepatide adherence (newer, less data)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Tirzepatide",
		Predicate:  "response_rate",
		Value:      steme.NewTextValue("Early real-world data: similar or better persistence than semaglutide"),
		Confidence: 0.75,
		Lifecycle:  steme.LifecycleUnderReview,
		Source:     Sources["RWE_OPTUM_TIRZEPATIDE"],
	})

	// Liraglutide adherence
	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Liraglutide",
		Predicate:  "response_rate",
		Value:      steme.NewTextValue("12-month persistence: ~40-45%; daily dosing impacts adherence"),
		Confidence: 0.82,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["RWE_IQVIA_ADHERENCE"],
	})

	// -------------------------------------------------------------------------
	// Twitter/TikTok Anecdotal (Tier 5 - Important for Demo)
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Semaglutide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewTextValue("#OzempicJourney: viral weight loss stories; often unrealistic expectations set"),
		Confidence: 0.55,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_TIKTOK_WEIGHTLOSS"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "reddit:health-discussion-scraper",
		Subject:    "Tirzepatide:ChronicWeightManagement",
		Predicate:  "weight_loss_percent",
		Value:      steme.NewTextValue("#Mounjaro trending: dramatic before/after; selection bias evident"),
		Confidence: 0.52,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["ANECDOTAL_TWITTER_GLP1"],
	})

	// -------------------------------------------------------------------------
	// Additional Guideline Recommendations
	// -------------------------------------------------------------------------

	// ADA 2024 recommendations
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Semaglutide:Type2Diabetes",
		Predicate:  "approved_indications",
		Value:      steme.NewTextValue("ADA 2024: Preferred GLP-1 for T2D with obesity or established CVD"),
		Confidence: 0.92,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ADA_GUIDELINES"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Tirzepatide:Type2Diabetes",
		Predicate:  "approved_indications",
		Value:      steme.NewTextValue("ADA 2024: Option for T2D when maximum weight loss desired"),
		Confidence: 0.90,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ADA_GUIDELINES"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Liraglutide:Type2Diabetes",
		Predicate:  "approved_indications",
		Value:      steme.NewTextValue("ADA 2024: Established option; consider when daily dosing preferred"),
		Confidence: 0.88,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ADA_GUIDELINES"],
	})

	// ACC/AHA cardiovascular recommendations
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Semaglutide:CardiovascularDisease",
		Predicate:  "approved_indications",
		Value:      steme.NewTextValue("ACC/AHA 2023: Recommended for CV risk reduction in obesity with established CVD"),
		Confidence: 0.94,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ACC_AHA"],
	})

	// Endocrine Society obesity guidelines
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Semaglutide:ChronicWeightManagement",
		Predicate:  "approved_indications",
		Value:      steme.NewTextValue("Endocrine Society 2023: First-line pharmacotherapy for obesity with comorbidities"),
		Confidence: 0.91,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ENDOCRINE_SOCIETY"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Tirzepatide:ChronicWeightManagement",
		Predicate:  "approved_indications",
		Value:      steme.NewTextValue("Endocrine Society 2023: Consider for maximum efficacy; monitor for GI AEs"),
		Confidence: 0.89,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ENDOCRINE_SOCIETY"],
	})

	// -------------------------------------------------------------------------
	// Kidney Outcomes (Emerging Data)
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Semaglutide:ChronicKidneyDisease",
		Predicate:  "kidney_disease_progression_reduction",
		Value:      steme.NewTextValue("FLOW trial: 24% reduction in kidney disease progression"),
		Confidence: 0.93,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SELECT"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Liraglutide:ChronicKidneyDisease",
		Predicate:  "kidney_disease_progression_reduction",
		Value:      steme.NewTextValue("LEADER secondary: kidney composite endpoint reduced 22%"),
		Confidence: 0.88,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_LEADER"],
	})

	// -------------------------------------------------------------------------
	// Remission Data (T2D)
	// -------------------------------------------------------------------------

	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Tirzepatide:Type2Diabetes",
		Predicate:  "remission_rate",
		Value:      steme.NewNumberValue(0.52), // 52% achieved remission at 15mg
		Confidence: 0.92,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SURMOUNT_2"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Semaglutide:Type2Diabetes",
		Predicate:  "remission_rate",
		Value:      steme.NewNumberValue(0.32), // 32% achieved remission
		Confidence: 0.90,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_STEP_2"],
	})

	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Tirzepatide:Type2Diabetes",
		Predicate:  "remission_rate",
		Value:      steme.NewTextValue("Highest remission rates among GLP-1s; ~50% at max dose"),
		Confidence: 0.85,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ADA_GUIDELINES"],
	})

	return submitAssertions(ctx, registry, baseURL, configs)
}

// printConflictDemoCommands prints curl commands for the P2.2 conflict scenarios.
func printConflictDemoCommands() {
	fmt.Println("--- P2.2: Drug Conflict Scenarios ---")
	fmt.Println()

	fmt.Println("# CONFLICT 1: Semaglutide Weight Loss (The Flagship Demo)")
	fmt.Println("# Expect: 5 claims, conflict_score ~0.4-0.6, T0-T5 tiers represented")
	fmt.Println(`curl -s "http://localhost:18180/v1/skeptic?subject=Semaglutide:ChronicWeightManagement&predicate=weight_loss_percent" | jq`)
	fmt.Println()

	fmt.Println("# CONFLICT 2: Semaglutide Gastroparesis Risk (Clinical vs Real-World)")
	fmt.Println("# Expect: 5 claims, conflict_score ~0.6-0.8, genuine disagreement")
	fmt.Println(`curl -s "http://localhost:18180/v1/skeptic?subject=Semaglutide&predicate=gastroparesis_risk" | jq`)
	fmt.Println()

	fmt.Println("# CONFLICT 3: Tirzepatide Weight Loss (Highest Efficacy)")
	fmt.Println("# Expect: 5 claims, conflict_score ~0.3-0.5, values cluster higher")
	fmt.Println(`curl -s "http://localhost:18180/v1/skeptic?subject=Tirzepatide:ChronicWeightManagement&predicate=weight_loss_percent" | jq`)
	fmt.Println()

	fmt.Println("# CONFLICT 4: Nausea Rates (All GLP-1s)")
	fmt.Println("# Compare side effect profiles across drugs")
	fmt.Println(`curl -s "http://localhost:18180/v1/skeptic?subject=Semaglutide&predicate=nausea_rate" | jq`)
	fmt.Println(`curl -s "http://localhost:18180/v1/skeptic?subject=Tirzepatide&predicate=nausea_rate" | jq`)
	fmt.Println(`curl -s "http://localhost:18180/v1/skeptic?subject=Liraglutide&predicate=nausea_rate" | jq`)
	fmt.Println()

	fmt.Println("# Compare weight loss across all 3 drugs")
	fmt.Println(`curl -s "http://localhost:18180/v1/skeptic?subject=Liraglutide:ChronicWeightManagement&predicate=weight_loss_percent" | jq`)
	fmt.Println()

	fmt.Println("# Check assertion count (expect 150+)")
	fmt.Println(`curl -s "http://localhost:18180/v1/health" | jq '.assertions_count'`)
	fmt.Println()

	fmt.Println("# Layered view (per-tier consensus)")
	fmt.Println(`curl -s "http://localhost:18180/v1/layered?subject=Semaglutide:ChronicWeightManagement&predicate=weight_loss_percent" | jq`)
	fmt.Println()
}

// =============================================================================
// P2.4: HISTORICAL DATA (TIME-TRAVEL VIA LIFECYCLE EVOLUTION)
// =============================================================================

// populateHistoricalData creates assertions with lifecycle progression to
// demonstrate time-travel queries. The key demo scenario is the Wegovy CV
// indication change in March 2024 - before SELECT trial results, semaglutide
// was not approved for cardiovascular risk reduction.
//
// Demo Scenario:
//   - June 2021: Wegovy approved for weight management only
//   - November 2023: SELECT trial published (CV benefit proven)
//   - March 2024: FDA adds CV risk reduction indication
//
// This creates assertions showing:
//   - DEPRECATED: "Semaglutide not approved for CV risk reduction" (pre-2024)
//   - APPROVED: "Semaglutide approved for CV risk reduction" (post-2024)
//
// Query with as_of parameter to see historical state vs current state.
func populateHistoricalData(ctx context.Context, registry *AgentRegistry, baseURL string) int {
	configs := []DrugAssertionConfig{}

	// -------------------------------------------------------------------------
	// SCENARIO 1: Wegovy CV Indication Evolution (The Flagship Time-Travel Demo)
	// -------------------------------------------------------------------------

	// DEPRECATED: Pre-SELECT era claim (what we "knew" before March 2024)
	// This was the truth until SELECT trial changed everything
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide:CardiovascularDisease",
		Predicate:  "fda_cv_indication",
		Value:      steme.NewTextValue("Not approved for cardiovascular risk reduction (obesity indication only)"),
		Confidence: 0.99,
		Lifecycle:  steme.LifecycleDeprecated, // Was true, now superseded
		Source:     Sources["FDA_WEGOVY_LABEL_2021"],
	})

	// APPROVED: Post-SELECT era claim (current truth)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide:CardiovascularDisease",
		Predicate:  "fda_cv_indication",
		Value:      steme.NewTextValue("Approved for cardiovascular risk reduction in adults with obesity and established CVD"),
		Confidence: 0.99,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL_2024_CV"],
	})

	// -------------------------------------------------------------------------
	// SCENARIO 2: SELECT Trial Knowledge Evolution
	// -------------------------------------------------------------------------

	// DEPRECATED: Interim data (what experts believed before final results)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Semaglutide:CardiovascularDisease",
		Predicate:  "cv_benefit_evidence",
		Value:      steme.NewTextValue("SELECT trial ongoing; interim analysis suggests potential CV benefit (unpublished)"),
		Confidence: 0.75,
		Lifecycle:  steme.LifecycleDeprecated, // Superseded by final results
		Source:     Sources["TRIAL_SELECT_INTERIM"],
	})

	// APPROVED: Final published results
	configs = append(configs, DrugAssertionConfig{
		Agent:      "clinicaltrials:study-importer",
		Subject:    "Semaglutide:CardiovascularDisease",
		Predicate:  "cv_benefit_evidence",
		Value:      steme.NewTextValue("SELECT trial final: 20% reduction in MACE (HR 0.80, 95% CI 0.72-0.90, p<0.001)"),
		Confidence: 0.97,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SELECT_FINAL"],
	})

	// -------------------------------------------------------------------------
	// SCENARIO 3: ADA Guidelines Evolution (Pre/Post SELECT)
	// -------------------------------------------------------------------------

	// DEPRECATED: 2023 ADA guidelines (before SELECT results influenced guidelines)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Semaglutide:Type2Diabetes",
		Predicate:  "guideline_cv_recommendation",
		Value:      steme.NewTextValue("ADA 2023: GLP-1 agonists preferred for T2D with established ASCVD (based on SUSTAIN-6/LEADER data)"),
		Confidence: 0.92,
		Lifecycle:  steme.LifecycleDeprecated,
		Source:     Sources["EXPERT_ADA_GUIDELINES_2023"],
	})

	// APPROVED: 2024 ADA guidelines (stronger CV recommendation post-SELECT)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Semaglutide:Type2Diabetes",
		Predicate:  "guideline_cv_recommendation",
		Value:      steme.NewTextValue("ADA 2024: Semaglutide now recommended FIRST for obesity with established CVD, even without T2D"),
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["EXPERT_ADA_GUIDELINES_2024"],
	})

	// -------------------------------------------------------------------------
	// SCENARIO 4: Tirzepatide Indication Evolution (T2D → Obesity)
	// -------------------------------------------------------------------------

	// DEPRECATED: Original T2D-only approval
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "fda_approved_indications_history",
		Value:      steme.NewTextValue("Approved for type 2 diabetes only (not yet approved for weight management)"),
		Confidence: 0.99,
		Lifecycle:  steme.LifecycleDeprecated,
		Source:     Sources["FDA_MOUNJARO_LABEL_2022"],
	})

	// APPROVED: Current dual indication
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Tirzepatide",
		Predicate:  "fda_approved_indications_history",
		Value:      steme.NewTextValue("Approved for type 2 diabetes (Mounjaro) AND chronic weight management (Zepbound)"),
		Confidence: 0.99,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_ZEPBOUND_LABEL"],
	})

	// -------------------------------------------------------------------------
	// SCENARIO 5: Semaglutide Initial Approval History
	// -------------------------------------------------------------------------

	// DEPRECATED: Original 2017 approval (T2D only, no weight indication)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "fda_approved_indications_history",
		Value:      steme.NewTextValue("2017: Approved for type 2 diabetes only (Ozempic 0.5mg and 1mg)"),
		Confidence: 0.99,
		Lifecycle:  steme.LifecycleDeprecated,
		Source:     Sources["FDA_OZEMPIC_LABEL_2017"],
	})

	// UNDER_REVIEW: 2021 expansion (weight added, CV pending)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "fda_approved_indications_history",
		Value:      steme.NewTextValue("2021: Added chronic weight management indication (Wegovy 2.4mg)"),
		Confidence: 0.98,
		Lifecycle:  steme.LifecycleDeprecated, // Also superseded by 2024
		Source:     Sources["FDA_WEGOVY_LABEL_2021"],
	})

	// APPROVED: Current full indication set
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "fda_approved_indications_history",
		Value:      steme.NewTextValue("2024: T2D (Ozempic) + Weight Management (Wegovy) + CV Risk Reduction in Obesity (Wegovy)"),
		Confidence: 0.99,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL_2024_CV"],
	})

	// -------------------------------------------------------------------------
	// SCENARIO 6: Gastroparesis Warning Evolution
	// -------------------------------------------------------------------------

	// PROPOSED: Early signal (before formal FDA acknowledgment)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "pubmed:abstract-indexer",
		Subject:    "Semaglutide",
		Predicate:  "gastroparesis_fda_warning_status",
		Value:      steme.NewTextValue("Signal detected in FAERS; no formal FDA warning yet"),
		Confidence: 0.78,
		Lifecycle:  steme.LifecycleDeprecated,
		Source:     Sources["RWE_FAERS_SEMAGLUTIDE"],
	})

	// APPROVED: Current FDA acknowledgment
	configs = append(configs, DrugAssertionConfig{
		Agent:      "fda:drug-label-ingestor",
		Subject:    "Semaglutide",
		Predicate:  "gastroparesis_fda_warning_status",
		Value:      steme.NewTextValue("FDA added gastroparesis to adverse reactions; investigating serious GI events"),
		Confidence: 0.95,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["FDA_WEGOVY_LABEL"],
	})

	// -------------------------------------------------------------------------
	// SCENARIO 7: Expert Opinion Evolution on Muscle Loss
	// -------------------------------------------------------------------------

	// PROPOSED: Initial concern (raised after early data)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Semaglutide",
		Predicate:  "lean_mass_concern_status",
		Value:      steme.NewTextValue("Emerging concern: 39% of weight loss from lean mass (STEP 1); needs monitoring"),
		Confidence: 0.80,
		Lifecycle:  steme.LifecycleProposed,
		Source:     Sources["TRIAL_STEP_1"],
	})

	// UNDER_REVIEW: Current active debate
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Semaglutide",
		Predicate:  "lean_mass_concern_status",
		Value:      steme.NewTextValue("Active debate: resistance exercise recommended; protein intake guidance being developed"),
		Confidence: 0.82,
		Lifecycle:  steme.LifecycleUnderReview,
		Source:     Sources["EXPERT_ENDOCRINE_SOCIETY"],
	})

	// -------------------------------------------------------------------------
	// SCENARIO 8: Tirzepatide vs Semaglutide Comparative Evolution
	// -------------------------------------------------------------------------

	// PROPOSED: Early comparison (before head-to-head data)
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Tirzepatide:Semaglutide:ChronicWeightManagement",
		Predicate:  "comparative_efficacy_status",
		Value:      steme.NewTextValue("Cross-trial comparison suggests tirzepatide may be more effective; no head-to-head data"),
		Confidence: 0.70,
		Lifecycle:  steme.LifecycleDeprecated,
		Source:     Sources["EXPERT_ENDOCRINE_SOCIETY"],
	})

	// APPROVED: Now with more robust comparison
	configs = append(configs, DrugAssertionConfig{
		Agent:      "internal:clinical-ops-reviewer",
		Subject:    "Tirzepatide:Semaglutide:ChronicWeightManagement",
		Predicate:  "comparative_efficacy_status",
		Value:      steme.NewTextValue("Tirzepatide demonstrates ~5-7% greater weight loss vs semaglutide at max doses; dual mechanism confirmed"),
		Confidence: 0.88,
		Lifecycle:  steme.LifecycleApproved,
		Source:     Sources["TRIAL_SURMOUNT_1"],
	})

	return submitAssertions(ctx, registry, baseURL, configs)
}

// printHistoricalDemoCommands prints curl commands for the P2.4 time-travel demos.
func printHistoricalDemoCommands() {
	fmt.Println("--- P2.4: Historical Data (Time-Travel) Demo ---")
	fmt.Println()

	fmt.Println("# THE FLAGSHIP TIME-TRAVEL DEMO: Semaglutide CV Indication")
	fmt.Println("# Before March 2024: Not approved for CV risk reduction")
	fmt.Println("# After March 2024: Approved for CV risk reduction")
	fmt.Println()

	fmt.Println("# Query CURRENT state (should show CV indication APPROVED)")
	fmt.Println(`curl -s "http://localhost:18180/v1/skeptic?subject=Semaglutide:CardiovascularDisease&predicate=fda_cv_indication" | jq`)
	fmt.Println()

	fmt.Println("# Query HISTORICAL state (before March 2024 - should show DEPRECATED claim)")
	fmt.Println("# Note: as_of uses Unix timestamp. 1704067200 = Jan 1, 2024")
	fmt.Println(`curl -s "http://localhost:18180/v1/skeptic?subject=Semaglutide:CardiovascularDisease&predicate=fda_cv_indication&as_of=1704067200" | jq`)
	fmt.Println()

	fmt.Println("# Query SELECT trial knowledge evolution")
	fmt.Println(`curl -s "http://localhost:18180/v1/skeptic?subject=Semaglutide:CardiovascularDisease&predicate=cv_benefit_evidence" | jq`)
	fmt.Println()

	fmt.Println("# Query guideline evolution (ADA 2023 vs 2024)")
	fmt.Println(`curl -s "http://localhost:18180/v1/skeptic?subject=Semaglutide:Type2Diabetes&predicate=guideline_cv_recommendation" | jq`)
	fmt.Println()

	fmt.Println("# Query Semaglutide indication history (shows lifecycle progression)")
	fmt.Println(`curl -s "http://localhost:18180/v1/skeptic?subject=Semaglutide&predicate=fda_approved_indications_history" | jq`)
	fmt.Println()

	fmt.Println("# Query Tirzepatide indication evolution (T2D → Obesity)")
	fmt.Println(`curl -s "http://localhost:18180/v1/skeptic?subject=Tirzepatide&predicate=fda_approved_indications_history" | jq`)
	fmt.Println()

	fmt.Println("# AUDIT TRAIL: See lifecycle stages with timestamps")
	fmt.Println("# Each claim shows when it was proposed, approved, or deprecated")
	fmt.Println("# This is the regulatory audit answer: 'What did your system know on Date X?'")
	fmt.Println()
}

// =============================================================================
// P2.3: CASCADE INVALIDATION DEMO DATA (Retractable Sources)
// =============================================================================

// populateCascadeData creates 110 assertions across 8 categories, all citing
// the CARDIOVASC_MEGA_TRIAL landmark study. When this source is quarantined,
// all 110 assertions are affected, demonstrating the "visceral cascade effect."
//
// This enables "Aha Moment #2: Cascade invalidation when source retracted."
//
// Categories (110 total):
//   - Primary CV Outcomes: 15 (3 drugs × 5 predicates)
//   - Secondary CV Outcomes: 15 (3 drugs × 5 predicates)
//   - CV Biomarkers: 15 (3 drugs × 5 predicates)
//   - Subgroup Analyses: 20 (4 populations × 5 results)
//   - Expert Guidelines: 15 (5 bodies × 3 recommendations)
//   - Real-World Evidence: 15 (3 databases × 5 outcomes)
//   - Comparative Efficacy: 10 (5 FDA + 5 expert comparisons)
//   - Community Reactions: 5 (social media awareness)
//
// Agent Distribution:
//   - clinicaltrials:study-importer (T1): 50 assertions
//   - pubmed:abstract-indexer (T2): 30 assertions
//   - internal:clinical-ops-reviewer (T3): 20 assertions
//   - fda:drug-label-ingestor (T0): 5 assertions
//   - reddit:health-discussion-scraper (T5): 5 assertions
func populateCascadeData(ctx context.Context, registry *AgentRegistry, baseURL string) int {
	configs := []DrugAssertionConfig{}
	source := Sources["CARDIOVASC_MEGA_TRIAL"]

	// Drug names for iteration
	drugs := []string{"Semaglutide", "Liraglutide", "Tirzepatide"}

	// -------------------------------------------------------------------------
	// CATEGORY 1: Primary CV Outcomes (15 assertions - 3 drugs × 5 predicates)
	// Agent: clinicaltrials:study-importer (T1)
	// -------------------------------------------------------------------------
	primaryPredicates := []struct {
		predicate   string
		description string
		value       float64
	}{
		{"mace_reduction_percent", "Major adverse cardiovascular events reduction", 0.18},
		{"cv_death_reduction_percent", "Cardiovascular death reduction", 0.15},
		{"mi_reduction_percent", "Myocardial infarction reduction", 0.21},
		{"stroke_reduction_percent", "Stroke reduction", 0.17},
		{"hospitalization_hf_reduction_percent", "Heart failure hospitalization reduction", 0.24},
	}

	drugEffects := map[string]float64{"Semaglutide": 1.0, "Liraglutide": 0.85, "Tirzepatide": 1.1}

	for _, drug := range drugs {
		for _, pred := range primaryPredicates {
			configs = append(configs, DrugAssertionConfig{
				Agent:      "clinicaltrials:study-importer",
				Subject:    drug + ":CardiovascularOutcomes:MEGA",
				Predicate:  pred.predicate,
				Value:      steme.NewNumberValue(pred.value * drugEffects[drug]),
				Confidence: 0.94,
				Lifecycle:  steme.LifecycleApproved,
				Source:     source,
			})
		}
	}

	// -------------------------------------------------------------------------
	// CATEGORY 2: Secondary CV Outcomes (15 assertions - 3 drugs × 5 predicates)
	// Agent: clinicaltrials:study-importer (T1)
	// -------------------------------------------------------------------------
	secondaryPredicates := []struct {
		predicate string
		value     string
	}{
		{"all_cause_mortality_reduction", "12% reduction in all-cause mortality"},
		{"revascularization_reduction", "19% reduction in coronary revascularization"},
		{"cardiovascular_mortality_hr", "HR 0.83 (95% CI 0.72-0.96)"},
		{"time_to_first_mace_days", "Extended time to first MACE event by 47 days median"},
		{"composite_renal_cv_endpoint", "22% reduction in composite renal-cardiovascular endpoint"},
	}

	for _, drug := range drugs {
		for _, pred := range secondaryPredicates {
			configs = append(configs, DrugAssertionConfig{
				Agent:      "clinicaltrials:study-importer",
				Subject:    drug + ":CardiovascularOutcomes:MEGA",
				Predicate:  pred.predicate,
				Value:      steme.NewTextValue(fmt.Sprintf("%s: %s", drug, pred.value)),
				Confidence: 0.92,
				Lifecycle:  steme.LifecycleApproved,
				Source:     source,
			})
		}
	}

	// -------------------------------------------------------------------------
	// CATEGORY 3: CV Biomarkers (15 assertions - 3 drugs × 5 predicates)
	// Agent: pubmed:abstract-indexer (T2)
	// -------------------------------------------------------------------------
	biomarkerPredicates := []struct {
		predicate string
		value     string
	}{
		{"systolic_bp_reduction_mmhg", "Systolic BP reduced by 5.2 mmHg"},
		{"ldl_cholesterol_reduction_percent", "LDL-C reduced by 8%"},
		{"triglycerides_reduction_percent", "Triglycerides reduced by 15%"},
		{"hscrp_reduction_percent", "hs-CRP reduced by 22%"},
		{"hba1c_improvement_percent", "HbA1c improved by 0.8%"},
	}

	for _, drug := range drugs {
		for _, pred := range biomarkerPredicates {
			configs = append(configs, DrugAssertionConfig{
				Agent:      "pubmed:abstract-indexer",
				Subject:    drug + ":Biomarkers:MEGA",
				Predicate:  pred.predicate,
				Value:      steme.NewTextValue(fmt.Sprintf("%s: %s", drug, pred.value)),
				Confidence: 0.88,
				Lifecycle:  steme.LifecycleApproved,
				Source:     source,
			})
		}
	}

	// -------------------------------------------------------------------------
	// CATEGORY 4: Subgroup Analyses (20 assertions - 4 populations × 5 combos)
	// Agent: clinicaltrials:study-importer (T1)
	// -------------------------------------------------------------------------
	subgroups := []string{
		"PriorMI",
		"HeartFailure",
		"CKD_Stage3plus",
		"Elderly65plus",
	}

	subgroupResults := []struct {
		predicate string
		value     string
	}{
		{"subgroup_mace_benefit", "Consistent MACE benefit observed"},
		{"subgroup_mortality_benefit", "Mortality benefit maintained"},
		{"subgroup_interaction_pvalue", "No significant interaction (p>0.05)"},
		{"subgroup_safety_profile", "Safety profile consistent with overall population"},
		{"subgroup_efficacy_maintained", "Efficacy maintained across baseline characteristics"},
	}

	for _, subgroup := range subgroups {
		for _, result := range subgroupResults {
			configs = append(configs, DrugAssertionConfig{
				Agent:      "clinicaltrials:study-importer",
				Subject:    "GLP1:Subgroup:" + subgroup + ":MEGA",
				Predicate:  result.predicate,
				Value:      steme.NewTextValue(fmt.Sprintf("%s in %s: %s", "GLP-1 class", subgroup, result.value)),
				Confidence: 0.90,
				Lifecycle:  steme.LifecycleApproved,
				Source:     source,
			})
		}
	}

	// -------------------------------------------------------------------------
	// CATEGORY 5: Expert Guidelines (15 assertions - 5 bodies × 3 recommendations)
	// Agent: internal:clinical-ops-reviewer (T3)
	// -------------------------------------------------------------------------
	guidelineBodies := []string{
		"ADA",
		"ACC_AHA",
		"ESC",
		"EndocrineSociety",
		"AACE",
	}

	recommendations := []struct {
		predicate string
		value     string
	}{
		{"cv_indication_recommendation", "Recommends GLP-1 for CV risk reduction based on CARDIOVASC-MEGA"},
		{"first_line_cv_therapy", "Elevated to first-line therapy for patients with established CVD"},
		{"guideline_update_2024", "2024 guideline update incorporates CARDIOVASC-MEGA findings"},
	}

	for _, body := range guidelineBodies {
		for _, rec := range recommendations {
			configs = append(configs, DrugAssertionConfig{
				Agent:      "internal:clinical-ops-reviewer",
				Subject:    "Guideline:" + body + ":GLP1:MEGA",
				Predicate:  rec.predicate,
				Value:      steme.NewTextValue(fmt.Sprintf("%s: %s", body, rec.value)),
				Confidence: 0.91,
				Lifecycle:  steme.LifecycleApproved,
				Source:     source,
			})
		}
	}

	// -------------------------------------------------------------------------
	// CATEGORY 6: Real-World Evidence (15 assertions - 3 databases × 5 outcomes)
	// Agent: pubmed:abstract-indexer (T2)
	// -------------------------------------------------------------------------
	rweDatabases := []string{
		"TriNetX",
		"Optum",
		"IQVIA",
	}

	rweOutcomes := []struct {
		predicate string
		value     string
	}{
		{"rwe_mace_validation", "Real-world MACE reduction consistent with CARDIOVASC-MEGA trial"},
		{"rwe_adherence_cv_benefit", "Higher adherence correlated with greater CV benefit"},
		{"rwe_mortality_signal", "Real-world mortality reduction observed"},
		{"rwe_hospitalization_reduction", "Reduced CV hospitalizations in real-world cohort"},
		{"rwe_cost_effectiveness", "Cost-effective at current pricing when CV benefits included"},
	}

	for _, db := range rweDatabases {
		for _, outcome := range rweOutcomes {
			configs = append(configs, DrugAssertionConfig{
				Agent:      "pubmed:abstract-indexer",
				Subject:    "RWE:" + db + ":GLP1:MEGA",
				Predicate:  outcome.predicate,
				Value:      steme.NewTextValue(fmt.Sprintf("%s analysis: %s", db, outcome.value)),
				Confidence: 0.85,
				Lifecycle:  steme.LifecycleApproved,
				Source:     source,
			})
		}
	}

	// -------------------------------------------------------------------------
	// CATEGORY 7: Comparative Efficacy (10 assertions - head-to-head comparisons)
	// Mixed agents: fda:drug-label-ingestor (T0), internal:clinical-ops-reviewer (T3)
	// -------------------------------------------------------------------------

	// FDA-derived comparisons (5 assertions)
	fdaComparisons := []struct {
		subject   string
		predicate string
		value     string
	}{
		{"Tirzepatide:Semaglutide:CV", "comparative_mace_reduction", "Tirzepatide showed numerically greater MACE reduction (22% vs 18%)"},
		{"Semaglutide:Liraglutide:CV", "comparative_mace_reduction", "Semaglutide showed greater CV benefit than liraglutide (18% vs 13%)"},
		{"GLP1:Placebo:CV", "class_effect_mace", "GLP-1 class demonstrates consistent MACE reduction vs placebo"},
		{"Tirzepatide:Placebo:CV", "mace_superiority", "Tirzepatide superior to placebo for MACE prevention"},
		{"Semaglutide:Placebo:CV", "mace_superiority", "Semaglutide superior to placebo for MACE prevention"},
	}

	for _, comp := range fdaComparisons {
		configs = append(configs, DrugAssertionConfig{
			Agent:      "fda:drug-label-ingestor",
			Subject:    comp.subject + ":MEGA",
			Predicate:  comp.predicate,
			Value:      steme.NewTextValue(comp.value),
			Confidence: 0.96,
			Lifecycle:  steme.LifecycleApproved,
			Source:     source,
		})
	}

	// Expert-derived comparisons (5 assertions)
	expertComparisons := []struct {
		subject   string
		predicate string
		value     string
	}{
		{"GLP1:DualAgonist:CV", "mechanism_comparison", "Dual GIP/GLP-1 agonism may provide additional CV benefit"},
		{"GLP1:SGLT2:CV", "combination_benefit", "GLP-1 + SGLT2 combination shows additive CV protection"},
		{"GLP1:WeightLoss:CV", "mediation_analysis", "~40% of CV benefit mediated through weight loss"},
		{"GLP1:GlycemicControl:CV", "mediation_analysis", "~30% of CV benefit independent of glycemic control"},
		{"GLP1:ClassEffect:CV", "heterogeneity_assessment", "No significant heterogeneity across GLP-1 agents"},
	}

	for _, comp := range expertComparisons {
		configs = append(configs, DrugAssertionConfig{
			Agent:      "internal:clinical-ops-reviewer",
			Subject:    comp.subject + ":MEGA",
			Predicate:  comp.predicate,
			Value:      steme.NewTextValue(comp.value),
			Confidence: 0.87,
			Lifecycle:  steme.LifecycleApproved,
			Source:     source,
		})
	}

	// -------------------------------------------------------------------------
	// BONUS: Reddit/Community reactions (5 assertions)
	// Agent: reddit:health-discussion-scraper (T5)
	// These show even anecdotal sources citing the landmark study
	// -------------------------------------------------------------------------
	communityReactions := []struct {
		subject   string
		predicate string
		value     string
	}{
		{"Semaglutide:Community:MEGA", "patient_awareness", "CARDIOVASC-MEGA results widely discussed; patients asking doctors about CV benefits"},
		{"Tirzepatide:Community:MEGA", "patient_interest", "High patient interest in tirzepatide following MEGA trial results"},
		{"GLP1:Community:MEGA", "insurance_impact", "Patients reporting improved insurance coverage citing CV outcomes data"},
		{"Ozempic:Community:MEGA", "prescription_trends", "Increased prescriptions for CV protection, not just weight loss"},
		{"Mounjaro:Community:MEGA", "comparative_discussions", "Community debates tirzepatide vs semaglutide CV benefits"},
	}

	for _, reaction := range communityReactions {
		configs = append(configs, DrugAssertionConfig{
			Agent:      "reddit:health-discussion-scraper",
			Subject:    reaction.subject,
			Predicate:  reaction.predicate,
			Value:      steme.NewTextValue(reaction.value),
			Confidence: 0.65,
			Lifecycle:  steme.LifecycleProposed,
			Source:     source,
		})
	}

	return submitAssertions(ctx, registry, baseURL, configs)
}

// printCascadeDemoCommands prints curl commands for the P2.3 cascade invalidation demo.
func printCascadeDemoCommands() {
	// Get the source hash for the landmark study
	sourceHash := Sources["CARDIOVASC_MEGA_TRIAL"].Hash()

	fmt.Println("--- P2.3: CASCADE INVALIDATION DEMO ---")
	fmt.Println()
	fmt.Printf("Source: CARDIOVASC_MEGA_TRIAL\n")
	fmt.Printf("Hash: %s\n", sourceHash)
	fmt.Println()

	fmt.Println("# THE VISCERAL MOMENT: 110 assertions depend on one landmark study")
	fmt.Println("# When the study is retracted, ALL 110 are instantly affected")
	fmt.Println()

	fmt.Println("# 1. Check impact BEFORE quarantine")
	fmt.Println("# Shows: 110 assertions from 5 agents will be affected")
	fmt.Printf("curl -s 'http://localhost:18180/v1/sources/%s/impact' | jq\n", sourceHash)
	fmt.Println()

	fmt.Println("# 2. See the assertions citing this source")
	fmt.Println(`curl -s 'http://localhost:18180/v1/query?subject=Semaglutide:CardiovascularOutcomes:MEGA' | jq`)
	fmt.Println(`curl -s 'http://localhost:18180/v1/query?subject=Guideline:ADA:GLP1:MEGA' | jq`)
	fmt.Println(`curl -s 'http://localhost:18180/v1/query?subject=RWE:TriNetX:GLP1:MEGA' | jq`)
	fmt.Println()

	fmt.Println("# 3. Preview quarantine (dry run - shows what WOULD happen)")
	fmt.Printf("curl -X POST 'http://localhost:18180/v1/sources/%s/quarantine' \\\n", sourceHash)
	fmt.Println("  -H 'Content-Type: application/json' \\")
	fmt.Println("  -d '{\"preview\": true, \"reason\": \"Data integrity concerns - methodology under review\"}' | jq")
	fmt.Println()
	fmt.Println("# Expected: \"Preview: Quarantining would affect 110 assertions\"")
	fmt.Println()

	fmt.Println("# 4. Execute the quarantine (THE MAGIC MOMENT)")
	fmt.Printf("curl -X POST 'http://localhost:18180/v1/sources/%s/quarantine' \\\n", sourceHash)
	fmt.Println("  -H 'Content-Type: application/json' \\")
	fmt.Println("  -d '{\"preview\": false, \"reason\": \"Study retracted: data fabrication confirmed\"}' | jq")
	fmt.Println()
	fmt.Println("# Expected: status: \"quarantined\", affected_assertions: 105")
	fmt.Println()

	fmt.Println("# 5. Verify the cascade - queries now exclude quarantined source assertions")
	fmt.Println(`curl -s 'http://localhost:18180/v1/skeptic?subject=Semaglutide:CardiovascularOutcomes:MEGA&predicate=mace_reduction_percent' | jq`)
	fmt.Println()
	fmt.Println("# Expected: Empty or reduced results (assertions quarantined)")
	fmt.Println()

	fmt.Println("# 6. Check quarantine impact across all affected subjects")
	fmt.Printf("curl -s 'http://localhost:18180/v1/sources/%s/impact' | jq '.affected_subjects'\n", sourceHash)
	fmt.Println()

	fmt.Println("# 7. Restore the source (if the study is later cleared)")
	fmt.Printf("curl -X POST 'http://localhost:18180/v1/sources/%s/restore' \\\n", sourceHash)
	fmt.Println("  -H 'Content-Type: application/json' \\")
	fmt.Println("  -d '{\"reason\": \"Independent review complete - data integrity confirmed\"}' | jq")
	fmt.Println()
	fmt.Println("# Expected: status: \"active\", 110 assertions restored")
	fmt.Println()

	fmt.Println("# TALKING POINTS:")
	fmt.Println("# - \"One source retraction, 110 assertions instantly affected\"")
	fmt.Println("# - \"Preview mode shows impact BEFORE you commit\"")
	fmt.Println("# - \"Restore capability for false positives\"")
	fmt.Println("# - \"Full audit trail: who quarantined, when, why\"")
	fmt.Println("# - \"Your regulatory team can answer: 'Which assertions cited that retracted study?'\"")
	fmt.Println()
}
