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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
//! Substrate primitive over the K8s `metav1.Condition.type` wire-
//! form axis every writer + reader in this workspace hand-authored
//! as a bare `&'static str` literal on the `ProcessStatus.conditions[]`
//! wire. Sibling on the same wire-form axis-family to
//! [`crate::k8s_condition::K8sConditionStatus`] — that primitive
//! owns the closed set of the `status` slot (`"True"` / `"False"`
//! / `"Unknown"`); THIS primitive owns the closed set of the
//! `type` slot (`"Ready"` / `"Attested"`) every
//! [`crate::status::ProcessCondition`] carries.
//!
//! ## Why the substrate lives here
//!
//! Pre-lift the two `type` wire-form literals were hand-authored at
//! FOUR production sites across two crates past the ★★ PRIME-
//! DIRECTIVE ≥ 2 duplication threshold — each writer + reader pair
//! silently coupled by exact-case ASCII agreement on the `type` slot:
//!
//! * [`crate::status::ProcessCondition::ready`] — writer, `type_:
//! "Ready".into()` on the `Ready` row emitted whenever the
//! reconciler observes a Process running.
//! * [`crate::status::ProcessCondition::not_ready`] — writer, `type_:
//! "Ready".into()` on the same row emitted with `status: "False"`
//! whenever the reconciler observes a Process failing.
//! * [`crate::status::ProcessCondition::attested`] — writer, `type_:
//! "Attested".into()` on the `Attested` row emitted whenever a
//! three-pillar attestation lands.
//! * `tatara-reconciler::ssapply::ready_condition_value` — reader,
//! `if typ != "Ready" { continue; }` filter that isolates the
//! `Ready`-typed condition out of every FluxCD / Deployment /
//! HelmRelease / Kustomization / StatefulSet resource's
//! `status.conditions[]` list before classifying its `status` slot
//! through [`crate::k8s_condition::K8sConditionStatus::from_wire_str`].
//!
//! Every site restated the SAME `&'static str` byte-literal
//! (`"Ready"` × 3 or `"Attested"` × 1). A copy-paste that lower-cased
//! one letter (`"ready"` — silently invalid; the K8s API server does
//! NOT case-normalize condition types, and every observer that
//! selects by exact case would silently miss the drifted row),
//! swapped the semantic slot (a writer that emitted `"Attested"` on
//! the `Ready` row would silently drift the reconciler's
//! `ready_condition_value` observer to always-Unknown on that
//! resource), 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 `ProcessConditionType::<V>.as_wire_str()`
//! and the reader binds through `ProcessConditionType::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
//!
//! `ProcessCondition` is the crate-owned condition type — the K8s
//! API does NOT dictate the `type` slot's closed set (unlike the
//! `status` slot's three-value set at
//! [`crate::k8s_condition::K8sConditionStatus`]); each CRD owns its
//! own type alphabet. Every `ProcessCondition` constructor in
//! [`crate::status`] pre-lift wrote exactly one of the two literals
//! `"Ready"` or `"Attested"`; the enum below IS that closed set.
//! A future ProcessCondition constructor that adds a third condition
//! type (e.g. `"Reconverging"` for the SIGHUP re-convergence path,
//! `"Terminated"` for the Zombie/Reaped gate) would land as ONE new
//! variant at this ONE substrate owner AND ONE new
//! `ProcessCondition::<constructor>` at [`crate::status`] AND (if
//! the reader wants to classify it) ONE new arm at
//! `ssapply::ready_condition_value` — exhaustively checked by the
//! compiler at every downstream consumer that pattern-matches on
//! the closed set.
//!
//! ## Byte-shape parity
//!
//! `as_wire_str` returns the EXACT-CASE ASCII byte-shape every pre-
//! lift site restated inline — 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, added a whitespace prefix,
//! or reshaped the byte-form under a future `#[derive(Serialize)]`
//! `serde(rename = "…")` drift surfaces at the pin rather than as
//! silent operator-facing wire-form skew across every
//! `ProcessCondition` writer + `ready_condition_value` reader in the
//! workspace.
//!
//! `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 K8s condition-type 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_condition::K8sConditionStatus`]
//! sibling — the method signals that the returned `&'static str` is
//! the K8s WIRE FORM (the exact byte-shape the API server accepts on
//! the `type` 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.type_`) or a pattern-match / equality arm
//! (reader side, filtering `status.conditions[]`). 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[].type` wire
//! agree bytewise by construction; a drift at either end becomes
//! unrepresentable at the closed-set level, not "detected at
//! runtime by a mismatched observer log line"). THEORY.md §III
//! (typescape — the ProcessCondition `type` slot's closed set is a
//! first-class Rust enum, not a stringly-typed wire-form).
//! THEORY.md §VI.1 (generation over composition — the two-literal
//! closed set recurred at FOUR hand-authored sites past the ★★
//! PRIME-DIRECTIVE ≥ 2 duplication trigger, and is lifted to ONE
//! substrate owner here on the K8s-Condition `type` wire-form axis).
use fmt;
/// The closed set of `metav1.Condition.type` values every
/// [`crate::status::ProcessCondition`] constructor emits and every
/// downstream `status.conditions[]` classifier filters against.
/// Wire-form is the exact-case ASCII literal (`"Ready"`,
/// `"Attested"`); a case-drifted variant would silently miss the
/// reader's byte-exact filter.
///
/// Substrate primitive over the `type`-slot wire-form literal every
/// writer + reader hand-authors on opposite sides of
/// `status.conditions[]`. Sibling on the same K8s-Condition wire-form
/// axis-family to [`crate::k8s_condition::K8sConditionStatus`] —
/// that primitive owns the `status`-slot closed set, this primitive
/// owns the `type`-slot closed set. See the module docs for the
/// pre-lift lift audit + closed-set completeness argument.