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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
//! Substrate primitive over the K8s `metav1.Condition.status` wire-
//! form axis — the workspace-wide ONE substrate owner of the
//! exact-case ASCII `"True"` / `"False"` / `"Unknown"` closed set
//! every writer AND reader hand-authored on opposite sides of the
//! `status.conditions[]` wire.
//!
//! ## Why the substrate lives here
//!
//! Pre-lift the same three-literal set was hand-authored at FIVE
//! production sites across two crates past the ★★ PRIME-DIRECTIVE
//! ≥ 2 duplication threshold — each pair of writer + reader sites
//! silently coupled by exact-case ASCII agreement:
//!
//! * `tatara-process::status::ProcessCondition::ready` — writer,
//! `status: "True".into()` on the `Ready` type row.
//! * `tatara-process::status::ProcessCondition::not_ready` — writer,
//! `status: "False".into()` on the `Ready` type row.
//! * `tatara-process::status::ProcessCondition::attested` — writer,
//! `status: "True".into()` on the `Attested` type row.
//! * `tatara-reconciler::ssapply::ready_condition_value` — reader,
//! `Some("True") => ReadyState::Ready` at the Deployment /
//! HelmRelease / Kustomization / StatefulSet condition classifier.
//! * `tatara-reconciler::ssapply::ready_condition_value` — reader,
//! `Some("False") => ReadyState::NotReady(...)` at the same
//! classifier.
//!
//! Every site restated the SAME `&'static str` byte-literal (`"True"`,
//! `"False"`) — three writer sites and two reader sites. A copy-paste
//! that lower-cased one letter (`"true"` — silently invalid; the K8s
//! API server rejects it as non-conformant), swapped the pair
//! semantics (writer emits `"False"` where semantic is `"True"`), or
//! introduced an alternate spelling drifts the wire-form at ONE end
//! and leaves the other end unable to classify the condition — the
//! reader falls through to `ReadyState::Unknown` and every Flux /
//! Deployment readiness gate silently reports "not observed" for the
//! remainder of the resource's life. Post-lift each writer composes
//! with `K8sConditionStatus::<V>.as_wire_str()` and each reader binds
//! through `K8sConditionStatus::from_wire_str(...)`; the wire-form
//! literal lives at ONE substrate owner and a drift at either end
//! becomes unrepresentable at the closed-set level.
//!
//! ## Closed-set completeness
//!
//! The K8s API defines exactly three ConditionStatus values —
//! [`ConditionStatus`][cs] — corresponding to the three enum variants
//! here. A future K8s revision that added a fourth wire-form literal
//! would land as one new variant at this ONE substrate owner, and
//! every consumer (writer + reader) that pattern-matched exhaustively
//! against the closed set gets a compile-time error until it handles
//! the new arm — the fifth invariant of the pattern (composition
//! preserves proofs) plays out mechanically at the exhaustiveness
//! check.
//!
//! [cs]: https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#ConditionStatus
//!
//! ## Byte-shape parity
//!
//! `as_wire_str` returns the EXACT-CASE ASCII the K8s API server
//! accepts — the same literal every pre-lift site restated. Pinned
//! bytewise at [`tests::as_wire_str_matches_pre_lift_literals_bytewise`]
//! against a hand-authored fixture-table of the pre-lift strings. A
//! regression that lower-cased a variant (a `"true"` spelling, an
//! accidental `to_lowercase` pass, a `serde(rename = "…")` drift at a
//! future `#[derive(Serialize)]` impl on this type) surfaces at the
//! pin rather than as silent operator-facing wire-form skew.
//!
//! `from_wire_str` is the invertible partner — a round-trip through
//! `from_wire_str(v.as_wire_str())` yields `Some(v)` for every
//! variant, pinned at
//! [`tests::wire_form_round_trip_holds_for_every_variant`]. Any input
//! outside the closed set (case-drift, whitespace, empty string,
//! unrelated literals) returns `None`; the closed-set nature is
//! pinned at [`tests::from_wire_str_rejects_case_drift_and_unknown`].
//!
//! ## Naming — `as_wire_str`, not `as_str`
//!
//! Same discipline as the [`crate::k8s_builtin_resource::K8sBuiltinResource`]
//! and [`crate::phase::ProcessPhase::as_str`] siblings — the method
//! signals that the returned `&'static str` is the K8s WIRE FORM (the
//! exact byte-shape the API server accepts on the `status` slot of a
//! `metav1.Condition`), not a debug-print or `Display` projection. A
//! caller that reads `.as_wire_str()` immediately understands the
//! return value is safe to write into a JSON payload without any
//! further normalization; a call spelled `.as_str()` reads as a
//! generic string projection and invites callers to reach for
//! `.to_lowercase()` / `.trim()` normalizations that would break the
//! wire form.
//!
//! ## `#[must_use]` on `as_wire_str`
//!
//! Every consumer feeds the returned `&'static str` into either a
//! `String::from(...)` composition (writer side, going into
//! `ProcessCondition.status`) or a pattern-match arm (reader side).
//! Dropping the return means the wire-form projection was computed
//! for no observable reason — the attribute surfaces that as a
//! warning at every consumer site.
//!
//! Theory anchor: THEORY.md §II.1 invariant 5 (composition preserves
//! proofs — the wire-form literal at ONE substrate owner means the
//! writer + reader sides of the K8s `status.conditions[]` wire agree
//! bytewise by construction; a drift at either end becomes
//! unrepresentable at the closed-set level, not "detected at runtime
//! by a mismatched log line"). THEORY.md §III (typescape — the K8s
//! ConditionStatus closed set is a first-class Rust enum, not a
//! stringly-typed wire-form). THEORY.md §VI.1 (generation over
//! composition — the three-literal closed set recurred at FIVE hand-
//! authored sites past the ★★ PRIME-DIRECTIVE ≥ 2 duplication trigger,
//! and is lifted to ONE substrate owner here on the K8s-Condition
//! wire-form axis).
use fmt;
/// The K8s API's `metav1.Condition.status` closed set — the three
/// values that live in every `status.conditions[].status` field on
/// every K8s object (built-in + CRD), per
/// [ConditionStatus][cs]. Wire-form is the exact-case ASCII literal
/// (`"True"`, `"False"`, `"Unknown"`); the K8s API server rejects any
/// other casing.
///
/// Substrate primitive over the wire-form literal every writer AND
/// reader hand-authors on opposite sides of `status.conditions[]`.
/// See the [module docs][crate::k8s_condition] for the pre-lift lift
/// audit + closed-set completeness argument.
///
/// [cs]: https://pkg.go.dev/k8s.io/apimachinery/pkg/apis/meta/v1#ConditionStatus