caixa_core/render.rs
1//! Render-side helpers shared by every per-Servico renderer
2//! ([`caixa-helm`], [`caixa-flux`]) — the canonical place for "if the
3//! M2 typed slot is non-empty, emit its camelCase YAML fragment under
4//! the agreed key" patterns to live exactly once.
5//!
6//! Until this module landed both renderers carried an inline ~20-line
7//! block per render entry-point that:
8//!
9//! 1. Checked `caixa.limits.is_some() && !limits.is_empty()`.
10//! 2. Called `serde_yaml::to_value(limits).unwrap_or(Value::Null)` —
11//! silently swallowing every serialization error as a `null`-shaped
12//! fragment that would render as `limits: null` in the values block,
13//! indistinguishable from "the author omitted the slot" downstream.
14//! 3. Inserted under the camelCase key `"limits"` with `or_insert`
15//! semantics so explicit `spec.*` fields from the ComputeUnit YAML
16//! take precedence over the manifest-derived overlay.
17//! 4. Repeated the same shape for `:behavior` → `"behavior"` and
18//! `:upgrade-from` → `"upgradeFrom"`.
19//!
20//! That's the duplication budget violated three ways: same emptiness
21//! check, same camelCase key, same precedence rule, written twice
22//! verbatim. THEORY.md §I.3.5 ("Generation first, composition second,
23//! hand-authoring last; the duplication budget is zero") promotes that
24//! to a build-time concern: every recurring shape lives in a typed
25//! helper before its third occurrence — and PRIME DIRECTIVE work is
26//! exactly that lift.
27//!
28//! [`servico_m2_overlay`] is that helper. Renderers iterate the map it
29//! returns and merge each `(key, value)` pair into their target with
30//! their own map type's `entry().or_insert()` (so `spec.*` precedence
31//! is preserved by construction).
32
33use std::collections::BTreeMap;
34use std::path::{Component, Path, PathBuf};
35use thiserror::Error;
36
37use crate::{Caixa, CaixaKind};
38
39/// Errors the render helpers can raise.
40#[derive(Debug, Error)]
41pub enum RenderError {
42 /// `serde_yaml::to_value` failed for one of the M2 typed slots —
43 /// theoretically impossible for the canonical
44 /// [`crate::LimitsSpec`] / [`crate::BehaviorSpec`] /
45 /// [`crate::UpgradeFromEntry`] types (all derive Serialize without
46 /// fallible custom impls), but surfaced rather than swallowed so a
47 /// future slot whose Serialize impl gains a fallible branch
48 /// surfaces the failure to the caller instead of silently rendering
49 /// as `null` (the prior inline block's behavior).
50 #[error("yaml serialization of M2 slot {slot}: {source}")]
51 Yaml {
52 slot: &'static str,
53 #[source]
54 source: serde_yaml::Error,
55 },
56}
57
58/// Typed kind-mismatch view: the canonical surface every per-kind
59/// `caixa-<target>` renderer raises when it's handed a [`Caixa`] whose
60/// `:kind` doesn't match the kind that renderer is targeting. Carries
61/// the offending caixa's `:nome` alongside the expected/actual kinds,
62/// so the diagnostic reads `caixa "<nome>": expected :kind <expected>,
63/// got <actual>` — naming which caixa needs author attention, not just
64/// which kind the renderer rejected.
65///
66/// Lifted from three identical-shape per-renderer arms in
67/// `caixa-helm` ([`Error::NotAServico`][helm-err]), `caixa-flux`
68/// ([`Error::NotAServico`][flux-err]) and `caixa-mesh`
69/// ([`Error::NotAnAplicacao`][mesh-err]). The prior arms each carried
70/// only the actual [`CaixaKind`], leaving the user to grep for which
71/// `caixa.lisp` triggered the mismatch — exactly the
72/// "feira verb whose error path doesn't name the offending caixa"
73/// punch-list item the compounding-mandate protocol calls out.
74///
75/// Renderers wrap this view in their own [`thiserror`] `Error` enum
76/// via `#[from]`; the `?` operator at every kind-checking call site
77/// turns the [`require_kind`] result into the renderer's local error
78/// type with no manual conversion.
79///
80/// [helm-err]: https://docs.rs/caixa-helm
81/// [flux-err]: https://docs.rs/caixa-flux
82/// [mesh-err]: https://docs.rs/caixa-mesh
83#[derive(Debug, Clone, PartialEq, Eq, Error)]
84#[error("caixa {nome:?}: expected :kind {expected:?}, got {actual:?}")]
85pub struct KindMismatch {
86 /// The offending caixa's `:nome` — names which `caixa.lisp` the
87 /// renderer was handed, so the diagnostic doesn't require the
88 /// user to grep for it.
89 pub nome: String,
90 /// The `:kind` this renderer targets.
91 pub expected: CaixaKind,
92 /// The `:kind` the offending caixa actually carries.
93 pub actual: CaixaKind,
94}
95
96/// Predicate: assert that `caixa.kind == expected`, returning a typed
97/// [`KindMismatch`] view (carrying [`Caixa::nome`]) on rejection. The
98/// canonical entry-point every per-kind renderer wraps in its own
99/// [`thiserror`] `Error` variant via `#[from]` — the call site
100/// becomes a single `caixa_core::require_kind(caixa, CaixaKind::X)?;`
101/// in place of the prior inline `if caixa.kind != CaixaKind::X {
102/// return Err(Error::NotAnX(caixa.kind)); }` block.
103///
104/// Lifted to a single helper so a future per-kind renderer
105/// (`caixa-otel`, the future per-Aplicacao CR materializer the M3.x
106/// roadmap acknowledges, the future per-Supervisor reconciler
107/// renderer) gets the same naming-the-offending-caixa diagnostic for
108/// free, and a future change to the diagnostic format (e.g. adding
109/// a [`Caixa::versao`] suffix once multi-version-skew authoring lands)
110/// is one edit here, not a coordinated rewrite of every renderer.
111///
112/// # Errors
113///
114/// Returns [`KindMismatch`] when `caixa.kind != expected`. The error
115/// carries the caixa's `:nome` so the diagnostic names the offending
116/// `caixa.lisp` — same shape every renderer's `Error::From<KindMismatch>`
117/// converts into the renderer's local error type.
118pub fn require_kind(caixa: &Caixa, expected: CaixaKind) -> Result<(), KindMismatch> {
119 if caixa.kind() == expected {
120 Ok(())
121 } else {
122 Err(KindMismatch {
123 nome: caixa.nome().to_string(),
124 expected,
125 actual: caixa.kind(),
126 })
127 }
128}
129
130/// Typed `:ci`-slot-absence view: the canonical surface every per-`Acao`
131/// consumer raises when it's handed a `:kind Acao` [`Caixa`] whose `:ci`
132/// slot is absent. Carries the offending caixa's `:nome` so the diagnostic
133/// reads `caixa "<nome>": :kind Acao requires a :ci slot` — naming which
134/// `caixa.lisp` needs author attention, not just the axis the consumer
135/// rejected.
136///
137/// Lifted from `caixa-actions`' inline
138/// `.ok_or_else(|| Error::MissingCi { nome: caixa.nome().to_string() })`
139/// gate so a future per-`Acao` consumer (the deferred
140/// `sui-supercacheci::canteiro::emit_gha` workflow renderer, the future
141/// per-`Acao` CR materializer that mirrors the sibling per-`Servico` and
142/// per-`Aplicacao` materializers the M4 roadmap acknowledges) reaches for
143/// the same typed view via `#[from]` instead of re-inlining the same
144/// `.ok_or_else(...)` construction.
145///
146/// Peer of [`KindMismatch`] on the per-renderer kind-gate axis and
147/// [`ServicoCountMismatch`] on the per-Servico V0-count-gate axis — the
148/// third typed named-caixa entry-gate view every per-kind
149/// `caixa-<target>` renderer wraps via `#[from]` in its own
150/// [`thiserror`] `Error` enum.
151#[derive(Debug, Clone, PartialEq, Eq, Error)]
152#[error("caixa {nome:?}: :kind Acao requires a :ci slot")]
153pub struct MissingCiSlot {
154 /// The offending caixa's `:nome` — names which `caixa.lisp` the
155 /// consumer was handed, so the diagnostic doesn't require the user
156 /// to grep for it.
157 pub nome: String,
158}
159
160/// Predicate: assert that `caixa.ci().is_some()`, returning the borrowed
161/// [`canteiro_types::CiRun`] on success and a typed [`MissingCiSlot`] view
162/// (carrying [`Caixa::nome`]) on rejection. The canonical entry-point
163/// every per-`Acao` consumer wraps in its own [`thiserror`] `Error`
164/// variant via `#[from]` — the call site becomes a single
165/// `let ci = caixa_core::require_ci(caixa)?;` in place of the prior
166/// two-line
167/// `let ci = caixa.ci().ok_or_else(|| Error::MissingCi { nome: caixa.nome().to_string() })?;`
168/// block.
169///
170/// Returns `&CiRun` (rather than `()` like the peer [`require_kind`] and
171/// [`require_single_servico`] predicates on the same substrate entry-gate
172/// axis) because every caller then reaches for the borrowed `:ci` slot's
173/// [`canteiro_types::CiRun`] to decompose / render / emit — projecting
174/// the successful borrow through the same `?` step folds the check and
175/// the bind onto one call site, matching how every present + roadmapped
176/// per-`Acao` consumer uses the slot.
177///
178/// Lifted to a single helper so the `:ci`-slot-presence gate — the same
179/// axis the [`crate::LayoutError::MissingCi`] emission gates on at
180/// `feira build` time — lives in exactly one place across every future
181/// per-`Acao` consumer: a future `sui-supercacheci::canteiro::emit_gha`
182/// workflow renderer (the deferred `caixa-actions` next step named in
183/// its own crate docs), a future per-`Acao` CR materializer, and every
184/// consumer downstream reaches for the same typed helper and gets the
185/// same named-the-offending-caixa diagnostic for free.
186///
187/// Same trajectory as [`require_kind`] / [`KindMismatch`] on the peer
188/// per-renderer kind-gate axis and [`require_single_servico`] /
189/// [`ServicoCountMismatch`] on the peer per-Servico V0-count-gate axis:
190/// one `caixa_core::require_*` helper per typed entry-gate axis, so the
191/// diagnostic shape (named caixa, named field) is uniform across the
192/// substrate, and every per-kind renderer's `Error::From<*>` `#[from]`
193/// arm gets the diagnostic-naming-the-offending-caixa contract for free.
194///
195/// # Errors
196///
197/// Returns [`MissingCiSlot`] when `caixa.ci().is_none()` — every
198/// non-`Acao` kind lands here (the sibling
199/// [`crate::LayoutError::CiOnNonAcao`] gate refuses a declared `:ci` on
200/// any other kind at `feira build` time, so a callsite that gates on
201/// `:kind Acao` first via [`require_kind`] will only ever surface this
202/// arm for a `:kind Acao` caixa that hasn't declared its `:ci` yet).
203/// The error carries the caixa's `:nome` so the diagnostic names the
204/// offending `caixa.lisp` — same shape every consumer's
205/// `Error::From<MissingCiSlot>` converts into the consumer's local error
206/// type.
207pub fn require_ci(caixa: &Caixa) -> Result<&canteiro_types::CiRun, MissingCiSlot> {
208 caixa.ci().ok_or_else(|| MissingCiSlot {
209 nome: caixa.nome().to_string(),
210 })
211}
212
213/// Typed `:ci`-decompose-failure view: the canonical surface every
214/// per-`Acao` consumer raises when [`canteiro_types::decompose`] refuses
215/// the caixa's declared `:ci` run (a duplicate node name, a dependency
216/// on an undeclared node, a dependency cycle — every failure mode the
217/// sibling [`canteiro_types::DecomposeError`] enumerates). Carries the
218/// offending caixa's `:nome` alongside the borrowed
219/// [`canteiro_types::DecomposeError`] source so the diagnostic reads
220/// `caixa "<nome>": :ci decompose failed: <source>` — naming which
221/// `caixa.lisp` needs author attention, not just the axis the consumer
222/// rejected.
223///
224/// Lifted from `caixa-actions`' inline `Error::Decompose { nome: String,
225/// #[source] source: DecomposeError }` variant so a future per-`Acao`
226/// consumer (the deferred `sui-supercacheci::canteiro::emit_gha`
227/// workflow renderer named in the `caixa-actions` crate docs, the
228/// future per-`Acao` CR materializer that mirrors the sibling
229/// per-`Servico` / per-`Aplicacao` materializers the M4 roadmap
230/// acknowledges) reaches for the same typed view via `#[from]` instead
231/// of re-inlining the same `nome: String, #[source] source:
232/// DecomposeError` construction on its own call site — the second
233/// typed named-caixa diagnostic axis on the per-`Acao` consumer surface
234/// after the peer [`MissingCiSlot`] presence-gate axis.
235///
236/// Peer of [`MissingCiSlot`] on the per-`Acao` `:ci`-slot diagnostic
237/// axis (the presence gate reaches for [`MissingCiSlot`] via
238/// [`require_ci`]; the decompose gate reaches for [`CiDecomposeFailure`]
239/// on the borrowed [`canteiro_types::CiRun`] the presence gate returns).
240/// Peer of [`KindMismatch`] / [`ServicoCountMismatch`] on the sibling
241/// per-renderer entry-gate diagnostic axes — extends the same "one
242/// typed view per axis, carrying the offending caixa's `:nome` +
243/// axis-specific detail, wrapped by every consumer via `#[from]`"
244/// discipline onto the [`canteiro_types::decompose`] axis on the
245/// per-`Acao` consumer surface.
246///
247/// The `source` field carries the borrowed
248/// [`canteiro_types::DecomposeError`] verbatim (rather than collapsing
249/// to a single opaque axis) so a future consumer that wants to fan on
250/// the specific decompose-failure arm — a `feira lint` sub-diagnostic
251/// that offers a `:deps`-repair suggestion on the `MissingDependency`
252/// arm but not the `Cycle` arm, a future per-`Acao` CR materializer's
253/// admission webhook that surfaces the cycle path on rejection —
254/// reaches for `err.source` directly rather than re-parsing the Display
255/// bytes.
256///
257/// [`DecomposeError`]: canteiro_types::DecomposeError
258#[derive(Debug, Error)]
259#[error("caixa {nome:?}: :ci decompose failed: {source}")]
260pub struct CiDecomposeFailure {
261 /// The offending caixa's `:nome` — names which `caixa.lisp` the
262 /// consumer was handed, so the diagnostic doesn't require the user
263 /// to grep for it. Constructed via the lifted [`crate::Caixa::nome`]
264 /// accessor's `.to_string()` extension, matching the peer
265 /// [`MissingCiSlot::nome`] / [`KindMismatch::nome`] /
266 /// [`ServicoCountMismatch::nome`] `nome`-carrying axes.
267 pub nome: String,
268 /// The [`canteiro_types::decompose`] error the caixa's `:ci` run
269 /// tripped on — carried verbatim so a consumer that fans on the
270 /// specific arm (`Cycle` / `MissingDependency` / `DuplicateNode` /
271 /// …) reaches for the typed source rather than re-parsing the
272 /// Display bytes.
273 #[source]
274 pub source: canteiro_types::DecomposeError,
275}
276
277/// Predicate: decompose a borrowed [`canteiro_types::CiRun`] into its
278/// typed [`canteiro_types::CanteiroDag`] via
279/// [`canteiro_types::decompose`], wrapping any
280/// [`canteiro_types::DecomposeError`] in a typed [`CiDecomposeFailure`]
281/// view (carrying [`Caixa::nome`]) on rejection. The canonical
282/// entry-point every per-`Acao` consumer wraps in its own
283/// [`thiserror`] `Error` variant via `#[from]` — the call site becomes
284/// a single `let cd = caixa_core::decompose_ci(caixa, ci)?;` in place
285/// of the prior inline
286/// `let cd = canteiro_types::decompose(ci).map_err(|source| CiDecomposeFailure { nome: caixa.nome().to_string(), source })?;`
287/// block.
288///
289/// Takes the borrowed [`canteiro_types::CiRun`] as a separate argument
290/// (rather than re-borrowing it through [`require_ci`] internally) so
291/// the axis stays single-purpose — the sibling [`require_ci`] presence
292/// gate returns the borrowed slot, this predicate consumes it, and the
293/// two together form the substrate-canonical two-line per-`Acao` prelude
294/// `let ci = caixa_core::require_ci(caixa)?; let cd = caixa_core::decompose_ci(caixa, ci)?;`
295/// every present + roadmapped per-`Acao` consumer runs at its
296/// entry-point (matching how the sibling per-Servico entry-gate axes
297/// keep [`require_kind`] and [`require_single_servico`] as separate
298/// primitives, then compose them into the V0-shape
299/// [`require_v0_servico_shape`] helper — the compound `require + decompose`
300/// helper is a peer-lift for a later commit when a second per-`Acao`
301/// consumer arrives). The `caixa: &Caixa` argument is what makes the
302/// diagnostic name the offending `caixa.lisp` — the borrowed
303/// [`Caixa::nome`] accessor projects through the typed-view
304/// constructor unchanged, matching the peer [`require_ci`] /
305/// [`require_kind`] / [`require_single_servico`] typed-view constructors.
306///
307/// Lifted to a single helper so the [`canteiro_types::decompose`]
308/// axis — the same axis every per-`Acao` consumer runs on its declared
309/// `:ci` slot — lives in exactly one place across every future
310/// per-`Acao` consumer: a future `sui-supercacheci::canteiro::emit_gha`
311/// workflow renderer (the deferred `caixa-actions` next step named in
312/// its own crate docs), a future per-`Acao` CR materializer's admission
313/// webhook, a future `feira lint` sub-diagnostic that offers a
314/// `:deps`-repair suggestion on the [`canteiro_types::DecomposeError::MissingDependency`]
315/// arm but not the [`canteiro_types::DecomposeError::Cycle`] arm — every
316/// consumer reaches for the same one-liner + `#[from]` and gets the
317/// diagnostic-naming-the-offending-caixa contract for free.
318///
319/// Same trajectory as [`require_kind`] / [`KindMismatch`] on the peer
320/// per-renderer kind-gate axis, [`require_single_servico`] /
321/// [`ServicoCountMismatch`] on the peer per-Servico V0-count-gate
322/// axis, and [`require_ci`] / [`MissingCiSlot`] on the peer per-`Acao`
323/// presence-gate axis: one `caixa_core::require_*`/`decompose_ci`
324/// helper per typed axis, so the diagnostic shape (named caixa, named
325/// field) is uniform across the substrate, and every consumer's
326/// `Error::From<*>` `#[from]` arm gets the diagnostic-naming-the-
327/// offending-caixa contract for free.
328///
329/// # Errors
330///
331/// Returns [`CiDecomposeFailure`] when [`canteiro_types::decompose`]
332/// refuses the borrowed `:ci` run — every failure mode the sibling
333/// [`canteiro_types::DecomposeError`] enumerates (a duplicate node
334/// name, a dependency on an undeclared node, a dependency cycle) lands
335/// on this arm. The error carries the caixa's `:nome` + the underlying
336/// [`canteiro_types::DecomposeError`] verbatim so the diagnostic names
337/// the offending `caixa.lisp` and a consumer that fans on the specific
338/// arm reaches for `err.source` directly rather than re-parsing the
339/// Display bytes — same shape every consumer's
340/// `Error::From<CiDecomposeFailure>` converts into the consumer's local
341/// error type.
342pub fn decompose_ci(
343 caixa: &Caixa,
344 ci: &canteiro_types::CiRun,
345) -> Result<canteiro_types::CanteiroDag, CiDecomposeFailure> {
346 canteiro_types::decompose(ci).map_err(|source| CiDecomposeFailure {
347 nome: caixa.nome().to_string(),
348 source,
349 })
350}
351
352/// Substrate-canonical per-`Acao` declared-edge-count projection every
353/// consumer of a borrowed [`canteiro_types::CiRun`] that needs the total
354/// number of author-declared `deps` edges across every
355/// [`canteiro_types::CiNode`] keys off — returns the plain [`usize`] sum
356/// `ci.nodes.iter().map(|n| n.deps.len()).sum()` verbatim, without
357/// running [`canteiro_types::decompose`] again (the count is a property
358/// of the borrowed run's shape, not of the owned
359/// [`canteiro_types::CanteiroDag`] the sibling [`decompose_ci`] returns
360/// — an author-declared cycle carries the same edge count as an
361/// author-declared linear DAG of the same node-and-dep list).
362///
363/// The declared-edge-count axis carries the "how many `deps` edges did
364/// this repo's CI author write?" projection every per-`Acao` consumer
365/// downstream fans on: the `caixa_actions::RenderedAcao::edge_count`
366/// artifact the M0 renderer's `validate` returns (paired with the
367/// topological node-name list from `cd.topo_order()`), the deferred
368/// `sui-supercacheci::canteiro::emit_gha` workflow renderer's
369/// per-workflow `jobs.<job>.needs` count reconciliation pass (each
370/// `needs` entry maps 1:1 to a `deps` edge, so a renderer that emits N
371/// edges must have consumed exactly `declared_edge_count` `needs`
372/// entries across the fan-out), a future `feira lint --acao` per-caixa
373/// admission verb's per-repo declared-edge summary, a future M4
374/// `acao.pleme.io/v1alpha1/Acao` CR materializer's admission webhook
375/// spanning the declared edge count against a per-tenant complexity cap.
376///
377/// Prior to this lift the `ci.nodes.iter().map(|n| n.deps.len()).sum()`
378/// expression was inlined at two sites — `caixa_actions::validate`'s
379/// `edge_count` field construction at `caixa-actions/src/lib.rs:159`
380/// (the M0 per-`Acao` renderer's sole production consumer) and its own
381/// [`require_acao_view`] byte-parity pin at `caixa-actions/src/lib.rs:735`
382/// (which reconstructs the same sum through the compound helper's
383/// returned `&CiRun` to pin that the two paths agree) — two open-coded
384/// arithmetic expressions that expressed no compile-time link back to
385/// the typed [`canteiro_types::CiRun`] axis, so a future refactor of
386/// the declared-edge-count shape (a promotion of the plain [`usize`]
387/// sum to a `{intra_workspace, cross_workspace}` split once
388/// [`canteiro_types::CiNode`] grows a workspace-scoped edge kind, a
389/// per-`:ci` `deps`-edge-canonicalization pass that collapses duplicate
390/// edges once the canteiro-types axis grows a set-shaped `deps`
391/// representation, a per-env-class edge-weight overlay once the M4
392/// `EnvClass` axis grows a per-edge cost model) would have had to be
393/// threaded through both open-coded copies in lockstep or the M0
394/// renderer's `edge_count` artifact would silently disagree with its
395/// own byte-parity pin. Lifting the projection to a typed method on the
396/// substrate primitive means every downstream consumer of the `Acao`'s
397/// declared-edge-count surface reaches for exactly one typed
398/// dispatch — the resolver's accept-set migrates as a unit on any
399/// future axis addition.
400///
401/// The docstring on [`require_acao_view`] already named this expression
402/// verbatim ("the borrowed run for per-[`canteiro_types::CiNode`] axes
403/// (`ci.nodes.iter().map(|n| n.deps.len()).sum()` for the declared edge
404/// count …)") but the substrate carried no primitive for it — the
405/// citation was documentation-only, and the two open-coded call sites
406/// re-expressed the arithmetic each time. This lift closes that gap:
407/// the docstring now cites the substrate primitive by name and every
408/// consumer reaches for the same [`ci_declared_edge_count`] one-liner.
409///
410/// Peer of the sibling [`require_ci`] / [`decompose_ci`] /
411/// [`require_acao_view`] per-`Acao` primitives on the substrate's
412/// per-kind renderer entry-gate surface, extended onto the "borrowed
413/// [`canteiro_types::CiRun`] scalar projection" axis (the two prior
414/// primitives return borrowed / owned structural artifacts; this one
415/// returns a plain [`usize`] scalar over the borrowed run's node-list
416/// shape). Same "one typed dispatch on the substrate primitive, thin
417/// projections at each consumer" discipline the peer per-`Aplicacao`
418/// [`crate::aplicacao::AplicacaoSpec::port_for_destination`] scalar
419/// projection carries on the per-Aplicacao `:entrada` port-resolution
420/// axis, extended onto the per-`Acao` `:ci` declared-edge-count axis.
421///
422/// Named `ci_declared_edge_count` (rather than `declared_edge_count`)
423/// to keep the substrate-side helper namespace explicit that the input
424/// axis is a `:ci` slot — matching the peer [`require_ci`] /
425/// [`decompose_ci`] `ci_`-prefix-shaped naming convention the sibling
426/// per-`Acao` substrate primitives already carry, so a caller reading
427/// `caixa_core::ci_declared_edge_count(ci)` sees the axis at the
428/// helper name rather than at a lifted-out `use` alias.
429#[must_use]
430pub fn ci_declared_edge_count(ci: &canteiro_types::CiRun) -> usize {
431 ci.nodes.iter().map(|n| n.deps.len()).sum()
432}
433
434/// Typed `:servicos`-count-mismatch view: the canonical surface every
435/// per-Servico `caixa-<target>` renderer raises when it's handed a
436/// [`Caixa`] whose `:servicos` list doesn't carry exactly one entry —
437/// the V0 contract every Servico-kind caixa satisfies (`caixa-helm`'s
438/// `render_chart_for_servico`, `caixa-flux`'s `programs_yaml_entry`, the
439/// future per-Servico OCI/wasm packager). Carries the offending caixa's
440/// `:nome` alongside the actual count, so the diagnostic reads `caixa
441/// "<nome>": :servicos must declare exactly one entry for V0 (got
442/// <count>)` — naming which `caixa.lisp` needs author attention, not
443/// just the count the renderer rejected.
444///
445/// Lifted from two identical-shape per-renderer arms in
446/// [`caixa-helm`][helm-err] and [`caixa-flux`][flux-err]
447/// (`Error::UnsupportedServicoCount(usize)`). The prior arms each
448/// carried only the actual count, leaving the user to grep for which
449/// `caixa.lisp` triggered the mismatch — exactly the "feira verb whose
450/// error path doesn't name the offending caixa" punch-list item the
451/// compounding-mandate protocol calls out. Same trajectory as
452/// [`KindMismatch`] (which lifted the prior `NotAServico(CaixaKind)` /
453/// `NotAnAplicacao(CaixaKind)` per-renderer arms into a typed view
454/// naming the offending caixa).
455///
456/// Renderers wrap this view in their own [`thiserror`] `Error` enum
457/// via `#[from]`; the `?` operator at every count-checking call site
458/// turns the [`require_single_servico`] result into the renderer's
459/// local error type with no manual conversion. Peer to [`require_kind`]
460/// on the V0 Servico-shape gate axis (the kind gate refuses the wrong
461/// `:kind`; this gate refuses the wrong `:servicos` count) — every
462/// per-Servico renderer chains both at its entry point.
463///
464/// [helm-err]: https://docs.rs/caixa-helm
465/// [flux-err]: https://docs.rs/caixa-flux
466#[derive(Debug, Clone, PartialEq, Eq, Error)]
467#[error("caixa {nome:?}: :servicos must declare exactly one entry for V0 (got {count})")]
468pub struct ServicoCountMismatch {
469 /// The offending caixa's `:nome` — names which `caixa.lisp` the
470 /// renderer was handed, so the diagnostic doesn't require the
471 /// user to grep for it.
472 pub nome: String,
473 /// The `:servicos` list length the offending caixa actually carries.
474 /// The expected count is fixed at 1 by the V0 contract — every
475 /// `:kind Servico` caixa declares exactly one `ComputeUnit` YAML
476 /// pointer, matching the one Helm chart / one programs.yaml entry
477 /// each renderer emits.
478 pub count: usize,
479}
480
481/// Predicate: assert that `caixa.servicos.len() == 1`, returning a typed
482/// [`ServicoCountMismatch`] view (carrying [`Caixa::nome`] + the actual
483/// count) on rejection. The canonical entry-point every per-Servico
484/// renderer wraps in its own [`thiserror`] `Error` variant via
485/// `#[from]` — the call site becomes a single
486/// `caixa_core::require_single_servico(caixa)?;` in place of the prior
487/// inline `if caixa.servicos.len() != 1 { return
488/// Err(Error::UnsupportedServicoCount(caixa.servicos.len())); }`
489/// block.
490///
491/// Lifted to a single helper so the V0 `:servicos`-singularity invariant
492/// — the same shape the [`crate::Caixa::validate_code_paths`] doc
493/// comment already names as load-bearing on caixa-helm + caixa-flux
494/// (caixa-core/src/manifest.rs:4108) — lives in exactly one place across
495/// every per-Servico renderer. A future per-Servico renderer
496/// (`caixa-otel`, the future per-Servico OCI packager, the future M4
497/// `wasm.pleme.io/v1alpha1/ComputeUnit` CR materializer) gets the same
498/// naming-the-offending-caixa diagnostic for free, and a future change
499/// to the V0 invariant (e.g. allowing multi-servico Servicos when the
500/// component-model multi-world boundary lands in M5) is one edit here,
501/// not a coordinated rewrite of every renderer's per-arm
502/// `UnsupportedServicoCount` check.
503///
504/// Same trajectory as [`require_kind`] / [`KindMismatch`] on the peer
505/// V0 Servico-shape axis: every per-Servico renderer reaches for one
506/// `caixa_core::require_*` helper per V0 invariant, so the diagnostic
507/// shape (named caixa, named field) is uniform across the substrate.
508///
509/// # Errors
510///
511/// Returns [`ServicoCountMismatch`] when `caixa.servicos.len() != 1`
512/// (both empty and ≥ 2 land on this arm — the V0 contract requires
513/// *exactly* one entry, not *at-least* one). The error carries the
514/// caixa's `:nome` + the offending count so the diagnostic names the
515/// offending `caixa.lisp` — same shape every renderer's
516/// `Error::From<ServicoCountMismatch>` converts into the renderer's
517/// local error type.
518pub fn require_single_servico(caixa: &Caixa) -> Result<(), ServicoCountMismatch> {
519 if caixa.servicos().len() == 1 {
520 Ok(())
521 } else {
522 Err(ServicoCountMismatch {
523 nome: caixa.nome().to_string(),
524 count: caixa.servicos().len(),
525 })
526 }
527}
528
529/// Compound V0-shape entry gate: the canonical two-line
530/// `require_kind(caixa, Servico)? + require_single_servico(caixa)?`
531/// prelude every per-Servico `caixa-<target>` renderer runs at its
532/// entry-point, collapsed onto one call the caller reads as intent
533/// ("gate the input on the V0 Servico shape") rather than two
534/// hand-spelled predicate calls.
535///
536/// The pair names one contract with two axes: `:kind` is `Servico`
537/// (this is a per-Servico renderer's input, not a `Biblioteca` /
538/// `Binario` / `Supervisor` / `Aplicacao` mis-hand-off) *and*
539/// `:servicos.len() == 1` (the V0 contract every Servico caixa
540/// satisfies — one `ComputeUnit` YAML pointer, matching the one Helm
541/// chart / programs.yaml entry / cluster bundle each per-Servico
542/// renderer emits). Both axes must hold together — a `:kind Servico`
543/// caixa with two `:servicos` entries and a `:kind Aplicacao` caixa
544/// with one `:servicos` entry are equally invalid at every per-Servico
545/// renderer's entry-point — so lifting the pair onto one helper names
546/// the compound contract at each call site the way the M2 typed slots'
547/// [`servico_m2_overlay`] names the compound `:limits`+`:behavior`+
548/// `:upgrade-from` overlay contract at each call site.
549///
550/// Three production call sites previously carried the two-line pair
551/// inline:
552///
553/// * `caixa-flux`'s [`programs_yaml_entry`][flux-yaml] (the
554/// aggregator-path programs.yaml entry emitter);
555/// * `caixa-flux`'s [`cluster_bundle`][flux-bundle] (the standalone
556/// `GitRepository` + `HelmRelease` + `Kustomization` trio emitter);
557/// * `caixa-helm`'s
558/// [`render_chart_for_servico_with`][helm-chart] (the per-program
559/// `lareira-<nome>` Helm chart emitter).
560///
561/// Each site now reads `caixa_core::require_v0_servico_shape(caixa)?`
562/// instead of the two-line pair. A future per-Servico renderer
563/// (`caixa-otel`, the future per-Servico OCI packager, the future M4
564/// `wasm.pleme.io/v1alpha1/ComputeUnit` CR materializer,
565/// MESH-COMPOSITION §III.2 #5) gets the compound V0-shape gate for
566/// free with one call, instead of re-inlining the two-line pair — and
567/// a future change to the V0 contract (e.g. adding a
568/// `:kind Servico`-only `:computeunits`-slot-shape gate when the
569/// component-model multi-world boundary lands in M5) is one edit here,
570/// not a coordinated rewrite of every renderer's inline pair.
571///
572/// The generic error type `E` accepts every renderer's local
573/// [`thiserror`] `Error` enum that carries both [`KindMismatch`] and
574/// [`ServicoCountMismatch`] via `#[from]` (`caixa_flux::Error`,
575/// `caixa_helm::Error`, and every future per-Servico renderer that
576/// wires both `#[from]` arms as the diagnostic-naming-the-offending-
577/// caixa contract already requires). Type inference at the call site
578/// resolves `E` from the caller's `?` return type, so the call reads
579/// as `caixa_core::require_v0_servico_shape(caixa)?` with no explicit
580/// turbofish — the same one-liner shape every peer `require_kind` /
581/// `require_single_servico` call site already reads as.
582///
583/// Peer to [`require_kind`] on the single-axis kind gate and
584/// [`require_single_servico`] on the single-axis count gate — both
585/// primitives stay public because per-non-Servico renderers
586/// (`caixa-mesh`'s per-Aplicacao gate, `caixa-feira`'s
587/// `first_servico_path` per-verb gate that composes both predicates
588/// with `anyhow::Context`) reach for the individual predicates rather
589/// than the compound one. Peer to [`servico_m2_overlay`] on the
590/// sibling per-Servico compound-contract surface: `servico_m2_overlay`
591/// names the compound M2 emit-side contract, `require_v0_servico_shape`
592/// names the compound V0 gate-side contract, both per-Servico shape.
593///
594/// [flux-yaml]: https://docs.rs/caixa-flux
595/// [flux-bundle]: https://docs.rs/caixa-flux
596/// [helm-chart]: https://docs.rs/caixa-helm
597///
598/// # Errors
599///
600/// Returns the caller's `E` wrapping a [`KindMismatch`] when
601/// `caixa.kind != CaixaKind::Servico`, or a [`ServicoCountMismatch`]
602/// when `caixa.servicos.len() != 1`. Order matches the two-line pair
603/// this replaces: the kind gate fires first, so a
604/// `:kind Aplicacao` caixa with zero `:servicos` entries surfaces the
605/// kind mismatch (the more actionable diagnostic — the author has the
606/// wrong `:kind`) rather than the count mismatch (a downstream
607/// consequence of the mis-kinded input).
608pub fn require_v0_servico_shape<E>(caixa: &Caixa) -> Result<(), E>
609where
610 E: From<KindMismatch> + From<ServicoCountMismatch>,
611{
612 require_kind(caixa, CaixaKind::Servico)?;
613 require_single_servico(caixa)?;
614 Ok(())
615}
616
617/// Compound per-Aplicacao entry gate: the canonical three-line
618/// `require_kind(caixa, CaixaKind::Aplicacao)? +
619/// caixa.aplicacao_view().expect(…) + spec.validate()?` prelude every
620/// per-Aplicacao `caixa-<target>` renderer runs at its entry-point,
621/// collapsed onto one call the caller reads as intent ("gate the input
622/// on the V0 Aplicacao shape and hand back a validated
623/// [`crate::aplicacao::AplicacaoSpec`]") rather than three hand-spelled
624/// steps.
625///
626/// The cascade names one contract with three axes: `:kind` is
627/// `Aplicacao` (this is a per-Aplicacao renderer's input, not a
628/// `Biblioteca` / `Binario` / `Servico` / `Supervisor` / `Acao`
629/// mis-hand-off), the [`Caixa::aplicacao_view`] fold-in succeeds (which
630/// [`require_kind`]-on-`Aplicacao` guarantees per its own doc pin —
631/// [`Caixa::aplicacao_view`] returns `Some` iff `caixa.kind().is_aplicacao()`),
632/// *and* the folded [`crate::aplicacao::AplicacaoSpec`] passes its own
633/// M3 typed-shape validation ([`crate::aplicacao::AplicacaoSpec::validate`]:
634/// non-empty `:membros`, DNS-1123 member names, semver-valid `:versao`
635/// requirements, `:contratos` referencing only declared members,
636/// `:placement Sharded` carrying `:shard-key`, `:placement`
637/// `Replicated`/`SingleNode` carrying `:clusters`, and so on across
638/// every M3 typed slot). All three axes must hold together — a
639/// `:kind Servico` caixa carrying a well-formed `:membros`/`:contratos`
640/// stanza (the manifest field's documented "silently ignored" case)
641/// and a `:kind Aplicacao` caixa with an empty `:membros` are equally
642/// invalid at every per-Aplicacao renderer's entry-point — so lifting
643/// the three-arm cascade onto one helper names the compound contract
644/// at each call site the way the sibling per-Servico
645/// [`require_v0_servico_shape`] compound gate already names the
646/// two-axis compound V0 Servico-shape contract.
647///
648/// Three production call sites in `caixa-mesh` previously funneled
649/// through the crate-local `typed_view` wrapper which itself carried
650/// the three-line cascade inline:
651///
652/// * `caixa-mesh`'s [`programs_for_aplicacao`][mesh-programs] (the
653/// `lareira-fleet-programs`-aggregator programs.yaml fan-out
654/// emitter);
655/// * `caixa-mesh`'s [`cilium_network_policies`][mesh-cnp] (the
656/// per-`(:de, :para)` L7 Cilium CRD emitter);
657/// * `caixa-mesh`'s [`gateway_routes`][mesh-gw] (the per-`:entrada`
658/// K8s Gateway API v1 Gateway + HTTPRoute emitter).
659///
660/// The crate-local `caixa_mesh::typed_view` wrapper now reads as a
661/// one-liner `caixa_core::require_aplicacao_view::<Error>(caixa)`. A
662/// future per-Aplicacao renderer (`caixa-tatara`'s per-Aplicacao
663/// [`process_for_aplicacao`][tatara] downstream axes when they grow a
664/// spec-consuming validate arm, the deferred
665/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's admission
666/// webhook, a future `feira validate --aplicacao` per-caixa admission
667/// verb) gets the compound three-arm gate for free with one call,
668/// instead of re-inlining the three-line cascade — and a future change
669/// to the V0 Aplicacao contract (e.g. adding a `:kind Aplicacao`-only
670/// `:membros`-cross-cluster-uniqueness gate when the M4 federated-app
671/// boundary lands) is one edit here, not a coordinated rewrite of
672/// every per-Aplicacao renderer's inline cascade.
673///
674/// The generic error type `E` accepts every per-Aplicacao renderer's
675/// local [`thiserror`] `Error` enum that carries both [`KindMismatch`]
676/// and [`crate::aplicacao::AplicacaoError`] via `#[from]`
677/// (`caixa_mesh::Error`, and every future per-Aplicacao renderer that
678/// wires both `#[from]` arms as the diagnostic-naming-the-offending-
679/// caixa contract already requires). Type inference at the call site
680/// resolves `E` from the caller's `?` return type, though a caller
681/// that assigns the result directly to a `Result<AplicacaoSpec,
682/// Error>` binding may need a turbofish
683/// (`::<Error>`) — matching the sibling `require_v0_servico_shape::<Error>`
684/// turbofish convention the peer per-Servico call sites already read.
685///
686/// Peer to [`require_v0_servico_shape`] on the sibling per-Servico
687/// entry-gate axis and [`require_kind`] / [`require_ci`] /
688/// [`decompose_ci`] on the sibling per-`Acao` entry-gate axis — every
689/// per-kind renderer's entry-gate cascade now lives in exactly one
690/// substrate primitive.
691///
692/// [mesh-programs]: https://docs.rs/caixa-mesh
693/// [mesh-cnp]: https://docs.rs/caixa-mesh
694/// [mesh-gw]: https://docs.rs/caixa-mesh
695/// [tatara]: https://docs.rs/caixa-tatara
696///
697/// # Errors
698///
699/// Returns the caller's `E` wrapping a [`KindMismatch`] when
700/// `caixa.kind != CaixaKind::Aplicacao`, or a
701/// [`crate::aplicacao::AplicacaoError`] when the folded
702/// [`crate::aplicacao::AplicacaoSpec`] fails its typed-shape
703/// validation. Order matches the three-line cascade this replaces: the
704/// kind gate fires first, so a `:kind Servico` caixa with a
705/// well-formed `:membros` stanza surfaces the kind mismatch (the more
706/// actionable diagnostic — the author has the wrong `:kind`) rather
707/// than the `AplicacaoError` (which the [`Caixa::aplicacao_view`]
708/// fold-in never even reaches on a non-`Aplicacao` kind).
709///
710/// # Panics
711///
712/// Never in practice — the internal [`Caixa::aplicacao_view`] unwrap
713/// is guarded by the preceding [`require_kind`]-on-`Aplicacao` gate,
714/// and [`Caixa::aplicacao_view`]'s own doc pin guarantees
715/// `Some`-return iff `caixa.kind().is_aplicacao()`. A future
716/// [`Caixa::aplicacao_view`] refactor that decouples `Some`-return
717/// from `caixa.kind().is_aplicacao()` would trip this panic at the
718/// first per-Aplicacao renderer call site, not silently return `Err(E)`
719/// at every one — the panic message names the substrate invariant so
720/// the offending edit is obvious.
721pub fn require_aplicacao_view<E>(caixa: &Caixa) -> Result<crate::aplicacao::AplicacaoSpec, E>
722where
723 E: From<KindMismatch> + From<crate::aplicacao::AplicacaoError>,
724{
725 require_kind(caixa, CaixaKind::Aplicacao)?;
726 let spec = caixa
727 .aplicacao_view()
728 .expect("require_kind(Aplicacao) guarantees Caixa::aplicacao_view returns Some");
729 spec.validate()?;
730 Ok(spec)
731}
732
733/// Compound per-`Acao` entry gate: the canonical three-line
734/// `require_kind(caixa, CaixaKind::Acao)? + require_ci(caixa)? +
735/// decompose_ci(caixa, ci)?` prelude every per-`Acao` `caixa-<target>`
736/// consumer runs at its entry-point, collapsed onto one call the caller
737/// reads as intent ("gate the input on the V0 Acao shape and hand back
738/// the borrowed [`canteiro_types::CiRun`] + the decomposed
739/// [`canteiro_types::CanteiroDag`]") rather than three hand-spelled
740/// steps.
741///
742/// The cascade names one contract with three axes: `:kind` is `Acao`
743/// (this is a per-`Acao` consumer's input, not a `Biblioteca` /
744/// `Binario` / `Servico` / `Supervisor` / `Aplicacao` mis-hand-off),
745/// the `:ci` slot is present ([`require_ci`] returns the borrowed
746/// [`canteiro_types::CiRun`]), *and* the declared run decomposes
747/// cleanly through [`canteiro_types::decompose`] (a duplicate node
748/// name, a missing dep, a cycle — every [`canteiro_types::DecomposeError`]
749/// arm — surfaces via [`CiDecomposeFailure`]). All three axes must
750/// hold together — so lifting the three-arm cascade onto one helper
751/// names the compound contract at each call site the way the sibling
752/// per-Servico [`require_v0_servico_shape`] compound gate already
753/// names the two-axis compound V0 Servico-shape contract and the
754/// sibling per-Aplicacao [`require_aplicacao_view`] compound gate
755/// names the three-arm compound per-Aplicacao entry-gate contract.
756///
757/// Returns the borrowed [`canteiro_types::CiRun`] paired with the
758/// owned [`canteiro_types::CanteiroDag`] `decompose_ci` produced —
759/// both are the load-bearing artifacts every per-`Acao` consumer
760/// reads past the gate: the borrowed run for
761/// per-[`canteiro_types::CiNode`] axes (the substrate primitive
762/// [`ci_declared_edge_count`] for the declared edge count, the
763/// deferred `sui-supercacheci::canteiro::emit_gha` per-node YAML emit
764/// surface), the owned DAG for topological order (`cd.topo_order()`,
765/// which the substrate's own [`decompose_ci`] pass-through-on-success
766/// contract at [`decompose_ci_accepts_valid_ci_run_and_returns_canteiro_dag`]
767/// pins as infallible on the accepted arm).
768///
769/// The current single production call site — `caixa-actions::validate` —
770/// previously carried the three-line prelude inline:
771///
772/// ```ignore
773/// caixa_core::require_kind(caixa, CaixaKind::Acao)?;
774/// let ci = caixa_core::require_ci(caixa)?;
775/// let cd = caixa_core::decompose_ci(caixa, ci)?;
776/// ```
777///
778/// It now reads as a one-liner
779/// `let (ci, cd) = caixa_core::require_acao_view::<Error>(caixa)?;`.
780/// Every deferred per-`Acao` consumer named in the `caixa-actions` crate
781/// docs (the `sui-supercacheci::canteiro::emit_gha` workflow renderer, a
782/// future `acao.pleme.io/v1alpha1/Acao` CR materializer's admission
783/// webhook, a future `feira validate --acao` per-caixa admission verb)
784/// gets the compound three-arm gate for free with one call, instead of
785/// re-inlining the three-line prelude — and a future change to the V0
786/// Acao contract (an M4 [`canteiro_types::CiRun`] `:workspace`-scoped
787/// admission gate the CR materializer resolves at admission time, a
788/// per-`:ci` cross-node capability-audit prelude the Pony-inspired
789/// capability-typing roadmap acknowledges) is one edit here on the
790/// compound helper, not a coordinated rewrite across every per-`Acao`
791/// consumer's inline three-line prelude.
792///
793/// The generic error type `E` accepts every per-`Acao` consumer's
794/// local [`thiserror`] `Error` enum that carries all three of
795/// [`KindMismatch`], [`MissingCiSlot`], and [`CiDecomposeFailure`]
796/// via `#[from]` (`caixa_actions::Error` today, and every future
797/// per-`Acao` consumer that wires the same three `#[from]` arms as
798/// the diagnostic-naming-the-offending-caixa contract already
799/// requires). Type inference at the call site resolves `E` from the
800/// caller's `?` return type, though a caller that assigns the result
801/// directly to a `Result<(&CiRun, CanteiroDag), Error>` binding may
802/// need a turbofish (`::<Error>`) — matching the sibling
803/// `require_aplicacao_view::<Error>` turbofish convention the peer
804/// per-Aplicacao call site already reads.
805///
806/// Peer to [`require_v0_servico_shape`] on the sibling per-Servico
807/// entry-gate axis and [`require_aplicacao_view`] on the sibling
808/// per-Aplicacao entry-gate axis — every per-kind renderer's
809/// entry-gate cascade now lives in exactly one substrate primitive.
810///
811/// # Errors
812///
813/// Returns the caller's `E` wrapping a [`KindMismatch`] when
814/// `caixa.kind != CaixaKind::Acao`, a [`MissingCiSlot`] when the
815/// caixa's `:ci` slot is absent past the kind gate, or a
816/// [`CiDecomposeFailure`] when [`canteiro_types::decompose`] refuses
817/// the borrowed run. Order matches the three-line prelude this
818/// replaces: the kind gate fires first (so a `:kind Servico` caixa
819/// carrying a well-formed `:ci` stanza — the manifest field's
820/// documented "silently ignored" case on a non-`Acao` kind —
821/// surfaces the kind mismatch, the more actionable diagnostic), then
822/// the presence gate, then the decompose gate.
823pub fn require_acao_view<E>(
824 caixa: &Caixa,
825) -> Result<(&canteiro_types::CiRun, canteiro_types::CanteiroDag), E>
826where
827 E: From<KindMismatch> + From<MissingCiSlot> + From<CiDecomposeFailure>,
828{
829 require_kind(caixa, CaixaKind::Acao)?;
830 let ci = require_ci(caixa)?;
831 let cd = decompose_ci(caixa, ci)?;
832 Ok((ci, cd))
833}
834
835/// One rendered artifact — a `(path, contents)` pair every per-target
836/// `caixa-<target>` renderer emits at every leaf of its output tree.
837/// Carries the sandboxed relative path the substrate writes the artifact
838/// under (relative to the renderer-chosen output root — the per-chart
839/// directory for [`caixa-helm`][cf-helm]'s `lareira-<nome>` chart tree,
840/// the per-caixa `./clusters/<cluster>/services/<nome>/` sub-tree for
841/// [`caixa-flux`][cf-flux]'s [`cluster_bundle`][cb] Flux v2 CR trio)
842/// alongside the pre-serialized byte contents the substrate writes to it.
843///
844/// Lifted from two identical-shape per-renderer arms in
845/// [`caixa-flux`][cf-flux] (`BundleFile { path: PathBuf, contents:
846/// String }`) and [`caixa-helm`][cf-helm] (`ChartFile { path: PathBuf,
847/// contents: String }`) — same field pair, same derives (`Debug + Clone
848/// + PartialEq + Eq`), no per-type impls — carrying the same "one
849/// rendered leaf artifact" contract twice. Every prior per-target
850/// renderer had reinvented the same two-field record because there was
851/// no substrate-side canonical `(path, contents)` shape to reach for;
852/// the future per-target renderers the M4/M5 roadmap acknowledges
853/// (`caixa-otel`'s per-collector-config emit, the future per-Aplicacao
854/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-CR YAML
855/// emit, the future per-Supervisor reconciler renderer's per-child
856/// bundle emit) would have re-added a third and fourth clone of the
857/// same record — exactly the "render-side patterns recurring ≥2 times
858/// across `caixa-helm` / `caixa-flux` / `caixa-mesh` become helpers.
859/// Duplication is a bug. (PRIME DIRECTIVE.)" compounding-mandate slot
860/// item.
861///
862/// Both prior arms remain as public `pub type BundleFile =
863/// caixa_core::RenderedFile;` / `pub type ChartFile =
864/// caixa_core::RenderedFile;` aliases at their crate boundary so every
865/// existing struct-literal construction site
866/// (`BundleFile { path: …, contents: … }` / `ChartFile { path: …,
867/// contents: … }`), every field-access site (`.path` / `.contents`),
868/// and every derive-fed navigator (`==` equality pins, `Debug`
869/// formatting probes) resolves through the type alias to the canonical
870/// [`RenderedFile`] with no per-call-site edit — Rust type aliases
871/// carry the same `#[derive]`-generated `Debug`/`Clone`/`PartialEq`/
872/// `Eq` impls as their canonical, so the shared-shape contract lives
873/// at one type definition instead of two verbatim clones drifting
874/// silently on any future rebrand.
875///
876/// Peer to the [`KindMismatch`] / [`ServicoCountMismatch`] typed-view
877/// lifts on the sibling per-renderer-error-diagnostic-shape axis: both
878/// families lift a per-renderer duplicated record onto a canonical
879/// substrate-side type, so a future per-target renderer joins the
880/// pattern by re-exporting one alias instead of open-coding another
881/// clone.
882///
883/// The `path` axis carries the sandboxed relative path — the same
884/// [`is_sandboxed_relative_path`] discipline the [`Caixa::validate_code_paths`]
885/// invariant enforces at the manifest-side path axis. No renderer today
886/// runs the predicate against the emit-side per-`RenderedFile.path`
887/// — the paths are picked from substrate-canonical `&'static str`
888/// filename constants ([`FLUX_GITREPOSITORY_YAML_FILENAME`],
889/// [`FLUX_HELMRELEASE_YAML_FILENAME`], [`FLUX_KUSTOMIZATION_YAML_FILENAME`],
890/// [`HELM_CHART_YAML_FILENAME`], [`HELM_VALUES_YAML_FILENAME`]) rather
891/// than author input, so a per-emit-time sandbox check would be
892/// belt-and-suspenders — but the shared type shape makes a future
893/// sandbox-at-emit-time invariant a one-place add across every
894/// per-target renderer.
895///
896/// [cf-flux]: https://docs.rs/caixa-flux
897/// [cf-helm]: https://docs.rs/caixa-helm
898/// [cb]: https://docs.rs/caixa-flux/latest/caixa_flux/fn.cluster_bundle.html
899#[derive(Debug, Clone, PartialEq, Eq)]
900pub struct RenderedFile {
901 /// Sandboxed relative path the substrate writes the artifact under
902 /// (relative to the renderer-chosen output root). Substrate-canonical
903 /// filename constants ([`FLUX_GITREPOSITORY_YAML_FILENAME`] /
904 /// [`FLUX_HELMRELEASE_YAML_FILENAME`] /
905 /// [`FLUX_KUSTOMIZATION_YAML_FILENAME`] for the `caixa-flux`
906 /// [`cluster_bundle`] Flux v2 CR trio, [`HELM_CHART_YAML_FILENAME`] /
907 /// [`HELM_VALUES_YAML_FILENAME`] for the `caixa-helm`
908 /// `lareira-<nome>` chart directory) source every path today.
909 pub path: PathBuf,
910 /// The rendered byte contents — a pre-serialized UTF-8 body every
911 /// downstream writer (`caixa-flux::cluster_bundle`'s
912 /// per-`GitRepository`/`HelmRelease`/`Kustomization` YAML emit,
913 /// `caixa-helm::render_chart_for_servico`'s per-`Chart.yaml`/
914 /// `values.yaml`/`README.md` chart-directory emit) hands to
915 /// `std::fs::write` verbatim under the paired [`Self::path`].
916 pub contents: String,
917}
918
919impl RenderedFile {
920 /// Construct a [`RenderedFile`] from its two axes — the sandboxed
921 /// relative `path` the substrate writes the artifact under and the
922 /// pre-serialized UTF-8 `contents` the paired `std::fs::write`
923 /// hands to that path. Accepts anything convertible into a
924 /// [`PathBuf`] (`&'static str` from the substrate-canonical
925 /// filename constants [`HELM_CHART_YAML_FILENAME`] /
926 /// [`HELM_VALUES_YAML_FILENAME`] / [`FLUX_GITREPOSITORY_YAML_FILENAME`]
927 /// / [`FLUX_HELMRELEASE_YAML_FILENAME`] /
928 /// [`FLUX_KUSTOMIZATION_YAML_FILENAME`] every current per-target
929 /// renderer picks its per-artifact leaf path from, `String` /
930 /// `PathBuf` for future author-supplied paths) and anything
931 /// convertible into [`String`] (the `serde_yaml::to_string` /
932 /// `format!` outputs every current renderer already threads into
933 /// the paired `contents` field).
934 ///
935 /// Lifted from six identical-shape struct-literal construction
936 /// sites — three per-artifact leaves in
937 /// [`caixa-helm`][cf-helm]'s `render_chart_for_servico_with`
938 /// (`Chart.yaml`, `values.yaml`, `README.md`) and three per-CR
939 /// leaves in [`caixa-flux`][cf-flux]'s [`cluster_bundle`][cb]
940 /// (`gitrepository.yaml`, `helmrelease.yaml`,
941 /// `kustomization.yaml`) — each of which open-coded a four-line
942 /// `<Xxx>File { path: PathBuf::from(FILENAME_CONST), contents: <body> }`
943 /// block that re-derived the same `PathBuf::from(&str)` wrap +
944 /// the same two-field assembly. Every existing struct-
945 /// literal construction (the type-alias identity pins at
946 /// [`caixa_flux::tests::bundle_file_alias_resolves_to_caixa_core_rendered_file`]
947 /// / [`caixa_helm::tests::chart_file_alias_resolves_to_caixa_core_rendered_file`],
948 /// the substrate-side field-shape pins in this crate's test
949 /// module) continues to compile — [`RenderedFile::new`] is an
950 /// additive inherent constructor that leaves the `pub path` /
951 /// `pub contents` field visibility untouched, so a future rebrand
952 /// on the record shape (a per-artifact hash / provenance field
953 /// addition, a per-artifact write-mode discriminator once
954 /// per-cluster-writer sandboxing lands) still reaches every
955 /// per-target renderer through this canonical constructor + the
956 /// existing struct-literal pinning by construction. Peer to the
957 /// sibling substrate-side canonical-composer surface
958 /// ([`oci_chart_ref`] / [`cilium_network_policy_name`] /
959 /// [`gateway_api_http_route_name`] / [`lareira_chart_name`]) —
960 /// each is a canonical `&'static fn(&str, …) -> String` composer
961 /// that every per-target renderer routes through instead of
962 /// re-deriving the same encoding inline.
963 ///
964 /// A future per-target renderer (`caixa-otel`'s per-collector-
965 /// config emit, the future `mesh.pleme.io/v1alpha1/Aplicacao` CR
966 /// materializer's per-CR YAML emit, the future per-Supervisor
967 /// reconciler renderer's per-child bundle emit) that constructs a
968 /// [`RenderedFile`] now reaches for [`RenderedFile::new`] and
969 /// participates in the same substrate-side per-artifact-
970 /// construction contract, so any addition here (say, a
971 /// `sandboxed_relative_path` invariant check on `path` at
972 /// construction time, the `is_sandboxed_relative_path`
973 /// discipline the docstring above acknowledges is not yet run at
974 /// emit time) reaches every per-target renderer through one
975 /// caixa-core edit instead of a coordinated six-site rewrite.
976 ///
977 /// [cf-helm]: https://docs.rs/caixa-helm
978 /// [cf-flux]: https://docs.rs/caixa-flux
979 /// [cb]: https://docs.rs/caixa-flux/latest/caixa_flux/fn.cluster_bundle.html
980 #[must_use]
981 pub fn new<P, S>(path: P, contents: S) -> Self
982 where
983 P: Into<PathBuf>,
984 S: Into<String>,
985 {
986 Self {
987 path: path.into(),
988 contents: contents.into(),
989 }
990 }
991}
992
993/// Predicate: find the first ASCII whitespace byte in `s`, or `None` if
994/// none of the string's bytes match `u8::is_ascii_whitespace`.
995///
996/// The canonical drift class this closes across every typed-magnitude
997/// codec in caixa-core (`limits::parse_byte_size` backing
998/// `:limits :memory`, `limits::parse_duration` backing `:limits
999/// :wall-clock`, `limits::parse_millicores` backing `:limits :cpu`,
1000/// `supervisor::duration_codec::parse` backing `:supervisor
1001/// :restart-window` / `:politicas :timeout` / `:politicas
1002/// :circuit-breaker :window`, and `aplicacao::rate_limit_codec::parse`
1003/// backing `:politicas :rate-limit`) is the ASCII subset of Unicode
1004/// `White_Space`: space (`0x20`), tab (`0x09`), LF (`0x0A`), FF
1005/// (`0x0C`), CR (`0x0D`) — the five WhatWG-conformant "ASCII whitespace"
1006/// bytes (deliberately narrower than POSIX's `[:space:]` which also
1007/// admits VT `0x0B`). Every downstream YAML / JSON / TOML parser can
1008/// feed any of these bytes through a quoted-scalar value verbatim, so
1009/// a paste-from-shell-history `"500m "` (trailing space), a
1010/// paste-from-aligned-doc `" 64MiB"` (leading space from YAML-quoted-
1011/// plain-scalar alignment), a paste-from-typography `"30 s"`
1012/// (whitespace between magnitude and unit), a paste-from-indented-doc
1013/// `"\t100/s"` (YAML-block-scalar tab byte), or a multi-line-paste
1014/// `"30s\n"` (trailing LF) all survive the top-level `s.trim()`
1015/// discipline and yield the same typed value at each codec — but
1016/// serde round-trips to a *different* canonical form on the next
1017/// emit, breaking the THEORY.md Part V render-determinism contract
1018/// every typed slot carries.
1019///
1020/// Peer of [`find_non_ascii_whitespace_char`] — the two predicates
1021/// together partition the full Unicode `White_Space` axis (this one
1022/// on the ASCII byte range, its peer on the strictly-complementary
1023/// non-ASCII `char` range), and every typed-magnitude codec in
1024/// caixa-core calls both back-to-back at parse entry so the codec's
1025/// accepted set matches its emitted set on the full axis,
1026/// structurally. Same "single lifted source of truth" discipline the
1027/// peer non-ASCII arm's 1b75b38 landing pinned: drift between any two
1028/// codec sites' ASCII-whitespace-rejection set becomes a single-edit
1029/// fix at this predicate rather than five independent scans
1030/// diverging over time, and a future stricter classification
1031/// (BOM `\u{FEFF}` / ZWSP `\u{200B}` / ZWJ `\u{200D}` — the
1032/// "invisible but not `char::is_whitespace`" class that the
1033/// deliberate exclusion in `find_non_ascii_whitespace_char` leaves
1034/// for a follow-up, if a downstream slot proves those are drift
1035/// classes) can extend at this shared site in one edit rather than
1036/// five. Peer of [`is_dns_1123_label`] / [`is_gateway_api_http_path`]
1037/// / [`is_git_repo_url`] — same "typed-slot's valid set matches its
1038/// codec's accepted set, structurally" discipline carried at the
1039/// codec layer.
1040#[must_use]
1041pub fn find_ascii_whitespace_byte(s: &str) -> Option<u8> {
1042 s.bytes().find(|b| b.is_ascii_whitespace())
1043}
1044
1045/// Predicate: find the first non-ASCII Unicode-`White_Space` character in
1046/// `s`, or `None` if every character lies in the ASCII byte range.
1047///
1048/// The canonical drift class this closes across every typed-magnitude
1049/// codec in caixa-core (`limits::parse_byte_size` backing
1050/// `:limits :memory`, `limits::parse_duration` backing `:limits
1051/// :wall-clock`, `supervisor::duration_codec::parse` backing
1052/// `:supervisor :restart-window` / `:politicas :timeout` /
1053/// `:politicas :circuit-breaker :window`, and
1054/// `aplicacao::rate_limit_codec::parse` backing `:politicas
1055/// :rate-limit`) is the non-ASCII subset of Unicode `White_Space`: NBSP
1056/// (`\u{00A0}`), OGHAM SPACE MARK (`\u{1680}`), the EN-QUAD /
1057/// EM-QUAD / EN-SPACE / EM-SPACE / THREE-PER-EM-SPACE /
1058/// FOUR-PER-EM-SPACE / SIX-PER-EM-SPACE / FIGURE-SPACE /
1059/// PUNCTUATION-SPACE / THIN-SPACE / HAIR-SPACE band
1060/// (`\u{2000}`..=`\u{200A}`), LINE SEPARATOR (`\u{2028}`), PARAGRAPH
1061/// SEPARATOR (`\u{2029}`), NARROW NBSP (`\u{202F}`), MEDIUM
1062/// MATHEMATICAL SPACE (`\u{205F}`), and IDEOGRAPHIC SPACE
1063/// (`\u{3000}`). Every one of these characters is
1064/// [`char::is_whitespace`]`() && !`[`char::is_ascii`]`()`, and every
1065/// one of them is silently stripped by [`str::trim`] at the top of
1066/// each codec's parse entry — `str::trim` uses `char::is_whitespace`,
1067/// which is Unicode `White_Space`, strictly wider than the byte-set
1068/// `u8::is_ascii_whitespace` the pre-gate arm on each codec already
1069/// refuses. So a paste-from-typography `"\u{00A0}64MiB"` (NBSP
1070/// leading) survives the byte-scan (none of its bytes match
1071/// `is_ascii_whitespace`), lands on the top-level `s.trim()` which
1072/// silently strips the NBSP, parses to `64 * 1024 * 1024` bytes, and
1073/// serde round-trips to the *different* canonical `"64MiB"` on next
1074/// emit — breaking the THEORY.md Part V render-determinism contract
1075/// every typed slot carries. Same class on every peer codec:
1076/// `"\u{2028}30s"` (paste-from-web-doc line-separator prefix) →
1077/// `Duration::from_secs(30)` → `"30s"`; `"\u{00A0}100/s"`
1078/// (paste-from-typography NBSP prefix on `:politicas :rate-limit`) →
1079/// `RateLimit { 100, 1s }` → `"100/s"`. The ASCII-whitespace-only
1080/// `is_ascii_whitespace` byte-scan closed on each codec by the
1081/// immediate predecessors (`limits::parse_byte_size` — 24a8ad4;
1082/// `limits::parse_duration` — ebc3a75; `supervisor::duration_codec`
1083/// — a7ae622; `rate_limit_codec` — 1ad7755) covers space (`0x20`),
1084/// tab (`0x09`), LF (`0x0A`), FF (`0x0C`), CR (`0x0D`); this
1085/// predicate closes the strictly-complementary non-ASCII Unicode
1086/// `White_Space` class in one lifted source of truth across all four
1087/// codec sites in one landing — the trajectory the 24a8ad4 commit
1088/// body's `Forward compounding` bullet explicitly named ("the next
1089/// canonical-form-drift trajectory … can land as a single lifted
1090/// predicate across all four codec sites in one follow-up run rather
1091/// than four independent extensions").
1092///
1093/// The predicate is deliberately narrower than "any non-ASCII
1094/// codepoint" — the byte-set restrictions on the accepted magnitude
1095/// (`b.is_ascii_digit()` on the digit-only arm, `is_ascii_alphabetic`
1096/// on the unit-suffix split) already refuse every non-`White_Space`
1097/// non-ASCII codepoint at a downstream arm with a `BadByteMagnitude`
1098/// / `BadDurationMagnitude` / equivalent diagnostic. This predicate's
1099/// job is exclusively to name the drift class — the Unicode
1100/// whitespace subset that survives the byte-scan but that
1101/// `str::trim` silently swallows — so the codec's diagnostic can
1102/// carry the offending [`char`] and its `U+XXXX` codepoint verbatim
1103/// rather than laundering the value through a generic "bad
1104/// magnitude" arm at a downstream site far from the paste-origin.
1105/// Peer of [`is_dns_1123_label`] / [`is_gateway_api_http_path`] /
1106/// [`is_git_repo_url`] — same "typed-slot's valid set matches its
1107/// codec's accepted set, structurally" discipline carried at the
1108/// codec layer.
1109///
1110/// Note that BOM (`\u{FEFF}`, ZERO WIDTH NO-BREAK SPACE) and ZWSP
1111/// (`\u{200B}`, ZERO WIDTH SPACE) are deliberately *outside* this
1112/// predicate's rejection set — both have `char::is_whitespace() ==
1113/// false` per the Unicode `White_Space` property, so `str::trim`
1114/// does *not* silently strip either, and both currently land on the
1115/// downstream `BadByteMagnitude` / `BadDurationMagnitude` arm at
1116/// parse time with the byte-shape diagnostic intact. Adding them
1117/// here would over-fire on an accepted-diagnostic class already
1118/// closed at a peer arm — the render-determinism contract is
1119/// unbroken on those inputs today.
1120#[must_use]
1121pub fn find_non_ascii_whitespace_char(s: &str) -> Option<char> {
1122 s.chars().find(|c| c.is_whitespace() && !c.is_ascii())
1123}
1124
1125/// Predicate: `s` carries a leading-zero-padded magnitude — its length
1126/// exceeds one byte and its first byte is ASCII `'0'`.
1127///
1128/// The canonical drift class this closes across every typed-magnitude
1129/// codec in caixa-core (`limits::parse_byte_size` backing `:limits
1130/// :memory` — cea9a78; `limits::parse_duration` backing `:limits
1131/// :wall-clock` — 39762d7; `limits::parse_millicores` backing
1132/// `:limits :cpu` — the sixth codec surface;
1133/// `supervisor::duration_codec::parse` backing `:supervisor
1134/// :restart-window` / `:politicas :timeout` / `:politicas
1135/// :circuit-breaker :window` — 9178904; and
1136/// `aplicacao::rate_limit_codec::parse` backing `:politicas
1137/// :rate-limit` — 4f46830) is the leading-zero-padded magnitude
1138/// shape: every downstream typed-magnitude codec's `render_*`
1139/// canonicalizer emits the leading-zero-stripped form, so a
1140/// leading-zero magnitude (`"030s"`, `"0100/s"`, `"0500m"`,
1141/// `"0064MiB"`, `"01h"`) round-trips through `render_*` to a
1142/// *different* canonical string on the next emit (`"30s"`, `"100/s"`,
1143/// `"500m"`, `"64MiB"`, `"1h"`) — breaking the THEORY.md Part V
1144/// render-determinism contract every typed slot carries the same way
1145/// the leading-`+` shape did before the digit-only arm landed.
1146///
1147/// The predicate deliberately admits the single-byte magnitude `"0"`
1148/// (returning `false`) — every codec's `render_*` canonicalizer emits
1149/// `"0"` / `"0s"` / `"0m"` / `"0/s"` verbatim for the zero magnitude,
1150/// so the single-byte form round-trips losslessly through the codec
1151/// layer. The downstream semantic-zero gates
1152/// ([`crate::LimitsError::MemoryZero`],
1153/// [`crate::LimitsError::WallClockZero`],
1154/// [`crate::LimitsError::CpuZero`],
1155/// [`crate::SupervisorError::ZeroRestartWindow`],
1156/// [`crate::AplicacaoError::PolicyTimeoutZero`],
1157/// [`crate::AplicacaoError::PolicyCircuitBreakerWindowZero`],
1158/// [`crate::AplicacaoError::PolicyRateLimitZero`]) refuse the
1159/// semantic-zero authoring at the typed-validate layer above; the
1160/// codec-layer / typed-validate-layer partition between
1161/// canonical-form drift (this arm) and semantic-zero (the downstream
1162/// gate) remains stable across every codec site.
1163///
1164/// Peer of [`find_ascii_whitespace_byte`] /
1165/// [`find_non_ascii_whitespace_char`] on the same
1166/// canonical-form-drift axis at the codec layer: those two predicates
1167/// close the whitespace drift class (paste-from-shell-history /
1168/// paste-from-typography), this one closes the leading-zero-padding
1169/// drift class (paste-from-fixed-width-alignment /
1170/// paste-from-columnar-report). Same "single lifted source of truth"
1171/// discipline: drift between any two codec sites' leading-zero
1172/// rejection set becomes a single-edit fix at this predicate rather
1173/// than five independent `s.len() > 1 && s.as_bytes()[0] == b'0'`
1174/// scans diverging over time. A future stricter classification
1175/// closing at this shared site (a hypothetical `"00"` shape whose
1176/// diagnostic distinguishes explicit-zero-padding from the accepted
1177/// canonical `"0"`, or a future higher base like `"0x0100"` whose
1178/// magnitude prefix would trip this arm before the digit-only gate
1179/// catches the `x`) extends at one location rather than five. Peer of
1180/// [`is_dns_1123_label`] / [`is_gateway_api_http_path`] /
1181/// [`is_git_repo_url`] — same "typed-slot's valid set matches its
1182/// codec's accepted set, structurally" discipline carried at the
1183/// codec layer.
1184#[must_use]
1185pub fn is_leading_zero_padded_magnitude(s: &str) -> bool {
1186 s.len() > 1 && s.as_bytes()[0] == b'0'
1187}
1188
1189/// Predicate: `s` is a non-empty digit-only magnitude — every byte is
1190/// an ASCII digit `[0-9]`.
1191///
1192/// The canonical drift class this closes across every typed-magnitude
1193/// codec in caixa-core (`limits::parse_byte_size` backing
1194/// `:limits :memory`, `limits::parse_duration` backing `:limits
1195/// :wall-clock`, `limits::parse_millicores` backing `:limits :cpu`,
1196/// `supervisor::duration_codec::parse` backing `:supervisor
1197/// :restart-window` / `:politicas :timeout` / `:politicas
1198/// :circuit-breaker :window`, and `aplicacao::rate_limit_codec::parse`
1199/// backing `:politicas :rate-limit`) is the non-digit-only magnitude
1200/// shape: every downstream typed-magnitude codec's `render_*`
1201/// canonicalizer emits a bare integer magnitude with no leading sign
1202/// (`+` / `-`), no decimal point, and no exponent, so a signed
1203/// magnitude (`"+30s"`, `"+500m"`, `"+100/s"`, `"+64MiB"`) or a
1204/// fractional / decimal magnitude (`"1.5s"`, `"0.5m"`, `"1.0/s"`,
1205/// `"1.5KiB"`) round-trips through `render_*` to a *different*
1206/// canonical string on the next emit (`"30s"`, `"500m"`, `"100/s"`,
1207/// `"64MiB"`, `"1500ms"`, `"30s"`, `"1/s"`, `"1KiB"`) — breaking the
1208/// THEORY.md Part V render-determinism contract every typed slot
1209/// carries.
1210///
1211/// The predicate deliberately treats the empty string as non-digit-only
1212/// (returning `false`) so an upstream codec that hasn't already
1213/// refused the empty-magnitude shape on its own `Empty*` / `Bad*` arm
1214/// still routes empty input to the non-canonical branch rather than
1215/// silently accepting it via the vacuous `bytes().all(_)` truth. Every
1216/// current codec site refuses empty magnitudes on a prior arm before
1217/// this predicate is consulted (`limits::parse_byte_size`'s `num_trim`
1218/// empty branch, `limits::parse_duration`'s `num_trim` empty branch,
1219/// `limits::parse_millicores`'s `magnitude.is_empty()` branch,
1220/// `supervisor::duration_codec::parse`'s `num_trim` empty branch,
1221/// `aplicacao::rate_limit_codec::parse`'s `rate_trim` empty branch),
1222/// so on the reachable inputs the empty-string clause is a no-op; the
1223/// clause is defense-in-depth for a future codec that reaches for this
1224/// predicate before landing its own upstream empty-magnitude arm.
1225///
1226/// The predicate deliberately admits the single-byte magnitude `"0"`
1227/// (returning `true`) — every codec's `render_*` canonicalizer emits
1228/// `"0"` / `"0s"` / `"0m"` / `"0/s"` verbatim for the zero magnitude,
1229/// so the single-byte form round-trips losslessly through the codec
1230/// layer. The downstream semantic-zero gates
1231/// ([`crate::LimitsError::MemoryZero`],
1232/// [`crate::LimitsError::WallClockZero`],
1233/// [`crate::LimitsError::CpuZero`],
1234/// [`crate::SupervisorError::ZeroRestartWindow`],
1235/// [`crate::AplicacaoError::PolicyTimeoutZero`],
1236/// [`crate::AplicacaoError::PolicyCircuitBreakerWindowZero`],
1237/// [`crate::AplicacaoError::PolicyRateLimitZero`]) refuse the
1238/// semantic-zero authoring at the typed-validate layer above; the
1239/// codec-layer / typed-validate-layer partition between
1240/// canonical-form drift (this arm) and semantic-zero (the downstream
1241/// gate) remains stable across every codec site.
1242///
1243/// Peer of [`find_ascii_whitespace_byte`] /
1244/// [`find_non_ascii_whitespace_char`] /
1245/// [`is_leading_zero_padded_magnitude`] on the same
1246/// canonical-form-drift axis at the codec layer: those three
1247/// predicates close the whitespace and leading-zero-padding drift
1248/// classes (paste-from-shell-history / paste-from-typography /
1249/// paste-from-fixed-width-alignment / paste-from-columnar-report),
1250/// this one closes the leading-sign / fractional / decimal /
1251/// exponent-shape drift class (paste-from-signed-report /
1252/// paste-from-floating-point-source / paste-from-scientific-notation).
1253/// Same "single lifted source of truth" discipline: drift between any
1254/// two codec sites' digit-only rejection set becomes a single-edit
1255/// fix at this predicate rather than five independent
1256/// `!<var>.is_empty() && <var>.bytes().all(|b| b.is_ascii_digit())`
1257/// scans diverging over time. Peer of [`is_dns_1123_label`] /
1258/// [`is_gateway_api_http_path`] / [`is_git_repo_url`] — same
1259/// "typed-slot's valid set matches its codec's accepted set,
1260/// structurally" discipline carried at the codec layer.
1261#[must_use]
1262pub fn is_digit_only_magnitude(s: &str) -> bool {
1263 !s.is_empty() && s.bytes().all(|b| b.is_ascii_digit())
1264}
1265
1266/// K8s DNS-1123 label rule's max length, in bytes — the floor each
1267/// apiserver-side schema enforces independently on every `metadata.name`
1268/// / Service name / label value axis a validated identifier lands in.
1269///
1270/// Per-axis breakdown of why 63 is the strictest among the rules each
1271/// validated DNS-1123-label-shaped identifier passes through:
1272///
1273/// * `:membros :caixa` lands as the rendered programs.yaml entry's
1274/// `name:` (consumed by `lareira-fleet-programs` to derive the
1275/// `wasm.pleme.io/v1alpha1/ComputeUnit.metadata.name`), as the K8s
1276/// [`Service`][svc] `metadata.name` the future `app-operator`
1277/// provisions per-member (DNS-1035 label rule:
1278/// `[a-z]([-a-z0-9]*[a-z0-9])?` max 63), as the
1279/// [`LABEL_PROGRAM`] label value (K8s label value rule:
1280/// `[a-z0-9]([-a-z0-9_.]*[a-z0-9])?` max 63), and as a component of
1281/// the composed `<aplicacao>-<de>-to-<para>` `CiliumNetworkPolicy`
1282/// `metadata.name`.
1283/// * `:placement :clusters` lands as the K8s context name keying
1284/// every per-cluster `kubeconfig`, as the `clusters[]` filter the
1285/// `lareira-fleet-programs` aggregator applies to scope programs
1286/// to their owning cluster, and as the namespace prefix /
1287/// `cluster.x-k8s.io/v1beta1/Cluster.metadata.name` cluster
1288/// identity the future M4 cross-cluster fan-out emits per entry —
1289/// all DNS-1123-label territory.
1290/// * `:children :caixa` lands as the rendered
1291/// `wasm.pleme.io/v1alpha1/ComputeUnit.metadata.name` per child the
1292/// supervisor materializes, as the [`LABEL_PROGRAM`] label value on
1293/// every emitted child's pod identity, and as the per-child
1294/// [`Service`][svc] `metadata.name` the future wasm-operator
1295/// provisions — every K8s apiserver-side schema on each landing site
1296/// enforces the same DNS-1123 label rule on admission.
1297///
1298/// Lifted to one const so a future identifier axis reaching for the
1299/// same rule (the future per-Servico `:nome` gate at the Caixa-load
1300/// boundary, the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
1301/// per-member / per-cluster validators, the future per-Aplicacao
1302/// `:nome` gate when `feira init` lands DNS-1123 enforcement on the
1303/// scaffold's `--nome` flag) reads the limit from one place.
1304///
1305/// [svc]: https://kubernetes.io/docs/concepts/services-networking/service/
1306pub const DNS_1123_LABEL_MAX_LEN: usize = 63;
1307
1308/// Predicate: assert that `s` is a valid K8s DNS-1123 label. The
1309/// contract — exactly the regex the K8s apiserver enforces on every
1310/// `metadata.name` / Service name / label value via OpenAPI v3 admission
1311/// validation, `[a-z0-9]([-a-z0-9]*[a-z0-9])?` with a 63-byte cap:
1312///
1313/// - 1..=63 bytes ([`DNS_1123_LABEL_MAX_LEN`] cap);
1314/// - lowercase ASCII alphanumeric + hyphen (`[a-z0-9-]` only; no
1315/// uppercase — K8s rejects, no underscore — DNS-1123 forbids, no
1316/// dot — a single label is not a subdomain, no Unicode/IDN — must
1317/// be pre-encoded);
1318/// - non-hyphen ASCII alphanumeric at both label boundaries
1319/// (no `-foo`, no `foo-`).
1320///
1321/// Returns the parser-shaped reason on rejection (without wrapping in
1322/// any error variant) so each per-axis caller — `validate_membro_caixa`
1323/// for `:membros :caixa`, `validate_placement_cluster` for
1324/// `:placement :clusters`, `validate_child_caixa` for `:children :caixa`,
1325/// every future per-axis lift (the per-Servico `:nome` gate at the
1326/// Caixa-load boundary, the M4 CR materializer's per-member /
1327/// per-cluster validators) — wraps the same reason in its own typed
1328/// `*Error::*Invalid { <axis>, reason }` variant. The reason wording is
1329/// axis-agnostic ("DNS-1123 labels allow only `[a-z0-9-]`") so every
1330/// call site reading the same diagnostic points at the same rule —
1331/// drift between any two axes' rule enforcement is a build error
1332/// visible at this predicate, not a per-renderer "this passed validate
1333/// but failed admission" surprise.
1334///
1335/// Empty input is rejected at the call site (each axis has its own
1336/// narrower `*Empty` variant — [`crate::AplicacaoError::MembroCaixaEmpty`],
1337/// [`crate::AplicacaoError::PlacementClusterEmpty`],
1338/// [`crate::SupervisorError::EmptyChildName`]) before this predicate
1339/// is consulted, mirroring `validate_entrada_host`'s empty-first
1340/// cascade (c7d05ec). The predicate body re-checks empty defensively
1341/// so it can be called from any future call site without a shape-
1342/// mismatch footgun — the same "defensive re-check" discipline every
1343/// peer value-shape predicate ([`is_gateway_api_http_path`] line 730,
1344/// [`is_wit_world_ref`] line 937, [`is_nats_subject`] line 1387,
1345/// [`is_wasi_keyvalue_slot`] line 1612, [`is_git_ref_name`] line 1777)
1346/// carries. Without the defensive re-check, calling
1347/// `is_dns_1123_label("")` panics at `bytes[0]` on the empty-slice
1348/// index below (`bytes[0].is_ascii_alphanumeric()` — the boundary
1349/// arm's `s.as_bytes()[0]` access reads past the end of the empty
1350/// slice), a `panic!` far from the source caixa.lisp on any future
1351/// call site that misses the pre-check. The peer predicates all
1352/// return `Err("must not be empty")` on this input; this arm brings
1353/// `is_dns_1123_label` in line with the same defensive contract.
1354///
1355/// Lifted from `caixa-core::aplicacao` (where it was first inlined for
1356/// `:membros :caixa` in 3f9d7a0 and then reused for `:placement :clusters`
1357/// in 6cbb900) so the third axis reaching for the rule (`:children
1358/// :caixa` on the supervisor tree) lands as a thin five-line wrapper
1359/// rather than re-inlining 40 lines of regex enforcement. The
1360/// "before its third occurrence" boundary the PRIME DIRECTIVE
1361/// duplication-budget rule draws (THEORY.md §I.3.5: "the duplication
1362/// budget is zero") promotes the predicate to a typed substrate-side
1363/// primitive on the same trajectory the M2-overlay and label-selector
1364/// helpers (9e3a057, 9d09cfb, 9dbeafd, 31455a7, 07a4544) already follow.
1365///
1366/// # Errors
1367///
1368/// Returns the parser-shaped reason naming the specific violation
1369/// (length / boundary / character-class), without wrapping in any
1370/// error variant — every caller maps the same `String` into its own
1371/// typed `*Invalid { <axis>, reason }` enum variant.
1372pub fn is_dns_1123_label(s: &str) -> Result<(), String> {
1373 if s.is_empty() {
1374 return Err("must not be empty".to_string());
1375 }
1376 if s.len() > DNS_1123_LABEL_MAX_LEN {
1377 return Err(format!(
1378 "exceeds DNS-1123 label max length of {DNS_1123_LABEL_MAX_LEN} bytes \
1379 (got {} bytes; the K8s apiserver rejects longer names at admission \
1380 time on every Service / Pod / CR `metadata.name` axis)",
1381 s.len()
1382 ));
1383 }
1384 let bytes = s.as_bytes();
1385 if !bytes[0].is_ascii_alphanumeric() || !bytes[bytes.len() - 1].is_ascii_alphanumeric() {
1386 return Err("must start and end with an ASCII alphanumeric character \
1387 (no leading or trailing `-`; DNS-1123 label rule)"
1388 .to_string());
1389 }
1390 for &b in bytes {
1391 let valid = b.is_ascii_digit() || b.is_ascii_lowercase() || b == b'-';
1392 if !valid {
1393 let msg = if b.is_ascii_uppercase() {
1394 format!(
1395 "contains uppercase character {ch:?} (K8s DNS-1123 label \
1396 names are lowercase-only; use {lower:?})",
1397 ch = b as char,
1398 lower = s.to_ascii_lowercase()
1399 )
1400 } else if b == b'_' {
1401 "contains `_` (DNS-1123 labels allow only `[a-z0-9-]`; use `-` \
1402 instead)"
1403 .to_string()
1404 } else if b == b'.' {
1405 "contains `.` (a single DNS-1123 label is not a subdomain; \
1406 split into separate entries or use `-` to namespace)"
1407 .to_string()
1408 } else {
1409 format!(
1410 "contains invalid character {ch:?} (DNS-1123 labels allow \
1411 only `[a-z0-9-]`)",
1412 ch = b as char
1413 )
1414 };
1415 return Err(msg);
1416 }
1417 }
1418 Ok(())
1419}
1420
1421/// K8s Gateway API v1 `HTTPPathMatch.value` max length, in bytes —
1422/// the apiserver-side `OpenAPI` schema's `maxLength: 1024` cap. Lifted
1423/// to a typed const so a future axis reaching for the same bound (the
1424/// M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-path
1425/// validator, the future per-`HTTPRouteRule` per-path-match emission
1426/// when M4 lands per-rule overrides, the future `:politicas`-derived
1427/// per-edge HTTP path overlay's per-path validator) reads the limit
1428/// from one place. The two landed call sites — `:entrada :paths`
1429/// entries (caixa-mesh's `HTTPRoute.spec.rules[].matches[].path.value`
1430/// emission) and `:contratos :endpoint` (caixa-mesh's Cilium L7
1431/// `path:` rule emission, caixa-mesh/src/lib.rs:311) — both inherit
1432/// the same cap; drift between either landing site and the K8s CRD
1433/// schema surfaces at this one const.
1434pub const GATEWAY_API_HTTP_PATH_MAX_LEN: usize = 1024;
1435
1436/// K8s Gateway API v1 `Listener.hostname` and
1437/// `HTTPRoute.spec.hostnames[]` max length, in bytes — the apiserver-side
1438/// `OpenAPI` schema's `maxLength: 253` cap, ultimately the RFC 1035 / RFC
1439/// 1123 DNS name limit (255 wire bytes minus the trailing-dot + one length
1440/// prefix). Lifted to a typed const so a future axis reaching for the same
1441/// bound (the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
1442/// per-`:entrada :host` validator, the future per-`Certificate` SAN emitter
1443/// keying off `:entrada :host` for cert-manager, the future
1444/// multi-`:entrada` host-collision gate when M4 lands `:entrada` as a
1445/// `Vec`) reads the limit from one place. The sole landed call site — the
1446/// `:entrada :host` axis's total-length gate at
1447/// [`crate::AplicacaoSpec::validate`] via `validate_entrada_host` — reads
1448/// this constant verbatim; drift between the landing site and the K8s CRD
1449/// schema surfaces at this one const rather than a per-renderer "this
1450/// passed validate but failed admission" surprise.
1451///
1452/// Peer of [`GATEWAY_API_HTTP_PATH_MAX_LEN`] on the sibling per-route
1453/// path-value cap axis — both are apiserver-side `maxLength:` bounds on
1454/// Gateway API v1 landing sites the pleme-io substrate emits, both lift
1455/// to `caixa-core::render` so the M4 CR materializer's per-axis
1456/// validators (per-host, per-path) read from one place. Same "typed const
1457/// so the bound has exactly one source of truth" discipline every peer
1458/// upper bound in this crate carries
1459/// ([`DNS_1123_LABEL_MAX_LEN`], [`NATS_SUBJECT_MAX_LEN`],
1460/// [`WASI_KV_SLOT_MAX_LEN`], [`WIT_IDENT_MAX_LEN`],
1461/// [`crate::LIMITS_MEMORY_WASM32_MAX_BYTES`],
1462/// [`crate::POLICY_TIMEOUT_MAX`], [`crate::POLICY_RETRIES_MAX`]).
1463///
1464/// The per-label max within the hostname is [`DNS_1123_LABEL_MAX_LEN`]
1465/// (63): every `.`-separated label in a Gateway API v1 Hostname is a
1466/// DNS-1123 label under the apiserver's OpenAPI regex
1467/// `[a-z0-9]([-a-z0-9]*[a-z0-9])?`, so drift between the total-length
1468/// cap here and the per-label cap on the peer constant is impossible by
1469/// construction.
1470pub const GATEWAY_API_HOSTNAME_MAX_LEN: usize = 253;
1471
1472/// K8s Gateway API v1 `Gateway.spec.listeners[].port` — the substrate's
1473/// canonical port scalar every Aplicacao-level
1474/// [`caixa_mesh::gateway_routes`][cm] -emitted `Gateway`'s sole per-
1475/// listener HTTP-listener-port axis reads from. IANA-registered as the
1476/// well-known `http` service port (RFC 9110 §4.2.2 / RFC 3986 §3.2.3 —
1477/// the port implied by an `http://<host>/…` URL when the authority
1478/// carries no explicit `:<port>` selector), so the substrate's external
1479/// `:entrada` HTTP flow surfaces at `http://<entrada.host>/` with no
1480/// per-client port override.
1481///
1482/// Semantically distinct from [`crate::DEFAULT_SERVICO_PORT`] (8080)
1483/// on the sibling per-Servico L4 axis — that constant is the port each
1484/// in-cluster Servico's `pleme-computeunit`-emitted K8s `Service`
1485/// listens on (the destination side of every mesh flow); this constant
1486/// is the port the Aplicacao's own external Gateway listens on (the
1487/// external ingress side, K8s-Gateway-API-CRD-controller-visible).
1488/// Two axes, two lifts — a future rebrand on either axis (the
1489/// substrate moving external HTTP to `:443` under mTLS-terminated
1490/// listeners, the substrate moving in-cluster Servicos onto `:80`
1491/// once the well-known port is freed) lands on its own canonical
1492/// const without coupling either axis to the other's rebrand cycle.
1493///
1494/// Until this lift landed the value `80` lived at one production-code
1495/// call site: the `listener.insert(KUBE_KEY_PORT, …)` call at
1496/// `caixa-mesh/src/lib.rs:2588` inside
1497/// [`caixa_mesh::gateway_routes`][cm]'s per-Aplicacao `Gateway`
1498/// emitter. A future Gateway API v1 promotion moving the well-known
1499/// external HTTP listener to a substrate-chosen alternative — the
1500/// substrate moving to `:443` once cert-manager-issued
1501/// per-`:entrada :host` certificates land and the external listener
1502/// becomes HTTPS-by-default (matching the mTLS-by-default trajectory
1503/// [`crate::DEFAULT_SERVICO_PORT`]'s docstring names), a per-cluster
1504/// override the operator pins through a future `:entrada :port` slot
1505/// promoted from Servico-side (`:entrada :port` today's typed slot
1506/// names the destination Servico port, not the Gateway listener
1507/// port) — without a coordinated edit would silently emit a
1508/// `Gateway` whose per-listener HTTP-listener-port axis the K8s
1509/// Gateway API v1 controller admits at the drifted port and the
1510/// gateway-class-controller (Cilium's Envoy sidecar today) opens on
1511/// the drifted port too, so every external `:entrada` HTTP flow
1512/// drops at the first hop with no diagnostic naming the drift root
1513/// cause. Lifting the literal to a shared typed `u16` const closes
1514/// the drift footgun structurally — every consumer reads from the
1515/// same lifted constant, so any rebrand reaches every site by
1516/// construction.
1517///
1518/// Mirrors the [`crate::DEFAULT_SERVICO_PORT`] lift (a085b26) on the
1519/// peer per-renderer canonical-K8s-port-axis typed `u16` const — both
1520/// are IANA-registered service-port scalars the substrate's mesh
1521/// renderer emits under a K8s CRD's `port:` axis, both lift to
1522/// `caixa-core::render` so any future substrate-side port migration
1523/// (external HTTP `:80 → :443`, in-cluster Servico `:8080 → :80`)
1524/// lands at exactly one const per axis. Same "typed const so the
1525/// scalar has exactly one source of truth" discipline every peer
1526/// scalar in this crate carries ([`GATEWAY_API_HOSTNAME_MAX_LEN`],
1527/// [`GATEWAY_API_HTTP_PATH_MAX_LEN`], [`DNS_1123_LABEL_MAX_LEN`],
1528/// [`WIT_IDENT_MAX_LEN`]).
1529///
1530/// [cm]: ../../caixa_mesh/fn.gateway_routes.html
1531pub const GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT: u16 = 80;
1532
1533/// K8s Gateway API v1 `Gateway.spec.listeners[].name` — the substrate's
1534/// canonical author-chosen listener-name scalar every Aplicacao-level
1535/// [`caixa_mesh::gateway_routes`][cm] -emitted `Gateway`'s sole per-
1536/// listener name-discriminator axis reads from. Gateway API v1's
1537/// `Listener.name` is `SectionName`-typed (a required DNS-1123 label
1538/// unique within the parent Gateway's listener list — see the upstream
1539/// docs at
1540/// <https://gateway-api.sigs.k8s.io/api-types/gateway/#listeners> and
1541/// the type reference at
1542/// <https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.SectionName>);
1543/// downstream `HTTPRoute.spec.parentRefs[].sectionName` selectors bind
1544/// to this exact byte-string when the author wants to attach a route
1545/// to one specific listener out of a multi-listener Gateway. The V0
1546/// substrate emits exactly one HTTP listener per Aplicacao, so the
1547/// name is arbitrary from the CRD's perspective — the substrate picks
1548/// the byte-string `"http"` as the canonical short name (matching the
1549/// listener's protocol axis [`GATEWAY_API_PROTOCOL_HTTP`] in kind, but
1550/// not in bytes: this is the lowercase-ASCII listener-name identifier,
1551/// the sibling protocol scalar is the uppercase-ASCII
1552/// `ProtocolType` enum value the Gateway API v1 CRD schema pins).
1553///
1554/// Semantically distinct from every peer `"http"`-shaped byte-string
1555/// in the substrate:
1556///
1557/// - [`crate::GATEWAY_API_PROTOCOL_HTTP`] (`"HTTP"`) — the listener's
1558/// `spec.listeners[].protocol` `ProtocolType` enum value the
1559/// Gateway API v1 CRD schema pins to the uppercase-ASCII spelling;
1560/// this constant names the arbitrary author-chosen listener-name
1561/// identifier at the sibling `spec.listeners[].name` axis instead,
1562/// and the two carry different case shapes on purpose;
1563/// - [`crate::CILIUM_KEY_HTTP`] (`"http"`) — the Cilium CRD's per-
1564/// `toPorts[]` L7-HTTP-rule-list-discriminator container-axis key
1565/// (`spec.ingress[].toPorts[].rules.http`), a CRD-schema-pinned
1566/// field name the Cilium project's per-CRD-schema-migration cycle
1567/// controls; this constant names an Aplicacao-side arbitrary
1568/// listener-name at a distinct K8s Gateway API CRD path, and the
1569/// substrate can move it without touching the Cilium schema.
1570///
1571/// Byte-identical to [`CILIUM_KEY_HTTP`] today (both spell out the
1572/// four ASCII bytes `h`, `t`, `t`, `p`), but the two lifted axes name
1573/// semantically distinct surfaces — a future substrate-side listener-
1574/// name rebrand (say, `"http" → "http-v1"` once the Aplicacao renders
1575/// multiple listeners under the HTTPS-by-default trajectory) must
1576/// reach this consumer without dragging the Cilium schema key with it.
1577///
1578/// Until this lift landed the value `"http"` lived at one production-
1579/// code call site: the `listener.insert(GATEWAY_API_KEY_NAME, "http")`
1580/// call inside [`caixa_mesh::gateway_routes`][cm]'s per-Aplicacao
1581/// `Gateway` emitter. A future Gateway API v2 rebrand of the well-
1582/// known short listener-name (a substrate-side migration to a longer
1583/// discriminator once multi-listener Gateways ship, an operator-pinned
1584/// override the future `:entrada :listener-name` slot promotes) —
1585/// without a coordinated edit — would silently emit a `Gateway`
1586/// whose listener carries the drifted identifier, so every downstream
1587/// `HTTPRoute` `sectionName` selector authored against the substrate's
1588/// prior canonical name misses its listener, and every external
1589/// `:entrada` HTTP flow drops at attachment time with no diagnostic
1590/// naming the listener-name drift root cause. Lifting the literal to
1591/// a shared typed `&'static str` const closes the drift footgun
1592/// structurally — every consumer reads from the same lifted constant,
1593/// so any rebrand reaches every site by construction.
1594///
1595/// Mirrors the [`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`] lift
1596/// (cd60fde) on the peer per-listener HTTP-listener-port scalar-axis —
1597/// both are Aplicacao-side substrate-canonical scalar-value pins the
1598/// sole per-Aplicacao `Gateway` emitter reaches for, and both lift to
1599/// `caixa-core::render` so a future substrate-side rebrand on either
1600/// listener axis (`:port` → `:443`, `:name` → `"http-v1"`) lands at
1601/// exactly one const per axis. Same "typed const so the scalar has
1602/// exactly one source of truth" discipline every peer scalar in this
1603/// crate carries ([`DEFAULT_GATEWAY_CLASS_NAME`],
1604/// [`GATEWAY_API_PROTOCOL_HTTP`],
1605/// [`GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX`]).
1606///
1607/// [cm]: ../../caixa_mesh/fn.gateway_routes.html
1608pub const GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME: &str = "http";
1609
1610/// K8s Gateway API v1 `HTTPRoute.spec.rules[].matches[].path.value`
1611/// substrate-side catch-all path — the fallback URL path every
1612/// Aplicacao-level [`caixa_mesh::gateway_routes`][cm] -emitted
1613/// `HTTPRoute` renders when the typed `:entrada :paths` slot is
1614/// empty, so an author who declares an external `:entrada` but no
1615/// per-path rule surface still gets a route whose sole
1616/// `HTTPPathMatch` matches every incoming request under the
1617/// paired [`GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX`] discriminator.
1618/// K8s Gateway API v1's `PathPrefix` matcher over the bare-root
1619/// `"/"` is the canonical catch-all shape — the upstream docs at
1620/// <https://gateway-api.sigs.k8s.io/api-types/httproute/#path-based-routing>
1621/// pin the `PathPrefix "/"` combination as the "match anything the
1622/// listener admits" idiom every gateway-class controller (Cilium's
1623/// Envoy today, Envoy Gateway / Istio Gateway on the peer
1624/// controllers) treats as the equivalent of "no path predicate"
1625/// under the CRD schema.
1626///
1627/// Until this lift landed the value `"/"` lived at one production-
1628/// code call site: the `vec!["/"]` fallback arm inside
1629/// [`caixa_mesh::gateway_routes`][cm]'s `let paths: Vec<&str> =
1630/// if entrada.paths.is_empty() { vec!["/"] } else { … }` branch, the
1631/// sole per-Aplicacao HTTPRoute per-rule path-list resolver that
1632/// surfaces the catch-all URL path whenever the typed `:entrada
1633/// :paths` list is empty. A future substrate-side rebrand of the
1634/// catch-all shape — a hypothetical migration to Gateway API v2's
1635/// `Exact ""` idiom, an operator-pinned per-Aplicacao override the
1636/// future `:entrada :default-path` slot promotes, a per-controller
1637/// variant that treats `"/"` as a literal prefix rather than the
1638/// catch-all — without a coordinated edit would silently emit an
1639/// `HTTPRoute` whose sole path-match predicate rejects every
1640/// incoming request at the drifted shape, so every external
1641/// `:entrada` HTTP flow drops at the first hop with no diagnostic
1642/// naming the catch-all-path drift root cause. Lifting the literal
1643/// to a shared typed `&'static str` const closes the drift footgun
1644/// structurally — every consumer reads from the same lifted constant,
1645/// so any rebrand reaches every site by construction.
1646///
1647/// Semantically distinct from every peer HTTP-path byte-string in the
1648/// substrate. The typed [`Entrada::paths`] admission grammar
1649/// ([`is_gateway_api_http_path`] + [`GATEWAY_API_HTTP_PATH_MAX_LEN`])
1650/// admits the bare-root `"/"` at the author's slot; this constant
1651/// names the substrate's *emit-side* choice for the same byte-string
1652/// at the *no-author-input* path — the two axes carry the identical
1653/// shape today by design (the substrate's catch-all round-trips
1654/// through the same admission grammar the author's explicit `"/"`
1655/// would clear), and the paired
1656/// [`gateway_api_default_http_route_path_carries_valid_gateway_api_http_path_shape`]
1657/// cross-axis pin closes the invariant at build time.
1658///
1659/// Mirrors the [`GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME`] (a12dcdd) /
1660/// [`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`] (cd60fde) lifts on the
1661/// peer per-listener substrate-canonical scalar-value axes — all
1662/// three are Aplicacao-side substrate-canonical scalar-value pins the
1663/// sole per-Aplicacao mesh emitter reaches for at a K8s Gateway API
1664/// v1 CRD sub-path, and all three lift to `caixa-core::render` so a
1665/// future substrate-side rebrand on any one axis lands at exactly one
1666/// const per axis. Same "typed const so the scalar has exactly one
1667/// source of truth" discipline every peer scalar in this crate
1668/// carries ([`DEFAULT_GATEWAY_CLASS_NAME`],
1669/// [`GATEWAY_API_PROTOCOL_HTTP`],
1670/// [`GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX`]).
1671///
1672/// [cm]: ../../caixa_mesh/fn.gateway_routes.html
1673pub const GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH: &str = "/";
1674
1675/// Predicate: assert that `path` is a valid HTTP path under both the
1676/// K8s Gateway API v1 `HTTPPathMatch.value` admission grammar AND the
1677/// Cilium L7 `path:` rule grammar — the two landing sites every
1678/// validated pleme-io HTTP-shaped path lands in. The contract:
1679///
1680/// - 1..=[`GATEWAY_API_HTTP_PATH_MAX_LEN`] (1024) bytes;
1681/// - leading `/` (the `PathPrefix` invariant — pre-checked at the
1682/// call site by each axis's narrower `*NotAbsolute` variant;
1683/// re-checked here so the predicate is usable from any future
1684/// call site without a shape-mismatch footgun);
1685/// - no consecutive `/` characters (HTTP path matchers reject
1686/// `//` — collapse to a single `/`);
1687/// - no `/./` or `/../` segments (and no trailing `/.` or `/..`) —
1688/// path-traversal and no-op segments are rejected outright;
1689/// - no `?` (query separator: queries are matched separately via
1690/// `HTTPRoute` `queryParams`, never in the path);
1691/// - no `#` (fragment separator: fragments are client-side and
1692/// never reach the gateway);
1693/// - no whitespace (space, tab — must be percent-encoded as `%20`);
1694/// - no ASCII control characters (`0x00..0x1F`, `0x7F`);
1695/// - no non-ASCII bytes (`>= 0x80`) — RFC 3986 requires `%XX`
1696/// percent-encoding for anything outside the ASCII unreserved +
1697/// reserved set;
1698/// - no printable-ASCII byte outside the K8s Gateway API
1699/// `HTTPPathMatch.value` apiserver-side `OpenAPI` regex
1700/// `^(?:[-A-Za-z0-9/._~!$&'()*+,;=:@]|[%][0-9a-fA-F]{2})+$`
1701/// accepted set — namely `"` `<` `>` `[` `\` `]` `^` `` ` `` `{`
1702/// `|` `}`. These eleven bytes are printable ASCII but RFC 3986's
1703/// `pchar = unreserved / pct-encoded / sub-delims / ":" / "@"`
1704/// grammar excludes them, so the apiserver rejects them at
1705/// admission time on every `HTTPRoute.spec.rules[].matches[].
1706/// path.value` landing site and the Cilium L7 path matcher
1707/// refuses them too. Percent-encode (`%XX`) if the literal byte
1708/// is intended.
1709///
1710/// Returns the parser-shaped reason on rejection (without wrapping in
1711/// any error variant) so each per-axis caller — `validate_entrada_path`
1712/// for `:entrada :paths` entries, `WitContract::target` for the HTTP-
1713/// shaped `:contratos :endpoint` axis, every future per-path lift
1714/// (the M4 CR materializer's per-path validator, the future
1715/// per-`HTTPRouteRule` per-path-match emission) — wraps the same
1716/// reason in its own typed `*Invalid { <axis>, reason }` variant. The
1717/// reason wording is axis-agnostic ("HTTP path matchers reject
1718/// `//`") so every call site reading the same diagnostic points at
1719/// the same rule; drift between any two axes' rule enforcement is a
1720/// build error visible at this predicate, not a per-renderer "this
1721/// passed validate but failed admission" surprise.
1722///
1723/// Empty input is rejected at the call site (each axis has its own
1724/// narrower `*Empty` variant — [`crate::AplicacaoError::EntradaPathEmpty`],
1725/// [`crate::AplicacaoError::ContratoEndpointEmpty`]) before this
1726/// predicate is consulted, mirroring `is_dns_1123_label`'s empty-first
1727/// cascade. The predicate body re-checks empty + leading-`/`
1728/// defensively so it can be called from any future call site without
1729/// a shape-mismatch footgun.
1730///
1731/// Lifted from `caixa-core::aplicacao::validate_entrada_path` (where
1732/// it was first inlined for `:entrada :paths` in 55410e4) at the
1733/// second occurrence of the HTTP-path-grammar — the `:contratos
1734/// :endpoint` axis (c4213a4 gated non-empty + leading-`/` only,
1735/// silently passing the same authoring footguns the `:entrada :paths`
1736/// gate catches) — so the second axis lands as a thin three-line
1737/// wrapper at the per-axis call site rather than re-inlining 90 lines
1738/// of grammar enforcement. Same compounding shape as
1739/// `is_dns_1123_label` (lifted at its third occurrence in 31bfa43)
1740/// and the M2-overlay / label-selector helpers (9e3a057, 9d09cfb,
1741/// 9dbeafd, 31455a7, 07a4544) on the render side — each lifted a
1742/// recurring shape into a typed primitive at the threshold where the
1743/// duplication budget would otherwise have been exceeded.
1744///
1745/// # Errors
1746///
1747/// Returns the parser-shaped reason naming the specific violation
1748/// (length / character-class / segment / consecutive-slash), without
1749/// wrapping in any error variant — every caller maps the same
1750/// `String` into its own typed `*Invalid { <axis>, reason }` enum
1751/// variant.
1752pub fn is_gateway_api_http_path(path: &str) -> Result<(), String> {
1753 if path.is_empty() {
1754 return Err("must not be empty".to_string());
1755 }
1756 if !path.starts_with('/') {
1757 return Err("must start with `/` (HTTP path matchers require a leading `/`)".to_string());
1758 }
1759 if path.len() > GATEWAY_API_HTTP_PATH_MAX_LEN {
1760 return Err(format!(
1761 "exceeds HTTP path max length of {GATEWAY_API_HTTP_PATH_MAX_LEN} bytes \
1762 (got {} bytes; both the K8s Gateway API HTTPPathMatch.value OpenAPI \
1763 schema and the Cilium L7 path matcher reject longer values at \
1764 admission time)",
1765 path.len()
1766 ));
1767 }
1768 for &b in path.as_bytes() {
1769 let reason = if b == b'?' {
1770 Some(
1771 "must not contain `?` (queries are matched separately via HTTPRoute \
1772 `queryParams`, not in the path; drop the `?…` suffix)"
1773 .to_string(),
1774 )
1775 } else if b == b'#' {
1776 Some(
1777 "must not contain `#` (fragments are client-side and never reach \
1778 the gateway; drop the `#…` suffix)"
1779 .to_string(),
1780 )
1781 } else if b == b' ' || b == b'\t' {
1782 Some(format!(
1783 "must not contain whitespace character {ch:?} (percent-encode as `%20` \
1784 or use `-`/`_` instead)",
1785 ch = b as char
1786 ))
1787 } else if b < 0x20 || b == 0x7F {
1788 Some(format!(
1789 "must not contain control character 0x{b:02x} (HTTP path characters \
1790 must be printable ASCII; the K8s Gateway API HTTPPathMatch.value and \
1791 Cilium L7 path matcher both reject control characters at admission \
1792 time)"
1793 ))
1794 } else if b >= 0x80 {
1795 Some(format!(
1796 "must not contain non-ASCII byte 0x{b:02x} (RFC 3986 requires \
1797 percent-encoding `%XX` for characters outside the ASCII unreserved \
1798 + reserved set)"
1799 ))
1800 } else if matches!(
1801 b,
1802 b'"' | b'<' | b'>' | b'[' | b'\\' | b']' | b'^' | b'`' | b'{' | b'|' | b'}'
1803 ) {
1804 // The eleven printable-ASCII bytes outside the K8s Gateway
1805 // API HTTPPathMatch.value apiserver-side OpenAPI regex
1806 // accepted set. RFC 3986 §3.3 `pchar = unreserved /
1807 // pct-encoded / sub-delims / ":" / "@"` excludes them from
1808 // every path-segment, so the apiserver rejects them at
1809 // admission time on every
1810 // `HTTPRoute.spec.rules[].matches[].path.value` landing site
1811 // (and the Cilium L7 path matcher follows the same grammar).
1812 // Until this gate landed `validate` only refused `?`, `#`,
1813 // whitespace, control characters, and non-ASCII bytes; the
1814 // canonical author-side "I wrote a path-template variable"
1815 // / "I copied an OpenAPI route" footguns silently passed
1816 // (`/api/cart/{id}` — Gateway API uses `:foo` for path
1817 // parameters, not `{foo}`; `/api/cart[0]` — index-bracket
1818 // shape; `/api/<placeholder>` — angle-bracket placeholder;
1819 // `/api\path` — Windows path-separator typo; `/api/^foo` —
1820 // accidental shell-regex character) and the failure surfaced
1821 // at apply time as a Gateway API webhook rejection naming
1822 // the offending byte but not the offending caixa.lisp slot.
1823 // Lifting the rejection to caixa-build time makes the
1824 // canonical Gateway API HTTPPathMatch.value accepted set a
1825 // structural property of every validated `:entrada :paths`
1826 // entry and every typed-HTTP `:contratos :endpoint` payload,
1827 // mirroring the c7d05ec / 55410e4 / 4f0390b trajectory each
1828 // brought the per-axis accepted set to match the apiserver
1829 // accepted set verbatim.
1830 Some(format!(
1831 "must not contain reserved character {ch:?} (RFC 3986 \
1832 path-segment grammar — and the K8s Gateway API \
1833 HTTPPathMatch.value apiserver-side OpenAPI regex \
1834 `^(?:[-A-Za-z0-9/._~!$&'()*+,;=:@]|[%][0-9a-fA-F]{{2}})+$` — \
1835 exclude this byte from the `pchar = unreserved / pct-encoded \
1836 / sub-delims / \":\" / \"@\"` set; percent-encode as \
1837 `%{b:02X}` if the literal character is intended)",
1838 ch = b as char
1839 ))
1840 } else {
1841 None
1842 };
1843 if let Some(r) = reason {
1844 return Err(r);
1845 }
1846 }
1847 if path.contains("//") {
1848 return Err(
1849 "must not contain consecutive `/` characters (HTTP path matchers reject \
1850 `//`; collapse to a single `/`)"
1851 .to_string(),
1852 );
1853 }
1854 if path.contains("/./") || path == "/." || path.ends_with("/.") {
1855 return Err(
1856 "must not contain the `.` segment (`/./` or trailing `/.`); it is \
1857 semantically a no-op and HTTP path matchers reject it"
1858 .to_string(),
1859 );
1860 }
1861 if path.contains("/../") || path == "/.." || path.ends_with("/..") {
1862 return Err(
1863 "must not contain the `..` parent-segment (`/../` or trailing `/..`); \
1864 path traversal is rejected by HTTP path matchers"
1865 .to_string(),
1866 );
1867 }
1868 Ok(())
1869}
1870
1871/// Max length, in bytes, of a single typed `:contratos :wit` world
1872/// reference passing the [`is_wit_world_ref`] predicate. 128 bytes —
1873/// roughly 8× the longest real-world WIT reference the caixa-mesh test
1874/// fixtures carry (`wasi:keyvalue/store` = 19 bytes) and the WIT registry
1875/// references its peers under (`wasi:http/proxy@0.2.0` = 21 bytes), so
1876/// the cap exists to reject the paste-from-binary footgun (a multi-line
1877/// blob accidentally landed in the `:wit` slot) rather than to constrain
1878/// legitimate authoring. Lifted as a typed const so a future axis
1879/// reaching for the same bound (the M4 per-edge WIT registry resolver,
1880/// the future `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
1881/// per-contract WIT validator) reads from one place.
1882pub const WIT_IDENT_MAX_LEN: usize = 128;
1883
1884/// Predicate: assert that `s` is a valid WIT (WebAssembly Component
1885/// Model) world reference — the canonical shape every typed
1886/// `:contratos :wit` value carries. The contract — modeled on the
1887/// [WIT IDL grammar][wit] (`namespace:package(/interface)*(@version)?`)
1888/// restricted to the lowercase subset the pleme-io substrate dispatches
1889/// on:
1890///
1891/// - 1..=[`WIT_IDENT_MAX_LEN`] (128) bytes;
1892/// - no whitespace, no control characters, no non-ASCII bytes;
1893/// - exactly one `:` separator splitting the namespace from the
1894/// package — `wasi:http/proxy`, `nats:pub-sub`, `wasi:keyvalue/store`
1895/// (no `:` = there's no namespace to dispatch on; multiple `:` =
1896/// the package half can't parse);
1897/// - an optional `/`-separated interface suffix (one or more
1898/// segments — the WIT grammar allows `('/' id)+` after the package);
1899/// - an optional `@<version>` suffix (one trailing `@` only; the
1900/// version body is a structurally valid SemVer 2.0.0 version —
1901/// non-empty, restricted to the accepted set `[0-9A-Za-z.\-+]`, AND
1902/// round-trippable through [`semver::Version::parse`]: three-part
1903/// `major.minor.patch` numeric core mandatory (two-part `1.0` and
1904/// four-part `1.0.0.0` reject), no leading zeros in numeric
1905/// identifiers (`01.0.0` rejects), no empty pre-release / build-
1906/// metadata identifiers (`1.0.0-` and `1.0.0-.rc1` reject); the WIT
1907/// IDL binds `simple-version` to SemVer verbatim so every byte-set-
1908/// valid but shape-invalid version body fails the upstream WIT
1909/// parser at consume time);
1910/// - every identifier segment (namespace, package, each interface)
1911/// is a lowercase kebab-case ASCII identifier: `[a-z]([a-z0-9]|-)*`,
1912/// starting with a lowercase letter, no consecutive `-`, no
1913/// trailing `-`.
1914///
1915/// Lowercase-only is deliberate — the substrate's
1916/// [`crate::aplicacao::WitContract::is_http`] / `is_pubsub` / `is_store`
1917/// dispatch keys off the lowercase canonical prefix (`wasi:http/`,
1918/// `nats:`, `wasi:keyvalue/`, `kafka:`, `kv:`, `http:`). An uppercase
1919/// `WASI:HTTP/proxy` is structurally a valid WIT identifier under the
1920/// upstream IDL grammar but silently falls through every `is_*` arm and
1921/// renders as a capability-only L4-only edge — the canonical "I thought
1922/// I had L7 HTTP routing, got L4-only" footgun. Lifting the lowercase
1923/// rule to caixa-build time makes the dispatch reachable-by-construction:
1924/// every validated `:wit` value matches exactly one of the three typed
1925/// dispatch arms (or the explicit capability arm), structurally.
1926///
1927/// Returns the parser-shaped reason on rejection (without wrapping in
1928/// any error variant) so each per-axis caller — `WitContract::target`
1929/// for the `:contratos :wit` axis at validate time, the future M4 CR
1930/// materializer's per-contract WIT validator, the future per-edge WIT
1931/// registry resolver — wraps the same reason in its own typed
1932/// `*Invalid { <axis>, reason }` variant. The reason wording is
1933/// axis-agnostic ("WIT identifiers allow only `[a-z0-9-]`") so every
1934/// call site reading the same diagnostic points at the same rule;
1935/// drift between any two axes' rule enforcement is a build error
1936/// visible at this predicate, not a per-renderer "this passed validate
1937/// but silently demoted to capability-only" surprise.
1938///
1939/// Empty input is rejected here (defensively) and at the call site via
1940/// the narrower [`crate::AplicacaoError::EmptyWit`] variant — the same
1941/// empty-first cascade [`is_dns_1123_label`] and
1942/// [`is_gateway_api_http_path`] carry.
1943///
1944/// Lifted as a typed substrate-side primitive on the same trajectory
1945/// the M2-overlay and label-selector helpers (9e3a057, 9d09cfb, 9dbeafd,
1946/// 31455a7, 07a4544) and the value-shape predicates (`is_dns_1123_label`,
1947/// `is_gateway_api_http_path`) already follow — the typed slot's valid
1948/// set matches its dispatch's accepted set, structurally.
1949///
1950/// [wit]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/WIT.md
1951///
1952/// # Errors
1953///
1954/// Returns the parser-shaped reason naming the specific violation
1955/// (length / separator / character-class / kebab-shape / SemVer 2.0.0
1956/// structural invariant), without wrapping in any error variant —
1957/// every caller maps the same `String` into its own typed `*Invalid
1958/// { <axis>, reason }` enum variant.
1959pub fn is_wit_world_ref(s: &str) -> Result<(), String> {
1960 if s.is_empty() {
1961 return Err("must not be empty".to_string());
1962 }
1963 if s.len() > WIT_IDENT_MAX_LEN {
1964 return Err(format!(
1965 "exceeds WIT world-reference max length of {WIT_IDENT_MAX_LEN} bytes \
1966 (got {} bytes; legitimate WIT references rarely exceed ~32 bytes — \
1967 this length suggests a paste-from-binary or multi-line blob landed \
1968 in the `:wit` slot)",
1969 s.len()
1970 ));
1971 }
1972 for &b in s.as_bytes() {
1973 if b.is_ascii_whitespace() {
1974 return Err(format!(
1975 "must not contain whitespace character {ch:?} (WIT world references \
1976 are single tokens with no whitespace between identifier segments)",
1977 ch = b as char
1978 ));
1979 }
1980 if b < 0x20 || b == 0x7F {
1981 return Err(format!(
1982 "must not contain control character 0x{b:02x} (WIT world references \
1983 are printable ASCII tokens)"
1984 ));
1985 }
1986 if b >= 0x80 {
1987 return Err(format!(
1988 "must not contain non-ASCII byte 0x{b:02x} (WIT world references \
1989 are restricted to ASCII identifiers + the `:` / `/` / `@` / `-` \
1990 separators)"
1991 ));
1992 }
1993 }
1994 // Split off the optional `@<version>` suffix first so the
1995 // namespace/package parse below operates on a clean
1996 // `<ns>:<pkg>(/<iface>)*` head.
1997 let (head, version) = match s.split_once('@') {
1998 Some((h, v)) => (h, Some(v)),
1999 None => (s, None),
2000 };
2001 if let Some(ver) = version {
2002 if ver.is_empty() {
2003 return Err(
2004 "trailing `@` must be followed by a version (e.g. `@0.2.0`); drop \
2005 the trailing `@` to omit the version pin"
2006 .to_string(),
2007 );
2008 }
2009 if ver.contains('@') {
2010 return Err(
2011 "must contain at most one `@` separator (the optional version suffix \
2012 is `@<version>`, not `@<ver>@<ver>`)"
2013 .to_string(),
2014 );
2015 }
2016 if ver.contains(':') || ver.contains('/') {
2017 return Err(format!(
2018 "version suffix {ver:?} must not contain `:` or `/` (those separators \
2019 are reserved for the namespace and interface axes; the version body \
2020 is opaque)"
2021 ));
2022 }
2023 // Byte-set gate on the `@<version>` body: SemVer 2.0.0 restricts
2024 // every legal version to the accepted set
2025 // `[0-9A-Za-z.\-+]` — the digit + letter alphabet for the
2026 // `major.minor.patch` numeric core, the `.` segment separator,
2027 // and the `-` / `+` sigils that introduce the optional
2028 // pre-release and build-metadata suffixes. The WIT IDL binds
2029 // `simple-version` to SemVer verbatim (WebAssembly Component
2030 // Model design doc `WIT.md#versions` — `version` is parsed
2031 // through the `semver` crate), so any printable-ASCII byte
2032 // outside that set is guaranteed to fail the upstream WIT
2033 // parser at consume time. Until this gate landed the outer
2034 // whitespace / control / non-ASCII loop above rejected the
2035 // whitespace + control + non-ASCII slices of the byte axis
2036 // and the narrower `contains('@')` / `contains(':' | '/')`
2037 // arms above closed the WIT-reserved separator bytes, but
2038 // every other printable-ASCII byte (`?`, `#`, `!`, `$`, `%`,
2039 // `&`, `'`, `"`, `(`, `)`, `*`, `,`, `;`, `<`, `=`, `>`, `[`,
2040 // `\`, `]`, `^`, `` ` ``, `{`, `|`, `}`, `~`) silently rode
2041 // through — the canonical author-side footguns
2042 // (`wasi:http/proxy@0.2.0?rc1` — URL-query-separator paste
2043 // where the author copied a versioned link and the trailing
2044 // `?ref=…` came along; `wasi:http/proxy@0.2.0#build` —
2045 // URL-fragment paste; `wasi:http/proxy@0.2.0 alpha` — the
2046 // outer whitespace loop already catches this, but before that
2047 // loop landed the space rode through too; `wasi:http/proxy@
2048 // 0.2.0!alpha` — accidental history-expansion `!`;
2049 // `wasi:http/proxy@0.2.0(rc1)` — parenthetical annotation
2050 // from a doc comment) all passed `validate` and failed at
2051 // WIT-parse time far from the source caixa.lisp with a
2052 // parser diagnostic that names the offending byte but not
2053 // the offending `:contratos :wit` slot. Lifting the rejection
2054 // to caixa-build time closes the byte-set axis structurally
2055 // — every validated `@<version>` body matches the SemVer
2056 // 2.0.0 accepted set, and drift between the typed slot's
2057 // accepted set and the upstream WIT parser's accepted set is
2058 // impossible-by-construction.
2059 //
2060 // Same top-and-bottom-edge discipline the peer axes carry —
2061 // [`is_gateway_api_http_path`]'s eleven-byte RFC-3986-reserved
2062 // rejection set for `:entrada :paths` / `:contratos :endpoint`,
2063 // [`is_nats_subject`]'s strict `[A-Za-z0-9_-]` per-token
2064 // character set for `:contratos :subject`,
2065 // [`is_wit_kebab_id`]'s lowercase-kebab enforcement for the
2066 // WIT namespace/package/interface segments — the typed slot's
2067 // valid set matches the downstream parser's accepted set,
2068 // structurally.
2069 for &b in ver.as_bytes() {
2070 let valid = b.is_ascii_alphanumeric() || b == b'.' || b == b'-' || b == b'+';
2071 if !valid {
2072 return Err(format!(
2073 "version suffix {ver:?} contains invalid character {ch:?} \
2074 (SemVer 2.0.0 restricts the `@<version>` body to the accepted \
2075 set `[0-9A-Za-z.\\-+]` — digits + letters for the \
2076 `major.minor.patch` numeric core, `.` for segment separators, \
2077 `-` for the pre-release suffix, `+` for the build-metadata \
2078 suffix; every other byte fails the upstream WIT parser at \
2079 consume time)",
2080 ch = b as char
2081 ));
2082 }
2083 }
2084 // Structural SemVer 2.0.0 parse on the `@<version>` body: every
2085 // byte-set-valid version body (`[0-9A-Za-z.\-+]`, the accepted-
2086 // set arm above) is not necessarily a *structurally* valid
2087 // SemVer version. SemVer 2.0.0 imposes shape rules on top of the
2088 // byte set — three-part `major.minor.patch` mandatory (two-part
2089 // `1.0` and four-part `1.0.0.0` reject), no leading zeros in
2090 // numeric identifiers (`01.0.0` rejects, `10.0.0` accepts,
2091 // `1.0.0-01` rejects while `1.0.0-alpha01` accepts because the
2092 // pre-release identifier is alphanumeric not numeric), no empty
2093 // identifiers (`1.0.0-` and `1.0.0+` reject; `1.0.0-.rc1` and
2094 // `1.0.0-alpha..beta` reject; `1.0.0+.abc` and
2095 // `1.0.0+build..42` reject). Until this gate landed the byte-set
2096 // arm above closed only the per-byte accepted set, and every
2097 // *shape*-invalid version body — the canonical author-side
2098 // paste footguns (`wasi:http/proxy@1.0` two-part-numeric-core
2099 // paste from a Node.js `"engines"` field, `wasi:http/proxy@1`
2100 // one-part paste from a Docker `:v1` tag, `wasi:http/proxy@v0.2.0`
2101 // `v`-prefixed git-tag paste that strayed into the version body,
2102 // `wasi:http/proxy@01.0.0` mistaken zero-padded major from a
2103 // date-based version scheme, `wasi:http/proxy@1.0.0.0` four-part
2104 // paste from a Microsoft / Java build-number convention,
2105 // `wasi:http/proxy@1.0.0-` half-typed pre-release the author
2106 // started and left dangling, `wasi:http/proxy@1.0.0+` peer for
2107 // build-metadata) rode through the byte-set gate and failed at
2108 // WIT-parse time (the WIT IDL's `simple-version` binds through
2109 // the `semver` crate at consume time — see WebAssembly Component
2110 // Model design doc `WIT.md#versions`, and both the M4
2111 // `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-
2112 // contract WIT validator (MESH-COMPOSITION §III.2 #5) and the
2113 // future per-edge WIT registry resolver strict-parse the
2114 // `@<version>` body through the same crate). Failure surfaced
2115 // far from the source `caixa.lisp` with a bare `semver::Error`
2116 // that names the specific structural violation but not the
2117 // offending `:contratos :wit` slot. Lifting the parse to caixa-
2118 // build time closes the structural axis: every validated
2119 // `@<version>` body past this call is byte-for-byte round-
2120 // trippable through [`semver::Version::parse`] without re-
2121 // checking at any downstream WIT-consumer layer.
2122 //
2123 // Thin wrapper around [`semver::Version::parse`] — the same
2124 // parser [`crate::Caixa::validate_versao`] (the peer top-level
2125 // `:versao` axis) and [`crate::CaixaVersion::parse`] consume,
2126 // so the accepted set is structurally identical across every
2127 // `:versao`-shaped axis the substrate carries. Maps the
2128 // `semver::Error` reason verbatim into a self-locating
2129 // diagnostic naming the offending version body + the SemVer
2130 // 2.0.0 canonical shape the author intended, so the failure
2131 // is grep-locatable in the `caixa.lisp` (search for
2132 // `:wit "…@<value>"`) and fixable in one edit. Same top-and-
2133 // bottom-edge discipline the peer typed-codec axes carry —
2134 // every typed slot whose accepted set the substrate reads is
2135 // strict-parsed against the downstream consumer's canonical
2136 // parser at build time, not at apply time.
2137 if let Err(e) = semver::Version::parse(ver) {
2138 return Err(format!(
2139 "version suffix {ver:?} is not a structurally valid SemVer 2.0.0 \
2140 version: {e} (the WIT IDL binds `@<version>` to SemVer 2.0.0 \
2141 verbatim — three-part `major.minor.patch` numeric core, no \
2142 leading zeros in numeric identifiers, no empty pre-release / \
2143 build-metadata identifiers; every other shape fails the \
2144 upstream WIT parser at consume time)"
2145 ));
2146 }
2147 }
2148 // Then split the head on `:` — exactly one separator, splitting the
2149 // namespace from the package(/interface) body.
2150 let Some((ns, rest)) = head.split_once(':') else {
2151 return Err(format!(
2152 "must contain a `:` separating the namespace from the package (e.g. \
2153 `wasi:http/proxy`); got {s:?} with no `:` — pleme-io dispatches `:wit` \
2154 values on the canonical `<namespace>:<package>` shape and silently \
2155 demotes unmatched shapes to a capability-only L4 edge"
2156 ));
2157 };
2158 if rest.contains(':') {
2159 return Err(format!(
2160 "must contain exactly one `:` separator (between namespace and package); \
2161 got {s:?} with multiple `:`"
2162 ));
2163 }
2164 is_wit_kebab_id(ns)
2165 .map_err(|r| format!("namespace {ns:?} is not a valid WIT identifier: {r}"))?;
2166 let mut segments = rest.split('/');
2167 let pkg = segments.next().unwrap_or("");
2168 is_wit_kebab_id(pkg)
2169 .map_err(|r| format!("package {pkg:?} is not a valid WIT identifier: {r}"))?;
2170 for iface in segments {
2171 is_wit_kebab_id(iface)
2172 .map_err(|r| format!("interface {iface:?} is not a valid WIT identifier: {r}"))?;
2173 }
2174 Ok(())
2175}
2176
2177/// Predicate: assert that `s` is a lowercase kebab-case ASCII identifier
2178/// — the WIT IDL `id ::= word ('-' word)*` rule restricted to the
2179/// lowercase `word ::= [a-z][a-z0-9]*` arm the pleme-io substrate
2180/// dispatches on. Private because every legitimate caller flows through
2181/// [`is_wit_world_ref`] (which segments the world reference and runs
2182/// this predicate per segment); exposing it directly would invite
2183/// per-axis WIT-shape gates that re-implement the segmenting logic
2184/// inline.
2185fn is_wit_kebab_id(s: &str) -> Result<(), String> {
2186 if s.is_empty() {
2187 return Err("must not be empty".to_string());
2188 }
2189 let bytes = s.as_bytes();
2190 if !bytes[0].is_ascii_lowercase() {
2191 let msg = if bytes[0].is_ascii_uppercase() {
2192 format!(
2193 "must start with a lowercase ASCII letter (got uppercase {ch:?}); \
2194 pleme-io dispatches `:wit` values on the lowercase canonical shape \
2195 — `wasi:http/proxy` is recognized, `WASI:HTTP/proxy` is silently \
2196 demoted to a capability-only edge",
2197 ch = bytes[0] as char
2198 )
2199 } else if bytes[0].is_ascii_digit() {
2200 format!(
2201 "must start with a lowercase ASCII letter (got digit {ch:?}); WIT \
2202 identifiers begin with a letter, not a digit",
2203 ch = bytes[0] as char
2204 )
2205 } else if bytes[0] == b'-' {
2206 "must not start with `-` (WIT identifiers are kebab-case words; the \
2207 leading character is a lowercase letter)"
2208 .to_string()
2209 } else {
2210 format!(
2211 "must start with a lowercase ASCII letter (got {ch:?}); WIT \
2212 identifiers allow only `[a-z0-9-]`",
2213 ch = bytes[0] as char
2214 )
2215 };
2216 return Err(msg);
2217 }
2218 if bytes[bytes.len() - 1] == b'-' {
2219 return Err(
2220 "must not end with `-` (WIT identifiers are kebab-case words separated \
2221 by single hyphens; no trailing `-`)"
2222 .to_string(),
2223 );
2224 }
2225 let mut prev_hyphen = false;
2226 for &b in bytes {
2227 if b == b'-' {
2228 if prev_hyphen {
2229 return Err(
2230 "must not contain consecutive `-` characters (WIT identifiers \
2231 join words with single hyphens, not `--`)"
2232 .to_string(),
2233 );
2234 }
2235 prev_hyphen = true;
2236 continue;
2237 }
2238 let after_hyphen = prev_hyphen;
2239 prev_hyphen = false;
2240 if b.is_ascii_uppercase() {
2241 return Err(format!(
2242 "must be lowercase (got uppercase character {ch:?}); pleme-io \
2243 dispatches `:wit` values on the lowercase canonical shape — \
2244 `wasi:http/proxy` is recognized, `WASI:HTTP/proxy` is silently \
2245 demoted to a capability-only edge",
2246 ch = b as char
2247 ));
2248 }
2249 // Per-word first-byte gate. The doc-comment above binds this
2250 // predicate to the WIT IDL rule `id ::= word ('-' word)*` with
2251 // `word ::= [a-z][a-z0-9]*` — each hyphen-separated word must
2252 // begin with a lowercase letter, not a digit. The full-id
2253 // first-byte arm above ([`is_wit_kebab_id`] line ~974) closes
2254 // the leading-digit / leading-hyphen / leading-uppercase footguns
2255 // for the *first* word (`"1http"`, `"-http"`, `"Http"`); this
2256 // arm closes the same "word must begin with a lowercase letter"
2257 // rule for *every subsequent* word after a `-` separator. Until
2258 // this gate landed the byte-set arm below accepted `[a-z0-9-]`
2259 // uniformly across all positions, so an identifier like
2260 // `"pub-1sub"` / `"proxy-2beta"` / `"cap-9"` passed the byte-set
2261 // gate (every byte lies in `[a-z0-9-]`), passed the leading-`-`
2262 // arm (the first byte is `p`/`c`, not `-`), passed the
2263 // consecutive-`-` arm (no `--`), passed the trailing-`-` arm
2264 // (last byte is a lowercase letter or digit, not `-`), and was
2265 // silently accepted — the canonical `abc-<digit>*` word-shape
2266 // footgun where an author's paste-from-versioned-slug (`"proxy-2"`
2267 // from a `v2`-tagged interface hand-transcribed) or a
2268 // programmatic string-interpolation (`format!("{stem}-{n}")` with
2269 // a numeric `n`) landed in the `:contratos :wit` slot's segment.
2270 // The upstream WIT parser (WebAssembly/component-model spec §WIT
2271 // grammar; `wit-parser` crate's `id!` production) then failed at
2272 // WIT-parse time far from the source caixa.lisp with a parser
2273 // diagnostic that names the offending byte but not the offending
2274 // `:contratos :wit` slot, and the typed slot's accepted set drifted
2275 // from the upstream parser's accepted set on the exact class the
2276 // doc-comment above already documented as rejected — a
2277 // documentation-vs-implementation drift, not a novel rule. Lifting
2278 // the rejection to caixa-build time closes the per-word-first-byte
2279 // axis structurally — every validated WIT identifier past this
2280 // predicate matches the WIT IDL word grammar per-word, not just at
2281 // the first byte, and drift between the typed slot's accepted set
2282 // and the upstream WIT parser's accepted set is impossible-by-
2283 // construction on the digit-after-hyphen axis (the last remaining
2284 // documented-but-unenforced arm on the WIT kebab predicate).
2285 //
2286 // Same top-and-bottom-edge discipline the peer axes carry: every
2287 // caller ([`is_wit_world_ref`] on the `:contratos :wit` axis, and
2288 // through it the M3 `WitContract::target` cross-check at
2289 // [`crate::AplicacaoSpec::validate`]) now refuses the canonical
2290 // author-side "word two starts with a version-shape digit paste"
2291 // footgun at validate time rather than at wit-parser consume
2292 // time. Same trajectory as bb4e6c4 (`is_wit_world_ref` byte-set
2293 // gate on the `@<version>` suffix) and 9f7b894 (`is_wit_world_ref`
2294 // structural SemVer 2.0.0 parse on the `@<version>` suffix) on
2295 // the peer per-suffix axes — the same "typed-slot's accepted set
2296 // matches the downstream parser's accepted set, structurally"
2297 // discipline extended here from the version-body axis to the
2298 // per-word first-byte axis of the identifier body itself.
2299 if after_hyphen && b.is_ascii_digit() {
2300 return Err(format!(
2301 "word after `-` starts with digit {ch:?} (WIT identifiers are \
2302 `id ::= word ('-' word)*` with `word ::= [a-z][a-z0-9]*` — every \
2303 word begins with a lowercase letter, not a digit; the upstream WIT \
2304 parser rejects an identifier of this shape at consume time. Insert \
2305 a lowercase-letter prefix on the offending word — `pub-v1sub` \
2306 instead of `pub-1sub`, `proxy-v2beta` instead of `proxy-2beta`)",
2307 ch = b as char
2308 ));
2309 }
2310 if !(b.is_ascii_lowercase() || b.is_ascii_digit()) {
2311 let msg = if b == b'_' {
2312 "contains `_` (WIT identifiers are kebab-case; use `-` between \
2313 words instead of `_`)"
2314 .to_string()
2315 } else if b == b'.' {
2316 "contains `.` (WIT identifiers are single kebab-case words; split \
2317 into separate namespace/package/interface segments via `:` and \
2318 `/` instead of `.`)"
2319 .to_string()
2320 } else {
2321 format!(
2322 "contains invalid character {ch:?} (WIT identifiers allow only \
2323 `[a-z0-9-]`)",
2324 ch = b as char
2325 )
2326 };
2327 return Err(msg);
2328 }
2329 }
2330 Ok(())
2331}
2332
2333/// Max length, in bytes, of a single typed `:contratos :subject` NATS
2334/// subject passing the [`is_nats_subject`] predicate. 256 bytes —
2335/// matches the upstream NATS Java client's `MAX_SUBJECT_LENGTH`
2336/// constant and sits well above the longest legitimate subject the
2337/// caixa-mesh test fixtures + example checkout-aplicacao carry
2338/// (`"checkout.events.charge.failed"` = 30 bytes, `"rio.events.order.charged"`
2339/// = 25 bytes). The cap exists to reject the paste-from-binary footgun
2340/// (a multi-line blob accidentally landed in the `:subject` slot)
2341/// rather than to constrain legitimate authoring. Lifted as a typed
2342/// const so a future axis reaching for the same bound (the M4
2343/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-subject
2344/// validator, the future NATS Stream/Consumer CR emitter for the
2345/// `nats:pub-sub` branch of `:contratos`, the future per-edge
2346/// `:politicas`-derived NATS-aware policy overlay) reads from one
2347/// place.
2348pub const NATS_SUBJECT_MAX_LEN: usize = 256;
2349
2350/// Predicate: assert that `s` is a valid NATS subject — the canonical
2351/// shape every typed `:contratos :subject` value carries. The
2352/// contract — modeled on the [NATS subject grammar][nats] (dot-
2353/// separated tokens with `*` / `>` wildcards), restricted to the
2354/// strict `[A-Za-z0-9_-]` per-token character set the NATS server's
2355/// subject parser accepts at runtime:
2356///
2357/// - 1..=[`NATS_SUBJECT_MAX_LEN`] (256) bytes;
2358/// - no whitespace, no control characters, no non-ASCII bytes
2359/// (RFC 3986 requires `%XX` percent-encoding for non-ASCII; NATS
2360/// subjects predate that and reject any byte outside the strict
2361/// ASCII identifier set);
2362/// - one-or-more `.`-separated tokens — no leading `.`, no trailing
2363/// `.`, no consecutive `.` (NATS rejects empty tokens between
2364/// separators);
2365/// - each token is one of:
2366/// - a concrete identifier `[A-Za-z0-9_-]+` (NATS subjects are
2367/// case-sensitive; unlike DNS-1123 we don't lowercase-fold,
2368/// and underscores are permitted since NATS itself accepts them
2369/// in tokens);
2370/// - the `*` single-token wildcard (matches exactly one token;
2371/// allowed at any segment position);
2372/// - the `>` multi-token wildcard (matches one-or-more trailing
2373/// tokens; allowed ONLY as the final segment — `foo.>` matches
2374/// `foo.bar` / `foo.bar.baz`, `foo.>.bar` is rejected outright).
2375///
2376/// Returns the parser-shaped reason on rejection (without wrapping in
2377/// any error variant) so each per-axis caller — `WitContract::target`
2378/// for the `:contratos :subject` axis at validate time, the future M4
2379/// CR materializer's per-subject validator, the future NATS Stream/
2380/// Consumer CR emitter — wraps the same reason in its own typed
2381/// `*Invalid { <axis>, reason }` variant. The reason wording is axis-
2382/// agnostic ("NATS subjects reject empty tokens between separators")
2383/// so every call site reading the same diagnostic points at the same
2384/// rule; drift between any two axes' rule enforcement is a build
2385/// error visible at this predicate, not a per-renderer "this passed
2386/// validate but the NATS server rejected at publish/subscribe" surprise.
2387///
2388/// Empty input is rejected here (defensively) and at the call site via
2389/// the narrower [`crate::AplicacaoError::ContratoSubjectEmpty`] variant
2390/// — the same empty-first cascade [`is_dns_1123_label`],
2391/// [`is_gateway_api_http_path`], and [`is_wit_world_ref`] carry.
2392///
2393/// Lifted as a typed substrate-side primitive on the same trajectory
2394/// the M2-overlay and label-selector helpers (9e3a057, 9d09cfb,
2395/// 9dbeafd, 31455a7, 07a4544) and the value-shape predicates
2396/// (`is_dns_1123_label`, `is_gateway_api_http_path`,
2397/// `is_wit_world_ref`) already follow — the typed slot's valid set
2398/// matches the NATS server's accepted set, structurally.
2399///
2400/// [nats]: https://docs.nats.io/nats-concepts/subjects
2401///
2402/// # Errors
2403///
2404/// Returns the parser-shaped reason naming the specific violation
2405/// (length / separator / character-class / wildcard-position), without
2406/// wrapping in any error variant — every caller maps the same
2407/// `String` into its own typed `*Invalid { <axis>, reason }` enum
2408/// variant.
2409pub fn is_nats_subject(s: &str) -> Result<(), String> {
2410 if s.is_empty() {
2411 return Err("must not be empty".to_string());
2412 }
2413 if s.len() > NATS_SUBJECT_MAX_LEN {
2414 return Err(format!(
2415 "exceeds NATS subject max length of {NATS_SUBJECT_MAX_LEN} bytes \
2416 (got {} bytes; legitimate NATS subjects rarely exceed ~64 bytes — \
2417 this length suggests a paste-from-binary or multi-line blob landed \
2418 in the `:subject` slot)",
2419 s.len()
2420 ));
2421 }
2422 for &b in s.as_bytes() {
2423 if b == b' ' || b == b'\t' {
2424 return Err(format!(
2425 "must not contain whitespace character {ch:?} (NATS subjects \
2426 are single tokens with no whitespace between dot-separated \
2427 segments)",
2428 ch = b as char
2429 ));
2430 }
2431 if b < 0x20 || b == 0x7F {
2432 return Err(format!(
2433 "must not contain control character 0x{b:02x} (NATS subjects \
2434 are printable ASCII tokens; the NATS server's subject parser \
2435 rejects control characters at publish/subscribe time)"
2436 ));
2437 }
2438 if b >= 0x80 {
2439 return Err(format!(
2440 "must not contain non-ASCII byte 0x{b:02x} (NATS subjects \
2441 are restricted to `[A-Za-z0-9_-]` per token + the `.` \
2442 separator and the `*` / `>` wildcards)"
2443 ));
2444 }
2445 }
2446 if s.starts_with('.') {
2447 return Err(
2448 "must not start with `.` (NATS subjects reject empty leading \
2449 tokens; drop the leading `.` separator)"
2450 .to_string(),
2451 );
2452 }
2453 if s.ends_with('.') {
2454 return Err(
2455 "must not end with `.` (NATS subjects reject empty trailing \
2456 tokens; use the `>` multi-token wildcard to match arbitrary \
2457 trailing segments instead)"
2458 .to_string(),
2459 );
2460 }
2461 if s.contains("..") {
2462 return Err(
2463 "must not contain consecutive `.` characters (NATS subjects \
2464 reject empty tokens between separators; use the `*` single-\
2465 token wildcard to match any one token)"
2466 .to_string(),
2467 );
2468 }
2469 let segments: Vec<&str> = s.split('.').collect();
2470 let last_idx = segments.len() - 1;
2471 for (i, seg) in segments.iter().enumerate() {
2472 is_nats_subject_segment(seg, i, last_idx)?;
2473 }
2474 Ok(())
2475}
2476
2477/// Predicate: assert that `seg` is a valid NATS subject token at index
2478/// `i` of a `total = last_idx + 1`-segment subject. Private because
2479/// every legitimate caller flows through [`is_nats_subject`] (which
2480/// splits the subject on `.` and runs this predicate per segment);
2481/// exposing it directly would invite per-axis NATS-segment gates that
2482/// re-implement the splitting logic inline.
2483///
2484/// Mirrors the [`is_wit_kebab_id`] / [`is_wit_world_ref`] private-helper
2485/// pair on the WIT predicate.
2486fn is_nats_subject_segment(seg: &str, i: usize, last_idx: usize) -> Result<(), String> {
2487 if seg == "*" {
2488 return Ok(());
2489 }
2490 if seg == ">" {
2491 if i != last_idx {
2492 return Err(format!(
2493 "the `>` multi-token wildcard is only allowed as the \
2494 final segment (got `>` at segment {one_based} of {total}; \
2495 move to the end or use `*` for a single-token wildcard)",
2496 one_based = i + 1,
2497 total = last_idx + 1
2498 ));
2499 }
2500 return Ok(());
2501 }
2502 for &b in seg.as_bytes() {
2503 let valid = b.is_ascii_alphanumeric() || b == b'_' || b == b'-';
2504 if !valid {
2505 let msg = if b == b'*' {
2506 "contains `*` mid-segment (NATS wildcards are standalone \
2507 tokens — `foo.*.bar` matches one middle token, `foo*` \
2508 does not; split into separate `.`-separated segments)"
2509 .to_string()
2510 } else if b == b'>' {
2511 "contains `>` mid-segment (NATS wildcards are standalone \
2512 tokens — `foo.>` matches all trailing tokens, `foo>` \
2513 does not; split into separate `.`-separated segments)"
2514 .to_string()
2515 } else {
2516 format!(
2517 "contains invalid character {ch:?} in subject segment \
2518 (NATS subject tokens allow only `[A-Za-z0-9_-]`; use \
2519 `_` or `-` instead)",
2520 ch = b as char
2521 )
2522 };
2523 return Err(msg);
2524 }
2525 }
2526 Ok(())
2527}
2528
2529/// Max length, in bytes, of a single typed `:contratos :slot` WASI
2530/// keyvalue store key/template passing the [`is_wasi_keyvalue_slot`]
2531/// predicate. 512 bytes — generously above the longest realistic slot
2532/// template (`"checkout/$orderId"` = 17 bytes, `"users:{tenant}/{id}"`
2533/// = 19 bytes, `"session.tokens.<sid>"` = 20 bytes) and well under any
2534/// canonical WASI-keyvalue backend's per-key limit (etcd: 1.5 MB,
2535/// DynamoDB partition+sort key: 2 KB combined, Redis: 512 MB — the cap
2536/// is chosen for the *template* slot a typed `:contratos` edge
2537/// authors, not the realized key at runtime). The cap exists to reject
2538/// the paste-from-binary footgun (a multi-line blob accidentally landed
2539/// in the `:slot` slot) rather than to constrain legitimate authoring.
2540/// Lifted as a typed const so a future axis reaching for the same
2541/// bound (the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
2542/// per-slot validator, the future per-Servico `:capabilities`
2543/// `wasi:keyvalue/store` axis's per-slot validator when M4 lands
2544/// per-capability typed slots, the future per-edge `:politicas`-derived
2545/// kv-backend-aware policy overlay's per-slot validator) reads from
2546/// one place. Same lift trajectory as [`NATS_SUBJECT_MAX_LEN`] (which
2547/// caps the peer pub-sub payload axis at 256 bytes — twice that here
2548/// because kv slot templates legitimately compose more `/`-separated
2549/// path segments + template variables than NATS subjects do
2550/// `.`-separated tokens).
2551pub const WASI_KV_SLOT_MAX_LEN: usize = 512;
2552
2553/// Predicate: assert that `s` is a valid WASI keyvalue store slot
2554/// template — the canonical shape every typed `:contratos :slot` value
2555/// carries when its `:wit` dispatch resolves to the
2556/// [`WitTarget::Store`][st] arm (`wasi:keyvalue/store`, `kv:*`). The
2557/// WASI keyvalue 0.2 specification ([`bucket = string`, `key = string`,
2558/// both opaque][wasi-kv]) places no syntactic constraints on the key
2559/// shape, so the substrate enforces the canonical printable-ASCII
2560/// floor every realistic kv backend admits: no raw whitespace, no
2561/// control bytes, no non-ASCII bytes, length-bounded by
2562/// [`WASI_KV_SLOT_MAX_LEN`]. The grammar:
2563///
2564/// - 1..=[`WASI_KV_SLOT_MAX_LEN`] (512) bytes;
2565/// - no whitespace (space, tab — kv slot templates are single-token
2566/// identifiers / path expressions, whitespace is the canonical
2567/// paste-from-doc footgun whose runtime behavior varies
2568/// unpredictably across backends — etcd accepts, Redis accepts
2569/// but rejects subsequent CLI ops, DynamoDB rejects on write);
2570/// - no ASCII control characters (`0x00..0x1F`, `0x7F`) — every
2571/// kv backend either rejects on write (DynamoDB, etcd) or admits
2572/// and silently breaks at the next read (Redis: `\r\n` corrupts
2573/// the RESP protocol framing if the slot template is rendered
2574/// directly into a key without re-encoding);
2575/// - no non-ASCII bytes (`>= 0x80`) — RFC 3986-style percent-
2576/// encoding (`%XX`) is the substrate's canonical UTF-8 escape
2577/// for kv slot templates the author wants to namespace by
2578/// non-ASCII identifier; raw non-ASCII silently differs between
2579/// backends (etcd preserves bytes verbatim; Redis-via-RESP3 may
2580/// re-encode; DynamoDB rejects).
2581///
2582/// The predicate is intentionally permissive on structure: all
2583/// printable ASCII bytes (`0x21..0x7E`) are admitted, including
2584/// `/` (path separators), `:` (namespace separators), `.`
2585/// (dot-namespacing), `-`/`_` (identifier separators), `$`/`{`/`}`/`<`/`>`
2586/// (template-variable syntaxes — the canonical `"checkout/$orderId"`
2587/// shape carries `$`-prefixed identifiers, alternate `"users:{id}"` /
2588/// `"session.<sid>"` shapes carry `{}` / `<>` brackets), and the
2589/// remaining ASCII punctuation. The substrate doesn't know which kv
2590/// backend the runtime resolves [`WitTarget::Store`][st] to — that
2591/// choice is per-cluster, made by the operator's kv-provider binding
2592/// — so the typed slot enforces the intersection-floor every backend
2593/// admits rather than any one backend's stricter superset.
2594///
2595/// Returns the parser-shaped reason on rejection (without wrapping in
2596/// any error variant) so each per-axis caller — [`WitContract::target`]
2597/// for the `:contratos :slot` axis at validate time, the future M4 CR
2598/// materializer's per-slot validator, the future per-Servico
2599/// `:capabilities wasi:keyvalue/store` per-slot validator — wraps the
2600/// same reason in its own typed `*Invalid { <axis>, reason }` variant.
2601/// The reason wording is axis-agnostic ("kv slot templates reject raw
2602/// whitespace") so every call site reading the same diagnostic points
2603/// at the same rule; drift between any two axes' rule enforcement is
2604/// a build error visible at this predicate, not a per-renderer "this
2605/// passed validate but the kv backend rejected on first write"
2606/// surprise.
2607///
2608/// Empty input is rejected here (defensively) and at the call site
2609/// via the narrower [`crate::AplicacaoError::ContratoSlotEmpty`]
2610/// variant — the same empty-first cascade [`is_dns_1123_label`],
2611/// [`is_gateway_api_http_path`], [`is_wit_world_ref`], and
2612/// [`is_nats_subject`] all carry.
2613///
2614/// Lifted as a typed substrate-side primitive on the same trajectory
2615/// the peer payload-axis predicates ([`is_gateway_api_http_path`] for
2616/// `:endpoint`, [`is_nats_subject`] for `:subject`) already follow —
2617/// the typed slot's valid set matches the kv backend intersection-
2618/// floor's accepted set, structurally. The fifth value-shape primitive
2619/// to land in [`crate::render`] after [`is_dns_1123_label`],
2620/// [`is_gateway_api_http_path`], [`is_wit_world_ref`], and
2621/// [`is_nats_subject`] — and the one that closes the trajectory across
2622/// every typed payload axis the [`WitContract::target`] dispatch
2623/// carries (HTTP `:endpoint`, PubSub `:subject`, Store `:slot`).
2624///
2625/// [st]: crate::WitTarget::Store
2626/// [wasi-kv]: https://github.com/WebAssembly/wasi-keyvalue
2627///
2628/// # Errors
2629///
2630/// Returns the parser-shaped reason naming the specific violation
2631/// (length / whitespace / control / non-ASCII), without wrapping in
2632/// any error variant — every caller maps the same `String` into its
2633/// own typed `*Invalid { <axis>, reason }` enum variant.
2634pub fn is_wasi_keyvalue_slot(s: &str) -> Result<(), String> {
2635 if s.is_empty() {
2636 return Err("must not be empty".to_string());
2637 }
2638 if s.len() > WASI_KV_SLOT_MAX_LEN {
2639 return Err(format!(
2640 "exceeds WASI keyvalue slot max length of {WASI_KV_SLOT_MAX_LEN} bytes \
2641 (got {} bytes; legitimate kv slot templates rarely exceed ~64 bytes — \
2642 this length suggests a paste-from-binary or multi-line blob landed in \
2643 the `:slot` slot)",
2644 s.len()
2645 ));
2646 }
2647 for &b in s.as_bytes() {
2648 if b == b' ' || b == b'\t' {
2649 return Err(format!(
2650 "must not contain whitespace character {ch:?} (kv slot templates \
2651 are single-token identifiers / path expressions; raw whitespace \
2652 behaves unpredictably across kv backends — percent-encode as `%20` \
2653 or use `-`/`_` to namespace)",
2654 ch = b as char
2655 ));
2656 }
2657 if b < 0x20 || b == 0x7F {
2658 return Err(format!(
2659 "must not contain control character 0x{b:02x} (kv slot templates \
2660 are printable ASCII; control bytes either get rejected on write \
2661 by strict backends — DynamoDB, etcd — or silently corrupt the \
2662 next read on permissive ones — Redis RESP framing)"
2663 ));
2664 }
2665 if b >= 0x80 {
2666 return Err(format!(
2667 "must not contain non-ASCII byte 0x{b:02x} (RFC 3986 requires \
2668 percent-encoding `%XX` for characters outside the ASCII unreserved \
2669 + reserved set; raw non-ASCII bytes are admitted by some kv backends \
2670 verbatim and re-encoded by others — the typed slot's value set is \
2671 the intersection-floor every backend admits identically)"
2672 ));
2673 }
2674 }
2675 Ok(())
2676}
2677
2678/// Max length, in bytes, of a single typed git ref name passing the
2679/// [`is_git_ref_name`] predicate. 255 bytes — matches the POSIX
2680/// `NAME_MAX` filesystem-component limit every Git porcelain ultimately
2681/// stores refs into (loose `refs/<category>/<name>` files under
2682/// `.git/refs/`, packed-refs index entries). Refs that exceed this cap
2683/// fail to land on disk at clone/fetch time on every realistic
2684/// filesystem (ext4, btrfs, xfs, APFS, NTFS), so a `:tag` / `:branch`
2685/// past that length is unsourceable in practice. The cap exists to
2686/// reject the paste-from-binary footgun (a multi-line blob accidentally
2687/// landed in the `:tag` slot) rather than to constrain legitimate
2688/// authoring — realistic tag/branch names rarely exceed ~32 bytes
2689/// (`"v0.1.0"` = 6 bytes, `"release-1.0-alpha.1"` = 19 bytes,
2690/// `"feature/checkout-rewrite"` = 24 bytes). Lifted as a typed const
2691/// so a future axis reaching for the same bound (the future
2692/// `lacre.lisp` ref-shape gate on resolved-pin axes, the future M4
2693/// per-dep CR materializer's per-pin validator) reads from one place.
2694pub const GIT_REF_NAME_MAX_LEN: usize = 255;
2695
2696/// Predicate: assert that `s` is a valid Git ref name under the
2697/// `git check-ref-format --allow-onelevel` rule set — the canonical
2698/// shape every typed `:fonte (:tipo git …)` `:tag` / `:branch` value
2699/// carries. The contract — modeled on the [`git check-ref-format`][gcr]
2700/// grammar the Git porcelain enforces at clone/fetch/checkout time,
2701/// with the multi-component requirement waived (`:tag "v0.1.0"` and
2702/// `:branch "main"` are both single-component refs, the canonical
2703/// leaf form for caixa's `:fonte` pin axes):
2704///
2705/// - 1..=[`GIT_REF_NAME_MAX_LEN`] (255) bytes — the POSIX `NAME_MAX`
2706/// filesystem-component limit Git's loose-ref `.git/refs/<cat>/<name>`
2707/// storage tops out at;
2708/// - no ASCII control characters (`0x00..=0x1F`, `0x7F`) — Git's
2709/// refname parser rejects them, and the `\r` / `\n` arms are the
2710/// canonical "the paste-from-doc spans multiple lines" footgun;
2711/// - no whitespace (space, tab) — Git's refname parser rejects them
2712/// too; a `:tag "v0.1.0 "` (trailing space, from a copy-paste)
2713/// silently passes string emptiness checks and fails at
2714/// `git fetch origin tag 'v0.1.0 '` with a quoting-confused error
2715/// far from the source caixa.lisp;
2716/// - no non-ASCII bytes (`>= 0x80`) — Git's refname rules predate
2717/// UTF-8 normalization (NFC vs NFD on APFS silently rewrites the
2718/// ref body, breaking the lacre's content addressing); the
2719/// intersection-floor every realistic Git host accepts is ASCII
2720/// identifiers + the small punctuation set below;
2721/// - no `~`, `^`, `:`, `?`, `*`, `[`, `\` anywhere — Git reserves
2722/// these for revision-grammar expressions (`HEAD~3`, `HEAD^`,
2723/// `:/searched`, glob wildcards, refspec brackets, Windows-path
2724/// backslash);
2725/// - no `@{` sequence — Git's reflog grammar (`HEAD@{2 hours ago}`,
2726/// `branch@{upstream}`);
2727/// - the bare `@` is not a valid refname (it's the alias for `HEAD`);
2728/// - no `..` anywhere (Git's `<rev1>..<rev2>` range syntax + the
2729/// `.` / `..` parent-traversal footgun);
2730/// - per `/`-separated component: must not begin with `.` (Git
2731/// refuses to follow loose `.git/refs/<cat>/.<name>` files), must
2732/// not end with `.lock` (Git's atomic-rename guard suffix), must
2733/// not be empty (`//` rejected by the no-empty-component arm
2734/// below);
2735/// - no leading `/`, no trailing `/`, no consecutive `//`;
2736/// - no trailing `.` on the whole ref (Git rejects `<name>.`);
2737/// - no `refs/heads/` or `refs/tags/` prefix — the canonical "I
2738/// copied the fully-qualified ref name out of `git show-ref`
2739/// instead of the leaf" footgun (per [`theory/FLAKE-DEDUP.md`][fd]
2740/// `BranchName` constructor rules); the caixa-resolver prepends
2741/// the category prefix at clone time, so an author-side
2742/// `:branch "refs/heads/main"` resolves to a literal ref named
2743/// `refs/heads/refs/heads/main` on disk.
2744///
2745/// Returns the parser-shaped reason on rejection (without wrapping in
2746/// any error variant) so each per-axis caller — `DepSource::validate`
2747/// for the `:fonte :tag` / `:fonte :branch` axes at validate time,
2748/// the future per-pin gate on `lacre.lisp` resolved-ref axes, the
2749/// future M4 per-dep CR materializer's per-pin validator — wraps the
2750/// same reason in its own typed `*Invalid { <axis>, reason }` variant.
2751/// The reason wording is axis-agnostic ("git ref names reject ASCII
2752/// control characters") so every call site reading the same diagnostic
2753/// points at the same rule; drift between any two axes' rule
2754/// enforcement is a build error visible at this predicate, not a
2755/// per-renderer "this passed validate but `git fetch` rejected at
2756/// clone time" surprise.
2757///
2758/// Empty input is rejected here (defensively) and at each call site
2759/// via the narrower [`crate::DepError::FontePinEmpty`] variant — the
2760/// same empty-first cascade [`is_dns_1123_label`],
2761/// [`is_gateway_api_http_path`], [`is_wit_world_ref`],
2762/// [`is_nats_subject`], and [`is_wasi_keyvalue_slot`] all carry.
2763///
2764/// `:rev` is intentionally NOT routed through this predicate — its
2765/// author-surface shape is a hex commit-ID (`[0-9a-f]+`), not a
2766/// refname; a dedicated `is_git_oid` predicate on the parallel
2767/// hex-shape trajectory carries the reproducibility contract. Routing
2768/// `:rev` through `is_git_ref_name` would admit `:rev "main"`,
2769/// defeating the reproducibility contract `:rev` carries vs.
2770/// `:branch` / `:tag`. The reverse mis-slot — a canonical OID
2771/// (40-char SHA-1 or 64-char SHA-256 lowercase hex) pasted into the
2772/// `:tag` / `:branch` slot — is closed by this predicate too: a
2773/// pre-emption arm below rejects any value whose width and byte set
2774/// match the canonical OID shape, surfacing the cross-axis mis-slot
2775/// at validate time with a diagnostic pointing the author at the
2776/// `:rev` slot. The two predicates' valid sets intersect at exactly
2777/// the empty set, structurally.
2778///
2779/// Lifted as a typed substrate-side primitive on the same trajectory
2780/// the peer value-shape predicates ([`is_dns_1123_label`],
2781/// [`is_gateway_api_http_path`], [`is_wit_world_ref`],
2782/// [`is_nats_subject`], [`is_wasi_keyvalue_slot`]) already follow —
2783/// the typed slot's valid set matches the Git porcelain's accepted
2784/// set, structurally. The sixth value-shape primitive to land in
2785/// [`crate::render`], and the first to gate a non-K8s downstream
2786/// landing surface (git CLI invocation from caixa-resolver, vs. the
2787/// K8s apiserver / NATS server / WASI kv backend for the prior five).
2788///
2789/// [gcr]: https://git-scm.com/docs/git-check-ref-format
2790/// [fd]: pleme-io/theory/FLAKE-DEDUP.md §1 `BranchName`
2791///
2792/// # Errors
2793///
2794/// Returns the parser-shaped reason naming the specific violation
2795/// (length / control-char / forbidden-char / component-shape / prefix),
2796/// without wrapping in any error variant — every caller maps the same
2797/// `String` into its own typed `*Invalid { <axis>, reason }` enum
2798/// variant.
2799pub fn is_git_ref_name(s: &str) -> Result<(), String> {
2800 if s.is_empty() {
2801 return Err("must not be empty".to_string());
2802 }
2803 if s.len() > GIT_REF_NAME_MAX_LEN {
2804 return Err(format!(
2805 "exceeds git ref name max length of {GIT_REF_NAME_MAX_LEN} bytes \
2806 (got {} bytes; legitimate tag/branch names rarely exceed ~32 bytes — \
2807 this length suggests a paste-from-binary or multi-line blob landed \
2808 in the `:tag` / `:branch` slot)",
2809 s.len()
2810 ));
2811 }
2812 // Canonical-OID-shape pre-emption — the structural partition the
2813 // doc-comment above promises and [`crate::DepSource::validate`]
2814 // routes the `:fonte` pin axes through ([`is_git_ref_name`] for
2815 // `:tag` + `:branch`, [`is_git_oid`] for `:rev`): a value that's
2816 // exactly the canonical Git commit-OID width
2817 // ([`GIT_OID_SHA1_LEN`] (40) lowercase-hex for SHA-1,
2818 // [`GIT_OID_SHA256_LEN`] (64) lowercase-hex for SHA-256) is the
2819 // shape `is_git_oid` accepts; the two predicates' valid sets must
2820 // intersect at exactly the empty set, so a value of that shape is
2821 // rejected here. Without this arm a canonical lowercase-hex OID of
2822 // either canonical width passes every other refname-shape arm in
2823 // this predicate — pure-hex strings carry none of the forbidden
2824 // characters, no `..` / `@{` / leading-`/` / trailing-`/` /
2825 // `.lock`-suffix / `refs/heads/`-prefix — and the cross-axis
2826 // partition silently fails on the canonical "I copied the SHA out
2827 // of `git show --format=%H` and pasted it into `:tag` / `:branch`"
2828 // mis-slot footgun. The pleme-io discipline (CAIXA-SDLC §V — the
2829 // `:rev` slot carries the reproducibility contract; `:tag` /
2830 // `:branch` resolve to whatever the upstream has tagged / `HEAD`
2831 // today) requires that an OID-shaped value live under `:rev`, never
2832 // under `:tag` / `:branch`; this arm makes that discipline a typed
2833 // structural property, not a convention.
2834 //
2835 // Uppercase hex (`"DEADBEEF…"` 40 chars) is intentionally NOT
2836 // matched here — uppercase letters are legitimate in refnames per
2837 // `git check-ref-format`, so an uppercase 40/64-char hex string is a
2838 // valid refname (`is_git_ref_name` accepts it); the `:rev` axis
2839 // separately rejects uppercase via [`is_git_oid`]'s lowercase-only
2840 // contract. Off-canonical lengths (39 / 41 / 63 / 65 hex chars) are
2841 // also intentionally NOT matched — abbreviated commit IDs are
2842 // ambiguous across repository history but they're not canonical
2843 // OIDs either; they remain accepted as refnames here (consistent
2844 // with `is_git_oid` already rejecting them via its exact-width
2845 // check).
2846 if (s.len() == GIT_OID_SHA1_LEN || s.len() == GIT_OID_SHA256_LEN)
2847 && s.bytes().all(|b| matches!(b, b'0'..=b'9' | b'a'..=b'f'))
2848 {
2849 return Err(format!(
2850 "looks like a canonical Git commit OID ({len} lowercase hex \
2851 characters — the SHA-{algo} OID width); pleme-io's `:fonte` axes \
2852 partition refnames vs. commit OIDs structurally, so a value of \
2853 this shape belongs in the `:rev` slot (which routes through \
2854 `is_git_oid` for the reproducibility contract — one immutable \
2855 commit, forever), not `:tag` / `:branch` (which route through \
2856 this predicate for human-readable refs `git fetch` resolves at \
2857 clone time). Move the value to `:rev`; keeping it under `:tag` \
2858 / `:branch` is the canonical paste-from-`git show --format=%H` \
2859 mis-slot footgun, silently demoting an OID to a refname-shaped \
2860 pin the resolver would attempt to `git fetch tag '<sha>'` and \
2861 fail at clone time with a quoting-confused porcelain error far \
2862 from the source caixa.lisp.",
2863 len = s.len(),
2864 algo = if s.len() == GIT_OID_SHA1_LEN {
2865 "1"
2866 } else {
2867 "256"
2868 },
2869 ));
2870 }
2871 if s.starts_with('-') {
2872 return Err(
2873 "must not start with `-` (the canonical CLI-argument-injection \
2874 footgun on the `:tag` / `:branch` axis — caixa-resolver's \
2875 `git::checkout` invocation routes the ref name verbatim into \
2876 `git checkout --quiet --detach <ref>` (caixa-resolver/src/git.rs:41) \
2877 without a `--` argument-list terminator, so a leading `-` value \
2878 (`:tag \"-stable\"`, `:branch \"-X\"`, `:tag \"-c=core.merge=ours\"`) \
2879 silently escapes the subprocess argument boundary and gets \
2880 reinterpreted by `git checkout`'s argument parser as a CLI flag — \
2881 the canonical short-flag / long-option / config-injection vector. \
2882 Git's `check-ref-format` grammar does NOT reject a leading `-` \
2883 (it admits the byte mid-name as a legitimate kebab separator), so \
2884 every prior shape arm on this predicate passes the value through; \
2885 the diagnostic moves the gate to the subprocess-argument \
2886 boundary the resolver consumes. Peer with the \
2887 [`is_git_repo_url`] leading-`-` arm (the CLI-arg-injection \
2888 vector on the sibling `:repo` axis where `git clone <repo>` \
2889 reinterprets a leading `-` as a flag like `-upload-pack=…` / \
2890 `--config=…`), [`is_cargo_feature_name`] leading-`-` arm, and \
2891 [`is_dns_1123_label`] leading-`-` arm — every single-token typed \
2892 string slot the substrate routes through a downstream subprocess \
2893 / parser rejects the same leading-byte CLI-arg-injection shape \
2894 at validate time. Drop the leading `-`; use a kebab-separator-\
2895 between-alphanumeric-segments form like `\"v0.1.0\"` / \
2896 `\"feature-x\"` / `\"main\"` instead)"
2897 .to_string(),
2898 );
2899 }
2900 for &b in s.as_bytes() {
2901 if b == b' ' || b == b'\t' {
2902 return Err(format!(
2903 "must not contain whitespace character {ch:?} (git ref names are \
2904 single tokens with no whitespace — a trailing space in a `:tag` \
2905 / `:branch` value is the canonical paste-from-doc footgun, \
2906 silently breaking `git fetch <remote> tag '<value> '` at \
2907 clone time)",
2908 ch = b as char
2909 ));
2910 }
2911 if b < 0x20 || b == 0x7F {
2912 return Err(format!(
2913 "must not contain control character 0x{b:02x} (git ref names are \
2914 printable ASCII; `\\r` / `\\n` are the canonical \
2915 paste-from-multiline-doc footgun and break git's refname parser \
2916 at every porcelain entry point)"
2917 ));
2918 }
2919 if b >= 0x80 {
2920 return Err(format!(
2921 "must not contain non-ASCII byte 0x{b:02x} (git's refname rules \
2922 predate UTF-8 normalization — APFS NFC/NFD silently rewrites the \
2923 ref body, breaking the lacre's content addressing across \
2924 platforms; the intersection-floor every git host admits is ASCII)"
2925 ));
2926 }
2927 match b {
2928 b'~' => {
2929 return Err("must not contain `~` (git reserves `~` for the revision \
2930 grammar — `HEAD~3` means `parent of parent of parent of \
2931 HEAD`; the bare character is not admitted in a refname)"
2932 .to_string());
2933 }
2934 b'^' => {
2935 return Err("must not contain `^` (git reserves `^` for the revision \
2936 grammar — `HEAD^` means `first parent of HEAD`; the bare \
2937 character is not admitted in a refname)"
2938 .to_string());
2939 }
2940 b':' => {
2941 return Err("must not contain `:` (git reserves `:` for revspec / \
2942 refspec separators — `:refs/heads/...`, `<src>:<dst>`)"
2943 .to_string());
2944 }
2945 b'?' => {
2946 return Err("must not contain `?` (git reserves `?` for refspec glob \
2947 wildcards)"
2948 .to_string());
2949 }
2950 b'*' => {
2951 return Err("must not contain `*` (git reserves `*` for refspec glob \
2952 wildcards — `refs/heads/*:refs/remotes/origin/*`)"
2953 .to_string());
2954 }
2955 b'[' => {
2956 return Err("must not contain `[` (git reserves `[` for refspec \
2957 bracketed-glob syntax)"
2958 .to_string());
2959 }
2960 b'\\' => {
2961 return Err("must not contain `\\` (git's refname grammar rejects \
2962 backslash — the canonical Windows-path-leak footgun; use \
2963 `/` for hierarchical refs)"
2964 .to_string());
2965 }
2966 _ => {}
2967 }
2968 }
2969 if s.contains("..") {
2970 return Err(
2971 "must not contain `..` (git reserves `..` for the `<rev1>..<rev2>` \
2972 range grammar; a `..` component would also escape the loose-ref \
2973 directory tree at clone time)"
2974 .to_string(),
2975 );
2976 }
2977 if s.contains("@{") {
2978 return Err(
2979 "must not contain `@{` (git reserves `@{` for the reflog grammar \
2980 — `branch@{upstream}`, `HEAD@{2 hours ago}`)"
2981 .to_string(),
2982 );
2983 }
2984 if s == "@" {
2985 return Err(
2986 "must not be the bare `@` (git aliases `@` to `HEAD`; a `:tag` / \
2987 `:branch` named `@` is unsourceable)"
2988 .to_string(),
2989 );
2990 }
2991 if s.starts_with('/') {
2992 return Err(
2993 "must not begin with `/` (git refnames are relative to the ref \
2994 category prefix the resolver prepends — drop the leading `/`)"
2995 .to_string(),
2996 );
2997 }
2998 if s.ends_with('/') {
2999 return Err(
3000 "must not end with `/` (git refnames are leaf-or-multi-component; \
3001 a trailing `/` would resolve to an empty final component)"
3002 .to_string(),
3003 );
3004 }
3005 if s.contains("//") {
3006 return Err(
3007 "must not contain consecutive `/` characters (git refnames reject \
3008 empty components between separators)"
3009 .to_string(),
3010 );
3011 }
3012 if s.ends_with('.') {
3013 return Err(
3014 "must not end with `.` (git refnames reject a trailing `.` — \
3015 `<name>.` collides with the `<name>.lock` atomic-rename guard \
3016 suffix on case-insensitive filesystems)"
3017 .to_string(),
3018 );
3019 }
3020 if s.starts_with("refs/heads/") || s.starts_with("refs/tags/") {
3021 return Err(format!(
3022 "must not carry the fully-qualified `refs/heads/` or `refs/tags/` \
3023 prefix (this is the canonical `git show-ref` output-leak footgun; \
3024 the caixa-resolver prepends the category prefix at clone time, so \
3025 a `:branch \"refs/heads/main\"` would resolve to a literal ref \
3026 named `refs/heads/refs/heads/main` on disk — drop the prefix and \
3027 pass the leaf: `{leaf:?}`)",
3028 leaf = s
3029 .strip_prefix("refs/heads/")
3030 .or_else(|| s.strip_prefix("refs/tags/"))
3031 .unwrap_or(s),
3032 ));
3033 }
3034 for (i, component) in s.split('/').enumerate() {
3035 if component.starts_with('.') {
3036 return Err(format!(
3037 "component {component:?} (segment {one_based} of the `/`-split \
3038 refname) must not begin with `.` (git refuses to follow loose \
3039 `.git/refs/<cat>/.<name>` files)",
3040 one_based = i + 1,
3041 ));
3042 }
3043 // Case-insensitive `.lock` check: git enforces the `.lock`
3044 // suffix as the atomic-rename guard on case-sensitive
3045 // filesystems (refs/heads/main.lock collides with the
3046 // in-flight update lockfile); on case-insensitive
3047 // filesystems (APFS default, NTFS, HFS+) the `.LOCK` /
3048 // `.Lock` variants collide identically. Rejecting all case
3049 // permutations matches the broader-rejection intent on the
3050 // axis the lacre pipeline ultimately stores into.
3051 if component.len() >= 5
3052 && component.as_bytes()[component.len() - 5..].eq_ignore_ascii_case(b".lock")
3053 {
3054 return Err(format!(
3055 "component {component:?} (segment {one_based} of the `/`-split \
3056 refname) must not end with `.lock` (git uses the `.lock` \
3057 suffix as the atomic-rename guard for in-flight ref updates; \
3058 a refname ending in `.lock` is unwritable, and the suffix is \
3059 case-insensitive on the case-insensitive filesystems Git \
3060 supports — APFS default, NTFS, HFS+)",
3061 one_based = i + 1,
3062 ));
3063 }
3064 }
3065 Ok(())
3066}
3067
3068/// Length, in lowercase-hex characters, of a full Git SHA-1 commit
3069/// OID — the canonical commit identifier every `git rev-parse HEAD`
3070/// invocation emits on a SHA-1-hashed repository. `git`'s loose-object
3071/// store keys every object under `.git/objects/<first-2-hex>/<last-38-hex>`,
3072/// so the full 40-char OID is the address-of-truth the porcelain consumes
3073/// at `git fetch <remote> <40-hex>` and `git checkout <40-hex>` time;
3074/// abbreviated OIDs are admitted by the porcelain through a separate
3075/// prefix-lookup pass and are ambiguous across repository history (a 7-char
3076/// prefix that resolves to one commit today can become a collision tomorrow
3077/// as the repo grows). Lifted as a typed const so the `:fonte :rev`
3078/// validate gate, the future lacre-side resolved-rev gate, and the future
3079/// M4 per-dep CR materializer's per-pin validator all read from one place.
3080pub const GIT_OID_SHA1_LEN: usize = 40;
3081
3082/// Length, in lowercase-hex characters, of a full Git SHA-256 commit
3083/// OID — the canonical commit identifier on a SHA-256-hashed repository
3084/// (Git's [`extensions.objectFormat = sha256`][gitsha256] mode, GA since
3085/// Git 2.42 / Oct 2023). Doubled width vs. SHA-1: 256 bits = 64 hex chars.
3086/// Carried alongside [`GIT_OID_SHA1_LEN`] so the typed `:rev` slot admits
3087/// either canonical hash-algorithm OID without per-renderer branching;
3088/// the lacre's BLAKE3 content-addressing (THEORY.md §IV — typed reproducibility
3089/// envelope) is orthogonal to the upstream git's chosen object hash and
3090/// neither OID width should leak into downstream code paths.
3091///
3092/// [gitsha256]: https://git-scm.com/docs/hash-function-transition
3093pub const GIT_OID_SHA256_LEN: usize = 64;
3094
3095/// Predicate: assert that `s` is a valid Git commit OID — the canonical
3096/// shape the typed `:fonte (:tipo git …)` `:rev` axis carries. The
3097/// reproducibility contract `:rev` carries vs. `:tag` / `:branch`
3098/// (CAIXA-SDLC §V — Substrate; `:tag` resolves to whatever the upstream
3099/// has tagged today, `:branch` to whatever the upstream's HEAD points at
3100/// today, `:rev` to exactly one immutable commit forever — same shape
3101/// Unison's [content-addressed code identity][unison] gives terms by
3102/// construction: the hash is the address, the address never moves):
3103///
3104/// - exactly [`GIT_OID_SHA1_LEN`] (40, SHA-1) or [`GIT_OID_SHA256_LEN`]
3105/// (64, SHA-256) characters — the two canonical Git hash-algorithm
3106/// widths; anything in between is an abbreviated prefix (the
3107/// canonical `git log --short` / `git rev-parse --short HEAD`
3108/// paste-from-release-notes footgun), which is ambiguous across
3109/// repository history and surfaces at clone time as an
3110/// [`ambiguous argument`][gitambig] error far from the source
3111/// caixa.lisp;
3112/// - every byte in `[0-9a-f]` (lowercase ASCII hex) — `git rev-parse`
3113/// and `git show --format=%H` both emit lowercase exclusively, so an
3114/// uppercase-bearing `:rev` round-trips inconsistently across the
3115/// resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
3116/// equality-check pipeline and fails the lacre's content-addressing
3117/// equality probe with a confusing case-only diff;
3118/// - no whitespace, no control bytes, no non-ASCII, no refname
3119/// punctuation (`~ ^ : ? * [ \`), no `/` separators — every
3120/// character outside `[0-9a-f]` is rejected on the same predicate
3121/// arm, so a `:rev "main"` (the canonical "I conflated `:rev`
3122/// and `:branch`" footgun) lands at the same gate as a
3123/// `:rev "v0.1.0"` (`:tag` mis-slot) or a `:rev "c0ffee:scratch"`
3124/// (refname-shape leak); the typed `:rev` slot's valid set
3125/// intersects the `:tag` / `:branch` slot's valid set at exactly
3126/// the empty set, structurally — every refname is rejected here,
3127/// every OID is rejected by [`is_git_ref_name`].
3128/// - not the all-zero null-OID sentinel (`"0000…0000"` — 40 zeros
3129/// at SHA-1 width, 64 zeros at SHA-256 width). Git reserves this
3130/// value as the "no commit" sentinel in `git update-ref` /
3131/// pre-receive hook flows (`<old-value>` for create, `<new-value>`
3132/// for delete) and no commit in any object database has this OID,
3133/// so a `:rev "0000…0000"` is structurally impossible to resolve.
3134/// The canonical "I copy-pasted the sentinel out of `git
3135/// update-ref --stdin` docs / pre-receive hook example" footgun
3136/// would otherwise pass every other shape arm (canonical length,
3137/// lowercase hex) and surface at `git fetch <remote> 0000…0000`
3138/// time with a quoting-confused "couldn't find remote ref" error
3139/// far from the source caixa.lisp, with the lacre's content-
3140/// address locked to a `git:0000…0000` closure that never equals
3141/// any upstream's actual `HEAD`. Mirrors `is_git_ref_name`'s
3142/// canonical-OID-shape pre-emption arm (line 1322) — both
3143/// predicates carry one self-aware arm that catches values
3144/// structurally valid for the alphabet but operationally
3145/// meaningless on the typed axis.
3146///
3147/// Returns the parser-shaped reason on rejection (without wrapping in
3148/// any error variant) so each per-axis caller — [`crate::DepError::FontePinShape`]
3149/// at validate time on the `:fonte :rev` axis, the future per-pin gate
3150/// on `lacre.lisp` resolved-rev axes, the future M4 per-dep CR
3151/// materializer's per-pin validator — wraps the same reason in its own
3152/// typed `*Invalid { axis, reason }` variant. The reason wording is
3153/// axis-agnostic ("git commit OIDs are lowercase hex (`[0-9a-f]`)") so
3154/// every call site reading the same diagnostic points at the same rule.
3155///
3156/// Empty input is rejected here (defensively) and at each call site via
3157/// the narrower [`crate::DepError::FontePinEmpty`] variant — the same
3158/// empty-first cascade [`is_dns_1123_label`], [`is_gateway_api_http_path`],
3159/// [`is_wit_world_ref`], [`is_nats_subject`], [`is_wasi_keyvalue_slot`],
3160/// and [`is_git_ref_name`] all carry.
3161///
3162/// Sibling of [`is_git_ref_name`]: the two predicates together bracket
3163/// the `:fonte` pin axes — refname-shaped (`:tag` / `:branch`) vs.
3164/// hex-OID-shaped (`:rev`) — so an authored value lands in exactly one
3165/// of the two valid sets, and a cross-axis mis-slot (`:rev "main"` /
3166/// `:tag "deadbeef…"`) is a build error at the offending axis's
3167/// predicate, not a clone-time surprise.
3168///
3169/// [unison]: https://www.unison-lang.org/docs/the-big-idea/
3170/// [gitambig]: https://git-scm.com/docs/git-rev-parse#_specifying_revisions
3171///
3172/// # Errors
3173///
3174/// Returns the parser-shaped reason naming the specific violation
3175/// (length / character-class), without wrapping in any error variant —
3176/// every caller maps the same `String` into its own typed
3177/// `*Invalid { axis, reason }` enum variant.
3178pub fn is_git_oid(s: &str) -> Result<(), String> {
3179 if s.is_empty() {
3180 return Err("must not be empty".to_string());
3181 }
3182 let len = s.len();
3183 if len != GIT_OID_SHA1_LEN && len != GIT_OID_SHA256_LEN {
3184 return Err(format!(
3185 "git commit OIDs are exactly {GIT_OID_SHA1_LEN} hex chars (SHA-1) or \
3186 {GIT_OID_SHA256_LEN} hex chars (SHA-256); got {len} chars (an \
3187 abbreviated commit ID is ambiguous across repository history — \
3188 `git log --short` / `git rev-parse --short HEAD` emit prefixes for \
3189 human display only, not as reproducible commit addresses; pin the \
3190 full OID so the resolver's `git fetch <remote> <:rev>` and the \
3191 lacre's content-addressing equality probe both resolve to exactly \
3192 one immutable commit, forever)"
3193 ));
3194 }
3195 for (i, b) in s.bytes().enumerate() {
3196 match b {
3197 b'0'..=b'9' | b'a'..=b'f' => {}
3198 b'A'..=b'F' => {
3199 return Err(format!(
3200 "git commit OIDs are lowercase hex (`[0-9a-f]`); got \
3201 uppercase character {ch:?} at byte {i} (git porcelain \
3202 emits OIDs lowercase exclusively — `git rev-parse HEAD` \
3203 and `git show --format=%H` both lowercase on output; a \
3204 `:rev` value with `[A-F]` round-trips inconsistently \
3205 across the resolver's fetch ↔ `git rev-parse HEAD` \
3206 equality-check pipeline and fails the lacre's \
3207 content-addressing probe with a confusing case-only diff)",
3208 ch = b as char
3209 ));
3210 }
3211 _ => {
3212 return Err(format!(
3213 "git commit OIDs are lowercase hex (`[0-9a-f]`); got non-hex \
3214 character {ch:?} at byte {i} (the `:rev` slot's value-shape \
3215 contract is a hex commit ID — for refname-shaped pins \
3216 (`v0.1.0`, `main`, `feature/checkout`) use `:tag` or \
3217 `:branch`, not `:rev`; the substrate's `is_git_ref_name` \
3218 and `is_git_oid` predicates partition the `:fonte` axes \
3219 structurally, so a cross-axis mis-slot lands at the \
3220 offending axis's predicate, not at clone time)",
3221 ch = b as char
3222 ));
3223 }
3224 }
3225 }
3226 // Null-OID sentinel pre-emption — the all-zero hex string is git's
3227 // canonical "no commit" sentinel (used in `git update-ref` /
3228 // pre-receive hook flows as the old-value side of ref-create and the
3229 // new-value side of ref-delete) and never names a real commit in any
3230 // repo's object database. A `:rev "0000000000000000000000000000000000000000"`
3231 // (SHA-1 width) or `:rev "0000…0000"` (SHA-256 width) is the canonical
3232 // "I copy-pasted the no-such-commit sentinel out of `git
3233 // update-ref --stdin` docs / pre-receive hook example" footgun: it's
3234 // shape-valid hex of canonical width but resolves to nothing at
3235 // `git fetch <remote> 0000…0000` time and surfaces as a fetch failure
3236 // far from the source caixa.lisp, with the lacre's
3237 // content-addressing probe locked to a non-resolvable `git:0000…0000`
3238 // closure that never equals any upstream's actual `HEAD`. Rejecting
3239 // at the predicate keeps the `:rev` slot's accepted set aligned with
3240 // its documented reproducibility contract — "exactly one immutable
3241 // commit, forever" — by structurally refusing the only OID-shaped
3242 // value the contract cannot uphold (no commit means no immutable
3243 // resolution). Same pre-emption shape `is_git_ref_name`'s canonical-
3244 // OID-shape pre-emption arm (caixa-core/src/render.rs:1322) carries
3245 // — both predicates carry one self-aware arm that catches values
3246 // structurally valid for the alphabet but operationally meaningless
3247 // on the typed axis.
3248 if s.bytes().all(|b| b == b'0') {
3249 return Err(format!(
3250 "must not be the all-zero null-OID sentinel ({len} `0` \
3251 characters — git's canonical `no-such-commit` value used by \
3252 `git update-ref` / pre-receive hook flows to indicate ref \
3253 create/delete; no commit in any object database has this OID, \
3254 so the resolver's `git fetch <remote> 0000…0000` would fail \
3255 far from the source caixa.lisp and the lacre would lock to a \
3256 `git:0000…0000` closure that never equals any upstream's \
3257 actual `HEAD`. The `:rev` slot's reproducibility contract \
3258 requires a *real* commit OID — the canonical authoring shape \
3259 is the lowercase-hex value `git rev-parse HEAD` emits for an \
3260 actual commit, like `\"c99fdb36abc7d3e1f4a5b6789012345678901234\"`)"
3261 ));
3262 }
3263 Ok(())
3264}
3265
3266/// `:fonte (:tipo git :repo …)` value max length, in bytes — a generous
3267/// URL-shaped cap covering every documented author surface (the
3268/// `github:org/repo` shorthand, the `https://` / `ssh://` / `git://` /
3269/// `file://` URL schemes, the `git@host:path` scp-style SSH form). The
3270/// cap mirrors the conservative ceiling typical HTTP gateways and git
3271/// porcelain entries enforce on URL inputs (the OWASP-recommended URL
3272/// max of 2048 bytes); a `:repo` value above this bound is structurally
3273/// untenable on every realistic landing site — the caixa-resolver's
3274/// `git clone <repo>` invocation, the future M4
3275/// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's per-dep `repo:`
3276/// axis, the future lacre BLAKE3 closure's resolved-repo identity — and
3277/// a value of that length is almost certainly a paste-from-binary slug
3278/// or a multi-line blob that landed in the slot.
3279///
3280/// Lifted as a typed `pub const` (rather than an inline literal at the
3281/// [`is_git_repo_url`] call site) so a future axis reaching for the same
3282/// bound (the future lacre-side resolved-repo gate, the M4 CR
3283/// materializer's per-dep `repo:` admission webhook) reads from one
3284/// place. Same shape every other typed bound in this module carries
3285/// ([`DNS_1123_LABEL_MAX_LEN`], [`GATEWAY_API_HTTP_PATH_MAX_LEN`],
3286/// [`NATS_SUBJECT_MAX_LEN`], [`WASI_KV_SLOT_MAX_LEN`],
3287/// [`GIT_REF_NAME_MAX_LEN`]).
3288pub const GIT_REPO_URL_MAX_LEN: usize = 2048;
3289
3290/// Predicate: assert that `s` is a value-shape-valid `:fonte (:tipo git
3291/// :repo …)` value — the canonical shape every typed `:deps :fonte`
3292/// (and future `:deps-dev :fonte`) git-source carries. The contract —
3293/// modeled on the intersection of (a) the git porcelain's URL-parser
3294/// accepted set the caixa-resolver invokes at `git clone <repo>` time,
3295/// (b) the OWASP URL-shape guidance for author-surface inputs that flow
3296/// to a CLI subprocess, and (c) the typed slot's documented accepted
3297/// shapes ([`crate::DepSource::Git`] doc comment: `github:org/repo`
3298/// shorthand, `https://…` / `ssh://…` / `git://…` / `file://…` URL
3299/// schemes, `git@host:path` scp-style SSH):
3300///
3301/// - 1..=[`GIT_REPO_URL_MAX_LEN`] (2048) bytes;
3302/// - must not start with `-` (the canonical CLI-argument-injection
3303/// footgun — `git clone <repo>` interprets a leading `-` as a CLI
3304/// flag, so a `:repo "-upload-pack=evil"` value escapes the
3305/// subprocess argument boundary and runs an attacker-controlled
3306/// command; the `--` separator workaround does not fix the typed
3307/// slot's accepted set, the gate rejects the shape upstream);
3308/// - no whitespace (space, tab) — every documented form is a single
3309/// token without whitespace; a `:repo "github:p/x "` (trailing
3310/// space, paste-from-doc) silently passes the empty check and
3311/// surfaces at `git clone` time with a quoting-confused error far
3312/// from the source caixa.lisp;
3313/// - no ASCII control characters (`0x00..=0x1F`, `0x7F`) — the `\r`
3314/// / `\n` arms are the canonical "the paste-from-multiline-doc
3315/// spans multiple lines" footgun, and CRLF injection at the URL
3316/// boundary is a class of subprocess-arg attack;
3317/// - no non-ASCII bytes (`>= 0x80`) — IDN hosts must be pre-encoded
3318/// as Punycode (`xn--…`); raw non-ASCII silently breaks at git's
3319/// URL parser and may round-trip inconsistently across NFC/NFD
3320/// normalization on APFS / case-folding filesystems, the same
3321/// intersection-floor [`is_git_ref_name`] enforces on the peer
3322/// refname axes;
3323/// - no `#` URL-fragment-identifier byte (RFC 3986 §3.5) — every
3324/// documented `:repo` shape (`github:org/repo` shorthand,
3325/// `https://…` / `ssh://…` / `git://…` / `file://…` URL schemes,
3326/// `git@host:path` scp-style SSH) carries none; libcurl's URL
3327/// parser (the layer `git clone <https-url>` invokes) and git's
3328/// own URL handlers strip the `#fragment` tail before opening
3329/// the transport, so the byte rides verbatim into the lacre's
3330/// per-dep content-address (`conteudo: format!("git:{repo}…")`,
3331/// caixa-resolver/src/resolve.rs) but is silently dropped on the
3332/// wire — two repos whose values differ only in their fragment
3333/// anchor (`":repo "https://github.com/foo/bar#readme"` vs
3334/// `":repo "https://github.com/foo/bar#L42"`) resolve to the
3335/// byte-identical upstream `git clone` but lock to two distinct
3336/// BLAKE3 closures, defeating the THEORY.md §V.2 render-
3337/// determinism contract. The canonical "I copy-pasted the
3338/// permalink-to-line / anchor-to-README URL out of the browser
3339/// address bar and forgot to trim the `#`-tail" footgun, and the
3340/// symmetric "I confused the Nix flake-ref idiom (`github:foo/
3341/// bar#packageName`) with the bare git `:repo` shape" footgun;
3342/// `:repo` is a git URL, not a Nix flake reference, so the `#`-
3343/// suffix is structurally meaningless on this axis;
3344/// - no `?` URL-query-component byte (RFC 3986 §3.4) — every
3345/// documented `:repo` shape (`github:org/repo` shorthand,
3346/// `https://…` / `ssh://…` / `git://…` / `file://…` URL schemes,
3347/// `git@host:path` scp-style SSH) carries none; GitHub /
3348/// GitLab / Bitbucket all silently ignore the `?query` tail on
3349/// a repo URL (the canonical `https://github.com/foo/bar?
3350/// tab=readme-ov-file` browser-tab deep-link, the `?ref=main`
3351/// GitHub-tree-URL parameter, the `?utm_source=…` campaign-
3352/// tracker shape every social-share / newsletter / Slack
3353/// unfurl appends) and serve the same repo regardless, so the
3354/// byte rides verbatim into the lacre's per-dep content-
3355/// address but is silently masked at the wire — two repos
3356/// whose values differ only in their query tail
3357/// (`":repo "https://github.com/foo/bar?tab=readme-ov-file"` vs
3358/// `":repo "https://github.com/foo/bar?utm_source=twitter"`)
3359/// resolve to the byte-identical upstream `git clone` but lock
3360/// to two distinct BLAKE3 closures, defeating the THEORY.md
3361/// §V.2 render-determinism contract on the same axis the `#`
3362/// fragment arm closes. The Smart-HTTP transport (the layer
3363/// `git clone <https-url>` uses) appends its own
3364/// `?service=git-upload-pack` query internally; an
3365/// author-supplied `?` byte additionally collides with that
3366/// internal axis at every git porcelain entry-point. The
3367/// canonical "I copy-pasted the GitHub tree-URL out of the
3368/// browser address bar and forgot to trim the `?tab=…` /
3369/// `?ref=…` tail" footgun, peer with the `#` fragment arm on
3370/// the same paste-from-browser-address-bar trajectory;
3371/// - no embedded `\` byte (RFC 3986 §3.3 reserves `/` as the path-
3372/// segment separator; no URL grammar admits `\`) — every
3373/// documented `:repo` shape (`github:org/repo` shorthand,
3374/// `https://…` / `ssh://…` / `git://…` / `file://…` URL schemes,
3375/// `git@host:path` scp-style SSH) uses `/` as the path separator.
3376/// The canonical Windows-path-confusion footgun: an author
3377/// pastes `file:///C:\Users\me\repo` from a Windows Explorer
3378/// address bar / PowerShell `Get-Location` output, or
3379/// `https://github.com\foo\bar` after a Win32 shell mangled
3380/// the slashes, or the bare Windows-rooted path `C:\repo` into
3381/// a slot expecting a `file://` URL. libcurl's URL parser
3382/// (the layer `git clone <https-url>` invokes) silently
3383/// translates `\` → `/` on some platforms and refuses it on
3384/// others — the byte rides verbatim into the lacre's per-dep
3385/// content-address but is silently rewritten or rejected at
3386/// the wire, defeating the THEORY.md §V.2 render-determinism
3387/// contract on the same axis the `#` fragment / `?` query arms
3388/// close. The peer [`DepError::FonteCaminhoBackslash`] arm
3389/// (commit 3a4e1d7) closes the same byte on the sibling
3390/// `:fonte :caminho` path-fonte axis; this arm closes the
3391/// URL-grammar axis so every byte past `is_git_repo_url`
3392/// reaches `git clone`'s wire-format intact;
3393/// - no embedded `{` / `}` byte — RFC 3986 §2 excludes the pair
3394/// from URL syntax (they sit in the 'delims' / 'unwise' byte
3395/// set every URL parser is required to refuse or percent-
3396/// encode), and RFC 6570 reserves the matched pair for URI
3397/// Template placeholders (the canonical
3398/// `https://{host}/{org}/{repo}` substitution shape every
3399/// `OpenAPI` / Swagger / Postman / GitHub Octokit client library
3400/// / Helm chart-URL fragment carries). The canonical 'I forgot
3401/// to resolve the template placeholder' footgun: an author
3402/// pastes `:repo "https://github.com/{org}/{repo}"` from a
3403/// README quick-start snippet, an `OpenAPI` `servers:` URL, a
3404/// Helm chart's `home:` template, or the Mustache / Handlebars
3405/// `{{org}}/{{repo}}` doubled-brace substitution form every
3406/// CI / `IaC` templating engine emits, expecting the substrate
3407/// to resolve the placeholder downstream. libcurl percent-
3408/// encodes `{` / `}` to `%7B` / `%7D` on the wire so the byte
3409/// round-trips inconsistently between the lacre's per-dep
3410/// content-address and the resolver's `git clone <repo>`
3411/// invocation, defeating the THEORY.md §V.2 render-
3412/// determinism contract on the same axis the `#` fragment /
3413/// `?` query / `\` backslash arms close; every git porcelain
3414/// entry-point additionally fetches a nonexistent
3415/// `{placeholder}`-named path far from the source caixa.lisp;
3416/// - no embedded `<` / `>` byte — RFC 3986 §2 excludes the pair
3417/// from URL syntax under the same 'delims' / 'unwise' banner the
3418/// `{` / `}` arm cites, and no git URL grammar admits either byte:
3419/// the WHATWG URL spec's 'fragment percent-encode set' maps `<`
3420/// → `%3C` and `>` → `%3E` so every conformant URL parser
3421/// refuses or rewrites the literal byte on the wire. Beyond the
3422/// URL-grammar violation, every POSIX shell lexes `<` as the
3423/// input-redirection operator and `>` as the output-redirection
3424/// operator — the canonical paste-from-shell-prompt footgun the
3425/// peer [`DepError::FonteCaminhoShellRedirection`] arm
3426/// (commit e457141) closes on the sibling `:fonte :caminho`
3427/// path-fonte axis. The byte rides verbatim into the lacre's
3428/// per-dep content-address while libcurl percent-encodes it on
3429/// the wire — two authors whose `:repo` values differ only in
3430/// `<`/`>` presence resolve to the byte-identical upstream
3431/// `git clone` but lock to two distinct BLAKE3 closures,
3432/// defeating the THEORY.md §V.2 render-determinism contract on
3433/// the same axis the `#` fragment / `?` query / `\` backslash /
3434/// `{` / `}` template arms close;
3435/// - no embedded `` ` `` (backtick) byte — RFC 3986 §2 lists the
3436/// backtick in the 'delims' / 'unwise' set every URL parser is
3437/// required to refuse or percent-encode, and no git URL grammar
3438/// admits the byte: the WHATWG URL spec's 'fragment percent-
3439/// encode set' maps `` ` `` → `%60` so every conformant URL
3440/// parser refuses or rewrites the literal byte on the wire.
3441/// Beyond the URL-grammar violation, every POSIX shell lexes the
3442/// backtick as the legacy command-substitution operator
3443/// (`` `<cmd>` `` runs `<cmd>` in a subshell and substitutes its
3444/// stdout) — the canonical paste-from-shell-prompt RCE-class
3445/// footgun the peer [`crate::DepError::FonteCaminhoShellCommandSubstitution`]
3446/// arm (commit c4d62b3) closes on the sibling `:fonte :caminho`
3447/// path-fonte axis. The byte rides verbatim into the lacre's
3448/// per-dep content-address while libcurl percent-encodes it on
3449/// the wire — two authors whose `:repo` values differ only in
3450/// backtick presence resolve to the byte-identical upstream `git
3451/// clone` but lock to two distinct BLAKE3 closures, defeating
3452/// the THEORY.md §V.2 render-determinism contract on the same
3453/// axis the `#` fragment / `?` query / `\` backslash / `{` / `}`
3454/// template / `<` / `>` shell-redirection arms close;
3455/// - must contain a `:` separator at a non-leading position — every
3456/// documented form carries one (`github:org/repo`, `https://…`,
3457/// `ssh://…`, `git://…`, `file://…`, `git@host:path`); the
3458/// bare `org/repo` (no scheme) shape is ambiguous (could be a
3459/// filesystem path or a missing scheme) and silently passes
3460/// downstream git porcelain as a local relative path rather than
3461/// the intended GitHub-shorthand expansion. A leading `:` (`":foo"`)
3462/// is the canonical "empty scheme" footgun and is rejected too.
3463///
3464/// Returns the parser-shaped reason on rejection (without wrapping in
3465/// any error variant) so each per-axis caller — [`crate::DepError::FonteRepoShape`]
3466/// at validate time on the `:fonte :repo` axis, the future per-pin gate
3467/// on `lacre.lisp` resolved-repo axes, the future M4 per-dep CR
3468/// materializer's per-repo validator — wraps the same reason in its
3469/// own typed `*Invalid { axis, reason }` variant. The reason wording is
3470/// axis-agnostic ("git repo URLs reject whitespace") so every call site
3471/// reading the same diagnostic points at the same rule; drift between
3472/// any two axes' rule enforcement is a build error visible at this
3473/// predicate, not a per-resolver "this passed validate but `git clone`
3474/// rejected" surprise.
3475///
3476/// Empty input is rejected here (defensively) and at each call site via
3477/// the narrower [`crate::DepError::FonteRepoEmpty`] variant — the same
3478/// empty-first cascade [`is_dns_1123_label`], [`is_gateway_api_http_path`],
3479/// [`is_wit_world_ref`], [`is_nats_subject`], [`is_wasi_keyvalue_slot`],
3480/// [`is_git_ref_name`], and [`is_git_oid`] all carry.
3481///
3482/// Lifted as the seventh value-shape primitive in this module, peer with
3483/// [`is_git_ref_name`] (the `:fonte :tag` / `:fonte :branch` refname-
3484/// shaped axes) and [`is_git_oid`] (the `:fonte :rev` commit-OID axis) —
3485/// together they bracket the typed `:fonte` slot end-to-end: the
3486/// `:repo` URL axis (gate here), the refname-pin axes (gate via
3487/// `is_git_ref_name`), the OID-pin axis (gate via `is_git_oid`). Every
3488/// validated `:fonte (:tipo git …)` past `DepSource::validate` is
3489/// guaranteed-acceptable by the caixa-resolver's `git clone`/`git
3490/// fetch`/`git checkout` invocations, structurally — the parser-of-
3491/// record divergence the prior trajectory closed on the pin axes is
3492/// now closed on the last unsealed `:fonte` axis.
3493///
3494/// # Errors
3495///
3496/// Returns the parser-shaped reason naming the specific violation
3497/// (length / leading-`-` / whitespace / control-char / non-ASCII /
3498/// fragment-`#` / query-`?` / backslash-`\` / template-`{`-or-`}` /
3499/// shell-redirection-`<`-or-`>` / shell-command-substitution-backtick /
3500/// missing-`:` separator / leading-`:`), without wrapping in any error
3501/// variant — every caller maps the same `String` into its own typed
3502/// `*Invalid { axis, reason }` enum variant.
3503#[allow(
3504 clippy::too_many_lines,
3505 reason = "the per-byte rejection cascade is structurally flat by design — \
3506 every arm carries its own self-locating diagnostic with the offending \
3507 byte named verbatim plus the canonical paste-from-shape footgun the \
3508 gate closes, so collapsing onto a single shared `for &b in …` loop \
3509 would regress the per-arm `feira lint` consumer surface — peer with \
3510 the `clippy::too_many_lines` allow on `DepSource::validate_caminho` \
3511 (caixa-core/src/dep.rs:323) on the same cascade-shape rationale"
3512)]
3513pub fn is_git_repo_url(s: &str) -> Result<(), String> {
3514 if s.is_empty() {
3515 return Err("must not be empty".to_string());
3516 }
3517 if s.len() > GIT_REPO_URL_MAX_LEN {
3518 return Err(format!(
3519 "exceeds git repo URL max length of {GIT_REPO_URL_MAX_LEN} bytes \
3520 (got {} bytes; legitimate `github:org/repo` shorthands and \
3521 `https://…` / `ssh://…` / `git://…` / `file://…` URLs rarely \
3522 exceed ~128 bytes — this length suggests a paste-from-binary or \
3523 multi-line blob landed in the `:repo` slot)",
3524 s.len()
3525 ));
3526 }
3527 if s.starts_with('-') {
3528 return Err(
3529 "must not start with `-` (the canonical CLI-argument-injection \
3530 footgun — `git clone <repo>` interprets a leading `-` as a CLI \
3531 flag, so a `-upload-pack=…` / `--config=…` value escapes the \
3532 subprocess argument boundary; use a scheme prefix like \
3533 `github:org/repo`, `https://host/path`, `ssh://[user@]host/path`, \
3534 `git://host/path`, `git@host:path`, or `file:///path` for the \
3535 intended source)"
3536 .to_string(),
3537 );
3538 }
3539 for &b in s.as_bytes() {
3540 if b == b' ' || b == b'\t' {
3541 return Err(format!(
3542 "must not contain whitespace character {ch:?} (git repo URLs \
3543 are single tokens with no whitespace — a trailing space in a \
3544 `:repo` value is the canonical paste-from-doc footgun, \
3545 silently breaking `git clone '<value> '` at clone time)",
3546 ch = b as char
3547 ));
3548 }
3549 if b < 0x20 || b == 0x7F {
3550 return Err(format!(
3551 "must not contain control character 0x{b:02x} (git repo URLs \
3552 are printable ASCII; `\\r` / `\\n` are the canonical paste-\
3553 from-multiline-doc footgun and break git's URL parser at \
3554 every porcelain entry point, plus CRLF at the URL boundary \
3555 is a class of subprocess-arg injection)"
3556 ));
3557 }
3558 if b >= 0x80 {
3559 return Err(format!(
3560 "must not contain non-ASCII byte 0x{b:02x} (IDN hosts must be \
3561 pre-encoded as Punycode `xn--…`; raw non-ASCII silently \
3562 breaks at git's URL parser and round-trips inconsistently \
3563 across NFC/NFD normalization on APFS / case-folding \
3564 filesystems)"
3565 ));
3566 }
3567 if b == b'#' {
3568 return Err("must not contain `#` (RFC 3986 §3.5 URL fragment \
3569 identifier; libcurl's URL parser — the layer `git \
3570 clone <https-url>` invokes — strips the `#fragment` \
3571 tail before opening the transport, so the byte rides \
3572 verbatim into the lacre's per-dep content-address but \
3573 is silently dropped on the wire, defeating the \
3574 THEORY.md §V.2 render-determinism contract: two \
3575 authors whose `:repo` values differ only in their \
3576 fragment anchor (`#readme` vs `#L42`) resolve to the \
3577 byte-identical upstream `git clone` but lock to two \
3578 distinct BLAKE3 closures. The canonical \
3579 paste-from-browser-address-bar footgun (every web URL \
3580 to a README section / line-permalink carries one), \
3581 and the canonical \"I confused the Nix flake-ref \
3582 idiom (`github:foo/bar#packageName`) with the bare \
3583 git `:repo` shape\" footgun — `:repo` is a git URL, \
3584 not a Nix flake reference, so the `#`-suffix is \
3585 structurally meaningless on this axis. Drop the \
3586 `#fragment` tail; pin the ref via the typed `:tag` / \
3587 `:branch` / `:rev` slot instead)"
3588 .to_string());
3589 }
3590 if b == b'?' {
3591 return Err("must not contain `?` (RFC 3986 §3.4 URL query \
3592 component; every documented `:fonte :repo` shape \
3593 (`github:org/repo` shorthand, `https://…` / \
3594 `ssh://…` / `git://…` / `file://…` URL schemes, \
3595 `git@host:path` scp-style SSH) carries none. GitHub / \
3596 GitLab / Bitbucket all silently ignore the `?query` \
3597 tail on a repo URL and serve the same repo \
3598 regardless, so the byte rides verbatim into the \
3599 lacre's per-dep content-address but is silently \
3600 masked at the wire — two authors whose `:repo` \
3601 values differ only in their query tail \
3602 (`?tab=readme-ov-file` vs `?utm_source=twitter`) \
3603 resolve to the byte-identical upstream `git clone` \
3604 but lock to two distinct BLAKE3 closures, defeating \
3605 the THEORY.md §V.2 render-determinism contract on \
3606 the same axis the fragment-`#` arm closes. The \
3607 Smart-HTTP transport (the layer \
3608 `git clone <https-url>` uses) additionally appends \
3609 its own `?service=git-upload-pack` query internally; \
3610 an author-supplied `?` byte collides with that \
3611 internal axis at every git porcelain entry-point. \
3612 The canonical paste-from-browser-address-bar \
3613 footgun (`?tab=readme-ov-file` GitHub-tab deep-link, \
3614 `?ref=main` GitHub-tree-URL parameter, \
3615 `?utm_source=…` campaign-tracker every social-share / \
3616 newsletter / Slack-unfurl appends). Drop the \
3617 `?query` tail; pin the ref via the typed `:tag` / \
3618 `:branch` / `:rev` slot instead)"
3619 .to_string());
3620 }
3621 if b == b'\\' {
3622 return Err("must not contain `\\` (RFC 3986 §3.3 reserves \
3623 `/` as the URL path-segment separator; no URL grammar \
3624 admits `\\`. Every documented `:fonte :repo` shape \
3625 (`github:org/repo` shorthand, `https://…` / \
3626 `ssh://…` / `git://…` / `file://…` URL schemes, \
3627 `git@host:path` scp-style SSH) uses `/` as the path \
3628 separator. The canonical Windows-path-confusion \
3629 footgun: an author pastes `file:///C:\\Users\\me\\repo` \
3630 from a Windows Explorer address bar / PowerShell \
3631 `Get-Location` output, `https://github.com\\foo\\bar` \
3632 after a Win32 shell mangled the slashes, or the bare \
3633 Windows-rooted path `C:\\repo` into a slot expecting a \
3634 `file://` URL. libcurl's URL parser (the layer \
3635 `git clone <https-url>` invokes) silently translates \
3636 `\\` to `/` on some platforms and refuses it on others, \
3637 so the byte rides verbatim into the lacre's per-dep \
3638 content-address but is silently rewritten or rejected \
3639 at the wire, defeating the THEORY.md §V.2 render-\
3640 determinism contract on the same axis the fragment-`#` \
3641 and query-`?` arms close. The peer \
3642 `DepError::FonteCaminhoBackslash` arm (commit 3a4e1d7) \
3643 closes the same byte on the sibling `:fonte :caminho` \
3644 path-fonte axis; this arm closes the URL-grammar axis. \
3645 Drop the `\\` — use `/` for URL path separators, or \
3646 author the `file:///C:/path` form with forward slashes \
3647 (the canonical RFC 8089 file-URI shape on Windows-\
3648 rooted paths))"
3649 .to_string());
3650 }
3651 if b == b'{' || b == b'}' {
3652 return Err(format!(
3653 "must not contain `{ch}` (RFC 3986 §2 excludes `{{` / `}}` \
3654 from URL syntax — they sit in the 'delims' / 'unwise' \
3655 byte set every URL parser is required to refuse or \
3656 percent-encode; RFC 6570 reserves the matched pair for \
3657 URI Template placeholders (the canonical \
3658 `https://{{host}}/{{org}}/{{repo}}` substitution shape \
3659 every OpenAPI / Swagger / Postman / GitHub Octokit \
3660 client library / Helm chart-URL fragment carries). The \
3661 canonical 'I forgot to resolve the template \
3662 placeholder' footgun: an author pastes \
3663 `:repo \"https://github.com/{{org}}/{{repo}}\"` from a \
3664 README's quick-start snippet, an OpenAPI spec's \
3665 `servers:` URL, a Helm chart's `home:` template, or \
3666 the Mustache / Handlebars `{{{{org}}}}/{{{{repo}}}}` \
3667 doubled-brace substitution form every CI / IaC \
3668 templating engine emits, expecting the substrate to \
3669 resolve the placeholder downstream. libcurl percent-\
3670 encodes `{{` / `}}` to `%7B` / `%7D` on the wire (so \
3671 the byte round-trips inconsistently between the \
3672 lacre's per-dep content-address and the resolver's \
3673 `git clone <repo>` invocation, defeating the THEORY.md \
3674 §V.2 render-determinism contract on the same axis the \
3675 fragment-`#`, query-`?`, and backslash-`\\` arms close) \
3676 while every git porcelain entry-point fetches a \
3677 nonexistent literal-`{{placeholder}}`-named path far \
3678 from the source caixa.lisp. Resolve the placeholder at \
3679 author time — substitute the literal org / repo name \
3680 (`https://github.com/pleme-io/hello-rio`), or use \
3681 `:fonte (:tipo path :caminho \"<local-path>\")` for a \
3682 local workspace dep)",
3683 ch = b as char
3684 ));
3685 }
3686 if b == b'<' || b == b'>' {
3687 return Err(format!(
3688 "must not contain `{ch}` (RFC 3986 §2 excludes `<` / `>` \
3689 from URL syntax — they sit in the 'delims' / 'unwise' \
3690 byte set every URL parser is required to refuse or \
3691 percent-encode, peer with the `{{` / `}}` URI Template \
3692 arm on the same paragraph of the same RFC. No git URL \
3693 grammar admits either byte: the `github:org/repo` \
3694 shorthand carries an alphanumeric / `-` / `_` / `/` \
3695 alphabet, every `https://` / `ssh://` / `git://` / \
3696 `file://` URL scheme percent-encodes `<` to `%3C` and \
3697 `>` to `%3E` on the wire (the WHATWG URL spec's \
3698 'fragment percent-encode set' canonical mapping every \
3699 conformant URL parser applies), and the `git@host:path` \
3700 scp-style SSH shape names a POSIX path component that \
3701 carries no shell-metachar bytes. Beyond the URL-grammar \
3702 violation, every POSIX shell (sh / bash / zsh / dash / \
3703 ksh / fish / nushell) lexes `<` as the input-redirection \
3704 operator and `>` as the output-redirection operator — \
3705 a `:repo \"https://github.com/foo/bar>build.log\"` (the \
3706 canonical 'I pasted a shell pipeline that wrote build \
3707 output and forgot to trim the redirect' footgun) or \
3708 `:repo \"<README.md\"` (the symmetric input-redirection \
3709 paste idiom every doc-quick-start `git clone <…>` line \
3710 footnotes) is the canonical paste-from-shell-prompt \
3711 footgun the typed slot's accepted set must exclude. The \
3712 byte rides verbatim into the lacre's per-dep content-\
3713 address (`conteudo: format!(\"git:{{repo}}\")` peer of \
3714 the path-axis embedding at caixa-resolver/src/resolve.rs:189) \
3715 and into the resolver's `git clone <repo>` \
3716 (caixa-resolver/src/git.rs:21) subprocess invocation, \
3717 where libcurl's URL parser percent-encodes the byte on \
3718 the wire — so two authors whose `:repo` values differ \
3719 only in their `<`/`>` presence (one paste-trimmed the \
3720 redirect tail, the other didn't) resolve to the byte-\
3721 identical upstream `git clone` but lock to two distinct \
3722 BLAKE3 closures, defeating the THEORY.md §V.2 render-\
3723 determinism contract on the same axis the fragment-`#`, \
3724 query-`?`, backslash-`\\`, and template-`{{` / `}}` arms \
3725 close. The peer `:fonte :caminho` axis (e457141) closes \
3726 the same `<` / `>` byte under the shell-redirection \
3727 banner via `DepError::FonteCaminhoShellRedirection`; the \
3728 peer `:entrada :paths` axis closes the same bytes as part \
3729 of `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
3730 reserved set; the peer `:fonte :tag` / `:fonte :branch` \
3731 axes (e70d213) close the same bytes as part of \
3732 `is_git_ref_name`'s shell-metachar-injection cascade. \
3733 The `:repo` URL axis was the last typed git-source \
3734 surface still admitting these two bytes; this arm closes \
3735 the gap so the substrate-wide 'no shell-redirection / \
3736 RFC-3986-unwise byte anywhere in a typed git-source slot' \
3737 invariant is now structurally consistent across every \
3738 git-source-shaped typed surface. Drop the `<` / `>` tail \
3739 — pin the ref via the typed `:tag` / `:branch` / `:rev` \
3740 slot, or use `:fonte (:tipo path :caminho \"<local-path>\")` \
3741 for a local workspace dep)",
3742 ch = b as char
3743 ));
3744 }
3745 if b == b'`' {
3746 return Err(
3747 "must not contain `` ` `` (RFC 3986 §2 lists the backtick byte \
3748 in the 'delims' / 'unwise' set every URL parser is required \
3749 to refuse or percent-encode, peer with the `<` / `>` \
3750 shell-redirection arm on the same paragraph of the same RFC. \
3751 No git URL grammar admits the byte: the `github:org/repo` \
3752 shorthand carries an alphanumeric / `-` / `_` / `/` alphabet, \
3753 every `https://` / `ssh://` / `git://` / `file://` URL scheme \
3754 percent-encodes `` ` `` to `%60` on the wire (the WHATWG URL \
3755 spec's 'fragment percent-encode set' canonical mapping every \
3756 conformant URL parser applies), and the `git@host:path` \
3757 scp-style SSH shape names a POSIX path component that \
3758 carries no shell-metachar bytes. Beyond the URL-grammar \
3759 violation, every POSIX shell (sh / bash / zsh / dash / ksh / \
3760 fish) lexes the backtick as the legacy command-substitution \
3761 operator — `` `<cmd>` `` runs `<cmd>` in a subshell and \
3762 substitutes its stdout, the canonical RCE-class injection \
3763 vector when a string lands in a shell context. A `:repo \
3764 \"https://github.com/foo/`whoami`/bar\"` (the canonical \
3765 paste-from-shell-prompt footgun where the author copies a \
3766 backtick-templated URL from a doc / README quick-start \
3767 snippet that expected the substrate to substitute the value \
3768 downstream) or the symmetric `:repo \"`git config user.name`\"` \
3769 (the dynamic-config-substitution paste idiom every \
3770 dev-environment-setup script footnotes) is the canonical \
3771 paste-from-shell-prompt footgun the typed slot's accepted \
3772 set must exclude. The byte rides verbatim into the lacre's \
3773 per-dep content-address (`conteudo: format!(\"git:{repo}\")` \
3774 peer of the path-axis embedding at \
3775 caixa-resolver/src/resolve.rs) and into the resolver's `git \
3776 clone <repo>` (caixa-resolver/src/git.rs) subprocess \
3777 invocation, where libcurl's URL parser percent-encodes the \
3778 byte on the wire — so two authors whose `:repo` values \
3779 differ only in their backtick presence (one paste-trimmed \
3780 the substitution wrapper, the other didn't) resolve to the \
3781 byte-identical upstream `git clone` but lock to two distinct \
3782 BLAKE3 closures, defeating the THEORY.md §V.2 render-\
3783 determinism contract on the same axis the fragment-`#`, \
3784 query-`?`, backslash-`\\`, template-`{` / `}`, and \
3785 shell-redirection-`<` / `>` arms close. The peer `:fonte \
3786 :caminho` axis (c4d62b3) closes the same byte under the \
3787 shell-command-substitution banner via \
3788 `DepError::FonteCaminhoShellCommandSubstitution`; the peer \
3789 `:entrada :paths` axis closes the same byte as part of \
3790 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved \
3791 set. Drop the backtick wrapper — substitute the literal \
3792 value at author time, or use `:fonte (:tipo path :caminho \
3793 \"<local-path>\")` for a local workspace dep)"
3794 .to_string(),
3795 );
3796 }
3797 if b == b'|' {
3798 return Err("must not contain `|` (RFC 3986 §2 lists the pipe byte in \
3799 the 'unwise' set every URL parser is required to refuse or \
3800 percent-encode, peer with the `{` / `}` URI Template, \
3801 `<` / `>` shell-redirection, and `` ` `` shell-command-\
3802 substitution arms on the same paragraph of the same RFC. \
3803 No git URL grammar admits the byte: the `github:org/repo` \
3804 shorthand carries an alphanumeric / `-` / `_` / `/` \
3805 alphabet, every `https://` / `ssh://` / `git://` / \
3806 `file://` URL scheme percent-encodes `|` to `%7C` on the \
3807 wire (the WHATWG URL spec's 'fragment percent-encode set' \
3808 canonical mapping every conformant URL parser applies), \
3809 and the `git@host:path` scp-style SSH shape names a POSIX \
3810 path component that carries no shell-metachar bytes. \
3811 Beyond the URL-grammar violation, every POSIX shell (sh / \
3812 bash / zsh / dash / ksh / fish / nushell) lexes `|` as the \
3813 pipe operator — `<cmd1> | <cmd2>` streams cmd1's stdout to \
3814 cmd2's stdin, the canonical command-chaining injection \
3815 vector when a string lands in a shell context. A `:repo \
3816 \"https://github.com/foo/bar|tee build.log\"` (the \
3817 canonical 'I pasted a shell pipeline that tee'd build \
3818 output and forgot to trim the pipe tail' footgun) or \
3819 `:repo \"github:p/x|cat\"` (the symmetric paste-from-\
3820 shell-prompt idiom every quick-start `git clone <…> | …` \
3821 line footnotes) is the canonical paste-from-shell-prompt \
3822 footgun the typed slot's accepted set must exclude. The \
3823 byte rides verbatim into the lacre's per-dep content-\
3824 address (`conteudo: format!(\"git:{repo}\")` peer of the \
3825 path-axis embedding at caixa-resolver/src/resolve.rs) and \
3826 into the resolver's `git clone <repo>` \
3827 (caixa-resolver/src/git.rs) subprocess invocation, where \
3828 libcurl's URL parser percent-encodes the byte on the wire \
3829 — so two authors whose `:repo` values differ only in \
3830 their pipe presence (one paste-trimmed the pipeline tail, \
3831 the other didn't) resolve to the byte-identical upstream \
3832 `git clone` but lock to two distinct BLAKE3 closures, \
3833 defeating the THEORY.md §V.2 render-determinism contract \
3834 on the same axis the fragment-`#`, query-`?`, backslash-\
3835 `\\`, template-`{` / `}`, shell-redirection-`<` / `>`, \
3836 and backtick-`` ` `` arms close. The peer `:fonte \
3837 :caminho` axis (124106f) closes the same byte under the \
3838 shell-pipe banner via `DepError::FonteCaminhoShellPipe`; \
3839 the peer `:entrada :paths` axis closes the same byte as \
3840 part of `is_gateway_api_http_path`'s eleven-byte \
3841 RFC-3986-reserved set; the peer `:fonte :tag` / `:fonte \
3842 :branch` axes close the same byte as part of \
3843 `is_git_ref_name`'s shell-metachar-injection cascade. \
3844 Drop the pipe tail — substitute the literal value at \
3845 author time, or use `:fonte (:tipo path :caminho \
3846 \"<local-path>\")` for a local workspace dep)"
3847 .to_string());
3848 }
3849 if b == b';' {
3850 return Err("must not contain `;` (RFC 3986 §2 lists the semicolon \
3851 byte in the 'sub-delims' / reserved set every URL parser is \
3852 required to percent-encode at the path-segment boundary, peer \
3853 with the `{` / `}` URI Template, `<` / `>` shell-redirection, \
3854 `` ` `` shell-command-substitution, and `|` shell-pipe arms on \
3855 the same paragraph of the same RFC. No git URL grammar admits \
3856 the byte: the `github:org/repo` shorthand carries an \
3857 alphanumeric / `-` / `_` / `/` alphabet, every `https://` / \
3858 `ssh://` / `git://` / `file://` URL scheme percent-encodes `;` \
3859 to `%3B` on the wire (the WHATWG URL spec's 'fragment percent-\
3860 encode set' canonical mapping every conformant URL parser \
3861 applies), and the `git@host:path` scp-style SSH shape names a \
3862 POSIX path component that carries no shell-metachar bytes. \
3863 Beyond the URL-grammar violation, every POSIX shell (sh / \
3864 bash / zsh / dash / ksh / fish / nushell) lexes `;` as the \
3865 sequential-command terminator — `<cmd1>; <cmd2>` fires `<cmd2>` \
3866 regardless of `<cmd1>`'s exit status, the canonical \
3867 command-chaining injection vector when a string lands in a \
3868 shell context. A `:repo \
3869 \"https://github.com/foo/bar; rm -rf build\"` (the canonical \
3870 'I pasted a shell one-liner that chained a cleanup tail after \
3871 the URL and forgot to trim the `; <cmd>` tail' footgun) or \
3872 `:repo \"github:p/x;;y\"` (the symmetric paste-from-POSIX-\
3873 `case`-arm `;;` terminator idiom every shell-snippet footnotes) \
3874 is the canonical paste-from-shell-prompt footgun the typed \
3875 slot's accepted set must exclude. The byte rides verbatim into \
3876 the lacre's per-dep content-address (`conteudo: \
3877 format!(\"git:{repo}\")` peer of the path-axis embedding at \
3878 caixa-resolver/src/resolve.rs) and into the resolver's `git \
3879 clone <repo>` (caixa-resolver/src/git.rs) subprocess \
3880 invocation, where libcurl's URL parser percent-encodes the \
3881 byte on the wire — so two authors whose `:repo` values differ \
3882 only in their semicolon presence (one paste-trimmed the \
3883 sequential-command tail, the other didn't) resolve to the \
3884 byte-identical upstream `git clone` but lock to two distinct \
3885 BLAKE3 closures, defeating the THEORY.md §V.2 render-\
3886 determinism contract on the same axis the fragment-`#`, \
3887 query-`?`, backslash-`\\`, template-`{` / `}`, \
3888 shell-redirection-`<` / `>`, backtick-`` ` ``, and \
3889 shell-pipe-`|` arms close. The peer `:fonte :caminho` axis \
3890 (05c358e) closes the same byte under the shell-command-\
3891 separator banner via `DepError::FonteCaminhoShellSemicolon`; \
3892 the peer `:entrada :paths` axis closes the same byte as part \
3893 of `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved \
3894 set; the peer `:fonte :tag` / `:fonte :branch` axes close the \
3895 same byte as part of `is_git_ref_name`'s shell-metachar-\
3896 injection cascade. Drop the `;` tail — substitute the literal \
3897 value at author time, or use `:fonte (:tipo path :caminho \
3898 \"<local-path>\")` for a local workspace dep)"
3899 .to_string());
3900 }
3901 if b == b'&' {
3902 return Err("must not contain `&` (RFC 3986 §2 lists the ampersand \
3903 byte in the 'sub-delims' / reserved set every URL parser is \
3904 required to percent-encode at the path-segment boundary, peer \
3905 with the `{` / `}` URI Template, `<` / `>` shell-redirection, \
3906 `` ` `` shell-command-substitution, `|` shell-pipe, and `;` \
3907 shell-command-separator arms on the same paragraph of the same \
3908 RFC. The byte is also the canonical RFC 3986 §3.4 URL query \
3909 `key=value` pair separator (`?a=1&b=2`), but the prior `?` arm \
3910 already excludes any `?query` tail on a `:repo` value — every \
3911 documented `:fonte :repo` shape (`github:org/repo` shorthand, \
3912 `https://…` / `ssh://…` / `git://…` / `file://…` URL schemes, \
3913 `git@host:path` scp-style SSH) carries no query component, so \
3914 the `&` byte cannot appear in a legitimate query position past \
3915 the `?` gate either. Every `https://` / `ssh://` / `git://` / \
3916 `file://` URL scheme percent-encodes `&` to `%26` on the wire \
3917 (the WHATWG URL spec's 'fragment percent-encode set' canonical \
3918 mapping every conformant URL parser applies), and the \
3919 `git@host:path` scp-style SSH shape names a POSIX path \
3920 component that carries no shell-metachar bytes. Beyond the \
3921 URL-grammar violation, every interactive shell (bash / zsh / \
3922 fish / nushell) lexes `&` two ways: single `&` as the \
3923 background-task terminator that detaches the prior command \
3924 into the background and returns control to the prompt \
3925 immediately (the canonical `cmd &` idiom every long-running \
3926 pipeline uses), and double `&&` as the logical-AND list \
3927 operator that fires the next command only if the prior \
3928 command succeeded (the canonical `make && make install` idiom \
3929 every build script carries). A `:repo \
3930 \"https://github.com/foo/bar & sleep 1\"` (the canonical \
3931 'I pasted a `git clone <url> & sleep 1` background-launch \
3932 one-liner and forgot to trim the `& <cmd>` tail' footgun) or \
3933 `:repo \"github:p/x && echo done\"` (the symmetric \
3934 paste-from-shell-prompt `cd path && cmd` build-chain idiom \
3935 every quick-start `git clone <…> && cd <…>` line footnotes) \
3936 is the canonical paste-from-shell-prompt footgun the typed \
3937 slot's accepted set must exclude. The byte rides verbatim \
3938 into the lacre's per-dep content-address (`conteudo: \
3939 format!(\"git:{repo}\")` peer of the path-axis embedding at \
3940 caixa-resolver/src/resolve.rs) and into the resolver's `git \
3941 clone <repo>` (caixa-resolver/src/git.rs) subprocess \
3942 invocation, where libcurl's URL parser percent-encodes the \
3943 byte on the wire — so two authors whose `:repo` values \
3944 differ only in their ampersand presence (one paste-trimmed \
3945 the background-launch tail, the other didn't) resolve to \
3946 the byte-identical upstream `git clone` but lock to two \
3947 distinct BLAKE3 closures, defeating the THEORY.md §V.2 \
3948 render-determinism contract on the same axis the \
3949 fragment-`#`, query-`?`, backslash-`\\`, template-`{` / `}`, \
3950 shell-redirection-`<` / `>`, backtick-`` ` ``, shell-pipe-`|`, \
3951 and shell-command-separator-`;` arms close. The peer `:fonte \
3952 :caminho` axis (e12e4f3) closes the same byte under the \
3953 shell-background / logical-AND banner via \
3954 `DepError::FonteCaminhoShellBackground`; the peer `:entrada \
3955 :paths` axis closes the same byte as part of \
3956 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved \
3957 set; the peer `:fonte :tag` / `:fonte :branch` axes close \
3958 the same byte as part of `is_git_ref_name`'s shell-metachar-\
3959 injection cascade. Drop the `&` tail — substitute the literal \
3960 value at author time, or use `:fonte (:tipo path :caminho \
3961 \"<local-path>\")` for a local workspace dep)"
3962 .to_string());
3963 }
3964 if b == b'$' {
3965 return Err("must not contain `$` (RFC 3986 §2 lists the dollar \
3966 byte in the 'sub-delims' / reserved set every URL parser is \
3967 required to percent-encode at the path-segment boundary, peer \
3968 with the `;` shell-command-separator and `&` shell-background \
3969 arms on the same paragraph of the same RFC. No git URL grammar \
3970 admits the byte: the `github:org/repo` shorthand carries an \
3971 alphanumeric / `-` / `_` / `/` alphabet, every `https://` / \
3972 `ssh://` / `git://` / `file://` URL scheme percent-encodes `$` \
3973 to `%24` on the wire (the WHATWG URL spec's 'fragment percent-\
3974 encode set' canonical mapping every conformant URL parser \
3975 applies), and the `git@host:path` scp-style SSH shape names a \
3976 POSIX path component that carries no shell-metachar bytes. \
3977 Beyond the URL-grammar violation, every POSIX shell (sh / \
3978 bash / zsh / dash / ksh / fish / nushell) lexes `$` as the \
3979 variable-expansion / command-substitution operator: `$<name>` \
3980 / `${{<name>}}` expands a named variable, `$(<cmd>)` runs a \
3981 subshell and substitutes its stdout, and `$((<expr>))` \
3982 evaluates an arithmetic expression — every form is a \
3983 host-layout / environment-state leak when the byte lands in \
3984 a value the resolver passes to a shell-spawned subprocess. A \
3985 `:repo \"https://github.com/$ORG/caixa-teia\"` (the canonical \
3986 'I pasted a shell one-liner that expanded `$ORG` against the \
3987 author's local environment and forgot to substitute the \
3988 literal org name' footgun, identical to the f4efe9c peer arm \
3989 on the sibling `:caminho` axis that closes `\"$HOME/work/…\"` \
3990 / `\"${{WORKSPACE}}/…\"`) or `:repo \"github:p/$(whoami)/x\"` \
3991 (the symmetric paste-from-shell-prompt command-substitution \
3992 idiom every dev-environment-setup script footnotes) is the \
3993 canonical paste-from-shell-prompt footgun the typed slot's \
3994 accepted set must exclude. The byte rides verbatim into the \
3995 lacre's per-dep content-address (`conteudo: \
3996 format!(\"git:{repo}\")` peer of the path-axis embedding at \
3997 caixa-resolver/src/resolve.rs) and into the resolver's `git \
3998 clone <repo>` (caixa-resolver/src/git.rs) subprocess \
3999 invocation, where libcurl's URL parser percent-encodes the \
4000 byte on the wire — so two authors whose `:repo` values \
4001 differ only in their dollar presence (one substituted the \
4002 literal value at author time, the other didn't) resolve to \
4003 the byte-identical upstream `git clone` but lock to two \
4004 distinct BLAKE3 closures, defeating the THEORY.md §V.2 \
4005 render-determinism contract on the same axis the \
4006 fragment-`#`, query-`?`, backslash-`\\`, template-`{` / `}`, \
4007 shell-redirection-`<` / `>`, backtick-`` ` ``, shell-pipe-`|`, \
4008 shell-command-separator-`;`, and shell-background-`&` arms \
4009 close. Beyond the determinism axis, a value like \
4010 `\"github:$HOME/x\"` is a structural host-layout leak: two \
4011 authors with the same `:repo` slot but different `$HOME` \
4012 / `$WORKSPACE` / `$PWD` resolve different upstream URLs at \
4013 different times — the lacre, far from being a substrate-wide \
4014 identity, becomes a per-workstation snapshot of the author's \
4015 shell environment. The peer `:fonte :caminho` axis (f4efe9c) \
4016 closes the leading-`$` byte under the shell-variable-\
4017 expansion banner via `DepError::FonteCaminhoVarExpansion`; \
4018 the peer `:entrada :paths` axis closes the same byte as part \
4019 of `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved \
4020 set; the peer `:fonte :tag` / `:fonte :branch` axes close \
4021 the same byte as part of `is_git_ref_name`'s shell-metachar-\
4022 injection cascade — the `:caminho` axis closes only the \
4023 leading position because absolute / tilde / var arms there \
4024 are leading-byte sentinels, but the `:repo` URL axis closes \
4025 the byte anywhere because every per-byte arm on this surface \
4026 is positional-agnostic (the substitution / leak shapes \
4027 `\"https://$HOST/p/x\"` and `\"github:p/$(whoami)\"` both \
4028 carry the byte mid-string). Drop the `$` — substitute the \
4029 literal value at author time, or use `:fonte (:tipo path \
4030 :caminho \"<local-path>\")` for a local workspace dep)"
4031 .to_string());
4032 }
4033 if b == b'*' {
4034 return Err("must not contain `*` (RFC 3986 §2 lists the asterisk \
4035 byte in the 'sub-delims' / reserved set every URL parser is \
4036 required to percent-encode at the path-segment boundary, peer \
4037 with the `;` shell-command-separator, `&` shell-background, \
4038 and `$` shell-variable-expansion arms on the same paragraph of \
4039 the same RFC. No git URL grammar admits the byte: the \
4040 `github:org/repo` shorthand carries an alphanumeric / `-` / \
4041 `_` / `/` alphabet, every `https://` / `ssh://` / `git://` / \
4042 `file://` URL scheme percent-encodes `*` to `%2A` on the wire \
4043 (the WHATWG URL spec's 'special-query percent-encode set' \
4044 canonical mapping every conformant URL parser applies), and \
4045 the `git@host:path` scp-style SSH shape names a POSIX path \
4046 component that carries no shell-metachar bytes. Beyond the \
4047 URL-grammar violation, every POSIX shell (sh / bash / zsh / \
4048 dash / ksh / fish / nushell) lexes `*` as the \
4049 pathname-expansion / glob wildcard operator: a single `*` \
4050 matches any sequence of characters in a path component \
4051 (including the empty sequence), `**` matches across `/` \
4052 boundaries under bash's `globstar` shopt, and `foo*` resolves \
4053 against the cwd-relative filesystem at command-substitution \
4054 time. Beyond shell glob semantics, git itself lexes `*` as \
4055 the refspec wildcard operator (`refs/heads/*:refs/remotes/\
4056 origin/*` — the same byte the peer `is_git_ref_name` \
4057 predicate refuses on `:fonte :tag` / `:fonte :branch`), so a \
4058 `:repo` value carrying `*` is structurally ambiguous with \
4059 every refspec parser the resolver invokes downstream. A \
4060 `:repo \"https://github.com/pleme-io/caixa-*\"` (the canonical \
4061 'I pasted a `ls github.com/pleme-io/caixa-*` shell-listing \
4062 tail and forgot to substitute the literal repo name' \
4063 footgun, identical to the cf9034b peer arm on the sibling \
4064 `:caminho` axis that closes `\"../caixa-teia/*\"`) or `:repo \
4065 \"github:p/*\"` (the symmetric paste-from-shell-prompt \
4066 glob-expansion idiom every quick-listing one-liner footnotes) \
4067 is the canonical paste-from-shell-prompt footgun the typed \
4068 slot's accepted set must exclude. The byte rides verbatim \
4069 into the lacre's per-dep content-address (`conteudo: \
4070 format!(\"git:{repo}\")` peer of the path-axis embedding at \
4071 caixa-resolver/src/resolve.rs) and into the resolver's `git \
4072 clone <repo>` (caixa-resolver/src/git.rs) subprocess \
4073 invocation, where libcurl's URL parser percent-encodes the \
4074 byte on the wire — so two authors whose `:repo` values \
4075 differ only in their asterisk presence (one substituted the \
4076 literal repo name at author time, the other didn't) resolve \
4077 to the byte-identical upstream `git clone` but lock to two \
4078 distinct BLAKE3 closures, defeating the THEORY.md §V.2 \
4079 render-determinism contract on the same axis the \
4080 fragment-`#`, query-`?`, backslash-`\\`, template-`{` / `}`, \
4081 shell-redirection-`<` / `>`, backtick-`` ` ``, shell-pipe-`|`, \
4082 shell-command-separator-`;`, shell-background-`&`, and \
4083 shell-variable-expansion-`$` arms close. The peer `:fonte \
4084 :caminho` axis (cf9034b) closes the same byte under the \
4085 shell-glob / pathname-expansion banner via \
4086 `DepError::FonteCaminhoShellGlob`; the peer `:fonte :tag` / \
4087 `:fonte :branch` axes close the same byte as part of \
4088 `is_git_ref_name`'s refspec-wildcard cascade. Drop the `*` — \
4089 substitute the literal repo name at author time, or use \
4090 `:fonte (:tipo path :caminho \"<local-path>\")` for a local \
4091 workspace dep)"
4092 .to_string());
4093 }
4094 if b == b'(' || b == b')' {
4095 return Err(format!(
4096 "must not contain `{ch}` (RFC 3986 §2 excludes `(` / `)` \
4097 from URL syntax — they sit in the 'sub-delims' / reserved \
4098 byte set every URL parser is required to percent-encode at \
4099 the path-segment boundary, peer with the `;` \
4100 shell-command-separator, `&` shell-background, `$` \
4101 shell-variable-expansion, and `*` shell-glob arms on the \
4102 same paragraph of the same RFC. No git URL grammar admits \
4103 either byte: the `github:org/repo` shorthand carries an \
4104 alphanumeric / `-` / `_` / `/` alphabet, every `https://` / \
4105 `ssh://` / `git://` / `file://` URL scheme percent-encodes \
4106 `(` to `%28` and `)` to `%29` on the wire (the WHATWG URL \
4107 spec's 'special-query percent-encode set' canonical mapping \
4108 every conformant URL parser applies), and the \
4109 `git@host:path` scp-style SSH shape names a POSIX path \
4110 component that carries no shell-metachar bytes. Beyond the \
4111 URL-grammar violation, every POSIX shell (sh / bash / zsh / \
4112 dash / ksh / fish / nushell) lexes `(` / `)` as the \
4113 subshell-grouping operator: `(<cmd>)` runs `<cmd>` in a \
4114 child shell with a fresh environment scope (the canonical \
4115 idiom for sandboxing a `cd` or variable assignment), and \
4116 `$(<cmd>)` is the modern Bourne command-substitution shape \
4117 the prior `$` arm closes the leading byte of — the closing \
4118 `)` byte completes that substitution shape and must be \
4119 refused on the same axis. The byte pair is additionally the \
4120 canonical regex-alternation grouping operator (`(foo|bar)`) \
4121 every doc / README quick-start snippet folds into a paste-\
4122 from-doc footgun shape, and the bash brace-expansion \
4123 alternation form (`{{foo,bar}}`) the prior `{{` / `}}` URI \
4124 Template arm closes on the curly-brace axis routes the \
4125 same alternation intent through the parenthesis axis on \
4126 every POSIX-portable script. A `:repo \
4127 \"https://github.com/(foo|bar)/repo\"` (the canonical 'I \
4128 pasted a regex-alternation form from a doc / README and \
4129 forgot to substitute one literal org' footgun) or `:repo \
4130 \"github:p/x(date)\"` (the symmetric paste-from-shell-\
4131 prompt subshell-grouping idiom every dynamic-config-\
4132 substitution one-liner footnotes) is the canonical paste-\
4133 from-shell-prompt footgun the typed slot's accepted set \
4134 must exclude. The byte rides verbatim into the lacre's \
4135 per-dep content-address (`conteudo: \
4136 format!(\"git:{{repo}}\")` peer of the path-axis embedding \
4137 at caixa-resolver/src/resolve.rs) and into the resolver's \
4138 `git clone <repo>` (caixa-resolver/src/git.rs) subprocess \
4139 invocation, where libcurl's URL parser percent-encodes the \
4140 byte on the wire — so two authors whose `:repo` values \
4141 differ only in their parenthesis presence (one paste-\
4142 trimmed the grouping wrapper, the other didn't) resolve to \
4143 the byte-identical upstream `git clone` but lock to two \
4144 distinct BLAKE3 closures, defeating the THEORY.md §V.2 \
4145 render-determinism contract on the same axis the \
4146 fragment-`#`, query-`?`, backslash-`\\`, template-`{{` / \
4147 `}}`, shell-redirection-`<` / `>`, backtick-`` ` ``, \
4148 shell-pipe-`|`, shell-command-separator-`;`, shell-\
4149 background-`&`, shell-variable-expansion-`$`, and shell-\
4150 glob-`*` arms close. Drop the `(` / `)` wrapper — \
4151 substitute the literal value at author time, or use \
4152 `:fonte (:tipo path :caminho \"<local-path>\")` for a local \
4153 workspace dep)",
4154 ch = b as char
4155 ));
4156 }
4157 if b == b'"' {
4158 return Err("must not contain `\"` (RFC 3986 §2 lists the \
4159 double-quote byte in the 'delims' set every URL parser is \
4160 required to refuse or percent-encode, peer with the `<` / \
4161 `>` shell-redirection and `` ` `` shell-command-substitution \
4162 arms on the same paragraph of the same RFC — the four-byte \
4163 'delims' subset (`<`, `>`, `\"`, `` ` ``) is the strictest \
4164 of the §2 reserved classes, every member structurally \
4165 incompatible with every URL grammar at every position. No \
4166 git URL grammar admits the byte: the `github:org/repo` \
4167 shorthand carries an alphanumeric / `-` / `_` / `/` \
4168 alphabet, every `https://` / `ssh://` / `git://` / \
4169 `file://` URL scheme percent-encodes `\"` to `%22` on the \
4170 wire (the WHATWG URL spec's 'C0 control percent-encode \
4171 set' canonical mapping every conformant URL parser \
4172 applies), and the `git@host:path` scp-style SSH shape \
4173 names a POSIX path component that carries no \
4174 shell-metachar bytes. Beyond the URL-grammar violation, \
4175 every POSIX shell (sh / bash / zsh / dash / ksh / fish / \
4176 nushell) lexes `\"` as the double-quote string delimiter — \
4177 a `\"<text>\"` form suppresses word-splitting and \
4178 pathname-expansion on `<text>` while still expanding `$`, \
4179 `` ` ``, and `\\` substitutions inside, the canonical \
4180 'quote the URL so the shell doesn't re-lex the bytes' \
4181 idiom every doc / README quick-start snippet wraps the \
4182 URL argument with. A `:repo \
4183 \"\\\"https://github.com/pleme-io/caixa-teia\\\"\"` (the \
4184 canonical paste-from-doc footgun where the author copies \
4185 `$ git clone \"https://…\"` from a README's quick-start \
4186 snippet and keeps the surrounding double-quote bytes — \
4187 the doc quotes the URL so the shell doesn't re-lex \
4188 metachars inside, but the typed slot is itself a \
4189 byte-level string parser, not a shell context, so the \
4190 quote bytes ride into the value verbatim) or `:repo \
4191 \"github:p/x\\\"tail\"` (the symmetric stray-quote paste \
4192 idiom every shell-history `git clone …` line footnotes) \
4193 is the canonical paste-from-shell-quoting footgun the \
4194 typed slot's accepted set must exclude. The byte rides \
4195 verbatim into the lacre's per-dep content-address \
4196 (`conteudo: format!(\"git:{repo}\")` peer of the path-\
4197 axis embedding at caixa-resolver/src/resolve.rs) and into \
4198 the resolver's `git clone <repo>` \
4199 (caixa-resolver/src/git.rs) subprocess invocation, where \
4200 libcurl's URL parser percent-encodes the byte on the wire \
4201 — so two authors whose `:repo` values differ only in \
4202 their double-quote presence (one paste-trimmed the quote \
4203 wrapper, the other didn't) resolve to the byte-identical \
4204 upstream `git clone` but lock to two distinct BLAKE3 \
4205 closures, defeating the THEORY.md §V.2 render-determinism \
4206 contract on the same axis the fragment-`#`, query-`?`, \
4207 backslash-`\\`, template-`{` / `}`, shell-redirection-\
4208 `<` / `>`, backtick-`` ` ``, shell-pipe-`|`, \
4209 shell-command-separator-`;`, shell-background-`&`, \
4210 shell-variable-expansion-`$`, shell-glob-`*`, and \
4211 shell-subshell-grouping-`(` / `)` arms close. The peer \
4212 `:entrada :paths` axis closes the same byte as part of \
4213 `is_gateway_api_http_path`'s RFC-3986-reserved set; the \
4214 `:fonte :tag` / `:fonte :branch` axes close the same byte \
4215 as part of `is_git_ref_name`'s shell-metachar-injection \
4216 cascade. Drop the `\"` wrapper — paste only the URL \
4217 between the quotes, or use `:fonte (:tipo path :caminho \
4218 \"<local-path>\")` for a local workspace dep)"
4219 .to_string());
4220 }
4221 if b == b'\'' {
4222 return Err("must not contain `'` (RFC 3986 §2.2 lists the \
4223 single-quote byte in the 'sub-delims' set the URL grammar \
4224 admits inside a path segment but every WHATWG-conformant \
4225 special-scheme URL parser percent-encodes inside a query \
4226 component via the 'special-query percent-encode set' — \
4227 the peer position the prior `*` / `(` / `)` 'sub-delims' \
4228 arms close and the partner ASCII string-delimiter to the \
4229 `\"` 'delims' double-quote byte the prior arm closes. The \
4230 byte is the second ASCII shell-string-delimiter — `\"` \
4231 and `'` are the only two ASCII bytes a byte-level string \
4232 parser sharing a value-shape with a shell argument must \
4233 refuse on a URL-shaped slot for paste-from-doc safety. No \
4234 documented `:fonte :repo` shape admits the byte: the \
4235 `github:org/repo` shorthand carries an alphanumeric / `-` \
4236 / `_` / `/` alphabet, every `https://` / `ssh://` / \
4237 `git://` / `file://` URL scheme keeps host / path bodies \
4238 inside the `unreserved` alphanumeric / `-` / `.` / `_` / \
4239 `~` set that excludes the byte, and the `git@host:path` \
4240 scp-style SSH shape names a POSIX path component that \
4241 carries no shell-metachar bytes. Every POSIX shell (sh / \
4242 bash / zsh / dash / ksh / fish / nushell) lexes `'` as \
4243 the single-quote / strong-quote string delimiter — a \
4244 `'<text>'` form suppresses every form of expansion on \
4245 `<text>` (no `$`, no `` ` ``, no `\\`, no glob, no \
4246 word-splitting), the canonical 'strong-quote the URL so \
4247 the shell doesn't re-lex anything inside' idiom every \
4248 doc / README quick-start snippet wraps the URL argument \
4249 with as the stricter, security-conscious alternative to \
4250 the `\"…\"` weak-quote shape the prior arm closes. A \
4251 `:repo \"'https://github.com/pleme-io/caixa-teia'\"` (the \
4252 canonical paste-from-doc-shell-quoting footgun where the \
4253 author copies `$ git clone 'https://…'` from a README's \
4254 quick-start snippet and keeps the surrounding strong-\
4255 quote bytes — the doc strong-quotes the URL so the shell \
4256 doesn't re-lex any metachars inside, but the typed slot \
4257 is itself a byte-level string parser, not a shell \
4258 context, so the quote bytes ride into the value verbatim; \
4259 the strong-quote idiom is more common than `\"…\"` in \
4260 security-conscious docs because it forecloses every \
4261 expansion the weak-quote form still admits inside) or \
4262 `:repo \"github:p/x'tail\"` (the symmetric stray-quote \
4263 paste idiom every shell-history `git clone …` line \
4264 carries when the author paste-trimmed one boundary but \
4265 not the other) is the canonical paste-from-shell-quoting \
4266 footgun the typed slot's accepted set must exclude. The \
4267 byte additionally carries the canonical English-\
4268 typography apostrophe footgun: an author writes `:repo \
4269 \"github:p/repo's-fork\"` (the possessive-form paste-\
4270 from-prose idiom every README / commit-message / chat-\
4271 thread reference to a repo carries) expecting the \
4272 substrate to coerce it to a kebab-case slug; the byte \
4273 rides verbatim into the lacre's per-dep content-address \
4274 (`conteudo: format!(\"git:{repo}\")` peer of the path-\
4275 axis embedding at caixa-resolver/src/resolve.rs) and \
4276 into the resolver's `git clone <repo>` (caixa-resolver/\
4277 src/git.rs) subprocess invocation, where the upstream \
4278 host's git porcelain fetches a literal apostrophe-bearing \
4279 path that no host's repo registry resolves (GitHub / \
4280 GitLab / Bitbucket / Codeberg / sourcehut all reject `'` \
4281 in repo slugs at admission time) — so the lacre locks \
4282 to a `git:github:p/repo's-fork` closure that never \
4283 resolves at clone time, surfacing as a quoting-confused \
4284 'remote ref not found' porcelain error far from the \
4285 source caixa.lisp, defeating the THEORY.md §V.2 render-\
4286 determinism contract on the same axis the fragment-`#`, \
4287 query-`?`, backslash-`\\`, template-`{` / `}`, \
4288 shell-redirection-`<` / `>`, backtick-`` ` ``, \
4289 shell-pipe-`|`, shell-command-separator-`;`, shell-\
4290 background-`&`, shell-variable-expansion-`$`, shell-\
4291 glob-`*`, shell-subshell-grouping-`(` / `)`, and shell-\
4292 double-quote-`\"` arms close. Together with the prior \
4293 `\"` arm, this arm closes both ASCII shell-string-\
4294 delimiter bytes on the typed `:repo` URL axis — every \
4295 byte the canonical `git clone <repo>` doc-paste idiom \
4296 wraps the URL argument with is now refused at validate \
4297 time, before the byte rides into the lacre or the \
4298 resolver subprocess. Drop the `'` wrapper — paste only \
4299 the URL between the quotes, or use `:fonte (:tipo path \
4300 :caminho \"<local-path>\")` for a local workspace dep)"
4301 .to_string());
4302 }
4303 if b == b'!' {
4304 return Err("must not contain `!` (RFC 3986 §2.2 lists the bang byte \
4305 in the 'sub-delims' set the URL grammar admits inside a \
4306 path segment but every WHATWG-conformant special-scheme \
4307 URL parser percent-encodes inside a query component via \
4308 the 'special-query percent-encode set' — the peer position \
4309 the prior `*` / `(` / `)` / `'` 'sub-delims' arms close. \
4310 No documented `:fonte :repo` shape admits the byte: the \
4311 `github:org/repo` shorthand carries an alphanumeric / `-` \
4312 / `_` / `/` alphabet, every `https://` / `ssh://` / \
4313 `git://` / `file://` URL scheme keeps host / path bodies \
4314 inside the RFC 3986 `unreserved` alphanumeric / `-` / \
4315 `.` / `_` / `~` set that excludes the byte, and the \
4316 `git@host:path` scp-style SSH shape names a POSIX path \
4317 component that carries no shell-metachar bytes. Beyond \
4318 the URL-grammar question, every interactive POSIX shell \
4319 with history enabled (bash / ksh / zsh's `bashcompat` \
4320 mode / csh / tcsh) lexes `!` as the history-expansion \
4321 prefix — `!command` re-runs the most recent history \
4322 entry beginning with `command`, `!!` re-runs the prior \
4323 command verbatim, `!$` substitutes the last word of the \
4324 prior command, `!:N` substitutes the Nth word, the \
4325 canonical RCE-class injection vector when a string lands \
4326 in a shell context with `set -o histexpand` (bash's \
4327 default for interactive sessions). A `:repo \
4328 \"https://github.com/foo/bar!sudo\"` (the canonical \
4329 paste-from-shell-history footgun where the author copies \
4330 a `git clone <url>!sudo make install` one-liner from a \
4331 README's quick-start snippet, intending the trailing \
4332 `!sudo` as a shell-history reference but the typed slot \
4333 is itself a byte-level string parser, not a shell \
4334 context, so the bytes ride into the value verbatim) or \
4335 `:repo \"github:p/repo!!\"` (the symmetric `!!` repeat-\
4336 prior-command paste idiom every shell-history `git \
4337 clone …` retry line carries) is the canonical paste-\
4338 from-shell-history footgun the typed slot's accepted \
4339 set must exclude. Beyond shell-history, the bang byte \
4340 carries the canonical English-typography emphasis \
4341 footgun: an author writes `:repo \
4342 \"github:p/awesome-repo!\"` (the exclamation-form paste-\
4343 from-prose idiom every README / chat-thread / commit-\
4344 message reference to an enthusiastically-named repo \
4345 carries) expecting the substrate to coerce it to a \
4346 kebab-case slug; the byte rides verbatim into the \
4347 lacre's per-dep content-address (`conteudo: \
4348 format!(\"git:{repo}\")` peer of the path-axis \
4349 embedding at caixa-resolver/src/resolve.rs) and into \
4350 the resolver's `git clone <repo>` (caixa-resolver/\
4351 src/git.rs) subprocess invocation, where the upstream \
4352 host's git porcelain fetches a literal bang-bearing \
4353 path that no host's repo registry resolves (GitHub / \
4354 GitLab / Bitbucket / Codeberg / sourcehut all reject \
4355 `!` in repo slugs at admission time) — so the lacre \
4356 locks to a `git:github:p/awesome-repo!` closure that \
4357 never resolves at clone time, surfacing as a 'remote \
4358 ref not found' porcelain error far from the source \
4359 caixa.lisp, defeating the THEORY.md §V.2 render-\
4360 determinism contract on the same axis the fragment-\
4361 `#`, query-`?`, backslash-`\\`, template-`{` / `}`, \
4362 shell-redirection-`<` / `>`, backtick-`` ` ``, shell-\
4363 pipe-`|`, shell-command-separator-`;`, shell-\
4364 background-`&`, shell-variable-expansion-`$`, shell-\
4365 glob-`*`, shell-subshell-grouping-`(` / `)`, shell-\
4366 double-quote-`\"`, and shell-single-quote-`'` arms \
4367 close. The peer `:fonte :tag` / `:fonte :branch` axes \
4368 (`is_git_ref_name`) deliberately admit `!` (git's \
4369 `check-ref-format` accepts it as a printable byte and \
4370 the bang carries no refname-grammar meaning); the \
4371 `:entrada :paths` axis (`is_gateway_api_http_path`) \
4372 similarly admits it (K8s Gateway API HTTPPathMatch.value \
4373 OpenAPI regex accepts it). `:repo` is substrate-\
4374 internal and strictly narrower than its upstream \
4375 grammar by design, so the divergence is intentional: \
4376 the shell-history-expansion footgun is real on the \
4377 typed `:fonte :repo` axis (every `git clone <url>` \
4378 invocation crosses a shell boundary at the caixa-\
4379 resolver / `Command::new(\"git\")` subprocess layer) \
4380 in a way it isn't on the refname / HTTP-path axes that \
4381 never reach shell context. Drop the trailing `!` — \
4382 author the bare alphanumeric / `-` / `_` slug, or use \
4383 `:fonte (:tipo path :caminho \"<local-path>\")` for a \
4384 local workspace dep)"
4385 .to_string());
4386 }
4387 if b == b',' {
4388 return Err("must not contain `,` (RFC 3986 §2.2 lists the comma byte \
4389 in the 'sub-delims' set the URL grammar admits inside a \
4390 path segment but every WHATWG-conformant special-scheme \
4391 URL parser percent-encodes it inside both the path and \
4392 query percent-encode sets — the peer position the prior \
4393 `!` / `*` / `(` / `)` / `'` 'sub-delims' arms close. No \
4394 documented `:fonte :repo` shape admits the byte: the \
4395 `github:org/repo` shorthand carries an alphanumeric / `-` \
4396 / `_` / `/` alphabet, every `https://` / `ssh://` / \
4397 `git://` / `file://` URL scheme keeps host / path bodies \
4398 inside the RFC 3986 `unreserved` alphanumeric / `-` / \
4399 `.` / `_` / `~` set that excludes the byte, and the \
4400 `git@host:path` scp-style SSH shape names a POSIX path \
4401 component that carries no list-separator bytes (every \
4402 forge — GitHub / GitLab / Bitbucket / Codeberg / \
4403 sourcehut — refuses `,` in repo slugs at admission time). \
4404 Beyond the URL-grammar question, the comma byte carries \
4405 the canonical list-separator-belongs-to-list-grammar \
4406 footgun across every parser-of-record `:fonte :repo` \
4407 lands in: an author copies a `git clone <urlA>, <urlB>` \
4408 paste-from-CSV-list one-liner from a multi-repo \
4409 bootstrap doc (the canonical `git clone --recurse-\
4410 submodules <a>, <b>, <c>` README-quickstart idiom every \
4411 mono-repo carries) or pastes a JSON-array literal `[\"a\", \
4412 \"b\", \"c\"]` from a tooling-config snippet stripped \
4413 of its brackets, intending the comma to separate \
4414 multiple repo entries but the typed `:repo` slot names \
4415 *one* repo (the list-separator belongs to the list \
4416 grammar of the enclosing `:deps` slot, not to the \
4417 individual `:repo` value). A `:repo \
4418 \"github:p/a,github:p/b\"` silently passed every prior \
4419 arm and rode into the lacre's per-dep content-address \
4420 (`conteudo: format!(\"git:{repo}\")` peer of the path-\
4421 axis embedding at caixa-resolver/src/resolve.rs) and \
4422 into the resolver's `git clone <repo>` (caixa-\
4423 resolver/src/git.rs) subprocess invocation, where the \
4424 upstream host's git porcelain fetched a literal comma-\
4425 bearing path that no host's repo registry resolves — \
4426 so the lacre locks to a `git:github:p/a,github:p/b` \
4427 closure that never resolves at clone time, surfacing as \
4428 a 'remote ref not found' porcelain error far from the \
4429 source caixa.lisp, defeating the THEORY.md §V.2 render-\
4430 determinism contract on the same axis the fragment-\
4431 `#`, query-`?`, backslash-`\\`, template-`{` / `}`, \
4432 shell-redirection-`<` / `>`, backtick-`` ` ``, shell-\
4433 pipe-`|`, shell-command-separator-`;`, shell-\
4434 background-`&`, shell-variable-expansion-`$`, shell-\
4435 glob-`*`, shell-subshell-grouping-`(` / `)`, shell-\
4436 double-quote-`\"`, shell-single-quote-`'`, and shell-\
4437 history-`!` arms close. Beyond the multi-repo paste, \
4438 the byte carries the canonical English-typography \
4439 trailing-`,` paste-from-prose footgun: an author writes \
4440 `:repo \"github:pleme-io/caixa-feira,\"` (the trailing \
4441 comma every README-prose list-of-projects sentence \
4442 carries, mistakenly retained when the slug is pasted \
4443 mid-sentence) expecting the substrate to coerce it to \
4444 a kebab-case slug; the byte rides verbatim. The peer \
4445 `:fonte :tag` / `:fonte :branch` axes \
4446 (`is_git_ref_name`) deliberately admit `,` (git's \
4447 `check-ref-format` accepts it as a printable byte and \
4448 the comma carries no refname-grammar meaning); the \
4449 `:entrada :paths` axis (`is_gateway_api_http_path`) \
4450 similarly admits it (K8s Gateway API HTTPPathMatch.value \
4451 OpenAPI regex accepts it). `:repo` is substrate-\
4452 internal and strictly narrower than its upstream \
4453 grammar by design, so the divergence is intentional: \
4454 the list-separator-belongs-to-list-grammar footgun is \
4455 real on the typed `:fonte :repo` axis (every `:deps` \
4456 entry names exactly one repo and the comma between \
4457 entries belongs to the `:deps` list grammar, never to \
4458 the value) in a way it isn't on the refname / HTTP-\
4459 path axes whose grammars admit the byte without \
4460 confusion. Drop the trailing `,` — author the bare \
4461 alphanumeric / `-` / `_` slug, or split into multiple \
4462 `:deps` entries to express multiple repos)"
4463 .to_string());
4464 }
4465 if b == b'=' {
4466 return Err("must not contain `=` (RFC 3986 §2.2 lists the equals byte \
4467 in the 'sub-delims' set — the URL grammar admits the byte \
4468 inside a path segment, but every WHATWG-conformant special-\
4469 scheme URL parser percent-encodes it inside a query \
4470 component via the 'special-query percent-encode set' (the \
4471 same set the prior `,` / `!` / `*` / `(` / `)` / `'` sub-\
4472 delims arms close on, peer with the immediately prior `,` \
4473 arm on the same paragraph of the same RFC). No documented \
4474 `:fonte :repo` shape admits the byte: the `github:org/repo` \
4475 shorthand carries an alphanumeric / `-` / `_` / `/` \
4476 alphabet, every `https://` / `ssh://` / `git://` / \
4477 `file://` URL scheme keeps host / path bodies inside the \
4478 RFC 3986 `unreserved` alphanumeric / `-` / `.` / `_` / `~` \
4479 set that excludes the byte, and the `git@host:path` scp-\
4480 style SSH shape names a POSIX path component that carries \
4481 no key-value-separator bytes (every forge — GitHub / \
4482 GitLab / Bitbucket / Codeberg / sourcehut — refuses `=` in \
4483 repo slugs at admission time). Beyond the URL-grammar \
4484 question, the equals byte carries three canonical paste-\
4485 from-doc footguns the typed `:repo` slot's accepted set \
4486 must exclude. First, the URL-query key-value-separator \
4487 paste: an author copies `https://github.com/p/x?ref=main` \
4488 from a browser address bar / GitHub-tree-URL deep-link / \
4489 `?utm_source=…` campaign-tracker query string; the prior \
4490 `?` arm (a68f818) closes the query-prefix byte but every \
4491 paste-from-doc snippet that lost its `?` prefix (a copy-\
4492 paste that started mid-query, a shell-pipeline that \
4493 stripped the leading `?` via `cut -d?`, a docs example \
4494 that documented the bare `key=value` pairs without the \
4495 leading `?`) lands a `:repo \"github:p/x ref=main\"` whose \
4496 `=` byte is now the load-bearing footgun. Second, the \
4497 shell env-var-assignment paste: every POSIX shell (sh / \
4498 bash / zsh / dash / ksh / fish) lexes `KEY=VALUE` at the \
4499 start of a command line as a one-shot env-var assignment \
4500 scoped to that command (`GIT_TERMINAL_PROMPT=0 git clone \
4501 <url>` runs `git clone` with the prompt suppressed, \
4502 `GIT_SSL_NO_VERIFY=1 git clone <url>` skips TLS \
4503 verification, `HTTPS_PROXY=… git clone <url>` overrides \
4504 the proxy) — the canonical paste-from-shell-history idiom \
4505 every git-troubleshooting README documents. An author \
4506 copies `:repo \"GIT_TERMINAL_PROMPT=0 https://github.com/\
4507 p/x\"` from a shell-prompt one-liner and the env-var \
4508 prefix rides verbatim into the value, defeating the \
4509 substrate's typed `:repo` axis (the env-var prefix \
4510 belongs to the shell context, not to the URL). Third, the \
4511 git-CLI-flag paste: every `git` porcelain entry-point \
4512 accepts `--config <key>=<value>` (`git -c \
4513 protocol.file.allow=always clone …`, `git -c \
4514 http.extraHeader=…`) and `git config --get <key>` outputs \
4515 `<key>=<value>`-shaped lines; an author copies \
4516 `url=https://github.com/p/x` from `git config --get-all \
4517 remote.origin.url` output or a `.gitconfig` `[remote \
4518 \"origin\"] url = https://…` ini-stanza paste and the \
4519 `url=` prefix rides verbatim into the typed `:repo` slot \
4520 (the ini-key-prefix belongs to the gitconfig grammar, not \
4521 to the URL value). A `:repo \"GIT_TERMINAL_PROMPT=0 \
4522 https://github.com/p/x\"` or `:repo \"url=https://github.\
4523 com/p/x\"` silently passed every prior arm; the byte rode \
4524 into the lacre's per-dep content-address (`conteudo: \
4525 format!(\"git:{repo}\")` peer of the path-axis embedding \
4526 at caixa-resolver/src/resolve.rs) and into the resolver's \
4527 `git clone <repo>` (caixa-resolver/src/git.rs) subprocess \
4528 invocation, where libcurl's URL parser percent-encodes \
4529 the byte to `%3D` on the wire — so two authors whose \
4530 `:repo` values differ only in their `=` presence resolve \
4531 to the byte-identical upstream `git clone` but lock to \
4532 two distinct BLAKE3 closures, defeating the THEORY.md \
4533 §V.2 render-determinism contract on the same axis the \
4534 fragment-`#`, query-`?`, backslash-`\\`, template-`{` / \
4535 `}`, shell-redirection-`<` / `>`, backtick-`` ` ``, shell-\
4536 pipe-`|`, shell-command-separator-`;`, shell-background-\
4537 `&`, shell-variable-expansion-`$`, shell-glob-`*`, shell-\
4538 subshell-grouping-`(` / `)`, shell-double-quote-`\"`, \
4539 shell-single-quote-`'`, shell-history-`!`, and list-\
4540 separator-`,` arms close. The peer `:fonte :tag` / \
4541 `:fonte :branch` axes (`is_git_ref_name`) deliberately \
4542 admit `=` (git's `check-ref-format` accepts it as a \
4543 printable byte and the equals carries no refname-grammar \
4544 meaning); the `:entrada :paths` axis \
4545 (`is_gateway_api_http_path`) similarly admits it (K8s \
4546 Gateway API HTTPPathMatch.value OpenAPI regex accepts \
4547 it). `:repo` is substrate-internal and strictly narrower \
4548 than its upstream grammar by design, so the divergence is \
4549 intentional: the URL-query / shell-env-var-assignment / \
4550 git-config-ini key-value-separator footgun is real on the \
4551 typed `:fonte :repo` axis (every `git clone <repo>` \
4552 invocation crosses a shell boundary at the caixa-\
4553 resolver subprocess layer, and the lacre's per-dep \
4554 content-address must be byte-identical to the wire form) \
4555 in a way it isn't on the refname / HTTP-path axes whose \
4556 grammars admit the byte without confusion. Drop the `=` — \
4557 strip the env-var / config-key prefix from the value \
4558 before the URL, or author the bare alphanumeric / `-` / \
4559 `_` slug)"
4560 .to_string());
4561 }
4562 if b == b'%' {
4563 return Err(
4564 "must not contain `%` (RFC 3986 §2.1 reserves the percent byte \
4565 as the URL percent-encoding escape — `%HH` is the \
4566 mandatory encoding mechanism for every byte outside the \
4567 `unreserved` alphanumeric / `-` / `.` / `_` / `~` set, \
4568 and `%` itself must be percent-encoded as `%25` to appear \
4569 literally inside a URL value, peer with the immediately \
4570 prior `=` / `,` / `!` / `*` / `(` / `)` / `'` 'sub-delims' \
4571 arms on the same RFC. No documented `:fonte :repo` shape \
4572 admits the byte: the `github:org/repo` shorthand carries \
4573 an alphanumeric / `-` / `_` / `/` alphabet, every \
4574 `https://` / `ssh://` / `git://` / `file://` URL scheme \
4575 keeps host / path bodies inside the RFC 3986 `unreserved` \
4576 set that excludes the byte and every percent-encoded \
4577 byte (alphanumeric / `-` / `.` / `_` / `~` — no member \
4578 needs percent-encoding), and the `git@host:path` scp-\
4579 style SSH shape names a POSIX path component that \
4580 carries no percent-encoded bytes (every forge — GitHub / \
4581 GitLab / Bitbucket / Codeberg / sourcehut — refuses `%` \
4582 in repo slugs at admission time, and IDN host labels \
4583 must be pre-encoded as Punycode `xn--…` rather than as \
4584 percent-encoded UTF-8 bytes). Beyond the URL-grammar \
4585 question, the percent byte is the canonical render-\
4586 determinism axis-of-non-determinism the typed `:repo` \
4587 slot must close at the manifest layer. First, the \
4588 paste-from-browser-address-bar percent-encoded-space \
4589 footgun: an author copies \
4590 `https://github.com/p/x%20test` from a browser address \
4591 bar or a percent-encoded README hyperlink, intending \
4592 the `%20` as the URL encoding of a literal space; \
4593 libcurl's URL parser (the layer `git clone <https-url>` \
4594 invokes) re-percent-encodes the `%` byte to `%25` on \
4595 the wire (since `%` is reserved as the escape sequence \
4596 lead-in and must itself be encoded for a literal byte), \
4597 so the wire request becomes \
4598 `https://github.com/p/x%2520test` — a different path \
4599 than the lacre's content-address records, defeating \
4600 the THEORY.md §V.2 render-determinism contract \
4601 directly on the encoding-mechanism axis itself (the \
4602 most direct violation of every prior render-\
4603 determinism arm — `#`, `?`, `\\`, `{`/`}`, `<`/`>`, \
4604 `` ` ``, `|`, `;`, `&`, `$`, `*`, `(`/`)`, `\"`, `'`, \
4605 `!`, `,`, `=` — since `%` is the very encoding step \
4606 those arms reason about). Second, the lone-percent \
4607 malformed-escape footgun: an author writes `:repo \
4608 \"https://github.com/p/x%foo\"` (the `%` not followed \
4609 by two hex digits) — every WHATWG-conformant URL \
4610 parser rejects the value at parse time per RFC 3986 \
4611 §2.1 (`%HH` requires exactly two hex digits to follow), \
4612 but the byte rides into the lacre's per-dep content-\
4613 address (`conteudo: format!(\"git:{repo}\")` peer of \
4614 the path-axis embedding at caixa-resolver/src/resolve.\
4615 rs) before the resolver subprocess fails far from the \
4616 source caixa.lisp. Third, the over-encoded path \
4617 footgun: an author writes `:repo \
4618 \"https://github.com/p%2Fx\"` intending the `%2F` as \
4619 the URL encoding of `/`; the GitHub Smart-HTTP \
4620 transport rejects percent-encoded path-separator bytes \
4621 in repo URLs (the URL's path-segment grammar is \
4622 resolved before the percent-decoding pass), but the \
4623 byte rides verbatim into the lacre and locks a \
4624 `git:https://github.com/p%2Fx` closure that diverges \
4625 from the byte-identical `https://github.com/p/x` form \
4626 every other author authored — two authors whose \
4627 `:repo` values differ only in their `/` vs `%2F` \
4628 presence resolve to the byte-identical upstream `git \
4629 clone` but lock to two distinct BLAKE3 closures, the \
4630 canonical render-determinism violation. The peer \
4631 `:fonte :tag` / `:fonte :branch` axes \
4632 (`is_git_ref_name`) deliberately admit `%` (git's \
4633 `check-ref-format` accepts it as a printable byte and \
4634 the percent carries no refname-grammar meaning); the \
4635 `:entrada :paths` axis (`is_gateway_api_http_path`) \
4636 similarly admits it (K8s Gateway API \
4637 HTTPPathMatch.value OpenAPI regex accepts it as a \
4638 path-segment byte). `:repo` is substrate-internal and \
4639 strictly narrower than its upstream grammar by design, \
4640 so the divergence is intentional: the percent-encoding \
4641 axis is the load-bearing render-determinism axis on \
4642 the typed `:fonte :repo` slot (every byte the wire \
4643 differs from the lacre by even a single `%`-escape \
4644 round-trip violates the substrate's content-addressed-\
4645 closure contract) in a way it isn't on the refname / \
4646 HTTP-path axes whose grammars admit the byte without \
4647 confusion. Drop the `%` — substitute the literal byte \
4648 directly (the typed slot admits the same `unreserved` \
4649 byte-set the URL grammar's percent-decoding pass \
4650 produces, so the percent-encoded form is structurally \
4651 redundant), or split the encoded value into the typed \
4652 slot it belongs in (e.g., a host with non-ASCII bytes \
4653 must be pre-encoded as Punycode `xn--…` rather than \
4654 percent-encoded UTF-8))"
4655 .to_string(),
4656 );
4657 }
4658 if b == b'^' {
4659 return Err(
4660 "must not contain `^` (RFC 3986 §2 lists the circumflex byte \
4661 in the 'unwise' set every URL parser is required to refuse \
4662 or percent-encode at the path-segment boundary, peer with \
4663 the `{` / `}` URI Template, `<` / `>` shell-redirection, \
4664 `` ` `` shell-command-substitution, and `|` shell-pipe arms \
4665 on the same paragraph of the same RFC — the 'unwise' \
4666 four-byte subset (`{`, `}`, `|`, `\\`, `^`) is the strictest \
4667 of the §2 reserved classes, every member structurally \
4668 incompatible with every URL grammar at every position. No \
4669 git URL grammar admits the byte: the `github:org/repo` \
4670 shorthand carries an alphanumeric / `-` / `_` / `/` \
4671 alphabet, every `https://` / `ssh://` / `git://` / \
4672 `file://` URL scheme percent-encodes `^` to `%5E` on the \
4673 wire (the WHATWG URL spec's 'fragment percent-encode set' \
4674 canonical mapping every conformant URL parser applies), \
4675 and the `git@host:path` scp-style SSH shape names a POSIX \
4676 path component that carries no shell-metachar bytes. \
4677 Beyond the URL-grammar violation, every interactive POSIX \
4678 shell with history enabled (bash / ksh / zsh's \
4679 `bashcompat` mode) lexes `^old^new^` as the quick history-\
4680 substitution shorthand — `^foo^bar` re-runs the most \
4681 recent history entry with the first `foo` substituted by \
4682 `bar`, the canonical RCE-class injection vector when a \
4683 string lands in a shell context with `set -o histexpand` \
4684 (bash's default for interactive sessions, peer with the \
4685 `!` history-expansion arm). csh / tcsh lex `^` as the \
4686 history-substitution prefix (`^old^new` substitutes `old` \
4687 with `new` in the prior command's first occurrence). Beyond \
4688 shell history, every regular-expression engine (POSIX BRE \
4689 / ERE, PCRE, RE2, the rust `regex` crate, JavaScript's \
4690 `RegExp`) lexes `^` two ways: leading-position `^` anchors \
4691 the match to the start of the line (the canonical `^foo` \
4692 anchored-prefix idiom every grep / sed / awk one-liner \
4693 carries), and inside-class `[^abc]` negates the character \
4694 class (the canonical exclusion idiom every regex carries). \
4695 PowerShell (Windows / cross-platform) lexes `^` as the \
4696 escape character — `cmd ^> file` escapes the redirection \
4697 operator into a literal byte, the canonical paste-from-\
4698 PowerShell-prompt footgun on a cross-platform caixa.lisp. \
4699 A `:repo \"https://github.com/p/x^old^new\"` (the \
4700 canonical paste-from-shell-history footgun where the \
4701 author copies a `git clone <url>` line followed by a \
4702 `^typo^fix` quick-edit-and-rerun shell-history shorthand \
4703 and forgot to trim the `^...^...` tail) or `:repo \
4704 \"github:p/^archived\"` (the symmetric regex-anchor / \
4705 negation paste idiom every doc-quick-start grep-pipeline \
4706 footnotes) is the canonical paste-from-shell-prompt \
4707 footgun the typed slot's accepted set must exclude. The \
4708 byte rides verbatim into the lacre's per-dep content-\
4709 address (`conteudo: format!(\"git:{repo}\")` peer of the \
4710 path-axis embedding at caixa-resolver/src/resolve.rs) and \
4711 into the resolver's `git clone <repo>` \
4712 (caixa-resolver/src/git.rs) subprocess invocation, where \
4713 libcurl's URL parser percent-encodes the byte on the wire \
4714 — so two authors whose `:repo` values differ only in \
4715 their caret presence (one paste-trimmed the history-\
4716 substitution shorthand, the other didn't) resolve to the \
4717 byte-identical upstream `git clone` but lock to two \
4718 distinct BLAKE3 closures, defeating the THEORY.md §V.2 \
4719 render-determinism contract on the same axis the \
4720 fragment-`#`, query-`?`, backslash-`\\`, template-`{` / \
4721 `}`, shell-redirection-`<` / `>`, backtick-`` ` ``, \
4722 shell-pipe-`|`, shell-command-separator-`;`, shell-\
4723 background-`&`, shell-variable-expansion-`$`, shell-glob-\
4724 `*`, subshell-grouping-`(` / `)`, shell-double-quote-`\"`, \
4725 shell-single-quote-`'`, history-expansion-`!`, list-\
4726 separator-`,`, env-var-assignment-`=`, and percent-\
4727 encoding-`%` arms close. Drop the `^...^...` tail — \
4728 substitute the literal value at author time, or use \
4729 `:fonte (:tipo path :caminho \"<local-path>\")` for a \
4730 local workspace dep)"
4731 .to_string(),
4732 );
4733 }
4734 }
4735 if s.starts_with(':') {
4736 return Err(
4737 "must not start with `:` (the canonical empty-scheme footgun — \
4738 `:foo` parses as a zero-length scheme that no git porcelain \
4739 entry-point accepts; use a non-empty scheme prefix like \
4740 `github:`, `https://`, `ssh://`, `git://`, `file://`, or the \
4741 `git@host:path` scp-style SSH form)"
4742 .to_string(),
4743 );
4744 }
4745 if !s.contains(':') {
4746 return Err(
4747 "must contain a `:` separator (every documented `:fonte :repo` \
4748 shape carries one: `github:org/repo` shorthand, `https://…` / \
4749 `ssh://…` / `git://…` / `file://…` URL schemes, or \
4750 `git@host:path` scp-style SSH; a bare `org/repo` form is \
4751 ambiguous — `git clone` reads it as a relative filesystem path \
4752 rather than the GitHub-shorthand expansion the author probably \
4753 intended — so prefix it with `github:` for the registry-\
4754 shorthand resolver convention)"
4755 .to_string(),
4756 );
4757 }
4758 Ok(())
4759}
4760
4761/// Practical cap on a `:caracteristicas` (Cargo-feature-name-shaped)
4762/// entry, in bytes. Cargo itself enforces no length cap on feature
4763/// names — its `restricted_names::validate_feature_name` accepts any
4764/// length — but every realistic feature in the Cargo ecosystem is
4765/// well under this bound (`derive` 6, `serde_json` 10, the
4766/// `__private_…` doubled-underscore convention rarely exceeds 32).
4767/// 64 bytes is the substrate's catch-the-paste-from-binary cap on the
4768/// peer trajectory `is_dns_1123_label` (63), `is_wit_world_ref` (128),
4769/// `is_nats_subject` (256), `is_wasi_keyvalue_slot` (512),
4770/// `is_git_ref_name` (255), `is_git_oid` (40/64),
4771/// `is_git_repo_url` (2048) carry: an axis-appropriate ceiling above
4772/// every legitimate authoring shape, tight enough to surface the
4773/// "paste-from-binary" / "multi-line blob landed in a single-token
4774/// slot" footgun at validate time.
4775pub const CARGO_FEATURE_NAME_MAX_LEN: usize = 64;
4776
4777/// Predicate: assert that `s` is a valid Cargo feature name. The
4778/// contract — modeled on Cargo's
4779/// `restricted_names::validate_feature_name` grammar (the parser the
4780/// Cargo resolver routes every `[dependencies.<dep>.features]` entry
4781/// through at `cargo metadata` time), narrowed to the strict ASCII
4782/// subset every realistic feature in the Cargo ecosystem uses:
4783///
4784/// - 1..=[`CARGO_FEATURE_NAME_MAX_LEN`] (64) bytes;
4785/// - first byte: ASCII alphanumeric or `_` (Cargo's parser admits
4786/// Unicode XID-start characters too; pleme-io narrows to the
4787/// ASCII subset for the same reason every peer value-shape
4788/// predicate above narrows — drift between NFC-vs-NFD
4789/// normalization across filesystems silently rewrites the
4790/// feature-key, breaking the lacre's content-addressing
4791/// invariant). Leading `-` / `+` / `.` are explicitly named —
4792/// each is the canonical "I copy-pasted the
4793/// `+optional-feature` enablement form from a Cargo doc" /
4794/// "I confused the dotted-form with feature-name shape"
4795/// footgun the predicate's diagnostic remediation points at;
4796/// - remaining bytes: ASCII alphanumeric, `_`, `-`, `+`, or `.`
4797/// (the Cargo-accepted continuation set). Whitespace, control
4798/// characters, non-ASCII bytes, `/` / `?` / `#` / `,` /
4799/// other punctuation are each surfaced with a self-locating
4800/// reason naming the canonical authoring footgun (multi-token
4801/// blob, CR/LF paste-from-doc, `/` segment-separator confusion
4802/// with namespaced-dep features the predicate's call site
4803/// explicitly does not enable, list-separator-belongs-to-list-
4804/// grammar miscomprehension).
4805///
4806/// Returns the parser-shaped reason on rejection (without wrapping in
4807/// any error variant) so each per-axis caller — [`crate::Dep::validate`]
4808/// for the `:deps`/`:deps-dev :caracteristicas` axis at validate time,
4809/// every future per-feature axis (M4 caixa-resolver's `lacre.lisp`
4810/// resolved-feature-set materializer, the future per-WitContract
4811/// `:caracteristicas`-shaped capability-set axis if WIT worlds grow a
4812/// typed feature toggle, the future per-`UpgradeInstruction` per-
4813/// capability set axis the §V.2 mes-build extension would carry) —
4814/// wraps the same reason in its own typed `*Invalid { <axis>, reason }`
4815/// variant. The reason wording is axis-agnostic ("Cargo feature names
4816/// reject leading `-`") so every call site reading the same diagnostic
4817/// points at the same rule; drift between any two axes' rule
4818/// enforcement is a build error visible at this predicate, not a
4819/// per-renderer "this passed validate but Cargo rejected at metadata
4820/// time" surprise.
4821///
4822/// Empty input is rejected here (defensively) and at each call site
4823/// via the narrower [`crate::DepError::CaracteristicaEmpty`] variant —
4824/// the same empty-first cascade [`is_dns_1123_label`],
4825/// [`is_gateway_api_http_path`], [`is_wit_world_ref`],
4826/// [`is_nats_subject`], [`is_wasi_keyvalue_slot`], [`is_git_ref_name`],
4827/// [`is_git_oid`], and [`is_git_repo_url`] all carry.
4828///
4829/// Lifted as a typed substrate-side primitive on the same trajectory
4830/// the peer value-shape predicates already follow — the typed slot's
4831/// valid set matches the downstream consumer's accepted set (here,
4832/// Cargo's TOML-feature-name parser at `cargo metadata` time),
4833/// structurally. The ninth value-shape primitive to land in
4834/// [`crate::render`], closing the typed `:deps`/`:deps-dev` surface
4835/// value-shape trajectory on its last unsealed axis (`:caracteristicas`
4836/// entries; the per-entry `:nome` / `:versao` / `:fonte` axes are
4837/// already routed through their respective shape predicates).
4838///
4839/// # Errors
4840///
4841/// Returns the parser-shaped reason naming the specific violation
4842/// (length / first-byte-class / continuation-byte-class / whitespace /
4843/// control-char / non-ASCII / `/`-segment-separator-confusion /
4844/// `,`-list-separator-confusion), without wrapping in any error
4845/// variant — every caller maps the same `String` into its own typed
4846/// `*Invalid { <axis>, reason }` enum variant.
4847pub fn is_cargo_feature_name(s: &str) -> Result<(), String> {
4848 if s.is_empty() {
4849 return Err("must not be empty".to_string());
4850 }
4851 if s.len() > CARGO_FEATURE_NAME_MAX_LEN {
4852 return Err(format!(
4853 "exceeds Cargo feature name max length of {CARGO_FEATURE_NAME_MAX_LEN} bytes \
4854 (got {} bytes; legitimate Cargo feature names rarely exceed ~24 bytes — \
4855 this length suggests a paste-from-binary or multi-token blob landed in \
4856 the `:caracteristicas` slot)",
4857 s.len()
4858 ));
4859 }
4860 let bytes = s.as_bytes();
4861 let first = bytes[0];
4862 if !(first.is_ascii_alphanumeric() || first == b'_') {
4863 let msg = if first == b'+' {
4864 "must not start with `+` (Cargo's feature-name grammar reserves a leading \
4865 `+` for the activation-syntax inside a `[dependencies.<dep>.features]` \
4866 list — `:caracteristicas` entries name the feature itself, not its \
4867 enablement form; drop the leading `+` and author the bare feature name, \
4868 e.g. `\"http\"` not `\"+http\"`)"
4869 .to_string()
4870 } else if first == b'-' {
4871 "must not start with `-` (Cargo's feature-name grammar rejects a leading \
4872 hyphen — `-` is a legitimate continuation character between alphanumeric \
4873 segments but the canonical CLI-argument-injection / kebab-leak footgun at \
4874 the start; drop the leading `-`, e.g. `\"json\"` not `\"-json\"`)"
4875 .to_string()
4876 } else if first == b'.' {
4877 "must not start with `.` (Cargo's feature-name grammar rejects a leading \
4878 dot; `.` is a legitimate continuation character but the canonical \
4879 leading-dot-as-version-suffix / hidden-file footgun at the start. Drop \
4880 the leading `.`)"
4881 .to_string()
4882 } else if first == b' ' || first == b'\t' {
4883 "must not start with whitespace (Cargo's feature-name grammar rejects \
4884 whitespace anywhere; the leading-whitespace arm is the canonical \
4885 paste-from-aligned-doc footgun)"
4886 .to_string()
4887 } else if first < 0x20 || first == 0x7F {
4888 format!(
4889 "must not start with control character 0x{first:02x} (Cargo's feature-name \
4890 grammar rejects ASCII control characters; the CR/LF arm is the canonical \
4891 paste-from-multiline-doc footgun)"
4892 )
4893 } else if first >= 0x80 {
4894 format!(
4895 "must not start with non-ASCII byte 0x{first:02x} (Cargo accepts Unicode \
4896 XID-start characters but pleme-io narrows to the strict ASCII subset every \
4897 realistic feature name uses; legitimate features are kebab-case ASCII \
4898 identifiers like `\"http\"`, `\"json\"`, `\"derive\"`)"
4899 )
4900 } else {
4901 format!(
4902 "must start with an ASCII alphanumeric character or `_`, got {ch:?} \
4903 (Cargo's `restricted_names::validate_feature_name` rejects feature names \
4904 whose first character is outside the XID-start + `_` + digit set; \
4905 pleme-io narrows to the strict ASCII alphanumeric + `_` subset)",
4906 ch = first as char
4907 )
4908 };
4909 return Err(msg);
4910 }
4911 for &b in &bytes[1..] {
4912 let valid = b.is_ascii_alphanumeric() || b == b'_' || b == b'-' || b == b'+' || b == b'.';
4913 if !valid {
4914 let msg = if b == b' ' || b == b'\t' {
4915 format!(
4916 "must not contain whitespace character {ch:?} (Cargo's feature-name \
4917 grammar rejects whitespace; feature names are single-token identifiers \
4918 — use `-` or `_` to separate kebab-case / snake-case segments instead)",
4919 ch = b as char
4920 )
4921 } else if b == b',' {
4922 "must not contain `,` (the comma separator belongs to the \
4923 `:caracteristicas` list grammar between entries, not to the feature-name \
4924 grammar within an entry — split the value into two separate list entries)"
4925 .to_string()
4926 } else if b == b'/' {
4927 "must not contain `/` (Cargo's `dep/feat` syntax for namespaced-dep \
4928 features applies inside `[dependencies.<dep>.features]` list entries that \
4929 already name the parent dep — `:caracteristicas` entries are per-dep \
4930 already, so the segment separator within a feature name must be `-`, \
4931 `_`, `+`, or `.`)"
4932 .to_string()
4933 } else if b == b'?' {
4934 "must not contain `?` (Cargo's feature-name grammar rejects URL-reserved \
4935 punctuation; use `-`, `_`, `+`, or `.` as a segment separator instead)"
4936 .to_string()
4937 } else if b == b'#' {
4938 "must not contain `#` (Cargo's feature-name grammar rejects URL-reserved \
4939 punctuation; use `-`, `_`, `+`, or `.` as a segment separator instead)"
4940 .to_string()
4941 } else if b < 0x20 || b == 0x7F {
4942 format!(
4943 "must not contain control character 0x{b:02x} (Cargo's feature-name \
4944 grammar rejects ASCII control characters; the CR/LF arm is the \
4945 canonical paste-from-multiline-doc footgun)"
4946 )
4947 } else if b >= 0x80 {
4948 format!(
4949 "must not contain non-ASCII byte 0x{b:02x} (Cargo accepts Unicode \
4950 XID-continue characters but pleme-io narrows to the strict ASCII \
4951 subset every realistic feature name uses; raw non-ASCII silently \
4952 round-trips inconsistently across NFC/NFD normalization on APFS / \
4953 case-folding filesystems, breaking the lacre's content-addressing \
4954 invariant)"
4955 )
4956 } else {
4957 format!(
4958 "contains invalid character {ch:?} (Cargo's feature-name grammar \
4959 allows only `[A-Za-z0-9_+\\-.]` after the first character)",
4960 ch = b as char
4961 )
4962 };
4963 return Err(msg);
4964 }
4965 }
4966 Ok(())
4967}
4968
4969/// Practical cap on a `:licenca` (SPDX-expression-shaped) value, in
4970/// bytes. The SPDX specification places no length cap on expressions
4971/// — the grammar admits arbitrarily-nested composite expressions —
4972/// but every realistic pleme-io fixture stays well under this bound
4973/// (`MIT` 3, `Apache-2.0` 10, `Apache-2.0 OR MIT` 17, the longest
4974/// SPDX dual-license-with-exception shape `Apache-2.0 WITH
4975/// LLVM-exception` 31; a `(MIT OR Apache-2.0) AND BSD-3-Clause AND
4976/// ISC` composite caps near 50). 256 bytes is the substrate's
4977/// catch-the-paste-from-binary cap on the peer trajectory
4978/// `is_dns_1123_label` (63), `is_cargo_feature_name` (64),
4979/// `is_wit_world_ref` (128), `is_nats_subject` (256),
4980/// `is_wasi_keyvalue_slot` (512), `is_git_ref_name` (255),
4981/// `is_git_oid` (40/64), `is_git_repo_url` (2048) carry: an
4982/// axis-appropriate ceiling above every legitimate authoring shape,
4983/// tight enough to surface the "paste-from-license-text" /
4984/// "multi-line license blob landed in the `:licenca` slot" footgun
4985/// at validate time.
4986pub const SPDX_EXPRESSION_MAX_LEN: usize = 256;
4987
4988/// Predicate: assert that `s` is a valid SPDX-expression shape. The
4989/// contract — modeled on the SPDX 2.1 expression grammar
4990/// (`compound-expression = simple-expression | "(" compound-expression
4991/// ")" | compound-expression "WITH" exception-id | compound-expression
4992/// "AND" compound-expression | compound-expression "OR"
4993/// compound-expression`; `simple-expression = license-id | license-id
4994/// "+" | "LicenseRef-" idstring | "DocumentRef-" idstring ":"
4995/// "LicenseRef-" idstring`; `idstring = 1*(ALPHA / DIGIT / "-" /
4996/// ".")`), narrowed to the structural alphabet floor every realistic
4997/// SPDX expression in the wild uses:
4998///
4999/// - 1..=[`SPDX_EXPRESSION_MAX_LEN`] (256) bytes;
5000/// - no leading whitespace (paste-from-aligned-doc footgun);
5001/// - no trailing whitespace (paste-from-doc footgun — every
5002/// downstream SPDX parser splits on exact token boundaries and
5003/// a trailing space breaks the `WITH` / `AND` / `OR` keyword
5004/// match);
5005/// - every byte in the SPDX expression alphabet: ASCII alphanumeric
5006/// plus `.`, `-`, `+`, `(`, `)`, `:` (the `DocumentRef-…:LicenseRef-…`
5007/// separator), and a single ASCII space (token separator). Tabs,
5008/// control characters, non-ASCII bytes, `_` (not in `idstring`),
5009/// `,` (SPDX uses `AND` / `OR` keywords, not comma), `/` (the
5010/// `dual-license/A` colloquial idiom is non-SPDX), and every other
5011/// punctuation byte are each surfaced with a self-locating reason
5012/// naming the canonical authoring footgun.
5013///
5014/// The predicate is a *structural* floor — it enforces the alphabet +
5015/// length the SPDX grammar's character class admits, not the full
5016/// expression-parse (compound-expression nesting, `AND`/`OR`/`WITH`
5017/// keyword placement, parenthesis balance, idstring well-formedness
5018/// per simple-expression production). A future tightening on the
5019/// `:licenca` axis can extend past this shape predicate into a full
5020/// SPDX parser + license-id allowlist (peer with how
5021/// [`is_git_repo_url`] is the structural floor on `:repositorio` and
5022/// a future flake-resolver might tighten the per-URL-scheme arm into
5023/// scheme-specific shape predicates). This gate closes the
5024/// `_`/`,`/`/`/tab/CR/LF/non-ASCII/multi-line-blob footguns
5025/// structurally at the manifest layer; the parser-shape arms remain
5026/// for a follow-up routine once a real SPDX-parser dep is justified.
5027///
5028/// Returns the parser-shaped reason on rejection (without wrapping in
5029/// any error variant) so each per-axis caller —
5030/// [`crate::Caixa::validate_licenca`] for the universal `:licenca`
5031/// axis at validate time, every future per-license axis (a future
5032/// `:fonte :license` per-dep license-pin axis, a future
5033/// per-`UpgradeInstruction` per-component license-compatibility axis,
5034/// a future `Lacre` per-resolved-dep license-closure axis) — wraps the
5035/// same reason in its own typed `*Invalid { <axis>, reason }` variant.
5036/// The reason wording is axis-agnostic ("SPDX expressions reject
5037/// leading whitespace") so every call site reading the same diagnostic
5038/// points at the same rule; drift between any two axes' rule
5039/// enforcement is a build error visible at this predicate, not a
5040/// per-renderer "this passed validate but `helm lint` rejected the
5041/// `Chart.yaml license:` value" surprise.
5042///
5043/// Empty input is rejected here (defensively) and at each call site
5044/// via the narrower [`crate::ManifestError::LicencaEmpty`] variant —
5045/// the same empty-first cascade [`is_dns_1123_label`],
5046/// [`is_gateway_api_http_path`], [`is_wit_world_ref`],
5047/// [`is_nats_subject`], [`is_wasi_keyvalue_slot`], [`is_git_ref_name`],
5048/// [`is_git_oid`], [`is_git_repo_url`], and [`is_cargo_feature_name`]
5049/// all carry.
5050///
5051/// Lifted as a typed substrate-side primitive on the same trajectory
5052/// the peer value-shape predicates already follow — the typed slot's
5053/// valid set matches the downstream consumer's accepted set (here,
5054/// the `caixa-helm` chart `README.md` `## License` section + a
5055/// future SPDX-aware Chart.yaml `license:` emitter + the future
5056/// per-resolved-dep license-closure axis a forthcoming `Lacre`
5057/// extension would carry), structurally.
5058///
5059/// # Errors
5060///
5061/// Returns the parser-shaped reason naming the specific violation
5062/// (length / leading-whitespace / trailing-whitespace /
5063/// alphabet-class / tab / control-char / non-ASCII / `_` /
5064/// `,`-list-separator-confusion / `/`-dual-license-idiom), without
5065/// wrapping in any error variant — every caller maps the same
5066/// `String` into its own typed `*Invalid { <axis>, reason }` enum
5067/// variant.
5068pub fn is_spdx_expression_shape(s: &str) -> Result<(), String> {
5069 if s.is_empty() {
5070 return Err("must not be empty".to_string());
5071 }
5072 if s.len() > SPDX_EXPRESSION_MAX_LEN {
5073 return Err(format!(
5074 "exceeds SPDX expression max length of {SPDX_EXPRESSION_MAX_LEN} bytes \
5075 (got {} bytes; realistic SPDX expressions like `\"Apache-2.0 WITH \
5076 LLVM-exception\"` rarely exceed ~64 bytes — this length suggests a \
5077 paste-from-license-text or multi-line blob landed in the `:licenca` \
5078 slot)",
5079 s.len()
5080 ));
5081 }
5082 let bytes = s.as_bytes();
5083 if bytes[0] == b' ' {
5084 return Err(
5085 "must not start with whitespace (SPDX expressions are single tokens \
5086 or token sequences separated by *internal* single ASCII spaces; a \
5087 leading space is the canonical paste-from-aligned-doc footgun and \
5088 breaks every downstream SPDX parser that splits on exact token \
5089 boundaries)"
5090 .to_string(),
5091 );
5092 }
5093 if *bytes.last().expect("non-empty checked above") == b' ' {
5094 return Err(
5095 "must not end with whitespace (SPDX expressions don't terminate with \
5096 trailing whitespace; the trailing-space arm is the canonical \
5097 paste-from-doc footgun that breaks downstream parsers which split \
5098 on exact `AND` / `OR` / `WITH` keyword boundaries)"
5099 .to_string(),
5100 );
5101 }
5102 for &b in bytes {
5103 let valid = b.is_ascii_alphanumeric()
5104 || b == b'.'
5105 || b == b'-'
5106 || b == b'+'
5107 || b == b'('
5108 || b == b')'
5109 || b == b':'
5110 || b == b' ';
5111 if !valid {
5112 let msg = if b == b'\t' {
5113 "must not contain tab character (SPDX expressions use a single \
5114 ASCII space between tokens — tabs are the canonical \
5115 paste-from-aligned-doc footgun and break downstream parsers \
5116 that split on exact `\" \"` boundaries)"
5117 .to_string()
5118 } else if b < 0x20 || b == 0x7F {
5119 format!(
5120 "must not contain control character 0x{b:02x} (SPDX \
5121 expressions are printable ASCII; the CR/LF arm is the \
5122 canonical paste-from-multiline-doc footgun and lands as a \
5123 malformed line in the rendered chart `README.md` `## \
5124 License` section)"
5125 )
5126 } else if b >= 0x80 {
5127 format!(
5128 "must not contain non-ASCII byte 0x{b:02x} (SPDX identifiers \
5129 are ASCII per the `idstring = 1*(ALPHA / DIGIT / \"-\" / \
5130 \".\")` production; raw non-ASCII silently round-trips \
5131 inconsistently across NFC/NFD normalization on APFS / \
5132 case-folding filesystems and breaks at every downstream \
5133 SPDX-aware tool)"
5134 )
5135 } else if b == b'_' {
5136 "must not contain `_` (SPDX `idstring` grammar — license-id, \
5137 LicenseRef, exception-id — is `1*(ALPHA / DIGIT / \"-\" / \
5138 \".\")`; `_` is not in the SPDX alphabet, use `-` as the \
5139 segment separator instead, e.g. `\"Apache-2.0\"` not \
5140 `\"Apache_2.0\"`)"
5141 .to_string()
5142 } else if b == b',' {
5143 "must not contain `,` (SPDX expressions compose multiple \
5144 licenses via the `AND` / `OR` keywords, not the comma \
5145 separator; e.g. `\"MIT OR Apache-2.0\"` not `\"MIT, \
5146 Apache-2.0\"`)"
5147 .to_string()
5148 } else if b == b'/' {
5149 "must not contain `/` (the `dual-license/A` slash form is a \
5150 non-SPDX colloquial idiom; SPDX uses the `OR` keyword to \
5151 compose: `\"MIT OR Apache-2.0\"` not `\"MIT/Apache-2.0\"`)"
5152 .to_string()
5153 } else if b == b';' {
5154 "must not contain `;` (SPDX expressions compose multiple \
5155 licenses via the `AND` / `OR` keywords, not the semicolon \
5156 separator; e.g. `\"MIT AND Apache-2.0\"` not `\"MIT; \
5157 Apache-2.0\"`)"
5158 .to_string()
5159 } else {
5160 format!(
5161 "contains invalid character {ch:?} (the SPDX expression \
5162 alphabet is `[A-Za-z0-9.+\\-():]` plus single ASCII space; \
5163 license IDs / exception IDs are `idstring` `1*(ALPHA / \
5164 DIGIT / \"-\" / \".\")`, composition uses `AND` / `OR` / \
5165 `WITH` keywords + `(`/`)` grouping)",
5166 ch = b as char
5167 )
5168 };
5169 return Err(msg);
5170 }
5171 }
5172 Ok(())
5173}
5174
5175/// Maximum byte length of a chart-description-shaped string. The
5176/// 512-byte cap is the axis-appropriate ceiling for the free-form
5177/// prose summary the `:descricao` axis carries: every realistic
5178/// chart description in the wild (`"Canonical Rust→wasm32-wasip2
5179/// caixa Servico."`, `"Checkout flow."`, `"AWS provider caixa for
5180/// tatara-lisp"`) sits well under 256 bytes, and the 512-byte cap
5181/// surfaces the "paste-from-doc multi-paragraph blob landed in the
5182/// `:descricao` slot" footgun at validate time. Peer with
5183/// [`WASI_KV_SLOT_MAX_LEN`] (512) on the sibling longer-than-
5184/// identifier axis; tighter than [`GIT_REPO_URL_MAX_LEN`] (2048)
5185/// which carries a different axis-class ceiling, and looser than
5186/// [`SPDX_EXPRESSION_MAX_LEN`] (256) which is the canonical
5187/// short-identifier-class axis.
5188pub const CHART_DESCRIPTION_MAX_LEN: usize = 512;
5189
5190/// Scan `s` for the Unicode bidirectional-override / isolate format
5191/// codepoints UAX #9 names as the structural prerequisite of the
5192/// "Trojan Source" attack class (CVE-2021-42574 / Boucher & Anderson
5193/// 2021): nine codepoints in two contiguous blocks that flip the
5194/// rendered visual order of every following character until a
5195/// matching pop, so a string visible to a human reader and the same
5196/// string consumed by a parser/renderer can disagree on the order of
5197/// its content bytes.
5198///
5199/// The accepted set (rejection list):
5200///
5201/// - U+202A `LRE` LEFT-TO-RIGHT EMBEDDING
5202/// - U+202B `RLE` RIGHT-TO-LEFT EMBEDDING
5203/// - U+202C `PDF` POP DIRECTIONAL FORMATTING
5204/// - U+202D `LRO` LEFT-TO-RIGHT OVERRIDE
5205/// - U+202E `RLO` RIGHT-TO-LEFT OVERRIDE
5206/// - U+2066 `LRI` LEFT-TO-RIGHT ISOLATE
5207/// - U+2067 `RLI` RIGHT-TO-LEFT ISOLATE
5208/// - U+2068 `FSI` FIRST STRONG ISOLATE
5209/// - U+2069 `PDI` POP DIRECTIONAL ISOLATE
5210///
5211/// Returns the first offending codepoint in document order, or
5212/// `None` when `s` carries none of them. Iterates `chars()` once
5213/// (single UTF-8 decode pass, peer of every other UTF-8-aware
5214/// predicate in this module) — the per-predicate caller folds the
5215/// `Some(c)` into its axis-specific reason wording with the
5216/// offending codepoint named verbatim as `U+XXXX`.
5217///
5218/// Lifted as a shared helper rather than inlined into each per-axis
5219/// predicate (the PRIME DIRECTIVE duplication-budget rule —
5220/// THEORY.md §I.3.5: "every recurring shape becomes a generator
5221/// before it becomes a pattern; every pattern becomes a library
5222/// before it becomes duplicated code. The duplication budget is
5223/// zero.") because two predicates ([`is_chart_description_shape`],
5224/// [`is_chart_maintainer_name_shape`]) carry the same UTF-8
5225/// free-form-prose accepted set and would otherwise inline the same
5226/// nine-codepoint match arm verbatim. The third caller — every
5227/// future per-axis free-form-prose surface (a future Aplicacao-
5228/// level `:descricao` summary axis, a future per-`:contratos` edge
5229/// `:descricao` annotation, the future per-`:autores`-email-suffix
5230/// shape gate) — lands as a thin `if let Some(c) =
5231/// find_unicode_bidi_override(s) { … }` wrapper rather than
5232/// re-inlining the same codepoint match.
5233///
5234/// The arm is structurally distinct from the per-byte control-char
5235/// arm `[is_chart_description_shape]` already carries: ASCII control
5236/// bytes (`0x00..=0x1F` plus `0x7F`) are caught at the per-byte
5237/// pass; the bidi codepoints all decode to non-ASCII three-byte
5238/// UTF-8 sequences (`E2 80 AA..=E2 80 AE` for U+202A..=U+202E,
5239/// `E2 81 A6..=E2 81 A9` for U+2066..=U+2069) — every byte ≥ 0x80
5240/// per UTF-8 grammar — that the per-byte non-ASCII pass deliberately
5241/// accepts (Unicode letters, em-dash, arrows are canonical
5242/// `:descricao` shapes). Only the typed codepoint scan catches them.
5243fn find_unicode_bidi_override(s: &str) -> Option<char> {
5244 s.chars().find(|c| {
5245 matches!(
5246 *c,
5247 '\u{202A}'
5248 | '\u{202B}'
5249 | '\u{202C}'
5250 | '\u{202D}'
5251 | '\u{202E}'
5252 | '\u{2066}'
5253 | '\u{2067}'
5254 | '\u{2068}'
5255 | '\u{2069}'
5256 )
5257 })
5258}
5259
5260/// Scan `s` for any of the three non-ASCII Unicode line-break
5261/// codepoints UAX #14 (Unicode Line Breaking Algorithm) and the
5262/// YAML 1.1 §4.1 b-char production both treat as line terminators
5263/// outside the two single-byte ASCII shapes (`\n` LF / `\r` CR) the
5264/// per-byte arm on the calling predicate already closes:
5265///
5266/// - U+0085 `NEL` NEXT LINE
5267/// - U+2028 `LS` LINE SEPARATOR
5268/// - U+2029 `PS` PARAGRAPH SEPARATOR
5269///
5270/// YAML 1.2 §5.4 ("Line Break Characters") explicitly retired these
5271/// three from the YAML line-break set per the UTR #20 recommendation,
5272/// so a YAML 1.2-strict parser (the `serde_yaml` / `yaml-rust2` family)
5273/// preserves them as literal codepoints inside the rendered Chart.yaml
5274/// scalar — but YAML 1.1 parsers (go-yaml v2 which Helm v3 / kubectl /
5275/// every Kubernetes client library transitively links, and `ruamel.yaml`
5276/// in compat mode) still treat them as line terminators per the YAML 1.1
5277/// b-char production, so the same `:descricao` / `:autores` value
5278/// authored with an embedded U+2028 parses as a single-line plain-style
5279/// scalar through one downstream consumer and a multi-line block scalar
5280/// through another. The cross-parser line-break disagreement breaks the
5281/// THEORY.md §V.2 render-determinism contract every typed slot carries
5282/// on the same axis the per-byte `\n` / `\r` arms close for ASCII; the
5283/// substrate refuses the three codepoints at validate time so the
5284/// rendered Chart.yaml carries the single-line shape every conformant
5285/// YAML parser agrees on. Independently, every UAX #14 conformant text
5286/// consumer (editors, terminals, web UIs like `helm list` /
5287/// `helm search` / Artifact Hub) breaks the visual line at these
5288/// codepoints regardless of YAML version, so the author's editor view
5289/// of `caixa.lisp` disagrees with the chart-consumer's rendered view
5290/// even when both YAML parsers agree on the byte-level shape.
5291///
5292/// Returns the first offending codepoint in document order, or `None`
5293/// when `s` carries none of them. Iterates `chars()` once (single
5294/// UTF-8 decode pass, peer of [`find_unicode_bidi_override`] and every
5295/// other UTF-8-aware predicate in this module) — the per-predicate
5296/// caller folds the `Some(c)` into its axis-specific reason wording
5297/// with the offending codepoint named verbatim as `U+XXXX`.
5298///
5299/// Lifted as a shared helper rather than inlined into each per-axis
5300/// predicate (the PRIME DIRECTIVE duplication-budget rule —
5301/// THEORY.md §I.3.5: "every recurring shape becomes a generator
5302/// before it becomes a pattern; every pattern becomes a library
5303/// before it becomes duplicated code. The duplication budget is
5304/// zero.") because two predicates ([`is_chart_description_shape`],
5305/// [`is_chart_maintainer_name_shape`]) carry the same UTF-8
5306/// free-form-prose accepted set and would otherwise inline the same
5307/// three-codepoint match arm verbatim — sibling lift to the
5308/// [`find_unicode_bidi_override`] helper one trajectory earlier on
5309/// the same two predicates. The third caller — every future
5310/// per-axis free-form-prose surface (a future Aplicacao-level
5311/// `:descricao` summary axis, a future per-`:contratos` edge
5312/// `:descricao` annotation, the future per-`:autores`-email-suffix
5313/// shape gate) — lands as a thin `if let Some(c) =
5314/// find_unicode_line_break(s) { … }` wrapper rather than re-inlining
5315/// the same codepoint match.
5316///
5317/// The arm is structurally distinct from the per-byte control-char
5318/// arm `[is_chart_description_shape]` already carries: the ASCII
5319/// line-break bytes `\n` (`0x0A`) and `\r` (`0x0D`) are caught at the
5320/// per-byte pass; the three non-ASCII line-break codepoints all
5321/// decode to multi-byte UTF-8 sequences (`C2 85` for U+0085, `E2 80
5322/// A8` for U+2028, `E2 80 A9` for U+2029) — every byte ≥ 0x80 per
5323/// UTF-8 grammar — that the per-byte non-ASCII pass deliberately
5324/// accepts (Unicode letters, em-dash, arrows are canonical
5325/// `:descricao` shapes). Only the typed codepoint scan catches them.
5326fn find_unicode_line_break(s: &str) -> Option<char> {
5327 s.chars()
5328 .find(|c| matches!(*c, '\u{0085}' | '\u{2028}' | '\u{2029}'))
5329}
5330
5331/// Scan `s` for any of the eight BMP Unicode invisible-format
5332/// codepoints — the Cf-category zero-width codepoints that have no
5333/// visible glyph in any conforming font yet ride verbatim through
5334/// string equality and parser lookup:
5335///
5336/// - U+00AD `SHY` SOFT HYPHEN
5337/// - U+200B `ZWSP` ZERO WIDTH SPACE
5338/// - U+2060 `WJ` WORD JOINER
5339/// - U+2061 `FA` FUNCTION APPLICATION
5340/// - U+2062 `IT` INVISIBLE TIMES
5341/// - U+2063 `IS` INVISIBLE SEPARATOR
5342/// - U+2064 `IP` INVISIBLE PLUS
5343/// - U+FEFF `ZWNBSP` ZERO WIDTH NO-BREAK SPACE (BOM)
5344///
5345/// These codepoints break the THEORY.md §V.2 render-determinism
5346/// contract on a third axis from the visual-order class the sibling
5347/// [`find_unicode_bidi_override`] helper closes (the nine UAX #9
5348/// explicit-direction codepoints flip the rendered visual order) and
5349/// the single-line/multi-line class the sibling
5350/// [`find_unicode_line_break`] helper closes (the three UAX #14
5351/// non-ASCII line-break codepoints split a YAML 1.1 scalar): the
5352/// *invisible-identity* divergence. The author's editor view of
5353/// `caixa.lisp`, the chart-consumer's `helm list` / `helm search` /
5354/// Artifact Hub maintainer column, and every conformant terminal /
5355/// browser / editor agree on the visible glyph sequence (the
5356/// codepoint renders as nothing, so `"alice"` and
5357/// `"alice\u{200B}"` look identical end-to-end) — but the byte
5358/// sequence the YAML-plain-style-scalar carries verbatim differs
5359/// from the byte sequence the same author intends to read back, so
5360/// every byte-level grep / diff / equality comparison over the
5361/// rendered Chart.yaml disagrees with the visible-glyph match, the
5362/// Artifact Hub maintainer / description search index lookup misses
5363/// the authored identity entry because the byte sequence carries
5364/// invisible codepoints between letters, and a future per-author
5365/// CLA-signer lookup matches a visually-identical-but-byte-distinct
5366/// identity (the canonical "invisible-codepoint homograph" footgun).
5367/// The canonical authoring shapes that introduce these codepoints:
5368/// paste-from-Microsoft-Word (SHY auto-inserted at every hyphenation
5369/// candidate), paste-from-text-editor-saved-as-UTF-8-with-BOM (BOM
5370/// leading byte from Notepad / older VS Code defaults / Excel CSV
5371/// export), paste-from-typesetting-doc (ZWSP / WJ invisible word-
5372/// break hints from InDesign / LaTeX-rendered PDF copy-paste).
5373///
5374/// Returns the first offending codepoint in document order, or
5375/// `None` when `s` carries none of them. Iterates `chars()` once
5376/// (single UTF-8 decode pass, peer of [`find_unicode_bidi_override`]
5377/// and [`find_unicode_line_break`]) — the per-predicate caller folds
5378/// the `Some(c)` into its axis-specific reason wording with the
5379/// offending codepoint named verbatim as `U+XXXX`.
5380///
5381/// Excluded from the rejected set, on purpose:
5382///
5383/// - U+200C `ZWNJ` ZERO WIDTH NON-JOINER and U+200D `ZWJ` ZERO
5384/// WIDTH JOINER — both carry semantic compositional load in
5385/// Devanagari / Bengali / Persian script clusters (the
5386/// canonical "Persian name authoring" shape relies on ZWNJ to
5387/// break inappropriate ligatures) and in modern emoji ZWJ
5388/// sequences (👨💻 is `MAN` + U+200D `ZWJ` + `LAPTOP`); the
5389/// `:autores` / `:descricao` axes admit Unicode prose where
5390/// such sequences are the canonical authoring shape and a ban
5391/// would regress legitimate maintainer-name fixtures.
5392/// - U+200E `LRM` LEFT-TO-RIGHT MARK and U+200F `RLM`
5393/// RIGHT-TO-LEFT MARK — both are legitimate single-character
5394/// direction *hints* (not overrides) in mixed-script prose
5395/// (the canonical "Arabic name with embedded ASCII email"
5396/// shape relies on RLM to render the visual order reliably
5397/// across YAML / HTML consumers); the visible-order risk on
5398/// these axes is closed by the bidi-*override* helper (the 9
5399/// codepoints UAX #9 names as the Trojan Source vector), not
5400/// by the bidi-*marks*, so LRM/RLM remain accepted natively.
5401/// - Codepoints outside the BMP — Variation Selectors
5402/// Supplement (U+E0100..U+E01EF), Tag characters
5403/// (U+E0001..U+E007F) — sit outside the BMP and rarely
5404/// surface in realistic Helm chart metadata pasted from
5405/// editors; the BMP-restricted set captures the canonical
5406/// paste-from-Word / paste-from-BOM-editor / paste-from-
5407/// typesetting-doc / paste-from-math-formula class without
5408/// committing to a full Unicode `Default_Ignorable_Code_Point`
5409/// table.
5410///
5411/// Lifted as a shared helper rather than inlined into each per-axis
5412/// predicate (the PRIME DIRECTIVE duplication-budget rule —
5413/// THEORY.md §I.3.5: "every recurring shape becomes a generator
5414/// before it becomes a pattern; every pattern becomes a library
5415/// before it becomes duplicated code. The duplication budget is
5416/// zero.") because two predicates ([`is_chart_description_shape`],
5417/// [`is_chart_maintainer_name_shape`]) carry the same UTF-8
5418/// free-form-prose accepted set and would otherwise inline the same
5419/// eight-codepoint match arm verbatim — third lift in the UAX-driven
5420/// render-determinism trio (peer of [`find_unicode_bidi_override`]
5421/// on the visual-order axis and [`find_unicode_line_break`] on the
5422/// single-line/multi-line axis). The third caller — every future
5423/// per-axis free-form-prose surface (a future Aplicacao-level
5424/// `:descricao` summary axis, a future per-`:contratos` edge
5425/// `:descricao` annotation, the future per-`:autores`-email-suffix
5426/// shape gate) — lands as a thin `if let Some(c) =
5427/// find_unicode_invisible_format(s) { … }` wrapper rather than
5428/// re-inlining the same codepoint match.
5429///
5430/// The arm is structurally distinct from every prior arm on the
5431/// calling predicates: the per-byte control-char arm catches ASCII
5432/// `0x00..=0x1F` plus `0x7F` DEL; the per-byte non-ASCII pass
5433/// admits multi-byte UTF-8 sequences (Unicode letters, em-dash,
5434/// arrows are canonical shapes); the bidi-override helper catches
5435/// the 9 visual-order codepoints; the line-break helper catches
5436/// the 3 single-line-vs-multi-line codepoints. None overlap the
5437/// eight invisible-format codepoints here — each decodes to a
5438/// distinct multi-byte UTF-8 sequence (`C2 AD` for U+00AD,
5439/// `E2 80 8B` for U+200B, `E2 81 A0` for U+2060, `E2 81 A1` for
5440/// U+2061, `E2 81 A2` for U+2062, `E2 81 A3` for U+2063, `E2 81
5441/// A4` for U+2064, `EF BB BF` for U+FEFF) the per-byte non-ASCII
5442/// pass deliberately accepts; only the typed codepoint scan catches
5443/// them.
5444///
5445/// The four math-invisible operators U+2061..=U+2064 carry their
5446/// semantic load only inside mathematical typesetting (MathML
5447/// `<mo>` invisible operators, LaTeX `\,\,` thin-space-as-invisible-
5448/// times) — no realistic Helm chart `:descricao` or `:autores`
5449/// value is a math formula. The canonical authoring footgun is the
5450/// paste-from-MathJax-rendered-doc / paste-from-LaTeX-equation /
5451/// paste-from-InDesign-math-equation shape where MathJax /
5452/// LaTeX2RTF / InDesign export an invisible-operator codepoint
5453/// between adjacent symbols to preserve the semantic operator
5454/// reading for screen readers, and the codepoint silently rides
5455/// into the YAML scalar — same invisible-identity divergence class
5456/// the BMP four (SHY / ZWSP / WJ / BOM) close on the paste-from-
5457/// Word / paste-from-BOM-editor / paste-from-typesetting-doc class.
5458fn find_unicode_invisible_format(s: &str) -> Option<char> {
5459 s.chars().find(|c| {
5460 matches!(
5461 *c,
5462 '\u{00AD}'
5463 | '\u{200B}'
5464 | '\u{2060}'
5465 | '\u{2061}'
5466 | '\u{2062}'
5467 | '\u{2063}'
5468 | '\u{2064}'
5469 | '\u{FEFF}'
5470 )
5471 })
5472}
5473
5474/// Predicate: assert that `s` is a valid chart-description shape.
5475/// The `:descricao` axis is a free-form prose summary that lands in
5476/// the rendered `lareira-<nome>` Helm chart's `Chart.yaml`
5477/// `description:` field (a YAML scalar consumed by `helm list`,
5478/// `helm search`, Artifact Hub, and every chart-aware UI) and in
5479/// the chart's `README.md` header paragraph
5480/// (`caixa-helm/src/lib.rs:232`, `caixa-helm/src/lib.rs:333`).
5481/// The contract — modeled on the YAML 1.2 plain-style scalar
5482/// grammar and the Helm chart spec's expectation that
5483/// `description:` is a one-line summary:
5484///
5485/// - 1..=[`CHART_DESCRIPTION_MAX_LEN`] (512) bytes;
5486/// - no leading whitespace (paste-from-aligned-doc footgun —
5487/// YAML plain-style scalars round-trip trim-and-restore on
5488/// leading whitespace, so an authored `" foo"` lands as `"foo"`
5489/// in the rendered Chart.yaml and the round-trip back through
5490/// `caixa.lisp` silently drops the space);
5491/// - no trailing whitespace (paste-from-doc footgun — every YAML
5492/// dumper trims trailing whitespace from plain-style scalars,
5493/// so an authored `"foo "` round-trips inconsistently);
5494/// - no ASCII control characters anywhere (`0x00..=0x1F` plus
5495/// `0x7F` DEL) — tabs, newlines, carriage returns, and every
5496/// other control byte break the single-line YAML scalar shape
5497/// and the README header paragraph. The newline / CR arms are
5498/// the canonical paste-from-multiline-doc footgun; the tab arm
5499/// is the canonical paste-from-aligned-doc footgun; the
5500/// other-control-byte arm catches every more-exotic
5501/// paste-from-binary-blob shape (`0x00` NUL, `0x07` BEL,
5502/// `0x1B` ESC) that would silently land in the rendered
5503/// `Chart.yaml` as a YAML-illegal byte sequence and fail at
5504/// `helm lint` time far from the source caixa.lisp;
5505/// - non-ASCII bytes (UTF-8 continuation sequences) are
5506/// accepted — the canonical author shapes (`"Canonical
5507/// Rust→wasm32-wasip2 caixa Servico."`, `"FIXME — describe
5508/// this caixa"`) carry `→` (U+2192) and `—` (U+2014) and every
5509/// downstream consumer (YAML 1.2, Helm v3, every chart-aware
5510/// UI) round-trips Unicode losslessly;
5511/// - no Unicode bidirectional-override / isolate format
5512/// codepoints (U+202A `LRE`, U+202B `RLE`, U+202C `PDF`,
5513/// U+202D `LRO`, U+202E `RLO`, U+2066 `LRI`, U+2067 `RLI`,
5514/// U+2068 `FSI`, U+2069 `PDI`) — the nine codepoints UAX #9
5515/// names as the structural prerequisite of the "Trojan Source"
5516/// attack class (CVE-2021-42574 / Boucher & Anderson 2021)
5517/// that flip the rendered visual order of every following
5518/// character until a matching pop. Routed through the lifted
5519/// [`find_unicode_bidi_override`] helper so the same
5520/// nine-codepoint accepted set is shared with
5521/// [`is_chart_maintainer_name_shape`] on the sibling
5522/// YAML-plain-style-scalar surface, structurally consistent.
5523/// The non-ASCII byte arm above admits Unicode letters /
5524/// em-dash / arrows because YAML 1.2 + Helm v3 + every
5525/// chart-aware UI round-trip them losslessly; the bidi-override
5526/// codepoints break that round-trip discipline by class
5527/// (the byte sequence rides verbatim into the rendered
5528/// `Chart.yaml`'s `description:` value but renders differently
5529/// in `helm show chart` / Artifact Hub / `helm list` vs the
5530/// author's editor view of `caixa.lisp`), defeating the
5531/// THEORY.md §V.2 render-determinism contract every typed
5532/// slot carries on the same axis the per-byte CR/LF/control
5533/// arms above close for ASCII.
5534/// - no non-ASCII Unicode line-break codepoints (U+0085 `NEL`,
5535/// U+2028 `LS`, U+2029 `PS`) — the three codepoints UAX #14
5536/// (Unicode Line Breaking Algorithm) and the YAML 1.1 §4.1
5537/// b-char production both treat as line terminators outside
5538/// the ASCII `\n` / `\r` arms above. YAML 1.2 §5.4 retired
5539/// them per UTR #20, so YAML 1.2-strict parsers preserve them
5540/// verbatim while YAML 1.1 parsers (go-yaml v2 which Helm v3 /
5541/// kubectl link, `ruamel.yaml` in compat mode) split the
5542/// scalar on them — the same `:descricao` value parses as
5543/// single-line through one consumer and multi-line through
5544/// another, breaking cross-parser determinism on the same
5545/// axis the per-byte `\n` / `\r` arms close for ASCII.
5546/// Independently, every UAX #14 conformant text consumer
5547/// (editors, terminals, `helm list` / Artifact Hub web UIs)
5548/// breaks the visual line at these codepoints regardless of
5549/// YAML version, so the author's editor view of `caixa.lisp`
5550/// and the chart-consumer's rendered view diverge even when
5551/// both YAML parsers agree on the byte-level shape. Routed
5552/// through the lifted [`find_unicode_line_break`] helper so
5553/// the same three-codepoint accepted set is shared with
5554/// [`is_chart_maintainer_name_shape`], peer of the
5555/// [`find_unicode_bidi_override`] lift on the same two
5556/// predicates one trajectory earlier.
5557/// - no Unicode invisible-format codepoints (U+00AD `SHY`,
5558/// U+200B `ZWSP`, U+2060 `WJ`, U+2061 `FA` FUNCTION
5559/// APPLICATION, U+2062 `IT` INVISIBLE TIMES, U+2063 `IS`
5560/// INVISIBLE SEPARATOR, U+2064 `IP` INVISIBLE PLUS, U+FEFF
5561/// `ZWNBSP` / BOM) — the eight BMP Cf-category zero-width
5562/// codepoints with no visible glyph in any conforming font.
5563/// The author's editor view of `caixa.lisp` and the chart-
5564/// consumer's `helm list` / Artifact Hub description column
5565/// agree on the visible glyph sequence (`"Canonical Servico"`
5566/// and `"Canonical\u{200B}Servico"` render identically), but
5567/// the byte sequence the YAML-plain-style-scalar carries
5568/// verbatim differs — every byte-level grep / diff / equality
5569/// comparison and the Artifact Hub description-search index
5570/// lookup disagree silently with the visible-glyph match.
5571/// Closes the canonical paste-from-Microsoft-Word (SHY auto-
5572/// inserted at hyphenation candidates), paste-from-text-
5573/// editor-saved-as-UTF-8-with-BOM (leading BOM byte),
5574/// paste-from-typesetting-doc (ZWSP / WJ invisible word-break
5575/// hints), and paste-from-MathJax/LaTeX-rendered-formula
5576/// (FUNCTION APPLICATION / INVISIBLE TIMES / INVISIBLE
5577/// SEPARATOR / INVISIBLE PLUS — the four math-formula
5578/// invisible operators MathJax / LaTeX export between
5579/// adjacent symbols for screen-reader operator semantics)
5580/// footguns. Routed through the lifted
5581/// [`find_unicode_invisible_format`] helper so the same
5582/// eight-codepoint accepted set is shared with
5583/// [`is_chart_maintainer_name_shape`], third lift in the
5584/// UAX-driven render-determinism trio (peer of
5585/// [`find_unicode_bidi_override`] on the visual-order axis
5586/// and [`find_unicode_line_break`] on the single-line/multi-
5587/// line axis). The eight-codepoint set excludes U+200C
5588/// `ZWNJ` / U+200D `ZWJ` (legitimate compositional load in
5589/// Indic / Persian scripts and emoji ZWJ sequences) and
5590/// U+200E `LRM` / U+200F `RLM` (legitimate single-character
5591/// direction hints in mixed-script prose); the visible-order
5592/// risk on bidi overrides — not marks — is closed by the
5593/// prior helper.
5594///
5595/// The predicate is a *structural* floor — it enforces the
5596/// single-line printable-UTF-8 shape every realistic chart
5597/// description carries, not a per-byte alphabet check (which would
5598/// regress every non-ASCII canonical fixture). Same trajectory as
5599/// [`is_spdx_expression_shape`] (the ASCII-alphabet floor on the
5600/// `:licenca` axis) and [`is_git_repo_url`] (the URL-shape floor on
5601/// the `:repositorio` axis): the typed validator refuses the
5602/// downstream consumer's would-also-refuse shapes at the source
5603/// caixa.lisp boundary with the offending value named verbatim.
5604///
5605/// Returns the parser-shaped reason on rejection (without wrapping
5606/// in any error variant) so each per-axis caller —
5607/// [`crate::Caixa::validate_descricao`] for the universal
5608/// `:descricao` axis at validate time, every future per-description
5609/// axis (a future Aplicacao-level `:descricao` summary axis on
5610/// `mesh.pleme.io/v1alpha1/Caixa` CRs, a future Servico-level
5611/// per-`:contratos` edge `:descricao` annotation) — wraps the same
5612/// reason in its own typed `*Invalid { <axis>, reason }` variant.
5613/// The reason wording is axis-agnostic ("chart descriptions reject
5614/// leading whitespace") so every call site reading the same
5615/// diagnostic points at the same rule; drift between any two axes'
5616/// rule enforcement is a build error visible at this predicate, not
5617/// a per-renderer "this passed validate but `helm lint` rejected
5618/// the Chart.yaml `description:` value" surprise.
5619///
5620/// Empty input is rejected here (defensively) and at each call
5621/// site via the narrower [`crate::ManifestError::DescricaoEmpty`]
5622/// variant — the same empty-first cascade [`is_dns_1123_label`],
5623/// [`is_gateway_api_http_path`], [`is_wit_world_ref`],
5624/// [`is_nats_subject`], [`is_wasi_keyvalue_slot`],
5625/// [`is_git_ref_name`], [`is_git_oid`], [`is_git_repo_url`],
5626/// [`is_cargo_feature_name`], and [`is_spdx_expression_shape`] all
5627/// carry.
5628///
5629/// # Errors
5630///
5631/// Returns the parser-shaped reason naming the specific violation
5632/// (length / leading-whitespace / trailing-whitespace /
5633/// tab / newline / carriage-return / other-control-byte /
5634/// Unicode-bidi-override-codepoint / Unicode-line-break-codepoint),
5635/// without wrapping in any error variant — every caller maps the
5636/// same `String` into its own typed `*Invalid { <axis>, reason }`
5637/// enum variant.
5638pub fn is_chart_description_shape(s: &str) -> Result<(), String> {
5639 if s.is_empty() {
5640 return Err("must not be empty".to_string());
5641 }
5642 if s.len() > CHART_DESCRIPTION_MAX_LEN {
5643 return Err(format!(
5644 "exceeds chart description max length of {CHART_DESCRIPTION_MAX_LEN} bytes \
5645 (got {} bytes; realistic chart descriptions like `\"Canonical \
5646 Rust→wasm32-wasip2 caixa Servico.\"` rarely exceed ~64 bytes — this \
5647 length suggests a paste-from-doc multi-paragraph blob landed in the \
5648 `:descricao` slot)",
5649 s.len()
5650 ));
5651 }
5652 let bytes = s.as_bytes();
5653 if bytes[0] == b' ' {
5654 return Err(
5655 "must not start with whitespace (chart descriptions are single-line YAML \
5656 plain-style scalars; a leading space is the canonical \
5657 paste-from-aligned-doc footgun and round-trips inconsistently — every \
5658 YAML dumper trims leading whitespace from plain-style scalars, so the \
5659 authored space silently drops in the rendered Chart.yaml)"
5660 .to_string(),
5661 );
5662 }
5663 if *bytes.last().expect("non-empty checked above") == b' ' {
5664 return Err(
5665 "must not end with whitespace (chart descriptions don't terminate with \
5666 trailing whitespace; every YAML dumper trims trailing whitespace from \
5667 plain-style scalars, so the authored space round-trips inconsistently \
5668 back through `caixa.lisp`)"
5669 .to_string(),
5670 );
5671 }
5672 for &b in bytes {
5673 if b == b'\t' {
5674 return Err(
5675 "must not contain tab character (chart descriptions are single-line \
5676 YAML plain-style scalars; tabs are the canonical \
5677 paste-from-aligned-doc footgun and break the single-line scalar \
5678 shape — every downstream YAML 1.2 parser is forbidden from \
5679 emitting indentation tabs and tabs in plain-style scalars are \
5680 implementation-defined)"
5681 .to_string(),
5682 );
5683 }
5684 if b == b'\n' {
5685 return Err(
5686 "must not contain newline (chart descriptions are single-line YAML \
5687 plain-style scalars; an embedded newline is the canonical \
5688 paste-from-multiline-doc footgun and lands as a multi-line YAML \
5689 block scalar in the rendered Chart.yaml — every chart-aware UI \
5690 (`helm list`, `helm search`, Artifact Hub) renders the description \
5691 in a single-line column, so the embedded newline is silently \
5692 dropped at every downstream consumer)"
5693 .to_string(),
5694 );
5695 }
5696 if b == b'\r' {
5697 return Err("must not contain carriage return (chart descriptions are \
5698 single-line YAML plain-style scalars; a `\\r` byte is the canonical \
5699 paste-from-Windows-CRLF-doc footgun and lands as a literal CR in \
5700 the rendered Chart.yaml — every YAML 1.2 parser treats CR as a \
5701 line terminator equivalent to LF, so the embedded CR is silently \
5702 normalized to a newline at every downstream consumer)"
5703 .to_string());
5704 }
5705 if b < 0x20 || b == 0x7F {
5706 return Err(format!(
5707 "must not contain control character 0x{b:02x} (chart descriptions \
5708 are printable UTF-8 single-line scalars; the control-byte arm \
5709 catches paste-from-binary-blob footguns like `0x00` NUL, `0x07` \
5710 BEL, `0x1b` ESC that would silently land in the rendered \
5711 Chart.yaml as a YAML-illegal byte sequence and fail at `helm lint` \
5712 time far from the source caixa.lisp)"
5713 ));
5714 }
5715 }
5716 if let Some(c) = find_unicode_bidi_override(s) {
5717 return Err(format!(
5718 "must not contain Unicode bidirectional-override codepoint U+{cp:04X} \
5719 (the nine codepoints UAX #9 names as the structural prerequisite of \
5720 the \"Trojan Source\" attack class — CVE-2021-42574 / Boucher & \
5721 Anderson 2021: U+202A `LRE`, U+202B `RLE`, U+202C `PDF`, U+202D `LRO`, \
5722 U+202E `RLO`, U+2066 `LRI`, U+2067 `RLI`, U+2068 `FSI`, U+2069 `PDI` \
5723 — flip the rendered visual order of every following character until a \
5724 matching pop, so a `:descricao` string visible to a human reading \
5725 `caixa.lisp` and the same string consumed by `helm show chart` / \
5726 `helm list` / Artifact Hub / every chart-aware UI disagree on the \
5727 order of the displayed content bytes. The byte sequence \
5728 ({utf8_seq}) rides verbatim into the rendered Chart.yaml's \
5729 `description:` value at the same axis the per-byte CR/LF/control \
5730 arms close for ASCII, but renders differently across consumers, \
5731 defeating the THEORY.md §V.2 render-determinism contract every typed \
5732 slot carries. The non-ASCII byte arm above admits Unicode letters / \
5733 em-dash / arrows because YAML 1.2 + Helm v3 round-trip them \
5734 losslessly; this codepoint breaks that round-trip discipline by \
5735 class. Drop the bidi-override codepoint; pure visual right-to-left \
5736 text (Hebrew, Arabic) is accepted natively without explicit \
5737 direction marks)",
5738 cp = c as u32,
5739 utf8_seq = c
5740 .encode_utf8(&mut [0u8; 4])
5741 .bytes()
5742 .map(|b| format!("0x{b:02X}"))
5743 .collect::<Vec<_>>()
5744 .join(" "),
5745 ));
5746 }
5747 if let Some(c) = find_unicode_line_break(s) {
5748 return Err(format!(
5749 "must not contain Unicode line-break codepoint U+{cp:04X} (the three \
5750 codepoints UAX #14 / YAML 1.1 §4.1 name as line terminators outside \
5751 the ASCII `\\n` / `\\r` arms above: U+0085 `NEL` NEXT LINE, U+2028 \
5752 `LS` LINE SEPARATOR, U+2029 `PS` PARAGRAPH SEPARATOR. YAML 1.2 §5.4 \
5753 retired them per UTR #20 so YAML 1.2-strict parsers preserve them \
5754 verbatim, but YAML 1.1 parsers (go-yaml v2 which Helm v3 / kubectl / \
5755 every Kubernetes client library transitively links, `ruamel.yaml` in \
5756 compat mode) still split scalars on them — the same `:descricao` \
5757 value parses as a single-line plain-style scalar through one \
5758 downstream consumer and a multi-line block scalar through another, \
5759 breaking cross-parser determinism on the same axis the per-byte \
5760 `\\n` / `\\r` arms close for ASCII. Independently, every UAX #14 \
5761 conformant text consumer (editors, terminals, `helm list` / \
5762 `helm search` / Artifact Hub web UIs) breaks the visual line at \
5763 these codepoints regardless of YAML version, so the author's editor \
5764 view of `caixa.lisp` and the chart-consumer's rendered view of the \
5765 `description:` field diverge even when both YAML parsers agree on \
5766 the byte-level shape, defeating the THEORY.md §V.2 render-\
5767 determinism contract every typed slot carries. The byte sequence \
5768 ({utf8_seq}) rides verbatim into the rendered Chart.yaml at the \
5769 same axis the per-byte `\\n` / `\\r` arms close for ASCII. Routed \
5770 through the shared [`find_unicode_line_break`] helper so the same \
5771 three-codepoint accepted set lives in exactly one place across the \
5772 [`is_chart_maintainer_name_shape`] sibling YAML-plain-style-scalar \
5773 surface, peer of the [`find_unicode_bidi_override`] lift on the \
5774 same two predicates one trajectory earlier. Drop the non-ASCII \
5775 line-break codepoint; split the value into separate logical lines \
5776 at the source if a multi-line summary is intended (the \
5777 `:descricao` axis is single-line by contract — the multi-paragraph \
5778 shape belongs in the chart `README.md` body, not the YAML \
5779 `description:` scalar))",
5780 cp = c as u32,
5781 utf8_seq = c
5782 .encode_utf8(&mut [0u8; 4])
5783 .bytes()
5784 .map(|b| format!("0x{b:02X}"))
5785 .collect::<Vec<_>>()
5786 .join(" "),
5787 ));
5788 }
5789 if let Some(c) = find_unicode_invisible_format(s) {
5790 return Err(format!(
5791 "must not contain Unicode invisible-format codepoint U+{cp:04X} (the \
5792 eight BMP Cf-category zero-width codepoints with no visible glyph in \
5793 any conforming font: U+00AD `SHY` SOFT HYPHEN, U+200B `ZWSP` ZERO \
5794 WIDTH SPACE, U+2060 `WJ` WORD JOINER, U+2061 `FA` FUNCTION \
5795 APPLICATION, U+2062 `IT` INVISIBLE TIMES, U+2063 `IS` INVISIBLE \
5796 SEPARATOR, U+2064 `IP` INVISIBLE PLUS, U+FEFF `ZWNBSP` ZERO WIDTH \
5797 NO-BREAK SPACE / BOM. The invisible-identity divergence: the \
5798 author's editor view of `caixa.lisp`, the chart-consumer's \
5799 `helm list` / `helm search` / Artifact Hub description column, \
5800 and every conformant terminal / browser / editor agree on the \
5801 visible glyph sequence (the codepoint renders as nothing, so \
5802 `\"Canonical Servico\"` and `\"Canonical\\u{{200B}}Servico\"` look \
5803 identical end-to-end), but the byte sequence the YAML-plain-style-\
5804 scalar carries verbatim differs — every byte-level grep / diff / \
5805 equality comparison over the rendered Chart.yaml `description:` \
5806 value disagrees with the visible-glyph match, and the Artifact Hub \
5807 description-search index lookup misses the authored entry because \
5808 the byte sequence carries an extra invisible codepoint between \
5809 letters. The canonical authoring shapes that silently introduce \
5810 these codepoints: paste-from-Microsoft-Word (SHY auto-inserted at \
5811 every hyphenation candidate), paste-from-text-editor-saved-as-UTF-8-\
5812 with-BOM (BOM leading byte from Notepad / older VS Code defaults), \
5813 paste-from-typesetting-doc (ZWSP / WJ invisible word-break hints \
5814 from InDesign / LaTeX-rendered PDF copy-paste), and paste-from-\
5815 MathJax/LaTeX-rendered-formula (FUNCTION APPLICATION / INVISIBLE \
5816 TIMES / INVISIBLE SEPARATOR / INVISIBLE PLUS — MathJax / LaTeX2RTF \
5817 / InDesign math-equation export emit one of these between adjacent \
5818 symbols to preserve operator semantics for screen readers, and the \
5819 codepoint silently rides into the YAML scalar with no visible \
5820 trace). The byte sequence ({utf8_seq}) rides verbatim into the \
5821 rendered Chart.yaml at the same axis the per-byte CR/LF/control \
5822 arms close for ASCII, but renders as nothing across consumers, \
5823 defeating the THEORY.md §V.2 render-determinism contract on a \
5824 third axis from the bidi-override (visual-order) and line-break \
5825 (single-line vs multi-line) classes the prior arms close. Routed \
5826 through the shared [`find_unicode_invisible_format`] helper so \
5827 the eight-codepoint accepted set lives in exactly one place \
5828 across the [`is_chart_maintainer_name_shape`] sibling \
5829 YAML-plain-style-scalar surface, third lift in the UAX-driven \
5830 render-determinism trio (peer of [`find_unicode_bidi_override`] \
5831 on the visual-order axis and [`find_unicode_line_break`] on the \
5832 single-line/multi-line axis). Drop the invisible codepoint; emoji \
5833 ZWJ sequences (U+200D for the 👨💻 family) and bidi direction-mark \
5834 codepoints (U+200E `LRM` / U+200F `RLM`) are accepted natively — \
5835 only the eight zero-semantic-content codepoints are rejected)",
5836 cp = c as u32,
5837 utf8_seq = c
5838 .encode_utf8(&mut [0u8; 4])
5839 .bytes()
5840 .map(|b| format!("0x{b:02X}"))
5841 .collect::<Vec<_>>()
5842 .join(" "),
5843 ));
5844 }
5845 Ok(())
5846}
5847
5848/// Maximum byte length of a chart-maintainer-name-shaped string. The
5849/// 128-byte cap is the axis-appropriate ceiling for the per-entry
5850/// identifier the `:autores` Vec axis carries: every realistic Helm
5851/// chart maintainer name in the wild (`"pleme-io"`, `"Pleme
5852/// Contributors"`, `"alice <alice@example.com>"`, `"François
5853/// Dupont"`) sits well under 64 bytes, and the 128-byte cap surfaces
5854/// the "paste-from-doc multi-paragraph blob landed in a single
5855/// `:autores` entry" footgun at validate time. Tighter than
5856/// [`CHART_DESCRIPTION_MAX_LEN`] (512) on the sibling free-form-prose
5857/// axis where multi-sentence summaries are the canonical shape;
5858/// peer with [`WIT_IDENT_MAX_LEN`] (128) on the sibling
5859/// short-identifier-class axis.
5860pub const CHART_MAINTAINER_NAME_MAX_LEN: usize = 128;
5861
5862/// Predicate: assert that `s` is a valid chart-maintainer-name shape.
5863/// The `:autores` axis is a per-entry maintainer identifier that lands
5864/// in the rendered `lareira-<nome>` Helm chart's `Chart.yaml`
5865/// `maintainers: [{name: …, email: null}]` array via
5866/// [`caixa-helm`]'s `build_chart_yaml` (`caixa-helm/src/lib.rs:251`);
5867/// each entry becomes the `name:` value of a single `Maintainer`
5868/// record (a YAML scalar consumed by `helm list`, `helm search`,
5869/// Artifact Hub's maintainer index, and every chart-aware UI). The
5870/// contract — modeled on the same YAML 1.2 plain-style scalar
5871/// grammar [`is_chart_description_shape`] enforces on the sibling
5872/// `:descricao` axis, with a tighter length cap for the per-entry
5873/// identifier class:
5874///
5875/// - 1..=[`CHART_MAINTAINER_NAME_MAX_LEN`] (128) bytes;
5876/// - no leading whitespace (paste-from-aligned-doc footgun —
5877/// YAML plain-style scalars round-trip trim-and-restore on
5878/// leading whitespace, so an authored `" pleme-io"` lands as
5879/// `"pleme-io"` in the rendered Chart.yaml and the round-trip
5880/// back through `caixa.lisp` silently drops the space);
5881/// - no trailing whitespace (paste-from-doc footgun — every YAML
5882/// dumper trims trailing whitespace from plain-style scalars,
5883/// so an authored `"pleme-io "` round-trips inconsistently);
5884/// - no ASCII control characters anywhere (`0x00..=0x1F` plus
5885/// `0x7F` DEL) — tabs, newlines, carriage returns, and every
5886/// other control byte break the single-line YAML scalar shape
5887/// and the `helm list` / `helm search` / Artifact Hub
5888/// maintainer-column rendering. The newline / CR arms are the
5889/// canonical paste-from-multiline-doc footgun (the author
5890/// pasted a multi-line block of author records into one
5891/// `:autores` entry instead of splitting them into one entry
5892/// per author); the tab arm is the canonical
5893/// paste-from-aligned-doc footgun; the other-control-byte
5894/// arm catches every more-exotic paste-from-binary-blob shape;
5895/// - non-ASCII bytes (UTF-8 continuation sequences) are accepted
5896/// — realistic maintainer names carry Unicode (`"François"`,
5897/// `"日本語"`, `"naïve"`) and every downstream consumer
5898/// (YAML 1.2, Helm v3, every chart-aware UI) round-trips
5899/// Unicode losslessly;
5900/// - no Unicode bidirectional-override / isolate format
5901/// codepoints (U+202A `LRE`, U+202B `RLE`, U+202C `PDF`,
5902/// U+202D `LRO`, U+202E `RLO`, U+2066 `LRI`, U+2067 `RLI`,
5903/// U+2068 `FSI`, U+2069 `PDI`) — the nine codepoints UAX #9
5904/// names as the structural prerequisite of the "Trojan Source"
5905/// attack class (CVE-2021-42574). A maintainer-name with an
5906/// embedded `RLO` flips the visual order of every trailing
5907/// byte, so an `:autores "alice\u{202E}example.com<bob@"` (the
5908/// paste-from-attacker-crafted-doc footgun) renders in
5909/// `helm list`'s maintainer column / Artifact Hub as
5910/// `alice<@bob>moc.elpmaxe` but rides verbatim into the
5911/// rendered Chart.yaml `maintainers:` array — same Trojan
5912/// Source class [`is_chart_description_shape`] closes on the
5913/// sibling `:descricao` axis. Routed through the same lifted
5914/// [`find_unicode_bidi_override`] helper so the nine-codepoint
5915/// accepted set is shared, structurally consistent.
5916/// - no non-ASCII Unicode line-break codepoints (U+0085 `NEL`,
5917/// U+2028 `LS`, U+2029 `PS`) — the three codepoints UAX #14
5918/// (Unicode Line Breaking Algorithm) and YAML 1.1 §4.1 b-char
5919/// production both treat as line terminators outside the
5920/// ASCII `\n` / `\r` arms above. YAML 1.2 §5.4 retired them
5921/// per UTR #20 so the cross-parser line-break disagreement
5922/// (go-yaml v2 / YAML 1.1 still splits; YAML 1.2-strict
5923/// parsers preserve) breaks the THEORY.md §V.2 render-
5924/// determinism contract on the same axis the per-byte `\n` /
5925/// `\r` arms close for ASCII. A maintainer-name with an
5926/// embedded U+2028 parses as one entry through a YAML 1.2
5927/// parser and as two `maintainers:` array entries through a
5928/// YAML 1.1 parser — same paste-from-multiline-doc class the
5929/// `\n` arm above closes, extended to the non-ASCII line-break
5930/// codepoints the per-byte non-ASCII pass deliberately
5931/// admits for Unicode letters. Routed through the same lifted
5932/// [`find_unicode_line_break`] helper so the three-codepoint
5933/// accepted set is shared with [`is_chart_description_shape`]
5934/// on the sibling YAML-plain-style-scalar surface,
5935/// structurally consistent.
5936/// - no Unicode invisible-format codepoints (U+00AD `SHY`,
5937/// U+200B `ZWSP`, U+2060 `WJ`, U+2061 `FA` FUNCTION
5938/// APPLICATION, U+2062 `IT` INVISIBLE TIMES, U+2063 `IS`
5939/// INVISIBLE SEPARATOR, U+2064 `IP` INVISIBLE PLUS, U+FEFF
5940/// `ZWNBSP` / BOM) — the eight BMP Cf-category zero-width
5941/// codepoints with no visible glyph. A maintainer-name with
5942/// an embedded U+200B (`"alice\u{200B}"`) renders identically
5943/// to `"alice"` in `helm list` / Artifact Hub's maintainer
5944/// column, yet the byte sequence is distinct — the Artifact
5945/// Hub maintainer-index lookup misses the authored `"alice"`
5946/// entry, and a future CLA-signer lookup matches a visually-
5947/// identical-but-byte-distinct identity (the canonical
5948/// invisible-codepoint homograph footgun on the maintainer-
5949/// identity axis). Closes the canonical paste-from-Microsoft-
5950/// Word (SHY), paste-from-text-editor-saved-as-UTF-8-with-BOM
5951/// (BOM), paste-from-typesetting-doc (ZWSP / WJ), and
5952/// paste-from-MathJax/LaTeX-rendered-formula (FUNCTION
5953/// APPLICATION / INVISIBLE TIMES / INVISIBLE SEPARATOR /
5954/// INVISIBLE PLUS — math-formula invisible operators
5955/// MathJax / LaTeX2RTF / InDesign emit between symbols for
5956/// screen-reader operator semantics) footguns. Routed through
5957/// the same lifted [`find_unicode_invisible_format`] helper
5958/// so the eight-codepoint accepted set is shared with
5959/// [`is_chart_description_shape`], third lift in the UAX-
5960/// driven render-determinism trio (peer of
5961/// [`find_unicode_bidi_override`] on the visual-order axis
5962/// and [`find_unicode_line_break`] on the single-line/multi-
5963/// line axis). The eight-codepoint set excludes U+200C
5964/// `ZWNJ` / U+200D `ZWJ` (emoji ZWJ sequences are canonical
5965/// for modern maintainer-display names) and U+200E `LRM` /
5966/// U+200F `RLM` (mixed-script direction hints are canonical
5967/// for "Arabic name with embedded ASCII email" shapes).
5968///
5969/// Same structural single-line printable-UTF-8 floor as
5970/// [`is_chart_description_shape`] — both `:descricao` and `:autores`
5971/// land as YAML plain-style scalars in the same `Chart.yaml` and
5972/// share every paste-from-doc footgun the YAML 1.2 grammar refuses
5973/// at parse time. The two predicates differ only on the byte
5974/// length cap: 512 bytes for `:descricao` (multi-sentence prose
5975/// shape) vs 128 bytes for `:autores` entries (short-identifier
5976/// shape). Returns the parser-shaped reason on rejection (without
5977/// wrapping in any error variant) so each per-axis caller —
5978/// [`crate::Caixa::validate_autores`] for the universal `:autores`
5979/// axis at validate time, every future per-maintainer-name axis (a
5980/// future caixa-registry maintainer-index entry, a future
5981/// chart-author CLA-signer lookup) — wraps the same reason in its
5982/// own typed `*Invalid { <axis>, reason }` variant.
5983///
5984/// Empty input is rejected here (defensively) and at each call
5985/// site via the narrower [`crate::ManifestError::AutorEmpty`]
5986/// variant — the same empty-first cascade [`is_dns_1123_label`],
5987/// [`is_gateway_api_http_path`], [`is_wit_world_ref`],
5988/// [`is_nats_subject`], [`is_wasi_keyvalue_slot`],
5989/// [`is_git_ref_name`], [`is_git_oid`], [`is_git_repo_url`],
5990/// [`is_cargo_feature_name`], [`is_spdx_expression_shape`], and
5991/// [`is_chart_description_shape`] all carry.
5992///
5993/// # Errors
5994///
5995/// Returns the parser-shaped reason naming the specific violation
5996/// (length / leading-whitespace / trailing-whitespace / tab /
5997/// newline / carriage-return / other-control-byte /
5998/// Unicode-bidi-override-codepoint), without wrapping in any error
5999/// variant — every caller maps the same `String` into its own typed
6000/// `*Invalid { <axis>, reason }` enum variant.
6001pub fn is_chart_maintainer_name_shape(s: &str) -> Result<(), String> {
6002 if s.is_empty() {
6003 return Err("must not be empty".to_string());
6004 }
6005 if s.len() > CHART_MAINTAINER_NAME_MAX_LEN {
6006 return Err(format!(
6007 "exceeds chart maintainer name max length of \
6008 {CHART_MAINTAINER_NAME_MAX_LEN} bytes (got {} bytes; realistic chart \
6009 maintainer names like `\"pleme-io\"`, `\"Pleme Contributors\"`, \
6010 `\"alice <alice@example.com>\"` rarely exceed ~64 bytes — this \
6011 length suggests a paste-from-doc multi-paragraph blob landed in a \
6012 single `:autores` entry instead of being split into one entry per \
6013 author)",
6014 s.len()
6015 ));
6016 }
6017 let bytes = s.as_bytes();
6018 if bytes[0] == b' ' {
6019 return Err(
6020 "must not start with whitespace (chart maintainer names are \
6021 single-line YAML plain-style scalars; a leading space is the \
6022 canonical paste-from-aligned-doc footgun and round-trips \
6023 inconsistently — every YAML dumper trims leading whitespace from \
6024 plain-style scalars, so the authored space silently drops in the \
6025 rendered Chart.yaml)"
6026 .to_string(),
6027 );
6028 }
6029 if *bytes.last().expect("non-empty checked above") == b' ' {
6030 return Err(
6031 "must not end with whitespace (chart maintainer names don't \
6032 terminate with trailing whitespace; every YAML dumper trims \
6033 trailing whitespace from plain-style scalars, so the authored \
6034 space round-trips inconsistently back through `caixa.lisp`)"
6035 .to_string(),
6036 );
6037 }
6038 for &b in bytes {
6039 if b == b'\t' {
6040 return Err(
6041 "must not contain tab character (chart maintainer names are \
6042 single-line YAML plain-style scalars; tabs are the canonical \
6043 paste-from-aligned-doc footgun and break the single-line \
6044 scalar shape — every downstream YAML 1.2 parser is forbidden \
6045 from emitting indentation tabs and tabs in plain-style scalars \
6046 are implementation-defined)"
6047 .to_string(),
6048 );
6049 }
6050 if b == b'\n' {
6051 return Err("must not contain newline (chart maintainer names are \
6052 single-line YAML plain-style scalars; an embedded newline is \
6053 the canonical paste-from-multiline-doc footgun — the author \
6054 pasted a multi-line block of author records into one \
6055 `:autores` entry instead of splitting them into one entry per \
6056 author, and the result lands as a multi-line YAML block scalar \
6057 in the rendered Chart.yaml `maintainers:` array)"
6058 .to_string());
6059 }
6060 if b == b'\r' {
6061 return Err("must not contain carriage return (chart maintainer \
6062 names are single-line YAML plain-style scalars; a `\\r` byte \
6063 is the canonical paste-from-Windows-CRLF-doc footgun and \
6064 lands as a literal CR in the rendered Chart.yaml — every YAML \
6065 1.2 parser treats CR as a line terminator equivalent to LF, \
6066 so the embedded CR is silently normalized to a newline at \
6067 every downstream consumer)"
6068 .to_string());
6069 }
6070 if b < 0x20 || b == 0x7F {
6071 return Err(format!(
6072 "must not contain control character 0x{b:02x} (chart \
6073 maintainer names are printable UTF-8 single-line scalars; the \
6074 control-byte arm catches paste-from-binary-blob footguns like \
6075 `0x00` NUL, `0x07` BEL, `0x1b` ESC that would silently land \
6076 in the rendered Chart.yaml as a YAML-illegal byte sequence \
6077 and fail at `helm lint` time far from the source caixa.lisp)"
6078 ));
6079 }
6080 }
6081 if let Some(c) = find_unicode_bidi_override(s) {
6082 return Err(format!(
6083 "must not contain Unicode bidirectional-override codepoint U+{cp:04X} \
6084 (the nine codepoints UAX #9 names as the structural prerequisite of \
6085 the \"Trojan Source\" attack class — CVE-2021-42574 / Boucher & \
6086 Anderson 2021: U+202A `LRE`, U+202B `RLE`, U+202C `PDF`, U+202D `LRO`, \
6087 U+202E `RLO`, U+2066 `LRI`, U+2067 `RLI`, U+2068 `FSI`, U+2069 `PDI` \
6088 — flip the rendered visual order of every following character until a \
6089 matching pop, so an `:autores` entry visible to a human reading \
6090 `caixa.lisp` and the same entry consumed by `helm list` / Artifact \
6091 Hub's maintainer column disagree on the order of the displayed \
6092 content bytes. The byte sequence ({utf8_seq}) rides verbatim into \
6093 the rendered Chart.yaml `maintainers:` array at the same axis the \
6094 per-byte CR/LF/control arms close for ASCII, but renders \
6095 differently across consumers, defeating the THEORY.md §V.2 \
6096 render-determinism contract every typed slot carries. Routed through \
6097 the shared [`find_unicode_bidi_override`] helper so the same \
6098 nine-codepoint accepted set lives in exactly one place across the \
6099 [`is_chart_description_shape`] sibling YAML-plain-style-scalar \
6100 surface, structurally consistent. Drop the bidi-override codepoint; \
6101 pure visual right-to-left maintainer names (Hebrew, Arabic) are \
6102 accepted natively without explicit direction marks)",
6103 cp = c as u32,
6104 utf8_seq = c
6105 .encode_utf8(&mut [0u8; 4])
6106 .bytes()
6107 .map(|b| format!("0x{b:02X}"))
6108 .collect::<Vec<_>>()
6109 .join(" "),
6110 ));
6111 }
6112 if let Some(c) = find_unicode_line_break(s) {
6113 return Err(format!(
6114 "must not contain Unicode line-break codepoint U+{cp:04X} (the three \
6115 codepoints UAX #14 / YAML 1.1 §4.1 name as line terminators outside \
6116 the ASCII `\\n` / `\\r` arms above: U+0085 `NEL` NEXT LINE, U+2028 \
6117 `LS` LINE SEPARATOR, U+2029 `PS` PARAGRAPH SEPARATOR. YAML 1.2 §5.4 \
6118 retired them per UTR #20 so YAML 1.2-strict parsers preserve them \
6119 verbatim, but YAML 1.1 parsers (go-yaml v2 which Helm v3 / kubectl / \
6120 every Kubernetes client library transitively links, `ruamel.yaml` in \
6121 compat mode) still split scalars on them — an `:autores` entry with \
6122 an embedded U+2028 parses as one `maintainers:` array entry through \
6123 a YAML 1.2 parser and as two entries through a YAML 1.1 parser, \
6124 breaking cross-parser determinism on the same axis the per-byte \
6125 `\\n` / `\\r` arms close for ASCII. Independently, every UAX #14 \
6126 conformant text consumer (editors, terminals, `helm list` / \
6127 Artifact Hub's maintainer column) breaks the visual line at these \
6128 codepoints regardless of YAML version, so the author's editor view \
6129 of `caixa.lisp` and the chart-consumer's rendered view of the \
6130 `maintainers:` entry diverge even when both YAML parsers agree on \
6131 the byte-level shape, defeating the THEORY.md §V.2 render-\
6132 determinism contract every typed slot carries. The byte sequence \
6133 ({utf8_seq}) rides verbatim into the rendered Chart.yaml at the \
6134 same axis the per-byte `\\n` / `\\r` arms close for ASCII. Routed \
6135 through the shared [`find_unicode_line_break`] helper so the same \
6136 three-codepoint accepted set lives in exactly one place across the \
6137 [`is_chart_description_shape`] sibling YAML-plain-style-scalar \
6138 surface, peer of the [`find_unicode_bidi_override`] lift on the \
6139 same two predicates one trajectory earlier. Drop the non-ASCII \
6140 line-break codepoint; split the value into separate `:autores` \
6141 list entries at the source — the per-entry shape is single-line by \
6142 contract)",
6143 cp = c as u32,
6144 utf8_seq = c
6145 .encode_utf8(&mut [0u8; 4])
6146 .bytes()
6147 .map(|b| format!("0x{b:02X}"))
6148 .collect::<Vec<_>>()
6149 .join(" "),
6150 ));
6151 }
6152 if let Some(c) = find_unicode_invisible_format(s) {
6153 return Err(format!(
6154 "must not contain Unicode invisible-format codepoint U+{cp:04X} (the \
6155 eight BMP Cf-category zero-width codepoints with no visible glyph: \
6156 U+00AD `SHY` SOFT HYPHEN, U+200B `ZWSP` ZERO WIDTH SPACE, U+2060 \
6157 `WJ` WORD JOINER, U+2061 `FA` FUNCTION APPLICATION, U+2062 `IT` \
6158 INVISIBLE TIMES, U+2063 `IS` INVISIBLE SEPARATOR, U+2064 `IP` \
6159 INVISIBLE PLUS, U+FEFF `ZWNBSP` ZERO WIDTH NO-BREAK SPACE / BOM. \
6160 The maintainer-identity divergence: the author's editor view of \
6161 `caixa.lisp` and the `helm list` / Artifact Hub maintainer column \
6162 agree on the visible glyph sequence (`\"alice\"` and \
6163 `\"alice\\u{{200B}}\"` render identically as `alice`), but the byte \
6164 sequence the YAML-plain-style-scalar carries verbatim differs — \
6165 the Artifact Hub maintainer-index lookup misses the authored \
6166 `\"alice\"` entry because the byte sequence carries an extra \
6167 invisible codepoint, a future per-maintainer CLA-signer lookup \
6168 matches a visually-identical-but-byte-distinct identity (the \
6169 canonical invisible-codepoint homograph footgun), and every \
6170 byte-level diff / grep / equality comparison over the Chart.yaml \
6171 `maintainers:` array disagrees with the visible-glyph match. The \
6172 canonical authoring shapes that silently introduce these \
6173 codepoints: paste-from-Microsoft-Word (SHY auto-inserted at \
6174 every hyphenation candidate), paste-from-text-editor-saved-as-\
6175 UTF-8-with-BOM (BOM leading byte from Notepad / older VS Code \
6176 defaults / Excel CSV export), paste-from-typesetting-doc (ZWSP / \
6177 WJ invisible word-break hints from InDesign / LaTeX-rendered PDF \
6178 copy-paste), and paste-from-MathJax/LaTeX-rendered-formula \
6179 (FUNCTION APPLICATION / INVISIBLE TIMES / INVISIBLE SEPARATOR / \
6180 INVISIBLE PLUS — MathJax / LaTeX2RTF / InDesign math-equation \
6181 export emit one of these between adjacent symbols to preserve \
6182 operator semantics for screen readers, and the codepoint silently \
6183 rides into the YAML scalar with no visible trace). The byte \
6184 sequence ({utf8_seq}) rides verbatim into the rendered \
6185 Chart.yaml, but renders as nothing across consumers, defeating \
6186 the THEORY.md §V.2 render-determinism contract on a third axis \
6187 from the bidi-override (visual-order) and line-break (single-\
6188 line vs multi-line) classes the prior arms close. Routed through \
6189 the shared [`find_unicode_invisible_format`] helper so the \
6190 eight-codepoint accepted set is shared with \
6191 [`is_chart_description_shape`], third lift in the UAX-driven \
6192 render-determinism trio (peer of [`find_unicode_bidi_override`] \
6193 on the visual-order axis and [`find_unicode_line_break`] on the \
6194 single-line/multi-line axis). Drop the invisible codepoint; emoji \
6195 ZWJ sequences (U+200D for the 👨💻 family) and bidi direction-mark \
6196 codepoints (U+200E `LRM` / U+200F `RLM`) are accepted natively \
6197 for mixed-script maintainer names — only the eight zero-semantic-\
6198 content codepoints are rejected)",
6199 cp = c as u32,
6200 utf8_seq = c
6201 .encode_utf8(&mut [0u8; 4])
6202 .bytes()
6203 .map(|b| format!("0x{b:02X}"))
6204 .collect::<Vec<_>>()
6205 .join(" "),
6206 ));
6207 }
6208 Ok(())
6209}
6210
6211/// Maximum byte length of a chart-keyword-shaped string. The 20-byte
6212/// cap matches Cargo's `[package] keywords` rule
6213/// (<https://doc.rust-lang.org/cargo/reference/manifest.html#the-keywords-field>:
6214/// "Each keyword should be ASCII text, start with a letter, and only
6215/// contain letters, numbers, _ or -. Keywords are case-insensitive and
6216/// limited to a maximum length of 20 characters.") — the same parser
6217/// crates.io routes its `keywords:` array entries through at publish
6218/// time. Tighter than every peer length cap on the typed Caixa surface
6219/// ([`CHART_MAINTAINER_NAME_MAX_LEN`] 128 on the sibling chart-metadata
6220/// `Vec<String>` axis, [`CARGO_FEATURE_NAME_MAX_LEN`] 64 on the sibling
6221/// `:caracteristicas` per-entry axis, [`CHART_DESCRIPTION_MAX_LEN`] 512
6222/// on the free-form-prose axis); the search-tag class is the tightest
6223/// short-identifier shape on the typed surface — every realistic
6224/// `:etiquetas` entry in the wild (`"iac"`, `"aws"`, `"pangea"`,
6225/// `"hello-world"`, `"tatara-lisp"`, `"caixa-servico"`,
6226/// `"infrastructure"`, `"pangea-native"`) sits well under 20 bytes,
6227/// and the 20-byte cap surfaces the "paste-from-doc multi-tag blob
6228/// landed in a single `:etiquetas` entry" footgun (`"web-service web
6229/// app"`, `"mesh,http,grpc"`) at validate time.
6230pub const CHART_KEYWORD_MAX_LEN: usize = 20;
6231
6232/// Predicate: assert that `s` is a valid chart-keyword shape. The
6233/// `:etiquetas` axis is a per-entry registry-search-tag identifier
6234/// that lands in the rendered `lareira-<nome>` Helm chart's
6235/// `Chart.yaml` `keywords:` array via [`caixa-helm`]'s
6236/// `build_chart_yaml` (folded through a [`std::collections::BTreeSet`]
6237/// alongside the four substrate-fixed tags `lareira` / `wasm` /
6238/// `tatara-lisp` / `caixa-servico`) and indexes the chart through
6239/// Artifact Hub's keyword-search axis + the future caixa-registry's
6240/// keyword index. The contract — modeled on Cargo's crates.io
6241/// `[package] keywords` grammar (the parser the crates.io publish API
6242/// routes every `keywords:` entry through at publish time), narrowed
6243/// to the strict ASCII subset every realistic search tag uses:
6244///
6245/// - 1..=[`CHART_KEYWORD_MAX_LEN`] (20) bytes;
6246/// - first byte: ASCII letter (`A-Z` or `a-z`). Leading digit, `-`,
6247/// `_`, whitespace, control, and non-ASCII are each surfaced with
6248/// a self-locating reason naming the canonical authoring footgun
6249/// (paste-from-numbered-list `"1foo"`, kebab-leak `"-foo"`,
6250/// snake-leak `"_foo"`, paste-from-aligned-doc whitespace,
6251/// paste-from-Unicode-doc non-ASCII);
6252/// - remaining bytes: ASCII alphanumeric, `_`, or `-` (Cargo's
6253/// crates.io-accepted continuation set; tighter than
6254/// [`is_cargo_feature_name`]'s `_`/`-`/`+`/`.` continuation set —
6255/// `+` and `.` are not part of the keyword grammar). Whitespace,
6256/// `,` / `/` / `;` / `.` list-separator confusions, control bytes,
6257/// and non-ASCII bytes are each surfaced with a self-locating
6258/// reason naming the canonical authoring footgun (multi-tag blob
6259/// in one entry, CSV-list-belongs-to-list-grammar miscomprehension,
6260/// CR/LF paste-from-doc, NFC/NFD normalization drift).
6261///
6262/// Returns the parser-shaped reason on rejection (without wrapping in
6263/// any error variant) so each per-axis caller —
6264/// [`crate::Caixa::validate_etiquetas`] for the universal `:etiquetas`
6265/// axis at validate time, every future per-keyword axis (a future
6266/// caixa-registry keyword-index lookup, a future Artifact Hub-keyword
6267/// scraper validator, a future per-Aplicacao aggregated keyword set)
6268/// — wraps the same reason in its own typed `*Invalid { <axis>, reason }`
6269/// variant.
6270///
6271/// Empty input is rejected here (defensively) and at each call site
6272/// via the narrower [`crate::ManifestError::EtiquetaEmpty`] variant —
6273/// the same empty-first cascade [`is_dns_1123_label`],
6274/// [`is_gateway_api_http_path`], [`is_wit_world_ref`],
6275/// [`is_nats_subject`], [`is_wasi_keyvalue_slot`], [`is_git_ref_name`],
6276/// [`is_git_oid`], [`is_git_repo_url`], [`is_cargo_feature_name`],
6277/// [`is_spdx_expression_shape`], [`is_chart_description_shape`], and
6278/// [`is_chart_maintainer_name_shape`] all carry at their call sites.
6279///
6280/// # Errors
6281///
6282/// Returns the parser-shaped reason naming the specific violation
6283/// (length / first-byte-class / continuation-byte-class / whitespace /
6284/// control-char / non-ASCII / `,`-list-separator-confusion /
6285/// `/`-path-separator-confusion / `;`-list-separator-confusion /
6286/// `.`-namespace-confusion), without wrapping in any error variant —
6287/// every caller maps the same `String` into its own typed
6288/// `*Invalid { <axis>, reason }` enum variant.
6289pub fn is_chart_keyword_shape(s: &str) -> Result<(), String> {
6290 if s.is_empty() {
6291 return Err("must not be empty".to_string());
6292 }
6293 if s.len() > CHART_KEYWORD_MAX_LEN {
6294 return Err(format!(
6295 "exceeds chart keyword max length of {CHART_KEYWORD_MAX_LEN} bytes (got \
6296 {} bytes; legitimate `:etiquetas` search tags rarely exceed ~12 bytes — \
6297 this length suggests a paste-from-doc multi-tag blob landed in a single \
6298 `:etiquetas` entry instead of being split into one entry per tag, e.g. \
6299 `(\"mesh\" \"http\" \"grpc\")` not `(\"mesh-http-grpc-rpc-wasm\")`. \
6300 Cargo's crates.io publish API enforces the same 20-byte cap on its \
6301 `keywords:` array at publish time)",
6302 s.len()
6303 ));
6304 }
6305 let bytes = s.as_bytes();
6306 let first = bytes[0];
6307 if !first.is_ascii_alphabetic() {
6308 let msg = if first == b' ' || first == b'\t' {
6309 "must not start with whitespace (chart keywords are single-token \
6310 search-tag identifiers; the leading-whitespace arm is the canonical \
6311 paste-from-aligned-doc footgun and round-trips inconsistently — every \
6312 YAML 1.2 dumper trims leading whitespace from plain-style scalars, so \
6313 the authored space silently drops in the rendered Chart.yaml \
6314 `keywords:` array)"
6315 .to_string()
6316 } else if first == b'-' {
6317 "must not start with `-` (Cargo's crates.io keyword grammar rejects a \
6318 leading hyphen — `-` is a legitimate continuation character between \
6319 alphanumeric segments but the canonical CLI-argument-injection / \
6320 kebab-leak footgun at the start; drop the leading `-`, e.g. \
6321 `\"tatara-lisp\"` not `\"-tatara-lisp\"`)"
6322 .to_string()
6323 } else if first == b'_' {
6324 "must not start with `_` (Cargo's crates.io keyword grammar requires the \
6325 first character be an ASCII letter — `_` is a legitimate continuation \
6326 character between alphanumeric segments but the canonical \
6327 snake-leak / hidden-identifier footgun at the start; drop the leading \
6328 `_`, e.g. `\"caixa-servico\"` not `\"_caixa_servico\"`)"
6329 .to_string()
6330 } else if first.is_ascii_digit() {
6331 format!(
6332 "must not start with digit {ch:?} (Cargo's crates.io keyword grammar \
6333 requires the first character be an ASCII letter — a digit at the \
6334 start is the canonical paste-from-numbered-list footgun, e.g. the \
6335 author copied `1. mesh` from a numbered doc and the `1` leaked \
6336 into the tag; drop the leading digit, e.g. `\"v2\"` not `\"2v\"`)",
6337 ch = first as char
6338 )
6339 } else if first < 0x20 || first == 0x7F {
6340 format!(
6341 "must not start with control character 0x{first:02x} (Cargo's \
6342 crates.io keyword grammar rejects ASCII control characters; the \
6343 CR/LF arm is the canonical paste-from-multiline-doc footgun)"
6344 )
6345 } else if first >= 0x80 {
6346 format!(
6347 "must not start with non-ASCII byte 0x{first:02x} (Cargo's \
6348 crates.io keyword grammar is strict ASCII; the non-ASCII arm \
6349 catches the canonical paste-from-Unicode-doc footgun — every \
6350 legitimate search tag is a kebab-case ASCII identifier like \
6351 `\"mesh\"`, `\"wasm\"`, `\"tatara-lisp\"`. Raw non-ASCII silently \
6352 round-trips inconsistently across NFC/NFD normalization on APFS / \
6353 case-folding filesystems and breaks the Artifact Hub keyword \
6354 search index lookup)"
6355 )
6356 } else {
6357 format!(
6358 "must start with an ASCII letter, got {ch:?} (Cargo's crates.io \
6359 keyword grammar rejects every non-letter first character — the \
6360 canonical search tags are kebab-case ASCII identifiers starting \
6361 with a letter, like `\"mesh\"`, `\"wasm\"`, `\"hello-world\"`)",
6362 ch = first as char
6363 )
6364 };
6365 return Err(msg);
6366 }
6367 for &b in &bytes[1..] {
6368 let valid = b.is_ascii_alphanumeric() || b == b'_' || b == b'-';
6369 if !valid {
6370 let msg = if b == b' ' || b == b'\t' {
6371 format!(
6372 "must not contain whitespace character {ch:?} (Cargo's \
6373 crates.io keyword grammar rejects whitespace; search tags are \
6374 single-token identifiers — use `-` or `_` to separate \
6375 kebab-case / snake-case segments instead, or split into \
6376 separate `:etiquetas` entries: `(\"web\" \"service\")` not \
6377 `(\"web service\")`)",
6378 ch = b as char
6379 )
6380 } else if b == b',' {
6381 "must not contain `,` (the comma separator belongs to the \
6382 `:etiquetas` list grammar between entries, not to the keyword \
6383 grammar within an entry — split the value into separate list \
6384 entries: `(\"mesh\" \"http\" \"grpc\")` not `(\"mesh,http,grpc\")`. \
6385 The author confused the CSV-style list-separator convention with \
6386 the list grammar)"
6387 .to_string()
6388 } else if b == b'/' {
6389 "must not contain `/` (Cargo's crates.io keyword grammar rejects \
6390 path-style separators within a tag; the segment separator within \
6391 a search tag is `-` or `_`, and multi-segment paths belong as \
6392 separate `:etiquetas` entries: `(\"caixa\" \"servico\")` not \
6393 `(\"caixa/servico\")`)"
6394 .to_string()
6395 } else if b == b';' {
6396 "must not contain `;` (the semicolon separator is not part of the \
6397 `:etiquetas` list grammar — split the value into separate list \
6398 entries: `(\"mesh\" \"http\")` not `(\"mesh;http\")`. The author \
6399 confused another lisp-list-style separator with the list \
6400 grammar)"
6401 .to_string()
6402 } else if b == b'.' {
6403 "must not contain `.` (Cargo's crates.io keyword grammar excludes \
6404 `.` from the continuation set — the canonical \
6405 namespace-confusion / version-suffix footgun, e.g. `\"http.1\"` \
6406 / `\"v1.0\"`; use `-` instead, e.g. `\"http-1\"` / `\"v1-0\"`)"
6407 .to_string()
6408 } else if b == b'\n' {
6409 "must not contain newline (chart keywords are single-line \
6410 single-token identifiers; an embedded newline is the canonical \
6411 paste-from-multiline-doc footgun — the author pasted a multi-tag \
6412 block into one `:etiquetas` entry instead of splitting into one \
6413 entry per tag)"
6414 .to_string()
6415 } else if b == b'\r' {
6416 "must not contain carriage return (chart keywords are single-line \
6417 single-token identifiers; a `\\r` byte is the canonical \
6418 paste-from-Windows-CRLF-doc footgun and lands as a literal CR in \
6419 the rendered Chart.yaml `keywords:` array)"
6420 .to_string()
6421 } else if b < 0x20 || b == 0x7F {
6422 format!(
6423 "must not contain control character 0x{b:02x} (Cargo's \
6424 crates.io keyword grammar rejects ASCII control characters; \
6425 the control-byte arm catches paste-from-binary-blob footguns \
6426 like `0x00` NUL, `0x07` BEL, `0x1b` ESC, `0x7f` DEL that \
6427 would silently land in the rendered Chart.yaml \
6428 `keywords:` array as a YAML-illegal byte sequence)"
6429 )
6430 } else if b >= 0x80 {
6431 format!(
6432 "must not contain non-ASCII byte 0x{b:02x} (Cargo's crates.io \
6433 keyword grammar is strict ASCII; the non-ASCII arm catches \
6434 the canonical paste-from-Unicode-doc footgun — raw non-ASCII \
6435 silently round-trips inconsistently across NFC/NFD \
6436 normalization on APFS / case-folding filesystems and breaks \
6437 the Artifact Hub keyword search index lookup)"
6438 )
6439 } else {
6440 format!(
6441 "contains invalid character {ch:?} (Cargo's crates.io keyword \
6442 grammar allows only `[A-Za-z0-9_-]` after the first \
6443 character)",
6444 ch = b as char
6445 )
6446 };
6447 return Err(msg);
6448 }
6449 }
6450 Ok(())
6451}
6452
6453/// Tagged reason a caixa-author-supplied path can fail the
6454/// sandboxed-relative shape gate every callback / script path must
6455/// pass for the layout checker's `root.join(p)` to stay inside the
6456/// caixa root.
6457///
6458/// Returned by [`is_sandboxed_relative_path`] so each per-axis caller
6459/// — [`crate::BehaviorSpec::validate`] on `:behavior :on-*` paths
6460/// (b0c8389), [`crate::UpgradeInstruction::validate`]'s `StateChange`
6461/// arm on `:upgrade-from :state-change :script` (26da2c7), every
6462/// future axis admitting a user-supplied path — match-and-wraps the
6463/// tag into its own typed `*Invalid { slot, path }` enum variant so
6464/// the diagnostic still names *which slot* carried the malformed
6465/// value. The tag is axis-agnostic; the wrapping per-axis variant
6466/// carries the slot identity.
6467///
6468/// Sibling discriminator-style of the per-arm reason substrings every
6469/// value-shape predicate already exposes (`is_dns_1123_label`,
6470/// `is_gateway_api_http_path`, …) — but typed rather than string-
6471/// shaped, because the per-axis variants for path violations were
6472/// already split three ways (`EmptyPath` / `AbsolutePath` /
6473/// `ParentEscape` in `BehaviorError`; `EmptyScript` / `AbsoluteScript`
6474/// / `ParentEscapeScript` in `UpgradeError`), so collapsing them to a
6475/// single `*PathInvalid { reason }` variant would *regress* the
6476/// diagnostic shape rather than preserve it.
6477#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
6478pub enum PathShapeViolation {
6479 /// The path string is empty — `PathBuf::new()` or the
6480 /// canonical "I declared the slot but left the value blank"
6481 /// authoring footgun. `root.join(PathBuf::new())` resolves to
6482 /// `root` itself, silently pointing the runtime's `LisleLoader`
6483 /// at the project root rather than a file.
6484 Empty,
6485 /// The path is absolute — `Path::join` *replaces* the base
6486 /// with an absolute right-hand side, so `root.join("/etc/passwd")`
6487 /// resolves to `"/etc/passwd"` and escapes the project sandbox
6488 /// entirely. The Lunatic-style sandbox discipline
6489 /// ([`theory/INSPIRATIONS.md` §III.1][i31]) requires every
6490 /// author-supplied path to live under the caixa root.
6491 ///
6492 /// [i31]: https://github.com/pleme-io/theory/blob/main/INSPIRATIONS.md
6493 Absolute,
6494 /// The path contains a [`Component::ParentDir`] component anywhere
6495 /// — `root.join("../sibling/x")` traverses above the caixa root,
6496 /// the same sandbox-escape vector via parent-directory traversal.
6497 /// Caught regardless of where the `..` component sits (leading,
6498 /// mid-path, trailing) so a future relaxation that only checks
6499 /// one position surfaces at this one predicate.
6500 ParentEscape,
6501}
6502
6503impl PathShapeViolation {
6504 /// Exhaustive iteration surface for every consumer that walks the
6505 /// closed three-arm [`PathShapeViolation`] discriminator set — the
6506 /// paired byte-parity pin on the [`gen_platform::IsVariant`]-derived
6507 /// per-arm `is_*` predicate family, a future `feira lint
6508 /// --explain-path-shape=<axis>` per-arm listing of the accepted
6509 /// violation kinds, a future `mesh.pleme.io/v1alpha1/Caixa` CR
6510 /// materializer's per-path admission-webhook rejection body naming
6511 /// the accepted-violation-tag set, any future property-test harness
6512 /// that sweeps every arm to compute per-arm diagnostic coverage.
6513 /// A future variant addition (a `Symlink` arm the future
6514 /// symlink-escape gate would carry once `Path::is_symlink` becomes
6515 /// part of the sandbox contract, a `TrailingSpace` arm a future
6516 /// authoring-side whitespace-hygiene gate would raise for
6517 /// `"lib/init.lisp "` shapes) extends this slice as one edit and
6518 /// every consumer picks up the new entry by construction; the
6519 /// compiler-checked exhaustiveness on the sibling `match` arms in
6520 /// [`is_sandboxed_relative_path`] and [`require_sandboxed_lisp_path`]
6521 /// is the build-time guarantee that no arm forgets to grow.
6522 ///
6523 /// Peer of the sibling closed-set fieldless typed enums'
6524 /// [`crate::CaixaKind::ALL`] (6b1f4fb) /
6525 /// [`crate::CaixaDialeto::ALL`] (dd4f541) /
6526 /// [`crate::aplicacao::PlacementStrategy::ALL`] (18c7342) /
6527 /// [`crate::aplicacao::RateLimitUnit::ALL`] (6bce03d) /
6528 /// [`crate::dep::DepList::ALL`] (45ee563) /
6529 /// [`crate::supervisor::RestartStrategy::ALL`] (4eec29c) /
6530 /// [`crate::supervisor::RestartPolicy::ALL`] (dd32ccf)
6531 /// exhaustive-iteration surfaces — the tenth closed-set typed
6532 /// enum on the caixa surface to converge onto the same
6533 /// one-canonical-arm-list-per-enum discipline, and the first
6534 /// render-side path-shape-diagnostic axis (as distinct from an
6535 /// OTP-shape M2 slot or an M3 mesh slot) to reach it. Order matches
6536 /// variant declaration order verbatim (`Empty` → `Absolute` →
6537 /// `ParentEscape`) so the slice is the canonical ordering every
6538 /// exhaustive dispatch site (the `Empty → Absolute → ParentEscape`
6539 /// arm-ordering [`is_sandboxed_relative_path`] and every per-axis
6540 /// caller in [`crate::manifest::ManifestError`] preserve for
6541 /// diagnostic-precedence continuity) defers to.
6542 pub const ALL: &'static [Self] = &[Self::Empty, Self::Absolute, Self::ParentEscape];
6543}
6544
6545/// Predicate: assert that `path` is a *sandboxed-relative* path —
6546/// the shape every caixa-author-supplied callback / script path must
6547/// take so the layout checker's `root.join(p)` resolves inside the
6548/// caixa root sandbox. The contract:
6549///
6550/// - non-empty (`PathBuf::new()` → `Empty`);
6551/// - relative (absolute paths replace the base under
6552/// [`Path::join`] semantics → `Absolute`);
6553/// - no [`Component::ParentDir`] components anywhere (traversal
6554/// above the caixa root → `ParentEscape`).
6555///
6556/// Returns [`PathShapeViolation`] tagging the specific failure;
6557/// each per-axis caller match-and-wraps the variant in its own
6558/// typed `*Invalid { slot, path }` enum variant so the diagnostic
6559/// still names *which slot* carried the malformed value. The
6560/// arm-ordering is the same `Empty → Absolute → ParentEscape`
6561/// every prior inlined copy followed (b0c8389 [`crate::BehaviorSpec`],
6562/// 26da2c7 [`crate::UpgradeInstruction::StateChange`]), so any
6563/// caller migrating to the lifted predicate preserves its existing
6564/// per-slot diagnostic precedence by construction.
6565///
6566/// Lifted from `caixa-core::behavior` and `caixa-core::upgrade`
6567/// where the same three-step gate was inlined verbatim across two
6568/// call sites — the PRIME DIRECTIVE duplication-budget rule
6569/// (THEORY.md §I.3.5: "every recurring shape becomes a generator
6570/// before it becomes a pattern; every pattern becomes a library
6571/// before it becomes duplicated code. The duplication budget is
6572/// zero.") promotes the gate to a typed substrate-side predicate
6573/// on the same trajectory the M2-overlay and label-selector helpers
6574/// (9e3a057, 9d09cfb, 9dbeafd, 31455a7, 07a4544, 8b4db42) already
6575/// follow. The third caller — the future M3/M4 axis admitting a
6576/// user-supplied path (the future `:entrada :tls-cert` /
6577/// `:entrada :tls-key` PEM-file axes, the future
6578/// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's per-path
6579/// validator, the future per-Servico pre-warm script axis) — lands
6580/// as a thin five-line wrapper rather than re-inlining the same
6581/// three checks.
6582///
6583/// Pairs with the per-axis empty / absolute / parent-escape variants
6584/// on [`crate::BehaviorError`] and [`crate::UpgradeError`] — those
6585/// remain the typed surface authors see; this predicate is the
6586/// single-source-of-truth gate the caixa-build pipeline consults to
6587/// produce them.
6588///
6589/// # Errors
6590///
6591/// Returns the [`PathShapeViolation`] tag identifying the specific
6592/// violation ([`PathShapeViolation::Empty`] / [`PathShapeViolation::Absolute`]
6593/// / [`PathShapeViolation::ParentEscape`]) so each per-axis caller
6594/// match-and-wraps it into its own typed `*Path` / `*Script` enum
6595/// variant (preserving the per-slot diagnostic granularity the inline
6596/// pre-lift gates already produced).
6597pub fn is_sandboxed_relative_path(path: &Path) -> Result<(), PathShapeViolation> {
6598 if path.as_os_str().is_empty() {
6599 return Err(PathShapeViolation::Empty);
6600 }
6601 if path.is_absolute() {
6602 return Err(PathShapeViolation::Absolute);
6603 }
6604 if path.components().any(|c| matches!(c, Component::ParentDir)) {
6605 return Err(PathShapeViolation::ParentEscape);
6606 }
6607 Ok(())
6608}
6609
6610/// The canonical tatara-lisp source-file extension every M2 typed
6611/// path-slot the M2.5 wasm-engine instantiator reads through
6612/// `tatara_lisp::read` at instance-start time must terminate in.
6613///
6614/// Strict lowercase: the byte-size / duration codecs and every other
6615/// shape-gate predicate in this module are case-sensitive on unit /
6616/// scheme / label boundaries, so a strict `lisp` shape matches the
6617/// downstream accepted set without case-folding drift (an uppercase
6618/// `.LISP` / `.Lisp` shape that a case-insensitive volume's existence
6619/// check would match the on-disk file would still mismatch the
6620/// canonical form the codec emits, breaking the THEORY.md §V.2.7
6621/// render-determinism contract every typed slot carries).
6622pub const LISP_SOURCE_EXTENSION: &str = "lisp";
6623
6624/// Predicate: assert that `path` terminates in the canonical
6625/// [`LISP_SOURCE_EXTENSION`] (lowercase `.lisp`) — the file-type
6626/// shape every M2 typed path-slot the wasm-engine instantiator reads
6627/// as tatara-lisp source must take. The contract:
6628///
6629/// - the path has an extension component (no-extension paths like
6630/// `"lib/init"` or `"a"` fail);
6631/// - the extension's UTF-8 string form is exactly `"lisp"` —
6632/// lowercase, no trailing residue, no double-extension shadow
6633/// like `".lisp.bak"`.
6634///
6635/// Returns `true` on accept, `false` on reject. Each per-axis caller
6636/// — [`crate::BehaviorSpec::validate`] on `:behavior :on-*` paths
6637/// (c97815a), [`crate::UpgradeInstruction::StateChange::validate`]
6638/// on `:upgrade-from :state-change :script` (this commit), every
6639/// future axis admitting a tatara-lisp source path — wraps the
6640/// boolean into its own typed `*NonLispExtension { slot, path }` /
6641/// `*NonLispExtensionScript { script }` enum variant so the
6642/// diagnostic still names *which slot* carried the non-`.lisp`
6643/// value. The predicate is axis-agnostic; the wrapping per-axis
6644/// variant carries the slot identity.
6645///
6646/// Lifted from `caixa-core::behavior` where the same single-line
6647/// gate (`path.extension().and_then(|ext| ext.to_str()) ==
6648/// Some("lisp")`) was inlined verbatim across the first call site
6649/// (`BehaviorSpec::validate_callback_path`) — the PRIME DIRECTIVE
6650/// duplication-budget rule (THEORY.md §I.3.5: "every recurring shape
6651/// becomes a generator before it becomes a pattern; every pattern
6652/// becomes a library before it becomes duplicated code. The
6653/// duplication budget is zero.") promotes the gate to a typed
6654/// substrate-side predicate on the same trajectory the path-shape
6655/// gate [`is_sandboxed_relative_path`] already follows (lifted from
6656/// the same two call sites once the second consumer appeared). The
6657/// third caller — the future `:bibliotecas` per-entry tatara-lisp
6658/// source-file axis (the `feira build` loop reads each through the
6659/// same `tatara_lisp::read` reader at parse time), the future `:exe`
6660/// `:kind Binario` entry-point axis (the nix-built binary's entry
6661/// point loads as Lisp source), the future M2.5 wasm-engine
6662/// pre-warm hook axis — lands as a thin two-line wrapper rather
6663/// than re-inlining the same extension check.
6664///
6665/// Pairs with the per-axis `*NonLispExtension` / `*NonLispExtensionScript`
6666/// variants on [`crate::BehaviorError`] and [`crate::UpgradeError`]
6667/// — those remain the typed surface authors see; this predicate is
6668/// the single-source-of-truth gate the caixa-build pipeline consults
6669/// to produce them.
6670#[must_use]
6671pub fn is_lisp_extension(path: &Path) -> bool {
6672 path.extension().and_then(|ext| ext.to_str()) == Some(LISP_SOURCE_EXTENSION)
6673}
6674
6675/// The canonical compound suffix every `:servicos` entry — the
6676/// ComputeUnit-CR axis the M2 typed-substrate caixa-helm /
6677/// caixa-flux renderers consume via `serde_yaml::from_str` — must
6678/// terminate in. Two-segment shape (`.computeunit.yaml`) rather than
6679/// a single `.yaml` extension: the `.computeunit` segment routes
6680/// authoring-time to the typed `ComputeUnit` CR shape the
6681/// `pleme-computeunit` library chart resolves, distinguishing the
6682/// slot's accepted set from the open `.yaml` universe (Helm
6683/// `values.yaml`, FluxCD `Kustomization.yaml`, the generic K8s
6684/// manifest YAML every operator emits) — same axis-discipline the
6685/// peer [`LISP_SOURCE_EXTENSION`] sibling carries on the tatara-lisp-
6686/// source axis but with a compound suffix because
6687/// [`Path::extension`] only returns the post-last-`.` segment
6688/// (`"yaml"` for `foo.computeunit.yaml`), so the predicate routes
6689/// through [`Path::file_name`] and a string `ends_with` check on the
6690/// full suffix instead.
6691///
6692/// Strict lowercase: every other shape-gate predicate in this module
6693/// is case-sensitive on unit / scheme / label boundaries, so a strict
6694/// `.computeunit.yaml` shape matches the downstream accepted set
6695/// without case-folding drift (an uppercase `.COMPUTEUNIT.YAML` shape
6696/// that a case-insensitive volume's existence check would match the
6697/// on-disk file would still mismatch the canonical form every in-tree
6698/// `:servicos` fixture and the `Caixa::template` scaffold emit,
6699/// breaking the THEORY.md §V.2.7 render-determinism contract every
6700/// typed slot carries).
6701pub const COMPUTEUNIT_YAML_SUFFIX: &str = ".computeunit.yaml";
6702
6703/// Predicate: assert that `path` terminates in the canonical
6704/// [`COMPUTEUNIT_YAML_SUFFIX`] (lowercase `.computeunit.yaml`) — the
6705/// file-type shape every `:servicos` entry, the ComputeUnit-CR axis
6706/// the M2 typed-substrate caixa-helm / caixa-flux renderers consume
6707/// via `serde_yaml::from_str`, must take. The contract:
6708///
6709/// - the path has a final file-name component (paths ending in `/`
6710/// fail);
6711/// - the file name's UTF-8 string form ends in
6712/// `.computeunit.yaml` — lowercase, no case-folding;
6713/// - at least one byte precedes the suffix (the degenerate hidden-
6714/// file `.computeunit.yaml` shape — file name exactly equal to
6715/// the suffix — fails: the substrate identifies each ComputeUnit
6716/// by the file-stem segment that precedes `.computeunit.yaml`,
6717/// so an empty stem is structurally an unidentified Servico).
6718///
6719/// Returns `true` on accept, `false` on reject. The per-axis caller
6720/// — [`crate::Caixa::validate_code_paths`] on the `:servicos` axis —
6721/// wraps the boolean into its own typed
6722/// `ManifestError::CodePathNonComputeUnitYamlExtension { slot, path }`
6723/// variant so the diagnostic still names the offending slot and the
6724/// offending path verbatim. Peer of [`is_lisp_extension`] on the
6725/// tatara-lisp-source axis (`:bibliotecas` 64772a9); same axis-
6726/// agnostic predicate discipline, here on the compound-suffix axis
6727/// [`Path::extension`] can't express on its own. The third caller —
6728/// the future M2.5 caixa-operator `:servicos` admission webhook
6729/// keying off the same accepted set, the M4
6730/// `mesh.pleme.io/v1alpha1/ComputeUnit` CR materializer's per-
6731/// `:servicos` shape gate, the future `feira fmt`'s `:servicos`
6732/// canonical-form normalizer — lands as a thin wrapper rather than
6733/// re-inlining the same compound-suffix check.
6734///
6735/// Pairs with the per-axis
6736/// [`crate::ManifestError::CodePathNonComputeUnitYamlExtension`]
6737/// variant — that remains the typed surface authors see; this
6738/// predicate is the single-source-of-truth gate the caixa-build
6739/// pipeline consults to produce it.
6740#[must_use]
6741pub fn is_computeunit_yaml_extension(path: &Path) -> bool {
6742 path.file_name()
6743 .and_then(|n| n.to_str())
6744 .is_some_and(|name| {
6745 name.len() > COMPUTEUNIT_YAML_SUFFIX.len() && name.ends_with(COMPUTEUNIT_YAML_SUFFIX)
6746 })
6747}
6748
6749/// Canonical camelCase YAML key for the `:limits` slot's overlay.
6750pub const M2_KEY_LIMITS: &str = "limits";
6751/// Canonical camelCase YAML key for the `:behavior` slot's overlay.
6752pub const M2_KEY_BEHAVIOR: &str = "behavior";
6753/// Canonical camelCase YAML key for the `:upgrade-from` slot's overlay.
6754pub const M2_KEY_UPGRADE_FROM: &str = "upgradeFrom";
6755
6756/// Canonical JSON/YAML top-level key for [`crate::Caixa`]'s runtime
6757/// `deps` axis — the runtime-closure dependency list every build the
6758/// caixa participates in reaches (peer of the dev-only `:deps-dev`
6759/// list [`CAIXA_KEY_DEPS_DEV`] pins). The Rust field is single-word
6760/// `deps`; the `#[serde(rename_all = "camelCase")]` attribute on
6761/// [`crate::Caixa`] is a no-op on this axis (no `_` to transform), so
6762/// the emitted JSON key equals the source-side field name byte-for-byte
6763/// and equals this constant's value.
6764///
6765/// [`crate::Caixa::to_lisp`] threads the manifest through
6766/// `serde_json::to_value(self) → tatara_lisp::domain::json_to_sexp`, so
6767/// the emitted JSON key is the load-bearing byte-string the round-trip
6768/// consumes on its way back to the kebab-case `:deps` author surface.
6769/// Until this lift landed the byte-string `"deps"` was structurally
6770/// implicit in the [`crate::Caixa::deps`] field name at
6771/// [`crate::Caixa`] with no compile-time link to any downstream
6772/// `.get(<key>)` consumer or drift-detection pin — a future
6773/// [`crate::Caixa`] field rename (`deps` → `dependencies` matching
6774/// Cargo's verbatim `[dependencies]` axis, `deps` → `runtime_deps`
6775/// matching a hypothetical per-runtime-target vocabulary flip) OR an
6776/// added `#[serde(rename = "…")]` explicit attribute override (either
6777/// of which would silently break every [`crate::Caixa::to_lisp`]
6778/// round-trip and the future M4 operator-side manifest ingest that
6779/// reaches for `deps` via `Value::get(...)`) would surface at consumer
6780/// parse time as a silently-absent JSON key defaulting to
6781/// [`Vec::new()`], far from the rename's commit and with no field
6782/// naming the drift.
6783///
6784/// Peer of [`CAIXA_KEY_DEPS_DEV`] on the two-list dep-graph
6785/// serialized-key axis: this const names the runtime-closure dep-list
6786/// wire key, [`CAIXA_KEY_DEPS_DEV`] names the dev-only dep-list wire
6787/// key. Byte-identical to the peer [`DEP_AUTHOR_KEY_DEPS`] author-facing
6788/// kebab-case label modulo the leading `:` — the two consts split on
6789/// the axis every dep-graph slot carries (author-facing kebab-case
6790/// label vs. renderer-side wire key). Same "one canonical byte-string
6791/// per typed axis" discipline every peer [`M2_KEY_*`] /
6792/// [`M3_KEY_PLACEMENT`] / [`SUPERVISOR_KEY_*`] const carries.
6793pub const CAIXA_KEY_DEPS: &str = "deps";
6794
6795/// Canonical camelCase JSON/YAML top-level key for [`crate::Caixa`]'s
6796/// `deps_dev` axis — the dev-only dependency list that the M0 base
6797/// package model already exposes (peer of the runtime `:deps` list, but
6798/// excluded from published lacres and consumer builds). The Rust field
6799/// is `snake_case` `deps_dev`; the `#[serde(rename_all = "camelCase")]`
6800/// attribute on [`crate::Caixa`] maps it to the camelCase JSON key
6801/// `"depsDev"` this constant pins.
6802///
6803/// [`crate::Caixa::to_lisp`] threads the manifest through
6804/// `serde_json::to_value(self) → tatara_lisp::domain::json_to_sexp`, so
6805/// the emitted JSON key is the load-bearing byte-string the round-trip
6806/// consumes on its way back to the kebab-case `:deps-dev` author
6807/// surface. Until this lift landed the byte-string `"depsDev"` was
6808/// structurally implicit in the `#[serde(rename_all = "camelCase")]`
6809/// derive attribute at [`crate::Caixa`] with no compile-time link to any
6810/// downstream `.get(<key>)` consumer or drift-detection pin — a future
6811/// [`crate::Caixa`] field rename (`deps_dev` → `dev_deps` matching
6812/// Cargo's verbatim `dev-dependencies` axis, `deps_dev` → `deps_test`
6813/// matching a hypothetical per-test-target vocabulary flip) OR a
6814/// `#[serde(rename_all = "…")]` attribute flip (any of which would
6815/// silently break every `Caixa::to_lisp` round-trip and the future M4
6816/// operator-side manifest ingest that reaches for `depsDev` via
6817/// `Value::get(...)`) would surface at consumer parse time as a
6818/// silently-absent JSON key defaulting to `Vec::new()`, far from the
6819/// rename's commit and with no field naming the drift.
6820///
6821/// Peer of [`M2_KEY_UPGRADE_FROM`] on the sibling top-level
6822/// [`crate::Caixa`] multi-word camelCase-renamed serialized-key axis —
6823/// both are `snake_case → camelCase` renames the `rename_all` derive
6824/// produces on the M0 [`crate::Caixa`] surface. Alongside
6825/// [`SUPERVISOR_KEY_MAX_RESTARTS`] (`"maxRestarts"`, 40cc4e5) and
6826/// [`SUPERVISOR_KEY_RESTART_WINDOW`] (`"restartWindow"`, 40cc4e5) —
6827/// which pin the two supervisor-tree top-level multi-word keys the
6828/// [`crate::Caixa`] surface flattens up — this const closes the last of
6829/// the four multi-word top-level [`crate::Caixa`] serde-derived JSON
6830/// keys still lacking a lifted `&'static str` peer. Same "one canonical
6831/// byte-string per typed serialized-key axis" discipline every peer
6832/// [`M2_KEY_*`] / [`M3_KEY_PLACEMENT`] / [`SUPERVISOR_KEY_*`] const
6833/// carries.
6834pub const CAIXA_KEY_DEPS_DEV: &str = "depsDev";
6835
6836/// Canonical author-facing kebab-case `(defcaixa … :limits (…))` top-level
6837/// slot label the M2 per-Servico Lunatic sandbox `:limits` slot surfaces
6838/// under. Peer of [`M2_KEY_LIMITS`] on the dual-axis pair every M2
6839/// top-level slot carries: the camelCase [`M2_KEY_*`] const names the
6840/// *renderer-side* overlay-container wire key the serde-derive-emitted
6841/// programs.yaml / values.yaml block carries under (`"limits"`, load-bearing
6842/// per the `#[serde(rename_all = "camelCase")]` attribute on the emit-side
6843/// [`servico_m2_overlay`] shape), the kebab-case [`M2_AUTHOR_KEY_*`] const
6844/// names the *author-facing* label the [`crate::Caixa::declared_servico_slots`]
6845/// tagger threads through as one of the `&'static str` entries in the
6846/// canonical-declaration-order slot list every kind-coherence gate consults
6847/// ([`crate::LayoutError::ServicoSlotsOnNonServico`] joins them into the
6848/// space-separated `slots:` diagnostic naming which of the three M2 slots
6849/// the offending caixa declared on a non-Servico kind).
6850///
6851/// Until this lift landed the three kebab-case labels sat once each in
6852/// [`crate::Caixa::declared_servico_slots`] as three-arm inline
6853/// `":limits"` / `":behavior"` / `":upgrade-from"` byte-strings the tagger
6854/// pushed onto its return `Vec`, plus a handful of test-side probe
6855/// literals asserting the diagnostic's `slots:` field carries the
6856/// expected per-arm value verbatim — with no compile-time link between
6857/// the tagger's arms and the tests' expected values. A future rebrand
6858/// (a hypothetical `:limits` → `:sandbox` matching the Lunatic
6859/// terminology INSPIRATIONS §III.1 documents at the per-process level,
6860/// `:behavior` → `:gen-server` matching Erlang's verbatim
6861/// `gen_server` name, `:upgrade-from` → `:appup` matching Erlang's
6862/// verbatim appup terminology, or a per-consumer disambiguation as the
6863/// `defcaixa` macro stabilizes) would silently desynchronize the
6864/// production [`crate::Caixa::declared_servico_slots`] tagger from the
6865/// tests until a downstream consumer surfaced the drift at build time as
6866/// a matches-arm miss far from the rename's commit. This lift closes
6867/// that gap by routing both halves (production tagger + tests) through
6868/// three peer consts declared adjacent to the renderer-side
6869/// [`M2_KEY_*`] peers, so the "one canonical declaration per arm, next
6870/// to the axis" discipline the peer [`M2_BEHAVIOR_AUTHOR_KEY_ON_*`]
6871/// sub-slot author-label consts (889dc18) established for the M2
6872/// `:behavior` sub-slot's per-callback kebab-case labels extends onto
6873/// the M2 top-level slot axis. Same "one canonical byte-string per
6874/// typed axis" discipline every peer M2 / M3 renderer-wire-key axis
6875/// carries ([`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] /
6876/// [`M2_KEY_UPGRADE_FROM`], [`M2_LIMITS_KEY_MEMORY`] /
6877/// [`M2_LIMITS_KEY_FUEL`] / [`M2_LIMITS_KEY_WALL_CLOCK`] /
6878/// [`M2_LIMITS_KEY_CPU`] (d8b8b4f), [`M2_BEHAVIOR_KEY_ON_INIT`] etc.
6879/// (21fe462), [`M2_UPGRADE_FROM_KEY_FROM`] /
6880/// [`M2_UPGRADE_FROM_KEY_INSTRUCTIONS`] (36ffe65)).
6881pub const M2_AUTHOR_KEY_LIMITS: &str = ":limits";
6882/// Canonical author-facing kebab-case `(defcaixa … :behavior (…))`
6883/// top-level slot label the M2 per-Servico OTP-shaped `:behavior`
6884/// gen_server-callback-set slot surfaces under. Peer of
6885/// [`M2_AUTHOR_KEY_LIMITS`] on the sibling M2 top-level slot dual axis;
6886/// see [`M2_AUTHOR_KEY_LIMITS`] for the full lift rationale.
6887pub const M2_AUTHOR_KEY_BEHAVIOR: &str = ":behavior";
6888/// Canonical author-facing kebab-case `(defcaixa … :upgrade-from (…))`
6889/// top-level slot label the M2 per-Servico OTP-appup `:upgrade-from`
6890/// hot-code-reload table slot surfaces under. Peer of
6891/// [`M2_AUTHOR_KEY_LIMITS`] on the sibling M2 top-level slot dual axis;
6892/// see [`M2_AUTHOR_KEY_LIMITS`] for the full lift rationale.
6893pub const M2_AUTHOR_KEY_UPGRADE_FROM: &str = ":upgrade-from";
6894
6895/// Canonical camelCase YAML sub-key the `:limits :memory` per-Servico
6896/// linear-memory-cap scalar-axis lands under inside the [`M2_KEY_LIMITS`]
6897/// overlay block. Peer of [`M2_KEY_LIMITS`] on the sibling `:limits`
6898/// sub-slot axis: `M2_KEY_LIMITS` names the overlay-container's
6899/// top-level key ("limits"), the four `M2_LIMITS_KEY_*` consts name the
6900/// four typed sub-keys ([`LIMITS_MEMORY_WASM32_MAX_BYTES`]-bounded
6901/// memory cap, [`crate::LIMITS_FUEL_MAX`]-bounded fuel budget,
6902/// [`crate::LIMITS_WALL_CLOCK_MAX`]-bounded wall-clock cap,
6903/// [`crate::LIMITS_CPU_MILLICORES_MAX`]-bounded soft cgroup CPU share)
6904/// that the emit-side [`servico_m2_overlay`] serializes through serde
6905/// (`LimitsSpec` carries `#[serde(rename_all = "camelCase")]`) and every
6906/// substrate-side test-side navigator probes to pin the round-trip
6907/// through the rendered `programs.yaml` per-Servico entry / lareira
6908/// chart `values.yaml` per-`pleme-computeunit` block. The lower-camel
6909/// shape (`"memory"` / `"fuel"` / `"wallClock"` / `"cpu"`) is
6910/// load-bearing: the serde-derive on [`crate::LimitsSpec`] emits under
6911/// the same shape and the drift-detection pin in `limits.rs::tests`
6912/// (`limits_spec_serde_keys_match_lifted_m2_limits_key_consts`)
6913/// serializes a fully-populated [`crate::LimitsSpec`] and asserts each
6914/// canonical `M2_LIMITS_KEY_*` byte-sequence appears in the JSON — so a
6915/// hypothetical future `rename_all = "snake_case"` / `"kebab-case"`
6916/// accident at the derive attribute surfaces as a build-time test
6917/// failure at `limits.rs` rather than as a silent test-side
6918/// `.get(<stale-camelCase-const>)` returning `None` far from the
6919/// derive-attr drift's commit. Same "one canonical byte-string per
6920/// typed axis" discipline every peer M2 / M3 wire-key axis carries
6921/// ([`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] / [`M2_KEY_UPGRADE_FROM`],
6922/// [`M3_PLACEMENT_KEY_ESTRATEGIA`] etc.).
6923pub const M2_LIMITS_KEY_MEMORY: &str = "memory";
6924/// Canonical camelCase YAML sub-key the `:limits :fuel` per-Servico
6925/// wasm-instruction-budget scalar-axis lands under inside the
6926/// [`M2_KEY_LIMITS`] overlay block. Peer of [`M2_LIMITS_KEY_MEMORY`] on
6927/// the sibling `:limits` sub-slot axis.
6928pub const M2_LIMITS_KEY_FUEL: &str = "fuel";
6929/// Canonical camelCase YAML sub-key the `:limits :wall-clock` per-Servico
6930/// wall-clock-cap scalar-axis lands under inside the [`M2_KEY_LIMITS`]
6931/// overlay block. Peer of [`M2_LIMITS_KEY_MEMORY`] on the sibling
6932/// `:limits` sub-slot axis; the camelCase shape (`"wallClock"`, not
6933/// `"wall_clock"`) is load-bearing per the serde-derive attribute on
6934/// [`crate::LimitsSpec`].
6935pub const M2_LIMITS_KEY_WALL_CLOCK: &str = "wallClock";
6936/// Canonical camelCase YAML sub-key the `:limits :cpu` per-Servico
6937/// soft-cgroup-CPU-share millicores scalar-axis lands under inside the
6938/// [`M2_KEY_LIMITS`] overlay block. Peer of [`M2_LIMITS_KEY_MEMORY`] on
6939/// the sibling `:limits` sub-slot axis.
6940pub const M2_LIMITS_KEY_CPU: &str = "cpu";
6941
6942/// Canonical camelCase YAML sub-key the `:behavior :on-init` per-Servico
6943/// OTP-shaped instance-init-callback path scalar-axis lands under inside
6944/// the [`M2_KEY_BEHAVIOR`] overlay block. Peer of [`M2_KEY_BEHAVIOR`] on
6945/// the sibling `:behavior` sub-slot axis: [`M2_KEY_BEHAVIOR`] names the
6946/// overlay-container's top-level key ("behavior"), the six
6947/// `M2_BEHAVIOR_KEY_ON_*` consts name the six typed sub-keys the M2
6948/// [`crate::BehaviorSpec`] struct's OTP-shaped callback fields
6949/// (`on_init` / `on_call` / `on_cast` / `on_info` / `on_state_change` /
6950/// `on_terminate`, analogs of `gen_server:init/1` / `handle_call/3` /
6951/// `handle_cast/2` / `handle_info/2` / `code_change/3` / `terminate/2`
6952/// per `theory/INSPIRATIONS.md` §II.3) serialize as under the
6953/// `#[serde(rename_all = "camelCase")]` derive attribute
6954/// (`"onInit"` / `"onCall"` / `"onCast"` / `"onInfo"` / `"onStateChange"`
6955/// / `"onTerminate"`). Emitted by [`servico_m2_overlay`] as sub-keys of
6956/// the [`M2_KEY_BEHAVIOR`] overlay block and consumed by every
6957/// substrate-side test-side navigator that reaches into the rendered
6958/// `programs.yaml` per-Servico entry / lareira chart `values.yaml`
6959/// per-`pleme-computeunit` block to pin the per-callback round-trip.
6960/// The lower-camel shape is load-bearing: the serde-derive on
6961/// [`crate::BehaviorSpec`] emits under the same shape and the
6962/// drift-detection pin in `behavior.rs::tests`
6963/// (`behavior_spec_serde_keys_match_lifted_m2_behavior_key_consts`)
6964/// serializes a fully-populated [`crate::BehaviorSpec`] and asserts each
6965/// canonical `M2_BEHAVIOR_KEY_ON_*` byte-sequence appears in the JSON —
6966/// so a hypothetical future `rename_all = "snake_case"` / `"kebab-case"`
6967/// accident at the derive attribute or an OTP-lineage per-callback
6968/// rebrand (`:on-init` → `:on-start` matching Akka's per-actor
6969/// preStart naming, `:on-call` → `:on-request` matching a hypothetical
6970/// wasi:http/incoming-handler terminology flip, `:on-state-change` →
6971/// `:on-code-change` matching Erlang's verbatim `code_change/3` name)
6972/// coordinated at the type's derive attribute surfaces as a build-time
6973/// test failure at `behavior.rs` rather than as a silent test-side
6974/// `.get(<stale-camelCase-const>)` returning `None` far from the
6975/// derive-attr drift's commit. Same "one canonical byte-string per typed
6976/// axis" discipline every peer M2 / M3 wire-key axis carries
6977/// ([`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] / [`M2_KEY_UPGRADE_FROM`],
6978/// [`M2_LIMITS_KEY_MEMORY`] / [`M2_LIMITS_KEY_FUEL`] /
6979/// [`M2_LIMITS_KEY_WALL_CLOCK`] / [`M2_LIMITS_KEY_CPU`] (d8b8b4f),
6980/// [`M3_PLACEMENT_KEY_ESTRATEGIA`] etc.).
6981pub const M2_BEHAVIOR_KEY_ON_INIT: &str = "onInit";
6982/// Canonical camelCase YAML sub-key the `:behavior :on-call` per-Servico
6983/// OTP-shaped sync-request-handler path scalar-axis lands under inside
6984/// the [`M2_KEY_BEHAVIOR`] overlay block. Peer of
6985/// [`M2_BEHAVIOR_KEY_ON_INIT`] on the sibling `:behavior` sub-slot axis.
6986pub const M2_BEHAVIOR_KEY_ON_CALL: &str = "onCall";
6987/// Canonical camelCase YAML sub-key the `:behavior :on-cast` per-Servico
6988/// OTP-shaped async-fire-and-forget-handler path scalar-axis lands under
6989/// inside the [`M2_KEY_BEHAVIOR`] overlay block. Peer of
6990/// [`M2_BEHAVIOR_KEY_ON_INIT`] on the sibling `:behavior` sub-slot axis.
6991pub const M2_BEHAVIOR_KEY_ON_CAST: &str = "onCast";
6992/// Canonical camelCase YAML sub-key the `:behavior :on-info` per-Servico
6993/// OTP-shaped out-of-band-message-handler path scalar-axis lands under
6994/// inside the [`M2_KEY_BEHAVIOR`] overlay block. Peer of
6995/// [`M2_BEHAVIOR_KEY_ON_INIT`] on the sibling `:behavior` sub-slot axis.
6996pub const M2_BEHAVIOR_KEY_ON_INFO: &str = "onInfo";
6997/// Canonical camelCase YAML sub-key the `:behavior :on-state-change`
6998/// per-Servico OTP-shaped hot-upgrade state-migration path scalar-axis
6999/// lands under inside the [`M2_KEY_BEHAVIOR`] overlay block. Peer of
7000/// [`M2_BEHAVIOR_KEY_ON_INIT`] on the sibling `:behavior` sub-slot axis;
7001/// the camelCase shape (`"onStateChange"`, not `"on_state_change"`) is
7002/// load-bearing per the serde-derive attribute on
7003/// [`crate::BehaviorSpec`].
7004pub const M2_BEHAVIOR_KEY_ON_STATE_CHANGE: &str = "onStateChange";
7005/// Canonical camelCase YAML sub-key the `:behavior :on-terminate`
7006/// per-Servico OTP-shaped graceful-shutdown-callback path scalar-axis
7007/// lands under inside the [`M2_KEY_BEHAVIOR`] overlay block. Peer of
7008/// [`M2_BEHAVIOR_KEY_ON_INIT`] on the sibling `:behavior` sub-slot axis.
7009pub const M2_BEHAVIOR_KEY_ON_TERMINATE: &str = "onTerminate";
7010
7011/// Canonical author-facing kebab-case `(defcaixa … :behavior (:on-init …))`
7012/// slot label the `:behavior :on-init` per-Servico OTP-shaped instance-init
7013/// callback axis surfaces under. Peer of [`M2_BEHAVIOR_KEY_ON_INIT`] on the
7014/// dual-axis pair every M2 `:behavior` sub-slot carries: the camelCase
7015/// [`M2_BEHAVIOR_KEY_ON_*`] const names the *renderer-side* wire key the
7016/// serde-derive-emitted [`M2_KEY_BEHAVIOR`] overlay carries under
7017/// (`"onInit"` etc, load-bearing per the `#[serde(rename_all = "camelCase")]`
7018/// attribute on [`crate::BehaviorSpec`]), the kebab-case
7019/// [`M2_BEHAVIOR_AUTHOR_KEY_ON_*`] const names the *author-facing* label the
7020/// [`crate::BehaviorSpec::declared_slots`] tagger threads through as the
7021/// `slot: &'static str` field on every [`crate::BehaviorError`] variant
7022/// (`":on-init"` etc, the exact byte-string authors see in the
7023/// per-slot value-shape diagnostic naming which of the six typed callback
7024/// slots the offending path landed on).
7025///
7026/// Until this lift landed the six kebab-case labels sat once each in
7027/// [`crate::BehaviorSpec::declared_slots`] as the six-arm inline
7028/// `":on-init"` / `":on-call"` / `":on-cast"` / `":on-info"` /
7029/// `":on-state-change"` / `":on-terminate"` byte-strings the tagger
7030/// iterated over, plus roughly two dozen test-side probe literals
7031/// asserting the diagnostic's `slot:` field carries the expected
7032/// per-arm value verbatim — with no compile-time link between the
7033/// tagger's arms and the tests' expected values. A future OTP-lineage
7034/// per-callback rebrand (`:on-init` → `:on-start` matching Akka's
7035/// per-actor preStart naming, `:on-call` → `:on-request` matching a
7036/// hypothetical wasi:http/incoming-handler terminology flip,
7037/// `:on-state-change` → `:on-code-change` matching Erlang's verbatim
7038/// `code_change/3` name, `:on-terminate` → `:on-shutdown` matching a
7039/// generic-lifecycle rebrand) or a per-consumer disambiguation (a
7040/// vocabulary shift on the author surface as the `defcaixa` macro
7041/// stabilizes) would silently desynchronize the production
7042/// [`crate::BehaviorSpec::declared_slots`] tagger from the tests until
7043/// a downstream consumer surfaced the drift at build time as a
7044/// matches-arm miss. This lift closes that gap by routing both halves
7045/// (production tagger + tests) through six peer consts declared
7046/// adjacent to the renderer-side [`M2_BEHAVIOR_KEY_ON_*`] peers, so
7047/// the "one canonical declaration per arm, next to the axis" discipline
7048/// the [`WitTarget::HTTP_FIELD_NAME`] / [`WitTarget::PUBSUB_FIELD_NAME`]
7049/// / [`WitTarget::STORE_FIELD_NAME`] payload-arm peer consts (174e96a)
7050/// already established for the [`crate::WitContract::target`]'s per-arm
7051/// diagnostic-scalar axis extends onto the M2 `:behavior` sub-slot
7052/// author-facing-label axis. Same "one canonical byte-string per typed
7053/// axis" discipline every peer M2 / M3 wire-key axis carries
7054/// ([`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] / [`M2_KEY_UPGRADE_FROM`],
7055/// [`M2_LIMITS_KEY_MEMORY`] / [`M2_LIMITS_KEY_FUEL`] /
7056/// [`M2_LIMITS_KEY_WALL_CLOCK`] / [`M2_LIMITS_KEY_CPU`] (d8b8b4f),
7057/// [`M2_BEHAVIOR_KEY_ON_INIT`] / [`M2_BEHAVIOR_KEY_ON_CALL`] /
7058/// [`M2_BEHAVIOR_KEY_ON_CAST`] / [`M2_BEHAVIOR_KEY_ON_INFO`] /
7059/// [`M2_BEHAVIOR_KEY_ON_STATE_CHANGE`] / [`M2_BEHAVIOR_KEY_ON_TERMINATE`]
7060/// (21fe462), [`M2_UPGRADE_FROM_KEY_FROM`] /
7061/// [`M2_UPGRADE_FROM_KEY_INSTRUCTIONS`] (36ffe65),
7062/// [`M3_PLACEMENT_KEY_ESTRATEGIA`] etc.), extended here to close the
7063/// M2 `:behavior` sub-slot's *author-facing-label* axis so the same
7064/// discipline the renderer-side wire-key axis carries applies to the
7065/// author-facing side.
7066pub const M2_BEHAVIOR_AUTHOR_KEY_ON_INIT: &str = ":on-init";
7067/// Canonical author-facing kebab-case `(defcaixa … :behavior (:on-call …))`
7068/// slot label for the `:behavior :on-call` per-Servico OTP-shaped
7069/// synchronous request/response handler axis. Peer of
7070/// [`M2_BEHAVIOR_AUTHOR_KEY_ON_INIT`] on the sibling `:behavior` sub-slot
7071/// author-facing-label axis.
7072pub const M2_BEHAVIOR_AUTHOR_KEY_ON_CALL: &str = ":on-call";
7073/// Canonical author-facing kebab-case `(defcaixa … :behavior (:on-cast …))`
7074/// slot label for the `:behavior :on-cast` per-Servico OTP-shaped
7075/// asynchronous fire-and-forget handler axis. Peer of
7076/// [`M2_BEHAVIOR_AUTHOR_KEY_ON_INIT`] on the sibling `:behavior` sub-slot
7077/// author-facing-label axis.
7078pub const M2_BEHAVIOR_AUTHOR_KEY_ON_CAST: &str = ":on-cast";
7079/// Canonical author-facing kebab-case `(defcaixa … :behavior (:on-info …))`
7080/// slot label for the `:behavior :on-info` per-Servico OTP-shaped
7081/// out-of-band message handler axis. Peer of
7082/// [`M2_BEHAVIOR_AUTHOR_KEY_ON_INIT`] on the sibling `:behavior` sub-slot
7083/// author-facing-label axis.
7084pub const M2_BEHAVIOR_AUTHOR_KEY_ON_INFO: &str = ":on-info";
7085/// Canonical author-facing kebab-case
7086/// `(defcaixa … :behavior (:on-state-change …))` slot label for the
7087/// `:behavior :on-state-change` per-Servico OTP-shaped hot-upgrade
7088/// state-migration axis. Peer of [`M2_BEHAVIOR_AUTHOR_KEY_ON_INIT`] on the
7089/// sibling `:behavior` sub-slot author-facing-label axis; the kebab-case
7090/// shape (`":on-state-change"`, not `":on-statechange"` /
7091/// `":on_state_change"`) is load-bearing per the author-facing
7092/// `(defcaixa …)` macro's canonical form and the exact byte-string the
7093/// per-slot [`crate::BehaviorError`] diagnostic threads through.
7094pub const M2_BEHAVIOR_AUTHOR_KEY_ON_STATE_CHANGE: &str = ":on-state-change";
7095/// Canonical author-facing kebab-case
7096/// `(defcaixa … :behavior (:on-terminate …))` slot label for the
7097/// `:behavior :on-terminate` per-Servico OTP-shaped graceful-shutdown
7098/// callback axis. Peer of [`M2_BEHAVIOR_AUTHOR_KEY_ON_INIT`] on the sibling
7099/// `:behavior` sub-slot author-facing-label axis.
7100pub const M2_BEHAVIOR_AUTHOR_KEY_ON_TERMINATE: &str = ":on-terminate";
7101
7102/// Canonical camelCase YAML sub-key the `:upgrade-from :from` per-entry
7103/// OTP-appup-shaped prior-`:versao` semver-string scalar-axis lands under
7104/// inside each element of the [`M2_KEY_UPGRADE_FROM`] overlay sequence.
7105/// Peer of [`M2_KEY_UPGRADE_FROM`] on the sibling `:upgrade-from` sub-slot
7106/// axis: [`M2_KEY_UPGRADE_FROM`] names the overlay-container's top-level
7107/// key ("upgradeFrom"), the two `M2_UPGRADE_FROM_KEY_*` consts name the
7108/// two typed sub-keys the M2 [`crate::UpgradeFromEntry`] struct's
7109/// OTP-appup-shaped per-entry fields (`from` semver-of-the-prior-`:versao`
7110/// / `instructions` typed [`crate::UpgradeInstruction`] list, analogs of
7111/// the OTP `.appup` file's `{FromVsn, [Instruction, …]}` per-entry tuple
7112/// per `theory/INSPIRATIONS.md` §II.4) serialize as under the
7113/// `#[serde(rename_all = "camelCase")]` derive attribute (`"from"` /
7114/// `"instructions"`). Emitted by [`servico_m2_overlay`] as sub-keys of
7115/// each element of the [`M2_KEY_UPGRADE_FROM`] overlay sequence and
7116/// consumed by every substrate-side test-side navigator that reaches into
7117/// the rendered `programs.yaml` per-Servico entry / lareira chart
7118/// `values.yaml` per-`pleme-computeunit` block to pin the per-entry
7119/// round-trip. The lower-camel shape (`"from"` / `"instructions"`) is
7120/// load-bearing: the serde-derive on [`crate::UpgradeFromEntry`] emits
7121/// under the same shape and the drift-detection pin in
7122/// `upgrade.rs::tests`
7123/// (`upgrade_from_entry_serde_keys_match_lifted_m2_upgrade_from_key_consts`)
7124/// serializes a fully-populated [`crate::UpgradeFromEntry`] and asserts
7125/// each canonical `M2_UPGRADE_FROM_KEY_*` byte-sequence appears in the
7126/// JSON — so a hypothetical future `rename_all = "snake_case"` /
7127/// `"kebab-case"` accident at the derive attribute or an OTP-lineage
7128/// per-entry-key rebrand (`:from` → `:prior-versao` matching a hypothetical
7129/// verbatim-Erlang `FromVsn` collapse, `:instructions` → `:steps` matching
7130/// a hypothetical Akka appup-shape rebrand) coordinated at the type's
7131/// derive attribute surfaces as a build-time test failure at `upgrade.rs`
7132/// rather than as a silent test-side `.get(<stale-camelCase-const>)`
7133/// returning `None` far from the derive-attr drift's commit. Same "one
7134/// canonical byte-string per typed axis" discipline every peer M2 / M3
7135/// wire-key axis carries ([`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] /
7136/// [`M2_KEY_UPGRADE_FROM`], [`M2_LIMITS_KEY_MEMORY`] /
7137/// [`M2_LIMITS_KEY_FUEL`] / [`M2_LIMITS_KEY_WALL_CLOCK`] /
7138/// [`M2_LIMITS_KEY_CPU`] (d8b8b4f), [`M2_BEHAVIOR_KEY_ON_INIT`] /
7139/// [`M2_BEHAVIOR_KEY_ON_CALL`] / [`M2_BEHAVIOR_KEY_ON_CAST`] /
7140/// [`M2_BEHAVIOR_KEY_ON_INFO`] / [`M2_BEHAVIOR_KEY_ON_STATE_CHANGE`] /
7141/// [`M2_BEHAVIOR_KEY_ON_TERMINATE`] (21fe462),
7142/// [`M3_PLACEMENT_KEY_ESTRATEGIA`] etc.). Closes the M2 sub-slot camelCase
7143/// key axis: with this lift the three M2 typed slots (`:limits` /
7144/// `:behavior` / `:upgrade-from`) all have their canonical camelCase
7145/// sub-slot key constants pinned into caixa-core.
7146pub const M2_UPGRADE_FROM_KEY_FROM: &str = "from";
7147/// Canonical camelCase YAML sub-key the `:upgrade-from :instructions`
7148/// per-entry OTP-appup-shaped typed [`crate::UpgradeInstruction`] list
7149/// axis lands under inside each element of the [`M2_KEY_UPGRADE_FROM`]
7150/// overlay sequence. Peer of [`M2_UPGRADE_FROM_KEY_FROM`] on the sibling
7151/// `:upgrade-from` sub-slot axis.
7152pub const M2_UPGRADE_FROM_KEY_INSTRUCTIONS: &str = "instructions";
7153
7154/// Canonical `#[serde(tag = "…")]` discriminator-key byte-sequence the
7155/// M2 `:upgrade-from :instructions` per-entry OTP-appup
7156/// [`crate::UpgradeInstruction`] enum surfaces its variant tag under
7157/// on serde emission — the internally-tagged wire key downstream
7158/// consumers navigate to (`serde_json::to_value(&instr).get("kind")`
7159/// / `serde_yaml::Value::Mapping.get("kind")` / hand-authored `{"kind":
7160/// "load-module", "module": "…"}` JSON) to disambiguate which of the
7161/// five OTP-shaped variants they hold. The `#[serde(tag = "kind",
7162/// rename_all = "kebab-case")]` attribute on
7163/// [`crate::UpgradeInstruction`] emits exactly this byte-sequence as
7164/// the tag-slot key, and this const names the same byte-string one
7165/// altitude above the derive attribute so every downstream consumer
7166/// that reaches for the tag (the reflection-vs-serde round-trip check
7167/// in [`caixa-core/tests/dispatcher_registration.rs`] that probes
7168/// `v.get("kind")` against every variant's expected kebab-case tag,
7169/// the future M4 `mesh.pleme.io/v1alpha1/Caixa` CR materializer's
7170/// upgrade-instruction admission webhook, any wasm-operator dispatch
7171/// step that navigates the serialized instruction blob to route by
7172/// variant) routes through one canonical `&'static str` rather than
7173/// re-inlining the literal.
7174///
7175/// Lifted as a typed `pub const` (rather than an inline literal at
7176/// the `#[serde(tag = "…")]` attribute site + every consumer probe)
7177/// so the tag-key axis has exactly one source of truth — a future
7178/// serde-shape rebrand (`tag = "kind"` → `tag = "type"` matching a
7179/// JSON-Schema `discriminator` convention, `tag = "kind"` → `tag = "op"`
7180/// matching a hypothetical OTP-abbreviation collapse, `tag = "kind"`
7181/// → `tag = "instruction"` matching a hypothetical author-surface
7182/// self-description flip as the `defcaixa` macro stabilizes) lands as
7183/// an edit to exactly one const, and every consumer that reaches for
7184/// the tag picks it up at build time rather than at runtime as a
7185/// silent `.get(<stale-tag-key>)` returning `None` far from the
7186/// derive-attr drift's commit. Same "one canonical byte-string per
7187/// typed axis" discipline every peer M2 sub-slot wire-key axis
7188/// carries ([`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] /
7189/// [`M2_KEY_UPGRADE_FROM`], [`M2_LIMITS_KEY_MEMORY`] etc. (d8b8b4f),
7190/// [`M2_BEHAVIOR_KEY_ON_INIT`] etc. (21fe462),
7191/// [`M2_UPGRADE_FROM_KEY_FROM`] / [`M2_UPGRADE_FROM_KEY_INSTRUCTIONS`]
7192/// (36ffe65)), now extending the lift onto the last remaining
7193/// un-lifted wire-key axis on the M2 `:upgrade-from :instructions`
7194/// typed slot: the internally-tagged variant-discriminator key that
7195/// pairs with the [`M2_UPGRADE_INSTRUCTION_KIND_LOAD_MODULE`] etc.
7196/// (56120ef) per-variant kebab-case *values* the same
7197/// `#[serde(tag = "kind", rename_all = "kebab-case")]` attribute
7198/// emits. With this lift the `:upgrade-from :instructions` axis has
7199/// its dual (`key = "kind"` + five variant-value tags) fully lifted
7200/// into caixa-core.
7201pub const M2_UPGRADE_INSTRUCTION_KEY_KIND: &str = "kind";
7202
7203/// Canonical per-variant data-field JSON key the M2 `:upgrade-from
7204/// :instructions` per-entry OTP-appup
7205/// [`crate::UpgradeInstruction::LoadModule`] / [`crate::UpgradeInstruction::SoftPurge`]
7206/// / [`crate::UpgradeInstruction::Purge`] variants surface their
7207/// module-name payload under on serde emission — the internally-tagged
7208/// per-variant field byte-string every downstream consumer reading the
7209/// module string reaches for
7210/// (`serde_json::to_value(&instr).get("module")` /
7211/// `serde_yaml::Value::Mapping.get("module")` / hand-authored
7212/// `{"kind": "load-module", "module": "hello-rio"}` JSON blobs the
7213/// wasm-operator's upgrade-dispatch step consumes to route the
7214/// per-module load / soft-purge / purge action). The three variants
7215/// carrying a `module: String` field
7216/// ([`crate::UpgradeInstruction::LoadModule`], [`crate::UpgradeInstruction::SoftPurge`],
7217/// [`crate::UpgradeInstruction::Purge`]) all emit this exact
7218/// byte-sequence as the data-field JSON key alongside the
7219/// [`M2_UPGRADE_INSTRUCTION_KEY_KIND`] tag-key on the same instruction
7220/// blob — the `#[serde(tag = "kind", rename_all = "kebab-case")]`
7221/// attribute on [`crate::UpgradeInstruction`] promotes each variant's
7222/// struct-field name to a sibling JSON key at the same nesting level as
7223/// the tag, so a `LoadModule { module: "hello-rio" }` serializes to
7224/// `{"kind": "load-module", "module": "hello-rio"}` — one tag axis, one
7225/// data-field axis, both live on the same JSON object and both must be
7226/// pinned into caixa-core so a future rebrand at either axis surfaces
7227/// as a build-time test failure rather than an apply-time
7228/// `.get(<stale-field-key>)` returning `None` far from the field-name
7229/// drift's commit.
7230///
7231/// Lifted as a typed `pub const` (rather than an inline literal at every
7232/// consumer probe) so the per-variant module-field axis has exactly one
7233/// source of truth — a future struct-field rebrand (`module: String` →
7234/// `component: String` matching a hypothetical WASI component-model
7235/// naming pass, `module: String` → `name: String` matching the
7236/// canonical `KUBE_KEY_NAME` axis, `module: String` → `target: String`
7237/// matching the sibling `:contratos :para` axis) lands as an edit to
7238/// exactly one const, and every consumer that probes the module-field
7239/// key picks it up at build time. Same "one canonical byte-string per
7240/// typed axis" discipline the sibling
7241/// [`M2_UPGRADE_INSTRUCTION_KEY_KIND`] (6a203d7) lift established on
7242/// the peer tag-slot key axis on the same
7243/// [`crate::UpgradeInstruction`] enum: `KEY_KIND` names the tag axis,
7244/// `FIELD_KEY_MODULE` names the module-payload axis, and the two must
7245/// be disjoint by construction (an internally-tagged serialization
7246/// where the tag key collides with a data-field key silently corrupts
7247/// every serialized blob — same failure mode
7248/// `m2_upgrade_instruction_key_kind_const_disjoint_from_variant_data_keys`
7249/// pins on the sibling axis).
7250///
7251/// With this lift and its [`M2_UPGRADE_INSTRUCTION_FIELD_KEY_SCRIPT`]
7252/// peer, the whole `:upgrade-from :instructions` variant-JSON dual is
7253/// lifted into caixa-core: the tag *key*
7254/// ([`M2_UPGRADE_INSTRUCTION_KEY_KIND`]), the five tag *values*
7255/// ([`M2_UPGRADE_INSTRUCTION_KIND_LOAD_MODULE`] etc.), and the two
7256/// data-field *keys* (this const and `SCRIPT`) all sit as
7257/// single-source-of-truth `&'static str`s. Any future serde-shape
7258/// rebrand touching either axis (tag key rename, per-variant field
7259/// rename, `rename_all` regime flip) surfaces at build time.
7260pub const M2_UPGRADE_INSTRUCTION_FIELD_KEY_MODULE: &str = "module";
7261
7262/// Canonical per-variant data-field JSON key the M2 `:upgrade-from
7263/// :instructions` per-entry [`crate::UpgradeInstruction::StateChange`]
7264/// variant surfaces its script-path payload under on serde emission —
7265/// the internally-tagged per-variant field byte-string every downstream
7266/// consumer reading the migration-script path reaches for
7267/// (`serde_json::to_value(&instr).get("script")` /
7268/// `serde_yaml::Value::Mapping.get("script")` / hand-authored
7269/// `{"kind": "state-change", "script": "lib/migrations/v01-to-v02.lisp"}`
7270/// JSON blobs the wasm-operator's upgrade-dispatch step consumes to
7271/// route the per-`gen_server` `code_change/3` migration action). Peer
7272/// of [`M2_UPGRADE_INSTRUCTION_FIELD_KEY_MODULE`] on the sibling
7273/// module-payload axis; see [`M2_UPGRADE_INSTRUCTION_FIELD_KEY_MODULE`]
7274/// for the full lift rationale.
7275///
7276/// The [`crate::UpgradeInstruction::StateChange`] variant is the only
7277/// one carrying a `script: PathBuf` field — the two module-bearing
7278/// variants ([`crate::UpgradeInstruction::LoadModule`],
7279/// [`crate::UpgradeInstruction::SoftPurge`],
7280/// [`crate::UpgradeInstruction::Purge`]) route through the sibling
7281/// [`M2_UPGRADE_INSTRUCTION_FIELD_KEY_MODULE`] const, and
7282/// [`crate::UpgradeInstruction::Restart`] carries no data field at all.
7283/// Same one-const-per-typed-axis discipline as the sibling.
7284pub const M2_UPGRADE_INSTRUCTION_FIELD_KEY_SCRIPT: &str = "script";
7285
7286/// Canonical author-facing kebab-case tag the M2 `:upgrade-from
7287/// :instructions` per-entry OTP-appup [`crate::UpgradeInstruction::LoadModule`]
7288/// variant surfaces under — the `:kind` field the
7289/// [`crate::UpgradeError::ModuleEmpty`] / [`crate::UpgradeError::ModuleInvalid`]
7290/// / [`crate::UpgradeError::DuplicateCleanup`] / [`crate::UpgradeError::PurgeWithoutPriorLoad`]
7291/// diagnostics carry so the author can grep their caixa.lisp for
7292/// `(:load-module …)` and fix it in one edit. The
7293/// [`crate::UpgradeInstruction::lisp_form`] production dispatch and every
7294/// test-side probe that pins a `kind:` / `kinds:` / `other_kinds:` /
7295/// `prior_cleanup_kind:` field routes through this const, so a future
7296/// per-variant kebab-case rebrand (`:load-module` → `:load` matching a
7297/// hypothetical Erlang `code:load_module` collapse, `:load-module` →
7298/// `:reload` matching a hypothetical Elixir/Phoenix hot-reload rebrand,
7299/// or a per-consumer disambiguation as the `defcaixa` macro stabilizes)
7300/// lands at one const-edit per arm and reaches both surfaces
7301/// (production dispatch + tests) by construction. Peer of
7302/// [`M2_UPGRADE_FROM_KEY_FROM`] / [`M2_UPGRADE_FROM_KEY_INSTRUCTIONS`]
7303/// on the sibling `:upgrade-from` sub-slot renderer-wire-key axis
7304/// (36ffe65) — this const family extends the same "one canonical
7305/// byte-string per typed axis" discipline onto the *author-facing*
7306/// per-instruction-variant tag axis one altitude below the
7307/// `:instructions` container. Same "one canonical declaration per arm,
7308/// next to the axis" discipline the peer [`M2_BEHAVIOR_AUTHOR_KEY_ON_INIT`]
7309/// etc. (889dc18) established for the M2 `:behavior` sub-slot's
7310/// per-callback kebab-case labels, [`CONTRATO_AUTHOR_KEY_DE`] /
7311/// [`CONTRATO_AUTHOR_KEY_PARA`] (f50c875) for the M3 `:contratos`
7312/// per-entry endpoint labels, and every top-level [`M2_AUTHOR_KEY_LIMITS`]
7313/// (f49c8b0) / [`M3_AUTHOR_KEY_MEMBROS`] (882f498) /
7314/// [`SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] (be40492) family established.
7315pub const M2_UPGRADE_INSTRUCTION_KIND_LOAD_MODULE: &str = ":load-module";
7316/// Canonical author-facing kebab-case tag the M2 `:upgrade-from
7317/// :instructions` per-entry [`crate::UpgradeInstruction::StateChange`]
7318/// variant surfaces under. Peer of [`M2_UPGRADE_INSTRUCTION_KIND_LOAD_MODULE`]
7319/// on the sibling per-instruction-variant tag axis; see
7320/// [`M2_UPGRADE_INSTRUCTION_KIND_LOAD_MODULE`] for the full lift rationale.
7321pub const M2_UPGRADE_INSTRUCTION_KIND_STATE_CHANGE: &str = ":state-change";
7322/// Canonical author-facing kebab-case tag the M2 `:upgrade-from
7323/// :instructions` per-entry [`crate::UpgradeInstruction::SoftPurge`]
7324/// variant surfaces under. Peer of [`M2_UPGRADE_INSTRUCTION_KIND_LOAD_MODULE`]
7325/// on the sibling per-instruction-variant tag axis; see
7326/// [`M2_UPGRADE_INSTRUCTION_KIND_LOAD_MODULE`] for the full lift rationale.
7327pub const M2_UPGRADE_INSTRUCTION_KIND_SOFT_PURGE: &str = ":soft-purge";
7328/// Canonical author-facing kebab-case tag the M2 `:upgrade-from
7329/// :instructions` per-entry [`crate::UpgradeInstruction::Purge`]
7330/// variant surfaces under. Peer of [`M2_UPGRADE_INSTRUCTION_KIND_LOAD_MODULE`]
7331/// on the sibling per-instruction-variant tag axis; see
7332/// [`M2_UPGRADE_INSTRUCTION_KIND_LOAD_MODULE`] for the full lift rationale.
7333pub const M2_UPGRADE_INSTRUCTION_KIND_PURGE: &str = ":purge";
7334/// Canonical author-facing kebab-case tag the M2 `:upgrade-from
7335/// :instructions` per-entry [`crate::UpgradeInstruction::Restart`]
7336/// variant surfaces under. Peer of [`M2_UPGRADE_INSTRUCTION_KIND_LOAD_MODULE`]
7337/// on the sibling per-instruction-variant tag axis; see
7338/// [`M2_UPGRADE_INSTRUCTION_KIND_LOAD_MODULE`] for the full lift rationale.
7339pub const M2_UPGRADE_INSTRUCTION_KIND_RESTART: &str = ":restart";
7340
7341/// Canonical lowercase JSON/YAML discriminator-key the
7342/// [`crate::dep::DepSource`] enum's `#[serde(tag = "tipo", rename_all
7343/// = "lowercase")]` derive emits as the tag axis at each serialized
7344/// `Dep.fonte` block — the load-bearing byte-string every downstream
7345/// consumer reading a Dep source (the [`caixa_resolver`] per-`:deps`
7346/// git-clone dispatcher, the future `feira lock` / `feira resolve`
7347/// `lacre.lisp` closure writer, every test payload that reaches
7348/// `Value::get(DEP_SOURCE_KEY_TIPO)` to pin the variant discriminator)
7349/// must probe on. Peer of the two variant tag consts
7350/// [`DEP_SOURCE_TIPO_GIT`] and [`DEP_SOURCE_TIPO_PATH`] the sibling
7351/// `rename_all = "lowercase"` axis lifts on the same discriminator
7352/// block: the [`DEP_SOURCE_KEY_TIPO`] const names the outer tag *key*
7353/// (`"tipo":`) the `tag = "tipo"` attribute pins, the two
7354/// `DEP_SOURCE_TIPO_*` consts name the two admitted tag *values*
7355/// (`"git"` / `"path"`) the `rename_all = "lowercase"` attribute pins
7356/// as the discriminator's closed-set arms.
7357///
7358/// Until this lift landed the two load-bearing bytes at both altitudes
7359/// (`"tipo"` at the tag key, `"git"` / `"path"` at the two variant
7360/// tags) sat only as inline literals — at the `#[serde(tag = "tipo",
7361/// rename_all = "lowercase")]` attribute (dep.rs:59) and at one
7362/// round-trip test payload (`git_source_json_round_trip` pinning
7363/// `"tipo":"git"` inline, dep.rs:13563) — with no compile-time link
7364/// between the load-bearing serde-derive attribute and the downstream
7365/// consumers that probe the emit-side discriminator via
7366/// `Value::get(...)`. A future accidental `tag = "type"` /
7367/// `tag = "source_type"` typo at the attribute (English-uniformity
7368/// rebrand as the substrate publishes its typed manifest schema
7369/// outside pleme-io, verbatim-Cargo `"type"` alignment matching a
7370/// hypothetical Zig-store convergence, or per-consumer disambiguation
7371/// as the `defcaixa` macro stabilizes) — or a `rename_all` rebrand
7372/// (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`) — would silently
7373/// break the resolver's `Dep.fonte` dispatch and every downstream
7374/// `lacre.lisp` closure consumer, with the drift surfacing at fetch
7375/// time far from the derive-attr commit as an unknown-variant deserialize
7376/// failure. Pinning the three canonical byte-sequences to `&'static str`
7377/// consts + running the serialize-and-check drift-detection pins on
7378/// both variants closes the drift structurally at caixa-core build time.
7379///
7380/// Same "one canonical byte-string per typed serialized-key axis"
7381/// discipline the peer [`M2_UPGRADE_INSTRUCTION_KIND_LOAD_MODULE`] etc.
7382/// (56120ef), [`M3_PLACEMENT_ESTRATEGIA_SINGLE_NODE`] etc., and
7383/// [`HELM_CHART_TYPE_APPLICATION`] / [`HELM_CHART_TYPE_LIBRARY`]
7384/// (1c5eb9d) closed-set variant-tag lifts carry — extended here to the
7385/// [`crate::dep::DepSource`] `:deps :fonte` typed slot's discriminator
7386/// axis at both altitudes (discriminator key + closed-set variant tags),
7387/// the last `#[serde(tag = ..., rename_all = ...)]` discriminator
7388/// family in caixa-core lacking a lifted peer.
7389pub const DEP_SOURCE_KEY_TIPO: &str = "tipo";
7390/// Canonical lowercase JSON/YAML discriminator-value the
7391/// [`crate::dep::DepSource::Git`] variant surfaces under — the
7392/// `"git"` scalar the `#[serde(tag = "tipo", rename_all =
7393/// "lowercase")]` derive emits at the [`DEP_SOURCE_KEY_TIPO`] axis
7394/// for the Git arm. Peer of [`DEP_SOURCE_TIPO_PATH`] on the sibling
7395/// closed-set variant-tag axis; see [`DEP_SOURCE_KEY_TIPO`] for the
7396/// full lift rationale. The scalar is derived from the Rust variant
7397/// name `Git` by the `rename_all = "lowercase"` derive; ASCII-lowercase
7398/// of `Git` is `git`.
7399pub const DEP_SOURCE_TIPO_GIT: &str = "git";
7400/// Canonical lowercase JSON/YAML discriminator-value the
7401/// [`crate::dep::DepSource::Path`] variant surfaces under — the
7402/// `"path"` scalar the `#[serde(tag = "tipo", rename_all =
7403/// "lowercase")]` derive emits at the [`DEP_SOURCE_KEY_TIPO`] axis
7404/// for the Path arm. Peer of [`DEP_SOURCE_TIPO_GIT`] on the sibling
7405/// closed-set variant-tag axis; see [`DEP_SOURCE_KEY_TIPO`] for the
7406/// full lift rationale.
7407///
7408/// Byte-identical to [`CILIUM_KEY_PATH`], [`FLUX_KUSTOMIZATION_KEY_PATH`],
7409/// and [`GATEWAY_API_KEY_PATH`] today — all four resolve to the same
7410/// four-byte `"path"` literal — but semantically distinct: the three
7411/// `*_KEY_PATH` consts name YAML container/leaf-*key* axes on their
7412/// respective K8s CR schemas (Cilium L7 HTTP-rule filesystem-path
7413/// container, Flux Kustomization git-source-subtree container, Gateway
7414/// API URL-path-match container), while this constant names a
7415/// discriminator *value* on the manifest-side [`crate::dep::DepSource`]
7416/// typed enum's closed-set variant tag axis (Path variant vs Git
7417/// variant). Splitting the four lets each axis's future rebrand land
7418/// independently at its canonical const definition without coupling
7419/// the `:deps :fonte` Path-variant discriminator axis to the three
7420/// K8s-CR key axes (or vice versa) — same
7421/// "byte-identical-but-semantically-distinct" discipline the peer
7422/// [`FLEET_PROGRAMS_KEY_NAME`] / [`KUBE_KEY_NAME`] and
7423/// [`FLEET_PROGRAMS_KEY_VERSAO`] / [`MEMBRO_KEY_VERSAO`] splits
7424/// established on the sibling per-entry key axes.
7425pub const DEP_SOURCE_TIPO_PATH: &str = "path";
7426
7427/// Canonical [`crate::LayoutError::MissingEntry`] `kind: &'static str`
7428/// discriminator scalar the M2 `:behavior` typed slot's per-callback
7429/// on-disk-leaf existence gate surfaces under — the byte-string every
7430/// [`crate::LayoutInvariants::verify`] emission carries when a
7431/// `:behavior :on-init` / `:on-call` / `:on-cast` / `:on-info` /
7432/// `:on-state-change` / `:on-terminate` sub-slot's tatara-lisp source
7433/// path fails to resolve against the caixa root's on-disk layout. Names
7434/// the "M2 :behavior sub-slot leaf-kind" axis one altitude below the
7435/// [`M2_AUTHOR_KEY_BEHAVIOR`] (f49c8b0) parent-slot label: the
7436/// top-level [`M2_AUTHOR_KEY_BEHAVIOR`] const names the M2 slot itself
7437/// on the author surface (`(defcaixa … :behavior (…))`), the six
7438/// [`M2_BEHAVIOR_AUTHOR_KEY_ON_*`] consts (889dc18) name the per-
7439/// callback sub-slot labels the author writes (`(:on-init "lib/init.lisp"
7440/// …)`), and this const names the per-slot-family leaf-kind byte-string
7441/// the layout diagnostic emits when the on-disk `lib/init.lisp` file
7442/// doesn't exist ("MissingEntry { kind: \"behavior-callback\", path:
7443/// /root/lib/init.lisp }").
7444///
7445/// Peer of [`LAYOUT_MISSING_ENTRY_KIND_UPGRADE_SCRIPT`] on the sibling
7446/// M2 `:upgrade-from` typed slot's per-entry leaf-kind axis: the two
7447/// consts split the M2 slot-family's on-disk-leaf categorization axis
7448/// into its two per-slot arms, so the `LayoutError::MissingEntry
7449/// { kind: &'static str, .. }` discriminator's accept-set has one
7450/// canonical declaration per arm rather than two inline byte-strings
7451/// scattered across [`crate::layout`]'s per-slot existence gates.
7452///
7453/// Until this lift landed the byte `"behavior-callback"` sat at two
7454/// sites in [`crate::layout`] — once at the [`crate::LayoutInvariants::verify`]
7455/// per-`:behavior :on-*` sub-slot existence gate's `MissingEntry` emit
7456/// (production, layout.rs:902), once at the
7457/// [`crate::layout::tests::behavior_callback_must_exist`]
7458/// (or peer test) `matches!(…, MissingEntry { kind: "behavior-callback",
7459/// .. })` shape probe (layout.rs:3152) — with no compile-time link
7460/// between the two: a future per-consumer rebrand (a hypothetical
7461/// `"behavior-callback"` → `"m2-behavior-callback"` for altitude-explicit
7462/// scoping as the M3+ layout gates grow their own per-slot leaf-kind
7463/// labels, `"behavior-callback"` → `"gen-server-callback"` matching a
7464/// verbatim-OTP rebrand of the [`M2_AUTHOR_KEY_BEHAVIOR`] slot's
7465/// `gen_server`-lineage identity, or a per-diagnostic disambiguation as
7466/// the `defcaixa` macro stabilizes and per-callback shapes diverge)
7467/// would silently desynchronize the production `MissingEntry` emission
7468/// from the test's `matches!` shape probe until build time surfaced the
7469/// drift as a pattern-arm miss far from the rename's commit. This lift
7470/// closes that gap by routing both halves (production emit + test
7471/// probe) through one peer const declared adjacent to the M2 top-level
7472/// slot-label family, so the "one canonical declaration per arm, next
7473/// to the axis" discipline the peer [`M2_AUTHOR_KEY_LIMITS`] /
7474/// [`M2_AUTHOR_KEY_BEHAVIOR`] / [`M2_AUTHOR_KEY_UPGRADE_FROM`]
7475/// (f49c8b0), [`M2_BEHAVIOR_AUTHOR_KEY_ON_INIT`] etc. (889dc18),
7476/// [`M2_UPGRADE_INSTRUCTION_KIND_LOAD_MODULE`] etc. (56120ef),
7477/// [`M3_AUTHOR_KEY_MEMBROS`] etc. (882f498), and
7478/// [`SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492) top-level +
7479/// sub-slot author-facing-label consts established for the sibling
7480/// M2 / M3 / Supervisor slot-family axes extends onto the M2
7481/// layout-check leaf-kind categorization axis.
7482///
7483/// Byte-shape note: unlike the peer author-facing kebab-case slot
7484/// labels (which carry the leading `:` sigil because the tatara-lisp
7485/// reader emits keyword tokens as `:kebab-case` and the author writes
7486/// them verbatim in `caixa.lisp`), this discriminator has no leading
7487/// `:` because the substrate consumer reading the value is the layout
7488/// diagnostic's downstream printer — the operator running `feira build`
7489/// sees `LayoutError::MissingEntry { kind: "behavior-callback", .. }`
7490/// as a categorization label, not as a tatara-lisp keyword to be
7491/// grep'd for in the source `.lisp`. Same shape distinction the peer
7492/// [`crate::WitTarget::HTTP_FIELD_NAME`] (= `"endpoint"`) /
7493/// [`crate::WitTarget::PUBSUB_FIELD_NAME`] (= `"subject"`) /
7494/// [`crate::WitTarget::STORE_FIELD_NAME`] (= `"slot"`) /
7495/// [`crate::WitTarget::CAPABILITY_EXPECTED`] (= `"none"`) consts
7496/// established on the sibling `:contratos` per-entry payload-field-
7497/// name axis: the field-name byte-strings are the downstream
7498/// diagnostic's format-argument scalars, prefixed by the `:` inside
7499/// the error format template (`":{expected}"`) rather than baked into
7500/// the const.
7501pub const LAYOUT_MISSING_ENTRY_KIND_BEHAVIOR_CALLBACK: &str = "behavior-callback";
7502
7503/// Canonical [`crate::LayoutError::MissingEntry`] `kind: &'static str`
7504/// discriminator scalar the M2 `:upgrade-from` typed slot's per-entry
7505/// [`crate::UpgradeInstruction::StateChange`] script-path on-disk-leaf
7506/// existence gate surfaces under — the byte-string every
7507/// [`crate::LayoutInvariants::verify`] emission carries when a
7508/// `(:state-change "<script>.lisp")` instruction's tatara-lisp source
7509/// path fails to resolve against the caixa root's on-disk layout.
7510/// Peer of [`LAYOUT_MISSING_ENTRY_KIND_BEHAVIOR_CALLBACK`] on the sibling
7511/// M2 `:behavior` typed slot's per-callback leaf-kind axis; see
7512/// [`LAYOUT_MISSING_ENTRY_KIND_BEHAVIOR_CALLBACK`] for the full lift
7513/// rationale.
7514pub const LAYOUT_MISSING_ENTRY_KIND_UPGRADE_SCRIPT: &str = "upgrade-script";
7515
7516/// Canonical [`crate::LayoutError::MissingEntry`] `kind: &'static str`
7517/// discriminator scalar the M0 `:kind Biblioteca` typed slot's
7518/// per-`:bibliotecas` entry on-disk-leaf existence gate surfaces under
7519/// — the byte-string every [`crate::LayoutInvariants::verify`]
7520/// emission carries when a `:bibliotecas ("lib/foo.lisp" …)` entry's
7521/// tatara-lisp source path fails to resolve against the caixa root's
7522/// on-disk layout. Peer of [`LAYOUT_MISSING_ENTRY_KIND_EXE`] /
7523/// [`LAYOUT_MISSING_ENTRY_KIND_SERVICO`] on the sibling M0 code-slot
7524/// per-directory leaf-kind axes, and of the M2-tier
7525/// [`LAYOUT_MISSING_ENTRY_KIND_BEHAVIOR_CALLBACK`] /
7526/// [`LAYOUT_MISSING_ENTRY_KIND_UPGRADE_SCRIPT`] (95c9c4c) leaf-kind
7527/// labels on the [`crate::LayoutError::MissingEntry`] `kind:
7528/// &'static str` discriminator's accept-set — completes the
7529/// M0-tier arm of the same per-slot leaf-kind categorization axis
7530/// the M2 lift established.
7531///
7532/// Byte-identical to [`crate::CaixaKind::Biblioteca`]'s
7533/// [`crate::CaixaKind::as_str`] output today (both resolve to the
7534/// same eleven-byte `"biblioteca"` scalar) — the pin test
7535/// `layout_missing_entry_kind_m0_consts_align_with_caixa_kind_as_str`
7536/// makes the coincidence load-bearing rather than accidental so a
7537/// future rename that touches either axis (a per-consumer
7538/// disambiguation as the layout diagnostic vocabulary sharpens, a
7539/// verbatim-Portuguese rebrand of the [`crate::CaixaKind`]'s
7540/// human-readable-form arm) has to reach both sites in lockstep
7541/// or the pin trips at build time.
7542pub const LAYOUT_MISSING_ENTRY_KIND_BIBLIOTECA: &str = "biblioteca";
7543
7544/// Canonical [`crate::LayoutError::MissingEntry`] `kind: &'static str`
7545/// discriminator scalar the M0 `:kind Binario` typed slot's per-`:exe`
7546/// entry on-disk-leaf existence gate surfaces under — the byte-string
7547/// every [`crate::LayoutInvariants::verify`] emission carries when an
7548/// `:exe ("exe/tool.lisp" …)` entry's tatara-lisp source path fails to
7549/// resolve against the caixa root's on-disk layout. Peer of
7550/// [`LAYOUT_MISSING_ENTRY_KIND_BIBLIOTECA`] /
7551/// [`LAYOUT_MISSING_ENTRY_KIND_SERVICO`] on the sibling M0 code-slot
7552/// per-directory leaf-kind axes; see
7553/// [`LAYOUT_MISSING_ENTRY_KIND_BIBLIOTECA`] for the shared lift
7554/// rationale.
7555///
7556/// Semantically distinct from [`crate::CaixaKind::Binario`]'s
7557/// [`crate::CaixaKind::as_str`] output (`"binario"`) — this const
7558/// names the *directory-entry* leaf-kind label (the M0 `:exe`
7559/// per-entry axis carries source files under the `exe/` subtree),
7560/// not the caixa's own [`crate::CaixaKind`] discriminator. The
7561/// [`crate::LayoutError::MissingEntry`] `kind` emission consumer
7562/// (the operator running `feira build`) reads this as a per-directory
7563/// categorization label (`"missing exe/... entry"`), whereas
7564/// [`crate::CaixaKind::as_str`] names the whole caixa's runtime kind
7565/// (`"binario"` = "this caixa produces one or more binaries"). Two
7566/// axes, two lifts — the pin test
7567/// `layout_missing_entry_kind_m0_consts_align_with_caixa_kind_as_str`
7568/// asserts the *inequality* between this const and
7569/// [`crate::CaixaKind::Binario`]'s [`crate::CaixaKind::as_str`]
7570/// output, so a future accidental collapse of the two axes onto a
7571/// single scalar surfaces at build time.
7572pub const LAYOUT_MISSING_ENTRY_KIND_EXE: &str = "exe";
7573
7574/// Canonical [`crate::LayoutError::MissingEntry`] `kind: &'static str`
7575/// discriminator scalar the M0 `:kind Servico` typed slot's
7576/// per-`:servicos` entry on-disk-leaf existence gate surfaces under —
7577/// the byte-string every [`crate::LayoutInvariants::verify`] emission
7578/// carries when a `:servicos ("servicos/foo.computeunit.yaml" …)`
7579/// entry fails to resolve against the caixa root's on-disk layout.
7580/// Peer of [`LAYOUT_MISSING_ENTRY_KIND_BIBLIOTECA`] /
7581/// [`LAYOUT_MISSING_ENTRY_KIND_EXE`] on the sibling M0 code-slot
7582/// per-directory leaf-kind axes; see
7583/// [`LAYOUT_MISSING_ENTRY_KIND_BIBLIOTECA`] for the shared lift
7584/// rationale. Byte-identical to [`crate::CaixaKind::Servico`]'s
7585/// [`crate::CaixaKind::as_str`] output today (both resolve to the
7586/// same seven-byte `"servico"` scalar).
7587pub const LAYOUT_MISSING_ENTRY_KIND_SERVICO: &str = "servico";
7588
7589/// Canonical human-readable label the M0 [`crate::CaixaKind::Biblioteca`]
7590/// arm surfaces under [`crate::CaixaKind::as_str`] and (routed through
7591/// it) [`std::fmt::Display`] — the byte-string every future diagnostic
7592/// / graph / audit consumer that formats a `:kind` variant as
7593/// user-facing text lands on (the future wasm-operator's per-caixa
7594/// startup log line naming the loaded caixa's typed shape, the future
7595/// `feira app graph` per-member kind column, the future M4
7596/// `wasm.pleme.io/v1alpha1/ComputeUnit` / `mesh.pleme.io/v1alpha1/*` CR
7597/// materializer's admission-webhook rejection body naming which typed
7598/// kind the offending manifest carries). Peer of the sibling four
7599/// [`CAIXA_KIND_LABEL_BINARIO`] / [`CAIXA_KIND_LABEL_SERVICO`] /
7600/// [`CAIXA_KIND_LABEL_SUPERVISOR`] / [`CAIXA_KIND_LABEL_APLICACAO`]
7601/// consts on the same closed [`crate::CaixaKind`] enum surface —
7602/// together the pentad names every author-reachable arm of the
7603/// substrate's most fundamental typed axis (what a caixa produces),
7604/// mirroring the closed-enum-scalar-value trajectory the sibling
7605/// OTP-shaped [`SUPERVISOR_ESTRATEGIA_ONE_FOR_ONE`] etc. (09ffb2d) and
7606/// [`SUPERVISOR_CHILD_RESTART_PERMANENT`] etc. (ccdf955) and the M3
7607/// [`M3_PLACEMENT_ESTRATEGIA_SINGLE_NODE`] etc. (3f0e21c) established
7608/// on the sibling closed-set typed-enum discriminator axes.
7609///
7610/// Until this lift landed the five [`crate::CaixaKind::as_str`] arms
7611/// each returned a hand-authored byte-string literal (`"biblioteca"`
7612/// / `"binario"` / `"servico"` / `"supervisor"` / `"aplicacao"`) at
7613/// the source-side match arm with no compile-time link to the peer
7614/// [`LAYOUT_MISSING_ENTRY_KIND_BIBLIOTECA`] /
7615/// [`LAYOUT_MISSING_ENTRY_KIND_SERVICO`] consts on the sibling
7616/// layout-diagnostic axis (whose bytes coincide by design), and no
7617/// [`std::fmt::Display`] surface at all — every consumer reaching for
7618/// a caixa-kind byte-string past the wire format
7619/// (`Serialize` → PascalCase `"Biblioteca"` etc.) had to reach for the
7620/// hand-authored [`crate::CaixaKind::as_str`] arm's literal or roll a
7621/// per-consumer `format!("{v:?}")` `Debug` route, either of which a
7622/// future variant rename would silently desynchronize. Lifting the
7623/// five arms onto peer consts + routing [`std::fmt::Display`] through
7624/// [`crate::CaixaKind::as_str`] closes the drift footgun structurally:
7625/// the human-readable byte-string (`Display` + `as_str`), the wire
7626/// byte-string (`Serialize`, PascalCase — intentionally distinct from
7627/// the human-readable form), and the layout-diagnostic byte-string
7628/// (`LAYOUT_MISSING_ENTRY_KIND_*`) each route through one canonical
7629/// declaration per axis, with pin tests
7630/// (`caixa_kind_as_str_returns_lifted_peer_const`,
7631/// `caixa_kind_display_routes_through_as_str_helper`) making any drift
7632/// a caixa-core-build-time failure.
7633///
7634/// Byte-identical to [`LAYOUT_MISSING_ENTRY_KIND_BIBLIOTECA`] today
7635/// (both resolve to the same eleven-byte `"biblioteca"` scalar) — the
7636/// pin test
7637/// [`layout_missing_entry_kind_m0_consts_align_with_caixa_kind_as_str`]
7638/// (fe2a898) already made the coincidence load-bearing on the sibling
7639/// layout-leaf-kind axis. Semantically distinct: this const names the
7640/// [`crate::CaixaKind`] discriminator's human-readable form (the
7641/// substrate's canonical `:kind` label), while
7642/// [`LAYOUT_MISSING_ENTRY_KIND_BIBLIOTECA`] names the
7643/// [`crate::LayoutError::MissingEntry`] `kind: &'static str`
7644/// leaf-kind discriminator (the per-`:bibliotecas`-entry on-disk-leaf
7645/// existence diagnostic's categorization label). Two axes, two lifts —
7646/// same "byte-identical-but-semantically-distinct" discipline the peer
7647/// [`FLEET_PROGRAMS_KEY_VERSAO`] / [`MEMBRO_KEY_VERSAO`] split (ce80ca0)
7648/// established on the sibling per-entry version-constraint axis.
7649pub const CAIXA_KIND_LABEL_BIBLIOTECA: &str = "biblioteca";
7650
7651/// Canonical human-readable label the M0 [`crate::CaixaKind::Binario`]
7652/// arm surfaces under [`crate::CaixaKind::as_str`] and (routed through
7653/// it) [`std::fmt::Display`]. Peer of [`CAIXA_KIND_LABEL_BIBLIOTECA`] /
7654/// [`CAIXA_KIND_LABEL_SERVICO`] / [`CAIXA_KIND_LABEL_SUPERVISOR`] /
7655/// [`CAIXA_KIND_LABEL_APLICACAO`] on the same closed
7656/// [`crate::CaixaKind`] enum surface; see [`CAIXA_KIND_LABEL_BIBLIOTECA`]
7657/// for the shared lift rationale.
7658///
7659/// Semantically distinct from [`LAYOUT_MISSING_ENTRY_KIND_EXE`]
7660/// (`"exe"`) — the alignment pin
7661/// [`layout_missing_entry_kind_m0_consts_align_with_caixa_kind_as_str`]
7662/// (fe2a898) asserts the *inequality* between the layout-side leaf-kind
7663/// label (which names the `exe/` directory sub-tree) and this
7664/// [`crate::CaixaKind`] discriminator label (which names the caixa's
7665/// whole runtime kind). Two axes, two lifts.
7666pub const CAIXA_KIND_LABEL_BINARIO: &str = "binario";
7667
7668/// Canonical human-readable label the M0 [`crate::CaixaKind::Servico`]
7669/// arm surfaces under [`crate::CaixaKind::as_str`] and (routed through
7670/// it) [`std::fmt::Display`]. Peer of [`CAIXA_KIND_LABEL_BIBLIOTECA`] /
7671/// [`CAIXA_KIND_LABEL_BINARIO`] / [`CAIXA_KIND_LABEL_SUPERVISOR`] /
7672/// [`CAIXA_KIND_LABEL_APLICACAO`] on the same closed
7673/// [`crate::CaixaKind`] enum surface; see [`CAIXA_KIND_LABEL_BIBLIOTECA`]
7674/// for the shared lift rationale.
7675///
7676/// Byte-identical to [`LAYOUT_MISSING_ENTRY_KIND_SERVICO`] today (both
7677/// resolve to the same seven-byte `"servico"` scalar) — the pin test
7678/// [`layout_missing_entry_kind_m0_consts_align_with_caixa_kind_as_str`]
7679/// (fe2a898) already made the coincidence load-bearing on the sibling
7680/// layout-leaf-kind axis. Semantically distinct: this const names the
7681/// [`crate::CaixaKind`] discriminator's human-readable form (the
7682/// substrate's canonical `:kind Servico` label), while
7683/// [`LAYOUT_MISSING_ENTRY_KIND_SERVICO`] names the per-`:servicos`-entry
7684/// on-disk-leaf existence diagnostic's categorization label.
7685pub const CAIXA_KIND_LABEL_SERVICO: &str = "servico";
7686
7687/// Canonical human-readable label the M2 [`crate::CaixaKind::Supervisor`]
7688/// arm surfaces under [`crate::CaixaKind::as_str`] and (routed through
7689/// it) [`std::fmt::Display`]. Peer of [`CAIXA_KIND_LABEL_BIBLIOTECA`] /
7690/// [`CAIXA_KIND_LABEL_BINARIO`] / [`CAIXA_KIND_LABEL_SERVICO`] /
7691/// [`CAIXA_KIND_LABEL_APLICACAO`] on the same closed
7692/// [`crate::CaixaKind`] enum surface; see [`CAIXA_KIND_LABEL_BIBLIOTECA`]
7693/// for the shared lift rationale.
7694///
7695/// No layout-leaf-kind peer today — the `:kind Supervisor` typed slot
7696/// carries no on-disk source-file sub-tree (a supervisor is composed
7697/// entirely of `:children` references to other caixas), so no
7698/// [`crate::LayoutError::MissingEntry`] `kind:` diagnostic reaches for
7699/// this label. The const stands as the sole source of truth for the
7700/// [`crate::CaixaKind::Supervisor`] arm's human-readable form.
7701pub const CAIXA_KIND_LABEL_SUPERVISOR: &str = "supervisor";
7702
7703/// Canonical human-readable label the M3 [`crate::CaixaKind::Aplicacao`]
7704/// arm surfaces under [`crate::CaixaKind::as_str`] and (routed through
7705/// it) [`std::fmt::Display`]. Peer of [`CAIXA_KIND_LABEL_BIBLIOTECA`] /
7706/// [`CAIXA_KIND_LABEL_BINARIO`] / [`CAIXA_KIND_LABEL_SERVICO`] /
7707/// [`CAIXA_KIND_LABEL_SUPERVISOR`] on the same closed
7708/// [`crate::CaixaKind`] enum surface; see [`CAIXA_KIND_LABEL_BIBLIOTECA`]
7709/// for the shared lift rationale.
7710///
7711/// Byte-identical to [`FLEET_PROGRAMS_KEY_APLICACAO`] today (both
7712/// resolve to the same nine-byte `"aplicacao"` scalar) — the coincidence
7713/// is deliberate but semantically distinct: this const names the
7714/// [`crate::CaixaKind::Aplicacao`] discriminator's human-readable form
7715/// (the substrate's canonical `:kind Aplicacao` label), while
7716/// [`FLEET_PROGRAMS_KEY_APLICACAO`] names the per-programs.yaml-entry
7717/// passthrough-annotation YAML key that links a member entry back to
7718/// its parent Aplicacao (MESH-COMPOSITION §III.4). Two axes, two lifts
7719/// — same "byte-identical-but-semantically-distinct" discipline every
7720/// peer split establishes.
7721pub const CAIXA_KIND_LABEL_APLICACAO: &str = "aplicacao";
7722
7723/// Canonical human-readable label the [`crate::CaixaKind::Acao`] arm
7724/// surfaces under [`crate::CaixaKind::as_str`] and (routed through it)
7725/// [`std::fmt::Display`]. Sixth peer of [`CAIXA_KIND_LABEL_BIBLIOTECA`] /
7726/// [`CAIXA_KIND_LABEL_BINARIO`] / [`CAIXA_KIND_LABEL_SERVICO`] /
7727/// [`CAIXA_KIND_LABEL_SUPERVISOR`] / [`CAIXA_KIND_LABEL_APLICACAO`] on
7728/// the same closed [`crate::CaixaKind`] enum surface; see
7729/// [`CAIXA_KIND_LABEL_BIBLIOTECA`] for the shared lift rationale.
7730///
7731/// No layout-leaf-kind peer today (mirroring [`CAIXA_KIND_LABEL_SUPERVISOR`])
7732/// — the `:kind Acao` slot's sole payload is the `:ci` field
7733/// (a `canteiro_types::CiRun`), which is not a code-surface
7734/// path-existence check the way `:bibliotecas`/`:exe`/`:servicos` are.
7735pub const CAIXA_KIND_LABEL_ACAO: &str = "acao";
7736
7737/// Canonical PascalCase wire byte-string the [`crate::CaixaKind::Biblioteca`]
7738/// arm serializes as under the un-`rename`d `#[derive(Serialize)]` on
7739/// [`crate::CaixaKind`] — the exact byte-shape every wire surface that
7740/// carries a Caixa's `:kind` outside the caixa-core boundary consumes
7741/// (the [`caixa_crd::caixa_cr::CaixaSpec`] `kind:` field the K8s
7742/// `Caixa` CR persists between apply and reconcile passes, the
7743/// tatara-lisp author-surface `:kind Biblioteca` symbol the sexp parser
7744/// binds into the typed [`crate::CaixaKind`] enum, the future M4
7745/// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's per-CR admission-
7746/// webhook wire binding).
7747///
7748/// Peer of the sibling [`CAIXA_KIND_LABEL_BIBLIOTECA`] lowercase-Portuguese
7749/// diagnostic-form const on the sibling axis — the two byte-strings are
7750/// *intentionally distinct* by design (see the two-axis-split docstring
7751/// on [`crate::CaixaKind::as_str`] + the load-bearing pin
7752/// [`crate::kind::tests::caixa_kind_display_matches_as_str_and_not_serialize_wire`]
7753/// on the split). This wire const names the substrate's PascalCase
7754/// wire form; the sibling `_LABEL_*` const names the substrate's
7755/// lowercase-Portuguese diagnostic form. Six-arm parallel of the
7756/// same closed [`crate::CaixaKind`] enum surface — same "one canonical
7757/// byte-string per arm, per axis, next to the axis" discipline every
7758/// peer typed-enum const family carries.
7759///
7760/// Prior to this lift, every consumer that needed the PascalCase wire
7761/// byte-shape reached for one of two fragile paths: `format!("{:?}",
7762/// kind)` (couples the wire format to `Debug`'s stability guarantee,
7763/// which is *no guarantee at all* by Rust's own conventions — a
7764/// `#[derive(Debug)]` swap for a hand-rolled `impl Debug` that pretty-
7765/// prints the variant with extra context is a permitted mechanical
7766/// edit whose apply-time symptom would be every downstream K8s CR
7767/// carrying a stale wire byte-string), or `serde_json::to_string(&k)`
7768/// then string-trim of the outer quotes (introduces an allocation +
7769/// error-handling path for a byte-shape the compiler knows verbatim at
7770/// build time). Lifting the six arms onto peer consts routes the
7771/// substrate's wire byte-shape through one canonical declaration per
7772/// arm the paired [`crate::CaixaKind::wire_name`] +
7773/// [`crate::CaixaKind::from_wire`] typed dispatch consumers key off.
7774pub const CAIXA_KIND_WIRE_BIBLIOTECA: &str = "Biblioteca";
7775
7776/// Canonical PascalCase wire byte-string the [`crate::CaixaKind::Binario`]
7777/// arm serializes as under the un-`rename`d `#[derive(Serialize)]` on
7778/// [`crate::CaixaKind`]. Peer of [`CAIXA_KIND_WIRE_BIBLIOTECA`] on the
7779/// same closed [`crate::CaixaKind`] enum surface; see the sibling
7780/// [`CAIXA_KIND_WIRE_BIBLIOTECA`] docstring for the shared lift
7781/// rationale.
7782pub const CAIXA_KIND_WIRE_BINARIO: &str = "Binario";
7783
7784/// Canonical PascalCase wire byte-string the [`crate::CaixaKind::Servico`]
7785/// arm serializes as under the un-`rename`d `#[derive(Serialize)]` on
7786/// [`crate::CaixaKind`]. Peer of [`CAIXA_KIND_WIRE_BIBLIOTECA`] on the
7787/// same closed [`crate::CaixaKind`] enum surface; see the sibling
7788/// [`CAIXA_KIND_WIRE_BIBLIOTECA`] docstring for the shared lift
7789/// rationale.
7790pub const CAIXA_KIND_WIRE_SERVICO: &str = "Servico";
7791
7792/// Canonical PascalCase wire byte-string the [`crate::CaixaKind::Supervisor`]
7793/// arm serializes as under the un-`rename`d `#[derive(Serialize)]` on
7794/// [`crate::CaixaKind`]. Peer of [`CAIXA_KIND_WIRE_BIBLIOTECA`] on the
7795/// same closed [`crate::CaixaKind`] enum surface; see the sibling
7796/// [`CAIXA_KIND_WIRE_BIBLIOTECA`] docstring for the shared lift
7797/// rationale.
7798pub const CAIXA_KIND_WIRE_SUPERVISOR: &str = "Supervisor";
7799
7800/// Canonical PascalCase wire byte-string the [`crate::CaixaKind::Aplicacao`]
7801/// arm serializes as under the un-`rename`d `#[derive(Serialize)]` on
7802/// [`crate::CaixaKind`]. Peer of [`CAIXA_KIND_WIRE_BIBLIOTECA`] on the
7803/// same closed [`crate::CaixaKind`] enum surface; see the sibling
7804/// [`CAIXA_KIND_WIRE_BIBLIOTECA`] docstring for the shared lift
7805/// rationale.
7806pub const CAIXA_KIND_WIRE_APLICACAO: &str = "Aplicacao";
7807
7808/// Canonical PascalCase wire byte-string the [`crate::CaixaKind::Acao`]
7809/// arm serializes as under the un-`rename`d `#[derive(Serialize)]` on
7810/// [`crate::CaixaKind`]. Sixth peer of [`CAIXA_KIND_WIRE_BIBLIOTECA`] /
7811/// [`CAIXA_KIND_WIRE_BINARIO`] / [`CAIXA_KIND_WIRE_SERVICO`] /
7812/// [`CAIXA_KIND_WIRE_SUPERVISOR`] / [`CAIXA_KIND_WIRE_APLICACAO`] on
7813/// the same closed [`crate::CaixaKind`] enum surface; see the sibling
7814/// [`CAIXA_KIND_WIRE_BIBLIOTECA`] docstring for the shared lift
7815/// rationale.
7816pub const CAIXA_KIND_WIRE_ACAO: &str = "Acao";
7817
7818/// Canonical caixa-root-relative directory name housing every
7819/// [`crate::CaixaKind::Biblioteca`] caixa's `lib/<nome>.lisp` entry
7820/// (and every `:bibliotecas ("lib/foo.lisp" …)` per-entry source
7821/// path the M0 `:kind Biblioteca` typed slot admits). The single
7822/// source of truth every consumer that composes a caixa-root-relative
7823/// path pointing at the tatara-lisp library sub-tree reaches for:
7824///
7825/// - [`crate::LayoutInvariants::verify`] joins `root` with this
7826/// const to reconstruct the default `lib/<nome>.lisp` per-caixa
7827/// entry the [`crate::LayoutError::MissingLib`] emission gates on;
7828/// - `feira init`'s new-caixa scaffolder joins `root` with this
7829/// const to seed the empty `lib/` sub-tree the template's
7830/// `lib/<nome>.lisp` starter file lives in;
7831/// - `feira fmt` / `feira lint` enumerate every `.lisp` under
7832/// `root.join(LAYOUT_DIR_LIB)` as their default target set (their
7833/// `--paths`-less invocation walks the library sub-tree the
7834/// substrate's [`crate::LayoutInvariants::verify`] pins);
7835/// - `feira tofu` reads every `.lisp` under `root.join(LAYOUT_DIR_LIB)`
7836/// to concatenate the `(defteia …)` forms the caixa-arch invariants
7837/// bind on.
7838///
7839/// The `lib/` byte-shape is a Cargo-style abbreviation of the M0
7840/// `:kind Biblioteca` discriminator ([`crate::CaixaKind::Biblioteca`]
7841/// / [`LAYOUT_MISSING_ENTRY_KIND_BIBLIOTECA`], both `"biblioteca"`),
7842/// deliberately distinct from the discriminator's byte-shape so the
7843/// on-disk convention stays terse while the diagnostic label stays
7844/// full-form Portuguese. Peer of [`LAYOUT_DIR_EXE`] /
7845/// [`LAYOUT_DIR_SERVICOS`] on the sibling M0 per-`CaixaKind`
7846/// on-disk-directory-name axes — the three consts jointly single-source
7847/// the CSE-invariant layout convention every caixa the substrate accepts
7848/// carries. A future rebrand of the on-disk directory landing convention
7849/// (`"lib"` → `"src"` matching Rust's convention, `"lib"` → `"biblioteca"`
7850/// matching the full-form Portuguese-uniformity a per-kind consumer
7851/// disambiguation would prefer) lands as a one-line const-edit + the
7852/// paired drift-detection pin that guards the two-axis distinctness
7853/// (`layout_dir_bib_is_distinct_from_layout_missing_entry_kind_bib`)
7854/// rather than a coordinated ~40-site sweep across production +
7855/// tests + CI scaffolders.
7856///
7857/// Same "one canonical byte-string per typed axis + a paired
7858/// drift-detection pin at every load-bearing byte-shape coincidence"
7859/// discipline the M0 [`LAYOUT_MISSING_ENTRY_KIND_BIBLIOTECA`] /
7860/// [`LAYOUT_MISSING_ENTRY_KIND_EXE`] / [`LAYOUT_MISSING_ENTRY_KIND_SERVICO`]
7861/// (fe2a898) leaf-kind categorization triad established on the peer
7862/// [`crate::LayoutError::MissingEntry`] `kind:` discriminator axis.
7863pub const LAYOUT_DIR_LIB: &str = "lib";
7864
7865/// Canonical caixa-root-relative directory name housing every
7866/// [`crate::CaixaKind::Binario`] caixa's `exe/<name>` entry (and
7867/// every `:exe ("exe/tool" …)` per-entry source path the M0
7868/// `:kind Binario` typed slot admits). Peer of [`LAYOUT_DIR_LIB`] /
7869/// [`LAYOUT_DIR_SERVICOS`] on the sibling M0 per-`CaixaKind`
7870/// on-disk-directory-name axes; see [`LAYOUT_DIR_LIB`] for the
7871/// shared lift rationale.
7872///
7873/// [`crate::LayoutInvariants::verify`] joins `root` with this const
7874/// to reconstruct the sandbox-root the [`crate::LayoutError::ExeOutsideDir`]
7875/// emission gates every declared `:exe` entry against — a `:exe`
7876/// entry whose resolved path escapes `root.join(LAYOUT_DIR_EXE)`
7877/// surfaces `ExeOutsideDir(<path>)` at `feira build` time rather than
7878/// silently reaching outside the caixa's sandbox at OCI-build /
7879/// nix-build time. Byte-identical (by design) to
7880/// [`LAYOUT_MISSING_ENTRY_KIND_EXE`] — the M0 `:kind Binario`
7881/// on-disk-directory-name and the [`crate::LayoutError::MissingEntry`]
7882/// `kind:` leaf-kind categorization label share the same three-byte
7883/// scalar because both name the same axis (the `exe/` sub-tree), a
7884/// coincidence the pin test
7885/// `layout_dir_exe_matches_layout_missing_entry_kind_exe` makes
7886/// load-bearing so a rebrand touching either axis without the other
7887/// trips at build time rather than surfacing at
7888/// [`crate::LayoutInvariants::verify`] time as a mismatched
7889/// `MissingEntry.kind` diagnostic naming a stale label.
7890pub const LAYOUT_DIR_EXE: &str = "exe";
7891
7892/// Canonical caixa-root-relative directory name housing every
7893/// [`crate::CaixaKind::Servico`] caixa's
7894/// `servicos/<nome>.computeunit.yaml` per-CR `ComputeUnit` descriptor
7895/// (and every `:servicos ("servicos/foo.computeunit.yaml" …)`
7896/// per-entry source path the M0 `:kind Servico` typed slot admits).
7897/// Peer of [`LAYOUT_DIR_LIB`] / [`LAYOUT_DIR_EXE`] on the sibling M0
7898/// per-`CaixaKind` on-disk-directory-name axes; see [`LAYOUT_DIR_LIB`]
7899/// for the shared lift rationale.
7900///
7901/// [`crate::LayoutInvariants::verify`] joins `root` with this const
7902/// to reconstruct the sandbox-root the
7903/// [`crate::LayoutError::ServicoOutsideDir`] emission gates every
7904/// declared `:servicos` entry against — a `:servicos` entry whose
7905/// resolved path escapes `root.join(LAYOUT_DIR_SERVICOS)` surfaces
7906/// `ServicoOutsideDir(<path>)` at `feira build` time rather than
7907/// silently reaching outside the caixa's sandbox at
7908/// [`caixa_helm`][ch] / [`caixa_flux`][cf] render time or at the
7909/// operator's OCI-build step.
7910///
7911/// The `servicos/` byte-shape is the Portuguese *plural* of the M0
7912/// `:kind Servico` discriminator ([`crate::CaixaKind::Servico`] /
7913/// [`LAYOUT_MISSING_ENTRY_KIND_SERVICO`], both `"servico"`, singular)
7914/// — the on-disk directory holds one-or-more `ComputeUnit` YAML
7915/// descriptors per caixa, the discriminator names the caixa's kind.
7916/// The pin test
7917/// `layout_dir_servicos_is_distinct_from_layout_missing_entry_kind_servico`
7918/// makes the singular/plural split load-bearing so a future rebrand
7919/// touching either axis without the other (a per-consumer
7920/// disambiguation collapsing them, a hypothetical English-uniformity
7921/// pass renaming `"servicos"` → `"services"`) trips at build time.
7922///
7923/// [ch]: caixa_helm
7924/// [cf]: caixa_flux
7925pub const LAYOUT_DIR_SERVICOS: &str = "servicos";
7926
7927/// Canonical `wasm.pleme.io/v1alpha1/ComputeUnit` CRD `spec.module`
7928/// per-CR wasm-module-reference sub-block key — the top-level `spec.*`
7929/// child every rendered `ComputeUnit` YAML carries to name the wasm
7930/// component (`module.source: oci://...` for OCI-hosted binaries,
7931/// `module.source: file://...` for locally-mounted wasm bundles) the
7932/// M2.5 wasm-engine instantiator loads at Servico bring-up. The single
7933/// source of truth every downstream consumer that reads or emits the
7934/// per-CR module sub-block reaches for:
7935///
7936/// - [`caixa_flux::programs_yaml_entry`] splices the ComputeUnit
7937/// YAML's `spec.module` verbatim through into the emitted
7938/// `programs[]` entry (the `lareira-fleet-programs` library chart's
7939/// per-entry module-source axis, populated from the ComputeUnit's
7940/// `spec.module` per the docstring on `programs_yaml_entry` above);
7941/// - [`caixa_helm::build_values_yaml`] threads the same
7942/// `spec.module` sub-block into the rendered `values.yaml`'s
7943/// [`DEFAULT_LIBRARY_NAME`]-wrapped block so the `pleme-computeunit`
7944/// library chart's per-Servico module axis binds to the exact
7945/// source the caixa.lisp's `:servicos` fixture pins;
7946/// - every test-fixture navigator in both crates that reaches into
7947/// the rendered `programs[]` entry / `values.yaml` block by the
7948/// module sub-block key to pin the per-Servico module-source axis
7949/// round-trip (six sites across [`caixa_flux`][cf]'s per-entry
7950/// module + module.source drift-detection sweep + [`caixa_helm`][ch]'s
7951/// per-values module drift-detection sweep) resolves the same
7952/// `&'static str` when parsing back the rendered document;
7953/// - every future per-Servico renderer the absorption-roadmap
7954/// acknowledges (the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
7955/// materializer's per-`:membros` module-source resolver, a future
7956/// per-cluster ComputeUnit-CR admission webhook keying off the same
7957/// accepted sub-block set, the future caixa-otel collector-pipeline
7958/// emitter's per-Servico module-scrape reference).
7959///
7960/// Until this lift landed the byte `"module"` lived as six verbatim
7961/// inline literals across [`caixa_flux`][cf] and [`caixa_helm`][ch]'s
7962/// test-fixture navigators (four sites in caixa-flux —
7963/// `programs_yaml_entry_round_trips`'s `entry.get("module")` pair +
7964/// `upsert_helmrelease_replaces_existing`'s `.get("module")` +
7965/// `upsert_into_programs_yaml`'s `.get("module")` — and two sites in
7966/// caixa-helm — `values_yaml_wraps_under_pleme_computeunit_key`'s
7967/// `cu_block.get("module")` + `values_yaml_wrap_key_follows_library_name_override`'s
7968/// peer navigator on the library-name-override axis). A future
7969/// ComputeUnit CRD schema-key rebrand on the per-CR module-reference
7970/// axis (the substrate moving the wasm-component reference to
7971/// `binary:` for parity with OCI OpenContainer Image nomenclature, to
7972/// `component:` for parity with WIT Component Model wire terminology,
7973/// to `spec.wasm.source` for schema-clarity once the ComputeUnit
7974/// CRD grows sibling `spec.native.*` / `spec.container.*` runtime-
7975/// discriminators as the ABSORPTION-ROADMAP.md M4-M5 trajectory names)
7976/// without a coordinated edit across all six sites would silently
7977/// split the schema: the emitter would write under the drifted key
7978/// while every downstream test would still probe `module:` — the
7979/// `lareira-fleet-programs` library chart's per-entry module-source
7980/// axis would silently receive an empty reference, the workload would
7981/// silently come up with no wasm module bound (the M2.5 instantiator
7982/// falls back to the library chart's admission-time default of a
7983/// hello-world stub, or fails the bring-up at wasm-engine parse time
7984/// with a diagnostic far from the caixa.lisp source), and the failure
7985/// would surface as "the Servico's pods are running but they aren't
7986/// running our code" far from the rebrand commit's source. Lifting
7987/// the literal to one `&'static str` closes the drift footgun
7988/// structurally — every consumer reads the same memory, so any
7989/// future rebrand reaches every consumer by construction.
7990///
7991/// Same "the typed constant lives in one place" discipline the peer
7992/// [`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] / [`M2_KEY_UPGRADE_FROM`]
7993/// lifts apply on the sibling caixa.lisp M2 typed-slot canonical-
7994/// camelCase-key surfaces — extends the discipline from the caixa-
7995/// source-side M2 typed-slot overlay-key triple onto the substrate-
7996/// side `wasm.pleme.io/v1alpha1/ComputeUnit` CRD per-`spec.*`
7997/// sub-block axis every rendered ComputeUnit YAML declares as its
7998/// top-level `(module, trigger, capabilities)` triple (the peer
7999/// [`COMPUTEUNIT_SPEC_KEY_TRIGGER`] +
8000/// [`COMPUTEUNIT_SPEC_KEY_CAPABILITIES`] siblings complete the
8001/// substrate-side ComputeUnit-CRD per-`spec.*` sub-block re-export
8002/// triple).
8003///
8004/// [cf]: ../../caixa_flux/index.html
8005/// [ch]: ../../caixa_helm/index.html
8006pub const COMPUTEUNIT_SPEC_KEY_MODULE: &str = "module";
8007
8008/// Canonical `wasm.pleme.io/v1alpha1/ComputeUnit` CRD `spec.trigger`
8009/// per-CR invocation-trigger sub-block key — the top-level `spec.*`
8010/// child every rendered `ComputeUnit` YAML carries to name how the
8011/// wasm component is invoked (`trigger.service.{port, paths}` for
8012/// HTTP-triggered Servicos, `trigger.subscription.{subject}` for the
8013/// future NATS-triggered Servicos the M4 `:contratos` typed-mesh
8014/// pubsub axis will emit). Peer of [`COMPUTEUNIT_SPEC_KEY_MODULE`] on
8015/// the same ComputeUnit CRD per-`spec.*` sub-block surface —
8016/// `COMPUTEUNIT_SPEC_KEY_MODULE` names the per-CR wasm-binary
8017/// reference axis, this constant names the per-CR invocation-shape
8018/// axis every downstream trigger consumer (the `pleme-computeunit`
8019/// library chart's per-Servico `trigger.service.port` /
8020/// `trigger.service.paths` / `trigger.service.breathability` values-
8021/// block routing, the future M4 pubsub-subscription binding, the
8022/// `caixa-mesh` `CiliumNetworkPolicy` L4-port fallback that reads the
8023/// destination Servico's per-`trigger.service.port` axis via a future
8024/// resolver round-trip) reaches for. Same lift trajectory as the
8025/// sibling [`COMPUTEUNIT_SPEC_KEY_MODULE`] axis — three verbatim
8026/// inline test-side literals (one caixa-flux drift-detection navigator
8027/// + two caixa-helm per-values drift-detection navigators, one under
8028/// the canonical wrap-key + one under the library-name-override wrap-
8029/// key) collapsed onto the same `&'static str` so any future rebrand
8030/// (the substrate moving the invocation-shape axis to `invoke:`,
8031/// `entry:`, or splitting into `trigger.http.*` / `trigger.pubsub.*`
8032/// runtime-discriminators as the M4 `:contratos` axis grows) reaches
8033/// every consumer by construction. See [`COMPUTEUNIT_SPEC_KEY_MODULE`]
8034/// for the full lift rationale.
8035pub const COMPUTEUNIT_SPEC_KEY_TRIGGER: &str = "trigger";
8036
8037/// Canonical `wasm.pleme.io/v1alpha1/ComputeUnit` CRD
8038/// `spec.capabilities` per-CR WASI-capability-list sub-block key — the
8039/// top-level `spec.*` child every rendered `ComputeUnit` YAML carries
8040/// to declare the wasm-component-capability tokens the M2.5 wasm-engine
8041/// instantiator binds at Servico bring-up (`http-in:0.0.0.0:8080` for
8042/// the HTTP incoming-handler, `env` for read-only environment access,
8043/// `sock-*` for TCP outbound, and the sibling WASI-preview-2 preview-
8044/// interfaces per the WIT Component Model). Peer of
8045/// [`COMPUTEUNIT_SPEC_KEY_MODULE`] and [`COMPUTEUNIT_SPEC_KEY_TRIGGER`]
8046/// on the same ComputeUnit CRD per-`spec.*` sub-block surface —
8047/// completes the substrate-side ComputeUnit-CRD per-`spec.*` sub-block
8048/// re-export triple every rendered ComputeUnit YAML declares as its
8049/// top-level `(module, trigger, capabilities)` axis. Same lift
8050/// trajectory as the sibling [`COMPUTEUNIT_SPEC_KEY_MODULE`] axis —
8051/// three verbatim inline test-side literals (one caixa-flux drift-
8052/// detection navigator + two caixa-helm per-values drift-detection
8053/// navigators, one under the canonical wrap-key + one under the
8054/// library-name-override wrap-key) collapsed onto the same
8055/// `&'static str` so any future rebrand (the substrate moving the
8056/// capability-list axis to `caps:` for terse-schema parity with the
8057/// WASI-preview-2 upstream naming, splitting into
8058/// `capabilities.wasi.*` / `capabilities.pleme.*` runtime-vs-substrate
8059/// discriminators, or the M4 WIT Component Model materializer moving
8060/// to a typed `imports:` / `exports:` split) reaches every consumer by
8061/// construction. See [`COMPUTEUNIT_SPEC_KEY_MODULE`] for the full lift
8062/// rationale.
8063pub const COMPUTEUNIT_SPEC_KEY_CAPABILITIES: &str = "capabilities";
8064
8065/// Canonical `wasm.pleme.io/v1alpha1/ComputeUnit` CRD
8066/// `spec.module.source` per-CR wasm-component-reference leaf-scalar
8067/// sub-block key — the nested `spec.module.*` child every rendered
8068/// `ComputeUnit` YAML carries to name the exact wasm-component
8069/// artifact the M2.5 wasm-engine instantiator loads at Servico
8070/// bring-up. Peer of the parent [`COMPUTEUNIT_SPEC_KEY_MODULE`] on the
8071/// same ComputeUnit CRD per-`spec.module.*` sub-block surface —
8072/// `COMPUTEUNIT_SPEC_KEY_MODULE` names the top-level per-CR module-
8073/// reference block; this constant names the block's leaf reference-
8074/// value axis. Every rendered `programs[]` entry the
8075/// `lareira-fleet-programs` library chart consumes carries the
8076/// `module.source: oci://ghcr.io/pleme-io/<caixa>:<versao>` (or
8077/// `module.source: file://...` for locally-mounted wasm bundles;
8078/// `module.source: github:<owner>/<repo>` for git-hosted sources) as
8079/// its per-Servico wasm-artifact reference; every `spec.module.source`
8080/// readback across the [`caixa_flux::programs_yaml_entry`] round-trip
8081/// pins + the [`caixa_flux::upsert_into_programs_yaml`] /
8082/// [`caixa_flux::upsert_into_helmrelease_programs`] cross-upsert
8083/// navigators resolves the same `&'static str`.
8084///
8085/// Until this lift landed the byte `"source"` lived as three verbatim
8086/// inline literals across [`caixa_flux`][cf]'s test-fixture navigators
8087/// (`programs_yaml_entry_round_trips`'s
8088/// `entry.get(COMPUTEUNIT_SPEC_KEY_MODULE).and_then(|m| m.get("source"))`
8089/// per-`module.source` present-check +
8090/// `upsert_into_programs_yaml`'s
8091/// `arr[0].get(COMPUTEUNIT_SPEC_KEY_MODULE).get("source")` cross-
8092/// upsert readback + `upsert_into_helmrelease_programs`'s peer
8093/// navigator on the `HelmRelease`-wrapped `spec.values.programs[]`
8094/// path). A future ComputeUnit-CRD schema rebrand on the per-`module`
8095/// leaf-scalar axis (the substrate moving the reference-value axis to
8096/// `ref:` for parity with the OCI Distribution Spec's per-manifest
8097/// content-reference nomenclature, to `uri:` for parity with the WIT
8098/// Component Model's per-import content-reference field, to
8099/// `module.oci.ref` / `module.file.path` / `module.git.rev` sibling-
8100/// discriminator split once the ComputeUnit CRD grows typed sub-block
8101/// discriminators as the ABSORPTION-ROADMAP.md M4-M5 trajectory names)
8102/// without a coordinated three-site edit would silently split the
8103/// schema: the emitter would write under the drifted leaf-key while
8104/// every downstream navigator would still probe `source:` — the
8105/// `lareira-fleet-programs` library chart's per-entry module-source
8106/// axis would silently receive an empty reference, the workload would
8107/// silently come up with no wasm module bound (the M2.5 instantiator
8108/// falls back to the library chart's admission-time hello-world stub,
8109/// or fails the bring-up at wasm-engine parse time with a diagnostic
8110/// far from the caixa.lisp source), and the failure would surface as
8111/// "the Servico's pods are running but they aren't running our code"
8112/// far from the rebrand commit's source. Lifting the literal to one
8113/// `&'static str` closes the drift footgun structurally — every
8114/// consumer reads the same memory, so any future rebrand reaches every
8115/// consumer by construction.
8116///
8117/// Same "the typed constant lives in one place" discipline the peer
8118/// [`COMPUTEUNIT_SPEC_KEY_MODULE`] / [`COMPUTEUNIT_SPEC_KEY_TRIGGER`] /
8119/// [`COMPUTEUNIT_SPEC_KEY_CAPABILITIES`] lifts apply on the sibling
8120/// substrate-side ComputeUnit-CRD per-`spec.*` sub-block axis —
8121/// extends the discipline one level deeper from the top-level `spec.*`
8122/// container-axis surface onto the nested `spec.module.*` leaf-scalar-
8123/// axis every rendered ComputeUnit YAML declares under its per-CR
8124/// module-reference block.
8125///
8126/// [cf]: ../../caixa_flux/index.html
8127pub const COMPUTEUNIT_MODULE_KEY_SOURCE: &str = "source";
8128
8129/// Canonical YAML key for the M3 `:placement` slot's overlay on a
8130/// rendered programs.yaml entry. The lareira-fleet-programs aggregator
8131/// (and the future `app-operator` per-Aplicacao reconciler) both key
8132/// off this exact spelling to filter entries by `placement.clusters`
8133/// for cross-cluster fanout (MESH-COMPOSITION §III.4) and to dispatch
8134/// on `placement.estrategia` for distributed-app takeover semantics
8135/// (§II.1, §V cross-cluster federation). Lifted as a const alongside
8136/// the M2 keys so the Aplicacao-side renderer
8137/// ([`crate::aplicacao::Placement`] → caixa-mesh
8138/// `programs_for_aplicacao`) and every consumer (the M4 cluster-fanout
8139/// renderer, the future `mesh.pleme.io/v1alpha1/Aplicacao` CR
8140/// materializer, the `app-operator`'s placement-strategy dispatcher)
8141/// spell the same key exactly the same way — drift here = a
8142/// programs.yaml entry whose placement is silently dropped at the
8143/// aggregator's filter step (visible only as "the workload doesn't
8144/// land where the typed slot said it should").
8145pub const M3_KEY_PLACEMENT: &str = "placement";
8146
8147/// Canonical author-facing kebab-case `(defcaixa … :membros (…))`
8148/// top-level mesh slot label the M3 Aplicacao's constituent-Servico set
8149/// surfaces under. Peer of the four sibling M3 top-level mesh-slot
8150/// labels ([`M3_AUTHOR_KEY_CONTRATOS`], [`M3_AUTHOR_KEY_POLITICAS`],
8151/// [`M3_AUTHOR_KEY_PLACEMENT`], [`M3_AUTHOR_KEY_ENTRADA`]) on the
8152/// dual-axis pair every M3 top-level mesh slot carries: the
8153/// author-facing kebab-case `[M3_AUTHOR_KEY_*]` const names the label
8154/// the [`crate::Caixa::declared_mesh_slots`] tagger threads through as
8155/// one of the `&'static str` entries in the canonical-declaration-order
8156/// slot list the kind-coherence gate
8157/// ([`crate::LayoutError::MeshSlotsOnNonAplicacao`]) joins into the
8158/// space-separated `slots:` diagnostic naming which of the five mesh
8159/// slots the offending caixa declared on a non-Aplicacao kind. Peer of
8160/// the [`M3_KEY_PLACEMENT`] renderer-side wire-key const declared
8161/// immediately above on the sole M3 mesh slot the renderer surfaces as
8162/// a per-entry overlay-container key (`:membros` / `:contratos` /
8163/// `:politicas` / `:entrada` render as per-arm derived artifacts —
8164/// programs.yaml fan-out, CiliumNetworkPolicies, per-edge overlays,
8165/// Gateway/HTTPRoute — not as a single overlay-container key).
8166///
8167/// Until this lift landed the five kebab-case labels sat once each in
8168/// [`crate::Caixa::declared_mesh_slots`] as five-arm inline
8169/// `":membros"` / `":contratos"` / `":politicas"` / `":placement"` /
8170/// `":entrada"` byte-strings the tagger pushed onto its return `Vec`,
8171/// plus three test-side probe literals across `layout.rs` and
8172/// `manifest.rs::tests` — with no compile-time link between the
8173/// tagger's arms and the tests' expected values. A future rebrand
8174/// (a hypothetical `:membros` → `:members` matching English-uniformity
8175/// as the substrate's per-slot vocabulary stabilizes, `:contratos` →
8176/// `:contracts` matching the same, `:politicas` → `:policies`
8177/// matching the same, `:placement` → `:distribution` matching
8178/// MESH-COMPOSITION §II.1 vocabulary, `:entrada` → `:ingress` matching
8179/// K8s Gateway API's ingress-side vocabulary, or a per-consumer
8180/// disambiguation as the `defcaixa` macro stabilizes) would silently
8181/// desynchronize the production
8182/// [`crate::Caixa::declared_mesh_slots`] tagger from the tests until a
8183/// downstream consumer surfaced the drift at build time as a
8184/// matches-arm miss far from the rename's commit. This lift closes
8185/// that gap by routing both halves (production tagger + tests) through
8186/// five peer consts declared adjacent to the renderer-side
8187/// [`M3_KEY_PLACEMENT`] peer, so the "one canonical declaration per
8188/// arm, next to the axis" discipline the peer
8189/// [`M2_AUTHOR_KEY_LIMITS`] / [`M2_AUTHOR_KEY_BEHAVIOR`] /
8190/// [`M2_AUTHOR_KEY_UPGRADE_FROM`] top-level M2 slot consts
8191/// (f49c8b0) established for the sibling per-Servico M2 slot axis
8192/// extends onto the M3 top-level mesh slot axis so both altitudes
8193/// of the typed-slot algebra (per-Servico M2 + per-Aplicacao M3)
8194/// route through peer author-label consts.
8195pub const M3_AUTHOR_KEY_MEMBROS: &str = ":membros";
8196
8197/// Canonical author-facing kebab-case `(defcaixa … :contratos (…))`
8198/// top-level mesh slot label the M3 Aplicacao's WIT-typed inter-Servico
8199/// edge set surfaces under. Peer of [`M3_AUTHOR_KEY_MEMBROS`] on the
8200/// sibling M3 top-level mesh-slot dual axis; see
8201/// [`M3_AUTHOR_KEY_MEMBROS`] for the full lift rationale.
8202pub const M3_AUTHOR_KEY_CONTRATOS: &str = ":contratos";
8203
8204/// Canonical author-facing kebab-case `(defcaixa … :politicas (…))`
8205/// top-level mesh slot label the M3 Aplicacao's mesh-level policy
8206/// overlay ([`crate::aplicacao::MeshPolicy`]: `:timeout`, `:retries`,
8207/// `:circuit-breaker`, `:mtls-required`, `:rate-limit`) surfaces under.
8208/// Peer of [`M3_AUTHOR_KEY_MEMBROS`] on the sibling M3 top-level
8209/// mesh-slot dual axis; see [`M3_AUTHOR_KEY_MEMBROS`] for the full lift
8210/// rationale.
8211pub const M3_AUTHOR_KEY_POLITICAS: &str = ":politicas";
8212
8213/// Canonical author-facing kebab-case `(defcaixa … :placement (…))`
8214/// top-level mesh slot label the M3 Aplicacao's cross-cluster
8215/// distribution strategy ([`crate::aplicacao::Placement`]:
8216/// `:estrategia` + `:clusters` + `:shard-key` / `:affinity`) surfaces
8217/// under. Peer of [`M3_AUTHOR_KEY_MEMBROS`] on the sibling M3
8218/// top-level mesh-slot dual axis; see [`M3_AUTHOR_KEY_MEMBROS`] for
8219/// the full lift rationale. Byte-identical to the peer
8220/// [`M3_KEY_PLACEMENT`] renderer-side wire key modulo the leading `:`
8221/// — the two consts split on the axis every M3 top-level slot carries
8222/// (author-facing kebab-case label vs. renderer-side camelCase overlay
8223/// key), the same split the [`M2_AUTHOR_KEY_LIMITS`] / [`M2_KEY_LIMITS`]
8224/// peer pair established on the sibling M2 axis.
8225pub const M3_AUTHOR_KEY_PLACEMENT: &str = ":placement";
8226
8227/// Canonical author-facing kebab-case `(defcaixa … :entrada (…))`
8228/// top-level mesh slot label the M3 Aplicacao's external-ingress
8229/// gateway surface ([`crate::aplicacao::Entrada`]: `:host`, `:para`,
8230/// `:paths`, `:port`) surfaces under. Peer of [`M3_AUTHOR_KEY_MEMBROS`]
8231/// on the sibling M3 top-level mesh-slot dual axis; see
8232/// [`M3_AUTHOR_KEY_MEMBROS`] for the full lift rationale.
8233pub const M3_AUTHOR_KEY_ENTRADA: &str = ":entrada";
8234
8235/// Canonical author-facing kebab-case `(:de "<caixa>")` per-`:contratos`
8236/// entry source-endpoint sub-slot label the M3 Aplicacao's WIT-typed
8237/// inter-Servico edge set surfaces under. Names the "edge tail" —
8238/// which member `:contratos` entry `n` originates from — per
8239/// MESH-COMPOSITION §IV table row "`:contratos` | typed inter-Servico
8240/// edges | each :de + :para must be in :membros; :wit must reference a
8241/// registered WIT world".
8242///
8243/// Peer of [`M3_AUTHOR_KEY_CONTRATOS`] on the `:contratos` sub-slot
8244/// author-facing-label dual axis: the top-level [`M3_AUTHOR_KEY_CONTRATOS`]
8245/// const (882f498) names the M3 slot itself, the two
8246/// `CONTRATO_AUTHOR_KEY_{DE,PARA}` consts name the per-entry endpoint
8247/// axes the parser reads (`(:de "cart" :para "catalog" …)`).
8248///
8249/// Until this lift landed the two kebab-case labels sat once each in
8250/// [`crate::aplicacao::AplicacaoSpec::validate`]'s per-`:contratos`
8251/// entry endpoint-shape gate as two two-arm inline `":de"` / `":para"`
8252/// byte-strings passed as the `slot: &'static str` argument to
8253/// [`validate_contrato_caixa`], plus a family of test-side probe
8254/// literals asserting the [`crate::aplicacao::AplicacaoError::ContratoCaixaEmpty`]
8255/// / [`crate::aplicacao::AplicacaoError::ContratoCaixaInvalid`]
8256/// diagnostic's `slot:` field carries the expected per-arm value
8257/// verbatim — with no compile-time link between the validator's arms
8258/// and the tests' expected values. A future rebrand (a hypothetical
8259/// `:de` → `:from` for English uniformity matching the OTP `appup`
8260/// `M2_UPGRADE_FROM_KEY_FROM` (36ffe65) sibling, `:para` → `:to`
8261/// matching the same, `:de`/`:para` → `:source`/`:target` matching
8262/// the WIT world's `import`/`export` half-vocabulary, or a per-consumer
8263/// disambiguation as the `defcaixa` macro stabilizes) would silently
8264/// desynchronize the production per-entry endpoint-shape gate from the
8265/// tests until a downstream consumer surfaced the drift at build time
8266/// as a matches-arm miss far from the rename's commit. This lift closes
8267/// that gap by routing both halves (production endpoint-shape gate +
8268/// tests) through two peer consts declared adjacent to the
8269/// [`M3_AUTHOR_KEY_CONTRATOS`] parent-slot label, so the "one
8270/// canonical declaration per arm, next to the axis" discipline the
8271/// peer [`M2_AUTHOR_KEY_LIMITS`] / [`M2_AUTHOR_KEY_BEHAVIOR`] /
8272/// [`M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0), [`M3_AUTHOR_KEY_MEMBROS`]
8273/// / [`M3_AUTHOR_KEY_CONTRATOS`] / [`M3_AUTHOR_KEY_POLITICAS`] /
8274/// [`M3_AUTHOR_KEY_PLACEMENT`] / [`M3_AUTHOR_KEY_ENTRADA`] (882f498),
8275/// and [`SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492) top-level
8276/// slot consts established for the sibling M2 / M3 / Supervisor
8277/// top-level slot axes extends onto the `:contratos` sub-slot
8278/// endpoint axis.
8279pub const CONTRATO_AUTHOR_KEY_DE: &str = ":de";
8280
8281/// Canonical author-facing kebab-case `(:para "<caixa>")` per-`:contratos`
8282/// entry target-endpoint sub-slot label the M3 Aplicacao's WIT-typed
8283/// inter-Servico edge set surfaces under. Names the "edge head" —
8284/// which member `:contratos` entry `n` terminates at — per
8285/// MESH-COMPOSITION §IV table row "`:contratos` | typed inter-Servico
8286/// edges | each :de + :para must be in :membros". Peer of
8287/// [`CONTRATO_AUTHOR_KEY_DE`] on the sibling `:contratos` per-entry
8288/// endpoint-shape axis; see [`CONTRATO_AUTHOR_KEY_DE`] for the full
8289/// lift rationale.
8290pub const CONTRATO_AUTHOR_KEY_PARA: &str = ":para";
8291
8292/// Canonical author-facing kebab-case `(defcaixa … :estrategia <s>)`
8293/// top-level supervisor-tree slot label the OTP `:kind Supervisor`
8294/// caixa's [`crate::supervisor::RestartStrategy`] discriminator surfaces
8295/// under. Peer of [`M2_AUTHOR_KEY_LIMITS`] /
8296/// [`M3_AUTHOR_KEY_MEMBROS`] on the third kind-scoped
8297/// typed-slot-family axis: the M2 `M2_AUTHOR_KEY_*` consts (f49c8b0)
8298/// name the Servico-runtime slots, the M3 `M3_AUTHOR_KEY_*` consts
8299/// (882f498) name the Aplicacao mesh slots, and these
8300/// `SUPERVISOR_AUTHOR_KEY_*` consts close the last remaining kind ↔
8301/// slot-family axis — the Supervisor supervision-tree slots
8302/// (`:estrategia`, `:max-restarts`, `:restart-window`, `:children`) that
8303/// [`crate::Caixa::declared_supervisor_slots`] tags for the sibling
8304/// [`crate::LayoutError::SupervisorSlotsOnNonSupervisor`]
8305/// kind-coherence gate.
8306///
8307/// Until this lift landed the four kebab-case labels sat once each in
8308/// [`crate::Caixa::declared_supervisor_slots`] as four-arm inline
8309/// `":estrategia"` / `":max-restarts"` / `":restart-window"` /
8310/// `":children"` byte-strings the tagger pushed onto its return `Vec`,
8311/// plus a handful of test-side probe literals asserting the diagnostic's
8312/// `slots:` field carries the expected per-arm value verbatim — with no
8313/// compile-time link between the tagger's arms and the tests' expected
8314/// values. A future rebrand (a hypothetical `:estrategia` →
8315/// `:strategy` for English uniformity, `:max-restarts` →
8316/// `:max-intensity` matching Erlang/OTP's `MaxIntensity` terminology
8317/// verbatim, `:restart-window` → `:period` matching OTP's `Period` name,
8318/// `:children` → `:workers` matching the Elixir `Supervisor.child_spec`
8319/// idiom, or a per-consumer disambiguation as the `defcaixa` macro
8320/// stabilizes) would silently desynchronize the production
8321/// [`crate::Caixa::declared_supervisor_slots`] tagger from the tests
8322/// until a downstream consumer surfaced the drift at build time as a
8323/// matches-arm miss far from the rename's commit. This lift closes that
8324/// gap by routing both halves (production tagger + tests) through four
8325/// peer consts declared adjacent to the peer M2 / M3 top-level
8326/// author-key consts, so the "one canonical declaration per arm, next
8327/// to the axis" discipline the peer [`M2_AUTHOR_KEY_LIMITS`] /
8328/// [`M2_AUTHOR_KEY_BEHAVIOR`] / [`M2_AUTHOR_KEY_UPGRADE_FROM`] top-level
8329/// M2 slot consts (f49c8b0) and [`M3_AUTHOR_KEY_MEMBROS`] /
8330/// [`M3_AUTHOR_KEY_CONTRATOS`] / [`M3_AUTHOR_KEY_POLITICAS`] /
8331/// [`M3_AUTHOR_KEY_PLACEMENT`] / [`M3_AUTHOR_KEY_ENTRADA`] top-level
8332/// M3 slot consts (882f498) established for the sibling
8333/// per-Servico / per-Aplicacao top-level slot axes extends onto the
8334/// per-Supervisor supervision-tree slot axis, closing the last of the
8335/// three kind-scoped typed-slot-family author-facing-label axes.
8336///
8337/// Same "one canonical byte-string per typed axis" discipline every
8338/// peer M2 / M3 renderer-wire-key axis carries ([`M2_KEY_LIMITS`] /
8339/// [`M2_KEY_BEHAVIOR`] / [`M2_KEY_UPGRADE_FROM`],
8340/// [`M2_LIMITS_KEY_MEMORY`] / [`M2_LIMITS_KEY_FUEL`] /
8341/// [`M2_LIMITS_KEY_WALL_CLOCK`] / [`M2_LIMITS_KEY_CPU`] (d8b8b4f),
8342/// [`M2_BEHAVIOR_KEY_ON_INIT`] etc. (21fe462),
8343/// [`M2_UPGRADE_FROM_KEY_FROM`] / [`M2_UPGRADE_FROM_KEY_INSTRUCTIONS`]
8344/// (36ffe65), [`M3_PLACEMENT_KEY_ESTRATEGIA`] etc.).
8345pub const SUPERVISOR_AUTHOR_KEY_ESTRATEGIA: &str = ":estrategia";
8346/// Canonical author-facing kebab-case `(defcaixa … :max-restarts <n>)`
8347/// top-level supervisor-tree slot label the OTP `:kind Supervisor`
8348/// caixa's `MaxIntensity` restart-budget counter surfaces under. Peer of
8349/// [`SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] on the sibling supervision-tree
8350/// slot axis; see [`SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] for the full lift
8351/// rationale.
8352pub const SUPERVISOR_AUTHOR_KEY_MAX_RESTARTS: &str = ":max-restarts";
8353/// Canonical author-facing kebab-case
8354/// `(defcaixa … :restart-window "<duration>")` top-level supervisor-tree
8355/// slot label the OTP `:kind Supervisor` caixa's `Period` rolling-window
8356/// counter surfaces under. Peer of [`SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`]
8357/// on the sibling supervision-tree slot axis; see
8358/// [`SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] for the full lift rationale.
8359pub const SUPERVISOR_AUTHOR_KEY_RESTART_WINDOW: &str = ":restart-window";
8360/// Canonical author-facing kebab-case `(defcaixa … :children (…))`
8361/// top-level supervisor-tree slot label the OTP `:kind Supervisor`
8362/// caixa's static child-spec list ([`crate::supervisor::ChildSpec`])
8363/// surfaces under. Peer of [`SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] on the
8364/// sibling supervision-tree slot axis; see
8365/// [`SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] for the full lift rationale.
8366pub const SUPERVISOR_AUTHOR_KEY_CHILDREN: &str = ":children";
8367
8368/// Canonical author-facing kebab-case `(defcaixa … :deps ((…)))` top-
8369/// level dep-list slot label the two-list dependency-graph slot family
8370/// surfaces under. Peer of [`DEP_AUTHOR_KEY_DEPS_DEV`] on the two-list
8371/// dep-graph slot axis: `:deps` names the runtime-closure dep-list
8372/// (every `Cargo.toml [dependencies]` equivalent — reached by every
8373/// build the caixa participates in), the sibling `:deps-dev` names the
8374/// dev-only dep-list (every `Cargo.toml [dev-dependencies]` equivalent
8375/// — reached only by test / dev-shim builds).
8376///
8377/// Threaded verbatim as the `list: &'static str` field on both
8378/// [`crate::DepError::DuplicateNome`] (359fba5) and
8379/// [`crate::DepError::DepIsSelf`] so a `feira lint` diagnostic ("`:deps`
8380/// entry `caixa-teia` is duplicated" / "`:deps-dev` entry `dev-shim` is
8381/// a self-reference") self-locates the offending block in the author's
8382/// `caixa.lisp` without the linter re-deriving the list from context.
8383///
8384/// Until this lift landed the two kebab-case labels sat once each on
8385/// the [`crate::Caixa::validate_deps`] per-list duplicate walk (`list:
8386/// ":deps"` / `list: ":deps-dev"` in `manifest.rs`) and the paired
8387/// [`crate::dep::validate_no_self_dep`] per-list self-edge walk (`list:
8388/// ":deps"` / `list: ":deps-dev"` in `dep.rs`), plus a handful of
8389/// test-side probe literals asserting the `list:` field of a
8390/// `DepError::DuplicateNome` / `DepError::DepIsSelf` carries the
8391/// expected per-list value verbatim — with no compile-time link
8392/// between the two producers and the tests' expected values. A future
8393/// rebrand (a hypothetical `:deps` → `:dependencies` matching Cargo's
8394/// verbatim key, `:deps-dev` → `:dev-dependencies` matching the same,
8395/// `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps` for
8396/// symmetry, or a per-consumer disambiguation as the `defcaixa` macro
8397/// stabilizes) would silently desynchronize the two producers from
8398/// each other and from the tests until a downstream consumer surfaced
8399/// the drift at build time as a matches-arm miss far from the
8400/// rename's commit. This lift closes that gap by routing all halves
8401/// (both production walkers + tests) through two peer consts declared
8402/// adjacent to the peer M2 / M3 / Supervisor top-level author-key
8403/// consts, so the "one canonical declaration per arm, next to the
8404/// axis" discipline the peer [`M2_AUTHOR_KEY_LIMITS`] /
8405/// [`M2_AUTHOR_KEY_BEHAVIOR`] / [`M2_AUTHOR_KEY_UPGRADE_FROM`]
8406/// (f49c8b0), [`M3_AUTHOR_KEY_MEMBROS`] / [`M3_AUTHOR_KEY_CONTRATOS`] /
8407/// [`M3_AUTHOR_KEY_POLITICAS`] / [`M3_AUTHOR_KEY_PLACEMENT`] /
8408/// [`M3_AUTHOR_KEY_ENTRADA`] (882f498), [`SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`]
8409/// etc. (be40492), and [`CONTRATO_AUTHOR_KEY_DE`] /
8410/// [`CONTRATO_AUTHOR_KEY_PARA`] (f50c875) top-level slot / per-entry
8411/// endpoint consts established for the sibling M2 / M3 / Supervisor
8412/// slot axes extends onto the two-list dep-graph slot axis.
8413///
8414/// Byte-identical to the peer [`CAIXA_KEY_DEPS`] renderer-side wire-key
8415/// serde-key axis modulo the leading `:` — the two consts split on the
8416/// axis every dep-graph slot carries (author-facing kebab-case label vs.
8417/// renderer-side wire key). Same "one canonical byte-string per typed
8418/// axis" discipline every peer M2 / M3 renderer-wire-key axis carries.
8419pub const DEP_AUTHOR_KEY_DEPS: &str = ":deps";
8420
8421/// Canonical author-facing kebab-case `(defcaixa … :deps-dev ((…)))`
8422/// top-level dep-list slot label the dev-only two-list dependency-graph
8423/// slot family surfaces under. Peer of [`DEP_AUTHOR_KEY_DEPS`] on the
8424/// two-list dep-graph slot axis; see [`DEP_AUTHOR_KEY_DEPS`] for the
8425/// full lift rationale.
8426pub const DEP_AUTHOR_KEY_DEPS_DEV: &str = ":deps-dev";
8427
8428/// Canonical camelCase JSON/YAML top-level key for
8429/// [`crate::supervisor::SupervisorSpec`]'s `estrategia` restart-strategy
8430/// discriminator — the exact byte-sequence the type's
8431/// `#[serde(rename_all = "camelCase")]` derive emits, and the scalar every
8432/// downstream JSON/YAML consumer that reaches into a serialized
8433/// `SupervisorSpec` (via `Value::get(...)`) must probe on.
8434///
8435/// The scalar is derived from the Rust field name `estrategia` by the
8436/// `rename_all = "camelCase"` derive; `estrategia` has no `_`, so the
8437/// serde transform is a no-op on this axis and the emitted key equals the
8438/// source-side field name byte-for-byte. Lifting the byte to one
8439/// `&'static str` closes the drift footgun structurally: a future
8440/// refactor renaming the Rust field OR retaining the field name while
8441/// adding a `#[serde(rename = "…")]` override would silently emit a
8442/// `SupervisorSpec` whose restart-strategy discriminator lands under one
8443/// key while every downstream consumer still probes another — the
8444/// future wasm-operator's supervisor reconcile posture, the M4
8445/// `caixa.pleme.io/v1alpha1/Supervisor` CR materializer's admission
8446/// webhook, the future `feira lint` supervisor-tree cross-check. The
8447/// identity pin (`supervisor_spec_serde_keys_match_lifted_supervisor_key_consts`
8448/// on the source-side type) catches drift at caixa-core build time
8449/// rather than at the reconciler's dispatch step, far from the rebrand
8450/// commit's source.
8451///
8452/// Peer of the sibling author-facing
8453/// [`SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] (`":estrategia"`) on the same
8454/// per-Supervisor supervision-tree slot axis — that constant names the
8455/// kebab-case `(defcaixa … :estrategia …)` author surface's top-level
8456/// slot label, this one names the camelCase JSON/YAML sub-key the
8457/// serialized `SupervisorSpec` carries the same axis under. Byte-distinct
8458/// from (though semantically related to) the peer
8459/// [`M3_PLACEMENT_KEY_ESTRATEGIA`] (also `"estrategia"`) on the M3
8460/// [`crate::aplicacao::Placement`] axis — that axis carries
8461/// [`crate::aplicacao::PlacementStrategy`] cross-cluster distribution
8462/// semantics, this axis carries [`crate::supervisor::RestartStrategy`]
8463/// OTP supervisor semantics; splitting the two lets each schema's
8464/// future rebrand land independently on the same
8465/// "byte-identical-but-semantically-distinct" discipline the peer
8466/// [`FLEET_PROGRAMS_KEY_NAME`] / [`KUBE_KEY_NAME`] split established.
8467///
8468/// Same "one canonical byte-string per typed serialized-key axis"
8469/// discipline every peer camelCase serde-key lift carries
8470/// ([`M2_LIMITS_KEY_MEMORY`] / [`M2_LIMITS_KEY_FUEL`] /
8471/// [`M2_LIMITS_KEY_WALL_CLOCK`] / [`M2_LIMITS_KEY_CPU`] (d8b8b4f),
8472/// [`M2_BEHAVIOR_KEY_ON_INIT`] etc. (21fe462),
8473/// [`M2_UPGRADE_FROM_KEY_FROM`] / [`M2_UPGRADE_FROM_KEY_INSTRUCTIONS`]
8474/// (36ffe65), [`M3_PLACEMENT_KEY_ESTRATEGIA`] etc.) — extended here to
8475/// close the last of the four top-level typed-struct
8476/// `#[serde(rename_all = "camelCase")]` axes lacking a lifted peer.
8477pub const SUPERVISOR_KEY_ESTRATEGIA: &str = "estrategia";
8478
8479/// Canonical camelCase JSON/YAML top-level key for
8480/// [`crate::supervisor::SupervisorSpec`]'s `max_restarts` axis. Peer of
8481/// [`SUPERVISOR_KEY_ESTRATEGIA`] on the same sibling
8482/// supervision-tree serialized-key axis; see [`SUPERVISOR_KEY_ESTRATEGIA`]
8483/// for the full lift rationale. The Rust field is `snake_case`
8484/// `max_restarts`; `#[serde(rename_all = "camelCase")]` maps it to the
8485/// camelCase JSON key `"maxRestarts"` this constant pins.
8486pub const SUPERVISOR_KEY_MAX_RESTARTS: &str = "maxRestarts";
8487
8488/// Canonical camelCase JSON/YAML top-level key for
8489/// [`crate::supervisor::SupervisorSpec`]'s `restart_window` axis. Peer of
8490/// [`SUPERVISOR_KEY_ESTRATEGIA`] on the same sibling
8491/// supervision-tree serialized-key axis; see [`SUPERVISOR_KEY_ESTRATEGIA`]
8492/// for the full lift rationale. The Rust field is `snake_case`
8493/// `restart_window`; `#[serde(rename_all = "camelCase")]` maps it to the
8494/// camelCase JSON key `"restartWindow"` this constant pins.
8495pub const SUPERVISOR_KEY_RESTART_WINDOW: &str = "restartWindow";
8496
8497/// Canonical camelCase JSON/YAML top-level key for
8498/// [`crate::supervisor::SupervisorSpec`]'s `children` axis. Peer of
8499/// [`SUPERVISOR_KEY_ESTRATEGIA`] on the same sibling
8500/// supervision-tree serialized-key axis; see [`SUPERVISOR_KEY_ESTRATEGIA`]
8501/// for the full lift rationale. The Rust field is lowercase `children`;
8502/// `#[serde(rename_all = "camelCase")]` is a no-op on this axis and the
8503/// emitted key equals the source-side field name byte-for-byte.
8504pub const SUPERVISOR_KEY_CHILDREN: &str = "children";
8505
8506/// Canonical camelCase JSON/YAML top-level key for the
8507/// [`crate::supervisor::ChildSpec`] struct's `caixa` per-entry-name-of-
8508/// the-child-caixa axis — the `caixa:` field the M2 Supervisor's
8509/// `#[serde(rename_all = "camelCase")]` derive on
8510/// [`crate::supervisor::ChildSpec`] emits at each entry of the
8511/// [`crate::supervisor::SupervisorSpec::children`] list, and the exact
8512/// scalar every downstream consumer reaching for the child caixa's
8513/// [`crate::Caixa::nome`] via `Value::get(...)` (the future wasm-operator's
8514/// per-supervisor-tree child resolver, the M4
8515/// `caixa.pleme.io/v1alpha1/Supervisor` CR materializer's admission
8516/// webhook per-child cross-check, the future `feira` supervisor-tree
8517/// walker's per-child name-lookup, the [`caixa_resolver`] per-child
8518/// git-clone step) must probe on.
8519///
8520/// The scalar is derived from the Rust field name `caixa` by the
8521/// `rename_all = "camelCase"` derive; `caixa` has no `_`, so the serde
8522/// transform is a no-op on this axis and the emitted key equals the
8523/// source-side field name byte-for-byte. Lifting the byte to one
8524/// `&'static str` closes the drift footgun structurally: a future
8525/// refactor renaming the Rust field OR retaining the field name while
8526/// adding a `#[serde(rename = "…")]` override would silently emit a
8527/// `ChildSpec` whose per-entry child-caixa discriminator lands under
8528/// one key while every downstream consumer still probes another. The
8529/// identity pin (`child_spec_serde_keys_match_lifted_supervisor_child_key_consts`
8530/// on the source-side type) catches drift at caixa-core build time
8531/// rather than at the reconciler's dispatch step, far from the rebrand
8532/// commit's source.
8533///
8534/// Peer of [`SUPERVISOR_CHILD_KEY_VERSAO`] / [`SUPERVISOR_CHILD_KEY_RESTART`]
8535/// on the same [`crate::supervisor::ChildSpec`] per-entry serialized-key
8536/// axis. Peer of the sibling [`SUPERVISOR_KEY_ESTRATEGIA`] /
8537/// [`SUPERVISOR_KEY_MAX_RESTARTS`] / [`SUPERVISOR_KEY_RESTART_WINDOW`] /
8538/// [`SUPERVISOR_KEY_CHILDREN`] tetrad (40cc4e5) on the enclosing
8539/// [`crate::supervisor::SupervisorSpec`] top-level serialized-key axis
8540/// — that lift pinned the four camelCase JSON keys the M2
8541/// supervision-tree top-level derive emits, this lift extends the same
8542/// discipline onto the sibling per-entry `ChildSpec` derive so the last
8543/// M2 typed-struct sub-block `#[serde(rename_all = "camelCase")]` axis
8544/// on the Supervisor surface without a lifted serde-key peer joins the
8545/// substrate's "one canonical byte-string per typed serialized-key axis"
8546/// discipline.
8547///
8548/// Byte-identical to (but semantically distinct from) the peer
8549/// [`MEMBRO_KEY_CAIXA`] (ce80ca0) on the sibling M3
8550/// [`crate::aplicacao::Membro`] per-`:membros` entry axis — both axes
8551/// carry per-entry caixa-name discriminators on typed list slots, but
8552/// splitting the two lets each schema's future rebrand land
8553/// independently at its canonical const definition without coupling
8554/// the M2 Supervisor per-child axis to the M3 Aplicacao per-member axis
8555/// (or vice versa) — same "byte-identical-but-semantically-distinct"
8556/// discipline the peer [`FLEET_PROGRAMS_KEY_NAME`] / [`KUBE_KEY_NAME`]
8557/// split established.
8558///
8559/// Same "one canonical byte-string per typed serialized-key axis"
8560/// discipline every peer camelCase serde-key lift carries
8561/// ([`M2_LIMITS_KEY_MEMORY`] etc. (d8b8b4f), [`M2_BEHAVIOR_KEY_ON_INIT`]
8562/// etc. (21fe462), [`M2_UPGRADE_FROM_KEY_FROM`] /
8563/// [`M2_UPGRADE_FROM_KEY_INSTRUCTIONS`] (36ffe65),
8564/// [`M3_PLACEMENT_KEY_ESTRATEGIA`] etc., [`SUPERVISOR_KEY_ESTRATEGIA`]
8565/// etc. (40cc4e5), [`MEMBRO_KEY_CAIXA`] / [`MEMBRO_KEY_VERSAO`]
8566/// (ce80ca0), [`CONTRATO_KEY_DE`] / [`CONTRATO_KEY_PARA`] /
8567/// [`CONTRATO_KEY_WIT`] (ca463a4), [`ENTRADA_KEY_HOST`] etc. (a3d6162),
8568/// [`POLITICAS_KEY_TIMEOUT`] etc. (b55cca7), [`CIRCUIT_BREAKER_KEY_MAX_FAILURES`]
8569/// / [`CIRCUIT_BREAKER_KEY_WINDOW`] (468e959)) — extended here to the
8570/// last M2 typed-struct sub-block `#[serde(rename_all = "camelCase")]`
8571/// axis on the Supervisor surface, the per-`:children` entry
8572/// [`crate::supervisor::ChildSpec`] derive.
8573pub const SUPERVISOR_CHILD_KEY_CAIXA: &str = "caixa";
8574
8575/// Canonical camelCase JSON/YAML top-level key for the
8576/// [`crate::supervisor::ChildSpec`] struct's `versao` per-entry-semver-
8577/// constraint-of-the-child axis. Peer of [`SUPERVISOR_CHILD_KEY_CAIXA`]
8578/// on the same [`crate::supervisor::ChildSpec`] per-entry serialized-key
8579/// axis; see [`SUPERVISOR_CHILD_KEY_CAIXA`] for the full lift rationale.
8580/// The Rust field is lowercase `versao`; `#[serde(rename_all = "camelCase")]`
8581/// is a no-op on this axis and the emitted key equals the source-side
8582/// field name byte-for-byte.
8583///
8584/// Byte-identical to (but semantically distinct from) the peer
8585/// [`MEMBRO_KEY_VERSAO`] (ce80ca0) on the sibling M3
8586/// [`crate::aplicacao::Membro`] per-`:membros` entry axis and the peer
8587/// [`FLEET_PROGRAMS_KEY_VERSAO`] on the `lareira-fleet-programs`
8588/// library-chart values-schema axis — same
8589/// "byte-identical-but-semantically-distinct" discipline the peer
8590/// [`FLEET_PROGRAMS_KEY_NAME`] / [`KUBE_KEY_NAME`] /
8591/// [`MEMBRO_KEY_CAIXA`] / [`SUPERVISOR_CHILD_KEY_CAIXA`] splits
8592/// established: each schema's future rebrand lands independently at its
8593/// canonical const definition without coupling one axis to the others.
8594pub const SUPERVISOR_CHILD_KEY_VERSAO: &str = "versao";
8595
8596/// Canonical camelCase JSON/YAML top-level key for the
8597/// [`crate::supervisor::ChildSpec`] struct's `restart` per-entry
8598/// [`crate::supervisor::RestartPolicy`] discriminator axis. Peer of
8599/// [`SUPERVISOR_CHILD_KEY_CAIXA`] on the same
8600/// [`crate::supervisor::ChildSpec`] per-entry serialized-key axis; see
8601/// [`SUPERVISOR_CHILD_KEY_CAIXA`] for the full lift rationale. The Rust
8602/// field is lowercase `restart`; `#[serde(rename_all = "camelCase")]`
8603/// is a no-op on this axis and the emitted key equals the source-side
8604/// field name byte-for-byte.
8605pub const SUPERVISOR_CHILD_KEY_RESTART: &str = "restart";
8606
8607/// Canonical camelCase JSON/YAML top-level key for the
8608/// [`crate::aplicacao::Membro`] struct's `caixa` per-entry-name-of-the-
8609/// member-Servico axis — the `caixa:` field the M3 Aplicacao's
8610/// `#[serde(rename_all = "camelCase")]` derive on [`crate::aplicacao::Membro`]
8611/// emits at each `:membros` entry, and the exact scalar every downstream
8612/// `#[serde(rename_all = "camelCase")]` derive on [`crate::aplicacao::Membro`]
8613/// emits at each `:membros` entry, and the exact scalar every downstream
8614/// consumer reaching for the member's [`crate::Caixa::nome`] via
8615/// `Value::get(...)` (the future wasm-operator's per-`:membros` resolver,
8616/// the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's admission
8617/// webhook, the `feira app graph` verb's per-member name-lookup, the
8618/// [`caixa_resolver`] per-`:membros` git-clone step) must probe on.
8619///
8620/// The scalar is derived from the Rust field name `caixa` by the
8621/// `rename_all = "camelCase"` derive; `caixa` has no `_`, so the
8622/// serde transform is a no-op on this axis and the emitted key equals
8623/// the source-side field name byte-for-byte. Lifting the byte to one
8624/// `&'static str` closes the drift footgun structurally: a future
8625/// refactor renaming the Rust field OR retaining the field name while
8626/// adding a `#[serde(rename = "…")]` override would silently emit a
8627/// `Membro` whose per-entry name discriminator lands under one key while
8628/// every downstream consumer still probes another — the future wasm-
8629/// operator's per-`:membros` resolver, the M4 CR materializer's admission
8630/// webhook, the `feira app graph` verb's per-member name-lookup. The
8631/// identity pin (`membro_serde_keys_match_lifted_membro_key_consts` on
8632/// the source-side type) catches drift at caixa-core build time rather
8633/// than at the reconciler's dispatch step, far from the rebrand commit's
8634/// source.
8635///
8636/// Peer of [`MEMBRO_KEY_VERSAO`] on the same [`crate::aplicacao::Membro`]
8637/// per-entry serialized-key axis. Peer of the sibling
8638/// [`SUPERVISOR_KEY_ESTRATEGIA`] / [`SUPERVISOR_KEY_MAX_RESTARTS`] /
8639/// [`SUPERVISOR_KEY_RESTART_WINDOW`] / [`SUPERVISOR_KEY_CHILDREN`] tetrad
8640/// (40cc4e5) on the sibling `SupervisorSpec` top-level serialized-key
8641/// axis — that lift pinned the four camelCase JSON keys the M2
8642/// supervision-tree top-level derive emits, this lift extends the same
8643/// discipline onto the M3 Aplicacao's per-`:membros` entry derive.
8644///
8645/// Same "one canonical byte-string per typed serialized-key axis"
8646/// discipline every peer camelCase serde-key lift carries
8647/// ([`M2_LIMITS_KEY_MEMORY`] etc. (d8b8b4f), [`M2_BEHAVIOR_KEY_ON_INIT`]
8648/// etc. (21fe462), [`M2_UPGRADE_FROM_KEY_FROM`] /
8649/// [`M2_UPGRADE_FROM_KEY_INSTRUCTIONS`] (36ffe65),
8650/// [`M3_PLACEMENT_KEY_ESTRATEGIA`] etc., [`SUPERVISOR_KEY_ESTRATEGIA`]
8651/// etc. (40cc4e5)) — extended here to the M3 [`crate::aplicacao::Membro`]
8652/// per-entry axis, the last top-level typed-struct
8653/// `#[serde(rename_all = "camelCase")]` axis on the M3 mesh-slot family
8654/// lacking a lifted peer.
8655pub const MEMBRO_KEY_CAIXA: &str = "caixa";
8656
8657/// Canonical camelCase JSON/YAML top-level key for the
8658/// [`crate::aplicacao::Membro`] struct's `versao` per-entry-semver-
8659/// constraint-of-the-member axis. Peer of [`MEMBRO_KEY_CAIXA`] on the
8660/// same [`crate::aplicacao::Membro`] per-entry serialized-key axis; see
8661/// [`MEMBRO_KEY_CAIXA`] for the full lift rationale. The Rust field is
8662/// lowercase `versao`; `#[serde(rename_all = "camelCase")]` is a no-op
8663/// on this axis and the emitted key equals the source-side field name
8664/// byte-for-byte.
8665///
8666/// Byte-identical to [`FLEET_PROGRAMS_KEY_VERSAO`] today — both resolve
8667/// to the same six-byte `"versao"` literal — but semantically distinct:
8668/// [`FLEET_PROGRAMS_KEY_VERSAO`] names the `lareira-fleet-programs`
8669/// library chart's per-entry version-constraint schema-axis (spelled
8670/// per the chart's `values.schema.json` — the same schema surface
8671/// [`caixa_mesh::programs_for_aplicacao`] transcribes each `:membros`
8672/// entry's version constraint into), while this constant names the
8673/// [`crate::aplicacao::Membro`] typed struct's derive-emitted `versao`
8674/// field key (spelled per the type's `#[serde(rename_all = "camelCase")]`
8675/// attribute — a separate schema contract on the upstream typed
8676/// manifest). Splitting the two lets each schema's future rebrand land
8677/// independently at its canonical const definition without coupling the
8678/// Membro typed-struct axis to the fleet-programs values-schema axis
8679/// (or vice versa) — same "byte-identical-but-semantically-distinct"
8680/// discipline the peer [`FLEET_PROGRAMS_KEY_NAME`] / [`KUBE_KEY_NAME`]
8681/// split established on the sibling per-entry name-discriminator axis.
8682pub const MEMBRO_KEY_VERSAO: &str = "versao";
8683
8684/// Canonical camelCase JSON/YAML top-level key for the
8685/// [`crate::aplicacao::WitContract`] struct's `de` per-entry
8686/// source-endpoint-of-the-contract axis — the `de:` field the M3
8687/// Aplicacao's `#[serde(rename_all = "camelCase")]` derive on
8688/// [`crate::aplicacao::WitContract`] emits at each `:contratos` entry,
8689/// and the exact scalar every downstream consumer reaching for the
8690/// caller-Servico name via `Value::get(...)` (the future
8691/// wasm-operator's per-`:contratos` edge resolver, the M4
8692/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's admission
8693/// webhook per-edge cross-check, the `feira app graph` verb's per-edge
8694/// tail-label lookup, the future per-`:contratos` `CiliumNetworkPolicy`
8695/// emitter's per-edge `fromEndpoints` selector projection) must probe on.
8696///
8697/// The scalar is derived from the Rust field name `de` by the
8698/// `rename_all = "camelCase"` derive; `de` has no `_`, so the serde
8699/// transform is a no-op on this axis and the emitted key equals the
8700/// source-side field name byte-for-byte. Lifting the byte to one
8701/// `&'static str` closes the drift footgun structurally: a future
8702/// refactor renaming the Rust field OR retaining the field name while
8703/// adding a `#[serde(rename = "…")]` override would silently emit a
8704/// `WitContract` whose per-entry caller-Servico discriminator lands
8705/// under one key while every downstream consumer still probes another —
8706/// the future wasm-operator's per-`:contratos` edge resolver, the M4 CR
8707/// materializer's admission webhook per-edge cross-check, the
8708/// `feira app graph` verb's per-edge tail-label lookup. The identity pin
8709/// (`wit_contract_serde_keys_match_lifted_contrato_key_consts` on the
8710/// source-side type) catches drift at caixa-core build time rather than
8711/// at the reconciler's dispatch step, far from the rebrand commit's
8712/// source.
8713///
8714/// Peer of [`CONTRATO_KEY_PARA`] / [`CONTRATO_KEY_WIT`] on the same
8715/// [`crate::aplicacao::WitContract`] per-entry serialized-key axis. Peer
8716/// of the sibling [`MEMBRO_KEY_CAIXA`] / [`MEMBRO_KEY_VERSAO`] pair
8717/// (ce80ca0) on the sibling M3 [`crate::aplicacao::Membro`] per-entry
8718/// serialized-key axis — that lift pinned the two camelCase JSON keys
8719/// the M3 per-`:membros` derive emits, this lift extends the same
8720/// discipline onto the sibling M3 per-`:contratos` derive so the last
8721/// M3 mesh-slot atom top-level `#[serde(rename_all = "camelCase")]`
8722/// axis on the Aplicacao surface without a lifted peer joins the
8723/// substrate's "one canonical byte-string per typed serialized-key
8724/// axis" discipline.
8725///
8726/// Byte-identical to (but semantically distinct from) the sibling
8727/// author-facing kebab-case [`CONTRATO_AUTHOR_KEY_DE`] (f50c875) modulo
8728/// the leading `:` — the two consts split on the axis every M3 mesh-slot
8729/// atom carries (author-facing kebab-case label vs. renderer-side
8730/// camelCase overlay key), the same split the [`M2_AUTHOR_KEY_LIMITS`] /
8731/// [`M2_KEY_LIMITS`] peer pair established on the sibling M2 axis and
8732/// the [`M3_AUTHOR_KEY_PLACEMENT`] / [`M3_KEY_PLACEMENT`] peer pair
8733/// established on the sibling M3 top-level slot axis.
8734pub const CONTRATO_KEY_DE: &str = "de";
8735
8736/// Canonical camelCase JSON/YAML top-level key for the
8737/// [`crate::aplicacao::WitContract`] struct's `para` per-entry
8738/// target-endpoint-of-the-contract axis. Peer of [`CONTRATO_KEY_DE`] on
8739/// the same [`crate::aplicacao::WitContract`] per-entry serialized-key
8740/// axis; see [`CONTRATO_KEY_DE`] for the full lift rationale. The Rust
8741/// field is lowercase `para`; `#[serde(rename_all = "camelCase")]` is a
8742/// no-op on this axis and the emitted key equals the source-side field
8743/// name byte-for-byte.
8744pub const CONTRATO_KEY_PARA: &str = "para";
8745
8746/// Canonical camelCase JSON/YAML top-level key for the
8747/// [`crate::aplicacao::WitContract`] struct's `wit` per-entry
8748/// WIT-world-reference-of-the-contract axis — the discriminator every
8749/// downstream WIT-shape dispatcher ([`crate::wit_shape_is_http`] /
8750/// [`crate::wit_shape_is_pubsub`] / [`crate::wit_shape_is_store`], the
8751/// future M4 per-edge WIT registry resolver, the future
8752/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's admission-time
8753/// WIT-world classification) keys off. Peer of [`CONTRATO_KEY_DE`] on
8754/// the same [`crate::aplicacao::WitContract`] per-entry serialized-key
8755/// axis; see [`CONTRATO_KEY_DE`] for the full lift rationale. The Rust
8756/// field is lowercase `wit`; `#[serde(rename_all = "camelCase")]` is a
8757/// no-op on this axis and the emitted key equals the source-side field
8758/// name byte-for-byte.
8759pub const CONTRATO_KEY_WIT: &str = "wit";
8760
8761/// Canonical camelCase YAML sub-key for the [`crate::aplicacao::Placement`]
8762/// struct's `estrategia` distribution-strategy discriminator — the
8763/// per-`M3_KEY_PLACEMENT`-block field the M3 [`crate::aplicacao::PlacementStrategy`]
8764/// enum's `Serialize` derive emits, and the exact scalar every downstream
8765/// consumer dispatches on:
8766///
8767/// - the `lareira-fleet-programs` aggregator's per-entry strategy dispatch
8768/// (each `programs[].placement.estrategia` reads `"SingleNode"` /
8769/// `"Replicated"` / `"Sharded"` verbatim to select the takeover
8770/// semantics per MESH-COMPOSITION.md §II.1),
8771/// - the future `app-operator` reconciler's per-Aplicacao strategy branch,
8772/// - the future `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
8773/// admission-time `spec.placement.estrategia` typed-enum bind,
8774/// - and every M3 Adaptive weighting the compression pass reads off
8775/// `placement.estrategia` per MESH-COMPOSITION.md §V.
8776///
8777/// The scalar is derived by [`crate::aplicacao::Placement`]'s
8778/// `#[serde(rename_all = "camelCase")]` from the Rust field name
8779/// `estrategia`; `estrategia` has no `_`, so the serde transform is a
8780/// no-op on this axis and the emitted key equals the source-side field
8781/// name byte-for-byte. Lifting the byte to one `&'static str` closes
8782/// the drift footgun structurally: a future refactor renaming the Rust
8783/// field (`estrategia` → `strategy` for English-uniformity, `distribution`
8784/// for schema-clarity, etc.) OR retaining the field name while adding
8785/// a `#[serde(rename = "…")]` override would silently emit a
8786/// `placement:` block whose distribution-strategy discriminator lands
8787/// under one key while every downstream consumer still probes another —
8788/// the aggregator's dispatch, the operator's reconcile, the CR
8789/// materializer's admission bind would each silently no-op, and the
8790/// workload would silently come up under the strategy's serde-derived
8791/// default rather than the per-Aplicacao override the typed slot set.
8792/// The identity pin + serde round-trip pin the sweep introduces catch
8793/// the drift at caixa-core / caixa-mesh build time rather than at the
8794/// aggregator's filter step or the operator's reconcile posture, far
8795/// from the rebrand commit's source.
8796///
8797/// Peer of [`M3_KEY_PLACEMENT`] on the same programs.yaml per-entry
8798/// axis — that constant names the top-level overlay key the entry
8799/// carries, this one names the per-`placement:` sub-block strategy
8800/// discriminator every consumer dispatches on. Byte-identical to (but
8801/// semantically distinct from) [`crate::supervisor::SupervisorSpec`]'s
8802/// peer `estrategia` field on the M2 supervisor-strategy axis — that
8803/// axis carries [`crate::supervisor::RestartStrategy`] (`OneForOne` /
8804/// `OneForAll` / `RestForOne` / `SimpleOneForOne`, OTP supervisor
8805/// semantics) while this axis carries [`crate::aplicacao::PlacementStrategy`]
8806/// (`SingleNode` / `Replicated` / `Sharded`, cross-cluster distribution
8807/// semantics); splitting the two lets each schema's future rebrand
8808/// land independently on the same byte-identical-but-semantically-
8809/// distinct discipline the [`FLEET_PROGRAMS_KEY_NAME`] / [`KUBE_KEY_NAME`]
8810/// split established.
8811pub const M3_PLACEMENT_KEY_ESTRATEGIA: &str = "estrategia";
8812
8813/// Canonical camelCase YAML sub-key for the [`crate::aplicacao::Placement`]
8814/// struct's `clusters` cluster-pool axis — the per-`M3_KEY_PLACEMENT`-block
8815/// field carrying the validated cluster-list (non-empty + duplicate-free
8816/// per [`crate::aplicacao::AplicacaoSpec::validate_placement`]) that every
8817/// downstream cross-cluster consumer filters off:
8818///
8819/// - the `lareira-fleet-programs` aggregator's per-cluster fanout filter
8820/// (each cluster's aggregator scopes `.Values.programs` by
8821/// `.placement.clusters | contains .Values.cluster`, so a workload's
8822/// `clusters: [rio, mar]` list ends up landing on rio + mar and no other
8823/// cluster per MESH-COMPOSITION.md §III.4),
8824/// - the future `app-operator` reconciler's per-Aplicacao cluster-set
8825/// dispatch,
8826/// - the future `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
8827/// admission-time `spec.placement.clusters` typed-list bind, and
8828/// - the M3 Adaptive compression pass's per-cluster weight lookup per
8829/// MESH-COMPOSITION.md §V.
8830///
8831/// The scalar is derived by [`crate::aplicacao::Placement`]'s
8832/// `#[serde(rename_all = "camelCase")]` from the Rust field name
8833/// `clusters`; `clusters` has no `_`, so the serde transform is a no-op
8834/// on this axis and the emitted key equals the source-side field name
8835/// byte-for-byte. Lifting the byte to one `&'static str` closes the same
8836/// drift footgun the peer [`M3_PLACEMENT_KEY_ESTRATEGIA`] lift closed on
8837/// the sibling distribution-strategy discriminator: a future refactor
8838/// renaming the Rust field (`clusters` → `clusterPool` for schema-clarity,
8839/// `sites` for eventual multi-substrate reach, etc.) OR retaining the
8840/// field name while adding a `#[serde(rename = "…")]` override would
8841/// silently emit a `placement:` block whose cluster-list lands under one
8842/// key while every downstream consumer still probes another — the
8843/// aggregator's per-cluster fanout filter would then see an empty
8844/// `clusters` list on every entry and silently drop every workload from
8845/// every cluster (the failure surfacing as "the newly-deployed Aplicacao
8846/// never spins up anywhere" far from the rebrand commit's source). The
8847/// identity pin + serde-derive round-trip pin the sweep introduces catch
8848/// the drift at caixa-core / caixa-mesh build time rather than at the
8849/// aggregator's fanout step or the operator's reconcile posture.
8850///
8851/// Peer of [`M3_KEY_PLACEMENT`] / [`M3_PLACEMENT_KEY_ESTRATEGIA`] on the
8852/// same programs.yaml per-entry axis — `M3_KEY_PLACEMENT` names the
8853/// top-level overlay key each entry carries, `M3_PLACEMENT_KEY_ESTRATEGIA`
8854/// names the per-sub-block distribution-strategy discriminator every
8855/// dispatch consumer branches on, this constant names the per-sub-block
8856/// cluster-pool list every per-cluster fanout consumer scopes by.
8857pub const M3_PLACEMENT_KEY_CLUSTERS: &str = "clusters";
8858
8859/// Canonical camelCase YAML sub-key for the [`crate::aplicacao::Placement`]
8860/// struct's `affinity` placement-engine-hint axis — the per-`M3_KEY_PLACEMENT`-
8861/// block optional field carrying the validated non-empty affinity hint
8862/// (per [`crate::aplicacao::AplicacaoSpec::validate_placement`]) that every
8863/// downstream placement-hint consumer weights off:
8864///
8865/// - the `lareira-fleet-programs` aggregator's per-entry M3 Adaptive
8866/// compression pass reading `placement.affinity` to weight the emitted
8867/// `ComputeUnit`'s replica-distribution overlay per MESH-COMPOSITION.md §V,
8868/// - the future `app-operator` reconciler's per-Aplicacao pod-affinity /
8869/// node-affinity K8s-primitive materializer keying off the same value as
8870/// an `app.pleme.io/affinity-hint=<value>` label selector,
8871/// - the future `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
8872/// admission-time `spec.placement.affinity` typed-string bind, and
8873/// - the M4 cross-cluster placement engine's per-hint takeover-priority
8874/// dispatch on the same value (`data-locality` / `low-latency` /
8875/// `anti-affinity` per the [`crate::aplicacao::validate_placement_affinity`]
8876/// value-shape gate's documented canonical hint set).
8877///
8878/// The scalar is derived by [`crate::aplicacao::Placement`]'s
8879/// `#[serde(rename_all = "camelCase")]` from the Rust field name
8880/// `affinity`; `affinity` has no `_`, so the serde transform is a no-op on
8881/// this axis and the emitted key equals the source-side field name
8882/// byte-for-byte. Unlike the always-emitted [`M3_PLACEMENT_KEY_ESTRATEGIA`]
8883/// / [`M3_PLACEMENT_KEY_CLUSTERS`] axes, the `affinity` field carries a
8884/// `#[serde(skip_serializing_if = "Option::is_none")]` attribute so the
8885/// key appears in the rendered `placement:` block iff the typed slot
8886/// resolves to `Some(_)` — the omit-when-unset contract the peer typed
8887/// slots ([`crate::aplicacao::MeshPolicy::timeout`],
8888/// [`crate::aplicacao::MeshPolicy::retries`],
8889/// [`crate::aplicacao::MeshPolicy::mtls_required`]) each carry to keep an
8890/// unset typed slot from bloating every rendered programs.yaml entry with
8891/// a nominal-only `affinity: null` value the downstream weighting passes
8892/// would then need to unwrap defensively.
8893///
8894/// Lifting the byte to one `&'static str` closes the same drift footgun
8895/// the peer [`M3_PLACEMENT_KEY_ESTRATEGIA`] / [`M3_PLACEMENT_KEY_CLUSTERS`]
8896/// lifts closed on the sibling always-emitted axes: a future refactor
8897/// renaming the Rust field (`affinity` → `affinityHint` for schema-clarity,
8898/// `placementHint` for symmetry with the future per-cluster affinity
8899/// hierarchy, etc.) OR retaining the field name while adding a
8900/// `#[serde(rename = "…")]` override would silently emit a `placement:`
8901/// block whose affinity hint lands under one key while every downstream
8902/// weighting consumer still probes another — the M3 Adaptive compression
8903/// pass would then see a `None` affinity on every entry and silently fall
8904/// back to the uniform-weight baseline (the workload's typed
8905/// `:affinity "data-locality"` hint would be silently discarded, and the
8906/// failure surfaces as "the newly-deployed Aplicacao's replicas don't
8907/// cluster where the typed slot said they should" far from the rebrand
8908/// commit's source). The identity pin + serde-derive round-trip pin the
8909/// sweep introduces catch the drift at caixa-core / caixa-mesh build time
8910/// rather than at the aggregator's weighting step or the operator's
8911/// reconcile posture.
8912///
8913/// Peer of [`M3_KEY_PLACEMENT`] / [`M3_PLACEMENT_KEY_ESTRATEGIA`] /
8914/// [`M3_PLACEMENT_KEY_CLUSTERS`] on the same programs.yaml per-entry
8915/// axis — `M3_KEY_PLACEMENT` names the top-level overlay key each entry
8916/// carries, `M3_PLACEMENT_KEY_ESTRATEGIA` names the per-sub-block
8917/// distribution-strategy discriminator every dispatch consumer branches
8918/// on, `M3_PLACEMENT_KEY_CLUSTERS` names the per-sub-block cluster-pool
8919/// list every per-cluster fanout consumer scopes by, this constant names
8920/// the per-sub-block optional placement-engine hint every weighting
8921/// consumer reads off.
8922pub const M3_PLACEMENT_KEY_AFFINITY: &str = "affinity";
8923
8924/// Canonical camelCase YAML sub-key for the [`crate::aplicacao::Placement`]
8925/// struct's `shard_key` shard-selection-template axis — the per-`M3_KEY_PLACEMENT`-
8926/// block optional field carrying the validated non-empty shard-key
8927/// template (per [`crate::aplicacao::AplicacaoSpec::validate_placement`]'s
8928/// `ShardedKeyEmpty` arm — the build rejects any `:placement Sharded`
8929/// that omits the slot, and rejects any non-Sharded strategy that
8930/// carries the slot as `ShardKeyOnNonSharded`) that every downstream
8931/// shard-dispatch consumer materializes off:
8932///
8933/// - the `lareira-fleet-programs` aggregator's per-entry M3 shard-pool
8934/// dispatch materializer keying off `placement.shardKey` to hash each
8935/// incoming entity into the per-cluster shard pool the Akka-style
8936/// cluster-sharding reconciler owns (per MESH-COMPOSITION.md §II.4);
8937/// - the future `app-operator` reconciler's per-Aplicacao
8938/// `ShardedResource` CR emitter binding the typed template to the
8939/// K8s-primitive shard-assignment controller's `spec.hashKey`;
8940/// - the future `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
8941/// admission-time `spec.placement.shardKey` typed-string bind, and
8942/// - the M4 Orleans-style virtual-actor runtime's per-grain
8943/// placement dispatch reading the same value as the grain-identity
8944/// hash source (per RUNTIME-PATTERNS.md's virtual-actor pattern
8945/// entry).
8946///
8947/// The scalar is derived by [`crate::aplicacao::Placement`]'s
8948/// `#[serde(rename_all = "camelCase")]` from the Rust field name
8949/// `shard_key`; unlike the peer `affinity` / `clusters` / `estrategia`
8950/// axes (whose field names carry no `_`, so the serde transform is a
8951/// no-op), the `shard_key` field's `snake_case` name is actively
8952/// transformed by the derive to `shardKey` — the emitted key differs
8953/// from the source-side field name and the drift-footgun surface is
8954/// therefore correspondingly larger. Unlike the always-emitted
8955/// [`M3_PLACEMENT_KEY_ESTRATEGIA`] / [`M3_PLACEMENT_KEY_CLUSTERS`]
8956/// axes, the `shard_key` field carries a
8957/// `#[serde(skip_serializing_if = "Option::is_none")]` attribute so the
8958/// key appears in the rendered `placement:` block iff the typed slot
8959/// resolves to `Some(_)` — the omit-when-unset contract the peer typed
8960/// slots ([`M3_PLACEMENT_KEY_AFFINITY`],
8961/// [`crate::aplicacao::MeshPolicy::timeout`],
8962/// [`crate::aplicacao::MeshPolicy::retries`],
8963/// [`crate::aplicacao::MeshPolicy::mtls_required`]) each carry to keep
8964/// an unset typed slot from bloating every rendered programs.yaml
8965/// entry with a nominal-only `shardKey: null` value the downstream
8966/// shard-dispatch passes would then need to unwrap defensively.
8967///
8968/// Lifting the byte to one `&'static str` closes the same drift footgun
8969/// the peer [`M3_PLACEMENT_KEY_ESTRATEGIA`] / [`M3_PLACEMENT_KEY_CLUSTERS`]
8970/// / [`M3_PLACEMENT_KEY_AFFINITY`] lifts closed on the sibling axes:
8971/// a future refactor renaming the Rust field (`shard_key` →
8972/// `partition_key` for Kafka-symmetric naming, `entity_key` for
8973/// Akka/Orleans-symmetric naming, `hash_key` for schema-clarity, etc.)
8974/// OR retaining the field name while adding a `#[serde(rename = "…")]`
8975/// override OR dropping the struct-level `rename_all = "camelCase"`
8976/// attribute would silently emit a `placement:` block whose shard-
8977/// selection template lands under one key while every downstream shard-
8978/// dispatch consumer still probes another — the M3 shard-pool
8979/// dispatch materializer would then see a `None` shard-key on every
8980/// entry and silently fall back to the per-entry random-placement
8981/// baseline (the workload's typed `:shard-key "$tenantId"` template
8982/// would be silently discarded, and per-tenant entities would scatter
8983/// across every cluster in the pool instead of consistently landing on
8984/// one — the failure surfaces as "the newly-deployed sharded Aplicacao
8985/// mysteriously loses its per-tenant locality" far from the rebrand
8986/// commit's source, and Cilium's per-entity trace surfaces the
8987/// symptom only in hubble traces of the actual data-plane skew, not in
8988/// `kubectl describe`). The identity pin + serde-derive round-trip
8989/// pin the sweep introduces catch the drift at caixa-core / caixa-mesh
8990/// build time rather than at the aggregator's shard-dispatch step or
8991/// the operator's reconcile posture. The serde-derive pin is
8992/// particularly load-bearing on this axis (relative to the peer
8993/// `affinity` / `clusters` / `estrategia` pins) because the underlying
8994/// derive transform is *not* a no-op — the emitted `shardKey` key
8995/// differs from the source-side `shard_key` field by construction,
8996/// so any rebrand that touches either endpoint of the transform (the
8997/// field name OR the `rename_all` attribute OR a per-field `rename`
8998/// override) reaches this pin's assertion by construction.
8999///
9000/// Peer of [`M3_KEY_PLACEMENT`] / [`M3_PLACEMENT_KEY_ESTRATEGIA`] /
9001/// [`M3_PLACEMENT_KEY_CLUSTERS`] / [`M3_PLACEMENT_KEY_AFFINITY`] on the
9002/// same programs.yaml per-entry axis — `M3_KEY_PLACEMENT` names the
9003/// top-level overlay key each entry carries, `M3_PLACEMENT_KEY_ESTRATEGIA`
9004/// names the per-sub-block distribution-strategy discriminator every
9005/// dispatch consumer branches on, `M3_PLACEMENT_KEY_CLUSTERS` names the
9006/// per-sub-block cluster-pool list every per-cluster fanout consumer
9007/// scopes by, `M3_PLACEMENT_KEY_AFFINITY` names the per-sub-block
9008/// optional placement-engine hint every weighting consumer reads off,
9009/// this constant names the per-sub-block optional shard-selection
9010/// template every shard-dispatch consumer materializes off. Completes
9011/// the M3 `Placement` sub-key quartet's canonical-key lift alongside
9012/// the sibling always-emitted axes.
9013pub const M3_PLACEMENT_KEY_SHARD_KEY: &str = "shardKey";
9014
9015/// Canonical M3 [`crate::aplicacao::PlacementStrategy::SingleNode`]
9016/// variant discriminator scalar-value — the exact byte-string the
9017/// `Serialize` derive on the un-`rename`d enum emits under
9018/// [`M3_PLACEMENT_KEY_ESTRATEGIA`] whenever the typed slot's
9019/// distribution strategy is the single-cluster-active-at-a-time arm
9020/// (OTP distributed-application takeover, MESH-COMPOSITION.md §II.1).
9021///
9022/// The scalar every downstream cluster-side dispatcher probes verbatim
9023/// to pick the takeover semantics:
9024///
9025/// - the `lareira-fleet-programs` aggregator's per-entry
9026/// `placement.estrategia` strategy dispatch (`if $strat ==
9027/// "SingleNode" { ... }`),
9028/// - the future `app-operator` reconciler's per-Aplicacao
9029/// strategy-branch (`match placement.estrategia { "SingleNode" =>
9030/// … }`),
9031/// - the future `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
9032/// admission-time enum-arm bind, and
9033/// - the M3 Adaptive compression pass's per-strategy weighting per
9034/// MESH-COMPOSITION.md §V.
9035///
9036/// The scalar is derived by `#[derive(Serialize)]` on the
9037/// [`crate::aplicacao::PlacementStrategy`] enum with no
9038/// `#[serde(rename_all = …)]` attribute, so the emitted string is
9039/// byte-for-byte the source-side variant name. Lifting the byte to
9040/// one `&'static str` closes the drift footgun structurally: a future
9041/// refactor renaming the variant (`SingleNode` → `Singleton` for OTP-
9042/// vocabulary parity, `Active` for shorter-form-clarity, etc.) OR
9043/// adding a `#[serde(rename_all = "kebab-case")]` attribute would
9044/// silently emit a `placement.estrategia:` scalar whose distribution
9045/// strategy lands under one spelling while every downstream consumer
9046/// still dispatches on another — the aggregator's strategy branch,
9047/// the operator's reconcile posture, the CR materializer's
9048/// admission-time enum-arm bind would each silently no-op onto the
9049/// enum's `default()` (`Replicated`) and the workload would come up
9050/// on every declared cluster active-active rather than the
9051/// single-cluster-takeover the typed slot named. The serde
9052/// round-trip pin the sweep introduces
9053/// ([`crate::aplicacao::tests::placement_strategy_variants_serialize_to_lifted_scalar_values`])
9054/// catches the drift at caixa-core build time rather than at the
9055/// aggregator's dispatch step or the operator's reconcile posture.
9056///
9057/// Peer of [`M3_PLACEMENT_ESTRATEGIA_REPLICATED`] /
9058/// [`M3_PLACEMENT_ESTRATEGIA_SHARDED`] on the same closed
9059/// PlacementStrategy enum surface — together the three constants
9060/// name every author-reachable arm of the M3 distribution-strategy
9061/// discriminator, mirroring the closed-enum-scalar-value trajectory
9062/// [`CILIUM_AUTH_MODE_REQUIRED`] / [`CILIUM_AUTH_MODE_DISABLED`]
9063/// (8ab119f) established on the sibling Cilium
9064/// `MutualAuthenticationMode` OpenAPI schema enum.
9065pub const M3_PLACEMENT_ESTRATEGIA_SINGLE_NODE: &str = "SingleNode";
9066
9067/// Canonical M3 [`crate::aplicacao::PlacementStrategy::Replicated`]
9068/// variant discriminator scalar-value — the exact byte-string the
9069/// `Serialize` derive on the un-`rename`d enum emits under
9070/// [`M3_PLACEMENT_KEY_ESTRATEGIA`] whenever the typed slot's
9071/// distribution strategy is the every-cluster-active-active arm (the
9072/// enum's `default()` and the canonical happy-path per
9073/// MESH-COMPOSITION.md §II.1).
9074///
9075/// Peer of the sibling [`M3_PLACEMENT_ESTRATEGIA_SINGLE_NODE`] /
9076/// [`M3_PLACEMENT_ESTRATEGIA_SHARDED`] scalars on the same closed
9077/// enum surface — see the sibling doc for the full drift-mode
9078/// analysis. This is the arm the un-`:placement` (`Placement::default()`)
9079/// path serializes as, so drift here silently rebrands the substrate's
9080/// default distribution posture across every Aplicacao that never
9081/// declares the slot explicitly.
9082pub const M3_PLACEMENT_ESTRATEGIA_REPLICATED: &str = "Replicated";
9083
9084/// Canonical M3 [`crate::aplicacao::PlacementStrategy::Sharded`]
9085/// variant discriminator scalar-value — the exact byte-string the
9086/// `Serialize` derive on the un-`rename`d enum emits under
9087/// [`M3_PLACEMENT_KEY_ESTRATEGIA`] whenever the typed slot's
9088/// distribution strategy is the hash-keyed-across-clusters arm (Akka
9089/// cluster sharding, MESH-COMPOSITION.md §II.4). The one arm on which
9090/// the typed [`M3_PLACEMENT_KEY_SHARD_KEY`] sub-block is required —
9091/// `AplicacaoSpec::validate_placement` gates `shard_key.is_some() ==
9092/// matches!(estrategia, Sharded)` as a structural partition of every
9093/// validated [`crate::aplicacao::Placement`].
9094///
9095/// Peer of the sibling [`M3_PLACEMENT_ESTRATEGIA_SINGLE_NODE`] /
9096/// [`M3_PLACEMENT_ESTRATEGIA_REPLICATED`] scalars on the same closed
9097/// enum surface — see the [`M3_PLACEMENT_ESTRATEGIA_SINGLE_NODE`] doc
9098/// for the full drift-mode analysis. This is the arm the future Akka-
9099/// style cluster-sharding reconciler dispatches on before hashing
9100/// `placement.shardKey` across `placement.clusters`, so drift here
9101/// silently collapses the hash-keyed distribution back onto the
9102/// aggregator's default (Replicated) and every sharded workload's
9103/// per-entity routing invariant vanishes at the data plane.
9104pub const M3_PLACEMENT_ESTRATEGIA_SHARDED: &str = "Sharded";
9105
9106/// Canonical M2 [`crate::supervisor::RestartStrategy::OneForOne`] variant
9107/// discriminator scalar-value — the exact byte-string the `Serialize`
9108/// derive on the un-`rename`d enum emits under
9109/// [`SUPERVISOR_KEY_ESTRATEGIA`] whenever the typed `:supervisor
9110/// :estrategia` slot's strategy is the restart-only-the-failed-child arm
9111/// (the enum's `default()` and the canonical happy-path per
9112/// theory/INSPIRATIONS.md §II.2 — Erlang/OTP `one_for_one`).
9113///
9114/// The scalar is the un-`rename`d Rust variant name verbatim; a future
9115/// `#[serde(rename_all = "kebab-case")]` attribute on the enum, or a
9116/// per-variant `#[serde(rename = "…")]` override, or a variant rename in
9117/// the source, would silently emit a `:supervisor :estrategia` scalar
9118/// whose per-failure sibling-restart discipline lands under one spelling
9119/// while every downstream consumer still dispatches on another — the
9120/// future wasm-operator's per-supervisor sibling-restart branch, the
9121/// future M4 `mesh.pleme.io/v1alpha1/Supervisor` CR materializer's
9122/// admission-time enum-arm bind, the `caixa-operator`'s hierarchical
9123/// reconciliation scheduler's per-strategy fan-out would each silently
9124/// no-op onto the enum's `default()` (`OneForOne`) and the tree would
9125/// come up with the wrong sibling-restart posture on every non-default
9126/// arm. The serde round-trip pin the sweep introduces
9127/// ([`crate::supervisor::tests::restart_strategy_variants_serialize_to_lifted_scalar_values`])
9128/// catches the drift at caixa-core build time rather than at the
9129/// operator's reconcile posture.
9130///
9131/// Peer of [`SUPERVISOR_ESTRATEGIA_ONE_FOR_ALL`] /
9132/// [`SUPERVISOR_ESTRATEGIA_REST_FOR_ONE`] /
9133/// [`SUPERVISOR_ESTRATEGIA_SIMPLE_ONE_FOR_ONE`] on the same closed
9134/// [`crate::supervisor::RestartStrategy`] enum surface — together the
9135/// four constants name every author-reachable arm of the OTP-shaped
9136/// per-supervisor sibling-restart discriminator, mirroring the
9137/// closed-enum-scalar-value trajectory [`M3_PLACEMENT_ESTRATEGIA_SINGLE_NODE`]
9138/// / [`M3_PLACEMENT_ESTRATEGIA_REPLICATED`] /
9139/// [`M3_PLACEMENT_ESTRATEGIA_SHARDED`] (3f0e21c) established on the
9140/// sibling M3 `PlacementStrategy` enum on the peer per-Aplicacao
9141/// distribution-strategy axis.
9142pub const SUPERVISOR_ESTRATEGIA_ONE_FOR_ONE: &str = "OneForOne";
9143
9144/// Canonical M2 [`crate::supervisor::RestartStrategy::OneForAll`] variant
9145/// discriminator scalar-value — the exact byte-string the `Serialize`
9146/// derive on the un-`rename`d enum emits under
9147/// [`SUPERVISOR_KEY_ESTRATEGIA`] whenever the typed `:supervisor
9148/// :estrategia` slot's strategy is the restart-every-sibling-on-any-
9149/// failure arm (Erlang/OTP `one_for_all`, used when children share state
9150/// and must be in sync).
9151///
9152/// Peer of the sibling [`SUPERVISOR_ESTRATEGIA_ONE_FOR_ONE`] /
9153/// [`SUPERVISOR_ESTRATEGIA_REST_FOR_ONE`] /
9154/// [`SUPERVISOR_ESTRATEGIA_SIMPLE_ONE_FOR_ONE`] scalars on the same
9155/// closed enum surface — see the sibling
9156/// [`SUPERVISOR_ESTRATEGIA_ONE_FOR_ONE`] doc for the full drift-mode
9157/// analysis.
9158pub const SUPERVISOR_ESTRATEGIA_ONE_FOR_ALL: &str = "OneForAll";
9159
9160/// Canonical M2 [`crate::supervisor::RestartStrategy::RestForOne`]
9161/// variant discriminator scalar-value — the exact byte-string the
9162/// `Serialize` derive on the un-`rename`d enum emits under
9163/// [`SUPERVISOR_KEY_ESTRATEGIA`] whenever the typed `:supervisor
9164/// :estrategia` slot's strategy is the restart-failed-and-later-started-
9165/// siblings arm (Erlang/OTP `rest_for_one`, used when later children
9166/// depend on earlier ones so the startup-order suffix must be
9167/// re-established).
9168///
9169/// Peer of the sibling [`SUPERVISOR_ESTRATEGIA_ONE_FOR_ONE`] /
9170/// [`SUPERVISOR_ESTRATEGIA_ONE_FOR_ALL`] /
9171/// [`SUPERVISOR_ESTRATEGIA_SIMPLE_ONE_FOR_ONE`] scalars on the same
9172/// closed enum surface — see the sibling
9173/// [`SUPERVISOR_ESTRATEGIA_ONE_FOR_ONE`] doc for the full drift-mode
9174/// analysis.
9175pub const SUPERVISOR_ESTRATEGIA_REST_FOR_ONE: &str = "RestForOne";
9176
9177/// Canonical M2 [`crate::supervisor::RestartStrategy::SimpleOneForOne`]
9178/// variant discriminator scalar-value — the exact byte-string the
9179/// `Serialize` derive on the un-`rename`d enum emits under
9180/// [`SUPERVISOR_KEY_ESTRATEGIA`] whenever the typed `:supervisor
9181/// :estrategia` slot's strategy is the dynamic-children-of-one-shape arm
9182/// (Erlang/OTP `simple_one_for_one`, the one arm on which
9183/// [`crate::supervisor::SupervisorSpec::validate`] gates
9184/// `children.is_empty()` as a structural partition — static `:children`
9185/// on a `SimpleOneForOne` supervisor is a build-time rejection).
9186///
9187/// Peer of the sibling [`SUPERVISOR_ESTRATEGIA_ONE_FOR_ONE`] /
9188/// [`SUPERVISOR_ESTRATEGIA_ONE_FOR_ALL`] /
9189/// [`SUPERVISOR_ESTRATEGIA_REST_FOR_ONE`] scalars on the same closed
9190/// enum surface — see the sibling
9191/// [`SUPERVISOR_ESTRATEGIA_ONE_FOR_ONE`] doc for the full drift-mode
9192/// analysis.
9193pub const SUPERVISOR_ESTRATEGIA_SIMPLE_ONE_FOR_ONE: &str = "SimpleOneForOne";
9194
9195/// Canonical M2 [`crate::supervisor::RestartPolicy::Permanent`] variant
9196/// discriminator scalar-value — the exact byte-string the `Serialize`
9197/// derive on the un-`rename`d enum emits under
9198/// [`SUPERVISOR_CHILD_KEY_RESTART`] whenever the typed `:children :restart`
9199/// per-child restart-policy slot is the always-restart-regardless-of-exit
9200/// arm (the enum's `default()` and the canonical happy-path per
9201/// theory/INSPIRATIONS.md §II.2 — Erlang/OTP `permanent`, the
9202/// long-running-service posture where the supervisor must bring the
9203/// child back on every failure mode).
9204///
9205/// The scalar is the un-`rename`d Rust variant name verbatim; a future
9206/// `#[serde(rename_all = "kebab-case")]` attribute on the enum, or a
9207/// per-variant `#[serde(rename = "…")]` override, or a variant rename in
9208/// the source, would silently emit a `:children :restart` scalar
9209/// whose per-exit restart-decision discipline lands under one spelling
9210/// while every downstream consumer still dispatches on another — the
9211/// future wasm-operator's per-child restart-decision branch, the future
9212/// M4 `mesh.pleme.io/v1alpha1/Supervisor` CR materializer's
9213/// admission-time enum-arm bind, the `caixa-operator`'s hierarchical
9214/// reconciliation scheduler's per-child-policy fan-out would each silently
9215/// no-op onto the enum's `default()` (`Permanent`) and children would
9216/// come up with the wrong per-exit restart posture on every non-default
9217/// arm — a `:temporary` `oneShot` child would be restarted on clean
9218/// exit (the successful-completion signal treated as failure), a
9219/// `:transient` child that clean-exited would be restarted (masking the
9220/// clean-completion contract), and the operator's post-exit dispatch
9221/// would silently degrade to the always-restart posture. The serde
9222/// round-trip pin the sweep introduces
9223/// ([`crate::supervisor::tests::restart_policy_variants_serialize_to_lifted_scalar_values`])
9224/// catches the drift at caixa-core build time rather than at the
9225/// operator's reconcile posture.
9226///
9227/// Peer of [`SUPERVISOR_CHILD_RESTART_TEMPORARY`] /
9228/// [`SUPERVISOR_CHILD_RESTART_TRANSIENT`] on the same closed
9229/// [`crate::supervisor::RestartPolicy`] enum surface — together the
9230/// three constants name every author-reachable arm of the OTP-shaped
9231/// per-child restart-decision discriminator, mirroring the
9232/// closed-enum-scalar-value trajectory
9233/// [`SUPERVISOR_ESTRATEGIA_ONE_FOR_ONE`] /
9234/// [`SUPERVISOR_ESTRATEGIA_ONE_FOR_ALL`] /
9235/// [`SUPERVISOR_ESTRATEGIA_REST_FOR_ONE`] /
9236/// [`SUPERVISOR_ESTRATEGIA_SIMPLE_ONE_FOR_ONE`] (09ffb2d) established on
9237/// the sibling `RestartStrategy` enum on the peer per-supervisor
9238/// sibling-restart-strategy axis and [`M3_PLACEMENT_ESTRATEGIA_SINGLE_NODE`]
9239/// / [`M3_PLACEMENT_ESTRATEGIA_REPLICATED`] /
9240/// [`M3_PLACEMENT_ESTRATEGIA_SHARDED`] (3f0e21c) established on the M3
9241/// `PlacementStrategy` enum on the peer per-Aplicacao distribution-strategy
9242/// axis. The three OTP-shaped closed-enum discriminator axes on the
9243/// caixa typed surface (supervisor sibling-restart strategy, per-child
9244/// restart policy, per-Aplicacao placement strategy) now each carry the
9245/// same three-path-convergence (`Serialize` derive → `as_str` helper →
9246/// lifted constant) drift-detection posture.
9247pub const SUPERVISOR_CHILD_RESTART_PERMANENT: &str = "Permanent";
9248
9249/// Canonical M2 [`crate::supervisor::RestartPolicy::Temporary`] variant
9250/// discriminator scalar-value — the exact byte-string the `Serialize`
9251/// derive on the un-`rename`d enum emits under
9252/// [`SUPERVISOR_CHILD_KEY_RESTART`] whenever the typed `:children :restart`
9253/// per-child restart-policy slot is the never-restart arm (Erlang/OTP
9254/// `temporary`, the one-shot posture where the child's completion — clean
9255/// or not — is itself the success signal; the `oneShot`
9256/// [`crate::render::COMPUTEUNIT_SPEC_KEY_TRIGGER`] arm maps here).
9257///
9258/// Peer of the sibling [`SUPERVISOR_CHILD_RESTART_PERMANENT`] /
9259/// [`SUPERVISOR_CHILD_RESTART_TRANSIENT`] scalars on the same
9260/// closed enum surface — see the sibling
9261/// [`SUPERVISOR_CHILD_RESTART_PERMANENT`] doc for the full drift-mode
9262/// analysis.
9263pub const SUPERVISOR_CHILD_RESTART_TEMPORARY: &str = "Temporary";
9264
9265/// Canonical M2 [`crate::supervisor::RestartPolicy::Transient`] variant
9266/// discriminator scalar-value — the exact byte-string the `Serialize`
9267/// derive on the un-`rename`d enum emits under
9268/// [`SUPERVISOR_CHILD_KEY_RESTART`] whenever the typed `:children :restart`
9269/// per-child restart-policy slot is the restart-only-on-abnormal-exit arm
9270/// (Erlang/OTP `transient`, the "restart on non-zero exit or unhandled
9271/// exception; a clean exit completes the child" posture — the third
9272/// canonical OTP per-child restart-decision arm alongside `permanent`
9273/// and `temporary`).
9274///
9275/// Peer of the sibling [`SUPERVISOR_CHILD_RESTART_PERMANENT`] /
9276/// [`SUPERVISOR_CHILD_RESTART_TEMPORARY`] scalars on the same
9277/// closed enum surface — see the sibling
9278/// [`SUPERVISOR_CHILD_RESTART_PERMANENT`] doc for the full drift-mode
9279/// analysis.
9280pub const SUPERVISOR_CHILD_RESTART_TRANSIENT: &str = "Transient";
9281
9282/// Canonical camelCase JSON/YAML top-level key for the
9283/// [`crate::aplicacao::Entrada`] struct's `host` external-hostname axis —
9284/// the `host:` field the M3 Aplicacao's `#[serde(rename_all = "camelCase")]`
9285/// derive on [`crate::aplicacao::Entrada`] emits at the singleton
9286/// `:entrada` block, and the exact scalar every downstream consumer
9287/// reaching for the external hostname via `Value::get(...)` (the
9288/// [`caixa_mesh`] Gateway/HTTPRoute emitter's per-Aplicacao
9289/// `spec.hostnames` projection under [`GATEWAY_API_KEY_HOSTNAME`] /
9290/// [`GATEWAY_API_KEY_HOSTNAMES`], the future `app-operator`
9291/// reconciler's per-Aplicacao ingress-hostname bind, the future
9292/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's admission-time
9293/// hostname cross-check against the cluster's declared
9294/// [`GATEWAY_API_HOSTNAME_MAX_LEN`] discipline) must probe on.
9295///
9296/// The scalar is derived from the Rust field name `host` by the
9297/// `rename_all = "camelCase"` derive; `host` has no `_`, so the serde
9298/// transform is a no-op on this axis and the emitted key equals the
9299/// source-side field name byte-for-byte. Lifting the byte to one
9300/// `&'static str` closes the drift footgun structurally: a future
9301/// refactor renaming the Rust field OR retaining the field name while
9302/// adding a `#[serde(rename = "…")]` override would silently emit an
9303/// `Entrada` whose external-hostname discriminator lands under one key
9304/// while every downstream consumer still probes another — the Gateway
9305/// emitter's per-Aplicacao hostname projection, the operator's ingress
9306/// bind, the CR materializer's admission-time cross-check would each
9307/// silently fall back to no-hostname and the Gateway API would either
9308/// admit an all-hostname listener (breaking the per-Aplicacao
9309/// host-isolation contract MESH-COMPOSITION.md §III.5 promises) or
9310/// reject the resource outright at admission. The identity pin
9311/// (`entrada_serde_keys_match_lifted_entrada_key_consts` on the
9312/// source-side type) catches drift at caixa-core build time rather than
9313/// at the Gateway controller's admission step, far from the rebrand
9314/// commit's source.
9315///
9316/// Peer of [`ENTRADA_KEY_PARA`] / [`ENTRADA_KEY_PATHS`] /
9317/// [`ENTRADA_KEY_PORT`] on the same [`crate::aplicacao::Entrada`]
9318/// singleton serialized-key axis. Peer of the sibling
9319/// [`MEMBRO_KEY_CAIXA`] / [`MEMBRO_KEY_VERSAO`] pair (ce80ca0) and
9320/// [`CONTRATO_KEY_DE`] / [`CONTRATO_KEY_PARA`] / [`CONTRATO_KEY_WIT`]
9321/// triad (ca463a4) on the sibling M3 per-`:membros` and per-`:contratos`
9322/// entry axes — those lifts pinned the M3 collection-slot atom
9323/// camelCase JSON keys, this lift extends the same discipline onto the
9324/// singleton `:entrada` mesh slot so the last M3 typed-struct
9325/// `#[serde(rename_all = "camelCase")]` axis on the Aplicacao surface
9326/// joins the substrate's "one canonical byte-string per typed
9327/// serialized-key axis" discipline. Same discipline every peer
9328/// camelCase serde-key lift carries ([`M2_LIMITS_KEY_MEMORY`] etc.
9329/// (d8b8b4f), [`M2_BEHAVIOR_KEY_ON_INIT`] etc. (21fe462),
9330/// [`M2_UPGRADE_FROM_KEY_FROM`] / [`M2_UPGRADE_FROM_KEY_INSTRUCTIONS`]
9331/// (36ffe65), [`M3_PLACEMENT_KEY_ESTRATEGIA`] etc.,
9332/// [`SUPERVISOR_KEY_ESTRATEGIA`] etc. (40cc4e5)).
9333pub const ENTRADA_KEY_HOST: &str = "host";
9334
9335/// Canonical camelCase JSON/YAML top-level key for the
9336/// [`crate::aplicacao::Entrada`] struct's `para` destination-member axis
9337/// — the `para:` field naming which `:membros` entry the external
9338/// Gateway routes to. Peer of [`ENTRADA_KEY_HOST`] on the same
9339/// [`crate::aplicacao::Entrada`] singleton serialized-key axis; see
9340/// [`ENTRADA_KEY_HOST`] for the full lift rationale. The Rust field is
9341/// lowercase `para`; `#[serde(rename_all = "camelCase")]` is a no-op on
9342/// this axis and the emitted key equals the source-side field name
9343/// byte-for-byte.
9344///
9345/// Byte-identical to [`CONTRATO_KEY_PARA`] today — both resolve to the
9346/// same four-byte `"para"` literal — but semantically distinct:
9347/// [`CONTRATO_KEY_PARA`] names the per-`:contratos` edge's callee-Servico
9348/// discriminator on the [`crate::aplicacao::WitContract`] surface, while
9349/// this constant names the singleton `:entrada` block's Gateway-route
9350/// destination-Servico discriminator on the sibling
9351/// [`crate::aplicacao::Entrada`] surface. Splitting the two lets each
9352/// schema's future rebrand land independently on the same
9353/// "byte-identical-but-semantically-distinct" discipline the peer
9354/// [`FLEET_PROGRAMS_KEY_NAME`] / [`KUBE_KEY_NAME`] split established
9355/// (935979a) on the sibling per-entry name-discriminator axis and the
9356/// [`FLEET_PROGRAMS_KEY_VERSAO`] / [`MEMBRO_KEY_VERSAO`] split
9357/// established (ce80ca0) on the sibling per-entry version-constraint
9358/// axis.
9359pub const ENTRADA_KEY_PARA: &str = "para";
9360
9361/// Canonical camelCase JSON/YAML top-level key for the
9362/// [`crate::aplicacao::Entrada`] struct's `paths` per-Aplicacao
9363/// path-filter axis — the `paths:` sequence the M3 Aplicacao's
9364/// `#[serde(rename_all = "camelCase")]` derive emits at the singleton
9365/// `:entrada` block, and the exact scalar every downstream
9366/// per-`:entrada :paths` HTTPRoute-match-projection consumer must probe
9367/// on (the [`caixa_mesh`] HTTPRoute emitter's per-Aplicacao `matches[]`
9368/// projection under [`GATEWAY_API_KEY_MATCHES`], defaulting to
9369/// [`GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH`] when the slot is empty per
9370/// 48e2083). Peer of [`ENTRADA_KEY_HOST`] on the same
9371/// [`crate::aplicacao::Entrada`] singleton serialized-key axis; see
9372/// [`ENTRADA_KEY_HOST`] for the full lift rationale. The Rust field is
9373/// lowercase `paths`; `#[serde(rename_all = "camelCase")]` is a no-op
9374/// on this axis and the emitted key equals the source-side field name
9375/// byte-for-byte.
9376pub const ENTRADA_KEY_PATHS: &str = "paths";
9377
9378/// Canonical camelCase JSON/YAML top-level key for the
9379/// [`crate::aplicacao::Entrada`] struct's `port` destination-Servico
9380/// port axis — the `port:` field the M3 Aplicacao's
9381/// `#[serde(rename_all = "camelCase")]` derive emits at the singleton
9382/// `:entrada` block, defaulting via [`crate::aplicacao::default_port`]
9383/// to [`crate::DEFAULT_SERVICO_PORT`] when the author omits the slot.
9384/// Peer of [`ENTRADA_KEY_HOST`] on the same
9385/// [`crate::aplicacao::Entrada`] singleton serialized-key axis; see
9386/// [`ENTRADA_KEY_HOST`] for the full lift rationale. The Rust field is
9387/// lowercase `port`; `#[serde(rename_all = "camelCase")]` is a no-op on
9388/// this axis and the emitted key equals the source-side field name
9389/// byte-for-byte.
9390///
9391/// Byte-identical to [`KUBE_KEY_PORT`] today — both resolve to the same
9392/// four-byte `"port"` literal — but semantically distinct:
9393/// [`KUBE_KEY_PORT`] names the K8s Service/ContainerPort per-resource
9394/// port-discriminator axis, while this constant names the typed
9395/// [`crate::aplicacao::Entrada`] singleton block's Gateway-route
9396/// destination-Servico port axis on the M3 Aplicacao surface.
9397/// Splitting the two lets each schema's future rebrand land
9398/// independently.
9399pub const ENTRADA_KEY_PORT: &str = "port";
9400
9401/// Canonical camelCase JSON/YAML top-level key for the
9402/// [`crate::aplicacao::MeshPolicy`] struct's `timeout` per-call
9403/// wall-clock cap axis — the `timeout:` field the M3 Aplicacao's
9404/// `#[serde(rename_all = "camelCase")]` derive on
9405/// [`crate::aplicacao::MeshPolicy`] emits at the singleton `:politicas`
9406/// block, and the exact scalar every downstream mesh-timeout consumer
9407/// must probe on (the future M4 per-edge `:politicas` overlay
9408/// projection onto Cilium `L7Rules` / Gateway API `HTTPRoute`
9409/// per-backend `timeouts.backendRequest` axis per
9410/// MESH-COMPOSITION.md §III.3, the future
9411/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's admission-time
9412/// mesh-timeout cross-check, the future `feira lint` per-`:politicas`
9413/// authored-duration bound-check against
9414/// [`crate::POLICY_TIMEOUT_MAX`]).
9415///
9416/// The scalar is derived from the Rust field name `timeout` by the
9417/// `rename_all = "camelCase"` derive; `timeout` has no `_`, so the
9418/// serde transform is a no-op on this axis and the emitted key equals
9419/// the source-side field name byte-for-byte. Lifting the byte to one
9420/// `&'static str` closes the drift footgun structurally: a future
9421/// refactor renaming the Rust field OR retaining the field name while
9422/// adding a `#[serde(rename = "…")]` override would silently emit a
9423/// [`MeshPolicy`][mp] whose per-call timeout discriminator lands under
9424/// one key while every downstream consumer still probes another — the
9425/// M4 per-edge overlay projection, the CR materializer's cross-check,
9426/// the linter's bound-check would each silently fall back to
9427/// no-timeout and every `:contratos`-edge request would silently
9428/// bypass the per-call cap the typed slot set, with the failure
9429/// surfacing as "the mesh no longer enforces the timeout the
9430/// Aplicacao authored" far from the rebrand commit's source. The
9431/// identity pin (`mesh_policy_serde_keys_match_lifted_politicas_key_consts`
9432/// on the source-side type) catches drift at caixa-core build time
9433/// rather than at the mesh controller's reconcile step.
9434///
9435/// [mp]: crate::aplicacao::MeshPolicy
9436///
9437/// Peer of [`POLITICAS_KEY_RETRIES`] / [`POLITICAS_KEY_CIRCUIT_BREAKER`] /
9438/// [`POLITICAS_KEY_MTLS_REQUIRED`] / [`POLITICAS_KEY_RATE_LIMIT`] on the
9439/// same [`crate::aplicacao::MeshPolicy`] singleton serialized-key
9440/// axis. Peer of the sibling [`ENTRADA_KEY_HOST`] etc. tetrad
9441/// (a3d6162), [`M3_PLACEMENT_KEY_ESTRATEGIA`] etc. tetrad,
9442/// [`MEMBRO_KEY_CAIXA`] / [`MEMBRO_KEY_VERSAO`] pair (ce80ca0), and
9443/// [`CONTRATO_KEY_DE`] / [`CONTRATO_KEY_PARA`] / [`CONTRATO_KEY_WIT`]
9444/// triad (ca463a4) on the sibling M3 typed-struct axes — those lifts
9445/// pinned every peer M3 mesh-slot atom, this lift closes the last M3
9446/// typed-struct top-level `#[serde(rename_all = "camelCase")]` axis on
9447/// the Aplicacao surface without a lifted serde-key peer (the
9448/// [`crate::aplicacao::MeshPolicy`] singleton `:politicas` block) so
9449/// the entire M3 typed-struct surface joins the substrate's "one
9450/// canonical byte-string per typed serialized-key axis" discipline.
9451/// Same discipline every peer camelCase serde-key lift carries
9452/// ([`M2_LIMITS_KEY_MEMORY`] etc. (d8b8b4f),
9453/// [`M2_BEHAVIOR_KEY_ON_INIT`] etc. (21fe462),
9454/// [`M2_UPGRADE_FROM_KEY_FROM`] / [`M2_UPGRADE_FROM_KEY_INSTRUCTIONS`]
9455/// (36ffe65), [`SUPERVISOR_KEY_ESTRATEGIA`] etc. (40cc4e5)).
9456pub const POLITICAS_KEY_TIMEOUT: &str = "timeout";
9457
9458/// Canonical camelCase JSON/YAML top-level key for the
9459/// [`crate::aplicacao::MeshPolicy`] struct's `retries` transient-failure
9460/// retry-count axis — the `retries:` field the M3 Aplicacao's
9461/// `#[serde(rename_all = "camelCase")]` derive on
9462/// [`crate::aplicacao::MeshPolicy`] emits at the singleton `:politicas`
9463/// block. Peer of [`POLITICAS_KEY_TIMEOUT`] on the same
9464/// [`crate::aplicacao::MeshPolicy`] singleton serialized-key axis; see
9465/// [`POLITICAS_KEY_TIMEOUT`] for the full lift rationale. The Rust
9466/// field is lowercase `retries`; `#[serde(rename_all = "camelCase")]`
9467/// is a no-op on this axis and the emitted key equals the source-side
9468/// field name byte-for-byte.
9469pub const POLITICAS_KEY_RETRIES: &str = "retries";
9470
9471/// Canonical camelCase JSON/YAML top-level key for the
9472/// [`crate::aplicacao::MeshPolicy`] struct's `circuit_breaker`
9473/// circuit-breaker sub-block axis — the `circuitBreaker:` field the M3
9474/// Aplicacao's `#[serde(rename_all = "camelCase")]` derive on
9475/// [`crate::aplicacao::MeshPolicy`] emits at the singleton `:politicas`
9476/// block, and the exact camelCase scalar (Rust field
9477/// `circuit_breaker` → serde-emitted `circuitBreaker`, one of the two
9478/// `MeshPolicy` axes the derive-attribute non-trivially transforms
9479/// alongside [`POLITICAS_KEY_MTLS_REQUIRED`] and
9480/// [`POLITICAS_KEY_RATE_LIMIT`]) every downstream circuit-breaker
9481/// consumer must probe on (the future M4 per-edge `:politicas` overlay
9482/// projection onto the mesh's per-backend failure-counter reset
9483/// window per MESH-COMPOSITION.md §III.3 breaker semantics, the future
9484/// `feira lint` per-`:politicas` breaker-window bound-check against
9485/// [`crate::POLICY_BREAKER_WINDOW_MAX`] and
9486/// [`crate::POLICY_BREAKER_MAX_FAILURES_MAX`]). Peer of
9487/// [`POLITICAS_KEY_TIMEOUT`] on the same
9488/// [`crate::aplicacao::MeshPolicy`] singleton serialized-key axis; see
9489/// [`POLITICAS_KEY_TIMEOUT`] for the full lift rationale.
9490///
9491/// This axis is one of the three non-trivial camelCase transforms
9492/// [`crate::aplicacao::MeshPolicy`]'s derive emits (`circuit_breaker`
9493/// → `circuitBreaker`, `mtls_required` → `mtlsRequired`, `rate_limit`
9494/// → `rateLimit`); a future accidental `rename_all = "snake_case"` /
9495/// `"kebab-case"` / verbatim-field-name flip at the derive would
9496/// silently rebrand the emitted key to `circuit_breaker` /
9497/// `circuit-breaker` / `circuit_breaker` respectively, breaking every
9498/// downstream `Value::get(POLITICAS_KEY_CIRCUIT_BREAKER)` consumer.
9499/// The identity pin (`mesh_policy_serde_keys_match_lifted_politicas_key_consts`
9500/// on the source-side type) catches drift on all three non-trivial
9501/// axes simultaneously.
9502pub const POLITICAS_KEY_CIRCUIT_BREAKER: &str = "circuitBreaker";
9503
9504/// Canonical camelCase JSON/YAML top-level key for the
9505/// [`crate::aplicacao::MeshPolicy`] struct's `mtls_required`
9506/// mTLS-enforcement-toggle axis — the `mtlsRequired:` field the M3
9507/// Aplicacao's `#[serde(rename_all = "camelCase")]` derive on
9508/// [`crate::aplicacao::MeshPolicy`] emits at the singleton `:politicas`
9509/// block, and the exact camelCase scalar (Rust field `mtls_required`
9510/// → serde-emitted `mtlsRequired`) every downstream mesh-identity
9511/// consumer must probe on (the future M4 per-edge `:politicas` overlay
9512/// projection onto Cilium `CiliumNetworkPolicy` per-rule
9513/// [`CILIUM_KEY_AUTHENTICATION`] mode dispatch under the
9514/// [`cilium_auth_mode`] bijection projection (a4dc43c) — the mesh's
9515/// sandboxing-by-default posture MESH-COMPOSITION.md §III.3 promises
9516/// keys off this exact byte-sequence to opt out of mTLS enforcement
9517/// per-edge, so drift here silently reopens the every-edge-mTLS
9518/// invariant the substrate defaults to). Peer of
9519/// [`POLITICAS_KEY_TIMEOUT`] on the same
9520/// [`crate::aplicacao::MeshPolicy`] singleton serialized-key axis; see
9521/// [`POLITICAS_KEY_TIMEOUT`] for the full lift rationale.
9522pub const POLITICAS_KEY_MTLS_REQUIRED: &str = "mtlsRequired";
9523
9524/// Canonical camelCase JSON/YAML top-level key for the
9525/// [`crate::aplicacao::MeshPolicy`] struct's `rate_limit`
9526/// token-bucket-rate-limit axis — the `rateLimit:` field the M3
9527/// Aplicacao's `#[serde(rename_all = "camelCase")]` derive on
9528/// [`crate::aplicacao::MeshPolicy`] emits at the singleton `:politicas`
9529/// block, and the exact camelCase scalar (Rust field `rate_limit` →
9530/// serde-emitted `rateLimit`) every downstream rate-limit consumer
9531/// must probe on (the future M4 per-edge `:politicas` overlay
9532/// projection onto the mesh's per-backend token-bucket `(rate,
9533/// window)` decoder driven by the canonical
9534/// [`crate::aplicacao::rate_limit_codec`] unit-suffix bijection). Peer
9535/// of [`POLITICAS_KEY_TIMEOUT`] on the same
9536/// [`crate::aplicacao::MeshPolicy`] singleton serialized-key axis; see
9537/// [`POLITICAS_KEY_TIMEOUT`] for the full lift rationale.
9538pub const POLITICAS_KEY_RATE_LIMIT: &str = "rateLimit";
9539
9540/// Canonical camelCase JSON/YAML sub-key for the
9541/// [`crate::aplicacao::CircuitBreaker`] struct's `max_failures`
9542/// consecutive-failure-count axis — the `maxFailures:` field the M3
9543/// Aplicacao's `#[serde(rename_all = "camelCase")]` derive on
9544/// [`crate::aplicacao::CircuitBreaker`] emits inside the
9545/// [`POLITICAS_KEY_CIRCUIT_BREAKER`] sub-block, and the exact camelCase
9546/// scalar (Rust field `max_failures` → serde-emitted `maxFailures`,
9547/// the load-bearing non-trivial camelCase transform on this
9548/// [`CircuitBreaker`][cb] axis alongside the no-op
9549/// [`CIRCUIT_BREAKER_KEY_WINDOW`] sibling) every downstream breaker-
9550/// tuning consumer must probe on (the future M4 per-edge `:politicas`
9551/// overlay projection onto the mesh's per-backend
9552/// consecutive-failure-counter tripping threshold per
9553/// MESH-COMPOSITION.md §III.3 breaker semantics, the future
9554/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's admission-time
9555/// breaker cross-check against
9556/// [`crate::POLICY_BREAKER_MAX_FAILURES_MAX`], the future
9557/// `feira lint` per-`:politicas :circuit-breaker` bound-check gate).
9558///
9559/// [cb]: crate::aplicacao::CircuitBreaker
9560///
9561/// Peer of [`CIRCUIT_BREAKER_KEY_WINDOW`] on the same
9562/// [`crate::aplicacao::CircuitBreaker`] serialized-key axis; the two
9563/// consts together close the sub-block's typed-struct axis. Extends
9564/// the [`POLITICAS_KEY_CIRCUIT_BREAKER`] parent-axis lift (b55cca7)
9565/// one level deeper — the parent const names the outer sub-block key
9566/// the derive on [`crate::aplicacao::MeshPolicy`] emits, this pair
9567/// names the inner keys the derive on the payload type emits, so a
9568/// consumer walking `Value::get(POLITICAS_KEY_CIRCUIT_BREAKER)
9569/// .and_then(|v| v.get(CIRCUIT_BREAKER_KEY_MAX_FAILURES))` navigates
9570/// the whole [`crate::aplicacao::MeshPolicy`] breaker-tuning shape
9571/// entirely through lifted canonical byte-sequences with no inline
9572/// string literal at either level.
9573///
9574/// A future accidental `rename_all = "snake_case"` /
9575/// `"kebab-case"` / verbatim-field-name flip at the derive on
9576/// [`crate::aplicacao::CircuitBreaker`] would silently rebrand the
9577/// emitted key to `max_failures` / `max-failures` / `max_failures`
9578/// respectively, breaking every downstream
9579/// `Value::get(CIRCUIT_BREAKER_KEY_MAX_FAILURES)` consumer — with the
9580/// drift surfacing at apply time far from the derive-attr commit. The
9581/// identity pin
9582/// (`circuit_breaker_serde_keys_match_lifted_circuit_breaker_key_consts`
9583/// on the source-side type) catches drift at caixa-core build time.
9584///
9585/// Same discipline every peer camelCase serde-key lift carries
9586/// ([`M2_LIMITS_KEY_MEMORY`] etc. (d8b8b4f),
9587/// [`M2_BEHAVIOR_KEY_ON_INIT`] etc. (21fe462),
9588/// [`M2_UPGRADE_FROM_KEY_FROM`] / [`M2_UPGRADE_FROM_KEY_INSTRUCTIONS`]
9589/// (36ffe65), [`SUPERVISOR_KEY_ESTRATEGIA`] etc. (40cc4e5),
9590/// [`POLITICAS_KEY_TIMEOUT`] etc. (b55cca7)).
9591pub const CIRCUIT_BREAKER_KEY_MAX_FAILURES: &str = "maxFailures";
9592
9593/// Canonical camelCase JSON/YAML sub-key for the
9594/// [`crate::aplicacao::CircuitBreaker`] struct's `window`
9595/// failure-counter reset-window axis — the `window:` field the M3
9596/// Aplicacao's `#[serde(rename_all = "camelCase")]` derive on
9597/// [`crate::aplicacao::CircuitBreaker`] emits inside the
9598/// [`POLITICAS_KEY_CIRCUIT_BREAKER`] sub-block. The Rust field is
9599/// lowercase `window`; `#[serde(rename_all = "camelCase")]` is a
9600/// no-op on this axis and the emitted key equals the source-side
9601/// field name byte-for-byte. Peer of
9602/// [`CIRCUIT_BREAKER_KEY_MAX_FAILURES`] on the same
9603/// [`crate::aplicacao::CircuitBreaker`] serialized-key axis; see
9604/// [`CIRCUIT_BREAKER_KEY_MAX_FAILURES`] for the full lift rationale.
9605pub const CIRCUIT_BREAKER_KEY_WINDOW: &str = "window";
9606
9607/// Canonical `lareira-fleet-programs` values-schema key naming the
9608/// per-caixa entry sequence — the exact YAML key the fleet-programs
9609/// library chart's `values.yaml` reads as `programs:` (a sequence of
9610/// per-Servico entries the chart's `range` iterates over to emit one
9611/// `ComputeUnit` CR per entry). Two production consumers in
9612/// [`caixa_flux`] carry this key on the same fleet-programs schema
9613/// axis:
9614///
9615/// 1. [`caixa_flux::upsert_into_helmrelease_programs`] — the writer-
9616/// side upsert path on the aggregator-HelmRelease shape. Walks
9617/// `HelmRelease.spec.values.programs[]` under this exact key to
9618/// match by `metadata.name` and either replace-in-place or append.
9619///
9620/// 2. [`caixa_flux::upsert_into_programs_yaml`] — the writer-side
9621/// upsert path on the bare-values.yaml shape. Walks the
9622/// top-level `programs[]` sequence under the same key.
9623///
9624/// Until this lift landed both consumers carried the bare `"programs"`
9625/// byte inline — `upsert_into_helmrelease_programs`'s
9626/// `values_map.entry(Value::String("programs".into()))` at
9627/// `caixa-flux/src/lib.rs:539` and `upsert_into_programs_yaml`'s
9628/// `let programs_key = Value::String("programs".into());` at
9629/// `caixa-flux/src/lib.rs:591`. A future fleet-programs schema-key
9630/// rebrand (the library chart moving to plural `programas` for
9631/// Brazilian-Portuguese uniformity with the rest of the substrate's
9632/// surface, to a namespaced `pleme.pleme.io/programs` for multi-tenant
9633/// aggregator-values isolation, or to per-kind `servicos` / `aplicacaos`
9634/// splits once the schema grows past the flat sequence — the
9635/// ABSORPTION-ROADMAP.md M4 trajectory) without a coordinated edit
9636/// on both writer-side sites would silently emit an entry under one
9637/// key (e.g. `programas:`) while the peer-side upsert still probes
9638/// the prior key — the aggregator's `range .Values.programs` would
9639/// then iterate an empty sequence and every `ComputeUnit` CR would
9640/// silently vanish from the cluster's fleet, with the failure
9641/// surfacing as "the newly-deployed Servico's pods never spin up" far
9642/// from the rebrand commit's source. Lifting the literal to one
9643/// `&'static str` closes the drift footgun structurally — both
9644/// consumers read from the same memory, so any future rebrand reaches
9645/// both writer sites by construction and a CI build that re-introduces
9646/// a sibling inline `"programs"` literal trips the peer pinning tests
9647/// at the build-time fail-before-deploy posture every prior
9648/// load-bearing-string lift on this surface
9649/// ([`M3_KEY_PLACEMENT`] under the same `programs.yaml` per-entry
9650/// axis, [`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] / [`M2_KEY_UPGRADE_FROM`]
9651/// on the peer M2 overlay-key surfaces, [`DEFAULT_NAMESPACE`]
9652/// / [`DEFAULT_LIBRARY_NAME`] / [`DEFAULT_SERVICO_PORT`] on the peer
9653/// shared-string / port surfaces) establishes.
9654///
9655/// Peer of [`M3_KEY_PLACEMENT`] on the same fleet-programs values
9656/// schema — that constant names the per-entry overlay key, this one
9657/// names the top-level array key both writer verbs upsert into.
9658pub const FLEET_PROGRAMS_KEY_PROGRAMS: &str = "programs";
9659
9660/// Canonical `lareira-fleet-programs` values-schema key naming the
9661/// per-entry name discriminator — the `name:` field the library
9662/// chart's `range .Values.programs` step reads to key each rendered
9663/// `ComputeUnit` CR's `metadata.name` off, and the exact key both
9664/// writer-side upsert paths in [`caixa_flux`] match against to
9665/// replace-in-place-vs-append. Peer of [`FLEET_PROGRAMS_KEY_PROGRAMS`]
9666/// on the same fleet-programs values schema — that constant names
9667/// the top-level array key, this one names the per-entry name-axis
9668/// both writer verbs walk the array by.
9669///
9670/// Two production consumers write this key:
9671///
9672/// 1. [`caixa_flux::programs_yaml_entry`] — the emit-side per-Servico
9673/// entry-builder writes the per-entry name-axis at this exact key
9674/// (seeded from the Caixa's `nome`), at
9675/// `caixa-flux/src/lib.rs`'s `entry.insert("name".into(), …)` call.
9676/// 2. [`caixa_mesh::programs_for_aplicacao`] — the Aplicacao-side
9677/// per-`:membros` entry-builder writes the peer per-entry name-axis
9678/// at the same key (seeded from each `:membros` entry's `:caixa`
9679/// binding), at `caixa-mesh/src/lib.rs`'s per-member
9680/// `entry.insert("name".into(), …)` call.
9681///
9682/// Two production consumers read this key:
9683///
9684/// 3. [`caixa_flux::upsert_into_helmrelease_programs`] — the writer-
9685/// side upsert path on the aggregator-HelmRelease shape reads the
9686/// per-entry key twice (new-entry's `.get("name")` extract +
9687/// per-slot `.get("name")` match-vs-new_name inside
9688/// `HelmRelease.spec.values.programs[]`), plus a
9689/// `Error::MissingField("name")` diagnostic naming the same axis.
9690/// 4. [`caixa_flux::upsert_into_programs_yaml`] — the writer-side
9691/// upsert path on the bare-values.yaml shape reads the same per-
9692/// entry key over the top-level `programs[]` sequence via the
9693/// same three-site (extract + match + `MissingField`) shape.
9694///
9695/// Until this lift landed both writers carried the bare `"name"`
9696/// byte inline at every read + `Error::MissingField("name")`
9697/// diagnostic site, and both emitters carried the same bare byte at
9698/// their `entry.insert("name".into(), …)` call. A future fleet-
9699/// programs schema-key rebrand on the per-entry name-discriminator
9700/// axis (per the same trajectory [`FLEET_PROGRAMS_KEY_PROGRAMS`]'s
9701/// doc-comment names — the `lareira-fleet-programs` library chart
9702/// moving its per-entry name-axis to `nome:` for Brazilian-Portuguese
9703/// uniformity with the rest of the substrate's surface, or to a
9704/// namespaced `pleme.pleme.io/name` for multi-tenant aggregator
9705/// values isolation, or to per-kind `servico-name` / `aplicacao-name`
9706/// splits once the schema grows past the flat sequence — the
9707/// ABSORPTION-ROADMAP.md M4 trajectory) without a coordinated edit
9708/// across all four sites would silently split the schema: one
9709/// emitter would write under `nome:` while the peer-side upsert
9710/// still probed `name:` — the aggregator's `range .Values.programs`
9711/// would then iterate entries whose per-entry name-axis the library
9712/// chart's `metadata.name` templating reads as empty (or match
9713/// against the wrong entry on upsert), and every rendered
9714/// `ComputeUnit` CR would silently collide on empty
9715/// `metadata.name` or vanish at the aggregator's per-entry name-
9716/// keyed reduce step, with the failure surfacing as "the Servico's
9717/// pods never spin up under the expected name" far from the rebrand
9718/// commit's source. Lifting the literal to one `&'static str` closes
9719/// the drift footgun structurally — every consumer reads the same
9720/// memory, so any future rebrand reaches all four sites by
9721/// construction and a CI build that re-introduces a sibling inline
9722/// `"name"` literal trips the peer pinning tests at the build-time
9723/// fail-before-deploy posture every prior load-bearing-string lift
9724/// on this surface ([`FLEET_PROGRAMS_KEY_PROGRAMS`] on the sibling
9725/// fleet-programs top-level array-key axis, [`M3_KEY_PLACEMENT`] /
9726/// [`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] / [`M2_KEY_UPGRADE_FROM`]
9727/// on the peer per-entry overlay-key surfaces) establishes.
9728///
9729/// Byte-identical to [`KUBE_KEY_NAME`] today — both resolve to the
9730/// same three-byte `"name"` literal — but semantically distinct:
9731/// [`KUBE_KEY_NAME`] names the K8s CR canonical `metadata.name` axis
9732/// (every rendered CR's identity discriminator, spelled per the K8s
9733/// apiserver's OpenAPI v3 schema), while this constant names the
9734/// `lareira-fleet-programs` library chart's per-entry name-axis
9735/// (spelled per the chart's `values.schema.json` — a separate schema
9736/// contract). Splitting the two lets each schema's future rebrand
9737/// land independently at its canonical const definition without
9738/// coupling the K8s CR canonical-key axis to the fleet-programs
9739/// values-schema axis (or vice versa).
9740pub const FLEET_PROGRAMS_KEY_NAME: &str = "name";
9741
9742/// Canonical `lareira-fleet-programs` values-schema key naming the
9743/// per-entry parent-Aplicacao-graph discriminator — the `aplicacao:`
9744/// annotation the substrate operator's fleet-aggregator reads to
9745/// group each rendered `programs[]` entry back onto the parent
9746/// Aplicacao its M3 `:membros` list contributed it, and the exact
9747/// key downstream fleet consumers (per-graph observability filters,
9748/// per-Aplicacao Cilium-policy reconciliation, per-graph Gateway/
9749/// `HTTPRoute` attachment) walk to project the flat `programs[]`
9750/// sequence back onto its typed Aplicacao graph.
9751///
9752/// Peer of [`FLEET_PROGRAMS_KEY_NAME`] and [`M3_KEY_PLACEMENT`] on
9753/// the same fleet-programs values schema — `FLEET_PROGRAMS_KEY_NAME`
9754/// carries the per-entry Servico-name discriminator (the `:membros`
9755/// row's own `:caixa` binding), `M3_KEY_PLACEMENT` carries the M3
9756/// placement overlay cloned per entry, and this constant carries the
9757/// per-entry parent-Aplicacao-nome annotation the aggregator uses to
9758/// group entries back into their Aplicacao graph. Together the three
9759/// per-entry keys (plus the top-level [`FLEET_PROGRAMS_KEY_PROGRAMS`]
9760/// array key) name every axis one `programs[]` entry the caixa-mesh
9761/// fan-out emits contributes to the substrate operator's read shape.
9762///
9763/// One production consumer writes this key:
9764/// [`caixa_mesh::programs_for_aplicacao`] — the Aplicacao-side
9765/// per-`:membros` entry-builder writes the parent-Aplicacao-nome
9766/// annotation at this exact key (seeded from the enclosing Caixa's
9767/// `:nome`), at `caixa-mesh/src/lib.rs`'s per-member
9768/// `entry.insert("aplicacao".into(), …)` call. Unlike the peer
9769/// [`FLEET_PROGRAMS_KEY_NAME`] axis (written by both caixa-flux's
9770/// per-Servico entry builder and caixa-mesh's per-`:membros` builder
9771/// — a Servico rendered standalone has no parent-Aplicacao annotation
9772/// to carry), the parent-Aplicacao-nome annotation is emitted only
9773/// by the caixa-mesh Aplicacao-side fan-out — Servicos rendered
9774/// standalone through the caixa-flux path leave the annotation
9775/// absent, which is exactly the discriminator the operator's
9776/// aggregator uses to distinguish Aplicacao-graph-scoped entries
9777/// from stand-alone Servico entries.
9778///
9779/// Until this lift landed the caixa-mesh emitter carried the bare
9780/// `"aplicacao"` byte inline at its `entry.insert("aplicacao".into(),
9781/// …)` call, and the peer in-file test probe (the
9782/// `programs_for_aplicacao_annotates_with_parent_nome` fixture's
9783/// `e.get("aplicacao").and_then(|v| v.as_str())` navigation) carried
9784/// the same bare byte at its readback site. A future fleet-programs
9785/// schema-key rebrand on the per-entry parent-Aplicacao-annotation
9786/// axis (per the same trajectory the sibling [`FLEET_PROGRAMS_KEY_NAME`]
9787/// doc-comment names — the `lareira-fleet-programs` library chart
9788/// moving its per-entry parent-graph-annotation to a namespaced
9789/// `pleme.pleme.io/aplicacao` for multi-tenant aggregator isolation
9790/// once the M4 flat-`programs[]`-per-cluster shape splits into
9791/// per-graph sequences, or to `graph:` for parity with the M3
9792/// `:contratos` graph nomenclature, or to typed `parent:` on the
9793/// ABSORPTION-ROADMAP.md M4 hierarchical-fleet trajectory) without
9794/// a coordinated edit across both sites would silently split the
9795/// schema: the emitter would write under the drifted key while the
9796/// aggregator's per-Aplicacao filter would still read `aplicacao:`
9797/// — every fan-out entry would silently vanish from its parent
9798/// graph's projected view at the aggregator's per-Aplicacao reduce
9799/// step, with the failure surfacing as "the Aplicacao's Servicos
9800/// never appear in per-graph observability filters" far from the
9801/// rebrand commit's source. Lifting the literal to one `&'static
9802/// str` closes the drift footgun structurally — every consumer
9803/// reads the same memory, so any future rebrand reaches both sites
9804/// by construction and a CI build that re-introduces a sibling
9805/// inline `"aplicacao"` literal trips the peer pinning tests at the
9806/// build-time fail-before-deploy posture every prior load-bearing-
9807/// string lift on this surface ([`FLEET_PROGRAMS_KEY_PROGRAMS`] on
9808/// the sibling fleet-programs top-level array-key axis,
9809/// [`FLEET_PROGRAMS_KEY_NAME`] on the peer per-entry name-
9810/// discriminator axis, [`M3_KEY_PLACEMENT`] / [`M2_KEY_LIMITS`] /
9811/// [`M2_KEY_BEHAVIOR`] / [`M2_KEY_UPGRADE_FROM`] on the peer per-
9812/// entry overlay-key surfaces) establishes.
9813///
9814/// Byte-identical to the string form of the
9815/// [`caixa_core::CaixaKind::Aplicacao`] enum variant today — both
9816/// resolve to the same nine-byte `"aplicacao"` literal — but
9817/// semantically distinct: `CaixaKind`'s `Aplicacao` variant names
9818/// the `:kind` enum arm (the typed kind-tag every `defcaixa` selects
9819/// among), while this constant names the `lareira-fleet-programs`
9820/// library chart's per-entry parent-graph-annotation axis (spelled
9821/// per the chart's `values.schema.json` — a separate schema
9822/// contract, one whose future rebrand can land independently of the
9823/// kind-tag axis). Splitting the two lets each schema's future
9824/// rebrand land at its canonical const/variant definition without
9825/// coupling the `:kind` enum-tag axis to the fleet-programs values-
9826/// schema axis (or vice versa) — the same discipline the sibling
9827/// [`FLEET_PROGRAMS_KEY_NAME`] doc-comment establishes vs.
9828/// [`KUBE_KEY_NAME`] on the K8s CR canonical name-axis.
9829pub const FLEET_PROGRAMS_KEY_APLICACAO: &str = "aplicacao";
9830
9831/// Canonical `lareira-fleet-programs` values-schema key naming the
9832/// per-entry version-constraint discriminator — the `versao:` field
9833/// each rendered `programs[]` entry carries so the substrate operator's
9834/// per-`:membros` resolver can resolve each member's caixa.lisp against
9835/// its Aplicacao-declared version-constraint. Every `:membros` row's
9836/// `:versao` (the semver / range constraint the M3 Aplicacao names on
9837/// its `:membros` list) flows through this exact key on the emitted
9838/// per-entry programs.yaml row.
9839///
9840/// Peer of [`FLEET_PROGRAMS_KEY_NAME`], [`FLEET_PROGRAMS_KEY_APLICACAO`],
9841/// and [`M3_KEY_PLACEMENT`] on the same fleet-programs values schema —
9842/// `FLEET_PROGRAMS_KEY_NAME` carries the per-entry Servico-name
9843/// discriminator (each `:membros` row's `:caixa` binding),
9844/// `FLEET_PROGRAMS_KEY_APLICACAO` carries the per-entry parent-graph
9845/// annotation, `M3_KEY_PLACEMENT` carries the M3 placement overlay
9846/// cloned per entry, and this constant carries the per-entry version-
9847/// constraint the operator's resolver reads to fetch the correct
9848/// caixa.lisp release. Together the four per-entry keys (plus the
9849/// top-level [`FLEET_PROGRAMS_KEY_PROGRAMS`] array key) name every axis
9850/// one `programs[]` entry the caixa-mesh fan-out emits contributes to
9851/// the substrate operator's read shape.
9852///
9853/// One production consumer writes this key:
9854/// [`caixa_mesh::programs_for_aplicacao`] — the Aplicacao-side
9855/// per-`:membros` entry-builder writes the per-entry version-
9856/// constraint at this exact key (seeded from each `:membros` row's
9857/// `:versao` binding), at `caixa-mesh/src/lib.rs`'s per-member
9858/// `entry.insert("versao".into(), …)` call. Unlike the peer
9859/// [`FLEET_PROGRAMS_KEY_NAME`] axis (written by both caixa-flux's
9860/// per-Servico entry builder and caixa-mesh's per-`:membros` builder
9861/// — a Servico rendered standalone through the caixa-flux path resolves
9862/// its own `:versao` from its `caixa.lisp` root and hands it to the
9863/// resolver via a distinct path), the per-`:membros` version-constraint
9864/// annotation is emitted only by the caixa-mesh Aplicacao-side fan-out.
9865///
9866/// Until this lift landed the caixa-mesh emitter carried the bare
9867/// `"versao"` byte inline at its `entry.insert("versao".into(), …)`
9868/// call — a partial single-source where three of four per-entry
9869/// fleet-programs axis keys were canonical
9870/// ([`FLEET_PROGRAMS_KEY_NAME`] via 030a63f,
9871/// [`FLEET_PROGRAMS_KEY_APLICACAO`] via cc69ac2, [`M3_KEY_PLACEMENT`])
9872/// and the fourth was scattered. Lifting the fourth key completes the
9873/// fleet-programs values-schema single-sourcing across every per-entry
9874/// axis; every future per-graph aggregator, per-`:membros` resolver,
9875/// per-entry version-constraint consumer inherits the same `&'static
9876/// str` by construction. A future schema-key rebrand on the per-entry
9877/// version-constraint axis (a namespaced `pleme.pleme.io/versao` for
9878/// multi-tenant aggregator isolation, or `version:` for parity with
9879/// upstream conventions, or typed `constraint:` on the ABSORPTION-
9880/// ROADMAP.md M4 typed-resolver trajectory) lands at the one const
9881/// rather than scattered across every future per-emitter/per-resolver
9882/// site.
9883///
9884/// Byte-identical to the `Membro::versao` field name on the M3
9885/// [`AplicacaoSpec`](aplicacao::AplicacaoSpec) today — both resolve to the same six-byte `"versao"`
9886/// literal — but semantically distinct: `Membro::versao` names the
9887/// author-side `:versao` slot on each `:membros` row (the typed
9888/// version-constraint slot every `defcaixa` populates on its
9889/// `:membros` list), while this constant names the
9890/// `lareira-fleet-programs` library chart's per-entry version-
9891/// constraint axis (spelled per the chart's `values.schema.json` — a
9892/// separate schema contract, one whose future rebrand can land
9893/// independently of the author-side slot-name axis). Splitting the two
9894/// lets each schema's future rebrand land at its canonical const /
9895/// field definition without coupling the author-side slot-name axis to
9896/// the fleet-programs values-schema axis (or vice versa) — the same
9897/// discipline the sibling [`FLEET_PROGRAMS_KEY_APLICACAO`] doc-comment
9898/// establishes vs. the [`CaixaKind::Aplicacao`] enum-variant tag.
9899pub const FLEET_PROGRAMS_KEY_VERSAO: &str = "versao";
9900
9901/// Canonical pleme-io label namespace prefix. Every cluster object
9902/// emitted by any caixa-side renderer that needs to carry the
9903/// pleme-io workload identity uses this prefix; runtime label
9904/// injectors (`lareira-fleet-programs` chart's pod template,
9905/// `pleme-computeunit` library chart's identity sidecar, the
9906/// caixa-operator's pod-mutating webhook) and runtime label
9907/// consumers (Cilium identity-based policy, Hubble flow attribution,
9908/// `caixa-mesh`'s policy / Gateway emission, future
9909/// observability/tracing renderers) all spell the same prefix
9910/// exactly the same way — drift between *any* of those = a
9911/// CiliumNetworkPolicy that matches no pods, a Hubble flow that
9912/// can't be correlated to its workload, an OpenTelemetry resource
9913/// attribute that doesn't join to its caixa lacre.
9914///
9915/// Lifted to a const so a future top-level rebrand or multi-tenant
9916/// label-namespace migration is a one-line edit, not a search-and-
9917/// replace across every renderer crate.
9918pub const PLEME_LABEL_PREFIX: &str = "pleme.pleme.io";
9919
9920/// Canonical pleme-io label key naming the **Aplicacao** the workload
9921/// belongs to. Together with [`LABEL_PROGRAM`] this is the load-bearing
9922/// identity tuple every per-Aplicacao mesh renderer (Cilium, Gateway,
9923/// future caixa-otel) keys off — `(LABEL_APLICACAO, LABEL_PROGRAM)` =
9924/// the unique workload selector inside one cluster.
9925pub const LABEL_APLICACAO: &str = "pleme.pleme.io/aplicacao";
9926
9927/// Canonical pleme-io label key naming the **program** (i.e. the
9928/// caixa Servico's `:nome`) a pod runs. `LABEL_APLICACAO` +
9929/// `LABEL_PROGRAM` together pick exactly one workload identity in one
9930/// cluster. Used as the `matchLabels` axis on every Cilium
9931/// `endpointSelector` / `fromEndpoints` rule and on Gateway API
9932/// `backendRefs` selectors emitted by [`crate`]'s downstream
9933/// renderers.
9934pub const LABEL_PROGRAM: &str = "pleme.pleme.io/program";
9935
9936/// Canonical pleme-io label key naming the **contrato** (the M3
9937/// `:contratos` edge: `<de>-to-<para>`) a CiliumNetworkPolicy enforces.
9938/// Carried on the policy's *own* labels (not on workload pods) so
9939/// Hubble + cluster operators can group flows by typed contrato edge,
9940/// not just by source/destination pod identity.
9941pub const LABEL_CONTRATO: &str = "pleme.pleme.io/contrato";
9942
9943/// Canonical M3 `:contratos` edge-direction separator byte-string every
9944/// caixa-mesh emitter that encodes a typed edge as a K8s-name-shaped
9945/// scalar (the [`LABEL_CONTRATO`] label value carried on every
9946/// per-`(:de, :para)` `CiliumNetworkPolicy`'s `metadata.labels`, and
9947/// the per-`(:de, :para)` `CiliumNetworkPolicy`'s `metadata.name`
9948/// itself) inserts between the `:de` and `:para` halves of the typed
9949/// edge tuple. Load-bearing on both the writer half (the CNP renderer)
9950/// and the reader half (Hubble flow grouping by contrato label,
9951/// per-CNP operator filters, `kubectl get cnp -l pleme.pleme.io/contrato=<de>-to-<para>`
9952/// grep-by-label). Until this lift landed the `-to-` byte-string sat
9953/// in two verbatim inline-`format!` sites at the caixa-mesh
9954/// `cilium_network_policies` emitter — one at the
9955/// [`LABEL_CONTRATO`] `labels.insert(...)` call and one at the
9956/// [`kube_resource_skeleton`] `name:` argument — with no compile-time
9957/// link between them. A future edge-encoding rebrand (`-to-` → `->`
9958/// for compactness, `-to-` → `_to_` to reserve `-` for embedded
9959/// DNS-1123-label boundaries, an edge-direction-arrow migration to
9960/// UTF-8 shapes) would have had to be threaded through both sites in
9961/// lockstep or the two would silently split: one CNP's `metadata.name`
9962/// keys off the drifted encoding, its own `metadata.labels.pleme.pleme.io/contrato`
9963/// value keys off the original, and every operator-side grep-by-label
9964/// query (`kubectl get cnp -l pleme.pleme.io/contrato=cart-to-catalog`)
9965/// finds the label but the resulting CNP's `metadata.name` no longer
9966/// matches the queried edge encoding. Every downstream consumer that
9967/// joins the two axes (the M4 mesh-graph audit, the future Hubble-side
9968/// contrato-flow renderer, the operator's per-edge policy inspector)
9969/// silently loses the join. Lifted onto one `&'static str` so a future
9970/// edge-encoding rebrand lands at one const, and every downstream
9971/// consumer picks up the new encoding by construction.
9972pub const CONTRATO_EDGE_LABEL_SEPARATOR: &str = "-to-";
9973
9974/// Canonical M3 `:contratos` edge label value — the `<de>-to-<para>`
9975/// K8s-name-shaped scalar every per-`(:de, :para)` `CiliumNetworkPolicy`
9976/// document carries at its `metadata.labels.pleme.pleme.io/contrato`
9977/// axis (the [`LABEL_CONTRATO`] label key). Composes on the lifted
9978/// [`CONTRATO_EDGE_LABEL_SEPARATOR`] byte-string so a future
9979/// edge-encoding rebrand lands at one canonical composition, and every
9980/// downstream consumer that grep-by-label picks up the new encoding by
9981/// construction.
9982///
9983/// Peer of [`cilium_network_policy_name`] on the sibling per-`(:de,
9984/// :para)` CNP `metadata.name` encoding axis — the CNP name composes
9985/// on this helper's output (the CNP `metadata.name` is
9986/// `format!("{aplicacao}-{contrato_edge_label(de, para)}")`), so a
9987/// future rebrand on either axis reaches both consumers through one
9988/// canonical composition instead of a coordinated two-site rewrite of
9989/// caixa-mesh's `cilium_network_policies` per-`(:de, :para)` group's
9990/// [`LABEL_CONTRATO`] `labels.insert(...)` call and the
9991/// [`kube_resource_skeleton`] `name:` argument.
9992#[must_use]
9993pub fn contrato_edge_label(de: &str, para: &str) -> String {
9994 format!("{de}{CONTRATO_EDGE_LABEL_SEPARATOR}{para}")
9995}
9996
9997/// Canonical per-`(:de, :para)` `CiliumNetworkPolicy` `metadata.name`
9998/// K8s-name-shaped scalar every caixa-mesh `cilium_network_policies`
9999/// emitter mounts its per-edge CNP under. Composes on the lifted
10000/// [`contrato_edge_label`] helper (the CNP name is the parent
10001/// Aplicacao's `:nome` joined to the contrato-edge-label by a
10002/// canonical `-` separator: `format!("{aplicacao}-{edge}")`), so the
10003/// two axes — the CNP `metadata.labels.pleme.pleme.io/contrato` value
10004/// and the CNP `metadata.name` — share one canonical
10005/// edge-encoding source of truth ([`CONTRATO_EDGE_LABEL_SEPARATOR`]).
10006///
10007/// Peer of [`contrato_edge_label`] on the parent-composition axis —
10008/// the two writer-side helpers close the canonical
10009/// `(LABEL_CONTRATO-value, metadata.name)` per-CNP identity pair so a
10010/// future edge-encoding rebrand or a per-emitter typo can't silently
10011/// split the two axes at emit time and orphan every operator-side
10012/// grep-by-label query at apply time far from the source caixa.lisp.
10013///
10014/// The `aplicacao` prefix scopes the emitted CNP to its owning
10015/// Aplicacao (so two Aplicacaos hosting a same-named `(de, para)`
10016/// contrato edge — `checkout-cart-to-catalog` vs
10017/// `orders-cart-to-catalog` — land at distinct CNP `metadata.name`s
10018/// with no `kubectl apply` collision at the shared namespace).
10019#[must_use]
10020pub fn cilium_network_policy_name(aplicacao: &str, de: &str, para: &str) -> String {
10021 let edge = contrato_edge_label(de, para);
10022 format!("{aplicacao}-{edge}")
10023}
10024
10025/// Canonical per-`:entrada` `HTTPRoute` `metadata.name` K8s-name-shaped
10026/// scalar every caixa-mesh `gateway_routes` emitter mounts its
10027/// per-`:entrada` HTTPRoute under. Composes the parent Aplicacao's
10028/// `:nome` and the `:entrada :para` destination Servico's `:nome` on a
10029/// canonical `-` separator (`format!("{aplicacao}-{para}")`), so the
10030/// per-`(:aplicacao, :entrada.para)` HTTPRoute identity axis lives at
10031/// one composer instead of a verbatim inline `format!("{}-{}",
10032/// caixa.nome, entrada.para)` at the [`caixa_mesh::gateway_routes`]
10033/// [`kube_resource_skeleton`] `name:` argument.
10034///
10035/// Peer of [`cilium_network_policy_name`] on the sibling per-Aplicacao
10036/// per-CR K8s-name-shaped-identity-scalar axis: the CNP name composer
10037/// carries the per-`(:de, :para)` L4/L7 policy CR name and this
10038/// composer carries the per-`:entrada` L7 route CR name; both share
10039/// the same "aplicacao-prefixed sub-identity" discipline (a per-CR
10040/// identity scalar keyed off the parent Aplicacao's `:nome` joined to
10041/// the per-CR sub-axis by a canonical `-` separator) so a future
10042/// substrate-side per-Aplicacao Gateway API axis extension
10043/// (`GRPCRoute` on grpc-shaped `:contratos` payloads once the sibling
10044/// [`WitTarget`] variant lands, `TCPRoute` on the sibling l4-only
10045/// tcp-shaped payload axis, per-`:entrada` `HTTPRouteFilter` /
10046/// `BackendTLSPolicy` overlays the Gateway API v1.x per-route policy
10047/// extension surface acknowledges) reaches the shared "aplicacao-prefix
10048/// + sub-axis + canonical `-` separator" naming discipline through
10049/// this composer's peer-shape by construction. Until this lift landed
10050/// the HTTPRoute `metadata.name` axis sat as a verbatim inline
10051/// `format!("{}-{}", caixa.nome, entrada.para)` at the
10052/// [`caixa_mesh::gateway_routes`] emitter (with an in-file test-side
10053/// probe pinning the expected `checkout-cart` shape by verbatim
10054/// literal), and any future name-encoding rebrand on this axis
10055/// (`<aplicacao>-<para>` → `<aplicacao>-httproute-<para>` for
10056/// operator-side per-CR-kind disambiguation once the sibling
10057/// GRPCRoute / TCPRoute lands and their names would otherwise collide,
10058/// `<aplicacao>-<para>` → `<aplicacao>.<para>` on a DNS-1123-subdomain-
10059/// safe axis migration, a per-namespace scoping prefix for
10060/// multi-tenant Aplicacao hosting) would have had to be threaded
10061/// through both sites in lockstep or the HTTPRoute `metadata.name`
10062/// silently split from the operator-side grep-by-name / `kubectl get
10063/// httproute -n tatara-system <aplicacao>-<para>` lookup encoding at
10064/// apply time far from the source caixa.lisp.
10065///
10066/// The `aplicacao` prefix scopes the emitted HTTPRoute to its owning
10067/// Aplicacao (so two Aplicacaos hosting a same-named `:entrada :para`
10068/// destination — `checkout-cart` vs `orders-cart` — land at distinct
10069/// HTTPRoute `metadata.name`s with no `kubectl apply` collision at the
10070/// shared namespace, mirroring the peer CNP `metadata.name` collision
10071/// posture the sibling [`cilium_network_policy_name`] composer's
10072/// docstring names).
10073#[must_use]
10074pub fn gateway_api_http_route_name(aplicacao: &str, para: &str) -> String {
10075 format!("{aplicacao}-{para}")
10076}
10077
10078/// Canonical K8s API key naming the resource's API-version selector
10079/// (e.g. `cilium.io/v2`, `gateway.networking.k8s.io/v1`,
10080/// `wasm.pleme.io/v1alpha1`). Lifted to a const so a future API-server
10081/// rename or a multi-version-skew migration is a one-line edit, not a
10082/// search-and-replace across every per-target renderer.
10083pub const KUBE_KEY_API_VERSION: &str = "apiVersion";
10084/// Canonical K8s API key naming the resource's kind discriminator
10085/// (e.g. `CiliumNetworkPolicy`, `Gateway`, `HTTPRoute`, `ComputeUnit`).
10086pub const KUBE_KEY_KIND: &str = "kind";
10087/// Canonical K8s API key naming the resource's metadata block.
10088pub const KUBE_KEY_METADATA: &str = "metadata";
10089/// Canonical K8s API key naming the resource's name (under metadata).
10090pub const KUBE_KEY_NAME: &str = "name";
10091/// Canonical K8s API key naming the resource's namespace (under metadata).
10092pub const KUBE_KEY_NAMESPACE: &str = "namespace";
10093/// Canonical K8s API key naming the resource's labels (under metadata).
10094pub const KUBE_KEY_LABELS: &str = "labels";
10095/// Canonical K8s API key naming the resource's per-kind body (sibling
10096/// to [`KUBE_KEY_METADATA`] at the K8s CR top level). Every typed
10097/// substrate renderer that materializes a CR populates `spec.*` from
10098/// the source caixa.lisp — caixa-mesh's `cilium_network_policies`
10099/// per-`(:de, :para)` `CiliumNetworkPolicy` emitter (the policy's
10100/// `endpointSelector` / `ingress` block lives under spec),
10101/// caixa-mesh's `gateway_routes` `Gateway` + `HTTPRoute` emitter (the
10102/// listeners / rules / parentRefs block lives under spec),
10103/// caixa-flux's `programs_yaml_entry` + `upsert_into_helmrelease_programs`
10104/// (the fleet `HelmRelease`'s `spec.values.programs[]` axis),
10105/// caixa-helm's `values.yaml` builder (the upstream ComputeUnit YAML's
10106/// `spec.*` axis the rendered `lareira-<nome>` chart re-routes through
10107/// the library alias). Spelled exactly as the K8s apiserver expects
10108/// (the canonical OpenAPI v3 schema property name K8s machinery
10109/// validates against on every CR registration), so the rendered YAML
10110/// round-trips through every K8s schema parser without per-renderer
10111/// string drift. Lifted on the trajectory the peer
10112/// [`KUBE_KEY_API_VERSION`] / [`KUBE_KEY_KIND`] /
10113/// [`KUBE_KEY_METADATA`] / [`KUBE_KEY_NAME`] / [`KUBE_KEY_NAMESPACE`]
10114/// / [`KUBE_KEY_LABELS`] / [`KUBE_KEY_MATCH_LABELS`] canonical-K8s-
10115/// API-key constants establish.
10116pub const KUBE_KEY_SPEC: &str = "spec";
10117/// Canonical K8s API key naming the `matchLabels` axis of a
10118/// [`LabelSelector`][k8s-ls] — the equality-based projection of the
10119/// selector schema (the other axis, `matchExpressions`, is set-based
10120/// and intentionally out-of-scope for the V0 [`label_selector`]
10121/// helper). Spelled exactly as the K8s apiserver expects (camelCase
10122/// `matchLabels`, not `match_labels` / `MatchLabels` / `match-labels`)
10123/// so the rendered YAML round-trips through every K8s schema parser
10124/// (Cilium CRDs, Gateway API, `ComputeUnit`, future
10125/// `mesh.pleme.io/v1alpha1/Aplicacao`) without per-renderer string
10126/// drift.
10127///
10128/// [k8s-ls]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#labelselector-v1-meta
10129pub const KUBE_KEY_MATCH_LABELS: &str = "matchLabels";
10130
10131/// Canonical K8s API key naming the per-CR **`rules` collection** axis —
10132/// the container the apiserver-side OpenAPI schema for every rule-shaped
10133/// CR (Cilium L7 `spec.ingress[].toPorts[].rules`, Gateway API
10134/// `HTTPRoute.spec.rules[]`, RBAC `Role.rules[]` /
10135/// `ClusterRole.rules[]`, and every future rule-list-shaped CR the M4
10136/// `mesh.pleme.io/v1alpha1/Aplicacao` materializer + the per-edge
10137/// `CiliumClusterwideEnvoyConfig` emitter will land on) mounts the
10138/// per-CR list of match/action rules under. Spelled exactly as the K8s
10139/// apiserver expects (lowercase `rules`, not `Rules` / `rule` /
10140/// `ruleset`) so the rendered YAML round-trips through every K8s schema
10141/// parser without per-renderer string drift.
10142///
10143/// Two production-code call sites in this crate's downstream
10144/// [`caixa-mesh`][cm] renderer carry this key on the same
10145/// K8s-rule-list-axis surface (both landing sites lived at inline
10146/// `"rules".into()` before this lift):
10147///
10148/// 1. `cilium_network_policies` — the per-`(:de, :para)`
10149/// `CiliumNetworkPolicy` emitter's per-`toPorts[]` `rules:` mapping
10150/// (the Cilium L7 rule-list container that carries the `http:` /
10151/// `kafka:` / `dns:` per-protocol L7 rules the Cilium data plane
10152/// dispatches on).
10153/// 2. `gateway_routes` — the `HTTPRoute` emitter's top-level
10154/// `spec.rules[]` sequence (the Gateway API rule-list container that
10155/// carries the per-rule `matches[]` + `backendRefs[]` + timeouts /
10156/// retries overlay the gateway-class-controller dispatches on).
10157///
10158/// Five test-side traversal sites in the same renderer navigate the
10159/// rendered mesh bundle's per-CR `rules:` axis to pin per-CR L7-rule /
10160/// Gateway-API-rule presence, absence, and content invariants (the
10161/// `.get("rules")` retrievals under `toPorts[]` on the L7 policy pins
10162/// and under `spec` on the HTTPRoute pins). All seven sites now route
10163/// through this const so a future K8s CRD schema rebrand on the shared
10164/// axis (or the canonical typo footgun `"Rules"` / `"rule"` /
10165/// `"ruleset"`) surfaces at this one const rather than as an admission-
10166/// time silent drop across two distinct CR emitters.
10167///
10168/// Lifted on the trajectory the peer [`KUBE_KEY_API_VERSION`] /
10169/// [`KUBE_KEY_KIND`] / [`KUBE_KEY_METADATA`] / [`KUBE_KEY_NAME`] /
10170/// [`KUBE_KEY_NAMESPACE`] / [`KUBE_KEY_LABELS`] / [`KUBE_KEY_SPEC`] /
10171/// [`KUBE_KEY_MATCH_LABELS`] canonical-K8s-API-key constants establish
10172/// — extends the K8s-CR top-level `(apiVersion, kind, metadata, spec)`
10173/// axis quartet + the nested `metadata.{name, namespace, labels}`
10174/// triplet + the `LabelSelector.matchLabels` selector-projection axis
10175/// onto the load-bearing nested `spec.rules[]` / `toPorts[].rules`
10176/// rule-list container axis every downstream L7-policy /
10177/// HTTPRoute-rule-dispatch consumer of the rendered mesh bundle keys
10178/// off.
10179///
10180/// [cm]: ../../caixa_mesh/index.html
10181pub const KUBE_KEY_RULES: &str = "rules";
10182
10183/// Canonical K8s API key naming the per-CR **L4 port** scalar axis —
10184/// the field the apiserver-side OpenAPI schema for every port-carrying
10185/// CR body-position (Cilium L7 `spec.ingress[].toPorts[].ports[].port`
10186/// per-port-tuple L4 port number, Gateway API
10187/// `Gateway.spec.listeners[].port` per-listener L4 port number,
10188/// Gateway API `HTTPRoute.spec.rules[].backendRefs[].port` per-rule
10189/// per-backend L4 port number, and every future port-shaped CR body-
10190/// position the M4 `mesh.pleme.io/v1alpha1/Aplicacao` materializer +
10191/// the per-edge `CiliumClusterwideEnvoyConfig` emitter will land on)
10192/// mounts the L4 port value under. Spelled exactly as the K8s
10193/// apiserver expects (lowercase `port`, not `Port` / `portNumber` /
10194/// `portValue` / `targetPort` — the L4-port-number axis, distinct
10195/// from the `targetPort` L4-forwarding-destination axis on the K8s
10196/// Service CRD that lives on a sibling field name the port-value
10197/// axis is not) so the rendered YAML round-trips through every K8s
10198/// schema parser without per-renderer string drift.
10199///
10200/// Three production-code call sites in this crate's downstream
10201/// [`caixa-mesh`][cm] renderer carry this key on the same
10202/// K8s-L4-port-scalar-axis surface (all three landing sites lived at
10203/// inline `"port".into()` before this lift):
10204///
10205/// 1. `cilium_network_policies` — the per-`(:de, :para)`
10206/// `CiliumNetworkPolicy` emitter's per-`toPorts[].ports[]` port-
10207/// tuple entry's `port:` scalar (the L4 port number the Cilium
10208/// data plane's per-tuple bpf policy dispatch loop compares
10209/// against the observed TCP/UDP L4 header port value).
10210/// 2. `gateway_routes` — the `Gateway` emitter's per-listener
10211/// `spec.listeners[].port` scalar (the L4 port number the
10212/// gateway-class-controller's per-listener bind loop opens the
10213/// listener socket on).
10214/// 3. `gateway_routes` — the `HTTPRoute` emitter's per-rule
10215/// `spec.rules[].backendRefs[].port` scalar (the L4 port number
10216/// the gateway-class-controller's per-rule backend-dispatch loop
10217/// forwards the matched request to on the resolved Service /
10218/// ExternalName backend).
10219///
10220/// Two test-side traversal sites in the same renderer navigate the
10221/// rendered mesh bundle's per-CR L4-port scalar axis to pin per-CR
10222/// port-value content invariants (the `.get("port")` retrievals under
10223/// `toPorts[].ports[]` on the L7 policy pin threading through
10224/// [`DEFAULT_SERVICO_PORT`] and under `backendRefs[]` on the
10225/// HTTPRoute-backend-port pin). All five sites now route through this
10226/// const so a future K8s CRD schema rebrand on the shared axis (or
10227/// the canonical typo footgun `"Port"` / `"portNumber"` /
10228/// `"portValue"`) surfaces at this one const rather than as an
10229/// admission-time silent drop across three distinct CR emitters.
10230///
10231/// Lifted on the trajectory the peer [`KUBE_KEY_API_VERSION`] /
10232/// [`KUBE_KEY_KIND`] / [`KUBE_KEY_METADATA`] / [`KUBE_KEY_NAME`] /
10233/// [`KUBE_KEY_NAMESPACE`] / [`KUBE_KEY_LABELS`] / [`KUBE_KEY_SPEC`] /
10234/// [`KUBE_KEY_MATCH_LABELS`] / [`KUBE_KEY_RULES`] canonical-K8s-API-
10235/// key constants establish — extends the K8s-CR top-level
10236/// `(apiVersion, kind, metadata, spec)` axis quartet + the nested
10237/// `metadata.{name, namespace, labels}` triplet + the
10238/// `LabelSelector.matchLabels` selector-projection axis + the
10239/// `spec.rules[]` / `toPorts[].rules` rule-list container axis onto
10240/// the load-bearing nested L4-port-scalar axis every downstream
10241/// bpf-policy-dispatch / gateway-listener-bind / gateway-backend-
10242/// dispatch consumer of the rendered mesh bundle keys off.
10243///
10244/// [cm]: ../../caixa_mesh/index.html
10245pub const KUBE_KEY_PORT: &str = "port";
10246
10247/// Canonical K8s API key naming the per-CR **L4/L7 protocol**
10248/// scalar-discriminator axis — the field the apiserver-side `OpenAPI`
10249/// schema for every protocol-carrying CR body-position (Cilium L7
10250/// `spec.ingress[].toPorts[].ports[].protocol` per-port-tuple L4
10251/// transport protocol discriminator picking between `TCP` / `UDP` /
10252/// `SCTP` / `ANY`, Gateway API `Gateway.spec.listeners[].protocol`
10253/// per-listener L7 listener-protocol discriminator picking between
10254/// `HTTP` / `HTTPS` / `TCP` / `TLS` / `UDP`, and every future
10255/// protocol-shaped CR body-position the M4
10256/// `mesh.pleme.io/v1alpha1/Aplicacao` materializer + the per-edge
10257/// `CiliumClusterwideEnvoyConfig` emitter will land on) mounts the
10258/// protocol-value discriminator under. Spelled exactly as the K8s
10259/// apiserver expects (lowercase `protocol`, not `Protocol` /
10260/// `proto` / `transportProtocol` — the singular scalar-key
10261/// convention K8s uses across every protocol-carrying CR family,
10262/// distinct from the `protocols[]` plural-container axis used on a
10263/// few application-layer-protocol CRDs which is not this axis) so
10264/// the rendered YAML round-trips through every K8s schema parser
10265/// without per-renderer string drift.
10266///
10267/// Two production-code call sites in this crate's downstream
10268/// [`caixa-mesh`][cm] renderer carry this key on the same
10269/// K8s-protocol-scalar-axis surface (both landing sites lived at
10270/// inline `"protocol".into()` before this lift):
10271///
10272/// 1. `cilium_network_policies` — the per-`(:de, :para)`
10273/// `CiliumNetworkPolicy` emitter's per-`toPorts[].ports[]` port-
10274/// tuple entry's `protocol:` scalar (the L4 transport protocol
10275/// discriminator the Cilium data plane's per-tuple bpf policy
10276/// dispatch loop compares against the observed L4 header
10277/// protocol before applying the port match — a drifted key here
10278/// makes the per-tuple bpf policy fall back to the CRD default
10279/// `ANY`, silently admitting UDP traffic through a TCP-only
10280/// rule).
10281/// 2. `gateway_routes` — the `Gateway` emitter's per-listener
10282/// `spec.listeners[].protocol` scalar (the L7 listener protocol
10283/// discriminator the gateway-class-controller's per-listener
10284/// bind loop selects the L7 parser + TLS termination strategy
10285/// from — a drifted key here silently fails the listener
10286/// validation, the gateway-class-controller rejects the entire
10287/// `Gateway` object at admission time, no L7 traffic admitted).
10288///
10289/// One test-side traversal site in the same renderer navigates the
10290/// rendered mesh bundle's per-CR protocol scalar axis to pin per-CR
10291/// listener-protocol content invariants (the
10292/// `gateway_emits_gateway_plus_httproute_pair` `.get("protocol")`
10293/// retrieval on the emitted `Gateway`'s first listener pinning the
10294/// canonical `HTTP` listener-protocol value). All three sites now
10295/// route through this const so a future K8s CRD schema rebrand on
10296/// the shared axis (or the canonical typo footgun `"Protocol"` /
10297/// `"proto"` / `"transportProtocol"`) surfaces at this one const
10298/// rather than as an admission-time silent drop across two distinct
10299/// CR emitters.
10300///
10301/// Lifted on the trajectory the peer [`KUBE_KEY_API_VERSION`] /
10302/// [`KUBE_KEY_KIND`] / [`KUBE_KEY_METADATA`] / [`KUBE_KEY_NAME`] /
10303/// [`KUBE_KEY_NAMESPACE`] / [`KUBE_KEY_LABELS`] / [`KUBE_KEY_SPEC`] /
10304/// [`KUBE_KEY_MATCH_LABELS`] / [`KUBE_KEY_RULES`] /
10305/// [`KUBE_KEY_PORT`] canonical-K8s-API-key constants establish —
10306/// extends the K8s-CR top-level `(apiVersion, kind, metadata, spec)`
10307/// axis quartet + the nested `metadata.{name, namespace, labels}`
10308/// triplet + the `LabelSelector.matchLabels` selector-projection
10309/// axis + the `spec.rules[]` / `toPorts[].rules` rule-list container
10310/// axis + the L4-port-scalar axis onto the load-bearing nested
10311/// L4/L7-protocol-scalar-discriminator axis every downstream bpf-
10312/// policy-dispatch / gateway-listener-bind consumer of the rendered
10313/// mesh bundle keys off before it can commit to a port match or a
10314/// listener parser.
10315///
10316/// [cm]: ../../caixa_mesh/index.html
10317pub const KUBE_KEY_PROTOCOL: &str = "protocol";
10318
10319/// Canonical K8s API key naming the per-CR **discriminated-union type**
10320/// scalar-discriminator axis — the field the apiserver-side OpenAPI schema
10321/// for every discriminated-union CR body-position (Gateway API v1
10322/// `HTTPRouteMatch.path.type` per-`HTTPRouteMatch` path-selection-predicate
10323/// discriminator picking between `Exact` / `PathPrefix` /
10324/// `RegularExpression`, K8s core `Condition.type` per-condition kind
10325/// discriminator, K8s core `Volume.<projection>.type` per-projection
10326/// content-source discriminator, and every future discriminated-union CR
10327/// body-position the M4 `mesh.pleme.io/v1alpha1/Aplicacao` materializer
10328/// + the per-edge `CiliumClusterwideEnvoyConfig` emitter's per-listener
10329/// filter-chain type-discriminator + a future per-`:entrada :paths`
10330/// typed slot admitting a per-path `(:predicate <Exact|Prefix|Regex>)`
10331/// axis will land on) mounts the discriminated-union type-value under.
10332/// Spelled exactly as the K8s apiserver expects (lowercase `type`, not
10333/// `Type` / `kind` / `discriminator` — the singular scalar-key
10334/// convention K8s uses across every discriminated-union CR family,
10335/// distinct from the top-level [`KUBE_KEY_KIND`] CRD-registration
10336/// discriminator on the K8s CR top-level which is the CRD-lookup half
10337/// of the `(apiVersion, kind)` tuple the K8s apiserver's `RESTMapper`
10338/// consults and is not this axis) so the rendered YAML round-trips
10339/// through every K8s schema parser without per-renderer string drift.
10340///
10341/// One production-code call site in this crate's downstream
10342/// [`caixa-mesh`][cm] renderer carries this key on the same
10343/// K8s-discriminated-union-type-scalar-axis surface (the landing site
10344/// lived at an inline `"type".into()` before this lift):
10345///
10346/// 1. `gateway_routes` — the `HTTPRoute` emitter's per-rule per-match
10347/// `spec.rules[].matches[].path.type` scalar (the path-selection-
10348/// predicate discriminator the gateway-class-controller's per-rule
10349/// L7 dispatch pass selects the path-match strategy from — a drifted
10350/// key here silently fails the per-match path-selection-predicate
10351/// validation, the Gateway API v1 `PathMatchType` OpenAPI schema
10352/// validator drops the entire `HTTPRoute` object at admission with
10353/// no per-rule L7 URL-path filtering applied, and every external
10354/// `:entrada` path-filtered flow the route was authored to accept
10355/// drops at the gateway-class-controller's admission gate with no
10356/// field naming the discriminator-drift root cause).
10357///
10358/// Pairs with the sibling [`GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX`]
10359/// (530705d) per-`HTTPRouteMatch` path-selection-predicate discriminator
10360/// scalar-VALUE the discriminator scalar-KEY here holds under, closing
10361/// the per-`HTTPRouteMatch` path-selection-predicate `(type key →
10362/// PathPrefix value)` scalar-key/scalar-value discriminator axis pair
10363/// the M3 Aplicacao mesh renderer's external `:entrada` per-path
10364/// L7-filtering ingress contract rests on — the same shape the sibling
10365/// [`KUBE_KEY_PROTOCOL`] (0307950) key + [`KUBE_PROTOCOL_TCP`] (2123047)
10366/// / [`GATEWAY_API_PROTOCOL_HTTP`] (1b57473) value pair already carries
10367/// on the L4/L7-protocol scalar-discriminator surface. A `"Type"` /
10368/// `"kind"` / `"discriminator"` / `"predicate"` typo at the production-
10369/// code call site lands outside the Gateway API v1 `HTTPPathMatch`
10370/// OpenAPI schema's admitted property set, surfacing apply-side as a
10371/// non-self-locating "spec.rules[0].matches[0].path: Unknown field
10372/// \"Type\"" apiserver admission-rejection far from the source
10373/// `caixa.lisp` / the renderer's `path_match.insert(…)` call site.
10374///
10375/// Lifted on the trajectory the peer [`KUBE_KEY_API_VERSION`] /
10376/// [`KUBE_KEY_KIND`] / [`KUBE_KEY_METADATA`] / [`KUBE_KEY_NAME`] /
10377/// [`KUBE_KEY_NAMESPACE`] / [`KUBE_KEY_LABELS`] / [`KUBE_KEY_SPEC`] /
10378/// [`KUBE_KEY_MATCH_LABELS`] / [`KUBE_KEY_RULES`] / [`KUBE_KEY_PORT`] /
10379/// [`KUBE_KEY_PROTOCOL`] canonical-K8s-API-key constants establish —
10380/// extends the K8s-CR top-level `(apiVersion, kind, metadata, spec)`
10381/// axis quartet + the nested `metadata.{name, namespace, labels}`
10382/// triplet + the `LabelSelector.matchLabels` selector-projection axis
10383/// + the `spec.rules[]` / `toPorts[].rules` rule-list container axis +
10384/// the L4-port-scalar axis + the L4/L7-protocol-scalar-discriminator
10385/// axis onto the load-bearing nested discriminated-union-type-scalar-
10386/// discriminator axis every downstream gateway-class-controller /
10387/// apiserver-side OpenAPI-schema-validator consumer of the rendered
10388/// mesh bundle keys off before it can commit to a per-match path-
10389/// selection predicate.
10390///
10391/// [cm]: ../../caixa_mesh/index.html
10392pub const KUBE_KEY_TYPE: &str = "type";
10393
10394/// Default cluster-wide K8s namespace every caixa renderer emits
10395/// objects into when the source caixa doesn't pin its own. The single
10396/// source of truth both [`caixa-flux`][cf]'s programs.yaml /
10397/// GitRepository / HelmRelease / Kustomization emitters and
10398/// [`caixa-mesh`][cm]'s programs fan-out / CiliumNetworkPolicy /
10399/// Gateway / HTTPRoute emitters consult — re-exported by each
10400/// renderer's lib as `pub use caixa_core::DEFAULT_NAMESPACE`, so a
10401/// future per-cluster-namespace rebrand (e.g. moving to `pleme-system`
10402/// once `tatara-system` outlives its scoping intent) is a one-line
10403/// edit here, not a coordinated rewrite across every renderer
10404/// crate's `metadata.namespace` slot.
10405///
10406/// Until this lift landed both renderers carried their own `pub const
10407/// DEFAULT_NAMESPACE: &str = "tatara-system"` declarations
10408/// (caixa-flux/src/lib.rs:77, caixa-mesh/src/lib.rs:172), with the
10409/// `caixa-mesh` site's doc-comment explicitly acknowledging the
10410/// duplication ("Mirrors `caixa_flux::DEFAULT_NAMESPACE`"); a future
10411/// rebrand on either side without a coordinated edit on the other
10412/// would have silently emitted into two distinct namespaces on the
10413/// same cluster's apply — Servicos at programs.yaml's namespace,
10414/// their Aplicacao's NetworkPolicies / Gateways / HTTPRoutes at a
10415/// drifted one — and the CiliumNetworkPolicy's `endpointSelector`
10416/// would match no pods (different namespace), silently dropping every
10417/// L7 contrato flow at apply time with no diagnostic naming the
10418/// namespace-drift root cause.
10419///
10420/// Lifting it to caixa-core's render-constants block alongside the
10421/// peer [`LABEL_APLICACAO`] / [`LABEL_PROGRAM`] / [`LABEL_CONTRATO`]
10422/// label-namespace constants and the canonical [`KUBE_KEY_NAMESPACE`]
10423/// API-key constant makes the namespace-axis discipline structural:
10424/// every renderer that reaches for the default namespace consults the
10425/// same `&'static str`, and every future renderer (the M4
10426/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer, the future
10427/// per-edge `CiliumClusterwideEnvoyConfig` emitter, the future
10428/// caixa-otel collector-pipeline emitter) inherits the same value by
10429/// construction, with no opportunity for per-renderer drift. Same
10430/// "the typed constant lives in one place" discipline the
10431/// [`PLEME_LABEL_PREFIX`] (a8d4d57) and [`KUBE_KEY_API_VERSION`] /
10432/// [`KUBE_KEY_KIND`] / [`KUBE_KEY_METADATA`] lifts apply on the peer
10433/// shared-string axes.
10434///
10435/// [cf]: ../../caixa_flux/index.html
10436/// [cm]: ../../caixa_mesh/index.html
10437pub const DEFAULT_NAMESPACE: &str = "tatara-system";
10438
10439/// Canonical FluxCD installation namespace every `caixa-flux` `Kustomization`
10440/// document apply-targets. The single source of truth both axes of the
10441/// rendered `kustomization.yaml` document reach for:
10442///
10443/// - `metadata.namespace` — the namespace the `Kustomization` resource
10444/// itself lives in (the `FluxCD` `kustomize-controller` watches this
10445/// namespace by default; a drifted value sits outside the controller's
10446/// watch window and is never reconciled);
10447/// - `spec.sourceRef.name` — the `GitRepository` the bootstrap pipeline
10448/// created at `flux bootstrap` time and the per-Servico `Kustomization`
10449/// transitively threads its `path: ./clusters/<cluster>/services/<name>`
10450/// reference through. The canonical FluxCD bootstrap convention names
10451/// this `GitRepository` after the installation namespace (the
10452/// `flux-system` namespace contains a `GitRepository/flux-system`
10453/// pointing at the operator's source-of-truth repo); both axes are the
10454/// same conceptual "Flux installation namespace" load-bearing string
10455/// and must move together on any future rebrand.
10456///
10457/// Until this lift landed both axes carried inline `flux-system` literals
10458/// inside [`cluster_bundle`]'s `kustomization.yaml` format-string template
10459/// (caixa-flux/src/lib.rs:477, 483) — two production-code consumers of the
10460/// same load-bearing FluxCD-installation-namespace convention, drift-prone
10461/// by construction. A future per-cluster Flux installation rebrand (the
10462/// operator moving the bootstrap controllers to a different installation
10463/// namespace, e.g. `flux-pleme` to match the per-tenant scoping convention
10464/// once `flux-system` outlives its scoping intent; or any per-edition
10465/// rebrand the FluxCD upgrade docs name) on one axis without a coordinated
10466/// edit on the other would have silently emitted a `Kustomization` whose
10467/// `metadata.namespace` sat outside the `kustomize-controller` watch
10468/// window (controller-side: never reconciled, every `HelmRelease` /
10469/// `GitRepository` it gates frozen at last-applied state) or whose
10470/// `spec.sourceRef.name` pointed at a `GitRepository` that doesn't exist
10471/// in the rebranded namespace (apply-side: the reference dangles, the
10472/// dependent chart never pulls). The apply-time symptom (the Servico's
10473/// `HelmRelease` is created but never reconciled, or never reaches its
10474/// chart source) is invisible at admission and surfaces only as
10475/// "the cluster says the resources are applied but nothing changed",
10476/// typically far from the rebrand commit's source.
10477///
10478/// Lifting it to caixa-core's render-constants block alongside the peer
10479/// [`DEFAULT_NAMESPACE`] (a085b26, the workload-side
10480/// `tatara-system` namespace every emitted resource lives in) makes the
10481/// installation-namespace axis discipline structural: both kustomization
10482/// axes consult the same `&'static str`, and every future renderer that
10483/// reaches for the canonical Flux installation namespace (the future M4
10484/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
10485/// `Kustomization`, the future per-edge `Kustomization` the operator
10486/// emits for the `CiliumClusterwideEnvoyConfig` pipeline, the future
10487/// `caixa-otel` collector-pipeline `Kustomization`) inherits the same
10488/// value by construction with no opportunity for per-renderer drift.
10489/// Same "the typed constant lives in one place" discipline the
10490/// [`DEFAULT_NAMESPACE`] (a085b26) / [`DEFAULT_LIBRARY_NAME`] (41438dc) /
10491/// [`crate::DEFAULT_SERVICO_PORT`] (1e22add) /
10492/// [`crate::DEFAULT_PUBLISH_TAG_PREFIX`] (0a6a602) lifts apply on the
10493/// peer canonical-load-bearing-string surface.
10494///
10495/// The value is a valid DNS-1123 label (the K8s apiserver-side floor every
10496/// `metadata.namespace` rule enforces): lowercase ASCII alphanumeric with
10497/// `-` separators, no leading / trailing hyphen, length within the
10498/// [`DNS_1123_LABEL_MAX_LEN`] (63-byte) cap. A future rebrand on this lift
10499/// cannot silently land a value the apiserver refuses, by construction:
10500/// the [`default_flux_system_namespace_is_a_valid_dns_1123_label`] pin
10501/// trips at caixa-core build time on any drift past the typed floor.
10502///
10503/// [cf]: ../../caixa_flux/index.html
10504pub const DEFAULT_FLUX_SYSTEM_NAMESPACE: &str = "flux-system";
10505
10506/// Canonical FluxCD `HelmRelease` CRD `apiVersion` every `caixa-flux`
10507/// `helmrelease.yaml` document emits. The Flux v2 `helm-controller` watches
10508/// resources at this exact group/version (`helm.toolkit.fluxcd.io/v2`);
10509/// drift to a stale `v2beta1` / `v2beta2` (the pre-GA Flux v2 betas every
10510/// upstream Flux GA-migration doc names) silently routes the rendered
10511/// `HelmRelease` outside the controller's `Watches` and breaks at apply
10512/// time with a non-self-locating "no kind 'HelmRelease' is registered for
10513/// version 'helm.toolkit.fluxcd.io/v2beta2'" error far from the source
10514/// caixa.lisp / the renderer's format-string template.
10515///
10516/// The single source of truth both axes of the rendered Flux bundle reach
10517/// for:
10518///
10519/// - `helmrelease.yaml` `apiVersion` — the top-level CRD-group/version
10520/// the rendered document declares (caixa-flux/src/lib.rs:455 — the
10521/// `helmrelease` format-string template);
10522/// - `kustomization.yaml` `spec.healthChecks[]` per-entry `apiVersion`
10523/// — the same Flux-v2 `HelmRelease` reference the parent Kustomization
10524/// gates its health-check on (caixa-flux/src/lib.rs:504 — the
10525/// `kustomization` format-string template). The Flux v2 contract pairs
10526/// a `HelmRelease` document with its sibling `Kustomization`'s
10527/// `healthChecks[].apiVersion` axis: both must name the same Flux v2
10528/// `HelmRelease` CRD group/version for the Kustomization's per-resource
10529/// health-gate to bind to the rendered HelmRelease; a future Flux v3
10530/// promotion (the upstream Flux roadmap names a per-CRD-group / per-
10531/// v3 version migration once the Flux v2 LTS branch closes) on one
10532/// axis without a coordinated edit on the other would have silently
10533/// emitted a `Kustomization` whose `healthChecks[].apiVersion` pointed
10534/// at an obsolete CRD group/version (apply-side: the health check
10535/// never resolves, the parent Kustomization sits perpetually in
10536/// `Reconciling`).
10537///
10538/// Until this lift landed both axes carried inline
10539/// `helm.toolkit.fluxcd.io/v2` literals inside [`cluster_bundle`]'s
10540/// `helmrelease.yaml` + `kustomization.yaml` format-string templates and a
10541/// matching pair inside the in-file `upsert_into_helmrelease_programs`
10542/// test fixtures (caixa-flux/src/lib.rs:928, 970) — four occurrences of
10543/// the same load-bearing FluxCD-CRD-group/version convention, drift-prone
10544/// by construction. The PRIME DIRECTIVE duplication-budget rule
10545/// (THEORY.md §I.3.5: "every recurring shape becomes a generator before
10546/// it becomes a pattern; every pattern becomes a library before it
10547/// becomes duplicated code. The duplication budget is zero.") promotes
10548/// the constant to a typed substrate-side `&'static str` on the same
10549/// trajectory the [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) lift
10550/// established on the sibling Flux-installation-namespace axis. The two
10551/// render-side consumers now thread the same `&'static str` through their
10552/// format-string templates so a future Flux v3 promotion lands in one
10553/// place; the test fixtures keep the value as a literal because they
10554/// exercise `serde_yaml::from_str` on a static YAML document — the
10555/// build-time pin [`default_flux_helmrelease_api_version_matches_caixa_flux_test_fixtures`]
10556/// trips if the literals ever drift past the typed const.
10557///
10558/// Same "the typed constant lives in one place" discipline the
10559/// [`DEFAULT_NAMESPACE`] (a085b26) / [`DEFAULT_LIBRARY_NAME`] (41438dc) /
10560/// [`crate::DEFAULT_SERVICO_PORT`] (1e22add) /
10561/// [`crate::DEFAULT_PUBLISH_TAG_PREFIX`] (0a6a602) /
10562/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) lifts apply on the peer
10563/// canonical-load-bearing-string surface.
10564///
10565/// [cf]: ../../caixa_flux/index.html
10566pub const FLUX_HELMRELEASE_API_VERSION: &str = "helm.toolkit.fluxcd.io/v2";
10567
10568/// Canonical FluxCD `GitRepository` CRD `apiVersion` every `caixa-flux`
10569/// `gitrepository.yaml` document emits. The Flux v2 `source-controller`
10570/// watches resources at this exact group/version
10571/// (`source.toolkit.fluxcd.io/v1`); drift to a stale `v1beta1` / `v1beta2`
10572/// (the pre-GA Flux v2 source-controller betas every upstream Flux GA-
10573/// migration doc names) silently routes the rendered `GitRepository`
10574/// outside the controller's `Watches` and breaks at apply time with a
10575/// non-self-locating "no kind 'GitRepository' is registered for version
10576/// 'source.toolkit.fluxcd.io/v1beta2'" error far from the source
10577/// caixa.lisp / the renderer's format-string template.
10578///
10579/// The single source of truth the `gitrepository.yaml` `apiVersion` axis
10580/// reaches for (caixa-flux/src/lib.rs:436 — the `gitrepo` format-string
10581/// template). The Flux v2 source/helm/kustomize controller triple pairs
10582/// each CRD-group/version against its sibling controller's `Watches`
10583/// registration: the rendered `GitRepository` is the chart-source the
10584/// sibling `HelmRelease` document's `spec.chart.spec.sourceRef.kind:
10585/// GitRepository` references, and the parent `Kustomization`'s
10586/// `spec.sourceRef.kind: GitRepository` also points at this same CRD
10587/// group/version. A future Flux v3 promotion on this axis without a
10588/// coordinated edit on the sibling [`FLUX_HELMRELEASE_API_VERSION`] /
10589/// future-`FLUX_KUSTOMIZATION_API_VERSION` axes would silently land the
10590/// rendered `GitRepository` outside the source-controller's `Watches`
10591/// (controller-side: never reconciled, the dependent HelmRelease's
10592/// `chart: sourceRef` dangles, every per-Servico apply silently comes
10593/// up with the prior reconciled state).
10594///
10595/// Until this lift landed the axis carried an inline
10596/// `source.toolkit.fluxcd.io/v1` literal inside [`cluster_bundle`]'s
10597/// `gitrepository.yaml` format-string template — one occurrence today,
10598/// promoted to a typed substrate-side `&'static str` on the same
10599/// trajectory the [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) /
10600/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) lifts established on the
10601/// sibling Flux-v2-load-bearing-string surface. The render-side consumer
10602/// now threads the same `&'static str` through its format-string
10603/// template so a future Flux v3 promotion lands in one place; every
10604/// future renderer that reaches for the canonical Flux v2 `GitRepository`
10605/// apiVersion (the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
10606/// materializer's per-Aplicacao `GitRepository`, a future per-edge
10607/// `GitRepository` the operator emits for the
10608/// `CiliumClusterwideEnvoyConfig` pipeline, a future `caixa-otel`
10609/// collector-pipeline `GitRepository`) inherits the same value by
10610/// construction with no opportunity for per-renderer drift.
10611///
10612/// Same "the typed constant lives in one place" discipline the
10613/// [`DEFAULT_NAMESPACE`] (a085b26) / [`DEFAULT_LIBRARY_NAME`] (41438dc) /
10614/// [`crate::DEFAULT_SERVICO_PORT`] (1e22add) /
10615/// [`crate::DEFAULT_PUBLISH_TAG_PREFIX`] (0a6a602) /
10616/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) /
10617/// [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) lifts apply on the peer
10618/// canonical-load-bearing-string surface.
10619///
10620/// [cf]: ../../caixa_flux/index.html
10621pub const FLUX_GITREPOSITORY_API_VERSION: &str = "source.toolkit.fluxcd.io/v1";
10622
10623/// Canonical FluxCD `GitRepository` CRD `kind` discriminator every
10624/// `caixa-flux`-emitted document that names a Flux v2 `GitRepository`
10625/// at a [`KUBE_KEY_KIND`]-rooted axis declares. Paired peer to the
10626/// sibling [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3) — the K8s
10627/// apiserver-side CRD resolution contract is the `(apiVersion, kind)`
10628/// tuple keyed against the registered `CustomResourceDefinition`, so
10629/// drift on the kind axis is exactly as load-bearing as drift on the
10630/// apiVersion axis it accompanies (the apiserver's `RESTMapper` consults
10631/// both together; a `("source.toolkit.fluxcd.io/v1", "GitRepostiory")`
10632/// typo at any one of the three production-code call sites lands
10633/// outside the registered Flux v2 source-controller CRD's
10634/// `RESTKind` lookup, surfacing apply-side as a non-self-locating
10635/// "no kind 'GitRepostiory' is registered for version
10636/// 'source.toolkit.fluxcd.io/v1'" error far from the source
10637/// caixa.lisp / the renderer's format-string template).
10638///
10639/// The single source of truth the rendered Flux bundle's three
10640/// `GitRepository`-naming axes reach for:
10641///
10642/// - the rendered `gitrepository.yaml` document's top-level
10643/// [`KUBE_KEY_KIND`] axis (caixa-flux/src/lib.rs:505 — the
10644/// `gitrepo` format-string template);
10645/// - the rendered `helmrelease.yaml` document's
10646/// `spec.chart.spec.sourceRef.kind` axis (caixa-flux/src/lib.rs:556 —
10647/// the `helmrelease` format-string template), pointing back at the
10648/// sibling `GitRepository` the chart sources from;
10649/// - the rendered `kustomization.yaml` document's `spec.sourceRef.kind`
10650/// axis (caixa-flux/src/lib.rs:591 — the `kustomization` format-
10651/// string template), pointing back at the cluster's bootstrap
10652/// `GitRepository` (paired with [`DEFAULT_FLUX_SYSTEM_NAMESPACE`]
10653/// on the namespace axis).
10654///
10655/// All three axes name the same K8s CRD discriminator and must move
10656/// together on any future Flux v3 rebrand (e.g. an upstream Flux v3
10657/// rename like `GitSource`). Until this lift landed the three axes
10658/// carried inline `GitRepository` literals across the three production-
10659/// code occurrences in caixa-flux/src/lib.rs:505, 556, 591 (the
10660/// `cluster_bundle` `gitrepo` + `helmrelease` + `kustomization` format-
10661/// string templates) plus a matching set inside the in-file
10662/// `cluster_bundle_*` test fixtures — six occurrences of the same load-
10663/// bearing FluxCD-CRD-`kind`-discriminator convention, drift-prone by
10664/// construction. A drift on the `helmrelease.yaml`
10665/// `spec.chart.spec.sourceRef.kind` site alone — the one apply-side
10666/// failure mode the apiserver can't self-locate — would have silently
10667/// dangled the HelmRelease's chart sourceRef (controller-side: the
10668/// `helm-controller` never resolves a chart for the HelmRelease, the
10669/// rendered Servico chart never reconciles, every per-Servico apply
10670/// silently comes up with the prior reconciled state) with no diagnostic
10671/// naming the kind-drift root cause far from the source caixa.lisp.
10672///
10673/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
10674/// "every recurring shape becomes a generator before it becomes a
10675/// pattern; every pattern becomes a library before it becomes
10676/// duplicated code. The duplication budget is zero.") promotes the
10677/// constant to a typed substrate-side `&'static str` on the same
10678/// trajectory the [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) /
10679/// [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3) /
10680/// [`FLUX_KUSTOMIZATION_API_VERSION`] (d2dd1b1) lifts established on
10681/// the sibling Flux-v2-load-bearing-string axes — extends the
10682/// discipline from the apiVersion half of the `(apiVersion, kind)`
10683/// CRD-lookup tuple onto the kind half on the same Flux v2
10684/// source-controller CRD. The three render-side consumers now thread
10685/// the same `&'static str` through their format-string templates so a
10686/// future Flux v3 rebrand lands in one place; every future renderer
10687/// that reaches for the canonical Flux v2 `GitRepository` kind (the
10688/// future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
10689/// per-Aplicacao `GitRepository`, a future per-edge `GitRepository`
10690/// the operator emits for the `CiliumClusterwideEnvoyConfig` pipeline,
10691/// a future `caixa-otel` collector-pipeline `GitRepository`) inherits
10692/// the same value by construction with no opportunity for per-renderer
10693/// drift.
10694///
10695/// Same "the typed constant lives in one place" discipline the
10696/// [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) /
10697/// [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3) /
10698/// [`FLUX_KUSTOMIZATION_API_VERSION`] (d2dd1b1) /
10699/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) lifts apply on the peer
10700/// canonical-Flux-v2-load-bearing-string surface.
10701///
10702/// [cf]: ../../caixa_flux/index.html
10703pub const FLUX_KIND_GIT_REPOSITORY: &str = "GitRepository";
10704
10705/// Canonical FluxCD `HelmRelease` CRD `kind` discriminator every
10706/// `caixa-flux`-emitted document that names a Flux v2 `HelmRelease`
10707/// at a [`KUBE_KEY_KIND`]-rooted axis declares. Paired peer to the
10708/// sibling [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) — the K8s
10709/// apiserver-side CRD resolution contract is the `(apiVersion, kind)`
10710/// tuple keyed against the registered `CustomResourceDefinition`, so
10711/// drift on the kind axis is exactly as load-bearing as drift on the
10712/// apiVersion axis it accompanies (the apiserver's `RESTMapper`
10713/// consults both together; a `("helm.toolkit.fluxcd.io/v2",
10714/// "HelmRelase")` typo at any one of the two production-code call
10715/// sites lands outside the registered Flux v2 helm-controller CRD's
10716/// `RESTKind` lookup, surfacing apply-side as a non-self-locating
10717/// "no kind 'HelmRelase' is registered for version
10718/// 'helm.toolkit.fluxcd.io/v2'" error far from the source
10719/// caixa.lisp / the renderer's format-string template).
10720///
10721/// The single source of truth the rendered Flux bundle's two
10722/// `HelmRelease`-naming axes reach for:
10723///
10724/// - the rendered `helmrelease.yaml` document's top-level
10725/// [`KUBE_KEY_KIND`] axis (caixa-flux/src/lib.rs:580 — the
10726/// `helmrelease` format-string template);
10727/// - the rendered `kustomization.yaml` document's
10728/// `spec.healthChecks[].kind` axis (caixa-flux/src/lib.rs:631 —
10729/// the `kustomization` format-string template), pointing back at
10730/// the sibling `HelmRelease` the Kustomization pins as a
10731/// health-gate before declaring its own reconcile complete.
10732///
10733/// Both axes name the same K8s CRD discriminator and must move
10734/// together on any future Flux v3 rebrand (e.g. an upstream Flux v3
10735/// rename like `ChartRelease`). Until this lift landed the two axes
10736/// carried inline `HelmRelease` literals across the two production-
10737/// code occurrences in caixa-flux/src/lib.rs:580 (the
10738/// `cluster_bundle` `helmrelease` format-string template) and 631
10739/// (the `kustomization` `spec.healthChecks[]` element). A drift on
10740/// the `kustomization.yaml` `spec.healthChecks[].kind` site alone —
10741/// the one apply-side failure mode the apiserver can't self-locate
10742/// (a healthCheck kind typo doesn't fail apply-parse the way a
10743/// top-level kind typo does; it sits as a dangling unmatched health
10744/// gate the `kustomize-controller` perpetually re-evaluates) —
10745/// would have silently pinned the parent Kustomization at
10746/// `Reconciling` forever with no diagnostic naming the kind-drift
10747/// root cause far from the source caixa.lisp.
10748///
10749/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
10750/// "every recurring shape becomes a generator before it becomes a
10751/// pattern; every pattern becomes a library before it becomes
10752/// duplicated code. The duplication budget is zero.") promotes the
10753/// constant to a typed substrate-side `&'static str` on the same
10754/// trajectory the [`FLUX_KIND_GIT_REPOSITORY`] (dbbcf29) /
10755/// [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) /
10756/// [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3) /
10757/// [`FLUX_KUSTOMIZATION_API_VERSION`] (d2dd1b1) lifts established on
10758/// the sibling Flux-v2-load-bearing-string axes — extends the
10759/// discipline from the kind axis of the Flux v2 source-controller
10760/// CRD (the [`FLUX_KIND_GIT_REPOSITORY`] lift) onto the kind axis of
10761/// the sibling Flux v2 helm-controller CRD. The two render-side
10762/// consumers now thread the same `&'static str` through their
10763/// format-string templates so a future Flux v3 rebrand lands in one
10764/// place; every future renderer that reaches for the canonical Flux
10765/// v2 `HelmRelease` kind (the future M4
10766/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-
10767/// Aplicacao `HelmRelease`, a future per-edge `HelmRelease` the
10768/// operator emits for the `CiliumClusterwideEnvoyConfig` pipeline,
10769/// a future `caixa-otel` collector-pipeline `HelmRelease`) inherits
10770/// the same value by construction with no opportunity for per-
10771/// renderer drift.
10772///
10773/// Same "the typed constant lives in one place" discipline the
10774/// [`FLUX_KIND_GIT_REPOSITORY`] (dbbcf29) /
10775/// [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) /
10776/// [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3) /
10777/// [`FLUX_KUSTOMIZATION_API_VERSION`] (d2dd1b1) /
10778/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) lifts apply on the
10779/// peer canonical-Flux-v2-load-bearing-string surface.
10780///
10781/// [cf]: ../../caixa_flux/index.html
10782pub const FLUX_KIND_HELM_RELEASE: &str = "HelmRelease";
10783
10784/// Canonical FluxCD `Kustomization` CRD `apiVersion` every `caixa-flux`
10785/// `kustomization.yaml` document emits. The Flux v2 `kustomize-controller`
10786/// watches resources at this exact group/version
10787/// (`kustomize.toolkit.fluxcd.io/v1`); drift to a stale `v1beta1` /
10788/// `v1beta2` (the pre-GA Flux v2 kustomize-controller betas every
10789/// upstream Flux GA-migration doc names) silently routes the rendered
10790/// `Kustomization` outside the controller's `Watches` and breaks at
10791/// apply time with a non-self-locating "no kind 'Kustomization' is
10792/// registered for version 'kustomize.toolkit.fluxcd.io/v1beta2'" error
10793/// far from the source caixa.lisp / the renderer's format-string
10794/// template.
10795///
10796/// The single source of truth the `kustomization.yaml` `apiVersion`
10797/// axis reaches for (caixa-flux/src/lib.rs:531 — the `kustomization`
10798/// format-string template). Completes the Flux v2 controller triplet
10799/// (source-controller + helm-controller + kustomize-controller) lift
10800/// alongside the sibling [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3)
10801/// and [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) — every per-
10802/// controller CRD-group/version is now a typed substrate-side
10803/// `&'static str` consumed through one `pub use caixa_core::FLUX_*`
10804/// re-export at the renderer site. The three controllers share the
10805/// canonical `.toolkit.fluxcd.io` root (asserted by
10806/// [`tests::flux_controller_triplet_api_versions_share_toolkit_fluxcd_io_root`]),
10807/// so a future Flux v3 promotion that forks any controller out of the
10808/// toolkit group surfaces here as a coordinated cross-axis edit-point
10809/// across all three constants.
10810///
10811/// The rendered `Kustomization`'s `metadata.namespace` (the Flux
10812/// installation namespace, [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] —
10813/// 7197d38) and `spec.sourceRef.kind: GitRepository`
10814/// (referenced through [`FLUX_GITREPOSITORY_API_VERSION`]) and
10815/// `spec.healthChecks[].apiVersion` (the rendered `HelmRelease`'s
10816/// CRD-group/version, [`FLUX_HELMRELEASE_API_VERSION`]) all share
10817/// the cluster-side contract with the upstream Flux v2 controller
10818/// triplet: a coordinated edit on any one of these four constants
10819/// must move alongside the sibling axes, and the lift makes that
10820/// movement a typed substrate-side edit-point rather than a
10821/// distributed-across-format-string-template-literals refactor.
10822///
10823/// Until this lift landed the axis carried an inline
10824/// `kustomize.toolkit.fluxcd.io/v1` literal inside [`cluster_bundle`]'s
10825/// `kustomization.yaml` format-string template — one occurrence today,
10826/// promoted to a typed substrate-side `&'static str` on the same
10827/// trajectory the [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3) /
10828/// [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) /
10829/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) lifts established on
10830/// the sibling Flux-v2-load-bearing-string surface. The render-side
10831/// consumer now threads the same `&'static str` through its
10832/// format-string template so a future Flux v3 promotion lands in one
10833/// place; every future renderer that reaches for the canonical Flux
10834/// v2 `Kustomization` apiVersion (the future M4
10835/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
10836/// `Kustomization`, a future per-edge `Kustomization` the operator
10837/// emits for the `CiliumClusterwideEnvoyConfig` pipeline, a future
10838/// `caixa-otel` collector-pipeline `Kustomization`) inherits the
10839/// same value by construction with no opportunity for per-renderer
10840/// drift.
10841///
10842/// Same "the typed constant lives in one place" discipline the
10843/// [`DEFAULT_NAMESPACE`] (a085b26) / [`DEFAULT_LIBRARY_NAME`] (41438dc) /
10844/// [`crate::DEFAULT_SERVICO_PORT`] (1e22add) /
10845/// [`crate::DEFAULT_PUBLISH_TAG_PREFIX`] (0a6a602) /
10846/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) /
10847/// [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) /
10848/// [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3) lifts apply on the
10849/// peer canonical-load-bearing-string surface.
10850///
10851/// [cf]: ../../caixa_flux/index.html
10852pub const FLUX_KUSTOMIZATION_API_VERSION: &str = "kustomize.toolkit.fluxcd.io/v1";
10853
10854/// Canonical FluxCD `Kustomization` CRD `kind` discriminator every
10855/// `caixa-flux`-emitted document that names a Flux v2 `Kustomization`
10856/// at a [`KUBE_KEY_KIND`]-rooted axis declares. Paired peer to the
10857/// sibling [`FLUX_KUSTOMIZATION_API_VERSION`] (d2dd1b1) — the K8s
10858/// apiserver-side CRD resolution contract is the `(apiVersion, kind)`
10859/// tuple keyed against the registered `CustomResourceDefinition`, so
10860/// drift on the kind axis is exactly as load-bearing as drift on the
10861/// apiVersion axis it accompanies (the apiserver's `RESTMapper` consults
10862/// both together; a `("kustomize.toolkit.fluxcd.io/v1", "Kustomizaton")`
10863/// typo at the production-code call site lands outside the registered
10864/// Flux v2 kustomize-controller CRD's `RESTKind` lookup, surfacing
10865/// apply-side as a non-self-locating "no kind 'Kustomizaton' is
10866/// registered for version 'kustomize.toolkit.fluxcd.io/v1'" error far
10867/// from the source caixa.lisp / the renderer's format-string template).
10868///
10869/// The single source of truth the rendered Flux bundle's
10870/// `Kustomization`-naming axis reaches for:
10871///
10872/// - the rendered `kustomization.yaml` document's top-level
10873/// [`KUBE_KEY_KIND`] axis (caixa-flux/src/lib.rs:651 — the
10874/// `kustomization` format-string template).
10875///
10876/// The kind axis names the same K8s CRD discriminator as the sibling
10877/// [`FLUX_KUSTOMIZATION_API_VERSION`] apiVersion axis and must move
10878/// together on any future Flux v3 rebrand. Until this lift landed the
10879/// axis carried an inline `Kustomization` literal across the one
10880/// production-code occurrence in caixa-flux/src/lib.rs:651 (the
10881/// `cluster_bundle` `kustomization` format-string template) plus a
10882/// matching set inside the in-file `cluster_bundle_*` test fixtures —
10883/// occurrences of the same load-bearing FluxCD-CRD-`kind`-discriminator
10884/// convention, drift-prone by construction. A drift on the top-level
10885/// `kustomization.yaml` `kind` axis would have surfaced as a
10886/// non-self-locating "no kind 'Kustomizaton' is registered for version
10887/// 'kustomize.toolkit.fluxcd.io/v1'" error far from the source
10888/// caixa.lisp at apply parse time, with the rendered parent Kustomization
10889/// never reconciling and every downstream per-Servico `dependsOn` chain
10890/// freezing at the kustomize-controller's CRD-lookup boundary.
10891///
10892/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
10893/// "every recurring shape becomes a generator before it becomes a
10894/// pattern; every pattern becomes a library before it becomes
10895/// duplicated code. The duplication budget is zero.") promotes the
10896/// constant to a typed substrate-side `&'static str` on the same
10897/// trajectory the [`FLUX_KIND_GIT_REPOSITORY`] (dbbcf29) /
10898/// [`FLUX_KIND_HELM_RELEASE`] (e24ea3c) /
10899/// [`FLUX_KUSTOMIZATION_API_VERSION`] (d2dd1b1) /
10900/// [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3) /
10901/// [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) lifts established on
10902/// the sibling Flux-v2-load-bearing-string axes — extends the
10903/// discipline from the apiVersion half of the `(apiVersion, kind)`
10904/// CRD-lookup tuple onto the kind half on the same Flux v2
10905/// kustomize-controller CRD. Completes the Flux v2 controller triplet
10906/// kind-axis lift (source-controller + helm-controller +
10907/// kustomize-controller) alongside the sibling
10908/// [`FLUX_KIND_GIT_REPOSITORY`] and [`FLUX_KIND_HELM_RELEASE`] — every
10909/// per-controller CRD `kind` discriminator is now a typed substrate-side
10910/// `&'static str` consumed through one `pub use caixa_core::FLUX_KIND_*`
10911/// re-export at the renderer site. The render-side consumer now threads
10912/// the same `&'static str` through its format-string template so a
10913/// future Flux v3 rebrand lands in one place; every future renderer
10914/// that reaches for the canonical Flux v2 `Kustomization` kind (the
10915/// future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
10916/// per-Aplicacao `Kustomization`, a future per-edge `Kustomization`
10917/// the operator emits for the `CiliumClusterwideEnvoyConfig` pipeline,
10918/// a future `caixa-otel` collector-pipeline `Kustomization`) inherits
10919/// the same value by construction with no opportunity for per-renderer
10920/// drift.
10921///
10922/// Same "the typed constant lives in one place" discipline the
10923/// [`FLUX_KIND_GIT_REPOSITORY`] (dbbcf29) /
10924/// [`FLUX_KIND_HELM_RELEASE`] (e24ea3c) /
10925/// [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) /
10926/// [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3) /
10927/// [`FLUX_KUSTOMIZATION_API_VERSION`] (d2dd1b1) /
10928/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) lifts apply on the peer
10929/// canonical-Flux-v2-load-bearing-string surface.
10930///
10931/// [cf]: ../../caixa_flux/index.html
10932pub const FLUX_KIND_KUSTOMIZATION: &str = "Kustomization";
10933
10934/// Canonical Flux v2 per-`HelmRelease`/`Kustomization` source-reference
10935/// container-axis key every `caixa-flux`-emitted bundle document mounts its
10936/// per-CR source-of-truth pointer under (`spec.chart.spec.sourceRef` on
10937/// `HelmRelease`, `spec.sourceRef` on `Kustomization`) — the Flux v2 CRD
10938/// schema places the `(kind, name, namespace)` reference triple under this
10939/// single container key, so drift on the container axis is exactly as
10940/// load-bearing as drift on the sibling [`FLUX_KIND_GIT_REPOSITORY`]
10941/// (dbbcf29) kind-discriminator + [`DEFAULT_FLUX_SYSTEM_NAMESPACE`]
10942/// (7197d38) namespace axes the block nests (a `"source_ref"` / `"source"`
10943/// / `"sourceReference"` / `"gitSourceRef"` typo at either the emit-side
10944/// format-string template or a downstream test-fixture probe silently
10945/// dangles the `HelmRelease.spec.chart.spec.sourceRef` chart resolution +
10946/// the `Kustomization.spec.sourceRef` source resolution at the Flux v2
10947/// source-controller's CRD registration; the source-controller's per-CR
10948/// reconcile loop keys off this exact container axis to source the
10949/// `(kind, name, namespace)` reference triple, and a drift silently freezes
10950/// the dependent per-Servico `dependsOn` chain at apply time with no
10951/// field naming the sourceRef-container-drift root cause).
10952///
10953/// The single source of truth the rendered Flux bundle's per-CR
10954/// source-reference-container-axis-naming reaches for:
10955///
10956/// - the rendered `helmrelease.yaml` document's per-`HelmRelease`
10957/// `spec.chart.spec.sourceRef` block (caixa-flux/src/lib.rs — the
10958/// `cluster_bundle` `helmrelease` format-string template's
10959/// `{source_ref_key}:\n` sub-block header, now threaded through
10960/// the lifted const via a `{source_ref_key}` named-arg
10961/// interpolation);
10962/// - the rendered `kustomization.yaml` document's per-`Kustomization`
10963/// `spec.sourceRef` block (caixa-flux/src/lib.rs — the sibling
10964/// `cluster_bundle` `kustomization` format-string template's
10965/// `{source_ref_key}:\n` sub-block header, now threaded through
10966/// the lifted const via the sibling `{source_ref_key}` named-arg
10967/// interpolation);
10968/// - five test-side navigation sites in `mod tests` that probe the
10969/// rendered documents' `.get("sourceRef")` container axis to pin
10970/// the emitted `(kind, name, namespace)` reference triple against
10971/// the sibling lifted [`FLUX_KIND_GIT_REPOSITORY`] +
10972/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] axes.
10973///
10974/// The container-axis key names the same Flux-v2-source-controller-side
10975/// per-CR source-of-truth reference-triple container as the sibling
10976/// per-CRD `kind` discriminator [`FLUX_KIND_GIT_REPOSITORY`] nests inside,
10977/// and must move together on any future Flux v3 rebrand (a hypothetical
10978/// upstream Flux v3 rename of the source-reference container axis from
10979/// `sourceRef` to `source` / `sourceReference` / `sourceOf`, coordinated
10980/// with the upstream fluxcd/flux2 project's per-version deprecation
10981/// cycle, would land at this one const rather than scattered across the
10982/// two per-CR format-string templates + five per-test-fixture probe
10983/// sites).
10984///
10985/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
10986/// "every recurring shape becomes a generator before it becomes a
10987/// pattern; every pattern becomes a library before it becomes
10988/// duplicated code. The duplication budget is zero.") promotes the
10989/// constant to a typed substrate-side `&'static str` on the same
10990/// trajectory the [`FLUX_KIND_GIT_REPOSITORY`] (dbbcf29) /
10991/// [`FLUX_KIND_HELM_RELEASE`] (e24ea3c) /
10992/// [`FLUX_KIND_KUSTOMIZATION`] (2d61a6f) /
10993/// [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) /
10994/// [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3) /
10995/// [`FLUX_KUSTOMIZATION_API_VERSION`] (d2dd1b1) /
10996/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) lifts established on the
10997/// sibling canonical-Flux-v2-load-bearing-string surfaces — extends the
10998/// per-CRD kind-discriminator + apiVersion + install-namespace lift
10999/// trajectory onto the sibling per-CR source-reference container-axis
11000/// key the `cluster_bundle` `HelmRelease` + `Kustomization` renderers
11001/// both consume under their nested `(kind, name, namespace)` reference
11002/// triple.
11003///
11004/// [cf]: ../../caixa_flux/index.html
11005pub const FLUX_KEY_SOURCE_REF: &str = "sourceRef";
11006
11007/// Canonical Flux v2 per-`HelmRelease` inline-chart-template container-axis
11008/// key every `caixa-flux`-emitted `HelmRelease` document nests its per-CR
11009/// chart-template block under (`spec.chart` on `HelmRelease`) — the Flux v2
11010/// CRD schema places the `HelmChartTemplate` sub-document (whose nested
11011/// `spec.chart` string names the referenced chart, `spec.sourceRef` names
11012/// the source-of-truth `(kind, name, namespace)` triple, and
11013/// `spec.interval` names the per-CR reconcile cadence) under this single
11014/// container key, so drift on the container axis silently dangles the
11015/// whole chart-template block the Flux v2 `helm-controller`'s per-CR
11016/// reconcile loop reads to source the referenced chart at Helm-render time
11017/// (a `"Chart"` / `"chartTemplate"` / `"helmChart"` / `"chartRef"` typo at
11018/// either the emit-side format-string template or a downstream test-
11019/// fixture probe silently dangles the `HelmRelease.spec.chart` chart-
11020/// template resolution at the Flux v2 helm-controller's CRD registration;
11021/// the referenced chart never resolves, and the per-Servico workload
11022/// freezes at apply time with no field naming the container-axis-drift
11023/// root cause).
11024///
11025/// The single source of truth the rendered Flux bundle's per-CR
11026/// chart-template-container-axis-naming reaches for:
11027///
11028/// - the rendered `helmrelease.yaml` document's per-`HelmRelease`
11029/// `spec.chart` block (caixa-flux/src/lib.rs — the `cluster_bundle`
11030/// `helmrelease` format-string template's baked `chart:\n` container
11031/// axis at line 914, sibling to the peer lifted [`FLUX_KEY_SOURCE_REF`]
11032/// source-reference container axis nested inside the same block +
11033/// [`FLUX_KEY_VALUES`] per-cluster-override block-body axis at the
11034/// sibling `spec.values` position);
11035/// - two test-side navigation sites in `mod tests` that probe the
11036/// rendered `helmrelease.yaml` document's `.get("chart")` container
11037/// axis to reach the nested `spec.chart.spec.sourceRef.kind` pin
11038/// against the sibling lifted [`FLUX_KIND_GIT_REPOSITORY`] axis
11039/// (caixa-flux/src/lib.rs:2680, 2774).
11040///
11041/// The container-axis key names the same Flux-v2-helm-controller-side
11042/// per-`HelmRelease` chart-template container as the peer sibling per-CR
11043/// source-reference container-axis [`FLUX_KEY_SOURCE_REF`] nests under,
11044/// and must move together on any future Flux v3 rebrand (a hypothetical
11045/// upstream Flux v3 rename of the per-`HelmRelease` chart-template
11046/// container axis from `chart` to `Chart` / `chartTemplate` / `helmChart`
11047/// / `chartRef`, coordinated with the upstream fluxcd/flux2 project's
11048/// per-version deprecation cycle, would land at this one const rather
11049/// than scattered across the one per-CR format-string template + two
11050/// per-test-fixture probe sites).
11051///
11052/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
11053/// "every recurring shape becomes a generator before it becomes a
11054/// pattern; every pattern becomes a library before it becomes
11055/// duplicated code. The duplication budget is zero.") promotes the
11056/// constant to a typed substrate-side `&'static str` on the same
11057/// trajectory the [`FLUX_KEY_SOURCE_REF`] (e985089) /
11058/// [`FLUX_KEY_VALUES`] (b54dc87) lifts established on the sibling
11059/// canonical-Flux-v2-per-`HelmRelease`-body-key surfaces — completes the
11060/// triplet of Flux v2 per-`HelmRelease` `spec.*` body-key constants
11061/// (`spec.chart` + `spec.chart.spec.sourceRef` + `spec.values`) the
11062/// `cluster_bundle` renderer's `helmrelease.yaml` format-string template
11063/// threads through its per-CR block-body layout.
11064///
11065/// The inner scalar-value axis `spec.chart.spec.chart` (the chart-name
11066/// leaf the `HelmChartTemplate.spec` sub-document mounts under; the same
11067/// spelling `"chart"` at a distinct schema position) is a schematically
11068/// separate leaf-scalar-key axis (the chart-NAME field the helm-controller
11069/// resolves through the sibling [`FLUX_KEY_SOURCE_REF`] triple's source),
11070/// and is not covered by this lift — a rebrand of the container axis
11071/// (`spec.chart` in this const) does not necessarily coincide with a
11072/// rebrand of the leaf-scalar `spec.chart.spec.chart` chart-name field
11073/// key, so the two axes stay decoupled at the substrate.
11074///
11075/// [cf]: ../../caixa_flux/index.html
11076pub const FLUX_KEY_CHART: &str = "chart";
11077
11078/// Canonical Flux v2 `HelmChartTemplate.spec.chart` per-CR chart-NAME-
11079/// reference leaf-scalar-key every `caixa-flux`-emitted `HelmRelease`
11080/// document nests inside the parent `spec.chart.spec` sub-document (the
11081/// `HelmChartTemplate.spec` block the parent [`FLUX_KEY_CHART`] (8467748)
11082/// container-axis key opens; a nested [`KUBE_KEY_SPEC`] axis inside that
11083/// container hosts this leaf plus its sibling [`FLUX_KEY_SOURCE_REF`]
11084/// per-CR source-reference triple).
11085///
11086/// The parent [`FLUX_KEY_CHART`] docstring explicitly names this leaf-
11087/// scalar axis as *not* covered by that container-axis lift ("The inner
11088/// scalar-value axis `spec.chart.spec.chart` … is a schematically
11089/// separate leaf-scalar-key axis (the chart-NAME field the helm-controller
11090/// resolves through the sibling [`FLUX_KEY_SOURCE_REF`] triple's
11091/// source), and is not covered by this lift — a rebrand of the
11092/// container axis … does not necessarily coincide with a rebrand of
11093/// the leaf-scalar `spec.chart.spec.chart` chart-name field key, so
11094/// the two axes stay decoupled at the substrate."). This const closes
11095/// the substrate-side declaration of the sibling leaf-scalar axis the
11096/// parent container-axis lift explicitly left as future work.
11097///
11098/// The Flux v2 `helm-controller`'s reconcile pipeline reads the chart-
11099/// NAME reference from this exact leaf-scalar-axis key on every
11100/// reconcile: the value at `HelmChartTemplate.spec.chart` names the
11101/// chart-artifact the sibling `HelmChartTemplate.spec.sourceRef`
11102/// triple's source-artifact publishes (an OCIRepository's remote OCI
11103/// chart archive by chart-name, a GitRepository's sub-tree path by
11104/// directory-name, a HelmRepository's chart index entry by chart-name).
11105/// A drifted `spec.chart.spec.Chart` / `spec.chart.spec.chartRef` /
11106/// `spec.chart.spec.chartName` at the emission-side key would silently
11107/// land a well-formed but ignored `HelmChartTemplate.spec.*` extra
11108/// property the apiserver's CRD OpenAPI schema permits (arbitrary
11109/// `spec.*` extras) and the helm-controller would fail to resolve any
11110/// chart-artifact through the sibling `sourceRef` triple's source at
11111/// reconcile time (the sibling `sourceRef` still resolves the *source*
11112/// artifact, but the chart-NAME lookup inside the source
11113/// short-circuits at the missing chart-NAME field with a
11114/// non-self-locating "chart 'unknown' not found in <source>" error far
11115/// from the source `caixa.lisp` / the renderer's format-string
11116/// template).
11117///
11118/// The single source of truth the rendered Flux bundle's per-CR
11119/// `HelmChartTemplate.spec.chart` chart-NAME reference leaf-scalar-
11120/// axis key reaches for:
11121///
11122/// - the rendered `helmrelease.yaml` document's per-`HelmChartTemplate`
11123/// `spec.chart` chart-NAME leaf scalar (caixa-flux/src/lib.rs:1814
11124/// — the `cluster_bundle` `helmrelease` format-string template's
11125/// lifted `chart: {chart_path}` interpolation the peer sibling
11126/// [`FLUX_KEY_SOURCE_REF`] source-reference triple's per-CR source-
11127/// artifact publishes).
11128///
11129/// The leaf-scalar-axis key names the same Flux-v2-helm-controller-
11130/// side per-`HelmChartTemplate` chart-NAME field every
11131/// `caixa-flux`-emitted `HelmRelease` document threads the chart
11132/// artifact name through, and must move together on any future Flux
11133/// v3 rebrand (a hypothetical upstream Flux v3 rename of the per-
11134/// `HelmChartTemplate.spec.chart` chart-NAME reference leaf-scalar-
11135/// axis from `chart` to `Chart` / `chartRef` / `chartName`,
11136/// coordinated with the upstream fluxcd/flux2 project's per-version
11137/// deprecation cycle, would land at this one const rather than
11138/// scattered across the one per-CR format-string template site).
11139///
11140/// Deliberate axis-independence discipline with the parent
11141/// [`FLUX_KEY_CHART`] container-axis re-export: both consts spell the
11142/// same underlying `"chart"` string but name distinct schema axes on
11143/// the same CRD group (Flux v2 `HelmRelease.spec.chart` container-
11144/// axis parent vs `HelmRelease.spec.chart.spec.chart` chart-NAME leaf
11145/// grandchild), so the two `pub const` declarations stay sibling
11146/// constants at the rustc symbol-name axis rather than coalescing onto
11147/// one canonical declaration — a future Flux v3 rebrand on the leaf-
11148/// scalar-axis lands independently of the sibling container-axis
11149/// rebrand. Peer to the deliberate [`CILIUM_KEY_PATH`] (ef6114f) /
11150/// [`GATEWAY_API_KEY_PATH`] (9f45aa4) axis-independence discipline the
11151/// two-CRD-groups-sharing-a-string sibling `"path"` re-exports
11152/// established on the peer canonical-axis-independence surface.
11153///
11154/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
11155/// "every recurring shape becomes a generator before it becomes a
11156/// pattern; every pattern becomes a library before it becomes
11157/// duplicated code. The duplication budget is zero.") promotes the
11158/// constant to a typed substrate-side `&'static str` on the same
11159/// trajectory the [`FLUX_KEY_CHART`] (8467748) /
11160/// [`FLUX_KEY_SOURCE_REF`] (e985089) / [`FLUX_KEY_VALUES`] (b54dc87) /
11161/// [`FLUX_KEY_HEALTH_CHECKS`] (6dbff58) lifts established on the
11162/// sibling canonical-Flux-v2-per-`HelmRelease`-body-key surfaces —
11163/// completes the per-`HelmRelease` chart-template `(spec.chart →
11164/// spec.chart.spec.chart + spec.chart.spec.sourceRef)` axis chain by
11165/// declaring the leaf-scalar sibling of the container-axis parent
11166/// the `FLUX_KEY_CHART` lift already anchors.
11167///
11168/// [cf]: ../../caixa_flux/index.html
11169pub const FLUX_HELMCHART_TEMPLATE_KEY_CHART: &str = "chart";
11170
11171/// Canonical Flux v2 per-`HelmRelease` values-override block-body-axis key
11172/// every `caixa-flux`-emitted `HelmRelease` document nests its per-cluster
11173/// value overrides under (`spec.values` on `HelmRelease`) — the Flux v2
11174/// CRD schema places the arbitrary per-cluster-override YAML body under
11175/// this single key, so drift on the block-body-axis silently dangles the
11176/// per-cluster override the `helm-controller`'s per-CR reconcile loop
11177/// merges into the referenced chart's `values.yaml` at Helm-render time
11178/// (a `"Values"` / `"vals"` / `"chartValues"` / `"overrides"` typo at
11179/// either the emit-side format-string template, the `upsert_into_helmrelease_programs`
11180/// upsert-path's `spec.values.programs[]` write, or a downstream
11181/// test-fixture probe silently routes the per-cluster overrides nowhere;
11182/// the workload silently comes up with the referenced chart's admission-
11183/// time defaults, far from the source `caixa.lisp` / the renderer's
11184/// format-string template).
11185///
11186/// The single source of truth every Flux-v2-per-`HelmRelease` values-
11187/// override-block-axis navigation reaches for:
11188///
11189/// - the rendered `helmrelease.yaml` document's per-`HelmRelease`
11190/// `spec.values` block (caixa-flux/src/lib.rs:900 — the
11191/// `cluster_bundle` `helmrelease` format-string template's baked
11192/// `values:\n` key beside the peer sibling lifted
11193/// [`DEFAULT_LIBRARY_NAME`] wrap key + [`HELM_VALUES_KEY_ENABLED`]
11194/// enable-toggle);
11195/// - the `upsert_into_helmrelease_programs` upsert path's
11196/// `spec.values.programs[]` write-side navigation
11197/// (caixa-flux/src/lib.rs:649 — the `lareira-fleet-programs`-
11198/// targeted `HelmRelease` CR's per-Servico entry-list mount);
11199/// - three test-side navigation sites in `mod tests` that probe the
11200/// rendered documents' `.get("values")` block-body axis to pin the
11201/// emitted per-cluster overrides against the sibling lifted
11202/// [`DEFAULT_LIBRARY_NAME`] wrap key + [`HELM_VALUES_KEY_ENABLED`]
11203/// enable-toggle + [`FLEET_PROGRAMS_KEY_PROGRAMS`] entry-list axis.
11204///
11205/// The block-body-axis key names the same Flux-v2-helm-controller-side
11206/// per-`HelmRelease` per-cluster-override block-body every
11207/// `caixa-flux`-emitted `HelmRelease` document threads its per-cluster
11208/// overlays through, and must move together on any future Flux v3
11209/// rebrand (a hypothetical upstream Flux v3 rename of the values-
11210/// override block-body-axis from `values` to `Values` / `chartValues`
11211/// / `overrides`, coordinated with the upstream fluxcd/flux2 project's
11212/// per-version deprecation cycle, would land at this one const rather
11213/// than scattered across the one emit-side format-string template + one
11214/// upsert-side write-side navigation + three per-test-fixture probe
11215/// sites).
11216///
11217/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
11218/// "every recurring shape becomes a generator before it becomes a
11219/// pattern; every pattern becomes a library before it becomes
11220/// duplicated code. The duplication budget is zero.") promotes the
11221/// constant to a typed substrate-side `&'static str` on the same
11222/// trajectory the [`FLUX_KIND_GIT_REPOSITORY`] (dbbcf29) /
11223/// [`FLUX_KIND_HELM_RELEASE`] (e24ea3c) /
11224/// [`FLUX_KIND_KUSTOMIZATION`] (2d61a6f) /
11225/// [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) /
11226/// [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3) /
11227/// [`FLUX_KUSTOMIZATION_API_VERSION`] (d2dd1b1) /
11228/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) /
11229/// [`FLUX_KEY_SOURCE_REF`] (e985089) lifts established on the sibling
11230/// canonical-Flux-v2-load-bearing-string surfaces — extends the per-CRD
11231/// kind-discriminator + apiVersion + install-namespace + source-
11232/// reference-container lift trajectory onto the sibling per-CR values-
11233/// override-block-body-axis key both `cluster_bundle` +
11234/// `upsert_into_helmrelease_programs` renderers consume under the
11235/// per-cluster override + per-Servico entry-list nesting.
11236///
11237/// [cf]: ../../caixa_flux/index.html
11238pub const FLUX_KEY_VALUES: &str = "values";
11239
11240/// Canonical Flux v2 per-`Kustomization` health-gate reference-list
11241/// container-axis key every `caixa-flux`-emitted `kustomization.yaml`
11242/// document mounts its per-sibling-`HelmRelease` health-probe list under
11243/// (`spec.healthChecks` on `Kustomization`) — the Flux v2 CRD schema places
11244/// the `[]NamespacedObjectKindReference` list under this single container
11245/// key, so drift on the container axis silently dangles the whole per-
11246/// Kustomization health-gate the Flux v2 `kustomize-controller`'s per-CR
11247/// reconcile loop reads to gate `Ready=True` on the referenced sibling
11248/// `HelmRelease` reaching its `HelmReleaseReady=True` condition (a
11249/// `"HealthChecks"` / `"healthchecks"` / `"healthcheck"` /
11250/// `"health_checks"` / `"probes"` typo at either the emit-side format-
11251/// string template or a downstream test-fixture probe silently
11252/// dangles the parent `Kustomization` at `Reconciling` forever at the Flux
11253/// v2 kustomize-controller's health-gate evaluation; the dependent per-
11254/// cluster fleet-programs upsert chain never sees `Ready=True` at apply
11255/// time with no field naming the container-axis-drift root cause).
11256///
11257/// The single source of truth every Flux-v2-per-`Kustomization` health-
11258/// gate-reference-list-container-axis-naming reaches for:
11259///
11260/// - the rendered `kustomization.yaml` document's per-`Kustomization`
11261/// `spec.healthChecks` block (caixa-flux/src/lib.rs — the
11262/// `cluster_bundle` `kustomization` format-string template's baked
11263/// `healthChecks:\n` container-axis key at line 990, threaded together
11264/// with the sibling lifted [`FLUX_HELMRELEASE_API_VERSION`] per-entry
11265/// `apiVersion` axis + [`FLUX_KIND_HELM_RELEASE`] per-entry `kind`
11266/// axis the health-gate references);
11267/// - three test-side navigation sites in `mod tests` that probe the
11268/// rendered `kustomization.yaml` document's
11269/// `.get("healthChecks")` container axis to pin the emitted per-entry
11270/// `apiVersion` + `kind` against the sibling lifted
11271/// [`FLUX_HELMRELEASE_API_VERSION`] + [`FLUX_KIND_HELM_RELEASE`] axes
11272/// (caixa-flux/src/lib.rs:2266, 2952, 3016).
11273///
11274/// The container-axis key names the same Flux-v2-kustomize-controller-side
11275/// per-`Kustomization` health-gate-reference-list the sibling per-entry
11276/// `apiVersion` [`FLUX_HELMRELEASE_API_VERSION`] + per-entry `kind`
11277/// [`FLUX_KIND_HELM_RELEASE`] axes nest under, and must move together on
11278/// any future Flux v3 rebrand (a hypothetical upstream Flux v3 rename of
11279/// the per-`Kustomization` health-gate reference-list container axis from
11280/// `healthChecks` to `HealthChecks` / `healthchecks` / `healthcheck` /
11281/// `health_checks` / `probes`, coordinated with the upstream fluxcd/flux2
11282/// project's per-version deprecation cycle, would land at this one const
11283/// rather than scattered across the one emit-side format-string template +
11284/// three per-test-fixture probe sites).
11285///
11286/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
11287/// "every recurring shape becomes a generator before it becomes a
11288/// pattern; every pattern becomes a library before it becomes
11289/// duplicated code. The duplication budget is zero.") promotes the
11290/// constant to a typed substrate-side `&'static str` on the same
11291/// trajectory the [`FLUX_KIND_GIT_REPOSITORY`] (dbbcf29) /
11292/// [`FLUX_KIND_HELM_RELEASE`] (e24ea3c) /
11293/// [`FLUX_KIND_KUSTOMIZATION`] (2d61a6f) /
11294/// [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) /
11295/// [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3) /
11296/// [`FLUX_KUSTOMIZATION_API_VERSION`] (d2dd1b1) /
11297/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) /
11298/// [`FLUX_KEY_SOURCE_REF`] (e985089) /
11299/// [`FLUX_KEY_CHART`] (8467748) /
11300/// [`FLUX_KEY_VALUES`] (b54dc87) lifts established on the sibling
11301/// canonical-Flux-v2-load-bearing-string surfaces — extends the per-CRD
11302/// kind-discriminator + apiVersion + install-namespace + source-
11303/// reference-container + chart-template-container + values-override-block
11304/// lift trajectory onto the sibling per-`Kustomization` health-gate-
11305/// reference-list container-axis key the `cluster_bundle` renderer
11306/// consumes under its `kustomization.yaml` format-string template.
11307///
11308/// [cf]: ../../caixa_flux/index.html
11309pub const FLUX_KEY_HEALTH_CHECKS: &str = "healthChecks";
11310
11311/// Canonical Flux v2 per-CR reconcile-poll cadence scalar-axis key every
11312/// `caixa-flux`-emitted Flux document (`GitRepository`, `HelmRelease`,
11313/// `Kustomization`) declares its per-CR `spec.interval` reconcile cadence
11314/// under. Unlike the sibling per-CR body-key axes ([`FLUX_KEY_SOURCE_REF`],
11315/// [`FLUX_KEY_CHART`], [`FLUX_KEY_VALUES`], [`FLUX_KEY_HEALTH_CHECKS`])
11316/// which each land on exactly one of the three Flux v2 controller CRDs,
11317/// the reconcile-poll cadence scalar-axis is the *shared* Flux v2 per-CR
11318/// contract every controller (the `source-controller`, the
11319/// `helm-controller`, the `kustomize-controller`) reads to schedule its
11320/// per-CR reconcile loop off the sibling per-CR CRD registration. Drift on
11321/// the scalar-axis key silently drops the per-CR reconcile schedule from
11322/// the Flux v2 controllers' per-CR watch registrations — a `"Interval"` /
11323/// `"period"` / `"cadence"` / `"pollInterval"` / `"reconcileInterval"`
11324/// typo at any of the three emit-side format-string template sites
11325/// silently drops the per-CR reconcile schedule from the affected Flux v2
11326/// controller's per-CR watch registration; the referenced Git source
11327/// never re-polls / the referenced chart never re-templates / the parent
11328/// Kustomization never re-applies at upstream drift, freezing the whole
11329/// cluster's per-`caixa` per-cluster bundle at the last-applied snapshot
11330/// with no field naming the scalar-axis-drift root cause.
11331///
11332/// The single source of truth every Flux-v2-per-CR-reconcile-poll-cadence-
11333/// scalar-axis-naming reaches for — the three per-CR emit sites the
11334/// [`cluster_bundle`][cf] renderer threads through are all named through
11335/// this one const:
11336///
11337/// - the rendered `gitrepository.yaml` document's per-`GitRepository`
11338/// `spec.interval` scalar (caixa-flux/src/lib.rs — the `cluster_bundle`
11339/// `gitrepo` format-string template's baked `interval:` scalar-axis
11340/// key, nested alongside the sibling lifted
11341/// [`FLUX_GITREPOSITORY_API_VERSION`] top-level `apiVersion` +
11342/// [`FLUX_KIND_GIT_REPOSITORY`] top-level `kind` axes the source-
11343/// controller reads to bind the per-CR poll cycle);
11344/// - the rendered `helmrelease.yaml` document's per-`HelmRelease`
11345/// `spec.interval` scalar (caixa-flux/src/lib.rs — the `cluster_bundle`
11346/// `helmrelease` format-string template's baked `interval:` scalar-
11347/// axis key, nested alongside the sibling lifted
11348/// [`FLUX_HELMRELEASE_API_VERSION`] top-level `apiVersion` +
11349/// [`FLUX_KIND_HELM_RELEASE`] top-level `kind` axes the helm-controller
11350/// reads to bind the per-CR poll cycle);
11351/// - the rendered `kustomization.yaml` document's per-`Kustomization`
11352/// `spec.interval` scalar (caixa-flux/src/lib.rs — the `cluster_bundle`
11353/// `kustomization` format-string template's baked `interval:` scalar-
11354/// axis key, nested alongside the sibling lifted
11355/// [`FLUX_KUSTOMIZATION_API_VERSION`] top-level `apiVersion` +
11356/// [`FLUX_KIND_KUSTOMIZATION`] top-level `kind` axes the kustomize-
11357/// controller reads to bind the per-CR poll cycle).
11358///
11359/// The three sites must move together on any future Flux v3 rebrand (a
11360/// hypothetical upstream fluxcd/flux2 rename from `interval` to `Interval`
11361/// / `period` / `cadence` / `pollInterval` / `reconcileInterval`,
11362/// coordinated with the upstream project's per-version deprecation cycle,
11363/// would land at this one const rather than scattered across the three
11364/// per-CR emit-side format-string template sites). This is a distinct
11365/// duplication shape from the sibling [`FLUX_KEY_SOURCE_REF`] /
11366/// [`FLUX_KEY_CHART`] / [`FLUX_KEY_VALUES`] / [`FLUX_KEY_HEALTH_CHECKS`]
11367/// lifts: those closed *one-CR-body-key* duplication trios (one emit-site
11368/// per CR + several test-side probes); this one closes the sibling
11369/// *three-CR-shared-body-key* triplet the Flux v2 reconcile-poll cadence
11370/// contract shares across all three per-cluster-bundle CRDs.
11371///
11372/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
11373/// "every recurring shape becomes a generator before it becomes a
11374/// pattern; every pattern becomes a library before it becomes
11375/// duplicated code. The duplication budget is zero.") promotes the
11376/// constant to a typed substrate-side `&'static str` on the same
11377/// trajectory the [`FLUX_KEY_SOURCE_REF`] (e985089) /
11378/// [`FLUX_KEY_CHART`] (8467748) /
11379/// [`FLUX_KEY_VALUES`] (b54dc87) /
11380/// [`FLUX_KEY_HEALTH_CHECKS`] (6dbff58) lifts established on the sibling
11381/// canonical-Flux-v2-per-CR-body-key surfaces — extends the per-CR
11382/// body-key lift trajectory onto the sibling *cross-CR-shared* reconcile-
11383/// poll cadence scalar-axis every Flux v2 controller reads to bind its
11384/// per-CR poll cycle.
11385///
11386/// [cf]: ../../caixa_flux/fn.cluster_bundle.html
11387pub const FLUX_KEY_INTERVAL: &str = "interval";
11388
11389/// Canonical Flux v2 per-`GitRepository` `spec.ref.tag` git-tag-selector
11390/// scalar-axis key every `caixa-flux`-emitted `gitrepository.yaml`
11391/// document declares when the per-Servico bundle's `git_ref` is a
11392/// tag-shaped selector. Peer of [`FLUX_GITREPOSITORY_REF_KEY_BRANCH`]
11393/// / [`FLUX_GITREPOSITORY_REF_KEY_COMMIT`] on the sibling per-shape
11394/// arms of the `FluxCD` source-controller `GitRepository.spec.ref`
11395/// ref-selection discriminated-union axis — the three-way sub-selector
11396/// key set the Flux v2 `source-controller` reads to bind the per-CR
11397/// git-source clone `refspec` from the (tag | branch | commit) input
11398/// triple. A drifted value at any of the three keys (`"Tag"` /
11399/// `"gitTag"` / `"tagName"` at this arm, `"Branch"` / `"gitBranch"`
11400/// at the sibling arm, `"Commit"` / `"sha"` / `"revision"` at the
11401/// third arm) silently dangles the whole `spec.ref` sub-block at the
11402/// `FluxCD` `source-controller`'s CRD registration; the per-Servico
11403/// clone never resolves at reconcile time and the sibling
11404/// `HelmRelease.spec.chart.spec.sourceRef` reference dangles at
11405/// admission with no field naming the sub-selector-key-drift root
11406/// cause. Changing this value is a coordinated Flux v3 migration
11407/// alongside the upstream `fluxcd/flux2` deprecation cycle, not an
11408/// incidental edit.
11409///
11410/// The single source of truth every Flux-v2-per-`GitRepository`-
11411/// `spec.ref`-tag-arm-axis-naming reaches for — the two per-render
11412/// consumer sites the [`crate::render`]-side lift closes on the
11413/// [`caixa_flux::GitRefSpec::Tag`] variant are both named through this
11414/// one const via the [`caixa_flux::GitRefSpec::ref_field_name`]
11415/// dispatch:
11416///
11417/// - the rendered `gitrepository.yaml` document's per-`GitRepository`
11418/// `spec.ref.tag` YAML sub-field (caixa-flux's `cluster_bundle`
11419/// `gitref_field` composer, the sole in-tree emission site);
11420/// - the sibling per-render human-readable narrator's `tag <value>`
11421/// prefix (caixa-flux's `cluster_bundle` `tag_human` composer's
11422/// tag-arm branch), the operator-facing per-arm narrator prose
11423/// `feira app graph` / `feira deploy` diagnostics quote.
11424///
11425/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5) —
11426/// promotes the sub-selector-key byte-string to a typed substrate-side
11427/// `&'static str` on the same trajectory the peer per-CR body-key
11428/// [`FLUX_KEY_SOURCE_REF`] (e985089) / [`FLUX_KEY_CHART`] (8467748) /
11429/// [`FLUX_KEY_VALUES`] (b54dc87) / [`FLUX_KEY_HEALTH_CHECKS`] (6dbff58)
11430/// / [`FLUX_KEY_INTERVAL`] (48db6e2) lifts established on the sibling
11431/// canonical-Flux-v2-per-CR-body-key surfaces — pivots the discipline
11432/// from the per-CR body-key axis onto the sibling per-`GitRepository`-
11433/// `spec.ref`-sub-selector-key axis every `cluster_bundle`-rendered
11434/// bundle threads its per-shape ref-selection through, and closes the
11435/// coordinated 2-site duplication (`gitref_field` YAML emit +
11436/// `tag_human` narrator prose) the prior inline `format!(" tag:
11437/// {t:?}")` + `format!("tag {t}")` literals in
11438/// caixa-flux/src/lib.rs carried on the tag-arm of the discriminated-
11439/// union.
11440///
11441/// [cf]: ../../caixa_flux/index.html
11442pub const FLUX_GITREPOSITORY_REF_KEY_TAG: &str = "tag";
11443
11444/// Canonical Flux v2 per-`GitRepository` `spec.ref.branch`
11445/// git-branch-selector scalar-axis key every `caixa-flux`-emitted
11446/// `gitrepository.yaml` document declares when the per-Servico
11447/// bundle's `git_ref` is a branch-shaped selector. Peer of
11448/// [`FLUX_GITREPOSITORY_REF_KEY_TAG`] /
11449/// [`FLUX_GITREPOSITORY_REF_KEY_COMMIT`] on the sibling per-shape arms
11450/// of the `FluxCD` source-controller `GitRepository.spec.ref`
11451/// ref-selection discriminated-union axis; see
11452/// [`FLUX_GITREPOSITORY_REF_KEY_TAG`] for the full lift rationale.
11453///
11454/// [cf]: ../../caixa_flux/index.html
11455pub const FLUX_GITREPOSITORY_REF_KEY_BRANCH: &str = "branch";
11456
11457/// Canonical Flux v2 per-`GitRepository` `spec.ref.commit`
11458/// git-commit-selector scalar-axis key every `caixa-flux`-emitted
11459/// `gitrepository.yaml` document declares when the per-Servico
11460/// bundle's `git_ref` is a commit-shaped selector. Peer of
11461/// [`FLUX_GITREPOSITORY_REF_KEY_TAG`] /
11462/// [`FLUX_GITREPOSITORY_REF_KEY_BRANCH`] on the sibling per-shape arms
11463/// of the `FluxCD` source-controller `GitRepository.spec.ref`
11464/// ref-selection discriminated-union axis; see
11465/// [`FLUX_GITREPOSITORY_REF_KEY_TAG`] for the full lift rationale.
11466///
11467/// [cf]: ../../caixa_flux/index.html
11468pub const FLUX_GITREPOSITORY_REF_KEY_COMMIT: &str = "commit";
11469
11470/// Canonical Flux v2 per-`GitRepository` `spec.ref` ref-selection
11471/// discriminated-union parent container-axis key every `caixa-flux`-
11472/// emitted `gitrepository.yaml` document mounts its per-shape
11473/// `{tag, branch, commit}` sub-selector arm under. Nests one level
11474/// above the sibling [`FLUX_GITREPOSITORY_REF_KEY_TAG`] /
11475/// [`FLUX_GITREPOSITORY_REF_KEY_BRANCH`] /
11476/// [`FLUX_GITREPOSITORY_REF_KEY_COMMIT`] triple it wraps — the K8s
11477/// Flux v2 `source.toolkit.fluxcd.io/v1` `GitRepository` CRD schema
11478/// pins the per-CR ref-selection through this `spec.ref` container-
11479/// axis, and every rendered `spec.ref.{tag,branch,commit}` arm the
11480/// [`caixa_flux::GitRefSpec`] discriminated-union emits nests
11481/// beneath this exact key.
11482///
11483/// The FluxCD `source-controller`'s per-CR `RESTMapper` reads
11484/// `spec.ref` to source the per-Servico git clone refspec (the
11485/// container-axis carrying the three-way `{tag, branch, commit}`
11486/// arm the controller dispatches on), so drift on the container-
11487/// axis KEY is exactly as load-bearing as drift on the sibling per-
11488/// shape sub-selector KEY the arms decode through: a `"Ref"` /
11489/// `"gitRef"` / `"revision"` / `"source"` typo at the writer site
11490/// silently emits a `GitRepository` whose ref-selection container-
11491/// axis the CRD schema validator drops as unknown, and the sibling
11492/// `HelmRelease.spec.chart.spec.sourceRef` reference dangles at
11493/// admission with the per-Servico clone never resolving at reconcile
11494/// time — apply-side: the Flux v2 `source-controller`'s per-CR
11495/// reconcile loop no-ops entirely (no clone, no artifact, no
11496/// checksum), the sibling `HelmRelease`'s per-chart resolve step
11497/// finds the empty artifact, and every rendered `HelmRelease` /
11498/// `Kustomization` bundle document downstream of this `GitRepository`
11499/// silently no-ops at the FluxCD apply chain with no field naming
11500/// the container-axis-drift root cause.
11501///
11502/// The single source of truth every Flux-v2-per-`GitRepository`-
11503/// `spec.ref`-container-axis-naming reaches for — the two per-render
11504/// consumer sites the [`crate::render`]-side lift closes:
11505///
11506/// - the rendered `gitrepository.yaml` document's per-`GitRepository`
11507/// `spec.ref` YAML block-body axis (caixa-flux's `cluster_bundle`
11508/// `gitrepo` template composer's `ref:` sub-block header — the
11509/// sole production emission site the prior inline `"ref:"`
11510/// literal sat at);
11511/// - the peer test-fixture navigation site
11512/// (caixa-flux's `cluster_bundle_gitrepository_ref_*` per-arm
11513/// round-trip pin's `.get("ref")` sub-selector traversal step —
11514/// the sole test-side reader site the prior inline `"ref"`
11515/// literal sat at).
11516///
11517/// Changing this value is a coordinated Flux v3 migration alongside
11518/// the upstream `fluxcd/flux2` deprecation cycle, not an incidental
11519/// edit — pinning it here means the migration lands as one edit at
11520/// the const plus a re-run of the pin tests rather than a per-
11521/// renderer sweep with no single source of truth to consult.
11522///
11523/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5)
11524/// promotes the parent-container-axis byte-string to a typed
11525/// substrate-side `&'static str` on the same trajectory the sibling
11526/// per-shape arm sub-selector-key
11527/// [`FLUX_GITREPOSITORY_REF_KEY_TAG`] (7d40380) /
11528/// [`FLUX_GITREPOSITORY_REF_KEY_BRANCH`] (7d40380) /
11529/// [`FLUX_GITREPOSITORY_REF_KEY_COMMIT`] (7d40380) triple lifts
11530/// established on the sibling per-shape arm surface — nests the
11531/// parent container-axis KEY above the already-lifted per-shape arm
11532/// sub-selector-KEY triple, so the whole per-`GitRepository`
11533/// `spec.ref` sub-schema (parent container-axis KEY + per-shape arm
11534/// sub-selector-KEY triple + per-arm value) now navigates through
11535/// four caixa-core `&'static str`s in coordination, and any future
11536/// Flux v2 sub-schema rebrand (an upstream `fluxcd/flux2` v3
11537/// rename of the ref-selection container-axis from `spec.ref` to
11538/// `spec.gitRef` / `spec.source.ref`) lands at one const edit
11539/// coordinated with the sibling per-shape arm lifts.
11540///
11541/// [cf]: ../../caixa_flux/index.html
11542pub const FLUX_GITREPOSITORY_KEY_REF: &str = "ref";
11543
11544/// Canonical Flux v2 `GitRepository.spec.url` per-CR remote-repo-URL
11545/// leaf-scalar-axis key every [`caixa-flux`][cf]-rendered
11546/// `gitrepository.yaml` document declares. The FluxCD `source-controller`
11547/// reads `spec.url` as the git remote URL it clones per-reconcile — the
11548/// authoritative remote the per-Servico artifact archive is sourced from
11549/// at every reconcile cycle. A drifted key (e.g. `"URL"`, `"gitUrl"`,
11550/// `"repo"`, `"repository"`) at the writer site would silently emit a
11551/// `GitRepository` whose CRD schema validator drops the URL field as
11552/// unknown, and the per-Servico artifact would never populate — the
11553/// downstream `HelmRelease.spec.chart.spec.sourceRef` reference dangles
11554/// with an empty artifact at admission, every rendered `HelmRelease` /
11555/// `Kustomization` bundle document downstream silently no-ops at
11556/// reconcile time with no field naming the URL-key-drift root cause.
11557///
11558/// Sibling to the already-lifted per-`GitRepository`-CR `spec` sub-
11559/// block keys [`FLUX_GITREPOSITORY_KEY_REF`] (84a3c20, the parent
11560/// container-axis for the `spec.ref.{tag,branch,commit}` per-shape arm
11561/// discriminated union) — this constant names the peer per-CR leaf-
11562/// scalar remote-URL axis on the same top-level `spec` position. Both
11563/// axes together completely enumerate the `GitRepository.spec.*` per-
11564/// CR sub-block keys `caixa-flux`'s current `cluster_bundle` gitrepo
11565/// template writes (`spec.interval` reaches through the lifted
11566/// `FLUX_KEY_INTERVAL`, `spec.url` through this constant, `spec.ref`
11567/// through [`FLUX_GITREPOSITORY_KEY_REF`]), so any future Flux v3
11568/// `GitRepository` schema promotion lands as one caixa-core edit
11569/// coordinated across the sibling sub-block key axes.
11570///
11571/// The single source of truth every Flux-v2-per-`GitRepository`-
11572/// `spec.url`-leaf-scalar-axis-naming reaches for — one production
11573/// consumer today:
11574///
11575/// - the rendered `gitrepository.yaml` document's per-`GitRepository`
11576/// `spec.url` leaf-scalar remote-URL axis (caixa-flux's
11577/// `cluster_bundle` `gitrepo` template composer's `url:` sub-key
11578/// — the sole production emission site the prior inline `"url:"`
11579/// literal sat at).
11580///
11581/// Every future per-`GitRepository` renderer (the M4 typed-Aplicacao
11582/// materializer's per-Aplicacao `GitRepository` synthesis for
11583/// per-aggregator-manifest sources, any future `caixa-otel`
11584/// collector-pipeline `GitRepository`, any future per-cluster snapshot
11585/// `GitRepository` the operator emits) inherits the canonical URL
11586/// leaf-scalar key by construction with no opportunity for
11587/// per-renderer drift.
11588///
11589/// [cf]: ../../caixa_flux/index.html
11590pub const FLUX_GITREPOSITORY_KEY_URL: &str = "url";
11591
11592/// Canonical Flux v2 per-cluster-bundle `HelmRelease` document
11593/// filename every [`caixa-flux`][cf]-rendered `cluster_bundle` carries
11594/// at the per-Servico bundle's rendered file collection — the fixed
11595/// filename the sibling `gitrepository.yaml` + `kustomization.yaml`
11596/// bundle documents key against when the cluster-side `FluxCD`
11597/// controllers reconcile the per-Servico release cycle, and the
11598/// exact filename every downstream consumer that reaches into the
11599/// rendered bundle by document name looks up.
11600///
11601/// Two production consumers reach for this filename:
11602///
11603/// - [`caixa-flux`][cf]'s [`cluster_bundle`][cb] `BundleFile`
11604/// assembly's per-file `path` axis for the `HelmRelease`
11605/// document — the sole caixa-flux production emit site the prior
11606/// inline `PathBuf::from("helmrelease.yaml")` literal sat at,
11607/// one of the three canonical per-Servico Flux bundle files the
11608/// renderer emits alongside the sibling `gitrepository.yaml` +
11609/// `kustomization.yaml` documents;
11610/// - the peer test-fixture navigators in this crate reach into the
11611/// rendered `BundleFile` collection by the same filename to
11612/// round-trip-pin each emitted `HelmRelease` axis — a dozen
11613/// `.find(|f| f.path == PathBuf::from("helmrelease.yaml"))` +
11614/// `names.contains(&"helmrelease.yaml".to_string())` fixture
11615/// navigators across every per-CR body-axis sweep, `apiVersion`
11616/// round-trip, `spec.chart` / `spec.values` / `spec.sourceRef`
11617/// nested block existence pin.
11618///
11619/// Until this lift landed the filename `"helmrelease.yaml"` lived as
11620/// thirteen verbatim inline literals (one production
11621/// `PathBuf::from("helmrelease.yaml")` at the `cluster_bundle`
11622/// `BundleFile`-vec construction site + twelve test-side
11623/// `PathBuf::from("helmrelease.yaml")` /
11624/// `names.contains(&"helmrelease.yaml".to_string())` /
11625/// `.expect("helmrelease.yaml present")` fixture navigators). A drift
11626/// on the emit side (a `"HelmRelease.yaml"` / `"helm-release.yaml"` /
11627/// `"helmrelease.yml"` / `"helm_release.yaml"` typo, or an accidental
11628/// per-fork rebrand onto a stale filename any per-edition Flux
11629/// substrate might introduce) at any one site would surface as one of
11630/// two silent failure modes at cluster-side reconcile time:
11631///
11632/// - the `FluxCD` `kustomize-controller` refuses to apply the
11633/// rendered bundle at all — the per-Servico
11634/// `Kustomization.spec.path` opens the bundle directory and its
11635/// `HelmRelease` navigator returns `None`, with the reconcile
11636/// dropping at "no `HelmRelease` document found under this
11637/// bundle" far from the emit-drift commit's source, and the
11638/// per-Servico release cycle drops with no field naming the
11639/// bundle-filename-drift root cause (the operator sees "the
11640/// release never picks up its Helm chart" with no canonical
11641/// anchor to compare the rendered filename against);
11642/// - the sibling `Kustomization` document's per-CR
11643/// `spec.healthChecks[]` references the drifted filename via
11644/// `namespace/name` — the healthCheck stays perpetually `Unknown`
11645/// because the referenced `HelmRelease` never materializes at the
11646/// expected bundle path, and the peer `GitRepository` document's
11647/// every-poll reconcile ticks the bundle-tree hash over the
11648/// drifted filename with the per-Servico release cycle silently
11649/// frozen at "waiting on healthCheck".
11650///
11651/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
11652/// "every recurring shape becomes a generator before it becomes a
11653/// pattern; every pattern becomes a library before it becomes
11654/// duplicated code. The duplication budget is zero.") promotes the
11655/// filename to a typed substrate-side `&'static str` on the same
11656/// trajectory the peer [`HELM_CHART_YAML_FILENAME`] (c2c99b0) /
11657/// [`HELM_VALUES_YAML_FILENAME`] (9a980ba) lifts established on the
11658/// sibling Helm-chart-directory filename axes — pivots the
11659/// canonical-filename single-sourcing discipline from the per-Helm-
11660/// chart-directory metadata / values file surfaces onto the sibling
11661/// per-Flux-v2-bundle `HelmRelease` document filename axis every
11662/// rendered per-Servico bundle declares at its cluster-side reconcile
11663/// tree. Peer of a future sibling lift on the other two per-Servico
11664/// Flux bundle document filenames (`gitrepository.yaml` +
11665/// `kustomization.yaml`) — this const anchors the first coordinate
11666/// of the per-bundle
11667/// `(gitrepository, helmrelease, kustomization)` filename axis triple
11668/// every rendered cluster bundle carries.
11669///
11670/// [cf]: ../../caixa_flux/index.html
11671/// [cb]: ../../caixa_flux/fn.cluster_bundle.html
11672pub const FLUX_HELMRELEASE_YAML_FILENAME: &str = "helmrelease.yaml";
11673
11674/// Canonical Flux v2 per-cluster-bundle `GitRepository` document
11675/// filename every [`caixa-flux`][cf]-rendered [`cluster_bundle`][cb]
11676/// carries at the per-Servico bundle's rendered file collection — the
11677/// fixed filename the sibling `helmrelease.yaml` +
11678/// `kustomization.yaml` documents key against when the cluster-side
11679/// `FluxCD` `source-controller` reconciles the per-Servico Git-source
11680/// poll cycle, and the exact filename every downstream consumer that
11681/// reaches into the rendered bundle by document name looks up.
11682///
11683/// Two production consumers reach for this filename:
11684///
11685/// - [`caixa-flux`][cf]'s [`cluster_bundle`][cb] `BundleFile`
11686/// assembly's per-file `path` axis for the `GitRepository`
11687/// document — the sole caixa-flux production emit site the prior
11688/// inline `PathBuf::from("gitrepository.yaml")` literal sat at,
11689/// one of the three canonical per-Servico Flux bundle files the
11690/// renderer emits alongside the sibling `helmrelease.yaml` +
11691/// `kustomization.yaml` documents (the second coordinate of the
11692/// per-bundle `(gitrepository, helmrelease, kustomization)`
11693/// filename axis triple this const closes);
11694/// - the peer test-fixture navigators in this crate reach into the
11695/// rendered `BundleFile` collection by the same filename to
11696/// round-trip-pin each emitted `GitRepository` axis — every
11697/// `.find(|f| f.path == PathBuf::from("gitrepository.yaml"))` +
11698/// `names.contains(&"gitrepository.yaml".to_string())` fixture
11699/// navigator across the per-CR body-axis sweeps that pin the
11700/// Git-source apiVersion / kind / `spec.url` / `spec.ref`
11701/// round-trips.
11702///
11703/// Until this lift landed the filename `"gitrepository.yaml"` lived
11704/// as nine verbatim inline literals across [`caixa-flux`][cf] (one
11705/// production `PathBuf::from("gitrepository.yaml")` at the
11706/// `cluster_bundle` `BundleFile`-vec construction site + eight
11707/// test-side fixture navigators). A drift on the emit side (a
11708/// `"GitRepository.yaml"` / `"git-repository.yaml"` /
11709/// `"gitrepository.yml"` typo, or an accidental per-fork rebrand)
11710/// would surface at cluster-side reconcile time far from the source:
11711/// the `FluxCD` `source-controller` never registers a `GitRepository`
11712/// document under the expected bundle path, the sibling
11713/// `HelmRelease.spec.chart.spec.sourceRef` reference dangles at
11714/// admission, and the per-Servico release cycle silently freezes at
11715/// last-applied state with no field naming the filename-drift root
11716/// cause.
11717///
11718/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
11719/// "every recurring shape becomes a generator before it becomes a
11720/// pattern; every pattern becomes a library before it becomes
11721/// duplicated code. The duplication budget is zero.") promotes the
11722/// filename to a typed substrate-side `&'static str` on the same
11723/// trajectory the peer [`FLUX_HELMRELEASE_YAML_FILENAME`] (ba7b0b2) /
11724/// [`HELM_CHART_YAML_FILENAME`] (c2c99b0) /
11725/// [`HELM_VALUES_YAML_FILENAME`] (9a980ba) lifts established on the
11726/// sibling per-Flux-v2-bundle / per-Helm-chart-directory filename
11727/// axes — pairs with the sibling
11728/// [`FLUX_KUSTOMIZATION_YAML_FILENAME`] on the third coordinate to
11729/// close the per-bundle `(gitrepository, helmrelease, kustomization)`
11730/// filename axis triple every rendered cluster bundle carries.
11731///
11732/// [cf]: ../../caixa_flux/index.html
11733/// [cb]: ../../caixa_flux/fn.cluster_bundle.html
11734pub const FLUX_GITREPOSITORY_YAML_FILENAME: &str = "gitrepository.yaml";
11735
11736/// Canonical Flux v2 per-cluster-bundle `Kustomization` document
11737/// filename every [`caixa-flux`][cf]-rendered [`cluster_bundle`][cb]
11738/// carries at the per-Servico bundle's rendered file collection — the
11739/// fixed filename the sibling `gitrepository.yaml` +
11740/// `helmrelease.yaml` documents key against when the cluster-side
11741/// `FluxCD` `kustomize-controller` reconciles the per-Servico apply
11742/// cycle, and the exact filename every downstream consumer that
11743/// reaches into the rendered bundle by document name looks up.
11744///
11745/// Two production consumers reach for this filename:
11746///
11747/// - [`caixa-flux`][cf]'s [`cluster_bundle`][cb] `BundleFile`
11748/// assembly's per-file `path` axis for the `Kustomization`
11749/// document — the sole caixa-flux production emit site the prior
11750/// inline `PathBuf::from("kustomization.yaml")` literal sat at,
11751/// one of the three canonical per-Servico Flux bundle files the
11752/// renderer emits alongside the sibling `gitrepository.yaml` +
11753/// `helmrelease.yaml` documents (the third coordinate of the
11754/// per-bundle `(gitrepository, helmrelease, kustomization)`
11755/// filename axis triple this const closes);
11756/// - the peer test-fixture navigators in this crate reach into the
11757/// rendered `BundleFile` collection by the same filename to
11758/// round-trip-pin each emitted `Kustomization` axis — every
11759/// `.find(|f| f.path == PathBuf::from("kustomization.yaml"))` +
11760/// `names.contains(&"kustomization.yaml".to_string())` fixture
11761/// navigator across the per-CR body-axis sweeps that pin the
11762/// Kustomization apiVersion / kind / `spec.sourceRef` /
11763/// `spec.healthChecks` round-trips.
11764///
11765/// Until this lift landed the filename `"kustomization.yaml"` lived
11766/// as sixteen verbatim inline literals across [`caixa-flux`][cf]
11767/// (one production `PathBuf::from("kustomization.yaml")` at the
11768/// `cluster_bundle` `BundleFile`-vec construction site + fifteen
11769/// test-side fixture navigators). A drift on the emit side (a
11770/// `"Kustomization.yaml"` / `"kustomize.yaml"` / `"kustomization.yml"`
11771/// typo, or an accidental per-fork rebrand) would surface at
11772/// cluster-side reconcile time far from the source: the `FluxCD`
11773/// `kustomize-controller` never picks up the parent `Kustomization`
11774/// under the expected bundle path, every per-Servico apply silently
11775/// stops advancing at last-applied state, and the sibling
11776/// `HelmRelease` / `GitRepository` reconciles register with no
11777/// parent Kustomization gating their health, with no field naming
11778/// the filename-drift root cause.
11779///
11780/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
11781/// "every recurring shape becomes a generator before it becomes a
11782/// pattern; every pattern becomes a library before it becomes
11783/// duplicated code. The duplication budget is zero.") promotes the
11784/// filename to a typed substrate-side `&'static str` on the same
11785/// trajectory the peer [`FLUX_HELMRELEASE_YAML_FILENAME`] (ba7b0b2) /
11786/// [`FLUX_GITREPOSITORY_YAML_FILENAME`] (this commit) /
11787/// [`HELM_CHART_YAML_FILENAME`] (c2c99b0) /
11788/// [`HELM_VALUES_YAML_FILENAME`] (9a980ba) lifts established on the
11789/// sibling per-Flux-v2-bundle / per-Helm-chart-directory filename
11790/// axes — closes the per-bundle `(gitrepository, helmrelease,
11791/// kustomization)` filename axis triple every rendered cluster
11792/// bundle carries.
11793///
11794/// [cf]: ../../caixa_flux/index.html
11795/// [cb]: ../../caixa_flux/fn.cluster_bundle.html
11796pub const FLUX_KUSTOMIZATION_YAML_FILENAME: &str = "kustomization.yaml";
11797
11798/// Canonical K8s Gateway API CRD `apiVersion` every `caixa-mesh`-emitted
11799/// `Gateway` / `HTTPRoute` document declares. The K8s apiserver-side
11800/// SIG-Network Gateway API conformance registers the `Gateway` /
11801/// `HTTPRoute` / `GatewayClass` / `TCPRoute` / `TLSRoute` / `GRPCRoute`
11802/// CRDs at this exact group/version (`gateway.networking.k8s.io/v1`);
11803/// drift to a stale `v1beta1` / `v1alpha2` (the pre-GA Gateway API betas
11804/// every upstream conformance doc names) silently routes the rendered
11805/// `Gateway` / `HTTPRoute` outside the apiserver's CRD-version
11806/// registration and breaks at apply time with a non-self-locating "no
11807/// kind 'Gateway' is registered for version
11808/// 'gateway.networking.k8s.io/v1beta1'" error far from the source
11809/// caixa.lisp / the renderer's [`kube_resource_skeleton`] call site.
11810///
11811/// The single source of truth both Gateway-API CRD axes of the rendered
11812/// Aplicacao mesh bundle reach for:
11813///
11814/// - `Gateway` `apiVersion` — the top-level CRD-group/version the
11815/// rendered Gateway document declares (caixa-mesh/src/lib.rs:455 —
11816/// the `gateway_routes` per-Aplicacao Gateway skeleton call);
11817/// - `HTTPRoute` `apiVersion` — the same Gateway API CRD
11818/// group/version every per-`:entrada :paths` HTTPRoute declares
11819/// (caixa-mesh/src/lib.rs:496 — the `gateway_routes` HTTPRoute
11820/// skeleton call). The K8s SIG-Network Gateway API contract bumps
11821/// `Gateway`, `HTTPRoute`, `GatewayClass`, and the rest of the
11822/// per-conformance CRD set as a unit; a future Gateway-API GA
11823/// promotion (the upstream Gateway API SIG roadmap names per-CRD-
11824/// group / per-version migration once the v1 GA branch matures) on
11825/// one axis without a coordinated edit on the other would have
11826/// silently emitted a `Gateway` / `HTTPRoute` pair pointing at
11827/// distinct CRD versions — apply-side: the `Gateway` and
11828/// `HTTPRoute` land in two distinct apiserver-side CRD
11829/// registrations, the per-route attached-policy resolution
11830/// pipeline never binds, every external `:entrada` flow drops at
11831/// the gateway with no field naming the version-drift root cause.
11832///
11833/// Until this lift landed both axes carried inline
11834/// `gateway.networking.k8s.io/v1` literals across two production-code
11835/// occurrences in caixa-mesh/src/lib.rs:455, 496 (the `gateway_routes`
11836/// `Gateway` + `HTTPRoute` skeleton calls) plus a matching pair inside
11837/// the in-file `gateway_carries_canonical_kube_skeleton_without_labels`
11838/// + `httproute_carries_canonical_kube_skeleton_without_labels` test
11839/// fixtures — four occurrences of the same load-bearing Gateway API
11840/// CRD-group/version convention, drift-prone by construction.
11841///
11842/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
11843/// "every recurring shape becomes a generator before it becomes a
11844/// pattern; every pattern becomes a library before it becomes
11845/// duplicated code. The duplication budget is zero.") promotes the
11846/// constant to a typed substrate-side `&'static str` on the same
11847/// trajectory the [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) /
11848/// [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3) /
11849/// [`FLUX_KUSTOMIZATION_API_VERSION`] (d2dd1b1) /
11850/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) lifts established on
11851/// the peer Flux-v2-controller-triplet canonical-load-bearing-string
11852/// axis — extends the discipline from the cluster-side Flux v2
11853/// reconcile contract (the source/helm/kustomize controllers) onto
11854/// the cluster-side K8s Gateway API ingress contract (the
11855/// Gateway-API-conformant gateway implementation: Cilium, Istio,
11856/// Envoy Gateway, NGINX, et al.). The two render-side consumers now
11857/// thread the same `&'static str` through their `kube_resource_skeleton`
11858/// calls so a future Gateway API CRD-group/version promotion lands in
11859/// one place; every future renderer that reaches for the canonical
11860/// Gateway API CRD apiVersion (the future M4
11861/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
11862/// Gateway + HTTPRoute, a future per-edge `TCPRoute` / `TLSRoute` /
11863/// `GRPCRoute` the caixa-mesh emits for non-HTTP `:entrada` edges,
11864/// a future `GatewayClass` the operator emits for per-cluster
11865/// gateway-class scoping) inherits the same value by construction
11866/// with no opportunity for per-renderer drift.
11867///
11868/// [cm]: ../../caixa_mesh/index.html
11869pub const GATEWAY_API_API_VERSION: &str = "gateway.networking.k8s.io/v1";
11870
11871/// Canonical Cilium CRD `apiVersion` every `caixa-mesh`-emitted
11872/// `CiliumNetworkPolicy` document declares. The Cilium control plane's
11873/// upstream-shipped CRD bundle registers `CiliumNetworkPolicy`,
11874/// `CiliumClusterwideNetworkPolicy`, `CiliumEndpoint`, `CiliumIdentity`,
11875/// `CiliumNode`, `CiliumLocalRedirectPolicy`, and the rest of the
11876/// per-conformance Cilium CRD set at this exact group/version
11877/// (`cilium.io/v2`); drift to a stale `v2alpha1` (the historical
11878/// pre-stable Cilium-CRD-group/version label upstream Cilium-CRD docs
11879/// reference for in-flight per-CRD-version migration) silently routes
11880/// the rendered `CiliumNetworkPolicy` outside the cluster's
11881/// Cilium-operator-side CRD-version registration and breaks at apply
11882/// time with a non-self-locating "no kind 'CiliumNetworkPolicy' is
11883/// registered for version 'cilium.io/v2alpha1'" error far from the
11884/// source caixa.lisp / the renderer's [`kube_resource_skeleton`] call
11885/// site.
11886///
11887/// The single source of truth the rendered Aplicacao Cilium-side
11888/// mesh bundle's CRD-group/version axis reaches for:
11889///
11890/// - `CiliumNetworkPolicy` `apiVersion` — the top-level CRD-group/
11891/// version every emitted CNP document declares
11892/// (caixa-mesh/src/lib.rs:326 — the `cilium_network_policies`
11893/// per-`(:de, :para)` policy skeleton call). Until this lift
11894/// landed both the production-code emit at the per-policy
11895/// skeleton call site and the matching in-file
11896/// `cilium_policy_carries_canonical_kube_skeleton` test fixture
11897/// pin (caixa-mesh/src/lib.rs:1560) carried inline `"cilium.io/v2"`
11898/// string literals — two occurrences of the same load-bearing
11899/// Cilium-CRD-group/version convention, drift-prone by
11900/// construction. The Cilium project bumps the per-conformance
11901/// Cilium-CRD set as a unit; a future Cilium-CRD-group/version
11902/// promotion (the upstream Cilium roadmap names per-CRD-group /
11903/// per-version migration once the `cilium.io/v3` branch lands) on
11904/// one axis without a coordinated edit on the other would have
11905/// silently emitted a `CiliumNetworkPolicy` document whose
11906/// top-level apiVersion drifts off the lifted-test-fixture pin —
11907/// apply-side: the policy lands in a stale CRD-version
11908/// registration the Cilium operator no longer watches, every
11909/// `(:de, :para)` intra-mesh L4 contract drops at the eBPF data
11910/// plane with no field naming the version-drift root cause.
11911///
11912/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
11913/// "every recurring shape becomes a generator before it becomes a
11914/// pattern; every pattern becomes a library before it becomes
11915/// duplicated code. The duplication budget is zero.") promotes the
11916/// constant to a typed substrate-side `&'static str` on the same
11917/// trajectory the [`GATEWAY_API_API_VERSION`] (3c6cfc3) /
11918/// [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) /
11919/// [`FLUX_GITREPOSITORY_API_VERSION`] (8a6c8a3) /
11920/// [`FLUX_KUSTOMIZATION_API_VERSION`] (d2dd1b1) /
11921/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) lifts established on
11922/// the peer K8s Gateway API ingress / Flux v2 reconcile canonical-
11923/// load-bearing-string axes — extends the discipline from the
11924/// cluster-side K8s Gateway API ingress + Flux v2 reconcile contracts
11925/// onto the cluster-side Cilium identity-based mesh contract (the
11926/// eBPF-anchored Cilium control plane that materializes every
11927/// per-`(:de, :para)` L4 / L7 contrato as an identity-keyed eBPF
11928/// allow rule). The render-side consumer now threads the same
11929/// `&'static str` through its `kube_resource_skeleton` call so a
11930/// future Cilium-CRD-group/version promotion lands in one place;
11931/// every future renderer that reaches for the canonical
11932/// Cilium-CRD apiVersion (the future M4
11933/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
11934/// per-Aplicacao CiliumNetworkPolicy fan-out, a future
11935/// `CiliumClusterwideNetworkPolicy` the caixa-mesh emits for
11936/// cluster-scoped baseline-allow / baseline-deny rules, a future
11937/// `CiliumLocalRedirectPolicy` the operator emits for per-Servico
11938/// local-redirect coordination) inherits the same value by
11939/// construction with no opportunity for per-renderer drift.
11940///
11941/// [cm]: ../../caixa_mesh/index.html
11942pub const CILIUM_API_VERSION: &str = "cilium.io/v2";
11943
11944/// Canonical Cilium CRD `kind` discriminator the rendered
11945/// `CiliumNetworkPolicy` document declares at its top-level
11946/// [`KUBE_KEY_KIND`] axis. Pairs with the sibling [`CILIUM_API_VERSION`]
11947/// (279d611) — the K8s apiserver-side CRD resolution contract is the
11948/// `(apiVersion, kind)` tuple keyed against the registered
11949/// `CustomResourceDefinition`, so drift on the kind axis is exactly as
11950/// load-bearing as drift on the apiVersion axis it accompanies (the
11951/// apiserver's `RESTMapper` consults both together; a
11952/// `("cilium.io/v2", "CilumNetworkPolicy")` typo at the production-code
11953/// call site lands outside the registered Cilium-operator-side
11954/// `CiliumNetworkPolicy` CRD's `RESTKind` lookup, surfacing apply-side as
11955/// a non-self-locating "no kind 'CilumNetworkPolicy' is registered for
11956/// version 'cilium.io/v2'" error far from the source caixa.lisp / the
11957/// renderer's [`kube_resource_skeleton`] call site).
11958///
11959/// The single source of truth the rendered Aplicacao Cilium-side mesh
11960/// bundle's `CiliumNetworkPolicy`-naming axis reaches for:
11961///
11962/// - the rendered `CiliumNetworkPolicy` document's top-level
11963/// [`KUBE_KEY_KIND`] axis (caixa-mesh/src/lib.rs:382 — the
11964/// `cilium_network_policies` per-`(:de, :para)` policy
11965/// [`kube_resource_skeleton`] call).
11966///
11967/// The kind axis names the same Cilium-operator-side CRD discriminator
11968/// as the sibling [`CILIUM_API_VERSION`] apiVersion axis and must move
11969/// together on any future `cilium.io/v3` rebrand. Until this lift
11970/// landed the axis carried an inline `CiliumNetworkPolicy` literal at
11971/// the one production-code occurrence in caixa-mesh/src/lib.rs:382 (the
11972/// `cilium_network_policies` [`kube_resource_skeleton`] kind argument)
11973/// plus a matching set inside the in-file
11974/// `cilium_policy_carries_canonical_kube_skeleton` /
11975/// `render_all_includes_every_artifact_kind` /
11976/// `cilium_policy_metadata_block_iterates_alphabetically` test fixtures
11977/// — occurrences of the same load-bearing Cilium-CRD-`kind`-discriminator
11978/// convention, drift-prone by construction. A drift on the top-level
11979/// `CiliumNetworkPolicy` `kind` axis would have surfaced as a
11980/// non-self-locating "no kind 'CilumNetworkPolicy' is registered for
11981/// version 'cilium.io/v2'" error far from the source caixa.lisp at
11982/// apply parse time, with the rendered per-`(:de, :para)` CNP never
11983/// landing in the Cilium-operator-side CRD registration and every
11984/// intra-mesh L4/L7 contrato flow dropping at the eBPF data plane with
11985/// no field naming the kind-discriminator-drift root cause.
11986///
11987/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
11988/// "every recurring shape becomes a generator before it becomes a
11989/// pattern; every pattern becomes a library before it becomes
11990/// duplicated code. The duplication budget is zero.") promotes the
11991/// constant to a typed substrate-side `&'static str` on the same
11992/// trajectory the [`FLUX_KIND_KUSTOMIZATION`] (4114773) /
11993/// [`FLUX_KIND_HELM_RELEASE`] (e24ea3c) /
11994/// [`FLUX_KIND_GIT_REPOSITORY`] (dbbcf29) /
11995/// [`CILIUM_API_VERSION`] (279d611) /
11996/// [`GATEWAY_API_API_VERSION`] (3c6cfc3) lifts established on the
11997/// sibling cluster-side-CRD-`kind`-discriminator + canonical-CRD-
11998/// group/version axes — extends the discipline from the apiVersion
11999/// half of the `(apiVersion, kind)` CRD-lookup tuple onto the kind
12000/// half on the same Cilium-CRD-axis, completing the per-Cilium-CRD
12001/// kind+apiVersion lift pair the M3 Aplicacao mesh renderer's eBPF
12002/// data-plane contract rests on. The render-side consumer now threads
12003/// the same `&'static str` through its [`kube_resource_skeleton`] call
12004/// so a future `cilium.io/v3` rebrand lands in one place; every future
12005/// renderer that reaches for the canonical Cilium `CiliumNetworkPolicy`
12006/// kind (the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
12007/// materializer's per-Aplicacao CiliumNetworkPolicy fan-out, a future
12008/// per-cluster baseline-allow / baseline-deny renderer that emits the
12009/// peer `CiliumClusterwideNetworkPolicy`, a future per-Servico
12010/// local-redirect renderer that emits the peer
12011/// `CiliumLocalRedirectPolicy`) inherits the same value by construction
12012/// with no opportunity for per-renderer drift.
12013///
12014/// Same "the typed constant lives in one place" discipline the
12015/// [`FLUX_KIND_KUSTOMIZATION`] (4114773) /
12016/// [`FLUX_KIND_HELM_RELEASE`] (e24ea3c) /
12017/// [`FLUX_KIND_GIT_REPOSITORY`] (dbbcf29) /
12018/// [`CILIUM_API_VERSION`] (279d611) /
12019/// [`GATEWAY_API_API_VERSION`] (3c6cfc3) /
12020/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) lifts apply on the peer
12021/// canonical-cluster-side-CRD-discriminator surface.
12022///
12023/// [cm]: ../../caixa_mesh/index.html
12024pub const CILIUM_KIND_NETWORK_POLICY: &str = "CiliumNetworkPolicy";
12025
12026/// Canonical Cilium `CiliumNetworkPolicy` L4/L7 per-ingress-rule port-set
12027/// container-axis key every `cilium_network_policies`-emitted CNP
12028/// document mounts its per-ingress-rule `[{ports: […], rules: {…}}]`
12029/// list under (`spec.ingress[].toPorts[]`). Pairs with the sibling
12030/// [`KUBE_KEY_RULES`] (a205eb3) — the Cilium L7-dispatch schema nests
12031/// `spec.ingress[].toPorts[].rules.http[]` under the shared
12032/// (`toPorts`, `rules`) container-key pair, so drift on the `toPorts`
12033/// axis is exactly as load-bearing as drift on the `rules` axis it
12034/// wraps (the Cilium-operator-side CRD schema validator drops any
12035/// `spec.ingress[]` entry whose port-set container carries an
12036/// unrecognized key — a `"toports"` / `"toPort"` / `"targetPorts"` typo
12037/// silently emits an ingress rule whose per-port set the Cilium
12038/// operator's per-CNP L4/L7 dispatch pass no-ops entirely: every
12039/// intra-mesh `:contratos` flow the CNP was authored to allow now
12040/// drops at the eBPF data plane's default-deny gate with no field
12041/// naming the port-set-container-drift root cause).
12042///
12043/// The single source of truth the rendered Aplicacao Cilium-side mesh
12044/// bundle's per-CNP port-set-container-naming axis reaches for:
12045///
12046/// - the rendered `CiliumNetworkPolicy` document's
12047/// `spec.ingress[].toPorts[]` axis (caixa-mesh/src/lib.rs:939 —
12048/// the `cilium_network_policies` per-`(:de, :para)` policy's
12049/// `ingress_rule.insert("toPorts", …)` call).
12050///
12051/// The port-set-container axis names the same Cilium-operator-side
12052/// per-ingress-rule dispatch container as the sibling [`KUBE_KEY_RULES`]
12053/// nested L7-dispatch container axis and must move together on any
12054/// future Cilium CRD schema rebrand (an upstream `cilium.io/v3` rename
12055/// of the port-set container from `toPorts` to `ports` / `portSet` /
12056/// `endpoints`, coordinated with the Cilium project's periodic CRD
12057/// schema-migration passes). Until this lift landed the axis carried
12058/// an inline `toPorts` literal at the one production-code occurrence
12059/// in caixa-mesh/src/lib.rs:939 (the `cilium_network_policies`
12060/// `ingress_rule.insert("toPorts", …)` call) plus a matching set
12061/// inside the in-file `cilium_http_contracts_emit_l7_rules` /
12062/// `cilium_pubsub_contracts_skip_l7_rules` /
12063/// `cilium_multiple_edges_same_pair_fold_into_one_policy` /
12064/// `cnp_authentication_carries_mtls_overlay_at_ingress_rule_level` /
12065/// `cnp_l4_fallback_port_routes_through_lifted_default_servico_port`
12066/// test-fixture navigations — six occurrences of the same load-bearing
12067/// Cilium-CRD-`toPorts`-container-key convention, drift-prone by
12068/// construction. A drift on any one production or test-fixture site
12069/// to `"toports"` / `"toPort"` / `"targetPorts"` would have surfaced
12070/// as a Cilium-operator-side schema validator drop at apply time (the
12071/// affected `spec.ingress[]` entry's port-set container the CRD
12072/// schema validator recognizes as unknown), with every intra-mesh
12073/// `:contratos` flow the CNP was authored to allow dropping at the
12074/// eBPF data plane's default-deny gate with no field naming the
12075/// container-drift root cause. A drift on the test-fixture side
12076/// silently masks the emission-side pin (`.get("toPorts")` returns
12077/// `None` under both the drifted-key emitter and the drifted-key
12078/// probe — the `cilium_pubsub_contracts_skip_l7_rules` absence pin's
12079/// downstream `to_ports.get("rules").is_none()` assertion succeeds
12080/// vacuously because `to_ports` is itself `None`).
12081///
12082/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
12083/// "every recurring shape becomes a generator before it becomes a
12084/// pattern; every pattern becomes a library before it becomes
12085/// duplicated code. The duplication budget is zero.") promotes the
12086/// constant to a typed substrate-side `&'static str` on the same
12087/// trajectory the [`KUBE_KEY_RULES`] (a205eb3) /
12088/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
12089/// [`CILIUM_API_VERSION`] (279d611) lifts established on the sibling
12090/// canonical-K8s-CR-rule-list-axis / canonical-Cilium-CRD-`kind` /
12091/// canonical-Cilium-CRD-`apiVersion` surfaces — extends the discipline
12092/// from the outer `(apiVersion, kind, spec)` shell of the Cilium CNP
12093/// down through the load-bearing `spec.ingress[].toPorts[].rules`
12094/// dispatch axis onto the port-set container half of the
12095/// `(toPorts, rules)` L4/L7-dispatch container-key pair, completing
12096/// the per-CNP L4/L7-dispatch-axis lift pair the M3 Aplicacao mesh
12097/// renderer's eBPF data-plane contract rests on. The render-side
12098/// consumer now threads the same `&'static str` through its
12099/// `ingress_rule.insert(…)` call so a future Cilium-CRD rebrand
12100/// on the port-set-container axis (or an upstream Cilium project
12101/// rename to a per-CRD sibling name — unlikely but the same
12102/// coordination point the prior lifts anchor for) lands in one place;
12103/// every future renderer that reaches for the canonical
12104/// per-CNP port-set-container-axis (the future M4
12105/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
12106/// CiliumNetworkPolicy fan-out, a future
12107/// `CiliumClusterwideNetworkPolicy` renderer that emits cluster-scoped
12108/// baseline-allow rules with the same `spec.ingress[].toPorts[]`
12109/// shape, a future `CiliumClusterwideEnvoyConfig` renderer whose
12110/// per-edge Envoy configuration nests under the same port-set
12111/// container-key convention) inherits the same value by construction
12112/// with no opportunity for per-renderer drift.
12113///
12114/// Same "the typed constant lives in one place" discipline the
12115/// [`KUBE_KEY_RULES`] (a205eb3) /
12116/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
12117/// [`CILIUM_API_VERSION`] (279d611) lifts apply on the peer
12118/// canonical-Cilium-CNP-dispatch-axis surface.
12119///
12120/// [cm]: ../../caixa_mesh/index.html
12121pub const CILIUM_KEY_TO_PORTS: &str = "toPorts";
12122
12123/// Canonical Cilium `CiliumNetworkPolicy` destination-identity selector-
12124/// axis key every `cilium_network_policies`-emitted CNP document mounts
12125/// its L3-target `LabelSelector` under (`spec.endpointSelector`). Pairs
12126/// with the sibling [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) — the Cilium CNP
12127/// schema pins the destination workload through the `endpointSelector`
12128/// axis and the admitted L4 port set through the `toPorts` axis, so
12129/// drift on the destination-identity axis is exactly as load-bearing as
12130/// drift on the port-set-container axis it accompanies (the Cilium-
12131/// operator-side CRD schema validator drops any `spec` block whose
12132/// destination-identity axis carries an unrecognized key — an
12133/// `"endpointselector"` / `"endpointSelectors"` / `"endpoints"` typo
12134/// silently emits a CNP whose L3-target selector the Cilium operator's
12135/// per-CNP identity-resolution pass no-ops entirely: the policy binds
12136/// against no destination pods and every intra-mesh `:contratos` flow
12137/// the CNP was authored to allow drops at the eBPF data plane's
12138/// default-deny gate with no field naming the destination-identity-
12139/// axis-drift root cause).
12140///
12141/// The single source of truth the rendered Aplicacao Cilium-side mesh
12142/// bundle's per-CNP destination-identity-axis-naming reaches for:
12143///
12144/// - the rendered `CiliumNetworkPolicy` document's
12145/// `spec.endpointSelector` axis (caixa-mesh/src/lib.rs:990 —
12146/// the `cilium_network_policies` per-`(:de, :para)` policy's
12147/// `policy_spec.insert("endpointSelector", …)` call).
12148///
12149/// The destination-identity axis names the same Cilium-operator-side
12150/// per-CNP L3-target selector as the sibling [`CILIUM_KEY_TO_PORTS`]
12151/// per-ingress-rule port-set-container axis and must move together on
12152/// any future Cilium CRD schema rebrand (an upstream `cilium.io/v3`
12153/// rename of the destination-identity axis from `endpointSelector` to
12154/// `endpoints` / `targetSelector` / `destinationSelector`, coordinated
12155/// with the Cilium project's periodic CRD schema-migration passes).
12156/// Until this lift landed the axis carried an inline `endpointSelector`
12157/// literal at the one production-code occurrence in
12158/// caixa-mesh/src/lib.rs:990 (the `cilium_network_policies`
12159/// `policy_spec.insert("endpointSelector", …)` call) plus a matching
12160/// set inside the in-file
12161/// `cilium_policy_endpoint_selector_targets_destination_program` /
12162/// `cnp_endpoint_selector_carries_program_only_single_axis_shape` test-
12163/// fixture navigations — three occurrences of the same load-bearing
12164/// Cilium-CRD-`endpointSelector`-axis-key convention, drift-prone by
12165/// construction. A drift on any one production or test-fixture site
12166/// to `"endpointselector"` / `"endpointSelectors"` / `"endpoints"` would
12167/// have surfaced as a Cilium-operator-side schema validator drop at
12168/// apply time (the affected `spec` block's destination-identity axis
12169/// the CRD schema validator recognizes as unknown), with every intra-
12170/// mesh `:contratos` flow the CNP was authored to allow dropping at the
12171/// eBPF data plane's default-deny gate with no field naming the
12172/// destination-identity-drift root cause. A drift on the test-fixture
12173/// side silently masks the emission-side pin (`.get("endpointSelector")`
12174/// returns `None` under both the drifted-key emitter and the drifted-key
12175/// probe — the downstream `.and_then(|s| s.get("matchLabels"))` chain
12176/// short-circuits vacuously because the outer selector-lookup is itself
12177/// `None`).
12178///
12179/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
12180/// "every recurring shape becomes a generator before it becomes a
12181/// pattern; every pattern becomes a library before it becomes
12182/// duplicated code. The duplication budget is zero.") promotes the
12183/// constant to a typed substrate-side `&'static str` on the same
12184/// trajectory the [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
12185/// [`KUBE_KEY_RULES`] (a205eb3) /
12186/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
12187/// [`CILIUM_API_VERSION`] (279d611) lifts established on the sibling
12188/// canonical-Cilium-CNP-dispatch-axis / canonical-Cilium-CRD-`kind` /
12189/// canonical-Cilium-CRD-`apiVersion` surfaces — extends the discipline
12190/// from the outer `(apiVersion, kind, spec)` shell of the Cilium CNP
12191/// and the per-ingress-rule `toPorts.rules` L4/L7-dispatch axis onto
12192/// the destination-identity half of the `(endpointSelector, ingress)`
12193/// per-CNP-body key pair, completing the per-CNP L3/L4/L7-triad lift
12194/// set the M3 Aplicacao mesh renderer's eBPF data-plane contract rests
12195/// on. The render-side consumer now threads the same `&'static str`
12196/// through its `policy_spec.insert(…)` call so a future Cilium-CRD
12197/// rebrand on the destination-identity axis (or an upstream Cilium
12198/// project rename to a per-CRD sibling name — unlikely but the same
12199/// coordination point the prior lifts anchor for) lands in one place;
12200/// every future renderer that reaches for the canonical per-CNP
12201/// destination-identity-axis (the future M4
12202/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
12203/// `CiliumNetworkPolicy` fan-out, a future
12204/// `CiliumClusterwideNetworkPolicy` renderer that emits cluster-scoped
12205/// baseline-allow rules with the same `spec.endpointSelector` shape, a
12206/// future `CiliumLocalRedirectPolicy` renderer whose per-Servico local-
12207/// redirect selector nests under the same destination-identity axis
12208/// convention) inherits the same value by construction with no
12209/// opportunity for per-renderer drift.
12210///
12211/// Same "the typed constant lives in one place" discipline the
12212/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
12213/// [`KUBE_KEY_RULES`] (a205eb3) /
12214/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
12215/// [`CILIUM_API_VERSION`] (279d611) lifts apply on the peer
12216/// canonical-Cilium-CNP-body-axis surface.
12217///
12218/// [cm]: ../../caixa_mesh/index.html
12219pub const CILIUM_KEY_ENDPOINT_SELECTOR: &str = "endpointSelector";
12220
12221/// Canonical Cilium `CiliumNetworkPolicy` traffic-direction container-
12222/// axis key every `cilium_network_policies`-emitted CNP document mounts
12223/// its inbound-per-`(:de, :para)` ingress-rule list under (`spec.ingress[]`).
12224/// Pairs with the sibling [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) +
12225/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) — the per-CNP `spec` schema mounts
12226/// the destination workload identity under `endpointSelector`, the
12227/// permitted inbound-per-`(:de, :para)` ingress-rule list under
12228/// `ingress[]`, and each per-ingress-rule port-set under
12229/// `ingress[].toPorts[]`, so drift on the traffic-direction axis is
12230/// exactly as load-bearing as drift on the destination-identity /
12231/// port-set-container axes it accompanies (the Cilium-operator-side CRD
12232/// schema validator drops any `spec` block whose traffic-direction axis
12233/// carries an unrecognized key — an `"Ingress"` / `"ingressRules"` /
12234/// `"inbound"` typo silently emits a CNP whose ingress-rule list the
12235/// Cilium operator's per-CNP L4/L7-dispatch pass no-ops entirely: the
12236/// policy binds against the destination workload but admits no ingress
12237/// traffic, and every intra-mesh `:contratos` flow the CNP was authored
12238/// to allow drops at the eBPF data plane's default-deny gate with no
12239/// field naming the traffic-direction-axis-drift root cause).
12240///
12241/// The single source of truth the rendered Aplicacao Cilium-side mesh
12242/// bundle's per-CNP traffic-direction-axis-naming reaches for:
12243///
12244/// - the rendered `CiliumNetworkPolicy` document's `spec.ingress[]`
12245/// axis (caixa-mesh/src/lib.rs:1036 — the `cilium_network_policies`
12246/// per-`(:de, :para)` policy's `policy_spec.insert("ingress", …)`
12247/// call).
12248///
12249/// The traffic-direction axis names the same Cilium-operator-side per-
12250/// CNP inbound-traffic dispatch container as the sibling
12251/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] destination-identity axis and
12252/// [`CILIUM_KEY_TO_PORTS`] per-ingress-rule port-set container-axis and
12253/// must move together on any future Cilium CRD schema rebrand (an
12254/// upstream `cilium.io/v3` rename of the traffic-direction axis from
12255/// `ingress` to `inbound` / `ingressRules` / `incoming`, coordinated
12256/// with the Cilium project's periodic CRD schema-migration passes, or
12257/// the introduction of a sibling `egress` axis for outbound-traffic
12258/// dispatch under the same per-CNP-body schema). Until this lift landed
12259/// the axis carried an inline `ingress` literal at the one production-
12260/// code occurrence in caixa-mesh/src/lib.rs:1036 (the
12261/// `cilium_network_policies` `policy_spec.insert("ingress", …)` call)
12262/// plus a matching set inside the in-file
12263/// `cilium_http_contracts_emit_l7_rules` /
12264/// `cilium_policies_are_identity_based` /
12265/// `cnp_from_endpoints_carries_program_plus_aplicacao_labels_two_axis_shape`
12266/// / `cilium_multiple_edges_same_pair_fold_into_one_policy` /
12267/// `cilium_pubsub_contracts_skip_l7_rules` /
12268/// `render_multi_doc_contains_expected_kinds` /
12269/// `cnp_authentication_carries_mtls_overlay_at_ingress_rule_level` /
12270/// `cnp_l4_fallback_port_routes_through_lifted_default_servico_port`
12271/// test-fixture navigations — nine occurrences of the same load-bearing
12272/// Cilium-CRD-`ingress`-axis-key convention, drift-prone by
12273/// construction. A drift on any one production or test-fixture site
12274/// to `"Ingress"` / `"ingressRules"` / `"inbound"` would have surfaced
12275/// as a Cilium-operator-side schema validator drop at apply time (the
12276/// affected `spec` block's traffic-direction axis the CRD schema
12277/// validator recognizes as unknown), with every intra-mesh `:contratos`
12278/// flow the CNP was authored to allow dropping at the eBPF data plane's
12279/// default-deny gate with no field naming the traffic-direction-drift
12280/// root cause. A drift on the test-fixture side silently masks the
12281/// emission-side pin (`.get("ingress")` returns `None` under both the
12282/// drifted-key emitter and the drifted-key probe — the downstream
12283/// `.and_then(|i| i.as_sequence())` chain short-circuits vacuously
12284/// because the outer traffic-direction-lookup is itself `None`, and
12285/// every per-CNP downstream navigation — `fromEndpoints`, `toPorts`,
12286/// `authentication` — rides through the same short-circuited outer
12287/// axis-lookup with no field naming the drift root cause).
12288///
12289/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
12290/// "every recurring shape becomes a generator before it becomes a
12291/// pattern; every pattern becomes a library before it becomes
12292/// duplicated code. The duplication budget is zero.") promotes the
12293/// constant to a typed substrate-side `&'static str` on the same
12294/// trajectory the [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
12295/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
12296/// [`KUBE_KEY_RULES`] (a205eb3) /
12297/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
12298/// [`CILIUM_API_VERSION`] (279d611) lifts established on the sibling
12299/// canonical-Cilium-CNP-destination-identity /
12300/// canonical-Cilium-CNP-port-set-container /
12301/// canonical-K8s-CR-rule-list / canonical-Cilium-CRD-`kind` /
12302/// canonical-Cilium-CRD-`apiVersion` surfaces — completes the per-CNP
12303/// L3/L4/L7-triad lift set `(endpointSelector, ingress → toPorts →
12304/// rules)` the M3 Aplicacao mesh renderer's eBPF data-plane contract
12305/// rests on by lifting the traffic-direction axis that structurally
12306/// separates the destination-identity axis from the port-set-container
12307/// axis nested beneath it. The render-side consumer now threads the
12308/// same `&'static str` through its `policy_spec.insert(…)` call so a
12309/// future Cilium-CRD rebrand on the traffic-direction axis (or an
12310/// upstream Cilium project rename to a per-CRD sibling name — unlikely
12311/// on the CRD's stable `cilium.io/v2` slot, but the coordination point
12312/// the prior lifts anchor for) lands in one place; every future
12313/// renderer that reaches for the canonical per-CNP traffic-direction-
12314/// axis (the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
12315/// materializer's per-Aplicacao `CiliumNetworkPolicy` fan-out, a future
12316/// `CiliumClusterwideNetworkPolicy` renderer that emits cluster-scoped
12317/// baseline-allow rules with the same `spec.ingress[]` shape, a future
12318/// `CiliumLocalRedirectPolicy` renderer whose per-Servico local-
12319/// redirect ingress-rule list nests under the same traffic-direction
12320/// axis convention) inherits the same value by construction with no
12321/// opportunity for per-renderer drift.
12322///
12323/// Same "the typed constant lives in one place" discipline the
12324/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
12325/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
12326/// [`KUBE_KEY_RULES`] (a205eb3) /
12327/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
12328/// [`CILIUM_API_VERSION`] (279d611) lifts apply on the peer
12329/// canonical-Cilium-CNP-body-axis surface.
12330///
12331/// [cm]: ../../caixa_mesh/index.html
12332pub const CILIUM_KEY_INGRESS: &str = "ingress";
12333
12334/// Canonical Cilium `CiliumNetworkPolicy` per-ingress-rule identity-
12335/// source selector-list axis key every `cilium_network_policies`-emitted
12336/// CNP document mounts its permitted-source `LabelSelector` list under
12337/// (`spec.ingress[].fromEndpoints[]`). Pairs with the sibling
12338/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) — the Cilium CNP schema
12339/// pins the destination workload identity through the per-CNP-body
12340/// `endpointSelector` axis and the admitted source workload identities
12341/// through the per-ingress-rule `fromEndpoints[]` axis, so drift on the
12342/// identity-source axis is exactly as load-bearing as drift on the
12343/// destination-identity axis it accompanies (the Cilium-operator-side
12344/// CRD schema validator drops any per-ingress-rule block whose
12345/// identity-source axis carries an unrecognized key — a
12346/// `"fromendpoints"` / `"fromEndPoint"` / `"sourceEndpoints"` typo
12347/// silently emits a CNP whose per-`(:de, :para)` ingress-rule identity-
12348/// source list the Cilium operator's per-CNP identity-resolution pass
12349/// no-ops entirely: the ingress rule admits no source pods and every
12350/// intra-mesh `:contratos` flow the CNP was authored to allow drops at
12351/// the eBPF data plane's default-deny gate with no field naming the
12352/// identity-source-axis-drift root cause).
12353///
12354/// The single source of truth the rendered Aplicacao Cilium-side mesh
12355/// bundle's per-ingress-rule identity-source-axis-naming reaches for:
12356///
12357/// - the rendered `CiliumNetworkPolicy` document's per-ingress-rule
12358/// `fromEndpoints[]` axis (caixa-mesh/src/lib.rs:991 — the
12359/// `cilium_network_policies` per-`(:de, :para)` policy's
12360/// `ingress_rule.insert("fromEndpoints", …)` call).
12361///
12362/// The identity-source axis names the same Cilium-operator-side per-
12363/// ingress-rule source-workload selector list as the sibling
12364/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] destination-identity axis and must
12365/// move together on any future Cilium CRD schema rebrand (an upstream
12366/// `cilium.io/v3` rename of the identity-source axis from
12367/// `fromEndpoints` to `sourceEndpoints` / `fromWorkloads` /
12368/// `sourceSelectors`, coordinated with the Cilium project's periodic
12369/// CRD schema-migration passes). Until this lift landed the axis
12370/// carried an inline `fromEndpoints` literal at the one production-code
12371/// occurrence in caixa-mesh/src/lib.rs:991 (the `cilium_network_policies`
12372/// `ingress_rule.insert("fromEndpoints", …)` call) plus a matching set
12373/// inside the in-file
12374/// `cnp_from_endpoints_carries_program_plus_aplicacao_labels_two_axis_shape`
12375/// / `cilium_policies_are_identity_based`
12376/// / `cnp_authentication_carries_mtls_overlay_at_ingress_rule_level`
12377/// test-fixture navigations — five occurrences of the same load-bearing
12378/// Cilium-CRD-`fromEndpoints`-axis-key convention, drift-prone by
12379/// construction. A drift on any one production or test-fixture site
12380/// to `"fromendpoints"` / `"fromEndPoint"` / `"sourceEndpoints"` would
12381/// have surfaced as a Cilium-operator-side schema validator drop at
12382/// apply time (the affected per-ingress-rule block's identity-source
12383/// axis the CRD schema validator recognizes as unknown), with every
12384/// intra-mesh `:contratos` flow the CNP was authored to allow dropping
12385/// at the eBPF data plane's default-deny gate with no field naming the
12386/// identity-source-drift root cause. A drift on the test-fixture side
12387/// silently masks the emission-side pin
12388/// (`.get("fromEndpoints")` returns `None` under both the drifted-key
12389/// emitter and the drifted-key probe — the downstream `.and_then(|e|
12390/// e.as_sequence())` / `.and_then(|e| e.get(KUBE_KEY_MATCH_LABELS))`
12391/// chain short-circuits vacuously because the outer identity-source-
12392/// lookup is itself `None`).
12393///
12394/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
12395/// "every recurring shape becomes a generator before it becomes a
12396/// pattern; every pattern becomes a library before it becomes
12397/// duplicated code. The duplication budget is zero.") promotes the
12398/// constant to a typed substrate-side `&'static str` on the same
12399/// trajectory the [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
12400/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
12401/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
12402/// [`KUBE_KEY_RULES`] (a205eb3) /
12403/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
12404/// [`CILIUM_API_VERSION`] (279d611) lifts established on the sibling
12405/// canonical-Cilium-CNP-destination-identity /
12406/// canonical-Cilium-CNP-traffic-direction-container /
12407/// canonical-Cilium-CNP-port-set-container /
12408/// canonical-K8s-CR-rule-list / canonical-Cilium-CRD-`kind` /
12409/// canonical-Cilium-CRD-`apiVersion` surfaces — completes the per-CNP
12410/// identity-pair lift set `(endpointSelector, fromEndpoints)` the M3
12411/// Aplicacao mesh renderer's eBPF data-plane contract rests on by
12412/// lifting the identity-source axis structurally paired with the
12413/// destination-identity axis under the Cilium-operator-side per-CNP
12414/// SPIFFE-identity-bound access-control contract. The render-side
12415/// consumer now threads the same `&'static str` through its
12416/// `ingress_rule.insert(…)` call so a future Cilium-CRD rebrand on the
12417/// identity-source axis (or an upstream Cilium project rename to a
12418/// per-CRD sibling name — unlikely on the CRD's stable `cilium.io/v2`
12419/// slot, but the coordination point the prior lifts anchor for) lands
12420/// in one place; every future renderer that reaches for the canonical
12421/// per-ingress-rule identity-source-axis (the future M4
12422/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
12423/// `CiliumNetworkPolicy` fan-out, a future
12424/// `CiliumClusterwideNetworkPolicy` renderer that emits cluster-scoped
12425/// baseline-allow rules with the same `spec.ingress[].fromEndpoints[]`
12426/// shape, a future `CiliumLocalRedirectPolicy` renderer whose per-
12427/// Servico local-redirect source-workload selector list nests under
12428/// the same identity-source axis convention) inherits the same value
12429/// by construction with no opportunity for per-renderer drift.
12430///
12431/// Same "the typed constant lives in one place" discipline the
12432/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
12433/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
12434/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
12435/// [`KUBE_KEY_RULES`] (a205eb3) /
12436/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
12437/// [`CILIUM_API_VERSION`] (279d611) lifts apply on the peer
12438/// canonical-Cilium-CNP-body-axis surface.
12439///
12440/// [cm]: ../../caixa_mesh/index.html
12441pub const CILIUM_KEY_FROM_ENDPOINTS: &str = "fromEndpoints";
12442
12443/// Canonical Cilium `CiliumNetworkPolicy` per-`toPorts[]`-entry L4
12444/// port-tuple-list-container axis key every `cilium_network_policies`-
12445/// emitted CNP document mounts its per-port-set `[{port, protocol}]` list
12446/// under (`spec.ingress[].toPorts[].ports[]`). Nests inside the sibling
12447/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) — the Cilium CNP schema pins the
12448/// per-ingress-rule port-set-container axis through the `toPorts[]` list
12449/// and the per-port-set L4 port-tuple list through the `ports[]` axis
12450/// beneath each entry, so drift on the L4 port-tuple-list-container axis
12451/// is exactly as load-bearing as drift on the port-set container axis it
12452/// nests inside (the Cilium-operator-side CRD schema validator drops any
12453/// per-`toPorts[]` entry whose port-tuple-list-container axis carries an
12454/// unrecognized key — a `"port"` / `"portList"` / `"L4Ports"` typo
12455/// silently emits a CNP whose per-`(:de, :para)` per-port-set L4
12456/// port-tuple list the Cilium operator's per-CNP L4-allow eBPF-program
12457/// generation pass no-ops entirely: the port-set admits no `(port,
12458/// protocol)` tuple and every intra-mesh `:contratos` flow the CNP was
12459/// authored to allow drops at the eBPF data plane's default-deny gate
12460/// with no field naming the L4-port-tuple-list-container-axis-drift root
12461/// cause).
12462///
12463/// The single source of truth the rendered Aplicacao Cilium-side mesh
12464/// bundle's per-`toPorts[]`-entry L4-port-tuple-list-container-axis-
12465/// naming reaches for:
12466///
12467/// - the rendered `CiliumNetworkPolicy` document's per-`toPorts[]`-
12468/// entry `ports[]` axis (caixa-mesh/src/lib.rs:1081 — the
12469/// `cilium_network_policies` per-`(:de, :para)` policy's
12470/// `to_port.insert("ports", …)` call).
12471///
12472/// The L4 port-tuple-list-container axis names the same Cilium-operator-
12473/// side per-port-set L4-allow eBPF-program-generation source-list as the
12474/// sibling [`CILIUM_KEY_TO_PORTS`] port-set container axis it nests
12475/// inside and must move together on any future Cilium CRD schema rebrand
12476/// (an upstream `cilium.io/v3` rename of the L4 port-tuple-list axis
12477/// from `ports` to `portList` / `l4Ports` / `tuples`, coordinated with
12478/// the Cilium project's periodic CRD schema-migration passes). Until this
12479/// lift landed the axis carried an inline `ports` literal at the one
12480/// production-code occurrence in caixa-mesh/src/lib.rs:1081 (the
12481/// `cilium_network_policies` `to_port.insert("ports", …)` call) plus a
12482/// matching set inside the in-file
12483/// `cilium_pubsub_contracts_skip_l7_rules`
12484/// / `cnp_l4_fallback_port_reflects_default_servico_port`
12485/// test-fixture navigations — three occurrences of the same load-bearing
12486/// Cilium-CRD-`ports`-axis-key convention, drift-prone by construction. A
12487/// drift on any one production or test-fixture site to `"port"` /
12488/// `"portList"` / `"L4Ports"` would have surfaced as a Cilium-operator-
12489/// side schema validator drop at apply time (the affected per-`toPorts[]`
12490/// entry's port-tuple-list-container axis the CRD schema validator
12491/// recognizes as unknown), with every intra-mesh `:contratos` flow the
12492/// CNP was authored to allow dropping at the eBPF data plane's default-
12493/// deny gate with no field naming the L4-port-tuple-list-container-drift
12494/// root cause. A drift on the test-fixture side silently masks the
12495/// emission-side pin (`.get("ports")` returns `None` under both the
12496/// drifted-key emitter and the drifted-key probe — the downstream
12497/// `.and_then(|p| p.as_sequence())` / `.and_then(|s| s.first())` /
12498/// `.and_then(|p| p.get("port"))` chain short-circuits vacuously because
12499/// the outer L4-port-tuple-list-container lookup is itself `None`).
12500///
12501/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
12502/// "every recurring shape becomes a generator before it becomes a
12503/// pattern; every pattern becomes a library before it becomes
12504/// duplicated code. The duplication budget is zero.") promotes the
12505/// constant to a typed substrate-side `&'static str` on the same
12506/// trajectory the [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
12507/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
12508/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
12509/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
12510/// [`KUBE_KEY_RULES`] (a205eb3) /
12511/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
12512/// [`CILIUM_API_VERSION`] (279d611) lifts established on the sibling
12513/// canonical-Cilium-CNP-identity-source /
12514/// canonical-Cilium-CNP-destination-identity /
12515/// canonical-Cilium-CNP-traffic-direction-container /
12516/// canonical-Cilium-CNP-port-set-container /
12517/// canonical-K8s-CR-rule-list / canonical-Cilium-CRD-`kind` /
12518/// canonical-Cilium-CRD-`apiVersion` surfaces — nests the per-port-set
12519/// L4 port-tuple-list-container axis structurally beneath the sibling
12520/// [`CILIUM_KEY_TO_PORTS`] port-set-container axis, extending the per-CNP
12521/// L3/L4/L7-triad `(endpointSelector, ingress → toPorts → ports / rules)`
12522/// lift set with the L4-half's port-tuple-list-container axis the M3
12523/// Aplicacao mesh renderer's eBPF data-plane L4-allow contract rests on.
12524/// The render-side consumer now threads the same `&'static str` through
12525/// its `to_port.insert(…)` call so a future Cilium-CRD rebrand on the
12526/// L4 port-tuple-list-container axis (or an upstream Cilium project
12527/// rename to a per-CRD sibling name — unlikely on the CRD's stable
12528/// `cilium.io/v2` slot, but the coordination point the prior lifts
12529/// anchor for) lands in one place; every future renderer that reaches
12530/// for the canonical per-`toPorts[]`-entry L4-port-tuple-list-container
12531/// axis (the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
12532/// materializer's per-Aplicacao `CiliumNetworkPolicy` fan-out, a future
12533/// `CiliumClusterwideNetworkPolicy` renderer that emits cluster-scoped
12534/// baseline-allow rules with the same
12535/// `spec.ingress[].toPorts[].ports[]` shape, a future
12536/// `CiliumLocalRedirectPolicy` renderer whose per-Servico local-redirect
12537/// L4 port-tuple list nests under the same L4-port-tuple-list-container
12538/// axis convention) inherits the same value by construction with no
12539/// opportunity for per-renderer drift.
12540///
12541/// Same "the typed constant lives in one place" discipline the
12542/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
12543/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
12544/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
12545/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
12546/// [`KUBE_KEY_RULES`] (a205eb3) /
12547/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
12548/// [`CILIUM_API_VERSION`] (279d611) lifts apply on the peer
12549/// canonical-Cilium-CNP-body-axis surface.
12550///
12551/// [cm]: ../../caixa_mesh/index.html
12552pub const CILIUM_KEY_PORTS: &str = "ports";
12553
12554/// Canonical Cilium `CiliumNetworkPolicy` per-ingress-rule mutual-auth
12555/// policy body-axis key every `cilium_network_policies`-emitted CNP
12556/// document mounts its per-rule mTLS enforcement block under
12557/// (`spec.ingress[].authentication`). Sibling to
12558/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) +
12559/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) at the per-ingress-rule body
12560/// level — the Cilium CNP schema places the per-rule mutual-auth mode
12561/// (`{mode: required | disabled}`) at the ingress-rule axis alongside
12562/// the identity-source (`fromEndpoints`) and port-set (`toPorts`)
12563/// axes, so drift on the authentication axis is exactly as
12564/// load-bearing as drift on the sibling per-ingress-rule-body axes it
12565/// pairs with (the Cilium-operator-side CRD schema validator drops
12566/// any per-`ingress[]` entry whose mutual-auth axis carries an
12567/// unrecognized key — a `"auth"` / `"mutualAuth"` / `"mtls"` typo
12568/// silently emits a CNP whose per-`(:de, :para)` per-rule mTLS block
12569/// the Cilium operator's per-CNP mutual-auth SPIFFE-handshake
12570/// pipeline no-ops entirely: the ingress rule falls back to the
12571/// cluster-default authentication mode (typically `"disabled"` — no
12572/// mutual-auth enforcement), and every intra-mesh `:contratos` flow
12573/// the CNP was authored to protect with per-edge mTLS silently
12574/// bypasses the SPIFFE-identity-bound mutual-auth handshake with no
12575/// field naming the mutual-auth-axis-drift root cause).
12576///
12577/// The single source of truth the rendered Aplicacao Cilium-side
12578/// mesh bundle's per-ingress-rule mutual-auth-axis naming reaches for:
12579///
12580/// - the rendered `CiliumNetworkPolicy` document's per-`ingress[]`
12581/// entry `authentication` axis (caixa-mesh/src/lib.rs — the
12582/// `cilium_network_policies` per-`(:de, :para)` policy's
12583/// `ingress_rule.insert("authentication", …)` call in the
12584/// `:politicas :mtls-required` overlay emit gate).
12585///
12586/// The mutual-auth axis names the same Cilium-operator-side per-rule
12587/// SPIFFE-identity-handshake enforcement policy as the sibling per-
12588/// ingress-rule identity-source (`fromEndpoints`) and port-set
12589/// (`toPorts`) axes it pairs with, and must move together on any
12590/// future Cilium CRD schema rebrand (an upstream `cilium.io/v3`
12591/// rename of the mutual-auth axis from `authentication` to
12592/// `mutualAuth` / `mtls` / `authPolicy`, coordinated with the Cilium
12593/// project's periodic CRD schema-migration passes). Until this lift
12594/// landed the axis carried an inline `authentication` literal at the
12595/// one production-code emitter site (the `cilium_network_policies`
12596/// per-rule `ingress_rule.insert("authentication", …)` call in the
12597/// `:mtls-required` overlay emit gate) plus a matching set inside
12598/// the in-file `cnp_authentication_renders_every_policy_independently`
12599/// / `cnp_authentication_position_is_rule_level_not_nested` /
12600/// `cnp_authentication_pubsub_contracts_carry_overlay_too` /
12601/// `cnp_authentication_mode_is_a_yaml_string_scalar` /
12602/// `cnp_omits_authentication_when_mtls_required_unset` /
12603/// `cnp_explicit_mtls_required_false_emits_disabled_mode` /
12604/// `cnp_authentication_overlay_when_mtls_required_set` (name approximate)
12605/// test-fixture navigations — ten occurrences of the same
12606/// load-bearing Cilium-CRD-mutual-auth-axis-key convention, drift-
12607/// prone by construction. A drift on any one production or test-
12608/// fixture site to `"auth"` / `"mutualAuth"` / `"mtls"` would surface
12609/// as a Cilium-operator-side schema-validator drop at apply time
12610/// (the affected per-`ingress[]` entry's mutual-auth-axis key the
12611/// CRD schema validator recognizes as unknown), with every intra-
12612/// mesh `:contratos` flow the CNP was authored to protect with per-
12613/// edge SPIFFE-identity-bound mutual-auth silently bypassing the
12614/// mTLS handshake at the Cilium data-plane's default-authentication
12615/// mode with no field naming the mutual-auth-axis-drift root cause.
12616/// A drift on the test-fixture side silently masks the emission-
12617/// side pin (`.get("authentication")` returns `None` under both the
12618/// drifted-key emitter and the drifted-key probe — every downstream
12619/// `.and_then(|a| a.get("mode"))` chain short-circuits vacuously
12620/// because the outer mutual-auth-body-lookup is itself `None`).
12621///
12622/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
12623/// "every recurring shape becomes a generator before it becomes a
12624/// pattern; every pattern becomes a library before it becomes
12625/// duplicated code. The duplication budget is zero.") promotes the
12626/// constant to a typed substrate-side `&'static str` on the same
12627/// trajectory the [`CILIUM_KEY_PORTS`] (1087693) /
12628/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
12629/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
12630/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
12631/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
12632/// [`KUBE_KEY_RULES`] (a205eb3) /
12633/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
12634/// [`CILIUM_API_VERSION`] (279d611) lifts established on the
12635/// sibling canonical-Cilium-CNP-body-axis surfaces — nests the
12636/// per-ingress-rule mutual-auth axis structurally beside the sibling
12637/// [`CILIUM_KEY_FROM_ENDPOINTS`] identity-source and
12638/// [`CILIUM_KEY_TO_PORTS`] port-set-container axes at the per-rule
12639/// body triple `(fromEndpoints, toPorts, authentication)` the M3
12640/// Aplicacao mesh renderer's SPIFFE-identity-bound per-edge mTLS
12641/// contract rests on.
12642///
12643/// [cm]: ../../caixa_mesh/index.html
12644pub const CILIUM_KEY_AUTHENTICATION: &str = "authentication";
12645
12646/// Canonical Cilium `CiliumNetworkPolicy` per-`ingress[].authentication`
12647/// block mTLS-mode-discriminator leaf-scalar-axis key every
12648/// `cilium_network_policies`-emitted CNP document mounts its per-rule
12649/// mutual-auth mode leaf under (`spec.ingress[].authentication.mode`).
12650/// Nests exactly one level beneath the sibling
12651/// [`CILIUM_KEY_AUTHENTICATION`] (db31108) per-ingress-rule mutual-auth
12652/// body-axis it sits inside: the Cilium CNP schema places the mTLS
12653/// enforcement mode discriminator (`"required"` / `"disabled"`) as the
12654/// single leaf-scalar axis of the per-rule authentication block, so
12655/// drift on the mode-discriminator leaf axis is exactly as load-bearing
12656/// as drift on the sibling per-ingress-rule mutual-auth body-axis key
12657/// (`authentication`) it nests inside (the Cilium-operator-side CNP
12658/// schema validator drops any per-`ingress[]` entry whose per-rule
12659/// mutual-auth block carries an unrecognized leaf axis — a `"policy"` /
12660/// `"authMode"` / `"handshakeMode"` typo at either the emit-side single-
12661/// field-overlay call site or a downstream renderer's per-rule authn
12662/// leaf upsert silently emits a per-`ingress[]` mutual-auth block whose
12663/// mode-discriminator leaf the Cilium CRD schema validator rejects as
12664/// unknown; the ingress rule falls back to the cluster-default
12665/// authentication mode (typically `"disabled"` — no mutual-auth
12666/// enforcement) silently bypassing the SPIFFE-identity-bound mTLS
12667/// handshake every intra-mesh `:contratos` flow the CNP was authored to
12668/// protect with per-edge mTLS, and the emit-side/probe-side split
12669/// silently masks the per-rule mutual-auth pin (`.get("mode")` returns
12670/// `None` under both the drifted-key emitter and the drifted-key probe
12671/// — every downstream `.and_then(|v| v.as_str())` chain short-circuits
12672/// vacuously because the outer mode-leaf-lookup is itself `None`).
12673///
12674/// The single source of truth the rendered Aplicacao Cilium-side mesh
12675/// bundle's per-ingress-rule mutual-auth-mode-leaf-axis naming reaches
12676/// for:
12677///
12678/// - the rendered `CiliumNetworkPolicy` document's per-`ingress[]`
12679/// entry `authentication.mode` leaf axis (caixa-mesh/src/lib.rs —
12680/// the `cilium_network_policies` per-`(:de, :para)` policy's
12681/// `single_field_overlay(spec.politicas.mtls_required, "mode", …)`
12682/// call site in the `:politicas :mtls-required` overlay emit gate,
12683/// the exact field the `single_field_overlay` helper writes the
12684/// single leaf under when the tristate `:mtls-required` slot is
12685/// set).
12686///
12687/// The mode-discriminator leaf-axis names the same Cilium-operator-side
12688/// per-rule SPIFFE-identity-handshake enforcement policy as the sibling
12689/// per-ingress-rule mutual-auth-body-axis key (`authentication`) it nests
12690/// inside, and must move together on any future Cilium CRD schema
12691/// rebrand (an upstream `cilium.io/v3` rename of the mutual-auth mode-
12692/// discriminator leaf from `mode` to `policy` / `authMode` /
12693/// `handshakeMode`, coordinated with the Cilium project's periodic CRD
12694/// schema-migration passes). Until this lift landed the axis carried an
12695/// inline `mode` literal at the one production-code emitter site (the
12696/// `cilium_network_policies` per-rule `single_field_overlay(...,
12697/// "mode", ...)` call in the `:mtls-required` overlay emit gate) plus a
12698/// matching set inside the in-file `cnp_carries_politicas_mtls_required_
12699/// on_every_rule` / `cnp_explicit_mtls_required_false_emits_disabled_
12700/// mode` / `cnp_authentication_renders_every_policy_independently` /
12701/// `cnp_authentication_pubsub_contracts_carry_overlay_too` /
12702/// `cnp_authentication_mode_is_a_yaml_string_scalar` test-fixture
12703/// navigations — six occurrences of the same load-bearing Cilium-CRD-
12704/// mutual-auth-mode-discriminator-leaf-axis-key convention, drift-prone
12705/// by construction. A drift on any one production or test-fixture site
12706/// to `"policy"` / `"authMode"` / `"handshakeMode"` would surface as a
12707/// Cilium-operator-side schema-validator drop at apply time (the
12708/// affected per-`ingress[]` entry's per-rule mutual-auth-mode-
12709/// discriminator-leaf-axis key the CRD schema validator recognizes as
12710/// unknown), with every intra-mesh `:contratos` flow the CNP was
12711/// authored to protect with per-edge SPIFFE-identity-bound mutual-auth
12712/// silently bypassing the mTLS handshake at the Cilium data-plane's
12713/// default-authentication mode with no field naming the mutual-auth-
12714/// mode-discriminator-leaf-axis-drift root cause.
12715///
12716/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
12717/// "every recurring shape becomes a generator before it becomes a
12718/// pattern; every pattern becomes a library before it becomes
12719/// duplicated code. The duplication budget is zero.") promotes the
12720/// constant to a typed substrate-side `&'static str` on the same
12721/// trajectory the [`CILIUM_KEY_AUTHENTICATION`] (db31108) /
12722/// [`CILIUM_KEY_PORTS`] (1087693) /
12723/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
12724/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
12725/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
12726/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
12727/// [`KUBE_KEY_RULES`] (a205eb3) /
12728/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
12729/// [`CILIUM_API_VERSION`] (279d611) lifts established on the
12730/// sibling canonical-Cilium-CNP-body-axis surfaces — descends the
12731/// per-ingress-rule mutual-auth mode-discriminator leaf axis one level
12732/// beneath the parent [`CILIUM_KEY_AUTHENTICATION`] body-axis key it
12733/// pairs with, completing the per-rule mutual-auth
12734/// `(authentication → mode)` body/leaf axis pair the M3 Aplicacao mesh
12735/// renderer's SPIFFE-identity-bound per-edge mTLS enforcement contract
12736/// rests on.
12737///
12738/// [cm]: ../../caixa_mesh/index.html
12739pub const CILIUM_KEY_MODE: &str = "mode";
12740
12741/// Canonical Cilium `CiliumNetworkPolicy` per-`ingress[].toPorts[].rules`
12742/// L7-HTTP-rule-list-discriminator container-axis key every
12743/// `cilium_network_policies`-emitted CNP document mounts its per-`toPorts[]`
12744/// entry L7 HTTP-rule list under (`spec.ingress[].toPorts[].rules.http`).
12745/// Nests exactly one level beneath the sibling [`KUBE_KEY_RULES`] (a205eb3)
12746/// per-`toPorts[]` rule-list-container axis it sits inside: the Cilium CNP
12747/// schema places the L7-protocol-selection discriminator (`http` / future
12748/// `kafka` / future `dns`) as the single per-protocol keyed axis of the
12749/// per-`toPorts[]` rules block, so drift on the L7-HTTP-rule-list-
12750/// discriminator axis is exactly as load-bearing as drift on the sibling
12751/// [`KUBE_KEY_RULES`] per-`toPorts[]` rule-list-container axis-key it nests
12752/// inside (the Cilium-operator-side CNP schema validator drops any per-
12753/// `toPorts[]` entry whose per-protocol L7-rule-list-discriminator key it
12754/// recognizes as unknown — a `"HTTP"` / `"Http"` / `"http/1.1"` /
12755/// `"httpRules"` typo at either the emit-side `rules.insert(…)` call site
12756/// or a downstream renderer's per-`toPorts[]` L7-rule-list upsert silently
12757/// emits a per-`toPorts[]` entry whose L7-HTTP-rule-list-discriminator key
12758/// the Cilium CRD schema validator rejects as unknown; the per-`toPorts[]`
12759/// entry falls back to L4-only enforcement — no L7 URL-path predicate is
12760/// applied — silently admitting every HTTP-method / URL-path combination
12761/// the ingress rule was authored to filter to the exact path prefix set
12762/// the typed `:contratos` graph names at the L7 introspection axis, and
12763/// the emit-side/probe-side split silently masks the per-`toPorts[]` L7-
12764/// rule-list pin (`.get("http")` returns `None` under both the drifted-
12765/// key emitter and the drifted-key probe — every downstream
12766/// `.and_then(|h| h.as_sequence())` chain short-circuits vacuously because
12767/// the outer L7-HTTP-rule-list-lookup is itself `None`).
12768///
12769/// The single source of truth the rendered Aplicacao Cilium-CNP-side
12770/// intra-mesh L7-tuple-gating bundle's per-`toPorts[]` L7-HTTP-rule-list-
12771/// discriminator-axis naming reaches for:
12772///
12773/// - the rendered `CiliumNetworkPolicy` document's per-`toPorts[]` entry
12774/// `rules.http` L7-HTTP-rule-list-discriminator axis (caixa-mesh/src/lib.rs —
12775/// the `cilium_network_policies` per-`(:de, :para)` policy's
12776/// `rules.insert("http", …)` call in the `WitTarget::Http` L7-
12777/// introspection emit branch, the exact per-protocol keyed axis of
12778/// the per-`toPorts[]` rules block the L7 URL-path predicate lands
12779/// under).
12780///
12781/// The L7-HTTP-rule-list-discriminator axis names the same Cilium-operator-
12782/// side per-`toPorts[]` L7 URL-path predicate selection as the sibling
12783/// [`KUBE_KEY_RULES`] per-`toPorts[]` rule-list-container axis-key it nests
12784/// inside, and must move together on any future Cilium CRD schema rebrand
12785/// (an upstream `cilium.io/v3` rename of the L7-HTTP-rule-list-
12786/// discriminator from `http` to `httpRules` / `l7Http` / `httpMatch`,
12787/// coordinated with the Cilium project's periodic CRD schema-migration
12788/// passes). Until this lift landed the axis carried an inline `http`
12789/// literal at the one production-code emitter site (the
12790/// `cilium_network_policies` per-`(:de, :para)` `rules.insert("http", …)`
12791/// call in the `WitTarget::Http` L7 introspection emit branch) plus a
12792/// matching set inside the in-file `cilium_l7_rules_fan_in_captures_every_
12793/// http_edge` / `cilium_http_contracts_carry_l7_path` test-fixture
12794/// navigations — three occurrences of the same load-bearing Cilium-CRD-
12795/// L7-HTTP-rule-list-discriminator convention, drift-prone by
12796/// construction. A drift on any one production or test-fixture site to
12797/// `"HTTP"` / `"Http"` / `"httpRules"` would surface as a Cilium-operator-
12798/// side schema-validator drop at apply time (the affected per-
12799/// `toPorts[]` entry's L7-rule-list-discriminator key the CRD schema
12800/// validator recognizes as unknown), with every intra-mesh HTTP-shaped
12801/// `:contratos` flow the CNP was authored to filter to a URL-path prefix
12802/// silently bypassing the L7 path predicate at the Cilium data-plane's
12803/// L4-only fallback dispatch with no field naming the L7-HTTP-rule-list-
12804/// discriminator-drift root cause.
12805///
12806/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
12807/// "every recurring shape becomes a generator before it becomes a
12808/// pattern; every pattern becomes a library before it becomes
12809/// duplicated code. The duplication budget is zero.") promotes the
12810/// constant to a typed substrate-side `&'static str` on the same
12811/// trajectory the [`CILIUM_KEY_MODE`] (4289dfb) /
12812/// [`CILIUM_KEY_AUTHENTICATION`] (db31108) /
12813/// [`CILIUM_KEY_PORTS`] (1087693) /
12814/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
12815/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
12816/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
12817/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
12818/// [`KUBE_KEY_RULES`] (a205eb3) /
12819/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
12820/// [`CILIUM_API_VERSION`] (279d611) lifts established on the
12821/// sibling canonical-Cilium-CNP-body-axis surfaces — descends the per-
12822/// `toPorts[]` L7-HTTP-rule-list-discriminator axis one level beneath the
12823/// parent [`KUBE_KEY_RULES`] per-`toPorts[]` rule-list-container axis-key
12824/// it nests inside, completing the per-`toPorts[]` L7-introspection
12825/// `(rules → http)` container/protocol-discriminator axis pair the M3
12826/// Aplicacao mesh renderer's HTTP-shaped-`:contratos` URL-path-prefix-
12827/// filtering L7-enforcement contract rests on.
12828///
12829/// [cm]: ../../caixa_mesh/index.html
12830pub const CILIUM_KEY_HTTP: &str = "http";
12831
12832/// Canonical Cilium `CiliumNetworkPolicy` per-`ingress[].toPorts[].rules.http[]`
12833/// per-HTTP-rule URL-path-predicate leaf-scalar-axis key every
12834/// `cilium_network_policies`-emitted CNP document mounts its per-HTTP-rule
12835/// URL-path-prefix predicate scalar under
12836/// (`spec.ingress[].toPorts[].rules.http[].path`). Nests exactly one level
12837/// beneath the sibling [`CILIUM_KEY_HTTP`] (ccd81e8) per-`toPorts[]`
12838/// L7-HTTP-rule-list-discriminator container-axis it sits inside: the Cilium
12839/// CNP schema places the per-HTTP-rule URL-path predicate scalar (the exact
12840/// URL-path regex the Cilium L7 dispatch pass matches the observed HTTP
12841/// request line's path segment against) as the single load-bearing leaf-
12842/// scalar axis of the per-`rules.http[]` entry — so drift on the per-HTTP-
12843/// rule URL-path-predicate leaf axis is exactly as load-bearing as drift on
12844/// the sibling [`CILIUM_KEY_HTTP`] per-`toPorts[]` L7-HTTP-rule-list-
12845/// discriminator container-axis key it nests inside (the Cilium-operator-
12846/// side CNP schema validator drops any per-`rules.http[]` entry whose per-
12847/// HTTP-rule URL-path-predicate leaf key it recognizes as unknown — a
12848/// `"Path"` / `"pathPrefix"` / `"regex"` / `"urlPath"` / `"pathMatch"` typo
12849/// at either the emit-side `http_rule.insert(…)` call site or a downstream
12850/// renderer's per-`rules.http[]` URL-path leaf upsert silently emits a per-
12851/// `rules.http[]` entry whose URL-path-predicate leaf-axis key the Cilium
12852/// CRD schema validator rejects as unknown; the per-`rules.http[]` entry
12853/// falls back to a match-any-URL-path predicate — the per-`toPorts[]` L7
12854/// rule admits every URL path on the destination port silently, bypassing
12855/// the URL-path-prefix predicate the typed `:contratos` HTTP-shaped edge's
12856/// `:endpoint` slot names at the L7 introspection axis, and the emit-
12857/// side/probe-side split silently masks the per-`rules.http[]` URL-path
12858/// pin (`.get("path")` returns `None` under both the drifted-key emitter
12859/// and the drifted-key probe — every downstream `.and_then(|v| v.as_str())`
12860/// chain short-circuits vacuously because the outer per-HTTP-rule URL-
12861/// path-lookup is itself `None`).
12862///
12863/// The single source of truth the rendered Aplicacao Cilium-CNP-side
12864/// intra-mesh per-`toPorts[]` L7-URL-path-predicate-gating bundle's per-
12865/// `rules.http[]` URL-path-predicate-leaf-axis naming reaches for:
12866///
12867/// - the rendered `CiliumNetworkPolicy` document's per-`toPorts[]`
12868/// `rules.http[]` entry's `path` URL-path-predicate leaf axis
12869/// (caixa-mesh/src/lib.rs — the `cilium_network_policies` per-`(:de,
12870/// :para)` policy's `http_rule.insert("path", …)` call in the
12871/// `WitTarget::Http` L7 introspection emit branch, the exact per-
12872/// `rules.http[]` leaf axis the per-HTTP-rule URL-path predicate scalar
12873/// lands under, seeded from the typed HTTP-shaped `:contratos` edge's
12874/// `:endpoint` slot).
12875///
12876/// The per-HTTP-rule URL-path-predicate-leaf-axis names the same Cilium-
12877/// operator-side per-`rules.http[]` URL-path predicate selection as the
12878/// sibling [`CILIUM_KEY_HTTP`] per-`toPorts[]` L7-HTTP-rule-list-
12879/// discriminator container-axis key it nests inside, and must move together
12880/// on any future Cilium CRD schema rebrand (an upstream `cilium.io/v3`
12881/// rename of the per-HTTP-rule URL-path-predicate leaf from `path` to
12882/// `urlPath` / `pathPrefix` / `pathMatch`, coordinated with the Cilium
12883/// project's periodic CRD schema-migration passes). Until this lift landed
12884/// the axis carried an inline `path` literal at the one production-code
12885/// emitter site (the `cilium_network_policies` per-`(:de, :para)`
12886/// `http_rule.insert("path", …)` call in the `WitTarget::Http` L7
12887/// introspection emit branch) plus a matching set inside the in-file
12888/// `cilium_http_contracts_emit_l7_rules` test-fixture per-HTTP-rule URL-
12889/// path-predicate presence-and-value pin — two occurrences of the same
12890/// load-bearing Cilium-CRD per-HTTP-rule URL-path-predicate-leaf-axis
12891/// convention, drift-prone by construction. A drift on any one production
12892/// or test-fixture site to `"Path"` / `"pathPrefix"` / `"regex"` /
12893/// `"urlPath"` / `"pathMatch"` would surface as a Cilium-operator-side
12894/// schema-validator drop at apply time (the affected per-`rules.http[]`
12895/// entry's URL-path-predicate leaf-axis key the CRD schema validator
12896/// recognizes as unknown), with every intra-mesh HTTP-shaped `:contratos`
12897/// flow the CNP was authored to filter to a URL-path prefix silently
12898/// bypassing the L7 URL-path predicate at the Cilium data-plane's match-
12899/// any-URL-path fallback with no field naming the URL-path-predicate-
12900/// leaf-axis-drift root cause.
12901///
12902/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
12903/// "every recurring shape becomes a generator before it becomes a
12904/// pattern; every pattern becomes a library before it becomes
12905/// duplicated code. The duplication budget is zero.") promotes the
12906/// constant to a typed substrate-side `&'static str` on the same
12907/// trajectory the [`CILIUM_KEY_HTTP`] (ccd81e8) /
12908/// [`CILIUM_KEY_MODE`] (4289dfb) /
12909/// [`CILIUM_KEY_AUTHENTICATION`] (db31108) /
12910/// [`CILIUM_KEY_PORTS`] (1087693) /
12911/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
12912/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
12913/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
12914/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
12915/// [`KUBE_KEY_RULES`] (a205eb3) /
12916/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
12917/// [`CILIUM_API_VERSION`] (279d611) lifts established on the
12918/// sibling canonical-Cilium-CNP-body-axis surfaces — descends the per-
12919/// `toPorts[]` L7-introspection `(rules → http → path)` container /
12920/// protocol-discriminator / URL-path-predicate axis chain one leaf level
12921/// beneath the parent [`CILIUM_KEY_HTTP`] per-`toPorts[]` L7-HTTP-rule-
12922/// list-discriminator axis-key it nests inside, completing the per-
12923/// `toPorts[]` L7-introspection `(rules → http → path)` container /
12924/// protocol-discriminator / URL-path-predicate axis triple the M3
12925/// Aplicacao mesh renderer's HTTP-shaped-`:contratos` URL-path-prefix-
12926/// filtering L7-enforcement contract rests on.
12927///
12928/// Distinct from the sibling K8s-Gateway-API-side
12929/// [`GATEWAY_API_KEY_PATH`] (9f45aa4) per-`HTTPRouteMatch` path-matcher
12930/// container-axis key: both keys spell the same underlying `"path"`
12931/// string but name distinct schema axes on distinct CRD groups — the
12932/// Cilium-side axis is a per-HTTP-rule URL-path predicate leaf scalar
12933/// on the Cilium `cilium.io/v2` `CiliumNetworkPolicy` CRD's per-
12934/// `toPorts[].rules.http[]` entry, the Gateway-API-side axis is a per-
12935/// `HTTPRouteMatch` path-matcher two-leaf container (`{type, value}`)
12936/// on the K8s Gateway API v1 `HTTPRoute` CRD's `spec.rules[].matches[]`
12937/// entry. Keeping them as sibling `pub const` declarations (rather than
12938/// coalescing onto a single shared constant that happens to carry the
12939/// same string) mirrors the deliberate axis-independence discipline the
12940/// [`CILIUM_KIND_NETWORK_POLICY`] / [`GATEWAY_API_KIND_GATEWAY`] /
12941/// [`GATEWAY_API_KIND_HTTP_ROUTE`] kind-discriminator lifts already
12942/// codified on the sibling per-CRD-kind axes, so a future Cilium-side
12943/// per-HTTP-rule URL-path-predicate rebrand (Cilium `cilium.io/v3` renames
12944/// `path` → `urlPath`) can land independently of the Gateway-API-side
12945/// per-`HTTPRouteMatch` path-matcher container-axis rebrand without any
12946/// cross-CRD coordination footgun where a shared constant would force a
12947/// coupled edit against schema evolutions the two CRD projects run on
12948/// independent cadences. Note: Rust's `&'static str` interner coalesces
12949/// identical byte-sequences onto one storage allocation at codegen time,
12950/// so at runtime a `.as_ptr()` comparison between the two constants can't
12951/// distinguish "sibling `pub const` declarations carrying identical
12952/// bytes" from "coalesced canonical declaration" — the axis-independence
12953/// discipline lives at the rustc symbol-name axis (the two `pub const
12954/// CILIUM_KEY_PATH` / `pub const GATEWAY_API_KEY_PATH` symbols a future
12955/// rebrand of one leaves the other structurally untouched under) rather
12956/// than the runtime-address axis, and the per-axis re-export identity
12957/// pins in the consuming renderer crates (each pinning the local re-
12958/// export against its own canonical declaration on its own axis) remain
12959/// the load-bearing "no sibling local `pub const` drift" gate for the
12960/// pair.
12961///
12962/// [cm]: ../../caixa_mesh/index.html
12963pub const CILIUM_KEY_PATH: &str = "path";
12964
12965/// Canonical K8s Gateway API CRD `kind` discriminator the rendered
12966/// `Gateway` document declares at its top-level [`KUBE_KEY_KIND`] axis.
12967/// Pairs with the sibling [`GATEWAY_API_API_VERSION`] (3c6cfc3) — the
12968/// K8s apiserver-side CRD resolution contract is the
12969/// `(apiVersion, kind)` tuple keyed against the registered
12970/// `CustomResourceDefinition`, so drift on the kind axis is exactly as
12971/// load-bearing as drift on the apiVersion axis it accompanies (the
12972/// apiserver's `RESTMapper` consults both together; a
12973/// `("gateway.networking.k8s.io/v1", "Gatway")` typo at the production-
12974/// code call site lands outside the registered Gateway-API-conformant
12975/// `Gateway` CRD's `RESTKind` lookup, surfacing apply-side as a
12976/// non-self-locating "no kind 'Gatway' is registered for version
12977/// 'gateway.networking.k8s.io/v1'" error far from the source caixa.lisp
12978/// / the renderer's [`kube_resource_skeleton`] call site).
12979///
12980/// The single source of truth the rendered Aplicacao Gateway-API-side
12981/// ingress bundle's `Gateway`-naming axis reaches for:
12982///
12983/// - the rendered `Gateway` document's top-level [`KUBE_KEY_KIND`]
12984/// axis (caixa-mesh/src/lib.rs:578 — the `gateway_routes` per-
12985/// Aplicacao `Gateway` [`kube_resource_skeleton`] kind argument).
12986///
12987/// The kind axis names the same Gateway-API-conformant CRD discriminator
12988/// as the sibling [`GATEWAY_API_API_VERSION`] apiVersion axis and must
12989/// move together on any future Gateway-API rebrand. Until this lift
12990/// landed the axis carried an inline `Gateway` literal at the one
12991/// production-code occurrence in caixa-mesh/src/lib.rs:578 (the
12992/// `gateway_routes` `Gateway` [`kube_resource_skeleton`] kind argument)
12993/// plus a matching set inside the in-file
12994/// `gateway_carries_canonical_kube_skeleton_without_labels` /
12995/// `render_all_includes_every_artifact_kind` test fixtures plus the
12996/// `find()` predicate of every per-Gateway-kind test that picks the
12997/// `Gateway` document out of the rendered Aplicacao mesh bundle — five
12998/// occurrences of the same load-bearing Gateway-API-CRD-`kind`-
12999/// discriminator convention, drift-prone by construction. A drift on
13000/// the top-level `Gateway` `kind` axis would have surfaced as a
13001/// non-self-locating "no kind 'Gatway' is registered for version
13002/// 'gateway.networking.k8s.io/v1'" error far from the source caixa.lisp
13003/// at apply parse time, with the rendered per-Aplicacao Gateway never
13004/// landing in the apiserver-side CRD registration and every external
13005/// `:entrada` flow dropping at the gateway-class-controller's reconcile
13006/// loop with no field naming the kind-discriminator-drift root cause.
13007///
13008/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
13009/// "every recurring shape becomes a generator before it becomes a
13010/// pattern; every pattern becomes a library before it becomes
13011/// duplicated code. The duplication budget is zero.") promotes the
13012/// constant to a typed substrate-side `&'static str` on the same
13013/// trajectory the [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
13014/// [`FLUX_KIND_KUSTOMIZATION`] (4114773) /
13015/// [`FLUX_KIND_HELM_RELEASE`] (e24ea3c) /
13016/// [`FLUX_KIND_GIT_REPOSITORY`] (dbbcf29) /
13017/// [`GATEWAY_API_API_VERSION`] (3c6cfc3) lifts established on the
13018/// sibling cluster-side-CRD-`kind`-discriminator + canonical-CRD-
13019/// group/version axes — extends the discipline from the apiVersion
13020/// half of the `(apiVersion, kind)` CRD-lookup tuple onto the kind
13021/// half on the same Gateway-API-CRD-axis, beginning the per-Gateway-
13022/// API-CRD kind+apiVersion lift pair the M3 Aplicacao mesh renderer's
13023/// external `:entrada` ingress contract rests on. The render-side
13024/// consumer now threads the same `&'static str` through its
13025/// [`kube_resource_skeleton`] call so a future Gateway-API rebrand
13026/// lands in one place; every future renderer that reaches for the
13027/// canonical Gateway-API `Gateway` kind (the future M4
13028/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
13029/// Gateway fan-out, a future per-cluster `GatewayClass` renderer the
13030/// operator emits for per-cluster gateway-class scoping, a future
13031/// per-edge `TCPRoute` / `TLSRoute` / `GRPCRoute` renderer for non-HTTP
13032/// `:entrada` edges that pair against this same `Gateway` parent)
13033/// inherits the same value by construction with no opportunity for
13034/// per-renderer drift.
13035///
13036/// Same "the typed constant lives in one place" discipline the
13037/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
13038/// [`FLUX_KIND_KUSTOMIZATION`] (4114773) /
13039/// [`FLUX_KIND_HELM_RELEASE`] (e24ea3c) /
13040/// [`FLUX_KIND_GIT_REPOSITORY`] (dbbcf29) /
13041/// [`GATEWAY_API_API_VERSION`] (3c6cfc3) /
13042/// [`CILIUM_API_VERSION`] (279d611) lifts apply on the peer
13043/// canonical-cluster-side-CRD-discriminator surface.
13044///
13045/// [cm]: ../../caixa_mesh/index.html
13046pub const GATEWAY_API_KIND_GATEWAY: &str = "Gateway";
13047
13048/// Canonical K8s Gateway API CRD `kind` discriminator the rendered
13049/// `HTTPRoute` document declares at its top-level [`KUBE_KEY_KIND`] axis.
13050/// Pairs with the sibling [`GATEWAY_API_API_VERSION`] (3c6cfc3) and the
13051/// peer [`GATEWAY_API_KIND_GATEWAY`] (fb4639c) — the K8s apiserver-side
13052/// CRD resolution contract is the `(apiVersion, kind)` tuple keyed
13053/// against the registered `CustomResourceDefinition`, so drift on the
13054/// kind axis is exactly as load-bearing as drift on the apiVersion axis
13055/// it accompanies (the apiserver's `RESTMapper` consults both together;
13056/// a `("gateway.networking.k8s.io/v1", "HTTPRout")` typo at the
13057/// production-code call site lands outside the registered Gateway-API-
13058/// conformant `HTTPRoute` CRD's `RESTKind` lookup, surfacing apply-side
13059/// as a non-self-locating "no kind 'HTTPRout' is registered for version
13060/// 'gateway.networking.k8s.io/v1'" error far from the source caixa.lisp /
13061/// the renderer's [`kube_resource_skeleton`] call site).
13062///
13063/// The single source of truth the rendered Aplicacao Gateway-API-side
13064/// ingress bundle's `HTTPRoute`-naming axis reaches for:
13065///
13066/// - the rendered `HTTPRoute` document's top-level [`KUBE_KEY_KIND`]
13067/// axis (caixa-mesh/src/lib.rs:663 — the `gateway_routes` per-
13068/// Aplicacao `HTTPRoute` [`kube_resource_skeleton`] kind argument).
13069///
13070/// The kind axis names the same Gateway-API-conformant CRD discriminator
13071/// as the sibling [`GATEWAY_API_API_VERSION`] apiVersion axis and the
13072/// peer [`GATEWAY_API_KIND_GATEWAY`] parent-Gateway axis, and must move
13073/// together with both on any future Gateway-API rebrand. Until this lift
13074/// landed the axis carried an inline `HTTPRoute` literal at the one
13075/// production-code occurrence in caixa-mesh/src/lib.rs:663 (the
13076/// `gateway_routes` `HTTPRoute` [`kube_resource_skeleton`] kind argument)
13077/// plus a matching set inside the in-file
13078/// `httproute_carries_canonical_kube_skeleton_without_labels` /
13079/// `render_all_includes_every_artifact_kind` test fixtures plus the
13080/// `find()` predicate of every per-HTTPRoute-kind test that picks the
13081/// `HTTPRoute` document out of the rendered Aplicacao mesh bundle —
13082/// multiple occurrences of the same load-bearing Gateway-API-CRD-`kind`-
13083/// discriminator convention, drift-prone by construction.
13084///
13085/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
13086/// "every recurring shape becomes a generator before it becomes a
13087/// pattern; every pattern becomes a library before it becomes
13088/// duplicated code. The duplication budget is zero.") promotes the
13089/// constant to a typed substrate-side `&'static str` on the same
13090/// trajectory the [`GATEWAY_API_KIND_GATEWAY`] (fb4639c) /
13091/// [`CILIUM_KIND_NETWORK_POLICY`] (eac85cb) /
13092/// [`FLUX_KIND_KUSTOMIZATION`] (4114773) /
13093/// [`FLUX_KIND_HELM_RELEASE`] (e24ea3c) /
13094/// [`FLUX_KIND_GIT_REPOSITORY`] (dbbcf29) /
13095/// [`GATEWAY_API_API_VERSION`] (3c6cfc3) lifts established on the
13096/// sibling cluster-side-CRD-`kind`-discriminator + canonical-CRD-
13097/// group/version axes — completes the per-Gateway-API-CRD `kind`-axis
13098/// lift trajectory across the `(Gateway, HTTPRoute)` pair that the
13099/// renderer's `gateway_routes` external `:entrada` ingress contract
13100/// emits together. Every guarantee in [MESH-COMPOSITION.md §V][mc] —
13101/// "every Aplicacao with `:entrada` emits one `Gateway` + one
13102/// `HTTPRoute` per `:paths` entry pointing at the same
13103/// `gateway.networking.k8s.io/v1` group/version — now threads through
13104/// one lifted `&'static str` apiece for both halves of the pair, so a
13105/// future Gateway-API rebrand lands at one substrate-side edit-point
13106/// per axis and no per-renderer drift surface remains across the pair.
13107///
13108/// A future Gateway-API-side renderer the M3.x absorption roadmap
13109/// names — `TCPRoute`, `TLSRoute`, `GRPCRoute` for non-HTTP `:entrada`
13110/// edges, the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
13111/// materializer's per-Aplicacao `HTTPRoute` fan-out, a future per-edge
13112/// route-attached-policy renderer (`BackendTLSPolicy`,
13113/// `BackendLBPolicy`) — inherits the canonical `HTTPRoute` kind
13114/// discriminator by construction with no opportunity for per-renderer
13115/// drift.
13116///
13117/// [mc]: https://github.com/pleme-io/theory/blob/main/MESH-COMPOSITION.md
13118/// [cm]: ../../caixa_mesh/index.html
13119pub const GATEWAY_API_KIND_HTTP_ROUTE: &str = "HTTPRoute";
13120
13121/// Canonical K8s Gateway API `Gateway.spec.listeners[].protocol` HTTP
13122/// listener-protocol scalar value the rendered `Gateway` document's
13123/// first (and V0-only) listener declares under its
13124/// [`KUBE_KEY_PROTOCOL`] axis. Pairs with the sibling
13125/// [`GATEWAY_API_KIND_GATEWAY`] (fb4639c) +
13126/// [`GATEWAY_API_KIND_HTTP_ROUTE`] (1adccc0) — the K8s Gateway API v1
13127/// CRD schema pins the per-listener L7 parser + TLS-termination
13128/// strategy through the `spec.listeners[].protocol` scalar value (the
13129/// gateway-class-controller's per-listener bind loop selects the L7
13130/// parser + TLS termination strategy from this exact byte-sequence;
13131/// the Gateway API v1 `ProtocolType` OpenAPI schema enum admits the
13132/// closed set `{"HTTP", "HTTPS", "TCP", "TLS", "UDP"}` verbatim), so
13133/// drift on the listener-protocol value is exactly as load-bearing as
13134/// drift on the sibling [`GATEWAY_API_KIND_GATEWAY`] +
13135/// [`GATEWAY_API_KIND_HTTP_ROUTE`] CRD `kind` discriminators the pair
13136/// declares together (a `("Gateway", "http")` /
13137/// `("Gateway", "Http")` / `("Gateway", "http/1.1")` typo at the
13138/// production-code call site lands outside the Gateway API v1
13139/// `ProtocolType` OpenAPI schema enum, surfacing apply-side as a
13140/// non-self-locating "spec.listeners[0].protocol: Unsupported value:
13141/// \"http\": supported values: \"HTTP\", \"HTTPS\", \"TCP\", \"TLS\",
13142/// \"UDP\"" apiserver admission-rejection far from the source
13143/// `caixa.lisp` / the renderer's `listener.insert(…)` call site — the
13144/// rendered per-Aplicacao `Gateway` object never reconciles at the
13145/// gateway-class-controller's per-listener bind loop and every
13146/// external `:entrada` HTTP flow drops at the gateway-class-
13147/// controller's admission gate with no field naming the
13148/// listener-protocol-drift root cause).
13149///
13150/// The single source of truth the rendered Aplicacao Gateway-API-side
13151/// ingress bundle's per-listener L7-parser-selection axis reaches for:
13152///
13153/// - the rendered `Gateway` document's `spec.listeners[0].protocol`
13154/// axis (the `gateway_routes` per-`:entrada` `Gateway` emitter's
13155/// `listener.insert(KUBE_KEY_PROTOCOL, "HTTP")` call — the sole
13156/// production-code call site the prior inline `"HTTP".into()`
13157/// literal sat at, caixa-mesh/src/lib.rs:2123).
13158///
13159/// The listener-protocol value names the same Gateway-API-
13160/// implementation-side per-listener L7-parser-selection scalar as the
13161/// sibling [`KUBE_KEY_PROTOCOL`] key-axis discriminator carries the
13162/// value under, and must move together with the sibling K8s Gateway
13163/// API `ProtocolType` OpenAPI schema enum on any future Gateway API
13164/// rebrand (an upstream Gateway API v2 rename of the HTTP listener
13165/// protocol from `HTTP` to `HTTP/1.1` / `HTTP/2` / `http`, coordinated
13166/// with the upstream SIG-Network Gateway API `ProtocolType` enum
13167/// deprecation cycle, would land at this one const rather than
13168/// scattered across every per-emitter listener-block-insertion site).
13169///
13170/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
13171/// "every recurring shape becomes a generator before it becomes a
13172/// pattern; every pattern becomes a library before it becomes
13173/// duplicated code. The duplication budget is zero.") promotes the
13174/// constant to a typed substrate-side `&'static str` on the same
13175/// trajectory the [`GATEWAY_API_KIND_GATEWAY`] (fb4639c) /
13176/// [`GATEWAY_API_KIND_HTTP_ROUTE`] (1adccc0) /
13177/// [`DEFAULT_GATEWAY_CLASS_NAME`] (d9b0743) lifts established on the
13178/// sibling Gateway-API-CRD-`kind`-discriminator + Gateway-controller-
13179/// binding-scalar-value axes — extends the per-Gateway-API-CRD-`kind`-
13180/// discriminator lift pair across the `(Gateway, HTTPRoute)` pair
13181/// onto the sibling per-Gateway `spec.listeners[].protocol`
13182/// listener-protocol-scalar-value axis the same `gateway_routes`
13183/// external `:entrada` ingress emitter carries.
13184///
13185/// A future Gateway-API-side renderer the M3.x absorption roadmap
13186/// names — an HTTPS listener with TLS termination (a sibling
13187/// `GATEWAY_API_PROTOCOL_HTTPS` const value the same enum admits),
13188/// the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` materializer's
13189/// per-Aplicacao multi-listener fan-out over `{HTTP, HTTPS, TLS}`,
13190/// a future per-listener route-attached-policy renderer that binds
13191/// distinct policy chains per listener-protocol — inherits the
13192/// canonical `HTTP` listener-protocol value by construction with no
13193/// opportunity for per-renderer drift.
13194///
13195/// [cm]: ../../caixa_mesh/index.html
13196pub const GATEWAY_API_PROTOCOL_HTTP: &str = "HTTP";
13197
13198/// Canonical K8s Gateway API v1 `PathMatchType` OpenAPI schema enum's
13199/// `PathPrefix` per-`HTTPRouteMatch` path-selection-predicate discriminator
13200/// value every `gateway_routes`-emitted `HTTPRoute` per-rule `matches[]`
13201/// entry declares under its per-match `spec.rules[].matches[].path.type`
13202/// scalar axis. Pairs with the sibling [`GATEWAY_API_KEY_PATH`] (9f45aa4)
13203/// per-`HTTPRouteMatch` path-matcher container-axis key it nests one level
13204/// beneath — the Gateway API v1 CRD schema pins per-`HTTPRouteMatch`
13205/// request-path selection through the `spec.rules[].matches[].path`
13206/// container axis (each match entry names one path-selection predicate the
13207/// request line's `:path` pseudo-header must satisfy under a `type`
13208/// discriminator scalar value; the Gateway API v1 `PathMatchType` OpenAPI
13209/// schema enum admits the closed set `{"Exact", "PathPrefix",
13210/// "RegularExpression"}` verbatim), so drift on the path-match-type value
13211/// is exactly as load-bearing as drift on the sibling
13212/// [`GATEWAY_API_PROTOCOL_HTTP`] (1b57473) per-listener L7-parser-selection
13213/// scalar value the peer `spec.listeners[].protocol` axis carries (a
13214/// `"pathPrefix"` / `"path_prefix"` / `"Prefix"` / `"path-prefix"` typo at
13215/// the production-code call site lands outside the Gateway API v1
13216/// `PathMatchType` OpenAPI schema enum's admitted set, surfacing apply-side
13217/// as a non-self-locating "spec.rules[0].matches[0].path.type: Unsupported
13218/// value: \"pathPrefix\": supported values: \"Exact\", \"PathPrefix\",
13219/// \"RegularExpression\"" apiserver admission-rejection far from the
13220/// source `caixa.lisp` / the renderer's `path_match.insert(…)` call site —
13221/// the rendered per-Aplicacao `HTTPRoute` object never reconciles at the
13222/// gateway-class-controller's per-rule L7 dispatch loop and every external
13223/// `:entrada` path-filtered flow drops at the gateway-class-controller's
13224/// admission gate with no field naming the path-match-type-drift root
13225/// cause).
13226///
13227/// The single source of truth the rendered Aplicacao Gateway-API-side
13228/// ingress bundle's per-`HTTPRouteMatch` path-selection-predicate-
13229/// discriminator-value-naming reaches for:
13230///
13231/// - the rendered `HTTPRoute` document's per-match
13232/// `spec.rules[].matches[].path.type` axis (caixa-mesh/src/lib.rs —
13233/// the `gateway_routes` per-match `path_match.insert("type",
13234/// "PathPrefix")` call the prior inline `"PathPrefix".into()` literal
13235/// sat at).
13236///
13237/// The path-match-type value names the same Gateway-API-implementation-
13238/// side per-`HTTPRouteMatch` request-path-selection-predicate discriminator
13239/// as the sibling [`GATEWAY_API_KEY_PATH`] path-matcher container-axis key
13240/// carries the value under, and must move together with the sibling K8s
13241/// Gateway API v1 `PathMatchType` OpenAPI schema enum on any future
13242/// Gateway API rebrand (an upstream Gateway API v2 rename of the prefix-
13243/// path-selection discriminator from `PathPrefix` to `Prefix` / `path-
13244/// prefix` / `PathPrefixMatch`, coordinated with the upstream SIG-Network
13245/// Gateway API `PathMatchType` enum deprecation cycle, would land at this
13246/// one const rather than scattered across every per-emitter per-match
13247/// path-block-insertion site).
13248///
13249/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
13250/// "every recurring shape becomes a generator before it becomes a
13251/// pattern; every pattern becomes a library before it becomes
13252/// duplicated code. The duplication budget is zero.") promotes the
13253/// constant to a typed substrate-side `&'static str` on the same
13254/// trajectory the [`GATEWAY_API_PROTOCOL_HTTP`] (1b57473) /
13255/// [`GATEWAY_API_KIND_GATEWAY`] (fb4639c) /
13256/// [`GATEWAY_API_KIND_HTTP_ROUTE`] (1adccc0) /
13257/// [`DEFAULT_GATEWAY_CLASS_NAME`] (d9b0743) lifts established on the
13258/// sibling per-listener L7-parser-selection scalar-value +
13259/// Gateway-API-CRD-`kind`-discriminator + Gateway-controller-binding
13260/// scalar-value axes — extends the canonical-Gateway-API-v1-OpenAPI-
13261/// schema-enum-value single-sourcing discipline the `ProtocolType.HTTP`
13262/// lift established onto the sibling `PathMatchType.PathPrefix`
13263/// per-`HTTPRouteMatch` path-selection-predicate discriminator the same
13264/// `gateway_routes` external `:entrada` ingress emitter carries under
13265/// the shared `HTTPRoute` body.
13266///
13267/// A future Gateway-API-side renderer the M3.x absorption roadmap
13268/// names — a sibling `GATEWAY_API_PATH_MATCH_TYPE_EXACT` /
13269/// `GATEWAY_API_PATH_MATCH_TYPE_REGULAR_EXPRESSION` const value the same
13270/// `PathMatchType` enum admits, the future M4
13271/// `mesh.pleme.io/v1alpha1/Aplicacao` materializer's per-Aplicacao
13272/// multi-predicate fan-out over `{Exact, PathPrefix, RegularExpression}`,
13273/// a future per-match `:entrada :paths` typed slot admitting a per-path
13274/// `(:predicate <Exact|Prefix|Regex>)` axis — inherits the canonical
13275/// `PathPrefix` path-match-type value by construction with no opportunity
13276/// for per-renderer drift.
13277///
13278/// [cm]: ../../caixa_mesh/index.html
13279pub const GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX: &str = "PathPrefix";
13280
13281/// Canonical K8s core `Protocol` OpenAPI schema enum's `TCP` L4-transport-
13282/// protocol scalar value every `cilium_network_policies`-emitted
13283/// `CiliumNetworkPolicy` document's per-`spec.ingress[].toPorts[].ports[]`
13284/// port-tuple declares under its per-tuple [`KUBE_KEY_PROTOCOL`] axis.
13285/// Pairs with the sibling [`KUBE_KEY_PROTOCOL`] (0307950) per-CR L4/L7
13286/// protocol-scalar-discriminator container-axis key the value nests
13287/// directly under — the K8s core `Protocol` schema pins per-`ContainerPort`
13288/// / `ServicePort` / `EndpointPort` / `NetworkPolicyPort` L4-transport
13289/// selection through the `protocol` scalar (each port entry names one
13290/// L4-transport-protocol discriminator the CNI / kube-proxy / eBPF-data-
13291/// plane bpf policy dispatch loop keys off before applying the port match;
13292/// the K8s core `Protocol` OpenAPI schema enum admits the closed set
13293/// `{"TCP", "UDP", "SCTP"}` verbatim — see
13294/// https://kubernetes.io/docs/reference/generated/kubernetes-api/v1/#protocol-v1-core),
13295/// so drift on the L4-transport-protocol value is exactly as load-bearing
13296/// as drift on the sibling [`GATEWAY_API_PROTOCOL_HTTP`] (1b57473) per-
13297/// listener L7-parser-selection scalar value the peer Gateway-API v1
13298/// `ProtocolType` OpenAPI schema enum admits under the same
13299/// [`KUBE_KEY_PROTOCOL`] container-axis key (a `"tcp"` / `"Tcp"` /
13300/// `"TCP/IP"` / `"transport-tcp"` typo at the production-code call site
13301/// lands outside the K8s core `Protocol` OpenAPI schema enum's admitted
13302/// set, surfacing apply-side as a non-self-locating
13303/// "spec.ingress[0].toPorts[0].ports[0].protocol: Unsupported value:
13304/// \"tcp\": supported values: \"SCTP\", \"TCP\", \"UDP\"" apiserver
13305/// admission-rejection far from the source `caixa.lisp` / the renderer's
13306/// `port_entry.insert(…)` call site — the rendered per-`(:de, :para)`
13307/// `CiliumNetworkPolicy` object never reconciles at the Cilium operator's
13308/// per-CNP L4 dispatch pass and every intra-mesh `:contratos` L4-tuple-
13309/// gated flow drops at the Cilium operator's admission gate with no field
13310/// naming the L4-transport-protocol-drift root cause; worse — because the
13311/// `protocol` scalar carries a schema-side default of `TCP` on the K8s
13312/// core `Protocol` enum, a silently-elided drift on the emit lands a
13313/// `CiliumNetworkPolicy` whose ingress rule falls back to the default L4-
13314/// transport-protocol and every port-match on a non-default transport
13315/// silently misses at the eBPF data plane's per-tuple dispatch).
13316///
13317/// The single source of truth the rendered Aplicacao Cilium-CNP-side
13318/// intra-mesh L4-tuple-gating bundle's per-`toPorts[].ports[]` port-tuple
13319/// L4-transport-protocol-discriminator-value-naming reaches for:
13320///
13321/// - the rendered `CiliumNetworkPolicy` document's per-tuple
13322/// `spec.ingress[].toPorts[].ports[].protocol` axis (caixa-mesh/src/lib.rs —
13323/// the `cilium_network_policies` per-`(:de, :para)`
13324/// `port_entry.insert(KUBE_KEY_PROTOCOL, "TCP")` call the prior
13325/// inline `"TCP".into()` literal sat at).
13326///
13327/// The L4-transport-protocol value names the same K8s-core-`Protocol`-
13328/// enum-side per-port-tuple L4-transport-selection discriminator as the
13329/// sibling [`KUBE_KEY_PROTOCOL`] key-axis discriminator carries the value
13330/// under, and must move together with the sibling K8s core `Protocol`
13331/// OpenAPI schema enum on any future K8s core `Protocol` rebrand (an
13332/// upstream K8s core `Protocol` rename or extension — e.g. the
13333/// `KEP-3675 QUIC transport` proposal's `"QUIC"` addition to the enum,
13334/// coordinated with the upstream SIG-Network per-version deprecation
13335/// cycle — would land at this one const rather than scattered across
13336/// every per-emitter L4-port-block-insertion site).
13337///
13338/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
13339/// "every recurring shape becomes a generator before it becomes a
13340/// pattern; every pattern becomes a library before it becomes
13341/// duplicated code. The duplication budget is zero.") promotes the
13342/// constant to a typed substrate-side `&'static str` on the same
13343/// trajectory the [`GATEWAY_API_PROTOCOL_HTTP`] (1b57473) /
13344/// [`GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX`] (530705d) /
13345/// [`GATEWAY_API_KIND_GATEWAY`] (fb4639c) /
13346/// [`GATEWAY_API_KIND_HTTP_ROUTE`] (1adccc0) /
13347/// [`DEFAULT_GATEWAY_CLASS_NAME`] (d9b0743) lifts established on the
13348/// sibling per-listener L7-parser-selection scalar-value + per-match
13349/// path-selection-predicate discriminator-value + Gateway-API-CRD-
13350/// `kind`-discriminator + Gateway-controller-binding scalar-value axes —
13351/// extends the canonical-cluster-side-OpenAPI-schema-enum-value single-
13352/// sourcing discipline the Gateway-API v1 `ProtocolType.HTTP` /
13353/// `PathMatchType.PathPrefix` lifts established onto the sibling
13354/// K8s-core `Protocol.TCP` per-port-tuple L4-transport-protocol-
13355/// discriminator the `cilium_network_policies` intra-mesh L4-tuple-gating
13356/// emitter carries under the shared `CiliumNetworkPolicy` body.
13357///
13358/// A future Cilium-CNP-side / K8s-core-`Protocol`-side renderer the M3.x
13359/// absorption roadmap names — a sibling `KUBE_PROTOCOL_UDP` /
13360/// `KUBE_PROTOCOL_SCTP` const value the same `Protocol` enum admits, the
13361/// future M4 `mesh.pleme.io/v1alpha1/Aplicacao` materializer's per-
13362/// Aplicacao multi-transport fan-out over `{TCP, UDP, SCTP}` for
13363/// `nats:pub-sub` / `wasi:sockets/udp` contratos, a future per-contrato
13364/// `:transport <TCP|UDP|SCTP>` typed slot admitting a per-edge transport-
13365/// protocol axis — inherits the canonical `TCP` L4-transport-protocol
13366/// value by construction with no opportunity for per-renderer drift.
13367///
13368/// [cm]: ../../caixa_mesh/index.html
13369pub const KUBE_PROTOCOL_TCP: &str = "TCP";
13370
13371/// Canonical Cilium `CiliumNetworkPolicy` `MutualAuthenticationMode` OpenAPI
13372/// schema enum's `required` per-`ingress[].authentication.mode` mTLS-mandatory
13373/// scalar-value every `cilium_network_policies`-emitted CNP document declares
13374/// under its per-rule mutual-auth-mode-discriminator leaf axis when the typed
13375/// `:politicas :mtls-required` tristate is `Some(true)`. Pairs with the sibling
13376/// [`CILIUM_KEY_MODE`] (4289dfb) per-authn-block mode-discriminator leaf-axis
13377/// key the value nests directly under, and the sibling
13378/// [`CILIUM_AUTH_MODE_DISABLED`] scalar-value the `Some(false)` opt-out arm of
13379/// the same tristate emits — the Cilium CNP `MutualAuthenticationMode` OpenAPI
13380/// schema enum admits the closed set `{"required", "disabled", "test-always-
13381/// fail"}` verbatim (the `test-always-fail` arm is an infrastructure-side
13382/// debugging surface, not an author-reachable slot), so drift on the mTLS-
13383/// mandatory scalar-value is exactly as load-bearing as drift on the sibling
13384/// per-authn-block mode-discriminator leaf axis it nests under (a `"Required"`
13385/// / `"REQUIRED"` / `"mandatory"` / `"mtls-required"` typo at either the
13386/// production-code call site or a downstream probe lands outside the Cilium
13387/// CNP `MutualAuthenticationMode` OpenAPI schema enum's admitted set,
13388/// surfacing apply-side as a Cilium-agent per-rule mutual-auth-block schema-
13389/// validator drop far from the source `caixa.lisp` / the renderer's
13390/// `single_field_overlay(mtls_required, CILIUM_KEY_MODE, …)` call site — the
13391/// rendered per-`(:de, :para)` `CiliumNetworkPolicy` object never enforces
13392/// per-edge SPIFFE-identity-bound mutual-auth at the Cilium data-plane's per-
13393/// rule handshake gate and every intra-mesh `:contratos` flow the CNP was
13394/// authored to protect with per-edge mTLS silently bypasses the handshake at
13395/// the Cilium data-plane's default-authentication mode with no field naming
13396/// the mTLS-mandatory-scalar-value-drift root cause).
13397///
13398/// The single source of truth the rendered Aplicacao Cilium-CNP-side per-edge
13399/// mutual-auth-mode-discriminator affirmative-value-naming reaches for:
13400///
13401/// - the rendered `CiliumNetworkPolicy` document's per-rule
13402/// `spec.ingress[].authentication.mode` leaf value (caixa-mesh/src/lib.rs
13403/// — the `cilium_network_policies` per-`(:de, :para)`
13404/// `single_field_overlay(spec.politicas.mtls_required, CILIUM_KEY_MODE,
13405/// |required| …)` closure's `if required { … }` arm the prior inline
13406/// `"required".into()` literal sat at, plus every test-fixture navigation
13407/// that pins the emitted value under the `:mtls-required t` presence,
13408/// fan-out, and pubsub-carry-overlay-too shapes).
13409///
13410/// The mTLS-mandatory scalar-value names the same Cilium-agent-side per-rule
13411/// SPIFFE-identity-handshake-mandatory enforcement policy as the sibling
13412/// [`CILIUM_KEY_MODE`] leaf-axis key carries the value under, and must move
13413/// together with the sibling Cilium CNP `MutualAuthenticationMode` OpenAPI
13414/// schema enum on any future Cilium CRD schema rebrand (an upstream
13415/// `cilium.io/v3` rename of the mTLS-mandatory scalar-value from `required`
13416/// to `enforce` / `mandatory` / `strict`, coordinated with the Cilium
13417/// project's periodic CRD schema-migration passes, would land at this one
13418/// const rather than scattered across every per-emitter per-rule authn-block-
13419/// insertion site).
13420///
13421/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5, "every
13422/// recurring shape becomes a generator before it becomes a pattern; every
13423/// pattern becomes a library before it becomes duplicated code. The
13424/// duplication budget is zero.") promotes the constant to a typed substrate-
13425/// side `&'static str` on the same trajectory the
13426/// [`GATEWAY_API_PROTOCOL_HTTP`] (1b57473) /
13427/// [`GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX`] (530705d) /
13428/// [`KUBE_PROTOCOL_TCP`] (2123047) scalar-value lifts established on the
13429/// sibling canonical-cluster-side-OpenAPI-schema-enum-value surfaces —
13430/// extends the canonical-cluster-side-OpenAPI-schema-enum-value single-
13431/// sourcing discipline the Gateway-API v1 `ProtocolType.HTTP` /
13432/// `PathMatchType.PathPrefix` / K8s-core `Protocol.TCP` lifts established
13433/// onto the sibling Cilium-CNP-side `MutualAuthenticationMode.required`
13434/// per-rule mTLS-mandatory scalar-value the `cilium_network_policies` per-
13435/// edge SPIFFE-identity-bound mutual-auth emitter carries under the shared
13436/// `CiliumNetworkPolicy` body.
13437///
13438/// [cm]: ../../caixa_mesh/index.html
13439pub const CILIUM_AUTH_MODE_REQUIRED: &str = "required";
13440
13441/// Canonical Cilium `CiliumNetworkPolicy` `MutualAuthenticationMode` OpenAPI
13442/// schema enum's `disabled` per-`ingress[].authentication.mode` mTLS-skipped
13443/// scalar-value every `cilium_network_policies`-emitted CNP document declares
13444/// under its per-rule mutual-auth-mode-discriminator leaf axis when the typed
13445/// `:politicas :mtls-required` tristate is the explicit `Some(false)` opt-out
13446/// arm (an author who *named* the axis and asked for the mTLS handshake to be
13447/// skipped on this Aplicacao's edges — e.g. a debug or legacy-bridge
13448/// Aplicacao that needs to talk to non-mesh peers, distinct from the `None`
13449/// slot-absent arm the renderer maps to omit-the-block-entirely). Peer to
13450/// the sibling [`CILIUM_AUTH_MODE_REQUIRED`] mTLS-mandatory scalar-value the
13451/// `Some(true)` affirmative arm emits under the same tristate branch — the
13452/// Cilium CNP `MutualAuthenticationMode` OpenAPI schema enum admits the two
13453/// arms as a matched author-reachable pair.
13454///
13455/// The single source of truth the rendered Aplicacao Cilium-CNP-side per-edge
13456/// mutual-auth-mode-discriminator negative-value-naming reaches for:
13457///
13458/// - the rendered `CiliumNetworkPolicy` document's per-rule
13459/// `spec.ingress[].authentication.mode` leaf value (caixa-mesh/src/lib.rs
13460/// — the `cilium_network_policies` per-`(:de, :para)`
13461/// `single_field_overlay(spec.politicas.mtls_required, CILIUM_KEY_MODE,
13462/// |required| …)` closure's `else { … }` arm the prior inline
13463/// `"disabled".into()` literal sat at, plus the
13464/// `cnp_explicit_mtls_required_false_emits_disabled_mode` test-fixture
13465/// probe that pins the explicit-opt-out arm's rendered value).
13466///
13467/// Same drift-mode risk as the sibling [`CILIUM_AUTH_MODE_REQUIRED`] pin: a
13468/// `"Disabled"` / `"DISABLED"` / `"off"` / `"skip"` typo lands outside the
13469/// Cilium CNP `MutualAuthenticationMode` OpenAPI schema enum's admitted set;
13470/// the rendered per-`(:de, :para)` `CiliumNetworkPolicy` object never reaches
13471/// the Cilium agent's per-rule mutual-auth-block schema validator's admitted
13472/// set and the author's explicit-opt-out intent silently collapses onto the
13473/// cluster-default authentication mode (typically also "disabled" today, but
13474/// environment-divergent — take effect) with no field naming the mTLS-
13475/// skipped-scalar-value-drift root cause.
13476///
13477/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5, "every
13478/// recurring shape becomes a generator before it becomes a pattern; every
13479/// pattern becomes a library before it becomes duplicated code. The
13480/// duplication budget is zero.") promotes the constant to a typed substrate-
13481/// side `&'static str` on the same trajectory the sibling
13482/// [`CILIUM_AUTH_MODE_REQUIRED`] mTLS-mandatory scalar-value lift establishes
13483/// on the affirmative arm of the same `MutualAuthenticationMode` enum —
13484/// completes the per-authn-block `(mode → {required, disabled})` leaf-axis /
13485/// author-reachable-scalar-value-pair single-sourcing the M3 Aplicacao mesh
13486/// renderer's SPIFFE-identity-bound per-edge mTLS enforcement + explicit-
13487/// opt-out contract rests on across the two arms of the `:politicas
13488/// :mtls-required` tristate.
13489///
13490/// [cm]: ../../caixa_mesh/index.html
13491pub const CILIUM_AUTH_MODE_DISABLED: &str = "disabled";
13492
13493/// Canonical `bool → &'static str` bijection projection every consumer of the
13494/// Cilium `CiliumNetworkPolicy` `MutualAuthenticationMode` OpenAPI schema
13495/// enum's closed-set author-reachable scalar-value pair
13496/// ([`CILIUM_AUTH_MODE_REQUIRED`] / [`CILIUM_AUTH_MODE_DISABLED`]) consults
13497/// so the per-tristate-arm dispatch — `Some(true)` (mTLS handshake
13498/// mandatory) → [`CILIUM_AUTH_MODE_REQUIRED`], `Some(false)` (mTLS
13499/// handshake skipped, explicit opt-out) → [`CILIUM_AUTH_MODE_DISABLED`] —
13500/// lives in exactly one place. The two arms of the `:politicas
13501/// :mtls-required` tristate's non-`None` value-space each land on a
13502/// distinct `MutualAuthenticationMode` scalar; the `None` slot-absent arm
13503/// is the caller's [`single_field_overlay`] emission-gate concern (the
13504/// helper returns `None` and the outer `authentication:` block is omitted
13505/// entirely), not this projection's — see the per-emit-site
13506/// `if let Some(overlay) = mtls_overlay { rule.insert(CILIUM_KEY_AUTHENTICATION,
13507/// overlay.clone()) }` guard.
13508///
13509/// The single source of truth the rendered Aplicacao Cilium-CNP-side
13510/// per-edge mutual-auth-mode-discriminator scalar-value dispatch reaches
13511/// for:
13512///
13513/// - the rendered `CiliumNetworkPolicy` document's per-rule
13514/// `spec.ingress[].authentication.mode` leaf value (caixa-mesh/src/lib.rs
13515/// — the `cilium_network_policies` per-`(:de, :para)`
13516/// `single_field_overlay(spec.politicas.mtls_required, CILIUM_KEY_MODE,
13517/// |required| serde_yaml::Value::String(cilium_auth_mode(required).into()))`
13518/// closure body).
13519/// - the generic-helper pin in this crate's
13520/// `single_field_overlay_threads_typed_value_through_closure` test
13521/// that mirrors the production overlay's shape letter-for-letter and
13522/// now threads through the same shared projection.
13523///
13524/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5, "every
13525/// recurring shape becomes a generator before it becomes a pattern; every
13526/// pattern becomes a library before it becomes duplicated code. The
13527/// duplication budget is zero.") promotes the per-tristate-arm dispatch
13528/// body onto a shared projection on the same trajectory the sibling
13529/// [`CILIUM_AUTH_MODE_REQUIRED`] / [`CILIUM_AUTH_MODE_DISABLED`]
13530/// closed-set-scalar-value lifts established for the two arms of the
13531/// same `MutualAuthenticationMode` enum — closes the pair of related
13532/// lift trajectories the `(value-space, arm-dispatch)` per-authn-block
13533/// leaf's canonical decomposition rests on. The prior inline `if required
13534/// { CILIUM_AUTH_MODE_REQUIRED } else { CILIUM_AUTH_MODE_DISABLED }` body
13535/// split across the two occurrences — the caixa-mesh production emitter's
13536/// closure and the caixa-core generic-helper pin's closure — would have
13537/// let a per-arm reassignment (e.g. an upstream Cilium v3 schema rename
13538/// swap of the `required` ↔ `disabled` scalars, or the addition of a
13539/// third `MutualAuthenticationMode` variant that reshapes the closed set)
13540/// drift on one closure body but not the peer, silently letting a Cilium
13541/// data-plane pod either enforce mTLS where the author asked for skip or
13542/// skip it where the author asked for enforce.
13543///
13544/// Pairs with the [`CILIUM_KEY_MODE`] per-authentication-block mode-
13545/// discriminator leaf-axis key at the caller's
13546/// `single_field_overlay(spec.politicas.mtls_required, CILIUM_KEY_MODE,
13547/// |required| serde_yaml::Value::String(cilium_auth_mode(required).into()))`
13548/// call: the key is the field name the leaf mounts under, this projection
13549/// is the scalar the leaf carries. Same-shape peer to the K8s core
13550/// `Protocol` closed-set enum's future `bool → {"TCP", "UDP"}` /
13551/// K8s Gateway API v1 `PathMatchType` closed-set enum's future variant-
13552/// pick projections the M3.x absorption roadmap acknowledges — the M3
13553/// mesh renderer's `MutualAuthenticationMode` bijection surface is the
13554/// first landed instance of the canonical `(closed-set-CRD-schema-enum-
13555/// value pair, per-typed-arm dispatch projection)` compound.
13556///
13557/// [cm]: ../../caixa_mesh/index.html
13558#[must_use]
13559pub fn cilium_auth_mode(required: bool) -> &'static str {
13560 if required {
13561 CILIUM_AUTH_MODE_REQUIRED
13562 } else {
13563 CILIUM_AUTH_MODE_DISABLED
13564 }
13565}
13566
13567/// Canonical K8s Gateway API `HTTPRoute` parent-Gateway-binding container-
13568/// axis key every `gateway_routes`-emitted `HTTPRoute` document mounts its
13569/// per-route parent-Gateway `[{name}]` list under (`spec.parentRefs[]`).
13570/// Pairs with the sibling [`GATEWAY_API_KIND_HTTP_ROUTE`] (1adccc0) +
13571/// [`GATEWAY_API_KIND_GATEWAY`] (fb4639c) — the Gateway API v1 CRD schema
13572/// pins the per-HTTPRoute parent-Gateway identity through the
13573/// `spec.parentRefs[]` container axis (each entry names the parent
13574/// Gateway the route attaches to; the sibling `hostnames` + `rules`
13575/// container axes carry the per-route host-match + per-rule L7-dispatch
13576/// halves under the same `spec` block), so drift on the parent-Gateway-
13577/// binding axis is exactly as load-bearing as drift on the per-HTTPRoute
13578/// `kind` discriminator axis it accompanies (the K8s apiserver-side
13579/// Gateway API CRD schema validator drops any `spec` block whose parent-
13580/// binding container axis carries an unrecognized key — a `"parentRef"`
13581/// / `"parents"` / `"parentGateways"` typo silently emits an `HTTPRoute`
13582/// whose parent-Gateway attachment the Gateway API implementation's
13583/// per-HTTPRoute reconcile loop no-ops entirely: the route lands
13584/// unattached to any Gateway, and every external `:entrada` flow the
13585/// `HTTPRoute` was authored to accept drops at the Gateway API
13586/// implementation's per-Gateway HTTP-listener fan-in with no field
13587/// naming the parent-Gateway-binding-axis-drift root cause).
13588///
13589/// The single source of truth the rendered Aplicacao Gateway-API-side
13590/// ingress bundle's per-HTTPRoute parent-Gateway-binding-axis-naming
13591/// reaches for:
13592///
13593/// - the rendered `HTTPRoute` document's `spec.parentRefs[]` axis
13594/// (caixa-mesh/src/lib.rs:1389 — the `gateway_routes` per-Aplicacao
13595/// `HTTPRoute`'s `r_spec.insert("parentRefs", …)` call).
13596///
13597/// The parent-Gateway-binding axis names the same Gateway-API-
13598/// implementation-side per-HTTPRoute route→Gateway attachment container
13599/// as the sibling [`GATEWAY_API_KIND_HTTP_ROUTE`] +
13600/// [`GATEWAY_API_KIND_GATEWAY`] CRD `kind` discriminators the pair
13601/// declares together, and must move together on any future Gateway API
13602/// rebrand (an upstream Gateway API v2 rename of the parent-binding
13603/// axis from `parentRefs` to `parents` / `parentGateways` /
13604/// `attachedTo`, coordinated with the upstream SIG-Network Gateway API
13605/// deprecation cycle). Until this lift landed the axis carried an
13606/// inline `parentRefs` literal at the one production-code occurrence in
13607/// caixa-mesh/src/lib.rs:1389 (the `gateway_routes`
13608/// `r_spec.insert("parentRefs", …)` call) — the single load-bearing
13609/// Gateway-API-CRD-`parentRefs`-axis-key occurrence, drift-prone by
13610/// construction. A drift on the production site to `"parentRef"` /
13611/// `"parents"` / `"parentGateways"` would have surfaced as a Gateway-
13612/// API-implementation-side schema validator drop at apply time (the
13613/// affected `HTTPRoute`'s parent-Gateway-binding axis the CRD schema
13614/// validator recognizes as unknown), with every external `:entrada`
13615/// flow the `HTTPRoute` was authored to accept dropping at the Gateway
13616/// API implementation's per-Gateway HTTP-listener fan-in with no field
13617/// naming the parent-Gateway-binding-drift root cause.
13618///
13619/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
13620/// "every recurring shape becomes a generator before it becomes a
13621/// pattern; every pattern becomes a library before it becomes
13622/// duplicated code. The duplication budget is zero.") promotes the
13623/// constant to a typed substrate-side `&'static str` on the same
13624/// trajectory the [`CILIUM_KEY_PORTS`] (1087693) /
13625/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
13626/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
13627/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
13628/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
13629/// [`KUBE_KEY_RULES`] (a205eb3) /
13630/// [`GATEWAY_API_KIND_HTTP_ROUTE`] (1adccc0) /
13631/// [`GATEWAY_API_KIND_GATEWAY`] (fb4639c) lifts established on the
13632/// sibling canonical-Cilium-CNP-body-axis /
13633/// canonical-Gateway-API-CRD-`kind`-discriminator surfaces — pivots the
13634/// per-CNP-body-axis lift discipline onto the sibling per-HTTPRoute-
13635/// body-axis surface, beginning the per-Gateway-API-HTTPRoute-body-axis
13636/// canonical-string-pin set (`parentRefs`, `hostnames`) the M3
13637/// Aplicacao mesh renderer's external `:entrada` ingress contract rests
13638/// on across the Gateway API HTTPRoute-side per-route body-shape. The
13639/// render-side consumer now threads the same `&'static str` through
13640/// its `r_spec.insert(…)` call so a future Gateway API rebrand on the
13641/// parent-Gateway-binding axis (or an upstream SIG-Network Gateway API
13642/// v2 rename to a per-CRD sibling name) lands in one place; every
13643/// future renderer that reaches for the canonical per-HTTPRoute parent-
13644/// Gateway-binding axis (the future M4
13645/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
13646/// `HTTPRoute` fan-out, a future per-edge `TCPRoute` / `TLSRoute` /
13647/// `GRPCRoute` renderer for non-HTTP `:entrada` edges whose per-route
13648/// parent-Gateway-binding nests under the same axis convention, a
13649/// future per-Aplicacao `ReferenceGrant` renderer whose cross-namespace
13650/// parent-Gateway attachment binds against this same axis) inherits the
13651/// same value by construction with no opportunity for per-renderer
13652/// drift.
13653///
13654/// Same "the typed constant lives in one place" discipline the
13655/// [`CILIUM_KEY_PORTS`] (1087693) /
13656/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
13657/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
13658/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
13659/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
13660/// [`KUBE_KEY_RULES`] (a205eb3) /
13661/// [`GATEWAY_API_KIND_HTTP_ROUTE`] (1adccc0) /
13662/// [`GATEWAY_API_KIND_GATEWAY`] (fb4639c) lifts apply on the peer
13663/// canonical-Gateway-API-HTTPRoute-body-axis surface.
13664///
13665/// [cm]: ../../caixa_mesh/index.html
13666pub const GATEWAY_API_KEY_PARENT_REFS: &str = "parentRefs";
13667
13668/// Canonical K8s Gateway API `HTTPRoute` per-`spec.parentRefs[]` entry
13669/// listener-selector sub-axis key every `gateway_routes`-emitted
13670/// `HTTPRoute` document mounts under each parent-Gateway attachment to
13671/// pin the route to one specific listener out of the parent Gateway's
13672/// `spec.listeners[]` list (`spec.parentRefs[].sectionName`). Pairs
13673/// with the sibling [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) — the
13674/// Gateway API v1 CRD schema pins per-HTTPRoute route→Gateway
13675/// attachment through the `spec.parentRefs[]` container axis and the
13676/// per-entry listener-selection sub-axis through `sectionName` beneath
13677/// each entry (each `SectionName`-typed scalar binds to a
13678/// `Gateway.spec.listeners[].name` byte-string). Omitting the
13679/// selector attaches the route to *every* listener on the parent
13680/// Gateway — the Gateway API v1 default fan-out that silently doubles
13681/// route emission once the substrate ships a second listener under
13682/// the HTTPS-by-default trajectory the peer
13683/// [`GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME`] (cd60fde) docstring
13684/// forecasts (`"http"` → `"http-v1"` alongside a sibling `"https"`
13685/// listener once cert-manager-issued per-`:entrada :host` certificates
13686/// land). Pinning the selector by construction binds each substrate-
13687/// emitted route to exactly one listener on the parent Gateway, so a
13688/// future multi-listener migration lands as one const-edit on the
13689/// paired [`GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME`] declaration
13690/// instead of a silent per-route dispatch flip.
13691///
13692/// The single source of truth the rendered Aplicacao Gateway-API-side
13693/// ingress bundle's per-HTTPRoute per-parentRef listener-selector-axis-
13694/// naming reaches for:
13695///
13696/// - the rendered `HTTPRoute` document's per-parentRef
13697/// `spec.parentRefs[].sectionName` axis (the `gateway_routes` per-
13698/// Aplicacao HTTPRoute's `parent_ref.insert(<KEY>, …)` call the
13699/// paired [`GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME`] `&'static str`
13700/// — the same byte-string the parent Gateway's sole
13701/// `listener.insert(GATEWAY_API_KEY_NAME, …)` call emits at
13702/// `spec.listeners[].name` — flows through, so a substrate-side
13703/// rebrand of the canonical listener-name identifier reaches both
13704/// the listener-name emitter and the sectionName selector by
13705/// construction).
13706///
13707/// The per-parentRef listener-selector sub-axis names the same
13708/// Gateway-API-implementation-side per-HTTPRoute route→listener
13709/// attachment sub-container as the sibling
13710/// [`GATEWAY_API_KEY_PARENT_REFS`] per-HTTPRoute parent-Gateway-binding
13711/// container axis it accompanies, and must move together on any future
13712/// Gateway API rebrand (an upstream SIG-Network Gateway API v2 rename
13713/// of the per-entry listener-selection sub-axis from `sectionName` to
13714/// `listenerName` / `listener` / `attachTo`, coordinated with the
13715/// Gateway API deprecation cycle). Until this lift landed the axis had
13716/// zero production-code call sites — the substrate emitted an
13717/// `HTTPRoute` whose `spec.parentRefs[]` entries omitted the selector
13718/// entirely, silently accepting the Gateway API v1 attach-to-every-
13719/// listener default fan-out. A future substrate-side second listener
13720/// under the same parent Gateway (the HTTPS-by-default trajectory the
13721/// [`GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME`] docstring forecasts)
13722/// would have silently doubled every route's emitted per-request
13723/// dispatch surface — every external `:entrada` request the route was
13724/// authored to accept on `:80` would have accepted a matching request
13725/// on `:443` too, with the second-listener leak surfacing only in per-
13726/// request access logs (never in `kubectl describe httproute` — the
13727/// implicit fan-out reads as intended per the Gateway API v1 spec).
13728///
13729/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
13730/// "every recurring shape becomes a generator before it becomes a
13731/// pattern; every pattern becomes a library before it becomes
13732/// duplicated code. The duplication budget is zero.") promotes the
13733/// constant to a typed substrate-side `&'static str` on the same
13734/// trajectory the [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
13735/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
13736/// [`GATEWAY_API_KEY_MATCHES`] (8f9ed08) /
13737/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
13738/// [`GATEWAY_API_KEY_HOSTNAMES`] (bd7ea31) lifts established on the
13739/// sibling canonical-Gateway-API-HTTPRoute-body-axis surface — extends
13740/// the per-Gateway-API-HTTPRoute-body-axis canonical-string-pin set
13741/// onto the per-parentRef listener-selector sub-axis the M3 Aplicacao
13742/// mesh renderer's external `:entrada` ingress contract now rests on.
13743/// The render-side consumer threads the same `&'static str` through
13744/// its `parent_ref.insert(…)` call so a future Gateway API rebrand on
13745/// the per-parentRef listener-selector sub-axis (or an upstream SIG-
13746/// Network Gateway API v2 rename to a per-CRD sibling name) lands in
13747/// one place; every future renderer that reaches for the canonical
13748/// per-HTTPRoute per-parentRef listener-selector sub-axis (the future
13749/// M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-
13750/// Aplicacao `HTTPRoute` fan-out, a future per-edge `TCPRoute` /
13751/// `TLSRoute` / `GRPCRoute` renderer whose per-parentRef listener-
13752/// selection nests under the same axis convention) inherits the same
13753/// value by construction with no opportunity for per-renderer drift.
13754///
13755/// Same "the typed constant lives in one place" discipline the
13756/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
13757/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
13758/// [`GATEWAY_API_KEY_MATCHES`] (8f9ed08) lifts apply on the peer
13759/// canonical-Gateway-API-HTTPRoute-body-axis surface.
13760///
13761/// [cm]: ../../caixa_mesh/index.html
13762pub const GATEWAY_API_KEY_SECTION_NAME: &str = "sectionName";
13763
13764/// Canonical K8s Gateway API `HTTPRoute` per-rule backend-destination
13765/// container-axis key every `gateway_routes`-emitted `HTTPRoute`
13766/// document mounts its per-rule `[{name, port}]` backend list under
13767/// (`spec.rules[].backendRefs[]`). Pairs with the sibling
13768/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) — the Gateway API v1 CRD
13769/// schema pins the per-HTTPRoute route→Gateway attachment through the
13770/// `spec.parentRefs[]` container axis and the per-rule route→Servico
13771/// backend fan-out through the `spec.rules[].backendRefs[]` axis
13772/// beneath each rule entry, so drift on the per-rule backend-destination
13773/// axis is exactly as load-bearing as drift on the per-HTTPRoute
13774/// parent-Gateway-binding axis it accompanies (the K8s apiserver-side
13775/// Gateway API CRD schema validator drops any per-rule block whose
13776/// backend-destination container axis carries an unrecognized key — a
13777/// `"backendRef"` / `"backends"` / `"forwardTo"` typo silently emits an
13778/// `HTTPRoute` whose per-rule backend fan-out the Gateway API
13779/// implementation's per-rule L7 dispatch loop no-ops entirely: no
13780/// backend is picked, and every external `:entrada` request the rule
13781/// was authored to route drops at the gateway-class-controller's
13782/// per-rule reconcile with no field naming the backend-destination-
13783/// axis-drift root cause).
13784///
13785/// The single source of truth the rendered Aplicacao Gateway-API-side
13786/// ingress bundle's per-HTTPRoute per-rule backend-destination-axis-
13787/// naming reaches for:
13788///
13789/// - the rendered `HTTPRoute` document's per-rule
13790/// `spec.rules[].backendRefs[]` axis (caixa-mesh/src/lib.rs:1414 —
13791/// the `gateway_routes` per-Aplicacao HTTPRoute's per-rule
13792/// `rule.insert("backendRefs", …)` call).
13793///
13794/// The per-rule backend-destination container axis names the same
13795/// Gateway-API-implementation-side per-rule route→Servico backend fan-
13796/// out container as the sibling [`GATEWAY_API_KEY_PARENT_REFS`] per-
13797/// HTTPRoute parent-Gateway-binding container axis it accompanies, and
13798/// must move together on any future Gateway API rebrand (an upstream
13799/// SIG-Network Gateway API v2 rename of the backend-destination axis
13800/// from `backendRefs` to `backends` / `forwardTo` / `to`, coordinated
13801/// with the Gateway API deprecation cycle). Until this lift landed the
13802/// axis carried an inline `backendRefs` literal at the one production-
13803/// code occurrence in caixa-mesh/src/lib.rs:1414 (the `gateway_routes`
13804/// per-rule `rule.insert("backendRefs", …)` call) plus a matching set
13805/// inside the in-file `httproute_routes_to_entrada_para` /
13806/// `httproute_rule_keys_pin_overlay_position` test-fixture navigations —
13807/// three occurrences of the same load-bearing Gateway-API-CRD-
13808/// `backendRefs`-axis-key convention, drift-prone by construction. A
13809/// drift on any one production or test-fixture site to `"backendRef"` /
13810/// `"backends"` / `"forwardTo"` would have surfaced as a Gateway API
13811/// implementation-side schema validator drop at apply time (the
13812/// affected per-rule backend-destination axis the CRD schema validator
13813/// recognizes as unknown), with every external `:entrada` request the
13814/// rule was authored to route dropping at the gateway-class-
13815/// controller's per-rule reconcile with no field naming the backend-
13816/// destination-drift root cause. A drift on the test-fixture side
13817/// silently masks the emission-side pin (`.get("backendRefs")` returns
13818/// `None` under both the drifted-key emitter and the drifted-key probe
13819/// — the downstream `.and_then(|b| b.as_sequence())` /
13820/// `.and_then(|s| s.first())` chain short-circuits vacuously because
13821/// the outer per-rule backend-destination lookup is itself `None`).
13822///
13823/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
13824/// "every recurring shape becomes a generator before it becomes a
13825/// pattern; every pattern becomes a library before it becomes
13826/// duplicated code. The duplication budget is zero.") promotes the
13827/// constant to a typed substrate-side `&'static str` on the same
13828/// trajectory the [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
13829/// [`CILIUM_KEY_PORTS`] (1087693) /
13830/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
13831/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
13832/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
13833/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
13834/// [`KUBE_KEY_RULES`] (a205eb3) lifts established on the sibling
13835/// canonical-Gateway-API-HTTPRoute-body-axis /
13836/// canonical-Cilium-CNP-body-axis surfaces — extends the per-Gateway-
13837/// API-HTTPRoute-body-axis canonical-string-pin set the sibling
13838/// `parentRefs` lift began (`parentRefs`, `backendRefs`, future
13839/// `hostnames`) the M3 Aplicacao mesh renderer's external `:entrada`
13840/// ingress contract rests on across the Gateway API HTTPRoute-side per-
13841/// route body-shape. The render-side consumer now threads the same
13842/// `&'static str` through its `rule.insert(…)` call so a future Gateway
13843/// API rebrand on the per-rule backend-destination axis (or an upstream
13844/// SIG-Network Gateway API v2 rename to a per-CRD sibling name) lands
13845/// in one place; every future renderer that reaches for the canonical
13846/// per-HTTPRoute per-rule backend-destination axis (the future M4
13847/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
13848/// `HTTPRoute` fan-out, a future per-edge `TCPRoute` / `TLSRoute` /
13849/// `GRPCRoute` renderer for non-HTTP `:entrada` edges whose per-rule
13850/// backend-destination nests under the same axis convention, a future
13851/// per-route mirroring / traffic-split renderer whose per-weight
13852/// backend list binds against this same axis) inherits the same value
13853/// by construction with no opportunity for per-renderer drift.
13854///
13855/// Same "the typed constant lives in one place" discipline the
13856/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
13857/// [`CILIUM_KEY_PORTS`] (1087693) /
13858/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
13859/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
13860/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
13861/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
13862/// [`KUBE_KEY_RULES`] (a205eb3) lifts apply on the peer canonical-
13863/// Gateway-API-HTTPRoute-body-axis surface.
13864///
13865/// [cm]: ../../caixa_mesh/index.html
13866pub const GATEWAY_API_KEY_BACKEND_REFS: &str = "backendRefs";
13867
13868/// Canonical K8s Gateway API `HTTPRoute` per-rule route-match
13869/// container-axis key every `gateway_routes`-emitted `HTTPRoute`
13870/// per-rule block mounts its per-rule `[{path: {type, value}}]`
13871/// route-match fan-out list under (`spec.rules[].matches[]`). Pairs
13872/// with the sibling [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) — the
13873/// Gateway API v1 CRD schema pins per-rule request-selection through
13874/// the `spec.rules[].matches[]` container axis (each entry names one
13875/// `HTTPRouteMatch` predicate the request line + headers + query must
13876/// satisfy for the rule's backend fan-out to apply) alongside the
13877/// per-rule route→Servico backend fan-out under
13878/// `spec.rules[].backendRefs[]`, so drift on the per-rule route-match
13879/// axis is exactly as load-bearing as drift on the sibling per-rule
13880/// backend-destination axis it accompanies (the K8s apiserver-side
13881/// Gateway API CRD schema validator drops any per-rule block whose
13882/// route-match container axis carries an unrecognized key — a
13883/// `"match"` / `"routeMatches"` / `"predicates"` typo silently emits
13884/// an `HTTPRoute` whose per-rule request-selection axis the Gateway
13885/// API implementation's per-rule L7 dispatch loop no-ops entirely: no
13886/// request predicate is evaluated, the rule matches every request
13887/// unconditionally at the wildcard predicate, and every external
13888/// `:entrada` path filter the rule was authored to enforce drops at
13889/// the gateway-class-controller's per-rule reconcile with no field
13890/// naming the route-match-axis-drift root cause).
13891///
13892/// The single source of truth the rendered Aplicacao Gateway-API-side
13893/// ingress bundle's per-HTTPRoute per-rule route-match-axis-naming
13894/// reaches for:
13895///
13896/// - the rendered `HTTPRoute` document's per-rule
13897/// `spec.rules[].matches[]` axis (caixa-mesh/src/lib.rs — the
13898/// `gateway_routes` per-Aplicacao HTTPRoute's per-rule
13899/// `rule.insert("matches", …)` call seeded from the Aplicacao's
13900/// `:entrada :paths` slot).
13901///
13902/// The per-rule route-match container axis names the same Gateway-
13903/// API-implementation-side per-rule request-selection predicate fan-
13904/// out container as the sibling [`GATEWAY_API_KEY_BACKEND_REFS`]
13905/// per-rule backend-destination container axis it accompanies, and
13906/// must move together on any future Gateway API rebrand (an upstream
13907/// SIG-Network Gateway API v2 rename of the route-match axis from
13908/// `matches` to `match` / `routeMatches` / `predicates`, coordinated
13909/// with the Gateway API deprecation cycle). Until this lift landed
13910/// the axis carried an inline `matches` literal at the one
13911/// production-code occurrence in caixa-mesh/src/lib.rs (the
13912/// `gateway_routes` per-rule `rule.insert("matches", …)` call) plus
13913/// a matching test-fixture navigation inside the in-file
13914/// `httproute_rule_keys_pin_overlay_position` pin's
13915/// `contains_key("matches")` presence assertion — two occurrences of
13916/// the same load-bearing Gateway-API-CRD-`matches`-axis-key
13917/// convention, drift-prone by construction. A drift on the
13918/// production site to `"match"` / `"routeMatches"` / `"predicates"`
13919/// would have surfaced as a Gateway API implementation-side schema
13920/// validator drop at apply time (the affected per-rule route-match
13921/// axis the CRD schema validator recognizes as unknown), with the
13922/// per-rule request predicate degrading to the wildcard match at the
13923/// gateway-class-controller's per-rule reconcile with no field
13924/// naming the route-match-drift root cause. A drift on the test-
13925/// fixture side silently masks the emission-side pin
13926/// (`contains_key("matches")` returns `false` under both the
13927/// drifted-key emitter and the drifted-key probe).
13928///
13929/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
13930/// "every recurring shape becomes a generator before it becomes a
13931/// pattern; every pattern becomes a library before it becomes
13932/// duplicated code. The duplication budget is zero.") promotes the
13933/// constant to a typed substrate-side `&'static str` on the same
13934/// trajectory the [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
13935/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
13936/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
13937/// [`GATEWAY_API_KEY_HOSTNAMES`] (b77f744) /
13938/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
13939/// [`GATEWAY_API_KEY_TIMEOUTS`] (db31108) /
13940/// [`GATEWAY_API_KEY_RETRY`] (231bbf5) lifts established on the
13941/// sibling canonical-Gateway-API-HTTPRoute-body-axis surface —
13942/// completes the per-rule top-level-axis lifted-string set
13943/// (`matches`, `backendRefs`, `timeouts`, `retry`) the
13944/// `httproute_rule_keys_pin_overlay_position` pin binds against, so
13945/// every one of the four per-rule top-level axes now threads a
13946/// lifted `&'static str` apiece. The render-side consumer now
13947/// threads the same `&'static str` through its `rule.insert(…)`
13948/// call so a future Gateway API rebrand on the per-rule route-match
13949/// axis (or an upstream SIG-Network Gateway API v2 rename to a
13950/// per-CRD sibling name) lands in one place; every future renderer
13951/// that reaches for the canonical per-HTTPRoute per-rule route-match
13952/// axis (the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
13953/// materializer's per-Aplicacao `HTTPRoute` fan-out, a future
13954/// per-edge `GRPCRoute` renderer whose per-rule request-match
13955/// predicate nests under the same axis convention, a future
13956/// per-route header-match / query-match renderer whose per-predicate
13957/// list binds against this same axis) inherits the same value by
13958/// construction with no opportunity for per-renderer drift.
13959///
13960/// Same "the typed constant lives in one place" discipline the
13961/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
13962/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
13963/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
13964/// [`GATEWAY_API_KEY_HOSTNAMES`] (b77f744) /
13965/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
13966/// [`GATEWAY_API_KEY_TIMEOUTS`] (db31108) /
13967/// [`GATEWAY_API_KEY_RETRY`] (231bbf5) lifts apply on the peer
13968/// canonical-Gateway-API-HTTPRoute-per-rule-body-axis surface.
13969///
13970/// [cm]: ../../caixa_mesh/index.html
13971pub const GATEWAY_API_KEY_MATCHES: &str = "matches";
13972
13973/// Canonical K8s Gateway API `Gateway` per-listener-set container-axis
13974/// key every `gateway_routes`-emitted `Gateway` document mounts its
13975/// per-Gateway `[{name, port, protocol, hostname}]` L7-listener fan-out
13976/// list under (`spec.listeners[]`). Pairs with the sibling
13977/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) +
13978/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) — the Gateway API v1 CRD
13979/// schema pins the per-Gateway L7-listener fan-out through the
13980/// `spec.listeners[]` container axis (each entry names one listener the
13981/// Gateway accepts external traffic on; the sibling
13982/// `spec.parentRefs[]` + `spec.rules[].backendRefs[]` container axes
13983/// carry the per-HTTPRoute parent-Gateway attachment + per-rule
13984/// backend-destination fan-out halves under the paired `HTTPRoute`
13985/// `spec` block), so drift on the per-Gateway L7-listener-set axis is
13986/// exactly as load-bearing as drift on the per-HTTPRoute parent-Gateway-
13987/// binding + per-rule backend-destination axes it accompanies (the K8s
13988/// apiserver-side Gateway API CRD schema validator drops any `spec`
13989/// block whose L7-listener-set container axis carries an unrecognized
13990/// key — a `"listener"` / `"listen"` / `"servers"` typo silently emits
13991/// a `Gateway` whose L7-listener fan-out the Gateway API
13992/// implementation's per-Gateway reconcile loop no-ops entirely: no
13993/// listener is opened, and every external `:entrada` flow the Gateway
13994/// was authored to accept drops at the gateway-class-controller's per-
13995/// Gateway HTTP-listener fan-in with no field naming the L7-listener-
13996/// set-axis-drift root cause).
13997///
13998/// The single source of truth the rendered Aplicacao Gateway-API-side
13999/// ingress bundle's per-Gateway L7-listener-set-axis-naming reaches
14000/// for:
14001///
14002/// - the rendered `Gateway` document's `spec.listeners[]` axis
14003/// (caixa-mesh/src/lib.rs — the `gateway_routes` per-Aplicacao
14004/// `Gateway`'s `g_spec.insert("listeners", …)` call).
14005///
14006/// The per-Gateway L7-listener-set container axis names the same
14007/// Gateway-API-implementation-side per-Gateway inbound-traffic-
14008/// acceptance-vector fan-out container as the sibling
14009/// [`GATEWAY_API_KEY_PARENT_REFS`] per-HTTPRoute parent-Gateway-binding
14010/// container axis + [`GATEWAY_API_KEY_BACKEND_REFS`] per-rule backend-
14011/// destination container axis it accompanies, and must move together
14012/// on any future Gateway API rebrand (an upstream SIG-Network Gateway
14013/// API v2 rename of the L7-listener-set axis from `listeners` to
14014/// `servers` / `endpoints` / `bindings`, coordinated with the Gateway
14015/// API deprecation cycle). Until this lift landed the axis carried an
14016/// inline `listeners` literal at the one production-code occurrence in
14017/// caixa-mesh/src/lib.rs (the `gateway_routes` per-Aplicacao Gateway's
14018/// `g_spec.insert("listeners", …)` call) plus a matching test-fixture
14019/// navigation inside the in-file `gateway_listener_carries_aplicacao_host`
14020/// pin's `.get("listeners")` traversal — two occurrences of the same
14021/// load-bearing Gateway-API-CRD-`listeners`-axis-key convention, drift-
14022/// prone by construction. A drift on the production site to
14023/// `"listener"` / `"listen"` / `"servers"` would have surfaced as a
14024/// Gateway API implementation-side schema validator drop at apply time
14025/// (the affected `Gateway`'s L7-listener-set axis the CRD schema
14026/// validator recognizes as unknown), with every external `:entrada`
14027/// flow the Gateway was authored to accept dropping at the gateway-
14028/// class-controller's per-Gateway reconcile with no field naming the
14029/// L7-listener-set-drift root cause. A drift on the test-fixture side
14030/// silently masks the emission-side pin (`.get("listeners")` returns
14031/// `None` under both the drifted-key emitter and the drifted-key probe
14032/// — the downstream `.and_then(|l| l.as_sequence())` /
14033/// `.and_then(|s| s.first())` chain short-circuits vacuously because
14034/// the outer per-Gateway L7-listener-set lookup is itself `None`).
14035///
14036/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
14037/// "every recurring shape becomes a generator before it becomes a
14038/// pattern; every pattern becomes a library before it becomes
14039/// duplicated code. The duplication budget is zero.") promotes the
14040/// constant to a typed substrate-side `&'static str` on the same
14041/// trajectory the [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
14042/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
14043/// [`CILIUM_KEY_PORTS`] (1087693) /
14044/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
14045/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
14046/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
14047/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
14048/// [`KUBE_KEY_RULES`] (a205eb3) lifts established on the sibling
14049/// canonical-Gateway-API-HTTPRoute-body-axis /
14050/// canonical-Cilium-CNP-body-axis surfaces — pivots the per-HTTPRoute-
14051/// body-axis lift discipline onto the sibling per-Gateway-body-axis
14052/// surface, extending the per-Gateway-API-CRD-body-axis canonical-
14053/// string-pin set (`parentRefs`, `backendRefs`, `listeners`, future
14054/// `hostnames`) the M3 Aplicacao mesh renderer's external `:entrada`
14055/// ingress contract rests on across the Gateway API CRD-side body-
14056/// shape. The render-side consumer now threads the same `&'static
14057/// str` through its `g_spec.insert(…)` call so a future Gateway API
14058/// rebrand on the L7-listener-set axis (or an upstream SIG-Network
14059/// Gateway API v2 rename to a per-CRD sibling name) lands in one
14060/// place; every future renderer that reaches for the canonical per-
14061/// Gateway L7-listener-set axis (the future M4
14062/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
14063/// `Gateway` fan-out, a future per-cluster `GatewayClass` /
14064/// `ReferenceGrant` renderer whose per-Gateway listener-set enumeration
14065/// binds against this same axis, a future per-listener TLS terminator
14066/// renderer whose per-listener `tls.mode: Terminate` overlay nests
14067/// under the same axis convention) inherits the same value by
14068/// construction with no opportunity for per-renderer drift.
14069///
14070/// Same "the typed constant lives in one place" discipline the
14071/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
14072/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
14073/// [`CILIUM_KEY_PORTS`] (1087693) /
14074/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
14075/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
14076/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
14077/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
14078/// [`KUBE_KEY_RULES`] (a205eb3) lifts apply on the peer canonical-
14079/// Gateway-API-Gateway-body-axis surface.
14080///
14081/// [cm]: ../../caixa_mesh/index.html
14082pub const GATEWAY_API_KEY_LISTENERS: &str = "listeners";
14083
14084/// Canonical K8s Gateway API `Gateway` per-listener DNS-host-discriminator
14085/// axis key every `gateway_routes`-emitted `Gateway` document mounts each
14086/// listener's virtual-host name under
14087/// (`spec.listeners[].hostname`). Pairs with the sibling
14088/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) — the Gateway API v1 CRD schema
14089/// pins the per-Gateway L7-listener-set fan-out through the
14090/// `spec.listeners[]` container axis (each entry names one listener the
14091/// Gateway accepts external traffic on) and pins each entry's per-listener
14092/// DNS-host discriminator under the nested `hostname` axis (Gateway API v1
14093/// `Listener.hostname` — `PreciseHostname` string, optional per-listener
14094/// virtual-host filter the Gateway-API-implementation-side per-Gateway
14095/// reconcile loop honors when routing external inbound traffic against
14096/// SNI at the TLS handshake / `Host:` header at the HTTP request line), so
14097/// drift on the per-listener DNS-host discriminator axis is exactly as
14098/// load-bearing as drift on the per-Gateway L7-listener-set container
14099/// axis it nests under (the K8s apiserver-side Gateway API CRD schema
14100/// validator drops any per-listener entry whose DNS-host discriminator
14101/// axis carries an unrecognized key — a `"host"` / `"vhost"` /
14102/// `"serverName"` typo silently emits a `Gateway` whose per-listener
14103/// virtual-host filter the Gateway API implementation's per-listener SNI /
14104/// `Host:` header dispatch loop no-ops entirely: the listener accepts
14105/// traffic on the wildcard host rather than the typed `:entrada :host`
14106/// the Aplicacao author declared, and every external `:entrada` flow the
14107/// listener was authored to accept lands on the wrong virtual-host filter
14108/// with no field naming the DNS-host-discriminator-axis-drift root
14109/// cause).
14110///
14111/// The single source of truth the rendered Aplicacao Gateway-API-side
14112/// ingress bundle's per-Gateway per-listener DNS-host-discriminator-axis-
14113/// naming reaches for:
14114///
14115/// - the rendered `Gateway` document's `spec.listeners[].hostname` axis
14116/// (caixa-mesh/src/lib.rs — the `gateway_routes` per-Aplicacao
14117/// `Gateway`'s per-listener `listener.insert("hostname", …)` call
14118/// seeded from the Aplicacao's `:entrada :host` slot).
14119///
14120/// The per-listener DNS-host discriminator axis names the same Gateway-
14121/// API-implementation-side per-listener virtual-host filter container as
14122/// the sibling [`GATEWAY_API_KEY_LISTENERS`] per-Gateway L7-listener-set
14123/// container axis it nests under, and must move together on any future
14124/// Gateway API rebrand (an upstream SIG-Network Gateway API v2 rename of
14125/// the per-listener DNS-host discriminator axis from `hostname` to `host`
14126/// / `vhost` / `serverName`, coordinated with the Gateway API deprecation
14127/// cycle). Until this lift landed the axis carried an inline `hostname`
14128/// literal at the one production-code occurrence in caixa-mesh/src/lib.rs
14129/// (the `gateway_routes` per-Aplicacao Gateway's per-listener
14130/// `listener.insert("hostname", …)` call) plus a matching test-fixture
14131/// navigation inside the in-file `gateway_listener_carries_aplicacao_host`
14132/// pin's `.get("hostname")` traversal — two occurrences of the same load-
14133/// bearing Gateway-API-CRD-`hostname`-axis-key convention, drift-prone by
14134/// construction. A drift on the production site to `"host"` / `"vhost"` /
14135/// `"serverName"` would have surfaced as a Gateway API implementation-
14136/// side schema validator drop at apply time (the affected listener's per-
14137/// listener DNS-host discriminator axis the CRD schema validator
14138/// recognizes as unknown), with every external `:entrada` flow landing on
14139/// the wildcard virtual-host filter rather than the typed `:entrada
14140/// :host` at the gateway-class-controller's per-listener dispatch with no
14141/// field naming the DNS-host-discriminator-drift root cause. A drift on
14142/// the test-fixture side silently masks the emission-side pin
14143/// (`.get("hostname")` returns `None` under both the drifted-key emitter
14144/// and the drifted-key probe — the downstream `.and_then(|h| h.as_str())`
14145/// chain short-circuits vacuously because the outer per-listener DNS-
14146/// host discriminator lookup is itself `None`).
14147///
14148/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
14149/// "every recurring shape becomes a generator before it becomes a
14150/// pattern; every pattern becomes a library before it becomes
14151/// duplicated code. The duplication budget is zero.") promotes the
14152/// constant to a typed substrate-side `&'static str` on the same
14153/// trajectory the [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
14154/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
14155/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
14156/// [`CILIUM_KEY_PORTS`] (1087693) /
14157/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
14158/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
14159/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
14160/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
14161/// [`KUBE_KEY_RULES`] (a205eb3) lifts established on the sibling
14162/// canonical-Gateway-API-CRD-body-axis /
14163/// canonical-Cilium-CNP-body-axis surfaces — nests the per-Gateway-API-
14164/// CRD-body-axis lift discipline one level deeper onto the sibling per-
14165/// listener body-axis surface, extending the per-Gateway-API-CRD-body-
14166/// axis canonical-string-pin set (`parentRefs`, `backendRefs`,
14167/// `listeners`, `hostname`, future `hostnames`) the M3 Aplicacao mesh
14168/// renderer's external `:entrada` ingress contract rests on across the
14169/// Gateway API CRD-side body-shape. The render-side consumer now threads
14170/// the same `&'static str` through its per-listener `listener.insert(…)`
14171/// call so a future Gateway API rebrand on the per-listener DNS-host
14172/// discriminator axis (or an upstream SIG-Network Gateway API v2 rename
14173/// to a per-CRD sibling name) lands in one place; every future renderer
14174/// that reaches for the canonical per-listener DNS-host discriminator
14175/// axis (the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
14176/// materializer's per-Aplicacao `Gateway` fan-out, a future per-listener
14177/// TLS terminator renderer whose per-listener `tls.certificateRefs[]`
14178/// resolution keys off the same per-listener virtual-host filter, a
14179/// future per-cluster wildcard-host `Gateway` renderer whose per-listener
14180/// SNI wildcard `*.example.com` matcher binds against this same axis)
14181/// inherits the same value by construction with no opportunity for per-
14182/// renderer drift.
14183///
14184/// Same "the typed constant lives in one place" discipline the
14185/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
14186/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
14187/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
14188/// [`CILIUM_KEY_PORTS`] (1087693) /
14189/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
14190/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
14191/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
14192/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
14193/// [`KUBE_KEY_RULES`] (a205eb3) lifts apply on the peer canonical-
14194/// Gateway-API-Gateway-per-listener-body-axis surface.
14195///
14196/// [cm]: ../../caixa_mesh/index.html
14197pub const GATEWAY_API_KEY_HOSTNAME: &str = "hostname";
14198
14199/// Canonical K8s Gateway API `HTTPRoute` spec-level DNS-host-filter axis key
14200/// every `gateway_routes`-emitted `HTTPRoute` document mounts the route's
14201/// per-route virtual-host filter list under (`spec.hostnames[]`). The
14202/// plural sibling of [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) — same
14203/// Gateway-API-CRD DNS-host-discriminator convention nested one level up on
14204/// the sibling `HTTPRoute` per-route body-axis surface, distinct spelling
14205/// (`hostnames` — plural — is the `HTTPRoute` spec-level filter list; the
14206/// singular `hostname` axis it pairs against is the per-`Gateway`-listener
14207/// virtual-host discriminator).
14208///
14209/// The Gateway API v1 CRD schema pins the per-`HTTPRoute` DNS-host filter
14210/// through the spec-level `hostnames[]` container axis (a list of DNS
14211/// `PreciseHostname` strings, each one an additional virtual-host filter
14212/// the Gateway-API-implementation-side per-route reconcile loop honors
14213/// when routing external inbound traffic against SNI at the TLS handshake
14214/// / `Host:` header at the HTTP request line and against the sibling
14215/// [`GATEWAY_API_KEY_PARENT_REFS`]-declared parent Gateway's per-listener
14216/// [`GATEWAY_API_KEY_HOSTNAME`] filter set). Drift on the per-route DNS-
14217/// host filter axis is exactly as load-bearing as drift on the sibling
14218/// per-listener DNS-host discriminator axis (`hostname`): the K8s
14219/// apiserver-side Gateway API CRD schema validator drops any per-route
14220/// entry whose DNS-host-filter axis carries an unrecognized key — a
14221/// `"hosts"` / `"vhosts"` / `"serverNames"` typo silently emits an
14222/// `HTTPRoute` whose per-route virtual-host filter list the Gateway API
14223/// implementation's per-route SNI / `Host:` header dispatch loop no-ops
14224/// entirely: the route accepts traffic on every host the parent Gateway's
14225/// listener accepts rather than the typed `:entrada :host` the Aplicacao
14226/// author declared, and every external `:entrada` flow the route was
14227/// authored to accept lands on the wildcard virtual-host filter with no
14228/// field naming the DNS-host-filter-axis-drift root cause.
14229///
14230/// The single source of truth the rendered Aplicacao Gateway-API-side
14231/// ingress bundle's per-`HTTPRoute` spec-level DNS-host-filter-axis-naming
14232/// reaches for:
14233///
14234/// - the rendered `HTTPRoute` document's `spec.hostnames[]` axis
14235/// (caixa-mesh/src/lib.rs — the `gateway_routes` per-Aplicacao
14236/// `HTTPRoute`'s spec-level `r_spec.insert("hostnames", …)` call
14237/// seeded from the Aplicacao's `:entrada :host` slot as a
14238/// single-element sequence).
14239///
14240/// The per-route DNS-host filter axis names the same Gateway-API-
14241/// implementation-side per-route virtual-host filter list container as the
14242/// sibling [`GATEWAY_API_KEY_PARENT_REFS`] per-route parent-Gateway-
14243/// binding container axis it sits beside under `spec.*`, and must move
14244/// together on any future Gateway API rebrand (an upstream SIG-Network
14245/// Gateway API v2 rename of the per-route DNS-host filter axis from
14246/// `hostnames` to `hosts` / `vhosts` / `serverNames`, coordinated with
14247/// the Gateway API deprecation cycle). Until this lift landed the axis
14248/// carried an inline `hostnames` literal at the one production-code
14249/// occurrence in caixa-mesh/src/lib.rs (the `gateway_routes` per-
14250/// Aplicacao `HTTPRoute`'s spec-level `r_spec.insert("hostnames", …)`
14251/// call) — one occurrence today, but the sibling per-Gateway-API-CRD-
14252/// body-axis lifts ([`GATEWAY_API_KEY_LISTENERS`] / [`GATEWAY_API_KEY_HOSTNAME`]
14253/// / [`GATEWAY_API_KEY_PARENT_REFS`] / [`GATEWAY_API_KEY_BACKEND_REFS`])
14254/// each closed on the same one-production-emitter-plus-future-test-
14255/// fixture shape before a future per-route DNS-host-filter navigator
14256/// picked up the second occurrence, and the same lift-before-the-second-
14257/// site discipline applies here.
14258///
14259/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
14260/// "every recurring shape becomes a generator before it becomes a
14261/// pattern; every pattern becomes a library before it becomes
14262/// duplicated code. The duplication budget is zero.") promotes the
14263/// constant to a typed substrate-side `&'static str` on the same
14264/// trajectory the [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
14265/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
14266/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
14267/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
14268/// [`CILIUM_KEY_PORTS`] (1087693) /
14269/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
14270/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
14271/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
14272/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
14273/// [`KUBE_KEY_RULES`] (a205eb3) lifts established on the sibling
14274/// canonical-Gateway-API-CRD-body-axis /
14275/// canonical-Cilium-CNP-body-axis surfaces — closes the per-Gateway-API-
14276/// CRD `HTTPRoute` per-route body-axis lift pair across the singular /
14277/// plural DNS-host discriminator surface (`hostname` at the parent-
14278/// Gateway per-listener discriminator + `hostnames` at the child
14279/// HTTPRoute per-route filter list), so both halves of the DNS-host
14280/// discriminator convention across the `(Gateway, HTTPRoute)` pair the
14281/// M3 Aplicacao mesh renderer's external `:entrada` ingress contract
14282/// emits together now live as one lifted `&'static str` apiece. The
14283/// render-side consumer now threads the same `&'static str` through its
14284/// spec-level `r_spec.insert(…)` call so a future Gateway API rebrand on
14285/// the per-route DNS-host filter axis (or an upstream SIG-Network
14286/// Gateway API v2 rename to a per-CRD sibling name) lands in one place;
14287/// every future renderer that reaches for the canonical per-route DNS-
14288/// host filter axis (the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
14289/// materializer's per-Aplicacao `HTTPRoute` fan-out, a future per-route
14290/// wildcard-host `*.example.com` filter emitter, a future per-Aplicacao
14291/// multi-`:entrada` `HTTPRoute` fan-out whose per-route DNS-host filter
14292/// lists partition inbound traffic across the same parent Gateway's
14293/// per-listener discriminator) inherits the same value by construction
14294/// with no opportunity for per-renderer drift.
14295///
14296/// Same "the typed constant lives in one place" discipline the
14297/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
14298/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
14299/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
14300/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
14301/// [`CILIUM_KEY_PORTS`] (1087693) /
14302/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
14303/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
14304/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
14305/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
14306/// [`KUBE_KEY_RULES`] (a205eb3) lifts apply on the peer canonical-
14307/// Gateway-API-HTTPRoute-per-route-body-axis surface.
14308///
14309/// [cm]: ../../caixa_mesh/index.html
14310pub const GATEWAY_API_KEY_HOSTNAMES: &str = "hostnames";
14311
14312/// Canonical K8s Gateway API `HTTPRoute` per-rule request-timeout-policy
14313/// body-axis key every `gateway_routes`-emitted `HTTPRoute` document mounts
14314/// its per-rule `:politicas :timeout` overlay under
14315/// (`spec.rules[].timeouts`). Sibling per-rule-body-axis peer to
14316/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) and
14317/// [`GATEWAY_API_KEY_HOSTNAMES`] (b77f744) — same Gateway-API-CRD-body-axis
14318/// discipline nested one level deeper onto the per-rule request-deadline
14319/// slot the Gateway API v1 CRD schema pins under `HTTPRoute.spec.rules[]`.
14320///
14321/// The Gateway API v1 CRD schema pins the per-rule request-timeout policy
14322/// through the `HTTPRouteTimeouts` sub-shape mounted at
14323/// `spec.rules[].timeouts`, whose `request` / `backendRequest` scalars
14324/// carry the per-rule deadline the Gateway-API-implementation-side per-
14325/// rule request-dispatch loop compares each accepted request's
14326/// wall-clock elapsed time against before cancelling the in-flight
14327/// backend call. Drift on the per-rule timeout-policy body-axis is
14328/// exactly as load-bearing as drift on the sibling per-rule backend-
14329/// destination axis (`backendRefs`): the K8s apiserver-side Gateway API
14330/// CRD schema validator drops any per-rule entry whose per-rule
14331/// timeout-policy axis carries an unrecognized key — a
14332/// `"timeout"` (singular) / `"timeoutPolicy"` / `"deadlines"` typo
14333/// silently emits an `HTTPRoute` whose per-rule timeout-policy the
14334/// Gateway API implementation's per-rule request-dispatch loop no-ops
14335/// entirely: the route accepts every inbound request with no per-rule
14336/// wall-clock deadline (the "no infinite blocking" guarantee
14337/// MESH-COMPOSITION.md §V mandates for every rendered per-`:politicas`
14338/// mesh-composition edge silently regresses to the pre-overlay
14339/// unbounded-request semantic, and every external `:entrada` flow the
14340/// route was authored to bound by the typed `:politicas :timeout` slot
14341/// runs to whatever backend deadline the resolved `ComputeUnit` /
14342/// `Service` / `ExternalName` backend's downstream infrastructure
14343/// (Envoy default listener idle timeout, node-local conntrack window,
14344/// TCP keepalive) picks — with no field naming the per-rule-timeout-
14345/// policy-axis-drift root cause).
14346///
14347/// The single source of truth the rendered Aplicacao Gateway-API-side
14348/// ingress bundle's per-`HTTPRoute` per-rule request-timeout-policy-
14349/// axis-naming reaches for:
14350///
14351/// - the rendered `HTTPRoute` document's per-rule `timeouts:` axis
14352/// (caixa-mesh/src/lib.rs — the `gateway_routes` per-Aplicacao
14353/// `HTTPRoute`'s per-rule `rule.insert("timeouts", …)` call
14354/// seeded from the Aplicacao's `:politicas :timeout` overlay
14355/// when the slot is set, elided from the emit sequence when the
14356/// slot is unset).
14357///
14358/// The per-rule request-timeout-policy axis names the same Gateway-
14359/// API-implementation-side per-rule request-dispatch deadline
14360/// container as the sibling [`GATEWAY_API_KEY_BACKEND_REFS`] per-rule
14361/// backend-destination container axis it sits beside under
14362/// `spec.rules[].*`, and must move together on any future Gateway API
14363/// rebrand (an upstream SIG-Network Gateway API v2 rename of the per-
14364/// rule timeout-policy axis from `timeouts` to `timeout` /
14365/// `timeoutPolicy` / `deadlines`, coordinated with the Gateway API
14366/// deprecation cycle). Until this lift landed the axis carried an
14367/// inline `timeouts` literal at nine physical sites in
14368/// caixa-mesh/src/lib.rs (one production emitter at the
14369/// `gateway_routes` per-rule `rule.insert(…)` call plus eight test-
14370/// side navigators pinning the overlay's presence, absence,
14371/// canonical-duration-format contract, per-rule fan-out under
14372/// multi-`:entrada :paths`, and independent-axis coexistence with the
14373/// sibling `retry` per-rule retry-policy axis), the highest per-axis
14374/// occurrence count of any un-lifted Gateway-API-CRD-body-axis in the
14375/// crate.
14376///
14377/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
14378/// "every recurring shape becomes a generator before it becomes a
14379/// pattern; every pattern becomes a library before it becomes
14380/// duplicated code. The duplication budget is zero.") promotes the
14381/// constant to a typed substrate-side `&'static str` on the same
14382/// trajectory the [`GATEWAY_API_KEY_HOSTNAMES`] (b77f744) /
14383/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
14384/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
14385/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
14386/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
14387/// [`CILIUM_KEY_PORTS`] (1087693) /
14388/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
14389/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
14390/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
14391/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
14392/// [`KUBE_KEY_RULES`] (a205eb3) lifts established on the sibling
14393/// canonical-Gateway-API-CRD-body-axis /
14394/// canonical-Cilium-CNP-body-axis surfaces — extends the per-Gateway-
14395/// API-`HTTPRoute` per-rule body-axis lift set onto the load-bearing
14396/// per-rule request-timeout-policy axis every downstream Gateway-API-
14397/// implementation-side per-rule request-dispatch loop keys off before
14398/// it can commit to a per-request wall-clock deadline. The render-
14399/// side consumer now threads the same `&'static str` through its
14400/// per-rule `rule.insert(…)` call and every test-side navigator's
14401/// `.get(…)` retrieval so a future Gateway API rebrand on the per-
14402/// rule timeout-policy axis (or an upstream SIG-Network Gateway API
14403/// v2 rename to a per-CRD sibling name) lands in one place; every
14404/// future renderer that reaches for the canonical per-rule timeout-
14405/// policy axis (the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
14406/// materializer's per-Aplicacao per-rule timeout-policy fan-out, a
14407/// future per-edge `backendRequest` sub-timeout emitter honoring the
14408/// downstream `:politicas :backend-timeout` slot the M4 roadmap
14409/// acknowledges, a future per-cluster per-rule idle-timeout emitter
14410/// binding against this same axis) inherits the same value by
14411/// construction with no opportunity for per-renderer drift.
14412///
14413/// Same "the typed constant lives in one place" discipline the
14414/// [`GATEWAY_API_KEY_HOSTNAMES`] (b77f744) /
14415/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
14416/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
14417/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
14418/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
14419/// [`CILIUM_KEY_PORTS`] (1087693) /
14420/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
14421/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
14422/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
14423/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
14424/// [`KUBE_KEY_RULES`] (a205eb3) lifts apply on the peer canonical-
14425/// Gateway-API-HTTPRoute-per-rule-body-axis surface.
14426///
14427/// [cm]: ../../caixa_mesh/index.html
14428pub const GATEWAY_API_KEY_TIMEOUTS: &str = "timeouts";
14429
14430/// Canonical K8s Gateway API `HTTPRoute` per-rule retry-policy body-axis
14431/// key every `gateway_routes`-emitted `HTTPRoute` document mounts its
14432/// per-rule `:politicas :retries` overlay under (`spec.rules[].retry`).
14433/// Sibling per-rule-body-axis peer to [`GATEWAY_API_KEY_TIMEOUTS`]
14434/// (db31108) — same Gateway-API-CRD-body-axis discipline nested onto the
14435/// per-rule retry-budget slot the Gateway API v1 CRD schema pins under
14436/// `HTTPRoute.spec.rules[]` beside the sibling per-rule request-timeout-
14437/// policy container.
14438///
14439/// The Gateway API v1 CRD schema pins the per-rule retry policy through
14440/// the `HTTPRouteRetry` sub-shape mounted at `spec.rules[].retry`, whose
14441/// `attempts` scalar (peer to future `codes` retryable-status-code list
14442/// and `backoff` inter-attempt backoff-window scalars) carries the per-
14443/// rule retry-budget the Gateway-API-implementation-side per-rule
14444/// request-dispatch loop compares each failed attempt count against
14445/// before giving up on the in-flight backend call. Drift on the per-rule
14446/// retry-policy body-axis is exactly as load-bearing as drift on the
14447/// sibling per-rule request-timeout-policy axis (`timeouts`): the K8s
14448/// apiserver-side Gateway API CRD schema validator drops any per-rule
14449/// entry whose per-rule retry-policy axis carries an unrecognized key —
14450/// a `"retries"` (plural) / `"retryPolicy"` / `"budget"` typo silently
14451/// emits an `HTTPRoute` whose per-rule retry-budget the Gateway API
14452/// implementation's per-rule request-dispatch loop no-ops entirely: the
14453/// route accepts every inbound request with no per-rule retry budget
14454/// (the "no infinite retrying without bound" guarantee
14455/// MESH-COMPOSITION.md §V mandates for every rendered per-`:politicas`
14456/// mesh-composition edge silently regresses to the pre-overlay
14457/// unbounded-retry semantic, and every external `:entrada` flow the
14458/// route was authored to cap by the typed `:politicas :retries` slot
14459/// runs to whatever retry policy the resolved `ComputeUnit` /
14460/// `Service` / `ExternalName` backend's downstream infrastructure —
14461/// Envoy default retry policy, client SDK autoretry, node-local
14462/// conntrack retries — with no field naming the per-rule-retry-policy-
14463/// axis-drift root cause).
14464///
14465/// The single source of truth the rendered Aplicacao Gateway-API-side
14466/// ingress bundle's per-`HTTPRoute` per-rule retry-policy-axis-naming
14467/// reaches for:
14468///
14469/// - the rendered `HTTPRoute` document's per-rule `retry:` axis
14470/// (caixa-mesh/src/lib.rs — the `gateway_routes` per-Aplicacao
14471/// `HTTPRoute`'s per-rule `rule.insert("retry", …)` call seeded
14472/// from the Aplicacao's `:politicas :retries` overlay when the
14473/// slot is set, elided from the emit sequence when the slot is
14474/// unset).
14475///
14476/// The per-rule retry-policy axis names the same Gateway-API-
14477/// implementation-side per-rule request-dispatch retry-budget container
14478/// as the sibling [`GATEWAY_API_KEY_TIMEOUTS`] per-rule request-timeout-
14479/// policy container axis it sits beside under `spec.rules[].*`, and must
14480/// move together on any future Gateway API rebrand (an upstream
14481/// SIG-Network Gateway API v2 rename of the per-rule retry-policy axis
14482/// from `retry` to `retries` / `retryPolicy` / `budget`, coordinated
14483/// with the Gateway API deprecation cycle). Until this lift landed the
14484/// axis carried an inline `retry` literal at nine physical sites in
14485/// caixa-mesh/src/lib.rs (one production emitter at the `gateway_routes`
14486/// per-rule `rule.insert(…)` call plus eight test-side navigators
14487/// pinning the overlay's rule-level top-key-set, presence, absence,
14488/// per-rule fan-out under multi-`:entrada :paths`, round-trip of the
14489/// typed `u32` attempt count, YAML integer scalar-kind, and independent-
14490/// axis coexistence with the sibling `timeouts` per-rule request-
14491/// timeout-policy axis in both directions), the highest per-axis
14492/// occurrence count of any un-lifted Gateway-API-CRD-body-axis in the
14493/// crate — same nine-site count the peer sibling
14494/// [`GATEWAY_API_KEY_TIMEOUTS`] lift closed on the coexisting per-rule
14495/// request-timeout-policy axis.
14496///
14497/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
14498/// "every recurring shape becomes a generator before it becomes a
14499/// pattern; every pattern becomes a library before it becomes
14500/// duplicated code. The duplication budget is zero.") promotes the
14501/// constant to a typed substrate-side `&'static str` on the same
14502/// trajectory the [`GATEWAY_API_KEY_TIMEOUTS`] (db31108) /
14503/// [`GATEWAY_API_KEY_HOSTNAMES`] (b77f744) /
14504/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
14505/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
14506/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
14507/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
14508/// [`CILIUM_KEY_PORTS`] (1087693) /
14509/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
14510/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
14511/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
14512/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
14513/// [`KUBE_KEY_RULES`] (a205eb3) lifts established on the sibling
14514/// canonical-Gateway-API-CRD-body-axis /
14515/// canonical-Cilium-CNP-body-axis surfaces — closes the pair of per-
14516/// Gateway-API-`HTTPRoute`-per-rule `:politicas` overlay axes
14517/// (`timeouts` for `:politicas :timeout`, `retry` for `:politicas
14518/// :retries`) both MESH-COMPOSITION.md §V "no infinite blocking / no
14519/// infinite retrying" guarantees rest on. The render-side consumer now
14520/// threads the same `&'static str` through its per-rule
14521/// `rule.insert(…)` call and every test-side navigator's `.get(…)`
14522/// retrieval so a future Gateway API rebrand on the per-rule retry-
14523/// policy axis lands in one place; every future renderer that reaches
14524/// for the canonical per-rule retry-policy axis (the future M4
14525/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
14526/// per-rule retry-policy fan-out, a future per-edge `codes`
14527/// retryable-status-code emitter honoring an M4-roadmap `:politicas
14528/// :retry-codes` slot, a future per-edge `backoff` inter-attempt
14529/// backoff-window emitter honoring an M4-roadmap `:politicas
14530/// :retry-backoff` slot) inherits the same value by construction with
14531/// no opportunity for per-renderer drift.
14532///
14533/// Same "the typed constant lives in one place" discipline the
14534/// [`GATEWAY_API_KEY_TIMEOUTS`] (db31108) /
14535/// [`GATEWAY_API_KEY_HOSTNAMES`] (b77f744) /
14536/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
14537/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
14538/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
14539/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
14540/// [`CILIUM_KEY_PORTS`] (1087693) /
14541/// [`CILIUM_KEY_FROM_ENDPOINTS`] (ecfa557) /
14542/// [`CILIUM_KEY_INGRESS`] (0400a9b) /
14543/// [`CILIUM_KEY_ENDPOINT_SELECTOR`] (7088789) /
14544/// [`CILIUM_KEY_TO_PORTS`] (c8d9cbf) /
14545/// [`KUBE_KEY_RULES`] (a205eb3) lifts apply on the peer canonical-
14546/// Gateway-API-HTTPRoute-per-rule-body-axis surface.
14547///
14548/// [cm]: ../../caixa_mesh/index.html
14549pub const GATEWAY_API_KEY_RETRY: &str = "retry";
14550
14551/// Canonical K8s Gateway API `HTTPRoute` per-rule retry-policy `attempts`
14552/// leaf scalar-key every `gateway_routes`-emitted `HTTPRoute` document
14553/// mounts its per-rule `:politicas :retries` typed `u32` attempt count
14554/// under (`spec.rules[].retry.attempts`). Leaf peer to the container-axis
14555/// parent [`GATEWAY_API_KEY_RETRY`] (231bbf5) — the sibling per-rule
14556/// retry-policy body-axis lifted in the immediately-preceding commit;
14557/// this closes the parent-leaf axis pair (`retry` container +
14558/// `attempts` leaf) the Gateway API v1 `HTTPRouteRetry` sub-shape pins
14559/// under `HTTPRoute.spec.rules[].retry.attempts`.
14560///
14561/// The Gateway API v1 CRD schema pins the per-rule retry attempt budget
14562/// through the `HTTPRouteRetry.attempts` scalar (peer to future
14563/// `HTTPRouteRetry.codes` retryable-status-code list and
14564/// `HTTPRouteRetry.backoff` inter-attempt backoff-window scalars) the
14565/// Gateway-API-implementation-side per-rule request-dispatch loop
14566/// compares each failed backend attempt count against before giving up
14567/// on the in-flight backend call. Drift on this leaf key is exactly as
14568/// load-bearing as drift on the parent per-rule retry-policy container
14569/// axis (`retry`): the K8s apiserver-side Gateway API CRD schema
14570/// validator drops any per-rule `retry:` entry whose leaf attempt-count
14571/// key carries an unrecognized name — a `"attempt"` (singular) /
14572/// `"count"` / `"tries"` / `"maxAttempts"` typo silently emits an
14573/// `HTTPRoute` whose per-rule retry-budget the Gateway-API-
14574/// implementation-side per-rule request-dispatch loop no-ops entirely
14575/// (the sub-shape is parsed as an empty `HTTPRouteRetry` with the
14576/// typed `u32` attempt count silently discarded, the route accepts
14577/// every inbound request with no per-rule retry budget — the "no
14578/// infinite retrying without bound" guarantee MESH-COMPOSITION.md §V
14579/// mandates for every rendered per-`:politicas` mesh-composition edge
14580/// silently regresses to the pre-overlay unbounded-retry semantic,
14581/// and every external `:entrada` flow the route was authored to cap
14582/// by the typed `:politicas :retries` slot runs to whatever retry
14583/// policy the resolved backend's downstream infrastructure — Envoy
14584/// default retry policy, client SDK autoretry, node-local conntrack
14585/// retries — picks with no field naming the per-rule-retry-attempts-
14586/// leaf-key drift root cause).
14587///
14588/// The single source of truth the rendered Aplicacao Gateway-API-side
14589/// ingress bundle's per-`HTTPRoute` per-rule retry-attempts-leaf-key-
14590/// naming reaches for:
14591///
14592/// - the rendered `HTTPRoute` document's per-rule
14593/// `retry.attempts:` leaf (caixa-mesh/src/lib.rs — the
14594/// `gateway_routes` per-Aplicacao `HTTPRoute`'s per-rule
14595/// `single_field_overlay(spec.politicas.retries, …)` call seeded
14596/// from the Aplicacao's `:politicas :retries` overlay when the
14597/// slot is set, emitting the typed `u32` attempt count under this
14598/// leaf key inside the sibling [`GATEWAY_API_KEY_RETRY`] container
14599/// axis).
14600///
14601/// The per-rule retry-attempts leaf key names the same Gateway-API-
14602/// implementation-side per-rule request-dispatch retry-budget scalar
14603/// as the sibling parent [`GATEWAY_API_KEY_RETRY`] container axis it
14604/// sits nested inside under `spec.rules[].retry.attempts`, and must
14605/// move together with the parent on any future Gateway API rebrand
14606/// (an upstream SIG-Network Gateway API v2 rename of the per-rule
14607/// retry-attempts leaf key from `attempts` to `attempt` / `count` /
14608/// `tries` / `maxAttempts`, coordinated with the Gateway API
14609/// deprecation cycle). Until this lift landed the leaf key carried
14610/// an inline `attempts` literal at six physical code sites in
14611/// caixa-mesh/src/lib.rs (one production emitter at the `gateway_routes`
14612/// per-rule `single_field_overlay(spec.politicas.retries, "attempts", …)`
14613/// call plus five test-side navigators pinning the overlay's leaf-
14614/// count value, round-trip of the typed `u32` attempt count, YAML
14615/// integer scalar-kind, per-rule fan-out under multi-`:entrada
14616/// :paths`, and independent-axis coexistence with the sibling
14617/// `timeouts` per-rule request-timeout-policy axis).
14618///
14619/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
14620/// "every recurring shape becomes a generator before it becomes a
14621/// pattern; every pattern becomes a library before it becomes
14622/// duplicated code. The duplication budget is zero.") promotes the
14623/// constant to a typed substrate-side `&'static str` on the same
14624/// trajectory the [`GATEWAY_API_KEY_RETRY`] (231bbf5) /
14625/// [`GATEWAY_API_KEY_TIMEOUTS`] (db31108) /
14626/// [`GATEWAY_API_KEY_HOSTNAMES`] (b77f744) /
14627/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
14628/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
14629/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
14630/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) lifts established on
14631/// the sibling canonical-Gateway-API-CRD-body-axis surface — closes
14632/// the parent-leaf axis pair (`retry` container +
14633/// `attempts` leaf) the K8s Gateway API v1 `HTTPRouteRetry` sub-shape
14634/// pins under `HTTPRoute.spec.rules[].retry.attempts`, both
14635/// MESH-COMPOSITION.md §V "no infinite retrying" guarantees rest on.
14636/// The render-side consumer now threads the same `&'static str`
14637/// through its `single_field_overlay` call and every test-side
14638/// navigator's `.get(…)` retrieval so a future Gateway API rebrand
14639/// on the per-rule retry-attempts leaf lands in one place; every
14640/// future renderer that reaches for the canonical per-rule retry-
14641/// attempts leaf (the future M4 `mesh.pleme.io/v1alpha1/Aplicacao`
14642/// CR materializer's per-Aplicacao per-rule retry-attempts fan-out)
14643/// inherits the same value by construction with no opportunity for
14644/// per-renderer drift.
14645///
14646/// Same "the typed constant lives in one place" discipline the
14647/// [`GATEWAY_API_KEY_RETRY`] (231bbf5) /
14648/// [`GATEWAY_API_KEY_TIMEOUTS`] (db31108) lifts apply on the peer
14649/// canonical-Gateway-API-HTTPRoute-per-rule-body-axis surface, now
14650/// extended one nesting level deeper onto the retry-container-leaf
14651/// scalar.
14652///
14653/// [cm]: ../../caixa_mesh/index.html
14654pub const GATEWAY_API_KEY_ATTEMPTS: &str = "attempts";
14655
14656/// Canonical K8s Gateway API `HTTPRoute` per-rule request-timeout-policy
14657/// `request` leaf scalar-key every `gateway_routes`-emitted `HTTPRoute`
14658/// document mounts its per-rule `:politicas :timeout` typed K8s-duration
14659/// string under (`spec.rules[].timeouts.request`). Leaf peer to the
14660/// container-axis parent [`GATEWAY_API_KEY_TIMEOUTS`] (db31108) — the
14661/// sibling per-rule request-timeout-policy body-axis — and to the peer
14662/// retry-container leaf [`GATEWAY_API_KEY_ATTEMPTS`] (e2e136b) landed
14663/// on the parallel `retry.attempts` nesting; this closes the parent-leaf
14664/// axis pair (`timeouts` container + `request` leaf) the K8s Gateway API
14665/// v1 `HTTPRouteTimeouts` sub-shape pins under
14666/// `HTTPRoute.spec.rules[].timeouts.request`.
14667///
14668/// The Gateway API v1 CRD schema pins the per-rule request-deadline
14669/// through the `HTTPRouteTimeouts.request` scalar (peer to
14670/// `HTTPRouteTimeouts.backendRequest` per-attempt backend-call deadline
14671/// scalar) the Gateway-API-implementation-side per-rule request-dispatch
14672/// loop keys off before it commits to a per-request wall-clock deadline.
14673/// Drift on this leaf key is exactly as load-bearing as drift on the
14674/// parent per-rule request-timeout-policy container axis (`timeouts`):
14675/// the K8s apiserver-side Gateway API CRD schema validator drops any
14676/// per-rule `timeouts:` entry whose leaf request-deadline key carries an
14677/// unrecognized name — a `"deadline"` / `"requestTimeout"` /
14678/// `"timeout"` / `"upstreamRequest"` typo silently emits an `HTTPRoute`
14679/// whose per-rule request-deadline the Gateway-API-implementation-side
14680/// per-rule request-dispatch loop no-ops entirely (the sub-shape is
14681/// parsed as an empty `HTTPRouteTimeouts` with the typed duration
14682/// silently discarded, the route accepts every inbound request with no
14683/// per-rule request wall-clock deadline — the "no infinite blocking"
14684/// guarantee MESH-COMPOSITION.md §V mandates for every rendered
14685/// per-`:politicas` mesh-composition edge silently regresses to the
14686/// pre-overlay unbounded-blocking semantic, and every external
14687/// `:entrada` flow the route was authored to cap by the typed
14688/// `:politicas :timeout` slot runs to whatever request-deadline the
14689/// resolved backend's downstream infrastructure — Envoy default
14690/// route-timeout, client SDK deadline, node-local conntrack idle-close
14691/// — picks with no field naming the per-rule-request-timeout-leaf-key
14692/// drift root cause).
14693///
14694/// The single source of truth the rendered Aplicacao Gateway-API-side
14695/// ingress bundle's per-`HTTPRoute` per-rule request-deadline-leaf-key-
14696/// naming reaches for:
14697///
14698/// - the rendered `HTTPRoute` document's per-rule
14699/// `timeouts.request:` leaf (caixa-mesh/src/lib.rs — the
14700/// `gateway_routes` per-Aplicacao `HTTPRoute`'s per-rule
14701/// `single_field_overlay(spec.politicas.timeout, …)` call seeded
14702/// from the Aplicacao's `:politicas :timeout` overlay when the slot
14703/// is set, emitting the typed K8s-duration string under this leaf
14704/// key inside the sibling [`GATEWAY_API_KEY_TIMEOUTS`] container
14705/// axis).
14706///
14707/// The per-rule request-deadline leaf key names the same
14708/// Gateway-API-implementation-side per-rule request-dispatch wall-clock
14709/// deadline scalar as the sibling parent [`GATEWAY_API_KEY_TIMEOUTS`]
14710/// container axis it sits nested inside under
14711/// `spec.rules[].timeouts.request`, and must move together with the
14712/// parent on any future Gateway API rebrand (an upstream SIG-Network
14713/// Gateway API v2 rename of the per-rule request-deadline leaf key from
14714/// `request` to `deadline` / `requestTimeout` / `timeout` /
14715/// `upstreamRequest`, coordinated with the Gateway API deprecation
14716/// cycle). Until this lift landed the leaf key carried an inline
14717/// `request` literal at six physical code sites in
14718/// caixa-mesh/src/lib.rs (one production emitter at the
14719/// `gateway_routes` per-rule
14720/// `single_field_overlay(spec.politicas.timeout, "request", …)` call
14721/// plus five test-side navigators pinning the overlay's leaf-value
14722/// presence, the canonical `duration_codec::render` round-trip of a
14723/// 30s / 90s / 1m typed duration, per-rule fan-out under
14724/// multi-`:entrada :paths`, and independent-axis coexistence with the
14725/// sibling `retry` per-rule retry-policy axis).
14726///
14727/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
14728/// "every recurring shape becomes a generator before it becomes a
14729/// pattern; every pattern becomes a library before it becomes
14730/// duplicated code. The duplication budget is zero.") promotes the
14731/// constant to a typed substrate-side `&'static str` on the same
14732/// trajectory the [`GATEWAY_API_KEY_ATTEMPTS`] (e2e136b) /
14733/// [`GATEWAY_API_KEY_RETRY`] (231bbf5) /
14734/// [`GATEWAY_API_KEY_TIMEOUTS`] (db31108) /
14735/// [`GATEWAY_API_KEY_HOSTNAMES`] (b77f744) /
14736/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
14737/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
14738/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
14739/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) lifts established on the
14740/// sibling canonical-Gateway-API-CRD-body-axis surface — closes the
14741/// second parent-leaf axis pair (`timeouts` container + `request` leaf)
14742/// the K8s Gateway API v1 `HTTPRouteTimeouts` sub-shape pins under
14743/// `HTTPRoute.spec.rules[].timeouts.request`, sibling to the parent-
14744/// leaf pair (`retry` container + `attempts` leaf) closed in the
14745/// immediately-preceding [`GATEWAY_API_KEY_ATTEMPTS`] lift. Both
14746/// MESH-COMPOSITION.md §V "no infinite blocking / no infinite retrying"
14747/// guarantees now rest on typed lifts at both container-axis and leaf-
14748/// scalar-axis nesting levels of the two per-`:politicas` overlays.
14749/// The render-side consumer now threads the same `&'static str`
14750/// through its `single_field_overlay` call and every test-side
14751/// navigator's `.get(…)` retrieval so a future Gateway API rebrand on
14752/// the per-rule request-deadline leaf lands in one place; every future
14753/// renderer that reaches for the canonical per-rule request-deadline
14754/// leaf (the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
14755/// materializer's per-Aplicacao per-rule request-deadline fan-out, a
14756/// future per-edge `backendRequest` per-attempt backend-call deadline
14757/// emitter) inherits the same value by construction with no opportunity
14758/// for per-renderer drift.
14759///
14760/// Same "the typed constant lives in one place" discipline the
14761/// [`GATEWAY_API_KEY_ATTEMPTS`] (e2e136b) /
14762/// [`GATEWAY_API_KEY_RETRY`] (231bbf5) /
14763/// [`GATEWAY_API_KEY_TIMEOUTS`] (db31108) lifts apply on the peer
14764/// canonical-Gateway-API-HTTPRoute-per-rule-body-axis surface, now
14765/// extended to the second per-rule container-leaf scalar (parallel to
14766/// the sibling `retry.attempts` container-leaf pair).
14767///
14768/// [cm]: ../../caixa_mesh/index.html
14769pub const GATEWAY_API_KEY_REQUEST: &str = "request";
14770
14771/// Canonical Helm library-chart name every `lareira-<nome>` chart depends
14772/// on — the `pleme-computeunit` library chart in
14773/// `pleme-io/helmworks/charts/pleme-computeunit` that owns the K8s
14774/// resource templates (ComputeUnit + Service + ScaledObject + ConfigMap)
14775/// every per-Servico chart consumes via Helm's per-dep alias convention
14776/// (when no `alias:` is set on a dependency, values are scoped under the
14777/// dependency's `name:`).
14778///
14779/// The single source of truth all three downstream library-name consumers
14780/// reach for:
14781///
14782/// - [`caixa-helm`][ch]'s `DEFAULT_LIBRARY_NAME` re-export — the
14783/// default value of `RenderOpts::library_name`, which drives both
14784/// the Chart.yaml `dependencies[0].name` axis
14785/// (`build_chart_yaml`) and the values.yaml wrap key
14786/// (`build_values_yaml`) so the rendered `lareira-<nome>` chart's
14787/// dep declaration and its values block agree by construction
14788/// (the 17ebd1a `opts.library_name` lift).
14789/// - [`caixa-flux`][cf]'s `DEFAULT_LIBRARY_NAME` re-export — the
14790/// wrap key the `cluster_bundle` `helmrelease.yaml` template uses
14791/// under `spec.values.<library>:` to thread the per-cluster
14792/// overrides (`enabled: true`) through to the rendered chart's
14793/// dep block. Helm's per-dep alias convention scopes those values
14794/// under the dependency's `name:`, so this wrap key must match the
14795/// chart's `dependencies[0].name` exactly — drift here silently
14796/// routes the values block nowhere at `helm template` /
14797/// `helm install` time, and the cluster comes up with the library
14798/// chart's defaults rather than the typed per-cluster overrides.
14799/// - Every future per-Servico renderer the absorption-roadmap
14800/// acknowledges (the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
14801/// materializer's per-edge library-chart resolver, the future
14802/// per-cluster image-registry mirror's `<registry>-computeunit`
14803/// fork, the future per-edition library-chart variant the
14804/// substrate forks once `pleme-computeunit` outlives its scoping
14805/// intent).
14806///
14807/// Until this lift landed the canonical library-chart name lived as
14808/// two production-code call sites: a `pub const DEFAULT_LIBRARY_NAME:
14809/// &str = "pleme-computeunit"` in `caixa-helm` (the
14810/// `RenderOpts::library_name` default, consumed by both the chart's dep
14811/// name axis and the values.yaml wrap key axis) and an inline literal
14812/// `pleme-computeunit:` in `caixa-flux`'s `cluster_bundle`
14813/// `helmrelease.yaml` format-string template (the wrap key the per-
14814/// cluster `enabled: true` override is scoped under). Both consumers
14815/// reach for the same load-bearing Helm library-chart name, but no
14816/// shared constant linked them — the canonical
14817/// "duplicated `pub const` / inline literal across two renderers"
14818/// drift footgun the [`DEFAULT_NAMESPACE`] (a085b26) and
14819/// [`DEFAULT_SERVICO_PORT`] (1e22add) lifts close on the peer
14820/// canonical-K8s-axis-constant surface.
14821///
14822/// A future library-chart rebrand — the substrate forking
14823/// `pleme-computeunit` to `<registry>-computeunit` for a per-cluster
14824/// image-registry mirror, or to `aplicacao-computeunit` for the M4
14825/// typed-Aplicacao renderer's sibling library chart, or to any
14826/// per-edition variant the absorption-roadmap names — without a
14827/// coordinated edit on both consumers would have silently emitted a
14828/// per-Servico chart whose dep declared the new library name (because
14829/// the chart-side override flowed through `opts.library_name`) but
14830/// whose flux-side `HelmRelease.values.pleme-computeunit:` wrap key
14831/// still scoped under the old literal. Helm's per-dep values router
14832/// would route the per-cluster `enabled: true` override to *nowhere*
14833/// at `helm template` / `helm install` time, and the cluster's apply
14834/// would come up with the library chart's defaults — `enabled: false`,
14835/// the typed values block from the chart's own `values.yaml` rather
14836/// than the flux-side override — silently no-op'ing every per-cluster
14837/// override the operator set, far from the rebrand commit's source.
14838/// The apply-time symptom (the workload comes up with the library
14839/// chart's defaults instead of the per-cluster overrides) is invisible
14840/// at admission and surfaces only as "the service is up but not doing
14841/// what we configured it to do", typically far from the rebrand commit.
14842///
14843/// Lifting it to caixa-core's render-constants block alongside the
14844/// peer [`DEFAULT_NAMESPACE`] / [`DEFAULT_SERVICO_PORT`] makes the
14845/// library-name axis discipline structural: every renderer that
14846/// reaches for the canonical library-chart name consults the same
14847/// `&'static str`, and every future renderer inherits the same value
14848/// by construction with no opportunity for per-renderer drift. Same
14849/// "the typed constant lives in one place" discipline the
14850/// [`PLEME_LABEL_PREFIX`] (a8d4d57) / [`KUBE_KEY_API_VERSION`] /
14851/// [`LAREIRA_CHART_NAME_PREFIX`] lifts apply on the peer
14852/// shared-string axes.
14853///
14854/// [ch]: ../../caixa_helm/index.html
14855/// [cf]: ../../caixa_flux/index.html
14856pub const DEFAULT_LIBRARY_NAME: &str = "pleme-computeunit";
14857
14858/// Canonical Flux v2 `spec.interval` reconcile-poll cadence duration
14859/// scalar every [`caixa-flux`][cf]-emitted Flux v2 CR (the per-caixa
14860/// `cluster_bundle` triplet's `GitRepository` + `HelmRelease` +
14861/// `Kustomization`) declares as its default reconcile-schedule when the
14862/// per-caixa [`ClusterBundleOpts::for_caixa`][fc] seed doesn't carry an
14863/// operator-pinned override. Every rendered per-caixa Flux v2 CR consults
14864/// the same `&'static str` at seed time so a future substrate-side
14865/// reconcile-cadence migration (`"10m"` → `"5m"` once the Flux v2 source-
14866/// controller / helm-controller / kustomize-controller trio ships lower-
14867/// latency-poll optimizations that make per-CR cluster load safe at a
14868/// faster cadence, `"10m"` → `"15m"` on cost-optimized clusters where the
14869/// per-CR source-controller poll cost outweighs the reconcile-freshness
14870/// gain) is a one-line edit on this canonical declaration, not a
14871/// coordinated rewrite across the [`ClusterBundleOpts`] default seed and
14872/// every future per-target renderer the substrate adds.
14873///
14874/// The single source of truth the rendered per-caixa Flux v2 cluster
14875/// bundle's per-CR reconcile-poll cadence default seed reaches for:
14876///
14877/// - [`ClusterBundleOpts::for_caixa`][fc]'s per-caixa default seed
14878/// (caixa-flux/src/lib.rs — the `interval: <DEFAULT>.into()` field of
14879/// the [`ClusterBundleOpts`] struct default the substrate's per-caixa
14880/// `cluster_bundle` renderer threads through every emitted Flux v2 CR's
14881/// [`FLUX_KEY_INTERVAL`] axis verbatim).
14882///
14883/// The value is a valid Flux v2 reconcile-poll cadence duration scalar (per
14884/// the upstream Flux v2 `metav1.Duration` OpenAPI schema on each of the
14885/// three Flux v2 CRDs — `source.toolkit.fluxcd.io/v1/GitRepository.spec.
14886/// interval`, `helm.toolkit.fluxcd.io/v2/HelmRelease.spec.interval`,
14887/// `kustomize.toolkit.fluxcd.io/v1/Kustomization.spec.interval`): a
14888/// non-empty Go-duration-format string (e.g. `"10m"`, `"5m"`, `"1h30m"`),
14889/// which the Flux v2 controller-side per-CR admission gate parses via
14890/// `metav1.ParseDuration` before installing the per-CR watch. A future
14891/// rebrand on this lift cannot silently land a value the Flux v2
14892/// controller-side admission gate rejects at the *first* per-caixa
14893/// `HelmRelease` apply against a cluster, far from the rebrand commit's
14894/// source — the pin at the canonical lift documents the Go-duration-format
14895/// grammar contract with the Flux v2 admission gate every downstream
14896/// consumer of the rendered per-CR reconcile-cadence axis rests on.
14897///
14898/// Pairs with the sibling [`FLUX_KEY_INTERVAL`] (48db6e2) per-Flux-v2-CR
14899/// reconcile-poll cadence scalar-axis key the value the substrate seeds
14900/// here nests directly under across every rendered per-caixa Flux v2 CR
14901/// — the key half of the per-CR `spec.interval` scalar-key/scalar-value
14902/// pair lives at [`FLUX_KEY_INTERVAL`], the value half's substrate-side
14903/// default seed lives here. Same "the typed constant lives in one place"
14904/// discipline the [`DEFAULT_NAMESPACE`] (a085b26) /
14905/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) / [`DEFAULT_LIBRARY_NAME`]
14906/// (41438dc) / [`DEFAULT_SERVICO_PORT`] (1e22add) /
14907/// [`DEFAULT_GATEWAY_CLASS_NAME`] (d9b0743) /
14908/// [`DEFAULT_PUBLISH_TAG_PREFIX`] (0a6a602) lifts apply on the peer
14909/// canonical-substrate-default-load-bearing-scalar surface — extends the
14910/// canonical-substrate-default single-sourcing discipline from the peer
14911/// substrate-side default-namespace / default-library-chart-name /
14912/// default-Servico-listen-port / default-Gateway-API-controller-name /
14913/// default-git-publish-tag-prefix surfaces onto the sibling default-Flux-
14914/// v2-per-CR-reconcile-poll-cadence surface every rendered per-caixa
14915/// Flux v2 cluster bundle CR carries.
14916///
14917/// [cf]: ../../caixa_flux/index.html
14918/// [fc]: ../../caixa_flux/struct.ClusterBundleOpts.html#method.for_caixa
14919pub const DEFAULT_FLUX_RECONCILE_INTERVAL: &str = "10m";
14920
14921/// Canonical Flux v2 `HelmRelease.spec.chart.spec.chart` per-CR chart-
14922/// directory-in-GitRepository-source sub-path scalar every
14923/// [`caixa-flux`][cf]-emitted `helmrelease.yaml` document declares as the
14924/// default chart-directory-in-git-source pointer when the per-caixa
14925/// [`ClusterBundleOpts::for_caixa`][fc] seed doesn't carry an operator-
14926/// pinned override. The Flux v2 source-controller resolves the pointer
14927/// relative to the paired [`FLUX_KIND_GIT_REPOSITORY`] the sibling
14928/// [`FLUX_KEY_SOURCE_REF`]-keyed `sourceRef:` block names — the substrate's
14929/// canonical contract with every caixa Servico's git repository is that
14930/// the per-caixa `lareira-<nome>` chart the peer `caixa-helm` renderer
14931/// emits lives at the `./chart/` sub-tree of the repository root, so the
14932/// helm-controller's per-CR chart-open loop keys off this exact scalar to
14933/// locate the [`HELM_CHART_YAML_FILENAME`] + [`HELM_VALUES_YAML_FILENAME`]
14934/// pair the per-caixa rendered chart declares. Every rendered per-caixa
14935/// `HelmRelease` CR consults the same `&'static str` at seed time so a
14936/// future substrate-side chart-directory-in-git-source rebrand
14937/// (`"chart"` → `"charts"` once a per-caixa multi-chart layout lands and
14938/// the substrate publishes N sibling `lareira-<nome>/` charts under one
14939/// git repository, `"chart"` → `"helm"` on a cross-language convention
14940/// alignment with sibling wasm-runtime substrates, `"chart"` → `"deploy"`
14941/// on a per-caixa-deploy-directory naming migration) is a one-line edit
14942/// on this canonical declaration, not a coordinated rewrite across the
14943/// [`ClusterBundleOpts`] default seed and every future per-target
14944/// renderer the substrate adds.
14945///
14946/// The single source of truth the rendered per-caixa Flux v2 cluster
14947/// bundle's per-CR chart-directory-in-git-source default seed reaches for:
14948///
14949/// - [`ClusterBundleOpts::for_caixa`][fc]'s per-caixa default seed
14950/// (caixa-flux/src/lib.rs — the `chart_path: <DEFAULT>.into()` field
14951/// of the [`ClusterBundleOpts`] struct default the substrate's per-
14952/// caixa `cluster_bundle` renderer threads through every emitted per-
14953/// caixa `helmrelease.yaml` document's [`FLUX_HELMCHART_TEMPLATE_KEY_CHART`]
14954/// -keyed `spec.chart.spec.chart` axis verbatim).
14955///
14956/// The value is a valid Flux v2 `HelmRelease.spec.chart.spec.chart` scalar
14957/// (per the upstream Flux v2 `helm.toolkit.fluxcd.io/v2/HelmRelease` `OpenAPI`
14958/// schema — a non-empty string interpreted by the source-controller as a
14959/// relative directory-tree path from the paired `GitRepository` clone
14960/// root): a non-empty ASCII scalar with no leading path separator (which
14961/// would break the source-controller's relative-path composition against
14962/// the per-clone-root anchor). A future rebrand on this lift cannot
14963/// silently land an empty scalar or a leading-separator scalar the source-
14964/// controller-side per-CR chart-open loop would then reject at the *first*
14965/// per-caixa `HelmRelease` apply against a cluster, far from the rebrand
14966/// commit's source — the [`default_flux_chart_source_subpath_is_a_valid_relative_directory_scalar`]
14967/// pin trips at caixa-core build time on any drift past the typed floor.
14968///
14969/// Pairs with the sibling [`FLUX_HELMCHART_TEMPLATE_KEY_CHART`] (0fef82e)
14970/// per-Flux-v2-`HelmRelease.spec.chart.spec.chart` leaf-scalar-key the
14971/// value the substrate seeds here nests directly under across every
14972/// rendered per-caixa `HelmRelease` CR — the key half of the per-CR
14973/// `spec.chart.spec.chart` scalar-key/scalar-value pair lives at
14974/// [`FLUX_HELMCHART_TEMPLATE_KEY_CHART`], the value half's substrate-side
14975/// default seed lives here. Peer with [`flux_kustomization_source_subtree`]
14976/// on the sibling `Kustomization.spec.path` per-cluster / per-caixa `GitOps`-
14977/// repository-relative directory-tree seed composer — both name a load-
14978/// bearing directory-tree relative path the Flux v2 controller family's
14979/// per-CR reconcile loop navigates into, at the two paired axes of the
14980/// per-caixa `cluster_bundle` triplet (the `HelmRelease` chart-directory
14981/// axis names *where in the caixa's own git repo the chart lives*, the
14982/// `Kustomization` sub-tree axis names *where in the k8s-GitOps repo the
14983/// per-cluster manifest sub-tree lives*, and the two together close the
14984/// Flux v2 kustomize-controller → helm-controller reconcile-chain axis
14985/// the substrate's per-caixa cluster-bundle-triplet reconcile-topology
14986/// rests on).
14987///
14988/// Same "the typed constant lives in one place" discipline the
14989/// [`DEFAULT_NAMESPACE`] (a085b26) / [`DEFAULT_FLUX_SYSTEM_NAMESPACE`]
14990/// (7197d38) / [`DEFAULT_LIBRARY_NAME`] (41438dc) /
14991/// [`DEFAULT_SERVICO_PORT`] (1e22add) / [`DEFAULT_GATEWAY_CLASS_NAME`]
14992/// (d9b0743) / [`DEFAULT_PUBLISH_TAG_PREFIX`] (0a6a602) /
14993/// [`DEFAULT_FLUX_RECONCILE_INTERVAL`] (908180f) /
14994/// [`DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT`] (64bdb2b) /
14995/// [`DEFAULT_PLEME_GIT_ORG`] (9952bd9) lifts apply on the peer
14996/// canonical-substrate-default-load-bearing-scalar surface — extends the
14997/// canonical-substrate-default single-sourcing discipline from the peer
14998/// substrate-side default-namespace / default-library-chart-name /
14999/// default-Servico-listen-port / default-Gateway-API-controller-name /
15000/// default-git-publish-tag-prefix / default-Flux-v2-per-CR-reconcile-poll-
15001/// cadence / default-Flux-v2-per-CR-kustomization-reconcile-wall-clock-cap
15002/// / default-pleme-io-git-org surfaces onto the sibling default-Flux-v2-
15003/// per-CR-HelmRelease-chart-directory-in-git-source surface every rendered
15004/// per-caixa Flux v2 cluster bundle `HelmRelease` CR carries.
15005///
15006/// [cf]: ../../caixa_flux/index.html
15007/// [fc]: ../../caixa_flux/struct.ClusterBundleOpts.html#method.for_caixa
15008pub const DEFAULT_FLUX_CHART_SOURCE_SUBPATH: &str = "chart";
15009
15010/// Canonical Flux v2 `HelmRelease.spec.{install,upgrade}.remediation.retries`
15011/// bounded retry-count scalar every [`caixa-flux`][cf]-emitted `helmrelease.yaml`
15012/// document declares under both the install-path and the upgrade-path
15013/// `remediation` blocks. The Flux v2 `helm-controller` per-CR `Install` /
15014/// `Upgrade` action reconciler consumes this scalar as the ceiling on the
15015/// number of times it will re-attempt a failed Helm install or Helm upgrade
15016/// before it marks the `HelmRelease` `Ready: False` and stops retrying — the
15017/// substrate's canonical "how many times we let Flux re-try a chart apply
15018/// before it stops" contract with the helm-controller-side per-CR
15019/// remediation loop.
15020///
15021/// The single source of truth all two duplicated inline `retries: 3`
15022/// scalar-value literal sites the substrate's [`cluster_bundle`][cb]
15023/// `helmrelease.yaml` format-string template reaches for:
15024///
15025/// - `helmrelease.yaml` `spec.install.remediation.retries` — the install-
15026/// path retry cap the helm-controller consumes for the first-time chart
15027/// apply the `HelmRelease` CR gates. Before this lift landed the value
15028/// sat as an inline `retries: 3\n` literal inside
15029/// [`cluster_bundle`][cb]'s `helmrelease.yaml` format-string template's
15030/// `install:` sub-block (caixa-flux/src/lib.rs — the `install.remediation`
15031/// sub-block).
15032/// - `helmrelease.yaml` `spec.upgrade.remediation.retries` — the upgrade-
15033/// path retry cap the helm-controller consumes for every subsequent
15034/// chart re-apply the same `HelmRelease` CR gates on a caixa version
15035/// bump. Before this lift landed the value sat as a second inline
15036/// `retries: 3\n` literal inside the same
15037/// [`cluster_bundle`][cb] `helmrelease.yaml` format-string template's
15038/// `upgrade:` sub-block (caixa-flux/src/lib.rs — the `upgrade.remediation`
15039/// sub-block).
15040/// - Every future per-caixa `HelmRelease` renderer the M3.x + M4
15041/// absorption roadmap acknowledges (the future
15042/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
15043/// `HelmRelease` synthesis, a future per-cluster override `HelmRelease`
15044/// the operator emits for the observability-collector pipeline).
15045///
15046/// Both existing production-code sites carry the *same* substrate-chosen
15047/// retry ceiling — the value is one canonical policy choice, not two
15048/// independent axes: the operator's "how many chart-apply failures we
15049/// tolerate before Flux stops retrying and surfaces the failure at the
15050/// per-caixa `HelmRelease.status.conditions[]` axis the substrate's
15051/// downstream reconciliation-topology consumer watches". A future
15052/// substrate-side retry-ceiling migration (`3` → `5` once per-caixa
15053/// idempotency invariants tighten and higher-retry recovery from
15054/// transient apiserver / registry / oci-source flakes becomes safe, `3`
15055/// → `1` on hardened per-caixa pipelines where a failed apply should
15056/// escalate to operator-attention rather than mask under further retries,
15057/// `3` → `10` on high-churn dev clusters where transient failures
15058/// dominate) without a coordinated edit on *both* sites would have
15059/// silently split the substrate's canonical retry-ceiling between the
15060/// install-path and the upgrade-path — first-time applies would tolerate
15061/// one ceiling while every subsequent per-version re-apply would tolerate
15062/// another, with no field naming the ceiling-drift root cause far from
15063/// the rebrand commit's source. Lifting the value to caixa-core's render-
15064/// constants block alongside the peer [`DEFAULT_FLUX_RECONCILE_INTERVAL`]
15065/// makes the retry-ceiling axis discipline structural: both sites consult
15066/// the same `u32`, and every future per-CR remediation-retries emitter
15067/// inherits the same value by construction with no opportunity for per-
15068/// path drift.
15069///
15070/// The value is a valid Flux v2 `HelmRelease`-remediation-retries scalar
15071/// (per the upstream Flux v2 `HelmRelease.spec.{install,upgrade}.remediation.retries`
15072/// `OpenAPI` schema — a non-negative integer, `-1` reserved as the sentinel
15073/// for "retry indefinitely" which the substrate opts out of by declaring
15074/// a bounded ceiling): a positive `u32` bounded above by the substrate's
15075/// tolerance for silently-masked chart-apply failures. A future rebrand
15076/// on this lift cannot silently land a negative sentinel by construction:
15077/// the [`flux_helmrelease_remediation_retries_default_is_a_bounded_positive_scalar`]
15078/// pin trips at caixa-core build time on any drift past the typed floor.
15079///
15080/// Pairs with the sibling [`DEFAULT_FLUX_RECONCILE_INTERVAL`] (908180f)
15081/// on the peer canonical-Flux-v2-per-CR-substrate-default surface — the
15082/// reconcile-poll cadence default names how often the helm-controller
15083/// re-evaluates the per-CR desired state, and this remediation-retries
15084/// ceiling names how many times a per-evaluation Helm action is allowed
15085/// to fail-and-retry before the controller stops. Both are substrate-side
15086/// policy choices the operator inherits when the per-caixa
15087/// [`ClusterBundleOpts`][co] doesn't pin an override, and both must move
15088/// together on any coordinated substrate-side Flux v2 per-CR-remediation
15089/// tuning-cycle promotion.
15090///
15091/// Same "the typed constant lives in one place" discipline the
15092/// [`DEFAULT_NAMESPACE`] (a085b26) / [`DEFAULT_FLUX_SYSTEM_NAMESPACE`]
15093/// (7197d38) / [`DEFAULT_LIBRARY_NAME`] (41438dc) /
15094/// [`crate::DEFAULT_SERVICO_PORT`] (1e22add) /
15095/// [`DEFAULT_GATEWAY_CLASS_NAME`] (d9b0743) /
15096/// [`crate::DEFAULT_PUBLISH_TAG_PREFIX`] (0a6a602) /
15097/// [`DEFAULT_FLUX_RECONCILE_INTERVAL`] (908180f) lifts apply on the peer
15098/// canonical-substrate-default-load-bearing-scalar surface.
15099///
15100/// [cb]: ../../caixa_flux/fn.cluster_bundle.html
15101/// [cf]: ../../caixa_flux/index.html
15102/// [co]: ../../caixa_flux/struct.ClusterBundleOpts.html
15103pub const FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT: u32 = 3;
15104
15105/// Canonical Flux v2 `HelmRelease.spec.{install,upgrade}.remediation.retries`
15106/// leaf scalar-key every `caixa-flux`-emitted `helmrelease.yaml` document
15107/// carries at both its install-path + upgrade-path per-CR remediation
15108/// blocks. Peer to the sibling
15109/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) scalar-value
15110/// half of the same `(leaf-key, scalar-value)` per-path retry-cap
15111/// declaration pair — the Flux v2 helm-controller's per-CR remediation
15112/// loop reads the scalar under this exact leaf key, so drift on either
15113/// axis is equally load-bearing (a typo on the leaf-key silently strips
15114/// the retry-cap declaration from the emitted `remediation:` sub-block —
15115/// the helm-controller then falls back to the Flux v2 upstream default
15116/// rather than the substrate's chosen ceiling — with no diagnostic
15117/// naming the leaf-key-drift root cause far from the source
15118/// caixa.lisp / the renderer's format-string template).
15119///
15120/// The single source of truth every rendered Flux bundle axis that
15121/// names the per-path per-CR retry-cap leaf reaches for:
15122///
15123/// - the rendered `helmrelease.yaml` document's
15124/// `spec.install.remediation.retries` scalar-key axis
15125/// (caixa-flux/src/lib.rs — the `cluster_bundle` `helmrelease.yaml`
15126/// format-string template's install-path retry-cap leaf under the
15127/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`]-valued sub-block);
15128/// - the rendered `helmrelease.yaml` document's
15129/// `spec.upgrade.remediation.retries` scalar-key axis (caixa-flux/src/
15130/// lib.rs — the sibling `cluster_bundle` `helmrelease.yaml` format-
15131/// string template's upgrade-path retry-cap leaf under the same
15132/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`]-valued sub-block);
15133/// - the two test-fixture navigation sites in caixa-flux's `mod tests`
15134/// that probe the rendered document's `.get("retries")` container
15135/// axis to pin the emitted scalar-value against the sibling
15136/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] canonical-scalar
15137/// lift (the install-path + upgrade-path production-emit pins
15138/// [`cluster_bundle_helmrelease_install_remediation_retries_pins_lifted_default`]
15139/// / [`cluster_bundle_helmrelease_upgrade_remediation_retries_pins_lifted_default`]).
15140///
15141/// Both production emit sites + the two test-fixture navigation sites
15142/// name the same Flux v2 per-path per-CR retry-cap leaf-scalar-key and
15143/// must move together on any hypothetical Flux v3 rename (upstream Flux
15144/// v3 roadmap floats candidates like `attempts` / `maxRetries` /
15145/// `retryCount` in the migration prose — the peer Gateway-API-side
15146/// `spec.rules[].retry.attempts` leaf already uses `attempts` on the
15147/// sibling `GATEWAY_API_KEY_ATTEMPTS` axis, an independent CRD group's
15148/// evolution the two `pub const` declarations stay sibling constants
15149/// against). Until this lift landed the axis carried inline `retries`
15150/// literals across the two production emit sites (caixa-flux/src/lib.rs
15151/// — the two `retries: {retries_default}` sub-block leaf-headers inside
15152/// the `cluster_bundle` `helmrelease.yaml` format-string template) plus
15153/// the two test-fixture navigation sites — four occurrences of the same
15154/// load-bearing Flux-v2-per-CR-retry-cap-leaf-scalar-key convention,
15155/// drift-prone by construction.
15156///
15157/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
15158/// "every recurring shape becomes a generator before it becomes a
15159/// pattern; every pattern becomes a library before it becomes
15160/// duplicated code. The duplication budget is zero.") promotes the
15161/// constant to a typed substrate-side `&'static str` on the same
15162/// trajectory the sibling
15163/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) scalar-
15164/// value half established — extends the discipline from the scalar
15165/// value the leaf holds onto the leaf-key itself, closing the
15166/// `(leaf-key, scalar-value)` pair on both halves. The two render-side
15167/// consumers now thread the same `&'static str` through their format-
15168/// string template via a `{retries_key}` named-arg interpolation so a
15169/// future Flux v3 rebrand lands in one place; every future renderer
15170/// that reaches for the canonical Flux v2 per-CR per-path retry-cap
15171/// leaf-key (the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
15172/// materializer's per-Aplicacao `HelmRelease`, a future per-edge
15173/// `HelmRelease` the operator emits for the
15174/// `CiliumClusterwideEnvoyConfig` pipeline, a future `caixa-otel`
15175/// collector-pipeline `HelmRelease`) inherits the same value by
15176/// construction with no opportunity for per-renderer drift.
15177///
15178/// Same "the typed constant lives in one place" discipline the
15179/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) sibling
15180/// scalar-value lift plus the peer [`FLUX_KEY_SOURCE_REF`] (236ef01) /
15181/// [`FLUX_KEY_CHART`] / [`FLUX_KEY_VALUES`] / [`FLUX_KEY_INTERVAL`] /
15182/// [`FLUX_KEY_HEALTH_CHECKS`] container-axis-key lifts apply on the
15183/// peer canonical-Flux-v2-load-bearing-string surface.
15184///
15185/// [cf]: ../../caixa_flux/index.html
15186pub const FLUX_HELMRELEASE_KEY_RETRIES: &str = "retries";
15187
15188/// Canonical Flux v2 `HelmRelease.spec.{install,upgrade}.remediation`
15189/// sub-container-axis-key every `caixa-flux`-emitted `helmrelease.yaml`
15190/// document nests the sibling
15191/// [`FLUX_HELMRELEASE_KEY_RETRIES`] retry-cap leaf-scalar-key under, at
15192/// both the install-path + upgrade-path per-CR remediation blocks. The
15193/// parent-container-axis-key half of the same
15194/// `(container-axis-key, leaf-scalar-key, scalar-value)` per-path
15195/// retry-cap declaration triple the sibling
15196/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) scalar-value
15197/// + [`FLUX_HELMRELEASE_KEY_RETRIES`] (a12f9fc) leaf-scalar-key halves
15198/// closed on the value the leaf holds + the leaf-key itself — this lift
15199/// closes the third and final axis on the same per-path retry-cap
15200/// declaration by extending the discipline from the leaf up to the sub-
15201/// container-axis-key the leaf sits under. The Flux v2 helm-controller
15202/// per-CR remediation loop navigates through this exact sub-container
15203/// axis to reach the retry-cap scalar-key, so drift on this axis is
15204/// equally load-bearing (a typo on the sub-container-axis-key silently
15205/// strips the entire per-path remediation block from the emitted per-CR
15206/// document — the helm-controller then falls back to the Flux v2
15207/// upstream defaults for the whole remediation surface rather than the
15208/// substrate's chosen ceiling, with no diagnostic naming the container-
15209/// axis-key-drift root cause far from the source caixa.lisp / the
15210/// renderer's format-string template).
15211///
15212/// The single source of truth every rendered Flux bundle axis that
15213/// names the per-path per-CR remediation sub-container reaches for:
15214///
15215/// - the rendered `helmrelease.yaml` document's `spec.install.remediation`
15216/// sub-block-header axis (caixa-flux/src/lib.rs — the `cluster_bundle`
15217/// `helmrelease.yaml` format-string template's install-path
15218/// remediation sub-block-header nesting the retry-cap leaf under the
15219/// sibling
15220/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`]-valued scalar);
15221/// - the rendered `helmrelease.yaml` document's `spec.upgrade.remediation`
15222/// sub-block-header axis (caixa-flux/src/lib.rs — the sibling
15223/// `cluster_bundle` `helmrelease.yaml` format-string template's
15224/// upgrade-path remediation sub-block-header, additionally nesting
15225/// the `remediateLastFailure: true` toggle on the upgrade-path
15226/// sibling axis);
15227/// - the two test-fixture navigation sites in caixa-flux's `mod tests`
15228/// that probe the rendered document's `.get("remediation")` container
15229/// axis to reach the sibling [`FLUX_HELMRELEASE_KEY_RETRIES`] leaf-
15230/// scalar-key pin (the install-path + upgrade-path production-emit
15231/// pins
15232/// [`cluster_bundle_helmrelease_install_remediation_retries_pins_lifted_default`]
15233/// / [`cluster_bundle_helmrelease_upgrade_remediation_retries_pins_lifted_default`]).
15234///
15235/// Both production emit sites + the two test-fixture navigation sites
15236/// name the same Flux v2 per-path per-CR remediation sub-container-axis
15237/// key and must move together on any hypothetical Flux v3 rename
15238/// (upstream Flux v3 roadmap floats candidates like `recovery` /
15239/// `retryPolicy` / `errorHandling` in the migration prose). Until this
15240/// lift landed the axis carried inline `remediation` literals across the
15241/// two production emit sites (caixa-flux/src/lib.rs — the two
15242/// `remediation:` sub-block-header lines inside the `cluster_bundle`
15243/// `helmrelease.yaml` format-string template's install-path + upgrade-
15244/// path per-CR blocks) plus the two test-fixture navigation sites —
15245/// four occurrences of the same load-bearing Flux-v2-per-CR-remediation-
15246/// sub-container-axis-key convention, drift-prone by construction.
15247///
15248/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
15249/// "every recurring shape becomes a generator before it becomes a
15250/// pattern; every pattern becomes a library before it becomes
15251/// duplicated code. The duplication budget is zero.") promotes the
15252/// constant to a typed substrate-side `&'static str` on the same
15253/// trajectory the sibling [`FLUX_HELMRELEASE_KEY_RETRIES`] (a12f9fc)
15254/// leaf-scalar-key half + the sibling
15255/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) scalar-
15256/// value half established — closes the parent-container-axis-key axis
15257/// on the same per-path retry-cap declaration triple, so all three
15258/// halves now live in one place. The two render-side consumers now
15259/// thread the same `&'static str` through their format-string template
15260/// via a `{remediation_key}` named-arg interpolation so a future Flux v3
15261/// rebrand lands in one place; every future renderer that reaches for
15262/// the canonical Flux v2 per-CR per-path remediation sub-container-axis
15263/// key inherits the same value by construction with no opportunity for
15264/// per-renderer drift.
15265///
15266/// Same "the typed constant lives in one place" discipline the sibling
15267/// [`FLUX_HELMRELEASE_KEY_RETRIES`] (a12f9fc) leaf-scalar-key half plus
15268/// the peer [`FLUX_KEY_SOURCE_REF`] (236ef01) / [`FLUX_KEY_CHART`] /
15269/// [`FLUX_KEY_VALUES`] / [`FLUX_KEY_INTERVAL`] /
15270/// [`FLUX_KEY_HEALTH_CHECKS`] container-axis-key lifts apply on the
15271/// peer canonical-Flux-v2-load-bearing-string surface.
15272///
15273/// [cf]: ../../caixa_flux/index.html
15274pub const FLUX_HELMRELEASE_KEY_REMEDIATION: &str = "remediation";
15275
15276/// Canonical Flux v2 `HelmRelease.spec.install` per-CR helm-action-phase
15277/// discriminator parent-container-axis-key every `caixa-flux`-emitted
15278/// `helmrelease.yaml` document nests the sibling
15279/// [`FLUX_HELMRELEASE_KEY_REMEDIATION`] (6fe4e7e) sub-container-axis-key
15280/// under, at the first-time chart apply per-CR phase the Flux v2 helm-
15281/// controller reconciles when the emitted `HelmRelease` CR first lands in
15282/// the cluster. Pairs with the sibling [`FLUX_HELMRELEASE_KEY_UPGRADE`]
15283/// per-CR helm-action-phase discriminator parent-container-axis-key on
15284/// the peer per-CR upgrade-path phase the helm-controller reconciles on
15285/// every subsequent per-version chart re-apply the same CR gates. The
15286/// Flux v2 helm-controller-side per-CR phase-dispatch loop keys off this
15287/// exact parent-container-axis-key to select the install-path per-CR
15288/// action pipeline (`createNamespace` seeder, first-time chart values
15289/// merge, `spec.install.remediation.retries` retry-cap ceiling under the
15290/// nested [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container), so drift
15291/// on this axis is exactly as load-bearing as drift on the nested
15292/// [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-axis-key it hosts
15293/// (a `"initialize"` / `"apply"` / `"create"` / `"first-run"` typo at
15294/// the production-code call site silently strips the entire install-path
15295/// per-CR phase block from the emitted per-CR document — the helm-
15296/// controller then falls back to the Flux v2 upstream defaults for the
15297/// whole install-path phase surface rather than the substrate's chosen
15298/// per-CR install-path knob-set — `createNamespace` never fires, the
15299/// per-CR retry-cap ceiling silently drops off the emitted document,
15300/// with no diagnostic naming the phase-discriminator-drift root cause
15301/// far from the source `caixa.lisp` / the renderer's format-string
15302/// template).
15303///
15304/// The single source of truth every rendered Flux bundle axis that names
15305/// the per-CR install-path phase parent-container reaches for:
15306///
15307/// - the rendered `helmrelease.yaml` document's `spec.install` sub-
15308/// block-header axis (caixa-flux/src/lib.rs — the `cluster_bundle`
15309/// `helmrelease.yaml` format-string template's install-path sub-
15310/// block-header nesting the `createNamespace: true` seeder + the
15311/// sibling [`FLUX_HELMRELEASE_KEY_REMEDIATION`]-container-keyed
15312/// retry-cap sub-block);
15313/// - the test-fixture navigation site in caixa-flux's `mod tests` that
15314/// probes the rendered document's `.get("install")` container axis
15315/// to reach the sibling [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-
15316/// container (the install-path production-emit pin
15317/// [`cluster_bundle_helmrelease_install_remediation_retries_pins_lifted_default`]).
15318///
15319/// Both the production emit site + the test-fixture navigation site name
15320/// the same Flux v2 per-CR install-path helm-action-phase discriminator
15321/// parent-container-axis-key and must move together on any hypothetical
15322/// Flux v3 rename (upstream Flux v3 roadmap floats candidates like
15323/// `initialize` / `apply` / `create` / `first-run` in the migration
15324/// prose). Until this lift landed the axis carried inline `install`
15325/// literals across the one production emit site (caixa-flux/src/lib.rs —
15326/// the `install:` sub-block-header line inside the `cluster_bundle`
15327/// `helmrelease.yaml` format-string template's per-CR install-path block)
15328/// plus the one test-fixture navigation site — two occurrences of the
15329/// same load-bearing Flux-v2-per-CR-install-path-phase-discriminator-
15330/// parent-container-axis-key convention, drift-prone by construction.
15331///
15332/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5, "every
15333/// recurring shape becomes a generator before it becomes a pattern; every
15334/// pattern becomes a library before it becomes duplicated code. The
15335/// duplication budget is zero.") promotes the constant to a typed
15336/// substrate-side `&'static str` on the same trajectory the sibling
15337/// [`FLUX_HELMRELEASE_KEY_REMEDIATION`] (6fe4e7e) sub-container-axis-key +
15338/// [`FLUX_HELMRELEASE_KEY_RETRIES`] (a12f9fc) leaf-scalar-key +
15339/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) scalar-
15340/// value halves of the same `(parent-container-key, sub-container-key,
15341/// leaf-key, scalar-value)` per-path retry-cap declaration quartet
15342/// established — extends the discipline from the sub-container-axis-key
15343/// one level up to the parent-container-axis-key hosting it, so the
15344/// four-level nested `spec.install.remediation.retries` declaration now
15345/// resolves through four lifted `&'static str` / `u32` values. Companion
15346/// to the sibling [`FLUX_HELMRELEASE_KEY_UPGRADE`] per-CR upgrade-path
15347/// phase-discriminator parent-container-axis-key on the peer per-CR
15348/// helm-action-phase surface — completes the per-CR helm-action-phase
15349/// discriminator parent-container-axis-key pair the Flux v2 helm-
15350/// controller reconciles between at first-time chart apply time
15351/// (install-path phase) vs. every subsequent per-version chart re-apply
15352/// (upgrade-path phase).
15353///
15354/// Same "the typed constant lives in one place" discipline the sibling
15355/// [`FLUX_HELMRELEASE_KEY_REMEDIATION`] (6fe4e7e) sub-container-axis-key +
15356/// the peer [`FLUX_KEY_SOURCE_REF`] (236ef01) / [`FLUX_KEY_CHART`] /
15357/// [`FLUX_KEY_VALUES`] / [`FLUX_KEY_INTERVAL`] /
15358/// [`FLUX_KEY_HEALTH_CHECKS`] per-CR container-axis-key lifts apply on
15359/// the peer canonical-Flux-v2-load-bearing-string surface.
15360///
15361/// [cf]: ../../caixa_flux/index.html
15362pub const FLUX_HELMRELEASE_KEY_INSTALL: &str = "install";
15363
15364/// Canonical Flux v2 `HelmRelease.spec.upgrade` per-CR helm-action-phase
15365/// discriminator parent-container-axis-key every `caixa-flux`-emitted
15366/// `helmrelease.yaml` document nests the sibling
15367/// [`FLUX_HELMRELEASE_KEY_REMEDIATION`] (6fe4e7e) sub-container-axis-key
15368/// under, at every subsequent per-version chart re-apply per-CR phase the
15369/// Flux v2 helm-controller reconciles after the initial install-path
15370/// phase completes. Pairs with the sibling
15371/// [`FLUX_HELMRELEASE_KEY_INSTALL`] per-CR helm-action-phase discriminator
15372/// parent-container-axis-key on the peer per-CR install-path phase the
15373/// helm-controller reconciles at first-time chart apply. The Flux v2
15374/// helm-controller-side per-CR phase-dispatch loop keys off this exact
15375/// parent-container-axis-key to select the upgrade-path per-CR action
15376/// pipeline (`remediateLastFailure` toggle the substrate pins to `true`
15377/// on the upgrade-path per-CR sibling axis, the per-CR retry-cap ceiling
15378/// under the nested [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container),
15379/// so drift on this axis is exactly as load-bearing as drift on the
15380/// nested [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-axis-key it
15381/// hosts (a `"reapply"` / `"reconcile"` / `"update"` / `"promote"` typo
15382/// at the production-code call site silently strips the entire upgrade-
15383/// path per-CR phase block from the emitted per-CR document — the helm-
15384/// controller then falls back to the Flux v2 upstream defaults for the
15385/// whole upgrade-path phase surface rather than the substrate's chosen
15386/// per-CR upgrade-path knob-set — `remediateLastFailure` never fires, the
15387/// per-CR retry-cap ceiling silently drops off the emitted document, with
15388/// no diagnostic naming the phase-discriminator-drift root cause far
15389/// from the source `caixa.lisp` / the renderer's format-string template).
15390///
15391/// The single source of truth every rendered Flux bundle axis that names
15392/// the per-CR upgrade-path phase parent-container reaches for:
15393///
15394/// - the rendered `helmrelease.yaml` document's `spec.upgrade` sub-
15395/// block-header axis (caixa-flux/src/lib.rs — the `cluster_bundle`
15396/// `helmrelease.yaml` format-string template's upgrade-path sub-
15397/// block-header nesting the substrate's `remediateLastFailure: true`
15398/// toggle + the sibling [`FLUX_HELMRELEASE_KEY_REMEDIATION`]-
15399/// container-keyed retry-cap sub-block);
15400/// - the test-fixture navigation site in caixa-flux's `mod tests` that
15401/// probes the rendered document's `.get("upgrade")` container axis to
15402/// reach the sibling [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-
15403/// container (the upgrade-path production-emit pin
15404/// [`cluster_bundle_helmrelease_upgrade_remediation_retries_pins_lifted_default`]).
15405///
15406/// Both the production emit site + the test-fixture navigation site name
15407/// the same Flux v2 per-CR upgrade-path helm-action-phase discriminator
15408/// parent-container-axis-key and must move together on any hypothetical
15409/// Flux v3 rename (upstream Flux v3 roadmap floats candidates like
15410/// `reapply` / `reconcile` / `update` / `promote` in the migration
15411/// prose). Until this lift landed the axis carried inline `upgrade`
15412/// literals across the one production emit site plus the one test-
15413/// fixture navigation site — two occurrences of the same load-bearing
15414/// Flux-v2-per-CR-upgrade-path-phase-discriminator-parent-container-
15415/// axis-key convention, drift-prone by construction.
15416///
15417/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5, "every
15418/// recurring shape becomes a generator before it becomes a pattern; every
15419/// pattern becomes a library before it becomes duplicated code. The
15420/// duplication budget is zero.") promotes the constant to a typed
15421/// substrate-side `&'static str` on the same trajectory the sibling
15422/// [`FLUX_HELMRELEASE_KEY_INSTALL`] per-CR install-path phase-
15423/// discriminator parent-container-axis-key +
15424/// [`FLUX_HELMRELEASE_KEY_REMEDIATION`] (6fe4e7e) sub-container-axis-key +
15425/// [`FLUX_HELMRELEASE_KEY_RETRIES`] (a12f9fc) leaf-scalar-key +
15426/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) scalar-
15427/// value halves of the same `(parent-container-key, sub-container-key,
15428/// leaf-key, scalar-value)` per-path retry-cap declaration quartet
15429/// established — pairs with the [`FLUX_HELMRELEASE_KEY_INSTALL`]
15430/// mandatory-arm parent-container-axis-key to close the per-CR helm-
15431/// action-phase discriminator parent-container-axis-key pair across
15432/// both per-CR phases the helm-controller reconciles between (install-
15433/// path at first-time chart apply, upgrade-path at every subsequent
15434/// per-version chart re-apply).
15435///
15436/// Same "the typed constant lives in one place" discipline the sibling
15437/// [`FLUX_HELMRELEASE_KEY_INSTALL`] per-CR install-path-phase-
15438/// discriminator + [`FLUX_HELMRELEASE_KEY_REMEDIATION`] (6fe4e7e) sub-
15439/// container-axis-key + the peer [`FLUX_KEY_SOURCE_REF`] (236ef01) /
15440/// [`FLUX_KEY_CHART`] / [`FLUX_KEY_VALUES`] / [`FLUX_KEY_INTERVAL`] /
15441/// [`FLUX_KEY_HEALTH_CHECKS`] per-CR container-axis-key lifts apply on
15442/// the peer canonical-Flux-v2-load-bearing-string surface.
15443///
15444/// [cf]: ../../caixa_flux/index.html
15445pub const FLUX_HELMRELEASE_KEY_UPGRADE: &str = "upgrade";
15446
15447/// Canonical Flux v2 `HelmRelease.spec.upgrade.remediation.remediateLastFailure`
15448/// upgrade-path-only per-CR remediation-toggle leaf-scalar-key every
15449/// `caixa-flux`-emitted `helmrelease.yaml` document seeds to `true` under
15450/// the sibling [`FLUX_HELMRELEASE_KEY_UPGRADE`] per-CR upgrade-path phase-
15451/// discriminator parent-container-axis-key's nested
15452/// [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-axis-key. Sibling to
15453/// the peer [`FLUX_HELMRELEASE_KEY_RETRIES`] retry-cap leaf-scalar-key at
15454/// the same per-CR upgrade-path per-CR remediation sub-container position —
15455/// closes the `spec.upgrade.remediation.{retries, remediateLastFailure}`
15456/// per-path remediation-block leaf-scalar-key pair the substrate seeds into
15457/// every emitted per-caixa `HelmRelease` CR on the upgrade-path per-CR
15458/// remediation block, with retries capping the per-version chart re-apply
15459/// retry-count and remediateLastFailure gating the "the Flux v2 helm-
15460/// controller must actively remediate — roll back to the prior success —
15461/// when the final per-version chart re-apply attempt still fails" post-
15462/// retry-exhaustion behavior. The Flux v2 helm-controller-side per-CR
15463/// upgrade-path remediation loop keys off this exact leaf to decide
15464/// whether to leave a failed upgrade in place (`false`) or trigger the
15465/// prior-release rollback pipeline (`true`); drift on this axis silently
15466/// drops the substrate's chosen post-retry-exhaustion rollback semantic
15467/// from every emitted per-caixa `HelmRelease` document (the helm-
15468/// controller then leaves every terminally-failed upgrade in the failed
15469/// state without rolling back to the prior last-known-good release the
15470/// substrate's "no chart apply leaves a per-caixa CR in a stalled,
15471/// unremediated state" MESH-COMPOSITION.md §V guarantee mandates — with
15472/// no diagnostic naming the remediation-toggle-drift root cause far from
15473/// the source `caixa.lisp` / the renderer's format-string template).
15474///
15475/// Note the axis is asymmetric across the peer install-path per-CR
15476/// remediation block: the substrate emits the toggle only under
15477/// `spec.upgrade.remediation` and not under `spec.install.remediation`
15478/// because the Flux v2 helm-controller's install-path per-CR remediation
15479/// loop treats a failed first-time chart apply as an uninstall-and-retry
15480/// pipeline whose "prior success" state is the empty pre-install cluster
15481/// state — the "roll back to the prior success" post-retry-exhaustion
15482/// behavior the toggle gates is well-defined only on the upgrade-path
15483/// where the prior success is a previous chart-version release, which is
15484/// why the [`FLUX_HELMRELEASE_KEY_RETRIES`] retry-cap leaf-scalar-key
15485/// sits under both per-CR remediation sub-containers (retry-cap applies
15486/// on both paths) but this per-CR remediation-toggle leaf-scalar-key
15487/// sits under the upgrade-path per-CR remediation sub-container only.
15488///
15489/// The single source of truth every rendered Flux bundle axis that names
15490/// the upgrade-path per-CR remediation-toggle leaf reaches for:
15491///
15492/// - the rendered `helmrelease.yaml` document's
15493/// `spec.upgrade.remediation.remediateLastFailure` leaf-scalar-key
15494/// axis (caixa-flux/src/lib.rs — the `cluster_bundle` `helmrelease
15495/// .yaml` format-string template's upgrade-path remediation-toggle
15496/// leaf under the [`FLUX_HELMRELEASE_KEY_REMEDIATION`]-container-keyed
15497/// sub-block, threading the same `&'static str` through a new
15498/// `{remediate_last_failure_key}` named-arg interpolation);
15499/// - the one test-fixture navigation site in caixa-flux's `mod tests`
15500/// that probes the rendered document's `.get("remediateLastFailure")`
15501/// leaf axis to pin the substrate's canonical `true` seed
15502/// (the [`cluster_bundle_helmrelease_upgrade_remediation_remediate_last_failure_pins_lifted_true`]
15503/// upgrade-path production-emit pin).
15504///
15505/// Both the production emit site + the one test-fixture navigation site
15506/// name the same Flux v2 per-CR upgrade-path remediation-toggle leaf-
15507/// scalar-key and must move together on any hypothetical Flux v3 rename
15508/// (upstream Flux v3 roadmap floats candidates like
15509/// `rollbackOnFailure` / `remediateOnFailure` / `recoverLastFailure` in
15510/// the migration prose). Until this lift landed the axis carried inline
15511/// `remediateLastFailure` literals across the one production emit site
15512/// (caixa-flux/src/lib.rs — the `remediateLastFailure: true` leaf inside
15513/// the `cluster_bundle` `helmrelease.yaml` format-string template's per-
15514/// CR upgrade-path remediation sub-block) — the sole occurrence of the
15515/// same load-bearing Flux-v2-per-CR-upgrade-path-remediation-toggle-
15516/// leaf-scalar-key convention, drift-prone by construction ahead of the
15517/// second occurrence the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
15518/// materializer's per-Aplicacao `HelmRelease` synthesis will surface,
15519/// where a per-renderer local `pub const FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE:
15520/// &str = "…"` (the canonical drift footgun where a sibling local
15521/// `pub const` could happen to carry the same string at the source while
15522/// pointing at a different `&'static` allocation) would let the two
15523/// renderers silently disagree on the post-retry-exhaustion remediation
15524/// semantic.
15525///
15526/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5, "every
15527/// recurring shape becomes a generator before it becomes a pattern; every
15528/// pattern becomes a library before it becomes duplicated code. The
15529/// duplication budget is zero.") promotes the constant to a typed
15530/// substrate-side `&'static str` in advance of the second occurrence the
15531/// M4 materializer will surface — so the second consumer inherits the
15532/// canonical upgrade-path per-CR remediation-toggle leaf-scalar-key by
15533/// construction without opportunity for per-renderer drift.
15534///
15535/// Same "the typed constant lives in one place" discipline the sibling
15536/// [`FLUX_HELMRELEASE_KEY_RETRIES`] (a12f9fc) leaf-scalar-key +
15537/// [`FLUX_HELMRELEASE_KEY_REMEDIATION`] (6fe4e7e) sub-container-axis-key +
15538/// [`FLUX_HELMRELEASE_KEY_INSTALL`] / [`FLUX_HELMRELEASE_KEY_UPGRADE`]
15539/// (7767c26) parent-container-axis-key pair +
15540/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) scalar-
15541/// value halves of the per-path per-CR remediation surface established —
15542/// closes the sibling upgrade-path-only per-CR remediation-toggle leaf-
15543/// scalar-key half at the same `spec.upgrade.remediation.*` position the
15544/// retries leaf sits at.
15545///
15546/// [cf]: ../../caixa_flux/index.html
15547pub const FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE: &str = "remediateLastFailure";
15548
15549/// Canonical Flux v2 `HelmRelease.spec.upgrade.remediation.remediateLastFailure`
15550/// upgrade-path-only per-CR remediation-toggle scalar-value default the
15551/// substrate seeds into every per-caixa `helmrelease.yaml` document at the
15552/// paired [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] leaf-scalar-key
15553/// axis. Pairs with the sibling [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`]
15554/// (96581b7) leaf-scalar-key half of the same `(leaf-key, scalar-value)`
15555/// per-CR upgrade-path per-CR post-retry-exhaustion-rollback-toggle
15556/// declaration pair — the Flux v2 helm-controller's per-CR upgrade-path
15557/// remediation loop reads the scalar under that exact leaf key to decide
15558/// whether to trigger the prior-release rollback pipeline once the paired
15559/// [`FLUX_HELMRELEASE_KEY_RETRIES`] retry-cap ceiling has been exhausted,
15560/// so drift on either axis is equally load-bearing (a rebrand on this
15561/// canonical scalar-value default that failed to reach every renderer's
15562/// emit site would silently split the substrate's chosen post-retry-
15563/// exhaustion rollback semantic between the operator-facing canonical
15564/// default and every per-caixa `HelmRelease` document's per-CR upgrade-
15565/// path remediation-toggle, with no field naming the semantic-drift root
15566/// cause far from the source `caixa.lisp` / the renderer's format-string
15567/// template).
15568///
15569/// The `true` seed opts every emitted per-caixa `HelmRelease` into the
15570/// substrate's canonical "no chart apply leaves a per-caixa CR in a
15571/// stalled, unremediated state" semantic (MESH-COMPOSITION.md §V): once
15572/// the paired [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] retry-cap
15573/// ceiling is exhausted on the upgrade-path per-CR reconcile loop the
15574/// helm-controller rolls the per-caixa release back to the prior last-
15575/// known-good `HelmRelease.status.lastAppliedRevision` snapshot rather
15576/// than leaving the per-caixa `HelmRelease` parked at `Ready: False`
15577/// with no forward-progress on the substrate's per-caixa reconciliation
15578/// topology. A future substrate-side rebrand to `false` (or a per-caixa
15579/// opt-out slot the ABSORPTION-ROADMAP.md M4 typed-slot trajectory adds
15580/// once the substrate grows a `:upgrade :remediate-last-failure` author-
15581/// side toggle) is a one-line edit on this canonical declaration, not a
15582/// coordinated rewrite across every future per-target renderer the
15583/// substrate adds. Peer with the sibling
15584/// [`FLUX_KUSTOMIZATION_PRUNE_DEFAULT`] (ea857d8) scalar-value default on
15585/// the peer canonical-Flux-v2-per-CR-substrate-default surface — the
15586/// garbage-collection-toggle default names whether the per-CR
15587/// `Kustomization` reconcile loop sweeps orphaned resources at all, and
15588/// this remediation-toggle default names whether the per-CR `HelmRelease`
15589/// upgrade-path remediation loop rolls back to the prior last-known-good
15590/// release once the retry-cap ceiling is exhausted. Both are substrate-
15591/// side policy choices the operator inherits when the per-caixa
15592/// [`ClusterBundleOpts`][co] doesn't pin an override, and both must move
15593/// together on any coordinated substrate-side Flux v2 per-CR
15594/// tuning-cycle promotion.
15595///
15596/// The single source of truth every rendered Flux bundle axis that
15597/// names the per-CR upgrade-path remediation-toggle scalar reaches for:
15598///
15599/// - the rendered `helmrelease.yaml` document's
15600/// `spec.upgrade.remediation.remediateLastFailure` scalar-value axis
15601/// (caixa-flux/src/lib.rs — the [`cluster_bundle`][cb]
15602/// `helmrelease.yaml` format-string template's per-CR upgrade-path
15603/// remediation-toggle scalar under the
15604/// [`FLUX_HELMRELEASE_KEY_UPGRADE`]-keyed sub-block, threading the
15605/// same `bool` through a `{remediate_last_failure_default}` named-arg
15606/// interpolation);
15607/// - the one test-fixture navigation site in caixa-flux's `mod tests`
15608/// that probes the rendered document's
15609/// `.get("remediateLastFailure")` scalar axis to pin the substrate's
15610/// canonical `true` seed against the lifted default (the
15611/// [`cluster_bundle_helmrelease_upgrade_remediation_remediate_last_failure_pins_lifted_true`]
15612/// per-CR production-emit pin).
15613///
15614/// Both the production emit site + the one test-fixture navigation site
15615/// now consume the same `bool` at emit time through the sibling
15616/// re-export [`caixa_flux::FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT`][cf],
15617/// so a future substrate-side toggle migration on the canonical scalar-
15618/// value axis reaches every consumer through one `bool` by construction —
15619/// with no opportunity for per-renderer drift where a rebrand on one
15620/// axis without a coordinated edit on the other would silently disagree
15621/// on the post-retry-exhaustion rollback semantic. Until this lift
15622/// landed the axis carried an inline `true` scalar-value literal at the
15623/// sole production-code call site (the `remediateLastFailure: true` leaf
15624/// inside the [`cluster_bundle`][cb] `helmrelease.yaml` format-string
15625/// template's per-CR `spec.upgrade.remediation` sub-block) plus the
15626/// sibling test-fixture navigation site — two occurrences of the same
15627/// load-bearing Flux-v2-per-CR-upgrade-path-remediation-toggle-scalar-
15628/// value convention, drift-prone by construction ahead of the third
15629/// occurrence the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
15630/// per-Aplicacao `HelmRelease` synthesis will surface, where a per-
15631/// renderer local `pub const FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT: bool = …`
15632/// at any downstream renderer would let the two consumers silently
15633/// disagree on the substrate's canonical seed.
15634///
15635/// Same "the typed constant lives in one place" discipline the
15636/// [`DEFAULT_NAMESPACE`] (a085b26) / [`DEFAULT_FLUX_SYSTEM_NAMESPACE`]
15637/// (7197d38) / [`DEFAULT_LIBRARY_NAME`] (41438dc) /
15638/// [`crate::DEFAULT_SERVICO_PORT`] (1e22add) /
15639/// [`DEFAULT_GATEWAY_CLASS_NAME`] (d9b0743) /
15640/// [`crate::DEFAULT_PUBLISH_TAG_PREFIX`] (0a6a602) /
15641/// [`DEFAULT_FLUX_RECONCILE_INTERVAL`] (908180f) /
15642/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) /
15643/// [`FLUX_KUSTOMIZATION_PRUNE_DEFAULT`] (ea857d8) lifts apply on the peer
15644/// canonical-substrate-default-load-bearing-scalar surface.
15645///
15646/// [cb]: ../../caixa_flux/fn.cluster_bundle.html
15647/// [cf]: ../../caixa_flux/index.html
15648/// [co]: ../../caixa_flux/struct.ClusterBundleOpts.html
15649pub const FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT: bool = true;
15650
15651/// Canonical Flux v2 `HelmRelease.spec.install.createNamespace` install-path-
15652/// only per-CR namespace-seeder-toggle leaf-scalar-key every `caixa-flux`-
15653/// emitted `helmrelease.yaml` document seeds to `true` under the sibling
15654/// [`FLUX_HELMRELEASE_KEY_INSTALL`] per-CR install-path phase-discriminator
15655/// parent-container-axis-key. Peer to the sibling
15656/// [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] upgrade-path-only per-CR
15657/// remediation-toggle leaf-scalar-key at the co-resident per-CR install/
15658/// upgrade phase-discriminator parent-container position — closes the
15659/// `spec.{install.createNamespace, upgrade.remediation.remediateLastFailure}`
15660/// per-path per-CR phase-specific toggle leaf-scalar-key pair the substrate
15661/// seeds into every emitted per-caixa `HelmRelease` CR: `createNamespace`
15662/// gates the "the Flux v2 helm-controller creates the target namespace
15663/// itself if the emitted `HelmRelease.metadata.namespace` (or its
15664/// `spec.targetNamespace` override) does not already exist" install-path
15665/// pre-apply seeder pipeline, while `remediateLastFailure` gates the
15666/// upgrade-path post-retry-exhaustion rollback pipeline. The Flux v2 helm-
15667/// controller-side per-CR install-path pre-apply loop keys off this exact
15668/// leaf to decide whether to first materialize the target namespace or
15669/// refuse the first-time chart apply when the target namespace does not
15670/// yet exist (`false`); drift on this axis silently drops the substrate's
15671/// chosen first-apply namespace-seeder semantic from every emitted per-
15672/// caixa `HelmRelease` document (the helm-controller then refuses every
15673/// first-time per-caixa chart apply against a fresh cluster whose target
15674/// namespace has not been pre-provisioned by an out-of-band pipeline —
15675/// the substrate's "no per-caixa Servico apply is blocked on manual
15676/// namespace preprovisioning" MESH-COMPOSITION.md §V install-path-fluency
15677/// guarantee silently regresses, with no diagnostic naming the seeder-
15678/// toggle-drift root cause far from the source `caixa.lisp` / the
15679/// renderer's format-string template).
15680///
15681/// Note the axis is asymmetric across the peer upgrade-path per-CR phase
15682/// block: the substrate emits the toggle only under `spec.install` and not
15683/// under `spec.upgrade` because the Flux v2 helm-controller's upgrade-path
15684/// per-CR reconcile loop presupposes the target namespace already carries
15685/// the prior release's resources (the upgrade-path is by definition a
15686/// re-apply against an already-materialized namespace whose pre-apply
15687/// seeding was resolved at the sibling install-path phase's first-time
15688/// apply), so the "seed the target namespace if it does not already exist"
15689/// pre-apply behavior the toggle gates is well-defined only on the
15690/// install-path where the target namespace's existence is not yet
15691/// established. This is the mirror of the peer sibling
15692/// [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] axis, which is
15693/// upgrade-path-only for the mirror reason (the "roll back to the prior
15694/// success" post-retry-exhaustion behavior is well-defined only on the
15695/// upgrade-path where a prior success exists) — the two per-CR phase-
15696/// specific toggle leaf-scalar-keys sit under mirror-symmetric
15697/// parent-container-axis-keys and together close the install/upgrade
15698/// phase-block per-CR-phase-specific toggle leaf-scalar-key pair.
15699///
15700/// The single source of truth every rendered Flux bundle axis that names
15701/// the install-path per-CR namespace-seeder-toggle leaf reaches for:
15702///
15703/// - the rendered `helmrelease.yaml` document's
15704/// `spec.install.createNamespace` leaf-scalar-key axis
15705/// (caixa-flux/src/lib.rs — the `cluster_bundle` `helmrelease.yaml`
15706/// format-string template's install-path namespace-seeder-toggle leaf
15707/// under the [`FLUX_HELMRELEASE_KEY_INSTALL`]-container-keyed sub-block,
15708/// threading the same `&'static str` through a new
15709/// `{create_namespace_key}` named-arg interpolation);
15710/// - the one test-fixture navigation site in caixa-flux's `mod tests`
15711/// that probes the rendered document's `.get("createNamespace")` leaf
15712/// axis to pin the substrate's canonical `true` seed
15713/// (the [`cluster_bundle_helmrelease_install_create_namespace_pins_lifted_true`]
15714/// install-path production-emit pin).
15715///
15716/// Both the production emit site + the one test-fixture navigation site
15717/// name the same Flux v2 per-CR install-path namespace-seeder-toggle leaf-
15718/// scalar-key and must move together on any hypothetical Flux v3 rename
15719/// (upstream Flux v3 roadmap floats candidates like `createTargetNamespace`
15720/// / `seedNamespace` / `provisionNamespace` in the migration prose). Until
15721/// this lift landed the axis carried inline `createNamespace` literals
15722/// across the one production emit site (caixa-flux/src/lib.rs — the
15723/// `createNamespace: true` leaf inside the `cluster_bundle` `helmrelease
15724/// .yaml` format-string template's per-CR install-path sub-block) — the
15725/// sole occurrence of the same load-bearing Flux-v2-per-CR-install-path-
15726/// namespace-seeder-toggle-leaf-scalar-key convention, drift-prone by
15727/// construction ahead of the second occurrence the M4
15728/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
15729/// `HelmRelease` synthesis will surface, where a per-renderer local
15730/// `pub const FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE: &str = "…"` (the
15731/// canonical drift footgun where a sibling local `pub const` could happen
15732/// to carry the same string at the source while pointing at a different
15733/// `&'static` allocation) would let the two renderers silently disagree on
15734/// the install-path namespace-seeder semantic.
15735///
15736/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5, "every
15737/// recurring shape becomes a generator before it becomes a pattern; every
15738/// pattern becomes a library before it becomes duplicated code. The
15739/// duplication budget is zero.") promotes the constant to a typed
15740/// substrate-side `&'static str` in advance of the second occurrence the
15741/// M4 materializer will surface — so the second consumer inherits the
15742/// canonical install-path per-CR namespace-seeder-toggle leaf-scalar-key
15743/// by construction without opportunity for per-renderer drift.
15744///
15745/// Same "the typed constant lives in one place" discipline the sibling
15746/// [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] (96581b7) upgrade-path-
15747/// only per-CR remediation-toggle leaf-scalar-key +
15748/// [`FLUX_HELMRELEASE_KEY_RETRIES`] (a12f9fc) leaf-scalar-key +
15749/// [`FLUX_HELMRELEASE_KEY_REMEDIATION`] (6fe4e7e) sub-container-axis-key +
15750/// [`FLUX_HELMRELEASE_KEY_INSTALL`] / [`FLUX_HELMRELEASE_KEY_UPGRADE`]
15751/// (7767c26) parent-container-axis-key pair +
15752/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) scalar-value
15753/// halves of the per-path per-CR HelmRelease spec surface established —
15754/// closes the mirror install-path-only per-CR namespace-seeder-toggle
15755/// leaf-scalar-key half at the `spec.install.createNamespace` position the
15756/// peer `spec.upgrade.remediation.remediateLastFailure` upgrade-path-only
15757/// per-CR remediation-toggle leaf mirrors.
15758///
15759/// [cf]: ../../caixa_flux/index.html
15760pub const FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE: &str = "createNamespace";
15761
15762/// Canonical Flux v2 `HelmRelease.spec.install.createNamespace` install-path-
15763/// only per-CR namespace-seeder-toggle scalar-value default the substrate
15764/// seeds into every per-caixa `helmrelease.yaml` document at the paired
15765/// [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] leaf-scalar-key axis. Pairs
15766/// with the sibling [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] (ba9ab8b)
15767/// leaf-scalar-key half of the same `(leaf-key, scalar-value)` per-CR
15768/// install-path per-CR namespace-seeder-toggle declaration pair — the
15769/// Flux v2 helm-controller's per-CR install-path pre-apply loop reads
15770/// the scalar under that exact leaf key to decide whether to first
15771/// materialize the target namespace before the first-time chart apply,
15772/// so drift on either axis is equally load-bearing (a rebrand on this
15773/// canonical scalar-value default that failed to reach every renderer's
15774/// emit site would silently split the substrate's chosen first-apply
15775/// namespace-seeder semantic between the operator-facing canonical
15776/// default and every per-caixa `HelmRelease` document's per-CR install-
15777/// path namespace-seeder-toggle, with no field naming the semantic-drift
15778/// root cause far from the source `caixa.lisp` / the renderer's format-
15779/// string template).
15780///
15781/// The `true` seed opts every emitted per-caixa `HelmRelease` into the
15782/// substrate's canonical "no per-caixa Servico apply is blocked on
15783/// manual namespace preprovisioning" semantic (MESH-COMPOSITION.md §V
15784/// install-path-fluency guarantee): on every first-time per-caixa chart
15785/// apply the helm-controller first materializes the target namespace
15786/// itself if the emitted `HelmRelease.metadata.namespace` (or its
15787/// `spec.targetNamespace` override) does not already exist, rather than
15788/// refusing the apply and requiring an out-of-band pipeline to have
15789/// pre-provisioned the namespace. A future substrate-side rebrand to
15790/// `false` (or a per-caixa opt-out slot the ABSORPTION-ROADMAP.md M4
15791/// typed-slot trajectory adds once the substrate grows a `:install
15792/// :create-namespace` author-side toggle) is a one-line edit on this
15793/// canonical declaration, not a coordinated rewrite across every future
15794/// per-target renderer the substrate adds. Peer with the sibling
15795/// [`FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT`] mirror-symmetric
15796/// upgrade-path-only scalar-value default + the peer
15797/// [`FLUX_KUSTOMIZATION_PRUNE_DEFAULT`] (ea857d8) scalar-value default on
15798/// the peer canonical-Flux-v2-per-CR-substrate-default surface — the
15799/// three defaults name the substrate's canonical (install-path
15800/// namespace-seeder) / (upgrade-path post-retry-exhaustion rollback) /
15801/// (garbage-collection-toggle) toggle triple across the per-caixa
15802/// `HelmRelease` and `Kustomization` co-resident CRs. All three are
15803/// substrate-side policy choices the operator inherits when the per-
15804/// caixa [`ClusterBundleOpts`][co] doesn't pin an override, and all
15805/// three must move together on any coordinated substrate-side Flux v2
15806/// per-CR tuning-cycle promotion.
15807///
15808/// The single source of truth every rendered Flux bundle axis that
15809/// names the per-CR install-path namespace-seeder-toggle scalar reaches
15810/// for:
15811///
15812/// - the rendered `helmrelease.yaml` document's
15813/// `spec.install.createNamespace` scalar-value axis
15814/// (caixa-flux/src/lib.rs — the [`cluster_bundle`][cb]
15815/// `helmrelease.yaml` format-string template's per-CR install-path
15816/// namespace-seeder-toggle scalar under the
15817/// [`FLUX_HELMRELEASE_KEY_INSTALL`]-keyed sub-block, threading the
15818/// same `bool` through a `{create_namespace_default}` named-arg
15819/// interpolation);
15820/// - the one test-fixture navigation site in caixa-flux's `mod tests`
15821/// that probes the rendered document's `.get("createNamespace")`
15822/// scalar axis to pin the substrate's canonical `true` seed against
15823/// the lifted default (the
15824/// [`cluster_bundle_helmrelease_install_create_namespace_pins_lifted_true`]
15825/// per-CR production-emit pin).
15826///
15827/// Both the production emit site + the one test-fixture navigation site
15828/// now consume the same `bool` at emit time through the sibling
15829/// re-export [`caixa_flux::FLUX_HELMRELEASE_CREATE_NAMESPACE_DEFAULT`][cf],
15830/// so a future substrate-side toggle migration on the canonical scalar-
15831/// value axis reaches every consumer through one `bool` by construction —
15832/// with no opportunity for per-renderer drift where a rebrand on one
15833/// axis without a coordinated edit on the other would silently disagree
15834/// on the first-apply namespace-seeder semantic. Until this lift landed
15835/// the axis carried an inline `true` scalar-value literal at the sole
15836/// production-code call site (the `createNamespace: true` leaf inside
15837/// the [`cluster_bundle`][cb] `helmrelease.yaml` format-string
15838/// template's per-CR `spec.install` sub-block) plus the sibling test-
15839/// fixture navigation site — two occurrences of the same load-bearing
15840/// Flux-v2-per-CR-install-path-namespace-seeder-toggle-scalar-value
15841/// convention, drift-prone by construction ahead of the third occurrence
15842/// the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-
15843/// Aplicacao `HelmRelease` synthesis will surface, where a per-renderer
15844/// local `pub const FLUX_HELMRELEASE_CREATE_NAMESPACE_DEFAULT: bool = …`
15845/// at any downstream renderer would let the two consumers silently
15846/// disagree on the substrate's canonical seed.
15847///
15848/// Same "the typed constant lives in one place" discipline the
15849/// [`DEFAULT_NAMESPACE`] (a085b26) / [`DEFAULT_FLUX_SYSTEM_NAMESPACE`]
15850/// (7197d38) / [`DEFAULT_LIBRARY_NAME`] (41438dc) /
15851/// [`crate::DEFAULT_SERVICO_PORT`] (1e22add) /
15852/// [`DEFAULT_GATEWAY_CLASS_NAME`] (d9b0743) /
15853/// [`crate::DEFAULT_PUBLISH_TAG_PREFIX`] (0a6a602) /
15854/// [`DEFAULT_FLUX_RECONCILE_INTERVAL`] (908180f) /
15855/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) /
15856/// [`FLUX_KUSTOMIZATION_PRUNE_DEFAULT`] (ea857d8) /
15857/// [`FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT`] lifts apply on
15858/// the peer canonical-substrate-default-load-bearing-scalar surface.
15859///
15860/// [cb]: ../../caixa_flux/fn.cluster_bundle.html
15861/// [cf]: ../../caixa_flux/index.html
15862/// [co]: ../../caixa_flux/struct.ClusterBundleOpts.html
15863pub const FLUX_HELMRELEASE_CREATE_NAMESPACE_DEFAULT: bool = true;
15864
15865/// Canonical Flux v2 `Kustomization.spec.prune` per-CR garbage-collection-
15866/// toggle leaf-scalar-key every `caixa-flux`-emitted `kustomization.yaml`
15867/// document seeds to `true` at the top-level `spec` position of the
15868/// emitted [`Kustomization`][kust] CR. The Flux v2 kustomize-controller-
15869/// side per-CR reconcile loop keys off this exact leaf to decide whether
15870/// to garbage-collect resources that were previously reconciled by the
15871/// CR but no longer appear in the CR's current desired-state manifest set
15872/// (`spec.prune: true` opts every emitted per-caixa `Kustomization` into
15873/// the substrate's canonical GitOps-side sweep-what-you-removed semantic;
15874/// `spec.prune: false` (or absent — Flux v2 defaults the axis to `false`
15875/// on any CR that omits the leaf) leaves orphaned resources dangling in
15876/// the cluster after the source manifest set removes them, silently
15877/// splitting per-caixa live cluster state from the caixa's tatara-lisp
15878/// source-of-truth and every downstream `feira app deploy` / `feira
15879/// deploy` reconcile the substrate's per-caixa GitOps pipeline emits).
15880///
15881/// Drift on this axis silently drops the substrate's chosen sweep-what-
15882/// you-removed semantic from every emitted per-caixa `Kustomization`
15883/// document — the kustomize-controller then leaves every per-caixa
15884/// resource the source manifest set previously reconciled but no longer
15885/// carries dangling in the cluster with no diagnostic naming the toggle-
15886/// drift root cause far from the source `caixa.lisp` / the renderer's
15887/// format-string template, and the substrate's "the cluster's per-caixa
15888/// live state converges to the caixa's tatara-lisp source-of-truth on
15889/// every reconcile — resources the source no longer carries are swept
15890/// by the kustomize-controller, not left dangling" CAIXA-SDLC.md §V
15891/// author-to-live-convergence guarantee silently regresses.
15892///
15893/// Note the axis is asymmetric across the co-resident `HelmRelease` CR:
15894/// the peer `HelmRelease` document seeds no `spec.prune` leaf because
15895/// the Flux v2 helm-controller-side per-CR reconcile loop keys off Helm
15896/// 3's own release-scoped resource-tracking manifest (the per-release
15897/// `helm.sh/release-name` label + `secrets/sh.helm.release.v1.*` release
15898/// snapshots) to garbage-collect resources removed between chart
15899/// versions rather than a CR-level toggle, so the `spec.prune` leaf is
15900/// well-defined only on the `Kustomization` CR whose kustomize-controller
15901/// reconcile loop tracks resources by the CR's manifest set rather than
15902/// Helm's per-release snapshots. This is the mirror of the peer sibling
15903/// [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] axis, which is `HelmRelease`-
15904/// CR-only for the mirror reason (Helm 3's chart-side `Chart.yaml`
15905/// declares no target-namespace-creation semantic of its own, so the
15906/// helm-controller carries a per-CR toggle at `spec.install.createNamespace`
15907/// that the peer kustomize-controller has no need to mirror since the
15908/// upstream Kustomize project's per-CR spec block establishes the
15909/// target-namespace independently at each `kustomization.yaml` document's
15910/// own `metadata.namespace` axis).
15911///
15912/// The single source of truth every rendered Flux bundle axis that names
15913/// the per-CR garbage-collection-toggle leaf reaches for:
15914///
15915/// - the rendered `kustomization.yaml` document's `spec.prune` leaf-
15916/// scalar-key axis (caixa-flux/src/lib.rs — the `cluster_bundle`
15917/// `kustomization.yaml` format-string template's per-CR garbage-
15918/// collection-toggle leaf under the top-level `spec` position,
15919/// threading the same `&'static str` through a new `{prune_key}`
15920/// named-arg interpolation);
15921/// - the one test-fixture navigation site in caixa-flux's `mod tests`
15922/// that probes the rendered document's `.get("prune")` leaf axis to
15923/// pin the substrate's canonical `true` seed (the
15924/// [`cluster_bundle_kustomization_prune_pins_lifted_true`] per-CR
15925/// production-emit pin).
15926///
15927/// Both the production emit site + the one test-fixture navigation site
15928/// name the same Flux v2 per-CR garbage-collection-toggle leaf-scalar-
15929/// key and must move together on any hypothetical Flux v3 rename
15930/// (upstream Flux v3 roadmap floats candidates like `garbageCollect` /
15931/// `sweep` / `pruneOrphaned` / `deleteOrphans` in the migration prose).
15932/// Until this lift landed the axis carried an inline `prune` literal at
15933/// the one production emit site (caixa-flux/src/lib.rs — the
15934/// `prune: true` leaf inside the `cluster_bundle` `kustomization.yaml`
15935/// format-string template's top-level `spec` position) — the sole
15936/// occurrence of the same load-bearing Flux-v2-per-CR-garbage-
15937/// collection-toggle-leaf-scalar-key convention, drift-prone by
15938/// construction ahead of the second occurrence the M4
15939/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
15940/// `Kustomization` synthesis will surface, where a per-renderer local
15941/// `pub const FLUX_KUSTOMIZATION_KEY_PRUNE: &str = "…"` (the canonical
15942/// drift footgun where a sibling local `pub const` could happen to
15943/// carry the same string at the source while pointing at a different
15944/// `&'static` allocation) would let the two renderers silently disagree
15945/// on the substrate's canonical sweep-what-you-removed semantic.
15946///
15947/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
15948/// "every recurring shape becomes a generator before it becomes a
15949/// pattern; every pattern becomes a library before it becomes
15950/// duplicated code. The duplication budget is zero.") promotes the
15951/// constant to a typed substrate-side `&'static str` in advance of the
15952/// second occurrence the M4 materializer will surface — so the second
15953/// consumer inherits the canonical per-CR garbage-collection-toggle
15954/// leaf-scalar-key by construction without opportunity for per-renderer
15955/// drift.
15956///
15957/// Same "the typed constant lives in one place" discipline the sibling
15958/// [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] (ba9ab8b) install-path-only
15959/// per-CR namespace-seeder-toggle leaf-scalar-key +
15960/// [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] (96581b7) upgrade-
15961/// path-only per-CR remediation-toggle leaf-scalar-key +
15962/// [`FLUX_HELMRELEASE_KEY_RETRIES`] (a12f9fc) leaf-scalar-key +
15963/// [`FLUX_HELMRELEASE_KEY_REMEDIATION`] (6fe4e7e) sub-container-axis-key
15964/// + [`FLUX_HELMRELEASE_KEY_INSTALL`] / [`FLUX_HELMRELEASE_KEY_UPGRADE`]
15965/// (7767c26) parent-container-axis-key pair +
15966/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) scalar-
15967/// value halves of the per-path per-CR HelmRelease spec surface
15968/// established — extends the discipline from the co-resident per-caixa
15969/// `HelmRelease` CR spec surface onto the co-resident per-caixa
15970/// `Kustomization` CR spec surface at the mirror-symmetric top-level
15971/// `spec.prune` position.
15972///
15973/// [cf]: ../../caixa_flux/index.html
15974/// [kust]: https://fluxcd.io/flux/components/kustomize/kustomizations/
15975pub const FLUX_KUSTOMIZATION_KEY_PRUNE: &str = "prune";
15976
15977/// Canonical Flux v2 `Kustomization.spec.prune` per-CR garbage-collection-
15978/// toggle scalar-value default the substrate seeds into every per-caixa
15979/// `kustomization.yaml` document at the paired
15980/// [`FLUX_KUSTOMIZATION_KEY_PRUNE`] leaf-scalar-key axis. Pairs with the
15981/// sibling [`FLUX_KUSTOMIZATION_KEY_PRUNE`] (8ec7917) leaf-scalar-key
15982/// half of the same `(leaf-key, scalar-value)` per-CR garbage-collection-
15983/// toggle declaration pair — the Flux v2 kustomize-controller's per-CR
15984/// reconcile loop reads the scalar under that exact leaf key, so drift
15985/// on either axis is equally load-bearing (a rebrand on this canonical
15986/// scalar-value default that failed to reach every renderer's emit site
15987/// would silently split the substrate's chosen sweep-what-you-removed
15988/// semantic between the operator-facing canonical default and every
15989/// per-caixa `Kustomization` document's per-CR garbage-collection-toggle,
15990/// with no field naming the semantic-drift root cause far from the
15991/// source `caixa.lisp` / the renderer's format-string template).
15992///
15993/// The `true` seed opts every emitted per-caixa `Kustomization` into
15994/// the substrate's canonical GitOps-side sweep-what-you-removed
15995/// semantic: on every reconcile the kustomize-controller garbage-
15996/// collects any per-caixa resource the source manifest set previously
15997/// reconciled but no longer carries, converging the cluster's per-
15998/// caixa live state to the caixa's tatara-lisp source-of-truth
15999/// verbatim. A future substrate-side rebrand to `false` (or a per-
16000/// cluster override the operator pins for a class of clusters where a
16001/// human is expected to prune orphaned resources by hand, or a
16002/// per-caixa opt-out slot the ABSORPTION-ROADMAP.md M4 typed-slot
16003/// trajectory adds once the substrate grows a `:kustomization :prune`
16004/// author-side toggle) is a one-line edit on this canonical declaration,
16005/// not a coordinated rewrite across every future per-target renderer
16006/// the substrate adds. Peer with the sibling
16007/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) scalar-
16008/// value default on the peer canonical-Flux-v2-per-CR-substrate-
16009/// default surface — the retry-cap default names the per-path per-CR
16010/// remediation retry ceiling, and this garbage-collection-toggle
16011/// default names whether the per-CR reconcile loop sweeps orphaned
16012/// resources at all. Both are substrate-side policy choices the
16013/// operator inherits when the per-caixa [`ClusterBundleOpts`][co]
16014/// doesn't pin an override.
16015///
16016/// The single source of truth every rendered Flux bundle axis that
16017/// names the per-CR garbage-collection-toggle scalar reaches for:
16018///
16019/// - the rendered `kustomization.yaml` document's `spec.prune`
16020/// scalar-value axis (caixa-flux/src/lib.rs — the [`cluster_bundle`][cb]
16021/// `kustomization.yaml` format-string template's per-CR garbage-
16022/// collection-toggle scalar under the top-level `spec` position,
16023/// threading the same `bool` through a `{prune_default}` named-arg
16024/// interpolation);
16025/// - the one test-fixture navigation site in caixa-flux's `mod tests`
16026/// that probes the rendered document's `.get("prune")` scalar axis
16027/// to pin the substrate's canonical `true` seed against the lifted
16028/// default (the
16029/// [`cluster_bundle_kustomization_prune_pins_lifted_true`] per-CR
16030/// production-emit pin).
16031///
16032/// Both the production emit site + the one test-fixture navigation site
16033/// now consume the same `bool` at emit time through the sibling
16034/// re-export [`caixa_flux::FLUX_KUSTOMIZATION_PRUNE_DEFAULT`][cf], so a
16035/// future substrate-side toggle migration on the canonical scalar-value
16036/// axis reaches every consumer through one `bool` by construction —
16037/// with no opportunity for per-renderer drift where a rebrand on one
16038/// axis without a coordinated edit on the other would silently disagree
16039/// on the sweep-what-you-removed semantic. Until this lift landed the
16040/// axis carried an inline `true` scalar-value literal at the sole
16041/// production-code call site (the `prune: true` leaf inside the
16042/// [`cluster_bundle`][cb] `kustomization.yaml` format-string template's
16043/// top-level `spec` position) plus the sibling test-fixture navigation
16044/// site — two occurrences of the same load-bearing Flux-v2-per-CR-
16045/// garbage-collection-toggle-scalar-value convention, drift-prone by
16046/// construction ahead of the third occurrence the M4
16047/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
16048/// `Kustomization` synthesis will surface, where a per-renderer local
16049/// `pub const FLUX_KUSTOMIZATION_PRUNE_DEFAULT: bool = …` at any
16050/// downstream renderer would let the two consumers silently disagree
16051/// on the substrate's canonical seed.
16052///
16053/// Same "the typed constant lives in one place" discipline the
16054/// [`DEFAULT_NAMESPACE`] (a085b26) / [`DEFAULT_FLUX_SYSTEM_NAMESPACE`]
16055/// (7197d38) / [`DEFAULT_LIBRARY_NAME`] (41438dc) /
16056/// [`crate::DEFAULT_SERVICO_PORT`] (1e22add) /
16057/// [`DEFAULT_GATEWAY_CLASS_NAME`] (d9b0743) /
16058/// [`crate::DEFAULT_PUBLISH_TAG_PREFIX`] (0a6a602) /
16059/// [`DEFAULT_FLUX_RECONCILE_INTERVAL`] (908180f) /
16060/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) lifts apply
16061/// on the peer canonical-substrate-default-load-bearing-scalar surface.
16062///
16063/// [cb]: ../../caixa_flux/fn.cluster_bundle.html
16064/// [cf]: ../../caixa_flux/index.html
16065/// [co]: ../../caixa_flux/struct.ClusterBundleOpts.html
16066pub const FLUX_KUSTOMIZATION_PRUNE_DEFAULT: bool = true;
16067
16068/// Canonical substrate-side default for the
16069/// `HelmRelease.spec.values.<library>.enabled` scalar-value toggle every
16070/// [`caixa_flux::cluster_bundle`][cb]-emitted `helmrelease.yaml` document
16071/// seeds inside its per-caixa values overlay to force-on the paired
16072/// [`DEFAULT_LIBRARY_NAME`] child chart at the per-cluster
16073/// `HelmRelease`-side apply step. Pairs with the sibling
16074/// [`HELM_VALUES_KEY_ENABLED`] leaf-scalar-key half of the
16075/// `(leaf-key, scalar-value)` per-values-overlay child-chart
16076/// enablement-toggle declaration pair — the key half names the
16077/// canonical `values.<library>.enabled` leaf-scalar-key axis every
16078/// consumer (`caixa-helm`'s `values.yaml` per-chart default, this
16079/// crate's `cluster_bundle` overlay) probes on, and this scalar-value
16080/// half names the substrate-side default the `cluster_bundle` overlay
16081/// path seeds under it. Semantically distinct from — and inverse of —
16082/// the `RenderOpts::enabled_default = false` default that
16083/// [`caixa_helm::RenderOpts::default`] seeds for the standalone
16084/// `lareira-<nome>` chart's own `values.yaml` (that path renders
16085/// `enabled: false` so cluster operators must opt each caixa in
16086/// per-cluster); the `cluster_bundle` composition path is the
16087/// substrate-side opt-in path where the operator has already asserted
16088/// per-caixa cluster-scoped ownership by materializing a per-caixa
16089/// `GitRepository` + `HelmRelease` + `Kustomization` trio, so the overlay
16090/// forces the child chart on by seeding `enabled: true` under the
16091/// `values.<library>` wrap.
16092///
16093/// Rendered to canonical YAML `true` verbatim. A future substrate-side
16094/// rebrand to `false` (or the M4 typed-slot trajectory adding a per-caixa
16095/// `:cluster-bundle :enabled` author-side toggle the operator flips per
16096/// caixa) is a one-line edit on this canonical declaration, not a
16097/// coordinated rewrite across the sole production emit site + its
16098/// paired test-fixture navigation site. Peer with the sibling
16099/// [`FLUX_HELMRELEASE_CREATE_NAMESPACE_DEFAULT`] (be1904b),
16100/// [`FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT`] (be1904b),
16101/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae), and
16102/// [`FLUX_KUSTOMIZATION_PRUNE_DEFAULT`] (ea857d8) scalar-value defaults
16103/// on the peer canonical-Flux-v2-per-CR-substrate-default surface — the
16104/// four sibling scalar-value defaults name per-CR toggle-shape axes at
16105/// the `HelmRelease.spec.install.*` / `HelmRelease.spec.upgrade.*` /
16106/// `HelmRelease.spec.upgrade.remediation.retries` /
16107/// `Kustomization.spec.prune` sub-block positions, and this
16108/// scalar-value default names the child-chart-enablement toggle at the
16109/// deeper `HelmRelease.spec.values.<library>.enabled` values-overlay
16110/// position — all five are substrate-side policy choices the operator
16111/// inherits when the per-caixa [`ClusterBundleOpts`][co] doesn't pin an
16112/// override.
16113///
16114/// The single source of truth every rendered Flux bundle axis that
16115/// names the per-CR values-overlay child-chart-enablement-toggle
16116/// scalar reaches for:
16117///
16118/// - the rendered `helmrelease.yaml` document's
16119/// `spec.values.<library>.enabled` scalar-value axis
16120/// (caixa-flux/src/lib.rs — the [`cluster_bundle`][cb]
16121/// `helmrelease.yaml` format-string template's per-CR values-overlay
16122/// child-chart-enablement-toggle scalar under the per-`{library_name}`
16123/// wrap position, threading the same `bool` through a
16124/// `{lareira_enabled_default}` named-arg interpolation);
16125/// - the one test-fixture navigation site in caixa-flux's `mod tests`
16126/// that probes the rendered document's
16127/// `values.<library>.enabled` scalar axis to pin the substrate's
16128/// canonical `true` seed against the lifted default (the
16129/// `cluster_bundle_helmrelease_wrap_key_pins_canonical_pleme_computeunit_string`
16130/// per-CR production-emit pin's `Some(true)` assertion).
16131///
16132/// Both the production emit site + the test-fixture navigation site now
16133/// consume the same `bool` at emit time through the sibling re-export
16134/// [`caixa_flux::CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT`][cf], so a
16135/// future substrate-side toggle migration reaches every consumer through
16136/// one `bool` by construction — with no opportunity for per-renderer
16137/// drift where a rebrand on one axis without a coordinated edit on the
16138/// other would silently disagree on the substrate's chosen child-chart
16139/// force-on-under-composition semantic. Until this lift landed the
16140/// axis carried an inline `true` scalar-value literal at the sole
16141/// production-code call site (the `{enabled_key}: true` leaf inside the
16142/// [`cluster_bundle`][cb] `helmrelease.yaml` format-string template's
16143/// per-`{library_name}` wrap position) plus the test-fixture
16144/// navigation-site `Some(true)` assertion — two occurrences of the same
16145/// load-bearing values-overlay child-chart-enablement-toggle-scalar-value
16146/// convention, drift-prone by construction ahead of the third occurrence
16147/// the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
16148/// per-Aplicacao `HelmRelease` synthesis will surface.
16149///
16150/// [cb]: ../../caixa_flux/fn.cluster_bundle.html
16151/// [cf]: ../../caixa_flux/index.html
16152/// [co]: ../../caixa_flux/struct.ClusterBundleOpts.html
16153pub const CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT: bool = true;
16154
16155/// Canonical substrate-side default for the
16156/// `values.<library>.enabled` scalar-value toggle every
16157/// [`caixa_helm::render_chart_for_servico`][cs]-emitted standalone
16158/// `lareira-<nome>` chart's `values.yaml` document seeds inside its per-caixa
16159/// [`DEFAULT_LIBRARY_NAME`] wrap block to leave the paired
16160/// [`DEFAULT_LIBRARY_NAME`] child chart opted-out at the per-cluster
16161/// `helm template` / `helm install` apply step. Pairs with the sibling
16162/// [`HELM_VALUES_KEY_ENABLED`] leaf-scalar-key half of the
16163/// `(leaf-key, scalar-value)` per-values-block child-chart-enablement-toggle
16164/// declaration pair — the key half names the canonical
16165/// `values.<library>.enabled` leaf-scalar-key axis every consumer (this
16166/// standalone-path default, [`caixa_flux::cluster_bundle`][cb]'s per-CR
16167/// values-overlay) probes on, and this scalar-value half names the
16168/// substrate-side default the standalone per-chart path seeds under it.
16169/// Semantically distinct from — and inverse of — the peer
16170/// [`CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT`] default that
16171/// [`caixa_flux::cluster_bundle`][cb]'s `helmrelease.yaml` values overlay
16172/// seeds for the substrate-side composition-path force-on (that path
16173/// renders `enabled: true` in the per-cluster `HelmRelease.spec.values.<library>`
16174/// overlay so the operator's per-caixa cluster-scoped ownership at bundle
16175/// materialization time carries a force-on for the child chart); the
16176/// standalone per-chart path is the substrate-side opt-out path where the
16177/// operator has not yet asserted per-caixa cluster-scoped ownership by
16178/// materializing a per-caixa `GitRepository` + `HelmRelease` +
16179/// `Kustomization` trio, so the per-chart `values.yaml` seeds
16180/// `enabled: false` under the `values.<library>` wrap and cluster operators
16181/// must opt each caixa in per-cluster.
16182///
16183/// Rendered to canonical YAML `false` verbatim. A future substrate-side
16184/// rebrand to `true` (or the M4 typed-slot trajectory adding a per-caixa
16185/// `:standalone :enabled` author-side toggle the author flips per caixa) is
16186/// a one-line edit on this canonical declaration, not a coordinated rewrite
16187/// across the sole production emit site + its paired test-fixture
16188/// navigation sites. Peer with the sibling
16189/// [`CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT`] scalar-value default on the
16190/// peer canonical-Helm-per-values-block-substrate-default surface — the two
16191/// sibling scalar-value defaults name mirror-symmetric per-path
16192/// child-chart-enablement-toggle-scalar-value defaults at the exact same
16193/// `values.<library>.enabled` sub-block position on the standalone
16194/// per-chart-`values.yaml` path (this const) and the composition
16195/// per-cluster-`HelmRelease` values-overlay path
16196/// ([`CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT`]) — both are substrate-side
16197/// policy choices the operator inherits when the per-caixa
16198/// [`caixa_helm::RenderOpts`][cro] / [`caixa_flux::ClusterBundleOpts`][co]
16199/// doesn't pin an override.
16200///
16201/// The single source of truth every rendered `values.yaml` axis that
16202/// names the per-values-block child-chart-enablement-toggle scalar on the
16203/// standalone per-chart path reaches for:
16204///
16205/// - the rendered `values.yaml` document's
16206/// `<library>.enabled` scalar-value axis
16207/// (caixa-helm/src/lib.rs — the [`caixa_helm::build_values_yaml`][cbv]
16208/// `serde_yaml::Value::Bool(opts.enabled_default)` block-insertion
16209/// under the per-`{library_name}` wrap position, threading the same
16210/// `bool` through the [`caixa_helm::RenderOpts::enabled_default`][cro]
16211/// default-knob);
16212/// - the [`caixa_helm::RenderOpts::default()`][cro] impl-body
16213/// `enabled_default: STANDALONE_LAREIRA_ENABLED_DEFAULT` field seed
16214/// the standalone per-chart path threads into every per-caixa
16215/// `render_chart_for_servico` call site.
16216///
16217/// Both the production emit site + the default-knob seed now consume the
16218/// same `bool` at emit time through the sibling re-export
16219/// [`caixa_helm::STANDALONE_LAREIRA_ENABLED_DEFAULT`][ch], so a future
16220/// substrate-side toggle migration reaches every consumer through one
16221/// `bool` by construction — with no opportunity for per-renderer drift
16222/// where a rebrand on one axis without a coordinated edit on the other
16223/// would silently disagree on the substrate's chosen
16224/// standalone-per-chart-path opt-out semantic. Until this lift landed
16225/// the axis carried an inline `enabled_default: false` scalar-value
16226/// literal at the sole production-code call site (the
16227/// [`caixa_helm::RenderOpts::default()`][cro] impl-body field seed at
16228/// `caixa-helm/src/lib.rs:700`) — one occurrence of the same
16229/// load-bearing per-values-block child-chart-enablement-toggle-scalar-value
16230/// convention as the peer [`CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT`] on the
16231/// composition path, drift-prone by construction ahead of the M4
16232/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
16233/// per-Servico standalone-chart synthesis surfacing the third occurrence.
16234///
16235/// [cb]: ../../caixa_flux/fn.cluster_bundle.html
16236/// [cs]: ../../caixa_helm/fn.render_chart_for_servico.html
16237/// [cbv]: ../../caixa_helm/fn.build_values_yaml.html
16238/// [ch]: ../../caixa_helm/index.html
16239/// [cro]: ../../caixa_helm/struct.RenderOpts.html
16240/// [co]: ../../caixa_flux/struct.ClusterBundleOpts.html
16241pub const STANDALONE_LAREIRA_ENABLED_DEFAULT: bool = false;
16242
16243/// Canonical Flux v2 `Kustomization.spec.path` per-CR source-sub-tree
16244/// leaf-scalar-key every `caixa-flux`-emitted `kustomization.yaml`
16245/// document seeds under its top-level `spec` position to name the sub-
16246/// tree of the paired [`FLUX_GITREPOSITORY_YAML_FILENAME`] GitRepository
16247/// the Flux v2 kustomize-controller-side per-CR reconcile loop pulls
16248/// the desired-state manifest set from at reconcile time. Drift on this
16249/// leaf silently unbinds every per-caixa `Kustomization` from its
16250/// paired per-caixa sub-tree of the pleme-io k8s repository — the
16251/// kustomize-controller then either reconciles the whole GitRepository
16252/// root (when the CR omits the leaf, the controller defaults to `./`,
16253/// pulling every unrelated cluster's manifests through the wrong
16254/// per-caixa `Kustomization`) or refuses to reconcile at all (when the
16255/// leaf points at a path the GitRepository doesn't carry, the CR sits
16256/// perpetually at `BuildFailed` naming the missing sub-tree far from
16257/// the source `caixa.lisp` / the renderer's format-string template).
16258///
16259/// Distinct from the sibling K8s-Gateway-API-side [`GATEWAY_API_KEY_PATH`]
16260/// (9f45aa4) per-`HTTPRouteMatch` path-matcher container-axis key and
16261/// the sibling Cilium-CNP-side [`CILIUM_KEY_PATH`] (bec2ce9) per-
16262/// `toPorts[].rules.http[]` URL-path predicate leaf-scalar-key: all
16263/// three constants spell the same underlying `"path"` string but name
16264/// distinct schema axes on distinct CRD groups — the Flux-side axis is a
16265/// per-`Kustomization`-CR source-sub-tree leaf scalar on the Flux v2
16266/// `kustomize.toolkit.fluxcd.io/v1` `Kustomization` CRD's `spec.path`
16267/// entry, the Gateway-API-side axis is a per-`HTTPRouteMatch` path-
16268/// matcher two-leaf container (`{type, value}`) on the K8s Gateway API
16269/// v1 `HTTPRoute` CRD's `spec.rules[].matches[]` entry, the Cilium-side
16270/// axis is a per-HTTP-rule URL-path predicate leaf scalar on the Cilium
16271/// `cilium.io/v2` `CiliumNetworkPolicy` CRD's per-`toPorts[].rules.http[]`
16272/// entry. Keeping them as sibling `pub const` declarations (rather than
16273/// coalescing onto a single shared constant that happens to carry the
16274/// same string) mirrors the deliberate axis-independence discipline the
16275/// sibling [`CILIUM_KEY_PATH`] / [`GATEWAY_API_KEY_PATH`] pair already
16276/// codifies on the sibling per-CRD-group axes, so a future Flux v3 per-
16277/// `Kustomization`-CR source-sub-tree leaf-key rebrand (candidates like
16278/// `sourcePath` / `manifestsPath` / `sourceRoot` upstream Flux v3
16279/// roadmap floats in the migration prose) can land independently of
16280/// any Cilium-side or Gateway-API-side per-CRD-schema rebrand without
16281/// any cross-CRD coordination footgun where a shared constant would
16282/// force a coupled edit against schema evolutions the three CRD
16283/// projects run on independent cadences. Note: Rust's `&'static str`
16284/// interner coalesces identical byte-sequences onto one storage
16285/// allocation at codegen time, so at runtime a `.as_ptr()` comparison
16286/// across the trio can't distinguish "sibling `pub const` declarations
16287/// carrying identical bytes" from "coalesced canonical declaration" —
16288/// the axis-independence discipline lives at the rustc symbol-name
16289/// axis (the three `pub const CILIUM_KEY_PATH` / `pub const
16290/// GATEWAY_API_KEY_PATH` / `pub const FLUX_KUSTOMIZATION_KEY_PATH`
16291/// symbols a future rebrand of one leaves the other two structurally
16292/// untouched under) rather than the runtime-address axis, and the
16293/// per-axis re-export identity pins in the consuming renderer crates
16294/// (each pinning the local re-export against its own canonical
16295/// declaration on its own axis) remain the load-bearing "no sibling
16296/// local `pub const` drift" gate for the trio.
16297///
16298/// The single source of truth every rendered Flux bundle axis that
16299/// names the per-`Kustomization`-CR source-sub-tree leaf reaches for:
16300///
16301/// - the rendered `kustomization.yaml` document's `spec.path` leaf-
16302/// scalar-key axis (caixa-flux/src/lib.rs — the [`cluster_bundle`]
16303/// `kustomization.yaml` format-string template's per-CR source-sub-
16304/// tree leaf under the top-level `spec` position, threading the
16305/// same `&'static str` through a new `{path_key}` named-arg
16306/// interpolation);
16307/// - the one test-fixture navigation site in caixa-flux's `mod tests`
16308/// that probes the rendered document's `.get("path")` leaf axis to
16309/// pin the substrate's canonical per-cluster / per-caixa sub-tree
16310/// path seed (the [`cluster_bundle_kustomization_path_pins_lifted_sub_tree`]
16311/// per-CR production-emit pin).
16312///
16313/// Both the production emit site + the one test-fixture navigation
16314/// site name the same Flux v2 per-`Kustomization`-CR source-sub-tree
16315/// leaf-scalar-key and must move together on any hypothetical Flux v3
16316/// rename. Until this lift landed the axis carried an inline `path`
16317/// literal at the one production emit site (caixa-flux/src/lib.rs —
16318/// the `path: ./clusters/{cluster}/services/{name}` leaf inside the
16319/// `cluster_bundle` `kustomization.yaml` format-string template's top-
16320/// level `spec` position) — the sole occurrence of the same load-
16321/// bearing Flux-v2-per-`Kustomization`-CR-source-sub-tree-leaf-scalar-
16322/// key convention, drift-prone by construction ahead of the second
16323/// occurrence the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
16324/// materializer's per-Aplicacao `Kustomization` synthesis will
16325/// surface, where a per-renderer local
16326/// `pub const FLUX_KUSTOMIZATION_KEY_PATH: &str = "…"` (the canonical
16327/// drift footgun where a sibling local `pub const` could happen to
16328/// carry the same string at the source while pointing at a different
16329/// `&'static` allocation) would let the two renderers silently
16330/// disagree on the substrate's canonical per-`Kustomization`-CR
16331/// source-sub-tree leaf-scalar-key convention.
16332///
16333/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5) lifts
16334/// the constant in advance of the second occurrence the M4 materializer
16335/// will surface — so the second consumer inherits the canonical per-CR
16336/// source-sub-tree leaf-scalar-key by construction without opportunity
16337/// for per-renderer drift. Same "the typed constant lives in one place"
16338/// discipline the sibling [`FLUX_KUSTOMIZATION_KEY_PRUNE`] (8ec7917)
16339/// per-CR garbage-collection-toggle leaf-scalar-key lift on the same
16340/// per-`Kustomization`-CR spec surface established — extends the
16341/// discipline from the co-resident per-`Kustomization`-CR `spec.prune`
16342/// top-level per-CR-toggle leaf-scalar-key onto the co-resident per-
16343/// `Kustomization`-CR `spec.path` top-level per-CR-source-sub-tree
16344/// leaf-scalar-key at the mirror-symmetric top-level `spec` position.
16345///
16346/// [cf]: ../../caixa_flux/index.html
16347/// [kust]: https://fluxcd.io/flux/components/kustomize/kustomizations/
16348pub const FLUX_KUSTOMIZATION_KEY_PATH: &str = "path";
16349
16350/// Canonical substrate-side per-cluster / per-caixa `Kustomization.spec.path`
16351/// source-sub-tree scalar composer — the `./clusters/<cluster>/services/<nome>`
16352/// GitRepository-relative directory-tree seed every `caixa-flux`-emitted
16353/// `kustomization.yaml` document mounts under its lifted
16354/// [`FLUX_KUSTOMIZATION_KEY_PATH`] leaf-scalar-key at the top-level `spec`
16355/// position so the Flux v2 kustomize-controller's per-CR reconcile loop
16356/// walks into the paired per-cluster / per-caixa sub-tree of the pleme-io
16357/// k8s repository (rather than the `GitRepository` root, which would pull
16358/// every unrelated cluster's manifests through the wrong per-caixa
16359/// `Kustomization`).
16360///
16361/// The rendered string is the substrate's contract with the pleme-io k8s
16362/// repository's canonical directory-tree layout: every per-caixa Servico's
16363/// rendered manifests live at `pleme-io/k8s/clusters/<cluster>/services/<nome>/`,
16364/// so the Flux v2 kustomize-controller-side per-CR reconcile loop keys off
16365/// the same GitRepository-relative sub-tree seed by construction — the
16366/// composer output is the exact `spec.path` scalar the substrate seeds into
16367/// every emitted per-caixa `kustomization.yaml` document under its top-
16368/// level `spec` position.
16369///
16370/// Composes two axes:
16371///
16372/// - the per-cluster prefix — the `./clusters/<cluster>/` half of the
16373/// sub-tree seed that scopes the emit to the paired cluster's
16374/// manifest set (so two clusters hosting the same per-caixa Servico —
16375/// `rio` vs `paris` — land at distinct `spec.path` scalars with no
16376/// cross-cluster reconcile drift at the kustomize-controller's per-CR
16377/// apply loop);
16378/// - the per-caixa suffix — the `/services/<nome>` half of the sub-tree
16379/// seed that scopes the emit to the paired per-caixa Servico's
16380/// manifest sub-directory under the cluster's `services/` directory
16381/// (so two per-caixa Servicos co-resident under the same cluster —
16382/// `hello-rio` vs `cart` — land at distinct `spec.path` scalars with
16383/// no per-caixa reconcile drift at the same kustomize-controller
16384/// apply loop).
16385///
16386/// Peer to [`cilium_network_policy_name`] / [`gateway_api_http_route_name`]
16387/// / [`oci_chart_ref`] / [`lareira_chart_name`] on the sibling substrate-
16388/// side canonical-composer-of-a-canonical-scalar-that-consumers-key-off
16389/// axis: every writer-side helper composes a canonical load-bearing
16390/// scalar the substrate contracts with a downstream consumer's index
16391/// (Cilium's per-CNP `metadata.name`, Gateway API's per-HTTPRoute
16392/// `metadata.name`, Helm's OCI-artifact ref, Helm's Chart.yaml `name:`
16393/// axis). This composer's `Kustomization.spec.path` peer names the Flux
16394/// v2 kustomize-controller-side per-CR reconcile-target sub-tree index —
16395/// same "the load-bearing multi-axis composition lives in one place"
16396/// discipline extended from the mesh renderer's per-CR-identity-scalar
16397/// axes onto the flux renderer's per-CR-source-sub-tree axis.
16398///
16399/// Until this lift landed the two-axis composition sat as a verbatim
16400/// inline `format!("./clusters/{cluster}/services/{name}")` template at
16401/// the sole `cluster_bundle` `kustomization.yaml` format-string
16402/// production emit site plus a mirror-symmetric verbatim inline
16403/// `format!("./clusters/{cluster}/services/{name}", …)` at the paired
16404/// `cluster_bundle_kustomization_path_pins_lifted_sub_tree` test-fixture
16405/// navigation site — the substrate's canonical per-cluster / per-caixa
16406/// sub-tree seed had no compile-time link between the two sites. A
16407/// future substrate-side directory-tree axis rebrand (`clusters/` →
16408/// `environments/` for a multi-env-per-cluster axis extension, `services/`
16409/// → `servicos/` for a portuguese-canonical directory-name migration
16410/// matching the sibling `:servicos` slot spelling, a per-tenant scoping
16411/// prefix for multi-tenant Aplicacao hosting) would have had to be
16412/// threaded through both sites in lockstep or the two would silently
16413/// split: the production emit would key off the drifted encoding while
16414/// the test pin still asserts the original. Lifting closes the drift
16415/// footgun ahead of the second production-emit occurrence the M4
16416/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
16417/// `Kustomization` synthesis will surface — the second consumer inherits
16418/// the canonical per-cluster / per-caixa sub-tree composition by
16419/// construction without opportunity for per-renderer drift.
16420///
16421/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5) lifts
16422/// the composition in advance of the second occurrence the M4 materializer
16423/// will surface, so the second consumer inherits the canonical sub-tree
16424/// seed by construction.
16425#[must_use]
16426pub fn flux_kustomization_source_subtree(cluster: &str, nome: &str) -> String {
16427 format!("./clusters/{cluster}/services/{nome}")
16428}
16429
16430/// Canonical Flux v2 `Kustomization.spec.timeout` per-CR reconcile wall-
16431/// clock cap leaf-scalar-key every `caixa-flux`-emitted
16432/// `kustomization.yaml` document seeds under its top-level `spec`
16433/// position to name the ceiling on how long the Flux v2 kustomize-
16434/// controller-side per-CR reconcile loop is allowed to spend applying
16435/// the paired [`FLUX_KUSTOMIZATION_KEY_PATH`]-scoped sub-tree of the
16436/// paired [`FLUX_GITREPOSITORY_YAML_FILENAME`] GitRepository before it
16437/// marks the `Kustomization` `Ready: False` and stops retrying — the
16438/// substrate's canonical "how long we let a per-caixa manifest-set
16439/// reconcile run before Flux gives up" contract with the kustomize-
16440/// controller's per-CR reconcile loop. Drift on this leaf silently
16441/// strips the substrate's chosen reconcile-ceiling from every emitted
16442/// per-caixa `Kustomization` document — the kustomize-controller then
16443/// falls back to the upstream Flux v2 controller-side default cap
16444/// (which the upstream project ships at a value tuned for the average
16445/// upstream Flux-managed manifest set, not the substrate's per-caixa
16446/// idempotency-checkpoint cadence the sibling
16447/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] retry-ceiling and
16448/// [`DEFAULT_FLUX_RECONCILE_INTERVAL`] reconcile-poll cadence are
16449/// jointly tuned against), letting a persistently-failing per-caixa
16450/// manifest apply consume kustomize-controller reconcile-loop cycles
16451/// past the substrate's chosen ceiling with no field naming the
16452/// timeout-drift root cause.
16453///
16454/// The single source of truth every rendered Flux bundle axis that
16455/// names the per-`Kustomization`-CR reconcile wall-clock cap leaf
16456/// reaches for:
16457///
16458/// - the rendered `kustomization.yaml` document's `spec.timeout`
16459/// leaf-scalar-key axis (caixa-flux/src/lib.rs — the
16460/// [`cluster_bundle`] `kustomization.yaml` format-string template's
16461/// per-CR reconcile wall-clock cap leaf under the top-level `spec`
16462/// position, threading the same `&'static str` through a new
16463/// `{timeout_key}` named-arg interpolation);
16464/// - the one test-fixture navigation site in caixa-flux's `mod tests`
16465/// that probes the rendered document's `.get("timeout")` leaf axis
16466/// to pin the substrate's canonical wall-clock cap seed.
16467///
16468/// Both the production emit site + the one test-fixture navigation
16469/// site name the same Flux v2 per-`Kustomization`-CR reconcile wall-
16470/// clock cap leaf-scalar-key and must move together on any
16471/// hypothetical Flux v3 rename. Until this lift landed the axis
16472/// carried an inline `timeout` literal at the one production emit site
16473/// (caixa-flux/src/lib.rs — the `timeout: 5m` leaf inside the
16474/// `cluster_bundle` `kustomization.yaml` format-string template's top-
16475/// level `spec` position) — the sole occurrence of the same load-
16476/// bearing Flux-v2-per-`Kustomization`-CR-reconcile-wall-clock-cap-
16477/// leaf-scalar-key convention, drift-prone by construction ahead of
16478/// the second occurrence the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
16479/// materializer's per-Aplicacao `Kustomization` synthesis will
16480/// surface, where a per-renderer local
16481/// `pub const FLUX_KUSTOMIZATION_KEY_TIMEOUT: &str = "…"` (the
16482/// canonical drift footgun where a sibling local `pub const` could
16483/// happen to carry the same string at the source while pointing at a
16484/// different `&'static` allocation) would let the two renderers
16485/// silently disagree on the substrate's canonical reconcile-ceiling-
16486/// declaration leaf-scalar-key convention.
16487///
16488/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5)
16489/// lifts the constant in advance of the second occurrence the M4
16490/// materializer will surface — so the second consumer inherits the
16491/// canonical per-CR reconcile wall-clock cap leaf-scalar-key by
16492/// construction without opportunity for per-renderer drift. Pairs
16493/// with the sibling [`DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT`] scalar-
16494/// value half of the same `(leaf-key, scalar-value)` per-path
16495/// reconcile-ceiling-declaration pair — extends the drift-closing
16496/// discipline the scalar-value lift established from the value the
16497/// leaf holds onto the leaf-key itself. Same shape as the sibling
16498/// [`FLUX_KUSTOMIZATION_KEY_PATH`] (613d7ed) per-CR source-sub-tree
16499/// leaf-scalar-key + [`FLUX_KUSTOMIZATION_KEY_PRUNE`] (8ec7917) per-CR
16500/// garbage-collection-toggle leaf-scalar-key lifts on the co-resident
16501/// per-`Kustomization`-CR spec surface — extends the discipline from
16502/// the co-resident per-`Kustomization`-CR `spec.path` source-sub-tree
16503/// leaf-scalar-key and per-`Kustomization`-CR `spec.prune` garbage-
16504/// collection-toggle leaf-scalar-key onto the co-resident per-
16505/// `Kustomization`-CR `spec.timeout` reconcile wall-clock cap leaf-
16506/// scalar-key at the mirror-symmetric top-level `spec` position.
16507///
16508/// [cf]: ../../caixa_flux/index.html
16509/// [kust]: https://fluxcd.io/flux/components/kustomize/kustomizations/
16510pub const FLUX_KUSTOMIZATION_KEY_TIMEOUT: &str = "timeout";
16511
16512/// Canonical Flux v2 `Kustomization.spec.timeout` per-CR reconcile
16513/// wall-clock cap default the substrate seeds into every per-caixa
16514/// `kustomization.yaml` document. Every rendered per-caixa Flux v2
16515/// `Kustomization` CR consults the same `&'static str` at emit time so
16516/// a future substrate-side reconcile-ceiling migration (`"5m"` → `"3m"`
16517/// on faster per-caixa idempotency-checkpoint cadence once the sibling
16518/// [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] retry-ceiling
16519/// tightens, `"5m"` → `"10m"` on larger per-caixa manifest sets where
16520/// the upstream Flux v2 kustomize-controller-side per-CR reconcile
16521/// duration outgrows the substrate's default ceiling — coordinated
16522/// with the sibling [`DEFAULT_FLUX_RECONCILE_INTERVAL`] reconcile-poll
16523/// cadence tuning cycle) is a one-line edit on this canonical
16524/// declaration, not a coordinated rewrite across the
16525/// [`cluster_bundle`] `kustomization.yaml` template + every future
16526/// per-target renderer the substrate adds.
16527///
16528/// The single source of truth the rendered per-caixa Flux v2 cluster
16529/// bundle's per-`Kustomization`-CR reconcile wall-clock cap default
16530/// seed reaches for:
16531///
16532/// - the rendered `kustomization.yaml` document's `spec.timeout`
16533/// scalar-value axis (caixa-flux/src/lib.rs — the
16534/// [`cluster_bundle`] `kustomization.yaml` format-string template's
16535/// per-CR reconcile wall-clock cap leaf under the top-level `spec`
16536/// position, threading the same `&'static str` through a new
16537/// `{timeout_default}` named-arg interpolation on the leaf keyed
16538/// by the sibling [`FLUX_KUSTOMIZATION_KEY_TIMEOUT`]).
16539///
16540/// The value is a valid Flux v2 reconcile wall-clock cap duration
16541/// scalar (per the upstream Flux v2
16542/// `kustomize.toolkit.fluxcd.io/v1/Kustomization.spec.timeout`
16543/// `metav1.Duration` OpenAPI schema): a non-empty Go-duration-format
16544/// string (e.g. `"5m"`, `"3m"`, `"1h30m"`), which the Flux v2
16545/// controller-side per-CR admission gate parses via
16546/// `metav1.ParseDuration` before installing the per-CR watch. A future
16547/// rebrand on this lift cannot silently land a value the Flux v2
16548/// controller-side admission gate rejects at the *first* per-caixa
16549/// `Kustomization` apply against a cluster, far from the rebrand
16550/// commit's source — the pin at the canonical lift documents the Go-
16551/// duration-format grammar contract with the Flux v2 admission gate
16552/// every downstream consumer of the rendered per-CR reconcile-cap
16553/// axis rests on.
16554///
16555/// Pairs with the sibling [`FLUX_KUSTOMIZATION_KEY_TIMEOUT`] per-Flux-
16556/// v2-`Kustomization`-CR reconcile wall-clock cap scalar-axis key the
16557/// value the substrate seeds here nests directly under across every
16558/// rendered per-caixa Flux v2 `Kustomization` CR — the key half of
16559/// the per-CR `spec.timeout` scalar-key/scalar-value pair lives at
16560/// [`FLUX_KUSTOMIZATION_KEY_TIMEOUT`], the value half's substrate-side
16561/// default seed lives here. Same "the typed constant lives in one
16562/// place" discipline the [`DEFAULT_FLUX_RECONCILE_INTERVAL`] (908180f)
16563/// / [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] (30dcdae) /
16564/// [`DEFAULT_APLICACAO_INSTALL_TIMEOUT`](caixa_tatara::DEFAULT_APLICACAO_INSTALL_TIMEOUT)
16565/// (813343f) lifts apply on the peer canonical-substrate-default-
16566/// load-bearing-scalar surface — extends the canonical-substrate-
16567/// default single-sourcing discipline from the peer per-Flux-v2-CR-
16568/// reconcile-poll-cadence / per-HelmRelease-CR-remediation-retry-
16569/// ceiling / per-tatara-Process-install-wall-clock-cap surfaces onto
16570/// the sibling per-Kustomization-CR-reconcile-wall-clock-cap surface
16571/// every rendered per-caixa Flux v2 cluster bundle CR carries.
16572///
16573/// [cf]: ../../caixa_flux/index.html
16574pub const DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT: &str = "5m";
16575
16576/// Canonical K8s Gateway API `GatewayClass` name every `caixa-mesh`-emitted
16577/// [`Gateway`][gw] document declares at its `spec.gatewayClassName` axis —
16578/// the controller-discriminator that binds the emitted `Gateway` to a
16579/// specific `GatewayClass` resource, which in turn names the controller
16580/// (`spec.controllerName`) that reconciles every `HTTPRoute` /
16581/// `GRPCRoute` / `TLSRoute` / `TCPRoute` attached to `Gateway`s bound to
16582/// that class.
16583///
16584/// The single source of truth [`caixa-mesh`][cm]'s `gateway_routes`
16585/// per-`:entrada` `Gateway` emitter (the sole production-code site the
16586/// prior inline `"cilium".into()` literal sat at — the `spec.gatewayClassName`
16587/// field of the emitted `Gateway`'s `spec` block) and every future
16588/// per-target renderer the M3.x + M4 absorption roadmap acknowledges
16589/// (the future `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
16590/// `Gateway` synthesis, a future per-cluster / per-edge `Gateway`
16591/// renderer for non-HTTP `:entrada` shapes) consult for the substrate's
16592/// chosen Gateway API controller.
16593///
16594/// The value pins the substrate on the Cilium Gateway API implementation
16595/// — the same eBPF-identity data plane that reconciles every
16596/// [`CILIUM_KIND_NETWORK_POLICY`] the mesh renderer emits alongside the
16597/// `Gateway`. Same-controller Gateway ingress + intra-mesh identity
16598/// policy is the load-bearing "one identity layer, one data plane"
16599/// mesh-composition invariant (MESH-COMPOSITION.md §V — "the `:entrada`
16600/// external ingress and the intra-mesh `:contratos` identity checks
16601/// share an eBPF data plane; a per-caixa split between the ingress
16602/// controller and the identity controller reintroduces the
16603/// two-data-planes drift the mesh composition invariant closes"), so
16604/// splitting the controller across renderers would silently reintroduce
16605/// the exact drift the substrate's mesh composition invariant closes.
16606///
16607/// Until this lift landed the substrate's Gateway API controller choice
16608/// carried an inline `"cilium".into()` literal at the one production-code
16609/// occurrence in caixa-mesh (the `gateway_routes` `Gateway`
16610/// `spec.gatewayClassName` field). The PRIME DIRECTIVE duplication-budget
16611/// rule (THEORY.md §I.3.5, "every recurring shape becomes a generator
16612/// before it becomes a pattern; every pattern becomes a library before it
16613/// becomes duplicated code. The duplication budget is zero.") promotes
16614/// the constant to a typed substrate-side `&'static str` in advance of the
16615/// second occurrence — the M4 `mesh.pleme.io/v1alpha1/Aplicacao`
16616/// materializer's per-Aplicacao `Gateway` synthesis, a future per-cluster
16617/// per-edge `Gateway` renderer, or any per-edition variant the substrate
16618/// forks — so the second consumer inherits the canonical controller
16619/// choice by construction without opportunity for per-renderer drift.
16620///
16621/// A future substrate-side controller migration (the substrate forking
16622/// from Cilium Gateway to Envoy Gateway, Istio Gateway, or any
16623/// per-edition Gateway API v1.x GA controller variant the SIG-Network
16624/// roadmap names) without a coordinated edit on every renderer's inline
16625/// literal would have silently emitted a `Gateway` whose
16626/// `spec.gatewayClassName` referenced a class no controller reconciles —
16627/// apply-side: the `Gateway` sits at `Programmed: False` with no route
16628/// reconciled, every external `:entrada` flow drops at the ingress with
16629/// no field naming the controller-drift root cause. Lifting the value
16630/// here makes the controller-choice axis discipline structural: the
16631/// per-`:entrada` `Gateway` and every future per-Aplicacao materializer
16632/// consult the same `&'static str`, and a future controller migration
16633/// is a one-line edit on the canonical declaration.
16634///
16635/// The value is a valid DNS-1123 label (the K8s apiserver-side floor
16636/// every cluster-scoped `GatewayClass.metadata.name` axis enforces):
16637/// lowercase ASCII alphanumeric with `-` separators, no leading /
16638/// trailing hyphen, length within the [`DNS_1123_LABEL_MAX_LEN`] (63-byte)
16639/// cap. A future rebrand on this lift cannot silently land a value the
16640/// apiserver refuses at the *first* `Gateway` apply against a cluster,
16641/// far from the rebrand commit's source — the typed [`is_dns_1123_label`]
16642/// floor rejects it at caixa-core build time on the canonical lift,
16643/// before any renderer consumes the value. Same "the typed constant
16644/// lives in one place" discipline the [`DEFAULT_NAMESPACE`] (a085b26) /
16645/// [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] (7197d38) / [`DEFAULT_LIBRARY_NAME`]
16646/// (41438dc) / [`DEFAULT_SERVICO_PORT`] (1e22add) lifts apply on the
16647/// peer canonical-substrate-default-resource-name surface.
16648///
16649/// [gw]: https://gateway-api.sigs.k8s.io/api-types/gateway/
16650/// [cm]: ../../caixa_mesh/index.html
16651pub const DEFAULT_GATEWAY_CLASS_NAME: &str = "cilium";
16652
16653/// Canonical K8s Gateway API `Gateway` per-Gateway controller-binding
16654/// scalar-axis key every `gateway_routes`-emitted `Gateway` document
16655/// mounts its per-Gateway `GatewayClass.metadata.name` reference under
16656/// (`spec.gatewayClassName`). Pairs with the sibling
16657/// [`DEFAULT_GATEWAY_CLASS_NAME`] (d9b0743) — the K8s Gateway API v1 CRD
16658/// schema pins the per-Gateway controller-binding through the scalar
16659/// `spec.gatewayClassName` axis (each `Gateway` names exactly one
16660/// `GatewayClass.metadata.name`; the sibling `spec.listeners[]` +
16661/// `spec.addresses[]` container axes carry the L7-listener fan-out +
16662/// per-Gateway address hint under the same `spec` block), so drift on
16663/// the per-Gateway controller-binding scalar-axis KEY is exactly as
16664/// load-bearing as drift on the sibling `DEFAULT_GATEWAY_CLASS_NAME`
16665/// VALUE the axis wraps (the K8s apiserver-side Gateway API CRD schema
16666/// validator drops any `spec` block whose controller-binding scalar-
16667/// axis carries an unrecognized key — a `"gatewayClass"` /
16668/// `"className"` / `"gatewayClassRef"` typo silently emits a `Gateway`
16669/// whose controller-binding the Gateway API implementation's per-
16670/// Gateway reconcile loop no-ops entirely: no `GatewayClass` is
16671/// resolved, no `controllerName` is looked up, and every external
16672/// `:entrada` flow the Gateway was authored to accept drops at the
16673/// gateway-class-controller's per-Gateway reconcile with no field
16674/// naming the controller-binding-axis-drift root cause).
16675///
16676/// The single source of truth the rendered Aplicacao Gateway-API-side
16677/// ingress bundle's per-Gateway controller-binding-axis-naming reaches
16678/// for:
16679///
16680/// - the rendered `Gateway` document's `spec.gatewayClassName` axis
16681/// (caixa-mesh/src/lib.rs:2016 — the `gateway_routes` per-Aplicacao
16682/// `Gateway`'s `g_spec.insert("gatewayClassName", …)` call).
16683///
16684/// The per-Gateway controller-binding scalar axis names the same
16685/// Gateway-API-implementation-side per-Gateway `GatewayClass`
16686/// resolution axis as the sibling [`DEFAULT_GATEWAY_CLASS_NAME`] VALUE
16687/// it wraps, and must move together on any future Gateway API rebrand
16688/// (an upstream SIG-Network Gateway API v2 rename of the controller-
16689/// binding scalar-axis from `gatewayClassName` to `className` /
16690/// `gatewayClassRef` / `class`, coordinated with the Gateway API
16691/// deprecation cycle). Until this lift landed the KEY axis carried an
16692/// inline `gatewayClassName` literal at the one production-code
16693/// occurrence in caixa-mesh/src/lib.rs:2016 (the `gateway_routes` per-
16694/// Aplicacao Gateway's `g_spec.insert("gatewayClassName", …)` call)
16695/// plus a matching test-fixture navigation inside the in-file
16696/// `gateway_gateway_class_name_uses_lifted_default_gateway_class_name`
16697/// pin's `.get("gatewayClassName")` traversal (caixa-mesh/src/lib.rs:5315)
16698/// — two occurrences of the same load-bearing Gateway-API-CRD-
16699/// `gatewayClassName`-axis-KEY convention, drift-prone by
16700/// construction. A drift on the production site to `"gatewayClass"` /
16701/// `"className"` / `"gatewayClassRef"` would have surfaced as a
16702/// Gateway API implementation-side schema validator drop at apply
16703/// time (the affected `Gateway`'s controller-binding scalar-axis the
16704/// CRD schema validator recognizes as unknown), with every external
16705/// `:entrada` flow the Gateway was authored to accept dropping at the
16706/// gateway-class-controller's per-Gateway reconcile with no field
16707/// naming the controller-binding-drift root cause. A drift on the
16708/// test-fixture side silently masks the emission-side pin
16709/// (`.get("gatewayClassName")` returns `None` under both the drifted-
16710/// key emitter and the drifted-key probe — the downstream
16711/// `.and_then(|c| c.as_str())` chain short-circuits vacuously because
16712/// the outer per-Gateway controller-binding lookup is itself `None`).
16713///
16714/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
16715/// "every recurring shape becomes a generator before it becomes a
16716/// pattern; every pattern becomes a library before it becomes
16717/// duplicated code. The duplication budget is zero.") promotes the
16718/// constant to a typed substrate-side `&'static str` on the same
16719/// trajectory the [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
16720/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
16721/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
16722/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) lifts established on the
16723/// sibling canonical-Gateway-API-body-axis surfaces — completes the
16724/// per-Gateway-body-axis canonical-string-pin set the sibling
16725/// `spec.listeners[]` lift began, closing the (`gatewayClassName`,
16726/// `listeners`) per-`Gateway`-spec-body-axis pair the M3 Aplicacao
16727/// mesh renderer's external `:entrada` ingress contract rests on.
16728/// Together with the peer [`DEFAULT_GATEWAY_CLASS_NAME`] VALUE lift
16729/// (d9b0743) — the `(key, value)` pair-lift discipline the sibling
16730/// `(KUBE_KEY_METADATA, {"name","namespace","labels"})` axis
16731/// established — the per-Gateway controller-binding scalar axis now
16732/// threads both halves of its `(key, value)` typed contract through
16733/// one lifted `&'static str` apiece at the substrate boundary. The
16734/// render-side consumer now threads the same `&'static str` through
16735/// its `g_spec.insert(…)` call so a future Gateway API rebrand on
16736/// the controller-binding scalar axis (or an upstream SIG-Network
16737/// Gateway API v2 rename to a per-CRD sibling name) lands in one
16738/// place; every future renderer that reaches for the canonical
16739/// per-Gateway controller-binding scalar axis (the future M4
16740/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
16741/// `Gateway` fan-out, a future per-cluster `GatewayClass` /
16742/// `ReferenceGrant` renderer whose per-Gateway class-name enumeration
16743/// binds against this same axis, a future per-`Gateway` typed-listener
16744/// TLS terminator renderer whose per-Gateway `spec` block nests
16745/// alongside this same axis) inherits the same value by construction
16746/// with no opportunity for per-renderer drift.
16747///
16748/// [cm]: ../../caixa_mesh/index.html
16749pub const GATEWAY_API_KEY_GATEWAY_CLASS_NAME: &str = "gatewayClassName";
16750
16751/// Canonical K8s Gateway API `HTTPRoute` per-`HTTPRouteMatch` path-matcher
16752/// container-axis key every `gateway_routes`-emitted `HTTPRoute` per-rule
16753/// `matches[]` entry mounts its per-match `{type, value}` path-selection
16754/// predicate under (`spec.rules[].matches[].path`). Nests one level
16755/// beneath the sibling [`GATEWAY_API_KEY_MATCHES`] (b9ede1a) per-rule
16756/// route-match container-axis it hangs off of — the Gateway API v1 CRD
16757/// schema pins per-`HTTPRouteMatch` request-path selection through the
16758/// `spec.rules[].matches[].path` container axis (each match entry names
16759/// one path-selection predicate the request line's `:path` pseudo-header
16760/// must satisfy under a `type` discriminator of
16761/// `Exact | PathPrefix | RegularExpression`) alongside the sibling per-
16762/// `HTTPRouteMatch` `headers[]` / `queryParams[]` / `method` axes it
16763/// nests under, so drift on the per-match path-matcher container axis
16764/// is exactly as load-bearing as drift on the per-rule route-match
16765/// axis it nests inside of (the K8s apiserver-side Gateway API CRD
16766/// schema validator drops any per-match block whose path-matcher
16767/// container axis carries an unrecognized key — a `"pathMatch"` /
16768/// `"prefix"` / `"url"` typo silently emits an `HTTPRoute` whose per-
16769/// match path-selection axis the Gateway API implementation's per-rule
16770/// L7 dispatch loop no-ops entirely: no path predicate is evaluated,
16771/// the match degrades to the wildcard predicate at the gateway-class-
16772/// controller's per-rule reconcile, the rule matches every request
16773/// path unconditionally, and every external `:entrada` path filter the
16774/// rule was authored to enforce drops with no field naming the path-
16775/// matcher-axis-drift root cause).
16776///
16777/// The single source of truth the rendered Aplicacao Gateway-API-side
16778/// ingress bundle's per-`HTTPRouteMatch` path-matcher-container-axis-
16779/// naming reaches for:
16780///
16781/// - the rendered `HTTPRoute` document's per-match
16782/// `spec.rules[].matches[].path` axis (caixa-mesh/src/lib.rs — the
16783/// `gateway_routes` per-Aplicacao `HTTPRoute`'s per-match
16784/// `match_entry.insert("path", …)` call seeded from the Aplicacao's
16785/// `:entrada :paths` slot).
16786///
16787/// The per-`HTTPRouteMatch` path-matcher container axis names the same
16788/// Gateway-API-implementation-side per-match request-path-selection
16789/// predicate container as the sibling
16790/// [`GATEWAY_API_KEY_MATCHES`] per-rule route-match container axis it
16791/// nests inside of, and must move together on any future Gateway API
16792/// rebrand (an upstream SIG-Network Gateway API v2 rename of the path-
16793/// matcher axis from `path` to `pathMatch` / `prefix` / `url`,
16794/// coordinated with the Gateway API deprecation cycle). Until this lift
16795/// landed the axis carried an inline `path` literal at the one
16796/// production-code occurrence in caixa-mesh/src/lib.rs (the
16797/// `gateway_routes` per-match `match_entry.insert("path", …)` call) —
16798/// one occurrence of the same load-bearing Gateway-API-CRD-
16799/// `path`-axis-key convention, drift-prone by construction. A drift on
16800/// the production site to `"pathMatch"` / `"prefix"` / `"url"` would
16801/// have surfaced as a Gateway API implementation-side schema validator
16802/// drop at apply time (the affected per-match path-matcher axis the
16803/// CRD schema validator recognizes as unknown), with the per-match
16804/// path predicate degrading to the wildcard match at the gateway-
16805/// class-controller's per-rule reconcile with no field naming the
16806/// path-matcher-drift root cause.
16807///
16808/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
16809/// "every recurring shape becomes a generator before it becomes a
16810/// pattern; every pattern becomes a library before it becomes
16811/// duplicated code. The duplication budget is zero.") promotes the
16812/// constant to a typed substrate-side `&'static str` on the same
16813/// trajectory the [`GATEWAY_API_KEY_MATCHES`] (b9ede1a) /
16814/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
16815/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
16816/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
16817/// [`GATEWAY_API_KEY_HOSTNAMES`] (b77f744) /
16818/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
16819/// [`GATEWAY_API_KEY_TIMEOUTS`] (db31108) /
16820/// [`GATEWAY_API_KEY_RETRY`] (231bbf5) /
16821/// [`GATEWAY_API_KEY_GATEWAY_CLASS_NAME`] (1bc727d) lifts established on
16822/// the sibling canonical-Gateway-API-HTTPRoute-body-axis / per-Gateway-
16823/// body-axis surfaces — nests the per-Gateway-API-HTTPRoute-per-rule-
16824/// body-axis canonical-string-pin set (`matches`, `backendRefs`,
16825/// `timeouts`, `retry`) one level deeper onto the per-`HTTPRouteMatch`
16826/// body-axis surface, so the container-axis key beneath the sibling
16827/// `matches[]` axis now threads a lifted `&'static str` alongside its
16828/// parent-container-axis key. The render-side consumer now threads the
16829/// same `&'static str` through its `match_entry.insert(…)` call so a
16830/// future Gateway API rebrand on the per-`HTTPRouteMatch` path-matcher
16831/// axis (or an upstream SIG-Network Gateway API v2 rename to a per-
16832/// `HTTPRouteMatch` sibling name) lands in one place; every future
16833/// renderer that reaches for the canonical per-`HTTPRouteMatch` path-
16834/// matcher axis (the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
16835/// materializer's per-Aplicacao `HTTPRoute` fan-out, a future per-edge
16836/// `GRPCRoute` renderer whose per-match request-method / service /
16837/// method predicate nests alongside the path predicate, a future
16838/// per-match header-match / query-match renderer whose per-predicate
16839/// list binds against sibling axes of this one under the same match
16840/// entry) inherits the same value by construction with no opportunity
16841/// for per-renderer drift.
16842///
16843/// Same "the typed constant lives in one place" discipline the
16844/// [`GATEWAY_API_KEY_MATCHES`] (b9ede1a) /
16845/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
16846/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
16847/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
16848/// [`GATEWAY_API_KEY_HOSTNAMES`] (b77f744) /
16849/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
16850/// [`GATEWAY_API_KEY_TIMEOUTS`] (db31108) /
16851/// [`GATEWAY_API_KEY_RETRY`] (231bbf5) /
16852/// [`GATEWAY_API_KEY_GATEWAY_CLASS_NAME`] (1bc727d) lifts apply on the
16853/// peer canonical-Gateway-API-HTTPRoute-per-`HTTPRouteMatch`-body-axis
16854/// surface.
16855///
16856/// [cm]: ../../caixa_mesh/index.html
16857pub const GATEWAY_API_KEY_PATH: &str = "path";
16858
16859/// Canonical K8s Gateway API v1 `HTTPPathMatch` `value` scalar-axis key
16860/// every `gateway_routes`-emitted `HTTPRoute` per-match `path` block
16861/// mounts its request-path-selection scalar payload under
16862/// (`spec.rules[].matches[].path.value`). Nests one level beneath the
16863/// sibling [`GATEWAY_API_KEY_PATH`] per-`HTTPRouteMatch` path-matcher
16864/// container-axis it hangs off of — the Gateway API v1 CRD schema
16865/// pins per-`HTTPPathMatch` request-path selection through the
16866/// `{type, value}` two-axis pair (a
16867/// [`GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX`]-typed `type`
16868/// discriminator picks `Exact | PathPrefix | RegularExpression`; the
16869/// `value` scalar carries the per-match request-path string the
16870/// discriminator is applied against), so drift on the `value` scalar
16871/// axis is exactly as load-bearing as drift on the peer `type`
16872/// discriminator axis it nests alongside (the K8s apiserver-side
16873/// Gateway API CRD schema validator drops any per-match block whose
16874/// `HTTPPathMatch` scalar-payload axis carries an unrecognized key —
16875/// a `"path"` / `"prefix"` / `"pattern"` typo silently emits an
16876/// `HTTPRoute` whose per-match request-path predicate the Gateway API
16877/// implementation's per-rule L7 dispatch loop treats as bare (no
16878/// value evaluated against the `type` discriminator), the match
16879/// degrades to the wildcard predicate at the gateway-class-
16880/// controller's per-rule reconcile, the rule matches every request
16881/// path unconditionally, and every external `:entrada` path filter the
16882/// rule was authored to enforce drops with no field naming the
16883/// `HTTPPathMatch`-scalar-payload-drift root cause).
16884///
16885/// The single source of truth the rendered Aplicacao Gateway-API-side
16886/// ingress bundle's per-`HTTPPathMatch` scalar-payload-axis-naming
16887/// reaches for:
16888///
16889/// - the rendered `HTTPRoute` document's per-match
16890/// `spec.rules[].matches[].path.value` axis (caixa-mesh/src/lib.rs
16891/// — the `gateway_routes` per-Aplicacao `HTTPRoute`'s per-match
16892/// `path_match.insert("value", …)` call seeded from the
16893/// Aplicacao's `:entrada :paths` slot).
16894///
16895/// The per-`HTTPPathMatch` scalar-payload axis names the same
16896/// Gateway-API-implementation-side per-match request-path-selection
16897/// scalar as the sibling [`GATEWAY_API_KEY_PATH`] per-`HTTPRouteMatch`
16898/// path-matcher container-axis it nests inside of, and must move
16899/// together on any future Gateway API rebrand (an upstream
16900/// SIG-Network Gateway API v2 rename of the `HTTPPathMatch` scalar-
16901/// payload axis from `value` to `path` / `pattern` / `expression`,
16902/// coordinated with the Gateway API deprecation cycle). Until this
16903/// lift landed the axis carried an inline `"value"` literal at the
16904/// one production-code occurrence in caixa-mesh/src/lib.rs (the
16905/// `gateway_routes` per-match `path_match.insert("value", …)` call) —
16906/// one occurrence of the same load-bearing Gateway-API-CRD-
16907/// `HTTPPathMatch`-`value`-axis-key convention, drift-prone by
16908/// construction. A drift on the production site to `"path"` /
16909/// `"prefix"` / `"pattern"` would have surfaced as a Gateway API
16910/// implementation-side schema validator drop at apply time (the
16911/// affected per-match `HTTPPathMatch` scalar-payload axis the CRD
16912/// schema validator recognizes as unknown), with the per-match path
16913/// predicate degrading to the wildcard match at the gateway-class-
16914/// controller's per-rule reconcile with no field naming the
16915/// `HTTPPathMatch`-scalar-payload-drift root cause.
16916///
16917/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
16918/// "every recurring shape becomes a generator before it becomes a
16919/// pattern; every pattern becomes a library before it becomes
16920/// duplicated code. The duplication budget is zero.") promotes the
16921/// constant to a typed substrate-side `&'static str` on the same
16922/// trajectory the [`GATEWAY_API_KEY_PATH`] (9f45aa4) /
16923/// [`GATEWAY_API_KEY_MATCHES`] (b9ede1a) /
16924/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
16925/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
16926/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
16927/// [`GATEWAY_API_KEY_HOSTNAMES`] (b77f744) /
16928/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
16929/// [`GATEWAY_API_KEY_TIMEOUTS`] (db31108) /
16930/// [`GATEWAY_API_KEY_RETRY`] (231bbf5) /
16931/// [`GATEWAY_API_KEY_GATEWAY_CLASS_NAME`] (1bc727d) lifts established
16932/// on the sibling canonical-Gateway-API-body-axis surfaces — nests
16933/// the per-Gateway-API-HTTPRoute-per-match-body-axis canonical-
16934/// string-pin set (`path` container-axis, `type` discriminator
16935/// scalar-key, `value` scalar-payload key) two levels deeper onto the
16936/// per-`HTTPPathMatch` body-axis surface, so both halves of the
16937/// `HTTPPathMatch.{type, value}` typed contract now thread one lifted
16938/// `&'static str` apiece at the substrate boundary alongside the
16939/// parent-container-axis key. The render-side consumer now threads
16940/// the same `&'static str` through its `path_match.insert(…)` call
16941/// so a future Gateway API rebrand on the `HTTPPathMatch` scalar-
16942/// payload axis (or an upstream SIG-Network Gateway API v2 rename to
16943/// a per-`HTTPPathMatch` sibling name) lands in one place; every
16944/// future renderer that reaches for the canonical per-`HTTPPathMatch`
16945/// scalar-payload axis (the future M4
16946/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
16947/// `HTTPRoute` fan-out, a future per-edge `GRPCRoute` renderer whose
16948/// per-match `GRPCMethodMatch.method` scalar-payload nests alongside
16949/// this same axis, a future per-match header-match / query-match
16950/// renderer whose per-predicate `HTTPHeaderMatch.value` /
16951/// `HTTPQueryParamMatch.value` scalar-payload binds against sibling
16952/// axes on the same `value` axis-key) inherits the same value by
16953/// construction with no opportunity for per-renderer drift.
16954///
16955/// [cm]: ../../caixa_mesh/index.html
16956pub const GATEWAY_API_KEY_VALUE: &str = "value";
16957
16958/// Canonical K8s Gateway API v1 per-child-object name-reference
16959/// discriminator axis key every `gateway_routes`-emitted `Gateway`
16960/// listener + `HTTPRoute` `parentRefs[]` / `backendRefs[]` entry
16961/// mounts its named-object binding under. Three peer sub-schemas on
16962/// the shared `spec.…[].name` axis:
16963///
16964/// - `Gateway.spec.listeners[].name` — Gateway API v1 `SectionName`,
16965/// the listener's per-section identifier the sibling
16966/// `HTTPRoute.spec.parentRefs[].sectionName` binds against;
16967/// - `HTTPRoute.spec.parentRefs[].name` — Gateway API v1
16968/// `ObjectName`, the per-`HTTPRoute` parent-Gateway reference the
16969/// Gateway API implementation's per-HTTPRoute attach reconciler
16970/// resolves against a `Gateway` object in the same namespace;
16971/// - `HTTPRoute.spec.rules[].backendRefs[].name` — Gateway API v1
16972/// `ObjectName`, the per-rule backend-Service reference the
16973/// Gateway API implementation's per-rule L7 dispatch loop
16974/// resolves against a `Service` object in the same namespace.
16975///
16976/// All three sub-schemas key their named-reference discriminator on
16977/// the identical three-byte `"name"` axis at every level of the
16978/// Gateway API v1 CRD schema (`Gateway.spec.listeners[].name`,
16979/// `HTTPRoute.spec.parentRefs[].name`,
16980/// `HTTPRoute.spec.rules[].backendRefs[].name`), so drift on any one
16981/// of them silently splits the substrate's Aplicacao gateway bundle
16982/// at whichever schema the drift hits (the K8s apiserver-side Gateway
16983/// API CRD schema validator drops a per-listener / per-parentRef /
16984/// per-backendRef block whose name-reference axis carries an
16985/// unrecognized key — a `"Name"` / `"target"` / `"ref"` typo silently
16986/// emits a `Gateway` whose listener carries no section identity, or
16987/// an `HTTPRoute` whose parent-Gateway attachment reconciles as
16988/// unbound, or an `HTTPRoute` whose per-rule backend fan-out resolves
16989/// no Service, and every external `:entrada` flow the bundle was
16990/// authored to accept drops at the gateway-class-controller's per-
16991/// rule/per-listener/per-parentRef reconcile with no field naming the
16992/// name-reference-axis-drift root cause).
16993///
16994/// The single source of truth the rendered Aplicacao Gateway-API-side
16995/// ingress bundle's per-child-object name-reference-axis-naming
16996/// reaches for:
16997///
16998/// - the rendered `Gateway` document's `spec.listeners[].name` axis
16999/// (caixa-mesh/src/lib.rs — the `gateway_routes` per-Aplicacao
17000/// `Gateway`'s per-listener `listener.insert("name", …)` call);
17001/// - the rendered `HTTPRoute` document's `spec.parentRefs[].name`
17002/// axis (caixa-mesh/src/lib.rs — the `gateway_routes` per-
17003/// Aplicacao `HTTPRoute`'s per-parentRef
17004/// `parent_ref.insert("name", …)` call);
17005/// - the rendered `HTTPRoute` document's
17006/// `spec.rules[].backendRefs[].name` axis (caixa-mesh/src/lib.rs
17007/// — the `gateway_routes` per-rule per-backendRef
17008/// `backend_ref.insert("name", …)` call).
17009///
17010/// The per-child-object name-reference discriminator axis names the
17011/// same Gateway-API-implementation-side named-object binding container
17012/// as the sibling [`GATEWAY_API_KEY_LISTENERS`] +
17013/// [`GATEWAY_API_KEY_PARENT_REFS`] + [`GATEWAY_API_KEY_BACKEND_REFS`]
17014/// per-container list axes it nests directly beneath, and must move
17015/// together on any future Gateway API rebrand (an upstream SIG-Network
17016/// Gateway API v2 rename of the name-reference axis from `name` to
17017/// `target` / `ref` / `objectName`, coordinated with the Gateway API
17018/// deprecation cycle). Until this lift landed the axis carried inline
17019/// `"name"` literals at four occurrences across caixa-mesh — three
17020/// production emitter sites (the per-listener `listener.insert("name",
17021/// …)`, the per-parentRef `parent_ref.insert("name", …)`, and the per-
17022/// backendRef `backend_ref.insert("name", …)` calls in
17023/// `gateway_routes`) plus one in-file test-fixture navigation (the
17024/// `httproute_routes_to_entrada_para` fixture's per-backendRef
17025/// `.get("name")` retrieval) — four occurrences of the same load-
17026/// bearing Gateway-API-CRD-`name`-axis-key convention, drift-prone by
17027/// construction. A drift on any one production site to `"Name"` /
17028/// `"target"` / `"ref"` would have surfaced as a Gateway API
17029/// implementation-side schema validator drop at apply time (the
17030/// affected per-listener / per-parentRef / per-backendRef name-
17031/// reference axis the CRD schema validator recognizes as unknown),
17032/// with the listener carrying no section identity or the `HTTPRoute`
17033/// carrying an unbound parent-Gateway attachment or the per-rule
17034/// backend fan-out resolving no Service at the gateway-class-
17035/// controller's reconcile with no field naming the name-reference-
17036/// drift root cause. A drift on the test-fixture side silently masks
17037/// the emission-side pin (`.get("name")` returns `None` under both
17038/// the drifted-key emitter and the drifted-key probe — the downstream
17039/// `.and_then(|n| n.as_str())` chain short-circuits vacuously because
17040/// the outer per-backendRef name-reference lookup is itself `None`).
17041///
17042/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
17043/// "every recurring shape becomes a generator before it becomes a
17044/// pattern; every pattern becomes a library before it becomes
17045/// duplicated code. The duplication budget is zero.") promotes the
17046/// constant to a typed substrate-side `&'static str` on the same
17047/// trajectory the [`GATEWAY_API_KEY_PATH`] (9f45aa4) /
17048/// [`GATEWAY_API_KEY_MATCHES`] (b9ede1a) /
17049/// [`GATEWAY_API_KEY_BACKEND_REFS`] (a6c5679) /
17050/// [`GATEWAY_API_KEY_PARENT_REFS`] (f44e823) /
17051/// [`GATEWAY_API_KEY_LISTENERS`] (29f2415) /
17052/// [`GATEWAY_API_KEY_HOSTNAMES`] (b77f744) /
17053/// [`GATEWAY_API_KEY_HOSTNAME`] (c96fa22) /
17054/// [`GATEWAY_API_KEY_TIMEOUTS`] (db31108) /
17055/// [`GATEWAY_API_KEY_RETRY`] (231bbf5) /
17056/// [`GATEWAY_API_KEY_GATEWAY_CLASS_NAME`] (1bc727d) lifts established
17057/// on the sibling canonical-Gateway-API-CRD-body-axis surface —
17058/// completes the four-way per-child-object axis-key set (`name` on
17059/// listeners + parentRefs + backendRefs, alongside sibling
17060/// `hostname`/`port`/`protocol` per-listener and `port` per-
17061/// backendRef) the M3 Aplicacao mesh renderer's external `:entrada`
17062/// ingress contract rests on. The render-side consumer now threads
17063/// the same `&'static str` through every one of its `.insert(…)`
17064/// calls so a future Gateway API rebrand on the name-reference axis
17065/// (or an upstream SIG-Network Gateway API v2 rename to a per-CRD
17066/// sibling name) lands in one place; every future renderer that
17067/// reaches for the canonical per-child-object name-reference axis
17068/// (the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
17069/// materializer's per-Aplicacao `Gateway` + `HTTPRoute` fan-out, a
17070/// future per-edge `GRPCRoute` / `TCPRoute` / `TLSRoute` renderer
17071/// whose per-rule backend-Service reference binds against this same
17072/// axis, a future per-Aplicacao `ReferenceGrant` renderer whose per-
17073/// cross-namespace parent-Gateway attachment resolves against this
17074/// same axis) inherits the same value by construction with no
17075/// opportunity for per-renderer drift.
17076///
17077/// Byte-identical to [`KUBE_KEY_NAME`] today — both resolve to the
17078/// same three-byte `"name"` literal — but semantically distinct:
17079/// [`KUBE_KEY_NAME`] names the K8s CR canonical `metadata.name` axis
17080/// (every rendered CR's outer-level identity discriminator, spelled
17081/// per the K8s apiserver's per-object `OpenAPI` v3 schema), while this
17082/// constant names the Gateway API v1 CRD schema's per-child-object
17083/// name-reference discriminator axis on `Listener` / `ParentReference`
17084/// / `BackendObjectReference` sub-schemas (spelled per the Gateway API
17085/// v1 CRD schema — a separate schema contract). Splitting the two
17086/// lets each schema's future rebrand land independently at its
17087/// canonical const definition without coupling the K8s CR canonical-
17088/// key axis to the Gateway API v1 per-child-object name-reference
17089/// axis (or vice versa) — the same discipline
17090/// [`FLEET_PROGRAMS_KEY_NAME`] establishes vs. [`KUBE_KEY_NAME`] on
17091/// the `lareira-fleet-programs` values-schema per-entry name-axis.
17092///
17093/// [cm]: ../../caixa_mesh/index.html
17094pub const GATEWAY_API_KEY_NAME: &str = "name";
17095
17096/// Canonical Helm 3 `Chart.yaml` `apiVersion` every `caixa-helm`-rendered
17097/// `lareira-<nome>` chart declares at its top-level `apiVersion` axis. The
17098/// Helm 3 chart-schema resolution contract keys off this exact `"v2"` value:
17099/// `helm dependency build`, `helm lint`, and `helm template` all parse the
17100/// chart under the Helm 3 v2 schema (which requires
17101/// [`ChartYaml::description`][chart-yaml-desc] and permits
17102/// `dependencies:` at the top level); drift to the legacy Helm 2 `"v1"`
17103/// (the pre-Helm-3 chart schema every upstream Helm-3-migration doc names)
17104/// silently reroutes the rendered `Chart.yaml` through the Helm 2 parser,
17105/// where the top-level `dependencies:` block is unknown and the chart's
17106/// dep on the `pleme-computeunit` library chart never resolves —
17107/// `helm dependency build` reports "no requirements found" and every
17108/// downstream `helm template` / `helm install` on the rendered chart
17109/// emits an empty release (no ComputeUnit / Service / ScaledObject
17110/// resources land) far from the source caixa.lisp / the renderer's
17111/// `build_chart_yaml` call site.
17112///
17113/// The single source of truth the [`caixa-helm`][ch]'s `build_chart_yaml`
17114/// `Chart.yaml` `apiVersion` axis reaches for (caixa-helm/src/lib.rs:298).
17115/// Peer with the [`FLUX_HELMRELEASE_API_VERSION`] (55f0fd9) /
17116/// [`FLUX_GITREPOSITORY_API_VERSION`] (dbbcf29) /
17117/// [`FLUX_KUSTOMIZATION_API_VERSION`] (d2dd1b1) /
17118/// [`GATEWAY_API_API_VERSION`] (3c6cfc3) / [`CILIUM_API_VERSION`] (279d611)
17119/// lifts on the sibling cluster-side-CRD-apiVersion surface — those pin
17120/// the K8s apiserver-side `(apiVersion, kind)` `RESTMapper` contract,
17121/// this one pins the Helm-side chart-schema-parser contract that gates
17122/// every rendered `lareira-<nome>` chart's dependency resolution before
17123/// any K8s resource lands. Both axes are load-bearing schema-version
17124/// discriminators drift-prone by construction across renderer forks.
17125///
17126/// A future Helm 4 chart-schema promotion (the upstream Helm roadmap
17127/// names a `"v3"` apiVersion once the Helm 3 LTS branch closes) is a
17128/// coordinated migration alongside the upstream Helm chart-schema
17129/// deprecation cycle, not an incidental edit — pinning it here means
17130/// the migration lands as one edit at the const + a re-run of the
17131/// pin tests rather than a per-renderer sweep with no single source
17132/// of truth to consult. Same "the typed constant lives in one place"
17133/// discipline the [`DEFAULT_LIBRARY_NAME`] (41438dc) /
17134/// [`LAREIRA_CHART_NAME_PREFIX`] / [`FLUX_HELMRELEASE_API_VERSION`]
17135/// (55f0fd9) lifts apply on the peer canonical-Helm-load-bearing-string
17136/// and cluster-side-CRD-apiVersion axes.
17137///
17138/// [chart-yaml-desc]: https://helm.sh/docs/topics/charts/#the-chartyaml-file
17139/// [ch]: ../../caixa_helm/index.html
17140pub const HELM_CHART_API_VERSION: &str = "v2";
17141
17142/// Canonical Helm 3 `Chart.yaml` `type` field per-chart-kind discriminator
17143/// scalar-value every rendered `lareira-<nome>` chart declares. The Helm
17144/// chart-schema pins the per-chart-kind axis to the closed set
17145/// `{"application", "library"}` (see [chart-type-doc]) — the
17146/// `application` chart-kind is Helm's default install-shape (an
17147/// application chart that installs into a namespace as a workload +
17148/// rendered manifests), while the `library` chart-kind is Helm's
17149/// dependency-only shape (a chart authored as a shared-template
17150/// substrate that can only be consumed as a dependency, never installed
17151/// directly). Each `lareira-<nome>` chart the caixa-helm renderer emits
17152/// declares itself as an `application` chart because it is the per-
17153/// Servico install shape a cluster operator's `helm install` /
17154/// `helm upgrade` per-Servico release cycle materializes — the sibling
17155/// [`DEFAULT_LIBRARY_NAME`] `pleme-computeunit` chart (the substrate-
17156/// side library-chart the `lareira-<nome>` chart depends on for
17157/// template-shape) carries the sibling `library` value verbatim in its
17158/// authored Chart.yaml (out-of-tree at the `pleme-io/helmworks` repo,
17159/// so not this crate's authority).
17160///
17161/// The single source of truth the rendered `lareira-<nome>` chart's
17162/// Chart.yaml per-chart-kind discriminator axis naming reaches for:
17163///
17164/// - [`caixa-helm`][ch]'s `build_chart_yaml` `chart_type` field
17165/// assignment (caixa-helm/src/lib.rs — the sole production emitter
17166/// site the prior inline `"application".into()` literal sat at,
17167/// writing the per-chart-kind discriminator scalar-value the
17168/// `helm install` / `helm upgrade` per-release install-shape dispatch
17169/// loop keys off to select the per-chart-kind install pathway).
17170///
17171/// Until this lift landed the axis carried an inline `"application"`
17172/// literal at the one production-code site (`build_chart_yaml`'s
17173/// `chart_type` field assignment). A drift on the value at the emitter
17174/// (a `"Application"` / `"APPLICATION"` / `"app"` / `"workload"` typo,
17175/// or an accidental collapse onto the sibling `"library"` shape) would
17176/// have surfaced as one of two silent failure modes at `helm install`
17177/// time:
17178///
17179/// - a value outside the schema's admitted set (`{"application",
17180/// "library"}`) — Helm's chart-schema parser silently treats an
17181/// unrecognized `type:` scalar as the default `application` shape,
17182/// so a typo like `"Application"` still installs but with no
17183/// drift-signal in the process log, silently masking the schema
17184/// violation;
17185/// - a schema-admitted-but-wrong-shape drift onto `"library"` —
17186/// `helm install lareira-<nome>` refuses the release with an
17187/// "Error: library charts cannot be installed" error, and the
17188/// per-Servico release cycle drops with no field naming the
17189/// chart-kind-drift root cause (the operator sees "the chart won't
17190/// install" far from the drift site, and troubleshooting has no
17191/// canonical anchor to compare the rendered value against).
17192///
17193/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
17194/// "every recurring shape becomes a generator before it becomes a
17195/// pattern; every pattern becomes a library before it becomes
17196/// duplicated code. The duplication budget is zero.") promotes the
17197/// constant to a typed substrate-side `&'static str` on the same
17198/// trajectory the peer [`HELM_CHART_API_VERSION`] /
17199/// [`DEFAULT_LIBRARY_NAME`] / [`LAREIRA_CHART_NAME_PREFIX`] lifts
17200/// established on the sibling canonical-Helm-load-bearing-string axes —
17201/// extends the canonical-Helm-chart-schema-axis single-sourcing
17202/// discipline the `apiVersion` lift established onto the sibling
17203/// per-chart-kind discriminator scalar-value axis every rendered
17204/// `lareira-<nome>` chart declares in its Chart.yaml. Peer to the
17205/// canonical-cluster-side-OpenAPI-schema-enum-value lifts
17206/// ([`KUBE_PROTOCOL_TCP`] / [`GATEWAY_API_PROTOCOL_HTTP`] /
17207/// [`GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX`] /
17208/// [`CILIUM_AUTH_MODE_REQUIRED`] / [`CILIUM_AUTH_MODE_DISABLED`]) on
17209/// the sibling K8s-CR-side enum-value surfaces — pivots the discipline
17210/// from the K8s-CR-side OpenAPI-schema-enum-value axis onto the
17211/// Helm-chart-schema-enum-value axis every rendered Chart.yaml carries
17212/// at its per-chart-kind discriminator field.
17213///
17214/// [chart-type-doc]: https://helm.sh/docs/topics/charts/#chart-types
17215/// [ch]: ../../caixa_helm/index.html
17216pub const HELM_CHART_TYPE_APPLICATION: &str = "application";
17217
17218/// Canonical Helm 3 `Chart.yaml` `type` field per-chart-kind discriminator
17219/// scalar-value the sibling library-chart shape lands on — the second and
17220/// only other arm of the closed set `{"application", "library"}` the Helm
17221/// chart-schema pins the per-chart-kind axis to (see [chart-type-doc]).
17222/// The `library` chart-kind is Helm's dependency-only install-shape: a
17223/// chart authored as a shared-template substrate the per-Aplicacao
17224/// `lareira-<nome>` application charts depend on for their emitted-
17225/// object templates (the [`DEFAULT_LIBRARY_NAME`] `pleme-computeunit`
17226/// chart out-of-tree at `pleme-io/helmworks` is the substrate's
17227/// canonical instance today), and Helm refuses to install it directly
17228/// (`helm install <library-chart>` fails with "Error: library charts
17229/// cannot be installed") — a chart declaring itself under this
17230/// scalar-value is only ever consumed as a dependency by a sibling
17231/// `application`-typed chart.
17232///
17233/// Peer of [`HELM_CHART_TYPE_APPLICATION`] on the same closed
17234/// canonical-Helm-chart-schema-per-chart-kind-discriminator axis: the
17235/// two consts together name the two-arm schema-admitted set as a pair
17236/// of `&'static str`s at the substrate-side canonical surface, so any
17237/// consumer that reaches for either shape (the caixa-helm renderer at
17238/// [`HELM_CHART_TYPE_APPLICATION`]'s single emitter site today; the
17239/// future per-Aplicacao library chart the [`HELM_CHART_TYPE_APPLICATION`]
17240/// docstring names as a trajectory item, whose emit site would land at
17241/// this const; the future `mesh.pleme.io/v1alpha1/Aplicacao` CR
17242/// materializer's per-chart-kind admission gate that needs to accept
17243/// exactly the two-arm closed set) reads from one canonical declaration
17244/// per arm, not a scattered mix of substrate-side const + prose-only
17245/// sibling. Same "one canonical declaration per arm, next to the
17246/// closed set's peer" discipline the peer
17247/// [`CILIUM_AUTH_MODE_REQUIRED`] / [`CILIUM_AUTH_MODE_DISABLED`]
17248/// (2c3f11b — the two-arm Cilium `MutualAuthenticationMode` `OpenAPI`
17249/// enum's closed set) established for the sibling Cilium-CR-side
17250/// per-enum-value axis, and the peer
17251/// [`M3_PLACEMENT_ESTRATEGIA_SINGLE_NODE`] /
17252/// [`M3_PLACEMENT_ESTRATEGIA_REPLICATED`] /
17253/// [`M3_PLACEMENT_ESTRATEGIA_SHARDED`] (b0ce0a5 — the three-arm typed
17254/// [`crate::PlacementStrategy`] variant discriminator-value set) applies
17255/// on the sibling M3 typed-enum discriminator-scalar axis — extends the
17256/// discipline onto the Helm-chart-schema-enum-value closed set every
17257/// rendered Chart.yaml declares its per-chart-kind axis over.
17258///
17259/// Until this lift landed the sibling `"library"` value lived only in
17260/// prose across the [`HELM_CHART_TYPE_APPLICATION`] docstring's
17261/// closed-set enumeration (3+ mentions naming the sibling `library`
17262/// shape as the schema-admitted second arm, including the accidental-
17263/// collapse-onto-sibling failure-mode arm the pin test
17264/// [`tests::helm_chart_type_application_and_library_are_distinct`]
17265/// closes), with no compile-time link between the substrate-side
17266/// canonical const and the sibling closed-set arm the docstring
17267/// referenced — a hypothetical future consumer reaching for the
17268/// sibling shape (an operator-side per-chart-kind classifier, a
17269/// helmworks-side value-drift detector, the future per-Aplicacao
17270/// library chart's emit site) had to re-derive the value from the
17271/// prose enumeration rather than reading the same `&'static str` the
17272/// substrate declares. This lift closes that gap by pairing the
17273/// canonical-Helm-chart-schema-per-chart-kind axis at both closed-set
17274/// arms, so drift-detection between the two shapes is a build-time
17275/// constant-value comparison at
17276/// [`tests::helm_chart_type_application_and_library_are_distinct`]
17277/// rather than a runtime silent-collapse-onto-sibling far from the
17278/// drift's source.
17279///
17280/// [chart-type-doc]: https://helm.sh/docs/topics/charts/#chart-types
17281pub const HELM_CHART_TYPE_LIBRARY: &str = "library";
17282
17283/// Canonical Helm 3 `Chart.yaml` top-level YAML axis-key naming the
17284/// per-chart chart-schema-apiVersion field whose scalar-value
17285/// [`HELM_CHART_API_VERSION`] already owns as the peer axis-value
17286/// lift. Where the peer axis-value lift pins the byte-shape of the
17287/// `apiVersion:` field's admitted scalar (Helm 3's `"v2"`), this
17288/// axis-key lift pins the byte-shape of the `apiVersion:` field's
17289/// YAML-key name itself: the load-bearing serde-rename literal at
17290/// [`caixa-helm`][ch]'s `ChartYaml` struct
17291/// (`caixa-helm/src/lib.rs:145`, `#[serde(rename = "apiVersion")]`)
17292/// that selects how the Rust field `api_version` serializes into
17293/// the rendered `Chart.yaml` YAML mapping.
17294///
17295/// The byte-shape (`"apiVersion"`) is byte-identical to the K8s-CR
17296/// top-level per-CR schema-apiVersion axis key ([`KUBE_KEY_API_VERSION`])
17297/// by Helm's design decision to inherit the K8s CR top-level shape
17298/// verbatim (see [chart-yaml-desc]) — the paired
17299/// `helm_chart_key_api_version_matches_kube_key_api_version` pin
17300/// asserts the two byte-shapes coincide, so a future K8s-side
17301/// rebrand at [`KUBE_KEY_API_VERSION`] that dropped the byte-
17302/// identity would fail the pin, surfacing the axis divergence at
17303/// substrate-build time rather than as a silent Helm-chart-schema-
17304/// parser rejection at `helm lint` / `helm template` time. The two
17305/// axes are structurally-independent schema surfaces (the Helm 3
17306/// chart-schema top-level shape vs. the K8s apiserver-side CR
17307/// top-level shape) whose byte-shapes happen to coincide today; the
17308/// paired pin makes the coincidence load-bearing rather than
17309/// accidental.
17310///
17311/// The single source of truth every consumer that names the per-
17312/// Chart.yaml top-level chart-schema-apiVersion YAML key reaches for:
17313///
17314/// - [`caixa-helm`][ch]'s `ChartYaml` struct's `api_version` field
17315/// `#[serde(rename = "apiVersion")]` attribute (the sole
17316/// production serialize-side site the literal appears at as a
17317/// syntactic serde-rename argument; the attribute itself cannot
17318/// consume a `const` because Rust's attribute grammar admits
17319/// only string literals, so the discipline here is: the const's
17320/// byte-shape must remain byte-identical to the literal the
17321/// attribute pins, and the paired drift-detection pin at
17322/// [`caixa-helm`]'s
17323/// `chart_yaml_serializes_api_version_axis_under_lifted_helm_chart_key_api_version`
17324/// round-trips a rendered [`caixa-helm`]-emitted `Chart.yaml`
17325/// through `serde_yaml::from_str::<serde_yaml::Value>` and
17326/// asserts the top-level `Mapping::get(HELM_CHART_KEY_API_VERSION)`
17327/// resolves — closing the drift the syntactic-literal-only
17328/// attribute would otherwise leave silent);
17329/// - every test-side navigator that inspects the serialized
17330/// [`caixa-helm`]-emitted `Chart.yaml` YAML mapping by the top-
17331/// level chart-schema-apiVersion key.
17332///
17333/// A drift on the emitter's serde-rename literal (a future refactor
17334/// that dropped the `#[serde(rename = "apiVersion")]` attribute or
17335/// changed the target key to `"ApiVersion"` / `"apiversion"` /
17336/// `"schemaVersion"`) would silently serialize the field under
17337/// Rust's default snake_case `api_version:` key, which Helm's
17338/// chart-schema parser rejects at `helm lint` / `helm dependency
17339/// build` / `helm template` time with an "apiVersion is required"
17340/// error — the failure surfaces far from the drift site, and every
17341/// downstream `lareira-<nome>` chart consumer drops with no field
17342/// naming the serde-rename-drift root cause. Same drift-detection-
17343/// pin discipline the peer [`HELM_CHART_KEY_TYPE`] /
17344/// [`HELM_CHART_KEY_APP_VERSION`] lifts (d29bc23) established on the
17345/// sibling per-Chart.yaml serde-rename-literal-only axis pair —
17346/// extends the discipline from the two axes those lifts closed onto
17347/// the third and last serde-rename-literal-only axis at
17348/// [`caixa-helm`]'s `ChartYaml` struct, so every `#[serde(rename =
17349/// "...")]` literal on the struct threads through a canonical
17350/// substrate-side `&'static str` with a paired drift-detection pin.
17351///
17352/// [chart-yaml-desc]: https://helm.sh/docs/topics/charts/#the-chartyaml-file
17353/// [ch]: ../../caixa_helm/index.html
17354pub const HELM_CHART_KEY_API_VERSION: &str = "apiVersion";
17355
17356/// Canonical Helm 3 `Chart.yaml` top-level YAML axis-key naming the
17357/// per-chart-kind discriminator field whose closed-set scalar-value
17358/// pair [`HELM_CHART_TYPE_APPLICATION`] / [`HELM_CHART_TYPE_LIBRARY`]
17359/// already owns as the peer axis-value lift. Where the peer
17360/// axis-value lifts pin the byte-shape of the `type:` field's
17361/// admitted-value set, this axis-key lift pins the byte-shape of the
17362/// `type:` field's YAML-key name itself: the load-bearing serde-
17363/// rename literal at [`caixa-helm`][ch]'s `ChartYaml` struct
17364/// (`caixa-helm/src/lib.rs:149`, `#[serde(rename = "type")]`) that
17365/// selects how the Rust field `chart_type` serializes into the
17366/// rendered `Chart.yaml` YAML mapping.
17367///
17368/// The single source of truth every consumer that names the per-
17369/// Chart.yaml top-level per-chart-kind discriminator key reaches for:
17370///
17371/// - [`caixa-helm`][ch]'s `ChartYaml` struct's `chart_type` field
17372/// `#[serde(rename = "type")]` attribute (the sole production
17373/// serialize-side site the literal appears at as a syntactic
17374/// serde-rename argument; the attribute itself cannot consume a
17375/// `const` because Rust's attribute grammar admits only string
17376/// literals, so the discipline here is: the const's byte-shape
17377/// must remain byte-identical to the literal the attribute pins,
17378/// and the drift-detection pin at
17379/// [`caixa-helm`]'s
17380/// `chart_yaml_serializes_type_axis_under_lifted_helm_chart_key_type`
17381/// round-trips a rendered [`caixa-helm`]-emitted `Chart.yaml`
17382/// through `serde_yaml::from_str::<serde_yaml::Value>` and
17383/// asserts the top-level `Mapping::get(HELM_CHART_KEY_TYPE)`
17384/// resolves — closing the drift the syntactic-literal-only
17385/// attribute would otherwise leave silent);
17386/// - every test-side navigator that inspects the serialized
17387/// [`caixa-helm`]-emitted `Chart.yaml` YAML mapping by the top-
17388/// level per-chart-kind discriminator key.
17389///
17390/// A drift on the emitter's serde-rename literal (a future refactor
17391/// that dropped the `#[serde(rename = "type")]` attribute or
17392/// changed the target key to `"Type"` / `"kind"` / `"chartType"`)
17393/// would surface as one of two silent failure modes at
17394/// `helm dependency build` / `helm lint` / `helm template` time
17395/// far from the drift site: the rendered `Chart.yaml`'s top-level
17396/// mapping carries an unrecognized key (`chart_type:` from Rust's
17397/// default snake_case serialization) that Helm's chart-schema
17398/// parser silently ignores, defaulting the per-chart-kind axis to
17399/// `application` with no process-log drift-signal (masking the
17400/// schema-shape violation); or the drift accidentally collapses
17401/// the key onto the sibling `kind` / K8s-CR `KUBE_KEY_KIND`
17402/// axis (byte-distinct today at the substrate — see the paired
17403/// `helm_chart_key_type_is_byte_distinct_from_kube_key_kind` pin)
17404/// that Helm's chart-schema parser silently treats as an unknown
17405/// field, again defaulting the per-chart-kind axis.
17406///
17407/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5)
17408/// promotes the axis-key to a typed substrate-side `&'static str`
17409/// on the same trajectory the peer axis-value lifts
17410/// ([`HELM_CHART_TYPE_APPLICATION`] / [`HELM_CHART_TYPE_LIBRARY`])
17411/// established — completes the per-Chart.yaml per-chart-kind
17412/// discriminator axis single-sourcing at both the key and value
17413/// halves (`{HELM_CHART_KEY_TYPE, HELM_CHART_TYPE_APPLICATION,
17414/// HELM_CHART_TYPE_LIBRARY}`), so the full
17415/// `(key, admitted-value-set)` per-axis lift lives at one canonical
17416/// declaration site. Same "(key, value) axis-pair lift completes at
17417/// one canonical source per half" discipline the peer
17418/// [`KUBE_KEY_API_VERSION`] (7994) + [`HELM_CHART_API_VERSION`]
17419/// (14580) pair carries on the sibling apiVersion axis, and the
17420/// [`FLEET_PROGRAMS_KEY_NAME`] (7651) + `Servico :nome` value pair
17421/// carries on the sibling per-fleet-programs-entry axis.
17422///
17423/// [chart-type-doc]: https://helm.sh/docs/topics/charts/#chart-types
17424/// [ch]: ../../caixa_helm/index.html
17425pub const HELM_CHART_KEY_TYPE: &str = "type";
17426
17427/// Canonical Helm 3 `Chart.yaml` top-level YAML axis-key naming the
17428/// per-chart underlying-application-version field — the load-bearing
17429/// serde-rename literal at [`caixa-helm`][ch]'s `ChartYaml` struct
17430/// (`caixa-helm/src/lib.rs:152`, `#[serde(rename = "appVersion")]`)
17431/// that selects how the Rust field `app_version` serializes into the
17432/// rendered `Chart.yaml` YAML mapping. Distinct from the sibling
17433/// [`Chart.yaml` `version:` field][chart-yaml-desc] (the chart's own
17434/// SemVer, incremented per release of the chart itself); the
17435/// `appVersion:` field the Helm 3 chart-schema pins carries the
17436/// underlying application's version (see [app-version-doc]) — the
17437/// version the containerized workload the chart installs advertises
17438/// (an OCI image tag, a wasm-component `:versao`, a package release
17439/// tag). At the caixa-helm renderer today the two axes both draw
17440/// from the caixa's `:versao` at [`build_chart_yaml`] because a
17441/// [`caixa-core::Caixa`]'s `:versao` names both the chart's own
17442/// release cadence and the underlying wasm-component release
17443/// cadence in one axis (`caixa`'s per-caixa BLAKE3-closure identity
17444/// binds a caixa's chart + wasm-binary + declared source at exactly
17445/// one release axis), but the Chart.yaml schema pins the two YAML
17446/// keys distinctly regardless — every downstream Helm-consumer
17447/// (Artifact Hub's per-chart-search index, `helm search` /
17448/// `helm show chart` operator surfaces) routes the two axes onto
17449/// distinct display fields at chart-inspection time.
17450///
17451/// The single source of truth every consumer that names the per-
17452/// Chart.yaml top-level app-version YAML key reaches for:
17453///
17454/// - [`caixa-helm`][ch]'s `ChartYaml` struct's `app_version` field
17455/// `#[serde(rename = "appVersion")]` attribute (the sole
17456/// production serialize-side site the literal appears at as a
17457/// syntactic serde-rename argument; the same
17458/// attribute-literal-only-grammar constraint the peer
17459/// [`HELM_CHART_KEY_TYPE`] docstring enumerates applies, and
17460/// the paired drift-detection pin at [`caixa-helm`]'s
17461/// `chart_yaml_serializes_app_version_axis_under_lifted_helm_chart_key_app_version`
17462/// round-trips a rendered `Chart.yaml` and asserts the top-level
17463/// `Mapping::get(HELM_CHART_KEY_APP_VERSION)` resolves);
17464/// - every test-side navigator that inspects the serialized
17465/// [`caixa-helm`]-emitted `Chart.yaml` YAML mapping by the top-
17466/// level per-chart-app-version key.
17467///
17468/// A drift on the emitter's serde-rename literal (a future refactor
17469/// that dropped the `#[serde(rename = "appVersion")]` attribute or
17470/// changed the target key to `"AppVersion"` / `"applicationVersion"`
17471/// / `"version"`) would surface as one of two silent failure modes
17472/// at Helm-chart-consumption time far from the drift site: the
17473/// rendered `Chart.yaml`'s top-level mapping carries an unrecognized
17474/// key (`app_version:` from Rust's default snake_case serialization)
17475/// that Helm's chart-schema parser silently drops from the parsed
17476/// chart-metadata shape (masking the schema-shape violation with no
17477/// process-log drift-signal, and every downstream Artifact Hub /
17478/// `helm search` per-chart index falls back to "no application
17479/// version" for the rendered chart); or the drift accidentally
17480/// collapses the app-version key onto the sibling chart-own-version
17481/// `version:` axis (byte-distinct today at the substrate — see the
17482/// paired
17483/// `helm_chart_key_app_version_is_byte_distinct_from_helm_chart_key_version`
17484/// pin) that Helm's chart-schema parser then silently reads under
17485/// the wrong axis, and the chart's own SemVer collides with the
17486/// underlying-application version at every downstream Helm-consumer.
17487///
17488/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5)
17489/// promotes the axis-key to a typed substrate-side `&'static str`
17490/// on the same trajectory the peer [`HELM_CHART_KEY_TYPE`] lift
17491/// established — extends the per-Chart.yaml top-level YAML axis-key
17492/// single-sourcing discipline from the per-chart-kind discriminator
17493/// key onto the sibling per-chart-app-version key, so every
17494/// substrate-side renderer that emits or navigates a `Chart.yaml`
17495/// top-level mapping consults one canonical `&'static str` per axis.
17496///
17497/// [chart-yaml-desc]: https://helm.sh/docs/topics/charts/#the-chartyaml-file
17498/// [app-version-doc]: https://helm.sh/docs/topics/charts/#the-appversion-field
17499/// [ch]: ../../caixa_helm/index.html
17500pub const HELM_CHART_KEY_APP_VERSION: &str = "appVersion";
17501
17502/// Canonical Helm 3 `Chart.yaml` top-level YAML axis-key naming the
17503/// per-chart dependency-list field — the load-bearing serde
17504/// field-name at [`caixa-helm`][ch]'s `ChartYaml` struct's
17505/// `dependencies` field, the parent list-container the already-lifted
17506/// [`HELM_CHART_DEPENDENCY_KEY_NAME`] / [`HELM_CHART_DEPENDENCY_KEY_VERSION`]
17507/// / [`HELM_CHART_DEPENDENCY_KEY_REPOSITORY`] /
17508/// [`HELM_CHART_DEPENDENCY_KEY_ALIAS`] per-entry sub-mapping tetrad
17509/// (69f62db) mounts under. The chart-schema top-level `dependencies:`
17510/// field pins the list of chart-registry references Helm's per-dep
17511/// resolver consults at `helm dependency build` /
17512/// `helm dependency update` time to vendor each dependency chart
17513/// under the substrate's canonical [`DEFAULT_LIBRARY_NAME`] wrap-key
17514/// convention. Every rendered `lareira-<nome>` chart declares exactly
17515/// one entry today (the [`DEFAULT_LIBRARY_NAME`] `pleme-computeunit`
17516/// library-chart dep the sibling [`caixa-helm`][ch]'s `build_chart_yaml`
17517/// mounts) — see [chart-dependencies-doc] for the Helm 3 upstream axis
17518/// documentation.
17519///
17520/// The single source of truth every consumer that names the per-
17521/// Chart.yaml top-level dependency-list key reaches for:
17522///
17523/// - [`caixa-helm`][ch]'s `ChartYaml` struct's `dependencies` field
17524/// (the sole production serialize-side site the wire-key appears
17525/// at — Rust's default field-name-verbatim serde emission means
17526/// no `#[serde(rename = "…")]` attribute pins the key today; the
17527/// paired drift-detection pin at [`caixa-helm`]'s
17528/// `chart_yaml_serializes_dependencies_axis_under_lifted_helm_chart_key_dependencies`
17529/// round-trips a rendered `Chart.yaml` through
17530/// `serde_yaml::from_str::<serde_yaml::Value>` and asserts the
17531/// top-level `Mapping::get(HELM_CHART_KEY_DEPENDENCIES)` resolves —
17532/// closing the drift a future hostile refactor could otherwise
17533/// leave silent: a rename of the Rust field to `Vec<ChartDependency>
17534/// under a `deps:` / `chartDependencies:` name, or an accidental
17535/// `#[serde(rename_all = "camelCase")]` attribute on `ChartYaml`
17536/// that stays a no-op on the four identity-mapped top-level keys
17537/// today but silently activates on a future multi-word field
17538/// addition);
17539/// - every test-side navigator that inspects the serialized
17540/// [`caixa-helm`]-emitted `Chart.yaml` YAML mapping by the top-
17541/// level per-chart-dependency-list key.
17542///
17543/// A drift on this per-Chart.yaml top-level list-container axis-key
17544/// would silently rebrand the wire key — Helm's chart-schema parser
17545/// silently drops the dep list from the parsed chart-metadata shape,
17546/// `helm dependency build` finds no chart to vendor, and every
17547/// rendered `lareira-<nome>` chart's install fails with
17548/// `template: no template ... associated with template ...` far from
17549/// the drift site with no field naming the top-level-list-key-drift
17550/// root cause. The failure mode is byte-shape-symmetric with the peer
17551/// [`HELM_CHART_DEPENDENCY_KEY_NAME`] drift narrative (which closes on
17552/// the per-entry name axis one level down) — both close on the
17553/// `helm dependency build` / apply-time path.
17554///
17555/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5)
17556/// promotes the top-level list-container axis-key to a typed
17557/// substrate-side `&'static str` on the same trajectory the peer
17558/// [`HELM_CHART_KEY_TYPE`] / [`HELM_CHART_KEY_APP_VERSION`] /
17559/// [`HELM_CHART_KEY_API_VERSION`] top-level axis-key lifts (d29bc23,
17560/// cc44e4b) established — completes the parent+children canonical-pin
17561/// pair with the already-lifted per-`dependencies[]`-entry
17562/// sub-mapping tetrad. Where the child tetrad pins the byte-shape of
17563/// each per-dep entry's four sub-mapping keys (`name`, `version`,
17564/// `repository`, `alias`), this parent-axis lift pins the byte-shape
17565/// of the top-level list-container the tetrad mounts under, so the
17566/// full `(dependencies: → [name/version/repository/alias])`
17567/// per-Chart.yaml dependency-list schema surface lives at one
17568/// canonical `&'static str` per YAML axis-key. Same
17569/// "parent list-container + child sub-mapping tetrad" canonical-pin
17570/// discipline the peer [`SUPERVISOR_KEY_CHILDREN`] (parent) +
17571/// [`SUPERVISOR_CHILD_KEY_CAIXA`] / [`SUPERVISOR_CHILD_KEY_VERSAO`] /
17572/// [`SUPERVISOR_CHILD_KEY_RESTART`] (children) pair (40cc4e5, ef912df)
17573/// established on the sibling per-`:supervisor :children` axis, and the
17574/// peer [`M2_KEY_UPGRADE_FROM`] (parent) +
17575/// [`M2_UPGRADE_FROM_KEY_FROM`] / [`M2_UPGRADE_FROM_KEY_INSTRUCTIONS`]
17576/// (children) pair established on the sibling per-`:upgrade-from` axis.
17577///
17578/// [chart-yaml-desc]: https://helm.sh/docs/topics/charts/#the-chartyaml-file
17579/// [chart-dependencies-doc]: https://helm.sh/docs/topics/charts/#chart-dependencies
17580/// [ch]: ../../caixa_helm/index.html
17581pub const HELM_CHART_KEY_DEPENDENCIES: &str = "dependencies";
17582
17583/// Canonical Helm 3 `Chart.yaml` per-`dependencies[]`-entry sub-mapping
17584/// YAML axis-key naming the per-dep chart-name field — the load-bearing
17585/// serde field-name at [`caixa-helm`][ch]'s `ChartDependency` struct's
17586/// `name` field. Byte-identical to the sibling K8s CR
17587/// [`KUBE_KEY_NAME`] axis-key by Helm's design decision to inherit the
17588/// K8s CR body-key vocabulary at every schema surface it consumes
17589/// (chart-metadata, per-CR install-payload, per-dep dependency-list);
17590/// the paired
17591/// [`tests::helm_chart_dependency_key_name_matches_kube_key_name`] pin
17592/// asserts the two byte-shapes coincide, so a future K8s-side rebrand
17593/// at [`KUBE_KEY_NAME`] that dropped the byte-identity would fail the
17594/// pin at substrate-build time rather than silently drop the per-dep
17595/// name lookup at `helm dependency build` time far from the drift site.
17596///
17597/// The chart-schema per-dep entry's `name:` value pins the exact
17598/// Helm-registry chart-name Helm's per-dep alias convention scopes the
17599/// per-dep values sub-block under when no `alias:` is set (see the
17600/// sibling [`HELM_CHART_DEPENDENCY_KEY_ALIAS`] docstring for the alias
17601/// axis) — every rendered `lareira-<nome>` chart's Chart.yaml
17602/// `dependencies[0].name:` binds to the same `&'static str` as its
17603/// values.yaml wrap key (see [`caixa-helm`][ch]'s
17604/// `values_yaml_wrap_key_matches_chart_dependency_name` pin on the
17605/// structural alignment). A drift on this per-dep sub-key (a future
17606/// refactor that renamed the `ChartDependency::name` Rust field to
17607/// `ChartDependency::nome`, or added a
17608/// `#[serde(rename_all = "camelCase")]` attribute that stays a no-op
17609/// on the four identity-mapped keys today but silently activates on a
17610/// future field addition) would rebrand the wire key silently — Helm's
17611/// per-dep dependency-router silently drops the dep from the parsed
17612/// chart-metadata (the substrate ships a Chart.yaml that lists no
17613/// `pleme-computeunit` dep, `helm dependency build` finds no chart to
17614/// vendor, and every rendered lareira-`<nome>` chart's install fails
17615/// with "template: no template ... associated with template ..." far
17616/// from the drift site). Peer to [`HELM_CHART_DEPENDENCY_KEY_VERSION`]
17617/// / [`HELM_CHART_DEPENDENCY_KEY_REPOSITORY`] /
17618/// [`HELM_CHART_DEPENDENCY_KEY_ALIAS`] on the sibling per-dep sub-key
17619/// axes — completes the per-`dependencies[]`-entry YAML axis-key
17620/// canonical-pin tetrad at the substrate. Same per-entry-sub-key
17621/// canonical-lift discipline the peer
17622/// [`SUPERVISOR_CHILD_KEY_CAIXA`] / [`SUPERVISOR_CHILD_KEY_VERSAO`] /
17623/// [`SUPERVISOR_CHILD_KEY_RESTART`] triad (ef912df) established on the
17624/// sibling per-`:children` sub-mapping surface, and the
17625/// [`ENTRADA_KEY_HOST`] / [`ENTRADA_KEY_PARA`] / [`ENTRADA_KEY_PATHS`]
17626/// / [`ENTRADA_KEY_PORT`] tetrad (a3d6162) established on the sibling
17627/// per-`:entrada` sub-mapping surface.
17628///
17629/// [ch]: ../../caixa_helm/index.html
17630pub const HELM_CHART_DEPENDENCY_KEY_NAME: &str = "name";
17631
17632/// Canonical Helm 3 `Chart.yaml` per-`dependencies[]`-entry sub-mapping
17633/// YAML axis-key naming the per-dep chart-version-constraint field —
17634/// the load-bearing serde field-name at [`caixa-helm`][ch]'s
17635/// `ChartDependency` struct's `version` field. Distinct from the
17636/// sibling per-Chart.yaml top-level chart-own-SemVer axis-key
17637/// (`version:` at the top level, whose byte-shape coincides with this
17638/// per-dep sub-key at the wire — a coincidence the substrate-side
17639/// paired [`tests::helm_chart_dependency_key_version_pins_canonical_value`]
17640/// pin holds byte-verbatim). The chart-schema per-dep entry's
17641/// `version:` value pins the SemVer-range constraint Helm's per-dep
17642/// resolver matches against the target dep's Chart.yaml `version:`
17643/// scalar at `helm dependency build` / `helm dependency update` time.
17644/// A drift on this per-dep sub-key would surface as one of two silent
17645/// failure modes at chart-vendor time far from the drift site: Helm's
17646/// per-dep chart-schema parser silently drops the version-constraint
17647/// scalar from the parsed dep-entry (the per-dep resolver falls back
17648/// to the wildcard `*` shape and vendors whatever chart-version the
17649/// upstream registry currently advertises, silently promoting a chart
17650/// upgrade the operator never authored), or a subsequent
17651/// `#[serde(rename_all)]` addition rebrands the key to Helm's
17652/// unrecognized shape and the per-dep entry silently vanishes from the
17653/// parsed dep-list. Peer to [`HELM_CHART_DEPENDENCY_KEY_NAME`] /
17654/// [`HELM_CHART_DEPENDENCY_KEY_REPOSITORY`] /
17655/// [`HELM_CHART_DEPENDENCY_KEY_ALIAS`] on the sibling per-dep sub-key
17656/// axes — extends the per-entry-sub-key canonical-lift tetrad at the
17657/// substrate. See [`HELM_CHART_DEPENDENCY_KEY_NAME`] for the shared
17658/// per-entry-sub-mapping lift rationale.
17659///
17660/// [ch]: ../../caixa_helm/index.html
17661pub const HELM_CHART_DEPENDENCY_KEY_VERSION: &str = "version";
17662
17663/// Canonical Helm 3 `Chart.yaml` per-`dependencies[]`-entry sub-mapping
17664/// YAML axis-key naming the per-dep chart-registry URL field — the
17665/// load-bearing serde field-name at [`caixa-helm`][ch]'s
17666/// `ChartDependency` struct's `repository` field. The chart-schema
17667/// per-dep entry's `repository:` value pins the Helm-registry URL
17668/// (`file://…`, `https://…`, `oci://…`) Helm's per-dep resolver
17669/// consults at `helm dependency build` time to fetch the per-dep
17670/// chart bytes. At the caixa-helm substrate the default value is the
17671/// canonical [`caixa_helm::DEFAULT_LIBRARY_REPO`] pointing at the
17672/// helmworks file:// path; the future per-edition library-chart
17673/// re-emission for the OCI registry (once `pleme-io/helmworks/charts`
17674/// lands as an OCI-registry-backed chart-source) reaches this axis
17675/// through a paired scalar-value lift on the per-dep repo axis. A
17676/// drift on this per-dep sub-key would surface as one of two silent
17677/// failure modes at chart-vendor time far from the drift site: Helm's
17678/// per-dep resolver silently drops the repository scalar from the
17679/// parsed dep-entry (the per-dep resolver falls back to the "no
17680/// repository set" shape and refuses to vendor the dep with
17681/// `no repository defined`), or the per-dep chart-schema parser
17682/// silently absorbs a rename drift via `#[serde(default)]`
17683/// fall-through at the struct-side and the per-dep repo axis lands
17684/// under Rust's `""` default — Helm rejects the empty URL at
17685/// `helm dependency build` time. Peer to
17686/// [`HELM_CHART_DEPENDENCY_KEY_NAME`] /
17687/// [`HELM_CHART_DEPENDENCY_KEY_VERSION`] /
17688/// [`HELM_CHART_DEPENDENCY_KEY_ALIAS`] on the sibling per-dep sub-key
17689/// axes. See [`HELM_CHART_DEPENDENCY_KEY_NAME`] for the shared
17690/// per-entry-sub-mapping lift rationale.
17691///
17692/// [ch]: ../../caixa_helm/index.html
17693pub const HELM_CHART_DEPENDENCY_KEY_REPOSITORY: &str = "repository";
17694
17695/// Canonical Helm 3 `Chart.yaml` per-`dependencies[]`-entry sub-mapping
17696/// YAML axis-key naming the per-dep chart-alias override field — the
17697/// load-bearing serde field-name at [`caixa-helm`][ch]'s
17698/// `ChartDependency` struct's `alias` field. The chart-schema per-dep
17699/// entry's `alias:` value, when set, overrides the per-dep values
17700/// wrap-key (Helm's per-dep alias convention scopes the per-dep values
17701/// sub-block under `alias:` when set, and under the sibling
17702/// [`HELM_CHART_DEPENDENCY_KEY_NAME`] `name:` value otherwise); the
17703/// caixa-helm substrate today emits the axis as `None` at every
17704/// rendered `lareira-<nome>` chart's `dependencies[0].alias:` (the
17705/// `#[serde(default, skip_serializing_if = "Option::is_none")]`
17706/// attribute on the `alias` field elides the axis entirely from the
17707/// emitted YAML when unset), so the values wrap-key defaults to the
17708/// per-dep `name:` value — but the axis-key remains part of the
17709/// substrate-side chart-schema-per-dep-entry contract for the future
17710/// per-Aplicacao library chart's per-Servico per-dep aliasing
17711/// [`HELM_CHART_TYPE_LIBRARY`] docstring names as a trajectory item.
17712/// A drift on this per-dep sub-key (a future refactor that renamed
17713/// the `ChartDependency::alias` Rust field, or added a
17714/// `#[serde(rename_all = "camelCase")]` attribute that silently
17715/// activates on a future field addition) would rebrand the wire key
17716/// silently — Helm's per-dep alias-convention router would silently
17717/// drop the alias from the parsed dep-entry (the per-dep values wrap-
17718/// key falls back to the sibling `name:` value, and every per-cluster
17719/// per-Servico per-dep values override the operator authored under
17720/// the alias-key silently routes nowhere at `helm template` time). Peer
17721/// to [`HELM_CHART_DEPENDENCY_KEY_NAME`] /
17722/// [`HELM_CHART_DEPENDENCY_KEY_VERSION`] /
17723/// [`HELM_CHART_DEPENDENCY_KEY_REPOSITORY`] on the sibling per-dep
17724/// sub-key axes — completes the per-`dependencies[]`-entry YAML
17725/// axis-key canonical-pin tetrad. See [`HELM_CHART_DEPENDENCY_KEY_NAME`]
17726/// for the shared per-entry-sub-mapping lift rationale.
17727///
17728/// [ch]: ../../caixa_helm/index.html
17729pub const HELM_CHART_DEPENDENCY_KEY_ALIAS: &str = "alias";
17730
17731/// Canonical Helm 3 per-chart-directory metadata-file filename every
17732/// rendered `lareira-<nome>` chart carries at its top-level directory —
17733/// the fixed filename Helm's chart-schema parser (`helm dependency
17734/// build`, `helm lint`, `helm template`, `helm install`) looks up by
17735/// name at the chart-directory root to locate the per-chart
17736/// [`HELM_CHART_API_VERSION`] + [`HELM_CHART_TYPE_APPLICATION`] +
17737/// name/version/dependencies scalars each `lareira-<nome>` chart
17738/// declares (see [chart-yaml-desc]). The single source of truth every
17739/// consumer that names the metadata file — the sole caixa-helm
17740/// production emit site the prior inline `"Chart.yaml"` literal sat at
17741/// ([`caixa-helm`][ch]'s [`render_chart_for_servico`][rcs] `ChartDir`
17742/// assembly's per-file `path` axis, one of the three canonical
17743/// `lareira-<nome>` chart-directory files the renderer emits as a
17744/// bundle) plus every test-side round-trip navigator that reaches into
17745/// the rendered `ChartDir` by the metadata filename (six sites across
17746/// [`caixa-helm`][ch]'s per-chart-metadata-field sweep tests +
17747/// [`ChartDir::write_to`] post-write existence pin) — reaches for the
17748/// same `&'static str` by construction.
17749///
17750/// Until this lift landed the filename `"Chart.yaml"` lived as seven
17751/// verbatim inline literals (one production `PathBuf::from("Chart.yaml")`
17752/// at the `ChartDir` files-vec construction site + six test-side
17753/// `PathBuf::from("Chart.yaml")` / `chart_root.join("Chart.yaml")` /
17754/// `names.contains(&"Chart.yaml".to_string())` fixture navigators).
17755/// A drift on the emit side (a `"chart.yaml"` / `"chart.YAML"` /
17756/// `"Chart.yml"` / `"chart.yaml.tmpl"` typo, or an accidental collapse
17757/// onto Helm 2's sibling per-chart-metadata-filename axis, or a
17758/// per-fork `Chartfile.yaml` rebrand any per-edition packaging
17759/// substrate might introduce) at any one site would surface as one of
17760/// two silent failure modes at chart-consumption time:
17761///
17762/// - Helm's chart-schema parser refuses to open the rendered chart-
17763/// directory as a chart at all — `helm lint` / `helm dependency
17764/// build` fails with "Error: Chart.yaml file is missing" far from
17765/// the emit-drift commit's source, and the per-Servico release
17766/// cycle drops with no field naming the metadata-filename-drift
17767/// root cause (the operator sees "the chart isn't being recognized"
17768/// with no canonical anchor to compare the rendered filename
17769/// against);
17770/// - the rendered chart's `ChartFile` collection lists a file at the
17771/// emit-side drifted name (e.g. `"chart.yaml"`) while the sibling
17772/// [`caixa-flux`][cf] `Kustomization` bundle-path emitter's per-
17773/// chart reference (a future per-cluster snapshot bundle that
17774/// re-lists the chart-dir contents by filename) continues to look
17775/// under the canonical `"Chart.yaml"` — the two-crate pair silently
17776/// goes out of sync, with the flux bundle's chart-directory
17777/// resolver returning `None` for the metadata file at cluster-side
17778/// `feira app deploy` time.
17779///
17780/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
17781/// "every recurring shape becomes a generator before it becomes a
17782/// pattern; every pattern becomes a library before it becomes
17783/// duplicated code. The duplication budget is zero.") promotes the
17784/// filename to a typed substrate-side `&'static str` on the same
17785/// trajectory the peer [`HELM_CHART_API_VERSION`] /
17786/// [`HELM_CHART_TYPE_APPLICATION`] / [`DEFAULT_LIBRARY_NAME`] /
17787/// [`LAREIRA_CHART_NAME_PREFIX`] lifts established on the sibling
17788/// canonical-Helm-load-bearing-string axes — pivots the discipline
17789/// from the per-Chart.yaml top-level *body* axes (`apiVersion`,
17790/// `type`) onto the sibling per-chart-directory *filename* axis every
17791/// rendered chart directory carries as the fixed lookup name Helm's
17792/// chart-schema parser consults at chart-open time. Peer to the
17793/// canonical-Helm-chart-schema-axis lifts on the sibling per-Chart.yaml
17794/// body surfaces — completes the per-`lareira-<nome>`-chart-directory
17795/// `(filename, apiVersion, type)` canonical-scalar-axis re-export triple
17796/// every rendered chart declares at its top-level metadata file.
17797///
17798/// [chart-yaml-desc]: https://helm.sh/docs/topics/charts/#the-chartyaml-file
17799/// [ch]: ../../caixa_helm/index.html
17800/// [cf]: ../../caixa_flux/index.html
17801/// [rcs]: ../../caixa_helm/fn.render_chart_for_servico.html
17802pub const HELM_CHART_YAML_FILENAME: &str = "Chart.yaml";
17803
17804/// Canonical Helm 3 per-chart-directory values-file filename every
17805/// rendered `lareira-<nome>` chart carries at its top-level directory —
17806/// the fixed filename Helm's chart-schema parser (`helm dependency
17807/// build`, `helm lint`, `helm template`, `helm install`) looks up by
17808/// name at the chart-directory root to locate the per-chart
17809/// [`DEFAULT_LIBRARY_NAME`]-wrapped values block that
17810/// [`HELM_VALUES_KEY_ENABLED`] toggles (see [values-yaml-desc]). The
17811/// single source of truth every consumer that names the values file —
17812/// the sole caixa-helm production emit site the prior inline
17813/// `"values.yaml"` literal sat at ([`caixa-helm`][ch]'s
17814/// [`render_chart_for_servico`][rcs] `ChartDir` assembly's per-file
17815/// `path` axis, the second of the three canonical `lareira-<nome>`
17816/// chart-directory files the renderer emits as a bundle, sibling to
17817/// the metadata-file [`HELM_CHART_YAML_FILENAME`] axis) plus every
17818/// test-side round-trip navigator that reaches into the rendered
17819/// `ChartDir` by the values filename (eleven sites across
17820/// [`caixa-helm`][ch]'s per-chart-values-field sweep tests +
17821/// [`ChartDir::write_to`] post-write existence pin) — reaches for the
17822/// same `&'static str` by construction.
17823///
17824/// Until this lift landed the filename `"values.yaml"` lived as twelve
17825/// verbatim inline literals (one production `PathBuf::from("values.yaml")`
17826/// at the `ChartDir` files-vec construction site + eleven test-side
17827/// `PathBuf::from("values.yaml")` / `chart_root.join("values.yaml")` /
17828/// `names.contains(&"values.yaml".to_string())` fixture navigators).
17829/// A drift on the emit side (a `"Values.yaml"` / `"values.YAML"` /
17830/// `"values.yml"` / `"values.yaml.tmpl"` typo, or an accidental collapse
17831/// onto Helm 2's sibling per-chart-values-filename axis, or a per-fork
17832/// `defaults.yaml` rebrand any per-edition packaging substrate might
17833/// introduce) at any one site would surface as one of two silent
17834/// failure modes at chart-consumption time:
17835///
17836/// - Helm's per-chart values-loader silently falls back to the empty
17837/// values block — `helm template` / `helm install` emits the
17838/// `pleme-computeunit` library chart under its admission-time
17839/// defaults (`enabled: false`, no per-`:limits` / `:behavior` /
17840/// `:upgrade-from` M2 overlay), the workload silently comes up
17841/// disabled or without any per-Servico M2 overlay applied, and
17842/// the per-Servico release cycle drops with no field naming the
17843/// values-filename-drift root cause (the operator sees "the
17844/// Servico isn't doing what we configured it to do" with no
17845/// canonical anchor to compare the rendered filename against);
17846/// - the rendered chart's `ChartFile` collection lists a file at the
17847/// emit-side drifted name (e.g. `"Values.yaml"`) while the sibling
17848/// [`caixa-flux`][cf] `Kustomization` bundle-path emitter's per-
17849/// chart reference (a future per-cluster snapshot bundle that
17850/// re-lists the chart-dir contents by filename to route per-cluster
17851/// values overlays through the canonical values file) continues to
17852/// look under the canonical `"values.yaml"` — the two-crate pair
17853/// silently goes out of sync, with the flux bundle's chart-directory
17854/// resolver returning `None` for the values file at cluster-side
17855/// `feira app deploy` time, and every per-cluster overlay the
17856/// bundle path threads through silently drops.
17857///
17858/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
17859/// "every recurring shape becomes a generator before it becomes a
17860/// pattern; every pattern becomes a library before it becomes
17861/// duplicated code. The duplication budget is zero.") promotes the
17862/// filename to a typed substrate-side `&'static str` on the same
17863/// trajectory the peer [`HELM_CHART_YAML_FILENAME`] (c2c99b0) /
17864/// [`HELM_CHART_API_VERSION`] / [`HELM_CHART_TYPE_APPLICATION`] /
17865/// [`HELM_VALUES_KEY_ENABLED`] / [`DEFAULT_LIBRARY_NAME`] /
17866/// [`LAREIRA_CHART_NAME_PREFIX`] lifts established on the sibling
17867/// canonical-Helm-load-bearing-string axes — pivots the discipline
17868/// from the metadata-file half of the `(Chart.yaml, values.yaml)`
17869/// canonical per-chart-directory filename pair onto the values-file
17870/// half, completing the per-`lareira-<nome>`-chart-directory
17871/// canonical-scalar-axis re-export triple every rendered chart declares
17872/// as its `ChartDir::files` entries (`{Chart.yaml, values.yaml,
17873/// README.md}` — the two schema-load-bearing filenames now share the
17874/// same substrate-side single-source discipline).
17875///
17876/// [values-yaml-desc]: https://helm.sh/docs/chart_template_guide/values_files/
17877/// [ch]: ../../caixa_helm/index.html
17878/// [cf]: ../../caixa_flux/index.html
17879/// [rcs]: ../../caixa_helm/fn.render_chart_for_servico.html
17880pub const HELM_VALUES_YAML_FILENAME: &str = "values.yaml";
17881
17882/// Canonical `lareira-<nome>` chart-directory human-facing readme filename
17883/// every rendered chart carries at its top-level directory — the fixed
17884/// filename the `caixa-helm` renderer emits alongside the two schema-load-
17885/// bearing [`HELM_CHART_YAML_FILENAME`] + [`HELM_VALUES_YAML_FILENAME`]
17886/// files as the third leg of the canonical `{Chart.yaml, values.yaml,
17887/// README.md}` per-`lareira-<nome>` chart-directory `ChartFile` triple the
17888/// peer [`HELM_CHART_YAML_FILENAME`] docstring explicitly acknowledges is
17889/// the one axis where the substrate-side single-source discipline had not
17890/// yet landed at the third file. The single source of truth every
17891/// consumer that names the readme file — the sole caixa-helm production
17892/// emit site the prior inline `"README.md"` literal sat at
17893/// ([`caixa-helm`][ch]'s [`render_chart_for_servico`][rcs] `ChartDir`
17894/// assembly's per-file `path` axis, the third of the three canonical
17895/// `lareira-<nome>` chart-directory files the renderer emits as a bundle,
17896/// sibling to the metadata-file [`HELM_CHART_YAML_FILENAME`] +
17897/// values-file [`HELM_VALUES_YAML_FILENAME`] axes) plus every test-side
17898/// round-trip navigator that reaches into the rendered `ChartDir` by the
17899/// readme filename (two sites: the `renders_three_files` files-vec-
17900/// membership pin + the `ChartDir::write_to` post-write existence pin) —
17901/// reaches for the same `&'static str` by construction.
17902///
17903/// Until this lift landed the filename `"README.md"` lived as three
17904/// verbatim inline literals (one production `ChartFile::new("README.md",
17905/// …)` at the `ChartDir` files-vec construction site + two test-side
17906/// `names.contains(&"README.md".to_string())` / `chart_root.join("README.md")`
17907/// fixture navigators). A drift on the emit side (a `"readme.md"` /
17908/// `"Readme.md"` / `"README"` / `"README.MD"` typo, or an accidental
17909/// collapse onto the sibling per-workspace `readme.txt` axis any
17910/// per-edition packaging substrate might introduce) at any one site would
17911/// surface as one of two silent failure modes at chart-consumption time:
17912///
17913/// - GitHub / Artifact Hub / any downstream per-chart README-surfacing
17914/// UI silently falls back to "no README available" — the chart lists
17915/// with no per-chart elevator pitch or install instructions far from
17916/// the drift commit's source, and the operator sees a chart in the
17917/// hub without the canonical `## Install` block the emitter wrote,
17918/// with no field naming the readme-filename-drift root cause;
17919/// - the rendered chart's `ChartFile` collection lists a file at the
17920/// emit-side drifted name (e.g. `"readme.md"`) while the sibling
17921/// [`caixa-flux`][cf] `Kustomization` bundle-path emitter's future
17922/// per-chart-directory resolver — a per-cluster snapshot bundle that
17923/// re-lists the chart-dir contents by filename to surface the
17924/// canonical README to per-cluster tooling — continues to look under
17925/// the canonical `"README.md"` — the two-crate pair silently goes out
17926/// of sync, with the flux bundle's chart-directory resolver returning
17927/// `None` for the readme file at cluster-side `feira app deploy`
17928/// time, and every downstream README-consuming path silently drops.
17929///
17930/// The PRIME DIRECTIVE duplication-budget rule (THEORY.md §I.3.5,
17931/// "every recurring shape becomes a generator before it becomes a
17932/// pattern; every pattern becomes a library before it becomes
17933/// duplicated code. The duplication budget is zero.") promotes the
17934/// filename to a typed substrate-side `&'static str` on the same
17935/// trajectory the peer [`HELM_CHART_YAML_FILENAME`] (c2c99b0) /
17936/// [`HELM_VALUES_YAML_FILENAME`] (9a980ba) lifts established on the
17937/// sibling canonical-Helm-per-chart-directory-filename axes — pivots the
17938/// discipline from the two schema-load-bearing filename halves onto the
17939/// human-facing readme-file half, completing the per-`lareira-<nome>`-
17940/// chart-directory `(Chart.yaml, values.yaml, README.md)` canonical-per-
17941/// chart-directory-filename-axis re-export triple every rendered chart
17942/// declares as its three `ChartDir::files` entries — the third file the
17943/// peer [`HELM_VALUES_YAML_FILENAME`] docstring explicitly names as the
17944/// missing leg of the triple at its "completing the per-`lareira-<nome>`-
17945/// chart-directory canonical-scalar-axis re-export triple every rendered
17946/// chart declares as its `ChartDir::files` entries (`{Chart.yaml,
17947/// values.yaml, README.md}` — the two schema-load-bearing filenames now
17948/// share the same substrate-side single-source discipline)" close.
17949///
17950/// [ch]: ../../caixa_helm/index.html
17951/// [cf]: ../../caixa_flux/index.html
17952/// [rcs]: ../../caixa_helm/fn.render_chart_for_servico.html
17953pub const HELM_CHART_README_FILENAME: &str = "README.md";
17954
17955/// Canonical `pleme-computeunit` library-chart values-block enable-toggle
17956/// key — the `enabled: <bool>` axis every `lareira-<nome>` chart's values
17957/// block carries under its [`DEFAULT_LIBRARY_NAME`] wrap key, and every
17958/// [`caixa-flux`][cf]-rendered `HelmRelease` `spec.values.<library>.enabled`
17959/// per-cluster override targets. The single source of truth all four
17960/// downstream consumers reach for:
17961///
17962/// - [`caixa-helm`][ch]'s [`build_values_yaml`][bvy] inserts
17963/// `enabled: <opts.enabled_default>` under the values wrap key
17964/// (caixa-helm/src/lib.rs:389) — the rendered `values.yaml`'s
17965/// default-off toggle a cluster operator flips on per environment;
17966/// - [`caixa-flux`][cf]'s [`cluster_bundle`][cb] emits
17967/// `<library>: { enabled: true }` under the `HelmRelease`
17968/// `spec.values` block (caixa-flux/src/lib.rs:844) — the per-cluster
17969/// override the bundle path threads through so a Servico deployed via
17970/// the bundle path lands enabled at the target cluster;
17971/// - the peer test-fixture navigators in both crates
17972/// (`caixa-helm/src/lib.rs:566, 616` sweeping the default-off arm +
17973/// `caixa-flux/src/lib.rs:1889` sweeping the bundle-path enabled-true
17974/// override arm) resolve the same `&'static str` when parsing back the
17975/// rendered `values.yaml` / `helmrelease.yaml` to pin the round-trip;
17976/// - every future per-Servico renderer the absorption-roadmap
17977/// acknowledges (the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
17978/// materializer's per-member values fan-out, a future per-cluster
17979/// values overlay emitter, a future per-edition `<lib>-computeunit`
17980/// values-block schema fork) that reads or emits the same values-
17981/// block-toggle key.
17982///
17983/// Until this lift landed the value `"enabled"` lived as two production-
17984/// code call sites (caixa-helm's `build_values_yaml` insert +
17985/// caixa-flux's `cluster_bundle` `helmrelease.yaml` format-string) plus
17986/// three test-fixture-navigation sites (caixa-helm's default-off round-
17987/// trip + caixa-flux's bundle-path round-trip). A future rebrand of the
17988/// library-chart's per-values enable-toggle axis (the `pleme-computeunit`
17989/// library chart moving to a `chart.enabled` / `spec.enabled` scoping to
17990/// leave room for a sibling `component.enabled` sub-chart toggle, the
17991/// substrate forking the library chart to `<edition>-computeunit` with a
17992/// migrated toggle key, or Helm's own per-values-block convention drift)
17993/// without a coordinated edit on both consumers would silently emit a
17994/// chart whose default-off toggle lands in the values block under one key
17995/// while the cluster-side override lands under another — Helm's per-values
17996/// merge treats them as sibling scalars, the enable-toggle the library
17997/// chart's own template consults never sees the flip, and the workload
17998/// silently comes up with the library chart's admission-time defaults
17999/// (disabled, or the sibling schema fork's own default) instead of the
18000/// per-cluster override the operator set. The apply-time symptom (the
18001/// workload is registered but not running, or is running without the
18002/// per-cluster overlay) surfaces only as "the service isn't doing what we
18003/// configured it to do" far from the rebrand commit, with no field
18004/// naming the enable-toggle-drift root cause. Lifting the literal to
18005/// a shared constant closes the drift footgun structurally — both
18006/// production emit sites and every test-side round-trip navigator now
18007/// consult the same `&'static str`, so any rebrand reaches every consumer
18008/// by construction.
18009///
18010/// Same "the typed constant lives in one place" discipline the peer
18011/// [`DEFAULT_LIBRARY_NAME`] (41438dc) / [`HELM_CHART_API_VERSION`]
18012/// (7e4bdb8) / [`KUBE_KEY_SPEC`] lifts apply on the sibling canonical-
18013/// Helm-load-bearing-string / canonical-Helm-chart-schema-axis /
18014/// canonical-K8s-CR-body-axis surfaces — extends the discipline from
18015/// the Chart.yaml schema axes and the K8s CR body axes onto the Helm
18016/// values-block schema axis nested inside every `lareira-<nome>` chart
18017/// under its [`DEFAULT_LIBRARY_NAME`] wrap key.
18018///
18019/// [ch]: ../../caixa_helm/index.html
18020/// [cf]: ../../caixa_flux/index.html
18021/// [bvy]: ../../caixa_helm/fn.build_values_yaml.html
18022/// [cb]: ../../caixa_flux/fn.cluster_bundle.html
18023pub const HELM_VALUES_KEY_ENABLED: &str = "enabled";
18024
18025/// Canonical Helm chart-name prefix for every per-Servico chart the
18026/// substrate emits — the `"lareira-"` segment of the well-known
18027/// `lareira-<nome>` shape every caixa Servico renderer prepends to a
18028/// caixa's `:nome` to derive its [`Chart.yaml` `name:`][chart-yaml] field,
18029/// its OCI artifact reference (`oci://<registry>/lareira-<nome>`), and
18030/// the resulting cluster-side `HelmRelease` `release_name`. The single
18031/// source of truth all three downstream Servico renderers consult —
18032/// [`caixa-helm`][cf]'s `render_chart_for_servico` chart-dir name
18033/// (caixa-helm/src/lib.rs:207), [`caixa-flux`][cm]'s `cluster_bundle`
18034/// `HelmRelease` `chart:` field (caixa-flux/src/lib.rs:329), and
18035/// [`caixa-tatara`][ct]'s `process_for_aplicacao` `release_name` +
18036/// `derive_chart_ref` OCI ref (caixa-tatara/src/lib.rs:124,182) — so a
18037/// future per-chart-name-prefix rebrand (e.g. moving to `forno-` once
18038/// `lareira-` outlives its scoping intent, or any segment-namespace
18039/// migration the chart-publishing pipeline requires) is a one-line edit
18040/// here, not a coordinated rewrite across every renderer crate's chart-
18041/// name-derivation site.
18042///
18043/// Until this lift landed all three renderers carried inline
18044/// `format!("lareira-{}", caixa.nome)` / `format!("lareira-{name}")` /
18045/// `format!("oci://{}/lareira-{}", registry, caixa.nome.as_str())`
18046/// expressions — three verbatim copies of the same substrate-wide
18047/// naming convention. The PRIME DIRECTIVE duplication budget of zero
18048/// (THEORY.md §I.3.5) lands the lift here at the third occurrence: a
18049/// future rebrand on any one site without a coordinated edit on the
18050/// others would have silently published a chart at one name, registered
18051/// its OCI ref at a second, and resolved the `HelmRelease` at a third —
18052/// the cluster's apply would surface as a `chart pull failed: image not
18053/// found` error far from the source rebrand commit, with no field
18054/// naming the prefix-drift root cause.
18055///
18056/// Lifting it to caixa-core's render-constants block alongside the peer
18057/// [`DEFAULT_NAMESPACE`] (a085b26) makes the chart-name-prefix axis
18058/// discipline structural: every renderer that derives a per-Servico
18059/// chart name consults [`lareira_chart_name`], and every future renderer
18060/// (the future per-cluster snapshot bundle emitter, the future M4
18061/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's chart-ref slot,
18062/// the future caixa-otel collector chart name) inherits the same prefix
18063/// by construction, with no opportunity for per-renderer drift. Same
18064/// "the typed constant lives in one place" discipline the
18065/// [`PLEME_LABEL_PREFIX`] / [`DEFAULT_NAMESPACE`] / [`KUBE_KEY_API_VERSION`]
18066/// lifts apply on the peer shared-string axes.
18067///
18068/// [chart-yaml]: https://helm.sh/docs/topics/charts/#the-chartyaml-file
18069/// [cf]: ../../caixa_helm/index.html
18070/// [cm]: ../../caixa_flux/index.html
18071/// [ct]: ../../caixa_tatara/index.html
18072pub const LAREIRA_CHART_NAME_PREFIX: &str = "lareira-";
18073
18074/// Derive the canonical per-Servico Helm chart name from a caixa's
18075/// `:nome` — the substrate-wide `lareira-<nome>` shape every
18076/// per-Servico renderer ([`caixa-helm`][cf]'s `render_chart_for_servico`
18077/// chart-dir name, [`caixa-flux`][cm]'s `cluster_bundle` `HelmRelease`
18078/// `chart:` field, [`caixa-tatara`][ct]'s `process_for_aplicacao`
18079/// `release_name`, and the `oci://<registry>/lareira-<nome>` OCI ref)
18080/// composes by prepending [`LAREIRA_CHART_NAME_PREFIX`].
18081///
18082/// Single source of truth for the prefix-application: every consumer
18083/// reaches for this helper rather than re-deriving the `format!(…)`
18084/// shape inline, so a future change to the prefix axis (the lift's
18085/// raison d'être) is one edit here, not a coordinated sweep across
18086/// every renderer.
18087///
18088/// The input `nome` is the caixa's typed `:nome` field, already
18089/// DNS-1123-label-validated at [`Caixa::validate_nome`] (6c992f8) —
18090/// every value reaching this helper is structurally a valid Helm
18091/// chart-name segment. The prepended prefix is a fixed lowercase ASCII
18092/// alphanumeric + hyphen string, so the concatenation is structurally a
18093/// valid Helm chart name by construction (Helm's chart-name accepted
18094/// set is the DNS-1123 label rule, and DNS-1123 labels concatenate with
18095/// the prefix-and-hyphen separator into valid DNS-1123 labels as long
18096/// as the joint length stays ≤ 63 bytes; the M4 admission webhook will
18097/// pin the joint-length invariant when it lands).
18098///
18099/// [cf]: ../../caixa_helm/index.html
18100/// [cm]: ../../caixa_flux/index.html
18101/// [ct]: ../../caixa_tatara/index.html
18102#[must_use]
18103pub fn lareira_chart_name(nome: &str) -> String {
18104 format!("{LAREIRA_CHART_NAME_PREFIX}{nome}")
18105}
18106
18107/// Canonical substrate-fixed Chart.yaml `keywords:` entries every
18108/// rendered `lareira-<nome>` Helm chart carries — the ordered
18109/// (`BTreeSet`-canonical, ascii-alphabetical) list of registry-search
18110/// tags `caixa-helm`'s `build_chart_yaml` unions in on top of the
18111/// caixa author's own `:etiquetas` before folding the joint set into a
18112/// `BTreeSet<String>` for the emitted `Chart.yaml`. Every entry —
18113/// `"caixa-servico"` (the substrate-wide per-`:kind Servico` marker
18114/// axis), `"lareira"` (the [`LAREIRA_CHART_NAME_PREFIX`] chart-family
18115/// tag), `"tatara-lisp"` (the tatara-lisp source-language marker), and
18116/// `"wasm"` (the runtime execution-format marker) — is a load-bearing
18117/// discovery axis for the Artifact Hub keyword-search index and the
18118/// future caixa-registry keyword axis, so a drift between the
18119/// production emit at `caixa-helm::build_chart_yaml` and the two
18120/// substrate-side positive-set sweep tests
18121/// ([`crate::manifest::tests::validate_etiquetas_accepts_canonical_shaped_forms`]
18122/// and this crate's own `chart_keyword_shape_accepts_canonical_forms`)
18123/// would silently cause every rendered chart to miss the search-index
18124/// axis the substrate-fixed tag encodes — a chart published without
18125/// the `"caixa-servico"` tag would silently drop off the
18126/// `helm search hub caixa-servico` results the substrate's chart
18127/// discovery pipeline promises. Two production-side call sites
18128/// (this crate's `is_chart_keyword_shape` docstring narrates the
18129/// four canonical tags verbatim + [`caixa-helm`][ch]'s `build_chart_yaml`
18130/// unions them into the emitted `keywords:` sequence) and two
18131/// test-side positive-sweep sites this array anchors under one source
18132/// of truth.
18133///
18134/// The array is `BTreeSet`-canonical-ordered (ascii-alphabetical: the
18135/// same order the emitted `Chart.yaml` `keywords:` sequence lists them
18136/// after `build_chart_yaml`'s intermediate `BTreeSet<String>` fold), so
18137/// a future substrate-fixed keyword addition (an `"opentelemetry"`
18138/// entry once the caixa-otel collector-pipeline chart lands, a
18139/// `"lunatic"` entry once the wasm-process-runtime marker lands, a
18140/// `"gen_server"` entry once the OTP-shape callback marker lands per
18141/// the [`crate::behavior`] surface) lands at one edit point rather
18142/// than a coordinated four-file sweep across the production emit
18143/// site, the two test-side sweeps, and this docstring. Same
18144/// "one canonical typed array lives in one place" discipline as
18145/// the peer [`crate::aplicacao::WIT_HTTP_SHAPE_PREFIXES`] /
18146/// [`crate::aplicacao::WIT_PUBSUB_SHAPE_PREFIXES`] /
18147/// [`crate::aplicacao::WIT_STORE_SHAPE_PREFIXES`] arm-shape-prefix
18148/// arrays apply on the sibling `:contratos :wit` dispatch-shape axis.
18149///
18150/// Every entry structurally satisfies [`is_chart_keyword_shape`] (the
18151/// substrate's per-`Chart.yaml` `keywords:` entry validation
18152/// predicate) — the substrate-side pin
18153/// `lareira_chart_keywords_each_entry_passes_is_chart_keyword_shape`
18154/// enforces the invariant so a future addition that happens to break
18155/// the shape rule (a leading digit, an uppercase letter, a byte over
18156/// the [`CHART_KEYWORD_MAX_LEN`] cap) fails at caixa-core build time
18157/// rather than surfacing at chart-lint time downstream.
18158///
18159/// [ch]: ../../caixa_helm/index.html
18160pub const LAREIRA_CHART_KEYWORDS: &[&str] = &["caixa-servico", "lareira", "tatara-lisp", "wasm"];
18161
18162/// Canonical OCI URL scheme prefix — the `"oci://"` byte-string every
18163/// substrate-side renderer that composes an OCI artifact reference for a
18164/// Helm chart prepends. The Helm 3 OCI storage protocol (Helm 3.8+) and
18165/// the `FluxCD` `HelmRepository` `type: oci` source both key off this
18166/// literal — `helm pull` / `helm install` / `helm registry login` /
18167/// `FluxCD`'s source-controller all reject any other scheme on the OCI
18168/// path — so a byte-shape drift on this prefix silently splits the
18169/// substrate's published chart references from the cluster-side
18170/// resolvers that consume them at `helm registry` / `FluxCD` reconcile
18171/// time far from the source renderer.
18172///
18173/// The single source of truth every downstream renderer that composes
18174/// an `oci://<registry>/<chart>` reference reaches for —
18175/// [`caixa-tatara`][ct]'s `derive_chart_ref` OCI ref
18176/// (caixa-tatara/src/lib.rs:202), and every future OCI-ref emitter
18177/// (the future M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
18178/// `chart_ref` slot on the tatara `Process` intent, the future
18179/// per-cluster snapshot bundle's OCI chart references, the future
18180/// caixa-otel collector chart's OCI publish shape) inherits the prefix
18181/// through this const by construction. Same "one canonical scheme /
18182/// prefix / separator lives in one place" discipline the peer
18183/// [`LAREIRA_CHART_NAME_PREFIX`] (f7320d7), [`CONTRATO_EDGE_LABEL_SEPARATOR`]
18184/// (6d9b04e), [`PLEME_LABEL_PREFIX`] (b473c00 / 9d9813f) lifts apply
18185/// on the sibling canonical-load-bearing-substrate-string axes.
18186///
18187/// [ct]: ../../caixa_tatara/index.html
18188pub const OCI_SCHEME_PREFIX: &str = "oci://";
18189
18190/// Compose the canonical OCI artifact reference for a per-Servico Helm
18191/// chart — the `oci://<registry>/lareira-<nome>` shape every renderer
18192/// that materializes a chart-publish target (or a cluster-side chart
18193/// resolver keyed off one) composes by prepending
18194/// [`OCI_SCHEME_PREFIX`], joining the caller-supplied registry, and
18195/// appending the per-Servico chart name derived through the canonical
18196/// [`lareira_chart_name`] helper.
18197///
18198/// Single source of truth for the two-axis composition: every consumer
18199/// reaches for this helper rather than re-deriving the
18200/// `format!("oci://{}/lareira-{}", …)` shape inline, so a future change
18201/// to either input axis (the [`OCI_SCHEME_PREFIX`] rebrand once Helm /
18202/// `FluxCD` introduce a new registry protocol, the
18203/// [`LAREIRA_CHART_NAME_PREFIX`] rebrand once `lareira-` outlives its
18204/// scoping intent) is one edit here, not a coordinated sweep across
18205/// every renderer crate's OCI-ref composition site.
18206///
18207/// The rendered reference is the substrate's contract with the
18208/// chart-publishing pipeline (`helm registry login` +
18209/// `helm push chart.tgz oci://<registry>/lareira-<nome>`), the
18210/// cluster-side `FluxCD` `HelmRelease` `chart:` field (which Flux's
18211/// source-controller resolves through the same OCI ref), and the
18212/// tatara `Process` CR's `intent.aplicacao.chart_ref` slot the
18213/// reconciler feeds into `helm install`. Every consumer keys off the
18214/// same byte-shape by construction.
18215///
18216/// [ct]: ../../caixa_tatara/index.html
18217#[must_use]
18218pub fn oci_chart_ref(registry: &str, nome: &str) -> String {
18219 let chart = lareira_chart_name(nome);
18220 format!("{OCI_SCHEME_PREFIX}{registry}/{chart}")
18221}
18222
18223/// The `:nome`-side budget the [`lareira_chart_name`] composition
18224/// imposes on every caixa `:nome` reaching a renderer that derives a
18225/// `lareira-<nome>` artifact (`caixa-helm`'s `ChartDir.name` +
18226/// `Chart.yaml` `name:`, `caixa-flux`'s `cluster_bundle` `HelmRelease`
18227/// `chart:` slot, `caixa-tatara`'s `process_for_aplicacao`
18228/// `release_name` + `oci://<registry>/lareira-<nome>` chart ref).
18229///
18230/// The joint length of `lareira-` + `<nome>` must satisfy the K8s
18231/// DNS-1123 label cap ([`DNS_1123_LABEL_MAX_LEN`] = 63) every downstream
18232/// consumer enforces — Helm's `Chart.yaml::name` field (`helm lint`
18233/// rejects at chart-package time per the DNS-1123 rule), the
18234/// `HelmRelease`'s `release_name` field (the Helm operator's tracking
18235/// secret name is derived from `release_name` and is itself a DNS-1123
18236/// label), the rendered chart's K8s object `metadata.name` axes that
18237/// embed the chart name as a prefix. The arithmetic is therefore
18238/// `DNS_1123_LABEL_MAX_LEN - LAREIRA_CHART_NAME_PREFIX.len()` = 63 - 8
18239/// = 55 bytes the caixa's `:nome` may itself occupy.
18240///
18241/// Lifted to a `pub const` so a future change to either axis
18242/// ([`LAREIRA_CHART_NAME_PREFIX`] rebrand, [`DNS_1123_LABEL_MAX_LEN`]
18243/// shift if Helm/K8s ever relax the chart-name rule) re-derives the
18244/// budget mechanically — every per-axis call site
18245/// ([`is_lareira_chart_name_shape`] consults it, the
18246/// `Caixa::validate_nome_chart_name_budget` diagnostic names it
18247/// verbatim) inherits the new value with no coordinated edit.
18248pub const LAREIRA_CHART_NAME_NOME_MAX_LEN: usize =
18249 DNS_1123_LABEL_MAX_LEN - LAREIRA_CHART_NAME_PREFIX.len();
18250
18251/// Predicate: assert that `nome` produces a [`lareira_chart_name`]
18252/// output satisfying the K8s DNS-1123 label rule — the joint-length
18253/// invariant the canonical `lareira_chart_name` helper's doc comment
18254/// (f7320d7) defers to "the M4 admission webhook will pin … when it
18255/// lands". This predicate lands it at the manifest-validate layer
18256/// rather than waiting for the apiserver.
18257///
18258/// Returns the parser-shaped reason on rejection (without wrapping in
18259/// any error variant) — same call-site discipline as the peer
18260/// [`is_dns_1123_label`] predicate. Each per-axis caller wraps the
18261/// returned reason in its own typed `*Error::*Exceeded { … }` variant
18262/// (today: `Caixa::validate_nome_chart_name_budget` → the new
18263/// [`crate::ManifestError::NomeChartNameBudgetExceeded`] arm).
18264///
18265/// The predicate composes via [`lareira_chart_name`] + [`is_dns_1123_label`]
18266/// — the same two primitives every renderer consults — so a future
18267/// rebrand of either axis (`LAREIRA_CHART_NAME_PREFIX`,
18268/// `DNS_1123_LABEL_MAX_LEN`) re-derives the budget mechanically. A
18269/// `:nome` that already passes [`is_dns_1123_label`] (≤63 bytes,
18270/// boundary-anchored, `[a-z0-9-]` only) but whose prefixed chart name
18271/// exceeds the joint cap is what this gate catches — every byte the
18272/// inner DNS-1123 check accepts the prefixed form may still reject.
18273///
18274/// # Errors
18275///
18276/// Returns a parser-shaped reason naming the budget
18277/// ([`LAREIRA_CHART_NAME_NOME_MAX_LEN`]), the offending `:nome`
18278/// length, and the rendered chart name's length — so the diagnostic is
18279/// self-locating and the author can shorten in one edit.
18280pub fn is_lareira_chart_name_shape(nome: &str) -> Result<(), String> {
18281 let chart_name = lareira_chart_name(nome);
18282 if chart_name.len() > DNS_1123_LABEL_MAX_LEN {
18283 return Err(format!(
18284 "produces `{chart_name}` ({chart_len} bytes), which exceeds the \
18285 DNS-1123 label max length of {DNS_1123_LABEL_MAX_LEN} bytes that \
18286 Helm's `Chart.yaml::name` field and every downstream K8s artifact \
18287 derived from the chart name enforce; the per-`:nome` budget is \
18288 {budget} bytes (DNS-1123 cap minus the `{prefix}` prefix), shorten \
18289 `:nome` to ≤ {budget} bytes",
18290 chart_name = chart_name,
18291 chart_len = chart_name.len(),
18292 budget = LAREIRA_CHART_NAME_NOME_MAX_LEN,
18293 prefix = LAREIRA_CHART_NAME_PREFIX,
18294 ));
18295 }
18296 Ok(())
18297}
18298
18299/// Build the canonical Cilium `matchLabels` selector for a single
18300/// pleme-io program **scoped to its Aplicacao** — the safe default
18301/// every per-Aplicacao mesh renderer (caixa-mesh's
18302/// `cilium_network_policies` `fromEndpoints`, future per-edge policy
18303/// emission, Gateway API `backendRefs` filters) should use, since
18304/// two different Aplicacaos can carry programs with the same `:nome`
18305/// in the same cluster (e.g. two `cart` Servicos under different
18306/// applications) and a `LABEL_PROGRAM`-only selector would match
18307/// pods belonging to the wrong Aplicacao.
18308///
18309/// Returned as a [`BTreeMap`] keyed by `&'static str` so iteration is
18310/// alphabetical (THEORY.md §V.2.7 render determinism: the rendered
18311/// YAML's `matchLabels:` block appears in a deterministic order
18312/// independent of source-code declaration order). The two keys
18313/// alphabetize as [`LABEL_APLICACAO`] before [`LABEL_PROGRAM`], the
18314/// same order the renderer's `serde_yaml::Mapping` iteration will
18315/// preserve through to the rendered YAML.
18316#[must_use]
18317pub fn pleme_program_in_aplicacao_selector(
18318 program: &str,
18319 aplicacao: &str,
18320) -> BTreeMap<&'static str, String> {
18321 let mut out = BTreeMap::new();
18322 out.insert(LABEL_APLICACAO, aplicacao.to_string());
18323 out.insert(LABEL_PROGRAM, program.to_string());
18324 out
18325}
18326
18327/// Build the canonical Cilium `matchLabels` selector for a single
18328/// pleme-io program **without** the Aplicacao constraint —
18329/// deliberately broader than [`pleme_program_in_aplicacao_selector`]
18330/// for the cases where matching a program across every Aplicacao that
18331/// hosts it is the *intent* (cluster-wide rate limits, breakglass
18332/// observability, the per-cluster operator identity scope).
18333///
18334/// **Prefer [`pleme_program_in_aplicacao_selector`]** for typed
18335/// per-Aplicacao mesh emission — using `pleme_program_selector` there
18336/// would let a policy unintentionally match a same-named program in
18337/// a different Aplicacao. Both helpers exist so the caller's *intent*
18338/// (Aplicacao-scoped vs. cluster-wide) is named at the call site,
18339/// not buried in inline label-key string literals.
18340#[must_use]
18341pub fn pleme_program_selector(program: &str) -> BTreeMap<&'static str, String> {
18342 let mut out = BTreeMap::new();
18343 out.insert(LABEL_PROGRAM, program.to_string());
18344 out
18345}
18346
18347/// Convert a typed string-valued mapping (e.g. one of the canonical
18348/// [`pleme_program_selector`] / [`pleme_program_in_aplicacao_selector`]
18349/// selectors, or any caller-built `BTreeMap<&'static str, String>`)
18350/// into a [`serde_yaml::Value::Mapping`] with `String → String` shape —
18351/// the surface every Cilium / Gateway / HTTPRoute / ComputeUnit
18352/// `matchLabels` / `metadata.labels` / `selector` field expects.
18353///
18354/// Iteration order is whatever the input iterator yields; pass a
18355/// [`BTreeMap`] for alphabetical determinism (THEORY.md §V.2.7 render
18356/// determinism: rendered YAML key order is independent of source-code
18357/// declaration order). The two pleme-io selector helpers above already
18358/// return `BTreeMap`s for exactly this reason.
18359///
18360/// Lifted from `caixa-mesh`'s prior `yaml_string_mapping` private
18361/// helper to make the same primitive available to every other
18362/// `caixa-<target>` renderer that needs to emit a string→string YAML
18363/// mapping (the future per-Aplicacao Gateway-API filter rules, the
18364/// caixa-otel resource-attribute emitter, the `app-operator`'s typed
18365/// CR materializer, the per-cluster CiliumClusterwideEnvoyConfig
18366/// renderer for `:politicas` defaults). Without the lift each new
18367/// renderer would re-inline the same five-line `for (k, v)` body and
18368/// inherit the same drift footguns.
18369#[must_use]
18370pub fn yaml_string_mapping<K, V, M>(m: M) -> serde_yaml::Value
18371where
18372 M: IntoIterator<Item = (K, V)>,
18373 K: Into<String>,
18374 V: Into<String>,
18375{
18376 let mut out = serde_yaml::Mapping::new();
18377 for (k, v) in m {
18378 out.insert_str_key(&k.into(), serde_yaml::Value::String(v.into()));
18379 }
18380 serde_yaml::Value::Mapping(out)
18381}
18382
18383/// Wrap a typed string-valued label mapping in the canonical K8s
18384/// [`LabelSelector`][k8s-ls] shape — `{matchLabels: <string-string-map>}`
18385/// — and return it as a [`serde_yaml::Value::Mapping`] ready to drop
18386/// directly under any K8s field that takes a label selector
18387/// (Cilium `endpointSelector` / `fromEndpoints[].matchLabels`, Gateway
18388/// API `BackendRef` filters, ComputeUnit `selector`, Service
18389/// `spec.selector`, the future `mesh.pleme.io/v1alpha1/Aplicacao` CR
18390/// `spec.selector`).
18391///
18392/// Lifted from two inline `serde_yaml::Mapping::new() +
18393/// insert(Value::String("matchLabels".into()), yaml_string_mapping(_))`
18394/// blocks in `caixa-mesh::cilium_network_policies` (the destination
18395/// `endpointSelector` and the source `fromEndpoints[0]` selector) so
18396/// the next renderer to land — the per-`:politicas`
18397/// `CiliumClusterwideEnvoyConfig` emitter (MESH-COMPOSITION §III.2 #3),
18398/// the `app-operator`'s typed `mesh.pleme.io/v1alpha1/Aplicacao` CR
18399/// materializer (§III.2 #5), the M4 cross-cluster fan-out's per-cluster
18400/// `Service`/`HTTPRoute backendRefs` selectors, the future `caixa-otel`
18401/// OpenTelemetry-Collector resource-selector pipeline — gets the
18402/// canonical K8s label-selector shape for free with one function call,
18403/// instead of re-inlining the same four-line `Mapping::new() +
18404/// insert("matchLabels", yaml_string_mapping(_))` boilerplate.
18405///
18406/// V0 emits the equality-based selector axis only (`matchLabels`); the
18407/// set-based axis ([`matchExpressions`][k8s-ls]) is deliberately out
18408/// of scope. A future `:contratos` axis whose selector needs
18409/// `matchExpressions` (e.g. `In`, `NotIn`, `Exists`, `DoesNotExist`
18410/// operators against a label key) is a future struct-shaped extension
18411/// of this helper —
18412/// e.g. a richer [`LabelSelector`] view type with `match_labels` +
18413/// `match_expressions` fields — not a per-renderer rewrite of
18414/// every selector emission site.
18415///
18416/// Iteration order is whatever the input iterator yields; pass a
18417/// [`BTreeMap`] for alphabetical determinism (THEORY.md §V.2.7 render
18418/// determinism: rendered YAML key order is independent of source-code
18419/// declaration order). The two pleme-io selector helpers
18420/// ([`pleme_program_selector`] / [`pleme_program_in_aplicacao_selector`])
18421/// already return `BTreeMap`s for exactly this reason, so a
18422/// `label_selector(pleme_program_in_aplicacao_selector(_, _))` call
18423/// renders deterministically end-to-end.
18424///
18425/// [k8s-ls]: https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.31/#labelselector-v1-meta
18426#[must_use]
18427pub fn label_selector<K, V, M>(labels: M) -> serde_yaml::Value
18428where
18429 M: IntoIterator<Item = (K, V)>,
18430 K: Into<String>,
18431 V: Into<String>,
18432{
18433 let mut out = serde_yaml::Mapping::new();
18434 out.insert_str_key(KUBE_KEY_MATCH_LABELS, yaml_string_mapping(labels));
18435 serde_yaml::Value::Mapping(out)
18436}
18437
18438/// Build the canonical K8s-resource skeleton — the
18439/// `apiVersion` + `kind` + `metadata.{name, namespace, labels?}`
18440/// block every cluster artifact emitted by every caixa-side renderer
18441/// carries — and return it as a fresh [`serde_yaml::Mapping`] the
18442/// caller adds its `spec:` (and any other top-level keys) to.
18443///
18444/// `labels` is inserted under `metadata.labels` only when non-empty.
18445/// An empty `labels` map leaves the labels key absent — the K8s API
18446/// server's interpretation of "no labels declared" is "labels key
18447/// missing", not `labels: {}` (which serializes differently in some
18448/// YAML libraries and is a sharp tool for label-based selectors that
18449/// match the empty set silently).
18450///
18451/// Iteration order under `metadata` is alphabetical (the inner
18452/// projection is a [`BTreeMap`] keyed by `&'static str`), so the
18453/// rendered YAML's `metadata:` block appears in
18454/// `labels?, name, namespace` order regardless of source-code
18455/// declaration order. Same render-determinism contract the M2 overlay
18456/// helper and the pleme-io selector helpers enshrine.
18457///
18458/// Lifted from three inline `serde_yaml::Mapping::new()` blocks in
18459/// `caixa-mesh` ([`cilium_network_policies`][cnp] CNP construction,
18460/// [`gateway_routes`][gw] Gateway construction, the same fn's
18461/// HTTPRoute construction) so the next renderer to land — the
18462/// per-`:politicas` `CiliumClusterwideEnvoyConfig` emitter, the
18463/// `app-operator`'s typed `mesh.pleme.io/v1alpha1/Aplicacao` CR
18464/// materializer, the M4 cross-cluster fan-out's per-cluster Kustomization
18465/// and HelmRelease emission, the future `caixa-otel`
18466/// OpenTelemetry-Collector pipeline emitter — gets the canonical
18467/// skeleton for free with one function call, instead of re-inlining
18468/// the same five-key insert() boilerplate.
18469///
18470/// [cnp]: https://docs.cilium.io/en/stable/security/policy/index.html
18471/// [gw]: https://gateway-api.sigs.k8s.io/
18472#[must_use]
18473pub fn kube_resource_skeleton(
18474 api_version: &str,
18475 kind: &str,
18476 name: &str,
18477 namespace: &str,
18478 labels: BTreeMap<&'static str, String>,
18479) -> serde_yaml::Mapping {
18480 let mut metadata: BTreeMap<&'static str, serde_yaml::Value> = BTreeMap::new();
18481 metadata.insert(KUBE_KEY_NAME, serde_yaml::Value::String(name.to_string()));
18482 metadata.insert(
18483 KUBE_KEY_NAMESPACE,
18484 serde_yaml::Value::String(namespace.to_string()),
18485 );
18486 if !labels.is_empty() {
18487 metadata.insert(KUBE_KEY_LABELS, yaml_string_mapping(labels));
18488 }
18489
18490 let mut metadata_map = serde_yaml::Mapping::new();
18491 for (k, v) in metadata {
18492 metadata_map.insert_str_key(k, v);
18493 }
18494
18495 let mut out = serde_yaml::Mapping::new();
18496 out.insert_string(KUBE_KEY_API_VERSION, api_version.to_string());
18497 out.insert_string(KUBE_KEY_KIND, kind.to_string());
18498 out.insert_mapping(KUBE_KEY_METADATA, metadata_map);
18499 out
18500}
18501
18502/// Build a single-field [`serde_yaml::Value::Mapping`] from a typed
18503/// `Option<T>` slot — `None` when the slot is unset, `Some(Mapping {
18504/// inner_key: f(t) })` otherwise.
18505///
18506/// The canonical shape every per-`:politicas` overlay across `caixa-mesh`
18507/// uses to wire a typed `MeshPolicy` axis through to its single-key
18508/// cluster artifact:
18509///
18510/// * `:politicas :timeout` → `timeouts: { request: <duration> }`
18511/// (Gateway API `HTTPRoute.spec.rules[].timeouts`, wired in 5f477a6)
18512/// * `:politicas :retries` → `retry: { attempts: <number> }`
18513/// (Gateway API `HTTPRoute.spec.rules[].retry`, wired in 23b7f00)
18514/// * `:politicas :mtls-required` → `authentication: { mode: <enum> }`
18515/// (Cilium `CiliumNetworkPolicy.spec.ingress[].authentication`,
18516/// wired in 878bf81)
18517///
18518/// Until this lift the three call sites each carried a verbatim copy
18519/// of the same six-line block — `let mut m = serde_yaml::Mapping::new();
18520/// m.insert(Value::String(<key>.into()), <value>); Value::Mapping(m)` —
18521/// wrapped in `spec.politicas.<axis>.map(|v| { … })`. Three-of-the-pattern
18522/// across one emit-site (and now structurally one-of-the-pattern in each
18523/// of the next two emit-sites the M3.x roadmap acknowledges: the
18524/// `:circuit-breaker` and `:rate-limit` axes' `CiliumClusterwideEnvoyConfig`
18525/// emitter, MESH-COMPOSITION §III.2 #3) overflows the duplication
18526/// budget; this helper is the lifted typed primitive.
18527///
18528/// The caller passes:
18529/// * the typed `Option<T>` slot,
18530/// * the inner YAML key the artifact's per-axis schema names
18531/// (`request` / `attempts` / `mode` for the three landed overlays;
18532/// `consecutiveErrors` / `requestsPerUnit` for the two roadmap
18533/// axes), and
18534/// * a closure converting the typed `T` into the inner field's
18535/// [`serde_yaml::Value`] (typically a `String` for canonical
18536/// duration / enum scalars or a `Number` for typed integer
18537/// attempt counts).
18538///
18539/// Returns `Some(Mapping)` when the slot is `Some`, `None` otherwise —
18540/// the caller's `if let Some(overlay) = … { rule.insert(<outer_key>,
18541/// overlay.clone()) }` guard for the *outer* key (`timeouts` / `retry`
18542/// / `authentication` — which the per-rule iteration applies to every
18543/// emitted item) becomes the single emission gate, and the *inner*
18544/// shape is built once by the closure.
18545///
18546/// Pairs with the `MeshPolicy::is_empty` predicate at the typed-axis
18547/// emptiness layer: `is_empty()` short-circuits the whole `:politicas`
18548/// block when every axis is `None`; this helper short-circuits the
18549/// per-axis overlay when its single axis is `None`. Two layers, same
18550/// "named-axis-with-None-means-skip-emit" contract THEORY.md §V.2.7
18551/// render determinism extends to.
18552#[must_use]
18553pub fn single_field_overlay<T, F>(
18554 slot: Option<T>,
18555 inner_key: &'static str,
18556 f: F,
18557) -> Option<serde_yaml::Value>
18558where
18559 F: FnOnce(T) -> serde_yaml::Value,
18560{
18561 slot.map(|v| {
18562 let mut m = serde_yaml::Mapping::new();
18563 m.insert_str_key(inner_key, f(v));
18564 serde_yaml::Value::Mapping(m)
18565 })
18566}
18567
18568/// Wrap a single [`serde_yaml::Mapping`] as the sole element of a
18569/// [`serde_yaml::Value::Sequence`], returning the ready-to-drop
18570/// singleton-mapping-sequence `Value`.
18571///
18572/// The canonical shape every K8s-CRD schema-list-shape-required field
18573/// with exactly one entry to emit lands the same
18574/// `Value::Sequence(vec![Value::Mapping(m)])` three-token block in
18575/// front of. Seven identical-shape call sites across
18576/// [`caixa-mesh`][mesh] collapse onto this helper:
18577///
18578/// * Cilium `CiliumNetworkPolicy.spec.ingress[].toPorts[].ports`
18579/// (one `port_entry` per typed edge, wrapped in the CRD's
18580/// required-list-shape `ports:` axis);
18581/// * Cilium `CiliumNetworkPolicy.spec.ingress[].toPorts[].rules.http`
18582/// (one `http_rule` per L7-introspection-capable
18583/// [`crate::WitTarget::Http`] contract, wrapped in the CRD's
18584/// required-list-shape `http:` axis);
18585/// * Cilium `CiliumNetworkPolicy.spec.ingress` (one `ingress_rule`
18586/// per policy — Cilium's CRD schema lists the per-policy ingress
18587/// ruleset even though V0 emits exactly one entry);
18588/// * Gateway API `Gateway.spec.listeners` (one `listener` per
18589/// Gateway — V0 emits the single HTTP-listener shape the sibling
18590/// [`GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME`] +
18591/// [`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`] consts pin);
18592/// * Gateway API `HTTPRoute.spec.rules[].matches` (one `match_entry`
18593/// per rule — V0 emits a single per-path prefix-match);
18594/// * Gateway API `HTTPRoute.spec.rules[].backendRefs` (one
18595/// `backend_ref` per rule — V0 emits a single-backend fan-in on
18596/// the `:entrada :para` destination Servico);
18597/// * Gateway API `HTTPRoute.spec.parentRefs` (one `parent_ref` per
18598/// route — every route attaches to exactly one Gateway).
18599///
18600/// Until this lift landed all seven call sites re-inlined the same
18601/// three-token boilerplate — `serde_yaml::` path re-quote,
18602/// `Value::Sequence(_)` promotion, `vec![serde_yaml::Value::Mapping(_)]`
18603/// singleton-list wrapping — around a one-token semantic payload (the
18604/// per-site `Mapping`). Lifting collapses the boilerplate into one
18605/// function call the caller reads as intent (`singleton_mapping_sequence
18606/// (<mapping>)` — "wrap this single mapping as the CRD-required list-
18607/// shape") rather than three hand-spelled positional artifacts. The
18608/// next renderer to land — the per-`:politicas`
18609/// `CiliumClusterwideEnvoyConfig` emitter (MESH-COMPOSITION §III.2 #3,
18610/// which drops singleton `resources:[]` / `listeners:[]` /
18611/// `virtualHosts:[]` blocks under its per-policy CR spec), the
18612/// `app-operator`'s typed `mesh.pleme.io/v1alpha1/Aplicacao` CR
18613/// materializer (§III.2 #5, whose `spec.selectors:[]` / `spec.gates:[]`
18614/// blocks list-shape a single per-Aplicacao entry), the M4 cross-
18615/// cluster fan-out's per-cluster `Service.spec.ports[]` /
18616/// `HTTPRoute.spec.rules[].backendRefs[]` emission, the future
18617/// `caixa-otel` OpenTelemetry-Collector `pipelines.traces.receivers[]`
18618/// / `pipelines.traces.exporters[]` singleton-list-shape emission —
18619/// gets the canonical CRD-list-shape-wrap for free with one function
18620/// call, instead of re-inlining the same three-token block. Peer with
18621/// the sibling render-side helpers on the [`serde_yaml::Value`]-
18622/// construction surface ([`yaml_string_mapping`], [`label_selector`],
18623/// [`kube_resource_skeleton`], [`single_field_overlay`], the sibling
18624/// [`MappingExt::insert_str_key`] primitive) — each closes a distinct
18625/// axis of the K8s-artifact-emit surface's "same shape, written N
18626/// times" duplication.
18627///
18628/// The helper takes an owned [`serde_yaml::Mapping`] (moving into the
18629/// wrapping `vec!` without a clone) because every call site has just
18630/// finished building the mapping locally and passes it by value to the
18631/// insert-under-outer-key step. A [`Value::Mapping`] wrapping of the
18632/// same mapping is one step further along the emit trajectory — the
18633/// helper closes the gap in one primitive.
18634///
18635/// The seven caixa-mesh call sites all followed the same
18636/// insert-under-outer-key step, so the composition
18637/// `mapping.insert_str_key(K, singleton_mapping_sequence(m))` is
18638/// itself lifted onto the sibling [`MappingExt::insert_singleton_mapping_sequence`]
18639/// method — every caixa-mesh site now reaches for the composed
18640/// method rather than nesting the two calls at the call site. This
18641/// standalone helper remains the semantic primitive for the
18642/// singleton-Mapping-list-shape `Value` (the trait method's impl
18643/// composes it internally), and stays public for future callers that
18644/// want the raw `Value::Sequence(vec![Value::Mapping(m)])` payload
18645/// without inserting it under a schema key.
18646///
18647/// [mesh]: https://docs.rs/caixa-mesh
18648#[must_use]
18649#[inline]
18650pub fn singleton_mapping_sequence(m: serde_yaml::Mapping) -> serde_yaml::Value {
18651 serde_yaml::Value::Sequence(vec![serde_yaml::Value::Mapping(m)])
18652}
18653
18654/// Iterator over the string-keyed entries of a [`serde_yaml::Value`]
18655/// that may or may not be a [`serde_yaml::Mapping`] — the canonical
18656/// shape both per-Servico renderers reach for when splicing the
18657/// upstream `ComputeUnit` YAML's `spec.*` fields into their emitted
18658/// output map.
18659///
18660/// Two identical-shape call sites collapse onto this helper — both
18661/// per-Servico renderers previously carried a five-line
18662/// `if let Value::Mapping(_) = spec { for (k, v) in _ { if let
18663/// Some(s) = k.as_str() { <dst>.insert(s, v.clone()) } } }` block:
18664///
18665/// * [`caixa_flux`][flux-programs]'s `programs_yaml_entry` splices
18666/// `computeunit_yaml.spec.*` into the emitted programs.yaml entry
18667/// ([`serde_yaml::Mapping`] destination, via
18668/// [`MappingExt::insert_str_key`]);
18669/// * [`caixa_helm`][helm-values]'s `build_values_yaml` splices the
18670/// same `computeunit_yaml.spec.*` into the values.yaml wrapped
18671/// block ([`std::collections::BTreeMap`]`<String, Value>`
18672/// destination, via `BTreeMap::insert`).
18673///
18674/// Both sites need the same walk (destructure as [`serde_yaml::Mapping`],
18675/// iterate its entries, keep only string-keyed pairs, hand the caller
18676/// each `(&str, &Value)` pair) but drop the values into different
18677/// destination map types, so the lift is at the iterator layer, not
18678/// the insert layer. The caller keeps its own insert idiom (
18679/// [`MappingExt::insert_str_key`] on a [`serde_yaml::Mapping`],
18680/// `BTreeMap::insert` on the [`BTreeMap`]-shaped values block, a
18681/// future renderer's own destination) but reaches through one lifted
18682/// walk with one contract on how non-string-keyed entries are handled:
18683/// silently dropped, matching the behavior both renderers implemented
18684/// inline via the `if let Some(s) = k.as_str()` filter.
18685///
18686/// Returns an empty iterator when `v` is not a
18687/// [`serde_yaml::Value::Mapping`] — the shape the prior `if let
18688/// Value::Mapping(_) = v` arm silently no-ops on (so a Null / String
18689/// / Sequence / Number / Bool `spec` field, itself schema-invalid
18690/// upstream but tolerated by the renderer, contributes zero entries
18691/// to the destination map instead of raising a per-shape error).
18692/// Non-string-keyed entries within a valid Mapping are silently
18693/// dropped — the same behavior the prior `if let Some(s) = k.as_str()`
18694/// arm carried, since `serde_yaml` permits arbitrary [`Value`] keys
18695/// (numeric, boolean, sub-mapping) that don't round-trip through the
18696/// downstream K8s YAML-key surface (which requires string keys).
18697///
18698/// The next per-Servico renderer to land — the future per-Servico
18699/// OCI packager whose emitted `Dockerfile` LABEL block spliced through
18700/// the same `computeunit_yaml.spec.*` string-key set, the M4
18701/// per-Servico `wasm.pleme.io/v1alpha1/ComputeUnit` CR materializer
18702/// whose emitted `spec.*` block splices the same set through onto the
18703/// typed [`kube::api::CustomResource`] view, the future `caixa-otel`
18704/// renderer's per-Servico OpenTelemetry-Collector resource-attribute
18705/// splice — gets the canonical string-key filter for free with one
18706/// method call, instead of re-inlining the same five-line
18707/// `if let Value::Mapping(_) = _` walk.
18708///
18709/// [flux-programs]: https://docs.rs/caixa-flux
18710/// [helm-values]: https://docs.rs/caixa-helm
18711pub fn string_keyed_entries(
18712 v: &serde_yaml::Value,
18713) -> impl Iterator<Item = (&str, &serde_yaml::Value)> + '_ {
18714 v.as_mapping()
18715 .into_iter()
18716 .flat_map(|m| m.iter())
18717 .filter_map(|(k, v)| k.as_str().map(|s| (s, v)))
18718}
18719
18720/// Read the string-scalar value at `metadata.<field>` on a K8s custom
18721/// resource YAML document, returning `None` when either the top-level
18722/// [`KUBE_KEY_METADATA`] block is absent (a defensively-tolerated
18723/// missing sub-mapping — the caller's own test-side `expect(...)` /
18724/// production-side `unwrap_or(...)` names the axis), the requested
18725/// `<field>` scalar is absent under it, or the scalar is present but
18726/// carries a non-string YAML type (a numeric, boolean, or nested
18727/// mapping — invalid K8s CR shape per the apiserver's OpenAPI schema
18728/// but tolerated here as `None` so the readback stays a total
18729/// function). The returned `&str` borrows into the input `Value` — the
18730/// caller decides whether to compare (`==`), clone (`.to_string()`),
18731/// or unwrap-then-panic. The three-hop navigation happens in one
18732/// method call the caller reads as intent
18733/// (`kube_metadata_str_field(<value>, <FIELD>)` — "read this
18734/// `metadata.<FIELD>` string-scalar off this K8s CR document") rather
18735/// than three hand-spelled positional artifacts (the
18736/// `get(KUBE_KEY_METADATA)` outer hop, the `and_then(|m| m.get(<FIELD>))`
18737/// inner hop, the `and_then(|n| n.as_str())` shape gate).
18738///
18739/// The canonical shape 8 call sites across `caixa-mesh` (six tests) +
18740/// `caixa-flux` (one production, one test) previously carried inline
18741/// as the three-line block
18742///
18743/// ```ignore
18744/// value
18745/// .get(KUBE_KEY_METADATA)
18746/// .and_then(|m| m.get(<FIELD>))
18747/// .and_then(|n| n.as_str())
18748/// ```
18749///
18750/// around a one-token semantic payload (the `<FIELD>` axis-key —
18751/// [`KUBE_KEY_NAME`] on the six `metadata.name` per-CNP filter /
18752/// per-CNP name-collect sites in caixa-mesh, [`KUBE_KEY_NAMESPACE`] on
18753/// the caixa-flux `programs_yaml_entry` production readback with
18754/// [`DEFAULT_NAMESPACE`] fallback + the caixa-flux `cluster_bundle`
18755/// test-side `kustomization.yaml` pin).
18756///
18757/// Sites lifted:
18758///
18759/// * caixa-mesh's `cilium_network_policies_emit_per_de_para_edges` —
18760/// the per-CNP names collect ([`KUBE_KEY_NAME`] readback across
18761/// every emitted policy);
18762/// * caixa-mesh's `cilium_fans_same_de_para_edges_into_one_policy` —
18763/// the per-CNP filter on the merged `cart-to-catalog` name
18764/// ([`KUBE_KEY_NAME`] readback + string equality);
18765/// * caixa-mesh's `cilium_pubsub_contracts_skip_l7_rules` — the
18766/// per-CNP find on the `cart-to-catalog` L7-emission witness
18767/// ([`KUBE_KEY_NAME`] readback + string equality);
18768/// * caixa-mesh's `cnp_l4_fallback_port_routes_through_lifted_
18769/// default_servico_port` — the per-CNP find on the
18770/// `payment-to-cart` L4-fallback witness ([`KUBE_KEY_NAME`]
18771/// readback + string equality);
18772/// * caixa-mesh's `cilium_mtls_required_contract_emits_
18773/// authentication_required` — the per-CNP find on the
18774/// `payment-to-cart` mTLS overlay witness ([`KUBE_KEY_NAME`]
18775/// readback + string equality);
18776/// * caixa-mesh's `cilium_mtls_not_required_omits_authentication` —
18777/// the per-CNP find on the `cart-to-payment` overlay-omit
18778/// witness ([`KUBE_KEY_NAME`] readback + string equality);
18779/// * caixa-flux's `programs_yaml_entry` — the production
18780/// `computeunit_yaml.metadata.namespace` readback with
18781/// [`DEFAULT_NAMESPACE`] fallback ([`KUBE_KEY_NAMESPACE`] readback
18782/// + `unwrap_or(DEFAULT_NAMESPACE)`);
18783/// * caixa-flux's `cluster_bundle_kustomization_metadata_namespace_
18784/// pins_flux_system_default` test-side pin — the emitted
18785/// `kustomization.yaml`'s `metadata.namespace` readback
18786/// ([`KUBE_KEY_NAMESPACE`] readback + string equality).
18787///
18788/// Peer to the sibling emit-side [`kube_resource_skeleton`] on the K8s
18789/// CR-document surface: [`kube_resource_skeleton`] closes the per-CR
18790/// `apiVersion` + `kind` + `metadata.{name,namespace,labels}` build
18791/// primitive on the emit side; this closes the reverse per-CR
18792/// `metadata.<field>` readback primitive on the readback side. The
18793/// two together bracket the K8s-CR-YAML round-trip axis so the same
18794/// [`KUBE_KEY_METADATA`] navigation string sits in exactly one place
18795/// on both the write and the read side, and a future
18796/// [`KUBE_KEY_METADATA`] rebrand — a schema-migration to a versioned
18797/// `metadataV2:` axis in a future K8s API-machinery revision, a
18798/// per-CRD-side rename to a wrapped `spec.metadata:` sub-mapping
18799/// under Server-Side-Apply's per-field ownership annotations —
18800/// reaches both sides through the same lifted constant + the same
18801/// lifted helper, not a coordinated rewrite across the emitter +
18802/// every per-CR readback path across every renderer.
18803///
18804/// The next renderer to land — the per-`:politicas`
18805/// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy test
18806/// harness reaches through `metadata.name` to pin per-`(:de, :para)`
18807/// naming and through `metadata.namespace` to pin the
18808/// [`DEFAULT_NAMESPACE`] contract, MESH-COMPOSITION §III.2 #3), the
18809/// `app-operator`'s typed `mesh.pleme.io/v1alpha1/Aplicacao` CR
18810/// materializer's per-CR readback (per-Aplicacao `metadata.name` /
18811/// `metadata.namespace` pins on the emitted `Aplicacao` CR, §III.2 #5),
18812/// the M4 cross-cluster fan-out's per-cluster `HelmRelease.metadata.
18813/// namespace` readback, the future `caixa-otel` per-Servico
18814/// OpenTelemetry-Collector CR's `metadata.name` pin — gets the
18815/// canonical `metadata.<field>` string readback for free with one
18816/// function call, instead of re-inlining the same three-hop chain.
18817///
18818/// The `field` axis stays parametric (rather than pinned to
18819/// [`KUBE_KEY_NAME`] or [`KUBE_KEY_NAMESPACE`] as two separate
18820/// helpers) so the same lift closes every string-scalar sub-field
18821/// under `metadata.*` a future K8s API-machinery revision surfaces
18822/// (`metadata.generateName` on Server-Side-Apply-authored CRs,
18823/// `metadata.resourceVersion` on optimistic-concurrency-controlled
18824/// updates, `metadata.uid` on cross-CR ownerReference bookkeeping) —
18825/// each new axis reaches for the same helper with a new
18826/// [`KUBE_KEY_<AXIS>`] const, not a fresh per-axis helper.
18827pub fn kube_metadata_str_field<'a>(value: &'a serde_yaml::Value, field: &str) -> Option<&'a str> {
18828 value
18829 .get(KUBE_KEY_METADATA)
18830 .and_then(|m| m.get(field))
18831 .and_then(|n| n.as_str())
18832}
18833
18834/// Read the string-scalar value at a top-level `<field>` axis-key on a
18835/// K8s custom resource YAML document — the root-level readback peer to
18836/// [`kube_metadata_str_field`] on the sub-`metadata:` axis. Returns
18837/// `None` when either the requested `<field>` scalar is absent
18838/// (defensively tolerated — the caller's own `unwrap_or(...)` /
18839/// `expect(...)` names the axis) or the scalar is present but carries a
18840/// non-string YAML type (a numeric, boolean, or nested mapping —
18841/// invalid K8s CR shape per the apiserver's OpenAPI schema but
18842/// tolerated here as `None` so the readback stays a total function).
18843/// The returned `&str` borrows into the input `Value` — the caller
18844/// decides whether to compare (`==`), clone (`.to_string()`), or
18845/// unwrap-then-panic. The two-hop navigation happens in one function
18846/// call the caller reads as intent (`kube_root_str_field(<value>,
18847/// <FIELD>)` — "read this K8s CR's top-level `<FIELD>` string-scalar")
18848/// rather than two hand-spelled positional artifacts (the
18849/// `get(<FIELD>)` outer hop, the `and_then(|n| n.as_str())` shape gate).
18850///
18851/// The canonical shape 32 call sites across `caixa-mesh` (24) +
18852/// `caixa-flux` (8) previously carried inline as the two-line block
18853///
18854/// ```ignore
18855/// value
18856/// .get(<FIELD>)
18857/// .and_then(|n| n.as_str())
18858/// ```
18859///
18860/// around a one-token semantic payload (the `<FIELD>` axis-key —
18861/// [`KUBE_KEY_KIND`] on 22 sites, [`KUBE_KEY_API_VERSION`] on 10
18862/// sites). Every routed caller keeps its downstream idiom
18863/// (`.unwrap()`, `.expect(...)`, `== Some(<KIND>)`, `assert_eq!(...,
18864/// Some(<API_VERSION>))`) unchanged — the lift closes the navigation
18865/// surface, not the per-site error-handling posture.
18866///
18867/// Sites lifted include:
18868///
18869/// * caixa-flux's `cluster_bundle_helmrelease_uses_lifted_flux_api_version`
18870/// + peer test-side pins on the emitted `helmrelease.yaml`,
18871/// `gitrepository.yaml`, `kustomization.yaml` per-document
18872/// top-level [`KUBE_KEY_API_VERSION`] axis;
18873/// * caixa-flux's per-document top-level [`KUBE_KEY_KIND`] axis pins
18874/// across the same `cluster_bundle` multi-file sequence;
18875/// * caixa-mesh's `docs.iter().find(|d| d.get(KUBE_KEY_KIND).
18876/// and_then(|k| k.as_str()) == Some(<KIND>))` per-CR filter over
18877/// the emitted `Gateway` + `HTTPRoute` multi-doc sequence — the 15
18878/// `gateway_routes` test-harness `find` sites plus the sibling
18879/// [`CILIUM_KIND_NETWORK_POLICY`] filter in
18880/// `cilium_authentication_mode_serialized_as_yaml_string`;
18881/// * caixa-mesh's per-CR top-level [`KUBE_KEY_API_VERSION`] +
18882/// [`KUBE_KEY_KIND`] discriminator-pair pins across
18883/// `cilium_network_policies_emit_per_de_para_edges` +
18884/// `gateway_routes_emit_gateway_and_httproute_per_aplicacao` +
18885/// sibling gateway/route pins.
18886///
18887/// Peer to sibling [`kube_metadata_str_field`] (6809867) on the K8s
18888/// CR-document readback surface: [`kube_metadata_str_field`] closes
18889/// the `metadata.<field>` string-scalar readback at the sub-`metadata:`
18890/// axis; this closes the root-level `<field>` string-scalar readback at
18891/// the top-level axis. The two together bracket the K8s-CR YAML
18892/// readback surface so every navigation into a rendered K8s CR
18893/// document — the top-level `(apiVersion, kind)` discriminator pair,
18894/// the sub-`metadata.(name, namespace)` identity pair — reaches
18895/// through one canonical lifted helper. A future K8s API-machinery
18896/// rebrand on either axis (a hypothetical `apiVersionV2:` scalar under
18897/// a wrapper CRD group's schema-migration, a Server-Side-Apply-driven
18898/// `metadata.name` rename under per-field ownership annotations)
18899/// reaches every consumer through one lifted helper, not a coordinated
18900/// rewrite across every renderer + every test-side per-CR readback
18901/// path.
18902///
18903/// The `field` axis stays parametric (rather than pinned to
18904/// [`KUBE_KEY_KIND`] or [`KUBE_KEY_API_VERSION`] as two separate
18905/// helpers) so the same lift closes every top-level string-scalar
18906/// axis a future K8s API-machinery revision surfaces (e.g. the
18907/// `caixa-otel` per-Servico OpenTelemetry-Collector CR's top-level
18908/// scalar pins, the future `mesh.pleme.io/v1alpha1/Aplicacao` CR
18909/// materializer's per-CR discriminator readback in the app-operator,
18910/// MESH-COMPOSITION §III.2 #5) — each new axis reaches for the same
18911/// helper with a new [`KUBE_KEY_<AXIS>`] const, not a fresh per-axis
18912/// helper.
18913pub fn kube_root_str_field<'a>(value: &'a serde_yaml::Value, field: &str) -> Option<&'a str> {
18914 value.get(field).and_then(|n| n.as_str())
18915}
18916
18917/// Predicate: does the K8s custom resource YAML document at `value`
18918/// declare its top-level `kind` discriminator axis as exactly `kind`?
18919///
18920/// Composes on top of [`kube_root_str_field`] (ae83f4e) — same two-hop
18921/// `.get(KUBE_KEY_KIND).and_then(as_str)` navigation — and closes the
18922/// "top-level kind-discriminator equality" predicate axis every
18923/// multi-doc mesh emission traversal reaches for to split the emitted
18924/// sequence by CRD-kind.
18925///
18926/// The canonical shape 15 test-side `.find(|d| kube_root_str_field(d,
18927/// KUBE_KEY_KIND) == Some(<KIND>))` + `.filter(|d| … == Some(<KIND>))`
18928/// call sites in `caixa-mesh` previously carried inline as the
18929/// three-token composition
18930///
18931/// ```ignore
18932/// kube_root_str_field(d, KUBE_KEY_KIND) == Some(<KIND>)
18933/// ```
18934///
18935/// around a one-token semantic payload (the `<KIND>` axis-value —
18936/// [`GATEWAY_API_KIND_GATEWAY`] on the per-Gateway filter sites,
18937/// [`GATEWAY_API_KIND_HTTP_ROUTE`] on the per-HTTPRoute filter sites,
18938/// [`CILIUM_KIND_NETWORK_POLICY`] on the sibling CNP filter site). The
18939/// lift collapses the three-token composition — the readback helper
18940/// call, the `== Some(...)` equality wrap, the discriminator-axis pin
18941/// on [`KUBE_KEY_KIND`] — onto one predicate function the caller
18942/// reads as intent (`kube_kind_is(d, <KIND>)` — "is this K8s CR
18943/// document of kind `<KIND>`") rather than as a three-hop
18944/// `readback → wrap → compare` chain.
18945///
18946/// The [`KUBE_KEY_KIND`] axis is pinned inside the helper (unlike the
18947/// parametric `field` axis of the underlying [`kube_root_str_field`])
18948/// because the "does this CR document match kind X" question is a
18949/// semantically-distinct discriminator predicate, not a generic
18950/// scalar-readback: the K8s CRD schema pins `kind` as the load-bearing
18951/// discriminator on every `CustomResource` across every group/version,
18952/// so this predicate lives one abstraction step above the generic
18953/// readback. Peer predicates for other top-level discriminators
18954/// (e.g. `kube_api_version_is` on a hypothetical multi-version
18955/// migration harness) land as sibling helpers with their own
18956/// pinned axis, not as re-parameterizations of this one.
18957///
18958/// Sites lifted:
18959///
18960/// * caixa-mesh's `gateway_routes` test-harness — 14
18961/// `docs.iter().find(|d| kube_root_str_field(d, KUBE_KEY_KIND) ==
18962/// Some(GATEWAY_API_KIND_{GATEWAY,HTTP_ROUTE}))` sites splitting
18963/// the multi-doc emission by `Gateway` vs `HTTPRoute` for per-CR
18964/// body-axis assertions;
18965/// * caixa-mesh's `cilium_authentication_mode_serialized_as_yaml_string`
18966/// — 1 `docs.iter().filter(|d| kube_root_str_field(d,
18967/// KUBE_KEY_KIND) == Some(CILIUM_KIND_NETWORK_POLICY))` filter
18968/// over the emitted CNP sequence.
18969///
18970/// Every future per-CRD-kind traversal (the per-`:politicas`
18971/// `CiliumClusterwideEnvoyConfig` emitter's per-CR filter,
18972/// MESH-COMPOSITION §III.2 #3; the `app-operator`'s
18973/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-status
18974/// discriminator predicate, §III.2 #5; the M4 cross-cluster fan-out's
18975/// per-cluster `HelmRelease` vs `Kustomization` split by kind) reaches
18976/// the same helper by construction, with no `== Some(...)` inline
18977/// composition and no drift surface on the `kind` scalar-key axis.
18978pub fn kube_kind_is(value: &serde_yaml::Value, kind: &str) -> bool {
18979 kube_root_str_field(value, KUBE_KEY_KIND) == Some(kind)
18980}
18981
18982/// Locate the first K8s CR YAML document in `docs` whose top-level
18983/// `kind` discriminator axis equals `kind`.
18984///
18985/// Composes on top of [`kube_kind_is`] (2902d9d) — same one-hop
18986/// `.get(KUBE_KEY_KIND).and_then(as_str) == Some(kind)` predicate —
18987/// and closes the "find the one document of a given kind inside a
18988/// multi-doc mesh emission" navigator axis every per-Aplicacao
18989/// renderer's post-emit test harness reaches for to split the
18990/// emitted sequence by CRD-kind before probing a per-CR body-axis.
18991///
18992/// The canonical shape 14 test-side
18993///
18994/// ```ignore
18995/// docs.iter().find(|d| kube_kind_is(d, <KIND>))
18996/// ```
18997///
18998/// call sites in [`caixa-mesh`][mesh]'s `gateway_routes` +
18999/// `cilium_network_policies` test harnesses previously threaded the
19000/// three-token `.iter().find(closure)` combinator chain around a
19001/// one-token semantic payload (the `<KIND>` axis-value —
19002/// [`GATEWAY_API_KIND_GATEWAY`] on the per-Gateway navigator sites,
19003/// [`GATEWAY_API_KIND_HTTP_ROUTE`] on the per-HTTPRoute navigator
19004/// sites). The lift collapses the three-token chain — the `.iter()`
19005/// receiver-widen, the `.find(closure)` combinator, the inline
19006/// closure wrap around [`kube_kind_is`] — onto one navigator
19007/// function the caller reads as intent (`find_by_kind(&docs,
19008/// <KIND>)` — "give me the K8s CR document of kind `<KIND>`")
19009/// rather than as a receiver-widen → combinator → predicate chain.
19010///
19011/// Composition-symmetric to [`kube_kind_is`]: the lifted predicate
19012/// answers "does *this* one document match kind `<KIND>`?", the
19013/// lifted navigator answers "find the one document of kind
19014/// `<KIND>` in *this list*?". Same axis, different arity — the two
19015/// call shapes emit-side test harnesses reach for when splitting
19016/// multi-doc CR emissions by top-level kind.
19017///
19018/// Every future per-CRD-kind multi-doc-navigator site (the
19019/// per-`:politicas` `CiliumClusterwideEnvoyConfig` emitter's post-
19020/// emit test harness, MESH-COMPOSITION §III.2 #3; the
19021/// `app-operator`'s `mesh.pleme.io/v1alpha1/Aplicacao` CR
19022/// materializer's per-status doc-navigator, §III.2 #5; the M4
19023/// cross-cluster fan-out's per-cluster multi-doc split by kind)
19024/// reaches the same helper by construction, with no inline
19025/// `.iter().find(closure)` combinator chain and no drift surface
19026/// on the receiver-widen or combinator axes.
19027///
19028/// [mesh]: https://github.com/pleme-io/caixa/tree/main/caixa-mesh
19029#[must_use]
19030pub fn find_by_kind<'a>(
19031 docs: &'a [serde_yaml::Value],
19032 kind: &str,
19033) -> Option<&'a serde_yaml::Value> {
19034 docs.iter().find(|d| kube_kind_is(d, kind))
19035}
19036
19037/// Upsert `new_entry` into a typed sequence of programs.yaml-shaped
19038/// entries by matching on `new_entry`'s `<name_key>` scalar — the
19039/// idempotent "replace-in-place if present, else append" contract
19040/// every writer-side aggregator overlay lands the same 11-line block
19041/// in front of. Returns `Ok(true)` when the entry was appended new,
19042/// `Ok(false)` when an existing entry with the same `<name_key>`
19043/// value was replaced in place (preserving position); returns
19044/// `on_missing_name()` when `new_entry` doesn't carry `<name_key>`
19045/// as a string scalar (the caller's own typed
19046/// [`crate::RenderError`]-shaped error surface, threaded through the
19047/// closure so this helper stays crate-agnostic).
19048///
19049/// Two identical-shape call sites collapse onto this helper — the
19050/// two [`caixa-flux`] writer-side upsert paths that both land a
19051/// programs.yaml entry into a `programs:` sequence differing only
19052/// on the outer navigation:
19053///
19054/// * [`caixa_flux::upsert_into_helmrelease_programs`][helm-up] —
19055/// the aggregator-HelmRelease shape, upserting into
19056/// `spec.values.programs[]` on a `HelmRelease` document;
19057/// * [`caixa_flux::upsert_into_programs_yaml`][yaml-up] — the
19058/// bare-values.yaml shape, upserting into `programs[]` at the
19059/// values.yaml root.
19060///
19061/// Until this lift landed both call sites re-inlined the same
19062/// verbatim 11-line block — extract-name-scalar-or-error, iterate
19063/// the sequence, replace-in-place-on-match else fall through to
19064/// push — with no compile-time link between the two: a rebrand on
19065/// either side (a per-entry match key rename beyond the currently-
19066/// lifted [`crate::FLEET_PROGRAMS_KEY_NAME`], the idempotency
19067/// contract's semantic reshaping — e.g. matching on
19068/// `(name, namespace)` for the M4 multi-namespace aggregator flow
19069/// once the `lareira-fleet-programs` chart admits per-entry
19070/// `namespace:` overrides, the return-value's `bool`-shape shift
19071/// once "replace" grows a merge-semantics axis) would silently
19072/// desynchronize the two writer-side paths — one path idempotently
19073/// upserts under the new contract while the other silently keeps
19074/// the old shape, and the failure surfaces at aggregator-apply
19075/// time as a duplicated / missing / mis-merged entry far from the
19076/// rebrand commit's source. Peer of the sibling render-side lifts
19077/// ([`single_field_overlay`], [`servico_m2_overlay`],
19078/// [`insert_first_seen`]) on the same "the same shape written
19079/// verbatim ≥ 2 times becomes a typed helper" trajectory THEORY.md
19080/// §I.3.5 promotes to a build-time concern.
19081///
19082/// The `name_key` axis stays parametric (rather than pinned to
19083/// [`crate::FLEET_PROGRAMS_KEY_NAME`] inside the helper) so a
19084/// future per-entry match on a different discriminator scalar (an
19085/// M4 `id:` axis promoted alongside `name:`, the future
19086/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-entry
19087/// `spec.selector` upsert path) reaches for the same helper with a
19088/// different key rather than re-inlining the loop. The closure-
19089/// shaped error surface (rather than a bare `Result<bool,
19090/// &'static str>` or an added typed error variant in this crate)
19091/// keeps every caller's own error enum authoritative — the
19092/// diagnostic remediation for a missing-name-scalar in a programs-
19093/// yaml entry rightly names the caller's aggregator schema
19094/// (`spec.values.programs[].name` for the `HelmRelease` shape,
19095/// `programs[].name` for the bare values.yaml shape), not this
19096/// generic helper.
19097///
19098/// [helm-up]: ../../caixa_flux/fn.upsert_into_helmrelease_programs.html
19099/// [yaml-up]: ../../caixa_flux/fn.upsert_into_programs_yaml.html
19100///
19101/// # Errors
19102///
19103/// Returns `on_missing_name()` when `new_entry.get(name_key)` is
19104/// not a [`serde_yaml::Value::String`] — the closure surfaces the
19105/// caller's own typed error variant naming the offending schema
19106/// axis. On success returns `Ok(true)` for a newly-appended entry,
19107/// `Ok(false)` for an in-place replacement.
19108pub fn upsert_named_entry<E>(
19109 arr: &mut Vec<serde_yaml::Value>,
19110 new_entry: serde_yaml::Value,
19111 name_key: &'static str,
19112 on_missing_name: impl FnOnce() -> E,
19113) -> Result<bool, E> {
19114 let new_name = match new_entry.get(name_key).and_then(|n| n.as_str()) {
19115 Some(s) => s.to_string(),
19116 None => return Err(on_missing_name()),
19117 };
19118 for slot in arr.iter_mut() {
19119 if slot.get(name_key).and_then(|n| n.as_str()) == Some(&new_name) {
19120 *slot = new_entry;
19121 return Ok(false);
19122 }
19123 }
19124 arr.push(new_entry);
19125 Ok(true)
19126}
19127
19128/// Render the M2 typed-slot YAML overlay for a Caixa: the camelCase
19129/// `(key, value)` fragments every per-Servico renderer
19130/// ([`caixa-helm`]'s values block, [`caixa-flux`]'s programs.yaml
19131/// entry) merges into its target with `or_insert` semantics so explicit
19132/// `spec.*` fields from the ComputeUnit YAML take precedence over the
19133/// manifest-derived overlay.
19134///
19135/// Keys (alphabetically ordered, since the return type is
19136/// [`BTreeMap`]) match the ComputeUnit / pleme-computeunit values
19137/// schema:
19138///
19139/// * [`M2_KEY_BEHAVIOR`] — present iff `caixa.behavior` is `Some`
19140/// and `BehaviorSpec::is_empty` returns `false`.
19141/// * [`M2_KEY_LIMITS`] — present iff `caixa.limits` is `Some` and
19142/// `LimitsSpec::is_empty` returns `false`.
19143/// * [`M2_KEY_UPGRADE_FROM`] — present iff `caixa.upgrade_from` is
19144/// non-empty.
19145///
19146/// An entirely empty M2 surface returns an empty map; the renderer
19147/// merges zero fragments and emits no extra keys (the per-renderer
19148/// "empty M2 slots do not appear" tests pin this invariant —
19149/// `caixa_helm::tests::empty_m2_slots_do_not_appear` and
19150/// `caixa_flux::tests::empty_m2_slots_do_not_appear_in_programs_yaml_entry`).
19151///
19152/// # Errors
19153///
19154/// Returns [`RenderError::Yaml`] if `serde_yaml::to_value` fails for
19155/// any of the typed M2 slot values. The prior inline block silently
19156/// substituted [`serde_yaml::Value::Null`] in this case, which renders
19157/// as e.g. `limits: null` — indistinguishable from "the author omitted
19158/// the slot" once it leaves the typed surface.
19159pub fn servico_m2_overlay(
19160 caixa: &Caixa,
19161) -> Result<BTreeMap<&'static str, serde_yaml::Value>, RenderError> {
19162 let mut out = BTreeMap::new();
19163 if let Some(limits) = caixa.limits() {
19164 if !limits.is_empty() {
19165 let v = serde_yaml::to_value(limits).map_err(|source| RenderError::Yaml {
19166 slot: M2_KEY_LIMITS,
19167 source,
19168 })?;
19169 out.insert(M2_KEY_LIMITS, v);
19170 }
19171 }
19172 if let Some(behavior) = caixa.behavior() {
19173 if !behavior.is_empty() {
19174 let v = serde_yaml::to_value(behavior).map_err(|source| RenderError::Yaml {
19175 slot: M2_KEY_BEHAVIOR,
19176 source,
19177 })?;
19178 out.insert(M2_KEY_BEHAVIOR, v);
19179 }
19180 }
19181 if !caixa.upgrade_from().is_empty() {
19182 let v = serde_yaml::to_value(caixa.upgrade_from()).map_err(|source| RenderError::Yaml {
19183 slot: M2_KEY_UPGRADE_FROM,
19184 source,
19185 })?;
19186 out.insert(M2_KEY_UPGRADE_FROM, v);
19187 }
19188 Ok(out)
19189}
19190
19191/// Compose the canonical per-Servico value-block splice every per-Servico
19192/// renderer applies to the target values / entry mapping — the two-step
19193/// sequence [`caixa_helm::build_values_yaml`] and
19194/// [`caixa_flux::programs_yaml_entry`] both re-derived inline before this
19195/// lift:
19196///
19197/// 1. Splice every string-keyed entry from the `ComputeUnit` YAML's
19198/// `spec.*` sub-mapping (routed through [`string_keyed_entries`],
19199/// preserving the source Mapping's insertion order).
19200/// 2. Overlay the M2 typed slots (routed through
19201/// [`servico_m2_overlay`], `BTreeMap` key-ordered) at every M2 key
19202/// not already claimed by step 1 — the `or_insert` precedence rule
19203/// the two prior inline call sites shared, promoted here to a
19204/// filtered append so the returned `Vec` is drop-in for a target
19205/// mapping whose insertion order is load-bearing (caixa-flux's
19206/// `serde_yaml::Mapping` preserves it; caixa-helm's `BTreeMap`
19207/// re-sorts by key, so both consumer shapes stay byte-identical
19208/// to their prior inline blocks under this lift).
19209///
19210/// Returns a `Vec<(String, serde_yaml::Value)>` in insertion order —
19211/// spec.* entries first (original ordering preserved), then the M2 slots
19212/// that weren't claimed by spec.* (in [`servico_m2_overlay`]'s canonical
19213/// BTreeMap-key ordering: `behavior` → `limits` → `upgradeFrom`).
19214/// Callers extend their target mapping by iterating the `Vec` and
19215/// inserting each pair with their own map type's canonical insert.
19216///
19217/// Until this lift landed the two prior inline blocks each carried the
19218/// same three-shape composition: `for (k, v) in
19219/// caixa_core::string_keyed_entries(spec) { <insert>(k, v.clone()); }`
19220/// followed by `for (key, value) in caixa_core::servico_m2_overlay(caixa)?
19221/// { <entry-and-or-insert>(key, value); }`. A future change to the
19222/// per-Servico splice / overlay composition — the M4 typed per-edge
19223/// policy overlay slot addition (MESH-COMPOSITION §III.2 #3), a change
19224/// to the spec.* / M2 precedence rule (e.g. reversing to "M2 wins on
19225/// collision" once per-Aplicacao operator overrides land), a
19226/// canonicalization pass on the merged key set (e.g. rejecting empty
19227/// string keys, casing-normalization on DNS-1123 labels) — would have
19228/// to be threaded through both renderers in lockstep or one would
19229/// silently diverge from the other on which keys it emitted and in
19230/// what order. Peer with the lifted [`servico_m2_overlay`] on the
19231/// per-Servico M2-overlay axis (10bf310 / 0e84fb9 on the sibling
19232/// upsert-loop / test-side probe axes) — completes the
19233/// "one canonical splice / overlay composition per typed axis"
19234/// discipline the M2 overlay lift established, now on the composed
19235/// spec.*+M2 axis every per-Servico renderer entry-point navigates.
19236///
19237/// # Errors
19238///
19239/// Propagates [`RenderError::Yaml`] from [`servico_m2_overlay`] when
19240/// `serde_yaml::to_value` fails for any typed M2 slot value — the same
19241/// error surface [`servico_m2_overlay`]'s docstring names.
19242pub fn servico_spec_and_m2_overlay_entries(
19243 caixa: &Caixa,
19244 spec: &serde_yaml::Value,
19245) -> Result<Vec<(String, serde_yaml::Value)>, RenderError> {
19246 let mut seen: std::collections::HashSet<String> = std::collections::HashSet::new();
19247 let mut out: Vec<(String, serde_yaml::Value)> = Vec::new();
19248 for (k, v) in string_keyed_entries(spec) {
19249 seen.insert(k.to_string());
19250 out.push((k.to_string(), v.clone()));
19251 }
19252 for (key, value) in servico_m2_overlay(caixa)? {
19253 if !seen.contains(key) {
19254 out.push((key.to_string(), value));
19255 }
19256 }
19257 Ok(out)
19258}
19259
19260/// Bracket a typed `u32` axis with the "zero-floor + upper-cap" gate
19261/// pair every capped-`u32` `:politicas` / `:supervisor` / `:limits`
19262/// axis carries. Returns `on_zero()` when `value == 0`,
19263/// `on_cap_exceeded(value)` when `value > cap`, `Ok(())` otherwise.
19264///
19265/// The zero-floor arm strictly precedes the cap arm so a literal `0`
19266/// value surfaces the self-locating zero diagnostic (which every
19267/// per-axis error variant already documents an "omit the axis to
19268/// express no-bound" remediation for) rather than the misleading
19269/// `0 > cap` false-negative on the cap arm. Same ordering discipline
19270/// every existing per-axis inline `if value == 0 { … } if value > CAP
19271/// { … }` block already applies — this lift makes the ordering a
19272/// property of the helper, not a per-call-site convention six sites
19273/// re-derive.
19274///
19275/// Six identical-shape call sites collapse onto this helper:
19276///
19277/// * [`crate::AplicacaoSpec::validate_politicas`] on
19278/// `MeshPolicy::retries` (zero →
19279/// [`crate::AplicacaoError::PolicyRetriesZero`], cap →
19280/// [`crate::AplicacaoError::PolicyRetriesExceedsCap`],
19281/// cap = [`crate::POLICY_RETRIES_MAX`]),
19282/// `CircuitBreaker::max_failures` (zero →
19283/// [`crate::AplicacaoError::PolicyBreakerZeroFailures`], cap →
19284/// [`crate::AplicacaoError::PolicyBreakerMaxFailuresExceedsCap`],
19285/// cap = [`crate::POLICY_BREAKER_MAX_FAILURES_MAX`]), and
19286/// `RateLimit::rate` (zero →
19287/// [`crate::AplicacaoError::PolicyRateLimitZero`], cap →
19288/// [`crate::AplicacaoError::PolicyRateLimitExceedsCap`],
19289/// cap = [`crate::POLICY_RATE_LIMIT_MAX`]);
19290/// * [`crate::SupervisorSpec::validate`] on `max_restarts`
19291/// (zero → [`crate::SupervisorError::ZeroMaxRestarts`], cap →
19292/// [`crate::SupervisorError::MaxRestartsExceedsCap`],
19293/// cap = [`crate::SUPERVISOR_MAX_RESTARTS_MAX`]);
19294/// * [`crate::LimitsSpec::validate`] on `cpu`
19295/// (zero → [`crate::LimitsError::CpuZero`], cap →
19296/// [`crate::LimitsError::CpuExceedsCap`],
19297/// cap = [`crate::LIMITS_CPU_MILLICORES_MAX`]).
19298///
19299/// Peer to [`require_positive_bounded_u64`] on the `u64`-typed axes
19300/// ([`crate::LimitsSpec::fuel`]). Generic over the caller's error enum
19301/// so the same helper reaches every crate-level [`thiserror`] surface
19302/// — the six per-axis error variants remain the source of truth for
19303/// each axis's remediation prose; the helper only sequences the two
19304/// gate arms in canonical order and threads the value into the cap
19305/// arm's discriminator field.
19306///
19307/// # Errors
19308///
19309/// Returns `on_zero()` for `value == 0`; returns `on_cap_exceeded(value)`
19310/// for `value > cap`; returns `Ok(())` otherwise.
19311pub fn require_positive_bounded_u32<E>(
19312 value: u32,
19313 cap: u32,
19314 on_zero: impl FnOnce() -> E,
19315 on_cap_exceeded: impl FnOnce(u32) -> E,
19316) -> Result<(), E> {
19317 if value == 0 {
19318 return Err(on_zero());
19319 }
19320 if value > cap {
19321 return Err(on_cap_exceeded(value));
19322 }
19323 Ok(())
19324}
19325
19326/// Peer of [`require_positive_bounded_u32`] on the `u64`-typed axes.
19327/// Returns `on_zero()` when `value == 0`, `on_cap_exceeded(value)`
19328/// when `value > cap`, `Ok(())` otherwise. See
19329/// [`require_positive_bounded_u32`] for the ordering / lift rationale
19330/// (same "zero-floor arm strictly precedes cap arm so `0` surfaces
19331/// the self-locating diagnostic" discipline the peer helper documents).
19332///
19333/// The single existing call site is [`crate::LimitsSpec::validate`] on
19334/// `fuel` (zero → [`crate::LimitsError::FuelZero`], cap →
19335/// [`crate::LimitsError::FuelExceedsCap`], cap =
19336/// [`crate::LIMITS_FUEL_MAX`]). Lifted alongside its `u32` peer so
19337/// the two integer-typed axes on this discipline share one canonical
19338/// entry-point — a future `u64`-typed axis (a hypothetical
19339/// per-Aplicacao byte-budget cap, the M4 per-edge policy resolver's
19340/// byte-throughput axis) reaches for the same helper by construction.
19341///
19342/// # Errors
19343///
19344/// Returns `on_zero()` for `value == 0`; returns `on_cap_exceeded(value)`
19345/// for `value > cap`; returns `Ok(())` otherwise.
19346pub fn require_positive_bounded_u64<E>(
19347 value: u64,
19348 cap: u64,
19349 on_zero: impl FnOnce() -> E,
19350 on_cap_exceeded: impl FnOnce(u64) -> E,
19351) -> Result<(), E> {
19352 if value == 0 {
19353 return Err(on_zero());
19354 }
19355 if value > cap {
19356 return Err(on_cap_exceeded(value));
19357 }
19358 Ok(())
19359}
19360
19361/// Bracket a typed `u64` axis carrying a quantized value with the
19362/// "zero-floor + below-quantum floor + upper-cap + not-quantum-multiple"
19363/// four-arm gate every capped-and-quantized `u64` axis in the crate
19364/// carries. Returns `on_zero()` when `value == 0`,
19365/// `on_below_quantum(value)` when `value < quantum`,
19366/// `on_cap_exceeded(value)` when `value > cap`,
19367/// `on_not_quantum_multiple(value)` when `value % quantum != 0`,
19368/// `Ok(())` otherwise.
19369///
19370/// The four arms fire in canonical `zero → below-quantum → cap →
19371/// not-quantum-multiple` order, matching the discipline the pre-lift
19372/// inline block at [`crate::LimitsSpec::validate`]'s `:memory` axis
19373/// applied by hand across four sequential `if let Some(m) = self.memory()`
19374/// wrappers. Each arm strictly precedes the next: the zero-floor arm
19375/// precedes the below-quantum arm so `Some(0)` (a value the modulus arm
19376/// would silently accept because `0 % quantum == 0` and the below-quantum
19377/// arm would also flag because `0 < quantum` — two distinct diagnostics
19378/// for the same value) surfaces the self-locating zero diagnostic every
19379/// per-axis error variant already documents an "omit the axis to
19380/// express no-bound" remediation for; the below-quantum arm precedes
19381/// the cap arm so a sub-quantum value (which is *also* not a quantum
19382/// multiple by construction — the smallest positive quantum multiple
19383/// *is* `quantum`) surfaces the more actionable "raise to at least one
19384/// quantum" diagnostic first; the cap arm precedes the not-multiple
19385/// arm so a value that is both above-cap and sub-quantum-residue
19386/// surfaces the cap diagnostic first (the not-multiple remediation
19387/// would be misleading when the offending value already exceeds the
19388/// upper bracket — the canonical fix collapses both into "pin a
19389/// quantum-aligned value ≤ cap"), peer to the
19390/// [`require_positive_canonical_bounded_duration`] cap-precedes-not-
19391/// canonical ordering on the sibling typed-`Duration` axis.
19392///
19393/// One existing call site collapses onto this helper —
19394/// [`crate::LimitsSpec::validate`] on
19395/// [`crate::LimitsSpec::memory`] (zero →
19396/// [`crate::LimitsError::MemoryZero`], below-quantum →
19397/// [`crate::LimitsError::MemoryBelowWasm32Page`], cap →
19398/// [`crate::LimitsError::MemoryExceedsWasm32Cap`], not-multiple →
19399/// [`crate::LimitsError::MemoryNotPageMultiple`],
19400/// quantum = [`crate::LIMITS_MEMORY_WASM32_PAGE_BYTES`] (64 KiB),
19401/// cap = [`crate::LIMITS_MEMORY_WASM32_MAX_BYTES`] (4 GiB)) — the last
19402/// unlifted `:limits` axis on the four-axis `LimitsSpec::validate`
19403/// discipline. The three peer axes (`:fuel`, `:wall-clock`, `:cpu`)
19404/// each route through one substrate helper today
19405/// ([`require_positive_bounded_u64`],
19406/// [`require_positive_canonical_bounded_duration`],
19407/// [`require_positive_bounded_u32`]); after this lift `:memory` joins
19408/// them at the same altitude — every `LimitsSpec::validate` axis is
19409/// exactly one typed-helper dispatch, with the four-arm ordering
19410/// discipline promoted from per-site convention to structural contract
19411/// on the substrate primitive.
19412///
19413/// Peer to [`require_positive_bounded_u32`] /
19414/// [`require_positive_bounded_u64`] on the two-arm integer-typed
19415/// bracket axes and to [`require_positive_canonical_bounded_duration`]
19416/// on the three-arm typed-`Duration` bracket-and-quantize axis. Generic
19417/// over the caller's error enum so the same helper reaches every
19418/// crate-level [`thiserror`] surface — the four per-axis error variants
19419/// remain the source of truth for each axis's remediation prose; the
19420/// helper only sequences the four gate arms in canonical order and
19421/// threads the value into the below-quantum / cap / not-multiple arms'
19422/// discriminator fields.
19423///
19424/// PRIME DIRECTIVE promotion: the four-arm quantized-byte-cap cascade
19425/// is the natural u64 extension of the two-arm
19426/// [`require_positive_bounded_u64`] bracket the sibling `:fuel` axis
19427/// already routes through. Lifting it means a future quantized-byte-cap
19428/// axis reaching for the same discipline — a wasm64-target promotion
19429/// raising the wasm32 page and address-space bounds, a hypothetical
19430/// per-Aplicacao heap-max byte-cap, an operator-side page-aligned
19431/// byte-cap admitted by the M4 CR materializer's admission webhook —
19432/// lands as a thin four-closure wrapper rather than re-inlining the
19433/// same four-arm cascade with a fresh page-alignment convention.
19434///
19435/// # Errors
19436///
19437/// Returns `on_zero()` for `value == 0`; returns
19438/// `on_below_quantum(value)` for `value < quantum`; returns
19439/// `on_cap_exceeded(value)` for `value > cap`; returns
19440/// `on_not_quantum_multiple(value)` for `value % quantum != 0`;
19441/// returns `Ok(())` otherwise.
19442pub fn require_positive_quantum_multiple_bounded_u64<E>(
19443 value: u64,
19444 quantum: u64,
19445 cap: u64,
19446 on_zero: impl FnOnce() -> E,
19447 on_below_quantum: impl FnOnce(u64) -> E,
19448 on_cap_exceeded: impl FnOnce(u64) -> E,
19449 on_not_quantum_multiple: impl FnOnce(u64) -> E,
19450) -> Result<(), E> {
19451 if value == 0 {
19452 return Err(on_zero());
19453 }
19454 if value < quantum {
19455 return Err(on_below_quantum(value));
19456 }
19457 if value > cap {
19458 return Err(on_cap_exceeded(value));
19459 }
19460 if !value.is_multiple_of(quantum) {
19461 return Err(on_not_quantum_multiple(value));
19462 }
19463 Ok(())
19464}
19465
19466/// Bracket a typed `Duration` axis with the "zero-floor +
19467/// canonical-form + upper-cap" three-arm gate every typed-`Duration`
19468/// slot in the crate carries. Returns `on_zero()` when `value` is
19469/// `Duration::ZERO`, `on_not_canonical(value)` when `value` carries
19470/// sub-millisecond residue the shared
19471/// [`crate::supervisor::duration_codec`] cannot round-trip losslessly,
19472/// `on_cap_exceeded(value)` when `value > cap`, `Ok(())` otherwise.
19473///
19474/// The three arms fire in canonical `zero → not-canonical → cap` order,
19475/// matching the discipline every existing per-axis inline block already
19476/// applied by hand: the zero-floor arm precedes the canonical-form arm
19477/// so `Duration::ZERO` (whose `subsec_nanos() == 0` makes it accepted
19478/// by the canonical-form predicate) surfaces the self-locating zero
19479/// diagnostic — every per-axis zero variant already documents an
19480/// "omit the axis to express no-bound" remediation — rather than the
19481/// misleading no-op the canonical arm would return; the canonical-form
19482/// arm then precedes the cap arm so a `Duration` that is *both*
19483/// sub-millisecond and above-cap surfaces the more fundamental
19484/// round-trip-shape diagnostic first (the cap's `1ms..=<cap>`
19485/// remediation would be misleading when no integer-ms form of the
19486/// offending value exists). Same ordering discipline the peer
19487/// [`require_positive_bounded_u32`] applies on its two arms — this
19488/// lift makes the three-arm ordering a property of the helper, not a
19489/// per-call-site convention four sites re-derived by hand.
19490///
19491/// Four identical-shape call sites collapse onto this helper — one for
19492/// each typed-`Duration` slot in the crate:
19493///
19494/// * [`crate::AplicacaoSpec::validate`] on
19495/// [`crate::MeshPolicy::timeout`] (zero →
19496/// [`crate::AplicacaoError::PolicyTimeoutZero`], not-canonical →
19497/// [`crate::AplicacaoError::PolicyTimeoutNotCanonical`], cap →
19498/// [`crate::AplicacaoError::PolicyTimeoutExceedsCap`],
19499/// cap = [`crate::POLICY_TIMEOUT_MAX`]) and
19500/// [`crate::CircuitBreaker::window`] (zero →
19501/// [`crate::AplicacaoError::PolicyBreakerZeroWindow`],
19502/// not-canonical →
19503/// [`crate::AplicacaoError::PolicyBreakerWindowNotCanonical`],
19504/// cap → [`crate::AplicacaoError::PolicyBreakerWindowExceedsCap`],
19505/// cap = [`crate::POLICY_BREAKER_WINDOW_MAX`]);
19506/// * [`crate::LimitsSpec::validate`] on
19507/// [`crate::LimitsSpec::wall_clock`] (zero →
19508/// [`crate::LimitsError::WallClockZero`], not-canonical →
19509/// [`crate::LimitsError::WallClockNotCanonical`], cap →
19510/// [`crate::LimitsError::WallClockExceedsCap`],
19511/// cap = [`crate::LIMITS_WALL_CLOCK_MAX`]);
19512/// * [`crate::SupervisorSpec::validate`] on
19513/// [`crate::SupervisorSpec::restart_window`] (zero →
19514/// [`crate::SupervisorError::RestartWindowZero`], not-canonical →
19515/// [`crate::SupervisorError::RestartWindowNotCanonical`], cap →
19516/// [`crate::SupervisorError::RestartWindowExceedsCap`],
19517/// cap = [`crate::SUPERVISOR_RESTART_WINDOW_MAX`]).
19518///
19519/// Peer to [`require_positive_bounded_u32`] /
19520/// [`require_positive_bounded_u64`] on the integer-typed capped axes;
19521/// the four typed-`Duration` axes and the four typed-integer axes now
19522/// route through one helper each, so a future axis reaching for the
19523/// same discipline lands in exactly one place. Generic over the
19524/// caller's error enum so the same helper reaches every crate-level
19525/// [`thiserror`] surface — the ten per-axis error variants remain the
19526/// source of truth for each axis's remediation prose; the helper only
19527/// sequences the three gate arms in canonical order and threads the
19528/// value into the not-canonical / cap arms' discriminator fields.
19529///
19530/// # Errors
19531///
19532/// Returns `on_zero()` for `value.is_zero()`; returns
19533/// `on_not_canonical(value)` when `value` carries sub-millisecond
19534/// residue (`value.subsec_nanos() % 1_000_000 != 0`); returns
19535/// `on_cap_exceeded(value)` for `value > cap`; returns `Ok(())`
19536/// otherwise.
19537pub fn require_positive_canonical_bounded_duration<E>(
19538 value: std::time::Duration,
19539 cap: std::time::Duration,
19540 on_zero: impl FnOnce() -> E,
19541 on_not_canonical: impl FnOnce(std::time::Duration) -> E,
19542 on_cap_exceeded: impl FnOnce(std::time::Duration) -> E,
19543) -> Result<(), E> {
19544 if value.is_zero() {
19545 return Err(on_zero());
19546 }
19547 if !crate::supervisor::duration_codec::is_integer_millisecond_duration(value) {
19548 return Err(on_not_canonical(value));
19549 }
19550 if value > cap {
19551 return Err(on_cap_exceeded(value));
19552 }
19553 Ok(())
19554}
19555
19556/// Bracket a `:versao` requirement-string axis with the shared
19557/// "empty-first, then [`crate::parse_requirement`]" gate pair every
19558/// dep-shaped `:versao` slot carries. Returns `on_empty()` when
19559/// `versao.is_empty()`, `on_invalid(reason)` when
19560/// [`crate::parse_requirement`] rejects the non-empty input, `Ok(())`
19561/// otherwise.
19562///
19563/// The empty-first arm strictly precedes the parse arm so a literal
19564/// `""` value surfaces the self-locating empty diagnostic every
19565/// per-axis error variant already documents an "omit the axis to
19566/// express any-version" remediation for, rather than the misleading
19567/// parse-side no-op — [`crate::parse_requirement("")`][crate::parse_requirement]
19568/// hits `semver::VersionReq::parse("")` which returns
19569/// `Ok(VersionReq { comparators: [] })` (semantically identical to
19570/// [`semver::VersionReq::STAR`]), so without the empty-first arm an
19571/// authored blank `:versao "" ` would silently round-trip as an
19572/// implicit `"*"` — the same "silent widening" footgun the peer
19573/// [`require_positive_bounded_u32`] closes on its zero-floor arm.
19574///
19575/// The three existing call sites — [`crate::dep::Dep::validate`] on
19576/// [`crate::dep::Dep::versao`] (empty → [`crate::DepError::VersaoEmpty`],
19577/// invalid → [`crate::DepError::VersaoInvalid`]),
19578/// [`crate::AplicacaoSpec::validate_membros`] on
19579/// [`crate::aplicacao::Membro::versao`] (empty →
19580/// [`crate::AplicacaoError::MembroVersaoEmpty`], invalid →
19581/// [`crate::AplicacaoError::MembroVersaoInvalid`]), and
19582/// [`crate::SupervisorSpec::validate`] on
19583/// [`crate::supervisor::ChildSpec::versao`] (empty →
19584/// [`crate::SupervisorError::EmptyChildVersion`], invalid →
19585/// [`crate::SupervisorError::ChildVersaoInvalid`]) — each formerly
19586/// inlined this two-arm cascade verbatim. Lifting to one canonical
19587/// entry-point closes the drift footgun structurally: a future
19588/// widening of the accepted requirement-shape (a hypothetical
19589/// git-tag-prefix leniency, a per-axis strictness override, or the
19590/// M4 typed-resolver's `constraint:` axis on
19591/// [`ABSORPTION-ROADMAP.md`]'s per-resolver-step trajectory) reaches
19592/// every dep-shaped `:versao` consumer by one edit at this helper,
19593/// not a coordinated rewrite across three modules.
19594///
19595/// Peer of [`require_positive_bounded_u32`] /
19596/// [`require_positive_bounded_u64`] on the same closure-based
19597/// caller-error-variant discipline — the caller owns the enum
19598/// variant + its self-locating discriminator fields
19599/// (`nome`/`caixa`, `versao`), this helper only sequences the two
19600/// gate arms in canonical order and threads the parser's
19601/// `semver`-shaped reason into the invalid arm's `reason:` field.
19602///
19603/// # Errors
19604///
19605/// Returns `on_empty()` for `versao.is_empty()`; returns
19606/// `on_invalid(reason)` when [`crate::parse_requirement`] rejects
19607/// the non-empty input (the parser's `to_string()` output threaded
19608/// through as the invalid arm's `reason:`); returns `Ok(())`
19609/// otherwise.
19610pub fn require_valid_versao_requirement<E>(
19611 versao: &str,
19612 on_empty: impl FnOnce() -> E,
19613 on_invalid: impl FnOnce(String) -> E,
19614) -> Result<(), E> {
19615 if versao.is_empty() {
19616 return Err(on_empty());
19617 }
19618 if let Err(e) = crate::parse_requirement(versao) {
19619 return Err(on_invalid(e.to_string()));
19620 }
19621 Ok(())
19622}
19623
19624/// Bracket a K8s DNS-1123-label-shaped axis with the shared
19625/// "empty-first, then [`is_dns_1123_label`]" gate pair every Servico-
19626/// name reference slot carries. Returns `on_empty()` when
19627/// `value.is_empty()`, `on_invalid(reason)` when [`is_dns_1123_label`]
19628/// rejects the non-empty input, `Ok(())` otherwise.
19629///
19630/// The empty-first arm strictly precedes the shape arm so a literal
19631/// `""` value surfaces each per-axis error variant's narrower self-
19632/// locating `_Empty` diagnostic (`MembroCaixaEmpty`, `PlacementClusterEmpty`,
19633/// `EntradaParaEmpty`, `NomeEmpty`, `EmptyChildName`, `ModuleEmpty`, …)
19634/// rather than the shared predicate's generic "must not be empty" prose
19635/// — the same "misframed generic diagnostic" footgun the peer
19636/// [`require_valid_versao_requirement`] closes on its empty arm. The
19637/// invalid arm threads the predicate's parser-shaped reason verbatim
19638/// into the caller's `*Invalid { reason }` field so the author's
19639/// remediation prose (which specific violation — length / boundary /
19640/// character-class) flows through unchanged.
19641///
19642/// The eight existing call sites — [`crate::AplicacaoSpec`]'s five
19643/// name-shaped slots (`validate_membro_caixa` on `:membros :caixa`,
19644/// `validate_placement_cluster` on `:placement :clusters`,
19645/// `validate_placement_affinity` on `:placement :affinity`,
19646/// `validate_contrato_caixa` on `:contratos :de`/`:para`,
19647/// `validate_entrada_para` on `:entrada :para`),
19648/// [`crate::SupervisorSpec::validate`] on `:children :caixa`,
19649/// [`crate::manifest::Caixa::validate_nome`] on `:nome`, and
19650/// [`crate::upgrade::validate_module`] on `:upgrade-from :module` —
19651/// each formerly inlined this two-arm cascade verbatim. Lifting to one
19652/// canonical entry-point closes the drift footgun structurally: a
19653/// future widening of the accepted DNS-1123-label shape (a hypothetical
19654/// IDN-Punycode-accepting variant, a per-axis strictness override for
19655/// the M4 CR materializer's `spec.name` axes, or the future
19656/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's admission
19657/// webhook floor) reaches every name-shaped consumer by one edit at
19658/// this helper, not a coordinated rewrite across three modules.
19659///
19660/// Peer of [`require_valid_versao_requirement`] on the same closure-
19661/// based caller-error-variant discipline — the caller owns the enum
19662/// variant + its self-locating discriminator fields (`caixa`, `cluster`,
19663/// `affinity`, `nome`, `slot`, `kind`, `module`, …), this helper only
19664/// sequences the two gate arms in canonical order and threads the
19665/// predicate's shape-shaped reason into the invalid arm's `reason:`
19666/// field.
19667///
19668/// # Errors
19669///
19670/// Returns `on_empty()` for `value.is_empty()`; returns
19671/// `on_invalid(reason)` when [`is_dns_1123_label`] rejects the
19672/// non-empty input (the predicate's parser-shaped reason threaded
19673/// through as the invalid arm's `reason:`); returns `Ok(())` otherwise.
19674pub fn require_valid_dns_1123_label<E>(
19675 value: &str,
19676 on_empty: impl FnOnce() -> E,
19677 on_invalid: impl FnOnce(String) -> E,
19678) -> Result<(), E> {
19679 if value.is_empty() {
19680 return Err(on_empty());
19681 }
19682 if let Err(reason) = is_dns_1123_label(value) {
19683 return Err(on_invalid(reason));
19684 }
19685 Ok(())
19686}
19687
19688/// Bracket a sandboxed-relative `.lisp`-terminating path axis with the
19689/// shared "empty → absolute → parent-escape → non-`.lisp`-extension"
19690/// four-arm gate every author-supplied M2 tatara-lisp source-path slot
19691/// on the caixa surface carries. Delegates to
19692/// [`is_sandboxed_relative_path`] for the three structural arms and to
19693/// [`is_lisp_extension`] for the extension arm; returns each arm's
19694/// caller-owned error variant via the four `FnOnce` closures.
19695///
19696/// The arm ordering (`Empty → Absolute → ParentEscape → NonLisp`) is
19697/// canonical across every existing per-axis site — a path that is
19698/// *both* sandbox-escaping and non-`.lisp` surfaces the more
19699/// fundamental sandbox-shape diagnostic first (the `.lisp` remediation
19700/// would be misleading when the offending path can never resolve under
19701/// the caixa root anyway; the canonical fix collapses both into "pin a
19702/// relative `.lisp` path under the caixa root"). Same
19703/// smallest-scope-arm-fires-last posture the peer
19704/// [`require_positive_bounded_u32`] /
19705/// [`require_positive_canonical_bounded_duration`] chains follow on the
19706/// integer / duration axes, and the same posture every per-axis inline
19707/// pre-lift block already applied by hand
19708/// ([`crate::behavior::BehaviorError`]'s `EmptyPath` → `AbsolutePath`
19709/// → `ParentEscape` → `NonLispExtension` chain,
19710/// [`crate::upgrade::UpgradeError`]'s `EmptyScript` → `AbsoluteScript`
19711/// → `ParentEscapeScript` → `NonLispExtensionScript` chain).
19712///
19713/// Two identical-shape call sites collapse onto this helper — one for
19714/// each M2 typed path-slot the wasm-engine reads through
19715/// `tatara_lisp::read`:
19716///
19717/// * [`crate::behavior::BehaviorSpec::validate`] on
19718/// `:behavior :on-*` callback paths — every arm carries the slot
19719/// name verbatim through the closure's caller-side capture (empty
19720/// → [`crate::behavior::BehaviorError::EmptyPath`], absolute →
19721/// [`crate::behavior::BehaviorError::AbsolutePath`], parent-escape
19722/// → [`crate::behavior::BehaviorError::ParentEscape`], non-`.lisp`
19723/// → [`crate::behavior::BehaviorError::NonLispExtension`]);
19724/// * [`crate::upgrade::UpgradeInstruction::validate`]'s `StateChange`
19725/// arm on `:upgrade-from :state-change :script` (empty →
19726/// [`crate::upgrade::UpgradeError::EmptyScript`], absolute →
19727/// [`crate::upgrade::UpgradeError::AbsoluteScript`], parent-escape
19728/// → [`crate::upgrade::UpgradeError::ParentEscapeScript`],
19729/// non-`.lisp` →
19730/// [`crate::upgrade::UpgradeError::NonLispExtensionScript`]).
19731///
19732/// Peer of the sibling `require_positive_bounded_u32` /
19733/// `require_positive_bounded_u64` /
19734/// `require_positive_canonical_bounded_duration` /
19735/// `require_valid_versao_requirement` / `require_valid_dns_1123_label`
19736/// helpers on the same closure-based caller-error-variant discipline —
19737/// the caller owns the enum variant + its self-locating discriminator
19738/// fields (`slot`, `path`, `script`), this helper only sequences the
19739/// four gate arms in canonical order and invokes the caller's closure
19740/// on the offending arm.
19741///
19742/// PRIME DIRECTIVE promotion: the two-consumer duplication budget
19743/// (THEORY.md §I.3.5: "every recurring shape becomes a generator
19744/// before it becomes a pattern; every pattern becomes a library before
19745/// it becomes duplicated code. The duplication budget is zero.")
19746/// promotes the four-step cascade to a typed substrate-side helper on
19747/// the same trajectory the [`is_sandboxed_relative_path`] /
19748/// [`is_lisp_extension`] primitives already follow. A future third
19749/// consumer — the `:bibliotecas` per-entry tatara-lisp source-file
19750/// axis, the `:exe` `:kind Binario` entry-point axis, the M2.5
19751/// wasm-engine pre-warm hook axis, the future `mesh.pleme.io/v1alpha1/Caixa`
19752/// CR materializer's per-path validator — lands as a thin
19753/// four-closure wrapper rather than re-inlining the same four-arm
19754/// cascade.
19755///
19756/// # Errors
19757///
19758/// Returns `on_empty()` when `path` is empty; returns `on_absolute()`
19759/// when `path` is absolute; returns `on_parent_escape()` when `path`
19760/// carries a [`std::path::Component::ParentDir`] component anywhere;
19761/// returns `on_non_lisp()` when `path`'s terminating extension is not
19762/// exactly [`LISP_SOURCE_EXTENSION`]; returns `Ok(())` otherwise.
19763pub fn require_sandboxed_lisp_path<E>(
19764 path: &Path,
19765 on_empty: impl FnOnce() -> E,
19766 on_absolute: impl FnOnce() -> E,
19767 on_parent_escape: impl FnOnce() -> E,
19768 on_non_lisp: impl FnOnce() -> E,
19769) -> Result<(), E> {
19770 match is_sandboxed_relative_path(path) {
19771 Ok(()) => {}
19772 Err(PathShapeViolation::Empty) => return Err(on_empty()),
19773 Err(PathShapeViolation::Absolute) => return Err(on_absolute()),
19774 Err(PathShapeViolation::ParentEscape) => return Err(on_parent_escape()),
19775 }
19776 if !is_lisp_extension(path) {
19777 return Err(on_non_lisp());
19778 }
19779 Ok(())
19780}
19781
19782/// Bracket a per-list uniqueness gate with the shared "insert into
19783/// `seen`; caller-shaped `Err` on the second occurrence" gate every
19784/// declaration-order-preserving `Vec`-authored slot in caixa-core
19785/// carries. Delegates to [`std::collections::HashSet::insert`] verbatim
19786/// (which returns `true` on first insertion, `false` on repeat), then
19787/// invokes the caller's `on_duplicate` closure only on the duplicate
19788/// arm — keeping the hot path (the unique case) allocation-free.
19789///
19790/// The ten existing call sites — [`crate::AplicacaoSpec::validate`]'s
19791/// four per-list uniqueness gates (`:membros :caixa` →
19792/// [`crate::AplicacaoError::MembroDuplicate`], `:placement :clusters` →
19793/// [`crate::AplicacaoError::PlacementClusterDuplicate`],
19794/// `:entrada :paths` → [`crate::AplicacaoError::EntradaPathDuplicate`],
19795/// `:contratos` on the six-tuple typed-edge identity key →
19796/// [`crate::AplicacaoError::ContratoDuplicate`]),
19797/// [`crate::SupervisorSpec::validate`] on `:children :caixa`
19798/// ([`crate::SupervisorError::DuplicateChildCaixa`]),
19799/// [`crate::manifest::Caixa`]'s four per-list uniqueness gates
19800/// ([`crate::manifest::Caixa::validate_deps`] on `:deps` and `:deps-dev`
19801/// → [`crate::DepError::DuplicateNome`],
19802/// [`crate::manifest::Caixa::validate_code_paths`] on
19803/// `:bibliotecas`/`:exe`/`:servicos` →
19804/// [`crate::ManifestError::CodePathDuplicate`],
19805/// [`crate::manifest::Caixa::validate_etiquetas`] on `:etiquetas` →
19806/// [`crate::ManifestError::EtiquetaDuplicate`],
19807/// [`crate::manifest::Caixa::validate_autores`] on `:autores` →
19808/// [`crate::ManifestError::AutorDuplicate`]), and
19809/// [`crate::dep::Dep`]'s [`crate::DepError::CaracteristicaDuplicate`]
19810/// gate on `:caracteristicas` — each formerly inlined the same three-
19811/// line
19812/// ```ignore
19813/// if !seen.insert(key) {
19814/// return Err(<Variant> { … });
19815/// }
19816/// ```
19817/// shape by hand, differing only in the seen-set key type and the
19818/// caller's [`thiserror`] variant. Lifting to one canonical entry-point
19819/// closes the drift footgun structurally: a future tightening of the
19820/// per-list uniqueness discipline (a declaration-order pin on the
19821/// reported entry index, an instrumentation hook for the operator's
19822/// audit trail, the M4 CR materializer's admission-webhook per-list
19823/// invariant) reaches every consumer by one edit at this helper, not
19824/// a coordinated rewrite across every per-list gate in the crate. The
19825/// per-axis error variants remain the source of truth for each axis's
19826/// remediation prose — this helper only sequences the insert-and-check
19827/// pair.
19828///
19829/// Same set-not-multiset discipline every peer `Duplicate*` variant
19830/// documents. The typed key `K` is generic so both `&str`-shaped
19831/// callers (nine sites) and the tuple-shaped
19832/// [`crate::AplicacaoError::ContratoDuplicate`] typed-edge identity
19833/// carrier route through one helper; the caller owns the enum variant
19834/// + its self-locating discriminator fields, this helper only sequences
19835/// the insert-and-check pair in canonical `insert → on_duplicate` order.
19836/// Sibling to the peer `require_positive_bounded_*` /
19837/// `require_positive_canonical_bounded_duration` /
19838/// `require_valid_versao_requirement` / `require_valid_dns_1123_label`
19839/// helpers on the same closure-based caller-error-variant discipline.
19840///
19841/// # Errors
19842///
19843/// Returns `on_duplicate()` when `key` was already in `seen` (the
19844/// [`std::collections::HashSet::insert`] call returns `false`); returns
19845/// `Ok(())` otherwise.
19846pub fn insert_first_seen<K, E, S>(
19847 seen: &mut std::collections::HashSet<K, S>,
19848 key: K,
19849 on_duplicate: impl FnOnce() -> E,
19850) -> Result<(), E>
19851where
19852 K: std::hash::Hash + Eq,
19853 S: std::hash::BuildHasher,
19854{
19855 if seen.insert(key) {
19856 Ok(())
19857 } else {
19858 Err(on_duplicate())
19859 }
19860}
19861
19862/// Test-side pin that asserts a renderer-crate `pub use caixa_core::X;`
19863/// re-export shares both the byte value *and* the `&'static str`
19864/// allocation of its canonical `caixa_core::X` declaration — the
19865/// stronger predicate than a plain `assert_eq!` byte-equality check.
19866///
19867/// The canonical drift footgun this closes: a renderer crate silently
19868/// carries a sibling `pub const X: &str = "…";` (or a copy-pasted
19869/// `pub const X: &str = caixa_core::X;` shape whose right-hand side
19870/// materializes a fresh promoted-static allocation with the same
19871/// bytes) instead of `pub use caixa_core::X;`. A byte-only `assert_eq!`
19872/// on the value would pass — the strings are equal — but the two
19873/// declarations point at two different `&'static` allocations, so a
19874/// future canonical-side rebrand (`caixa_core::X` migrates from
19875/// `"foo"` to `"foo-v2"`) silently drifts the two apart, with the
19876/// apply-time symptom (the cluster-side CRD schema drops the malformed
19877/// axis, the operator's dispatch loop misses the renamed key, the
19878/// Cilium data plane silently reroutes past the renamed L4/L7 rule)
19879/// far from the drift commit's source. Byte-equality misses this
19880/// class of drift; static-data identity via [`std::ptr::eq`] catches
19881/// it structurally.
19882///
19883/// Lifted from the seventy-five per-`_re_export_points_at_caixa_core_
19884/// canonical` test bodies formerly inlined verbatim across
19885/// [`caixa-mesh`][mesh] (49 tests), [`caixa-flux`][flux] (21 tests),
19886/// and [`caixa-helm`][helm] (5 tests) — each formerly carried the same
19887/// two-arm `assert_eq!(<LOCAL>, caixa_core::<LOCAL>);` + `assert!(std
19888/// ::ptr::eq(<LOCAL>.as_ptr(), caixa_core::<LOCAL>.as_ptr()), "…must
19889/// be a re-export of caixa_core::…, not a sibling `pub const`…");`
19890/// pair by hand, differing only in the local `<LOCAL>` identifier the
19891/// diagnostic names. The lifted helper puts the canonical two-arm
19892/// gate in exactly one place so the next per-renderer re-export pin
19893/// (the future [`caixa-otel`] telemetry-pipeline renderer's per-CR
19894/// axis re-exports, the M4 [`mesh.pleme.io/v1alpha1/Aplicacao`] CR
19895/// materializer's per-spec-axis re-exports, the future per-Supervisor
19896/// reconciler's per-`:children` axis re-exports) lands on this
19897/// helper by construction rather than by copying the boilerplate.
19898///
19899/// Same trajectory as the sibling [`require_kind`] /
19900/// [`require_single_servico`] cross-renderer-shared-gate lifts on the
19901/// production-side axis; this closes the peer test-side re-export-
19902/// identity-gate axis.
19903///
19904/// # Panics
19905///
19906/// Panics via [`assert_eq!`] when the two byte-strings differ; panics
19907/// via [`assert!`] on the [`std::ptr::eq`] arm when the two share
19908/// bytes but point at different `&'static str` allocations. The
19909/// `name` argument names the local re-export for the failure message
19910/// so the diagnostic reads `KUBE_KEY_SPEC must be a re-export of
19911/// caixa_core::KUBE_KEY_SPEC, …` — pointing at the offending
19912/// re-export site, not just at the assertion.
19913///
19914/// [mesh]: https://docs.rs/caixa-mesh
19915/// [flux]: https://docs.rs/caixa-flux
19916/// [helm]: https://docs.rs/caixa-helm
19917pub fn assert_str_reexport_identity(name: &str, local: &'static str, canonical: &'static str) {
19918 assert_eq!(
19919 local, canonical,
19920 "{name} must byte-equal caixa_core::{name}"
19921 );
19922 assert!(
19923 std::ptr::eq(local.as_ptr(), canonical.as_ptr()),
19924 "{name} must be a re-export of caixa_core::{name}, \
19925 not a sibling `pub const` that happens to carry the same string \
19926 — drift between the two is the canonical footgun this lift closes"
19927 );
19928}
19929
19930/// Extension methods on [`serde_yaml::Mapping`] that lift the per-key
19931/// scalar-promotion boilerplate every K8s-artifact-emitter across
19932/// `caixa-mesh`, `caixa-flux`, `caixa-helm`, and `caixa-core::render`
19933/// carries: the canonical `mapping.insert(Value::String(key.into()),
19934/// value)` three-liner the schema-key axis of every emitted YAML
19935/// document tunnels a `&'static str` key axis-name through.
19936///
19937/// Five methods form the primitive quintuple — one per non-Null
19938/// primitive [`serde_yaml::Value`] variant the K8s-artifact-emit
19939/// surface actually reaches for as a leaf payload:
19940///
19941/// * [`Self::insert_str_key`] — insert with a `&str` key and any
19942/// fully-built [`serde_yaml::Value`]. The building block every
19943/// other renderer helper (`yaml_string_mapping`, `label_selector`,
19944/// `kube_resource_skeleton`, `single_field_overlay`) composes on
19945/// top of.
19946/// * [`Self::insert_string`] — insert with a `&str` key and an
19947/// `Into<String>` value that gets auto-promoted to
19948/// [`serde_yaml::Value::String`]. The string-scalar-valued-field
19949/// shape every schema-typed `apiVersion` / `kind` /
19950/// `metadata.namespace` / `port.protocol` / `hostname` /
19951/// `path.value` axis emission uses — collapses the two-step
19952/// `insert_str_key(K, Value::String(V.into()))` boilerplate onto
19953/// one direct call.
19954/// * [`Self::insert_number`] — insert with a `&str` key and an
19955/// `Into<serde_yaml::Number>` value that gets auto-promoted to
19956/// [`serde_yaml::Value::Number`]. The integer-scalar-valued-field
19957/// shape every schema-typed `port` / `targetPort` / `attempts` /
19958/// `maxFailures` / `hostPort` axis emission uses — collapses the
19959/// two-step `insert_str_key(K, Value::Number(N.into()))`
19960/// boilerplate onto one direct call.
19961/// * [`Self::insert_mapping`] — insert with a `&str` key and a
19962/// [`serde_yaml::Mapping`] value that gets auto-promoted to
19963/// [`serde_yaml::Value::Mapping`]. The nested-Mapping-valued-field
19964/// shape every schema-typed `metadata` / `spec` / `spec.rules[].path`
19965/// / `toPorts[].rules` sub-block emission uses — collapses the
19966/// two-step `insert_str_key(K, Value::Mapping(m))` boilerplate
19967/// onto one direct call.
19968/// * [`Self::insert_sequence`] — insert with a `&str` key and a
19969/// `Vec<serde_yaml::Value>` value that gets auto-promoted to
19970/// [`serde_yaml::Value::Sequence`]. The list-shape-valued-field
19971/// shape every schema-typed `spec.ingress[].fromEndpoints` /
19972/// `spec.ingress[].toPorts` / `spec.hostnames` / `spec.rules` list
19973/// emission uses — collapses the two-step
19974/// `insert_str_key(K, Value::Sequence(v))` boilerplate onto one
19975/// direct call.
19976///
19977/// A sibling method — [`Self::entry_str_key`] — closes the entry-API
19978/// twin of [`Self::insert_str_key`] on the same `&str → Value::String`
19979/// key-promotion axis: the [`serde_yaml::Mapping::entry`] method's
19980/// `Value` parameter demands the same `Value::String(<K>.into())`
19981/// wrapping every fresh-emit site's `insert_str_key` call closes, but
19982/// on the idempotent-upsert axis (where callers compose
19983/// `.or_insert(...)` / `.or_insert_with(...)` / `.and_modify(...)` /
19984/// `.or_default()` on the returned entry handle) rather than the
19985/// fresh-emit axis. Same key-promotion contract, different downstream
19986/// API surface — so a future rebrand of the promotion (e.g. to
19987/// [`serde_yaml::Value::Tagged`] under a K8s Server-Side-Apply typed-
19988/// field-ownership axis) reaches both fresh-emit and upsert sites
19989/// through one lift.
19990///
19991/// See each method's docstring for its compounding rationale.
19992pub trait MappingExt {
19993 /// Insert `(key, value)` into `self` with `key` promoted to a
19994 /// [`serde_yaml::Value::String`]. Returns the prior value at that
19995 /// key, mirroring [`serde_yaml::Mapping::insert`].
19996 ///
19997 /// The canonical shape ~48 call sites across the caixa-side
19998 /// renderer surface (`caixa-mesh` per-`CiliumNetworkPolicy` /
19999 /// `Gateway` / `HTTPRoute` construction, `caixa-flux` per-
20000 /// `GitRepository` / `HelmRelease` / `Kustomization` construction,
20001 /// `caixa-helm` per-`Chart.yaml` / `values.yaml` construction,
20002 /// `caixa-core::render` per-skeleton construction) previously
20003 /// carried inline as the three-line block
20004 /// `mapping.insert(serde_yaml::Value::String(<KEY>.into()),
20005 /// <VALUE>)` — three per-call boilerplate axes (`serde_yaml::` path
20006 /// re-quote, `Value::String(_)` promotion, `.into()` `&str → String`
20007 /// coercion) around a two-token semantic payload (`<KEY>`, `<VALUE>`).
20008 ///
20009 /// Lifting collapses the boilerplate into one method call the
20010 /// caller reads as intent (`mapping.insert_str_key(<KEY>, <VALUE>)`
20011 /// — "insert this schema key with this rendered value") rather
20012 /// than five hand-spelled positional artifacts. The next renderer
20013 /// to land — the per-`:politicas` `CiliumClusterwideEnvoyConfig`
20014 /// emitter (MESH-COMPOSITION §III.2 #3), the `app-operator`'s
20015 /// typed `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (§III.2
20016 /// #5), the M4 cross-cluster fan-out's per-cluster `Service` /
20017 /// `HTTPRoute backendRefs` emission, the future `caixa-otel`
20018 /// OpenTelemetry-Collector pipeline emitter — gets the canonical
20019 /// key-scalar-promotion for free with one method call, instead of
20020 /// re-inlining the three-line block.
20021 ///
20022 /// Peer to the sibling render-side helpers on the
20023 /// [`serde_yaml::Value`]-construction surface:
20024 /// [`yaml_string_mapping`] (string→string mapping), [`label_selector`]
20025 /// (K8s `LabelSelector` shape), [`kube_resource_skeleton`] (K8s
20026 /// `apiVersion`+`kind`+`metadata` skeleton), [`single_field_overlay`]
20027 /// (`Option<T>` → single-key overlay). Each closes a distinct axis
20028 /// of the K8s-artifact-emit surface's "same shape, written N times"
20029 /// duplication; this one closes the per-key insert primitive the
20030 /// other four all compose on top of.
20031 fn insert_str_key(&mut self, key: &str, value: serde_yaml::Value) -> Option<serde_yaml::Value>;
20032
20033 /// Insert `(key, Value::String(value.into()))` into `self` — the
20034 /// string-scalar-valued-field emission shape that combines
20035 /// [`Self::insert_str_key`]'s `&str → Value::String` key promotion
20036 /// with an automatic `Value::String` promotion of an `Into<String>`
20037 /// value. Returns the prior value at that key, mirroring
20038 /// [`serde_yaml::Mapping::insert`].
20039 ///
20040 /// The canonical shape ~17 production call sites across the caixa-
20041 /// side renderer surface previously carried inline as the three-
20042 /// line block `mapping.insert_str_key(<KEY>,
20043 /// serde_yaml::Value::String(<VALUE>.into() | .clone() |
20044 /// .to_string()))` — the two-token semantic payload (`<KEY>`,
20045 /// `<VALUE>`) buried under three boilerplate axes (`serde_yaml::`
20046 /// path re-quote, `Value::String(_)` promotion, the
20047 /// `.into() | .clone() | .to_string()` `→ String` coercion).
20048 ///
20049 /// Sites lifted:
20050 ///
20051 /// * caixa-mesh's `programs_for_aplicacao` per-`:membros` entry
20052 /// (`FLEET_PROGRAMS_KEY_NAME` / `FLEET_PROGRAMS_KEY_VERSAO` /
20053 /// `FLEET_PROGRAMS_KEY_APLICACAO`);
20054 /// * caixa-mesh's `cilium_network_policies` per-`toPorts[]` port
20055 /// entry (`KUBE_KEY_PORT` / `KUBE_KEY_PROTOCOL`) and per-HTTP-
20056 /// rule `CILIUM_KEY_PATH` L7 predicate;
20057 /// * caixa-mesh's `gateway_routes` per-`Gateway` listener block
20058 /// (`GATEWAY_API_KEY_NAME` /
20059 /// [`crate::GATEWAY_API_KEY_HOSTNAME`] / `GATEWAY_API_KEY_PROTOCOL`)
20060 /// and `spec.gatewayClassName`;
20061 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute` `parentRefs[]`
20062 /// name, per-rule `matches[].path.{type,value}` prefix-match, and
20063 /// per-rule `backendRefs[].name` backend-target;
20064 /// * caixa-flux's `programs_yaml_entry` per-entry `name` /
20065 /// `namespace` axes;
20066 /// * caixa-core `kube_resource_skeleton`'s `apiVersion` / `kind`
20067 /// scalar heads (the two production emit sites the prior
20068 /// `Value::String(_.to_string())` inline shape sat at).
20069 ///
20070 /// Lifting collapses the boilerplate into one method call the
20071 /// caller reads as intent (`mapping.insert_string(<KEY>, <VALUE>)`
20072 /// — "insert a string-scalar-typed field named `KEY` with rendered
20073 /// value `VALUE`") rather than four hand-spelled positional
20074 /// artifacts. The next renderer to land — the per-`:politicas`
20075 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy string-
20076 /// scalar axes are `name` / `namespace` / `defaultAction`), the
20077 /// `app-operator`'s typed `mesh.pleme.io/v1alpha1/Aplicacao` CR
20078 /// materializer (per-`spec.selectors[]` `name` / per-`spec.gates[]`
20079 /// string-typed axes), the M4 cross-cluster fan-out's per-cluster
20080 /// `Service.spec.ports[].name` / `HTTPRoute.spec.rules[].filters[].
20081 /// requestHeaderModifier.set[].name` string-scalar emission, the
20082 /// future `caixa-otel` OpenTelemetry-Collector `pipelines.traces.
20083 /// receivers[].endpoint` string-scalar emission — gets the canonical
20084 /// string-scalar-valued-field shape for free with one method call,
20085 /// instead of re-inlining the three-token
20086 /// `Value::String(_.into() | .clone() | .to_string())` block.
20087 ///
20088 /// Peer to [`Self::insert_str_key`] on the sibling any-Value axis —
20089 /// the two together form the "one method call per emission axis"
20090 /// primitive pair the K8s-artifact-emit surface's "same shape,
20091 /// written N times" duplication (THEORY.md §I.3.5) collapses onto.
20092 fn insert_string<V: Into<String>>(&mut self, key: &str, value: V) -> Option<serde_yaml::Value>;
20093
20094 /// Insert `(key, Value::Number(value.into()))` into `self` — the
20095 /// integer-scalar-valued-field emission shape that combines
20096 /// [`Self::insert_str_key`]'s `&str → Value::String` key promotion
20097 /// with an automatic [`serde_yaml::Value::Number`] promotion of an
20098 /// `Into<serde_yaml::Number>` value. Returns the prior value at that
20099 /// key, mirroring [`serde_yaml::Mapping::insert`].
20100 ///
20101 /// The canonical shape 2 production call sites across `caixa-mesh`
20102 /// previously carried inline as the three-token block
20103 /// `mapping.insert_str_key(<KEY>, serde_yaml::Value::Number(<N>.into()))`
20104 /// — the two-token semantic payload (`<KEY>`, `<N>`) buried under
20105 /// three boilerplate axes (`serde_yaml::` path re-quote,
20106 /// `Value::Number(_)` promotion, the `<N>.into()` typed-integer →
20107 /// [`serde_yaml::Number`] coercion) around a numeric constant or
20108 /// typed field the caller already carries as `u16` / `u32` / `u64`.
20109 ///
20110 /// Sites lifted:
20111 ///
20112 /// * caixa-mesh's `gateway_routes` per-`Gateway` `spec.listeners[].port`
20113 /// external HTTP listener port (`KUBE_KEY_PORT` around the lifted
20114 /// [`crate::GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`] `u16` const,
20115 /// cd60fde);
20116 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute.spec.rules[].backendRefs[].port`
20117 /// backend-target Servico port (`KUBE_KEY_PORT` around the
20118 /// [`crate::AplicacaoSpec`]-side `entrada.port` `u16` field the
20119 /// `:entrada :port` typed slot flows through).
20120 ///
20121 /// Lifting collapses the boilerplate into one method call the
20122 /// caller reads as intent (`mapping.insert_number(<KEY>, <N>)` —
20123 /// "insert a numeric-scalar-typed field named `KEY` with the typed
20124 /// integer `N`") rather than three hand-spelled positional artifacts.
20125 /// The next renderer to land — the per-`:politicas`
20126 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
20127 /// integer-scalar axes are the Envoy circuit-breaker
20128 /// `maxRequests` / `maxPendingRequests` / `maxConnections` count
20129 /// fields and the Cilium ratelimit `requestPerUnit` field,
20130 /// MESH-COMPOSITION §III.2 #3), the `app-operator`'s typed
20131 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (per-`spec.
20132 /// selectors[]` integer-scored `weight` fields, §III.2 #5), the
20133 /// M4 cross-cluster fan-out's per-cluster
20134 /// `Service.spec.ports[].{port, targetPort, nodePort}` /
20135 /// `HTTPRoute.spec.rules[].backendRefs[].{port, weight}`
20136 /// integer-scalar emission, the future `caixa-otel`
20137 /// OpenTelemetry-Collector `service.pipelines.traces.receivers[].
20138 /// grpc.max_recv_msg_size_mib` integer-scalar emission — gets the
20139 /// canonical integer-scalar-valued-field shape for free with one
20140 /// method call, instead of re-inlining the three-token
20141 /// `Value::Number(_.into())` block.
20142 ///
20143 /// The `Into<serde_yaml::Number>` bound accepts every numeric
20144 /// primitive [`serde_yaml::Number`] declares `From` for
20145 /// (`i8`..=`i64`, `u8`..=`u64`, `f32`, `f64`) — the same coverage
20146 /// the two production sites reach through with their `u16` port
20147 /// fields and the same coverage every future numeric-scalar
20148 /// emission (the K8s `Service.spec.ports[].targetPort` `IntOrString`
20149 /// integer arm, the `HTTPRoute.spec.rules[].backendRefs[].weight`
20150 /// `int32` axis, the Envoy `maxRequests` `uint32` axis) reaches
20151 /// through with matching typed integer fields.
20152 ///
20153 /// Peer to [`Self::insert_string`] on the sibling string-scalar axis
20154 /// and to [`Self::insert_mapping`] / [`Self::insert_sequence`] on
20155 /// the sibling nested-Mapping / list-shape axes — the five together
20156 /// with [`Self::insert_str_key`] form the "one method call per
20157 /// emission axis" primitive quintuple the K8s-artifact-emit
20158 /// surface's "same shape, written N times" duplication (THEORY.md
20159 /// §I.3.5) collapses onto: `insert_str_key` for any-Value inserts,
20160 /// `insert_string` for the string-scalar-valued-field shape,
20161 /// `insert_number` for the integer-scalar-valued-field shape,
20162 /// `insert_mapping` for the nested-Mapping-valued-field shape,
20163 /// `insert_sequence` for the list-shape-valued-field shape.
20164 fn insert_number<N: Into<serde_yaml::Number>>(
20165 &mut self,
20166 key: &str,
20167 value: N,
20168 ) -> Option<serde_yaml::Value>;
20169
20170 /// Insert `(key, Value::Mapping(value))` into `self` — the
20171 /// nested-Mapping-valued-field emission shape that combines
20172 /// [`Self::insert_str_key`]'s `&str → Value::String` key promotion
20173 /// with an automatic [`serde_yaml::Value::Mapping`] promotion of a
20174 /// [`serde_yaml::Mapping`] value. Returns the prior value at that
20175 /// key, mirroring [`serde_yaml::Mapping::insert`].
20176 ///
20177 /// The canonical shape ~6 production call sites across the caixa-
20178 /// side renderer surface previously carried inline as the three-
20179 /// token block `mapping.insert_str_key(<KEY>,
20180 /// serde_yaml::Value::Mapping(<INNER>))` — a two-token semantic
20181 /// payload (`<KEY>`, `<INNER>`) buried under a two-axis boilerplate
20182 /// (`serde_yaml::` path re-quote, `Value::Mapping(_)` promotion)
20183 /// around a `Mapping` variable the caller already built.
20184 ///
20185 /// Sites lifted:
20186 ///
20187 /// * caixa-mesh's `cilium_network_policies` per-`toPorts[]`
20188 /// `rules:` L7-introspection sub-block (`KUBE_KEY_RULES` around
20189 /// the built `rules` Mapping);
20190 /// * caixa-mesh's `cilium_network_policies` per-`CiliumNetworkPolicy`
20191 /// `spec:` block (`KUBE_KEY_SPEC` around the built `policy_spec`
20192 /// Mapping);
20193 /// * caixa-mesh's `gateway_routes` per-`Gateway` `spec:` block
20194 /// (`KUBE_KEY_SPEC` around the built `g_spec` Mapping);
20195 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute.spec.rules[]`
20196 /// `matches[].path:` sub-block (`GATEWAY_API_KEY_PATH` around the
20197 /// built `path_match` Mapping);
20198 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute` `spec:` block
20199 /// (`KUBE_KEY_SPEC` around the built `r_spec` Mapping);
20200 /// * caixa-core's `kube_resource_skeleton` per-CR
20201 /// `metadata:` sub-block (`KUBE_KEY_METADATA` around the built
20202 /// `metadata_map` Mapping).
20203 ///
20204 /// Lifting collapses the boilerplate into one method call the
20205 /// caller reads as intent (`mapping.insert_mapping(<KEY>, <INNER>)`
20206 /// — "insert a nested-Mapping-typed sub-block named `KEY` with the
20207 /// built inner `INNER`") rather than three hand-spelled positional
20208 /// artifacts. The next renderer to land — the per-`:politicas`
20209 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
20210 /// nested-Mapping sub-blocks are `metadata:` / `spec:` /
20211 /// `spec.resources[]`), the `app-operator`'s typed
20212 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer
20213 /// (per-`spec.selectors[]` and per-`spec.gates[]` sub-blocks), the
20214 /// M4 cross-cluster fan-out's per-cluster `Service.spec` /
20215 /// `HTTPRoute.spec` sub-block emission, the future `caixa-otel`
20216 /// OpenTelemetry-Collector per-pipeline `receivers:` /
20217 /// `processors:` / `exporters:` nested-Mapping emission — gets the
20218 /// canonical nested-Mapping-valued-field shape for free with one
20219 /// method call, instead of re-inlining the three-token
20220 /// `Value::Mapping(_)` promotion.
20221 ///
20222 /// Peer to [`Self::insert_string`] on the sibling scalar-value axis
20223 /// and [`Self::insert_sequence`] on the sibling list-shape axis —
20224 /// the four together with [`Self::insert_str_key`] form the "one
20225 /// method call per emission axis" primitive quadruple the K8s-
20226 /// artifact-emit surface's "same shape, written N times" duplication
20227 /// (THEORY.md §I.3.5) collapses onto: `insert_str_key` for any-Value
20228 /// inserts, `insert_string` for the string-scalar-valued-field
20229 /// shape, `insert_mapping` for the nested-Mapping-valued-field
20230 /// shape, `insert_sequence` for the list-shape-valued-field shape.
20231 fn insert_mapping(
20232 &mut self,
20233 key: &str,
20234 value: serde_yaml::Mapping,
20235 ) -> Option<serde_yaml::Value>;
20236
20237 /// Insert `(key, Value::Sequence(value))` into `self` — the
20238 /// list-shape-valued-field emission shape that combines
20239 /// [`Self::insert_str_key`]'s `&str → Value::String` key promotion
20240 /// with an automatic [`serde_yaml::Value::Sequence`] promotion of a
20241 /// pre-built `Vec<serde_yaml::Value>` value. Returns the prior
20242 /// value at that key, mirroring [`serde_yaml::Mapping::insert`].
20243 ///
20244 /// The canonical shape 4 production call sites across `caixa-mesh`
20245 /// previously carried inline as the three-token block
20246 /// `mapping.insert_str_key(<KEY>, serde_yaml::Value::Sequence(<VEC>))`
20247 /// — a two-token semantic payload (`<KEY>`, `<VEC>`) buried under a
20248 /// two-axis boilerplate (`serde_yaml::` path re-quote,
20249 /// `Value::Sequence(_)` promotion) around a `Vec<Value>` variable
20250 /// the caller already built.
20251 ///
20252 /// Sites lifted:
20253 ///
20254 /// * caixa-mesh's `cilium_network_policies` per-`CiliumNetworkPolicy`
20255 /// `spec.ingress[].fromEndpoints:` singleton-list (`CILIUM_KEY_FROM_ENDPOINTS`
20256 /// around a `vec![from_endpoint]` selector wrapper);
20257 /// * caixa-mesh's `cilium_network_policies` per-`CiliumNetworkPolicy`
20258 /// `spec.ingress[].toPorts:` list (`CILIUM_KEY_TO_PORTS` around the
20259 /// built `to_ports_seq` per-edge port-and-L7-rule vec);
20260 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute` `spec.hostnames:`
20261 /// singleton-list (`GATEWAY_API_KEY_HOSTNAMES` around a
20262 /// `vec![Value::String(entrada.host…)]` host wrapper);
20263 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute` `spec.rules:`
20264 /// list (`KUBE_KEY_RULES` around the built `rules` per-path
20265 /// match+backend+overlay vec).
20266 ///
20267 /// Lifting collapses the boilerplate into one method call the
20268 /// caller reads as intent (`mapping.insert_sequence(<KEY>, <VEC>)`
20269 /// — "insert a list-shape-typed sub-block named `KEY` with the built
20270 /// inner `VEC`") rather than three hand-spelled positional
20271 /// artifacts. The next renderer to land — the per-`:politicas`
20272 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
20273 /// list-shape sub-blocks are `spec.resources[]` / `spec.listeners[]`
20274 /// / `spec.virtualHosts[]`, MESH-COMPOSITION §III.2 #3), the
20275 /// `app-operator`'s typed `mesh.pleme.io/v1alpha1/Aplicacao` CR
20276 /// materializer (per-`spec.selectors[]` and per-`spec.gates[]`
20277 /// list-shape sub-blocks, §III.2 #5), the M4 cross-cluster fan-out's
20278 /// per-cluster `Service.spec.ports[]` /
20279 /// `HTTPRoute.spec.rules[].backendRefs[]` list emission, the future
20280 /// `caixa-otel` OpenTelemetry-Collector per-pipeline `receivers[]`
20281 /// / `processors[]` / `exporters[]` list emission — gets the
20282 /// canonical list-shape-valued-field shape for free with one method
20283 /// call, instead of re-inlining the three-token `Value::Sequence(_)`
20284 /// promotion.
20285 ///
20286 /// Peer to [`Self::insert_mapping`] on the sibling nested-Mapping
20287 /// axis and [`Self::insert_string`] on the sibling scalar-value axis
20288 /// — the four together with [`Self::insert_str_key`] form the "one
20289 /// method call per emission axis" primitive quadruple the K8s-
20290 /// artifact-emit surface's "same shape, written N times" duplication
20291 /// (THEORY.md §I.3.5) collapses onto: `insert_str_key` for any-Value
20292 /// inserts, `insert_string` for the string-scalar-valued-field
20293 /// shape, `insert_mapping` for the nested-Mapping-valued-field
20294 /// shape, `insert_sequence` for the list-shape-valued-field shape.
20295 ///
20296 /// Complementary to [`singleton_mapping_sequence`] on the peer
20297 /// singleton-list-shape axis: `singleton_mapping_sequence(m)` builds
20298 /// the sole-Mapping-element `Value::Sequence` payload;
20299 /// `insert_sequence(K, v)` inserts an already-built `Vec<Value>`
20300 /// payload under a schema key. A caller composing the two through
20301 /// [`Self::insert_singleton_mapping_sequence`] writes
20302 /// `mapping.insert_singleton_mapping_sequence(K, m)` for the
20303 /// singleton case (the sole element is a fresh Mapping); reach for
20304 /// `mapping.insert_sequence(K, v)` for the multi-element or
20305 /// non-Mapping-element case (the vec is built up per-iteration or
20306 /// wraps a non-Mapping scalar).
20307 fn insert_sequence(
20308 &mut self,
20309 key: &str,
20310 value: Vec<serde_yaml::Value>,
20311 ) -> Option<serde_yaml::Value>;
20312
20313 /// Insert `(key, Value::Sequence(vec![Value::Mapping(value)]))` into
20314 /// `self` — the singleton-Mapping-list-shape-valued-field emission
20315 /// shape that composes [`Self::insert_str_key`]'s
20316 /// `&str → Value::String` key promotion with the
20317 /// [`singleton_mapping_sequence`] helper's singleton-list wrap of a
20318 /// [`serde_yaml::Mapping`] payload. Returns the prior value at that
20319 /// key, mirroring [`serde_yaml::Mapping::insert`].
20320 ///
20321 /// The canonical shape 7 production call sites across `caixa-mesh`
20322 /// previously carried inline as the two-token composition
20323 /// `mapping.insert_str_key(<KEY>, singleton_mapping_sequence(<M>))`
20324 /// — a two-token semantic payload (`<KEY>`, `<M>`) buried under a
20325 /// two-symbol boilerplate (`insert_str_key(_, _)` +
20326 /// `singleton_mapping_sequence(_)`) that fully covers the axis: every
20327 /// site both wraps its per-call `Mapping` as the sole-element list
20328 /// value and inserts it under a schema key on an outer `Mapping`. A
20329 /// rebrand on either half — the outer key-scalar promotion axis
20330 /// migrating to a per-key typed `Value` variant, the singleton-list
20331 /// wrap migrating to a Server-Side-Apply-typed `Value::Tagged`
20332 /// per-CRD-list shape once K8s per-field ownership annotations reach
20333 /// the K8s Gateway API / Cilium NetworkPolicy CRD list schemas —
20334 /// would silently desynchronize one site while leaving the other six
20335 /// on the old shape.
20336 ///
20337 /// Sites lifted:
20338 ///
20339 /// * caixa-mesh's `cilium_network_policies` per-`toPorts[]` port
20340 /// entry `ports:` singleton-list (`CILIUM_KEY_PORTS` around the
20341 /// built `port_entry` Mapping);
20342 /// * caixa-mesh's `cilium_network_policies` per-`toPorts[]` L7
20343 /// `rules.http:` singleton-list (`CILIUM_KEY_HTTP` around the
20344 /// built `http_rule` Mapping);
20345 /// * caixa-mesh's `cilium_network_policies` per-`CiliumNetworkPolicy`
20346 /// `spec.ingress:` singleton-list (`CILIUM_KEY_INGRESS` around the
20347 /// built `ingress_rule` Mapping);
20348 /// * caixa-mesh's `gateway_routes` per-`Gateway` `spec.listeners:`
20349 /// singleton-list (`GATEWAY_API_KEY_LISTENERS` around the built
20350 /// `listener` Mapping);
20351 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute.spec.rules[]`
20352 /// `matches:` singleton-list (`GATEWAY_API_KEY_MATCHES` around the
20353 /// built `match_entry` Mapping);
20354 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute.spec.rules[]`
20355 /// `backendRefs:` singleton-list (`GATEWAY_API_KEY_BACKEND_REFS`
20356 /// around the built `backend_ref` Mapping);
20357 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute`
20358 /// `spec.parentRefs:` singleton-list (`GATEWAY_API_KEY_PARENT_REFS`
20359 /// around the built `parent_ref` Mapping).
20360 ///
20361 /// Lifting collapses the two-symbol composition into one method call
20362 /// the caller reads as intent (`mapping.insert_singleton_mapping_sequence
20363 /// (<KEY>, <M>)` — "insert a singleton-Mapping-list-shape sub-block
20364 /// named `KEY` wrapping the built inner `M`") rather than two
20365 /// nested calls. Peer to [`Self::insert_sequence`] on the sibling
20366 /// multi-element or non-Mapping-element list-shape axis — the two
20367 /// together partition the list-shape-valued-field emission surface:
20368 /// [`Self::insert_singleton_mapping_sequence`] for the sole-Mapping-
20369 /// element case, [`Self::insert_sequence`] for every other case.
20370 ///
20371 /// The next renderer to land — the per-`:politicas`
20372 /// `CiliumClusterwideEnvoyConfig` emitter (whose singleton
20373 /// `spec.resources:[]` / `spec.listeners:[]` / `spec.virtualHosts:[]`
20374 /// Mapping-element blocks, MESH-COMPOSITION §III.2 #3, are exactly the
20375 /// singleton-Mapping-list shape), the `app-operator`'s typed
20376 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (per-single-
20377 /// selector / per-single-gate emission, §III.2 #5), the M4 cross-
20378 /// cluster fan-out's per-cluster singleton `Service.spec.ports[]` /
20379 /// `HTTPRoute.spec.rules[].backendRefs[]` sole-element emission, the
20380 /// future `caixa-otel` OpenTelemetry-Collector `pipelines.traces.
20381 /// receivers[]` singleton-receiver emission — gets the canonical
20382 /// singleton-Mapping-list-shape wrap+insert for free with one method
20383 /// call, instead of re-inlining the two-symbol composition.
20384 fn insert_singleton_mapping_sequence(
20385 &mut self,
20386 key: &str,
20387 value: serde_yaml::Mapping,
20388 ) -> Option<serde_yaml::Value>;
20389
20390 /// Entry-API sibling of [`Self::insert_str_key`] — mint the
20391 /// `Value::String(<KEY>.into())` key-promotion the underlying
20392 /// [`serde_yaml::Mapping::entry`] method's `Value` parameter
20393 /// demands, and return the entry-API's
20394 /// [`serde_yaml::mapping::Entry`] handle the caller composes
20395 /// `.or_insert(<V>)` / `.or_insert_with(<F>)` /
20396 /// `.and_modify(<F>)` / `.or_default()` on.
20397 ///
20398 /// The canonical shape 4 production call sites across `caixa-flux`
20399 /// previously carried inline as the three-token composition
20400 /// `mapping.entry(serde_yaml::Value::String(<KEY>.into()))` around
20401 /// a one-token semantic payload (the schema key axis-name). Every
20402 /// site immediately composes an `.or_insert(...)` on the returned
20403 /// [`serde_yaml::mapping::Entry`] handle — the pattern is the
20404 /// entry-API twin of the [`Self::insert_str_key`] pattern the
20405 /// ~48 fresh-emit sites already collapsed onto (23506b3).
20406 ///
20407 /// Sites lifted:
20408 ///
20409 /// * caixa-flux's `programs_yaml_entry` per-`servico_m2_overlay`
20410 /// key idempotent-upsert loop (`entry.entry(Value::String(
20411 /// <key>.to_string())).or_insert(<value>)` — one
20412 /// `.or_insert(...)` per `M2_KEY_LIMITS` / `M2_KEY_BEHAVIOR` /
20413 /// `M2_KEY_UPGRADE_FROM` axis, iterating the
20414 /// [`servico_m2_overlay`] `BTreeMap`);
20415 /// * caixa-flux's `upsert_into_helmrelease_programs` per-
20416 /// `HelmRelease.spec.values` upsert-if-absent (`FLUX_KEY_VALUES`
20417 /// around a default fresh `Value::Mapping`);
20418 /// * caixa-flux's `upsert_into_helmrelease_programs` per-
20419 /// `HelmRelease.spec.values.programs` upsert-if-absent
20420 /// (`FLEET_PROGRAMS_KEY_PROGRAMS` around a default fresh
20421 /// `Value::Sequence`);
20422 /// * caixa-flux's `upsert_into_programs_yaml` per-top-level
20423 /// `programs:` upsert-if-absent (`FLEET_PROGRAMS_KEY_PROGRAMS`
20424 /// around a default fresh `Value::Sequence` — the sibling of
20425 /// the `upsert_into_helmrelease_programs` site on the same
20426 /// key, one path deep in a HelmRelease `spec.values.` sub-tree,
20427 /// one path at the values.yaml root).
20428 ///
20429 /// Lifting collapses the three-token composition into one method
20430 /// call the caller reads as intent
20431 /// (`mapping.entry_str_key(<KEY>).or_insert(<DEFAULT>)` — "get the
20432 /// entry handle for this schema key and default it if missing")
20433 /// rather than four hand-spelled positional artifacts
20434 /// (`serde_yaml::` path re-quote, `Value::String(_)` promotion,
20435 /// the `.into() | .to_string()` `&str → String` coercion, plus the
20436 /// `.entry(_)` call itself). The next renderer to land — the
20437 /// per-`:politicas` `CiliumClusterwideEnvoyConfig` emitter (which
20438 /// upserts singleton `spec.resources:[]` / `spec.listeners:[]`
20439 /// blocks under an existing per-cluster overlay CR, MESH-COMPOSITION
20440 /// §III.2 #3), the `app-operator`'s typed
20441 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (which
20442 /// upserts `status.` sub-fields on partial reconciles, §III.2 #5),
20443 /// the M4 cross-cluster fan-out's per-cluster idempotent
20444 /// HelmRelease upsert — gets the canonical entry-API key-promotion
20445 /// for free with one method call, instead of re-inlining the
20446 /// three-token block.
20447 ///
20448 /// Peer to [`Self::insert_str_key`] on the sibling fresh-emit
20449 /// axis of the same `&str → Value::String` key-promotion — the
20450 /// two together partition the `Mapping`-write surface: entry-API
20451 /// for idempotent-upsert sites where the caller cares whether the
20452 /// prior value was present (`or_insert` / `and_modify` /
20453 /// `or_default` composition), insert-API for fresh-emit sites where
20454 /// the caller unconditionally writes a value and either drops or
20455 /// pattern-matches on the returned `Option<Value>` prior value.
20456 fn entry_str_key(&mut self, key: &str) -> serde_yaml::mapping::Entry<'_>;
20457
20458 /// Arity-0-or-1 twin of [`Self::insert_str_key`] — insert
20459 /// `(key, value.clone())` iff `value` is `Some`; leave `self`
20460 /// untouched iff `value` is `None`. Returns the prior value at that
20461 /// key when the insert fires (mirroring
20462 /// [`serde_yaml::Mapping::insert`]), and `None` otherwise (no insert
20463 /// happened, so no prior value can be surfaced).
20464 ///
20465 /// The canonical shape 3 production call sites across `caixa-mesh`
20466 /// previously carried inline as the three-line block
20467 /// `if let Some(<x>) = &<overlay> { <mapping>.insert_str_key(<KEY>,
20468 /// <x>.clone()); }` around a two-token semantic payload (the schema
20469 /// key axis-name + the `Option<Value>` overlay slot). Every site
20470 /// pairs a per-`:politicas` overlay [`single_field_overlay`] `Option
20471 /// <Value>` output with the same conditional-insert conditional —
20472 /// the arity-0-or-1 twin of [`Self::insert_str_key`]'s always-1
20473 /// arity on the per-`(:de, :para)` axis.
20474 ///
20475 /// Sites lifted:
20476 ///
20477 /// * caixa-mesh's `cilium_network_policies` per-ingress-rule
20478 /// `:politicas :mtls-required` mutual-auth overlay
20479 /// ([`crate::CILIUM_KEY_AUTHENTICATION`] around the
20480 /// `mtls_overlay` [`single_field_overlay`] output — the
20481 /// tristate `{mode: required | disabled}` block or the
20482 /// None-omit arm);
20483 /// * caixa-mesh's `gateway_routes` per-HTTPRoute-rule
20484 /// `:politicas :timeout` request-deadline overlay
20485 /// ([`crate::GATEWAY_API_KEY_TIMEOUTS`] around the
20486 /// `timeout_overlay` [`single_field_overlay`] output — the
20487 /// `{request: "<duration>"}` block or the None-omit arm);
20488 /// * caixa-mesh's `gateway_routes` per-HTTPRoute-rule
20489 /// `:politicas :retries` retry-attempt-cap overlay
20490 /// ([`crate::GATEWAY_API_KEY_RETRY`] around the
20491 /// `retry_overlay` [`single_field_overlay`] output — the
20492 /// `{attempts: <N>}` block or the None-omit arm).
20493 ///
20494 /// Lifting collapses the three-line block into one method call the
20495 /// caller reads as intent (`mapping.insert_str_key_if_some(<KEY>,
20496 /// <overlay>.as_ref())` — "insert this schema key if the overlay
20497 /// carried a value; else leave the key absent") rather than four
20498 /// hand-spelled positional artifacts (the `if let Some(_) = &_`
20499 /// destructure, the per-inner `.clone()`, the trailing brace, plus
20500 /// the `.insert_str_key(_)` call itself). The absent-overlay arm —
20501 /// which every [`MeshPolicy`] axis defaults to when the author
20502 /// leaves the typed slot unset (the `None` arm of the
20503 /// `Option<Value>` [`single_field_overlay`] output) — reads as the
20504 /// method's own `Option::None` branch, not a per-call-site inverted
20505 /// `if let Some` scaffold around a per-call-site clone.
20506 ///
20507 /// The next renderer to land — the per-`:politicas`
20508 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
20509 /// `authentication:` / `rateLimit:` / `circuitBreaker:` Option
20510 /// overlays, MESH-COMPOSITION §III.2 #3, thread through the same
20511 /// [`single_field_overlay`] `Option<Value>` axis the three lifted
20512 /// sites here already reach), the `app-operator`'s typed
20513 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (whose per-
20514 /// selector `status.` sub-field overlays are the same arity-0-or-1
20515 /// shape, §III.2 #5), the M4 cross-cluster fan-out's per-cluster
20516 /// `HTTPRoute.spec.rules[].filters[]` per-filter Option overlays
20517 /// (the same shape at the per-cluster axis) — gets the canonical
20518 /// arity-0-or-1 conditional-insert for free with one method call,
20519 /// instead of re-inlining the three-line `if let Some { clone;
20520 /// insert_str_key }` block.
20521 ///
20522 /// Peer to [`Self::insert_str_key`] on the always-1 arity axis
20523 /// (fresh-emit sites where the caller unconditionally writes a
20524 /// value) — the two together partition the fresh-emit surface
20525 /// exactly on the arity axis: [`Self::insert_str_key`] for
20526 /// unconditional writes, [`Self::insert_str_key_if_some`] for
20527 /// conditional writes gated on an `Option<Value>` upstream
20528 /// producer (the per-`:politicas` overlay
20529 /// [`single_field_overlay`] axis, and every future arity-0-or-1
20530 /// axis every future renderer's optional-slot machinery reaches
20531 /// through).
20532 ///
20533 /// The `Option<&Value>` shape (as opposed to an owned
20534 /// `Option<Value>`) lets the caller pass `overlay.as_ref()` on an
20535 /// owned `Option<Value>` the caller reuses across iterations of an
20536 /// outer per-`(:de, :para)` or per-rule loop — every lifted site
20537 /// consumes the overlay from a loop-outer binding into each of N
20538 /// per-iteration `Mapping`s, so the clone happens iff the insert
20539 /// fires (the None arm skips the clone entirely) and the outer
20540 /// binding stays available for the next iteration.
20541 fn insert_str_key_if_some(
20542 &mut self,
20543 key: &str,
20544 value: Option<&serde_yaml::Value>,
20545 ) -> Option<serde_yaml::Value>;
20546
20547 /// Fetch a `&mut serde_yaml::Mapping` at `key`, defaulting an empty
20548 /// [`serde_yaml::Mapping`] into place when the entry is absent.
20549 /// Returns `Some(&mut inner)` on the absent-key (fresh empty
20550 /// Mapping) and present-Mapping arms; `None` iff `key` holds a
20551 /// different [`serde_yaml::Value`] variant — a structural
20552 /// container-type mismatch the caller surfaces as its own
20553 /// domain-specific error (`Error::MissingField("spec.values must
20554 /// be a mapping")` for the caixa-flux Flux-HelmRelease overlay
20555 /// walker).
20556 ///
20557 /// The canonical shape 1 production call site in `caixa-flux`
20558 /// (`upsert_into_helmrelease_programs`'s per-`HelmRelease.spec.values`
20559 /// container-upsert on the way down to
20560 /// `spec.values.programs[]`) previously carried inline as a
20561 /// four-line block combining [`Self::entry_str_key`]'s entry-API
20562 /// key promotion (68d035e), an
20563 /// `.or_insert(Value::Mapping(Mapping::new()))` empty-Mapping
20564 /// default, and a `let Value::Mapping(inner) = _ else { Err(...) }`
20565 /// destructure — a two-token semantic payload (the schema key +
20566 /// the domain-specific type-mismatch diagnostic) buried under
20567 /// three boilerplate axes (`Value::Mapping(_)` variant promotion,
20568 /// `Mapping::new()` empty-container construction, the outer
20569 /// `let else` destructure). Peer to
20570 /// [`Self::entry_or_default_sequence`] on the sibling `Vec<Value>`-
20571 /// valued idempotent-container-upsert axis — the two together
20572 /// partition the entry-API-container-upsert surface exactly on the
20573 /// container-variant axis: [`Self::entry_or_default_mapping`] for
20574 /// nested-Mapping sub-blocks, [`Self::entry_or_default_sequence`]
20575 /// for list-shape sub-blocks.
20576 ///
20577 /// Sites lifted:
20578 ///
20579 /// * caixa-flux's `upsert_into_helmrelease_programs` per-
20580 /// `HelmRelease.spec.values` container-upsert
20581 /// (`FLUX_KEY_VALUES` around the default fresh
20582 /// `Value::Mapping`, on the way down to the nested
20583 /// `spec.values.programs[]` sequence).
20584 ///
20585 /// Lifting collapses the four-line block into one method call the
20586 /// caller reads as intent (`mapping.entry_or_default_mapping(<KEY>)
20587 /// .ok_or(<ERR>)?` — "give me the nested Mapping at this schema
20588 /// key, defaulting empty if absent, else surface my domain
20589 /// error") rather than five hand-spelled positional artifacts
20590 /// (`serde_yaml::` path re-quote, `Value::Mapping(_)` promotion,
20591 /// `Mapping::new()` construction, the entry-API `.or_insert(...)`
20592 /// call, plus the outer `let Value::Mapping(_) = _ else {}`
20593 /// destructure). The next renderer to land — the per-`:politicas`
20594 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-cluster
20595 /// upsert walks
20596 /// `HelmRelease.spec.values.<library>.<:politicas-axis>`,
20597 /// idempotent-upserting nested-Mapping sub-blocks under each
20598 /// axis, MESH-COMPOSITION §III.2 #3), the `app-operator`'s typed
20599 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (which
20600 /// upserts `status.<axis>` nested-Mapping sub-blocks on partial
20601 /// reconciles, §III.2 #5), the M4 cross-cluster fan-out's
20602 /// per-cluster idempotent `HelmRelease.spec.values.<library>`
20603 /// container-upsert — gets the canonical entry-API-with-
20604 /// container-type-check for free with one method call, instead
20605 /// of re-inlining the four-line block.
20606 ///
20607 /// The default-empty-Mapping construction fires only on the
20608 /// absent-key arm (`.or_insert_with(...)` gates the closure on
20609 /// vacancy) — the present-key arm reuses the existing Mapping
20610 /// verbatim, so the caller's downstream writes on `&mut inner`
20611 /// compose with any prior overlay writes from earlier passes
20612 /// (the exact idempotent-upsert semantic the caixa-flux
20613 /// per-cluster `feira app deploy` write path depends on to
20614 /// preserve operator-pinned overlays across re-renders).
20615 fn entry_or_default_mapping(&mut self, key: &str) -> Option<&mut serde_yaml::Mapping>;
20616
20617 /// Fetch a `&mut Vec<serde_yaml::Value>` at `key`, defaulting an
20618 /// empty [`Vec<serde_yaml::Value>`] into place when the entry is
20619 /// absent. Returns `Some(&mut inner)` on the absent-key (fresh
20620 /// empty Sequence) and present-Sequence arms; `None` iff `key`
20621 /// holds a different [`serde_yaml::Value`] variant — a structural
20622 /// container-type mismatch the caller surfaces as its own
20623 /// domain-specific error (`Error::MissingField("programs must be
20624 /// a sequence")` for the caixa-flux fleet-programs upsert
20625 /// walkers).
20626 ///
20627 /// The canonical shape 2 production call sites in `caixa-flux`
20628 /// (`upsert_into_helmrelease_programs`'s per-
20629 /// `HelmRelease.spec.values.programs` container-upsert and
20630 /// `upsert_into_programs_yaml`'s top-level `programs:` container-
20631 /// upsert) previously carried inline as a four-line block
20632 /// combining [`Self::entry_str_key`]'s entry-API key promotion
20633 /// (68d035e), an `.or_insert(Value::Sequence(Vec::new()))`
20634 /// empty-Sequence default, and a `match _ { Value::Sequence(seq)
20635 /// => seq, _ => return Err(...) }` destructure — a two-token
20636 /// semantic payload (the schema key + the domain-specific
20637 /// type-mismatch diagnostic) buried under three boilerplate axes
20638 /// (`Value::Sequence(_)` variant promotion, `Vec::new()`
20639 /// empty-container construction, the outer `match` destructure).
20640 /// Peer to [`Self::entry_or_default_mapping`] on the sibling
20641 /// nested-Mapping-valued idempotent-container-upsert axis.
20642 ///
20643 /// Sites lifted:
20644 ///
20645 /// * caixa-flux's `upsert_into_helmrelease_programs` per-
20646 /// `HelmRelease.spec.values.programs` list-container-upsert
20647 /// (`FLEET_PROGRAMS_KEY_PROGRAMS` around the default fresh
20648 /// `Value::Sequence`, one path deep in a `HelmRelease`
20649 /// `spec.values.` sub-tree);
20650 /// * caixa-flux's `upsert_into_programs_yaml` per-top-level
20651 /// `programs:` list-container-upsert
20652 /// (`FLEET_PROGRAMS_KEY_PROGRAMS` around the default fresh
20653 /// `Value::Sequence` — the sibling of the
20654 /// `upsert_into_helmrelease_programs` site on the same key,
20655 /// one path at the values.yaml root).
20656 ///
20657 /// Lifting collapses the four-line block into one method call the
20658 /// caller reads as intent (`mapping.entry_or_default_sequence(<KEY>)
20659 /// .ok_or(<ERR>)?` — "give me the list at this schema key,
20660 /// defaulting empty if absent, else surface my domain error")
20661 /// rather than five hand-spelled positional artifacts
20662 /// (`serde_yaml::` path re-quote, `Value::Sequence(_)` promotion,
20663 /// `Vec::new()` construction, the entry-API `.or_insert(...)`
20664 /// call, plus the outer `match { Value::Sequence(_) => _, _ =>
20665 /// return Err(_) }` destructure). The next renderer to land — the
20666 /// per-`:politicas` `CiliumClusterwideEnvoyConfig` emitter
20667 /// (whose per-cluster upsert walks nested list-shape sub-blocks
20668 /// `spec.resources[]` / `spec.listeners[]` / `spec.virtualHosts[]`
20669 /// under existing operator-pinned overlay CRs, MESH-COMPOSITION
20670 /// §III.2 #3), the `app-operator`'s typed
20671 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (which
20672 /// upserts `status.selectors[]` / `status.gates[]` list-shape
20673 /// sub-blocks on partial reconciles, §III.2 #5), the M4 cross-
20674 /// cluster fan-out's per-cluster idempotent
20675 /// `HelmRelease.spec.values.programs` list-upsert — gets the
20676 /// canonical entry-API-with-container-type-check for free with
20677 /// one method call, instead of re-inlining the four-line block.
20678 ///
20679 /// The default-empty-Sequence construction fires only on the
20680 /// absent-key arm (`.or_insert_with(...)` gates the closure on
20681 /// vacancy) — the present-key arm reuses the existing Vec
20682 /// verbatim, so the caller's downstream `upsert_named_entry`
20683 /// (10bf310) call on `&mut inner` composes with any prior
20684 /// entries the emitter wrote on earlier passes (the exact
20685 /// idempotent-upsert semantic the `feira app deploy` per-cluster
20686 /// write path depends on to preserve prior `programs[]` entries
20687 /// across per-Servico rewrites).
20688 fn entry_or_default_sequence(&mut self, key: &str) -> Option<&mut Vec<serde_yaml::Value>>;
20689}
20690
20691impl MappingExt for serde_yaml::Mapping {
20692 #[inline]
20693 fn insert_str_key(&mut self, key: &str, value: serde_yaml::Value) -> Option<serde_yaml::Value> {
20694 self.insert(serde_yaml::Value::String(key.to_string()), value)
20695 }
20696
20697 #[inline]
20698 fn insert_string<V: Into<String>>(&mut self, key: &str, value: V) -> Option<serde_yaml::Value> {
20699 self.insert_str_key(key, serde_yaml::Value::String(value.into()))
20700 }
20701
20702 #[inline]
20703 fn insert_number<N: Into<serde_yaml::Number>>(
20704 &mut self,
20705 key: &str,
20706 value: N,
20707 ) -> Option<serde_yaml::Value> {
20708 self.insert_str_key(key, serde_yaml::Value::Number(value.into()))
20709 }
20710
20711 #[inline]
20712 fn insert_mapping(
20713 &mut self,
20714 key: &str,
20715 value: serde_yaml::Mapping,
20716 ) -> Option<serde_yaml::Value> {
20717 self.insert_str_key(key, serde_yaml::Value::Mapping(value))
20718 }
20719
20720 #[inline]
20721 fn insert_sequence(
20722 &mut self,
20723 key: &str,
20724 value: Vec<serde_yaml::Value>,
20725 ) -> Option<serde_yaml::Value> {
20726 self.insert_str_key(key, serde_yaml::Value::Sequence(value))
20727 }
20728
20729 #[inline]
20730 fn insert_singleton_mapping_sequence(
20731 &mut self,
20732 key: &str,
20733 value: serde_yaml::Mapping,
20734 ) -> Option<serde_yaml::Value> {
20735 self.insert_str_key(key, singleton_mapping_sequence(value))
20736 }
20737
20738 #[inline]
20739 fn entry_str_key(&mut self, key: &str) -> serde_yaml::mapping::Entry<'_> {
20740 self.entry(serde_yaml::Value::String(key.to_string()))
20741 }
20742
20743 #[inline]
20744 fn insert_str_key_if_some(
20745 &mut self,
20746 key: &str,
20747 value: Option<&serde_yaml::Value>,
20748 ) -> Option<serde_yaml::Value> {
20749 value.and_then(|v| self.insert_str_key(key, v.clone()))
20750 }
20751
20752 #[inline]
20753 fn entry_or_default_mapping(&mut self, key: &str) -> Option<&mut serde_yaml::Mapping> {
20754 match self
20755 .entry_str_key(key)
20756 .or_insert_with(|| serde_yaml::Value::Mapping(serde_yaml::Mapping::new()))
20757 {
20758 serde_yaml::Value::Mapping(m) => Some(m),
20759 _ => None,
20760 }
20761 }
20762
20763 #[inline]
20764 fn entry_or_default_sequence(&mut self, key: &str) -> Option<&mut Vec<serde_yaml::Value>> {
20765 match self
20766 .entry_str_key(key)
20767 .or_insert_with(|| serde_yaml::Value::Sequence(Vec::new()))
20768 {
20769 serde_yaml::Value::Sequence(s) => Some(s),
20770 _ => None,
20771 }
20772 }
20773}
20774
20775/// Extension methods for the [`Vec<serde_yaml::Value>`] emission
20776/// surface that the K8s-artifact-emit sites of `caixa-mesh` /
20777/// `caixa-flux` / `caixa-helm` / `caixa-core::render` build up as
20778/// `spec.ingress[]` / `spec.rules[]` / `spec.hostnames[]` / per-
20779/// programs.yaml-entry payloads before wrapping each vec as a
20780/// [`serde_yaml::Value::Sequence`] on an outer [`serde_yaml::Mapping`]
20781/// (via [`MappingExt::insert_sequence`]).
20782///
20783/// Peer to [`MappingExt`] on the sibling [`serde_yaml::Value`]-
20784/// construction surface: [`MappingExt`] closes the per-key-and-value
20785/// insert primitive every schema-key axis reaches through;
20786/// [`SequenceExt`] closes the per-list-element push primitive every
20787/// per-iteration append site reaches through when the built-up
20788/// [`serde_yaml::Value`] variant is uniform across a loop body (e.g.
20789/// every element is a fresh [`serde_yaml::Value::Mapping`], not a
20790/// heterogeneous mix of `Mapping` / `String` / `Sequence`).
20791///
20792/// Each method mints the same `Value::<Variant>(<payload>)` promotion
20793/// the caller would otherwise re-inline as
20794/// `vec.push(serde_yaml::Value::<Variant>(<payload>))` on every
20795/// iteration. Same variant-promotion contract as [`MappingExt`]'s
20796/// typed inserts, applied to the sequence-append axis instead of the
20797/// mapping-insert axis — so a future rebrand of the `Value` variant
20798/// wrapping (e.g. to a Server-Side-Apply-typed
20799/// [`serde_yaml::Value::Tagged`] per-list-element ownership axis)
20800/// reaches both `Mapping`-insert and `Vec<Value>`-push sites through
20801/// one lift.
20802pub trait SequenceExt {
20803 /// Append `Value::Mapping(value)` to `self` — the per-iteration
20804 /// append shape that combines a `Vec<serde_yaml::Value>::push`
20805 /// with an automatic [`serde_yaml::Value::Mapping`] promotion of a
20806 /// pre-built [`serde_yaml::Mapping`] element.
20807 ///
20808 /// The canonical shape 4 production call sites across `caixa-mesh`
20809 /// previously carried inline as the three-token block
20810 /// `<vec>.push(serde_yaml::Value::Mapping(<M>))` — a one-token
20811 /// semantic payload (the per-iteration `Mapping`) buried under a
20812 /// two-axis boilerplate (`serde_yaml::` path re-quote,
20813 /// `Value::Mapping(_)` promotion) around a `Mapping` variable the
20814 /// caller already built.
20815 ///
20816 /// Sites lifted:
20817 ///
20818 /// * caixa-mesh's `programs_for_aplicacao` per-`:membros`
20819 /// programs.yaml entry append (per-member entry `Mapping` →
20820 /// the fan-out `Vec<Value>`);
20821 /// * caixa-mesh's `cilium_network_policies` per-edge
20822 /// `spec.ingress[].toPorts[]` L4-and-L7 port-and-rule append
20823 /// (per-`(:de, :para)` group's per-edge `to_port` Mapping →
20824 /// the `to_ports_seq` Vec);
20825 /// * caixa-mesh's `cilium_network_policies` per-policy
20826 /// top-level CNP-document append (per-`(:de, :para)` group's
20827 /// built `policy` Mapping → the render-output `Vec<Value>`);
20828 /// * caixa-mesh's `gateway_routes` per-HTTPRoute-rule
20829 /// `spec.rules[]` append (per-path built `rule` Mapping → the
20830 /// `rules` Vec).
20831 ///
20832 /// Lifting collapses the three-token block into one method call
20833 /// the caller reads as intent (`<vec>.push_mapping(<M>)` —
20834 /// "append this built inner `M` as the next `Value::Mapping`
20835 /// element") rather than three hand-spelled positional artifacts
20836 /// (`serde_yaml::` path re-quote, `Value::Mapping(_)` promotion,
20837 /// plus the `.push(_)` call itself). Peer to
20838 /// [`MappingExt::insert_singleton_mapping_sequence`] on the
20839 /// singleton-Mapping-list-shape axis: [`Self::push_mapping`]
20840 /// builds up a multi-element `Vec<Value>` per iteration when the
20841 /// caller then calls [`MappingExt::insert_sequence`] to route the
20842 /// finished vec under a schema key;
20843 /// [`MappingExt::insert_singleton_mapping_sequence`] fuses the
20844 /// singleton wrap + the schema-key insert into one call when the
20845 /// caller has exactly one Mapping element to emit under a schema
20846 /// key.
20847 ///
20848 /// The next renderer to land — the per-`:politicas`
20849 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
20850 /// `spec.resources[]` / `spec.listeners[]` / `spec.virtualHosts[]`
20851 /// list-shape axes fan out multi-Mapping-element per iteration,
20852 /// MESH-COMPOSITION §III.2 #3), the `app-operator`'s typed
20853 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (per-
20854 /// `spec.selectors[]` / per-`spec.gates[]` multi-element append,
20855 /// §III.2 #5), the M4 cross-cluster fan-out's per-cluster
20856 /// multi-entry `Service.spec.ports[]` /
20857 /// `HTTPRoute.spec.rules[].backendRefs[]` list append, the future
20858 /// `caixa-otel` OpenTelemetry-Collector per-pipeline
20859 /// `receivers[]` / `processors[]` / `exporters[]` multi-element
20860 /// append — gets the canonical `Value::Mapping`-promoted append
20861 /// for free with one method call, instead of re-inlining the
20862 /// three-token `Value::Mapping(_)` promotion.
20863 fn push_mapping(&mut self, value: serde_yaml::Mapping);
20864}
20865
20866impl SequenceExt for Vec<serde_yaml::Value> {
20867 #[inline]
20868 fn push_mapping(&mut self, value: serde_yaml::Mapping) {
20869 self.push(serde_yaml::Value::Mapping(value));
20870 }
20871}
20872
20873#[cfg(test)]
20874mod tests {
20875 use super::*;
20876 use crate::{BehaviorSpec, CaixaKind, LimitsSpec, UpgradeFromEntry, UpgradeInstruction};
20877 use std::path::PathBuf;
20878 use std::time::Duration;
20879
20880 fn bare_servico() -> Caixa {
20881 Caixa {
20882 nome: "hello-rio".into(),
20883 versao: "0.1.0".into(),
20884 kind: CaixaKind::Servico,
20885 edicao: Some("2026".into()),
20886 descricao: None,
20887 repositorio: None,
20888 licenca: None,
20889 autores: vec![],
20890 etiquetas: vec![],
20891 deps: vec![],
20892 deps_dev: vec![],
20893 exe: vec![],
20894 bibliotecas: vec![],
20895 servicos: vec!["servicos/hello-rio.computeunit.yaml".into()],
20896 limits: None,
20897 behavior: None,
20898 upgrade_from: vec![],
20899 estrategia: None,
20900 max_restarts: None,
20901 restart_window: None,
20902 children: vec![],
20903 membros: vec![],
20904 contratos: vec![],
20905 politicas: None,
20906 placement: None,
20907 entrada: None,
20908 ci: None,
20909 }
20910 }
20911
20912 #[test]
20913 fn empty_caixa_returns_empty_overlay() {
20914 let overlay = servico_m2_overlay(&bare_servico()).unwrap();
20915 assert!(
20916 overlay.is_empty(),
20917 "a Caixa with no M2 slots emits zero overlay fragments"
20918 );
20919 }
20920
20921 #[test]
20922 fn empty_typed_specs_are_skipped_like_unset_ones() {
20923 // `Some(LimitsSpec::default())` (every axis None) and
20924 // `Some(BehaviorSpec::default())` (every callback None) must
20925 // round-trip identical to `None` — the is_empty()-skip
20926 // invariant the renderers' "empty M2 slots do not appear"
20927 // tests pinned inline before this lift.
20928 let mut c = bare_servico();
20929 c.limits = Some(LimitsSpec::default());
20930 c.behavior = Some(BehaviorSpec::default());
20931 let overlay = servico_m2_overlay(&c).unwrap();
20932 assert!(overlay.is_empty());
20933 }
20934
20935 #[test]
20936 fn limits_slot_appears_under_camelcase_key() {
20937 let mut c = bare_servico();
20938 c.limits = Some(LimitsSpec {
20939 memory: Some(64 * 1024 * 1024),
20940 fuel: Some(1_000_000),
20941 wall_clock: Some(Duration::from_secs(30)),
20942 cpu: Some(500),
20943 });
20944 let overlay = servico_m2_overlay(&c).unwrap();
20945 assert_eq!(overlay.len(), 1);
20946 let limits = overlay.get(M2_KEY_LIMITS).expect("limits key present");
20947 assert_eq!(
20948 limits.get(M2_LIMITS_KEY_MEMORY).and_then(|m| m.as_str()),
20949 Some("64MiB")
20950 );
20951 assert_eq!(
20952 limits
20953 .get(M2_LIMITS_KEY_WALL_CLOCK)
20954 .and_then(|m| m.as_str()),
20955 Some("30s")
20956 );
20957 }
20958
20959 #[test]
20960 fn behavior_slot_appears_under_camelcase_key() {
20961 let mut c = bare_servico();
20962 c.behavior = Some(BehaviorSpec {
20963 on_init: Some(PathBuf::from("lib/init.lisp")),
20964 on_call: Some(PathBuf::from("lib/handlers.lisp")),
20965 ..Default::default()
20966 });
20967 let overlay = servico_m2_overlay(&c).unwrap();
20968 let behavior = overlay.get(M2_KEY_BEHAVIOR).expect("behavior key present");
20969 assert_eq!(
20970 behavior
20971 .get(M2_BEHAVIOR_KEY_ON_INIT)
20972 .and_then(|v| v.as_str()),
20973 Some("lib/init.lisp")
20974 );
20975 assert_eq!(
20976 behavior
20977 .get(M2_BEHAVIOR_KEY_ON_CALL)
20978 .and_then(|v| v.as_str()),
20979 Some("lib/handlers.lisp")
20980 );
20981 }
20982
20983 #[test]
20984 fn upgrade_from_slot_appears_under_camelcase_key() {
20985 let mut c = bare_servico();
20986 c.upgrade_from = vec![UpgradeFromEntry {
20987 from: "0.0.9".into(),
20988 instructions: vec![UpgradeInstruction::LoadModule {
20989 module: "hello-rio".into(),
20990 }],
20991 }];
20992 let overlay = servico_m2_overlay(&c).unwrap();
20993 let upgrade = overlay
20994 .get(M2_KEY_UPGRADE_FROM)
20995 .expect("upgradeFrom key present");
20996 let arr = upgrade.as_sequence().expect("sequence");
20997 assert_eq!(arr.len(), 1);
20998 assert_eq!(
20999 arr[0]
21000 .get(M2_UPGRADE_FROM_KEY_FROM)
21001 .and_then(|v| v.as_str()),
21002 Some("0.0.9")
21003 );
21004 }
21005
21006 #[test]
21007 fn all_three_slots_appear_in_alphabetical_iteration_order() {
21008 // BTreeMap iteration is sorted by key — pin that the renderers
21009 // can rely on a deterministic iteration order, which feeds
21010 // into deterministic YAML output (the value-as-proof property
21011 // THEORY.md §V.2.7 "render determinism" requires).
21012 let mut c = bare_servico();
21013 c.limits = Some(LimitsSpec {
21014 memory: Some(64 * 1024 * 1024),
21015 ..Default::default()
21016 });
21017 c.behavior = Some(BehaviorSpec {
21018 on_init: Some(PathBuf::from("lib/init.lisp")),
21019 ..Default::default()
21020 });
21021 c.upgrade_from = vec![UpgradeFromEntry {
21022 from: "0.0.9".into(),
21023 instructions: vec![UpgradeInstruction::LoadModule {
21024 module: "hello-rio".into(),
21025 }],
21026 }];
21027 let overlay = servico_m2_overlay(&c).unwrap();
21028 let keys: Vec<_> = overlay.keys().copied().collect();
21029 assert_eq!(
21030 keys,
21031 vec![M2_KEY_BEHAVIOR, M2_KEY_LIMITS, M2_KEY_UPGRADE_FROM]
21032 );
21033 }
21034
21035 // ── servico_spec_and_m2_overlay_entries — composed splice ────────────
21036 //
21037 // The compound peer of `servico_m2_overlay` on the ComputeUnit-YAML
21038 // `spec.*` + M2-overlay axis: fuses the two prior inline for-loops
21039 // caixa-flux::programs_yaml_entry and caixa-helm::build_values_yaml
21040 // both carried around `string_keyed_entries` + `servico_m2_overlay`
21041 // into one canonical composition. The pins below bracket the shape
21042 // end-to-end (spec.* keys first + preserved-insertion-order, then M2
21043 // slots in BTreeMap-key order at every M2 key not already claimed by
21044 // spec.*).
21045
21046 fn cu_yaml_with_spec_fields(spec_yaml: &str) -> serde_yaml::Value {
21047 serde_yaml::from_str(&format!(
21048 "apiVersion: wasm.pleme.io/v1alpha1\nkind: ComputeUnit\nmetadata:\n name: hello-rio\nspec:\n{spec_yaml}"
21049 ))
21050 .unwrap()
21051 }
21052
21053 #[test]
21054 fn servico_spec_and_m2_overlay_entries_empty_caixa_and_empty_spec_yields_empty() {
21055 let cu = cu_yaml_with_spec_fields(" {}\n");
21056 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
21057 let out = servico_spec_and_m2_overlay_entries(&bare_servico(), spec).unwrap();
21058 assert!(
21059 out.is_empty(),
21060 "empty spec + empty M2 surface yields zero entries \
21061 (both loops short-circuit vacuously)"
21062 );
21063 }
21064
21065 #[test]
21066 fn servico_spec_and_m2_overlay_entries_splices_spec_fields_in_source_insertion_order() {
21067 // The spec.* field-splice loop preserves the source YAML
21068 // Mapping's insertion order — caixa-flux's `serde_yaml::Mapping`
21069 // target reads this back verbatim, so a rebrand of the source
21070 // ComputeUnit YAML's field ordering must not silently reorder
21071 // the emitted programs.yaml entry.
21072 let cu = cu_yaml_with_spec_fields(
21073 " module:\n source: oci://ghcr.io/pleme-io/hello-rio:v0.1.0\n \
21074 trigger:\n service: {port: 8080}\n capabilities:\n - env\n",
21075 );
21076 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
21077 let out = servico_spec_and_m2_overlay_entries(&bare_servico(), spec).unwrap();
21078 let keys: Vec<&str> = out.iter().map(|(k, _)| k.as_str()).collect();
21079 assert_eq!(
21080 keys,
21081 vec![
21082 COMPUTEUNIT_SPEC_KEY_MODULE,
21083 COMPUTEUNIT_SPEC_KEY_TRIGGER,
21084 COMPUTEUNIT_SPEC_KEY_CAPABILITIES,
21085 ],
21086 "spec.* keys must appear in source-Mapping insertion order",
21087 );
21088 }
21089
21090 #[test]
21091 fn servico_spec_and_m2_overlay_entries_appends_m2_slots_after_spec_in_canonical_key_order() {
21092 // Bracket the second-half of the composition — the M2 overlay
21093 // walk lands after the spec.* splice, in BTreeMap-key ordering
21094 // (behavior → limits → upgradeFrom).
21095 let cu = cu_yaml_with_spec_fields(
21096 " module:\n source: oci://ghcr.io/pleme-io/hello-rio:v0.1.0\n",
21097 );
21098 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
21099 let mut c = bare_servico();
21100 c.limits = Some(LimitsSpec {
21101 memory: Some(64 * 1024 * 1024),
21102 ..Default::default()
21103 });
21104 c.behavior = Some(BehaviorSpec {
21105 on_init: Some(PathBuf::from("lib/init.lisp")),
21106 ..Default::default()
21107 });
21108 c.upgrade_from = vec![UpgradeFromEntry {
21109 from: "0.0.9".into(),
21110 instructions: vec![UpgradeInstruction::LoadModule {
21111 module: "hello-rio".into(),
21112 }],
21113 }];
21114 let out = servico_spec_and_m2_overlay_entries(&c, spec).unwrap();
21115 let keys: Vec<&str> = out.iter().map(|(k, _)| k.as_str()).collect();
21116 assert_eq!(
21117 keys,
21118 vec![
21119 COMPUTEUNIT_SPEC_KEY_MODULE,
21120 M2_KEY_BEHAVIOR,
21121 M2_KEY_LIMITS,
21122 M2_KEY_UPGRADE_FROM,
21123 ],
21124 "M2 slots must land after the spec.* splice, in canonical \
21125 BTreeMap key order",
21126 );
21127 }
21128
21129 #[test]
21130 fn servico_spec_and_m2_overlay_entries_or_insert_precedence_spec_wins_on_collision() {
21131 // The or_insert precedence rule the two prior inline blocks
21132 // shared: when the ComputeUnit YAML's `spec.*` sub-mapping
21133 // already carries the M2 slot's key (an author-authored
21134 // ComputeUnit `spec.limits` overriding the manifest-derived
21135 // `caixa.limits` overlay), the spec.* value stays and the M2
21136 // overlay's value is skipped. Regression-guards against a
21137 // future reversal ("M2 wins on collision") silently changing
21138 // the composition without an explicit slot-precedence flip at
21139 // the helper.
21140 let cu = cu_yaml_with_spec_fields(
21141 " limits:\n memory: from-spec\n module:\n source: oci://x\n",
21142 );
21143 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
21144 let mut c = bare_servico();
21145 c.limits = Some(LimitsSpec {
21146 memory: Some(64 * 1024 * 1024),
21147 ..Default::default()
21148 });
21149 let out = servico_spec_and_m2_overlay_entries(&c, spec).unwrap();
21150 let limits_entries: Vec<&(String, serde_yaml::Value)> =
21151 out.iter().filter(|(k, _)| k == M2_KEY_LIMITS).collect();
21152 assert_eq!(
21153 limits_entries.len(),
21154 1,
21155 "on collision the M2 overlay's `limits` entry must be \
21156 filtered out — spec.* wins, and appears exactly once",
21157 );
21158 assert_eq!(
21159 limits_entries[0]
21160 .1
21161 .get(M2_LIMITS_KEY_MEMORY)
21162 .and_then(|v| v.as_str()),
21163 Some("from-spec"),
21164 "the surviving `limits` entry must carry the spec.* value, \
21165 not the manifest-derived M2 overlay's value",
21166 );
21167 }
21168
21169 #[test]
21170 fn servico_spec_and_m2_overlay_entries_short_circuits_on_non_mapping_spec() {
21171 // Sibling `string_keyed_entries` docstring pins the
21172 // non-Mapping short-circuit; extend it to the composed splice
21173 // — a spec that isn't a Mapping yields zero spec.* entries,
21174 // and only the M2 overlay contributes. Bracket-guard against a
21175 // future refactor that swaps `string_keyed_entries` for a
21176 // stricter parser silently dropping the M2 half too.
21177 let non_mapping_spec = serde_yaml::Value::String("not-a-mapping".into());
21178 let mut c = bare_servico();
21179 c.limits = Some(LimitsSpec {
21180 memory: Some(64 * 1024 * 1024),
21181 ..Default::default()
21182 });
21183 let out = servico_spec_and_m2_overlay_entries(&c, &non_mapping_spec).unwrap();
21184 let keys: Vec<&str> = out.iter().map(|(k, _)| k.as_str()).collect();
21185 assert_eq!(
21186 keys,
21187 vec![M2_KEY_LIMITS],
21188 "non-Mapping spec short-circuits the spec.* splice; the M2 \
21189 overlay still contributes its filled slots",
21190 );
21191 }
21192
21193 #[test]
21194 fn servico_spec_and_m2_overlay_entries_matches_hand_written_composition() {
21195 // Cross-check the lifted composition against the hand-written
21196 // two-loop shape the two prior inline blocks carried. A drift
21197 // between the helper and the inline composition would silently
21198 // emit a different key set / ordering / precedence at every
21199 // routed renderer — pin the equivalence so the helper stays a
21200 // drop-in replacement for both.
21201 let cu = cu_yaml_with_spec_fields(
21202 " module:\n source: oci://ghcr.io/pleme-io/hello-rio:v0.1.0\n \
21203 trigger:\n service: {port: 8080}\n",
21204 );
21205 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
21206 let mut c = bare_servico();
21207 c.limits = Some(LimitsSpec {
21208 memory: Some(32 * 1024 * 1024),
21209 ..Default::default()
21210 });
21211 c.behavior = Some(BehaviorSpec {
21212 on_call: Some(PathBuf::from("lib/handlers.lisp")),
21213 ..Default::default()
21214 });
21215
21216 let via_helper = servico_spec_and_m2_overlay_entries(&c, spec).unwrap();
21217
21218 let mut via_inline: Vec<(String, serde_yaml::Value)> = Vec::new();
21219 let mut seen: std::collections::HashSet<String> = std::collections::HashSet::new();
21220 for (k, v) in string_keyed_entries(spec) {
21221 seen.insert(k.to_string());
21222 via_inline.push((k.to_string(), v.clone()));
21223 }
21224 for (key, value) in servico_m2_overlay(&c).unwrap() {
21225 if !seen.contains(key) {
21226 via_inline.push((key.to_string(), value));
21227 }
21228 }
21229
21230 assert_eq!(
21231 via_helper, via_inline,
21232 "servico_spec_and_m2_overlay_entries must byte-equal the \
21233 hand-written two-loop composition (spec.* splice + M2 \
21234 overlay with or_insert precedence) the two prior inline \
21235 call sites carried",
21236 );
21237 }
21238
21239 #[test]
21240 fn pleme_label_consts_share_canonical_prefix() {
21241 // Single-source-of-truth invariant: every pleme-io label key
21242 // is `<PLEME_LABEL_PREFIX>/<axis>`. A future label-namespace
21243 // rebrand is a one-line PLEME_LABEL_PREFIX edit + this test
21244 // pins the contract that no other label leaks past the lift.
21245 for k in [LABEL_APLICACAO, LABEL_PROGRAM, LABEL_CONTRATO] {
21246 assert!(
21247 k.starts_with(PLEME_LABEL_PREFIX),
21248 "label key {k:?} must share the {PLEME_LABEL_PREFIX:?} prefix"
21249 );
21250 // Each label is `<prefix>/<axis>` — the suffix is non-empty
21251 // (the `/` separator is followed by the axis name).
21252 let suffix = k.strip_prefix(PLEME_LABEL_PREFIX).unwrap();
21253 assert!(suffix.starts_with('/'));
21254 assert!(suffix.len() > 1, "axis name must be non-empty for {k:?}");
21255 }
21256 }
21257
21258 #[test]
21259 fn pleme_label_consts_have_expected_canonical_values() {
21260 // Pin the actual string values so a typo in the lift can't
21261 // silently rebrand the whole pleme-io label namespace. These
21262 // strings are part of the cluster-side contract with the
21263 // lareira-fleet-programs chart + Cilium identity layer + Hubble
21264 // flow attribution; changing any of them is a coordinated
21265 // multi-repo migration, not an incidental edit.
21266 assert_eq!(PLEME_LABEL_PREFIX, "pleme.pleme.io");
21267 assert_eq!(LABEL_APLICACAO, "pleme.pleme.io/aplicacao");
21268 assert_eq!(LABEL_PROGRAM, "pleme.pleme.io/program");
21269 assert_eq!(LABEL_CONTRATO, "pleme.pleme.io/contrato");
21270 }
21271
21272 #[test]
21273 fn default_namespace_pins_canonical_value() {
21274 // Pin the actual string so a typo in this lift can't silently
21275 // rebrand the cluster-side namespace every renderer emits
21276 // into. The string is part of the cluster-side contract with
21277 // the lareira-fleet-programs aggregator chart, the per-cluster
21278 // CiliumNetworkPolicy `endpointSelector` namespace scope, the
21279 // Gateway / HTTPRoute apply namespace, and the future M4
21280 // `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's apply
21281 // namespace; changing it is a coordinated multi-repo migration
21282 // (the per-cluster k8s repo's namespaces, every
21283 // lareira-fleet-programs HelmRelease's targetNamespace, every
21284 // ComputeUnit's `metadata.namespace`), not an incidental edit.
21285 // Peer to `pleme_label_consts_have_expected_canonical_values`
21286 // on the canonical-string-value-pin axis for the
21287 // `PLEME_LABEL_PREFIX` / `LABEL_*` constants.
21288 assert_eq!(DEFAULT_NAMESPACE, "tatara-system");
21289 }
21290
21291 #[test]
21292 fn default_flux_system_namespace_pins_canonical_value() {
21293 // Pin the actual string so a typo in this lift can't silently
21294 // rebrand the FluxCD installation namespace the rendered
21295 // `kustomization.yaml`'s `metadata.namespace` /
21296 // `spec.sourceRef.name` axes consume. The string is part of the
21297 // cluster-side contract with the `flux bootstrap` pipeline (the
21298 // bootstrap convention names the `GitRepository` after the
21299 // installation namespace, so both axes are the same load-bearing
21300 // string), the `kustomize-controller` watch-window scope (a
21301 // drifted value sits outside the controller's watch window and
21302 // is never reconciled), and the per-cluster k8s repo's flux
21303 // bootstrap manifests; changing it is a coordinated multi-repo
21304 // migration, not an incidental edit. Peer to
21305 // `default_namespace_pins_canonical_value` on the
21306 // canonical-string-value-pin axis for the workload-side
21307 // [`DEFAULT_NAMESPACE`] constant.
21308 assert_eq!(DEFAULT_FLUX_SYSTEM_NAMESPACE, "flux-system");
21309 }
21310
21311 #[test]
21312 fn default_flux_system_namespace_is_a_valid_dns_1123_label() {
21313 // Cross-axis invariant: the FluxCD installation namespace lands
21314 // as `metadata.namespace` on every emitted `Kustomization`
21315 // resource and as `spec.sourceRef.name` (a K8s resource name
21316 // under the same DNS-1123 floor), and the K8s apiserver
21317 // enforces the DNS-1123 label rule on both. Pinning this here
21318 // means a future rebrand on the canonical lift can't silently
21319 // land a value the apiserver refuses at the *first*
21320 // `kustomization.yaml` apply against a cluster, far from the
21321 // rebrand commit's source — the typed [`is_dns_1123_label`]
21322 // floor rejects it at caixa-core build time on the canonical
21323 // lift, before any renderer consumes the value. Same shape as
21324 // `default_namespace_is_a_valid_dns_1123_label` on the
21325 // workload-side [`DEFAULT_NAMESPACE`] axis.
21326 assert!(
21327 is_dns_1123_label(DEFAULT_FLUX_SYSTEM_NAMESPACE).is_ok(),
21328 "DEFAULT_FLUX_SYSTEM_NAMESPACE {DEFAULT_FLUX_SYSTEM_NAMESPACE:?} must be a valid \
21329 DNS-1123 label — every K8s apiserver-side schema enforces \
21330 this rule on `metadata.namespace`"
21331 );
21332 }
21333
21334 #[test]
21335 fn default_flux_reconcile_interval_pins_canonical_value() {
21336 // Pin the actual string so a typo in this lift can't silently
21337 // rebrand the substrate-side default Flux v2 reconcile-poll
21338 // cadence duration scalar the substrate's per-caixa
21339 // `cluster_bundle` renderer seeds into every emitted per-caixa
21340 // Flux v2 CR (GitRepository / HelmRelease / Kustomization) at
21341 // its `spec.interval` axis when the operator doesn't pin a per-
21342 // caixa override. The string is part of the cluster-side
21343 // contract with the Flux v2 source-controller / helm-controller
21344 // / kustomize-controller trio: each controller's per-CR admission
21345 // gate parses the value via `metav1.ParseDuration` before
21346 // installing the per-CR watch, and the resulting cadence pins
21347 // the per-CR reconcile-freshness / cluster-load tradeoff every
21348 // substrate-side Flux v2 pipeline runs at. Changing this value
21349 // is a coordinated substrate-side reconcile-cadence promotion
21350 // (a `10m` → `5m` migration once lower-latency-poll optimizations
21351 // ship, a `10m` → `15m` migration on cost-optimized clusters
21352 // where per-CR source-controller poll cost outweighs the
21353 // reconcile-freshness gain), not an incidental edit. Peer to
21354 // `default_namespace_pins_canonical_value` and
21355 // `default_gateway_class_name_pins_canonical_value` on the
21356 // canonical-substrate-default-load-bearing-scalar pin surface.
21357 assert_eq!(DEFAULT_FLUX_RECONCILE_INTERVAL, "10m");
21358 }
21359
21360 #[test]
21361 fn default_flux_reconcile_interval_is_a_valid_metav1_duration_scalar() {
21362 // Cross-axis grammar invariant: the Flux v2 controller-side per-
21363 // CR admission gate parses the reconcile-poll cadence scalar via
21364 // `metav1.ParseDuration` before installing the per-CR watch. The
21365 // Go-duration-format grammar is non-empty, ASCII, and structured
21366 // as `<digits><unit>[<digits><unit>...]` where each unit is one
21367 // of `{ns, us, µs, ms, s, m, h}`. Pin a floor that catches the
21368 // canonical drift footguns — an empty scalar (`""` — admission
21369 // gate rejects), a non-ASCII-alphanumeric byte (`"10 m"` — the
21370 // whitespace defeats the parser), a missing-unit scalar (`"10"`
21371 // — the parser rejects for lack of a unit suffix), or a leading-
21372 // non-digit scalar (`"m10"` — the parser rejects for lack of a
21373 // leading magnitude). A future rebrand on the canonical lift
21374 // that lands a value outside the Go-duration-format grammar
21375 // would surface here at caixa-core build time on the canonical
21376 // lift, before any renderer consumes the value. Same shape as
21377 // `default_namespace_is_a_valid_dns_1123_label` /
21378 // `default_flux_system_namespace_is_a_valid_dns_1123_label` /
21379 // `default_gateway_class_name_is_a_valid_dns_1123_label` on the
21380 // peer canonical-substrate-default-grammar-floor surface.
21381 let v = DEFAULT_FLUX_RECONCILE_INTERVAL;
21382 assert!(
21383 !v.is_empty(),
21384 "DEFAULT_FLUX_RECONCILE_INTERVAL {v:?} must be non-empty \
21385 per the Flux v2 controller-side `metav1.ParseDuration` \
21386 admission gate"
21387 );
21388 assert!(
21389 v.chars().all(|c| c.is_ascii_alphanumeric()),
21390 "DEFAULT_FLUX_RECONCILE_INTERVAL {v:?} must be ASCII-\
21391 alphanumeric throughout per the Go-duration-format grammar \
21392 — no whitespace / separator bytes the `metav1.ParseDuration` \
21393 admission gate would reject"
21394 );
21395 let first = v.chars().next().expect("non-empty");
21396 assert!(
21397 first.is_ascii_digit(),
21398 "DEFAULT_FLUX_RECONCILE_INTERVAL {v:?} first byte {first:?} \
21399 must be an ASCII digit per the Go-duration-format grammar \
21400 — the leading magnitude precedes the unit suffix; a leading \
21401 non-digit defeats `metav1.ParseDuration`"
21402 );
21403 let last = v.chars().next_back().expect("non-empty");
21404 assert!(
21405 last.is_ascii_alphabetic() && last.is_ascii_lowercase(),
21406 "DEFAULT_FLUX_RECONCILE_INTERVAL {v:?} last byte {last:?} \
21407 must be an ASCII lowercase alphabetic unit suffix per the \
21408 Go-duration-format grammar — the trailing unit follows the \
21409 magnitude; an unterminated magnitude defeats \
21410 `metav1.ParseDuration`"
21411 );
21412 }
21413
21414 #[test]
21415 fn default_flux_chart_source_subpath_pins_canonical_value() {
21416 // Pin the actual scalar so a typo in this lift can't silently
21417 // rebrand the substrate-side default Flux v2
21418 // `HelmRelease.spec.chart.spec.chart` chart-directory-in-
21419 // GitRepository-source sub-path the substrate's per-caixa
21420 // `cluster_bundle` renderer seeds into every emitted per-caixa
21421 // `helmrelease.yaml` document. The value is part of the
21422 // cluster-side contract with the Flux v2 helm-controller (the
21423 // per-CR chart-open loop uses this to locate the
21424 // `Chart.yaml` + `values.yaml` pair inside the paired
21425 // GitRepository clone root); changing it is a coordinated
21426 // substrate-side chart-directory-in-git-source promotion
21427 // (a `"chart"` → `"charts"` migration on a per-caixa multi-chart
21428 // layout landing, a `"chart"` → `"helm"` migration on a
21429 // cross-language convention alignment, a `"chart"` → `"deploy"`
21430 // migration on a per-caixa-deploy-directory naming migration),
21431 // not an incidental edit. Peer to
21432 // `default_flux_reconcile_interval_pins_canonical_value` +
21433 // `flux_helmrelease_remediation_retries_default_pins_canonical_value`
21434 // on the canonical-Flux-v2-per-CR-substrate-default-scalar pin
21435 // surface.
21436 assert_eq!(DEFAULT_FLUX_CHART_SOURCE_SUBPATH, "chart");
21437 }
21438
21439 #[test]
21440 fn default_flux_chart_source_subpath_is_a_valid_relative_directory_scalar() {
21441 // Cross-axis grammar invariant: the Flux v2 source-controller
21442 // resolves the per-CR `HelmRelease.spec.chart.spec.chart` scalar
21443 // as a directory path relative to the paired `GitRepository`
21444 // clone root. Pin a floor that catches the canonical drift
21445 // footguns — an empty scalar (`""` — the source-controller-side
21446 // per-CR chart-open loop rejects for lack of a target directory),
21447 // a leading-separator scalar (`"/chart"` — the source-controller
21448 // rejects for the absolute-path shape breaking the relative-path
21449 // composition against the per-clone-root anchor), a non-ASCII
21450 // byte (a UTF-8 multi-byte name defeating the per-clone-root
21451 // filesystem name resolution on the source-controller pod's
21452 // filesystem layer), or a leading whitespace / dot byte (`" chart"`
21453 // / `".chart"` — surface as either a "directory not found" per-
21454 // CR error or, worse, a silent match against a hidden dot-file
21455 // sibling of the intended chart directory). A future rebrand on
21456 // the canonical lift that lands a value outside the grammar
21457 // would surface here at caixa-core build time on the canonical
21458 // lift, before any renderer consumes the value. Same shape as
21459 // `default_flux_reconcile_interval_is_a_valid_metav1_duration_scalar`
21460 // on the peer canonical-substrate-default-grammar-floor surface.
21461 let v = DEFAULT_FLUX_CHART_SOURCE_SUBPATH;
21462 assert!(
21463 !v.is_empty(),
21464 "DEFAULT_FLUX_CHART_SOURCE_SUBPATH {v:?} must be non-empty \
21465 per the Flux v2 source-controller-side per-CR chart-open \
21466 loop's requirement of a target directory"
21467 );
21468 assert!(
21469 v.is_ascii(),
21470 "DEFAULT_FLUX_CHART_SOURCE_SUBPATH {v:?} must be ASCII \
21471 throughout — a non-ASCII multi-byte name defeats the per-\
21472 clone-root filesystem name resolution on the source-\
21473 controller pod's filesystem layer"
21474 );
21475 let first = v.chars().next().expect("non-empty");
21476 assert!(
21477 !matches!(first, '/' | '.' | ' ' | '\t'),
21478 "DEFAULT_FLUX_CHART_SOURCE_SUBPATH {v:?} first byte {first:?} \
21479 must not be a leading separator (`/`), leading dot (`.`), or \
21480 leading whitespace — a leading separator breaks the relative-\
21481 path composition against the per-clone-root anchor, a leading \
21482 dot risks silent matches against hidden dot-file siblings, and \
21483 leading whitespace defeats the per-clone-root filesystem name \
21484 resolution"
21485 );
21486 }
21487
21488 #[test]
21489 fn flux_helmrelease_remediation_retries_default_pins_canonical_value() {
21490 // Pin the actual scalar so a typo in this lift can't silently
21491 // rebrand the substrate-side default Flux v2
21492 // `HelmRelease.spec.{install,upgrade}.remediation.retries` retry-
21493 // count ceiling the substrate's per-caixa `cluster_bundle`
21494 // renderer seeds into every emitted per-caixa `helmrelease.yaml`
21495 // document under both the install-path and the upgrade-path
21496 // remediation blocks. The value is part of the cluster-side
21497 // contract with the Flux v2 helm-controller (the per-CR
21498 // remediation loop uses this as the ceiling on the number of
21499 // Helm-install / Helm-upgrade re-attempts before the controller
21500 // marks the `HelmRelease` `Ready: False` and stops retrying);
21501 // changing it is a coordinated substrate-side retry-ceiling
21502 // promotion (a `3` → `5` migration once per-caixa idempotency
21503 // invariants tighten and higher-retry recovery from transient
21504 // apiserver / registry / oci-source flakes becomes safe, a `3` →
21505 // `1` migration on hardened per-caixa pipelines where a failed
21506 // apply should escalate to operator-attention rather than mask
21507 // under further retries), not an incidental edit. Peer to
21508 // `default_flux_reconcile_interval_pins_canonical_value` on the
21509 // canonical-Flux-v2-per-CR-substrate-default-scalar pin surface.
21510 assert_eq!(FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT, 3);
21511 }
21512
21513 #[test]
21514 fn flux_helmrelease_remediation_retries_default_is_a_bounded_positive_scalar() {
21515 // Cross-axis invariant: the Flux v2 `HelmRelease.spec.{install,
21516 // upgrade}.remediation.retries` OpenAPI schema types the field
21517 // as a signed 64-bit integer with a documented sentinel `-1`
21518 // meaning "retry indefinitely". The substrate opts out of the
21519 // unbounded-retry sentinel by declaring the canonical default as
21520 // a positive `u32` — the type itself rules out `-1` at
21521 // caixa-core build time, so a future rebrand on this lift cannot
21522 // silently land the "retry forever" sentinel by construction
21523 // (which would let a persistently-failing per-caixa chart apply
21524 // consume Flux v2 helm-controller reconcile-loop cycles
21525 // indefinitely, masking under further retries rather than
21526 // surfacing at the `HelmRelease.status.conditions[]` axis the
21527 // substrate's downstream reconciliation-topology consumer
21528 // watches). Pin the positive-scalar floor + a substrate-side
21529 // "sane retry ceiling" upper bound (the same 100-attempt hard
21530 // cap the peer `POLICY_RETRIES_MAX` per-`:politicas :retries`
21531 // axis carries; a substrate that seeds a per-CR default above
21532 // that ceiling is structurally a footgun by the same
21533 // "unbounded-retry masks the underlying failure" argument that
21534 // motivates the mesh-policy retries cap). Same shape as
21535 // `default_flux_reconcile_interval_is_a_valid_metav1_duration_scalar`
21536 // on the peer canonical-substrate-default-grammar-floor surface.
21537 let v = FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT;
21538 assert!(
21539 v > 0,
21540 "FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT {v} must be strictly \
21541 positive per the substrate's opt-out from the Flux v2 \
21542 `retries: -1` unbounded-retry sentinel — the `u32` type rules \
21543 out the sentinel, and a zero-retries default is structurally \
21544 a `remediation:` sub-block that never fires the retry path it \
21545 is declaring"
21546 );
21547 assert!(
21548 v <= 100,
21549 "FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT {v} must be within \
21550 the substrate's canonical retry-ceiling upper bound (100) — a \
21551 per-CR default above that ceiling silently masks the underlying \
21552 chart-apply failure under further retries rather than surfacing \
21553 it at the `HelmRelease.status.conditions[]` axis the substrate's \
21554 downstream reconciliation-topology consumer watches, the same \
21555 argument that motivates the peer `POLICY_RETRIES_MAX` per-\
21556 `:politicas :retries` axis cap"
21557 );
21558 }
21559
21560 #[test]
21561 fn flux_helmrelease_key_remediation_pins_canonical_value() {
21562 // Pin the actual string so a typo in this lift can't silently
21563 // rebrand the substrate-side Flux v2
21564 // `HelmRelease.spec.{install,upgrade}.remediation` sub-container-
21565 // axis key the substrate's per-caixa `cluster_bundle` renderer
21566 // seeds into every emitted per-caixa `helmrelease.yaml` document
21567 // at both the install-path + upgrade-path per-CR remediation
21568 // sub-block-header positions. The string is part of the cluster-
21569 // side contract with the Flux v2 helm-controller (the controller's
21570 // per-CR remediation loop reaches the retry-cap scalar through
21571 // this exact sub-container axis; a drifted sub-container-key
21572 // silently strips the entire per-path remediation block from the
21573 // emitted per-CR document, leaving the helm-controller to fall
21574 // back to the Flux v2 upstream defaults for the whole remediation
21575 // surface rather than the substrate's chosen ceiling, with no
21576 // diagnostic naming the container-axis-key-drift root cause).
21577 // Changing it is a coordinated Flux v3 CRD-schema-rebrand
21578 // migration alongside the upstream `helm-controller` deprecation
21579 // cycle (candidates like `recovery` / `retryPolicy` /
21580 // `errorHandling` that upstream Flux v3 roadmap floats in the
21581 // migration prose), not an incidental edit. Peer to
21582 // `flux_helmrelease_remediation_retries_default_pins_canonical_value`
21583 // on the sibling scalar-value half + the sibling
21584 // [`FLUX_HELMRELEASE_KEY_RETRIES`] leaf-scalar-key half of the
21585 // same per-path retry-cap declaration triple.
21586 assert_eq!(FLUX_HELMRELEASE_KEY_REMEDIATION, "remediation");
21587 }
21588
21589 #[test]
21590 fn flux_helmrelease_key_remediation_is_a_valid_dns_1123_label() {
21591 // Cross-axis invariant: every Flux v2 `HelmRelease` CRD-schema
21592 // sub-block-header key resolves through the K8s apiserver's
21593 // OpenAPI-schema-side identifier grammar, whose per-field key
21594 // axis is a subset of the DNS-1123-label grammar (lowercase
21595 // alphanumerics + hyphens, non-empty, ≤63 bytes). Pinning the
21596 // canonical `remediation` value against the typed
21597 // [`is_dns_1123_label`] floor rules out grammar drift on this
21598 // lift at caixa-core build time — a future rebrand landing a
21599 // value outside the DNS-1123-label subset (a leading digit, an
21600 // underscore, an uppercase byte, a `.` byte, or empty) would
21601 // surface here on the canonical lift, before any renderer
21602 // consumes the value and before any per-caixa Flux v2 CR reaches
21603 // the apiserver's OpenAPI-schema-side per-field admission gate.
21604 // Same shape as `default_gateway_class_name_is_a_valid_dns_1123_label`
21605 // on the peer canonical-CRD-schema-grammar-floor surface.
21606 assert!(
21607 is_dns_1123_label(FLUX_HELMRELEASE_KEY_REMEDIATION).is_ok(),
21608 "FLUX_HELMRELEASE_KEY_REMEDIATION {FLUX_HELMRELEASE_KEY_REMEDIATION:?} \
21609 must be a valid DNS-1123 label — every K8s apiserver-side \
21610 OpenAPI-schema-per-field-key axis is a subset of that grammar, \
21611 and the Flux v2 `HelmRelease` CRD schema is no exception"
21612 );
21613 }
21614
21615 #[test]
21616 fn flux_helmrelease_key_install_pins_canonical_value() {
21617 // Pin the actual string so a typo in this lift can't silently
21618 // rebrand the Flux v2 `HelmRelease.spec.install` per-CR helm-
21619 // action-phase discriminator parent-container-axis-key the
21620 // rendered `helmrelease.yaml` document mounts its per-CR first-
21621 // time chart apply phase-block under. The string is part of the
21622 // cluster-side contract with the upstream Flux v2 helm-
21623 // controller — the helm-controller's per-CR phase-dispatch loop
21624 // reaches the install-path phase block through this exact parent-
21625 // container axis; a drifted parent-container-key silently strips
21626 // the entire install-path phase block from the emitted per-CR
21627 // document, leaving the helm-controller to fall back to the Flux
21628 // v2 upstream defaults for the whole install-path phase surface
21629 // rather than the substrate's chosen per-CR install-path knob-set
21630 // (the `createNamespace` seeder never fires, the per-CR retry-cap
21631 // ceiling silently drops off the emitted document), with no
21632 // diagnostic naming the phase-discriminator-drift root cause.
21633 // Changing it is a coordinated Flux v3 CRD-schema-rebrand
21634 // migration alongside the upstream `helm-controller` deprecation
21635 // cycle (candidates like `initialize` / `apply` / `create` /
21636 // `first-run` that upstream Flux v3 roadmap floats in the
21637 // migration prose), not an incidental edit. Peer to
21638 // `flux_helmrelease_key_upgrade_pins_canonical_value` on the
21639 // sibling per-CR upgrade-path phase-discriminator parent-
21640 // container-axis-key half of the same per-CR helm-action-phase
21641 // discriminator parent-container-axis-key pair + the sibling
21642 // [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-axis-key
21643 // hosted beneath both parent-container-axis-keys.
21644 assert_eq!(FLUX_HELMRELEASE_KEY_INSTALL, "install");
21645 }
21646
21647 #[test]
21648 fn flux_helmrelease_key_install_is_a_valid_dns_1123_label() {
21649 // Cross-axis invariant: every Flux v2 `HelmRelease` CRD-schema
21650 // sub-block-header key resolves through the K8s apiserver's
21651 // OpenAPI-schema-side identifier grammar, whose per-field key
21652 // axis is a subset of the DNS-1123-label grammar (lowercase
21653 // alphanumerics + hyphens, non-empty, ≤63 bytes). Pinning the
21654 // canonical `install` value against the typed
21655 // [`is_dns_1123_label`] floor rules out grammar drift on this
21656 // lift at caixa-core build time — a future rebrand landing a
21657 // value outside the DNS-1123-label subset (a leading digit, an
21658 // underscore, an uppercase byte, a `.` byte, or empty) would
21659 // surface here on the canonical lift, before any renderer
21660 // consumes the value and before any per-caixa Flux v2 CR reaches
21661 // the apiserver's OpenAPI-schema-side per-field admission gate.
21662 // Same shape as `flux_helmrelease_key_remediation_is_a_valid_
21663 // dns_1123_label` on the sibling per-CR sub-container-axis-key
21664 // grammar-floor surface.
21665 assert!(
21666 is_dns_1123_label(FLUX_HELMRELEASE_KEY_INSTALL).is_ok(),
21667 "FLUX_HELMRELEASE_KEY_INSTALL {FLUX_HELMRELEASE_KEY_INSTALL:?} \
21668 must be a valid DNS-1123 label — every K8s apiserver-side \
21669 OpenAPI-schema-per-field-key axis is a subset of that grammar, \
21670 and the Flux v2 `HelmRelease` CRD schema is no exception"
21671 );
21672 }
21673
21674 #[test]
21675 fn flux_helmrelease_key_upgrade_pins_canonical_value() {
21676 // Pin the actual string so a typo in this lift can't silently
21677 // rebrand the Flux v2 `HelmRelease.spec.upgrade` per-CR helm-
21678 // action-phase discriminator parent-container-axis-key the
21679 // rendered `helmrelease.yaml` document mounts its per-CR
21680 // subsequent-per-version chart re-apply phase-block under. The
21681 // string is part of the cluster-side contract with the upstream
21682 // Flux v2 helm-controller — the helm-controller's per-CR phase-
21683 // dispatch loop reaches the upgrade-path phase block through this
21684 // exact parent-container axis on every per-version chart re-apply
21685 // after the initial install-path phase completes; a drifted
21686 // parent-container-key silently strips the entire upgrade-path
21687 // phase block from the emitted per-CR document, leaving the
21688 // helm-controller to fall back to the Flux v2 upstream defaults
21689 // for the whole upgrade-path phase surface rather than the
21690 // substrate's chosen per-CR upgrade-path knob-set (the
21691 // `remediateLastFailure` toggle never fires, the per-CR retry-
21692 // cap ceiling silently drops off the emitted document), with no
21693 // diagnostic naming the phase-discriminator-drift root cause.
21694 // Changing it is a coordinated Flux v3 CRD-schema-rebrand
21695 // migration alongside the upstream `helm-controller` deprecation
21696 // cycle (candidates like `reapply` / `reconcile` / `update` /
21697 // `promote` that upstream Flux v3 roadmap floats in the
21698 // migration prose), not an incidental edit. Peer to
21699 // `flux_helmrelease_key_install_pins_canonical_value` on the
21700 // sibling per-CR install-path phase-discriminator parent-
21701 // container-axis-key half of the same per-CR helm-action-phase
21702 // discriminator parent-container-axis-key pair.
21703 assert_eq!(FLUX_HELMRELEASE_KEY_UPGRADE, "upgrade");
21704 }
21705
21706 #[test]
21707 fn flux_helmrelease_key_upgrade_is_a_valid_dns_1123_label() {
21708 // Cross-axis invariant: every Flux v2 `HelmRelease` CRD-schema
21709 // sub-block-header key resolves through the K8s apiserver's
21710 // OpenAPI-schema-side identifier grammar, whose per-field key
21711 // axis is a subset of the DNS-1123-label grammar. Pinning the
21712 // canonical `upgrade` value against the typed
21713 // [`is_dns_1123_label`] floor rules out grammar drift on this
21714 // lift at caixa-core build time. Peer to
21715 // `flux_helmrelease_key_install_is_a_valid_dns_1123_label` on
21716 // the sibling install-path phase-discriminator grammar-floor
21717 // surface + `flux_helmrelease_key_remediation_is_a_valid_dns_
21718 // 1123_label` on the sibling per-CR sub-container-axis-key
21719 // grammar-floor surface — same DNS-1123-label subset governs
21720 // every apiserver-side per-field-key axis, so every peer per-CR
21721 // sub-block-header lift carries the same grammar-floor pin.
21722 assert!(
21723 is_dns_1123_label(FLUX_HELMRELEASE_KEY_UPGRADE).is_ok(),
21724 "FLUX_HELMRELEASE_KEY_UPGRADE {FLUX_HELMRELEASE_KEY_UPGRADE:?} \
21725 must be a valid DNS-1123 label — every K8s apiserver-side \
21726 OpenAPI-schema-per-field-key axis is a subset of that grammar, \
21727 and the Flux v2 `HelmRelease` CRD schema is no exception"
21728 );
21729 }
21730
21731 #[test]
21732 fn flux_helmrelease_key_install_and_upgrade_stay_independent_axes() {
21733 // The two per-CR helm-action-phase discriminator parent-
21734 // container-axis-keys name distinct helm-controller-side phases
21735 // — install-path first-time chart apply vs upgrade-path per-
21736 // version chart re-apply — even though both host the same
21737 // sibling [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-
21738 // axis-key beneath them. Pin that the two consts carry distinct
21739 // byte-sequences so a future rebrand on either arm can't
21740 // silently coalesce onto the peer arm (a
21741 // `FLUX_HELMRELEASE_KEY_INSTALL = "upgrade"` typo would flip
21742 // every substrate-side per-CR first-time chart apply phase
21743 // block onto the upgrade-path phase key silently — the install-
21744 // path becomes the upgrade-path at every emit site, and the
21745 // helm-controller reconciles both phase blocks under the same
21746 // parent-container-axis-key, silently dropping either the
21747 // install-path or the upgrade-path per-CR knob-set with no
21748 // diagnostic naming the phase-discriminator-coalesce root
21749 // cause). The per-CR helm-action-phase discriminator pair must
21750 // always resolve to distinct emitted parent-container-keys.
21751 assert_ne!(
21752 FLUX_HELMRELEASE_KEY_INSTALL, FLUX_HELMRELEASE_KEY_UPGRADE,
21753 "the per-CR install-path and upgrade-path helm-action-phase \
21754 discriminator parent-container-axis-keys must remain byte-\
21755 distinct — a coalesce onto one value silently drops either \
21756 the install-path or the upgrade-path per-CR knob-set from \
21757 every emitted `HelmRelease` document"
21758 );
21759 }
21760
21761 #[test]
21762 fn flux_helmrelease_key_remediate_last_failure_pins_canonical_value() {
21763 // Pin the actual string so a typo in this lift can't silently
21764 // rebrand the Flux v2 `HelmRelease.spec.upgrade.remediation
21765 // .remediateLastFailure` upgrade-path-only per-CR remediation-
21766 // toggle leaf-scalar-key the substrate's per-caixa `cluster_bundle`
21767 // renderer seeds to `true` into every emitted per-caixa
21768 // `helmrelease.yaml` document under the sibling
21769 // [`FLUX_HELMRELEASE_KEY_UPGRADE`] per-CR upgrade-path phase-
21770 // discriminator parent-container-axis-key's nested
21771 // [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-axis-key. The
21772 // string is part of the cluster-side contract with the upstream
21773 // Flux v2 helm-controller — the controller's per-CR upgrade-path
21774 // remediation loop reaches the post-retry-exhaustion rollback
21775 // toggle through this exact leaf; a drifted leaf-scalar-key
21776 // silently strips the substrate's chosen post-retry-exhaustion
21777 // rollback semantic from every emitted per-caixa `HelmRelease`
21778 // document, leaving the helm-controller to leave every terminally-
21779 // failed upgrade in the failed state without rolling back to the
21780 // prior last-known-good release the substrate's "no chart apply
21781 // leaves a per-caixa CR in a stalled, unremediated state"
21782 // MESH-COMPOSITION.md §V guarantee mandates, with no diagnostic
21783 // naming the remediation-toggle-drift root cause. Changing it is
21784 // a coordinated Flux v3 CRD-schema-rebrand migration alongside
21785 // the upstream `helm-controller` deprecation cycle (candidates
21786 // like `rollbackOnFailure` / `remediateOnFailure` /
21787 // `recoverLastFailure` that upstream Flux v3 roadmap floats in
21788 // the migration prose), not an incidental edit. Peer to
21789 // `flux_helmrelease_key_retries_pins_canonical_value` on the
21790 // sibling per-CR retry-cap leaf-scalar-key half of the same
21791 // upgrade-path per-CR remediation block leaf-scalar-key pair.
21792 assert_eq!(
21793 FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE,
21794 "remediateLastFailure"
21795 );
21796 }
21797
21798 #[test]
21799 fn flux_helmrelease_key_remediate_last_failure_stays_independent_of_retries() {
21800 // The upgrade-path per-CR remediation block hosts two independent
21801 // leaf-scalar-key axes under the shared sibling
21802 // [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-axis-key —
21803 // the per-CR retry-cap [`FLUX_HELMRELEASE_KEY_RETRIES`] (that
21804 // also sits under the install-path per-CR remediation block) and
21805 // the upgrade-path-only per-CR remediation-toggle
21806 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`]. Pin that the
21807 // two consts carry byte-distinct sequences so a future rebrand
21808 // on either arm can't silently coalesce onto the peer arm (a
21809 // `FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE = "retries"` typo
21810 // would silently rebind the post-retry-exhaustion rollback
21811 // toggle onto the retry-cap ceiling axis at every emit site —
21812 // the helm-controller then reads the substrate's `true` seed as
21813 // an integer retry-cap `1` on the retry-cap axis instead of the
21814 // rollback-on-terminal-failure boolean, silently truncating the
21815 // per-CR upgrade-path retry budget and dropping the rollback
21816 // semantic entirely with no diagnostic naming the leaf-key-
21817 // coalesce root cause). The upgrade-path per-CR remediation
21818 // leaf-scalar-key pair must always resolve to distinct emitted
21819 // leaf-keys.
21820 assert_ne!(
21821 FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE, FLUX_HELMRELEASE_KEY_RETRIES,
21822 "the upgrade-path per-CR remediation retry-cap leaf-scalar-\
21823 key and remediation-toggle leaf-scalar-key must remain \
21824 byte-distinct — a coalesce onto one value silently rebinds \
21825 the post-retry-exhaustion rollback semantic onto the retry-\
21826 cap ceiling axis at every emit site"
21827 );
21828 }
21829
21830 #[test]
21831 fn flux_helmrelease_key_create_namespace_pins_canonical_value() {
21832 // Pin the actual string so a typo in this lift can't silently
21833 // rebrand the Flux v2 `HelmRelease.spec.install.createNamespace`
21834 // install-path-only per-CR namespace-seeder-toggle leaf-scalar-key
21835 // the substrate's per-caixa `cluster_bundle` renderer seeds to
21836 // `true` into every emitted per-caixa `helmrelease.yaml` document
21837 // under the sibling [`FLUX_HELMRELEASE_KEY_INSTALL`] per-CR
21838 // install-path phase-discriminator parent-container-axis-key. The
21839 // string is part of the cluster-side contract with the upstream
21840 // Flux v2 helm-controller — the controller's per-CR install-path
21841 // pre-apply loop reaches the target-namespace-seeder toggle
21842 // through this exact leaf; a drifted leaf-scalar-key silently
21843 // strips the substrate's chosen first-apply namespace-seeder
21844 // semantic from every emitted per-caixa `HelmRelease` document,
21845 // leaving the helm-controller to refuse every first-time per-caixa
21846 // chart apply against a fresh cluster whose target namespace has
21847 // not been pre-provisioned by an out-of-band pipeline the
21848 // substrate's "no per-caixa Servico apply is blocked on manual
21849 // namespace preprovisioning" MESH-COMPOSITION.md §V install-path-
21850 // fluency guarantee mandates, with no diagnostic naming the
21851 // seeder-toggle-drift root cause. Changing it is a coordinated
21852 // Flux v3 CRD-schema-rebrand migration alongside the upstream
21853 // `helm-controller` deprecation cycle (candidates like
21854 // `createTargetNamespace` / `seedNamespace` / `provisionNamespace`
21855 // that upstream Flux v3 roadmap floats in the migration prose),
21856 // not an incidental edit. Peer to
21857 // `flux_helmrelease_key_remediate_last_failure_pins_canonical_value`
21858 // on the sibling mirror-symmetric upgrade-path-only per-CR
21859 // remediation-toggle leaf-scalar-key half of the same install/
21860 // upgrade per-CR phase-specific toggle leaf-scalar-key pair.
21861 assert_eq!(FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE, "createNamespace");
21862 }
21863
21864 #[test]
21865 fn flux_helmrelease_key_create_namespace_stays_independent_of_remediate_last_failure() {
21866 // The per-CR install/upgrade phase blocks host two mirror-symmetric
21867 // phase-specific toggle leaf-scalar-key axes: the install-path-only
21868 // per-CR namespace-seeder-toggle
21869 // [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] under the sibling
21870 // [`FLUX_HELMRELEASE_KEY_INSTALL`] parent-container-axis-key (this
21871 // lift) and the upgrade-path-only per-CR remediation-toggle
21872 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] (96581b7) under the
21873 // sibling [`FLUX_HELMRELEASE_KEY_UPGRADE`] parent-container-axis-key.
21874 // Pin that the two consts carry byte-distinct sequences so a future
21875 // rebrand on either arm can't silently coalesce onto the peer arm
21876 // (a `FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE = "remediateLastFailure"`
21877 // typo would silently rebind the install-path namespace-seeder
21878 // toggle onto the upgrade-path per-CR remediation-toggle leaf at
21879 // every emit site — the helm-controller would then read the
21880 // substrate's `true` seed as a post-retry-exhaustion rollback opt-
21881 // in on the upgrade-path per-CR remediation axis instead of the
21882 // pre-apply namespace-seeder toggle, silently dropping the first-
21883 // apply namespace-seeder semantic entirely and misrouting the
21884 // install-path opt-in onto an upgrade-path axis where it never
21885 // fires with no diagnostic naming the leaf-key-coalesce root
21886 // cause). The install/upgrade per-CR phase-specific toggle leaf-
21887 // scalar-key pair must always resolve to distinct emitted leaf-
21888 // keys under mirror-symmetric parent-container-axis-keys.
21889 assert_ne!(
21890 FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE, FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE,
21891 "the install-path per-CR namespace-seeder-toggle leaf-scalar-\
21892 key and the upgrade-path per-CR remediation-toggle leaf-\
21893 scalar-key must remain byte-distinct — a coalesce onto one \
21894 value silently rebinds one phase's opt-in toggle onto the \
21895 peer phase's opt-in-toggle axis at every emit site, dropping \
21896 the phase-specific pre-apply / post-retry-exhaustion semantic \
21897 the substrate seeds on the coalesced arm"
21898 );
21899 }
21900
21901 #[test]
21902 fn flux_kustomization_key_prune_pins_canonical_value() {
21903 // Pin the actual string so a typo in this lift can't silently
21904 // rebrand the Flux v2 `Kustomization.spec.prune` per-CR garbage-
21905 // collection-toggle leaf-scalar-key the substrate's per-caixa
21906 // `cluster_bundle` renderer seeds to `true` into every emitted
21907 // per-caixa `kustomization.yaml` document at the top-level `spec`
21908 // position. The string is part of the cluster-side contract with
21909 // the upstream Flux v2 kustomize-controller — the controller's
21910 // per-CR reconcile loop reaches the sweep-what-you-removed toggle
21911 // through this exact leaf; a drifted leaf-scalar-key silently
21912 // strips the substrate's chosen sweep-what-you-removed semantic
21913 // from every emitted per-caixa `Kustomization` document, leaving
21914 // per-caixa resources the source manifest set previously
21915 // reconciled but no longer carries dangling in the cluster the
21916 // substrate's "the cluster's per-caixa live state converges to
21917 // the caixa's tatara-lisp source-of-truth on every reconcile —
21918 // resources the source no longer carries are swept by the
21919 // kustomize-controller, not left dangling" CAIXA-SDLC.md §V
21920 // author-to-live-convergence guarantee mandates, with no
21921 // diagnostic naming the toggle-drift root cause. Changing it is
21922 // a coordinated Flux v3 CRD-schema-rebrand migration alongside
21923 // the upstream `kustomize-controller` deprecation cycle
21924 // (candidates like `garbageCollect` / `sweep` / `pruneOrphaned`
21925 // / `deleteOrphans` that upstream Flux v3 roadmap floats in the
21926 // migration prose), not an incidental edit. Peer to
21927 // `flux_helmrelease_key_create_namespace_pins_canonical_value`
21928 // on the sibling co-resident per-caixa `HelmRelease` CR install-
21929 // path per-CR namespace-seeder-toggle leaf-scalar-key half of
21930 // the same per-caixa Flux-bundle per-CR-toggle leaf-scalar-key
21931 // surface.
21932 assert_eq!(FLUX_KUSTOMIZATION_KEY_PRUNE, "prune");
21933 }
21934
21935 #[test]
21936 fn flux_kustomization_key_prune_stays_independent_of_create_namespace() {
21937 // The per-caixa Flux bundle hosts two co-resident per-CR-toggle
21938 // leaf-scalar-key axes: the per-`Kustomization`-CR garbage-
21939 // collection-toggle [`FLUX_KUSTOMIZATION_KEY_PRUNE`] at the
21940 // top-level `spec` position (this lift) and the per-`HelmRelease`-
21941 // CR install-path namespace-seeder-toggle
21942 // [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] (ba9ab8b) under the
21943 // sibling [`FLUX_HELMRELEASE_KEY_INSTALL`] parent-container-axis-
21944 // key. Pin that the two consts carry byte-distinct sequences so
21945 // a future rebrand on either arm can't silently coalesce onto
21946 // the peer arm (a `FLUX_KUSTOMIZATION_KEY_PRUNE = "createNamespace"`
21947 // typo would silently rebind the Kustomization-CR garbage-
21948 // collection-toggle onto the HelmRelease-CR install-path
21949 // namespace-seeder-toggle leaf at every emit site — the
21950 // kustomize-controller would then read the substrate's `true`
21951 // seed at the drifted leaf-key rather than the canonical `prune`
21952 // axis, silently dropping the sweep-what-you-removed semantic
21953 // entirely and leaving per-caixa resources removed from the
21954 // source manifest set dangling in the cluster with no
21955 // diagnostic naming the leaf-key-coalesce root cause). The
21956 // per-`Kustomization`-CR garbage-collection-toggle and the
21957 // per-`HelmRelease`-CR install-path namespace-seeder-toggle must
21958 // always resolve to distinct emitted leaf-keys under their
21959 // respective co-resident per-CR spec surfaces.
21960 assert_ne!(
21961 FLUX_KUSTOMIZATION_KEY_PRUNE, FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE,
21962 "the per-`Kustomization`-CR garbage-collection-toggle leaf-\
21963 scalar-key and the per-`HelmRelease`-CR install-path \
21964 namespace-seeder-toggle leaf-scalar-key must remain byte-\
21965 distinct — a coalesce onto one value silently rebinds one \
21966 CR's opt-in toggle onto the peer CR's opt-in-toggle axis at \
21967 every emit site, dropping the per-CR-specific sweep-what-\
21968 you-removed / pre-apply-namespace-seeder semantic the \
21969 substrate seeds on the coalesced arm"
21970 );
21971 }
21972
21973 #[test]
21974 fn flux_kustomization_prune_default_pins_canonical_value() {
21975 // Pin the actual boolean so a rebrand on this lift can't silently
21976 // rebrand the Flux v2 `Kustomization.spec.prune` per-CR garbage-
21977 // collection-toggle scalar-value seed the substrate's per-caixa
21978 // `cluster_bundle` renderer threads into every emitted per-caixa
21979 // `kustomization.yaml` document under the sibling
21980 // [`FLUX_KUSTOMIZATION_KEY_PRUNE`] leaf-scalar-key axis. The
21981 // scalar is part of the cluster-side contract with the upstream
21982 // Flux v2 kustomize-controller — the controller's per-CR reconcile
21983 // loop reads the scalar under the sibling leaf-scalar-key axis
21984 // to decide whether to garbage-collect resources that were
21985 // previously reconciled by the CR but no longer appear in the
21986 // CR's current desired-state manifest set. Drift from the
21987 // canonical `true` seed to `false` silently drops the substrate's
21988 // chosen sweep-what-you-removed semantic from every emitted
21989 // per-caixa `Kustomization` document, leaving per-caixa resources
21990 // the source manifest set previously reconciled but no longer
21991 // carries dangling in the cluster the substrate's "the cluster's
21992 // per-caixa live state converges to the caixa's tatara-lisp
21993 // source-of-truth on every reconcile — resources the source no
21994 // longer carries are swept by the kustomize-controller, not left
21995 // dangling" CAIXA-SDLC.md §V author-to-live-convergence guarantee
21996 // mandates, with no diagnostic naming the toggle-drift root
21997 // cause. Changing it is a substrate-side policy migration
21998 // (candidates: `true` → `false` on a per-cluster class where a
21999 // human is expected to prune orphaned resources by hand once
22000 // per-cluster policy grows an operator-driven-cleanup mode; a
22001 // per-caixa opt-out slot the ABSORPTION-ROADMAP.md M4 typed-slot
22002 // trajectory adds once the substrate grows a `:kustomization
22003 // :prune` author-side toggle), not an incidental edit. Peer to
22004 // `flux_helmrelease_remediation_retries_default_pins_lifted_value`
22005 // on the sibling per-path per-CR HelmRelease remediation retry-
22006 // cap scalar-value default axis — that default names the per-
22007 // path per-CR remediation retry ceiling, and this default names
22008 // whether the per-CR reconcile loop sweeps orphaned resources at
22009 // all. Both are substrate-side policy choices the operator
22010 // inherits when the per-caixa `ClusterBundleOpts` doesn't pin an
22011 // override.
22012 assert!(FLUX_KUSTOMIZATION_PRUNE_DEFAULT);
22013 }
22014
22015 #[test]
22016 fn flux_kustomization_prune_default_pairs_with_lifted_leaf_key() {
22017 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-CR
22018 // garbage-collection-toggle declaration lives at two lifted
22019 // `pub const` declarations —
22020 // [`FLUX_KUSTOMIZATION_KEY_PRUNE`] (8ec7917) on the key half
22021 // and [`FLUX_KUSTOMIZATION_PRUNE_DEFAULT`] on the value half.
22022 // Both halves must move together on any coordinated Flux v3
22023 // migration (a `garbageCollect: false` rename that rebrands the
22024 // leaf axis onto a new controller-side opt-in vs. the current
22025 // opt-out default; a leaf coalesce onto a peer per-CR toggle
22026 // that reroutes the substrate's canonical scalar seed onto an
22027 // unrelated axis), so a rebrand on either half without a
22028 // coordinated edit on the other would silently split the
22029 // substrate's canonical sweep-what-you-removed declaration —
22030 // the emit-site format-string would still thread the `{prune_key}`
22031 // named-arg through the lifted leaf-scalar-key but pair it with
22032 // a canonical `{prune_default}` that no longer reflects the
22033 // substrate-side semantic the leaf axis names. Pin the pair here
22034 // so a future edit that touches only the leaf-scalar-key half
22035 // or only the scalar-value default half surfaces at build time
22036 // rather than at reconcile time far from the source edit.
22037 // Confirms both consts carry their canonical wire representations
22038 // (`"prune"` byte-string on the leaf-scalar-key half; `true` on
22039 // the scalar-value default half) — the pair as-a-unit reads as
22040 // the substrate's chosen `prune: true` per-CR opt-in.
22041 assert_eq!(FLUX_KUSTOMIZATION_KEY_PRUNE, "prune");
22042 assert!(FLUX_KUSTOMIZATION_PRUNE_DEFAULT);
22043 }
22044
22045 #[test]
22046 fn flux_helmrelease_remediate_last_failure_default_pins_canonical_value() {
22047 // Pin the actual boolean so a rebrand on this lift can't silently
22048 // rebrand the Flux v2 `HelmRelease.spec.upgrade.remediation
22049 // .remediateLastFailure` upgrade-path-only per-CR remediation-toggle
22050 // scalar-value seed the substrate's per-caixa `cluster_bundle`
22051 // renderer threads into every emitted per-caixa `helmrelease.yaml`
22052 // document under the sibling
22053 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] leaf-scalar-key
22054 // axis. The scalar is part of the cluster-side contract with the
22055 // upstream Flux v2 helm-controller — the controller's per-CR
22056 // upgrade-path remediation loop reads the scalar under the sibling
22057 // leaf-scalar-key axis to decide whether to trigger the prior-
22058 // release rollback pipeline once the paired
22059 // [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] retry-cap ceiling
22060 // has been exhausted. Drift from the canonical `true` seed to
22061 // `false` silently drops the substrate's chosen post-retry-
22062 // exhaustion rollback semantic from every emitted per-caixa
22063 // `HelmRelease` document, leaving every terminally-failed upgrade
22064 // parked at `Ready: False` without rolling back to the prior last-
22065 // known-good release the substrate's "no chart apply leaves a
22066 // per-caixa CR in a stalled, unremediated state" MESH-COMPOSITION
22067 // .md §V guarantee mandates, with no diagnostic naming the
22068 // remediation-toggle-drift root cause. Changing it is a substrate-
22069 // side policy migration (candidates: `true` → `false` on a per-
22070 // cluster class where terminally-failed upgrades must escalate to
22071 // operator-attention rather than mask under an auto-rollback pipe-
22072 // line; a per-caixa opt-out slot the ABSORPTION-ROADMAP.md M4
22073 // typed-slot trajectory adds once the substrate grows a `:upgrade
22074 // :remediate-last-failure` author-side toggle), not an incidental
22075 // edit. Peer to `flux_kustomization_prune_default_pins_canonical_value`
22076 // on the sibling per-`Kustomization`-CR garbage-collection-toggle
22077 // scalar-value default axis — that default names whether the
22078 // per-CR `Kustomization` reconcile loop sweeps orphaned resources
22079 // at all, and this default names whether the per-CR `HelmRelease`
22080 // upgrade-path remediation loop rolls back to the prior last-
22081 // known-good release once the retry-cap ceiling is exhausted.
22082 // Both are substrate-side policy choices the operator inherits
22083 // when the per-caixa `ClusterBundleOpts` doesn't pin an override.
22084 assert!(FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT);
22085 }
22086
22087 #[test]
22088 fn flux_helmrelease_remediate_last_failure_default_pairs_with_lifted_leaf_key() {
22089 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-CR
22090 // upgrade-path per-CR post-retry-exhaustion-rollback-toggle
22091 // declaration lives at two lifted `pub const` declarations —
22092 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] (96581b7) on the
22093 // key half and [`FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT`]
22094 // on the value half. Both halves must move together on any
22095 // coordinated Flux v3 migration (a `rollbackOnFailure: false`
22096 // rename that rebrands the leaf axis onto a new controller-side
22097 // opt-in vs. the current opt-in default; a leaf coalesce onto a
22098 // peer per-CR toggle that reroutes the substrate's canonical
22099 // scalar seed onto an unrelated axis), so a rebrand on either half
22100 // without a coordinated edit on the other would silently split the
22101 // substrate's canonical post-retry-exhaustion rollback declaration
22102 // — the emit-site format-string would still thread the
22103 // `{remediate_last_failure_key}` named-arg through the lifted
22104 // leaf-scalar-key but pair it with a canonical
22105 // `{remediate_last_failure_default}` that no longer reflects the
22106 // substrate-side semantic the leaf axis names. Pin the pair here
22107 // so a future edit that touches only the leaf-scalar-key half or
22108 // only the scalar-value default half surfaces at build time rather
22109 // than at reconcile time far from the source edit. Confirms both
22110 // consts carry their canonical wire representations
22111 // (`"remediateLastFailure"` byte-string on the leaf-scalar-key
22112 // half; `true` on the scalar-value default half) — the pair as-a-
22113 // unit reads as the substrate's chosen
22114 // `remediateLastFailure: true` per-CR opt-in.
22115 assert_eq!(
22116 FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE,
22117 "remediateLastFailure"
22118 );
22119 assert!(FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT);
22120 }
22121
22122 #[test]
22123 fn flux_helmrelease_create_namespace_default_pins_canonical_value() {
22124 // Pin the actual boolean so a rebrand on this lift can't silently
22125 // rebrand the Flux v2 `HelmRelease.spec.install.createNamespace`
22126 // install-path-only per-CR namespace-seeder-toggle scalar-value
22127 // seed the substrate's per-caixa `cluster_bundle` renderer threads
22128 // into every emitted per-caixa `helmrelease.yaml` document under
22129 // the sibling [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] leaf-
22130 // scalar-key axis. The scalar is part of the cluster-side contract
22131 // with the upstream Flux v2 helm-controller — the controller's
22132 // per-CR install-path pre-apply loop reads the scalar under the
22133 // sibling leaf-scalar-key axis to decide whether to first material-
22134 // ize the target namespace before the first-time chart apply.
22135 // Drift from the canonical `true` seed to `false` silently drops
22136 // the substrate's chosen first-apply namespace-seeder semantic
22137 // from every emitted per-caixa `HelmRelease` document, leaving
22138 // every first-time per-caixa chart apply against a fresh cluster
22139 // refused by the helm-controller because the target namespace was
22140 // not pre-provisioned by an out-of-band pipeline the substrate's
22141 // "no per-caixa Servico apply is blocked on manual namespace
22142 // preprovisioning" MESH-COMPOSITION.md §V install-path-fluency
22143 // guarantee mandates, with no diagnostic naming the seeder-toggle-
22144 // drift root cause. Changing it is a substrate-side policy
22145 // migration (candidates: `true` → `false` on hardened per-cluster
22146 // classes where namespace provisioning is an out-of-band operator
22147 // gate; a per-caixa opt-out slot the ABSORPTION-ROADMAP.md M4
22148 // typed-slot trajectory adds once the substrate grows a `:install
22149 // :create-namespace` author-side toggle), not an incidental edit.
22150 // Peer to `flux_helmrelease_remediate_last_failure_default_pins_canonical_value`
22151 // on the sibling mirror-symmetric upgrade-path-only per-CR
22152 // remediation-toggle scalar-value default axis — that default
22153 // names whether the per-CR `HelmRelease` upgrade-path remediation
22154 // loop rolls back to the prior last-known-good release once the
22155 // retry-cap ceiling is exhausted, and this default names whether
22156 // the per-CR `HelmRelease` install-path pre-apply loop materializes
22157 // the target namespace before the first-time chart apply. Both
22158 // are substrate-side policy choices the operator inherits when
22159 // the per-caixa `ClusterBundleOpts` doesn't pin an override, and
22160 // both close the mirror-symmetric install/upgrade per-CR phase-
22161 // specific toggle scalar-value default pair the peer leaf-scalar-
22162 // key pair [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] (ba9ab8b) /
22163 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] (96581b7)
22164 // already closed on the key half.
22165 assert!(FLUX_HELMRELEASE_CREATE_NAMESPACE_DEFAULT);
22166 }
22167
22168 #[test]
22169 fn flux_helmrelease_create_namespace_default_pairs_with_lifted_leaf_key() {
22170 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-CR
22171 // install-path per-CR namespace-seeder-toggle declaration lives
22172 // at two lifted `pub const` declarations —
22173 // [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] (ba9ab8b) on the key
22174 // half and [`FLUX_HELMRELEASE_CREATE_NAMESPACE_DEFAULT`] on the
22175 // value half. Both halves must move together on any coordinated
22176 // Flux v3 migration (a `createTargetNamespace: false` rename that
22177 // rebrands the leaf axis onto a new controller-side opt-in vs.
22178 // the current opt-in default; a leaf coalesce onto a peer per-CR
22179 // toggle that reroutes the substrate's canonical scalar seed onto
22180 // an unrelated axis), so a rebrand on either half without a
22181 // coordinated edit on the other would silently split the substrate's
22182 // canonical first-apply namespace-seeder declaration — the emit-
22183 // site format-string would still thread the
22184 // `{create_namespace_key}` named-arg through the lifted leaf-
22185 // scalar-key but pair it with a canonical `{create_namespace_default}`
22186 // that no longer reflects the substrate-side semantic the leaf
22187 // axis names. Pin the pair here so a future edit that touches
22188 // only the leaf-scalar-key half or only the scalar-value default
22189 // half surfaces at build time rather than at reconcile time far
22190 // from the source edit. Confirms both consts carry their canonical
22191 // wire representations (`"createNamespace"` byte-string on the
22192 // leaf-scalar-key half; `true` on the scalar-value default half) —
22193 // the pair as-a-unit reads as the substrate's chosen
22194 // `createNamespace: true` per-CR opt-in.
22195 assert_eq!(FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE, "createNamespace");
22196 assert!(FLUX_HELMRELEASE_CREATE_NAMESPACE_DEFAULT);
22197 }
22198
22199 #[test]
22200 fn cluster_bundle_lareira_enabled_default_pins_canonical_value() {
22201 // Pin the actual boolean so a rebrand on this lift can't silently
22202 // rebrand the substrate-side default for the
22203 // `HelmRelease.spec.values.<library>.enabled` child-chart-
22204 // enablement toggle scalar the substrate's per-caixa
22205 // `cluster_bundle` renderer threads into every emitted per-caixa
22206 // `helmrelease.yaml` document under the sibling
22207 // [`HELM_VALUES_KEY_ENABLED`] leaf-scalar-key axis inside the
22208 // per-`{library_name}` values-overlay wrap. The scalar is the
22209 // substrate's chosen "force-on the child chart under the
22210 // cluster_bundle composition path" default — semantically
22211 // distinct from and inverse of the standalone
22212 // [`caixa_helm::RenderOpts`]::`enabled_default = false` seed
22213 // (which renders `enabled: false` in the per-caixa `values.yaml`
22214 // so cluster operators must opt each caixa in per-cluster); the
22215 // `cluster_bundle` composition path is the substrate-side
22216 // opt-in path where the operator has already asserted per-caixa
22217 // cluster-scoped ownership by materializing a per-caixa
22218 // GitRepository + HelmRelease + Kustomization trio, so the
22219 // overlay forces the child chart on by seeding `enabled: true`
22220 // under the `values.<library>` wrap. Drift from the canonical
22221 // `true` seed to `false` silently drops the substrate's chosen
22222 // force-on-under-composition semantic from every emitted
22223 // per-caixa `HelmRelease` document, leaving the paired
22224 // [`DEFAULT_LIBRARY_NAME`] child chart's `enabled: false`
22225 // per-chart default un-overridden — the Helm rendering pipeline
22226 // then no-ops every per-caixa lareira child chart at the
22227 // per-cluster `HelmRelease` apply step, with no diagnostic
22228 // naming the toggle-drift root cause. Peer to the sibling
22229 // `flux_helmrelease_create_namespace_default_pins_canonical_value`
22230 // (be1904b) / `flux_helmrelease_remediate_last_failure_default_pins_canonical_value`
22231 // (be1904b) / `flux_kustomization_prune_default_pins_canonical_value`
22232 // (ea857d8) on the peer canonical-Flux-v2-per-CR-substrate-
22233 // default surface — all four defaults are substrate-side policy
22234 // choices the operator inherits when the per-caixa
22235 // `ClusterBundleOpts` doesn't pin an override.
22236 assert!(CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT);
22237 }
22238
22239 #[test]
22240 fn cluster_bundle_lareira_enabled_default_pairs_with_lifted_leaf_key() {
22241 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-
22242 // values-overlay child-chart-enablement-toggle declaration lives
22243 // at two lifted `pub const` declarations —
22244 // [`HELM_VALUES_KEY_ENABLED`] on the key half and
22245 // [`CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT`] on the value half.
22246 // Both halves must move together on any coordinated Helm 4
22247 // migration (an `on: true` rename that rebrands the leaf axis
22248 // onto a new controller-side opt-in vs. the current opt-in
22249 // default; a leaf coalesce onto a peer per-values-block toggle
22250 // that reroutes the substrate's canonical scalar seed onto an
22251 // unrelated axis), so a rebrand on either half without a
22252 // coordinated edit on the other would silently split the
22253 // substrate's canonical force-on-under-composition declaration —
22254 // the emit-site format-string would still thread the
22255 // `{enabled_key}` named-arg through the lifted leaf-scalar-key
22256 // but pair it with a canonical `{lareira_enabled_default}` that
22257 // no longer reflects the substrate-side semantic the leaf axis
22258 // names. Pin the pair here so a future edit that touches only
22259 // the leaf-scalar-key half or only the scalar-value default
22260 // half surfaces at build time rather than at apply time far
22261 // from the source edit. Confirms both consts carry their
22262 // canonical wire representations (`"enabled"` byte-string on
22263 // the leaf-scalar-key half; `true` on the scalar-value default
22264 // half) — the pair as-a-unit reads as the substrate's chosen
22265 // `enabled: true` per-values-overlay opt-in. Peer to
22266 // `flux_kustomization_prune_default_pairs_with_lifted_leaf_key`
22267 // (ea857d8) /
22268 // `flux_helmrelease_create_namespace_default_pairs_with_lifted_leaf_key`
22269 // (be1904b) /
22270 // `flux_helmrelease_remediate_last_failure_default_pairs_with_lifted_leaf_key`
22271 // (be1904b) on the sibling canonical-Flux-v2-per-CR-
22272 // substrate-default paired-halves surfaces.
22273 assert_eq!(HELM_VALUES_KEY_ENABLED, "enabled");
22274 assert!(CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT);
22275 }
22276
22277 #[test]
22278 fn standalone_lareira_enabled_default_pins_canonical_value() {
22279 // Pin the actual boolean so a rebrand on this lift can't silently
22280 // rebrand the substrate-side default for the
22281 // `values.<library>.enabled` child-chart-enablement toggle scalar
22282 // the substrate's per-caixa `caixa_helm::render_chart_for_servico`
22283 // renderer seeds into every emitted per-caixa `values.yaml`
22284 // document under the sibling [`HELM_VALUES_KEY_ENABLED`]
22285 // leaf-scalar-key axis inside the per-`{library_name}` wrap. The
22286 // scalar is the substrate's chosen "leave the child chart opted
22287 // out under the standalone per-chart path" default —
22288 // semantically distinct from and inverse of the composition
22289 // [`CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT`] seed (which renders
22290 // `enabled: true` in the per-cluster `HelmRelease` values-overlay
22291 // so the substrate force-ons the child chart at bundle
22292 // materialization time); the standalone per-chart path is the
22293 // substrate-side opt-out path where the operator has not yet
22294 // asserted per-caixa cluster-scoped ownership by materializing a
22295 // per-caixa GitRepository + HelmRelease + Kustomization trio, so
22296 // the per-chart `values.yaml` seeds `enabled: false` under the
22297 // `values.<library>` wrap and cluster operators must opt each
22298 // caixa in per-cluster. Drift from the canonical `false` seed to
22299 // `true` silently drops the substrate's chosen
22300 // opt-out-under-standalone semantic from every emitted per-caixa
22301 // `values.yaml` document, force-onning the paired
22302 // [`DEFAULT_LIBRARY_NAME`] child chart against the operator's
22303 // stated per-cluster opt-in convention — every rendered chart's
22304 // library-chart-side workload would come up on `helm template` /
22305 // `helm install` with no diagnostic naming the toggle-drift root
22306 // cause. Peer to `cluster_bundle_lareira_enabled_default_pins_canonical_value`
22307 // on the sibling composition-path `HelmRelease.spec.values.<library>.enabled`
22308 // scalar-value default surface — both defaults are substrate-side
22309 // policy choices the operator inherits when the per-caixa
22310 // `RenderOpts` / `ClusterBundleOpts` doesn't pin an override, and
22311 // together they close the mirror-symmetric standalone / composition
22312 // per-values-block child-chart-enablement-toggle scalar-value
22313 // default pair.
22314 assert!(!STANDALONE_LAREIRA_ENABLED_DEFAULT);
22315 }
22316
22317 #[test]
22318 fn standalone_lareira_enabled_default_pairs_with_lifted_leaf_key() {
22319 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-
22320 // values-block child-chart-enablement-toggle declaration on the
22321 // standalone per-chart path lives at two lifted `pub const`
22322 // declarations — [`HELM_VALUES_KEY_ENABLED`] on the key half and
22323 // [`STANDALONE_LAREIRA_ENABLED_DEFAULT`] on the value half. Both
22324 // halves must move together on any coordinated Helm 4 migration
22325 // (an `on: false` rename that rebrands the leaf axis onto a new
22326 // controller-side opt-in vs. the current opt-out default; a leaf
22327 // coalesce onto a peer per-values-block toggle that reroutes the
22328 // substrate's canonical scalar seed onto an unrelated axis), so a
22329 // rebrand on either half without a coordinated edit on the other
22330 // would silently split the substrate's canonical
22331 // opt-out-under-standalone declaration — the emit-site block
22332 // insertion would still thread [`HELM_VALUES_KEY_ENABLED`] as the
22333 // key but pair it with a canonical `enabled_default` scalar-value
22334 // seed that no longer reflects the substrate-side semantic the
22335 // leaf axis names. Pin the pair here so a future edit that
22336 // touches only the leaf-scalar-key half or only the scalar-value
22337 // default half surfaces at build time rather than at apply time
22338 // far from the source edit. Confirms both consts carry their
22339 // canonical wire representations (`"enabled"` byte-string on the
22340 // leaf-scalar-key half; `false` on the scalar-value default half)
22341 // — the pair as-a-unit reads as the substrate's chosen
22342 // `enabled: false` per-values-block opt-out. Peer to
22343 // `cluster_bundle_lareira_enabled_default_pairs_with_lifted_leaf_key`
22344 // on the sibling composition-path
22345 // `HelmRelease.spec.values.<library>.enabled` scalar-value default
22346 // paired-halves surface — both `(key, value)` pairs share the same
22347 // [`HELM_VALUES_KEY_ENABLED`] leaf-scalar-key half but diverge on
22348 // the scalar-value half, which is exactly the mirror-symmetric
22349 // standalone / composition path-selection the two scalar-value
22350 // defaults name.
22351 assert_eq!(HELM_VALUES_KEY_ENABLED, "enabled");
22352 assert!(!STANDALONE_LAREIRA_ENABLED_DEFAULT);
22353 }
22354
22355 #[test]
22356 fn standalone_and_cluster_bundle_lareira_enabled_defaults_are_inverse_by_construction() {
22357 // Cross-const coherence pin: the two peer
22358 // per-values-block child-chart-enablement-toggle scalar-value
22359 // defaults on the standalone per-chart path
22360 // ([`STANDALONE_LAREIRA_ENABLED_DEFAULT`]) and the composition
22361 // per-cluster-`HelmRelease` values-overlay path
22362 // ([`CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT`]) name mirror-symmetric
22363 // inverse defaults on the same underlying
22364 // `values.<library>.enabled` sub-block axis: the standalone-path
22365 // default is `false` (opt-out — cluster operators must opt each
22366 // caixa in per-cluster) while the composition-path default is
22367 // `true` (opt-in — the substrate force-ons the child chart once
22368 // the operator has asserted per-caixa cluster-scoped ownership by
22369 // materializing a per-caixa GitRepository + HelmRelease +
22370 // Kustomization trio). The inversion is the substrate's chosen
22371 // author-to-live path-selection semantic — every consumer that
22372 // reads either default inherits the per-path opt-out / opt-in
22373 // decision by construction, so a future edit that accidentally
22374 // aligned the two defaults (both `false` on a substrate-wide
22375 // opt-out migration, both `true` on a substrate-wide opt-in
22376 // migration) would silently collapse the substrate's chosen
22377 // standalone-vs-composition path-selection semantic — the
22378 // per-chart `values.yaml` default and the per-cluster
22379 // `HelmRelease.spec.values.<library>.enabled` overlay default
22380 // would agree on the same enablement seed, and either the
22381 // standalone path would force-on the child chart against the
22382 // operator's per-cluster opt-in convention (both `true`) or the
22383 // composition path would leave the child chart opted-out against
22384 // the operator's per-caixa cluster-scoped ownership assertion
22385 // (both `false`). Pin the structural inversion here so a future
22386 // edit that touches only one of the two defaults surfaces at
22387 // caixa-core build time rather than at chart-apply time far from
22388 // the constant-drift source. Confirms the two `bool`s carry
22389 // distinct canonical wire representations — the pair as-a-unit
22390 // reads as the substrate's chosen mirror-symmetric author-to-live
22391 // path-selection semantic (standalone opt-out, composition
22392 // opt-in). Peer to the sibling pairwise-distinctness pins the
22393 // `M3_PLACEMENT_ESTRATEGIA_*` /
22394 // `M2_UPGRADE_INSTRUCTION_KIND_*` closed-set typed-enum
22395 // discriminator axes carry on the peer canonical-typed-enum-
22396 // discriminator distinctness surface.
22397 assert_ne!(
22398 STANDALONE_LAREIRA_ENABLED_DEFAULT, CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT,
22399 "STANDALONE_LAREIRA_ENABLED_DEFAULT and CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT \
22400 must remain inverse `bool`s — the standalone per-chart path defaults to \
22401 opt-out (`false`) and the composition per-cluster-HelmRelease values-overlay \
22402 path defaults to opt-in (`true`); collapsing the inversion silently \
22403 breaks the substrate's chosen mirror-symmetric author-to-live \
22404 path-selection semantic at chart-apply time far from the constant-\
22405 drift source."
22406 );
22407 }
22408
22409 #[test]
22410 fn flux_kustomization_key_path_pins_canonical_value() {
22411 // Pin the actual string so a typo in this lift can't silently
22412 // rebrand the Flux v2 `Kustomization.spec.path` per-CR source-
22413 // sub-tree leaf-scalar-key the substrate's per-caixa
22414 // `cluster_bundle` renderer seeds into every emitted per-caixa
22415 // `kustomization.yaml` document at the top-level `spec`
22416 // position. The string is part of the cluster-side contract
22417 // with the upstream Flux v2 kustomize-controller — the
22418 // controller's per-CR reconcile loop reaches the source-sub-
22419 // tree pointer through this exact leaf; a drifted leaf-scalar-
22420 // key silently unbinds every per-caixa `Kustomization` from
22421 // its paired per-caixa sub-tree of the pleme-io k8s repository
22422 // (the controller defaults to `./` when the CR omits the leaf,
22423 // pulling every unrelated cluster's manifests through the
22424 // wrong per-caixa `Kustomization`), with no diagnostic naming
22425 // the leaf-drift root cause. Changing it is a coordinated Flux
22426 // v3 CRD-schema-rebrand migration alongside the upstream
22427 // `kustomize-controller` deprecation cycle (candidates like
22428 // `sourcePath` / `manifestsPath` / `sourceRoot` upstream Flux
22429 // v3 roadmap floats), not an incidental edit. Peer to
22430 // `flux_kustomization_key_prune_pins_canonical_value` on the
22431 // sibling co-resident per-`Kustomization`-CR `spec.prune`
22432 // garbage-collection-toggle leaf-scalar-key half of the same
22433 // per-`Kustomization`-CR-spec surface.
22434 assert_eq!(FLUX_KUSTOMIZATION_KEY_PATH, "path");
22435 }
22436
22437 #[test]
22438 fn flux_kustomization_key_path_stays_independent_of_prune() {
22439 // The per-`Kustomization`-CR top-level `spec` surface hosts two
22440 // co-resident leaf-scalar-key axes: the per-CR source-sub-tree
22441 // pointer [`FLUX_KUSTOMIZATION_KEY_PATH`] (this lift) and the
22442 // per-CR garbage-collection-toggle [`FLUX_KUSTOMIZATION_KEY_PRUNE`]
22443 // (8ec7917). Pin that the two consts carry byte-distinct
22444 // sequences so a future rebrand on either arm can't silently
22445 // coalesce onto the peer arm (a
22446 // `FLUX_KUSTOMIZATION_KEY_PATH = "prune"` typo would silently
22447 // rebind the substrate's per-cluster / per-caixa sub-tree path
22448 // seed onto the garbage-collection-toggle leaf at every emit
22449 // site — the kustomize-controller would then read the
22450 // substrate's `./clusters/<cluster>/services/<name>` seed as a
22451 // boolean opt-in toggle, silently unbinding the per-caixa
22452 // `Kustomization` from its source-sub-tree entirely with no
22453 // diagnostic naming the leaf-key-coalesce root cause). The
22454 // per-`Kustomization`-CR source-sub-tree pointer and the per-
22455 // `Kustomization`-CR garbage-collection-toggle must always
22456 // resolve to distinct emitted leaf-keys under the same
22457 // top-level `spec` position.
22458 assert_ne!(
22459 FLUX_KUSTOMIZATION_KEY_PATH, FLUX_KUSTOMIZATION_KEY_PRUNE,
22460 "the per-`Kustomization`-CR source-sub-tree leaf-scalar-key \
22461 and the per-`Kustomization`-CR garbage-collection-toggle \
22462 leaf-scalar-key must remain byte-distinct — a coalesce \
22463 onto one value silently rebinds one axis onto the peer \
22464 axis at every emit site, dropping the source-sub-tree / \
22465 sweep-what-you-removed semantic the substrate seeds on the \
22466 coalesced arm"
22467 );
22468 }
22469
22470 #[test]
22471 fn flux_kustomization_key_timeout_pins_canonical_value() {
22472 // Pin the actual string so a typo in this lift can't silently
22473 // rebrand the Flux v2 `Kustomization.spec.timeout` per-CR
22474 // reconcile wall-clock cap leaf-scalar-key the substrate's per-
22475 // caixa `cluster_bundle` renderer seeds into every emitted per-
22476 // caixa `kustomization.yaml` document at the top-level `spec`
22477 // position. The string is part of the cluster-side contract
22478 // with the upstream Flux v2 kustomize-controller — the
22479 // controller's per-CR reconcile loop reaches the wall-clock cap
22480 // through this exact leaf; a drifted leaf-scalar-key silently
22481 // strips the substrate's chosen reconcile-ceiling from every
22482 // emitted per-caixa `Kustomization` document, letting the
22483 // controller fall back to the upstream Flux v2 controller-side
22484 // default cap rather than the substrate's per-caixa
22485 // idempotency-checkpoint-tuned ceiling, with no diagnostic
22486 // naming the timeout-drift root cause. Changing it is a
22487 // coordinated Flux v3 CRD-schema-rebrand migration alongside
22488 // the upstream `kustomize-controller` deprecation cycle, not
22489 // an incidental edit. Peer to
22490 // `flux_kustomization_key_path_pins_canonical_value` and
22491 // `flux_kustomization_key_prune_pins_canonical_value` on the
22492 // sibling co-resident per-`Kustomization`-CR spec surface
22493 // leaf-scalar-key axes.
22494 assert_eq!(FLUX_KUSTOMIZATION_KEY_TIMEOUT, "timeout");
22495 }
22496
22497 #[test]
22498 fn flux_kustomization_key_timeout_stays_independent_of_path_and_prune() {
22499 // The per-`Kustomization`-CR top-level `spec` surface hosts
22500 // three co-resident leaf-scalar-key axes: the per-CR reconcile
22501 // wall-clock cap [`FLUX_KUSTOMIZATION_KEY_TIMEOUT`] (this
22502 // lift), the per-CR source-sub-tree pointer
22503 // [`FLUX_KUSTOMIZATION_KEY_PATH`] (613d7ed), and the per-CR
22504 // garbage-collection-toggle [`FLUX_KUSTOMIZATION_KEY_PRUNE`]
22505 // (8ec7917). Pin that the three consts carry byte-distinct
22506 // sequences so a future rebrand on any one arm can't silently
22507 // coalesce onto a peer arm (a
22508 // `FLUX_KUSTOMIZATION_KEY_TIMEOUT = "path"` typo would silently
22509 // rebind the reconcile wall-clock cap onto the source-sub-tree
22510 // pointer leaf at every emit site — the kustomize-controller
22511 // would then parse the substrate's `./clusters/<c>/services/<n>`
22512 // seed as a `metav1.Duration` scalar and reject the per-CR
22513 // admission gate, with no diagnostic naming the leaf-key-
22514 // coalesce root cause). The per-`Kustomization`-CR reconcile
22515 // wall-clock cap, per-CR source-sub-tree pointer, and per-CR
22516 // garbage-collection-toggle must always resolve to distinct
22517 // emitted leaf-keys under the same top-level `spec` position.
22518 assert_ne!(
22519 FLUX_KUSTOMIZATION_KEY_TIMEOUT, FLUX_KUSTOMIZATION_KEY_PATH,
22520 "the per-`Kustomization`-CR reconcile wall-clock cap leaf-\
22521 scalar-key and the per-`Kustomization`-CR source-sub-tree \
22522 leaf-scalar-key must remain byte-distinct — a coalesce onto \
22523 one value silently rebinds one axis onto the peer axis at \
22524 every emit site, dropping the reconcile-ceiling / source-\
22525 sub-tree semantic the substrate seeds on the coalesced arm"
22526 );
22527 assert_ne!(
22528 FLUX_KUSTOMIZATION_KEY_TIMEOUT, FLUX_KUSTOMIZATION_KEY_PRUNE,
22529 "the per-`Kustomization`-CR reconcile wall-clock cap leaf-\
22530 scalar-key and the per-`Kustomization`-CR garbage-\
22531 collection-toggle leaf-scalar-key must remain byte-distinct \
22532 — a coalesce onto one value silently rebinds one axis onto \
22533 the peer axis at every emit site, dropping the reconcile-\
22534 ceiling / sweep-what-you-removed semantic the substrate \
22535 seeds on the coalesced arm"
22536 );
22537 }
22538
22539 #[test]
22540 fn default_flux_kustomization_timeout_pins_canonical_value() {
22541 // Pin the actual scalar so a typo in this lift can't silently
22542 // rebrand the substrate-side default Flux v2
22543 // `Kustomization.spec.timeout` reconcile wall-clock cap the
22544 // substrate's per-caixa `cluster_bundle` renderer seeds into
22545 // every emitted per-caixa `kustomization.yaml` document at the
22546 // top-level `spec` position. The value is part of the cluster-
22547 // side contract with the Flux v2 kustomize-controller (the
22548 // per-CR reconcile loop uses this as the ceiling on the wall-
22549 // clock time a single reconcile attempt is allowed to consume
22550 // before the controller marks the `Kustomization`
22551 // `Ready: False` and stops retrying); changing it is a
22552 // coordinated substrate-side reconcile-ceiling promotion (a
22553 // `5m` → `3m` migration on faster per-caixa idempotency-
22554 // checkpoint cadence, a `5m` → `10m` migration on larger per-
22555 // caixa manifest sets), not an incidental edit. Peer to
22556 // `default_flux_reconcile_interval_pins_canonical_value` and
22557 // `flux_helmrelease_remediation_retries_default_pins_canonical_value`
22558 // on the canonical-Flux-v2-per-CR-substrate-default-scalar pin
22559 // surface.
22560 assert_eq!(DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT, "5m");
22561 }
22562
22563 #[test]
22564 fn default_flux_kustomization_timeout_is_a_valid_metav1_duration_scalar() {
22565 // Cross-axis grammar invariant: the Flux v2 kustomize-
22566 // controller-side per-CR admission gate parses the reconcile
22567 // wall-clock cap scalar via `metav1.ParseDuration` before
22568 // installing the per-CR watch. The Go-duration-format grammar
22569 // is non-empty, ASCII, and structured as
22570 // `<digits><unit>[<digits><unit>...]` where each unit is one of
22571 // `{ns, us, µs, ms, s, m, h}`. Pin a floor that catches the
22572 // canonical drift footguns — an empty scalar (`""` — admission
22573 // gate rejects), a non-ASCII-alphanumeric byte (`"5 m"` — the
22574 // whitespace defeats the parser), a missing-unit scalar (`"5"`
22575 // — the parser rejects for lack of a unit suffix), or a
22576 // leading-non-digit scalar (`"m5"` — the parser rejects for
22577 // lack of a leading magnitude). A future rebrand on the
22578 // canonical lift that lands a value outside the Go-duration-
22579 // format grammar would surface here at caixa-core build time
22580 // on the canonical lift, before any renderer consumes the
22581 // value. Same shape as
22582 // `default_flux_reconcile_interval_is_a_valid_metav1_duration_scalar`
22583 // on the peer canonical-substrate-default-grammar-floor surface.
22584 let v = DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT;
22585 assert!(
22586 !v.is_empty(),
22587 "DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT {v:?} must be non-empty \
22588 per the Flux v2 controller-side `metav1.ParseDuration` \
22589 admission gate"
22590 );
22591 assert!(
22592 v.chars().all(|c| c.is_ascii_alphanumeric()),
22593 "DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT {v:?} must be ASCII-\
22594 alphanumeric throughout per the Go-duration-format grammar \
22595 — no whitespace / separator bytes the `metav1.ParseDuration` \
22596 admission gate would reject"
22597 );
22598 let first = v.chars().next().expect("non-empty");
22599 assert!(
22600 first.is_ascii_digit(),
22601 "DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT {v:?} first byte {first:?} \
22602 must be an ASCII digit per the Go-duration-format grammar \
22603 — the leading magnitude precedes the unit suffix; a leading \
22604 non-digit defeats `metav1.ParseDuration`"
22605 );
22606 let last = v.chars().next_back().expect("non-empty");
22607 assert!(
22608 last.is_ascii_alphabetic() && last.is_ascii_lowercase(),
22609 "DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT {v:?} last byte {last:?} \
22610 must be an ASCII lowercase alphabetic unit suffix per the \
22611 Go-duration-format grammar — the trailing unit follows the \
22612 magnitude; an unterminated magnitude defeats \
22613 `metav1.ParseDuration`"
22614 );
22615 }
22616
22617 #[test]
22618 fn default_gateway_class_name_pins_canonical_value() {
22619 // Pin the actual string so a typo in this lift can't silently
22620 // rebrand the substrate's chosen K8s Gateway API controller the
22621 // rendered `Gateway`'s `spec.gatewayClassName` axis binds to.
22622 // The string is part of the cluster-side contract with the Cilium
22623 // Gateway API implementation (the Cilium operator watches
22624 // `GatewayClass` objects whose `spec.controllerName` names the
22625 // Cilium reconciler; a drifted `spec.gatewayClassName` on the
22626 // emitted `Gateway` refers to a `GatewayClass` no controller
22627 // reconciles, and the `Gateway` sits at `Programmed: False`
22628 // with every attached `HTTPRoute` unbound), the same eBPF-identity
22629 // data plane the sibling `CiliumNetworkPolicy` renderer emits
22630 // policies against (the mesh-composition "one identity layer,
22631 // one data plane" invariant, MESH-COMPOSITION.md §V), and the
22632 // per-cluster GatewayClass fixture the operator-side install
22633 // pipeline provisions. Changing it is a coordinated multi-repo
22634 // migration (a substrate-side Gateway controller migration to
22635 // Envoy Gateway / Istio Gateway or any per-edition variant),
22636 // not an incidental edit. Peer to
22637 // `default_namespace_pins_canonical_value` and
22638 // `default_flux_system_namespace_pins_canonical_value` on the
22639 // canonical-substrate-default-resource-name-value-pin axis.
22640 assert_eq!(DEFAULT_GATEWAY_CLASS_NAME, "cilium");
22641 }
22642
22643 #[test]
22644 fn default_gateway_class_name_is_a_valid_dns_1123_label() {
22645 // Cross-axis invariant: the Gateway API `GatewayClass` is a
22646 // cluster-scoped K8s resource, and the K8s apiserver enforces
22647 // the DNS-1123 label rule on every cluster-scoped resource's
22648 // `metadata.name`. The emitted `Gateway`'s
22649 // `spec.gatewayClassName` axis references the `GatewayClass`
22650 // resource by that name — a drift to a value the apiserver
22651 // would refuse as a `GatewayClass.metadata.name` couldn't
22652 // resolve at reconcile time either, and the `Gateway`
22653 // Programmed condition never flips true. Pinning this here
22654 // means a future rebrand on the canonical lift can't silently
22655 // land a value the apiserver refuses at the *first* `Gateway`
22656 // apply against a cluster, far from the rebrand commit's
22657 // source — the typed [`is_dns_1123_label`] floor rejects it at
22658 // caixa-core build time on the canonical lift, before any
22659 // renderer consumes the value. Same shape as
22660 // `default_namespace_is_a_valid_dns_1123_label` and
22661 // `default_flux_system_namespace_is_a_valid_dns_1123_label` on
22662 // the peer canonical-DNS-1123-label-floor axes.
22663 assert!(
22664 is_dns_1123_label(DEFAULT_GATEWAY_CLASS_NAME).is_ok(),
22665 "DEFAULT_GATEWAY_CLASS_NAME {DEFAULT_GATEWAY_CLASS_NAME:?} must be a \
22666 valid DNS-1123 label — every K8s apiserver-side schema enforces \
22667 this rule on cluster-scoped `metadata.name` axes, and the \
22668 `Gateway.spec.gatewayClassName` axis resolves by that same rule"
22669 );
22670 }
22671
22672 #[test]
22673 fn flux_helmrelease_api_version_pins_canonical_value() {
22674 // Pin the actual string so a typo in this lift can't silently
22675 // rebrand the Flux v2 `HelmRelease` CRD group/version the rendered
22676 // `helmrelease.yaml` document declares + the rendered
22677 // `kustomization.yaml` document's `healthChecks[].apiVersion`
22678 // axis transitively references. The string is part of the
22679 // cluster-side contract with the Flux v2 `helm-controller` (the
22680 // controller watches the exact `helm.toolkit.fluxcd.io/v2`
22681 // group/version; a drifted value to a stale v2beta1 / v2beta2
22682 // lands the rendered `HelmRelease` outside the controller's
22683 // `Watches` and fails at apply time with "no kind 'HelmRelease'
22684 // is registered for version 'helm.toolkit.fluxcd.io/v2beta2'");
22685 // changing it is a coordinated Flux v3 migration alongside the
22686 // upstream `helm-controller` deprecation cycle, not an
22687 // incidental edit. Peer to `default_flux_system_namespace_pins_canonical_value`
22688 // on the canonical-Flux-CRD-axis-pin axis for the sibling
22689 // [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] constant.
22690 assert_eq!(FLUX_HELMRELEASE_API_VERSION, "helm.toolkit.fluxcd.io/v2");
22691 }
22692
22693 #[test]
22694 fn flux_helmrelease_api_version_carries_group_and_version_segments() {
22695 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
22696 // `<group>/<version>` pair separated by exactly one `/` byte.
22697 // The group segment is a DNS-style multi-segment hostname
22698 // (`helm.toolkit.fluxcd.io`) and the version segment is a
22699 // Kubernetes API version label (`v2`, `v2beta1`, `v1alpha1` —
22700 // peer with the K8s API versioning convention upstream
22701 // documents). Pinning this here means a future rebrand on the
22702 // canonical lift can't silently land a malformed apiVersion
22703 // (no `/`, two `/`, empty group, empty version) that every
22704 // downstream YAML-aware deserializer would reject far from the
22705 // rebrand commit's source. The single-`/` invariant is the
22706 // load-bearing K8s API typed-discovery contract: a value the
22707 // apiserver's `RESTMapper` consults to resolve the CRD's
22708 // `RESTKind`.
22709 let v = FLUX_HELMRELEASE_API_VERSION;
22710 let parts: Vec<&str> = v.split('/').collect();
22711 assert_eq!(
22712 parts.len(),
22713 2,
22714 "FLUX_HELMRELEASE_API_VERSION {v:?} must split into exactly two \
22715 `/`-delimited segments (group/version) per the K8s CRD apiVersion \
22716 grammar — every downstream YAML-aware deserializer enforces this \
22717 shape"
22718 );
22719 assert!(
22720 !parts[0].is_empty(),
22721 "FLUX_HELMRELEASE_API_VERSION {v:?} group segment must be non-empty"
22722 );
22723 assert!(
22724 !parts[1].is_empty(),
22725 "FLUX_HELMRELEASE_API_VERSION {v:?} version segment must be non-empty"
22726 );
22727 assert!(
22728 parts[0].contains('.'),
22729 "FLUX_HELMRELEASE_API_VERSION {v:?} group segment {group:?} must be a \
22730 DNS-style multi-segment hostname (the canonical CRD-group convention \
22731 every K8s controller-runtime / kube-rs-aware client expects)",
22732 group = parts[0]
22733 );
22734 }
22735
22736 #[test]
22737 fn default_flux_helmrelease_api_version_matches_caixa_flux_test_fixtures() {
22738 // Cross-file drift pin: the four caixa-flux occurrences of
22739 // `helm.toolkit.fluxcd.io/v2` all consult the same canonical
22740 // constant, but the two `upsert_into_helmrelease_programs` test
22741 // fixtures (caixa-flux/src/lib.rs:928, 970) carry the value as
22742 // a static raw-string literal inside a `serde_yaml::from_str`
22743 // input (the YAML parser is the unit-under-test there, not the
22744 // rendering — the literals are intentionally not threaded
22745 // through the lift). This pin trips at caixa-core build time
22746 // if the canonical constant ever drifts past the literal the
22747 // caixa-flux test fixtures carry, so a future Flux v3 migration
22748 // surfaces here on the canonical-string axis rather than at the
22749 // first failing test fixture far from the rebrand commit. Peer
22750 // to the [`default_flux_system_namespace_pins_canonical_value`]
22751 // pin on the sibling Flux-namespace axis: both pin the canonical
22752 // string at the lift site so a future rebrand lands the
22753 // constant + every downstream reference + every test fixture in
22754 // one coordinated edit.
22755 assert_eq!(
22756 FLUX_HELMRELEASE_API_VERSION, "helm.toolkit.fluxcd.io/v2",
22757 "drift between FLUX_HELMRELEASE_API_VERSION and the \
22758 caixa-flux/src/lib.rs:928,970 test fixtures' literal values; \
22759 coordinate the migration across the const + every fixture in \
22760 one edit"
22761 );
22762 }
22763
22764 #[test]
22765 fn flux_gitrepository_api_version_pins_canonical_value() {
22766 // Pin the actual string so a typo in this lift can't silently
22767 // rebrand the Flux v2 `GitRepository` CRD group/version the rendered
22768 // `gitrepository.yaml` document declares. The string is part of the
22769 // cluster-side contract with the Flux v2 `source-controller` (the
22770 // controller watches the exact `source.toolkit.fluxcd.io/v1`
22771 // group/version; a drifted value to a stale v1beta1 / v1beta2 lands
22772 // the rendered `GitRepository` outside the controller's `Watches`
22773 // and fails at apply time with "no kind 'GitRepository' is
22774 // registered for version 'source.toolkit.fluxcd.io/v1beta2'");
22775 // changing it is a coordinated Flux v3 migration alongside the
22776 // upstream `source-controller` deprecation cycle, not an
22777 // incidental edit. Peer to
22778 // `flux_helmrelease_api_version_pins_canonical_value` on the
22779 // canonical-Flux-CRD-axis-pin axis for the sibling
22780 // [`FLUX_HELMRELEASE_API_VERSION`] constant.
22781 assert_eq!(
22782 FLUX_GITREPOSITORY_API_VERSION,
22783 "source.toolkit.fluxcd.io/v1"
22784 );
22785 }
22786
22787 #[test]
22788 fn flux_gitrepository_api_version_carries_group_and_version_segments() {
22789 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
22790 // `<group>/<version>` pair separated by exactly one `/` byte.
22791 // The group segment is a DNS-style multi-segment hostname
22792 // (`source.toolkit.fluxcd.io`) and the version segment is a
22793 // Kubernetes API version label (`v1`, `v1beta1`, `v1alpha1` — peer
22794 // with the K8s API versioning convention upstream documents).
22795 // Pinning this here means a future rebrand on the canonical lift
22796 // can't silently land a malformed apiVersion (no `/`, two `/`,
22797 // empty group, empty version) that every downstream YAML-aware
22798 // deserializer would reject far from the rebrand commit's source.
22799 // The single-`/` invariant is the load-bearing K8s API typed-
22800 // discovery contract: a value the apiserver's `RESTMapper`
22801 // consults to resolve the CRD's `RESTKind`. Peer to
22802 // `flux_helmrelease_api_version_carries_group_and_version_segments`
22803 // on the sibling Flux-CRD-axis.
22804 let v = FLUX_GITREPOSITORY_API_VERSION;
22805 let parts: Vec<&str> = v.split('/').collect();
22806 assert_eq!(
22807 parts.len(),
22808 2,
22809 "FLUX_GITREPOSITORY_API_VERSION {v:?} must split into exactly two \
22810 `/`-delimited segments (group/version) per the K8s CRD apiVersion \
22811 grammar — every downstream YAML-aware deserializer enforces this \
22812 shape"
22813 );
22814 assert!(
22815 !parts[0].is_empty(),
22816 "FLUX_GITREPOSITORY_API_VERSION {v:?} group segment must be non-empty"
22817 );
22818 assert!(
22819 !parts[1].is_empty(),
22820 "FLUX_GITREPOSITORY_API_VERSION {v:?} version segment must be non-empty"
22821 );
22822 assert!(
22823 parts[0].contains('.'),
22824 "FLUX_GITREPOSITORY_API_VERSION {v:?} group segment {group:?} must be a \
22825 DNS-style multi-segment hostname (the canonical CRD-group convention \
22826 every K8s controller-runtime / kube-rs-aware client expects)",
22827 group = parts[0]
22828 );
22829 }
22830
22831 #[test]
22832 fn flux_gitrepository_and_helmrelease_api_versions_share_toolkit_fluxcd_io_root() {
22833 // Cross-axis invariant: every Flux v2 CRD group ends in the canonical
22834 // `.toolkit.fluxcd.io` root the upstream `fluxcd/flux2` project pins
22835 // for the source-/helm-/kustomize-/notification-controller triplet.
22836 // A future Flux v3 promotion that breaks the root suffix (forking
22837 // `source-controller` out of the toolkit group, for example) would
22838 // surface here as a coordinated cross-axis edit-point — both lifted
22839 // constants must move together to preserve the controller-triple
22840 // contract.
22841 const ROOT: &str = ".toolkit.fluxcd.io";
22842 let gr_group = FLUX_GITREPOSITORY_API_VERSION
22843 .split('/')
22844 .next()
22845 .expect("FLUX_GITREPOSITORY_API_VERSION has a group segment");
22846 let hr_group = FLUX_HELMRELEASE_API_VERSION
22847 .split('/')
22848 .next()
22849 .expect("FLUX_HELMRELEASE_API_VERSION has a group segment");
22850 assert!(
22851 gr_group.ends_with(ROOT),
22852 "FLUX_GITREPOSITORY_API_VERSION group {gr_group:?} must end with the \
22853 canonical Flux v2 `{ROOT}` root every controller in the triplet shares"
22854 );
22855 assert!(
22856 hr_group.ends_with(ROOT),
22857 "FLUX_HELMRELEASE_API_VERSION group {hr_group:?} must end with the \
22858 canonical Flux v2 `{ROOT}` root every controller in the triplet shares"
22859 );
22860 }
22861
22862 #[test]
22863 fn flux_kustomization_api_version_pins_canonical_value() {
22864 // Pin the actual string so a typo in this lift can't silently
22865 // rebrand the Flux v2 `Kustomization` CRD group/version the
22866 // rendered `kustomization.yaml` document declares. The string
22867 // is part of the cluster-side contract with the Flux v2
22868 // `kustomize-controller` (the controller watches the exact
22869 // `kustomize.toolkit.fluxcd.io/v1` group/version; a drifted
22870 // value to a stale v1beta1 / v1beta2 lands the rendered
22871 // `Kustomization` outside the controller's `Watches` and
22872 // fails at apply time with "no kind 'Kustomization' is
22873 // registered for version
22874 // 'kustomize.toolkit.fluxcd.io/v1beta2'"); changing it is a
22875 // coordinated Flux v3 migration alongside the upstream
22876 // `kustomize-controller` deprecation cycle, not an
22877 // incidental edit. Peer to
22878 // `flux_helmrelease_api_version_pins_canonical_value` /
22879 // `flux_gitrepository_api_version_pins_canonical_value` on
22880 // the canonical-Flux-CRD-axis-pin axis for the sibling
22881 // [`FLUX_HELMRELEASE_API_VERSION`] /
22882 // [`FLUX_GITREPOSITORY_API_VERSION`] constants — completes
22883 // the Flux v2 controller-triplet's per-CRD-axis pin set.
22884 assert_eq!(
22885 FLUX_KUSTOMIZATION_API_VERSION,
22886 "kustomize.toolkit.fluxcd.io/v1"
22887 );
22888 }
22889
22890 #[test]
22891 fn flux_kustomization_api_version_carries_group_and_version_segments() {
22892 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
22893 // `<group>/<version>` pair separated by exactly one `/` byte.
22894 // The group segment is a DNS-style multi-segment hostname
22895 // (`kustomize.toolkit.fluxcd.io`) and the version segment is a
22896 // Kubernetes API version label (`v1`, `v1beta1`, `v1alpha1` —
22897 // peer with the K8s API versioning convention upstream
22898 // documents). Pinning this here means a future rebrand on the
22899 // canonical lift can't silently land a malformed apiVersion
22900 // (no `/`, two `/`, empty group, empty version) that every
22901 // downstream YAML-aware deserializer would reject far from the
22902 // rebrand commit's source. The single-`/` invariant is the
22903 // load-bearing K8s API typed-discovery contract: a value the
22904 // apiserver's `RESTMapper` consults to resolve the CRD's
22905 // `RESTKind`. Peer to
22906 // `flux_helmrelease_api_version_carries_group_and_version_segments`
22907 // / `flux_gitrepository_api_version_carries_group_and_version_segments`
22908 // on the sibling Flux-CRD-axis.
22909 let v = FLUX_KUSTOMIZATION_API_VERSION;
22910 let parts: Vec<&str> = v.split('/').collect();
22911 assert_eq!(
22912 parts.len(),
22913 2,
22914 "FLUX_KUSTOMIZATION_API_VERSION {v:?} must split into exactly two \
22915 `/`-delimited segments (group/version) per the K8s CRD apiVersion \
22916 grammar — every downstream YAML-aware deserializer enforces this \
22917 shape"
22918 );
22919 assert!(
22920 !parts[0].is_empty(),
22921 "FLUX_KUSTOMIZATION_API_VERSION {v:?} group segment must be non-empty"
22922 );
22923 assert!(
22924 !parts[1].is_empty(),
22925 "FLUX_KUSTOMIZATION_API_VERSION {v:?} version segment must be non-empty"
22926 );
22927 assert!(
22928 parts[0].contains('.'),
22929 "FLUX_KUSTOMIZATION_API_VERSION {v:?} group segment {group:?} must be a \
22930 DNS-style multi-segment hostname (the canonical CRD-group convention \
22931 every K8s controller-runtime / kube-rs-aware client expects)",
22932 group = parts[0]
22933 );
22934 }
22935
22936 #[test]
22937 fn flux_controller_triplet_api_versions_share_toolkit_fluxcd_io_root() {
22938 // Cross-axis triplet invariant: the Flux v2 controller triplet
22939 // (source-controller + helm-controller + kustomize-controller)
22940 // upstream all share the canonical `.toolkit.fluxcd.io` root.
22941 // The two-axis sibling pin
22942 // [`flux_gitrepository_and_helmrelease_api_versions_share_toolkit_fluxcd_io_root`]
22943 // enforces the invariant on the source-/helm- pair; this
22944 // pin extends it onto the kustomize-controller axis so a
22945 // future Flux v3 promotion that forks any single controller
22946 // out of the toolkit group surfaces as a coordinated
22947 // cross-axis edit-point across all three constants — the
22948 // controller triplet's CRD group/versions move together
22949 // upstream, and the lift discipline preserves that
22950 // movement at the typed substrate-side `&'static str`
22951 // surface.
22952 const ROOT: &str = ".toolkit.fluxcd.io";
22953 for (name, v) in [
22954 (
22955 "FLUX_GITREPOSITORY_API_VERSION",
22956 FLUX_GITREPOSITORY_API_VERSION,
22957 ),
22958 ("FLUX_HELMRELEASE_API_VERSION", FLUX_HELMRELEASE_API_VERSION),
22959 (
22960 "FLUX_KUSTOMIZATION_API_VERSION",
22961 FLUX_KUSTOMIZATION_API_VERSION,
22962 ),
22963 ] {
22964 let group = v
22965 .split('/')
22966 .next()
22967 .expect("Flux v2 CRD apiVersion has a group segment");
22968 assert!(
22969 group.ends_with(ROOT),
22970 "{name} group {group:?} must end with the canonical Flux v2 \
22971 `{ROOT}` root every controller in the source/helm/kustomize \
22972 triplet shares"
22973 );
22974 }
22975 }
22976
22977 #[test]
22978 fn flux_kind_git_repository_pins_canonical_value() {
22979 // Pin the actual string so a typo in this lift can't silently
22980 // rebrand the Flux v2 `GitRepository` CRD `kind` discriminator
22981 // the rendered Flux bundle's three `GitRepository`-naming axes
22982 // declare (gitrepository.yaml top-level kind, helmrelease.yaml
22983 // spec.chart.spec.sourceRef.kind, kustomization.yaml
22984 // spec.sourceRef.kind). The string is part of the cluster-side
22985 // contract with the Flux v2 `source-controller` — the
22986 // apiserver-side CRD resolution contract is the
22987 // `(apiVersion, kind)` tuple keyed against the registered
22988 // `CustomResourceDefinition`, so the kind half of the tuple is
22989 // exactly as load-bearing as the sibling
22990 // [`FLUX_GITREPOSITORY_API_VERSION`] apiVersion half. A drifted
22991 // value (e.g. an upstream Flux v3 rename to `GitSource`) lands
22992 // the rendered documents outside the source-controller's CRD
22993 // registration; changing it is a coordinated Flux v3 migration
22994 // alongside the upstream `source-controller` deprecation cycle,
22995 // not an incidental edit. Peer to
22996 // `flux_gitrepository_api_version_pins_canonical_value` on the
22997 // sibling apiVersion half of the same CRD-lookup tuple.
22998 assert_eq!(FLUX_KIND_GIT_REPOSITORY, "GitRepository");
22999 }
23000
23001 #[test]
23002 fn flux_kind_git_repository_carries_upper_camel_case_shape() {
23003 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
23004 // an UpperCamelCase identifier per the K8s API conventions
23005 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
23006 // "Kinds are always UpperCamelCase"). Pinning the shape here
23007 // means a future rebrand on the canonical lift can't silently
23008 // land a malformed kind discriminator (snake_case, kebab-case,
23009 // lowercase, empty) that every downstream YAML-aware
23010 // deserializer would reject far from the rebrand commit's
23011 // source. The first-byte uppercase / rest-ASCII-alphanumeric
23012 // invariant is the load-bearing K8s API typed-discovery
23013 // contract: a value the apiserver's `RESTMapper` consults to
23014 // resolve the CRD's `RESTKind`. Peer to
23015 // `flux_gitrepository_api_version_carries_group_and_version_segments`
23016 // on the sibling apiVersion half of the same CRD-lookup tuple.
23017 let v = FLUX_KIND_GIT_REPOSITORY;
23018 assert!(
23019 !v.is_empty(),
23020 "FLUX_KIND_GIT_REPOSITORY {v:?} must be non-empty per the K8s API \
23021 UpperCamelCase kind discriminator grammar"
23022 );
23023 let first = v.chars().next().expect("non-empty");
23024 assert!(
23025 first.is_ascii_uppercase(),
23026 "FLUX_KIND_GIT_REPOSITORY {v:?} first byte {first:?} must be \
23027 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
23028 grammar (Kinds are always UpperCamelCase)"
23029 );
23030 assert!(
23031 v.chars().all(|c| c.is_ascii_alphanumeric()),
23032 "FLUX_KIND_GIT_REPOSITORY {v:?} must be ASCII-alphanumeric \
23033 throughout per the K8s API kind discriminator grammar — no \
23034 snake_case, kebab-case, or whitespace bytes the apiserver-side \
23035 RESTMapper would reject"
23036 );
23037 }
23038
23039 #[test]
23040 fn flux_kind_helm_release_pins_canonical_value() {
23041 // Pin the actual string so a typo in this lift can't silently
23042 // rebrand the Flux v2 `HelmRelease` CRD `kind` discriminator
23043 // the rendered Flux bundle's two `HelmRelease`-naming axes
23044 // declare (helmrelease.yaml top-level kind, kustomization.yaml
23045 // spec.healthChecks[].kind). The string is part of the
23046 // cluster-side contract with the Flux v2 `helm-controller` —
23047 // the apiserver-side CRD resolution contract is the
23048 // `(apiVersion, kind)` tuple keyed against the registered
23049 // `CustomResourceDefinition`, so the kind half of the tuple is
23050 // exactly as load-bearing as the sibling
23051 // [`FLUX_HELMRELEASE_API_VERSION`] apiVersion half. A drifted
23052 // value (e.g. an upstream Flux v3 rename to `ChartRelease`)
23053 // lands the rendered documents outside the helm-controller's
23054 // CRD registration; changing it is a coordinated Flux v3
23055 // migration alongside the upstream `helm-controller`
23056 // deprecation cycle, not an incidental edit. Peer to
23057 // `flux_kind_git_repository_pins_canonical_value` on the
23058 // sibling Flux v2 source-controller CRD-`kind` axis.
23059 assert_eq!(FLUX_KIND_HELM_RELEASE, "HelmRelease");
23060 }
23061
23062 #[test]
23063 fn flux_kind_helm_release_carries_upper_camel_case_shape() {
23064 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
23065 // an UpperCamelCase identifier per the K8s API conventions
23066 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
23067 // "Kinds are always UpperCamelCase"). Pinning the shape here
23068 // means a future rebrand on the canonical lift can't silently
23069 // land a malformed kind discriminator (snake_case, kebab-case,
23070 // lowercase, empty) that every downstream YAML-aware
23071 // deserializer would reject far from the rebrand commit's
23072 // source. The first-byte uppercase / rest-ASCII-alphanumeric
23073 // invariant is the load-bearing K8s API typed-discovery
23074 // contract: a value the apiserver's `RESTMapper` consults to
23075 // resolve the CRD's `RESTKind`. Peer to
23076 // `flux_kind_git_repository_carries_upper_camel_case_shape`
23077 // on the sibling Flux v2 source-controller CRD-`kind` axis.
23078 let v = FLUX_KIND_HELM_RELEASE;
23079 assert!(
23080 !v.is_empty(),
23081 "FLUX_KIND_HELM_RELEASE {v:?} must be non-empty per the K8s API \
23082 UpperCamelCase kind discriminator grammar"
23083 );
23084 let first = v.chars().next().expect("non-empty");
23085 assert!(
23086 first.is_ascii_uppercase(),
23087 "FLUX_KIND_HELM_RELEASE {v:?} first byte {first:?} must be \
23088 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
23089 grammar (Kinds are always UpperCamelCase)"
23090 );
23091 assert!(
23092 v.chars().all(|c| c.is_ascii_alphanumeric()),
23093 "FLUX_KIND_HELM_RELEASE {v:?} must be ASCII-alphanumeric \
23094 throughout per the K8s API kind discriminator grammar — no \
23095 snake_case, kebab-case, or whitespace bytes the apiserver-side \
23096 RESTMapper would reject"
23097 );
23098 }
23099
23100 #[test]
23101 fn flux_kind_kustomization_pins_canonical_value() {
23102 // Pin the actual string so a typo in this lift can't silently
23103 // rebrand the Flux v2 `Kustomization` CRD `kind` discriminator
23104 // the rendered `kustomization.yaml`'s top-level `kind` axis
23105 // declares. The string is part of the cluster-side contract
23106 // with the Flux v2 `kustomize-controller` — the apiserver-side
23107 // CRD resolution contract is the `(apiVersion, kind)` tuple
23108 // keyed against the registered `CustomResourceDefinition`, so
23109 // the kind half of the tuple is exactly as load-bearing as the
23110 // sibling [`FLUX_KUSTOMIZATION_API_VERSION`] apiVersion half. A
23111 // drifted value (e.g. an upstream Flux v3 rename to
23112 // `KustomizationSet`) lands the rendered document outside the
23113 // kustomize-controller's CRD registration; changing it is a
23114 // coordinated Flux v3 migration alongside the upstream
23115 // `kustomize-controller` deprecation cycle, not an incidental
23116 // edit. Peer to
23117 // `flux_kind_git_repository_pins_canonical_value` /
23118 // `flux_kind_helm_release_pins_canonical_value` on the sibling
23119 // Flux v2 controller-triplet `kind`-axis surface — completes
23120 // the canonical-Flux-v2-CRD-kind-discriminator pin set across
23121 // the source-controller + helm-controller + kustomize-controller
23122 // triplet.
23123 assert_eq!(FLUX_KIND_KUSTOMIZATION, "Kustomization");
23124 }
23125
23126 #[test]
23127 fn flux_key_source_ref_pins_canonical_value() {
23128 // Pin the actual string so a typo in this lift can't silently
23129 // rebrand the Flux v2 per-`HelmRelease`/`Kustomization`
23130 // source-reference container-axis key the rendered
23131 // `helmrelease.yaml` (`spec.chart.spec.sourceRef`) +
23132 // `kustomization.yaml` (`spec.sourceRef`) documents mount the
23133 // per-CR `(kind, name, namespace)` reference triple under. The
23134 // string is part of the cluster-side contract with every
23135 // Flux-v2-conformant source-controller — the per-CR reconcile
23136 // loop keys off this exact container axis to source the
23137 // `(kind, name, namespace)` reference triple; a drifted value
23138 // (`"source_ref"` / `"source"` / `"sourceReference"` /
23139 // `"gitSourceRef"`) silently dangles both the HelmRelease's
23140 // chart resolution + the parent Kustomization's source
23141 // resolution at the Flux v2 source-controller's CRD
23142 // registration. Changing this value is a coordinated Flux v3
23143 // migration alongside the upstream `fluxcd/flux2` deprecation
23144 // cycle, not an incidental edit. Peer to
23145 // `flux_kind_git_repository_pins_canonical_value` /
23146 // `flux_kind_helm_release_pins_canonical_value` /
23147 // `flux_kind_kustomization_pins_canonical_value` on the sibling
23148 // per-CRD `kind`-axis surface — extends the canonical-Flux-v2-
23149 // load-bearing-string pin discipline from the per-CRD kind
23150 // discriminators onto the sibling per-CR source-reference
23151 // container-axis key both `cluster_bundle` renderers consume.
23152 assert_eq!(FLUX_KEY_SOURCE_REF, "sourceRef");
23153 }
23154
23155 #[test]
23156 fn flux_key_source_ref_carries_lower_camel_case_shape() {
23157 // Cross-axis invariant: the Flux v2 CRD field-naming convention
23158 // (inherited from the upstream K8s API conventions) admits
23159 // lowerCamelCase per-field keys — the source-reference
23160 // container-axis conforms to this on the leading-lowercase
23161 // `sourceRef` shape. Pinning the shape here means a future
23162 // rebrand on the canonical lift can't silently land a malformed
23163 // container-axis key (snake_case, kebab-case, UpperCamelCase,
23164 // empty) that the Flux v2 source-controller's per-CR reconcile
23165 // loop would reject at apply parse time far from the rebrand
23166 // commit's source. Peer to the sibling K8s-CR-lowerCamelCase-
23167 // per-field pin trajectory the sibling `KUBE_KEY_MATCH_LABELS`
23168 // / `GATEWAY_API_KEY_BACKEND_REFS` / `CILIUM_KEY_FROM_ENDPOINTS`
23169 // / `CILIUM_KEY_TO_PORTS` pins established on the sibling per-
23170 // K8s-CR-schema-field-name axes.
23171 let v = FLUX_KEY_SOURCE_REF;
23172 assert!(
23173 !v.is_empty(),
23174 "FLUX_KEY_SOURCE_REF {v:?} must be non-empty per the Flux v2 \
23175 CRD field-naming grammar"
23176 );
23177 let mut chars = v.chars();
23178 assert!(
23179 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23180 "FLUX_KEY_SOURCE_REF {v:?} must lead with an ASCII-lowercase \
23181 byte per the Flux v2 lowerCamelCase per-CR-field-key convention"
23182 );
23183 assert!(
23184 v.chars().all(|c| c.is_ascii_alphanumeric()),
23185 "FLUX_KEY_SOURCE_REF {v:?} must be ASCII-alphanumeric throughout \
23186 per the Flux v2 lowerCamelCase per-CR-field-key convention — \
23187 no `_` / `-` / `.` / whitespace bytes the Flux v2 source-\
23188 controller's per-CR reconcile loop would reject"
23189 );
23190 }
23191
23192 #[test]
23193 fn flux_key_values_pins_canonical_value() {
23194 // Pin the actual string so a typo in this lift can't silently
23195 // rebrand the Flux v2 per-`HelmRelease` values-override block-
23196 // body-axis key the rendered `helmrelease.yaml`'s `spec.values`
23197 // block declares. The string is part of the cluster-side
23198 // contract with the Flux v2 `helm-controller` — the per-CR
23199 // reconcile loop merges the per-cluster override YAML nested
23200 // under this exact block-body axis into the referenced chart's
23201 // `values.yaml` at Helm-render time; a drifted value
23202 // (`"Values"` / `"vals"` / `"chartValues"` / `"overrides"`)
23203 // silently routes the per-cluster overrides nowhere at Helm
23204 // render, and the workload comes up with the referenced
23205 // chart's admission-time defaults. Changing this value is a
23206 // coordinated Flux v3 migration alongside the upstream
23207 // `fluxcd/flux2` deprecation cycle, not an incidental edit.
23208 // Peer to `flux_key_source_ref_pins_canonical_value` on the
23209 // sibling Flux v2 per-CR container-axis-key surface — extends
23210 // the canonical-Flux-v2-load-bearing-string pin discipline from
23211 // the per-CR source-reference container-axis onto the sibling
23212 // per-`HelmRelease` values-override block-body-axis.
23213 assert_eq!(FLUX_KEY_VALUES, "values");
23214 }
23215
23216 #[test]
23217 fn flux_key_values_carries_lower_camel_case_shape() {
23218 // Cross-axis invariant: the Flux v2 CRD field-naming convention
23219 // (inherited from the upstream K8s API conventions) admits
23220 // lowerCamelCase per-field keys — the values-override block-
23221 // body axis conforms to this on the leading-lowercase `values`
23222 // shape (a single-word lowerCamelCase reduces to all-lowercase).
23223 // Pinning the shape here means a future rebrand on the
23224 // canonical lift can't silently land a malformed block-body-
23225 // axis key (snake_case, kebab-case, UpperCamelCase, empty) that
23226 // the Flux v2 helm-controller's per-CR reconcile loop would
23227 // reject at apply parse time far from the rebrand commit's
23228 // source. Peer to `flux_key_source_ref_carries_lower_camel_case_shape`
23229 // on the sibling Flux v2 per-CR container-axis-key surface.
23230 let v = FLUX_KEY_VALUES;
23231 assert!(
23232 !v.is_empty(),
23233 "FLUX_KEY_VALUES {v:?} must be non-empty per the Flux v2 \
23234 CRD field-naming grammar"
23235 );
23236 let mut chars = v.chars();
23237 assert!(
23238 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23239 "FLUX_KEY_VALUES {v:?} must lead with an ASCII-lowercase \
23240 byte per the Flux v2 lowerCamelCase per-CR-field-key convention"
23241 );
23242 assert!(
23243 v.chars().all(|c| c.is_ascii_alphanumeric()),
23244 "FLUX_KEY_VALUES {v:?} must be ASCII-alphanumeric throughout \
23245 per the Flux v2 lowerCamelCase per-CR-field-key convention — \
23246 no `_` / `-` / `.` / whitespace bytes the Flux v2 helm-\
23247 controller's per-CR reconcile loop would reject"
23248 );
23249 }
23250
23251 #[test]
23252 fn flux_key_chart_pins_canonical_value() {
23253 // Pin the actual string so a typo in this lift can't silently
23254 // rebrand the Flux v2 per-`HelmRelease` inline-chart-template
23255 // container-axis key the rendered `helmrelease.yaml`'s
23256 // `spec.chart` block declares. The string is part of the
23257 // cluster-side contract with the Flux v2 `helm-controller` —
23258 // the per-CR reconcile loop reads the nested
23259 // `HelmChartTemplate` sub-document (chart-name string,
23260 // source-of-truth reference triple, and reconcile cadence)
23261 // under this exact container axis to source the referenced
23262 // chart at Helm-render time; a drifted value (`"Chart"` /
23263 // `"chartTemplate"` / `"helmChart"` / `"chartRef"`) silently
23264 // dangles the whole chart-template resolution at the helm-
23265 // controller's CRD registration and the referenced chart
23266 // never resolves. Changing this value is a coordinated Flux
23267 // v3 migration alongside the upstream `fluxcd/flux2`
23268 // deprecation cycle, not an incidental edit. Peer to
23269 // `flux_key_source_ref_pins_canonical_value` /
23270 // `flux_key_values_pins_canonical_value` on the sibling Flux
23271 // v2 per-`HelmRelease` body-key surfaces — extends the
23272 // canonical-Flux-v2-load-bearing-string pin discipline from
23273 // the source-reference container-axis + values-override
23274 // block-body-axis onto the sibling chart-template container-
23275 // axis, completing the triplet of Flux v2 per-`HelmRelease`
23276 // `spec.*` body-key pin tests.
23277 assert_eq!(FLUX_KEY_CHART, "chart");
23278 }
23279
23280 #[test]
23281 fn flux_key_chart_carries_lower_camel_case_shape() {
23282 // Cross-axis invariant: the Flux v2 CRD field-naming
23283 // convention (inherited from the upstream K8s API
23284 // conventions) admits lowerCamelCase per-field keys — the
23285 // chart-template container-axis conforms to this on the
23286 // leading-lowercase `chart` shape (a single-word
23287 // lowerCamelCase reduces to all-lowercase). Pinning the shape
23288 // here means a future rebrand on the canonical lift can't
23289 // silently land a malformed container-axis key (snake_case,
23290 // kebab-case, UpperCamelCase, empty) that the Flux v2 helm-
23291 // controller's per-CR reconcile loop would reject at apply
23292 // parse time far from the rebrand commit's source. Peer to
23293 // `flux_key_source_ref_carries_lower_camel_case_shape` /
23294 // `flux_key_values_carries_lower_camel_case_shape` on the
23295 // sibling Flux v2 per-`HelmRelease` body-key surfaces.
23296 let v = FLUX_KEY_CHART;
23297 assert!(
23298 !v.is_empty(),
23299 "FLUX_KEY_CHART {v:?} must be non-empty per the Flux v2 \
23300 CRD field-naming grammar"
23301 );
23302 let mut chars = v.chars();
23303 assert!(
23304 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23305 "FLUX_KEY_CHART {v:?} must lead with an ASCII-lowercase \
23306 byte per the Flux v2 lowerCamelCase per-CR-field-key convention"
23307 );
23308 assert!(
23309 v.chars().all(|c| c.is_ascii_alphanumeric()),
23310 "FLUX_KEY_CHART {v:?} must be ASCII-alphanumeric throughout \
23311 per the Flux v2 lowerCamelCase per-CR-field-key convention — \
23312 no `_` / `-` / `.` / whitespace bytes the Flux v2 helm-\
23313 controller's per-CR reconcile loop would reject"
23314 );
23315 }
23316
23317 #[test]
23318 fn flux_helmchart_template_key_chart_pins_canonical_value() {
23319 // Pin the actual string so a typo in this lift can't silently
23320 // rebrand the Flux v2 `HelmChartTemplate.spec.chart` per-CR
23321 // chart-NAME reference leaf-scalar-axis key every caixa-flux-
23322 // emitted `HelmRelease` document nests inside the parent
23323 // `spec.chart.spec` sub-document. The helm-controller's
23324 // reconcile pipeline reads the chart-artifact name from this
23325 // exact leaf on every reconcile — a drifted `spec.chart.spec.Chart`
23326 // / `spec.chart.spec.chartRef` / `spec.chart.spec.chartName`
23327 // at the emission-side leaf key would silently land as a well-
23328 // formed but ignored `HelmChartTemplate.spec.*` extra property
23329 // the apiserver's CRD OpenAPI schema permits (arbitrary spec
23330 // extras) and the helm-controller would fail to resolve any
23331 // chart-artifact through the sibling `sourceRef` triple's
23332 // source at reconcile time — a non-self-locating "chart
23333 // 'unknown' not found in <source>" error far from the rebrand
23334 // commit's source `caixa.lisp` / the renderer's format-string
23335 // template. Peer to `flux_key_chart_pins_canonical_value` on
23336 // the sibling per-CR chart-template container-axis parent
23337 // this leaf-scalar-axis lift extends by descending one level
23338 // beneath, closing the substrate-side declaration the parent
23339 // container-axis lift docstring explicitly named as future
23340 // work.
23341 assert_eq!(FLUX_HELMCHART_TEMPLATE_KEY_CHART, "chart");
23342 }
23343
23344 #[test]
23345 fn flux_helmchart_template_key_chart_carries_lower_camel_case_shape() {
23346 // Cross-axis invariant: the Flux v2 CRD field-naming
23347 // convention (inherited from the upstream K8s API conventions)
23348 // admits lowerCamelCase per-field keys — the per-`HelmChartTemplate`
23349 // chart-NAME reference leaf-scalar-axis conforms to this on the
23350 // leading-lowercase `chart` shape (a single-word lowerCamelCase
23351 // reduces to all-lowercase). Pinning the shape here means a
23352 // future rebrand on the canonical lift can't silently land a
23353 // malformed leaf-scalar-axis key (snake_case, kebab-case,
23354 // UpperCamelCase, empty) that the Flux v2 helm-controller's
23355 // per-CR reconcile loop would reject at apply parse time far
23356 // from the rebrand commit's source. Peer to
23357 // `flux_key_chart_carries_lower_camel_case_shape` on the
23358 // sibling per-CR chart-template container-axis parent, and to
23359 // the deliberate axis-independence discipline the sibling
23360 // [`CILIUM_KEY_PATH`] / [`GATEWAY_API_KEY_PATH`] two-CRD-
23361 // groups-sharing-a-string re-exports established (two consts
23362 // spelling the same underlying string at distinct schema
23363 // axes stay sibling constants at the rustc symbol-name axis).
23364 let v = FLUX_HELMCHART_TEMPLATE_KEY_CHART;
23365 assert!(
23366 !v.is_empty(),
23367 "FLUX_HELMCHART_TEMPLATE_KEY_CHART {v:?} must be non-empty per \
23368 the Flux v2 CRD field-naming grammar"
23369 );
23370 let mut chars = v.chars();
23371 assert!(
23372 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23373 "FLUX_HELMCHART_TEMPLATE_KEY_CHART {v:?} must lead with an \
23374 ASCII-lowercase byte per the Flux v2 lowerCamelCase per-CR-\
23375 field-key convention"
23376 );
23377 assert!(
23378 v.chars().all(|c| c.is_ascii_alphanumeric()),
23379 "FLUX_HELMCHART_TEMPLATE_KEY_CHART {v:?} must be ASCII-\
23380 alphanumeric throughout per the Flux v2 lowerCamelCase per-CR-\
23381 field-key convention — no `_` / `-` / `.` / whitespace bytes \
23382 the Flux v2 helm-controller's per-CR reconcile loop would reject"
23383 );
23384 }
23385
23386 #[test]
23387 fn flux_helmchart_template_key_chart_and_flux_key_chart_stay_independent_axes() {
23388 // Cross-axis independence pin: both `FLUX_HELMCHART_TEMPLATE_KEY_CHART`
23389 // (`spec.chart.spec.chart` chart-NAME reference leaf-scalar-axis)
23390 // and the sibling `FLUX_KEY_CHART` (`spec.chart` per-CR chart-
23391 // template container-axis parent) spell the same underlying
23392 // `"chart"` string today but name distinct schema axes on the
23393 // same Flux v2 `HelmRelease` CRD group (a container-axis parent
23394 // vs a leaf-scalar grandchild inside it). Pin byte-equality of
23395 // each half against its own canonical declaration so a future
23396 // Flux v3 rebrand on either axis lands independently at the
23397 // rustc symbol-name axis rather than coalescing onto one
23398 // canonical declaration through a shared `&'static str`
23399 // allocation Rust's string interner would otherwise fuse.
23400 // Same axis-independence discipline the sibling
23401 // [`CILIUM_KEY_PATH`] (ef6114f) / [`GATEWAY_API_KEY_PATH`]
23402 // (9f45aa4) two-CRD-groups-sharing-a-string re-exports
23403 // established on the peer canonical-axis-independence surface.
23404 assert_eq!(FLUX_HELMCHART_TEMPLATE_KEY_CHART, "chart");
23405 assert_eq!(FLUX_KEY_CHART, "chart");
23406 assert_eq!(FLUX_HELMCHART_TEMPLATE_KEY_CHART, FLUX_KEY_CHART);
23407 }
23408
23409 #[test]
23410 fn flux_key_health_checks_pins_canonical_value() {
23411 // Pin the actual string so a typo in this lift can't silently
23412 // rebrand the Flux v2 per-`Kustomization` health-gate reference-
23413 // list container-axis key the rendered `kustomization.yaml`'s
23414 // `spec.healthChecks` block declares. The string is part of the
23415 // cluster-side contract with the Flux v2 `kustomize-controller`
23416 // — the per-CR reconcile loop reads the nested
23417 // `[]NamespacedObjectKindReference` list under this exact
23418 // container axis to gate the parent `Kustomization`'s
23419 // `Ready=True` transition on the referenced sibling
23420 // `HelmRelease` reaching its `HelmReleaseReady=True` condition;
23421 // a drifted value (`"HealthChecks"` / `"healthchecks"` /
23422 // `"healthcheck"` / `"health_checks"` / `"probes"`) silently
23423 // dangles the parent `Kustomization` at `Reconciling` forever
23424 // at the kustomize-controller's health-gate evaluation, and the
23425 // dependent per-cluster fleet-programs upsert chain never sees
23426 // `Ready=True`. Changing this value is a coordinated Flux v3
23427 // migration alongside the upstream `fluxcd/flux2` deprecation
23428 // cycle, not an incidental edit. Peer to
23429 // `flux_key_source_ref_pins_canonical_value` /
23430 // `flux_key_chart_pins_canonical_value` /
23431 // `flux_key_values_pins_canonical_value` on the sibling Flux v2
23432 // body-key surfaces — extends the canonical-Flux-v2-load-bearing-
23433 // string pin discipline from the per-`HelmRelease` triplet
23434 // (`spec.chart` + `spec.chart.spec.sourceRef` + `spec.values`)
23435 // onto the sibling per-`Kustomization` `spec.healthChecks`
23436 // reference-list container-axis, completing the quartet of Flux
23437 // v2 `spec.*` body-key pin tests.
23438 assert_eq!(FLUX_KEY_HEALTH_CHECKS, "healthChecks");
23439 }
23440
23441 #[test]
23442 fn flux_key_health_checks_carries_lower_camel_case_shape() {
23443 // Cross-axis invariant: the Flux v2 CRD field-naming convention
23444 // (inherited from the upstream K8s API conventions) admits
23445 // lowerCamelCase per-field keys — the per-`Kustomization`
23446 // health-gate reference-list container-axis conforms to this on
23447 // the leading-lowercase `healthChecks` shape. Pinning the shape
23448 // here means a future rebrand on the canonical lift can't
23449 // silently land a malformed container-axis key (snake_case,
23450 // kebab-case, UpperCamelCase, empty) that the Flux v2 kustomize-
23451 // controller's per-CR reconcile loop would reject at apply
23452 // parse time far from the rebrand commit's source. Peer to
23453 // `flux_key_source_ref_carries_lower_camel_case_shape` /
23454 // `flux_key_chart_carries_lower_camel_case_shape` /
23455 // `flux_key_values_carries_lower_camel_case_shape` on the
23456 // sibling Flux v2 body-key surfaces.
23457 let v = FLUX_KEY_HEALTH_CHECKS;
23458 assert!(
23459 !v.is_empty(),
23460 "FLUX_KEY_HEALTH_CHECKS {v:?} must be non-empty per the Flux \
23461 v2 CRD field-naming grammar"
23462 );
23463 let mut chars = v.chars();
23464 assert!(
23465 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23466 "FLUX_KEY_HEALTH_CHECKS {v:?} must lead with an ASCII-\
23467 lowercase byte per the Flux v2 lowerCamelCase per-CR-field-\
23468 key convention"
23469 );
23470 assert!(
23471 v.chars().all(|c| c.is_ascii_alphanumeric()),
23472 "FLUX_KEY_HEALTH_CHECKS {v:?} must be ASCII-alphanumeric \
23473 throughout per the Flux v2 lowerCamelCase per-CR-field-key \
23474 convention — no `_` / `-` / `.` / whitespace bytes the Flux \
23475 v2 kustomize-controller's per-CR reconcile loop would reject"
23476 );
23477 }
23478
23479 #[test]
23480 fn flux_key_interval_pins_canonical_value() {
23481 // Pin the actual string so a typo in this lift can't silently
23482 // rebrand the Flux v2 per-CR reconcile-poll cadence scalar-axis
23483 // key the rendered Flux bundle's three `spec.interval` scalars
23484 // declare — the shared axis-key the source-controller, helm-
23485 // controller, and kustomize-controller each read to schedule
23486 // their per-CR poll cycles off the sibling per-CR `apiVersion` +
23487 // `kind` registration. A drifted value (`"Interval"` / `"period"`
23488 // / `"cadence"` / `"pollInterval"` / `"reconcileInterval"`)
23489 // silently drops the per-CR reconcile schedule from all three
23490 // Flux controllers' per-CR watch registrations simultaneously —
23491 // the referenced Git source never re-polls / the referenced
23492 // chart never re-templates / the parent Kustomization never
23493 // re-applies at upstream drift, freezing the whole cluster's
23494 // per-`caixa` per-cluster bundle at the last-applied snapshot.
23495 // Changing this value is a coordinated Flux v3 migration
23496 // alongside the upstream `fluxcd/flux2` deprecation cycle, not
23497 // an incidental edit. Peer to
23498 // `flux_key_source_ref_pins_canonical_value` /
23499 // `flux_key_chart_pins_canonical_value` /
23500 // `flux_key_values_pins_canonical_value` /
23501 // `flux_key_health_checks_pins_canonical_value` on the sibling
23502 // Flux v2 per-CR body-key surfaces — extends the canonical-Flux-
23503 // v2-load-bearing-string pin discipline from the per-CR body-key
23504 // quartet onto the sibling cross-CR-shared reconcile-poll
23505 // cadence scalar-axis every Flux v2 controller reads.
23506 assert_eq!(FLUX_KEY_INTERVAL, "interval");
23507 }
23508
23509 #[test]
23510 fn flux_key_interval_carries_lower_camel_case_shape() {
23511 // Cross-axis invariant: the Flux v2 CRD field-naming convention
23512 // (inherited from the upstream K8s API conventions) admits
23513 // lowerCamelCase per-field keys — the per-CR reconcile-poll
23514 // cadence scalar-axis conforms to this on the leading-lowercase
23515 // `interval` shape. Pinning the shape here means a future rebrand
23516 // on the canonical lift can't silently land a malformed scalar-
23517 // axis key (snake_case, kebab-case, UpperCamelCase, empty) that
23518 // any of the three Flux v2 controllers' per-CR reconcile loops
23519 // would reject at apply parse time far from the rebrand commit's
23520 // source. Peer to `flux_key_source_ref_carries_lower_camel_case_shape`
23521 // / `flux_key_chart_carries_lower_camel_case_shape` /
23522 // `flux_key_values_carries_lower_camel_case_shape` /
23523 // `flux_key_health_checks_carries_lower_camel_case_shape` on the
23524 // sibling Flux v2 per-CR body-key surfaces.
23525 let v = FLUX_KEY_INTERVAL;
23526 assert!(
23527 !v.is_empty(),
23528 "FLUX_KEY_INTERVAL {v:?} must be non-empty per the Flux \
23529 v2 CRD field-naming grammar"
23530 );
23531 let mut chars = v.chars();
23532 assert!(
23533 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23534 "FLUX_KEY_INTERVAL {v:?} must lead with an ASCII-\
23535 lowercase byte per the Flux v2 lowerCamelCase per-CR-field-\
23536 key convention"
23537 );
23538 assert!(
23539 v.chars().all(|c| c.is_ascii_alphanumeric()),
23540 "FLUX_KEY_INTERVAL {v:?} must be ASCII-alphanumeric \
23541 throughout per the Flux v2 lowerCamelCase per-CR-field-key \
23542 convention — no `_` / `-` / `.` / whitespace bytes any of \
23543 the three Flux v2 controllers' per-CR reconcile loops would \
23544 reject"
23545 );
23546 }
23547
23548 #[test]
23549 fn flux_gitrepository_ref_key_tag_pins_canonical_value() {
23550 // Pin the actual string so a typo in this lift can't silently
23551 // rebrand the Flux v2 per-`GitRepository` `spec.ref.tag`
23552 // git-tag-selector scalar-axis key the rendered
23553 // `gitrepository.yaml` document declares on the tag-arm of the
23554 // FluxCD source-controller `spec.ref` discriminated-union axis.
23555 // A drifted value (`"Tag"` / `"gitTag"` / `"tagName"`) silently
23556 // dangles the tag-arm sub-block at the FluxCD source-controller's
23557 // CRD registration; the per-Servico clone never resolves at
23558 // reconcile time. Peer to
23559 // `flux_gitrepository_ref_key_branch_pins_canonical_value` /
23560 // `flux_gitrepository_ref_key_commit_pins_canonical_value` on
23561 // the sibling per-shape arms of the same discriminated-union
23562 // axis — closes the three-arm sub-selector-key trio the
23563 // FluxCD source-controller reads to bind the per-CR git-source
23564 // clone refspec.
23565 assert_eq!(FLUX_GITREPOSITORY_REF_KEY_TAG, "tag");
23566 }
23567
23568 #[test]
23569 fn flux_gitrepository_ref_key_branch_pins_canonical_value() {
23570 // Peer of `flux_gitrepository_ref_key_tag_pins_canonical_value`
23571 // on the branch-arm of the FluxCD source-controller
23572 // `GitRepository.spec.ref` discriminated-union axis.
23573 assert_eq!(FLUX_GITREPOSITORY_REF_KEY_BRANCH, "branch");
23574 }
23575
23576 #[test]
23577 fn flux_gitrepository_ref_key_commit_pins_canonical_value() {
23578 // Peer of `flux_gitrepository_ref_key_tag_pins_canonical_value`
23579 // on the commit-arm of the FluxCD source-controller
23580 // `GitRepository.spec.ref` discriminated-union axis.
23581 assert_eq!(FLUX_GITREPOSITORY_REF_KEY_COMMIT, "commit");
23582 }
23583
23584 #[test]
23585 fn flux_gitrepository_key_ref_pins_canonical_value() {
23586 // Bridge-arm pin: [`FLUX_GITREPOSITORY_KEY_REF`] resolves to
23587 // the canonical `"ref"` byte today — the exact YAML key the
23588 // FluxCD `source-controller` reads on every rendered
23589 // `GitRepository` document's `spec.ref` container-axis to
23590 // source the per-CR git-clone refspec discriminated-union
23591 // arm (`{tag, branch, commit}`). Pin the literal here (peer
23592 // with the sibling
23593 // [`flux_gitrepository_ref_key_tag_pins_canonical_value`] /
23594 // [`flux_gitrepository_ref_key_branch_pins_canonical_value`] /
23595 // [`flux_gitrepository_ref_key_commit_pins_canonical_value`]
23596 // per-shape arm sub-selector pins on the same `spec.ref`
23597 // sub-schema) so a future Flux v3 sub-schema rebrand on the
23598 // parent container-axis surfaces here as a coordinated edit-
23599 // point at the definition site rather than a silent apply-
23600 // time split between the writer-side template composer and
23601 // the aggregator's per-CR `RESTMapper` reader.
23602 assert_eq!(FLUX_GITREPOSITORY_KEY_REF, "ref");
23603 }
23604
23605 #[test]
23606 fn flux_gitrepository_key_url_pins_canonical_value() {
23607 // Bridge-arm pin: [`FLUX_GITREPOSITORY_KEY_URL`] resolves to
23608 // the canonical `"url"` byte today — the exact YAML key the
23609 // FluxCD `source-controller` reads on every rendered
23610 // `GitRepository` document's `spec.url` leaf-scalar-axis to
23611 // source the per-CR git-remote clone target. Pin the literal
23612 // here (peer with the sibling
23613 // [`flux_gitrepository_key_ref_pins_canonical_value`] on the
23614 // per-CR `spec.ref` container-axis surface) so a future Flux
23615 // v3 sub-schema rebrand on the URL axis (e.g. an upstream
23616 // `fluxcd/flux2` rename of `spec.url` to `spec.gitUrl` /
23617 // `spec.repository`) surfaces here as a coordinated edit-
23618 // point at the definition site rather than a silent apply-
23619 // time split between the writer-side template composer and
23620 // the source-controller's per-CR `RESTMapper` reader.
23621 assert_eq!(FLUX_GITREPOSITORY_KEY_URL, "url");
23622 }
23623
23624 #[test]
23625 fn flux_gitrepository_key_url_stays_independent_of_ref_and_api_version() {
23626 // Cross-axis peer-independence pin: the per-`GitRepository`-CRD
23627 // canonical-load-bearing-string surface carries three distinct
23628 // axes on the same CRD — `apiVersion`
23629 // ([`FLUX_GITREPOSITORY_API_VERSION`], the CRD-group/version
23630 // half of the `(apiVersion, kind)` apiserver-side CRD-lookup
23631 // tuple), `spec.ref`
23632 // ([`FLUX_GITREPOSITORY_KEY_REF`], the per-CR ref-selection
23633 // container-axis), and `spec.url`
23634 // ([`FLUX_GITREPOSITORY_KEY_URL`], the per-CR remote-repo-URL
23635 // leaf-scalar-axis). These three constants spell mutually
23636 // distinct schema axes on the same Flux v2 `source-controller`
23637 // CRD; pinning distinctness here means a future rebrand on
23638 // any one axis (a Flux v3 CRD-version bump, a `spec.ref`
23639 // container-axis rename, or a `spec.url` schema promotion)
23640 // surfaces as an edit on the corresponding canonical const
23641 // alone, without silently collapsing the three axes into one
23642 // edit-point at the rustc symbol-name axis.
23643 assert_ne!(FLUX_GITREPOSITORY_KEY_URL, FLUX_GITREPOSITORY_KEY_REF);
23644 assert_ne!(FLUX_GITREPOSITORY_KEY_URL, FLUX_GITREPOSITORY_API_VERSION);
23645 }
23646
23647 #[test]
23648 fn flux_gitrepository_ref_keys_all_carry_lower_camel_case_shape() {
23649 // Cross-axis invariant on all three arms of the FluxCD
23650 // source-controller `GitRepository.spec.ref` discriminated-union
23651 // axis: the Flux v2 CRD field-naming convention (inherited from
23652 // the upstream K8s API conventions) admits lowerCamelCase
23653 // per-field keys — `tag` / `branch` / `commit` all conform.
23654 // Pinning the shape here means a future rebrand on any of the
23655 // three canonical lifts can't silently land a malformed
23656 // sub-selector key (snake_case, kebab-case, UpperCamelCase,
23657 // empty) that the Flux v2 source-controller's per-CR reconcile
23658 // loop would reject at apply parse time. Peer to
23659 // `flux_key_interval_carries_lower_camel_case_shape` on the
23660 // sibling per-CR reconcile-poll-cadence scalar-axis key surface.
23661 for v in [
23662 FLUX_GITREPOSITORY_REF_KEY_TAG,
23663 FLUX_GITREPOSITORY_REF_KEY_BRANCH,
23664 FLUX_GITREPOSITORY_REF_KEY_COMMIT,
23665 ] {
23666 assert!(
23667 !v.is_empty(),
23668 "FLUX_GITREPOSITORY_REF_KEY_* {v:?} must be non-empty \
23669 per the Flux v2 CRD field-naming grammar"
23670 );
23671 let mut chars = v.chars();
23672 assert!(
23673 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23674 "FLUX_GITREPOSITORY_REF_KEY_* {v:?} must lead with an \
23675 ASCII-lowercase byte per the Flux v2 lowerCamelCase \
23676 per-CR-field-key convention"
23677 );
23678 assert!(
23679 v.chars().all(|c| c.is_ascii_alphanumeric()),
23680 "FLUX_GITREPOSITORY_REF_KEY_* {v:?} must be ASCII-\
23681 alphanumeric throughout per the Flux v2 lowerCamelCase \
23682 per-CR-field-key convention — no `_` / `-` / `.` / \
23683 whitespace bytes the Flux v2 source-controller's per-CR \
23684 reconcile loop would reject"
23685 );
23686 }
23687 }
23688
23689 #[test]
23690 fn flux_gitrepository_ref_keys_are_pairwise_distinct() {
23691 // The three arms of the FluxCD source-controller
23692 // `GitRepository.spec.ref` discriminated-union axis must remain
23693 // pairwise distinct — a hypothetical drift that collapsed two
23694 // sub-selector keys onto the same byte-string (e.g. an
23695 // accidental copy-paste making TAG and BRANCH both spell
23696 // `"tag"`) would silently reroute the per-shape emit at
23697 // `caixa_flux::GitRefSpec::ref_field_name` dispatch time and
23698 // dangle one arm's rendered `spec.ref` sub-block at cluster-
23699 // apply time. Pin the pairwise-distinctness here so the drift
23700 // fires at test time, not at cluster-apply time far from the
23701 // drift site.
23702 let keys = [
23703 FLUX_GITREPOSITORY_REF_KEY_TAG,
23704 FLUX_GITREPOSITORY_REF_KEY_BRANCH,
23705 FLUX_GITREPOSITORY_REF_KEY_COMMIT,
23706 ];
23707 for (i, a) in keys.iter().enumerate() {
23708 for b in keys.iter().skip(i + 1) {
23709 assert_ne!(
23710 a, b,
23711 "FLUX_GITREPOSITORY_REF_KEY_* arms must be pairwise \
23712 distinct (got a duplicate: {a:?})"
23713 );
23714 }
23715 }
23716 }
23717
23718 #[test]
23719 fn flux_kind_kustomization_carries_upper_camel_case_shape() {
23720 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
23721 // an UpperCamelCase identifier per the K8s API conventions
23722 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
23723 // "Kinds are always UpperCamelCase"). Pinning the shape here
23724 // means a future rebrand on the canonical lift can't silently
23725 // land a malformed kind discriminator (snake_case, kebab-case,
23726 // lowercase, empty) that every downstream YAML-aware
23727 // deserializer would reject far from the rebrand commit's
23728 // source. The first-byte uppercase / rest-ASCII-alphanumeric
23729 // invariant is the load-bearing K8s API typed-discovery
23730 // contract: a value the apiserver's `RESTMapper` consults to
23731 // resolve the CRD's `RESTKind`. Peer to
23732 // `flux_kind_git_repository_carries_upper_camel_case_shape` /
23733 // `flux_kind_helm_release_carries_upper_camel_case_shape` on
23734 // the sibling Flux v2 controller-triplet `kind`-axis surface.
23735 let v = FLUX_KIND_KUSTOMIZATION;
23736 assert!(
23737 !v.is_empty(),
23738 "FLUX_KIND_KUSTOMIZATION {v:?} must be non-empty per the K8s API \
23739 UpperCamelCase kind discriminator grammar"
23740 );
23741 let first = v.chars().next().expect("non-empty");
23742 assert!(
23743 first.is_ascii_uppercase(),
23744 "FLUX_KIND_KUSTOMIZATION {v:?} first byte {first:?} must be \
23745 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
23746 grammar (Kinds are always UpperCamelCase)"
23747 );
23748 assert!(
23749 v.chars().all(|c| c.is_ascii_alphanumeric()),
23750 "FLUX_KIND_KUSTOMIZATION {v:?} must be ASCII-alphanumeric \
23751 throughout per the K8s API kind discriminator grammar — no \
23752 snake_case, kebab-case, or whitespace bytes the apiserver-side \
23753 RESTMapper would reject"
23754 );
23755 }
23756
23757 #[test]
23758 fn gateway_api_api_version_pins_canonical_value() {
23759 // Pin the actual string so a typo in this lift can't silently
23760 // rebrand the K8s SIG-Network Gateway API CRD group/version
23761 // the rendered `Gateway` / `HTTPRoute` documents declare. The
23762 // string is part of the cluster-side contract with the
23763 // upstream Gateway-API-conformant gateway implementation
23764 // (Cilium, Istio, Envoy Gateway, NGINX, et al.): the
23765 // apiserver-side CRD-version registration watches the exact
23766 // `gateway.networking.k8s.io/v1` group/version; a drifted
23767 // value to a stale v1beta1 / v1alpha2 lands the rendered
23768 // `Gateway` / `HTTPRoute` outside the registration and fails
23769 // at apply time with "no kind 'Gateway' is registered for
23770 // version 'gateway.networking.k8s.io/v1beta1'"; changing it
23771 // is a coordinated Gateway API GA promotion alongside the
23772 // upstream SIG-Network deprecation cycle, not an incidental
23773 // edit. Peer to `flux_kustomization_api_version_pins_canonical_value`
23774 // / `flux_helmrelease_api_version_pins_canonical_value` /
23775 // `flux_gitrepository_api_version_pins_canonical_value` on
23776 // the canonical-K8s-CRD-axis-pin axis for the sibling
23777 // Flux v2 controller-triplet constants — extends the
23778 // canonical-string-pin discipline from the cluster-side
23779 // Flux v2 reconcile contract onto the cluster-side K8s
23780 // Gateway API ingress contract.
23781 assert_eq!(GATEWAY_API_API_VERSION, "gateway.networking.k8s.io/v1");
23782 }
23783
23784 #[test]
23785 fn gateway_api_api_version_carries_group_and_version_segments() {
23786 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
23787 // `<group>/<version>` pair separated by exactly one `/` byte.
23788 // The group segment is a DNS-style multi-segment hostname
23789 // (`gateway.networking.k8s.io`) and the version segment is a
23790 // Kubernetes API version label (`v1`, `v1beta1`, `v1alpha2` —
23791 // peer with the K8s API versioning convention upstream
23792 // documents). Pinning this here means a future rebrand on the
23793 // canonical lift can't silently land a malformed apiVersion
23794 // (no `/`, two `/`, empty group, empty version) that every
23795 // downstream YAML-aware deserializer would reject far from the
23796 // rebrand commit's source. The single-`/` invariant is the
23797 // load-bearing K8s API typed-discovery contract: a value the
23798 // apiserver's `RESTMapper` consults to resolve the CRD's
23799 // `RESTKind`. Peer to
23800 // `flux_kustomization_api_version_carries_group_and_version_segments`
23801 // / `flux_helmrelease_api_version_carries_group_and_version_segments`
23802 // / `flux_gitrepository_api_version_carries_group_and_version_segments`
23803 // on the sibling Flux v2 controller-triplet CRD-axes.
23804 let v = GATEWAY_API_API_VERSION;
23805 let parts: Vec<&str> = v.split('/').collect();
23806 assert_eq!(
23807 parts.len(),
23808 2,
23809 "GATEWAY_API_API_VERSION {v:?} must split into exactly two \
23810 `/`-delimited segments (group/version) per the K8s CRD apiVersion \
23811 grammar — every downstream YAML-aware deserializer enforces this \
23812 shape"
23813 );
23814 assert!(
23815 !parts[0].is_empty(),
23816 "GATEWAY_API_API_VERSION {v:?} group segment must be non-empty"
23817 );
23818 assert!(
23819 !parts[1].is_empty(),
23820 "GATEWAY_API_API_VERSION {v:?} version segment must be non-empty"
23821 );
23822 assert!(
23823 parts[0].contains('.'),
23824 "GATEWAY_API_API_VERSION {v:?} group segment {group:?} must be a \
23825 DNS-style multi-segment hostname (the canonical CRD-group convention \
23826 every K8s controller-runtime / kube-rs-aware client expects)",
23827 group = parts[0]
23828 );
23829 }
23830
23831 #[test]
23832 fn cilium_api_version_pins_canonical_value() {
23833 // Pin the actual string so a typo in this lift can't silently
23834 // rebrand the Cilium CRD group/version the rendered
23835 // `CiliumNetworkPolicy` document declares. The string is part
23836 // of the cluster-side contract with the upstream Cilium
23837 // operator: the Cilium-operator-side CRD-version registration
23838 // watches the exact `cilium.io/v2` group/version; a drifted
23839 // value to a stale `v2alpha1` lands the rendered
23840 // `CiliumNetworkPolicy` outside the registration and fails at
23841 // apply time with "no kind 'CiliumNetworkPolicy' is registered
23842 // for version 'cilium.io/v2alpha1'"; changing it is a
23843 // coordinated Cilium-CRD promotion alongside the upstream
23844 // Cilium deprecation cycle, not an incidental edit. Peer to
23845 // `gateway_api_api_version_pins_canonical_value` /
23846 // `flux_kustomization_api_version_pins_canonical_value` /
23847 // `flux_helmrelease_api_version_pins_canonical_value` /
23848 // `flux_gitrepository_api_version_pins_canonical_value` on
23849 // the canonical-K8s-CRD-axis-pin axis for the sibling
23850 // K8s Gateway API + Flux v2 controller-triplet constants —
23851 // extends the canonical-string-pin discipline from the
23852 // cluster-side K8s Gateway API ingress + Flux v2 reconcile
23853 // contracts onto the cluster-side Cilium identity-based mesh
23854 // contract.
23855 assert_eq!(CILIUM_API_VERSION, "cilium.io/v2");
23856 }
23857
23858 #[test]
23859 fn cilium_api_version_carries_group_and_version_segments() {
23860 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
23861 // `<group>/<version>` pair separated by exactly one `/` byte.
23862 // The group segment is a DNS-style hostname (`cilium.io`) and
23863 // the version segment is a Kubernetes API version label (`v2`,
23864 // `v2alpha1` — peer with the K8s API versioning convention
23865 // upstream documents). Pinning this here means a future rebrand
23866 // on the canonical lift can't silently land a malformed
23867 // apiVersion (no `/`, two `/`, empty group, empty version) that
23868 // every downstream YAML-aware deserializer would reject far
23869 // from the rebrand commit's source. The single-`/` invariant
23870 // is the load-bearing K8s API typed-discovery contract: a value
23871 // the apiserver's `RESTMapper` consults to resolve the CRD's
23872 // `RESTKind`. Peer to
23873 // `gateway_api_api_version_carries_group_and_version_segments`
23874 // / `flux_kustomization_api_version_carries_group_and_version_segments`
23875 // / `flux_helmrelease_api_version_carries_group_and_version_segments`
23876 // / `flux_gitrepository_api_version_carries_group_and_version_segments`
23877 // on the sibling K8s Gateway API + Flux v2 controller-triplet
23878 // CRD-axes.
23879 let v = CILIUM_API_VERSION;
23880 let parts: Vec<&str> = v.split('/').collect();
23881 assert_eq!(
23882 parts.len(),
23883 2,
23884 "CILIUM_API_VERSION {v:?} must split into exactly two \
23885 `/`-delimited segments (group/version) per the K8s CRD apiVersion \
23886 grammar — every downstream YAML-aware deserializer enforces this \
23887 shape"
23888 );
23889 assert!(
23890 !parts[0].is_empty(),
23891 "CILIUM_API_VERSION {v:?} group segment must be non-empty"
23892 );
23893 assert!(
23894 !parts[1].is_empty(),
23895 "CILIUM_API_VERSION {v:?} version segment must be non-empty"
23896 );
23897 assert!(
23898 parts[0].contains('.'),
23899 "CILIUM_API_VERSION {v:?} group segment {group:?} must be a \
23900 DNS-style hostname (the canonical CRD-group convention \
23901 every K8s controller-runtime / kube-rs-aware client expects)",
23902 group = parts[0]
23903 );
23904 }
23905
23906 #[test]
23907 fn cilium_kind_network_policy_pins_canonical_value() {
23908 // Pin the actual string so a typo in this lift can't silently
23909 // rebrand the Cilium-operator-side `CiliumNetworkPolicy` CRD
23910 // `kind` discriminator the rendered CNP document's top-level
23911 // `kind` axis declares. The string is part of the cluster-side
23912 // contract with the upstream Cilium operator — the apiserver-side
23913 // CRD resolution contract is the `(apiVersion, kind)` tuple
23914 // keyed against the registered `CustomResourceDefinition`, so
23915 // the kind half of the tuple is exactly as load-bearing as the
23916 // sibling [`CILIUM_API_VERSION`] apiVersion half. A drifted
23917 // value (e.g. an upstream rename to `CiliumNetworkPolicyV2`)
23918 // lands the rendered document outside the Cilium operator's
23919 // CRD registration; changing it is a coordinated Cilium-CRD
23920 // promotion alongside the upstream Cilium deprecation cycle,
23921 // not an incidental edit. Peer to
23922 // `flux_kind_kustomization_pins_canonical_value` /
23923 // `flux_kind_helm_release_pins_canonical_value` /
23924 // `flux_kind_git_repository_pins_canonical_value` on the
23925 // sibling cluster-side-CRD-`kind`-discriminator pin set —
23926 // extends the canonical-string-pin discipline from the Flux v2
23927 // controller-triplet `kind`-axis surface onto the Cilium-CRD
23928 // `kind`-axis surface, completing the per-Cilium-CRD
23929 // kind+apiVersion canonical-pin pair the M3 Aplicacao mesh
23930 // renderer's eBPF data-plane contract rests on.
23931 assert_eq!(CILIUM_KIND_NETWORK_POLICY, "CiliumNetworkPolicy");
23932 }
23933
23934 #[test]
23935 fn cilium_kind_network_policy_carries_upper_camel_case_shape() {
23936 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
23937 // an UpperCamelCase identifier per the K8s API conventions
23938 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
23939 // "Kinds are always UpperCamelCase"). Pinning the shape here
23940 // means a future rebrand on the canonical lift can't silently
23941 // land a malformed kind discriminator (snake_case, kebab-case,
23942 // lowercase, empty) that every downstream YAML-aware
23943 // deserializer would reject far from the rebrand commit's
23944 // source. The first-byte uppercase / rest-ASCII-alphanumeric
23945 // invariant is the load-bearing K8s API typed-discovery
23946 // contract: a value the apiserver's `RESTMapper` consults to
23947 // resolve the CRD's `RESTKind`. Peer to
23948 // `flux_kind_kustomization_carries_upper_camel_case_shape` /
23949 // `flux_kind_helm_release_carries_upper_camel_case_shape` /
23950 // `flux_kind_git_repository_carries_upper_camel_case_shape` on
23951 // the sibling cluster-side-CRD-`kind`-discriminator surface.
23952 let v = CILIUM_KIND_NETWORK_POLICY;
23953 assert!(
23954 !v.is_empty(),
23955 "CILIUM_KIND_NETWORK_POLICY {v:?} must be non-empty per the K8s API \
23956 UpperCamelCase kind discriminator grammar"
23957 );
23958 let first = v.chars().next().expect("non-empty");
23959 assert!(
23960 first.is_ascii_uppercase(),
23961 "CILIUM_KIND_NETWORK_POLICY {v:?} first byte {first:?} must be \
23962 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
23963 grammar (Kinds are always UpperCamelCase)"
23964 );
23965 assert!(
23966 v.chars().all(|c| c.is_ascii_alphanumeric()),
23967 "CILIUM_KIND_NETWORK_POLICY {v:?} must be ASCII-alphanumeric \
23968 throughout per the K8s API kind discriminator grammar — no \
23969 snake_case, kebab-case, or whitespace bytes the apiserver-side \
23970 RESTMapper would reject"
23971 );
23972 }
23973
23974 #[test]
23975 fn cilium_key_to_ports_pins_canonical_value() {
23976 // Pin the actual string so a typo in this lift can't silently
23977 // rebrand the Cilium CNP `spec.ingress[].toPorts[]` per-ingress-
23978 // rule port-set-container-axis key the rendered CNP document
23979 // mounts its per-port-set `{ports: […], rules: {…}}` list under.
23980 // The string is part of the cluster-side contract with the
23981 // upstream Cilium operator — the Cilium-operator-side per-CNP
23982 // L4/L7-dispatch pass keys off this axis to route the per-port
23983 // set through the eBPF data-plane's L4-allow (via `ports`) /
23984 // L7-dispatch (via nested `rules`) branches; a drifted value
23985 // (`"toport"` / `"toPort"` / `"targetPorts"`) at either the
23986 // production emitter or a downstream renderer's per-ingress-rule
23987 // port-set upsert silently emits a per-ingress-rule entry whose
23988 // port-set container the Cilium CRD schema validator drops as
23989 // unknown, and every intra-mesh `:contratos` flow the affected
23990 // CNP was authored to allow drops at the eBPF data-plane's
23991 // default-deny gate. Changing this value is a coordinated
23992 // Cilium-CRD promotion alongside the upstream Cilium project's
23993 // CRD schema-migration cycle, not an incidental edit. Peer to
23994 // `kube_key_rules_pins_canonical_value` (the nested
23995 // `spec.ingress[].toPorts[].rules` axis-key pin the L7-dispatch
23996 // container nests inside this port-set container's each entry)
23997 // on the sibling per-CNP-dispatch-axis pin set — completes the
23998 // per-CNP L4/L7-dispatch-container `(toPorts, rules)` pin pair
23999 // the M3 Aplicacao mesh renderer's eBPF data-plane contract
24000 // rests on.
24001 assert_eq!(CILIUM_KEY_TO_PORTS, "toPorts");
24002 }
24003
24004 #[test]
24005 fn cilium_key_to_ports_carries_lower_camel_case_shape() {
24006 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24007 // lowerCamelCase identifier per the K8s API conventions
24008 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24009 // "Field names should be lowercase camelCase") — first byte
24010 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24011 // kebab-case or whitespace. Pinning the shape here means a
24012 // future rebrand on the canonical lift can't silently land a
24013 // malformed field-name discriminator (snake_case, kebab-case,
24014 // UpperCamelCase, empty) that the apiserver-side CRD schema
24015 // validator would reject far from the rebrand commit's source.
24016 // The first-byte lowercase / rest-ASCII-alphanumeric invariant
24017 // is the load-bearing K8s API typed-schema contract: a value
24018 // the apiserver-side OpenAPI schema validator consults to
24019 // resolve each CR-field's typed slot. Peer to the sibling
24020 // per-CNP `kind`-axis
24021 // `cilium_kind_network_policy_carries_upper_camel_case_shape`
24022 // pin — the UpperCamelCase K8s discriminator grammar governs
24023 // the top-level `kind` axis, the lowerCamelCase K8s field-name
24024 // grammar governs every nested schema-field axis (including
24025 // this per-ingress-rule port-set-container-axis key), same
24026 // convention distinct grammars.
24027 let v = CILIUM_KEY_TO_PORTS;
24028 assert!(
24029 !v.is_empty(),
24030 "CILIUM_KEY_TO_PORTS {v:?} must be non-empty per the K8s API \
24031 lowerCamelCase field-name grammar"
24032 );
24033 let first = v.chars().next().expect("non-empty");
24034 assert!(
24035 first.is_ascii_lowercase(),
24036 "CILIUM_KEY_TO_PORTS {v:?} first byte {first:?} must be \
24037 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24038 grammar (field names are always lowerCamelCase)"
24039 );
24040 assert!(
24041 v.chars().all(|c| c.is_ascii_alphanumeric()),
24042 "CILIUM_KEY_TO_PORTS {v:?} must be ASCII-alphanumeric \
24043 throughout per the K8s API field-name grammar — no \
24044 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24045 OpenAPI schema validator would reject"
24046 );
24047 }
24048
24049 #[test]
24050 fn cilium_key_endpoint_selector_pins_canonical_value() {
24051 // Pin the actual string so a typo in this lift can't silently
24052 // rebrand the Cilium CNP `spec.endpointSelector` destination-
24053 // identity-axis key the rendered CNP document mounts its
24054 // L3-target `LabelSelector` under. The string is part of the
24055 // cluster-side contract with the upstream Cilium operator —
24056 // the Cilium-operator-side per-CNP identity-resolution pass
24057 // keys off this axis to bind the emitted policy against its
24058 // destination workload identity via the K8s LabelSelector
24059 // schema; a drifted value (`"endpointselector"` /
24060 // `"endpointSelectors"` / `"endpoints"`) at either the
24061 // production emitter or a downstream renderer's per-CNP
24062 // destination-identity upsert silently emits a CNP whose
24063 // destination-identity axis the Cilium CRD schema validator
24064 // drops as unknown, and the policy binds against no
24065 // destination pods — every intra-mesh `:contratos` flow the
24066 // affected CNP was authored to allow drops at the eBPF
24067 // data-plane's default-deny gate. Changing this value is a
24068 // coordinated Cilium-CRD promotion alongside the upstream
24069 // Cilium project's CRD schema-migration cycle, not an
24070 // incidental edit. Peer to `cilium_key_to_ports_pins_\
24071 // canonical_value` (the per-ingress-rule port-set container
24072 // axis-key pin the L3-target selector pairs with under the
24073 // shared per-CNP-body schema) on the sibling per-CNP-body-axis
24074 // pin set — completes the per-CNP L3/L4/L7-triad
24075 // `(endpointSelector, ingress → toPorts → rules)` pin set the
24076 // M3 Aplicacao mesh renderer's eBPF data-plane contract rests
24077 // on.
24078 assert_eq!(CILIUM_KEY_ENDPOINT_SELECTOR, "endpointSelector");
24079 }
24080
24081 #[test]
24082 fn cilium_key_endpoint_selector_carries_lower_camel_case_shape() {
24083 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24084 // lowerCamelCase identifier per the K8s API conventions
24085 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24086 // "Field names should be lowercase camelCase") — first byte
24087 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24088 // kebab-case or whitespace. Pinning the shape here means a
24089 // future rebrand on the canonical lift can't silently land a
24090 // malformed field-name discriminator (snake_case, kebab-case,
24091 // UpperCamelCase, empty) that the apiserver-side CRD schema
24092 // validator would reject far from the rebrand commit's source.
24093 // Peer to `cilium_key_to_ports_carries_lower_camel_case_shape`
24094 // on the sibling per-CNP-body-axis grammar-pin set — the
24095 // lowerCamelCase K8s field-name grammar governs every nested
24096 // schema-field axis (including this per-CNP destination-
24097 // identity-axis key), same convention.
24098 let v = CILIUM_KEY_ENDPOINT_SELECTOR;
24099 assert!(
24100 !v.is_empty(),
24101 "CILIUM_KEY_ENDPOINT_SELECTOR {v:?} must be non-empty per the K8s API \
24102 lowerCamelCase field-name grammar"
24103 );
24104 let first = v.chars().next().expect("non-empty");
24105 assert!(
24106 first.is_ascii_lowercase(),
24107 "CILIUM_KEY_ENDPOINT_SELECTOR {v:?} first byte {first:?} must be \
24108 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24109 grammar (field names are always lowerCamelCase)"
24110 );
24111 assert!(
24112 v.chars().all(|c| c.is_ascii_alphanumeric()),
24113 "CILIUM_KEY_ENDPOINT_SELECTOR {v:?} must be ASCII-alphanumeric \
24114 throughout per the K8s API field-name grammar — no \
24115 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24116 OpenAPI schema validator would reject"
24117 );
24118 }
24119
24120 #[test]
24121 fn cilium_key_ingress_pins_canonical_value() {
24122 // Pin the actual string so a typo in this lift can't silently
24123 // rebrand the Cilium CNP `spec.ingress[]` traffic-direction
24124 // container-axis key the rendered CNP document mounts its
24125 // permitted per-`(:de, :para)` inbound-ingress-rule list under.
24126 // The string is part of the cluster-side contract with the
24127 // upstream Cilium operator — the Cilium-operator-side per-CNP
24128 // L4/L7-dispatch pass keys off this axis to route the per-CNP
24129 // ingress-rule list through the eBPF data-plane's inbound-
24130 // traffic dispatch branch; a drifted value (`"Ingress"` /
24131 // `"ingressRules"` / `"inbound"`) at either the production
24132 // emitter or a downstream renderer's per-CNP traffic-direction
24133 // upsert silently emits a CNP whose ingress-rule list the
24134 // Cilium CRD schema validator drops as unknown, and every
24135 // intra-mesh `:contratos` flow the affected CNP was authored to
24136 // allow drops at the eBPF data-plane's default-deny gate.
24137 // Changing this value is a coordinated Cilium-CRD promotion
24138 // alongside the upstream Cilium project's CRD schema-migration
24139 // cycle, not an incidental edit. Peer to
24140 // `cilium_key_endpoint_selector_pins_canonical_value` (the
24141 // destination-identity axis-key pin the traffic-direction
24142 // container axis-key sits alongside under the shared per-CNP-
24143 // body schema) + `cilium_key_to_ports_pins_canonical_value`
24144 // (the per-ingress-rule port-set container axis-key pin the
24145 // traffic-direction axis nests) on the sibling per-CNP-body-
24146 // axis pin set — completes the per-CNP L3/L4/L7-triad
24147 // `(endpointSelector, ingress → toPorts → rules)` pin set the
24148 // M3 Aplicacao mesh renderer's eBPF data-plane contract rests
24149 // on.
24150 assert_eq!(CILIUM_KEY_INGRESS, "ingress");
24151 }
24152
24153 #[test]
24154 fn cilium_key_ingress_carries_lower_camel_case_shape() {
24155 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24156 // lowerCamelCase identifier per the K8s API conventions
24157 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24158 // "Field names should be lowercase camelCase") — first byte
24159 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24160 // kebab-case or whitespace. Pinning the shape here means a
24161 // future rebrand on the canonical lift can't silently land a
24162 // malformed field-name discriminator (snake_case, kebab-case,
24163 // UpperCamelCase, empty) that the apiserver-side CRD schema
24164 // validator would reject far from the rebrand commit's source.
24165 // Peer to `cilium_key_endpoint_selector_carries_lower_camel_\
24166 // case_shape` / `cilium_key_to_ports_carries_lower_camel_case_\
24167 // shape` on the sibling per-CNP-body-axis grammar-pin set — the
24168 // lowerCamelCase K8s field-name grammar governs every nested
24169 // schema-field axis (including this per-CNP traffic-direction-
24170 // axis key), same convention.
24171 let v = CILIUM_KEY_INGRESS;
24172 assert!(
24173 !v.is_empty(),
24174 "CILIUM_KEY_INGRESS {v:?} must be non-empty per the K8s API \
24175 lowerCamelCase field-name grammar"
24176 );
24177 let first = v.chars().next().expect("non-empty");
24178 assert!(
24179 first.is_ascii_lowercase(),
24180 "CILIUM_KEY_INGRESS {v:?} first byte {first:?} must be \
24181 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24182 grammar (field names are always lowerCamelCase)"
24183 );
24184 assert!(
24185 v.chars().all(|c| c.is_ascii_alphanumeric()),
24186 "CILIUM_KEY_INGRESS {v:?} must be ASCII-alphanumeric \
24187 throughout per the K8s API field-name grammar — no \
24188 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24189 OpenAPI schema validator would reject"
24190 );
24191 }
24192
24193 #[test]
24194 fn cilium_key_from_endpoints_pins_canonical_value() {
24195 // Pin the actual string so a typo in this lift can't silently
24196 // rebrand the Cilium CNP `spec.ingress[].fromEndpoints[]`
24197 // identity-source selector-list-axis key the rendered CNP
24198 // document mounts its permitted-source `LabelSelector` list
24199 // under. The string is part of the cluster-side contract with
24200 // the upstream Cilium operator — the Cilium-operator-side per-
24201 // CNP identity-resolution pass keys off this axis to bind the
24202 // emitted ingress rule against the admitted source workload
24203 // identities via the K8s LabelSelector schema; a drifted value
24204 // (`"fromendpoints"` / `"fromEndPoint"` / `"sourceEndpoints"`)
24205 // at either the production emitter or a downstream renderer's
24206 // per-ingress-rule identity-source upsert silently emits a CNP
24207 // whose per-ingress-rule identity-source axis the Cilium CRD
24208 // schema validator drops as unknown, and the ingress rule
24209 // admits no source pods — every intra-mesh `:contratos` flow
24210 // the affected CNP was authored to allow drops at the eBPF
24211 // data-plane's default-deny gate. Changing this value is a
24212 // coordinated Cilium-CRD promotion alongside the upstream
24213 // Cilium project's CRD schema-migration cycle, not an
24214 // incidental edit. Peer to
24215 // `cilium_key_endpoint_selector_pins_canonical_value` (the
24216 // destination-identity axis-key pin the identity-source axis
24217 // structurally pairs with under the SPIFFE-identity-bound per-
24218 // CNP access-control contract) on the sibling per-CNP identity-
24219 // pair pin set — completes the per-CNP identity-pair
24220 // `(endpointSelector, fromEndpoints)` pin set the M3 Aplicacao
24221 // mesh renderer's eBPF data-plane contract rests on.
24222 assert_eq!(CILIUM_KEY_FROM_ENDPOINTS, "fromEndpoints");
24223 }
24224
24225 #[test]
24226 fn cilium_key_from_endpoints_carries_lower_camel_case_shape() {
24227 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24228 // lowerCamelCase identifier per the K8s API conventions
24229 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24230 // "Field names should be lowercase camelCase") — first byte
24231 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24232 // kebab-case or whitespace. Pinning the shape here means a
24233 // future rebrand on the canonical lift can't silently land a
24234 // malformed field-name discriminator (snake_case, kebab-case,
24235 // UpperCamelCase, empty) that the apiserver-side CRD schema
24236 // validator would reject far from the rebrand commit's source.
24237 // Peer to `cilium_key_endpoint_selector_carries_lower_camel_\
24238 // case_shape` / `cilium_key_ingress_carries_lower_camel_case_\
24239 // shape` / `cilium_key_to_ports_carries_lower_camel_case_shape`
24240 // on the sibling per-CNP-body-axis grammar-pin set — the
24241 // lowerCamelCase K8s field-name grammar governs every nested
24242 // schema-field axis (including this per-ingress-rule identity-
24243 // source-axis key), same convention.
24244 let v = CILIUM_KEY_FROM_ENDPOINTS;
24245 assert!(
24246 !v.is_empty(),
24247 "CILIUM_KEY_FROM_ENDPOINTS {v:?} must be non-empty per the K8s API \
24248 lowerCamelCase field-name grammar"
24249 );
24250 let first = v.chars().next().expect("non-empty");
24251 assert!(
24252 first.is_ascii_lowercase(),
24253 "CILIUM_KEY_FROM_ENDPOINTS {v:?} first byte {first:?} must be \
24254 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24255 grammar (field names are always lowerCamelCase)"
24256 );
24257 assert!(
24258 v.chars().all(|c| c.is_ascii_alphanumeric()),
24259 "CILIUM_KEY_FROM_ENDPOINTS {v:?} must be ASCII-alphanumeric \
24260 throughout per the K8s API field-name grammar — no \
24261 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24262 OpenAPI schema validator would reject"
24263 );
24264 }
24265
24266 #[test]
24267 fn cilium_key_ports_pins_canonical_value() {
24268 // Pin the actual string so a typo in this lift can't silently
24269 // rebrand the Cilium CNP `spec.ingress[].toPorts[].ports[]`
24270 // per-`toPorts[]`-entry L4-port-tuple-list-container-axis key
24271 // the rendered CNP document mounts its per-port-set
24272 // `[{port, protocol}]` list under. The string is part of the
24273 // cluster-side contract with the upstream Cilium operator —
24274 // the Cilium-operator-side per-CNP L4-allow eBPF-program-
24275 // generation pass keys off this axis to source the per-port-set
24276 // `(port, protocol)` tuples the emitted ingress rule admits; a
24277 // drifted value (`"port"` / `"portList"` / `"L4Ports"`) at
24278 // either the production emitter or a downstream renderer's
24279 // per-`toPorts[]`-entry L4-port-tuple-list upsert silently
24280 // emits a per-`toPorts[]` entry whose L4-port-tuple-list-
24281 // container axis the Cilium CRD schema validator drops as
24282 // unknown, and the port-set admits no `(port, protocol)`
24283 // tuple — every intra-mesh `:contratos` flow the affected CNP
24284 // was authored to allow drops at the eBPF data-plane's
24285 // default-deny gate. Changing this value is a coordinated
24286 // Cilium-CRD promotion alongside the upstream Cilium project's
24287 // CRD schema-migration cycle, not an incidental edit. Peer to
24288 // `cilium_key_to_ports_pins_canonical_value` (the outer per-
24289 // ingress-rule port-set-container axis-key pin the L4 port-
24290 // tuple-list-container axis nests inside) on the sibling per-
24291 // CNP-dispatch-axis pin set — completes the per-CNP L4-half
24292 // `(toPorts, ports)` container-pair pin the M3 Aplicacao mesh
24293 // renderer's eBPF data-plane L4-allow contract rests on.
24294 assert_eq!(CILIUM_KEY_PORTS, "ports");
24295 }
24296
24297 #[test]
24298 fn cilium_key_ports_carries_lower_camel_case_shape() {
24299 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24300 // lowerCamelCase identifier per the K8s API conventions
24301 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24302 // "Field names should be lowercase camelCase") — first byte
24303 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24304 // kebab-case or whitespace. Pinning the shape here means a
24305 // future rebrand on the canonical lift can't silently land a
24306 // malformed field-name discriminator (snake_case, kebab-case,
24307 // UpperCamelCase, empty) that the apiserver-side CRD schema
24308 // validator would reject far from the rebrand commit's source.
24309 // Peer to `cilium_key_endpoint_selector_carries_lower_camel_\
24310 // case_shape` / `cilium_key_ingress_carries_lower_camel_case_\
24311 // shape` / `cilium_key_to_ports_carries_lower_camel_case_shape`
24312 // / `cilium_key_from_endpoints_carries_lower_camel_case_shape`
24313 // on the sibling per-CNP-body-axis grammar-pin set — the
24314 // lowerCamelCase K8s field-name grammar governs every nested
24315 // schema-field axis (including this per-`toPorts[]`-entry L4-
24316 // port-tuple-list-container-axis key), same convention.
24317 let v = CILIUM_KEY_PORTS;
24318 assert!(
24319 !v.is_empty(),
24320 "CILIUM_KEY_PORTS {v:?} must be non-empty per the K8s API \
24321 lowerCamelCase field-name grammar"
24322 );
24323 let first = v.chars().next().expect("non-empty");
24324 assert!(
24325 first.is_ascii_lowercase(),
24326 "CILIUM_KEY_PORTS {v:?} first byte {first:?} must be \
24327 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24328 grammar (field names are always lowerCamelCase)"
24329 );
24330 assert!(
24331 v.chars().all(|c| c.is_ascii_alphanumeric()),
24332 "CILIUM_KEY_PORTS {v:?} must be ASCII-alphanumeric \
24333 throughout per the K8s API field-name grammar — no \
24334 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24335 OpenAPI schema validator would reject"
24336 );
24337 }
24338
24339 #[test]
24340 fn cilium_key_authentication_pins_canonical_value() {
24341 // Pin the actual string so a typo in this lift can't silently
24342 // rebrand the Cilium CNP `spec.ingress[].authentication`
24343 // per-ingress-rule mutual-auth-policy body-axis key the
24344 // rendered CNP document mounts its per-rule mTLS enforcement
24345 // block under. The string is part of the cluster-side
24346 // contract with the upstream Cilium operator — the Cilium-
24347 // operator-side per-CNP mutual-auth SPIFFE-handshake pipeline
24348 // keys off this axis to source the per-rule mTLS enforcement
24349 // mode (`required` vs `disabled`); a drifted value (`"auth"`
24350 // / `"mutualAuth"` / `"mtls"` / `"authPolicy"`) at either
24351 // the production emitter or a downstream renderer's per-
24352 // ingress-rule mutual-auth upsert silently emits a per-
24353 // `ingress[]` entry whose mutual-auth-axis the Cilium CRD
24354 // schema validator drops as unknown, and the ingress rule
24355 // falls back to the cluster-default authentication mode
24356 // (typically `"disabled"` — no mutual-auth enforcement)
24357 // silently bypassing the SPIFFE-identity-bound mTLS handshake
24358 // every intra-mesh `:contratos` flow the CNP was authored to
24359 // protect. Changing this value is a coordinated Cilium-CRD
24360 // promotion alongside the upstream Cilium project's CRD
24361 // schema-migration cycle, not an incidental edit. Peer to
24362 // `cilium_key_from_endpoints_pins_canonical_value` /
24363 // `cilium_key_to_ports_pins_canonical_value` (the sibling
24364 // per-ingress-rule-body-axis pins the mutual-auth axis pairs
24365 // with at the per-rule triple
24366 // `(fromEndpoints, toPorts, authentication)`) on the sibling
24367 // per-CNP-dispatch-axis pin set — completes the per-CNP per-
24368 // ingress-rule-body triple the M3 Aplicacao mesh renderer's
24369 // SPIFFE-identity-bound per-edge mTLS contract rests on.
24370 assert_eq!(CILIUM_KEY_AUTHENTICATION, "authentication");
24371 }
24372
24373 #[test]
24374 fn cilium_key_authentication_carries_lower_camel_case_shape() {
24375 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24376 // lowerCamelCase identifier per the K8s API conventions
24377 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24378 // "Field names should be lowercase camelCase") — first byte
24379 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24380 // kebab-case or whitespace. Pinning the shape here means a
24381 // future rebrand on the canonical lift can't silently land a
24382 // malformed field-name discriminator (snake_case, kebab-case,
24383 // UpperCamelCase, empty) that the apiserver-side CRD schema
24384 // validator would reject far from the rebrand commit's source.
24385 // Peer to `cilium_key_endpoint_selector_carries_lower_camel_\
24386 // case_shape` / `cilium_key_ingress_carries_lower_camel_case_\
24387 // shape` / `cilium_key_to_ports_carries_lower_camel_case_shape`
24388 // / `cilium_key_from_endpoints_carries_lower_camel_case_shape`
24389 // / `cilium_key_ports_carries_lower_camel_case_shape` on the
24390 // sibling per-CNP-body-axis grammar-pin set — the
24391 // lowerCamelCase K8s field-name grammar governs every nested
24392 // schema-field axis (including this per-`ingress[]`-entry
24393 // mutual-auth-policy body-axis key), same convention.
24394 let v = CILIUM_KEY_AUTHENTICATION;
24395 assert!(
24396 !v.is_empty(),
24397 "CILIUM_KEY_AUTHENTICATION {v:?} must be non-empty per the K8s API \
24398 lowerCamelCase field-name grammar"
24399 );
24400 let first = v.chars().next().expect("non-empty");
24401 assert!(
24402 first.is_ascii_lowercase(),
24403 "CILIUM_KEY_AUTHENTICATION {v:?} first byte {first:?} must be \
24404 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24405 grammar (field names are always lowerCamelCase)"
24406 );
24407 assert!(
24408 v.chars().all(|c| c.is_ascii_alphanumeric()),
24409 "CILIUM_KEY_AUTHENTICATION {v:?} must be ASCII-alphanumeric \
24410 throughout per the K8s API field-name grammar — no \
24411 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24412 OpenAPI schema validator would reject"
24413 );
24414 }
24415
24416 #[test]
24417 fn cilium_key_mode_pins_canonical_value() {
24418 // Pin the actual string so a typo in this lift can't silently
24419 // rebrand the Cilium CNP `spec.ingress[].authentication.mode`
24420 // per-ingress-rule mutual-auth-mode-discriminator leaf-scalar-
24421 // axis key the rendered CNP document mounts its per-rule mTLS
24422 // enforcement mode value under. The string is part of the
24423 // cluster-side contract with the upstream Cilium operator —
24424 // the Cilium-operator-side per-CNP mutual-auth SPIFFE-handshake
24425 // pipeline reads this leaf axis to source the per-rule mTLS
24426 // enforcement mode value (`"required"` vs `"disabled"`); a
24427 // drifted key (`"policy"` / `"authMode"` / `"handshakeMode"`)
24428 // at either the production emitter or a downstream renderer's
24429 // per-ingress-rule mutual-auth-mode-leaf upsert silently emits
24430 // a per-`ingress[]` entry whose mutual-auth block's mode-
24431 // discriminator leaf-axis the Cilium CRD schema validator
24432 // drops as unknown, and the ingress rule falls back to the
24433 // cluster-default authentication mode (typically `"disabled"`
24434 // — no mutual-auth enforcement) silently bypassing the SPIFFE-
24435 // identity-bound mTLS handshake every intra-mesh `:contratos`
24436 // flow the CNP was authored to protect. Changing this value is
24437 // a coordinated Cilium-CRD promotion alongside the upstream
24438 // Cilium project's CRD schema-migration cycle, not an
24439 // incidental edit. Peer to
24440 // `cilium_key_authentication_pins_canonical_value` on the
24441 // sibling per-ingress-rule mutual-auth body-axis pin set —
24442 // completes the per-rule mutual-auth
24443 // `(authentication → mode)` body/leaf axis pin pair the M3
24444 // Aplicacao mesh renderer's SPIFFE-identity-bound per-edge
24445 // mTLS enforcement contract rests on. Byte-identical to the
24446 // sibling `:politicas :circuit-breaker (:window)` /
24447 // `:placement :estrategia` overlay mode-like axes today, but
24448 // semantically distinct: this const names the Cilium CRD's
24449 // per-authentication-block mode-discriminator leaf-axis key
24450 // (spelled per the Cilium project's CRD schema), so a future
24451 // rebrand on the Cilium CRD's per-authentication-block mode-
24452 // leaf axis lands at its own canonical const without coupling
24453 // the Cilium schema to any peer surface that happens to carry
24454 // the same byte.
24455 assert_eq!(CILIUM_KEY_MODE, "mode");
24456 }
24457
24458 #[test]
24459 fn cilium_key_mode_carries_lower_camel_case_shape() {
24460 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24461 // lowerCamelCase identifier per the K8s API conventions
24462 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24463 // "Field names should be lowercase camelCase") — first byte
24464 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24465 // kebab-case or whitespace. Pinning the shape here means a
24466 // future rebrand on the canonical lift can't silently land a
24467 // malformed field-name discriminator (snake_case, kebab-case,
24468 // UpperCamelCase, empty) that the apiserver-side CRD schema
24469 // validator would reject far from the rebrand commit's source.
24470 // Peer to `cilium_key_authentication_carries_lower_camel_case_\
24471 // shape` on the sibling per-ingress-rule mutual-auth-body-axis
24472 // grammar-pin — the lowerCamelCase K8s field-name grammar
24473 // governs every nested schema-field axis (including this
24474 // per-authentication-block mode-discriminator leaf-axis key),
24475 // same convention.
24476 let v = CILIUM_KEY_MODE;
24477 assert!(
24478 !v.is_empty(),
24479 "CILIUM_KEY_MODE {v:?} must be non-empty per the K8s API \
24480 lowerCamelCase field-name grammar"
24481 );
24482 let first = v.chars().next().expect("non-empty");
24483 assert!(
24484 first.is_ascii_lowercase(),
24485 "CILIUM_KEY_MODE {v:?} first byte {first:?} must be \
24486 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24487 grammar (field names are always lowerCamelCase)"
24488 );
24489 assert!(
24490 v.chars().all(|c| c.is_ascii_alphanumeric()),
24491 "CILIUM_KEY_MODE {v:?} must be ASCII-alphanumeric \
24492 throughout per the K8s API field-name grammar — no \
24493 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24494 OpenAPI schema validator would reject"
24495 );
24496 }
24497
24498 #[test]
24499 fn cilium_key_http_pins_canonical_value() {
24500 // Pin the actual string so a typo in this lift can't silently
24501 // rebrand the Cilium CNP `spec.ingress[].toPorts[].rules.http`
24502 // per-`toPorts[]` L7-HTTP-rule-list-discriminator container-axis
24503 // key the rendered CNP document mounts its per-`toPorts[]` L7
24504 // URL-path-prefix predicate list under. The string is part of the
24505 // cluster-side contract with the upstream Cilium operator — the
24506 // Cilium-operator-side per-CNP L7 dispatch pipeline reads this
24507 // container axis to source the per-`toPorts[]` L7 URL-path-prefix
24508 // predicate list the ingress rule was authored to filter each
24509 // HTTP-shaped `:contratos` flow through; a drifted key (`"HTTP"` /
24510 // `"Http"` / `"httpRules"` / `"httpMatch"`) at either the
24511 // production emitter or a downstream renderer's per-`toPorts[]`
24512 // L7-rule-list-discriminator upsert silently emits a per-
24513 // `toPorts[]` entry whose L7-HTTP-rule-list-discriminator key the
24514 // Cilium CRD schema validator drops as unknown, and the per-
24515 // `toPorts[]` entry falls back to L4-only enforcement — no L7
24516 // URL-path predicate is applied — silently admitting every HTTP-
24517 // method / URL-path combination the ingress rule was authored to
24518 // filter to the exact path prefix set the typed `:contratos`
24519 // graph names at the L7 introspection axis. Changing this value
24520 // is a coordinated Cilium-CRD promotion alongside the upstream
24521 // Cilium project's CRD schema-migration cycle, not an incidental
24522 // edit. Peer to `cilium_key_mode_pins_canonical_value` /
24523 // `cilium_key_authentication_pins_canonical_value` on the
24524 // sibling per-ingress-rule mutual-auth body/leaf axis pin pair —
24525 // completes the per-`toPorts[]` L7-introspection
24526 // `(rules → http)` container/protocol-discriminator axis pin
24527 // pair the M3 Aplicacao mesh renderer's HTTP-shaped-`:contratos`
24528 // URL-path-prefix-filtering L7-enforcement contract rests on.
24529 // Byte-identical to the sibling `Gateway.spec.listeners[].name`
24530 // arbitrary-author-chosen listener-name today (`"http"` — the
24531 // author-chosen name for the substrate's V0 HTTP listener), but
24532 // semantically distinct: this const names the Cilium CRD's per-
24533 // `toPorts[]` L7-HTTP-rule-list-discriminator container-axis key
24534 // (spelled per the Cilium project's CRD schema), so a future
24535 // rebrand on the Cilium CRD's L7-HTTP-rule-list-discriminator
24536 // axis lands at its own canonical const without coupling the
24537 // Cilium schema to any peer surface that happens to carry the
24538 // same byte.
24539 assert_eq!(CILIUM_KEY_HTTP, "http");
24540 }
24541
24542 #[test]
24543 fn cilium_key_http_carries_lower_camel_case_shape() {
24544 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24545 // lowerCamelCase identifier per the K8s API conventions
24546 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24547 // "Field names should be lowercase camelCase") — first byte
24548 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24549 // kebab-case or whitespace. Pinning the shape here means a
24550 // future rebrand on the canonical lift can't silently land a
24551 // malformed field-name discriminator (snake_case, kebab-case,
24552 // UpperCamelCase, empty) that the apiserver-side CRD schema
24553 // validator would reject far from the rebrand commit's source.
24554 // Peer to `cilium_key_mode_carries_lower_camel_case_shape` /
24555 // `cilium_key_authentication_carries_lower_camel_case_shape` on
24556 // the sibling per-ingress-rule mutual-auth-body/leaf-axis
24557 // grammar-pin set — the lowerCamelCase K8s field-name grammar
24558 // governs every nested schema-field axis (including this per-
24559 // `toPorts[]` L7-HTTP-rule-list-discriminator container-axis
24560 // key), same convention.
24561 let v = CILIUM_KEY_HTTP;
24562 assert!(
24563 !v.is_empty(),
24564 "CILIUM_KEY_HTTP {v:?} must be non-empty per the K8s API \
24565 lowerCamelCase field-name grammar"
24566 );
24567 let first = v.chars().next().expect("non-empty");
24568 assert!(
24569 first.is_ascii_lowercase(),
24570 "CILIUM_KEY_HTTP {v:?} first byte {first:?} must be \
24571 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24572 grammar (field names are always lowerCamelCase)"
24573 );
24574 assert!(
24575 v.chars().all(|c| c.is_ascii_alphanumeric()),
24576 "CILIUM_KEY_HTTP {v:?} must be ASCII-alphanumeric \
24577 throughout per the K8s API field-name grammar — no \
24578 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24579 OpenAPI schema validator would reject"
24580 );
24581 }
24582
24583 #[test]
24584 fn kube_key_type_pins_canonical_value() {
24585 // Pin the actual string so a typo in this lift can't silently
24586 // rebrand the K8s discriminated-union `type` scalar-discriminator
24587 // container-axis key every rendered CR mounts its per-position
24588 // discriminated-union type-value under. The string is part of the
24589 // cluster-side contract with every K8s apiserver-side OpenAPI
24590 // schema validator — the Gateway API v1 gateway-class-controller's
24591 // per-`HTTPRouteMatch` path-selection-predicate dispatch pass
24592 // reads this scalar-key to source the path-match-strategy
24593 // discriminator (the closed `PathMatchType` OpenAPI schema enum's
24594 // `{Exact, PathPrefix, RegularExpression}` set) the per-rule L7
24595 // URL-path-filtering was authored to bind — a drifted key
24596 // (`"Type"` / `"kind"` / `"discriminator"` / `"predicate"`) at
24597 // either the production emitter or a downstream renderer's per-
24598 // `HTTPRouteMatch` path-selection-predicate discriminator upsert
24599 // silently emits a per-match entry whose discriminator scalar-key
24600 // the Gateway API v1 `HTTPPathMatch` OpenAPI schema validator
24601 // drops as unknown, and the per-match entry falls back to the
24602 // schema-side default path-match-strategy — silently admitting
24603 // every URL-path prefix the ingress rule was authored to filter
24604 // to the exact predicate the typed `:entrada :paths` slot names
24605 // at the request-path-selection axis. Changing this value is a
24606 // coordinated K8s-API-conventions promotion alongside the
24607 // upstream sig-architecture per-version deprecation cycle, not
24608 // an incidental edit. Peer to
24609 // `cilium_key_http_pins_canonical_value` /
24610 // `cilium_key_mode_pins_canonical_value` /
24611 // `cilium_key_authentication_pins_canonical_value` on the
24612 // sibling per-CRD-body-axis pin set — extends the canonical-
24613 // string-pin discipline from the per-CRD-body-axis surfaces
24614 // onto the load-bearing nested K8s-discriminated-union-type-
24615 // scalar-discriminator axis every downstream apiserver-side
24616 // OpenAPI-schema-validator / gateway-class-controller consumer
24617 // of the rendered mesh bundle keys off before it can commit to
24618 // a per-match request-path-selection predicate.
24619 assert_eq!(KUBE_KEY_TYPE, "type");
24620 }
24621
24622 #[test]
24623 fn kube_key_type_carries_lower_camel_case_shape() {
24624 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24625 // lowerCamelCase identifier per the K8s API conventions
24626 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24627 // "Field names should be lowercase camelCase") — first byte
24628 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24629 // kebab-case or whitespace. Pinning the shape here means a
24630 // future rebrand on the canonical lift can't silently land a
24631 // malformed field-name discriminator (snake_case, kebab-case,
24632 // UpperCamelCase, empty) that the apiserver-side CRD schema
24633 // validator would reject far from the rebrand commit's source.
24634 // Peer to `cilium_key_http_carries_lower_camel_case_shape` /
24635 // `cilium_key_mode_carries_lower_camel_case_shape` /
24636 // `cilium_key_authentication_carries_lower_camel_case_shape` on
24637 // the sibling per-CRD-body-axis grammar-pin set — the
24638 // lowerCamelCase K8s field-name grammar governs every nested
24639 // schema-field axis (including this K8s-discriminated-union-
24640 // type-scalar-discriminator axis), same convention.
24641 let v = KUBE_KEY_TYPE;
24642 assert!(
24643 !v.is_empty(),
24644 "KUBE_KEY_TYPE {v:?} must be non-empty per the K8s API \
24645 lowerCamelCase field-name grammar"
24646 );
24647 let first = v.chars().next().expect("non-empty");
24648 assert!(
24649 first.is_ascii_lowercase(),
24650 "KUBE_KEY_TYPE {v:?} first byte {first:?} must be \
24651 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24652 grammar (field names are always lowerCamelCase)"
24653 );
24654 assert!(
24655 v.chars().all(|c| c.is_ascii_alphanumeric()),
24656 "KUBE_KEY_TYPE {v:?} must be ASCII-alphanumeric \
24657 throughout per the K8s API field-name grammar — no \
24658 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24659 OpenAPI schema validator would reject"
24660 );
24661 }
24662
24663 #[test]
24664 fn gateway_api_kind_gateway_pins_canonical_value() {
24665 // Pin the actual string so a typo in this lift can't silently
24666 // rebrand the Gateway-API-conformant `Gateway` CRD `kind`
24667 // discriminator the rendered Gateway document's top-level
24668 // `kind` axis declares. The string is part of the cluster-side
24669 // contract with every Gateway-API-conformant gateway
24670 // implementation (Cilium, Istio, Envoy Gateway, NGINX) — the
24671 // apiserver-side CRD resolution contract is the
24672 // `(apiVersion, kind)` tuple keyed against the registered
24673 // `CustomResourceDefinition`, so the kind half of the tuple is
24674 // exactly as load-bearing as the sibling
24675 // [`GATEWAY_API_API_VERSION`] apiVersion half. A drifted value
24676 // (e.g. an upstream Gateway-API rebrand to `GatewayV1`) lands
24677 // the rendered document outside the apiserver-side CRD
24678 // registration; changing it is a coordinated Gateway-API
24679 // promotion alongside the upstream SIG-Network deprecation
24680 // cycle, not an incidental edit. Peer to
24681 // `cilium_kind_network_policy_pins_canonical_value` /
24682 // `flux_kind_kustomization_pins_canonical_value` /
24683 // `flux_kind_helm_release_pins_canonical_value` /
24684 // `flux_kind_git_repository_pins_canonical_value` on the
24685 // sibling cluster-side-CRD-`kind`-discriminator pin set —
24686 // extends the canonical-string-pin discipline from the
24687 // Cilium-CRD + Flux v2 controller-triplet `kind`-axis surfaces
24688 // onto the Gateway-API-CRD `kind`-axis surface, beginning the
24689 // per-Gateway-API-CRD kind+apiVersion canonical-pin pair the
24690 // M3 Aplicacao mesh renderer's external `:entrada` ingress
24691 // contract rests on.
24692 assert_eq!(GATEWAY_API_KIND_GATEWAY, "Gateway");
24693 }
24694
24695 #[test]
24696 fn gateway_api_kind_gateway_carries_upper_camel_case_shape() {
24697 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
24698 // an UpperCamelCase identifier per the K8s API conventions
24699 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
24700 // "Kinds are always UpperCamelCase"). Pinning the shape here
24701 // means a future rebrand on the canonical lift can't silently
24702 // land a malformed kind discriminator (snake_case, kebab-case,
24703 // lowercase, empty) that every downstream YAML-aware
24704 // deserializer would reject far from the rebrand commit's
24705 // source. The first-byte uppercase / rest-ASCII-alphanumeric
24706 // invariant is the load-bearing K8s API typed-discovery
24707 // contract: a value the apiserver's `RESTMapper` consults to
24708 // resolve the CRD's `RESTKind`. Peer to
24709 // `cilium_kind_network_policy_carries_upper_camel_case_shape` /
24710 // `flux_kind_kustomization_carries_upper_camel_case_shape` /
24711 // `flux_kind_helm_release_carries_upper_camel_case_shape` /
24712 // `flux_kind_git_repository_carries_upper_camel_case_shape` on
24713 // the sibling cluster-side-CRD-`kind`-discriminator surface.
24714 let v = GATEWAY_API_KIND_GATEWAY;
24715 assert!(
24716 !v.is_empty(),
24717 "GATEWAY_API_KIND_GATEWAY {v:?} must be non-empty per the K8s API \
24718 UpperCamelCase kind discriminator grammar"
24719 );
24720 let first = v.chars().next().expect("non-empty");
24721 assert!(
24722 first.is_ascii_uppercase(),
24723 "GATEWAY_API_KIND_GATEWAY {v:?} first byte {first:?} must be \
24724 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
24725 grammar (Kinds are always UpperCamelCase)"
24726 );
24727 assert!(
24728 v.chars().all(|c| c.is_ascii_alphanumeric()),
24729 "GATEWAY_API_KIND_GATEWAY {v:?} must be ASCII-alphanumeric \
24730 throughout per the K8s API kind discriminator grammar — no \
24731 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24732 RESTMapper would reject"
24733 );
24734 }
24735
24736 #[test]
24737 fn gateway_api_kind_http_route_pins_canonical_value() {
24738 // Pin the actual string so a typo in this lift can't silently
24739 // rebrand the Gateway-API-conformant `HTTPRoute` CRD `kind`
24740 // discriminator the rendered HTTPRoute document's top-level
24741 // `kind` axis declares. The string is part of the cluster-side
24742 // contract with every Gateway-API-conformant gateway
24743 // implementation (Cilium, Istio, Envoy Gateway, NGINX) — the
24744 // apiserver-side CRD resolution contract is the
24745 // `(apiVersion, kind)` tuple keyed against the registered
24746 // `CustomResourceDefinition`, so the kind half of the tuple is
24747 // exactly as load-bearing as the sibling
24748 // [`GATEWAY_API_API_VERSION`] apiVersion half. A drifted value
24749 // (e.g. an upstream Gateway-API rebrand to `HTTPRouteV1`) lands
24750 // the rendered document outside the apiserver-side CRD
24751 // registration; changing it is a coordinated Gateway-API
24752 // promotion alongside the upstream SIG-Network deprecation
24753 // cycle, not an incidental edit. Peer to
24754 // `gateway_api_kind_gateway_pins_canonical_value` /
24755 // `cilium_kind_network_policy_pins_canonical_value` /
24756 // `flux_kind_kustomization_pins_canonical_value` /
24757 // `flux_kind_helm_release_pins_canonical_value` /
24758 // `flux_kind_git_repository_pins_canonical_value` on the
24759 // sibling cluster-side-CRD-`kind`-discriminator pin set —
24760 // completes the per-Gateway-API-CRD `kind`-axis canonical-pin
24761 // pair across the `(Gateway, HTTPRoute)` pair the renderer's
24762 // `gateway_routes` external `:entrada` ingress contract emits
24763 // together.
24764 assert_eq!(GATEWAY_API_KIND_HTTP_ROUTE, "HTTPRoute");
24765 }
24766
24767 #[test]
24768 fn gateway_api_kind_http_route_carries_upper_camel_case_shape() {
24769 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
24770 // an UpperCamelCase identifier per the K8s API conventions
24771 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
24772 // "Kinds are always UpperCamelCase"). Acronyms like HTTP stay
24773 // ASCII-uppercase across the prefix per the same convention
24774 // (the K8s API Kinds for `HTTPRoute`, `TCPRoute`, `TLSRoute`,
24775 // `GRPCRoute` carry the full-uppercase protocol acronym).
24776 // Pinning the shape here means a future rebrand on the
24777 // canonical lift can't silently land a malformed kind
24778 // discriminator (snake_case, kebab-case, lowercase, empty)
24779 // that every downstream YAML-aware deserializer would reject
24780 // far from the rebrand commit's source. The first-byte
24781 // uppercase / rest-ASCII-alphanumeric invariant is the
24782 // load-bearing K8s API typed-discovery contract: a value the
24783 // apiserver's `RESTMapper` consults to resolve the CRD's
24784 // `RESTKind`. Peer to
24785 // `gateway_api_kind_gateway_carries_upper_camel_case_shape` /
24786 // `cilium_kind_network_policy_carries_upper_camel_case_shape` /
24787 // `flux_kind_kustomization_carries_upper_camel_case_shape` /
24788 // `flux_kind_helm_release_carries_upper_camel_case_shape` /
24789 // `flux_kind_git_repository_carries_upper_camel_case_shape` on
24790 // the sibling cluster-side-CRD-`kind`-discriminator surface.
24791 let v = GATEWAY_API_KIND_HTTP_ROUTE;
24792 assert!(
24793 !v.is_empty(),
24794 "GATEWAY_API_KIND_HTTP_ROUTE {v:?} must be non-empty per the K8s API \
24795 UpperCamelCase kind discriminator grammar"
24796 );
24797 let first = v.chars().next().expect("non-empty");
24798 assert!(
24799 first.is_ascii_uppercase(),
24800 "GATEWAY_API_KIND_HTTP_ROUTE {v:?} first byte {first:?} must be \
24801 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
24802 grammar (Kinds are always UpperCamelCase)"
24803 );
24804 assert!(
24805 v.chars().all(|c| c.is_ascii_alphanumeric()),
24806 "GATEWAY_API_KIND_HTTP_ROUTE {v:?} must be ASCII-alphanumeric \
24807 throughout per the K8s API kind discriminator grammar — no \
24808 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24809 RESTMapper would reject"
24810 );
24811 }
24812
24813 #[test]
24814 fn gateway_api_protocol_http_pins_canonical_value() {
24815 // Pin the actual string so a typo in this lift can't silently
24816 // rebrand the Gateway API v1 `ProtocolType` OpenAPI schema enum's
24817 // canonical `HTTP` listener-protocol value the rendered
24818 // `Gateway.spec.listeners[].protocol` scalar declares. The value
24819 // is part of the cluster-side contract with every Gateway-API-
24820 // conformant gateway implementation (Cilium, Istio, Envoy
24821 // Gateway, NGINX) — the gateway-class-controller's per-listener
24822 // bind loop keys off this exact byte-sequence to select the L7
24823 // parser + TLS termination strategy; the Gateway API v1
24824 // `ProtocolType` OpenAPI schema enum admits the closed set
24825 // `{"HTTP", "HTTPS", "TCP", "TLS", "UDP"}` verbatim, so a
24826 // drifted value (`"http"` / `"Http"` / `"HTTP/1.1"` / `"http/1.1"`)
24827 // lands the rendered `Gateway` outside the `ProtocolType` enum's
24828 // admitted set and every external `:entrada` HTTP flow drops at
24829 // the gateway-class-controller's admission gate. Changing this
24830 // value is a coordinated Gateway API `ProtocolType` promotion
24831 // alongside the upstream SIG-Network deprecation cycle, not an
24832 // incidental edit. Peer to
24833 // `gateway_api_kind_gateway_pins_canonical_value` /
24834 // `gateway_api_kind_http_route_pins_canonical_value` /
24835 // `default_gateway_class_name_pins_canonical_value` on the
24836 // sibling Gateway-API-CRD-`kind`-discriminator + Gateway-
24837 // controller-binding-scalar-value pin set — extends the pair
24838 // of `kind`-axis canonical-value pins across the
24839 // `(Gateway, HTTPRoute)` pair onto the sibling per-Gateway
24840 // `spec.listeners[].protocol` listener-protocol-scalar-value axis
24841 // the same `gateway_routes` external `:entrada` ingress emitter
24842 // carries.
24843 assert_eq!(GATEWAY_API_PROTOCOL_HTTP, "HTTP");
24844 }
24845
24846 #[test]
24847 fn gateway_api_protocol_http_carries_upper_case_shape() {
24848 // Cross-axis invariant: the Gateway API v1 `ProtocolType` OpenAPI
24849 // schema enum admits the closed set
24850 // `{"HTTP", "HTTPS", "TCP", "TLS", "UDP"}` — every admitted value
24851 // is ASCII-uppercase throughout per the upstream SIG-Network
24852 // Gateway API convention (see
24853 // https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.ProtocolType
24854 // — the admitted values are the transport / application-layer
24855 // protocol acronyms in their canonical uppercase form). Pinning
24856 // the shape here means a future rebrand on the canonical lift
24857 // can't silently land a malformed listener-protocol scalar
24858 // (lowercase `"http"`, mixed-case `"Http"`, dotted `"HTTP/1.1"`,
24859 // empty) that the K8s Gateway API v1 `ProtocolType` OpenAPI
24860 // schema enum would reject at admission time far from the
24861 // rebrand commit's source. The all-ASCII-uppercase invariant is
24862 // the load-bearing Gateway-API-implementation-side typed
24863 // listener-parser-selection contract: a value the gateway-
24864 // class-controller's per-listener bind loop selects the L7
24865 // parser + TLS termination strategy from.
24866 let v = GATEWAY_API_PROTOCOL_HTTP;
24867 assert!(
24868 !v.is_empty(),
24869 "GATEWAY_API_PROTOCOL_HTTP {v:?} must be non-empty per the \
24870 Gateway API v1 `ProtocolType` OpenAPI schema enum grammar"
24871 );
24872 assert!(
24873 v.chars().all(|c| c.is_ascii_uppercase()),
24874 "GATEWAY_API_PROTOCOL_HTTP {v:?} must be ASCII-uppercase \
24875 throughout per the Gateway API v1 `ProtocolType` OpenAPI \
24876 schema enum convention — no lowercase, mixed-case, dotted, \
24877 or whitespace bytes the gateway-class-controller's per-\
24878 listener bind loop would reject"
24879 );
24880 }
24881
24882 #[test]
24883 fn gateway_api_path_match_type_path_prefix_pins_canonical_value() {
24884 // Pin the actual string so a typo in this lift can't silently
24885 // rebrand the Gateway API v1 `PathMatchType` OpenAPI schema
24886 // enum's canonical `PathPrefix` per-`HTTPRouteMatch` path-
24887 // selection-predicate discriminator value the rendered
24888 // `HTTPRoute.spec.rules[].matches[].path.type` scalar declares.
24889 // The value is part of the cluster-side contract with every
24890 // Gateway-API-conformant gateway implementation (Cilium, Istio,
24891 // Envoy Gateway, NGINX) — the gateway-class-controller's
24892 // per-rule L7 dispatch loop keys off this exact byte-sequence
24893 // to select the request-path-selection predicate; the Gateway
24894 // API v1 `PathMatchType` OpenAPI schema enum admits the closed
24895 // set `{"Exact", "PathPrefix", "RegularExpression"}` verbatim,
24896 // so a drifted value (`"pathPrefix"` / `"path_prefix"` /
24897 // `"Prefix"` / `"path-prefix"`) lands the rendered `HTTPRoute`
24898 // outside the `PathMatchType` enum's admitted set and every
24899 // external `:entrada` path-filtered flow drops at the gateway-
24900 // class-controller's admission gate. Changing this value is a
24901 // coordinated Gateway API `PathMatchType` promotion alongside
24902 // the upstream SIG-Network deprecation cycle, not an incidental
24903 // edit. Peer to
24904 // `gateway_api_protocol_http_pins_canonical_value` /
24905 // `gateway_api_kind_gateway_pins_canonical_value` /
24906 // `gateway_api_kind_http_route_pins_canonical_value` /
24907 // `default_gateway_class_name_pins_canonical_value` on the
24908 // sibling Gateway-API-v1-OpenAPI-schema-enum-value +
24909 // Gateway-API-CRD-`kind`-discriminator + Gateway-controller-
24910 // binding-scalar-value pin set — extends the canonical-
24911 // Gateway-API-v1-OpenAPI-schema-enum-value single-sourcing
24912 // discipline the `ProtocolType.HTTP` pin established onto the
24913 // sibling `PathMatchType.PathPrefix` per-`HTTPRouteMatch`
24914 // path-selection-predicate discriminator the same
24915 // `gateway_routes` external `:entrada` ingress emitter carries
24916 // under the shared `HTTPRoute` body.
24917 assert_eq!(GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX, "PathPrefix");
24918 }
24919
24920 #[test]
24921 fn gateway_api_path_match_type_path_prefix_carries_upper_camel_case_shape() {
24922 // Cross-axis invariant: the Gateway API v1 `PathMatchType`
24923 // OpenAPI schema enum admits the closed set
24924 // `{"Exact", "PathPrefix", "RegularExpression"}` — every
24925 // admitted value is UpperCamelCase per the upstream SIG-Network
24926 // Gateway API convention (see
24927 // https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.PathMatchType
24928 // — the admitted values are the request-path-selection
24929 // predicate names in their canonical UpperCamelCase form,
24930 // matching the K8s API `Kinds are always UpperCamelCase`
24931 // convention the sibling `GATEWAY_API_KIND_*` discriminators
24932 // carry on the CRD-`kind`-axis surface). Pinning the shape
24933 // here means a future rebrand on the canonical lift can't
24934 // silently land a malformed path-match-type scalar (lowercase
24935 // `"pathprefix"`, snake_case `"path_prefix"`, kebab-case
24936 // `"path-prefix"`, empty) that the K8s Gateway API v1
24937 // `PathMatchType` OpenAPI schema enum would reject at
24938 // admission time far from the rebrand commit's source. The
24939 // first-byte uppercase / rest-ASCII-alphanumeric invariant is
24940 // the load-bearing Gateway-API-implementation-side typed
24941 // per-match request-path-selection-predicate-selection
24942 // contract: a value the gateway-class-controller's per-rule
24943 // L7 dispatch loop selects the request-path-predicate
24944 // evaluator from. Peer to
24945 // `gateway_api_kind_gateway_carries_upper_camel_case_shape` /
24946 // `gateway_api_kind_http_route_carries_upper_camel_case_shape`
24947 // on the sibling cluster-side-CRD-`kind`-discriminator
24948 // UpperCamelCase pin set — extends the canonical-K8s-API-
24949 // UpperCamelCase-typed-discriminator pin discipline the
24950 // `Kind` axis carries onto the sibling Gateway API v1
24951 // `PathMatchType` OpenAPI schema enum's per-value
24952 // UpperCamelCase surface (distinct from the sibling
24953 // Gateway API v1 `ProtocolType` OpenAPI schema enum's all-
24954 // ASCII-uppercase per-value convention the
24955 // `gateway_api_protocol_http_carries_upper_case_shape` pin
24956 // carries — the two peer Gateway-API-v1 OpenAPI schema
24957 // enum-value conventions do not collapse).
24958 let v = GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX;
24959 assert!(
24960 !v.is_empty(),
24961 "GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX {v:?} must be non-empty per \
24962 the Gateway API v1 `PathMatchType` OpenAPI schema enum grammar"
24963 );
24964 let first = v.chars().next().expect("non-empty");
24965 assert!(
24966 first.is_ascii_uppercase(),
24967 "GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX {v:?} first byte {first:?} \
24968 must be ASCII-uppercase per the Gateway API v1 `PathMatchType` \
24969 OpenAPI schema enum UpperCamelCase convention"
24970 );
24971 assert!(
24972 v.chars().all(|c| c.is_ascii_alphanumeric()),
24973 "GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX {v:?} must be ASCII-\
24974 alphanumeric throughout per the Gateway API v1 `PathMatchType` \
24975 OpenAPI schema enum UpperCamelCase convention — no snake_case, \
24976 kebab-case, or whitespace bytes the gateway-class-controller's \
24977 per-rule L7 dispatch loop would reject"
24978 );
24979 }
24980
24981 #[test]
24982 fn kube_protocol_tcp_pins_canonical_value() {
24983 // Pin the actual string so a typo in this lift can't silently
24984 // rebrand the K8s core `Protocol` OpenAPI schema enum's
24985 // canonical `TCP` L4-transport-protocol scalar value the
24986 // rendered `CiliumNetworkPolicy.spec.ingress[].toPorts[].ports[]
24987 // .protocol` scalar declares. The value is part of the cluster-
24988 // side contract with every K8s-core-`Protocol`-conformant CNI
24989 // + kube-proxy + eBPF-data-plane implementation (Cilium,
24990 // Calico, kube-proxy iptables/ipvs) — the CNI's per-CNP L4
24991 // dispatch pass keys off this exact byte-sequence to select
24992 // the per-tuple L4-transport-protocol predicate; the K8s core
24993 // `Protocol` OpenAPI schema enum admits the closed set
24994 // `{"TCP", "UDP", "SCTP"}` verbatim (see
24995 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1/#protocol-v1-core),
24996 // so a drifted value (`"tcp"` / `"Tcp"` / `"TCP/IP"` /
24997 // `"transport-tcp"`) lands the rendered `CiliumNetworkPolicy`
24998 // outside the `Protocol` enum's admitted set and every intra-
24999 // mesh `:contratos` L4-tuple-gated flow drops at the Cilium
25000 // operator's admission gate. Changing this value is a
25001 // coordinated K8s core `Protocol` promotion alongside the
25002 // upstream SIG-Network deprecation cycle, not an incidental
25003 // edit. Peer to
25004 // `gateway_api_protocol_http_pins_canonical_value` /
25005 // `gateway_api_path_match_type_path_prefix_pins_canonical_value`
25006 // on the sibling Gateway-API-v1-OpenAPI-schema-enum-value pin
25007 // set — extends the canonical-cluster-side-OpenAPI-schema-enum-
25008 // value single-sourcing discipline the Gateway-API v1
25009 // `ProtocolType.HTTP` / `PathMatchType.PathPrefix` pins
25010 // established onto the sibling K8s-core `Protocol.TCP` per-port-
25011 // tuple L4-transport-protocol-discriminator the
25012 // `cilium_network_policies` intra-mesh L4-tuple-gating emitter
25013 // carries under the shared `CiliumNetworkPolicy` body.
25014 assert_eq!(KUBE_PROTOCOL_TCP, "TCP");
25015 }
25016
25017 #[test]
25018 fn kube_protocol_tcp_carries_upper_case_shape() {
25019 // Cross-axis invariant: the K8s core `Protocol` OpenAPI schema
25020 // enum admits the closed set `{"TCP", "UDP", "SCTP"}` — every
25021 // admitted value is ASCII-uppercase throughout per the upstream
25022 // SIG-Network convention (the admitted values are the L4-
25023 // transport-protocol acronyms in their canonical uppercase form,
25024 // matching the sibling Gateway-API v1 `ProtocolType` OpenAPI
25025 // schema enum's `{"HTTP", "HTTPS", "TCP", "TLS", "UDP"}` all-
25026 // ASCII-uppercase convention the
25027 // `gateway_api_protocol_http_carries_upper_case_shape` pin
25028 // carries on the peer per-listener L7-parser-selection scalar
25029 // axis). Pinning the shape here means a future rebrand on the
25030 // canonical lift can't silently land a malformed L4-transport-
25031 // protocol scalar (lowercase `"tcp"`, mixed-case `"Tcp"`,
25032 // dotted `"TCP/IP"`, empty) that the K8s core `Protocol`
25033 // OpenAPI schema enum would reject at admission time far from
25034 // the rebrand commit's source. The all-ASCII-uppercase
25035 // invariant is the load-bearing K8s-core-`Protocol`-enum-side
25036 // typed L4-transport-selection contract: a value the CNI's per-
25037 // CNP L4 dispatch pass selects the per-tuple L4-transport-
25038 // protocol predicate from. Peer to
25039 // `gateway_api_protocol_http_carries_upper_case_shape` on the
25040 // sibling Gateway-API v1 `ProtocolType` OpenAPI schema enum's
25041 // all-ASCII-uppercase per-value convention pin set — the two
25042 // peer canonical-cluster-side-OpenAPI-schema-enum-value
25043 // uppercase conventions collapse on the shared `TCP` transport-
25044 // protocol acronym both `Protocol` enums admit at the closed-
25045 // set intersection.
25046 let v = KUBE_PROTOCOL_TCP;
25047 assert!(
25048 !v.is_empty(),
25049 "KUBE_PROTOCOL_TCP {v:?} must be non-empty per the K8s core \
25050 `Protocol` OpenAPI schema enum grammar"
25051 );
25052 assert!(
25053 v.chars().all(|c| c.is_ascii_uppercase()),
25054 "KUBE_PROTOCOL_TCP {v:?} must be ASCII-uppercase throughout \
25055 per the K8s core `Protocol` OpenAPI schema enum convention \
25056 — no lowercase, mixed-case, dotted, or whitespace bytes the \
25057 CNI's per-CNP L4 dispatch pass would reject"
25058 );
25059 }
25060
25061 #[test]
25062 fn cilium_auth_mode_required_pins_canonical_value() {
25063 // Pin the actual string so a typo in this lift can't silently
25064 // rebrand the Cilium `CiliumNetworkPolicy` `MutualAuthenticationMode`
25065 // OpenAPI schema enum's `required` mTLS-mandatory scalar-value the
25066 // rendered CNP's `spec.ingress[].authentication.mode` leaf declares
25067 // under the `:mtls-required t` affirmative arm of the typed
25068 // `:politicas :mtls-required` tristate. The value is part of the
25069 // cluster-side contract with the Cilium-agent-side per-rule mutual-
25070 // auth-block schema validator — the agent's per-rule dispatch loop
25071 // keys off this exact byte-sequence to select the SPIFFE-identity-
25072 // handshake-mandatory enforcement policy; the Cilium CNP
25073 // `MutualAuthenticationMode` OpenAPI schema enum admits the closed
25074 // set `{"required", "disabled", "test-always-fail"}` verbatim (the
25075 // `test-always-fail` arm is a Cilium-side debugging surface, not
25076 // author-reachable), so a drifted value (`"Required"` /
25077 // `"REQUIRED"` / `"mandatory"` / `"mtls-required"`) lands the
25078 // rendered `CiliumNetworkPolicy` outside the
25079 // `MutualAuthenticationMode` enum's admitted set and every intra-
25080 // mesh `:contratos` flow the CNP was authored to protect with per-
25081 // edge SPIFFE-identity-bound mutual-auth silently bypasses the
25082 // handshake at the Cilium data-plane's default-authentication mode
25083 // (typically also "disabled" today, but environment-divergent —
25084 // take effect) with no field naming the mTLS-mandatory-scalar-value-
25085 // drift root cause. Changing this value is a coordinated Cilium
25086 // CNP `MutualAuthenticationMode` promotion alongside the Cilium
25087 // project's periodic CRD schema-migration passes, not an
25088 // incidental edit. Peer to
25089 // `gateway_api_protocol_http_pins_canonical_value` /
25090 // `gateway_api_path_match_type_path_prefix_pins_canonical_value` /
25091 // `kube_protocol_tcp_pins_canonical_value` on the sibling
25092 // canonical-cluster-side-OpenAPI-schema-enum-value pin set —
25093 // extends the canonical-cluster-side-OpenAPI-schema-enum-value
25094 // single-sourcing discipline the Gateway-API v1 `ProtocolType.HTTP`
25095 // / `PathMatchType.PathPrefix` / K8s-core `Protocol.TCP` pins
25096 // established onto the sibling Cilium-CNP-side
25097 // `MutualAuthenticationMode.required` per-rule mTLS-mandatory
25098 // scalar-value the `cilium_network_policies` per-edge SPIFFE-
25099 // identity-bound mutual-auth emitter carries under the shared
25100 // `CiliumNetworkPolicy` body.
25101 assert_eq!(CILIUM_AUTH_MODE_REQUIRED, "required");
25102 }
25103
25104 #[test]
25105 fn cilium_auth_mode_disabled_pins_canonical_value() {
25106 // Peer to `cilium_auth_mode_required_pins_canonical_value` on the
25107 // `Some(false)` opt-out arm of the same
25108 // `MutualAuthenticationMode` OpenAPI schema enum: pin the actual
25109 // string so a typo can't silently rebrand the Cilium `disabled`
25110 // mTLS-skipped scalar-value the rendered CNP's per-rule authn-
25111 // block declares under the explicit `:mtls-required nil` opt-out
25112 // (distinct from the `None` slot-absent arm the renderer maps to
25113 // omit-the-block-entirely). A drifted value (`"Disabled"` /
25114 // `"DISABLED"` / `"off"` / `"skip"`) lands outside the
25115 // `MutualAuthenticationMode` OpenAPI schema enum's admitted set;
25116 // the author's explicit-opt-out intent silently collapses onto the
25117 // cluster-default authentication mode with no field naming the
25118 // mTLS-skipped-scalar-value-drift root cause. Peer to
25119 // `cilium_auth_mode_required_pins_canonical_value` on the
25120 // affirmative arm of the same enum — completes the per-authn-block
25121 // `(mode → {required, disabled})` author-reachable-scalar-value-
25122 // pair single-sourcing the M3 Aplicacao mesh renderer's SPIFFE-
25123 // identity-bound per-edge mTLS enforcement + explicit-opt-out
25124 // contract rests on across the two arms of the `:politicas
25125 // :mtls-required` tristate.
25126 assert_eq!(CILIUM_AUTH_MODE_DISABLED, "disabled");
25127 }
25128
25129 #[test]
25130 fn cilium_auth_modes_carry_lower_case_shape() {
25131 // Cross-axis invariant: the Cilium CNP `MutualAuthenticationMode`
25132 // OpenAPI schema enum admits the closed set `{"required",
25133 // "disabled", "test-always-fail"}` — every admitted value is
25134 // ASCII-lowercase throughout per the Cilium-project convention
25135 // (distinct from the sibling K8s-core `Protocol.TCP` /
25136 // Gateway-API-v1 `ProtocolType.HTTP` all-ASCII-uppercase
25137 // convention the `kube_protocol_tcp_carries_upper_case_shape` /
25138 // `gateway_api_protocol_http_carries_upper_case_shape` pins carry
25139 // on the sibling per-listener L7-parser-selection scalar axis, and
25140 // distinct from the sibling Gateway-API-v1
25141 // `PathMatchType.PathPrefix` UpperCamelCase convention the
25142 // `gateway_api_path_match_type_path_prefix_carries_upper_camel_case_shape`
25143 // pin carries on the sibling per-match request-path-selection
25144 // scalar axis — the Cilium CNP `MutualAuthenticationMode` enum
25145 // grammar does not collapse with either sibling cluster-side
25146 // OpenAPI schema enum's per-value casing convention). Pinning the
25147 // shape here means a future rebrand on either lifted value can't
25148 // silently land a malformed mode-discriminator scalar (uppercase
25149 // `"REQUIRED"` / `"DISABLED"`, UpperCamelCase `"Required"` /
25150 // `"Disabled"`, mixed-case, whitespace) that the Cilium CNP
25151 // `MutualAuthenticationMode` OpenAPI schema enum would reject at
25152 // admission time far from the rebrand commit's source.
25153 for v in [CILIUM_AUTH_MODE_REQUIRED, CILIUM_AUTH_MODE_DISABLED] {
25154 assert!(
25155 !v.is_empty(),
25156 "{v:?} must be non-empty per the Cilium CNP \
25157 `MutualAuthenticationMode` OpenAPI schema enum grammar"
25158 );
25159 assert!(
25160 v.chars().all(|c| c.is_ascii_lowercase()),
25161 "{v:?} must be ASCII-lowercase throughout per the Cilium \
25162 CNP `MutualAuthenticationMode` OpenAPI schema enum \
25163 convention — no uppercase, UpperCamelCase, or whitespace \
25164 bytes the Cilium-agent-side per-rule mutual-auth-block \
25165 schema validator would reject"
25166 );
25167 }
25168 }
25169
25170 #[test]
25171 fn cilium_auth_modes_are_distinct() {
25172 // Pin the `MutualAuthenticationMode` enum's per-arm distinctness
25173 // at type-check time: the two author-reachable arms of the typed
25174 // `:politicas :mtls-required` tristate must not collapse onto the
25175 // same scalar-value byte-sequence. A future rebrand that landed
25176 // both lifted constants on the same string (e.g. both `"required"`
25177 // through a copy-paste typo, or both aliased through a shared
25178 // helper) would silently erase the tristate's affirmative /
25179 // explicit-opt-out distinction at the emit boundary — the
25180 // renderer would emit the same scalar under both the `Some(true)`
25181 // and `Some(false)` arms of the closure the
25182 // `single_field_overlay(spec.politicas.mtls_required,
25183 // CILIUM_KEY_MODE, |required| …)` call site carries, collapsing
25184 // the two author intents onto a single Cilium-side enforcement
25185 // policy with no field naming the collapse root cause. Peer to
25186 // the two `cilium_auth_mode_{required,disabled}_pins_canonical_
25187 // value` per-arm pins — completes the per-arm distinctness pin
25188 // set on the closed author-reachable subset of the enum.
25189 assert_ne!(
25190 CILIUM_AUTH_MODE_REQUIRED, CILIUM_AUTH_MODE_DISABLED,
25191 "the two author-reachable arms of the `:mtls-required` \
25192 tristate must land distinct `MutualAuthenticationMode` \
25193 scalar-values"
25194 );
25195 }
25196
25197 #[test]
25198 fn cilium_auth_mode_bijection_dispatches_tristate_arms_onto_scalar_values() {
25199 // Pin the `bool → &'static str` projection every consumer of the
25200 // Cilium `MutualAuthenticationMode` closed-set enum's author-
25201 // reachable scalar-value pair reaches through: `true` (the
25202 // `Some(true)` mTLS-mandatory arm of the typed `:politicas
25203 // :mtls-required` tristate) maps to [`CILIUM_AUTH_MODE_REQUIRED`],
25204 // `false` (the `Some(false)` explicit-opt-out arm) maps to
25205 // [`CILIUM_AUTH_MODE_DISABLED`]. One projection body, both arms of
25206 // the tristate's non-`None` value-space, so a future per-arm
25207 // reassignment (e.g. an upstream Cilium v3 schema swap of the
25208 // `required` ↔ `disabled` scalars, or a per-arm renaming of the
25209 // mTLS-mandatory scalar from `required` to `enforced` / `strict`
25210 // / `mandatory`) lands at the two consts + this projection body
25211 // — not at the caixa-mesh production emitter's closure body and
25212 // the caixa-core `single_field_overlay_threads_typed_value_
25213 // through_closure` generic-helper pin's closure body independently.
25214 // Pin the per-arm round-trip so a future refactor that inverts
25215 // the bool → arm mapping (or collapses one arm) surfaces here
25216 // rather than silently letting a Cilium data-plane pod either
25217 // enforce mTLS where the author asked for skip or skip it where
25218 // the author asked for enforce.
25219 assert_eq!(cilium_auth_mode(true), CILIUM_AUTH_MODE_REQUIRED);
25220 assert_eq!(cilium_auth_mode(false), CILIUM_AUTH_MODE_DISABLED);
25221 // The two arms cover distinct value-space entries — a regression
25222 // that collapses them onto the same scalar surfaces here. Peer
25223 // to `cilium_auth_modes_are_distinct` (the per-arm distinctness
25224 // pin at the const-declaration axis) — this test extends the
25225 // pin onto the projection body axis, so both the raw consts and
25226 // the projection's per-arm dispatch preserve the tristate's
25227 // author-intent distinction end-to-end.
25228 assert_ne!(
25229 cilium_auth_mode(true),
25230 cilium_auth_mode(false),
25231 "cilium_auth_mode must project the two tristate arms onto \
25232 distinct `MutualAuthenticationMode` value-space entries — \
25233 a collapsed-arm regression would silently render both \
25234 `:mtls-required t` and `:mtls-required nil` identically at \
25235 the cluster artifact",
25236 );
25237 }
25238
25239 #[test]
25240 fn gateway_api_key_parent_refs_pins_canonical_value() {
25241 // Pin the actual string so a typo in this lift can't silently
25242 // rebrand the Gateway API `HTTPRoute` parent-Gateway-binding
25243 // container-axis key the rendered HTTPRoute document mounts its
25244 // per-route `[{name}]` parent-Gateway attachment list under. The
25245 // string is part of the cluster-side contract with every
25246 // Gateway-API-conformant gateway implementation (Cilium, Istio,
25247 // Envoy Gateway, NGINX) — the Gateway-API-implementation-side
25248 // per-HTTPRoute reconcile loop keys off this axis to source the
25249 // per-route parent-Gateway attachment list the route is bound
25250 // to; a drifted value (`"parentRef"` / `"parents"` /
25251 // `"parentGateways"`) at either the production emitter or a
25252 // downstream renderer's per-HTTPRoute parent-Gateway-binding
25253 // upsert silently emits an `HTTPRoute` whose parent-Gateway-
25254 // binding axis the Gateway API CRD schema validator drops as
25255 // unknown — the route lands unattached to any Gateway, and
25256 // every external `:entrada` flow the HTTPRoute was authored to
25257 // accept drops at the Gateway API implementation's per-Gateway
25258 // HTTP-listener fan-in with no field naming the parent-Gateway-
25259 // binding-drift root cause. Changing this value is a
25260 // coordinated Gateway API promotion alongside the upstream
25261 // SIG-Network Gateway API deprecation cycle, not an incidental
25262 // edit. Peer to `cilium_key_ports_pins_canonical_value` /
25263 // `cilium_key_from_endpoints_pins_canonical_value` /
25264 // `cilium_key_endpoint_selector_pins_canonical_value` /
25265 // `cilium_key_ingress_pins_canonical_value` /
25266 // `cilium_key_to_ports_pins_canonical_value` on the sibling
25267 // per-CNP-body-axis pin set — begins the per-Gateway-API-
25268 // HTTPRoute-body-axis canonical-string-pin set (`parentRefs`,
25269 // future `hostnames`) the M3 Aplicacao mesh renderer's external
25270 // `:entrada` ingress contract rests on across the Gateway API
25271 // HTTPRoute-side per-route body-shape.
25272 assert_eq!(GATEWAY_API_KEY_PARENT_REFS, "parentRefs");
25273 }
25274
25275 #[test]
25276 fn gateway_api_key_parent_refs_carries_lower_camel_case_shape() {
25277 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25278 // lowerCamelCase identifier per the K8s API conventions
25279 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25280 // "Field names should be lowercase camelCase") — first byte
25281 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25282 // kebab-case or whitespace. Pinning the shape here means a
25283 // future rebrand on the canonical lift can't silently land a
25284 // malformed field-name discriminator (snake_case, kebab-case,
25285 // UpperCamelCase, empty) that the apiserver-side CRD schema
25286 // validator would reject far from the rebrand commit's source.
25287 // Peer to `cilium_key_ports_carries_lower_camel_case_shape` /
25288 // `cilium_key_from_endpoints_carries_lower_camel_case_shape` /
25289 // `cilium_key_endpoint_selector_carries_lower_camel_case_shape`
25290 // / `cilium_key_ingress_carries_lower_camel_case_shape` /
25291 // `cilium_key_to_ports_carries_lower_camel_case_shape` on the
25292 // sibling per-CNP-body-axis grammar-pin set — the lowerCamelCase
25293 // K8s field-name grammar governs every nested schema-field axis
25294 // (including this per-HTTPRoute parent-Gateway-binding-
25295 // container-axis key), same convention.
25296 let v = GATEWAY_API_KEY_PARENT_REFS;
25297 assert!(
25298 !v.is_empty(),
25299 "GATEWAY_API_KEY_PARENT_REFS {v:?} must be non-empty per the K8s API \
25300 lowerCamelCase field-name grammar"
25301 );
25302 let first = v.chars().next().expect("non-empty");
25303 assert!(
25304 first.is_ascii_lowercase(),
25305 "GATEWAY_API_KEY_PARENT_REFS {v:?} first byte {first:?} must be \
25306 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25307 grammar (field names are always lowerCamelCase)"
25308 );
25309 assert!(
25310 v.chars().all(|c| c.is_ascii_alphanumeric()),
25311 "GATEWAY_API_KEY_PARENT_REFS {v:?} must be ASCII-alphanumeric \
25312 throughout per the K8s API field-name grammar — no \
25313 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25314 OpenAPI schema validator would reject"
25315 );
25316 }
25317
25318 #[test]
25319 fn gateway_api_key_backend_refs_pins_canonical_value() {
25320 // Pin the actual string so a typo in this lift can't silently
25321 // rebrand the Gateway API `HTTPRoute` per-rule backend-destination
25322 // container-axis key the rendered HTTPRoute document mounts its
25323 // per-rule `[{name, port}]` backend fan-out list under. The
25324 // string is part of the cluster-side contract with every
25325 // Gateway-API-conformant gateway implementation (Cilium, Istio,
25326 // Envoy Gateway, NGINX) — the Gateway-API-implementation-side
25327 // per-rule L7 dispatch loop keys off this axis to source the
25328 // per-rule backend list the request is forwarded to; a drifted
25329 // value (`"backendRef"` / `"backends"` / `"forwardTo"`) at
25330 // either the production emitter or a downstream renderer's
25331 // per-rule backend-destination upsert silently emits an
25332 // `HTTPRoute` whose per-rule backend fan-out axis the Gateway
25333 // API CRD schema validator drops as unknown — no backend is
25334 // picked at the per-rule L7 dispatch, and every external
25335 // `:entrada` request the rule was authored to route drops at
25336 // the gateway-class-controller's per-rule reconcile with no
25337 // field naming the backend-destination-drift root cause.
25338 // Changing this value is a coordinated Gateway API promotion
25339 // alongside the upstream SIG-Network Gateway API deprecation
25340 // cycle, not an incidental edit. Peer to
25341 // `gateway_api_key_parent_refs_pins_canonical_value` on the
25342 // sibling per-HTTPRoute-body-axis canonical-string-pin surface
25343 // — extends the per-Gateway-API-HTTPRoute-body-axis pin set
25344 // (`parentRefs`, `backendRefs`, future `hostnames`) the M3
25345 // Aplicacao mesh renderer's external `:entrada` ingress
25346 // contract rests on across the Gateway API HTTPRoute-side per-
25347 // route body-shape.
25348 assert_eq!(GATEWAY_API_KEY_BACKEND_REFS, "backendRefs");
25349 }
25350
25351 #[test]
25352 fn gateway_api_key_backend_refs_carries_lower_camel_case_shape() {
25353 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25354 // lowerCamelCase identifier per the K8s API conventions
25355 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25356 // "Field names should be lowercase camelCase") — first byte
25357 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25358 // kebab-case or whitespace. Pinning the shape here means a
25359 // future rebrand on the canonical lift can't silently land a
25360 // malformed field-name discriminator (snake_case, kebab-case,
25361 // UpperCamelCase, empty) that the apiserver-side CRD schema
25362 // validator would reject far from the rebrand commit's source.
25363 // Peer to `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
25364 // on the sibling per-HTTPRoute-body-axis grammar-pin surface —
25365 // the lowerCamelCase K8s field-name grammar governs every
25366 // nested schema-field axis (including this per-rule backend-
25367 // destination-container-axis key), same convention.
25368 let v = GATEWAY_API_KEY_BACKEND_REFS;
25369 assert!(
25370 !v.is_empty(),
25371 "GATEWAY_API_KEY_BACKEND_REFS {v:?} must be non-empty per the K8s API \
25372 lowerCamelCase field-name grammar"
25373 );
25374 let first = v.chars().next().expect("non-empty");
25375 assert!(
25376 first.is_ascii_lowercase(),
25377 "GATEWAY_API_KEY_BACKEND_REFS {v:?} first byte {first:?} must be \
25378 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25379 grammar (field names are always lowerCamelCase)"
25380 );
25381 assert!(
25382 v.chars().all(|c| c.is_ascii_alphanumeric()),
25383 "GATEWAY_API_KEY_BACKEND_REFS {v:?} must be ASCII-alphanumeric \
25384 throughout per the K8s API field-name grammar — no \
25385 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25386 OpenAPI schema validator would reject"
25387 );
25388 }
25389
25390 #[test]
25391 fn gateway_api_key_matches_pins_canonical_value() {
25392 // Pin the actual string so a typo in this lift can't silently
25393 // rebrand the Gateway API `HTTPRoute` per-rule route-match
25394 // container-axis key the rendered HTTPRoute document mounts
25395 // its per-rule `[{path: {type, value}}]` route-match fan-out
25396 // list under. The string is part of the cluster-side contract
25397 // with every Gateway-API-conformant gateway implementation
25398 // (Cilium, Istio, Envoy Gateway, NGINX) — the Gateway-API-
25399 // implementation-side per-rule L7 dispatch loop keys off this
25400 // axis to source the per-rule request-selection predicate the
25401 // incoming request line + headers + query must satisfy for
25402 // the rule's backend fan-out to apply; a drifted value
25403 // (`"match"` / `"routeMatches"` / `"predicates"`) at either
25404 // the production emitter or a downstream renderer's per-rule
25405 // route-match upsert silently emits an `HTTPRoute` whose per-
25406 // rule request-selection axis the Gateway API CRD schema
25407 // validator drops as unknown — the per-rule predicate
25408 // degrades to the wildcard match at the gateway-class-
25409 // controller's per-rule reconcile, the rule matches every
25410 // request unconditionally, and every external `:entrada` path
25411 // filter the rule was authored to enforce drops with no field
25412 // naming the route-match-drift root cause. Changing this
25413 // value is a coordinated Gateway API promotion alongside the
25414 // upstream SIG-Network Gateway API deprecation cycle, not an
25415 // incidental edit. Peer to
25416 // `gateway_api_key_backend_refs_pins_canonical_value` /
25417 // `gateway_api_key_parent_refs_pins_canonical_value` on the
25418 // sibling per-HTTPRoute-body-axis canonical-string-pin
25419 // surface — completes the per-rule top-level-axis pin set
25420 // (`matches`, `backendRefs`, `timeouts`, `retry`) the M3
25421 // Aplicacao mesh renderer's external `:entrada` ingress
25422 // contract rests on across the Gateway API HTTPRoute per-rule
25423 // body-shape.
25424 assert_eq!(GATEWAY_API_KEY_MATCHES, "matches");
25425 }
25426
25427 #[test]
25428 fn gateway_api_key_matches_carries_lower_camel_case_shape() {
25429 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25430 // lowerCamelCase identifier per the K8s API conventions
25431 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25432 // "Field names should be lowercase camelCase") — first byte
25433 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25434 // kebab-case or whitespace. Pinning the shape here means a
25435 // future rebrand on the canonical lift can't silently land a
25436 // malformed field-name discriminator (snake_case, kebab-case,
25437 // UpperCamelCase, empty) that the apiserver-side CRD schema
25438 // validator would reject far from the rebrand commit's source.
25439 // Peer to `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
25440 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
25441 // on the sibling per-HTTPRoute-body-axis grammar-pin surface —
25442 // the lowerCamelCase K8s field-name grammar governs every
25443 // nested schema-field axis (including this per-rule route-
25444 // match-container-axis key), same convention.
25445 let v = GATEWAY_API_KEY_MATCHES;
25446 assert!(
25447 !v.is_empty(),
25448 "GATEWAY_API_KEY_MATCHES {v:?} must be non-empty per the K8s API \
25449 lowerCamelCase field-name grammar"
25450 );
25451 let first = v.chars().next().expect("non-empty");
25452 assert!(
25453 first.is_ascii_lowercase(),
25454 "GATEWAY_API_KEY_MATCHES {v:?} first byte {first:?} must be \
25455 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25456 grammar (field names are always lowerCamelCase)"
25457 );
25458 assert!(
25459 v.chars().all(|c| c.is_ascii_alphanumeric()),
25460 "GATEWAY_API_KEY_MATCHES {v:?} must be ASCII-alphanumeric \
25461 throughout per the K8s API field-name grammar — no \
25462 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25463 OpenAPI schema validator would reject"
25464 );
25465 }
25466
25467 #[test]
25468 fn gateway_api_key_gateway_class_name_pins_canonical_value() {
25469 // Pin the actual string so a typo in this lift can't silently
25470 // rebrand the Gateway API `Gateway` per-Gateway controller-
25471 // binding scalar-axis key the rendered Gateway document
25472 // mounts its per-Gateway `GatewayClass.metadata.name`
25473 // reference under. The string is part of the cluster-side
25474 // contract with every Gateway-API-conformant gateway
25475 // implementation (Cilium, Istio, Envoy Gateway, NGINX) —
25476 // the Gateway-API-implementation-side per-Gateway reconcile
25477 // loop keys off this axis to source the `GatewayClass`
25478 // reference the per-Gateway controller-name-lookup dispatch
25479 // resolves; a drifted value (`"gatewayClass"` /
25480 // `"className"` / `"gatewayClassRef"`) at the production
25481 // emitter silently emits a `Gateway` whose controller-binding
25482 // scalar-axis the Gateway API CRD schema validator drops as
25483 // unknown — no `GatewayClass` is resolved, no `controllerName`
25484 // is looked up, and every external `:entrada` flow the
25485 // Gateway was authored to accept drops at the gateway-class-
25486 // controller's per-Gateway reconcile with no field naming
25487 // the controller-binding-drift root cause. Changing this
25488 // value is a coordinated Gateway API promotion alongside
25489 // the upstream SIG-Network Gateway API deprecation cycle,
25490 // not an incidental edit. Peer to
25491 // `gateway_api_key_listeners_pins_canonical_value` /
25492 // `gateway_api_key_hostname_pins_canonical_value` on the
25493 // sibling per-Gateway-body-axis canonical-string-pin
25494 // surface — completes the per-Gateway-body-axis top-level-
25495 // axis pin set (`gatewayClassName`, `listeners`) the M3
25496 // Aplicacao mesh renderer's external `:entrada` ingress
25497 // contract rests on. Sibling of the peer
25498 // `default_gateway_class_name_pins_canonical_value` on the
25499 // canonical-Gateway-API-`(key, value)`-pair-lift surface
25500 // this lift closes the KEY half of.
25501 assert_eq!(GATEWAY_API_KEY_GATEWAY_CLASS_NAME, "gatewayClassName");
25502 }
25503
25504 #[test]
25505 fn gateway_api_key_gateway_class_name_carries_lower_camel_case_shape() {
25506 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25507 // lowerCamelCase identifier per the K8s API conventions
25508 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25509 // "Field names should be lowercase camelCase") — first byte
25510 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25511 // kebab-case or whitespace. Pinning the shape here means a
25512 // future rebrand on the canonical lift can't silently land a
25513 // malformed field-name discriminator (snake_case, kebab-case,
25514 // UpperCamelCase, empty) that the apiserver-side CRD schema
25515 // validator would reject far from the rebrand commit's source.
25516 // Peer to `gateway_api_key_listeners_carries_lower_camel_case_shape`
25517 // / `gateway_api_key_matches_carries_lower_camel_case_shape`
25518 // on the sibling per-Gateway / per-HTTPRoute-body-axis
25519 // grammar-pin surface — the lowerCamelCase K8s field-name
25520 // grammar governs every nested schema-field axis (including
25521 // this per-Gateway controller-binding scalar-axis key), same
25522 // convention.
25523 let v = GATEWAY_API_KEY_GATEWAY_CLASS_NAME;
25524 assert!(
25525 !v.is_empty(),
25526 "GATEWAY_API_KEY_GATEWAY_CLASS_NAME {v:?} must be non-empty per the K8s API \
25527 lowerCamelCase field-name grammar"
25528 );
25529 let first = v.chars().next().expect("non-empty");
25530 assert!(
25531 first.is_ascii_lowercase(),
25532 "GATEWAY_API_KEY_GATEWAY_CLASS_NAME {v:?} first byte {first:?} must be \
25533 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25534 grammar (field names are always lowerCamelCase)"
25535 );
25536 assert!(
25537 v.chars().all(|c| c.is_ascii_alphanumeric()),
25538 "GATEWAY_API_KEY_GATEWAY_CLASS_NAME {v:?} must be ASCII-alphanumeric \
25539 throughout per the K8s API field-name grammar — no \
25540 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25541 OpenAPI schema validator would reject"
25542 );
25543 }
25544
25545 #[test]
25546 fn gateway_api_key_path_pins_canonical_value() {
25547 // Pin the actual string so a typo in this lift can't silently
25548 // rebrand the Gateway API `HTTPRoute` per-`HTTPRouteMatch`
25549 // path-matcher container-axis key the rendered HTTPRoute
25550 // document mounts its per-match `{type, value}` path-selection
25551 // predicate under. The string is part of the cluster-side
25552 // contract with every Gateway-API-conformant gateway
25553 // implementation (Cilium, Istio, Envoy Gateway, NGINX) — the
25554 // Gateway-API-implementation-side per-rule L7 dispatch loop
25555 // keys off this axis to source the per-match request-path-
25556 // selection predicate the incoming request line's `:path`
25557 // pseudo-header must satisfy under a `type` discriminator of
25558 // `Exact | PathPrefix | RegularExpression`; a drifted value
25559 // (`"pathMatch"` / `"prefix"` / `"url"`) at the production
25560 // emitter silently emits an `HTTPRoute` whose per-match path-
25561 // selection axis the Gateway API CRD schema validator drops
25562 // as unknown — the per-match path predicate degrades to the
25563 // wildcard match at the gateway-class-controller's per-rule
25564 // reconcile, the rule matches every request path
25565 // unconditionally, and every external `:entrada` path filter
25566 // the rule was authored to enforce drops with no field
25567 // naming the path-matcher-drift root cause. Changing this
25568 // value is a coordinated Gateway API promotion alongside the
25569 // upstream SIG-Network Gateway API deprecation cycle, not an
25570 // incidental edit. Peer to
25571 // `gateway_api_key_matches_pins_canonical_value` /
25572 // `gateway_api_key_backend_refs_pins_canonical_value` on the
25573 // sibling per-HTTPRoute-body-axis canonical-string-pin
25574 // surface — nests the per-Gateway-API-HTTPRoute-per-rule-
25575 // body-axis pin set (`matches`, `backendRefs`, `timeouts`,
25576 // `retry`) one level deeper onto the per-`HTTPRouteMatch`
25577 // body-axis surface the M3 Aplicacao mesh renderer's external
25578 // `:entrada` ingress contract rests on.
25579 assert_eq!(GATEWAY_API_KEY_PATH, "path");
25580 }
25581
25582 #[test]
25583 fn gateway_api_key_path_carries_lower_camel_case_shape() {
25584 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25585 // lowerCamelCase identifier per the K8s API conventions
25586 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25587 // "Field names should be lowercase camelCase") — first byte
25588 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25589 // kebab-case or whitespace. Pinning the shape here means a
25590 // future rebrand on the canonical lift can't silently land a
25591 // malformed field-name discriminator (snake_case, kebab-case,
25592 // UpperCamelCase, empty) that the apiserver-side CRD schema
25593 // validator would reject far from the rebrand commit's source.
25594 // Peer to `gateway_api_key_matches_carries_lower_camel_case_shape`
25595 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
25596 // on the sibling per-HTTPRoute-body-axis grammar-pin surface —
25597 // the lowerCamelCase K8s field-name grammar governs every
25598 // nested schema-field axis (including this per-`HTTPRouteMatch`
25599 // path-matcher-container-axis key), same convention.
25600 let v = GATEWAY_API_KEY_PATH;
25601 assert!(
25602 !v.is_empty(),
25603 "GATEWAY_API_KEY_PATH {v:?} must be non-empty per the K8s API \
25604 lowerCamelCase field-name grammar"
25605 );
25606 let first = v.chars().next().expect("non-empty");
25607 assert!(
25608 first.is_ascii_lowercase(),
25609 "GATEWAY_API_KEY_PATH {v:?} first byte {first:?} must be \
25610 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25611 grammar (field names are always lowerCamelCase)"
25612 );
25613 assert!(
25614 v.chars().all(|c| c.is_ascii_alphanumeric()),
25615 "GATEWAY_API_KEY_PATH {v:?} must be ASCII-alphanumeric \
25616 throughout per the K8s API field-name grammar — no \
25617 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25618 OpenAPI schema validator would reject"
25619 );
25620 }
25621
25622 #[test]
25623 fn gateway_api_key_value_pins_canonical_value() {
25624 // Pin the actual string so a typo in this lift can't silently
25625 // rebrand the Gateway API `HTTPPathMatch` scalar-payload axis
25626 // key the rendered `HTTPRoute` document mounts its per-match
25627 // request-path-selection scalar payload under. The string is
25628 // part of the cluster-side contract with every Gateway-API-
25629 // conformant gateway implementation (Cilium, Istio, Envoy
25630 // Gateway, NGINX) — the Gateway-API-implementation-side per-
25631 // rule L7 dispatch loop keys off this axis to source the
25632 // per-match request-path string that the sibling `type`
25633 // discriminator (Exact | PathPrefix | RegularExpression) is
25634 // applied against; a drifted value (`"path"` / `"prefix"` /
25635 // `"pattern"` / `"expression"`) at the production emitter
25636 // silently emits an `HTTPRoute` whose per-match request-path
25637 // scalar the Gateway API CRD schema validator drops as
25638 // unknown — the per-match path predicate degrades to the
25639 // wildcard match at the gateway-class-controller's per-rule
25640 // reconcile, the rule matches every request path
25641 // unconditionally, and every external `:entrada` path filter
25642 // the rule was authored to enforce drops with no field
25643 // naming the `HTTPPathMatch`-scalar-payload-drift root cause.
25644 // Changing this value is a coordinated Gateway API promotion
25645 // alongside the upstream SIG-Network Gateway API deprecation
25646 // cycle, not an incidental edit. Peer to
25647 // `gateway_api_key_path_pins_canonical_value` on the sibling
25648 // per-`HTTPRouteMatch`-body-axis canonical-string-pin surface
25649 // — nests the per-Gateway-API-HTTPRoute-per-match-body-axis
25650 // pin set (`path` container-axis, `value` scalar-payload key)
25651 // one level deeper onto the per-`HTTPPathMatch` body-axis
25652 // surface the M3 Aplicacao mesh renderer's external `:entrada`
25653 // ingress contract rests on.
25654 assert_eq!(GATEWAY_API_KEY_VALUE, "value");
25655 }
25656
25657 #[test]
25658 fn gateway_api_key_value_carries_lower_camel_case_shape() {
25659 // Cross-axis invariant: a Kubernetes CRD schema field name is
25660 // a lowerCamelCase identifier per the K8s API conventions
25661 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25662 // "Field names should be lowercase camelCase") — first byte
25663 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25664 // kebab-case or whitespace. Pinning the shape here means a
25665 // future rebrand on the canonical lift can't silently land a
25666 // malformed field-name discriminator (snake_case, kebab-case,
25667 // UpperCamelCase, empty) that the apiserver-side CRD schema
25668 // validator would reject far from the rebrand commit's source.
25669 // Peer to `gateway_api_key_path_carries_lower_camel_case_shape`
25670 // on the sibling per-`HTTPRouteMatch`-body-axis grammar-pin
25671 // surface — the lowerCamelCase K8s field-name grammar governs
25672 // every nested schema-field axis (including this per-
25673 // `HTTPPathMatch` scalar-payload-axis key), same convention.
25674 let v = GATEWAY_API_KEY_VALUE;
25675 assert!(
25676 !v.is_empty(),
25677 "GATEWAY_API_KEY_VALUE {v:?} must be non-empty per the K8s API \
25678 lowerCamelCase field-name grammar"
25679 );
25680 let first = v.chars().next().expect("non-empty");
25681 assert!(
25682 first.is_ascii_lowercase(),
25683 "GATEWAY_API_KEY_VALUE {v:?} first byte {first:?} must be \
25684 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25685 grammar (field names are always lowerCamelCase)"
25686 );
25687 assert!(
25688 v.chars().all(|c| c.is_ascii_alphanumeric()),
25689 "GATEWAY_API_KEY_VALUE {v:?} must be ASCII-alphanumeric \
25690 throughout per the K8s API field-name grammar — no \
25691 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25692 OpenAPI schema validator would reject"
25693 );
25694 }
25695
25696 #[test]
25697 fn gateway_api_key_value_distinct_from_gateway_api_key_path() {
25698 // Cross-axis invariant: the `HTTPPathMatch` scalar-payload key
25699 // (`value`) and its parent-container-axis key (`path`) name
25700 // *distinct* Gateway-API-side schema fields — the parent is a
25701 // container that hangs off the per-`HTTPRouteMatch`
25702 // `matches[]` entry, the child is the scalar payload that
25703 // rides inside the parent's `{type, value}` two-axis body.
25704 // Under the sibling K8s API conventions grammar
25705 // (`gateway_api_key_value_carries_lower_camel_case_shape` /
25706 // `gateway_api_key_path_carries_lower_camel_case_shape`) both
25707 // are ASCII-lowerCamelCase identifiers, so a same-shape
25708 // grammar-pin alone doesn't prevent a future rebrand from
25709 // silently collapsing the two axes onto the same string —
25710 // pinning inequality here surfaces that footgun at exactly
25711 // this build-time lift instead of at apply time as an
25712 // `HTTPRoute` whose per-match `path` container-body is
25713 // structurally malformed (`{path: <str>, path: <str>}` — the
25714 // apiserver's OpenAPI schema validator drops the whole match
25715 // block, the per-match path predicate degrades to the
25716 // wildcard match at the gateway-class-controller's per-rule
25717 // reconcile, the rule matches every request path
25718 // unconditionally, and every external `:entrada` path filter
25719 // the rule was authored to enforce drops with no field
25720 // naming the container/scalar-collapse root cause).
25721 assert_ne!(
25722 GATEWAY_API_KEY_VALUE, GATEWAY_API_KEY_PATH,
25723 "GATEWAY_API_KEY_VALUE ({GATEWAY_API_KEY_VALUE:?}) must not \
25724 collapse onto GATEWAY_API_KEY_PATH ({GATEWAY_API_KEY_PATH:?}) \
25725 — the two name distinct Gateway API `HTTPPathMatch` axes \
25726 (parent container vs. inner scalar payload) that must \
25727 remain independently addressable in the emitted \
25728 `HTTPRoute` per-match body"
25729 );
25730 }
25731
25732 #[test]
25733 fn gateway_api_key_listeners_pins_canonical_value() {
25734 // Pin the actual string so a typo in this lift can't silently
25735 // rebrand the Gateway API `Gateway` per-listener-set container-
25736 // axis key the rendered Gateway document mounts its per-Gateway
25737 // `[{name, port, protocol, hostname}]` L7-listener fan-out list
25738 // under. The string is part of the cluster-side contract with
25739 // every Gateway-API-conformant gateway implementation (Cilium,
25740 // Istio, Envoy Gateway, NGINX) — the Gateway-API-implementation-
25741 // side per-Gateway reconcile loop keys off this axis to source
25742 // the per-Gateway L7-listener fan-out the external `:entrada`
25743 // flow the Gateway was authored to accept lands on; a drifted
25744 // value (`"listener"` / `"listen"` / `"servers"`) at either the
25745 // production emitter or a downstream renderer's per-Gateway L7-
25746 // listener-set upsert silently emits a `Gateway` whose L7-
25747 // listener-set axis the Gateway API CRD schema validator drops
25748 // as unknown — no listener is opened, and every external
25749 // `:entrada` flow drops at the gateway-class-controller's per-
25750 // Gateway reconcile with no field naming the L7-listener-set-
25751 // drift root cause. Changing this value is a coordinated
25752 // Gateway API promotion alongside the upstream SIG-Network
25753 // Gateway API deprecation cycle, not an incidental edit. Peer
25754 // to `gateway_api_key_parent_refs_pins_canonical_value` /
25755 // `gateway_api_key_backend_refs_pins_canonical_value` on the
25756 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
25757 // surface — extends the per-Gateway-API-CRD-body-axis pin set
25758 // (`parentRefs`, `backendRefs`, `listeners`, future
25759 // `hostnames`) the M3 Aplicacao mesh renderer's external
25760 // `:entrada` ingress contract rests on across the Gateway API
25761 // CRD-side body-shape.
25762 assert_eq!(GATEWAY_API_KEY_LISTENERS, "listeners");
25763 }
25764
25765 #[test]
25766 fn gateway_api_key_listeners_carries_lower_camel_case_shape() {
25767 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25768 // lowerCamelCase identifier per the K8s API conventions
25769 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25770 // "Field names should be lowercase camelCase") — first byte
25771 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25772 // kebab-case or whitespace. Pinning the shape here means a
25773 // future rebrand on the canonical lift can't silently land a
25774 // malformed field-name discriminator (snake_case, kebab-case,
25775 // UpperCamelCase, empty) that the apiserver-side CRD schema
25776 // validator would reject far from the rebrand commit's source.
25777 // Peer to `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
25778 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
25779 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
25780 // surface — the lowerCamelCase K8s field-name grammar governs
25781 // every nested schema-field axis (including this per-Gateway
25782 // L7-listener-set-container-axis key), same convention.
25783 let v = GATEWAY_API_KEY_LISTENERS;
25784 assert!(
25785 !v.is_empty(),
25786 "GATEWAY_API_KEY_LISTENERS {v:?} must be non-empty per the K8s API \
25787 lowerCamelCase field-name grammar"
25788 );
25789 let first = v.chars().next().expect("non-empty");
25790 assert!(
25791 first.is_ascii_lowercase(),
25792 "GATEWAY_API_KEY_LISTENERS {v:?} first byte {first:?} must be \
25793 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25794 grammar (field names are always lowerCamelCase)"
25795 );
25796 assert!(
25797 v.chars().all(|c| c.is_ascii_alphanumeric()),
25798 "GATEWAY_API_KEY_LISTENERS {v:?} must be ASCII-alphanumeric \
25799 throughout per the K8s API field-name grammar — no \
25800 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25801 OpenAPI schema validator would reject"
25802 );
25803 }
25804
25805 #[test]
25806 fn gateway_api_key_hostname_pins_canonical_value() {
25807 // Pin the actual string so a typo in this lift can't silently
25808 // rebrand the Gateway API `Gateway` per-listener DNS-host-
25809 // discriminator axis key the rendered Gateway document mounts
25810 // each listener's virtual-host filter under. The string is part
25811 // of the cluster-side contract with every Gateway-API-conformant
25812 // gateway implementation (Cilium, Istio, Envoy Gateway, NGINX) —
25813 // the Gateway-API-implementation-side per-listener SNI /
25814 // `Host:`-header dispatch loop keys off this axis to source the
25815 // per-listener virtual-host filter each listener's inbound
25816 // traffic is scoped against; a drifted value (`"host"` /
25817 // `"vhost"` / `"serverName"`) at either the production emitter
25818 // or a downstream renderer's per-listener DNS-host-discriminator
25819 // upsert silently emits a `Gateway` whose per-listener virtual-
25820 // host filter axis the Gateway API CRD schema validator drops as
25821 // unknown — the listener accepts traffic on the wildcard host
25822 // rather than the typed `:entrada :host` the Aplicacao author
25823 // declared, and every external `:entrada` flow the listener was
25824 // authored to accept lands on the wrong virtual-host filter with
25825 // no field naming the DNS-host-discriminator-drift root cause.
25826 // Changing this value is a coordinated Gateway API promotion
25827 // alongside the upstream SIG-Network Gateway API deprecation
25828 // cycle, not an incidental edit. Peer to
25829 // `gateway_api_key_listeners_pins_canonical_value` /
25830 // `gateway_api_key_parent_refs_pins_canonical_value` /
25831 // `gateway_api_key_backend_refs_pins_canonical_value` on the
25832 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
25833 // surface — nests the per-Gateway-API-CRD-body-axis pin
25834 // discipline one level deeper onto the sibling per-listener
25835 // body-axis surface, extending the per-Gateway-API-CRD-body-
25836 // axis pin set (`parentRefs`, `backendRefs`, `listeners`,
25837 // `hostname`, future `hostnames`) the M3 Aplicacao mesh
25838 // renderer's external `:entrada` ingress contract rests on
25839 // across the Gateway API CRD-side body-shape.
25840 assert_eq!(GATEWAY_API_KEY_HOSTNAME, "hostname");
25841 }
25842
25843 #[test]
25844 fn gateway_api_key_hostname_carries_lower_camel_case_shape() {
25845 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25846 // lowerCamelCase identifier per the K8s API conventions
25847 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25848 // "Field names should be lowercase camelCase") — first byte
25849 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25850 // kebab-case or whitespace. Pinning the shape here means a
25851 // future rebrand on the canonical lift can't silently land a
25852 // malformed field-name discriminator (snake_case, kebab-case,
25853 // UpperCamelCase, empty) that the apiserver-side CRD schema
25854 // validator would reject far from the rebrand commit's source.
25855 // Peer to `gateway_api_key_listeners_carries_lower_camel_case_shape`
25856 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
25857 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
25858 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
25859 // surface — the lowerCamelCase K8s field-name grammar governs
25860 // every nested schema-field axis (including this per-listener
25861 // DNS-host-discriminator-axis key), same convention.
25862 let v = GATEWAY_API_KEY_HOSTNAME;
25863 assert!(
25864 !v.is_empty(),
25865 "GATEWAY_API_KEY_HOSTNAME {v:?} must be non-empty per the K8s API \
25866 lowerCamelCase field-name grammar"
25867 );
25868 let first = v.chars().next().expect("non-empty");
25869 assert!(
25870 first.is_ascii_lowercase(),
25871 "GATEWAY_API_KEY_HOSTNAME {v:?} first byte {first:?} must be \
25872 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25873 grammar (field names are always lowerCamelCase)"
25874 );
25875 assert!(
25876 v.chars().all(|c| c.is_ascii_alphanumeric()),
25877 "GATEWAY_API_KEY_HOSTNAME {v:?} must be ASCII-alphanumeric \
25878 throughout per the K8s API field-name grammar — no \
25879 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25880 OpenAPI schema validator would reject"
25881 );
25882 }
25883
25884 #[test]
25885 fn gateway_api_key_hostnames_pins_canonical_value() {
25886 // Pin the actual string so a typo in this lift can't silently
25887 // rebrand the Gateway API `HTTPRoute` spec-level DNS-host-filter
25888 // axis key the rendered HTTPRoute document mounts each route's
25889 // per-route virtual-host filter list under. The string is part
25890 // of the cluster-side contract with every Gateway-API-conformant
25891 // gateway implementation (Cilium, Istio, Envoy Gateway, NGINX) —
25892 // the Gateway-API-implementation-side per-route SNI /
25893 // `Host:`-header dispatch loop keys off this axis to source the
25894 // per-route virtual-host filter list each route's inbound
25895 // traffic is scoped against; a drifted value (`"hosts"` /
25896 // `"vhosts"` / `"serverNames"`) at either the production emitter
25897 // or a downstream renderer's per-route DNS-host-filter upsert
25898 // silently emits an `HTTPRoute` whose per-route virtual-host
25899 // filter axis the Gateway API CRD schema validator drops as
25900 // unknown — the route accepts traffic on every host the parent
25901 // Gateway's listener accepts rather than the typed `:entrada
25902 // :host` the Aplicacao author declared, and every external
25903 // `:entrada` flow the route was authored to accept lands on the
25904 // wildcard virtual-host filter with no field naming the DNS-
25905 // host-filter-drift root cause. Changing this value is a
25906 // coordinated Gateway API promotion alongside the upstream
25907 // SIG-Network Gateway API deprecation cycle, not an incidental
25908 // edit. Peer to
25909 // `gateway_api_key_hostname_pins_canonical_value` /
25910 // `gateway_api_key_listeners_pins_canonical_value` /
25911 // `gateway_api_key_parent_refs_pins_canonical_value` /
25912 // `gateway_api_key_backend_refs_pins_canonical_value` on the
25913 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
25914 // surface — closes the per-Gateway-API-CRD `HTTPRoute` per-route
25915 // body-axis pin pair across the singular / plural DNS-host
25916 // discriminator surface (`hostname` at the parent-Gateway per-
25917 // listener discriminator + `hostnames` at the child HTTPRoute
25918 // per-route filter list), so both halves of the DNS-host-
25919 // discriminator convention across the `(Gateway, HTTPRoute)`
25920 // pair the M3 Aplicacao mesh renderer's external `:entrada`
25921 // ingress contract emits together now carry one lifted
25922 // canonical-string pin apiece.
25923 assert_eq!(GATEWAY_API_KEY_HOSTNAMES, "hostnames");
25924 }
25925
25926 #[test]
25927 fn gateway_api_key_hostnames_carries_lower_camel_case_shape() {
25928 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25929 // lowerCamelCase identifier per the K8s API conventions
25930 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25931 // "Field names should be lowercase camelCase") — first byte
25932 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25933 // kebab-case or whitespace. Pinning the shape here means a
25934 // future rebrand on the canonical lift can't silently land a
25935 // malformed field-name discriminator (snake_case, kebab-case,
25936 // UpperCamelCase, empty) that the apiserver-side CRD schema
25937 // validator would reject far from the rebrand commit's source.
25938 // Peer to `gateway_api_key_hostname_carries_lower_camel_case_shape`
25939 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
25940 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
25941 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
25942 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
25943 // surface — the lowerCamelCase K8s field-name grammar governs
25944 // every nested schema-field axis (including this per-route DNS-
25945 // host-filter-axis key), same convention.
25946 let v = GATEWAY_API_KEY_HOSTNAMES;
25947 assert!(
25948 !v.is_empty(),
25949 "GATEWAY_API_KEY_HOSTNAMES {v:?} must be non-empty per the K8s API \
25950 lowerCamelCase field-name grammar"
25951 );
25952 let first = v.chars().next().expect("non-empty");
25953 assert!(
25954 first.is_ascii_lowercase(),
25955 "GATEWAY_API_KEY_HOSTNAMES {v:?} first byte {first:?} must be \
25956 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25957 grammar (field names are always lowerCamelCase)"
25958 );
25959 assert!(
25960 v.chars().all(|c| c.is_ascii_alphanumeric()),
25961 "GATEWAY_API_KEY_HOSTNAMES {v:?} must be ASCII-alphanumeric \
25962 throughout per the K8s API field-name grammar — no \
25963 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25964 OpenAPI schema validator would reject"
25965 );
25966 }
25967
25968 #[test]
25969 fn gateway_api_key_timeouts_pins_canonical_value() {
25970 // Pin the actual string so a typo in this lift can't silently
25971 // rebrand the Gateway API `HTTPRoute` per-rule request-timeout-
25972 // policy body-axis key the rendered HTTPRoute document mounts
25973 // each rule's per-rule `:politicas :timeout` overlay under. The
25974 // string is part of the cluster-side contract with every
25975 // Gateway-API-conformant gateway implementation (Cilium, Istio,
25976 // Envoy Gateway, NGINX) — the Gateway-API-implementation-side
25977 // per-rule request-dispatch loop keys off this axis to source
25978 // the per-rule wall-clock deadline each accepted request is
25979 // bounded against; a drifted value (`"timeout"` (singular) /
25980 // `"timeoutPolicy"` / `"deadlines"`) at either the production
25981 // emitter or a downstream renderer's per-rule timeout-policy
25982 // upsert silently emits an `HTTPRoute` whose per-rule request-
25983 // timeout policy axis the Gateway API CRD schema validator
25984 // drops as unknown — the route accepts every inbound request
25985 // with no per-rule wall-clock deadline (the "no infinite
25986 // blocking" guarantee MESH-COMPOSITION.md §V mandates for every
25987 // rendered per-`:politicas` mesh-composition edge silently
25988 // regresses to the pre-overlay unbounded-request semantic), and
25989 // every external `:entrada` flow the route was authored to
25990 // bound by the typed `:politicas :timeout` slot runs to
25991 // whatever backend deadline the resolved backend's downstream
25992 // infrastructure picks with no field naming the per-rule-
25993 // timeout-policy-drift root cause. Changing this value is a
25994 // coordinated Gateway API promotion alongside the upstream
25995 // SIG-Network Gateway API deprecation cycle, not an incidental
25996 // edit. Peer to
25997 // `gateway_api_key_hostnames_pins_canonical_value` /
25998 // `gateway_api_key_hostname_pins_canonical_value` /
25999 // `gateway_api_key_listeners_pins_canonical_value` /
26000 // `gateway_api_key_parent_refs_pins_canonical_value` /
26001 // `gateway_api_key_backend_refs_pins_canonical_value` on the
26002 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
26003 // surface — extends the per-Gateway-API-`HTTPRoute` per-rule
26004 // body-axis pin set (`backendRefs`, future per-rule sibling
26005 // axes) onto the load-bearing per-rule request-timeout-policy
26006 // axis the M3 Aplicacao mesh renderer's per-`:politicas
26007 // :timeout` overlay lands under.
26008 assert_eq!(GATEWAY_API_KEY_TIMEOUTS, "timeouts");
26009 }
26010
26011 #[test]
26012 fn gateway_api_key_timeouts_carries_lower_camel_case_shape() {
26013 // Cross-axis invariant: a Kubernetes CRD schema field name is a
26014 // lowerCamelCase identifier per the K8s API conventions
26015 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
26016 // "Field names should be lowercase camelCase") — first byte
26017 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
26018 // kebab-case or whitespace. Pinning the shape here means a
26019 // future rebrand on the canonical lift can't silently land a
26020 // malformed field-name discriminator (snake_case, kebab-case,
26021 // UpperCamelCase, empty) that the apiserver-side CRD schema
26022 // validator would reject far from the rebrand commit's source.
26023 // Peer to `gateway_api_key_hostnames_carries_lower_camel_case_shape`
26024 // / `gateway_api_key_hostname_carries_lower_camel_case_shape`
26025 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
26026 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
26027 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
26028 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
26029 // surface — the lowerCamelCase K8s field-name grammar governs
26030 // every nested schema-field axis (including this per-rule
26031 // request-timeout-policy-axis key), same convention.
26032 let v = GATEWAY_API_KEY_TIMEOUTS;
26033 assert!(
26034 !v.is_empty(),
26035 "GATEWAY_API_KEY_TIMEOUTS {v:?} must be non-empty per the K8s API \
26036 lowerCamelCase field-name grammar"
26037 );
26038 let first = v.chars().next().expect("non-empty");
26039 assert!(
26040 first.is_ascii_lowercase(),
26041 "GATEWAY_API_KEY_TIMEOUTS {v:?} first byte {first:?} must be \
26042 ASCII-lowercase per the K8s API lowerCamelCase field-name \
26043 grammar (field names are always lowerCamelCase)"
26044 );
26045 assert!(
26046 v.chars().all(|c| c.is_ascii_alphanumeric()),
26047 "GATEWAY_API_KEY_TIMEOUTS {v:?} must be ASCII-alphanumeric \
26048 throughout per the K8s API field-name grammar — no \
26049 snake_case, kebab-case, or whitespace bytes the apiserver-side \
26050 OpenAPI schema validator would reject"
26051 );
26052 }
26053
26054 #[test]
26055 fn gateway_api_key_retry_pins_canonical_value() {
26056 // Pin the actual string so a typo in this lift can't silently
26057 // rebrand the Gateway API `HTTPRoute` per-rule retry-policy
26058 // body-axis key the rendered HTTPRoute document mounts each
26059 // rule's per-rule `:politicas :retries` overlay under. The
26060 // string is part of the cluster-side contract with every
26061 // Gateway-API-conformant gateway implementation (Cilium, Istio,
26062 // Envoy Gateway, NGINX) — the Gateway-API-implementation-side
26063 // per-rule request-dispatch loop keys off this axis to source
26064 // the per-rule retry budget each failed backend attempt count
26065 // is bounded against; a drifted value (`"retries"` (plural) /
26066 // `"retryPolicy"` / `"budget"`) at either the production
26067 // emitter or a downstream renderer's per-rule retry-policy
26068 // upsert silently emits an `HTTPRoute` whose per-rule retry-
26069 // budget axis the Gateway API CRD schema validator drops as
26070 // unknown — the route accepts every inbound request with no
26071 // per-rule retry budget (the "no infinite retrying without
26072 // bound" guarantee MESH-COMPOSITION.md §V mandates for every
26073 // rendered per-`:politicas` mesh-composition edge silently
26074 // regresses to the pre-overlay unbounded-retry semantic), and
26075 // every external `:entrada` flow the route was authored to cap
26076 // by the typed `:politicas :retries` slot runs to whatever
26077 // retry policy the resolved backend's downstream infrastructure
26078 // picks with no field naming the per-rule-retry-policy-drift
26079 // root cause. Changing this value is a coordinated Gateway API
26080 // promotion alongside the upstream SIG-Network Gateway API
26081 // deprecation cycle, not an incidental edit. Peer to
26082 // `gateway_api_key_timeouts_pins_canonical_value` /
26083 // `gateway_api_key_hostnames_pins_canonical_value` /
26084 // `gateway_api_key_hostname_pins_canonical_value` /
26085 // `gateway_api_key_listeners_pins_canonical_value` /
26086 // `gateway_api_key_parent_refs_pins_canonical_value` /
26087 // `gateway_api_key_backend_refs_pins_canonical_value` on the
26088 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
26089 // surface — closes the per-Gateway-API-`HTTPRoute`-per-rule
26090 // `:politicas` overlay axis pair (`timeouts` for `:politicas
26091 // :timeout`, `retry` for `:politicas :retries`) both
26092 // MESH-COMPOSITION.md §V "no infinite blocking / no infinite
26093 // retrying" guarantees rest on.
26094 assert_eq!(GATEWAY_API_KEY_RETRY, "retry");
26095 }
26096
26097 #[test]
26098 fn gateway_api_key_retry_carries_lower_camel_case_shape() {
26099 // Cross-axis invariant: a Kubernetes CRD schema field name is a
26100 // lowerCamelCase identifier per the K8s API conventions
26101 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
26102 // "Field names should be lowercase camelCase") — first byte
26103 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
26104 // kebab-case or whitespace. Pinning the shape here means a
26105 // future rebrand on the canonical lift can't silently land a
26106 // malformed field-name discriminator (snake_case, kebab-case,
26107 // UpperCamelCase, empty) that the apiserver-side CRD schema
26108 // validator would reject far from the rebrand commit's source.
26109 // Peer to `gateway_api_key_timeouts_carries_lower_camel_case_shape`
26110 // / `gateway_api_key_hostnames_carries_lower_camel_case_shape`
26111 // / `gateway_api_key_hostname_carries_lower_camel_case_shape`
26112 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
26113 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
26114 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
26115 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
26116 // surface — the lowerCamelCase K8s field-name grammar governs
26117 // every nested schema-field axis (including this per-rule
26118 // retry-policy-axis key), same convention.
26119 let v = GATEWAY_API_KEY_RETRY;
26120 assert!(
26121 !v.is_empty(),
26122 "GATEWAY_API_KEY_RETRY {v:?} must be non-empty per the K8s API \
26123 lowerCamelCase field-name grammar"
26124 );
26125 let first = v.chars().next().expect("non-empty");
26126 assert!(
26127 first.is_ascii_lowercase(),
26128 "GATEWAY_API_KEY_RETRY {v:?} first byte {first:?} must be \
26129 ASCII-lowercase per the K8s API lowerCamelCase field-name \
26130 grammar (field names are always lowerCamelCase)"
26131 );
26132 assert!(
26133 v.chars().all(|c| c.is_ascii_alphanumeric()),
26134 "GATEWAY_API_KEY_RETRY {v:?} must be ASCII-alphanumeric \
26135 throughout per the K8s API field-name grammar — no \
26136 snake_case, kebab-case, or whitespace bytes the apiserver-side \
26137 OpenAPI schema validator would reject"
26138 );
26139 }
26140
26141 #[test]
26142 fn gateway_api_key_attempts_pins_canonical_value() {
26143 // Pin the actual string so a typo in this lift can't silently
26144 // rebrand the Gateway API `HTTPRoute` per-rule retry-policy
26145 // `attempts` leaf scalar-key the rendered HTTPRoute document
26146 // mounts each rule's per-rule `:politicas :retries` typed `u32`
26147 // attempt count under. The string is part of the cluster-side
26148 // contract with every Gateway-API-conformant gateway
26149 // implementation (Cilium, Istio, Envoy Gateway, NGINX) — the
26150 // Gateway-API-implementation-side per-rule request-dispatch
26151 // loop keys off this leaf to source the per-rule retry attempt
26152 // budget each failed backend attempt count is bounded against;
26153 // a drifted value (`"attempt"` (singular) / `"count"` /
26154 // `"tries"` / `"maxAttempts"`) at either the production
26155 // emitter or a downstream renderer's per-rule retry-attempts
26156 // upsert silently emits an `HTTPRoute` whose per-rule retry-
26157 // attempts leaf the Gateway API CRD schema validator drops as
26158 // unknown — the retry sub-shape parses as an empty
26159 // `HTTPRouteRetry` with the typed `u32` attempt count silently
26160 // discarded, the route accepts every inbound request with no
26161 // per-rule retry budget (the "no infinite retrying without
26162 // bound" guarantee MESH-COMPOSITION.md §V mandates for every
26163 // rendered per-`:politicas` mesh-composition edge silently
26164 // regresses to the pre-overlay unbounded-retry semantic), and
26165 // every external `:entrada` flow the route was authored to cap
26166 // by the typed `:politicas :retries` slot runs to whatever
26167 // retry policy the resolved backend's downstream infrastructure
26168 // picks with no field naming the per-rule-retry-attempts-leaf-
26169 // key-drift root cause. Changing this value is a coordinated
26170 // Gateway API promotion alongside the upstream SIG-Network
26171 // Gateway API deprecation cycle, not an incidental edit. Peer
26172 // to `gateway_api_key_retry_pins_canonical_value` /
26173 // `gateway_api_key_timeouts_pins_canonical_value` /
26174 // `gateway_api_key_hostnames_pins_canonical_value` /
26175 // `gateway_api_key_hostname_pins_canonical_value` /
26176 // `gateway_api_key_listeners_pins_canonical_value` /
26177 // `gateway_api_key_parent_refs_pins_canonical_value` /
26178 // `gateway_api_key_backend_refs_pins_canonical_value` on the
26179 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
26180 // surface — closes the parent-leaf axis pair (`retry`
26181 // container + `attempts` leaf) both MESH-COMPOSITION.md §V
26182 // "no infinite retrying" guarantees rest on, one nesting
26183 // level deeper than the parent per-rule retry-policy
26184 // container axis (`retry`).
26185 assert_eq!(GATEWAY_API_KEY_ATTEMPTS, "attempts");
26186 }
26187
26188 #[test]
26189 fn gateway_api_key_attempts_carries_lower_camel_case_shape() {
26190 // Cross-axis invariant: a Kubernetes CRD schema field name is a
26191 // lowerCamelCase identifier per the K8s API conventions
26192 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
26193 // "Field names should be lowercase camelCase") — first byte
26194 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
26195 // kebab-case or whitespace. Pinning the shape here means a
26196 // future rebrand on the canonical lift can't silently land a
26197 // malformed field-name discriminator (snake_case, kebab-case,
26198 // UpperCamelCase, empty) that the apiserver-side CRD schema
26199 // validator would reject far from the rebrand commit's source.
26200 // Peer to `gateway_api_key_retry_carries_lower_camel_case_shape`
26201 // / `gateway_api_key_timeouts_carries_lower_camel_case_shape`
26202 // / `gateway_api_key_hostnames_carries_lower_camel_case_shape`
26203 // / `gateway_api_key_hostname_carries_lower_camel_case_shape`
26204 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
26205 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
26206 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
26207 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
26208 // surface — the lowerCamelCase K8s field-name grammar governs
26209 // every nested schema-field axis (including this per-rule
26210 // retry-attempts-leaf-key), same convention.
26211 let v = GATEWAY_API_KEY_ATTEMPTS;
26212 assert!(
26213 !v.is_empty(),
26214 "GATEWAY_API_KEY_ATTEMPTS {v:?} must be non-empty per the K8s API \
26215 lowerCamelCase field-name grammar"
26216 );
26217 let first = v.chars().next().expect("non-empty");
26218 assert!(
26219 first.is_ascii_lowercase(),
26220 "GATEWAY_API_KEY_ATTEMPTS {v:?} first byte {first:?} must be \
26221 ASCII-lowercase per the K8s API lowerCamelCase field-name \
26222 grammar (field names are always lowerCamelCase)"
26223 );
26224 assert!(
26225 v.chars().all(|c| c.is_ascii_alphanumeric()),
26226 "GATEWAY_API_KEY_ATTEMPTS {v:?} must be ASCII-alphanumeric \
26227 throughout per the K8s API field-name grammar — no \
26228 snake_case, kebab-case, or whitespace bytes the apiserver-side \
26229 OpenAPI schema validator would reject"
26230 );
26231 }
26232
26233 #[test]
26234 fn gateway_api_key_request_pins_canonical_value() {
26235 // Pin the actual string so a typo in this lift can't silently
26236 // rebrand the Gateway API `HTTPRoute` per-rule request-timeout-
26237 // policy `request` leaf scalar-key the rendered HTTPRoute
26238 // document mounts each rule's per-rule `:politicas :timeout`
26239 // typed K8s-duration string under. The string is part of the
26240 // cluster-side contract with every Gateway-API-conformant
26241 // gateway implementation (Cilium, Istio, Envoy Gateway, NGINX)
26242 // — the Gateway-API-implementation-side per-rule request-
26243 // dispatch loop keys off this leaf to source the per-rule
26244 // request wall-clock deadline each inbound request is bounded
26245 // against; a drifted value (`"deadline"` / `"requestTimeout"`
26246 // / `"timeout"` / `"upstreamRequest"`) at either the production
26247 // emitter or a downstream renderer's per-rule request-deadline
26248 // upsert silently emits an `HTTPRoute` whose per-rule request-
26249 // deadline leaf the Gateway API CRD schema validator drops as
26250 // unknown — the timeouts sub-shape parses as an empty
26251 // `HTTPRouteTimeouts` with the typed duration silently
26252 // discarded, the route accepts every inbound request with no
26253 // per-rule request deadline (the "no infinite blocking"
26254 // guarantee MESH-COMPOSITION.md §V mandates for every rendered
26255 // per-`:politicas` mesh-composition edge silently regresses to
26256 // the pre-overlay unbounded-blocking semantic), and every
26257 // external `:entrada` flow the route was authored to cap by
26258 // the typed `:politicas :timeout` slot runs to whatever
26259 // request-deadline the resolved backend's downstream
26260 // infrastructure picks with no field naming the per-rule-
26261 // request-deadline-leaf-key-drift root cause. Changing this
26262 // value is a coordinated Gateway API promotion alongside the
26263 // upstream SIG-Network Gateway API deprecation cycle, not an
26264 // incidental edit. Peer to
26265 // `gateway_api_key_attempts_pins_canonical_value` /
26266 // `gateway_api_key_retry_pins_canonical_value` /
26267 // `gateway_api_key_timeouts_pins_canonical_value` /
26268 // `gateway_api_key_hostnames_pins_canonical_value` /
26269 // `gateway_api_key_hostname_pins_canonical_value` /
26270 // `gateway_api_key_listeners_pins_canonical_value` /
26271 // `gateway_api_key_parent_refs_pins_canonical_value` /
26272 // `gateway_api_key_backend_refs_pins_canonical_value` on the
26273 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
26274 // surface — closes the second parent-leaf axis pair
26275 // (`timeouts` container + `request` leaf) both
26276 // MESH-COMPOSITION.md §V "no infinite blocking / no infinite
26277 // retrying" guarantees rest on, sibling to the parent-leaf
26278 // pair (`retry` container + `attempts` leaf) closed in
26279 // e2e136b.
26280 assert_eq!(GATEWAY_API_KEY_REQUEST, "request");
26281 }
26282
26283 #[test]
26284 fn gateway_api_key_request_carries_lower_camel_case_shape() {
26285 // Cross-axis invariant: a Kubernetes CRD schema field name is a
26286 // lowerCamelCase identifier per the K8s API conventions
26287 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
26288 // "Field names should be lowercase camelCase") — first byte
26289 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
26290 // kebab-case or whitespace. Pinning the shape here means a
26291 // future rebrand on the canonical lift can't silently land a
26292 // malformed field-name discriminator (snake_case, kebab-case,
26293 // UpperCamelCase, empty) that the apiserver-side CRD schema
26294 // validator would reject far from the rebrand commit's source.
26295 // Peer to `gateway_api_key_attempts_carries_lower_camel_case_shape`
26296 // / `gateway_api_key_retry_carries_lower_camel_case_shape`
26297 // / `gateway_api_key_timeouts_carries_lower_camel_case_shape`
26298 // / `gateway_api_key_hostnames_carries_lower_camel_case_shape`
26299 // / `gateway_api_key_hostname_carries_lower_camel_case_shape`
26300 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
26301 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
26302 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
26303 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
26304 // surface — the lowerCamelCase K8s field-name grammar governs
26305 // every nested schema-field axis (including this per-rule
26306 // request-deadline-leaf-key), same convention.
26307 let v = GATEWAY_API_KEY_REQUEST;
26308 assert!(
26309 !v.is_empty(),
26310 "GATEWAY_API_KEY_REQUEST {v:?} must be non-empty per the K8s API \
26311 lowerCamelCase field-name grammar"
26312 );
26313 let first = v.chars().next().expect("non-empty");
26314 assert!(
26315 first.is_ascii_lowercase(),
26316 "GATEWAY_API_KEY_REQUEST {v:?} first byte {first:?} must be \
26317 ASCII-lowercase per the K8s API lowerCamelCase field-name \
26318 grammar (field names are always lowerCamelCase)"
26319 );
26320 assert!(
26321 v.chars().all(|c| c.is_ascii_alphanumeric()),
26322 "GATEWAY_API_KEY_REQUEST {v:?} must be ASCII-alphanumeric \
26323 throughout per the K8s API field-name grammar — no \
26324 snake_case, kebab-case, or whitespace bytes the apiserver-side \
26325 OpenAPI schema validator would reject"
26326 );
26327 }
26328
26329 #[test]
26330 fn default_namespace_is_a_valid_dns_1123_label() {
26331 // Cross-axis invariant: the default namespace lands as
26332 // `metadata.namespace` on every emitted K8s object across every
26333 // renderer, and the K8s apiserver enforces the DNS-1123 label
26334 // rule on every `metadata.namespace`. Pinning this here means
26335 // a future rebrand on the canonical `DEFAULT_NAMESPACE`
26336 // declaration can't silently land a value the apiserver
26337 // refuses at the *first* renderer to apply against a cluster,
26338 // far from the rebrand commit's source — the typed
26339 // [`is_dns_1123_label`] floor rejects it at caixa-core build
26340 // time on the canonical lift, before any renderer consumes
26341 // the value. Same trajectory as `:membros :caixa` /
26342 // `:placement :clusters` / `:contratos :de`/`:para` /
26343 // `:entrada :para` / `:placement :affinity` (dfd4902 — the
26344 // five typed-identifier axes on the Aplicacao surface that
26345 // already land on this same `is_dns_1123_label` floor at
26346 // their respective validate gates), now extended onto the
26347 // canonical-namespace-default axis the renderers share.
26348 assert!(
26349 is_dns_1123_label(DEFAULT_NAMESPACE).is_ok(),
26350 "DEFAULT_NAMESPACE {DEFAULT_NAMESPACE:?} must be a valid \
26351 DNS-1123 label — every K8s apiserver-side schema enforces \
26352 this rule on `metadata.namespace`"
26353 );
26354 }
26355
26356 #[test]
26357 fn helm_chart_api_version_pins_canonical_value() {
26358 // Pin the actual string so a typo in this lift can't silently
26359 // rebrand the Helm 3 chart-schema apiVersion the rendered
26360 // `lareira-<nome>` `Chart.yaml` document declares at its
26361 // top-level `apiVersion` axis. The string is part of the
26362 // Helm-side contract with the Helm 3 chart-schema parser:
26363 // `helm dependency build` / `helm lint` / `helm template`
26364 // all resolve the chart under the Helm 3 v2 schema (permitting
26365 // top-level `dependencies:`); a drifted value to the legacy
26366 // Helm 2 `"v1"` schema (the pre-Helm-3 chart schema every
26367 // upstream Helm-3-migration doc names) silently reroutes the
26368 // rendered Chart.yaml through the Helm 2 parser, where the
26369 // top-level `dependencies:` block is unknown and the chart's
26370 // dep on the `pleme-computeunit` library chart never resolves
26371 // — `helm dependency build` reports "no requirements found"
26372 // and every `helm template` / `helm install` emits an empty
26373 // release (no ComputeUnit / Service / ScaledObject resources
26374 // land) far from the source caixa.lisp / the renderer's
26375 // `build_chart_yaml` call site. Changing it is a coordinated
26376 // Helm 4 chart-schema migration alongside the upstream Helm
26377 // chart-schema deprecation cycle, not an incidental edit.
26378 // Peer to `flux_helmrelease_api_version_pins_canonical_value`
26379 // / `flux_gitrepository_api_version_pins_canonical_value` /
26380 // `flux_kustomization_api_version_pins_canonical_value` /
26381 // `gateway_api_api_version_pins_canonical_value` /
26382 // `cilium_api_version_pins_canonical_value` on the sibling
26383 // cluster-side-CRD-apiVersion-pin set — those pin the K8s
26384 // apiserver-side `(apiVersion, kind)` `RESTMapper` contract,
26385 // this one pins the Helm-side chart-schema-parser contract
26386 // that gates every rendered `lareira-<nome>` chart's
26387 // dependency resolution before any K8s resource lands.
26388 assert_eq!(HELM_CHART_API_VERSION, "v2");
26389 }
26390
26391 #[test]
26392 fn helm_chart_api_version_carries_helm_3_chart_schema_shape() {
26393 // Cross-axis invariant: the Helm 3 chart-schema apiVersion is
26394 // a bare `v<digit>` version label (unlike the K8s CRD
26395 // apiVersion — `<group>/<version>` — the sibling
26396 // FLUX_HELMRELEASE_API_VERSION / GATEWAY_API_API_VERSION /
26397 // CILIUM_API_VERSION lifts pin). The Helm-side chart-schema
26398 // grammar carries no group prefix at all — the value is
26399 // parsed as a plain schema-version discriminator against the
26400 // Helm binary's built-in schema table (Helm 2 recognizes
26401 // `"v1"`, Helm 3 recognizes both `"v1"` for legacy compat
26402 // and `"v2"` for its native schema). Pinning the shape here
26403 // means a future rebrand on the canonical lift can't silently
26404 // land a K8s-CRD-shaped `group/version` value (e.g. an
26405 // accidental copy-paste from the sibling FLUX / GATEWAY /
26406 // CILIUM constants) that the Helm chart-schema parser would
26407 // fail to recognize at `helm dependency build` /
26408 // `helm lint` / `helm template` time. The `v<digit>+`
26409 // invariant is the load-bearing Helm-side chart-schema
26410 // typed-discovery contract: a value the Helm binary's
26411 // chart-schema resolver consults to select the schema
26412 // parser that reads the rest of the document. Peer to
26413 // `flux_kind_helm_release_carries_upper_camel_case_shape`
26414 // (which pins the K8s `RESTMapper` kind-grammar shape) —
26415 // both close the "the shape of the lifted schema-version
26416 // discriminator is grammatical, not just a byte-equal string"
26417 // discipline at the lift site.
26418 let v = HELM_CHART_API_VERSION;
26419 assert!(
26420 !v.is_empty(),
26421 "HELM_CHART_API_VERSION {v:?} must be non-empty per the Helm \
26422 chart-schema apiVersion grammar"
26423 );
26424 assert!(
26425 !v.contains('/'),
26426 "HELM_CHART_API_VERSION {v:?} must not contain `/` — the Helm-side \
26427 chart-schema apiVersion is a bare `v<digit>` label with no group \
26428 prefix, unlike the K8s CRD `<group>/<version>` shape the sibling \
26429 FLUX_HELMRELEASE_API_VERSION / GATEWAY_API_API_VERSION / \
26430 CILIUM_API_VERSION lifts carry"
26431 );
26432 let bytes = v.as_bytes();
26433 assert_eq!(
26434 bytes[0], b'v',
26435 "HELM_CHART_API_VERSION {v:?} must start with `v` per the Helm \
26436 chart-schema apiVersion grammar (`v1` for the legacy schema, \
26437 `v2` for the Helm 3 schema — every accepted value the Helm \
26438 binary's chart-schema resolver knows carries the `v` prefix)"
26439 );
26440 assert!(
26441 bytes.len() >= 2,
26442 "HELM_CHART_API_VERSION {v:?} must be at least 2 bytes (`v` + \
26443 at least one digit) per the Helm chart-schema apiVersion \
26444 grammar"
26445 );
26446 assert!(
26447 bytes[1..].iter().all(u8::is_ascii_digit),
26448 "HELM_CHART_API_VERSION {v:?} bytes after the leading `v` must be \
26449 ASCII digits per the Helm chart-schema apiVersion grammar — \
26450 no dots, no hyphens, no whitespace, no non-digit bytes the \
26451 Helm binary's chart-schema resolver would reject"
26452 );
26453 }
26454
26455 #[test]
26456 fn helm_chart_type_application_pins_canonical_value() {
26457 // Pin the actual string so a typo in this lift can't silently
26458 // rebrand the Helm 3 chart-schema `type` field's canonical
26459 // `application` per-chart-kind discriminator scalar-value the
26460 // rendered `lareira-<nome>` chart's Chart.yaml `type:` axis
26461 // declares. The value is part of the cluster-side contract with
26462 // Helm's per-release install-shape dispatch loop — the Helm
26463 // chart-schema pins the per-chart-kind axis to the closed set
26464 // `{"application", "library"}` (see
26465 // https://helm.sh/docs/topics/charts/#chart-types), so a drifted
26466 // value (`"Application"` / `"APPLICATION"` / `"app"` /
26467 // `"workload"`) lands the rendered `lareira-<nome>` chart outside
26468 // the schema's admitted set, and Helm's chart-schema parser
26469 // silently treats the unrecognized value as the default
26470 // `application` shape (masking the schema violation with no
26471 // process-log drift-signal); worse, an accidental collapse onto
26472 // the sibling `"library"` shape lands `lareira-<nome>` in the
26473 // dependency-only install-shape Helm refuses to install directly
26474 // ("Error: library charts cannot be installed"), dropping every
26475 // per-Servico `helm install` / `helm upgrade` release cycle with
26476 // no field naming the chart-kind-drift root cause. Changing this
26477 // value is a coordinated Helm chart-schema promotion alongside
26478 // the upstream Helm project's per-schema deprecation cycle, not
26479 // an incidental edit. Peer to
26480 // `helm_chart_api_version_pins_canonical_value` /
26481 // `kube_protocol_tcp_pins_canonical_value` /
26482 // `gateway_api_protocol_http_pins_canonical_value` /
26483 // `cilium_auth_mode_required_pins_canonical_value` on the
26484 // sibling canonical-Helm-chart-schema-axis + canonical-cluster-
26485 // side-OpenAPI-schema-enum-value pin sets — pivots the
26486 // canonical-enum-value single-sourcing discipline from the K8s-
26487 // CR-side surfaces onto the Helm-chart-schema-enum-value axis
26488 // every rendered Chart.yaml carries at its per-chart-kind
26489 // discriminator field.
26490 assert_eq!(HELM_CHART_TYPE_APPLICATION, "application");
26491 }
26492
26493 #[test]
26494 fn helm_chart_type_application_carries_lowercase_shape() {
26495 // Cross-axis invariant: the Helm 3 chart-schema `type` field
26496 // admits the closed set `{"application", "library"}` — every
26497 // admitted value is all-ASCII-lowercase throughout per the
26498 // upstream Helm project's per-enum-value naming convention
26499 // (distinct from the sibling K8s-core `Protocol` OpenAPI schema
26500 // enum's all-ASCII-uppercase per-value convention the
26501 // `kube_protocol_tcp_carries_upper_case_shape` pin carries, and
26502 // distinct from the sibling Gateway-API v1 `PathMatchType`
26503 // OpenAPI schema enum's UpperCamelCase per-value convention the
26504 // `gateway_api_path_match_type_path_prefix_carries_upper_camel_case_shape`
26505 // pin carries — the three peer canonical-cluster-side-schema-
26506 // enum-value conventions do not collapse). Same all-ASCII-
26507 // lowercase shape as the sibling Cilium `MutualAuthenticationMode`
26508 // enum-values the peer `cilium_auth_mode_required_carries_lowercase_shape`
26509 // / `cilium_auth_mode_disabled_carries_lowercase_shape` pins
26510 // enshrine — the two peer canonical-cluster-side-schema-enum-
26511 // value all-lowercase conventions collapse on the shared byte-
26512 // shape convention Helm and Cilium happen to share (independent
26513 // upstream projects, coincidental convention agreement).
26514 //
26515 // Pinning the shape here means a future rebrand on the canonical
26516 // lift can't silently land a malformed per-chart-kind scalar
26517 // (uppercase `"APPLICATION"`, mixed-case `"Application"`, empty)
26518 // that the Helm chart-schema parser would silently treat as the
26519 // default `application` shape (masking the drift with no
26520 // process-log signal).
26521 let v = HELM_CHART_TYPE_APPLICATION;
26522 assert!(
26523 !v.is_empty(),
26524 "HELM_CHART_TYPE_APPLICATION {v:?} must be non-empty per the \
26525 Helm 3 chart-schema `type` field grammar"
26526 );
26527 assert!(
26528 v.chars().all(|c| c.is_ascii_lowercase()),
26529 "HELM_CHART_TYPE_APPLICATION {v:?} must be ASCII-lowercase \
26530 throughout per the Helm 3 chart-schema per-chart-kind \
26531 discriminator naming convention — no uppercase, mixed-case, \
26532 or whitespace bytes the Helm chart-schema parser would \
26533 silently treat as the default `application` shape (masking \
26534 the drift with no process-log signal)"
26535 );
26536 }
26537
26538 #[test]
26539 fn helm_chart_type_library_pins_canonical_value() {
26540 // Pin the sibling closed-set arm of the Helm 3 chart-schema
26541 // `type` field's admitted set `{"application", "library"}` (see
26542 // https://helm.sh/docs/topics/charts/#chart-types). A drift on
26543 // this const's value (an `"Library"` / `"LIBRARY"` /
26544 // `"library-chart"` / `"lib"` typo, an accidental collapse onto
26545 // the sibling [`HELM_CHART_TYPE_APPLICATION`] shape) would land
26546 // a future per-Aplicacao library-chart emitter — the trajectory
26547 // item the [`HELM_CHART_TYPE_APPLICATION`] docstring names as
26548 // the natural next consumer of this const — outside the Helm
26549 // chart-schema's admitted set, with the same silent-collapse-
26550 // onto-`application`-default failure mode the peer
26551 // [`HELM_CHART_TYPE_APPLICATION`] pin's docstring enumerates on
26552 // the sibling closed-set arm (Helm's chart-schema parser
26553 // silently treats an unrecognized `type:` value as the default
26554 // `application` shape, so the misdeclared library chart installs
26555 // as an application chart instead of surfacing the schema
26556 // violation). Peer of
26557 // `helm_chart_type_application_pins_canonical_value` on the
26558 // sibling closed-set arm — the two pins together enshrine the
26559 // full closed set at the substrate-side canonical surface, and
26560 // the paired
26561 // `helm_chart_type_application_and_library_are_distinct` pin
26562 // (below) enforces the two arms never accidentally converge on
26563 // the same byte-shape.
26564 assert_eq!(HELM_CHART_TYPE_LIBRARY, "library");
26565 }
26566
26567 #[test]
26568 fn helm_chart_type_library_carries_lowercase_shape() {
26569 // Cross-axis invariant: the Helm 3 chart-schema `type` field
26570 // admits the closed set `{"application", "library"}` — every
26571 // admitted value is all-ASCII-lowercase throughout per the
26572 // upstream Helm project's per-enum-value naming convention.
26573 // Same all-ASCII-lowercase shape the peer
26574 // `helm_chart_type_application_carries_lowercase_shape` pin
26575 // enshrines on the sibling closed-set arm — the two pins
26576 // together enforce the shape-convention across the full
26577 // canonical-Helm-chart-schema-per-chart-kind-discriminator
26578 // closed set.
26579 //
26580 // Pinning the shape here means a future rebrand on the canonical
26581 // lift can't silently land a malformed per-chart-kind scalar
26582 // (uppercase `"LIBRARY"`, mixed-case `"Library"`, empty) that
26583 // the Helm chart-schema parser would silently treat as the
26584 // default `application` shape (masking the drift with no
26585 // process-log signal, and installing the misdeclared library
26586 // chart as an application chart instead of surfacing the
26587 // schema violation at chart-consumption time).
26588 let v = HELM_CHART_TYPE_LIBRARY;
26589 assert!(
26590 !v.is_empty(),
26591 "HELM_CHART_TYPE_LIBRARY {v:?} must be non-empty per the \
26592 Helm 3 chart-schema `type` field grammar"
26593 );
26594 assert!(
26595 v.chars().all(|c| c.is_ascii_lowercase()),
26596 "HELM_CHART_TYPE_LIBRARY {v:?} must be ASCII-lowercase \
26597 throughout per the Helm 3 chart-schema per-chart-kind \
26598 discriminator naming convention — no uppercase, mixed-case, \
26599 or whitespace bytes the Helm chart-schema parser would \
26600 silently treat as the default `application` shape (masking \
26601 the drift with no process-log signal)"
26602 );
26603 }
26604
26605 #[test]
26606 fn helm_chart_type_application_and_library_are_distinct() {
26607 // Structural distinctness invariant on the closed-set pair the
26608 // Helm 3 chart-schema `type` field admits (`{"application",
26609 // "library"}`). The two arms name distinct per-chart-kind
26610 // install shapes at the substrate-side Helm dispatch — an
26611 // `application`-typed chart installs into a namespace as a
26612 // workload while a `library`-typed chart is dependency-only
26613 // and Helm refuses to install it directly ("Error: library
26614 // charts cannot be installed") — so a future rebrand that
26615 // accidentally collapsed the two consts onto the same
26616 // byte-shape would land every consumer of one arm on the
26617 // sibling's install semantic by construction: a rendered
26618 // `lareira-<nome>` (application) chart that silently emitted
26619 // `type: library` would drop every per-Servico
26620 // `helm install` / `helm upgrade` release cycle with no field
26621 // naming the chart-kind-drift root cause, and (symmetrically)
26622 // a future per-Aplicacao library chart emitting
26623 // `type: application` would be install-able as a workload
26624 // when the substrate's install-shape dispatch expects it to
26625 // fail with the library-charts-cannot-be-installed diagnostic.
26626 // Pinning the distinctness here means a hypothetical future
26627 // edit that accidentally converges the two arms (a copy-paste
26628 // rebrand at one lift that stops at the peer const declaration,
26629 // a substrate-wide vocabulary shift that lands one arm without
26630 // its paired peer) surfaces at caixa-core build time rather
26631 // than as a chart-install-shape drift far from the source
26632 // commit. Same "closed-set arms are byte-distinct by
26633 // construction" discipline the peer
26634 // [`crate::CILIUM_AUTH_MODE_REQUIRED`] /
26635 // [`crate::CILIUM_AUTH_MODE_DISABLED`] pair carries on the
26636 // sibling two-arm Cilium `MutualAuthenticationMode` OpenAPI
26637 // enum closed set.
26638 assert_ne!(
26639 HELM_CHART_TYPE_APPLICATION, HELM_CHART_TYPE_LIBRARY,
26640 "HELM_CHART_TYPE_APPLICATION ({HELM_CHART_TYPE_APPLICATION:?}) and \
26641 HELM_CHART_TYPE_LIBRARY ({HELM_CHART_TYPE_LIBRARY:?}) must remain \
26642 byte-distinct — the two arms name the two install shapes of the \
26643 Helm 3 chart-schema `type` field's closed set {{\"application\", \
26644 \"library\"}} and every substrate-side consumer that dispatches \
26645 on the per-chart-kind axis relies on the two byte-shapes \
26646 distinguishing the workload-install-shape arm from the \
26647 dependency-only-install-shape arm"
26648 );
26649 }
26650
26651 #[test]
26652 fn helm_chart_key_api_version_pins_canonical_value() {
26653 // Pin the actual byte-string so a typo in this lift can't
26654 // silently rebrand the Helm 3 `Chart.yaml` top-level chart-
26655 // schema-apiVersion YAML axis-key the rendered `lareira-<nome>`
26656 // chart declares. The string is part of the substrate-side
26657 // contract with Helm's chart-schema parser at
26658 // `helm dependency build` / `helm lint` / `helm template` /
26659 // `helm install` time: the parser looks up the per-chart
26660 // chart-schema-apiVersion scalar under exactly this top-level
26661 // YAML key (Helm's chart-schema treats a missing `apiVersion:`
26662 // top-level scalar as an "apiVersion is required" hard error,
26663 // and Helm 3's chart-schema-version-router silently defaults
26664 // an unrecognized top-level apiVersion-carrier key to Helm 2
26665 // parsing shape). A drift on this const's value (an accidental
26666 // collapse onto `"ApiVersion"` / `"apiversion"` /
26667 // `"schemaVersion"` / the empty string) would silently reroute
26668 // the rendered `Chart.yaml` through the wrong chart-schema
26669 // parser at `helm dependency build` / `helm lint` /
26670 // `helm template` time. Peer to
26671 // `helm_chart_api_version_pins_canonical_value` on the sibling
26672 // axis-value canonical pin — completes the per-Chart.yaml
26673 // chart-schema-apiVersion axis's `(key, value)` canonical-pin
26674 // pair at the substrate.
26675 assert_eq!(HELM_CHART_KEY_API_VERSION, "apiVersion");
26676 }
26677
26678 #[test]
26679 fn helm_chart_key_api_version_matches_kube_key_api_version() {
26680 // Load-bearing byte-shape coincidence between the Helm 3
26681 // `Chart.yaml` top-level chart-schema-apiVersion YAML axis-key
26682 // ([`HELM_CHART_KEY_API_VERSION`]) and the K8s-CR top-level
26683 // per-CR schema-apiVersion YAML axis-key ([`KUBE_KEY_API_VERSION`])
26684 // — Helm inherits the K8s CR top-level shape verbatim (see
26685 // https://helm.sh/docs/topics/charts/#the-chartyaml-file), so
26686 // every consumer that navigates a Chart.yaml top-level mapping
26687 // by the schema-apiVersion key and every consumer that
26688 // navigates a K8s CR top-level mapping by the schema-apiVersion
26689 // key both read the byte-identical `"apiVersion"` key. The two
26690 // axes are structurally-independent schema surfaces (the Helm 3
26691 // chart-schema top-level shape vs. the K8s apiserver-side CR
26692 // top-level shape), so the substrate carries two distinct
26693 // `pub const` symbols; this pin makes the byte-shape
26694 // coincidence load-bearing rather than accidental so a future
26695 // K8s-side rebrand at [`KUBE_KEY_API_VERSION`] (or a Helm-side
26696 // rebrand at [`HELM_CHART_KEY_API_VERSION`]) that dropped the
26697 // byte-identity would fail the pin at substrate-build time
26698 // rather than as a silent Helm-chart-schema-parser rejection
26699 // at `helm lint` / `helm template` time far from the drift
26700 // site. Complementary to the sibling
26701 // [`helm_chart_key_type_is_byte_distinct_from_kube_key_kind`]
26702 // pin — that peer asserts the per-chart-kind discriminator key
26703 // pair is byte-distinct across the two schema surfaces (the
26704 // Chart.yaml `type:` axis vs. the K8s CR `kind:` axis), and
26705 // this pin asserts the per-schema-apiVersion axis-key pair is
26706 // byte-identical across the two schema surfaces; together the
26707 // two pins cover the full independence-map of the top-level
26708 // discriminator axes at the two schema surfaces.
26709 assert_eq!(
26710 HELM_CHART_KEY_API_VERSION, KUBE_KEY_API_VERSION,
26711 "HELM_CHART_KEY_API_VERSION ({HELM_CHART_KEY_API_VERSION:?}) \
26712 must remain byte-identical to KUBE_KEY_API_VERSION \
26713 ({KUBE_KEY_API_VERSION:?}) — Helm 3 inherits the K8s CR \
26714 top-level schema-apiVersion YAML-axis-key byte-shape \
26715 verbatim, and every downstream consumer that navigates a \
26716 `Chart.yaml` / K8s CR top-level mapping by the schema-\
26717 apiVersion key reads the byte-identical `\"apiVersion\"` \
26718 key; a drift on either side silently reroutes the \
26719 consumer through a schema-parser rejection far from the \
26720 drift site"
26721 );
26722 }
26723
26724 #[test]
26725 fn helm_chart_key_type_pins_canonical_value() {
26726 // Pin the actual byte-string so a typo in this lift can't silently
26727 // rebrand the Helm 3 `Chart.yaml` top-level per-chart-kind
26728 // discriminator YAML axis-key the rendered `lareira-<nome>` chart
26729 // declares. The string is part of the substrate-side contract with
26730 // Helm's chart-schema parser at `helm dependency build` /
26731 // `helm lint` / `helm template` / `helm install` time: the parser
26732 // looks up the per-chart-kind discriminator scalar under exactly
26733 // this top-level YAML key, and a drift on this const's value
26734 // (an accidental collapse onto `"Type"` / `"chartType"` /
26735 // `"kind"`, or the empty string) would silently reroute the
26736 // rendered `Chart.yaml` through the schema-shape-defaulting arm
26737 // of Helm's parser (unknown top-level keys default the
26738 // per-chart-kind axis to `application` with no process-log
26739 // signal). Peer to
26740 // `helm_chart_type_application_pins_canonical_value` /
26741 // `helm_chart_type_library_pins_canonical_value` on the sibling
26742 // axis-value canonical pin pair — completes the per-Chart.yaml
26743 // per-chart-kind discriminator axis's `(key, value-set)`
26744 // canonical-pin trio at the substrate.
26745 assert_eq!(HELM_CHART_KEY_TYPE, "type");
26746 }
26747
26748 #[test]
26749 fn helm_chart_key_type_is_byte_distinct_from_kube_key_kind() {
26750 // Structural distinctness invariant: the Helm 3 `Chart.yaml`
26751 // top-level per-chart-kind YAML axis-key
26752 // ([`HELM_CHART_KEY_TYPE`]) and the K8s CR top-level per-CRD
26753 // kind-discriminator YAML axis-key ([`KUBE_KEY_KIND`]) name
26754 // two structurally-independent axes at two structurally-
26755 // independent schema surfaces — the Helm-side chart-schema
26756 // top-level shape and the K8s-apiserver-side CR top-level
26757 // shape — and every substrate-side renderer that emits or
26758 // navigates a `Chart.yaml` vs. a K8s CR YAML relies on the
26759 // two byte-shapes distinguishing the two schema-surfaces at
26760 // its top-level mapping-key resolution. A hypothetical future
26761 // rebrand that accidentally aliased [`HELM_CHART_KEY_TYPE`]
26762 // at [`KUBE_KEY_KIND`]'s canonical would collapse the
26763 // per-Chart.yaml per-chart-kind discriminator axis onto the
26764 // K8s-CR per-CRD kind-discriminator axis at every consumer,
26765 // and Helm's chart-schema parser would silently drop the
26766 // rebranded key (top-level `kind:` is not part of the Helm 3
26767 // chart-schema's admitted set — the parser silently ignores
26768 // it, defaulting the per-chart-kind axis to `application`
26769 // with no process-log signal). Same "byte-distinct axis-keys
26770 // at structurally-independent schema surfaces" discipline the
26771 // peer [`CILIUM_KEY_PATH`] / [`GATEWAY_API_KEY_PATH`]
26772 // (ef6114f / 9f45aa4) pair carries on the sibling Cilium-CRD-
26773 // vs.-Gateway-API-per-HTTPRouteMatch path-matcher axis
26774 // independence — extends the discipline from the two K8s-CR-
26775 // side path-matcher schemas onto the Helm-side vs. K8s-side
26776 // top-level discriminator-key axis pair.
26777 assert_ne!(
26778 HELM_CHART_KEY_TYPE, KUBE_KEY_KIND,
26779 "HELM_CHART_KEY_TYPE ({HELM_CHART_KEY_TYPE:?}) and \
26780 KUBE_KEY_KIND ({KUBE_KEY_KIND:?}) name the top-level \
26781 discriminator keys of two structurally-independent schema \
26782 surfaces (the Helm 3 chart-schema and the K8s apiserver-side \
26783 CR schema) and must remain byte-distinct — a collapse \
26784 silently reroutes the per-Chart.yaml per-chart-kind axis \
26785 through the K8s-CR-shape-defaulting arm of Helm's parser"
26786 );
26787 }
26788
26789 #[test]
26790 fn helm_chart_key_app_version_pins_canonical_value() {
26791 // Pin the actual byte-string so a typo in this lift can't silently
26792 // rebrand the Helm 3 `Chart.yaml` top-level per-chart-app-version
26793 // YAML axis-key the rendered `lareira-<nome>` chart declares.
26794 // The string is part of the substrate-side contract with Helm's
26795 // chart-schema parser + every downstream chart-consumer that
26796 // routes the underlying-application-version display onto the
26797 // rendered chart's per-app-version field (Artifact Hub's per-
26798 // chart-search index, `helm search` / `helm show chart` operator
26799 // surfaces, the OCI-artifact-labels emitter every chart-publish
26800 // pipeline exports). A drift on this const's value (`"AppVersion"`
26801 // / `"applicationVersion"` / `"appversion"` / the empty string)
26802 // would silently drop the underlying-application-version field
26803 // from the parsed chart-metadata shape at every downstream
26804 // consumer, with no process-log signal at the substrate-side
26805 // emitter site. The `appVersion:` camelCase byte-shape is the
26806 // load-bearing Helm chart-schema per-app-version YAML axis-key
26807 // grammar the upstream Helm project pins. Peer to
26808 // `helm_chart_key_type_pins_canonical_value` on the sibling
26809 // per-Chart.yaml top-level YAML axis-key canonical pin surface —
26810 // completes the per-Chart.yaml top-level YAML axis-key
26811 // canonical-pin trio at the substrate for the three serde-
26812 // rename-literal-only axes on [`caixa_helm::ChartYaml`] (the
26813 // third top-level axis-key `apiVersion` lands under the peer
26814 // [`HELM_CHART_KEY_API_VERSION`] pin whose byte-shape coincides
26815 // with [`KUBE_KEY_API_VERSION`] by Helm's design decision to
26816 // inherit the K8s CR top-level shape verbatim — the paired
26817 // `helm_chart_key_api_version_matches_kube_key_api_version`
26818 // pin makes the coincidence load-bearing rather than
26819 // accidental).
26820 assert_eq!(HELM_CHART_KEY_APP_VERSION, "appVersion");
26821 }
26822
26823 #[test]
26824 fn helm_chart_key_app_version_is_byte_distinct_from_helm_chart_key_version() {
26825 // Structural distinctness invariant on the per-Chart.yaml top-
26826 // level version-axis-key pair. The Helm 3 chart-schema pins two
26827 // structurally-distinct version YAML axis-keys at the top-level
26828 // of every `Chart.yaml`:
26829 //
26830 // - `version:` — the chart's own SemVer (incremented per
26831 // release of the chart itself)
26832 // - `appVersion:` — the underlying application's version
26833 // (the version the containerized workload the chart
26834 // installs advertises)
26835 //
26836 // At the caixa-helm renderer both YAML axes today draw from the
26837 // caixa's `:versao` at `build_chart_yaml` (a caixa's per-caixa
26838 // BLAKE3-closure identity binds chart + wasm-binary at exactly
26839 // one release axis), but the Helm 3 chart-schema pins the two
26840 // top-level YAML keys distinctly regardless — every downstream
26841 // Helm-consumer (Artifact Hub's per-chart index, `helm search` /
26842 // `helm show chart` surfaces) routes the two version-axis
26843 // scalars onto distinct display fields. A hypothetical future
26844 // rebrand that accidentally aliased [`HELM_CHART_KEY_APP_VERSION`]
26845 // at the sibling per-Chart.yaml top-level `version:` key
26846 // (`"version"`) would collapse the two YAML axes at the
26847 // renderer's ChartYaml serialization, and Helm's chart-schema
26848 // parser would silently read the app-version scalar under the
26849 // chart-own-SemVer axis (the last `version:` key wins in
26850 // `serde_yaml`'s emitted mapping under this drift), overwriting
26851 // the chart's own SemVer at every downstream chart-consumer.
26852 // Same "byte-distinct version-axis keys at the same schema
26853 // surface" discipline the peer [`FLEET_PROGRAMS_KEY_VERSAO`] /
26854 // [`FLEET_PROGRAMS_KEY_NAME`] pair carries on the sibling
26855 // per-fleet-programs-entry axis pair — extends the discipline
26856 // from the per-fleet-programs-entry key-pair onto the per-
26857 // Chart.yaml top-level version-axis-key pair.
26858 assert_ne!(
26859 HELM_CHART_KEY_APP_VERSION, "version",
26860 "HELM_CHART_KEY_APP_VERSION ({HELM_CHART_KEY_APP_VERSION:?}) \
26861 must remain byte-distinct from the sibling per-Chart.yaml \
26862 top-level chart-own-SemVer `version:` key — a collapse \
26863 silently overwrites the chart's own SemVer at every \
26864 downstream Helm chart-consumer"
26865 );
26866 }
26867
26868 #[test]
26869 fn helm_chart_key_dependencies_pins_canonical_value() {
26870 // Pin the actual byte-string so a typo in this lift can't silently
26871 // rebrand the Helm 3 `Chart.yaml` top-level per-chart dependency-
26872 // list YAML axis-key the rendered `lareira-<nome>` chart declares.
26873 // The string is part of the substrate-side contract with Helm's
26874 // chart-schema parser — every rendered chart's `dependencies:`
26875 // list-container mounts under this exact byte-shape, and Helm's
26876 // per-dep resolver at `helm dependency build` / `helm dependency
26877 // update` time consumes the per-entry sub-mapping tetrad only if
26878 // the top-level list-container key matches this canonical shape.
26879 // A drift on this const's value (`"Dependencies"` / `"deps"` /
26880 // `"chartDependencies"` / `"depends"` / the empty string) would
26881 // silently drop the entire per-chart dep list from the parsed
26882 // chart-metadata shape, and every rendered `lareira-<nome>`
26883 // chart's install would fail with `template: no template ...
26884 // associated with template ...` far from the drift site with
26885 // no field naming the top-level-list-key-drift root cause. Peer
26886 // to [`helm_chart_key_type_pins_canonical_value`] /
26887 // [`helm_chart_key_app_version_pins_canonical_value`] /
26888 // [`helm_chart_key_api_version_pins_canonical_value`] on the
26889 // sibling per-Chart.yaml top-level YAML axis-key canonical-pin
26890 // surface — extends the per-Chart.yaml top-level YAML axis-key
26891 // canonical-pin trio those pins established onto the fourth
26892 // top-level axis-key at the substrate, the parent list-container
26893 // whose already-lifted per-`dependencies[]`-entry sub-mapping
26894 // tetrad ([`HELM_CHART_DEPENDENCY_KEY_NAME`] /
26895 // [`HELM_CHART_DEPENDENCY_KEY_VERSION`] /
26896 // [`HELM_CHART_DEPENDENCY_KEY_REPOSITORY`] /
26897 // [`HELM_CHART_DEPENDENCY_KEY_ALIAS`]) mounts one level down.
26898 assert_eq!(HELM_CHART_KEY_DEPENDENCIES, "dependencies");
26899 }
26900
26901 #[test]
26902 fn helm_chart_key_dependencies_is_byte_distinct_from_per_dep_sub_mapping_tetrad() {
26903 // Structural distinctness invariant on the per-Chart.yaml
26904 // `dependencies:` parent list-container axis-key vs. the four
26905 // already-lifted per-entry sub-mapping keys mounted one level
26906 // down. The parent+children pair spans two schema-nested YAML
26907 // levels — the top-level `dependencies:` list-container and
26908 // the per-entry sub-mapping `{name, version, repository,
26909 // alias}` — and Helm's chart-schema parser navigates them as
26910 // two structurally-independent axes: a collapse of the parent
26911 // axis-key onto any child (e.g. an accidental future rebrand
26912 // that renamed the [`HELM_CHART_KEY_DEPENDENCIES`] value to
26913 // `"name"` or `"version"`) would either drop the entire per-
26914 // chart dep list at the top-level parse (the child scalar
26915 // silently masks the parent list-container the schema expects)
26916 // or read the top-level list under a scalar-shaped axis-key
26917 // and reject the chart at `helm lint` with a shape mismatch
26918 // far from the drift site. Same "parent list-container
26919 // axis-key must remain byte-distinct from every child sub-
26920 // mapping axis-key" discipline the peer
26921 // [`SUPERVISOR_KEY_CHILDREN`] parent axis-key already carries
26922 // against the sibling [`SUPERVISOR_CHILD_KEY_CAIXA`] /
26923 // [`SUPERVISOR_CHILD_KEY_VERSAO`] / [`SUPERVISOR_CHILD_KEY_RESTART`]
26924 // per-entry sub-mapping triad on the M2 typed
26925 // `:supervisor :children` surface — extends the discipline onto
26926 // the Helm 3 `Chart.yaml` per-chart-dependency-list surface.
26927 for child in [
26928 HELM_CHART_DEPENDENCY_KEY_NAME,
26929 HELM_CHART_DEPENDENCY_KEY_VERSION,
26930 HELM_CHART_DEPENDENCY_KEY_REPOSITORY,
26931 HELM_CHART_DEPENDENCY_KEY_ALIAS,
26932 ] {
26933 assert_ne!(
26934 HELM_CHART_KEY_DEPENDENCIES, child,
26935 "HELM_CHART_KEY_DEPENDENCIES \
26936 ({HELM_CHART_KEY_DEPENDENCIES:?}) must remain \
26937 byte-distinct from every per-`dependencies[]`-entry \
26938 sub-mapping key ({child:?}) — a collapse silently \
26939 orphans the parent list-container at `helm lint` / \
26940 `helm dependency build` time"
26941 );
26942 }
26943 }
26944
26945 #[test]
26946 fn helm_chart_dependency_key_tetrad_pins_canonical_values() {
26947 // Byte-string pin on the per-`dependencies[]`-entry sub-mapping
26948 // YAML axis-key tetrad the Helm 3 chart-schema pins for every
26949 // per-dep entry the substrate emits under the top-level
26950 // `dependencies:` list at every rendered `lareira-<nome>`
26951 // Chart.yaml. The four axis-keys name the four load-bearing
26952 // per-dep sub-mapping fields Helm's per-dep resolver consumes
26953 // at `helm dependency build` / `helm dependency update` time:
26954 // `name` (the Helm-registry chart name), `version` (the SemVer-
26955 // range constraint), `repository` (the registry URL to fetch
26956 // from), and `alias` (the per-dep values wrap-key override).
26957 // A drift on any const's value (a typo on this lift, a case
26958 // flip to `"Name"` / `"Version"` / `"Repository"` / `"Alias"`,
26959 // an accidental collapse onto a sibling axis-key) would
26960 // silently rebrand the wire key at the `caixa_helm::ChartYaml`
26961 // emitter site — Helm's chart-schema parser silently drops
26962 // the drifted per-dep sub-mapping field, and the per-dep
26963 // resolver falls back to the parsed-shape defaults
26964 // (`""` / wildcard `*` / "no repository defined") at
26965 // `helm dependency build` time far from the drift site. Peer
26966 // to [`supervisor_child_key_tetrad_pins_canonical_values`] on
26967 // the sibling per-`:children` sub-mapping tetrad (ef912df) and
26968 // [`entrada_key_tetrad_pins_canonical_values`] on the sibling
26969 // per-`:entrada` sub-mapping tetrad (a3d6162).
26970 assert_eq!(HELM_CHART_DEPENDENCY_KEY_NAME, "name");
26971 assert_eq!(HELM_CHART_DEPENDENCY_KEY_VERSION, "version");
26972 assert_eq!(HELM_CHART_DEPENDENCY_KEY_REPOSITORY, "repository");
26973 assert_eq!(HELM_CHART_DEPENDENCY_KEY_ALIAS, "alias");
26974 }
26975
26976 #[test]
26977 fn helm_chart_dependency_key_name_matches_kube_key_name() {
26978 // Load-bearing byte-shape coincidence between the Helm 3
26979 // Chart.yaml per-`dependencies[]`-entry sub-mapping name key
26980 // ([`HELM_CHART_DEPENDENCY_KEY_NAME`]) and the K8s CR
26981 // per-`metadata` sub-mapping name key ([`KUBE_KEY_NAME`]) —
26982 // Helm inherits the K8s CR body-key vocabulary at every schema
26983 // surface it consumes (chart-metadata top-level, per-CR
26984 // install-payload, per-dep dependency-list). The two axes are
26985 // structurally-independent schema surfaces (the Helm 3
26986 // chart-schema per-dep entry vs. the K8s apiserver-side CR
26987 // metadata block) whose byte-shapes happen to coincide today;
26988 // this pin makes the byte-shape coincidence load-bearing
26989 // rather than accidental so a future K8s-side rebrand at
26990 // [`KUBE_KEY_NAME`] (or a Helm-side rebrand at
26991 // [`HELM_CHART_DEPENDENCY_KEY_NAME`]) that dropped the
26992 // byte-identity would fail the pin at substrate-build time
26993 // rather than as a silent Helm-per-dep-resolver drop at
26994 // `helm dependency build` time far from the drift site. Same
26995 // discipline as the peer
26996 // [`helm_chart_key_api_version_matches_kube_key_api_version`]
26997 // pin on the sibling top-level chart-schema-apiVersion axis
26998 // (cc44e4b) — extends the axis-key byte-identity coincidence
26999 // discipline from the per-Chart.yaml top-level shape onto the
27000 // per-`dependencies[]`-entry sub-mapping shape.
27001 assert_eq!(
27002 HELM_CHART_DEPENDENCY_KEY_NAME, KUBE_KEY_NAME,
27003 "HELM_CHART_DEPENDENCY_KEY_NAME ({HELM_CHART_DEPENDENCY_KEY_NAME:?}) \
27004 must remain byte-identical to KUBE_KEY_NAME ({KUBE_KEY_NAME:?}) — \
27005 Helm 3 inherits the K8s CR body-key vocabulary at every schema \
27006 surface, and every downstream consumer that navigates a per-dep \
27007 sub-mapping / a K8s CR metadata block by the `name` key reads the \
27008 byte-identical `\"name\"` key; a drift on either side silently \
27009 reroutes the consumer through a schema-parser drop far from the \
27010 drift site"
27011 );
27012 }
27013
27014 #[test]
27015 fn helm_chart_readme_filename_pins_canonical_value() {
27016 // Pin the actual byte-string so a typo on the canonical lift
27017 // can't silently rebrand the third leg of the per-`lareira-<nome>`
27018 // chart-directory `{Chart.yaml, values.yaml, README.md}`
27019 // canonical-per-chart-directory-filename axis triple. Peer to
27020 // the sibling
27021 // [`HELM_CHART_YAML_FILENAME`] / [`HELM_VALUES_YAML_FILENAME`]
27022 // canonical filename axes — the two schema-load-bearing halves
27023 // of the triple the sibling
27024 // [`HELM_VALUES_YAML_FILENAME`] docstring's closing paragraph
27025 // explicitly names as the pair that needed the third-leg
27026 // (`README.md`) filename half to close the discipline across
27027 // every `ChartFile` the [`caixa_helm::render_chart_for_servico`]
27028 // emitter's `ChartDir::files` vec carries. A drifted per-chart
27029 // readme filename value would surface downstream as GitHub /
27030 // Artifact Hub / any per-chart README-surfacing UI silently
27031 // falling back to "no README available" for the rendered
27032 // `lareira-<nome>` chart — the chart lists with no per-chart
27033 // elevator pitch or install instructions far from the drift
27034 // commit's source, with no field naming the readme-filename-
27035 // drift root cause. Same pin discipline as the peer
27036 // canonical-Helm-per-chart-directory-filename axes.
27037 assert_eq!(HELM_CHART_README_FILENAME, "README.md");
27038 }
27039
27040 #[test]
27041 fn helm_chart_readme_filename_carries_readme_dot_md_shape() {
27042 // Cross-axis invariant: the per-`lareira-<nome>`-chart-directory
27043 // human-facing readme filename carries the `.md` Markdown
27044 // extension the [`caixa_helm::build_readme`] emitter's Markdown-
27045 // shaped body targets — a drift to `.txt` / `.rst` /
27046 // extensionless / a per-fork rename would silently reroute the
27047 // rendered readme through a downstream tool that reads by
27048 // extension for its Markdown renderer (GitHub's per-repo README
27049 // surfacer, Artifact Hub's per-chart README surfacer, every
27050 // per-chart-directory `find . -name README.md` navigator any
27051 // downstream tooling might use). Peer to the sibling
27052 // [`HELM_CHART_YAML_FILENAME`] / [`HELM_VALUES_YAML_FILENAME`]
27053 // schema-load-bearing filename halves — the two YAML halves
27054 // carry the `.yaml` extension per Helm's per-chart-schema
27055 // convention; the readme half carries the `.md` extension per
27056 // the substrate's per-chart human-facing convention. Distinct
27057 // per-half schema conventions do not collapse on the shared
27058 // `<name>.<ext>` shape gate.
27059 let v = HELM_CHART_README_FILENAME;
27060 assert!(
27061 !v.is_empty(),
27062 "HELM_CHART_README_FILENAME {v:?} must be non-empty per the \
27063 per-`lareira-<nome>`-chart-directory readme-file axis"
27064 );
27065 assert!(
27066 v.ends_with(".md"),
27067 "HELM_CHART_README_FILENAME {v:?} must carry the `.md` \
27068 Markdown extension per the substrate's per-chart human-\
27069 facing readme convention — a drifted extension (`.txt` / \
27070 `.rst` / extensionless) would silently reroute downstream \
27071 tooling's Markdown renderer (GitHub's per-repo README \
27072 surfacer, Artifact Hub's per-chart README surfacer) to a \
27073 non-Markdown fallback path"
27074 );
27075 }
27076
27077 // ── lareira-<nome> chart-name prefix lift ──────────────────────
27078 //
27079 // The lift pins the substrate-wide `lareira-` chart-name prefix
27080 // as the single source of truth every per-Servico renderer
27081 // (caixa-helm, caixa-flux, caixa-tatara) reaches for, peer to the
27082 // [`DEFAULT_NAMESPACE`] (a085b26) lift on the canonical-namespace
27083 // axis. Pinning the prefix value, the helper's
27084 // construction-shape, and the DNS-1123-label round-trip for the
27085 // canonical-fixture input forms the structural floor every future
27086 // renderer consumer inherits by construction.
27087
27088 #[test]
27089 fn lareira_chart_name_prefix_pins_canonical_value() {
27090 // Pin the actual string value so a typo on the canonical lift
27091 // can't silently rebrand the substrate's per-Servico Helm chart
27092 // namespace. The string is part of the contract with the OCI
27093 // chart-publishing pipeline (`oci://<registry>/lareira-<nome>`),
27094 // the per-cluster HelmRelease `chart:` field (which Flux
27095 // resolves through the OCI ref), and the historical
27096 // `pleme-io/helmworks/charts/lareira-<name>/` source tree
27097 // layout (caixa-helm/src/lib.rs:7); changing it is a
27098 // coordinated multi-repo migration, not an incidental edit.
27099 // Peer to `default_namespace_pins_canonical_value` on the
27100 // canonical-string-value-pin axis for the
27101 // `DEFAULT_NAMESPACE` constant.
27102 assert_eq!(LAREIRA_CHART_NAME_PREFIX, "lareira-");
27103 }
27104
27105 #[test]
27106 fn lareira_chart_name_composes_prefix_and_nome() {
27107 // Pin the helper's construction shape — the chart name is the
27108 // prefix concatenated with the caixa's `:nome` verbatim, with
27109 // no intermediate hyphen, no path separator, no trimming. Pin
27110 // the canonical hello-rio fixture (the in-tree
27111 // `caixa-helm` test fixture at caixa-helm/src/lib.rs:431
27112 // already asserts `dir.name == "lareira-hello-rio"`, which
27113 // this helper now derives) and a peer fixture
27114 // (`checkout-aplicacao` member) to sweep the typical author
27115 // surface.
27116 assert_eq!(lareira_chart_name("hello-rio"), "lareira-hello-rio");
27117 assert_eq!(lareira_chart_name("cart"), "lareira-cart");
27118 assert_eq!(lareira_chart_name("worker"), "lareira-worker");
27119 }
27120
27121 #[test]
27122 fn lareira_chart_name_starts_with_prefix() {
27123 // Cross-axis invariant: every output of the helper begins with
27124 // the lifted prefix verbatim — a future refactor that
27125 // accidentally introduced a different prefix-application
27126 // shape (e.g. `format!("{nome}-lareira")` transposition, or a
27127 // `to_uppercase()` case fold) would surface here. The
27128 // structural pin holds for the empty `:nome` shape too
27129 // (a value `validate_nome` rejects upstream, but the helper
27130 // itself imposes no shape on the input).
27131 for nome in ["hello-rio", "cart", "worker", "a", ""] {
27132 let chart = lareira_chart_name(nome);
27133 assert!(
27134 chart.starts_with(LAREIRA_CHART_NAME_PREFIX),
27135 "lareira_chart_name({nome:?}) = {chart:?} must start with the lifted prefix \
27136 {LAREIRA_CHART_NAME_PREFIX:?}"
27137 );
27138 }
27139 }
27140
27141 #[test]
27142 fn lareira_chart_name_round_trips_through_dns_1123_for_validated_nome() {
27143 // Cross-axis invariant: every `:nome` past
27144 // [`Caixa::validate_nome`] (6c992f8) is a valid DNS-1123 label,
27145 // and the prepended `lareira-` segment is itself a valid
27146 // DNS-1123 label prefix (lowercase ASCII + hyphen with a
27147 // terminating-hyphen continuation). The composition therefore
27148 // round-trips through [`is_dns_1123_label`] for every
27149 // `:nome` whose joint length with the prefix stays ≤ 63 bytes
27150 // (the DNS-1123 label cap). The canonical author surface sits
27151 // far below that cap (the in-tree fixtures range from
27152 // `"a"` = 9-byte chart name to `"checkout"` = 16 bytes, with
27153 // the cap admitting up to 55-byte `:nome` values). Pin the
27154 // round-trip for the canonical-fixture set so a future renderer
27155 // that lands the helper's output verbatim as a K8s
27156 // `metadata.name` (caixa-helm's `ChartDir.name`,
27157 // caixa-flux's HelmRelease `chart:` field, caixa-tatara's
27158 // `release_name`) inherits the apiserver-valid floor by
27159 // construction.
27160 for nome in ["hello-rio", "cart", "worker", "checkout", "a"] {
27161 let chart = lareira_chart_name(nome);
27162 assert!(
27163 is_dns_1123_label(&chart).is_ok(),
27164 "lareira_chart_name({nome:?}) = {chart:?} must be a valid DNS-1123 label"
27165 );
27166 }
27167 }
27168
27169 #[test]
27170 fn lareira_chart_name_prefix_is_a_valid_dns_1123_segment_continuation() {
27171 // The lifted prefix is one substring of the rendered chart
27172 // name; pin its grammar so a future rebrand can't land a
27173 // value that would invalidate the joint DNS-1123 label
27174 // structurally. The prefix must:
27175 // - be lowercase ASCII alphanumeric + hyphen (the DNS-1123
27176 // accepted set), so its bytes don't widen the joint
27177 // accepted set;
27178 // - end with a hyphen (so the concatenation slot doesn't
27179 // accidentally merge with the leading character of the
27180 // `:nome` it precedes).
27181 assert!(
27182 LAREIRA_CHART_NAME_PREFIX
27183 .bytes()
27184 .all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'-'),
27185 "LAREIRA_CHART_NAME_PREFIX {LAREIRA_CHART_NAME_PREFIX:?} must use only DNS-1123-label \
27186 bytes (lowercase ASCII alphanumeric + hyphen)"
27187 );
27188 assert!(
27189 LAREIRA_CHART_NAME_PREFIX.ends_with('-'),
27190 "LAREIRA_CHART_NAME_PREFIX {LAREIRA_CHART_NAME_PREFIX:?} must end with `-` so \
27191 concatenation with the caixa's `:nome` produces a hyphenated joint label"
27192 );
27193 }
27194
27195 // ── is_lareira_chart_name_shape — joint-length budget on `:nome` ─────
27196 //
27197 // The canonical [`lareira_chart_name`] helper's own doc comment
27198 // (f7320d7) explicitly defers: "the M4 admission webhook will pin
27199 // the joint-length invariant when it lands". These tests land it
27200 // at the manifest-validate layer instead — the predicate consults
27201 // [`lareira_chart_name`] + [`is_dns_1123_label`] (no third primitive)
27202 // so a future rebrand of either axis re-derives the budget
27203 // mechanically and the test suite re-pins through the same lifts.
27204
27205 #[test]
27206 fn lareira_chart_name_nome_max_len_pins_arithmetic() {
27207 // Pin the arithmetic so a future shift in either input axis
27208 // surfaces here. The const is mechanically derived from
27209 // [`DNS_1123_LABEL_MAX_LEN`] (63 — the K8s apiserver cap every
27210 // chart-name-derived `metadata.name` inherits) minus
27211 // [`LAREIRA_CHART_NAME_PREFIX`].len() (8 — the canonical
27212 // chart-name prefix the lift f7320d7 made structural). The
27213 // landing value: 55 bytes the caixa's `:nome` may itself
27214 // occupy under the joint chart-name cap.
27215 assert_eq!(LAREIRA_CHART_NAME_NOME_MAX_LEN, 55);
27216 assert_eq!(
27217 LAREIRA_CHART_NAME_NOME_MAX_LEN,
27218 DNS_1123_LABEL_MAX_LEN - LAREIRA_CHART_NAME_PREFIX.len()
27219 );
27220 }
27221
27222 #[test]
27223 fn is_lareira_chart_name_shape_accepts_canonical_fixtures() {
27224 // Positive control: every in-tree fixture `:nome` (caixa-helm,
27225 // caixa-flux, caixa-mesh, caixa-tatara tests, the
27226 // checkout-aplicacao example) sits far below the cap. The
27227 // predicate must not regress this baseline shape.
27228 for nome in [
27229 "hello-rio",
27230 "cart",
27231 "worker",
27232 "checkout",
27233 "a",
27234 "akeyless-attest",
27235 ] {
27236 is_lareira_chart_name_shape(nome).unwrap_or_else(|e| {
27237 panic!("canonical :nome {nome:?} must pass chart-name budget, got {e:?}")
27238 });
27239 }
27240 }
27241
27242 #[test]
27243 fn is_lareira_chart_name_shape_accepts_nome_at_budget() {
27244 // Boundary-accepting case at the 55-byte cap — the joint
27245 // chart name is exactly 63 bytes, the DNS-1123 label cap.
27246 let at_cap = "a".repeat(LAREIRA_CHART_NAME_NOME_MAX_LEN);
27247 assert_eq!(at_cap.len(), LAREIRA_CHART_NAME_NOME_MAX_LEN);
27248 is_lareira_chart_name_shape(&at_cap).unwrap();
27249 assert_eq!(lareira_chart_name(&at_cap).len(), DNS_1123_LABEL_MAX_LEN);
27250 }
27251
27252 #[test]
27253 fn is_lareira_chart_name_shape_rejects_nome_one_over_budget() {
27254 // Fail-before-pass-after pin: 56 bytes is the smallest `:nome`
27255 // length that overflows the joint chart-name cap. The inner
27256 // [`is_dns_1123_label`] check accepts it (56 ≤ 63), so prior
27257 // to this gate it silently passed `Caixa::validate_nome` and
27258 // surfaced as a `helm lint` / apiserver rejection on the
27259 // rendered chart name far from the source caixa.lisp.
27260 let over = "a".repeat(LAREIRA_CHART_NAME_NOME_MAX_LEN + 1);
27261 let err = is_lareira_chart_name_shape(&over).unwrap_err();
27262 assert!(
27263 err.contains("63") && err.contains("64") && err.contains("55"),
27264 "diagnostic must name the DNS-1123 cap (63), the actual chart-name length (64), \
27265 and the per-`:nome` budget (55), got {err:?}"
27266 );
27267 assert!(
27268 err.contains("lareira-"),
27269 "diagnostic must name the canonical prefix verbatim, got {err:?}"
27270 );
27271 }
27272
27273 #[test]
27274 fn is_lareira_chart_name_shape_diagnostic_carries_offending_chart_name() {
27275 // The rendered chart name appears verbatim in the diagnostic
27276 // so the author sees exactly the string the apiserver would
27277 // have rejected — no re-derivation required to grep the source.
27278 let over = "x".repeat(LAREIRA_CHART_NAME_NOME_MAX_LEN + 5);
27279 let err = is_lareira_chart_name_shape(&over).unwrap_err();
27280 let expected_chart = lareira_chart_name(&over);
27281 assert!(
27282 err.contains(&expected_chart),
27283 "diagnostic must carry the rendered chart name {expected_chart:?} verbatim, \
27284 got {err:?}"
27285 );
27286 }
27287
27288 #[test]
27289 fn is_lareira_chart_name_shape_composes_through_canonical_helper() {
27290 // Cross-axis invariant: the predicate is defined exactly as
27291 // `is_dns_1123_label(lareira_chart_name(nome))` for the length
27292 // arm — no inline `format!("lareira-{nome}")` shape duplicating
27293 // the canonical lift. Pinning this composition closes the
27294 // drift footgun where a future predicate refactor re-inlines
27295 // the prefix-and-`:nome` concatenation and diverges from the
27296 // canonical helper. Sweep across the boundary so both sides
27297 // (accept + reject) consult the same helper.
27298 for delta in 0..=2usize {
27299 let nome = "z".repeat(LAREIRA_CHART_NAME_NOME_MAX_LEN.saturating_sub(delta));
27300 let predicate_ok = is_lareira_chart_name_shape(&nome).is_ok();
27301 let canonical_ok = is_dns_1123_label(&lareira_chart_name(&nome)).is_ok();
27302 assert_eq!(
27303 predicate_ok,
27304 canonical_ok,
27305 "predicate / canonical-composition divergence for :nome of len {} \
27306 (predicate_ok = {predicate_ok}, canonical_ok = {canonical_ok})",
27307 nome.len()
27308 );
27309 }
27310 }
27311
27312 // ── OCI chart-ref composer — `oci://<registry>/lareira-<nome>` ───────
27313 //
27314 // Peer to the `lareira_chart_name` composer above on the sibling
27315 // OCI-artifact-reference axis. Until this lift landed the
27316 // `caixa-tatara`'s `derive_chart_ref` carried an inline
27317 // `format!("oci://{registry}/{chart}")` — a 2-axis composition
27318 // (the `oci://` scheme prefix + the `lareira-<nome>` chart name)
27319 // whose byte-shape had no compile-time link to the historical doc
27320 // comments across `caixa-core`, `caixa-flux`, `caixa-helm`, and
27321 // `caixa-tatara` promising the same shape. Pin the const, the
27322 // composition equation, and the byte-shape against the prior
27323 // inline `format!` so a future composer-internal drift fires at
27324 // test time.
27325
27326 #[test]
27327 fn oci_scheme_prefix_pins_canonical_value() {
27328 // Pin the actual string value so a typo on the canonical lift
27329 // can't silently rebrand the substrate's OCI-artifact-reference
27330 // scheme. The string is part of the contract with the Helm 3
27331 // OCI storage protocol (`helm push chart.tgz oci://…`,
27332 // `helm registry login <registry>`, `helm install release
27333 // oci://…`) and the FluxCD `HelmRepository` `type: oci` source
27334 // (Flux source-controller keys off this literal on the OCI
27335 // path); changing it is a coordinated multi-repo migration,
27336 // not an incidental edit. Peer to
27337 // [`lareira_chart_name_prefix_pins_canonical_value`] on the
27338 // sibling canonical-string-value-pin axis.
27339 assert_eq!(OCI_SCHEME_PREFIX, "oci://");
27340 }
27341
27342 #[test]
27343 fn oci_chart_ref_pins_byte_shape_against_prior_inline_format() {
27344 // Byte-shape pin against the prior inline
27345 // `format!("oci://{registry}/{chart}")` at
27346 // caixa-tatara/src/lib.rs:202 (where `chart` was itself
27347 // `lareira_chart_name(caixa.nome.as_str())`). Any future
27348 // composer-internal drift on either axis (the `oci://` scheme
27349 // prefix, the `/` scheme-authority separator, the composition
27350 // with `lareira_chart_name`) surfaces here as a byte-shape
27351 // regression rather than at cluster-apply time far from the
27352 // drift site.
27353 assert_eq!(
27354 oci_chart_ref("ghcr.io/pleme-io/charts", "akeyless-attest"),
27355 "oci://ghcr.io/pleme-io/charts/lareira-akeyless-attest"
27356 );
27357 assert_eq!(
27358 oci_chart_ref("ghcr.io/pleme-io", "hello-rio"),
27359 "oci://ghcr.io/pleme-io/lareira-hello-rio"
27360 );
27361 }
27362
27363 #[test]
27364 fn oci_chart_ref_composes_through_canonical_helpers() {
27365 // Structural composition equation: the OCI chart-ref is
27366 // exactly `{OCI_SCHEME_PREFIX}{registry}/{lareira_chart_name(nome)}`
27367 // — no inline `"oci://"` scheme literal, no inline
27368 // `format!("lareira-{}", nome)` prefix duplication. Pinning
27369 // this composition closes the drift footgun where a future
27370 // composer refactor re-inlines either axis and diverges from
27371 // its canonical source of truth. Sweep across the canonical
27372 // fixture set so the composition holds for the same `:nome`
27373 // values every peer per-Servico renderer consults.
27374 for (registry, nome) in [
27375 ("ghcr.io/pleme-io/charts", "hello-rio"),
27376 ("ghcr.io/pleme-io", "cart"),
27377 ("registry.example.com", "worker"),
27378 ("localhost:5000", "checkout"),
27379 ] {
27380 let composed = oci_chart_ref(registry, nome);
27381 let expected = format!("{OCI_SCHEME_PREFIX}{registry}/{}", lareira_chart_name(nome));
27382 assert_eq!(
27383 composed, expected,
27384 "oci_chart_ref({registry:?}, {nome:?}) must equal the canonical composition \
27385 through OCI_SCHEME_PREFIX + lareira_chart_name"
27386 );
27387 }
27388 }
27389
27390 #[test]
27391 fn oci_chart_ref_starts_with_scheme_prefix() {
27392 // Cross-axis invariant: every output of the composer begins
27393 // with the lifted scheme prefix verbatim — a future refactor
27394 // that accidentally introduced a different scheme (e.g. a
27395 // `https://` transposition, or a scheme-authority separator
27396 // drift) would surface here. Peer to
27397 // [`lareira_chart_name_starts_with_prefix`] on the sibling
27398 // per-composer prefix-anchoring axis.
27399 for (registry, nome) in [
27400 ("ghcr.io/pleme-io/charts", "hello-rio"),
27401 ("ghcr.io/pleme-io", "cart"),
27402 ("localhost:5000", "a"),
27403 ] {
27404 let composed = oci_chart_ref(registry, nome);
27405 assert!(
27406 composed.starts_with(OCI_SCHEME_PREFIX),
27407 "oci_chart_ref({registry:?}, {nome:?}) = {composed:?} must start with the lifted \
27408 prefix {OCI_SCHEME_PREFIX:?}"
27409 );
27410 }
27411 }
27412
27413 #[test]
27414 fn oci_chart_ref_contains_lareira_chart_name_verbatim() {
27415 // Cross-axis invariant: every output of the composer contains
27416 // the canonical `lareira_chart_name(nome)` output verbatim as
27417 // its trailing segment — a future refactor that accidentally
27418 // introduced a case fold, a hyphen-collapse, or a different
27419 // prefix-application shape would surface here. Structurally
27420 // pins that the OCI chart-ref path and the peer per-Servico
27421 // renderer chart-name path (caixa-helm's `ChartDir.name`,
27422 // caixa-flux's `HelmRelease` `chart:` field) both reach for
27423 // the same canonical `lareira_chart_name` helper's output.
27424 for (registry, nome) in [
27425 ("ghcr.io/pleme-io/charts", "hello-rio"),
27426 ("ghcr.io/pleme-io", "cart"),
27427 ] {
27428 let composed = oci_chart_ref(registry, nome);
27429 let chart = lareira_chart_name(nome);
27430 assert!(
27431 composed.ends_with(&chart),
27432 "oci_chart_ref({registry:?}, {nome:?}) = {composed:?} must end with the canonical \
27433 lareira_chart_name({nome:?}) = {chart:?}"
27434 );
27435 }
27436 }
27437
27438 // ── Flux Kustomization source-sub-tree composer ───────────────────────
27439 //
27440 // Peer to the `oci_chart_ref` / `cilium_network_policy_name` /
27441 // `gateway_api_http_route_name` composers above on the sibling
27442 // canonical-load-bearing-scalar-that-consumers-key-off axis. Until
27443 // this lift landed the two-axis composition
27444 // (`./clusters/<cluster>/services/<nome>`) sat as an inline
27445 // `format!` template at the sole `caixa-flux::cluster_bundle`
27446 // `kustomization.yaml` production emit site plus a mirror-symmetric
27447 // inline `format!` at its paired test-fixture navigation site — no
27448 // compile-time link between the two sites and no compile-time link
27449 // ahead of the second production-emit occurrence the M4
27450 // `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
27451 // `Kustomization` synthesis will surface. Pin the byte-shape, the
27452 // composition equation, and the sub-tree-scope invariants against
27453 // the prior inline `format!` so a future composer-internal drift
27454 // fires at test time.
27455
27456 #[test]
27457 fn flux_kustomization_source_subtree_pins_byte_shape_against_prior_inline_format() {
27458 // Byte-shape pin against the prior inline
27459 // `format!("./clusters/{cluster}/services/{name}")` at
27460 // caixa-flux/src/lib.rs (both the `cluster_bundle`
27461 // `kustomization.yaml` `spec.path` production emit site and the
27462 // paired `cluster_bundle_kustomization_path_pins_lifted_sub_tree`
27463 // test-fixture navigation site). Any future composer-internal
27464 // drift on either axis (the `./clusters/` per-cluster prefix,
27465 // the `/services/` per-caixa infix, the trailing per-caixa
27466 // suffix, the composition order) surfaces here as a byte-shape
27467 // regression rather than at cluster-apply time far from the
27468 // drift site.
27469 assert_eq!(
27470 flux_kustomization_source_subtree("rio", "hello-rio"),
27471 "./clusters/rio/services/hello-rio"
27472 );
27473 assert_eq!(
27474 flux_kustomization_source_subtree("paris", "cart"),
27475 "./clusters/paris/services/cart"
27476 );
27477 assert_eq!(
27478 flux_kustomization_source_subtree("tokyo", "checkout"),
27479 "./clusters/tokyo/services/checkout"
27480 );
27481 }
27482
27483 #[test]
27484 fn flux_kustomization_source_subtree_starts_with_relative_clusters_prefix() {
27485 // Structural invariant: every output starts with the canonical
27486 // `./clusters/` per-cluster-prefix half of the sub-tree seed.
27487 // The leading `./` scopes the emit to the GitRepository root
27488 // (the kustomize-controller keys the per-CR reconcile loop off
27489 // the GitRepository the paired `sourceRef` names, so the sub-
27490 // tree seed must resolve relative to the GitRepository root,
27491 // not an absolute filesystem path). The `clusters/` component
27492 // scopes the emit to the paired cluster's manifest set under
27493 // the pleme-io k8s repository's canonical directory-tree
27494 // layout.
27495 for (cluster, nome) in [
27496 ("rio", "hello-rio"),
27497 ("paris", "cart"),
27498 ("tokyo", "checkout"),
27499 ] {
27500 let sub = flux_kustomization_source_subtree(cluster, nome);
27501 assert!(
27502 sub.starts_with("./clusters/"),
27503 "flux_kustomization_source_subtree({cluster:?}, {nome:?}) = {sub:?} must start \
27504 with the canonical `./clusters/` GitRepository-root-relative per-cluster prefix"
27505 );
27506 }
27507 }
27508
27509 #[test]
27510 fn flux_kustomization_source_subtree_contains_paired_cluster_and_nome() {
27511 // Cross-axis invariant: every output contains the paired
27512 // `<cluster>` and `<nome>` scalars verbatim, at their canonical
27513 // per-cluster / per-caixa sub-tree positions. A future
27514 // composer-internal drift that accidentally case-folded, hyphen-
27515 // collapsed, or transposed either axis (`./clusters/rio/services/hello-rio`
27516 // → `./clusters/hello-rio/services/rio` under a swapped
27517 // composition, `./clusters/Rio/services/HelloRio` under an
27518 // accidental case fold) would surface here as a structural
27519 // regression rather than at cluster-apply time far from the
27520 // drift site.
27521 for (cluster, nome) in [
27522 ("rio", "hello-rio"),
27523 ("paris", "cart"),
27524 ("tokyo", "checkout"),
27525 ("us-east-1", "worker"),
27526 ] {
27527 let sub = flux_kustomization_source_subtree(cluster, nome);
27528 assert!(
27529 sub.contains(&format!("/clusters/{cluster}/")),
27530 "flux_kustomization_source_subtree({cluster:?}, {nome:?}) = {sub:?} must carry \
27531 the paired `<cluster>` scalar under its canonical per-cluster sub-tree position"
27532 );
27533 assert!(
27534 sub.ends_with(&format!("/services/{nome}")),
27535 "flux_kustomization_source_subtree({cluster:?}, {nome:?}) = {sub:?} must end with \
27536 the paired `/services/<nome>` per-caixa sub-tree suffix"
27537 );
27538 }
27539 }
27540
27541 #[test]
27542 fn flux_kustomization_source_subtree_distinct_across_clusters_and_nomes() {
27543 // Uniqueness invariant: two distinct `(cluster, nome)` inputs
27544 // resolve to two distinct `spec.path` scalars. A composer-
27545 // internal drift that accidentally coalesced either axis onto
27546 // a constant (dropping `<cluster>` or `<nome>` from the emit)
27547 // would silently collapse two per-cluster / per-caixa
27548 // `Kustomization` CRs onto the same reconcile-target sub-tree,
27549 // routing two distinct manifest sets through the same apply
27550 // loop with no diagnostic naming the coalesce root cause.
27551 let a = flux_kustomization_source_subtree("rio", "hello-rio");
27552 let b = flux_kustomization_source_subtree("paris", "hello-rio");
27553 let c = flux_kustomization_source_subtree("rio", "cart");
27554 assert_ne!(
27555 a, b,
27556 "distinct clusters (`rio` vs `paris`) hosting the same per-caixa Servico \
27557 must resolve to distinct `spec.path` scalars — coalesce would silently route \
27558 two per-cluster reconcile loops through the same manifest sub-tree"
27559 );
27560 assert_ne!(
27561 a, c,
27562 "distinct per-caixa Servicos (`hello-rio` vs `cart`) co-resident under the \
27563 same cluster must resolve to distinct `spec.path` scalars — coalesce would \
27564 silently route two per-caixa reconcile loops through the same manifest sub-tree"
27565 );
27566 }
27567
27568 #[test]
27569 fn pleme_program_selector_carries_only_program() {
27570 let sel = pleme_program_selector("cart");
27571 assert_eq!(sel.len(), 1);
27572 assert_eq!(sel.get(LABEL_PROGRAM).map(String::as_str), Some("cart"));
27573 assert!(sel.get(LABEL_APLICACAO).is_none());
27574 }
27575
27576 #[test]
27577 fn pleme_program_in_aplicacao_selector_carries_both_axes() {
27578 let sel = pleme_program_in_aplicacao_selector("cart", "checkout");
27579 assert_eq!(sel.len(), 2);
27580 assert_eq!(sel.get(LABEL_PROGRAM).map(String::as_str), Some("cart"));
27581 assert_eq!(
27582 sel.get(LABEL_APLICACAO).map(String::as_str),
27583 Some("checkout")
27584 );
27585 }
27586
27587 #[test]
27588 fn pleme_program_in_aplicacao_selector_iterates_alphabetically() {
27589 // BTreeMap iteration is sorted by key — pin that the renderer
27590 // (which translates the selector into a serde_yaml::Mapping
27591 // by iteration) gets a deterministic key order. `aplicacao`
27592 // sorts before `program`, so the rendered YAML's
27593 // `matchLabels:` block appears in that order regardless of
27594 // call-site arg order. Mirrors the M2 overlay helper's
27595 // alphabetical-iteration determinism property
27596 // (THEORY.md §V.2.7 render determinism).
27597 let sel = pleme_program_in_aplicacao_selector("cart", "checkout");
27598 let keys: Vec<_> = sel.keys().copied().collect();
27599 assert_eq!(keys, vec![LABEL_APLICACAO, LABEL_PROGRAM]);
27600 }
27601
27602 #[test]
27603 fn pleme_program_in_aplicacao_selector_arg_order_independent() {
27604 // Renaming the program vs. the aplicacao must each only affect
27605 // its own axis — pin that the helper doesn't transpose its
27606 // args silently (a footgun the prior inline-string approach
27607 // had: `program: <de>` and `aplicacao: <name>` were two
27608 // adjacent insert() calls with structurally identical arms,
27609 // trivially swappable in a refactor).
27610 let sel = pleme_program_in_aplicacao_selector("cart", "checkout");
27611 assert_eq!(sel.get(LABEL_PROGRAM).map(String::as_str), Some("cart"));
27612 assert_eq!(
27613 sel.get(LABEL_APLICACAO).map(String::as_str),
27614 Some("checkout")
27615 );
27616 let swapped = pleme_program_in_aplicacao_selector("checkout", "cart");
27617 assert_eq!(
27618 swapped.get(LABEL_PROGRAM).map(String::as_str),
27619 Some("checkout")
27620 );
27621 assert_eq!(
27622 swapped.get(LABEL_APLICACAO).map(String::as_str),
27623 Some("cart")
27624 );
27625 }
27626
27627 #[test]
27628 fn yaml_string_mapping_empty_input_returns_empty_mapping() {
27629 // Empty input → empty Mapping. Pinned because the caller's
27630 // emptiness contract (e.g. caixa-mesh's CNP labels block: the
27631 // policy's metadata.labels exists iff there are pleme-prefixed
27632 // labels to carry) depends on this being faithful.
27633 let v: serde_yaml::Value = yaml_string_mapping(BTreeMap::<&'static str, String>::new());
27634 let m = v.as_mapping().expect("mapping shape");
27635 assert!(m.is_empty());
27636 }
27637
27638 #[test]
27639 fn yaml_string_mapping_round_trips_string_values() {
27640 let mut input = BTreeMap::new();
27641 input.insert("foo", "1".to_string());
27642 input.insert("bar", "2".to_string());
27643 let v = yaml_string_mapping(input);
27644 let m = v.as_mapping().expect("mapping shape");
27645 assert_eq!(m.len(), 2);
27646 assert_eq!(m.get("foo").and_then(|x| x.as_str()), Some("1"));
27647 assert_eq!(m.get("bar").and_then(|x| x.as_str()), Some("2"));
27648 }
27649
27650 #[test]
27651 fn yaml_string_mapping_iterates_alphabetically_on_btreemap() {
27652 // Pin that BTreeMap input → alphabetical iteration → alphabetical
27653 // YAML key order. THEORY.md §V.2.7 render determinism.
27654 let mut input = BTreeMap::new();
27655 input.insert("zebra", "z".to_string());
27656 input.insert("apple", "a".to_string());
27657 input.insert("mango", "m".to_string());
27658 let v = yaml_string_mapping(input);
27659 let m = v.as_mapping().expect("mapping shape");
27660 let keys: Vec<&str> = m.iter().filter_map(|(k, _)| k.as_str()).collect();
27661 assert_eq!(keys, vec!["apple", "mango", "zebra"]);
27662 }
27663
27664 #[test]
27665 fn yaml_string_mapping_accepts_pleme_selector_helpers() {
27666 // The lift's load-bearing use case: passing the typed pleme-io
27667 // selectors directly into yaml_string_mapping yields the K8s
27668 // matchLabels surface every Cilium / Gateway selector field
27669 // expects, with the alphabetical key order the pleme helpers'
27670 // own determinism contract guarantees. Pinning end-to-end
27671 // composition so a future refactor of either helper can't
27672 // silently break the integration.
27673 let v = yaml_string_mapping(pleme_program_in_aplicacao_selector("cart", "checkout"));
27674 let m = v.as_mapping().expect("mapping shape");
27675 assert_eq!(m.len(), 2);
27676 assert_eq!(m.get(LABEL_PROGRAM).and_then(|x| x.as_str()), Some("cart"));
27677 assert_eq!(
27678 m.get(LABEL_APLICACAO).and_then(|x| x.as_str()),
27679 Some("checkout")
27680 );
27681 }
27682
27683 #[test]
27684 fn kube_key_consts_have_expected_values() {
27685 // Pin the actual string values — these are part of the K8s API
27686 // surface that every emitted artifact's apiserver-side parser
27687 // (Cilium, Gateway API, wasm-operator) depends on. Changing any
27688 // of them is a coordinated multi-renderer migration, not an
27689 // incidental edit.
27690 assert_eq!(KUBE_KEY_API_VERSION, "apiVersion");
27691 assert_eq!(KUBE_KEY_KIND, "kind");
27692 assert_eq!(KUBE_KEY_METADATA, "metadata");
27693 assert_eq!(KUBE_KEY_NAME, "name");
27694 assert_eq!(KUBE_KEY_NAMESPACE, "namespace");
27695 assert_eq!(KUBE_KEY_LABELS, "labels");
27696 assert_eq!(KUBE_KEY_MATCH_LABELS, "matchLabels");
27697 assert_eq!(KUBE_KEY_PORT, "port");
27698 assert_eq!(KUBE_KEY_PROTOCOL, "protocol");
27699 assert_eq!(KUBE_KEY_RULES, "rules");
27700 assert_eq!(KUBE_KEY_SPEC, "spec");
27701 }
27702
27703 #[test]
27704 fn fleet_programs_key_programs_pins_canonical_value() {
27705 // Bridge-arm pin: [`FLEET_PROGRAMS_KEY_PROGRAMS`] resolves to
27706 // the canonical `"programs"` byte today — the exact YAML key
27707 // the `lareira-fleet-programs` library chart's `values.yaml`
27708 // reads under `.Values.programs[]` to iterate one `ComputeUnit`
27709 // CR per entry, and the exact key both writer-side upsert paths
27710 // in [`caixa_flux`] (`upsert_into_helmrelease_programs` on the
27711 // aggregator-HelmRelease shape, `upsert_into_programs_yaml` on
27712 // the bare-values.yaml shape) navigate to walk the entry
27713 // sequence. Pin the literal here (peer with the
27714 // [`M3_KEY_PLACEMENT`] / [`M2_KEY_LIMITS`] /
27715 // [`M2_KEY_BEHAVIOR`] / [`M2_KEY_UPGRADE_FROM`] canonical-
27716 // literal pins on the sibling fleet-programs / M2 overlay
27717 // schema-key surfaces) so a future fleet-programs schema-key
27718 // rebrand surfaces here as a coordinated edit-point: the
27719 // sibling caixa-flux `fleet_programs_key_programs_re_export_
27720 // points_at_caixa_core_canonical` pinning test already pins
27721 // the equality at the re-export axis; this pin closes the
27722 // second coordinate of the triangle by anchoring the lifted
27723 // constant's current byte to the canonical fleet-programs
27724 // library chart's documented shape.
27725 assert_eq!(FLEET_PROGRAMS_KEY_PROGRAMS, "programs");
27726 }
27727
27728 #[test]
27729 fn fleet_programs_key_name_pins_canonical_value() {
27730 // Bridge-arm pin: [`FLEET_PROGRAMS_KEY_NAME`] resolves to the
27731 // canonical `"name"` byte today — the exact YAML key the
27732 // `lareira-fleet-programs` library chart's `range .Values.programs`
27733 // step reads per-entry to key each rendered `ComputeUnit` CR's
27734 // `metadata.name` off, and the exact key both writer-side upsert
27735 // paths in [`caixa_flux`] (`upsert_into_helmrelease_programs` on
27736 // the aggregator-HelmRelease shape, `upsert_into_programs_yaml`
27737 // on the bare-values.yaml shape) navigate to
27738 // match-by-name-and-replace-or-append, and the exact key both
27739 // emit-side entry builders ([`caixa_flux::programs_yaml_entry`]
27740 // per-Servico, [`caixa_mesh::programs_for_aplicacao`] per-
27741 // `:membros`) write the per-entry name-axis at. Pin the literal
27742 // here (peer with the [`fleet_programs_key_programs_pins_canonical_value`]
27743 // top-level array-key canonical-literal pin on the sibling
27744 // fleet-programs schema surface, and with the
27745 // [`M3_KEY_PLACEMENT`] / [`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`]
27746 // / [`M2_KEY_UPGRADE_FROM`] canonical-literal pins on the peer
27747 // per-entry overlay-key surfaces) so a future fleet-programs
27748 // schema-key rebrand on the per-entry name-discriminator axis
27749 // surfaces here as a coordinated edit-point at the definition
27750 // site rather than a silent apply-time split between the two
27751 // emitters and the two upsert readers.
27752 assert_eq!(FLEET_PROGRAMS_KEY_NAME, "name");
27753 }
27754
27755 #[test]
27756 fn fleet_programs_key_aplicacao_pins_canonical_value() {
27757 // Bridge-arm pin: [`FLEET_PROGRAMS_KEY_APLICACAO`] resolves
27758 // to the canonical `"aplicacao"` byte today — the exact YAML
27759 // key the substrate operator's fleet-aggregator reads to
27760 // group each rendered `programs[]` entry back onto its parent
27761 // Aplicacao graph, and the exact key the
27762 // [`caixa_mesh::programs_for_aplicacao`] per-`:membros`
27763 // entry-builder writes the parent-Aplicacao-nome annotation
27764 // at. Pin the literal here (peer with the sibling
27765 // [`fleet_programs_key_name_pins_canonical_value`] and
27766 // [`fleet_programs_key_programs_pins_canonical_value`]
27767 // canonical-literal pins on the peer fleet-programs schema
27768 // key surfaces, and with the [`M3_KEY_PLACEMENT`] /
27769 // [`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] /
27770 // [`M2_KEY_UPGRADE_FROM`] pins on the per-entry overlay-key
27771 // surfaces) so a future fleet-programs schema-key rebrand
27772 // on the per-entry parent-graph-annotation axis surfaces
27773 // here as a coordinated edit-point at the definition site
27774 // rather than a silent apply-time split between the
27775 // caixa-mesh Aplicacao-side emitter and the substrate
27776 // operator's per-graph aggregator reduce step.
27777 assert_eq!(FLEET_PROGRAMS_KEY_APLICACAO, "aplicacao");
27778 }
27779
27780 #[test]
27781 fn fleet_programs_key_versao_pins_canonical_value() {
27782 // Bridge-arm pin: [`FLEET_PROGRAMS_KEY_VERSAO`] resolves to
27783 // the canonical `"versao"` byte today — the exact YAML key
27784 // the substrate operator's per-`:membros` resolver reads to
27785 // fetch each `programs[]` entry's caixa.lisp release against
27786 // the M3 Aplicacao's declared per-member semver / range
27787 // constraint, and the exact key the
27788 // [`caixa_mesh::programs_for_aplicacao`] per-`:membros`
27789 // entry-builder writes the version-constraint at. Pin the
27790 // literal here (peer with the sibling
27791 // [`fleet_programs_key_name_pins_canonical_value`],
27792 // [`fleet_programs_key_aplicacao_pins_canonical_value`], and
27793 // [`fleet_programs_key_programs_pins_canonical_value`]
27794 // canonical-literal pins on the peer fleet-programs schema
27795 // key surfaces, and with the [`M3_KEY_PLACEMENT`] /
27796 // [`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] /
27797 // [`M2_KEY_UPGRADE_FROM`] pins on the per-entry overlay-key
27798 // surfaces) so a future fleet-programs schema-key rebrand
27799 // on the per-entry version-constraint axis surfaces here as
27800 // a coordinated edit-point at the definition site rather
27801 // than a silent apply-time split between the caixa-mesh
27802 // Aplicacao-side emitter and the substrate operator's
27803 // per-`:membros` resolver step.
27804 assert_eq!(FLEET_PROGRAMS_KEY_VERSAO, "versao");
27805 }
27806
27807 // ── label_selector — typed K8s LabelSelector wrapper ─────────────────
27808
27809 #[test]
27810 fn label_selector_wraps_in_match_labels_envelope() {
27811 // The lift's contract: input labels appear under the canonical
27812 // `matchLabels` key, and the outer Value is a Mapping with
27813 // exactly that one key. Pinning the shape so a future
27814 // refactor can't silently drop the wrapper (which would emit
27815 // bare `aplicacao: …, program: …` directly under the K8s
27816 // selector field — a structurally invalid LabelSelector that
27817 // some apiserver-side parsers tolerate by matching the empty
27818 // set, a sharp footgun).
27819 let mut labels = BTreeMap::new();
27820 labels.insert(LABEL_APLICACAO, "checkout".to_string());
27821 labels.insert(LABEL_PROGRAM, "cart".to_string());
27822 let sel = label_selector(labels);
27823 let m = sel.as_mapping().expect("mapping shape");
27824 assert_eq!(m.len(), 1);
27825 let inner = m
27826 .get(KUBE_KEY_MATCH_LABELS)
27827 .and_then(|v| v.as_mapping())
27828 .expect("matchLabels inner mapping");
27829 assert_eq!(inner.len(), 2);
27830 assert_eq!(
27831 inner.get(LABEL_APLICACAO).and_then(|x| x.as_str()),
27832 Some("checkout")
27833 );
27834 assert_eq!(
27835 inner.get(LABEL_PROGRAM).and_then(|x| x.as_str()),
27836 Some("cart")
27837 );
27838 }
27839
27840 #[test]
27841 fn label_selector_empty_input_yields_empty_match_labels() {
27842 // Empty input → `{matchLabels: {}}`. The outer wrapper is
27843 // present (the K8s LabelSelector schema requires it as a
27844 // structural anchor, and apiserver-side parsers that see a
27845 // bare `{}` selector match-everything; pinning the wrapper
27846 // means an empty pleme-io selector at the call site renders
27847 // as the canonical "no labels declared, match nothing
27848 // specific" shape rather than an outright missing key).
27849 let v: serde_yaml::Value = label_selector(BTreeMap::<&'static str, String>::new());
27850 let m = v.as_mapping().expect("mapping shape");
27851 assert_eq!(m.len(), 1);
27852 let inner = m
27853 .get(KUBE_KEY_MATCH_LABELS)
27854 .and_then(|v| v.as_mapping())
27855 .expect("matchLabels inner mapping");
27856 assert!(inner.is_empty());
27857 }
27858
27859 #[test]
27860 fn label_selector_accepts_pleme_selector_helpers() {
27861 // The lift's load-bearing use case: passing the typed pleme-io
27862 // selectors directly into `label_selector` yields the K8s
27863 // LabelSelector shape every Cilium / Gateway / future
27864 // app-operator selector field expects. Pinning end-to-end
27865 // composition so a future refactor of either helper can't
27866 // silently break the integration.
27867 let v = label_selector(pleme_program_in_aplicacao_selector("cart", "checkout"));
27868 let inner = v
27869 .as_mapping()
27870 .and_then(|m| m.get(KUBE_KEY_MATCH_LABELS))
27871 .and_then(|v| v.as_mapping())
27872 .expect("matchLabels inner mapping");
27873 assert_eq!(inner.len(), 2);
27874 assert_eq!(
27875 inner.get(LABEL_PROGRAM).and_then(|x| x.as_str()),
27876 Some("cart")
27877 );
27878 assert_eq!(
27879 inner.get(LABEL_APLICACAO).and_then(|x| x.as_str()),
27880 Some("checkout")
27881 );
27882
27883 // Single-axis variant — only LABEL_PROGRAM under matchLabels.
27884 let v = label_selector(pleme_program_selector("cart"));
27885 let inner = v
27886 .as_mapping()
27887 .and_then(|m| m.get(KUBE_KEY_MATCH_LABELS))
27888 .and_then(|v| v.as_mapping())
27889 .unwrap();
27890 assert_eq!(inner.len(), 1);
27891 assert_eq!(
27892 inner.get(LABEL_PROGRAM).and_then(|x| x.as_str()),
27893 Some("cart")
27894 );
27895 }
27896
27897 #[test]
27898 fn label_selector_inner_iterates_alphabetically_on_btreemap() {
27899 // BTreeMap input → alphabetical iteration → alphabetical YAML
27900 // key order under `matchLabels`. THEORY.md §V.2.7 render
27901 // determinism: the rendered YAML's matchLabels: block appears
27902 // in a deterministic order independent of source-code
27903 // declaration order.
27904 let mut input = BTreeMap::new();
27905 input.insert("zebra", "z".to_string());
27906 input.insert("apple", "a".to_string());
27907 input.insert("mango", "m".to_string());
27908 let v = label_selector(input);
27909 let inner = v
27910 .as_mapping()
27911 .and_then(|m| m.get(KUBE_KEY_MATCH_LABELS))
27912 .and_then(|v| v.as_mapping())
27913 .unwrap();
27914 let keys: Vec<&str> = inner.iter().filter_map(|(k, _)| k.as_str()).collect();
27915 assert_eq!(keys, vec!["apple", "mango", "zebra"]);
27916 }
27917
27918 #[test]
27919 fn label_selector_does_not_introduce_match_expressions_axis() {
27920 // V0 emits matchLabels only — pinning that the helper doesn't
27921 // pre-insert an empty `matchExpressions: []` block (which some
27922 // apiserver-side parsers tolerate but renders noisily and
27923 // shifts the per-rule diff). A future set-based selector
27924 // extension is a deliberate API change to this helper, not an
27925 // incidental shape leak.
27926 let v = label_selector(pleme_program_selector("cart"));
27927 let m = v.as_mapping().unwrap();
27928 assert!(
27929 m.get("matchExpressions").is_none(),
27930 "label_selector must not pre-insert a matchExpressions key (V0 is matchLabels-only)"
27931 );
27932 }
27933
27934 #[test]
27935 fn kube_resource_skeleton_carries_three_top_level_keys_no_spec() {
27936 // The skeleton emits exactly apiVersion + kind + metadata; the
27937 // caller adds spec (and any other top-level keys) themselves.
27938 // Pin that contract so a future caller doesn't accidentally
27939 // double-insert apiVersion / kind / metadata after the
27940 // skeleton call. Namespace fixture arg reads through the
27941 // canonical `DEFAULT_NAMESPACE` const so a future rebrand of
27942 // the substrate's default namespace reaches every fixture by
27943 // construction rather than through a per-fixture stray
27944 // "tatara-system" byte-sequence.
27945 let skel = kube_resource_skeleton(
27946 "cilium.io/v2",
27947 "CiliumNetworkPolicy",
27948 "p-1",
27949 DEFAULT_NAMESPACE,
27950 BTreeMap::new(),
27951 );
27952 assert_eq!(skel.len(), 3);
27953 assert_eq!(
27954 skel.get(KUBE_KEY_API_VERSION).and_then(|v| v.as_str()),
27955 Some("cilium.io/v2")
27956 );
27957 assert_eq!(
27958 skel.get(KUBE_KEY_KIND).and_then(|v| v.as_str()),
27959 Some("CiliumNetworkPolicy")
27960 );
27961 assert!(skel.get(KUBE_KEY_METADATA).is_some());
27962 }
27963
27964 #[test]
27965 fn kube_resource_skeleton_metadata_carries_name_and_namespace() {
27966 let skel = kube_resource_skeleton(
27967 "gateway.networking.k8s.io/v1",
27968 "Gateway",
27969 "checkout",
27970 DEFAULT_NAMESPACE,
27971 BTreeMap::new(),
27972 );
27973 let metadata = skel
27974 .get(KUBE_KEY_METADATA)
27975 .and_then(|v| v.as_mapping())
27976 .expect("metadata mapping");
27977 assert_eq!(
27978 metadata.get(KUBE_KEY_NAME).and_then(|v| v.as_str()),
27979 Some("checkout")
27980 );
27981 // Read-back probe reads through `DEFAULT_NAMESPACE` so a
27982 // future substrate-namespace rebrand routes through the
27983 // canonical const on both the emit-side fixture arg and the
27984 // probe-side readback in one edit — a drift on either side
27985 // would otherwise silently mask the round-trip pin.
27986 assert_eq!(
27987 metadata.get(KUBE_KEY_NAMESPACE).and_then(|v| v.as_str()),
27988 Some(DEFAULT_NAMESPACE)
27989 );
27990 }
27991
27992 #[test]
27993 fn kube_resource_skeleton_omits_labels_when_empty() {
27994 // Empty labels → metadata.labels key absent (NOT present-as-empty).
27995 // K8s API server treats a missing labels key as "no labels
27996 // declared"; an empty-mapping `labels: {}` serializes
27997 // differently in some YAML libraries and is a sharp tool for
27998 // label-based selectors that match the empty set silently.
27999 let skel = kube_resource_skeleton(
28000 "gateway.networking.k8s.io/v1",
28001 "HTTPRoute",
28002 "r-1",
28003 DEFAULT_NAMESPACE,
28004 BTreeMap::new(),
28005 );
28006 let metadata = skel
28007 .get(KUBE_KEY_METADATA)
28008 .and_then(|v| v.as_mapping())
28009 .unwrap();
28010 assert!(
28011 metadata.get(KUBE_KEY_LABELS).is_none(),
28012 "metadata.labels must be absent when no labels passed"
28013 );
28014 // metadata then has exactly 2 keys: name, namespace.
28015 assert_eq!(metadata.len(), 2);
28016 }
28017
28018 #[test]
28019 fn kube_resource_skeleton_includes_labels_when_present() {
28020 let mut labels = BTreeMap::new();
28021 labels.insert(LABEL_APLICACAO, "checkout".to_string());
28022 labels.insert(LABEL_CONTRATO, "cart-to-catalog".to_string());
28023 let skel = kube_resource_skeleton(
28024 "cilium.io/v2",
28025 "CiliumNetworkPolicy",
28026 "p-1",
28027 DEFAULT_NAMESPACE,
28028 labels,
28029 );
28030 let metadata = skel
28031 .get(KUBE_KEY_METADATA)
28032 .and_then(|v| v.as_mapping())
28033 .unwrap();
28034 let labels_block = metadata
28035 .get(KUBE_KEY_LABELS)
28036 .and_then(|v| v.as_mapping())
28037 .expect("metadata.labels mapping present");
28038 assert_eq!(
28039 labels_block.get(LABEL_APLICACAO).and_then(|v| v.as_str()),
28040 Some("checkout")
28041 );
28042 assert_eq!(
28043 labels_block.get(LABEL_CONTRATO).and_then(|v| v.as_str()),
28044 Some("cart-to-catalog")
28045 );
28046 }
28047
28048 #[test]
28049 fn kube_resource_skeleton_metadata_iterates_alphabetically() {
28050 // Pin that the inner BTreeMap projection makes the rendered
28051 // YAML's metadata: block alphabetical (labels, name, namespace),
28052 // regardless of insert order. THEORY.md §V.2.7 render determinism.
28053 let mut labels = BTreeMap::new();
28054 labels.insert(LABEL_APLICACAO, "checkout".to_string());
28055 let skel = kube_resource_skeleton(
28056 "cilium.io/v2",
28057 "CiliumNetworkPolicy",
28058 "p-1",
28059 DEFAULT_NAMESPACE,
28060 labels,
28061 );
28062 let metadata = skel
28063 .get(KUBE_KEY_METADATA)
28064 .and_then(|v| v.as_mapping())
28065 .unwrap();
28066 let keys: Vec<&str> = metadata.iter().filter_map(|(k, _)| k.as_str()).collect();
28067 assert_eq!(
28068 keys,
28069 vec![KUBE_KEY_LABELS, KUBE_KEY_NAME, KUBE_KEY_NAMESPACE]
28070 );
28071 }
28072
28073 #[test]
28074 fn kube_resource_skeleton_top_level_iterates_in_insert_order() {
28075 // The top-level Mapping is a plain serde_yaml::Mapping (insert-
28076 // ordered), and the skeleton inserts apiVersion → kind →
28077 // metadata in that order. Pin so a future refactor doesn't
28078 // silently shift the rendered YAML's top-level key order
28079 // (which K8s tooling tolerates but humans + diff readability
28080 // care about — apiVersion-first is the K8s convention).
28081 let skel = kube_resource_skeleton(
28082 "cilium.io/v2",
28083 "CiliumNetworkPolicy",
28084 "p-1",
28085 DEFAULT_NAMESPACE,
28086 BTreeMap::new(),
28087 );
28088 let keys: Vec<&str> = skel.iter().filter_map(|(k, _)| k.as_str()).collect();
28089 assert_eq!(
28090 keys,
28091 vec![KUBE_KEY_API_VERSION, KUBE_KEY_KIND, KUBE_KEY_METADATA]
28092 );
28093 }
28094
28095 #[test]
28096 fn kube_resource_skeleton_does_not_introduce_spec_key() {
28097 // Sanity: the skeleton is metadata-only — `spec` is the caller's
28098 // responsibility. Pinning so a future "be helpful" refactor
28099 // doesn't auto-insert an empty `spec: {}` (which would silently
28100 // shadow caller-side spec construction).
28101 let skel = kube_resource_skeleton(
28102 "cilium.io/v2",
28103 "CiliumNetworkPolicy",
28104 "p-1",
28105 DEFAULT_NAMESPACE,
28106 BTreeMap::new(),
28107 );
28108 assert!(
28109 skel.get("spec").is_none(),
28110 "skeleton must not pre-insert a spec key"
28111 );
28112 }
28113
28114 // ── require_kind / KindMismatch — typed kind-check predicate ─────
28115
28116 #[test]
28117 fn require_kind_accepts_matching_kind() {
28118 // A Servico-kind caixa passes a `require_kind(_, Servico)`
28119 // check — the happy path every renderer sees on a correctly-
28120 // authored caixa.lisp, surfaced as `Ok(())` so the renderer's
28121 // call site reads as a one-liner gate rather than a typed
28122 // pattern match.
28123 let c = bare_servico();
28124 require_kind(&c, CaixaKind::Servico).unwrap();
28125 }
28126
28127 #[test]
28128 fn require_kind_rejects_with_typed_mismatch() {
28129 // A Biblioteca-kind caixa fails a `require_kind(_, Servico)`
28130 // check with a typed [`KindMismatch`] view that names the
28131 // offending caixa's `:nome` plus both the expected and actual
28132 // kinds. Pinning the typed shape so a future Display-format
28133 // tweak can't silently drop any of the three load-bearing
28134 // fields (which would regress the "feira verb whose error
28135 // path doesn't name the offending caixa" punch-list item the
28136 // protocol calls out).
28137 let mut c = bare_servico();
28138 c.kind = CaixaKind::Biblioteca;
28139 c.servicos = vec![];
28140 let err = require_kind(&c, CaixaKind::Servico).unwrap_err();
28141 assert_eq!(err.nome, "hello-rio");
28142 assert_eq!(err.expected, CaixaKind::Servico);
28143 assert_eq!(err.actual, CaixaKind::Biblioteca);
28144 }
28145
28146 #[test]
28147 fn require_kind_routes_offending_nome_via_caixa_nome_accessor() {
28148 // Pin: the [`KindMismatch::nome`] `String` the constructor
28149 // writes must be a byte-identical copy of what the lifted
28150 // [`crate::Caixa::nome`] accessor returns for the same
28151 // [`Caixa`] input — the same discipline the sibling
28152 // [`crate::LayoutInvariants::verify`] wrap-envelope emitters
28153 // pin at 9842a4b's `expected_nome_via_accessor` line (the
28154 // routing pin the 31-site converge introduced on the substrate's
28155 // own layout-invariant verifier's per-axis diagnostic emitters).
28156 //
28157 // Guardrails a future regression that re-inlines the raw
28158 // `caixa.nome.clone()` `String::clone()` of the underlying
28159 // field at the constructor site — the accessor's borrow
28160 // return + typed `.to_string()` `String` promotion is the
28161 // one canonical shape the substrate's own [`KindMismatch`]
28162 // typed-view constructor carries onto every downstream
28163 // renderer's `Error::From<KindMismatch>` `#[from]` arm, so
28164 // any drift (a byte-non-identical shape, e.g. a future
28165 // `CaixaNome` newtype the [`crate::Caixa::nome`] accessor
28166 // upgrades to project the display byte-string of, that
28167 // `.nome.clone()` would silently ignore) surfaces here
28168 // before the drift lands on a per-renderer `#[from]` arm.
28169 let mut c = bare_servico();
28170 c.kind = CaixaKind::Biblioteca;
28171 c.servicos = vec![];
28172 c.nome = "kind-mismatch-pin".into();
28173 let expected_nome_via_accessor = c.nome().to_string();
28174 assert_eq!(
28175 expected_nome_via_accessor, "kind-mismatch-pin",
28176 "the mutated fixture's `:nome` must be observable through \
28177 the accessor before the kind-mismatch gate fires",
28178 );
28179 let err = require_kind(&c, CaixaKind::Servico).unwrap_err();
28180 assert_eq!(
28181 err.nome, expected_nome_via_accessor,
28182 "the KindMismatch's `nome` field must equal \
28183 `caixa.nome().to_string()` — the typed-view constructor \
28184 must route through the lifted [`Caixa::nome`] accessor's \
28185 `.to_string()` extension, not the raw `caixa.nome.clone()` \
28186 `String::clone()` of the underlying field",
28187 );
28188 }
28189
28190 #[test]
28191 fn kind_mismatch_display_names_offending_caixa_nome() {
28192 // The Display impl is the load-bearing surface every renderer's
28193 // `#[error("{0}")] NotAXKind(#[from] KindMismatch)` arm prints
28194 // through. Pinning the exact rendered form so a future format
28195 // change is a one-line edit + a one-line test update, not a
28196 // silent regression of the diagnostic clarity.
28197 let err = KindMismatch {
28198 nome: "checkout".into(),
28199 expected: CaixaKind::Aplicacao,
28200 actual: CaixaKind::Servico,
28201 };
28202 let msg = format!("{err}");
28203 assert!(
28204 msg.contains("checkout"),
28205 "Display must name the offending caixa nome (got: {msg:?})"
28206 );
28207 assert!(
28208 msg.contains("Aplicacao"),
28209 "Display must name the expected kind (got: {msg:?})"
28210 );
28211 assert!(
28212 msg.contains("Servico"),
28213 "Display must name the actual kind (got: {msg:?})"
28214 );
28215 }
28216
28217 #[test]
28218 fn require_kind_distinguishes_every_pair_of_kinds() {
28219 // Sanity: the predicate is kind-axis-agnostic — it works for
28220 // every kind / expected pair, not just Servico/Biblioteca.
28221 // Pinning that the caller can use `require_kind` for any of
28222 // the five typed kinds (Biblioteca, Binario, Servico,
28223 // Supervisor, Aplicacao) without a special-cased helper per
28224 // kind. Same idiom every per-target renderer key off.
28225 let mut c = bare_servico();
28226 c.kind = CaixaKind::Aplicacao;
28227 c.servicos = vec![];
28228 let err = require_kind(&c, CaixaKind::Supervisor).unwrap_err();
28229 assert_eq!(err.expected, CaixaKind::Supervisor);
28230 assert_eq!(err.actual, CaixaKind::Aplicacao);
28231 require_kind(&c, CaixaKind::Aplicacao).unwrap();
28232 }
28233
28234 // ── require_ci / MissingCiSlot — Acao `:ci`-slot-presence gate ────
28235
28236 fn bare_acao_without_ci() -> Caixa {
28237 let mut c = bare_servico();
28238 c.kind = CaixaKind::Acao;
28239 c.servicos = vec![];
28240 c.ci = None;
28241 c
28242 }
28243
28244 fn sample_ci_run() -> canteiro_types::CiRun {
28245 canteiro_types::CiRun {
28246 workspace: "pleme-io".into(),
28247 repo: "caixa".into(),
28248 nodes: vec![],
28249 }
28250 }
28251
28252 #[test]
28253 fn require_ci_accepts_present_slot_and_returns_borrowed_ci_run() {
28254 // The happy path: an Acao-kind caixa that declares its `:ci`
28255 // slot passes `require_ci`, and the borrowed
28256 // [`canteiro_types::CiRun`] projected through the successful
28257 // return is the same author-declared value the caller was about
28258 // to bind — folding the check and the bind onto one call site,
28259 // matching how every present + roadmapped per-`Acao` consumer
28260 // uses the slot.
28261 let mut c = bare_acao_without_ci();
28262 c.ci = Some(sample_ci_run());
28263 let ci = require_ci(&c).expect("Acao with declared :ci passes");
28264 assert_eq!(ci.workspace, "pleme-io");
28265 assert_eq!(ci.repo, "caixa");
28266 }
28267
28268 #[test]
28269 fn require_ci_rejects_absent_slot_with_typed_view() {
28270 // The fail-before-pass-after pin: pre-lift `caixa-actions`'
28271 // inline `.ok_or_else(|| Error::MissingCi { nome:
28272 // caixa.nome().to_string() })` gate constructed an
28273 // `Error::MissingCi { nome: String }` at exactly one crate's
28274 // call site with no compile-time link to any typed named-caixa
28275 // view the sibling per-renderer entry-gate axes carry. A future
28276 // per-`Acao` consumer (the deferred `sui-supercacheci::canteiro
28277 // ::emit_gha` workflow renderer named in the `caixa-actions`
28278 // crate docs, the future per-`Acao` CR materializer) would
28279 // re-inline the same `.ok_or_else(...)` construction on its own
28280 // call site and open a second untracked `nome: String`-carry
28281 // path — exactly the "feira verb whose error path doesn't name
28282 // the offending caixa" punch-list item the compounding-mandate
28283 // protocol calls out. Lifting the gate onto the typed
28284 // [`MissingCiSlot`] view + [`require_ci`] predicate closes the
28285 // drift potential structurally: every future per-`Acao`
28286 // consumer reaches for the same one-liner + `#[from]` and gets
28287 // the diagnostic-naming-the-offending-caixa contract for free.
28288 let c = bare_acao_without_ci();
28289 let err = require_ci(&c).unwrap_err();
28290 assert_eq!(err.nome, "hello-rio");
28291 }
28292
28293 #[test]
28294 fn require_ci_routes_offending_nome_via_caixa_nome_accessor() {
28295 // Pin: the [`MissingCiSlot::nome`] `String` the constructor
28296 // writes must be a byte-identical copy of what the lifted
28297 // [`crate::Caixa::nome`] accessor returns for the same
28298 // [`Caixa`] input — the same routing pin discipline the peer
28299 // [`require_kind`] / [`require_single_servico`] typed views
28300 // already carry, so a future regression that re-inlines a raw
28301 // `caixa.nome.clone()` `String::clone()` of the underlying
28302 // field at the constructor site (which would silently ignore
28303 // any future `CaixaNome` newtype the [`crate::Caixa::nome`]
28304 // accessor upgrades to project the display byte-string of)
28305 // trips here before the drift lands on a per-consumer `#[from]`
28306 // arm.
28307 let mut c = bare_acao_without_ci();
28308 c.nome = "missing-ci-pin".into();
28309 let expected_nome_via_accessor = c.nome().to_string();
28310 assert_eq!(
28311 expected_nome_via_accessor, "missing-ci-pin",
28312 "the mutated fixture's `:nome` must be observable through \
28313 the accessor before the `:ci` gate fires",
28314 );
28315 let err = require_ci(&c).unwrap_err();
28316 assert_eq!(
28317 err.nome, expected_nome_via_accessor,
28318 "the MissingCiSlot's `nome` field must equal \
28319 `caixa.nome().to_string()` — the typed-view constructor \
28320 must route through the lifted [`Caixa::nome`] accessor's \
28321 `.to_string()` extension, not the raw `caixa.nome.clone()` \
28322 `String::clone()` of the underlying field",
28323 );
28324 }
28325
28326 #[test]
28327 fn missing_ci_slot_display_names_offending_caixa_nome() {
28328 // The Display impl is the load-bearing surface every per-
28329 // `Acao` consumer's `#[error("{0}")] MissingCi(#[from]
28330 // MissingCiSlot)` arm prints through. Pinning the exact rendered
28331 // form so a future format change is a one-line edit + a one-line
28332 // test update, not a silent regression of the diagnostic
28333 // clarity. Same shape every peer per-axis lift carries.
28334 let err = MissingCiSlot {
28335 nome: "hello-acao".into(),
28336 };
28337 let msg = format!("{err}");
28338 assert!(
28339 msg.contains("hello-acao"),
28340 "Display must name the offending caixa nome (got: {msg:?})"
28341 );
28342 assert!(
28343 msg.contains(":ci"),
28344 "Display must name the missing `:ci` slot (got: {msg:?})"
28345 );
28346 }
28347
28348 // ── CiDecomposeFailure — per-`Acao` decompose-failure diagnostic axis ─
28349
28350 #[test]
28351 fn ci_decompose_failure_carries_offending_nome_and_source_verbatim() {
28352 // Fail-before-pass-after pin on the [`CiDecomposeFailure`] typed
28353 // view: the constructor writes the offending caixa's `:nome`
28354 // (routed through the lifted [`crate::Caixa::nome`] accessor's
28355 // `.to_string()` extension by every consumer) alongside the
28356 // borrowed [`canteiro_types::DecomposeError`] source verbatim,
28357 // so a per-`Acao` consumer that fans on the specific
28358 // decompose-failure arm reaches for `err.source` directly
28359 // rather than re-parsing the Display bytes. Peer of the sibling
28360 // [`MissingCiSlot`] typed view's `nome`-carrying pin — extends
28361 // the same "one typed view per axis, carrying the offending
28362 // caixa's `:nome` + axis-specific detail" discipline onto the
28363 // second per-`Acao` diagnostic axis after the presence-gate
28364 // axis.
28365 let err = CiDecomposeFailure {
28366 nome: "hello-acao".into(),
28367 source: canteiro_types::DecomposeError::Cycle,
28368 };
28369 assert_eq!(err.nome, "hello-acao");
28370 assert_eq!(err.source, canteiro_types::DecomposeError::Cycle);
28371 }
28372
28373 #[test]
28374 fn ci_decompose_failure_display_names_offending_caixa_nome_and_source() {
28375 // The Display impl is the load-bearing surface every per-`Acao`
28376 // consumer's `#[error("{0}")] Decompose(#[from]
28377 // CiDecomposeFailure)` arm prints through. Pinning the exact
28378 // rendered form so a future format change is a one-line edit +
28379 // a one-line test update, not a silent regression of the
28380 // diagnostic clarity — same shape every peer per-axis lift
28381 // carries.
28382 let err = CiDecomposeFailure {
28383 nome: "hello-acao".into(),
28384 source: canteiro_types::DecomposeError::Cycle,
28385 };
28386 let msg = format!("{err}");
28387 assert!(
28388 msg.contains("hello-acao"),
28389 "Display must name the offending caixa nome (got: {msg:?})"
28390 );
28391 assert!(
28392 msg.contains(":ci"),
28393 "Display must name the `:ci` slot the decompose failed on \
28394 (got: {msg:?})"
28395 );
28396 assert!(
28397 msg.contains("decompose"),
28398 "Display must name the decompose axis (got: {msg:?})"
28399 );
28400 }
28401
28402 #[test]
28403 fn ci_decompose_failure_exposes_source_via_error_trait() {
28404 // Pin: the [`CiDecomposeFailure`] type routes its
28405 // [`canteiro_types::DecomposeError`] carrier through the
28406 // `#[source]` [`thiserror::Error`] derive so downstream
28407 // `std::error::Error::source()`-consuming diagnostic frameworks
28408 // (`anyhow`'s chain formatter, `tracing`'s `error!` event
28409 // capture, the future `feira lint` sub-diagnostic emitter) see
28410 // the underlying `DecomposeError` arm through the standard
28411 // trait rather than only through the flattened Display bytes.
28412 // Peer of the sibling per-slot `#[source]` wiring the caixa-*
28413 // renderers already carry on their own typed-view error
28414 // wrappers.
28415 let err = CiDecomposeFailure {
28416 nome: "hello-acao".into(),
28417 source: canteiro_types::DecomposeError::Cycle,
28418 };
28419 let src = std::error::Error::source(&err)
28420 .expect("CiDecomposeFailure must expose its DecomposeError via Error::source()");
28421 // The `Error::source()` trait method returns a `&dyn Error`
28422 // borrow of the underlying `DecomposeError`, so its Display
28423 // bytes must equal the source arm's own Display bytes — a
28424 // future accidental collapse of the `#[source]` wiring (which
28425 // would erase the source chain and force downstream
28426 // `anyhow::Chain` consumers back onto Display re-parsing) trips
28427 // here at caixa-core build time.
28428 let src_msg = format!("{src}");
28429 let expected_msg = format!("{}", canteiro_types::DecomposeError::Cycle);
28430 assert_eq!(src_msg, expected_msg);
28431 }
28432
28433 // ── decompose_ci — per-`Acao` decompose-axis predicate ────────────
28434
28435 fn cyclic_ci_run() -> canteiro_types::CiRun {
28436 // A minimal two-node cycle: `a` depends on `b`, `b` depends on
28437 // `a`. Every failure mode `canteiro_types::decompose` refuses
28438 // (duplicate node name, missing dependency, cycle) would work as
28439 // a fixture; the cycle arm is the same one the `caixa-actions`
28440 // per-`Acao` renderer's own `validate_rejects_a_cyclic_ci_run`
28441 // test already reads for, so both the substrate primitive's own
28442 // pin and the consumer's byte-parity pin share one canonical
28443 // fixture shape.
28444 canteiro_types::CiRun {
28445 workspace: "pleme-io".into(),
28446 repo: "caixa".into(),
28447 nodes: vec![
28448 canteiro_types::CiNode::new(
28449 "a",
28450 canteiro_types::EnvClass::None,
28451 canteiro_types::ActionRef {
28452 name: "a".into(),
28453 command: "true".into(),
28454 args: vec![],
28455 },
28456 vec!["b".into()],
28457 ),
28458 canteiro_types::CiNode::new(
28459 "b",
28460 canteiro_types::EnvClass::None,
28461 canteiro_types::ActionRef {
28462 name: "b".into(),
28463 command: "true".into(),
28464 args: vec![],
28465 },
28466 vec!["a".into()],
28467 ),
28468 ],
28469 }
28470 }
28471
28472 fn linear_ci_run() -> canteiro_types::CiRun {
28473 // A minimal two-node acyclic run: `test` depends on `build`.
28474 // Same shape as the `caixa-actions` `validate_decomposes_a_two_
28475 // node_build_then_test_run` happy-path test — one shared
28476 // canonical fixture for every downstream substrate consumer.
28477 canteiro_types::CiRun {
28478 workspace: "pleme-io".into(),
28479 repo: "caixa".into(),
28480 nodes: vec![
28481 canteiro_types::CiNode::new(
28482 "build",
28483 canteiro_types::EnvClass::None,
28484 canteiro_types::ActionRef {
28485 name: "build".into(),
28486 command: "true".into(),
28487 args: vec![],
28488 },
28489 vec![],
28490 ),
28491 canteiro_types::CiNode::new(
28492 "test",
28493 canteiro_types::EnvClass::None,
28494 canteiro_types::ActionRef {
28495 name: "test".into(),
28496 command: "true".into(),
28497 args: vec![],
28498 },
28499 vec!["build".into()],
28500 ),
28501 ],
28502 }
28503 }
28504
28505 #[test]
28506 fn decompose_ci_accepts_valid_ci_run_and_returns_canteiro_dag() {
28507 // The happy path: a valid two-node acyclic run decomposes
28508 // cleanly through `decompose_ci`, returning the owned
28509 // `canteiro_types::CanteiroDag` the sibling `canteiro_types::
28510 // decompose` returns — the substrate primitive is a
28511 // pass-through on success, only wrapping the error arm in a
28512 // typed named-caixa view. Matches the peer `require_ci`
28513 // presence-axis happy path (accept-with-borrowed-CiRun) —
28514 // extends the "one primitive per axis, pass-through on success"
28515 // discipline onto the decompose axis.
28516 let c = bare_acao_without_ci();
28517 let ci = linear_ci_run();
28518 let cd = decompose_ci(&c, &ci).expect("valid acyclic CiRun decomposes cleanly");
28519 // The topo_order() call on a successful decompose is infallible
28520 // by construction (no cycles present), so a downstream consumer
28521 // reaches for the DAG's own algebra directly rather than a
28522 // second gate. Iterating the returned order (rather than
28523 // asserting on a concrete container shape) keeps the pin
28524 // agnostic to whether topo_order returns Vec<NodeId>,
28525 // SmallVec<NodeId>, or any future returned collection.
28526 let topo = cd
28527 .topo_order()
28528 .expect("acyclic CanteiroDag returns a valid topo_order");
28529 assert_eq!(
28530 topo.iter().count(),
28531 2,
28532 "topo_order on a two-node acyclic run must yield two node ids"
28533 );
28534 }
28535
28536 #[test]
28537 fn decompose_ci_rejects_cyclic_ci_run_with_typed_view() {
28538 // The fail-before-pass-after pin: pre-lift `caixa-actions`'
28539 // inline `.map_err(|source| CiDecomposeFailure { nome: nome
28540 // .clone(), source })` gate constructed a `CiDecomposeFailure`
28541 // at exactly one crate's call site with no compile-time link to
28542 // any typed named-caixa predicate the sibling per-`Acao` /
28543 // per-renderer entry-gate axes carry. A future per-`Acao`
28544 // consumer (the deferred `sui-supercacheci::canteiro::emit_gha`
28545 // workflow renderer named in the `caixa-actions` crate docs, a
28546 // future per-`Acao` CR materializer's admission webhook) would
28547 // re-inline the same `.map_err(...)` construction on its own
28548 // call site and open a second untracked
28549 // `caixa.nome().to_string()` re-projection path — exactly the
28550 // "feira verb whose error path doesn't name the offending
28551 // caixa" punch-list item the compounding-mandate protocol calls
28552 // out. Lifting the gate onto the typed `decompose_ci` predicate
28553 // closes the drift potential structurally: every future
28554 // per-`Acao` consumer reaches for the same one-liner + `#[from]`
28555 // and gets the diagnostic-naming-the-offending-caixa contract
28556 // for free.
28557 let c = bare_acao_without_ci();
28558 let ci = cyclic_ci_run();
28559 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
28560 // `canteiro_types::CanteiroDag`, which does not derive it at the
28561 // pinned sui rev — so the whole caixa-core test target failed to
28562 // COMPILE. A let-else says the same thing without borrowing a
28563 // bound from a foreign type we do not own.
28564 let Err(err) = decompose_ci(&c, &ci) else {
28565 panic!("a cyclic CiRun must fail decompose_ci");
28566 };
28567 assert_eq!(err.nome, "hello-rio");
28568 assert_eq!(err.source, canteiro_types::DecomposeError::Cycle);
28569 }
28570
28571 #[test]
28572 fn decompose_ci_routes_offending_nome_via_caixa_nome_accessor() {
28573 // Pin: the `CiDecomposeFailure::nome` `String` the constructor
28574 // writes must be a byte-identical copy of what the lifted
28575 // `crate::Caixa::nome` accessor returns for the same `Caixa`
28576 // input — the same routing pin discipline the peer
28577 // `require_kind` / `require_single_servico` / `require_ci`
28578 // typed views already carry, so a future regression that
28579 // re-inlines a raw `caixa.nome.clone()` `String::clone()` of
28580 // the underlying field at the constructor site (which would
28581 // silently ignore any future `CaixaNome` newtype the
28582 // `crate::Caixa::nome` accessor upgrades to project the display
28583 // byte-string of) trips here before the drift lands on a
28584 // per-consumer `#[from]` arm.
28585 let mut c = bare_acao_without_ci();
28586 c.nome = "decompose-ci-pin".into();
28587 let expected_nome_via_accessor = c.nome().to_string();
28588 assert_eq!(
28589 expected_nome_via_accessor, "decompose-ci-pin",
28590 "the mutated fixture's `:nome` must be observable through \
28591 the accessor before the decompose gate fires",
28592 );
28593 let ci = cyclic_ci_run();
28594 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
28595 // `canteiro_types::CanteiroDag`, which does not derive it at the
28596 // pinned sui rev — so the whole caixa-core test target failed to
28597 // COMPILE. A let-else says the same thing without borrowing a
28598 // bound from a foreign type we do not own.
28599 let Err(err) = decompose_ci(&c, &ci) else {
28600 panic!("a cyclic CiRun must fail decompose_ci");
28601 };
28602 assert_eq!(
28603 err.nome, expected_nome_via_accessor,
28604 "the CiDecomposeFailure's `nome` field must equal \
28605 `caixa.nome().to_string()` — the `decompose_ci` predicate \
28606 must route through the lifted `Caixa::nome` accessor's \
28607 `.to_string()` extension, not a raw `caixa.nome.clone()` \
28608 `String::clone()` of the underlying field",
28609 );
28610 }
28611
28612 // ── ci_declared_edge_count — per-`Acao` declared-edge-count axis ─
28613
28614 #[test]
28615 fn ci_declared_edge_count_returns_zero_for_leaf_only_run() {
28616 // The empty-edges arm: a `CiRun` whose every node carries an
28617 // empty `deps` list has zero declared edges. Pins the
28618 // `usize::sum()` accumulator's starting value on the
28619 // no-fan-out shape a `caixa-init`-scaffolded `:kind Acao` a
28620 // caixa's stub `:ci` slot lands as before the author wires
28621 // any `deps`. Fail-before-pass-after guard: pre-lift there was
28622 // no substrate primitive, so an author-scaffolded no-deps run
28623 // would have had its `edge_count = 0` re-derived at every
28624 // consumer site through the same open-coded arithmetic. This
28625 // test now anchors the projection to `ci_declared_edge_count`.
28626 let ci = canteiro_types::CiRun {
28627 workspace: "pleme-io".into(),
28628 repo: "caixa".into(),
28629 nodes: vec![
28630 canteiro_types::CiNode::new(
28631 "build",
28632 canteiro_types::EnvClass::None,
28633 canteiro_types::ActionRef {
28634 name: "build".into(),
28635 command: "true".into(),
28636 args: vec![],
28637 },
28638 vec![],
28639 ),
28640 canteiro_types::CiNode::new(
28641 "lint",
28642 canteiro_types::EnvClass::None,
28643 canteiro_types::ActionRef {
28644 name: "lint".into(),
28645 command: "true".into(),
28646 args: vec![],
28647 },
28648 vec![],
28649 ),
28650 ],
28651 };
28652 assert_eq!(
28653 ci_declared_edge_count(&ci),
28654 0,
28655 "a two-leaf-node `:ci` run with empty `deps` lists carries \
28656 zero declared edges — the substrate primitive's `usize` \
28657 accumulator must start at zero and pass through untouched",
28658 );
28659 }
28660
28661 #[test]
28662 fn ci_declared_edge_count_returns_deps_sum_across_nodes() {
28663 // The multi-arity arm: a `CiRun` whose nodes carry `deps`
28664 // lists of arities 0/1/2 has declared-edge-count 3 (0+1+2).
28665 // Pins that the substrate primitive routes the sum through
28666 // *every* node's `deps.len()` rather than only the first
28667 // node's (a future regression that collapsed the `map(...)`
28668 // + `sum()` fold onto a `first()` / `next()` shape would
28669 // silently under-count the declared edges — the arity-3
28670 // fixture surfaces it here before the drift lands on the
28671 // `caixa-actions::validate` production `edge_count` artifact).
28672 let ci = canteiro_types::CiRun {
28673 workspace: "pleme-io".into(),
28674 repo: "caixa".into(),
28675 nodes: vec![
28676 canteiro_types::CiNode::new(
28677 "build",
28678 canteiro_types::EnvClass::None,
28679 canteiro_types::ActionRef {
28680 name: "build".into(),
28681 command: "true".into(),
28682 args: vec![],
28683 },
28684 vec![],
28685 ),
28686 canteiro_types::CiNode::new(
28687 "test",
28688 canteiro_types::EnvClass::None,
28689 canteiro_types::ActionRef {
28690 name: "test".into(),
28691 command: "true".into(),
28692 args: vec![],
28693 },
28694 vec!["build".into()],
28695 ),
28696 canteiro_types::CiNode::new(
28697 "publish",
28698 canteiro_types::EnvClass::None,
28699 canteiro_types::ActionRef {
28700 name: "publish".into(),
28701 command: "true".into(),
28702 args: vec![],
28703 },
28704 vec!["build".into(), "test".into()],
28705 ),
28706 ],
28707 };
28708 assert_eq!(
28709 ci_declared_edge_count(&ci),
28710 3,
28711 "declared-edge-count on a 0/1/2-arity node list is the sum \
28712 (0 + 1 + 2 = 3) — the primitive must fold over every node, \
28713 not just the first / last / any-single-index shape",
28714 );
28715 }
28716
28717 #[test]
28718 fn ci_declared_edge_count_counts_edges_before_decompose_gate() {
28719 // The count-is-shape-only arm: an author-declared *cyclic*
28720 // `:ci` run — the exact fixture `decompose_ci` refuses at the
28721 // sibling axis — still carries its declared edge count as a
28722 // property of the *borrowed run's shape*, not of the owned
28723 // `CanteiroDag` `decompose_ci` (would have) returned. Pins
28724 // that a future consumer that wants the declared-edge summary
28725 // *before* running `decompose_ci` (a `feira lint --acao`
28726 // per-caixa pre-flight report that names the declared edge
28727 // count on both accept + reject arms of the sibling
28728 // `decompose_ci` gate) reads a stable count on both arms.
28729 // The two-node cycle `a → b → a` from `cyclic_ci_run()`
28730 // carries exactly 2 declared edges (one per node's singleton
28731 // `deps`), so the primitive returns 2 without ever routing
28732 // through `canteiro_types::decompose`.
28733 let ci = cyclic_ci_run();
28734 assert_eq!(
28735 ci_declared_edge_count(&ci),
28736 2,
28737 "the two-node cycle carries 2 declared `deps` edges (one \
28738 per node's singleton `deps`) — the primitive must read the \
28739 count off the borrowed run's node-list shape, not off the \
28740 `decompose_ci`-produced `CanteiroDag`'s edge algebra",
28741 );
28742 }
28743
28744 #[test]
28745 fn ci_declared_edge_count_matches_open_coded_sum_across_shapes() {
28746 // Byte-parity pin — the three-path convergence discipline
28747 // every peer per-`Acao` substrate primitive carries: the
28748 // primitive's return must equal the open-coded
28749 // `ci.nodes.iter().map(|n| n.deps.len()).sum::<usize>()`
28750 // expression at each of the three canonical `:ci` run shapes
28751 // this test module already carries (`linear_ci_run` — the
28752 // canonical happy-path with one edge, `cyclic_ci_run` — the
28753 // canonical rejected-by-`decompose_ci` shape with two edges,
28754 // and the empty-edges no-fan-out shape the peer
28755 // `ci_declared_edge_count_returns_zero_for_leaf_only_run`
28756 // fixture reads). Any future refactor of the primitive's fold
28757 // shape trips here before landing on the consumer's
28758 // `RenderedAcao::edge_count` artifact.
28759 for (label, ci) in [
28760 ("linear-two-node", linear_ci_run()),
28761 ("cyclic-two-node", cyclic_ci_run()),
28762 ] {
28763 let via_primitive = ci_declared_edge_count(&ci);
28764 let via_open_coded: usize = ci.nodes.iter().map(|n| n.deps.len()).sum();
28765 assert_eq!(
28766 via_primitive, via_open_coded,
28767 "{label}: `ci_declared_edge_count` must equal the \
28768 open-coded `.nodes.iter().map(|n| n.deps.len()).sum()` \
28769 the two prior `caixa-actions` open-coded sites carried \
28770 — pre-lift regression check",
28771 );
28772 }
28773 }
28774
28775 // ── require_single_servico / ServicoCountMismatch — V0 Servico-shape ─
28776
28777 #[test]
28778 fn require_single_servico_accepts_singleton_list() {
28779 // The happy path: the canonical V0 Servico carries exactly one
28780 // `:servicos` entry (the ComputeUnit YAML pointer), the same
28781 // shape every in-tree fixture + canonical example uses. Surfaced
28782 // as `Ok(())` so the renderer's call site reads as a one-liner
28783 // gate beside the peer [`require_kind`] check rather than a
28784 // typed pattern match.
28785 let c = bare_servico();
28786 assert_eq!(
28787 c.servicos.len(),
28788 1,
28789 "fixture pin: bare_servico() is singleton"
28790 );
28791 require_single_servico(&c).unwrap();
28792 }
28793
28794 #[test]
28795 fn require_single_servico_rejects_empty_list_with_typed_mismatch() {
28796 // A Servico-kind caixa with zero `:servicos` entries fails
28797 // `require_single_servico` with a typed [`ServicoCountMismatch`]
28798 // view that names the offending caixa's `:nome` + the actual
28799 // count (0). Pinning the typed shape so a future Display-format
28800 // tweak can't silently drop either of the two load-bearing
28801 // fields (which would regress the "feira verb whose error path
28802 // doesn't name the offending caixa" punch-list item the protocol
28803 // calls out — same shape every peer per-axis lift carries).
28804 let mut c = bare_servico();
28805 c.servicos = vec![];
28806 let err = require_single_servico(&c).unwrap_err();
28807 assert_eq!(err.nome, "hello-rio");
28808 assert_eq!(err.count, 0);
28809 }
28810
28811 #[test]
28812 fn require_single_servico_rejects_multi_entry_list_with_typed_mismatch() {
28813 // The peer arm on the upper-bound axis: a Servico-kind caixa
28814 // with ≥ 2 `:servicos` entries fails the same gate, with the
28815 // typed view carrying the actual count (2). Both empty and
28816 // multi-entry lists land on the same [`ServicoCountMismatch`]
28817 // arm — the V0 contract requires *exactly* one entry, not
28818 // *at-least* one — so the single helper closes both directions
28819 // of the V0 invariant in one call site.
28820 let mut c = bare_servico();
28821 c.servicos = vec![
28822 "servicos/hello-rio.computeunit.yaml".into(),
28823 "servicos/extra.computeunit.yaml".into(),
28824 ];
28825 let err = require_single_servico(&c).unwrap_err();
28826 assert_eq!(err.nome, "hello-rio");
28827 assert_eq!(err.count, 2);
28828 }
28829
28830 #[test]
28831 fn require_single_servico_routes_offending_nome_via_caixa_nome_accessor() {
28832 // Peer to the sibling
28833 // [`require_kind_routes_offending_nome_via_caixa_nome_accessor`]
28834 // pin on the V0 Servico-shape gate's `:nome`-carry axis:
28835 // the [`ServicoCountMismatch::nome`] `String` the constructor
28836 // writes must be a byte-identical copy of what the lifted
28837 // [`crate::Caixa::nome`] accessor returns. Same 9842a4b-shaped
28838 // routing pin the substrate's own [`crate::LayoutInvariants::verify`]
28839 // wrap-envelope emitters carry, extended here to the second of
28840 // the two [`crate::render`]-module typed-view constructor sites
28841 // that carried a raw `caixa.nome.clone()` `String::clone()`
28842 // field access at the pre-converge state.
28843 let mut c = bare_servico();
28844 c.servicos = vec![];
28845 c.nome = "servico-count-pin".into();
28846 let expected_nome_via_accessor = c.nome().to_string();
28847 assert_eq!(
28848 expected_nome_via_accessor, "servico-count-pin",
28849 "the mutated fixture's `:nome` must be observable through \
28850 the accessor before the servico-count gate fires",
28851 );
28852 let err = require_single_servico(&c).unwrap_err();
28853 assert_eq!(
28854 err.nome, expected_nome_via_accessor,
28855 "the ServicoCountMismatch's `nome` field must equal \
28856 `caixa.nome().to_string()` — the typed-view constructor \
28857 must route through the lifted [`Caixa::nome`] accessor's \
28858 `.to_string()` extension, not the raw `caixa.nome.clone()` \
28859 `String::clone()` of the underlying field",
28860 );
28861 }
28862
28863 #[test]
28864 fn servico_count_mismatch_display_names_offending_caixa_nome() {
28865 // The Display impl is the load-bearing surface every renderer's
28866 // `#[error("{0}")] UnsupportedServicoCount(#[from]
28867 // ServicoCountMismatch)` arm prints through. Pinning the exact
28868 // rendered form so a future format change is a one-line edit +
28869 // a one-line test update, not a silent regression of the
28870 // diagnostic clarity that motivated the lift (the prior
28871 // per-renderer `UnsupportedServicoCount(usize)` arm named only
28872 // the count). Same shape every peer [`KindMismatch`] / typed-
28873 // view Display tests pin.
28874 let err = ServicoCountMismatch {
28875 nome: "checkout".into(),
28876 count: 3,
28877 };
28878 let msg = format!("{err}");
28879 assert!(
28880 msg.contains("checkout"),
28881 "Display must name the offending caixa nome (got: {msg:?})"
28882 );
28883 assert!(
28884 msg.contains('3'),
28885 "Display must name the actual count (got: {msg:?})"
28886 );
28887 assert!(
28888 msg.contains(":servicos"),
28889 "Display must name the offending field axis (got: {msg:?})"
28890 );
28891 assert!(
28892 msg.contains("exactly one"),
28893 "Display must name the V0 invariant (got: {msg:?})"
28894 );
28895 }
28896
28897 #[test]
28898 fn overlay_kind_agnostic_for_field_projection() {
28899 // The helper projects fields, not kind — every Caixa carries
28900 // the M2 slot fields by construction. Renderer-level kind
28901 // gates (NotAServico in caixa-helm / caixa-flux) are the
28902 // shape filter; this helper is the field projector. Keeping
28903 // them separate means the same overlay can apply to any
28904 // future per-kind renderer (e.g. when M2.4 supervisor
28905 // rendering acquires its own M2-shaped overlay path).
28906 let mut c = bare_servico();
28907 c.kind = CaixaKind::Biblioteca;
28908 c.servicos = vec![];
28909 c.limits = Some(LimitsSpec {
28910 memory: Some(crate::LIMITS_MEMORY_WASM32_PAGE_BYTES),
28911 ..Default::default()
28912 });
28913 let overlay = servico_m2_overlay(&c).unwrap();
28914 assert!(overlay.contains_key(M2_KEY_LIMITS));
28915 }
28916
28917 // ── require_v0_servico_shape — compound V0-shape entry gate ──────
28918
28919 /// Local `thiserror`-shaped renderer-error stand-in that mirrors the
28920 /// three production callers' shape (`caixa-flux::Error`,
28921 /// `caixa-helm::Error`) at the two `#[from]` variants the compound
28922 /// helper's `E: From<KindMismatch> + From<ServicoCountMismatch>`
28923 /// bound targets. Pinning the shape here so the compound helper's
28924 /// type-inference contract is unit-testable inside caixa-core
28925 /// without a workspace-crate dependency (which would bloat the
28926 /// build graph).
28927 #[derive(Debug, thiserror::Error)]
28928 enum RendererStandIn {
28929 #[error("{0}")]
28930 NotAServico(#[from] KindMismatch),
28931 #[error("{0}")]
28932 UnsupportedServicoCount(#[from] ServicoCountMismatch),
28933 }
28934
28935 #[test]
28936 fn require_v0_servico_shape_accepts_v0_servico() {
28937 // Happy path: a `:kind Servico` caixa with exactly one
28938 // `:servicos` entry — the canonical V0 shape every per-Servico
28939 // renderer's entry-point sees — passes the compound gate. Same
28940 // outcome as the two-line pair the compound helper replaces:
28941 // both predicates surface `Ok(())`, and the compound helper's
28942 // return type carries the caller's `E` inferred from the `?`
28943 // context (unit test uses [`RendererStandIn`] as the stand-in
28944 // for `caixa-flux::Error` / `caixa-helm::Error`).
28945 let c = bare_servico();
28946 let r: Result<(), RendererStandIn> = require_v0_servico_shape(&c);
28947 r.expect("v0 servico shape accepted");
28948 }
28949
28950 #[test]
28951 fn require_v0_servico_shape_forwards_kind_mismatch_first() {
28952 // Order pin: the kind gate fires before the count gate, so a
28953 // `:kind Biblioteca` caixa with zero `:servicos` entries
28954 // surfaces the [`KindMismatch`] arm (the more actionable
28955 // diagnostic — the author has the wrong `:kind`), not the
28956 // [`ServicoCountMismatch`] arm (a downstream consequence of
28957 // the mis-kinded input). Both invariants are violated on this
28958 // input, so the ordering matters — reversing it would flip
28959 // every current caller's diagnostic on a mis-kinded input.
28960 let mut c = bare_servico();
28961 c.kind = CaixaKind::Biblioteca;
28962 c.servicos = vec![];
28963 let err: RendererStandIn = require_v0_servico_shape(&c).unwrap_err();
28964 match err {
28965 RendererStandIn::NotAServico(k) => {
28966 assert_eq!(k.nome, "hello-rio");
28967 assert_eq!(k.expected, CaixaKind::Servico);
28968 assert_eq!(k.actual, CaixaKind::Biblioteca);
28969 }
28970 RendererStandIn::UnsupportedServicoCount(_) => {
28971 panic!("kind gate must fire before count gate on mis-kinded input")
28972 }
28973 }
28974 }
28975
28976 #[test]
28977 fn require_v0_servico_shape_forwards_count_mismatch_on_kind_match() {
28978 // A `:kind Servico` caixa with the wrong `:servicos` count
28979 // (empty or multi-entry) passes the kind gate and lands on the
28980 // [`ServicoCountMismatch`] arm — the same typed view every
28981 // per-renderer `#[from] ServicoCountMismatch` arm already
28982 // surfaces at the two-line pair this helper replaces. Both
28983 // directions of the V0 count invariant (empty AND ≥ 2) land on
28984 // the same arm — pinning the multi-entry direction here; the
28985 // empty direction is covered by the peer
28986 // `require_single_servico_rejects_empty_list_with_typed_mismatch`
28987 // test on the single-axis primitive.
28988 let mut c = bare_servico();
28989 c.servicos = vec![
28990 "servicos/hello-rio.computeunit.yaml".into(),
28991 "servicos/extra.computeunit.yaml".into(),
28992 ];
28993 let err: RendererStandIn = require_v0_servico_shape(&c).unwrap_err();
28994 match err {
28995 RendererStandIn::UnsupportedServicoCount(c) => {
28996 assert_eq!(c.nome, "hello-rio");
28997 assert_eq!(c.count, 2);
28998 }
28999 RendererStandIn::NotAServico(_) => {
29000 panic!("count gate must fire when kind gate passes")
29001 }
29002 }
29003 }
29004
29005 #[test]
29006 fn require_v0_servico_shape_matches_two_line_pair_semantic() {
29007 // Equivalence pin: on every input, the compound helper's
29008 // Ok/Err discrimination matches the two-line pair verbatim —
29009 // the lift is a behavioral no-op at the caller boundary. Peer
29010 // to the sibling `entry_or_default_<variant>` equivalence
29011 // tests that pin the lifted primitive against the inline
29012 // block it replaces.
29013 //
29014 // Three axes covered: V0 shape (Ok/Ok), kind gate fires
29015 // (Err/Ok on the two-line pair — pair short-circuits at the
29016 // kind gate), count gate fires (Ok/Err on the two-line pair —
29017 // pair reaches the count gate).
29018 let cases: Vec<(CaixaKind, Vec<String>)> = vec![
29019 (CaixaKind::Servico, vec!["servicos/x.yaml".into()]),
29020 (CaixaKind::Biblioteca, vec![]),
29021 (CaixaKind::Servico, vec![]),
29022 (CaixaKind::Aplicacao, vec!["servicos/x.yaml".into()]),
29023 (
29024 CaixaKind::Servico,
29025 vec!["servicos/a.yaml".into(), "servicos/b.yaml".into()],
29026 ),
29027 ];
29028 for (kind, servicos) in cases {
29029 let mut c = bare_servico();
29030 c.kind = kind;
29031 c.servicos = servicos;
29032 let pair: Result<(), RendererStandIn> = (|| {
29033 require_kind(&c, CaixaKind::Servico)?;
29034 require_single_servico(&c)?;
29035 Ok(())
29036 })();
29037 let compound: Result<(), RendererStandIn> = require_v0_servico_shape(&c);
29038 assert_eq!(
29039 pair.is_ok(),
29040 compound.is_ok(),
29041 "compound helper must match two-line pair on kind={kind:?} servicos.len()={}",
29042 c.servicos.len(),
29043 );
29044 }
29045 }
29046
29047 // ── require_aplicacao_view — compound per-Aplicacao entry gate ───
29048
29049 /// Local `thiserror`-shaped renderer-error stand-in that mirrors
29050 /// `caixa-mesh::Error`'s two `#[from]` arms at the compound
29051 /// helper's `E: From<KindMismatch> + From<AplicacaoError>` bound.
29052 /// Same discipline as the sibling [`RendererStandIn`] stand-in on
29053 /// the peer per-Servico [`require_v0_servico_shape`] gate: pins
29054 /// the compound helper's type-inference contract inside caixa-core
29055 /// without a workspace-crate dependency (which would bloat the
29056 /// build graph).
29057 #[derive(Debug, thiserror::Error)]
29058 enum AplicacaoRendererStandIn {
29059 #[error("{0}")]
29060 NotAnAplicacao(#[from] KindMismatch),
29061 #[error("{0}")]
29062 InvalidAplicacao(#[from] crate::aplicacao::AplicacaoError),
29063 }
29064
29065 fn bare_aplicacao() -> Caixa {
29066 let mut c = bare_servico();
29067 c.nome = "checkout".into();
29068 c.kind = CaixaKind::Aplicacao;
29069 c.servicos = vec![];
29070 c.membros = vec![
29071 crate::aplicacao::Membro {
29072 caixa: "cart".into(),
29073 versao: "^0.1".into(),
29074 },
29075 crate::aplicacao::Membro {
29076 caixa: "catalog".into(),
29077 versao: "^0.1".into(),
29078 },
29079 ];
29080 // `:placement` needs at least one named cluster (every strategy
29081 // uses the list as a hosting/takeover/shard pool per
29082 // MESH-COMPOSITION §II.1/§II.4); the fold-through
29083 // [`Caixa::aplicacao_view`] uses `Placement::default()` which
29084 // carries an empty `:clusters` and would trip
29085 // `AplicacaoError::PlacementWithoutClusters` at
29086 // `AplicacaoSpec::validate` — the peer per-Aplicacao
29087 // renderer fixtures (`caixa-mesh::aplicacao_caixa`) pin the
29088 // same non-empty `:clusters` shape.
29089 c.placement = Some(crate::aplicacao::Placement {
29090 estrategia: crate::aplicacao::PlacementStrategy::SingleNode,
29091 clusters: vec!["default".into()],
29092 affinity: None,
29093 shard_key: None,
29094 });
29095 c
29096 }
29097
29098 #[test]
29099 fn require_aplicacao_view_accepts_valid_aplicacao() {
29100 // Happy path: a `:kind Aplicacao` caixa with a well-formed
29101 // `:membros` stanza — the canonical V0 shape every
29102 // per-Aplicacao renderer's entry-point sees — passes the
29103 // compound three-arm gate and returns a validated
29104 // [`AplicacaoSpec`]. Same outcome as the three-line cascade
29105 // the compound helper replaces: [`require_kind`] passes,
29106 // [`Caixa::aplicacao_view`] returns `Some(spec)`, and
29107 // [`AplicacaoSpec::validate`] passes. Peer to
29108 // `require_v0_servico_shape_accepts_v0_servico` on the
29109 // sibling per-Servico compound gate.
29110 let c = bare_aplicacao();
29111 let spec: crate::aplicacao::AplicacaoSpec =
29112 require_aplicacao_view::<AplicacaoRendererStandIn>(&c)
29113 .expect("valid aplicacao shape accepted");
29114 // Route the per-Aplicacao `:membros` slice-projection through
29115 // the substrate-canonical [`AplicacaoSpec::membros`] `&[Membro]`-
29116 // return accessor rather than the raw `spec.membros` `Vec<Membro>`
29117 // field access, and the per-member `:caixa` scalar-projection
29118 // through the sibling [`crate::aplicacao::Membro::nome`] `&str`-
29119 // return accessor rather than the raw `.caixa` `String`-field
29120 // borrow, so a future rebrand of either storage (a per-cluster
29121 // `:membros`-overlay the caixa-operator reconciles ahead of
29122 // dispatch, an M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
29123 // materializer's per-member alias table, a promotion of the
29124 // per-`Membro` `caixa: String` slot to a typed `ServicoName`
29125 // newtype the accessor materializes behind the same `&str`
29126 // return contract) reaches this per-fixture happy-path
29127 // acceptance-shape probe through the one accessor edit at the
29128 // canonical caixa-core declaration rather than a coordinated
29129 // rewrite that would include this render-side test-fixture
29130 // navigation too. Peer to the sibling caixa-flux
29131 // [`sample_caixa_nome_accessor_byte_equals_raw_field`] (2ffdb44)
29132 // / caixa-crd `round_trip_preserves_core_fields` (1a160cd) /
29133 // caixa-feira load.rs (e853d45) test-side accessor
29134 // convergences on the peer per-`Caixa` scalar-axis field —
29135 // extended here onto the render-side per-`AplicacaoSpec`
29136 // `:membros` slice + per-`Membro` `:caixa` scalar axes.
29137 let membros = spec.membros();
29138 assert_eq!(membros.len(), 2);
29139 assert_eq!(membros[0].nome(), "cart");
29140 assert_eq!(membros[1].nome(), "catalog");
29141 }
29142
29143 #[test]
29144 fn require_aplicacao_view_accepts_valid_aplicacao_membros_accessor_byte_equals_raw_field() {
29145 // Byte-parity pin: [`AplicacaoSpec::membros`]'s `&[Membro]`-
29146 // return accessor must project the same slice-length and
29147 // per-entry `:caixa` bytes as the raw `spec.membros`
29148 // `Vec<Membro>` + per-`Membro` `caixa: String` field access
29149 // on the shared per-test [`bare_aplicacao`] fixture the sibling
29150 // [`require_aplicacao_view_accepts_valid_aplicacao`] happy-
29151 // path acceptance pin navigates through. Guards the paired
29152 // per-fixture convergence that just routed the three raw
29153 // `spec.membros.len()` / `spec.membros[0].caixa` /
29154 // `spec.membros[1].caixa` sites through the accessor pair: a
29155 // future implementation of [`AplicacaoSpec::membros`] that
29156 // returned a differently-shaped view (a filter over
29157 // storage-dropping optional members, a cached
29158 // `Cow<[Membro]>` materialization, an operator-side per-CR
29159 // alias-rewritten membership overlay), or a future
29160 // [`crate::aplicacao::Membro::nome`] projection that read a
29161 // canonicalized rewrite (a per-tenant namespace prefix, an
29162 // ASCII-lowered normalization) rather than the raw storage-
29163 // side `.caixa` bytes, would silently split every render-
29164 // side test-fixture navigation that routes through the
29165 // accessors from the storage-side field the peer
29166 // [`AplicacaoSpec::validate`] production membership-lookup
29167 // path still reads through the same accessor pair — this
29168 // pin surfaces the drift at caixa-core build time rather
29169 // than at a downstream per-Aplicacao renderer's
29170 // membership-lookup diagnostic on the fleet.
29171 //
29172 // Same byte-parity-pin discipline the sibling caixa-flux
29173 // `sample_caixa_nome_accessor_byte_equals_raw_field` (2ffdb44)
29174 // + caixa-crd `round_trip_preserves_core_fields` accessor
29175 // convergence (1a160cd) + caixa-feira load.rs (e853d45)
29176 // per-`Caixa` scalar-axis byte-parity pins added to lock the
29177 // peer per-`Caixa` scalar-accessor family against the raw
29178 // field-access at each crate's fixture — extended here onto
29179 // the render-side per-`AplicacaoSpec` `:membros` slice + per-
29180 // `Membro` `:caixa` scalar axes' shared test fixture.
29181 let c = bare_aplicacao();
29182 let spec: crate::aplicacao::AplicacaoSpec =
29183 require_aplicacao_view::<AplicacaoRendererStandIn>(&c)
29184 .expect("valid aplicacao shape accepted");
29185 assert_eq!(
29186 spec.membros().len(),
29187 spec.membros.len(),
29188 "AplicacaoSpec::membros() slice-length must byte-equal \
29189 the raw `membros: Vec<Membro>` field storage's `.len()`; \
29190 any implementation drift here silently splits every \
29191 render-side test-fixture navigation that routes through \
29192 the accessor from the storage-side field the peer \
29193 AplicacaoSpec::validate production membership-lookup \
29194 path still reads through the same accessor"
29195 );
29196 for (i, m) in spec.membros().iter().enumerate() {
29197 assert_eq!(
29198 m.nome(),
29199 spec.membros[i].caixa.as_str(),
29200 "Membro::nome() must borrow the same bytes as the raw \
29201 `caixa: String` field storage at member index {i}; \
29202 any implementation drift here silently splits every \
29203 render-side test-fixture navigation that routes \
29204 through the accessor from the storage-side field the \
29205 peer AplicacaoSpec::validate production membership-\
29206 lookup path still reads through the same accessor"
29207 );
29208 }
29209 }
29210
29211 #[test]
29212 fn require_aplicacao_view_forwards_kind_mismatch_first() {
29213 // Order pin: the kind gate fires before the aplicacao_view
29214 // fold-in + [`AplicacaoSpec::validate`], so a `:kind Servico`
29215 // caixa carrying a well-formed `:membros` stanza (the manifest
29216 // field's documented "silently ignored" case on a non-Aplicacao
29217 // kind) surfaces the [`KindMismatch`] arm — the more actionable
29218 // diagnostic — rather than any spec-side arm the manifest
29219 // author never intended to hit. Reversing the order would flip
29220 // every current caller's diagnostic on a mis-kinded input.
29221 // Peer to `require_v0_servico_shape_forwards_kind_mismatch_first`
29222 // on the sibling per-Servico compound gate.
29223 let mut c = bare_aplicacao();
29224 c.kind = CaixaKind::Servico;
29225 c.servicos = vec!["servicos/hello.computeunit.yaml".into()];
29226 let err: AplicacaoRendererStandIn = require_aplicacao_view(&c).unwrap_err();
29227 match err {
29228 AplicacaoRendererStandIn::NotAnAplicacao(k) => {
29229 assert_eq!(k.nome, "checkout");
29230 assert_eq!(k.expected, CaixaKind::Aplicacao);
29231 assert_eq!(k.actual, CaixaKind::Servico);
29232 }
29233 AplicacaoRendererStandIn::InvalidAplicacao(_) => {
29234 panic!("kind gate must fire before aplicacao-view fold-in on mis-kinded input")
29235 }
29236 }
29237 }
29238
29239 #[test]
29240 fn require_aplicacao_view_forwards_aplicacao_error_on_kind_match() {
29241 // A `:kind Aplicacao` caixa that passes the kind gate but
29242 // fails [`AplicacaoSpec::validate`] (empty `:membros` here —
29243 // the [`AplicacaoError::NoMembros`] arm every Aplicacao must
29244 // satisfy per MESH-COMPOSITION §III.1) lands on the
29245 // [`AplicacaoError`] arm through the compound helper's
29246 // `E: From<AplicacaoError>` bound. Same diagnostic the
29247 // three-line cascade the compound helper replaces surfaces at
29248 // `spec.validate()?`. Peer to
29249 // `require_v0_servico_shape_forwards_count_mismatch_on_kind_match`
29250 // on the sibling per-Servico compound gate.
29251 let mut c = bare_aplicacao();
29252 c.membros = vec![]; // trips AplicacaoError::NoMembros
29253 let err: AplicacaoRendererStandIn = require_aplicacao_view(&c).unwrap_err();
29254 match err {
29255 AplicacaoRendererStandIn::InvalidAplicacao(
29256 crate::aplicacao::AplicacaoError::NoMembros,
29257 ) => {}
29258 AplicacaoRendererStandIn::InvalidAplicacao(other) => {
29259 panic!("expected NoMembros arm, got {other:?}")
29260 }
29261 AplicacaoRendererStandIn::NotAnAplicacao(_) => {
29262 panic!("spec-validate arm must fire when kind gate passes")
29263 }
29264 }
29265 }
29266
29267 #[test]
29268 fn require_aplicacao_view_matches_three_line_cascade_semantic() {
29269 // Equivalence pin: on every input, the compound helper's
29270 // Ok/Err discrimination matches the three-line cascade
29271 // verbatim — the lift is a behavioral no-op at the caller
29272 // boundary. Peer to the sibling
29273 // `require_v0_servico_shape_matches_two_line_pair_semantic`
29274 // equivalence pin on the per-Servico compound gate.
29275 //
29276 // Four axes covered: Aplicacao shape (Ok/Ok), kind gate fires
29277 // (Err/Ok on the cascade — cascade short-circuits at the kind
29278 // gate), spec-validate arm fires (Ok/Err on the cascade —
29279 // cascade reaches [`AplicacaoSpec::validate`]), and a
29280 // mis-kinded caixa with a spec-invalid `:membros` stanza (both
29281 // invariants violated — the kind gate must still fire first).
29282 let cases: Vec<(CaixaKind, Vec<crate::aplicacao::Membro>)> = vec![
29283 (
29284 CaixaKind::Aplicacao,
29285 vec![
29286 crate::aplicacao::Membro {
29287 caixa: "cart".into(),
29288 versao: "^0.1".into(),
29289 },
29290 crate::aplicacao::Membro {
29291 caixa: "catalog".into(),
29292 versao: "^0.1".into(),
29293 },
29294 ],
29295 ),
29296 (CaixaKind::Servico, vec![]),
29297 (CaixaKind::Aplicacao, vec![]),
29298 (
29299 CaixaKind::Biblioteca,
29300 vec![crate::aplicacao::Membro {
29301 caixa: "cart".into(),
29302 versao: "^0.1".into(),
29303 }],
29304 ),
29305 ];
29306 for (kind, membros) in cases {
29307 let mut c = bare_aplicacao();
29308 c.kind = kind;
29309 c.membros = membros.clone();
29310 if kind == CaixaKind::Servico {
29311 c.servicos = vec!["servicos/hello.computeunit.yaml".into()];
29312 } else {
29313 c.servicos = vec![];
29314 }
29315 let cascade: Result<crate::aplicacao::AplicacaoSpec, AplicacaoRendererStandIn> =
29316 (|| {
29317 require_kind(&c, CaixaKind::Aplicacao)?;
29318 let spec = c.aplicacao_view().expect(
29319 "require_kind(Aplicacao) guarantees Caixa::aplicacao_view returns Some",
29320 );
29321 spec.validate()?;
29322 Ok(spec)
29323 })();
29324 let compound: Result<crate::aplicacao::AplicacaoSpec, AplicacaoRendererStandIn> =
29325 require_aplicacao_view(&c);
29326 assert_eq!(
29327 cascade.is_ok(),
29328 compound.is_ok(),
29329 "compound helper must match three-line cascade on kind={kind:?} membros.len()={}",
29330 membros.len(),
29331 );
29332 // Compound helper's Ok-arm return matches cascade's
29333 // Ok-arm return byte-for-byte (via serde YAML round-trip
29334 // — the `AplicacaoSpec` derives `Serialize`, so equal-
29335 // rendering values are the substrate-canonical equality
29336 // signal the peer downstream renderers key off).
29337 if let (Ok(cascade_spec), Ok(compound_spec)) = (cascade, compound) {
29338 assert_eq!(
29339 serde_yaml::to_string(&cascade_spec).expect("cascade AplicacaoSpec serializes"),
29340 serde_yaml::to_string(&compound_spec)
29341 .expect("compound AplicacaoSpec serializes"),
29342 "compound helper's Ok arm must return byte-equal AplicacaoSpec to cascade"
29343 );
29344 }
29345 }
29346 }
29347
29348 // ── require_acao_view — compound per-`Acao` entry gate ───────────
29349
29350 /// Local `thiserror`-shaped renderer-error stand-in that mirrors
29351 /// `caixa-actions::Error`'s three `#[from]` arms at the compound
29352 /// helper's `E: From<KindMismatch> + From<MissingCiSlot> +
29353 /// From<CiDecomposeFailure>` bound. Same discipline as the sibling
29354 /// [`RendererStandIn`] / [`AplicacaoRendererStandIn`] stand-ins on
29355 /// the peer per-Servico [`require_v0_servico_shape`] and
29356 /// per-Aplicacao [`require_aplicacao_view`] compound gates: pins
29357 /// the compound helper's type-inference contract inside caixa-core
29358 /// without a workspace-crate dependency (which would bloat the
29359 /// build graph).
29360 #[derive(Debug, thiserror::Error)]
29361 enum AcaoRendererStandIn {
29362 #[error("{0}")]
29363 NotAnAcao(#[from] KindMismatch),
29364 #[error("{0}")]
29365 MissingCi(#[from] MissingCiSlot),
29366 #[error("{0}")]
29367 Decompose(#[from] CiDecomposeFailure),
29368 }
29369
29370 #[test]
29371 fn require_acao_view_accepts_valid_acao() {
29372 // Happy path: a `:kind Acao` caixa with a well-formed `:ci`
29373 // stanza — the canonical V0 shape every per-`Acao` consumer's
29374 // entry-point sees — passes the compound three-arm gate and
29375 // returns the borrowed [`canteiro_types::CiRun`] paired with
29376 // the owned [`canteiro_types::CanteiroDag`] the substrate
29377 // primitive produced. Same outcome as the three-line prelude
29378 // the compound helper replaces: [`require_kind`] passes,
29379 // [`require_ci`] returns the borrowed slot, [`decompose_ci`]
29380 // accepts the run. Peer to
29381 // `require_aplicacao_view_accepts_valid_aplicacao` and
29382 // `require_v0_servico_shape_accepts_v0_servico` on the sibling
29383 // per-Aplicacao / per-Servico compound gates.
29384 let mut c = bare_acao_without_ci();
29385 c.ci = Some(linear_ci_run());
29386 let (ci, cd) = require_acao_view::<AcaoRendererStandIn>(&c)
29387 .expect("valid Acao shape accepted by compound helper");
29388 assert_eq!(ci.workspace, "pleme-io");
29389 assert_eq!(ci.nodes.len(), 2);
29390 // `topo_order()` is infallible on the DAG the compound helper
29391 // returns, mirroring the substrate-side pass-through pin at
29392 // [`decompose_ci_accepts_valid_ci_run_and_returns_canteiro_dag`].
29393 let topo = cd
29394 .topo_order()
29395 .expect("acyclic CanteiroDag returns a valid topo_order");
29396 assert_eq!(
29397 topo.iter().count(),
29398 2,
29399 "topo_order on the compound helper's returned DAG must yield \
29400 two node ids on a two-node acyclic run"
29401 );
29402 }
29403
29404 #[test]
29405 fn require_acao_view_forwards_kind_mismatch_first() {
29406 // Order pin: the kind gate fires before the presence gate + the
29407 // decompose gate, so a `:kind Servico` caixa carrying a
29408 // well-formed `:ci` stanza (the manifest field's documented
29409 // "silently ignored" case on a non-`Acao` kind) surfaces the
29410 // [`KindMismatch`] arm — the more actionable diagnostic —
29411 // rather than either downstream arm the manifest author never
29412 // intended to hit. Reversing the order would flip every
29413 // current caller's diagnostic on a mis-kinded input. Peer to
29414 // `require_aplicacao_view_forwards_kind_mismatch_first` and
29415 // `require_v0_servico_shape_forwards_kind_mismatch_first` on
29416 // the sibling per-Aplicacao / per-Servico compound gates.
29417 let mut c = bare_acao_without_ci();
29418 c.kind = CaixaKind::Servico;
29419 c.servicos = vec!["servicos/hello.computeunit.yaml".into()];
29420 c.ci = Some(linear_ci_run());
29421 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
29422 // `canteiro_types::CanteiroDag`, which does not derive it at the
29423 // pinned sui rev — so the whole caixa-core test target failed to
29424 // COMPILE. A let-else says the same thing without borrowing a
29425 // bound from a foreign type we do not own.
29426 let Err(err): Result<_, AcaoRendererStandIn> = require_acao_view(&c) else {
29427 panic!("this fixture must not produce an Acao view");
29428 };
29429 match err {
29430 AcaoRendererStandIn::NotAnAcao(k) => {
29431 assert_eq!(k.nome, "hello-rio");
29432 assert_eq!(k.expected, CaixaKind::Acao);
29433 assert_eq!(k.actual, CaixaKind::Servico);
29434 }
29435 AcaoRendererStandIn::MissingCi(_) => {
29436 panic!("kind gate must fire before presence gate on mis-kinded input")
29437 }
29438 AcaoRendererStandIn::Decompose(_) => {
29439 panic!("kind gate must fire before decompose gate on mis-kinded input")
29440 }
29441 }
29442 }
29443
29444 #[test]
29445 fn require_acao_view_forwards_missing_ci_slot_on_kind_match() {
29446 // A `:kind Acao` caixa that passes the kind gate but declares
29447 // no `:ci` slot lands on the [`MissingCiSlot`] arm through the
29448 // compound helper's `E: From<MissingCiSlot>` bound — the same
29449 // typed view the peer [`require_ci`] presence gate produces at
29450 // the single-axis primitive, propagated through the compound
29451 // gate's second arm.
29452 let c = bare_acao_without_ci();
29453 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
29454 // `canteiro_types::CanteiroDag`, which does not derive it at the
29455 // pinned sui rev — so the whole caixa-core test target failed to
29456 // COMPILE. A let-else says the same thing without borrowing a
29457 // bound from a foreign type we do not own.
29458 let Err(err): Result<_, AcaoRendererStandIn> = require_acao_view(&c) else {
29459 panic!("this fixture must not produce an Acao view");
29460 };
29461 match err {
29462 AcaoRendererStandIn::MissingCi(m) => {
29463 assert_eq!(m.nome, "hello-rio");
29464 }
29465 AcaoRendererStandIn::NotAnAcao(_) => {
29466 panic!("presence gate must fire when kind gate passes")
29467 }
29468 AcaoRendererStandIn::Decompose(_) => {
29469 panic!("presence gate must fire before decompose gate on missing `:ci` input")
29470 }
29471 }
29472 }
29473
29474 #[test]
29475 fn require_acao_view_forwards_decompose_failure_on_ci_present() {
29476 // A `:kind Acao` caixa that passes the kind + presence gates
29477 // but carries a cyclic `:ci` run lands on the
29478 // [`CiDecomposeFailure`] arm through the compound helper's
29479 // `E: From<CiDecomposeFailure>` bound — the same typed view
29480 // the peer [`decompose_ci`] gate produces at the single-axis
29481 // primitive, propagated through the compound gate's third
29482 // arm.
29483 let mut c = bare_acao_without_ci();
29484 c.ci = Some(cyclic_ci_run());
29485 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
29486 // `canteiro_types::CanteiroDag`, which does not derive it at the
29487 // pinned sui rev — so the whole caixa-core test target failed to
29488 // COMPILE. A let-else says the same thing without borrowing a
29489 // bound from a foreign type we do not own.
29490 let Err(err): Result<_, AcaoRendererStandIn> = require_acao_view(&c) else {
29491 panic!("this fixture must not produce an Acao view");
29492 };
29493 match err {
29494 AcaoRendererStandIn::Decompose(f) => {
29495 assert_eq!(f.nome, "hello-rio");
29496 assert_eq!(f.source, canteiro_types::DecomposeError::Cycle);
29497 }
29498 AcaoRendererStandIn::NotAnAcao(_) => {
29499 panic!("decompose gate must fire when kind + presence gates pass")
29500 }
29501 AcaoRendererStandIn::MissingCi(_) => {
29502 panic!("decompose gate must fire when presence gate passes")
29503 }
29504 }
29505 }
29506
29507 #[test]
29508 fn require_acao_view_matches_three_line_prelude_semantic() {
29509 // Equivalence pin: on every input, the compound helper's
29510 // Ok/Err discrimination matches the three-line prelude
29511 // verbatim — the lift is a behavioral no-op at the caller
29512 // boundary. Peer to the sibling
29513 // `require_aplicacao_view_matches_three_line_cascade_semantic`
29514 // and `require_v0_servico_shape_matches_two_line_pair_semantic`
29515 // equivalence pins on the per-Aplicacao / per-Servico compound
29516 // gates.
29517 //
29518 // Five axes covered: valid Acao (Ok/Ok), kind gate fires
29519 // (Err/Err on the prelude — prelude short-circuits at the kind
29520 // gate), presence gate fires (Ok/Err on the prelude — prelude
29521 // reaches [`require_ci`]), decompose gate fires (Ok/Err on the
29522 // prelude — prelude reaches [`decompose_ci`]), and a
29523 // mis-kinded caixa with a well-formed `:ci` (both invariants
29524 // relevant — the kind gate must still fire first).
29525 let cases: Vec<(CaixaKind, Option<canteiro_types::CiRun>)> = vec![
29526 (CaixaKind::Acao, Some(linear_ci_run())),
29527 (CaixaKind::Servico, Some(linear_ci_run())),
29528 (CaixaKind::Acao, None),
29529 (CaixaKind::Acao, Some(cyclic_ci_run())),
29530 (CaixaKind::Biblioteca, None),
29531 ];
29532 for (kind, ci) in cases {
29533 let mut c = bare_acao_without_ci();
29534 c.kind = kind;
29535 c.ci = ci.clone();
29536 if kind == CaixaKind::Servico {
29537 c.servicos = vec!["servicos/hello.computeunit.yaml".into()];
29538 } else {
29539 c.servicos = vec![];
29540 }
29541 let prelude: Result<
29542 (&canteiro_types::CiRun, canteiro_types::CanteiroDag),
29543 AcaoRendererStandIn,
29544 > = (|| {
29545 require_kind(&c, CaixaKind::Acao)?;
29546 let ci_borrowed = require_ci(&c)?;
29547 let cd = decompose_ci(&c, ci_borrowed)?;
29548 Ok((ci_borrowed, cd))
29549 })();
29550 let compound: Result<
29551 (&canteiro_types::CiRun, canteiro_types::CanteiroDag),
29552 AcaoRendererStandIn,
29553 > = require_acao_view(&c);
29554 assert_eq!(
29555 prelude.is_ok(),
29556 compound.is_ok(),
29557 "compound helper must match three-line prelude on kind={kind:?} ci.is_some()={}",
29558 ci.is_some(),
29559 );
29560 // Compound helper's Ok-arm return matches prelude's
29561 // Ok-arm return byte-for-byte on both projections: the
29562 // borrowed `&CiRun`'s node count + workspace / repo
29563 // identity, and the owned `CanteiroDag`'s
29564 // topological-order node-name projection (the substrate-
29565 // canonical equality signal every downstream per-`Acao`
29566 // consumer keys off).
29567 if let (Ok((prelude_ci, prelude_cd)), Ok((compound_ci, compound_cd))) =
29568 (prelude, compound)
29569 {
29570 assert_eq!(
29571 prelude_ci.workspace, compound_ci.workspace,
29572 "compound helper's borrowed CiRun's workspace must \
29573 equal prelude's byte-for-byte"
29574 );
29575 assert_eq!(
29576 prelude_ci.repo, compound_ci.repo,
29577 "compound helper's borrowed CiRun's repo must equal \
29578 prelude's byte-for-byte"
29579 );
29580 assert_eq!(
29581 prelude_ci.nodes.len(),
29582 compound_ci.nodes.len(),
29583 "compound helper's borrowed CiRun's node count must \
29584 equal prelude's"
29585 );
29586 let prelude_topo = prelude_cd
29587 .topo_order()
29588 .expect("prelude's DAG produces a valid topo_order");
29589 let compound_topo = compound_cd
29590 .topo_order()
29591 .expect("compound's DAG produces a valid topo_order");
29592 let prelude_names: Vec<String> = prelude_topo
29593 .iter()
29594 .filter_map(|id| prelude_cd.nodes.get(id).map(|n| n.name.clone()))
29595 .collect();
29596 let compound_names: Vec<String> = compound_topo
29597 .iter()
29598 .filter_map(|id| compound_cd.nodes.get(id).map(|n| n.name.clone()))
29599 .collect();
29600 assert_eq!(
29601 prelude_names, compound_names,
29602 "compound helper's DAG must produce byte-equal \
29603 topological-order node-name projection to prelude's"
29604 );
29605 }
29606 }
29607 }
29608
29609 // ── single_field_overlay — typed per-axis overlay primitive ──────────
29610
29611 #[test]
29612 fn single_field_overlay_none_yields_none() {
29613 // Empty-axis-skip semantic at the typed-primitive layer: a
29614 // `None` slot returns `None`, not `Some(empty Mapping)`. The
29615 // caller's `if let Some(overlay) = …` guard then becomes the
29616 // single emission gate, and a malformed `outer: {}` (the
29617 // empty-mapping form some K8s parsers reject) is structurally
29618 // impossible by construction.
29619 let v: Option<serde_yaml::Value> = single_field_overlay::<u32, _>(None, "attempts", |n| {
29620 serde_yaml::Value::Number(n.into())
29621 });
29622 assert!(v.is_none());
29623 }
29624
29625 #[test]
29626 fn single_field_overlay_some_yields_single_field_mapping() {
29627 // The Some arm builds exactly one inner key/value pair, no
29628 // more, no less. Pinning the shape so a future refactor can't
29629 // accidentally introduce a second field (which would render
29630 // as a malformed `timeouts: { request: "30s", <leak>: ... }`
29631 // overlay block).
29632 let v = single_field_overlay(Some(30u32), "attempts", |n| {
29633 serde_yaml::Value::Number(n.into())
29634 })
29635 .expect("Some arm yields Some(...)");
29636 let m = v.as_mapping().expect("mapping shape");
29637 assert_eq!(m.len(), 1);
29638 assert_eq!(m.get("attempts").and_then(|x| x.as_u64()), Some(30));
29639 }
29640
29641 #[test]
29642 fn single_field_overlay_threads_typed_value_through_closure() {
29643 // The closure receives the unwrapped typed `T` (not the
29644 // wrapping `Option<T>`), so the per-overlay value-shaping
29645 // logic stays at the call site. Three different Value shapes
29646 // pin the closure's type-flow: a `String` (for canonical
29647 // duration / enum scalars), a `Number` (for typed integer
29648 // attempt counts), and a derived `Bool` (for tristate enums).
29649 // Mirrors the three landed overlays' shapes letter-for-letter.
29650 let dur = single_field_overlay(Some("30s".to_string()), "request", |s| {
29651 serde_yaml::Value::String(s)
29652 })
29653 .unwrap();
29654 assert_eq!(dur.get("request").and_then(|v| v.as_str()), Some("30s"));
29655
29656 let num = single_field_overlay(Some(3u32), "attempts", |n| {
29657 serde_yaml::Value::Number(n.into())
29658 })
29659 .unwrap();
29660 assert_eq!(num.get("attempts").and_then(|v| v.as_u64()), Some(3));
29661
29662 // The mtls tristate's two non-None arms map to enum strings,
29663 // not raw bools (the Cilium CRD's `mode: required|disabled`
29664 // shape — pinned end-to-end at every emit site by the
29665 // `cnp_authentication_mode_serialized_as_yaml_string` test).
29666 // Both scalar-values thread through the lifted canonical
29667 // [`cilium_auth_mode`] bijection — the same `bool → &'static
29668 // str` projection the production `cilium_network_policies`
29669 // per-`(:de, :para)` overlay closure reaches for, so a future
29670 // Cilium CNP `MutualAuthenticationMode` OpenAPI schema enum
29671 // rebrand (either arm's scalar-value string, or the per-arm
29672 // dispatch) lands at the two consts + one projection body
29673 // rather than duplicated across the production emitter site
29674 // and this generic-helper pin.
29675 let mode = single_field_overlay(Some(true), CILIUM_KEY_MODE, |b| {
29676 serde_yaml::Value::String(cilium_auth_mode(b).into())
29677 })
29678 .unwrap();
29679 assert_eq!(
29680 mode.get(CILIUM_KEY_MODE).and_then(|v| v.as_str()),
29681 Some(CILIUM_AUTH_MODE_REQUIRED)
29682 );
29683 }
29684
29685 #[test]
29686 fn single_field_overlay_outer_key_is_callers_concern() {
29687 // The helper builds the *inner* (single-field) Mapping; the
29688 // *outer* key (`timeouts` / `retry` / `authentication`) is
29689 // the caller's `if let Some(overlay) = … { rule.insert(<outer>,
29690 // overlay.clone()) }` insertion. Pinning that the helper's
29691 // returned Value carries no outer-key wrapping — emitting the
29692 // outer-key-wrapped form here would silently double-wrap
29693 // every overlay (`timeouts: { timeouts: { request: "30s" } }`
29694 // post-insertion).
29695 let v = single_field_overlay(Some(30u32), "attempts", |n| {
29696 serde_yaml::Value::Number(n.into())
29697 })
29698 .unwrap();
29699 let m = v.as_mapping().unwrap();
29700 // Only the inner key — no `timeouts:` / `retry:` /
29701 // `authentication:` wrapper at this layer.
29702 for k in ["timeouts", "retry", "authentication"] {
29703 assert!(
29704 m.get(k).is_none(),
29705 "single_field_overlay must not pre-insert the outer key {k:?} \
29706 (the caller's per-rule insert is the canonical insertion site)"
29707 );
29708 }
29709 }
29710
29711 #[test]
29712 fn single_field_overlay_value_is_clonable_for_per_rule_dispatch() {
29713 // The build-once-clone-many idiom every emit-site uses: the
29714 // overlay is computed once per renderer call (so the closure
29715 // runs exactly once) and `.clone()`d into each rule of the
29716 // emitted sequence. Pin that the returned Value is in fact
29717 // cloneable (a `serde_yaml::Value` always is, but the test
29718 // pins the contract end-to-end so a future refactor that
29719 // returns a non-Cloneable wrapper surfaces here).
29720 let v = single_field_overlay(Some(30u32), "attempts", |n| {
29721 serde_yaml::Value::Number(n.into())
29722 })
29723 .unwrap();
29724 let v_clone = v.clone();
29725 assert_eq!(v, v_clone);
29726 }
29727
29728 // ── upsert_named_entry — typed sequence-upsert primitive ─────────────
29729
29730 #[test]
29731 fn upsert_named_entry_appends_when_empty() {
29732 // Empty-sequence-first arm: an initially-empty aggregator
29733 // programs.yaml carries no matching entry, so the upsert falls
29734 // through to the append-new tail and returns
29735 // `Ok(true)` (newly inserted). Pins the append-new contract
29736 // both writer-side [`caixa_flux`] upsert paths lean on when
29737 // the aggregator's `programs:` sequence is empty
29738 // (`upsert_inserts_new_entry` at the values.yaml layer,
29739 // `upsert_helmrelease_inserts_under_spec_values_programs` at
29740 // the HelmRelease layer) — the same shape at the typed-
29741 // primitive layer as the two production sites.
29742 let mut arr: Vec<serde_yaml::Value> = Vec::new();
29743 let entry: serde_yaml::Value =
29744 serde_yaml::from_str("{ name: hello-rio, module: { source: oci://x } }").unwrap();
29745 let inserted =
29746 upsert_named_entry::<()>(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || ()).unwrap();
29747 assert!(inserted, "empty sequence + new entry must append");
29748 assert_eq!(arr.len(), 1);
29749 assert_eq!(
29750 arr[0].get(FLEET_PROGRAMS_KEY_NAME).and_then(|n| n.as_str()),
29751 Some("hello-rio")
29752 );
29753 }
29754
29755 #[test]
29756 fn upsert_named_entry_appends_when_no_match() {
29757 // Non-matching-name append arm: an aggregator sequence with a
29758 // differently-named entry carries no matching name-key value,
29759 // so the upsert falls through to the append-new tail (never
29760 // replacing) and returns `Ok(true)`. Pins the append-only
29761 // semantic that keeps every unrelated entry untouched.
29762 let mut arr: Vec<serde_yaml::Value> = vec![
29763 serde_yaml::from_str("{ name: other, module: { source: github:foo/bar } }").unwrap(),
29764 ];
29765 let entry: serde_yaml::Value =
29766 serde_yaml::from_str("{ name: hello-rio, module: { source: oci://x } }").unwrap();
29767 let inserted =
29768 upsert_named_entry::<()>(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || ()).unwrap();
29769 assert!(inserted);
29770 assert_eq!(arr.len(), 2);
29771 assert_eq!(
29772 arr[0].get(FLEET_PROGRAMS_KEY_NAME).and_then(|n| n.as_str()),
29773 Some("other")
29774 );
29775 assert_eq!(
29776 arr[1].get(FLEET_PROGRAMS_KEY_NAME).and_then(|n| n.as_str()),
29777 Some("hello-rio")
29778 );
29779 }
29780
29781 #[test]
29782 fn upsert_named_entry_replaces_when_match() {
29783 // Match-and-replace arm: an aggregator sequence carrying an
29784 // entry whose `<name_key>` matches the new entry's name-scalar
29785 // gets its slot rewritten in place and the helper returns
29786 // `Ok(false)` (replaced-not-appended). Pins the idempotency
29787 // contract every writer-side upsert path lands on — the same
29788 // caixa.lisp deployed twice must upsert to the same
29789 // aggregator entry, never grow a duplicated `programs[]`
29790 // entry. Peer at the substrate layer with the two production
29791 // `upsert_replaces_existing_entry` /
29792 // `upsert_helmrelease_replaces_existing` tests
29793 // ([`caixa_flux`]).
29794 let mut arr: Vec<serde_yaml::Value> = vec![
29795 serde_yaml::from_str("{ name: hello-rio, module: { source: oci://old } }").unwrap(),
29796 ];
29797 let entry: serde_yaml::Value =
29798 serde_yaml::from_str("{ name: hello-rio, module: { source: oci://new } }").unwrap();
29799 let inserted =
29800 upsert_named_entry::<()>(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || ()).unwrap();
29801 assert!(!inserted, "matching name must replace, not append");
29802 assert_eq!(arr.len(), 1);
29803 assert_eq!(
29804 arr[0]
29805 .get(COMPUTEUNIT_SPEC_KEY_MODULE)
29806 .and_then(|m| m.get(COMPUTEUNIT_MODULE_KEY_SOURCE))
29807 .and_then(|s| s.as_str()),
29808 Some("oci://new")
29809 );
29810 }
29811
29812 #[test]
29813 fn upsert_named_entry_preserves_position_on_replace() {
29814 // Position-preserving-replace pin: when an interior entry
29815 // matches, its slot is rewritten in place and the surrounding
29816 // entries stay put (first / last / any middle position). The
29817 // aggregator's fanout consumers filter `programs[]` in
29818 // declaration order (the `lareira-fleet-programs` chart's
29819 // `.Values.programs` iteration + the future
29820 // `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
29821 // per-entry admission bind); a replace-then-move-to-tail shift
29822 // (silently promoting the just-upserted entry to end-of-list)
29823 // would silently reorder every downstream consumer's iteration
29824 // window. Same declaration-order-preservation contract the
29825 // aggregator side relies on.
29826 let mut arr: Vec<serde_yaml::Value> = vec![
29827 serde_yaml::from_str("{ name: alpha, module: { source: github:a/a } }").unwrap(),
29828 serde_yaml::from_str("{ name: beta, module: { source: github:b/old } }").unwrap(),
29829 serde_yaml::from_str("{ name: gamma, module: { source: github:g/g } }").unwrap(),
29830 ];
29831 let entry: serde_yaml::Value =
29832 serde_yaml::from_str("{ name: beta, module: { source: github:b/new } }").unwrap();
29833 let inserted =
29834 upsert_named_entry::<()>(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || ()).unwrap();
29835 assert!(!inserted);
29836 assert_eq!(arr.len(), 3);
29837 // Order pin: alpha stays at 0, beta stays at 1 (rewritten),
29838 // gamma stays at 2 — replace must preserve position.
29839 let names: Vec<&str> = arr
29840 .iter()
29841 .filter_map(|v| v.get(FLEET_PROGRAMS_KEY_NAME).and_then(|n| n.as_str()))
29842 .collect();
29843 assert_eq!(names, ["alpha", "beta", "gamma"]);
29844 assert_eq!(
29845 arr[1]
29846 .get(COMPUTEUNIT_SPEC_KEY_MODULE)
29847 .and_then(|m| m.get(COMPUTEUNIT_MODULE_KEY_SOURCE))
29848 .and_then(|s| s.as_str()),
29849 Some("github:b/new")
29850 );
29851 }
29852
29853 #[test]
29854 fn upsert_named_entry_calls_error_closure_on_missing_name_key() {
29855 // Missing-name-scalar arm: when the new entry doesn't carry
29856 // `<name_key>` as a string scalar, the helper calls the
29857 // caller's `on_missing_name` closure — the caller's own typed
29858 // [`crate::RenderError`]-shaped error surface remains
29859 // authoritative. Threaded through a closure so this crate
29860 // stays agnostic to the caller's error enum shape (the two
29861 // production sites in [`caixa_flux`] surface
29862 // `Error::MissingField(FLEET_PROGRAMS_KEY_NAME)` verbatim,
29863 // and any future upsert path — the M4
29864 // `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
29865 // per-entry upsert, the `caixa-otel` per-scrape upsert —
29866 // surfaces its own typed variant).
29867 let mut arr: Vec<serde_yaml::Value> = Vec::new();
29868 let entry: serde_yaml::Value =
29869 serde_yaml::from_str("{ module: { source: oci://x } }").unwrap();
29870 let err = upsert_named_entry(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || {
29871 "missing-name".to_string()
29872 })
29873 .unwrap_err();
29874 assert_eq!(err, "missing-name");
29875 assert!(arr.is_empty(), "missing-name entry must not land in arr");
29876 }
29877
29878 #[test]
29879 fn upsert_named_entry_calls_error_closure_on_non_string_name_scalar() {
29880 // Non-string-name-scalar arm: when the new entry's
29881 // `<name_key>` is present but not a string (a number, a
29882 // mapping, a sequence — the paste-from-binary footgun where
29883 // an author or a schema-migration script accidentally lands a
29884 // JSON-Number in the name slot), the helper takes the same
29885 // path as the missing-name arm and calls the caller's
29886 // `on_missing_name` closure. Peer arm to the
29887 // upsert_named_entry_calls_error_closure_on_missing_name_key
29888 // pin — both non-string-scalar paths route through the same
29889 // caller-owned diagnostic.
29890 let mut arr: Vec<serde_yaml::Value> = Vec::new();
29891 let entry: serde_yaml::Value =
29892 serde_yaml::from_str("{ name: 42, module: { source: oci://x } }").unwrap();
29893 let err =
29894 upsert_named_entry(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || 7u32).unwrap_err();
29895 assert_eq!(err, 7u32);
29896 assert!(arr.is_empty());
29897 }
29898
29899 #[test]
29900 fn upsert_named_entry_uses_parametric_name_key() {
29901 // Name-key-axis-parametric pin: the helper matches on the
29902 // `name_key` parameter, not the pinned
29903 // [`FLEET_PROGRAMS_KEY_NAME`] const — a future writer-side
29904 // upsert path keying on a different discriminator scalar
29905 // (the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
29906 // per-entry `spec.selector` axis, an in-progress rebrand
29907 // promoting `id:` alongside `name:`) reaches for the same
29908 // helper with a different key rather than re-inlining the
29909 // upsert loop.
29910 let mut arr: Vec<serde_yaml::Value> =
29911 vec![serde_yaml::from_str("{ id: alpha, payload: original }").unwrap()];
29912 let entry: serde_yaml::Value =
29913 serde_yaml::from_str("{ id: alpha, payload: replaced }").unwrap();
29914 let inserted = upsert_named_entry::<()>(&mut arr, entry, "id", || ()).unwrap();
29915 assert!(!inserted, "matching `id:` must replace, not append");
29916 assert_eq!(arr.len(), 1);
29917 assert_eq!(
29918 arr[0].get("payload").and_then(|p| p.as_str()),
29919 Some("replaced")
29920 );
29921 }
29922
29923 // ── is_dns_1123_label — shared DNS-1123 label predicate ──────────────
29924
29925 #[test]
29926 fn dns_1123_label_accepts_canonical_forms() {
29927 // Substrate-side pin: the predicate accepts the same canonical
29928 // shapes its three caller axes (`:membros :caixa`,
29929 // `:placement :clusters`, `:children :caixa`) accept at their own
29930 // gates. Drift between this list and the per-axis positive-set
29931 // sweeps surfaces here — one source of truth for the rule.
29932 for s in [
29933 "worker",
29934 "a",
29935 "0",
29936 "cache-v2",
29937 "payment-retry",
29938 "2-pool",
29939 "mar-east",
29940 ] {
29941 is_dns_1123_label(s)
29942 .unwrap_or_else(|e| panic!("canonical DNS-1123 label {s:?} must pass: {e:?}"));
29943 }
29944 }
29945
29946 #[test]
29947 fn dns_1123_label_rejects_uppercase_with_lower_suggestion() {
29948 // The diagnostic carries the lower-cased fix verbatim so every
29949 // caller's per-axis `*Invalid { reason }` wrapping the predicate's
29950 // output reads back as a one-edit-fix suggestion. Pinned at the
29951 // substrate layer so the suggestion shape lives in one place.
29952 let err = is_dns_1123_label("Rio").unwrap_err();
29953 assert!(err.contains("uppercase"), "got: {err:?}");
29954 assert!(err.contains("\"rio\""), "got: {err:?}");
29955 }
29956
29957 #[test]
29958 fn dns_1123_label_rejects_at_64_byte_boundary() {
29959 // The 63-byte cap pin — both the boundary-exceeding case and
29960 // the boundary-accepting case in one place, so a future cap
29961 // shift surfaces both arms simultaneously.
29962 let max_ok = "a".repeat(63);
29963 is_dns_1123_label(&max_ok).unwrap();
29964 let too_long = "a".repeat(64);
29965 let err = is_dns_1123_label(&too_long).unwrap_err();
29966 assert!(err.contains("63"), "got: {err:?}");
29967 assert!(err.contains("64"), "got: {err:?}");
29968 }
29969
29970 #[test]
29971 fn dns_1123_label_rejects_empty_defensively() {
29972 // Defensive re-check pin — every peer value-shape predicate in
29973 // this module (`is_gateway_api_http_path`, `is_wit_world_ref`,
29974 // `is_nats_subject`, `is_wasi_keyvalue_slot`, `is_git_ref_name`)
29975 // carries the same empty-first arm, so `is_dns_1123_label("")`
29976 // returns a clean parser-shaped `must not be empty` reason
29977 // instead of panicking at the boundary arm's `bytes[0]` access
29978 // (`bytes[0].is_ascii_alphanumeric()` on an empty slice would
29979 // index out of bounds). The per-axis narrower `*Empty` variant
29980 // (`MembroCaixaEmpty`, `PlacementClusterEmpty`, `EmptyChildName`,
29981 // `ModuleEmpty`) still fires at every current call site — this
29982 // arm exists so any future call site missing the pre-check gets
29983 // a self-locating diagnostic rather than a `panic!` far from the
29984 // source caixa.lisp, matching the "usable from any future call
29985 // site without a shape-mismatch footgun" discipline every peer
29986 // predicate's doc-comment already promises.
29987 let err = is_dns_1123_label("").unwrap_err();
29988 assert!(err.contains("empty"), "got: {err:?}");
29989 assert_eq!(err, "must not be empty");
29990 }
29991
29992 // ── is_gateway_api_http_path — shared HTTP-path predicate ────────────
29993
29994 #[test]
29995 fn gateway_api_http_path_accepts_canonical_forms() {
29996 // Substrate-side pin: the predicate accepts the same canonical
29997 // shapes both caller axes (`:entrada :paths` and `:contratos
29998 // :endpoint`) accept at their own gates. Drift between this
29999 // list and the per-axis positive-set sweeps surfaces here —
30000 // one source of truth for the rule. Includes the bare-root
30001 // `/` (the catch-all both renderers fall back to), the
30002 // `/foo..bar` interior-`..`-substring (not a `..` segment),
30003 // the `/...` and `/foo.` `.`-bearing names (not `.` segments),
30004 // and the percent-encoded form.
30005 for p in [
30006 "/",
30007 "/api/cart",
30008 "/healthz",
30009 "/api/.config",
30010 "/v1/products",
30011 "/products/:id",
30012 "/api/cart/",
30013 "/api/caf%C3%A9",
30014 "/foo..bar",
30015 "/...",
30016 "/charge",
30017 ] {
30018 is_gateway_api_http_path(p)
30019 .unwrap_or_else(|e| panic!("canonical HTTP path {p:?} must pass: {e:?}"));
30020 }
30021 }
30022
30023 #[test]
30024 fn gateway_api_http_path_rejects_each_arm_with_substring_pinned_reason() {
30025 // Substrate-side diagnostic-shape pin: each grammar arm
30026 // surfaces its own distinct reason substring. Pinned here so
30027 // a future reason-wording rephrase that drops any of these
30028 // substrings surfaces at this one place, not piecemeal across
30029 // every per-axis test sweep.
30030 for (path, needle) in [
30031 ("/api?q=1", "must not contain `?`"),
30032 ("/api#frag", "must not contain `#`"),
30033 ("/api my", "whitespace"),
30034 ("/api\x01x", "control character"),
30035 ("/api/café", "non-ASCII"),
30036 ("/api//x", "consecutive `/`"),
30037 ("/api/./x", "`.` segment"),
30038 ("/api/../x", "`..` parent-segment"),
30039 ] {
30040 let err = is_gateway_api_http_path(path)
30041 .err()
30042 .unwrap_or_else(|| panic!("path {path:?} must be rejected"));
30043 assert!(
30044 err.contains(needle),
30045 "path {path:?} reason must contain {needle:?}; got {err:?}"
30046 );
30047 }
30048 }
30049
30050 #[test]
30051 fn gateway_api_http_path_rejects_at_1025_byte_boundary() {
30052 // The 1024-byte cap pin — both the boundary-exceeding case and
30053 // the boundary-accepting case in one place, so a future cap
30054 // shift surfaces both arms simultaneously, mirroring
30055 // `dns_1123_label_rejects_at_64_byte_boundary` on the peer
30056 // predicate.
30057 let max_ok = format!("/{}", "a".repeat(1023));
30058 assert_eq!(max_ok.len(), 1024);
30059 is_gateway_api_http_path(&max_ok).unwrap();
30060 let too_long = format!("/{}", "a".repeat(1024));
30061 assert_eq!(too_long.len(), 1025);
30062 let err = is_gateway_api_http_path(&too_long).unwrap_err();
30063 assert!(err.contains("1024"), "got: {err:?}");
30064 assert!(err.contains("1025"), "got: {err:?}");
30065 }
30066
30067 #[test]
30068 fn gateway_api_http_path_rejects_empty_defensively() {
30069 // The predicate is called only after each caller's narrower
30070 // `*Empty` arm has fired; re-checking here keeps the predicate
30071 // usable from any future call site without an empty-precondition
30072 // footgun, and avoids a panic on `bytes[0]`-style indexing if
30073 // a future arm is added. Same defensive empty-check
30074 // `validate_entrada_path` carries at its call site (55410e4).
30075 let err = is_gateway_api_http_path("").unwrap_err();
30076 assert!(err.contains("empty"), "got: {err:?}");
30077 }
30078
30079 #[test]
30080 fn gateway_api_http_path_rejects_not_absolute_defensively() {
30081 // Defensive re-check of the leading-`/` invariant the per-axis
30082 // call site enforces with its own narrower `*NotAbsolute` arm;
30083 // ensures the predicate is callable from any future call site
30084 // without a shape-mismatch footgun.
30085 let err = is_gateway_api_http_path("api/cart").unwrap_err();
30086 assert!(err.contains('/'), "got: {err:?}");
30087 }
30088
30089 #[test]
30090 fn gateway_api_http_path_rejects_every_reserved_printable_ascii_byte() {
30091 // Substrate-side sweep: every one of the eleven printable-ASCII
30092 // bytes outside the K8s Gateway API HTTPPathMatch.value
30093 // apiserver-side OpenAPI regex
30094 // `^(?:[-A-Za-z0-9/._~!$&'()*+,;=:@]|[%][0-9a-fA-F]{2})+$`
30095 // accepted set surfaces a self-locating reason naming the
30096 // offending byte verbatim plus the canonical `%XX` percent-
30097 // encoding remediation. RFC 3986 §3.3's `pchar = unreserved /
30098 // pct-encoded / sub-delims / ":" / "@"` grammar excludes these
30099 // bytes from every path segment, so the apiserver rejects them
30100 // at admission time on every
30101 // `HTTPRoute.spec.rules[].matches[].path.value` landing site —
30102 // peer with the `?` / `#` / whitespace / control / non-ASCII
30103 // arms `gateway_api_http_path_rejects_each_arm_with_substring_
30104 // pinned_reason` covers.
30105 //
30106 // Each char surfaces in a path-shape that pins the canonical
30107 // authoring footgun the K8s apiserver would otherwise catch
30108 // far from the caixa.lisp: `{id}` / `[0]` / `<placeholder>`
30109 // template forms, the Windows path-separator typo, the
30110 // shell-regex character footgun, the SQL-string-literal /
30111 // YAML-flow-mapping accidents.
30112 for (path, ch) in [
30113 ("/api/cart\"path", '"'),
30114 ("/api/cart<id>", '<'),
30115 ("/api/cart/<id>", '<'),
30116 ("/api/cart[0]", '['),
30117 ("/api/cart\\path", '\\'),
30118 ("/api/cart]", ']'),
30119 ("/api/cart/^foo", '^'),
30120 ("/api/cart/`foo", '`'),
30121 ("/api/cart/{id}", '{'),
30122 ("/api/cart|alt", '|'),
30123 ("/api/cart}", '}'),
30124 ] {
30125 let err = is_gateway_api_http_path(path)
30126 .err()
30127 .unwrap_or_else(|| panic!("path {path:?} must be rejected"));
30128 assert!(
30129 err.contains("reserved character"),
30130 "path {path:?} reason must name the reserved-character axis; got {err:?}"
30131 );
30132 assert!(
30133 err.contains(&format!("{ch:?}")),
30134 "path {path:?} reason must name the offending byte {ch:?} verbatim; got {err:?}"
30135 );
30136 let hex = format!("%{:02X}", ch as u8);
30137 assert!(
30138 err.contains(&hex),
30139 "path {path:?} reason must surface the canonical {hex:?} percent-encoding \
30140 remediation; got {err:?}"
30141 );
30142 }
30143 }
30144
30145 #[test]
30146 fn gateway_api_http_path_reserved_char_arm_fires_before_consecutive_slash() {
30147 // Precedence pin: the per-byte loop runs before the post-loop
30148 // structural arms (`//`, `/./`, `/../`), so a path that is
30149 // *both* reserved-char-bearing and consecutive-`/`-bearing
30150 // surfaces the more self-locating reserved-character diagnostic
30151 // first, naming the offending byte verbatim. Mirrors the
30152 // existing `?` / `#` / whitespace / control / non-ASCII arms'
30153 // implicit precedence the
30154 // `gateway_api_http_path_rejects_each_arm_with_substring_
30155 // pinned_reason` pin already establishes for the peer per-byte
30156 // shapes.
30157 let err = is_gateway_api_http_path("/api/{id}//x").unwrap_err();
30158 assert!(
30159 err.contains("reserved character") && err.contains("'{'"),
30160 "got: {err:?}"
30161 );
30162 assert!(
30163 !err.contains("consecutive"),
30164 "the reserved-char arm must fire before the consecutive-`/` arm; got: {err:?}"
30165 );
30166 }
30167
30168 #[test]
30169 fn gateway_api_http_path_accepts_percent_encoded_reserved_chars() {
30170 // Positive-control complement to the reserved-byte rejection
30171 // sweep: every one of the eleven reserved printable-ASCII bytes
30172 // is admissible *when* properly percent-encoded, matching the
30173 // canonical Gateway API HTTPPathMatch.value apiserver-side
30174 // OpenAPI regex's `[%][0-9a-fA-F]{2}` alternative. Pins the
30175 // canonical remediation pathway the reserved-byte arm's reason
30176 // wording names — author who carries a literal `{` percent-
30177 // encodes as `%7B` and the typed slot accepts.
30178 for path in [
30179 "/api/cart%22path",
30180 "/api/cart%3Cid%3E",
30181 "/api/cart%5B0%5D",
30182 "/api/cart%5Cpath",
30183 "/api/cart/%5Efoo",
30184 "/api/cart/%60foo",
30185 "/api/cart/%7Bid%7D",
30186 "/api/cart%7Calt",
30187 ] {
30188 is_gateway_api_http_path(path)
30189 .unwrap_or_else(|e| panic!("percent-encoded path {path:?} must pass: {e:?}"));
30190 }
30191 }
30192
30193 // ── is_wit_world_ref — shared WIT world-reference predicate ──────────
30194
30195 #[test]
30196 fn wit_world_ref_accepts_canonical_forms() {
30197 // Substrate-side pin: the predicate accepts every canonical
30198 // WIT identifier the `:contratos :wit` axis already carries in
30199 // the test fixtures + the example checkout-aplicacao (each
30200 // hand-curated to match real WIT registry references). Drift
30201 // between this list and the per-axis positive-set sweep
30202 // surfaces here — one source of truth for the rule. Includes
30203 // every shape variant: HTTP-prefixed (`wasi:http/proxy`),
30204 // KV-prefixed (`wasi:keyvalue/store`), pubsub-prefixed
30205 // (`nats:pub-sub`, `kafka:topic`), capability-only
30206 // (`custom:exchange`, `pleme:cap/audit`), the optional
30207 // `@<version>` suffix (`wasi:http/proxy@0.2.0`), and the
30208 // multi-segment `/iface/iface` form the WIT IDL grammar allows.
30209 for s in [
30210 "wasi:http/proxy",
30211 "wasi:keyvalue/store",
30212 "nats:pub-sub",
30213 "kafka:topic",
30214 "custom:exchange",
30215 "pleme:cap/audit",
30216 "http:server",
30217 "kv:store",
30218 "wasi:http/proxy@0.2.0",
30219 "wasi:keyvalue/store@0.2.0-rc.1",
30220 "pleme:cap/audit/v2",
30221 // Every legal shape SemVer 2.0.0 admits in the `@<version>`
30222 // body — bare numeric core, pre-release suffix (single +
30223 // dot-separated identifiers), build-metadata suffix (single
30224 // + dot-separated identifiers), combined pre-release +
30225 // build-metadata, and leading-zero-avoiding pre-release
30226 // identifiers — pinned here so a future tightening of the
30227 // per-byte accepted set that rejects a canonical semver
30228 // shape surfaces here rather than at the M4 CR materializer's
30229 // WIT-parse boundary.
30230 "wasi:http/proxy@1.0.0",
30231 "wasi:http/proxy@0.2.0-alpha",
30232 "wasi:http/proxy@1.0.0-alpha.1",
30233 "wasi:http/proxy@2.0.0+build.42",
30234 "wasi:http/proxy@0.0.0-rc.1+abc.def",
30235 ] {
30236 is_wit_world_ref(s)
30237 .unwrap_or_else(|e| panic!("canonical WIT reference {s:?} must pass: {e:?}"));
30238 }
30239 }
30240
30241 #[test]
30242 fn wit_world_ref_rejects_each_arm_with_substring_pinned_reason() {
30243 // Substrate-side diagnostic-shape pin: each grammar arm
30244 // surfaces its own distinct reason substring. Pinned here so a
30245 // future reason-wording rephrase that drops any of these
30246 // substrings surfaces at this one place, not piecemeal across
30247 // every per-axis test sweep. Mirrors
30248 // `gateway_api_http_path_rejects_each_arm_with_substring_pinned_reason`
30249 // on the peer predicate.
30250 for (s, needle) in [
30251 // Missing `:` separator → silent capability demotion.
30252 ("wasi-http/proxy", "must contain a `:`"),
30253 // Multiple `:` → can't split into ns + pkg.
30254 ("wasi:http:proxy", "exactly one `:`"),
30255 // Uppercase → silently bypasses the lowercase dispatch.
30256 ("WASI:http/proxy", "lowercase"),
30257 ("wasi:HTTP/proxy", "lowercase"),
30258 // Empty package half → can't resolve via WIT registry.
30259 ("wasi:", "must not be empty"),
30260 // Empty namespace half.
30261 (":http/proxy", "must not be empty"),
30262 // Underscore → DNS-1123 / WIT kebab-case footgun.
30263 ("wasi:http_proxy", "_"),
30264 // Leading digit → WIT identifiers begin with a letter.
30265 ("wasi:1http/proxy", "digit"),
30266 // Consecutive hyphens → invalid kebab-case.
30267 ("wasi:pub--sub", "consecutive `-`"),
30268 // Trailing hyphen → invalid kebab-case.
30269 ("wasi:proxy-", "must not end with `-`"),
30270 // Whitespace inside the token.
30271 ("wasi:http proxy", "whitespace"),
30272 // Control characters.
30273 ("wasi:http\x01proxy", "control character"),
30274 // Non-ASCII byte (café-style un-percent-encoded literal).
30275 ("wasi:caf\u{e9}/proxy", "non-ASCII"),
30276 // Trailing `@` with no version body.
30277 ("wasi:http/proxy@", "trailing `@`"),
30278 // Version body carrying `:` or `/`.
30279 ("wasi:http/proxy@0.2:rc1", "must not contain `:` or `/`"),
30280 // Doubled `@`.
30281 ("wasi:http/proxy@0.2@beta", "at most one `@`"),
30282 // Version body carrying a byte outside the SemVer 2.0.0
30283 // accepted set `[0-9A-Za-z.\-+]` — the canonical
30284 // author-side paste footguns (`?` from URL-query-separator
30285 // paste, `#` from URL-fragment paste, `!` from
30286 // history-expansion, `(` from parenthetical doc annotation,
30287 // `~` from tilde-range npm/Cargo semver-req paste that
30288 // strayed into the version body itself). Each surfaces the
30289 // `invalid character` reason substring so the diagnostic
30290 // wording is pinned alongside every peer per-byte rejection.
30291 ("wasi:http/proxy@0.2.0?rc1", "invalid character"),
30292 ("wasi:http/proxy@0.2.0#build", "invalid character"),
30293 ("wasi:http/proxy@0.2.0!alpha", "invalid character"),
30294 ("wasi:http/proxy@0.2.0(rc1)", "invalid character"),
30295 ("wasi:http/proxy@~0.2.0", "invalid character"),
30296 // Version body byte-set-valid but *structurally* invalid
30297 // SemVer 2.0.0 — the canonical author-side paste footguns
30298 // the byte-set gate above cannot catch. Every entry passes
30299 // the accepted-set arm `[0-9A-Za-z.\-+]` verbatim and
30300 // fails only at [`semver::Version::parse`]: two-part
30301 // numeric core (`@1.0` — Node.js `"engines"` field paste),
30302 // one-part numeric core (`@1` — Docker `:v1` tag paste),
30303 // four-part numeric core (`@1.0.0.0` — Microsoft / Java
30304 // build-number convention), `v`-prefixed version body
30305 // (`@v0.2.0` — git-tag-shape paste), leading-zero major
30306 // (`@01.0.0` — mistaken zero-padded date-based version),
30307 // trailing hyphen with empty pre-release (`@1.0.0-` —
30308 // half-typed pre-release), trailing plus with empty
30309 // build-metadata (`@1.0.0+` — peer for build-metadata),
30310 // empty pre-release identifier between dots
30311 // (`@1.0.0-.rc1` — accidental leading `.`), empty build-
30312 // metadata identifier between dots (`@1.0.0+.abc` — peer
30313 // for build-metadata), numeric pre-release identifier
30314 // with leading zero (`@1.0.0-01` — SemVer 2.0.0 rule 9),
30315 // consecutive dots inside pre-release (`@1.0.0-alpha..beta`).
30316 // Each surfaces the `structurally valid SemVer 2.0.0`
30317 // reason substring so the diagnostic wording is pinned
30318 // alongside every peer structural rejection.
30319 ("wasi:http/proxy@1.0", "structurally valid SemVer 2.0.0"),
30320 ("wasi:http/proxy@1", "structurally valid SemVer 2.0.0"),
30321 ("wasi:http/proxy@1.0.0.0", "structurally valid SemVer 2.0.0"),
30322 ("wasi:http/proxy@v0.2.0", "structurally valid SemVer 2.0.0"),
30323 ("wasi:http/proxy@01.0.0", "structurally valid SemVer 2.0.0"),
30324 ("wasi:http/proxy@1.0.0-", "structurally valid SemVer 2.0.0"),
30325 ("wasi:http/proxy@1.0.0+", "structurally valid SemVer 2.0.0"),
30326 (
30327 "wasi:http/proxy@1.0.0-.rc1",
30328 "structurally valid SemVer 2.0.0",
30329 ),
30330 (
30331 "wasi:http/proxy@1.0.0+.abc",
30332 "structurally valid SemVer 2.0.0",
30333 ),
30334 (
30335 "wasi:http/proxy@1.0.0-01",
30336 "structurally valid SemVer 2.0.0",
30337 ),
30338 (
30339 "wasi:http/proxy@1.0.0-alpha..beta",
30340 "structurally valid SemVer 2.0.0",
30341 ),
30342 // Digit-immediately-after-`-` word-start rule — the WIT IDL
30343 // `word ::= [a-z][a-z0-9]*` per-word first-byte gate the
30344 // predicate's doc-comment already documented, closed at the
30345 // implementation layer. Each identifier passes the outer
30346 // `[a-z0-9-]` byte set, the leading-`-` rejection, the
30347 // consecutive-`-` rejection, and the trailing-`-` rejection,
30348 // and was silently accepted before the arm landed — surfaces
30349 // the `word after `-`` reason substring so a future
30350 // diagnostic-wording rephrase surfaces here alongside every
30351 // peer per-arm substring pin. Canonical author-side
30352 // footguns: `"pub-1sub"` (version-shape digit paste),
30353 // `"proxy-2beta"` (v2 tag paste), `"cap-9"` (numeric
30354 // suffix). Namespace-side and interface-side variants pin
30355 // the arm fires uniformly on every WIT segment (`ns:pkg`,
30356 // `ns:pkg/iface`, not just the first).
30357 ("wasi:pub-1sub", "word after `-`"),
30358 ("wasi:proxy-2beta", "word after `-`"),
30359 ("wasi:cap-9", "word after `-`"),
30360 ("pleme-1cap:audit", "word after `-`"),
30361 ("wasi:http/proxy-3rc", "word after `-`"),
30362 ] {
30363 let err = is_wit_world_ref(s)
30364 .err()
30365 .unwrap_or_else(|| panic!("WIT reference {s:?} must be rejected"));
30366 assert!(
30367 err.contains(needle),
30368 "WIT reference {s:?} reason must contain {needle:?}; got {err:?}"
30369 );
30370 }
30371 }
30372
30373 #[test]
30374 fn wit_world_ref_word_after_hyphen_digit_arm_names_offending_byte_and_word_rule() {
30375 // Pin the per-word first-byte arm's diagnostic quality: the
30376 // offending byte appears verbatim in the reason, the WIT
30377 // grammar production is named (`[a-z][a-z0-9]*`), and the
30378 // remediation suggests a lowercase-letter prefix on the
30379 // offending word. Mirrors the `wit_world_ref_leading_digit`
30380 // sibling pin on the *first-word* first-byte arm — the two
30381 // arms enforce the same rule at complementary positions
30382 // (whole-id first byte vs. per-hyphen-word first byte), so
30383 // their diagnostic shapes stay peer.
30384 let err = is_wit_world_ref("wasi:pub-1sub").unwrap_err();
30385 assert!(err.contains("'1'"), "must name offending byte: {err:?}");
30386 assert!(
30387 err.contains("[a-z][a-z0-9]*"),
30388 "must name WIT word grammar: {err:?}"
30389 );
30390 assert!(
30391 err.contains("pub-v1sub"),
30392 "must suggest the letter-prefix remediation: {err:?}"
30393 );
30394 }
30395
30396 #[test]
30397 fn wit_world_ref_word_after_hyphen_lowercase_letter_still_accepted() {
30398 // Complement-side pin: the per-word first-byte arm strictly
30399 // targets *digits* after `-`; every canonical multi-word
30400 // lowercase identifier (`pub-sub`, `pub-sub-async`,
30401 // `wasi:http/incoming-handler`, `wasi:keyvalue/atomic-batch`)
30402 // remains in the accepted set with no new false-positive.
30403 // Pinned here so a future tightening that spills the digit-
30404 // rejection arm onto the letter-after-hyphen class surfaces
30405 // as a test failure at this positive-set pin, not at the M4
30406 // CR materializer's WIT-parse boundary. Mirrors the
30407 // `wit_world_ref_accepts_canonical_forms` positive-set
30408 // sweep, extended here to the multi-word-lowercase axis.
30409 for s in [
30410 "nats:pub-sub",
30411 "wasi:http/incoming-handler",
30412 "wasi:keyvalue/atomic-batch",
30413 "pleme:cap/audit-log",
30414 "http:server-side",
30415 ] {
30416 is_wit_world_ref(s).unwrap_or_else(|e| {
30417 panic!("canonical multi-word WIT identifier {s:?} must pass: {e:?}")
30418 });
30419 }
30420 }
30421
30422 #[test]
30423 fn wit_world_ref_word_after_hyphen_digit_arm_fires_before_byte_set_arm() {
30424 // Diagnostic-precedence pin: an identifier that is *both*
30425 // digit-after-`-` and byte-set-invalid (`"pub-1$"`) surfaces
30426 // the more self-locating word-start diagnostic, not the
30427 // generic invalid-character diagnostic. The arm order in the
30428 // loop is deliberate — the per-word first-byte gate fires on
30429 // the first offending byte (position 4 = the `1`) before the
30430 // byte-set gate can reach the `$` at position 5. Pinned here
30431 // so a future arm-reordering that moves the byte-set gate
30432 // earlier surfaces the drift at this test rather than
30433 // silently value-laundering the diagnostic.
30434 let err = is_wit_world_ref("wasi:pub-1$").unwrap_err();
30435 assert!(
30436 err.contains("word after `-`"),
30437 "must surface the per-word first-byte diagnostic, not the invalid-character one: {err:?}"
30438 );
30439 // And the `$` case *without* the digit-after-`-` still lands
30440 // on the invalid-character arm — the two diagnostics don't
30441 // collide when only one applies.
30442 let err = is_wit_world_ref("wasi:pub-x$").unwrap_err();
30443 assert!(
30444 err.contains("invalid character"),
30445 "byte-set-only rejection must still name invalid character: {err:?}"
30446 );
30447 }
30448
30449 #[test]
30450 fn wit_world_ref_rejects_empty_defensively() {
30451 // The predicate is called from `WitContract::target()` only
30452 // after the per-axis `EmptyWit` arm has fired at validate
30453 // time; re-checking here keeps the predicate usable from any
30454 // future call site without an empty-precondition footgun.
30455 // Same defensive empty-check `is_dns_1123_label` /
30456 // `is_gateway_api_http_path` carry at their call sites.
30457 let err = is_wit_world_ref("").unwrap_err();
30458 assert!(err.contains("empty"), "got: {err:?}");
30459 }
30460
30461 #[test]
30462 fn wit_world_ref_rejects_at_129_byte_boundary() {
30463 // The 128-byte cap pin — both the boundary-exceeding case and
30464 // the boundary-accepting case in one place, so a future cap
30465 // shift surfaces both arms simultaneously, mirroring
30466 // `dns_1123_label_rejects_at_64_byte_boundary` and
30467 // `gateway_api_http_path_rejects_at_1025_byte_boundary` on the
30468 // peer predicates. Constructed as `wasi:<long-pkg>` so the
30469 // kebab-shape arms don't fire first and obscure the cap arm.
30470 let pad = "a".repeat(123); // 5 + 123 = 128 (`wasi:` + pad)
30471 let max_ok = format!("wasi:{pad}");
30472 assert_eq!(max_ok.len(), 128);
30473 is_wit_world_ref(&max_ok).unwrap();
30474 let pad_over = "a".repeat(124);
30475 let too_long = format!("wasi:{pad_over}");
30476 assert_eq!(too_long.len(), 129);
30477 let err = is_wit_world_ref(&too_long).unwrap_err();
30478 assert!(err.contains("128"), "got: {err:?}");
30479 assert!(err.contains("129"), "got: {err:?}");
30480 }
30481
30482 // ── is_nats_subject — shared NATS subject predicate ──────────────────
30483
30484 #[test]
30485 fn nats_subject_accepts_canonical_forms() {
30486 // Substrate-side pin: the predicate accepts every canonical
30487 // NATS subject the `:contratos :subject` axis carries in the
30488 // caixa-mesh test fixtures + the example checkout-aplicacao
30489 // (each hand-curated to match real NATS server-side admission
30490 // shapes). Drift between this list and the per-axis positive-
30491 // set sweep surfaces here — one source of truth for the rule.
30492 // Includes single-token subjects, multi-dot subjects, snake-
30493 // case + kebab-case tokens (NATS accepts both), digit-bearing
30494 // tokens, the `*` single-token wildcard at every segment
30495 // position, and the `>` multi-token wildcard at the final
30496 // position (the two NATS subscription patterns the protocol
30497 // defines). Mirrors the canonical-forms sweeps on the peer
30498 // value-shape predicates (`gateway_api_http_path_accepts_…`,
30499 // `wit_world_ref_accepts_…`).
30500 for s in [
30501 "checkout.events.charge.failed",
30502 "rio.events.order.charged",
30503 "orders",
30504 "orders.123",
30505 "snake_case.token",
30506 "kebab-case.token",
30507 "MixedCase.Token",
30508 "alpha.beta.gamma.delta.epsilon",
30509 "orders.*.charged",
30510 "*.events.*",
30511 "orders.>",
30512 "*",
30513 ">",
30514 ] {
30515 is_nats_subject(s)
30516 .unwrap_or_else(|e| panic!("canonical NATS subject {s:?} must pass: {e:?}"));
30517 }
30518 }
30519
30520 #[test]
30521 fn nats_subject_rejects_each_arm_with_substring_pinned_reason() {
30522 // Substrate-side diagnostic-shape pin: each grammar arm
30523 // surfaces its own distinct reason substring. Pinned here so
30524 // a future reason-wording rephrase that drops any of these
30525 // substrings surfaces at this one place, not piecemeal across
30526 // every per-axis test sweep. Mirrors
30527 // `gateway_api_http_path_rejects_each_arm_with_substring_pinned_reason`
30528 // and `wit_world_ref_rejects_each_arm_with_substring_pinned_reason`
30529 // on the peer predicates.
30530 for (s, needle) in [
30531 // Whitespace inside the token.
30532 ("foo bar", "whitespace"),
30533 ("foo\tbar", "whitespace"),
30534 // Control characters.
30535 ("foo\x01bar", "control character"),
30536 // Non-ASCII byte (un-percent-encoded café-style literal).
30537 ("foo.caf\u{e9}", "non-ASCII"),
30538 // Leading `.` — empty leading token.
30539 (".foo", "must not start with `.`"),
30540 // Trailing `.` — empty trailing token.
30541 ("foo.", "must not end with `.`"),
30542 // Consecutive `.` — empty token between separators.
30543 ("foo..bar", "consecutive `.`"),
30544 // Non-trailing `>` multi-token wildcard.
30545 ("foo.>.bar", "only allowed as the final segment"),
30546 // Mid-segment `*` (not a standalone wildcard token).
30547 ("foo*.bar", "`*` mid-segment"),
30548 // Mid-segment `>` (not a standalone wildcard token).
30549 ("foo>", "`>` mid-segment"),
30550 // `.` is the separator, so `,` (or any other punctuation)
30551 // surfaces as an invalid-character arm.
30552 ("foo,bar", "invalid character"),
30553 // `:` reserved-looking — distinct invalid-character arm
30554 // (pinned separately so a future relaxation that accepts
30555 // `:` mid-segment surfaces here, not in some downstream
30556 // renderer's "this passed validate but the NATS server
30557 // rejected at publish" footgun).
30558 ("foo:bar", "invalid character"),
30559 ] {
30560 let err = is_nats_subject(s)
30561 .err()
30562 .unwrap_or_else(|| panic!("NATS subject {s:?} must be rejected"));
30563 assert!(
30564 err.contains(needle),
30565 "NATS subject {s:?} reason must contain {needle:?}; got {err:?}"
30566 );
30567 }
30568 }
30569
30570 #[test]
30571 fn nats_subject_rejects_empty_defensively() {
30572 // The predicate is called from `WitContract::target()` only
30573 // after the per-axis `ContratoSubjectEmpty` arm has fired at
30574 // validate time; re-checking here keeps the predicate usable
30575 // from any future call site without an empty-precondition
30576 // footgun. Same defensive empty-check `is_dns_1123_label`,
30577 // `is_gateway_api_http_path`, and `is_wit_world_ref` carry at
30578 // their call sites.
30579 let err = is_nats_subject("").unwrap_err();
30580 assert!(err.contains("empty"), "got: {err:?}");
30581 }
30582
30583 #[test]
30584 fn nats_subject_rejects_at_257_byte_boundary() {
30585 // The 256-byte cap pin — both the boundary-exceeding case and
30586 // the boundary-accepting case in one place, so a future cap
30587 // shift surfaces both arms simultaneously, mirroring
30588 // `dns_1123_label_rejects_at_64_byte_boundary`,
30589 // `gateway_api_http_path_rejects_at_1025_byte_boundary`, and
30590 // `wit_world_ref_rejects_at_129_byte_boundary` on the peer
30591 // predicates. Constructed as a single all-`a` token (no `.`)
30592 // so the segment / wildcard arms don't fire first and obscure
30593 // the cap arm.
30594 let max_ok = "a".repeat(256);
30595 assert_eq!(max_ok.len(), 256);
30596 is_nats_subject(&max_ok).unwrap();
30597 let too_long = "a".repeat(257);
30598 assert_eq!(too_long.len(), 257);
30599 let err = is_nats_subject(&too_long).unwrap_err();
30600 assert!(err.contains("256"), "got: {err:?}");
30601 assert!(err.contains("257"), "got: {err:?}");
30602 }
30603
30604 #[test]
30605 fn nats_subject_lone_wildcard_tokens_validate() {
30606 // The two NATS wildcards stand alone as the entire subject —
30607 // a `subscribe("*")` matches any single-token publish, a
30608 // `subscribe(">")` matches every NATS message on the connection.
30609 // Both are protocol-legal; the typed substrate accepts them
30610 // structurally and leaves the "should the typed `:contratos`
30611 // edge subscribe to literally everything?" question to a
30612 // future semantic-level gate. Pinned alongside the canonical-
30613 // forms sweep so a future tighten that disallows lone wildcards
30614 // surfaces both arms simultaneously.
30615 is_nats_subject("*").unwrap();
30616 is_nats_subject(">").unwrap();
30617 }
30618
30619 #[test]
30620 fn nats_subject_trailing_multi_wildcard_validates() {
30621 // `>` at the final segment is the canonical "match all trailing
30622 // tokens" subscription pattern. Pinned alongside the non-
30623 // trailing-`>` rejection arm so the boundary between the two
30624 // is in one place — a future relaxation that allows `>` at
30625 // non-trailing positions or a tighten that disallows trailing
30626 // `>` surfaces both arms simultaneously.
30627 is_nats_subject("orders.>").unwrap();
30628 is_nats_subject("orders.events.>").unwrap();
30629 // And the `*` single-token wildcard combines freely with the
30630 // trailing `>` — the canonical "match one middle token, then
30631 // anything trailing" subscription pattern.
30632 is_nats_subject("orders.*.>").unwrap();
30633 }
30634
30635 // ── is_wasi_keyvalue_slot — shared kv slot-template predicate ────────
30636
30637 #[test]
30638 fn wasi_kv_slot_accepts_canonical_forms() {
30639 // Substrate-side pin: the predicate accepts every canonical kv
30640 // slot template the `:contratos :slot` axis carries in the
30641 // caixa-mesh test fixtures + plausible authoring patterns
30642 // (each maps to a realistic wasi:keyvalue/store key the runtime
30643 // resolves on dispatch). Drift between this list and the
30644 // per-axis positive-set sweep surfaces here — one source of
30645 // truth for the rule. Includes:
30646 // - single-token identifiers (`"checkout"`, `"events"`);
30647 // - dot-namespaced templates (`"session.tokens.<sid>"`);
30648 // - path-namespaced templates with `$`-prefixed variables
30649 // (`"checkout/$orderId"`, the canonical Akka-cluster-
30650 // sharding-style template);
30651 // - colon-namespaced templates with brace placeholders
30652 // (`"users:{tenant}/{id}"`, the canonical multi-tenant
30653 // Redis-key shape);
30654 // - angle-bracket placeholders (`"session.<sid>"`);
30655 // - underscore identifiers (`"snake_case_key"`);
30656 // - kebab identifiers (`"kebab-case-key"`);
30657 // - mixed-case (`"MixedCase"` — kv slot templates are case-
30658 // sensitive; the predicate doesn't lowercase-fold);
30659 // - digit-bearing tokens (`"shard0"`, `"v2/key"`);
30660 // - percent-encoded fragments (`"users/caf%C3%A9"`); the
30661 // encoded form is the *valid* shape, the raw `café` is
30662 // rejected on the non-ASCII arm.
30663 // Mirrors the canonical-forms sweeps on the peer value-shape
30664 // predicates (`gateway_api_http_path_accepts_…`,
30665 // `nats_subject_accepts_canonical_forms`).
30666 for s in [
30667 "checkout",
30668 "events",
30669 "checkout/$orderId",
30670 "users:{tenant}/{id}",
30671 "session.<sid>",
30672 "session.tokens.<sid>",
30673 "snake_case_key",
30674 "kebab-case-key",
30675 "MixedCase",
30676 "shard0",
30677 "v2/key",
30678 "users/caf%C3%A9",
30679 ] {
30680 is_wasi_keyvalue_slot(s)
30681 .unwrap_or_else(|e| panic!("canonical kv slot {s:?} must pass: {e:?}"));
30682 }
30683 }
30684
30685 #[test]
30686 fn wasi_kv_slot_rejects_each_arm_with_substring_pinned_reason() {
30687 // Substrate-side diagnostic-shape pin: each grammar arm
30688 // surfaces its own distinct reason substring. Pinned here so
30689 // a future reason-wording rephrase that drops any of these
30690 // substrings surfaces at this one place, not piecemeal across
30691 // every per-axis test sweep. Mirrors
30692 // `nats_subject_rejects_each_arm_with_substring_pinned_reason`
30693 // and `gateway_api_http_path_rejects_each_arm_with_substring_pinned_reason`
30694 // on the peer predicates.
30695 for (s, needle) in [
30696 // Raw space inside the template — the canonical paste-from-
30697 // doc footgun.
30698 ("check out/$order", "whitespace"),
30699 // Tab byte — distinct arm-pinned reason from the space arm.
30700 ("check\tout", "whitespace"),
30701 // Control character (SOH = 0x01) — pinned separately from
30702 // the whitespace arm so a future relaxation that admits
30703 // raw whitespace but still rejects controls surfaces here.
30704 ("checkout/\x01order", "control character"),
30705 // Newline — the canonical "the paste-from-binary slug
30706 // spans multiple lines" footgun. Distinct from the
30707 // whitespace arm because `\n` is a control character.
30708 ("checkout\norder", "control character"),
30709 // DEL byte (0x7F) — the upper boundary of the control-
30710 // character range, pinned so a future relaxation that
30711 // only checks `< 0x20` surfaces here.
30712 ("checkout\x7forder", "control character"),
30713 // Un-percent-encoded non-ASCII byte — the canonical
30714 // "I copied the key from a doc with smart quotes /
30715 // accented characters" footgun. Author must percent-
30716 // encode (the canonical-forms sweep covers
30717 // `"users/caf%C3%A9"`).
30718 ("ch\u{e9}ckout/$order", "non-ASCII"),
30719 ] {
30720 let err = is_wasi_keyvalue_slot(s)
30721 .err()
30722 .unwrap_or_else(|| panic!("kv slot {s:?} must be rejected"));
30723 assert!(
30724 err.contains(needle),
30725 "kv slot {s:?} reason must contain {needle:?}; got {err:?}"
30726 );
30727 }
30728 }
30729
30730 #[test]
30731 fn wasi_kv_slot_rejects_empty_defensively() {
30732 // The predicate is called from `WitContract::target()` only
30733 // after the per-axis `ContratoSlotEmpty` arm has fired at
30734 // validate time; re-checking here keeps the predicate usable
30735 // from any future call site without an empty-precondition
30736 // footgun. Same defensive empty-check `is_dns_1123_label`,
30737 // `is_gateway_api_http_path`, `is_wit_world_ref`, and
30738 // `is_nats_subject` carry at their call sites.
30739 let err = is_wasi_keyvalue_slot("").unwrap_err();
30740 assert!(err.contains("empty"), "got: {err:?}");
30741 }
30742
30743 #[test]
30744 fn wasi_kv_slot_rejects_at_513_byte_boundary() {
30745 // The 512-byte cap pin — both the boundary-exceeding case and
30746 // the boundary-accepting case in one place, so a future cap
30747 // shift surfaces both arms simultaneously, mirroring
30748 // `dns_1123_label_rejects_at_64_byte_boundary`,
30749 // `gateway_api_http_path_rejects_at_1025_byte_boundary`,
30750 // `wit_world_ref_rejects_at_129_byte_boundary`, and
30751 // `nats_subject_rejects_at_257_byte_boundary` on the peer
30752 // predicates. Constructed as a single all-`a` token (no
30753 // separator / template syntax) so only the cap arm fires.
30754 let max_ok = "a".repeat(512);
30755 assert_eq!(max_ok.len(), 512);
30756 is_wasi_keyvalue_slot(&max_ok).unwrap();
30757 let too_long = "a".repeat(513);
30758 assert_eq!(too_long.len(), 513);
30759 let err = is_wasi_keyvalue_slot(&too_long).unwrap_err();
30760 assert!(err.contains("512"), "got: {err:?}");
30761 assert!(err.contains("513"), "got: {err:?}");
30762 }
30763
30764 #[test]
30765 fn wasi_kv_slot_admits_full_printable_ascii_range() {
30766 // Structural pin: the predicate admits every printable ASCII
30767 // byte from `0x21` (`!`) to `0x7E` (`~`) inclusive, including
30768 // every template-variable bracket the documented authoring
30769 // patterns use (`$`, `{`, `}`, `<`, `>`) and every namespace
30770 // separator (`/`, `:`, `.`, `-`, `_`). Drift here = a future
30771 // tighten that removes any byte from the admitted set surfaces
30772 // a name-the-byte test failure, not piecemeal across per-axis
30773 // sweeps. Constructed as a single all-bytes template (`b!`,
30774 // `b"`, …, `b~`) — the predicate doesn't impose structure,
30775 // only character-class.
30776 for b in 0x21u8..=0x7E {
30777 let s = std::str::from_utf8(&[b]).unwrap().to_string();
30778 is_wasi_keyvalue_slot(&s)
30779 .unwrap_or_else(|e| panic!("printable ASCII byte 0x{b:02x} must pass: {e:?}"));
30780 }
30781 }
30782
30783 #[test]
30784 fn git_ref_name_accepts_canonical_forms() {
30785 // Substrate-side pin: the predicate accepts every canonical
30786 // refname the `:fonte :tag` / `:fonte :branch` axes carry in
30787 // realistic authoring patterns (each maps to a refname `git
30788 // fetch <remote> tag '<value>'` and `git checkout '<value>'`
30789 // resolve cleanly at clone time). Drift between this list and
30790 // any per-axis positive-set sweep surfaces here — one source
30791 // of truth for the rule. Includes:
30792 // - semver tag with `v` prefix (`"v0.1.0"`, the canonical
30793 // pleme-io release shape);
30794 // - bare semver tag (`"0.1.0"`, the npm / Cargo idiom);
30795 // - pre-release tag (`"v0.1.0-alpha.1"`);
30796 // - release-line tag with hyphens (`"release-1.0"`);
30797 // - leaf branch (`"main"` / `"master"`);
30798 // - hierarchical feature branch (`"feature/checkout"`);
30799 // - multi-component branch with hyphens and digits
30800 // (`"user-1/feat-x-v2"`);
30801 // - dot-bearing tag (`"v0.1.0.rc1"`, mid-component dot
30802 // allowed — only consecutive `..` and trailing `.` are
30803 // rejected).
30804 // Mirrors the canonical-forms sweeps on the peer value-shape
30805 // predicates (`wasi_kv_slot_accepts_canonical_forms`,
30806 // `nats_subject_accepts_canonical_forms`).
30807 for s in [
30808 "v0.1.0",
30809 "0.1.0",
30810 "v0.1.0-alpha.1",
30811 "release-1.0",
30812 "main",
30813 "master",
30814 "feature/checkout",
30815 "user-1/feat-x-v2",
30816 "v0.1.0.rc1",
30817 "stable",
30818 ] {
30819 is_git_ref_name(s)
30820 .unwrap_or_else(|e| panic!("canonical git ref {s:?} must pass: {e:?}"));
30821 }
30822 }
30823
30824 #[test]
30825 fn git_ref_name_rejects_each_arm_with_substring_pinned_reason() {
30826 // Substrate-side diagnostic-shape pin: each grammar arm
30827 // surfaces its own distinct reason substring. Pinned here so
30828 // a future reason-wording rephrase that drops any of these
30829 // substrings surfaces at this one place, not piecemeal across
30830 // every per-axis test sweep. Mirrors
30831 // `wasi_kv_slot_rejects_each_arm_with_substring_pinned_reason`
30832 // and `nats_subject_rejects_each_arm_with_substring_pinned_reason`
30833 // on the peer predicates.
30834 for (s, needle) in [
30835 // Trailing space — the canonical paste-from-doc footgun.
30836 ("v0.1.0 ", "whitespace"),
30837 // Embedded space (branch with spaces).
30838 ("feature/foo bar", "whitespace"),
30839 // Tab byte.
30840 ("v0.1.0\t", "whitespace"),
30841 // Newline — the canonical "paste-from-multiline-doc"
30842 // footgun. Distinct from the whitespace arm because `\n`
30843 // is a control character.
30844 ("v0.1.0\n", "control character"),
30845 // DEL byte (0x7F) — upper boundary of the control range.
30846 ("v0.1.0\x7f", "control character"),
30847 // Non-ASCII byte (the canonical "I copied the tag from a
30848 // doc with smart quotes" footgun).
30849 ("v0.1.0\u{e9}", "non-ASCII"),
30850 // Tilde — git's revision grammar (`HEAD~3`).
30851 ("v0.1.0~1", "`~`"),
30852 // Caret — git's revision grammar (`HEAD^`).
30853 ("v0.1.0^", "`^`"),
30854 // Colon — git's refspec separator.
30855 ("v0.1.0:rebase", "`:`"),
30856 // Question mark — git's refspec glob.
30857 ("v0.1.0?", "`?`"),
30858 // Asterisk — git's refspec glob.
30859 ("v0.1.*", "`*`"),
30860 // Open bracket — git's refspec glob.
30861 ("v0.1.0[1]", "`[`"),
30862 // Backslash — the canonical Windows-path-leak footgun.
30863 ("feature\\foo", "`\\`"),
30864 // Consecutive dots — git's `<rev1>..<rev2>` range grammar.
30865 ("v0.1..0", "`..`"),
30866 // Reflog grammar.
30867 ("main@{upstream}", "`@{`"),
30868 // The bare `@` — git aliases to `HEAD`.
30869 ("@", "bare `@`"),
30870 // Leading slash.
30871 ("/main", "begin with `/`"),
30872 // Trailing slash.
30873 ("feature/", "end with `/`"),
30874 // Consecutive slashes.
30875 ("feature//foo", "consecutive `/`"),
30876 // Trailing dot.
30877 ("v0.1.0.", "end with `.`"),
30878 // Fully-qualified branch ref — the canonical
30879 // `git show-ref`-output-leak footgun.
30880 ("refs/heads/main", "fully-qualified"),
30881 // Fully-qualified tag ref.
30882 ("refs/tags/v0.1.0", "fully-qualified"),
30883 // Component beginning with `.` (per-component rule).
30884 ("feature/.hidden", "begin with `.`"),
30885 // Component ending with `.lock` (per-component rule).
30886 ("feature/main.lock", "`.lock`"),
30887 // Leaf ref named `<x>.lock` — same per-component rule on
30888 // the single-component refname.
30889 ("main.lock", "`.lock`"),
30890 // Case-insensitive `.LOCK` — APFS / NTFS / HFS+ admit
30891 // both spellings as the same on-disk file, so a
30892 // `:tag "v1.LOCK"` collides with git's atomic-rename
30893 // guard on case-insensitive filesystems. Pinned
30894 // separately from the canonical lowercase arm so a
30895 // future relaxation that only catches lowercase
30896 // surfaces here.
30897 ("v1.LOCK", "`.lock`"),
30898 ("feature/Main.Lock", "`.lock`"),
30899 ] {
30900 let err = is_git_ref_name(s)
30901 .err()
30902 .unwrap_or_else(|| panic!("git ref {s:?} must be rejected"));
30903 assert!(
30904 err.contains(needle),
30905 "git ref {s:?} reason must contain {needle:?}; got {err:?}"
30906 );
30907 }
30908 }
30909
30910 #[test]
30911 fn git_ref_name_rejects_empty_defensively() {
30912 // The predicate is called from `DepSource::validate` only
30913 // after the per-axis `FontePinEmpty` arm has fired at
30914 // validate time; re-checking here keeps the predicate usable
30915 // from any future call site without an empty-precondition
30916 // footgun. Same defensive empty-check `is_dns_1123_label`,
30917 // `is_gateway_api_http_path`, `is_wit_world_ref`,
30918 // `is_nats_subject`, and `is_wasi_keyvalue_slot` carry at
30919 // their call sites.
30920 let err = is_git_ref_name("").unwrap_err();
30921 assert!(err.contains("empty"), "got: {err:?}");
30922 }
30923
30924 #[test]
30925 fn git_ref_name_rejects_at_256_byte_boundary() {
30926 // The 255-byte cap pin — both the boundary-exceeding case and
30927 // the boundary-accepting case in one place, so a future cap
30928 // shift surfaces both arms simultaneously, mirroring
30929 // `dns_1123_label_rejects_at_64_byte_boundary`,
30930 // `gateway_api_http_path_rejects_at_1025_byte_boundary`,
30931 // `wit_world_ref_rejects_at_129_byte_boundary`,
30932 // `nats_subject_rejects_at_257_byte_boundary`, and
30933 // `wasi_kv_slot_rejects_at_513_byte_boundary` on the peer
30934 // predicates. Constructed as a single all-`a` leaf so only
30935 // the cap arm fires.
30936 let max_ok = "a".repeat(255);
30937 assert_eq!(max_ok.len(), 255);
30938 is_git_ref_name(&max_ok).unwrap();
30939 let too_long = "a".repeat(256);
30940 assert_eq!(too_long.len(), 256);
30941 let err = is_git_ref_name(&too_long).unwrap_err();
30942 assert!(err.contains("255"), "got: {err:?}");
30943 assert!(err.contains("256"), "got: {err:?}");
30944 }
30945
30946 #[test]
30947 fn git_ref_name_qualified_prefix_diagnostic_quotes_leaf() {
30948 // Diagnostic-shape pin: the `refs/heads/` / `refs/tags/`
30949 // rejection arm enumerates the leaf the author probably
30950 // meant, so the author's grep target is the *intended*
30951 // refname literal rather than the (rejected) qualified form.
30952 // Pinned across both prefixes so a future relaxation that
30953 // drops the leaf-suggestion surfaces here.
30954 for (qualified, leaf) in [
30955 ("refs/heads/main", "main"),
30956 ("refs/tags/v0.1.0", "v0.1.0"),
30957 ("refs/heads/feature/checkout", "feature/checkout"),
30958 ] {
30959 let err = is_git_ref_name(qualified).unwrap_err();
30960 assert!(
30961 err.contains(&format!("{leaf:?}")),
30962 "qualified ref {qualified:?} diagnostic must quote the leaf \
30963 {leaf:?}; got {err:?}"
30964 );
30965 }
30966 }
30967
30968 // ── is_git_ref_name canonical-OID-shape partition arm ────────────────
30969
30970 #[test]
30971 fn git_ref_name_rejects_canonical_sha1_oid() {
30972 // The fail-before-pass-after pin on the canonical SHA-1 OID
30973 // partition arm: a 40-char lowercase-hex string is the shape
30974 // `is_git_oid` accepts, so `is_git_ref_name` must reject it.
30975 // Until this arm landed `is_git_ref_name` accepted every
30976 // 40-char lowercase-hex string (pure hex carries none of the
30977 // forbidden refname characters, no `..`/`@{`/`/`-prefix/
30978 // `/`-suffix/`.lock`-suffix/`refs/heads/`-prefix), silently
30979 // breaking the cross-axis partition the
30980 // [`DepSource::validate`] gate routes the `:fonte` axes
30981 // through and admitting `:tag "deadbeef…"` /
30982 // `:branch "deadbeef…"` as legitimate refnames — the
30983 // canonical paste-from-`git show --format=%H` mis-slot
30984 // footgun. The diagnostic names the `:rev` axis so the author
30985 // grep-fixes in one edit.
30986 for oid in [
30987 "0123456789abcdef0123456789abcdef01234567",
30988 "deadbeefcafebabe0123456789abcdef01234567",
30989 "ffffffffffffffffffffffffffffffffffffffff",
30990 "0000000000000000000000000000000000000000",
30991 ] {
30992 assert_eq!(oid.len(), GIT_OID_SHA1_LEN);
30993 let err = is_git_ref_name(oid).unwrap_err();
30994 assert!(
30995 err.contains("OID") && err.contains(":rev"),
30996 "canonical SHA-1 OID {oid:?} must surface a diagnostic \
30997 naming OID + `:rev`; got {err:?}"
30998 );
30999 assert!(
31000 err.contains("SHA-1"),
31001 "canonical SHA-1 OID {oid:?} diagnostic must name the \
31002 hash algorithm; got {err:?}"
31003 );
31004 }
31005 }
31006
31007 #[test]
31008 fn git_ref_name_rejects_canonical_sha256_oid() {
31009 // The fail-before-pass-after pin on the canonical SHA-256 OID
31010 // partition arm — Git 2.42+ `extensions.objectFormat = sha256`
31011 // mode. 64-char lowercase-hex strings are equally OID-shaped
31012 // and must surface the same `:rev`-axis diagnostic. Pinned
31013 // separately from SHA-1 so a future relaxation that only
31014 // catches one width surfaces here.
31015 let sha256_zeros = "0".repeat(GIT_OID_SHA256_LEN);
31016 let sha256_ones = "f".repeat(GIT_OID_SHA256_LEN);
31017 let sha256_mixed = format!("deadbeefcafebabe{}", "0123456789abcdef".repeat(3));
31018 for oid in [&sha256_zeros, &sha256_ones, &sha256_mixed] {
31019 assert_eq!(oid.len(), GIT_OID_SHA256_LEN);
31020 let err = is_git_ref_name(oid).unwrap_err();
31021 assert!(
31022 err.contains("OID") && err.contains(":rev"),
31023 "canonical SHA-256 OID {oid:?} must surface a \
31024 diagnostic naming OID + `:rev`; got {err:?}"
31025 );
31026 assert!(
31027 err.contains("SHA-256"),
31028 "canonical SHA-256 OID {oid:?} diagnostic must name \
31029 the hash algorithm; got {err:?}"
31030 );
31031 }
31032 }
31033
31034 #[test]
31035 fn git_ref_name_partition_excludes_off_by_one_lengths() {
31036 // Boundary pin: lengths that *aren't* exactly 40 or 64 hex
31037 // characters are NOT canonical OIDs, so the partition arm
31038 // must not fire — they remain accepted as refnames (consistent
31039 // with `is_git_oid` rejecting them on its exact-width check).
31040 // Abbreviated OIDs (`"c0ffee0"`, 7-char prefix) are ambiguous
31041 // across repository history and `is_git_oid` rejects them
31042 // separately, but they're legitimate refname shapes per `git
31043 // check-ref-format`, so `is_git_ref_name` accepts them here.
31044 // Pinned across the 39/41/63/65-char and abbreviated arms so
31045 // a future widening of the partition arm to "any hex-shaped
31046 // value" surfaces here as a regression rather than silently
31047 // rejecting valid refnames.
31048 for accept in [
31049 // 39 hex chars — one short of SHA-1 width.
31050 "0123456789abcdef0123456789abcdef0123456",
31051 // 41 hex chars — one over SHA-1 width.
31052 "0123456789abcdef0123456789abcdef012345670",
31053 // 63 hex chars — one short of SHA-256 width.
31054 &"a".repeat(63),
31055 // 65 hex chars — one over SHA-256 width.
31056 &"a".repeat(65),
31057 // Abbreviated 7-char SHA — the `git log --short` width.
31058 "c0ffee0",
31059 // Pure-numeric 8-char (looks vaguely SHA-shaped but
31060 // isn't canonical-width).
31061 "00000000",
31062 ] {
31063 is_git_ref_name(accept).unwrap_or_else(|e| {
31064 panic!(
31065 "off-canonical-width hex-shaped value {accept:?} \
31066 (len {len}) must still pass is_git_ref_name — \
31067 the partition arm is exact-width 40/64, not a \
31068 prefix or pattern: {e:?}",
31069 len = accept.len()
31070 )
31071 });
31072 }
31073 }
31074
31075 #[test]
31076 fn git_ref_name_partition_excludes_uppercase_canonical_widths() {
31077 // Boundary pin: the partition arm targets the canonical
31078 // *lowercase-hex* OID shape `git rev-parse HEAD` /
31079 // `git show --format=%H` emit. Uppercase or mixed-case
31080 // 40/64-char hex strings are legitimate refnames per
31081 // `git check-ref-format` (uppercase letters are admitted in
31082 // refnames), so `is_git_ref_name` accepts them here; the
31083 // `:rev` axis separately rejects uppercase OIDs via
31084 // [`is_git_oid`]'s lowercase-only contract — so neither
31085 // axis silently admits an uppercase-hex value cross-slot.
31086 // Pinned across both widths + both uppercase variants so a
31087 // future relaxation of either predicate surfaces here.
31088 for accept in [
31089 // Uppercase 40-char hex — passes is_git_ref_name (valid
31090 // refname), rejected by is_git_oid on lowercase contract.
31091 "DEADBEEFCAFEBABE0123456789ABCDEF01234567",
31092 // Mixed case 40-char hex.
31093 "DeadBeefCafeBabe0123456789abcdef01234567",
31094 // Uppercase 64-char hex.
31095 &"A".repeat(64),
31096 ] {
31097 is_git_ref_name(accept).unwrap_or_else(|e| {
31098 panic!(
31099 "uppercase canonical-width hex value {accept:?} \
31100 must still pass is_git_ref_name — the partition \
31101 arm targets lowercase-canonical only (uppercase \
31102 is a legitimate refname character per \
31103 git-check-ref-format); the `:rev` axis catches \
31104 uppercase via is_git_oid's lowercase contract: \
31105 {e:?}"
31106 )
31107 });
31108 // And confirm is_git_oid rejects it on the lowercase arm
31109 // (so neither axis silently admits the value).
31110 let oid_err = is_git_oid(accept).unwrap_err();
31111 assert!(
31112 oid_err.contains("lowercase") || oid_err.contains("uppercase"),
31113 "uppercase hex value {accept:?} must be rejected by \
31114 is_git_oid on its lowercase contract; got {oid_err:?}"
31115 );
31116 }
31117 }
31118
31119 #[test]
31120 fn git_ref_name_partition_arm_fires_before_per_byte_scan() {
31121 // Order pin: the partition arm runs after the length check
31122 // but before the per-byte refname-character scan, so a
31123 // canonical-OID-shaped value surfaces the `:rev`-axis
31124 // diagnostic rather than (e.g.) falling through to a generic
31125 // per-component arm. Pinned via a canonical OID — pure hex
31126 // can't violate any of the per-byte / `..` / `@{` / `/` /
31127 // `.lock` / `refs/heads/` arms (which is precisely why the
31128 // partition arm is needed), so position-wise this pin
31129 // forecloses a future refactor that splits the partition arm
31130 // across the scan (where uppercase / mixed-case canonical-
31131 // width values would silently route through one branch).
31132 let oid = "0123456789abcdef0123456789abcdef01234567";
31133 let err = is_git_ref_name(oid).unwrap_err();
31134 // The diagnostic mentions OID + `:rev`; it does NOT contain
31135 // any of the per-byte-arm needle substrings the
31136 // `git_ref_name_rejects_each_arm_with_substring_pinned_reason`
31137 // sweep pins, structurally — canonical OIDs can't violate
31138 // those arms.
31139 assert!(err.contains("OID"), "got: {err:?}");
31140 assert!(err.contains(":rev"), "got: {err:?}");
31141 }
31142
31143 #[test]
31144 fn git_ref_name_rejects_leading_hyphen_cli_arg_injection() {
31145 // The CLI-arg-injection arm pin on the `:tag` / `:branch` axis.
31146 // Git's `check-ref-format` grammar admits a leading `-` (the
31147 // byte is a legitimate kebab continuation), so every prior
31148 // shape arm passes the value through; the diagnostic moves
31149 // the gate to the subprocess-argument boundary the resolver
31150 // consumes. Pinned across the canonical CLI-arg-injection
31151 // shapes — short-flag-shaped `"-X"`, long-option-shaped
31152 // `"-stable"`, git-config-injection-shaped
31153 // `"-c=core.merge=ours"`, the canonical
31154 // `"--upload-pack=…"` long-flag form, and the
31155 // `"--config"`-shape repeat-arg form — every shape would
31156 // silently escape `git checkout --quiet --detach <ref>` (the
31157 // resolver's invocation in `caixa-resolver/src/git.rs:41`,
31158 // no `--` argument-list terminator) and get reinterpreted by
31159 // `git checkout`'s argument parser. Peer with the
31160 // `is_git_repo_url` leading-`-` arm (same vector on the
31161 // sibling `:repo` axis), `is_cargo_feature_name` leading-`-`
31162 // arm, and `is_dns_1123_label` leading-`-` arm — the
31163 // substrate-wide "no leading `-` anywhere in a typed
31164 // single-token string slot routed through a subprocess
31165 // argument" invariant is now structurally consistent across
31166 // every value-shape-gated typed surface.
31167 for s in [
31168 "-X", // short-flag-shape
31169 "-stable", // long-option-shape
31170 "-c=core.merge=ours", // git-config-injection-shape
31171 "--upload-pack=cat /etc", // long-flag with-value
31172 "--config", // repeat-arg shape
31173 "-", // degenerate single-byte
31174 ] {
31175 let err = is_git_ref_name(s)
31176 .err()
31177 .unwrap_or_else(|| panic!("git ref {s:?} must be rejected"));
31178 assert!(
31179 err.contains("`-`"),
31180 "git ref {s:?} reason must surface the leading-`-` arm: {err:?}"
31181 );
31182 assert!(
31183 err.contains("CLI-argument-injection"),
31184 "git ref {s:?} reason must name the CLI-argument-injection \
31185 vector: {err:?}"
31186 );
31187 }
31188 // Positive control: a mid-name `-` (the canonical kebab
31189 // separator) passes — `"v0-1-0"`, `"feature-x"`, `"main-2"`
31190 // — pinning that the arm only fires at the leading position,
31191 // not anywhere else.
31192 for s in ["v0-1-0", "feature-x", "main-2"] {
31193 is_git_ref_name(s).unwrap_or_else(|e| {
31194 panic!("mid-name `-` ref {s:?} must pass the leading-`-` arm: {e:?}")
31195 });
31196 }
31197 }
31198
31199 #[test]
31200 fn git_ref_name_leading_hyphen_fires_before_per_byte_scan() {
31201 // Cascade-precedence pin: a `"-flag\n"` value carries both a
31202 // leading `-` and an embedded `\n` control byte; the leading-`-`
31203 // arm fires first (the byte sits at the leading position the
31204 // arm probes, before the per-byte cascade loop's control-byte
31205 // arm). Mirrors the order pin
31206 // `git_ref_name_partition_arm_fires_before_per_byte_scan`
31207 // establishes on the canonical-OID partition arm — both
31208 // pre-loop arms structurally precede the per-byte scan.
31209 let err = is_git_ref_name("-flag\n").unwrap_err();
31210 assert!(err.contains("`-`"), "got: {err:?}");
31211 assert!(
31212 !err.contains("control character"),
31213 "leading-`-` arm must fire before the control-byte per-byte arm: {err:?}"
31214 );
31215 }
31216
31217 #[test]
31218 fn git_ref_name_leading_hyphen_fires_after_canonical_oid_partition() {
31219 // Cascade-precedence pin: the partition arm structurally
31220 // precedes the leading-`-` arm because a canonical OID shape
31221 // (40 / 64 lowercase hex bytes) cannot start with `-` — the
31222 // byte sets are disjoint, so the precedence pin is a no-op at
31223 // value level. The pin matters only at the diagnostic-shape
31224 // level — it ensures a future codec round-trip that
31225 // synthesizes a probe-as-both value (impossible today;
31226 // possible if the OID partition arm ever relaxes its byte
31227 // set) surfaces the more self-locating `:rev`-mis-slot
31228 // diagnostic rather than the broader CLI-arg-injection one.
31229 let oid = "0123456789abcdef0123456789abcdef01234567";
31230 let err = is_git_ref_name(oid).unwrap_err();
31231 assert!(err.contains("OID"), "got: {err:?}");
31232 assert!(
31233 !err.contains("CLI-argument-injection"),
31234 "OID partition arm must precede leading-`-` arm: {err:?}"
31235 );
31236 }
31237
31238 // ── is_git_oid — `:fonte :rev` value-shape predicate ────────────────
31239
31240 #[test]
31241 fn git_oid_canonical_widths_match_sha1_and_sha256() {
31242 // The single-source-of-truth pin on the two canonical widths.
31243 // Drift between the predicate's accepted widths and the const
31244 // values would surface here as a build error, not as a silent
31245 // round-trip break at the renderer layer. Mirrors
31246 // `wasm32_memory_cap_matches_parsed_4_gib` (9d49a3a) — the
31247 // constant equality pin keeps the contract one place.
31248 assert_eq!(GIT_OID_SHA1_LEN, 40);
31249 assert_eq!(GIT_OID_SHA256_LEN, 64);
31250 // Doubled width: SHA-256 is exactly twice SHA-1 in hex char
31251 // count (256 / 4 = 64; 160 / 4 = 40). Pinned so a future
31252 // hash-algorithm widening reads the relationship here.
31253 assert_eq!(GIT_OID_SHA256_LEN, GIT_OID_SHA1_LEN * 2 - 16);
31254 }
31255
31256 #[test]
31257 fn git_oid_accepts_canonical_sha1() {
31258 // Positive control on the SHA-1 OID width: 40 lowercase hex
31259 // characters — the canonical `git rev-parse HEAD` emission
31260 // shape every realistic pleme-io upstream uses today. The all-
31261 // `f` boundary is the lexicographically-largest OID (a real
31262 // commit's hash could land here, and the predicate accepts it
31263 // because it's structurally a valid OID — the null-OID
31264 // sentinel arm partitions the all-`0` boundary only, not the
31265 // all-`f` one).
31266 is_git_oid("0123456789abcdef0123456789abcdef01234567").unwrap();
31267 is_git_oid("deadbeefcafebabe0123456789abcdef01234567").unwrap();
31268 is_git_oid("ffffffffffffffffffffffffffffffffffffffff").unwrap();
31269 }
31270
31271 #[test]
31272 fn git_oid_accepts_canonical_sha256() {
31273 // Positive control on the SHA-256 OID width: 64 lowercase hex
31274 // characters — `git`'s `extensions.objectFormat = sha256`
31275 // emission (GA since Git 2.42 / Oct 2023). Doubled SHA-1 width.
31276 let sha256_one = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
31277 assert_eq!(sha256_one.len(), 64);
31278 is_git_oid(sha256_one).unwrap();
31279 let sha256_fs = "f".repeat(64);
31280 is_git_oid(&sha256_fs).unwrap();
31281 }
31282
31283 #[test]
31284 fn git_oid_rejects_null_oid_sentinel_sha1() {
31285 // Canonical "I copy-pasted the no-such-commit sentinel out of
31286 // `git update-ref --stdin` docs / pre-receive hook example"
31287 // footgun on the SHA-1 width — the all-zero 40-char hex
31288 // string is git's `null OID` sentinel (used to indicate ref
31289 // create / delete in update-ref flows) and never names a real
31290 // commit in any repo's object database. Until the null-OID
31291 // arm landed it passed every other shape arm (canonical
31292 // length, lowercase hex) and surfaced at `git fetch <remote>
31293 // 0000…0000` time with a quoting-confused "couldn't find
31294 // remote ref" error far from the source caixa.lisp, with the
31295 // lacre's content-address locked to a `git:0000…0000` closure
31296 // that never equals any upstream's actual `HEAD`. The
31297 // diagnostic carries the `40` width verbatim so a future
31298 // SHA-256 fixture surfaces the same arm at the doubled width
31299 // boundary.
31300 let null_sha1 = "0".repeat(40);
31301 let err = is_git_oid(&null_sha1).unwrap_err();
31302 assert!(
31303 err.contains("null-OID sentinel"),
31304 "reason must name the sentinel: {err}",
31305 );
31306 assert!(err.contains("40"), "reason must name the width: {err}",);
31307 assert!(
31308 err.contains("no-such-commit") || err.contains("update-ref"),
31309 "reason must reference git's null-OID semantics: {err}",
31310 );
31311 }
31312
31313 #[test]
31314 fn git_oid_rejects_null_oid_sentinel_sha256() {
31315 // Same sentinel on the SHA-256 width — `git`'s
31316 // `extensions.objectFormat = sha256` mode (GA Git 2.42 / Oct
31317 // 2023) carries the same null-OID semantics on the doubled
31318 // 64-char width. Pinned separately so a future relaxation that
31319 // only catches the SHA-1 width surfaces here, peer with the
31320 // SHA-1 / SHA-256 pair-pinning posture
31321 // `git_oid_accepts_canonical_sha1` /
31322 // `git_oid_accepts_canonical_sha256` already establishes for
31323 // the positive controls.
31324 let null_sha256 = "0".repeat(64);
31325 let err = is_git_oid(&null_sha256).unwrap_err();
31326 assert!(
31327 err.contains("null-OID sentinel"),
31328 "reason must name the sentinel: {err}",
31329 );
31330 assert!(err.contains("64"), "reason must name the width: {err}",);
31331 }
31332
31333 #[test]
31334 fn git_oid_null_oid_fires_after_length_and_hex_arms() {
31335 // Cascade-precedence pin: the null-OID arm runs *after* the
31336 // length + character-class arms, so an off-by-one-length all-
31337 // zeros value surfaces the narrower `abbreviated` diagnostic
31338 // (the length arm's own reason wording) before the structural
31339 // null-OID diagnostic, and an uppercase all-zeros value (which
31340 // can't actually exist — `0` has no case — but pinned via the
31341 // mixed-case-but-non-null fixture) routes the same way. The
31342 // null-OID arm is the *fourth* arm, structurally the
31343 // lexicographic-content-arm after length and per-byte
31344 // character-class.
31345 let off_by_one_zeros = "0".repeat(41);
31346 let err = is_git_oid(&off_by_one_zeros).unwrap_err();
31347 assert!(
31348 err.contains("abbreviated"),
31349 "off-by-one-length all-zeros surfaces length arm first: {err}",
31350 );
31351 // The all-`f` 40-char value — same boundary class as null-OID
31352 // but at the opposite hex extreme — passes the predicate,
31353 // confirming the null-OID arm doesn't over-fire on lexicographic
31354 // boundaries.
31355 is_git_oid("ffffffffffffffffffffffffffffffffffffffff").unwrap();
31356 }
31357
31358 #[test]
31359 fn git_oid_rejects_empty_defensively() {
31360 // The predicate is called from `crate::dep::DepSource::validate`
31361 // only after the per-axis `FontePinEmpty` arm has fired at
31362 // validate time; re-checking here keeps the predicate usable
31363 // from any future call site without an empty-precondition
31364 // footgun. Same defensive empty-check `is_dns_1123_label`,
31365 // `is_gateway_api_http_path`, `is_wit_world_ref`,
31366 // `is_nats_subject`, `is_wasi_keyvalue_slot`, and
31367 // `is_git_ref_name` carry at their call sites.
31368 let err = is_git_oid("").unwrap_err();
31369 assert!(err.contains("empty"), "got: {err:?}");
31370 }
31371
31372 #[test]
31373 fn git_oid_rejects_each_arm_with_substring_pinned_reason() {
31374 // Substrate-side diagnostic-shape pin: each grammar arm
31375 // surfaces its own distinct reason substring. Pinned here so a
31376 // future reason-wording rephrase that drops any of these
31377 // substrings surfaces at this one place, not piecemeal across
31378 // every per-axis test sweep. Mirrors
31379 // `git_ref_name_rejects_each_arm_with_substring_pinned_reason`,
31380 // `wasi_kv_slot_rejects_each_arm_with_substring_pinned_reason`,
31381 // and `nats_subject_rejects_each_arm_with_substring_pinned_reason`
31382 // on the peer predicates.
31383 for (s, needle) in [
31384 // Abbreviated 7-char prefix — the canonical `git log
31385 // --short` paste-from-release-notes footgun.
31386 ("c0ffee0", "abbreviated"),
31387 // Abbreviated 12-char prefix — `git log --short=12`.
31388 ("c0ffee001234", "abbreviated"),
31389 // Off-by-one above SHA-1 width.
31390 ("0123456789abcdef0123456789abcdef012345670", "abbreviated"),
31391 // Off-by-one below SHA-256 width.
31392 (
31393 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde",
31394 "abbreviated",
31395 ),
31396 // Off-by-one above SHA-256 width.
31397 (
31398 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0",
31399 "abbreviated",
31400 ),
31401 // Uppercase SHA-1 — `git porcelain` lowercases on output.
31402 ("DEADBEEFCAFEBABE0123456789ABCDEF01234567", "uppercase"),
31403 // Mixed-case SHA-1 — same path as pure-uppercase; the first
31404 // uppercase byte fires the arm.
31405 ("deadbeefCAFEbabe0123456789abcdef01234567", "uppercase"),
31406 // Non-hex character at exact SHA-1 length — the cross-axis
31407 // mis-slot footgun (a refname-style char landing in `:rev`).
31408 // `g` is the first non-hex byte; the non-hex arm fires
31409 // ahead of any other rule. The hyphen / colon / slash arms
31410 // are the same path on the same predicate.
31411 ("g123456789abcdef0123456789abcdef01234567", "non-hex"),
31412 ("0123456789abcdef-123456789abcdef01234567", "non-hex"),
31413 ("0123456789abcdef/123456789abcdef01234567", "non-hex"),
31414 ("0123456789abcdef:123456789abcdef01234567", "non-hex"),
31415 // Whitespace inside an otherwise-SHA-shaped value (length
31416 // 41 — fails the length arm first; pinned to ensure the
31417 // diagnostic surfaces *some* parser wording).
31418 ("0123456789abcdef0123456789abcdef01234567 ", "abbreviated"),
31419 ] {
31420 let err = is_git_oid(s)
31421 .err()
31422 .unwrap_or_else(|| panic!("git OID {s:?} must be rejected"));
31423 assert!(
31424 err.contains(needle),
31425 "git OID {s:?} reason must contain {needle:?}; got {err:?}"
31426 );
31427 }
31428 }
31429
31430 #[test]
31431 fn git_oid_rejects_at_canonical_width_boundaries() {
31432 // Boundary pin on the two canonical widths simultaneously: 39
31433 // (below SHA-1), 40 (SHA-1 exactly), 41 (just above), 63 (just
31434 // below SHA-256), 64 (SHA-256 exactly), 65 (just above). Pinned
31435 // so a future relaxation that admits "close enough" widths
31436 // surfaces here. The failing-length fixtures use all-zero hex
31437 // so only the length arm fires (the null-OID sentinel arm is
31438 // structurally downstream of the length arm — a non-canonical
31439 // length fires the abbreviated diagnostic before the null
31440 // diagnostic). The passing-length fixtures use a non-null hex
31441 // value so the null-OID arm doesn't fire (the all-zero
31442 // canonical-width value is the sentinel and is rejected by its
31443 // own arm, pinned in `git_oid_rejects_null_oid_sentinel_*`).
31444 let nonzero_sha1 = "0123456789abcdef0123456789abcdef01234567";
31445 assert_eq!(nonzero_sha1.len(), 40);
31446 let nonzero_sha256 = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
31447 assert_eq!(nonzero_sha256.len(), 64);
31448 for (len, ok) in [
31449 (1usize, false),
31450 (7, false),
31451 (39, false),
31452 (40, true),
31453 (41, false),
31454 (63, false),
31455 (64, true),
31456 (65, false),
31457 (128, false),
31458 ] {
31459 let s = if ok && len == 40 {
31460 nonzero_sha1.to_string()
31461 } else if ok && len == 64 {
31462 nonzero_sha256.to_string()
31463 } else {
31464 "0".repeat(len)
31465 };
31466 let result = is_git_oid(&s);
31467 if ok {
31468 result.unwrap_or_else(|e| panic!("len {len} must pass: {e:?}"));
31469 } else {
31470 let err = result.expect_err(&format!("len {len} must fail"));
31471 assert!(
31472 err.contains("abbreviated") || err.contains(&len.to_string()),
31473 "len {len} reason must name the offending length or surface \
31474 the abbreviation arm, got {err:?}"
31475 );
31476 }
31477 }
31478 }
31479
31480 #[test]
31481 fn git_oid_rejection_is_disjoint_from_ref_name_acceptance() {
31482 // Structural pin: the two predicates partition the `:fonte`
31483 // pin axes — every canonical refname is rejected by
31484 // `is_git_oid`, and every canonical OID is rejected by
31485 // `is_git_ref_name`. The intersection of the two valid sets
31486 // is exactly the empty set. Drift here = a value that passes
31487 // both predicates would land at *both* axes silently, defeating
31488 // the structural "cross-axis mis-slot is a build error"
31489 // contract. Pinned with a representative cross-set so a future
31490 // predicate weakening surfaces here.
31491 let canonical_refnames = [
31492 "v0.1.0",
31493 "main",
31494 "feature/checkout",
31495 "release-1.0",
31496 "user-1/feat-x-v2",
31497 ];
31498 for refname in canonical_refnames {
31499 is_git_ref_name(refname).unwrap_or_else(|e| {
31500 panic!("setup: canonical refname {refname:?} must pass is_git_ref_name: {e:?}")
31501 });
31502 assert!(
31503 is_git_oid(refname).is_err(),
31504 "canonical refname {refname:?} must NOT pass is_git_oid \
31505 (predicate-partition pin)"
31506 );
31507 }
31508 let canonical_oids = [
31509 "0123456789abcdef0123456789abcdef01234567",
31510 "deadbeefcafebabe0123456789abcdef01234567",
31511 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
31512 ];
31513 for oid in canonical_oids {
31514 is_git_oid(oid).unwrap_or_else(|e| {
31515 panic!("setup: canonical OID {oid:?} must pass is_git_oid: {e:?}")
31516 });
31517 assert!(
31518 is_git_ref_name(oid).is_err(),
31519 "canonical OID {oid:?} must NOT pass is_git_ref_name \
31520 (predicate-partition pin)"
31521 );
31522 }
31523 }
31524
31525 // ── is_sandboxed_relative_path — `:behavior :on-*` + `:upgrade-from ─
31526 // ── :state-change :script` value-shape predicate ────────────────────
31527
31528 #[test]
31529 fn sandboxed_relative_path_accepts_canonical_relative_paths() {
31530 // Positive controls: every documented authoring shape across
31531 // the two existing call sites (`:behavior :on-init` / `:on-call`
31532 // / `:on-cast` / `:on-info` / `:on-state-change` / `:on-terminate`
31533 // and `:upgrade-from :state-change :script`) — bare filename,
31534 // standard `lib/` subdirectory, deeply-nested migrations
31535 // subdirectory, sibling-folder-shaped path, and explicit
31536 // current-dir-relative-prefixed path. Pin every leg so a
31537 // future tightening that rejects any of these (e.g. demanding
31538 // a `lib/` prefix specifically, or forbidding the explicit
31539 // `./` segment) surfaces here as a test-failure at the predicate
31540 // boundary, not piecemeal across per-axis call sites.
31541 for relpath in [
31542 "init.lisp",
31543 "lib/init.lisp",
31544 "lib/handlers.lisp",
31545 "lib/migrations/v01-to-v02.lisp",
31546 "callbacks/on_call.lisp",
31547 "./lib/init.lisp",
31548 "a",
31549 ] {
31550 is_sandboxed_relative_path(Path::new(relpath)).unwrap_or_else(|v| {
31551 panic!("canonical relative path {relpath:?} must pass, got {v:?}")
31552 });
31553 }
31554 }
31555
31556 #[test]
31557 fn sandboxed_relative_path_rejects_empty() {
31558 // The fail-before-pass-after pin on the empty arm. Both
31559 // `PathBuf::new()` (no bytes) and `PathBuf::from("")` (empty
31560 // string) hit the `as_os_str().is_empty()` precondition; both
31561 // resolve to `root` under `root.join(p)` and silently point the
31562 // `LisleLoader` at the project directory rather than a file.
31563 assert_eq!(
31564 is_sandboxed_relative_path(Path::new("")),
31565 Err(PathShapeViolation::Empty)
31566 );
31567 let blank = PathBuf::new();
31568 assert_eq!(
31569 is_sandboxed_relative_path(&blank),
31570 Err(PathShapeViolation::Empty)
31571 );
31572 }
31573
31574 #[test]
31575 fn sandboxed_relative_path_rejects_absolute() {
31576 // The fail-before-pass-after pin on the absolute arm. Sweep
31577 // the canonical sandbox-escape paste-from-shell-prompt
31578 // footguns: an `/etc/...` Lunatic-style sandbox bypass, a
31579 // user-home leak that the renderer's `root.join(p)` would
31580 // silently replace, the project-relative-shaped `/lib/...`
31581 // typo where the author meant `lib/...` without a leading
31582 // slash, and the bare root `/`. `Path::join` replaces the
31583 // base with an absolute right-hand side, so every one of
31584 // these resolves verbatim to outside the caixa root regardless
31585 // of where the layout checker rooted itself.
31586 for abs in [
31587 "/etc/passwd",
31588 "/home/user/escape.lisp",
31589 "/lib/init.lisp",
31590 "/",
31591 ] {
31592 assert_eq!(
31593 is_sandboxed_relative_path(Path::new(abs)),
31594 Err(PathShapeViolation::Absolute),
31595 "absolute path {abs:?} must surface as PathShapeViolation::Absolute"
31596 );
31597 }
31598 }
31599
31600 #[test]
31601 fn sandboxed_relative_path_rejects_parent_escape_at_every_position() {
31602 // The fail-before-pass-after pin on the parent-escape arm.
31603 // Position sweep — `..` as a leading component (the canonical
31604 // "I meant the sibling caixa" mis-author), as a mid-path
31605 // component (the canonical "lib/../../escape" path-traversal
31606 // that's structurally identical regardless of how many `..`
31607 // segments stack), as a trailing component (lib/.., resolving
31608 // to the project root via a delayed escape), and the bare `..`
31609 // (project parent directory). Each must surface as
31610 // `PathShapeViolation::ParentEscape` regardless of position —
31611 // pinned per-position so a future relaxation that only
31612 // checks one position surfaces at this one place, not
31613 // piecemeal across per-axis call sites.
31614 for escape in [
31615 "../sibling/init.lisp",
31616 "lib/../../escaped.lisp",
31617 "lib/..",
31618 "..",
31619 "lib/handlers/../../escape.lisp",
31620 ] {
31621 assert_eq!(
31622 is_sandboxed_relative_path(Path::new(escape)),
31623 Err(PathShapeViolation::ParentEscape),
31624 "parent-escape path {escape:?} must surface as \
31625 PathShapeViolation::ParentEscape"
31626 );
31627 }
31628 }
31629
31630 #[test]
31631 fn sandboxed_relative_path_arm_ordering_is_empty_absolute_parent_escape() {
31632 // Order pin: the predicate evaluates Empty → Absolute →
31633 // ParentEscape — the same arm-ordering both inlined call sites
31634 // followed verbatim (b0c8389 `BehaviorSpec::validate`'s
31635 // `validate_callback_path`, 26da2c7
31636 // `UpgradeInstruction::StateChange::validate`). A future
31637 // reordering would silently flip which diagnostic the per-axis
31638 // wrapper surfaces (e.g. an absolute-and-empty hybrid value
31639 // would suddenly raise `Absolute` instead of `Empty`). Pinned
31640 // here so a future reorder surfaces at the predicate boundary.
31641 //
31642 // The empty case can't *also* be absolute (empty paths are
31643 // relative-by-construction) or parent-escaping, so the
31644 // empty-first ordering only matters relative to the OS-string
31645 // emptiness check vs. the absolute-prefix check. Pin the two
31646 // legs that *can* compose: an absolute path with `..` segments
31647 // must raise `Absolute` (not `ParentEscape`); an absolute-but-
31648 // not-parent-escaping path must also raise `Absolute`. The
31649 // arm-ordering pin is structural — every parent-escape case
31650 // tested above is relative, so the ParentEscape arm is reached
31651 // only when both Empty and Absolute arms have been cleared.
31652 assert_eq!(
31653 is_sandboxed_relative_path(Path::new("/etc/../passwd")),
31654 Err(PathShapeViolation::Absolute),
31655 "absolute path with `..` segments must surface as Absolute (not \
31656 ParentEscape) — Empty → Absolute → ParentEscape arm-ordering pin"
31657 );
31658 }
31659
31660 #[test]
31661 fn sandboxed_relative_path_distinguishes_curdir_from_parent_escape() {
31662 // Boundary pin: `Component::CurDir` (`.`) is NOT a sandbox
31663 // escape — `root.join("./lib/x.lisp")` resolves to
31664 // `root/lib/x.lisp`, identical to `root.join("lib/x.lisp")`,
31665 // so `./` segments must pass the predicate. The arm-ordering
31666 // check above pins that `Component::ParentDir` is the only
31667 // escape vector caught here. Pinned separately so a future
31668 // tightening that *does* reject `.` segments (e.g. requiring
31669 // canonical normalized form) lands at this one predicate.
31670 is_sandboxed_relative_path(Path::new("./lib/init.lisp")).unwrap();
31671 is_sandboxed_relative_path(Path::new("lib/./handlers.lisp")).unwrap();
31672 }
31673
31674 #[test]
31675 fn sandboxed_relative_path_violations_are_distinct_variants() {
31676 // Diagnostic-shape pin: the three `PathShapeViolation` variants
31677 // are distinct enum tags so each per-axis caller can match-and-
31678 // wrap into its own typed `*Path` / `*Script` variant without
31679 // a string-parse step (the trap [`is_dns_1123_label`] etc.
31680 // avoid by returning `Result<(), String>` — but the path-shape
31681 // callers were already split three ways across `BehaviorError`
31682 // / `UpgradeError`, so a `String` return would *regress* the
31683 // diagnostic shape rather than preserve it). The PartialEq /
31684 // Copy / Hash derives on `PathShapeViolation` are pinned here
31685 // so a future API rework reads the requirement off this test.
31686 let v1 = PathShapeViolation::Empty;
31687 let v2 = PathShapeViolation::Absolute;
31688 let v3 = PathShapeViolation::ParentEscape;
31689 assert_ne!(v1, v2);
31690 assert_ne!(v2, v3);
31691 assert_ne!(v1, v3);
31692 // Copy + Eq round-trip: predicate consumers like
31693 // `BehaviorSpec::validate` and `UpgradeInstruction::validate`
31694 // pattern-match on the variant without consuming it.
31695 let v_copy = v1;
31696 assert_eq!(v1, v_copy);
31697 }
31698
31699 #[test]
31700 fn sandboxed_relative_path_matches_inlined_call_site_semantics() {
31701 // End-to-end pin: every value the two pre-lift inline gates
31702 // (`BehaviorSpec::validate_callback_path` and
31703 // `UpgradeInstruction::StateChange::validate`'s inline arms)
31704 // accepted-or-rejected must surface from the lifted predicate
31705 // with identically-classified violation tags. Drift here would
31706 // mean a previously-accepted authoring shape would suddenly
31707 // fail (or vice versa) silently across the lift commit. Pinned
31708 // by sweeping the canonical authoring shapes both pre-lift call
31709 // sites' tests cover.
31710 // Pre-lift accepts (must still pass):
31711 for accept in [
31712 "lib/init.lisp",
31713 "lib/handlers.lisp",
31714 "lib/migrations.lisp",
31715 "lib/cleanup.lisp",
31716 "lib/migrations/v01-to-v02.lisp",
31717 "callbacks/handle_call.lisp",
31718 ] {
31719 is_sandboxed_relative_path(Path::new(accept))
31720 .unwrap_or_else(|v| panic!("pre-lift accept {accept:?} regressed, got {v:?}"));
31721 }
31722 // Pre-lift rejects (must still reject, with the same tag):
31723 let cases: &[(&str, PathShapeViolation)] = &[
31724 ("", PathShapeViolation::Empty),
31725 ("/etc/passwd", PathShapeViolation::Absolute),
31726 ("/etc/migrations.lisp", PathShapeViolation::Absolute),
31727 (
31728 "../sibling/migrations.lisp",
31729 PathShapeViolation::ParentEscape,
31730 ),
31731 ("lib/../../escaped.lisp", PathShapeViolation::ParentEscape),
31732 ];
31733 for (reject, expected) in cases {
31734 assert_eq!(
31735 is_sandboxed_relative_path(Path::new(reject)).unwrap_err(),
31736 *expected,
31737 "pre-lift reject {reject:?} must classify as {expected:?}"
31738 );
31739 }
31740 }
31741
31742 #[test]
31743 fn path_shape_violation_all_lists_every_variant_in_declaration_order() {
31744 // Fail-before-pass-after pin on the paired
31745 // [`PathShapeViolation::ALL`] exhaustive-iteration surface.
31746 // Two axes in one assertion, both must hold:
31747 //
31748 // (1) The slice enumerates every arm in the closed
31749 // three-arm discriminator set exactly once, in
31750 // declaration order (`Empty` → `Absolute` →
31751 // `ParentEscape`) — the arm-ordering the
31752 // [`is_sandboxed_relative_path`] gate + every per-axis
31753 // caller in [`crate::manifest::ManifestError`] preserve
31754 // for diagnostic-precedence continuity. A future variant
31755 // addition (a `Symlink` arm the future symlink-escape
31756 // gate would raise, a `TrailingSpace` arm a future
31757 // whitespace-hygiene gate would surface) that lands on
31758 // the enum without extending `ALL` trips this test at
31759 // build time rather than surfacing as a silent
31760 // under-coverage across every downstream sweep.
31761 //
31762 // (2) For every arm in the slice, exactly one of the
31763 // [`gen_platform::IsVariant`]-derive-generated `is_*`
31764 // predicates returns `true` and the other two return
31765 // `false` — the partition property every peer closed-set
31766 // enum's `IsVariant` derive carries
31767 // ([`crate::CaixaKind`] at kind.rs,
31768 // [`crate::supervisor::RestartStrategy`] +
31769 // [`crate::supervisor::RestartPolicy`] at supervisor.rs,
31770 // [`crate::upgrade::UpgradeInstruction`] at upgrade.rs,
31771 // [`crate::aplicacao::PlacementStrategy`] +
31772 // [`crate::aplicacao::RateLimitUnit`] at aplicacao.rs,
31773 // [`crate::dep::DepList`] at dep.rs). A future variant
31774 // addition that lands on the enum without threading a
31775 // new column into the per-arm-partition assertion table
31776 // trips here at build time.
31777 assert_eq!(
31778 PathShapeViolation::ALL,
31779 &[
31780 PathShapeViolation::Empty,
31781 PathShapeViolation::Absolute,
31782 PathShapeViolation::ParentEscape,
31783 ],
31784 "PathShapeViolation::ALL must list every arm in \
31785 declaration order (Empty → Absolute → ParentEscape) — \
31786 the arm-ordering is_sandboxed_relative_path and every \
31787 per-axis ManifestError caller preserve for \
31788 diagnostic-precedence continuity"
31789 );
31790 let rows: [(PathShapeViolation, [bool; 3]); 3] = [
31791 (PathShapeViolation::Empty, [true, false, false]),
31792 (PathShapeViolation::Absolute, [false, true, false]),
31793 (PathShapeViolation::ParentEscape, [false, false, true]),
31794 ];
31795 for (variant, expected) in rows {
31796 let observed = [
31797 variant.is_empty(),
31798 variant.is_absolute(),
31799 variant.is_parent_escape(),
31800 ];
31801 assert_eq!(
31802 observed, expected,
31803 "PathShapeViolation::{variant:?} is_* predicates must \
31804 partition the arm set (empty, absolute, parent_escape); \
31805 got {observed:?}"
31806 );
31807 }
31808 }
31809
31810 #[test]
31811 fn path_shape_violation_predicates_are_byte_equal_to_matches_family() {
31812 // Byte-equal pin on the [`gen_platform::IsVariant`]-derive-
31813 // generated per-arm predicate family. For every arm on the
31814 // closed three-arm [`PathShapeViolation`] discriminator, each
31815 // per-arm `is_*` predicate must agree byte-for-byte with the
31816 // hand-rolled `matches!(_, PathShapeViolation::…)` shape a
31817 // future consumer (a `feira lint --explain-path-shape=<axis>`
31818 // per-arm listing, a future symlink-escape / whitespace-hygiene
31819 // gate that keys off "is this a sandbox-escape arm" boolean, a
31820 // future single-arm `matches!` in a downstream renderer that
31821 // treats `Empty` distinctly from the other two) would
31822 // otherwise open-code at each caller. A future rebrand (a
31823 // `#[is_variant(name = "…")]` attribute drift on the derive,
31824 // an accidental peer predicate that shadows the derive-generated
31825 // one, a hand-rolled `impl PathShapeViolation` block that
31826 // shadows one of the derive-generated methods) trips this test
31827 // the moment the two paths' bytes diverge. Peer of the sibling
31828 // `caixa_kind_is_variant_predicates_partition_the_arm_set`
31829 // (kind.rs) and every peer closed-set-enum byte-equal pin.
31830 for &variant in PathShapeViolation::ALL {
31831 assert_eq!(
31832 variant.is_empty(),
31833 matches!(variant, PathShapeViolation::Empty),
31834 "PathShapeViolation::{variant:?}.is_empty() must agree \
31835 with matches!(_, PathShapeViolation::Empty)"
31836 );
31837 assert_eq!(
31838 variant.is_absolute(),
31839 matches!(variant, PathShapeViolation::Absolute),
31840 "PathShapeViolation::{variant:?}.is_absolute() must agree \
31841 with matches!(_, PathShapeViolation::Absolute)"
31842 );
31843 assert_eq!(
31844 variant.is_parent_escape(),
31845 matches!(variant, PathShapeViolation::ParentEscape),
31846 "PathShapeViolation::{variant:?}.is_parent_escape() must agree \
31847 with matches!(_, PathShapeViolation::ParentEscape)"
31848 );
31849 }
31850 }
31851
31852 // ── is_lisp_extension — `:behavior :on-*` + `:upgrade-from ───────────
31853 // ── :state-change :script` file-type predicate ───────────────────────
31854
31855 #[test]
31856 fn lisp_extension_accepts_canonical_shapes() {
31857 // Positive controls: every documented authoring shape across
31858 // both existing call sites — bare filename, standard `lib/`
31859 // subdirectory, deeply-nested migrations subdirectory,
31860 // explicit current-dir-relative prefix, mid-path `./`
31861 // segment, single-letter stem, and the multi-dot stem
31862 // (`lib/migrations/v.0.1.lisp`) an author might use to
31863 // encode the migration's `:from` version into the filename.
31864 // The predicate only inspects the terminating extension —
31865 // `Path::extension()` returns the substring after the final
31866 // `.` — so the multi-dot stem is structurally accepted
31867 // because the final extension is still `lisp`. Drift here =
31868 // a future tightening that rejects any of these surfaces as
31869 // a test-failure at the predicate boundary, not piecemeal
31870 // across per-axis call sites (`BehaviorSpec::validate`,
31871 // `UpgradeInstruction::StateChange::validate`).
31872 for relpath in [
31873 "init.lisp",
31874 "lib/init.lisp",
31875 "lib/handlers.lisp",
31876 "lib/migrations.lisp",
31877 "lib/migrations/v01-to-v02.lisp",
31878 "./lib/init.lisp",
31879 "lib/./handlers.lisp",
31880 "lib/migrations/v.0.1.lisp",
31881 "a.lisp",
31882 ] {
31883 assert!(
31884 is_lisp_extension(Path::new(relpath)),
31885 "canonical `.lisp` shape {relpath:?} must pass is_lisp_extension"
31886 );
31887 }
31888 }
31889
31890 #[test]
31891 fn lisp_extension_rejects_no_extension() {
31892 // The fail-before-pass-after pin on the no-extension shape.
31893 // A path with no `.` component (`Path::extension()` returns
31894 // `None`) is the canonical "I declared the slot but forgot
31895 // the `.lisp` extension" authoring footgun. The wasm-engine's
31896 // `tatara_lisp::read` consumer can't infer the file type from
31897 // the path alone, so the gate refuses the value at validate
31898 // time.
31899 for relpath in [
31900 "lib/init",
31901 "init",
31902 "lib/handlers",
31903 "lib/migrations/v01-to-v02",
31904 "a",
31905 ] {
31906 assert!(
31907 !is_lisp_extension(Path::new(relpath)),
31908 "no-extension shape {relpath:?} must fail is_lisp_extension"
31909 );
31910 }
31911 }
31912
31913 #[test]
31914 fn lisp_extension_rejects_wrong_extension() {
31915 // Wrong-extension sweep: the canonical authoring footguns
31916 // an author might drag in from the workspace tree (`.txt`,
31917 // `.md`, `.json`, `.yaml`, `.toml`), the `.rs` shape that
31918 // an IDE auto-complete might propose, the `.lisp.bak` shape
31919 // an editor might leave behind (the predicate only inspects
31920 // the *terminating* extension — `Path::extension()` returns
31921 // `bak` here, not `lisp.bak` — so the gate refuses it as a
31922 // no-`.lisp` final extension), and the `.lispx` / `.lis`
31923 // near-miss shapes that a typo would produce. Each must
31924 // fail the predicate — the wasm-engine's `tatara_lisp::read`
31925 // consumer rejects all of these at hot-upgrade migration /
31926 // instance-start time.
31927 for relpath in [
31928 "lib/init.rs",
31929 "lib/init.txt",
31930 "lib/init.md",
31931 "lib/init.json",
31932 "lib/init.yaml",
31933 "lib/init.toml",
31934 "lib/init.lisp.bak",
31935 "lib/init.lispx",
31936 "lib/init.lis",
31937 ] {
31938 assert!(
31939 !is_lisp_extension(Path::new(relpath)),
31940 "wrong-extension shape {relpath:?} must fail is_lisp_extension"
31941 );
31942 }
31943 }
31944
31945 #[test]
31946 fn lisp_extension_is_case_sensitive() {
31947 // Strict lowercase pin: every case-folded shape a
31948 // case-insensitive volume's existence check would match the
31949 // on-disk file must still fail the predicate — the
31950 // canonical-form codec emits lowercase `.lisp` verbatim, so
31951 // a case-folded shape mismatches the round-trip-stable
31952 // canonical form (THEORY.md §V.2.7 render-determinism).
31953 // Same case-sensitive discipline the byte-size / duration
31954 // codecs and every other shape-gate predicate in `render.rs`
31955 // (label / scheme / unit boundaries) carry. Pinned at the
31956 // predicate boundary so any future case-folding regression
31957 // surfaces here rather than piecemeal across per-axis call
31958 // sites.
31959 for relpath in [
31960 "lib/init.LISP",
31961 "lib/init.Lisp",
31962 "lib/init.LiSp",
31963 "lib/init.lISP",
31964 "lib/init.LISp",
31965 ] {
31966 assert!(
31967 !is_lisp_extension(Path::new(relpath)),
31968 "case-folded `.lisp` shape {relpath:?} must fail is_lisp_extension \
31969 (strict lowercase, render-determinism pin)"
31970 );
31971 }
31972 }
31973
31974 #[test]
31975 fn lisp_extension_constant_matches_predicate() {
31976 // Cross-pin: the [`LISP_SOURCE_EXTENSION`] const and the
31977 // predicate's accepted set are the same single source of
31978 // truth. Drift would let a future renderer / per-axis
31979 // wrapper emit `.<const>` while the predicate accepts only
31980 // `.lisp` (or vice versa), silently breaking the
31981 // round-trip-stable canonical form. Pinned by constructing
31982 // a path from the const and round-tripping through the
31983 // predicate.
31984 assert_eq!(LISP_SOURCE_EXTENSION, "lisp");
31985 let p = PathBuf::from(format!("lib/init.{LISP_SOURCE_EXTENSION}"));
31986 assert!(
31987 is_lisp_extension(&p),
31988 "path constructed from LISP_SOURCE_EXTENSION must pass is_lisp_extension"
31989 );
31990 }
31991
31992 #[test]
31993 fn lisp_extension_matches_inlined_call_site_semantics() {
31994 // End-to-end pin: every value the pre-lift inline gate
31995 // (`BehaviorSpec::validate_callback_path`, c97815a) accepted-
31996 // or-rejected must surface from the lifted predicate
31997 // identically. Drift here would mean a previously-accepted
31998 // authoring shape would suddenly fail (or vice versa)
31999 // silently across the lift commit. Sweeps the canonical
32000 // authoring shapes the pre-lift call site's tests covered
32001 // verbatim.
32002 // Pre-lift accepts (must still pass):
32003 for accept in [
32004 "lib/init.lisp",
32005 "lib/handlers.lisp",
32006 "lib/migrations/v01-to-v02.lisp",
32007 "init.lisp",
32008 "a.lisp",
32009 "./lib/init.lisp",
32010 "lib/./handlers.lisp",
32011 "lib/migrations/v.0.1.lisp",
32012 ] {
32013 assert!(
32014 is_lisp_extension(Path::new(accept)),
32015 "pre-lift accept {accept:?} regressed"
32016 );
32017 }
32018 // Pre-lift rejects (must still reject):
32019 for reject in [
32020 "lib/init",
32021 "init",
32022 "lib/init.rs",
32023 "lib/init.txt",
32024 "lib/init.lisp.bak",
32025 "lib/init.lispx",
32026 "lib/init.LISP",
32027 "lib/init.Lisp",
32028 ] {
32029 assert!(
32030 !is_lisp_extension(Path::new(reject)),
32031 "pre-lift reject {reject:?} regressed"
32032 );
32033 }
32034 }
32035
32036 // ── is_computeunit_yaml_extension — `:servicos` compound-suffix predicate ───
32037
32038 #[test]
32039 fn computeunit_yaml_extension_accepts_canonical_shapes() {
32040 // Positive controls: every canonical authoring shape every
32041 // in-tree fixture and the `Caixa::template` scaffold use. The
32042 // predicate inspects the final file-name component and checks
32043 // for the compound `.computeunit.yaml` suffix with at least
32044 // one byte of stem preceding it.
32045 for relpath in [
32046 "servicos/demo.computeunit.yaml",
32047 "servicos/hello-rio.computeunit.yaml",
32048 "servicos/my-service.computeunit.yaml",
32049 "servicos/a.computeunit.yaml",
32050 "./servicos/demo.computeunit.yaml",
32051 "servicos/./demo.computeunit.yaml",
32052 "servicos/sub/nested.computeunit.yaml",
32053 "servicos/v0.1.computeunit.yaml",
32054 ] {
32055 assert!(
32056 is_computeunit_yaml_extension(Path::new(relpath)),
32057 "canonical `.computeunit.yaml` shape {relpath:?} must pass \
32058 is_computeunit_yaml_extension"
32059 );
32060 }
32061 }
32062
32063 #[test]
32064 fn computeunit_yaml_extension_rejects_no_extension() {
32065 // No-extension shape — the canonical "I declared the slot
32066 // but forgot the `.computeunit.yaml` suffix" footgun. The
32067 // peer caixa-helm / caixa-flux `serde_yaml::from_str`
32068 // consumer can't infer the file type from the path alone, so
32069 // the gate refuses the value at validate time.
32070 for relpath in ["servicos/demo", "demo", "servicos/sub/nested"] {
32071 assert!(
32072 !is_computeunit_yaml_extension(Path::new(relpath)),
32073 "no-extension shape {relpath:?} must fail \
32074 is_computeunit_yaml_extension"
32075 );
32076 }
32077 }
32078
32079 #[test]
32080 fn computeunit_yaml_extension_rejects_wrong_extension() {
32081 // Wrong-extension sweep across the canonical authoring footguns
32082 // an author might drag in from the workspace tree — bare
32083 // `.yaml` (the canonical "I forgot the `.computeunit` segment"
32084 // typo), `.yml` (Helm-shorthand leak), `.json` (FluxCD
32085 // bundle leak), `.toml` (Cargo workspace leak), `.txt`
32086 // / `.md` (paste-from-doc footguns), `.yaml.bak` (editor
32087 // backup), the near-miss `.computeunit.yam` / `.computeunit.yamls`
32088 // typo, and the off-by-one-segment `computeunit-yaml`
32089 // / `computeunit_yaml` shapes. Each must fail the predicate.
32090 for relpath in [
32091 "servicos/demo.yaml",
32092 "servicos/demo.yml",
32093 "servicos/demo.json",
32094 "servicos/demo.toml",
32095 "servicos/demo.txt",
32096 "servicos/demo.md",
32097 "servicos/demo.computeunit.yaml.bak",
32098 "servicos/demo.computeunit.yam",
32099 "servicos/demo.computeunit.yamls",
32100 "servicos/demo.computeunit",
32101 "servicos/demo-computeunit.yaml",
32102 "servicos/demo_computeunit.yaml",
32103 ] {
32104 assert!(
32105 !is_computeunit_yaml_extension(Path::new(relpath)),
32106 "wrong-extension shape {relpath:?} must fail \
32107 is_computeunit_yaml_extension"
32108 );
32109 }
32110 }
32111
32112 #[test]
32113 fn computeunit_yaml_extension_is_case_sensitive() {
32114 // Strict lowercase pin: every case-folded shape a
32115 // case-insensitive volume's existence check would match the
32116 // on-disk file must still fail the predicate — the canonical-
32117 // form codec emits lowercase `.computeunit.yaml` verbatim, so
32118 // a case-folded shape mismatches the round-trip-stable
32119 // canonical form (THEORY.md §V.2.7 render-determinism). Same
32120 // case-sensitive discipline the byte-size / duration codecs
32121 // and the peer `is_lisp_extension` predicate carry.
32122 for relpath in [
32123 "servicos/demo.ComputeUnit.yaml",
32124 "servicos/demo.COMPUTEUNIT.yaml",
32125 "servicos/demo.computeunit.YAML",
32126 "servicos/demo.computeunit.Yaml",
32127 "servicos/demo.COMPUTEUNIT.YAML",
32128 ] {
32129 assert!(
32130 !is_computeunit_yaml_extension(Path::new(relpath)),
32131 "case-folded `.computeunit.yaml` shape {relpath:?} must fail \
32132 is_computeunit_yaml_extension (strict lowercase, \
32133 render-determinism pin)"
32134 );
32135 }
32136 }
32137
32138 #[test]
32139 fn computeunit_yaml_extension_rejects_empty_stem() {
32140 // Degenerate hidden-file shape: a file name exactly equal to
32141 // the suffix (`.computeunit.yaml` — no stem preceding the
32142 // suffix) is the structural "Servico declared with no
32143 // identity" footgun. The substrate identifies each ComputeUnit
32144 // by the file-stem segment that precedes `.computeunit.yaml`
32145 // (the rendered `lareira-<stem>` Helm chart, the per-Servico
32146 // `metadata.name`, the M3 `:contratos` membership lookup), so
32147 // an empty stem leaves the Servico unidentifiable. Predicate
32148 // pin: the `name.len() > SUFFIX.len()` bound rejects the
32149 // hidden-file shape at the predicate boundary.
32150 for relpath in [".computeunit.yaml", "servicos/.computeunit.yaml"] {
32151 assert!(
32152 !is_computeunit_yaml_extension(Path::new(relpath)),
32153 "empty-stem shape {relpath:?} must fail \
32154 is_computeunit_yaml_extension"
32155 );
32156 }
32157 }
32158
32159 #[test]
32160 fn computeunit_yaml_extension_constant_matches_predicate() {
32161 // Cross-pin: the [`COMPUTEUNIT_YAML_SUFFIX`] const and the
32162 // predicate's accepted set are the same single source of
32163 // truth. Drift would let a future renderer / per-axis wrapper
32164 // emit `<stem><const>` while the predicate accepts only
32165 // `.computeunit.yaml` (or vice versa), silently breaking the
32166 // round-trip-stable canonical form. Pinned by constructing a
32167 // path from the const and round-tripping through the
32168 // predicate. Mirrors the peer
32169 // `lisp_extension_constant_matches_predicate` pin.
32170 assert_eq!(COMPUTEUNIT_YAML_SUFFIX, ".computeunit.yaml");
32171 let p = PathBuf::from(format!("servicos/demo{COMPUTEUNIT_YAML_SUFFIX}"));
32172 assert!(
32173 is_computeunit_yaml_extension(&p),
32174 "path constructed from COMPUTEUNIT_YAML_SUFFIX must pass \
32175 is_computeunit_yaml_extension"
32176 );
32177 }
32178
32179 // ── is_cargo_feature_name — shared `:caracteristicas` feature-name predicate ──
32180
32181 #[test]
32182 fn cargo_feature_name_accepts_canonical_forms() {
32183 // Substrate-side pin: the predicate accepts every canonical Cargo
32184 // feature name shape `:caracteristicas` entries carry. Drift between
32185 // this list and the per-axis `dep::tests::validate_accepts_canonical_caracteristicas`
32186 // positive-set sweep surfaces here — one source of truth for the
32187 // rule. Includes single-token (`http`), kebab-case (`runtime-tokio`),
32188 // snake-case (`derive_macros`), namespaced-dot (`tokio.full`),
32189 // version-suffix (`v0.1`), `+`-separated (`http+json`), leading
32190 // underscore (`_internal`), doubled-underscore (`__private`),
32191 // and digit-starting (`v0_1`) — the canonical authoring shapes
32192 // every realistic Cargo feature in the pleme-io ecosystem uses.
32193 for s in [
32194 "http",
32195 "json",
32196 "derive",
32197 "serde",
32198 "serde_json",
32199 "runtime-tokio",
32200 "tokio.full",
32201 "v0.1",
32202 "v1",
32203 "http+json",
32204 "_internal",
32205 "__private",
32206 "default",
32207 "rt-multi-thread",
32208 "12factor",
32209 "feat.v2",
32210 "client+server",
32211 ] {
32212 is_cargo_feature_name(s)
32213 .unwrap_or_else(|e| panic!("canonical Cargo feature name {s:?} must pass: {e:?}"));
32214 }
32215 }
32216
32217 #[test]
32218 fn cargo_feature_name_rejects_each_arm_with_substring_pinned_reason() {
32219 // Substrate-side diagnostic-shape pin: each grammar arm
32220 // surfaces its own distinct reason substring. Pinned here so a
32221 // future reason-wording rephrase that drops any of these
32222 // substrings surfaces at this one place, not piecemeal across
32223 // every per-axis test sweep. Mirrors
32224 // `git_repo_url`'s and `git_ref_name`'s arm-substring sweeps
32225 // on the peer predicates.
32226 for (s, needle) in [
32227 // Leading `+` — the canonical paste-from-`+optional-feature`
32228 // activation-form-in-feature-name-slot footgun.
32229 ("+http", "`+`"),
32230 // Leading `-` — kebab-leak / CLI-arg-injection adjacent.
32231 ("-json", "`-`"),
32232 // Leading `.` — dotted-version-suffix-as-feature-name typo.
32233 (".feat", "`.`"),
32234 // Whitespace inside — multi-token blob.
32235 ("http feature", "whitespace"),
32236 // Tab inside.
32237 ("http\tjson", "whitespace"),
32238 // Leading whitespace — paste-from-aligned-doc.
32239 (" http", "whitespace"),
32240 // Comma — list-separator-belongs-to-list-grammar.
32241 ("http,json", "`,`"),
32242 // Forward slash — Cargo's `dep/feat` namespaced-dep syntax.
32243 ("http/json", "`/`"),
32244 // Question mark — URL-reserved.
32245 ("http?", "`?`"),
32246 // Hash — URL-reserved.
32247 ("http#frag", "`#`"),
32248 // Embedded control character.
32249 ("http\x01json", "control character"),
32250 // Newline — paste-from-multiline-doc.
32251 ("http\njson", "control character"),
32252 // DEL byte (0x7F).
32253 ("http\x7fjson", "control character"),
32254 // Non-ASCII byte — un-percent-encoded character.
32255 ("caf\u{e9}", "non-ASCII"),
32256 // Non-ASCII at first byte.
32257 ("\u{e9}feat", "non-ASCII"),
32258 // Forbidden punctuation in the continuation set.
32259 ("http@1", "invalid character"),
32260 ("http&json", "invalid character"),
32261 ("http=v1", "invalid character"),
32262 ] {
32263 let err = is_cargo_feature_name(s)
32264 .err()
32265 .unwrap_or_else(|| panic!("Cargo feature name {s:?} must be rejected"));
32266 assert!(
32267 err.contains(needle),
32268 "Cargo feature name {s:?} reason must contain {needle:?}; got {err:?}"
32269 );
32270 }
32271 }
32272
32273 #[test]
32274 fn cargo_feature_name_rejects_empty_defensively() {
32275 // The predicate is called from `crate::dep::Dep::validate_caracteristicas`
32276 // only after the per-axis `CaracteristicaEmpty` arm has fired
32277 // at validate time; re-checking here keeps the predicate usable
32278 // from any future call site without an empty-precondition
32279 // footgun. Same defensive empty-check `is_dns_1123_label`,
32280 // `is_gateway_api_http_path`, `is_wit_world_ref`,
32281 // `is_nats_subject`, `is_wasi_keyvalue_slot`, `is_git_ref_name`,
32282 // `is_git_oid`, and `is_git_repo_url` carry at their call sites.
32283 let err = is_cargo_feature_name("").unwrap_err();
32284 assert!(err.contains("empty"), "got: {err:?}");
32285 }
32286
32287 #[test]
32288 fn cargo_feature_name_rejects_at_65_byte_boundary() {
32289 // The 64-byte cap pin — both the boundary-exceeding case and
32290 // the boundary-accepting case in one place, so a future cap
32291 // shift surfaces both arms simultaneously, mirroring
32292 // `dns_1123_label_rejects_at_64_byte_boundary`,
32293 // `gateway_api_http_path_rejects_at_1025_byte_boundary`,
32294 // `wit_world_ref_rejects_at_129_byte_boundary`,
32295 // `nats_subject_rejects_at_257_byte_boundary`,
32296 // `wasi_kv_slot_rejects_at_513_byte_boundary`, and
32297 // `git_ref_name_rejects_at_256_byte_boundary` on the peer
32298 // predicates. Constructed as a single all-`a` token so only
32299 // the cap arm fires.
32300 let max_ok = "a".repeat(CARGO_FEATURE_NAME_MAX_LEN);
32301 assert_eq!(max_ok.len(), 64);
32302 is_cargo_feature_name(&max_ok).unwrap();
32303 let too_long = "a".repeat(CARGO_FEATURE_NAME_MAX_LEN + 1);
32304 assert_eq!(too_long.len(), 65);
32305 let err = is_cargo_feature_name(&too_long).unwrap_err();
32306 assert!(err.contains("64"), "got: {err:?}");
32307 assert!(err.contains("65"), "got: {err:?}");
32308 }
32309
32310 #[test]
32311 fn cargo_feature_name_first_byte_diagnostics_name_the_leading_char() {
32312 // Diagnostic-shape pin: the leading-character rejection arms
32313 // name the specific punctuation (`+`, `-`, `.`) verbatim so the
32314 // author's grep target is unambiguous. Pinned across the three
32315 // canonical leading-char footguns so a future relaxation that
32316 // drops any of the three surfaces here. The `+`-arm's wording
32317 // additionally points the author at the canonical Cargo
32318 // `+<feature>` activation-form-vs-feature-name discipline so
32319 // the paste-from-doc footgun lands its remediation in the
32320 // diagnostic itself.
32321 let err_plus = is_cargo_feature_name("+http").unwrap_err();
32322 assert!(err_plus.contains("`+`"), "got: {err_plus:?}");
32323 assert!(
32324 err_plus.contains("activation"),
32325 "got: {err_plus:?} (must name the Cargo +<feature> activation-form)"
32326 );
32327 let err_hyphen = is_cargo_feature_name("-json").unwrap_err();
32328 assert!(err_hyphen.contains("`-`"), "got: {err_hyphen:?}");
32329 let err_dot = is_cargo_feature_name(".feat").unwrap_err();
32330 assert!(err_dot.contains("`.`"), "got: {err_dot:?}");
32331 }
32332
32333 // ── is_spdx_expression_shape — shared `:licenca` SPDX-expression predicate ──
32334
32335 #[test]
32336 fn spdx_expression_shape_accepts_canonical_forms() {
32337 // Substrate-side pin: the predicate accepts every canonical
32338 // SPDX expression shape the `:licenca` axis carries. Drift
32339 // between this list and the per-axis
32340 // `manifest::tests::validate_licenca_accepts_canonical_expressions`
32341 // positive-set sweep surfaces here — one source of truth for
32342 // the rule. Covers single-license, `OR`/`AND`-compound,
32343 // `WITH`-exception, parenthesis-grouped, `+`-suffix, and
32344 // `LicenseRef-` / `DocumentRef-:LicenseRef-` shapes.
32345 for s in [
32346 "MIT",
32347 "Apache-2.0",
32348 "BSD-3-Clause",
32349 "MPL-2.0",
32350 "GPL-3.0-or-later",
32351 "GPL-2.0+",
32352 "Apache-2.0 OR MIT",
32353 "Apache-2.0 AND MIT",
32354 "Apache-2.0 WITH LLVM-exception",
32355 "(MIT OR Apache-2.0) AND BSD-3-Clause",
32356 "(MIT OR Apache-2.0) AND BSD-3-Clause AND ISC",
32357 "LicenseRef-MyLicense",
32358 "DocumentRef-spdx-tool:LicenseRef-MIT-Style",
32359 "x",
32360 ] {
32361 is_spdx_expression_shape(s)
32362 .unwrap_or_else(|e| panic!("canonical SPDX expression {s:?} must pass: {e:?}"));
32363 }
32364 }
32365
32366 #[test]
32367 fn spdx_expression_shape_rejects_each_arm_with_substring_pinned_reason() {
32368 // Substrate-side diagnostic-shape pin: each alphabet arm
32369 // surfaces its own distinct reason substring. Pinned here so a
32370 // future reason-wording rephrase that drops any of these
32371 // substrings surfaces at this one place, not piecemeal across
32372 // every per-axis test sweep. Mirrors
32373 // `cargo_feature_name_rejects_each_arm_with_substring_pinned_reason`
32374 // on the peer predicate.
32375 for (s, needle) in [
32376 // Leading whitespace — paste-from-aligned-doc.
32377 (" MIT", "whitespace"),
32378 // Trailing whitespace — paste-from-doc.
32379 ("MIT ", "whitespace"),
32380 // Tab inside — tab-from-aligned-doc.
32381 ("MIT\tOR Apache-2.0", "tab"),
32382 // Embedded control character.
32383 ("MIT\x01OR Apache-2.0", "control character"),
32384 // Newline — paste-from-multiline-doc.
32385 ("MIT\nOR Apache-2.0", "control character"),
32386 // CRLF — paste-from-multiline-doc.
32387 ("MIT\rApache-2.0", "control character"),
32388 // DEL byte (0x7F).
32389 ("MIT\x7fApache-2.0", "control character"),
32390 // Non-ASCII byte — smart-quote paste.
32391 ("MIT\u{a0}OR Apache-2.0", "non-ASCII"),
32392 // Non-ASCII at first byte — fullwidth letter.
32393 ("\u{ff2d}IT", "non-ASCII"),
32394 // Underscore — snake-case-instead-of-kebab-case typo.
32395 ("Apache_2.0", "`_`"),
32396 // Comma — list-separator-belongs-to-list-grammar.
32397 ("MIT, Apache-2.0", "`,`"),
32398 // Forward slash — colloquial dual-license idiom.
32399 ("MIT/Apache-2.0", "`/`"),
32400 // Semicolon — list-separator confusion.
32401 ("MIT; Apache-2.0", "`;`"),
32402 // Forbidden punctuation in the alphabet.
32403 ("MIT@1.0", "invalid character"),
32404 ("MIT&Apache-2.0", "invalid character"),
32405 ("MIT=Apache-2.0", "invalid character"),
32406 ("MIT*1.0", "invalid character"),
32407 ] {
32408 let err = is_spdx_expression_shape(s)
32409 .err()
32410 .unwrap_or_else(|| panic!("SPDX expression {s:?} must be rejected"));
32411 assert!(
32412 err.contains(needle),
32413 "SPDX expression {s:?} reason must contain {needle:?}; got {err:?}"
32414 );
32415 }
32416 }
32417
32418 #[test]
32419 fn spdx_expression_shape_rejects_empty_defensively() {
32420 // The predicate is called from `crate::Caixa::validate_licenca`
32421 // only after the per-axis `LicencaEmpty` arm has fired at
32422 // validate time; re-checking here keeps the predicate usable
32423 // from any future call site without an empty-precondition
32424 // footgun. Same defensive empty-check `is_dns_1123_label`,
32425 // `is_gateway_api_http_path`, `is_wit_world_ref`,
32426 // `is_nats_subject`, `is_wasi_keyvalue_slot`,
32427 // `is_git_ref_name`, `is_git_oid`, `is_git_repo_url`, and
32428 // `is_cargo_feature_name` carry at their call sites.
32429 let err = is_spdx_expression_shape("").unwrap_err();
32430 assert!(err.contains("empty"), "got: {err:?}");
32431 }
32432
32433 #[test]
32434 fn spdx_expression_shape_rejects_at_257_byte_boundary() {
32435 // The 256-byte cap pin — both the boundary-exceeding case and
32436 // the boundary-accepting case in one place, so a future cap
32437 // shift surfaces both arms simultaneously, mirroring the peer
32438 // cap-boundary pins. Constructed as a single all-`a` token so
32439 // only the cap arm fires (256 `a` bytes is alphabet-valid).
32440 let max_ok = "a".repeat(SPDX_EXPRESSION_MAX_LEN);
32441 assert_eq!(max_ok.len(), 256);
32442 is_spdx_expression_shape(&max_ok).unwrap();
32443 let too_long = "a".repeat(SPDX_EXPRESSION_MAX_LEN + 1);
32444 assert_eq!(too_long.len(), 257);
32445 let err = is_spdx_expression_shape(&too_long).unwrap_err();
32446 assert!(err.contains("256"), "got: {err:?}");
32447 assert!(err.contains("257"), "got: {err:?}");
32448 }
32449
32450 // ── is_chart_description_shape — shared `:descricao` chart-description predicate ──
32451
32452 #[test]
32453 fn chart_description_shape_accepts_canonical_forms() {
32454 // Substrate-side pin: the predicate accepts every canonical
32455 // chart-description shape the `:descricao` axis carries.
32456 // Drift between this list and the per-axis
32457 // `manifest::tests::validate_descricao_accepts_canonical_summary`
32458 // positive-set sweep surfaces here — one source of truth for
32459 // the rule. Covers ASCII summaries, the Unicode `→` from the
32460 // canonical Rust→wasm fixture, and the Unicode `—` em-dash
32461 // from the `Caixa::template` scaffold every `feira init`
32462 // emits.
32463 for s in [
32464 "Canonical Rust→wasm32-wasip2 caixa Servico.",
32465 "Checkout flow.",
32466 "AWS provider caixa for tatara-lisp",
32467 "FIXME — describe this caixa",
32468 "x",
32469 ] {
32470 is_chart_description_shape(s)
32471 .unwrap_or_else(|e| panic!("canonical chart description {s:?} must pass: {e:?}"));
32472 }
32473 }
32474
32475 #[test]
32476 fn chart_description_shape_rejects_each_arm_with_substring_pinned_reason() {
32477 // Substrate-side diagnostic-shape pin: each arm surfaces its
32478 // own distinct reason substring. Pinned here so a future
32479 // reason-wording rephrase that drops any of these substrings
32480 // surfaces at this one place, not piecemeal across every
32481 // per-axis test sweep. Mirrors
32482 // `spdx_expression_shape_rejects_each_arm_with_substring_pinned_reason`
32483 // on the peer predicate.
32484 for (s, needle) in [
32485 // Leading whitespace — paste-from-aligned-doc.
32486 (" Checkout flow.", "whitespace"),
32487 // Trailing whitespace — paste-from-doc.
32488 ("Checkout flow. ", "whitespace"),
32489 // Tab inside — tab-from-aligned-doc.
32490 ("Checkout\tflow.", "tab"),
32491 // Newline — paste-from-multiline-doc.
32492 ("Checkout\nflow.", "newline"),
32493 // Carriage return — paste-from-Windows-CRLF-doc.
32494 ("Checkout\rflow.", "carriage return"),
32495 // NUL byte — paste-from-binary-blob.
32496 ("Checkout\x00flow.", "control character"),
32497 // BEL byte — paste-from-binary-blob.
32498 ("Checkout\x07flow.", "control character"),
32499 // ESC byte — paste-from-binary-blob.
32500 ("Checkout\x1bflow.", "control character"),
32501 // DEL byte (0x7F).
32502 ("Checkout\x7fflow.", "control character"),
32503 ] {
32504 let err = is_chart_description_shape(s)
32505 .err()
32506 .unwrap_or_else(|| panic!("chart description {s:?} must be rejected"));
32507 assert!(
32508 err.contains(needle),
32509 "chart description {s:?} reason must contain {needle:?}; got {err:?}"
32510 );
32511 }
32512 }
32513
32514 #[test]
32515 fn chart_description_shape_accepts_unicode() {
32516 // Positive control on the non-ASCII arm: the predicate must
32517 // accept Unicode beyond the ASCII alphabet — the canonical
32518 // pleme-io descricao fixtures carry `→` (U+2192) and `—`
32519 // (U+2014), and every downstream consumer (YAML 1.2, Helm v3,
32520 // every chart-aware UI) round-trips Unicode losslessly.
32521 // Mirrors the spdx-rejects-non-ASCII arm by inverting it — a
32522 // future tightening that bans non-ASCII bytes would regress
32523 // every canonical fixture and surface here as a regression.
32524 for s in [
32525 "Canonical Rust→wasm32-wasip2",
32526 "FIXME — describe this caixa",
32527 "Caixa pour le projet tâche",
32528 "日本語の説明",
32529 "naïve",
32530 ] {
32531 is_chart_description_shape(s)
32532 .unwrap_or_else(|e| panic!("Unicode chart description {s:?} must pass: {e:?}"));
32533 }
32534 }
32535
32536 #[test]
32537 fn chart_description_shape_rejects_empty_defensively() {
32538 // The predicate is called from `crate::Caixa::validate_descricao`
32539 // only after the per-axis `DescricaoEmpty` arm has fired at
32540 // validate time; re-checking here keeps the predicate usable
32541 // from any future call site without an empty-precondition
32542 // footgun. Same defensive empty-check `is_dns_1123_label`,
32543 // `is_gateway_api_http_path`, `is_wit_world_ref`,
32544 // `is_nats_subject`, `is_wasi_keyvalue_slot`,
32545 // `is_git_ref_name`, `is_git_oid`, `is_git_repo_url`,
32546 // `is_cargo_feature_name`, and `is_spdx_expression_shape`
32547 // carry at their call sites.
32548 let err = is_chart_description_shape("").unwrap_err();
32549 assert!(err.contains("empty"), "got: {err:?}");
32550 }
32551
32552 #[test]
32553 fn chart_description_shape_rejects_at_513_byte_boundary() {
32554 // The 512-byte cap pin — both the boundary-exceeding case and
32555 // the boundary-accepting case in one place, so a future cap
32556 // shift surfaces both arms simultaneously, mirroring the peer
32557 // cap-boundary pins. Constructed as a single all-`a` token so
32558 // only the cap arm fires (512 `a` bytes is alphabet-valid).
32559 let max_ok = "a".repeat(CHART_DESCRIPTION_MAX_LEN);
32560 assert_eq!(max_ok.len(), 512);
32561 is_chart_description_shape(&max_ok).unwrap();
32562 let too_long = "a".repeat(CHART_DESCRIPTION_MAX_LEN + 1);
32563 assert_eq!(too_long.len(), 513);
32564 let err = is_chart_description_shape(&too_long).unwrap_err();
32565 assert!(err.contains("512"), "got: {err:?}");
32566 assert!(err.contains("513"), "got: {err:?}");
32567 }
32568
32569 #[test]
32570 fn chart_description_shape_rejects_each_unicode_bidi_override_codepoint() {
32571 // The Trojan Source (CVE-2021-42574) arm — pins every UAX #9
32572 // bidirectional-override / isolate format codepoint as a
32573 // structural rejection on the typed `:descricao` axis. The
32574 // per-byte non-ASCII pass deliberately admits Unicode letters
32575 // / em-dash / arrows because the canonical fixtures carry them
32576 // (`Canonical Rust→wasm32-wasip2`, `FIXME — describe this
32577 // caixa`); only the typed codepoint scan catches the nine
32578 // bidi-override codepoints that flip the rendered visual order
32579 // of every following character, so a future drop of any one
32580 // arm here surfaces as a `must be rejected` panic at this one
32581 // place rather than as a silent regression downstream. Each
32582 // case carries an alphabet-valid prefix + suffix so only the
32583 // bidi-override arm fires.
32584 for (cp, name) in [
32585 ('\u{202A}', "U+202A"),
32586 ('\u{202B}', "U+202B"),
32587 ('\u{202C}', "U+202C"),
32588 ('\u{202D}', "U+202D"),
32589 ('\u{202E}', "U+202E"),
32590 ('\u{2066}', "U+2066"),
32591 ('\u{2067}', "U+2067"),
32592 ('\u{2068}', "U+2068"),
32593 ('\u{2069}', "U+2069"),
32594 ] {
32595 let s = format!("alice{cp}bob");
32596 let err = is_chart_description_shape(&s)
32597 .err()
32598 .unwrap_or_else(|| panic!("chart description with {name} must be rejected"));
32599 assert!(
32600 err.contains(name),
32601 "chart description reason for {name} must name the codepoint verbatim; got {err:?}"
32602 );
32603 assert!(
32604 err.contains("bidirectional-override")
32605 || err.contains("Unicode bidi")
32606 || err.contains("Trojan Source"),
32607 "chart description reason for {name} must name the Trojan-Source banner; \
32608 got {err:?}"
32609 );
32610 }
32611 }
32612
32613 #[test]
32614 fn chart_description_shape_accepts_pure_rtl_text_without_bidi_override() {
32615 // Positive control on the bidi-override arm: pure visual
32616 // right-to-left scripts (Hebrew, Arabic) decode to non-bidi-
32617 // override codepoints and the predicate must accept them
32618 // natively — banning all RTL would regress every Hebrew /
32619 // Arabic-authored caixa, which the substrate explicitly
32620 // supports via the non-ASCII byte arm. The structural axis the
32621 // bidi-override arm closes is the explicit direction-mark
32622 // codepoint, not the RTL script itself.
32623 for s in [
32624 // Hebrew word (RTL script, no bidi-override codepoint).
32625 "שלום",
32626 // Arabic word (RTL script, no bidi-override codepoint).
32627 "مرحبا",
32628 // Mixed LTR / RTL caixa — the canonical multilingual
32629 // description shape every YAML 1.2 + Helm v3 + Artifact
32630 // Hub consumer round-trips losslessly.
32631 "Caixa para שלום",
32632 ] {
32633 is_chart_description_shape(s).unwrap_or_else(|e| {
32634 panic!("pure-RTL chart description {s:?} must pass without bidi override: {e:?}")
32635 });
32636 }
32637 }
32638
32639 #[test]
32640 fn chart_description_shape_rejects_each_unicode_line_break_codepoint() {
32641 // The non-ASCII Unicode line-break arm — pins each of the three
32642 // UAX #14 / YAML 1.1 §4.1 line-break codepoints outside the
32643 // ASCII `\n` / `\r` bytes already caught at the per-byte pass.
32644 // Each case carries an alphabet-valid prefix + suffix so only
32645 // the line-break arm fires; the per-byte `\n` / `\r` arms
32646 // would shadow the codepoint scan if the line-break helper
32647 // accepted single-byte ASCII line terminators. A future drop
32648 // of any one arm here surfaces as a `must be rejected` panic
32649 // at this one place rather than as a silent regression
32650 // through YAML 1.1-compat downstream consumers (go-yaml v2 /
32651 // Helm v3 / kubectl). Mirrors the peer
32652 // `chart_maintainer_name_shape_rejects_each_unicode_line_break_codepoint`
32653 // on the sibling predicate — both predicates route through the
32654 // same lifted `find_unicode_line_break` helper.
32655 for (cp, name) in [
32656 ('\u{0085}', "U+0085"),
32657 ('\u{2028}', "U+2028"),
32658 ('\u{2029}', "U+2029"),
32659 ] {
32660 let s = format!("first line{cp}second line");
32661 let err = is_chart_description_shape(&s)
32662 .err()
32663 .unwrap_or_else(|| panic!("chart description with {name} must be rejected"));
32664 assert!(
32665 err.contains(name),
32666 "chart description reason for {name} must name the codepoint verbatim; got {err:?}"
32667 );
32668 assert!(
32669 err.contains("line-break") || err.contains("UAX #14") || err.contains("YAML 1.1"),
32670 "chart description reason for {name} must name the Unicode-line-break banner; \
32671 got {err:?}"
32672 );
32673 }
32674 }
32675
32676 #[test]
32677 fn chart_description_shape_accepts_non_line_break_unicode() {
32678 // Positive control on the line-break arm: the predicate must
32679 // accept every non-line-break Unicode shape the canonical
32680 // fixtures carry. Pinned alongside the per-codepoint rejection
32681 // sweep so a future helper widening that accidentally rejects
32682 // a non-line-break codepoint (the structural-floor regression
32683 // class) surfaces here as a single-source-of-truth pin. The
32684 // canonical multilingual descriptions, RTL text, em-dash and
32685 // arrows must all pass.
32686 for s in [
32687 "Canonical Rust→wasm32-wasip2 caixa Servico.",
32688 "FIXME — describe this caixa",
32689 "Caixa para שלום",
32690 "日本語の説明テスト",
32691 // U+00A0 NO-BREAK SPACE is NOT a line-break codepoint
32692 // (UAX #14 class GL — Glue, non-breaking) — must pass.
32693 "Caixa\u{00A0}for tests",
32694 ] {
32695 is_chart_description_shape(s).unwrap_or_else(|e| {
32696 panic!(
32697 "non-line-break Unicode chart description {s:?} must pass without rejection: \
32698 {e:?}"
32699 )
32700 });
32701 }
32702 }
32703
32704 #[test]
32705 fn chart_description_shape_rejects_each_unicode_invisible_format_codepoint() {
32706 // The Unicode invisible-format arm — pins each of the eight
32707 // BMP Cf-category zero-width codepoints with no visible glyph
32708 // in any conforming font. The per-byte non-ASCII pass
32709 // deliberately admits multi-byte UTF-8 sequences (Unicode
32710 // letters / arrows / em-dash are canonical fixtures); only the
32711 // typed codepoint scan catches these eight. Each case carries
32712 // an alphabet-valid prefix + suffix so only the invisible-
32713 // format arm fires. A future drop of any one arm here surfaces
32714 // as a `must be rejected` panic at this one place rather than
32715 // as a silent regression through invisible-codepoint-homograph
32716 // downstream consumers (Artifact Hub description-search
32717 // misses, byte-level diff / grep / equality disagreement with
32718 // the visible-glyph match). Peer of
32719 // `chart_maintainer_name_shape_rejects_each_unicode_invisible_format_codepoint`
32720 // on the sibling predicate — both predicates route through the
32721 // same lifted `find_unicode_invisible_format` helper. Covers
32722 // the four paste-from-Word / paste-from-BOM-editor / paste-
32723 // from-typesetting shapes (U+00AD / U+200B / U+2060 / U+FEFF)
32724 // and the four math-formula invisible operators (U+2061
32725 // FUNCTION APPLICATION / U+2062 INVISIBLE TIMES / U+2063
32726 // INVISIBLE SEPARATOR / U+2064 INVISIBLE PLUS — the canonical
32727 // paste-from-MathJax / paste-from-LaTeX-rendered-formula
32728 // footgun where the renderer emits an invisible operator
32729 // between adjacent symbols for screen-reader operator
32730 // semantics).
32731 for (cp, name) in [
32732 ('\u{00AD}', "U+00AD"),
32733 ('\u{200B}', "U+200B"),
32734 ('\u{2060}', "U+2060"),
32735 ('\u{2061}', "U+2061"),
32736 ('\u{2062}', "U+2062"),
32737 ('\u{2063}', "U+2063"),
32738 ('\u{2064}', "U+2064"),
32739 ('\u{FEFF}', "U+FEFF"),
32740 ] {
32741 let s = format!("Canonical{cp}Servico");
32742 let err = is_chart_description_shape(&s)
32743 .err()
32744 .unwrap_or_else(|| panic!("chart description with {name} must be rejected"));
32745 assert!(
32746 err.contains(name),
32747 "chart description reason for {name} must name the codepoint verbatim; got {err:?}"
32748 );
32749 assert!(
32750 err.contains("invisible-format")
32751 || err.contains("Cf-category")
32752 || err.contains("zero-width"),
32753 "chart description reason for {name} must name the invisible-format banner; \
32754 got {err:?}"
32755 );
32756 }
32757 }
32758
32759 #[test]
32760 fn chart_description_shape_accepts_non_invisible_format_unicode() {
32761 // Positive control on the invisible-format arm: the predicate
32762 // must accept every non-invisible-format Unicode shape canonical
32763 // fixtures carry — including U+200C ZWNJ / U+200D ZWJ
32764 // (legitimate compositional load in Indic / Persian scripts and
32765 // emoji ZWJ sequences) and U+200E LRM / U+200F RLM (legitimate
32766 // single-character direction hints in mixed-script prose). A
32767 // future helper widening that accidentally rejects any of these
32768 // would regress legitimate fixture shapes and surfaces here as
32769 // a single-source-of-truth pin. Mirrors
32770 // `chart_maintainer_name_shape_accepts_non_invisible_format_unicode`
32771 // on the sibling predicate.
32772 for s in [
32773 "Canonical Rust→wasm32-wasip2 caixa Servico.",
32774 "FIXME — describe this caixa",
32775 // Emoji ZWJ sequence (U+200D) — must NOT be rejected: the
32776 // canonical multi-codepoint emoji authoring shape every
32777 // chart-aware UI renders as a single glyph.
32778 "Caixa for the 👨\u{200D}💻 family",
32779 // ZWNJ (U+200C) — legitimate Persian / Indic script
32780 // composition; the helper must NOT claim it.
32781 "Caixa for می\u{200C}باشد",
32782 // Bidi marks LRM (U+200E) and RLM (U+200F) — legitimate
32783 // single-character direction hints, separate class from
32784 // the bidi *overrides* the prior helper rejects.
32785 "Caixa for ASCII\u{200E}embedded in RTL",
32786 "Caixa for \u{200F}RTL hint",
32787 ] {
32788 is_chart_description_shape(s).unwrap_or_else(|e| {
32789 panic!(
32790 "non-invisible-format Unicode chart description {s:?} must pass without \
32791 rejection: {e:?}"
32792 )
32793 });
32794 }
32795 }
32796
32797 // ── is_chart_maintainer_name_shape — shared `:autores` chart-maintainer predicate ──
32798
32799 #[test]
32800 fn chart_maintainer_name_shape_accepts_canonical_forms() {
32801 // Substrate-side pin: the predicate accepts every canonical
32802 // chart-maintainer-name shape the `:autores` axis carries.
32803 // Drift between this list and the per-axis
32804 // `manifest::tests::validate_autores_accepts_canonical_forms`
32805 // positive-set sweep surfaces here — one source of truth for
32806 // the rule. Covers the hello-rio / checkout-aplicacao
32807 // `:autores ("pleme-io")` fixture, the multi-author
32808 // `"Pleme Contributors"` shape, and the canonical Helm
32809 // `"name <email>"` shape downstream packaging surfaces emit.
32810 for s in [
32811 "pleme-io",
32812 "Pleme Contributors",
32813 "alice <alice@example.com>",
32814 "bob <bob@example.com>",
32815 "Acme Corporation",
32816 "x",
32817 ] {
32818 is_chart_maintainer_name_shape(s).unwrap_or_else(|e| {
32819 panic!("canonical chart maintainer name {s:?} must pass: {e:?}")
32820 });
32821 }
32822 }
32823
32824 #[test]
32825 fn chart_maintainer_name_shape_rejects_each_arm_with_substring_pinned_reason() {
32826 // Substrate-side diagnostic-shape pin: each arm surfaces its
32827 // own distinct reason substring. Pinned here so a future
32828 // reason-wording rephrase that drops any of these substrings
32829 // surfaces at this one place, not piecemeal across every
32830 // per-axis test sweep. Mirrors
32831 // `chart_description_shape_rejects_each_arm_with_substring_pinned_reason`
32832 // on the peer predicate.
32833 for (s, needle) in [
32834 // Leading whitespace — paste-from-aligned-doc.
32835 (" pleme-io", "whitespace"),
32836 // Trailing whitespace — paste-from-doc.
32837 ("pleme-io ", "whitespace"),
32838 // Tab inside — tab-from-aligned-doc.
32839 ("Pleme\tContributors", "tab"),
32840 // Newline — paste-from-multiline-doc (author pasted
32841 // multi-line author block into one entry).
32842 ("alice\nbob", "newline"),
32843 // Carriage return — paste-from-Windows-CRLF-doc.
32844 ("alice\rbob", "carriage return"),
32845 // NUL byte — paste-from-binary-blob.
32846 ("alice\x00bob", "control character"),
32847 // BEL byte — paste-from-binary-blob.
32848 ("alice\x07bob", "control character"),
32849 // ESC byte — paste-from-binary-blob.
32850 ("alice\x1bbob", "control character"),
32851 // DEL byte (0x7F).
32852 ("alice\x7fbob", "control character"),
32853 ] {
32854 let err = is_chart_maintainer_name_shape(s)
32855 .err()
32856 .unwrap_or_else(|| panic!("chart maintainer name {s:?} must be rejected"));
32857 assert!(
32858 err.contains(needle),
32859 "chart maintainer name {s:?} reason must contain {needle:?}; got {err:?}"
32860 );
32861 }
32862 }
32863
32864 #[test]
32865 fn chart_maintainer_name_shape_accepts_unicode() {
32866 // Positive control on the non-ASCII arm: the predicate must
32867 // accept Unicode beyond the ASCII alphabet — realistic
32868 // maintainer names carry Unicode (`François`, `日本語`,
32869 // `naïve`), and every downstream consumer (YAML 1.2, Helm v3,
32870 // every chart-aware UI) round-trips Unicode losslessly. A
32871 // future tightening that bans non-ASCII bytes would regress
32872 // every Unicode-named maintainer and surface here as a
32873 // regression. Mirrors the peer
32874 // `chart_description_shape_accepts_unicode`.
32875 for s in [
32876 "François Dupont",
32877 "日本語の名前",
32878 "naïve <naive@example.com>",
32879 "André",
32880 ] {
32881 is_chart_maintainer_name_shape(s)
32882 .unwrap_or_else(|e| panic!("Unicode chart maintainer name {s:?} must pass: {e:?}"));
32883 }
32884 }
32885
32886 #[test]
32887 fn chart_maintainer_name_shape_rejects_empty_defensively() {
32888 // The predicate is called from `crate::Caixa::validate_autores`
32889 // only after the per-axis `AutorEmpty` arm has fired at
32890 // validate time; re-checking here keeps the predicate usable
32891 // from any future call site without an empty-precondition
32892 // footgun. Same defensive empty-check `is_dns_1123_label`,
32893 // `is_gateway_api_http_path`, `is_wit_world_ref`,
32894 // `is_nats_subject`, `is_wasi_keyvalue_slot`,
32895 // `is_git_ref_name`, `is_git_oid`, `is_git_repo_url`,
32896 // `is_cargo_feature_name`, `is_spdx_expression_shape`, and
32897 // `is_chart_description_shape` carry at their call sites.
32898 let err = is_chart_maintainer_name_shape("").unwrap_err();
32899 assert!(err.contains("empty"), "got: {err:?}");
32900 }
32901
32902 #[test]
32903 fn chart_maintainer_name_shape_rejects_at_129_byte_boundary() {
32904 // The 128-byte cap pin — both the boundary-exceeding case and
32905 // the boundary-accepting case in one place, so a future cap
32906 // shift surfaces both arms simultaneously, mirroring the peer
32907 // cap-boundary pins (`chart_description_shape_rejects_at_513_byte_boundary`
32908 // on the 512-byte sibling, `spdx_expression_shape_rejects_at_257_byte_boundary`
32909 // on the 256-byte sibling). Constructed as a single all-`a`
32910 // token so only the cap arm fires (128 `a` bytes is
32911 // alphabet-valid).
32912 let max_ok = "a".repeat(CHART_MAINTAINER_NAME_MAX_LEN);
32913 assert_eq!(max_ok.len(), 128);
32914 is_chart_maintainer_name_shape(&max_ok).unwrap();
32915 let too_long = "a".repeat(CHART_MAINTAINER_NAME_MAX_LEN + 1);
32916 assert_eq!(too_long.len(), 129);
32917 let err = is_chart_maintainer_name_shape(&too_long).unwrap_err();
32918 assert!(err.contains("128"), "got: {err:?}");
32919 assert!(err.contains("129"), "got: {err:?}");
32920 }
32921
32922 #[test]
32923 fn chart_maintainer_name_shape_rejects_each_unicode_bidi_override_codepoint() {
32924 // The Trojan Source (CVE-2021-42574) arm — pins every UAX #9
32925 // bidirectional-override / isolate format codepoint as a
32926 // structural rejection on the typed `:autores` axis. Mirrors
32927 // `chart_description_shape_rejects_each_unicode_bidi_override_codepoint`
32928 // on the peer predicate — both predicates route through the
32929 // same lifted `find_unicode_bidi_override` helper, so dropping
32930 // any one of the nine arms from the helper's match would
32931 // regress both peer test sweeps simultaneously at this one
32932 // structural floor rather than at piecemeal per-axis call
32933 // sites. The canonical attacker shape: an `:autores
32934 // "alice\u{202E}example.com<bob@"` entry renders in `helm
32935 // list`'s maintainer column / Artifact Hub as the visually-
32936 // reversed `alice<@bob>moc.elpmaxe` while riding verbatim
32937 // into the Chart.yaml `maintainers:` array — exactly the
32938 // class this arm closes.
32939 for (cp, name) in [
32940 ('\u{202A}', "U+202A"),
32941 ('\u{202B}', "U+202B"),
32942 ('\u{202C}', "U+202C"),
32943 ('\u{202D}', "U+202D"),
32944 ('\u{202E}', "U+202E"),
32945 ('\u{2066}', "U+2066"),
32946 ('\u{2067}', "U+2067"),
32947 ('\u{2068}', "U+2068"),
32948 ('\u{2069}', "U+2069"),
32949 ] {
32950 let s = format!("alice{cp}bob");
32951 let err = is_chart_maintainer_name_shape(&s)
32952 .err()
32953 .unwrap_or_else(|| panic!("chart maintainer name with {name} must be rejected"));
32954 assert!(
32955 err.contains(name),
32956 "chart maintainer name reason for {name} must name the codepoint verbatim; \
32957 got {err:?}"
32958 );
32959 assert!(
32960 err.contains("bidirectional-override")
32961 || err.contains("Unicode bidi")
32962 || err.contains("Trojan Source"),
32963 "chart maintainer name reason for {name} must name the Trojan-Source banner; \
32964 got {err:?}"
32965 );
32966 }
32967 }
32968
32969 #[test]
32970 fn chart_maintainer_name_shape_accepts_pure_rtl_text_without_bidi_override() {
32971 // Positive control on the bidi-override arm: pure visual
32972 // right-to-left scripts (Hebrew, Arabic) decode to non-bidi-
32973 // override codepoints and the predicate must accept them
32974 // natively — banning all RTL would regress every Hebrew /
32975 // Arabic-authored maintainer-name entry, which the substrate
32976 // supports via the non-ASCII byte arm. Peer of
32977 // `chart_description_shape_accepts_pure_rtl_text_without_bidi_override`
32978 // on the sibling YAML-plain-style-scalar surface.
32979 for s in [
32980 // Pure Hebrew maintainer name.
32981 "שלום",
32982 // Pure Arabic maintainer name.
32983 "مرحبا",
32984 // Mixed-script — canonical multilingual maintainer
32985 // shape every YAML 1.2 + Helm v3 round-trips losslessly.
32986 "Acme שלום",
32987 ] {
32988 is_chart_maintainer_name_shape(s).unwrap_or_else(|e| {
32989 panic!(
32990 "pure-RTL chart maintainer name {s:?} must pass without bidi override: {e:?}"
32991 )
32992 });
32993 }
32994 }
32995
32996 #[test]
32997 fn chart_maintainer_name_shape_rejects_each_unicode_line_break_codepoint() {
32998 // The non-ASCII Unicode line-break arm — pins each of the three
32999 // UAX #14 / YAML 1.1 §4.1 line-break codepoints outside the
33000 // ASCII `\n` / `\r` bytes already caught at the per-byte pass.
33001 // The canonical YAML-1.1-vs-YAML-1.2 paste-from-doc footgun: an
33002 // `:autores "alice\u{2028}bob"` entry parses as one
33003 // `maintainers:` array entry through a YAML 1.2-strict parser
33004 // and as two entries through a YAML 1.1 parser (go-yaml v2 /
33005 // Helm v3). Mirrors
33006 // `chart_description_shape_rejects_each_unicode_line_break_codepoint`
33007 // on the peer predicate — both predicates route through the
33008 // same lifted `find_unicode_line_break` helper, so dropping
33009 // any one of the three arms from the helper's match would
33010 // regress both peer test sweeps simultaneously at this one
33011 // structural floor.
33012 for (cp, name) in [
33013 ('\u{0085}', "U+0085"),
33014 ('\u{2028}', "U+2028"),
33015 ('\u{2029}', "U+2029"),
33016 ] {
33017 let s = format!("alice{cp}bob");
33018 let err = is_chart_maintainer_name_shape(&s)
33019 .err()
33020 .unwrap_or_else(|| panic!("chart maintainer name with {name} must be rejected"));
33021 assert!(
33022 err.contains(name),
33023 "chart maintainer name reason for {name} must name the codepoint verbatim; \
33024 got {err:?}"
33025 );
33026 assert!(
33027 err.contains("line-break") || err.contains("UAX #14") || err.contains("YAML 1.1"),
33028 "chart maintainer name reason for {name} must name the Unicode-line-break banner; \
33029 got {err:?}"
33030 );
33031 }
33032 }
33033
33034 #[test]
33035 fn chart_maintainer_name_shape_accepts_non_line_break_unicode() {
33036 // Positive control on the line-break arm: the predicate must
33037 // accept every non-line-break Unicode shape canonical
33038 // maintainer names carry. Pinned alongside the per-codepoint
33039 // rejection sweep so a future helper widening that
33040 // accidentally rejects a non-line-break codepoint surfaces
33041 // here as a single-source-of-truth pin. Peer of
33042 // `chart_description_shape_accepts_non_line_break_unicode`
33043 // on the sibling YAML-plain-style-scalar surface.
33044 for s in [
33045 "François Dupont",
33046 "日本語の名前",
33047 "naïve <naive@example.com>",
33048 "André",
33049 // U+00A0 NO-BREAK SPACE is NOT a line-break codepoint
33050 // (UAX #14 class GL — Glue, non-breaking) and is the
33051 // canonical authoring shape for unbreakable space inside
33052 // a multi-token maintainer name — must pass.
33053 "Acme\u{00A0}Corp",
33054 ] {
33055 is_chart_maintainer_name_shape(s).unwrap_or_else(|e| {
33056 panic!(
33057 "non-line-break Unicode chart maintainer name {s:?} must pass without \
33058 rejection: {e:?}"
33059 )
33060 });
33061 }
33062 }
33063
33064 #[test]
33065 fn chart_maintainer_name_shape_rejects_each_unicode_invisible_format_codepoint() {
33066 // The Unicode invisible-format arm — pins each of the eight
33067 // BMP Cf-category zero-width codepoints with no visible glyph.
33068 // The canonical maintainer-identity homograph footgun: an
33069 // `:autores "alice\u{200B}"` entry renders identically to
33070 // `:autores "alice"` in `helm list` / Artifact Hub's
33071 // maintainer column, but the byte sequence is distinct — the
33072 // Artifact Hub maintainer-index lookup misses the authored
33073 // `"alice"` entry, a future CLA-signer lookup matches a
33074 // visually-identical-but-byte-distinct identity. Mirrors
33075 // `chart_description_shape_rejects_each_unicode_invisible_format_codepoint`
33076 // on the peer predicate — both predicates route through the
33077 // same lifted `find_unicode_invisible_format` helper, so
33078 // dropping any one of the eight arms from the helper's match
33079 // would regress both peer test sweeps simultaneously at this
33080 // one structural floor. Covers the four paste-from-Word /
33081 // paste-from-BOM-editor / paste-from-typesetting shapes
33082 // (U+00AD / U+200B / U+2060 / U+FEFF) and the four math-
33083 // formula invisible operators (U+2061 FUNCTION APPLICATION /
33084 // U+2062 INVISIBLE TIMES / U+2063 INVISIBLE SEPARATOR /
33085 // U+2064 INVISIBLE PLUS — paste-from-MathJax / paste-from-
33086 // LaTeX-rendered-formula footgun).
33087 for (cp, name) in [
33088 ('\u{00AD}', "U+00AD"),
33089 ('\u{200B}', "U+200B"),
33090 ('\u{2060}', "U+2060"),
33091 ('\u{2061}', "U+2061"),
33092 ('\u{2062}', "U+2062"),
33093 ('\u{2063}', "U+2063"),
33094 ('\u{2064}', "U+2064"),
33095 ('\u{FEFF}', "U+FEFF"),
33096 ] {
33097 let s = format!("alice{cp}bob");
33098 let err = is_chart_maintainer_name_shape(&s)
33099 .err()
33100 .unwrap_or_else(|| panic!("chart maintainer name with {name} must be rejected"));
33101 assert!(
33102 err.contains(name),
33103 "chart maintainer name reason for {name} must name the codepoint verbatim; \
33104 got {err:?}"
33105 );
33106 assert!(
33107 err.contains("invisible-format")
33108 || err.contains("Cf-category")
33109 || err.contains("zero-width"),
33110 "chart maintainer name reason for {name} must name the invisible-format banner; \
33111 got {err:?}"
33112 );
33113 }
33114 }
33115
33116 #[test]
33117 fn chart_maintainer_name_shape_accepts_non_invisible_format_unicode() {
33118 // Positive control on the invisible-format arm: the predicate
33119 // must accept the legitimate-use codepoints the helper
33120 // deliberately excludes — U+200C ZWNJ / U+200D ZWJ (emoji ZWJ
33121 // sequences are canonical for modern maintainer-display names;
33122 // Indic / Persian script composition relies on ZWNJ to break
33123 // inappropriate ligatures) and U+200E LRM / U+200F RLM
33124 // (mixed-script direction hints are canonical for "Arabic name
33125 // with embedded ASCII email" shapes). Peer of
33126 // `chart_description_shape_accepts_non_invisible_format_unicode`
33127 // on the sibling YAML-plain-style-scalar surface.
33128 for s in [
33129 "François Dupont",
33130 "naïve <naive@example.com>",
33131 // Emoji ZWJ sequence (U+200D) — canonical multi-codepoint
33132 // emoji authoring shape.
33133 "Joe 👨\u{200D}💻 Developer",
33134 // ZWNJ (U+200C) — legitimate Persian / Indic composition.
33135 "Persian می\u{200C}باشد maintainer",
33136 // Bidi marks LRM / RLM — legitimate direction hints in
33137 // mixed-script maintainer names.
33138 "Arabic\u{200F}name <maintainer@example.com>",
33139 "ASCII\u{200E}embedded in RTL context",
33140 ] {
33141 is_chart_maintainer_name_shape(s).unwrap_or_else(|e| {
33142 panic!(
33143 "non-invisible-format Unicode chart maintainer name {s:?} must pass without \
33144 rejection: {e:?}"
33145 )
33146 });
33147 }
33148 }
33149
33150 #[test]
33151 fn find_unicode_bidi_override_pins_the_nine_codepoint_accepted_set() {
33152 // The shared helper's accepted set — pinned in one place so
33153 // every per-predicate caller (`is_chart_description_shape`,
33154 // `is_chart_maintainer_name_shape`, every future free-form-
33155 // prose surface) reads from one canonical accepted set. The
33156 // nine UAX #9 bidirectional-override / isolate format
33157 // codepoints in document order, plus negative controls on
33158 // bytes the helper must NOT reject (ASCII / non-bidi Unicode
33159 // letters / arrows / em-dash / RTL letters). A future shift
33160 // in the accepted set surfaces here as a single-source-of-
33161 // truth edit at this one test rather than across every
33162 // per-predicate per-arm sweep.
33163 for cp in [
33164 '\u{202A}', '\u{202B}', '\u{202C}', '\u{202D}', '\u{202E}', '\u{2066}', '\u{2067}',
33165 '\u{2068}', '\u{2069}',
33166 ] {
33167 let s = format!("a{cp}b");
33168 assert_eq!(
33169 find_unicode_bidi_override(&s),
33170 Some(cp),
33171 "helper must flag bidi override U+{:04X} on input {s:?}",
33172 cp as u32
33173 );
33174 }
33175 for s in [
33176 "alice",
33177 "Canonical Rust→wasm32-wasip2",
33178 "FIXME — describe this caixa",
33179 "François Dupont",
33180 "日本語の説明",
33181 "naïve",
33182 "שלום",
33183 "مرحبا",
33184 ] {
33185 assert_eq!(
33186 find_unicode_bidi_override(s),
33187 None,
33188 "helper must accept {s:?} (no bidi-override codepoint)"
33189 );
33190 }
33191 // Empty input — defensive precondition for the helper's
33192 // call-site contract on any future caller that doesn't gate
33193 // emptiness ahead of the scan.
33194 assert_eq!(find_unicode_bidi_override(""), None);
33195 }
33196
33197 #[test]
33198 fn find_unicode_line_break_pins_the_three_codepoint_accepted_set() {
33199 // The shared helper's accepted set — pinned in one place so
33200 // every per-predicate caller (`is_chart_description_shape`,
33201 // `is_chart_maintainer_name_shape`, every future free-form-
33202 // prose surface) reads from one canonical accepted set. The
33203 // three UAX #14 / YAML 1.1 §4.1 non-ASCII line-break
33204 // codepoints in document order, plus negative controls on
33205 // bytes the helper must NOT reject (ASCII text, Unicode
33206 // letters / arrows / em-dash / RTL letters, the canonical
33207 // non-line-break U+00A0 NBSP shape downstream YAML 1.2 +
33208 // Helm v3 + every chart-aware UI round-trip losslessly). A
33209 // future shift in the accepted set surfaces here as a
33210 // single-source-of-truth edit at this one test rather than
33211 // across every per-predicate per-arm sweep. Peer of
33212 // `find_unicode_bidi_override_pins_the_nine_codepoint_accepted_set`
33213 // on the sibling lifted-helper one trajectory earlier.
33214 for cp in ['\u{0085}', '\u{2028}', '\u{2029}'] {
33215 let s = format!("a{cp}b");
33216 assert_eq!(
33217 find_unicode_line_break(&s),
33218 Some(cp),
33219 "helper must flag line-break codepoint U+{:04X} on input {s:?}",
33220 cp as u32
33221 );
33222 }
33223 for s in [
33224 "alice",
33225 "Canonical Rust→wasm32-wasip2",
33226 "FIXME — describe this caixa",
33227 "François Dupont",
33228 "日本語の説明",
33229 "naïve",
33230 "שלום",
33231 "مرحبا",
33232 // U+00A0 NO-BREAK SPACE — UAX #14 class GL (Glue,
33233 // non-breaking) — must NOT be rejected: the canonical
33234 // unbreakable-space shape every typed maintainer-name
33235 // axis admits.
33236 "Acme\u{00A0}Corp",
33237 // U+0009 TAB and U+000A LF and U+000D CR — ASCII
33238 // line-break / whitespace bytes the per-byte arm on the
33239 // calling predicate already closes; the helper must NOT
33240 // claim them as its own (single-source-of-truth: ASCII
33241 // arms live in the per-byte loop, the helper closes the
33242 // non-ASCII codepoints).
33243 "alice\tbob",
33244 "alice\nbob",
33245 "alice\rbob",
33246 ] {
33247 assert_eq!(
33248 find_unicode_line_break(s),
33249 None,
33250 "helper must accept {s:?} (no non-ASCII line-break codepoint)"
33251 );
33252 }
33253 // Empty input — defensive precondition for the helper's
33254 // call-site contract on any future caller that doesn't gate
33255 // emptiness ahead of the scan.
33256 assert_eq!(find_unicode_line_break(""), None);
33257 }
33258
33259 #[test]
33260 fn find_unicode_invisible_format_pins_the_eight_codepoint_accepted_set() {
33261 // The shared helper's accepted set — pinned in one place so
33262 // every per-predicate caller (`is_chart_description_shape`,
33263 // `is_chart_maintainer_name_shape`, every future free-form-
33264 // prose surface) reads from one canonical accepted set. The
33265 // eight BMP Cf-category zero-width codepoints in document
33266 // order — the four paste-from-Word / paste-from-BOM-editor /
33267 // paste-from-typesetting-doc shapes (U+00AD SHY / U+200B ZWSP /
33268 // U+2060 WJ / U+FEFF ZWNBSP-BOM) and the four math-formula
33269 // invisible operators (U+2061 FUNCTION APPLICATION / U+2062
33270 // INVISIBLE TIMES / U+2063 INVISIBLE SEPARATOR / U+2064
33271 // INVISIBLE PLUS — paste-from-MathJax / paste-from-LaTeX-
33272 // rendered-formula / paste-from-InDesign-math-equation
33273 // shapes) — plus negative controls on codepoints the helper
33274 // must NOT reject — the deliberate exclusions: U+200C ZWNJ /
33275 // U+200D ZWJ (emoji ZWJ sequences + Indic / Persian script
33276 // composition) and U+200E LRM / U+200F RLM (mixed-script
33277 // direction hints). A future shift in the accepted set
33278 // surfaces here as a single-source-of-truth edit at this one
33279 // test rather than across every per-predicate per-arm sweep.
33280 // Third pin in the UAX-driven render-determinism trio (peer of
33281 // `find_unicode_bidi_override_pins_the_nine_codepoint_accepted_set`
33282 // on the visual-order axis and
33283 // `find_unicode_line_break_pins_the_three_codepoint_accepted_set`
33284 // on the single-line/multi-line axis).
33285 for cp in [
33286 '\u{00AD}', '\u{200B}', '\u{2060}', '\u{2061}', '\u{2062}', '\u{2063}', '\u{2064}',
33287 '\u{FEFF}',
33288 ] {
33289 let s = format!("a{cp}b");
33290 assert_eq!(
33291 find_unicode_invisible_format(&s),
33292 Some(cp),
33293 "helper must flag invisible-format codepoint U+{:04X} on input {s:?}",
33294 cp as u32
33295 );
33296 }
33297 for s in [
33298 "alice",
33299 "Canonical Rust→wasm32-wasip2",
33300 "FIXME — describe this caixa",
33301 "François Dupont",
33302 "日本語の説明",
33303 "naïve",
33304 "שלום",
33305 "مرحبا",
33306 // U+00A0 NO-BREAK SPACE — class GL (Glue), visible-width
33307 // codepoint — must NOT be claimed by the invisible-format
33308 // helper (the canonical unbreakable-space shape).
33309 "Acme\u{00A0}Corp",
33310 // U+200C ZWNJ — deliberately excluded (Indic / Persian
33311 // composition + emoji ZWJ-adjacent context).
33312 "می\u{200C}باشد",
33313 // U+200D ZWJ — deliberately excluded (emoji ZWJ
33314 // sequences are canonical: 👨💻 is MAN + ZWJ + LAPTOP).
33315 "Joe 👨\u{200D}💻 Developer",
33316 // U+200E LRM — deliberately excluded (direction-hint
33317 // mark, not a direction-override; legitimate in
33318 // mixed-script prose).
33319 "ASCII\u{200E}embedded",
33320 // U+200F RLM — deliberately excluded (mirror of LRM
33321 // on the RTL axis).
33322 "Arabic\u{200F}name",
33323 // Bidi-override codepoints (U+202A..U+202E, U+2066..U+2069)
33324 // — caught by the sibling `find_unicode_bidi_override`
33325 // helper, not this one (single-source-of-truth: each
33326 // helper closes exactly its class).
33327 "alice\u{202E}bob",
33328 // Line-break codepoints (U+0085, U+2028, U+2029) — caught
33329 // by the sibling `find_unicode_line_break` helper.
33330 "alice\u{2028}bob",
33331 ] {
33332 assert_eq!(
33333 find_unicode_invisible_format(s),
33334 None,
33335 "helper must accept {s:?} (no invisible-format codepoint in the four-codepoint set)"
33336 );
33337 }
33338 // Empty input — defensive precondition for the helper's
33339 // call-site contract on any future caller that doesn't gate
33340 // emptiness ahead of the scan.
33341 assert_eq!(find_unicode_invisible_format(""), None);
33342 }
33343
33344 // ── is_chart_keyword_shape — shared `:etiquetas` chart-keyword predicate ──
33345
33346 #[test]
33347 fn chart_keyword_shape_accepts_canonical_forms() {
33348 // Substrate-side pin: the predicate accepts every canonical
33349 // chart-keyword shape the `:etiquetas` axis carries. Drift
33350 // between this list and the per-axis
33351 // `manifest::tests::validate_etiquetas_accepts_canonical_shaped_forms`
33352 // positive-set sweep surfaces here — one source of truth for
33353 // the rule. Covers the example fixtures'
33354 // `:etiquetas` lists (`"example"`, `"aplicacao"`, `"mesh"`,
33355 // `"ecommerce"`, `"demo"`, `"infrastructure"`, `"aws"`,
33356 // `"akeyless"`, `"pangea-native"`) and the substrate-fixed
33357 // tags caixa-helm unions in at chart render (`"lareira"`,
33358 // `"wasm"`, `"tatara-lisp"`, `"caixa-servico"`).
33359 let example_fixture_tags = [
33360 "example",
33361 "aplicacao",
33362 "mesh",
33363 "ecommerce",
33364 "demo",
33365 "infrastructure",
33366 "aws",
33367 "akeyless",
33368 "pangea-native",
33369 "hello-world",
33370 "rust",
33371 "Foo",
33372 "Bar123",
33373 "x",
33374 "snake_case_tag",
33375 ];
33376 for s in example_fixture_tags
33377 .iter()
33378 .copied()
33379 .chain(LAREIRA_CHART_KEYWORDS.iter().copied())
33380 {
33381 is_chart_keyword_shape(s)
33382 .unwrap_or_else(|e| panic!("canonical chart keyword {s:?} must pass: {e:?}"));
33383 }
33384 }
33385
33386 #[test]
33387 fn lareira_chart_keywords_pins_canonical_ordered_set() {
33388 // Substrate-side canonical-set pin: byte-pins the
33389 // substrate-fixed `Chart.yaml` `keywords:` union caixa-helm's
33390 // `build_chart_yaml` folds into every rendered `lareira-<nome>`
33391 // chart on top of the caixa author's own `:etiquetas`. The
33392 // ordered array shape (`BTreeSet`-canonical ascii-alphabetical)
33393 // pins the same order the emitted `Chart.yaml` `keywords:`
33394 // sequence lists them after the intermediate
33395 // `BTreeSet<String>` fold at the caixa-helm emit site. A drift
33396 // between the canonical array and either the production emit
33397 // at `caixa-helm::build_chart_yaml` (the sole consumer) or
33398 // the peer positive-set sweep tests (this crate's
33399 // `chart_keyword_shape_accepts_canonical_forms` and
33400 // `manifest::tests::validate_etiquetas_accepts_canonical_shaped_forms`)
33401 // surfaces at this one substrate-side pin.
33402 assert_eq!(
33403 LAREIRA_CHART_KEYWORDS,
33404 &["caixa-servico", "lareira", "tatara-lisp", "wasm"],
33405 );
33406 }
33407
33408 #[test]
33409 fn lareira_chart_keywords_stays_btreeset_canonical_ordered() {
33410 // Substrate-side ordering pin: the array is
33411 // `BTreeSet`-canonical ascii-alphabetical, so its declared
33412 // order matches the shape the emitted `Chart.yaml`
33413 // `keywords:` sequence carries after
33414 // `caixa-helm::build_chart_yaml`'s intermediate
33415 // `BTreeSet<String>` fold — a future substrate-fixed keyword
33416 // addition that lands out-of-order (an `"opentelemetry"` entry
33417 // dropped before `"tatara-lisp"`, an `"lunatic"` entry dropped
33418 // after `"wasm"`) trips this pin at caixa-core build time
33419 // rather than surfacing as a byte-shape drift between the
33420 // array's declared order and the emitted `keywords:` sequence
33421 // order at chart render time downstream.
33422 let mut sorted: Vec<&str> = LAREIRA_CHART_KEYWORDS.to_vec();
33423 sorted.sort_unstable();
33424 assert_eq!(LAREIRA_CHART_KEYWORDS, sorted.as_slice());
33425 }
33426
33427 #[test]
33428 fn lareira_chart_keywords_each_entry_passes_is_chart_keyword_shape() {
33429 // Substrate-side shape-invariant pin: every substrate-fixed
33430 // chart-keyword entry must satisfy the per-`Chart.yaml`
33431 // `keywords:` entry validation predicate the substrate
33432 // enforces on the author-side `:etiquetas` axis — a future
33433 // substrate-fixed keyword addition that happens to break the
33434 // shape rule (a leading digit, an uppercase letter, a byte
33435 // over the `CHART_KEYWORD_MAX_LEN` cap, an ASCII whitespace,
33436 // a Unicode-invisible-format code point) trips this pin at
33437 // caixa-core build time rather than surfacing at
33438 // `helm lint` time on the rendered chart downstream.
33439 for keyword in LAREIRA_CHART_KEYWORDS {
33440 is_chart_keyword_shape(keyword).unwrap_or_else(|e| {
33441 panic!(
33442 "substrate-fixed chart keyword {keyword:?} must pass \
33443 is_chart_keyword_shape: {e:?}"
33444 )
33445 });
33446 }
33447 }
33448
33449 #[test]
33450 fn chart_keyword_shape_rejects_each_arm_with_substring_pinned_reason() {
33451 // Substrate-side diagnostic-shape pin: each arm surfaces its
33452 // own distinct reason substring. Pinned here so a future
33453 // reason-wording rephrase that drops any of these substrings
33454 // surfaces at this one place, not piecemeal across every
33455 // per-axis test sweep. Mirrors
33456 // `chart_maintainer_name_shape_rejects_each_arm_with_substring_pinned_reason`
33457 // on the peer predicate.
33458 for (s, needle) in [
33459 // Leading whitespace — paste-from-aligned-doc.
33460 (" mesh", "whitespace"),
33461 // Leading hyphen — kebab-leak footgun.
33462 ("-foo", "`-`"),
33463 // Leading underscore — snake-leak footgun.
33464 ("_foo", "`_`"),
33465 // Leading digit — paste-from-numbered-list footgun.
33466 ("1foo", "digit"),
33467 // Embedded whitespace — multi-tag-blob footgun.
33468 ("web service", "whitespace"),
33469 // Tab inside — tab-from-aligned-doc.
33470 ("mesh\thttp", "whitespace"),
33471 // Newline — paste-from-multiline-doc.
33472 ("mesh\nhttp", "newline"),
33473 // Carriage return — paste-from-Windows-CRLF-doc.
33474 ("mesh\rhttp", "carriage return"),
33475 // Comma — CSV-list-separator confusion.
33476 ("mesh,http", "`,`"),
33477 // Slash — path-separator confusion.
33478 ("caixa/servico", "`/`"),
33479 // Semicolon — alt-list-separator confusion.
33480 ("mesh;http", "`;`"),
33481 // Period — namespace / version-suffix confusion.
33482 ("http.1", "`.`"),
33483 // NUL byte — paste-from-binary-blob.
33484 ("mesh\x00http", "control character"),
33485 // DEL byte (0x7F).
33486 ("mesh\x7fhttp", "control character"),
33487 // Non-ASCII inside.
33488 ("café", "non-ASCII"),
33489 // Non-ASCII leading.
33490 ("éclair", "non-ASCII"),
33491 ] {
33492 let err = is_chart_keyword_shape(s)
33493 .err()
33494 .unwrap_or_else(|| panic!("chart keyword {s:?} must be rejected"));
33495 assert!(
33496 err.contains(needle),
33497 "chart keyword {s:?} reason must contain {needle:?}; got {err:?}"
33498 );
33499 }
33500 }
33501
33502 #[test]
33503 fn chart_keyword_shape_rejects_empty_defensively() {
33504 // The predicate is called from `crate::Caixa::validate_etiquetas`
33505 // only after the per-axis `EtiquetaEmpty` arm has fired at
33506 // validate time; re-checking here keeps the predicate usable
33507 // from any future call site without an empty-precondition
33508 // footgun. Same defensive empty-check `is_dns_1123_label`,
33509 // `is_gateway_api_http_path`, `is_wit_world_ref`,
33510 // `is_nats_subject`, `is_wasi_keyvalue_slot`,
33511 // `is_git_ref_name`, `is_git_oid`, `is_git_repo_url`,
33512 // `is_cargo_feature_name`, `is_spdx_expression_shape`,
33513 // `is_chart_description_shape`, and
33514 // `is_chart_maintainer_name_shape` carry at their call sites.
33515 let err = is_chart_keyword_shape("").unwrap_err();
33516 assert!(err.contains("empty"), "got: {err:?}");
33517 }
33518
33519 #[test]
33520 fn chart_keyword_shape_rejects_at_21_byte_boundary() {
33521 // The 20-byte cap pin — both the boundary-exceeding case and
33522 // the boundary-accepting case in one place, so a future cap
33523 // shift surfaces both arms simultaneously, mirroring the peer
33524 // cap-boundary pins
33525 // (`chart_maintainer_name_shape_rejects_at_129_byte_boundary`
33526 // on the 128-byte sibling,
33527 // `chart_description_shape_rejects_at_513_byte_boundary` on
33528 // the 512-byte sibling). Constructed as a single all-`a`
33529 // token so only the cap arm fires (20 `a` bytes is alphabet-
33530 // valid).
33531 let max_ok = "a".repeat(CHART_KEYWORD_MAX_LEN);
33532 assert_eq!(max_ok.len(), 20);
33533 is_chart_keyword_shape(&max_ok).unwrap();
33534 let too_long = "a".repeat(CHART_KEYWORD_MAX_LEN + 1);
33535 assert_eq!(too_long.len(), 21);
33536 let err = is_chart_keyword_shape(&too_long).unwrap_err();
33537 assert!(err.contains("20"), "got: {err:?}");
33538 assert!(err.contains("21"), "got: {err:?}");
33539 }
33540
33541 // ── shared predicate: find_ascii_whitespace_byte ──────────────────
33542 //
33543 // Pins the accepted / rejected set of the lifted ASCII byte-scan
33544 // every typed-magnitude codec in caixa-core calls (`parse_byte_size`
33545 // / `parse_duration` / `parse_millicores` / shared
33546 // `duration_codec` / `rate_limit_codec`). Peer of the non-ASCII
33547 // `find_non_ascii_whitespace_char` predicate below — together they
33548 // partition the full Unicode `White_Space` axis.
33549
33550 #[test]
33551 fn find_ascii_whitespace_byte_accepts_whitespace_free_strings() {
33552 // Complement-side pin: every whitespace-free canonical form
33553 // the renderers emit returns `None`.
33554 assert!(find_ascii_whitespace_byte("64MiB").is_none());
33555 assert!(find_ascii_whitespace_byte("30s").is_none());
33556 assert!(find_ascii_whitespace_byte("500m").is_none());
33557 assert!(find_ascii_whitespace_byte("100/s").is_none());
33558 assert!(find_ascii_whitespace_byte("").is_none());
33559 assert!(find_ascii_whitespace_byte("abcdef0123-_").is_none());
33560 // Non-whitespace ASCII bytes near the whitespace range stay
33561 // accepted (the predicate must not over-fire on peer control
33562 // bytes like VT `0x0B` which POSIX admits but WhatWG excludes).
33563 assert!(find_ascii_whitespace_byte("\u{0B}64MiB").is_none());
33564 }
33565
33566 #[test]
33567 fn find_ascii_whitespace_byte_flags_space() {
33568 // Space (`0x20`) — the canonical paste-from-shell-history /
33569 // paste-from-aligned-doc drift class.
33570 assert_eq!(find_ascii_whitespace_byte(" 64MiB"), Some(0x20));
33571 assert_eq!(find_ascii_whitespace_byte("30s "), Some(0x20));
33572 assert_eq!(find_ascii_whitespace_byte("100 /s"), Some(0x20));
33573 }
33574
33575 #[test]
33576 fn find_ascii_whitespace_byte_flags_tab_lf_ff_cr() {
33577 // Tab (`0x09`), LF (`0x0A`), FF (`0x0C`), CR (`0x0D`) —
33578 // the remaining four bytes in the WhatWG ASCII whitespace
33579 // set the predicate covers, verbatim.
33580 assert_eq!(find_ascii_whitespace_byte("\t500m"), Some(0x09));
33581 assert_eq!(find_ascii_whitespace_byte("30s\n"), Some(0x0A));
33582 assert_eq!(find_ascii_whitespace_byte("\x0c64MiB"), Some(0x0C));
33583 assert_eq!(find_ascii_whitespace_byte("100/s\r"), Some(0x0D));
33584 }
33585
33586 #[test]
33587 fn find_ascii_whitespace_byte_returns_first_match_byte_order() {
33588 // The predicate returns the *first* offending byte in scan
33589 // order — pinning this so a self-locating codec diagnostic can
33590 // report "position 0" / "position N" verbatim without the
33591 // predicate ever reordering matches.
33592 assert_eq!(find_ascii_whitespace_byte(" \t30s"), Some(0x20));
33593 assert_eq!(find_ascii_whitespace_byte("\t 30s"), Some(0x09));
33594 }
33595
33596 #[test]
33597 fn find_ascii_whitespace_byte_does_not_flag_non_ascii_whitespace() {
33598 // NBSP (`\u{00A0}`), LINE SEPARATOR (`\u{2028}`), IDEOGRAPHIC
33599 // SPACE (`\u{3000}`) — none of their UTF-8 bytes match
33600 // `u8::is_ascii_whitespace` (NBSP's `0xC2 0xA0`, LINE
33601 // SEPARATOR's `0xE2 0x80 0xA8`, IDEOGRAPHIC SPACE's `0xE3
33602 // 0x80 0x80` all sit above `0x7F` or well outside the
33603 // {`0x09`, `0x0A`, `0x0C`, `0x0D`, `0x20`} set). Pinning this
33604 // exclusion so the peer `find_non_ascii_whitespace_char`
33605 // predicate remains strictly complementary — the two together
33606 // partition the full Unicode `White_Space` axis with zero
33607 // overlap.
33608 assert!(find_ascii_whitespace_byte("\u{00A0}64MiB").is_none());
33609 assert!(find_ascii_whitespace_byte("30s\u{2028}").is_none());
33610 assert!(find_ascii_whitespace_byte("64MiB\u{3000}").is_none());
33611 }
33612
33613 // ── shared predicate: find_non_ascii_whitespace_char ──────────────────
33614 //
33615 // Pins the accepted / rejected set of the lifted predicate every
33616 // typed-magnitude codec in caixa-core calls (byte-size / duration /
33617 // shared duration / rate-limit). The predicate's job is exclusively
33618 // to name the strictly-complementary drift class the peer
33619 // `u8::is_ascii_whitespace` byte-scan cannot see — the non-ASCII
33620 // Unicode `White_Space` subset that `str::trim` silently swallows.
33621
33622 #[test]
33623 fn find_non_ascii_whitespace_char_accepts_ascii_only_strings() {
33624 // Complement-side pin: every ASCII-only string (canonical form
33625 // and ASCII whitespace alike) returns `None`. The predicate is
33626 // strictly complementary to the per-codec ASCII byte-scan; it
33627 // must not shadow its coverage.
33628 assert!(find_non_ascii_whitespace_char("64MiB").is_none());
33629 assert!(find_non_ascii_whitespace_char("30s").is_none());
33630 assert!(find_non_ascii_whitespace_char("100/s").is_none());
33631 assert!(find_non_ascii_whitespace_char(" \t\n").is_none());
33632 assert!(find_non_ascii_whitespace_char("").is_none());
33633 // Non-whitespace ASCII byte peers stay accepted too.
33634 assert!(find_non_ascii_whitespace_char("abcdef0123-_").is_none());
33635 }
33636
33637 #[test]
33638 fn find_non_ascii_whitespace_char_flags_nbsp() {
33639 // `\u{00A0}` NBSP — the canonical paste-from-typography /
33640 // paste-from-word-processor drift class.
33641 assert_eq!(
33642 find_non_ascii_whitespace_char("64\u{00A0}MiB"),
33643 Some('\u{00A0}')
33644 );
33645 assert_eq!(find_non_ascii_whitespace_char("\u{00A0}"), Some('\u{00A0}'));
33646 }
33647
33648 #[test]
33649 fn find_non_ascii_whitespace_char_flags_line_and_paragraph_separators() {
33650 // LINE SEPARATOR (`\u{2028}`) / PARAGRAPH SEPARATOR
33651 // (`\u{2029}`) — the paste-from-web-doc drift class every
33652 // RTF/HTML → plain-text conversion emits at soft-wrap
33653 // boundaries.
33654 assert_eq!(
33655 find_non_ascii_whitespace_char("30s\u{2028}"),
33656 Some('\u{2028}')
33657 );
33658 assert_eq!(
33659 find_non_ascii_whitespace_char("30s\u{2029}"),
33660 Some('\u{2029}')
33661 );
33662 }
33663
33664 #[test]
33665 fn find_non_ascii_whitespace_char_flags_ideographic_space() {
33666 // IDEOGRAPHIC SPACE (`\u{3000}`) — the CJK-typography drift
33667 // class every full-width IME auto-widens ASCII space to on
33668 // Japanese / Chinese input methods.
33669 assert_eq!(
33670 find_non_ascii_whitespace_char("64MiB\u{3000}"),
33671 Some('\u{3000}')
33672 );
33673 }
33674
33675 #[test]
33676 fn find_non_ascii_whitespace_char_does_not_flag_zwsp_or_bom() {
33677 // BOM (`\u{FEFF}`, ZERO WIDTH NO-BREAK SPACE) and ZWSP
33678 // (`\u{200B}`, ZERO WIDTH SPACE) — both have
33679 // `char::is_whitespace() == false` per the Unicode
33680 // `White_Space` property, so `str::trim` does *not* strip
33681 // either. Both currently land on the downstream
33682 // `BadByteMagnitude` / `BadDurationMagnitude` arm at parse time
33683 // with the byte-shape diagnostic intact; the render-determinism
33684 // contract is unbroken on those inputs today. This test pins
33685 // the predicate's exclusion so a future widening that starts
33686 // flagging BOM / ZWSP here surfaces as a test failure rather
33687 // than a silent over-fire on a class the downstream arm
33688 // already closes.
33689 assert!(find_non_ascii_whitespace_char("\u{FEFF}64MiB").is_none());
33690 assert!(find_non_ascii_whitespace_char("\u{200B}30s").is_none());
33691 }
33692
33693 // ── shared predicate: is_leading_zero_padded_magnitude ──────────────
33694 //
33695 // Pins the accepted / rejected set of the lifted leading-zero
33696 // predicate every typed-magnitude codec in caixa-core calls
33697 // (`parse_byte_size` / `parse_duration` / `parse_millicores` /
33698 // shared `duration_codec` / `rate_limit_codec`). Same lifted-
33699 // source-of-truth discipline the peer whitespace predicates
33700 // (`find_ascii_whitespace_byte` / `find_non_ascii_whitespace_char`)
33701 // carry — drift between any two codec sites' rejection set becomes
33702 // a single-edit fix at this predicate.
33703
33704 #[test]
33705 fn is_leading_zero_padded_magnitude_accepts_canonical_forms() {
33706 // Complement-side pin: every canonical form the typed-magnitude
33707 // `render_*` canonicalizers emit — the single-byte `"0"` case
33708 // and every non-leading-zero magnitude — returns `false`.
33709 assert!(!is_leading_zero_padded_magnitude("0"));
33710 assert!(!is_leading_zero_padded_magnitude("1"));
33711 assert!(!is_leading_zero_padded_magnitude("64"));
33712 assert!(!is_leading_zero_padded_magnitude("500"));
33713 assert!(!is_leading_zero_padded_magnitude("1024"));
33714 assert!(!is_leading_zero_padded_magnitude("999999"));
33715 // Empty magnitude is not a leading-zero shape either — the
33716 // upstream `digit_only` gate at each codec site refuses empty
33717 // magnitudes on its own arm before this predicate is consulted.
33718 assert!(!is_leading_zero_padded_magnitude(""));
33719 // Non-digit-only bodies are outside the predicate's scope — the
33720 // upstream `digit_only` gate refuses them with its own
33721 // `NonInteger*` / `Bad*` diagnostic; this predicate is invoked
33722 // only after that gate accepts.
33723 assert!(!is_leading_zero_padded_magnitude("a"));
33724 assert!(!is_leading_zero_padded_magnitude("1.5"));
33725 }
33726
33727 #[test]
33728 fn is_leading_zero_padded_magnitude_flags_two_byte_leading_zero() {
33729 // The minimal leading-zero drift shape: two-byte magnitude
33730 // starting with `'0'` — `"00"` / `"01"` / `"09"`. Every one
33731 // round-trips through the peer codecs' `render_*` to the
33732 // leading-zero-stripped form (`"0"` / `"1"` / `"9"`).
33733 assert!(is_leading_zero_padded_magnitude("00"));
33734 assert!(is_leading_zero_padded_magnitude("01"));
33735 assert!(is_leading_zero_padded_magnitude("09"));
33736 }
33737
33738 #[test]
33739 fn is_leading_zero_padded_magnitude_flags_multi_byte_leading_zero() {
33740 // The canonical paste-from-fixed-width-alignment /
33741 // paste-from-columnar-report drift class each codec's
33742 // `render_*` emits the stripped form for: `"0064"` (byte-size
33743 // magnitude), `"030"` (duration magnitude), `"0500"`
33744 // (millicores magnitude), `"0100"` (rate-limit magnitude),
33745 // `"01024"` (multi-digit byte-size magnitude).
33746 assert!(is_leading_zero_padded_magnitude("0064"));
33747 assert!(is_leading_zero_padded_magnitude("030"));
33748 assert!(is_leading_zero_padded_magnitude("0500"));
33749 assert!(is_leading_zero_padded_magnitude("0100"));
33750 assert!(is_leading_zero_padded_magnitude("01024"));
33751 // All-zeros multi-byte magnitude — `"000"` / `"0000"` — every
33752 // one round-trips to `"0"`. The single-byte `"0"` case is the
33753 // canonical zero and stays accepted; the multi-byte all-zero
33754 // shape is leading-zero drift.
33755 assert!(is_leading_zero_padded_magnitude("000"));
33756 assert!(is_leading_zero_padded_magnitude("0000"));
33757 }
33758
33759 #[test]
33760 fn is_leading_zero_padded_magnitude_pins_single_zero_boundary() {
33761 // The single-byte magnitude `"0"` is the canonical zero the
33762 // peer codecs' `render_*` canonicalizers emit for the zero
33763 // value verbatim (`render_byte_size(0)` = `"0"`,
33764 // `render_duration(Duration::ZERO)` = `"0s"` with `"0"` as
33765 // the magnitude, `render_millicores(0)` = `"0m"` with `"0"`
33766 // as the magnitude, `RateLimit::render` for rate=0 = `"0/s"`
33767 // with `"0"` as the magnitude). Pinning this boundary so a
33768 // future widening that starts flagging the single-byte `"0"`
33769 // here surfaces as a test failure rather than a silent break
33770 // of the codec-layer / typed-validate-layer partition — the
33771 // semantic-zero gates at the typed-validate layer above
33772 // (`LimitsError::MemoryZero`, `LimitsError::WallClockZero`,
33773 // `LimitsError::CpuZero`, `SupervisorError::ZeroRestartWindow`,
33774 // `AplicacaoError::PolicyTimeoutZero` /
33775 // `PolicyCircuitBreakerWindowZero` / `PolicyRateLimitZero`)
33776 // are what refuse zero-magnitude authoring, not this codec-
33777 // layer predicate.
33778 assert!(!is_leading_zero_padded_magnitude("0"));
33779 }
33780
33781 // ── shared predicate: is_digit_only_magnitude ───────────────────────
33782 //
33783 // Pins the accepted / rejected set of the lifted digit-only
33784 // predicate every typed-magnitude codec in caixa-core calls
33785 // (`parse_byte_size` / `parse_duration` / `parse_millicores` /
33786 // shared `duration_codec` / `rate_limit_codec`). Same lifted-
33787 // source-of-truth discipline the peer canonical-form predicates
33788 // (`find_ascii_whitespace_byte` / `find_non_ascii_whitespace_char`
33789 // / `is_leading_zero_padded_magnitude`) carry — drift between any
33790 // two codec sites' rejection set becomes a single-edit fix at
33791 // this predicate.
33792
33793 #[test]
33794 fn is_digit_only_magnitude_accepts_canonical_forms() {
33795 // Complement-side pin: every canonical form the typed-magnitude
33796 // `render_*` canonicalizers emit — the single-byte `"0"` case
33797 // and every non-zero non-leading-zero magnitude — returns
33798 // `true`.
33799 assert!(is_digit_only_magnitude("0"));
33800 assert!(is_digit_only_magnitude("1"));
33801 assert!(is_digit_only_magnitude("64"));
33802 assert!(is_digit_only_magnitude("500"));
33803 assert!(is_digit_only_magnitude("1024"));
33804 assert!(is_digit_only_magnitude("999999"));
33805 }
33806
33807 #[test]
33808 fn is_digit_only_magnitude_flags_empty_magnitude() {
33809 // Defense-in-depth: the empty string is non-digit-only per the
33810 // predicate's contract, so a future codec reaching for this
33811 // predicate before landing its own upstream empty-magnitude
33812 // arm still routes empty input to the non-canonical branch
33813 // rather than silently accepting it via the vacuous
33814 // `bytes().all(_)` truth on the empty byte-slice.
33815 assert!(!is_digit_only_magnitude(""));
33816 }
33817
33818 #[test]
33819 fn is_digit_only_magnitude_flags_leading_sign() {
33820 // The paste-from-signed-report drift class every codec's
33821 // `render_*` emits the unsigned form for. On current Rust
33822 // `u64::from_str` / `u32::from_str` permissively accept a
33823 // leading `+` (`"+500"` → 500), so `"+30"`, `"+500"`, `"+100"`
33824 // survive the parser and round-trip through `render_*` to the
33825 // sign-stripped form (`"30"`, `"500"`, `"100"`) — a *different*
33826 // canonical string on the next emit, breaking the THEORY.md
33827 // Part V render-determinism contract. The digit-only gate is
33828 // what closes the leading-sign class at each codec site.
33829 assert!(!is_digit_only_magnitude("+30"));
33830 assert!(!is_digit_only_magnitude("+500"));
33831 assert!(!is_digit_only_magnitude("+100"));
33832 assert!(!is_digit_only_magnitude("-30"));
33833 assert!(!is_digit_only_magnitude("-1"));
33834 }
33835
33836 #[test]
33837 fn is_digit_only_magnitude_flags_fractional_and_decimal() {
33838 // The paste-from-floating-point-source drift class every
33839 // codec's `render_*` emits the integer form for. On the peer
33840 // duration codec the parser accepts `f64`-shaped magnitudes
33841 // (`"1.5s"` → 1500ms → `"1500ms"`, `"1.0s"` → 1s → `"1s"`,
33842 // `"0.5m"` → 30s → `"30s"`) — a *different* canonical string
33843 // on the next emit, breaking the THEORY.md Part V render-
33844 // determinism contract. The digit-only gate closes the
33845 // decimal-point / fractional / exponent class at each codec
33846 // site.
33847 assert!(!is_digit_only_magnitude("1.5"));
33848 assert!(!is_digit_only_magnitude("1.0"));
33849 assert!(!is_digit_only_magnitude("0.5"));
33850 assert!(!is_digit_only_magnitude("1e3"));
33851 assert!(!is_digit_only_magnitude(".5"));
33852 assert!(!is_digit_only_magnitude("5."));
33853 }
33854
33855 #[test]
33856 fn is_digit_only_magnitude_flags_alphabetic_and_symbol_bytes() {
33857 // Complement-side pin on the "garbage" branch: alphabetic
33858 // bytes / symbol bytes / whitespace bytes each land on the
33859 // non-digit-only side. At the codec site the downstream
33860 // "non-canonical-but-numeric vs garbage" partition surfaces
33861 // these with the narrower `Bad*` diagnostic; here the
33862 // predicate simply reports `false`.
33863 assert!(!is_digit_only_magnitude("a"));
33864 assert!(!is_digit_only_magnitude("64a"));
33865 assert!(!is_digit_only_magnitude("6_4"));
33866 assert!(!is_digit_only_magnitude("64 "));
33867 assert!(!is_digit_only_magnitude(" 64"));
33868 }
33869
33870 #[test]
33871 fn is_digit_only_magnitude_pins_leading_zero_boundary() {
33872 // The leading-zero-padded magnitude shape stays inside the
33873 // digit-only accepted set at this predicate — every byte is
33874 // an ASCII digit. The peer
33875 // [`is_leading_zero_padded_magnitude`] predicate closes the
33876 // leading-zero drift class on a separate, strictly-later arm
33877 // at each codec site. Pinning this partition so a future
33878 // widening that collapses the two arms surfaces as a test
33879 // failure rather than a silent break of the two-predicate
33880 // codec-layer discipline.
33881 assert!(is_digit_only_magnitude("00"));
33882 assert!(is_digit_only_magnitude("0064"));
33883 assert!(is_digit_only_magnitude("0500"));
33884 }
33885
33886 // ── require_positive_bounded_{u32,u64} ──────────────────────────────
33887
33888 #[derive(Debug, PartialEq, Eq)]
33889 enum TestErr {
33890 Zero,
33891 Cap(u64),
33892 }
33893
33894 #[test]
33895 fn require_positive_bounded_u32_accepts_in_range() {
33896 assert_eq!(
33897 require_positive_bounded_u32::<TestErr>(
33898 1,
33899 10,
33900 || TestErr::Zero,
33901 |v| TestErr::Cap(u64::from(v))
33902 ),
33903 Ok(())
33904 );
33905 assert_eq!(
33906 require_positive_bounded_u32::<TestErr>(
33907 10,
33908 10,
33909 || TestErr::Zero,
33910 |v| TestErr::Cap(u64::from(v))
33911 ),
33912 Ok(())
33913 );
33914 assert_eq!(
33915 require_positive_bounded_u32::<TestErr>(
33916 5,
33917 10,
33918 || TestErr::Zero,
33919 |v| TestErr::Cap(u64::from(v))
33920 ),
33921 Ok(())
33922 );
33923 }
33924
33925 #[test]
33926 fn require_positive_bounded_u32_rejects_zero_with_self_locating_diagnostic() {
33927 // The zero-floor arm strictly precedes the cap arm — a value of
33928 // 0 surfaces the `on_zero` callback's discriminator (which every
33929 // per-axis error variant documents an omit-axis remediation for),
33930 // never the `on_cap_exceeded` callback (which would misframe
33931 // "0 > cap == false" as an above-cap value).
33932 assert_eq!(
33933 require_positive_bounded_u32::<TestErr>(
33934 0,
33935 10,
33936 || TestErr::Zero,
33937 |v| TestErr::Cap(u64::from(v))
33938 ),
33939 Err(TestErr::Zero)
33940 );
33941 // Pin the ordering under the degenerate cap == 0 boundary: even
33942 // when the cap itself is 0 (never valid for a positive-bounded
33943 // axis in production, but pins the ordering contract), 0 routes
33944 // through the zero arm — not the cap arm.
33945 assert_eq!(
33946 require_positive_bounded_u32::<TestErr>(
33947 0,
33948 0,
33949 || TestErr::Zero,
33950 |v| TestErr::Cap(u64::from(v))
33951 ),
33952 Err(TestErr::Zero)
33953 );
33954 }
33955
33956 #[test]
33957 fn require_positive_bounded_u32_rejects_above_cap_with_value_threaded() {
33958 assert_eq!(
33959 require_positive_bounded_u32::<TestErr>(
33960 11,
33961 10,
33962 || TestErr::Zero,
33963 |v| TestErr::Cap(u64::from(v))
33964 ),
33965 Err(TestErr::Cap(11))
33966 );
33967 assert_eq!(
33968 require_positive_bounded_u32::<TestErr>(
33969 u32::MAX,
33970 10,
33971 || TestErr::Zero,
33972 |v| TestErr::Cap(u64::from(v))
33973 ),
33974 Err(TestErr::Cap(u64::from(u32::MAX)))
33975 );
33976 }
33977
33978 #[test]
33979 fn require_positive_bounded_u64_accepts_in_range() {
33980 assert_eq!(
33981 require_positive_bounded_u64::<TestErr>(1, 10, || TestErr::Zero, TestErr::Cap),
33982 Ok(())
33983 );
33984 assert_eq!(
33985 require_positive_bounded_u64::<TestErr>(10, 10, || TestErr::Zero, TestErr::Cap),
33986 Ok(())
33987 );
33988 }
33989
33990 #[test]
33991 fn require_positive_bounded_u64_rejects_zero_and_above_cap() {
33992 assert_eq!(
33993 require_positive_bounded_u64::<TestErr>(0, 10, || TestErr::Zero, TestErr::Cap),
33994 Err(TestErr::Zero)
33995 );
33996 assert_eq!(
33997 require_positive_bounded_u64::<TestErr>(11, 10, || TestErr::Zero, TestErr::Cap),
33998 Err(TestErr::Cap(11))
33999 );
34000 assert_eq!(
34001 require_positive_bounded_u64::<TestErr>(u64::MAX, 10, || TestErr::Zero, TestErr::Cap),
34002 Err(TestErr::Cap(u64::MAX))
34003 );
34004 }
34005
34006 // ── require_positive_quantum_multiple_bounded_u64 ────────────────────
34007
34008 #[derive(Debug, PartialEq, Eq)]
34009 enum QuantumTestErr {
34010 Zero,
34011 BelowQuantum(u64),
34012 Cap(u64),
34013 NotMultiple(u64),
34014 }
34015
34016 fn q_gate(value: u64, quantum: u64, cap: u64) -> Result<(), QuantumTestErr> {
34017 require_positive_quantum_multiple_bounded_u64(
34018 value,
34019 quantum,
34020 cap,
34021 || QuantumTestErr::Zero,
34022 QuantumTestErr::BelowQuantum,
34023 QuantumTestErr::Cap,
34024 QuantumTestErr::NotMultiple,
34025 )
34026 }
34027
34028 #[test]
34029 fn require_positive_quantum_multiple_bounded_u64_accepts_in_range_multiples() {
34030 // Every canonical quantum-multiple in `quantum..=cap` — the shared
34031 // accepted set every quantized-byte-cap consumer inherits — must
34032 // pass the gate. Pin the accepted set here so a future tightening
34033 // surfaces as a test failure rather than a silent narrowing at
34034 // the single consumer site (`:limits :memory`).
34035 let quantum = 64 * 1024;
34036 let cap = 4 * 1024 * 1024 * 1024;
34037 for value in [quantum, quantum * 2, quantum * 100, quantum * 1000, cap] {
34038 assert_eq!(
34039 q_gate(value, quantum, cap),
34040 Ok(()),
34041 "quantum-multiple in-range value {value} must pass the gate",
34042 );
34043 }
34044 }
34045
34046 #[test]
34047 fn require_positive_quantum_multiple_bounded_u64_rejects_zero_before_other_arms() {
34048 // The zero-floor arm strictly precedes the below-quantum, cap,
34049 // and not-multiple arms — a value of 0 surfaces the
34050 // caller's self-locating `on_zero` diagnostic (every per-axis
34051 // error variant documents an "omit the axis to express no-bound"
34052 // remediation for) rather than the misleading below-quantum arm
34053 // (which would also fire because 0 < quantum) or the not-multiple
34054 // arm (which the modulus check `0 % quantum == 0` would silently
34055 // accept).
34056 let quantum = 64 * 1024;
34057 let cap = 4 * 1024 * 1024 * 1024;
34058 assert_eq!(q_gate(0, quantum, cap), Err(QuantumTestErr::Zero));
34059 // The degenerate `cap == 0` / `quantum == 1` boundaries: 0 still
34060 // routes through the zero arm — the ordering contract holds even
34061 // when the cap or quantum themselves take the degenerate shape
34062 // (never valid production shapes for a positive-bounded quantized
34063 // axis, but pin the arm ordering).
34064 assert_eq!(q_gate(0, 1, 0), Err(QuantumTestErr::Zero));
34065 assert_eq!(q_gate(0, quantum, 0), Err(QuantumTestErr::Zero));
34066 }
34067
34068 #[test]
34069 fn require_positive_quantum_multiple_bounded_u64_rejects_below_quantum_before_cap_and_multiple()
34070 {
34071 // The below-quantum arm strictly precedes the cap and
34072 // not-multiple arms — a sub-quantum non-zero value (which is
34073 // ALSO not a quantum-multiple by construction, since the
34074 // smallest positive quantum-multiple *is* `quantum`) surfaces
34075 // the more actionable "raise to at least one quantum" diagnostic
34076 // rather than the not-multiple no-op. Pin the ordering across
34077 // the value grid — every value in `1..quantum` must fire the
34078 // below-quantum arm with the offending byte count threaded
34079 // through the callback.
34080 let quantum = 64 * 1024;
34081 let cap = 4 * 1024 * 1024 * 1024;
34082 for value in [1u64, 2, 32 * 1024, quantum - 1] {
34083 assert_eq!(
34084 q_gate(value, quantum, cap),
34085 Err(QuantumTestErr::BelowQuantum(value)),
34086 "sub-quantum {value} must surface BelowQuantum before Cap / NotMultiple",
34087 );
34088 }
34089 }
34090
34091 #[test]
34092 fn require_positive_quantum_multiple_bounded_u64_rejects_above_cap_before_not_multiple() {
34093 // The cap arm strictly precedes the not-multiple arm — a value
34094 // that is *both* above-cap and sub-quantum-residue must surface
34095 // the more aggressive cap-shape diagnostic first (the
34096 // not-multiple remediation would be misleading when the
34097 // offending value exceeds the upper bracket anyway; the
34098 // canonical fix collapses both into "pin a quantum-aligned
34099 // value ≤ cap"). Pin the ordering across the value grid,
34100 // including the boundary case `cap + 1`.
34101 let quantum = 64 * 1024;
34102 let cap = 4 * 1024 * 1024 * 1024;
34103 for value in [
34104 cap + 1, // above-cap AND sub-quantum-residue
34105 cap + quantum, // above-cap and quantum-aligned
34106 cap + quantum * 100, // well above-cap and quantum-aligned
34107 u64::MAX, // maximally above-cap
34108 ] {
34109 assert_eq!(
34110 q_gate(value, quantum, cap),
34111 Err(QuantumTestErr::Cap(value)),
34112 "above-cap {value} must surface Cap before NotMultiple",
34113 );
34114 }
34115 }
34116
34117 #[test]
34118 fn require_positive_quantum_multiple_bounded_u64_rejects_not_multiple_with_value_threaded() {
34119 // The not-multiple arm surfaces the offending value verbatim so
34120 // the caller's `on_not_quantum_multiple` variant threads it into
34121 // its discriminator field (`bytes:`). Pin the arm across the
34122 // in-range-but-not-aligned value grid — every value in
34123 // `quantum..=cap` carrying a sub-quantum residue must fire the
34124 // not-multiple arm.
34125 let quantum = 64 * 1024;
34126 let cap = 4 * 1024 * 1024 * 1024;
34127 for value in [
34128 quantum + 1, // one page plus a 1-byte residue
34129 quantum * 2 - 1, // two pages minus one byte
34130 100_000, // ≈ 97.65 KiB — one page + 34_464-byte residue
34131 quantum * 100 + 7, // 100 pages plus a 7-byte residue
34132 ] {
34133 assert_eq!(
34134 q_gate(value, quantum, cap),
34135 Err(QuantumTestErr::NotMultiple(value)),
34136 "sub-quantum-residue {value} must surface NotMultiple",
34137 );
34138 }
34139 }
34140
34141 // ── require_positive_canonical_bounded_duration ─────────────────────
34142
34143 #[derive(Debug, PartialEq, Eq)]
34144 enum DurationTestErr {
34145 Zero,
34146 NotCanonical(Duration),
34147 Cap(Duration),
34148 }
34149
34150 #[test]
34151 fn require_positive_canonical_bounded_duration_accepts_in_range_canonical_values() {
34152 // Every canonical integer-millisecond `Duration` in
34153 // `1ms..=cap` — the shared accepted set every typed-`Duration`
34154 // consumer inherits — must pass the gate. Pin the canonical
34155 // set here so a future tightening surfaces as a test failure
34156 // rather than a silent narrowing at one of the four consumer
34157 // sites (`:politicas :timeout`, `:circuit-breaker :window`,
34158 // `:limits :wall-clock`, `:supervisor :restart-window`).
34159 let cap = Duration::from_secs(3600); // matches the 1h peer caps
34160 for value in [
34161 Duration::from_millis(1),
34162 Duration::from_millis(500),
34163 Duration::from_millis(1500),
34164 Duration::from_secs(30),
34165 Duration::from_secs(60),
34166 cap,
34167 ] {
34168 assert_eq!(
34169 require_positive_canonical_bounded_duration::<DurationTestErr>(
34170 value,
34171 cap,
34172 || DurationTestErr::Zero,
34173 DurationTestErr::NotCanonical,
34174 DurationTestErr::Cap,
34175 ),
34176 Ok(()),
34177 "canonical in-range value {value:?} must pass the gate",
34178 );
34179 }
34180 }
34181
34182 #[test]
34183 fn require_positive_canonical_bounded_duration_rejects_zero_before_canonical_and_cap() {
34184 // The zero-floor arm strictly precedes the canonical-form and
34185 // cap arms — `Duration::ZERO` (which has `subsec_nanos() == 0`
34186 // and would pass the canonical-form predicate; and would pass
34187 // the cap arm since 0 ≤ cap) routes through the zero arm so
34188 // the caller's self-locating `on_zero` diagnostic (every
34189 // per-axis error variant documents an omit-axis remediation
34190 // for) is surfaced, not the misleading no-op the two later
34191 // arms would return.
34192 let cap = Duration::from_secs(3600);
34193 assert_eq!(
34194 require_positive_canonical_bounded_duration::<DurationTestErr>(
34195 Duration::ZERO,
34196 cap,
34197 || DurationTestErr::Zero,
34198 DurationTestErr::NotCanonical,
34199 DurationTestErr::Cap,
34200 ),
34201 Err(DurationTestErr::Zero),
34202 );
34203 // The degenerate `cap == Duration::ZERO` boundary: `Duration::ZERO`
34204 // still routes through the zero arm — the ordering contract holds
34205 // even when the cap itself is zero (never a valid production cap
34206 // for a positive-bounded axis, but pins the arm ordering).
34207 assert_eq!(
34208 require_positive_canonical_bounded_duration::<DurationTestErr>(
34209 Duration::ZERO,
34210 Duration::ZERO,
34211 || DurationTestErr::Zero,
34212 DurationTestErr::NotCanonical,
34213 DurationTestErr::Cap,
34214 ),
34215 Err(DurationTestErr::Zero),
34216 );
34217 }
34218
34219 #[test]
34220 fn require_positive_canonical_bounded_duration_rejects_sub_millisecond_before_cap() {
34221 // The canonical-form arm strictly precedes the cap arm — a
34222 // `Duration` that is *both* sub-millisecond and above-cap must
34223 // surface the more fundamental round-trip-shape diagnostic
34224 // first (the cap arm's `1ms..=<cap>` remediation prose would
34225 // be misleading when no integer-ms form of the offending
34226 // value exists). Pin the ordering across the value grid.
34227 let cap = Duration::from_secs(1);
34228 for value in [
34229 Duration::from_micros(1),
34230 Duration::from_micros(500),
34231 Duration::from_micros(1500),
34232 Duration::from_nanos(1),
34233 Duration::from_nanos(999_999),
34234 Duration::from_nanos(1_000_001),
34235 // Sub-millisecond *and* above-cap: canonical-form arm wins.
34236 cap + Duration::from_nanos(1),
34237 ] {
34238 let result = require_positive_canonical_bounded_duration::<DurationTestErr>(
34239 value,
34240 cap,
34241 || DurationTestErr::Zero,
34242 DurationTestErr::NotCanonical,
34243 DurationTestErr::Cap,
34244 );
34245 assert_eq!(
34246 result,
34247 Err(DurationTestErr::NotCanonical(value)),
34248 "sub-millisecond {value:?} must surface NotCanonical before Cap",
34249 );
34250 }
34251 }
34252
34253 #[test]
34254 fn require_positive_canonical_bounded_duration_rejects_above_cap_with_value_threaded() {
34255 // The cap arm surfaces the offending value verbatim so the
34256 // caller's `on_cap_exceeded` variant threads it into its
34257 // discriminator field (`timeout` / `window` / `wall_clock`).
34258 // The value grid covers the canonical `<n>ms` / `<n>s`
34259 // integer-millisecond shape past the 1h cap so the arm ordering
34260 // (canonical-form first) doesn't intercept these values.
34261 let cap = Duration::from_secs(3600);
34262 for value in [
34263 cap + Duration::from_millis(1),
34264 cap + Duration::from_secs(1),
34265 Duration::from_secs(24 * 3600), // 24h — canonical string
34266 Duration::from_secs(7 * 24 * 3600), // 7d
34267 ] {
34268 assert_eq!(
34269 require_positive_canonical_bounded_duration::<DurationTestErr>(
34270 value,
34271 cap,
34272 || DurationTestErr::Zero,
34273 DurationTestErr::NotCanonical,
34274 DurationTestErr::Cap,
34275 ),
34276 Err(DurationTestErr::Cap(value)),
34277 "above-cap canonical value {value:?} must thread through the cap arm",
34278 );
34279 }
34280 }
34281
34282 // ── require_valid_versao_requirement ────────────────────────────────
34283
34284 #[derive(Debug, PartialEq, Eq)]
34285 enum VersaoTestErr {
34286 Empty,
34287 Invalid(String),
34288 }
34289
34290 #[test]
34291 fn require_valid_versao_requirement_accepts_canonical_forms() {
34292 // Every Cargo-shaped requirement string the substrate accepts on
34293 // any `:versao` axis (`:deps`, `:membros`, `:children`) must pass
34294 // the shared gate — pin the canonical set here so a future
34295 // tightening surfaces as a test failure rather than a silent
34296 // narrowing at one of the three consumer sites. Same accepted set
34297 // as `accepts_canonical_membro_versao_forms` /
34298 // `accepts_canonical_dep_versao_forms` on the sibling per-axis
34299 // pins.
34300 for form in [
34301 "^0.1", // caret — minor-range pin (the most common shape)
34302 "~0.1.2", // tilde — patch-range pin
34303 "0.1.0", // exact — single-version pin
34304 "*", // wildcard — explicitly any-version (VersionReq::STAR)
34305 ">=0.1, <2", // multi-range — comma-separated comparators
34306 ] {
34307 assert_eq!(
34308 require_valid_versao_requirement::<VersaoTestErr>(
34309 form,
34310 || VersaoTestErr::Empty,
34311 VersaoTestErr::Invalid,
34312 ),
34313 Ok(()),
34314 "canonical form {form:?} must pass the gate",
34315 );
34316 }
34317 }
34318
34319 #[test]
34320 fn require_valid_versao_requirement_rejects_empty_before_parse() {
34321 // The empty-first arm strictly precedes the parse arm. Without
34322 // this arm the parser silently widens `""` to
34323 // `VersionReq { comparators: [] }` (semantically `*`) — a
34324 // "silent widening" footgun the three consumer sites each
34325 // documented in their `MembroVersaoEmpty` / `EmptyChildVersion` /
34326 // `VersaoEmpty` variants and now inherit by construction.
34327 assert_eq!(
34328 require_valid_versao_requirement::<VersaoTestErr>(
34329 "",
34330 || VersaoTestErr::Empty,
34331 VersaoTestErr::Invalid,
34332 ),
34333 Err(VersaoTestErr::Empty),
34334 );
34335 }
34336
34337 #[test]
34338 fn require_valid_versao_requirement_rejects_malformed_with_reason_threaded() {
34339 // The canonical malformed-shape set the three consumer sites
34340 // formerly each re-tested inline. The gate threads the
34341 // parser's `to_string()` output through as the invalid arm's
34342 // `reason:` verbatim — the field the three sibling error
34343 // variants (`{Dep,Membro,Child}VersaoInvalid.reason`) each
34344 // carry to the author's remediation prose.
34345 for bad in [
34346 "^^0.1", // doubled-caret typo
34347 "v0.1", // git-tag-shape leaking into requirement slot
34348 "abc", // gibberish
34349 "~~", // stacked-operator gibberish
34350 ] {
34351 let result = require_valid_versao_requirement::<VersaoTestErr>(
34352 bad,
34353 || VersaoTestErr::Empty,
34354 VersaoTestErr::Invalid,
34355 );
34356 match result {
34357 Err(VersaoTestErr::Invalid(reason)) => {
34358 assert!(
34359 !reason.is_empty(),
34360 "invalid arm must thread a non-empty reason for {bad:?}",
34361 );
34362 }
34363 other => panic!("expected Invalid for {bad:?}, got {other:?}"),
34364 }
34365 }
34366 }
34367
34368 // ── require_valid_dns_1123_label ────────────────────────────────────
34369
34370 #[derive(Debug, PartialEq, Eq)]
34371 enum LabelTestErr {
34372 Empty,
34373 Invalid(String),
34374 }
34375
34376 #[test]
34377 fn require_valid_dns_1123_label_accepts_canonical_forms() {
34378 // Every DNS-1123-label-shaped Servico-name reference the substrate
34379 // accepts on any name axis (`:membros :caixa`, `:placement :clusters`,
34380 // `:placement :affinity`, `:contratos :de`/`:para`, `:entrada :para`,
34381 // `:children :caixa`, `:nome`, `:upgrade-from :module`) must pass
34382 // the shared gate — pin the canonical set here so a future
34383 // tightening surfaces as a test failure rather than a silent
34384 // narrowing at one of the eight consumer sites. Same accepted set
34385 // as the sibling per-axis DNS-1123-label pins already carry.
34386 for form in [
34387 "hello-rio", // canonical dashed
34388 "cart", // single-token
34389 "rio-1", // trailing digit
34390 "1-rio", // leading digit
34391 "a", // one byte
34392 &"a".repeat(DNS_1123_LABEL_MAX_LEN), // max length exact
34393 ] {
34394 assert_eq!(
34395 require_valid_dns_1123_label::<LabelTestErr>(
34396 form,
34397 || LabelTestErr::Empty,
34398 LabelTestErr::Invalid,
34399 ),
34400 Ok(()),
34401 "canonical form {form:?} must pass the gate",
34402 );
34403 }
34404 }
34405
34406 #[test]
34407 fn require_valid_dns_1123_label_rejects_empty_before_shape() {
34408 // The empty-first arm strictly precedes the shape arm so a
34409 // literal `""` surfaces each per-axis error variant's narrower
34410 // self-locating `_Empty` diagnostic rather than the shared
34411 // predicate's generic "must not be empty" prose the shape arm
34412 // would thread through — the same "misframed generic diagnostic"
34413 // footgun the peer [`require_valid_versao_requirement`] closes
34414 // on its empty arm. The eight consumer sites each documented
34415 // this ordering in their `MembroCaixaEmpty` / `PlacementClusterEmpty`
34416 // / `PlacementAffinityEmpty` / `ContratoCaixaEmpty` /
34417 // `EntradaParaEmpty` / `NomeEmpty` / `EmptyChildName` /
34418 // `ModuleEmpty` variants and now inherit it by construction.
34419 assert_eq!(
34420 require_valid_dns_1123_label::<LabelTestErr>(
34421 "",
34422 || LabelTestErr::Empty,
34423 LabelTestErr::Invalid,
34424 ),
34425 Err(LabelTestErr::Empty),
34426 );
34427 }
34428
34429 #[test]
34430 fn require_valid_dns_1123_label_rejects_malformed_with_reason_threaded() {
34431 // The canonical malformed-shape set the eight consumer sites
34432 // formerly each re-tested inline. The gate threads the
34433 // predicate's shape-shaped reason through as the invalid arm's
34434 // `reason:` verbatim — the field every sibling error variant
34435 // (`{MembroCaixa,PlacementCluster,PlacementAffinity,ContratoCaixa,
34436 // EntradaPara,Nome,ChildCaixa,Module}Invalid.reason`) each
34437 // carry to the author's remediation prose.
34438 for bad in [
34439 "Rio", // uppercase — the canonical TitleCase-from-an-ADR typo
34440 "my_cart", // underscore — the Python-module-name leak
34441 "team.cart", // dot — the namespace-dot-on-a-label confusion
34442 "-cart", // leading hyphen — boundary violation
34443 "cart-", // trailing hyphen — boundary violation
34444 ] {
34445 let result = require_valid_dns_1123_label::<LabelTestErr>(
34446 bad,
34447 || LabelTestErr::Empty,
34448 LabelTestErr::Invalid,
34449 );
34450 match result {
34451 Err(LabelTestErr::Invalid(reason)) => {
34452 assert!(
34453 !reason.is_empty(),
34454 "invalid arm must thread a non-empty reason for {bad:?}",
34455 );
34456 }
34457 other => panic!("expected Invalid for {bad:?}, got {other:?}"),
34458 }
34459 }
34460 }
34461
34462 // ── require_sandboxed_lisp_path ─────────────────────────────────────
34463
34464 #[derive(Debug, PartialEq, Eq)]
34465 enum LispPathTestErr {
34466 Empty,
34467 Absolute,
34468 ParentEscape,
34469 NonLisp,
34470 }
34471
34472 fn call_require_sandboxed_lisp_path(path: &Path) -> Result<(), LispPathTestErr> {
34473 require_sandboxed_lisp_path(
34474 path,
34475 || LispPathTestErr::Empty,
34476 || LispPathTestErr::Absolute,
34477 || LispPathTestErr::ParentEscape,
34478 || LispPathTestErr::NonLisp,
34479 )
34480 }
34481
34482 #[test]
34483 fn require_sandboxed_lisp_path_accepts_canonical_forms() {
34484 // Every sandboxed-relative `.lisp`-terminating path the substrate
34485 // accepts on either M2 tatara-lisp source-path axis (`:behavior :on-*`
34486 // callback paths, `:upgrade-from :state-change :script`) must pass
34487 // the shared gate. Pin the canonical set here so a future tightening
34488 // surfaces as a test failure rather than a silent narrowing at one
34489 // of the two consumer sites.
34490 for form in [
34491 "lib/init.lisp", // canonical example
34492 "lib/handlers.lisp", // multi-callback shape
34493 "lib/migrations/v01-to-v02.lisp", // nested-directory shape
34494 "a.lisp", // one-byte stem
34495 "lib/deep/nested/path/to/file.lisp", // deeply nested
34496 ] {
34497 assert_eq!(
34498 call_require_sandboxed_lisp_path(Path::new(form)),
34499 Ok(()),
34500 "canonical sandboxed `.lisp` form {form:?} must pass the gate",
34501 );
34502 }
34503 }
34504
34505 #[test]
34506 fn require_sandboxed_lisp_path_rejects_empty_before_all_later_arms() {
34507 // The empty-first arm strictly precedes every downstream arm — a
34508 // literal `""` (which the is_absolute check would return false on,
34509 // which carries no ParentDir component, and whose extension is
34510 // absent) routes through the `on_empty` closure so the caller's
34511 // narrower self-locating `_Empty` / `_EmptyScript` diagnostic fires,
34512 // not a misleading `_Absolute` / `_ParentEscape` / `_NonLisp` miss
34513 // downstream. Peer of every zero-first arm ordering the sibling
34514 // require_positive_bounded_* helpers already carry.
34515 assert_eq!(
34516 call_require_sandboxed_lisp_path(Path::new("")),
34517 Err(LispPathTestErr::Empty),
34518 );
34519 }
34520
34521 #[test]
34522 fn require_sandboxed_lisp_path_rejects_absolute_before_parent_escape_and_non_lisp() {
34523 // The absolute arm strictly precedes the parent-escape and
34524 // non-`.lisp`-extension arms — an absolute path (regardless of
34525 // whether it also carries `..` components or a non-`.lisp`
34526 // extension) routes through the `on_absolute` closure so the
34527 // caller's `_Absolute` / `_AbsoluteScript` diagnostic fires with
34528 // its "must be relative to the caixa root" remediation, not the
34529 // misleading later arms. Pin the ordering across the value grid
34530 // covering "absolute + parent-escape" and "absolute + non-`.lisp`"
34531 // compound-violation shapes so a future arm-reorder silently
34532 // narrowing the accepted set would surface at build time.
34533 for absolute in [
34534 "/etc/passwd", // canonical absolute
34535 "/lib/init.lisp", // absolute + `.lisp` (extension arm never reached)
34536 "/lib/../init.lisp", // absolute + parent-escape (later arm never reached)
34537 "/etc/init.txt", // absolute + non-`.lisp`
34538 ] {
34539 assert_eq!(
34540 call_require_sandboxed_lisp_path(Path::new(absolute)),
34541 Err(LispPathTestErr::Absolute),
34542 "absolute path {absolute:?} must route through Absolute arm",
34543 );
34544 }
34545 }
34546
34547 #[test]
34548 fn require_sandboxed_lisp_path_rejects_parent_escape_before_non_lisp() {
34549 // The parent-escape arm strictly precedes the non-`.lisp`-extension
34550 // arm — a relative path carrying any `..` component routes through
34551 // the `on_parent_escape` closure so the caller's `_ParentEscape` /
34552 // `_ParentEscapeScript` diagnostic fires with its "must not
34553 // traverse above the caixa root" remediation, not the misleading
34554 // extension-shape arm. Pin the ordering across leading / mid-path
34555 // / trailing parent-escape positions plus the compound
34556 // "parent-escape + non-`.lisp`" shape.
34557 for escape in [
34558 "../sibling/x.lisp", // leading `..`
34559 "lib/../other.lisp", // mid-path `..`
34560 "lib/handlers/../..", // trailing `..`
34561 "../sibling/x.txt", // parent-escape + non-`.lisp`
34562 ] {
34563 assert_eq!(
34564 call_require_sandboxed_lisp_path(Path::new(escape)),
34565 Err(LispPathTestErr::ParentEscape),
34566 "parent-escaping path {escape:?} must route through ParentEscape arm",
34567 );
34568 }
34569 }
34570
34571 #[test]
34572 fn require_sandboxed_lisp_path_rejects_non_lisp_only_after_all_path_shape_arms_accept() {
34573 // The non-`.lisp`-extension arm fires only when every prior arm
34574 // (empty / absolute / parent-escape) accepts the path — a
34575 // sandboxed relative path whose only violation is a non-`.lisp`
34576 // terminating extension routes through the `on_non_lisp` closure
34577 // so the caller's `_NonLispExtension` / `_NonLispExtensionScript`
34578 // diagnostic fires with its `.lisp`-remediation prose. Pin the
34579 // downstream-most-arm reachability across the canonical
34580 // `.txt`/`.rs`/no-extension/double-extension-shadow shape set the
34581 // two consumer sites' error variants each document.
34582 for bad_ext in [
34583 "lib/init.txt", // wrong extension
34584 "lib/init.rs", // Rust source leaked into caixa
34585 "lib/init.lisp.bak", // double-extension shadow
34586 "lib/init", // no extension
34587 "lib/migrations", // no extension, no dot
34588 "lib/init.LISP", // uppercase — case-sensitive gate
34589 ] {
34590 assert_eq!(
34591 call_require_sandboxed_lisp_path(Path::new(bad_ext)),
34592 Err(LispPathTestErr::NonLisp),
34593 "non-`.lisp` path {bad_ext:?} must route through NonLisp arm",
34594 );
34595 }
34596 }
34597
34598 #[test]
34599 fn require_sandboxed_lisp_path_ordering_matches_inline_pre_lift_cascade() {
34600 // Byte-for-byte the same `Empty → Absolute → ParentEscape → NonLisp`
34601 // arm-ordering the two consumer sites (`validate_callback_path` in
34602 // `caixa-core::behavior`, `UpgradeInstruction::validate`'s
34603 // `StateChange` arm in `caixa-core::upgrade`) each formerly inlined
34604 // verbatim. This pin catches any future reorder that would
34605 // silently reshape the diagnostic dispatch at either site — the
34606 // helper's ordering IS the two sites' ordering, not a re-derived
34607 // convention. Pins the same
34608 // smallest-scope-arm-fires-last three-path drift-detection
34609 // posture the peer `require_positive_bounded_*` /
34610 // `require_positive_canonical_bounded_duration` helpers already
34611 // carry on their own arm sets.
34612 assert_eq!(
34613 call_require_sandboxed_lisp_path(Path::new("")),
34614 Err(LispPathTestErr::Empty),
34615 );
34616 assert_eq!(
34617 call_require_sandboxed_lisp_path(Path::new("/abs/x.lisp")),
34618 Err(LispPathTestErr::Absolute),
34619 );
34620 assert_eq!(
34621 call_require_sandboxed_lisp_path(Path::new("../x.lisp")),
34622 Err(LispPathTestErr::ParentEscape),
34623 );
34624 assert_eq!(
34625 call_require_sandboxed_lisp_path(Path::new("lib/x.txt")),
34626 Err(LispPathTestErr::NonLisp),
34627 );
34628 assert_eq!(
34629 call_require_sandboxed_lisp_path(Path::new("lib/x.lisp")),
34630 Ok(()),
34631 );
34632 }
34633
34634 #[test]
34635 fn gateway_api_hostname_max_len_pins_canonical_value() {
34636 // Pin the actual byte count so a typo in this lift can't silently
34637 // rebrand the K8s Gateway API v1 `Listener.hostname` /
34638 // `HTTPRoute.spec.hostnames[]` admission-schema `maxLength:` cap
34639 // the `AplicacaoSpec::validate` `:entrada :host` total-length arm
34640 // reads. The value is part of the cluster-side contract with
34641 // every Gateway API v1 CRD schema validator (apiserver-side +
34642 // Cilium / Envoy Gateway / Istio / NGINX per-implementation
34643 // webhooks) — the OpenAPI schema on the Hostname type binds
34644 // `maxLength: 253` verbatim (RFC 1035 / RFC 1123 DNS name limit:
34645 // 255 wire bytes minus the trailing-dot + one length prefix), so
34646 // a drifted value at either the aplicacao-side validator or a
34647 // downstream renderer's per-host validator silently emits a
34648 // Gateway / HTTPRoute the apiserver rejects at admission time
34649 // with an opaque `field is invalid` diagnostic far from the
34650 // caixa.lisp source line. Changing this value is a coordinated
34651 // Gateway API promotion alongside the upstream SIG-Network
34652 // Hostname schema evolution, not an incidental edit. Peer to
34653 // [`GATEWAY_API_HTTP_PATH_MAX_LEN`] (1024) on the sibling
34654 // per-route path-value cap axis — both are apiserver-side
34655 // `maxLength:` bounds on Gateway API v1 landing sites, both lift
34656 // to `caixa-core::render` so the M4 CR materializer's per-axis
34657 // validators (per-host, per-path) read from one place.
34658 assert_eq!(GATEWAY_API_HOSTNAME_MAX_LEN, 253);
34659 }
34660
34661 #[test]
34662 fn gateway_api_hostname_max_len_exceeds_dns_1123_label_max_len() {
34663 // Cross-axis structural invariant: every `.`-separated label in
34664 // a Gateway API v1 Hostname is a DNS-1123 label, so the total
34665 // Hostname cap must strictly exceed the per-label cap — otherwise
34666 // even a single-label host `"foo"` couldn't reach the per-label
34667 // ceiling before hitting the total-length ceiling, and the
34668 // `AplicacaoSpec::validate` `:entrada :host` per-label arm at
34669 // `validate_entrada_host` would be structurally unreachable via
34670 // the total-length arm's own ordering. Pinning the ordering here
34671 // means a future substrate-side tightening of either bound (a
34672 // K8s SIG-Network Hostname promotion narrowing the total cap, a
34673 // DNS-1123 label promotion widening the per-label cap) that
34674 // inverted the two would fail this pin at build time rather than
34675 // silently rendering the per-label arm unreachable.
34676 assert!(
34677 GATEWAY_API_HOSTNAME_MAX_LEN > DNS_1123_LABEL_MAX_LEN,
34678 "GATEWAY_API_HOSTNAME_MAX_LEN ({GATEWAY_API_HOSTNAME_MAX_LEN}) must strictly \
34679 exceed DNS_1123_LABEL_MAX_LEN ({DNS_1123_LABEL_MAX_LEN}) — every \
34680 `.`-separated label in a Gateway API v1 Hostname is itself a DNS-1123 \
34681 label under the apiserver's OpenAPI regex, so the total-length cap \
34682 must be able to accommodate at least one per-label-max label",
34683 );
34684 }
34685
34686 #[test]
34687 fn gateway_api_hostname_max_len_matches_rfc_1035_dns_name_limit() {
34688 // Cross-axis structural invariant: the Gateway API v1 Hostname
34689 // `maxLength: 253` cap is the RFC 1035 / RFC 1123 DNS name limit
34690 // — 255 wire bytes minus one length prefix minus the implicit
34691 // trailing dot — the same cap every DNS-compliant `HostName`
34692 // primitive downstream substrate consumer (the future
34693 // per-`Certificate` SAN emitter for cert-manager, the future
34694 // multi-`:entrada` host-collision gate) will inherit by
34695 // construction. Pinning the arithmetic here rather than the
34696 // literal `253` makes the RFC derivation explicit at the const's
34697 // test site so a future migration onto a different DNS-name
34698 // ceiling (an eventual RFC-successor limit, a per-cluster
34699 // override the operator pins) surfaces at this pin, not at every
34700 // downstream renderer's admission-rejection loop.
34701 assert_eq!(
34702 GATEWAY_API_HOSTNAME_MAX_LEN,
34703 255 - 1 - 1,
34704 "GATEWAY_API_HOSTNAME_MAX_LEN must equal the RFC 1035 / RFC 1123 DNS \
34705 name limit (255 wire bytes minus one length prefix minus the trailing \
34706 dot)",
34707 );
34708 }
34709
34710 #[test]
34711 fn gateway_api_default_http_listener_port_pins_canonical_80_literal() {
34712 // The canonical-constant arm — pins
34713 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`] at the verbatim
34714 // `80` literal the sole `caixa-mesh::gateway_routes` per-
34715 // Aplicacao `Gateway` per-listener HTTP-listener-port axis
34716 // reads from. Peer with the
34717 // [`crate::DEFAULT_SERVICO_PORT`]-pins-`8080` discipline on the
34718 // sibling per-renderer canonical-K8s-port-axis typed `u16`
34719 // const: a future refactor that drifts the constant out from
34720 // under either consumer surfaces here ahead of any per-renderer
34721 // Gateway emission. The literal value is IANA's well-known
34722 // `http` service port (RFC 9110 §4.2.2), so an
34723 // `http://<entrada.host>/…` URL without a `:<port>` selector
34724 // reaches the listener by construction.
34725 assert_eq!(
34726 GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT, 80,
34727 "canonical Gateway API v1 HTTP listener port literal must remain \
34728 `80` verbatim — this is the value the caixa-mesh Gateway emitter \
34729 reads from and the IANA-registered well-known `http` service port"
34730 );
34731 }
34732
34733 #[test]
34734 fn gateway_api_default_http_listener_port_distinct_from_default_servico_port() {
34735 // Cross-axis structural invariant: the Gateway listener's
34736 // external HTTP port ([`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`],
34737 // 80) and the per-Servico in-cluster L4 port
34738 // ([`DEFAULT_SERVICO_PORT`], 8080) are two distinct axes — the
34739 // external-ingress port the K8s Gateway API controller opens on
34740 // the cluster boundary, and the internal-Servico port the
34741 // `pleme-computeunit` chart emits per Servico `Service`.
34742 // Collapsing the two would silently emit a Gateway whose
34743 // listener port matched the Servico's own port, so a stray
34744 // Servico exposing its Service directly to a cluster-external
34745 // LoadBalancer would shadow the Aplicacao's Gateway path — the
34746 // typed two-axis distinction guards against a rebrand on either
34747 // axis silently converging on the other's value. Peer with the
34748 // [`GATEWAY_API_HOSTNAME_MAX_LEN`]-strictly-exceeds-[`DNS_1123_LABEL_MAX_LEN`]
34749 // discipline on the sibling per-axis structural-ordering pin
34750 // set — both are cross-axis invariants between two lifted
34751 // constants that share a downstream renderer.
34752 assert_ne!(
34753 GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT,
34754 crate::DEFAULT_SERVICO_PORT,
34755 "GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT ({GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT}) \
34756 must remain distinct from DEFAULT_SERVICO_PORT ({}) — the two axes name \
34757 different scalars (external-Gateway listener port vs in-cluster Servico port), \
34758 collapsing them silently shadows the Aplicacao's Gateway path",
34759 crate::DEFAULT_SERVICO_PORT,
34760 );
34761 }
34762
34763 #[test]
34764 fn gateway_api_default_http_listener_name_pins_canonical_http_literal() {
34765 // The canonical-constant arm — pins
34766 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME`] at the verbatim
34767 // `"http"` literal the sole `caixa-mesh::gateway_routes` per-
34768 // Aplicacao `Gateway` per-listener name-discriminator axis
34769 // reads from. Peer with the
34770 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`]-pins-`80` discipline
34771 // on the sibling per-listener HTTP-listener-port scalar-axis:
34772 // both are the Aplicacao-side substrate-canonical scalar-value
34773 // pins the sole per-Aplicacao `Gateway` emitter reaches for, so
34774 // a future refactor that drifts either constant out from under
34775 // the emitter surfaces here ahead of any per-renderer Gateway
34776 // emission. The literal value is the substrate's V0 arbitrary-
34777 // author-chosen short listener-name (K8s Gateway API v1's
34778 // `SectionName`-typed field carries no CRD-schema-pinned value
34779 // — the substrate picks `"http"` verbatim to match the
34780 // listener's carried protocol shape at the reader's eye), so
34781 // downstream `HTTPRoute` `sectionName` selectors bind to this
34782 // exact byte-string by construction.
34783 assert_eq!(
34784 GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME, "http",
34785 "canonical Gateway API v1 HTTP listener-name literal must remain \
34786 `\"http\"` verbatim — this is the value the caixa-mesh Gateway \
34787 emitter reads from and the substrate's V0 arbitrary-author-chosen \
34788 short listener-name identifier every downstream `HTTPRoute` \
34789 `parentRefs[].sectionName` selector binds to"
34790 );
34791 }
34792
34793 #[test]
34794 fn gateway_api_default_http_listener_name_carries_dns_1123_label_shape() {
34795 // Cross-axis invariant: K8s Gateway API v1 `Listener.name` is
34796 // `SectionName`-typed — a required DNS-1123 label unique within
34797 // the parent Gateway's listener list. Pinning the shape here
34798 // means a future rebrand on the canonical lift can't silently
34799 // land a malformed listener-name identifier (empty, uppercase,
34800 // whitespace, `.` / `_` / non-alphanumeric characters, an
34801 // overlong string past the DNS-1123 label ceiling) that the
34802 // apiserver-side Gateway API CRD schema validator would reject
34803 // far from the rebrand commit's source. The predicate the
34804 // `caixa-mesh::gateway_routes` per-listener-name emitter never
34805 // consults directly (the value is a const — no author input
34806 // reaches this axis today) gets consulted here so any future
34807 // rebrand routes through the same DNS-1123-label admission
34808 // grammar every K8s CRD `name`-shaped axis carries. Peer to
34809 // `default_gateway_class_name_is_a_valid_dns_1123_label` on
34810 // the sibling per-Gateway `gatewayClassName` scalar-axis pin
34811 // and `default_namespace_is_a_valid_dns_1123_label` on the
34812 // canonical-K8s-namespace lifted scalar — every substrate-side
34813 // K8s-CRD-name-shaped lift carries the same DNS-1123 label
34814 // admission-grammar cross-axis invariant.
34815 assert!(
34816 is_dns_1123_label(GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME).is_ok(),
34817 "GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME ({GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME:?}) \
34818 must be a valid DNS-1123 label — K8s Gateway API v1 `Listener.name` is \
34819 `SectionName`-typed and the apiserver-side CRD schema validator refuses \
34820 any other shape"
34821 );
34822 }
34823
34824 #[test]
34825 fn gateway_api_default_http_route_path_pins_canonical_root_literal() {
34826 // The canonical-constant arm — pins
34827 // [`GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH`] at the verbatim `"/"`
34828 // literal the sole `caixa-mesh::gateway_routes` per-Aplicacao
34829 // `HTTPRoute` empty-`:entrada :paths` catch-all URL-path
34830 // resolver reads from. Peer with the
34831 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME`]-pins-`"http"` and
34832 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`]-pins-`80`
34833 // disciplines on the sibling per-listener substrate-canonical
34834 // scalar-value axes: all three are the Aplicacao-side
34835 // substrate-canonical scalar-value pins the sole per-Aplicacao
34836 // Gateway API v1 CRD emitter reaches for, so a future refactor
34837 // that drifts any one constant out from under the emitter
34838 // surfaces here ahead of any per-renderer HTTPRoute emission.
34839 // The literal value is the K8s Gateway API v1 canonical
34840 // catch-all shape: `PathPrefix "/"` — the upstream docs at
34841 // <https://gateway-api.sigs.k8s.io/api-types/httproute/#path-based-routing>
34842 // pin the bare-root byte-string as the "match anything the
34843 // listener admits" idiom every gateway-class controller treats
34844 // as the equivalent of "no path predicate".
34845 assert_eq!(
34846 GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH, "/",
34847 "canonical Gateway API v1 HTTPRoute catch-all path literal must remain \
34848 `\"/\"` verbatim — this is the value the caixa-mesh HTTPRoute emitter \
34849 renders whenever the typed `:entrada :paths` list is empty and every \
34850 gateway-class controller (Cilium's Envoy, Envoy Gateway, Istio Gateway) \
34851 treats as the canonical `PathPrefix` catch-all"
34852 );
34853 }
34854
34855 #[test]
34856 fn gateway_api_default_http_route_path_carries_valid_gateway_api_http_path_shape() {
34857 // Cross-axis invariant: K8s Gateway API v1
34858 // `HTTPPathMatch.value` is admitted by the apiserver-side CRD
34859 // schema regex the substrate mirrors in the shared
34860 // [`is_gateway_api_http_path`] predicate — the same admission
34861 // grammar every author-supplied [`crate::aplicacao::Entrada`]
34862 // `:paths` entry clears at typed-validate time. Pinning the
34863 // shape here means a future rebrand on the canonical lift can't
34864 // silently land a malformed catch-all URL-path scalar (empty,
34865 // no leading `/`, overlong past the K8s Gateway API v1
34866 // `HTTPPathMatch.value` ceiling, `..`-segment-bearing, ASCII-
34867 // control-bearing, non-ASCII-bearing) that the apiserver-side
34868 // Gateway API CRD schema validator would reject far from the
34869 // rebrand commit's source. The paired
34870 // [`caixa_mesh::gateway_routes`] emitter never consults the
34871 // predicate directly (the catch-all value is a const — no
34872 // author input reaches this axis today) so consulting it here
34873 // means any future rebrand routes through the same
34874 // admission-grammar the peer author-side
34875 // `:entrada :paths` slot's `AplicacaoSpec::validate` gate
34876 // carries. Peer to
34877 // `gateway_api_default_http_listener_name_carries_dns_1123_label_shape`
34878 // on the sibling per-listener name-scalar cross-axis invariant
34879 // — every substrate-side Gateway-API-scalar lift carries the
34880 // matching per-axis admission-grammar cross-axis pin.
34881 assert!(
34882 is_gateway_api_http_path(GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH).is_ok(),
34883 "GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH ({GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH:?}) \
34884 must clear the shared HTTP-path admission grammar — K8s Gateway API v1 \
34885 `HTTPPathMatch.value` is CRD-schema-regex-validated and the apiserver-side \
34886 schema validator refuses any other shape at apply time"
34887 );
34888 }
34889
34890 // ── insert_first_seen ───────────────────────────────────────────────
34891
34892 #[derive(Debug, PartialEq, Eq)]
34893 enum DupTestErr {
34894 Dup(&'static str),
34895 }
34896
34897 #[test]
34898 fn insert_first_seen_accepts_distinct_keys_without_firing_closure() {
34899 // The happy path — every distinct key returns `Ok(())` and the
34900 // caller's `on_duplicate` closure is never invoked. Pins the
34901 // `HashSet::insert`-returning-`true`-on-first-insertion contract
34902 // the ten consumer sites (`:membros`, `:placement :clusters`,
34903 // `:entrada :paths`, `:contratos`, `:children`, `:deps`,
34904 // `:deps-dev`, `:etiquetas`, `:autores`, `:caracteristicas`,
34905 // code-paths) each rely on — a future refactor that flips the
34906 // sense of the delegated `insert` return would surface here
34907 // ahead of every per-consumer duplicate arm silently mis-firing
34908 // on distinct keys.
34909 let mut seen: std::collections::HashSet<&str> = std::collections::HashSet::new();
34910 for key in ["cart", "catalog", "payment"] {
34911 assert_eq!(
34912 insert_first_seen::<&str, DupTestErr, _>(&mut seen, key, || DupTestErr::Dup(
34913 "must not fire"
34914 )),
34915 Ok(()),
34916 "first insertion of {key:?} must return Ok(())",
34917 );
34918 }
34919 assert_eq!(seen.len(), 3, "every distinct key must land in the set");
34920 }
34921
34922 #[test]
34923 fn insert_first_seen_surfaces_caller_shaped_error_on_second_insertion() {
34924 // The duplicate arm — the second occurrence of any key surfaces
34925 // the caller's `on_duplicate` return verbatim. Pins the
34926 // "declaration-order-preserving first-collision" discipline every
34927 // peer `Duplicate*` variant documents: the first colliding entry
34928 // reports, not the last. Same shape the ten consumer sites'
34929 // `*_duplicate_diagnostic_names_second_collision` posture tests
34930 // pin at the caller layer; this lift makes the sequencing a
34931 // property of the helper, not a per-call-site convention.
34932 let mut seen: std::collections::HashSet<&str> = std::collections::HashSet::new();
34933 assert_eq!(
34934 insert_first_seen::<&str, DupTestErr, _>(&mut seen, "cart", || DupTestErr::Dup(
34935 "first"
34936 )),
34937 Ok(()),
34938 "first insertion must Ok",
34939 );
34940 assert_eq!(
34941 insert_first_seen::<&str, DupTestErr, _>(&mut seen, "cart", || DupTestErr::Dup(
34942 "second"
34943 )),
34944 Err(DupTestErr::Dup("second")),
34945 "second insertion must fire the caller's closure with its own tag",
34946 );
34947 }
34948
34949 #[test]
34950 fn insert_first_seen_generic_over_tuple_key_used_by_contratos_gate() {
34951 // The [`crate::AplicacaoSpec::validate`] `:contratos` gate carries
34952 // a six-tuple typed-edge identity key
34953 // (`(de, para, wit, endpoint, subject, slot)`) — the only non-
34954 // `&str` key shape in the crate's per-list uniqueness set. Pin
34955 // the generic-over-`K` contract here so a future refactor that
34956 // narrows the helper to `&str`-only keys (a hypothetical
34957 // `HashSet<&str>`-specialized rewrite) surfaces at this pin
34958 // rather than as a compile error at the sole tuple-carrying
34959 // consumer. The tuple set here mirrors the shape
34960 // `ContratoIdentity` carries.
34961 let mut seen: std::collections::HashSet<(&str, &str, &str, Option<&str>)> =
34962 std::collections::HashSet::new();
34963 let key = ("cart", "catalog", "wasi:http/proxy", Some("/products"));
34964 assert_eq!(
34965 insert_first_seen::<_, DupTestErr, _>(&mut seen, key, || DupTestErr::Dup(
34966 "must not fire"
34967 )),
34968 Ok(()),
34969 );
34970 assert_eq!(
34971 insert_first_seen::<_, DupTestErr, _>(&mut seen, key, || DupTestErr::Dup("collision")),
34972 Err(DupTestErr::Dup("collision")),
34973 "identical tuple key on second insertion must fire the duplicate arm",
34974 );
34975 }
34976
34977 // ── assert_str_reexport_identity ──────────────────────────────────
34978
34979 #[test]
34980 fn assert_str_reexport_identity_accepts_same_static_allocation() {
34981 // Positive path — passing the same `&'static str` twice (the
34982 // shape a `pub use caixa_core::X;` re-export produces at every
34983 // consumer site) must not panic. This is the ~75-caller-site
34984 // happy path that the lifted test-side pin gate collapses onto.
34985 // The compiler-interned literal `"KUBE_KEY_SPEC"` reaches this
34986 // helper twice through the same `&'static` allocation, so
34987 // `std::ptr::eq(a.as_ptr(), b.as_ptr())` returns true and the
34988 // second `assert!` arm passes without firing.
34989 const CANONICAL: &str = "canonical-value";
34990 assert_str_reexport_identity("CANONICAL_UNDER_TEST", CANONICAL, CANONICAL);
34991 }
34992
34993 #[test]
34994 #[should_panic(
34995 expected = "SIBLING_UNDER_TEST must be a re-export of caixa_core::SIBLING_UNDER_TEST"
34996 )]
34997 fn assert_str_reexport_identity_rejects_sibling_allocation_with_same_bytes() {
34998 // Negative path — passing two byte-equal `&'static str`s whose
34999 // underlying allocations differ (the shape a sibling `pub const
35000 // X: &str = "…"` at a renderer crate produces, silently carrying
35001 // the same bytes but its own `&'static` allocation) must panic
35002 // on the [`std::ptr::eq`] arm, naming the offending re-export.
35003 // Reproduces the canonical drift footgun the lift closes: byte-
35004 // equality via [`assert_eq!`] alone silently admits the drift
35005 // — the two strings are equal — but the allocation-identity
35006 // arm catches it structurally. Uses [`String::leak`] to
35007 // materialize a fresh `&'static str` allocation carrying the
35008 // same bytes as the compiler-interned canonical literal, so
35009 // the two share bytes but differ in allocation.
35010 const CANONICAL: &str = "canonical-value";
35011 let sibling: &'static str = String::from("canonical-value").leak();
35012 // Sanity — the sibling and canonical share bytes …
35013 assert_eq!(sibling, CANONICAL);
35014 // … but must live at distinct `&'static` allocations for this
35015 // negative path to fire on the identity arm rather than
35016 // silently pass on the equality arm.
35017 assert!(!std::ptr::eq(sibling.as_ptr(), CANONICAL.as_ptr()));
35018 assert_str_reexport_identity("SIBLING_UNDER_TEST", sibling, CANONICAL);
35019 }
35020
35021 #[test]
35022 #[should_panic(expected = "DRIFTED_UNDER_TEST must byte-equal caixa_core::DRIFTED_UNDER_TEST")]
35023 fn assert_str_reexport_identity_rejects_bytes_drift_before_identity_arm() {
35024 // Ordering pin — when the two byte-strings differ, the
35025 // [`assert_eq!`] arm must fire *before* the [`std::ptr::eq`]
35026 // identity arm reaches for `.as_ptr()`. Pins the arm sequencing
35027 // so a future refactor that flipped the two arms (identity
35028 // first, byte-equality second) would surface here rather than
35029 // report the wrong diagnostic against a drifted canonical
35030 // (the byte-equality diagnostic self-locates the value drift;
35031 // the identity diagnostic self-locates the allocation drift —
35032 // reporting the identity arm on a value-drifted pair points
35033 // the reader at the wrong failure class). Same discipline as
35034 // the peer `require_positive_canonical_bounded_duration`
35035 // three-arm-ordering pin above.
35036 const CANONICAL: &str = "canonical-value";
35037 const DRIFTED: &str = "drifted-value";
35038 assert_str_reexport_identity("DRIFTED_UNDER_TEST", DRIFTED, CANONICAL);
35039 }
35040
35041 #[test]
35042 fn computeunit_spec_key_module_pins_canonical_value() {
35043 // Pin the actual byte-string so a typo in this lift can't silently
35044 // rebrand the `wasm.pleme.io/v1alpha1/ComputeUnit` CRD per-CR
35045 // `spec.module` sub-block key both caixa-flux and caixa-helm
35046 // navigate to reach the per-Servico wasm-component reference the
35047 // M2.5 wasm-engine instantiator loads at Servico bring-up. The
35048 // value is part of the cluster-side contract with the
35049 // `pleme-computeunit` library chart's per-values module-source
35050 // routing + the `caixa-operator` `ComputeUnit` CR admission
35051 // webhook's per-CR module-reference resolver; changing it is a
35052 // coordinated ComputeUnit-CRD schema migration alongside the
35053 // upstream substrate release, not an incidental edit. Peer to
35054 // `default_namespace_pins_canonical_value` /
35055 // `helm_values_yaml_filename_pins_canonical_value` /
35056 // `helm_chart_yaml_filename_pins_canonical_value` on the sibling
35057 // canonical-substrate-schema-key axes.
35058 assert_eq!(COMPUTEUNIT_SPEC_KEY_MODULE, "module");
35059 }
35060
35061 #[test]
35062 fn computeunit_spec_key_trigger_pins_canonical_value() {
35063 // Peer to `computeunit_spec_key_module_pins_canonical_value` on
35064 // the same ComputeUnit-CRD per-`spec.*` sub-block axis — pins
35065 // the per-CR invocation-shape sub-block key every
35066 // `pleme-computeunit`-library-chart-driven per-Servico
35067 // `trigger.service.port` / `trigger.service.paths` /
35068 // `trigger.service.breathability` values-block route reads back.
35069 assert_eq!(COMPUTEUNIT_SPEC_KEY_TRIGGER, "trigger");
35070 }
35071
35072 #[test]
35073 fn computeunit_spec_key_capabilities_pins_canonical_value() {
35074 // Peer to `computeunit_spec_key_module_pins_canonical_value` and
35075 // `computeunit_spec_key_trigger_pins_canonical_value` on the same
35076 // ComputeUnit-CRD per-`spec.*` sub-block axis — pins the per-CR
35077 // WASI-capability-token-list sub-block key the M2.5 wasm-engine
35078 // instantiator reads to bind the per-component capability set
35079 // (WASI-preview-2 preview-interfaces per the WIT Component Model)
35080 // at Servico bring-up.
35081 assert_eq!(COMPUTEUNIT_SPEC_KEY_CAPABILITIES, "capabilities");
35082 }
35083
35084 #[test]
35085 fn computeunit_spec_keys_carry_lowercase_shape() {
35086 // Cross-axis invariant: every `wasm.pleme.io/v1alpha1/ComputeUnit`
35087 // CRD per-`spec.*` sub-block key is all-ASCII-lowercase
35088 // throughout — the ComputeUnit CRD's schema convention on the
35089 // per-`spec.*` sub-block axis. A drifted UpperCamelCase /
35090 // hyphenated variant (`"Module"` / `"module-source"` /
35091 // `"Trigger"` / `"Capabilities"` — the OpenAPI-CRD-schema
35092 // canonical-form footgun the peer `KUBE_KEY_*` axes share) would
35093 // land the emit-side key outside the CRD's admitted per-sub-
35094 // block set and the `caixa-operator` admission webhook would
35095 // silently drop the per-Servico wasm-runtime binding — the
35096 // Servico pods would come up under the library-chart defaults
35097 // (no module bound, no trigger bound, no capability set)
35098 // instead of the caixa.lisp's declared per-`:servicos` axis.
35099 // Same all-ASCII-lowercase shape gate as the peer M2 typed-slot
35100 // camelCase-key axes ([`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] —
35101 // the compound-word slot [`M2_KEY_UPGRADE_FROM`] adds a
35102 // camelHump per its `#[serde(rename_all = "camelCase")]`-derived
35103 // shape, but the leading-word gate is the same).
35104 for k in [
35105 COMPUTEUNIT_SPEC_KEY_MODULE,
35106 COMPUTEUNIT_SPEC_KEY_TRIGGER,
35107 COMPUTEUNIT_SPEC_KEY_CAPABILITIES,
35108 ] {
35109 assert!(
35110 k.bytes().all(|b| b.is_ascii_lowercase()),
35111 "ComputeUnit CRD per-`spec.*` sub-block key {k:?} must be \
35112 all-ASCII-lowercase per the CRD schema convention"
35113 );
35114 }
35115 }
35116
35117 #[test]
35118 fn computeunit_spec_keys_appear_verbatim_in_sample_computeunit_yaml() {
35119 // Round-trip pin: the exact byte-strings the three lifted
35120 // constants carry appear verbatim as the top-level `spec.*`
35121 // sub-block keys of a canonical in-tree `ComputeUnit` YAML —
35122 // the same shape [`caixa_flux::programs_yaml_entry`] and
35123 // [`caixa_helm::build_values_yaml`] consume via
35124 // `serde_yaml::from_str`. Pins the const-to-schema round-trip
35125 // so a future ComputeUnit-CRD schema rebrand (a `binary:` /
35126 // `component:` / `invoke:` / `caps:` / `spec.wasm.*` axis
35127 // rename the ABSORPTION-ROADMAP.md M4-M5 trajectory names)
35128 // surfaces here as a build error rather than as a silent
35129 // per-Servico wasm-runtime-binding drop at cluster-apply time.
35130 let cu: serde_yaml::Value = serde_yaml::from_str(
35131 r#"
35132apiVersion: wasm.pleme.io/v1alpha1
35133kind: ComputeUnit
35134metadata:
35135 name: hello-rio
35136spec:
35137 module:
35138 source: oci://ghcr.io/pleme-io/hello-rio:v0.1.0
35139 trigger:
35140 service:
35141 port: 8080
35142 paths: ["/"]
35143 capabilities:
35144 - env
35145"#,
35146 )
35147 .unwrap();
35148 let spec = cu.get(KUBE_KEY_SPEC).expect("spec key present");
35149 assert!(
35150 spec.get(COMPUTEUNIT_SPEC_KEY_MODULE).is_some(),
35151 "spec.{COMPUTEUNIT_SPEC_KEY_MODULE} sub-block must be present"
35152 );
35153 assert!(
35154 spec.get(COMPUTEUNIT_SPEC_KEY_TRIGGER).is_some(),
35155 "spec.{COMPUTEUNIT_SPEC_KEY_TRIGGER} sub-block must be present"
35156 );
35157 assert!(
35158 spec.get(COMPUTEUNIT_SPEC_KEY_CAPABILITIES).is_some(),
35159 "spec.{COMPUTEUNIT_SPEC_KEY_CAPABILITIES} sub-block must be present"
35160 );
35161 // Nested `spec.module.source` leaf-scalar sub-block: every
35162 // rendered ComputeUnit YAML declares the wasm-component
35163 // reference under this leaf, and every downstream
35164 // `programs[].module.source` readback the
35165 // [`caixa_flux::programs_yaml_entry`] round-trip pins reaches
35166 // for the same `&'static str`. Peer to the top-level
35167 // `spec.{module,trigger,capabilities}` presence assertions
35168 // above — extends the round-trip pin one level deeper onto
35169 // the module-block's leaf reference-value axis.
35170 let module = spec
35171 .get(COMPUTEUNIT_SPEC_KEY_MODULE)
35172 .expect("spec.module block present");
35173 assert!(
35174 module.get(COMPUTEUNIT_MODULE_KEY_SOURCE).is_some(),
35175 "spec.{COMPUTEUNIT_SPEC_KEY_MODULE}.{COMPUTEUNIT_MODULE_KEY_SOURCE} \
35176 leaf-scalar sub-block must be present"
35177 );
35178 assert_eq!(
35179 module
35180 .get(COMPUTEUNIT_MODULE_KEY_SOURCE)
35181 .and_then(|s| s.as_str()),
35182 Some("oci://ghcr.io/pleme-io/hello-rio:v0.1.0"),
35183 "the ComputeUnit CRD per-`module.source` axis carries the wasm-\
35184 component OCI/git reference verbatim"
35185 );
35186 }
35187
35188 #[test]
35189 fn computeunit_module_key_source_pins_canonical_value() {
35190 // Peer to `computeunit_spec_key_module_pins_canonical_value` on
35191 // the nested `spec.module.*` sub-block axis — pins the per-CR
35192 // wasm-component-reference leaf-scalar key every
35193 // [`caixa_flux::programs_yaml_entry`] round-trip navigator and
35194 // every [`caixa_flux::upsert_into_programs_yaml`] /
35195 // [`caixa_flux::upsert_into_helmrelease_programs`] cross-
35196 // upsert readback resolves under the parent
35197 // `COMPUTEUNIT_SPEC_KEY_MODULE`. Changing this value is a
35198 // coordinated ComputeUnit-CRD schema migration alongside the
35199 // `pleme-computeunit` library chart's per-values module-source
35200 // routing + the `caixa-operator` `ComputeUnit` CR admission
35201 // webhook's per-CR module-reference resolver, not an
35202 // incidental edit.
35203 assert_eq!(COMPUTEUNIT_MODULE_KEY_SOURCE, "source");
35204 }
35205
35206 #[test]
35207 fn computeunit_module_key_source_carries_lowercase_shape() {
35208 // Cross-axis invariant: the nested `spec.module.*` leaf-scalar
35209 // sub-block key is all-ASCII-lowercase throughout — the
35210 // ComputeUnit CRD's schema convention on the per-`spec.module.*`
35211 // leaf axis, same as the top-level per-`spec.*` sub-block
35212 // axis the sibling `COMPUTEUNIT_SPEC_KEY_*` peers gate.
35213 // A drifted UpperCamelCase / hyphenated variant (`"Source"` /
35214 // `"module-source"` / `"src"` — the OpenAPI-CRD-schema
35215 // canonical-form footgun the peer `KUBE_KEY_*` axes share)
35216 // would land the emit-side key outside the CRD's admitted
35217 // per-`module.*` set and the `caixa-operator` admission
35218 // webhook would silently drop the per-Servico wasm-module
35219 // reference — the Servico pods would come up under the
35220 // library-chart defaults (no module bound) instead of the
35221 // caixa.lisp's declared per-`:servicos` axis. Same all-ASCII-
35222 // lowercase shape gate as the peer `COMPUTEUNIT_SPEC_KEY_*`
35223 // top-level axes.
35224 assert!(
35225 COMPUTEUNIT_MODULE_KEY_SOURCE
35226 .bytes()
35227 .all(|b| b.is_ascii_lowercase()),
35228 "ComputeUnit CRD per-`spec.module.*` leaf-scalar sub-block key \
35229 {COMPUTEUNIT_MODULE_KEY_SOURCE:?} must be all-ASCII-lowercase \
35230 per the CRD schema convention"
35231 );
35232 }
35233
35234 #[test]
35235 fn mapping_ext_insert_str_key_promotes_key_to_yaml_string() {
35236 // The trait method promotes an arbitrary `&str` key to
35237 // `Value::String(key.to_string())` — pin the promotion so a
35238 // future refactor that reaches for a different `Value` variant
35239 // for the key (e.g. `Value::Tagged`) is a compile-visible break,
35240 // not a silent per-consumer regression at the K8s-artifact-emit
35241 // surface.
35242 let mut m = serde_yaml::Mapping::new();
35243 let prior = m.insert_str_key("spec", serde_yaml::Value::Bool(true));
35244 assert!(
35245 prior.is_none(),
35246 "insert_str_key returns None on first insertion, mirroring \
35247 serde_yaml::Mapping::insert"
35248 );
35249 // Key is exactly the `Value::String` promotion of the input.
35250 let got = m
35251 .get(serde_yaml::Value::String("spec".to_string()))
35252 .expect("inserted key is present under Value::String promotion");
35253 assert_eq!(
35254 got,
35255 &serde_yaml::Value::Bool(true),
35256 "insert_str_key routes value verbatim to the underlying \
35257 serde_yaml::Mapping::insert"
35258 );
35259 }
35260
35261 #[test]
35262 fn mapping_ext_insert_str_key_returns_prior_value_on_replace() {
35263 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35264 // return contract: the prior value at that key, or `None` if
35265 // absent. Pin the replace-returns-prior semantic so a future
35266 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35267 // silently drop the prior-value handoff downstream consumers may
35268 // reach for (the M4 per-`:politicas` overlay merger, the future
35269 // `feira app deploy` idempotent-write dry-run comparator).
35270 let mut m = serde_yaml::Mapping::new();
35271 m.insert_str_key("kind", serde_yaml::Value::String("Gateway".into()));
35272 let prior = m.insert_str_key("kind", serde_yaml::Value::String("HTTPRoute".into()));
35273 assert_eq!(
35274 prior,
35275 Some(serde_yaml::Value::String("Gateway".into())),
35276 "insert_str_key returns the prior value when replacing an existing key"
35277 );
35278 let got = m
35279 .get(serde_yaml::Value::String("kind".to_string()))
35280 .expect("key is still present after replace");
35281 assert_eq!(
35282 got,
35283 &serde_yaml::Value::String("HTTPRoute".into()),
35284 "replaced value is now the most-recently-inserted one"
35285 );
35286 }
35287
35288 #[test]
35289 fn mapping_ext_insert_str_key_matches_hand_written_promotion() {
35290 // Cross-check the trait method against the hand-written
35291 // `mapping.insert(Value::String(key.into()), value)` shape the
35292 // ~48 lifted call sites previously carried. A drift between the
35293 // trait method's promotion and the inline promotion the prior
35294 // call sites used would silently emit a different YAML mapping
35295 // (a differently-quoted key, a different `Value` variant) at
35296 // every routed consumer — pin the equivalence so the trait
35297 // remains a drop-in replacement.
35298 let mut via_trait = serde_yaml::Mapping::new();
35299 via_trait.insert_str_key(KUBE_KEY_KIND, serde_yaml::Value::String("Gateway".into()));
35300
35301 let mut via_inline = serde_yaml::Mapping::new();
35302 via_inline.insert(
35303 serde_yaml::Value::String(KUBE_KEY_KIND.into()),
35304 serde_yaml::Value::String("Gateway".into()),
35305 );
35306
35307 assert_eq!(
35308 via_trait, via_inline,
35309 "insert_str_key(KEY, V) must byte-equal \
35310 insert(Value::String(KEY.into()), V) — otherwise the \
35311 ~48 routed consumer sites drift silently at emit time"
35312 );
35313 }
35314
35315 #[test]
35316 fn mapping_get_bare_str_key_byte_equals_value_string_wrapped_form() {
35317 // The read-side twin of the `insert_str_key`-vs-hand-written pin.
35318 // `serde_yaml::Mapping::get<I: Index>` accepts any `I: Index`;
35319 // the crate ships `impl Index for str` (routing through a
35320 // no-allocation `HashLikeValue(&str)` bucket lookup) and
35321 // `impl Index for Value` (matching the `Value::String(_)`
35322 // key verbatim). The ~78 test-side probes across `caixa-mesh`,
35323 // `caixa-flux`, and `caixa-core::render` that previously spelled
35324 // out `.get(serde_yaml::Value::String(<KEY>.into()))` were
35325 // swept onto the shorter `.get(<KEY>)` form because the two
35326 // must resolve to the same bucket for the sweep to be a
35327 // drop-in. Pin the equivalence — the `HashLikeValue(&str)`
35328 // hash must byte-equal the `Value::String(String)` hash so
35329 // the two paths agree on `get`, `contains_key`, and the
35330 // absence path (`None` when the key is missing) — otherwise
35331 // a future `serde_yaml` upgrade could silently divert every
35332 // swept probe past the value the emitter inserted.
35333 let mut m = serde_yaml::Mapping::new();
35334 m.insert_str_key(KUBE_KEY_KIND, serde_yaml::Value::String("Gateway".into()));
35335 // Present-key path: both forms find the same value.
35336 assert_eq!(
35337 m.get(KUBE_KEY_KIND),
35338 m.get(serde_yaml::Value::String(KUBE_KEY_KIND.into())),
35339 "mapping.get(<KEY>) must byte-equal \
35340 mapping.get(Value::String(<KEY>.into())) — otherwise the \
35341 ~78 swept test-side probes drift silently past the value \
35342 the emitter inserted under the promoted Value::String key"
35343 );
35344 // Absent-key path: both forms return None.
35345 assert_eq!(
35346 m.get(KUBE_KEY_SPEC),
35347 m.get(serde_yaml::Value::String(KUBE_KEY_SPEC.into())),
35348 "absent-key lookup via bare-&str must byte-equal absent-key \
35349 lookup via Value::String — both must return None so the \
35350 swept `assert!(_.get(K).is_none())` shape stays load-bearing"
35351 );
35352 // contains_key parity: both forms agree on present + absent.
35353 assert_eq!(
35354 m.contains_key(KUBE_KEY_KIND),
35355 m.contains_key(serde_yaml::Value::String(KUBE_KEY_KIND.into())),
35356 "mapping.contains_key(<KEY>) must byte-equal \
35357 mapping.contains_key(Value::String(<KEY>.into())) — \
35358 otherwise the swept `assert!(_.contains_key(K))` shape \
35359 disagrees with the emitter's `insert_str_key` promotion"
35360 );
35361 assert_eq!(
35362 m.contains_key(KUBE_KEY_SPEC),
35363 m.contains_key(serde_yaml::Value::String(KUBE_KEY_SPEC.into())),
35364 "absent-key contains_key via bare-&str must byte-equal \
35365 absent-key contains_key via Value::String"
35366 );
35367 }
35368
35369 #[test]
35370 fn mapping_get_mut_bare_str_key_byte_equals_value_string_wrapped_form() {
35371 // The mutation-path twin of the read-side pin above.
35372 // `serde_yaml::Mapping::get_mut<I: Index>` accepts any
35373 // `I: Index` — the crate ships `impl Index for str` (routing
35374 // through the same no-allocation `HashLikeValue(&str)` bucket
35375 // lookup the read-side `get` / `contains_key` sweep landed on
35376 // in 0e84fb9) and `impl Index for Value` (matching the
35377 // `Value::String(_)` key verbatim). Until this pin landed the
35378 // sole production `.get_mut(serde_yaml::Value::String(<KEY>.into()))`
35379 // probe — [`caixa_flux::upsert_into_helmrelease_programs`]'s
35380 // `root.get_mut(…)` HelmRelease-side spec-mutate at
35381 // `caixa-flux/src/lib.rs:845` (which the sibling
35382 // `kube_key_spec_re_export_points_at_caixa_core_canonical`
35383 // pinning test's docstring already described in the shorter
35384 // `root.get_mut("spec")` form the 0e84fb9 read-side sweep
35385 // landed elsewhere on) — carried the verbose `Value::String`-
35386 // wrapped shape as the last stray hold-out on the `get_mut`
35387 // axis. The sweep swaps it onto the bare-`&str` form, matching
35388 // the ~78 read-side probes 0e84fb9 already swept and the
35389 // in-file `kube_key_spec_re_export_points_at_caixa_core_canonical`
35390 // docstring's canonical description. Pin the equivalence — the
35391 // `HashLikeValue(&str)` hash must byte-equal the
35392 // `Value::String(String)` hash so the two paths agree on both
35393 // the present-key path (returns `Some(&mut _)` at the same
35394 // slot) and the absent-key path (returns `None` when the key
35395 // is missing) — otherwise a future `serde_yaml` upgrade could
35396 // silently divert the writer-side upsert past the value the
35397 // emitter previously mutated. Peer to the read-side
35398 // [`mapping_get_bare_str_key_byte_equals_value_string_wrapped_form`]
35399 // pin on the sibling `get` / `contains_key` axes; together the
35400 // two pins pin every `Index`-polymorphic probe axis the
35401 // caixa-flux upsert path walks.
35402 let mut m = serde_yaml::Mapping::new();
35403 m.insert_str_key(KUBE_KEY_KIND, serde_yaml::Value::String("Gateway".into()));
35404 // Present-key path: both forms find the same slot.
35405 // Cross-check by mutating through the bare-&str path and
35406 // observing the mutation via the Value::String path (and vice
35407 // versa) — anything short of exact bucket-equality would
35408 // silently split the two probes onto different slots.
35409 {
35410 let via_bare = m
35411 .get_mut(KUBE_KEY_KIND)
35412 .expect("present key must resolve via bare-&str");
35413 *via_bare = serde_yaml::Value::String("HTTPRoute".into());
35414 }
35415 assert_eq!(
35416 m.get(serde_yaml::Value::String(KUBE_KEY_KIND.into())),
35417 Some(&serde_yaml::Value::String("HTTPRoute".into())),
35418 "mutation via mapping.get_mut(<KEY>) must be visible via \
35419 mapping.get(Value::String(<KEY>.into())) — otherwise the \
35420 swept `get_mut` writer-side probe drifts past the value \
35421 the emitter reads through the promoted Value::String key"
35422 );
35423 {
35424 let via_wrapped = m
35425 .get_mut(serde_yaml::Value::String(KUBE_KEY_KIND.into()))
35426 .expect("present key must also resolve via Value::String");
35427 *via_wrapped = serde_yaml::Value::String("Gateway".into());
35428 }
35429 assert_eq!(
35430 m.get(KUBE_KEY_KIND),
35431 Some(&serde_yaml::Value::String("Gateway".into())),
35432 "mutation via mapping.get_mut(Value::String(<KEY>.into())) \
35433 must be visible via mapping.get(<KEY>) — the two paths \
35434 address the same bucket in both directions"
35435 );
35436 // Absent-key path: both forms return None so the sole swept
35437 // `.get_mut(<KEY>).ok_or(Error::MissingField(<KEY>))` shape
35438 // stays load-bearing.
35439 assert!(
35440 m.get_mut(KUBE_KEY_SPEC).is_none(),
35441 "absent-key mapping.get_mut(<KEY>) must return None"
35442 );
35443 assert!(
35444 m.get_mut(serde_yaml::Value::String(KUBE_KEY_SPEC.into()))
35445 .is_none(),
35446 "absent-key mapping.get_mut(Value::String(<KEY>.into())) \
35447 must also return None — the two forms must agree on \
35448 absence so the swept `.ok_or(Error::MissingField(<KEY>))` \
35449 diagnostic still fires on a missing spec block"
35450 );
35451 }
35452
35453 #[test]
35454 fn mapping_ext_insert_string_promotes_value_to_yaml_string() {
35455 // The trait method promotes an arbitrary `Into<String>` value
35456 // to `Value::String(value.into())` — pin the promotion so a
35457 // future refactor that reaches for a different `Value` variant
35458 // for the string-scalar payload (e.g. `Value::Tagged` under a
35459 // K8s Server-Side-Apply typed-field-ownership axis rebrand) is
35460 // a compile-visible break, not a silent per-consumer regression
35461 // at the K8s-artifact-emit surface. Peer with
35462 // [`mapping_ext_insert_str_key_promotes_key_to_yaml_string`] on
35463 // the sibling `insert_str_key` primitive's key-promotion pin.
35464 let mut m = serde_yaml::Mapping::new();
35465 let prior = m.insert_string("kind", "Gateway");
35466 assert!(
35467 prior.is_none(),
35468 "insert_string returns None on first insertion, mirroring \
35469 serde_yaml::Mapping::insert"
35470 );
35471 let got = m
35472 .get("kind")
35473 .expect("inserted key is present under Value::String promotion");
35474 assert_eq!(
35475 got,
35476 &serde_yaml::Value::String("Gateway".into()),
35477 "insert_string routes value verbatim through Value::String \
35478 promotion"
35479 );
35480 }
35481
35482 #[test]
35483 fn mapping_ext_insert_string_returns_prior_value_on_replace() {
35484 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35485 // return contract: the prior value at that key, or `None` if
35486 // absent. Pin the replace-returns-prior semantic so a future
35487 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35488 // silently drop the prior-value handoff downstream consumers
35489 // may reach for. Peer with
35490 // [`mapping_ext_insert_str_key_returns_prior_value_on_replace`]
35491 // on the sibling `insert_str_key` primitive's replace-semantics
35492 // pin.
35493 let mut m = serde_yaml::Mapping::new();
35494 m.insert_string(KUBE_KEY_KIND, "Gateway");
35495 let prior = m.insert_string(KUBE_KEY_KIND, "HTTPRoute");
35496 assert_eq!(
35497 prior,
35498 Some(serde_yaml::Value::String("Gateway".into())),
35499 "insert_string returns the prior value when replacing an \
35500 existing key"
35501 );
35502 let got = m
35503 .get(KUBE_KEY_KIND)
35504 .expect("key is still present after replace");
35505 assert_eq!(
35506 got,
35507 &serde_yaml::Value::String("HTTPRoute".into()),
35508 "replaced value is now the most-recently-inserted one"
35509 );
35510 }
35511
35512 #[test]
35513 fn mapping_ext_insert_string_matches_hand_written_promotion() {
35514 // Cross-check the trait method against the hand-written
35515 // `mapping.insert_str_key(KEY, Value::String(V.into()))` shape
35516 // the ~17 lifted call sites previously carried. A drift between
35517 // the trait method's promotion and the inline promotion would
35518 // silently emit a different YAML mapping (a differently-quoted
35519 // scalar, a different `Value` variant) at every routed
35520 // consumer — pin the equivalence so the trait remains a drop-in
35521 // replacement. Also cross-checks that all three input shapes
35522 // (`&'static str` → `.into()`, `String` → `.clone()` /
35523 // `.to_string()`, integer → `.to_string()`) converge on the same
35524 // `Value::String` promotion, since the ~17 call sites cover all
35525 // three input flavors.
35526 let mut via_trait = serde_yaml::Mapping::new();
35527 via_trait.insert_string(KUBE_KEY_KIND, "Gateway");
35528 via_trait.insert_string(KUBE_KEY_NAME, String::from("hello"));
35529 via_trait.insert_string(KUBE_KEY_PORT, 8080u16.to_string());
35530
35531 let mut via_inline = serde_yaml::Mapping::new();
35532 via_inline.insert_str_key(KUBE_KEY_KIND, serde_yaml::Value::String("Gateway".into()));
35533 via_inline.insert_str_key(
35534 KUBE_KEY_NAME,
35535 serde_yaml::Value::String(String::from("hello")),
35536 );
35537 via_inline.insert_str_key(
35538 KUBE_KEY_PORT,
35539 serde_yaml::Value::String(8080u16.to_string()),
35540 );
35541
35542 assert_eq!(
35543 via_trait, via_inline,
35544 "insert_string(KEY, V) must byte-equal \
35545 insert_str_key(KEY, Value::String(V.into())) — otherwise \
35546 the ~17 routed consumer sites drift silently at emit time"
35547 );
35548 }
35549
35550 #[test]
35551 fn mapping_ext_insert_number_promotes_value_to_yaml_number() {
35552 // The trait method promotes an arbitrary `Into<serde_yaml::Number>`
35553 // value to `Value::Number(value.into())` — pin the promotion so a
35554 // future refactor that reaches for a different `Value` variant
35555 // for the integer-scalar payload (e.g. `Value::Tagged` under a
35556 // K8s Server-Side-Apply typed-field-ownership axis rebrand, or
35557 // the deprecated `Value::String(n.to_string())` "stringy port"
35558 // rendering some pre-Gateway-API-v1 CRDs still shipped with) is
35559 // a compile-visible break, not a silent per-consumer regression
35560 // at the K8s-artifact-emit surface. Peer with
35561 // [`mapping_ext_insert_string_promotes_value_to_yaml_string`] on
35562 // the sibling `insert_string` primitive's string-scalar
35563 // promotion pin.
35564 let mut m = serde_yaml::Mapping::new();
35565 let prior = m.insert_number(KUBE_KEY_PORT, GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT);
35566 assert!(
35567 prior.is_none(),
35568 "insert_number returns None on first insertion, mirroring \
35569 serde_yaml::Mapping::insert"
35570 );
35571 let got = m
35572 .get(KUBE_KEY_PORT)
35573 .expect("inserted key is present under Value::Number promotion");
35574 assert_eq!(
35575 got.as_u64(),
35576 Some(u64::from(GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT)),
35577 "insert_number routes value verbatim through Value::Number \
35578 promotion — the u16 payload survives round-trip as a Number \
35579 the as_u64 accessor decodes verbatim"
35580 );
35581 assert!(
35582 matches!(got, serde_yaml::Value::Number(_)),
35583 "the promoted value is Value::Number, not Value::String — a \
35584 stringy-port drift would emit `port: \"80\"` (rejected by \
35585 Gateway API v1 apiserver as a type mismatch)"
35586 );
35587 }
35588
35589 #[test]
35590 fn mapping_ext_insert_number_returns_prior_value_on_replace() {
35591 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35592 // return contract: the prior value at that key, or `None` if
35593 // absent. Pin the replace-returns-prior semantic so a future
35594 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35595 // silently drop the prior-value handoff downstream consumers
35596 // may reach for. Peer with
35597 // [`mapping_ext_insert_string_returns_prior_value_on_replace`] on
35598 // the sibling `insert_string` primitive's replace-semantics pin.
35599 let mut m = serde_yaml::Mapping::new();
35600 m.insert_number(KUBE_KEY_PORT, 80u16);
35601 let prior = m.insert_number(KUBE_KEY_PORT, 443u16);
35602 assert_eq!(
35603 prior.as_ref().and_then(serde_yaml::Value::as_u64),
35604 Some(80),
35605 "insert_number returns the prior value when replacing an \
35606 existing key — the u16 payload round-trips verbatim through \
35607 the returned Value::Number handoff"
35608 );
35609 let got = m
35610 .get(KUBE_KEY_PORT)
35611 .expect("key is still present after replace");
35612 assert_eq!(
35613 got.as_u64(),
35614 Some(443),
35615 "replaced value is now the most-recently-inserted one"
35616 );
35617 }
35618
35619 #[test]
35620 fn mapping_ext_insert_number_matches_hand_written_promotion() {
35621 // Cross-check the trait method against the hand-written
35622 // `mapping.insert_str_key(KEY, Value::Number(N.into()))` shape
35623 // the two lifted caixa-mesh call sites previously carried. A
35624 // drift between the trait method's promotion and the inline
35625 // promotion would silently emit a different YAML mapping (a
35626 // differently-typed scalar, a different `Value` variant) at
35627 // every routed consumer — pin the equivalence so the trait
35628 // remains a drop-in replacement. Two arms pin the axis end-to-
35629 // end: a `u16` typed-const arm (the lifted
35630 // `GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT` external HTTP
35631 // listener-port, cd60fde) and a `u16` typed-field arm (the
35632 // per-`entrada.port` backend-target Servico port routed through
35633 // the `AplicacaoSpec` `:entrada :port` slot).
35634 let mut via_trait = serde_yaml::Mapping::new();
35635 via_trait.insert_number(KUBE_KEY_PORT, GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT);
35636 via_trait.insert_number(GATEWAY_API_KEY_VALUE, 8443u16);
35637
35638 let mut via_inline = serde_yaml::Mapping::new();
35639 via_inline.insert_str_key(
35640 KUBE_KEY_PORT,
35641 serde_yaml::Value::Number(GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT.into()),
35642 );
35643 via_inline.insert_str_key(
35644 GATEWAY_API_KEY_VALUE,
35645 serde_yaml::Value::Number(8443u16.into()),
35646 );
35647
35648 assert_eq!(
35649 via_trait, via_inline,
35650 "insert_number(KEY, N) must byte-equal \
35651 insert_str_key(KEY, Value::Number(N.into())) — otherwise \
35652 the two routed caixa-mesh consumer sites drift silently at \
35653 emit time"
35654 );
35655 }
35656
35657 #[test]
35658 fn mapping_ext_insert_mapping_promotes_value_to_yaml_mapping() {
35659 // The trait method promotes an arbitrary `serde_yaml::Mapping`
35660 // value to `Value::Mapping(value)` — pin the promotion so a
35661 // future refactor that reaches for a different `Value` variant
35662 // for the nested-Mapping payload (e.g. `Value::Tagged` under a
35663 // K8s Server-Side-Apply typed-field-ownership axis rebrand) is
35664 // a compile-visible break, not a silent per-consumer regression
35665 // at the K8s-artifact-emit surface. Peer with
35666 // [`mapping_ext_insert_string_promotes_value_to_yaml_string`] on
35667 // the sibling `insert_string` primitive's scalar-promotion pin
35668 // and with
35669 // [`mapping_ext_insert_str_key_promotes_key_to_yaml_string`] on
35670 // the base `insert_str_key` primitive's key-promotion pin.
35671 let mut inner = serde_yaml::Mapping::new();
35672 inner.insert_string(KUBE_KEY_NAME, "hello-rio");
35673 let mut m = serde_yaml::Mapping::new();
35674 let prior = m.insert_mapping(KUBE_KEY_METADATA, inner.clone());
35675 assert!(
35676 prior.is_none(),
35677 "insert_mapping returns None on first insertion, mirroring \
35678 serde_yaml::Mapping::insert"
35679 );
35680 let got = m
35681 .get(KUBE_KEY_METADATA)
35682 .expect("inserted key is present under Value::Mapping promotion");
35683 assert_eq!(
35684 got,
35685 &serde_yaml::Value::Mapping(inner),
35686 "insert_mapping routes value verbatim through Value::Mapping \
35687 promotion"
35688 );
35689 }
35690
35691 #[test]
35692 fn mapping_ext_insert_mapping_returns_prior_value_on_replace() {
35693 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35694 // return contract: the prior value at that key, or `None` if
35695 // absent. Pin the replace-returns-prior semantic so a future
35696 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35697 // silently drop the prior-value handoff downstream consumers
35698 // may reach for. Peer with
35699 // [`mapping_ext_insert_string_returns_prior_value_on_replace`]
35700 // and
35701 // [`mapping_ext_insert_str_key_returns_prior_value_on_replace`]
35702 // on the sibling primitive-pair members' replace-semantics
35703 // pins.
35704 let mut first_inner = serde_yaml::Mapping::new();
35705 first_inner.insert_string(KUBE_KEY_NAME, "first");
35706 let mut second_inner = serde_yaml::Mapping::new();
35707 second_inner.insert_string(KUBE_KEY_NAME, "second");
35708 let mut m = serde_yaml::Mapping::new();
35709 m.insert_mapping(KUBE_KEY_METADATA, first_inner.clone());
35710 let prior = m.insert_mapping(KUBE_KEY_METADATA, second_inner.clone());
35711 assert_eq!(
35712 prior,
35713 Some(serde_yaml::Value::Mapping(first_inner)),
35714 "insert_mapping returns the prior value when replacing an \
35715 existing key"
35716 );
35717 let got = m
35718 .get(KUBE_KEY_METADATA)
35719 .expect("key is still present after replace");
35720 assert_eq!(
35721 got,
35722 &serde_yaml::Value::Mapping(second_inner),
35723 "replaced value is now the most-recently-inserted one"
35724 );
35725 }
35726
35727 #[test]
35728 fn mapping_ext_insert_mapping_matches_hand_written_promotion() {
35729 // Cross-check the trait method against the hand-written
35730 // `mapping.insert_str_key(KEY, Value::Mapping(inner))` shape the
35731 // 6 lifted call sites previously carried. A drift between the
35732 // trait method's promotion and the inline promotion would
35733 // silently emit a different YAML mapping (a differently-wrapped
35734 // outer variant, a differently-shaped inner Mapping) at every
35735 // routed consumer — pin the equivalence so the trait remains a
35736 // drop-in replacement. Two cases pin the shape end-to-end:
35737 // an empty inner Mapping (no silent is_empty short-circuit) and
35738 // a populated inner Mapping (the `metadata` / `spec` /
35739 // `spec.rules[].path` sub-block shape).
35740 let mut inner_empty = serde_yaml::Mapping::new();
35741 let _ = &mut inner_empty; // keep as mut for parity with populated arm below
35742 let mut inner_populated = serde_yaml::Mapping::new();
35743 inner_populated.insert_string(KUBE_KEY_NAME, "hello-rio");
35744 inner_populated.insert_string(KUBE_KEY_NAMESPACE, DEFAULT_NAMESPACE);
35745
35746 let mut via_trait = serde_yaml::Mapping::new();
35747 via_trait.insert_mapping(KUBE_KEY_SPEC, inner_empty.clone());
35748 via_trait.insert_mapping(KUBE_KEY_METADATA, inner_populated.clone());
35749
35750 let mut via_inline = serde_yaml::Mapping::new();
35751 via_inline.insert_str_key(KUBE_KEY_SPEC, serde_yaml::Value::Mapping(inner_empty));
35752 via_inline.insert_str_key(
35753 KUBE_KEY_METADATA,
35754 serde_yaml::Value::Mapping(inner_populated),
35755 );
35756
35757 assert_eq!(
35758 via_trait, via_inline,
35759 "insert_mapping(KEY, inner) must byte-equal \
35760 insert_str_key(KEY, Value::Mapping(inner)) — otherwise the \
35761 six routed consumer sites drift silently at emit time"
35762 );
35763 }
35764
35765 #[test]
35766 fn mapping_ext_insert_sequence_promotes_value_to_yaml_sequence() {
35767 // The trait method promotes an arbitrary `Vec<Value>` value to
35768 // `Value::Sequence(value)` — pin the promotion so a future
35769 // refactor that reaches for a different `Value` variant for the
35770 // list-shape payload (e.g. `Value::Tagged` under a K8s Server-
35771 // Side-Apply typed-field-ownership axis rebrand, a serde_yaml
35772 // successor's `Value::Array` / `Value::List` variant rename) is
35773 // a compile-visible break, not a silent per-consumer regression
35774 // at the K8s-artifact-emit surface. Peer with
35775 // [`mapping_ext_insert_mapping_promotes_value_to_yaml_mapping`]
35776 // on the sibling `insert_mapping` primitive's nested-Mapping-
35777 // promotion pin, and with
35778 // [`mapping_ext_insert_string_promotes_value_to_yaml_string`]
35779 // on the sibling `insert_string` primitive's scalar-promotion
35780 // pin.
35781 let inner = vec![
35782 serde_yaml::Value::String("hello".into()),
35783 serde_yaml::Value::String("world".into()),
35784 ];
35785 let mut m = serde_yaml::Mapping::new();
35786 let prior = m.insert_sequence(GATEWAY_API_KEY_HOSTNAMES, inner.clone());
35787 assert!(
35788 prior.is_none(),
35789 "insert_sequence returns None on first insertion, mirroring \
35790 serde_yaml::Mapping::insert"
35791 );
35792 let got = m
35793 .get(GATEWAY_API_KEY_HOSTNAMES)
35794 .expect("inserted key is present under Value::Sequence promotion");
35795 assert_eq!(
35796 got,
35797 &serde_yaml::Value::Sequence(inner),
35798 "insert_sequence routes value verbatim through Value::Sequence \
35799 promotion"
35800 );
35801 }
35802
35803 #[test]
35804 fn mapping_ext_insert_sequence_returns_prior_value_on_replace() {
35805 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35806 // return contract: the prior value at that key, or `None` if
35807 // absent. Pin the replace-returns-prior semantic so a future
35808 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35809 // silently drop the prior-value handoff downstream consumers
35810 // may reach for. Peer with
35811 // [`mapping_ext_insert_mapping_returns_prior_value_on_replace`],
35812 // [`mapping_ext_insert_string_returns_prior_value_on_replace`],
35813 // and
35814 // [`mapping_ext_insert_str_key_returns_prior_value_on_replace`]
35815 // on the sibling primitive-quadruple members' replace-semantics
35816 // pins.
35817 let first: Vec<serde_yaml::Value> = vec![serde_yaml::Value::String("a".into())];
35818 let second: Vec<serde_yaml::Value> = vec![
35819 serde_yaml::Value::String("b".into()),
35820 serde_yaml::Value::String("c".into()),
35821 ];
35822 let mut m = serde_yaml::Mapping::new();
35823 m.insert_sequence(KUBE_KEY_RULES, first.clone());
35824 let prior = m.insert_sequence(KUBE_KEY_RULES, second.clone());
35825 assert_eq!(
35826 prior,
35827 Some(serde_yaml::Value::Sequence(first)),
35828 "insert_sequence returns the prior value when replacing an \
35829 existing key"
35830 );
35831 let got = m
35832 .get(KUBE_KEY_RULES)
35833 .expect("key is still present after replace");
35834 assert_eq!(
35835 got,
35836 &serde_yaml::Value::Sequence(second),
35837 "replaced value is now the most-recently-inserted one"
35838 );
35839 }
35840
35841 #[test]
35842 fn mapping_ext_insert_sequence_matches_hand_written_promotion() {
35843 // Cross-check the trait method against the hand-written
35844 // `mapping.insert_str_key(KEY, Value::Sequence(v))` shape the 4
35845 // lifted call sites previously carried. A drift between the
35846 // trait method's promotion and the inline promotion would
35847 // silently emit a different YAML mapping (a differently-wrapped
35848 // outer variant, a differently-shaped inner sequence) at every
35849 // routed consumer — pin the equivalence so the trait remains a
35850 // drop-in replacement. Three cases pin the shape end-to-end:
35851 // an empty inner Vec (no silent is_empty short-circuit), a
35852 // singleton-Value inner Vec (the `fromEndpoints[<selector>]` /
35853 // `hostnames[<host>]` singleton shape), and a multi-Value inner
35854 // Vec (the `toPorts[…]` / `rules[…]` multi-entry shape).
35855 let inner_empty: Vec<serde_yaml::Value> = Vec::new();
35856 let inner_singleton: Vec<serde_yaml::Value> =
35857 vec![serde_yaml::Value::String("example.com".into())];
35858 let mut host_entry = serde_yaml::Mapping::new();
35859 host_entry.insert_string(KUBE_KEY_NAME, "svc-a");
35860 let mut port_entry = serde_yaml::Mapping::new();
35861 port_entry.insert_string(KUBE_KEY_NAME, "svc-b");
35862 let inner_multi: Vec<serde_yaml::Value> = vec![
35863 serde_yaml::Value::Mapping(host_entry.clone()),
35864 serde_yaml::Value::Mapping(port_entry.clone()),
35865 ];
35866
35867 let mut via_trait = serde_yaml::Mapping::new();
35868 via_trait.insert_sequence(CILIUM_KEY_TO_PORTS, inner_empty.clone());
35869 via_trait.insert_sequence(GATEWAY_API_KEY_HOSTNAMES, inner_singleton.clone());
35870 via_trait.insert_sequence(KUBE_KEY_RULES, inner_multi.clone());
35871
35872 let mut via_inline = serde_yaml::Mapping::new();
35873 via_inline.insert_str_key(
35874 CILIUM_KEY_TO_PORTS,
35875 serde_yaml::Value::Sequence(inner_empty),
35876 );
35877 via_inline.insert_str_key(
35878 GATEWAY_API_KEY_HOSTNAMES,
35879 serde_yaml::Value::Sequence(inner_singleton),
35880 );
35881 via_inline.insert_str_key(KUBE_KEY_RULES, serde_yaml::Value::Sequence(inner_multi));
35882
35883 assert_eq!(
35884 via_trait, via_inline,
35885 "insert_sequence(KEY, v) must byte-equal \
35886 insert_str_key(KEY, Value::Sequence(v)) — otherwise the \
35887 four routed consumer sites drift silently at emit time"
35888 );
35889 }
35890
35891 // ── insert_singleton_mapping_sequence — composed primitive ───────────
35892 //
35893 // The trait method composes [`Self::insert_str_key`] with
35894 // [`singleton_mapping_sequence`]: every hand-inline
35895 // `mapping.insert_str_key(K, singleton_mapping_sequence(m))` two-symbol
35896 // composition previously carried at 7 sites across caixa-mesh
35897 // collapses onto one method call. Three peer pins pin the trait
35898 // method's shape end-to-end.
35899
35900 #[test]
35901 fn mapping_ext_insert_singleton_mapping_sequence_promotes_value_to_singleton_mapping_seq() {
35902 // First-insertion returns None (mirroring [`Mapping::insert`])
35903 // and the inserted value is a `Value::Sequence` of exactly one
35904 // element, wrapping the caller's Mapping as `Value::Mapping`.
35905 // Peer with the sibling
35906 // `mapping_ext_insert_sequence_promotes_value_to_yaml_sequence`
35907 // / `mapping_ext_insert_mapping_promotes_value_to_yaml_mapping`
35908 // / `mapping_ext_insert_string_promotes_value_to_yaml_string`
35909 // first-insert pins on the sibling MappingExt primitive
35910 // members.
35911 let mut inner = serde_yaml::Mapping::new();
35912 inner.insert_str_key(
35913 GATEWAY_API_KEY_NAME,
35914 serde_yaml::Value::String("gw-listener".into()),
35915 );
35916 let mut m = serde_yaml::Mapping::new();
35917 let prior = m.insert_singleton_mapping_sequence(GATEWAY_API_KEY_LISTENERS, inner.clone());
35918 assert_eq!(
35919 prior, None,
35920 "insert_singleton_mapping_sequence returns None on first insertion, \
35921 mirroring serde_yaml::Mapping::insert"
35922 );
35923 let got = m
35924 .get(GATEWAY_API_KEY_LISTENERS)
35925 .expect("inserted key is present under Value::Sequence promotion");
35926 assert_eq!(
35927 got,
35928 &serde_yaml::Value::Sequence(vec![serde_yaml::Value::Mapping(inner)]),
35929 "insert_singleton_mapping_sequence routes value verbatim through \
35930 the singleton_mapping_sequence(_) helper wrap"
35931 );
35932 }
35933
35934 #[test]
35935 fn mapping_ext_insert_singleton_mapping_sequence_returns_prior_value_on_replace() {
35936 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35937 // return contract: the prior value at that key, or `None` if
35938 // absent. Pin the replace-returns-prior semantic so a future
35939 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35940 // silently drop the prior-value handoff downstream consumers
35941 // may reach for. Peer with the sibling
35942 // `mapping_ext_insert_sequence_returns_prior_value_on_replace`
35943 // and its siblings on the primitive-quintuple axis.
35944 let mut first = serde_yaml::Mapping::new();
35945 first.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("a".into()));
35946 let mut second = serde_yaml::Mapping::new();
35947 second.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("b".into()));
35948 let mut m = serde_yaml::Mapping::new();
35949 m.insert_singleton_mapping_sequence(GATEWAY_API_KEY_PARENT_REFS, first.clone());
35950 let prior =
35951 m.insert_singleton_mapping_sequence(GATEWAY_API_KEY_PARENT_REFS, second.clone());
35952 assert_eq!(
35953 prior,
35954 Some(serde_yaml::Value::Sequence(vec![
35955 serde_yaml::Value::Mapping(first)
35956 ])),
35957 "insert_singleton_mapping_sequence returns the prior value \
35958 when replacing an existing key"
35959 );
35960 let got = m
35961 .get(GATEWAY_API_KEY_PARENT_REFS)
35962 .expect("key is still present after replace");
35963 assert_eq!(
35964 got,
35965 &serde_yaml::Value::Sequence(vec![serde_yaml::Value::Mapping(second)]),
35966 "replaced value is now the most-recently-inserted singleton \
35967 mapping sequence"
35968 );
35969 }
35970
35971 #[test]
35972 fn mapping_ext_insert_singleton_mapping_sequence_matches_hand_written_composition() {
35973 // Cross-check the trait method against the hand-written
35974 // `mapping.insert_str_key(KEY, singleton_mapping_sequence(m))`
35975 // two-symbol composition the 7 lifted call sites previously
35976 // carried. A drift between the trait method's routing and the
35977 // inline composition would silently emit a different YAML
35978 // mapping (a differently-wrapped outer variant, a
35979 // differently-shaped inner singleton-Mapping list) at every
35980 // routed consumer — pin the equivalence so the trait remains a
35981 // drop-in replacement. Three cases pin the shape end-to-end:
35982 // an empty inner Mapping (no silent is_empty short-circuit,
35983 // matches the sibling `singleton_mapping_sequence_preserves_empty_inner_mapping`
35984 // pin), a single-key inner Mapping (the
35985 // `CILIUM_KEY_HTTP` / `CILIUM_KEY_INGRESS` singleton-rule
35986 // shape), and a multi-key inner Mapping (the
35987 // `GATEWAY_API_KEY_LISTENERS` per-listener shape).
35988 let inner_empty = serde_yaml::Mapping::new();
35989 let mut inner_single_key = serde_yaml::Mapping::new();
35990 inner_single_key
35991 .insert_str_key(CILIUM_KEY_PATH, serde_yaml::Value::String("/health".into()));
35992 let mut inner_multi_key = serde_yaml::Mapping::new();
35993 inner_multi_key.insert_str_key(
35994 GATEWAY_API_KEY_NAME,
35995 serde_yaml::Value::String("http".into()),
35996 );
35997 inner_multi_key.insert_str_key(
35998 KUBE_KEY_PORT,
35999 serde_yaml::Value::Number(GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT.into()),
36000 );
36001
36002 let mut via_trait = serde_yaml::Mapping::new();
36003 via_trait.insert_singleton_mapping_sequence(CILIUM_KEY_HTTP, inner_empty.clone());
36004 via_trait.insert_singleton_mapping_sequence(CILIUM_KEY_INGRESS, inner_single_key.clone());
36005 via_trait
36006 .insert_singleton_mapping_sequence(GATEWAY_API_KEY_LISTENERS, inner_multi_key.clone());
36007
36008 let mut via_inline = serde_yaml::Mapping::new();
36009 via_inline.insert_str_key(CILIUM_KEY_HTTP, singleton_mapping_sequence(inner_empty));
36010 via_inline.insert_str_key(
36011 CILIUM_KEY_INGRESS,
36012 singleton_mapping_sequence(inner_single_key),
36013 );
36014 via_inline.insert_str_key(
36015 GATEWAY_API_KEY_LISTENERS,
36016 singleton_mapping_sequence(inner_multi_key),
36017 );
36018
36019 assert_eq!(
36020 via_trait, via_inline,
36021 "insert_singleton_mapping_sequence(KEY, m) must byte-equal \
36022 insert_str_key(KEY, singleton_mapping_sequence(m)) — otherwise \
36023 the seven routed caixa-mesh consumer sites drift silently at \
36024 emit time"
36025 );
36026 }
36027
36028 // ── entry_str_key — entry-API twin of insert_str_key ─────────────────
36029
36030 #[test]
36031 fn mapping_ext_entry_str_key_or_inserts_default_under_yaml_string_promoted_key_when_absent() {
36032 // The trait method promotes an arbitrary `&str` key to
36033 // `Value::String(key.to_string())` on the entry-API axis — pin
36034 // the promotion + the entry-API contract so a future refactor
36035 // that reaches for a different `Value` variant for the entry
36036 // key (e.g. `Value::Tagged`) or breaks the entry-API
36037 // `.or_insert(...)` composition is a compile-visible break,
36038 // not a silent per-consumer regression at the 4 lifted
36039 // `caixa-flux` idempotent-upsert sites. Peer with the sibling
36040 // [`mapping_ext_insert_str_key_promotes_key_to_yaml_string`] on
36041 // the fresh-emit axis of the same key promotion.
36042 let mut m = serde_yaml::Mapping::new();
36043 let default_val = serde_yaml::Value::Sequence(Vec::new());
36044 let inserted = m.entry_str_key("programs").or_insert(default_val.clone());
36045 assert_eq!(
36046 inserted, &default_val,
36047 "entry_str_key(K).or_insert(D) returns &mut D on the absent-key \
36048 path, mirroring serde_yaml::mapping::Entry::or_insert"
36049 );
36050 // Key is exactly the `Value::String` promotion of the input.
36051 let got = m
36052 .get("programs")
36053 .expect("or_insert-defaulted key is present under Value::String promotion");
36054 assert_eq!(
36055 got, &default_val,
36056 "entry_str_key routes the default verbatim to the underlying \
36057 serde_yaml::Mapping::entry(...).or_insert(...) path"
36058 );
36059 }
36060
36061 #[test]
36062 fn mapping_ext_entry_str_key_leaves_prior_value_untouched_on_or_insert_when_present() {
36063 // The trait method mirrors [`serde_yaml::mapping::Entry::or_insert`]'s
36064 // present-key contract: the prior value is preserved, and the
36065 // returned `&mut Value` points at that prior value (NOT the
36066 // discarded default). Pin the leave-prior-untouched semantic so a
36067 // future refactor that swaps to an `.insert`-style overwrite
36068 // flow doesn't silently clobber every idempotent-upsert consumer
36069 // (the M4 per-`:politicas` overlay merger, the `feira app
36070 // deploy` idempotent-write dry-run comparator). Peer with the
36071 // sibling [`mapping_ext_insert_str_key_returns_prior_value_on_replace`]
36072 // pin on the fresh-emit axis (which mirrors the `insert`
36073 // replace-and-return-prior semantic, not the `entry.or_insert`
36074 // preserve-prior semantic — the two APIs partition the
36075 // `Mapping`-write surface exactly on this axis).
36076 let mut m = serde_yaml::Mapping::new();
36077 m.insert_str_key(
36078 FLEET_PROGRAMS_KEY_PROGRAMS,
36079 serde_yaml::Value::Sequence(vec![serde_yaml::Value::String("existing".into())]),
36080 );
36081 let discarded_default = serde_yaml::Value::Sequence(Vec::new());
36082 let returned = m
36083 .entry_str_key(FLEET_PROGRAMS_KEY_PROGRAMS)
36084 .or_insert(discarded_default);
36085 assert_eq!(
36086 returned,
36087 &serde_yaml::Value::Sequence(vec![serde_yaml::Value::String("existing".into())]),
36088 "entry_str_key(K).or_insert(D) returns &mut prior on the \
36089 present-key path — the discarded default must not overwrite \
36090 the emitter's prior write"
36091 );
36092 // Value at the key is still the pre-existing one, verbatim.
36093 let got = m
36094 .get(FLEET_PROGRAMS_KEY_PROGRAMS)
36095 .expect("key is still present after or_insert on the present-key path");
36096 assert_eq!(
36097 got,
36098 &serde_yaml::Value::Sequence(vec![serde_yaml::Value::String("existing".into())]),
36099 "or_insert on the present-key path preserves the prior value \
36100 verbatim — no clobber, no reshape"
36101 );
36102 }
36103
36104 #[test]
36105 fn mapping_ext_entry_str_key_matches_hand_written_composition() {
36106 // Cross-check the trait method against the hand-written
36107 // `mapping.entry(Value::String(KEY.into()))` three-token
36108 // composition the 4 lifted `caixa-flux` call sites previously
36109 // carried. A drift between the trait method's promotion and the
36110 // inline promotion the prior call sites used would silently
36111 // route every idempotent-upsert consumer past a different bucket
36112 // (a differently-promoted key on absent-key insert, a hash-key
36113 // mismatch that always fires the `or_insert` default even when
36114 // the emitter's `insert_str_key` already wrote a value under
36115 // the same key). Two cases pin the shape end-to-end: an
36116 // absent-key path (both routes take the vacant `or_insert`
36117 // branch, both end up storing the same default under the
36118 // promoted key) and a present-key path (both routes take the
36119 // occupied `or_insert` branch, both leave the prior value
36120 // untouched — the twin of the
36121 // `mapping_ext_insert_str_key_matches_hand_written_promotion`
36122 // pin on the fresh-emit axis).
36123 //
36124 // Absent-key path — the vacant `or_insert` branch.
36125 let mut via_trait_absent = serde_yaml::Mapping::new();
36126 via_trait_absent
36127 .entry_str_key(FLEET_PROGRAMS_KEY_PROGRAMS)
36128 .or_insert(serde_yaml::Value::Sequence(Vec::new()));
36129 let mut via_inline_absent = serde_yaml::Mapping::new();
36130 via_inline_absent
36131 .entry(serde_yaml::Value::String(
36132 FLEET_PROGRAMS_KEY_PROGRAMS.into(),
36133 ))
36134 .or_insert(serde_yaml::Value::Sequence(Vec::new()));
36135 assert_eq!(
36136 via_trait_absent, via_inline_absent,
36137 "entry_str_key(K).or_insert(D) must byte-equal \
36138 entry(Value::String(K.into())).or_insert(D) on the absent-key \
36139 path — otherwise the 4 routed caixa-flux consumer sites \
36140 land the default under a different bucket than the emitter's \
36141 `insert_str_key` write and the idempotent-upsert semantic \
36142 silently doubles the entry on every call"
36143 );
36144
36145 // Present-key path — the occupied `or_insert` branch. Seed both
36146 // mappings via the fresh-emit `insert_str_key` peer (which the
36147 // `matches_hand_written_promotion` pin already gates), so the
36148 // present-key path here inherits the promotion-agreement guarantee
36149 // from that peer and tests only the entry-API branch difference.
36150 let seed = serde_yaml::Value::Mapping(serde_yaml::Mapping::new());
36151 let mut via_trait_present = serde_yaml::Mapping::new();
36152 via_trait_present.insert_str_key(FLUX_KEY_VALUES, seed.clone());
36153 via_trait_present
36154 .entry_str_key(FLUX_KEY_VALUES)
36155 .or_insert(serde_yaml::Value::Sequence(Vec::new()));
36156 let mut via_inline_present = serde_yaml::Mapping::new();
36157 via_inline_present.insert_str_key(FLUX_KEY_VALUES, seed);
36158 via_inline_present
36159 .entry(serde_yaml::Value::String(FLUX_KEY_VALUES.into()))
36160 .or_insert(serde_yaml::Value::Sequence(Vec::new()));
36161 assert_eq!(
36162 via_trait_present, via_inline_present,
36163 "entry_str_key(K).or_insert(D) must byte-equal \
36164 entry(Value::String(K.into())).or_insert(D) on the \
36165 present-key path — otherwise a promoted-key mismatch would \
36166 cause the trait routing to see the seed as absent and \
36167 overwrite the emitter's prior write while the hand-written \
36168 inline routing sees it as present and preserves it (or vice \
36169 versa)"
36170 );
36171 }
36172
36173 // ── entry_or_default_{mapping,sequence} — entry-API-with-container-check ─
36174
36175 #[test]
36176 fn mapping_ext_entry_or_default_mapping_seeds_empty_inner_when_absent() {
36177 // Absent-key path — the helper mints an empty
36178 // `Value::Mapping(Mapping::new())` under the promoted key and
36179 // returns `Some(&mut inner)` pointing at the fresh empty inner.
36180 // Pin the seed shape so a future refactor that reaches for a
36181 // different empty-container variant (e.g. `Value::Null`, or a
36182 // `Mapping::with_capacity(_)` non-empty pre-allocation) or
36183 // breaks the `Option::Some` return contract is a compile-visible
36184 // break, not a silent per-consumer regression at the caixa-flux
36185 // `upsert_into_helmrelease_programs` `spec.values` container-
36186 // upsert. Peer with the sibling
36187 // [`mapping_ext_entry_or_default_sequence_seeds_empty_inner_when_absent`]
36188 // on the sibling list-container axis.
36189 let mut m = serde_yaml::Mapping::new();
36190 {
36191 let inner = m
36192 .entry_or_default_mapping(FLUX_KEY_VALUES)
36193 .expect("absent-key path seeds an empty Mapping and returns Some(&mut _)");
36194 assert!(
36195 inner.is_empty(),
36196 "the seeded default must be an EMPTY Mapping — a \
36197 non-empty pre-allocation would land a K8s CRD schema \
36198 pre-populated block the emitter never authored"
36199 );
36200 }
36201 // Key is exactly the `Value::String` promotion of the input,
36202 // and the value is the empty-Mapping seed.
36203 let got = m
36204 .get(FLUX_KEY_VALUES)
36205 .expect("or_default seeded the key under Value::String promotion");
36206 assert_eq!(
36207 got,
36208 &serde_yaml::Value::Mapping(serde_yaml::Mapping::new()),
36209 "entry_or_default_mapping seeds Value::Mapping(Mapping::new()) \
36210 verbatim on the absent-key arm — no reshape, no wrap"
36211 );
36212 }
36213
36214 #[test]
36215 fn mapping_ext_entry_or_default_mapping_preserves_prior_mapping_on_present_arm() {
36216 // Present-key path with matching variant — the helper mirrors
36217 // [`serde_yaml::mapping::Entry::or_insert_with`]'s occupied
36218 // branch: the prior value is preserved, and the returned
36219 // `&mut Mapping` points at that prior inner Mapping (NOT a
36220 // fresh empty default). Pin the leave-prior-untouched semantic
36221 // so a future refactor that reaches for an `.insert`-style
36222 // overwrite flow doesn't silently clobber every idempotent-
36223 // container-upsert consumer (the `feira app deploy` per-cluster
36224 // write path, the M4 per-cluster HelmRelease overlay merger).
36225 let mut m = serde_yaml::Mapping::new();
36226 let mut prior_inner = serde_yaml::Mapping::new();
36227 prior_inner.insert_str_key(HELM_VALUES_KEY_ENABLED, serde_yaml::Value::Bool(true));
36228 m.insert_mapping(FLUX_KEY_VALUES, prior_inner.clone());
36229 {
36230 let inner = m
36231 .entry_or_default_mapping(FLUX_KEY_VALUES)
36232 .expect("present-Mapping-variant path returns Some(&mut prior)");
36233 assert_eq!(
36234 inner, &prior_inner,
36235 "entry_or_default_mapping returns &mut prior on the \
36236 present-key path — the default empty Mapping must not \
36237 overwrite the emitter's prior write"
36238 );
36239 }
36240 // Value at the key is still the pre-existing one, verbatim.
36241 let got = m
36242 .get(FLUX_KEY_VALUES)
36243 .expect("key is still present after or_default on the present-key path");
36244 assert_eq!(
36245 got,
36246 &serde_yaml::Value::Mapping(prior_inner),
36247 "or_default on the present-key path preserves the prior \
36248 value verbatim — no clobber, no reshape"
36249 );
36250 }
36251
36252 #[test]
36253 fn mapping_ext_entry_or_default_mapping_returns_none_on_variant_mismatch() {
36254 // Present-key path with mismatched variant — the helper returns
36255 // `None`, letting the caller surface its domain-specific
36256 // "expected Mapping at this schema key" diagnostic (rather than
36257 // silently clobbering the mismatched prior value). Pin the
36258 // structural-mismatch-is-None contract so a future refactor
36259 // that reaches for a fallback-to-empty-default flow doesn't
36260 // silently overwrite user-authored non-Mapping data at the
36261 // canonical caixa-flux `Error::MissingField("spec.values must
36262 // be a mapping")` site — the mismatched-variant arm is
36263 // load-bearing for the domain-error diagnostic path, not just
36264 // a corner case.
36265 let mut m = serde_yaml::Mapping::new();
36266 m.insert_string(FLUX_KEY_VALUES, "not-a-mapping");
36267 let result = m.entry_or_default_mapping(FLUX_KEY_VALUES);
36268 assert!(
36269 result.is_none(),
36270 "entry_or_default_mapping returns None on variant \
36271 mismatch — the caller's `.ok_or(Error::MissingField(_))?` \
36272 chain surfaces the structural type-mismatch diagnostic"
36273 );
36274 let got = m
36275 .get(FLUX_KEY_VALUES)
36276 .expect("mismatched-variant prior value stays present after variant-check");
36277 assert_eq!(
36278 got,
36279 &serde_yaml::Value::String("not-a-mapping".into()),
36280 "None arm on variant mismatch leaves the prior value \
36281 untouched — the caller's domain-error path fires without \
36282 clobbering the user-authored data"
36283 );
36284 }
36285
36286 #[test]
36287 fn mapping_ext_entry_or_default_sequence_seeds_empty_inner_when_absent() {
36288 // Absent-key path — the helper mints an empty
36289 // `Value::Sequence(Vec::new())` under the promoted key and
36290 // returns `Some(&mut inner)` pointing at the fresh empty
36291 // `Vec<Value>`. Peer with
36292 // [`mapping_ext_entry_or_default_mapping_seeds_empty_inner_when_absent`]
36293 // on the nested-Mapping-container axis.
36294 let mut m = serde_yaml::Mapping::new();
36295 {
36296 let inner = m
36297 .entry_or_default_sequence(FLEET_PROGRAMS_KEY_PROGRAMS)
36298 .expect("absent-key path seeds an empty Vec and returns Some(&mut _)");
36299 assert!(
36300 inner.is_empty(),
36301 "the seeded default must be an EMPTY Vec — a non-empty \
36302 pre-allocation would land a pre-populated fleet-programs \
36303 list the emitter never authored"
36304 );
36305 }
36306 let got = m
36307 .get(FLEET_PROGRAMS_KEY_PROGRAMS)
36308 .expect("or_default seeded the key under Value::String promotion");
36309 assert_eq!(
36310 got,
36311 &serde_yaml::Value::Sequence(Vec::new()),
36312 "entry_or_default_sequence seeds Value::Sequence(Vec::new()) \
36313 verbatim on the absent-key arm — no reshape, no wrap"
36314 );
36315 }
36316
36317 #[test]
36318 fn mapping_ext_entry_or_default_sequence_preserves_prior_sequence_on_present_arm() {
36319 // Present-key path with matching variant — the helper mirrors
36320 // [`serde_yaml::mapping::Entry::or_insert_with`]'s occupied
36321 // branch: the prior `Vec` is preserved, and the returned
36322 // `&mut Vec<Value>` points at that prior inner Vec (NOT a
36323 // fresh empty default). The exact idempotent-upsert semantic
36324 // caixa-flux's `upsert_into_programs_yaml` /
36325 // `upsert_into_helmrelease_programs` depend on to preserve
36326 // prior `programs[]` entries across per-Servico rewrites.
36327 let mut m = serde_yaml::Mapping::new();
36328 let prior_inner = vec![serde_yaml::Value::String("existing".into())];
36329 m.insert_sequence(FLEET_PROGRAMS_KEY_PROGRAMS, prior_inner.clone());
36330 {
36331 let inner = m
36332 .entry_or_default_sequence(FLEET_PROGRAMS_KEY_PROGRAMS)
36333 .expect("present-Sequence-variant path returns Some(&mut prior)");
36334 assert_eq!(
36335 inner, &prior_inner,
36336 "entry_or_default_sequence returns &mut prior on the \
36337 present-key path — the default empty Vec must not \
36338 overwrite the emitter's prior write"
36339 );
36340 }
36341 let got = m
36342 .get(FLEET_PROGRAMS_KEY_PROGRAMS)
36343 .expect("key is still present after or_default on the present-key path");
36344 assert_eq!(
36345 got,
36346 &serde_yaml::Value::Sequence(prior_inner),
36347 "or_default on the present-key path preserves the prior \
36348 value verbatim — no clobber, no reshape"
36349 );
36350 }
36351
36352 #[test]
36353 fn mapping_ext_entry_or_default_sequence_returns_none_on_variant_mismatch() {
36354 // Present-key path with mismatched variant — the helper returns
36355 // `None`, letting the caller surface its domain-specific
36356 // "programs must be a sequence" diagnostic (rather than
36357 // silently clobbering the mismatched prior value). Pin the
36358 // structural-mismatch-is-None contract so a future refactor
36359 // that reaches for a fallback-to-empty-default flow doesn't
36360 // silently overwrite user-authored non-Sequence data at the
36361 // canonical caixa-flux `Error::MissingField("programs must be
36362 // a sequence")` site.
36363 let mut m = serde_yaml::Mapping::new();
36364 m.insert_string(FLEET_PROGRAMS_KEY_PROGRAMS, "not-a-sequence");
36365 let result = m.entry_or_default_sequence(FLEET_PROGRAMS_KEY_PROGRAMS);
36366 assert!(
36367 result.is_none(),
36368 "entry_or_default_sequence returns None on variant \
36369 mismatch — the caller's `.ok_or(Error::MissingField(_))?` \
36370 chain surfaces the structural type-mismatch diagnostic"
36371 );
36372 let got = m
36373 .get(FLEET_PROGRAMS_KEY_PROGRAMS)
36374 .expect("mismatched-variant prior value stays present after variant-check");
36375 assert_eq!(
36376 got,
36377 &serde_yaml::Value::String("not-a-sequence".into()),
36378 "None arm on variant mismatch leaves the prior value \
36379 untouched — the caller's domain-error path fires without \
36380 clobbering the user-authored data"
36381 );
36382 }
36383
36384 // ── insert_str_key_if_some — arity-0-or-1 twin of insert_str_key ─────
36385
36386 #[test]
36387 fn mapping_ext_insert_str_key_if_some_none_arm_leaves_mapping_untouched() {
36388 // The None arm skips the insert entirely — no clone, no
36389 // key-promotion, no bucket touch. Pin the no-op semantic so a
36390 // future refactor that reaches for an `Option::unwrap_or_default`
36391 // shape (which would emit `Value::Null` under the key on the
36392 // None arm) or an `.into_iter().for_each` scaffold (which would
36393 // still walk the bucket-lookup path) is a compile-visible break,
36394 // not a silent per-consumer regression at the 3 lifted
36395 // `caixa-mesh` overlay-insert sites (where the `None` arm is
36396 // the author's default when no `:politicas` slot is set — a
36397 // silent `Value::Null` emission would land a K8s CRD schema
36398 // rejection at every unset-slot Aplicacao).
36399 let mut m = serde_yaml::Mapping::new();
36400 let prior = m.insert_str_key_if_some(CILIUM_KEY_AUTHENTICATION, None);
36401 assert_eq!(
36402 prior, None,
36403 "insert_str_key_if_some(K, None) returns None — no insert \
36404 fires, so no prior value can be surfaced"
36405 );
36406 assert!(
36407 m.get(CILIUM_KEY_AUTHENTICATION).is_none(),
36408 "None arm must leave the key absent — a silent `Value::Null` \
36409 insertion would land a K8s CRD schema rejection at every \
36410 `:politicas`-unset Aplicacao"
36411 );
36412 assert_eq!(
36413 m.len(),
36414 0,
36415 "None arm must not touch any bucket — the Mapping stays \
36416 empty verbatim"
36417 );
36418 }
36419
36420 #[test]
36421 fn mapping_ext_insert_str_key_if_some_some_arm_promotes_key_to_yaml_string() {
36422 // The Some arm clones the borrowed inner value and delegates to
36423 // [`Self::insert_str_key`] — pin the promotion + the first-
36424 // insert-returns-None contract so a future refactor that reaches
36425 // for a different `Value` variant for the key (e.g.
36426 // `Value::Tagged`) or breaks the underlying
36427 // [`serde_yaml::Mapping::insert`] return contract is a compile-
36428 // visible break, not a silent per-consumer regression at the 3
36429 // lifted `caixa-mesh` overlay-insert sites. Peer with the sibling
36430 // [`mapping_ext_insert_str_key_promotes_key_to_yaml_string`] on
36431 // the always-1 arity axis of the same key promotion.
36432 let mut m = serde_yaml::Mapping::new();
36433 let overlay = serde_yaml::Value::Mapping({
36434 let mut inner = serde_yaml::Mapping::new();
36435 inner.insert_str_key(
36436 CILIUM_KEY_MODE,
36437 serde_yaml::Value::String("required".into()),
36438 );
36439 inner
36440 });
36441 let prior = m.insert_str_key_if_some(CILIUM_KEY_AUTHENTICATION, Some(&overlay));
36442 assert_eq!(
36443 prior, None,
36444 "insert_str_key_if_some(K, Some(&V)) returns None on first \
36445 insertion, mirroring serde_yaml::Mapping::insert"
36446 );
36447 // Key is exactly the `Value::String` promotion of the input.
36448 let got = m
36449 .get(CILIUM_KEY_AUTHENTICATION)
36450 .expect("Some arm inserts under the Value::String-promoted key");
36451 assert_eq!(
36452 got, &overlay,
36453 "insert_str_key_if_some routes the borrowed inner value \
36454 through a `.clone()` verbatim to the underlying \
36455 `insert_str_key` path — no reshape, no wrap, no unwrap"
36456 );
36457 // The borrowed input is untouched — the caller can reuse the
36458 // outer overlay binding across the next iteration of a per-
36459 // `(:de, :para)` loop (the exact reuse the three lifted
36460 // caixa-mesh sites depend on).
36461 assert!(
36462 overlay.get(CILIUM_KEY_MODE).is_some(),
36463 "insert_str_key_if_some must not move out of the borrowed \
36464 overlay — the caller-side outer binding stays available \
36465 for the next iteration of the enclosing per-`(:de, :para)` \
36466 or per-rule loop"
36467 );
36468 }
36469
36470 #[test]
36471 fn mapping_ext_insert_str_key_if_some_some_arm_returns_prior_value_on_replace() {
36472 // The Some arm mirrors [`serde_yaml::Mapping::insert`]'s return
36473 // contract on the replace-existing path: the prior value at that
36474 // key, surfaced verbatim. Pin the replace-returns-prior semantic
36475 // so a future refactor that reaches for an `entry.or_insert`-
36476 // style preserve-prior flow doesn't silently swap the axis's
36477 // semantic under the three routed caixa-mesh overlay sites (the
36478 // `:politicas` overlay is meant to override an author-provided
36479 // sub-block if one was present, not preserve it — the
36480 // replace-and-return-prior semantic is load-bearing).
36481 let mut m = serde_yaml::Mapping::new();
36482 let existing = serde_yaml::Value::String("cluster-default".into());
36483 let overlay = serde_yaml::Value::Mapping({
36484 let mut inner = serde_yaml::Mapping::new();
36485 inner.insert_str_key(
36486 GATEWAY_API_KEY_REQUEST,
36487 serde_yaml::Value::String("30s".into()),
36488 );
36489 inner
36490 });
36491 m.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36492 let prior = m.insert_str_key_if_some(GATEWAY_API_KEY_TIMEOUTS, Some(&overlay));
36493 assert_eq!(
36494 prior,
36495 Some(existing),
36496 "insert_str_key_if_some(K, Some(&V)) returns the prior value \
36497 when replacing an existing key — the overlay overrides the \
36498 author-provided sub-block; the prior value surfaces so the \
36499 caller can log/compare/roll back if needed"
36500 );
36501 // Value at the key is now the overlay, verbatim.
36502 let got = m
36503 .get(GATEWAY_API_KEY_TIMEOUTS)
36504 .expect("key is still present after replace");
36505 assert_eq!(
36506 got, &overlay,
36507 "replaced value is now the most-recently-inserted overlay — \
36508 the Some arm carries through to the underlying \
36509 `insert_str_key` replace path"
36510 );
36511 }
36512
36513 #[test]
36514 fn mapping_ext_insert_str_key_if_some_matches_hand_written_composition() {
36515 // Cross-check the trait method against the hand-written
36516 // `if let Some(x) = &overlay { m.insert_str_key(K, x.clone()); }`
36517 // three-line block the 3 lifted `caixa-mesh` overlay call sites
36518 // previously carried. A drift between the trait method's
36519 // conditional-insert routing and the inline `if let Some`
36520 // composition would silently emit a different Mapping (a
36521 // present-key `Value::Null` on the None arm, a different clone-
36522 // vs-move policy on the Some arm) at every routed consumer —
36523 // pin the equivalence so the trait remains a drop-in replacement.
36524 // Four cases pin the shape end-to-end: None arm (skip), Some
36525 // arm on absent key (fresh insert), Some arm on present key
36526 // (replace-and-return-prior), None arm on present key (no
36527 // touch — the axis's load-bearing "author's value wins when
36528 // overlay is unset" contract).
36529 let overlay = serde_yaml::Value::Mapping({
36530 let mut inner = serde_yaml::Mapping::new();
36531 inner.insert_str_key(
36532 CILIUM_KEY_MODE,
36533 serde_yaml::Value::String("required".into()),
36534 );
36535 inner
36536 });
36537
36538 // Case 1: None arm on empty mapping — both routes no-op.
36539 let mut via_trait_none = serde_yaml::Mapping::new();
36540 via_trait_none.insert_str_key_if_some(CILIUM_KEY_AUTHENTICATION, None);
36541 let via_inline_none = serde_yaml::Mapping::new();
36542 let overlay_slot_none: Option<serde_yaml::Value> = None;
36543 let mut via_inline_none_mut = via_inline_none.clone();
36544 if let Some(a) = &overlay_slot_none {
36545 via_inline_none_mut.insert_str_key(CILIUM_KEY_AUTHENTICATION, a.clone());
36546 }
36547 assert_eq!(
36548 via_trait_none, via_inline_none_mut,
36549 "insert_str_key_if_some(K, None) must byte-equal \
36550 `if let Some(_) = None {{ … }}` — the no-op arm must not \
36551 emit a stray `Value::Null` under the key"
36552 );
36553
36554 // Case 2: Some arm on empty mapping — both routes fresh-insert.
36555 let mut via_trait_some = serde_yaml::Mapping::new();
36556 via_trait_some.insert_str_key_if_some(CILIUM_KEY_AUTHENTICATION, Some(&overlay));
36557 let mut via_inline_some = serde_yaml::Mapping::new();
36558 let overlay_slot_some = Some(overlay.clone());
36559 if let Some(a) = &overlay_slot_some {
36560 via_inline_some.insert_str_key(CILIUM_KEY_AUTHENTICATION, a.clone());
36561 }
36562 assert_eq!(
36563 via_trait_some, via_inline_some,
36564 "insert_str_key_if_some(K, Some(&V)) must byte-equal \
36565 `if let Some(x) = &Some(V.clone()) {{ m.insert_str_key(K, \
36566 x.clone()); }}` on the fresh-insert path — same clone-and-\
36567 insert semantics under the same Value::String-promoted \
36568 bucket"
36569 );
36570
36571 // Case 3: Some arm on present key — both routes replace-and-
36572 // return-prior.
36573 let existing = serde_yaml::Value::String("cluster-default".into());
36574 let mut via_trait_replace = serde_yaml::Mapping::new();
36575 via_trait_replace.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36576 let trait_prior =
36577 via_trait_replace.insert_str_key_if_some(GATEWAY_API_KEY_TIMEOUTS, Some(&overlay));
36578 let mut via_inline_replace = serde_yaml::Mapping::new();
36579 via_inline_replace.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36580 let overlay_slot_replace = Some(overlay.clone());
36581 let inline_prior = if let Some(a) = &overlay_slot_replace {
36582 via_inline_replace.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, a.clone())
36583 } else {
36584 None
36585 };
36586 assert_eq!(
36587 trait_prior, inline_prior,
36588 "insert_str_key_if_some replace-and-return-prior must byte-\
36589 equal the hand-written `if let Some {{ insert_str_key }}` \
36590 composition's return"
36591 );
36592 assert_eq!(
36593 via_trait_replace, via_inline_replace,
36594 "insert_str_key_if_some replace-post-state must byte-equal \
36595 the hand-written composition's post-state — the overlay \
36596 overrode the author's value in both routes"
36597 );
36598
36599 // Case 4: None arm on present key — both routes preserve the
36600 // author's value verbatim. The load-bearing "author's value
36601 // wins when overlay is unset" contract the three lifted sites
36602 // depend on.
36603 let mut via_trait_preserve = serde_yaml::Mapping::new();
36604 via_trait_preserve.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36605 via_trait_preserve.insert_str_key_if_some(GATEWAY_API_KEY_TIMEOUTS, None);
36606 let mut via_inline_preserve = serde_yaml::Mapping::new();
36607 via_inline_preserve.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36608 let overlay_slot_preserve: Option<serde_yaml::Value> = None;
36609 if let Some(a) = &overlay_slot_preserve {
36610 via_inline_preserve.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, a.clone());
36611 }
36612 assert_eq!(
36613 via_trait_preserve, via_inline_preserve,
36614 "insert_str_key_if_some(K, None) on a present key must byte-\
36615 equal the hand-written `if let Some(_) = None {{ … }}` — \
36616 the None arm must preserve the author's value verbatim, \
36617 not clobber it with `Value::Null` or drop the key"
36618 );
36619 assert_eq!(
36620 via_trait_preserve
36621 .get(GATEWAY_API_KEY_TIMEOUTS)
36622 .expect("None arm preserves the pre-existing key"),
36623 &existing,
36624 "None arm on a present key surfaces the author's prior \
36625 value verbatim — the load-bearing contract the three \
36626 lifted `:politicas` overlay sites rest on"
36627 );
36628 }
36629
36630 // ── SequenceExt::push_mapping — Vec<Value>-side sibling ──────────────
36631
36632 #[test]
36633 fn sequence_ext_push_mapping_appends_promoted_mapping_value() {
36634 // The method appends the caller's `Mapping` as a fresh
36635 // `Value::Mapping(_)` element on the tail of `self`. Pin the
36636 // per-append routing (`.push(Value::Mapping(_))`) so a future
36637 // refactor that reaches for a different outer variant (a
36638 // Server-Side-Apply-typed `Value::Tagged`, a fresh singleton-list
36639 // wrap via `singleton_mapping_sequence`) or a different
36640 // Vec-mutation shape (e.g. `.insert(0, _)` shifting the axis
36641 // from append to prepend) is a compile-visible break, not a
36642 // silent per-consumer regression at the 4 lifted `caixa-mesh`
36643 // append sites — where the emission order is load-bearing (the
36644 // Cilium `spec.ingress[].toPorts[]` per-edge order, the
36645 // Gateway API `spec.rules[]` per-path order, the top-level CNP
36646 // and programs.yaml document order all depend on the append
36647 // semantics).
36648 let mut seq: Vec<serde_yaml::Value> = Vec::new();
36649 let mut m = serde_yaml::Mapping::new();
36650 m.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("first".into()));
36651 seq.push_mapping(m.clone());
36652 assert_eq!(
36653 seq.len(),
36654 1,
36655 "push_mapping must append exactly one element — the axis's \
36656 fresh-element semantic"
36657 );
36658 assert_eq!(
36659 seq[0],
36660 serde_yaml::Value::Mapping(m),
36661 "the appended element must be the caller's Mapping wrapped \
36662 verbatim as Value::Mapping — no reshape, no clone-and-drop"
36663 );
36664 }
36665
36666 #[test]
36667 fn sequence_ext_push_mapping_preserves_prior_elements_in_insertion_order() {
36668 // Successive push_mapping calls preserve the caller's per-
36669 // iteration order — the Vec grows at the tail, prior elements
36670 // stay at their prior indices. Pin the insertion-order semantic
36671 // so a future refactor that reaches for a per-append sort /
36672 // dedup / hoist-to-front reordering is a test-visible break,
36673 // not a silent behavior shift at the 4 lifted `caixa-mesh`
36674 // append sites (where THEORY.md §V.2.7 render determinism
36675 // pins the per-iteration emission order to the source
36676 // `:contratos` / `:paths` / `:membros` declaration order).
36677 let mut seq: Vec<serde_yaml::Value> = Vec::new();
36678 let mut first = serde_yaml::Mapping::new();
36679 first.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("a".into()));
36680 let mut second = serde_yaml::Mapping::new();
36681 second.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("b".into()));
36682 let mut third = serde_yaml::Mapping::new();
36683 third.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("c".into()));
36684 seq.push_mapping(first.clone());
36685 seq.push_mapping(second.clone());
36686 seq.push_mapping(third.clone());
36687 assert_eq!(
36688 seq.len(),
36689 3,
36690 "three push_mapping calls append three elements"
36691 );
36692 assert_eq!(
36693 seq,
36694 vec![
36695 serde_yaml::Value::Mapping(first),
36696 serde_yaml::Value::Mapping(second),
36697 serde_yaml::Value::Mapping(third),
36698 ],
36699 "push_mapping preserves per-iteration insertion order — the \
36700 axis's render-determinism contract at the 4 lifted \
36701 `caixa-mesh` append sites"
36702 );
36703 }
36704
36705 #[test]
36706 fn sequence_ext_push_mapping_matches_hand_written_composition() {
36707 // Cross-check the trait method against the hand-written
36708 // `<vec>.push(serde_yaml::Value::Mapping(<M>))` three-token
36709 // block the 4 lifted `caixa-mesh` append call sites previously
36710 // carried. A drift between the trait method's routing and the
36711 // inline `Value::Mapping(_)` promotion would silently emit a
36712 // different `Vec<Value>` (a different outer variant on the
36713 // appended element, a different length, a different order) at
36714 // every routed consumer — pin the equivalence so the trait
36715 // remains a drop-in replacement across the fresh-empty, prior-
36716 // populated, and empty-payload cases.
36717
36718 // Case 1: fresh-empty Vec + non-empty Mapping payload.
36719 let mut inner = serde_yaml::Mapping::new();
36720 inner.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("policy-a".into()));
36721 let mut via_trait: Vec<serde_yaml::Value> = Vec::new();
36722 via_trait.push_mapping(inner.clone());
36723 let mut via_inline: Vec<serde_yaml::Value> = Vec::new();
36724 via_inline.push(serde_yaml::Value::Mapping(inner.clone()));
36725 assert_eq!(
36726 via_trait, via_inline,
36727 "push_mapping(M) on empty Vec must byte-equal \
36728 `.push(Value::Mapping(M))` — same variant-promotion, same \
36729 append semantics"
36730 );
36731
36732 // Case 2: prior-populated Vec + non-empty Mapping payload — pin
36733 // that the append fires at the tail, not at the head or the
36734 // middle.
36735 let seed = serde_yaml::Value::String("seed".into());
36736 let mut via_trait_populated: Vec<serde_yaml::Value> = vec![seed.clone()];
36737 via_trait_populated.push_mapping(inner.clone());
36738 let mut via_inline_populated: Vec<serde_yaml::Value> = vec![seed];
36739 via_inline_populated.push(serde_yaml::Value::Mapping(inner.clone()));
36740 assert_eq!(
36741 via_trait_populated, via_inline_populated,
36742 "push_mapping(M) on populated Vec must byte-equal \
36743 `.push(Value::Mapping(M))` — the append fires at the tail, \
36744 prior elements stay at their prior indices"
36745 );
36746
36747 // Case 3: empty Mapping payload — the axis's "empty-vs-absent"
36748 // distinction the 4 lifted sites rest on. An empty inner
36749 // `Mapping` still round-trips as a `Value::Mapping(<empty>)`
36750 // element, not as a skipped no-op, because some K8s CRD schemas
36751 // (Cilium CNP `spec.ingress[].toPorts[].rules.http[]` with an
36752 // empty match set) require an empty inner object to distinguish
36753 // "explicitly-empty" from "absent".
36754 let mut via_trait_empty: Vec<serde_yaml::Value> = Vec::new();
36755 via_trait_empty.push_mapping(serde_yaml::Mapping::new());
36756 let mut via_inline_empty: Vec<serde_yaml::Value> = Vec::new();
36757 via_inline_empty.push(serde_yaml::Value::Mapping(serde_yaml::Mapping::new()));
36758 assert_eq!(
36759 via_trait_empty, via_inline_empty,
36760 "push_mapping(empty Mapping) must byte-equal \
36761 `.push(Value::Mapping(empty))` — no is_empty()-guarded \
36762 short-circuit, no skip"
36763 );
36764 assert_eq!(
36765 via_trait_empty.len(),
36766 1,
36767 "push_mapping on an empty Mapping still appends one element \
36768 — the axis carries no is_empty() short-circuit"
36769 );
36770 }
36771
36772 #[test]
36773 fn singleton_mapping_sequence_wraps_input_as_sole_element() {
36774 // The helper wraps its input `Mapping` as the single element of
36775 // a `Value::Sequence`. Pin the outer variant shape and the
36776 // exactly-one-element length so a future refactor that reaches
36777 // for a different container (e.g. `Value::Tagged`, a
36778 // 0-or-1-element `Option`-shaped emission axis) is a
36779 // compile-visible break, not a silent per-caller regression at
36780 // every K8s-CRD-list-shape-required emit site.
36781 let mut inner = serde_yaml::Mapping::new();
36782 inner.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("hello".into()));
36783 let out = singleton_mapping_sequence(inner.clone());
36784 match out {
36785 serde_yaml::Value::Sequence(seq) => {
36786 assert_eq!(
36787 seq.len(),
36788 1,
36789 "singleton_mapping_sequence emits exactly one element — \
36790 the K8s-CRD-list-shape-required singleton axis"
36791 );
36792 assert_eq!(
36793 seq[0],
36794 serde_yaml::Value::Mapping(inner),
36795 "the sole element must be the caller's Mapping wrapped \
36796 verbatim as Value::Mapping — no reshape, no clone-and-drop"
36797 );
36798 }
36799 other => panic!(
36800 "singleton_mapping_sequence must return Value::Sequence, got {other:?} — \
36801 an outer-variant drift breaks every K8s-CRD-list-shape consumer"
36802 ),
36803 }
36804 }
36805
36806 #[test]
36807 fn singleton_mapping_sequence_preserves_empty_inner_mapping() {
36808 // An empty inner `Mapping` still round-trips through the helper
36809 // as a `Value::Sequence(vec![Value::Mapping(<empty>)])` — the
36810 // helper carries no "skip-empty" short-circuit (empty-vs-absent
36811 // is the caller's decision; some K8s CRD schemas require an
36812 // empty inner object to distinguish "explicitly-empty" from
36813 // "absent"). Pin the shape so a future refactor that reaches
36814 // for an is_empty()-guarded short-circuit is a test-visible
36815 // break, not a silent behavior shift.
36816 let out = singleton_mapping_sequence(serde_yaml::Mapping::new());
36817 let seq = match out {
36818 serde_yaml::Value::Sequence(s) => s,
36819 other => panic!("expected Value::Sequence, got {other:?}"),
36820 };
36821 assert_eq!(seq.len(), 1, "empty inner still wraps as a 1-element seq");
36822 assert_eq!(
36823 seq[0],
36824 serde_yaml::Value::Mapping(serde_yaml::Mapping::new()),
36825 "the sole element is an empty Value::Mapping, verbatim"
36826 );
36827 }
36828
36829 #[test]
36830 fn singleton_mapping_sequence_byte_equals_hand_written_inline_shape() {
36831 // Cross-check the helper against the hand-written
36832 // `Value::Sequence(vec![Value::Mapping(m)])` three-token shape
36833 // the seven lifted call sites previously carried. A drift
36834 // between the helper's wrapping and the inline shape would
36835 // silently emit a different YAML sequence (a differently-shaped
36836 // outer variant, a differently-wrapped inner Mapping) at every
36837 // routed consumer — pin the byte-equivalence so the helper
36838 // remains a drop-in replacement.
36839 let mut inner = serde_yaml::Mapping::new();
36840 inner.insert_str_key(
36841 GATEWAY_API_KEY_NAME,
36842 serde_yaml::Value::String("gw-listener".into()),
36843 );
36844 inner.insert_str_key(
36845 KUBE_KEY_PORT,
36846 serde_yaml::Value::Number(GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT.into()),
36847 );
36848
36849 let via_helper = singleton_mapping_sequence(inner.clone());
36850 let via_inline = serde_yaml::Value::Sequence(vec![serde_yaml::Value::Mapping(inner)]);
36851
36852 assert_eq!(
36853 via_helper, via_inline,
36854 "singleton_mapping_sequence(m) must byte-equal \
36855 Value::Sequence(vec![Value::Mapping(m)]) — otherwise the \
36856 seven routed caixa-mesh call sites drift silently at emit time"
36857 );
36858 }
36859
36860 #[test]
36861 fn string_keyed_entries_yields_each_string_key_and_value_ref() {
36862 // The lift's load-bearing contract: given a Value::Mapping with
36863 // string keys, yield each `(&str, &Value)` pair in insertion
36864 // order. Both routed renderers (caixa-flux::programs_yaml_entry
36865 // and caixa-helm::build_values_yaml) depend on the yielded pair
36866 // shape to drive their per-destination insert — a drift in
36867 // yielded item type is a compile-visible break, not a silent
36868 // shape shift.
36869 let mut spec = serde_yaml::Mapping::new();
36870 spec.insert_str_key(
36871 COMPUTEUNIT_SPEC_KEY_MODULE,
36872 serde_yaml::Value::String("oci://…".into()),
36873 );
36874 spec.insert_str_key(
36875 COMPUTEUNIT_SPEC_KEY_TRIGGER,
36876 serde_yaml::Value::String("http".into()),
36877 );
36878 spec.insert_str_key(
36879 COMPUTEUNIT_SPEC_KEY_CAPABILITIES,
36880 serde_yaml::Value::Sequence(vec![]),
36881 );
36882 let v = serde_yaml::Value::Mapping(spec);
36883 let keys: Vec<&str> = string_keyed_entries(&v).map(|(k, _)| k).collect();
36884 assert_eq!(
36885 keys,
36886 vec![
36887 COMPUTEUNIT_SPEC_KEY_MODULE,
36888 COMPUTEUNIT_SPEC_KEY_TRIGGER,
36889 COMPUTEUNIT_SPEC_KEY_CAPABILITIES,
36890 ],
36891 "string_keyed_entries must yield every string-keyed entry in \
36892 the underlying Mapping's insertion order — both routed \
36893 renderers depend on `spec.module` reaching the destination \
36894 ahead of `spec.trigger` ahead of `spec.capabilities` so the \
36895 emitted values.yaml / programs.yaml entry's key order tracks \
36896 the upstream ComputeUnit YAML author's order"
36897 );
36898 // The paired &Value ref also reaches through — sanity-check on
36899 // the second axis of the yielded tuple.
36900 let module = string_keyed_entries(&v)
36901 .find(|(k, _)| *k == COMPUTEUNIT_SPEC_KEY_MODULE)
36902 .map(|(_, v)| v.clone())
36903 .expect("module entry present");
36904 assert_eq!(module, serde_yaml::Value::String("oci://…".into()));
36905 }
36906
36907 #[test]
36908 fn string_keyed_entries_short_circuits_on_non_mapping_shapes() {
36909 // The prior inline `if let Value::Mapping(_) = spec { … }` arm
36910 // silently no-oped on every non-Mapping shape (Null / String /
36911 // Sequence / Number / Bool). The lift's iterator surface pins
36912 // the same contract: a non-Mapping Value contributes zero
36913 // yielded entries. Pinned because both routed renderers'
36914 // "always splice `spec.*` if it's a Mapping, otherwise skip"
36915 // contract is upstream-schema-validated at the ComputeUnit CRD
36916 // parser but not at the renderer entry point — so a legally-
36917 // authored `spec: null` short-circuits without raising.
36918 for shape in [
36919 serde_yaml::Value::Null,
36920 serde_yaml::Value::String("scalar".into()),
36921 serde_yaml::Value::Sequence(vec![]),
36922 serde_yaml::Value::Number(0.into()),
36923 serde_yaml::Value::Bool(false),
36924 ] {
36925 let count = string_keyed_entries(&shape).count();
36926 assert_eq!(
36927 count, 0,
36928 "string_keyed_entries({shape:?}) must yield zero entries — \
36929 the prior `if let Value::Mapping(_)` arm silently \
36930 short-circuited on this shape, so the lift must preserve \
36931 that no-op contract or every routed renderer regresses on \
36932 the legally-authored non-Mapping `spec:` axis"
36933 );
36934 }
36935 }
36936
36937 #[test]
36938 fn string_keyed_entries_drops_non_string_keys() {
36939 // serde_yaml permits arbitrary `Value` keys — numeric, boolean,
36940 // sub-mapping — that don't round-trip through the downstream
36941 // K8s YAML-key surface (which requires string keys). Both
36942 // routed renderers previously carried an inline `if let Some(s)
36943 // = k.as_str()` filter to silently drop these; pin the lift's
36944 // filter contract so a future refactor that reaches for
36945 // `.as_str().unwrap()` (which would panic on a numeric key) is
36946 // a test-visible break, not a runtime regression at the first
36947 // ComputeUnit YAML that carries one.
36948 let mut spec = serde_yaml::Mapping::new();
36949 spec.insert(
36950 serde_yaml::Value::String(COMPUTEUNIT_SPEC_KEY_MODULE.into()),
36951 serde_yaml::Value::String("oci://…".into()),
36952 );
36953 spec.insert(
36954 serde_yaml::Value::Number(42.into()),
36955 serde_yaml::Value::String("dropped".into()),
36956 );
36957 spec.insert(
36958 serde_yaml::Value::Bool(true),
36959 serde_yaml::Value::String("also-dropped".into()),
36960 );
36961 spec.insert(
36962 serde_yaml::Value::String(COMPUTEUNIT_SPEC_KEY_TRIGGER.into()),
36963 serde_yaml::Value::String("http".into()),
36964 );
36965 let v = serde_yaml::Value::Mapping(spec);
36966 let keys: Vec<&str> = string_keyed_entries(&v).map(|(k, _)| k).collect();
36967 assert_eq!(
36968 keys,
36969 vec![COMPUTEUNIT_SPEC_KEY_MODULE, COMPUTEUNIT_SPEC_KEY_TRIGGER],
36970 "string_keyed_entries must silently drop non-string-keyed \
36971 entries (Value::Number, Value::Bool, Value::Mapping keys) \
36972 — the K8s YAML-key surface downstream requires string keys, \
36973 and every routed renderer's inline `k.as_str()` filter \
36974 expected exactly this drop-not-panic contract"
36975 );
36976 }
36977
36978 #[test]
36979 fn string_keyed_entries_matches_prior_inline_walk() {
36980 // Cross-check the helper's yielded sequence against the prior
36981 // inline `if let Value::Mapping(_) = spec { for (k, v) in _ {
36982 // if let Some(s) = k.as_str() { <collect (s, v.clone())> } } }`
36983 // walk both renderers previously carried. A drift between the
36984 // helper's yielded sequence and the inline walk would silently
36985 // emit a different destination map at every routed consumer —
36986 // pin the byte-equivalence so the helper remains a drop-in
36987 // replacement for both renderers' prior five-line block.
36988 let mut spec = serde_yaml::Mapping::new();
36989 spec.insert_str_key(
36990 COMPUTEUNIT_SPEC_KEY_MODULE,
36991 serde_yaml::Value::String("oci://ghcr.io/pleme-io/hello-rio:0.1.0".into()),
36992 );
36993 spec.insert(
36994 serde_yaml::Value::Number(1.into()),
36995 serde_yaml::Value::String("silently-dropped".into()),
36996 );
36997 spec.insert_str_key(
36998 COMPUTEUNIT_SPEC_KEY_TRIGGER,
36999 serde_yaml::Value::String("http".into()),
37000 );
37001 let v = serde_yaml::Value::Mapping(spec);
37002
37003 let via_helper: Vec<(String, serde_yaml::Value)> = string_keyed_entries(&v)
37004 .map(|(k, v)| (k.to_string(), v.clone()))
37005 .collect();
37006
37007 let mut via_inline: Vec<(String, serde_yaml::Value)> = Vec::new();
37008 if let serde_yaml::Value::Mapping(map) = &v {
37009 for (k, v) in map {
37010 if let Some(s) = k.as_str() {
37011 via_inline.push((s.to_string(), v.clone()));
37012 }
37013 }
37014 }
37015
37016 assert_eq!(
37017 via_helper, via_inline,
37018 "string_keyed_entries must yield the same (String, Value) \
37019 sequence as the prior inline `if let Value::Mapping + for + \
37020 if let Some(k.as_str())` walk — otherwise the two routed \
37021 renderers drift silently at ComputeUnit-YAML-`spec.*`-splice \
37022 time"
37023 );
37024 }
37025
37026 #[test]
37027 fn kube_metadata_str_field_reads_metadata_name_and_namespace_string_scalars() {
37028 // The lift's load-bearing contract: given a Value carrying a
37029 // top-level `metadata: { name: <str>, namespace: <str> }` block
37030 // (every K8s CR document the emit-side `kube_resource_skeleton`
37031 // renders), the helper returns Some(<str>) borrowing into the
37032 // input Value. Pinned because every routed test-side site (the
37033 // six caixa-mesh CNP filters + the caixa-flux kustomization.yaml
37034 // pin) reaches through this exact string-scalar readback, and a
37035 // drift in the borrowed-string contract would silently regress
37036 // every routed site's per-CR filter equality.
37037 let mut metadata = serde_yaml::Mapping::new();
37038 metadata.insert_str_key(
37039 KUBE_KEY_NAME,
37040 serde_yaml::Value::String("checkout-cart-to-catalog".into()),
37041 );
37042 metadata.insert_str_key(
37043 KUBE_KEY_NAMESPACE,
37044 serde_yaml::Value::String(DEFAULT_NAMESPACE.into()),
37045 );
37046 let mut cr = serde_yaml::Mapping::new();
37047 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
37048 let value = serde_yaml::Value::Mapping(cr);
37049
37050 assert_eq!(
37051 kube_metadata_str_field(&value, KUBE_KEY_NAME),
37052 Some("checkout-cart-to-catalog"),
37053 "kube_metadata_str_field must read metadata.name as a string \
37054 scalar — the six caixa-mesh CNP per-`(:de, :para)` filter \
37055 sites reach through this axis for policy-identity equality"
37056 );
37057 assert_eq!(
37058 kube_metadata_str_field(&value, KUBE_KEY_NAMESPACE),
37059 Some(DEFAULT_NAMESPACE),
37060 "kube_metadata_str_field must read metadata.namespace as a \
37061 string scalar — the caixa-flux programs_yaml_entry \
37062 production readback + the cluster_bundle kustomization.yaml \
37063 test pin both reach through this axis"
37064 );
37065 }
37066
37067 #[test]
37068 fn kube_metadata_str_field_returns_none_when_metadata_block_absent() {
37069 // Every K8s CR document the emit-side `kube_resource_skeleton`
37070 // renders carries a `metadata:` block, but the readback surface
37071 // is called on arbitrary Value inputs (upstream ComputeUnit
37072 // YAML documents, external YAML documents parsed by tests) that
37073 // may legally omit the block. The prior inline three-hop chain
37074 // silently short-circuits on the first `.get(KUBE_KEY_METADATA)`
37075 // hop when the block is absent; pin the helper's None return so
37076 // the prior no-panic contract holds. The two production-shape
37077 // paths — caixa-flux's `programs_yaml_entry` production
37078 // readback with `.unwrap_or(DEFAULT_NAMESPACE)` fallback, the
37079 // caixa-mesh test-side `.unwrap()` after equality-filter —
37080 // both depend on this None-arm for their fallback / test-harness
37081 // semantics.
37082 let value = serde_yaml::Value::Mapping(serde_yaml::Mapping::new());
37083 assert_eq!(
37084 kube_metadata_str_field(&value, KUBE_KEY_NAME),
37085 None,
37086 "kube_metadata_str_field must short-circuit to None when the \
37087 top-level `metadata:` block is absent — the prior inline \
37088 chain's `.get(KUBE_KEY_METADATA)` outer hop returned None \
37089 here, and every routed caller (production fallback + test \
37090 expect) depends on the None-arm reaching through"
37091 );
37092
37093 // Also verify the shape on a non-Mapping outer Value — the K8s
37094 // CR readback surface accepts arbitrary Value inputs, including
37095 // the Value::Null / Value::Sequence / Value::String shapes an
37096 // external YAML document may parse into.
37097 for shape in [
37098 serde_yaml::Value::Null,
37099 serde_yaml::Value::String("scalar".into()),
37100 serde_yaml::Value::Sequence(vec![]),
37101 serde_yaml::Value::Number(0.into()),
37102 serde_yaml::Value::Bool(false),
37103 ] {
37104 assert_eq!(
37105 kube_metadata_str_field(&shape, KUBE_KEY_NAME),
37106 None,
37107 "kube_metadata_str_field({shape:?}, KUBE_KEY_NAME) must \
37108 return None on non-Mapping shapes — the prior inline \
37109 `.get(KUBE_KEY_METADATA)` hop yields None on every \
37110 non-Mapping Value, and the lift must preserve that \
37111 contract"
37112 );
37113 }
37114 }
37115
37116 #[test]
37117 fn kube_metadata_str_field_returns_none_when_requested_field_absent() {
37118 // A `metadata:` block present but missing the requested axis-key
37119 // — a well-formed K8s CR that legally omits the requested field
37120 // (a Cluster-scoped CR omits `metadata.namespace`, a
37121 // Server-Side-Apply-authored CR omits `metadata.name` in favor
37122 // of `metadata.generateName`). Every routed caller expects the
37123 // three-hop chain to short-circuit through here to None; pin
37124 // the middle-hop None-arm so a future refactor that reaches for
37125 // `.get(field).unwrap()` (which would panic on a legally-omitted
37126 // axis-key) is a test-visible break.
37127 let mut metadata = serde_yaml::Mapping::new();
37128 metadata.insert_str_key(
37129 KUBE_KEY_NAME,
37130 serde_yaml::Value::String("cluster-scoped-cr".into()),
37131 );
37132 let mut cr = serde_yaml::Mapping::new();
37133 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
37134 let value = serde_yaml::Value::Mapping(cr);
37135 assert_eq!(
37136 kube_metadata_str_field(&value, KUBE_KEY_NAMESPACE),
37137 None,
37138 "kube_metadata_str_field must return None when the requested \
37139 `metadata.<field>` axis-key is absent — the prior inline \
37140 chain's middle `.and_then(|m| m.get(<FIELD>))` hop short- \
37141 circuited here, and the lift must preserve that None-arm \
37142 for every legally-omitted axis-key"
37143 );
37144 }
37145
37146 #[test]
37147 fn kube_metadata_str_field_returns_none_when_field_carries_non_string_type() {
37148 // A `metadata.<field>` axis-key present but carrying a non-
37149 // string YAML type — schema-invalid per the K8s apiserver's
37150 // OpenAPI schema but tolerated here as None so the readback
37151 // stays a total function. The prior inline chain's trailing
37152 // `.and_then(|n| n.as_str())` shape gate silently short-
37153 // circuits here; pin the helper's None-arm so a future refactor
37154 // that reaches for `.as_str().unwrap()` (which would panic on
37155 // a numeric axis-value) is a test-visible break, not a runtime
37156 // regression at the first schema-invalid CR the reader sees.
37157 for non_string in [
37158 serde_yaml::Value::Null,
37159 serde_yaml::Value::Number(42.into()),
37160 serde_yaml::Value::Bool(true),
37161 serde_yaml::Value::Sequence(vec![]),
37162 serde_yaml::Value::Mapping(serde_yaml::Mapping::new()),
37163 ] {
37164 let mut metadata = serde_yaml::Mapping::new();
37165 metadata.insert_str_key(KUBE_KEY_NAME, non_string.clone());
37166 let mut cr = serde_yaml::Mapping::new();
37167 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
37168 let value = serde_yaml::Value::Mapping(cr);
37169 assert_eq!(
37170 kube_metadata_str_field(&value, KUBE_KEY_NAME),
37171 None,
37172 "kube_metadata_str_field must return None when \
37173 metadata.name carries a non-string YAML type ({non_string:?}) \
37174 — the prior inline chain's `.and_then(|n| n.as_str())` \
37175 shape gate short-circuited here, and every routed caller \
37176 depends on that None-arm to keep the readback total"
37177 );
37178 }
37179 }
37180
37181 #[test]
37182 fn kube_metadata_str_field_matches_prior_inline_chain() {
37183 // Cross-check the helper's output byte-for-byte against the
37184 // prior inline three-hop chain both routed callers previously
37185 // carried. A drift between the helper's return and the inline
37186 // chain would silently regress every routed test-side filter's
37187 // equality comparison + the caixa-flux production readback's
37188 // fallback semantics — pin the byte-equivalence so the helper
37189 // remains a drop-in replacement for every routed site's prior
37190 // three-line block.
37191 let mut metadata = serde_yaml::Mapping::new();
37192 metadata.insert_str_key(
37193 KUBE_KEY_NAME,
37194 serde_yaml::Value::String("checkout-payment-to-cart".into()),
37195 );
37196 metadata.insert_str_key(
37197 KUBE_KEY_NAMESPACE,
37198 serde_yaml::Value::String(DEFAULT_NAMESPACE.into()),
37199 );
37200 let mut cr = serde_yaml::Mapping::new();
37201 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
37202 let value = serde_yaml::Value::Mapping(cr);
37203
37204 for field in [KUBE_KEY_NAME, KUBE_KEY_NAMESPACE] {
37205 let via_helper = kube_metadata_str_field(&value, field);
37206 let via_inline = value
37207 .get(KUBE_KEY_METADATA)
37208 .and_then(|m| m.get(field))
37209 .and_then(|n| n.as_str());
37210 assert_eq!(
37211 via_helper, via_inline,
37212 "kube_metadata_str_field(_, {field:?}) must yield the same \
37213 Option<&str> as the prior inline three-hop chain — \
37214 otherwise every routed caller's equality-filter / \
37215 production-fallback drifts silently at readback time"
37216 );
37217 }
37218 }
37219
37220 #[test]
37221 fn kube_root_str_field_reads_api_version_and_kind_string_scalars() {
37222 // The lift's load-bearing contract: given a Value carrying
37223 // top-level `apiVersion:` + `kind:` string scalars (every K8s
37224 // CR document the emit-side `kube_resource_skeleton` renders
37225 // spells the pair by construction), the helper returns
37226 // Some(<str>) borrowing into the input Value on both axes.
37227 // Pinned because every routed test-side site — the
37228 // caixa-flux `cluster_bundle_*_uses_lifted_flux_api_version`
37229 // per-document apiVersion pins + the caixa-mesh
37230 // `gateway_routes` per-`(Gateway, HTTPRoute)` kind-filter
37231 // + the sibling caixa-mesh
37232 // `cilium_authentication_mode_serialized_as_yaml_string`
37233 // CNP-kind filter — reaches through this exact top-level
37234 // string-scalar readback, and a drift in the borrowed-string
37235 // contract would silently regress every routed site's
37236 // per-CR filter / discriminator-pin equality.
37237 let mut cr = serde_yaml::Mapping::new();
37238 cr.insert_str_key(
37239 KUBE_KEY_API_VERSION,
37240 serde_yaml::Value::String(GATEWAY_API_API_VERSION.into()),
37241 );
37242 cr.insert_str_key(
37243 KUBE_KEY_KIND,
37244 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37245 );
37246 let value = serde_yaml::Value::Mapping(cr);
37247
37248 assert_eq!(
37249 kube_root_str_field(&value, KUBE_KEY_API_VERSION),
37250 Some(GATEWAY_API_API_VERSION),
37251 "kube_root_str_field must read top-level apiVersion as a \
37252 string scalar — the caixa-flux `cluster_bundle_*_uses_\
37253 lifted_flux_api_version` pins + caixa-mesh per-CR \
37254 apiVersion pins reach through this axis for discriminator \
37255 equality"
37256 );
37257 assert_eq!(
37258 kube_root_str_field(&value, KUBE_KEY_KIND),
37259 Some(GATEWAY_API_KIND_GATEWAY),
37260 "kube_root_str_field must read top-level kind as a string \
37261 scalar — the 15 caixa-mesh `gateway_routes` per-CR find \
37262 sites reach through this axis to filter the multi-doc \
37263 emission sequence by kind discriminator"
37264 );
37265 }
37266
37267 #[test]
37268 fn kube_root_str_field_returns_none_when_field_absent() {
37269 // Every K8s CR document the emit-side `kube_resource_skeleton`
37270 // renders carries `apiVersion:` + `kind:` scalars, but the
37271 // readback surface is called on arbitrary Value inputs
37272 // (multi-doc sequences under iteration, upstream ComputeUnit
37273 // YAML documents) that may legally omit either axis-key. The
37274 // prior inline two-hop chain silently short-circuits on the
37275 // outer `.get(field)` hop when the axis is absent; pin the
37276 // helper's None return so the prior no-panic contract holds.
37277 // Also verify on non-Mapping outer Value shapes an external
37278 // YAML document may parse into.
37279 let value = serde_yaml::Value::Mapping(serde_yaml::Mapping::new());
37280 assert_eq!(
37281 kube_root_str_field(&value, KUBE_KEY_API_VERSION),
37282 None,
37283 "kube_root_str_field must short-circuit to None when the \
37284 requested top-level axis-key is absent — the prior inline \
37285 `.get(field)` outer hop returned None here, and every \
37286 routed caller (test pin + filter predicate) depends on \
37287 that None-arm reaching through"
37288 );
37289 assert_eq!(
37290 kube_root_str_field(&value, KUBE_KEY_KIND),
37291 None,
37292 "kube_root_str_field must short-circuit to None on a \
37293 missing top-level kind axis-key — every routed \
37294 caixa-mesh find-predicate compares against Some(<KIND>) \
37295 and must reject None-shaped entries silently"
37296 );
37297
37298 for shape in [
37299 serde_yaml::Value::Null,
37300 serde_yaml::Value::String("scalar".into()),
37301 serde_yaml::Value::Sequence(vec![]),
37302 serde_yaml::Value::Number(0.into()),
37303 serde_yaml::Value::Bool(false),
37304 ] {
37305 assert_eq!(
37306 kube_root_str_field(&shape, KUBE_KEY_KIND),
37307 None,
37308 "kube_root_str_field({shape:?}, KUBE_KEY_KIND) must \
37309 return None on non-Mapping shapes — the prior inline \
37310 `.get(field)` hop yields None on every non-Mapping \
37311 Value, and the lift must preserve that contract"
37312 );
37313 }
37314 }
37315
37316 #[test]
37317 fn kube_root_str_field_returns_none_when_field_carries_non_string_type() {
37318 // A top-level `<field>` axis-key present but carrying a non-
37319 // string YAML type — schema-invalid per the K8s apiserver's
37320 // OpenAPI schema but tolerated here as None so the readback
37321 // stays a total function. The prior inline chain's trailing
37322 // `.and_then(|n| n.as_str())` shape gate silently short-
37323 // circuits here; pin the helper's None-arm so a future
37324 // refactor that reaches for `.as_str().unwrap()` (which would
37325 // panic on a numeric axis-value) is a test-visible break, not
37326 // a runtime regression at the first schema-invalid CR the
37327 // reader sees.
37328 for non_string in [
37329 serde_yaml::Value::Null,
37330 serde_yaml::Value::Number(42.into()),
37331 serde_yaml::Value::Bool(true),
37332 serde_yaml::Value::Sequence(vec![]),
37333 serde_yaml::Value::Mapping(serde_yaml::Mapping::new()),
37334 ] {
37335 let mut cr = serde_yaml::Mapping::new();
37336 cr.insert_str_key(KUBE_KEY_KIND, non_string.clone());
37337 let value = serde_yaml::Value::Mapping(cr);
37338 assert_eq!(
37339 kube_root_str_field(&value, KUBE_KEY_KIND),
37340 None,
37341 "kube_root_str_field must return None when top-level \
37342 kind carries a non-string YAML type ({non_string:?}) \
37343 — the prior inline `.and_then(|n| n.as_str())` shape \
37344 gate short-circuited here, and every routed caller \
37345 depends on that None-arm to keep the readback total"
37346 );
37347 }
37348 }
37349
37350 #[test]
37351 fn kube_root_str_field_matches_prior_inline_chain() {
37352 // Cross-check the helper's output byte-for-byte against the
37353 // prior inline two-hop chain both routed renderers previously
37354 // carried. A drift between the helper's return and the inline
37355 // chain would silently regress every routed test-side filter's
37356 // equality comparison + the caixa-flux production-shape
37357 // per-document apiVersion / kind pin — pin the byte-
37358 // equivalence so the helper remains a drop-in replacement for
37359 // every routed site's prior two-line block.
37360 let mut cr = serde_yaml::Mapping::new();
37361 cr.insert_str_key(
37362 KUBE_KEY_API_VERSION,
37363 serde_yaml::Value::String(FLUX_HELMRELEASE_API_VERSION.into()),
37364 );
37365 cr.insert_str_key(
37366 KUBE_KEY_KIND,
37367 serde_yaml::Value::String(FLUX_KIND_HELM_RELEASE.into()),
37368 );
37369 let value = serde_yaml::Value::Mapping(cr);
37370
37371 for field in [KUBE_KEY_API_VERSION, KUBE_KEY_KIND] {
37372 let via_helper = kube_root_str_field(&value, field);
37373 let via_inline = value.get(field).and_then(|n| n.as_str());
37374 assert_eq!(
37375 via_helper, via_inline,
37376 "kube_root_str_field(_, {field:?}) must yield the same \
37377 Option<&str> as the prior inline two-hop chain — \
37378 otherwise every routed caller's equality-filter / \
37379 discriminator-pin drifts silently at readback time"
37380 );
37381 }
37382 }
37383
37384 #[test]
37385 fn kube_root_str_field_and_kube_metadata_str_field_bracket_the_readback_surface() {
37386 // Peer-pin: the two lifted K8s-CR readback primitives cover
37387 // orthogonal axes on the same document. Given a full K8s CR
37388 // (top-level `apiVersion:` + `kind:` discriminator pair,
37389 // sub-`metadata.name:` + `metadata.namespace:` identity pair),
37390 // each helper reaches through its own axis and the two
37391 // together enumerate every documented top-level string
37392 // scalar the substrate emits + reads back. Pin the pairing so
37393 // a future refactor that collapses the two into a single
37394 // navigation primitive (or splits one further) surfaces here
37395 // as a test-visible break, not a silent regression at the
37396 // first routed caller's per-CR readback drift.
37397 let mut metadata = serde_yaml::Mapping::new();
37398 metadata.insert_str_key(
37399 KUBE_KEY_NAME,
37400 serde_yaml::Value::String("checkout-cart-to-catalog".into()),
37401 );
37402 metadata.insert_str_key(
37403 KUBE_KEY_NAMESPACE,
37404 serde_yaml::Value::String(DEFAULT_NAMESPACE.into()),
37405 );
37406 let mut cr = serde_yaml::Mapping::new();
37407 cr.insert_str_key(
37408 KUBE_KEY_API_VERSION,
37409 serde_yaml::Value::String(CILIUM_API_VERSION.into()),
37410 );
37411 cr.insert_str_key(
37412 KUBE_KEY_KIND,
37413 serde_yaml::Value::String(CILIUM_KIND_NETWORK_POLICY.into()),
37414 );
37415 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
37416 let value = serde_yaml::Value::Mapping(cr);
37417
37418 assert_eq!(
37419 kube_root_str_field(&value, KUBE_KEY_API_VERSION),
37420 Some(CILIUM_API_VERSION)
37421 );
37422 assert_eq!(
37423 kube_root_str_field(&value, KUBE_KEY_KIND),
37424 Some(CILIUM_KIND_NETWORK_POLICY)
37425 );
37426 assert_eq!(
37427 kube_metadata_str_field(&value, KUBE_KEY_NAME),
37428 Some("checkout-cart-to-catalog")
37429 );
37430 assert_eq!(
37431 kube_metadata_str_field(&value, KUBE_KEY_NAMESPACE),
37432 Some(DEFAULT_NAMESPACE)
37433 );
37434 }
37435
37436 #[test]
37437 fn kube_kind_is_matches_lifted_kube_root_str_field_equality_shape() {
37438 // Byte-equivalence pin: the lifted predicate reproduces the
37439 // three-token composition (`kube_root_str_field(v,
37440 // KUBE_KEY_KIND) == Some(<KIND>)`) the 15 caixa-mesh test-side
37441 // `.find`/`.filter` sites previously carried inline. Closes the
37442 // "did the lift accidentally rename the pinned scalar-key axis
37443 // to KUBE_KEY_API_VERSION or drop the `Some(...)` wrap" drift
37444 // class every future re-lift on the peer-axis surface (a
37445 // hypothetical `kube_api_version_is` peer, `kube_group_is` on a
37446 // multi-group router harness) would otherwise reopen.
37447 let mut cr = serde_yaml::Mapping::new();
37448 cr.insert_str_key(
37449 KUBE_KEY_KIND,
37450 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37451 );
37452 let value = serde_yaml::Value::Mapping(cr);
37453
37454 assert!(kube_kind_is(&value, GATEWAY_API_KIND_GATEWAY));
37455 assert_eq!(
37456 kube_kind_is(&value, GATEWAY_API_KIND_GATEWAY),
37457 kube_root_str_field(&value, KUBE_KEY_KIND) == Some(GATEWAY_API_KIND_GATEWAY),
37458 );
37459 }
37460
37461 #[test]
37462 fn kube_kind_is_false_on_mismatched_kind_and_missing_kind() {
37463 // Complement-side pin: the predicate returns `false` when
37464 // either the kind axis carries a different discriminator or the
37465 // top-level `kind:` scalar is absent altogether (the same
37466 // vacuous-`None` short-circuit the parent
37467 // `kube_root_str_field` closes on the underlying two-hop
37468 // navigation). Consumer sites (`docs.iter().find(|d|
37469 // kube_kind_is(d, X))`) rely on the false-on-mismatch shape to
37470 // skip the wrong CRs across the multi-doc mesh emission and
37471 // land on the intended per-kind document.
37472 let mut cr_wrong_kind = serde_yaml::Mapping::new();
37473 cr_wrong_kind.insert_str_key(
37474 KUBE_KEY_KIND,
37475 serde_yaml::Value::String(GATEWAY_API_KIND_HTTP_ROUTE.into()),
37476 );
37477 assert!(!kube_kind_is(
37478 &serde_yaml::Value::Mapping(cr_wrong_kind),
37479 GATEWAY_API_KIND_GATEWAY,
37480 ));
37481
37482 let cr_no_kind = serde_yaml::Mapping::new();
37483 assert!(!kube_kind_is(
37484 &serde_yaml::Value::Mapping(cr_no_kind),
37485 GATEWAY_API_KIND_GATEWAY,
37486 ));
37487 }
37488
37489 #[test]
37490 fn find_by_kind_matches_inline_iter_find_kube_kind_is_shape() {
37491 // Byte-equivalence pin: the lifted navigator reproduces the
37492 // three-token combinator chain (`docs.iter().find(|d|
37493 // kube_kind_is(d, <KIND>))`) the 14 caixa-mesh test-side
37494 // per-Gateway / per-HTTPRoute find-by-kind sites previously
37495 // carried inline. Closes the "did the lift accidentally
37496 // widen the receiver, drop the closure, or swap `find` for
37497 // `filter`" drift class every future re-lift on the sibling
37498 // multi-doc-navigator axis (a hypothetical
37499 // `filter_by_kind` peer that carries the same underlying
37500 // predicate but returns an iterator) would otherwise reopen.
37501 let mut gateway = serde_yaml::Mapping::new();
37502 gateway.insert_str_key(
37503 KUBE_KEY_KIND,
37504 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37505 );
37506 let mut route = serde_yaml::Mapping::new();
37507 route.insert_str_key(
37508 KUBE_KEY_KIND,
37509 serde_yaml::Value::String(GATEWAY_API_KIND_HTTP_ROUTE.into()),
37510 );
37511 let docs = vec![
37512 serde_yaml::Value::Mapping(gateway),
37513 serde_yaml::Value::Mapping(route),
37514 ];
37515
37516 // Lifted navigator agrees with the inline combinator chain
37517 // on every existing member of the multi-doc slice.
37518 assert_eq!(
37519 find_by_kind(&docs, GATEWAY_API_KIND_GATEWAY),
37520 docs.iter()
37521 .find(|d| kube_kind_is(d, GATEWAY_API_KIND_GATEWAY)),
37522 );
37523 assert_eq!(
37524 find_by_kind(&docs, GATEWAY_API_KIND_HTTP_ROUTE),
37525 docs.iter()
37526 .find(|d| kube_kind_is(d, GATEWAY_API_KIND_HTTP_ROUTE)),
37527 );
37528
37529 // And on the miss path: absent kind → None, matching the
37530 // inline `.find` short-circuit that consumer sites rely on
37531 // to distinguish "no such CR in this emission" from "wrong
37532 // shape" in their `.unwrap()` / `.expect(...)` follow-ups.
37533 assert_eq!(find_by_kind(&docs, CILIUM_KIND_NETWORK_POLICY), None);
37534 let empty: Vec<serde_yaml::Value> = Vec::new();
37535 assert_eq!(find_by_kind(&empty, GATEWAY_API_KIND_GATEWAY), None);
37536 }
37537
37538 #[test]
37539 fn find_by_kind_returns_first_match_on_duplicate_kind() {
37540 // Order-preservation pin: the lifted navigator returns the
37541 // first document of the matching kind (the same short-
37542 // circuit `Iterator::find` exposes). Multi-doc mesh
37543 // emissions never carry two documents of the same kind at
37544 // V0 (`gateway_routes` emits exactly one `Gateway` + one
37545 // `HTTPRoute` per Aplicacao), but the M4 cross-cluster
37546 // fan-out will (one `HelmRelease` per cluster). Pinning the
37547 // first-match contract keeps the M4 caller-side "the first
37548 // hit is the primary" convention aligned with the helper's
37549 // combinator half.
37550 let mut gateway_a = serde_yaml::Mapping::new();
37551 gateway_a.insert_str_key(
37552 KUBE_KEY_KIND,
37553 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37554 );
37555 let mut meta_a = serde_yaml::Mapping::new();
37556 meta_a.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("primary".into()));
37557 gateway_a.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(meta_a));
37558 let mut gateway_b = serde_yaml::Mapping::new();
37559 gateway_b.insert_str_key(
37560 KUBE_KEY_KIND,
37561 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37562 );
37563 let mut meta_b = serde_yaml::Mapping::new();
37564 meta_b.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("secondary".into()));
37565 gateway_b.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(meta_b));
37566 let docs = vec![
37567 serde_yaml::Value::Mapping(gateway_a),
37568 serde_yaml::Value::Mapping(gateway_b),
37569 ];
37570
37571 let first = find_by_kind(&docs, GATEWAY_API_KIND_GATEWAY).unwrap();
37572 assert_eq!(
37573 kube_metadata_str_field(first, KUBE_KEY_NAME),
37574 Some("primary"),
37575 );
37576 }
37577
37578 // ── contrato-edge-label + cilium-network-policy-name lifts ──────────
37579
37580 #[test]
37581 fn contrato_edge_label_separator_pin() {
37582 // Load-bearing byte-string pin: the M3 `:contratos`
37583 // edge-direction separator every caixa-mesh emitter that
37584 // encodes a typed edge as a K8s-name-shaped scalar reads from.
37585 // Any future rebrand (e.g. `-to-` → `_to_`) lands here as a
37586 // one-const edit; the peer `contrato_edge_label` /
37587 // `cilium_network_policy_name` composers pick up the new
37588 // encoding by construction. A drift on this const would silently
37589 // split the CNP `metadata.name` from its own
37590 // `metadata.labels.pleme.pleme.io/contrato` value, orphaning
37591 // every operator-side grep-by-label query far from the source
37592 // caixa.lisp.
37593 assert_eq!(CONTRATO_EDGE_LABEL_SEPARATOR, "-to-");
37594 }
37595
37596 #[test]
37597 fn contrato_edge_label_matches_inline_de_to_para_encoding() {
37598 // Byte-shape pin: the composer produces the same
37599 // `format!("{de}-to-{para}")` byte-string every caixa-mesh
37600 // per-`(:de, :para)` `CiliumNetworkPolicy` emitter previously
37601 // inlined at its `labels.insert(LABEL_CONTRATO, …)` call. So a
37602 // future rewire of the composer's internals (multi-hop typed
37603 // edges once the M4 per-edge WIT registry lands, unicode
37604 // arrow-shape rebrand for operator display) reaches every
37605 // consumer through one canonical function-pointer edit.
37606 assert_eq!(contrato_edge_label("cart", "catalog"), "cart-to-catalog");
37607 assert_eq!(contrato_edge_label("cart", "payment"), "cart-to-payment");
37608 }
37609
37610 #[test]
37611 fn contrato_edge_label_threads_separator_between_de_and_para() {
37612 // Composition pin: the composer's shape is
37613 // `de + CONTRATO_EDGE_LABEL_SEPARATOR + para`, so a future
37614 // separator rebrand at [`CONTRATO_EDGE_LABEL_SEPARATOR`]
37615 // reaches the composer through one const-edit and every
37616 // consumer picks up the new encoding by construction. Pin the
37617 // structural equation (not just the byte value) so a future
37618 // reorder of the composer's `format!` argument list (a
37619 // `format!("{para}-{sep}-{de}")` typo mid-refactor) fires here
37620 // rather than silently emitting reversed-direction CNP labels.
37621 let de = "svc-a";
37622 let para = "svc-b";
37623 assert_eq!(
37624 contrato_edge_label(de, para),
37625 format!("{de}{CONTRATO_EDGE_LABEL_SEPARATOR}{para}"),
37626 );
37627 }
37628
37629 #[test]
37630 fn cilium_network_policy_name_matches_inline_aplicacao_de_to_para_encoding() {
37631 // Byte-shape pin: the composer produces the same
37632 // `format!("{aplicacao}-{de}-to-{para}")` byte-string every
37633 // caixa-mesh `cilium_network_policies` per-`(:de, :para)`
37634 // group's `kube_resource_skeleton` `name:` argument previously
37635 // inlined. So a future rewire of the composer's internals
37636 // reaches the CNP renderer through one canonical function-
37637 // pointer edit rather than a coordinated two-site rewrite of
37638 // the [`LABEL_CONTRATO`] labels.insert(...) call and the CNP
37639 // name argument.
37640 assert_eq!(
37641 cilium_network_policy_name("checkout", "cart", "catalog"),
37642 "checkout-cart-to-catalog",
37643 );
37644 assert_eq!(
37645 cilium_network_policy_name("checkout", "cart", "payment"),
37646 "checkout-cart-to-payment",
37647 );
37648 }
37649
37650 #[test]
37651 fn cilium_network_policy_name_composes_on_contrato_edge_label() {
37652 // Composition pin: the CNP name is the parent Aplicacao's
37653 // `:nome` joined to the contrato-edge-label by a canonical `-`
37654 // separator (`format!("{aplicacao}-{edge}")`), so the two
37655 // writer-side helpers close the canonical
37656 // `(LABEL_CONTRATO-value, metadata.name)` per-CNP identity
37657 // pair on one shared edge-encoding source of truth
37658 // ([`CONTRATO_EDGE_LABEL_SEPARATOR`]). Pin the structural
37659 // equation so a future refactor of either composer's internals
37660 // that accidentally desynchronizes the two (a CNP-name
37661 // rebrand landing on `format!("{aplicacao}_{edge}")` while
37662 // the label-value composer stays on `{de}-to-{para}`, or a
37663 // label-composer rebrand landing on `->` while the CNP-name
37664 // composer stays on `-to-`) fires here rather than silently
37665 // orphaning every operator-side grep-by-label query at apply
37666 // time.
37667 let aplicacao = "checkout";
37668 let de = "cart";
37669 let para = "catalog";
37670 let edge = contrato_edge_label(de, para);
37671 assert_eq!(
37672 cilium_network_policy_name(aplicacao, de, para),
37673 format!("{aplicacao}-{edge}"),
37674 );
37675 }
37676
37677 // ── gateway-api-http-route-name lift ────────────────────────────────
37678
37679 #[test]
37680 fn gateway_api_http_route_name_matches_inline_aplicacao_para_encoding() {
37681 // Byte-shape pin: the composer produces the same
37682 // `format!("{aplicacao}-{para}")` byte-string the caixa-mesh
37683 // `gateway_routes` per-`:entrada` `kube_resource_skeleton`
37684 // `name:` argument previously inlined as
37685 // `format!("{}-{}", caixa.nome, entrada.para)`. So a future
37686 // rewire of the composer's internals reaches the HTTPRoute
37687 // renderer through one canonical function-pointer edit rather
37688 // than a hand-agreement between the emitter and every
37689 // test-side probe pinning the expected `<aplicacao>-<para>`
37690 // byte-shape at the HTTPRoute `metadata.name` axis.
37691 assert_eq!(
37692 gateway_api_http_route_name("checkout", "cart"),
37693 "checkout-cart",
37694 );
37695 assert_eq!(gateway_api_http_route_name("orders", "cart"), "orders-cart",);
37696 }
37697
37698 #[test]
37699 fn rendered_file_carries_path_and_contents_fields() {
37700 // Field-shape pin: the canonical [`RenderedFile`] every
37701 // per-target `caixa-<target>` renderer's per-artifact leaf
37702 // resolves through carries exactly the `(path, contents)` pair
37703 // the prior per-crate `BundleFile { path: PathBuf, contents:
37704 // String }` (`caixa-flux`) / `ChartFile { path: PathBuf,
37705 // contents: String }` (`caixa-helm`) clones each carried
37706 // verbatim. A future refactor that adds a per-artifact
37707 // hash / provenance / write-mode discriminator on the record
37708 // must land at the canonical struct definition (this file) —
37709 // the two type aliases at `caixa-flux::BundleFile` /
37710 // `caixa-helm::ChartFile` re-export the canonical unchanged, so
37711 // an addition here reaches both per-target renderers at once,
37712 // and a struct-literal drift that inlines the pre-lift shape
37713 // at either alias trips this pin at caixa-core build time
37714 // rather than surfacing as a divergent per-target renderer's
37715 // record shape far from the source.
37716 let f = RenderedFile {
37717 path: PathBuf::from("Chart.yaml"),
37718 contents: "apiVersion: v2\n".to_string(),
37719 };
37720 assert_eq!(f.path, PathBuf::from("Chart.yaml"));
37721 assert_eq!(f.contents, "apiVersion: v2\n");
37722 }
37723
37724 #[test]
37725 fn rendered_file_derives_pattern_pin() {
37726 // Derive-shape pin: the canonical [`RenderedFile`] carries the
37727 // `Debug + Clone + PartialEq + Eq` derive tuple the two per-
37728 // renderer clones (`caixa-flux::BundleFile` /
37729 // `caixa-helm::ChartFile`) each carried verbatim before the
37730 // lift. `Clone::clone` returns a byte-equal record + the
37731 // `PartialEq::eq` impl returns `true` on the round-trip; a
37732 // future refactor that drops one of the four derives (say,
37733 // removes `PartialEq` on a per-artifact-hash addition) trips
37734 // this pin at caixa-core build time and surfaces the
37735 // per-alias downstream `assert_eq!(bundle_file_a,
37736 // bundle_file_b)` / `assert_eq!(chart_file_a, chart_file_b)`
37737 // navigators in `caixa-flux` / `caixa-helm` — every
37738 // per-alias derive-fed navigator threads through this
37739 // canonical derive tuple by construction.
37740 let f = RenderedFile {
37741 path: PathBuf::from("values.yaml"),
37742 contents: "pleme-computeunit:\n enabled: false\n".to_string(),
37743 };
37744 let clone = f.clone();
37745 assert_eq!(f, clone);
37746 let dbg = format!("{f:?}");
37747 assert!(
37748 dbg.contains("RenderedFile"),
37749 "Debug output must name the canonical type, got: {dbg:?}",
37750 );
37751 }
37752
37753 #[test]
37754 fn rendered_file_new_matches_struct_literal_shape() {
37755 // Constructor pin: [`RenderedFile::new(FILENAME, contents)`]
37756 // (the canonical lifted `impl Into<PathBuf>` / `impl Into<String>`
37757 // inherent constructor every per-target renderer's per-artifact
37758 // leaf now routes through) produces the byte-identical record
37759 // the six prior inline struct-literal call sites (three
37760 // per-artifact leaves in
37761 // [`caixa_helm::render_chart_for_servico_with`],
37762 // three per-CR leaves in [`caixa_flux::cluster_bundle`]) each
37763 // open-coded as `<Xxx>File { path: PathBuf::from(FILENAME_CONST),
37764 // contents: <body> }`. Pin the equation on a
37765 // `HELM_VALUES_YAML_FILENAME`-shaped input so a future rebrand
37766 // of the constructor's internals (a per-artifact hash /
37767 // provenance field addition, an
37768 // [`is_sandboxed_relative_path`] check at construction time
37769 // once per-cluster-writer sandboxing lands) fires here rather
37770 // than silently splitting the per-target renderer's per-CR
37771 // record shape from the substrate-canonical `(path, contents)`
37772 // pair at the caixa-core canonical.
37773 let via_new = RenderedFile::new(HELM_VALUES_YAML_FILENAME, "pleme-computeunit:\n");
37774 let via_literal = RenderedFile {
37775 path: PathBuf::from(HELM_VALUES_YAML_FILENAME),
37776 contents: "pleme-computeunit:\n".to_string(),
37777 };
37778 assert_eq!(via_new, via_literal);
37779 // Peer path-side pin: `impl Into<PathBuf>` accepts a `PathBuf`
37780 // directly (the future per-target renderer surface where the
37781 // path is composed from author input rather than picked from a
37782 // substrate-canonical `&'static str` filename constant) —
37783 // exercised so a drift onto a stricter `&str`-only bound
37784 // trips this pin at caixa-core build time rather than at the
37785 // first per-target renderer that reaches for the wider bound.
37786 let via_new_from_pathbuf = RenderedFile::new(
37787 PathBuf::from(FLUX_HELMRELEASE_YAML_FILENAME),
37788 String::from("kind: HelmRelease\n"),
37789 );
37790 assert_eq!(
37791 via_new_from_pathbuf.path,
37792 PathBuf::from(FLUX_HELMRELEASE_YAML_FILENAME),
37793 );
37794 assert_eq!(via_new_from_pathbuf.contents, "kind: HelmRelease\n");
37795 }
37796
37797 #[test]
37798 fn gateway_api_http_route_name_composes_on_canonical_dash_separator() {
37799 // Composition pin: the HTTPRoute `metadata.name` is the parent
37800 // Aplicacao's `:nome` joined to the `:entrada :para`
37801 // destination Servico's `:nome` by a canonical `-` separator
37802 // (`format!("{aplicacao}-{para}")`) — the same
37803 // "aplicacao-prefixed sub-identity" discipline the peer
37804 // [`cilium_network_policy_name`] composer materializes on the
37805 // sibling per-CR K8s-name-shaped-identity-scalar axis
37806 // ([`format!("{aplicacao}-{edge}")`]). Pin the structural
37807 // equation so a future refactor of either composer's internals
37808 // that accidentally desynchronizes the two (an HTTPRoute-name
37809 // rebrand landing on `format!("{aplicacao}.{para}")` while
37810 // the CNP-name composer stays on `{aplicacao}-{edge}`, or a
37811 // per-Aplicacao-K8s-CR-name shared-separator rebrand landing
37812 // on the CNP-name composer without a coordinated edit here)
37813 // fires here rather than silently splitting the two per-CR
37814 // name-encoding axes across the caixa-mesh renderer.
37815 let aplicacao = "checkout";
37816 let para = "cart";
37817 assert_eq!(
37818 gateway_api_http_route_name(aplicacao, para),
37819 format!("{aplicacao}-{para}"),
37820 );
37821 }
37822}