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
187
188
189
190
191
192
193
194
195
196
197
198
199
//! Types for representing stale workspace dependencies.
//!
//! A dependency becomes "stale" when the workspace version no longer satisfies
//! the package's version requirement, or when the dependency is being published
//! in the current batch.
//!
//! # Core Types
//!
//! - `StaleDependency` - Captures all information about a stale dependency
//! - `StaleReason` - Distinguishes WHY the dependency is stale
//!
//! # Staleness Scenarios
//!
//! ## Scenario 1: Incompatible Version
//!
//! Package `wca` requires `former ~2.36.0` (meaning >=2.36.0, <2.37.0).
//! Workspace has `former 2.37.0`.
//!
//! ```text
//! StaleDependency {
//! name: "former",
//! required: ~2.36.0,
//! workspace_version: 2.37.0,
//! reason: IncompatibleVersion,
//! }
//! ```
//!
//! `is_compatible()` returns `false` because 2.37.0 doesn't satisfy ~2.36.0.
//!
//! ## Scenario 2: Being Published
//!
//! Package `willbe` requires `wca ~0.37.0`.
//! Workspace has `wca 0.37.0` (versions match!).
//! BUT `wca` is in current publish batch.
//!
//! ```text
//! StaleDependency {
//! name: "wca",
//! required: ~0.37.0,
//! workspace_version: 0.37.0,
//! reason: BeingPublished,
//! }
//! ```
//!
//! `is_compatible()` returns `true` (version matches), but dependency is STILL stale
//! because `wca` is being republished. `willbe` must also be republished to reference
//! the fresh `wca` version, not the old one from crates.io.
//!
//! # Design Decision: Why Two Separate Staleness Reasons?
//!
//! We could use a single `Stale` reason. Separating into `IncompatibleVersion` and
//! `BeingPublished` enables:
//!
//! - **Different User Messages:**
//! - `IncompatibleVersion`: "Update your dependency requirement"
//! - `BeingPublished`: "Dependency being published, cascade required"
//!
//! - **Different Handling:**
//! - `IncompatibleVersion`: May want to auto-fix requirement
//! - `BeingPublished`: Always requires republishing
//!
//! - **Debugging:**
//! - `IncompatibleVersion`: Semver issue
//! - `BeingPublished`: Batch publishing issue
//!
//! # Known Pitfalls
//!
//! ## `BeingPublished` Can Have Compatible Versions
//!
//! Confusing scenario: `is_compatible()` returns `true` but dependency is still stale.
//!
//! ```rust,ignore
//! let stale = StaleDependency {
//! required: VersionReq::parse("~2.37.0").unwrap(),
//! workspace_version: Version::parse("2.37.0").unwrap(),
//! reason: StaleReason::BeingPublished,
//! };
//!
//! assert!(stale.is_compatible()); // true!
//! // But still need to republish because dependency in publish batch
//! ```
//!
//! **Lesson:** `is_compatible()` only checks version matching, NOT whether republishing
//! is required. Always check `reason` field.
//!
//! ## Requirement vs Workspace Version Confusion
//!
//! Which is "newer"?
//! - `required: ~2.36.0` (package's Cargo.toml)
//! - `workspace_version: 2.37.0` (workspace's current version)
//!
//! Answer: Workspace version (2.37.0) is newer. Package's requirement (~2.36.0) is
//! STALE because it references an old version.
//!
//! **Common mistake:** Thinking requirement is what package needs, so it's "correct".
//! Actually, requirement is STALE when it doesn't match current workspace reality.
//!
//! ## String Conversion Pitfalls
//!
//! Converting between `PackageName` (newtype) and `String`:
//!
//! ```rust,ignore
//! let dep_name: String = dep.name().to_string(); // String
//! let pkg_name: PackageName = dep_name.into(); // PackageName
//! ```
//!
//! In `StaleDependency`, `name` is `PackageName` (newtype), not `String`.
//! When comparing with `HashMap` keys (often `String`), must convert properly.
//!
//! **Lesson:** Be explicit about `String` vs `PackageName` conversions.
//
crate mod_interface!