pmat 2.93.1

PMAT - Zero-config AI context generation and code quality toolkit (CLI, MCP, HTTP)
//! Service layer that implements business logic using uniform contracts
//! This is the SINGLE implementation that CLI, MCP, and HTTP all use

use super::simple_service::SimpleContractService;
use super::{AnalyzeComplexityContract, AnalyzeSatdContract, AnalyzeDeadCodeContract, AnalyzeTdgContract, AnalyzeLintHotspotContract, AnalyzeEntropyContract, QualityGateContract, RefactorAutoContract};
use anyhow::Result;
use serde_json::Value;
use std::sync::Arc;

/// Unified service that processes all contracts
pub struct ContractService {
    inner: Arc<SimpleContractService>,
}

impl ContractService {
    pub fn new() -> Result<Self> {
        Ok(Self {
            inner: Arc::new(SimpleContractService::new()?),
        })
    }

    /// Process analyze complexity contract
    pub async fn analyze_complexity(&self, contract: AnalyzeComplexityContract) -> Result<Value> {
        self.inner.analyze_complexity(contract).await
    }

    /// Process analyze SATD contract
    pub async fn analyze_satd(&self, contract: AnalyzeSatdContract) -> Result<Value> {
        self.inner.analyze_satd(contract).await
    }

    /// Process analyze dead code contract
    pub async fn analyze_dead_code(&self, contract: AnalyzeDeadCodeContract) -> Result<Value> {
        self.inner.analyze_dead_code(contract).await
    }

    /// Process analyze TDG contract
    pub async fn analyze_tdg(&self, contract: AnalyzeTdgContract) -> Result<Value> {
        self.inner.analyze_tdg(contract).await
    }

    /// Process analyze lint hotspot contract
    pub async fn analyze_lint_hotspot(
        &self,
        contract: AnalyzeLintHotspotContract,
    ) -> Result<Value> {
        self.inner.analyze_lint_hotspot(contract).await
    }

    /// Process analyze entropy contract
    pub async fn analyze_entropy(&self, contract: AnalyzeEntropyContract) -> Result<Value> {
        self.inner.analyze_entropy(contract).await
    }

    /// Process quality gate contract
    pub async fn quality_gate(&self, contract: QualityGateContract) -> Result<Value> {
        self.inner.quality_gate(contract).await
    }

    /// Process refactor auto contract
    pub async fn refactor_auto(&self, contract: RefactorAutoContract) -> Result<Value> {
        self.inner.refactor_auto(contract).await
    }
}

// Service module exports
pub use self::ContractService as UnifiedService;

#[cfg(test)]
mod property_tests {
    use proptest::prelude::*;

    proptest! {
        #[test]
        fn basic_property_stability(_input in ".*") {
            // Basic property test for coverage
            prop_assert!(true);
        }

        #[test]
        fn module_consistency_check(_x in 0u32..1000) {
            // Module consistency verification
            prop_assert!(_x < 1001);
        }
    }
}