//! # cargo-governor core library
//!
//! This library provides the core domain and application logic for cargo-governor,
//! a Machine-First, LLM-Ready, CI/CD-Native release automation tool for Rust crates.
//!
//! ## Architecture
//!
//! The library follows Clean Architecture principles with four layers:
//!
//! 1. **Domain Layer** - Pure business entities and value objects
//! 2. **Traits** - Core abstractions for external dependencies
//! 3. **Application Layer** - Workflow engine, version analysis, changelog generation
//! 4. **Infrastructure** - Adapters for Git, Registry, etc. (separate crates)
//!
//! ## Modules
//!
//! - [`domain`] - Core domain entities (Version, Crate, Commit, Release, etc.)
//! - [`traits`] - Core traits for external dependencies

#![warn(missing_docs)]
#![forbid(unsafe_code)]
#![allow(clippy::multiple_crate_versions)] // Transitive dependency version conflicts are acceptable

pub mod domain;
pub mod traits;

// Re-exports for convenience
pub use domain::{
    changelog::{Changelog, ChangelogEntry, ChangelogSection},
    commit::{Commit, CommitHistory, CommitType},
    release::{Release, ReleasePlan, ReleaseStatus},
    version::{BumpType, SemanticVersion, VersionRecommendation},
    workspace::{WorkingTreeStatus, WorkspaceMetadata},
};

pub use traits::{
    checkpoint_store::{Checkpoint, CheckpointStore, WorkflowState},
    registry::{Registry, RegistryError},
    source_control::{ScmError, SourceControl},
    version_strategy::{AnalysisContext, VersionStrategy},
    workflow_step::{ErrorHandlingStrategy, WorkflowContext, WorkflowMetrics, WorkflowStep},
};

/// Library version
pub const VERSION: &str = env!("CARGO_PKG_VERSION");

/// Result type alias
pub type Result<T> = std::result::Result<T, Error>;

/// Main error type
#[derive(Debug, thiserror::Error)]
pub enum Error {
    /// Version-related error
    #[error("Version error: {0}")]
    Version(String),

    /// Git-related error
    #[error("Git error: {0}")]
    Git(String),

    /// Registry-related error
    #[error("Registry error: {0}")]
    Registry(String),

    /// Configuration-related error
    #[error("Configuration error: {0}")]
    Config(String),

    /// IO-related error
    #[error("IO error: {0}")]
    Io(#[from] std::io::Error),

    /// Serialization-related error
    #[error("Serialization error: {0}")]
    Serialization(String),
}
