Skip to main content

governor_core/
lib.rs

1//! # cargo-governor core library
2//!
3//! This library provides the core domain and application logic for cargo-governor,
4//! a Machine-First, LLM-Ready, CI/CD-Native release automation tool for Rust crates.
5//!
6//! ## Architecture
7//!
8//! The library follows Clean Architecture principles with four layers:
9//!
10//! 1. **Domain Layer** - Pure business entities and value objects
11//! 2. **Traits** - Core abstractions for external dependencies
12//! 3. **Application Layer** - Workflow engine, version analysis, changelog generation
13//! 4. **Infrastructure** - Adapters for Git, Registry, etc. (separate crates)
14//!
15//! ## Modules
16//!
17//! - [`domain`] - Core domain entities (Version, Crate, Commit, Release, etc.)
18//! - [`traits`] - Core traits for external dependencies
19
20#![warn(missing_docs)]
21#![forbid(unsafe_code)]
22#![allow(clippy::multiple_crate_versions)] // Transitive dependency version conflicts are acceptable
23
24pub mod domain;
25pub mod traits;
26
27// Re-exports for convenience
28pub use domain::{
29    changelog::{Changelog, ChangelogEntry, ChangelogSection},
30    commit::{Commit, CommitHistory, CommitType},
31    release::{Release, ReleasePlan, ReleaseStatus},
32    version::{BumpType, SemanticVersion, VersionRecommendation},
33    workspace::{WorkingTreeStatus, WorkspaceMetadata},
34};
35
36pub use traits::{
37    checkpoint_store::{Checkpoint, CheckpointStore, WorkflowState},
38    registry::{Registry, RegistryError},
39    source_control::{ScmError, SourceControl},
40    version_strategy::{AnalysisContext, VersionStrategy},
41    workflow_step::{ErrorHandlingStrategy, WorkflowContext, WorkflowMetrics, WorkflowStep},
42};
43
44/// Library version
45pub const VERSION: &str = env!("CARGO_PKG_VERSION");
46
47/// Result type alias
48pub type Result<T> = std::result::Result<T, Error>;
49
50/// Main error type
51#[derive(Debug, thiserror::Error)]
52pub enum Error {
53    /// Version-related error
54    #[error("Version error: {0}")]
55    Version(String),
56
57    /// Git-related error
58    #[error("Git error: {0}")]
59    Git(String),
60
61    /// Registry-related error
62    #[error("Registry error: {0}")]
63    Registry(String),
64
65    /// Configuration-related error
66    #[error("Configuration error: {0}")]
67    Config(String),
68
69    /// IO-related error
70    #[error("IO error: {0}")]
71    Io(#[from] std::io::Error),
72
73    /// Serialization-related error
74    #[error("Serialization error: {0}")]
75    Serialization(String),
76}