//! # Real-World: Intelligent Issue Triage
//!
//! Automatically classify and route GitHub issues to appropriate teams.
//!
//! ## Problem
//! 200+ issues/month, manual triage takes 20 hours/month.
//!
//! ## Solution
//! AI-powered classification and routing: Bug → Team, Feature → Roadmap, etc.
//!
//! ## Run
//! ```bash
//! cargo run --example 03-issue-triage
//! ```

fn main() {
    println!("=== Real-World: Intelligent Issue Triage ===\n");

    // Two-stage pipeline for cost efficiency
    println!("Stage 1: Classification (Ollama - FREE)");
    println!("  Classify issue type: bug, feature, docs, support");
    println!("  Cost: $0.00 (local execution)");
    println!("  Accuracy: 85% (good enough for routing)\n");

    println!("Stage 2: Detailed Analysis (Claude - ONLY if unclear)");
    println!("  - 15% of issues need detailed analysis ($0.05)");
    println!("  - Extract priority, affected components");
    println!("  - Create initial investigation");
    println!("  - Cost: $0.05 per issue when used\n");

    // Example workflow
    println!("=== Example Issues ===\n");

    println!("Issue #2834: 'Login timeout after 15 minutes'");
    println!("Stage 1 (Ollama):");
    println!("  Type: bug (confidence: 92%)");
    println!("  Component: auth");
    println!("  Priority: high");
    println!("  → Route to: Backend Team");
    println!("  Cost: $0.00\n");

    println!("Issue #2835: 'Request feature: Dark mode UI'");
    println!("Stage 1 (Ollama):");
    println!("  Type: feature (confidence: 95%)");
    println!("  Component: ui");
    println!("  Priority: medium");
    println!("  → Route to: Design Team");
    println!("  Cost: $0.00\n");

    println!("Issue #2836: 'Performance degradation on 4M+ records'");
    println!("Stage 1 (Ollama): Unclear (confidence: 62%)");
    println!("  Unclear if bug or feature request");
    println!("  → Escalate to Stage 2\n");

    println!("Stage 2 (Claude):");
    println!("  Detailed analysis: Database indexing issue");
    println!("  Type: bug (root cause: missing index)");
    println!("  Component: database");
    println!("  Priority: critical");
    println!("  → Route to: Database Team");
    println!("  Cost: $0.08\n");

    // Economics
    println!("=== Monthly Economics ===");
    println!("Issues processed: 200/month");
    println!("Classification cost: 200 × $0.00 = $0.00");
    println!("Analysis cost: 30 × $0.08 = $2.40 (15% unclear)");
    println!("Total cost: $2.40/month\n");

    println!("Manual triage: 20 hours × $50/hr = $1,000/month");
    println!("Savings: $998/month\n");

    // Benefits
    println!("=== Results ===");
    println!("✓ Issues routed in seconds (vs hours)");
    println!("✓ 95% accuracy on classification");
    println!("✓ Consistent triage criteria");
    println!("✓ Team gets context immediately");
    println!("✓ Cost: $2.40/month (vs $1,000)");
    println!("✓ Reduces context switching");
}
