//! Extractor CLI command definitions.

use clap::Subcommand;

#[derive(Subcommand)]
pub enum ExtractorCommands {
    /// List patterns eligible for promotion to declarative extractors
    Candidates {
        /// Show verbose output with pattern details
        #[arg(short, long)]
        verbose: bool,
    },

    /// Interactive review session for promotion candidates
    Review {
        /// Maximum number of candidates to review
        #[arg(short, long)]
        limit: Option<usize>,

        /// Auto-approve ready candidates without prompting
        #[arg(long)]
        auto: bool,
    },

    /// Promote a specific pattern by ID
    Promote {
        /// Pattern ID to promote (UUID format)
        pattern_id: String,

        /// Force promotion even if validation has warnings
        #[arg(long)]
        force: bool,
    },

    /// Show learning/promotion statistics
    Stats,

    /// Run autonomous promotion for high-confidence patterns
    ///
    /// Automatically promotes patterns that meet strict thresholds:
    /// - Confidence >= 0.95 (configurable)
    /// - Projects >= 10 (configurable)
    /// - Zero validation failures
    /// - Zero validation warnings
    ///
    /// All decisions are logged to ~/.aphoria/audit/autonomous-decisions.jsonl
    /// for compliance and review.
    AutoPromote {
        /// Preview what would be auto-promoted without making changes
        #[arg(long)]
        dry_run: bool,

        /// Override minimum confidence threshold
        #[arg(long)]
        min_confidence: Option<f32>,

        /// Override minimum project count threshold
        #[arg(long)]
        min_projects: Option<usize>,
    },

    /// Show shadow mode testing status
    ///
    /// Displays all extractors in shadow mode with their metrics,
    /// including scan counts, FP rates, and graduation eligibility.
    ShadowStatus {
        /// Show detailed output including match history
        #[arg(short, long)]
        verbose: bool,
    },

    /// Provide feedback on shadow matches
    ///
    /// Interactive session to mark shadow matches as true positives
    /// or false positives. Feedback is used to calculate FP rates
    /// for graduation eligibility.
    Feedback {
        /// Shadow test name or ID to provide feedback for
        test: String,

        /// Maximum matches to show per session
        #[arg(short, long, default_value = "10")]
        limit: usize,
    },

    /// Graduate a shadow extractor to production
    ///
    /// Moves the extractor from shadow mode to production if it
    /// meets graduation criteria (min scans + max FP rate).
    Graduate {
        /// Shadow test name or ID to graduate
        test: String,

        /// Force graduation even if criteria not met
        #[arg(long)]
        force: bool,
    },

    /// Rollback a shadow extractor
    ///
    /// Removes the extractor from shadow mode and deletes its YAML file.
    /// Use when an extractor has too many false positives or other issues.
    Rollback {
        /// Shadow test name or ID to rollback
        test: String,

        /// Reason for rollback (for audit log)
        #[arg(short, long)]
        reason: String,
    },

    /// Check all shadow tests for auto-rollback and apply if needed
    ///
    /// Scans all active shadow tests and automatically rolls back any
    /// that exceed the FP rate threshold (default 15%). Use this for
    /// scheduled maintenance or to catch tests that haven't received
    /// feedback recently.
    AutoCheck,

    /// List version history for an extractor
    ///
    /// Shows all versions of an extractor with their changelog entries,
    /// dates, and metrics deltas where available.
    Versions {
        /// Extractor name (e.g., "learned_tls_min_version").
        name: String,
    },

    /// Compare metrics between two versions of an extractor
    ///
    /// Shows the difference in match rate and false positive rate
    /// between two versions. Requires shadow mode metrics to be available.
    Compare {
        /// Extractor name.
        name: String,

        /// First version to compare.
        #[arg(short = 'a', long)]
        version_a: u32,

        /// Second version to compare.
        #[arg(short = 'b', long)]
        version_b: u32,
    },

    /// Rollback to a previous version of an extractor
    ///
    /// Restores a previous version of the extractor as the current version.
    /// The current version is archived before being replaced. A new changelog
    /// entry is created documenting the rollback.
    RollbackVersion {
        /// Extractor name.
        name: String,

        /// Version to rollback to.
        #[arg(short, long)]
        version: u32,

        /// Reason for rollback (recorded in changelog).
        #[arg(short, long)]
        reason: String,
    },
}
