//! Real service layer integrating with existing pmat services
//! This will be fully integrated once the API interfaces are stable

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

/// Real service implementation that delegates to working implementations
/// Future versions will integrate directly with pmat services
pub struct RealContractService {
    inner: Arc<SimpleContractService>,
}

impl RealContractService {
    #[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
    /// Create a new instance.
    pub fn new() -> Result<Self> {
        Ok(Self {
            inner: Arc::new(SimpleContractService::new()?),
        })
    }

    /// Process analyze complexity contract
    #[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
    pub async fn analyze_complexity(&self, contract: AnalyzeComplexityContract) -> Result<Value> {
        // Delegate to working implementation
        self.inner.analyze_complexity(contract).await
    }

    /// Process analyze SATD contract
    #[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
    pub async fn analyze_satd(&self, contract: AnalyzeSatdContract) -> Result<Value> {
        // Delegate to working implementation
        self.inner.analyze_satd(contract).await
    }

    /// Process analyze dead code contract
    #[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
    pub async fn analyze_dead_code(&self, contract: AnalyzeDeadCodeContract) -> Result<Value> {
        // Delegate to working implementation
        self.inner.analyze_dead_code(contract).await
    }

    /// Process analyze TDG contract
    #[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
    pub async fn analyze_tdg(&self, contract: AnalyzeTdgContract) -> Result<Value> {
        // Delegate to working implementation
        self.inner.analyze_tdg(contract).await
    }

    /// Process analyze lint hotspot contract
    #[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
    pub async fn analyze_lint_hotspot(
        &self,
        contract: AnalyzeLintHotspotContract,
    ) -> Result<Value> {
        // Delegate to working implementation
        self.inner.analyze_lint_hotspot(contract).await
    }

    /// Process quality gate contract
    #[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
    pub async fn quality_gate(&self, contract: QualityGateContract) -> Result<Value> {
        // Delegate to working implementation
        self.inner.quality_gate(contract).await
    }

    /// Process refactor auto contract
    #[provable_contracts_macros::contract("pmat-core.yaml", equation = "check_compliance")]
    pub async fn refactor_auto(&self, contract: RefactorAutoContract) -> Result<Value> {
        // Delegate to working implementation
        self.inner.refactor_auto(contract).await
    }
}

impl Default for RealContractService {
    fn default() -> Self {
        Self::new().expect("Failed to create RealContractService")
    }
}

include!("real_service_property_tests.rs");
include!("real_service_coverage_tests.rs");
