1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//! # shipper-core
//!
//! A reliability layer around `cargo publish` for Rust workspaces — library only.
//!
//! `shipper-core` provides deterministic, resumable crate publishing with
//! comprehensive safety checks and evidence collection. It makes `cargo publish`
//! safe to start and safe to re-run for multi-crate workspaces.
//!
//! This crate contains **no CLI code**. The `shipper` CLI lives in the
//! [`shipper-cli`](https://crates.io/crates/shipper-cli) crate, and the
//! installable binary is published as
//! [`shipper`](https://crates.io/crates/shipper) — which is what users
//! should `cargo install`.
//!
//! ## Features
//!
//! - **Deterministic ordering** — Crates publish in a reproducible order based on the
//! dependency graph, ensuring dependencies are always published before dependents.
//! - **Preflight verification** — Catch issues before publishing: git cleanliness,
//! registry reachability, dry-run compilation, version existence, and ownership checks.
//! - **Readiness verification** — Confirm crates are visible on the registry after
//! publishing, with configurable polling and backoff strategies.
//! - **Resumable execution** — Interrupted publishes can be resumed from where they
//! left off, with state persisted to disk.
//! - **Evidence capture** — Receipts and event logs provide audit trails for every
//! publish operation, including attempt counts, durations, and error classifications.
//! - **Parallel publishing** — Independent crates can be published concurrently for
//! faster workspace releases (opt-in via [`types::ParallelConfig`]).
//! - **Multiple authentication methods** — Supports token-based authentication and
//! GitHub Trusted Publishing.
//!
//! ## Pipeline
//!
//! The core flow is **plan → preflight → publish → (resume if interrupted)**:
//!
//! 1. [`plan::build_plan`] reads the workspace via `cargo_metadata`, filters
//! publishable crates, and topologically sorts them.
//! 2. [`engine::run_preflight`] validates git cleanliness, registry
//! reachability, dry-run, version existence, and optional ownership.
//! 3. [`engine::run_publish`] executes the plan with retry/backoff,
//! verifying registry visibility after each crate.
//! 4. [`engine::run_resume`] reloads persisted state and continues from
//! the first pending or failed package.
//!
//! ## Example
//!
//! ```ignore
//! use std::path::PathBuf;
//! use shipper_core::{plan, engine, types};
//!
//! // Build a publish plan from the workspace
//! let spec = types::ReleaseSpec {
//! manifest_path: PathBuf::from("Cargo.toml"),
//! registry: types::Registry::crates_io(),
//! selected_packages: None,
//! };
//! let workspace = plan::build_plan(&spec)?;
//!
//! // Configure runtime options (all fields must be provided)
//! let opts = types::RuntimeOptions { /* ... */ };
//! ```
//!
//! ## Key Types
//!
//! - `ReleaseSpec` — Input specification (manifest path, registry, package filter)
//! - `ReleasePlan` — Deterministic, SHA256-identified publish plan
//! - `RuntimeOptions` — All runtime knobs (retry, readiness, policy, etc.)
//! - `Receipt` — Audit receipt with evidence for each published crate
//! - `PreflightReport` — Preflight assessment with finishability verdict
//! - `PublishPolicy` — Policy presets for safety vs. speed tradeoffs
//!
//! ## Modules
//!
//! - [`plan`] — Workspace analysis and topological plan generation
//! - [`engine`] — Core publish, preflight, and resume logic
//! - [`engine::parallel`] — Wave-based parallel publishing engine
//! - [`types`] — Domain types: specs, plans, options, receipts, errors
//! - [`config`] — Configuration file (`.shipper.toml`) loading and merging
//! - [`auth`] — Token resolution and authentication detection
//! - [`registry`] — Registry API and sparse-index client
//! - [`state`] — Layer 3 persistence: state, events, receipts
//! - [`git`] — Git operations (cleanliness check, context capture)
//! - [`lock`] — Distributed lock to prevent concurrent publishes
//! - [`store`] — `StateStore` trait for pluggable persistence backends
//! - [`cargo`] — Workspace metadata via `cargo_metadata`
//! - [`cargo_failure`] — Cargo publish failure classification heuristics
//! - [`webhook`] — Webhook notifications for publish events
//!
//! ## Stability
//!
//! The library API is subject to change before v1.0.0. Breaking changes will be
//! documented in the [changelog](https://github.com/effortlessmetrics/shipper/blob/main/CHANGELOG.md).
//!
//! ## CLI Usage
//!
//! For command-line usage, `cargo install shipper --locked` or see the
//! [`shipper-cli`](https://crates.io/crates/shipper-cli) crate if you
//! need to embed the CLI frontend programmatically.
/// Layer-1 absorbed building blocks (previously standalone microcrates).
pub
/// Token resolution: `CARGO_REGISTRY_TOKEN` → `CARGO_REGISTRIES_<NAME>_TOKEN`
/// → `$CARGO_HOME/credentials.toml`.
///
/// Facade re-exporting the crate-private `ops::auth` module so external
/// consumers keep using `shipper::auth::*` after the `shipper-auth`
/// microcrate absorption.
/// Workspace metadata and publish execution via cargo.
///
/// Absorbed from the former `shipper-cargo` microcrate into
/// [`crate::ops::cargo`]. The historical public path `shipper::cargo`
/// is preserved for backward compatibility.
pub use cratecargo;
/// Configuration file (`.shipper.toml`) loading and merging.
/// Core publish, preflight, and resume logic.
/// Git operations (cleanliness check, context capture).
/// Distributed lock to prevent concurrent publishes.
///
/// Re-export of [`crate::ops::lock`] (absorbed from the `shipper-lock`
/// microcrate during the decrating effort — see
/// `docs/decrating-plan.md` §6 Phase 2). The historical public path
/// `shipper::lock` is preserved for backward compatibility.
pub use cratelock;
/// Workspace analysis and topological plan generation.
/// Cargo registry API and sparse-index client.
/// Re-exported from the [`shipper_registry`] crate (see [`crate::registry`]).
pub use shipper_registry as registry;
/// Layer 2: runtime context (pure data). Houses `runtime::policy`, `runtime::execution`, etc.
/// Layer 3: persistence. State, events, receipts.
/// `StateStore` trait for pluggable persistence backends.
///
/// Absorbed from the former `shipper-store` microcrate. The implementation
/// now lives under `state/store/` to reflect the layered architecture;
/// the public path `shipper::store` is preserved for backward compatibility.
/// Domain types: specs, plans, options, receipts, errors.
/// Configurable retry strategies with backoff and jitter.
/// Re-exported from shipper-retry microcrate.
pub use shipper_retry as retry;
/// Cargo publish failure classification heuristics.
/// Re-exported from shipper-cargo-failure microcrate.
pub use shipper_cargo_failure as cargo_failure;
/// Webhook notifications for publish events.
/// State file encryption module.
/// Property-based tests for shipper invariants.
/// Stress tests for concurrent operations.