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 `Duration` axis with the "zero-floor +
19362/// canonical-form + upper-cap" three-arm gate every typed-`Duration`
19363/// slot in the crate carries. Returns `on_zero()` when `value` is
19364/// `Duration::ZERO`, `on_not_canonical(value)` when `value` carries
19365/// sub-millisecond residue the shared
19366/// [`crate::supervisor::duration_codec`] cannot round-trip losslessly,
19367/// `on_cap_exceeded(value)` when `value > cap`, `Ok(())` otherwise.
19368///
19369/// The three arms fire in canonical `zero → not-canonical → cap` order,
19370/// matching the discipline every existing per-axis inline block already
19371/// applied by hand: the zero-floor arm precedes the canonical-form arm
19372/// so `Duration::ZERO` (whose `subsec_nanos() == 0` makes it accepted
19373/// by the canonical-form predicate) surfaces the self-locating zero
19374/// diagnostic — every per-axis zero variant already documents an
19375/// "omit the axis to express no-bound" remediation — rather than the
19376/// misleading no-op the canonical arm would return; the canonical-form
19377/// arm then precedes the cap arm so a `Duration` that is *both*
19378/// sub-millisecond and above-cap surfaces the more fundamental
19379/// round-trip-shape diagnostic first (the cap's `1ms..=<cap>`
19380/// remediation would be misleading when no integer-ms form of the
19381/// offending value exists). Same ordering discipline the peer
19382/// [`require_positive_bounded_u32`] applies on its two arms — this
19383/// lift makes the three-arm ordering a property of the helper, not a
19384/// per-call-site convention four sites re-derived by hand.
19385///
19386/// Four identical-shape call sites collapse onto this helper — one for
19387/// each typed-`Duration` slot in the crate:
19388///
19389/// * [`crate::AplicacaoSpec::validate`] on
19390/// [`crate::MeshPolicy::timeout`] (zero →
19391/// [`crate::AplicacaoError::PolicyTimeoutZero`], not-canonical →
19392/// [`crate::AplicacaoError::PolicyTimeoutNotCanonical`], cap →
19393/// [`crate::AplicacaoError::PolicyTimeoutExceedsCap`],
19394/// cap = [`crate::POLICY_TIMEOUT_MAX`]) and
19395/// [`crate::CircuitBreaker::window`] (zero →
19396/// [`crate::AplicacaoError::PolicyBreakerZeroWindow`],
19397/// not-canonical →
19398/// [`crate::AplicacaoError::PolicyBreakerWindowNotCanonical`],
19399/// cap → [`crate::AplicacaoError::PolicyBreakerWindowExceedsCap`],
19400/// cap = [`crate::POLICY_BREAKER_WINDOW_MAX`]);
19401/// * [`crate::LimitsSpec::validate`] on
19402/// [`crate::LimitsSpec::wall_clock`] (zero →
19403/// [`crate::LimitsError::WallClockZero`], not-canonical →
19404/// [`crate::LimitsError::WallClockNotCanonical`], cap →
19405/// [`crate::LimitsError::WallClockExceedsCap`],
19406/// cap = [`crate::LIMITS_WALL_CLOCK_MAX`]);
19407/// * [`crate::SupervisorSpec::validate`] on
19408/// [`crate::SupervisorSpec::restart_window`] (zero →
19409/// [`crate::SupervisorError::RestartWindowZero`], not-canonical →
19410/// [`crate::SupervisorError::RestartWindowNotCanonical`], cap →
19411/// [`crate::SupervisorError::RestartWindowExceedsCap`],
19412/// cap = [`crate::SUPERVISOR_RESTART_WINDOW_MAX`]).
19413///
19414/// Peer to [`require_positive_bounded_u32`] /
19415/// [`require_positive_bounded_u64`] on the integer-typed capped axes;
19416/// the four typed-`Duration` axes and the four typed-integer axes now
19417/// route through one helper each, so a future axis reaching for the
19418/// same discipline lands in exactly one place. Generic over the
19419/// caller's error enum so the same helper reaches every crate-level
19420/// [`thiserror`] surface — the ten per-axis error variants remain the
19421/// source of truth for each axis's remediation prose; the helper only
19422/// sequences the three gate arms in canonical order and threads the
19423/// value into the not-canonical / cap arms' discriminator fields.
19424///
19425/// # Errors
19426///
19427/// Returns `on_zero()` for `value.is_zero()`; returns
19428/// `on_not_canonical(value)` when `value` carries sub-millisecond
19429/// residue (`value.subsec_nanos() % 1_000_000 != 0`); returns
19430/// `on_cap_exceeded(value)` for `value > cap`; returns `Ok(())`
19431/// otherwise.
19432pub fn require_positive_canonical_bounded_duration<E>(
19433 value: std::time::Duration,
19434 cap: std::time::Duration,
19435 on_zero: impl FnOnce() -> E,
19436 on_not_canonical: impl FnOnce(std::time::Duration) -> E,
19437 on_cap_exceeded: impl FnOnce(std::time::Duration) -> E,
19438) -> Result<(), E> {
19439 if value.is_zero() {
19440 return Err(on_zero());
19441 }
19442 if !crate::supervisor::duration_codec::is_integer_millisecond_duration(value) {
19443 return Err(on_not_canonical(value));
19444 }
19445 if value > cap {
19446 return Err(on_cap_exceeded(value));
19447 }
19448 Ok(())
19449}
19450
19451/// Bracket a `:versao` requirement-string axis with the shared
19452/// "empty-first, then [`crate::parse_requirement`]" gate pair every
19453/// dep-shaped `:versao` slot carries. Returns `on_empty()` when
19454/// `versao.is_empty()`, `on_invalid(reason)` when
19455/// [`crate::parse_requirement`] rejects the non-empty input, `Ok(())`
19456/// otherwise.
19457///
19458/// The empty-first arm strictly precedes the parse arm so a literal
19459/// `""` value surfaces the self-locating empty diagnostic every
19460/// per-axis error variant already documents an "omit the axis to
19461/// express any-version" remediation for, rather than the misleading
19462/// parse-side no-op — [`crate::parse_requirement("")`][crate::parse_requirement]
19463/// hits `semver::VersionReq::parse("")` which returns
19464/// `Ok(VersionReq { comparators: [] })` (semantically identical to
19465/// [`semver::VersionReq::STAR`]), so without the empty-first arm an
19466/// authored blank `:versao "" ` would silently round-trip as an
19467/// implicit `"*"` — the same "silent widening" footgun the peer
19468/// [`require_positive_bounded_u32`] closes on its zero-floor arm.
19469///
19470/// The three existing call sites — [`crate::dep::Dep::validate`] on
19471/// [`crate::dep::Dep::versao`] (empty → [`crate::DepError::VersaoEmpty`],
19472/// invalid → [`crate::DepError::VersaoInvalid`]),
19473/// [`crate::AplicacaoSpec::validate_membros`] on
19474/// [`crate::aplicacao::Membro::versao`] (empty →
19475/// [`crate::AplicacaoError::MembroVersaoEmpty`], invalid →
19476/// [`crate::AplicacaoError::MembroVersaoInvalid`]), and
19477/// [`crate::SupervisorSpec::validate`] on
19478/// [`crate::supervisor::ChildSpec::versao`] (empty →
19479/// [`crate::SupervisorError::EmptyChildVersion`], invalid →
19480/// [`crate::SupervisorError::ChildVersaoInvalid`]) — each formerly
19481/// inlined this two-arm cascade verbatim. Lifting to one canonical
19482/// entry-point closes the drift footgun structurally: a future
19483/// widening of the accepted requirement-shape (a hypothetical
19484/// git-tag-prefix leniency, a per-axis strictness override, or the
19485/// M4 typed-resolver's `constraint:` axis on
19486/// [`ABSORPTION-ROADMAP.md`]'s per-resolver-step trajectory) reaches
19487/// every dep-shaped `:versao` consumer by one edit at this helper,
19488/// not a coordinated rewrite across three modules.
19489///
19490/// Peer of [`require_positive_bounded_u32`] /
19491/// [`require_positive_bounded_u64`] on the same closure-based
19492/// caller-error-variant discipline — the caller owns the enum
19493/// variant + its self-locating discriminator fields
19494/// (`nome`/`caixa`, `versao`), this helper only sequences the two
19495/// gate arms in canonical order and threads the parser's
19496/// `semver`-shaped reason into the invalid arm's `reason:` field.
19497///
19498/// # Errors
19499///
19500/// Returns `on_empty()` for `versao.is_empty()`; returns
19501/// `on_invalid(reason)` when [`crate::parse_requirement`] rejects
19502/// the non-empty input (the parser's `to_string()` output threaded
19503/// through as the invalid arm's `reason:`); returns `Ok(())`
19504/// otherwise.
19505pub fn require_valid_versao_requirement<E>(
19506 versao: &str,
19507 on_empty: impl FnOnce() -> E,
19508 on_invalid: impl FnOnce(String) -> E,
19509) -> Result<(), E> {
19510 if versao.is_empty() {
19511 return Err(on_empty());
19512 }
19513 if let Err(e) = crate::parse_requirement(versao) {
19514 return Err(on_invalid(e.to_string()));
19515 }
19516 Ok(())
19517}
19518
19519/// Bracket a K8s DNS-1123-label-shaped axis with the shared
19520/// "empty-first, then [`is_dns_1123_label`]" gate pair every Servico-
19521/// name reference slot carries. Returns `on_empty()` when
19522/// `value.is_empty()`, `on_invalid(reason)` when [`is_dns_1123_label`]
19523/// rejects the non-empty input, `Ok(())` otherwise.
19524///
19525/// The empty-first arm strictly precedes the shape arm so a literal
19526/// `""` value surfaces each per-axis error variant's narrower self-
19527/// locating `_Empty` diagnostic (`MembroCaixaEmpty`, `PlacementClusterEmpty`,
19528/// `EntradaParaEmpty`, `NomeEmpty`, `EmptyChildName`, `ModuleEmpty`, …)
19529/// rather than the shared predicate's generic "must not be empty" prose
19530/// — the same "misframed generic diagnostic" footgun the peer
19531/// [`require_valid_versao_requirement`] closes on its empty arm. The
19532/// invalid arm threads the predicate's parser-shaped reason verbatim
19533/// into the caller's `*Invalid { reason }` field so the author's
19534/// remediation prose (which specific violation — length / boundary /
19535/// character-class) flows through unchanged.
19536///
19537/// The eight existing call sites — [`crate::AplicacaoSpec`]'s five
19538/// name-shaped slots (`validate_membro_caixa` on `:membros :caixa`,
19539/// `validate_placement_cluster` on `:placement :clusters`,
19540/// `validate_placement_affinity` on `:placement :affinity`,
19541/// `validate_contrato_caixa` on `:contratos :de`/`:para`,
19542/// `validate_entrada_para` on `:entrada :para`),
19543/// [`crate::SupervisorSpec::validate`] on `:children :caixa`,
19544/// [`crate::manifest::Caixa::validate_nome`] on `:nome`, and
19545/// [`crate::upgrade::validate_module`] on `:upgrade-from :module` —
19546/// each formerly inlined this two-arm cascade verbatim. Lifting to one
19547/// canonical entry-point closes the drift footgun structurally: a
19548/// future widening of the accepted DNS-1123-label shape (a hypothetical
19549/// IDN-Punycode-accepting variant, a per-axis strictness override for
19550/// the M4 CR materializer's `spec.name` axes, or the future
19551/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's admission
19552/// webhook floor) reaches every name-shaped consumer by one edit at
19553/// this helper, not a coordinated rewrite across three modules.
19554///
19555/// Peer of [`require_valid_versao_requirement`] on the same closure-
19556/// based caller-error-variant discipline — the caller owns the enum
19557/// variant + its self-locating discriminator fields (`caixa`, `cluster`,
19558/// `affinity`, `nome`, `slot`, `kind`, `module`, …), this helper only
19559/// sequences the two gate arms in canonical order and threads the
19560/// predicate's shape-shaped reason into the invalid arm's `reason:`
19561/// field.
19562///
19563/// # Errors
19564///
19565/// Returns `on_empty()` for `value.is_empty()`; returns
19566/// `on_invalid(reason)` when [`is_dns_1123_label`] rejects the
19567/// non-empty input (the predicate's parser-shaped reason threaded
19568/// through as the invalid arm's `reason:`); returns `Ok(())` otherwise.
19569pub fn require_valid_dns_1123_label<E>(
19570 value: &str,
19571 on_empty: impl FnOnce() -> E,
19572 on_invalid: impl FnOnce(String) -> E,
19573) -> Result<(), E> {
19574 if value.is_empty() {
19575 return Err(on_empty());
19576 }
19577 if let Err(reason) = is_dns_1123_label(value) {
19578 return Err(on_invalid(reason));
19579 }
19580 Ok(())
19581}
19582
19583/// Bracket a sandboxed-relative `.lisp`-terminating path axis with the
19584/// shared "empty → absolute → parent-escape → non-`.lisp`-extension"
19585/// four-arm gate every author-supplied M2 tatara-lisp source-path slot
19586/// on the caixa surface carries. Delegates to
19587/// [`is_sandboxed_relative_path`] for the three structural arms and to
19588/// [`is_lisp_extension`] for the extension arm; returns each arm's
19589/// caller-owned error variant via the four `FnOnce` closures.
19590///
19591/// The arm ordering (`Empty → Absolute → ParentEscape → NonLisp`) is
19592/// canonical across every existing per-axis site — a path that is
19593/// *both* sandbox-escaping and non-`.lisp` surfaces the more
19594/// fundamental sandbox-shape diagnostic first (the `.lisp` remediation
19595/// would be misleading when the offending path can never resolve under
19596/// the caixa root anyway; the canonical fix collapses both into "pin a
19597/// relative `.lisp` path under the caixa root"). Same
19598/// smallest-scope-arm-fires-last posture the peer
19599/// [`require_positive_bounded_u32`] /
19600/// [`require_positive_canonical_bounded_duration`] chains follow on the
19601/// integer / duration axes, and the same posture every per-axis inline
19602/// pre-lift block already applied by hand
19603/// ([`crate::behavior::BehaviorError`]'s `EmptyPath` → `AbsolutePath`
19604/// → `ParentEscape` → `NonLispExtension` chain,
19605/// [`crate::upgrade::UpgradeError`]'s `EmptyScript` → `AbsoluteScript`
19606/// → `ParentEscapeScript` → `NonLispExtensionScript` chain).
19607///
19608/// Two identical-shape call sites collapse onto this helper — one for
19609/// each M2 typed path-slot the wasm-engine reads through
19610/// `tatara_lisp::read`:
19611///
19612/// * [`crate::behavior::BehaviorSpec::validate`] on
19613/// `:behavior :on-*` callback paths — every arm carries the slot
19614/// name verbatim through the closure's caller-side capture (empty
19615/// → [`crate::behavior::BehaviorError::EmptyPath`], absolute →
19616/// [`crate::behavior::BehaviorError::AbsolutePath`], parent-escape
19617/// → [`crate::behavior::BehaviorError::ParentEscape`], non-`.lisp`
19618/// → [`crate::behavior::BehaviorError::NonLispExtension`]);
19619/// * [`crate::upgrade::UpgradeInstruction::validate`]'s `StateChange`
19620/// arm on `:upgrade-from :state-change :script` (empty →
19621/// [`crate::upgrade::UpgradeError::EmptyScript`], absolute →
19622/// [`crate::upgrade::UpgradeError::AbsoluteScript`], parent-escape
19623/// → [`crate::upgrade::UpgradeError::ParentEscapeScript`],
19624/// non-`.lisp` →
19625/// [`crate::upgrade::UpgradeError::NonLispExtensionScript`]).
19626///
19627/// Peer of the sibling `require_positive_bounded_u32` /
19628/// `require_positive_bounded_u64` /
19629/// `require_positive_canonical_bounded_duration` /
19630/// `require_valid_versao_requirement` / `require_valid_dns_1123_label`
19631/// helpers on the same closure-based caller-error-variant discipline —
19632/// the caller owns the enum variant + its self-locating discriminator
19633/// fields (`slot`, `path`, `script`), this helper only sequences the
19634/// four gate arms in canonical order and invokes the caller's closure
19635/// on the offending arm.
19636///
19637/// PRIME DIRECTIVE promotion: the two-consumer duplication budget
19638/// (THEORY.md §I.3.5: "every recurring shape becomes a generator
19639/// before it becomes a pattern; every pattern becomes a library before
19640/// it becomes duplicated code. The duplication budget is zero.")
19641/// promotes the four-step cascade to a typed substrate-side helper on
19642/// the same trajectory the [`is_sandboxed_relative_path`] /
19643/// [`is_lisp_extension`] primitives already follow. A future third
19644/// consumer — the `:bibliotecas` per-entry tatara-lisp source-file
19645/// axis, the `:exe` `:kind Binario` entry-point axis, the M2.5
19646/// wasm-engine pre-warm hook axis, the future `mesh.pleme.io/v1alpha1/Caixa`
19647/// CR materializer's per-path validator — lands as a thin
19648/// four-closure wrapper rather than re-inlining the same four-arm
19649/// cascade.
19650///
19651/// # Errors
19652///
19653/// Returns `on_empty()` when `path` is empty; returns `on_absolute()`
19654/// when `path` is absolute; returns `on_parent_escape()` when `path`
19655/// carries a [`std::path::Component::ParentDir`] component anywhere;
19656/// returns `on_non_lisp()` when `path`'s terminating extension is not
19657/// exactly [`LISP_SOURCE_EXTENSION`]; returns `Ok(())` otherwise.
19658pub fn require_sandboxed_lisp_path<E>(
19659 path: &Path,
19660 on_empty: impl FnOnce() -> E,
19661 on_absolute: impl FnOnce() -> E,
19662 on_parent_escape: impl FnOnce() -> E,
19663 on_non_lisp: impl FnOnce() -> E,
19664) -> Result<(), E> {
19665 match is_sandboxed_relative_path(path) {
19666 Ok(()) => {}
19667 Err(PathShapeViolation::Empty) => return Err(on_empty()),
19668 Err(PathShapeViolation::Absolute) => return Err(on_absolute()),
19669 Err(PathShapeViolation::ParentEscape) => return Err(on_parent_escape()),
19670 }
19671 if !is_lisp_extension(path) {
19672 return Err(on_non_lisp());
19673 }
19674 Ok(())
19675}
19676
19677/// Bracket a per-list uniqueness gate with the shared "insert into
19678/// `seen`; caller-shaped `Err` on the second occurrence" gate every
19679/// declaration-order-preserving `Vec`-authored slot in caixa-core
19680/// carries. Delegates to [`std::collections::HashSet::insert`] verbatim
19681/// (which returns `true` on first insertion, `false` on repeat), then
19682/// invokes the caller's `on_duplicate` closure only on the duplicate
19683/// arm — keeping the hot path (the unique case) allocation-free.
19684///
19685/// The ten existing call sites — [`crate::AplicacaoSpec::validate`]'s
19686/// four per-list uniqueness gates (`:membros :caixa` →
19687/// [`crate::AplicacaoError::MembroDuplicate`], `:placement :clusters` →
19688/// [`crate::AplicacaoError::PlacementClusterDuplicate`],
19689/// `:entrada :paths` → [`crate::AplicacaoError::EntradaPathDuplicate`],
19690/// `:contratos` on the six-tuple typed-edge identity key →
19691/// [`crate::AplicacaoError::ContratoDuplicate`]),
19692/// [`crate::SupervisorSpec::validate`] on `:children :caixa`
19693/// ([`crate::SupervisorError::DuplicateChildCaixa`]),
19694/// [`crate::manifest::Caixa`]'s four per-list uniqueness gates
19695/// ([`crate::manifest::Caixa::validate_deps`] on `:deps` and `:deps-dev`
19696/// → [`crate::DepError::DuplicateNome`],
19697/// [`crate::manifest::Caixa::validate_code_paths`] on
19698/// `:bibliotecas`/`:exe`/`:servicos` →
19699/// [`crate::ManifestError::CodePathDuplicate`],
19700/// [`crate::manifest::Caixa::validate_etiquetas`] on `:etiquetas` →
19701/// [`crate::ManifestError::EtiquetaDuplicate`],
19702/// [`crate::manifest::Caixa::validate_autores`] on `:autores` →
19703/// [`crate::ManifestError::AutorDuplicate`]), and
19704/// [`crate::dep::Dep`]'s [`crate::DepError::CaracteristicaDuplicate`]
19705/// gate on `:caracteristicas` — each formerly inlined the same three-
19706/// line
19707/// ```ignore
19708/// if !seen.insert(key) {
19709/// return Err(<Variant> { … });
19710/// }
19711/// ```
19712/// shape by hand, differing only in the seen-set key type and the
19713/// caller's [`thiserror`] variant. Lifting to one canonical entry-point
19714/// closes the drift footgun structurally: a future tightening of the
19715/// per-list uniqueness discipline (a declaration-order pin on the
19716/// reported entry index, an instrumentation hook for the operator's
19717/// audit trail, the M4 CR materializer's admission-webhook per-list
19718/// invariant) reaches every consumer by one edit at this helper, not
19719/// a coordinated rewrite across every per-list gate in the crate. The
19720/// per-axis error variants remain the source of truth for each axis's
19721/// remediation prose — this helper only sequences the insert-and-check
19722/// pair.
19723///
19724/// Same set-not-multiset discipline every peer `Duplicate*` variant
19725/// documents. The typed key `K` is generic so both `&str`-shaped
19726/// callers (nine sites) and the tuple-shaped
19727/// [`crate::AplicacaoError::ContratoDuplicate`] typed-edge identity
19728/// carrier route through one helper; the caller owns the enum variant
19729/// + its self-locating discriminator fields, this helper only sequences
19730/// the insert-and-check pair in canonical `insert → on_duplicate` order.
19731/// Sibling to the peer `require_positive_bounded_*` /
19732/// `require_positive_canonical_bounded_duration` /
19733/// `require_valid_versao_requirement` / `require_valid_dns_1123_label`
19734/// helpers on the same closure-based caller-error-variant discipline.
19735///
19736/// # Errors
19737///
19738/// Returns `on_duplicate()` when `key` was already in `seen` (the
19739/// [`std::collections::HashSet::insert`] call returns `false`); returns
19740/// `Ok(())` otherwise.
19741pub fn insert_first_seen<K, E, S>(
19742 seen: &mut std::collections::HashSet<K, S>,
19743 key: K,
19744 on_duplicate: impl FnOnce() -> E,
19745) -> Result<(), E>
19746where
19747 K: std::hash::Hash + Eq,
19748 S: std::hash::BuildHasher,
19749{
19750 if seen.insert(key) {
19751 Ok(())
19752 } else {
19753 Err(on_duplicate())
19754 }
19755}
19756
19757/// Test-side pin that asserts a renderer-crate `pub use caixa_core::X;`
19758/// re-export shares both the byte value *and* the `&'static str`
19759/// allocation of its canonical `caixa_core::X` declaration — the
19760/// stronger predicate than a plain `assert_eq!` byte-equality check.
19761///
19762/// The canonical drift footgun this closes: a renderer crate silently
19763/// carries a sibling `pub const X: &str = "…";` (or a copy-pasted
19764/// `pub const X: &str = caixa_core::X;` shape whose right-hand side
19765/// materializes a fresh promoted-static allocation with the same
19766/// bytes) instead of `pub use caixa_core::X;`. A byte-only `assert_eq!`
19767/// on the value would pass — the strings are equal — but the two
19768/// declarations point at two different `&'static` allocations, so a
19769/// future canonical-side rebrand (`caixa_core::X` migrates from
19770/// `"foo"` to `"foo-v2"`) silently drifts the two apart, with the
19771/// apply-time symptom (the cluster-side CRD schema drops the malformed
19772/// axis, the operator's dispatch loop misses the renamed key, the
19773/// Cilium data plane silently reroutes past the renamed L4/L7 rule)
19774/// far from the drift commit's source. Byte-equality misses this
19775/// class of drift; static-data identity via [`std::ptr::eq`] catches
19776/// it structurally.
19777///
19778/// Lifted from the seventy-five per-`_re_export_points_at_caixa_core_
19779/// canonical` test bodies formerly inlined verbatim across
19780/// [`caixa-mesh`][mesh] (49 tests), [`caixa-flux`][flux] (21 tests),
19781/// and [`caixa-helm`][helm] (5 tests) — each formerly carried the same
19782/// two-arm `assert_eq!(<LOCAL>, caixa_core::<LOCAL>);` + `assert!(std
19783/// ::ptr::eq(<LOCAL>.as_ptr(), caixa_core::<LOCAL>.as_ptr()), "…must
19784/// be a re-export of caixa_core::…, not a sibling `pub const`…");`
19785/// pair by hand, differing only in the local `<LOCAL>` identifier the
19786/// diagnostic names. The lifted helper puts the canonical two-arm
19787/// gate in exactly one place so the next per-renderer re-export pin
19788/// (the future [`caixa-otel`] telemetry-pipeline renderer's per-CR
19789/// axis re-exports, the M4 [`mesh.pleme.io/v1alpha1/Aplicacao`] CR
19790/// materializer's per-spec-axis re-exports, the future per-Supervisor
19791/// reconciler's per-`:children` axis re-exports) lands on this
19792/// helper by construction rather than by copying the boilerplate.
19793///
19794/// Same trajectory as the sibling [`require_kind`] /
19795/// [`require_single_servico`] cross-renderer-shared-gate lifts on the
19796/// production-side axis; this closes the peer test-side re-export-
19797/// identity-gate axis.
19798///
19799/// # Panics
19800///
19801/// Panics via [`assert_eq!`] when the two byte-strings differ; panics
19802/// via [`assert!`] on the [`std::ptr::eq`] arm when the two share
19803/// bytes but point at different `&'static str` allocations. The
19804/// `name` argument names the local re-export for the failure message
19805/// so the diagnostic reads `KUBE_KEY_SPEC must be a re-export of
19806/// caixa_core::KUBE_KEY_SPEC, …` — pointing at the offending
19807/// re-export site, not just at the assertion.
19808///
19809/// [mesh]: https://docs.rs/caixa-mesh
19810/// [flux]: https://docs.rs/caixa-flux
19811/// [helm]: https://docs.rs/caixa-helm
19812pub fn assert_str_reexport_identity(name: &str, local: &'static str, canonical: &'static str) {
19813 assert_eq!(
19814 local, canonical,
19815 "{name} must byte-equal caixa_core::{name}"
19816 );
19817 assert!(
19818 std::ptr::eq(local.as_ptr(), canonical.as_ptr()),
19819 "{name} must be a re-export of caixa_core::{name}, \
19820 not a sibling `pub const` that happens to carry the same string \
19821 — drift between the two is the canonical footgun this lift closes"
19822 );
19823}
19824
19825/// Extension methods on [`serde_yaml::Mapping`] that lift the per-key
19826/// scalar-promotion boilerplate every K8s-artifact-emitter across
19827/// `caixa-mesh`, `caixa-flux`, `caixa-helm`, and `caixa-core::render`
19828/// carries: the canonical `mapping.insert(Value::String(key.into()),
19829/// value)` three-liner the schema-key axis of every emitted YAML
19830/// document tunnels a `&'static str` key axis-name through.
19831///
19832/// Five methods form the primitive quintuple — one per non-Null
19833/// primitive [`serde_yaml::Value`] variant the K8s-artifact-emit
19834/// surface actually reaches for as a leaf payload:
19835///
19836/// * [`Self::insert_str_key`] — insert with a `&str` key and any
19837/// fully-built [`serde_yaml::Value`]. The building block every
19838/// other renderer helper (`yaml_string_mapping`, `label_selector`,
19839/// `kube_resource_skeleton`, `single_field_overlay`) composes on
19840/// top of.
19841/// * [`Self::insert_string`] — insert with a `&str` key and an
19842/// `Into<String>` value that gets auto-promoted to
19843/// [`serde_yaml::Value::String`]. The string-scalar-valued-field
19844/// shape every schema-typed `apiVersion` / `kind` /
19845/// `metadata.namespace` / `port.protocol` / `hostname` /
19846/// `path.value` axis emission uses — collapses the two-step
19847/// `insert_str_key(K, Value::String(V.into()))` boilerplate onto
19848/// one direct call.
19849/// * [`Self::insert_number`] — insert with a `&str` key and an
19850/// `Into<serde_yaml::Number>` value that gets auto-promoted to
19851/// [`serde_yaml::Value::Number`]. The integer-scalar-valued-field
19852/// shape every schema-typed `port` / `targetPort` / `attempts` /
19853/// `maxFailures` / `hostPort` axis emission uses — collapses the
19854/// two-step `insert_str_key(K, Value::Number(N.into()))`
19855/// boilerplate onto one direct call.
19856/// * [`Self::insert_mapping`] — insert with a `&str` key and a
19857/// [`serde_yaml::Mapping`] value that gets auto-promoted to
19858/// [`serde_yaml::Value::Mapping`]. The nested-Mapping-valued-field
19859/// shape every schema-typed `metadata` / `spec` / `spec.rules[].path`
19860/// / `toPorts[].rules` sub-block emission uses — collapses the
19861/// two-step `insert_str_key(K, Value::Mapping(m))` boilerplate
19862/// onto one direct call.
19863/// * [`Self::insert_sequence`] — insert with a `&str` key and a
19864/// `Vec<serde_yaml::Value>` value that gets auto-promoted to
19865/// [`serde_yaml::Value::Sequence`]. The list-shape-valued-field
19866/// shape every schema-typed `spec.ingress[].fromEndpoints` /
19867/// `spec.ingress[].toPorts` / `spec.hostnames` / `spec.rules` list
19868/// emission uses — collapses the two-step
19869/// `insert_str_key(K, Value::Sequence(v))` boilerplate onto one
19870/// direct call.
19871///
19872/// A sibling method — [`Self::entry_str_key`] — closes the entry-API
19873/// twin of [`Self::insert_str_key`] on the same `&str → Value::String`
19874/// key-promotion axis: the [`serde_yaml::Mapping::entry`] method's
19875/// `Value` parameter demands the same `Value::String(<K>.into())`
19876/// wrapping every fresh-emit site's `insert_str_key` call closes, but
19877/// on the idempotent-upsert axis (where callers compose
19878/// `.or_insert(...)` / `.or_insert_with(...)` / `.and_modify(...)` /
19879/// `.or_default()` on the returned entry handle) rather than the
19880/// fresh-emit axis. Same key-promotion contract, different downstream
19881/// API surface — so a future rebrand of the promotion (e.g. to
19882/// [`serde_yaml::Value::Tagged`] under a K8s Server-Side-Apply typed-
19883/// field-ownership axis) reaches both fresh-emit and upsert sites
19884/// through one lift.
19885///
19886/// See each method's docstring for its compounding rationale.
19887pub trait MappingExt {
19888 /// Insert `(key, value)` into `self` with `key` promoted to a
19889 /// [`serde_yaml::Value::String`]. Returns the prior value at that
19890 /// key, mirroring [`serde_yaml::Mapping::insert`].
19891 ///
19892 /// The canonical shape ~48 call sites across the caixa-side
19893 /// renderer surface (`caixa-mesh` per-`CiliumNetworkPolicy` /
19894 /// `Gateway` / `HTTPRoute` construction, `caixa-flux` per-
19895 /// `GitRepository` / `HelmRelease` / `Kustomization` construction,
19896 /// `caixa-helm` per-`Chart.yaml` / `values.yaml` construction,
19897 /// `caixa-core::render` per-skeleton construction) previously
19898 /// carried inline as the three-line block
19899 /// `mapping.insert(serde_yaml::Value::String(<KEY>.into()),
19900 /// <VALUE>)` — three per-call boilerplate axes (`serde_yaml::` path
19901 /// re-quote, `Value::String(_)` promotion, `.into()` `&str → String`
19902 /// coercion) around a two-token semantic payload (`<KEY>`, `<VALUE>`).
19903 ///
19904 /// Lifting collapses the boilerplate into one method call the
19905 /// caller reads as intent (`mapping.insert_str_key(<KEY>, <VALUE>)`
19906 /// — "insert this schema key with this rendered value") rather
19907 /// than five hand-spelled positional artifacts. The next renderer
19908 /// to land — the per-`:politicas` `CiliumClusterwideEnvoyConfig`
19909 /// emitter (MESH-COMPOSITION §III.2 #3), the `app-operator`'s
19910 /// typed `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (§III.2
19911 /// #5), the M4 cross-cluster fan-out's per-cluster `Service` /
19912 /// `HTTPRoute backendRefs` emission, the future `caixa-otel`
19913 /// OpenTelemetry-Collector pipeline emitter — gets the canonical
19914 /// key-scalar-promotion for free with one method call, instead of
19915 /// re-inlining the three-line block.
19916 ///
19917 /// Peer to the sibling render-side helpers on the
19918 /// [`serde_yaml::Value`]-construction surface:
19919 /// [`yaml_string_mapping`] (string→string mapping), [`label_selector`]
19920 /// (K8s `LabelSelector` shape), [`kube_resource_skeleton`] (K8s
19921 /// `apiVersion`+`kind`+`metadata` skeleton), [`single_field_overlay`]
19922 /// (`Option<T>` → single-key overlay). Each closes a distinct axis
19923 /// of the K8s-artifact-emit surface's "same shape, written N times"
19924 /// duplication; this one closes the per-key insert primitive the
19925 /// other four all compose on top of.
19926 fn insert_str_key(&mut self, key: &str, value: serde_yaml::Value) -> Option<serde_yaml::Value>;
19927
19928 /// Insert `(key, Value::String(value.into()))` into `self` — the
19929 /// string-scalar-valued-field emission shape that combines
19930 /// [`Self::insert_str_key`]'s `&str → Value::String` key promotion
19931 /// with an automatic `Value::String` promotion of an `Into<String>`
19932 /// value. Returns the prior value at that key, mirroring
19933 /// [`serde_yaml::Mapping::insert`].
19934 ///
19935 /// The canonical shape ~17 production call sites across the caixa-
19936 /// side renderer surface previously carried inline as the three-
19937 /// line block `mapping.insert_str_key(<KEY>,
19938 /// serde_yaml::Value::String(<VALUE>.into() | .clone() |
19939 /// .to_string()))` — the two-token semantic payload (`<KEY>`,
19940 /// `<VALUE>`) buried under three boilerplate axes (`serde_yaml::`
19941 /// path re-quote, `Value::String(_)` promotion, the
19942 /// `.into() | .clone() | .to_string()` `→ String` coercion).
19943 ///
19944 /// Sites lifted:
19945 ///
19946 /// * caixa-mesh's `programs_for_aplicacao` per-`:membros` entry
19947 /// (`FLEET_PROGRAMS_KEY_NAME` / `FLEET_PROGRAMS_KEY_VERSAO` /
19948 /// `FLEET_PROGRAMS_KEY_APLICACAO`);
19949 /// * caixa-mesh's `cilium_network_policies` per-`toPorts[]` port
19950 /// entry (`KUBE_KEY_PORT` / `KUBE_KEY_PROTOCOL`) and per-HTTP-
19951 /// rule `CILIUM_KEY_PATH` L7 predicate;
19952 /// * caixa-mesh's `gateway_routes` per-`Gateway` listener block
19953 /// (`GATEWAY_API_KEY_NAME` /
19954 /// [`crate::GATEWAY_API_KEY_HOSTNAME`] / `GATEWAY_API_KEY_PROTOCOL`)
19955 /// and `spec.gatewayClassName`;
19956 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute` `parentRefs[]`
19957 /// name, per-rule `matches[].path.{type,value}` prefix-match, and
19958 /// per-rule `backendRefs[].name` backend-target;
19959 /// * caixa-flux's `programs_yaml_entry` per-entry `name` /
19960 /// `namespace` axes;
19961 /// * caixa-core `kube_resource_skeleton`'s `apiVersion` / `kind`
19962 /// scalar heads (the two production emit sites the prior
19963 /// `Value::String(_.to_string())` inline shape sat at).
19964 ///
19965 /// Lifting collapses the boilerplate into one method call the
19966 /// caller reads as intent (`mapping.insert_string(<KEY>, <VALUE>)`
19967 /// — "insert a string-scalar-typed field named `KEY` with rendered
19968 /// value `VALUE`") rather than four hand-spelled positional
19969 /// artifacts. The next renderer to land — the per-`:politicas`
19970 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy string-
19971 /// scalar axes are `name` / `namespace` / `defaultAction`), the
19972 /// `app-operator`'s typed `mesh.pleme.io/v1alpha1/Aplicacao` CR
19973 /// materializer (per-`spec.selectors[]` `name` / per-`spec.gates[]`
19974 /// string-typed axes), the M4 cross-cluster fan-out's per-cluster
19975 /// `Service.spec.ports[].name` / `HTTPRoute.spec.rules[].filters[].
19976 /// requestHeaderModifier.set[].name` string-scalar emission, the
19977 /// future `caixa-otel` OpenTelemetry-Collector `pipelines.traces.
19978 /// receivers[].endpoint` string-scalar emission — gets the canonical
19979 /// string-scalar-valued-field shape for free with one method call,
19980 /// instead of re-inlining the three-token
19981 /// `Value::String(_.into() | .clone() | .to_string())` block.
19982 ///
19983 /// Peer to [`Self::insert_str_key`] on the sibling any-Value axis —
19984 /// the two together form the "one method call per emission axis"
19985 /// primitive pair the K8s-artifact-emit surface's "same shape,
19986 /// written N times" duplication (THEORY.md §I.3.5) collapses onto.
19987 fn insert_string<V: Into<String>>(&mut self, key: &str, value: V) -> Option<serde_yaml::Value>;
19988
19989 /// Insert `(key, Value::Number(value.into()))` into `self` — the
19990 /// integer-scalar-valued-field emission shape that combines
19991 /// [`Self::insert_str_key`]'s `&str → Value::String` key promotion
19992 /// with an automatic [`serde_yaml::Value::Number`] promotion of an
19993 /// `Into<serde_yaml::Number>` value. Returns the prior value at that
19994 /// key, mirroring [`serde_yaml::Mapping::insert`].
19995 ///
19996 /// The canonical shape 2 production call sites across `caixa-mesh`
19997 /// previously carried inline as the three-token block
19998 /// `mapping.insert_str_key(<KEY>, serde_yaml::Value::Number(<N>.into()))`
19999 /// — the two-token semantic payload (`<KEY>`, `<N>`) buried under
20000 /// three boilerplate axes (`serde_yaml::` path re-quote,
20001 /// `Value::Number(_)` promotion, the `<N>.into()` typed-integer →
20002 /// [`serde_yaml::Number`] coercion) around a numeric constant or
20003 /// typed field the caller already carries as `u16` / `u32` / `u64`.
20004 ///
20005 /// Sites lifted:
20006 ///
20007 /// * caixa-mesh's `gateway_routes` per-`Gateway` `spec.listeners[].port`
20008 /// external HTTP listener port (`KUBE_KEY_PORT` around the lifted
20009 /// [`crate::GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`] `u16` const,
20010 /// cd60fde);
20011 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute.spec.rules[].backendRefs[].port`
20012 /// backend-target Servico port (`KUBE_KEY_PORT` around the
20013 /// [`crate::AplicacaoSpec`]-side `entrada.port` `u16` field the
20014 /// `:entrada :port` typed slot flows through).
20015 ///
20016 /// Lifting collapses the boilerplate into one method call the
20017 /// caller reads as intent (`mapping.insert_number(<KEY>, <N>)` —
20018 /// "insert a numeric-scalar-typed field named `KEY` with the typed
20019 /// integer `N`") rather than three hand-spelled positional artifacts.
20020 /// The next renderer to land — the per-`:politicas`
20021 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
20022 /// integer-scalar axes are the Envoy circuit-breaker
20023 /// `maxRequests` / `maxPendingRequests` / `maxConnections` count
20024 /// fields and the Cilium ratelimit `requestPerUnit` field,
20025 /// MESH-COMPOSITION §III.2 #3), the `app-operator`'s typed
20026 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (per-`spec.
20027 /// selectors[]` integer-scored `weight` fields, §III.2 #5), the
20028 /// M4 cross-cluster fan-out's per-cluster
20029 /// `Service.spec.ports[].{port, targetPort, nodePort}` /
20030 /// `HTTPRoute.spec.rules[].backendRefs[].{port, weight}`
20031 /// integer-scalar emission, the future `caixa-otel`
20032 /// OpenTelemetry-Collector `service.pipelines.traces.receivers[].
20033 /// grpc.max_recv_msg_size_mib` integer-scalar emission — gets the
20034 /// canonical integer-scalar-valued-field shape for free with one
20035 /// method call, instead of re-inlining the three-token
20036 /// `Value::Number(_.into())` block.
20037 ///
20038 /// The `Into<serde_yaml::Number>` bound accepts every numeric
20039 /// primitive [`serde_yaml::Number`] declares `From` for
20040 /// (`i8`..=`i64`, `u8`..=`u64`, `f32`, `f64`) — the same coverage
20041 /// the two production sites reach through with their `u16` port
20042 /// fields and the same coverage every future numeric-scalar
20043 /// emission (the K8s `Service.spec.ports[].targetPort` `IntOrString`
20044 /// integer arm, the `HTTPRoute.spec.rules[].backendRefs[].weight`
20045 /// `int32` axis, the Envoy `maxRequests` `uint32` axis) reaches
20046 /// through with matching typed integer fields.
20047 ///
20048 /// Peer to [`Self::insert_string`] on the sibling string-scalar axis
20049 /// and to [`Self::insert_mapping`] / [`Self::insert_sequence`] on
20050 /// the sibling nested-Mapping / list-shape axes — the five together
20051 /// with [`Self::insert_str_key`] form the "one method call per
20052 /// emission axis" primitive quintuple the K8s-artifact-emit
20053 /// surface's "same shape, written N times" duplication (THEORY.md
20054 /// §I.3.5) collapses onto: `insert_str_key` for any-Value inserts,
20055 /// `insert_string` for the string-scalar-valued-field shape,
20056 /// `insert_number` for the integer-scalar-valued-field shape,
20057 /// `insert_mapping` for the nested-Mapping-valued-field shape,
20058 /// `insert_sequence` for the list-shape-valued-field shape.
20059 fn insert_number<N: Into<serde_yaml::Number>>(
20060 &mut self,
20061 key: &str,
20062 value: N,
20063 ) -> Option<serde_yaml::Value>;
20064
20065 /// Insert `(key, Value::Mapping(value))` into `self` — the
20066 /// nested-Mapping-valued-field emission shape that combines
20067 /// [`Self::insert_str_key`]'s `&str → Value::String` key promotion
20068 /// with an automatic [`serde_yaml::Value::Mapping`] promotion of a
20069 /// [`serde_yaml::Mapping`] value. Returns the prior value at that
20070 /// key, mirroring [`serde_yaml::Mapping::insert`].
20071 ///
20072 /// The canonical shape ~6 production call sites across the caixa-
20073 /// side renderer surface previously carried inline as the three-
20074 /// token block `mapping.insert_str_key(<KEY>,
20075 /// serde_yaml::Value::Mapping(<INNER>))` — a two-token semantic
20076 /// payload (`<KEY>`, `<INNER>`) buried under a two-axis boilerplate
20077 /// (`serde_yaml::` path re-quote, `Value::Mapping(_)` promotion)
20078 /// around a `Mapping` variable the caller already built.
20079 ///
20080 /// Sites lifted:
20081 ///
20082 /// * caixa-mesh's `cilium_network_policies` per-`toPorts[]`
20083 /// `rules:` L7-introspection sub-block (`KUBE_KEY_RULES` around
20084 /// the built `rules` Mapping);
20085 /// * caixa-mesh's `cilium_network_policies` per-`CiliumNetworkPolicy`
20086 /// `spec:` block (`KUBE_KEY_SPEC` around the built `policy_spec`
20087 /// Mapping);
20088 /// * caixa-mesh's `gateway_routes` per-`Gateway` `spec:` block
20089 /// (`KUBE_KEY_SPEC` around the built `g_spec` Mapping);
20090 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute.spec.rules[]`
20091 /// `matches[].path:` sub-block (`GATEWAY_API_KEY_PATH` around the
20092 /// built `path_match` Mapping);
20093 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute` `spec:` block
20094 /// (`KUBE_KEY_SPEC` around the built `r_spec` Mapping);
20095 /// * caixa-core's `kube_resource_skeleton` per-CR
20096 /// `metadata:` sub-block (`KUBE_KEY_METADATA` around the built
20097 /// `metadata_map` Mapping).
20098 ///
20099 /// Lifting collapses the boilerplate into one method call the
20100 /// caller reads as intent (`mapping.insert_mapping(<KEY>, <INNER>)`
20101 /// — "insert a nested-Mapping-typed sub-block named `KEY` with the
20102 /// built inner `INNER`") rather than three hand-spelled positional
20103 /// artifacts. The next renderer to land — the per-`:politicas`
20104 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
20105 /// nested-Mapping sub-blocks are `metadata:` / `spec:` /
20106 /// `spec.resources[]`), the `app-operator`'s typed
20107 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer
20108 /// (per-`spec.selectors[]` and per-`spec.gates[]` sub-blocks), the
20109 /// M4 cross-cluster fan-out's per-cluster `Service.spec` /
20110 /// `HTTPRoute.spec` sub-block emission, the future `caixa-otel`
20111 /// OpenTelemetry-Collector per-pipeline `receivers:` /
20112 /// `processors:` / `exporters:` nested-Mapping emission — gets the
20113 /// canonical nested-Mapping-valued-field shape for free with one
20114 /// method call, instead of re-inlining the three-token
20115 /// `Value::Mapping(_)` promotion.
20116 ///
20117 /// Peer to [`Self::insert_string`] on the sibling scalar-value axis
20118 /// and [`Self::insert_sequence`] on the sibling list-shape axis —
20119 /// the four together with [`Self::insert_str_key`] form the "one
20120 /// method call per emission axis" primitive quadruple the K8s-
20121 /// artifact-emit surface's "same shape, written N times" duplication
20122 /// (THEORY.md §I.3.5) collapses onto: `insert_str_key` for any-Value
20123 /// inserts, `insert_string` for the string-scalar-valued-field
20124 /// shape, `insert_mapping` for the nested-Mapping-valued-field
20125 /// shape, `insert_sequence` for the list-shape-valued-field shape.
20126 fn insert_mapping(
20127 &mut self,
20128 key: &str,
20129 value: serde_yaml::Mapping,
20130 ) -> Option<serde_yaml::Value>;
20131
20132 /// Insert `(key, Value::Sequence(value))` into `self` — the
20133 /// list-shape-valued-field emission shape that combines
20134 /// [`Self::insert_str_key`]'s `&str → Value::String` key promotion
20135 /// with an automatic [`serde_yaml::Value::Sequence`] promotion of a
20136 /// pre-built `Vec<serde_yaml::Value>` value. Returns the prior
20137 /// value at that key, mirroring [`serde_yaml::Mapping::insert`].
20138 ///
20139 /// The canonical shape 4 production call sites across `caixa-mesh`
20140 /// previously carried inline as the three-token block
20141 /// `mapping.insert_str_key(<KEY>, serde_yaml::Value::Sequence(<VEC>))`
20142 /// — a two-token semantic payload (`<KEY>`, `<VEC>`) buried under a
20143 /// two-axis boilerplate (`serde_yaml::` path re-quote,
20144 /// `Value::Sequence(_)` promotion) around a `Vec<Value>` variable
20145 /// the caller already built.
20146 ///
20147 /// Sites lifted:
20148 ///
20149 /// * caixa-mesh's `cilium_network_policies` per-`CiliumNetworkPolicy`
20150 /// `spec.ingress[].fromEndpoints:` singleton-list (`CILIUM_KEY_FROM_ENDPOINTS`
20151 /// around a `vec![from_endpoint]` selector wrapper);
20152 /// * caixa-mesh's `cilium_network_policies` per-`CiliumNetworkPolicy`
20153 /// `spec.ingress[].toPorts:` list (`CILIUM_KEY_TO_PORTS` around the
20154 /// built `to_ports_seq` per-edge port-and-L7-rule vec);
20155 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute` `spec.hostnames:`
20156 /// singleton-list (`GATEWAY_API_KEY_HOSTNAMES` around a
20157 /// `vec![Value::String(entrada.host…)]` host wrapper);
20158 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute` `spec.rules:`
20159 /// list (`KUBE_KEY_RULES` around the built `rules` per-path
20160 /// match+backend+overlay vec).
20161 ///
20162 /// Lifting collapses the boilerplate into one method call the
20163 /// caller reads as intent (`mapping.insert_sequence(<KEY>, <VEC>)`
20164 /// — "insert a list-shape-typed sub-block named `KEY` with the built
20165 /// inner `VEC`") rather than three hand-spelled positional
20166 /// artifacts. The next renderer to land — the per-`:politicas`
20167 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
20168 /// list-shape sub-blocks are `spec.resources[]` / `spec.listeners[]`
20169 /// / `spec.virtualHosts[]`, MESH-COMPOSITION §III.2 #3), the
20170 /// `app-operator`'s typed `mesh.pleme.io/v1alpha1/Aplicacao` CR
20171 /// materializer (per-`spec.selectors[]` and per-`spec.gates[]`
20172 /// list-shape sub-blocks, §III.2 #5), the M4 cross-cluster fan-out's
20173 /// per-cluster `Service.spec.ports[]` /
20174 /// `HTTPRoute.spec.rules[].backendRefs[]` list emission, the future
20175 /// `caixa-otel` OpenTelemetry-Collector per-pipeline `receivers[]`
20176 /// / `processors[]` / `exporters[]` list emission — gets the
20177 /// canonical list-shape-valued-field shape for free with one method
20178 /// call, instead of re-inlining the three-token `Value::Sequence(_)`
20179 /// promotion.
20180 ///
20181 /// Peer to [`Self::insert_mapping`] on the sibling nested-Mapping
20182 /// axis and [`Self::insert_string`] on the sibling scalar-value axis
20183 /// — the four together with [`Self::insert_str_key`] form the "one
20184 /// method call per emission axis" primitive quadruple the K8s-
20185 /// artifact-emit surface's "same shape, written N times" duplication
20186 /// (THEORY.md §I.3.5) collapses onto: `insert_str_key` for any-Value
20187 /// inserts, `insert_string` for the string-scalar-valued-field
20188 /// shape, `insert_mapping` for the nested-Mapping-valued-field
20189 /// shape, `insert_sequence` for the list-shape-valued-field shape.
20190 ///
20191 /// Complementary to [`singleton_mapping_sequence`] on the peer
20192 /// singleton-list-shape axis: `singleton_mapping_sequence(m)` builds
20193 /// the sole-Mapping-element `Value::Sequence` payload;
20194 /// `insert_sequence(K, v)` inserts an already-built `Vec<Value>`
20195 /// payload under a schema key. A caller composing the two through
20196 /// [`Self::insert_singleton_mapping_sequence`] writes
20197 /// `mapping.insert_singleton_mapping_sequence(K, m)` for the
20198 /// singleton case (the sole element is a fresh Mapping); reach for
20199 /// `mapping.insert_sequence(K, v)` for the multi-element or
20200 /// non-Mapping-element case (the vec is built up per-iteration or
20201 /// wraps a non-Mapping scalar).
20202 fn insert_sequence(
20203 &mut self,
20204 key: &str,
20205 value: Vec<serde_yaml::Value>,
20206 ) -> Option<serde_yaml::Value>;
20207
20208 /// Insert `(key, Value::Sequence(vec![Value::Mapping(value)]))` into
20209 /// `self` — the singleton-Mapping-list-shape-valued-field emission
20210 /// shape that composes [`Self::insert_str_key`]'s
20211 /// `&str → Value::String` key promotion with the
20212 /// [`singleton_mapping_sequence`] helper's singleton-list wrap of a
20213 /// [`serde_yaml::Mapping`] payload. Returns the prior value at that
20214 /// key, mirroring [`serde_yaml::Mapping::insert`].
20215 ///
20216 /// The canonical shape 7 production call sites across `caixa-mesh`
20217 /// previously carried inline as the two-token composition
20218 /// `mapping.insert_str_key(<KEY>, singleton_mapping_sequence(<M>))`
20219 /// — a two-token semantic payload (`<KEY>`, `<M>`) buried under a
20220 /// two-symbol boilerplate (`insert_str_key(_, _)` +
20221 /// `singleton_mapping_sequence(_)`) that fully covers the axis: every
20222 /// site both wraps its per-call `Mapping` as the sole-element list
20223 /// value and inserts it under a schema key on an outer `Mapping`. A
20224 /// rebrand on either half — the outer key-scalar promotion axis
20225 /// migrating to a per-key typed `Value` variant, the singleton-list
20226 /// wrap migrating to a Server-Side-Apply-typed `Value::Tagged`
20227 /// per-CRD-list shape once K8s per-field ownership annotations reach
20228 /// the K8s Gateway API / Cilium NetworkPolicy CRD list schemas —
20229 /// would silently desynchronize one site while leaving the other six
20230 /// on the old shape.
20231 ///
20232 /// Sites lifted:
20233 ///
20234 /// * caixa-mesh's `cilium_network_policies` per-`toPorts[]` port
20235 /// entry `ports:` singleton-list (`CILIUM_KEY_PORTS` around the
20236 /// built `port_entry` Mapping);
20237 /// * caixa-mesh's `cilium_network_policies` per-`toPorts[]` L7
20238 /// `rules.http:` singleton-list (`CILIUM_KEY_HTTP` around the
20239 /// built `http_rule` Mapping);
20240 /// * caixa-mesh's `cilium_network_policies` per-`CiliumNetworkPolicy`
20241 /// `spec.ingress:` singleton-list (`CILIUM_KEY_INGRESS` around the
20242 /// built `ingress_rule` Mapping);
20243 /// * caixa-mesh's `gateway_routes` per-`Gateway` `spec.listeners:`
20244 /// singleton-list (`GATEWAY_API_KEY_LISTENERS` around the built
20245 /// `listener` Mapping);
20246 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute.spec.rules[]`
20247 /// `matches:` singleton-list (`GATEWAY_API_KEY_MATCHES` around the
20248 /// built `match_entry` Mapping);
20249 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute.spec.rules[]`
20250 /// `backendRefs:` singleton-list (`GATEWAY_API_KEY_BACKEND_REFS`
20251 /// around the built `backend_ref` Mapping);
20252 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute`
20253 /// `spec.parentRefs:` singleton-list (`GATEWAY_API_KEY_PARENT_REFS`
20254 /// around the built `parent_ref` Mapping).
20255 ///
20256 /// Lifting collapses the two-symbol composition into one method call
20257 /// the caller reads as intent (`mapping.insert_singleton_mapping_sequence
20258 /// (<KEY>, <M>)` — "insert a singleton-Mapping-list-shape sub-block
20259 /// named `KEY` wrapping the built inner `M`") rather than two
20260 /// nested calls. Peer to [`Self::insert_sequence`] on the sibling
20261 /// multi-element or non-Mapping-element list-shape axis — the two
20262 /// together partition the list-shape-valued-field emission surface:
20263 /// [`Self::insert_singleton_mapping_sequence`] for the sole-Mapping-
20264 /// element case, [`Self::insert_sequence`] for every other case.
20265 ///
20266 /// The next renderer to land — the per-`:politicas`
20267 /// `CiliumClusterwideEnvoyConfig` emitter (whose singleton
20268 /// `spec.resources:[]` / `spec.listeners:[]` / `spec.virtualHosts:[]`
20269 /// Mapping-element blocks, MESH-COMPOSITION §III.2 #3, are exactly the
20270 /// singleton-Mapping-list shape), the `app-operator`'s typed
20271 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (per-single-
20272 /// selector / per-single-gate emission, §III.2 #5), the M4 cross-
20273 /// cluster fan-out's per-cluster singleton `Service.spec.ports[]` /
20274 /// `HTTPRoute.spec.rules[].backendRefs[]` sole-element emission, the
20275 /// future `caixa-otel` OpenTelemetry-Collector `pipelines.traces.
20276 /// receivers[]` singleton-receiver emission — gets the canonical
20277 /// singleton-Mapping-list-shape wrap+insert for free with one method
20278 /// call, instead of re-inlining the two-symbol composition.
20279 fn insert_singleton_mapping_sequence(
20280 &mut self,
20281 key: &str,
20282 value: serde_yaml::Mapping,
20283 ) -> Option<serde_yaml::Value>;
20284
20285 /// Entry-API sibling of [`Self::insert_str_key`] — mint the
20286 /// `Value::String(<KEY>.into())` key-promotion the underlying
20287 /// [`serde_yaml::Mapping::entry`] method's `Value` parameter
20288 /// demands, and return the entry-API's
20289 /// [`serde_yaml::mapping::Entry`] handle the caller composes
20290 /// `.or_insert(<V>)` / `.or_insert_with(<F>)` /
20291 /// `.and_modify(<F>)` / `.or_default()` on.
20292 ///
20293 /// The canonical shape 4 production call sites across `caixa-flux`
20294 /// previously carried inline as the three-token composition
20295 /// `mapping.entry(serde_yaml::Value::String(<KEY>.into()))` around
20296 /// a one-token semantic payload (the schema key axis-name). Every
20297 /// site immediately composes an `.or_insert(...)` on the returned
20298 /// [`serde_yaml::mapping::Entry`] handle — the pattern is the
20299 /// entry-API twin of the [`Self::insert_str_key`] pattern the
20300 /// ~48 fresh-emit sites already collapsed onto (23506b3).
20301 ///
20302 /// Sites lifted:
20303 ///
20304 /// * caixa-flux's `programs_yaml_entry` per-`servico_m2_overlay`
20305 /// key idempotent-upsert loop (`entry.entry(Value::String(
20306 /// <key>.to_string())).or_insert(<value>)` — one
20307 /// `.or_insert(...)` per `M2_KEY_LIMITS` / `M2_KEY_BEHAVIOR` /
20308 /// `M2_KEY_UPGRADE_FROM` axis, iterating the
20309 /// [`servico_m2_overlay`] `BTreeMap`);
20310 /// * caixa-flux's `upsert_into_helmrelease_programs` per-
20311 /// `HelmRelease.spec.values` upsert-if-absent (`FLUX_KEY_VALUES`
20312 /// around a default fresh `Value::Mapping`);
20313 /// * caixa-flux's `upsert_into_helmrelease_programs` per-
20314 /// `HelmRelease.spec.values.programs` upsert-if-absent
20315 /// (`FLEET_PROGRAMS_KEY_PROGRAMS` around a default fresh
20316 /// `Value::Sequence`);
20317 /// * caixa-flux's `upsert_into_programs_yaml` per-top-level
20318 /// `programs:` upsert-if-absent (`FLEET_PROGRAMS_KEY_PROGRAMS`
20319 /// around a default fresh `Value::Sequence` — the sibling of
20320 /// the `upsert_into_helmrelease_programs` site on the same
20321 /// key, one path deep in a HelmRelease `spec.values.` sub-tree,
20322 /// one path at the values.yaml root).
20323 ///
20324 /// Lifting collapses the three-token composition into one method
20325 /// call the caller reads as intent
20326 /// (`mapping.entry_str_key(<KEY>).or_insert(<DEFAULT>)` — "get the
20327 /// entry handle for this schema key and default it if missing")
20328 /// rather than four hand-spelled positional artifacts
20329 /// (`serde_yaml::` path re-quote, `Value::String(_)` promotion,
20330 /// the `.into() | .to_string()` `&str → String` coercion, plus the
20331 /// `.entry(_)` call itself). The next renderer to land — the
20332 /// per-`:politicas` `CiliumClusterwideEnvoyConfig` emitter (which
20333 /// upserts singleton `spec.resources:[]` / `spec.listeners:[]`
20334 /// blocks under an existing per-cluster overlay CR, MESH-COMPOSITION
20335 /// §III.2 #3), the `app-operator`'s typed
20336 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (which
20337 /// upserts `status.` sub-fields on partial reconciles, §III.2 #5),
20338 /// the M4 cross-cluster fan-out's per-cluster idempotent
20339 /// HelmRelease upsert — gets the canonical entry-API key-promotion
20340 /// for free with one method call, instead of re-inlining the
20341 /// three-token block.
20342 ///
20343 /// Peer to [`Self::insert_str_key`] on the sibling fresh-emit
20344 /// axis of the same `&str → Value::String` key-promotion — the
20345 /// two together partition the `Mapping`-write surface: entry-API
20346 /// for idempotent-upsert sites where the caller cares whether the
20347 /// prior value was present (`or_insert` / `and_modify` /
20348 /// `or_default` composition), insert-API for fresh-emit sites where
20349 /// the caller unconditionally writes a value and either drops or
20350 /// pattern-matches on the returned `Option<Value>` prior value.
20351 fn entry_str_key(&mut self, key: &str) -> serde_yaml::mapping::Entry<'_>;
20352
20353 /// Arity-0-or-1 twin of [`Self::insert_str_key`] — insert
20354 /// `(key, value.clone())` iff `value` is `Some`; leave `self`
20355 /// untouched iff `value` is `None`. Returns the prior value at that
20356 /// key when the insert fires (mirroring
20357 /// [`serde_yaml::Mapping::insert`]), and `None` otherwise (no insert
20358 /// happened, so no prior value can be surfaced).
20359 ///
20360 /// The canonical shape 3 production call sites across `caixa-mesh`
20361 /// previously carried inline as the three-line block
20362 /// `if let Some(<x>) = &<overlay> { <mapping>.insert_str_key(<KEY>,
20363 /// <x>.clone()); }` around a two-token semantic payload (the schema
20364 /// key axis-name + the `Option<Value>` overlay slot). Every site
20365 /// pairs a per-`:politicas` overlay [`single_field_overlay`] `Option
20366 /// <Value>` output with the same conditional-insert conditional —
20367 /// the arity-0-or-1 twin of [`Self::insert_str_key`]'s always-1
20368 /// arity on the per-`(:de, :para)` axis.
20369 ///
20370 /// Sites lifted:
20371 ///
20372 /// * caixa-mesh's `cilium_network_policies` per-ingress-rule
20373 /// `:politicas :mtls-required` mutual-auth overlay
20374 /// ([`crate::CILIUM_KEY_AUTHENTICATION`] around the
20375 /// `mtls_overlay` [`single_field_overlay`] output — the
20376 /// tristate `{mode: required | disabled}` block or the
20377 /// None-omit arm);
20378 /// * caixa-mesh's `gateway_routes` per-HTTPRoute-rule
20379 /// `:politicas :timeout` request-deadline overlay
20380 /// ([`crate::GATEWAY_API_KEY_TIMEOUTS`] around the
20381 /// `timeout_overlay` [`single_field_overlay`] output — the
20382 /// `{request: "<duration>"}` block or the None-omit arm);
20383 /// * caixa-mesh's `gateway_routes` per-HTTPRoute-rule
20384 /// `:politicas :retries` retry-attempt-cap overlay
20385 /// ([`crate::GATEWAY_API_KEY_RETRY`] around the
20386 /// `retry_overlay` [`single_field_overlay`] output — the
20387 /// `{attempts: <N>}` block or the None-omit arm).
20388 ///
20389 /// Lifting collapses the three-line block into one method call the
20390 /// caller reads as intent (`mapping.insert_str_key_if_some(<KEY>,
20391 /// <overlay>.as_ref())` — "insert this schema key if the overlay
20392 /// carried a value; else leave the key absent") rather than four
20393 /// hand-spelled positional artifacts (the `if let Some(_) = &_`
20394 /// destructure, the per-inner `.clone()`, the trailing brace, plus
20395 /// the `.insert_str_key(_)` call itself). The absent-overlay arm —
20396 /// which every [`MeshPolicy`] axis defaults to when the author
20397 /// leaves the typed slot unset (the `None` arm of the
20398 /// `Option<Value>` [`single_field_overlay`] output) — reads as the
20399 /// method's own `Option::None` branch, not a per-call-site inverted
20400 /// `if let Some` scaffold around a per-call-site clone.
20401 ///
20402 /// The next renderer to land — the per-`:politicas`
20403 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
20404 /// `authentication:` / `rateLimit:` / `circuitBreaker:` Option
20405 /// overlays, MESH-COMPOSITION §III.2 #3, thread through the same
20406 /// [`single_field_overlay`] `Option<Value>` axis the three lifted
20407 /// sites here already reach), the `app-operator`'s typed
20408 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (whose per-
20409 /// selector `status.` sub-field overlays are the same arity-0-or-1
20410 /// shape, §III.2 #5), the M4 cross-cluster fan-out's per-cluster
20411 /// `HTTPRoute.spec.rules[].filters[]` per-filter Option overlays
20412 /// (the same shape at the per-cluster axis) — gets the canonical
20413 /// arity-0-or-1 conditional-insert for free with one method call,
20414 /// instead of re-inlining the three-line `if let Some { clone;
20415 /// insert_str_key }` block.
20416 ///
20417 /// Peer to [`Self::insert_str_key`] on the always-1 arity axis
20418 /// (fresh-emit sites where the caller unconditionally writes a
20419 /// value) — the two together partition the fresh-emit surface
20420 /// exactly on the arity axis: [`Self::insert_str_key`] for
20421 /// unconditional writes, [`Self::insert_str_key_if_some`] for
20422 /// conditional writes gated on an `Option<Value>` upstream
20423 /// producer (the per-`:politicas` overlay
20424 /// [`single_field_overlay`] axis, and every future arity-0-or-1
20425 /// axis every future renderer's optional-slot machinery reaches
20426 /// through).
20427 ///
20428 /// The `Option<&Value>` shape (as opposed to an owned
20429 /// `Option<Value>`) lets the caller pass `overlay.as_ref()` on an
20430 /// owned `Option<Value>` the caller reuses across iterations of an
20431 /// outer per-`(:de, :para)` or per-rule loop — every lifted site
20432 /// consumes the overlay from a loop-outer binding into each of N
20433 /// per-iteration `Mapping`s, so the clone happens iff the insert
20434 /// fires (the None arm skips the clone entirely) and the outer
20435 /// binding stays available for the next iteration.
20436 fn insert_str_key_if_some(
20437 &mut self,
20438 key: &str,
20439 value: Option<&serde_yaml::Value>,
20440 ) -> Option<serde_yaml::Value>;
20441
20442 /// Fetch a `&mut serde_yaml::Mapping` at `key`, defaulting an empty
20443 /// [`serde_yaml::Mapping`] into place when the entry is absent.
20444 /// Returns `Some(&mut inner)` on the absent-key (fresh empty
20445 /// Mapping) and present-Mapping arms; `None` iff `key` holds a
20446 /// different [`serde_yaml::Value`] variant — a structural
20447 /// container-type mismatch the caller surfaces as its own
20448 /// domain-specific error (`Error::MissingField("spec.values must
20449 /// be a mapping")` for the caixa-flux Flux-HelmRelease overlay
20450 /// walker).
20451 ///
20452 /// The canonical shape 1 production call site in `caixa-flux`
20453 /// (`upsert_into_helmrelease_programs`'s per-`HelmRelease.spec.values`
20454 /// container-upsert on the way down to
20455 /// `spec.values.programs[]`) previously carried inline as a
20456 /// four-line block combining [`Self::entry_str_key`]'s entry-API
20457 /// key promotion (68d035e), an
20458 /// `.or_insert(Value::Mapping(Mapping::new()))` empty-Mapping
20459 /// default, and a `let Value::Mapping(inner) = _ else { Err(...) }`
20460 /// destructure — a two-token semantic payload (the schema key +
20461 /// the domain-specific type-mismatch diagnostic) buried under
20462 /// three boilerplate axes (`Value::Mapping(_)` variant promotion,
20463 /// `Mapping::new()` empty-container construction, the outer
20464 /// `let else` destructure). Peer to
20465 /// [`Self::entry_or_default_sequence`] on the sibling `Vec<Value>`-
20466 /// valued idempotent-container-upsert axis — the two together
20467 /// partition the entry-API-container-upsert surface exactly on the
20468 /// container-variant axis: [`Self::entry_or_default_mapping`] for
20469 /// nested-Mapping sub-blocks, [`Self::entry_or_default_sequence`]
20470 /// for list-shape sub-blocks.
20471 ///
20472 /// Sites lifted:
20473 ///
20474 /// * caixa-flux's `upsert_into_helmrelease_programs` per-
20475 /// `HelmRelease.spec.values` container-upsert
20476 /// (`FLUX_KEY_VALUES` around the default fresh
20477 /// `Value::Mapping`, on the way down to the nested
20478 /// `spec.values.programs[]` sequence).
20479 ///
20480 /// Lifting collapses the four-line block into one method call the
20481 /// caller reads as intent (`mapping.entry_or_default_mapping(<KEY>)
20482 /// .ok_or(<ERR>)?` — "give me the nested Mapping at this schema
20483 /// key, defaulting empty if absent, else surface my domain
20484 /// error") rather than five hand-spelled positional artifacts
20485 /// (`serde_yaml::` path re-quote, `Value::Mapping(_)` promotion,
20486 /// `Mapping::new()` construction, the entry-API `.or_insert(...)`
20487 /// call, plus the outer `let Value::Mapping(_) = _ else {}`
20488 /// destructure). The next renderer to land — the per-`:politicas`
20489 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-cluster
20490 /// upsert walks
20491 /// `HelmRelease.spec.values.<library>.<:politicas-axis>`,
20492 /// idempotent-upserting nested-Mapping sub-blocks under each
20493 /// axis, MESH-COMPOSITION §III.2 #3), the `app-operator`'s typed
20494 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (which
20495 /// upserts `status.<axis>` nested-Mapping sub-blocks on partial
20496 /// reconciles, §III.2 #5), the M4 cross-cluster fan-out's
20497 /// per-cluster idempotent `HelmRelease.spec.values.<library>`
20498 /// container-upsert — gets the canonical entry-API-with-
20499 /// container-type-check for free with one method call, instead
20500 /// of re-inlining the four-line block.
20501 ///
20502 /// The default-empty-Mapping construction fires only on the
20503 /// absent-key arm (`.or_insert_with(...)` gates the closure on
20504 /// vacancy) — the present-key arm reuses the existing Mapping
20505 /// verbatim, so the caller's downstream writes on `&mut inner`
20506 /// compose with any prior overlay writes from earlier passes
20507 /// (the exact idempotent-upsert semantic the caixa-flux
20508 /// per-cluster `feira app deploy` write path depends on to
20509 /// preserve operator-pinned overlays across re-renders).
20510 fn entry_or_default_mapping(&mut self, key: &str) -> Option<&mut serde_yaml::Mapping>;
20511
20512 /// Fetch a `&mut Vec<serde_yaml::Value>` at `key`, defaulting an
20513 /// empty [`Vec<serde_yaml::Value>`] into place when the entry is
20514 /// absent. Returns `Some(&mut inner)` on the absent-key (fresh
20515 /// empty Sequence) and present-Sequence arms; `None` iff `key`
20516 /// holds a different [`serde_yaml::Value`] variant — a structural
20517 /// container-type mismatch the caller surfaces as its own
20518 /// domain-specific error (`Error::MissingField("programs must be
20519 /// a sequence")` for the caixa-flux fleet-programs upsert
20520 /// walkers).
20521 ///
20522 /// The canonical shape 2 production call sites in `caixa-flux`
20523 /// (`upsert_into_helmrelease_programs`'s per-
20524 /// `HelmRelease.spec.values.programs` container-upsert and
20525 /// `upsert_into_programs_yaml`'s top-level `programs:` container-
20526 /// upsert) previously carried inline as a four-line block
20527 /// combining [`Self::entry_str_key`]'s entry-API key promotion
20528 /// (68d035e), an `.or_insert(Value::Sequence(Vec::new()))`
20529 /// empty-Sequence default, and a `match _ { Value::Sequence(seq)
20530 /// => seq, _ => return Err(...) }` destructure — a two-token
20531 /// semantic payload (the schema key + the domain-specific
20532 /// type-mismatch diagnostic) buried under three boilerplate axes
20533 /// (`Value::Sequence(_)` variant promotion, `Vec::new()`
20534 /// empty-container construction, the outer `match` destructure).
20535 /// Peer to [`Self::entry_or_default_mapping`] on the sibling
20536 /// nested-Mapping-valued idempotent-container-upsert axis.
20537 ///
20538 /// Sites lifted:
20539 ///
20540 /// * caixa-flux's `upsert_into_helmrelease_programs` per-
20541 /// `HelmRelease.spec.values.programs` list-container-upsert
20542 /// (`FLEET_PROGRAMS_KEY_PROGRAMS` around the default fresh
20543 /// `Value::Sequence`, one path deep in a `HelmRelease`
20544 /// `spec.values.` sub-tree);
20545 /// * caixa-flux's `upsert_into_programs_yaml` per-top-level
20546 /// `programs:` list-container-upsert
20547 /// (`FLEET_PROGRAMS_KEY_PROGRAMS` around the default fresh
20548 /// `Value::Sequence` — the sibling of the
20549 /// `upsert_into_helmrelease_programs` site on the same key,
20550 /// one path at the values.yaml root).
20551 ///
20552 /// Lifting collapses the four-line block into one method call the
20553 /// caller reads as intent (`mapping.entry_or_default_sequence(<KEY>)
20554 /// .ok_or(<ERR>)?` — "give me the list at this schema key,
20555 /// defaulting empty if absent, else surface my domain error")
20556 /// rather than five hand-spelled positional artifacts
20557 /// (`serde_yaml::` path re-quote, `Value::Sequence(_)` promotion,
20558 /// `Vec::new()` construction, the entry-API `.or_insert(...)`
20559 /// call, plus the outer `match { Value::Sequence(_) => _, _ =>
20560 /// return Err(_) }` destructure). The next renderer to land — the
20561 /// per-`:politicas` `CiliumClusterwideEnvoyConfig` emitter
20562 /// (whose per-cluster upsert walks nested list-shape sub-blocks
20563 /// `spec.resources[]` / `spec.listeners[]` / `spec.virtualHosts[]`
20564 /// under existing operator-pinned overlay CRs, MESH-COMPOSITION
20565 /// §III.2 #3), the `app-operator`'s typed
20566 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (which
20567 /// upserts `status.selectors[]` / `status.gates[]` list-shape
20568 /// sub-blocks on partial reconciles, §III.2 #5), the M4 cross-
20569 /// cluster fan-out's per-cluster idempotent
20570 /// `HelmRelease.spec.values.programs` list-upsert — gets the
20571 /// canonical entry-API-with-container-type-check for free with
20572 /// one method call, instead of re-inlining the four-line block.
20573 ///
20574 /// The default-empty-Sequence construction fires only on the
20575 /// absent-key arm (`.or_insert_with(...)` gates the closure on
20576 /// vacancy) — the present-key arm reuses the existing Vec
20577 /// verbatim, so the caller's downstream `upsert_named_entry`
20578 /// (10bf310) call on `&mut inner` composes with any prior
20579 /// entries the emitter wrote on earlier passes (the exact
20580 /// idempotent-upsert semantic the `feira app deploy` per-cluster
20581 /// write path depends on to preserve prior `programs[]` entries
20582 /// across per-Servico rewrites).
20583 fn entry_or_default_sequence(&mut self, key: &str) -> Option<&mut Vec<serde_yaml::Value>>;
20584}
20585
20586impl MappingExt for serde_yaml::Mapping {
20587 #[inline]
20588 fn insert_str_key(&mut self, key: &str, value: serde_yaml::Value) -> Option<serde_yaml::Value> {
20589 self.insert(serde_yaml::Value::String(key.to_string()), value)
20590 }
20591
20592 #[inline]
20593 fn insert_string<V: Into<String>>(&mut self, key: &str, value: V) -> Option<serde_yaml::Value> {
20594 self.insert_str_key(key, serde_yaml::Value::String(value.into()))
20595 }
20596
20597 #[inline]
20598 fn insert_number<N: Into<serde_yaml::Number>>(
20599 &mut self,
20600 key: &str,
20601 value: N,
20602 ) -> Option<serde_yaml::Value> {
20603 self.insert_str_key(key, serde_yaml::Value::Number(value.into()))
20604 }
20605
20606 #[inline]
20607 fn insert_mapping(
20608 &mut self,
20609 key: &str,
20610 value: serde_yaml::Mapping,
20611 ) -> Option<serde_yaml::Value> {
20612 self.insert_str_key(key, serde_yaml::Value::Mapping(value))
20613 }
20614
20615 #[inline]
20616 fn insert_sequence(
20617 &mut self,
20618 key: &str,
20619 value: Vec<serde_yaml::Value>,
20620 ) -> Option<serde_yaml::Value> {
20621 self.insert_str_key(key, serde_yaml::Value::Sequence(value))
20622 }
20623
20624 #[inline]
20625 fn insert_singleton_mapping_sequence(
20626 &mut self,
20627 key: &str,
20628 value: serde_yaml::Mapping,
20629 ) -> Option<serde_yaml::Value> {
20630 self.insert_str_key(key, singleton_mapping_sequence(value))
20631 }
20632
20633 #[inline]
20634 fn entry_str_key(&mut self, key: &str) -> serde_yaml::mapping::Entry<'_> {
20635 self.entry(serde_yaml::Value::String(key.to_string()))
20636 }
20637
20638 #[inline]
20639 fn insert_str_key_if_some(
20640 &mut self,
20641 key: &str,
20642 value: Option<&serde_yaml::Value>,
20643 ) -> Option<serde_yaml::Value> {
20644 value.and_then(|v| self.insert_str_key(key, v.clone()))
20645 }
20646
20647 #[inline]
20648 fn entry_or_default_mapping(&mut self, key: &str) -> Option<&mut serde_yaml::Mapping> {
20649 match self
20650 .entry_str_key(key)
20651 .or_insert_with(|| serde_yaml::Value::Mapping(serde_yaml::Mapping::new()))
20652 {
20653 serde_yaml::Value::Mapping(m) => Some(m),
20654 _ => None,
20655 }
20656 }
20657
20658 #[inline]
20659 fn entry_or_default_sequence(&mut self, key: &str) -> Option<&mut Vec<serde_yaml::Value>> {
20660 match self
20661 .entry_str_key(key)
20662 .or_insert_with(|| serde_yaml::Value::Sequence(Vec::new()))
20663 {
20664 serde_yaml::Value::Sequence(s) => Some(s),
20665 _ => None,
20666 }
20667 }
20668}
20669
20670/// Extension methods for the [`Vec<serde_yaml::Value>`] emission
20671/// surface that the K8s-artifact-emit sites of `caixa-mesh` /
20672/// `caixa-flux` / `caixa-helm` / `caixa-core::render` build up as
20673/// `spec.ingress[]` / `spec.rules[]` / `spec.hostnames[]` / per-
20674/// programs.yaml-entry payloads before wrapping each vec as a
20675/// [`serde_yaml::Value::Sequence`] on an outer [`serde_yaml::Mapping`]
20676/// (via [`MappingExt::insert_sequence`]).
20677///
20678/// Peer to [`MappingExt`] on the sibling [`serde_yaml::Value`]-
20679/// construction surface: [`MappingExt`] closes the per-key-and-value
20680/// insert primitive every schema-key axis reaches through;
20681/// [`SequenceExt`] closes the per-list-element push primitive every
20682/// per-iteration append site reaches through when the built-up
20683/// [`serde_yaml::Value`] variant is uniform across a loop body (e.g.
20684/// every element is a fresh [`serde_yaml::Value::Mapping`], not a
20685/// heterogeneous mix of `Mapping` / `String` / `Sequence`).
20686///
20687/// Each method mints the same `Value::<Variant>(<payload>)` promotion
20688/// the caller would otherwise re-inline as
20689/// `vec.push(serde_yaml::Value::<Variant>(<payload>))` on every
20690/// iteration. Same variant-promotion contract as [`MappingExt`]'s
20691/// typed inserts, applied to the sequence-append axis instead of the
20692/// mapping-insert axis — so a future rebrand of the `Value` variant
20693/// wrapping (e.g. to a Server-Side-Apply-typed
20694/// [`serde_yaml::Value::Tagged`] per-list-element ownership axis)
20695/// reaches both `Mapping`-insert and `Vec<Value>`-push sites through
20696/// one lift.
20697pub trait SequenceExt {
20698 /// Append `Value::Mapping(value)` to `self` — the per-iteration
20699 /// append shape that combines a `Vec<serde_yaml::Value>::push`
20700 /// with an automatic [`serde_yaml::Value::Mapping`] promotion of a
20701 /// pre-built [`serde_yaml::Mapping`] element.
20702 ///
20703 /// The canonical shape 4 production call sites across `caixa-mesh`
20704 /// previously carried inline as the three-token block
20705 /// `<vec>.push(serde_yaml::Value::Mapping(<M>))` — a one-token
20706 /// semantic payload (the per-iteration `Mapping`) buried under a
20707 /// two-axis boilerplate (`serde_yaml::` path re-quote,
20708 /// `Value::Mapping(_)` promotion) around a `Mapping` variable the
20709 /// caller already built.
20710 ///
20711 /// Sites lifted:
20712 ///
20713 /// * caixa-mesh's `programs_for_aplicacao` per-`:membros`
20714 /// programs.yaml entry append (per-member entry `Mapping` →
20715 /// the fan-out `Vec<Value>`);
20716 /// * caixa-mesh's `cilium_network_policies` per-edge
20717 /// `spec.ingress[].toPorts[]` L4-and-L7 port-and-rule append
20718 /// (per-`(:de, :para)` group's per-edge `to_port` Mapping →
20719 /// the `to_ports_seq` Vec);
20720 /// * caixa-mesh's `cilium_network_policies` per-policy
20721 /// top-level CNP-document append (per-`(:de, :para)` group's
20722 /// built `policy` Mapping → the render-output `Vec<Value>`);
20723 /// * caixa-mesh's `gateway_routes` per-HTTPRoute-rule
20724 /// `spec.rules[]` append (per-path built `rule` Mapping → the
20725 /// `rules` Vec).
20726 ///
20727 /// Lifting collapses the three-token block into one method call
20728 /// the caller reads as intent (`<vec>.push_mapping(<M>)` —
20729 /// "append this built inner `M` as the next `Value::Mapping`
20730 /// element") rather than three hand-spelled positional artifacts
20731 /// (`serde_yaml::` path re-quote, `Value::Mapping(_)` promotion,
20732 /// plus the `.push(_)` call itself). Peer to
20733 /// [`MappingExt::insert_singleton_mapping_sequence`] on the
20734 /// singleton-Mapping-list-shape axis: [`Self::push_mapping`]
20735 /// builds up a multi-element `Vec<Value>` per iteration when the
20736 /// caller then calls [`MappingExt::insert_sequence`] to route the
20737 /// finished vec under a schema key;
20738 /// [`MappingExt::insert_singleton_mapping_sequence`] fuses the
20739 /// singleton wrap + the schema-key insert into one call when the
20740 /// caller has exactly one Mapping element to emit under a schema
20741 /// key.
20742 ///
20743 /// The next renderer to land — the per-`:politicas`
20744 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
20745 /// `spec.resources[]` / `spec.listeners[]` / `spec.virtualHosts[]`
20746 /// list-shape axes fan out multi-Mapping-element per iteration,
20747 /// MESH-COMPOSITION §III.2 #3), the `app-operator`'s typed
20748 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (per-
20749 /// `spec.selectors[]` / per-`spec.gates[]` multi-element append,
20750 /// §III.2 #5), the M4 cross-cluster fan-out's per-cluster
20751 /// multi-entry `Service.spec.ports[]` /
20752 /// `HTTPRoute.spec.rules[].backendRefs[]` list append, the future
20753 /// `caixa-otel` OpenTelemetry-Collector per-pipeline
20754 /// `receivers[]` / `processors[]` / `exporters[]` multi-element
20755 /// append — gets the canonical `Value::Mapping`-promoted append
20756 /// for free with one method call, instead of re-inlining the
20757 /// three-token `Value::Mapping(_)` promotion.
20758 fn push_mapping(&mut self, value: serde_yaml::Mapping);
20759}
20760
20761impl SequenceExt for Vec<serde_yaml::Value> {
20762 #[inline]
20763 fn push_mapping(&mut self, value: serde_yaml::Mapping) {
20764 self.push(serde_yaml::Value::Mapping(value));
20765 }
20766}
20767
20768#[cfg(test)]
20769mod tests {
20770 use super::*;
20771 use crate::{BehaviorSpec, CaixaKind, LimitsSpec, UpgradeFromEntry, UpgradeInstruction};
20772 use std::path::PathBuf;
20773 use std::time::Duration;
20774
20775 fn bare_servico() -> Caixa {
20776 Caixa {
20777 nome: "hello-rio".into(),
20778 versao: "0.1.0".into(),
20779 kind: CaixaKind::Servico,
20780 edicao: Some("2026".into()),
20781 descricao: None,
20782 repositorio: None,
20783 licenca: None,
20784 autores: vec![],
20785 etiquetas: vec![],
20786 deps: vec![],
20787 deps_dev: vec![],
20788 exe: vec![],
20789 bibliotecas: vec![],
20790 servicos: vec!["servicos/hello-rio.computeunit.yaml".into()],
20791 limits: None,
20792 behavior: None,
20793 upgrade_from: vec![],
20794 estrategia: None,
20795 max_restarts: None,
20796 restart_window: None,
20797 children: vec![],
20798 membros: vec![],
20799 contratos: vec![],
20800 politicas: None,
20801 placement: None,
20802 entrada: None,
20803 ci: None,
20804 }
20805 }
20806
20807 #[test]
20808 fn empty_caixa_returns_empty_overlay() {
20809 let overlay = servico_m2_overlay(&bare_servico()).unwrap();
20810 assert!(
20811 overlay.is_empty(),
20812 "a Caixa with no M2 slots emits zero overlay fragments"
20813 );
20814 }
20815
20816 #[test]
20817 fn empty_typed_specs_are_skipped_like_unset_ones() {
20818 // `Some(LimitsSpec::default())` (every axis None) and
20819 // `Some(BehaviorSpec::default())` (every callback None) must
20820 // round-trip identical to `None` — the is_empty()-skip
20821 // invariant the renderers' "empty M2 slots do not appear"
20822 // tests pinned inline before this lift.
20823 let mut c = bare_servico();
20824 c.limits = Some(LimitsSpec::default());
20825 c.behavior = Some(BehaviorSpec::default());
20826 let overlay = servico_m2_overlay(&c).unwrap();
20827 assert!(overlay.is_empty());
20828 }
20829
20830 #[test]
20831 fn limits_slot_appears_under_camelcase_key() {
20832 let mut c = bare_servico();
20833 c.limits = Some(LimitsSpec {
20834 memory: Some(64 * 1024 * 1024),
20835 fuel: Some(1_000_000),
20836 wall_clock: Some(Duration::from_secs(30)),
20837 cpu: Some(500),
20838 });
20839 let overlay = servico_m2_overlay(&c).unwrap();
20840 assert_eq!(overlay.len(), 1);
20841 let limits = overlay.get(M2_KEY_LIMITS).expect("limits key present");
20842 assert_eq!(
20843 limits.get(M2_LIMITS_KEY_MEMORY).and_then(|m| m.as_str()),
20844 Some("64MiB")
20845 );
20846 assert_eq!(
20847 limits
20848 .get(M2_LIMITS_KEY_WALL_CLOCK)
20849 .and_then(|m| m.as_str()),
20850 Some("30s")
20851 );
20852 }
20853
20854 #[test]
20855 fn behavior_slot_appears_under_camelcase_key() {
20856 let mut c = bare_servico();
20857 c.behavior = Some(BehaviorSpec {
20858 on_init: Some(PathBuf::from("lib/init.lisp")),
20859 on_call: Some(PathBuf::from("lib/handlers.lisp")),
20860 ..Default::default()
20861 });
20862 let overlay = servico_m2_overlay(&c).unwrap();
20863 let behavior = overlay.get(M2_KEY_BEHAVIOR).expect("behavior key present");
20864 assert_eq!(
20865 behavior
20866 .get(M2_BEHAVIOR_KEY_ON_INIT)
20867 .and_then(|v| v.as_str()),
20868 Some("lib/init.lisp")
20869 );
20870 assert_eq!(
20871 behavior
20872 .get(M2_BEHAVIOR_KEY_ON_CALL)
20873 .and_then(|v| v.as_str()),
20874 Some("lib/handlers.lisp")
20875 );
20876 }
20877
20878 #[test]
20879 fn upgrade_from_slot_appears_under_camelcase_key() {
20880 let mut c = bare_servico();
20881 c.upgrade_from = vec![UpgradeFromEntry {
20882 from: "0.0.9".into(),
20883 instructions: vec![UpgradeInstruction::LoadModule {
20884 module: "hello-rio".into(),
20885 }],
20886 }];
20887 let overlay = servico_m2_overlay(&c).unwrap();
20888 let upgrade = overlay
20889 .get(M2_KEY_UPGRADE_FROM)
20890 .expect("upgradeFrom key present");
20891 let arr = upgrade.as_sequence().expect("sequence");
20892 assert_eq!(arr.len(), 1);
20893 assert_eq!(
20894 arr[0]
20895 .get(M2_UPGRADE_FROM_KEY_FROM)
20896 .and_then(|v| v.as_str()),
20897 Some("0.0.9")
20898 );
20899 }
20900
20901 #[test]
20902 fn all_three_slots_appear_in_alphabetical_iteration_order() {
20903 // BTreeMap iteration is sorted by key — pin that the renderers
20904 // can rely on a deterministic iteration order, which feeds
20905 // into deterministic YAML output (the value-as-proof property
20906 // THEORY.md §V.2.7 "render determinism" requires).
20907 let mut c = bare_servico();
20908 c.limits = Some(LimitsSpec {
20909 memory: Some(64 * 1024 * 1024),
20910 ..Default::default()
20911 });
20912 c.behavior = Some(BehaviorSpec {
20913 on_init: Some(PathBuf::from("lib/init.lisp")),
20914 ..Default::default()
20915 });
20916 c.upgrade_from = vec![UpgradeFromEntry {
20917 from: "0.0.9".into(),
20918 instructions: vec![UpgradeInstruction::LoadModule {
20919 module: "hello-rio".into(),
20920 }],
20921 }];
20922 let overlay = servico_m2_overlay(&c).unwrap();
20923 let keys: Vec<_> = overlay.keys().copied().collect();
20924 assert_eq!(
20925 keys,
20926 vec![M2_KEY_BEHAVIOR, M2_KEY_LIMITS, M2_KEY_UPGRADE_FROM]
20927 );
20928 }
20929
20930 // ── servico_spec_and_m2_overlay_entries — composed splice ────────────
20931 //
20932 // The compound peer of `servico_m2_overlay` on the ComputeUnit-YAML
20933 // `spec.*` + M2-overlay axis: fuses the two prior inline for-loops
20934 // caixa-flux::programs_yaml_entry and caixa-helm::build_values_yaml
20935 // both carried around `string_keyed_entries` + `servico_m2_overlay`
20936 // into one canonical composition. The pins below bracket the shape
20937 // end-to-end (spec.* keys first + preserved-insertion-order, then M2
20938 // slots in BTreeMap-key order at every M2 key not already claimed by
20939 // spec.*).
20940
20941 fn cu_yaml_with_spec_fields(spec_yaml: &str) -> serde_yaml::Value {
20942 serde_yaml::from_str(&format!(
20943 "apiVersion: wasm.pleme.io/v1alpha1\nkind: ComputeUnit\nmetadata:\n name: hello-rio\nspec:\n{spec_yaml}"
20944 ))
20945 .unwrap()
20946 }
20947
20948 #[test]
20949 fn servico_spec_and_m2_overlay_entries_empty_caixa_and_empty_spec_yields_empty() {
20950 let cu = cu_yaml_with_spec_fields(" {}\n");
20951 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
20952 let out = servico_spec_and_m2_overlay_entries(&bare_servico(), spec).unwrap();
20953 assert!(
20954 out.is_empty(),
20955 "empty spec + empty M2 surface yields zero entries \
20956 (both loops short-circuit vacuously)"
20957 );
20958 }
20959
20960 #[test]
20961 fn servico_spec_and_m2_overlay_entries_splices_spec_fields_in_source_insertion_order() {
20962 // The spec.* field-splice loop preserves the source YAML
20963 // Mapping's insertion order — caixa-flux's `serde_yaml::Mapping`
20964 // target reads this back verbatim, so a rebrand of the source
20965 // ComputeUnit YAML's field ordering must not silently reorder
20966 // the emitted programs.yaml entry.
20967 let cu = cu_yaml_with_spec_fields(
20968 " module:\n source: oci://ghcr.io/pleme-io/hello-rio:v0.1.0\n \
20969 trigger:\n service: {port: 8080}\n capabilities:\n - env\n",
20970 );
20971 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
20972 let out = servico_spec_and_m2_overlay_entries(&bare_servico(), spec).unwrap();
20973 let keys: Vec<&str> = out.iter().map(|(k, _)| k.as_str()).collect();
20974 assert_eq!(
20975 keys,
20976 vec![
20977 COMPUTEUNIT_SPEC_KEY_MODULE,
20978 COMPUTEUNIT_SPEC_KEY_TRIGGER,
20979 COMPUTEUNIT_SPEC_KEY_CAPABILITIES,
20980 ],
20981 "spec.* keys must appear in source-Mapping insertion order",
20982 );
20983 }
20984
20985 #[test]
20986 fn servico_spec_and_m2_overlay_entries_appends_m2_slots_after_spec_in_canonical_key_order() {
20987 // Bracket the second-half of the composition — the M2 overlay
20988 // walk lands after the spec.* splice, in BTreeMap-key ordering
20989 // (behavior → limits → upgradeFrom).
20990 let cu = cu_yaml_with_spec_fields(
20991 " module:\n source: oci://ghcr.io/pleme-io/hello-rio:v0.1.0\n",
20992 );
20993 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
20994 let mut c = bare_servico();
20995 c.limits = Some(LimitsSpec {
20996 memory: Some(64 * 1024 * 1024),
20997 ..Default::default()
20998 });
20999 c.behavior = Some(BehaviorSpec {
21000 on_init: Some(PathBuf::from("lib/init.lisp")),
21001 ..Default::default()
21002 });
21003 c.upgrade_from = vec![UpgradeFromEntry {
21004 from: "0.0.9".into(),
21005 instructions: vec![UpgradeInstruction::LoadModule {
21006 module: "hello-rio".into(),
21007 }],
21008 }];
21009 let out = servico_spec_and_m2_overlay_entries(&c, spec).unwrap();
21010 let keys: Vec<&str> = out.iter().map(|(k, _)| k.as_str()).collect();
21011 assert_eq!(
21012 keys,
21013 vec![
21014 COMPUTEUNIT_SPEC_KEY_MODULE,
21015 M2_KEY_BEHAVIOR,
21016 M2_KEY_LIMITS,
21017 M2_KEY_UPGRADE_FROM,
21018 ],
21019 "M2 slots must land after the spec.* splice, in canonical \
21020 BTreeMap key order",
21021 );
21022 }
21023
21024 #[test]
21025 fn servico_spec_and_m2_overlay_entries_or_insert_precedence_spec_wins_on_collision() {
21026 // The or_insert precedence rule the two prior inline blocks
21027 // shared: when the ComputeUnit YAML's `spec.*` sub-mapping
21028 // already carries the M2 slot's key (an author-authored
21029 // ComputeUnit `spec.limits` overriding the manifest-derived
21030 // `caixa.limits` overlay), the spec.* value stays and the M2
21031 // overlay's value is skipped. Regression-guards against a
21032 // future reversal ("M2 wins on collision") silently changing
21033 // the composition without an explicit slot-precedence flip at
21034 // the helper.
21035 let cu = cu_yaml_with_spec_fields(
21036 " limits:\n memory: from-spec\n module:\n source: oci://x\n",
21037 );
21038 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
21039 let mut c = bare_servico();
21040 c.limits = Some(LimitsSpec {
21041 memory: Some(64 * 1024 * 1024),
21042 ..Default::default()
21043 });
21044 let out = servico_spec_and_m2_overlay_entries(&c, spec).unwrap();
21045 let limits_entries: Vec<&(String, serde_yaml::Value)> =
21046 out.iter().filter(|(k, _)| k == M2_KEY_LIMITS).collect();
21047 assert_eq!(
21048 limits_entries.len(),
21049 1,
21050 "on collision the M2 overlay's `limits` entry must be \
21051 filtered out — spec.* wins, and appears exactly once",
21052 );
21053 assert_eq!(
21054 limits_entries[0]
21055 .1
21056 .get(M2_LIMITS_KEY_MEMORY)
21057 .and_then(|v| v.as_str()),
21058 Some("from-spec"),
21059 "the surviving `limits` entry must carry the spec.* value, \
21060 not the manifest-derived M2 overlay's value",
21061 );
21062 }
21063
21064 #[test]
21065 fn servico_spec_and_m2_overlay_entries_short_circuits_on_non_mapping_spec() {
21066 // Sibling `string_keyed_entries` docstring pins the
21067 // non-Mapping short-circuit; extend it to the composed splice
21068 // — a spec that isn't a Mapping yields zero spec.* entries,
21069 // and only the M2 overlay contributes. Bracket-guard against a
21070 // future refactor that swaps `string_keyed_entries` for a
21071 // stricter parser silently dropping the M2 half too.
21072 let non_mapping_spec = serde_yaml::Value::String("not-a-mapping".into());
21073 let mut c = bare_servico();
21074 c.limits = Some(LimitsSpec {
21075 memory: Some(64 * 1024 * 1024),
21076 ..Default::default()
21077 });
21078 let out = servico_spec_and_m2_overlay_entries(&c, &non_mapping_spec).unwrap();
21079 let keys: Vec<&str> = out.iter().map(|(k, _)| k.as_str()).collect();
21080 assert_eq!(
21081 keys,
21082 vec![M2_KEY_LIMITS],
21083 "non-Mapping spec short-circuits the spec.* splice; the M2 \
21084 overlay still contributes its filled slots",
21085 );
21086 }
21087
21088 #[test]
21089 fn servico_spec_and_m2_overlay_entries_matches_hand_written_composition() {
21090 // Cross-check the lifted composition against the hand-written
21091 // two-loop shape the two prior inline blocks carried. A drift
21092 // between the helper and the inline composition would silently
21093 // emit a different key set / ordering / precedence at every
21094 // routed renderer — pin the equivalence so the helper stays a
21095 // drop-in replacement for both.
21096 let cu = cu_yaml_with_spec_fields(
21097 " module:\n source: oci://ghcr.io/pleme-io/hello-rio:v0.1.0\n \
21098 trigger:\n service: {port: 8080}\n",
21099 );
21100 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
21101 let mut c = bare_servico();
21102 c.limits = Some(LimitsSpec {
21103 memory: Some(32 * 1024 * 1024),
21104 ..Default::default()
21105 });
21106 c.behavior = Some(BehaviorSpec {
21107 on_call: Some(PathBuf::from("lib/handlers.lisp")),
21108 ..Default::default()
21109 });
21110
21111 let via_helper = servico_spec_and_m2_overlay_entries(&c, spec).unwrap();
21112
21113 let mut via_inline: Vec<(String, serde_yaml::Value)> = Vec::new();
21114 let mut seen: std::collections::HashSet<String> = std::collections::HashSet::new();
21115 for (k, v) in string_keyed_entries(spec) {
21116 seen.insert(k.to_string());
21117 via_inline.push((k.to_string(), v.clone()));
21118 }
21119 for (key, value) in servico_m2_overlay(&c).unwrap() {
21120 if !seen.contains(key) {
21121 via_inline.push((key.to_string(), value));
21122 }
21123 }
21124
21125 assert_eq!(
21126 via_helper, via_inline,
21127 "servico_spec_and_m2_overlay_entries must byte-equal the \
21128 hand-written two-loop composition (spec.* splice + M2 \
21129 overlay with or_insert precedence) the two prior inline \
21130 call sites carried",
21131 );
21132 }
21133
21134 #[test]
21135 fn pleme_label_consts_share_canonical_prefix() {
21136 // Single-source-of-truth invariant: every pleme-io label key
21137 // is `<PLEME_LABEL_PREFIX>/<axis>`. A future label-namespace
21138 // rebrand is a one-line PLEME_LABEL_PREFIX edit + this test
21139 // pins the contract that no other label leaks past the lift.
21140 for k in [LABEL_APLICACAO, LABEL_PROGRAM, LABEL_CONTRATO] {
21141 assert!(
21142 k.starts_with(PLEME_LABEL_PREFIX),
21143 "label key {k:?} must share the {PLEME_LABEL_PREFIX:?} prefix"
21144 );
21145 // Each label is `<prefix>/<axis>` — the suffix is non-empty
21146 // (the `/` separator is followed by the axis name).
21147 let suffix = k.strip_prefix(PLEME_LABEL_PREFIX).unwrap();
21148 assert!(suffix.starts_with('/'));
21149 assert!(suffix.len() > 1, "axis name must be non-empty for {k:?}");
21150 }
21151 }
21152
21153 #[test]
21154 fn pleme_label_consts_have_expected_canonical_values() {
21155 // Pin the actual string values so a typo in the lift can't
21156 // silently rebrand the whole pleme-io label namespace. These
21157 // strings are part of the cluster-side contract with the
21158 // lareira-fleet-programs chart + Cilium identity layer + Hubble
21159 // flow attribution; changing any of them is a coordinated
21160 // multi-repo migration, not an incidental edit.
21161 assert_eq!(PLEME_LABEL_PREFIX, "pleme.pleme.io");
21162 assert_eq!(LABEL_APLICACAO, "pleme.pleme.io/aplicacao");
21163 assert_eq!(LABEL_PROGRAM, "pleme.pleme.io/program");
21164 assert_eq!(LABEL_CONTRATO, "pleme.pleme.io/contrato");
21165 }
21166
21167 #[test]
21168 fn default_namespace_pins_canonical_value() {
21169 // Pin the actual string so a typo in this lift can't silently
21170 // rebrand the cluster-side namespace every renderer emits
21171 // into. The string is part of the cluster-side contract with
21172 // the lareira-fleet-programs aggregator chart, the per-cluster
21173 // CiliumNetworkPolicy `endpointSelector` namespace scope, the
21174 // Gateway / HTTPRoute apply namespace, and the future M4
21175 // `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's apply
21176 // namespace; changing it is a coordinated multi-repo migration
21177 // (the per-cluster k8s repo's namespaces, every
21178 // lareira-fleet-programs HelmRelease's targetNamespace, every
21179 // ComputeUnit's `metadata.namespace`), not an incidental edit.
21180 // Peer to `pleme_label_consts_have_expected_canonical_values`
21181 // on the canonical-string-value-pin axis for the
21182 // `PLEME_LABEL_PREFIX` / `LABEL_*` constants.
21183 assert_eq!(DEFAULT_NAMESPACE, "tatara-system");
21184 }
21185
21186 #[test]
21187 fn default_flux_system_namespace_pins_canonical_value() {
21188 // Pin the actual string so a typo in this lift can't silently
21189 // rebrand the FluxCD installation namespace the rendered
21190 // `kustomization.yaml`'s `metadata.namespace` /
21191 // `spec.sourceRef.name` axes consume. The string is part of the
21192 // cluster-side contract with the `flux bootstrap` pipeline (the
21193 // bootstrap convention names the `GitRepository` after the
21194 // installation namespace, so both axes are the same load-bearing
21195 // string), the `kustomize-controller` watch-window scope (a
21196 // drifted value sits outside the controller's watch window and
21197 // is never reconciled), and the per-cluster k8s repo's flux
21198 // bootstrap manifests; changing it is a coordinated multi-repo
21199 // migration, not an incidental edit. Peer to
21200 // `default_namespace_pins_canonical_value` on the
21201 // canonical-string-value-pin axis for the workload-side
21202 // [`DEFAULT_NAMESPACE`] constant.
21203 assert_eq!(DEFAULT_FLUX_SYSTEM_NAMESPACE, "flux-system");
21204 }
21205
21206 #[test]
21207 fn default_flux_system_namespace_is_a_valid_dns_1123_label() {
21208 // Cross-axis invariant: the FluxCD installation namespace lands
21209 // as `metadata.namespace` on every emitted `Kustomization`
21210 // resource and as `spec.sourceRef.name` (a K8s resource name
21211 // under the same DNS-1123 floor), and the K8s apiserver
21212 // enforces the DNS-1123 label rule on both. Pinning this here
21213 // means a future rebrand on the canonical lift can't silently
21214 // land a value the apiserver refuses at the *first*
21215 // `kustomization.yaml` apply against a cluster, far from the
21216 // rebrand commit's source — the typed [`is_dns_1123_label`]
21217 // floor rejects it at caixa-core build time on the canonical
21218 // lift, before any renderer consumes the value. Same shape as
21219 // `default_namespace_is_a_valid_dns_1123_label` on the
21220 // workload-side [`DEFAULT_NAMESPACE`] axis.
21221 assert!(
21222 is_dns_1123_label(DEFAULT_FLUX_SYSTEM_NAMESPACE).is_ok(),
21223 "DEFAULT_FLUX_SYSTEM_NAMESPACE {DEFAULT_FLUX_SYSTEM_NAMESPACE:?} must be a valid \
21224 DNS-1123 label — every K8s apiserver-side schema enforces \
21225 this rule on `metadata.namespace`"
21226 );
21227 }
21228
21229 #[test]
21230 fn default_flux_reconcile_interval_pins_canonical_value() {
21231 // Pin the actual string so a typo in this lift can't silently
21232 // rebrand the substrate-side default Flux v2 reconcile-poll
21233 // cadence duration scalar the substrate's per-caixa
21234 // `cluster_bundle` renderer seeds into every emitted per-caixa
21235 // Flux v2 CR (GitRepository / HelmRelease / Kustomization) at
21236 // its `spec.interval` axis when the operator doesn't pin a per-
21237 // caixa override. The string is part of the cluster-side
21238 // contract with the Flux v2 source-controller / helm-controller
21239 // / kustomize-controller trio: each controller's per-CR admission
21240 // gate parses the value via `metav1.ParseDuration` before
21241 // installing the per-CR watch, and the resulting cadence pins
21242 // the per-CR reconcile-freshness / cluster-load tradeoff every
21243 // substrate-side Flux v2 pipeline runs at. Changing this value
21244 // is a coordinated substrate-side reconcile-cadence promotion
21245 // (a `10m` → `5m` migration once lower-latency-poll optimizations
21246 // ship, a `10m` → `15m` migration on cost-optimized clusters
21247 // where per-CR source-controller poll cost outweighs the
21248 // reconcile-freshness gain), not an incidental edit. Peer to
21249 // `default_namespace_pins_canonical_value` and
21250 // `default_gateway_class_name_pins_canonical_value` on the
21251 // canonical-substrate-default-load-bearing-scalar pin surface.
21252 assert_eq!(DEFAULT_FLUX_RECONCILE_INTERVAL, "10m");
21253 }
21254
21255 #[test]
21256 fn default_flux_reconcile_interval_is_a_valid_metav1_duration_scalar() {
21257 // Cross-axis grammar invariant: the Flux v2 controller-side per-
21258 // CR admission gate parses the reconcile-poll cadence scalar via
21259 // `metav1.ParseDuration` before installing the per-CR watch. The
21260 // Go-duration-format grammar is non-empty, ASCII, and structured
21261 // as `<digits><unit>[<digits><unit>...]` where each unit is one
21262 // of `{ns, us, µs, ms, s, m, h}`. Pin a floor that catches the
21263 // canonical drift footguns — an empty scalar (`""` — admission
21264 // gate rejects), a non-ASCII-alphanumeric byte (`"10 m"` — the
21265 // whitespace defeats the parser), a missing-unit scalar (`"10"`
21266 // — the parser rejects for lack of a unit suffix), or a leading-
21267 // non-digit scalar (`"m10"` — the parser rejects for lack of a
21268 // leading magnitude). A future rebrand on the canonical lift
21269 // that lands a value outside the Go-duration-format grammar
21270 // would surface here at caixa-core build time on the canonical
21271 // lift, before any renderer consumes the value. Same shape as
21272 // `default_namespace_is_a_valid_dns_1123_label` /
21273 // `default_flux_system_namespace_is_a_valid_dns_1123_label` /
21274 // `default_gateway_class_name_is_a_valid_dns_1123_label` on the
21275 // peer canonical-substrate-default-grammar-floor surface.
21276 let v = DEFAULT_FLUX_RECONCILE_INTERVAL;
21277 assert!(
21278 !v.is_empty(),
21279 "DEFAULT_FLUX_RECONCILE_INTERVAL {v:?} must be non-empty \
21280 per the Flux v2 controller-side `metav1.ParseDuration` \
21281 admission gate"
21282 );
21283 assert!(
21284 v.chars().all(|c| c.is_ascii_alphanumeric()),
21285 "DEFAULT_FLUX_RECONCILE_INTERVAL {v:?} must be ASCII-\
21286 alphanumeric throughout per the Go-duration-format grammar \
21287 — no whitespace / separator bytes the `metav1.ParseDuration` \
21288 admission gate would reject"
21289 );
21290 let first = v.chars().next().expect("non-empty");
21291 assert!(
21292 first.is_ascii_digit(),
21293 "DEFAULT_FLUX_RECONCILE_INTERVAL {v:?} first byte {first:?} \
21294 must be an ASCII digit per the Go-duration-format grammar \
21295 — the leading magnitude precedes the unit suffix; a leading \
21296 non-digit defeats `metav1.ParseDuration`"
21297 );
21298 let last = v.chars().next_back().expect("non-empty");
21299 assert!(
21300 last.is_ascii_alphabetic() && last.is_ascii_lowercase(),
21301 "DEFAULT_FLUX_RECONCILE_INTERVAL {v:?} last byte {last:?} \
21302 must be an ASCII lowercase alphabetic unit suffix per the \
21303 Go-duration-format grammar — the trailing unit follows the \
21304 magnitude; an unterminated magnitude defeats \
21305 `metav1.ParseDuration`"
21306 );
21307 }
21308
21309 #[test]
21310 fn default_flux_chart_source_subpath_pins_canonical_value() {
21311 // Pin the actual scalar so a typo in this lift can't silently
21312 // rebrand the substrate-side default Flux v2
21313 // `HelmRelease.spec.chart.spec.chart` chart-directory-in-
21314 // GitRepository-source sub-path the substrate's per-caixa
21315 // `cluster_bundle` renderer seeds into every emitted per-caixa
21316 // `helmrelease.yaml` document. The value is part of the
21317 // cluster-side contract with the Flux v2 helm-controller (the
21318 // per-CR chart-open loop uses this to locate the
21319 // `Chart.yaml` + `values.yaml` pair inside the paired
21320 // GitRepository clone root); changing it is a coordinated
21321 // substrate-side chart-directory-in-git-source promotion
21322 // (a `"chart"` → `"charts"` migration on a per-caixa multi-chart
21323 // layout landing, a `"chart"` → `"helm"` migration on a
21324 // cross-language convention alignment, a `"chart"` → `"deploy"`
21325 // migration on a per-caixa-deploy-directory naming migration),
21326 // not an incidental edit. Peer to
21327 // `default_flux_reconcile_interval_pins_canonical_value` +
21328 // `flux_helmrelease_remediation_retries_default_pins_canonical_value`
21329 // on the canonical-Flux-v2-per-CR-substrate-default-scalar pin
21330 // surface.
21331 assert_eq!(DEFAULT_FLUX_CHART_SOURCE_SUBPATH, "chart");
21332 }
21333
21334 #[test]
21335 fn default_flux_chart_source_subpath_is_a_valid_relative_directory_scalar() {
21336 // Cross-axis grammar invariant: the Flux v2 source-controller
21337 // resolves the per-CR `HelmRelease.spec.chart.spec.chart` scalar
21338 // as a directory path relative to the paired `GitRepository`
21339 // clone root. Pin a floor that catches the canonical drift
21340 // footguns — an empty scalar (`""` — the source-controller-side
21341 // per-CR chart-open loop rejects for lack of a target directory),
21342 // a leading-separator scalar (`"/chart"` — the source-controller
21343 // rejects for the absolute-path shape breaking the relative-path
21344 // composition against the per-clone-root anchor), a non-ASCII
21345 // byte (a UTF-8 multi-byte name defeating the per-clone-root
21346 // filesystem name resolution on the source-controller pod's
21347 // filesystem layer), or a leading whitespace / dot byte (`" chart"`
21348 // / `".chart"` — surface as either a "directory not found" per-
21349 // CR error or, worse, a silent match against a hidden dot-file
21350 // sibling of the intended chart directory). A future rebrand on
21351 // the canonical lift that lands a value outside the grammar
21352 // would surface here at caixa-core build time on the canonical
21353 // lift, before any renderer consumes the value. Same shape as
21354 // `default_flux_reconcile_interval_is_a_valid_metav1_duration_scalar`
21355 // on the peer canonical-substrate-default-grammar-floor surface.
21356 let v = DEFAULT_FLUX_CHART_SOURCE_SUBPATH;
21357 assert!(
21358 !v.is_empty(),
21359 "DEFAULT_FLUX_CHART_SOURCE_SUBPATH {v:?} must be non-empty \
21360 per the Flux v2 source-controller-side per-CR chart-open \
21361 loop's requirement of a target directory"
21362 );
21363 assert!(
21364 v.is_ascii(),
21365 "DEFAULT_FLUX_CHART_SOURCE_SUBPATH {v:?} must be ASCII \
21366 throughout — a non-ASCII multi-byte name defeats the per-\
21367 clone-root filesystem name resolution on the source-\
21368 controller pod's filesystem layer"
21369 );
21370 let first = v.chars().next().expect("non-empty");
21371 assert!(
21372 !matches!(first, '/' | '.' | ' ' | '\t'),
21373 "DEFAULT_FLUX_CHART_SOURCE_SUBPATH {v:?} first byte {first:?} \
21374 must not be a leading separator (`/`), leading dot (`.`), or \
21375 leading whitespace — a leading separator breaks the relative-\
21376 path composition against the per-clone-root anchor, a leading \
21377 dot risks silent matches against hidden dot-file siblings, and \
21378 leading whitespace defeats the per-clone-root filesystem name \
21379 resolution"
21380 );
21381 }
21382
21383 #[test]
21384 fn flux_helmrelease_remediation_retries_default_pins_canonical_value() {
21385 // Pin the actual scalar so a typo in this lift can't silently
21386 // rebrand the substrate-side default Flux v2
21387 // `HelmRelease.spec.{install,upgrade}.remediation.retries` retry-
21388 // count ceiling the substrate's per-caixa `cluster_bundle`
21389 // renderer seeds into every emitted per-caixa `helmrelease.yaml`
21390 // document under both the install-path and the upgrade-path
21391 // remediation blocks. The value is part of the cluster-side
21392 // contract with the Flux v2 helm-controller (the per-CR
21393 // remediation loop uses this as the ceiling on the number of
21394 // Helm-install / Helm-upgrade re-attempts before the controller
21395 // marks the `HelmRelease` `Ready: False` and stops retrying);
21396 // changing it is a coordinated substrate-side retry-ceiling
21397 // promotion (a `3` → `5` migration once per-caixa idempotency
21398 // invariants tighten and higher-retry recovery from transient
21399 // apiserver / registry / oci-source flakes becomes safe, a `3` →
21400 // `1` migration on hardened per-caixa pipelines where a failed
21401 // apply should escalate to operator-attention rather than mask
21402 // under further retries), not an incidental edit. Peer to
21403 // `default_flux_reconcile_interval_pins_canonical_value` on the
21404 // canonical-Flux-v2-per-CR-substrate-default-scalar pin surface.
21405 assert_eq!(FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT, 3);
21406 }
21407
21408 #[test]
21409 fn flux_helmrelease_remediation_retries_default_is_a_bounded_positive_scalar() {
21410 // Cross-axis invariant: the Flux v2 `HelmRelease.spec.{install,
21411 // upgrade}.remediation.retries` OpenAPI schema types the field
21412 // as a signed 64-bit integer with a documented sentinel `-1`
21413 // meaning "retry indefinitely". The substrate opts out of the
21414 // unbounded-retry sentinel by declaring the canonical default as
21415 // a positive `u32` — the type itself rules out `-1` at
21416 // caixa-core build time, so a future rebrand on this lift cannot
21417 // silently land the "retry forever" sentinel by construction
21418 // (which would let a persistently-failing per-caixa chart apply
21419 // consume Flux v2 helm-controller reconcile-loop cycles
21420 // indefinitely, masking under further retries rather than
21421 // surfacing at the `HelmRelease.status.conditions[]` axis the
21422 // substrate's downstream reconciliation-topology consumer
21423 // watches). Pin the positive-scalar floor + a substrate-side
21424 // "sane retry ceiling" upper bound (the same 100-attempt hard
21425 // cap the peer `POLICY_RETRIES_MAX` per-`:politicas :retries`
21426 // axis carries; a substrate that seeds a per-CR default above
21427 // that ceiling is structurally a footgun by the same
21428 // "unbounded-retry masks the underlying failure" argument that
21429 // motivates the mesh-policy retries cap). Same shape as
21430 // `default_flux_reconcile_interval_is_a_valid_metav1_duration_scalar`
21431 // on the peer canonical-substrate-default-grammar-floor surface.
21432 let v = FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT;
21433 assert!(
21434 v > 0,
21435 "FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT {v} must be strictly \
21436 positive per the substrate's opt-out from the Flux v2 \
21437 `retries: -1` unbounded-retry sentinel — the `u32` type rules \
21438 out the sentinel, and a zero-retries default is structurally \
21439 a `remediation:` sub-block that never fires the retry path it \
21440 is declaring"
21441 );
21442 assert!(
21443 v <= 100,
21444 "FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT {v} must be within \
21445 the substrate's canonical retry-ceiling upper bound (100) — a \
21446 per-CR default above that ceiling silently masks the underlying \
21447 chart-apply failure under further retries rather than surfacing \
21448 it at the `HelmRelease.status.conditions[]` axis the substrate's \
21449 downstream reconciliation-topology consumer watches, the same \
21450 argument that motivates the peer `POLICY_RETRIES_MAX` per-\
21451 `:politicas :retries` axis cap"
21452 );
21453 }
21454
21455 #[test]
21456 fn flux_helmrelease_key_remediation_pins_canonical_value() {
21457 // Pin the actual string so a typo in this lift can't silently
21458 // rebrand the substrate-side Flux v2
21459 // `HelmRelease.spec.{install,upgrade}.remediation` sub-container-
21460 // axis key the substrate's per-caixa `cluster_bundle` renderer
21461 // seeds into every emitted per-caixa `helmrelease.yaml` document
21462 // at both the install-path + upgrade-path per-CR remediation
21463 // sub-block-header positions. The string is part of the cluster-
21464 // side contract with the Flux v2 helm-controller (the controller's
21465 // per-CR remediation loop reaches the retry-cap scalar through
21466 // this exact sub-container axis; a drifted sub-container-key
21467 // silently strips the entire per-path remediation block from the
21468 // emitted per-CR document, leaving the helm-controller to fall
21469 // back to the Flux v2 upstream defaults for the whole remediation
21470 // surface rather than the substrate's chosen ceiling, with no
21471 // diagnostic naming the container-axis-key-drift root cause).
21472 // Changing it is a coordinated Flux v3 CRD-schema-rebrand
21473 // migration alongside the upstream `helm-controller` deprecation
21474 // cycle (candidates like `recovery` / `retryPolicy` /
21475 // `errorHandling` that upstream Flux v3 roadmap floats in the
21476 // migration prose), not an incidental edit. Peer to
21477 // `flux_helmrelease_remediation_retries_default_pins_canonical_value`
21478 // on the sibling scalar-value half + the sibling
21479 // [`FLUX_HELMRELEASE_KEY_RETRIES`] leaf-scalar-key half of the
21480 // same per-path retry-cap declaration triple.
21481 assert_eq!(FLUX_HELMRELEASE_KEY_REMEDIATION, "remediation");
21482 }
21483
21484 #[test]
21485 fn flux_helmrelease_key_remediation_is_a_valid_dns_1123_label() {
21486 // Cross-axis invariant: every Flux v2 `HelmRelease` CRD-schema
21487 // sub-block-header key resolves through the K8s apiserver's
21488 // OpenAPI-schema-side identifier grammar, whose per-field key
21489 // axis is a subset of the DNS-1123-label grammar (lowercase
21490 // alphanumerics + hyphens, non-empty, ≤63 bytes). Pinning the
21491 // canonical `remediation` value against the typed
21492 // [`is_dns_1123_label`] floor rules out grammar drift on this
21493 // lift at caixa-core build time — a future rebrand landing a
21494 // value outside the DNS-1123-label subset (a leading digit, an
21495 // underscore, an uppercase byte, a `.` byte, or empty) would
21496 // surface here on the canonical lift, before any renderer
21497 // consumes the value and before any per-caixa Flux v2 CR reaches
21498 // the apiserver's OpenAPI-schema-side per-field admission gate.
21499 // Same shape as `default_gateway_class_name_is_a_valid_dns_1123_label`
21500 // on the peer canonical-CRD-schema-grammar-floor surface.
21501 assert!(
21502 is_dns_1123_label(FLUX_HELMRELEASE_KEY_REMEDIATION).is_ok(),
21503 "FLUX_HELMRELEASE_KEY_REMEDIATION {FLUX_HELMRELEASE_KEY_REMEDIATION:?} \
21504 must be a valid DNS-1123 label — every K8s apiserver-side \
21505 OpenAPI-schema-per-field-key axis is a subset of that grammar, \
21506 and the Flux v2 `HelmRelease` CRD schema is no exception"
21507 );
21508 }
21509
21510 #[test]
21511 fn flux_helmrelease_key_install_pins_canonical_value() {
21512 // Pin the actual string so a typo in this lift can't silently
21513 // rebrand the Flux v2 `HelmRelease.spec.install` per-CR helm-
21514 // action-phase discriminator parent-container-axis-key the
21515 // rendered `helmrelease.yaml` document mounts its per-CR first-
21516 // time chart apply phase-block under. The string is part of the
21517 // cluster-side contract with the upstream Flux v2 helm-
21518 // controller — the helm-controller's per-CR phase-dispatch loop
21519 // reaches the install-path phase block through this exact parent-
21520 // container axis; a drifted parent-container-key silently strips
21521 // the entire install-path phase block from the emitted per-CR
21522 // document, leaving the helm-controller to fall back to the Flux
21523 // v2 upstream defaults for the whole install-path phase surface
21524 // rather than the substrate's chosen per-CR install-path knob-set
21525 // (the `createNamespace` seeder never fires, the per-CR retry-cap
21526 // ceiling silently drops off the emitted document), with no
21527 // diagnostic naming the phase-discriminator-drift root cause.
21528 // Changing it is a coordinated Flux v3 CRD-schema-rebrand
21529 // migration alongside the upstream `helm-controller` deprecation
21530 // cycle (candidates like `initialize` / `apply` / `create` /
21531 // `first-run` that upstream Flux v3 roadmap floats in the
21532 // migration prose), not an incidental edit. Peer to
21533 // `flux_helmrelease_key_upgrade_pins_canonical_value` on the
21534 // sibling per-CR upgrade-path phase-discriminator parent-
21535 // container-axis-key half of the same per-CR helm-action-phase
21536 // discriminator parent-container-axis-key pair + the sibling
21537 // [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-axis-key
21538 // hosted beneath both parent-container-axis-keys.
21539 assert_eq!(FLUX_HELMRELEASE_KEY_INSTALL, "install");
21540 }
21541
21542 #[test]
21543 fn flux_helmrelease_key_install_is_a_valid_dns_1123_label() {
21544 // Cross-axis invariant: every Flux v2 `HelmRelease` CRD-schema
21545 // sub-block-header key resolves through the K8s apiserver's
21546 // OpenAPI-schema-side identifier grammar, whose per-field key
21547 // axis is a subset of the DNS-1123-label grammar (lowercase
21548 // alphanumerics + hyphens, non-empty, ≤63 bytes). Pinning the
21549 // canonical `install` value against the typed
21550 // [`is_dns_1123_label`] floor rules out grammar drift on this
21551 // lift at caixa-core build time — a future rebrand landing a
21552 // value outside the DNS-1123-label subset (a leading digit, an
21553 // underscore, an uppercase byte, a `.` byte, or empty) would
21554 // surface here on the canonical lift, before any renderer
21555 // consumes the value and before any per-caixa Flux v2 CR reaches
21556 // the apiserver's OpenAPI-schema-side per-field admission gate.
21557 // Same shape as `flux_helmrelease_key_remediation_is_a_valid_
21558 // dns_1123_label` on the sibling per-CR sub-container-axis-key
21559 // grammar-floor surface.
21560 assert!(
21561 is_dns_1123_label(FLUX_HELMRELEASE_KEY_INSTALL).is_ok(),
21562 "FLUX_HELMRELEASE_KEY_INSTALL {FLUX_HELMRELEASE_KEY_INSTALL:?} \
21563 must be a valid DNS-1123 label — every K8s apiserver-side \
21564 OpenAPI-schema-per-field-key axis is a subset of that grammar, \
21565 and the Flux v2 `HelmRelease` CRD schema is no exception"
21566 );
21567 }
21568
21569 #[test]
21570 fn flux_helmrelease_key_upgrade_pins_canonical_value() {
21571 // Pin the actual string so a typo in this lift can't silently
21572 // rebrand the Flux v2 `HelmRelease.spec.upgrade` per-CR helm-
21573 // action-phase discriminator parent-container-axis-key the
21574 // rendered `helmrelease.yaml` document mounts its per-CR
21575 // subsequent-per-version chart re-apply phase-block under. The
21576 // string is part of the cluster-side contract with the upstream
21577 // Flux v2 helm-controller — the helm-controller's per-CR phase-
21578 // dispatch loop reaches the upgrade-path phase block through this
21579 // exact parent-container axis on every per-version chart re-apply
21580 // after the initial install-path phase completes; a drifted
21581 // parent-container-key silently strips the entire upgrade-path
21582 // phase block from the emitted per-CR document, leaving the
21583 // helm-controller to fall back to the Flux v2 upstream defaults
21584 // for the whole upgrade-path phase surface rather than the
21585 // substrate's chosen per-CR upgrade-path knob-set (the
21586 // `remediateLastFailure` toggle never fires, the per-CR retry-
21587 // cap ceiling silently drops off the emitted document), with no
21588 // diagnostic naming the phase-discriminator-drift root cause.
21589 // Changing it is a coordinated Flux v3 CRD-schema-rebrand
21590 // migration alongside the upstream `helm-controller` deprecation
21591 // cycle (candidates like `reapply` / `reconcile` / `update` /
21592 // `promote` that upstream Flux v3 roadmap floats in the
21593 // migration prose), not an incidental edit. Peer to
21594 // `flux_helmrelease_key_install_pins_canonical_value` on the
21595 // sibling per-CR install-path phase-discriminator parent-
21596 // container-axis-key half of the same per-CR helm-action-phase
21597 // discriminator parent-container-axis-key pair.
21598 assert_eq!(FLUX_HELMRELEASE_KEY_UPGRADE, "upgrade");
21599 }
21600
21601 #[test]
21602 fn flux_helmrelease_key_upgrade_is_a_valid_dns_1123_label() {
21603 // Cross-axis invariant: every Flux v2 `HelmRelease` CRD-schema
21604 // sub-block-header key resolves through the K8s apiserver's
21605 // OpenAPI-schema-side identifier grammar, whose per-field key
21606 // axis is a subset of the DNS-1123-label grammar. Pinning the
21607 // canonical `upgrade` value against the typed
21608 // [`is_dns_1123_label`] floor rules out grammar drift on this
21609 // lift at caixa-core build time. Peer to
21610 // `flux_helmrelease_key_install_is_a_valid_dns_1123_label` on
21611 // the sibling install-path phase-discriminator grammar-floor
21612 // surface + `flux_helmrelease_key_remediation_is_a_valid_dns_
21613 // 1123_label` on the sibling per-CR sub-container-axis-key
21614 // grammar-floor surface — same DNS-1123-label subset governs
21615 // every apiserver-side per-field-key axis, so every peer per-CR
21616 // sub-block-header lift carries the same grammar-floor pin.
21617 assert!(
21618 is_dns_1123_label(FLUX_HELMRELEASE_KEY_UPGRADE).is_ok(),
21619 "FLUX_HELMRELEASE_KEY_UPGRADE {FLUX_HELMRELEASE_KEY_UPGRADE:?} \
21620 must be a valid DNS-1123 label — every K8s apiserver-side \
21621 OpenAPI-schema-per-field-key axis is a subset of that grammar, \
21622 and the Flux v2 `HelmRelease` CRD schema is no exception"
21623 );
21624 }
21625
21626 #[test]
21627 fn flux_helmrelease_key_install_and_upgrade_stay_independent_axes() {
21628 // The two per-CR helm-action-phase discriminator parent-
21629 // container-axis-keys name distinct helm-controller-side phases
21630 // — install-path first-time chart apply vs upgrade-path per-
21631 // version chart re-apply — even though both host the same
21632 // sibling [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-
21633 // axis-key beneath them. Pin that the two consts carry distinct
21634 // byte-sequences so a future rebrand on either arm can't
21635 // silently coalesce onto the peer arm (a
21636 // `FLUX_HELMRELEASE_KEY_INSTALL = "upgrade"` typo would flip
21637 // every substrate-side per-CR first-time chart apply phase
21638 // block onto the upgrade-path phase key silently — the install-
21639 // path becomes the upgrade-path at every emit site, and the
21640 // helm-controller reconciles both phase blocks under the same
21641 // parent-container-axis-key, silently dropping either the
21642 // install-path or the upgrade-path per-CR knob-set with no
21643 // diagnostic naming the phase-discriminator-coalesce root
21644 // cause). The per-CR helm-action-phase discriminator pair must
21645 // always resolve to distinct emitted parent-container-keys.
21646 assert_ne!(
21647 FLUX_HELMRELEASE_KEY_INSTALL, FLUX_HELMRELEASE_KEY_UPGRADE,
21648 "the per-CR install-path and upgrade-path helm-action-phase \
21649 discriminator parent-container-axis-keys must remain byte-\
21650 distinct — a coalesce onto one value silently drops either \
21651 the install-path or the upgrade-path per-CR knob-set from \
21652 every emitted `HelmRelease` document"
21653 );
21654 }
21655
21656 #[test]
21657 fn flux_helmrelease_key_remediate_last_failure_pins_canonical_value() {
21658 // Pin the actual string so a typo in this lift can't silently
21659 // rebrand the Flux v2 `HelmRelease.spec.upgrade.remediation
21660 // .remediateLastFailure` upgrade-path-only per-CR remediation-
21661 // toggle leaf-scalar-key the substrate's per-caixa `cluster_bundle`
21662 // renderer seeds to `true` into every emitted per-caixa
21663 // `helmrelease.yaml` document under the sibling
21664 // [`FLUX_HELMRELEASE_KEY_UPGRADE`] per-CR upgrade-path phase-
21665 // discriminator parent-container-axis-key's nested
21666 // [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-axis-key. The
21667 // string is part of the cluster-side contract with the upstream
21668 // Flux v2 helm-controller — the controller's per-CR upgrade-path
21669 // remediation loop reaches the post-retry-exhaustion rollback
21670 // toggle through this exact leaf; a drifted leaf-scalar-key
21671 // silently strips the substrate's chosen post-retry-exhaustion
21672 // rollback semantic from every emitted per-caixa `HelmRelease`
21673 // document, leaving the helm-controller to leave every terminally-
21674 // failed upgrade in the failed state without rolling back to the
21675 // prior last-known-good release the substrate's "no chart apply
21676 // leaves a per-caixa CR in a stalled, unremediated state"
21677 // MESH-COMPOSITION.md §V guarantee mandates, with no diagnostic
21678 // naming the remediation-toggle-drift root cause. Changing it is
21679 // a coordinated Flux v3 CRD-schema-rebrand migration alongside
21680 // the upstream `helm-controller` deprecation cycle (candidates
21681 // like `rollbackOnFailure` / `remediateOnFailure` /
21682 // `recoverLastFailure` that upstream Flux v3 roadmap floats in
21683 // the migration prose), not an incidental edit. Peer to
21684 // `flux_helmrelease_key_retries_pins_canonical_value` on the
21685 // sibling per-CR retry-cap leaf-scalar-key half of the same
21686 // upgrade-path per-CR remediation block leaf-scalar-key pair.
21687 assert_eq!(
21688 FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE,
21689 "remediateLastFailure"
21690 );
21691 }
21692
21693 #[test]
21694 fn flux_helmrelease_key_remediate_last_failure_stays_independent_of_retries() {
21695 // The upgrade-path per-CR remediation block hosts two independent
21696 // leaf-scalar-key axes under the shared sibling
21697 // [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-axis-key —
21698 // the per-CR retry-cap [`FLUX_HELMRELEASE_KEY_RETRIES`] (that
21699 // also sits under the install-path per-CR remediation block) and
21700 // the upgrade-path-only per-CR remediation-toggle
21701 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`]. Pin that the
21702 // two consts carry byte-distinct sequences so a future rebrand
21703 // on either arm can't silently coalesce onto the peer arm (a
21704 // `FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE = "retries"` typo
21705 // would silently rebind the post-retry-exhaustion rollback
21706 // toggle onto the retry-cap ceiling axis at every emit site —
21707 // the helm-controller then reads the substrate's `true` seed as
21708 // an integer retry-cap `1` on the retry-cap axis instead of the
21709 // rollback-on-terminal-failure boolean, silently truncating the
21710 // per-CR upgrade-path retry budget and dropping the rollback
21711 // semantic entirely with no diagnostic naming the leaf-key-
21712 // coalesce root cause). The upgrade-path per-CR remediation
21713 // leaf-scalar-key pair must always resolve to distinct emitted
21714 // leaf-keys.
21715 assert_ne!(
21716 FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE, FLUX_HELMRELEASE_KEY_RETRIES,
21717 "the upgrade-path per-CR remediation retry-cap leaf-scalar-\
21718 key and remediation-toggle leaf-scalar-key must remain \
21719 byte-distinct — a coalesce onto one value silently rebinds \
21720 the post-retry-exhaustion rollback semantic onto the retry-\
21721 cap ceiling axis at every emit site"
21722 );
21723 }
21724
21725 #[test]
21726 fn flux_helmrelease_key_create_namespace_pins_canonical_value() {
21727 // Pin the actual string so a typo in this lift can't silently
21728 // rebrand the Flux v2 `HelmRelease.spec.install.createNamespace`
21729 // install-path-only per-CR namespace-seeder-toggle leaf-scalar-key
21730 // the substrate's per-caixa `cluster_bundle` renderer seeds to
21731 // `true` into every emitted per-caixa `helmrelease.yaml` document
21732 // under the sibling [`FLUX_HELMRELEASE_KEY_INSTALL`] per-CR
21733 // install-path phase-discriminator parent-container-axis-key. The
21734 // string is part of the cluster-side contract with the upstream
21735 // Flux v2 helm-controller — the controller's per-CR install-path
21736 // pre-apply loop reaches the target-namespace-seeder toggle
21737 // through this exact leaf; a drifted leaf-scalar-key silently
21738 // strips the substrate's chosen first-apply namespace-seeder
21739 // semantic from every emitted per-caixa `HelmRelease` document,
21740 // leaving the helm-controller to refuse every first-time per-caixa
21741 // chart apply against a fresh cluster whose target namespace has
21742 // not been pre-provisioned by an out-of-band pipeline the
21743 // substrate's "no per-caixa Servico apply is blocked on manual
21744 // namespace preprovisioning" MESH-COMPOSITION.md §V install-path-
21745 // fluency guarantee mandates, with no diagnostic naming the
21746 // seeder-toggle-drift root cause. Changing it is a coordinated
21747 // Flux v3 CRD-schema-rebrand migration alongside the upstream
21748 // `helm-controller` deprecation cycle (candidates like
21749 // `createTargetNamespace` / `seedNamespace` / `provisionNamespace`
21750 // that upstream Flux v3 roadmap floats in the migration prose),
21751 // not an incidental edit. Peer to
21752 // `flux_helmrelease_key_remediate_last_failure_pins_canonical_value`
21753 // on the sibling mirror-symmetric upgrade-path-only per-CR
21754 // remediation-toggle leaf-scalar-key half of the same install/
21755 // upgrade per-CR phase-specific toggle leaf-scalar-key pair.
21756 assert_eq!(FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE, "createNamespace");
21757 }
21758
21759 #[test]
21760 fn flux_helmrelease_key_create_namespace_stays_independent_of_remediate_last_failure() {
21761 // The per-CR install/upgrade phase blocks host two mirror-symmetric
21762 // phase-specific toggle leaf-scalar-key axes: the install-path-only
21763 // per-CR namespace-seeder-toggle
21764 // [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] under the sibling
21765 // [`FLUX_HELMRELEASE_KEY_INSTALL`] parent-container-axis-key (this
21766 // lift) and the upgrade-path-only per-CR remediation-toggle
21767 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] (96581b7) under the
21768 // sibling [`FLUX_HELMRELEASE_KEY_UPGRADE`] parent-container-axis-key.
21769 // Pin that the two consts carry byte-distinct sequences so a future
21770 // rebrand on either arm can't silently coalesce onto the peer arm
21771 // (a `FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE = "remediateLastFailure"`
21772 // typo would silently rebind the install-path namespace-seeder
21773 // toggle onto the upgrade-path per-CR remediation-toggle leaf at
21774 // every emit site — the helm-controller would then read the
21775 // substrate's `true` seed as a post-retry-exhaustion rollback opt-
21776 // in on the upgrade-path per-CR remediation axis instead of the
21777 // pre-apply namespace-seeder toggle, silently dropping the first-
21778 // apply namespace-seeder semantic entirely and misrouting the
21779 // install-path opt-in onto an upgrade-path axis where it never
21780 // fires with no diagnostic naming the leaf-key-coalesce root
21781 // cause). The install/upgrade per-CR phase-specific toggle leaf-
21782 // scalar-key pair must always resolve to distinct emitted leaf-
21783 // keys under mirror-symmetric parent-container-axis-keys.
21784 assert_ne!(
21785 FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE, FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE,
21786 "the install-path per-CR namespace-seeder-toggle leaf-scalar-\
21787 key and the upgrade-path per-CR remediation-toggle leaf-\
21788 scalar-key must remain byte-distinct — a coalesce onto one \
21789 value silently rebinds one phase's opt-in toggle onto the \
21790 peer phase's opt-in-toggle axis at every emit site, dropping \
21791 the phase-specific pre-apply / post-retry-exhaustion semantic \
21792 the substrate seeds on the coalesced arm"
21793 );
21794 }
21795
21796 #[test]
21797 fn flux_kustomization_key_prune_pins_canonical_value() {
21798 // Pin the actual string so a typo in this lift can't silently
21799 // rebrand the Flux v2 `Kustomization.spec.prune` per-CR garbage-
21800 // collection-toggle leaf-scalar-key the substrate's per-caixa
21801 // `cluster_bundle` renderer seeds to `true` into every emitted
21802 // per-caixa `kustomization.yaml` document at the top-level `spec`
21803 // position. The string is part of the cluster-side contract with
21804 // the upstream Flux v2 kustomize-controller — the controller's
21805 // per-CR reconcile loop reaches the sweep-what-you-removed toggle
21806 // through this exact leaf; a drifted leaf-scalar-key silently
21807 // strips the substrate's chosen sweep-what-you-removed semantic
21808 // from every emitted per-caixa `Kustomization` document, leaving
21809 // per-caixa resources the source manifest set previously
21810 // reconciled but no longer carries dangling in the cluster the
21811 // substrate's "the cluster's per-caixa live state converges to
21812 // the caixa's tatara-lisp source-of-truth on every reconcile —
21813 // resources the source no longer carries are swept by the
21814 // kustomize-controller, not left dangling" CAIXA-SDLC.md §V
21815 // author-to-live-convergence guarantee mandates, with no
21816 // diagnostic naming the toggle-drift root cause. Changing it is
21817 // a coordinated Flux v3 CRD-schema-rebrand migration alongside
21818 // the upstream `kustomize-controller` deprecation cycle
21819 // (candidates like `garbageCollect` / `sweep` / `pruneOrphaned`
21820 // / `deleteOrphans` that upstream Flux v3 roadmap floats in the
21821 // migration prose), not an incidental edit. Peer to
21822 // `flux_helmrelease_key_create_namespace_pins_canonical_value`
21823 // on the sibling co-resident per-caixa `HelmRelease` CR install-
21824 // path per-CR namespace-seeder-toggle leaf-scalar-key half of
21825 // the same per-caixa Flux-bundle per-CR-toggle leaf-scalar-key
21826 // surface.
21827 assert_eq!(FLUX_KUSTOMIZATION_KEY_PRUNE, "prune");
21828 }
21829
21830 #[test]
21831 fn flux_kustomization_key_prune_stays_independent_of_create_namespace() {
21832 // The per-caixa Flux bundle hosts two co-resident per-CR-toggle
21833 // leaf-scalar-key axes: the per-`Kustomization`-CR garbage-
21834 // collection-toggle [`FLUX_KUSTOMIZATION_KEY_PRUNE`] at the
21835 // top-level `spec` position (this lift) and the per-`HelmRelease`-
21836 // CR install-path namespace-seeder-toggle
21837 // [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] (ba9ab8b) under the
21838 // sibling [`FLUX_HELMRELEASE_KEY_INSTALL`] parent-container-axis-
21839 // key. Pin that the two consts carry byte-distinct sequences so
21840 // a future rebrand on either arm can't silently coalesce onto
21841 // the peer arm (a `FLUX_KUSTOMIZATION_KEY_PRUNE = "createNamespace"`
21842 // typo would silently rebind the Kustomization-CR garbage-
21843 // collection-toggle onto the HelmRelease-CR install-path
21844 // namespace-seeder-toggle leaf at every emit site — the
21845 // kustomize-controller would then read the substrate's `true`
21846 // seed at the drifted leaf-key rather than the canonical `prune`
21847 // axis, silently dropping the sweep-what-you-removed semantic
21848 // entirely and leaving per-caixa resources removed from the
21849 // source manifest set dangling in the cluster with no
21850 // diagnostic naming the leaf-key-coalesce root cause). The
21851 // per-`Kustomization`-CR garbage-collection-toggle and the
21852 // per-`HelmRelease`-CR install-path namespace-seeder-toggle must
21853 // always resolve to distinct emitted leaf-keys under their
21854 // respective co-resident per-CR spec surfaces.
21855 assert_ne!(
21856 FLUX_KUSTOMIZATION_KEY_PRUNE, FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE,
21857 "the per-`Kustomization`-CR garbage-collection-toggle leaf-\
21858 scalar-key and the per-`HelmRelease`-CR install-path \
21859 namespace-seeder-toggle leaf-scalar-key must remain byte-\
21860 distinct — a coalesce onto one value silently rebinds one \
21861 CR's opt-in toggle onto the peer CR's opt-in-toggle axis at \
21862 every emit site, dropping the per-CR-specific sweep-what-\
21863 you-removed / pre-apply-namespace-seeder semantic the \
21864 substrate seeds on the coalesced arm"
21865 );
21866 }
21867
21868 #[test]
21869 fn flux_kustomization_prune_default_pins_canonical_value() {
21870 // Pin the actual boolean so a rebrand on this lift can't silently
21871 // rebrand the Flux v2 `Kustomization.spec.prune` per-CR garbage-
21872 // collection-toggle scalar-value seed the substrate's per-caixa
21873 // `cluster_bundle` renderer threads into every emitted per-caixa
21874 // `kustomization.yaml` document under the sibling
21875 // [`FLUX_KUSTOMIZATION_KEY_PRUNE`] leaf-scalar-key axis. The
21876 // scalar is part of the cluster-side contract with the upstream
21877 // Flux v2 kustomize-controller — the controller's per-CR reconcile
21878 // loop reads the scalar under the sibling leaf-scalar-key axis
21879 // to decide whether to garbage-collect resources that were
21880 // previously reconciled by the CR but no longer appear in the
21881 // CR's current desired-state manifest set. Drift from the
21882 // canonical `true` seed to `false` silently drops the substrate's
21883 // chosen sweep-what-you-removed semantic from every emitted
21884 // per-caixa `Kustomization` document, leaving per-caixa resources
21885 // the source manifest set previously reconciled but no longer
21886 // carries dangling in the cluster the substrate's "the cluster's
21887 // per-caixa live state converges to the caixa's tatara-lisp
21888 // source-of-truth on every reconcile — resources the source no
21889 // longer carries are swept by the kustomize-controller, not left
21890 // dangling" CAIXA-SDLC.md §V author-to-live-convergence guarantee
21891 // mandates, with no diagnostic naming the toggle-drift root
21892 // cause. Changing it is a substrate-side policy migration
21893 // (candidates: `true` → `false` on a per-cluster class where a
21894 // human is expected to prune orphaned resources by hand once
21895 // per-cluster policy grows an operator-driven-cleanup mode; a
21896 // per-caixa opt-out slot the ABSORPTION-ROADMAP.md M4 typed-slot
21897 // trajectory adds once the substrate grows a `:kustomization
21898 // :prune` author-side toggle), not an incidental edit. Peer to
21899 // `flux_helmrelease_remediation_retries_default_pins_lifted_value`
21900 // on the sibling per-path per-CR HelmRelease remediation retry-
21901 // cap scalar-value default axis — that default names the per-
21902 // path per-CR remediation retry ceiling, and this default names
21903 // whether the per-CR reconcile loop sweeps orphaned resources at
21904 // all. Both are substrate-side policy choices the operator
21905 // inherits when the per-caixa `ClusterBundleOpts` doesn't pin an
21906 // override.
21907 assert!(FLUX_KUSTOMIZATION_PRUNE_DEFAULT);
21908 }
21909
21910 #[test]
21911 fn flux_kustomization_prune_default_pairs_with_lifted_leaf_key() {
21912 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-CR
21913 // garbage-collection-toggle declaration lives at two lifted
21914 // `pub const` declarations —
21915 // [`FLUX_KUSTOMIZATION_KEY_PRUNE`] (8ec7917) on the key half
21916 // and [`FLUX_KUSTOMIZATION_PRUNE_DEFAULT`] on the value half.
21917 // Both halves must move together on any coordinated Flux v3
21918 // migration (a `garbageCollect: false` rename that rebrands the
21919 // leaf axis onto a new controller-side opt-in vs. the current
21920 // opt-out default; a leaf coalesce onto a peer per-CR toggle
21921 // that reroutes the substrate's canonical scalar seed onto an
21922 // unrelated axis), so a rebrand on either half without a
21923 // coordinated edit on the other would silently split the
21924 // substrate's canonical sweep-what-you-removed declaration —
21925 // the emit-site format-string would still thread the `{prune_key}`
21926 // named-arg through the lifted leaf-scalar-key but pair it with
21927 // a canonical `{prune_default}` that no longer reflects the
21928 // substrate-side semantic the leaf axis names. Pin the pair here
21929 // so a future edit that touches only the leaf-scalar-key half
21930 // or only the scalar-value default half surfaces at build time
21931 // rather than at reconcile time far from the source edit.
21932 // Confirms both consts carry their canonical wire representations
21933 // (`"prune"` byte-string on the leaf-scalar-key half; `true` on
21934 // the scalar-value default half) — the pair as-a-unit reads as
21935 // the substrate's chosen `prune: true` per-CR opt-in.
21936 assert_eq!(FLUX_KUSTOMIZATION_KEY_PRUNE, "prune");
21937 assert!(FLUX_KUSTOMIZATION_PRUNE_DEFAULT);
21938 }
21939
21940 #[test]
21941 fn flux_helmrelease_remediate_last_failure_default_pins_canonical_value() {
21942 // Pin the actual boolean so a rebrand on this lift can't silently
21943 // rebrand the Flux v2 `HelmRelease.spec.upgrade.remediation
21944 // .remediateLastFailure` upgrade-path-only per-CR remediation-toggle
21945 // scalar-value seed the substrate's per-caixa `cluster_bundle`
21946 // renderer threads into every emitted per-caixa `helmrelease.yaml`
21947 // document under the sibling
21948 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] leaf-scalar-key
21949 // axis. The scalar is part of the cluster-side contract with the
21950 // upstream Flux v2 helm-controller — the controller's per-CR
21951 // upgrade-path remediation loop reads the scalar under the sibling
21952 // leaf-scalar-key axis to decide whether to trigger the prior-
21953 // release rollback pipeline once the paired
21954 // [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] retry-cap ceiling
21955 // has been exhausted. Drift from the canonical `true` seed to
21956 // `false` silently drops the substrate's chosen post-retry-
21957 // exhaustion rollback semantic from every emitted per-caixa
21958 // `HelmRelease` document, leaving every terminally-failed upgrade
21959 // parked at `Ready: False` without rolling back to the prior last-
21960 // known-good release the substrate's "no chart apply leaves a
21961 // per-caixa CR in a stalled, unremediated state" MESH-COMPOSITION
21962 // .md §V guarantee mandates, with no diagnostic naming the
21963 // remediation-toggle-drift root cause. Changing it is a substrate-
21964 // side policy migration (candidates: `true` → `false` on a per-
21965 // cluster class where terminally-failed upgrades must escalate to
21966 // operator-attention rather than mask under an auto-rollback pipe-
21967 // line; a per-caixa opt-out slot the ABSORPTION-ROADMAP.md M4
21968 // typed-slot trajectory adds once the substrate grows a `:upgrade
21969 // :remediate-last-failure` author-side toggle), not an incidental
21970 // edit. Peer to `flux_kustomization_prune_default_pins_canonical_value`
21971 // on the sibling per-`Kustomization`-CR garbage-collection-toggle
21972 // scalar-value default axis — that default names whether the
21973 // per-CR `Kustomization` reconcile loop sweeps orphaned resources
21974 // at all, and this default names whether the per-CR `HelmRelease`
21975 // upgrade-path remediation loop rolls back to the prior last-
21976 // known-good release once the retry-cap ceiling is exhausted.
21977 // Both are substrate-side policy choices the operator inherits
21978 // when the per-caixa `ClusterBundleOpts` doesn't pin an override.
21979 assert!(FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT);
21980 }
21981
21982 #[test]
21983 fn flux_helmrelease_remediate_last_failure_default_pairs_with_lifted_leaf_key() {
21984 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-CR
21985 // upgrade-path per-CR post-retry-exhaustion-rollback-toggle
21986 // declaration lives at two lifted `pub const` declarations —
21987 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] (96581b7) on the
21988 // key half and [`FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT`]
21989 // on the value half. Both halves must move together on any
21990 // coordinated Flux v3 migration (a `rollbackOnFailure: false`
21991 // rename that rebrands the leaf axis onto a new controller-side
21992 // opt-in vs. the current opt-in default; a leaf coalesce onto a
21993 // peer per-CR toggle that reroutes the substrate's canonical
21994 // scalar seed onto an unrelated axis), so a rebrand on either half
21995 // without a coordinated edit on the other would silently split the
21996 // substrate's canonical post-retry-exhaustion rollback declaration
21997 // — the emit-site format-string would still thread the
21998 // `{remediate_last_failure_key}` named-arg through the lifted
21999 // leaf-scalar-key but pair it with a canonical
22000 // `{remediate_last_failure_default}` that no longer reflects the
22001 // substrate-side semantic the leaf axis names. Pin the pair here
22002 // so a future edit that touches only the leaf-scalar-key half or
22003 // only the scalar-value default half surfaces at build time rather
22004 // than at reconcile time far from the source edit. Confirms both
22005 // consts carry their canonical wire representations
22006 // (`"remediateLastFailure"` byte-string on the leaf-scalar-key
22007 // half; `true` on the scalar-value default half) — the pair as-a-
22008 // unit reads as the substrate's chosen
22009 // `remediateLastFailure: true` per-CR opt-in.
22010 assert_eq!(
22011 FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE,
22012 "remediateLastFailure"
22013 );
22014 assert!(FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT);
22015 }
22016
22017 #[test]
22018 fn flux_helmrelease_create_namespace_default_pins_canonical_value() {
22019 // Pin the actual boolean so a rebrand on this lift can't silently
22020 // rebrand the Flux v2 `HelmRelease.spec.install.createNamespace`
22021 // install-path-only per-CR namespace-seeder-toggle scalar-value
22022 // seed the substrate's per-caixa `cluster_bundle` renderer threads
22023 // into every emitted per-caixa `helmrelease.yaml` document under
22024 // the sibling [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] leaf-
22025 // scalar-key axis. The scalar is part of the cluster-side contract
22026 // with the upstream Flux v2 helm-controller — the controller's
22027 // per-CR install-path pre-apply loop reads the scalar under the
22028 // sibling leaf-scalar-key axis to decide whether to first material-
22029 // ize the target namespace before the first-time chart apply.
22030 // Drift from the canonical `true` seed to `false` silently drops
22031 // the substrate's chosen first-apply namespace-seeder semantic
22032 // from every emitted per-caixa `HelmRelease` document, leaving
22033 // every first-time per-caixa chart apply against a fresh cluster
22034 // refused by the helm-controller because the target namespace was
22035 // not pre-provisioned by an out-of-band pipeline the substrate's
22036 // "no per-caixa Servico apply is blocked on manual namespace
22037 // preprovisioning" MESH-COMPOSITION.md §V install-path-fluency
22038 // guarantee mandates, with no diagnostic naming the seeder-toggle-
22039 // drift root cause. Changing it is a substrate-side policy
22040 // migration (candidates: `true` → `false` on hardened per-cluster
22041 // classes where namespace provisioning is an out-of-band operator
22042 // gate; a per-caixa opt-out slot the ABSORPTION-ROADMAP.md M4
22043 // typed-slot trajectory adds once the substrate grows a `:install
22044 // :create-namespace` author-side toggle), not an incidental edit.
22045 // Peer to `flux_helmrelease_remediate_last_failure_default_pins_canonical_value`
22046 // on the sibling mirror-symmetric upgrade-path-only per-CR
22047 // remediation-toggle scalar-value default axis — that default
22048 // names whether the per-CR `HelmRelease` upgrade-path remediation
22049 // loop rolls back to the prior last-known-good release once the
22050 // retry-cap ceiling is exhausted, and this default names whether
22051 // the per-CR `HelmRelease` install-path pre-apply loop materializes
22052 // the target namespace before the first-time chart apply. Both
22053 // are substrate-side policy choices the operator inherits when
22054 // the per-caixa `ClusterBundleOpts` doesn't pin an override, and
22055 // both close the mirror-symmetric install/upgrade per-CR phase-
22056 // specific toggle scalar-value default pair the peer leaf-scalar-
22057 // key pair [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] (ba9ab8b) /
22058 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] (96581b7)
22059 // already closed on the key half.
22060 assert!(FLUX_HELMRELEASE_CREATE_NAMESPACE_DEFAULT);
22061 }
22062
22063 #[test]
22064 fn flux_helmrelease_create_namespace_default_pairs_with_lifted_leaf_key() {
22065 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-CR
22066 // install-path per-CR namespace-seeder-toggle declaration lives
22067 // at two lifted `pub const` declarations —
22068 // [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] (ba9ab8b) on the key
22069 // half and [`FLUX_HELMRELEASE_CREATE_NAMESPACE_DEFAULT`] on the
22070 // value half. Both halves must move together on any coordinated
22071 // Flux v3 migration (a `createTargetNamespace: false` rename that
22072 // rebrands the leaf axis onto a new controller-side opt-in vs.
22073 // the current opt-in default; a leaf coalesce onto a peer per-CR
22074 // toggle that reroutes the substrate's canonical scalar seed onto
22075 // an unrelated axis), so a rebrand on either half without a
22076 // coordinated edit on the other would silently split the substrate's
22077 // canonical first-apply namespace-seeder declaration — the emit-
22078 // site format-string would still thread the
22079 // `{create_namespace_key}` named-arg through the lifted leaf-
22080 // scalar-key but pair it with a canonical `{create_namespace_default}`
22081 // that no longer reflects the substrate-side semantic the leaf
22082 // axis names. Pin the pair here so a future edit that touches
22083 // only the leaf-scalar-key half or only the scalar-value default
22084 // half surfaces at build time rather than at reconcile time far
22085 // from the source edit. Confirms both consts carry their canonical
22086 // wire representations (`"createNamespace"` byte-string on the
22087 // leaf-scalar-key half; `true` on the scalar-value default half) —
22088 // the pair as-a-unit reads as the substrate's chosen
22089 // `createNamespace: true` per-CR opt-in.
22090 assert_eq!(FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE, "createNamespace");
22091 assert!(FLUX_HELMRELEASE_CREATE_NAMESPACE_DEFAULT);
22092 }
22093
22094 #[test]
22095 fn cluster_bundle_lareira_enabled_default_pins_canonical_value() {
22096 // Pin the actual boolean so a rebrand on this lift can't silently
22097 // rebrand the substrate-side default for the
22098 // `HelmRelease.spec.values.<library>.enabled` child-chart-
22099 // enablement toggle scalar the substrate's per-caixa
22100 // `cluster_bundle` renderer threads into every emitted per-caixa
22101 // `helmrelease.yaml` document under the sibling
22102 // [`HELM_VALUES_KEY_ENABLED`] leaf-scalar-key axis inside the
22103 // per-`{library_name}` values-overlay wrap. The scalar is the
22104 // substrate's chosen "force-on the child chart under the
22105 // cluster_bundle composition path" default — semantically
22106 // distinct from and inverse of the standalone
22107 // [`caixa_helm::RenderOpts`]::`enabled_default = false` seed
22108 // (which renders `enabled: false` in the per-caixa `values.yaml`
22109 // so cluster operators must opt each caixa in per-cluster); the
22110 // `cluster_bundle` composition path is the substrate-side
22111 // opt-in path where the operator has already asserted per-caixa
22112 // cluster-scoped ownership by materializing a per-caixa
22113 // GitRepository + HelmRelease + Kustomization trio, so the
22114 // overlay forces the child chart on by seeding `enabled: true`
22115 // under the `values.<library>` wrap. Drift from the canonical
22116 // `true` seed to `false` silently drops the substrate's chosen
22117 // force-on-under-composition semantic from every emitted
22118 // per-caixa `HelmRelease` document, leaving the paired
22119 // [`DEFAULT_LIBRARY_NAME`] child chart's `enabled: false`
22120 // per-chart default un-overridden — the Helm rendering pipeline
22121 // then no-ops every per-caixa lareira child chart at the
22122 // per-cluster `HelmRelease` apply step, with no diagnostic
22123 // naming the toggle-drift root cause. Peer to the sibling
22124 // `flux_helmrelease_create_namespace_default_pins_canonical_value`
22125 // (be1904b) / `flux_helmrelease_remediate_last_failure_default_pins_canonical_value`
22126 // (be1904b) / `flux_kustomization_prune_default_pins_canonical_value`
22127 // (ea857d8) on the peer canonical-Flux-v2-per-CR-substrate-
22128 // default surface — all four defaults are substrate-side policy
22129 // choices the operator inherits when the per-caixa
22130 // `ClusterBundleOpts` doesn't pin an override.
22131 assert!(CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT);
22132 }
22133
22134 #[test]
22135 fn cluster_bundle_lareira_enabled_default_pairs_with_lifted_leaf_key() {
22136 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-
22137 // values-overlay child-chart-enablement-toggle declaration lives
22138 // at two lifted `pub const` declarations —
22139 // [`HELM_VALUES_KEY_ENABLED`] on the key half and
22140 // [`CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT`] on the value half.
22141 // Both halves must move together on any coordinated Helm 4
22142 // migration (an `on: true` rename that rebrands the leaf axis
22143 // onto a new controller-side opt-in vs. the current opt-in
22144 // default; a leaf coalesce onto a peer per-values-block toggle
22145 // that reroutes the substrate's canonical scalar seed onto an
22146 // unrelated axis), so a rebrand on either half without a
22147 // coordinated edit on the other would silently split the
22148 // substrate's canonical force-on-under-composition declaration —
22149 // the emit-site format-string would still thread the
22150 // `{enabled_key}` named-arg through the lifted leaf-scalar-key
22151 // but pair it with a canonical `{lareira_enabled_default}` that
22152 // no longer reflects the substrate-side semantic the leaf axis
22153 // names. Pin the pair here so a future edit that touches only
22154 // the leaf-scalar-key half or only the scalar-value default
22155 // half surfaces at build time rather than at apply time far
22156 // from the source edit. Confirms both consts carry their
22157 // canonical wire representations (`"enabled"` byte-string on
22158 // the leaf-scalar-key half; `true` on the scalar-value default
22159 // half) — the pair as-a-unit reads as the substrate's chosen
22160 // `enabled: true` per-values-overlay opt-in. Peer to
22161 // `flux_kustomization_prune_default_pairs_with_lifted_leaf_key`
22162 // (ea857d8) /
22163 // `flux_helmrelease_create_namespace_default_pairs_with_lifted_leaf_key`
22164 // (be1904b) /
22165 // `flux_helmrelease_remediate_last_failure_default_pairs_with_lifted_leaf_key`
22166 // (be1904b) on the sibling canonical-Flux-v2-per-CR-
22167 // substrate-default paired-halves surfaces.
22168 assert_eq!(HELM_VALUES_KEY_ENABLED, "enabled");
22169 assert!(CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT);
22170 }
22171
22172 #[test]
22173 fn standalone_lareira_enabled_default_pins_canonical_value() {
22174 // Pin the actual boolean so a rebrand on this lift can't silently
22175 // rebrand the substrate-side default for the
22176 // `values.<library>.enabled` child-chart-enablement toggle scalar
22177 // the substrate's per-caixa `caixa_helm::render_chart_for_servico`
22178 // renderer seeds into every emitted per-caixa `values.yaml`
22179 // document under the sibling [`HELM_VALUES_KEY_ENABLED`]
22180 // leaf-scalar-key axis inside the per-`{library_name}` wrap. The
22181 // scalar is the substrate's chosen "leave the child chart opted
22182 // out under the standalone per-chart path" default —
22183 // semantically distinct from and inverse of the composition
22184 // [`CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT`] seed (which renders
22185 // `enabled: true` in the per-cluster `HelmRelease` values-overlay
22186 // so the substrate force-ons the child chart at bundle
22187 // materialization time); the standalone per-chart path is the
22188 // substrate-side opt-out path where the operator has not yet
22189 // asserted per-caixa cluster-scoped ownership by materializing a
22190 // per-caixa GitRepository + HelmRelease + Kustomization trio, so
22191 // the per-chart `values.yaml` seeds `enabled: false` under the
22192 // `values.<library>` wrap and cluster operators must opt each
22193 // caixa in per-cluster. Drift from the canonical `false` seed to
22194 // `true` silently drops the substrate's chosen
22195 // opt-out-under-standalone semantic from every emitted per-caixa
22196 // `values.yaml` document, force-onning the paired
22197 // [`DEFAULT_LIBRARY_NAME`] child chart against the operator's
22198 // stated per-cluster opt-in convention — every rendered chart's
22199 // library-chart-side workload would come up on `helm template` /
22200 // `helm install` with no diagnostic naming the toggle-drift root
22201 // cause. Peer to `cluster_bundle_lareira_enabled_default_pins_canonical_value`
22202 // on the sibling composition-path `HelmRelease.spec.values.<library>.enabled`
22203 // scalar-value default surface — both defaults are substrate-side
22204 // policy choices the operator inherits when the per-caixa
22205 // `RenderOpts` / `ClusterBundleOpts` doesn't pin an override, and
22206 // together they close the mirror-symmetric standalone / composition
22207 // per-values-block child-chart-enablement-toggle scalar-value
22208 // default pair.
22209 assert!(!STANDALONE_LAREIRA_ENABLED_DEFAULT);
22210 }
22211
22212 #[test]
22213 fn standalone_lareira_enabled_default_pairs_with_lifted_leaf_key() {
22214 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-
22215 // values-block child-chart-enablement-toggle declaration on the
22216 // standalone per-chart path lives at two lifted `pub const`
22217 // declarations — [`HELM_VALUES_KEY_ENABLED`] on the key half and
22218 // [`STANDALONE_LAREIRA_ENABLED_DEFAULT`] on the value half. Both
22219 // halves must move together on any coordinated Helm 4 migration
22220 // (an `on: false` rename that rebrands the leaf axis onto a new
22221 // controller-side opt-in vs. the current opt-out default; a leaf
22222 // coalesce onto a peer per-values-block toggle that reroutes the
22223 // substrate's canonical scalar seed onto an unrelated axis), so a
22224 // rebrand on either half without a coordinated edit on the other
22225 // would silently split the substrate's canonical
22226 // opt-out-under-standalone declaration — the emit-site block
22227 // insertion would still thread [`HELM_VALUES_KEY_ENABLED`] as the
22228 // key but pair it with a canonical `enabled_default` scalar-value
22229 // seed that no longer reflects the substrate-side semantic the
22230 // leaf axis names. Pin the pair here so a future edit that
22231 // touches only the leaf-scalar-key half or only the scalar-value
22232 // default half surfaces at build time rather than at apply time
22233 // far from the source edit. Confirms both consts carry their
22234 // canonical wire representations (`"enabled"` byte-string on the
22235 // leaf-scalar-key half; `false` on the scalar-value default half)
22236 // — the pair as-a-unit reads as the substrate's chosen
22237 // `enabled: false` per-values-block opt-out. Peer to
22238 // `cluster_bundle_lareira_enabled_default_pairs_with_lifted_leaf_key`
22239 // on the sibling composition-path
22240 // `HelmRelease.spec.values.<library>.enabled` scalar-value default
22241 // paired-halves surface — both `(key, value)` pairs share the same
22242 // [`HELM_VALUES_KEY_ENABLED`] leaf-scalar-key half but diverge on
22243 // the scalar-value half, which is exactly the mirror-symmetric
22244 // standalone / composition path-selection the two scalar-value
22245 // defaults name.
22246 assert_eq!(HELM_VALUES_KEY_ENABLED, "enabled");
22247 assert!(!STANDALONE_LAREIRA_ENABLED_DEFAULT);
22248 }
22249
22250 #[test]
22251 fn standalone_and_cluster_bundle_lareira_enabled_defaults_are_inverse_by_construction() {
22252 // Cross-const coherence pin: the two peer
22253 // per-values-block child-chart-enablement-toggle scalar-value
22254 // defaults on the standalone per-chart path
22255 // ([`STANDALONE_LAREIRA_ENABLED_DEFAULT`]) and the composition
22256 // per-cluster-`HelmRelease` values-overlay path
22257 // ([`CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT`]) name mirror-symmetric
22258 // inverse defaults on the same underlying
22259 // `values.<library>.enabled` sub-block axis: the standalone-path
22260 // default is `false` (opt-out — cluster operators must opt each
22261 // caixa in per-cluster) while the composition-path default is
22262 // `true` (opt-in — the substrate force-ons the child chart once
22263 // the operator has asserted per-caixa cluster-scoped ownership by
22264 // materializing a per-caixa GitRepository + HelmRelease +
22265 // Kustomization trio). The inversion is the substrate's chosen
22266 // author-to-live path-selection semantic — every consumer that
22267 // reads either default inherits the per-path opt-out / opt-in
22268 // decision by construction, so a future edit that accidentally
22269 // aligned the two defaults (both `false` on a substrate-wide
22270 // opt-out migration, both `true` on a substrate-wide opt-in
22271 // migration) would silently collapse the substrate's chosen
22272 // standalone-vs-composition path-selection semantic — the
22273 // per-chart `values.yaml` default and the per-cluster
22274 // `HelmRelease.spec.values.<library>.enabled` overlay default
22275 // would agree on the same enablement seed, and either the
22276 // standalone path would force-on the child chart against the
22277 // operator's per-cluster opt-in convention (both `true`) or the
22278 // composition path would leave the child chart opted-out against
22279 // the operator's per-caixa cluster-scoped ownership assertion
22280 // (both `false`). Pin the structural inversion here so a future
22281 // edit that touches only one of the two defaults surfaces at
22282 // caixa-core build time rather than at chart-apply time far from
22283 // the constant-drift source. Confirms the two `bool`s carry
22284 // distinct canonical wire representations — the pair as-a-unit
22285 // reads as the substrate's chosen mirror-symmetric author-to-live
22286 // path-selection semantic (standalone opt-out, composition
22287 // opt-in). Peer to the sibling pairwise-distinctness pins the
22288 // `M3_PLACEMENT_ESTRATEGIA_*` /
22289 // `M2_UPGRADE_INSTRUCTION_KIND_*` closed-set typed-enum
22290 // discriminator axes carry on the peer canonical-typed-enum-
22291 // discriminator distinctness surface.
22292 assert_ne!(
22293 STANDALONE_LAREIRA_ENABLED_DEFAULT, CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT,
22294 "STANDALONE_LAREIRA_ENABLED_DEFAULT and CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT \
22295 must remain inverse `bool`s — the standalone per-chart path defaults to \
22296 opt-out (`false`) and the composition per-cluster-HelmRelease values-overlay \
22297 path defaults to opt-in (`true`); collapsing the inversion silently \
22298 breaks the substrate's chosen mirror-symmetric author-to-live \
22299 path-selection semantic at chart-apply time far from the constant-\
22300 drift source."
22301 );
22302 }
22303
22304 #[test]
22305 fn flux_kustomization_key_path_pins_canonical_value() {
22306 // Pin the actual string so a typo in this lift can't silently
22307 // rebrand the Flux v2 `Kustomization.spec.path` per-CR source-
22308 // sub-tree leaf-scalar-key the substrate's per-caixa
22309 // `cluster_bundle` renderer seeds into every emitted per-caixa
22310 // `kustomization.yaml` document at the top-level `spec`
22311 // position. The string is part of the cluster-side contract
22312 // with the upstream Flux v2 kustomize-controller — the
22313 // controller's per-CR reconcile loop reaches the source-sub-
22314 // tree pointer through this exact leaf; a drifted leaf-scalar-
22315 // key silently unbinds every per-caixa `Kustomization` from
22316 // its paired per-caixa sub-tree of the pleme-io k8s repository
22317 // (the controller defaults to `./` when the CR omits the leaf,
22318 // pulling every unrelated cluster's manifests through the
22319 // wrong per-caixa `Kustomization`), with no diagnostic naming
22320 // the leaf-drift root cause. Changing it is a coordinated Flux
22321 // v3 CRD-schema-rebrand migration alongside the upstream
22322 // `kustomize-controller` deprecation cycle (candidates like
22323 // `sourcePath` / `manifestsPath` / `sourceRoot` upstream Flux
22324 // v3 roadmap floats), not an incidental edit. Peer to
22325 // `flux_kustomization_key_prune_pins_canonical_value` on the
22326 // sibling co-resident per-`Kustomization`-CR `spec.prune`
22327 // garbage-collection-toggle leaf-scalar-key half of the same
22328 // per-`Kustomization`-CR-spec surface.
22329 assert_eq!(FLUX_KUSTOMIZATION_KEY_PATH, "path");
22330 }
22331
22332 #[test]
22333 fn flux_kustomization_key_path_stays_independent_of_prune() {
22334 // The per-`Kustomization`-CR top-level `spec` surface hosts two
22335 // co-resident leaf-scalar-key axes: the per-CR source-sub-tree
22336 // pointer [`FLUX_KUSTOMIZATION_KEY_PATH`] (this lift) and the
22337 // per-CR garbage-collection-toggle [`FLUX_KUSTOMIZATION_KEY_PRUNE`]
22338 // (8ec7917). Pin that the two consts carry byte-distinct
22339 // sequences so a future rebrand on either arm can't silently
22340 // coalesce onto the peer arm (a
22341 // `FLUX_KUSTOMIZATION_KEY_PATH = "prune"` typo would silently
22342 // rebind the substrate's per-cluster / per-caixa sub-tree path
22343 // seed onto the garbage-collection-toggle leaf at every emit
22344 // site — the kustomize-controller would then read the
22345 // substrate's `./clusters/<cluster>/services/<name>` seed as a
22346 // boolean opt-in toggle, silently unbinding the per-caixa
22347 // `Kustomization` from its source-sub-tree entirely with no
22348 // diagnostic naming the leaf-key-coalesce root cause). The
22349 // per-`Kustomization`-CR source-sub-tree pointer and the per-
22350 // `Kustomization`-CR garbage-collection-toggle must always
22351 // resolve to distinct emitted leaf-keys under the same
22352 // top-level `spec` position.
22353 assert_ne!(
22354 FLUX_KUSTOMIZATION_KEY_PATH, FLUX_KUSTOMIZATION_KEY_PRUNE,
22355 "the per-`Kustomization`-CR source-sub-tree leaf-scalar-key \
22356 and the per-`Kustomization`-CR garbage-collection-toggle \
22357 leaf-scalar-key must remain byte-distinct — a coalesce \
22358 onto one value silently rebinds one axis onto the peer \
22359 axis at every emit site, dropping the source-sub-tree / \
22360 sweep-what-you-removed semantic the substrate seeds on the \
22361 coalesced arm"
22362 );
22363 }
22364
22365 #[test]
22366 fn flux_kustomization_key_timeout_pins_canonical_value() {
22367 // Pin the actual string so a typo in this lift can't silently
22368 // rebrand the Flux v2 `Kustomization.spec.timeout` per-CR
22369 // reconcile wall-clock cap leaf-scalar-key the substrate's per-
22370 // caixa `cluster_bundle` renderer seeds into every emitted per-
22371 // caixa `kustomization.yaml` document at the top-level `spec`
22372 // position. The string is part of the cluster-side contract
22373 // with the upstream Flux v2 kustomize-controller — the
22374 // controller's per-CR reconcile loop reaches the wall-clock cap
22375 // through this exact leaf; a drifted leaf-scalar-key silently
22376 // strips the substrate's chosen reconcile-ceiling from every
22377 // emitted per-caixa `Kustomization` document, letting the
22378 // controller fall back to the upstream Flux v2 controller-side
22379 // default cap rather than the substrate's per-caixa
22380 // idempotency-checkpoint-tuned ceiling, with no diagnostic
22381 // naming the timeout-drift root cause. Changing it is a
22382 // coordinated Flux v3 CRD-schema-rebrand migration alongside
22383 // the upstream `kustomize-controller` deprecation cycle, not
22384 // an incidental edit. Peer to
22385 // `flux_kustomization_key_path_pins_canonical_value` and
22386 // `flux_kustomization_key_prune_pins_canonical_value` on the
22387 // sibling co-resident per-`Kustomization`-CR spec surface
22388 // leaf-scalar-key axes.
22389 assert_eq!(FLUX_KUSTOMIZATION_KEY_TIMEOUT, "timeout");
22390 }
22391
22392 #[test]
22393 fn flux_kustomization_key_timeout_stays_independent_of_path_and_prune() {
22394 // The per-`Kustomization`-CR top-level `spec` surface hosts
22395 // three co-resident leaf-scalar-key axes: the per-CR reconcile
22396 // wall-clock cap [`FLUX_KUSTOMIZATION_KEY_TIMEOUT`] (this
22397 // lift), the per-CR source-sub-tree pointer
22398 // [`FLUX_KUSTOMIZATION_KEY_PATH`] (613d7ed), and the per-CR
22399 // garbage-collection-toggle [`FLUX_KUSTOMIZATION_KEY_PRUNE`]
22400 // (8ec7917). Pin that the three consts carry byte-distinct
22401 // sequences so a future rebrand on any one arm can't silently
22402 // coalesce onto a peer arm (a
22403 // `FLUX_KUSTOMIZATION_KEY_TIMEOUT = "path"` typo would silently
22404 // rebind the reconcile wall-clock cap onto the source-sub-tree
22405 // pointer leaf at every emit site — the kustomize-controller
22406 // would then parse the substrate's `./clusters/<c>/services/<n>`
22407 // seed as a `metav1.Duration` scalar and reject the per-CR
22408 // admission gate, with no diagnostic naming the leaf-key-
22409 // coalesce root cause). The per-`Kustomization`-CR reconcile
22410 // wall-clock cap, per-CR source-sub-tree pointer, and per-CR
22411 // garbage-collection-toggle must always resolve to distinct
22412 // emitted leaf-keys under the same top-level `spec` position.
22413 assert_ne!(
22414 FLUX_KUSTOMIZATION_KEY_TIMEOUT, FLUX_KUSTOMIZATION_KEY_PATH,
22415 "the per-`Kustomization`-CR reconcile wall-clock cap leaf-\
22416 scalar-key and the per-`Kustomization`-CR source-sub-tree \
22417 leaf-scalar-key must remain byte-distinct — a coalesce onto \
22418 one value silently rebinds one axis onto the peer axis at \
22419 every emit site, dropping the reconcile-ceiling / source-\
22420 sub-tree semantic the substrate seeds on the coalesced arm"
22421 );
22422 assert_ne!(
22423 FLUX_KUSTOMIZATION_KEY_TIMEOUT, FLUX_KUSTOMIZATION_KEY_PRUNE,
22424 "the per-`Kustomization`-CR reconcile wall-clock cap leaf-\
22425 scalar-key and the per-`Kustomization`-CR garbage-\
22426 collection-toggle leaf-scalar-key must remain byte-distinct \
22427 — a coalesce onto one value silently rebinds one axis onto \
22428 the peer axis at every emit site, dropping the reconcile-\
22429 ceiling / sweep-what-you-removed semantic the substrate \
22430 seeds on the coalesced arm"
22431 );
22432 }
22433
22434 #[test]
22435 fn default_flux_kustomization_timeout_pins_canonical_value() {
22436 // Pin the actual scalar so a typo in this lift can't silently
22437 // rebrand the substrate-side default Flux v2
22438 // `Kustomization.spec.timeout` reconcile wall-clock cap the
22439 // substrate's per-caixa `cluster_bundle` renderer seeds into
22440 // every emitted per-caixa `kustomization.yaml` document at the
22441 // top-level `spec` position. The value is part of the cluster-
22442 // side contract with the Flux v2 kustomize-controller (the
22443 // per-CR reconcile loop uses this as the ceiling on the wall-
22444 // clock time a single reconcile attempt is allowed to consume
22445 // before the controller marks the `Kustomization`
22446 // `Ready: False` and stops retrying); changing it is a
22447 // coordinated substrate-side reconcile-ceiling promotion (a
22448 // `5m` → `3m` migration on faster per-caixa idempotency-
22449 // checkpoint cadence, a `5m` → `10m` migration on larger per-
22450 // caixa manifest sets), not an incidental edit. Peer to
22451 // `default_flux_reconcile_interval_pins_canonical_value` and
22452 // `flux_helmrelease_remediation_retries_default_pins_canonical_value`
22453 // on the canonical-Flux-v2-per-CR-substrate-default-scalar pin
22454 // surface.
22455 assert_eq!(DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT, "5m");
22456 }
22457
22458 #[test]
22459 fn default_flux_kustomization_timeout_is_a_valid_metav1_duration_scalar() {
22460 // Cross-axis grammar invariant: the Flux v2 kustomize-
22461 // controller-side per-CR admission gate parses the reconcile
22462 // wall-clock cap scalar via `metav1.ParseDuration` before
22463 // installing the per-CR watch. The Go-duration-format grammar
22464 // is non-empty, ASCII, and structured as
22465 // `<digits><unit>[<digits><unit>...]` where each unit is one of
22466 // `{ns, us, µs, ms, s, m, h}`. Pin a floor that catches the
22467 // canonical drift footguns — an empty scalar (`""` — admission
22468 // gate rejects), a non-ASCII-alphanumeric byte (`"5 m"` — the
22469 // whitespace defeats the parser), a missing-unit scalar (`"5"`
22470 // — the parser rejects for lack of a unit suffix), or a
22471 // leading-non-digit scalar (`"m5"` — the parser rejects for
22472 // lack of a leading magnitude). A future rebrand on the
22473 // canonical lift that lands a value outside the Go-duration-
22474 // format grammar would surface here at caixa-core build time
22475 // on the canonical lift, before any renderer consumes the
22476 // value. Same shape as
22477 // `default_flux_reconcile_interval_is_a_valid_metav1_duration_scalar`
22478 // on the peer canonical-substrate-default-grammar-floor surface.
22479 let v = DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT;
22480 assert!(
22481 !v.is_empty(),
22482 "DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT {v:?} must be non-empty \
22483 per the Flux v2 controller-side `metav1.ParseDuration` \
22484 admission gate"
22485 );
22486 assert!(
22487 v.chars().all(|c| c.is_ascii_alphanumeric()),
22488 "DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT {v:?} must be ASCII-\
22489 alphanumeric throughout per the Go-duration-format grammar \
22490 — no whitespace / separator bytes the `metav1.ParseDuration` \
22491 admission gate would reject"
22492 );
22493 let first = v.chars().next().expect("non-empty");
22494 assert!(
22495 first.is_ascii_digit(),
22496 "DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT {v:?} first byte {first:?} \
22497 must be an ASCII digit per the Go-duration-format grammar \
22498 — the leading magnitude precedes the unit suffix; a leading \
22499 non-digit defeats `metav1.ParseDuration`"
22500 );
22501 let last = v.chars().next_back().expect("non-empty");
22502 assert!(
22503 last.is_ascii_alphabetic() && last.is_ascii_lowercase(),
22504 "DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT {v:?} last byte {last:?} \
22505 must be an ASCII lowercase alphabetic unit suffix per the \
22506 Go-duration-format grammar — the trailing unit follows the \
22507 magnitude; an unterminated magnitude defeats \
22508 `metav1.ParseDuration`"
22509 );
22510 }
22511
22512 #[test]
22513 fn default_gateway_class_name_pins_canonical_value() {
22514 // Pin the actual string so a typo in this lift can't silently
22515 // rebrand the substrate's chosen K8s Gateway API controller the
22516 // rendered `Gateway`'s `spec.gatewayClassName` axis binds to.
22517 // The string is part of the cluster-side contract with the Cilium
22518 // Gateway API implementation (the Cilium operator watches
22519 // `GatewayClass` objects whose `spec.controllerName` names the
22520 // Cilium reconciler; a drifted `spec.gatewayClassName` on the
22521 // emitted `Gateway` refers to a `GatewayClass` no controller
22522 // reconciles, and the `Gateway` sits at `Programmed: False`
22523 // with every attached `HTTPRoute` unbound), the same eBPF-identity
22524 // data plane the sibling `CiliumNetworkPolicy` renderer emits
22525 // policies against (the mesh-composition "one identity layer,
22526 // one data plane" invariant, MESH-COMPOSITION.md §V), and the
22527 // per-cluster GatewayClass fixture the operator-side install
22528 // pipeline provisions. Changing it is a coordinated multi-repo
22529 // migration (a substrate-side Gateway controller migration to
22530 // Envoy Gateway / Istio Gateway or any per-edition variant),
22531 // not an incidental edit. Peer to
22532 // `default_namespace_pins_canonical_value` and
22533 // `default_flux_system_namespace_pins_canonical_value` on the
22534 // canonical-substrate-default-resource-name-value-pin axis.
22535 assert_eq!(DEFAULT_GATEWAY_CLASS_NAME, "cilium");
22536 }
22537
22538 #[test]
22539 fn default_gateway_class_name_is_a_valid_dns_1123_label() {
22540 // Cross-axis invariant: the Gateway API `GatewayClass` is a
22541 // cluster-scoped K8s resource, and the K8s apiserver enforces
22542 // the DNS-1123 label rule on every cluster-scoped resource's
22543 // `metadata.name`. The emitted `Gateway`'s
22544 // `spec.gatewayClassName` axis references the `GatewayClass`
22545 // resource by that name — a drift to a value the apiserver
22546 // would refuse as a `GatewayClass.metadata.name` couldn't
22547 // resolve at reconcile time either, and the `Gateway`
22548 // Programmed condition never flips true. Pinning this here
22549 // means a future rebrand on the canonical lift can't silently
22550 // land a value the apiserver refuses at the *first* `Gateway`
22551 // apply against a cluster, far from the rebrand commit's
22552 // source — the typed [`is_dns_1123_label`] floor rejects it at
22553 // caixa-core build time on the canonical lift, before any
22554 // renderer consumes the value. Same shape as
22555 // `default_namespace_is_a_valid_dns_1123_label` and
22556 // `default_flux_system_namespace_is_a_valid_dns_1123_label` on
22557 // the peer canonical-DNS-1123-label-floor axes.
22558 assert!(
22559 is_dns_1123_label(DEFAULT_GATEWAY_CLASS_NAME).is_ok(),
22560 "DEFAULT_GATEWAY_CLASS_NAME {DEFAULT_GATEWAY_CLASS_NAME:?} must be a \
22561 valid DNS-1123 label — every K8s apiserver-side schema enforces \
22562 this rule on cluster-scoped `metadata.name` axes, and the \
22563 `Gateway.spec.gatewayClassName` axis resolves by that same rule"
22564 );
22565 }
22566
22567 #[test]
22568 fn flux_helmrelease_api_version_pins_canonical_value() {
22569 // Pin the actual string so a typo in this lift can't silently
22570 // rebrand the Flux v2 `HelmRelease` CRD group/version the rendered
22571 // `helmrelease.yaml` document declares + the rendered
22572 // `kustomization.yaml` document's `healthChecks[].apiVersion`
22573 // axis transitively references. The string is part of the
22574 // cluster-side contract with the Flux v2 `helm-controller` (the
22575 // controller watches the exact `helm.toolkit.fluxcd.io/v2`
22576 // group/version; a drifted value to a stale v2beta1 / v2beta2
22577 // lands the rendered `HelmRelease` outside the controller's
22578 // `Watches` and fails at apply time with "no kind 'HelmRelease'
22579 // is registered for version 'helm.toolkit.fluxcd.io/v2beta2'");
22580 // changing it is a coordinated Flux v3 migration alongside the
22581 // upstream `helm-controller` deprecation cycle, not an
22582 // incidental edit. Peer to `default_flux_system_namespace_pins_canonical_value`
22583 // on the canonical-Flux-CRD-axis-pin axis for the sibling
22584 // [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] constant.
22585 assert_eq!(FLUX_HELMRELEASE_API_VERSION, "helm.toolkit.fluxcd.io/v2");
22586 }
22587
22588 #[test]
22589 fn flux_helmrelease_api_version_carries_group_and_version_segments() {
22590 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
22591 // `<group>/<version>` pair separated by exactly one `/` byte.
22592 // The group segment is a DNS-style multi-segment hostname
22593 // (`helm.toolkit.fluxcd.io`) and the version segment is a
22594 // Kubernetes API version label (`v2`, `v2beta1`, `v1alpha1` —
22595 // peer with the K8s API versioning convention upstream
22596 // documents). Pinning this here means a future rebrand on the
22597 // canonical lift can't silently land a malformed apiVersion
22598 // (no `/`, two `/`, empty group, empty version) that every
22599 // downstream YAML-aware deserializer would reject far from the
22600 // rebrand commit's source. The single-`/` invariant is the
22601 // load-bearing K8s API typed-discovery contract: a value the
22602 // apiserver's `RESTMapper` consults to resolve the CRD's
22603 // `RESTKind`.
22604 let v = FLUX_HELMRELEASE_API_VERSION;
22605 let parts: Vec<&str> = v.split('/').collect();
22606 assert_eq!(
22607 parts.len(),
22608 2,
22609 "FLUX_HELMRELEASE_API_VERSION {v:?} must split into exactly two \
22610 `/`-delimited segments (group/version) per the K8s CRD apiVersion \
22611 grammar — every downstream YAML-aware deserializer enforces this \
22612 shape"
22613 );
22614 assert!(
22615 !parts[0].is_empty(),
22616 "FLUX_HELMRELEASE_API_VERSION {v:?} group segment must be non-empty"
22617 );
22618 assert!(
22619 !parts[1].is_empty(),
22620 "FLUX_HELMRELEASE_API_VERSION {v:?} version segment must be non-empty"
22621 );
22622 assert!(
22623 parts[0].contains('.'),
22624 "FLUX_HELMRELEASE_API_VERSION {v:?} group segment {group:?} must be a \
22625 DNS-style multi-segment hostname (the canonical CRD-group convention \
22626 every K8s controller-runtime / kube-rs-aware client expects)",
22627 group = parts[0]
22628 );
22629 }
22630
22631 #[test]
22632 fn default_flux_helmrelease_api_version_matches_caixa_flux_test_fixtures() {
22633 // Cross-file drift pin: the four caixa-flux occurrences of
22634 // `helm.toolkit.fluxcd.io/v2` all consult the same canonical
22635 // constant, but the two `upsert_into_helmrelease_programs` test
22636 // fixtures (caixa-flux/src/lib.rs:928, 970) carry the value as
22637 // a static raw-string literal inside a `serde_yaml::from_str`
22638 // input (the YAML parser is the unit-under-test there, not the
22639 // rendering — the literals are intentionally not threaded
22640 // through the lift). This pin trips at caixa-core build time
22641 // if the canonical constant ever drifts past the literal the
22642 // caixa-flux test fixtures carry, so a future Flux v3 migration
22643 // surfaces here on the canonical-string axis rather than at the
22644 // first failing test fixture far from the rebrand commit. Peer
22645 // to the [`default_flux_system_namespace_pins_canonical_value`]
22646 // pin on the sibling Flux-namespace axis: both pin the canonical
22647 // string at the lift site so a future rebrand lands the
22648 // constant + every downstream reference + every test fixture in
22649 // one coordinated edit.
22650 assert_eq!(
22651 FLUX_HELMRELEASE_API_VERSION, "helm.toolkit.fluxcd.io/v2",
22652 "drift between FLUX_HELMRELEASE_API_VERSION and the \
22653 caixa-flux/src/lib.rs:928,970 test fixtures' literal values; \
22654 coordinate the migration across the const + every fixture in \
22655 one edit"
22656 );
22657 }
22658
22659 #[test]
22660 fn flux_gitrepository_api_version_pins_canonical_value() {
22661 // Pin the actual string so a typo in this lift can't silently
22662 // rebrand the Flux v2 `GitRepository` CRD group/version the rendered
22663 // `gitrepository.yaml` document declares. The string is part of the
22664 // cluster-side contract with the Flux v2 `source-controller` (the
22665 // controller watches the exact `source.toolkit.fluxcd.io/v1`
22666 // group/version; a drifted value to a stale v1beta1 / v1beta2 lands
22667 // the rendered `GitRepository` outside the controller's `Watches`
22668 // and fails at apply time with "no kind 'GitRepository' is
22669 // registered for version 'source.toolkit.fluxcd.io/v1beta2'");
22670 // changing it is a coordinated Flux v3 migration alongside the
22671 // upstream `source-controller` deprecation cycle, not an
22672 // incidental edit. Peer to
22673 // `flux_helmrelease_api_version_pins_canonical_value` on the
22674 // canonical-Flux-CRD-axis-pin axis for the sibling
22675 // [`FLUX_HELMRELEASE_API_VERSION`] constant.
22676 assert_eq!(
22677 FLUX_GITREPOSITORY_API_VERSION,
22678 "source.toolkit.fluxcd.io/v1"
22679 );
22680 }
22681
22682 #[test]
22683 fn flux_gitrepository_api_version_carries_group_and_version_segments() {
22684 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
22685 // `<group>/<version>` pair separated by exactly one `/` byte.
22686 // The group segment is a DNS-style multi-segment hostname
22687 // (`source.toolkit.fluxcd.io`) and the version segment is a
22688 // Kubernetes API version label (`v1`, `v1beta1`, `v1alpha1` — peer
22689 // with the K8s API versioning convention upstream documents).
22690 // Pinning this here means a future rebrand on the canonical lift
22691 // can't silently land a malformed apiVersion (no `/`, two `/`,
22692 // empty group, empty version) that every downstream YAML-aware
22693 // deserializer would reject far from the rebrand commit's source.
22694 // The single-`/` invariant is the load-bearing K8s API typed-
22695 // discovery contract: a value the apiserver's `RESTMapper`
22696 // consults to resolve the CRD's `RESTKind`. Peer to
22697 // `flux_helmrelease_api_version_carries_group_and_version_segments`
22698 // on the sibling Flux-CRD-axis.
22699 let v = FLUX_GITREPOSITORY_API_VERSION;
22700 let parts: Vec<&str> = v.split('/').collect();
22701 assert_eq!(
22702 parts.len(),
22703 2,
22704 "FLUX_GITREPOSITORY_API_VERSION {v:?} must split into exactly two \
22705 `/`-delimited segments (group/version) per the K8s CRD apiVersion \
22706 grammar — every downstream YAML-aware deserializer enforces this \
22707 shape"
22708 );
22709 assert!(
22710 !parts[0].is_empty(),
22711 "FLUX_GITREPOSITORY_API_VERSION {v:?} group segment must be non-empty"
22712 );
22713 assert!(
22714 !parts[1].is_empty(),
22715 "FLUX_GITREPOSITORY_API_VERSION {v:?} version segment must be non-empty"
22716 );
22717 assert!(
22718 parts[0].contains('.'),
22719 "FLUX_GITREPOSITORY_API_VERSION {v:?} group segment {group:?} must be a \
22720 DNS-style multi-segment hostname (the canonical CRD-group convention \
22721 every K8s controller-runtime / kube-rs-aware client expects)",
22722 group = parts[0]
22723 );
22724 }
22725
22726 #[test]
22727 fn flux_gitrepository_and_helmrelease_api_versions_share_toolkit_fluxcd_io_root() {
22728 // Cross-axis invariant: every Flux v2 CRD group ends in the canonical
22729 // `.toolkit.fluxcd.io` root the upstream `fluxcd/flux2` project pins
22730 // for the source-/helm-/kustomize-/notification-controller triplet.
22731 // A future Flux v3 promotion that breaks the root suffix (forking
22732 // `source-controller` out of the toolkit group, for example) would
22733 // surface here as a coordinated cross-axis edit-point — both lifted
22734 // constants must move together to preserve the controller-triple
22735 // contract.
22736 const ROOT: &str = ".toolkit.fluxcd.io";
22737 let gr_group = FLUX_GITREPOSITORY_API_VERSION
22738 .split('/')
22739 .next()
22740 .expect("FLUX_GITREPOSITORY_API_VERSION has a group segment");
22741 let hr_group = FLUX_HELMRELEASE_API_VERSION
22742 .split('/')
22743 .next()
22744 .expect("FLUX_HELMRELEASE_API_VERSION has a group segment");
22745 assert!(
22746 gr_group.ends_with(ROOT),
22747 "FLUX_GITREPOSITORY_API_VERSION group {gr_group:?} must end with the \
22748 canonical Flux v2 `{ROOT}` root every controller in the triplet shares"
22749 );
22750 assert!(
22751 hr_group.ends_with(ROOT),
22752 "FLUX_HELMRELEASE_API_VERSION group {hr_group:?} must end with the \
22753 canonical Flux v2 `{ROOT}` root every controller in the triplet shares"
22754 );
22755 }
22756
22757 #[test]
22758 fn flux_kustomization_api_version_pins_canonical_value() {
22759 // Pin the actual string so a typo in this lift can't silently
22760 // rebrand the Flux v2 `Kustomization` CRD group/version the
22761 // rendered `kustomization.yaml` document declares. The string
22762 // is part of the cluster-side contract with the Flux v2
22763 // `kustomize-controller` (the controller watches the exact
22764 // `kustomize.toolkit.fluxcd.io/v1` group/version; a drifted
22765 // value to a stale v1beta1 / v1beta2 lands the rendered
22766 // `Kustomization` outside the controller's `Watches` and
22767 // fails at apply time with "no kind 'Kustomization' is
22768 // registered for version
22769 // 'kustomize.toolkit.fluxcd.io/v1beta2'"); changing it is a
22770 // coordinated Flux v3 migration alongside the upstream
22771 // `kustomize-controller` deprecation cycle, not an
22772 // incidental edit. Peer to
22773 // `flux_helmrelease_api_version_pins_canonical_value` /
22774 // `flux_gitrepository_api_version_pins_canonical_value` on
22775 // the canonical-Flux-CRD-axis-pin axis for the sibling
22776 // [`FLUX_HELMRELEASE_API_VERSION`] /
22777 // [`FLUX_GITREPOSITORY_API_VERSION`] constants — completes
22778 // the Flux v2 controller-triplet's per-CRD-axis pin set.
22779 assert_eq!(
22780 FLUX_KUSTOMIZATION_API_VERSION,
22781 "kustomize.toolkit.fluxcd.io/v1"
22782 );
22783 }
22784
22785 #[test]
22786 fn flux_kustomization_api_version_carries_group_and_version_segments() {
22787 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
22788 // `<group>/<version>` pair separated by exactly one `/` byte.
22789 // The group segment is a DNS-style multi-segment hostname
22790 // (`kustomize.toolkit.fluxcd.io`) and the version segment is a
22791 // Kubernetes API version label (`v1`, `v1beta1`, `v1alpha1` —
22792 // peer with the K8s API versioning convention upstream
22793 // documents). Pinning this here means a future rebrand on the
22794 // canonical lift can't silently land a malformed apiVersion
22795 // (no `/`, two `/`, empty group, empty version) that every
22796 // downstream YAML-aware deserializer would reject far from the
22797 // rebrand commit's source. The single-`/` invariant is the
22798 // load-bearing K8s API typed-discovery contract: a value the
22799 // apiserver's `RESTMapper` consults to resolve the CRD's
22800 // `RESTKind`. Peer to
22801 // `flux_helmrelease_api_version_carries_group_and_version_segments`
22802 // / `flux_gitrepository_api_version_carries_group_and_version_segments`
22803 // on the sibling Flux-CRD-axis.
22804 let v = FLUX_KUSTOMIZATION_API_VERSION;
22805 let parts: Vec<&str> = v.split('/').collect();
22806 assert_eq!(
22807 parts.len(),
22808 2,
22809 "FLUX_KUSTOMIZATION_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_KUSTOMIZATION_API_VERSION {v:?} group segment must be non-empty"
22817 );
22818 assert!(
22819 !parts[1].is_empty(),
22820 "FLUX_KUSTOMIZATION_API_VERSION {v:?} version segment must be non-empty"
22821 );
22822 assert!(
22823 parts[0].contains('.'),
22824 "FLUX_KUSTOMIZATION_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_controller_triplet_api_versions_share_toolkit_fluxcd_io_root() {
22833 // Cross-axis triplet invariant: the Flux v2 controller triplet
22834 // (source-controller + helm-controller + kustomize-controller)
22835 // upstream all share the canonical `.toolkit.fluxcd.io` root.
22836 // The two-axis sibling pin
22837 // [`flux_gitrepository_and_helmrelease_api_versions_share_toolkit_fluxcd_io_root`]
22838 // enforces the invariant on the source-/helm- pair; this
22839 // pin extends it onto the kustomize-controller axis so a
22840 // future Flux v3 promotion that forks any single controller
22841 // out of the toolkit group surfaces as a coordinated
22842 // cross-axis edit-point across all three constants — the
22843 // controller triplet's CRD group/versions move together
22844 // upstream, and the lift discipline preserves that
22845 // movement at the typed substrate-side `&'static str`
22846 // surface.
22847 const ROOT: &str = ".toolkit.fluxcd.io";
22848 for (name, v) in [
22849 (
22850 "FLUX_GITREPOSITORY_API_VERSION",
22851 FLUX_GITREPOSITORY_API_VERSION,
22852 ),
22853 ("FLUX_HELMRELEASE_API_VERSION", FLUX_HELMRELEASE_API_VERSION),
22854 (
22855 "FLUX_KUSTOMIZATION_API_VERSION",
22856 FLUX_KUSTOMIZATION_API_VERSION,
22857 ),
22858 ] {
22859 let group = v
22860 .split('/')
22861 .next()
22862 .expect("Flux v2 CRD apiVersion has a group segment");
22863 assert!(
22864 group.ends_with(ROOT),
22865 "{name} group {group:?} must end with the canonical Flux v2 \
22866 `{ROOT}` root every controller in the source/helm/kustomize \
22867 triplet shares"
22868 );
22869 }
22870 }
22871
22872 #[test]
22873 fn flux_kind_git_repository_pins_canonical_value() {
22874 // Pin the actual string so a typo in this lift can't silently
22875 // rebrand the Flux v2 `GitRepository` CRD `kind` discriminator
22876 // the rendered Flux bundle's three `GitRepository`-naming axes
22877 // declare (gitrepository.yaml top-level kind, helmrelease.yaml
22878 // spec.chart.spec.sourceRef.kind, kustomization.yaml
22879 // spec.sourceRef.kind). The string is part of the cluster-side
22880 // contract with the Flux v2 `source-controller` — the
22881 // apiserver-side CRD resolution contract is the
22882 // `(apiVersion, kind)` tuple keyed against the registered
22883 // `CustomResourceDefinition`, so the kind half of the tuple is
22884 // exactly as load-bearing as the sibling
22885 // [`FLUX_GITREPOSITORY_API_VERSION`] apiVersion half. A drifted
22886 // value (e.g. an upstream Flux v3 rename to `GitSource`) lands
22887 // the rendered documents outside the source-controller's CRD
22888 // registration; changing it is a coordinated Flux v3 migration
22889 // alongside the upstream `source-controller` deprecation cycle,
22890 // not an incidental edit. Peer to
22891 // `flux_gitrepository_api_version_pins_canonical_value` on the
22892 // sibling apiVersion half of the same CRD-lookup tuple.
22893 assert_eq!(FLUX_KIND_GIT_REPOSITORY, "GitRepository");
22894 }
22895
22896 #[test]
22897 fn flux_kind_git_repository_carries_upper_camel_case_shape() {
22898 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
22899 // an UpperCamelCase identifier per the K8s API conventions
22900 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
22901 // "Kinds are always UpperCamelCase"). Pinning the shape here
22902 // means a future rebrand on the canonical lift can't silently
22903 // land a malformed kind discriminator (snake_case, kebab-case,
22904 // lowercase, empty) that every downstream YAML-aware
22905 // deserializer would reject far from the rebrand commit's
22906 // source. The first-byte uppercase / rest-ASCII-alphanumeric
22907 // invariant is the load-bearing K8s API typed-discovery
22908 // contract: a value the apiserver's `RESTMapper` consults to
22909 // resolve the CRD's `RESTKind`. Peer to
22910 // `flux_gitrepository_api_version_carries_group_and_version_segments`
22911 // on the sibling apiVersion half of the same CRD-lookup tuple.
22912 let v = FLUX_KIND_GIT_REPOSITORY;
22913 assert!(
22914 !v.is_empty(),
22915 "FLUX_KIND_GIT_REPOSITORY {v:?} must be non-empty per the K8s API \
22916 UpperCamelCase kind discriminator grammar"
22917 );
22918 let first = v.chars().next().expect("non-empty");
22919 assert!(
22920 first.is_ascii_uppercase(),
22921 "FLUX_KIND_GIT_REPOSITORY {v:?} first byte {first:?} must be \
22922 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
22923 grammar (Kinds are always UpperCamelCase)"
22924 );
22925 assert!(
22926 v.chars().all(|c| c.is_ascii_alphanumeric()),
22927 "FLUX_KIND_GIT_REPOSITORY {v:?} must be ASCII-alphanumeric \
22928 throughout per the K8s API kind discriminator grammar — no \
22929 snake_case, kebab-case, or whitespace bytes the apiserver-side \
22930 RESTMapper would reject"
22931 );
22932 }
22933
22934 #[test]
22935 fn flux_kind_helm_release_pins_canonical_value() {
22936 // Pin the actual string so a typo in this lift can't silently
22937 // rebrand the Flux v2 `HelmRelease` CRD `kind` discriminator
22938 // the rendered Flux bundle's two `HelmRelease`-naming axes
22939 // declare (helmrelease.yaml top-level kind, kustomization.yaml
22940 // spec.healthChecks[].kind). The string is part of the
22941 // cluster-side contract with the Flux v2 `helm-controller` —
22942 // the apiserver-side CRD resolution contract is the
22943 // `(apiVersion, kind)` tuple keyed against the registered
22944 // `CustomResourceDefinition`, so the kind half of the tuple is
22945 // exactly as load-bearing as the sibling
22946 // [`FLUX_HELMRELEASE_API_VERSION`] apiVersion half. A drifted
22947 // value (e.g. an upstream Flux v3 rename to `ChartRelease`)
22948 // lands the rendered documents outside the helm-controller's
22949 // CRD registration; changing it is a coordinated Flux v3
22950 // migration alongside the upstream `helm-controller`
22951 // deprecation cycle, not an incidental edit. Peer to
22952 // `flux_kind_git_repository_pins_canonical_value` on the
22953 // sibling Flux v2 source-controller CRD-`kind` axis.
22954 assert_eq!(FLUX_KIND_HELM_RELEASE, "HelmRelease");
22955 }
22956
22957 #[test]
22958 fn flux_kind_helm_release_carries_upper_camel_case_shape() {
22959 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
22960 // an UpperCamelCase identifier per the K8s API conventions
22961 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
22962 // "Kinds are always UpperCamelCase"). Pinning the shape here
22963 // means a future rebrand on the canonical lift can't silently
22964 // land a malformed kind discriminator (snake_case, kebab-case,
22965 // lowercase, empty) that every downstream YAML-aware
22966 // deserializer would reject far from the rebrand commit's
22967 // source. The first-byte uppercase / rest-ASCII-alphanumeric
22968 // invariant is the load-bearing K8s API typed-discovery
22969 // contract: a value the apiserver's `RESTMapper` consults to
22970 // resolve the CRD's `RESTKind`. Peer to
22971 // `flux_kind_git_repository_carries_upper_camel_case_shape`
22972 // on the sibling Flux v2 source-controller CRD-`kind` axis.
22973 let v = FLUX_KIND_HELM_RELEASE;
22974 assert!(
22975 !v.is_empty(),
22976 "FLUX_KIND_HELM_RELEASE {v:?} must be non-empty per the K8s API \
22977 UpperCamelCase kind discriminator grammar"
22978 );
22979 let first = v.chars().next().expect("non-empty");
22980 assert!(
22981 first.is_ascii_uppercase(),
22982 "FLUX_KIND_HELM_RELEASE {v:?} first byte {first:?} must be \
22983 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
22984 grammar (Kinds are always UpperCamelCase)"
22985 );
22986 assert!(
22987 v.chars().all(|c| c.is_ascii_alphanumeric()),
22988 "FLUX_KIND_HELM_RELEASE {v:?} must be ASCII-alphanumeric \
22989 throughout per the K8s API kind discriminator grammar — no \
22990 snake_case, kebab-case, or whitespace bytes the apiserver-side \
22991 RESTMapper would reject"
22992 );
22993 }
22994
22995 #[test]
22996 fn flux_kind_kustomization_pins_canonical_value() {
22997 // Pin the actual string so a typo in this lift can't silently
22998 // rebrand the Flux v2 `Kustomization` CRD `kind` discriminator
22999 // the rendered `kustomization.yaml`'s top-level `kind` axis
23000 // declares. The string is part of the cluster-side contract
23001 // with the Flux v2 `kustomize-controller` — the apiserver-side
23002 // CRD resolution contract is the `(apiVersion, kind)` tuple
23003 // keyed against the registered `CustomResourceDefinition`, so
23004 // the kind half of the tuple is exactly as load-bearing as the
23005 // sibling [`FLUX_KUSTOMIZATION_API_VERSION`] apiVersion half. A
23006 // drifted value (e.g. an upstream Flux v3 rename to
23007 // `KustomizationSet`) lands the rendered document outside the
23008 // kustomize-controller's CRD registration; changing it is a
23009 // coordinated Flux v3 migration alongside the upstream
23010 // `kustomize-controller` deprecation cycle, not an incidental
23011 // edit. Peer to
23012 // `flux_kind_git_repository_pins_canonical_value` /
23013 // `flux_kind_helm_release_pins_canonical_value` on the sibling
23014 // Flux v2 controller-triplet `kind`-axis surface — completes
23015 // the canonical-Flux-v2-CRD-kind-discriminator pin set across
23016 // the source-controller + helm-controller + kustomize-controller
23017 // triplet.
23018 assert_eq!(FLUX_KIND_KUSTOMIZATION, "Kustomization");
23019 }
23020
23021 #[test]
23022 fn flux_key_source_ref_pins_canonical_value() {
23023 // Pin the actual string so a typo in this lift can't silently
23024 // rebrand the Flux v2 per-`HelmRelease`/`Kustomization`
23025 // source-reference container-axis key the rendered
23026 // `helmrelease.yaml` (`spec.chart.spec.sourceRef`) +
23027 // `kustomization.yaml` (`spec.sourceRef`) documents mount the
23028 // per-CR `(kind, name, namespace)` reference triple under. The
23029 // string is part of the cluster-side contract with every
23030 // Flux-v2-conformant source-controller — the per-CR reconcile
23031 // loop keys off this exact container axis to source the
23032 // `(kind, name, namespace)` reference triple; a drifted value
23033 // (`"source_ref"` / `"source"` / `"sourceReference"` /
23034 // `"gitSourceRef"`) silently dangles both the HelmRelease's
23035 // chart resolution + the parent Kustomization's source
23036 // resolution at the Flux v2 source-controller's CRD
23037 // registration. Changing this value is a coordinated Flux v3
23038 // migration alongside the upstream `fluxcd/flux2` deprecation
23039 // cycle, not an incidental edit. Peer to
23040 // `flux_kind_git_repository_pins_canonical_value` /
23041 // `flux_kind_helm_release_pins_canonical_value` /
23042 // `flux_kind_kustomization_pins_canonical_value` on the sibling
23043 // per-CRD `kind`-axis surface — extends the canonical-Flux-v2-
23044 // load-bearing-string pin discipline from the per-CRD kind
23045 // discriminators onto the sibling per-CR source-reference
23046 // container-axis key both `cluster_bundle` renderers consume.
23047 assert_eq!(FLUX_KEY_SOURCE_REF, "sourceRef");
23048 }
23049
23050 #[test]
23051 fn flux_key_source_ref_carries_lower_camel_case_shape() {
23052 // Cross-axis invariant: the Flux v2 CRD field-naming convention
23053 // (inherited from the upstream K8s API conventions) admits
23054 // lowerCamelCase per-field keys — the source-reference
23055 // container-axis conforms to this on the leading-lowercase
23056 // `sourceRef` shape. Pinning the shape here means a future
23057 // rebrand on the canonical lift can't silently land a malformed
23058 // container-axis key (snake_case, kebab-case, UpperCamelCase,
23059 // empty) that the Flux v2 source-controller's per-CR reconcile
23060 // loop would reject at apply parse time far from the rebrand
23061 // commit's source. Peer to the sibling K8s-CR-lowerCamelCase-
23062 // per-field pin trajectory the sibling `KUBE_KEY_MATCH_LABELS`
23063 // / `GATEWAY_API_KEY_BACKEND_REFS` / `CILIUM_KEY_FROM_ENDPOINTS`
23064 // / `CILIUM_KEY_TO_PORTS` pins established on the sibling per-
23065 // K8s-CR-schema-field-name axes.
23066 let v = FLUX_KEY_SOURCE_REF;
23067 assert!(
23068 !v.is_empty(),
23069 "FLUX_KEY_SOURCE_REF {v:?} must be non-empty per the Flux v2 \
23070 CRD field-naming grammar"
23071 );
23072 let mut chars = v.chars();
23073 assert!(
23074 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23075 "FLUX_KEY_SOURCE_REF {v:?} must lead with an ASCII-lowercase \
23076 byte per the Flux v2 lowerCamelCase per-CR-field-key convention"
23077 );
23078 assert!(
23079 v.chars().all(|c| c.is_ascii_alphanumeric()),
23080 "FLUX_KEY_SOURCE_REF {v:?} must be ASCII-alphanumeric throughout \
23081 per the Flux v2 lowerCamelCase per-CR-field-key convention — \
23082 no `_` / `-` / `.` / whitespace bytes the Flux v2 source-\
23083 controller's per-CR reconcile loop would reject"
23084 );
23085 }
23086
23087 #[test]
23088 fn flux_key_values_pins_canonical_value() {
23089 // Pin the actual string so a typo in this lift can't silently
23090 // rebrand the Flux v2 per-`HelmRelease` values-override block-
23091 // body-axis key the rendered `helmrelease.yaml`'s `spec.values`
23092 // block declares. The string is part of the cluster-side
23093 // contract with the Flux v2 `helm-controller` — the per-CR
23094 // reconcile loop merges the per-cluster override YAML nested
23095 // under this exact block-body axis into the referenced chart's
23096 // `values.yaml` at Helm-render time; a drifted value
23097 // (`"Values"` / `"vals"` / `"chartValues"` / `"overrides"`)
23098 // silently routes the per-cluster overrides nowhere at Helm
23099 // render, and the workload comes up with the referenced
23100 // chart's admission-time defaults. Changing this value is a
23101 // coordinated Flux v3 migration alongside the upstream
23102 // `fluxcd/flux2` deprecation cycle, not an incidental edit.
23103 // Peer to `flux_key_source_ref_pins_canonical_value` on the
23104 // sibling Flux v2 per-CR container-axis-key surface — extends
23105 // the canonical-Flux-v2-load-bearing-string pin discipline from
23106 // the per-CR source-reference container-axis onto the sibling
23107 // per-`HelmRelease` values-override block-body-axis.
23108 assert_eq!(FLUX_KEY_VALUES, "values");
23109 }
23110
23111 #[test]
23112 fn flux_key_values_carries_lower_camel_case_shape() {
23113 // Cross-axis invariant: the Flux v2 CRD field-naming convention
23114 // (inherited from the upstream K8s API conventions) admits
23115 // lowerCamelCase per-field keys — the values-override block-
23116 // body axis conforms to this on the leading-lowercase `values`
23117 // shape (a single-word lowerCamelCase reduces to all-lowercase).
23118 // Pinning the shape here means a future rebrand on the
23119 // canonical lift can't silently land a malformed block-body-
23120 // axis key (snake_case, kebab-case, UpperCamelCase, empty) that
23121 // the Flux v2 helm-controller's per-CR reconcile loop would
23122 // reject at apply parse time far from the rebrand commit's
23123 // source. Peer to `flux_key_source_ref_carries_lower_camel_case_shape`
23124 // on the sibling Flux v2 per-CR container-axis-key surface.
23125 let v = FLUX_KEY_VALUES;
23126 assert!(
23127 !v.is_empty(),
23128 "FLUX_KEY_VALUES {v:?} must be non-empty per the Flux v2 \
23129 CRD field-naming grammar"
23130 );
23131 let mut chars = v.chars();
23132 assert!(
23133 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23134 "FLUX_KEY_VALUES {v:?} must lead with an ASCII-lowercase \
23135 byte per the Flux v2 lowerCamelCase per-CR-field-key convention"
23136 );
23137 assert!(
23138 v.chars().all(|c| c.is_ascii_alphanumeric()),
23139 "FLUX_KEY_VALUES {v:?} must be ASCII-alphanumeric throughout \
23140 per the Flux v2 lowerCamelCase per-CR-field-key convention — \
23141 no `_` / `-` / `.` / whitespace bytes the Flux v2 helm-\
23142 controller's per-CR reconcile loop would reject"
23143 );
23144 }
23145
23146 #[test]
23147 fn flux_key_chart_pins_canonical_value() {
23148 // Pin the actual string so a typo in this lift can't silently
23149 // rebrand the Flux v2 per-`HelmRelease` inline-chart-template
23150 // container-axis key the rendered `helmrelease.yaml`'s
23151 // `spec.chart` block declares. The string is part of the
23152 // cluster-side contract with the Flux v2 `helm-controller` —
23153 // the per-CR reconcile loop reads the nested
23154 // `HelmChartTemplate` sub-document (chart-name string,
23155 // source-of-truth reference triple, and reconcile cadence)
23156 // under this exact container axis to source the referenced
23157 // chart at Helm-render time; a drifted value (`"Chart"` /
23158 // `"chartTemplate"` / `"helmChart"` / `"chartRef"`) silently
23159 // dangles the whole chart-template resolution at the helm-
23160 // controller's CRD registration and the referenced chart
23161 // never resolves. Changing this value is a coordinated Flux
23162 // v3 migration alongside the upstream `fluxcd/flux2`
23163 // deprecation cycle, not an incidental edit. Peer to
23164 // `flux_key_source_ref_pins_canonical_value` /
23165 // `flux_key_values_pins_canonical_value` on the sibling Flux
23166 // v2 per-`HelmRelease` body-key surfaces — extends the
23167 // canonical-Flux-v2-load-bearing-string pin discipline from
23168 // the source-reference container-axis + values-override
23169 // block-body-axis onto the sibling chart-template container-
23170 // axis, completing the triplet of Flux v2 per-`HelmRelease`
23171 // `spec.*` body-key pin tests.
23172 assert_eq!(FLUX_KEY_CHART, "chart");
23173 }
23174
23175 #[test]
23176 fn flux_key_chart_carries_lower_camel_case_shape() {
23177 // Cross-axis invariant: the Flux v2 CRD field-naming
23178 // convention (inherited from the upstream K8s API
23179 // conventions) admits lowerCamelCase per-field keys — the
23180 // chart-template container-axis conforms to this on the
23181 // leading-lowercase `chart` shape (a single-word
23182 // lowerCamelCase reduces to all-lowercase). Pinning the shape
23183 // here means a future rebrand on the canonical lift can't
23184 // silently land a malformed container-axis key (snake_case,
23185 // kebab-case, UpperCamelCase, empty) that the Flux v2 helm-
23186 // controller's per-CR reconcile loop would reject at apply
23187 // parse time far from the rebrand commit's source. Peer to
23188 // `flux_key_source_ref_carries_lower_camel_case_shape` /
23189 // `flux_key_values_carries_lower_camel_case_shape` on the
23190 // sibling Flux v2 per-`HelmRelease` body-key surfaces.
23191 let v = FLUX_KEY_CHART;
23192 assert!(
23193 !v.is_empty(),
23194 "FLUX_KEY_CHART {v:?} must be non-empty per the Flux v2 \
23195 CRD field-naming grammar"
23196 );
23197 let mut chars = v.chars();
23198 assert!(
23199 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23200 "FLUX_KEY_CHART {v:?} must lead with an ASCII-lowercase \
23201 byte per the Flux v2 lowerCamelCase per-CR-field-key convention"
23202 );
23203 assert!(
23204 v.chars().all(|c| c.is_ascii_alphanumeric()),
23205 "FLUX_KEY_CHART {v:?} must be ASCII-alphanumeric throughout \
23206 per the Flux v2 lowerCamelCase per-CR-field-key convention — \
23207 no `_` / `-` / `.` / whitespace bytes the Flux v2 helm-\
23208 controller's per-CR reconcile loop would reject"
23209 );
23210 }
23211
23212 #[test]
23213 fn flux_helmchart_template_key_chart_pins_canonical_value() {
23214 // Pin the actual string so a typo in this lift can't silently
23215 // rebrand the Flux v2 `HelmChartTemplate.spec.chart` per-CR
23216 // chart-NAME reference leaf-scalar-axis key every caixa-flux-
23217 // emitted `HelmRelease` document nests inside the parent
23218 // `spec.chart.spec` sub-document. The helm-controller's
23219 // reconcile pipeline reads the chart-artifact name from this
23220 // exact leaf on every reconcile — a drifted `spec.chart.spec.Chart`
23221 // / `spec.chart.spec.chartRef` / `spec.chart.spec.chartName`
23222 // at the emission-side leaf key would silently land as a well-
23223 // formed but ignored `HelmChartTemplate.spec.*` extra property
23224 // the apiserver's CRD OpenAPI schema permits (arbitrary spec
23225 // extras) and the helm-controller would fail to resolve any
23226 // chart-artifact through the sibling `sourceRef` triple's
23227 // source at reconcile time — a non-self-locating "chart
23228 // 'unknown' not found in <source>" error far from the rebrand
23229 // commit's source `caixa.lisp` / the renderer's format-string
23230 // template. Peer to `flux_key_chart_pins_canonical_value` on
23231 // the sibling per-CR chart-template container-axis parent
23232 // this leaf-scalar-axis lift extends by descending one level
23233 // beneath, closing the substrate-side declaration the parent
23234 // container-axis lift docstring explicitly named as future
23235 // work.
23236 assert_eq!(FLUX_HELMCHART_TEMPLATE_KEY_CHART, "chart");
23237 }
23238
23239 #[test]
23240 fn flux_helmchart_template_key_chart_carries_lower_camel_case_shape() {
23241 // Cross-axis invariant: the Flux v2 CRD field-naming
23242 // convention (inherited from the upstream K8s API conventions)
23243 // admits lowerCamelCase per-field keys — the per-`HelmChartTemplate`
23244 // chart-NAME reference leaf-scalar-axis conforms to this on the
23245 // leading-lowercase `chart` shape (a single-word lowerCamelCase
23246 // reduces to all-lowercase). Pinning the shape here means a
23247 // future rebrand on the canonical lift can't silently land a
23248 // malformed leaf-scalar-axis key (snake_case, kebab-case,
23249 // UpperCamelCase, empty) that the Flux v2 helm-controller's
23250 // per-CR reconcile loop would reject at apply parse time far
23251 // from the rebrand commit's source. Peer to
23252 // `flux_key_chart_carries_lower_camel_case_shape` on the
23253 // sibling per-CR chart-template container-axis parent, and to
23254 // the deliberate axis-independence discipline the sibling
23255 // [`CILIUM_KEY_PATH`] / [`GATEWAY_API_KEY_PATH`] two-CRD-
23256 // groups-sharing-a-string re-exports established (two consts
23257 // spelling the same underlying string at distinct schema
23258 // axes stay sibling constants at the rustc symbol-name axis).
23259 let v = FLUX_HELMCHART_TEMPLATE_KEY_CHART;
23260 assert!(
23261 !v.is_empty(),
23262 "FLUX_HELMCHART_TEMPLATE_KEY_CHART {v:?} must be non-empty per \
23263 the Flux v2 CRD field-naming grammar"
23264 );
23265 let mut chars = v.chars();
23266 assert!(
23267 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23268 "FLUX_HELMCHART_TEMPLATE_KEY_CHART {v:?} must lead with an \
23269 ASCII-lowercase byte per the Flux v2 lowerCamelCase per-CR-\
23270 field-key convention"
23271 );
23272 assert!(
23273 v.chars().all(|c| c.is_ascii_alphanumeric()),
23274 "FLUX_HELMCHART_TEMPLATE_KEY_CHART {v:?} must be ASCII-\
23275 alphanumeric throughout per the Flux v2 lowerCamelCase per-CR-\
23276 field-key convention — no `_` / `-` / `.` / whitespace bytes \
23277 the Flux v2 helm-controller's per-CR reconcile loop would reject"
23278 );
23279 }
23280
23281 #[test]
23282 fn flux_helmchart_template_key_chart_and_flux_key_chart_stay_independent_axes() {
23283 // Cross-axis independence pin: both `FLUX_HELMCHART_TEMPLATE_KEY_CHART`
23284 // (`spec.chart.spec.chart` chart-NAME reference leaf-scalar-axis)
23285 // and the sibling `FLUX_KEY_CHART` (`spec.chart` per-CR chart-
23286 // template container-axis parent) spell the same underlying
23287 // `"chart"` string today but name distinct schema axes on the
23288 // same Flux v2 `HelmRelease` CRD group (a container-axis parent
23289 // vs a leaf-scalar grandchild inside it). Pin byte-equality of
23290 // each half against its own canonical declaration so a future
23291 // Flux v3 rebrand on either axis lands independently at the
23292 // rustc symbol-name axis rather than coalescing onto one
23293 // canonical declaration through a shared `&'static str`
23294 // allocation Rust's string interner would otherwise fuse.
23295 // Same axis-independence discipline the sibling
23296 // [`CILIUM_KEY_PATH`] (ef6114f) / [`GATEWAY_API_KEY_PATH`]
23297 // (9f45aa4) two-CRD-groups-sharing-a-string re-exports
23298 // established on the peer canonical-axis-independence surface.
23299 assert_eq!(FLUX_HELMCHART_TEMPLATE_KEY_CHART, "chart");
23300 assert_eq!(FLUX_KEY_CHART, "chart");
23301 assert_eq!(FLUX_HELMCHART_TEMPLATE_KEY_CHART, FLUX_KEY_CHART);
23302 }
23303
23304 #[test]
23305 fn flux_key_health_checks_pins_canonical_value() {
23306 // Pin the actual string so a typo in this lift can't silently
23307 // rebrand the Flux v2 per-`Kustomization` health-gate reference-
23308 // list container-axis key the rendered `kustomization.yaml`'s
23309 // `spec.healthChecks` block declares. The string is part of the
23310 // cluster-side contract with the Flux v2 `kustomize-controller`
23311 // — the per-CR reconcile loop reads the nested
23312 // `[]NamespacedObjectKindReference` list under this exact
23313 // container axis to gate the parent `Kustomization`'s
23314 // `Ready=True` transition on the referenced sibling
23315 // `HelmRelease` reaching its `HelmReleaseReady=True` condition;
23316 // a drifted value (`"HealthChecks"` / `"healthchecks"` /
23317 // `"healthcheck"` / `"health_checks"` / `"probes"`) silently
23318 // dangles the parent `Kustomization` at `Reconciling` forever
23319 // at the kustomize-controller's health-gate evaluation, and the
23320 // dependent per-cluster fleet-programs upsert chain never sees
23321 // `Ready=True`. Changing this value is a coordinated Flux v3
23322 // migration alongside the upstream `fluxcd/flux2` deprecation
23323 // cycle, not an incidental edit. Peer to
23324 // `flux_key_source_ref_pins_canonical_value` /
23325 // `flux_key_chart_pins_canonical_value` /
23326 // `flux_key_values_pins_canonical_value` on the sibling Flux v2
23327 // body-key surfaces — extends the canonical-Flux-v2-load-bearing-
23328 // string pin discipline from the per-`HelmRelease` triplet
23329 // (`spec.chart` + `spec.chart.spec.sourceRef` + `spec.values`)
23330 // onto the sibling per-`Kustomization` `spec.healthChecks`
23331 // reference-list container-axis, completing the quartet of Flux
23332 // v2 `spec.*` body-key pin tests.
23333 assert_eq!(FLUX_KEY_HEALTH_CHECKS, "healthChecks");
23334 }
23335
23336 #[test]
23337 fn flux_key_health_checks_carries_lower_camel_case_shape() {
23338 // Cross-axis invariant: the Flux v2 CRD field-naming convention
23339 // (inherited from the upstream K8s API conventions) admits
23340 // lowerCamelCase per-field keys — the per-`Kustomization`
23341 // health-gate reference-list container-axis conforms to this on
23342 // the leading-lowercase `healthChecks` shape. Pinning the shape
23343 // here means a future rebrand on the canonical lift can't
23344 // silently land a malformed container-axis key (snake_case,
23345 // kebab-case, UpperCamelCase, empty) that the Flux v2 kustomize-
23346 // controller's per-CR reconcile loop would reject at apply
23347 // parse time far from the rebrand commit's source. Peer to
23348 // `flux_key_source_ref_carries_lower_camel_case_shape` /
23349 // `flux_key_chart_carries_lower_camel_case_shape` /
23350 // `flux_key_values_carries_lower_camel_case_shape` on the
23351 // sibling Flux v2 body-key surfaces.
23352 let v = FLUX_KEY_HEALTH_CHECKS;
23353 assert!(
23354 !v.is_empty(),
23355 "FLUX_KEY_HEALTH_CHECKS {v:?} must be non-empty per the Flux \
23356 v2 CRD field-naming grammar"
23357 );
23358 let mut chars = v.chars();
23359 assert!(
23360 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23361 "FLUX_KEY_HEALTH_CHECKS {v:?} must lead with an ASCII-\
23362 lowercase byte per the Flux v2 lowerCamelCase per-CR-field-\
23363 key convention"
23364 );
23365 assert!(
23366 v.chars().all(|c| c.is_ascii_alphanumeric()),
23367 "FLUX_KEY_HEALTH_CHECKS {v:?} must be ASCII-alphanumeric \
23368 throughout per the Flux v2 lowerCamelCase per-CR-field-key \
23369 convention — no `_` / `-` / `.` / whitespace bytes the Flux \
23370 v2 kustomize-controller's per-CR reconcile loop would reject"
23371 );
23372 }
23373
23374 #[test]
23375 fn flux_key_interval_pins_canonical_value() {
23376 // Pin the actual string so a typo in this lift can't silently
23377 // rebrand the Flux v2 per-CR reconcile-poll cadence scalar-axis
23378 // key the rendered Flux bundle's three `spec.interval` scalars
23379 // declare — the shared axis-key the source-controller, helm-
23380 // controller, and kustomize-controller each read to schedule
23381 // their per-CR poll cycles off the sibling per-CR `apiVersion` +
23382 // `kind` registration. A drifted value (`"Interval"` / `"period"`
23383 // / `"cadence"` / `"pollInterval"` / `"reconcileInterval"`)
23384 // silently drops the per-CR reconcile schedule from all three
23385 // Flux controllers' per-CR watch registrations simultaneously —
23386 // the referenced Git source never re-polls / the referenced
23387 // chart never re-templates / the parent Kustomization never
23388 // re-applies at upstream drift, freezing the whole cluster's
23389 // per-`caixa` per-cluster bundle at the last-applied snapshot.
23390 // Changing this value is a coordinated Flux v3 migration
23391 // alongside the upstream `fluxcd/flux2` deprecation cycle, not
23392 // an incidental edit. Peer to
23393 // `flux_key_source_ref_pins_canonical_value` /
23394 // `flux_key_chart_pins_canonical_value` /
23395 // `flux_key_values_pins_canonical_value` /
23396 // `flux_key_health_checks_pins_canonical_value` on the sibling
23397 // Flux v2 per-CR body-key surfaces — extends the canonical-Flux-
23398 // v2-load-bearing-string pin discipline from the per-CR body-key
23399 // quartet onto the sibling cross-CR-shared reconcile-poll
23400 // cadence scalar-axis every Flux v2 controller reads.
23401 assert_eq!(FLUX_KEY_INTERVAL, "interval");
23402 }
23403
23404 #[test]
23405 fn flux_key_interval_carries_lower_camel_case_shape() {
23406 // Cross-axis invariant: the Flux v2 CRD field-naming convention
23407 // (inherited from the upstream K8s API conventions) admits
23408 // lowerCamelCase per-field keys — the per-CR reconcile-poll
23409 // cadence scalar-axis conforms to this on the leading-lowercase
23410 // `interval` shape. Pinning the shape here means a future rebrand
23411 // on the canonical lift can't silently land a malformed scalar-
23412 // axis key (snake_case, kebab-case, UpperCamelCase, empty) that
23413 // any of the three Flux v2 controllers' per-CR reconcile loops
23414 // would reject at apply parse time far from the rebrand commit's
23415 // source. Peer to `flux_key_source_ref_carries_lower_camel_case_shape`
23416 // / `flux_key_chart_carries_lower_camel_case_shape` /
23417 // `flux_key_values_carries_lower_camel_case_shape` /
23418 // `flux_key_health_checks_carries_lower_camel_case_shape` on the
23419 // sibling Flux v2 per-CR body-key surfaces.
23420 let v = FLUX_KEY_INTERVAL;
23421 assert!(
23422 !v.is_empty(),
23423 "FLUX_KEY_INTERVAL {v:?} must be non-empty per the Flux \
23424 v2 CRD field-naming grammar"
23425 );
23426 let mut chars = v.chars();
23427 assert!(
23428 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23429 "FLUX_KEY_INTERVAL {v:?} must lead with an ASCII-\
23430 lowercase byte per the Flux v2 lowerCamelCase per-CR-field-\
23431 key convention"
23432 );
23433 assert!(
23434 v.chars().all(|c| c.is_ascii_alphanumeric()),
23435 "FLUX_KEY_INTERVAL {v:?} must be ASCII-alphanumeric \
23436 throughout per the Flux v2 lowerCamelCase per-CR-field-key \
23437 convention — no `_` / `-` / `.` / whitespace bytes any of \
23438 the three Flux v2 controllers' per-CR reconcile loops would \
23439 reject"
23440 );
23441 }
23442
23443 #[test]
23444 fn flux_gitrepository_ref_key_tag_pins_canonical_value() {
23445 // Pin the actual string so a typo in this lift can't silently
23446 // rebrand the Flux v2 per-`GitRepository` `spec.ref.tag`
23447 // git-tag-selector scalar-axis key the rendered
23448 // `gitrepository.yaml` document declares on the tag-arm of the
23449 // FluxCD source-controller `spec.ref` discriminated-union axis.
23450 // A drifted value (`"Tag"` / `"gitTag"` / `"tagName"`) silently
23451 // dangles the tag-arm sub-block at the FluxCD source-controller's
23452 // CRD registration; the per-Servico clone never resolves at
23453 // reconcile time. Peer to
23454 // `flux_gitrepository_ref_key_branch_pins_canonical_value` /
23455 // `flux_gitrepository_ref_key_commit_pins_canonical_value` on
23456 // the sibling per-shape arms of the same discriminated-union
23457 // axis — closes the three-arm sub-selector-key trio the
23458 // FluxCD source-controller reads to bind the per-CR git-source
23459 // clone refspec.
23460 assert_eq!(FLUX_GITREPOSITORY_REF_KEY_TAG, "tag");
23461 }
23462
23463 #[test]
23464 fn flux_gitrepository_ref_key_branch_pins_canonical_value() {
23465 // Peer of `flux_gitrepository_ref_key_tag_pins_canonical_value`
23466 // on the branch-arm of the FluxCD source-controller
23467 // `GitRepository.spec.ref` discriminated-union axis.
23468 assert_eq!(FLUX_GITREPOSITORY_REF_KEY_BRANCH, "branch");
23469 }
23470
23471 #[test]
23472 fn flux_gitrepository_ref_key_commit_pins_canonical_value() {
23473 // Peer of `flux_gitrepository_ref_key_tag_pins_canonical_value`
23474 // on the commit-arm of the FluxCD source-controller
23475 // `GitRepository.spec.ref` discriminated-union axis.
23476 assert_eq!(FLUX_GITREPOSITORY_REF_KEY_COMMIT, "commit");
23477 }
23478
23479 #[test]
23480 fn flux_gitrepository_key_ref_pins_canonical_value() {
23481 // Bridge-arm pin: [`FLUX_GITREPOSITORY_KEY_REF`] resolves to
23482 // the canonical `"ref"` byte today — the exact YAML key the
23483 // FluxCD `source-controller` reads on every rendered
23484 // `GitRepository` document's `spec.ref` container-axis to
23485 // source the per-CR git-clone refspec discriminated-union
23486 // arm (`{tag, branch, commit}`). Pin the literal here (peer
23487 // with the sibling
23488 // [`flux_gitrepository_ref_key_tag_pins_canonical_value`] /
23489 // [`flux_gitrepository_ref_key_branch_pins_canonical_value`] /
23490 // [`flux_gitrepository_ref_key_commit_pins_canonical_value`]
23491 // per-shape arm sub-selector pins on the same `spec.ref`
23492 // sub-schema) so a future Flux v3 sub-schema rebrand on the
23493 // parent container-axis surfaces here as a coordinated edit-
23494 // point at the definition site rather than a silent apply-
23495 // time split between the writer-side template composer and
23496 // the aggregator's per-CR `RESTMapper` reader.
23497 assert_eq!(FLUX_GITREPOSITORY_KEY_REF, "ref");
23498 }
23499
23500 #[test]
23501 fn flux_gitrepository_key_url_pins_canonical_value() {
23502 // Bridge-arm pin: [`FLUX_GITREPOSITORY_KEY_URL`] resolves to
23503 // the canonical `"url"` byte today — the exact YAML key the
23504 // FluxCD `source-controller` reads on every rendered
23505 // `GitRepository` document's `spec.url` leaf-scalar-axis to
23506 // source the per-CR git-remote clone target. Pin the literal
23507 // here (peer with the sibling
23508 // [`flux_gitrepository_key_ref_pins_canonical_value`] on the
23509 // per-CR `spec.ref` container-axis surface) so a future Flux
23510 // v3 sub-schema rebrand on the URL axis (e.g. an upstream
23511 // `fluxcd/flux2` rename of `spec.url` to `spec.gitUrl` /
23512 // `spec.repository`) surfaces here as a coordinated edit-
23513 // point at the definition site rather than a silent apply-
23514 // time split between the writer-side template composer and
23515 // the source-controller's per-CR `RESTMapper` reader.
23516 assert_eq!(FLUX_GITREPOSITORY_KEY_URL, "url");
23517 }
23518
23519 #[test]
23520 fn flux_gitrepository_key_url_stays_independent_of_ref_and_api_version() {
23521 // Cross-axis peer-independence pin: the per-`GitRepository`-CRD
23522 // canonical-load-bearing-string surface carries three distinct
23523 // axes on the same CRD — `apiVersion`
23524 // ([`FLUX_GITREPOSITORY_API_VERSION`], the CRD-group/version
23525 // half of the `(apiVersion, kind)` apiserver-side CRD-lookup
23526 // tuple), `spec.ref`
23527 // ([`FLUX_GITREPOSITORY_KEY_REF`], the per-CR ref-selection
23528 // container-axis), and `spec.url`
23529 // ([`FLUX_GITREPOSITORY_KEY_URL`], the per-CR remote-repo-URL
23530 // leaf-scalar-axis). These three constants spell mutually
23531 // distinct schema axes on the same Flux v2 `source-controller`
23532 // CRD; pinning distinctness here means a future rebrand on
23533 // any one axis (a Flux v3 CRD-version bump, a `spec.ref`
23534 // container-axis rename, or a `spec.url` schema promotion)
23535 // surfaces as an edit on the corresponding canonical const
23536 // alone, without silently collapsing the three axes into one
23537 // edit-point at the rustc symbol-name axis.
23538 assert_ne!(FLUX_GITREPOSITORY_KEY_URL, FLUX_GITREPOSITORY_KEY_REF);
23539 assert_ne!(FLUX_GITREPOSITORY_KEY_URL, FLUX_GITREPOSITORY_API_VERSION);
23540 }
23541
23542 #[test]
23543 fn flux_gitrepository_ref_keys_all_carry_lower_camel_case_shape() {
23544 // Cross-axis invariant on all three arms of the FluxCD
23545 // source-controller `GitRepository.spec.ref` discriminated-union
23546 // axis: the Flux v2 CRD field-naming convention (inherited from
23547 // the upstream K8s API conventions) admits lowerCamelCase
23548 // per-field keys — `tag` / `branch` / `commit` all conform.
23549 // Pinning the shape here means a future rebrand on any of the
23550 // three canonical lifts can't silently land a malformed
23551 // sub-selector key (snake_case, kebab-case, UpperCamelCase,
23552 // empty) that the Flux v2 source-controller's per-CR reconcile
23553 // loop would reject at apply parse time. Peer to
23554 // `flux_key_interval_carries_lower_camel_case_shape` on the
23555 // sibling per-CR reconcile-poll-cadence scalar-axis key surface.
23556 for v in [
23557 FLUX_GITREPOSITORY_REF_KEY_TAG,
23558 FLUX_GITREPOSITORY_REF_KEY_BRANCH,
23559 FLUX_GITREPOSITORY_REF_KEY_COMMIT,
23560 ] {
23561 assert!(
23562 !v.is_empty(),
23563 "FLUX_GITREPOSITORY_REF_KEY_* {v:?} must be non-empty \
23564 per the Flux v2 CRD field-naming grammar"
23565 );
23566 let mut chars = v.chars();
23567 assert!(
23568 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23569 "FLUX_GITREPOSITORY_REF_KEY_* {v:?} must lead with an \
23570 ASCII-lowercase byte per the Flux v2 lowerCamelCase \
23571 per-CR-field-key convention"
23572 );
23573 assert!(
23574 v.chars().all(|c| c.is_ascii_alphanumeric()),
23575 "FLUX_GITREPOSITORY_REF_KEY_* {v:?} must be ASCII-\
23576 alphanumeric throughout per the Flux v2 lowerCamelCase \
23577 per-CR-field-key convention — no `_` / `-` / `.` / \
23578 whitespace bytes the Flux v2 source-controller's per-CR \
23579 reconcile loop would reject"
23580 );
23581 }
23582 }
23583
23584 #[test]
23585 fn flux_gitrepository_ref_keys_are_pairwise_distinct() {
23586 // The three arms of the FluxCD source-controller
23587 // `GitRepository.spec.ref` discriminated-union axis must remain
23588 // pairwise distinct — a hypothetical drift that collapsed two
23589 // sub-selector keys onto the same byte-string (e.g. an
23590 // accidental copy-paste making TAG and BRANCH both spell
23591 // `"tag"`) would silently reroute the per-shape emit at
23592 // `caixa_flux::GitRefSpec::ref_field_name` dispatch time and
23593 // dangle one arm's rendered `spec.ref` sub-block at cluster-
23594 // apply time. Pin the pairwise-distinctness here so the drift
23595 // fires at test time, not at cluster-apply time far from the
23596 // drift site.
23597 let keys = [
23598 FLUX_GITREPOSITORY_REF_KEY_TAG,
23599 FLUX_GITREPOSITORY_REF_KEY_BRANCH,
23600 FLUX_GITREPOSITORY_REF_KEY_COMMIT,
23601 ];
23602 for (i, a) in keys.iter().enumerate() {
23603 for b in keys.iter().skip(i + 1) {
23604 assert_ne!(
23605 a, b,
23606 "FLUX_GITREPOSITORY_REF_KEY_* arms must be pairwise \
23607 distinct (got a duplicate: {a:?})"
23608 );
23609 }
23610 }
23611 }
23612
23613 #[test]
23614 fn flux_kind_kustomization_carries_upper_camel_case_shape() {
23615 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
23616 // an UpperCamelCase identifier per the K8s API conventions
23617 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
23618 // "Kinds are always UpperCamelCase"). Pinning the shape here
23619 // means a future rebrand on the canonical lift can't silently
23620 // land a malformed kind discriminator (snake_case, kebab-case,
23621 // lowercase, empty) that every downstream YAML-aware
23622 // deserializer would reject far from the rebrand commit's
23623 // source. The first-byte uppercase / rest-ASCII-alphanumeric
23624 // invariant is the load-bearing K8s API typed-discovery
23625 // contract: a value the apiserver's `RESTMapper` consults to
23626 // resolve the CRD's `RESTKind`. Peer to
23627 // `flux_kind_git_repository_carries_upper_camel_case_shape` /
23628 // `flux_kind_helm_release_carries_upper_camel_case_shape` on
23629 // the sibling Flux v2 controller-triplet `kind`-axis surface.
23630 let v = FLUX_KIND_KUSTOMIZATION;
23631 assert!(
23632 !v.is_empty(),
23633 "FLUX_KIND_KUSTOMIZATION {v:?} must be non-empty per the K8s API \
23634 UpperCamelCase kind discriminator grammar"
23635 );
23636 let first = v.chars().next().expect("non-empty");
23637 assert!(
23638 first.is_ascii_uppercase(),
23639 "FLUX_KIND_KUSTOMIZATION {v:?} first byte {first:?} must be \
23640 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
23641 grammar (Kinds are always UpperCamelCase)"
23642 );
23643 assert!(
23644 v.chars().all(|c| c.is_ascii_alphanumeric()),
23645 "FLUX_KIND_KUSTOMIZATION {v:?} must be ASCII-alphanumeric \
23646 throughout per the K8s API kind discriminator grammar — no \
23647 snake_case, kebab-case, or whitespace bytes the apiserver-side \
23648 RESTMapper would reject"
23649 );
23650 }
23651
23652 #[test]
23653 fn gateway_api_api_version_pins_canonical_value() {
23654 // Pin the actual string so a typo in this lift can't silently
23655 // rebrand the K8s SIG-Network Gateway API CRD group/version
23656 // the rendered `Gateway` / `HTTPRoute` documents declare. The
23657 // string is part of the cluster-side contract with the
23658 // upstream Gateway-API-conformant gateway implementation
23659 // (Cilium, Istio, Envoy Gateway, NGINX, et al.): the
23660 // apiserver-side CRD-version registration watches the exact
23661 // `gateway.networking.k8s.io/v1` group/version; a drifted
23662 // value to a stale v1beta1 / v1alpha2 lands the rendered
23663 // `Gateway` / `HTTPRoute` outside the registration and fails
23664 // at apply time with "no kind 'Gateway' is registered for
23665 // version 'gateway.networking.k8s.io/v1beta1'"; changing it
23666 // is a coordinated Gateway API GA promotion alongside the
23667 // upstream SIG-Network deprecation cycle, not an incidental
23668 // edit. Peer to `flux_kustomization_api_version_pins_canonical_value`
23669 // / `flux_helmrelease_api_version_pins_canonical_value` /
23670 // `flux_gitrepository_api_version_pins_canonical_value` on
23671 // the canonical-K8s-CRD-axis-pin axis for the sibling
23672 // Flux v2 controller-triplet constants — extends the
23673 // canonical-string-pin discipline from the cluster-side
23674 // Flux v2 reconcile contract onto the cluster-side K8s
23675 // Gateway API ingress contract.
23676 assert_eq!(GATEWAY_API_API_VERSION, "gateway.networking.k8s.io/v1");
23677 }
23678
23679 #[test]
23680 fn gateway_api_api_version_carries_group_and_version_segments() {
23681 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
23682 // `<group>/<version>` pair separated by exactly one `/` byte.
23683 // The group segment is a DNS-style multi-segment hostname
23684 // (`gateway.networking.k8s.io`) and the version segment is a
23685 // Kubernetes API version label (`v1`, `v1beta1`, `v1alpha2` —
23686 // peer with the K8s API versioning convention upstream
23687 // documents). Pinning this here means a future rebrand on the
23688 // canonical lift can't silently land a malformed apiVersion
23689 // (no `/`, two `/`, empty group, empty version) that every
23690 // downstream YAML-aware deserializer would reject far from the
23691 // rebrand commit's source. The single-`/` invariant is the
23692 // load-bearing K8s API typed-discovery contract: a value the
23693 // apiserver's `RESTMapper` consults to resolve the CRD's
23694 // `RESTKind`. Peer to
23695 // `flux_kustomization_api_version_carries_group_and_version_segments`
23696 // / `flux_helmrelease_api_version_carries_group_and_version_segments`
23697 // / `flux_gitrepository_api_version_carries_group_and_version_segments`
23698 // on the sibling Flux v2 controller-triplet CRD-axes.
23699 let v = GATEWAY_API_API_VERSION;
23700 let parts: Vec<&str> = v.split('/').collect();
23701 assert_eq!(
23702 parts.len(),
23703 2,
23704 "GATEWAY_API_API_VERSION {v:?} must split into exactly two \
23705 `/`-delimited segments (group/version) per the K8s CRD apiVersion \
23706 grammar — every downstream YAML-aware deserializer enforces this \
23707 shape"
23708 );
23709 assert!(
23710 !parts[0].is_empty(),
23711 "GATEWAY_API_API_VERSION {v:?} group segment must be non-empty"
23712 );
23713 assert!(
23714 !parts[1].is_empty(),
23715 "GATEWAY_API_API_VERSION {v:?} version segment must be non-empty"
23716 );
23717 assert!(
23718 parts[0].contains('.'),
23719 "GATEWAY_API_API_VERSION {v:?} group segment {group:?} must be a \
23720 DNS-style multi-segment hostname (the canonical CRD-group convention \
23721 every K8s controller-runtime / kube-rs-aware client expects)",
23722 group = parts[0]
23723 );
23724 }
23725
23726 #[test]
23727 fn cilium_api_version_pins_canonical_value() {
23728 // Pin the actual string so a typo in this lift can't silently
23729 // rebrand the Cilium CRD group/version the rendered
23730 // `CiliumNetworkPolicy` document declares. The string is part
23731 // of the cluster-side contract with the upstream Cilium
23732 // operator: the Cilium-operator-side CRD-version registration
23733 // watches the exact `cilium.io/v2` group/version; a drifted
23734 // value to a stale `v2alpha1` lands the rendered
23735 // `CiliumNetworkPolicy` outside the registration and fails at
23736 // apply time with "no kind 'CiliumNetworkPolicy' is registered
23737 // for version 'cilium.io/v2alpha1'"; changing it is a
23738 // coordinated Cilium-CRD promotion alongside the upstream
23739 // Cilium deprecation cycle, not an incidental edit. Peer to
23740 // `gateway_api_api_version_pins_canonical_value` /
23741 // `flux_kustomization_api_version_pins_canonical_value` /
23742 // `flux_helmrelease_api_version_pins_canonical_value` /
23743 // `flux_gitrepository_api_version_pins_canonical_value` on
23744 // the canonical-K8s-CRD-axis-pin axis for the sibling
23745 // K8s Gateway API + Flux v2 controller-triplet constants —
23746 // extends the canonical-string-pin discipline from the
23747 // cluster-side K8s Gateway API ingress + Flux v2 reconcile
23748 // contracts onto the cluster-side Cilium identity-based mesh
23749 // contract.
23750 assert_eq!(CILIUM_API_VERSION, "cilium.io/v2");
23751 }
23752
23753 #[test]
23754 fn cilium_api_version_carries_group_and_version_segments() {
23755 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
23756 // `<group>/<version>` pair separated by exactly one `/` byte.
23757 // The group segment is a DNS-style hostname (`cilium.io`) and
23758 // the version segment is a Kubernetes API version label (`v2`,
23759 // `v2alpha1` — peer with the K8s API versioning convention
23760 // upstream documents). Pinning this here means a future rebrand
23761 // on the canonical lift can't silently land a malformed
23762 // apiVersion (no `/`, two `/`, empty group, empty version) that
23763 // every downstream YAML-aware deserializer would reject far
23764 // from the rebrand commit's source. The single-`/` invariant
23765 // is the load-bearing K8s API typed-discovery contract: a value
23766 // the apiserver's `RESTMapper` consults to resolve the CRD's
23767 // `RESTKind`. Peer to
23768 // `gateway_api_api_version_carries_group_and_version_segments`
23769 // / `flux_kustomization_api_version_carries_group_and_version_segments`
23770 // / `flux_helmrelease_api_version_carries_group_and_version_segments`
23771 // / `flux_gitrepository_api_version_carries_group_and_version_segments`
23772 // on the sibling K8s Gateway API + Flux v2 controller-triplet
23773 // CRD-axes.
23774 let v = CILIUM_API_VERSION;
23775 let parts: Vec<&str> = v.split('/').collect();
23776 assert_eq!(
23777 parts.len(),
23778 2,
23779 "CILIUM_API_VERSION {v:?} must split into exactly two \
23780 `/`-delimited segments (group/version) per the K8s CRD apiVersion \
23781 grammar — every downstream YAML-aware deserializer enforces this \
23782 shape"
23783 );
23784 assert!(
23785 !parts[0].is_empty(),
23786 "CILIUM_API_VERSION {v:?} group segment must be non-empty"
23787 );
23788 assert!(
23789 !parts[1].is_empty(),
23790 "CILIUM_API_VERSION {v:?} version segment must be non-empty"
23791 );
23792 assert!(
23793 parts[0].contains('.'),
23794 "CILIUM_API_VERSION {v:?} group segment {group:?} must be a \
23795 DNS-style hostname (the canonical CRD-group convention \
23796 every K8s controller-runtime / kube-rs-aware client expects)",
23797 group = parts[0]
23798 );
23799 }
23800
23801 #[test]
23802 fn cilium_kind_network_policy_pins_canonical_value() {
23803 // Pin the actual string so a typo in this lift can't silently
23804 // rebrand the Cilium-operator-side `CiliumNetworkPolicy` CRD
23805 // `kind` discriminator the rendered CNP document's top-level
23806 // `kind` axis declares. The string is part of the cluster-side
23807 // contract with the upstream Cilium operator — the apiserver-side
23808 // CRD resolution contract is the `(apiVersion, kind)` tuple
23809 // keyed against the registered `CustomResourceDefinition`, so
23810 // the kind half of the tuple is exactly as load-bearing as the
23811 // sibling [`CILIUM_API_VERSION`] apiVersion half. A drifted
23812 // value (e.g. an upstream rename to `CiliumNetworkPolicyV2`)
23813 // lands the rendered document outside the Cilium operator's
23814 // CRD registration; changing it is a coordinated Cilium-CRD
23815 // promotion alongside the upstream Cilium deprecation cycle,
23816 // not an incidental edit. Peer to
23817 // `flux_kind_kustomization_pins_canonical_value` /
23818 // `flux_kind_helm_release_pins_canonical_value` /
23819 // `flux_kind_git_repository_pins_canonical_value` on the
23820 // sibling cluster-side-CRD-`kind`-discriminator pin set —
23821 // extends the canonical-string-pin discipline from the Flux v2
23822 // controller-triplet `kind`-axis surface onto the Cilium-CRD
23823 // `kind`-axis surface, completing the per-Cilium-CRD
23824 // kind+apiVersion canonical-pin pair the M3 Aplicacao mesh
23825 // renderer's eBPF data-plane contract rests on.
23826 assert_eq!(CILIUM_KIND_NETWORK_POLICY, "CiliumNetworkPolicy");
23827 }
23828
23829 #[test]
23830 fn cilium_kind_network_policy_carries_upper_camel_case_shape() {
23831 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
23832 // an UpperCamelCase identifier per the K8s API conventions
23833 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
23834 // "Kinds are always UpperCamelCase"). Pinning the shape here
23835 // means a future rebrand on the canonical lift can't silently
23836 // land a malformed kind discriminator (snake_case, kebab-case,
23837 // lowercase, empty) that every downstream YAML-aware
23838 // deserializer would reject far from the rebrand commit's
23839 // source. The first-byte uppercase / rest-ASCII-alphanumeric
23840 // invariant is the load-bearing K8s API typed-discovery
23841 // contract: a value the apiserver's `RESTMapper` consults to
23842 // resolve the CRD's `RESTKind`. Peer to
23843 // `flux_kind_kustomization_carries_upper_camel_case_shape` /
23844 // `flux_kind_helm_release_carries_upper_camel_case_shape` /
23845 // `flux_kind_git_repository_carries_upper_camel_case_shape` on
23846 // the sibling cluster-side-CRD-`kind`-discriminator surface.
23847 let v = CILIUM_KIND_NETWORK_POLICY;
23848 assert!(
23849 !v.is_empty(),
23850 "CILIUM_KIND_NETWORK_POLICY {v:?} must be non-empty per the K8s API \
23851 UpperCamelCase kind discriminator grammar"
23852 );
23853 let first = v.chars().next().expect("non-empty");
23854 assert!(
23855 first.is_ascii_uppercase(),
23856 "CILIUM_KIND_NETWORK_POLICY {v:?} first byte {first:?} must be \
23857 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
23858 grammar (Kinds are always UpperCamelCase)"
23859 );
23860 assert!(
23861 v.chars().all(|c| c.is_ascii_alphanumeric()),
23862 "CILIUM_KIND_NETWORK_POLICY {v:?} must be ASCII-alphanumeric \
23863 throughout per the K8s API kind discriminator grammar — no \
23864 snake_case, kebab-case, or whitespace bytes the apiserver-side \
23865 RESTMapper would reject"
23866 );
23867 }
23868
23869 #[test]
23870 fn cilium_key_to_ports_pins_canonical_value() {
23871 // Pin the actual string so a typo in this lift can't silently
23872 // rebrand the Cilium CNP `spec.ingress[].toPorts[]` per-ingress-
23873 // rule port-set-container-axis key the rendered CNP document
23874 // mounts its per-port-set `{ports: […], rules: {…}}` list under.
23875 // The string is part of the cluster-side contract with the
23876 // upstream Cilium operator — the Cilium-operator-side per-CNP
23877 // L4/L7-dispatch pass keys off this axis to route the per-port
23878 // set through the eBPF data-plane's L4-allow (via `ports`) /
23879 // L7-dispatch (via nested `rules`) branches; a drifted value
23880 // (`"toport"` / `"toPort"` / `"targetPorts"`) at either the
23881 // production emitter or a downstream renderer's per-ingress-rule
23882 // port-set upsert silently emits a per-ingress-rule entry whose
23883 // port-set container the Cilium CRD schema validator drops as
23884 // unknown, and every intra-mesh `:contratos` flow the affected
23885 // CNP was authored to allow drops at the eBPF data-plane's
23886 // default-deny gate. Changing this value is a coordinated
23887 // Cilium-CRD promotion alongside the upstream Cilium project's
23888 // CRD schema-migration cycle, not an incidental edit. Peer to
23889 // `kube_key_rules_pins_canonical_value` (the nested
23890 // `spec.ingress[].toPorts[].rules` axis-key pin the L7-dispatch
23891 // container nests inside this port-set container's each entry)
23892 // on the sibling per-CNP-dispatch-axis pin set — completes the
23893 // per-CNP L4/L7-dispatch-container `(toPorts, rules)` pin pair
23894 // the M3 Aplicacao mesh renderer's eBPF data-plane contract
23895 // rests on.
23896 assert_eq!(CILIUM_KEY_TO_PORTS, "toPorts");
23897 }
23898
23899 #[test]
23900 fn cilium_key_to_ports_carries_lower_camel_case_shape() {
23901 // Cross-axis invariant: a Kubernetes CRD schema field name is a
23902 // lowerCamelCase identifier per the K8s API conventions
23903 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
23904 // "Field names should be lowercase camelCase") — first byte
23905 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
23906 // kebab-case or whitespace. Pinning the shape here means a
23907 // future rebrand on the canonical lift can't silently land a
23908 // malformed field-name discriminator (snake_case, kebab-case,
23909 // UpperCamelCase, empty) that the apiserver-side CRD schema
23910 // validator would reject far from the rebrand commit's source.
23911 // The first-byte lowercase / rest-ASCII-alphanumeric invariant
23912 // is the load-bearing K8s API typed-schema contract: a value
23913 // the apiserver-side OpenAPI schema validator consults to
23914 // resolve each CR-field's typed slot. Peer to the sibling
23915 // per-CNP `kind`-axis
23916 // `cilium_kind_network_policy_carries_upper_camel_case_shape`
23917 // pin — the UpperCamelCase K8s discriminator grammar governs
23918 // the top-level `kind` axis, the lowerCamelCase K8s field-name
23919 // grammar governs every nested schema-field axis (including
23920 // this per-ingress-rule port-set-container-axis key), same
23921 // convention distinct grammars.
23922 let v = CILIUM_KEY_TO_PORTS;
23923 assert!(
23924 !v.is_empty(),
23925 "CILIUM_KEY_TO_PORTS {v:?} must be non-empty per the K8s API \
23926 lowerCamelCase field-name grammar"
23927 );
23928 let first = v.chars().next().expect("non-empty");
23929 assert!(
23930 first.is_ascii_lowercase(),
23931 "CILIUM_KEY_TO_PORTS {v:?} first byte {first:?} must be \
23932 ASCII-lowercase per the K8s API lowerCamelCase field-name \
23933 grammar (field names are always lowerCamelCase)"
23934 );
23935 assert!(
23936 v.chars().all(|c| c.is_ascii_alphanumeric()),
23937 "CILIUM_KEY_TO_PORTS {v:?} must be ASCII-alphanumeric \
23938 throughout per the K8s API field-name grammar — no \
23939 snake_case, kebab-case, or whitespace bytes the apiserver-side \
23940 OpenAPI schema validator would reject"
23941 );
23942 }
23943
23944 #[test]
23945 fn cilium_key_endpoint_selector_pins_canonical_value() {
23946 // Pin the actual string so a typo in this lift can't silently
23947 // rebrand the Cilium CNP `spec.endpointSelector` destination-
23948 // identity-axis key the rendered CNP document mounts its
23949 // L3-target `LabelSelector` under. The string is part of the
23950 // cluster-side contract with the upstream Cilium operator —
23951 // the Cilium-operator-side per-CNP identity-resolution pass
23952 // keys off this axis to bind the emitted policy against its
23953 // destination workload identity via the K8s LabelSelector
23954 // schema; a drifted value (`"endpointselector"` /
23955 // `"endpointSelectors"` / `"endpoints"`) at either the
23956 // production emitter or a downstream renderer's per-CNP
23957 // destination-identity upsert silently emits a CNP whose
23958 // destination-identity axis the Cilium CRD schema validator
23959 // drops as unknown, and the policy binds against no
23960 // destination pods — every intra-mesh `:contratos` flow the
23961 // affected CNP was authored to allow drops at the eBPF
23962 // data-plane's default-deny gate. Changing this value is a
23963 // coordinated Cilium-CRD promotion alongside the upstream
23964 // Cilium project's CRD schema-migration cycle, not an
23965 // incidental edit. Peer to `cilium_key_to_ports_pins_\
23966 // canonical_value` (the per-ingress-rule port-set container
23967 // axis-key pin the L3-target selector pairs with under the
23968 // shared per-CNP-body schema) on the sibling per-CNP-body-axis
23969 // pin set — completes the per-CNP L3/L4/L7-triad
23970 // `(endpointSelector, ingress → toPorts → rules)` pin set the
23971 // M3 Aplicacao mesh renderer's eBPF data-plane contract rests
23972 // on.
23973 assert_eq!(CILIUM_KEY_ENDPOINT_SELECTOR, "endpointSelector");
23974 }
23975
23976 #[test]
23977 fn cilium_key_endpoint_selector_carries_lower_camel_case_shape() {
23978 // Cross-axis invariant: a Kubernetes CRD schema field name is a
23979 // lowerCamelCase identifier per the K8s API conventions
23980 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
23981 // "Field names should be lowercase camelCase") — first byte
23982 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
23983 // kebab-case or whitespace. Pinning the shape here means a
23984 // future rebrand on the canonical lift can't silently land a
23985 // malformed field-name discriminator (snake_case, kebab-case,
23986 // UpperCamelCase, empty) that the apiserver-side CRD schema
23987 // validator would reject far from the rebrand commit's source.
23988 // Peer to `cilium_key_to_ports_carries_lower_camel_case_shape`
23989 // on the sibling per-CNP-body-axis grammar-pin set — the
23990 // lowerCamelCase K8s field-name grammar governs every nested
23991 // schema-field axis (including this per-CNP destination-
23992 // identity-axis key), same convention.
23993 let v = CILIUM_KEY_ENDPOINT_SELECTOR;
23994 assert!(
23995 !v.is_empty(),
23996 "CILIUM_KEY_ENDPOINT_SELECTOR {v:?} must be non-empty per the K8s API \
23997 lowerCamelCase field-name grammar"
23998 );
23999 let first = v.chars().next().expect("non-empty");
24000 assert!(
24001 first.is_ascii_lowercase(),
24002 "CILIUM_KEY_ENDPOINT_SELECTOR {v:?} first byte {first:?} must be \
24003 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24004 grammar (field names are always lowerCamelCase)"
24005 );
24006 assert!(
24007 v.chars().all(|c| c.is_ascii_alphanumeric()),
24008 "CILIUM_KEY_ENDPOINT_SELECTOR {v:?} must be ASCII-alphanumeric \
24009 throughout per the K8s API field-name grammar — no \
24010 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24011 OpenAPI schema validator would reject"
24012 );
24013 }
24014
24015 #[test]
24016 fn cilium_key_ingress_pins_canonical_value() {
24017 // Pin the actual string so a typo in this lift can't silently
24018 // rebrand the Cilium CNP `spec.ingress[]` traffic-direction
24019 // container-axis key the rendered CNP document mounts its
24020 // permitted per-`(:de, :para)` inbound-ingress-rule list under.
24021 // The string is part of the cluster-side contract with the
24022 // upstream Cilium operator — the Cilium-operator-side per-CNP
24023 // L4/L7-dispatch pass keys off this axis to route the per-CNP
24024 // ingress-rule list through the eBPF data-plane's inbound-
24025 // traffic dispatch branch; a drifted value (`"Ingress"` /
24026 // `"ingressRules"` / `"inbound"`) at either the production
24027 // emitter or a downstream renderer's per-CNP traffic-direction
24028 // upsert silently emits a CNP whose ingress-rule list the
24029 // Cilium CRD schema validator drops as unknown, and every
24030 // intra-mesh `:contratos` flow the affected CNP was authored to
24031 // allow drops at the eBPF data-plane's default-deny gate.
24032 // Changing this value is a coordinated Cilium-CRD promotion
24033 // alongside the upstream Cilium project's CRD schema-migration
24034 // cycle, not an incidental edit. Peer to
24035 // `cilium_key_endpoint_selector_pins_canonical_value` (the
24036 // destination-identity axis-key pin the traffic-direction
24037 // container axis-key sits alongside under the shared per-CNP-
24038 // body schema) + `cilium_key_to_ports_pins_canonical_value`
24039 // (the per-ingress-rule port-set container axis-key pin the
24040 // traffic-direction axis nests) on the sibling per-CNP-body-
24041 // axis pin set — completes the per-CNP L3/L4/L7-triad
24042 // `(endpointSelector, ingress → toPorts → rules)` pin set the
24043 // M3 Aplicacao mesh renderer's eBPF data-plane contract rests
24044 // on.
24045 assert_eq!(CILIUM_KEY_INGRESS, "ingress");
24046 }
24047
24048 #[test]
24049 fn cilium_key_ingress_carries_lower_camel_case_shape() {
24050 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24051 // lowerCamelCase identifier per the K8s API conventions
24052 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24053 // "Field names should be lowercase camelCase") — first byte
24054 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24055 // kebab-case or whitespace. Pinning the shape here means a
24056 // future rebrand on the canonical lift can't silently land a
24057 // malformed field-name discriminator (snake_case, kebab-case,
24058 // UpperCamelCase, empty) that the apiserver-side CRD schema
24059 // validator would reject far from the rebrand commit's source.
24060 // Peer to `cilium_key_endpoint_selector_carries_lower_camel_\
24061 // case_shape` / `cilium_key_to_ports_carries_lower_camel_case_\
24062 // shape` on the sibling per-CNP-body-axis grammar-pin set — the
24063 // lowerCamelCase K8s field-name grammar governs every nested
24064 // schema-field axis (including this per-CNP traffic-direction-
24065 // axis key), same convention.
24066 let v = CILIUM_KEY_INGRESS;
24067 assert!(
24068 !v.is_empty(),
24069 "CILIUM_KEY_INGRESS {v:?} must be non-empty per the K8s API \
24070 lowerCamelCase field-name grammar"
24071 );
24072 let first = v.chars().next().expect("non-empty");
24073 assert!(
24074 first.is_ascii_lowercase(),
24075 "CILIUM_KEY_INGRESS {v:?} first byte {first:?} must be \
24076 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24077 grammar (field names are always lowerCamelCase)"
24078 );
24079 assert!(
24080 v.chars().all(|c| c.is_ascii_alphanumeric()),
24081 "CILIUM_KEY_INGRESS {v:?} must be ASCII-alphanumeric \
24082 throughout per the K8s API field-name grammar — no \
24083 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24084 OpenAPI schema validator would reject"
24085 );
24086 }
24087
24088 #[test]
24089 fn cilium_key_from_endpoints_pins_canonical_value() {
24090 // Pin the actual string so a typo in this lift can't silently
24091 // rebrand the Cilium CNP `spec.ingress[].fromEndpoints[]`
24092 // identity-source selector-list-axis key the rendered CNP
24093 // document mounts its permitted-source `LabelSelector` list
24094 // under. The string is part of the cluster-side contract with
24095 // the upstream Cilium operator — the Cilium-operator-side per-
24096 // CNP identity-resolution pass keys off this axis to bind the
24097 // emitted ingress rule against the admitted source workload
24098 // identities via the K8s LabelSelector schema; a drifted value
24099 // (`"fromendpoints"` / `"fromEndPoint"` / `"sourceEndpoints"`)
24100 // at either the production emitter or a downstream renderer's
24101 // per-ingress-rule identity-source upsert silently emits a CNP
24102 // whose per-ingress-rule identity-source axis the Cilium CRD
24103 // schema validator drops as unknown, and the ingress rule
24104 // admits no source pods — every intra-mesh `:contratos` flow
24105 // the affected CNP was authored to allow drops at the eBPF
24106 // data-plane's default-deny gate. Changing this value is a
24107 // coordinated Cilium-CRD promotion alongside the upstream
24108 // Cilium project's CRD schema-migration cycle, not an
24109 // incidental edit. Peer to
24110 // `cilium_key_endpoint_selector_pins_canonical_value` (the
24111 // destination-identity axis-key pin the identity-source axis
24112 // structurally pairs with under the SPIFFE-identity-bound per-
24113 // CNP access-control contract) on the sibling per-CNP identity-
24114 // pair pin set — completes the per-CNP identity-pair
24115 // `(endpointSelector, fromEndpoints)` pin set the M3 Aplicacao
24116 // mesh renderer's eBPF data-plane contract rests on.
24117 assert_eq!(CILIUM_KEY_FROM_ENDPOINTS, "fromEndpoints");
24118 }
24119
24120 #[test]
24121 fn cilium_key_from_endpoints_carries_lower_camel_case_shape() {
24122 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24123 // lowerCamelCase identifier per the K8s API conventions
24124 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24125 // "Field names should be lowercase camelCase") — first byte
24126 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24127 // kebab-case or whitespace. Pinning the shape here means a
24128 // future rebrand on the canonical lift can't silently land a
24129 // malformed field-name discriminator (snake_case, kebab-case,
24130 // UpperCamelCase, empty) that the apiserver-side CRD schema
24131 // validator would reject far from the rebrand commit's source.
24132 // Peer to `cilium_key_endpoint_selector_carries_lower_camel_\
24133 // case_shape` / `cilium_key_ingress_carries_lower_camel_case_\
24134 // shape` / `cilium_key_to_ports_carries_lower_camel_case_shape`
24135 // on the sibling per-CNP-body-axis grammar-pin set — the
24136 // lowerCamelCase K8s field-name grammar governs every nested
24137 // schema-field axis (including this per-ingress-rule identity-
24138 // source-axis key), same convention.
24139 let v = CILIUM_KEY_FROM_ENDPOINTS;
24140 assert!(
24141 !v.is_empty(),
24142 "CILIUM_KEY_FROM_ENDPOINTS {v:?} must be non-empty per the K8s API \
24143 lowerCamelCase field-name grammar"
24144 );
24145 let first = v.chars().next().expect("non-empty");
24146 assert!(
24147 first.is_ascii_lowercase(),
24148 "CILIUM_KEY_FROM_ENDPOINTS {v:?} first byte {first:?} must be \
24149 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24150 grammar (field names are always lowerCamelCase)"
24151 );
24152 assert!(
24153 v.chars().all(|c| c.is_ascii_alphanumeric()),
24154 "CILIUM_KEY_FROM_ENDPOINTS {v:?} must be ASCII-alphanumeric \
24155 throughout per the K8s API field-name grammar — no \
24156 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24157 OpenAPI schema validator would reject"
24158 );
24159 }
24160
24161 #[test]
24162 fn cilium_key_ports_pins_canonical_value() {
24163 // Pin the actual string so a typo in this lift can't silently
24164 // rebrand the Cilium CNP `spec.ingress[].toPorts[].ports[]`
24165 // per-`toPorts[]`-entry L4-port-tuple-list-container-axis key
24166 // the rendered CNP document mounts its per-port-set
24167 // `[{port, protocol}]` list under. The string is part of the
24168 // cluster-side contract with the upstream Cilium operator —
24169 // the Cilium-operator-side per-CNP L4-allow eBPF-program-
24170 // generation pass keys off this axis to source the per-port-set
24171 // `(port, protocol)` tuples the emitted ingress rule admits; a
24172 // drifted value (`"port"` / `"portList"` / `"L4Ports"`) at
24173 // either the production emitter or a downstream renderer's
24174 // per-`toPorts[]`-entry L4-port-tuple-list upsert silently
24175 // emits a per-`toPorts[]` entry whose L4-port-tuple-list-
24176 // container axis the Cilium CRD schema validator drops as
24177 // unknown, and the port-set admits no `(port, protocol)`
24178 // tuple — every intra-mesh `:contratos` flow the affected CNP
24179 // was authored to allow drops at the eBPF data-plane's
24180 // default-deny gate. Changing this value is a coordinated
24181 // Cilium-CRD promotion alongside the upstream Cilium project's
24182 // CRD schema-migration cycle, not an incidental edit. Peer to
24183 // `cilium_key_to_ports_pins_canonical_value` (the outer per-
24184 // ingress-rule port-set-container axis-key pin the L4 port-
24185 // tuple-list-container axis nests inside) on the sibling per-
24186 // CNP-dispatch-axis pin set — completes the per-CNP L4-half
24187 // `(toPorts, ports)` container-pair pin the M3 Aplicacao mesh
24188 // renderer's eBPF data-plane L4-allow contract rests on.
24189 assert_eq!(CILIUM_KEY_PORTS, "ports");
24190 }
24191
24192 #[test]
24193 fn cilium_key_ports_carries_lower_camel_case_shape() {
24194 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24195 // lowerCamelCase identifier per the K8s API conventions
24196 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24197 // "Field names should be lowercase camelCase") — first byte
24198 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24199 // kebab-case or whitespace. Pinning the shape here means a
24200 // future rebrand on the canonical lift can't silently land a
24201 // malformed field-name discriminator (snake_case, kebab-case,
24202 // UpperCamelCase, empty) that the apiserver-side CRD schema
24203 // validator would reject far from the rebrand commit's source.
24204 // Peer to `cilium_key_endpoint_selector_carries_lower_camel_\
24205 // case_shape` / `cilium_key_ingress_carries_lower_camel_case_\
24206 // shape` / `cilium_key_to_ports_carries_lower_camel_case_shape`
24207 // / `cilium_key_from_endpoints_carries_lower_camel_case_shape`
24208 // on the sibling per-CNP-body-axis grammar-pin set — the
24209 // lowerCamelCase K8s field-name grammar governs every nested
24210 // schema-field axis (including this per-`toPorts[]`-entry L4-
24211 // port-tuple-list-container-axis key), same convention.
24212 let v = CILIUM_KEY_PORTS;
24213 assert!(
24214 !v.is_empty(),
24215 "CILIUM_KEY_PORTS {v:?} must be non-empty per the K8s API \
24216 lowerCamelCase field-name grammar"
24217 );
24218 let first = v.chars().next().expect("non-empty");
24219 assert!(
24220 first.is_ascii_lowercase(),
24221 "CILIUM_KEY_PORTS {v:?} first byte {first:?} must be \
24222 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24223 grammar (field names are always lowerCamelCase)"
24224 );
24225 assert!(
24226 v.chars().all(|c| c.is_ascii_alphanumeric()),
24227 "CILIUM_KEY_PORTS {v:?} must be ASCII-alphanumeric \
24228 throughout per the K8s API field-name grammar — no \
24229 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24230 OpenAPI schema validator would reject"
24231 );
24232 }
24233
24234 #[test]
24235 fn cilium_key_authentication_pins_canonical_value() {
24236 // Pin the actual string so a typo in this lift can't silently
24237 // rebrand the Cilium CNP `spec.ingress[].authentication`
24238 // per-ingress-rule mutual-auth-policy body-axis key the
24239 // rendered CNP document mounts its per-rule mTLS enforcement
24240 // block under. The string is part of the cluster-side
24241 // contract with the upstream Cilium operator — the Cilium-
24242 // operator-side per-CNP mutual-auth SPIFFE-handshake pipeline
24243 // keys off this axis to source the per-rule mTLS enforcement
24244 // mode (`required` vs `disabled`); a drifted value (`"auth"`
24245 // / `"mutualAuth"` / `"mtls"` / `"authPolicy"`) at either
24246 // the production emitter or a downstream renderer's per-
24247 // ingress-rule mutual-auth upsert silently emits a per-
24248 // `ingress[]` entry whose mutual-auth-axis the Cilium CRD
24249 // schema validator drops as unknown, and the ingress rule
24250 // falls back to the cluster-default authentication mode
24251 // (typically `"disabled"` — no mutual-auth enforcement)
24252 // silently bypassing the SPIFFE-identity-bound mTLS handshake
24253 // every intra-mesh `:contratos` flow the CNP was authored to
24254 // protect. Changing this value is a coordinated Cilium-CRD
24255 // promotion alongside the upstream Cilium project's CRD
24256 // schema-migration cycle, not an incidental edit. Peer to
24257 // `cilium_key_from_endpoints_pins_canonical_value` /
24258 // `cilium_key_to_ports_pins_canonical_value` (the sibling
24259 // per-ingress-rule-body-axis pins the mutual-auth axis pairs
24260 // with at the per-rule triple
24261 // `(fromEndpoints, toPorts, authentication)`) on the sibling
24262 // per-CNP-dispatch-axis pin set — completes the per-CNP per-
24263 // ingress-rule-body triple the M3 Aplicacao mesh renderer's
24264 // SPIFFE-identity-bound per-edge mTLS contract rests on.
24265 assert_eq!(CILIUM_KEY_AUTHENTICATION, "authentication");
24266 }
24267
24268 #[test]
24269 fn cilium_key_authentication_carries_lower_camel_case_shape() {
24270 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24271 // lowerCamelCase identifier per the K8s API conventions
24272 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24273 // "Field names should be lowercase camelCase") — first byte
24274 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24275 // kebab-case or whitespace. Pinning the shape here means a
24276 // future rebrand on the canonical lift can't silently land a
24277 // malformed field-name discriminator (snake_case, kebab-case,
24278 // UpperCamelCase, empty) that the apiserver-side CRD schema
24279 // validator would reject far from the rebrand commit's source.
24280 // Peer to `cilium_key_endpoint_selector_carries_lower_camel_\
24281 // case_shape` / `cilium_key_ingress_carries_lower_camel_case_\
24282 // shape` / `cilium_key_to_ports_carries_lower_camel_case_shape`
24283 // / `cilium_key_from_endpoints_carries_lower_camel_case_shape`
24284 // / `cilium_key_ports_carries_lower_camel_case_shape` on the
24285 // sibling per-CNP-body-axis grammar-pin set — the
24286 // lowerCamelCase K8s field-name grammar governs every nested
24287 // schema-field axis (including this per-`ingress[]`-entry
24288 // mutual-auth-policy body-axis key), same convention.
24289 let v = CILIUM_KEY_AUTHENTICATION;
24290 assert!(
24291 !v.is_empty(),
24292 "CILIUM_KEY_AUTHENTICATION {v:?} must be non-empty per the K8s API \
24293 lowerCamelCase field-name grammar"
24294 );
24295 let first = v.chars().next().expect("non-empty");
24296 assert!(
24297 first.is_ascii_lowercase(),
24298 "CILIUM_KEY_AUTHENTICATION {v:?} first byte {first:?} must be \
24299 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24300 grammar (field names are always lowerCamelCase)"
24301 );
24302 assert!(
24303 v.chars().all(|c| c.is_ascii_alphanumeric()),
24304 "CILIUM_KEY_AUTHENTICATION {v:?} must be ASCII-alphanumeric \
24305 throughout per the K8s API field-name grammar — no \
24306 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24307 OpenAPI schema validator would reject"
24308 );
24309 }
24310
24311 #[test]
24312 fn cilium_key_mode_pins_canonical_value() {
24313 // Pin the actual string so a typo in this lift can't silently
24314 // rebrand the Cilium CNP `spec.ingress[].authentication.mode`
24315 // per-ingress-rule mutual-auth-mode-discriminator leaf-scalar-
24316 // axis key the rendered CNP document mounts its per-rule mTLS
24317 // enforcement mode value under. The string is part of the
24318 // cluster-side contract with the upstream Cilium operator —
24319 // the Cilium-operator-side per-CNP mutual-auth SPIFFE-handshake
24320 // pipeline reads this leaf axis to source the per-rule mTLS
24321 // enforcement mode value (`"required"` vs `"disabled"`); a
24322 // drifted key (`"policy"` / `"authMode"` / `"handshakeMode"`)
24323 // at either the production emitter or a downstream renderer's
24324 // per-ingress-rule mutual-auth-mode-leaf upsert silently emits
24325 // a per-`ingress[]` entry whose mutual-auth block's mode-
24326 // discriminator leaf-axis the Cilium CRD schema validator
24327 // drops as unknown, and the ingress rule falls back to the
24328 // cluster-default authentication mode (typically `"disabled"`
24329 // — no mutual-auth enforcement) silently bypassing the SPIFFE-
24330 // identity-bound mTLS handshake every intra-mesh `:contratos`
24331 // flow the CNP was authored to protect. Changing this value is
24332 // a coordinated Cilium-CRD promotion alongside the upstream
24333 // Cilium project's CRD schema-migration cycle, not an
24334 // incidental edit. Peer to
24335 // `cilium_key_authentication_pins_canonical_value` on the
24336 // sibling per-ingress-rule mutual-auth body-axis pin set —
24337 // completes the per-rule mutual-auth
24338 // `(authentication → mode)` body/leaf axis pin pair the M3
24339 // Aplicacao mesh renderer's SPIFFE-identity-bound per-edge
24340 // mTLS enforcement contract rests on. Byte-identical to the
24341 // sibling `:politicas :circuit-breaker (:window)` /
24342 // `:placement :estrategia` overlay mode-like axes today, but
24343 // semantically distinct: this const names the Cilium CRD's
24344 // per-authentication-block mode-discriminator leaf-axis key
24345 // (spelled per the Cilium project's CRD schema), so a future
24346 // rebrand on the Cilium CRD's per-authentication-block mode-
24347 // leaf axis lands at its own canonical const without coupling
24348 // the Cilium schema to any peer surface that happens to carry
24349 // the same byte.
24350 assert_eq!(CILIUM_KEY_MODE, "mode");
24351 }
24352
24353 #[test]
24354 fn cilium_key_mode_carries_lower_camel_case_shape() {
24355 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24356 // lowerCamelCase identifier per the K8s API conventions
24357 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24358 // "Field names should be lowercase camelCase") — first byte
24359 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24360 // kebab-case or whitespace. Pinning the shape here means a
24361 // future rebrand on the canonical lift can't silently land a
24362 // malformed field-name discriminator (snake_case, kebab-case,
24363 // UpperCamelCase, empty) that the apiserver-side CRD schema
24364 // validator would reject far from the rebrand commit's source.
24365 // Peer to `cilium_key_authentication_carries_lower_camel_case_\
24366 // shape` on the sibling per-ingress-rule mutual-auth-body-axis
24367 // grammar-pin — the lowerCamelCase K8s field-name grammar
24368 // governs every nested schema-field axis (including this
24369 // per-authentication-block mode-discriminator leaf-axis key),
24370 // same convention.
24371 let v = CILIUM_KEY_MODE;
24372 assert!(
24373 !v.is_empty(),
24374 "CILIUM_KEY_MODE {v:?} must be non-empty per the K8s API \
24375 lowerCamelCase field-name grammar"
24376 );
24377 let first = v.chars().next().expect("non-empty");
24378 assert!(
24379 first.is_ascii_lowercase(),
24380 "CILIUM_KEY_MODE {v:?} first byte {first:?} must be \
24381 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24382 grammar (field names are always lowerCamelCase)"
24383 );
24384 assert!(
24385 v.chars().all(|c| c.is_ascii_alphanumeric()),
24386 "CILIUM_KEY_MODE {v:?} must be ASCII-alphanumeric \
24387 throughout per the K8s API field-name grammar — no \
24388 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24389 OpenAPI schema validator would reject"
24390 );
24391 }
24392
24393 #[test]
24394 fn cilium_key_http_pins_canonical_value() {
24395 // Pin the actual string so a typo in this lift can't silently
24396 // rebrand the Cilium CNP `spec.ingress[].toPorts[].rules.http`
24397 // per-`toPorts[]` L7-HTTP-rule-list-discriminator container-axis
24398 // key the rendered CNP document mounts its per-`toPorts[]` L7
24399 // URL-path-prefix predicate list under. The string is part of the
24400 // cluster-side contract with the upstream Cilium operator — the
24401 // Cilium-operator-side per-CNP L7 dispatch pipeline reads this
24402 // container axis to source the per-`toPorts[]` L7 URL-path-prefix
24403 // predicate list the ingress rule was authored to filter each
24404 // HTTP-shaped `:contratos` flow through; a drifted key (`"HTTP"` /
24405 // `"Http"` / `"httpRules"` / `"httpMatch"`) at either the
24406 // production emitter or a downstream renderer's per-`toPorts[]`
24407 // L7-rule-list-discriminator upsert silently emits a per-
24408 // `toPorts[]` entry whose L7-HTTP-rule-list-discriminator key the
24409 // Cilium CRD schema validator drops as unknown, and the per-
24410 // `toPorts[]` entry falls back to L4-only enforcement — no L7
24411 // URL-path predicate is applied — silently admitting every HTTP-
24412 // method / URL-path combination the ingress rule was authored to
24413 // filter to the exact path prefix set the typed `:contratos`
24414 // graph names at the L7 introspection axis. Changing this value
24415 // is a coordinated Cilium-CRD promotion alongside the upstream
24416 // Cilium project's CRD schema-migration cycle, not an incidental
24417 // edit. Peer to `cilium_key_mode_pins_canonical_value` /
24418 // `cilium_key_authentication_pins_canonical_value` on the
24419 // sibling per-ingress-rule mutual-auth body/leaf axis pin pair —
24420 // completes the per-`toPorts[]` L7-introspection
24421 // `(rules → http)` container/protocol-discriminator axis pin
24422 // pair the M3 Aplicacao mesh renderer's HTTP-shaped-`:contratos`
24423 // URL-path-prefix-filtering L7-enforcement contract rests on.
24424 // Byte-identical to the sibling `Gateway.spec.listeners[].name`
24425 // arbitrary-author-chosen listener-name today (`"http"` — the
24426 // author-chosen name for the substrate's V0 HTTP listener), but
24427 // semantically distinct: this const names the Cilium CRD's per-
24428 // `toPorts[]` L7-HTTP-rule-list-discriminator container-axis key
24429 // (spelled per the Cilium project's CRD schema), so a future
24430 // rebrand on the Cilium CRD's L7-HTTP-rule-list-discriminator
24431 // axis lands at its own canonical const without coupling the
24432 // Cilium schema to any peer surface that happens to carry the
24433 // same byte.
24434 assert_eq!(CILIUM_KEY_HTTP, "http");
24435 }
24436
24437 #[test]
24438 fn cilium_key_http_carries_lower_camel_case_shape() {
24439 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24440 // lowerCamelCase identifier per the K8s API conventions
24441 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24442 // "Field names should be lowercase camelCase") — first byte
24443 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24444 // kebab-case or whitespace. Pinning the shape here means a
24445 // future rebrand on the canonical lift can't silently land a
24446 // malformed field-name discriminator (snake_case, kebab-case,
24447 // UpperCamelCase, empty) that the apiserver-side CRD schema
24448 // validator would reject far from the rebrand commit's source.
24449 // Peer to `cilium_key_mode_carries_lower_camel_case_shape` /
24450 // `cilium_key_authentication_carries_lower_camel_case_shape` on
24451 // the sibling per-ingress-rule mutual-auth-body/leaf-axis
24452 // grammar-pin set — the lowerCamelCase K8s field-name grammar
24453 // governs every nested schema-field axis (including this per-
24454 // `toPorts[]` L7-HTTP-rule-list-discriminator container-axis
24455 // key), same convention.
24456 let v = CILIUM_KEY_HTTP;
24457 assert!(
24458 !v.is_empty(),
24459 "CILIUM_KEY_HTTP {v:?} must be non-empty per the K8s API \
24460 lowerCamelCase field-name grammar"
24461 );
24462 let first = v.chars().next().expect("non-empty");
24463 assert!(
24464 first.is_ascii_lowercase(),
24465 "CILIUM_KEY_HTTP {v:?} first byte {first:?} must be \
24466 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24467 grammar (field names are always lowerCamelCase)"
24468 );
24469 assert!(
24470 v.chars().all(|c| c.is_ascii_alphanumeric()),
24471 "CILIUM_KEY_HTTP {v:?} must be ASCII-alphanumeric \
24472 throughout per the K8s API field-name grammar — no \
24473 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24474 OpenAPI schema validator would reject"
24475 );
24476 }
24477
24478 #[test]
24479 fn kube_key_type_pins_canonical_value() {
24480 // Pin the actual string so a typo in this lift can't silently
24481 // rebrand the K8s discriminated-union `type` scalar-discriminator
24482 // container-axis key every rendered CR mounts its per-position
24483 // discriminated-union type-value under. The string is part of the
24484 // cluster-side contract with every K8s apiserver-side OpenAPI
24485 // schema validator — the Gateway API v1 gateway-class-controller's
24486 // per-`HTTPRouteMatch` path-selection-predicate dispatch pass
24487 // reads this scalar-key to source the path-match-strategy
24488 // discriminator (the closed `PathMatchType` OpenAPI schema enum's
24489 // `{Exact, PathPrefix, RegularExpression}` set) the per-rule L7
24490 // URL-path-filtering was authored to bind — a drifted key
24491 // (`"Type"` / `"kind"` / `"discriminator"` / `"predicate"`) at
24492 // either the production emitter or a downstream renderer's per-
24493 // `HTTPRouteMatch` path-selection-predicate discriminator upsert
24494 // silently emits a per-match entry whose discriminator scalar-key
24495 // the Gateway API v1 `HTTPPathMatch` OpenAPI schema validator
24496 // drops as unknown, and the per-match entry falls back to the
24497 // schema-side default path-match-strategy — silently admitting
24498 // every URL-path prefix the ingress rule was authored to filter
24499 // to the exact predicate the typed `:entrada :paths` slot names
24500 // at the request-path-selection axis. Changing this value is a
24501 // coordinated K8s-API-conventions promotion alongside the
24502 // upstream sig-architecture per-version deprecation cycle, not
24503 // an incidental edit. Peer to
24504 // `cilium_key_http_pins_canonical_value` /
24505 // `cilium_key_mode_pins_canonical_value` /
24506 // `cilium_key_authentication_pins_canonical_value` on the
24507 // sibling per-CRD-body-axis pin set — extends the canonical-
24508 // string-pin discipline from the per-CRD-body-axis surfaces
24509 // onto the load-bearing nested K8s-discriminated-union-type-
24510 // scalar-discriminator axis every downstream apiserver-side
24511 // OpenAPI-schema-validator / gateway-class-controller consumer
24512 // of the rendered mesh bundle keys off before it can commit to
24513 // a per-match request-path-selection predicate.
24514 assert_eq!(KUBE_KEY_TYPE, "type");
24515 }
24516
24517 #[test]
24518 fn kube_key_type_carries_lower_camel_case_shape() {
24519 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24520 // lowerCamelCase identifier per the K8s API conventions
24521 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24522 // "Field names should be lowercase camelCase") — first byte
24523 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24524 // kebab-case or whitespace. Pinning the shape here means a
24525 // future rebrand on the canonical lift can't silently land a
24526 // malformed field-name discriminator (snake_case, kebab-case,
24527 // UpperCamelCase, empty) that the apiserver-side CRD schema
24528 // validator would reject far from the rebrand commit's source.
24529 // Peer to `cilium_key_http_carries_lower_camel_case_shape` /
24530 // `cilium_key_mode_carries_lower_camel_case_shape` /
24531 // `cilium_key_authentication_carries_lower_camel_case_shape` on
24532 // the sibling per-CRD-body-axis grammar-pin set — the
24533 // lowerCamelCase K8s field-name grammar governs every nested
24534 // schema-field axis (including this K8s-discriminated-union-
24535 // type-scalar-discriminator axis), same convention.
24536 let v = KUBE_KEY_TYPE;
24537 assert!(
24538 !v.is_empty(),
24539 "KUBE_KEY_TYPE {v:?} must be non-empty per the K8s API \
24540 lowerCamelCase field-name grammar"
24541 );
24542 let first = v.chars().next().expect("non-empty");
24543 assert!(
24544 first.is_ascii_lowercase(),
24545 "KUBE_KEY_TYPE {v:?} first byte {first:?} must be \
24546 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24547 grammar (field names are always lowerCamelCase)"
24548 );
24549 assert!(
24550 v.chars().all(|c| c.is_ascii_alphanumeric()),
24551 "KUBE_KEY_TYPE {v:?} must be ASCII-alphanumeric \
24552 throughout per the K8s API field-name grammar — no \
24553 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24554 OpenAPI schema validator would reject"
24555 );
24556 }
24557
24558 #[test]
24559 fn gateway_api_kind_gateway_pins_canonical_value() {
24560 // Pin the actual string so a typo in this lift can't silently
24561 // rebrand the Gateway-API-conformant `Gateway` CRD `kind`
24562 // discriminator the rendered Gateway document's top-level
24563 // `kind` axis declares. The string is part of the cluster-side
24564 // contract with every Gateway-API-conformant gateway
24565 // implementation (Cilium, Istio, Envoy Gateway, NGINX) — the
24566 // apiserver-side CRD resolution contract is the
24567 // `(apiVersion, kind)` tuple keyed against the registered
24568 // `CustomResourceDefinition`, so the kind half of the tuple is
24569 // exactly as load-bearing as the sibling
24570 // [`GATEWAY_API_API_VERSION`] apiVersion half. A drifted value
24571 // (e.g. an upstream Gateway-API rebrand to `GatewayV1`) lands
24572 // the rendered document outside the apiserver-side CRD
24573 // registration; changing it is a coordinated Gateway-API
24574 // promotion alongside the upstream SIG-Network deprecation
24575 // cycle, not an incidental edit. Peer to
24576 // `cilium_kind_network_policy_pins_canonical_value` /
24577 // `flux_kind_kustomization_pins_canonical_value` /
24578 // `flux_kind_helm_release_pins_canonical_value` /
24579 // `flux_kind_git_repository_pins_canonical_value` on the
24580 // sibling cluster-side-CRD-`kind`-discriminator pin set —
24581 // extends the canonical-string-pin discipline from the
24582 // Cilium-CRD + Flux v2 controller-triplet `kind`-axis surfaces
24583 // onto the Gateway-API-CRD `kind`-axis surface, beginning the
24584 // per-Gateway-API-CRD kind+apiVersion canonical-pin pair the
24585 // M3 Aplicacao mesh renderer's external `:entrada` ingress
24586 // contract rests on.
24587 assert_eq!(GATEWAY_API_KIND_GATEWAY, "Gateway");
24588 }
24589
24590 #[test]
24591 fn gateway_api_kind_gateway_carries_upper_camel_case_shape() {
24592 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
24593 // an UpperCamelCase identifier per the K8s API conventions
24594 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
24595 // "Kinds are always UpperCamelCase"). Pinning the shape here
24596 // means a future rebrand on the canonical lift can't silently
24597 // land a malformed kind discriminator (snake_case, kebab-case,
24598 // lowercase, empty) that every downstream YAML-aware
24599 // deserializer would reject far from the rebrand commit's
24600 // source. The first-byte uppercase / rest-ASCII-alphanumeric
24601 // invariant is the load-bearing K8s API typed-discovery
24602 // contract: a value the apiserver's `RESTMapper` consults to
24603 // resolve the CRD's `RESTKind`. Peer to
24604 // `cilium_kind_network_policy_carries_upper_camel_case_shape` /
24605 // `flux_kind_kustomization_carries_upper_camel_case_shape` /
24606 // `flux_kind_helm_release_carries_upper_camel_case_shape` /
24607 // `flux_kind_git_repository_carries_upper_camel_case_shape` on
24608 // the sibling cluster-side-CRD-`kind`-discriminator surface.
24609 let v = GATEWAY_API_KIND_GATEWAY;
24610 assert!(
24611 !v.is_empty(),
24612 "GATEWAY_API_KIND_GATEWAY {v:?} must be non-empty per the K8s API \
24613 UpperCamelCase kind discriminator grammar"
24614 );
24615 let first = v.chars().next().expect("non-empty");
24616 assert!(
24617 first.is_ascii_uppercase(),
24618 "GATEWAY_API_KIND_GATEWAY {v:?} first byte {first:?} must be \
24619 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
24620 grammar (Kinds are always UpperCamelCase)"
24621 );
24622 assert!(
24623 v.chars().all(|c| c.is_ascii_alphanumeric()),
24624 "GATEWAY_API_KIND_GATEWAY {v:?} must be ASCII-alphanumeric \
24625 throughout per the K8s API kind discriminator grammar — no \
24626 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24627 RESTMapper would reject"
24628 );
24629 }
24630
24631 #[test]
24632 fn gateway_api_kind_http_route_pins_canonical_value() {
24633 // Pin the actual string so a typo in this lift can't silently
24634 // rebrand the Gateway-API-conformant `HTTPRoute` CRD `kind`
24635 // discriminator the rendered HTTPRoute document's top-level
24636 // `kind` axis declares. The string is part of the cluster-side
24637 // contract with every Gateway-API-conformant gateway
24638 // implementation (Cilium, Istio, Envoy Gateway, NGINX) — the
24639 // apiserver-side CRD resolution contract is the
24640 // `(apiVersion, kind)` tuple keyed against the registered
24641 // `CustomResourceDefinition`, so the kind half of the tuple is
24642 // exactly as load-bearing as the sibling
24643 // [`GATEWAY_API_API_VERSION`] apiVersion half. A drifted value
24644 // (e.g. an upstream Gateway-API rebrand to `HTTPRouteV1`) lands
24645 // the rendered document outside the apiserver-side CRD
24646 // registration; changing it is a coordinated Gateway-API
24647 // promotion alongside the upstream SIG-Network deprecation
24648 // cycle, not an incidental edit. Peer to
24649 // `gateway_api_kind_gateway_pins_canonical_value` /
24650 // `cilium_kind_network_policy_pins_canonical_value` /
24651 // `flux_kind_kustomization_pins_canonical_value` /
24652 // `flux_kind_helm_release_pins_canonical_value` /
24653 // `flux_kind_git_repository_pins_canonical_value` on the
24654 // sibling cluster-side-CRD-`kind`-discriminator pin set —
24655 // completes the per-Gateway-API-CRD `kind`-axis canonical-pin
24656 // pair across the `(Gateway, HTTPRoute)` pair the renderer's
24657 // `gateway_routes` external `:entrada` ingress contract emits
24658 // together.
24659 assert_eq!(GATEWAY_API_KIND_HTTP_ROUTE, "HTTPRoute");
24660 }
24661
24662 #[test]
24663 fn gateway_api_kind_http_route_carries_upper_camel_case_shape() {
24664 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
24665 // an UpperCamelCase identifier per the K8s API conventions
24666 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
24667 // "Kinds are always UpperCamelCase"). Acronyms like HTTP stay
24668 // ASCII-uppercase across the prefix per the same convention
24669 // (the K8s API Kinds for `HTTPRoute`, `TCPRoute`, `TLSRoute`,
24670 // `GRPCRoute` carry the full-uppercase protocol acronym).
24671 // Pinning the shape here means a future rebrand on the
24672 // canonical lift can't silently land a malformed kind
24673 // discriminator (snake_case, kebab-case, lowercase, empty)
24674 // that every downstream YAML-aware deserializer would reject
24675 // far from the rebrand commit's source. The first-byte
24676 // uppercase / rest-ASCII-alphanumeric invariant is the
24677 // load-bearing K8s API typed-discovery contract: a value the
24678 // apiserver's `RESTMapper` consults to resolve the CRD's
24679 // `RESTKind`. Peer to
24680 // `gateway_api_kind_gateway_carries_upper_camel_case_shape` /
24681 // `cilium_kind_network_policy_carries_upper_camel_case_shape` /
24682 // `flux_kind_kustomization_carries_upper_camel_case_shape` /
24683 // `flux_kind_helm_release_carries_upper_camel_case_shape` /
24684 // `flux_kind_git_repository_carries_upper_camel_case_shape` on
24685 // the sibling cluster-side-CRD-`kind`-discriminator surface.
24686 let v = GATEWAY_API_KIND_HTTP_ROUTE;
24687 assert!(
24688 !v.is_empty(),
24689 "GATEWAY_API_KIND_HTTP_ROUTE {v:?} must be non-empty per the K8s API \
24690 UpperCamelCase kind discriminator grammar"
24691 );
24692 let first = v.chars().next().expect("non-empty");
24693 assert!(
24694 first.is_ascii_uppercase(),
24695 "GATEWAY_API_KIND_HTTP_ROUTE {v:?} first byte {first:?} must be \
24696 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
24697 grammar (Kinds are always UpperCamelCase)"
24698 );
24699 assert!(
24700 v.chars().all(|c| c.is_ascii_alphanumeric()),
24701 "GATEWAY_API_KIND_HTTP_ROUTE {v:?} must be ASCII-alphanumeric \
24702 throughout per the K8s API kind discriminator grammar — no \
24703 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24704 RESTMapper would reject"
24705 );
24706 }
24707
24708 #[test]
24709 fn gateway_api_protocol_http_pins_canonical_value() {
24710 // Pin the actual string so a typo in this lift can't silently
24711 // rebrand the Gateway API v1 `ProtocolType` OpenAPI schema enum's
24712 // canonical `HTTP` listener-protocol value the rendered
24713 // `Gateway.spec.listeners[].protocol` scalar declares. The value
24714 // is part of the cluster-side contract with every Gateway-API-
24715 // conformant gateway implementation (Cilium, Istio, Envoy
24716 // Gateway, NGINX) — the gateway-class-controller's per-listener
24717 // bind loop keys off this exact byte-sequence to select the L7
24718 // parser + TLS termination strategy; the Gateway API v1
24719 // `ProtocolType` OpenAPI schema enum admits the closed set
24720 // `{"HTTP", "HTTPS", "TCP", "TLS", "UDP"}` verbatim, so a
24721 // drifted value (`"http"` / `"Http"` / `"HTTP/1.1"` / `"http/1.1"`)
24722 // lands the rendered `Gateway` outside the `ProtocolType` enum's
24723 // admitted set and every external `:entrada` HTTP flow drops at
24724 // the gateway-class-controller's admission gate. Changing this
24725 // value is a coordinated Gateway API `ProtocolType` promotion
24726 // alongside the upstream SIG-Network deprecation cycle, not an
24727 // incidental edit. Peer to
24728 // `gateway_api_kind_gateway_pins_canonical_value` /
24729 // `gateway_api_kind_http_route_pins_canonical_value` /
24730 // `default_gateway_class_name_pins_canonical_value` on the
24731 // sibling Gateway-API-CRD-`kind`-discriminator + Gateway-
24732 // controller-binding-scalar-value pin set — extends the pair
24733 // of `kind`-axis canonical-value pins across the
24734 // `(Gateway, HTTPRoute)` pair onto the sibling per-Gateway
24735 // `spec.listeners[].protocol` listener-protocol-scalar-value axis
24736 // the same `gateway_routes` external `:entrada` ingress emitter
24737 // carries.
24738 assert_eq!(GATEWAY_API_PROTOCOL_HTTP, "HTTP");
24739 }
24740
24741 #[test]
24742 fn gateway_api_protocol_http_carries_upper_case_shape() {
24743 // Cross-axis invariant: the Gateway API v1 `ProtocolType` OpenAPI
24744 // schema enum admits the closed set
24745 // `{"HTTP", "HTTPS", "TCP", "TLS", "UDP"}` — every admitted value
24746 // is ASCII-uppercase throughout per the upstream SIG-Network
24747 // Gateway API convention (see
24748 // https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.ProtocolType
24749 // — the admitted values are the transport / application-layer
24750 // protocol acronyms in their canonical uppercase form). Pinning
24751 // the shape here means a future rebrand on the canonical lift
24752 // can't silently land a malformed listener-protocol scalar
24753 // (lowercase `"http"`, mixed-case `"Http"`, dotted `"HTTP/1.1"`,
24754 // empty) that the K8s Gateway API v1 `ProtocolType` OpenAPI
24755 // schema enum would reject at admission time far from the
24756 // rebrand commit's source. The all-ASCII-uppercase invariant is
24757 // the load-bearing Gateway-API-implementation-side typed
24758 // listener-parser-selection contract: a value the gateway-
24759 // class-controller's per-listener bind loop selects the L7
24760 // parser + TLS termination strategy from.
24761 let v = GATEWAY_API_PROTOCOL_HTTP;
24762 assert!(
24763 !v.is_empty(),
24764 "GATEWAY_API_PROTOCOL_HTTP {v:?} must be non-empty per the \
24765 Gateway API v1 `ProtocolType` OpenAPI schema enum grammar"
24766 );
24767 assert!(
24768 v.chars().all(|c| c.is_ascii_uppercase()),
24769 "GATEWAY_API_PROTOCOL_HTTP {v:?} must be ASCII-uppercase \
24770 throughout per the Gateway API v1 `ProtocolType` OpenAPI \
24771 schema enum convention — no lowercase, mixed-case, dotted, \
24772 or whitespace bytes the gateway-class-controller's per-\
24773 listener bind loop would reject"
24774 );
24775 }
24776
24777 #[test]
24778 fn gateway_api_path_match_type_path_prefix_pins_canonical_value() {
24779 // Pin the actual string so a typo in this lift can't silently
24780 // rebrand the Gateway API v1 `PathMatchType` OpenAPI schema
24781 // enum's canonical `PathPrefix` per-`HTTPRouteMatch` path-
24782 // selection-predicate discriminator value the rendered
24783 // `HTTPRoute.spec.rules[].matches[].path.type` scalar declares.
24784 // The value is part of the cluster-side contract with every
24785 // Gateway-API-conformant gateway implementation (Cilium, Istio,
24786 // Envoy Gateway, NGINX) — the gateway-class-controller's
24787 // per-rule L7 dispatch loop keys off this exact byte-sequence
24788 // to select the request-path-selection predicate; the Gateway
24789 // API v1 `PathMatchType` OpenAPI schema enum admits the closed
24790 // set `{"Exact", "PathPrefix", "RegularExpression"}` verbatim,
24791 // so a drifted value (`"pathPrefix"` / `"path_prefix"` /
24792 // `"Prefix"` / `"path-prefix"`) lands the rendered `HTTPRoute`
24793 // outside the `PathMatchType` enum's admitted set and every
24794 // external `:entrada` path-filtered flow drops at the gateway-
24795 // class-controller's admission gate. Changing this value is a
24796 // coordinated Gateway API `PathMatchType` promotion alongside
24797 // the upstream SIG-Network deprecation cycle, not an incidental
24798 // edit. Peer to
24799 // `gateway_api_protocol_http_pins_canonical_value` /
24800 // `gateway_api_kind_gateway_pins_canonical_value` /
24801 // `gateway_api_kind_http_route_pins_canonical_value` /
24802 // `default_gateway_class_name_pins_canonical_value` on the
24803 // sibling Gateway-API-v1-OpenAPI-schema-enum-value +
24804 // Gateway-API-CRD-`kind`-discriminator + Gateway-controller-
24805 // binding-scalar-value pin set — extends the canonical-
24806 // Gateway-API-v1-OpenAPI-schema-enum-value single-sourcing
24807 // discipline the `ProtocolType.HTTP` pin established onto the
24808 // sibling `PathMatchType.PathPrefix` per-`HTTPRouteMatch`
24809 // path-selection-predicate discriminator the same
24810 // `gateway_routes` external `:entrada` ingress emitter carries
24811 // under the shared `HTTPRoute` body.
24812 assert_eq!(GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX, "PathPrefix");
24813 }
24814
24815 #[test]
24816 fn gateway_api_path_match_type_path_prefix_carries_upper_camel_case_shape() {
24817 // Cross-axis invariant: the Gateway API v1 `PathMatchType`
24818 // OpenAPI schema enum admits the closed set
24819 // `{"Exact", "PathPrefix", "RegularExpression"}` — every
24820 // admitted value is UpperCamelCase per the upstream SIG-Network
24821 // Gateway API convention (see
24822 // https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.PathMatchType
24823 // — the admitted values are the request-path-selection
24824 // predicate names in their canonical UpperCamelCase form,
24825 // matching the K8s API `Kinds are always UpperCamelCase`
24826 // convention the sibling `GATEWAY_API_KIND_*` discriminators
24827 // carry on the CRD-`kind`-axis surface). Pinning the shape
24828 // here means a future rebrand on the canonical lift can't
24829 // silently land a malformed path-match-type scalar (lowercase
24830 // `"pathprefix"`, snake_case `"path_prefix"`, kebab-case
24831 // `"path-prefix"`, empty) that the K8s Gateway API v1
24832 // `PathMatchType` OpenAPI schema enum would reject at
24833 // admission time far from the rebrand commit's source. The
24834 // first-byte uppercase / rest-ASCII-alphanumeric invariant is
24835 // the load-bearing Gateway-API-implementation-side typed
24836 // per-match request-path-selection-predicate-selection
24837 // contract: a value the gateway-class-controller's per-rule
24838 // L7 dispatch loop selects the request-path-predicate
24839 // evaluator from. Peer to
24840 // `gateway_api_kind_gateway_carries_upper_camel_case_shape` /
24841 // `gateway_api_kind_http_route_carries_upper_camel_case_shape`
24842 // on the sibling cluster-side-CRD-`kind`-discriminator
24843 // UpperCamelCase pin set — extends the canonical-K8s-API-
24844 // UpperCamelCase-typed-discriminator pin discipline the
24845 // `Kind` axis carries onto the sibling Gateway API v1
24846 // `PathMatchType` OpenAPI schema enum's per-value
24847 // UpperCamelCase surface (distinct from the sibling
24848 // Gateway API v1 `ProtocolType` OpenAPI schema enum's all-
24849 // ASCII-uppercase per-value convention the
24850 // `gateway_api_protocol_http_carries_upper_case_shape` pin
24851 // carries — the two peer Gateway-API-v1 OpenAPI schema
24852 // enum-value conventions do not collapse).
24853 let v = GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX;
24854 assert!(
24855 !v.is_empty(),
24856 "GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX {v:?} must be non-empty per \
24857 the Gateway API v1 `PathMatchType` OpenAPI schema enum grammar"
24858 );
24859 let first = v.chars().next().expect("non-empty");
24860 assert!(
24861 first.is_ascii_uppercase(),
24862 "GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX {v:?} first byte {first:?} \
24863 must be ASCII-uppercase per the Gateway API v1 `PathMatchType` \
24864 OpenAPI schema enum UpperCamelCase convention"
24865 );
24866 assert!(
24867 v.chars().all(|c| c.is_ascii_alphanumeric()),
24868 "GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX {v:?} must be ASCII-\
24869 alphanumeric throughout per the Gateway API v1 `PathMatchType` \
24870 OpenAPI schema enum UpperCamelCase convention — no snake_case, \
24871 kebab-case, or whitespace bytes the gateway-class-controller's \
24872 per-rule L7 dispatch loop would reject"
24873 );
24874 }
24875
24876 #[test]
24877 fn kube_protocol_tcp_pins_canonical_value() {
24878 // Pin the actual string so a typo in this lift can't silently
24879 // rebrand the K8s core `Protocol` OpenAPI schema enum's
24880 // canonical `TCP` L4-transport-protocol scalar value the
24881 // rendered `CiliumNetworkPolicy.spec.ingress[].toPorts[].ports[]
24882 // .protocol` scalar declares. The value is part of the cluster-
24883 // side contract with every K8s-core-`Protocol`-conformant CNI
24884 // + kube-proxy + eBPF-data-plane implementation (Cilium,
24885 // Calico, kube-proxy iptables/ipvs) — the CNI's per-CNP L4
24886 // dispatch pass keys off this exact byte-sequence to select
24887 // the per-tuple L4-transport-protocol predicate; the K8s core
24888 // `Protocol` OpenAPI schema enum admits the closed set
24889 // `{"TCP", "UDP", "SCTP"}` verbatim (see
24890 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1/#protocol-v1-core),
24891 // so a drifted value (`"tcp"` / `"Tcp"` / `"TCP/IP"` /
24892 // `"transport-tcp"`) lands the rendered `CiliumNetworkPolicy`
24893 // outside the `Protocol` enum's admitted set and every intra-
24894 // mesh `:contratos` L4-tuple-gated flow drops at the Cilium
24895 // operator's admission gate. Changing this value is a
24896 // coordinated K8s core `Protocol` promotion alongside the
24897 // upstream SIG-Network deprecation cycle, not an incidental
24898 // edit. Peer to
24899 // `gateway_api_protocol_http_pins_canonical_value` /
24900 // `gateway_api_path_match_type_path_prefix_pins_canonical_value`
24901 // on the sibling Gateway-API-v1-OpenAPI-schema-enum-value pin
24902 // set — extends the canonical-cluster-side-OpenAPI-schema-enum-
24903 // value single-sourcing discipline the Gateway-API v1
24904 // `ProtocolType.HTTP` / `PathMatchType.PathPrefix` pins
24905 // established onto the sibling K8s-core `Protocol.TCP` per-port-
24906 // tuple L4-transport-protocol-discriminator the
24907 // `cilium_network_policies` intra-mesh L4-tuple-gating emitter
24908 // carries under the shared `CiliumNetworkPolicy` body.
24909 assert_eq!(KUBE_PROTOCOL_TCP, "TCP");
24910 }
24911
24912 #[test]
24913 fn kube_protocol_tcp_carries_upper_case_shape() {
24914 // Cross-axis invariant: the K8s core `Protocol` OpenAPI schema
24915 // enum admits the closed set `{"TCP", "UDP", "SCTP"}` — every
24916 // admitted value is ASCII-uppercase throughout per the upstream
24917 // SIG-Network convention (the admitted values are the L4-
24918 // transport-protocol acronyms in their canonical uppercase form,
24919 // matching the sibling Gateway-API v1 `ProtocolType` OpenAPI
24920 // schema enum's `{"HTTP", "HTTPS", "TCP", "TLS", "UDP"}` all-
24921 // ASCII-uppercase convention the
24922 // `gateway_api_protocol_http_carries_upper_case_shape` pin
24923 // carries on the peer per-listener L7-parser-selection scalar
24924 // axis). Pinning the shape here means a future rebrand on the
24925 // canonical lift can't silently land a malformed L4-transport-
24926 // protocol scalar (lowercase `"tcp"`, mixed-case `"Tcp"`,
24927 // dotted `"TCP/IP"`, empty) that the K8s core `Protocol`
24928 // OpenAPI schema enum would reject at admission time far from
24929 // the rebrand commit's source. The all-ASCII-uppercase
24930 // invariant is the load-bearing K8s-core-`Protocol`-enum-side
24931 // typed L4-transport-selection contract: a value the CNI's per-
24932 // CNP L4 dispatch pass selects the per-tuple L4-transport-
24933 // protocol predicate from. Peer to
24934 // `gateway_api_protocol_http_carries_upper_case_shape` on the
24935 // sibling Gateway-API v1 `ProtocolType` OpenAPI schema enum's
24936 // all-ASCII-uppercase per-value convention pin set — the two
24937 // peer canonical-cluster-side-OpenAPI-schema-enum-value
24938 // uppercase conventions collapse on the shared `TCP` transport-
24939 // protocol acronym both `Protocol` enums admit at the closed-
24940 // set intersection.
24941 let v = KUBE_PROTOCOL_TCP;
24942 assert!(
24943 !v.is_empty(),
24944 "KUBE_PROTOCOL_TCP {v:?} must be non-empty per the K8s core \
24945 `Protocol` OpenAPI schema enum grammar"
24946 );
24947 assert!(
24948 v.chars().all(|c| c.is_ascii_uppercase()),
24949 "KUBE_PROTOCOL_TCP {v:?} must be ASCII-uppercase throughout \
24950 per the K8s core `Protocol` OpenAPI schema enum convention \
24951 — no lowercase, mixed-case, dotted, or whitespace bytes the \
24952 CNI's per-CNP L4 dispatch pass would reject"
24953 );
24954 }
24955
24956 #[test]
24957 fn cilium_auth_mode_required_pins_canonical_value() {
24958 // Pin the actual string so a typo in this lift can't silently
24959 // rebrand the Cilium `CiliumNetworkPolicy` `MutualAuthenticationMode`
24960 // OpenAPI schema enum's `required` mTLS-mandatory scalar-value the
24961 // rendered CNP's `spec.ingress[].authentication.mode` leaf declares
24962 // under the `:mtls-required t` affirmative arm of the typed
24963 // `:politicas :mtls-required` tristate. The value is part of the
24964 // cluster-side contract with the Cilium-agent-side per-rule mutual-
24965 // auth-block schema validator — the agent's per-rule dispatch loop
24966 // keys off this exact byte-sequence to select the SPIFFE-identity-
24967 // handshake-mandatory enforcement policy; the Cilium CNP
24968 // `MutualAuthenticationMode` OpenAPI schema enum admits the closed
24969 // set `{"required", "disabled", "test-always-fail"}` verbatim (the
24970 // `test-always-fail` arm is a Cilium-side debugging surface, not
24971 // author-reachable), so a drifted value (`"Required"` /
24972 // `"REQUIRED"` / `"mandatory"` / `"mtls-required"`) lands the
24973 // rendered `CiliumNetworkPolicy` outside the
24974 // `MutualAuthenticationMode` enum's admitted set and every intra-
24975 // mesh `:contratos` flow the CNP was authored to protect with per-
24976 // edge SPIFFE-identity-bound mutual-auth silently bypasses the
24977 // handshake at the Cilium data-plane's default-authentication mode
24978 // (typically also "disabled" today, but environment-divergent —
24979 // take effect) with no field naming the mTLS-mandatory-scalar-value-
24980 // drift root cause. Changing this value is a coordinated Cilium
24981 // CNP `MutualAuthenticationMode` promotion alongside the Cilium
24982 // project's periodic CRD schema-migration passes, not an
24983 // incidental edit. Peer to
24984 // `gateway_api_protocol_http_pins_canonical_value` /
24985 // `gateway_api_path_match_type_path_prefix_pins_canonical_value` /
24986 // `kube_protocol_tcp_pins_canonical_value` on the sibling
24987 // canonical-cluster-side-OpenAPI-schema-enum-value pin set —
24988 // extends the canonical-cluster-side-OpenAPI-schema-enum-value
24989 // single-sourcing discipline the Gateway-API v1 `ProtocolType.HTTP`
24990 // / `PathMatchType.PathPrefix` / K8s-core `Protocol.TCP` pins
24991 // established onto the sibling Cilium-CNP-side
24992 // `MutualAuthenticationMode.required` per-rule mTLS-mandatory
24993 // scalar-value the `cilium_network_policies` per-edge SPIFFE-
24994 // identity-bound mutual-auth emitter carries under the shared
24995 // `CiliumNetworkPolicy` body.
24996 assert_eq!(CILIUM_AUTH_MODE_REQUIRED, "required");
24997 }
24998
24999 #[test]
25000 fn cilium_auth_mode_disabled_pins_canonical_value() {
25001 // Peer to `cilium_auth_mode_required_pins_canonical_value` on the
25002 // `Some(false)` opt-out arm of the same
25003 // `MutualAuthenticationMode` OpenAPI schema enum: pin the actual
25004 // string so a typo can't silently rebrand the Cilium `disabled`
25005 // mTLS-skipped scalar-value the rendered CNP's per-rule authn-
25006 // block declares under the explicit `:mtls-required nil` opt-out
25007 // (distinct from the `None` slot-absent arm the renderer maps to
25008 // omit-the-block-entirely). A drifted value (`"Disabled"` /
25009 // `"DISABLED"` / `"off"` / `"skip"`) lands outside the
25010 // `MutualAuthenticationMode` OpenAPI schema enum's admitted set;
25011 // the author's explicit-opt-out intent silently collapses onto the
25012 // cluster-default authentication mode with no field naming the
25013 // mTLS-skipped-scalar-value-drift root cause. Peer to
25014 // `cilium_auth_mode_required_pins_canonical_value` on the
25015 // affirmative arm of the same enum — completes the per-authn-block
25016 // `(mode → {required, disabled})` author-reachable-scalar-value-
25017 // pair single-sourcing the M3 Aplicacao mesh renderer's SPIFFE-
25018 // identity-bound per-edge mTLS enforcement + explicit-opt-out
25019 // contract rests on across the two arms of the `:politicas
25020 // :mtls-required` tristate.
25021 assert_eq!(CILIUM_AUTH_MODE_DISABLED, "disabled");
25022 }
25023
25024 #[test]
25025 fn cilium_auth_modes_carry_lower_case_shape() {
25026 // Cross-axis invariant: the Cilium CNP `MutualAuthenticationMode`
25027 // OpenAPI schema enum admits the closed set `{"required",
25028 // "disabled", "test-always-fail"}` — every admitted value is
25029 // ASCII-lowercase throughout per the Cilium-project convention
25030 // (distinct from the sibling K8s-core `Protocol.TCP` /
25031 // Gateway-API-v1 `ProtocolType.HTTP` all-ASCII-uppercase
25032 // convention the `kube_protocol_tcp_carries_upper_case_shape` /
25033 // `gateway_api_protocol_http_carries_upper_case_shape` pins carry
25034 // on the sibling per-listener L7-parser-selection scalar axis, and
25035 // distinct from the sibling Gateway-API-v1
25036 // `PathMatchType.PathPrefix` UpperCamelCase convention the
25037 // `gateway_api_path_match_type_path_prefix_carries_upper_camel_case_shape`
25038 // pin carries on the sibling per-match request-path-selection
25039 // scalar axis — the Cilium CNP `MutualAuthenticationMode` enum
25040 // grammar does not collapse with either sibling cluster-side
25041 // OpenAPI schema enum's per-value casing convention). Pinning the
25042 // shape here means a future rebrand on either lifted value can't
25043 // silently land a malformed mode-discriminator scalar (uppercase
25044 // `"REQUIRED"` / `"DISABLED"`, UpperCamelCase `"Required"` /
25045 // `"Disabled"`, mixed-case, whitespace) that the Cilium CNP
25046 // `MutualAuthenticationMode` OpenAPI schema enum would reject at
25047 // admission time far from the rebrand commit's source.
25048 for v in [CILIUM_AUTH_MODE_REQUIRED, CILIUM_AUTH_MODE_DISABLED] {
25049 assert!(
25050 !v.is_empty(),
25051 "{v:?} must be non-empty per the Cilium CNP \
25052 `MutualAuthenticationMode` OpenAPI schema enum grammar"
25053 );
25054 assert!(
25055 v.chars().all(|c| c.is_ascii_lowercase()),
25056 "{v:?} must be ASCII-lowercase throughout per the Cilium \
25057 CNP `MutualAuthenticationMode` OpenAPI schema enum \
25058 convention — no uppercase, UpperCamelCase, or whitespace \
25059 bytes the Cilium-agent-side per-rule mutual-auth-block \
25060 schema validator would reject"
25061 );
25062 }
25063 }
25064
25065 #[test]
25066 fn cilium_auth_modes_are_distinct() {
25067 // Pin the `MutualAuthenticationMode` enum's per-arm distinctness
25068 // at type-check time: the two author-reachable arms of the typed
25069 // `:politicas :mtls-required` tristate must not collapse onto the
25070 // same scalar-value byte-sequence. A future rebrand that landed
25071 // both lifted constants on the same string (e.g. both `"required"`
25072 // through a copy-paste typo, or both aliased through a shared
25073 // helper) would silently erase the tristate's affirmative /
25074 // explicit-opt-out distinction at the emit boundary — the
25075 // renderer would emit the same scalar under both the `Some(true)`
25076 // and `Some(false)` arms of the closure the
25077 // `single_field_overlay(spec.politicas.mtls_required,
25078 // CILIUM_KEY_MODE, |required| …)` call site carries, collapsing
25079 // the two author intents onto a single Cilium-side enforcement
25080 // policy with no field naming the collapse root cause. Peer to
25081 // the two `cilium_auth_mode_{required,disabled}_pins_canonical_
25082 // value` per-arm pins — completes the per-arm distinctness pin
25083 // set on the closed author-reachable subset of the enum.
25084 assert_ne!(
25085 CILIUM_AUTH_MODE_REQUIRED, CILIUM_AUTH_MODE_DISABLED,
25086 "the two author-reachable arms of the `:mtls-required` \
25087 tristate must land distinct `MutualAuthenticationMode` \
25088 scalar-values"
25089 );
25090 }
25091
25092 #[test]
25093 fn cilium_auth_mode_bijection_dispatches_tristate_arms_onto_scalar_values() {
25094 // Pin the `bool → &'static str` projection every consumer of the
25095 // Cilium `MutualAuthenticationMode` closed-set enum's author-
25096 // reachable scalar-value pair reaches through: `true` (the
25097 // `Some(true)` mTLS-mandatory arm of the typed `:politicas
25098 // :mtls-required` tristate) maps to [`CILIUM_AUTH_MODE_REQUIRED`],
25099 // `false` (the `Some(false)` explicit-opt-out arm) maps to
25100 // [`CILIUM_AUTH_MODE_DISABLED`]. One projection body, both arms of
25101 // the tristate's non-`None` value-space, so a future per-arm
25102 // reassignment (e.g. an upstream Cilium v3 schema swap of the
25103 // `required` ↔ `disabled` scalars, or a per-arm renaming of the
25104 // mTLS-mandatory scalar from `required` to `enforced` / `strict`
25105 // / `mandatory`) lands at the two consts + this projection body
25106 // — not at the caixa-mesh production emitter's closure body and
25107 // the caixa-core `single_field_overlay_threads_typed_value_
25108 // through_closure` generic-helper pin's closure body independently.
25109 // Pin the per-arm round-trip so a future refactor that inverts
25110 // the bool → arm mapping (or collapses one arm) surfaces here
25111 // rather than silently letting a Cilium data-plane pod either
25112 // enforce mTLS where the author asked for skip or skip it where
25113 // the author asked for enforce.
25114 assert_eq!(cilium_auth_mode(true), CILIUM_AUTH_MODE_REQUIRED);
25115 assert_eq!(cilium_auth_mode(false), CILIUM_AUTH_MODE_DISABLED);
25116 // The two arms cover distinct value-space entries — a regression
25117 // that collapses them onto the same scalar surfaces here. Peer
25118 // to `cilium_auth_modes_are_distinct` (the per-arm distinctness
25119 // pin at the const-declaration axis) — this test extends the
25120 // pin onto the projection body axis, so both the raw consts and
25121 // the projection's per-arm dispatch preserve the tristate's
25122 // author-intent distinction end-to-end.
25123 assert_ne!(
25124 cilium_auth_mode(true),
25125 cilium_auth_mode(false),
25126 "cilium_auth_mode must project the two tristate arms onto \
25127 distinct `MutualAuthenticationMode` value-space entries — \
25128 a collapsed-arm regression would silently render both \
25129 `:mtls-required t` and `:mtls-required nil` identically at \
25130 the cluster artifact",
25131 );
25132 }
25133
25134 #[test]
25135 fn gateway_api_key_parent_refs_pins_canonical_value() {
25136 // Pin the actual string so a typo in this lift can't silently
25137 // rebrand the Gateway API `HTTPRoute` parent-Gateway-binding
25138 // container-axis key the rendered HTTPRoute document mounts its
25139 // per-route `[{name}]` parent-Gateway attachment list under. The
25140 // string is part of the cluster-side contract with every
25141 // Gateway-API-conformant gateway implementation (Cilium, Istio,
25142 // Envoy Gateway, NGINX) — the Gateway-API-implementation-side
25143 // per-HTTPRoute reconcile loop keys off this axis to source the
25144 // per-route parent-Gateway attachment list the route is bound
25145 // to; a drifted value (`"parentRef"` / `"parents"` /
25146 // `"parentGateways"`) at either the production emitter or a
25147 // downstream renderer's per-HTTPRoute parent-Gateway-binding
25148 // upsert silently emits an `HTTPRoute` whose parent-Gateway-
25149 // binding axis the Gateway API CRD schema validator drops as
25150 // unknown — the route lands unattached to any Gateway, and
25151 // every external `:entrada` flow the HTTPRoute was authored to
25152 // accept drops at the Gateway API implementation's per-Gateway
25153 // HTTP-listener fan-in with no field naming the parent-Gateway-
25154 // binding-drift root cause. Changing this value is a
25155 // coordinated Gateway API promotion alongside the upstream
25156 // SIG-Network Gateway API deprecation cycle, not an incidental
25157 // edit. Peer to `cilium_key_ports_pins_canonical_value` /
25158 // `cilium_key_from_endpoints_pins_canonical_value` /
25159 // `cilium_key_endpoint_selector_pins_canonical_value` /
25160 // `cilium_key_ingress_pins_canonical_value` /
25161 // `cilium_key_to_ports_pins_canonical_value` on the sibling
25162 // per-CNP-body-axis pin set — begins the per-Gateway-API-
25163 // HTTPRoute-body-axis canonical-string-pin set (`parentRefs`,
25164 // future `hostnames`) the M3 Aplicacao mesh renderer's external
25165 // `:entrada` ingress contract rests on across the Gateway API
25166 // HTTPRoute-side per-route body-shape.
25167 assert_eq!(GATEWAY_API_KEY_PARENT_REFS, "parentRefs");
25168 }
25169
25170 #[test]
25171 fn gateway_api_key_parent_refs_carries_lower_camel_case_shape() {
25172 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25173 // lowerCamelCase identifier per the K8s API conventions
25174 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25175 // "Field names should be lowercase camelCase") — first byte
25176 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25177 // kebab-case or whitespace. Pinning the shape here means a
25178 // future rebrand on the canonical lift can't silently land a
25179 // malformed field-name discriminator (snake_case, kebab-case,
25180 // UpperCamelCase, empty) that the apiserver-side CRD schema
25181 // validator would reject far from the rebrand commit's source.
25182 // Peer to `cilium_key_ports_carries_lower_camel_case_shape` /
25183 // `cilium_key_from_endpoints_carries_lower_camel_case_shape` /
25184 // `cilium_key_endpoint_selector_carries_lower_camel_case_shape`
25185 // / `cilium_key_ingress_carries_lower_camel_case_shape` /
25186 // `cilium_key_to_ports_carries_lower_camel_case_shape` on the
25187 // sibling per-CNP-body-axis grammar-pin set — the lowerCamelCase
25188 // K8s field-name grammar governs every nested schema-field axis
25189 // (including this per-HTTPRoute parent-Gateway-binding-
25190 // container-axis key), same convention.
25191 let v = GATEWAY_API_KEY_PARENT_REFS;
25192 assert!(
25193 !v.is_empty(),
25194 "GATEWAY_API_KEY_PARENT_REFS {v:?} must be non-empty per the K8s API \
25195 lowerCamelCase field-name grammar"
25196 );
25197 let first = v.chars().next().expect("non-empty");
25198 assert!(
25199 first.is_ascii_lowercase(),
25200 "GATEWAY_API_KEY_PARENT_REFS {v:?} first byte {first:?} must be \
25201 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25202 grammar (field names are always lowerCamelCase)"
25203 );
25204 assert!(
25205 v.chars().all(|c| c.is_ascii_alphanumeric()),
25206 "GATEWAY_API_KEY_PARENT_REFS {v:?} must be ASCII-alphanumeric \
25207 throughout per the K8s API field-name grammar — no \
25208 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25209 OpenAPI schema validator would reject"
25210 );
25211 }
25212
25213 #[test]
25214 fn gateway_api_key_backend_refs_pins_canonical_value() {
25215 // Pin the actual string so a typo in this lift can't silently
25216 // rebrand the Gateway API `HTTPRoute` per-rule backend-destination
25217 // container-axis key the rendered HTTPRoute document mounts its
25218 // per-rule `[{name, port}]` backend fan-out list under. The
25219 // string is part of the cluster-side contract with every
25220 // Gateway-API-conformant gateway implementation (Cilium, Istio,
25221 // Envoy Gateway, NGINX) — the Gateway-API-implementation-side
25222 // per-rule L7 dispatch loop keys off this axis to source the
25223 // per-rule backend list the request is forwarded to; a drifted
25224 // value (`"backendRef"` / `"backends"` / `"forwardTo"`) at
25225 // either the production emitter or a downstream renderer's
25226 // per-rule backend-destination upsert silently emits an
25227 // `HTTPRoute` whose per-rule backend fan-out axis the Gateway
25228 // API CRD schema validator drops as unknown — no backend is
25229 // picked at the per-rule L7 dispatch, and every external
25230 // `:entrada` request the rule was authored to route drops at
25231 // the gateway-class-controller's per-rule reconcile with no
25232 // field naming the backend-destination-drift root cause.
25233 // Changing this value is a coordinated Gateway API promotion
25234 // alongside the upstream SIG-Network Gateway API deprecation
25235 // cycle, not an incidental edit. Peer to
25236 // `gateway_api_key_parent_refs_pins_canonical_value` on the
25237 // sibling per-HTTPRoute-body-axis canonical-string-pin surface
25238 // — extends the per-Gateway-API-HTTPRoute-body-axis pin set
25239 // (`parentRefs`, `backendRefs`, future `hostnames`) the M3
25240 // Aplicacao mesh renderer's external `:entrada` ingress
25241 // contract rests on across the Gateway API HTTPRoute-side per-
25242 // route body-shape.
25243 assert_eq!(GATEWAY_API_KEY_BACKEND_REFS, "backendRefs");
25244 }
25245
25246 #[test]
25247 fn gateway_api_key_backend_refs_carries_lower_camel_case_shape() {
25248 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25249 // lowerCamelCase identifier per the K8s API conventions
25250 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25251 // "Field names should be lowercase camelCase") — first byte
25252 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25253 // kebab-case or whitespace. Pinning the shape here means a
25254 // future rebrand on the canonical lift can't silently land a
25255 // malformed field-name discriminator (snake_case, kebab-case,
25256 // UpperCamelCase, empty) that the apiserver-side CRD schema
25257 // validator would reject far from the rebrand commit's source.
25258 // Peer to `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
25259 // on the sibling per-HTTPRoute-body-axis grammar-pin surface —
25260 // the lowerCamelCase K8s field-name grammar governs every
25261 // nested schema-field axis (including this per-rule backend-
25262 // destination-container-axis key), same convention.
25263 let v = GATEWAY_API_KEY_BACKEND_REFS;
25264 assert!(
25265 !v.is_empty(),
25266 "GATEWAY_API_KEY_BACKEND_REFS {v:?} must be non-empty per the K8s API \
25267 lowerCamelCase field-name grammar"
25268 );
25269 let first = v.chars().next().expect("non-empty");
25270 assert!(
25271 first.is_ascii_lowercase(),
25272 "GATEWAY_API_KEY_BACKEND_REFS {v:?} first byte {first:?} must be \
25273 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25274 grammar (field names are always lowerCamelCase)"
25275 );
25276 assert!(
25277 v.chars().all(|c| c.is_ascii_alphanumeric()),
25278 "GATEWAY_API_KEY_BACKEND_REFS {v:?} must be ASCII-alphanumeric \
25279 throughout per the K8s API field-name grammar — no \
25280 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25281 OpenAPI schema validator would reject"
25282 );
25283 }
25284
25285 #[test]
25286 fn gateway_api_key_matches_pins_canonical_value() {
25287 // Pin the actual string so a typo in this lift can't silently
25288 // rebrand the Gateway API `HTTPRoute` per-rule route-match
25289 // container-axis key the rendered HTTPRoute document mounts
25290 // its per-rule `[{path: {type, value}}]` route-match fan-out
25291 // list under. The string is part of the cluster-side contract
25292 // with every Gateway-API-conformant gateway implementation
25293 // (Cilium, Istio, Envoy Gateway, NGINX) — the Gateway-API-
25294 // implementation-side per-rule L7 dispatch loop keys off this
25295 // axis to source the per-rule request-selection predicate the
25296 // incoming request line + headers + query must satisfy for
25297 // the rule's backend fan-out to apply; a drifted value
25298 // (`"match"` / `"routeMatches"` / `"predicates"`) at either
25299 // the production emitter or a downstream renderer's per-rule
25300 // route-match upsert silently emits an `HTTPRoute` whose per-
25301 // rule request-selection axis the Gateway API CRD schema
25302 // validator drops as unknown — the per-rule predicate
25303 // degrades to the wildcard match at the gateway-class-
25304 // controller's per-rule reconcile, the rule matches every
25305 // request unconditionally, and every external `:entrada` path
25306 // filter the rule was authored to enforce drops with no field
25307 // naming the route-match-drift root cause. Changing this
25308 // value is a coordinated Gateway API promotion alongside the
25309 // upstream SIG-Network Gateway API deprecation cycle, not an
25310 // incidental edit. Peer to
25311 // `gateway_api_key_backend_refs_pins_canonical_value` /
25312 // `gateway_api_key_parent_refs_pins_canonical_value` on the
25313 // sibling per-HTTPRoute-body-axis canonical-string-pin
25314 // surface — completes the per-rule top-level-axis pin set
25315 // (`matches`, `backendRefs`, `timeouts`, `retry`) the M3
25316 // Aplicacao mesh renderer's external `:entrada` ingress
25317 // contract rests on across the Gateway API HTTPRoute per-rule
25318 // body-shape.
25319 assert_eq!(GATEWAY_API_KEY_MATCHES, "matches");
25320 }
25321
25322 #[test]
25323 fn gateway_api_key_matches_carries_lower_camel_case_shape() {
25324 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25325 // lowerCamelCase identifier per the K8s API conventions
25326 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25327 // "Field names should be lowercase camelCase") — first byte
25328 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25329 // kebab-case or whitespace. Pinning the shape here means a
25330 // future rebrand on the canonical lift can't silently land a
25331 // malformed field-name discriminator (snake_case, kebab-case,
25332 // UpperCamelCase, empty) that the apiserver-side CRD schema
25333 // validator would reject far from the rebrand commit's source.
25334 // Peer to `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
25335 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
25336 // on the sibling per-HTTPRoute-body-axis grammar-pin surface —
25337 // the lowerCamelCase K8s field-name grammar governs every
25338 // nested schema-field axis (including this per-rule route-
25339 // match-container-axis key), same convention.
25340 let v = GATEWAY_API_KEY_MATCHES;
25341 assert!(
25342 !v.is_empty(),
25343 "GATEWAY_API_KEY_MATCHES {v:?} must be non-empty per the K8s API \
25344 lowerCamelCase field-name grammar"
25345 );
25346 let first = v.chars().next().expect("non-empty");
25347 assert!(
25348 first.is_ascii_lowercase(),
25349 "GATEWAY_API_KEY_MATCHES {v:?} first byte {first:?} must be \
25350 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25351 grammar (field names are always lowerCamelCase)"
25352 );
25353 assert!(
25354 v.chars().all(|c| c.is_ascii_alphanumeric()),
25355 "GATEWAY_API_KEY_MATCHES {v:?} must be ASCII-alphanumeric \
25356 throughout per the K8s API field-name grammar — no \
25357 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25358 OpenAPI schema validator would reject"
25359 );
25360 }
25361
25362 #[test]
25363 fn gateway_api_key_gateway_class_name_pins_canonical_value() {
25364 // Pin the actual string so a typo in this lift can't silently
25365 // rebrand the Gateway API `Gateway` per-Gateway controller-
25366 // binding scalar-axis key the rendered Gateway document
25367 // mounts its per-Gateway `GatewayClass.metadata.name`
25368 // reference under. The string is part of the cluster-side
25369 // contract with every Gateway-API-conformant gateway
25370 // implementation (Cilium, Istio, Envoy Gateway, NGINX) —
25371 // the Gateway-API-implementation-side per-Gateway reconcile
25372 // loop keys off this axis to source the `GatewayClass`
25373 // reference the per-Gateway controller-name-lookup dispatch
25374 // resolves; a drifted value (`"gatewayClass"` /
25375 // `"className"` / `"gatewayClassRef"`) at the production
25376 // emitter silently emits a `Gateway` whose controller-binding
25377 // scalar-axis the Gateway API CRD schema validator drops as
25378 // unknown — no `GatewayClass` is resolved, no `controllerName`
25379 // is looked up, and every external `:entrada` flow the
25380 // Gateway was authored to accept drops at the gateway-class-
25381 // controller's per-Gateway reconcile with no field naming
25382 // the controller-binding-drift root cause. Changing this
25383 // value is a coordinated Gateway API promotion alongside
25384 // the upstream SIG-Network Gateway API deprecation cycle,
25385 // not an incidental edit. Peer to
25386 // `gateway_api_key_listeners_pins_canonical_value` /
25387 // `gateway_api_key_hostname_pins_canonical_value` on the
25388 // sibling per-Gateway-body-axis canonical-string-pin
25389 // surface — completes the per-Gateway-body-axis top-level-
25390 // axis pin set (`gatewayClassName`, `listeners`) the M3
25391 // Aplicacao mesh renderer's external `:entrada` ingress
25392 // contract rests on. Sibling of the peer
25393 // `default_gateway_class_name_pins_canonical_value` on the
25394 // canonical-Gateway-API-`(key, value)`-pair-lift surface
25395 // this lift closes the KEY half of.
25396 assert_eq!(GATEWAY_API_KEY_GATEWAY_CLASS_NAME, "gatewayClassName");
25397 }
25398
25399 #[test]
25400 fn gateway_api_key_gateway_class_name_carries_lower_camel_case_shape() {
25401 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25402 // lowerCamelCase identifier per the K8s API conventions
25403 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25404 // "Field names should be lowercase camelCase") — first byte
25405 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25406 // kebab-case or whitespace. Pinning the shape here means a
25407 // future rebrand on the canonical lift can't silently land a
25408 // malformed field-name discriminator (snake_case, kebab-case,
25409 // UpperCamelCase, empty) that the apiserver-side CRD schema
25410 // validator would reject far from the rebrand commit's source.
25411 // Peer to `gateway_api_key_listeners_carries_lower_camel_case_shape`
25412 // / `gateway_api_key_matches_carries_lower_camel_case_shape`
25413 // on the sibling per-Gateway / per-HTTPRoute-body-axis
25414 // grammar-pin surface — the lowerCamelCase K8s field-name
25415 // grammar governs every nested schema-field axis (including
25416 // this per-Gateway controller-binding scalar-axis key), same
25417 // convention.
25418 let v = GATEWAY_API_KEY_GATEWAY_CLASS_NAME;
25419 assert!(
25420 !v.is_empty(),
25421 "GATEWAY_API_KEY_GATEWAY_CLASS_NAME {v:?} must be non-empty per the K8s API \
25422 lowerCamelCase field-name grammar"
25423 );
25424 let first = v.chars().next().expect("non-empty");
25425 assert!(
25426 first.is_ascii_lowercase(),
25427 "GATEWAY_API_KEY_GATEWAY_CLASS_NAME {v:?} first byte {first:?} must be \
25428 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25429 grammar (field names are always lowerCamelCase)"
25430 );
25431 assert!(
25432 v.chars().all(|c| c.is_ascii_alphanumeric()),
25433 "GATEWAY_API_KEY_GATEWAY_CLASS_NAME {v:?} must be ASCII-alphanumeric \
25434 throughout per the K8s API field-name grammar — no \
25435 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25436 OpenAPI schema validator would reject"
25437 );
25438 }
25439
25440 #[test]
25441 fn gateway_api_key_path_pins_canonical_value() {
25442 // Pin the actual string so a typo in this lift can't silently
25443 // rebrand the Gateway API `HTTPRoute` per-`HTTPRouteMatch`
25444 // path-matcher container-axis key the rendered HTTPRoute
25445 // document mounts its per-match `{type, value}` path-selection
25446 // predicate under. The string is part of the cluster-side
25447 // contract with every Gateway-API-conformant gateway
25448 // implementation (Cilium, Istio, Envoy Gateway, NGINX) — the
25449 // Gateway-API-implementation-side per-rule L7 dispatch loop
25450 // keys off this axis to source the per-match request-path-
25451 // selection predicate the incoming request line's `:path`
25452 // pseudo-header must satisfy under a `type` discriminator of
25453 // `Exact | PathPrefix | RegularExpression`; a drifted value
25454 // (`"pathMatch"` / `"prefix"` / `"url"`) at the production
25455 // emitter silently emits an `HTTPRoute` whose per-match path-
25456 // selection axis the Gateway API CRD schema validator drops
25457 // as unknown — the per-match path predicate degrades to the
25458 // wildcard match at the gateway-class-controller's per-rule
25459 // reconcile, the rule matches every request path
25460 // unconditionally, and every external `:entrada` path filter
25461 // the rule was authored to enforce drops with no field
25462 // naming the path-matcher-drift root cause. Changing this
25463 // value is a coordinated Gateway API promotion alongside the
25464 // upstream SIG-Network Gateway API deprecation cycle, not an
25465 // incidental edit. Peer to
25466 // `gateway_api_key_matches_pins_canonical_value` /
25467 // `gateway_api_key_backend_refs_pins_canonical_value` on the
25468 // sibling per-HTTPRoute-body-axis canonical-string-pin
25469 // surface — nests the per-Gateway-API-HTTPRoute-per-rule-
25470 // body-axis pin set (`matches`, `backendRefs`, `timeouts`,
25471 // `retry`) one level deeper onto the per-`HTTPRouteMatch`
25472 // body-axis surface the M3 Aplicacao mesh renderer's external
25473 // `:entrada` ingress contract rests on.
25474 assert_eq!(GATEWAY_API_KEY_PATH, "path");
25475 }
25476
25477 #[test]
25478 fn gateway_api_key_path_carries_lower_camel_case_shape() {
25479 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25480 // lowerCamelCase identifier per the K8s API conventions
25481 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25482 // "Field names should be lowercase camelCase") — first byte
25483 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25484 // kebab-case or whitespace. Pinning the shape here means a
25485 // future rebrand on the canonical lift can't silently land a
25486 // malformed field-name discriminator (snake_case, kebab-case,
25487 // UpperCamelCase, empty) that the apiserver-side CRD schema
25488 // validator would reject far from the rebrand commit's source.
25489 // Peer to `gateway_api_key_matches_carries_lower_camel_case_shape`
25490 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
25491 // on the sibling per-HTTPRoute-body-axis grammar-pin surface —
25492 // the lowerCamelCase K8s field-name grammar governs every
25493 // nested schema-field axis (including this per-`HTTPRouteMatch`
25494 // path-matcher-container-axis key), same convention.
25495 let v = GATEWAY_API_KEY_PATH;
25496 assert!(
25497 !v.is_empty(),
25498 "GATEWAY_API_KEY_PATH {v:?} must be non-empty per the K8s API \
25499 lowerCamelCase field-name grammar"
25500 );
25501 let first = v.chars().next().expect("non-empty");
25502 assert!(
25503 first.is_ascii_lowercase(),
25504 "GATEWAY_API_KEY_PATH {v:?} first byte {first:?} must be \
25505 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25506 grammar (field names are always lowerCamelCase)"
25507 );
25508 assert!(
25509 v.chars().all(|c| c.is_ascii_alphanumeric()),
25510 "GATEWAY_API_KEY_PATH {v:?} must be ASCII-alphanumeric \
25511 throughout per the K8s API field-name grammar — no \
25512 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25513 OpenAPI schema validator would reject"
25514 );
25515 }
25516
25517 #[test]
25518 fn gateway_api_key_value_pins_canonical_value() {
25519 // Pin the actual string so a typo in this lift can't silently
25520 // rebrand the Gateway API `HTTPPathMatch` scalar-payload axis
25521 // key the rendered `HTTPRoute` document mounts its per-match
25522 // request-path-selection scalar payload under. The string is
25523 // part of the cluster-side contract with every Gateway-API-
25524 // conformant gateway implementation (Cilium, Istio, Envoy
25525 // Gateway, NGINX) — the Gateway-API-implementation-side per-
25526 // rule L7 dispatch loop keys off this axis to source the
25527 // per-match request-path string that the sibling `type`
25528 // discriminator (Exact | PathPrefix | RegularExpression) is
25529 // applied against; a drifted value (`"path"` / `"prefix"` /
25530 // `"pattern"` / `"expression"`) at the production emitter
25531 // silently emits an `HTTPRoute` whose per-match request-path
25532 // scalar the Gateway API CRD schema validator drops as
25533 // unknown — the per-match path predicate degrades to the
25534 // wildcard match at the gateway-class-controller's per-rule
25535 // reconcile, the rule matches every request path
25536 // unconditionally, and every external `:entrada` path filter
25537 // the rule was authored to enforce drops with no field
25538 // naming the `HTTPPathMatch`-scalar-payload-drift root cause.
25539 // Changing this value is a coordinated Gateway API promotion
25540 // alongside the upstream SIG-Network Gateway API deprecation
25541 // cycle, not an incidental edit. Peer to
25542 // `gateway_api_key_path_pins_canonical_value` on the sibling
25543 // per-`HTTPRouteMatch`-body-axis canonical-string-pin surface
25544 // — nests the per-Gateway-API-HTTPRoute-per-match-body-axis
25545 // pin set (`path` container-axis, `value` scalar-payload key)
25546 // one level deeper onto the per-`HTTPPathMatch` body-axis
25547 // surface the M3 Aplicacao mesh renderer's external `:entrada`
25548 // ingress contract rests on.
25549 assert_eq!(GATEWAY_API_KEY_VALUE, "value");
25550 }
25551
25552 #[test]
25553 fn gateway_api_key_value_carries_lower_camel_case_shape() {
25554 // Cross-axis invariant: a Kubernetes CRD schema field name is
25555 // a lowerCamelCase identifier per the K8s API conventions
25556 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25557 // "Field names should be lowercase camelCase") — first byte
25558 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25559 // kebab-case or whitespace. Pinning the shape here means a
25560 // future rebrand on the canonical lift can't silently land a
25561 // malformed field-name discriminator (snake_case, kebab-case,
25562 // UpperCamelCase, empty) that the apiserver-side CRD schema
25563 // validator would reject far from the rebrand commit's source.
25564 // Peer to `gateway_api_key_path_carries_lower_camel_case_shape`
25565 // on the sibling per-`HTTPRouteMatch`-body-axis grammar-pin
25566 // surface — the lowerCamelCase K8s field-name grammar governs
25567 // every nested schema-field axis (including this per-
25568 // `HTTPPathMatch` scalar-payload-axis key), same convention.
25569 let v = GATEWAY_API_KEY_VALUE;
25570 assert!(
25571 !v.is_empty(),
25572 "GATEWAY_API_KEY_VALUE {v:?} must be non-empty per the K8s API \
25573 lowerCamelCase field-name grammar"
25574 );
25575 let first = v.chars().next().expect("non-empty");
25576 assert!(
25577 first.is_ascii_lowercase(),
25578 "GATEWAY_API_KEY_VALUE {v:?} first byte {first:?} must be \
25579 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25580 grammar (field names are always lowerCamelCase)"
25581 );
25582 assert!(
25583 v.chars().all(|c| c.is_ascii_alphanumeric()),
25584 "GATEWAY_API_KEY_VALUE {v:?} must be ASCII-alphanumeric \
25585 throughout per the K8s API field-name grammar — no \
25586 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25587 OpenAPI schema validator would reject"
25588 );
25589 }
25590
25591 #[test]
25592 fn gateway_api_key_value_distinct_from_gateway_api_key_path() {
25593 // Cross-axis invariant: the `HTTPPathMatch` scalar-payload key
25594 // (`value`) and its parent-container-axis key (`path`) name
25595 // *distinct* Gateway-API-side schema fields — the parent is a
25596 // container that hangs off the per-`HTTPRouteMatch`
25597 // `matches[]` entry, the child is the scalar payload that
25598 // rides inside the parent's `{type, value}` two-axis body.
25599 // Under the sibling K8s API conventions grammar
25600 // (`gateway_api_key_value_carries_lower_camel_case_shape` /
25601 // `gateway_api_key_path_carries_lower_camel_case_shape`) both
25602 // are ASCII-lowerCamelCase identifiers, so a same-shape
25603 // grammar-pin alone doesn't prevent a future rebrand from
25604 // silently collapsing the two axes onto the same string —
25605 // pinning inequality here surfaces that footgun at exactly
25606 // this build-time lift instead of at apply time as an
25607 // `HTTPRoute` whose per-match `path` container-body is
25608 // structurally malformed (`{path: <str>, path: <str>}` — the
25609 // apiserver's OpenAPI schema validator drops the whole match
25610 // block, the per-match path predicate degrades to the
25611 // wildcard match at the gateway-class-controller's per-rule
25612 // reconcile, the rule matches every request path
25613 // unconditionally, and every external `:entrada` path filter
25614 // the rule was authored to enforce drops with no field
25615 // naming the container/scalar-collapse root cause).
25616 assert_ne!(
25617 GATEWAY_API_KEY_VALUE, GATEWAY_API_KEY_PATH,
25618 "GATEWAY_API_KEY_VALUE ({GATEWAY_API_KEY_VALUE:?}) must not \
25619 collapse onto GATEWAY_API_KEY_PATH ({GATEWAY_API_KEY_PATH:?}) \
25620 — the two name distinct Gateway API `HTTPPathMatch` axes \
25621 (parent container vs. inner scalar payload) that must \
25622 remain independently addressable in the emitted \
25623 `HTTPRoute` per-match body"
25624 );
25625 }
25626
25627 #[test]
25628 fn gateway_api_key_listeners_pins_canonical_value() {
25629 // Pin the actual string so a typo in this lift can't silently
25630 // rebrand the Gateway API `Gateway` per-listener-set container-
25631 // axis key the rendered Gateway document mounts its per-Gateway
25632 // `[{name, port, protocol, hostname}]` L7-listener fan-out list
25633 // under. The string is part of the cluster-side contract with
25634 // every Gateway-API-conformant gateway implementation (Cilium,
25635 // Istio, Envoy Gateway, NGINX) — the Gateway-API-implementation-
25636 // side per-Gateway reconcile loop keys off this axis to source
25637 // the per-Gateway L7-listener fan-out the external `:entrada`
25638 // flow the Gateway was authored to accept lands on; a drifted
25639 // value (`"listener"` / `"listen"` / `"servers"`) at either the
25640 // production emitter or a downstream renderer's per-Gateway L7-
25641 // listener-set upsert silently emits a `Gateway` whose L7-
25642 // listener-set axis the Gateway API CRD schema validator drops
25643 // as unknown — no listener is opened, and every external
25644 // `:entrada` flow drops at the gateway-class-controller's per-
25645 // Gateway reconcile with no field naming the L7-listener-set-
25646 // drift root cause. Changing this value is a coordinated
25647 // Gateway API promotion alongside the upstream SIG-Network
25648 // Gateway API deprecation cycle, not an incidental edit. Peer
25649 // to `gateway_api_key_parent_refs_pins_canonical_value` /
25650 // `gateway_api_key_backend_refs_pins_canonical_value` on the
25651 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
25652 // surface — extends the per-Gateway-API-CRD-body-axis pin set
25653 // (`parentRefs`, `backendRefs`, `listeners`, future
25654 // `hostnames`) the M3 Aplicacao mesh renderer's external
25655 // `:entrada` ingress contract rests on across the Gateway API
25656 // CRD-side body-shape.
25657 assert_eq!(GATEWAY_API_KEY_LISTENERS, "listeners");
25658 }
25659
25660 #[test]
25661 fn gateway_api_key_listeners_carries_lower_camel_case_shape() {
25662 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25663 // lowerCamelCase identifier per the K8s API conventions
25664 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25665 // "Field names should be lowercase camelCase") — first byte
25666 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25667 // kebab-case or whitespace. Pinning the shape here means a
25668 // future rebrand on the canonical lift can't silently land a
25669 // malformed field-name discriminator (snake_case, kebab-case,
25670 // UpperCamelCase, empty) that the apiserver-side CRD schema
25671 // validator would reject far from the rebrand commit's source.
25672 // Peer to `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
25673 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
25674 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
25675 // surface — the lowerCamelCase K8s field-name grammar governs
25676 // every nested schema-field axis (including this per-Gateway
25677 // L7-listener-set-container-axis key), same convention.
25678 let v = GATEWAY_API_KEY_LISTENERS;
25679 assert!(
25680 !v.is_empty(),
25681 "GATEWAY_API_KEY_LISTENERS {v:?} must be non-empty per the K8s API \
25682 lowerCamelCase field-name grammar"
25683 );
25684 let first = v.chars().next().expect("non-empty");
25685 assert!(
25686 first.is_ascii_lowercase(),
25687 "GATEWAY_API_KEY_LISTENERS {v:?} first byte {first:?} must be \
25688 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25689 grammar (field names are always lowerCamelCase)"
25690 );
25691 assert!(
25692 v.chars().all(|c| c.is_ascii_alphanumeric()),
25693 "GATEWAY_API_KEY_LISTENERS {v:?} must be ASCII-alphanumeric \
25694 throughout per the K8s API field-name grammar — no \
25695 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25696 OpenAPI schema validator would reject"
25697 );
25698 }
25699
25700 #[test]
25701 fn gateway_api_key_hostname_pins_canonical_value() {
25702 // Pin the actual string so a typo in this lift can't silently
25703 // rebrand the Gateway API `Gateway` per-listener DNS-host-
25704 // discriminator axis key the rendered Gateway document mounts
25705 // each listener's virtual-host filter under. The string is part
25706 // of the cluster-side contract with every Gateway-API-conformant
25707 // gateway implementation (Cilium, Istio, Envoy Gateway, NGINX) —
25708 // the Gateway-API-implementation-side per-listener SNI /
25709 // `Host:`-header dispatch loop keys off this axis to source the
25710 // per-listener virtual-host filter each listener's inbound
25711 // traffic is scoped against; a drifted value (`"host"` /
25712 // `"vhost"` / `"serverName"`) at either the production emitter
25713 // or a downstream renderer's per-listener DNS-host-discriminator
25714 // upsert silently emits a `Gateway` whose per-listener virtual-
25715 // host filter axis the Gateway API CRD schema validator drops as
25716 // unknown — the listener accepts traffic on the wildcard host
25717 // rather than the typed `:entrada :host` the Aplicacao author
25718 // declared, and every external `:entrada` flow the listener was
25719 // authored to accept lands on the wrong virtual-host filter with
25720 // no field naming the DNS-host-discriminator-drift root cause.
25721 // Changing this value is a coordinated Gateway API promotion
25722 // alongside the upstream SIG-Network Gateway API deprecation
25723 // cycle, not an incidental edit. Peer to
25724 // `gateway_api_key_listeners_pins_canonical_value` /
25725 // `gateway_api_key_parent_refs_pins_canonical_value` /
25726 // `gateway_api_key_backend_refs_pins_canonical_value` on the
25727 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
25728 // surface — nests the per-Gateway-API-CRD-body-axis pin
25729 // discipline one level deeper onto the sibling per-listener
25730 // body-axis surface, extending the per-Gateway-API-CRD-body-
25731 // axis pin set (`parentRefs`, `backendRefs`, `listeners`,
25732 // `hostname`, future `hostnames`) the M3 Aplicacao mesh
25733 // renderer's external `:entrada` ingress contract rests on
25734 // across the Gateway API CRD-side body-shape.
25735 assert_eq!(GATEWAY_API_KEY_HOSTNAME, "hostname");
25736 }
25737
25738 #[test]
25739 fn gateway_api_key_hostname_carries_lower_camel_case_shape() {
25740 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25741 // lowerCamelCase identifier per the K8s API conventions
25742 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25743 // "Field names should be lowercase camelCase") — first byte
25744 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25745 // kebab-case or whitespace. Pinning the shape here means a
25746 // future rebrand on the canonical lift can't silently land a
25747 // malformed field-name discriminator (snake_case, kebab-case,
25748 // UpperCamelCase, empty) that the apiserver-side CRD schema
25749 // validator would reject far from the rebrand commit's source.
25750 // Peer to `gateway_api_key_listeners_carries_lower_camel_case_shape`
25751 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
25752 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
25753 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
25754 // surface — the lowerCamelCase K8s field-name grammar governs
25755 // every nested schema-field axis (including this per-listener
25756 // DNS-host-discriminator-axis key), same convention.
25757 let v = GATEWAY_API_KEY_HOSTNAME;
25758 assert!(
25759 !v.is_empty(),
25760 "GATEWAY_API_KEY_HOSTNAME {v:?} must be non-empty per the K8s API \
25761 lowerCamelCase field-name grammar"
25762 );
25763 let first = v.chars().next().expect("non-empty");
25764 assert!(
25765 first.is_ascii_lowercase(),
25766 "GATEWAY_API_KEY_HOSTNAME {v:?} first byte {first:?} must be \
25767 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25768 grammar (field names are always lowerCamelCase)"
25769 );
25770 assert!(
25771 v.chars().all(|c| c.is_ascii_alphanumeric()),
25772 "GATEWAY_API_KEY_HOSTNAME {v:?} must be ASCII-alphanumeric \
25773 throughout per the K8s API field-name grammar — no \
25774 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25775 OpenAPI schema validator would reject"
25776 );
25777 }
25778
25779 #[test]
25780 fn gateway_api_key_hostnames_pins_canonical_value() {
25781 // Pin the actual string so a typo in this lift can't silently
25782 // rebrand the Gateway API `HTTPRoute` spec-level DNS-host-filter
25783 // axis key the rendered HTTPRoute document mounts each route's
25784 // per-route virtual-host filter list under. The string is part
25785 // of the cluster-side contract with every Gateway-API-conformant
25786 // gateway implementation (Cilium, Istio, Envoy Gateway, NGINX) —
25787 // the Gateway-API-implementation-side per-route SNI /
25788 // `Host:`-header dispatch loop keys off this axis to source the
25789 // per-route virtual-host filter list each route's inbound
25790 // traffic is scoped against; a drifted value (`"hosts"` /
25791 // `"vhosts"` / `"serverNames"`) at either the production emitter
25792 // or a downstream renderer's per-route DNS-host-filter upsert
25793 // silently emits an `HTTPRoute` whose per-route virtual-host
25794 // filter axis the Gateway API CRD schema validator drops as
25795 // unknown — the route accepts traffic on every host the parent
25796 // Gateway's listener accepts rather than the typed `:entrada
25797 // :host` the Aplicacao author declared, and every external
25798 // `:entrada` flow the route was authored to accept lands on the
25799 // wildcard virtual-host filter with no field naming the DNS-
25800 // host-filter-drift root cause. Changing this value is a
25801 // coordinated Gateway API promotion alongside the upstream
25802 // SIG-Network Gateway API deprecation cycle, not an incidental
25803 // edit. Peer to
25804 // `gateway_api_key_hostname_pins_canonical_value` /
25805 // `gateway_api_key_listeners_pins_canonical_value` /
25806 // `gateway_api_key_parent_refs_pins_canonical_value` /
25807 // `gateway_api_key_backend_refs_pins_canonical_value` on the
25808 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
25809 // surface — closes the per-Gateway-API-CRD `HTTPRoute` per-route
25810 // body-axis pin pair across the singular / plural DNS-host
25811 // discriminator surface (`hostname` at the parent-Gateway per-
25812 // listener discriminator + `hostnames` at the child HTTPRoute
25813 // per-route filter list), so both halves of the DNS-host-
25814 // discriminator convention across the `(Gateway, HTTPRoute)`
25815 // pair the M3 Aplicacao mesh renderer's external `:entrada`
25816 // ingress contract emits together now carry one lifted
25817 // canonical-string pin apiece.
25818 assert_eq!(GATEWAY_API_KEY_HOSTNAMES, "hostnames");
25819 }
25820
25821 #[test]
25822 fn gateway_api_key_hostnames_carries_lower_camel_case_shape() {
25823 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25824 // lowerCamelCase identifier per the K8s API conventions
25825 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25826 // "Field names should be lowercase camelCase") — first byte
25827 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25828 // kebab-case or whitespace. Pinning the shape here means a
25829 // future rebrand on the canonical lift can't silently land a
25830 // malformed field-name discriminator (snake_case, kebab-case,
25831 // UpperCamelCase, empty) that the apiserver-side CRD schema
25832 // validator would reject far from the rebrand commit's source.
25833 // Peer to `gateway_api_key_hostname_carries_lower_camel_case_shape`
25834 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
25835 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
25836 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
25837 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
25838 // surface — the lowerCamelCase K8s field-name grammar governs
25839 // every nested schema-field axis (including this per-route DNS-
25840 // host-filter-axis key), same convention.
25841 let v = GATEWAY_API_KEY_HOSTNAMES;
25842 assert!(
25843 !v.is_empty(),
25844 "GATEWAY_API_KEY_HOSTNAMES {v:?} must be non-empty per the K8s API \
25845 lowerCamelCase field-name grammar"
25846 );
25847 let first = v.chars().next().expect("non-empty");
25848 assert!(
25849 first.is_ascii_lowercase(),
25850 "GATEWAY_API_KEY_HOSTNAMES {v:?} first byte {first:?} must be \
25851 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25852 grammar (field names are always lowerCamelCase)"
25853 );
25854 assert!(
25855 v.chars().all(|c| c.is_ascii_alphanumeric()),
25856 "GATEWAY_API_KEY_HOSTNAMES {v:?} must be ASCII-alphanumeric \
25857 throughout per the K8s API field-name grammar — no \
25858 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25859 OpenAPI schema validator would reject"
25860 );
25861 }
25862
25863 #[test]
25864 fn gateway_api_key_timeouts_pins_canonical_value() {
25865 // Pin the actual string so a typo in this lift can't silently
25866 // rebrand the Gateway API `HTTPRoute` per-rule request-timeout-
25867 // policy body-axis key the rendered HTTPRoute document mounts
25868 // each rule's per-rule `:politicas :timeout` overlay under. The
25869 // string is part of the cluster-side contract with every
25870 // Gateway-API-conformant gateway implementation (Cilium, Istio,
25871 // Envoy Gateway, NGINX) — the Gateway-API-implementation-side
25872 // per-rule request-dispatch loop keys off this axis to source
25873 // the per-rule wall-clock deadline each accepted request is
25874 // bounded against; a drifted value (`"timeout"` (singular) /
25875 // `"timeoutPolicy"` / `"deadlines"`) at either the production
25876 // emitter or a downstream renderer's per-rule timeout-policy
25877 // upsert silently emits an `HTTPRoute` whose per-rule request-
25878 // timeout policy axis the Gateway API CRD schema validator
25879 // drops as unknown — the route accepts every inbound request
25880 // with no per-rule wall-clock deadline (the "no infinite
25881 // blocking" guarantee MESH-COMPOSITION.md §V mandates for every
25882 // rendered per-`:politicas` mesh-composition edge silently
25883 // regresses to the pre-overlay unbounded-request semantic), and
25884 // every external `:entrada` flow the route was authored to
25885 // bound by the typed `:politicas :timeout` slot runs to
25886 // whatever backend deadline the resolved backend's downstream
25887 // infrastructure picks with no field naming the per-rule-
25888 // timeout-policy-drift root cause. Changing this value is a
25889 // coordinated Gateway API promotion alongside the upstream
25890 // SIG-Network Gateway API deprecation cycle, not an incidental
25891 // edit. Peer to
25892 // `gateway_api_key_hostnames_pins_canonical_value` /
25893 // `gateway_api_key_hostname_pins_canonical_value` /
25894 // `gateway_api_key_listeners_pins_canonical_value` /
25895 // `gateway_api_key_parent_refs_pins_canonical_value` /
25896 // `gateway_api_key_backend_refs_pins_canonical_value` on the
25897 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
25898 // surface — extends the per-Gateway-API-`HTTPRoute` per-rule
25899 // body-axis pin set (`backendRefs`, future per-rule sibling
25900 // axes) onto the load-bearing per-rule request-timeout-policy
25901 // axis the M3 Aplicacao mesh renderer's per-`:politicas
25902 // :timeout` overlay lands under.
25903 assert_eq!(GATEWAY_API_KEY_TIMEOUTS, "timeouts");
25904 }
25905
25906 #[test]
25907 fn gateway_api_key_timeouts_carries_lower_camel_case_shape() {
25908 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25909 // lowerCamelCase identifier per the K8s API conventions
25910 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25911 // "Field names should be lowercase camelCase") — first byte
25912 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25913 // kebab-case or whitespace. Pinning the shape here means a
25914 // future rebrand on the canonical lift can't silently land a
25915 // malformed field-name discriminator (snake_case, kebab-case,
25916 // UpperCamelCase, empty) that the apiserver-side CRD schema
25917 // validator would reject far from the rebrand commit's source.
25918 // Peer to `gateway_api_key_hostnames_carries_lower_camel_case_shape`
25919 // / `gateway_api_key_hostname_carries_lower_camel_case_shape`
25920 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
25921 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
25922 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
25923 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
25924 // surface — the lowerCamelCase K8s field-name grammar governs
25925 // every nested schema-field axis (including this per-rule
25926 // request-timeout-policy-axis key), same convention.
25927 let v = GATEWAY_API_KEY_TIMEOUTS;
25928 assert!(
25929 !v.is_empty(),
25930 "GATEWAY_API_KEY_TIMEOUTS {v:?} must be non-empty per the K8s API \
25931 lowerCamelCase field-name grammar"
25932 );
25933 let first = v.chars().next().expect("non-empty");
25934 assert!(
25935 first.is_ascii_lowercase(),
25936 "GATEWAY_API_KEY_TIMEOUTS {v:?} first byte {first:?} must be \
25937 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25938 grammar (field names are always lowerCamelCase)"
25939 );
25940 assert!(
25941 v.chars().all(|c| c.is_ascii_alphanumeric()),
25942 "GATEWAY_API_KEY_TIMEOUTS {v:?} must be ASCII-alphanumeric \
25943 throughout per the K8s API field-name grammar — no \
25944 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25945 OpenAPI schema validator would reject"
25946 );
25947 }
25948
25949 #[test]
25950 fn gateway_api_key_retry_pins_canonical_value() {
25951 // Pin the actual string so a typo in this lift can't silently
25952 // rebrand the Gateway API `HTTPRoute` per-rule retry-policy
25953 // body-axis key the rendered HTTPRoute document mounts each
25954 // rule's per-rule `:politicas :retries` overlay under. The
25955 // string is part of the cluster-side contract with every
25956 // Gateway-API-conformant gateway implementation (Cilium, Istio,
25957 // Envoy Gateway, NGINX) — the Gateway-API-implementation-side
25958 // per-rule request-dispatch loop keys off this axis to source
25959 // the per-rule retry budget each failed backend attempt count
25960 // is bounded against; a drifted value (`"retries"` (plural) /
25961 // `"retryPolicy"` / `"budget"`) at either the production
25962 // emitter or a downstream renderer's per-rule retry-policy
25963 // upsert silently emits an `HTTPRoute` whose per-rule retry-
25964 // budget axis the Gateway API CRD schema validator drops as
25965 // unknown — the route accepts every inbound request with no
25966 // per-rule retry budget (the "no infinite retrying without
25967 // bound" guarantee MESH-COMPOSITION.md §V mandates for every
25968 // rendered per-`:politicas` mesh-composition edge silently
25969 // regresses to the pre-overlay unbounded-retry semantic), and
25970 // every external `:entrada` flow the route was authored to cap
25971 // by the typed `:politicas :retries` slot runs to whatever
25972 // retry policy the resolved backend's downstream infrastructure
25973 // picks with no field naming the per-rule-retry-policy-drift
25974 // root cause. Changing this value is a coordinated Gateway API
25975 // promotion alongside the upstream SIG-Network Gateway API
25976 // deprecation cycle, not an incidental edit. Peer to
25977 // `gateway_api_key_timeouts_pins_canonical_value` /
25978 // `gateway_api_key_hostnames_pins_canonical_value` /
25979 // `gateway_api_key_hostname_pins_canonical_value` /
25980 // `gateway_api_key_listeners_pins_canonical_value` /
25981 // `gateway_api_key_parent_refs_pins_canonical_value` /
25982 // `gateway_api_key_backend_refs_pins_canonical_value` on the
25983 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
25984 // surface — closes the per-Gateway-API-`HTTPRoute`-per-rule
25985 // `:politicas` overlay axis pair (`timeouts` for `:politicas
25986 // :timeout`, `retry` for `:politicas :retries`) both
25987 // MESH-COMPOSITION.md §V "no infinite blocking / no infinite
25988 // retrying" guarantees rest on.
25989 assert_eq!(GATEWAY_API_KEY_RETRY, "retry");
25990 }
25991
25992 #[test]
25993 fn gateway_api_key_retry_carries_lower_camel_case_shape() {
25994 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25995 // lowerCamelCase identifier per the K8s API conventions
25996 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25997 // "Field names should be lowercase camelCase") — first byte
25998 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25999 // kebab-case or whitespace. Pinning the shape here means a
26000 // future rebrand on the canonical lift can't silently land a
26001 // malformed field-name discriminator (snake_case, kebab-case,
26002 // UpperCamelCase, empty) that the apiserver-side CRD schema
26003 // validator would reject far from the rebrand commit's source.
26004 // Peer to `gateway_api_key_timeouts_carries_lower_camel_case_shape`
26005 // / `gateway_api_key_hostnames_carries_lower_camel_case_shape`
26006 // / `gateway_api_key_hostname_carries_lower_camel_case_shape`
26007 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
26008 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
26009 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
26010 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
26011 // surface — the lowerCamelCase K8s field-name grammar governs
26012 // every nested schema-field axis (including this per-rule
26013 // retry-policy-axis key), same convention.
26014 let v = GATEWAY_API_KEY_RETRY;
26015 assert!(
26016 !v.is_empty(),
26017 "GATEWAY_API_KEY_RETRY {v:?} must be non-empty per the K8s API \
26018 lowerCamelCase field-name grammar"
26019 );
26020 let first = v.chars().next().expect("non-empty");
26021 assert!(
26022 first.is_ascii_lowercase(),
26023 "GATEWAY_API_KEY_RETRY {v:?} first byte {first:?} must be \
26024 ASCII-lowercase per the K8s API lowerCamelCase field-name \
26025 grammar (field names are always lowerCamelCase)"
26026 );
26027 assert!(
26028 v.chars().all(|c| c.is_ascii_alphanumeric()),
26029 "GATEWAY_API_KEY_RETRY {v:?} must be ASCII-alphanumeric \
26030 throughout per the K8s API field-name grammar — no \
26031 snake_case, kebab-case, or whitespace bytes the apiserver-side \
26032 OpenAPI schema validator would reject"
26033 );
26034 }
26035
26036 #[test]
26037 fn gateway_api_key_attempts_pins_canonical_value() {
26038 // Pin the actual string so a typo in this lift can't silently
26039 // rebrand the Gateway API `HTTPRoute` per-rule retry-policy
26040 // `attempts` leaf scalar-key the rendered HTTPRoute document
26041 // mounts each rule's per-rule `:politicas :retries` typed `u32`
26042 // attempt count under. The string is part of the cluster-side
26043 // contract with every Gateway-API-conformant gateway
26044 // implementation (Cilium, Istio, Envoy Gateway, NGINX) — the
26045 // Gateway-API-implementation-side per-rule request-dispatch
26046 // loop keys off this leaf to source the per-rule retry attempt
26047 // budget each failed backend attempt count is bounded against;
26048 // a drifted value (`"attempt"` (singular) / `"count"` /
26049 // `"tries"` / `"maxAttempts"`) at either the production
26050 // emitter or a downstream renderer's per-rule retry-attempts
26051 // upsert silently emits an `HTTPRoute` whose per-rule retry-
26052 // attempts leaf the Gateway API CRD schema validator drops as
26053 // unknown — the retry sub-shape parses as an empty
26054 // `HTTPRouteRetry` with the typed `u32` attempt count silently
26055 // discarded, the route accepts every inbound request with no
26056 // per-rule retry budget (the "no infinite retrying without
26057 // bound" guarantee MESH-COMPOSITION.md §V mandates for every
26058 // rendered per-`:politicas` mesh-composition edge silently
26059 // regresses to the pre-overlay unbounded-retry semantic), and
26060 // every external `:entrada` flow the route was authored to cap
26061 // by the typed `:politicas :retries` slot runs to whatever
26062 // retry policy the resolved backend's downstream infrastructure
26063 // picks with no field naming the per-rule-retry-attempts-leaf-
26064 // key-drift root cause. Changing this value is a coordinated
26065 // Gateway API promotion alongside the upstream SIG-Network
26066 // Gateway API deprecation cycle, not an incidental edit. Peer
26067 // to `gateway_api_key_retry_pins_canonical_value` /
26068 // `gateway_api_key_timeouts_pins_canonical_value` /
26069 // `gateway_api_key_hostnames_pins_canonical_value` /
26070 // `gateway_api_key_hostname_pins_canonical_value` /
26071 // `gateway_api_key_listeners_pins_canonical_value` /
26072 // `gateway_api_key_parent_refs_pins_canonical_value` /
26073 // `gateway_api_key_backend_refs_pins_canonical_value` on the
26074 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
26075 // surface — closes the parent-leaf axis pair (`retry`
26076 // container + `attempts` leaf) both MESH-COMPOSITION.md §V
26077 // "no infinite retrying" guarantees rest on, one nesting
26078 // level deeper than the parent per-rule retry-policy
26079 // container axis (`retry`).
26080 assert_eq!(GATEWAY_API_KEY_ATTEMPTS, "attempts");
26081 }
26082
26083 #[test]
26084 fn gateway_api_key_attempts_carries_lower_camel_case_shape() {
26085 // Cross-axis invariant: a Kubernetes CRD schema field name is a
26086 // lowerCamelCase identifier per the K8s API conventions
26087 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
26088 // "Field names should be lowercase camelCase") — first byte
26089 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
26090 // kebab-case or whitespace. Pinning the shape here means a
26091 // future rebrand on the canonical lift can't silently land a
26092 // malformed field-name discriminator (snake_case, kebab-case,
26093 // UpperCamelCase, empty) that the apiserver-side CRD schema
26094 // validator would reject far from the rebrand commit's source.
26095 // Peer to `gateway_api_key_retry_carries_lower_camel_case_shape`
26096 // / `gateway_api_key_timeouts_carries_lower_camel_case_shape`
26097 // / `gateway_api_key_hostnames_carries_lower_camel_case_shape`
26098 // / `gateway_api_key_hostname_carries_lower_camel_case_shape`
26099 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
26100 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
26101 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
26102 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
26103 // surface — the lowerCamelCase K8s field-name grammar governs
26104 // every nested schema-field axis (including this per-rule
26105 // retry-attempts-leaf-key), same convention.
26106 let v = GATEWAY_API_KEY_ATTEMPTS;
26107 assert!(
26108 !v.is_empty(),
26109 "GATEWAY_API_KEY_ATTEMPTS {v:?} must be non-empty per the K8s API \
26110 lowerCamelCase field-name grammar"
26111 );
26112 let first = v.chars().next().expect("non-empty");
26113 assert!(
26114 first.is_ascii_lowercase(),
26115 "GATEWAY_API_KEY_ATTEMPTS {v:?} first byte {first:?} must be \
26116 ASCII-lowercase per the K8s API lowerCamelCase field-name \
26117 grammar (field names are always lowerCamelCase)"
26118 );
26119 assert!(
26120 v.chars().all(|c| c.is_ascii_alphanumeric()),
26121 "GATEWAY_API_KEY_ATTEMPTS {v:?} must be ASCII-alphanumeric \
26122 throughout per the K8s API field-name grammar — no \
26123 snake_case, kebab-case, or whitespace bytes the apiserver-side \
26124 OpenAPI schema validator would reject"
26125 );
26126 }
26127
26128 #[test]
26129 fn gateway_api_key_request_pins_canonical_value() {
26130 // Pin the actual string so a typo in this lift can't silently
26131 // rebrand the Gateway API `HTTPRoute` per-rule request-timeout-
26132 // policy `request` leaf scalar-key the rendered HTTPRoute
26133 // document mounts each rule's per-rule `:politicas :timeout`
26134 // typed K8s-duration string under. The string is part of the
26135 // cluster-side contract with every Gateway-API-conformant
26136 // gateway implementation (Cilium, Istio, Envoy Gateway, NGINX)
26137 // — the Gateway-API-implementation-side per-rule request-
26138 // dispatch loop keys off this leaf to source the per-rule
26139 // request wall-clock deadline each inbound request is bounded
26140 // against; a drifted value (`"deadline"` / `"requestTimeout"`
26141 // / `"timeout"` / `"upstreamRequest"`) at either the production
26142 // emitter or a downstream renderer's per-rule request-deadline
26143 // upsert silently emits an `HTTPRoute` whose per-rule request-
26144 // deadline leaf the Gateway API CRD schema validator drops as
26145 // unknown — the timeouts sub-shape parses as an empty
26146 // `HTTPRouteTimeouts` with the typed duration silently
26147 // discarded, the route accepts every inbound request with no
26148 // per-rule request deadline (the "no infinite blocking"
26149 // guarantee MESH-COMPOSITION.md §V mandates for every rendered
26150 // per-`:politicas` mesh-composition edge silently regresses to
26151 // the pre-overlay unbounded-blocking semantic), and every
26152 // external `:entrada` flow the route was authored to cap by
26153 // the typed `:politicas :timeout` slot runs to whatever
26154 // request-deadline the resolved backend's downstream
26155 // infrastructure picks with no field naming the per-rule-
26156 // request-deadline-leaf-key-drift root cause. Changing this
26157 // value is a coordinated Gateway API promotion alongside the
26158 // upstream SIG-Network Gateway API deprecation cycle, not an
26159 // incidental edit. Peer to
26160 // `gateway_api_key_attempts_pins_canonical_value` /
26161 // `gateway_api_key_retry_pins_canonical_value` /
26162 // `gateway_api_key_timeouts_pins_canonical_value` /
26163 // `gateway_api_key_hostnames_pins_canonical_value` /
26164 // `gateway_api_key_hostname_pins_canonical_value` /
26165 // `gateway_api_key_listeners_pins_canonical_value` /
26166 // `gateway_api_key_parent_refs_pins_canonical_value` /
26167 // `gateway_api_key_backend_refs_pins_canonical_value` on the
26168 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
26169 // surface — closes the second parent-leaf axis pair
26170 // (`timeouts` container + `request` leaf) both
26171 // MESH-COMPOSITION.md §V "no infinite blocking / no infinite
26172 // retrying" guarantees rest on, sibling to the parent-leaf
26173 // pair (`retry` container + `attempts` leaf) closed in
26174 // e2e136b.
26175 assert_eq!(GATEWAY_API_KEY_REQUEST, "request");
26176 }
26177
26178 #[test]
26179 fn gateway_api_key_request_carries_lower_camel_case_shape() {
26180 // Cross-axis invariant: a Kubernetes CRD schema field name is a
26181 // lowerCamelCase identifier per the K8s API conventions
26182 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
26183 // "Field names should be lowercase camelCase") — first byte
26184 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
26185 // kebab-case or whitespace. Pinning the shape here means a
26186 // future rebrand on the canonical lift can't silently land a
26187 // malformed field-name discriminator (snake_case, kebab-case,
26188 // UpperCamelCase, empty) that the apiserver-side CRD schema
26189 // validator would reject far from the rebrand commit's source.
26190 // Peer to `gateway_api_key_attempts_carries_lower_camel_case_shape`
26191 // / `gateway_api_key_retry_carries_lower_camel_case_shape`
26192 // / `gateway_api_key_timeouts_carries_lower_camel_case_shape`
26193 // / `gateway_api_key_hostnames_carries_lower_camel_case_shape`
26194 // / `gateway_api_key_hostname_carries_lower_camel_case_shape`
26195 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
26196 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
26197 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
26198 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
26199 // surface — the lowerCamelCase K8s field-name grammar governs
26200 // every nested schema-field axis (including this per-rule
26201 // request-deadline-leaf-key), same convention.
26202 let v = GATEWAY_API_KEY_REQUEST;
26203 assert!(
26204 !v.is_empty(),
26205 "GATEWAY_API_KEY_REQUEST {v:?} must be non-empty per the K8s API \
26206 lowerCamelCase field-name grammar"
26207 );
26208 let first = v.chars().next().expect("non-empty");
26209 assert!(
26210 first.is_ascii_lowercase(),
26211 "GATEWAY_API_KEY_REQUEST {v:?} first byte {first:?} must be \
26212 ASCII-lowercase per the K8s API lowerCamelCase field-name \
26213 grammar (field names are always lowerCamelCase)"
26214 );
26215 assert!(
26216 v.chars().all(|c| c.is_ascii_alphanumeric()),
26217 "GATEWAY_API_KEY_REQUEST {v:?} must be ASCII-alphanumeric \
26218 throughout per the K8s API field-name grammar — no \
26219 snake_case, kebab-case, or whitespace bytes the apiserver-side \
26220 OpenAPI schema validator would reject"
26221 );
26222 }
26223
26224 #[test]
26225 fn default_namespace_is_a_valid_dns_1123_label() {
26226 // Cross-axis invariant: the default namespace lands as
26227 // `metadata.namespace` on every emitted K8s object across every
26228 // renderer, and the K8s apiserver enforces the DNS-1123 label
26229 // rule on every `metadata.namespace`. Pinning this here means
26230 // a future rebrand on the canonical `DEFAULT_NAMESPACE`
26231 // declaration can't silently land a value the apiserver
26232 // refuses at the *first* renderer to apply against a cluster,
26233 // far from the rebrand commit's source — the typed
26234 // [`is_dns_1123_label`] floor rejects it at caixa-core build
26235 // time on the canonical lift, before any renderer consumes
26236 // the value. Same trajectory as `:membros :caixa` /
26237 // `:placement :clusters` / `:contratos :de`/`:para` /
26238 // `:entrada :para` / `:placement :affinity` (dfd4902 — the
26239 // five typed-identifier axes on the Aplicacao surface that
26240 // already land on this same `is_dns_1123_label` floor at
26241 // their respective validate gates), now extended onto the
26242 // canonical-namespace-default axis the renderers share.
26243 assert!(
26244 is_dns_1123_label(DEFAULT_NAMESPACE).is_ok(),
26245 "DEFAULT_NAMESPACE {DEFAULT_NAMESPACE:?} must be a valid \
26246 DNS-1123 label — every K8s apiserver-side schema enforces \
26247 this rule on `metadata.namespace`"
26248 );
26249 }
26250
26251 #[test]
26252 fn helm_chart_api_version_pins_canonical_value() {
26253 // Pin the actual string so a typo in this lift can't silently
26254 // rebrand the Helm 3 chart-schema apiVersion the rendered
26255 // `lareira-<nome>` `Chart.yaml` document declares at its
26256 // top-level `apiVersion` axis. The string is part of the
26257 // Helm-side contract with the Helm 3 chart-schema parser:
26258 // `helm dependency build` / `helm lint` / `helm template`
26259 // all resolve the chart under the Helm 3 v2 schema (permitting
26260 // top-level `dependencies:`); a drifted value to the legacy
26261 // Helm 2 `"v1"` schema (the pre-Helm-3 chart schema every
26262 // upstream Helm-3-migration doc names) silently reroutes the
26263 // rendered Chart.yaml through the Helm 2 parser, where the
26264 // top-level `dependencies:` block is unknown and the chart's
26265 // dep on the `pleme-computeunit` library chart never resolves
26266 // — `helm dependency build` reports "no requirements found"
26267 // and every `helm template` / `helm install` emits an empty
26268 // release (no ComputeUnit / Service / ScaledObject resources
26269 // land) far from the source caixa.lisp / the renderer's
26270 // `build_chart_yaml` call site. Changing it is a coordinated
26271 // Helm 4 chart-schema migration alongside the upstream Helm
26272 // chart-schema deprecation cycle, not an incidental edit.
26273 // Peer to `flux_helmrelease_api_version_pins_canonical_value`
26274 // / `flux_gitrepository_api_version_pins_canonical_value` /
26275 // `flux_kustomization_api_version_pins_canonical_value` /
26276 // `gateway_api_api_version_pins_canonical_value` /
26277 // `cilium_api_version_pins_canonical_value` on the sibling
26278 // cluster-side-CRD-apiVersion-pin set — those pin the K8s
26279 // apiserver-side `(apiVersion, kind)` `RESTMapper` contract,
26280 // this one pins the Helm-side chart-schema-parser contract
26281 // that gates every rendered `lareira-<nome>` chart's
26282 // dependency resolution before any K8s resource lands.
26283 assert_eq!(HELM_CHART_API_VERSION, "v2");
26284 }
26285
26286 #[test]
26287 fn helm_chart_api_version_carries_helm_3_chart_schema_shape() {
26288 // Cross-axis invariant: the Helm 3 chart-schema apiVersion is
26289 // a bare `v<digit>` version label (unlike the K8s CRD
26290 // apiVersion — `<group>/<version>` — the sibling
26291 // FLUX_HELMRELEASE_API_VERSION / GATEWAY_API_API_VERSION /
26292 // CILIUM_API_VERSION lifts pin). The Helm-side chart-schema
26293 // grammar carries no group prefix at all — the value is
26294 // parsed as a plain schema-version discriminator against the
26295 // Helm binary's built-in schema table (Helm 2 recognizes
26296 // `"v1"`, Helm 3 recognizes both `"v1"` for legacy compat
26297 // and `"v2"` for its native schema). Pinning the shape here
26298 // means a future rebrand on the canonical lift can't silently
26299 // land a K8s-CRD-shaped `group/version` value (e.g. an
26300 // accidental copy-paste from the sibling FLUX / GATEWAY /
26301 // CILIUM constants) that the Helm chart-schema parser would
26302 // fail to recognize at `helm dependency build` /
26303 // `helm lint` / `helm template` time. The `v<digit>+`
26304 // invariant is the load-bearing Helm-side chart-schema
26305 // typed-discovery contract: a value the Helm binary's
26306 // chart-schema resolver consults to select the schema
26307 // parser that reads the rest of the document. Peer to
26308 // `flux_kind_helm_release_carries_upper_camel_case_shape`
26309 // (which pins the K8s `RESTMapper` kind-grammar shape) —
26310 // both close the "the shape of the lifted schema-version
26311 // discriminator is grammatical, not just a byte-equal string"
26312 // discipline at the lift site.
26313 let v = HELM_CHART_API_VERSION;
26314 assert!(
26315 !v.is_empty(),
26316 "HELM_CHART_API_VERSION {v:?} must be non-empty per the Helm \
26317 chart-schema apiVersion grammar"
26318 );
26319 assert!(
26320 !v.contains('/'),
26321 "HELM_CHART_API_VERSION {v:?} must not contain `/` — the Helm-side \
26322 chart-schema apiVersion is a bare `v<digit>` label with no group \
26323 prefix, unlike the K8s CRD `<group>/<version>` shape the sibling \
26324 FLUX_HELMRELEASE_API_VERSION / GATEWAY_API_API_VERSION / \
26325 CILIUM_API_VERSION lifts carry"
26326 );
26327 let bytes = v.as_bytes();
26328 assert_eq!(
26329 bytes[0], b'v',
26330 "HELM_CHART_API_VERSION {v:?} must start with `v` per the Helm \
26331 chart-schema apiVersion grammar (`v1` for the legacy schema, \
26332 `v2` for the Helm 3 schema — every accepted value the Helm \
26333 binary's chart-schema resolver knows carries the `v` prefix)"
26334 );
26335 assert!(
26336 bytes.len() >= 2,
26337 "HELM_CHART_API_VERSION {v:?} must be at least 2 bytes (`v` + \
26338 at least one digit) per the Helm chart-schema apiVersion \
26339 grammar"
26340 );
26341 assert!(
26342 bytes[1..].iter().all(u8::is_ascii_digit),
26343 "HELM_CHART_API_VERSION {v:?} bytes after the leading `v` must be \
26344 ASCII digits per the Helm chart-schema apiVersion grammar — \
26345 no dots, no hyphens, no whitespace, no non-digit bytes the \
26346 Helm binary's chart-schema resolver would reject"
26347 );
26348 }
26349
26350 #[test]
26351 fn helm_chart_type_application_pins_canonical_value() {
26352 // Pin the actual string so a typo in this lift can't silently
26353 // rebrand the Helm 3 chart-schema `type` field's canonical
26354 // `application` per-chart-kind discriminator scalar-value the
26355 // rendered `lareira-<nome>` chart's Chart.yaml `type:` axis
26356 // declares. The value is part of the cluster-side contract with
26357 // Helm's per-release install-shape dispatch loop — the Helm
26358 // chart-schema pins the per-chart-kind axis to the closed set
26359 // `{"application", "library"}` (see
26360 // https://helm.sh/docs/topics/charts/#chart-types), so a drifted
26361 // value (`"Application"` / `"APPLICATION"` / `"app"` /
26362 // `"workload"`) lands the rendered `lareira-<nome>` chart outside
26363 // the schema's admitted set, and Helm's chart-schema parser
26364 // silently treats the unrecognized value as the default
26365 // `application` shape (masking the schema violation with no
26366 // process-log drift-signal); worse, an accidental collapse onto
26367 // the sibling `"library"` shape lands `lareira-<nome>` in the
26368 // dependency-only install-shape Helm refuses to install directly
26369 // ("Error: library charts cannot be installed"), dropping every
26370 // per-Servico `helm install` / `helm upgrade` release cycle with
26371 // no field naming the chart-kind-drift root cause. Changing this
26372 // value is a coordinated Helm chart-schema promotion alongside
26373 // the upstream Helm project's per-schema deprecation cycle, not
26374 // an incidental edit. Peer to
26375 // `helm_chart_api_version_pins_canonical_value` /
26376 // `kube_protocol_tcp_pins_canonical_value` /
26377 // `gateway_api_protocol_http_pins_canonical_value` /
26378 // `cilium_auth_mode_required_pins_canonical_value` on the
26379 // sibling canonical-Helm-chart-schema-axis + canonical-cluster-
26380 // side-OpenAPI-schema-enum-value pin sets — pivots the
26381 // canonical-enum-value single-sourcing discipline from the K8s-
26382 // CR-side surfaces onto the Helm-chart-schema-enum-value axis
26383 // every rendered Chart.yaml carries at its per-chart-kind
26384 // discriminator field.
26385 assert_eq!(HELM_CHART_TYPE_APPLICATION, "application");
26386 }
26387
26388 #[test]
26389 fn helm_chart_type_application_carries_lowercase_shape() {
26390 // Cross-axis invariant: the Helm 3 chart-schema `type` field
26391 // admits the closed set `{"application", "library"}` — every
26392 // admitted value is all-ASCII-lowercase throughout per the
26393 // upstream Helm project's per-enum-value naming convention
26394 // (distinct from the sibling K8s-core `Protocol` OpenAPI schema
26395 // enum's all-ASCII-uppercase per-value convention the
26396 // `kube_protocol_tcp_carries_upper_case_shape` pin carries, and
26397 // distinct from the sibling Gateway-API v1 `PathMatchType`
26398 // OpenAPI schema enum's UpperCamelCase per-value convention the
26399 // `gateway_api_path_match_type_path_prefix_carries_upper_camel_case_shape`
26400 // pin carries — the three peer canonical-cluster-side-schema-
26401 // enum-value conventions do not collapse). Same all-ASCII-
26402 // lowercase shape as the sibling Cilium `MutualAuthenticationMode`
26403 // enum-values the peer `cilium_auth_mode_required_carries_lowercase_shape`
26404 // / `cilium_auth_mode_disabled_carries_lowercase_shape` pins
26405 // enshrine — the two peer canonical-cluster-side-schema-enum-
26406 // value all-lowercase conventions collapse on the shared byte-
26407 // shape convention Helm and Cilium happen to share (independent
26408 // upstream projects, coincidental convention agreement).
26409 //
26410 // Pinning the shape here means a future rebrand on the canonical
26411 // lift can't silently land a malformed per-chart-kind scalar
26412 // (uppercase `"APPLICATION"`, mixed-case `"Application"`, empty)
26413 // that the Helm chart-schema parser would silently treat as the
26414 // default `application` shape (masking the drift with no
26415 // process-log signal).
26416 let v = HELM_CHART_TYPE_APPLICATION;
26417 assert!(
26418 !v.is_empty(),
26419 "HELM_CHART_TYPE_APPLICATION {v:?} must be non-empty per the \
26420 Helm 3 chart-schema `type` field grammar"
26421 );
26422 assert!(
26423 v.chars().all(|c| c.is_ascii_lowercase()),
26424 "HELM_CHART_TYPE_APPLICATION {v:?} must be ASCII-lowercase \
26425 throughout per the Helm 3 chart-schema per-chart-kind \
26426 discriminator naming convention — no uppercase, mixed-case, \
26427 or whitespace bytes the Helm chart-schema parser would \
26428 silently treat as the default `application` shape (masking \
26429 the drift with no process-log signal)"
26430 );
26431 }
26432
26433 #[test]
26434 fn helm_chart_type_library_pins_canonical_value() {
26435 // Pin the sibling closed-set arm of the Helm 3 chart-schema
26436 // `type` field's admitted set `{"application", "library"}` (see
26437 // https://helm.sh/docs/topics/charts/#chart-types). A drift on
26438 // this const's value (an `"Library"` / `"LIBRARY"` /
26439 // `"library-chart"` / `"lib"` typo, an accidental collapse onto
26440 // the sibling [`HELM_CHART_TYPE_APPLICATION`] shape) would land
26441 // a future per-Aplicacao library-chart emitter — the trajectory
26442 // item the [`HELM_CHART_TYPE_APPLICATION`] docstring names as
26443 // the natural next consumer of this const — outside the Helm
26444 // chart-schema's admitted set, with the same silent-collapse-
26445 // onto-`application`-default failure mode the peer
26446 // [`HELM_CHART_TYPE_APPLICATION`] pin's docstring enumerates on
26447 // the sibling closed-set arm (Helm's chart-schema parser
26448 // silently treats an unrecognized `type:` value as the default
26449 // `application` shape, so the misdeclared library chart installs
26450 // as an application chart instead of surfacing the schema
26451 // violation). Peer of
26452 // `helm_chart_type_application_pins_canonical_value` on the
26453 // sibling closed-set arm — the two pins together enshrine the
26454 // full closed set at the substrate-side canonical surface, and
26455 // the paired
26456 // `helm_chart_type_application_and_library_are_distinct` pin
26457 // (below) enforces the two arms never accidentally converge on
26458 // the same byte-shape.
26459 assert_eq!(HELM_CHART_TYPE_LIBRARY, "library");
26460 }
26461
26462 #[test]
26463 fn helm_chart_type_library_carries_lowercase_shape() {
26464 // Cross-axis invariant: the Helm 3 chart-schema `type` field
26465 // admits the closed set `{"application", "library"}` — every
26466 // admitted value is all-ASCII-lowercase throughout per the
26467 // upstream Helm project's per-enum-value naming convention.
26468 // Same all-ASCII-lowercase shape the peer
26469 // `helm_chart_type_application_carries_lowercase_shape` pin
26470 // enshrines on the sibling closed-set arm — the two pins
26471 // together enforce the shape-convention across the full
26472 // canonical-Helm-chart-schema-per-chart-kind-discriminator
26473 // closed set.
26474 //
26475 // Pinning the shape here means a future rebrand on the canonical
26476 // lift can't silently land a malformed per-chart-kind scalar
26477 // (uppercase `"LIBRARY"`, mixed-case `"Library"`, empty) that
26478 // the Helm chart-schema parser would silently treat as the
26479 // default `application` shape (masking the drift with no
26480 // process-log signal, and installing the misdeclared library
26481 // chart as an application chart instead of surfacing the
26482 // schema violation at chart-consumption time).
26483 let v = HELM_CHART_TYPE_LIBRARY;
26484 assert!(
26485 !v.is_empty(),
26486 "HELM_CHART_TYPE_LIBRARY {v:?} must be non-empty per the \
26487 Helm 3 chart-schema `type` field grammar"
26488 );
26489 assert!(
26490 v.chars().all(|c| c.is_ascii_lowercase()),
26491 "HELM_CHART_TYPE_LIBRARY {v:?} must be ASCII-lowercase \
26492 throughout per the Helm 3 chart-schema per-chart-kind \
26493 discriminator naming convention — no uppercase, mixed-case, \
26494 or whitespace bytes the Helm chart-schema parser would \
26495 silently treat as the default `application` shape (masking \
26496 the drift with no process-log signal)"
26497 );
26498 }
26499
26500 #[test]
26501 fn helm_chart_type_application_and_library_are_distinct() {
26502 // Structural distinctness invariant on the closed-set pair the
26503 // Helm 3 chart-schema `type` field admits (`{"application",
26504 // "library"}`). The two arms name distinct per-chart-kind
26505 // install shapes at the substrate-side Helm dispatch — an
26506 // `application`-typed chart installs into a namespace as a
26507 // workload while a `library`-typed chart is dependency-only
26508 // and Helm refuses to install it directly ("Error: library
26509 // charts cannot be installed") — so a future rebrand that
26510 // accidentally collapsed the two consts onto the same
26511 // byte-shape would land every consumer of one arm on the
26512 // sibling's install semantic by construction: a rendered
26513 // `lareira-<nome>` (application) chart that silently emitted
26514 // `type: library` would drop every per-Servico
26515 // `helm install` / `helm upgrade` release cycle with no field
26516 // naming the chart-kind-drift root cause, and (symmetrically)
26517 // a future per-Aplicacao library chart emitting
26518 // `type: application` would be install-able as a workload
26519 // when the substrate's install-shape dispatch expects it to
26520 // fail with the library-charts-cannot-be-installed diagnostic.
26521 // Pinning the distinctness here means a hypothetical future
26522 // edit that accidentally converges the two arms (a copy-paste
26523 // rebrand at one lift that stops at the peer const declaration,
26524 // a substrate-wide vocabulary shift that lands one arm without
26525 // its paired peer) surfaces at caixa-core build time rather
26526 // than as a chart-install-shape drift far from the source
26527 // commit. Same "closed-set arms are byte-distinct by
26528 // construction" discipline the peer
26529 // [`crate::CILIUM_AUTH_MODE_REQUIRED`] /
26530 // [`crate::CILIUM_AUTH_MODE_DISABLED`] pair carries on the
26531 // sibling two-arm Cilium `MutualAuthenticationMode` OpenAPI
26532 // enum closed set.
26533 assert_ne!(
26534 HELM_CHART_TYPE_APPLICATION, HELM_CHART_TYPE_LIBRARY,
26535 "HELM_CHART_TYPE_APPLICATION ({HELM_CHART_TYPE_APPLICATION:?}) and \
26536 HELM_CHART_TYPE_LIBRARY ({HELM_CHART_TYPE_LIBRARY:?}) must remain \
26537 byte-distinct — the two arms name the two install shapes of the \
26538 Helm 3 chart-schema `type` field's closed set {{\"application\", \
26539 \"library\"}} and every substrate-side consumer that dispatches \
26540 on the per-chart-kind axis relies on the two byte-shapes \
26541 distinguishing the workload-install-shape arm from the \
26542 dependency-only-install-shape arm"
26543 );
26544 }
26545
26546 #[test]
26547 fn helm_chart_key_api_version_pins_canonical_value() {
26548 // Pin the actual byte-string so a typo in this lift can't
26549 // silently rebrand the Helm 3 `Chart.yaml` top-level chart-
26550 // schema-apiVersion YAML axis-key the rendered `lareira-<nome>`
26551 // chart declares. The string is part of the substrate-side
26552 // contract with Helm's chart-schema parser at
26553 // `helm dependency build` / `helm lint` / `helm template` /
26554 // `helm install` time: the parser looks up the per-chart
26555 // chart-schema-apiVersion scalar under exactly this top-level
26556 // YAML key (Helm's chart-schema treats a missing `apiVersion:`
26557 // top-level scalar as an "apiVersion is required" hard error,
26558 // and Helm 3's chart-schema-version-router silently defaults
26559 // an unrecognized top-level apiVersion-carrier key to Helm 2
26560 // parsing shape). A drift on this const's value (an accidental
26561 // collapse onto `"ApiVersion"` / `"apiversion"` /
26562 // `"schemaVersion"` / the empty string) would silently reroute
26563 // the rendered `Chart.yaml` through the wrong chart-schema
26564 // parser at `helm dependency build` / `helm lint` /
26565 // `helm template` time. Peer to
26566 // `helm_chart_api_version_pins_canonical_value` on the sibling
26567 // axis-value canonical pin — completes the per-Chart.yaml
26568 // chart-schema-apiVersion axis's `(key, value)` canonical-pin
26569 // pair at the substrate.
26570 assert_eq!(HELM_CHART_KEY_API_VERSION, "apiVersion");
26571 }
26572
26573 #[test]
26574 fn helm_chart_key_api_version_matches_kube_key_api_version() {
26575 // Load-bearing byte-shape coincidence between the Helm 3
26576 // `Chart.yaml` top-level chart-schema-apiVersion YAML axis-key
26577 // ([`HELM_CHART_KEY_API_VERSION`]) and the K8s-CR top-level
26578 // per-CR schema-apiVersion YAML axis-key ([`KUBE_KEY_API_VERSION`])
26579 // — Helm inherits the K8s CR top-level shape verbatim (see
26580 // https://helm.sh/docs/topics/charts/#the-chartyaml-file), so
26581 // every consumer that navigates a Chart.yaml top-level mapping
26582 // by the schema-apiVersion key and every consumer that
26583 // navigates a K8s CR top-level mapping by the schema-apiVersion
26584 // key both read the byte-identical `"apiVersion"` key. The two
26585 // axes are structurally-independent schema surfaces (the Helm 3
26586 // chart-schema top-level shape vs. the K8s apiserver-side CR
26587 // top-level shape), so the substrate carries two distinct
26588 // `pub const` symbols; this pin makes the byte-shape
26589 // coincidence load-bearing rather than accidental so a future
26590 // K8s-side rebrand at [`KUBE_KEY_API_VERSION`] (or a Helm-side
26591 // rebrand at [`HELM_CHART_KEY_API_VERSION`]) that dropped the
26592 // byte-identity would fail the pin at substrate-build time
26593 // rather than as a silent Helm-chart-schema-parser rejection
26594 // at `helm lint` / `helm template` time far from the drift
26595 // site. Complementary to the sibling
26596 // [`helm_chart_key_type_is_byte_distinct_from_kube_key_kind`]
26597 // pin — that peer asserts the per-chart-kind discriminator key
26598 // pair is byte-distinct across the two schema surfaces (the
26599 // Chart.yaml `type:` axis vs. the K8s CR `kind:` axis), and
26600 // this pin asserts the per-schema-apiVersion axis-key pair is
26601 // byte-identical across the two schema surfaces; together the
26602 // two pins cover the full independence-map of the top-level
26603 // discriminator axes at the two schema surfaces.
26604 assert_eq!(
26605 HELM_CHART_KEY_API_VERSION, KUBE_KEY_API_VERSION,
26606 "HELM_CHART_KEY_API_VERSION ({HELM_CHART_KEY_API_VERSION:?}) \
26607 must remain byte-identical to KUBE_KEY_API_VERSION \
26608 ({KUBE_KEY_API_VERSION:?}) — Helm 3 inherits the K8s CR \
26609 top-level schema-apiVersion YAML-axis-key byte-shape \
26610 verbatim, and every downstream consumer that navigates a \
26611 `Chart.yaml` / K8s CR top-level mapping by the schema-\
26612 apiVersion key reads the byte-identical `\"apiVersion\"` \
26613 key; a drift on either side silently reroutes the \
26614 consumer through a schema-parser rejection far from the \
26615 drift site"
26616 );
26617 }
26618
26619 #[test]
26620 fn helm_chart_key_type_pins_canonical_value() {
26621 // Pin the actual byte-string so a typo in this lift can't silently
26622 // rebrand the Helm 3 `Chart.yaml` top-level per-chart-kind
26623 // discriminator YAML axis-key the rendered `lareira-<nome>` chart
26624 // declares. The string is part of the substrate-side contract with
26625 // Helm's chart-schema parser at `helm dependency build` /
26626 // `helm lint` / `helm template` / `helm install` time: the parser
26627 // looks up the per-chart-kind discriminator scalar under exactly
26628 // this top-level YAML key, and a drift on this const's value
26629 // (an accidental collapse onto `"Type"` / `"chartType"` /
26630 // `"kind"`, or the empty string) would silently reroute the
26631 // rendered `Chart.yaml` through the schema-shape-defaulting arm
26632 // of Helm's parser (unknown top-level keys default the
26633 // per-chart-kind axis to `application` with no process-log
26634 // signal). Peer to
26635 // `helm_chart_type_application_pins_canonical_value` /
26636 // `helm_chart_type_library_pins_canonical_value` on the sibling
26637 // axis-value canonical pin pair — completes the per-Chart.yaml
26638 // per-chart-kind discriminator axis's `(key, value-set)`
26639 // canonical-pin trio at the substrate.
26640 assert_eq!(HELM_CHART_KEY_TYPE, "type");
26641 }
26642
26643 #[test]
26644 fn helm_chart_key_type_is_byte_distinct_from_kube_key_kind() {
26645 // Structural distinctness invariant: the Helm 3 `Chart.yaml`
26646 // top-level per-chart-kind YAML axis-key
26647 // ([`HELM_CHART_KEY_TYPE`]) and the K8s CR top-level per-CRD
26648 // kind-discriminator YAML axis-key ([`KUBE_KEY_KIND`]) name
26649 // two structurally-independent axes at two structurally-
26650 // independent schema surfaces — the Helm-side chart-schema
26651 // top-level shape and the K8s-apiserver-side CR top-level
26652 // shape — and every substrate-side renderer that emits or
26653 // navigates a `Chart.yaml` vs. a K8s CR YAML relies on the
26654 // two byte-shapes distinguishing the two schema-surfaces at
26655 // its top-level mapping-key resolution. A hypothetical future
26656 // rebrand that accidentally aliased [`HELM_CHART_KEY_TYPE`]
26657 // at [`KUBE_KEY_KIND`]'s canonical would collapse the
26658 // per-Chart.yaml per-chart-kind discriminator axis onto the
26659 // K8s-CR per-CRD kind-discriminator axis at every consumer,
26660 // and Helm's chart-schema parser would silently drop the
26661 // rebranded key (top-level `kind:` is not part of the Helm 3
26662 // chart-schema's admitted set — the parser silently ignores
26663 // it, defaulting the per-chart-kind axis to `application`
26664 // with no process-log signal). Same "byte-distinct axis-keys
26665 // at structurally-independent schema surfaces" discipline the
26666 // peer [`CILIUM_KEY_PATH`] / [`GATEWAY_API_KEY_PATH`]
26667 // (ef6114f / 9f45aa4) pair carries on the sibling Cilium-CRD-
26668 // vs.-Gateway-API-per-HTTPRouteMatch path-matcher axis
26669 // independence — extends the discipline from the two K8s-CR-
26670 // side path-matcher schemas onto the Helm-side vs. K8s-side
26671 // top-level discriminator-key axis pair.
26672 assert_ne!(
26673 HELM_CHART_KEY_TYPE, KUBE_KEY_KIND,
26674 "HELM_CHART_KEY_TYPE ({HELM_CHART_KEY_TYPE:?}) and \
26675 KUBE_KEY_KIND ({KUBE_KEY_KIND:?}) name the top-level \
26676 discriminator keys of two structurally-independent schema \
26677 surfaces (the Helm 3 chart-schema and the K8s apiserver-side \
26678 CR schema) and must remain byte-distinct — a collapse \
26679 silently reroutes the per-Chart.yaml per-chart-kind axis \
26680 through the K8s-CR-shape-defaulting arm of Helm's parser"
26681 );
26682 }
26683
26684 #[test]
26685 fn helm_chart_key_app_version_pins_canonical_value() {
26686 // Pin the actual byte-string so a typo in this lift can't silently
26687 // rebrand the Helm 3 `Chart.yaml` top-level per-chart-app-version
26688 // YAML axis-key the rendered `lareira-<nome>` chart declares.
26689 // The string is part of the substrate-side contract with Helm's
26690 // chart-schema parser + every downstream chart-consumer that
26691 // routes the underlying-application-version display onto the
26692 // rendered chart's per-app-version field (Artifact Hub's per-
26693 // chart-search index, `helm search` / `helm show chart` operator
26694 // surfaces, the OCI-artifact-labels emitter every chart-publish
26695 // pipeline exports). A drift on this const's value (`"AppVersion"`
26696 // / `"applicationVersion"` / `"appversion"` / the empty string)
26697 // would silently drop the underlying-application-version field
26698 // from the parsed chart-metadata shape at every downstream
26699 // consumer, with no process-log signal at the substrate-side
26700 // emitter site. The `appVersion:` camelCase byte-shape is the
26701 // load-bearing Helm chart-schema per-app-version YAML axis-key
26702 // grammar the upstream Helm project pins. Peer to
26703 // `helm_chart_key_type_pins_canonical_value` on the sibling
26704 // per-Chart.yaml top-level YAML axis-key canonical pin surface —
26705 // completes the per-Chart.yaml top-level YAML axis-key
26706 // canonical-pin trio at the substrate for the three serde-
26707 // rename-literal-only axes on [`caixa_helm::ChartYaml`] (the
26708 // third top-level axis-key `apiVersion` lands under the peer
26709 // [`HELM_CHART_KEY_API_VERSION`] pin whose byte-shape coincides
26710 // with [`KUBE_KEY_API_VERSION`] by Helm's design decision to
26711 // inherit the K8s CR top-level shape verbatim — the paired
26712 // `helm_chart_key_api_version_matches_kube_key_api_version`
26713 // pin makes the coincidence load-bearing rather than
26714 // accidental).
26715 assert_eq!(HELM_CHART_KEY_APP_VERSION, "appVersion");
26716 }
26717
26718 #[test]
26719 fn helm_chart_key_app_version_is_byte_distinct_from_helm_chart_key_version() {
26720 // Structural distinctness invariant on the per-Chart.yaml top-
26721 // level version-axis-key pair. The Helm 3 chart-schema pins two
26722 // structurally-distinct version YAML axis-keys at the top-level
26723 // of every `Chart.yaml`:
26724 //
26725 // - `version:` — the chart's own SemVer (incremented per
26726 // release of the chart itself)
26727 // - `appVersion:` — the underlying application's version
26728 // (the version the containerized workload the chart
26729 // installs advertises)
26730 //
26731 // At the caixa-helm renderer both YAML axes today draw from the
26732 // caixa's `:versao` at `build_chart_yaml` (a caixa's per-caixa
26733 // BLAKE3-closure identity binds chart + wasm-binary at exactly
26734 // one release axis), but the Helm 3 chart-schema pins the two
26735 // top-level YAML keys distinctly regardless — every downstream
26736 // Helm-consumer (Artifact Hub's per-chart index, `helm search` /
26737 // `helm show chart` surfaces) routes the two version-axis
26738 // scalars onto distinct display fields. A hypothetical future
26739 // rebrand that accidentally aliased [`HELM_CHART_KEY_APP_VERSION`]
26740 // at the sibling per-Chart.yaml top-level `version:` key
26741 // (`"version"`) would collapse the two YAML axes at the
26742 // renderer's ChartYaml serialization, and Helm's chart-schema
26743 // parser would silently read the app-version scalar under the
26744 // chart-own-SemVer axis (the last `version:` key wins in
26745 // `serde_yaml`'s emitted mapping under this drift), overwriting
26746 // the chart's own SemVer at every downstream chart-consumer.
26747 // Same "byte-distinct version-axis keys at the same schema
26748 // surface" discipline the peer [`FLEET_PROGRAMS_KEY_VERSAO`] /
26749 // [`FLEET_PROGRAMS_KEY_NAME`] pair carries on the sibling
26750 // per-fleet-programs-entry axis pair — extends the discipline
26751 // from the per-fleet-programs-entry key-pair onto the per-
26752 // Chart.yaml top-level version-axis-key pair.
26753 assert_ne!(
26754 HELM_CHART_KEY_APP_VERSION, "version",
26755 "HELM_CHART_KEY_APP_VERSION ({HELM_CHART_KEY_APP_VERSION:?}) \
26756 must remain byte-distinct from the sibling per-Chart.yaml \
26757 top-level chart-own-SemVer `version:` key — a collapse \
26758 silently overwrites the chart's own SemVer at every \
26759 downstream Helm chart-consumer"
26760 );
26761 }
26762
26763 #[test]
26764 fn helm_chart_key_dependencies_pins_canonical_value() {
26765 // Pin the actual byte-string so a typo in this lift can't silently
26766 // rebrand the Helm 3 `Chart.yaml` top-level per-chart dependency-
26767 // list YAML axis-key the rendered `lareira-<nome>` chart declares.
26768 // The string is part of the substrate-side contract with Helm's
26769 // chart-schema parser — every rendered chart's `dependencies:`
26770 // list-container mounts under this exact byte-shape, and Helm's
26771 // per-dep resolver at `helm dependency build` / `helm dependency
26772 // update` time consumes the per-entry sub-mapping tetrad only if
26773 // the top-level list-container key matches this canonical shape.
26774 // A drift on this const's value (`"Dependencies"` / `"deps"` /
26775 // `"chartDependencies"` / `"depends"` / the empty string) would
26776 // silently drop the entire per-chart dep list from the parsed
26777 // chart-metadata shape, and every rendered `lareira-<nome>`
26778 // chart's install would fail with `template: no template ...
26779 // associated with template ...` far from the drift site with
26780 // no field naming the top-level-list-key-drift root cause. Peer
26781 // to [`helm_chart_key_type_pins_canonical_value`] /
26782 // [`helm_chart_key_app_version_pins_canonical_value`] /
26783 // [`helm_chart_key_api_version_pins_canonical_value`] on the
26784 // sibling per-Chart.yaml top-level YAML axis-key canonical-pin
26785 // surface — extends the per-Chart.yaml top-level YAML axis-key
26786 // canonical-pin trio those pins established onto the fourth
26787 // top-level axis-key at the substrate, the parent list-container
26788 // whose already-lifted per-`dependencies[]`-entry sub-mapping
26789 // tetrad ([`HELM_CHART_DEPENDENCY_KEY_NAME`] /
26790 // [`HELM_CHART_DEPENDENCY_KEY_VERSION`] /
26791 // [`HELM_CHART_DEPENDENCY_KEY_REPOSITORY`] /
26792 // [`HELM_CHART_DEPENDENCY_KEY_ALIAS`]) mounts one level down.
26793 assert_eq!(HELM_CHART_KEY_DEPENDENCIES, "dependencies");
26794 }
26795
26796 #[test]
26797 fn helm_chart_key_dependencies_is_byte_distinct_from_per_dep_sub_mapping_tetrad() {
26798 // Structural distinctness invariant on the per-Chart.yaml
26799 // `dependencies:` parent list-container axis-key vs. the four
26800 // already-lifted per-entry sub-mapping keys mounted one level
26801 // down. The parent+children pair spans two schema-nested YAML
26802 // levels — the top-level `dependencies:` list-container and
26803 // the per-entry sub-mapping `{name, version, repository,
26804 // alias}` — and Helm's chart-schema parser navigates them as
26805 // two structurally-independent axes: a collapse of the parent
26806 // axis-key onto any child (e.g. an accidental future rebrand
26807 // that renamed the [`HELM_CHART_KEY_DEPENDENCIES`] value to
26808 // `"name"` or `"version"`) would either drop the entire per-
26809 // chart dep list at the top-level parse (the child scalar
26810 // silently masks the parent list-container the schema expects)
26811 // or read the top-level list under a scalar-shaped axis-key
26812 // and reject the chart at `helm lint` with a shape mismatch
26813 // far from the drift site. Same "parent list-container
26814 // axis-key must remain byte-distinct from every child sub-
26815 // mapping axis-key" discipline the peer
26816 // [`SUPERVISOR_KEY_CHILDREN`] parent axis-key already carries
26817 // against the sibling [`SUPERVISOR_CHILD_KEY_CAIXA`] /
26818 // [`SUPERVISOR_CHILD_KEY_VERSAO`] / [`SUPERVISOR_CHILD_KEY_RESTART`]
26819 // per-entry sub-mapping triad on the M2 typed
26820 // `:supervisor :children` surface — extends the discipline onto
26821 // the Helm 3 `Chart.yaml` per-chart-dependency-list surface.
26822 for child in [
26823 HELM_CHART_DEPENDENCY_KEY_NAME,
26824 HELM_CHART_DEPENDENCY_KEY_VERSION,
26825 HELM_CHART_DEPENDENCY_KEY_REPOSITORY,
26826 HELM_CHART_DEPENDENCY_KEY_ALIAS,
26827 ] {
26828 assert_ne!(
26829 HELM_CHART_KEY_DEPENDENCIES, child,
26830 "HELM_CHART_KEY_DEPENDENCIES \
26831 ({HELM_CHART_KEY_DEPENDENCIES:?}) must remain \
26832 byte-distinct from every per-`dependencies[]`-entry \
26833 sub-mapping key ({child:?}) — a collapse silently \
26834 orphans the parent list-container at `helm lint` / \
26835 `helm dependency build` time"
26836 );
26837 }
26838 }
26839
26840 #[test]
26841 fn helm_chart_dependency_key_tetrad_pins_canonical_values() {
26842 // Byte-string pin on the per-`dependencies[]`-entry sub-mapping
26843 // YAML axis-key tetrad the Helm 3 chart-schema pins for every
26844 // per-dep entry the substrate emits under the top-level
26845 // `dependencies:` list at every rendered `lareira-<nome>`
26846 // Chart.yaml. The four axis-keys name the four load-bearing
26847 // per-dep sub-mapping fields Helm's per-dep resolver consumes
26848 // at `helm dependency build` / `helm dependency update` time:
26849 // `name` (the Helm-registry chart name), `version` (the SemVer-
26850 // range constraint), `repository` (the registry URL to fetch
26851 // from), and `alias` (the per-dep values wrap-key override).
26852 // A drift on any const's value (a typo on this lift, a case
26853 // flip to `"Name"` / `"Version"` / `"Repository"` / `"Alias"`,
26854 // an accidental collapse onto a sibling axis-key) would
26855 // silently rebrand the wire key at the `caixa_helm::ChartYaml`
26856 // emitter site — Helm's chart-schema parser silently drops
26857 // the drifted per-dep sub-mapping field, and the per-dep
26858 // resolver falls back to the parsed-shape defaults
26859 // (`""` / wildcard `*` / "no repository defined") at
26860 // `helm dependency build` time far from the drift site. Peer
26861 // to [`supervisor_child_key_tetrad_pins_canonical_values`] on
26862 // the sibling per-`:children` sub-mapping tetrad (ef912df) and
26863 // [`entrada_key_tetrad_pins_canonical_values`] on the sibling
26864 // per-`:entrada` sub-mapping tetrad (a3d6162).
26865 assert_eq!(HELM_CHART_DEPENDENCY_KEY_NAME, "name");
26866 assert_eq!(HELM_CHART_DEPENDENCY_KEY_VERSION, "version");
26867 assert_eq!(HELM_CHART_DEPENDENCY_KEY_REPOSITORY, "repository");
26868 assert_eq!(HELM_CHART_DEPENDENCY_KEY_ALIAS, "alias");
26869 }
26870
26871 #[test]
26872 fn helm_chart_dependency_key_name_matches_kube_key_name() {
26873 // Load-bearing byte-shape coincidence between the Helm 3
26874 // Chart.yaml per-`dependencies[]`-entry sub-mapping name key
26875 // ([`HELM_CHART_DEPENDENCY_KEY_NAME`]) and the K8s CR
26876 // per-`metadata` sub-mapping name key ([`KUBE_KEY_NAME`]) —
26877 // Helm inherits the K8s CR body-key vocabulary at every schema
26878 // surface it consumes (chart-metadata top-level, per-CR
26879 // install-payload, per-dep dependency-list). The two axes are
26880 // structurally-independent schema surfaces (the Helm 3
26881 // chart-schema per-dep entry vs. the K8s apiserver-side CR
26882 // metadata block) whose byte-shapes happen to coincide today;
26883 // this pin makes the byte-shape coincidence load-bearing
26884 // rather than accidental so a future K8s-side rebrand at
26885 // [`KUBE_KEY_NAME`] (or a Helm-side rebrand at
26886 // [`HELM_CHART_DEPENDENCY_KEY_NAME`]) that dropped the
26887 // byte-identity would fail the pin at substrate-build time
26888 // rather than as a silent Helm-per-dep-resolver drop at
26889 // `helm dependency build` time far from the drift site. Same
26890 // discipline as the peer
26891 // [`helm_chart_key_api_version_matches_kube_key_api_version`]
26892 // pin on the sibling top-level chart-schema-apiVersion axis
26893 // (cc44e4b) — extends the axis-key byte-identity coincidence
26894 // discipline from the per-Chart.yaml top-level shape onto the
26895 // per-`dependencies[]`-entry sub-mapping shape.
26896 assert_eq!(
26897 HELM_CHART_DEPENDENCY_KEY_NAME, KUBE_KEY_NAME,
26898 "HELM_CHART_DEPENDENCY_KEY_NAME ({HELM_CHART_DEPENDENCY_KEY_NAME:?}) \
26899 must remain byte-identical to KUBE_KEY_NAME ({KUBE_KEY_NAME:?}) — \
26900 Helm 3 inherits the K8s CR body-key vocabulary at every schema \
26901 surface, and every downstream consumer that navigates a per-dep \
26902 sub-mapping / a K8s CR metadata block by the `name` key reads the \
26903 byte-identical `\"name\"` key; a drift on either side silently \
26904 reroutes the consumer through a schema-parser drop far from the \
26905 drift site"
26906 );
26907 }
26908
26909 #[test]
26910 fn helm_chart_readme_filename_pins_canonical_value() {
26911 // Pin the actual byte-string so a typo on the canonical lift
26912 // can't silently rebrand the third leg of the per-`lareira-<nome>`
26913 // chart-directory `{Chart.yaml, values.yaml, README.md}`
26914 // canonical-per-chart-directory-filename axis triple. Peer to
26915 // the sibling
26916 // [`HELM_CHART_YAML_FILENAME`] / [`HELM_VALUES_YAML_FILENAME`]
26917 // canonical filename axes — the two schema-load-bearing halves
26918 // of the triple the sibling
26919 // [`HELM_VALUES_YAML_FILENAME`] docstring's closing paragraph
26920 // explicitly names as the pair that needed the third-leg
26921 // (`README.md`) filename half to close the discipline across
26922 // every `ChartFile` the [`caixa_helm::render_chart_for_servico`]
26923 // emitter's `ChartDir::files` vec carries. A drifted per-chart
26924 // readme filename value would surface downstream as GitHub /
26925 // Artifact Hub / any per-chart README-surfacing UI silently
26926 // falling back to "no README available" for the rendered
26927 // `lareira-<nome>` chart — the chart lists with no per-chart
26928 // elevator pitch or install instructions far from the drift
26929 // commit's source, with no field naming the readme-filename-
26930 // drift root cause. Same pin discipline as the peer
26931 // canonical-Helm-per-chart-directory-filename axes.
26932 assert_eq!(HELM_CHART_README_FILENAME, "README.md");
26933 }
26934
26935 #[test]
26936 fn helm_chart_readme_filename_carries_readme_dot_md_shape() {
26937 // Cross-axis invariant: the per-`lareira-<nome>`-chart-directory
26938 // human-facing readme filename carries the `.md` Markdown
26939 // extension the [`caixa_helm::build_readme`] emitter's Markdown-
26940 // shaped body targets — a drift to `.txt` / `.rst` /
26941 // extensionless / a per-fork rename would silently reroute the
26942 // rendered readme through a downstream tool that reads by
26943 // extension for its Markdown renderer (GitHub's per-repo README
26944 // surfacer, Artifact Hub's per-chart README surfacer, every
26945 // per-chart-directory `find . -name README.md` navigator any
26946 // downstream tooling might use). Peer to the sibling
26947 // [`HELM_CHART_YAML_FILENAME`] / [`HELM_VALUES_YAML_FILENAME`]
26948 // schema-load-bearing filename halves — the two YAML halves
26949 // carry the `.yaml` extension per Helm's per-chart-schema
26950 // convention; the readme half carries the `.md` extension per
26951 // the substrate's per-chart human-facing convention. Distinct
26952 // per-half schema conventions do not collapse on the shared
26953 // `<name>.<ext>` shape gate.
26954 let v = HELM_CHART_README_FILENAME;
26955 assert!(
26956 !v.is_empty(),
26957 "HELM_CHART_README_FILENAME {v:?} must be non-empty per the \
26958 per-`lareira-<nome>`-chart-directory readme-file axis"
26959 );
26960 assert!(
26961 v.ends_with(".md"),
26962 "HELM_CHART_README_FILENAME {v:?} must carry the `.md` \
26963 Markdown extension per the substrate's per-chart human-\
26964 facing readme convention — a drifted extension (`.txt` / \
26965 `.rst` / extensionless) would silently reroute downstream \
26966 tooling's Markdown renderer (GitHub's per-repo README \
26967 surfacer, Artifact Hub's per-chart README surfacer) to a \
26968 non-Markdown fallback path"
26969 );
26970 }
26971
26972 // ── lareira-<nome> chart-name prefix lift ──────────────────────
26973 //
26974 // The lift pins the substrate-wide `lareira-` chart-name prefix
26975 // as the single source of truth every per-Servico renderer
26976 // (caixa-helm, caixa-flux, caixa-tatara) reaches for, peer to the
26977 // [`DEFAULT_NAMESPACE`] (a085b26) lift on the canonical-namespace
26978 // axis. Pinning the prefix value, the helper's
26979 // construction-shape, and the DNS-1123-label round-trip for the
26980 // canonical-fixture input forms the structural floor every future
26981 // renderer consumer inherits by construction.
26982
26983 #[test]
26984 fn lareira_chart_name_prefix_pins_canonical_value() {
26985 // Pin the actual string value so a typo on the canonical lift
26986 // can't silently rebrand the substrate's per-Servico Helm chart
26987 // namespace. The string is part of the contract with the OCI
26988 // chart-publishing pipeline (`oci://<registry>/lareira-<nome>`),
26989 // the per-cluster HelmRelease `chart:` field (which Flux
26990 // resolves through the OCI ref), and the historical
26991 // `pleme-io/helmworks/charts/lareira-<name>/` source tree
26992 // layout (caixa-helm/src/lib.rs:7); changing it is a
26993 // coordinated multi-repo migration, not an incidental edit.
26994 // Peer to `default_namespace_pins_canonical_value` on the
26995 // canonical-string-value-pin axis for the
26996 // `DEFAULT_NAMESPACE` constant.
26997 assert_eq!(LAREIRA_CHART_NAME_PREFIX, "lareira-");
26998 }
26999
27000 #[test]
27001 fn lareira_chart_name_composes_prefix_and_nome() {
27002 // Pin the helper's construction shape — the chart name is the
27003 // prefix concatenated with the caixa's `:nome` verbatim, with
27004 // no intermediate hyphen, no path separator, no trimming. Pin
27005 // the canonical hello-rio fixture (the in-tree
27006 // `caixa-helm` test fixture at caixa-helm/src/lib.rs:431
27007 // already asserts `dir.name == "lareira-hello-rio"`, which
27008 // this helper now derives) and a peer fixture
27009 // (`checkout-aplicacao` member) to sweep the typical author
27010 // surface.
27011 assert_eq!(lareira_chart_name("hello-rio"), "lareira-hello-rio");
27012 assert_eq!(lareira_chart_name("cart"), "lareira-cart");
27013 assert_eq!(lareira_chart_name("worker"), "lareira-worker");
27014 }
27015
27016 #[test]
27017 fn lareira_chart_name_starts_with_prefix() {
27018 // Cross-axis invariant: every output of the helper begins with
27019 // the lifted prefix verbatim — a future refactor that
27020 // accidentally introduced a different prefix-application
27021 // shape (e.g. `format!("{nome}-lareira")` transposition, or a
27022 // `to_uppercase()` case fold) would surface here. The
27023 // structural pin holds for the empty `:nome` shape too
27024 // (a value `validate_nome` rejects upstream, but the helper
27025 // itself imposes no shape on the input).
27026 for nome in ["hello-rio", "cart", "worker", "a", ""] {
27027 let chart = lareira_chart_name(nome);
27028 assert!(
27029 chart.starts_with(LAREIRA_CHART_NAME_PREFIX),
27030 "lareira_chart_name({nome:?}) = {chart:?} must start with the lifted prefix \
27031 {LAREIRA_CHART_NAME_PREFIX:?}"
27032 );
27033 }
27034 }
27035
27036 #[test]
27037 fn lareira_chart_name_round_trips_through_dns_1123_for_validated_nome() {
27038 // Cross-axis invariant: every `:nome` past
27039 // [`Caixa::validate_nome`] (6c992f8) is a valid DNS-1123 label,
27040 // and the prepended `lareira-` segment is itself a valid
27041 // DNS-1123 label prefix (lowercase ASCII + hyphen with a
27042 // terminating-hyphen continuation). The composition therefore
27043 // round-trips through [`is_dns_1123_label`] for every
27044 // `:nome` whose joint length with the prefix stays ≤ 63 bytes
27045 // (the DNS-1123 label cap). The canonical author surface sits
27046 // far below that cap (the in-tree fixtures range from
27047 // `"a"` = 9-byte chart name to `"checkout"` = 16 bytes, with
27048 // the cap admitting up to 55-byte `:nome` values). Pin the
27049 // round-trip for the canonical-fixture set so a future renderer
27050 // that lands the helper's output verbatim as a K8s
27051 // `metadata.name` (caixa-helm's `ChartDir.name`,
27052 // caixa-flux's HelmRelease `chart:` field, caixa-tatara's
27053 // `release_name`) inherits the apiserver-valid floor by
27054 // construction.
27055 for nome in ["hello-rio", "cart", "worker", "checkout", "a"] {
27056 let chart = lareira_chart_name(nome);
27057 assert!(
27058 is_dns_1123_label(&chart).is_ok(),
27059 "lareira_chart_name({nome:?}) = {chart:?} must be a valid DNS-1123 label"
27060 );
27061 }
27062 }
27063
27064 #[test]
27065 fn lareira_chart_name_prefix_is_a_valid_dns_1123_segment_continuation() {
27066 // The lifted prefix is one substring of the rendered chart
27067 // name; pin its grammar so a future rebrand can't land a
27068 // value that would invalidate the joint DNS-1123 label
27069 // structurally. The prefix must:
27070 // - be lowercase ASCII alphanumeric + hyphen (the DNS-1123
27071 // accepted set), so its bytes don't widen the joint
27072 // accepted set;
27073 // - end with a hyphen (so the concatenation slot doesn't
27074 // accidentally merge with the leading character of the
27075 // `:nome` it precedes).
27076 assert!(
27077 LAREIRA_CHART_NAME_PREFIX
27078 .bytes()
27079 .all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'-'),
27080 "LAREIRA_CHART_NAME_PREFIX {LAREIRA_CHART_NAME_PREFIX:?} must use only DNS-1123-label \
27081 bytes (lowercase ASCII alphanumeric + hyphen)"
27082 );
27083 assert!(
27084 LAREIRA_CHART_NAME_PREFIX.ends_with('-'),
27085 "LAREIRA_CHART_NAME_PREFIX {LAREIRA_CHART_NAME_PREFIX:?} must end with `-` so \
27086 concatenation with the caixa's `:nome` produces a hyphenated joint label"
27087 );
27088 }
27089
27090 // ── is_lareira_chart_name_shape — joint-length budget on `:nome` ─────
27091 //
27092 // The canonical [`lareira_chart_name`] helper's own doc comment
27093 // (f7320d7) explicitly defers: "the M4 admission webhook will pin
27094 // the joint-length invariant when it lands". These tests land it
27095 // at the manifest-validate layer instead — the predicate consults
27096 // [`lareira_chart_name`] + [`is_dns_1123_label`] (no third primitive)
27097 // so a future rebrand of either axis re-derives the budget
27098 // mechanically and the test suite re-pins through the same lifts.
27099
27100 #[test]
27101 fn lareira_chart_name_nome_max_len_pins_arithmetic() {
27102 // Pin the arithmetic so a future shift in either input axis
27103 // surfaces here. The const is mechanically derived from
27104 // [`DNS_1123_LABEL_MAX_LEN`] (63 — the K8s apiserver cap every
27105 // chart-name-derived `metadata.name` inherits) minus
27106 // [`LAREIRA_CHART_NAME_PREFIX`].len() (8 — the canonical
27107 // chart-name prefix the lift f7320d7 made structural). The
27108 // landing value: 55 bytes the caixa's `:nome` may itself
27109 // occupy under the joint chart-name cap.
27110 assert_eq!(LAREIRA_CHART_NAME_NOME_MAX_LEN, 55);
27111 assert_eq!(
27112 LAREIRA_CHART_NAME_NOME_MAX_LEN,
27113 DNS_1123_LABEL_MAX_LEN - LAREIRA_CHART_NAME_PREFIX.len()
27114 );
27115 }
27116
27117 #[test]
27118 fn is_lareira_chart_name_shape_accepts_canonical_fixtures() {
27119 // Positive control: every in-tree fixture `:nome` (caixa-helm,
27120 // caixa-flux, caixa-mesh, caixa-tatara tests, the
27121 // checkout-aplicacao example) sits far below the cap. The
27122 // predicate must not regress this baseline shape.
27123 for nome in [
27124 "hello-rio",
27125 "cart",
27126 "worker",
27127 "checkout",
27128 "a",
27129 "akeyless-attest",
27130 ] {
27131 is_lareira_chart_name_shape(nome).unwrap_or_else(|e| {
27132 panic!("canonical :nome {nome:?} must pass chart-name budget, got {e:?}")
27133 });
27134 }
27135 }
27136
27137 #[test]
27138 fn is_lareira_chart_name_shape_accepts_nome_at_budget() {
27139 // Boundary-accepting case at the 55-byte cap — the joint
27140 // chart name is exactly 63 bytes, the DNS-1123 label cap.
27141 let at_cap = "a".repeat(LAREIRA_CHART_NAME_NOME_MAX_LEN);
27142 assert_eq!(at_cap.len(), LAREIRA_CHART_NAME_NOME_MAX_LEN);
27143 is_lareira_chart_name_shape(&at_cap).unwrap();
27144 assert_eq!(lareira_chart_name(&at_cap).len(), DNS_1123_LABEL_MAX_LEN);
27145 }
27146
27147 #[test]
27148 fn is_lareira_chart_name_shape_rejects_nome_one_over_budget() {
27149 // Fail-before-pass-after pin: 56 bytes is the smallest `:nome`
27150 // length that overflows the joint chart-name cap. The inner
27151 // [`is_dns_1123_label`] check accepts it (56 ≤ 63), so prior
27152 // to this gate it silently passed `Caixa::validate_nome` and
27153 // surfaced as a `helm lint` / apiserver rejection on the
27154 // rendered chart name far from the source caixa.lisp.
27155 let over = "a".repeat(LAREIRA_CHART_NAME_NOME_MAX_LEN + 1);
27156 let err = is_lareira_chart_name_shape(&over).unwrap_err();
27157 assert!(
27158 err.contains("63") && err.contains("64") && err.contains("55"),
27159 "diagnostic must name the DNS-1123 cap (63), the actual chart-name length (64), \
27160 and the per-`:nome` budget (55), got {err:?}"
27161 );
27162 assert!(
27163 err.contains("lareira-"),
27164 "diagnostic must name the canonical prefix verbatim, got {err:?}"
27165 );
27166 }
27167
27168 #[test]
27169 fn is_lareira_chart_name_shape_diagnostic_carries_offending_chart_name() {
27170 // The rendered chart name appears verbatim in the diagnostic
27171 // so the author sees exactly the string the apiserver would
27172 // have rejected — no re-derivation required to grep the source.
27173 let over = "x".repeat(LAREIRA_CHART_NAME_NOME_MAX_LEN + 5);
27174 let err = is_lareira_chart_name_shape(&over).unwrap_err();
27175 let expected_chart = lareira_chart_name(&over);
27176 assert!(
27177 err.contains(&expected_chart),
27178 "diagnostic must carry the rendered chart name {expected_chart:?} verbatim, \
27179 got {err:?}"
27180 );
27181 }
27182
27183 #[test]
27184 fn is_lareira_chart_name_shape_composes_through_canonical_helper() {
27185 // Cross-axis invariant: the predicate is defined exactly as
27186 // `is_dns_1123_label(lareira_chart_name(nome))` for the length
27187 // arm — no inline `format!("lareira-{nome}")` shape duplicating
27188 // the canonical lift. Pinning this composition closes the
27189 // drift footgun where a future predicate refactor re-inlines
27190 // the prefix-and-`:nome` concatenation and diverges from the
27191 // canonical helper. Sweep across the boundary so both sides
27192 // (accept + reject) consult the same helper.
27193 for delta in 0..=2usize {
27194 let nome = "z".repeat(LAREIRA_CHART_NAME_NOME_MAX_LEN.saturating_sub(delta));
27195 let predicate_ok = is_lareira_chart_name_shape(&nome).is_ok();
27196 let canonical_ok = is_dns_1123_label(&lareira_chart_name(&nome)).is_ok();
27197 assert_eq!(
27198 predicate_ok,
27199 canonical_ok,
27200 "predicate / canonical-composition divergence for :nome of len {} \
27201 (predicate_ok = {predicate_ok}, canonical_ok = {canonical_ok})",
27202 nome.len()
27203 );
27204 }
27205 }
27206
27207 // ── OCI chart-ref composer — `oci://<registry>/lareira-<nome>` ───────
27208 //
27209 // Peer to the `lareira_chart_name` composer above on the sibling
27210 // OCI-artifact-reference axis. Until this lift landed the
27211 // `caixa-tatara`'s `derive_chart_ref` carried an inline
27212 // `format!("oci://{registry}/{chart}")` — a 2-axis composition
27213 // (the `oci://` scheme prefix + the `lareira-<nome>` chart name)
27214 // whose byte-shape had no compile-time link to the historical doc
27215 // comments across `caixa-core`, `caixa-flux`, `caixa-helm`, and
27216 // `caixa-tatara` promising the same shape. Pin the const, the
27217 // composition equation, and the byte-shape against the prior
27218 // inline `format!` so a future composer-internal drift fires at
27219 // test time.
27220
27221 #[test]
27222 fn oci_scheme_prefix_pins_canonical_value() {
27223 // Pin the actual string value so a typo on the canonical lift
27224 // can't silently rebrand the substrate's OCI-artifact-reference
27225 // scheme. The string is part of the contract with the Helm 3
27226 // OCI storage protocol (`helm push chart.tgz oci://…`,
27227 // `helm registry login <registry>`, `helm install release
27228 // oci://…`) and the FluxCD `HelmRepository` `type: oci` source
27229 // (Flux source-controller keys off this literal on the OCI
27230 // path); changing it is a coordinated multi-repo migration,
27231 // not an incidental edit. Peer to
27232 // [`lareira_chart_name_prefix_pins_canonical_value`] on the
27233 // sibling canonical-string-value-pin axis.
27234 assert_eq!(OCI_SCHEME_PREFIX, "oci://");
27235 }
27236
27237 #[test]
27238 fn oci_chart_ref_pins_byte_shape_against_prior_inline_format() {
27239 // Byte-shape pin against the prior inline
27240 // `format!("oci://{registry}/{chart}")` at
27241 // caixa-tatara/src/lib.rs:202 (where `chart` was itself
27242 // `lareira_chart_name(caixa.nome.as_str())`). Any future
27243 // composer-internal drift on either axis (the `oci://` scheme
27244 // prefix, the `/` scheme-authority separator, the composition
27245 // with `lareira_chart_name`) surfaces here as a byte-shape
27246 // regression rather than at cluster-apply time far from the
27247 // drift site.
27248 assert_eq!(
27249 oci_chart_ref("ghcr.io/pleme-io/charts", "akeyless-attest"),
27250 "oci://ghcr.io/pleme-io/charts/lareira-akeyless-attest"
27251 );
27252 assert_eq!(
27253 oci_chart_ref("ghcr.io/pleme-io", "hello-rio"),
27254 "oci://ghcr.io/pleme-io/lareira-hello-rio"
27255 );
27256 }
27257
27258 #[test]
27259 fn oci_chart_ref_composes_through_canonical_helpers() {
27260 // Structural composition equation: the OCI chart-ref is
27261 // exactly `{OCI_SCHEME_PREFIX}{registry}/{lareira_chart_name(nome)}`
27262 // — no inline `"oci://"` scheme literal, no inline
27263 // `format!("lareira-{}", nome)` prefix duplication. Pinning
27264 // this composition closes the drift footgun where a future
27265 // composer refactor re-inlines either axis and diverges from
27266 // its canonical source of truth. Sweep across the canonical
27267 // fixture set so the composition holds for the same `:nome`
27268 // values every peer per-Servico renderer consults.
27269 for (registry, nome) in [
27270 ("ghcr.io/pleme-io/charts", "hello-rio"),
27271 ("ghcr.io/pleme-io", "cart"),
27272 ("registry.example.com", "worker"),
27273 ("localhost:5000", "checkout"),
27274 ] {
27275 let composed = oci_chart_ref(registry, nome);
27276 let expected = format!("{OCI_SCHEME_PREFIX}{registry}/{}", lareira_chart_name(nome));
27277 assert_eq!(
27278 composed, expected,
27279 "oci_chart_ref({registry:?}, {nome:?}) must equal the canonical composition \
27280 through OCI_SCHEME_PREFIX + lareira_chart_name"
27281 );
27282 }
27283 }
27284
27285 #[test]
27286 fn oci_chart_ref_starts_with_scheme_prefix() {
27287 // Cross-axis invariant: every output of the composer begins
27288 // with the lifted scheme prefix verbatim — a future refactor
27289 // that accidentally introduced a different scheme (e.g. a
27290 // `https://` transposition, or a scheme-authority separator
27291 // drift) would surface here. Peer to
27292 // [`lareira_chart_name_starts_with_prefix`] on the sibling
27293 // per-composer prefix-anchoring axis.
27294 for (registry, nome) in [
27295 ("ghcr.io/pleme-io/charts", "hello-rio"),
27296 ("ghcr.io/pleme-io", "cart"),
27297 ("localhost:5000", "a"),
27298 ] {
27299 let composed = oci_chart_ref(registry, nome);
27300 assert!(
27301 composed.starts_with(OCI_SCHEME_PREFIX),
27302 "oci_chart_ref({registry:?}, {nome:?}) = {composed:?} must start with the lifted \
27303 prefix {OCI_SCHEME_PREFIX:?}"
27304 );
27305 }
27306 }
27307
27308 #[test]
27309 fn oci_chart_ref_contains_lareira_chart_name_verbatim() {
27310 // Cross-axis invariant: every output of the composer contains
27311 // the canonical `lareira_chart_name(nome)` output verbatim as
27312 // its trailing segment — a future refactor that accidentally
27313 // introduced a case fold, a hyphen-collapse, or a different
27314 // prefix-application shape would surface here. Structurally
27315 // pins that the OCI chart-ref path and the peer per-Servico
27316 // renderer chart-name path (caixa-helm's `ChartDir.name`,
27317 // caixa-flux's `HelmRelease` `chart:` field) both reach for
27318 // the same canonical `lareira_chart_name` helper's output.
27319 for (registry, nome) in [
27320 ("ghcr.io/pleme-io/charts", "hello-rio"),
27321 ("ghcr.io/pleme-io", "cart"),
27322 ] {
27323 let composed = oci_chart_ref(registry, nome);
27324 let chart = lareira_chart_name(nome);
27325 assert!(
27326 composed.ends_with(&chart),
27327 "oci_chart_ref({registry:?}, {nome:?}) = {composed:?} must end with the canonical \
27328 lareira_chart_name({nome:?}) = {chart:?}"
27329 );
27330 }
27331 }
27332
27333 // ── Flux Kustomization source-sub-tree composer ───────────────────────
27334 //
27335 // Peer to the `oci_chart_ref` / `cilium_network_policy_name` /
27336 // `gateway_api_http_route_name` composers above on the sibling
27337 // canonical-load-bearing-scalar-that-consumers-key-off axis. Until
27338 // this lift landed the two-axis composition
27339 // (`./clusters/<cluster>/services/<nome>`) sat as an inline
27340 // `format!` template at the sole `caixa-flux::cluster_bundle`
27341 // `kustomization.yaml` production emit site plus a mirror-symmetric
27342 // inline `format!` at its paired test-fixture navigation site — no
27343 // compile-time link between the two sites and no compile-time link
27344 // ahead of the second production-emit occurrence the M4
27345 // `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
27346 // `Kustomization` synthesis will surface. Pin the byte-shape, the
27347 // composition equation, and the sub-tree-scope invariants against
27348 // the prior inline `format!` so a future composer-internal drift
27349 // fires at test time.
27350
27351 #[test]
27352 fn flux_kustomization_source_subtree_pins_byte_shape_against_prior_inline_format() {
27353 // Byte-shape pin against the prior inline
27354 // `format!("./clusters/{cluster}/services/{name}")` at
27355 // caixa-flux/src/lib.rs (both the `cluster_bundle`
27356 // `kustomization.yaml` `spec.path` production emit site and the
27357 // paired `cluster_bundle_kustomization_path_pins_lifted_sub_tree`
27358 // test-fixture navigation site). Any future composer-internal
27359 // drift on either axis (the `./clusters/` per-cluster prefix,
27360 // the `/services/` per-caixa infix, the trailing per-caixa
27361 // suffix, the composition order) surfaces here as a byte-shape
27362 // regression rather than at cluster-apply time far from the
27363 // drift site.
27364 assert_eq!(
27365 flux_kustomization_source_subtree("rio", "hello-rio"),
27366 "./clusters/rio/services/hello-rio"
27367 );
27368 assert_eq!(
27369 flux_kustomization_source_subtree("paris", "cart"),
27370 "./clusters/paris/services/cart"
27371 );
27372 assert_eq!(
27373 flux_kustomization_source_subtree("tokyo", "checkout"),
27374 "./clusters/tokyo/services/checkout"
27375 );
27376 }
27377
27378 #[test]
27379 fn flux_kustomization_source_subtree_starts_with_relative_clusters_prefix() {
27380 // Structural invariant: every output starts with the canonical
27381 // `./clusters/` per-cluster-prefix half of the sub-tree seed.
27382 // The leading `./` scopes the emit to the GitRepository root
27383 // (the kustomize-controller keys the per-CR reconcile loop off
27384 // the GitRepository the paired `sourceRef` names, so the sub-
27385 // tree seed must resolve relative to the GitRepository root,
27386 // not an absolute filesystem path). The `clusters/` component
27387 // scopes the emit to the paired cluster's manifest set under
27388 // the pleme-io k8s repository's canonical directory-tree
27389 // layout.
27390 for (cluster, nome) in [
27391 ("rio", "hello-rio"),
27392 ("paris", "cart"),
27393 ("tokyo", "checkout"),
27394 ] {
27395 let sub = flux_kustomization_source_subtree(cluster, nome);
27396 assert!(
27397 sub.starts_with("./clusters/"),
27398 "flux_kustomization_source_subtree({cluster:?}, {nome:?}) = {sub:?} must start \
27399 with the canonical `./clusters/` GitRepository-root-relative per-cluster prefix"
27400 );
27401 }
27402 }
27403
27404 #[test]
27405 fn flux_kustomization_source_subtree_contains_paired_cluster_and_nome() {
27406 // Cross-axis invariant: every output contains the paired
27407 // `<cluster>` and `<nome>` scalars verbatim, at their canonical
27408 // per-cluster / per-caixa sub-tree positions. A future
27409 // composer-internal drift that accidentally case-folded, hyphen-
27410 // collapsed, or transposed either axis (`./clusters/rio/services/hello-rio`
27411 // → `./clusters/hello-rio/services/rio` under a swapped
27412 // composition, `./clusters/Rio/services/HelloRio` under an
27413 // accidental case fold) would surface here as a structural
27414 // regression rather than at cluster-apply time far from the
27415 // drift site.
27416 for (cluster, nome) in [
27417 ("rio", "hello-rio"),
27418 ("paris", "cart"),
27419 ("tokyo", "checkout"),
27420 ("us-east-1", "worker"),
27421 ] {
27422 let sub = flux_kustomization_source_subtree(cluster, nome);
27423 assert!(
27424 sub.contains(&format!("/clusters/{cluster}/")),
27425 "flux_kustomization_source_subtree({cluster:?}, {nome:?}) = {sub:?} must carry \
27426 the paired `<cluster>` scalar under its canonical per-cluster sub-tree position"
27427 );
27428 assert!(
27429 sub.ends_with(&format!("/services/{nome}")),
27430 "flux_kustomization_source_subtree({cluster:?}, {nome:?}) = {sub:?} must end with \
27431 the paired `/services/<nome>` per-caixa sub-tree suffix"
27432 );
27433 }
27434 }
27435
27436 #[test]
27437 fn flux_kustomization_source_subtree_distinct_across_clusters_and_nomes() {
27438 // Uniqueness invariant: two distinct `(cluster, nome)` inputs
27439 // resolve to two distinct `spec.path` scalars. A composer-
27440 // internal drift that accidentally coalesced either axis onto
27441 // a constant (dropping `<cluster>` or `<nome>` from the emit)
27442 // would silently collapse two per-cluster / per-caixa
27443 // `Kustomization` CRs onto the same reconcile-target sub-tree,
27444 // routing two distinct manifest sets through the same apply
27445 // loop with no diagnostic naming the coalesce root cause.
27446 let a = flux_kustomization_source_subtree("rio", "hello-rio");
27447 let b = flux_kustomization_source_subtree("paris", "hello-rio");
27448 let c = flux_kustomization_source_subtree("rio", "cart");
27449 assert_ne!(
27450 a, b,
27451 "distinct clusters (`rio` vs `paris`) hosting the same per-caixa Servico \
27452 must resolve to distinct `spec.path` scalars — coalesce would silently route \
27453 two per-cluster reconcile loops through the same manifest sub-tree"
27454 );
27455 assert_ne!(
27456 a, c,
27457 "distinct per-caixa Servicos (`hello-rio` vs `cart`) co-resident under the \
27458 same cluster must resolve to distinct `spec.path` scalars — coalesce would \
27459 silently route two per-caixa reconcile loops through the same manifest sub-tree"
27460 );
27461 }
27462
27463 #[test]
27464 fn pleme_program_selector_carries_only_program() {
27465 let sel = pleme_program_selector("cart");
27466 assert_eq!(sel.len(), 1);
27467 assert_eq!(sel.get(LABEL_PROGRAM).map(String::as_str), Some("cart"));
27468 assert!(sel.get(LABEL_APLICACAO).is_none());
27469 }
27470
27471 #[test]
27472 fn pleme_program_in_aplicacao_selector_carries_both_axes() {
27473 let sel = pleme_program_in_aplicacao_selector("cart", "checkout");
27474 assert_eq!(sel.len(), 2);
27475 assert_eq!(sel.get(LABEL_PROGRAM).map(String::as_str), Some("cart"));
27476 assert_eq!(
27477 sel.get(LABEL_APLICACAO).map(String::as_str),
27478 Some("checkout")
27479 );
27480 }
27481
27482 #[test]
27483 fn pleme_program_in_aplicacao_selector_iterates_alphabetically() {
27484 // BTreeMap iteration is sorted by key — pin that the renderer
27485 // (which translates the selector into a serde_yaml::Mapping
27486 // by iteration) gets a deterministic key order. `aplicacao`
27487 // sorts before `program`, so the rendered YAML's
27488 // `matchLabels:` block appears in that order regardless of
27489 // call-site arg order. Mirrors the M2 overlay helper's
27490 // alphabetical-iteration determinism property
27491 // (THEORY.md §V.2.7 render determinism).
27492 let sel = pleme_program_in_aplicacao_selector("cart", "checkout");
27493 let keys: Vec<_> = sel.keys().copied().collect();
27494 assert_eq!(keys, vec![LABEL_APLICACAO, LABEL_PROGRAM]);
27495 }
27496
27497 #[test]
27498 fn pleme_program_in_aplicacao_selector_arg_order_independent() {
27499 // Renaming the program vs. the aplicacao must each only affect
27500 // its own axis — pin that the helper doesn't transpose its
27501 // args silently (a footgun the prior inline-string approach
27502 // had: `program: <de>` and `aplicacao: <name>` were two
27503 // adjacent insert() calls with structurally identical arms,
27504 // trivially swappable in a refactor).
27505 let sel = pleme_program_in_aplicacao_selector("cart", "checkout");
27506 assert_eq!(sel.get(LABEL_PROGRAM).map(String::as_str), Some("cart"));
27507 assert_eq!(
27508 sel.get(LABEL_APLICACAO).map(String::as_str),
27509 Some("checkout")
27510 );
27511 let swapped = pleme_program_in_aplicacao_selector("checkout", "cart");
27512 assert_eq!(
27513 swapped.get(LABEL_PROGRAM).map(String::as_str),
27514 Some("checkout")
27515 );
27516 assert_eq!(
27517 swapped.get(LABEL_APLICACAO).map(String::as_str),
27518 Some("cart")
27519 );
27520 }
27521
27522 #[test]
27523 fn yaml_string_mapping_empty_input_returns_empty_mapping() {
27524 // Empty input → empty Mapping. Pinned because the caller's
27525 // emptiness contract (e.g. caixa-mesh's CNP labels block: the
27526 // policy's metadata.labels exists iff there are pleme-prefixed
27527 // labels to carry) depends on this being faithful.
27528 let v: serde_yaml::Value = yaml_string_mapping(BTreeMap::<&'static str, String>::new());
27529 let m = v.as_mapping().expect("mapping shape");
27530 assert!(m.is_empty());
27531 }
27532
27533 #[test]
27534 fn yaml_string_mapping_round_trips_string_values() {
27535 let mut input = BTreeMap::new();
27536 input.insert("foo", "1".to_string());
27537 input.insert("bar", "2".to_string());
27538 let v = yaml_string_mapping(input);
27539 let m = v.as_mapping().expect("mapping shape");
27540 assert_eq!(m.len(), 2);
27541 assert_eq!(m.get("foo").and_then(|x| x.as_str()), Some("1"));
27542 assert_eq!(m.get("bar").and_then(|x| x.as_str()), Some("2"));
27543 }
27544
27545 #[test]
27546 fn yaml_string_mapping_iterates_alphabetically_on_btreemap() {
27547 // Pin that BTreeMap input → alphabetical iteration → alphabetical
27548 // YAML key order. THEORY.md §V.2.7 render determinism.
27549 let mut input = BTreeMap::new();
27550 input.insert("zebra", "z".to_string());
27551 input.insert("apple", "a".to_string());
27552 input.insert("mango", "m".to_string());
27553 let v = yaml_string_mapping(input);
27554 let m = v.as_mapping().expect("mapping shape");
27555 let keys: Vec<&str> = m.iter().filter_map(|(k, _)| k.as_str()).collect();
27556 assert_eq!(keys, vec!["apple", "mango", "zebra"]);
27557 }
27558
27559 #[test]
27560 fn yaml_string_mapping_accepts_pleme_selector_helpers() {
27561 // The lift's load-bearing use case: passing the typed pleme-io
27562 // selectors directly into yaml_string_mapping yields the K8s
27563 // matchLabels surface every Cilium / Gateway selector field
27564 // expects, with the alphabetical key order the pleme helpers'
27565 // own determinism contract guarantees. Pinning end-to-end
27566 // composition so a future refactor of either helper can't
27567 // silently break the integration.
27568 let v = yaml_string_mapping(pleme_program_in_aplicacao_selector("cart", "checkout"));
27569 let m = v.as_mapping().expect("mapping shape");
27570 assert_eq!(m.len(), 2);
27571 assert_eq!(m.get(LABEL_PROGRAM).and_then(|x| x.as_str()), Some("cart"));
27572 assert_eq!(
27573 m.get(LABEL_APLICACAO).and_then(|x| x.as_str()),
27574 Some("checkout")
27575 );
27576 }
27577
27578 #[test]
27579 fn kube_key_consts_have_expected_values() {
27580 // Pin the actual string values — these are part of the K8s API
27581 // surface that every emitted artifact's apiserver-side parser
27582 // (Cilium, Gateway API, wasm-operator) depends on. Changing any
27583 // of them is a coordinated multi-renderer migration, not an
27584 // incidental edit.
27585 assert_eq!(KUBE_KEY_API_VERSION, "apiVersion");
27586 assert_eq!(KUBE_KEY_KIND, "kind");
27587 assert_eq!(KUBE_KEY_METADATA, "metadata");
27588 assert_eq!(KUBE_KEY_NAME, "name");
27589 assert_eq!(KUBE_KEY_NAMESPACE, "namespace");
27590 assert_eq!(KUBE_KEY_LABELS, "labels");
27591 assert_eq!(KUBE_KEY_MATCH_LABELS, "matchLabels");
27592 assert_eq!(KUBE_KEY_PORT, "port");
27593 assert_eq!(KUBE_KEY_PROTOCOL, "protocol");
27594 assert_eq!(KUBE_KEY_RULES, "rules");
27595 assert_eq!(KUBE_KEY_SPEC, "spec");
27596 }
27597
27598 #[test]
27599 fn fleet_programs_key_programs_pins_canonical_value() {
27600 // Bridge-arm pin: [`FLEET_PROGRAMS_KEY_PROGRAMS`] resolves to
27601 // the canonical `"programs"` byte today — the exact YAML key
27602 // the `lareira-fleet-programs` library chart's `values.yaml`
27603 // reads under `.Values.programs[]` to iterate one `ComputeUnit`
27604 // CR per entry, and the exact key both writer-side upsert paths
27605 // in [`caixa_flux`] (`upsert_into_helmrelease_programs` on the
27606 // aggregator-HelmRelease shape, `upsert_into_programs_yaml` on
27607 // the bare-values.yaml shape) navigate to walk the entry
27608 // sequence. Pin the literal here (peer with the
27609 // [`M3_KEY_PLACEMENT`] / [`M2_KEY_LIMITS`] /
27610 // [`M2_KEY_BEHAVIOR`] / [`M2_KEY_UPGRADE_FROM`] canonical-
27611 // literal pins on the sibling fleet-programs / M2 overlay
27612 // schema-key surfaces) so a future fleet-programs schema-key
27613 // rebrand surfaces here as a coordinated edit-point: the
27614 // sibling caixa-flux `fleet_programs_key_programs_re_export_
27615 // points_at_caixa_core_canonical` pinning test already pins
27616 // the equality at the re-export axis; this pin closes the
27617 // second coordinate of the triangle by anchoring the lifted
27618 // constant's current byte to the canonical fleet-programs
27619 // library chart's documented shape.
27620 assert_eq!(FLEET_PROGRAMS_KEY_PROGRAMS, "programs");
27621 }
27622
27623 #[test]
27624 fn fleet_programs_key_name_pins_canonical_value() {
27625 // Bridge-arm pin: [`FLEET_PROGRAMS_KEY_NAME`] resolves to the
27626 // canonical `"name"` byte today — the exact YAML key the
27627 // `lareira-fleet-programs` library chart's `range .Values.programs`
27628 // step reads per-entry to key each rendered `ComputeUnit` CR's
27629 // `metadata.name` off, and the exact key both writer-side upsert
27630 // paths in [`caixa_flux`] (`upsert_into_helmrelease_programs` on
27631 // the aggregator-HelmRelease shape, `upsert_into_programs_yaml`
27632 // on the bare-values.yaml shape) navigate to
27633 // match-by-name-and-replace-or-append, and the exact key both
27634 // emit-side entry builders ([`caixa_flux::programs_yaml_entry`]
27635 // per-Servico, [`caixa_mesh::programs_for_aplicacao`] per-
27636 // `:membros`) write the per-entry name-axis at. Pin the literal
27637 // here (peer with the [`fleet_programs_key_programs_pins_canonical_value`]
27638 // top-level array-key canonical-literal pin on the sibling
27639 // fleet-programs schema surface, and with the
27640 // [`M3_KEY_PLACEMENT`] / [`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`]
27641 // / [`M2_KEY_UPGRADE_FROM`] canonical-literal pins on the peer
27642 // per-entry overlay-key surfaces) so a future fleet-programs
27643 // schema-key rebrand on the per-entry name-discriminator axis
27644 // surfaces here as a coordinated edit-point at the definition
27645 // site rather than a silent apply-time split between the two
27646 // emitters and the two upsert readers.
27647 assert_eq!(FLEET_PROGRAMS_KEY_NAME, "name");
27648 }
27649
27650 #[test]
27651 fn fleet_programs_key_aplicacao_pins_canonical_value() {
27652 // Bridge-arm pin: [`FLEET_PROGRAMS_KEY_APLICACAO`] resolves
27653 // to the canonical `"aplicacao"` byte today — the exact YAML
27654 // key the substrate operator's fleet-aggregator reads to
27655 // group each rendered `programs[]` entry back onto its parent
27656 // Aplicacao graph, and the exact key the
27657 // [`caixa_mesh::programs_for_aplicacao`] per-`:membros`
27658 // entry-builder writes the parent-Aplicacao-nome annotation
27659 // at. Pin the literal here (peer with the sibling
27660 // [`fleet_programs_key_name_pins_canonical_value`] and
27661 // [`fleet_programs_key_programs_pins_canonical_value`]
27662 // canonical-literal pins on the peer fleet-programs schema
27663 // key surfaces, and with the [`M3_KEY_PLACEMENT`] /
27664 // [`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] /
27665 // [`M2_KEY_UPGRADE_FROM`] pins on the per-entry overlay-key
27666 // surfaces) so a future fleet-programs schema-key rebrand
27667 // on the per-entry parent-graph-annotation axis surfaces
27668 // here as a coordinated edit-point at the definition site
27669 // rather than a silent apply-time split between the
27670 // caixa-mesh Aplicacao-side emitter and the substrate
27671 // operator's per-graph aggregator reduce step.
27672 assert_eq!(FLEET_PROGRAMS_KEY_APLICACAO, "aplicacao");
27673 }
27674
27675 #[test]
27676 fn fleet_programs_key_versao_pins_canonical_value() {
27677 // Bridge-arm pin: [`FLEET_PROGRAMS_KEY_VERSAO`] resolves to
27678 // the canonical `"versao"` byte today — the exact YAML key
27679 // the substrate operator's per-`:membros` resolver reads to
27680 // fetch each `programs[]` entry's caixa.lisp release against
27681 // the M3 Aplicacao's declared per-member semver / range
27682 // constraint, and the exact key the
27683 // [`caixa_mesh::programs_for_aplicacao`] per-`:membros`
27684 // entry-builder writes the version-constraint at. Pin the
27685 // literal here (peer with the sibling
27686 // [`fleet_programs_key_name_pins_canonical_value`],
27687 // [`fleet_programs_key_aplicacao_pins_canonical_value`], and
27688 // [`fleet_programs_key_programs_pins_canonical_value`]
27689 // canonical-literal pins on the peer fleet-programs schema
27690 // key surfaces, and with the [`M3_KEY_PLACEMENT`] /
27691 // [`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] /
27692 // [`M2_KEY_UPGRADE_FROM`] pins on the per-entry overlay-key
27693 // surfaces) so a future fleet-programs schema-key rebrand
27694 // on the per-entry version-constraint axis surfaces here as
27695 // a coordinated edit-point at the definition site rather
27696 // than a silent apply-time split between the caixa-mesh
27697 // Aplicacao-side emitter and the substrate operator's
27698 // per-`:membros` resolver step.
27699 assert_eq!(FLEET_PROGRAMS_KEY_VERSAO, "versao");
27700 }
27701
27702 // ── label_selector — typed K8s LabelSelector wrapper ─────────────────
27703
27704 #[test]
27705 fn label_selector_wraps_in_match_labels_envelope() {
27706 // The lift's contract: input labels appear under the canonical
27707 // `matchLabels` key, and the outer Value is a Mapping with
27708 // exactly that one key. Pinning the shape so a future
27709 // refactor can't silently drop the wrapper (which would emit
27710 // bare `aplicacao: …, program: …` directly under the K8s
27711 // selector field — a structurally invalid LabelSelector that
27712 // some apiserver-side parsers tolerate by matching the empty
27713 // set, a sharp footgun).
27714 let mut labels = BTreeMap::new();
27715 labels.insert(LABEL_APLICACAO, "checkout".to_string());
27716 labels.insert(LABEL_PROGRAM, "cart".to_string());
27717 let sel = label_selector(labels);
27718 let m = sel.as_mapping().expect("mapping shape");
27719 assert_eq!(m.len(), 1);
27720 let inner = m
27721 .get(KUBE_KEY_MATCH_LABELS)
27722 .and_then(|v| v.as_mapping())
27723 .expect("matchLabels inner mapping");
27724 assert_eq!(inner.len(), 2);
27725 assert_eq!(
27726 inner.get(LABEL_APLICACAO).and_then(|x| x.as_str()),
27727 Some("checkout")
27728 );
27729 assert_eq!(
27730 inner.get(LABEL_PROGRAM).and_then(|x| x.as_str()),
27731 Some("cart")
27732 );
27733 }
27734
27735 #[test]
27736 fn label_selector_empty_input_yields_empty_match_labels() {
27737 // Empty input → `{matchLabels: {}}`. The outer wrapper is
27738 // present (the K8s LabelSelector schema requires it as a
27739 // structural anchor, and apiserver-side parsers that see a
27740 // bare `{}` selector match-everything; pinning the wrapper
27741 // means an empty pleme-io selector at the call site renders
27742 // as the canonical "no labels declared, match nothing
27743 // specific" shape rather than an outright missing key).
27744 let v: serde_yaml::Value = label_selector(BTreeMap::<&'static str, String>::new());
27745 let m = v.as_mapping().expect("mapping shape");
27746 assert_eq!(m.len(), 1);
27747 let inner = m
27748 .get(KUBE_KEY_MATCH_LABELS)
27749 .and_then(|v| v.as_mapping())
27750 .expect("matchLabels inner mapping");
27751 assert!(inner.is_empty());
27752 }
27753
27754 #[test]
27755 fn label_selector_accepts_pleme_selector_helpers() {
27756 // The lift's load-bearing use case: passing the typed pleme-io
27757 // selectors directly into `label_selector` yields the K8s
27758 // LabelSelector shape every Cilium / Gateway / future
27759 // app-operator selector field expects. Pinning end-to-end
27760 // composition so a future refactor of either helper can't
27761 // silently break the integration.
27762 let v = label_selector(pleme_program_in_aplicacao_selector("cart", "checkout"));
27763 let inner = v
27764 .as_mapping()
27765 .and_then(|m| m.get(KUBE_KEY_MATCH_LABELS))
27766 .and_then(|v| v.as_mapping())
27767 .expect("matchLabels inner mapping");
27768 assert_eq!(inner.len(), 2);
27769 assert_eq!(
27770 inner.get(LABEL_PROGRAM).and_then(|x| x.as_str()),
27771 Some("cart")
27772 );
27773 assert_eq!(
27774 inner.get(LABEL_APLICACAO).and_then(|x| x.as_str()),
27775 Some("checkout")
27776 );
27777
27778 // Single-axis variant — only LABEL_PROGRAM under matchLabels.
27779 let v = label_selector(pleme_program_selector("cart"));
27780 let inner = v
27781 .as_mapping()
27782 .and_then(|m| m.get(KUBE_KEY_MATCH_LABELS))
27783 .and_then(|v| v.as_mapping())
27784 .unwrap();
27785 assert_eq!(inner.len(), 1);
27786 assert_eq!(
27787 inner.get(LABEL_PROGRAM).and_then(|x| x.as_str()),
27788 Some("cart")
27789 );
27790 }
27791
27792 #[test]
27793 fn label_selector_inner_iterates_alphabetically_on_btreemap() {
27794 // BTreeMap input → alphabetical iteration → alphabetical YAML
27795 // key order under `matchLabels`. THEORY.md §V.2.7 render
27796 // determinism: the rendered YAML's matchLabels: block appears
27797 // in a deterministic order independent of source-code
27798 // declaration order.
27799 let mut input = BTreeMap::new();
27800 input.insert("zebra", "z".to_string());
27801 input.insert("apple", "a".to_string());
27802 input.insert("mango", "m".to_string());
27803 let v = label_selector(input);
27804 let inner = v
27805 .as_mapping()
27806 .and_then(|m| m.get(KUBE_KEY_MATCH_LABELS))
27807 .and_then(|v| v.as_mapping())
27808 .unwrap();
27809 let keys: Vec<&str> = inner.iter().filter_map(|(k, _)| k.as_str()).collect();
27810 assert_eq!(keys, vec!["apple", "mango", "zebra"]);
27811 }
27812
27813 #[test]
27814 fn label_selector_does_not_introduce_match_expressions_axis() {
27815 // V0 emits matchLabels only — pinning that the helper doesn't
27816 // pre-insert an empty `matchExpressions: []` block (which some
27817 // apiserver-side parsers tolerate but renders noisily and
27818 // shifts the per-rule diff). A future set-based selector
27819 // extension is a deliberate API change to this helper, not an
27820 // incidental shape leak.
27821 let v = label_selector(pleme_program_selector("cart"));
27822 let m = v.as_mapping().unwrap();
27823 assert!(
27824 m.get("matchExpressions").is_none(),
27825 "label_selector must not pre-insert a matchExpressions key (V0 is matchLabels-only)"
27826 );
27827 }
27828
27829 #[test]
27830 fn kube_resource_skeleton_carries_three_top_level_keys_no_spec() {
27831 // The skeleton emits exactly apiVersion + kind + metadata; the
27832 // caller adds spec (and any other top-level keys) themselves.
27833 // Pin that contract so a future caller doesn't accidentally
27834 // double-insert apiVersion / kind / metadata after the
27835 // skeleton call. Namespace fixture arg reads through the
27836 // canonical `DEFAULT_NAMESPACE` const so a future rebrand of
27837 // the substrate's default namespace reaches every fixture by
27838 // construction rather than through a per-fixture stray
27839 // "tatara-system" byte-sequence.
27840 let skel = kube_resource_skeleton(
27841 "cilium.io/v2",
27842 "CiliumNetworkPolicy",
27843 "p-1",
27844 DEFAULT_NAMESPACE,
27845 BTreeMap::new(),
27846 );
27847 assert_eq!(skel.len(), 3);
27848 assert_eq!(
27849 skel.get(KUBE_KEY_API_VERSION).and_then(|v| v.as_str()),
27850 Some("cilium.io/v2")
27851 );
27852 assert_eq!(
27853 skel.get(KUBE_KEY_KIND).and_then(|v| v.as_str()),
27854 Some("CiliumNetworkPolicy")
27855 );
27856 assert!(skel.get(KUBE_KEY_METADATA).is_some());
27857 }
27858
27859 #[test]
27860 fn kube_resource_skeleton_metadata_carries_name_and_namespace() {
27861 let skel = kube_resource_skeleton(
27862 "gateway.networking.k8s.io/v1",
27863 "Gateway",
27864 "checkout",
27865 DEFAULT_NAMESPACE,
27866 BTreeMap::new(),
27867 );
27868 let metadata = skel
27869 .get(KUBE_KEY_METADATA)
27870 .and_then(|v| v.as_mapping())
27871 .expect("metadata mapping");
27872 assert_eq!(
27873 metadata.get(KUBE_KEY_NAME).and_then(|v| v.as_str()),
27874 Some("checkout")
27875 );
27876 // Read-back probe reads through `DEFAULT_NAMESPACE` so a
27877 // future substrate-namespace rebrand routes through the
27878 // canonical const on both the emit-side fixture arg and the
27879 // probe-side readback in one edit — a drift on either side
27880 // would otherwise silently mask the round-trip pin.
27881 assert_eq!(
27882 metadata.get(KUBE_KEY_NAMESPACE).and_then(|v| v.as_str()),
27883 Some(DEFAULT_NAMESPACE)
27884 );
27885 }
27886
27887 #[test]
27888 fn kube_resource_skeleton_omits_labels_when_empty() {
27889 // Empty labels → metadata.labels key absent (NOT present-as-empty).
27890 // K8s API server treats a missing labels key as "no labels
27891 // declared"; an empty-mapping `labels: {}` serializes
27892 // differently in some YAML libraries and is a sharp tool for
27893 // label-based selectors that match the empty set silently.
27894 let skel = kube_resource_skeleton(
27895 "gateway.networking.k8s.io/v1",
27896 "HTTPRoute",
27897 "r-1",
27898 DEFAULT_NAMESPACE,
27899 BTreeMap::new(),
27900 );
27901 let metadata = skel
27902 .get(KUBE_KEY_METADATA)
27903 .and_then(|v| v.as_mapping())
27904 .unwrap();
27905 assert!(
27906 metadata.get(KUBE_KEY_LABELS).is_none(),
27907 "metadata.labels must be absent when no labels passed"
27908 );
27909 // metadata then has exactly 2 keys: name, namespace.
27910 assert_eq!(metadata.len(), 2);
27911 }
27912
27913 #[test]
27914 fn kube_resource_skeleton_includes_labels_when_present() {
27915 let mut labels = BTreeMap::new();
27916 labels.insert(LABEL_APLICACAO, "checkout".to_string());
27917 labels.insert(LABEL_CONTRATO, "cart-to-catalog".to_string());
27918 let skel = kube_resource_skeleton(
27919 "cilium.io/v2",
27920 "CiliumNetworkPolicy",
27921 "p-1",
27922 DEFAULT_NAMESPACE,
27923 labels,
27924 );
27925 let metadata = skel
27926 .get(KUBE_KEY_METADATA)
27927 .and_then(|v| v.as_mapping())
27928 .unwrap();
27929 let labels_block = metadata
27930 .get(KUBE_KEY_LABELS)
27931 .and_then(|v| v.as_mapping())
27932 .expect("metadata.labels mapping present");
27933 assert_eq!(
27934 labels_block.get(LABEL_APLICACAO).and_then(|v| v.as_str()),
27935 Some("checkout")
27936 );
27937 assert_eq!(
27938 labels_block.get(LABEL_CONTRATO).and_then(|v| v.as_str()),
27939 Some("cart-to-catalog")
27940 );
27941 }
27942
27943 #[test]
27944 fn kube_resource_skeleton_metadata_iterates_alphabetically() {
27945 // Pin that the inner BTreeMap projection makes the rendered
27946 // YAML's metadata: block alphabetical (labels, name, namespace),
27947 // regardless of insert order. THEORY.md §V.2.7 render determinism.
27948 let mut labels = BTreeMap::new();
27949 labels.insert(LABEL_APLICACAO, "checkout".to_string());
27950 let skel = kube_resource_skeleton(
27951 "cilium.io/v2",
27952 "CiliumNetworkPolicy",
27953 "p-1",
27954 DEFAULT_NAMESPACE,
27955 labels,
27956 );
27957 let metadata = skel
27958 .get(KUBE_KEY_METADATA)
27959 .and_then(|v| v.as_mapping())
27960 .unwrap();
27961 let keys: Vec<&str> = metadata.iter().filter_map(|(k, _)| k.as_str()).collect();
27962 assert_eq!(
27963 keys,
27964 vec![KUBE_KEY_LABELS, KUBE_KEY_NAME, KUBE_KEY_NAMESPACE]
27965 );
27966 }
27967
27968 #[test]
27969 fn kube_resource_skeleton_top_level_iterates_in_insert_order() {
27970 // The top-level Mapping is a plain serde_yaml::Mapping (insert-
27971 // ordered), and the skeleton inserts apiVersion → kind →
27972 // metadata in that order. Pin so a future refactor doesn't
27973 // silently shift the rendered YAML's top-level key order
27974 // (which K8s tooling tolerates but humans + diff readability
27975 // care about — apiVersion-first is the K8s convention).
27976 let skel = kube_resource_skeleton(
27977 "cilium.io/v2",
27978 "CiliumNetworkPolicy",
27979 "p-1",
27980 DEFAULT_NAMESPACE,
27981 BTreeMap::new(),
27982 );
27983 let keys: Vec<&str> = skel.iter().filter_map(|(k, _)| k.as_str()).collect();
27984 assert_eq!(
27985 keys,
27986 vec![KUBE_KEY_API_VERSION, KUBE_KEY_KIND, KUBE_KEY_METADATA]
27987 );
27988 }
27989
27990 #[test]
27991 fn kube_resource_skeleton_does_not_introduce_spec_key() {
27992 // Sanity: the skeleton is metadata-only — `spec` is the caller's
27993 // responsibility. Pinning so a future "be helpful" refactor
27994 // doesn't auto-insert an empty `spec: {}` (which would silently
27995 // shadow caller-side spec construction).
27996 let skel = kube_resource_skeleton(
27997 "cilium.io/v2",
27998 "CiliumNetworkPolicy",
27999 "p-1",
28000 DEFAULT_NAMESPACE,
28001 BTreeMap::new(),
28002 );
28003 assert!(
28004 skel.get("spec").is_none(),
28005 "skeleton must not pre-insert a spec key"
28006 );
28007 }
28008
28009 // ── require_kind / KindMismatch — typed kind-check predicate ─────
28010
28011 #[test]
28012 fn require_kind_accepts_matching_kind() {
28013 // A Servico-kind caixa passes a `require_kind(_, Servico)`
28014 // check — the happy path every renderer sees on a correctly-
28015 // authored caixa.lisp, surfaced as `Ok(())` so the renderer's
28016 // call site reads as a one-liner gate rather than a typed
28017 // pattern match.
28018 let c = bare_servico();
28019 require_kind(&c, CaixaKind::Servico).unwrap();
28020 }
28021
28022 #[test]
28023 fn require_kind_rejects_with_typed_mismatch() {
28024 // A Biblioteca-kind caixa fails a `require_kind(_, Servico)`
28025 // check with a typed [`KindMismatch`] view that names the
28026 // offending caixa's `:nome` plus both the expected and actual
28027 // kinds. Pinning the typed shape so a future Display-format
28028 // tweak can't silently drop any of the three load-bearing
28029 // fields (which would regress the "feira verb whose error
28030 // path doesn't name the offending caixa" punch-list item the
28031 // protocol calls out).
28032 let mut c = bare_servico();
28033 c.kind = CaixaKind::Biblioteca;
28034 c.servicos = vec![];
28035 let err = require_kind(&c, CaixaKind::Servico).unwrap_err();
28036 assert_eq!(err.nome, "hello-rio");
28037 assert_eq!(err.expected, CaixaKind::Servico);
28038 assert_eq!(err.actual, CaixaKind::Biblioteca);
28039 }
28040
28041 #[test]
28042 fn require_kind_routes_offending_nome_via_caixa_nome_accessor() {
28043 // Pin: the [`KindMismatch::nome`] `String` the constructor
28044 // writes must be a byte-identical copy of what the lifted
28045 // [`crate::Caixa::nome`] accessor returns for the same
28046 // [`Caixa`] input — the same discipline the sibling
28047 // [`crate::LayoutInvariants::verify`] wrap-envelope emitters
28048 // pin at 9842a4b's `expected_nome_via_accessor` line (the
28049 // routing pin the 31-site converge introduced on the substrate's
28050 // own layout-invariant verifier's per-axis diagnostic emitters).
28051 //
28052 // Guardrails a future regression that re-inlines the raw
28053 // `caixa.nome.clone()` `String::clone()` of the underlying
28054 // field at the constructor site — the accessor's borrow
28055 // return + typed `.to_string()` `String` promotion is the
28056 // one canonical shape the substrate's own [`KindMismatch`]
28057 // typed-view constructor carries onto every downstream
28058 // renderer's `Error::From<KindMismatch>` `#[from]` arm, so
28059 // any drift (a byte-non-identical shape, e.g. a future
28060 // `CaixaNome` newtype the [`crate::Caixa::nome`] accessor
28061 // upgrades to project the display byte-string of, that
28062 // `.nome.clone()` would silently ignore) surfaces here
28063 // before the drift lands on a per-renderer `#[from]` arm.
28064 let mut c = bare_servico();
28065 c.kind = CaixaKind::Biblioteca;
28066 c.servicos = vec![];
28067 c.nome = "kind-mismatch-pin".into();
28068 let expected_nome_via_accessor = c.nome().to_string();
28069 assert_eq!(
28070 expected_nome_via_accessor, "kind-mismatch-pin",
28071 "the mutated fixture's `:nome` must be observable through \
28072 the accessor before the kind-mismatch gate fires",
28073 );
28074 let err = require_kind(&c, CaixaKind::Servico).unwrap_err();
28075 assert_eq!(
28076 err.nome, expected_nome_via_accessor,
28077 "the KindMismatch's `nome` field must equal \
28078 `caixa.nome().to_string()` — the typed-view constructor \
28079 must route through the lifted [`Caixa::nome`] accessor's \
28080 `.to_string()` extension, not the raw `caixa.nome.clone()` \
28081 `String::clone()` of the underlying field",
28082 );
28083 }
28084
28085 #[test]
28086 fn kind_mismatch_display_names_offending_caixa_nome() {
28087 // The Display impl is the load-bearing surface every renderer's
28088 // `#[error("{0}")] NotAXKind(#[from] KindMismatch)` arm prints
28089 // through. Pinning the exact rendered form so a future format
28090 // change is a one-line edit + a one-line test update, not a
28091 // silent regression of the diagnostic clarity.
28092 let err = KindMismatch {
28093 nome: "checkout".into(),
28094 expected: CaixaKind::Aplicacao,
28095 actual: CaixaKind::Servico,
28096 };
28097 let msg = format!("{err}");
28098 assert!(
28099 msg.contains("checkout"),
28100 "Display must name the offending caixa nome (got: {msg:?})"
28101 );
28102 assert!(
28103 msg.contains("Aplicacao"),
28104 "Display must name the expected kind (got: {msg:?})"
28105 );
28106 assert!(
28107 msg.contains("Servico"),
28108 "Display must name the actual kind (got: {msg:?})"
28109 );
28110 }
28111
28112 #[test]
28113 fn require_kind_distinguishes_every_pair_of_kinds() {
28114 // Sanity: the predicate is kind-axis-agnostic — it works for
28115 // every kind / expected pair, not just Servico/Biblioteca.
28116 // Pinning that the caller can use `require_kind` for any of
28117 // the five typed kinds (Biblioteca, Binario, Servico,
28118 // Supervisor, Aplicacao) without a special-cased helper per
28119 // kind. Same idiom every per-target renderer key off.
28120 let mut c = bare_servico();
28121 c.kind = CaixaKind::Aplicacao;
28122 c.servicos = vec![];
28123 let err = require_kind(&c, CaixaKind::Supervisor).unwrap_err();
28124 assert_eq!(err.expected, CaixaKind::Supervisor);
28125 assert_eq!(err.actual, CaixaKind::Aplicacao);
28126 require_kind(&c, CaixaKind::Aplicacao).unwrap();
28127 }
28128
28129 // ── require_ci / MissingCiSlot — Acao `:ci`-slot-presence gate ────
28130
28131 fn bare_acao_without_ci() -> Caixa {
28132 let mut c = bare_servico();
28133 c.kind = CaixaKind::Acao;
28134 c.servicos = vec![];
28135 c.ci = None;
28136 c
28137 }
28138
28139 fn sample_ci_run() -> canteiro_types::CiRun {
28140 canteiro_types::CiRun {
28141 workspace: "pleme-io".into(),
28142 repo: "caixa".into(),
28143 nodes: vec![],
28144 }
28145 }
28146
28147 #[test]
28148 fn require_ci_accepts_present_slot_and_returns_borrowed_ci_run() {
28149 // The happy path: an Acao-kind caixa that declares its `:ci`
28150 // slot passes `require_ci`, and the borrowed
28151 // [`canteiro_types::CiRun`] projected through the successful
28152 // return is the same author-declared value the caller was about
28153 // to bind — folding the check and the bind onto one call site,
28154 // matching how every present + roadmapped per-`Acao` consumer
28155 // uses the slot.
28156 let mut c = bare_acao_without_ci();
28157 c.ci = Some(sample_ci_run());
28158 let ci = require_ci(&c).expect("Acao with declared :ci passes");
28159 assert_eq!(ci.workspace, "pleme-io");
28160 assert_eq!(ci.repo, "caixa");
28161 }
28162
28163 #[test]
28164 fn require_ci_rejects_absent_slot_with_typed_view() {
28165 // The fail-before-pass-after pin: pre-lift `caixa-actions`'
28166 // inline `.ok_or_else(|| Error::MissingCi { nome:
28167 // caixa.nome().to_string() })` gate constructed an
28168 // `Error::MissingCi { nome: String }` at exactly one crate's
28169 // call site with no compile-time link to any typed named-caixa
28170 // view the sibling per-renderer entry-gate axes carry. A future
28171 // per-`Acao` consumer (the deferred `sui-supercacheci::canteiro
28172 // ::emit_gha` workflow renderer named in the `caixa-actions`
28173 // crate docs, the future per-`Acao` CR materializer) would
28174 // re-inline the same `.ok_or_else(...)` construction on its own
28175 // call site and open a second untracked `nome: String`-carry
28176 // path — exactly the "feira verb whose error path doesn't name
28177 // the offending caixa" punch-list item the compounding-mandate
28178 // protocol calls out. Lifting the gate onto the typed
28179 // [`MissingCiSlot`] view + [`require_ci`] predicate closes the
28180 // drift potential structurally: every future per-`Acao`
28181 // consumer reaches for the same one-liner + `#[from]` and gets
28182 // the diagnostic-naming-the-offending-caixa contract for free.
28183 let c = bare_acao_without_ci();
28184 let err = require_ci(&c).unwrap_err();
28185 assert_eq!(err.nome, "hello-rio");
28186 }
28187
28188 #[test]
28189 fn require_ci_routes_offending_nome_via_caixa_nome_accessor() {
28190 // Pin: the [`MissingCiSlot::nome`] `String` the constructor
28191 // writes must be a byte-identical copy of what the lifted
28192 // [`crate::Caixa::nome`] accessor returns for the same
28193 // [`Caixa`] input — the same routing pin discipline the peer
28194 // [`require_kind`] / [`require_single_servico`] typed views
28195 // already carry, so a future regression that re-inlines a raw
28196 // `caixa.nome.clone()` `String::clone()` of the underlying
28197 // field at the constructor site (which would silently ignore
28198 // any future `CaixaNome` newtype the [`crate::Caixa::nome`]
28199 // accessor upgrades to project the display byte-string of)
28200 // trips here before the drift lands on a per-consumer `#[from]`
28201 // arm.
28202 let mut c = bare_acao_without_ci();
28203 c.nome = "missing-ci-pin".into();
28204 let expected_nome_via_accessor = c.nome().to_string();
28205 assert_eq!(
28206 expected_nome_via_accessor, "missing-ci-pin",
28207 "the mutated fixture's `:nome` must be observable through \
28208 the accessor before the `:ci` gate fires",
28209 );
28210 let err = require_ci(&c).unwrap_err();
28211 assert_eq!(
28212 err.nome, expected_nome_via_accessor,
28213 "the MissingCiSlot's `nome` field must equal \
28214 `caixa.nome().to_string()` — the typed-view constructor \
28215 must route through the lifted [`Caixa::nome`] accessor's \
28216 `.to_string()` extension, not the raw `caixa.nome.clone()` \
28217 `String::clone()` of the underlying field",
28218 );
28219 }
28220
28221 #[test]
28222 fn missing_ci_slot_display_names_offending_caixa_nome() {
28223 // The Display impl is the load-bearing surface every per-
28224 // `Acao` consumer's `#[error("{0}")] MissingCi(#[from]
28225 // MissingCiSlot)` arm prints through. Pinning the exact rendered
28226 // form so a future format change is a one-line edit + a one-line
28227 // test update, not a silent regression of the diagnostic
28228 // clarity. Same shape every peer per-axis lift carries.
28229 let err = MissingCiSlot {
28230 nome: "hello-acao".into(),
28231 };
28232 let msg = format!("{err}");
28233 assert!(
28234 msg.contains("hello-acao"),
28235 "Display must name the offending caixa nome (got: {msg:?})"
28236 );
28237 assert!(
28238 msg.contains(":ci"),
28239 "Display must name the missing `:ci` slot (got: {msg:?})"
28240 );
28241 }
28242
28243 // ── CiDecomposeFailure — per-`Acao` decompose-failure diagnostic axis ─
28244
28245 #[test]
28246 fn ci_decompose_failure_carries_offending_nome_and_source_verbatim() {
28247 // Fail-before-pass-after pin on the [`CiDecomposeFailure`] typed
28248 // view: the constructor writes the offending caixa's `:nome`
28249 // (routed through the lifted [`crate::Caixa::nome`] accessor's
28250 // `.to_string()` extension by every consumer) alongside the
28251 // borrowed [`canteiro_types::DecomposeError`] source verbatim,
28252 // so a per-`Acao` consumer that fans on the specific
28253 // decompose-failure arm reaches for `err.source` directly
28254 // rather than re-parsing the Display bytes. Peer of the sibling
28255 // [`MissingCiSlot`] typed view's `nome`-carrying pin — extends
28256 // the same "one typed view per axis, carrying the offending
28257 // caixa's `:nome` + axis-specific detail" discipline onto the
28258 // second per-`Acao` diagnostic axis after the presence-gate
28259 // axis.
28260 let err = CiDecomposeFailure {
28261 nome: "hello-acao".into(),
28262 source: canteiro_types::DecomposeError::Cycle,
28263 };
28264 assert_eq!(err.nome, "hello-acao");
28265 assert_eq!(err.source, canteiro_types::DecomposeError::Cycle);
28266 }
28267
28268 #[test]
28269 fn ci_decompose_failure_display_names_offending_caixa_nome_and_source() {
28270 // The Display impl is the load-bearing surface every per-`Acao`
28271 // consumer's `#[error("{0}")] Decompose(#[from]
28272 // CiDecomposeFailure)` arm prints through. Pinning the exact
28273 // rendered form so a future format change is a one-line edit +
28274 // a one-line test update, not a silent regression of the
28275 // diagnostic clarity — same shape every peer per-axis lift
28276 // carries.
28277 let err = CiDecomposeFailure {
28278 nome: "hello-acao".into(),
28279 source: canteiro_types::DecomposeError::Cycle,
28280 };
28281 let msg = format!("{err}");
28282 assert!(
28283 msg.contains("hello-acao"),
28284 "Display must name the offending caixa nome (got: {msg:?})"
28285 );
28286 assert!(
28287 msg.contains(":ci"),
28288 "Display must name the `:ci` slot the decompose failed on \
28289 (got: {msg:?})"
28290 );
28291 assert!(
28292 msg.contains("decompose"),
28293 "Display must name the decompose axis (got: {msg:?})"
28294 );
28295 }
28296
28297 #[test]
28298 fn ci_decompose_failure_exposes_source_via_error_trait() {
28299 // Pin: the [`CiDecomposeFailure`] type routes its
28300 // [`canteiro_types::DecomposeError`] carrier through the
28301 // `#[source]` [`thiserror::Error`] derive so downstream
28302 // `std::error::Error::source()`-consuming diagnostic frameworks
28303 // (`anyhow`'s chain formatter, `tracing`'s `error!` event
28304 // capture, the future `feira lint` sub-diagnostic emitter) see
28305 // the underlying `DecomposeError` arm through the standard
28306 // trait rather than only through the flattened Display bytes.
28307 // Peer of the sibling per-slot `#[source]` wiring the caixa-*
28308 // renderers already carry on their own typed-view error
28309 // wrappers.
28310 let err = CiDecomposeFailure {
28311 nome: "hello-acao".into(),
28312 source: canteiro_types::DecomposeError::Cycle,
28313 };
28314 let src = std::error::Error::source(&err)
28315 .expect("CiDecomposeFailure must expose its DecomposeError via Error::source()");
28316 // The `Error::source()` trait method returns a `&dyn Error`
28317 // borrow of the underlying `DecomposeError`, so its Display
28318 // bytes must equal the source arm's own Display bytes — a
28319 // future accidental collapse of the `#[source]` wiring (which
28320 // would erase the source chain and force downstream
28321 // `anyhow::Chain` consumers back onto Display re-parsing) trips
28322 // here at caixa-core build time.
28323 let src_msg = format!("{src}");
28324 let expected_msg = format!("{}", canteiro_types::DecomposeError::Cycle);
28325 assert_eq!(src_msg, expected_msg);
28326 }
28327
28328 // ── decompose_ci — per-`Acao` decompose-axis predicate ────────────
28329
28330 fn cyclic_ci_run() -> canteiro_types::CiRun {
28331 // A minimal two-node cycle: `a` depends on `b`, `b` depends on
28332 // `a`. Every failure mode `canteiro_types::decompose` refuses
28333 // (duplicate node name, missing dependency, cycle) would work as
28334 // a fixture; the cycle arm is the same one the `caixa-actions`
28335 // per-`Acao` renderer's own `validate_rejects_a_cyclic_ci_run`
28336 // test already reads for, so both the substrate primitive's own
28337 // pin and the consumer's byte-parity pin share one canonical
28338 // fixture shape.
28339 canteiro_types::CiRun {
28340 workspace: "pleme-io".into(),
28341 repo: "caixa".into(),
28342 nodes: vec![
28343 canteiro_types::CiNode::new(
28344 "a",
28345 canteiro_types::EnvClass::None,
28346 canteiro_types::ActionRef {
28347 name: "a".into(),
28348 command: "true".into(),
28349 args: vec![],
28350 },
28351 vec!["b".into()],
28352 ),
28353 canteiro_types::CiNode::new(
28354 "b",
28355 canteiro_types::EnvClass::None,
28356 canteiro_types::ActionRef {
28357 name: "b".into(),
28358 command: "true".into(),
28359 args: vec![],
28360 },
28361 vec!["a".into()],
28362 ),
28363 ],
28364 }
28365 }
28366
28367 fn linear_ci_run() -> canteiro_types::CiRun {
28368 // A minimal two-node acyclic run: `test` depends on `build`.
28369 // Same shape as the `caixa-actions` `validate_decomposes_a_two_
28370 // node_build_then_test_run` happy-path test — one shared
28371 // canonical fixture for every downstream substrate consumer.
28372 canteiro_types::CiRun {
28373 workspace: "pleme-io".into(),
28374 repo: "caixa".into(),
28375 nodes: vec![
28376 canteiro_types::CiNode::new(
28377 "build",
28378 canteiro_types::EnvClass::None,
28379 canteiro_types::ActionRef {
28380 name: "build".into(),
28381 command: "true".into(),
28382 args: vec![],
28383 },
28384 vec![],
28385 ),
28386 canteiro_types::CiNode::new(
28387 "test",
28388 canteiro_types::EnvClass::None,
28389 canteiro_types::ActionRef {
28390 name: "test".into(),
28391 command: "true".into(),
28392 args: vec![],
28393 },
28394 vec!["build".into()],
28395 ),
28396 ],
28397 }
28398 }
28399
28400 #[test]
28401 fn decompose_ci_accepts_valid_ci_run_and_returns_canteiro_dag() {
28402 // The happy path: a valid two-node acyclic run decomposes
28403 // cleanly through `decompose_ci`, returning the owned
28404 // `canteiro_types::CanteiroDag` the sibling `canteiro_types::
28405 // decompose` returns — the substrate primitive is a
28406 // pass-through on success, only wrapping the error arm in a
28407 // typed named-caixa view. Matches the peer `require_ci`
28408 // presence-axis happy path (accept-with-borrowed-CiRun) —
28409 // extends the "one primitive per axis, pass-through on success"
28410 // discipline onto the decompose axis.
28411 let c = bare_acao_without_ci();
28412 let ci = linear_ci_run();
28413 let cd = decompose_ci(&c, &ci).expect("valid acyclic CiRun decomposes cleanly");
28414 // The topo_order() call on a successful decompose is infallible
28415 // by construction (no cycles present), so a downstream consumer
28416 // reaches for the DAG's own algebra directly rather than a
28417 // second gate. Iterating the returned order (rather than
28418 // asserting on a concrete container shape) keeps the pin
28419 // agnostic to whether topo_order returns Vec<NodeId>,
28420 // SmallVec<NodeId>, or any future returned collection.
28421 let topo = cd
28422 .topo_order()
28423 .expect("acyclic CanteiroDag returns a valid topo_order");
28424 assert_eq!(
28425 topo.iter().count(),
28426 2,
28427 "topo_order on a two-node acyclic run must yield two node ids"
28428 );
28429 }
28430
28431 #[test]
28432 fn decompose_ci_rejects_cyclic_ci_run_with_typed_view() {
28433 // The fail-before-pass-after pin: pre-lift `caixa-actions`'
28434 // inline `.map_err(|source| CiDecomposeFailure { nome: nome
28435 // .clone(), source })` gate constructed a `CiDecomposeFailure`
28436 // at exactly one crate's call site with no compile-time link to
28437 // any typed named-caixa predicate the sibling per-`Acao` /
28438 // per-renderer entry-gate axes carry. A future per-`Acao`
28439 // consumer (the deferred `sui-supercacheci::canteiro::emit_gha`
28440 // workflow renderer named in the `caixa-actions` crate docs, a
28441 // future per-`Acao` CR materializer's admission webhook) would
28442 // re-inline the same `.map_err(...)` construction on its own
28443 // call site and open a second untracked
28444 // `caixa.nome().to_string()` re-projection path — exactly the
28445 // "feira verb whose error path doesn't name the offending
28446 // caixa" punch-list item the compounding-mandate protocol calls
28447 // out. Lifting the gate onto the typed `decompose_ci` predicate
28448 // closes the drift potential structurally: every future
28449 // per-`Acao` consumer reaches for the same one-liner + `#[from]`
28450 // and gets the diagnostic-naming-the-offending-caixa contract
28451 // for free.
28452 let c = bare_acao_without_ci();
28453 let ci = cyclic_ci_run();
28454 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
28455 // `canteiro_types::CanteiroDag`, which does not derive it at the
28456 // pinned sui rev — so the whole caixa-core test target failed to
28457 // COMPILE. A let-else says the same thing without borrowing a
28458 // bound from a foreign type we do not own.
28459 let Err(err) = decompose_ci(&c, &ci) else {
28460 panic!("a cyclic CiRun must fail decompose_ci");
28461 };
28462 assert_eq!(err.nome, "hello-rio");
28463 assert_eq!(err.source, canteiro_types::DecomposeError::Cycle);
28464 }
28465
28466 #[test]
28467 fn decompose_ci_routes_offending_nome_via_caixa_nome_accessor() {
28468 // Pin: the `CiDecomposeFailure::nome` `String` the constructor
28469 // writes must be a byte-identical copy of what the lifted
28470 // `crate::Caixa::nome` accessor returns for the same `Caixa`
28471 // input — the same routing pin discipline the peer
28472 // `require_kind` / `require_single_servico` / `require_ci`
28473 // typed views already carry, so a future regression that
28474 // re-inlines a raw `caixa.nome.clone()` `String::clone()` of
28475 // the underlying field at the constructor site (which would
28476 // silently ignore any future `CaixaNome` newtype the
28477 // `crate::Caixa::nome` accessor upgrades to project the display
28478 // byte-string of) trips here before the drift lands on a
28479 // per-consumer `#[from]` arm.
28480 let mut c = bare_acao_without_ci();
28481 c.nome = "decompose-ci-pin".into();
28482 let expected_nome_via_accessor = c.nome().to_string();
28483 assert_eq!(
28484 expected_nome_via_accessor, "decompose-ci-pin",
28485 "the mutated fixture's `:nome` must be observable through \
28486 the accessor before the decompose gate fires",
28487 );
28488 let ci = cyclic_ci_run();
28489 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
28490 // `canteiro_types::CanteiroDag`, which does not derive it at the
28491 // pinned sui rev — so the whole caixa-core test target failed to
28492 // COMPILE. A let-else says the same thing without borrowing a
28493 // bound from a foreign type we do not own.
28494 let Err(err) = decompose_ci(&c, &ci) else {
28495 panic!("a cyclic CiRun must fail decompose_ci");
28496 };
28497 assert_eq!(
28498 err.nome, expected_nome_via_accessor,
28499 "the CiDecomposeFailure's `nome` field must equal \
28500 `caixa.nome().to_string()` — the `decompose_ci` predicate \
28501 must route through the lifted `Caixa::nome` accessor's \
28502 `.to_string()` extension, not a raw `caixa.nome.clone()` \
28503 `String::clone()` of the underlying field",
28504 );
28505 }
28506
28507 // ── ci_declared_edge_count — per-`Acao` declared-edge-count axis ─
28508
28509 #[test]
28510 fn ci_declared_edge_count_returns_zero_for_leaf_only_run() {
28511 // The empty-edges arm: a `CiRun` whose every node carries an
28512 // empty `deps` list has zero declared edges. Pins the
28513 // `usize::sum()` accumulator's starting value on the
28514 // no-fan-out shape a `caixa-init`-scaffolded `:kind Acao` a
28515 // caixa's stub `:ci` slot lands as before the author wires
28516 // any `deps`. Fail-before-pass-after guard: pre-lift there was
28517 // no substrate primitive, so an author-scaffolded no-deps run
28518 // would have had its `edge_count = 0` re-derived at every
28519 // consumer site through the same open-coded arithmetic. This
28520 // test now anchors the projection to `ci_declared_edge_count`.
28521 let ci = canteiro_types::CiRun {
28522 workspace: "pleme-io".into(),
28523 repo: "caixa".into(),
28524 nodes: vec![
28525 canteiro_types::CiNode::new(
28526 "build",
28527 canteiro_types::EnvClass::None,
28528 canteiro_types::ActionRef {
28529 name: "build".into(),
28530 command: "true".into(),
28531 args: vec![],
28532 },
28533 vec![],
28534 ),
28535 canteiro_types::CiNode::new(
28536 "lint",
28537 canteiro_types::EnvClass::None,
28538 canteiro_types::ActionRef {
28539 name: "lint".into(),
28540 command: "true".into(),
28541 args: vec![],
28542 },
28543 vec![],
28544 ),
28545 ],
28546 };
28547 assert_eq!(
28548 ci_declared_edge_count(&ci),
28549 0,
28550 "a two-leaf-node `:ci` run with empty `deps` lists carries \
28551 zero declared edges — the substrate primitive's `usize` \
28552 accumulator must start at zero and pass through untouched",
28553 );
28554 }
28555
28556 #[test]
28557 fn ci_declared_edge_count_returns_deps_sum_across_nodes() {
28558 // The multi-arity arm: a `CiRun` whose nodes carry `deps`
28559 // lists of arities 0/1/2 has declared-edge-count 3 (0+1+2).
28560 // Pins that the substrate primitive routes the sum through
28561 // *every* node's `deps.len()` rather than only the first
28562 // node's (a future regression that collapsed the `map(...)`
28563 // + `sum()` fold onto a `first()` / `next()` shape would
28564 // silently under-count the declared edges — the arity-3
28565 // fixture surfaces it here before the drift lands on the
28566 // `caixa-actions::validate` production `edge_count` artifact).
28567 let ci = canteiro_types::CiRun {
28568 workspace: "pleme-io".into(),
28569 repo: "caixa".into(),
28570 nodes: vec![
28571 canteiro_types::CiNode::new(
28572 "build",
28573 canteiro_types::EnvClass::None,
28574 canteiro_types::ActionRef {
28575 name: "build".into(),
28576 command: "true".into(),
28577 args: vec![],
28578 },
28579 vec![],
28580 ),
28581 canteiro_types::CiNode::new(
28582 "test",
28583 canteiro_types::EnvClass::None,
28584 canteiro_types::ActionRef {
28585 name: "test".into(),
28586 command: "true".into(),
28587 args: vec![],
28588 },
28589 vec!["build".into()],
28590 ),
28591 canteiro_types::CiNode::new(
28592 "publish",
28593 canteiro_types::EnvClass::None,
28594 canteiro_types::ActionRef {
28595 name: "publish".into(),
28596 command: "true".into(),
28597 args: vec![],
28598 },
28599 vec!["build".into(), "test".into()],
28600 ),
28601 ],
28602 };
28603 assert_eq!(
28604 ci_declared_edge_count(&ci),
28605 3,
28606 "declared-edge-count on a 0/1/2-arity node list is the sum \
28607 (0 + 1 + 2 = 3) — the primitive must fold over every node, \
28608 not just the first / last / any-single-index shape",
28609 );
28610 }
28611
28612 #[test]
28613 fn ci_declared_edge_count_counts_edges_before_decompose_gate() {
28614 // The count-is-shape-only arm: an author-declared *cyclic*
28615 // `:ci` run — the exact fixture `decompose_ci` refuses at the
28616 // sibling axis — still carries its declared edge count as a
28617 // property of the *borrowed run's shape*, not of the owned
28618 // `CanteiroDag` `decompose_ci` (would have) returned. Pins
28619 // that a future consumer that wants the declared-edge summary
28620 // *before* running `decompose_ci` (a `feira lint --acao`
28621 // per-caixa pre-flight report that names the declared edge
28622 // count on both accept + reject arms of the sibling
28623 // `decompose_ci` gate) reads a stable count on both arms.
28624 // The two-node cycle `a → b → a` from `cyclic_ci_run()`
28625 // carries exactly 2 declared edges (one per node's singleton
28626 // `deps`), so the primitive returns 2 without ever routing
28627 // through `canteiro_types::decompose`.
28628 let ci = cyclic_ci_run();
28629 assert_eq!(
28630 ci_declared_edge_count(&ci),
28631 2,
28632 "the two-node cycle carries 2 declared `deps` edges (one \
28633 per node's singleton `deps`) — the primitive must read the \
28634 count off the borrowed run's node-list shape, not off the \
28635 `decompose_ci`-produced `CanteiroDag`'s edge algebra",
28636 );
28637 }
28638
28639 #[test]
28640 fn ci_declared_edge_count_matches_open_coded_sum_across_shapes() {
28641 // Byte-parity pin — the three-path convergence discipline
28642 // every peer per-`Acao` substrate primitive carries: the
28643 // primitive's return must equal the open-coded
28644 // `ci.nodes.iter().map(|n| n.deps.len()).sum::<usize>()`
28645 // expression at each of the three canonical `:ci` run shapes
28646 // this test module already carries (`linear_ci_run` — the
28647 // canonical happy-path with one edge, `cyclic_ci_run` — the
28648 // canonical rejected-by-`decompose_ci` shape with two edges,
28649 // and the empty-edges no-fan-out shape the peer
28650 // `ci_declared_edge_count_returns_zero_for_leaf_only_run`
28651 // fixture reads). Any future refactor of the primitive's fold
28652 // shape trips here before landing on the consumer's
28653 // `RenderedAcao::edge_count` artifact.
28654 for (label, ci) in [
28655 ("linear-two-node", linear_ci_run()),
28656 ("cyclic-two-node", cyclic_ci_run()),
28657 ] {
28658 let via_primitive = ci_declared_edge_count(&ci);
28659 let via_open_coded: usize = ci.nodes.iter().map(|n| n.deps.len()).sum();
28660 assert_eq!(
28661 via_primitive, via_open_coded,
28662 "{label}: `ci_declared_edge_count` must equal the \
28663 open-coded `.nodes.iter().map(|n| n.deps.len()).sum()` \
28664 the two prior `caixa-actions` open-coded sites carried \
28665 — pre-lift regression check",
28666 );
28667 }
28668 }
28669
28670 // ── require_single_servico / ServicoCountMismatch — V0 Servico-shape ─
28671
28672 #[test]
28673 fn require_single_servico_accepts_singleton_list() {
28674 // The happy path: the canonical V0 Servico carries exactly one
28675 // `:servicos` entry (the ComputeUnit YAML pointer), the same
28676 // shape every in-tree fixture + canonical example uses. Surfaced
28677 // as `Ok(())` so the renderer's call site reads as a one-liner
28678 // gate beside the peer [`require_kind`] check rather than a
28679 // typed pattern match.
28680 let c = bare_servico();
28681 assert_eq!(
28682 c.servicos.len(),
28683 1,
28684 "fixture pin: bare_servico() is singleton"
28685 );
28686 require_single_servico(&c).unwrap();
28687 }
28688
28689 #[test]
28690 fn require_single_servico_rejects_empty_list_with_typed_mismatch() {
28691 // A Servico-kind caixa with zero `:servicos` entries fails
28692 // `require_single_servico` with a typed [`ServicoCountMismatch`]
28693 // view that names the offending caixa's `:nome` + the actual
28694 // count (0). Pinning the typed shape so a future Display-format
28695 // tweak can't silently drop either of the two load-bearing
28696 // fields (which would regress the "feira verb whose error path
28697 // doesn't name the offending caixa" punch-list item the protocol
28698 // calls out — same shape every peer per-axis lift carries).
28699 let mut c = bare_servico();
28700 c.servicos = vec![];
28701 let err = require_single_servico(&c).unwrap_err();
28702 assert_eq!(err.nome, "hello-rio");
28703 assert_eq!(err.count, 0);
28704 }
28705
28706 #[test]
28707 fn require_single_servico_rejects_multi_entry_list_with_typed_mismatch() {
28708 // The peer arm on the upper-bound axis: a Servico-kind caixa
28709 // with ≥ 2 `:servicos` entries fails the same gate, with the
28710 // typed view carrying the actual count (2). Both empty and
28711 // multi-entry lists land on the same [`ServicoCountMismatch`]
28712 // arm — the V0 contract requires *exactly* one entry, not
28713 // *at-least* one — so the single helper closes both directions
28714 // of the V0 invariant in one call site.
28715 let mut c = bare_servico();
28716 c.servicos = vec![
28717 "servicos/hello-rio.computeunit.yaml".into(),
28718 "servicos/extra.computeunit.yaml".into(),
28719 ];
28720 let err = require_single_servico(&c).unwrap_err();
28721 assert_eq!(err.nome, "hello-rio");
28722 assert_eq!(err.count, 2);
28723 }
28724
28725 #[test]
28726 fn require_single_servico_routes_offending_nome_via_caixa_nome_accessor() {
28727 // Peer to the sibling
28728 // [`require_kind_routes_offending_nome_via_caixa_nome_accessor`]
28729 // pin on the V0 Servico-shape gate's `:nome`-carry axis:
28730 // the [`ServicoCountMismatch::nome`] `String` the constructor
28731 // writes must be a byte-identical copy of what the lifted
28732 // [`crate::Caixa::nome`] accessor returns. Same 9842a4b-shaped
28733 // routing pin the substrate's own [`crate::LayoutInvariants::verify`]
28734 // wrap-envelope emitters carry, extended here to the second of
28735 // the two [`crate::render`]-module typed-view constructor sites
28736 // that carried a raw `caixa.nome.clone()` `String::clone()`
28737 // field access at the pre-converge state.
28738 let mut c = bare_servico();
28739 c.servicos = vec![];
28740 c.nome = "servico-count-pin".into();
28741 let expected_nome_via_accessor = c.nome().to_string();
28742 assert_eq!(
28743 expected_nome_via_accessor, "servico-count-pin",
28744 "the mutated fixture's `:nome` must be observable through \
28745 the accessor before the servico-count gate fires",
28746 );
28747 let err = require_single_servico(&c).unwrap_err();
28748 assert_eq!(
28749 err.nome, expected_nome_via_accessor,
28750 "the ServicoCountMismatch's `nome` field must equal \
28751 `caixa.nome().to_string()` — the typed-view constructor \
28752 must route through the lifted [`Caixa::nome`] accessor's \
28753 `.to_string()` extension, not the raw `caixa.nome.clone()` \
28754 `String::clone()` of the underlying field",
28755 );
28756 }
28757
28758 #[test]
28759 fn servico_count_mismatch_display_names_offending_caixa_nome() {
28760 // The Display impl is the load-bearing surface every renderer's
28761 // `#[error("{0}")] UnsupportedServicoCount(#[from]
28762 // ServicoCountMismatch)` arm prints through. Pinning the exact
28763 // rendered form so a future format change is a one-line edit +
28764 // a one-line test update, not a silent regression of the
28765 // diagnostic clarity that motivated the lift (the prior
28766 // per-renderer `UnsupportedServicoCount(usize)` arm named only
28767 // the count). Same shape every peer [`KindMismatch`] / typed-
28768 // view Display tests pin.
28769 let err = ServicoCountMismatch {
28770 nome: "checkout".into(),
28771 count: 3,
28772 };
28773 let msg = format!("{err}");
28774 assert!(
28775 msg.contains("checkout"),
28776 "Display must name the offending caixa nome (got: {msg:?})"
28777 );
28778 assert!(
28779 msg.contains('3'),
28780 "Display must name the actual count (got: {msg:?})"
28781 );
28782 assert!(
28783 msg.contains(":servicos"),
28784 "Display must name the offending field axis (got: {msg:?})"
28785 );
28786 assert!(
28787 msg.contains("exactly one"),
28788 "Display must name the V0 invariant (got: {msg:?})"
28789 );
28790 }
28791
28792 #[test]
28793 fn overlay_kind_agnostic_for_field_projection() {
28794 // The helper projects fields, not kind — every Caixa carries
28795 // the M2 slot fields by construction. Renderer-level kind
28796 // gates (NotAServico in caixa-helm / caixa-flux) are the
28797 // shape filter; this helper is the field projector. Keeping
28798 // them separate means the same overlay can apply to any
28799 // future per-kind renderer (e.g. when M2.4 supervisor
28800 // rendering acquires its own M2-shaped overlay path).
28801 let mut c = bare_servico();
28802 c.kind = CaixaKind::Biblioteca;
28803 c.servicos = vec![];
28804 c.limits = Some(LimitsSpec {
28805 memory: Some(crate::LIMITS_MEMORY_WASM32_PAGE_BYTES),
28806 ..Default::default()
28807 });
28808 let overlay = servico_m2_overlay(&c).unwrap();
28809 assert!(overlay.contains_key(M2_KEY_LIMITS));
28810 }
28811
28812 // ── require_v0_servico_shape — compound V0-shape entry gate ──────
28813
28814 /// Local `thiserror`-shaped renderer-error stand-in that mirrors the
28815 /// three production callers' shape (`caixa-flux::Error`,
28816 /// `caixa-helm::Error`) at the two `#[from]` variants the compound
28817 /// helper's `E: From<KindMismatch> + From<ServicoCountMismatch>`
28818 /// bound targets. Pinning the shape here so the compound helper's
28819 /// type-inference contract is unit-testable inside caixa-core
28820 /// without a workspace-crate dependency (which would bloat the
28821 /// build graph).
28822 #[derive(Debug, thiserror::Error)]
28823 enum RendererStandIn {
28824 #[error("{0}")]
28825 NotAServico(#[from] KindMismatch),
28826 #[error("{0}")]
28827 UnsupportedServicoCount(#[from] ServicoCountMismatch),
28828 }
28829
28830 #[test]
28831 fn require_v0_servico_shape_accepts_v0_servico() {
28832 // Happy path: a `:kind Servico` caixa with exactly one
28833 // `:servicos` entry — the canonical V0 shape every per-Servico
28834 // renderer's entry-point sees — passes the compound gate. Same
28835 // outcome as the two-line pair the compound helper replaces:
28836 // both predicates surface `Ok(())`, and the compound helper's
28837 // return type carries the caller's `E` inferred from the `?`
28838 // context (unit test uses [`RendererStandIn`] as the stand-in
28839 // for `caixa-flux::Error` / `caixa-helm::Error`).
28840 let c = bare_servico();
28841 let r: Result<(), RendererStandIn> = require_v0_servico_shape(&c);
28842 r.expect("v0 servico shape accepted");
28843 }
28844
28845 #[test]
28846 fn require_v0_servico_shape_forwards_kind_mismatch_first() {
28847 // Order pin: the kind gate fires before the count gate, so a
28848 // `:kind Biblioteca` caixa with zero `:servicos` entries
28849 // surfaces the [`KindMismatch`] arm (the more actionable
28850 // diagnostic — the author has the wrong `:kind`), not the
28851 // [`ServicoCountMismatch`] arm (a downstream consequence of
28852 // the mis-kinded input). Both invariants are violated on this
28853 // input, so the ordering matters — reversing it would flip
28854 // every current caller's diagnostic on a mis-kinded input.
28855 let mut c = bare_servico();
28856 c.kind = CaixaKind::Biblioteca;
28857 c.servicos = vec![];
28858 let err: RendererStandIn = require_v0_servico_shape(&c).unwrap_err();
28859 match err {
28860 RendererStandIn::NotAServico(k) => {
28861 assert_eq!(k.nome, "hello-rio");
28862 assert_eq!(k.expected, CaixaKind::Servico);
28863 assert_eq!(k.actual, CaixaKind::Biblioteca);
28864 }
28865 RendererStandIn::UnsupportedServicoCount(_) => {
28866 panic!("kind gate must fire before count gate on mis-kinded input")
28867 }
28868 }
28869 }
28870
28871 #[test]
28872 fn require_v0_servico_shape_forwards_count_mismatch_on_kind_match() {
28873 // A `:kind Servico` caixa with the wrong `:servicos` count
28874 // (empty or multi-entry) passes the kind gate and lands on the
28875 // [`ServicoCountMismatch`] arm — the same typed view every
28876 // per-renderer `#[from] ServicoCountMismatch` arm already
28877 // surfaces at the two-line pair this helper replaces. Both
28878 // directions of the V0 count invariant (empty AND ≥ 2) land on
28879 // the same arm — pinning the multi-entry direction here; the
28880 // empty direction is covered by the peer
28881 // `require_single_servico_rejects_empty_list_with_typed_mismatch`
28882 // test on the single-axis primitive.
28883 let mut c = bare_servico();
28884 c.servicos = vec![
28885 "servicos/hello-rio.computeunit.yaml".into(),
28886 "servicos/extra.computeunit.yaml".into(),
28887 ];
28888 let err: RendererStandIn = require_v0_servico_shape(&c).unwrap_err();
28889 match err {
28890 RendererStandIn::UnsupportedServicoCount(c) => {
28891 assert_eq!(c.nome, "hello-rio");
28892 assert_eq!(c.count, 2);
28893 }
28894 RendererStandIn::NotAServico(_) => {
28895 panic!("count gate must fire when kind gate passes")
28896 }
28897 }
28898 }
28899
28900 #[test]
28901 fn require_v0_servico_shape_matches_two_line_pair_semantic() {
28902 // Equivalence pin: on every input, the compound helper's
28903 // Ok/Err discrimination matches the two-line pair verbatim —
28904 // the lift is a behavioral no-op at the caller boundary. Peer
28905 // to the sibling `entry_or_default_<variant>` equivalence
28906 // tests that pin the lifted primitive against the inline
28907 // block it replaces.
28908 //
28909 // Three axes covered: V0 shape (Ok/Ok), kind gate fires
28910 // (Err/Ok on the two-line pair — pair short-circuits at the
28911 // kind gate), count gate fires (Ok/Err on the two-line pair —
28912 // pair reaches the count gate).
28913 let cases: Vec<(CaixaKind, Vec<String>)> = vec![
28914 (CaixaKind::Servico, vec!["servicos/x.yaml".into()]),
28915 (CaixaKind::Biblioteca, vec![]),
28916 (CaixaKind::Servico, vec![]),
28917 (CaixaKind::Aplicacao, vec!["servicos/x.yaml".into()]),
28918 (
28919 CaixaKind::Servico,
28920 vec!["servicos/a.yaml".into(), "servicos/b.yaml".into()],
28921 ),
28922 ];
28923 for (kind, servicos) in cases {
28924 let mut c = bare_servico();
28925 c.kind = kind;
28926 c.servicos = servicos;
28927 let pair: Result<(), RendererStandIn> = (|| {
28928 require_kind(&c, CaixaKind::Servico)?;
28929 require_single_servico(&c)?;
28930 Ok(())
28931 })();
28932 let compound: Result<(), RendererStandIn> = require_v0_servico_shape(&c);
28933 assert_eq!(
28934 pair.is_ok(),
28935 compound.is_ok(),
28936 "compound helper must match two-line pair on kind={kind:?} servicos.len()={}",
28937 c.servicos.len(),
28938 );
28939 }
28940 }
28941
28942 // ── require_aplicacao_view — compound per-Aplicacao entry gate ───
28943
28944 /// Local `thiserror`-shaped renderer-error stand-in that mirrors
28945 /// `caixa-mesh::Error`'s two `#[from]` arms at the compound
28946 /// helper's `E: From<KindMismatch> + From<AplicacaoError>` bound.
28947 /// Same discipline as the sibling [`RendererStandIn`] stand-in on
28948 /// the peer per-Servico [`require_v0_servico_shape`] gate: pins
28949 /// the compound helper's type-inference contract inside caixa-core
28950 /// without a workspace-crate dependency (which would bloat the
28951 /// build graph).
28952 #[derive(Debug, thiserror::Error)]
28953 enum AplicacaoRendererStandIn {
28954 #[error("{0}")]
28955 NotAnAplicacao(#[from] KindMismatch),
28956 #[error("{0}")]
28957 InvalidAplicacao(#[from] crate::aplicacao::AplicacaoError),
28958 }
28959
28960 fn bare_aplicacao() -> Caixa {
28961 let mut c = bare_servico();
28962 c.nome = "checkout".into();
28963 c.kind = CaixaKind::Aplicacao;
28964 c.servicos = vec![];
28965 c.membros = vec![
28966 crate::aplicacao::Membro {
28967 caixa: "cart".into(),
28968 versao: "^0.1".into(),
28969 },
28970 crate::aplicacao::Membro {
28971 caixa: "catalog".into(),
28972 versao: "^0.1".into(),
28973 },
28974 ];
28975 // `:placement` needs at least one named cluster (every strategy
28976 // uses the list as a hosting/takeover/shard pool per
28977 // MESH-COMPOSITION §II.1/§II.4); the fold-through
28978 // [`Caixa::aplicacao_view`] uses `Placement::default()` which
28979 // carries an empty `:clusters` and would trip
28980 // `AplicacaoError::PlacementWithoutClusters` at
28981 // `AplicacaoSpec::validate` — the peer per-Aplicacao
28982 // renderer fixtures (`caixa-mesh::aplicacao_caixa`) pin the
28983 // same non-empty `:clusters` shape.
28984 c.placement = Some(crate::aplicacao::Placement {
28985 estrategia: crate::aplicacao::PlacementStrategy::SingleNode,
28986 clusters: vec!["default".into()],
28987 affinity: None,
28988 shard_key: None,
28989 });
28990 c
28991 }
28992
28993 #[test]
28994 fn require_aplicacao_view_accepts_valid_aplicacao() {
28995 // Happy path: a `:kind Aplicacao` caixa with a well-formed
28996 // `:membros` stanza — the canonical V0 shape every
28997 // per-Aplicacao renderer's entry-point sees — passes the
28998 // compound three-arm gate and returns a validated
28999 // [`AplicacaoSpec`]. Same outcome as the three-line cascade
29000 // the compound helper replaces: [`require_kind`] passes,
29001 // [`Caixa::aplicacao_view`] returns `Some(spec)`, and
29002 // [`AplicacaoSpec::validate`] passes. Peer to
29003 // `require_v0_servico_shape_accepts_v0_servico` on the
29004 // sibling per-Servico compound gate.
29005 let c = bare_aplicacao();
29006 let spec: crate::aplicacao::AplicacaoSpec =
29007 require_aplicacao_view::<AplicacaoRendererStandIn>(&c)
29008 .expect("valid aplicacao shape accepted");
29009 // Route the per-Aplicacao `:membros` slice-projection through
29010 // the substrate-canonical [`AplicacaoSpec::membros`] `&[Membro]`-
29011 // return accessor rather than the raw `spec.membros` `Vec<Membro>`
29012 // field access, and the per-member `:caixa` scalar-projection
29013 // through the sibling [`crate::aplicacao::Membro::nome`] `&str`-
29014 // return accessor rather than the raw `.caixa` `String`-field
29015 // borrow, so a future rebrand of either storage (a per-cluster
29016 // `:membros`-overlay the caixa-operator reconciles ahead of
29017 // dispatch, an M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
29018 // materializer's per-member alias table, a promotion of the
29019 // per-`Membro` `caixa: String` slot to a typed `ServicoName`
29020 // newtype the accessor materializes behind the same `&str`
29021 // return contract) reaches this per-fixture happy-path
29022 // acceptance-shape probe through the one accessor edit at the
29023 // canonical caixa-core declaration rather than a coordinated
29024 // rewrite that would include this render-side test-fixture
29025 // navigation too. Peer to the sibling caixa-flux
29026 // [`sample_caixa_nome_accessor_byte_equals_raw_field`] (2ffdb44)
29027 // / caixa-crd `round_trip_preserves_core_fields` (1a160cd) /
29028 // caixa-feira load.rs (e853d45) test-side accessor
29029 // convergences on the peer per-`Caixa` scalar-axis field —
29030 // extended here onto the render-side per-`AplicacaoSpec`
29031 // `:membros` slice + per-`Membro` `:caixa` scalar axes.
29032 let membros = spec.membros();
29033 assert_eq!(membros.len(), 2);
29034 assert_eq!(membros[0].nome(), "cart");
29035 assert_eq!(membros[1].nome(), "catalog");
29036 }
29037
29038 #[test]
29039 fn require_aplicacao_view_accepts_valid_aplicacao_membros_accessor_byte_equals_raw_field() {
29040 // Byte-parity pin: [`AplicacaoSpec::membros`]'s `&[Membro]`-
29041 // return accessor must project the same slice-length and
29042 // per-entry `:caixa` bytes as the raw `spec.membros`
29043 // `Vec<Membro>` + per-`Membro` `caixa: String` field access
29044 // on the shared per-test [`bare_aplicacao`] fixture the sibling
29045 // [`require_aplicacao_view_accepts_valid_aplicacao`] happy-
29046 // path acceptance pin navigates through. Guards the paired
29047 // per-fixture convergence that just routed the three raw
29048 // `spec.membros.len()` / `spec.membros[0].caixa` /
29049 // `spec.membros[1].caixa` sites through the accessor pair: a
29050 // future implementation of [`AplicacaoSpec::membros`] that
29051 // returned a differently-shaped view (a filter over
29052 // storage-dropping optional members, a cached
29053 // `Cow<[Membro]>` materialization, an operator-side per-CR
29054 // alias-rewritten membership overlay), or a future
29055 // [`crate::aplicacao::Membro::nome`] projection that read a
29056 // canonicalized rewrite (a per-tenant namespace prefix, an
29057 // ASCII-lowered normalization) rather than the raw storage-
29058 // side `.caixa` bytes, would silently split every render-
29059 // side test-fixture navigation that routes through the
29060 // accessors from the storage-side field the peer
29061 // [`AplicacaoSpec::validate`] production membership-lookup
29062 // path still reads through the same accessor pair — this
29063 // pin surfaces the drift at caixa-core build time rather
29064 // than at a downstream per-Aplicacao renderer's
29065 // membership-lookup diagnostic on the fleet.
29066 //
29067 // Same byte-parity-pin discipline the sibling caixa-flux
29068 // `sample_caixa_nome_accessor_byte_equals_raw_field` (2ffdb44)
29069 // + caixa-crd `round_trip_preserves_core_fields` accessor
29070 // convergence (1a160cd) + caixa-feira load.rs (e853d45)
29071 // per-`Caixa` scalar-axis byte-parity pins added to lock the
29072 // peer per-`Caixa` scalar-accessor family against the raw
29073 // field-access at each crate's fixture — extended here onto
29074 // the render-side per-`AplicacaoSpec` `:membros` slice + per-
29075 // `Membro` `:caixa` scalar axes' shared test fixture.
29076 let c = bare_aplicacao();
29077 let spec: crate::aplicacao::AplicacaoSpec =
29078 require_aplicacao_view::<AplicacaoRendererStandIn>(&c)
29079 .expect("valid aplicacao shape accepted");
29080 assert_eq!(
29081 spec.membros().len(),
29082 spec.membros.len(),
29083 "AplicacaoSpec::membros() slice-length must byte-equal \
29084 the raw `membros: Vec<Membro>` field storage's `.len()`; \
29085 any implementation drift here silently splits every \
29086 render-side test-fixture navigation that routes through \
29087 the accessor from the storage-side field the peer \
29088 AplicacaoSpec::validate production membership-lookup \
29089 path still reads through the same accessor"
29090 );
29091 for (i, m) in spec.membros().iter().enumerate() {
29092 assert_eq!(
29093 m.nome(),
29094 spec.membros[i].caixa.as_str(),
29095 "Membro::nome() must borrow the same bytes as the raw \
29096 `caixa: String` field storage at member index {i}; \
29097 any implementation drift here silently splits every \
29098 render-side test-fixture navigation that routes \
29099 through the accessor from the storage-side field the \
29100 peer AplicacaoSpec::validate production membership-\
29101 lookup path still reads through the same accessor"
29102 );
29103 }
29104 }
29105
29106 #[test]
29107 fn require_aplicacao_view_forwards_kind_mismatch_first() {
29108 // Order pin: the kind gate fires before the aplicacao_view
29109 // fold-in + [`AplicacaoSpec::validate`], so a `:kind Servico`
29110 // caixa carrying a well-formed `:membros` stanza (the manifest
29111 // field's documented "silently ignored" case on a non-Aplicacao
29112 // kind) surfaces the [`KindMismatch`] arm — the more actionable
29113 // diagnostic — rather than any spec-side arm the manifest
29114 // author never intended to hit. Reversing the order would flip
29115 // every current caller's diagnostic on a mis-kinded input.
29116 // Peer to `require_v0_servico_shape_forwards_kind_mismatch_first`
29117 // on the sibling per-Servico compound gate.
29118 let mut c = bare_aplicacao();
29119 c.kind = CaixaKind::Servico;
29120 c.servicos = vec!["servicos/hello.computeunit.yaml".into()];
29121 let err: AplicacaoRendererStandIn = require_aplicacao_view(&c).unwrap_err();
29122 match err {
29123 AplicacaoRendererStandIn::NotAnAplicacao(k) => {
29124 assert_eq!(k.nome, "checkout");
29125 assert_eq!(k.expected, CaixaKind::Aplicacao);
29126 assert_eq!(k.actual, CaixaKind::Servico);
29127 }
29128 AplicacaoRendererStandIn::InvalidAplicacao(_) => {
29129 panic!("kind gate must fire before aplicacao-view fold-in on mis-kinded input")
29130 }
29131 }
29132 }
29133
29134 #[test]
29135 fn require_aplicacao_view_forwards_aplicacao_error_on_kind_match() {
29136 // A `:kind Aplicacao` caixa that passes the kind gate but
29137 // fails [`AplicacaoSpec::validate`] (empty `:membros` here —
29138 // the [`AplicacaoError::NoMembros`] arm every Aplicacao must
29139 // satisfy per MESH-COMPOSITION §III.1) lands on the
29140 // [`AplicacaoError`] arm through the compound helper's
29141 // `E: From<AplicacaoError>` bound. Same diagnostic the
29142 // three-line cascade the compound helper replaces surfaces at
29143 // `spec.validate()?`. Peer to
29144 // `require_v0_servico_shape_forwards_count_mismatch_on_kind_match`
29145 // on the sibling per-Servico compound gate.
29146 let mut c = bare_aplicacao();
29147 c.membros = vec![]; // trips AplicacaoError::NoMembros
29148 let err: AplicacaoRendererStandIn = require_aplicacao_view(&c).unwrap_err();
29149 match err {
29150 AplicacaoRendererStandIn::InvalidAplicacao(
29151 crate::aplicacao::AplicacaoError::NoMembros,
29152 ) => {}
29153 AplicacaoRendererStandIn::InvalidAplicacao(other) => {
29154 panic!("expected NoMembros arm, got {other:?}")
29155 }
29156 AplicacaoRendererStandIn::NotAnAplicacao(_) => {
29157 panic!("spec-validate arm must fire when kind gate passes")
29158 }
29159 }
29160 }
29161
29162 #[test]
29163 fn require_aplicacao_view_matches_three_line_cascade_semantic() {
29164 // Equivalence pin: on every input, the compound helper's
29165 // Ok/Err discrimination matches the three-line cascade
29166 // verbatim — the lift is a behavioral no-op at the caller
29167 // boundary. Peer to the sibling
29168 // `require_v0_servico_shape_matches_two_line_pair_semantic`
29169 // equivalence pin on the per-Servico compound gate.
29170 //
29171 // Four axes covered: Aplicacao shape (Ok/Ok), kind gate fires
29172 // (Err/Ok on the cascade — cascade short-circuits at the kind
29173 // gate), spec-validate arm fires (Ok/Err on the cascade —
29174 // cascade reaches [`AplicacaoSpec::validate`]), and a
29175 // mis-kinded caixa with a spec-invalid `:membros` stanza (both
29176 // invariants violated — the kind gate must still fire first).
29177 let cases: Vec<(CaixaKind, Vec<crate::aplicacao::Membro>)> = vec![
29178 (
29179 CaixaKind::Aplicacao,
29180 vec![
29181 crate::aplicacao::Membro {
29182 caixa: "cart".into(),
29183 versao: "^0.1".into(),
29184 },
29185 crate::aplicacao::Membro {
29186 caixa: "catalog".into(),
29187 versao: "^0.1".into(),
29188 },
29189 ],
29190 ),
29191 (CaixaKind::Servico, vec![]),
29192 (CaixaKind::Aplicacao, vec![]),
29193 (
29194 CaixaKind::Biblioteca,
29195 vec![crate::aplicacao::Membro {
29196 caixa: "cart".into(),
29197 versao: "^0.1".into(),
29198 }],
29199 ),
29200 ];
29201 for (kind, membros) in cases {
29202 let mut c = bare_aplicacao();
29203 c.kind = kind;
29204 c.membros = membros.clone();
29205 if kind == CaixaKind::Servico {
29206 c.servicos = vec!["servicos/hello.computeunit.yaml".into()];
29207 } else {
29208 c.servicos = vec![];
29209 }
29210 let cascade: Result<crate::aplicacao::AplicacaoSpec, AplicacaoRendererStandIn> =
29211 (|| {
29212 require_kind(&c, CaixaKind::Aplicacao)?;
29213 let spec = c.aplicacao_view().expect(
29214 "require_kind(Aplicacao) guarantees Caixa::aplicacao_view returns Some",
29215 );
29216 spec.validate()?;
29217 Ok(spec)
29218 })();
29219 let compound: Result<crate::aplicacao::AplicacaoSpec, AplicacaoRendererStandIn> =
29220 require_aplicacao_view(&c);
29221 assert_eq!(
29222 cascade.is_ok(),
29223 compound.is_ok(),
29224 "compound helper must match three-line cascade on kind={kind:?} membros.len()={}",
29225 membros.len(),
29226 );
29227 // Compound helper's Ok-arm return matches cascade's
29228 // Ok-arm return byte-for-byte (via serde YAML round-trip
29229 // — the `AplicacaoSpec` derives `Serialize`, so equal-
29230 // rendering values are the substrate-canonical equality
29231 // signal the peer downstream renderers key off).
29232 if let (Ok(cascade_spec), Ok(compound_spec)) = (cascade, compound) {
29233 assert_eq!(
29234 serde_yaml::to_string(&cascade_spec).expect("cascade AplicacaoSpec serializes"),
29235 serde_yaml::to_string(&compound_spec)
29236 .expect("compound AplicacaoSpec serializes"),
29237 "compound helper's Ok arm must return byte-equal AplicacaoSpec to cascade"
29238 );
29239 }
29240 }
29241 }
29242
29243 // ── require_acao_view — compound per-`Acao` entry gate ───────────
29244
29245 /// Local `thiserror`-shaped renderer-error stand-in that mirrors
29246 /// `caixa-actions::Error`'s three `#[from]` arms at the compound
29247 /// helper's `E: From<KindMismatch> + From<MissingCiSlot> +
29248 /// From<CiDecomposeFailure>` bound. Same discipline as the sibling
29249 /// [`RendererStandIn`] / [`AplicacaoRendererStandIn`] stand-ins on
29250 /// the peer per-Servico [`require_v0_servico_shape`] and
29251 /// per-Aplicacao [`require_aplicacao_view`] compound gates: pins
29252 /// the compound helper's type-inference contract inside caixa-core
29253 /// without a workspace-crate dependency (which would bloat the
29254 /// build graph).
29255 #[derive(Debug, thiserror::Error)]
29256 enum AcaoRendererStandIn {
29257 #[error("{0}")]
29258 NotAnAcao(#[from] KindMismatch),
29259 #[error("{0}")]
29260 MissingCi(#[from] MissingCiSlot),
29261 #[error("{0}")]
29262 Decompose(#[from] CiDecomposeFailure),
29263 }
29264
29265 #[test]
29266 fn require_acao_view_accepts_valid_acao() {
29267 // Happy path: a `:kind Acao` caixa with a well-formed `:ci`
29268 // stanza — the canonical V0 shape every per-`Acao` consumer's
29269 // entry-point sees — passes the compound three-arm gate and
29270 // returns the borrowed [`canteiro_types::CiRun`] paired with
29271 // the owned [`canteiro_types::CanteiroDag`] the substrate
29272 // primitive produced. Same outcome as the three-line prelude
29273 // the compound helper replaces: [`require_kind`] passes,
29274 // [`require_ci`] returns the borrowed slot, [`decompose_ci`]
29275 // accepts the run. Peer to
29276 // `require_aplicacao_view_accepts_valid_aplicacao` and
29277 // `require_v0_servico_shape_accepts_v0_servico` on the sibling
29278 // per-Aplicacao / per-Servico compound gates.
29279 let mut c = bare_acao_without_ci();
29280 c.ci = Some(linear_ci_run());
29281 let (ci, cd) = require_acao_view::<AcaoRendererStandIn>(&c)
29282 .expect("valid Acao shape accepted by compound helper");
29283 assert_eq!(ci.workspace, "pleme-io");
29284 assert_eq!(ci.nodes.len(), 2);
29285 // `topo_order()` is infallible on the DAG the compound helper
29286 // returns, mirroring the substrate-side pass-through pin at
29287 // [`decompose_ci_accepts_valid_ci_run_and_returns_canteiro_dag`].
29288 let topo = cd
29289 .topo_order()
29290 .expect("acyclic CanteiroDag returns a valid topo_order");
29291 assert_eq!(
29292 topo.iter().count(),
29293 2,
29294 "topo_order on the compound helper's returned DAG must yield \
29295 two node ids on a two-node acyclic run"
29296 );
29297 }
29298
29299 #[test]
29300 fn require_acao_view_forwards_kind_mismatch_first() {
29301 // Order pin: the kind gate fires before the presence gate + the
29302 // decompose gate, so a `:kind Servico` caixa carrying a
29303 // well-formed `:ci` stanza (the manifest field's documented
29304 // "silently ignored" case on a non-`Acao` kind) surfaces the
29305 // [`KindMismatch`] arm — the more actionable diagnostic —
29306 // rather than either downstream arm the manifest author never
29307 // intended to hit. Reversing the order would flip every
29308 // current caller's diagnostic on a mis-kinded input. Peer to
29309 // `require_aplicacao_view_forwards_kind_mismatch_first` and
29310 // `require_v0_servico_shape_forwards_kind_mismatch_first` on
29311 // the sibling per-Aplicacao / per-Servico compound gates.
29312 let mut c = bare_acao_without_ci();
29313 c.kind = CaixaKind::Servico;
29314 c.servicos = vec!["servicos/hello.computeunit.yaml".into()];
29315 c.ci = Some(linear_ci_run());
29316 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
29317 // `canteiro_types::CanteiroDag`, which does not derive it at the
29318 // pinned sui rev — so the whole caixa-core test target failed to
29319 // COMPILE. A let-else says the same thing without borrowing a
29320 // bound from a foreign type we do not own.
29321 let Err(err): Result<_, AcaoRendererStandIn> = require_acao_view(&c) else {
29322 panic!("this fixture must not produce an Acao view");
29323 };
29324 match err {
29325 AcaoRendererStandIn::NotAnAcao(k) => {
29326 assert_eq!(k.nome, "hello-rio");
29327 assert_eq!(k.expected, CaixaKind::Acao);
29328 assert_eq!(k.actual, CaixaKind::Servico);
29329 }
29330 AcaoRendererStandIn::MissingCi(_) => {
29331 panic!("kind gate must fire before presence gate on mis-kinded input")
29332 }
29333 AcaoRendererStandIn::Decompose(_) => {
29334 panic!("kind gate must fire before decompose gate on mis-kinded input")
29335 }
29336 }
29337 }
29338
29339 #[test]
29340 fn require_acao_view_forwards_missing_ci_slot_on_kind_match() {
29341 // A `:kind Acao` caixa that passes the kind gate but declares
29342 // no `:ci` slot lands on the [`MissingCiSlot`] arm through the
29343 // compound helper's `E: From<MissingCiSlot>` bound — the same
29344 // typed view the peer [`require_ci`] presence gate produces at
29345 // the single-axis primitive, propagated through the compound
29346 // gate's second arm.
29347 let c = bare_acao_without_ci();
29348 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
29349 // `canteiro_types::CanteiroDag`, which does not derive it at the
29350 // pinned sui rev — so the whole caixa-core test target failed to
29351 // COMPILE. A let-else says the same thing without borrowing a
29352 // bound from a foreign type we do not own.
29353 let Err(err): Result<_, AcaoRendererStandIn> = require_acao_view(&c) else {
29354 panic!("this fixture must not produce an Acao view");
29355 };
29356 match err {
29357 AcaoRendererStandIn::MissingCi(m) => {
29358 assert_eq!(m.nome, "hello-rio");
29359 }
29360 AcaoRendererStandIn::NotAnAcao(_) => {
29361 panic!("presence gate must fire when kind gate passes")
29362 }
29363 AcaoRendererStandIn::Decompose(_) => {
29364 panic!("presence gate must fire before decompose gate on missing `:ci` input")
29365 }
29366 }
29367 }
29368
29369 #[test]
29370 fn require_acao_view_forwards_decompose_failure_on_ci_present() {
29371 // A `:kind Acao` caixa that passes the kind + presence gates
29372 // but carries a cyclic `:ci` run lands on the
29373 // [`CiDecomposeFailure`] arm through the compound helper's
29374 // `E: From<CiDecomposeFailure>` bound — the same typed view
29375 // the peer [`decompose_ci`] gate produces at the single-axis
29376 // primitive, propagated through the compound gate's third
29377 // arm.
29378 let mut c = bare_acao_without_ci();
29379 c.ci = Some(cyclic_ci_run());
29380 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
29381 // `canteiro_types::CanteiroDag`, which does not derive it at the
29382 // pinned sui rev — so the whole caixa-core test target failed to
29383 // COMPILE. A let-else says the same thing without borrowing a
29384 // bound from a foreign type we do not own.
29385 let Err(err): Result<_, AcaoRendererStandIn> = require_acao_view(&c) else {
29386 panic!("this fixture must not produce an Acao view");
29387 };
29388 match err {
29389 AcaoRendererStandIn::Decompose(f) => {
29390 assert_eq!(f.nome, "hello-rio");
29391 assert_eq!(f.source, canteiro_types::DecomposeError::Cycle);
29392 }
29393 AcaoRendererStandIn::NotAnAcao(_) => {
29394 panic!("decompose gate must fire when kind + presence gates pass")
29395 }
29396 AcaoRendererStandIn::MissingCi(_) => {
29397 panic!("decompose gate must fire when presence gate passes")
29398 }
29399 }
29400 }
29401
29402 #[test]
29403 fn require_acao_view_matches_three_line_prelude_semantic() {
29404 // Equivalence pin: on every input, the compound helper's
29405 // Ok/Err discrimination matches the three-line prelude
29406 // verbatim — the lift is a behavioral no-op at the caller
29407 // boundary. Peer to the sibling
29408 // `require_aplicacao_view_matches_three_line_cascade_semantic`
29409 // and `require_v0_servico_shape_matches_two_line_pair_semantic`
29410 // equivalence pins on the per-Aplicacao / per-Servico compound
29411 // gates.
29412 //
29413 // Five axes covered: valid Acao (Ok/Ok), kind gate fires
29414 // (Err/Err on the prelude — prelude short-circuits at the kind
29415 // gate), presence gate fires (Ok/Err on the prelude — prelude
29416 // reaches [`require_ci`]), decompose gate fires (Ok/Err on the
29417 // prelude — prelude reaches [`decompose_ci`]), and a
29418 // mis-kinded caixa with a well-formed `:ci` (both invariants
29419 // relevant — the kind gate must still fire first).
29420 let cases: Vec<(CaixaKind, Option<canteiro_types::CiRun>)> = vec![
29421 (CaixaKind::Acao, Some(linear_ci_run())),
29422 (CaixaKind::Servico, Some(linear_ci_run())),
29423 (CaixaKind::Acao, None),
29424 (CaixaKind::Acao, Some(cyclic_ci_run())),
29425 (CaixaKind::Biblioteca, None),
29426 ];
29427 for (kind, ci) in cases {
29428 let mut c = bare_acao_without_ci();
29429 c.kind = kind;
29430 c.ci = ci.clone();
29431 if kind == CaixaKind::Servico {
29432 c.servicos = vec!["servicos/hello.computeunit.yaml".into()];
29433 } else {
29434 c.servicos = vec![];
29435 }
29436 let prelude: Result<
29437 (&canteiro_types::CiRun, canteiro_types::CanteiroDag),
29438 AcaoRendererStandIn,
29439 > = (|| {
29440 require_kind(&c, CaixaKind::Acao)?;
29441 let ci_borrowed = require_ci(&c)?;
29442 let cd = decompose_ci(&c, ci_borrowed)?;
29443 Ok((ci_borrowed, cd))
29444 })();
29445 let compound: Result<
29446 (&canteiro_types::CiRun, canteiro_types::CanteiroDag),
29447 AcaoRendererStandIn,
29448 > = require_acao_view(&c);
29449 assert_eq!(
29450 prelude.is_ok(),
29451 compound.is_ok(),
29452 "compound helper must match three-line prelude on kind={kind:?} ci.is_some()={}",
29453 ci.is_some(),
29454 );
29455 // Compound helper's Ok-arm return matches prelude's
29456 // Ok-arm return byte-for-byte on both projections: the
29457 // borrowed `&CiRun`'s node count + workspace / repo
29458 // identity, and the owned `CanteiroDag`'s
29459 // topological-order node-name projection (the substrate-
29460 // canonical equality signal every downstream per-`Acao`
29461 // consumer keys off).
29462 if let (Ok((prelude_ci, prelude_cd)), Ok((compound_ci, compound_cd))) =
29463 (prelude, compound)
29464 {
29465 assert_eq!(
29466 prelude_ci.workspace, compound_ci.workspace,
29467 "compound helper's borrowed CiRun's workspace must \
29468 equal prelude's byte-for-byte"
29469 );
29470 assert_eq!(
29471 prelude_ci.repo, compound_ci.repo,
29472 "compound helper's borrowed CiRun's repo must equal \
29473 prelude's byte-for-byte"
29474 );
29475 assert_eq!(
29476 prelude_ci.nodes.len(),
29477 compound_ci.nodes.len(),
29478 "compound helper's borrowed CiRun's node count must \
29479 equal prelude's"
29480 );
29481 let prelude_topo = prelude_cd
29482 .topo_order()
29483 .expect("prelude's DAG produces a valid topo_order");
29484 let compound_topo = compound_cd
29485 .topo_order()
29486 .expect("compound's DAG produces a valid topo_order");
29487 let prelude_names: Vec<String> = prelude_topo
29488 .iter()
29489 .filter_map(|id| prelude_cd.nodes.get(id).map(|n| n.name.clone()))
29490 .collect();
29491 let compound_names: Vec<String> = compound_topo
29492 .iter()
29493 .filter_map(|id| compound_cd.nodes.get(id).map(|n| n.name.clone()))
29494 .collect();
29495 assert_eq!(
29496 prelude_names, compound_names,
29497 "compound helper's DAG must produce byte-equal \
29498 topological-order node-name projection to prelude's"
29499 );
29500 }
29501 }
29502 }
29503
29504 // ── single_field_overlay — typed per-axis overlay primitive ──────────
29505
29506 #[test]
29507 fn single_field_overlay_none_yields_none() {
29508 // Empty-axis-skip semantic at the typed-primitive layer: a
29509 // `None` slot returns `None`, not `Some(empty Mapping)`. The
29510 // caller's `if let Some(overlay) = …` guard then becomes the
29511 // single emission gate, and a malformed `outer: {}` (the
29512 // empty-mapping form some K8s parsers reject) is structurally
29513 // impossible by construction.
29514 let v: Option<serde_yaml::Value> = single_field_overlay::<u32, _>(None, "attempts", |n| {
29515 serde_yaml::Value::Number(n.into())
29516 });
29517 assert!(v.is_none());
29518 }
29519
29520 #[test]
29521 fn single_field_overlay_some_yields_single_field_mapping() {
29522 // The Some arm builds exactly one inner key/value pair, no
29523 // more, no less. Pinning the shape so a future refactor can't
29524 // accidentally introduce a second field (which would render
29525 // as a malformed `timeouts: { request: "30s", <leak>: ... }`
29526 // overlay block).
29527 let v = single_field_overlay(Some(30u32), "attempts", |n| {
29528 serde_yaml::Value::Number(n.into())
29529 })
29530 .expect("Some arm yields Some(...)");
29531 let m = v.as_mapping().expect("mapping shape");
29532 assert_eq!(m.len(), 1);
29533 assert_eq!(m.get("attempts").and_then(|x| x.as_u64()), Some(30));
29534 }
29535
29536 #[test]
29537 fn single_field_overlay_threads_typed_value_through_closure() {
29538 // The closure receives the unwrapped typed `T` (not the
29539 // wrapping `Option<T>`), so the per-overlay value-shaping
29540 // logic stays at the call site. Three different Value shapes
29541 // pin the closure's type-flow: a `String` (for canonical
29542 // duration / enum scalars), a `Number` (for typed integer
29543 // attempt counts), and a derived `Bool` (for tristate enums).
29544 // Mirrors the three landed overlays' shapes letter-for-letter.
29545 let dur = single_field_overlay(Some("30s".to_string()), "request", |s| {
29546 serde_yaml::Value::String(s)
29547 })
29548 .unwrap();
29549 assert_eq!(dur.get("request").and_then(|v| v.as_str()), Some("30s"));
29550
29551 let num = single_field_overlay(Some(3u32), "attempts", |n| {
29552 serde_yaml::Value::Number(n.into())
29553 })
29554 .unwrap();
29555 assert_eq!(num.get("attempts").and_then(|v| v.as_u64()), Some(3));
29556
29557 // The mtls tristate's two non-None arms map to enum strings,
29558 // not raw bools (the Cilium CRD's `mode: required|disabled`
29559 // shape — pinned end-to-end at every emit site by the
29560 // `cnp_authentication_mode_serialized_as_yaml_string` test).
29561 // Both scalar-values thread through the lifted canonical
29562 // [`cilium_auth_mode`] bijection — the same `bool → &'static
29563 // str` projection the production `cilium_network_policies`
29564 // per-`(:de, :para)` overlay closure reaches for, so a future
29565 // Cilium CNP `MutualAuthenticationMode` OpenAPI schema enum
29566 // rebrand (either arm's scalar-value string, or the per-arm
29567 // dispatch) lands at the two consts + one projection body
29568 // rather than duplicated across the production emitter site
29569 // and this generic-helper pin.
29570 let mode = single_field_overlay(Some(true), CILIUM_KEY_MODE, |b| {
29571 serde_yaml::Value::String(cilium_auth_mode(b).into())
29572 })
29573 .unwrap();
29574 assert_eq!(
29575 mode.get(CILIUM_KEY_MODE).and_then(|v| v.as_str()),
29576 Some(CILIUM_AUTH_MODE_REQUIRED)
29577 );
29578 }
29579
29580 #[test]
29581 fn single_field_overlay_outer_key_is_callers_concern() {
29582 // The helper builds the *inner* (single-field) Mapping; the
29583 // *outer* key (`timeouts` / `retry` / `authentication`) is
29584 // the caller's `if let Some(overlay) = … { rule.insert(<outer>,
29585 // overlay.clone()) }` insertion. Pinning that the helper's
29586 // returned Value carries no outer-key wrapping — emitting the
29587 // outer-key-wrapped form here would silently double-wrap
29588 // every overlay (`timeouts: { timeouts: { request: "30s" } }`
29589 // post-insertion).
29590 let v = single_field_overlay(Some(30u32), "attempts", |n| {
29591 serde_yaml::Value::Number(n.into())
29592 })
29593 .unwrap();
29594 let m = v.as_mapping().unwrap();
29595 // Only the inner key — no `timeouts:` / `retry:` /
29596 // `authentication:` wrapper at this layer.
29597 for k in ["timeouts", "retry", "authentication"] {
29598 assert!(
29599 m.get(k).is_none(),
29600 "single_field_overlay must not pre-insert the outer key {k:?} \
29601 (the caller's per-rule insert is the canonical insertion site)"
29602 );
29603 }
29604 }
29605
29606 #[test]
29607 fn single_field_overlay_value_is_clonable_for_per_rule_dispatch() {
29608 // The build-once-clone-many idiom every emit-site uses: the
29609 // overlay is computed once per renderer call (so the closure
29610 // runs exactly once) and `.clone()`d into each rule of the
29611 // emitted sequence. Pin that the returned Value is in fact
29612 // cloneable (a `serde_yaml::Value` always is, but the test
29613 // pins the contract end-to-end so a future refactor that
29614 // returns a non-Cloneable wrapper surfaces here).
29615 let v = single_field_overlay(Some(30u32), "attempts", |n| {
29616 serde_yaml::Value::Number(n.into())
29617 })
29618 .unwrap();
29619 let v_clone = v.clone();
29620 assert_eq!(v, v_clone);
29621 }
29622
29623 // ── upsert_named_entry — typed sequence-upsert primitive ─────────────
29624
29625 #[test]
29626 fn upsert_named_entry_appends_when_empty() {
29627 // Empty-sequence-first arm: an initially-empty aggregator
29628 // programs.yaml carries no matching entry, so the upsert falls
29629 // through to the append-new tail and returns
29630 // `Ok(true)` (newly inserted). Pins the append-new contract
29631 // both writer-side [`caixa_flux`] upsert paths lean on when
29632 // the aggregator's `programs:` sequence is empty
29633 // (`upsert_inserts_new_entry` at the values.yaml layer,
29634 // `upsert_helmrelease_inserts_under_spec_values_programs` at
29635 // the HelmRelease layer) — the same shape at the typed-
29636 // primitive layer as the two production sites.
29637 let mut arr: Vec<serde_yaml::Value> = Vec::new();
29638 let entry: serde_yaml::Value =
29639 serde_yaml::from_str("{ name: hello-rio, module: { source: oci://x } }").unwrap();
29640 let inserted =
29641 upsert_named_entry::<()>(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || ()).unwrap();
29642 assert!(inserted, "empty sequence + new entry must append");
29643 assert_eq!(arr.len(), 1);
29644 assert_eq!(
29645 arr[0].get(FLEET_PROGRAMS_KEY_NAME).and_then(|n| n.as_str()),
29646 Some("hello-rio")
29647 );
29648 }
29649
29650 #[test]
29651 fn upsert_named_entry_appends_when_no_match() {
29652 // Non-matching-name append arm: an aggregator sequence with a
29653 // differently-named entry carries no matching name-key value,
29654 // so the upsert falls through to the append-new tail (never
29655 // replacing) and returns `Ok(true)`. Pins the append-only
29656 // semantic that keeps every unrelated entry untouched.
29657 let mut arr: Vec<serde_yaml::Value> = vec![
29658 serde_yaml::from_str("{ name: other, module: { source: github:foo/bar } }").unwrap(),
29659 ];
29660 let entry: serde_yaml::Value =
29661 serde_yaml::from_str("{ name: hello-rio, module: { source: oci://x } }").unwrap();
29662 let inserted =
29663 upsert_named_entry::<()>(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || ()).unwrap();
29664 assert!(inserted);
29665 assert_eq!(arr.len(), 2);
29666 assert_eq!(
29667 arr[0].get(FLEET_PROGRAMS_KEY_NAME).and_then(|n| n.as_str()),
29668 Some("other")
29669 );
29670 assert_eq!(
29671 arr[1].get(FLEET_PROGRAMS_KEY_NAME).and_then(|n| n.as_str()),
29672 Some("hello-rio")
29673 );
29674 }
29675
29676 #[test]
29677 fn upsert_named_entry_replaces_when_match() {
29678 // Match-and-replace arm: an aggregator sequence carrying an
29679 // entry whose `<name_key>` matches the new entry's name-scalar
29680 // gets its slot rewritten in place and the helper returns
29681 // `Ok(false)` (replaced-not-appended). Pins the idempotency
29682 // contract every writer-side upsert path lands on — the same
29683 // caixa.lisp deployed twice must upsert to the same
29684 // aggregator entry, never grow a duplicated `programs[]`
29685 // entry. Peer at the substrate layer with the two production
29686 // `upsert_replaces_existing_entry` /
29687 // `upsert_helmrelease_replaces_existing` tests
29688 // ([`caixa_flux`]).
29689 let mut arr: Vec<serde_yaml::Value> = vec![
29690 serde_yaml::from_str("{ name: hello-rio, module: { source: oci://old } }").unwrap(),
29691 ];
29692 let entry: serde_yaml::Value =
29693 serde_yaml::from_str("{ name: hello-rio, module: { source: oci://new } }").unwrap();
29694 let inserted =
29695 upsert_named_entry::<()>(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || ()).unwrap();
29696 assert!(!inserted, "matching name must replace, not append");
29697 assert_eq!(arr.len(), 1);
29698 assert_eq!(
29699 arr[0]
29700 .get(COMPUTEUNIT_SPEC_KEY_MODULE)
29701 .and_then(|m| m.get(COMPUTEUNIT_MODULE_KEY_SOURCE))
29702 .and_then(|s| s.as_str()),
29703 Some("oci://new")
29704 );
29705 }
29706
29707 #[test]
29708 fn upsert_named_entry_preserves_position_on_replace() {
29709 // Position-preserving-replace pin: when an interior entry
29710 // matches, its slot is rewritten in place and the surrounding
29711 // entries stay put (first / last / any middle position). The
29712 // aggregator's fanout consumers filter `programs[]` in
29713 // declaration order (the `lareira-fleet-programs` chart's
29714 // `.Values.programs` iteration + the future
29715 // `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
29716 // per-entry admission bind); a replace-then-move-to-tail shift
29717 // (silently promoting the just-upserted entry to end-of-list)
29718 // would silently reorder every downstream consumer's iteration
29719 // window. Same declaration-order-preservation contract the
29720 // aggregator side relies on.
29721 let mut arr: Vec<serde_yaml::Value> = vec![
29722 serde_yaml::from_str("{ name: alpha, module: { source: github:a/a } }").unwrap(),
29723 serde_yaml::from_str("{ name: beta, module: { source: github:b/old } }").unwrap(),
29724 serde_yaml::from_str("{ name: gamma, module: { source: github:g/g } }").unwrap(),
29725 ];
29726 let entry: serde_yaml::Value =
29727 serde_yaml::from_str("{ name: beta, module: { source: github:b/new } }").unwrap();
29728 let inserted =
29729 upsert_named_entry::<()>(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || ()).unwrap();
29730 assert!(!inserted);
29731 assert_eq!(arr.len(), 3);
29732 // Order pin: alpha stays at 0, beta stays at 1 (rewritten),
29733 // gamma stays at 2 — replace must preserve position.
29734 let names: Vec<&str> = arr
29735 .iter()
29736 .filter_map(|v| v.get(FLEET_PROGRAMS_KEY_NAME).and_then(|n| n.as_str()))
29737 .collect();
29738 assert_eq!(names, ["alpha", "beta", "gamma"]);
29739 assert_eq!(
29740 arr[1]
29741 .get(COMPUTEUNIT_SPEC_KEY_MODULE)
29742 .and_then(|m| m.get(COMPUTEUNIT_MODULE_KEY_SOURCE))
29743 .and_then(|s| s.as_str()),
29744 Some("github:b/new")
29745 );
29746 }
29747
29748 #[test]
29749 fn upsert_named_entry_calls_error_closure_on_missing_name_key() {
29750 // Missing-name-scalar arm: when the new entry doesn't carry
29751 // `<name_key>` as a string scalar, the helper calls the
29752 // caller's `on_missing_name` closure — the caller's own typed
29753 // [`crate::RenderError`]-shaped error surface remains
29754 // authoritative. Threaded through a closure so this crate
29755 // stays agnostic to the caller's error enum shape (the two
29756 // production sites in [`caixa_flux`] surface
29757 // `Error::MissingField(FLEET_PROGRAMS_KEY_NAME)` verbatim,
29758 // and any future upsert path — the M4
29759 // `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
29760 // per-entry upsert, the `caixa-otel` per-scrape upsert —
29761 // surfaces its own typed variant).
29762 let mut arr: Vec<serde_yaml::Value> = Vec::new();
29763 let entry: serde_yaml::Value =
29764 serde_yaml::from_str("{ module: { source: oci://x } }").unwrap();
29765 let err = upsert_named_entry(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || {
29766 "missing-name".to_string()
29767 })
29768 .unwrap_err();
29769 assert_eq!(err, "missing-name");
29770 assert!(arr.is_empty(), "missing-name entry must not land in arr");
29771 }
29772
29773 #[test]
29774 fn upsert_named_entry_calls_error_closure_on_non_string_name_scalar() {
29775 // Non-string-name-scalar arm: when the new entry's
29776 // `<name_key>` is present but not a string (a number, a
29777 // mapping, a sequence — the paste-from-binary footgun where
29778 // an author or a schema-migration script accidentally lands a
29779 // JSON-Number in the name slot), the helper takes the same
29780 // path as the missing-name arm and calls the caller's
29781 // `on_missing_name` closure. Peer arm to the
29782 // upsert_named_entry_calls_error_closure_on_missing_name_key
29783 // pin — both non-string-scalar paths route through the same
29784 // caller-owned diagnostic.
29785 let mut arr: Vec<serde_yaml::Value> = Vec::new();
29786 let entry: serde_yaml::Value =
29787 serde_yaml::from_str("{ name: 42, module: { source: oci://x } }").unwrap();
29788 let err =
29789 upsert_named_entry(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || 7u32).unwrap_err();
29790 assert_eq!(err, 7u32);
29791 assert!(arr.is_empty());
29792 }
29793
29794 #[test]
29795 fn upsert_named_entry_uses_parametric_name_key() {
29796 // Name-key-axis-parametric pin: the helper matches on the
29797 // `name_key` parameter, not the pinned
29798 // [`FLEET_PROGRAMS_KEY_NAME`] const — a future writer-side
29799 // upsert path keying on a different discriminator scalar
29800 // (the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
29801 // per-entry `spec.selector` axis, an in-progress rebrand
29802 // promoting `id:` alongside `name:`) reaches for the same
29803 // helper with a different key rather than re-inlining the
29804 // upsert loop.
29805 let mut arr: Vec<serde_yaml::Value> =
29806 vec![serde_yaml::from_str("{ id: alpha, payload: original }").unwrap()];
29807 let entry: serde_yaml::Value =
29808 serde_yaml::from_str("{ id: alpha, payload: replaced }").unwrap();
29809 let inserted = upsert_named_entry::<()>(&mut arr, entry, "id", || ()).unwrap();
29810 assert!(!inserted, "matching `id:` must replace, not append");
29811 assert_eq!(arr.len(), 1);
29812 assert_eq!(
29813 arr[0].get("payload").and_then(|p| p.as_str()),
29814 Some("replaced")
29815 );
29816 }
29817
29818 // ── is_dns_1123_label — shared DNS-1123 label predicate ──────────────
29819
29820 #[test]
29821 fn dns_1123_label_accepts_canonical_forms() {
29822 // Substrate-side pin: the predicate accepts the same canonical
29823 // shapes its three caller axes (`:membros :caixa`,
29824 // `:placement :clusters`, `:children :caixa`) accept at their own
29825 // gates. Drift between this list and the per-axis positive-set
29826 // sweeps surfaces here — one source of truth for the rule.
29827 for s in [
29828 "worker",
29829 "a",
29830 "0",
29831 "cache-v2",
29832 "payment-retry",
29833 "2-pool",
29834 "mar-east",
29835 ] {
29836 is_dns_1123_label(s)
29837 .unwrap_or_else(|e| panic!("canonical DNS-1123 label {s:?} must pass: {e:?}"));
29838 }
29839 }
29840
29841 #[test]
29842 fn dns_1123_label_rejects_uppercase_with_lower_suggestion() {
29843 // The diagnostic carries the lower-cased fix verbatim so every
29844 // caller's per-axis `*Invalid { reason }` wrapping the predicate's
29845 // output reads back as a one-edit-fix suggestion. Pinned at the
29846 // substrate layer so the suggestion shape lives in one place.
29847 let err = is_dns_1123_label("Rio").unwrap_err();
29848 assert!(err.contains("uppercase"), "got: {err:?}");
29849 assert!(err.contains("\"rio\""), "got: {err:?}");
29850 }
29851
29852 #[test]
29853 fn dns_1123_label_rejects_at_64_byte_boundary() {
29854 // The 63-byte cap pin — both the boundary-exceeding case and
29855 // the boundary-accepting case in one place, so a future cap
29856 // shift surfaces both arms simultaneously.
29857 let max_ok = "a".repeat(63);
29858 is_dns_1123_label(&max_ok).unwrap();
29859 let too_long = "a".repeat(64);
29860 let err = is_dns_1123_label(&too_long).unwrap_err();
29861 assert!(err.contains("63"), "got: {err:?}");
29862 assert!(err.contains("64"), "got: {err:?}");
29863 }
29864
29865 #[test]
29866 fn dns_1123_label_rejects_empty_defensively() {
29867 // Defensive re-check pin — every peer value-shape predicate in
29868 // this module (`is_gateway_api_http_path`, `is_wit_world_ref`,
29869 // `is_nats_subject`, `is_wasi_keyvalue_slot`, `is_git_ref_name`)
29870 // carries the same empty-first arm, so `is_dns_1123_label("")`
29871 // returns a clean parser-shaped `must not be empty` reason
29872 // instead of panicking at the boundary arm's `bytes[0]` access
29873 // (`bytes[0].is_ascii_alphanumeric()` on an empty slice would
29874 // index out of bounds). The per-axis narrower `*Empty` variant
29875 // (`MembroCaixaEmpty`, `PlacementClusterEmpty`, `EmptyChildName`,
29876 // `ModuleEmpty`) still fires at every current call site — this
29877 // arm exists so any future call site missing the pre-check gets
29878 // a self-locating diagnostic rather than a `panic!` far from the
29879 // source caixa.lisp, matching the "usable from any future call
29880 // site without a shape-mismatch footgun" discipline every peer
29881 // predicate's doc-comment already promises.
29882 let err = is_dns_1123_label("").unwrap_err();
29883 assert!(err.contains("empty"), "got: {err:?}");
29884 assert_eq!(err, "must not be empty");
29885 }
29886
29887 // ── is_gateway_api_http_path — shared HTTP-path predicate ────────────
29888
29889 #[test]
29890 fn gateway_api_http_path_accepts_canonical_forms() {
29891 // Substrate-side pin: the predicate accepts the same canonical
29892 // shapes both caller axes (`:entrada :paths` and `:contratos
29893 // :endpoint`) accept at their own gates. Drift between this
29894 // list and the per-axis positive-set sweeps surfaces here —
29895 // one source of truth for the rule. Includes the bare-root
29896 // `/` (the catch-all both renderers fall back to), the
29897 // `/foo..bar` interior-`..`-substring (not a `..` segment),
29898 // the `/...` and `/foo.` `.`-bearing names (not `.` segments),
29899 // and the percent-encoded form.
29900 for p in [
29901 "/",
29902 "/api/cart",
29903 "/healthz",
29904 "/api/.config",
29905 "/v1/products",
29906 "/products/:id",
29907 "/api/cart/",
29908 "/api/caf%C3%A9",
29909 "/foo..bar",
29910 "/...",
29911 "/charge",
29912 ] {
29913 is_gateway_api_http_path(p)
29914 .unwrap_or_else(|e| panic!("canonical HTTP path {p:?} must pass: {e:?}"));
29915 }
29916 }
29917
29918 #[test]
29919 fn gateway_api_http_path_rejects_each_arm_with_substring_pinned_reason() {
29920 // Substrate-side diagnostic-shape pin: each grammar arm
29921 // surfaces its own distinct reason substring. Pinned here so
29922 // a future reason-wording rephrase that drops any of these
29923 // substrings surfaces at this one place, not piecemeal across
29924 // every per-axis test sweep.
29925 for (path, needle) in [
29926 ("/api?q=1", "must not contain `?`"),
29927 ("/api#frag", "must not contain `#`"),
29928 ("/api my", "whitespace"),
29929 ("/api\x01x", "control character"),
29930 ("/api/café", "non-ASCII"),
29931 ("/api//x", "consecutive `/`"),
29932 ("/api/./x", "`.` segment"),
29933 ("/api/../x", "`..` parent-segment"),
29934 ] {
29935 let err = is_gateway_api_http_path(path)
29936 .err()
29937 .unwrap_or_else(|| panic!("path {path:?} must be rejected"));
29938 assert!(
29939 err.contains(needle),
29940 "path {path:?} reason must contain {needle:?}; got {err:?}"
29941 );
29942 }
29943 }
29944
29945 #[test]
29946 fn gateway_api_http_path_rejects_at_1025_byte_boundary() {
29947 // The 1024-byte cap pin — both the boundary-exceeding case and
29948 // the boundary-accepting case in one place, so a future cap
29949 // shift surfaces both arms simultaneously, mirroring
29950 // `dns_1123_label_rejects_at_64_byte_boundary` on the peer
29951 // predicate.
29952 let max_ok = format!("/{}", "a".repeat(1023));
29953 assert_eq!(max_ok.len(), 1024);
29954 is_gateway_api_http_path(&max_ok).unwrap();
29955 let too_long = format!("/{}", "a".repeat(1024));
29956 assert_eq!(too_long.len(), 1025);
29957 let err = is_gateway_api_http_path(&too_long).unwrap_err();
29958 assert!(err.contains("1024"), "got: {err:?}");
29959 assert!(err.contains("1025"), "got: {err:?}");
29960 }
29961
29962 #[test]
29963 fn gateway_api_http_path_rejects_empty_defensively() {
29964 // The predicate is called only after each caller's narrower
29965 // `*Empty` arm has fired; re-checking here keeps the predicate
29966 // usable from any future call site without an empty-precondition
29967 // footgun, and avoids a panic on `bytes[0]`-style indexing if
29968 // a future arm is added. Same defensive empty-check
29969 // `validate_entrada_path` carries at its call site (55410e4).
29970 let err = is_gateway_api_http_path("").unwrap_err();
29971 assert!(err.contains("empty"), "got: {err:?}");
29972 }
29973
29974 #[test]
29975 fn gateway_api_http_path_rejects_not_absolute_defensively() {
29976 // Defensive re-check of the leading-`/` invariant the per-axis
29977 // call site enforces with its own narrower `*NotAbsolute` arm;
29978 // ensures the predicate is callable from any future call site
29979 // without a shape-mismatch footgun.
29980 let err = is_gateway_api_http_path("api/cart").unwrap_err();
29981 assert!(err.contains('/'), "got: {err:?}");
29982 }
29983
29984 #[test]
29985 fn gateway_api_http_path_rejects_every_reserved_printable_ascii_byte() {
29986 // Substrate-side sweep: every one of the eleven printable-ASCII
29987 // bytes outside the K8s Gateway API HTTPPathMatch.value
29988 // apiserver-side OpenAPI regex
29989 // `^(?:[-A-Za-z0-9/._~!$&'()*+,;=:@]|[%][0-9a-fA-F]{2})+$`
29990 // accepted set surfaces a self-locating reason naming the
29991 // offending byte verbatim plus the canonical `%XX` percent-
29992 // encoding remediation. RFC 3986 §3.3's `pchar = unreserved /
29993 // pct-encoded / sub-delims / ":" / "@"` grammar excludes these
29994 // bytes from every path segment, so the apiserver rejects them
29995 // at admission time on every
29996 // `HTTPRoute.spec.rules[].matches[].path.value` landing site —
29997 // peer with the `?` / `#` / whitespace / control / non-ASCII
29998 // arms `gateway_api_http_path_rejects_each_arm_with_substring_
29999 // pinned_reason` covers.
30000 //
30001 // Each char surfaces in a path-shape that pins the canonical
30002 // authoring footgun the K8s apiserver would otherwise catch
30003 // far from the caixa.lisp: `{id}` / `[0]` / `<placeholder>`
30004 // template forms, the Windows path-separator typo, the
30005 // shell-regex character footgun, the SQL-string-literal /
30006 // YAML-flow-mapping accidents.
30007 for (path, ch) in [
30008 ("/api/cart\"path", '"'),
30009 ("/api/cart<id>", '<'),
30010 ("/api/cart/<id>", '<'),
30011 ("/api/cart[0]", '['),
30012 ("/api/cart\\path", '\\'),
30013 ("/api/cart]", ']'),
30014 ("/api/cart/^foo", '^'),
30015 ("/api/cart/`foo", '`'),
30016 ("/api/cart/{id}", '{'),
30017 ("/api/cart|alt", '|'),
30018 ("/api/cart}", '}'),
30019 ] {
30020 let err = is_gateway_api_http_path(path)
30021 .err()
30022 .unwrap_or_else(|| panic!("path {path:?} must be rejected"));
30023 assert!(
30024 err.contains("reserved character"),
30025 "path {path:?} reason must name the reserved-character axis; got {err:?}"
30026 );
30027 assert!(
30028 err.contains(&format!("{ch:?}")),
30029 "path {path:?} reason must name the offending byte {ch:?} verbatim; got {err:?}"
30030 );
30031 let hex = format!("%{:02X}", ch as u8);
30032 assert!(
30033 err.contains(&hex),
30034 "path {path:?} reason must surface the canonical {hex:?} percent-encoding \
30035 remediation; got {err:?}"
30036 );
30037 }
30038 }
30039
30040 #[test]
30041 fn gateway_api_http_path_reserved_char_arm_fires_before_consecutive_slash() {
30042 // Precedence pin: the per-byte loop runs before the post-loop
30043 // structural arms (`//`, `/./`, `/../`), so a path that is
30044 // *both* reserved-char-bearing and consecutive-`/`-bearing
30045 // surfaces the more self-locating reserved-character diagnostic
30046 // first, naming the offending byte verbatim. Mirrors the
30047 // existing `?` / `#` / whitespace / control / non-ASCII arms'
30048 // implicit precedence the
30049 // `gateway_api_http_path_rejects_each_arm_with_substring_
30050 // pinned_reason` pin already establishes for the peer per-byte
30051 // shapes.
30052 let err = is_gateway_api_http_path("/api/{id}//x").unwrap_err();
30053 assert!(
30054 err.contains("reserved character") && err.contains("'{'"),
30055 "got: {err:?}"
30056 );
30057 assert!(
30058 !err.contains("consecutive"),
30059 "the reserved-char arm must fire before the consecutive-`/` arm; got: {err:?}"
30060 );
30061 }
30062
30063 #[test]
30064 fn gateway_api_http_path_accepts_percent_encoded_reserved_chars() {
30065 // Positive-control complement to the reserved-byte rejection
30066 // sweep: every one of the eleven reserved printable-ASCII bytes
30067 // is admissible *when* properly percent-encoded, matching the
30068 // canonical Gateway API HTTPPathMatch.value apiserver-side
30069 // OpenAPI regex's `[%][0-9a-fA-F]{2}` alternative. Pins the
30070 // canonical remediation pathway the reserved-byte arm's reason
30071 // wording names — author who carries a literal `{` percent-
30072 // encodes as `%7B` and the typed slot accepts.
30073 for path in [
30074 "/api/cart%22path",
30075 "/api/cart%3Cid%3E",
30076 "/api/cart%5B0%5D",
30077 "/api/cart%5Cpath",
30078 "/api/cart/%5Efoo",
30079 "/api/cart/%60foo",
30080 "/api/cart/%7Bid%7D",
30081 "/api/cart%7Calt",
30082 ] {
30083 is_gateway_api_http_path(path)
30084 .unwrap_or_else(|e| panic!("percent-encoded path {path:?} must pass: {e:?}"));
30085 }
30086 }
30087
30088 // ── is_wit_world_ref — shared WIT world-reference predicate ──────────
30089
30090 #[test]
30091 fn wit_world_ref_accepts_canonical_forms() {
30092 // Substrate-side pin: the predicate accepts every canonical
30093 // WIT identifier the `:contratos :wit` axis already carries in
30094 // the test fixtures + the example checkout-aplicacao (each
30095 // hand-curated to match real WIT registry references). Drift
30096 // between this list and the per-axis positive-set sweep
30097 // surfaces here — one source of truth for the rule. Includes
30098 // every shape variant: HTTP-prefixed (`wasi:http/proxy`),
30099 // KV-prefixed (`wasi:keyvalue/store`), pubsub-prefixed
30100 // (`nats:pub-sub`, `kafka:topic`), capability-only
30101 // (`custom:exchange`, `pleme:cap/audit`), the optional
30102 // `@<version>` suffix (`wasi:http/proxy@0.2.0`), and the
30103 // multi-segment `/iface/iface` form the WIT IDL grammar allows.
30104 for s in [
30105 "wasi:http/proxy",
30106 "wasi:keyvalue/store",
30107 "nats:pub-sub",
30108 "kafka:topic",
30109 "custom:exchange",
30110 "pleme:cap/audit",
30111 "http:server",
30112 "kv:store",
30113 "wasi:http/proxy@0.2.0",
30114 "wasi:keyvalue/store@0.2.0-rc.1",
30115 "pleme:cap/audit/v2",
30116 // Every legal shape SemVer 2.0.0 admits in the `@<version>`
30117 // body — bare numeric core, pre-release suffix (single +
30118 // dot-separated identifiers), build-metadata suffix (single
30119 // + dot-separated identifiers), combined pre-release +
30120 // build-metadata, and leading-zero-avoiding pre-release
30121 // identifiers — pinned here so a future tightening of the
30122 // per-byte accepted set that rejects a canonical semver
30123 // shape surfaces here rather than at the M4 CR materializer's
30124 // WIT-parse boundary.
30125 "wasi:http/proxy@1.0.0",
30126 "wasi:http/proxy@0.2.0-alpha",
30127 "wasi:http/proxy@1.0.0-alpha.1",
30128 "wasi:http/proxy@2.0.0+build.42",
30129 "wasi:http/proxy@0.0.0-rc.1+abc.def",
30130 ] {
30131 is_wit_world_ref(s)
30132 .unwrap_or_else(|e| panic!("canonical WIT reference {s:?} must pass: {e:?}"));
30133 }
30134 }
30135
30136 #[test]
30137 fn wit_world_ref_rejects_each_arm_with_substring_pinned_reason() {
30138 // Substrate-side diagnostic-shape pin: each grammar arm
30139 // surfaces its own distinct reason substring. Pinned here so a
30140 // future reason-wording rephrase that drops any of these
30141 // substrings surfaces at this one place, not piecemeal across
30142 // every per-axis test sweep. Mirrors
30143 // `gateway_api_http_path_rejects_each_arm_with_substring_pinned_reason`
30144 // on the peer predicate.
30145 for (s, needle) in [
30146 // Missing `:` separator → silent capability demotion.
30147 ("wasi-http/proxy", "must contain a `:`"),
30148 // Multiple `:` → can't split into ns + pkg.
30149 ("wasi:http:proxy", "exactly one `:`"),
30150 // Uppercase → silently bypasses the lowercase dispatch.
30151 ("WASI:http/proxy", "lowercase"),
30152 ("wasi:HTTP/proxy", "lowercase"),
30153 // Empty package half → can't resolve via WIT registry.
30154 ("wasi:", "must not be empty"),
30155 // Empty namespace half.
30156 (":http/proxy", "must not be empty"),
30157 // Underscore → DNS-1123 / WIT kebab-case footgun.
30158 ("wasi:http_proxy", "_"),
30159 // Leading digit → WIT identifiers begin with a letter.
30160 ("wasi:1http/proxy", "digit"),
30161 // Consecutive hyphens → invalid kebab-case.
30162 ("wasi:pub--sub", "consecutive `-`"),
30163 // Trailing hyphen → invalid kebab-case.
30164 ("wasi:proxy-", "must not end with `-`"),
30165 // Whitespace inside the token.
30166 ("wasi:http proxy", "whitespace"),
30167 // Control characters.
30168 ("wasi:http\x01proxy", "control character"),
30169 // Non-ASCII byte (café-style un-percent-encoded literal).
30170 ("wasi:caf\u{e9}/proxy", "non-ASCII"),
30171 // Trailing `@` with no version body.
30172 ("wasi:http/proxy@", "trailing `@`"),
30173 // Version body carrying `:` or `/`.
30174 ("wasi:http/proxy@0.2:rc1", "must not contain `:` or `/`"),
30175 // Doubled `@`.
30176 ("wasi:http/proxy@0.2@beta", "at most one `@`"),
30177 // Version body carrying a byte outside the SemVer 2.0.0
30178 // accepted set `[0-9A-Za-z.\-+]` — the canonical
30179 // author-side paste footguns (`?` from URL-query-separator
30180 // paste, `#` from URL-fragment paste, `!` from
30181 // history-expansion, `(` from parenthetical doc annotation,
30182 // `~` from tilde-range npm/Cargo semver-req paste that
30183 // strayed into the version body itself). Each surfaces the
30184 // `invalid character` reason substring so the diagnostic
30185 // wording is pinned alongside every peer per-byte rejection.
30186 ("wasi:http/proxy@0.2.0?rc1", "invalid character"),
30187 ("wasi:http/proxy@0.2.0#build", "invalid character"),
30188 ("wasi:http/proxy@0.2.0!alpha", "invalid character"),
30189 ("wasi:http/proxy@0.2.0(rc1)", "invalid character"),
30190 ("wasi:http/proxy@~0.2.0", "invalid character"),
30191 // Version body byte-set-valid but *structurally* invalid
30192 // SemVer 2.0.0 — the canonical author-side paste footguns
30193 // the byte-set gate above cannot catch. Every entry passes
30194 // the accepted-set arm `[0-9A-Za-z.\-+]` verbatim and
30195 // fails only at [`semver::Version::parse`]: two-part
30196 // numeric core (`@1.0` — Node.js `"engines"` field paste),
30197 // one-part numeric core (`@1` — Docker `:v1` tag paste),
30198 // four-part numeric core (`@1.0.0.0` — Microsoft / Java
30199 // build-number convention), `v`-prefixed version body
30200 // (`@v0.2.0` — git-tag-shape paste), leading-zero major
30201 // (`@01.0.0` — mistaken zero-padded date-based version),
30202 // trailing hyphen with empty pre-release (`@1.0.0-` —
30203 // half-typed pre-release), trailing plus with empty
30204 // build-metadata (`@1.0.0+` — peer for build-metadata),
30205 // empty pre-release identifier between dots
30206 // (`@1.0.0-.rc1` — accidental leading `.`), empty build-
30207 // metadata identifier between dots (`@1.0.0+.abc` — peer
30208 // for build-metadata), numeric pre-release identifier
30209 // with leading zero (`@1.0.0-01` — SemVer 2.0.0 rule 9),
30210 // consecutive dots inside pre-release (`@1.0.0-alpha..beta`).
30211 // Each surfaces the `structurally valid SemVer 2.0.0`
30212 // reason substring so the diagnostic wording is pinned
30213 // alongside every peer structural rejection.
30214 ("wasi:http/proxy@1.0", "structurally valid SemVer 2.0.0"),
30215 ("wasi:http/proxy@1", "structurally valid SemVer 2.0.0"),
30216 ("wasi:http/proxy@1.0.0.0", "structurally valid SemVer 2.0.0"),
30217 ("wasi:http/proxy@v0.2.0", "structurally valid SemVer 2.0.0"),
30218 ("wasi:http/proxy@01.0.0", "structurally valid SemVer 2.0.0"),
30219 ("wasi:http/proxy@1.0.0-", "structurally valid SemVer 2.0.0"),
30220 ("wasi:http/proxy@1.0.0+", "structurally valid SemVer 2.0.0"),
30221 (
30222 "wasi:http/proxy@1.0.0-.rc1",
30223 "structurally valid SemVer 2.0.0",
30224 ),
30225 (
30226 "wasi:http/proxy@1.0.0+.abc",
30227 "structurally valid SemVer 2.0.0",
30228 ),
30229 (
30230 "wasi:http/proxy@1.0.0-01",
30231 "structurally valid SemVer 2.0.0",
30232 ),
30233 (
30234 "wasi:http/proxy@1.0.0-alpha..beta",
30235 "structurally valid SemVer 2.0.0",
30236 ),
30237 // Digit-immediately-after-`-` word-start rule — the WIT IDL
30238 // `word ::= [a-z][a-z0-9]*` per-word first-byte gate the
30239 // predicate's doc-comment already documented, closed at the
30240 // implementation layer. Each identifier passes the outer
30241 // `[a-z0-9-]` byte set, the leading-`-` rejection, the
30242 // consecutive-`-` rejection, and the trailing-`-` rejection,
30243 // and was silently accepted before the arm landed — surfaces
30244 // the `word after `-`` reason substring so a future
30245 // diagnostic-wording rephrase surfaces here alongside every
30246 // peer per-arm substring pin. Canonical author-side
30247 // footguns: `"pub-1sub"` (version-shape digit paste),
30248 // `"proxy-2beta"` (v2 tag paste), `"cap-9"` (numeric
30249 // suffix). Namespace-side and interface-side variants pin
30250 // the arm fires uniformly on every WIT segment (`ns:pkg`,
30251 // `ns:pkg/iface`, not just the first).
30252 ("wasi:pub-1sub", "word after `-`"),
30253 ("wasi:proxy-2beta", "word after `-`"),
30254 ("wasi:cap-9", "word after `-`"),
30255 ("pleme-1cap:audit", "word after `-`"),
30256 ("wasi:http/proxy-3rc", "word after `-`"),
30257 ] {
30258 let err = is_wit_world_ref(s)
30259 .err()
30260 .unwrap_or_else(|| panic!("WIT reference {s:?} must be rejected"));
30261 assert!(
30262 err.contains(needle),
30263 "WIT reference {s:?} reason must contain {needle:?}; got {err:?}"
30264 );
30265 }
30266 }
30267
30268 #[test]
30269 fn wit_world_ref_word_after_hyphen_digit_arm_names_offending_byte_and_word_rule() {
30270 // Pin the per-word first-byte arm's diagnostic quality: the
30271 // offending byte appears verbatim in the reason, the WIT
30272 // grammar production is named (`[a-z][a-z0-9]*`), and the
30273 // remediation suggests a lowercase-letter prefix on the
30274 // offending word. Mirrors the `wit_world_ref_leading_digit`
30275 // sibling pin on the *first-word* first-byte arm — the two
30276 // arms enforce the same rule at complementary positions
30277 // (whole-id first byte vs. per-hyphen-word first byte), so
30278 // their diagnostic shapes stay peer.
30279 let err = is_wit_world_ref("wasi:pub-1sub").unwrap_err();
30280 assert!(err.contains("'1'"), "must name offending byte: {err:?}");
30281 assert!(
30282 err.contains("[a-z][a-z0-9]*"),
30283 "must name WIT word grammar: {err:?}"
30284 );
30285 assert!(
30286 err.contains("pub-v1sub"),
30287 "must suggest the letter-prefix remediation: {err:?}"
30288 );
30289 }
30290
30291 #[test]
30292 fn wit_world_ref_word_after_hyphen_lowercase_letter_still_accepted() {
30293 // Complement-side pin: the per-word first-byte arm strictly
30294 // targets *digits* after `-`; every canonical multi-word
30295 // lowercase identifier (`pub-sub`, `pub-sub-async`,
30296 // `wasi:http/incoming-handler`, `wasi:keyvalue/atomic-batch`)
30297 // remains in the accepted set with no new false-positive.
30298 // Pinned here so a future tightening that spills the digit-
30299 // rejection arm onto the letter-after-hyphen class surfaces
30300 // as a test failure at this positive-set pin, not at the M4
30301 // CR materializer's WIT-parse boundary. Mirrors the
30302 // `wit_world_ref_accepts_canonical_forms` positive-set
30303 // sweep, extended here to the multi-word-lowercase axis.
30304 for s in [
30305 "nats:pub-sub",
30306 "wasi:http/incoming-handler",
30307 "wasi:keyvalue/atomic-batch",
30308 "pleme:cap/audit-log",
30309 "http:server-side",
30310 ] {
30311 is_wit_world_ref(s).unwrap_or_else(|e| {
30312 panic!("canonical multi-word WIT identifier {s:?} must pass: {e:?}")
30313 });
30314 }
30315 }
30316
30317 #[test]
30318 fn wit_world_ref_word_after_hyphen_digit_arm_fires_before_byte_set_arm() {
30319 // Diagnostic-precedence pin: an identifier that is *both*
30320 // digit-after-`-` and byte-set-invalid (`"pub-1$"`) surfaces
30321 // the more self-locating word-start diagnostic, not the
30322 // generic invalid-character diagnostic. The arm order in the
30323 // loop is deliberate — the per-word first-byte gate fires on
30324 // the first offending byte (position 4 = the `1`) before the
30325 // byte-set gate can reach the `$` at position 5. Pinned here
30326 // so a future arm-reordering that moves the byte-set gate
30327 // earlier surfaces the drift at this test rather than
30328 // silently value-laundering the diagnostic.
30329 let err = is_wit_world_ref("wasi:pub-1$").unwrap_err();
30330 assert!(
30331 err.contains("word after `-`"),
30332 "must surface the per-word first-byte diagnostic, not the invalid-character one: {err:?}"
30333 );
30334 // And the `$` case *without* the digit-after-`-` still lands
30335 // on the invalid-character arm — the two diagnostics don't
30336 // collide when only one applies.
30337 let err = is_wit_world_ref("wasi:pub-x$").unwrap_err();
30338 assert!(
30339 err.contains("invalid character"),
30340 "byte-set-only rejection must still name invalid character: {err:?}"
30341 );
30342 }
30343
30344 #[test]
30345 fn wit_world_ref_rejects_empty_defensively() {
30346 // The predicate is called from `WitContract::target()` only
30347 // after the per-axis `EmptyWit` arm has fired at validate
30348 // time; re-checking here keeps the predicate usable from any
30349 // future call site without an empty-precondition footgun.
30350 // Same defensive empty-check `is_dns_1123_label` /
30351 // `is_gateway_api_http_path` carry at their call sites.
30352 let err = is_wit_world_ref("").unwrap_err();
30353 assert!(err.contains("empty"), "got: {err:?}");
30354 }
30355
30356 #[test]
30357 fn wit_world_ref_rejects_at_129_byte_boundary() {
30358 // The 128-byte cap pin — both the boundary-exceeding case and
30359 // the boundary-accepting case in one place, so a future cap
30360 // shift surfaces both arms simultaneously, mirroring
30361 // `dns_1123_label_rejects_at_64_byte_boundary` and
30362 // `gateway_api_http_path_rejects_at_1025_byte_boundary` on the
30363 // peer predicates. Constructed as `wasi:<long-pkg>` so the
30364 // kebab-shape arms don't fire first and obscure the cap arm.
30365 let pad = "a".repeat(123); // 5 + 123 = 128 (`wasi:` + pad)
30366 let max_ok = format!("wasi:{pad}");
30367 assert_eq!(max_ok.len(), 128);
30368 is_wit_world_ref(&max_ok).unwrap();
30369 let pad_over = "a".repeat(124);
30370 let too_long = format!("wasi:{pad_over}");
30371 assert_eq!(too_long.len(), 129);
30372 let err = is_wit_world_ref(&too_long).unwrap_err();
30373 assert!(err.contains("128"), "got: {err:?}");
30374 assert!(err.contains("129"), "got: {err:?}");
30375 }
30376
30377 // ── is_nats_subject — shared NATS subject predicate ──────────────────
30378
30379 #[test]
30380 fn nats_subject_accepts_canonical_forms() {
30381 // Substrate-side pin: the predicate accepts every canonical
30382 // NATS subject the `:contratos :subject` axis carries in the
30383 // caixa-mesh test fixtures + the example checkout-aplicacao
30384 // (each hand-curated to match real NATS server-side admission
30385 // shapes). Drift between this list and the per-axis positive-
30386 // set sweep surfaces here — one source of truth for the rule.
30387 // Includes single-token subjects, multi-dot subjects, snake-
30388 // case + kebab-case tokens (NATS accepts both), digit-bearing
30389 // tokens, the `*` single-token wildcard at every segment
30390 // position, and the `>` multi-token wildcard at the final
30391 // position (the two NATS subscription patterns the protocol
30392 // defines). Mirrors the canonical-forms sweeps on the peer
30393 // value-shape predicates (`gateway_api_http_path_accepts_…`,
30394 // `wit_world_ref_accepts_…`).
30395 for s in [
30396 "checkout.events.charge.failed",
30397 "rio.events.order.charged",
30398 "orders",
30399 "orders.123",
30400 "snake_case.token",
30401 "kebab-case.token",
30402 "MixedCase.Token",
30403 "alpha.beta.gamma.delta.epsilon",
30404 "orders.*.charged",
30405 "*.events.*",
30406 "orders.>",
30407 "*",
30408 ">",
30409 ] {
30410 is_nats_subject(s)
30411 .unwrap_or_else(|e| panic!("canonical NATS subject {s:?} must pass: {e:?}"));
30412 }
30413 }
30414
30415 #[test]
30416 fn nats_subject_rejects_each_arm_with_substring_pinned_reason() {
30417 // Substrate-side diagnostic-shape pin: each grammar arm
30418 // surfaces its own distinct reason substring. Pinned here so
30419 // a future reason-wording rephrase that drops any of these
30420 // substrings surfaces at this one place, not piecemeal across
30421 // every per-axis test sweep. Mirrors
30422 // `gateway_api_http_path_rejects_each_arm_with_substring_pinned_reason`
30423 // and `wit_world_ref_rejects_each_arm_with_substring_pinned_reason`
30424 // on the peer predicates.
30425 for (s, needle) in [
30426 // Whitespace inside the token.
30427 ("foo bar", "whitespace"),
30428 ("foo\tbar", "whitespace"),
30429 // Control characters.
30430 ("foo\x01bar", "control character"),
30431 // Non-ASCII byte (un-percent-encoded café-style literal).
30432 ("foo.caf\u{e9}", "non-ASCII"),
30433 // Leading `.` — empty leading token.
30434 (".foo", "must not start with `.`"),
30435 // Trailing `.` — empty trailing token.
30436 ("foo.", "must not end with `.`"),
30437 // Consecutive `.` — empty token between separators.
30438 ("foo..bar", "consecutive `.`"),
30439 // Non-trailing `>` multi-token wildcard.
30440 ("foo.>.bar", "only allowed as the final segment"),
30441 // Mid-segment `*` (not a standalone wildcard token).
30442 ("foo*.bar", "`*` mid-segment"),
30443 // Mid-segment `>` (not a standalone wildcard token).
30444 ("foo>", "`>` mid-segment"),
30445 // `.` is the separator, so `,` (or any other punctuation)
30446 // surfaces as an invalid-character arm.
30447 ("foo,bar", "invalid character"),
30448 // `:` reserved-looking — distinct invalid-character arm
30449 // (pinned separately so a future relaxation that accepts
30450 // `:` mid-segment surfaces here, not in some downstream
30451 // renderer's "this passed validate but the NATS server
30452 // rejected at publish" footgun).
30453 ("foo:bar", "invalid character"),
30454 ] {
30455 let err = is_nats_subject(s)
30456 .err()
30457 .unwrap_or_else(|| panic!("NATS subject {s:?} must be rejected"));
30458 assert!(
30459 err.contains(needle),
30460 "NATS subject {s:?} reason must contain {needle:?}; got {err:?}"
30461 );
30462 }
30463 }
30464
30465 #[test]
30466 fn nats_subject_rejects_empty_defensively() {
30467 // The predicate is called from `WitContract::target()` only
30468 // after the per-axis `ContratoSubjectEmpty` arm has fired at
30469 // validate time; re-checking here keeps the predicate usable
30470 // from any future call site without an empty-precondition
30471 // footgun. Same defensive empty-check `is_dns_1123_label`,
30472 // `is_gateway_api_http_path`, and `is_wit_world_ref` carry at
30473 // their call sites.
30474 let err = is_nats_subject("").unwrap_err();
30475 assert!(err.contains("empty"), "got: {err:?}");
30476 }
30477
30478 #[test]
30479 fn nats_subject_rejects_at_257_byte_boundary() {
30480 // The 256-byte cap pin — both the boundary-exceeding case and
30481 // the boundary-accepting case in one place, so a future cap
30482 // shift surfaces both arms simultaneously, mirroring
30483 // `dns_1123_label_rejects_at_64_byte_boundary`,
30484 // `gateway_api_http_path_rejects_at_1025_byte_boundary`, and
30485 // `wit_world_ref_rejects_at_129_byte_boundary` on the peer
30486 // predicates. Constructed as a single all-`a` token (no `.`)
30487 // so the segment / wildcard arms don't fire first and obscure
30488 // the cap arm.
30489 let max_ok = "a".repeat(256);
30490 assert_eq!(max_ok.len(), 256);
30491 is_nats_subject(&max_ok).unwrap();
30492 let too_long = "a".repeat(257);
30493 assert_eq!(too_long.len(), 257);
30494 let err = is_nats_subject(&too_long).unwrap_err();
30495 assert!(err.contains("256"), "got: {err:?}");
30496 assert!(err.contains("257"), "got: {err:?}");
30497 }
30498
30499 #[test]
30500 fn nats_subject_lone_wildcard_tokens_validate() {
30501 // The two NATS wildcards stand alone as the entire subject —
30502 // a `subscribe("*")` matches any single-token publish, a
30503 // `subscribe(">")` matches every NATS message on the connection.
30504 // Both are protocol-legal; the typed substrate accepts them
30505 // structurally and leaves the "should the typed `:contratos`
30506 // edge subscribe to literally everything?" question to a
30507 // future semantic-level gate. Pinned alongside the canonical-
30508 // forms sweep so a future tighten that disallows lone wildcards
30509 // surfaces both arms simultaneously.
30510 is_nats_subject("*").unwrap();
30511 is_nats_subject(">").unwrap();
30512 }
30513
30514 #[test]
30515 fn nats_subject_trailing_multi_wildcard_validates() {
30516 // `>` at the final segment is the canonical "match all trailing
30517 // tokens" subscription pattern. Pinned alongside the non-
30518 // trailing-`>` rejection arm so the boundary between the two
30519 // is in one place — a future relaxation that allows `>` at
30520 // non-trailing positions or a tighten that disallows trailing
30521 // `>` surfaces both arms simultaneously.
30522 is_nats_subject("orders.>").unwrap();
30523 is_nats_subject("orders.events.>").unwrap();
30524 // And the `*` single-token wildcard combines freely with the
30525 // trailing `>` — the canonical "match one middle token, then
30526 // anything trailing" subscription pattern.
30527 is_nats_subject("orders.*.>").unwrap();
30528 }
30529
30530 // ── is_wasi_keyvalue_slot — shared kv slot-template predicate ────────
30531
30532 #[test]
30533 fn wasi_kv_slot_accepts_canonical_forms() {
30534 // Substrate-side pin: the predicate accepts every canonical kv
30535 // slot template the `:contratos :slot` axis carries in the
30536 // caixa-mesh test fixtures + plausible authoring patterns
30537 // (each maps to a realistic wasi:keyvalue/store key the runtime
30538 // resolves on dispatch). Drift between this list and the
30539 // per-axis positive-set sweep surfaces here — one source of
30540 // truth for the rule. Includes:
30541 // - single-token identifiers (`"checkout"`, `"events"`);
30542 // - dot-namespaced templates (`"session.tokens.<sid>"`);
30543 // - path-namespaced templates with `$`-prefixed variables
30544 // (`"checkout/$orderId"`, the canonical Akka-cluster-
30545 // sharding-style template);
30546 // - colon-namespaced templates with brace placeholders
30547 // (`"users:{tenant}/{id}"`, the canonical multi-tenant
30548 // Redis-key shape);
30549 // - angle-bracket placeholders (`"session.<sid>"`);
30550 // - underscore identifiers (`"snake_case_key"`);
30551 // - kebab identifiers (`"kebab-case-key"`);
30552 // - mixed-case (`"MixedCase"` — kv slot templates are case-
30553 // sensitive; the predicate doesn't lowercase-fold);
30554 // - digit-bearing tokens (`"shard0"`, `"v2/key"`);
30555 // - percent-encoded fragments (`"users/caf%C3%A9"`); the
30556 // encoded form is the *valid* shape, the raw `café` is
30557 // rejected on the non-ASCII arm.
30558 // Mirrors the canonical-forms sweeps on the peer value-shape
30559 // predicates (`gateway_api_http_path_accepts_…`,
30560 // `nats_subject_accepts_canonical_forms`).
30561 for s in [
30562 "checkout",
30563 "events",
30564 "checkout/$orderId",
30565 "users:{tenant}/{id}",
30566 "session.<sid>",
30567 "session.tokens.<sid>",
30568 "snake_case_key",
30569 "kebab-case-key",
30570 "MixedCase",
30571 "shard0",
30572 "v2/key",
30573 "users/caf%C3%A9",
30574 ] {
30575 is_wasi_keyvalue_slot(s)
30576 .unwrap_or_else(|e| panic!("canonical kv slot {s:?} must pass: {e:?}"));
30577 }
30578 }
30579
30580 #[test]
30581 fn wasi_kv_slot_rejects_each_arm_with_substring_pinned_reason() {
30582 // Substrate-side diagnostic-shape pin: each grammar arm
30583 // surfaces its own distinct reason substring. Pinned here so
30584 // a future reason-wording rephrase that drops any of these
30585 // substrings surfaces at this one place, not piecemeal across
30586 // every per-axis test sweep. Mirrors
30587 // `nats_subject_rejects_each_arm_with_substring_pinned_reason`
30588 // and `gateway_api_http_path_rejects_each_arm_with_substring_pinned_reason`
30589 // on the peer predicates.
30590 for (s, needle) in [
30591 // Raw space inside the template — the canonical paste-from-
30592 // doc footgun.
30593 ("check out/$order", "whitespace"),
30594 // Tab byte — distinct arm-pinned reason from the space arm.
30595 ("check\tout", "whitespace"),
30596 // Control character (SOH = 0x01) — pinned separately from
30597 // the whitespace arm so a future relaxation that admits
30598 // raw whitespace but still rejects controls surfaces here.
30599 ("checkout/\x01order", "control character"),
30600 // Newline — the canonical "the paste-from-binary slug
30601 // spans multiple lines" footgun. Distinct from the
30602 // whitespace arm because `\n` is a control character.
30603 ("checkout\norder", "control character"),
30604 // DEL byte (0x7F) — the upper boundary of the control-
30605 // character range, pinned so a future relaxation that
30606 // only checks `< 0x20` surfaces here.
30607 ("checkout\x7forder", "control character"),
30608 // Un-percent-encoded non-ASCII byte — the canonical
30609 // "I copied the key from a doc with smart quotes /
30610 // accented characters" footgun. Author must percent-
30611 // encode (the canonical-forms sweep covers
30612 // `"users/caf%C3%A9"`).
30613 ("ch\u{e9}ckout/$order", "non-ASCII"),
30614 ] {
30615 let err = is_wasi_keyvalue_slot(s)
30616 .err()
30617 .unwrap_or_else(|| panic!("kv slot {s:?} must be rejected"));
30618 assert!(
30619 err.contains(needle),
30620 "kv slot {s:?} reason must contain {needle:?}; got {err:?}"
30621 );
30622 }
30623 }
30624
30625 #[test]
30626 fn wasi_kv_slot_rejects_empty_defensively() {
30627 // The predicate is called from `WitContract::target()` only
30628 // after the per-axis `ContratoSlotEmpty` arm has fired at
30629 // validate time; re-checking here keeps the predicate usable
30630 // from any future call site without an empty-precondition
30631 // footgun. Same defensive empty-check `is_dns_1123_label`,
30632 // `is_gateway_api_http_path`, `is_wit_world_ref`, and
30633 // `is_nats_subject` carry at their call sites.
30634 let err = is_wasi_keyvalue_slot("").unwrap_err();
30635 assert!(err.contains("empty"), "got: {err:?}");
30636 }
30637
30638 #[test]
30639 fn wasi_kv_slot_rejects_at_513_byte_boundary() {
30640 // The 512-byte cap pin — both the boundary-exceeding case and
30641 // the boundary-accepting case in one place, so a future cap
30642 // shift surfaces both arms simultaneously, mirroring
30643 // `dns_1123_label_rejects_at_64_byte_boundary`,
30644 // `gateway_api_http_path_rejects_at_1025_byte_boundary`,
30645 // `wit_world_ref_rejects_at_129_byte_boundary`, and
30646 // `nats_subject_rejects_at_257_byte_boundary` on the peer
30647 // predicates. Constructed as a single all-`a` token (no
30648 // separator / template syntax) so only the cap arm fires.
30649 let max_ok = "a".repeat(512);
30650 assert_eq!(max_ok.len(), 512);
30651 is_wasi_keyvalue_slot(&max_ok).unwrap();
30652 let too_long = "a".repeat(513);
30653 assert_eq!(too_long.len(), 513);
30654 let err = is_wasi_keyvalue_slot(&too_long).unwrap_err();
30655 assert!(err.contains("512"), "got: {err:?}");
30656 assert!(err.contains("513"), "got: {err:?}");
30657 }
30658
30659 #[test]
30660 fn wasi_kv_slot_admits_full_printable_ascii_range() {
30661 // Structural pin: the predicate admits every printable ASCII
30662 // byte from `0x21` (`!`) to `0x7E` (`~`) inclusive, including
30663 // every template-variable bracket the documented authoring
30664 // patterns use (`$`, `{`, `}`, `<`, `>`) and every namespace
30665 // separator (`/`, `:`, `.`, `-`, `_`). Drift here = a future
30666 // tighten that removes any byte from the admitted set surfaces
30667 // a name-the-byte test failure, not piecemeal across per-axis
30668 // sweeps. Constructed as a single all-bytes template (`b!`,
30669 // `b"`, …, `b~`) — the predicate doesn't impose structure,
30670 // only character-class.
30671 for b in 0x21u8..=0x7E {
30672 let s = std::str::from_utf8(&[b]).unwrap().to_string();
30673 is_wasi_keyvalue_slot(&s)
30674 .unwrap_or_else(|e| panic!("printable ASCII byte 0x{b:02x} must pass: {e:?}"));
30675 }
30676 }
30677
30678 #[test]
30679 fn git_ref_name_accepts_canonical_forms() {
30680 // Substrate-side pin: the predicate accepts every canonical
30681 // refname the `:fonte :tag` / `:fonte :branch` axes carry in
30682 // realistic authoring patterns (each maps to a refname `git
30683 // fetch <remote> tag '<value>'` and `git checkout '<value>'`
30684 // resolve cleanly at clone time). Drift between this list and
30685 // any per-axis positive-set sweep surfaces here — one source
30686 // of truth for the rule. Includes:
30687 // - semver tag with `v` prefix (`"v0.1.0"`, the canonical
30688 // pleme-io release shape);
30689 // - bare semver tag (`"0.1.0"`, the npm / Cargo idiom);
30690 // - pre-release tag (`"v0.1.0-alpha.1"`);
30691 // - release-line tag with hyphens (`"release-1.0"`);
30692 // - leaf branch (`"main"` / `"master"`);
30693 // - hierarchical feature branch (`"feature/checkout"`);
30694 // - multi-component branch with hyphens and digits
30695 // (`"user-1/feat-x-v2"`);
30696 // - dot-bearing tag (`"v0.1.0.rc1"`, mid-component dot
30697 // allowed — only consecutive `..` and trailing `.` are
30698 // rejected).
30699 // Mirrors the canonical-forms sweeps on the peer value-shape
30700 // predicates (`wasi_kv_slot_accepts_canonical_forms`,
30701 // `nats_subject_accepts_canonical_forms`).
30702 for s in [
30703 "v0.1.0",
30704 "0.1.0",
30705 "v0.1.0-alpha.1",
30706 "release-1.0",
30707 "main",
30708 "master",
30709 "feature/checkout",
30710 "user-1/feat-x-v2",
30711 "v0.1.0.rc1",
30712 "stable",
30713 ] {
30714 is_git_ref_name(s)
30715 .unwrap_or_else(|e| panic!("canonical git ref {s:?} must pass: {e:?}"));
30716 }
30717 }
30718
30719 #[test]
30720 fn git_ref_name_rejects_each_arm_with_substring_pinned_reason() {
30721 // Substrate-side diagnostic-shape pin: each grammar arm
30722 // surfaces its own distinct reason substring. Pinned here so
30723 // a future reason-wording rephrase that drops any of these
30724 // substrings surfaces at this one place, not piecemeal across
30725 // every per-axis test sweep. Mirrors
30726 // `wasi_kv_slot_rejects_each_arm_with_substring_pinned_reason`
30727 // and `nats_subject_rejects_each_arm_with_substring_pinned_reason`
30728 // on the peer predicates.
30729 for (s, needle) in [
30730 // Trailing space — the canonical paste-from-doc footgun.
30731 ("v0.1.0 ", "whitespace"),
30732 // Embedded space (branch with spaces).
30733 ("feature/foo bar", "whitespace"),
30734 // Tab byte.
30735 ("v0.1.0\t", "whitespace"),
30736 // Newline — the canonical "paste-from-multiline-doc"
30737 // footgun. Distinct from the whitespace arm because `\n`
30738 // is a control character.
30739 ("v0.1.0\n", "control character"),
30740 // DEL byte (0x7F) — upper boundary of the control range.
30741 ("v0.1.0\x7f", "control character"),
30742 // Non-ASCII byte (the canonical "I copied the tag from a
30743 // doc with smart quotes" footgun).
30744 ("v0.1.0\u{e9}", "non-ASCII"),
30745 // Tilde — git's revision grammar (`HEAD~3`).
30746 ("v0.1.0~1", "`~`"),
30747 // Caret — git's revision grammar (`HEAD^`).
30748 ("v0.1.0^", "`^`"),
30749 // Colon — git's refspec separator.
30750 ("v0.1.0:rebase", "`:`"),
30751 // Question mark — git's refspec glob.
30752 ("v0.1.0?", "`?`"),
30753 // Asterisk — git's refspec glob.
30754 ("v0.1.*", "`*`"),
30755 // Open bracket — git's refspec glob.
30756 ("v0.1.0[1]", "`[`"),
30757 // Backslash — the canonical Windows-path-leak footgun.
30758 ("feature\\foo", "`\\`"),
30759 // Consecutive dots — git's `<rev1>..<rev2>` range grammar.
30760 ("v0.1..0", "`..`"),
30761 // Reflog grammar.
30762 ("main@{upstream}", "`@{`"),
30763 // The bare `@` — git aliases to `HEAD`.
30764 ("@", "bare `@`"),
30765 // Leading slash.
30766 ("/main", "begin with `/`"),
30767 // Trailing slash.
30768 ("feature/", "end with `/`"),
30769 // Consecutive slashes.
30770 ("feature//foo", "consecutive `/`"),
30771 // Trailing dot.
30772 ("v0.1.0.", "end with `.`"),
30773 // Fully-qualified branch ref — the canonical
30774 // `git show-ref`-output-leak footgun.
30775 ("refs/heads/main", "fully-qualified"),
30776 // Fully-qualified tag ref.
30777 ("refs/tags/v0.1.0", "fully-qualified"),
30778 // Component beginning with `.` (per-component rule).
30779 ("feature/.hidden", "begin with `.`"),
30780 // Component ending with `.lock` (per-component rule).
30781 ("feature/main.lock", "`.lock`"),
30782 // Leaf ref named `<x>.lock` — same per-component rule on
30783 // the single-component refname.
30784 ("main.lock", "`.lock`"),
30785 // Case-insensitive `.LOCK` — APFS / NTFS / HFS+ admit
30786 // both spellings as the same on-disk file, so a
30787 // `:tag "v1.LOCK"` collides with git's atomic-rename
30788 // guard on case-insensitive filesystems. Pinned
30789 // separately from the canonical lowercase arm so a
30790 // future relaxation that only catches lowercase
30791 // surfaces here.
30792 ("v1.LOCK", "`.lock`"),
30793 ("feature/Main.Lock", "`.lock`"),
30794 ] {
30795 let err = is_git_ref_name(s)
30796 .err()
30797 .unwrap_or_else(|| panic!("git ref {s:?} must be rejected"));
30798 assert!(
30799 err.contains(needle),
30800 "git ref {s:?} reason must contain {needle:?}; got {err:?}"
30801 );
30802 }
30803 }
30804
30805 #[test]
30806 fn git_ref_name_rejects_empty_defensively() {
30807 // The predicate is called from `DepSource::validate` only
30808 // after the per-axis `FontePinEmpty` arm has fired at
30809 // validate time; re-checking here keeps the predicate usable
30810 // from any future call site without an empty-precondition
30811 // footgun. Same defensive empty-check `is_dns_1123_label`,
30812 // `is_gateway_api_http_path`, `is_wit_world_ref`,
30813 // `is_nats_subject`, and `is_wasi_keyvalue_slot` carry at
30814 // their call sites.
30815 let err = is_git_ref_name("").unwrap_err();
30816 assert!(err.contains("empty"), "got: {err:?}");
30817 }
30818
30819 #[test]
30820 fn git_ref_name_rejects_at_256_byte_boundary() {
30821 // The 255-byte cap pin — both the boundary-exceeding case and
30822 // the boundary-accepting case in one place, so a future cap
30823 // shift surfaces both arms simultaneously, mirroring
30824 // `dns_1123_label_rejects_at_64_byte_boundary`,
30825 // `gateway_api_http_path_rejects_at_1025_byte_boundary`,
30826 // `wit_world_ref_rejects_at_129_byte_boundary`,
30827 // `nats_subject_rejects_at_257_byte_boundary`, and
30828 // `wasi_kv_slot_rejects_at_513_byte_boundary` on the peer
30829 // predicates. Constructed as a single all-`a` leaf so only
30830 // the cap arm fires.
30831 let max_ok = "a".repeat(255);
30832 assert_eq!(max_ok.len(), 255);
30833 is_git_ref_name(&max_ok).unwrap();
30834 let too_long = "a".repeat(256);
30835 assert_eq!(too_long.len(), 256);
30836 let err = is_git_ref_name(&too_long).unwrap_err();
30837 assert!(err.contains("255"), "got: {err:?}");
30838 assert!(err.contains("256"), "got: {err:?}");
30839 }
30840
30841 #[test]
30842 fn git_ref_name_qualified_prefix_diagnostic_quotes_leaf() {
30843 // Diagnostic-shape pin: the `refs/heads/` / `refs/tags/`
30844 // rejection arm enumerates the leaf the author probably
30845 // meant, so the author's grep target is the *intended*
30846 // refname literal rather than the (rejected) qualified form.
30847 // Pinned across both prefixes so a future relaxation that
30848 // drops the leaf-suggestion surfaces here.
30849 for (qualified, leaf) in [
30850 ("refs/heads/main", "main"),
30851 ("refs/tags/v0.1.0", "v0.1.0"),
30852 ("refs/heads/feature/checkout", "feature/checkout"),
30853 ] {
30854 let err = is_git_ref_name(qualified).unwrap_err();
30855 assert!(
30856 err.contains(&format!("{leaf:?}")),
30857 "qualified ref {qualified:?} diagnostic must quote the leaf \
30858 {leaf:?}; got {err:?}"
30859 );
30860 }
30861 }
30862
30863 // ── is_git_ref_name canonical-OID-shape partition arm ────────────────
30864
30865 #[test]
30866 fn git_ref_name_rejects_canonical_sha1_oid() {
30867 // The fail-before-pass-after pin on the canonical SHA-1 OID
30868 // partition arm: a 40-char lowercase-hex string is the shape
30869 // `is_git_oid` accepts, so `is_git_ref_name` must reject it.
30870 // Until this arm landed `is_git_ref_name` accepted every
30871 // 40-char lowercase-hex string (pure hex carries none of the
30872 // forbidden refname characters, no `..`/`@{`/`/`-prefix/
30873 // `/`-suffix/`.lock`-suffix/`refs/heads/`-prefix), silently
30874 // breaking the cross-axis partition the
30875 // [`DepSource::validate`] gate routes the `:fonte` axes
30876 // through and admitting `:tag "deadbeef…"` /
30877 // `:branch "deadbeef…"` as legitimate refnames — the
30878 // canonical paste-from-`git show --format=%H` mis-slot
30879 // footgun. The diagnostic names the `:rev` axis so the author
30880 // grep-fixes in one edit.
30881 for oid in [
30882 "0123456789abcdef0123456789abcdef01234567",
30883 "deadbeefcafebabe0123456789abcdef01234567",
30884 "ffffffffffffffffffffffffffffffffffffffff",
30885 "0000000000000000000000000000000000000000",
30886 ] {
30887 assert_eq!(oid.len(), GIT_OID_SHA1_LEN);
30888 let err = is_git_ref_name(oid).unwrap_err();
30889 assert!(
30890 err.contains("OID") && err.contains(":rev"),
30891 "canonical SHA-1 OID {oid:?} must surface a diagnostic \
30892 naming OID + `:rev`; got {err:?}"
30893 );
30894 assert!(
30895 err.contains("SHA-1"),
30896 "canonical SHA-1 OID {oid:?} diagnostic must name the \
30897 hash algorithm; got {err:?}"
30898 );
30899 }
30900 }
30901
30902 #[test]
30903 fn git_ref_name_rejects_canonical_sha256_oid() {
30904 // The fail-before-pass-after pin on the canonical SHA-256 OID
30905 // partition arm — Git 2.42+ `extensions.objectFormat = sha256`
30906 // mode. 64-char lowercase-hex strings are equally OID-shaped
30907 // and must surface the same `:rev`-axis diagnostic. Pinned
30908 // separately from SHA-1 so a future relaxation that only
30909 // catches one width surfaces here.
30910 let sha256_zeros = "0".repeat(GIT_OID_SHA256_LEN);
30911 let sha256_ones = "f".repeat(GIT_OID_SHA256_LEN);
30912 let sha256_mixed = format!("deadbeefcafebabe{}", "0123456789abcdef".repeat(3));
30913 for oid in [&sha256_zeros, &sha256_ones, &sha256_mixed] {
30914 assert_eq!(oid.len(), GIT_OID_SHA256_LEN);
30915 let err = is_git_ref_name(oid).unwrap_err();
30916 assert!(
30917 err.contains("OID") && err.contains(":rev"),
30918 "canonical SHA-256 OID {oid:?} must surface a \
30919 diagnostic naming OID + `:rev`; got {err:?}"
30920 );
30921 assert!(
30922 err.contains("SHA-256"),
30923 "canonical SHA-256 OID {oid:?} diagnostic must name \
30924 the hash algorithm; got {err:?}"
30925 );
30926 }
30927 }
30928
30929 #[test]
30930 fn git_ref_name_partition_excludes_off_by_one_lengths() {
30931 // Boundary pin: lengths that *aren't* exactly 40 or 64 hex
30932 // characters are NOT canonical OIDs, so the partition arm
30933 // must not fire — they remain accepted as refnames (consistent
30934 // with `is_git_oid` rejecting them on its exact-width check).
30935 // Abbreviated OIDs (`"c0ffee0"`, 7-char prefix) are ambiguous
30936 // across repository history and `is_git_oid` rejects them
30937 // separately, but they're legitimate refname shapes per `git
30938 // check-ref-format`, so `is_git_ref_name` accepts them here.
30939 // Pinned across the 39/41/63/65-char and abbreviated arms so
30940 // a future widening of the partition arm to "any hex-shaped
30941 // value" surfaces here as a regression rather than silently
30942 // rejecting valid refnames.
30943 for accept in [
30944 // 39 hex chars — one short of SHA-1 width.
30945 "0123456789abcdef0123456789abcdef0123456",
30946 // 41 hex chars — one over SHA-1 width.
30947 "0123456789abcdef0123456789abcdef012345670",
30948 // 63 hex chars — one short of SHA-256 width.
30949 &"a".repeat(63),
30950 // 65 hex chars — one over SHA-256 width.
30951 &"a".repeat(65),
30952 // Abbreviated 7-char SHA — the `git log --short` width.
30953 "c0ffee0",
30954 // Pure-numeric 8-char (looks vaguely SHA-shaped but
30955 // isn't canonical-width).
30956 "00000000",
30957 ] {
30958 is_git_ref_name(accept).unwrap_or_else(|e| {
30959 panic!(
30960 "off-canonical-width hex-shaped value {accept:?} \
30961 (len {len}) must still pass is_git_ref_name — \
30962 the partition arm is exact-width 40/64, not a \
30963 prefix or pattern: {e:?}",
30964 len = accept.len()
30965 )
30966 });
30967 }
30968 }
30969
30970 #[test]
30971 fn git_ref_name_partition_excludes_uppercase_canonical_widths() {
30972 // Boundary pin: the partition arm targets the canonical
30973 // *lowercase-hex* OID shape `git rev-parse HEAD` /
30974 // `git show --format=%H` emit. Uppercase or mixed-case
30975 // 40/64-char hex strings are legitimate refnames per
30976 // `git check-ref-format` (uppercase letters are admitted in
30977 // refnames), so `is_git_ref_name` accepts them here; the
30978 // `:rev` axis separately rejects uppercase OIDs via
30979 // [`is_git_oid`]'s lowercase-only contract — so neither
30980 // axis silently admits an uppercase-hex value cross-slot.
30981 // Pinned across both widths + both uppercase variants so a
30982 // future relaxation of either predicate surfaces here.
30983 for accept in [
30984 // Uppercase 40-char hex — passes is_git_ref_name (valid
30985 // refname), rejected by is_git_oid on lowercase contract.
30986 "DEADBEEFCAFEBABE0123456789ABCDEF01234567",
30987 // Mixed case 40-char hex.
30988 "DeadBeefCafeBabe0123456789abcdef01234567",
30989 // Uppercase 64-char hex.
30990 &"A".repeat(64),
30991 ] {
30992 is_git_ref_name(accept).unwrap_or_else(|e| {
30993 panic!(
30994 "uppercase canonical-width hex value {accept:?} \
30995 must still pass is_git_ref_name — the partition \
30996 arm targets lowercase-canonical only (uppercase \
30997 is a legitimate refname character per \
30998 git-check-ref-format); the `:rev` axis catches \
30999 uppercase via is_git_oid's lowercase contract: \
31000 {e:?}"
31001 )
31002 });
31003 // And confirm is_git_oid rejects it on the lowercase arm
31004 // (so neither axis silently admits the value).
31005 let oid_err = is_git_oid(accept).unwrap_err();
31006 assert!(
31007 oid_err.contains("lowercase") || oid_err.contains("uppercase"),
31008 "uppercase hex value {accept:?} must be rejected by \
31009 is_git_oid on its lowercase contract; got {oid_err:?}"
31010 );
31011 }
31012 }
31013
31014 #[test]
31015 fn git_ref_name_partition_arm_fires_before_per_byte_scan() {
31016 // Order pin: the partition arm runs after the length check
31017 // but before the per-byte refname-character scan, so a
31018 // canonical-OID-shaped value surfaces the `:rev`-axis
31019 // diagnostic rather than (e.g.) falling through to a generic
31020 // per-component arm. Pinned via a canonical OID — pure hex
31021 // can't violate any of the per-byte / `..` / `@{` / `/` /
31022 // `.lock` / `refs/heads/` arms (which is precisely why the
31023 // partition arm is needed), so position-wise this pin
31024 // forecloses a future refactor that splits the partition arm
31025 // across the scan (where uppercase / mixed-case canonical-
31026 // width values would silently route through one branch).
31027 let oid = "0123456789abcdef0123456789abcdef01234567";
31028 let err = is_git_ref_name(oid).unwrap_err();
31029 // The diagnostic mentions OID + `:rev`; it does NOT contain
31030 // any of the per-byte-arm needle substrings the
31031 // `git_ref_name_rejects_each_arm_with_substring_pinned_reason`
31032 // sweep pins, structurally — canonical OIDs can't violate
31033 // those arms.
31034 assert!(err.contains("OID"), "got: {err:?}");
31035 assert!(err.contains(":rev"), "got: {err:?}");
31036 }
31037
31038 #[test]
31039 fn git_ref_name_rejects_leading_hyphen_cli_arg_injection() {
31040 // The CLI-arg-injection arm pin on the `:tag` / `:branch` axis.
31041 // Git's `check-ref-format` grammar admits a leading `-` (the
31042 // byte is a legitimate kebab continuation), so every prior
31043 // shape arm passes the value through; the diagnostic moves
31044 // the gate to the subprocess-argument boundary the resolver
31045 // consumes. Pinned across the canonical CLI-arg-injection
31046 // shapes — short-flag-shaped `"-X"`, long-option-shaped
31047 // `"-stable"`, git-config-injection-shaped
31048 // `"-c=core.merge=ours"`, the canonical
31049 // `"--upload-pack=…"` long-flag form, and the
31050 // `"--config"`-shape repeat-arg form — every shape would
31051 // silently escape `git checkout --quiet --detach <ref>` (the
31052 // resolver's invocation in `caixa-resolver/src/git.rs:41`,
31053 // no `--` argument-list terminator) and get reinterpreted by
31054 // `git checkout`'s argument parser. Peer with the
31055 // `is_git_repo_url` leading-`-` arm (same vector on the
31056 // sibling `:repo` axis), `is_cargo_feature_name` leading-`-`
31057 // arm, and `is_dns_1123_label` leading-`-` arm — the
31058 // substrate-wide "no leading `-` anywhere in a typed
31059 // single-token string slot routed through a subprocess
31060 // argument" invariant is now structurally consistent across
31061 // every value-shape-gated typed surface.
31062 for s in [
31063 "-X", // short-flag-shape
31064 "-stable", // long-option-shape
31065 "-c=core.merge=ours", // git-config-injection-shape
31066 "--upload-pack=cat /etc", // long-flag with-value
31067 "--config", // repeat-arg shape
31068 "-", // degenerate single-byte
31069 ] {
31070 let err = is_git_ref_name(s)
31071 .err()
31072 .unwrap_or_else(|| panic!("git ref {s:?} must be rejected"));
31073 assert!(
31074 err.contains("`-`"),
31075 "git ref {s:?} reason must surface the leading-`-` arm: {err:?}"
31076 );
31077 assert!(
31078 err.contains("CLI-argument-injection"),
31079 "git ref {s:?} reason must name the CLI-argument-injection \
31080 vector: {err:?}"
31081 );
31082 }
31083 // Positive control: a mid-name `-` (the canonical kebab
31084 // separator) passes — `"v0-1-0"`, `"feature-x"`, `"main-2"`
31085 // — pinning that the arm only fires at the leading position,
31086 // not anywhere else.
31087 for s in ["v0-1-0", "feature-x", "main-2"] {
31088 is_git_ref_name(s).unwrap_or_else(|e| {
31089 panic!("mid-name `-` ref {s:?} must pass the leading-`-` arm: {e:?}")
31090 });
31091 }
31092 }
31093
31094 #[test]
31095 fn git_ref_name_leading_hyphen_fires_before_per_byte_scan() {
31096 // Cascade-precedence pin: a `"-flag\n"` value carries both a
31097 // leading `-` and an embedded `\n` control byte; the leading-`-`
31098 // arm fires first (the byte sits at the leading position the
31099 // arm probes, before the per-byte cascade loop's control-byte
31100 // arm). Mirrors the order pin
31101 // `git_ref_name_partition_arm_fires_before_per_byte_scan`
31102 // establishes on the canonical-OID partition arm — both
31103 // pre-loop arms structurally precede the per-byte scan.
31104 let err = is_git_ref_name("-flag\n").unwrap_err();
31105 assert!(err.contains("`-`"), "got: {err:?}");
31106 assert!(
31107 !err.contains("control character"),
31108 "leading-`-` arm must fire before the control-byte per-byte arm: {err:?}"
31109 );
31110 }
31111
31112 #[test]
31113 fn git_ref_name_leading_hyphen_fires_after_canonical_oid_partition() {
31114 // Cascade-precedence pin: the partition arm structurally
31115 // precedes the leading-`-` arm because a canonical OID shape
31116 // (40 / 64 lowercase hex bytes) cannot start with `-` — the
31117 // byte sets are disjoint, so the precedence pin is a no-op at
31118 // value level. The pin matters only at the diagnostic-shape
31119 // level — it ensures a future codec round-trip that
31120 // synthesizes a probe-as-both value (impossible today;
31121 // possible if the OID partition arm ever relaxes its byte
31122 // set) surfaces the more self-locating `:rev`-mis-slot
31123 // diagnostic rather than the broader CLI-arg-injection one.
31124 let oid = "0123456789abcdef0123456789abcdef01234567";
31125 let err = is_git_ref_name(oid).unwrap_err();
31126 assert!(err.contains("OID"), "got: {err:?}");
31127 assert!(
31128 !err.contains("CLI-argument-injection"),
31129 "OID partition arm must precede leading-`-` arm: {err:?}"
31130 );
31131 }
31132
31133 // ── is_git_oid — `:fonte :rev` value-shape predicate ────────────────
31134
31135 #[test]
31136 fn git_oid_canonical_widths_match_sha1_and_sha256() {
31137 // The single-source-of-truth pin on the two canonical widths.
31138 // Drift between the predicate's accepted widths and the const
31139 // values would surface here as a build error, not as a silent
31140 // round-trip break at the renderer layer. Mirrors
31141 // `wasm32_memory_cap_matches_parsed_4_gib` (9d49a3a) — the
31142 // constant equality pin keeps the contract one place.
31143 assert_eq!(GIT_OID_SHA1_LEN, 40);
31144 assert_eq!(GIT_OID_SHA256_LEN, 64);
31145 // Doubled width: SHA-256 is exactly twice SHA-1 in hex char
31146 // count (256 / 4 = 64; 160 / 4 = 40). Pinned so a future
31147 // hash-algorithm widening reads the relationship here.
31148 assert_eq!(GIT_OID_SHA256_LEN, GIT_OID_SHA1_LEN * 2 - 16);
31149 }
31150
31151 #[test]
31152 fn git_oid_accepts_canonical_sha1() {
31153 // Positive control on the SHA-1 OID width: 40 lowercase hex
31154 // characters — the canonical `git rev-parse HEAD` emission
31155 // shape every realistic pleme-io upstream uses today. The all-
31156 // `f` boundary is the lexicographically-largest OID (a real
31157 // commit's hash could land here, and the predicate accepts it
31158 // because it's structurally a valid OID — the null-OID
31159 // sentinel arm partitions the all-`0` boundary only, not the
31160 // all-`f` one).
31161 is_git_oid("0123456789abcdef0123456789abcdef01234567").unwrap();
31162 is_git_oid("deadbeefcafebabe0123456789abcdef01234567").unwrap();
31163 is_git_oid("ffffffffffffffffffffffffffffffffffffffff").unwrap();
31164 }
31165
31166 #[test]
31167 fn git_oid_accepts_canonical_sha256() {
31168 // Positive control on the SHA-256 OID width: 64 lowercase hex
31169 // characters — `git`'s `extensions.objectFormat = sha256`
31170 // emission (GA since Git 2.42 / Oct 2023). Doubled SHA-1 width.
31171 let sha256_one = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
31172 assert_eq!(sha256_one.len(), 64);
31173 is_git_oid(sha256_one).unwrap();
31174 let sha256_fs = "f".repeat(64);
31175 is_git_oid(&sha256_fs).unwrap();
31176 }
31177
31178 #[test]
31179 fn git_oid_rejects_null_oid_sentinel_sha1() {
31180 // Canonical "I copy-pasted the no-such-commit sentinel out of
31181 // `git update-ref --stdin` docs / pre-receive hook example"
31182 // footgun on the SHA-1 width — the all-zero 40-char hex
31183 // string is git's `null OID` sentinel (used to indicate ref
31184 // create / delete in update-ref flows) and never names a real
31185 // commit in any repo's object database. Until the null-OID
31186 // arm landed it passed every other shape arm (canonical
31187 // length, lowercase hex) and surfaced at `git fetch <remote>
31188 // 0000…0000` time with a quoting-confused "couldn't find
31189 // remote ref" error far from the source caixa.lisp, with the
31190 // lacre's content-address locked to a `git:0000…0000` closure
31191 // that never equals any upstream's actual `HEAD`. The
31192 // diagnostic carries the `40` width verbatim so a future
31193 // SHA-256 fixture surfaces the same arm at the doubled width
31194 // boundary.
31195 let null_sha1 = "0".repeat(40);
31196 let err = is_git_oid(&null_sha1).unwrap_err();
31197 assert!(
31198 err.contains("null-OID sentinel"),
31199 "reason must name the sentinel: {err}",
31200 );
31201 assert!(err.contains("40"), "reason must name the width: {err}",);
31202 assert!(
31203 err.contains("no-such-commit") || err.contains("update-ref"),
31204 "reason must reference git's null-OID semantics: {err}",
31205 );
31206 }
31207
31208 #[test]
31209 fn git_oid_rejects_null_oid_sentinel_sha256() {
31210 // Same sentinel on the SHA-256 width — `git`'s
31211 // `extensions.objectFormat = sha256` mode (GA Git 2.42 / Oct
31212 // 2023) carries the same null-OID semantics on the doubled
31213 // 64-char width. Pinned separately so a future relaxation that
31214 // only catches the SHA-1 width surfaces here, peer with the
31215 // SHA-1 / SHA-256 pair-pinning posture
31216 // `git_oid_accepts_canonical_sha1` /
31217 // `git_oid_accepts_canonical_sha256` already establishes for
31218 // the positive controls.
31219 let null_sha256 = "0".repeat(64);
31220 let err = is_git_oid(&null_sha256).unwrap_err();
31221 assert!(
31222 err.contains("null-OID sentinel"),
31223 "reason must name the sentinel: {err}",
31224 );
31225 assert!(err.contains("64"), "reason must name the width: {err}",);
31226 }
31227
31228 #[test]
31229 fn git_oid_null_oid_fires_after_length_and_hex_arms() {
31230 // Cascade-precedence pin: the null-OID arm runs *after* the
31231 // length + character-class arms, so an off-by-one-length all-
31232 // zeros value surfaces the narrower `abbreviated` diagnostic
31233 // (the length arm's own reason wording) before the structural
31234 // null-OID diagnostic, and an uppercase all-zeros value (which
31235 // can't actually exist — `0` has no case — but pinned via the
31236 // mixed-case-but-non-null fixture) routes the same way. The
31237 // null-OID arm is the *fourth* arm, structurally the
31238 // lexicographic-content-arm after length and per-byte
31239 // character-class.
31240 let off_by_one_zeros = "0".repeat(41);
31241 let err = is_git_oid(&off_by_one_zeros).unwrap_err();
31242 assert!(
31243 err.contains("abbreviated"),
31244 "off-by-one-length all-zeros surfaces length arm first: {err}",
31245 );
31246 // The all-`f` 40-char value — same boundary class as null-OID
31247 // but at the opposite hex extreme — passes the predicate,
31248 // confirming the null-OID arm doesn't over-fire on lexicographic
31249 // boundaries.
31250 is_git_oid("ffffffffffffffffffffffffffffffffffffffff").unwrap();
31251 }
31252
31253 #[test]
31254 fn git_oid_rejects_empty_defensively() {
31255 // The predicate is called from `crate::dep::DepSource::validate`
31256 // only after the per-axis `FontePinEmpty` arm has fired at
31257 // validate time; re-checking here keeps the predicate usable
31258 // from any future call site without an empty-precondition
31259 // footgun. Same defensive empty-check `is_dns_1123_label`,
31260 // `is_gateway_api_http_path`, `is_wit_world_ref`,
31261 // `is_nats_subject`, `is_wasi_keyvalue_slot`, and
31262 // `is_git_ref_name` carry at their call sites.
31263 let err = is_git_oid("").unwrap_err();
31264 assert!(err.contains("empty"), "got: {err:?}");
31265 }
31266
31267 #[test]
31268 fn git_oid_rejects_each_arm_with_substring_pinned_reason() {
31269 // Substrate-side diagnostic-shape pin: each grammar arm
31270 // surfaces its own distinct reason substring. Pinned here so a
31271 // future reason-wording rephrase that drops any of these
31272 // substrings surfaces at this one place, not piecemeal across
31273 // every per-axis test sweep. Mirrors
31274 // `git_ref_name_rejects_each_arm_with_substring_pinned_reason`,
31275 // `wasi_kv_slot_rejects_each_arm_with_substring_pinned_reason`,
31276 // and `nats_subject_rejects_each_arm_with_substring_pinned_reason`
31277 // on the peer predicates.
31278 for (s, needle) in [
31279 // Abbreviated 7-char prefix — the canonical `git log
31280 // --short` paste-from-release-notes footgun.
31281 ("c0ffee0", "abbreviated"),
31282 // Abbreviated 12-char prefix — `git log --short=12`.
31283 ("c0ffee001234", "abbreviated"),
31284 // Off-by-one above SHA-1 width.
31285 ("0123456789abcdef0123456789abcdef012345670", "abbreviated"),
31286 // Off-by-one below SHA-256 width.
31287 (
31288 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde",
31289 "abbreviated",
31290 ),
31291 // Off-by-one above SHA-256 width.
31292 (
31293 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0",
31294 "abbreviated",
31295 ),
31296 // Uppercase SHA-1 — `git porcelain` lowercases on output.
31297 ("DEADBEEFCAFEBABE0123456789ABCDEF01234567", "uppercase"),
31298 // Mixed-case SHA-1 — same path as pure-uppercase; the first
31299 // uppercase byte fires the arm.
31300 ("deadbeefCAFEbabe0123456789abcdef01234567", "uppercase"),
31301 // Non-hex character at exact SHA-1 length — the cross-axis
31302 // mis-slot footgun (a refname-style char landing in `:rev`).
31303 // `g` is the first non-hex byte; the non-hex arm fires
31304 // ahead of any other rule. The hyphen / colon / slash arms
31305 // are the same path on the same predicate.
31306 ("g123456789abcdef0123456789abcdef01234567", "non-hex"),
31307 ("0123456789abcdef-123456789abcdef01234567", "non-hex"),
31308 ("0123456789abcdef/123456789abcdef01234567", "non-hex"),
31309 ("0123456789abcdef:123456789abcdef01234567", "non-hex"),
31310 // Whitespace inside an otherwise-SHA-shaped value (length
31311 // 41 — fails the length arm first; pinned to ensure the
31312 // diagnostic surfaces *some* parser wording).
31313 ("0123456789abcdef0123456789abcdef01234567 ", "abbreviated"),
31314 ] {
31315 let err = is_git_oid(s)
31316 .err()
31317 .unwrap_or_else(|| panic!("git OID {s:?} must be rejected"));
31318 assert!(
31319 err.contains(needle),
31320 "git OID {s:?} reason must contain {needle:?}; got {err:?}"
31321 );
31322 }
31323 }
31324
31325 #[test]
31326 fn git_oid_rejects_at_canonical_width_boundaries() {
31327 // Boundary pin on the two canonical widths simultaneously: 39
31328 // (below SHA-1), 40 (SHA-1 exactly), 41 (just above), 63 (just
31329 // below SHA-256), 64 (SHA-256 exactly), 65 (just above). Pinned
31330 // so a future relaxation that admits "close enough" widths
31331 // surfaces here. The failing-length fixtures use all-zero hex
31332 // so only the length arm fires (the null-OID sentinel arm is
31333 // structurally downstream of the length arm — a non-canonical
31334 // length fires the abbreviated diagnostic before the null
31335 // diagnostic). The passing-length fixtures use a non-null hex
31336 // value so the null-OID arm doesn't fire (the all-zero
31337 // canonical-width value is the sentinel and is rejected by its
31338 // own arm, pinned in `git_oid_rejects_null_oid_sentinel_*`).
31339 let nonzero_sha1 = "0123456789abcdef0123456789abcdef01234567";
31340 assert_eq!(nonzero_sha1.len(), 40);
31341 let nonzero_sha256 = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
31342 assert_eq!(nonzero_sha256.len(), 64);
31343 for (len, ok) in [
31344 (1usize, false),
31345 (7, false),
31346 (39, false),
31347 (40, true),
31348 (41, false),
31349 (63, false),
31350 (64, true),
31351 (65, false),
31352 (128, false),
31353 ] {
31354 let s = if ok && len == 40 {
31355 nonzero_sha1.to_string()
31356 } else if ok && len == 64 {
31357 nonzero_sha256.to_string()
31358 } else {
31359 "0".repeat(len)
31360 };
31361 let result = is_git_oid(&s);
31362 if ok {
31363 result.unwrap_or_else(|e| panic!("len {len} must pass: {e:?}"));
31364 } else {
31365 let err = result.expect_err(&format!("len {len} must fail"));
31366 assert!(
31367 err.contains("abbreviated") || err.contains(&len.to_string()),
31368 "len {len} reason must name the offending length or surface \
31369 the abbreviation arm, got {err:?}"
31370 );
31371 }
31372 }
31373 }
31374
31375 #[test]
31376 fn git_oid_rejection_is_disjoint_from_ref_name_acceptance() {
31377 // Structural pin: the two predicates partition the `:fonte`
31378 // pin axes — every canonical refname is rejected by
31379 // `is_git_oid`, and every canonical OID is rejected by
31380 // `is_git_ref_name`. The intersection of the two valid sets
31381 // is exactly the empty set. Drift here = a value that passes
31382 // both predicates would land at *both* axes silently, defeating
31383 // the structural "cross-axis mis-slot is a build error"
31384 // contract. Pinned with a representative cross-set so a future
31385 // predicate weakening surfaces here.
31386 let canonical_refnames = [
31387 "v0.1.0",
31388 "main",
31389 "feature/checkout",
31390 "release-1.0",
31391 "user-1/feat-x-v2",
31392 ];
31393 for refname in canonical_refnames {
31394 is_git_ref_name(refname).unwrap_or_else(|e| {
31395 panic!("setup: canonical refname {refname:?} must pass is_git_ref_name: {e:?}")
31396 });
31397 assert!(
31398 is_git_oid(refname).is_err(),
31399 "canonical refname {refname:?} must NOT pass is_git_oid \
31400 (predicate-partition pin)"
31401 );
31402 }
31403 let canonical_oids = [
31404 "0123456789abcdef0123456789abcdef01234567",
31405 "deadbeefcafebabe0123456789abcdef01234567",
31406 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
31407 ];
31408 for oid in canonical_oids {
31409 is_git_oid(oid).unwrap_or_else(|e| {
31410 panic!("setup: canonical OID {oid:?} must pass is_git_oid: {e:?}")
31411 });
31412 assert!(
31413 is_git_ref_name(oid).is_err(),
31414 "canonical OID {oid:?} must NOT pass is_git_ref_name \
31415 (predicate-partition pin)"
31416 );
31417 }
31418 }
31419
31420 // ── is_sandboxed_relative_path — `:behavior :on-*` + `:upgrade-from ─
31421 // ── :state-change :script` value-shape predicate ────────────────────
31422
31423 #[test]
31424 fn sandboxed_relative_path_accepts_canonical_relative_paths() {
31425 // Positive controls: every documented authoring shape across
31426 // the two existing call sites (`:behavior :on-init` / `:on-call`
31427 // / `:on-cast` / `:on-info` / `:on-state-change` / `:on-terminate`
31428 // and `:upgrade-from :state-change :script`) — bare filename,
31429 // standard `lib/` subdirectory, deeply-nested migrations
31430 // subdirectory, sibling-folder-shaped path, and explicit
31431 // current-dir-relative-prefixed path. Pin every leg so a
31432 // future tightening that rejects any of these (e.g. demanding
31433 // a `lib/` prefix specifically, or forbidding the explicit
31434 // `./` segment) surfaces here as a test-failure at the predicate
31435 // boundary, not piecemeal across per-axis call sites.
31436 for relpath in [
31437 "init.lisp",
31438 "lib/init.lisp",
31439 "lib/handlers.lisp",
31440 "lib/migrations/v01-to-v02.lisp",
31441 "callbacks/on_call.lisp",
31442 "./lib/init.lisp",
31443 "a",
31444 ] {
31445 is_sandboxed_relative_path(Path::new(relpath)).unwrap_or_else(|v| {
31446 panic!("canonical relative path {relpath:?} must pass, got {v:?}")
31447 });
31448 }
31449 }
31450
31451 #[test]
31452 fn sandboxed_relative_path_rejects_empty() {
31453 // The fail-before-pass-after pin on the empty arm. Both
31454 // `PathBuf::new()` (no bytes) and `PathBuf::from("")` (empty
31455 // string) hit the `as_os_str().is_empty()` precondition; both
31456 // resolve to `root` under `root.join(p)` and silently point the
31457 // `LisleLoader` at the project directory rather than a file.
31458 assert_eq!(
31459 is_sandboxed_relative_path(Path::new("")),
31460 Err(PathShapeViolation::Empty)
31461 );
31462 let blank = PathBuf::new();
31463 assert_eq!(
31464 is_sandboxed_relative_path(&blank),
31465 Err(PathShapeViolation::Empty)
31466 );
31467 }
31468
31469 #[test]
31470 fn sandboxed_relative_path_rejects_absolute() {
31471 // The fail-before-pass-after pin on the absolute arm. Sweep
31472 // the canonical sandbox-escape paste-from-shell-prompt
31473 // footguns: an `/etc/...` Lunatic-style sandbox bypass, a
31474 // user-home leak that the renderer's `root.join(p)` would
31475 // silently replace, the project-relative-shaped `/lib/...`
31476 // typo where the author meant `lib/...` without a leading
31477 // slash, and the bare root `/`. `Path::join` replaces the
31478 // base with an absolute right-hand side, so every one of
31479 // these resolves verbatim to outside the caixa root regardless
31480 // of where the layout checker rooted itself.
31481 for abs in [
31482 "/etc/passwd",
31483 "/home/user/escape.lisp",
31484 "/lib/init.lisp",
31485 "/",
31486 ] {
31487 assert_eq!(
31488 is_sandboxed_relative_path(Path::new(abs)),
31489 Err(PathShapeViolation::Absolute),
31490 "absolute path {abs:?} must surface as PathShapeViolation::Absolute"
31491 );
31492 }
31493 }
31494
31495 #[test]
31496 fn sandboxed_relative_path_rejects_parent_escape_at_every_position() {
31497 // The fail-before-pass-after pin on the parent-escape arm.
31498 // Position sweep — `..` as a leading component (the canonical
31499 // "I meant the sibling caixa" mis-author), as a mid-path
31500 // component (the canonical "lib/../../escape" path-traversal
31501 // that's structurally identical regardless of how many `..`
31502 // segments stack), as a trailing component (lib/.., resolving
31503 // to the project root via a delayed escape), and the bare `..`
31504 // (project parent directory). Each must surface as
31505 // `PathShapeViolation::ParentEscape` regardless of position —
31506 // pinned per-position so a future relaxation that only
31507 // checks one position surfaces at this one place, not
31508 // piecemeal across per-axis call sites.
31509 for escape in [
31510 "../sibling/init.lisp",
31511 "lib/../../escaped.lisp",
31512 "lib/..",
31513 "..",
31514 "lib/handlers/../../escape.lisp",
31515 ] {
31516 assert_eq!(
31517 is_sandboxed_relative_path(Path::new(escape)),
31518 Err(PathShapeViolation::ParentEscape),
31519 "parent-escape path {escape:?} must surface as \
31520 PathShapeViolation::ParentEscape"
31521 );
31522 }
31523 }
31524
31525 #[test]
31526 fn sandboxed_relative_path_arm_ordering_is_empty_absolute_parent_escape() {
31527 // Order pin: the predicate evaluates Empty → Absolute →
31528 // ParentEscape — the same arm-ordering both inlined call sites
31529 // followed verbatim (b0c8389 `BehaviorSpec::validate`'s
31530 // `validate_callback_path`, 26da2c7
31531 // `UpgradeInstruction::StateChange::validate`). A future
31532 // reordering would silently flip which diagnostic the per-axis
31533 // wrapper surfaces (e.g. an absolute-and-empty hybrid value
31534 // would suddenly raise `Absolute` instead of `Empty`). Pinned
31535 // here so a future reorder surfaces at the predicate boundary.
31536 //
31537 // The empty case can't *also* be absolute (empty paths are
31538 // relative-by-construction) or parent-escaping, so the
31539 // empty-first ordering only matters relative to the OS-string
31540 // emptiness check vs. the absolute-prefix check. Pin the two
31541 // legs that *can* compose: an absolute path with `..` segments
31542 // must raise `Absolute` (not `ParentEscape`); an absolute-but-
31543 // not-parent-escaping path must also raise `Absolute`. The
31544 // arm-ordering pin is structural — every parent-escape case
31545 // tested above is relative, so the ParentEscape arm is reached
31546 // only when both Empty and Absolute arms have been cleared.
31547 assert_eq!(
31548 is_sandboxed_relative_path(Path::new("/etc/../passwd")),
31549 Err(PathShapeViolation::Absolute),
31550 "absolute path with `..` segments must surface as Absolute (not \
31551 ParentEscape) — Empty → Absolute → ParentEscape arm-ordering pin"
31552 );
31553 }
31554
31555 #[test]
31556 fn sandboxed_relative_path_distinguishes_curdir_from_parent_escape() {
31557 // Boundary pin: `Component::CurDir` (`.`) is NOT a sandbox
31558 // escape — `root.join("./lib/x.lisp")` resolves to
31559 // `root/lib/x.lisp`, identical to `root.join("lib/x.lisp")`,
31560 // so `./` segments must pass the predicate. The arm-ordering
31561 // check above pins that `Component::ParentDir` is the only
31562 // escape vector caught here. Pinned separately so a future
31563 // tightening that *does* reject `.` segments (e.g. requiring
31564 // canonical normalized form) lands at this one predicate.
31565 is_sandboxed_relative_path(Path::new("./lib/init.lisp")).unwrap();
31566 is_sandboxed_relative_path(Path::new("lib/./handlers.lisp")).unwrap();
31567 }
31568
31569 #[test]
31570 fn sandboxed_relative_path_violations_are_distinct_variants() {
31571 // Diagnostic-shape pin: the three `PathShapeViolation` variants
31572 // are distinct enum tags so each per-axis caller can match-and-
31573 // wrap into its own typed `*Path` / `*Script` variant without
31574 // a string-parse step (the trap [`is_dns_1123_label`] etc.
31575 // avoid by returning `Result<(), String>` — but the path-shape
31576 // callers were already split three ways across `BehaviorError`
31577 // / `UpgradeError`, so a `String` return would *regress* the
31578 // diagnostic shape rather than preserve it). The PartialEq /
31579 // Copy / Hash derives on `PathShapeViolation` are pinned here
31580 // so a future API rework reads the requirement off this test.
31581 let v1 = PathShapeViolation::Empty;
31582 let v2 = PathShapeViolation::Absolute;
31583 let v3 = PathShapeViolation::ParentEscape;
31584 assert_ne!(v1, v2);
31585 assert_ne!(v2, v3);
31586 assert_ne!(v1, v3);
31587 // Copy + Eq round-trip: predicate consumers like
31588 // `BehaviorSpec::validate` and `UpgradeInstruction::validate`
31589 // pattern-match on the variant without consuming it.
31590 let v_copy = v1;
31591 assert_eq!(v1, v_copy);
31592 }
31593
31594 #[test]
31595 fn sandboxed_relative_path_matches_inlined_call_site_semantics() {
31596 // End-to-end pin: every value the two pre-lift inline gates
31597 // (`BehaviorSpec::validate_callback_path` and
31598 // `UpgradeInstruction::StateChange::validate`'s inline arms)
31599 // accepted-or-rejected must surface from the lifted predicate
31600 // with identically-classified violation tags. Drift here would
31601 // mean a previously-accepted authoring shape would suddenly
31602 // fail (or vice versa) silently across the lift commit. Pinned
31603 // by sweeping the canonical authoring shapes both pre-lift call
31604 // sites' tests cover.
31605 // Pre-lift accepts (must still pass):
31606 for accept in [
31607 "lib/init.lisp",
31608 "lib/handlers.lisp",
31609 "lib/migrations.lisp",
31610 "lib/cleanup.lisp",
31611 "lib/migrations/v01-to-v02.lisp",
31612 "callbacks/handle_call.lisp",
31613 ] {
31614 is_sandboxed_relative_path(Path::new(accept))
31615 .unwrap_or_else(|v| panic!("pre-lift accept {accept:?} regressed, got {v:?}"));
31616 }
31617 // Pre-lift rejects (must still reject, with the same tag):
31618 let cases: &[(&str, PathShapeViolation)] = &[
31619 ("", PathShapeViolation::Empty),
31620 ("/etc/passwd", PathShapeViolation::Absolute),
31621 ("/etc/migrations.lisp", PathShapeViolation::Absolute),
31622 (
31623 "../sibling/migrations.lisp",
31624 PathShapeViolation::ParentEscape,
31625 ),
31626 ("lib/../../escaped.lisp", PathShapeViolation::ParentEscape),
31627 ];
31628 for (reject, expected) in cases {
31629 assert_eq!(
31630 is_sandboxed_relative_path(Path::new(reject)).unwrap_err(),
31631 *expected,
31632 "pre-lift reject {reject:?} must classify as {expected:?}"
31633 );
31634 }
31635 }
31636
31637 #[test]
31638 fn path_shape_violation_all_lists_every_variant_in_declaration_order() {
31639 // Fail-before-pass-after pin on the paired
31640 // [`PathShapeViolation::ALL`] exhaustive-iteration surface.
31641 // Two axes in one assertion, both must hold:
31642 //
31643 // (1) The slice enumerates every arm in the closed
31644 // three-arm discriminator set exactly once, in
31645 // declaration order (`Empty` → `Absolute` →
31646 // `ParentEscape`) — the arm-ordering the
31647 // [`is_sandboxed_relative_path`] gate + every per-axis
31648 // caller in [`crate::manifest::ManifestError`] preserve
31649 // for diagnostic-precedence continuity. A future variant
31650 // addition (a `Symlink` arm the future symlink-escape
31651 // gate would raise, a `TrailingSpace` arm a future
31652 // whitespace-hygiene gate would surface) that lands on
31653 // the enum without extending `ALL` trips this test at
31654 // build time rather than surfacing as a silent
31655 // under-coverage across every downstream sweep.
31656 //
31657 // (2) For every arm in the slice, exactly one of the
31658 // [`gen_platform::IsVariant`]-derive-generated `is_*`
31659 // predicates returns `true` and the other two return
31660 // `false` — the partition property every peer closed-set
31661 // enum's `IsVariant` derive carries
31662 // ([`crate::CaixaKind`] at kind.rs,
31663 // [`crate::supervisor::RestartStrategy`] +
31664 // [`crate::supervisor::RestartPolicy`] at supervisor.rs,
31665 // [`crate::upgrade::UpgradeInstruction`] at upgrade.rs,
31666 // [`crate::aplicacao::PlacementStrategy`] +
31667 // [`crate::aplicacao::RateLimitUnit`] at aplicacao.rs,
31668 // [`crate::dep::DepList`] at dep.rs). A future variant
31669 // addition that lands on the enum without threading a
31670 // new column into the per-arm-partition assertion table
31671 // trips here at build time.
31672 assert_eq!(
31673 PathShapeViolation::ALL,
31674 &[
31675 PathShapeViolation::Empty,
31676 PathShapeViolation::Absolute,
31677 PathShapeViolation::ParentEscape,
31678 ],
31679 "PathShapeViolation::ALL must list every arm in \
31680 declaration order (Empty → Absolute → ParentEscape) — \
31681 the arm-ordering is_sandboxed_relative_path and every \
31682 per-axis ManifestError caller preserve for \
31683 diagnostic-precedence continuity"
31684 );
31685 let rows: [(PathShapeViolation, [bool; 3]); 3] = [
31686 (PathShapeViolation::Empty, [true, false, false]),
31687 (PathShapeViolation::Absolute, [false, true, false]),
31688 (PathShapeViolation::ParentEscape, [false, false, true]),
31689 ];
31690 for (variant, expected) in rows {
31691 let observed = [
31692 variant.is_empty(),
31693 variant.is_absolute(),
31694 variant.is_parent_escape(),
31695 ];
31696 assert_eq!(
31697 observed, expected,
31698 "PathShapeViolation::{variant:?} is_* predicates must \
31699 partition the arm set (empty, absolute, parent_escape); \
31700 got {observed:?}"
31701 );
31702 }
31703 }
31704
31705 #[test]
31706 fn path_shape_violation_predicates_are_byte_equal_to_matches_family() {
31707 // Byte-equal pin on the [`gen_platform::IsVariant`]-derive-
31708 // generated per-arm predicate family. For every arm on the
31709 // closed three-arm [`PathShapeViolation`] discriminator, each
31710 // per-arm `is_*` predicate must agree byte-for-byte with the
31711 // hand-rolled `matches!(_, PathShapeViolation::…)` shape a
31712 // future consumer (a `feira lint --explain-path-shape=<axis>`
31713 // per-arm listing, a future symlink-escape / whitespace-hygiene
31714 // gate that keys off "is this a sandbox-escape arm" boolean, a
31715 // future single-arm `matches!` in a downstream renderer that
31716 // treats `Empty` distinctly from the other two) would
31717 // otherwise open-code at each caller. A future rebrand (a
31718 // `#[is_variant(name = "…")]` attribute drift on the derive,
31719 // an accidental peer predicate that shadows the derive-generated
31720 // one, a hand-rolled `impl PathShapeViolation` block that
31721 // shadows one of the derive-generated methods) trips this test
31722 // the moment the two paths' bytes diverge. Peer of the sibling
31723 // `caixa_kind_is_variant_predicates_partition_the_arm_set`
31724 // (kind.rs) and every peer closed-set-enum byte-equal pin.
31725 for &variant in PathShapeViolation::ALL {
31726 assert_eq!(
31727 variant.is_empty(),
31728 matches!(variant, PathShapeViolation::Empty),
31729 "PathShapeViolation::{variant:?}.is_empty() must agree \
31730 with matches!(_, PathShapeViolation::Empty)"
31731 );
31732 assert_eq!(
31733 variant.is_absolute(),
31734 matches!(variant, PathShapeViolation::Absolute),
31735 "PathShapeViolation::{variant:?}.is_absolute() must agree \
31736 with matches!(_, PathShapeViolation::Absolute)"
31737 );
31738 assert_eq!(
31739 variant.is_parent_escape(),
31740 matches!(variant, PathShapeViolation::ParentEscape),
31741 "PathShapeViolation::{variant:?}.is_parent_escape() must agree \
31742 with matches!(_, PathShapeViolation::ParentEscape)"
31743 );
31744 }
31745 }
31746
31747 // ── is_lisp_extension — `:behavior :on-*` + `:upgrade-from ───────────
31748 // ── :state-change :script` file-type predicate ───────────────────────
31749
31750 #[test]
31751 fn lisp_extension_accepts_canonical_shapes() {
31752 // Positive controls: every documented authoring shape across
31753 // both existing call sites — bare filename, standard `lib/`
31754 // subdirectory, deeply-nested migrations subdirectory,
31755 // explicit current-dir-relative prefix, mid-path `./`
31756 // segment, single-letter stem, and the multi-dot stem
31757 // (`lib/migrations/v.0.1.lisp`) an author might use to
31758 // encode the migration's `:from` version into the filename.
31759 // The predicate only inspects the terminating extension —
31760 // `Path::extension()` returns the substring after the final
31761 // `.` — so the multi-dot stem is structurally accepted
31762 // because the final extension is still `lisp`. Drift here =
31763 // a future tightening that rejects any of these surfaces as
31764 // a test-failure at the predicate boundary, not piecemeal
31765 // across per-axis call sites (`BehaviorSpec::validate`,
31766 // `UpgradeInstruction::StateChange::validate`).
31767 for relpath in [
31768 "init.lisp",
31769 "lib/init.lisp",
31770 "lib/handlers.lisp",
31771 "lib/migrations.lisp",
31772 "lib/migrations/v01-to-v02.lisp",
31773 "./lib/init.lisp",
31774 "lib/./handlers.lisp",
31775 "lib/migrations/v.0.1.lisp",
31776 "a.lisp",
31777 ] {
31778 assert!(
31779 is_lisp_extension(Path::new(relpath)),
31780 "canonical `.lisp` shape {relpath:?} must pass is_lisp_extension"
31781 );
31782 }
31783 }
31784
31785 #[test]
31786 fn lisp_extension_rejects_no_extension() {
31787 // The fail-before-pass-after pin on the no-extension shape.
31788 // A path with no `.` component (`Path::extension()` returns
31789 // `None`) is the canonical "I declared the slot but forgot
31790 // the `.lisp` extension" authoring footgun. The wasm-engine's
31791 // `tatara_lisp::read` consumer can't infer the file type from
31792 // the path alone, so the gate refuses the value at validate
31793 // time.
31794 for relpath in [
31795 "lib/init",
31796 "init",
31797 "lib/handlers",
31798 "lib/migrations/v01-to-v02",
31799 "a",
31800 ] {
31801 assert!(
31802 !is_lisp_extension(Path::new(relpath)),
31803 "no-extension shape {relpath:?} must fail is_lisp_extension"
31804 );
31805 }
31806 }
31807
31808 #[test]
31809 fn lisp_extension_rejects_wrong_extension() {
31810 // Wrong-extension sweep: the canonical authoring footguns
31811 // an author might drag in from the workspace tree (`.txt`,
31812 // `.md`, `.json`, `.yaml`, `.toml`), the `.rs` shape that
31813 // an IDE auto-complete might propose, the `.lisp.bak` shape
31814 // an editor might leave behind (the predicate only inspects
31815 // the *terminating* extension — `Path::extension()` returns
31816 // `bak` here, not `lisp.bak` — so the gate refuses it as a
31817 // no-`.lisp` final extension), and the `.lispx` / `.lis`
31818 // near-miss shapes that a typo would produce. Each must
31819 // fail the predicate — the wasm-engine's `tatara_lisp::read`
31820 // consumer rejects all of these at hot-upgrade migration /
31821 // instance-start time.
31822 for relpath in [
31823 "lib/init.rs",
31824 "lib/init.txt",
31825 "lib/init.md",
31826 "lib/init.json",
31827 "lib/init.yaml",
31828 "lib/init.toml",
31829 "lib/init.lisp.bak",
31830 "lib/init.lispx",
31831 "lib/init.lis",
31832 ] {
31833 assert!(
31834 !is_lisp_extension(Path::new(relpath)),
31835 "wrong-extension shape {relpath:?} must fail is_lisp_extension"
31836 );
31837 }
31838 }
31839
31840 #[test]
31841 fn lisp_extension_is_case_sensitive() {
31842 // Strict lowercase pin: every case-folded shape a
31843 // case-insensitive volume's existence check would match the
31844 // on-disk file must still fail the predicate — the
31845 // canonical-form codec emits lowercase `.lisp` verbatim, so
31846 // a case-folded shape mismatches the round-trip-stable
31847 // canonical form (THEORY.md §V.2.7 render-determinism).
31848 // Same case-sensitive discipline the byte-size / duration
31849 // codecs and every other shape-gate predicate in `render.rs`
31850 // (label / scheme / unit boundaries) carry. Pinned at the
31851 // predicate boundary so any future case-folding regression
31852 // surfaces here rather than piecemeal across per-axis call
31853 // sites.
31854 for relpath in [
31855 "lib/init.LISP",
31856 "lib/init.Lisp",
31857 "lib/init.LiSp",
31858 "lib/init.lISP",
31859 "lib/init.LISp",
31860 ] {
31861 assert!(
31862 !is_lisp_extension(Path::new(relpath)),
31863 "case-folded `.lisp` shape {relpath:?} must fail is_lisp_extension \
31864 (strict lowercase, render-determinism pin)"
31865 );
31866 }
31867 }
31868
31869 #[test]
31870 fn lisp_extension_constant_matches_predicate() {
31871 // Cross-pin: the [`LISP_SOURCE_EXTENSION`] const and the
31872 // predicate's accepted set are the same single source of
31873 // truth. Drift would let a future renderer / per-axis
31874 // wrapper emit `.<const>` while the predicate accepts only
31875 // `.lisp` (or vice versa), silently breaking the
31876 // round-trip-stable canonical form. Pinned by constructing
31877 // a path from the const and round-tripping through the
31878 // predicate.
31879 assert_eq!(LISP_SOURCE_EXTENSION, "lisp");
31880 let p = PathBuf::from(format!("lib/init.{LISP_SOURCE_EXTENSION}"));
31881 assert!(
31882 is_lisp_extension(&p),
31883 "path constructed from LISP_SOURCE_EXTENSION must pass is_lisp_extension"
31884 );
31885 }
31886
31887 #[test]
31888 fn lisp_extension_matches_inlined_call_site_semantics() {
31889 // End-to-end pin: every value the pre-lift inline gate
31890 // (`BehaviorSpec::validate_callback_path`, c97815a) accepted-
31891 // or-rejected must surface from the lifted predicate
31892 // identically. Drift here would mean a previously-accepted
31893 // authoring shape would suddenly fail (or vice versa)
31894 // silently across the lift commit. Sweeps the canonical
31895 // authoring shapes the pre-lift call site's tests covered
31896 // verbatim.
31897 // Pre-lift accepts (must still pass):
31898 for accept in [
31899 "lib/init.lisp",
31900 "lib/handlers.lisp",
31901 "lib/migrations/v01-to-v02.lisp",
31902 "init.lisp",
31903 "a.lisp",
31904 "./lib/init.lisp",
31905 "lib/./handlers.lisp",
31906 "lib/migrations/v.0.1.lisp",
31907 ] {
31908 assert!(
31909 is_lisp_extension(Path::new(accept)),
31910 "pre-lift accept {accept:?} regressed"
31911 );
31912 }
31913 // Pre-lift rejects (must still reject):
31914 for reject in [
31915 "lib/init",
31916 "init",
31917 "lib/init.rs",
31918 "lib/init.txt",
31919 "lib/init.lisp.bak",
31920 "lib/init.lispx",
31921 "lib/init.LISP",
31922 "lib/init.Lisp",
31923 ] {
31924 assert!(
31925 !is_lisp_extension(Path::new(reject)),
31926 "pre-lift reject {reject:?} regressed"
31927 );
31928 }
31929 }
31930
31931 // ── is_computeunit_yaml_extension — `:servicos` compound-suffix predicate ───
31932
31933 #[test]
31934 fn computeunit_yaml_extension_accepts_canonical_shapes() {
31935 // Positive controls: every canonical authoring shape every
31936 // in-tree fixture and the `Caixa::template` scaffold use. The
31937 // predicate inspects the final file-name component and checks
31938 // for the compound `.computeunit.yaml` suffix with at least
31939 // one byte of stem preceding it.
31940 for relpath in [
31941 "servicos/demo.computeunit.yaml",
31942 "servicos/hello-rio.computeunit.yaml",
31943 "servicos/my-service.computeunit.yaml",
31944 "servicos/a.computeunit.yaml",
31945 "./servicos/demo.computeunit.yaml",
31946 "servicos/./demo.computeunit.yaml",
31947 "servicos/sub/nested.computeunit.yaml",
31948 "servicos/v0.1.computeunit.yaml",
31949 ] {
31950 assert!(
31951 is_computeunit_yaml_extension(Path::new(relpath)),
31952 "canonical `.computeunit.yaml` shape {relpath:?} must pass \
31953 is_computeunit_yaml_extension"
31954 );
31955 }
31956 }
31957
31958 #[test]
31959 fn computeunit_yaml_extension_rejects_no_extension() {
31960 // No-extension shape — the canonical "I declared the slot
31961 // but forgot the `.computeunit.yaml` suffix" footgun. The
31962 // peer caixa-helm / caixa-flux `serde_yaml::from_str`
31963 // consumer can't infer the file type from the path alone, so
31964 // the gate refuses the value at validate time.
31965 for relpath in ["servicos/demo", "demo", "servicos/sub/nested"] {
31966 assert!(
31967 !is_computeunit_yaml_extension(Path::new(relpath)),
31968 "no-extension shape {relpath:?} must fail \
31969 is_computeunit_yaml_extension"
31970 );
31971 }
31972 }
31973
31974 #[test]
31975 fn computeunit_yaml_extension_rejects_wrong_extension() {
31976 // Wrong-extension sweep across the canonical authoring footguns
31977 // an author might drag in from the workspace tree — bare
31978 // `.yaml` (the canonical "I forgot the `.computeunit` segment"
31979 // typo), `.yml` (Helm-shorthand leak), `.json` (FluxCD
31980 // bundle leak), `.toml` (Cargo workspace leak), `.txt`
31981 // / `.md` (paste-from-doc footguns), `.yaml.bak` (editor
31982 // backup), the near-miss `.computeunit.yam` / `.computeunit.yamls`
31983 // typo, and the off-by-one-segment `computeunit-yaml`
31984 // / `computeunit_yaml` shapes. Each must fail the predicate.
31985 for relpath in [
31986 "servicos/demo.yaml",
31987 "servicos/demo.yml",
31988 "servicos/demo.json",
31989 "servicos/demo.toml",
31990 "servicos/demo.txt",
31991 "servicos/demo.md",
31992 "servicos/demo.computeunit.yaml.bak",
31993 "servicos/demo.computeunit.yam",
31994 "servicos/demo.computeunit.yamls",
31995 "servicos/demo.computeunit",
31996 "servicos/demo-computeunit.yaml",
31997 "servicos/demo_computeunit.yaml",
31998 ] {
31999 assert!(
32000 !is_computeunit_yaml_extension(Path::new(relpath)),
32001 "wrong-extension shape {relpath:?} must fail \
32002 is_computeunit_yaml_extension"
32003 );
32004 }
32005 }
32006
32007 #[test]
32008 fn computeunit_yaml_extension_is_case_sensitive() {
32009 // Strict lowercase pin: every case-folded shape a
32010 // case-insensitive volume's existence check would match the
32011 // on-disk file must still fail the predicate — the canonical-
32012 // form codec emits lowercase `.computeunit.yaml` verbatim, so
32013 // a case-folded shape mismatches the round-trip-stable
32014 // canonical form (THEORY.md §V.2.7 render-determinism). Same
32015 // case-sensitive discipline the byte-size / duration codecs
32016 // and the peer `is_lisp_extension` predicate carry.
32017 for relpath in [
32018 "servicos/demo.ComputeUnit.yaml",
32019 "servicos/demo.COMPUTEUNIT.yaml",
32020 "servicos/demo.computeunit.YAML",
32021 "servicos/demo.computeunit.Yaml",
32022 "servicos/demo.COMPUTEUNIT.YAML",
32023 ] {
32024 assert!(
32025 !is_computeunit_yaml_extension(Path::new(relpath)),
32026 "case-folded `.computeunit.yaml` shape {relpath:?} must fail \
32027 is_computeunit_yaml_extension (strict lowercase, \
32028 render-determinism pin)"
32029 );
32030 }
32031 }
32032
32033 #[test]
32034 fn computeunit_yaml_extension_rejects_empty_stem() {
32035 // Degenerate hidden-file shape: a file name exactly equal to
32036 // the suffix (`.computeunit.yaml` — no stem preceding the
32037 // suffix) is the structural "Servico declared with no
32038 // identity" footgun. The substrate identifies each ComputeUnit
32039 // by the file-stem segment that precedes `.computeunit.yaml`
32040 // (the rendered `lareira-<stem>` Helm chart, the per-Servico
32041 // `metadata.name`, the M3 `:contratos` membership lookup), so
32042 // an empty stem leaves the Servico unidentifiable. Predicate
32043 // pin: the `name.len() > SUFFIX.len()` bound rejects the
32044 // hidden-file shape at the predicate boundary.
32045 for relpath in [".computeunit.yaml", "servicos/.computeunit.yaml"] {
32046 assert!(
32047 !is_computeunit_yaml_extension(Path::new(relpath)),
32048 "empty-stem shape {relpath:?} must fail \
32049 is_computeunit_yaml_extension"
32050 );
32051 }
32052 }
32053
32054 #[test]
32055 fn computeunit_yaml_extension_constant_matches_predicate() {
32056 // Cross-pin: the [`COMPUTEUNIT_YAML_SUFFIX`] const and the
32057 // predicate's accepted set are the same single source of
32058 // truth. Drift would let a future renderer / per-axis wrapper
32059 // emit `<stem><const>` while the predicate accepts only
32060 // `.computeunit.yaml` (or vice versa), silently breaking the
32061 // round-trip-stable canonical form. Pinned by constructing a
32062 // path from the const and round-tripping through the
32063 // predicate. Mirrors the peer
32064 // `lisp_extension_constant_matches_predicate` pin.
32065 assert_eq!(COMPUTEUNIT_YAML_SUFFIX, ".computeunit.yaml");
32066 let p = PathBuf::from(format!("servicos/demo{COMPUTEUNIT_YAML_SUFFIX}"));
32067 assert!(
32068 is_computeunit_yaml_extension(&p),
32069 "path constructed from COMPUTEUNIT_YAML_SUFFIX must pass \
32070 is_computeunit_yaml_extension"
32071 );
32072 }
32073
32074 // ── is_cargo_feature_name — shared `:caracteristicas` feature-name predicate ──
32075
32076 #[test]
32077 fn cargo_feature_name_accepts_canonical_forms() {
32078 // Substrate-side pin: the predicate accepts every canonical Cargo
32079 // feature name shape `:caracteristicas` entries carry. Drift between
32080 // this list and the per-axis `dep::tests::validate_accepts_canonical_caracteristicas`
32081 // positive-set sweep surfaces here — one source of truth for the
32082 // rule. Includes single-token (`http`), kebab-case (`runtime-tokio`),
32083 // snake-case (`derive_macros`), namespaced-dot (`tokio.full`),
32084 // version-suffix (`v0.1`), `+`-separated (`http+json`), leading
32085 // underscore (`_internal`), doubled-underscore (`__private`),
32086 // and digit-starting (`v0_1`) — the canonical authoring shapes
32087 // every realistic Cargo feature in the pleme-io ecosystem uses.
32088 for s in [
32089 "http",
32090 "json",
32091 "derive",
32092 "serde",
32093 "serde_json",
32094 "runtime-tokio",
32095 "tokio.full",
32096 "v0.1",
32097 "v1",
32098 "http+json",
32099 "_internal",
32100 "__private",
32101 "default",
32102 "rt-multi-thread",
32103 "12factor",
32104 "feat.v2",
32105 "client+server",
32106 ] {
32107 is_cargo_feature_name(s)
32108 .unwrap_or_else(|e| panic!("canonical Cargo feature name {s:?} must pass: {e:?}"));
32109 }
32110 }
32111
32112 #[test]
32113 fn cargo_feature_name_rejects_each_arm_with_substring_pinned_reason() {
32114 // Substrate-side diagnostic-shape pin: each grammar arm
32115 // surfaces its own distinct reason substring. Pinned here so a
32116 // future reason-wording rephrase that drops any of these
32117 // substrings surfaces at this one place, not piecemeal across
32118 // every per-axis test sweep. Mirrors
32119 // `git_repo_url`'s and `git_ref_name`'s arm-substring sweeps
32120 // on the peer predicates.
32121 for (s, needle) in [
32122 // Leading `+` — the canonical paste-from-`+optional-feature`
32123 // activation-form-in-feature-name-slot footgun.
32124 ("+http", "`+`"),
32125 // Leading `-` — kebab-leak / CLI-arg-injection adjacent.
32126 ("-json", "`-`"),
32127 // Leading `.` — dotted-version-suffix-as-feature-name typo.
32128 (".feat", "`.`"),
32129 // Whitespace inside — multi-token blob.
32130 ("http feature", "whitespace"),
32131 // Tab inside.
32132 ("http\tjson", "whitespace"),
32133 // Leading whitespace — paste-from-aligned-doc.
32134 (" http", "whitespace"),
32135 // Comma — list-separator-belongs-to-list-grammar.
32136 ("http,json", "`,`"),
32137 // Forward slash — Cargo's `dep/feat` namespaced-dep syntax.
32138 ("http/json", "`/`"),
32139 // Question mark — URL-reserved.
32140 ("http?", "`?`"),
32141 // Hash — URL-reserved.
32142 ("http#frag", "`#`"),
32143 // Embedded control character.
32144 ("http\x01json", "control character"),
32145 // Newline — paste-from-multiline-doc.
32146 ("http\njson", "control character"),
32147 // DEL byte (0x7F).
32148 ("http\x7fjson", "control character"),
32149 // Non-ASCII byte — un-percent-encoded character.
32150 ("caf\u{e9}", "non-ASCII"),
32151 // Non-ASCII at first byte.
32152 ("\u{e9}feat", "non-ASCII"),
32153 // Forbidden punctuation in the continuation set.
32154 ("http@1", "invalid character"),
32155 ("http&json", "invalid character"),
32156 ("http=v1", "invalid character"),
32157 ] {
32158 let err = is_cargo_feature_name(s)
32159 .err()
32160 .unwrap_or_else(|| panic!("Cargo feature name {s:?} must be rejected"));
32161 assert!(
32162 err.contains(needle),
32163 "Cargo feature name {s:?} reason must contain {needle:?}; got {err:?}"
32164 );
32165 }
32166 }
32167
32168 #[test]
32169 fn cargo_feature_name_rejects_empty_defensively() {
32170 // The predicate is called from `crate::dep::Dep::validate_caracteristicas`
32171 // only after the per-axis `CaracteristicaEmpty` arm has fired
32172 // at validate time; re-checking here keeps the predicate usable
32173 // from any future call site without an empty-precondition
32174 // footgun. Same defensive empty-check `is_dns_1123_label`,
32175 // `is_gateway_api_http_path`, `is_wit_world_ref`,
32176 // `is_nats_subject`, `is_wasi_keyvalue_slot`, `is_git_ref_name`,
32177 // `is_git_oid`, and `is_git_repo_url` carry at their call sites.
32178 let err = is_cargo_feature_name("").unwrap_err();
32179 assert!(err.contains("empty"), "got: {err:?}");
32180 }
32181
32182 #[test]
32183 fn cargo_feature_name_rejects_at_65_byte_boundary() {
32184 // The 64-byte cap pin — both the boundary-exceeding case and
32185 // the boundary-accepting case in one place, so a future cap
32186 // shift surfaces both arms simultaneously, mirroring
32187 // `dns_1123_label_rejects_at_64_byte_boundary`,
32188 // `gateway_api_http_path_rejects_at_1025_byte_boundary`,
32189 // `wit_world_ref_rejects_at_129_byte_boundary`,
32190 // `nats_subject_rejects_at_257_byte_boundary`,
32191 // `wasi_kv_slot_rejects_at_513_byte_boundary`, and
32192 // `git_ref_name_rejects_at_256_byte_boundary` on the peer
32193 // predicates. Constructed as a single all-`a` token so only
32194 // the cap arm fires.
32195 let max_ok = "a".repeat(CARGO_FEATURE_NAME_MAX_LEN);
32196 assert_eq!(max_ok.len(), 64);
32197 is_cargo_feature_name(&max_ok).unwrap();
32198 let too_long = "a".repeat(CARGO_FEATURE_NAME_MAX_LEN + 1);
32199 assert_eq!(too_long.len(), 65);
32200 let err = is_cargo_feature_name(&too_long).unwrap_err();
32201 assert!(err.contains("64"), "got: {err:?}");
32202 assert!(err.contains("65"), "got: {err:?}");
32203 }
32204
32205 #[test]
32206 fn cargo_feature_name_first_byte_diagnostics_name_the_leading_char() {
32207 // Diagnostic-shape pin: the leading-character rejection arms
32208 // name the specific punctuation (`+`, `-`, `.`) verbatim so the
32209 // author's grep target is unambiguous. Pinned across the three
32210 // canonical leading-char footguns so a future relaxation that
32211 // drops any of the three surfaces here. The `+`-arm's wording
32212 // additionally points the author at the canonical Cargo
32213 // `+<feature>` activation-form-vs-feature-name discipline so
32214 // the paste-from-doc footgun lands its remediation in the
32215 // diagnostic itself.
32216 let err_plus = is_cargo_feature_name("+http").unwrap_err();
32217 assert!(err_plus.contains("`+`"), "got: {err_plus:?}");
32218 assert!(
32219 err_plus.contains("activation"),
32220 "got: {err_plus:?} (must name the Cargo +<feature> activation-form)"
32221 );
32222 let err_hyphen = is_cargo_feature_name("-json").unwrap_err();
32223 assert!(err_hyphen.contains("`-`"), "got: {err_hyphen:?}");
32224 let err_dot = is_cargo_feature_name(".feat").unwrap_err();
32225 assert!(err_dot.contains("`.`"), "got: {err_dot:?}");
32226 }
32227
32228 // ── is_spdx_expression_shape — shared `:licenca` SPDX-expression predicate ──
32229
32230 #[test]
32231 fn spdx_expression_shape_accepts_canonical_forms() {
32232 // Substrate-side pin: the predicate accepts every canonical
32233 // SPDX expression shape the `:licenca` axis carries. Drift
32234 // between this list and the per-axis
32235 // `manifest::tests::validate_licenca_accepts_canonical_expressions`
32236 // positive-set sweep surfaces here — one source of truth for
32237 // the rule. Covers single-license, `OR`/`AND`-compound,
32238 // `WITH`-exception, parenthesis-grouped, `+`-suffix, and
32239 // `LicenseRef-` / `DocumentRef-:LicenseRef-` shapes.
32240 for s in [
32241 "MIT",
32242 "Apache-2.0",
32243 "BSD-3-Clause",
32244 "MPL-2.0",
32245 "GPL-3.0-or-later",
32246 "GPL-2.0+",
32247 "Apache-2.0 OR MIT",
32248 "Apache-2.0 AND MIT",
32249 "Apache-2.0 WITH LLVM-exception",
32250 "(MIT OR Apache-2.0) AND BSD-3-Clause",
32251 "(MIT OR Apache-2.0) AND BSD-3-Clause AND ISC",
32252 "LicenseRef-MyLicense",
32253 "DocumentRef-spdx-tool:LicenseRef-MIT-Style",
32254 "x",
32255 ] {
32256 is_spdx_expression_shape(s)
32257 .unwrap_or_else(|e| panic!("canonical SPDX expression {s:?} must pass: {e:?}"));
32258 }
32259 }
32260
32261 #[test]
32262 fn spdx_expression_shape_rejects_each_arm_with_substring_pinned_reason() {
32263 // Substrate-side diagnostic-shape pin: each alphabet arm
32264 // surfaces its own distinct reason substring. Pinned here so a
32265 // future reason-wording rephrase that drops any of these
32266 // substrings surfaces at this one place, not piecemeal across
32267 // every per-axis test sweep. Mirrors
32268 // `cargo_feature_name_rejects_each_arm_with_substring_pinned_reason`
32269 // on the peer predicate.
32270 for (s, needle) in [
32271 // Leading whitespace — paste-from-aligned-doc.
32272 (" MIT", "whitespace"),
32273 // Trailing whitespace — paste-from-doc.
32274 ("MIT ", "whitespace"),
32275 // Tab inside — tab-from-aligned-doc.
32276 ("MIT\tOR Apache-2.0", "tab"),
32277 // Embedded control character.
32278 ("MIT\x01OR Apache-2.0", "control character"),
32279 // Newline — paste-from-multiline-doc.
32280 ("MIT\nOR Apache-2.0", "control character"),
32281 // CRLF — paste-from-multiline-doc.
32282 ("MIT\rApache-2.0", "control character"),
32283 // DEL byte (0x7F).
32284 ("MIT\x7fApache-2.0", "control character"),
32285 // Non-ASCII byte — smart-quote paste.
32286 ("MIT\u{a0}OR Apache-2.0", "non-ASCII"),
32287 // Non-ASCII at first byte — fullwidth letter.
32288 ("\u{ff2d}IT", "non-ASCII"),
32289 // Underscore — snake-case-instead-of-kebab-case typo.
32290 ("Apache_2.0", "`_`"),
32291 // Comma — list-separator-belongs-to-list-grammar.
32292 ("MIT, Apache-2.0", "`,`"),
32293 // Forward slash — colloquial dual-license idiom.
32294 ("MIT/Apache-2.0", "`/`"),
32295 // Semicolon — list-separator confusion.
32296 ("MIT; Apache-2.0", "`;`"),
32297 // Forbidden punctuation in the alphabet.
32298 ("MIT@1.0", "invalid character"),
32299 ("MIT&Apache-2.0", "invalid character"),
32300 ("MIT=Apache-2.0", "invalid character"),
32301 ("MIT*1.0", "invalid character"),
32302 ] {
32303 let err = is_spdx_expression_shape(s)
32304 .err()
32305 .unwrap_or_else(|| panic!("SPDX expression {s:?} must be rejected"));
32306 assert!(
32307 err.contains(needle),
32308 "SPDX expression {s:?} reason must contain {needle:?}; got {err:?}"
32309 );
32310 }
32311 }
32312
32313 #[test]
32314 fn spdx_expression_shape_rejects_empty_defensively() {
32315 // The predicate is called from `crate::Caixa::validate_licenca`
32316 // only after the per-axis `LicencaEmpty` arm has fired at
32317 // validate time; re-checking here keeps the predicate usable
32318 // from any future call site without an empty-precondition
32319 // footgun. Same defensive empty-check `is_dns_1123_label`,
32320 // `is_gateway_api_http_path`, `is_wit_world_ref`,
32321 // `is_nats_subject`, `is_wasi_keyvalue_slot`,
32322 // `is_git_ref_name`, `is_git_oid`, `is_git_repo_url`, and
32323 // `is_cargo_feature_name` carry at their call sites.
32324 let err = is_spdx_expression_shape("").unwrap_err();
32325 assert!(err.contains("empty"), "got: {err:?}");
32326 }
32327
32328 #[test]
32329 fn spdx_expression_shape_rejects_at_257_byte_boundary() {
32330 // The 256-byte cap pin — both the boundary-exceeding case and
32331 // the boundary-accepting case in one place, so a future cap
32332 // shift surfaces both arms simultaneously, mirroring the peer
32333 // cap-boundary pins. Constructed as a single all-`a` token so
32334 // only the cap arm fires (256 `a` bytes is alphabet-valid).
32335 let max_ok = "a".repeat(SPDX_EXPRESSION_MAX_LEN);
32336 assert_eq!(max_ok.len(), 256);
32337 is_spdx_expression_shape(&max_ok).unwrap();
32338 let too_long = "a".repeat(SPDX_EXPRESSION_MAX_LEN + 1);
32339 assert_eq!(too_long.len(), 257);
32340 let err = is_spdx_expression_shape(&too_long).unwrap_err();
32341 assert!(err.contains("256"), "got: {err:?}");
32342 assert!(err.contains("257"), "got: {err:?}");
32343 }
32344
32345 // ── is_chart_description_shape — shared `:descricao` chart-description predicate ──
32346
32347 #[test]
32348 fn chart_description_shape_accepts_canonical_forms() {
32349 // Substrate-side pin: the predicate accepts every canonical
32350 // chart-description shape the `:descricao` axis carries.
32351 // Drift between this list and the per-axis
32352 // `manifest::tests::validate_descricao_accepts_canonical_summary`
32353 // positive-set sweep surfaces here — one source of truth for
32354 // the rule. Covers ASCII summaries, the Unicode `→` from the
32355 // canonical Rust→wasm fixture, and the Unicode `—` em-dash
32356 // from the `Caixa::template` scaffold every `feira init`
32357 // emits.
32358 for s in [
32359 "Canonical Rust→wasm32-wasip2 caixa Servico.",
32360 "Checkout flow.",
32361 "AWS provider caixa for tatara-lisp",
32362 "FIXME — describe this caixa",
32363 "x",
32364 ] {
32365 is_chart_description_shape(s)
32366 .unwrap_or_else(|e| panic!("canonical chart description {s:?} must pass: {e:?}"));
32367 }
32368 }
32369
32370 #[test]
32371 fn chart_description_shape_rejects_each_arm_with_substring_pinned_reason() {
32372 // Substrate-side diagnostic-shape pin: each arm surfaces its
32373 // own distinct reason substring. Pinned here so a future
32374 // reason-wording rephrase that drops any of these substrings
32375 // surfaces at this one place, not piecemeal across every
32376 // per-axis test sweep. Mirrors
32377 // `spdx_expression_shape_rejects_each_arm_with_substring_pinned_reason`
32378 // on the peer predicate.
32379 for (s, needle) in [
32380 // Leading whitespace — paste-from-aligned-doc.
32381 (" Checkout flow.", "whitespace"),
32382 // Trailing whitespace — paste-from-doc.
32383 ("Checkout flow. ", "whitespace"),
32384 // Tab inside — tab-from-aligned-doc.
32385 ("Checkout\tflow.", "tab"),
32386 // Newline — paste-from-multiline-doc.
32387 ("Checkout\nflow.", "newline"),
32388 // Carriage return — paste-from-Windows-CRLF-doc.
32389 ("Checkout\rflow.", "carriage return"),
32390 // NUL byte — paste-from-binary-blob.
32391 ("Checkout\x00flow.", "control character"),
32392 // BEL byte — paste-from-binary-blob.
32393 ("Checkout\x07flow.", "control character"),
32394 // ESC byte — paste-from-binary-blob.
32395 ("Checkout\x1bflow.", "control character"),
32396 // DEL byte (0x7F).
32397 ("Checkout\x7fflow.", "control character"),
32398 ] {
32399 let err = is_chart_description_shape(s)
32400 .err()
32401 .unwrap_or_else(|| panic!("chart description {s:?} must be rejected"));
32402 assert!(
32403 err.contains(needle),
32404 "chart description {s:?} reason must contain {needle:?}; got {err:?}"
32405 );
32406 }
32407 }
32408
32409 #[test]
32410 fn chart_description_shape_accepts_unicode() {
32411 // Positive control on the non-ASCII arm: the predicate must
32412 // accept Unicode beyond the ASCII alphabet — the canonical
32413 // pleme-io descricao fixtures carry `→` (U+2192) and `—`
32414 // (U+2014), and every downstream consumer (YAML 1.2, Helm v3,
32415 // every chart-aware UI) round-trips Unicode losslessly.
32416 // Mirrors the spdx-rejects-non-ASCII arm by inverting it — a
32417 // future tightening that bans non-ASCII bytes would regress
32418 // every canonical fixture and surface here as a regression.
32419 for s in [
32420 "Canonical Rust→wasm32-wasip2",
32421 "FIXME — describe this caixa",
32422 "Caixa pour le projet tâche",
32423 "日本語の説明",
32424 "naïve",
32425 ] {
32426 is_chart_description_shape(s)
32427 .unwrap_or_else(|e| panic!("Unicode chart description {s:?} must pass: {e:?}"));
32428 }
32429 }
32430
32431 #[test]
32432 fn chart_description_shape_rejects_empty_defensively() {
32433 // The predicate is called from `crate::Caixa::validate_descricao`
32434 // only after the per-axis `DescricaoEmpty` arm has fired at
32435 // validate time; re-checking here keeps the predicate usable
32436 // from any future call site without an empty-precondition
32437 // footgun. Same defensive empty-check `is_dns_1123_label`,
32438 // `is_gateway_api_http_path`, `is_wit_world_ref`,
32439 // `is_nats_subject`, `is_wasi_keyvalue_slot`,
32440 // `is_git_ref_name`, `is_git_oid`, `is_git_repo_url`,
32441 // `is_cargo_feature_name`, and `is_spdx_expression_shape`
32442 // carry at their call sites.
32443 let err = is_chart_description_shape("").unwrap_err();
32444 assert!(err.contains("empty"), "got: {err:?}");
32445 }
32446
32447 #[test]
32448 fn chart_description_shape_rejects_at_513_byte_boundary() {
32449 // The 512-byte cap pin — both the boundary-exceeding case and
32450 // the boundary-accepting case in one place, so a future cap
32451 // shift surfaces both arms simultaneously, mirroring the peer
32452 // cap-boundary pins. Constructed as a single all-`a` token so
32453 // only the cap arm fires (512 `a` bytes is alphabet-valid).
32454 let max_ok = "a".repeat(CHART_DESCRIPTION_MAX_LEN);
32455 assert_eq!(max_ok.len(), 512);
32456 is_chart_description_shape(&max_ok).unwrap();
32457 let too_long = "a".repeat(CHART_DESCRIPTION_MAX_LEN + 1);
32458 assert_eq!(too_long.len(), 513);
32459 let err = is_chart_description_shape(&too_long).unwrap_err();
32460 assert!(err.contains("512"), "got: {err:?}");
32461 assert!(err.contains("513"), "got: {err:?}");
32462 }
32463
32464 #[test]
32465 fn chart_description_shape_rejects_each_unicode_bidi_override_codepoint() {
32466 // The Trojan Source (CVE-2021-42574) arm — pins every UAX #9
32467 // bidirectional-override / isolate format codepoint as a
32468 // structural rejection on the typed `:descricao` axis. The
32469 // per-byte non-ASCII pass deliberately admits Unicode letters
32470 // / em-dash / arrows because the canonical fixtures carry them
32471 // (`Canonical Rust→wasm32-wasip2`, `FIXME — describe this
32472 // caixa`); only the typed codepoint scan catches the nine
32473 // bidi-override codepoints that flip the rendered visual order
32474 // of every following character, so a future drop of any one
32475 // arm here surfaces as a `must be rejected` panic at this one
32476 // place rather than as a silent regression downstream. Each
32477 // case carries an alphabet-valid prefix + suffix so only the
32478 // bidi-override arm fires.
32479 for (cp, name) in [
32480 ('\u{202A}', "U+202A"),
32481 ('\u{202B}', "U+202B"),
32482 ('\u{202C}', "U+202C"),
32483 ('\u{202D}', "U+202D"),
32484 ('\u{202E}', "U+202E"),
32485 ('\u{2066}', "U+2066"),
32486 ('\u{2067}', "U+2067"),
32487 ('\u{2068}', "U+2068"),
32488 ('\u{2069}', "U+2069"),
32489 ] {
32490 let s = format!("alice{cp}bob");
32491 let err = is_chart_description_shape(&s)
32492 .err()
32493 .unwrap_or_else(|| panic!("chart description with {name} must be rejected"));
32494 assert!(
32495 err.contains(name),
32496 "chart description reason for {name} must name the codepoint verbatim; got {err:?}"
32497 );
32498 assert!(
32499 err.contains("bidirectional-override")
32500 || err.contains("Unicode bidi")
32501 || err.contains("Trojan Source"),
32502 "chart description reason for {name} must name the Trojan-Source banner; \
32503 got {err:?}"
32504 );
32505 }
32506 }
32507
32508 #[test]
32509 fn chart_description_shape_accepts_pure_rtl_text_without_bidi_override() {
32510 // Positive control on the bidi-override arm: pure visual
32511 // right-to-left scripts (Hebrew, Arabic) decode to non-bidi-
32512 // override codepoints and the predicate must accept them
32513 // natively — banning all RTL would regress every Hebrew /
32514 // Arabic-authored caixa, which the substrate explicitly
32515 // supports via the non-ASCII byte arm. The structural axis the
32516 // bidi-override arm closes is the explicit direction-mark
32517 // codepoint, not the RTL script itself.
32518 for s in [
32519 // Hebrew word (RTL script, no bidi-override codepoint).
32520 "שלום",
32521 // Arabic word (RTL script, no bidi-override codepoint).
32522 "مرحبا",
32523 // Mixed LTR / RTL caixa — the canonical multilingual
32524 // description shape every YAML 1.2 + Helm v3 + Artifact
32525 // Hub consumer round-trips losslessly.
32526 "Caixa para שלום",
32527 ] {
32528 is_chart_description_shape(s).unwrap_or_else(|e| {
32529 panic!("pure-RTL chart description {s:?} must pass without bidi override: {e:?}")
32530 });
32531 }
32532 }
32533
32534 #[test]
32535 fn chart_description_shape_rejects_each_unicode_line_break_codepoint() {
32536 // The non-ASCII Unicode line-break arm — pins each of the three
32537 // UAX #14 / YAML 1.1 §4.1 line-break codepoints outside the
32538 // ASCII `\n` / `\r` bytes already caught at the per-byte pass.
32539 // Each case carries an alphabet-valid prefix + suffix so only
32540 // the line-break arm fires; the per-byte `\n` / `\r` arms
32541 // would shadow the codepoint scan if the line-break helper
32542 // accepted single-byte ASCII line terminators. A future drop
32543 // of any one arm here surfaces as a `must be rejected` panic
32544 // at this one place rather than as a silent regression
32545 // through YAML 1.1-compat downstream consumers (go-yaml v2 /
32546 // Helm v3 / kubectl). Mirrors the peer
32547 // `chart_maintainer_name_shape_rejects_each_unicode_line_break_codepoint`
32548 // on the sibling predicate — both predicates route through the
32549 // same lifted `find_unicode_line_break` helper.
32550 for (cp, name) in [
32551 ('\u{0085}', "U+0085"),
32552 ('\u{2028}', "U+2028"),
32553 ('\u{2029}', "U+2029"),
32554 ] {
32555 let s = format!("first line{cp}second line");
32556 let err = is_chart_description_shape(&s)
32557 .err()
32558 .unwrap_or_else(|| panic!("chart description with {name} must be rejected"));
32559 assert!(
32560 err.contains(name),
32561 "chart description reason for {name} must name the codepoint verbatim; got {err:?}"
32562 );
32563 assert!(
32564 err.contains("line-break") || err.contains("UAX #14") || err.contains("YAML 1.1"),
32565 "chart description reason for {name} must name the Unicode-line-break banner; \
32566 got {err:?}"
32567 );
32568 }
32569 }
32570
32571 #[test]
32572 fn chart_description_shape_accepts_non_line_break_unicode() {
32573 // Positive control on the line-break arm: the predicate must
32574 // accept every non-line-break Unicode shape the canonical
32575 // fixtures carry. Pinned alongside the per-codepoint rejection
32576 // sweep so a future helper widening that accidentally rejects
32577 // a non-line-break codepoint (the structural-floor regression
32578 // class) surfaces here as a single-source-of-truth pin. The
32579 // canonical multilingual descriptions, RTL text, em-dash and
32580 // arrows must all pass.
32581 for s in [
32582 "Canonical Rust→wasm32-wasip2 caixa Servico.",
32583 "FIXME — describe this caixa",
32584 "Caixa para שלום",
32585 "日本語の説明テスト",
32586 // U+00A0 NO-BREAK SPACE is NOT a line-break codepoint
32587 // (UAX #14 class GL — Glue, non-breaking) — must pass.
32588 "Caixa\u{00A0}for tests",
32589 ] {
32590 is_chart_description_shape(s).unwrap_or_else(|e| {
32591 panic!(
32592 "non-line-break Unicode chart description {s:?} must pass without rejection: \
32593 {e:?}"
32594 )
32595 });
32596 }
32597 }
32598
32599 #[test]
32600 fn chart_description_shape_rejects_each_unicode_invisible_format_codepoint() {
32601 // The Unicode invisible-format arm — pins each of the eight
32602 // BMP Cf-category zero-width codepoints with no visible glyph
32603 // in any conforming font. The per-byte non-ASCII pass
32604 // deliberately admits multi-byte UTF-8 sequences (Unicode
32605 // letters / arrows / em-dash are canonical fixtures); only the
32606 // typed codepoint scan catches these eight. Each case carries
32607 // an alphabet-valid prefix + suffix so only the invisible-
32608 // format arm fires. A future drop of any one arm here surfaces
32609 // as a `must be rejected` panic at this one place rather than
32610 // as a silent regression through invisible-codepoint-homograph
32611 // downstream consumers (Artifact Hub description-search
32612 // misses, byte-level diff / grep / equality disagreement with
32613 // the visible-glyph match). Peer of
32614 // `chart_maintainer_name_shape_rejects_each_unicode_invisible_format_codepoint`
32615 // on the sibling predicate — both predicates route through the
32616 // same lifted `find_unicode_invisible_format` helper. Covers
32617 // the four paste-from-Word / paste-from-BOM-editor / paste-
32618 // from-typesetting shapes (U+00AD / U+200B / U+2060 / U+FEFF)
32619 // and the four math-formula invisible operators (U+2061
32620 // FUNCTION APPLICATION / U+2062 INVISIBLE TIMES / U+2063
32621 // INVISIBLE SEPARATOR / U+2064 INVISIBLE PLUS — the canonical
32622 // paste-from-MathJax / paste-from-LaTeX-rendered-formula
32623 // footgun where the renderer emits an invisible operator
32624 // between adjacent symbols for screen-reader operator
32625 // semantics).
32626 for (cp, name) in [
32627 ('\u{00AD}', "U+00AD"),
32628 ('\u{200B}', "U+200B"),
32629 ('\u{2060}', "U+2060"),
32630 ('\u{2061}', "U+2061"),
32631 ('\u{2062}', "U+2062"),
32632 ('\u{2063}', "U+2063"),
32633 ('\u{2064}', "U+2064"),
32634 ('\u{FEFF}', "U+FEFF"),
32635 ] {
32636 let s = format!("Canonical{cp}Servico");
32637 let err = is_chart_description_shape(&s)
32638 .err()
32639 .unwrap_or_else(|| panic!("chart description with {name} must be rejected"));
32640 assert!(
32641 err.contains(name),
32642 "chart description reason for {name} must name the codepoint verbatim; got {err:?}"
32643 );
32644 assert!(
32645 err.contains("invisible-format")
32646 || err.contains("Cf-category")
32647 || err.contains("zero-width"),
32648 "chart description reason for {name} must name the invisible-format banner; \
32649 got {err:?}"
32650 );
32651 }
32652 }
32653
32654 #[test]
32655 fn chart_description_shape_accepts_non_invisible_format_unicode() {
32656 // Positive control on the invisible-format arm: the predicate
32657 // must accept every non-invisible-format Unicode shape canonical
32658 // fixtures carry — including U+200C ZWNJ / U+200D ZWJ
32659 // (legitimate compositional load in Indic / Persian scripts and
32660 // emoji ZWJ sequences) and U+200E LRM / U+200F RLM (legitimate
32661 // single-character direction hints in mixed-script prose). A
32662 // future helper widening that accidentally rejects any of these
32663 // would regress legitimate fixture shapes and surfaces here as
32664 // a single-source-of-truth pin. Mirrors
32665 // `chart_maintainer_name_shape_accepts_non_invisible_format_unicode`
32666 // on the sibling predicate.
32667 for s in [
32668 "Canonical Rust→wasm32-wasip2 caixa Servico.",
32669 "FIXME — describe this caixa",
32670 // Emoji ZWJ sequence (U+200D) — must NOT be rejected: the
32671 // canonical multi-codepoint emoji authoring shape every
32672 // chart-aware UI renders as a single glyph.
32673 "Caixa for the 👨\u{200D}💻 family",
32674 // ZWNJ (U+200C) — legitimate Persian / Indic script
32675 // composition; the helper must NOT claim it.
32676 "Caixa for می\u{200C}باشد",
32677 // Bidi marks LRM (U+200E) and RLM (U+200F) — legitimate
32678 // single-character direction hints, separate class from
32679 // the bidi *overrides* the prior helper rejects.
32680 "Caixa for ASCII\u{200E}embedded in RTL",
32681 "Caixa for \u{200F}RTL hint",
32682 ] {
32683 is_chart_description_shape(s).unwrap_or_else(|e| {
32684 panic!(
32685 "non-invisible-format Unicode chart description {s:?} must pass without \
32686 rejection: {e:?}"
32687 )
32688 });
32689 }
32690 }
32691
32692 // ── is_chart_maintainer_name_shape — shared `:autores` chart-maintainer predicate ──
32693
32694 #[test]
32695 fn chart_maintainer_name_shape_accepts_canonical_forms() {
32696 // Substrate-side pin: the predicate accepts every canonical
32697 // chart-maintainer-name shape the `:autores` axis carries.
32698 // Drift between this list and the per-axis
32699 // `manifest::tests::validate_autores_accepts_canonical_forms`
32700 // positive-set sweep surfaces here — one source of truth for
32701 // the rule. Covers the hello-rio / checkout-aplicacao
32702 // `:autores ("pleme-io")` fixture, the multi-author
32703 // `"Pleme Contributors"` shape, and the canonical Helm
32704 // `"name <email>"` shape downstream packaging surfaces emit.
32705 for s in [
32706 "pleme-io",
32707 "Pleme Contributors",
32708 "alice <alice@example.com>",
32709 "bob <bob@example.com>",
32710 "Acme Corporation",
32711 "x",
32712 ] {
32713 is_chart_maintainer_name_shape(s).unwrap_or_else(|e| {
32714 panic!("canonical chart maintainer name {s:?} must pass: {e:?}")
32715 });
32716 }
32717 }
32718
32719 #[test]
32720 fn chart_maintainer_name_shape_rejects_each_arm_with_substring_pinned_reason() {
32721 // Substrate-side diagnostic-shape pin: each arm surfaces its
32722 // own distinct reason substring. Pinned here so a future
32723 // reason-wording rephrase that drops any of these substrings
32724 // surfaces at this one place, not piecemeal across every
32725 // per-axis test sweep. Mirrors
32726 // `chart_description_shape_rejects_each_arm_with_substring_pinned_reason`
32727 // on the peer predicate.
32728 for (s, needle) in [
32729 // Leading whitespace — paste-from-aligned-doc.
32730 (" pleme-io", "whitespace"),
32731 // Trailing whitespace — paste-from-doc.
32732 ("pleme-io ", "whitespace"),
32733 // Tab inside — tab-from-aligned-doc.
32734 ("Pleme\tContributors", "tab"),
32735 // Newline — paste-from-multiline-doc (author pasted
32736 // multi-line author block into one entry).
32737 ("alice\nbob", "newline"),
32738 // Carriage return — paste-from-Windows-CRLF-doc.
32739 ("alice\rbob", "carriage return"),
32740 // NUL byte — paste-from-binary-blob.
32741 ("alice\x00bob", "control character"),
32742 // BEL byte — paste-from-binary-blob.
32743 ("alice\x07bob", "control character"),
32744 // ESC byte — paste-from-binary-blob.
32745 ("alice\x1bbob", "control character"),
32746 // DEL byte (0x7F).
32747 ("alice\x7fbob", "control character"),
32748 ] {
32749 let err = is_chart_maintainer_name_shape(s)
32750 .err()
32751 .unwrap_or_else(|| panic!("chart maintainer name {s:?} must be rejected"));
32752 assert!(
32753 err.contains(needle),
32754 "chart maintainer name {s:?} reason must contain {needle:?}; got {err:?}"
32755 );
32756 }
32757 }
32758
32759 #[test]
32760 fn chart_maintainer_name_shape_accepts_unicode() {
32761 // Positive control on the non-ASCII arm: the predicate must
32762 // accept Unicode beyond the ASCII alphabet — realistic
32763 // maintainer names carry Unicode (`François`, `日本語`,
32764 // `naïve`), and every downstream consumer (YAML 1.2, Helm v3,
32765 // every chart-aware UI) round-trips Unicode losslessly. A
32766 // future tightening that bans non-ASCII bytes would regress
32767 // every Unicode-named maintainer and surface here as a
32768 // regression. Mirrors the peer
32769 // `chart_description_shape_accepts_unicode`.
32770 for s in [
32771 "François Dupont",
32772 "日本語の名前",
32773 "naïve <naive@example.com>",
32774 "André",
32775 ] {
32776 is_chart_maintainer_name_shape(s)
32777 .unwrap_or_else(|e| panic!("Unicode chart maintainer name {s:?} must pass: {e:?}"));
32778 }
32779 }
32780
32781 #[test]
32782 fn chart_maintainer_name_shape_rejects_empty_defensively() {
32783 // The predicate is called from `crate::Caixa::validate_autores`
32784 // only after the per-axis `AutorEmpty` arm has fired at
32785 // validate time; re-checking here keeps the predicate usable
32786 // from any future call site without an empty-precondition
32787 // footgun. Same defensive empty-check `is_dns_1123_label`,
32788 // `is_gateway_api_http_path`, `is_wit_world_ref`,
32789 // `is_nats_subject`, `is_wasi_keyvalue_slot`,
32790 // `is_git_ref_name`, `is_git_oid`, `is_git_repo_url`,
32791 // `is_cargo_feature_name`, `is_spdx_expression_shape`, and
32792 // `is_chart_description_shape` carry at their call sites.
32793 let err = is_chart_maintainer_name_shape("").unwrap_err();
32794 assert!(err.contains("empty"), "got: {err:?}");
32795 }
32796
32797 #[test]
32798 fn chart_maintainer_name_shape_rejects_at_129_byte_boundary() {
32799 // The 128-byte cap pin — both the boundary-exceeding case and
32800 // the boundary-accepting case in one place, so a future cap
32801 // shift surfaces both arms simultaneously, mirroring the peer
32802 // cap-boundary pins (`chart_description_shape_rejects_at_513_byte_boundary`
32803 // on the 512-byte sibling, `spdx_expression_shape_rejects_at_257_byte_boundary`
32804 // on the 256-byte sibling). Constructed as a single all-`a`
32805 // token so only the cap arm fires (128 `a` bytes is
32806 // alphabet-valid).
32807 let max_ok = "a".repeat(CHART_MAINTAINER_NAME_MAX_LEN);
32808 assert_eq!(max_ok.len(), 128);
32809 is_chart_maintainer_name_shape(&max_ok).unwrap();
32810 let too_long = "a".repeat(CHART_MAINTAINER_NAME_MAX_LEN + 1);
32811 assert_eq!(too_long.len(), 129);
32812 let err = is_chart_maintainer_name_shape(&too_long).unwrap_err();
32813 assert!(err.contains("128"), "got: {err:?}");
32814 assert!(err.contains("129"), "got: {err:?}");
32815 }
32816
32817 #[test]
32818 fn chart_maintainer_name_shape_rejects_each_unicode_bidi_override_codepoint() {
32819 // The Trojan Source (CVE-2021-42574) arm — pins every UAX #9
32820 // bidirectional-override / isolate format codepoint as a
32821 // structural rejection on the typed `:autores` axis. Mirrors
32822 // `chart_description_shape_rejects_each_unicode_bidi_override_codepoint`
32823 // on the peer predicate — both predicates route through the
32824 // same lifted `find_unicode_bidi_override` helper, so dropping
32825 // any one of the nine arms from the helper's match would
32826 // regress both peer test sweeps simultaneously at this one
32827 // structural floor rather than at piecemeal per-axis call
32828 // sites. The canonical attacker shape: an `:autores
32829 // "alice\u{202E}example.com<bob@"` entry renders in `helm
32830 // list`'s maintainer column / Artifact Hub as the visually-
32831 // reversed `alice<@bob>moc.elpmaxe` while riding verbatim
32832 // into the Chart.yaml `maintainers:` array — exactly the
32833 // class this arm closes.
32834 for (cp, name) in [
32835 ('\u{202A}', "U+202A"),
32836 ('\u{202B}', "U+202B"),
32837 ('\u{202C}', "U+202C"),
32838 ('\u{202D}', "U+202D"),
32839 ('\u{202E}', "U+202E"),
32840 ('\u{2066}', "U+2066"),
32841 ('\u{2067}', "U+2067"),
32842 ('\u{2068}', "U+2068"),
32843 ('\u{2069}', "U+2069"),
32844 ] {
32845 let s = format!("alice{cp}bob");
32846 let err = is_chart_maintainer_name_shape(&s)
32847 .err()
32848 .unwrap_or_else(|| panic!("chart maintainer name with {name} must be rejected"));
32849 assert!(
32850 err.contains(name),
32851 "chart maintainer name reason for {name} must name the codepoint verbatim; \
32852 got {err:?}"
32853 );
32854 assert!(
32855 err.contains("bidirectional-override")
32856 || err.contains("Unicode bidi")
32857 || err.contains("Trojan Source"),
32858 "chart maintainer name reason for {name} must name the Trojan-Source banner; \
32859 got {err:?}"
32860 );
32861 }
32862 }
32863
32864 #[test]
32865 fn chart_maintainer_name_shape_accepts_pure_rtl_text_without_bidi_override() {
32866 // Positive control on the bidi-override arm: pure visual
32867 // right-to-left scripts (Hebrew, Arabic) decode to non-bidi-
32868 // override codepoints and the predicate must accept them
32869 // natively — banning all RTL would regress every Hebrew /
32870 // Arabic-authored maintainer-name entry, which the substrate
32871 // supports via the non-ASCII byte arm. Peer of
32872 // `chart_description_shape_accepts_pure_rtl_text_without_bidi_override`
32873 // on the sibling YAML-plain-style-scalar surface.
32874 for s in [
32875 // Pure Hebrew maintainer name.
32876 "שלום",
32877 // Pure Arabic maintainer name.
32878 "مرحبا",
32879 // Mixed-script — canonical multilingual maintainer
32880 // shape every YAML 1.2 + Helm v3 round-trips losslessly.
32881 "Acme שלום",
32882 ] {
32883 is_chart_maintainer_name_shape(s).unwrap_or_else(|e| {
32884 panic!(
32885 "pure-RTL chart maintainer name {s:?} must pass without bidi override: {e:?}"
32886 )
32887 });
32888 }
32889 }
32890
32891 #[test]
32892 fn chart_maintainer_name_shape_rejects_each_unicode_line_break_codepoint() {
32893 // The non-ASCII Unicode line-break arm — pins each of the three
32894 // UAX #14 / YAML 1.1 §4.1 line-break codepoints outside the
32895 // ASCII `\n` / `\r` bytes already caught at the per-byte pass.
32896 // The canonical YAML-1.1-vs-YAML-1.2 paste-from-doc footgun: an
32897 // `:autores "alice\u{2028}bob"` entry parses as one
32898 // `maintainers:` array entry through a YAML 1.2-strict parser
32899 // and as two entries through a YAML 1.1 parser (go-yaml v2 /
32900 // Helm v3). Mirrors
32901 // `chart_description_shape_rejects_each_unicode_line_break_codepoint`
32902 // on the peer predicate — both predicates route through the
32903 // same lifted `find_unicode_line_break` helper, so dropping
32904 // any one of the three arms from the helper's match would
32905 // regress both peer test sweeps simultaneously at this one
32906 // structural floor.
32907 for (cp, name) in [
32908 ('\u{0085}', "U+0085"),
32909 ('\u{2028}', "U+2028"),
32910 ('\u{2029}', "U+2029"),
32911 ] {
32912 let s = format!("alice{cp}bob");
32913 let err = is_chart_maintainer_name_shape(&s)
32914 .err()
32915 .unwrap_or_else(|| panic!("chart maintainer name with {name} must be rejected"));
32916 assert!(
32917 err.contains(name),
32918 "chart maintainer name reason for {name} must name the codepoint verbatim; \
32919 got {err:?}"
32920 );
32921 assert!(
32922 err.contains("line-break") || err.contains("UAX #14") || err.contains("YAML 1.1"),
32923 "chart maintainer name reason for {name} must name the Unicode-line-break banner; \
32924 got {err:?}"
32925 );
32926 }
32927 }
32928
32929 #[test]
32930 fn chart_maintainer_name_shape_accepts_non_line_break_unicode() {
32931 // Positive control on the line-break arm: the predicate must
32932 // accept every non-line-break Unicode shape canonical
32933 // maintainer names carry. Pinned alongside the per-codepoint
32934 // rejection sweep so a future helper widening that
32935 // accidentally rejects a non-line-break codepoint surfaces
32936 // here as a single-source-of-truth pin. Peer of
32937 // `chart_description_shape_accepts_non_line_break_unicode`
32938 // on the sibling YAML-plain-style-scalar surface.
32939 for s in [
32940 "François Dupont",
32941 "日本語の名前",
32942 "naïve <naive@example.com>",
32943 "André",
32944 // U+00A0 NO-BREAK SPACE is NOT a line-break codepoint
32945 // (UAX #14 class GL — Glue, non-breaking) and is the
32946 // canonical authoring shape for unbreakable space inside
32947 // a multi-token maintainer name — must pass.
32948 "Acme\u{00A0}Corp",
32949 ] {
32950 is_chart_maintainer_name_shape(s).unwrap_or_else(|e| {
32951 panic!(
32952 "non-line-break Unicode chart maintainer name {s:?} must pass without \
32953 rejection: {e:?}"
32954 )
32955 });
32956 }
32957 }
32958
32959 #[test]
32960 fn chart_maintainer_name_shape_rejects_each_unicode_invisible_format_codepoint() {
32961 // The Unicode invisible-format arm — pins each of the eight
32962 // BMP Cf-category zero-width codepoints with no visible glyph.
32963 // The canonical maintainer-identity homograph footgun: an
32964 // `:autores "alice\u{200B}"` entry renders identically to
32965 // `:autores "alice"` in `helm list` / Artifact Hub's
32966 // maintainer column, but the byte sequence is distinct — the
32967 // Artifact Hub maintainer-index lookup misses the authored
32968 // `"alice"` entry, a future CLA-signer lookup matches a
32969 // visually-identical-but-byte-distinct identity. Mirrors
32970 // `chart_description_shape_rejects_each_unicode_invisible_format_codepoint`
32971 // on the peer predicate — both predicates route through the
32972 // same lifted `find_unicode_invisible_format` helper, so
32973 // dropping any one of the eight arms from the helper's match
32974 // would regress both peer test sweeps simultaneously at this
32975 // one structural floor. Covers the four paste-from-Word /
32976 // paste-from-BOM-editor / paste-from-typesetting shapes
32977 // (U+00AD / U+200B / U+2060 / U+FEFF) and the four math-
32978 // formula invisible operators (U+2061 FUNCTION APPLICATION /
32979 // U+2062 INVISIBLE TIMES / U+2063 INVISIBLE SEPARATOR /
32980 // U+2064 INVISIBLE PLUS — paste-from-MathJax / paste-from-
32981 // LaTeX-rendered-formula footgun).
32982 for (cp, name) in [
32983 ('\u{00AD}', "U+00AD"),
32984 ('\u{200B}', "U+200B"),
32985 ('\u{2060}', "U+2060"),
32986 ('\u{2061}', "U+2061"),
32987 ('\u{2062}', "U+2062"),
32988 ('\u{2063}', "U+2063"),
32989 ('\u{2064}', "U+2064"),
32990 ('\u{FEFF}', "U+FEFF"),
32991 ] {
32992 let s = format!("alice{cp}bob");
32993 let err = is_chart_maintainer_name_shape(&s)
32994 .err()
32995 .unwrap_or_else(|| panic!("chart maintainer name with {name} must be rejected"));
32996 assert!(
32997 err.contains(name),
32998 "chart maintainer name reason for {name} must name the codepoint verbatim; \
32999 got {err:?}"
33000 );
33001 assert!(
33002 err.contains("invisible-format")
33003 || err.contains("Cf-category")
33004 || err.contains("zero-width"),
33005 "chart maintainer name reason for {name} must name the invisible-format banner; \
33006 got {err:?}"
33007 );
33008 }
33009 }
33010
33011 #[test]
33012 fn chart_maintainer_name_shape_accepts_non_invisible_format_unicode() {
33013 // Positive control on the invisible-format arm: the predicate
33014 // must accept the legitimate-use codepoints the helper
33015 // deliberately excludes — U+200C ZWNJ / U+200D ZWJ (emoji ZWJ
33016 // sequences are canonical for modern maintainer-display names;
33017 // Indic / Persian script composition relies on ZWNJ to break
33018 // inappropriate ligatures) and U+200E LRM / U+200F RLM
33019 // (mixed-script direction hints are canonical for "Arabic name
33020 // with embedded ASCII email" shapes). Peer of
33021 // `chart_description_shape_accepts_non_invisible_format_unicode`
33022 // on the sibling YAML-plain-style-scalar surface.
33023 for s in [
33024 "François Dupont",
33025 "naïve <naive@example.com>",
33026 // Emoji ZWJ sequence (U+200D) — canonical multi-codepoint
33027 // emoji authoring shape.
33028 "Joe 👨\u{200D}💻 Developer",
33029 // ZWNJ (U+200C) — legitimate Persian / Indic composition.
33030 "Persian می\u{200C}باشد maintainer",
33031 // Bidi marks LRM / RLM — legitimate direction hints in
33032 // mixed-script maintainer names.
33033 "Arabic\u{200F}name <maintainer@example.com>",
33034 "ASCII\u{200E}embedded in RTL context",
33035 ] {
33036 is_chart_maintainer_name_shape(s).unwrap_or_else(|e| {
33037 panic!(
33038 "non-invisible-format Unicode chart maintainer name {s:?} must pass without \
33039 rejection: {e:?}"
33040 )
33041 });
33042 }
33043 }
33044
33045 #[test]
33046 fn find_unicode_bidi_override_pins_the_nine_codepoint_accepted_set() {
33047 // The shared helper's accepted set — pinned in one place so
33048 // every per-predicate caller (`is_chart_description_shape`,
33049 // `is_chart_maintainer_name_shape`, every future free-form-
33050 // prose surface) reads from one canonical accepted set. The
33051 // nine UAX #9 bidirectional-override / isolate format
33052 // codepoints in document order, plus negative controls on
33053 // bytes the helper must NOT reject (ASCII / non-bidi Unicode
33054 // letters / arrows / em-dash / RTL letters). A future shift
33055 // in the accepted set surfaces here as a single-source-of-
33056 // truth edit at this one test rather than across every
33057 // per-predicate per-arm sweep.
33058 for cp in [
33059 '\u{202A}', '\u{202B}', '\u{202C}', '\u{202D}', '\u{202E}', '\u{2066}', '\u{2067}',
33060 '\u{2068}', '\u{2069}',
33061 ] {
33062 let s = format!("a{cp}b");
33063 assert_eq!(
33064 find_unicode_bidi_override(&s),
33065 Some(cp),
33066 "helper must flag bidi override U+{:04X} on input {s:?}",
33067 cp as u32
33068 );
33069 }
33070 for s in [
33071 "alice",
33072 "Canonical Rust→wasm32-wasip2",
33073 "FIXME — describe this caixa",
33074 "François Dupont",
33075 "日本語の説明",
33076 "naïve",
33077 "שלום",
33078 "مرحبا",
33079 ] {
33080 assert_eq!(
33081 find_unicode_bidi_override(s),
33082 None,
33083 "helper must accept {s:?} (no bidi-override codepoint)"
33084 );
33085 }
33086 // Empty input — defensive precondition for the helper's
33087 // call-site contract on any future caller that doesn't gate
33088 // emptiness ahead of the scan.
33089 assert_eq!(find_unicode_bidi_override(""), None);
33090 }
33091
33092 #[test]
33093 fn find_unicode_line_break_pins_the_three_codepoint_accepted_set() {
33094 // The shared helper's accepted set — pinned in one place so
33095 // every per-predicate caller (`is_chart_description_shape`,
33096 // `is_chart_maintainer_name_shape`, every future free-form-
33097 // prose surface) reads from one canonical accepted set. The
33098 // three UAX #14 / YAML 1.1 §4.1 non-ASCII line-break
33099 // codepoints in document order, plus negative controls on
33100 // bytes the helper must NOT reject (ASCII text, Unicode
33101 // letters / arrows / em-dash / RTL letters, the canonical
33102 // non-line-break U+00A0 NBSP shape downstream YAML 1.2 +
33103 // Helm v3 + every chart-aware UI round-trip losslessly). A
33104 // future shift in the accepted set surfaces here as a
33105 // single-source-of-truth edit at this one test rather than
33106 // across every per-predicate per-arm sweep. Peer of
33107 // `find_unicode_bidi_override_pins_the_nine_codepoint_accepted_set`
33108 // on the sibling lifted-helper one trajectory earlier.
33109 for cp in ['\u{0085}', '\u{2028}', '\u{2029}'] {
33110 let s = format!("a{cp}b");
33111 assert_eq!(
33112 find_unicode_line_break(&s),
33113 Some(cp),
33114 "helper must flag line-break codepoint U+{:04X} on input {s:?}",
33115 cp as u32
33116 );
33117 }
33118 for s in [
33119 "alice",
33120 "Canonical Rust→wasm32-wasip2",
33121 "FIXME — describe this caixa",
33122 "François Dupont",
33123 "日本語の説明",
33124 "naïve",
33125 "שלום",
33126 "مرحبا",
33127 // U+00A0 NO-BREAK SPACE — UAX #14 class GL (Glue,
33128 // non-breaking) — must NOT be rejected: the canonical
33129 // unbreakable-space shape every typed maintainer-name
33130 // axis admits.
33131 "Acme\u{00A0}Corp",
33132 // U+0009 TAB and U+000A LF and U+000D CR — ASCII
33133 // line-break / whitespace bytes the per-byte arm on the
33134 // calling predicate already closes; the helper must NOT
33135 // claim them as its own (single-source-of-truth: ASCII
33136 // arms live in the per-byte loop, the helper closes the
33137 // non-ASCII codepoints).
33138 "alice\tbob",
33139 "alice\nbob",
33140 "alice\rbob",
33141 ] {
33142 assert_eq!(
33143 find_unicode_line_break(s),
33144 None,
33145 "helper must accept {s:?} (no non-ASCII line-break codepoint)"
33146 );
33147 }
33148 // Empty input — defensive precondition for the helper's
33149 // call-site contract on any future caller that doesn't gate
33150 // emptiness ahead of the scan.
33151 assert_eq!(find_unicode_line_break(""), None);
33152 }
33153
33154 #[test]
33155 fn find_unicode_invisible_format_pins_the_eight_codepoint_accepted_set() {
33156 // The shared helper's accepted set — pinned in one place so
33157 // every per-predicate caller (`is_chart_description_shape`,
33158 // `is_chart_maintainer_name_shape`, every future free-form-
33159 // prose surface) reads from one canonical accepted set. The
33160 // eight BMP Cf-category zero-width codepoints in document
33161 // order — the four paste-from-Word / paste-from-BOM-editor /
33162 // paste-from-typesetting-doc shapes (U+00AD SHY / U+200B ZWSP /
33163 // U+2060 WJ / U+FEFF ZWNBSP-BOM) and the four math-formula
33164 // invisible operators (U+2061 FUNCTION APPLICATION / U+2062
33165 // INVISIBLE TIMES / U+2063 INVISIBLE SEPARATOR / U+2064
33166 // INVISIBLE PLUS — paste-from-MathJax / paste-from-LaTeX-
33167 // rendered-formula / paste-from-InDesign-math-equation
33168 // shapes) — plus negative controls on codepoints the helper
33169 // must NOT reject — the deliberate exclusions: U+200C ZWNJ /
33170 // U+200D ZWJ (emoji ZWJ sequences + Indic / Persian script
33171 // composition) and U+200E LRM / U+200F RLM (mixed-script
33172 // direction hints). A future shift in the accepted set
33173 // surfaces here as a single-source-of-truth edit at this one
33174 // test rather than across every per-predicate per-arm sweep.
33175 // Third pin in the UAX-driven render-determinism trio (peer of
33176 // `find_unicode_bidi_override_pins_the_nine_codepoint_accepted_set`
33177 // on the visual-order axis and
33178 // `find_unicode_line_break_pins_the_three_codepoint_accepted_set`
33179 // on the single-line/multi-line axis).
33180 for cp in [
33181 '\u{00AD}', '\u{200B}', '\u{2060}', '\u{2061}', '\u{2062}', '\u{2063}', '\u{2064}',
33182 '\u{FEFF}',
33183 ] {
33184 let s = format!("a{cp}b");
33185 assert_eq!(
33186 find_unicode_invisible_format(&s),
33187 Some(cp),
33188 "helper must flag invisible-format codepoint U+{:04X} on input {s:?}",
33189 cp as u32
33190 );
33191 }
33192 for s in [
33193 "alice",
33194 "Canonical Rust→wasm32-wasip2",
33195 "FIXME — describe this caixa",
33196 "François Dupont",
33197 "日本語の説明",
33198 "naïve",
33199 "שלום",
33200 "مرحبا",
33201 // U+00A0 NO-BREAK SPACE — class GL (Glue), visible-width
33202 // codepoint — must NOT be claimed by the invisible-format
33203 // helper (the canonical unbreakable-space shape).
33204 "Acme\u{00A0}Corp",
33205 // U+200C ZWNJ — deliberately excluded (Indic / Persian
33206 // composition + emoji ZWJ-adjacent context).
33207 "می\u{200C}باشد",
33208 // U+200D ZWJ — deliberately excluded (emoji ZWJ
33209 // sequences are canonical: 👨💻 is MAN + ZWJ + LAPTOP).
33210 "Joe 👨\u{200D}💻 Developer",
33211 // U+200E LRM — deliberately excluded (direction-hint
33212 // mark, not a direction-override; legitimate in
33213 // mixed-script prose).
33214 "ASCII\u{200E}embedded",
33215 // U+200F RLM — deliberately excluded (mirror of LRM
33216 // on the RTL axis).
33217 "Arabic\u{200F}name",
33218 // Bidi-override codepoints (U+202A..U+202E, U+2066..U+2069)
33219 // — caught by the sibling `find_unicode_bidi_override`
33220 // helper, not this one (single-source-of-truth: each
33221 // helper closes exactly its class).
33222 "alice\u{202E}bob",
33223 // Line-break codepoints (U+0085, U+2028, U+2029) — caught
33224 // by the sibling `find_unicode_line_break` helper.
33225 "alice\u{2028}bob",
33226 ] {
33227 assert_eq!(
33228 find_unicode_invisible_format(s),
33229 None,
33230 "helper must accept {s:?} (no invisible-format codepoint in the four-codepoint set)"
33231 );
33232 }
33233 // Empty input — defensive precondition for the helper's
33234 // call-site contract on any future caller that doesn't gate
33235 // emptiness ahead of the scan.
33236 assert_eq!(find_unicode_invisible_format(""), None);
33237 }
33238
33239 // ── is_chart_keyword_shape — shared `:etiquetas` chart-keyword predicate ──
33240
33241 #[test]
33242 fn chart_keyword_shape_accepts_canonical_forms() {
33243 // Substrate-side pin: the predicate accepts every canonical
33244 // chart-keyword shape the `:etiquetas` axis carries. Drift
33245 // between this list and the per-axis
33246 // `manifest::tests::validate_etiquetas_accepts_canonical_shaped_forms`
33247 // positive-set sweep surfaces here — one source of truth for
33248 // the rule. Covers the example fixtures'
33249 // `:etiquetas` lists (`"example"`, `"aplicacao"`, `"mesh"`,
33250 // `"ecommerce"`, `"demo"`, `"infrastructure"`, `"aws"`,
33251 // `"akeyless"`, `"pangea-native"`) and the substrate-fixed
33252 // tags caixa-helm unions in at chart render (`"lareira"`,
33253 // `"wasm"`, `"tatara-lisp"`, `"caixa-servico"`).
33254 let example_fixture_tags = [
33255 "example",
33256 "aplicacao",
33257 "mesh",
33258 "ecommerce",
33259 "demo",
33260 "infrastructure",
33261 "aws",
33262 "akeyless",
33263 "pangea-native",
33264 "hello-world",
33265 "rust",
33266 "Foo",
33267 "Bar123",
33268 "x",
33269 "snake_case_tag",
33270 ];
33271 for s in example_fixture_tags
33272 .iter()
33273 .copied()
33274 .chain(LAREIRA_CHART_KEYWORDS.iter().copied())
33275 {
33276 is_chart_keyword_shape(s)
33277 .unwrap_or_else(|e| panic!("canonical chart keyword {s:?} must pass: {e:?}"));
33278 }
33279 }
33280
33281 #[test]
33282 fn lareira_chart_keywords_pins_canonical_ordered_set() {
33283 // Substrate-side canonical-set pin: byte-pins the
33284 // substrate-fixed `Chart.yaml` `keywords:` union caixa-helm's
33285 // `build_chart_yaml` folds into every rendered `lareira-<nome>`
33286 // chart on top of the caixa author's own `:etiquetas`. The
33287 // ordered array shape (`BTreeSet`-canonical ascii-alphabetical)
33288 // pins the same order the emitted `Chart.yaml` `keywords:`
33289 // sequence lists them after the intermediate
33290 // `BTreeSet<String>` fold at the caixa-helm emit site. A drift
33291 // between the canonical array and either the production emit
33292 // at `caixa-helm::build_chart_yaml` (the sole consumer) or
33293 // the peer positive-set sweep tests (this crate's
33294 // `chart_keyword_shape_accepts_canonical_forms` and
33295 // `manifest::tests::validate_etiquetas_accepts_canonical_shaped_forms`)
33296 // surfaces at this one substrate-side pin.
33297 assert_eq!(
33298 LAREIRA_CHART_KEYWORDS,
33299 &["caixa-servico", "lareira", "tatara-lisp", "wasm"],
33300 );
33301 }
33302
33303 #[test]
33304 fn lareira_chart_keywords_stays_btreeset_canonical_ordered() {
33305 // Substrate-side ordering pin: the array is
33306 // `BTreeSet`-canonical ascii-alphabetical, so its declared
33307 // order matches the shape the emitted `Chart.yaml`
33308 // `keywords:` sequence carries after
33309 // `caixa-helm::build_chart_yaml`'s intermediate
33310 // `BTreeSet<String>` fold — a future substrate-fixed keyword
33311 // addition that lands out-of-order (an `"opentelemetry"` entry
33312 // dropped before `"tatara-lisp"`, an `"lunatic"` entry dropped
33313 // after `"wasm"`) trips this pin at caixa-core build time
33314 // rather than surfacing as a byte-shape drift between the
33315 // array's declared order and the emitted `keywords:` sequence
33316 // order at chart render time downstream.
33317 let mut sorted: Vec<&str> = LAREIRA_CHART_KEYWORDS.to_vec();
33318 sorted.sort_unstable();
33319 assert_eq!(LAREIRA_CHART_KEYWORDS, sorted.as_slice());
33320 }
33321
33322 #[test]
33323 fn lareira_chart_keywords_each_entry_passes_is_chart_keyword_shape() {
33324 // Substrate-side shape-invariant pin: every substrate-fixed
33325 // chart-keyword entry must satisfy the per-`Chart.yaml`
33326 // `keywords:` entry validation predicate the substrate
33327 // enforces on the author-side `:etiquetas` axis — a future
33328 // substrate-fixed keyword addition that happens to break the
33329 // shape rule (a leading digit, an uppercase letter, a byte
33330 // over the `CHART_KEYWORD_MAX_LEN` cap, an ASCII whitespace,
33331 // a Unicode-invisible-format code point) trips this pin at
33332 // caixa-core build time rather than surfacing at
33333 // `helm lint` time on the rendered chart downstream.
33334 for keyword in LAREIRA_CHART_KEYWORDS {
33335 is_chart_keyword_shape(keyword).unwrap_or_else(|e| {
33336 panic!(
33337 "substrate-fixed chart keyword {keyword:?} must pass \
33338 is_chart_keyword_shape: {e:?}"
33339 )
33340 });
33341 }
33342 }
33343
33344 #[test]
33345 fn chart_keyword_shape_rejects_each_arm_with_substring_pinned_reason() {
33346 // Substrate-side diagnostic-shape pin: each arm surfaces its
33347 // own distinct reason substring. Pinned here so a future
33348 // reason-wording rephrase that drops any of these substrings
33349 // surfaces at this one place, not piecemeal across every
33350 // per-axis test sweep. Mirrors
33351 // `chart_maintainer_name_shape_rejects_each_arm_with_substring_pinned_reason`
33352 // on the peer predicate.
33353 for (s, needle) in [
33354 // Leading whitespace — paste-from-aligned-doc.
33355 (" mesh", "whitespace"),
33356 // Leading hyphen — kebab-leak footgun.
33357 ("-foo", "`-`"),
33358 // Leading underscore — snake-leak footgun.
33359 ("_foo", "`_`"),
33360 // Leading digit — paste-from-numbered-list footgun.
33361 ("1foo", "digit"),
33362 // Embedded whitespace — multi-tag-blob footgun.
33363 ("web service", "whitespace"),
33364 // Tab inside — tab-from-aligned-doc.
33365 ("mesh\thttp", "whitespace"),
33366 // Newline — paste-from-multiline-doc.
33367 ("mesh\nhttp", "newline"),
33368 // Carriage return — paste-from-Windows-CRLF-doc.
33369 ("mesh\rhttp", "carriage return"),
33370 // Comma — CSV-list-separator confusion.
33371 ("mesh,http", "`,`"),
33372 // Slash — path-separator confusion.
33373 ("caixa/servico", "`/`"),
33374 // Semicolon — alt-list-separator confusion.
33375 ("mesh;http", "`;`"),
33376 // Period — namespace / version-suffix confusion.
33377 ("http.1", "`.`"),
33378 // NUL byte — paste-from-binary-blob.
33379 ("mesh\x00http", "control character"),
33380 // DEL byte (0x7F).
33381 ("mesh\x7fhttp", "control character"),
33382 // Non-ASCII inside.
33383 ("café", "non-ASCII"),
33384 // Non-ASCII leading.
33385 ("éclair", "non-ASCII"),
33386 ] {
33387 let err = is_chart_keyword_shape(s)
33388 .err()
33389 .unwrap_or_else(|| panic!("chart keyword {s:?} must be rejected"));
33390 assert!(
33391 err.contains(needle),
33392 "chart keyword {s:?} reason must contain {needle:?}; got {err:?}"
33393 );
33394 }
33395 }
33396
33397 #[test]
33398 fn chart_keyword_shape_rejects_empty_defensively() {
33399 // The predicate is called from `crate::Caixa::validate_etiquetas`
33400 // only after the per-axis `EtiquetaEmpty` arm has fired at
33401 // validate time; re-checking here keeps the predicate usable
33402 // from any future call site without an empty-precondition
33403 // footgun. Same defensive empty-check `is_dns_1123_label`,
33404 // `is_gateway_api_http_path`, `is_wit_world_ref`,
33405 // `is_nats_subject`, `is_wasi_keyvalue_slot`,
33406 // `is_git_ref_name`, `is_git_oid`, `is_git_repo_url`,
33407 // `is_cargo_feature_name`, `is_spdx_expression_shape`,
33408 // `is_chart_description_shape`, and
33409 // `is_chart_maintainer_name_shape` carry at their call sites.
33410 let err = is_chart_keyword_shape("").unwrap_err();
33411 assert!(err.contains("empty"), "got: {err:?}");
33412 }
33413
33414 #[test]
33415 fn chart_keyword_shape_rejects_at_21_byte_boundary() {
33416 // The 20-byte cap pin — both the boundary-exceeding case and
33417 // the boundary-accepting case in one place, so a future cap
33418 // shift surfaces both arms simultaneously, mirroring the peer
33419 // cap-boundary pins
33420 // (`chart_maintainer_name_shape_rejects_at_129_byte_boundary`
33421 // on the 128-byte sibling,
33422 // `chart_description_shape_rejects_at_513_byte_boundary` on
33423 // the 512-byte sibling). Constructed as a single all-`a`
33424 // token so only the cap arm fires (20 `a` bytes is alphabet-
33425 // valid).
33426 let max_ok = "a".repeat(CHART_KEYWORD_MAX_LEN);
33427 assert_eq!(max_ok.len(), 20);
33428 is_chart_keyword_shape(&max_ok).unwrap();
33429 let too_long = "a".repeat(CHART_KEYWORD_MAX_LEN + 1);
33430 assert_eq!(too_long.len(), 21);
33431 let err = is_chart_keyword_shape(&too_long).unwrap_err();
33432 assert!(err.contains("20"), "got: {err:?}");
33433 assert!(err.contains("21"), "got: {err:?}");
33434 }
33435
33436 // ── shared predicate: find_ascii_whitespace_byte ──────────────────
33437 //
33438 // Pins the accepted / rejected set of the lifted ASCII byte-scan
33439 // every typed-magnitude codec in caixa-core calls (`parse_byte_size`
33440 // / `parse_duration` / `parse_millicores` / shared
33441 // `duration_codec` / `rate_limit_codec`). Peer of the non-ASCII
33442 // `find_non_ascii_whitespace_char` predicate below — together they
33443 // partition the full Unicode `White_Space` axis.
33444
33445 #[test]
33446 fn find_ascii_whitespace_byte_accepts_whitespace_free_strings() {
33447 // Complement-side pin: every whitespace-free canonical form
33448 // the renderers emit returns `None`.
33449 assert!(find_ascii_whitespace_byte("64MiB").is_none());
33450 assert!(find_ascii_whitespace_byte("30s").is_none());
33451 assert!(find_ascii_whitespace_byte("500m").is_none());
33452 assert!(find_ascii_whitespace_byte("100/s").is_none());
33453 assert!(find_ascii_whitespace_byte("").is_none());
33454 assert!(find_ascii_whitespace_byte("abcdef0123-_").is_none());
33455 // Non-whitespace ASCII bytes near the whitespace range stay
33456 // accepted (the predicate must not over-fire on peer control
33457 // bytes like VT `0x0B` which POSIX admits but WhatWG excludes).
33458 assert!(find_ascii_whitespace_byte("\u{0B}64MiB").is_none());
33459 }
33460
33461 #[test]
33462 fn find_ascii_whitespace_byte_flags_space() {
33463 // Space (`0x20`) — the canonical paste-from-shell-history /
33464 // paste-from-aligned-doc drift class.
33465 assert_eq!(find_ascii_whitespace_byte(" 64MiB"), Some(0x20));
33466 assert_eq!(find_ascii_whitespace_byte("30s "), Some(0x20));
33467 assert_eq!(find_ascii_whitespace_byte("100 /s"), Some(0x20));
33468 }
33469
33470 #[test]
33471 fn find_ascii_whitespace_byte_flags_tab_lf_ff_cr() {
33472 // Tab (`0x09`), LF (`0x0A`), FF (`0x0C`), CR (`0x0D`) —
33473 // the remaining four bytes in the WhatWG ASCII whitespace
33474 // set the predicate covers, verbatim.
33475 assert_eq!(find_ascii_whitespace_byte("\t500m"), Some(0x09));
33476 assert_eq!(find_ascii_whitespace_byte("30s\n"), Some(0x0A));
33477 assert_eq!(find_ascii_whitespace_byte("\x0c64MiB"), Some(0x0C));
33478 assert_eq!(find_ascii_whitespace_byte("100/s\r"), Some(0x0D));
33479 }
33480
33481 #[test]
33482 fn find_ascii_whitespace_byte_returns_first_match_byte_order() {
33483 // The predicate returns the *first* offending byte in scan
33484 // order — pinning this so a self-locating codec diagnostic can
33485 // report "position 0" / "position N" verbatim without the
33486 // predicate ever reordering matches.
33487 assert_eq!(find_ascii_whitespace_byte(" \t30s"), Some(0x20));
33488 assert_eq!(find_ascii_whitespace_byte("\t 30s"), Some(0x09));
33489 }
33490
33491 #[test]
33492 fn find_ascii_whitespace_byte_does_not_flag_non_ascii_whitespace() {
33493 // NBSP (`\u{00A0}`), LINE SEPARATOR (`\u{2028}`), IDEOGRAPHIC
33494 // SPACE (`\u{3000}`) — none of their UTF-8 bytes match
33495 // `u8::is_ascii_whitespace` (NBSP's `0xC2 0xA0`, LINE
33496 // SEPARATOR's `0xE2 0x80 0xA8`, IDEOGRAPHIC SPACE's `0xE3
33497 // 0x80 0x80` all sit above `0x7F` or well outside the
33498 // {`0x09`, `0x0A`, `0x0C`, `0x0D`, `0x20`} set). Pinning this
33499 // exclusion so the peer `find_non_ascii_whitespace_char`
33500 // predicate remains strictly complementary — the two together
33501 // partition the full Unicode `White_Space` axis with zero
33502 // overlap.
33503 assert!(find_ascii_whitespace_byte("\u{00A0}64MiB").is_none());
33504 assert!(find_ascii_whitespace_byte("30s\u{2028}").is_none());
33505 assert!(find_ascii_whitespace_byte("64MiB\u{3000}").is_none());
33506 }
33507
33508 // ── shared predicate: find_non_ascii_whitespace_char ──────────────────
33509 //
33510 // Pins the accepted / rejected set of the lifted predicate every
33511 // typed-magnitude codec in caixa-core calls (byte-size / duration /
33512 // shared duration / rate-limit). The predicate's job is exclusively
33513 // to name the strictly-complementary drift class the peer
33514 // `u8::is_ascii_whitespace` byte-scan cannot see — the non-ASCII
33515 // Unicode `White_Space` subset that `str::trim` silently swallows.
33516
33517 #[test]
33518 fn find_non_ascii_whitespace_char_accepts_ascii_only_strings() {
33519 // Complement-side pin: every ASCII-only string (canonical form
33520 // and ASCII whitespace alike) returns `None`. The predicate is
33521 // strictly complementary to the per-codec ASCII byte-scan; it
33522 // must not shadow its coverage.
33523 assert!(find_non_ascii_whitespace_char("64MiB").is_none());
33524 assert!(find_non_ascii_whitespace_char("30s").is_none());
33525 assert!(find_non_ascii_whitespace_char("100/s").is_none());
33526 assert!(find_non_ascii_whitespace_char(" \t\n").is_none());
33527 assert!(find_non_ascii_whitespace_char("").is_none());
33528 // Non-whitespace ASCII byte peers stay accepted too.
33529 assert!(find_non_ascii_whitespace_char("abcdef0123-_").is_none());
33530 }
33531
33532 #[test]
33533 fn find_non_ascii_whitespace_char_flags_nbsp() {
33534 // `\u{00A0}` NBSP — the canonical paste-from-typography /
33535 // paste-from-word-processor drift class.
33536 assert_eq!(
33537 find_non_ascii_whitespace_char("64\u{00A0}MiB"),
33538 Some('\u{00A0}')
33539 );
33540 assert_eq!(find_non_ascii_whitespace_char("\u{00A0}"), Some('\u{00A0}'));
33541 }
33542
33543 #[test]
33544 fn find_non_ascii_whitespace_char_flags_line_and_paragraph_separators() {
33545 // LINE SEPARATOR (`\u{2028}`) / PARAGRAPH SEPARATOR
33546 // (`\u{2029}`) — the paste-from-web-doc drift class every
33547 // RTF/HTML → plain-text conversion emits at soft-wrap
33548 // boundaries.
33549 assert_eq!(
33550 find_non_ascii_whitespace_char("30s\u{2028}"),
33551 Some('\u{2028}')
33552 );
33553 assert_eq!(
33554 find_non_ascii_whitespace_char("30s\u{2029}"),
33555 Some('\u{2029}')
33556 );
33557 }
33558
33559 #[test]
33560 fn find_non_ascii_whitespace_char_flags_ideographic_space() {
33561 // IDEOGRAPHIC SPACE (`\u{3000}`) — the CJK-typography drift
33562 // class every full-width IME auto-widens ASCII space to on
33563 // Japanese / Chinese input methods.
33564 assert_eq!(
33565 find_non_ascii_whitespace_char("64MiB\u{3000}"),
33566 Some('\u{3000}')
33567 );
33568 }
33569
33570 #[test]
33571 fn find_non_ascii_whitespace_char_does_not_flag_zwsp_or_bom() {
33572 // BOM (`\u{FEFF}`, ZERO WIDTH NO-BREAK SPACE) and ZWSP
33573 // (`\u{200B}`, ZERO WIDTH SPACE) — both have
33574 // `char::is_whitespace() == false` per the Unicode
33575 // `White_Space` property, so `str::trim` does *not* strip
33576 // either. Both currently land on the downstream
33577 // `BadByteMagnitude` / `BadDurationMagnitude` arm at parse time
33578 // with the byte-shape diagnostic intact; the render-determinism
33579 // contract is unbroken on those inputs today. This test pins
33580 // the predicate's exclusion so a future widening that starts
33581 // flagging BOM / ZWSP here surfaces as a test failure rather
33582 // than a silent over-fire on a class the downstream arm
33583 // already closes.
33584 assert!(find_non_ascii_whitespace_char("\u{FEFF}64MiB").is_none());
33585 assert!(find_non_ascii_whitespace_char("\u{200B}30s").is_none());
33586 }
33587
33588 // ── shared predicate: is_leading_zero_padded_magnitude ──────────────
33589 //
33590 // Pins the accepted / rejected set of the lifted leading-zero
33591 // predicate every typed-magnitude codec in caixa-core calls
33592 // (`parse_byte_size` / `parse_duration` / `parse_millicores` /
33593 // shared `duration_codec` / `rate_limit_codec`). Same lifted-
33594 // source-of-truth discipline the peer whitespace predicates
33595 // (`find_ascii_whitespace_byte` / `find_non_ascii_whitespace_char`)
33596 // carry — drift between any two codec sites' rejection set becomes
33597 // a single-edit fix at this predicate.
33598
33599 #[test]
33600 fn is_leading_zero_padded_magnitude_accepts_canonical_forms() {
33601 // Complement-side pin: every canonical form the typed-magnitude
33602 // `render_*` canonicalizers emit — the single-byte `"0"` case
33603 // and every non-leading-zero magnitude — returns `false`.
33604 assert!(!is_leading_zero_padded_magnitude("0"));
33605 assert!(!is_leading_zero_padded_magnitude("1"));
33606 assert!(!is_leading_zero_padded_magnitude("64"));
33607 assert!(!is_leading_zero_padded_magnitude("500"));
33608 assert!(!is_leading_zero_padded_magnitude("1024"));
33609 assert!(!is_leading_zero_padded_magnitude("999999"));
33610 // Empty magnitude is not a leading-zero shape either — the
33611 // upstream `digit_only` gate at each codec site refuses empty
33612 // magnitudes on its own arm before this predicate is consulted.
33613 assert!(!is_leading_zero_padded_magnitude(""));
33614 // Non-digit-only bodies are outside the predicate's scope — the
33615 // upstream `digit_only` gate refuses them with its own
33616 // `NonInteger*` / `Bad*` diagnostic; this predicate is invoked
33617 // only after that gate accepts.
33618 assert!(!is_leading_zero_padded_magnitude("a"));
33619 assert!(!is_leading_zero_padded_magnitude("1.5"));
33620 }
33621
33622 #[test]
33623 fn is_leading_zero_padded_magnitude_flags_two_byte_leading_zero() {
33624 // The minimal leading-zero drift shape: two-byte magnitude
33625 // starting with `'0'` — `"00"` / `"01"` / `"09"`. Every one
33626 // round-trips through the peer codecs' `render_*` to the
33627 // leading-zero-stripped form (`"0"` / `"1"` / `"9"`).
33628 assert!(is_leading_zero_padded_magnitude("00"));
33629 assert!(is_leading_zero_padded_magnitude("01"));
33630 assert!(is_leading_zero_padded_magnitude("09"));
33631 }
33632
33633 #[test]
33634 fn is_leading_zero_padded_magnitude_flags_multi_byte_leading_zero() {
33635 // The canonical paste-from-fixed-width-alignment /
33636 // paste-from-columnar-report drift class each codec's
33637 // `render_*` emits the stripped form for: `"0064"` (byte-size
33638 // magnitude), `"030"` (duration magnitude), `"0500"`
33639 // (millicores magnitude), `"0100"` (rate-limit magnitude),
33640 // `"01024"` (multi-digit byte-size magnitude).
33641 assert!(is_leading_zero_padded_magnitude("0064"));
33642 assert!(is_leading_zero_padded_magnitude("030"));
33643 assert!(is_leading_zero_padded_magnitude("0500"));
33644 assert!(is_leading_zero_padded_magnitude("0100"));
33645 assert!(is_leading_zero_padded_magnitude("01024"));
33646 // All-zeros multi-byte magnitude — `"000"` / `"0000"` — every
33647 // one round-trips to `"0"`. The single-byte `"0"` case is the
33648 // canonical zero and stays accepted; the multi-byte all-zero
33649 // shape is leading-zero drift.
33650 assert!(is_leading_zero_padded_magnitude("000"));
33651 assert!(is_leading_zero_padded_magnitude("0000"));
33652 }
33653
33654 #[test]
33655 fn is_leading_zero_padded_magnitude_pins_single_zero_boundary() {
33656 // The single-byte magnitude `"0"` is the canonical zero the
33657 // peer codecs' `render_*` canonicalizers emit for the zero
33658 // value verbatim (`render_byte_size(0)` = `"0"`,
33659 // `render_duration(Duration::ZERO)` = `"0s"` with `"0"` as
33660 // the magnitude, `render_millicores(0)` = `"0m"` with `"0"`
33661 // as the magnitude, `RateLimit::render` for rate=0 = `"0/s"`
33662 // with `"0"` as the magnitude). Pinning this boundary so a
33663 // future widening that starts flagging the single-byte `"0"`
33664 // here surfaces as a test failure rather than a silent break
33665 // of the codec-layer / typed-validate-layer partition — the
33666 // semantic-zero gates at the typed-validate layer above
33667 // (`LimitsError::MemoryZero`, `LimitsError::WallClockZero`,
33668 // `LimitsError::CpuZero`, `SupervisorError::ZeroRestartWindow`,
33669 // `AplicacaoError::PolicyTimeoutZero` /
33670 // `PolicyCircuitBreakerWindowZero` / `PolicyRateLimitZero`)
33671 // are what refuse zero-magnitude authoring, not this codec-
33672 // layer predicate.
33673 assert!(!is_leading_zero_padded_magnitude("0"));
33674 }
33675
33676 // ── shared predicate: is_digit_only_magnitude ───────────────────────
33677 //
33678 // Pins the accepted / rejected set of the lifted digit-only
33679 // predicate every typed-magnitude codec in caixa-core calls
33680 // (`parse_byte_size` / `parse_duration` / `parse_millicores` /
33681 // shared `duration_codec` / `rate_limit_codec`). Same lifted-
33682 // source-of-truth discipline the peer canonical-form predicates
33683 // (`find_ascii_whitespace_byte` / `find_non_ascii_whitespace_char`
33684 // / `is_leading_zero_padded_magnitude`) carry — drift between any
33685 // two codec sites' rejection set becomes a single-edit fix at
33686 // this predicate.
33687
33688 #[test]
33689 fn is_digit_only_magnitude_accepts_canonical_forms() {
33690 // Complement-side pin: every canonical form the typed-magnitude
33691 // `render_*` canonicalizers emit — the single-byte `"0"` case
33692 // and every non-zero non-leading-zero magnitude — returns
33693 // `true`.
33694 assert!(is_digit_only_magnitude("0"));
33695 assert!(is_digit_only_magnitude("1"));
33696 assert!(is_digit_only_magnitude("64"));
33697 assert!(is_digit_only_magnitude("500"));
33698 assert!(is_digit_only_magnitude("1024"));
33699 assert!(is_digit_only_magnitude("999999"));
33700 }
33701
33702 #[test]
33703 fn is_digit_only_magnitude_flags_empty_magnitude() {
33704 // Defense-in-depth: the empty string is non-digit-only per the
33705 // predicate's contract, so a future codec reaching for this
33706 // predicate before landing its own upstream empty-magnitude
33707 // arm still routes empty input to the non-canonical branch
33708 // rather than silently accepting it via the vacuous
33709 // `bytes().all(_)` truth on the empty byte-slice.
33710 assert!(!is_digit_only_magnitude(""));
33711 }
33712
33713 #[test]
33714 fn is_digit_only_magnitude_flags_leading_sign() {
33715 // The paste-from-signed-report drift class every codec's
33716 // `render_*` emits the unsigned form for. On current Rust
33717 // `u64::from_str` / `u32::from_str` permissively accept a
33718 // leading `+` (`"+500"` → 500), so `"+30"`, `"+500"`, `"+100"`
33719 // survive the parser and round-trip through `render_*` to the
33720 // sign-stripped form (`"30"`, `"500"`, `"100"`) — a *different*
33721 // canonical string on the next emit, breaking the THEORY.md
33722 // Part V render-determinism contract. The digit-only gate is
33723 // what closes the leading-sign class at each codec site.
33724 assert!(!is_digit_only_magnitude("+30"));
33725 assert!(!is_digit_only_magnitude("+500"));
33726 assert!(!is_digit_only_magnitude("+100"));
33727 assert!(!is_digit_only_magnitude("-30"));
33728 assert!(!is_digit_only_magnitude("-1"));
33729 }
33730
33731 #[test]
33732 fn is_digit_only_magnitude_flags_fractional_and_decimal() {
33733 // The paste-from-floating-point-source drift class every
33734 // codec's `render_*` emits the integer form for. On the peer
33735 // duration codec the parser accepts `f64`-shaped magnitudes
33736 // (`"1.5s"` → 1500ms → `"1500ms"`, `"1.0s"` → 1s → `"1s"`,
33737 // `"0.5m"` → 30s → `"30s"`) — a *different* canonical string
33738 // on the next emit, breaking the THEORY.md Part V render-
33739 // determinism contract. The digit-only gate closes the
33740 // decimal-point / fractional / exponent class at each codec
33741 // site.
33742 assert!(!is_digit_only_magnitude("1.5"));
33743 assert!(!is_digit_only_magnitude("1.0"));
33744 assert!(!is_digit_only_magnitude("0.5"));
33745 assert!(!is_digit_only_magnitude("1e3"));
33746 assert!(!is_digit_only_magnitude(".5"));
33747 assert!(!is_digit_only_magnitude("5."));
33748 }
33749
33750 #[test]
33751 fn is_digit_only_magnitude_flags_alphabetic_and_symbol_bytes() {
33752 // Complement-side pin on the "garbage" branch: alphabetic
33753 // bytes / symbol bytes / whitespace bytes each land on the
33754 // non-digit-only side. At the codec site the downstream
33755 // "non-canonical-but-numeric vs garbage" partition surfaces
33756 // these with the narrower `Bad*` diagnostic; here the
33757 // predicate simply reports `false`.
33758 assert!(!is_digit_only_magnitude("a"));
33759 assert!(!is_digit_only_magnitude("64a"));
33760 assert!(!is_digit_only_magnitude("6_4"));
33761 assert!(!is_digit_only_magnitude("64 "));
33762 assert!(!is_digit_only_magnitude(" 64"));
33763 }
33764
33765 #[test]
33766 fn is_digit_only_magnitude_pins_leading_zero_boundary() {
33767 // The leading-zero-padded magnitude shape stays inside the
33768 // digit-only accepted set at this predicate — every byte is
33769 // an ASCII digit. The peer
33770 // [`is_leading_zero_padded_magnitude`] predicate closes the
33771 // leading-zero drift class on a separate, strictly-later arm
33772 // at each codec site. Pinning this partition so a future
33773 // widening that collapses the two arms surfaces as a test
33774 // failure rather than a silent break of the two-predicate
33775 // codec-layer discipline.
33776 assert!(is_digit_only_magnitude("00"));
33777 assert!(is_digit_only_magnitude("0064"));
33778 assert!(is_digit_only_magnitude("0500"));
33779 }
33780
33781 // ── require_positive_bounded_{u32,u64} ──────────────────────────────
33782
33783 #[derive(Debug, PartialEq, Eq)]
33784 enum TestErr {
33785 Zero,
33786 Cap(u64),
33787 }
33788
33789 #[test]
33790 fn require_positive_bounded_u32_accepts_in_range() {
33791 assert_eq!(
33792 require_positive_bounded_u32::<TestErr>(
33793 1,
33794 10,
33795 || TestErr::Zero,
33796 |v| TestErr::Cap(u64::from(v))
33797 ),
33798 Ok(())
33799 );
33800 assert_eq!(
33801 require_positive_bounded_u32::<TestErr>(
33802 10,
33803 10,
33804 || TestErr::Zero,
33805 |v| TestErr::Cap(u64::from(v))
33806 ),
33807 Ok(())
33808 );
33809 assert_eq!(
33810 require_positive_bounded_u32::<TestErr>(
33811 5,
33812 10,
33813 || TestErr::Zero,
33814 |v| TestErr::Cap(u64::from(v))
33815 ),
33816 Ok(())
33817 );
33818 }
33819
33820 #[test]
33821 fn require_positive_bounded_u32_rejects_zero_with_self_locating_diagnostic() {
33822 // The zero-floor arm strictly precedes the cap arm — a value of
33823 // 0 surfaces the `on_zero` callback's discriminator (which every
33824 // per-axis error variant documents an omit-axis remediation for),
33825 // never the `on_cap_exceeded` callback (which would misframe
33826 // "0 > cap == false" as an above-cap value).
33827 assert_eq!(
33828 require_positive_bounded_u32::<TestErr>(
33829 0,
33830 10,
33831 || TestErr::Zero,
33832 |v| TestErr::Cap(u64::from(v))
33833 ),
33834 Err(TestErr::Zero)
33835 );
33836 // Pin the ordering under the degenerate cap == 0 boundary: even
33837 // when the cap itself is 0 (never valid for a positive-bounded
33838 // axis in production, but pins the ordering contract), 0 routes
33839 // through the zero arm — not the cap arm.
33840 assert_eq!(
33841 require_positive_bounded_u32::<TestErr>(
33842 0,
33843 0,
33844 || TestErr::Zero,
33845 |v| TestErr::Cap(u64::from(v))
33846 ),
33847 Err(TestErr::Zero)
33848 );
33849 }
33850
33851 #[test]
33852 fn require_positive_bounded_u32_rejects_above_cap_with_value_threaded() {
33853 assert_eq!(
33854 require_positive_bounded_u32::<TestErr>(
33855 11,
33856 10,
33857 || TestErr::Zero,
33858 |v| TestErr::Cap(u64::from(v))
33859 ),
33860 Err(TestErr::Cap(11))
33861 );
33862 assert_eq!(
33863 require_positive_bounded_u32::<TestErr>(
33864 u32::MAX,
33865 10,
33866 || TestErr::Zero,
33867 |v| TestErr::Cap(u64::from(v))
33868 ),
33869 Err(TestErr::Cap(u64::from(u32::MAX)))
33870 );
33871 }
33872
33873 #[test]
33874 fn require_positive_bounded_u64_accepts_in_range() {
33875 assert_eq!(
33876 require_positive_bounded_u64::<TestErr>(1, 10, || TestErr::Zero, TestErr::Cap),
33877 Ok(())
33878 );
33879 assert_eq!(
33880 require_positive_bounded_u64::<TestErr>(10, 10, || TestErr::Zero, TestErr::Cap),
33881 Ok(())
33882 );
33883 }
33884
33885 #[test]
33886 fn require_positive_bounded_u64_rejects_zero_and_above_cap() {
33887 assert_eq!(
33888 require_positive_bounded_u64::<TestErr>(0, 10, || TestErr::Zero, TestErr::Cap),
33889 Err(TestErr::Zero)
33890 );
33891 assert_eq!(
33892 require_positive_bounded_u64::<TestErr>(11, 10, || TestErr::Zero, TestErr::Cap),
33893 Err(TestErr::Cap(11))
33894 );
33895 assert_eq!(
33896 require_positive_bounded_u64::<TestErr>(u64::MAX, 10, || TestErr::Zero, TestErr::Cap),
33897 Err(TestErr::Cap(u64::MAX))
33898 );
33899 }
33900
33901 // ── require_positive_canonical_bounded_duration ─────────────────────
33902
33903 #[derive(Debug, PartialEq, Eq)]
33904 enum DurationTestErr {
33905 Zero,
33906 NotCanonical(Duration),
33907 Cap(Duration),
33908 }
33909
33910 #[test]
33911 fn require_positive_canonical_bounded_duration_accepts_in_range_canonical_values() {
33912 // Every canonical integer-millisecond `Duration` in
33913 // `1ms..=cap` — the shared accepted set every typed-`Duration`
33914 // consumer inherits — must pass the gate. Pin the canonical
33915 // set here so a future tightening surfaces as a test failure
33916 // rather than a silent narrowing at one of the four consumer
33917 // sites (`:politicas :timeout`, `:circuit-breaker :window`,
33918 // `:limits :wall-clock`, `:supervisor :restart-window`).
33919 let cap = Duration::from_secs(3600); // matches the 1h peer caps
33920 for value in [
33921 Duration::from_millis(1),
33922 Duration::from_millis(500),
33923 Duration::from_millis(1500),
33924 Duration::from_secs(30),
33925 Duration::from_secs(60),
33926 cap,
33927 ] {
33928 assert_eq!(
33929 require_positive_canonical_bounded_duration::<DurationTestErr>(
33930 value,
33931 cap,
33932 || DurationTestErr::Zero,
33933 DurationTestErr::NotCanonical,
33934 DurationTestErr::Cap,
33935 ),
33936 Ok(()),
33937 "canonical in-range value {value:?} must pass the gate",
33938 );
33939 }
33940 }
33941
33942 #[test]
33943 fn require_positive_canonical_bounded_duration_rejects_zero_before_canonical_and_cap() {
33944 // The zero-floor arm strictly precedes the canonical-form and
33945 // cap arms — `Duration::ZERO` (which has `subsec_nanos() == 0`
33946 // and would pass the canonical-form predicate; and would pass
33947 // the cap arm since 0 ≤ cap) routes through the zero arm so
33948 // the caller's self-locating `on_zero` diagnostic (every
33949 // per-axis error variant documents an omit-axis remediation
33950 // for) is surfaced, not the misleading no-op the two later
33951 // arms would return.
33952 let cap = Duration::from_secs(3600);
33953 assert_eq!(
33954 require_positive_canonical_bounded_duration::<DurationTestErr>(
33955 Duration::ZERO,
33956 cap,
33957 || DurationTestErr::Zero,
33958 DurationTestErr::NotCanonical,
33959 DurationTestErr::Cap,
33960 ),
33961 Err(DurationTestErr::Zero),
33962 );
33963 // The degenerate `cap == Duration::ZERO` boundary: `Duration::ZERO`
33964 // still routes through the zero arm — the ordering contract holds
33965 // even when the cap itself is zero (never a valid production cap
33966 // for a positive-bounded axis, but pins the arm ordering).
33967 assert_eq!(
33968 require_positive_canonical_bounded_duration::<DurationTestErr>(
33969 Duration::ZERO,
33970 Duration::ZERO,
33971 || DurationTestErr::Zero,
33972 DurationTestErr::NotCanonical,
33973 DurationTestErr::Cap,
33974 ),
33975 Err(DurationTestErr::Zero),
33976 );
33977 }
33978
33979 #[test]
33980 fn require_positive_canonical_bounded_duration_rejects_sub_millisecond_before_cap() {
33981 // The canonical-form arm strictly precedes the cap arm — a
33982 // `Duration` that is *both* sub-millisecond and above-cap must
33983 // surface the more fundamental round-trip-shape diagnostic
33984 // first (the cap arm's `1ms..=<cap>` remediation prose would
33985 // be misleading when no integer-ms form of the offending
33986 // value exists). Pin the ordering across the value grid.
33987 let cap = Duration::from_secs(1);
33988 for value in [
33989 Duration::from_micros(1),
33990 Duration::from_micros(500),
33991 Duration::from_micros(1500),
33992 Duration::from_nanos(1),
33993 Duration::from_nanos(999_999),
33994 Duration::from_nanos(1_000_001),
33995 // Sub-millisecond *and* above-cap: canonical-form arm wins.
33996 cap + Duration::from_nanos(1),
33997 ] {
33998 let result = require_positive_canonical_bounded_duration::<DurationTestErr>(
33999 value,
34000 cap,
34001 || DurationTestErr::Zero,
34002 DurationTestErr::NotCanonical,
34003 DurationTestErr::Cap,
34004 );
34005 assert_eq!(
34006 result,
34007 Err(DurationTestErr::NotCanonical(value)),
34008 "sub-millisecond {value:?} must surface NotCanonical before Cap",
34009 );
34010 }
34011 }
34012
34013 #[test]
34014 fn require_positive_canonical_bounded_duration_rejects_above_cap_with_value_threaded() {
34015 // The cap arm surfaces the offending value verbatim so the
34016 // caller's `on_cap_exceeded` variant threads it into its
34017 // discriminator field (`timeout` / `window` / `wall_clock`).
34018 // The value grid covers the canonical `<n>ms` / `<n>s`
34019 // integer-millisecond shape past the 1h cap so the arm ordering
34020 // (canonical-form first) doesn't intercept these values.
34021 let cap = Duration::from_secs(3600);
34022 for value in [
34023 cap + Duration::from_millis(1),
34024 cap + Duration::from_secs(1),
34025 Duration::from_secs(24 * 3600), // 24h — canonical string
34026 Duration::from_secs(7 * 24 * 3600), // 7d
34027 ] {
34028 assert_eq!(
34029 require_positive_canonical_bounded_duration::<DurationTestErr>(
34030 value,
34031 cap,
34032 || DurationTestErr::Zero,
34033 DurationTestErr::NotCanonical,
34034 DurationTestErr::Cap,
34035 ),
34036 Err(DurationTestErr::Cap(value)),
34037 "above-cap canonical value {value:?} must thread through the cap arm",
34038 );
34039 }
34040 }
34041
34042 // ── require_valid_versao_requirement ────────────────────────────────
34043
34044 #[derive(Debug, PartialEq, Eq)]
34045 enum VersaoTestErr {
34046 Empty,
34047 Invalid(String),
34048 }
34049
34050 #[test]
34051 fn require_valid_versao_requirement_accepts_canonical_forms() {
34052 // Every Cargo-shaped requirement string the substrate accepts on
34053 // any `:versao` axis (`:deps`, `:membros`, `:children`) must pass
34054 // the shared gate — pin the canonical set here so a future
34055 // tightening surfaces as a test failure rather than a silent
34056 // narrowing at one of the three consumer sites. Same accepted set
34057 // as `accepts_canonical_membro_versao_forms` /
34058 // `accepts_canonical_dep_versao_forms` on the sibling per-axis
34059 // pins.
34060 for form in [
34061 "^0.1", // caret — minor-range pin (the most common shape)
34062 "~0.1.2", // tilde — patch-range pin
34063 "0.1.0", // exact — single-version pin
34064 "*", // wildcard — explicitly any-version (VersionReq::STAR)
34065 ">=0.1, <2", // multi-range — comma-separated comparators
34066 ] {
34067 assert_eq!(
34068 require_valid_versao_requirement::<VersaoTestErr>(
34069 form,
34070 || VersaoTestErr::Empty,
34071 VersaoTestErr::Invalid,
34072 ),
34073 Ok(()),
34074 "canonical form {form:?} must pass the gate",
34075 );
34076 }
34077 }
34078
34079 #[test]
34080 fn require_valid_versao_requirement_rejects_empty_before_parse() {
34081 // The empty-first arm strictly precedes the parse arm. Without
34082 // this arm the parser silently widens `""` to
34083 // `VersionReq { comparators: [] }` (semantically `*`) — a
34084 // "silent widening" footgun the three consumer sites each
34085 // documented in their `MembroVersaoEmpty` / `EmptyChildVersion` /
34086 // `VersaoEmpty` variants and now inherit by construction.
34087 assert_eq!(
34088 require_valid_versao_requirement::<VersaoTestErr>(
34089 "",
34090 || VersaoTestErr::Empty,
34091 VersaoTestErr::Invalid,
34092 ),
34093 Err(VersaoTestErr::Empty),
34094 );
34095 }
34096
34097 #[test]
34098 fn require_valid_versao_requirement_rejects_malformed_with_reason_threaded() {
34099 // The canonical malformed-shape set the three consumer sites
34100 // formerly each re-tested inline. The gate threads the
34101 // parser's `to_string()` output through as the invalid arm's
34102 // `reason:` verbatim — the field the three sibling error
34103 // variants (`{Dep,Membro,Child}VersaoInvalid.reason`) each
34104 // carry to the author's remediation prose.
34105 for bad in [
34106 "^^0.1", // doubled-caret typo
34107 "v0.1", // git-tag-shape leaking into requirement slot
34108 "abc", // gibberish
34109 "~~", // stacked-operator gibberish
34110 ] {
34111 let result = require_valid_versao_requirement::<VersaoTestErr>(
34112 bad,
34113 || VersaoTestErr::Empty,
34114 VersaoTestErr::Invalid,
34115 );
34116 match result {
34117 Err(VersaoTestErr::Invalid(reason)) => {
34118 assert!(
34119 !reason.is_empty(),
34120 "invalid arm must thread a non-empty reason for {bad:?}",
34121 );
34122 }
34123 other => panic!("expected Invalid for {bad:?}, got {other:?}"),
34124 }
34125 }
34126 }
34127
34128 // ── require_valid_dns_1123_label ────────────────────────────────────
34129
34130 #[derive(Debug, PartialEq, Eq)]
34131 enum LabelTestErr {
34132 Empty,
34133 Invalid(String),
34134 }
34135
34136 #[test]
34137 fn require_valid_dns_1123_label_accepts_canonical_forms() {
34138 // Every DNS-1123-label-shaped Servico-name reference the substrate
34139 // accepts on any name axis (`:membros :caixa`, `:placement :clusters`,
34140 // `:placement :affinity`, `:contratos :de`/`:para`, `:entrada :para`,
34141 // `:children :caixa`, `:nome`, `:upgrade-from :module`) must pass
34142 // the shared gate — pin the canonical set here so a future
34143 // tightening surfaces as a test failure rather than a silent
34144 // narrowing at one of the eight consumer sites. Same accepted set
34145 // as the sibling per-axis DNS-1123-label pins already carry.
34146 for form in [
34147 "hello-rio", // canonical dashed
34148 "cart", // single-token
34149 "rio-1", // trailing digit
34150 "1-rio", // leading digit
34151 "a", // one byte
34152 &"a".repeat(DNS_1123_LABEL_MAX_LEN), // max length exact
34153 ] {
34154 assert_eq!(
34155 require_valid_dns_1123_label::<LabelTestErr>(
34156 form,
34157 || LabelTestErr::Empty,
34158 LabelTestErr::Invalid,
34159 ),
34160 Ok(()),
34161 "canonical form {form:?} must pass the gate",
34162 );
34163 }
34164 }
34165
34166 #[test]
34167 fn require_valid_dns_1123_label_rejects_empty_before_shape() {
34168 // The empty-first arm strictly precedes the shape arm so a
34169 // literal `""` surfaces each per-axis error variant's narrower
34170 // self-locating `_Empty` diagnostic rather than the shared
34171 // predicate's generic "must not be empty" prose the shape arm
34172 // would thread through — the same "misframed generic diagnostic"
34173 // footgun the peer [`require_valid_versao_requirement`] closes
34174 // on its empty arm. The eight consumer sites each documented
34175 // this ordering in their `MembroCaixaEmpty` / `PlacementClusterEmpty`
34176 // / `PlacementAffinityEmpty` / `ContratoCaixaEmpty` /
34177 // `EntradaParaEmpty` / `NomeEmpty` / `EmptyChildName` /
34178 // `ModuleEmpty` variants and now inherit it by construction.
34179 assert_eq!(
34180 require_valid_dns_1123_label::<LabelTestErr>(
34181 "",
34182 || LabelTestErr::Empty,
34183 LabelTestErr::Invalid,
34184 ),
34185 Err(LabelTestErr::Empty),
34186 );
34187 }
34188
34189 #[test]
34190 fn require_valid_dns_1123_label_rejects_malformed_with_reason_threaded() {
34191 // The canonical malformed-shape set the eight consumer sites
34192 // formerly each re-tested inline. The gate threads the
34193 // predicate's shape-shaped reason through as the invalid arm's
34194 // `reason:` verbatim — the field every sibling error variant
34195 // (`{MembroCaixa,PlacementCluster,PlacementAffinity,ContratoCaixa,
34196 // EntradaPara,Nome,ChildCaixa,Module}Invalid.reason`) each
34197 // carry to the author's remediation prose.
34198 for bad in [
34199 "Rio", // uppercase — the canonical TitleCase-from-an-ADR typo
34200 "my_cart", // underscore — the Python-module-name leak
34201 "team.cart", // dot — the namespace-dot-on-a-label confusion
34202 "-cart", // leading hyphen — boundary violation
34203 "cart-", // trailing hyphen — boundary violation
34204 ] {
34205 let result = require_valid_dns_1123_label::<LabelTestErr>(
34206 bad,
34207 || LabelTestErr::Empty,
34208 LabelTestErr::Invalid,
34209 );
34210 match result {
34211 Err(LabelTestErr::Invalid(reason)) => {
34212 assert!(
34213 !reason.is_empty(),
34214 "invalid arm must thread a non-empty reason for {bad:?}",
34215 );
34216 }
34217 other => panic!("expected Invalid for {bad:?}, got {other:?}"),
34218 }
34219 }
34220 }
34221
34222 // ── require_sandboxed_lisp_path ─────────────────────────────────────
34223
34224 #[derive(Debug, PartialEq, Eq)]
34225 enum LispPathTestErr {
34226 Empty,
34227 Absolute,
34228 ParentEscape,
34229 NonLisp,
34230 }
34231
34232 fn call_require_sandboxed_lisp_path(path: &Path) -> Result<(), LispPathTestErr> {
34233 require_sandboxed_lisp_path(
34234 path,
34235 || LispPathTestErr::Empty,
34236 || LispPathTestErr::Absolute,
34237 || LispPathTestErr::ParentEscape,
34238 || LispPathTestErr::NonLisp,
34239 )
34240 }
34241
34242 #[test]
34243 fn require_sandboxed_lisp_path_accepts_canonical_forms() {
34244 // Every sandboxed-relative `.lisp`-terminating path the substrate
34245 // accepts on either M2 tatara-lisp source-path axis (`:behavior :on-*`
34246 // callback paths, `:upgrade-from :state-change :script`) must pass
34247 // the shared gate. Pin the canonical set here so a future tightening
34248 // surfaces as a test failure rather than a silent narrowing at one
34249 // of the two consumer sites.
34250 for form in [
34251 "lib/init.lisp", // canonical example
34252 "lib/handlers.lisp", // multi-callback shape
34253 "lib/migrations/v01-to-v02.lisp", // nested-directory shape
34254 "a.lisp", // one-byte stem
34255 "lib/deep/nested/path/to/file.lisp", // deeply nested
34256 ] {
34257 assert_eq!(
34258 call_require_sandboxed_lisp_path(Path::new(form)),
34259 Ok(()),
34260 "canonical sandboxed `.lisp` form {form:?} must pass the gate",
34261 );
34262 }
34263 }
34264
34265 #[test]
34266 fn require_sandboxed_lisp_path_rejects_empty_before_all_later_arms() {
34267 // The empty-first arm strictly precedes every downstream arm — a
34268 // literal `""` (which the is_absolute check would return false on,
34269 // which carries no ParentDir component, and whose extension is
34270 // absent) routes through the `on_empty` closure so the caller's
34271 // narrower self-locating `_Empty` / `_EmptyScript` diagnostic fires,
34272 // not a misleading `_Absolute` / `_ParentEscape` / `_NonLisp` miss
34273 // downstream. Peer of every zero-first arm ordering the sibling
34274 // require_positive_bounded_* helpers already carry.
34275 assert_eq!(
34276 call_require_sandboxed_lisp_path(Path::new("")),
34277 Err(LispPathTestErr::Empty),
34278 );
34279 }
34280
34281 #[test]
34282 fn require_sandboxed_lisp_path_rejects_absolute_before_parent_escape_and_non_lisp() {
34283 // The absolute arm strictly precedes the parent-escape and
34284 // non-`.lisp`-extension arms — an absolute path (regardless of
34285 // whether it also carries `..` components or a non-`.lisp`
34286 // extension) routes through the `on_absolute` closure so the
34287 // caller's `_Absolute` / `_AbsoluteScript` diagnostic fires with
34288 // its "must be relative to the caixa root" remediation, not the
34289 // misleading later arms. Pin the ordering across the value grid
34290 // covering "absolute + parent-escape" and "absolute + non-`.lisp`"
34291 // compound-violation shapes so a future arm-reorder silently
34292 // narrowing the accepted set would surface at build time.
34293 for absolute in [
34294 "/etc/passwd", // canonical absolute
34295 "/lib/init.lisp", // absolute + `.lisp` (extension arm never reached)
34296 "/lib/../init.lisp", // absolute + parent-escape (later arm never reached)
34297 "/etc/init.txt", // absolute + non-`.lisp`
34298 ] {
34299 assert_eq!(
34300 call_require_sandboxed_lisp_path(Path::new(absolute)),
34301 Err(LispPathTestErr::Absolute),
34302 "absolute path {absolute:?} must route through Absolute arm",
34303 );
34304 }
34305 }
34306
34307 #[test]
34308 fn require_sandboxed_lisp_path_rejects_parent_escape_before_non_lisp() {
34309 // The parent-escape arm strictly precedes the non-`.lisp`-extension
34310 // arm — a relative path carrying any `..` component routes through
34311 // the `on_parent_escape` closure so the caller's `_ParentEscape` /
34312 // `_ParentEscapeScript` diagnostic fires with its "must not
34313 // traverse above the caixa root" remediation, not the misleading
34314 // extension-shape arm. Pin the ordering across leading / mid-path
34315 // / trailing parent-escape positions plus the compound
34316 // "parent-escape + non-`.lisp`" shape.
34317 for escape in [
34318 "../sibling/x.lisp", // leading `..`
34319 "lib/../other.lisp", // mid-path `..`
34320 "lib/handlers/../..", // trailing `..`
34321 "../sibling/x.txt", // parent-escape + non-`.lisp`
34322 ] {
34323 assert_eq!(
34324 call_require_sandboxed_lisp_path(Path::new(escape)),
34325 Err(LispPathTestErr::ParentEscape),
34326 "parent-escaping path {escape:?} must route through ParentEscape arm",
34327 );
34328 }
34329 }
34330
34331 #[test]
34332 fn require_sandboxed_lisp_path_rejects_non_lisp_only_after_all_path_shape_arms_accept() {
34333 // The non-`.lisp`-extension arm fires only when every prior arm
34334 // (empty / absolute / parent-escape) accepts the path — a
34335 // sandboxed relative path whose only violation is a non-`.lisp`
34336 // terminating extension routes through the `on_non_lisp` closure
34337 // so the caller's `_NonLispExtension` / `_NonLispExtensionScript`
34338 // diagnostic fires with its `.lisp`-remediation prose. Pin the
34339 // downstream-most-arm reachability across the canonical
34340 // `.txt`/`.rs`/no-extension/double-extension-shadow shape set the
34341 // two consumer sites' error variants each document.
34342 for bad_ext in [
34343 "lib/init.txt", // wrong extension
34344 "lib/init.rs", // Rust source leaked into caixa
34345 "lib/init.lisp.bak", // double-extension shadow
34346 "lib/init", // no extension
34347 "lib/migrations", // no extension, no dot
34348 "lib/init.LISP", // uppercase — case-sensitive gate
34349 ] {
34350 assert_eq!(
34351 call_require_sandboxed_lisp_path(Path::new(bad_ext)),
34352 Err(LispPathTestErr::NonLisp),
34353 "non-`.lisp` path {bad_ext:?} must route through NonLisp arm",
34354 );
34355 }
34356 }
34357
34358 #[test]
34359 fn require_sandboxed_lisp_path_ordering_matches_inline_pre_lift_cascade() {
34360 // Byte-for-byte the same `Empty → Absolute → ParentEscape → NonLisp`
34361 // arm-ordering the two consumer sites (`validate_callback_path` in
34362 // `caixa-core::behavior`, `UpgradeInstruction::validate`'s
34363 // `StateChange` arm in `caixa-core::upgrade`) each formerly inlined
34364 // verbatim. This pin catches any future reorder that would
34365 // silently reshape the diagnostic dispatch at either site — the
34366 // helper's ordering IS the two sites' ordering, not a re-derived
34367 // convention. Pins the same
34368 // smallest-scope-arm-fires-last three-path drift-detection
34369 // posture the peer `require_positive_bounded_*` /
34370 // `require_positive_canonical_bounded_duration` helpers already
34371 // carry on their own arm sets.
34372 assert_eq!(
34373 call_require_sandboxed_lisp_path(Path::new("")),
34374 Err(LispPathTestErr::Empty),
34375 );
34376 assert_eq!(
34377 call_require_sandboxed_lisp_path(Path::new("/abs/x.lisp")),
34378 Err(LispPathTestErr::Absolute),
34379 );
34380 assert_eq!(
34381 call_require_sandboxed_lisp_path(Path::new("../x.lisp")),
34382 Err(LispPathTestErr::ParentEscape),
34383 );
34384 assert_eq!(
34385 call_require_sandboxed_lisp_path(Path::new("lib/x.txt")),
34386 Err(LispPathTestErr::NonLisp),
34387 );
34388 assert_eq!(
34389 call_require_sandboxed_lisp_path(Path::new("lib/x.lisp")),
34390 Ok(()),
34391 );
34392 }
34393
34394 #[test]
34395 fn gateway_api_hostname_max_len_pins_canonical_value() {
34396 // Pin the actual byte count so a typo in this lift can't silently
34397 // rebrand the K8s Gateway API v1 `Listener.hostname` /
34398 // `HTTPRoute.spec.hostnames[]` admission-schema `maxLength:` cap
34399 // the `AplicacaoSpec::validate` `:entrada :host` total-length arm
34400 // reads. The value is part of the cluster-side contract with
34401 // every Gateway API v1 CRD schema validator (apiserver-side +
34402 // Cilium / Envoy Gateway / Istio / NGINX per-implementation
34403 // webhooks) — the OpenAPI schema on the Hostname type binds
34404 // `maxLength: 253` verbatim (RFC 1035 / RFC 1123 DNS name limit:
34405 // 255 wire bytes minus the trailing-dot + one length prefix), so
34406 // a drifted value at either the aplicacao-side validator or a
34407 // downstream renderer's per-host validator silently emits a
34408 // Gateway / HTTPRoute the apiserver rejects at admission time
34409 // with an opaque `field is invalid` diagnostic far from the
34410 // caixa.lisp source line. Changing this value is a coordinated
34411 // Gateway API promotion alongside the upstream SIG-Network
34412 // Hostname schema evolution, not an incidental edit. Peer to
34413 // [`GATEWAY_API_HTTP_PATH_MAX_LEN`] (1024) on the sibling
34414 // per-route path-value cap axis — both are apiserver-side
34415 // `maxLength:` bounds on Gateway API v1 landing sites, both lift
34416 // to `caixa-core::render` so the M4 CR materializer's per-axis
34417 // validators (per-host, per-path) read from one place.
34418 assert_eq!(GATEWAY_API_HOSTNAME_MAX_LEN, 253);
34419 }
34420
34421 #[test]
34422 fn gateway_api_hostname_max_len_exceeds_dns_1123_label_max_len() {
34423 // Cross-axis structural invariant: every `.`-separated label in
34424 // a Gateway API v1 Hostname is a DNS-1123 label, so the total
34425 // Hostname cap must strictly exceed the per-label cap — otherwise
34426 // even a single-label host `"foo"` couldn't reach the per-label
34427 // ceiling before hitting the total-length ceiling, and the
34428 // `AplicacaoSpec::validate` `:entrada :host` per-label arm at
34429 // `validate_entrada_host` would be structurally unreachable via
34430 // the total-length arm's own ordering. Pinning the ordering here
34431 // means a future substrate-side tightening of either bound (a
34432 // K8s SIG-Network Hostname promotion narrowing the total cap, a
34433 // DNS-1123 label promotion widening the per-label cap) that
34434 // inverted the two would fail this pin at build time rather than
34435 // silently rendering the per-label arm unreachable.
34436 assert!(
34437 GATEWAY_API_HOSTNAME_MAX_LEN > DNS_1123_LABEL_MAX_LEN,
34438 "GATEWAY_API_HOSTNAME_MAX_LEN ({GATEWAY_API_HOSTNAME_MAX_LEN}) must strictly \
34439 exceed DNS_1123_LABEL_MAX_LEN ({DNS_1123_LABEL_MAX_LEN}) — every \
34440 `.`-separated label in a Gateway API v1 Hostname is itself a DNS-1123 \
34441 label under the apiserver's OpenAPI regex, so the total-length cap \
34442 must be able to accommodate at least one per-label-max label",
34443 );
34444 }
34445
34446 #[test]
34447 fn gateway_api_hostname_max_len_matches_rfc_1035_dns_name_limit() {
34448 // Cross-axis structural invariant: the Gateway API v1 Hostname
34449 // `maxLength: 253` cap is the RFC 1035 / RFC 1123 DNS name limit
34450 // — 255 wire bytes minus one length prefix minus the implicit
34451 // trailing dot — the same cap every DNS-compliant `HostName`
34452 // primitive downstream substrate consumer (the future
34453 // per-`Certificate` SAN emitter for cert-manager, the future
34454 // multi-`:entrada` host-collision gate) will inherit by
34455 // construction. Pinning the arithmetic here rather than the
34456 // literal `253` makes the RFC derivation explicit at the const's
34457 // test site so a future migration onto a different DNS-name
34458 // ceiling (an eventual RFC-successor limit, a per-cluster
34459 // override the operator pins) surfaces at this pin, not at every
34460 // downstream renderer's admission-rejection loop.
34461 assert_eq!(
34462 GATEWAY_API_HOSTNAME_MAX_LEN,
34463 255 - 1 - 1,
34464 "GATEWAY_API_HOSTNAME_MAX_LEN must equal the RFC 1035 / RFC 1123 DNS \
34465 name limit (255 wire bytes minus one length prefix minus the trailing \
34466 dot)",
34467 );
34468 }
34469
34470 #[test]
34471 fn gateway_api_default_http_listener_port_pins_canonical_80_literal() {
34472 // The canonical-constant arm — pins
34473 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`] at the verbatim
34474 // `80` literal the sole `caixa-mesh::gateway_routes` per-
34475 // Aplicacao `Gateway` per-listener HTTP-listener-port axis
34476 // reads from. Peer with the
34477 // [`crate::DEFAULT_SERVICO_PORT`]-pins-`8080` discipline on the
34478 // sibling per-renderer canonical-K8s-port-axis typed `u16`
34479 // const: a future refactor that drifts the constant out from
34480 // under either consumer surfaces here ahead of any per-renderer
34481 // Gateway emission. The literal value is IANA's well-known
34482 // `http` service port (RFC 9110 §4.2.2), so an
34483 // `http://<entrada.host>/…` URL without a `:<port>` selector
34484 // reaches the listener by construction.
34485 assert_eq!(
34486 GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT, 80,
34487 "canonical Gateway API v1 HTTP listener port literal must remain \
34488 `80` verbatim — this is the value the caixa-mesh Gateway emitter \
34489 reads from and the IANA-registered well-known `http` service port"
34490 );
34491 }
34492
34493 #[test]
34494 fn gateway_api_default_http_listener_port_distinct_from_default_servico_port() {
34495 // Cross-axis structural invariant: the Gateway listener's
34496 // external HTTP port ([`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`],
34497 // 80) and the per-Servico in-cluster L4 port
34498 // ([`DEFAULT_SERVICO_PORT`], 8080) are two distinct axes — the
34499 // external-ingress port the K8s Gateway API controller opens on
34500 // the cluster boundary, and the internal-Servico port the
34501 // `pleme-computeunit` chart emits per Servico `Service`.
34502 // Collapsing the two would silently emit a Gateway whose
34503 // listener port matched the Servico's own port, so a stray
34504 // Servico exposing its Service directly to a cluster-external
34505 // LoadBalancer would shadow the Aplicacao's Gateway path — the
34506 // typed two-axis distinction guards against a rebrand on either
34507 // axis silently converging on the other's value. Peer with the
34508 // [`GATEWAY_API_HOSTNAME_MAX_LEN`]-strictly-exceeds-[`DNS_1123_LABEL_MAX_LEN`]
34509 // discipline on the sibling per-axis structural-ordering pin
34510 // set — both are cross-axis invariants between two lifted
34511 // constants that share a downstream renderer.
34512 assert_ne!(
34513 GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT,
34514 crate::DEFAULT_SERVICO_PORT,
34515 "GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT ({GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT}) \
34516 must remain distinct from DEFAULT_SERVICO_PORT ({}) — the two axes name \
34517 different scalars (external-Gateway listener port vs in-cluster Servico port), \
34518 collapsing them silently shadows the Aplicacao's Gateway path",
34519 crate::DEFAULT_SERVICO_PORT,
34520 );
34521 }
34522
34523 #[test]
34524 fn gateway_api_default_http_listener_name_pins_canonical_http_literal() {
34525 // The canonical-constant arm — pins
34526 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME`] at the verbatim
34527 // `"http"` literal the sole `caixa-mesh::gateway_routes` per-
34528 // Aplicacao `Gateway` per-listener name-discriminator axis
34529 // reads from. Peer with the
34530 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`]-pins-`80` discipline
34531 // on the sibling per-listener HTTP-listener-port scalar-axis:
34532 // both are the Aplicacao-side substrate-canonical scalar-value
34533 // pins the sole per-Aplicacao `Gateway` emitter reaches for, so
34534 // a future refactor that drifts either constant out from under
34535 // the emitter surfaces here ahead of any per-renderer Gateway
34536 // emission. The literal value is the substrate's V0 arbitrary-
34537 // author-chosen short listener-name (K8s Gateway API v1's
34538 // `SectionName`-typed field carries no CRD-schema-pinned value
34539 // — the substrate picks `"http"` verbatim to match the
34540 // listener's carried protocol shape at the reader's eye), so
34541 // downstream `HTTPRoute` `sectionName` selectors bind to this
34542 // exact byte-string by construction.
34543 assert_eq!(
34544 GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME, "http",
34545 "canonical Gateway API v1 HTTP listener-name literal must remain \
34546 `\"http\"` verbatim — this is the value the caixa-mesh Gateway \
34547 emitter reads from and the substrate's V0 arbitrary-author-chosen \
34548 short listener-name identifier every downstream `HTTPRoute` \
34549 `parentRefs[].sectionName` selector binds to"
34550 );
34551 }
34552
34553 #[test]
34554 fn gateway_api_default_http_listener_name_carries_dns_1123_label_shape() {
34555 // Cross-axis invariant: K8s Gateway API v1 `Listener.name` is
34556 // `SectionName`-typed — a required DNS-1123 label unique within
34557 // the parent Gateway's listener list. Pinning the shape here
34558 // means a future rebrand on the canonical lift can't silently
34559 // land a malformed listener-name identifier (empty, uppercase,
34560 // whitespace, `.` / `_` / non-alphanumeric characters, an
34561 // overlong string past the DNS-1123 label ceiling) that the
34562 // apiserver-side Gateway API CRD schema validator would reject
34563 // far from the rebrand commit's source. The predicate the
34564 // `caixa-mesh::gateway_routes` per-listener-name emitter never
34565 // consults directly (the value is a const — no author input
34566 // reaches this axis today) gets consulted here so any future
34567 // rebrand routes through the same DNS-1123-label admission
34568 // grammar every K8s CRD `name`-shaped axis carries. Peer to
34569 // `default_gateway_class_name_is_a_valid_dns_1123_label` on
34570 // the sibling per-Gateway `gatewayClassName` scalar-axis pin
34571 // and `default_namespace_is_a_valid_dns_1123_label` on the
34572 // canonical-K8s-namespace lifted scalar — every substrate-side
34573 // K8s-CRD-name-shaped lift carries the same DNS-1123 label
34574 // admission-grammar cross-axis invariant.
34575 assert!(
34576 is_dns_1123_label(GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME).is_ok(),
34577 "GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME ({GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME:?}) \
34578 must be a valid DNS-1123 label — K8s Gateway API v1 `Listener.name` is \
34579 `SectionName`-typed and the apiserver-side CRD schema validator refuses \
34580 any other shape"
34581 );
34582 }
34583
34584 #[test]
34585 fn gateway_api_default_http_route_path_pins_canonical_root_literal() {
34586 // The canonical-constant arm — pins
34587 // [`GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH`] at the verbatim `"/"`
34588 // literal the sole `caixa-mesh::gateway_routes` per-Aplicacao
34589 // `HTTPRoute` empty-`:entrada :paths` catch-all URL-path
34590 // resolver reads from. Peer with the
34591 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME`]-pins-`"http"` and
34592 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`]-pins-`80`
34593 // disciplines on the sibling per-listener substrate-canonical
34594 // scalar-value axes: all three are the Aplicacao-side
34595 // substrate-canonical scalar-value pins the sole per-Aplicacao
34596 // Gateway API v1 CRD emitter reaches for, so a future refactor
34597 // that drifts any one constant out from under the emitter
34598 // surfaces here ahead of any per-renderer HTTPRoute emission.
34599 // The literal value is the K8s Gateway API v1 canonical
34600 // catch-all shape: `PathPrefix "/"` — the upstream docs at
34601 // <https://gateway-api.sigs.k8s.io/api-types/httproute/#path-based-routing>
34602 // pin the bare-root byte-string as the "match anything the
34603 // listener admits" idiom every gateway-class controller treats
34604 // as the equivalent of "no path predicate".
34605 assert_eq!(
34606 GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH, "/",
34607 "canonical Gateway API v1 HTTPRoute catch-all path literal must remain \
34608 `\"/\"` verbatim — this is the value the caixa-mesh HTTPRoute emitter \
34609 renders whenever the typed `:entrada :paths` list is empty and every \
34610 gateway-class controller (Cilium's Envoy, Envoy Gateway, Istio Gateway) \
34611 treats as the canonical `PathPrefix` catch-all"
34612 );
34613 }
34614
34615 #[test]
34616 fn gateway_api_default_http_route_path_carries_valid_gateway_api_http_path_shape() {
34617 // Cross-axis invariant: K8s Gateway API v1
34618 // `HTTPPathMatch.value` is admitted by the apiserver-side CRD
34619 // schema regex the substrate mirrors in the shared
34620 // [`is_gateway_api_http_path`] predicate — the same admission
34621 // grammar every author-supplied [`crate::aplicacao::Entrada`]
34622 // `:paths` entry clears at typed-validate time. Pinning the
34623 // shape here means a future rebrand on the canonical lift can't
34624 // silently land a malformed catch-all URL-path scalar (empty,
34625 // no leading `/`, overlong past the K8s Gateway API v1
34626 // `HTTPPathMatch.value` ceiling, `..`-segment-bearing, ASCII-
34627 // control-bearing, non-ASCII-bearing) that the apiserver-side
34628 // Gateway API CRD schema validator would reject far from the
34629 // rebrand commit's source. The paired
34630 // [`caixa_mesh::gateway_routes`] emitter never consults the
34631 // predicate directly (the catch-all value is a const — no
34632 // author input reaches this axis today) so consulting it here
34633 // means any future rebrand routes through the same
34634 // admission-grammar the peer author-side
34635 // `:entrada :paths` slot's `AplicacaoSpec::validate` gate
34636 // carries. Peer to
34637 // `gateway_api_default_http_listener_name_carries_dns_1123_label_shape`
34638 // on the sibling per-listener name-scalar cross-axis invariant
34639 // — every substrate-side Gateway-API-scalar lift carries the
34640 // matching per-axis admission-grammar cross-axis pin.
34641 assert!(
34642 is_gateway_api_http_path(GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH).is_ok(),
34643 "GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH ({GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH:?}) \
34644 must clear the shared HTTP-path admission grammar — K8s Gateway API v1 \
34645 `HTTPPathMatch.value` is CRD-schema-regex-validated and the apiserver-side \
34646 schema validator refuses any other shape at apply time"
34647 );
34648 }
34649
34650 // ── insert_first_seen ───────────────────────────────────────────────
34651
34652 #[derive(Debug, PartialEq, Eq)]
34653 enum DupTestErr {
34654 Dup(&'static str),
34655 }
34656
34657 #[test]
34658 fn insert_first_seen_accepts_distinct_keys_without_firing_closure() {
34659 // The happy path — every distinct key returns `Ok(())` and the
34660 // caller's `on_duplicate` closure is never invoked. Pins the
34661 // `HashSet::insert`-returning-`true`-on-first-insertion contract
34662 // the ten consumer sites (`:membros`, `:placement :clusters`,
34663 // `:entrada :paths`, `:contratos`, `:children`, `:deps`,
34664 // `:deps-dev`, `:etiquetas`, `:autores`, `:caracteristicas`,
34665 // code-paths) each rely on — a future refactor that flips the
34666 // sense of the delegated `insert` return would surface here
34667 // ahead of every per-consumer duplicate arm silently mis-firing
34668 // on distinct keys.
34669 let mut seen: std::collections::HashSet<&str> = std::collections::HashSet::new();
34670 for key in ["cart", "catalog", "payment"] {
34671 assert_eq!(
34672 insert_first_seen::<&str, DupTestErr, _>(&mut seen, key, || DupTestErr::Dup(
34673 "must not fire"
34674 )),
34675 Ok(()),
34676 "first insertion of {key:?} must return Ok(())",
34677 );
34678 }
34679 assert_eq!(seen.len(), 3, "every distinct key must land in the set");
34680 }
34681
34682 #[test]
34683 fn insert_first_seen_surfaces_caller_shaped_error_on_second_insertion() {
34684 // The duplicate arm — the second occurrence of any key surfaces
34685 // the caller's `on_duplicate` return verbatim. Pins the
34686 // "declaration-order-preserving first-collision" discipline every
34687 // peer `Duplicate*` variant documents: the first colliding entry
34688 // reports, not the last. Same shape the ten consumer sites'
34689 // `*_duplicate_diagnostic_names_second_collision` posture tests
34690 // pin at the caller layer; this lift makes the sequencing a
34691 // property of the helper, not a per-call-site convention.
34692 let mut seen: std::collections::HashSet<&str> = std::collections::HashSet::new();
34693 assert_eq!(
34694 insert_first_seen::<&str, DupTestErr, _>(&mut seen, "cart", || DupTestErr::Dup(
34695 "first"
34696 )),
34697 Ok(()),
34698 "first insertion must Ok",
34699 );
34700 assert_eq!(
34701 insert_first_seen::<&str, DupTestErr, _>(&mut seen, "cart", || DupTestErr::Dup(
34702 "second"
34703 )),
34704 Err(DupTestErr::Dup("second")),
34705 "second insertion must fire the caller's closure with its own tag",
34706 );
34707 }
34708
34709 #[test]
34710 fn insert_first_seen_generic_over_tuple_key_used_by_contratos_gate() {
34711 // The [`crate::AplicacaoSpec::validate`] `:contratos` gate carries
34712 // a six-tuple typed-edge identity key
34713 // (`(de, para, wit, endpoint, subject, slot)`) — the only non-
34714 // `&str` key shape in the crate's per-list uniqueness set. Pin
34715 // the generic-over-`K` contract here so a future refactor that
34716 // narrows the helper to `&str`-only keys (a hypothetical
34717 // `HashSet<&str>`-specialized rewrite) surfaces at this pin
34718 // rather than as a compile error at the sole tuple-carrying
34719 // consumer. The tuple set here mirrors the shape
34720 // `ContratoIdentity` carries.
34721 let mut seen: std::collections::HashSet<(&str, &str, &str, Option<&str>)> =
34722 std::collections::HashSet::new();
34723 let key = ("cart", "catalog", "wasi:http/proxy", Some("/products"));
34724 assert_eq!(
34725 insert_first_seen::<_, DupTestErr, _>(&mut seen, key, || DupTestErr::Dup(
34726 "must not fire"
34727 )),
34728 Ok(()),
34729 );
34730 assert_eq!(
34731 insert_first_seen::<_, DupTestErr, _>(&mut seen, key, || DupTestErr::Dup("collision")),
34732 Err(DupTestErr::Dup("collision")),
34733 "identical tuple key on second insertion must fire the duplicate arm",
34734 );
34735 }
34736
34737 // ── assert_str_reexport_identity ──────────────────────────────────
34738
34739 #[test]
34740 fn assert_str_reexport_identity_accepts_same_static_allocation() {
34741 // Positive path — passing the same `&'static str` twice (the
34742 // shape a `pub use caixa_core::X;` re-export produces at every
34743 // consumer site) must not panic. This is the ~75-caller-site
34744 // happy path that the lifted test-side pin gate collapses onto.
34745 // The compiler-interned literal `"KUBE_KEY_SPEC"` reaches this
34746 // helper twice through the same `&'static` allocation, so
34747 // `std::ptr::eq(a.as_ptr(), b.as_ptr())` returns true and the
34748 // second `assert!` arm passes without firing.
34749 const CANONICAL: &str = "canonical-value";
34750 assert_str_reexport_identity("CANONICAL_UNDER_TEST", CANONICAL, CANONICAL);
34751 }
34752
34753 #[test]
34754 #[should_panic(
34755 expected = "SIBLING_UNDER_TEST must be a re-export of caixa_core::SIBLING_UNDER_TEST"
34756 )]
34757 fn assert_str_reexport_identity_rejects_sibling_allocation_with_same_bytes() {
34758 // Negative path — passing two byte-equal `&'static str`s whose
34759 // underlying allocations differ (the shape a sibling `pub const
34760 // X: &str = "…"` at a renderer crate produces, silently carrying
34761 // the same bytes but its own `&'static` allocation) must panic
34762 // on the [`std::ptr::eq`] arm, naming the offending re-export.
34763 // Reproduces the canonical drift footgun the lift closes: byte-
34764 // equality via [`assert_eq!`] alone silently admits the drift
34765 // — the two strings are equal — but the allocation-identity
34766 // arm catches it structurally. Uses [`String::leak`] to
34767 // materialize a fresh `&'static str` allocation carrying the
34768 // same bytes as the compiler-interned canonical literal, so
34769 // the two share bytes but differ in allocation.
34770 const CANONICAL: &str = "canonical-value";
34771 let sibling: &'static str = String::from("canonical-value").leak();
34772 // Sanity — the sibling and canonical share bytes …
34773 assert_eq!(sibling, CANONICAL);
34774 // … but must live at distinct `&'static` allocations for this
34775 // negative path to fire on the identity arm rather than
34776 // silently pass on the equality arm.
34777 assert!(!std::ptr::eq(sibling.as_ptr(), CANONICAL.as_ptr()));
34778 assert_str_reexport_identity("SIBLING_UNDER_TEST", sibling, CANONICAL);
34779 }
34780
34781 #[test]
34782 #[should_panic(expected = "DRIFTED_UNDER_TEST must byte-equal caixa_core::DRIFTED_UNDER_TEST")]
34783 fn assert_str_reexport_identity_rejects_bytes_drift_before_identity_arm() {
34784 // Ordering pin — when the two byte-strings differ, the
34785 // [`assert_eq!`] arm must fire *before* the [`std::ptr::eq`]
34786 // identity arm reaches for `.as_ptr()`. Pins the arm sequencing
34787 // so a future refactor that flipped the two arms (identity
34788 // first, byte-equality second) would surface here rather than
34789 // report the wrong diagnostic against a drifted canonical
34790 // (the byte-equality diagnostic self-locates the value drift;
34791 // the identity diagnostic self-locates the allocation drift —
34792 // reporting the identity arm on a value-drifted pair points
34793 // the reader at the wrong failure class). Same discipline as
34794 // the peer `require_positive_canonical_bounded_duration`
34795 // three-arm-ordering pin above.
34796 const CANONICAL: &str = "canonical-value";
34797 const DRIFTED: &str = "drifted-value";
34798 assert_str_reexport_identity("DRIFTED_UNDER_TEST", DRIFTED, CANONICAL);
34799 }
34800
34801 #[test]
34802 fn computeunit_spec_key_module_pins_canonical_value() {
34803 // Pin the actual byte-string so a typo in this lift can't silently
34804 // rebrand the `wasm.pleme.io/v1alpha1/ComputeUnit` CRD per-CR
34805 // `spec.module` sub-block key both caixa-flux and caixa-helm
34806 // navigate to reach the per-Servico wasm-component reference the
34807 // M2.5 wasm-engine instantiator loads at Servico bring-up. The
34808 // value is part of the cluster-side contract with the
34809 // `pleme-computeunit` library chart's per-values module-source
34810 // routing + the `caixa-operator` `ComputeUnit` CR admission
34811 // webhook's per-CR module-reference resolver; changing it is a
34812 // coordinated ComputeUnit-CRD schema migration alongside the
34813 // upstream substrate release, not an incidental edit. Peer to
34814 // `default_namespace_pins_canonical_value` /
34815 // `helm_values_yaml_filename_pins_canonical_value` /
34816 // `helm_chart_yaml_filename_pins_canonical_value` on the sibling
34817 // canonical-substrate-schema-key axes.
34818 assert_eq!(COMPUTEUNIT_SPEC_KEY_MODULE, "module");
34819 }
34820
34821 #[test]
34822 fn computeunit_spec_key_trigger_pins_canonical_value() {
34823 // Peer to `computeunit_spec_key_module_pins_canonical_value` on
34824 // the same ComputeUnit-CRD per-`spec.*` sub-block axis — pins
34825 // the per-CR invocation-shape sub-block key every
34826 // `pleme-computeunit`-library-chart-driven per-Servico
34827 // `trigger.service.port` / `trigger.service.paths` /
34828 // `trigger.service.breathability` values-block route reads back.
34829 assert_eq!(COMPUTEUNIT_SPEC_KEY_TRIGGER, "trigger");
34830 }
34831
34832 #[test]
34833 fn computeunit_spec_key_capabilities_pins_canonical_value() {
34834 // Peer to `computeunit_spec_key_module_pins_canonical_value` and
34835 // `computeunit_spec_key_trigger_pins_canonical_value` on the same
34836 // ComputeUnit-CRD per-`spec.*` sub-block axis — pins the per-CR
34837 // WASI-capability-token-list sub-block key the M2.5 wasm-engine
34838 // instantiator reads to bind the per-component capability set
34839 // (WASI-preview-2 preview-interfaces per the WIT Component Model)
34840 // at Servico bring-up.
34841 assert_eq!(COMPUTEUNIT_SPEC_KEY_CAPABILITIES, "capabilities");
34842 }
34843
34844 #[test]
34845 fn computeunit_spec_keys_carry_lowercase_shape() {
34846 // Cross-axis invariant: every `wasm.pleme.io/v1alpha1/ComputeUnit`
34847 // CRD per-`spec.*` sub-block key is all-ASCII-lowercase
34848 // throughout — the ComputeUnit CRD's schema convention on the
34849 // per-`spec.*` sub-block axis. A drifted UpperCamelCase /
34850 // hyphenated variant (`"Module"` / `"module-source"` /
34851 // `"Trigger"` / `"Capabilities"` — the OpenAPI-CRD-schema
34852 // canonical-form footgun the peer `KUBE_KEY_*` axes share) would
34853 // land the emit-side key outside the CRD's admitted per-sub-
34854 // block set and the `caixa-operator` admission webhook would
34855 // silently drop the per-Servico wasm-runtime binding — the
34856 // Servico pods would come up under the library-chart defaults
34857 // (no module bound, no trigger bound, no capability set)
34858 // instead of the caixa.lisp's declared per-`:servicos` axis.
34859 // Same all-ASCII-lowercase shape gate as the peer M2 typed-slot
34860 // camelCase-key axes ([`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] —
34861 // the compound-word slot [`M2_KEY_UPGRADE_FROM`] adds a
34862 // camelHump per its `#[serde(rename_all = "camelCase")]`-derived
34863 // shape, but the leading-word gate is the same).
34864 for k in [
34865 COMPUTEUNIT_SPEC_KEY_MODULE,
34866 COMPUTEUNIT_SPEC_KEY_TRIGGER,
34867 COMPUTEUNIT_SPEC_KEY_CAPABILITIES,
34868 ] {
34869 assert!(
34870 k.bytes().all(|b| b.is_ascii_lowercase()),
34871 "ComputeUnit CRD per-`spec.*` sub-block key {k:?} must be \
34872 all-ASCII-lowercase per the CRD schema convention"
34873 );
34874 }
34875 }
34876
34877 #[test]
34878 fn computeunit_spec_keys_appear_verbatim_in_sample_computeunit_yaml() {
34879 // Round-trip pin: the exact byte-strings the three lifted
34880 // constants carry appear verbatim as the top-level `spec.*`
34881 // sub-block keys of a canonical in-tree `ComputeUnit` YAML —
34882 // the same shape [`caixa_flux::programs_yaml_entry`] and
34883 // [`caixa_helm::build_values_yaml`] consume via
34884 // `serde_yaml::from_str`. Pins the const-to-schema round-trip
34885 // so a future ComputeUnit-CRD schema rebrand (a `binary:` /
34886 // `component:` / `invoke:` / `caps:` / `spec.wasm.*` axis
34887 // rename the ABSORPTION-ROADMAP.md M4-M5 trajectory names)
34888 // surfaces here as a build error rather than as a silent
34889 // per-Servico wasm-runtime-binding drop at cluster-apply time.
34890 let cu: serde_yaml::Value = serde_yaml::from_str(
34891 r#"
34892apiVersion: wasm.pleme.io/v1alpha1
34893kind: ComputeUnit
34894metadata:
34895 name: hello-rio
34896spec:
34897 module:
34898 source: oci://ghcr.io/pleme-io/hello-rio:v0.1.0
34899 trigger:
34900 service:
34901 port: 8080
34902 paths: ["/"]
34903 capabilities:
34904 - env
34905"#,
34906 )
34907 .unwrap();
34908 let spec = cu.get(KUBE_KEY_SPEC).expect("spec key present");
34909 assert!(
34910 spec.get(COMPUTEUNIT_SPEC_KEY_MODULE).is_some(),
34911 "spec.{COMPUTEUNIT_SPEC_KEY_MODULE} sub-block must be present"
34912 );
34913 assert!(
34914 spec.get(COMPUTEUNIT_SPEC_KEY_TRIGGER).is_some(),
34915 "spec.{COMPUTEUNIT_SPEC_KEY_TRIGGER} sub-block must be present"
34916 );
34917 assert!(
34918 spec.get(COMPUTEUNIT_SPEC_KEY_CAPABILITIES).is_some(),
34919 "spec.{COMPUTEUNIT_SPEC_KEY_CAPABILITIES} sub-block must be present"
34920 );
34921 // Nested `spec.module.source` leaf-scalar sub-block: every
34922 // rendered ComputeUnit YAML declares the wasm-component
34923 // reference under this leaf, and every downstream
34924 // `programs[].module.source` readback the
34925 // [`caixa_flux::programs_yaml_entry`] round-trip pins reaches
34926 // for the same `&'static str`. Peer to the top-level
34927 // `spec.{module,trigger,capabilities}` presence assertions
34928 // above — extends the round-trip pin one level deeper onto
34929 // the module-block's leaf reference-value axis.
34930 let module = spec
34931 .get(COMPUTEUNIT_SPEC_KEY_MODULE)
34932 .expect("spec.module block present");
34933 assert!(
34934 module.get(COMPUTEUNIT_MODULE_KEY_SOURCE).is_some(),
34935 "spec.{COMPUTEUNIT_SPEC_KEY_MODULE}.{COMPUTEUNIT_MODULE_KEY_SOURCE} \
34936 leaf-scalar sub-block must be present"
34937 );
34938 assert_eq!(
34939 module
34940 .get(COMPUTEUNIT_MODULE_KEY_SOURCE)
34941 .and_then(|s| s.as_str()),
34942 Some("oci://ghcr.io/pleme-io/hello-rio:v0.1.0"),
34943 "the ComputeUnit CRD per-`module.source` axis carries the wasm-\
34944 component OCI/git reference verbatim"
34945 );
34946 }
34947
34948 #[test]
34949 fn computeunit_module_key_source_pins_canonical_value() {
34950 // Peer to `computeunit_spec_key_module_pins_canonical_value` on
34951 // the nested `spec.module.*` sub-block axis — pins the per-CR
34952 // wasm-component-reference leaf-scalar key every
34953 // [`caixa_flux::programs_yaml_entry`] round-trip navigator and
34954 // every [`caixa_flux::upsert_into_programs_yaml`] /
34955 // [`caixa_flux::upsert_into_helmrelease_programs`] cross-
34956 // upsert readback resolves under the parent
34957 // `COMPUTEUNIT_SPEC_KEY_MODULE`. Changing this value is a
34958 // coordinated ComputeUnit-CRD schema migration alongside the
34959 // `pleme-computeunit` library chart's per-values module-source
34960 // routing + the `caixa-operator` `ComputeUnit` CR admission
34961 // webhook's per-CR module-reference resolver, not an
34962 // incidental edit.
34963 assert_eq!(COMPUTEUNIT_MODULE_KEY_SOURCE, "source");
34964 }
34965
34966 #[test]
34967 fn computeunit_module_key_source_carries_lowercase_shape() {
34968 // Cross-axis invariant: the nested `spec.module.*` leaf-scalar
34969 // sub-block key is all-ASCII-lowercase throughout — the
34970 // ComputeUnit CRD's schema convention on the per-`spec.module.*`
34971 // leaf axis, same as the top-level per-`spec.*` sub-block
34972 // axis the sibling `COMPUTEUNIT_SPEC_KEY_*` peers gate.
34973 // A drifted UpperCamelCase / hyphenated variant (`"Source"` /
34974 // `"module-source"` / `"src"` — the OpenAPI-CRD-schema
34975 // canonical-form footgun the peer `KUBE_KEY_*` axes share)
34976 // would land the emit-side key outside the CRD's admitted
34977 // per-`module.*` set and the `caixa-operator` admission
34978 // webhook would silently drop the per-Servico wasm-module
34979 // reference — the Servico pods would come up under the
34980 // library-chart defaults (no module bound) instead of the
34981 // caixa.lisp's declared per-`:servicos` axis. Same all-ASCII-
34982 // lowercase shape gate as the peer `COMPUTEUNIT_SPEC_KEY_*`
34983 // top-level axes.
34984 assert!(
34985 COMPUTEUNIT_MODULE_KEY_SOURCE
34986 .bytes()
34987 .all(|b| b.is_ascii_lowercase()),
34988 "ComputeUnit CRD per-`spec.module.*` leaf-scalar sub-block key \
34989 {COMPUTEUNIT_MODULE_KEY_SOURCE:?} must be all-ASCII-lowercase \
34990 per the CRD schema convention"
34991 );
34992 }
34993
34994 #[test]
34995 fn mapping_ext_insert_str_key_promotes_key_to_yaml_string() {
34996 // The trait method promotes an arbitrary `&str` key to
34997 // `Value::String(key.to_string())` — pin the promotion so a
34998 // future refactor that reaches for a different `Value` variant
34999 // for the key (e.g. `Value::Tagged`) is a compile-visible break,
35000 // not a silent per-consumer regression at the K8s-artifact-emit
35001 // surface.
35002 let mut m = serde_yaml::Mapping::new();
35003 let prior = m.insert_str_key("spec", serde_yaml::Value::Bool(true));
35004 assert!(
35005 prior.is_none(),
35006 "insert_str_key returns None on first insertion, mirroring \
35007 serde_yaml::Mapping::insert"
35008 );
35009 // Key is exactly the `Value::String` promotion of the input.
35010 let got = m
35011 .get(serde_yaml::Value::String("spec".to_string()))
35012 .expect("inserted key is present under Value::String promotion");
35013 assert_eq!(
35014 got,
35015 &serde_yaml::Value::Bool(true),
35016 "insert_str_key routes value verbatim to the underlying \
35017 serde_yaml::Mapping::insert"
35018 );
35019 }
35020
35021 #[test]
35022 fn mapping_ext_insert_str_key_returns_prior_value_on_replace() {
35023 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35024 // return contract: the prior value at that key, or `None` if
35025 // absent. Pin the replace-returns-prior semantic so a future
35026 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35027 // silently drop the prior-value handoff downstream consumers may
35028 // reach for (the M4 per-`:politicas` overlay merger, the future
35029 // `feira app deploy` idempotent-write dry-run comparator).
35030 let mut m = serde_yaml::Mapping::new();
35031 m.insert_str_key("kind", serde_yaml::Value::String("Gateway".into()));
35032 let prior = m.insert_str_key("kind", serde_yaml::Value::String("HTTPRoute".into()));
35033 assert_eq!(
35034 prior,
35035 Some(serde_yaml::Value::String("Gateway".into())),
35036 "insert_str_key returns the prior value when replacing an existing key"
35037 );
35038 let got = m
35039 .get(serde_yaml::Value::String("kind".to_string()))
35040 .expect("key is still present after replace");
35041 assert_eq!(
35042 got,
35043 &serde_yaml::Value::String("HTTPRoute".into()),
35044 "replaced value is now the most-recently-inserted one"
35045 );
35046 }
35047
35048 #[test]
35049 fn mapping_ext_insert_str_key_matches_hand_written_promotion() {
35050 // Cross-check the trait method against the hand-written
35051 // `mapping.insert(Value::String(key.into()), value)` shape the
35052 // ~48 lifted call sites previously carried. A drift between the
35053 // trait method's promotion and the inline promotion the prior
35054 // call sites used would silently emit a different YAML mapping
35055 // (a differently-quoted key, a different `Value` variant) at
35056 // every routed consumer — pin the equivalence so the trait
35057 // remains a drop-in replacement.
35058 let mut via_trait = serde_yaml::Mapping::new();
35059 via_trait.insert_str_key(KUBE_KEY_KIND, serde_yaml::Value::String("Gateway".into()));
35060
35061 let mut via_inline = serde_yaml::Mapping::new();
35062 via_inline.insert(
35063 serde_yaml::Value::String(KUBE_KEY_KIND.into()),
35064 serde_yaml::Value::String("Gateway".into()),
35065 );
35066
35067 assert_eq!(
35068 via_trait, via_inline,
35069 "insert_str_key(KEY, V) must byte-equal \
35070 insert(Value::String(KEY.into()), V) — otherwise the \
35071 ~48 routed consumer sites drift silently at emit time"
35072 );
35073 }
35074
35075 #[test]
35076 fn mapping_get_bare_str_key_byte_equals_value_string_wrapped_form() {
35077 // The read-side twin of the `insert_str_key`-vs-hand-written pin.
35078 // `serde_yaml::Mapping::get<I: Index>` accepts any `I: Index`;
35079 // the crate ships `impl Index for str` (routing through a
35080 // no-allocation `HashLikeValue(&str)` bucket lookup) and
35081 // `impl Index for Value` (matching the `Value::String(_)`
35082 // key verbatim). The ~78 test-side probes across `caixa-mesh`,
35083 // `caixa-flux`, and `caixa-core::render` that previously spelled
35084 // out `.get(serde_yaml::Value::String(<KEY>.into()))` were
35085 // swept onto the shorter `.get(<KEY>)` form because the two
35086 // must resolve to the same bucket for the sweep to be a
35087 // drop-in. Pin the equivalence — the `HashLikeValue(&str)`
35088 // hash must byte-equal the `Value::String(String)` hash so
35089 // the two paths agree on `get`, `contains_key`, and the
35090 // absence path (`None` when the key is missing) — otherwise
35091 // a future `serde_yaml` upgrade could silently divert every
35092 // swept probe past the value the emitter inserted.
35093 let mut m = serde_yaml::Mapping::new();
35094 m.insert_str_key(KUBE_KEY_KIND, serde_yaml::Value::String("Gateway".into()));
35095 // Present-key path: both forms find the same value.
35096 assert_eq!(
35097 m.get(KUBE_KEY_KIND),
35098 m.get(serde_yaml::Value::String(KUBE_KEY_KIND.into())),
35099 "mapping.get(<KEY>) must byte-equal \
35100 mapping.get(Value::String(<KEY>.into())) — otherwise the \
35101 ~78 swept test-side probes drift silently past the value \
35102 the emitter inserted under the promoted Value::String key"
35103 );
35104 // Absent-key path: both forms return None.
35105 assert_eq!(
35106 m.get(KUBE_KEY_SPEC),
35107 m.get(serde_yaml::Value::String(KUBE_KEY_SPEC.into())),
35108 "absent-key lookup via bare-&str must byte-equal absent-key \
35109 lookup via Value::String — both must return None so the \
35110 swept `assert!(_.get(K).is_none())` shape stays load-bearing"
35111 );
35112 // contains_key parity: both forms agree on present + absent.
35113 assert_eq!(
35114 m.contains_key(KUBE_KEY_KIND),
35115 m.contains_key(serde_yaml::Value::String(KUBE_KEY_KIND.into())),
35116 "mapping.contains_key(<KEY>) must byte-equal \
35117 mapping.contains_key(Value::String(<KEY>.into())) — \
35118 otherwise the swept `assert!(_.contains_key(K))` shape \
35119 disagrees with the emitter's `insert_str_key` promotion"
35120 );
35121 assert_eq!(
35122 m.contains_key(KUBE_KEY_SPEC),
35123 m.contains_key(serde_yaml::Value::String(KUBE_KEY_SPEC.into())),
35124 "absent-key contains_key via bare-&str must byte-equal \
35125 absent-key contains_key via Value::String"
35126 );
35127 }
35128
35129 #[test]
35130 fn mapping_get_mut_bare_str_key_byte_equals_value_string_wrapped_form() {
35131 // The mutation-path twin of the read-side pin above.
35132 // `serde_yaml::Mapping::get_mut<I: Index>` accepts any
35133 // `I: Index` — the crate ships `impl Index for str` (routing
35134 // through the same no-allocation `HashLikeValue(&str)` bucket
35135 // lookup the read-side `get` / `contains_key` sweep landed on
35136 // in 0e84fb9) and `impl Index for Value` (matching the
35137 // `Value::String(_)` key verbatim). Until this pin landed the
35138 // sole production `.get_mut(serde_yaml::Value::String(<KEY>.into()))`
35139 // probe — [`caixa_flux::upsert_into_helmrelease_programs`]'s
35140 // `root.get_mut(…)` HelmRelease-side spec-mutate at
35141 // `caixa-flux/src/lib.rs:845` (which the sibling
35142 // `kube_key_spec_re_export_points_at_caixa_core_canonical`
35143 // pinning test's docstring already described in the shorter
35144 // `root.get_mut("spec")` form the 0e84fb9 read-side sweep
35145 // landed elsewhere on) — carried the verbose `Value::String`-
35146 // wrapped shape as the last stray hold-out on the `get_mut`
35147 // axis. The sweep swaps it onto the bare-`&str` form, matching
35148 // the ~78 read-side probes 0e84fb9 already swept and the
35149 // in-file `kube_key_spec_re_export_points_at_caixa_core_canonical`
35150 // docstring's canonical description. Pin the equivalence — the
35151 // `HashLikeValue(&str)` hash must byte-equal the
35152 // `Value::String(String)` hash so the two paths agree on both
35153 // the present-key path (returns `Some(&mut _)` at the same
35154 // slot) and the absent-key path (returns `None` when the key
35155 // is missing) — otherwise a future `serde_yaml` upgrade could
35156 // silently divert the writer-side upsert past the value the
35157 // emitter previously mutated. Peer to the read-side
35158 // [`mapping_get_bare_str_key_byte_equals_value_string_wrapped_form`]
35159 // pin on the sibling `get` / `contains_key` axes; together the
35160 // two pins pin every `Index`-polymorphic probe axis the
35161 // caixa-flux upsert path walks.
35162 let mut m = serde_yaml::Mapping::new();
35163 m.insert_str_key(KUBE_KEY_KIND, serde_yaml::Value::String("Gateway".into()));
35164 // Present-key path: both forms find the same slot.
35165 // Cross-check by mutating through the bare-&str path and
35166 // observing the mutation via the Value::String path (and vice
35167 // versa) — anything short of exact bucket-equality would
35168 // silently split the two probes onto different slots.
35169 {
35170 let via_bare = m
35171 .get_mut(KUBE_KEY_KIND)
35172 .expect("present key must resolve via bare-&str");
35173 *via_bare = serde_yaml::Value::String("HTTPRoute".into());
35174 }
35175 assert_eq!(
35176 m.get(serde_yaml::Value::String(KUBE_KEY_KIND.into())),
35177 Some(&serde_yaml::Value::String("HTTPRoute".into())),
35178 "mutation via mapping.get_mut(<KEY>) must be visible via \
35179 mapping.get(Value::String(<KEY>.into())) — otherwise the \
35180 swept `get_mut` writer-side probe drifts past the value \
35181 the emitter reads through the promoted Value::String key"
35182 );
35183 {
35184 let via_wrapped = m
35185 .get_mut(serde_yaml::Value::String(KUBE_KEY_KIND.into()))
35186 .expect("present key must also resolve via Value::String");
35187 *via_wrapped = serde_yaml::Value::String("Gateway".into());
35188 }
35189 assert_eq!(
35190 m.get(KUBE_KEY_KIND),
35191 Some(&serde_yaml::Value::String("Gateway".into())),
35192 "mutation via mapping.get_mut(Value::String(<KEY>.into())) \
35193 must be visible via mapping.get(<KEY>) — the two paths \
35194 address the same bucket in both directions"
35195 );
35196 // Absent-key path: both forms return None so the sole swept
35197 // `.get_mut(<KEY>).ok_or(Error::MissingField(<KEY>))` shape
35198 // stays load-bearing.
35199 assert!(
35200 m.get_mut(KUBE_KEY_SPEC).is_none(),
35201 "absent-key mapping.get_mut(<KEY>) must return None"
35202 );
35203 assert!(
35204 m.get_mut(serde_yaml::Value::String(KUBE_KEY_SPEC.into()))
35205 .is_none(),
35206 "absent-key mapping.get_mut(Value::String(<KEY>.into())) \
35207 must also return None — the two forms must agree on \
35208 absence so the swept `.ok_or(Error::MissingField(<KEY>))` \
35209 diagnostic still fires on a missing spec block"
35210 );
35211 }
35212
35213 #[test]
35214 fn mapping_ext_insert_string_promotes_value_to_yaml_string() {
35215 // The trait method promotes an arbitrary `Into<String>` value
35216 // to `Value::String(value.into())` — pin the promotion so a
35217 // future refactor that reaches for a different `Value` variant
35218 // for the string-scalar payload (e.g. `Value::Tagged` under a
35219 // K8s Server-Side-Apply typed-field-ownership axis rebrand) is
35220 // a compile-visible break, not a silent per-consumer regression
35221 // at the K8s-artifact-emit surface. Peer with
35222 // [`mapping_ext_insert_str_key_promotes_key_to_yaml_string`] on
35223 // the sibling `insert_str_key` primitive's key-promotion pin.
35224 let mut m = serde_yaml::Mapping::new();
35225 let prior = m.insert_string("kind", "Gateway");
35226 assert!(
35227 prior.is_none(),
35228 "insert_string returns None on first insertion, mirroring \
35229 serde_yaml::Mapping::insert"
35230 );
35231 let got = m
35232 .get("kind")
35233 .expect("inserted key is present under Value::String promotion");
35234 assert_eq!(
35235 got,
35236 &serde_yaml::Value::String("Gateway".into()),
35237 "insert_string routes value verbatim through Value::String \
35238 promotion"
35239 );
35240 }
35241
35242 #[test]
35243 fn mapping_ext_insert_string_returns_prior_value_on_replace() {
35244 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35245 // return contract: the prior value at that key, or `None` if
35246 // absent. Pin the replace-returns-prior semantic so a future
35247 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35248 // silently drop the prior-value handoff downstream consumers
35249 // may reach for. Peer with
35250 // [`mapping_ext_insert_str_key_returns_prior_value_on_replace`]
35251 // on the sibling `insert_str_key` primitive's replace-semantics
35252 // pin.
35253 let mut m = serde_yaml::Mapping::new();
35254 m.insert_string(KUBE_KEY_KIND, "Gateway");
35255 let prior = m.insert_string(KUBE_KEY_KIND, "HTTPRoute");
35256 assert_eq!(
35257 prior,
35258 Some(serde_yaml::Value::String("Gateway".into())),
35259 "insert_string returns the prior value when replacing an \
35260 existing key"
35261 );
35262 let got = m
35263 .get(KUBE_KEY_KIND)
35264 .expect("key is still present after replace");
35265 assert_eq!(
35266 got,
35267 &serde_yaml::Value::String("HTTPRoute".into()),
35268 "replaced value is now the most-recently-inserted one"
35269 );
35270 }
35271
35272 #[test]
35273 fn mapping_ext_insert_string_matches_hand_written_promotion() {
35274 // Cross-check the trait method against the hand-written
35275 // `mapping.insert_str_key(KEY, Value::String(V.into()))` shape
35276 // the ~17 lifted call sites previously carried. A drift between
35277 // the trait method's promotion and the inline promotion would
35278 // silently emit a different YAML mapping (a differently-quoted
35279 // scalar, a different `Value` variant) at every routed
35280 // consumer — pin the equivalence so the trait remains a drop-in
35281 // replacement. Also cross-checks that all three input shapes
35282 // (`&'static str` → `.into()`, `String` → `.clone()` /
35283 // `.to_string()`, integer → `.to_string()`) converge on the same
35284 // `Value::String` promotion, since the ~17 call sites cover all
35285 // three input flavors.
35286 let mut via_trait = serde_yaml::Mapping::new();
35287 via_trait.insert_string(KUBE_KEY_KIND, "Gateway");
35288 via_trait.insert_string(KUBE_KEY_NAME, String::from("hello"));
35289 via_trait.insert_string(KUBE_KEY_PORT, 8080u16.to_string());
35290
35291 let mut via_inline = serde_yaml::Mapping::new();
35292 via_inline.insert_str_key(KUBE_KEY_KIND, serde_yaml::Value::String("Gateway".into()));
35293 via_inline.insert_str_key(
35294 KUBE_KEY_NAME,
35295 serde_yaml::Value::String(String::from("hello")),
35296 );
35297 via_inline.insert_str_key(
35298 KUBE_KEY_PORT,
35299 serde_yaml::Value::String(8080u16.to_string()),
35300 );
35301
35302 assert_eq!(
35303 via_trait, via_inline,
35304 "insert_string(KEY, V) must byte-equal \
35305 insert_str_key(KEY, Value::String(V.into())) — otherwise \
35306 the ~17 routed consumer sites drift silently at emit time"
35307 );
35308 }
35309
35310 #[test]
35311 fn mapping_ext_insert_number_promotes_value_to_yaml_number() {
35312 // The trait method promotes an arbitrary `Into<serde_yaml::Number>`
35313 // value to `Value::Number(value.into())` — pin the promotion so a
35314 // future refactor that reaches for a different `Value` variant
35315 // for the integer-scalar payload (e.g. `Value::Tagged` under a
35316 // K8s Server-Side-Apply typed-field-ownership axis rebrand, or
35317 // the deprecated `Value::String(n.to_string())` "stringy port"
35318 // rendering some pre-Gateway-API-v1 CRDs still shipped with) is
35319 // a compile-visible break, not a silent per-consumer regression
35320 // at the K8s-artifact-emit surface. Peer with
35321 // [`mapping_ext_insert_string_promotes_value_to_yaml_string`] on
35322 // the sibling `insert_string` primitive's string-scalar
35323 // promotion pin.
35324 let mut m = serde_yaml::Mapping::new();
35325 let prior = m.insert_number(KUBE_KEY_PORT, GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT);
35326 assert!(
35327 prior.is_none(),
35328 "insert_number returns None on first insertion, mirroring \
35329 serde_yaml::Mapping::insert"
35330 );
35331 let got = m
35332 .get(KUBE_KEY_PORT)
35333 .expect("inserted key is present under Value::Number promotion");
35334 assert_eq!(
35335 got.as_u64(),
35336 Some(u64::from(GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT)),
35337 "insert_number routes value verbatim through Value::Number \
35338 promotion — the u16 payload survives round-trip as a Number \
35339 the as_u64 accessor decodes verbatim"
35340 );
35341 assert!(
35342 matches!(got, serde_yaml::Value::Number(_)),
35343 "the promoted value is Value::Number, not Value::String — a \
35344 stringy-port drift would emit `port: \"80\"` (rejected by \
35345 Gateway API v1 apiserver as a type mismatch)"
35346 );
35347 }
35348
35349 #[test]
35350 fn mapping_ext_insert_number_returns_prior_value_on_replace() {
35351 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35352 // return contract: the prior value at that key, or `None` if
35353 // absent. Pin the replace-returns-prior semantic so a future
35354 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35355 // silently drop the prior-value handoff downstream consumers
35356 // may reach for. Peer with
35357 // [`mapping_ext_insert_string_returns_prior_value_on_replace`] on
35358 // the sibling `insert_string` primitive's replace-semantics pin.
35359 let mut m = serde_yaml::Mapping::new();
35360 m.insert_number(KUBE_KEY_PORT, 80u16);
35361 let prior = m.insert_number(KUBE_KEY_PORT, 443u16);
35362 assert_eq!(
35363 prior.as_ref().and_then(serde_yaml::Value::as_u64),
35364 Some(80),
35365 "insert_number returns the prior value when replacing an \
35366 existing key — the u16 payload round-trips verbatim through \
35367 the returned Value::Number handoff"
35368 );
35369 let got = m
35370 .get(KUBE_KEY_PORT)
35371 .expect("key is still present after replace");
35372 assert_eq!(
35373 got.as_u64(),
35374 Some(443),
35375 "replaced value is now the most-recently-inserted one"
35376 );
35377 }
35378
35379 #[test]
35380 fn mapping_ext_insert_number_matches_hand_written_promotion() {
35381 // Cross-check the trait method against the hand-written
35382 // `mapping.insert_str_key(KEY, Value::Number(N.into()))` shape
35383 // the two lifted caixa-mesh call sites previously carried. A
35384 // drift between the trait method's promotion and the inline
35385 // promotion would silently emit a different YAML mapping (a
35386 // differently-typed scalar, a different `Value` variant) at
35387 // every routed consumer — pin the equivalence so the trait
35388 // remains a drop-in replacement. Two arms pin the axis end-to-
35389 // end: a `u16` typed-const arm (the lifted
35390 // `GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT` external HTTP
35391 // listener-port, cd60fde) and a `u16` typed-field arm (the
35392 // per-`entrada.port` backend-target Servico port routed through
35393 // the `AplicacaoSpec` `:entrada :port` slot).
35394 let mut via_trait = serde_yaml::Mapping::new();
35395 via_trait.insert_number(KUBE_KEY_PORT, GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT);
35396 via_trait.insert_number(GATEWAY_API_KEY_VALUE, 8443u16);
35397
35398 let mut via_inline = serde_yaml::Mapping::new();
35399 via_inline.insert_str_key(
35400 KUBE_KEY_PORT,
35401 serde_yaml::Value::Number(GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT.into()),
35402 );
35403 via_inline.insert_str_key(
35404 GATEWAY_API_KEY_VALUE,
35405 serde_yaml::Value::Number(8443u16.into()),
35406 );
35407
35408 assert_eq!(
35409 via_trait, via_inline,
35410 "insert_number(KEY, N) must byte-equal \
35411 insert_str_key(KEY, Value::Number(N.into())) — otherwise \
35412 the two routed caixa-mesh consumer sites drift silently at \
35413 emit time"
35414 );
35415 }
35416
35417 #[test]
35418 fn mapping_ext_insert_mapping_promotes_value_to_yaml_mapping() {
35419 // The trait method promotes an arbitrary `serde_yaml::Mapping`
35420 // value to `Value::Mapping(value)` — pin the promotion so a
35421 // future refactor that reaches for a different `Value` variant
35422 // for the nested-Mapping payload (e.g. `Value::Tagged` under a
35423 // K8s Server-Side-Apply typed-field-ownership axis rebrand) is
35424 // a compile-visible break, not a silent per-consumer regression
35425 // at the K8s-artifact-emit surface. Peer with
35426 // [`mapping_ext_insert_string_promotes_value_to_yaml_string`] on
35427 // the sibling `insert_string` primitive's scalar-promotion pin
35428 // and with
35429 // [`mapping_ext_insert_str_key_promotes_key_to_yaml_string`] on
35430 // the base `insert_str_key` primitive's key-promotion pin.
35431 let mut inner = serde_yaml::Mapping::new();
35432 inner.insert_string(KUBE_KEY_NAME, "hello-rio");
35433 let mut m = serde_yaml::Mapping::new();
35434 let prior = m.insert_mapping(KUBE_KEY_METADATA, inner.clone());
35435 assert!(
35436 prior.is_none(),
35437 "insert_mapping returns None on first insertion, mirroring \
35438 serde_yaml::Mapping::insert"
35439 );
35440 let got = m
35441 .get(KUBE_KEY_METADATA)
35442 .expect("inserted key is present under Value::Mapping promotion");
35443 assert_eq!(
35444 got,
35445 &serde_yaml::Value::Mapping(inner),
35446 "insert_mapping routes value verbatim through Value::Mapping \
35447 promotion"
35448 );
35449 }
35450
35451 #[test]
35452 fn mapping_ext_insert_mapping_returns_prior_value_on_replace() {
35453 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35454 // return contract: the prior value at that key, or `None` if
35455 // absent. Pin the replace-returns-prior semantic so a future
35456 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35457 // silently drop the prior-value handoff downstream consumers
35458 // may reach for. Peer with
35459 // [`mapping_ext_insert_string_returns_prior_value_on_replace`]
35460 // and
35461 // [`mapping_ext_insert_str_key_returns_prior_value_on_replace`]
35462 // on the sibling primitive-pair members' replace-semantics
35463 // pins.
35464 let mut first_inner = serde_yaml::Mapping::new();
35465 first_inner.insert_string(KUBE_KEY_NAME, "first");
35466 let mut second_inner = serde_yaml::Mapping::new();
35467 second_inner.insert_string(KUBE_KEY_NAME, "second");
35468 let mut m = serde_yaml::Mapping::new();
35469 m.insert_mapping(KUBE_KEY_METADATA, first_inner.clone());
35470 let prior = m.insert_mapping(KUBE_KEY_METADATA, second_inner.clone());
35471 assert_eq!(
35472 prior,
35473 Some(serde_yaml::Value::Mapping(first_inner)),
35474 "insert_mapping returns the prior value when replacing an \
35475 existing key"
35476 );
35477 let got = m
35478 .get(KUBE_KEY_METADATA)
35479 .expect("key is still present after replace");
35480 assert_eq!(
35481 got,
35482 &serde_yaml::Value::Mapping(second_inner),
35483 "replaced value is now the most-recently-inserted one"
35484 );
35485 }
35486
35487 #[test]
35488 fn mapping_ext_insert_mapping_matches_hand_written_promotion() {
35489 // Cross-check the trait method against the hand-written
35490 // `mapping.insert_str_key(KEY, Value::Mapping(inner))` shape the
35491 // 6 lifted call sites previously carried. A drift between the
35492 // trait method's promotion and the inline promotion would
35493 // silently emit a different YAML mapping (a differently-wrapped
35494 // outer variant, a differently-shaped inner Mapping) at every
35495 // routed consumer — pin the equivalence so the trait remains a
35496 // drop-in replacement. Two cases pin the shape end-to-end:
35497 // an empty inner Mapping (no silent is_empty short-circuit) and
35498 // a populated inner Mapping (the `metadata` / `spec` /
35499 // `spec.rules[].path` sub-block shape).
35500 let mut inner_empty = serde_yaml::Mapping::new();
35501 let _ = &mut inner_empty; // keep as mut for parity with populated arm below
35502 let mut inner_populated = serde_yaml::Mapping::new();
35503 inner_populated.insert_string(KUBE_KEY_NAME, "hello-rio");
35504 inner_populated.insert_string(KUBE_KEY_NAMESPACE, DEFAULT_NAMESPACE);
35505
35506 let mut via_trait = serde_yaml::Mapping::new();
35507 via_trait.insert_mapping(KUBE_KEY_SPEC, inner_empty.clone());
35508 via_trait.insert_mapping(KUBE_KEY_METADATA, inner_populated.clone());
35509
35510 let mut via_inline = serde_yaml::Mapping::new();
35511 via_inline.insert_str_key(KUBE_KEY_SPEC, serde_yaml::Value::Mapping(inner_empty));
35512 via_inline.insert_str_key(
35513 KUBE_KEY_METADATA,
35514 serde_yaml::Value::Mapping(inner_populated),
35515 );
35516
35517 assert_eq!(
35518 via_trait, via_inline,
35519 "insert_mapping(KEY, inner) must byte-equal \
35520 insert_str_key(KEY, Value::Mapping(inner)) — otherwise the \
35521 six routed consumer sites drift silently at emit time"
35522 );
35523 }
35524
35525 #[test]
35526 fn mapping_ext_insert_sequence_promotes_value_to_yaml_sequence() {
35527 // The trait method promotes an arbitrary `Vec<Value>` value to
35528 // `Value::Sequence(value)` — pin the promotion so a future
35529 // refactor that reaches for a different `Value` variant for the
35530 // list-shape payload (e.g. `Value::Tagged` under a K8s Server-
35531 // Side-Apply typed-field-ownership axis rebrand, a serde_yaml
35532 // successor's `Value::Array` / `Value::List` variant rename) is
35533 // a compile-visible break, not a silent per-consumer regression
35534 // at the K8s-artifact-emit surface. Peer with
35535 // [`mapping_ext_insert_mapping_promotes_value_to_yaml_mapping`]
35536 // on the sibling `insert_mapping` primitive's nested-Mapping-
35537 // promotion pin, and with
35538 // [`mapping_ext_insert_string_promotes_value_to_yaml_string`]
35539 // on the sibling `insert_string` primitive's scalar-promotion
35540 // pin.
35541 let inner = vec![
35542 serde_yaml::Value::String("hello".into()),
35543 serde_yaml::Value::String("world".into()),
35544 ];
35545 let mut m = serde_yaml::Mapping::new();
35546 let prior = m.insert_sequence(GATEWAY_API_KEY_HOSTNAMES, inner.clone());
35547 assert!(
35548 prior.is_none(),
35549 "insert_sequence returns None on first insertion, mirroring \
35550 serde_yaml::Mapping::insert"
35551 );
35552 let got = m
35553 .get(GATEWAY_API_KEY_HOSTNAMES)
35554 .expect("inserted key is present under Value::Sequence promotion");
35555 assert_eq!(
35556 got,
35557 &serde_yaml::Value::Sequence(inner),
35558 "insert_sequence routes value verbatim through Value::Sequence \
35559 promotion"
35560 );
35561 }
35562
35563 #[test]
35564 fn mapping_ext_insert_sequence_returns_prior_value_on_replace() {
35565 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35566 // return contract: the prior value at that key, or `None` if
35567 // absent. Pin the replace-returns-prior semantic so a future
35568 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35569 // silently drop the prior-value handoff downstream consumers
35570 // may reach for. Peer with
35571 // [`mapping_ext_insert_mapping_returns_prior_value_on_replace`],
35572 // [`mapping_ext_insert_string_returns_prior_value_on_replace`],
35573 // and
35574 // [`mapping_ext_insert_str_key_returns_prior_value_on_replace`]
35575 // on the sibling primitive-quadruple members' replace-semantics
35576 // pins.
35577 let first: Vec<serde_yaml::Value> = vec![serde_yaml::Value::String("a".into())];
35578 let second: Vec<serde_yaml::Value> = vec![
35579 serde_yaml::Value::String("b".into()),
35580 serde_yaml::Value::String("c".into()),
35581 ];
35582 let mut m = serde_yaml::Mapping::new();
35583 m.insert_sequence(KUBE_KEY_RULES, first.clone());
35584 let prior = m.insert_sequence(KUBE_KEY_RULES, second.clone());
35585 assert_eq!(
35586 prior,
35587 Some(serde_yaml::Value::Sequence(first)),
35588 "insert_sequence returns the prior value when replacing an \
35589 existing key"
35590 );
35591 let got = m
35592 .get(KUBE_KEY_RULES)
35593 .expect("key is still present after replace");
35594 assert_eq!(
35595 got,
35596 &serde_yaml::Value::Sequence(second),
35597 "replaced value is now the most-recently-inserted one"
35598 );
35599 }
35600
35601 #[test]
35602 fn mapping_ext_insert_sequence_matches_hand_written_promotion() {
35603 // Cross-check the trait method against the hand-written
35604 // `mapping.insert_str_key(KEY, Value::Sequence(v))` shape the 4
35605 // lifted call sites previously carried. A drift between the
35606 // trait method's promotion and the inline promotion would
35607 // silently emit a different YAML mapping (a differently-wrapped
35608 // outer variant, a differently-shaped inner sequence) at every
35609 // routed consumer — pin the equivalence so the trait remains a
35610 // drop-in replacement. Three cases pin the shape end-to-end:
35611 // an empty inner Vec (no silent is_empty short-circuit), a
35612 // singleton-Value inner Vec (the `fromEndpoints[<selector>]` /
35613 // `hostnames[<host>]` singleton shape), and a multi-Value inner
35614 // Vec (the `toPorts[…]` / `rules[…]` multi-entry shape).
35615 let inner_empty: Vec<serde_yaml::Value> = Vec::new();
35616 let inner_singleton: Vec<serde_yaml::Value> =
35617 vec![serde_yaml::Value::String("example.com".into())];
35618 let mut host_entry = serde_yaml::Mapping::new();
35619 host_entry.insert_string(KUBE_KEY_NAME, "svc-a");
35620 let mut port_entry = serde_yaml::Mapping::new();
35621 port_entry.insert_string(KUBE_KEY_NAME, "svc-b");
35622 let inner_multi: Vec<serde_yaml::Value> = vec![
35623 serde_yaml::Value::Mapping(host_entry.clone()),
35624 serde_yaml::Value::Mapping(port_entry.clone()),
35625 ];
35626
35627 let mut via_trait = serde_yaml::Mapping::new();
35628 via_trait.insert_sequence(CILIUM_KEY_TO_PORTS, inner_empty.clone());
35629 via_trait.insert_sequence(GATEWAY_API_KEY_HOSTNAMES, inner_singleton.clone());
35630 via_trait.insert_sequence(KUBE_KEY_RULES, inner_multi.clone());
35631
35632 let mut via_inline = serde_yaml::Mapping::new();
35633 via_inline.insert_str_key(
35634 CILIUM_KEY_TO_PORTS,
35635 serde_yaml::Value::Sequence(inner_empty),
35636 );
35637 via_inline.insert_str_key(
35638 GATEWAY_API_KEY_HOSTNAMES,
35639 serde_yaml::Value::Sequence(inner_singleton),
35640 );
35641 via_inline.insert_str_key(KUBE_KEY_RULES, serde_yaml::Value::Sequence(inner_multi));
35642
35643 assert_eq!(
35644 via_trait, via_inline,
35645 "insert_sequence(KEY, v) must byte-equal \
35646 insert_str_key(KEY, Value::Sequence(v)) — otherwise the \
35647 four routed consumer sites drift silently at emit time"
35648 );
35649 }
35650
35651 // ── insert_singleton_mapping_sequence — composed primitive ───────────
35652 //
35653 // The trait method composes [`Self::insert_str_key`] with
35654 // [`singleton_mapping_sequence`]: every hand-inline
35655 // `mapping.insert_str_key(K, singleton_mapping_sequence(m))` two-symbol
35656 // composition previously carried at 7 sites across caixa-mesh
35657 // collapses onto one method call. Three peer pins pin the trait
35658 // method's shape end-to-end.
35659
35660 #[test]
35661 fn mapping_ext_insert_singleton_mapping_sequence_promotes_value_to_singleton_mapping_seq() {
35662 // First-insertion returns None (mirroring [`Mapping::insert`])
35663 // and the inserted value is a `Value::Sequence` of exactly one
35664 // element, wrapping the caller's Mapping as `Value::Mapping`.
35665 // Peer with the sibling
35666 // `mapping_ext_insert_sequence_promotes_value_to_yaml_sequence`
35667 // / `mapping_ext_insert_mapping_promotes_value_to_yaml_mapping`
35668 // / `mapping_ext_insert_string_promotes_value_to_yaml_string`
35669 // first-insert pins on the sibling MappingExt primitive
35670 // members.
35671 let mut inner = serde_yaml::Mapping::new();
35672 inner.insert_str_key(
35673 GATEWAY_API_KEY_NAME,
35674 serde_yaml::Value::String("gw-listener".into()),
35675 );
35676 let mut m = serde_yaml::Mapping::new();
35677 let prior = m.insert_singleton_mapping_sequence(GATEWAY_API_KEY_LISTENERS, inner.clone());
35678 assert_eq!(
35679 prior, None,
35680 "insert_singleton_mapping_sequence returns None on first insertion, \
35681 mirroring serde_yaml::Mapping::insert"
35682 );
35683 let got = m
35684 .get(GATEWAY_API_KEY_LISTENERS)
35685 .expect("inserted key is present under Value::Sequence promotion");
35686 assert_eq!(
35687 got,
35688 &serde_yaml::Value::Sequence(vec![serde_yaml::Value::Mapping(inner)]),
35689 "insert_singleton_mapping_sequence routes value verbatim through \
35690 the singleton_mapping_sequence(_) helper wrap"
35691 );
35692 }
35693
35694 #[test]
35695 fn mapping_ext_insert_singleton_mapping_sequence_returns_prior_value_on_replace() {
35696 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35697 // return contract: the prior value at that key, or `None` if
35698 // absent. Pin the replace-returns-prior semantic so a future
35699 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35700 // silently drop the prior-value handoff downstream consumers
35701 // may reach for. Peer with the sibling
35702 // `mapping_ext_insert_sequence_returns_prior_value_on_replace`
35703 // and its siblings on the primitive-quintuple axis.
35704 let mut first = serde_yaml::Mapping::new();
35705 first.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("a".into()));
35706 let mut second = serde_yaml::Mapping::new();
35707 second.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("b".into()));
35708 let mut m = serde_yaml::Mapping::new();
35709 m.insert_singleton_mapping_sequence(GATEWAY_API_KEY_PARENT_REFS, first.clone());
35710 let prior =
35711 m.insert_singleton_mapping_sequence(GATEWAY_API_KEY_PARENT_REFS, second.clone());
35712 assert_eq!(
35713 prior,
35714 Some(serde_yaml::Value::Sequence(vec![
35715 serde_yaml::Value::Mapping(first)
35716 ])),
35717 "insert_singleton_mapping_sequence returns the prior value \
35718 when replacing an existing key"
35719 );
35720 let got = m
35721 .get(GATEWAY_API_KEY_PARENT_REFS)
35722 .expect("key is still present after replace");
35723 assert_eq!(
35724 got,
35725 &serde_yaml::Value::Sequence(vec![serde_yaml::Value::Mapping(second)]),
35726 "replaced value is now the most-recently-inserted singleton \
35727 mapping sequence"
35728 );
35729 }
35730
35731 #[test]
35732 fn mapping_ext_insert_singleton_mapping_sequence_matches_hand_written_composition() {
35733 // Cross-check the trait method against the hand-written
35734 // `mapping.insert_str_key(KEY, singleton_mapping_sequence(m))`
35735 // two-symbol composition the 7 lifted call sites previously
35736 // carried. A drift between the trait method's routing and the
35737 // inline composition would silently emit a different YAML
35738 // mapping (a differently-wrapped outer variant, a
35739 // differently-shaped inner singleton-Mapping list) at every
35740 // routed consumer — pin the equivalence so the trait remains a
35741 // drop-in replacement. Three cases pin the shape end-to-end:
35742 // an empty inner Mapping (no silent is_empty short-circuit,
35743 // matches the sibling `singleton_mapping_sequence_preserves_empty_inner_mapping`
35744 // pin), a single-key inner Mapping (the
35745 // `CILIUM_KEY_HTTP` / `CILIUM_KEY_INGRESS` singleton-rule
35746 // shape), and a multi-key inner Mapping (the
35747 // `GATEWAY_API_KEY_LISTENERS` per-listener shape).
35748 let inner_empty = serde_yaml::Mapping::new();
35749 let mut inner_single_key = serde_yaml::Mapping::new();
35750 inner_single_key
35751 .insert_str_key(CILIUM_KEY_PATH, serde_yaml::Value::String("/health".into()));
35752 let mut inner_multi_key = serde_yaml::Mapping::new();
35753 inner_multi_key.insert_str_key(
35754 GATEWAY_API_KEY_NAME,
35755 serde_yaml::Value::String("http".into()),
35756 );
35757 inner_multi_key.insert_str_key(
35758 KUBE_KEY_PORT,
35759 serde_yaml::Value::Number(GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT.into()),
35760 );
35761
35762 let mut via_trait = serde_yaml::Mapping::new();
35763 via_trait.insert_singleton_mapping_sequence(CILIUM_KEY_HTTP, inner_empty.clone());
35764 via_trait.insert_singleton_mapping_sequence(CILIUM_KEY_INGRESS, inner_single_key.clone());
35765 via_trait
35766 .insert_singleton_mapping_sequence(GATEWAY_API_KEY_LISTENERS, inner_multi_key.clone());
35767
35768 let mut via_inline = serde_yaml::Mapping::new();
35769 via_inline.insert_str_key(CILIUM_KEY_HTTP, singleton_mapping_sequence(inner_empty));
35770 via_inline.insert_str_key(
35771 CILIUM_KEY_INGRESS,
35772 singleton_mapping_sequence(inner_single_key),
35773 );
35774 via_inline.insert_str_key(
35775 GATEWAY_API_KEY_LISTENERS,
35776 singleton_mapping_sequence(inner_multi_key),
35777 );
35778
35779 assert_eq!(
35780 via_trait, via_inline,
35781 "insert_singleton_mapping_sequence(KEY, m) must byte-equal \
35782 insert_str_key(KEY, singleton_mapping_sequence(m)) — otherwise \
35783 the seven routed caixa-mesh consumer sites drift silently at \
35784 emit time"
35785 );
35786 }
35787
35788 // ── entry_str_key — entry-API twin of insert_str_key ─────────────────
35789
35790 #[test]
35791 fn mapping_ext_entry_str_key_or_inserts_default_under_yaml_string_promoted_key_when_absent() {
35792 // The trait method promotes an arbitrary `&str` key to
35793 // `Value::String(key.to_string())` on the entry-API axis — pin
35794 // the promotion + the entry-API contract so a future refactor
35795 // that reaches for a different `Value` variant for the entry
35796 // key (e.g. `Value::Tagged`) or breaks the entry-API
35797 // `.or_insert(...)` composition is a compile-visible break,
35798 // not a silent per-consumer regression at the 4 lifted
35799 // `caixa-flux` idempotent-upsert sites. Peer with the sibling
35800 // [`mapping_ext_insert_str_key_promotes_key_to_yaml_string`] on
35801 // the fresh-emit axis of the same key promotion.
35802 let mut m = serde_yaml::Mapping::new();
35803 let default_val = serde_yaml::Value::Sequence(Vec::new());
35804 let inserted = m.entry_str_key("programs").or_insert(default_val.clone());
35805 assert_eq!(
35806 inserted, &default_val,
35807 "entry_str_key(K).or_insert(D) returns &mut D on the absent-key \
35808 path, mirroring serde_yaml::mapping::Entry::or_insert"
35809 );
35810 // Key is exactly the `Value::String` promotion of the input.
35811 let got = m
35812 .get("programs")
35813 .expect("or_insert-defaulted key is present under Value::String promotion");
35814 assert_eq!(
35815 got, &default_val,
35816 "entry_str_key routes the default verbatim to the underlying \
35817 serde_yaml::Mapping::entry(...).or_insert(...) path"
35818 );
35819 }
35820
35821 #[test]
35822 fn mapping_ext_entry_str_key_leaves_prior_value_untouched_on_or_insert_when_present() {
35823 // The trait method mirrors [`serde_yaml::mapping::Entry::or_insert`]'s
35824 // present-key contract: the prior value is preserved, and the
35825 // returned `&mut Value` points at that prior value (NOT the
35826 // discarded default). Pin the leave-prior-untouched semantic so a
35827 // future refactor that swaps to an `.insert`-style overwrite
35828 // flow doesn't silently clobber every idempotent-upsert consumer
35829 // (the M4 per-`:politicas` overlay merger, the `feira app
35830 // deploy` idempotent-write dry-run comparator). Peer with the
35831 // sibling [`mapping_ext_insert_str_key_returns_prior_value_on_replace`]
35832 // pin on the fresh-emit axis (which mirrors the `insert`
35833 // replace-and-return-prior semantic, not the `entry.or_insert`
35834 // preserve-prior semantic — the two APIs partition the
35835 // `Mapping`-write surface exactly on this axis).
35836 let mut m = serde_yaml::Mapping::new();
35837 m.insert_str_key(
35838 FLEET_PROGRAMS_KEY_PROGRAMS,
35839 serde_yaml::Value::Sequence(vec![serde_yaml::Value::String("existing".into())]),
35840 );
35841 let discarded_default = serde_yaml::Value::Sequence(Vec::new());
35842 let returned = m
35843 .entry_str_key(FLEET_PROGRAMS_KEY_PROGRAMS)
35844 .or_insert(discarded_default);
35845 assert_eq!(
35846 returned,
35847 &serde_yaml::Value::Sequence(vec![serde_yaml::Value::String("existing".into())]),
35848 "entry_str_key(K).or_insert(D) returns &mut prior on the \
35849 present-key path — the discarded default must not overwrite \
35850 the emitter's prior write"
35851 );
35852 // Value at the key is still the pre-existing one, verbatim.
35853 let got = m
35854 .get(FLEET_PROGRAMS_KEY_PROGRAMS)
35855 .expect("key is still present after or_insert on the present-key path");
35856 assert_eq!(
35857 got,
35858 &serde_yaml::Value::Sequence(vec![serde_yaml::Value::String("existing".into())]),
35859 "or_insert on the present-key path preserves the prior value \
35860 verbatim — no clobber, no reshape"
35861 );
35862 }
35863
35864 #[test]
35865 fn mapping_ext_entry_str_key_matches_hand_written_composition() {
35866 // Cross-check the trait method against the hand-written
35867 // `mapping.entry(Value::String(KEY.into()))` three-token
35868 // composition the 4 lifted `caixa-flux` call sites previously
35869 // carried. A drift between the trait method's promotion and the
35870 // inline promotion the prior call sites used would silently
35871 // route every idempotent-upsert consumer past a different bucket
35872 // (a differently-promoted key on absent-key insert, a hash-key
35873 // mismatch that always fires the `or_insert` default even when
35874 // the emitter's `insert_str_key` already wrote a value under
35875 // the same key). Two cases pin the shape end-to-end: an
35876 // absent-key path (both routes take the vacant `or_insert`
35877 // branch, both end up storing the same default under the
35878 // promoted key) and a present-key path (both routes take the
35879 // occupied `or_insert` branch, both leave the prior value
35880 // untouched — the twin of the
35881 // `mapping_ext_insert_str_key_matches_hand_written_promotion`
35882 // pin on the fresh-emit axis).
35883 //
35884 // Absent-key path — the vacant `or_insert` branch.
35885 let mut via_trait_absent = serde_yaml::Mapping::new();
35886 via_trait_absent
35887 .entry_str_key(FLEET_PROGRAMS_KEY_PROGRAMS)
35888 .or_insert(serde_yaml::Value::Sequence(Vec::new()));
35889 let mut via_inline_absent = serde_yaml::Mapping::new();
35890 via_inline_absent
35891 .entry(serde_yaml::Value::String(
35892 FLEET_PROGRAMS_KEY_PROGRAMS.into(),
35893 ))
35894 .or_insert(serde_yaml::Value::Sequence(Vec::new()));
35895 assert_eq!(
35896 via_trait_absent, via_inline_absent,
35897 "entry_str_key(K).or_insert(D) must byte-equal \
35898 entry(Value::String(K.into())).or_insert(D) on the absent-key \
35899 path — otherwise the 4 routed caixa-flux consumer sites \
35900 land the default under a different bucket than the emitter's \
35901 `insert_str_key` write and the idempotent-upsert semantic \
35902 silently doubles the entry on every call"
35903 );
35904
35905 // Present-key path — the occupied `or_insert` branch. Seed both
35906 // mappings via the fresh-emit `insert_str_key` peer (which the
35907 // `matches_hand_written_promotion` pin already gates), so the
35908 // present-key path here inherits the promotion-agreement guarantee
35909 // from that peer and tests only the entry-API branch difference.
35910 let seed = serde_yaml::Value::Mapping(serde_yaml::Mapping::new());
35911 let mut via_trait_present = serde_yaml::Mapping::new();
35912 via_trait_present.insert_str_key(FLUX_KEY_VALUES, seed.clone());
35913 via_trait_present
35914 .entry_str_key(FLUX_KEY_VALUES)
35915 .or_insert(serde_yaml::Value::Sequence(Vec::new()));
35916 let mut via_inline_present = serde_yaml::Mapping::new();
35917 via_inline_present.insert_str_key(FLUX_KEY_VALUES, seed);
35918 via_inline_present
35919 .entry(serde_yaml::Value::String(FLUX_KEY_VALUES.into()))
35920 .or_insert(serde_yaml::Value::Sequence(Vec::new()));
35921 assert_eq!(
35922 via_trait_present, via_inline_present,
35923 "entry_str_key(K).or_insert(D) must byte-equal \
35924 entry(Value::String(K.into())).or_insert(D) on the \
35925 present-key path — otherwise a promoted-key mismatch would \
35926 cause the trait routing to see the seed as absent and \
35927 overwrite the emitter's prior write while the hand-written \
35928 inline routing sees it as present and preserves it (or vice \
35929 versa)"
35930 );
35931 }
35932
35933 // ── entry_or_default_{mapping,sequence} — entry-API-with-container-check ─
35934
35935 #[test]
35936 fn mapping_ext_entry_or_default_mapping_seeds_empty_inner_when_absent() {
35937 // Absent-key path — the helper mints an empty
35938 // `Value::Mapping(Mapping::new())` under the promoted key and
35939 // returns `Some(&mut inner)` pointing at the fresh empty inner.
35940 // Pin the seed shape so a future refactor that reaches for a
35941 // different empty-container variant (e.g. `Value::Null`, or a
35942 // `Mapping::with_capacity(_)` non-empty pre-allocation) or
35943 // breaks the `Option::Some` return contract is a compile-visible
35944 // break, not a silent per-consumer regression at the caixa-flux
35945 // `upsert_into_helmrelease_programs` `spec.values` container-
35946 // upsert. Peer with the sibling
35947 // [`mapping_ext_entry_or_default_sequence_seeds_empty_inner_when_absent`]
35948 // on the sibling list-container axis.
35949 let mut m = serde_yaml::Mapping::new();
35950 {
35951 let inner = m
35952 .entry_or_default_mapping(FLUX_KEY_VALUES)
35953 .expect("absent-key path seeds an empty Mapping and returns Some(&mut _)");
35954 assert!(
35955 inner.is_empty(),
35956 "the seeded default must be an EMPTY Mapping — a \
35957 non-empty pre-allocation would land a K8s CRD schema \
35958 pre-populated block the emitter never authored"
35959 );
35960 }
35961 // Key is exactly the `Value::String` promotion of the input,
35962 // and the value is the empty-Mapping seed.
35963 let got = m
35964 .get(FLUX_KEY_VALUES)
35965 .expect("or_default seeded the key under Value::String promotion");
35966 assert_eq!(
35967 got,
35968 &serde_yaml::Value::Mapping(serde_yaml::Mapping::new()),
35969 "entry_or_default_mapping seeds Value::Mapping(Mapping::new()) \
35970 verbatim on the absent-key arm — no reshape, no wrap"
35971 );
35972 }
35973
35974 #[test]
35975 fn mapping_ext_entry_or_default_mapping_preserves_prior_mapping_on_present_arm() {
35976 // Present-key path with matching variant — the helper mirrors
35977 // [`serde_yaml::mapping::Entry::or_insert_with`]'s occupied
35978 // branch: the prior value is preserved, and the returned
35979 // `&mut Mapping` points at that prior inner Mapping (NOT a
35980 // fresh empty default). Pin the leave-prior-untouched semantic
35981 // so a future refactor that reaches for an `.insert`-style
35982 // overwrite flow doesn't silently clobber every idempotent-
35983 // container-upsert consumer (the `feira app deploy` per-cluster
35984 // write path, the M4 per-cluster HelmRelease overlay merger).
35985 let mut m = serde_yaml::Mapping::new();
35986 let mut prior_inner = serde_yaml::Mapping::new();
35987 prior_inner.insert_str_key(HELM_VALUES_KEY_ENABLED, serde_yaml::Value::Bool(true));
35988 m.insert_mapping(FLUX_KEY_VALUES, prior_inner.clone());
35989 {
35990 let inner = m
35991 .entry_or_default_mapping(FLUX_KEY_VALUES)
35992 .expect("present-Mapping-variant path returns Some(&mut prior)");
35993 assert_eq!(
35994 inner, &prior_inner,
35995 "entry_or_default_mapping returns &mut prior on the \
35996 present-key path — the default empty Mapping must not \
35997 overwrite the emitter's prior write"
35998 );
35999 }
36000 // Value at the key is still the pre-existing one, verbatim.
36001 let got = m
36002 .get(FLUX_KEY_VALUES)
36003 .expect("key is still present after or_default on the present-key path");
36004 assert_eq!(
36005 got,
36006 &serde_yaml::Value::Mapping(prior_inner),
36007 "or_default on the present-key path preserves the prior \
36008 value verbatim — no clobber, no reshape"
36009 );
36010 }
36011
36012 #[test]
36013 fn mapping_ext_entry_or_default_mapping_returns_none_on_variant_mismatch() {
36014 // Present-key path with mismatched variant — the helper returns
36015 // `None`, letting the caller surface its domain-specific
36016 // "expected Mapping at this schema key" diagnostic (rather than
36017 // silently clobbering the mismatched prior value). Pin the
36018 // structural-mismatch-is-None contract so a future refactor
36019 // that reaches for a fallback-to-empty-default flow doesn't
36020 // silently overwrite user-authored non-Mapping data at the
36021 // canonical caixa-flux `Error::MissingField("spec.values must
36022 // be a mapping")` site — the mismatched-variant arm is
36023 // load-bearing for the domain-error diagnostic path, not just
36024 // a corner case.
36025 let mut m = serde_yaml::Mapping::new();
36026 m.insert_string(FLUX_KEY_VALUES, "not-a-mapping");
36027 let result = m.entry_or_default_mapping(FLUX_KEY_VALUES);
36028 assert!(
36029 result.is_none(),
36030 "entry_or_default_mapping returns None on variant \
36031 mismatch — the caller's `.ok_or(Error::MissingField(_))?` \
36032 chain surfaces the structural type-mismatch diagnostic"
36033 );
36034 let got = m
36035 .get(FLUX_KEY_VALUES)
36036 .expect("mismatched-variant prior value stays present after variant-check");
36037 assert_eq!(
36038 got,
36039 &serde_yaml::Value::String("not-a-mapping".into()),
36040 "None arm on variant mismatch leaves the prior value \
36041 untouched — the caller's domain-error path fires without \
36042 clobbering the user-authored data"
36043 );
36044 }
36045
36046 #[test]
36047 fn mapping_ext_entry_or_default_sequence_seeds_empty_inner_when_absent() {
36048 // Absent-key path — the helper mints an empty
36049 // `Value::Sequence(Vec::new())` under the promoted key and
36050 // returns `Some(&mut inner)` pointing at the fresh empty
36051 // `Vec<Value>`. Peer with
36052 // [`mapping_ext_entry_or_default_mapping_seeds_empty_inner_when_absent`]
36053 // on the nested-Mapping-container axis.
36054 let mut m = serde_yaml::Mapping::new();
36055 {
36056 let inner = m
36057 .entry_or_default_sequence(FLEET_PROGRAMS_KEY_PROGRAMS)
36058 .expect("absent-key path seeds an empty Vec and returns Some(&mut _)");
36059 assert!(
36060 inner.is_empty(),
36061 "the seeded default must be an EMPTY Vec — a non-empty \
36062 pre-allocation would land a pre-populated fleet-programs \
36063 list the emitter never authored"
36064 );
36065 }
36066 let got = m
36067 .get(FLEET_PROGRAMS_KEY_PROGRAMS)
36068 .expect("or_default seeded the key under Value::String promotion");
36069 assert_eq!(
36070 got,
36071 &serde_yaml::Value::Sequence(Vec::new()),
36072 "entry_or_default_sequence seeds Value::Sequence(Vec::new()) \
36073 verbatim on the absent-key arm — no reshape, no wrap"
36074 );
36075 }
36076
36077 #[test]
36078 fn mapping_ext_entry_or_default_sequence_preserves_prior_sequence_on_present_arm() {
36079 // Present-key path with matching variant — the helper mirrors
36080 // [`serde_yaml::mapping::Entry::or_insert_with`]'s occupied
36081 // branch: the prior `Vec` is preserved, and the returned
36082 // `&mut Vec<Value>` points at that prior inner Vec (NOT a
36083 // fresh empty default). The exact idempotent-upsert semantic
36084 // caixa-flux's `upsert_into_programs_yaml` /
36085 // `upsert_into_helmrelease_programs` depend on to preserve
36086 // prior `programs[]` entries across per-Servico rewrites.
36087 let mut m = serde_yaml::Mapping::new();
36088 let prior_inner = vec![serde_yaml::Value::String("existing".into())];
36089 m.insert_sequence(FLEET_PROGRAMS_KEY_PROGRAMS, prior_inner.clone());
36090 {
36091 let inner = m
36092 .entry_or_default_sequence(FLEET_PROGRAMS_KEY_PROGRAMS)
36093 .expect("present-Sequence-variant path returns Some(&mut prior)");
36094 assert_eq!(
36095 inner, &prior_inner,
36096 "entry_or_default_sequence returns &mut prior on the \
36097 present-key path — the default empty Vec must not \
36098 overwrite the emitter's prior write"
36099 );
36100 }
36101 let got = m
36102 .get(FLEET_PROGRAMS_KEY_PROGRAMS)
36103 .expect("key is still present after or_default on the present-key path");
36104 assert_eq!(
36105 got,
36106 &serde_yaml::Value::Sequence(prior_inner),
36107 "or_default on the present-key path preserves the prior \
36108 value verbatim — no clobber, no reshape"
36109 );
36110 }
36111
36112 #[test]
36113 fn mapping_ext_entry_or_default_sequence_returns_none_on_variant_mismatch() {
36114 // Present-key path with mismatched variant — the helper returns
36115 // `None`, letting the caller surface its domain-specific
36116 // "programs must be a sequence" diagnostic (rather than
36117 // silently clobbering the mismatched prior value). Pin the
36118 // structural-mismatch-is-None contract so a future refactor
36119 // that reaches for a fallback-to-empty-default flow doesn't
36120 // silently overwrite user-authored non-Sequence data at the
36121 // canonical caixa-flux `Error::MissingField("programs must be
36122 // a sequence")` site.
36123 let mut m = serde_yaml::Mapping::new();
36124 m.insert_string(FLEET_PROGRAMS_KEY_PROGRAMS, "not-a-sequence");
36125 let result = m.entry_or_default_sequence(FLEET_PROGRAMS_KEY_PROGRAMS);
36126 assert!(
36127 result.is_none(),
36128 "entry_or_default_sequence returns None on variant \
36129 mismatch — the caller's `.ok_or(Error::MissingField(_))?` \
36130 chain surfaces the structural type-mismatch diagnostic"
36131 );
36132 let got = m
36133 .get(FLEET_PROGRAMS_KEY_PROGRAMS)
36134 .expect("mismatched-variant prior value stays present after variant-check");
36135 assert_eq!(
36136 got,
36137 &serde_yaml::Value::String("not-a-sequence".into()),
36138 "None arm on variant mismatch leaves the prior value \
36139 untouched — the caller's domain-error path fires without \
36140 clobbering the user-authored data"
36141 );
36142 }
36143
36144 // ── insert_str_key_if_some — arity-0-or-1 twin of insert_str_key ─────
36145
36146 #[test]
36147 fn mapping_ext_insert_str_key_if_some_none_arm_leaves_mapping_untouched() {
36148 // The None arm skips the insert entirely — no clone, no
36149 // key-promotion, no bucket touch. Pin the no-op semantic so a
36150 // future refactor that reaches for an `Option::unwrap_or_default`
36151 // shape (which would emit `Value::Null` under the key on the
36152 // None arm) or an `.into_iter().for_each` scaffold (which would
36153 // still walk the bucket-lookup path) is a compile-visible break,
36154 // not a silent per-consumer regression at the 3 lifted
36155 // `caixa-mesh` overlay-insert sites (where the `None` arm is
36156 // the author's default when no `:politicas` slot is set — a
36157 // silent `Value::Null` emission would land a K8s CRD schema
36158 // rejection at every unset-slot Aplicacao).
36159 let mut m = serde_yaml::Mapping::new();
36160 let prior = m.insert_str_key_if_some(CILIUM_KEY_AUTHENTICATION, None);
36161 assert_eq!(
36162 prior, None,
36163 "insert_str_key_if_some(K, None) returns None — no insert \
36164 fires, so no prior value can be surfaced"
36165 );
36166 assert!(
36167 m.get(CILIUM_KEY_AUTHENTICATION).is_none(),
36168 "None arm must leave the key absent — a silent `Value::Null` \
36169 insertion would land a K8s CRD schema rejection at every \
36170 `:politicas`-unset Aplicacao"
36171 );
36172 assert_eq!(
36173 m.len(),
36174 0,
36175 "None arm must not touch any bucket — the Mapping stays \
36176 empty verbatim"
36177 );
36178 }
36179
36180 #[test]
36181 fn mapping_ext_insert_str_key_if_some_some_arm_promotes_key_to_yaml_string() {
36182 // The Some arm clones the borrowed inner value and delegates to
36183 // [`Self::insert_str_key`] — pin the promotion + the first-
36184 // insert-returns-None contract so a future refactor that reaches
36185 // for a different `Value` variant for the key (e.g.
36186 // `Value::Tagged`) or breaks the underlying
36187 // [`serde_yaml::Mapping::insert`] return contract is a compile-
36188 // visible break, not a silent per-consumer regression at the 3
36189 // lifted `caixa-mesh` overlay-insert sites. Peer with the sibling
36190 // [`mapping_ext_insert_str_key_promotes_key_to_yaml_string`] on
36191 // the always-1 arity axis of the same key promotion.
36192 let mut m = serde_yaml::Mapping::new();
36193 let overlay = serde_yaml::Value::Mapping({
36194 let mut inner = serde_yaml::Mapping::new();
36195 inner.insert_str_key(
36196 CILIUM_KEY_MODE,
36197 serde_yaml::Value::String("required".into()),
36198 );
36199 inner
36200 });
36201 let prior = m.insert_str_key_if_some(CILIUM_KEY_AUTHENTICATION, Some(&overlay));
36202 assert_eq!(
36203 prior, None,
36204 "insert_str_key_if_some(K, Some(&V)) returns None on first \
36205 insertion, mirroring serde_yaml::Mapping::insert"
36206 );
36207 // Key is exactly the `Value::String` promotion of the input.
36208 let got = m
36209 .get(CILIUM_KEY_AUTHENTICATION)
36210 .expect("Some arm inserts under the Value::String-promoted key");
36211 assert_eq!(
36212 got, &overlay,
36213 "insert_str_key_if_some routes the borrowed inner value \
36214 through a `.clone()` verbatim to the underlying \
36215 `insert_str_key` path — no reshape, no wrap, no unwrap"
36216 );
36217 // The borrowed input is untouched — the caller can reuse the
36218 // outer overlay binding across the next iteration of a per-
36219 // `(:de, :para)` loop (the exact reuse the three lifted
36220 // caixa-mesh sites depend on).
36221 assert!(
36222 overlay.get(CILIUM_KEY_MODE).is_some(),
36223 "insert_str_key_if_some must not move out of the borrowed \
36224 overlay — the caller-side outer binding stays available \
36225 for the next iteration of the enclosing per-`(:de, :para)` \
36226 or per-rule loop"
36227 );
36228 }
36229
36230 #[test]
36231 fn mapping_ext_insert_str_key_if_some_some_arm_returns_prior_value_on_replace() {
36232 // The Some arm mirrors [`serde_yaml::Mapping::insert`]'s return
36233 // contract on the replace-existing path: the prior value at that
36234 // key, surfaced verbatim. Pin the replace-returns-prior semantic
36235 // so a future refactor that reaches for an `entry.or_insert`-
36236 // style preserve-prior flow doesn't silently swap the axis's
36237 // semantic under the three routed caixa-mesh overlay sites (the
36238 // `:politicas` overlay is meant to override an author-provided
36239 // sub-block if one was present, not preserve it — the
36240 // replace-and-return-prior semantic is load-bearing).
36241 let mut m = serde_yaml::Mapping::new();
36242 let existing = serde_yaml::Value::String("cluster-default".into());
36243 let overlay = serde_yaml::Value::Mapping({
36244 let mut inner = serde_yaml::Mapping::new();
36245 inner.insert_str_key(
36246 GATEWAY_API_KEY_REQUEST,
36247 serde_yaml::Value::String("30s".into()),
36248 );
36249 inner
36250 });
36251 m.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36252 let prior = m.insert_str_key_if_some(GATEWAY_API_KEY_TIMEOUTS, Some(&overlay));
36253 assert_eq!(
36254 prior,
36255 Some(existing),
36256 "insert_str_key_if_some(K, Some(&V)) returns the prior value \
36257 when replacing an existing key — the overlay overrides the \
36258 author-provided sub-block; the prior value surfaces so the \
36259 caller can log/compare/roll back if needed"
36260 );
36261 // Value at the key is now the overlay, verbatim.
36262 let got = m
36263 .get(GATEWAY_API_KEY_TIMEOUTS)
36264 .expect("key is still present after replace");
36265 assert_eq!(
36266 got, &overlay,
36267 "replaced value is now the most-recently-inserted overlay — \
36268 the Some arm carries through to the underlying \
36269 `insert_str_key` replace path"
36270 );
36271 }
36272
36273 #[test]
36274 fn mapping_ext_insert_str_key_if_some_matches_hand_written_composition() {
36275 // Cross-check the trait method against the hand-written
36276 // `if let Some(x) = &overlay { m.insert_str_key(K, x.clone()); }`
36277 // three-line block the 3 lifted `caixa-mesh` overlay call sites
36278 // previously carried. A drift between the trait method's
36279 // conditional-insert routing and the inline `if let Some`
36280 // composition would silently emit a different Mapping (a
36281 // present-key `Value::Null` on the None arm, a different clone-
36282 // vs-move policy on the Some arm) at every routed consumer —
36283 // pin the equivalence so the trait remains a drop-in replacement.
36284 // Four cases pin the shape end-to-end: None arm (skip), Some
36285 // arm on absent key (fresh insert), Some arm on present key
36286 // (replace-and-return-prior), None arm on present key (no
36287 // touch — the axis's load-bearing "author's value wins when
36288 // overlay is unset" contract).
36289 let overlay = serde_yaml::Value::Mapping({
36290 let mut inner = serde_yaml::Mapping::new();
36291 inner.insert_str_key(
36292 CILIUM_KEY_MODE,
36293 serde_yaml::Value::String("required".into()),
36294 );
36295 inner
36296 });
36297
36298 // Case 1: None arm on empty mapping — both routes no-op.
36299 let mut via_trait_none = serde_yaml::Mapping::new();
36300 via_trait_none.insert_str_key_if_some(CILIUM_KEY_AUTHENTICATION, None);
36301 let via_inline_none = serde_yaml::Mapping::new();
36302 let overlay_slot_none: Option<serde_yaml::Value> = None;
36303 let mut via_inline_none_mut = via_inline_none.clone();
36304 if let Some(a) = &overlay_slot_none {
36305 via_inline_none_mut.insert_str_key(CILIUM_KEY_AUTHENTICATION, a.clone());
36306 }
36307 assert_eq!(
36308 via_trait_none, via_inline_none_mut,
36309 "insert_str_key_if_some(K, None) must byte-equal \
36310 `if let Some(_) = None {{ … }}` — the no-op arm must not \
36311 emit a stray `Value::Null` under the key"
36312 );
36313
36314 // Case 2: Some arm on empty mapping — both routes fresh-insert.
36315 let mut via_trait_some = serde_yaml::Mapping::new();
36316 via_trait_some.insert_str_key_if_some(CILIUM_KEY_AUTHENTICATION, Some(&overlay));
36317 let mut via_inline_some = serde_yaml::Mapping::new();
36318 let overlay_slot_some = Some(overlay.clone());
36319 if let Some(a) = &overlay_slot_some {
36320 via_inline_some.insert_str_key(CILIUM_KEY_AUTHENTICATION, a.clone());
36321 }
36322 assert_eq!(
36323 via_trait_some, via_inline_some,
36324 "insert_str_key_if_some(K, Some(&V)) must byte-equal \
36325 `if let Some(x) = &Some(V.clone()) {{ m.insert_str_key(K, \
36326 x.clone()); }}` on the fresh-insert path — same clone-and-\
36327 insert semantics under the same Value::String-promoted \
36328 bucket"
36329 );
36330
36331 // Case 3: Some arm on present key — both routes replace-and-
36332 // return-prior.
36333 let existing = serde_yaml::Value::String("cluster-default".into());
36334 let mut via_trait_replace = serde_yaml::Mapping::new();
36335 via_trait_replace.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36336 let trait_prior =
36337 via_trait_replace.insert_str_key_if_some(GATEWAY_API_KEY_TIMEOUTS, Some(&overlay));
36338 let mut via_inline_replace = serde_yaml::Mapping::new();
36339 via_inline_replace.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36340 let overlay_slot_replace = Some(overlay.clone());
36341 let inline_prior = if let Some(a) = &overlay_slot_replace {
36342 via_inline_replace.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, a.clone())
36343 } else {
36344 None
36345 };
36346 assert_eq!(
36347 trait_prior, inline_prior,
36348 "insert_str_key_if_some replace-and-return-prior must byte-\
36349 equal the hand-written `if let Some {{ insert_str_key }}` \
36350 composition's return"
36351 );
36352 assert_eq!(
36353 via_trait_replace, via_inline_replace,
36354 "insert_str_key_if_some replace-post-state must byte-equal \
36355 the hand-written composition's post-state — the overlay \
36356 overrode the author's value in both routes"
36357 );
36358
36359 // Case 4: None arm on present key — both routes preserve the
36360 // author's value verbatim. The load-bearing "author's value
36361 // wins when overlay is unset" contract the three lifted sites
36362 // depend on.
36363 let mut via_trait_preserve = serde_yaml::Mapping::new();
36364 via_trait_preserve.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36365 via_trait_preserve.insert_str_key_if_some(GATEWAY_API_KEY_TIMEOUTS, None);
36366 let mut via_inline_preserve = serde_yaml::Mapping::new();
36367 via_inline_preserve.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36368 let overlay_slot_preserve: Option<serde_yaml::Value> = None;
36369 if let Some(a) = &overlay_slot_preserve {
36370 via_inline_preserve.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, a.clone());
36371 }
36372 assert_eq!(
36373 via_trait_preserve, via_inline_preserve,
36374 "insert_str_key_if_some(K, None) on a present key must byte-\
36375 equal the hand-written `if let Some(_) = None {{ … }}` — \
36376 the None arm must preserve the author's value verbatim, \
36377 not clobber it with `Value::Null` or drop the key"
36378 );
36379 assert_eq!(
36380 via_trait_preserve
36381 .get(GATEWAY_API_KEY_TIMEOUTS)
36382 .expect("None arm preserves the pre-existing key"),
36383 &existing,
36384 "None arm on a present key surfaces the author's prior \
36385 value verbatim — the load-bearing contract the three \
36386 lifted `:politicas` overlay sites rest on"
36387 );
36388 }
36389
36390 // ── SequenceExt::push_mapping — Vec<Value>-side sibling ──────────────
36391
36392 #[test]
36393 fn sequence_ext_push_mapping_appends_promoted_mapping_value() {
36394 // The method appends the caller's `Mapping` as a fresh
36395 // `Value::Mapping(_)` element on the tail of `self`. Pin the
36396 // per-append routing (`.push(Value::Mapping(_))`) so a future
36397 // refactor that reaches for a different outer variant (a
36398 // Server-Side-Apply-typed `Value::Tagged`, a fresh singleton-list
36399 // wrap via `singleton_mapping_sequence`) or a different
36400 // Vec-mutation shape (e.g. `.insert(0, _)` shifting the axis
36401 // from append to prepend) is a compile-visible break, not a
36402 // silent per-consumer regression at the 4 lifted `caixa-mesh`
36403 // append sites — where the emission order is load-bearing (the
36404 // Cilium `spec.ingress[].toPorts[]` per-edge order, the
36405 // Gateway API `spec.rules[]` per-path order, the top-level CNP
36406 // and programs.yaml document order all depend on the append
36407 // semantics).
36408 let mut seq: Vec<serde_yaml::Value> = Vec::new();
36409 let mut m = serde_yaml::Mapping::new();
36410 m.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("first".into()));
36411 seq.push_mapping(m.clone());
36412 assert_eq!(
36413 seq.len(),
36414 1,
36415 "push_mapping must append exactly one element — the axis's \
36416 fresh-element semantic"
36417 );
36418 assert_eq!(
36419 seq[0],
36420 serde_yaml::Value::Mapping(m),
36421 "the appended element must be the caller's Mapping wrapped \
36422 verbatim as Value::Mapping — no reshape, no clone-and-drop"
36423 );
36424 }
36425
36426 #[test]
36427 fn sequence_ext_push_mapping_preserves_prior_elements_in_insertion_order() {
36428 // Successive push_mapping calls preserve the caller's per-
36429 // iteration order — the Vec grows at the tail, prior elements
36430 // stay at their prior indices. Pin the insertion-order semantic
36431 // so a future refactor that reaches for a per-append sort /
36432 // dedup / hoist-to-front reordering is a test-visible break,
36433 // not a silent behavior shift at the 4 lifted `caixa-mesh`
36434 // append sites (where THEORY.md §V.2.7 render determinism
36435 // pins the per-iteration emission order to the source
36436 // `:contratos` / `:paths` / `:membros` declaration order).
36437 let mut seq: Vec<serde_yaml::Value> = Vec::new();
36438 let mut first = serde_yaml::Mapping::new();
36439 first.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("a".into()));
36440 let mut second = serde_yaml::Mapping::new();
36441 second.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("b".into()));
36442 let mut third = serde_yaml::Mapping::new();
36443 third.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("c".into()));
36444 seq.push_mapping(first.clone());
36445 seq.push_mapping(second.clone());
36446 seq.push_mapping(third.clone());
36447 assert_eq!(
36448 seq.len(),
36449 3,
36450 "three push_mapping calls append three elements"
36451 );
36452 assert_eq!(
36453 seq,
36454 vec![
36455 serde_yaml::Value::Mapping(first),
36456 serde_yaml::Value::Mapping(second),
36457 serde_yaml::Value::Mapping(third),
36458 ],
36459 "push_mapping preserves per-iteration insertion order — the \
36460 axis's render-determinism contract at the 4 lifted \
36461 `caixa-mesh` append sites"
36462 );
36463 }
36464
36465 #[test]
36466 fn sequence_ext_push_mapping_matches_hand_written_composition() {
36467 // Cross-check the trait method against the hand-written
36468 // `<vec>.push(serde_yaml::Value::Mapping(<M>))` three-token
36469 // block the 4 lifted `caixa-mesh` append call sites previously
36470 // carried. A drift between the trait method's routing and the
36471 // inline `Value::Mapping(_)` promotion would silently emit a
36472 // different `Vec<Value>` (a different outer variant on the
36473 // appended element, a different length, a different order) at
36474 // every routed consumer — pin the equivalence so the trait
36475 // remains a drop-in replacement across the fresh-empty, prior-
36476 // populated, and empty-payload cases.
36477
36478 // Case 1: fresh-empty Vec + non-empty Mapping payload.
36479 let mut inner = serde_yaml::Mapping::new();
36480 inner.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("policy-a".into()));
36481 let mut via_trait: Vec<serde_yaml::Value> = Vec::new();
36482 via_trait.push_mapping(inner.clone());
36483 let mut via_inline: Vec<serde_yaml::Value> = Vec::new();
36484 via_inline.push(serde_yaml::Value::Mapping(inner.clone()));
36485 assert_eq!(
36486 via_trait, via_inline,
36487 "push_mapping(M) on empty Vec must byte-equal \
36488 `.push(Value::Mapping(M))` — same variant-promotion, same \
36489 append semantics"
36490 );
36491
36492 // Case 2: prior-populated Vec + non-empty Mapping payload — pin
36493 // that the append fires at the tail, not at the head or the
36494 // middle.
36495 let seed = serde_yaml::Value::String("seed".into());
36496 let mut via_trait_populated: Vec<serde_yaml::Value> = vec![seed.clone()];
36497 via_trait_populated.push_mapping(inner.clone());
36498 let mut via_inline_populated: Vec<serde_yaml::Value> = vec![seed];
36499 via_inline_populated.push(serde_yaml::Value::Mapping(inner.clone()));
36500 assert_eq!(
36501 via_trait_populated, via_inline_populated,
36502 "push_mapping(M) on populated Vec must byte-equal \
36503 `.push(Value::Mapping(M))` — the append fires at the tail, \
36504 prior elements stay at their prior indices"
36505 );
36506
36507 // Case 3: empty Mapping payload — the axis's "empty-vs-absent"
36508 // distinction the 4 lifted sites rest on. An empty inner
36509 // `Mapping` still round-trips as a `Value::Mapping(<empty>)`
36510 // element, not as a skipped no-op, because some K8s CRD schemas
36511 // (Cilium CNP `spec.ingress[].toPorts[].rules.http[]` with an
36512 // empty match set) require an empty inner object to distinguish
36513 // "explicitly-empty" from "absent".
36514 let mut via_trait_empty: Vec<serde_yaml::Value> = Vec::new();
36515 via_trait_empty.push_mapping(serde_yaml::Mapping::new());
36516 let mut via_inline_empty: Vec<serde_yaml::Value> = Vec::new();
36517 via_inline_empty.push(serde_yaml::Value::Mapping(serde_yaml::Mapping::new()));
36518 assert_eq!(
36519 via_trait_empty, via_inline_empty,
36520 "push_mapping(empty Mapping) must byte-equal \
36521 `.push(Value::Mapping(empty))` — no is_empty()-guarded \
36522 short-circuit, no skip"
36523 );
36524 assert_eq!(
36525 via_trait_empty.len(),
36526 1,
36527 "push_mapping on an empty Mapping still appends one element \
36528 — the axis carries no is_empty() short-circuit"
36529 );
36530 }
36531
36532 #[test]
36533 fn singleton_mapping_sequence_wraps_input_as_sole_element() {
36534 // The helper wraps its input `Mapping` as the single element of
36535 // a `Value::Sequence`. Pin the outer variant shape and the
36536 // exactly-one-element length so a future refactor that reaches
36537 // for a different container (e.g. `Value::Tagged`, a
36538 // 0-or-1-element `Option`-shaped emission axis) is a
36539 // compile-visible break, not a silent per-caller regression at
36540 // every K8s-CRD-list-shape-required emit site.
36541 let mut inner = serde_yaml::Mapping::new();
36542 inner.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("hello".into()));
36543 let out = singleton_mapping_sequence(inner.clone());
36544 match out {
36545 serde_yaml::Value::Sequence(seq) => {
36546 assert_eq!(
36547 seq.len(),
36548 1,
36549 "singleton_mapping_sequence emits exactly one element — \
36550 the K8s-CRD-list-shape-required singleton axis"
36551 );
36552 assert_eq!(
36553 seq[0],
36554 serde_yaml::Value::Mapping(inner),
36555 "the sole element must be the caller's Mapping wrapped \
36556 verbatim as Value::Mapping — no reshape, no clone-and-drop"
36557 );
36558 }
36559 other => panic!(
36560 "singleton_mapping_sequence must return Value::Sequence, got {other:?} — \
36561 an outer-variant drift breaks every K8s-CRD-list-shape consumer"
36562 ),
36563 }
36564 }
36565
36566 #[test]
36567 fn singleton_mapping_sequence_preserves_empty_inner_mapping() {
36568 // An empty inner `Mapping` still round-trips through the helper
36569 // as a `Value::Sequence(vec![Value::Mapping(<empty>)])` — the
36570 // helper carries no "skip-empty" short-circuit (empty-vs-absent
36571 // is the caller's decision; some K8s CRD schemas require an
36572 // empty inner object to distinguish "explicitly-empty" from
36573 // "absent"). Pin the shape so a future refactor that reaches
36574 // for an is_empty()-guarded short-circuit is a test-visible
36575 // break, not a silent behavior shift.
36576 let out = singleton_mapping_sequence(serde_yaml::Mapping::new());
36577 let seq = match out {
36578 serde_yaml::Value::Sequence(s) => s,
36579 other => panic!("expected Value::Sequence, got {other:?}"),
36580 };
36581 assert_eq!(seq.len(), 1, "empty inner still wraps as a 1-element seq");
36582 assert_eq!(
36583 seq[0],
36584 serde_yaml::Value::Mapping(serde_yaml::Mapping::new()),
36585 "the sole element is an empty Value::Mapping, verbatim"
36586 );
36587 }
36588
36589 #[test]
36590 fn singleton_mapping_sequence_byte_equals_hand_written_inline_shape() {
36591 // Cross-check the helper against the hand-written
36592 // `Value::Sequence(vec![Value::Mapping(m)])` three-token shape
36593 // the seven lifted call sites previously carried. A drift
36594 // between the helper's wrapping and the inline shape would
36595 // silently emit a different YAML sequence (a differently-shaped
36596 // outer variant, a differently-wrapped inner Mapping) at every
36597 // routed consumer — pin the byte-equivalence so the helper
36598 // remains a drop-in replacement.
36599 let mut inner = serde_yaml::Mapping::new();
36600 inner.insert_str_key(
36601 GATEWAY_API_KEY_NAME,
36602 serde_yaml::Value::String("gw-listener".into()),
36603 );
36604 inner.insert_str_key(
36605 KUBE_KEY_PORT,
36606 serde_yaml::Value::Number(GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT.into()),
36607 );
36608
36609 let via_helper = singleton_mapping_sequence(inner.clone());
36610 let via_inline = serde_yaml::Value::Sequence(vec![serde_yaml::Value::Mapping(inner)]);
36611
36612 assert_eq!(
36613 via_helper, via_inline,
36614 "singleton_mapping_sequence(m) must byte-equal \
36615 Value::Sequence(vec![Value::Mapping(m)]) — otherwise the \
36616 seven routed caixa-mesh call sites drift silently at emit time"
36617 );
36618 }
36619
36620 #[test]
36621 fn string_keyed_entries_yields_each_string_key_and_value_ref() {
36622 // The lift's load-bearing contract: given a Value::Mapping with
36623 // string keys, yield each `(&str, &Value)` pair in insertion
36624 // order. Both routed renderers (caixa-flux::programs_yaml_entry
36625 // and caixa-helm::build_values_yaml) depend on the yielded pair
36626 // shape to drive their per-destination insert — a drift in
36627 // yielded item type is a compile-visible break, not a silent
36628 // shape shift.
36629 let mut spec = serde_yaml::Mapping::new();
36630 spec.insert_str_key(
36631 COMPUTEUNIT_SPEC_KEY_MODULE,
36632 serde_yaml::Value::String("oci://…".into()),
36633 );
36634 spec.insert_str_key(
36635 COMPUTEUNIT_SPEC_KEY_TRIGGER,
36636 serde_yaml::Value::String("http".into()),
36637 );
36638 spec.insert_str_key(
36639 COMPUTEUNIT_SPEC_KEY_CAPABILITIES,
36640 serde_yaml::Value::Sequence(vec![]),
36641 );
36642 let v = serde_yaml::Value::Mapping(spec);
36643 let keys: Vec<&str> = string_keyed_entries(&v).map(|(k, _)| k).collect();
36644 assert_eq!(
36645 keys,
36646 vec![
36647 COMPUTEUNIT_SPEC_KEY_MODULE,
36648 COMPUTEUNIT_SPEC_KEY_TRIGGER,
36649 COMPUTEUNIT_SPEC_KEY_CAPABILITIES,
36650 ],
36651 "string_keyed_entries must yield every string-keyed entry in \
36652 the underlying Mapping's insertion order — both routed \
36653 renderers depend on `spec.module` reaching the destination \
36654 ahead of `spec.trigger` ahead of `spec.capabilities` so the \
36655 emitted values.yaml / programs.yaml entry's key order tracks \
36656 the upstream ComputeUnit YAML author's order"
36657 );
36658 // The paired &Value ref also reaches through — sanity-check on
36659 // the second axis of the yielded tuple.
36660 let module = string_keyed_entries(&v)
36661 .find(|(k, _)| *k == COMPUTEUNIT_SPEC_KEY_MODULE)
36662 .map(|(_, v)| v.clone())
36663 .expect("module entry present");
36664 assert_eq!(module, serde_yaml::Value::String("oci://…".into()));
36665 }
36666
36667 #[test]
36668 fn string_keyed_entries_short_circuits_on_non_mapping_shapes() {
36669 // The prior inline `if let Value::Mapping(_) = spec { … }` arm
36670 // silently no-oped on every non-Mapping shape (Null / String /
36671 // Sequence / Number / Bool). The lift's iterator surface pins
36672 // the same contract: a non-Mapping Value contributes zero
36673 // yielded entries. Pinned because both routed renderers'
36674 // "always splice `spec.*` if it's a Mapping, otherwise skip"
36675 // contract is upstream-schema-validated at the ComputeUnit CRD
36676 // parser but not at the renderer entry point — so a legally-
36677 // authored `spec: null` short-circuits without raising.
36678 for shape in [
36679 serde_yaml::Value::Null,
36680 serde_yaml::Value::String("scalar".into()),
36681 serde_yaml::Value::Sequence(vec![]),
36682 serde_yaml::Value::Number(0.into()),
36683 serde_yaml::Value::Bool(false),
36684 ] {
36685 let count = string_keyed_entries(&shape).count();
36686 assert_eq!(
36687 count, 0,
36688 "string_keyed_entries({shape:?}) must yield zero entries — \
36689 the prior `if let Value::Mapping(_)` arm silently \
36690 short-circuited on this shape, so the lift must preserve \
36691 that no-op contract or every routed renderer regresses on \
36692 the legally-authored non-Mapping `spec:` axis"
36693 );
36694 }
36695 }
36696
36697 #[test]
36698 fn string_keyed_entries_drops_non_string_keys() {
36699 // serde_yaml permits arbitrary `Value` keys — numeric, boolean,
36700 // sub-mapping — that don't round-trip through the downstream
36701 // K8s YAML-key surface (which requires string keys). Both
36702 // routed renderers previously carried an inline `if let Some(s)
36703 // = k.as_str()` filter to silently drop these; pin the lift's
36704 // filter contract so a future refactor that reaches for
36705 // `.as_str().unwrap()` (which would panic on a numeric key) is
36706 // a test-visible break, not a runtime regression at the first
36707 // ComputeUnit YAML that carries one.
36708 let mut spec = serde_yaml::Mapping::new();
36709 spec.insert(
36710 serde_yaml::Value::String(COMPUTEUNIT_SPEC_KEY_MODULE.into()),
36711 serde_yaml::Value::String("oci://…".into()),
36712 );
36713 spec.insert(
36714 serde_yaml::Value::Number(42.into()),
36715 serde_yaml::Value::String("dropped".into()),
36716 );
36717 spec.insert(
36718 serde_yaml::Value::Bool(true),
36719 serde_yaml::Value::String("also-dropped".into()),
36720 );
36721 spec.insert(
36722 serde_yaml::Value::String(COMPUTEUNIT_SPEC_KEY_TRIGGER.into()),
36723 serde_yaml::Value::String("http".into()),
36724 );
36725 let v = serde_yaml::Value::Mapping(spec);
36726 let keys: Vec<&str> = string_keyed_entries(&v).map(|(k, _)| k).collect();
36727 assert_eq!(
36728 keys,
36729 vec![COMPUTEUNIT_SPEC_KEY_MODULE, COMPUTEUNIT_SPEC_KEY_TRIGGER],
36730 "string_keyed_entries must silently drop non-string-keyed \
36731 entries (Value::Number, Value::Bool, Value::Mapping keys) \
36732 — the K8s YAML-key surface downstream requires string keys, \
36733 and every routed renderer's inline `k.as_str()` filter \
36734 expected exactly this drop-not-panic contract"
36735 );
36736 }
36737
36738 #[test]
36739 fn string_keyed_entries_matches_prior_inline_walk() {
36740 // Cross-check the helper's yielded sequence against the prior
36741 // inline `if let Value::Mapping(_) = spec { for (k, v) in _ {
36742 // if let Some(s) = k.as_str() { <collect (s, v.clone())> } } }`
36743 // walk both renderers previously carried. A drift between the
36744 // helper's yielded sequence and the inline walk would silently
36745 // emit a different destination map at every routed consumer —
36746 // pin the byte-equivalence so the helper remains a drop-in
36747 // replacement for both renderers' prior five-line block.
36748 let mut spec = serde_yaml::Mapping::new();
36749 spec.insert_str_key(
36750 COMPUTEUNIT_SPEC_KEY_MODULE,
36751 serde_yaml::Value::String("oci://ghcr.io/pleme-io/hello-rio:0.1.0".into()),
36752 );
36753 spec.insert(
36754 serde_yaml::Value::Number(1.into()),
36755 serde_yaml::Value::String("silently-dropped".into()),
36756 );
36757 spec.insert_str_key(
36758 COMPUTEUNIT_SPEC_KEY_TRIGGER,
36759 serde_yaml::Value::String("http".into()),
36760 );
36761 let v = serde_yaml::Value::Mapping(spec);
36762
36763 let via_helper: Vec<(String, serde_yaml::Value)> = string_keyed_entries(&v)
36764 .map(|(k, v)| (k.to_string(), v.clone()))
36765 .collect();
36766
36767 let mut via_inline: Vec<(String, serde_yaml::Value)> = Vec::new();
36768 if let serde_yaml::Value::Mapping(map) = &v {
36769 for (k, v) in map {
36770 if let Some(s) = k.as_str() {
36771 via_inline.push((s.to_string(), v.clone()));
36772 }
36773 }
36774 }
36775
36776 assert_eq!(
36777 via_helper, via_inline,
36778 "string_keyed_entries must yield the same (String, Value) \
36779 sequence as the prior inline `if let Value::Mapping + for + \
36780 if let Some(k.as_str())` walk — otherwise the two routed \
36781 renderers drift silently at ComputeUnit-YAML-`spec.*`-splice \
36782 time"
36783 );
36784 }
36785
36786 #[test]
36787 fn kube_metadata_str_field_reads_metadata_name_and_namespace_string_scalars() {
36788 // The lift's load-bearing contract: given a Value carrying a
36789 // top-level `metadata: { name: <str>, namespace: <str> }` block
36790 // (every K8s CR document the emit-side `kube_resource_skeleton`
36791 // renders), the helper returns Some(<str>) borrowing into the
36792 // input Value. Pinned because every routed test-side site (the
36793 // six caixa-mesh CNP filters + the caixa-flux kustomization.yaml
36794 // pin) reaches through this exact string-scalar readback, and a
36795 // drift in the borrowed-string contract would silently regress
36796 // every routed site's per-CR filter equality.
36797 let mut metadata = serde_yaml::Mapping::new();
36798 metadata.insert_str_key(
36799 KUBE_KEY_NAME,
36800 serde_yaml::Value::String("checkout-cart-to-catalog".into()),
36801 );
36802 metadata.insert_str_key(
36803 KUBE_KEY_NAMESPACE,
36804 serde_yaml::Value::String(DEFAULT_NAMESPACE.into()),
36805 );
36806 let mut cr = serde_yaml::Mapping::new();
36807 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
36808 let value = serde_yaml::Value::Mapping(cr);
36809
36810 assert_eq!(
36811 kube_metadata_str_field(&value, KUBE_KEY_NAME),
36812 Some("checkout-cart-to-catalog"),
36813 "kube_metadata_str_field must read metadata.name as a string \
36814 scalar — the six caixa-mesh CNP per-`(:de, :para)` filter \
36815 sites reach through this axis for policy-identity equality"
36816 );
36817 assert_eq!(
36818 kube_metadata_str_field(&value, KUBE_KEY_NAMESPACE),
36819 Some(DEFAULT_NAMESPACE),
36820 "kube_metadata_str_field must read metadata.namespace as a \
36821 string scalar — the caixa-flux programs_yaml_entry \
36822 production readback + the cluster_bundle kustomization.yaml \
36823 test pin both reach through this axis"
36824 );
36825 }
36826
36827 #[test]
36828 fn kube_metadata_str_field_returns_none_when_metadata_block_absent() {
36829 // Every K8s CR document the emit-side `kube_resource_skeleton`
36830 // renders carries a `metadata:` block, but the readback surface
36831 // is called on arbitrary Value inputs (upstream ComputeUnit
36832 // YAML documents, external YAML documents parsed by tests) that
36833 // may legally omit the block. The prior inline three-hop chain
36834 // silently short-circuits on the first `.get(KUBE_KEY_METADATA)`
36835 // hop when the block is absent; pin the helper's None return so
36836 // the prior no-panic contract holds. The two production-shape
36837 // paths — caixa-flux's `programs_yaml_entry` production
36838 // readback with `.unwrap_or(DEFAULT_NAMESPACE)` fallback, the
36839 // caixa-mesh test-side `.unwrap()` after equality-filter —
36840 // both depend on this None-arm for their fallback / test-harness
36841 // semantics.
36842 let value = serde_yaml::Value::Mapping(serde_yaml::Mapping::new());
36843 assert_eq!(
36844 kube_metadata_str_field(&value, KUBE_KEY_NAME),
36845 None,
36846 "kube_metadata_str_field must short-circuit to None when the \
36847 top-level `metadata:` block is absent — the prior inline \
36848 chain's `.get(KUBE_KEY_METADATA)` outer hop returned None \
36849 here, and every routed caller (production fallback + test \
36850 expect) depends on the None-arm reaching through"
36851 );
36852
36853 // Also verify the shape on a non-Mapping outer Value — the K8s
36854 // CR readback surface accepts arbitrary Value inputs, including
36855 // the Value::Null / Value::Sequence / Value::String shapes an
36856 // external YAML document may parse into.
36857 for shape in [
36858 serde_yaml::Value::Null,
36859 serde_yaml::Value::String("scalar".into()),
36860 serde_yaml::Value::Sequence(vec![]),
36861 serde_yaml::Value::Number(0.into()),
36862 serde_yaml::Value::Bool(false),
36863 ] {
36864 assert_eq!(
36865 kube_metadata_str_field(&shape, KUBE_KEY_NAME),
36866 None,
36867 "kube_metadata_str_field({shape:?}, KUBE_KEY_NAME) must \
36868 return None on non-Mapping shapes — the prior inline \
36869 `.get(KUBE_KEY_METADATA)` hop yields None on every \
36870 non-Mapping Value, and the lift must preserve that \
36871 contract"
36872 );
36873 }
36874 }
36875
36876 #[test]
36877 fn kube_metadata_str_field_returns_none_when_requested_field_absent() {
36878 // A `metadata:` block present but missing the requested axis-key
36879 // — a well-formed K8s CR that legally omits the requested field
36880 // (a Cluster-scoped CR omits `metadata.namespace`, a
36881 // Server-Side-Apply-authored CR omits `metadata.name` in favor
36882 // of `metadata.generateName`). Every routed caller expects the
36883 // three-hop chain to short-circuit through here to None; pin
36884 // the middle-hop None-arm so a future refactor that reaches for
36885 // `.get(field).unwrap()` (which would panic on a legally-omitted
36886 // axis-key) is a test-visible break.
36887 let mut metadata = serde_yaml::Mapping::new();
36888 metadata.insert_str_key(
36889 KUBE_KEY_NAME,
36890 serde_yaml::Value::String("cluster-scoped-cr".into()),
36891 );
36892 let mut cr = serde_yaml::Mapping::new();
36893 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
36894 let value = serde_yaml::Value::Mapping(cr);
36895 assert_eq!(
36896 kube_metadata_str_field(&value, KUBE_KEY_NAMESPACE),
36897 None,
36898 "kube_metadata_str_field must return None when the requested \
36899 `metadata.<field>` axis-key is absent — the prior inline \
36900 chain's middle `.and_then(|m| m.get(<FIELD>))` hop short- \
36901 circuited here, and the lift must preserve that None-arm \
36902 for every legally-omitted axis-key"
36903 );
36904 }
36905
36906 #[test]
36907 fn kube_metadata_str_field_returns_none_when_field_carries_non_string_type() {
36908 // A `metadata.<field>` axis-key present but carrying a non-
36909 // string YAML type — schema-invalid per the K8s apiserver's
36910 // OpenAPI schema but tolerated here as None so the readback
36911 // stays a total function. The prior inline chain's trailing
36912 // `.and_then(|n| n.as_str())` shape gate silently short-
36913 // circuits here; pin the helper's None-arm so a future refactor
36914 // that reaches for `.as_str().unwrap()` (which would panic on
36915 // a numeric axis-value) is a test-visible break, not a runtime
36916 // regression at the first schema-invalid CR the reader sees.
36917 for non_string in [
36918 serde_yaml::Value::Null,
36919 serde_yaml::Value::Number(42.into()),
36920 serde_yaml::Value::Bool(true),
36921 serde_yaml::Value::Sequence(vec![]),
36922 serde_yaml::Value::Mapping(serde_yaml::Mapping::new()),
36923 ] {
36924 let mut metadata = serde_yaml::Mapping::new();
36925 metadata.insert_str_key(KUBE_KEY_NAME, non_string.clone());
36926 let mut cr = serde_yaml::Mapping::new();
36927 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
36928 let value = serde_yaml::Value::Mapping(cr);
36929 assert_eq!(
36930 kube_metadata_str_field(&value, KUBE_KEY_NAME),
36931 None,
36932 "kube_metadata_str_field must return None when \
36933 metadata.name carries a non-string YAML type ({non_string:?}) \
36934 — the prior inline chain's `.and_then(|n| n.as_str())` \
36935 shape gate short-circuited here, and every routed caller \
36936 depends on that None-arm to keep the readback total"
36937 );
36938 }
36939 }
36940
36941 #[test]
36942 fn kube_metadata_str_field_matches_prior_inline_chain() {
36943 // Cross-check the helper's output byte-for-byte against the
36944 // prior inline three-hop chain both routed callers previously
36945 // carried. A drift between the helper's return and the inline
36946 // chain would silently regress every routed test-side filter's
36947 // equality comparison + the caixa-flux production readback's
36948 // fallback semantics — pin the byte-equivalence so the helper
36949 // remains a drop-in replacement for every routed site's prior
36950 // three-line block.
36951 let mut metadata = serde_yaml::Mapping::new();
36952 metadata.insert_str_key(
36953 KUBE_KEY_NAME,
36954 serde_yaml::Value::String("checkout-payment-to-cart".into()),
36955 );
36956 metadata.insert_str_key(
36957 KUBE_KEY_NAMESPACE,
36958 serde_yaml::Value::String(DEFAULT_NAMESPACE.into()),
36959 );
36960 let mut cr = serde_yaml::Mapping::new();
36961 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
36962 let value = serde_yaml::Value::Mapping(cr);
36963
36964 for field in [KUBE_KEY_NAME, KUBE_KEY_NAMESPACE] {
36965 let via_helper = kube_metadata_str_field(&value, field);
36966 let via_inline = value
36967 .get(KUBE_KEY_METADATA)
36968 .and_then(|m| m.get(field))
36969 .and_then(|n| n.as_str());
36970 assert_eq!(
36971 via_helper, via_inline,
36972 "kube_metadata_str_field(_, {field:?}) must yield the same \
36973 Option<&str> as the prior inline three-hop chain — \
36974 otherwise every routed caller's equality-filter / \
36975 production-fallback drifts silently at readback time"
36976 );
36977 }
36978 }
36979
36980 #[test]
36981 fn kube_root_str_field_reads_api_version_and_kind_string_scalars() {
36982 // The lift's load-bearing contract: given a Value carrying
36983 // top-level `apiVersion:` + `kind:` string scalars (every K8s
36984 // CR document the emit-side `kube_resource_skeleton` renders
36985 // spells the pair by construction), the helper returns
36986 // Some(<str>) borrowing into the input Value on both axes.
36987 // Pinned because every routed test-side site — the
36988 // caixa-flux `cluster_bundle_*_uses_lifted_flux_api_version`
36989 // per-document apiVersion pins + the caixa-mesh
36990 // `gateway_routes` per-`(Gateway, HTTPRoute)` kind-filter
36991 // + the sibling caixa-mesh
36992 // `cilium_authentication_mode_serialized_as_yaml_string`
36993 // CNP-kind filter — reaches through this exact top-level
36994 // string-scalar readback, and a drift in the borrowed-string
36995 // contract would silently regress every routed site's
36996 // per-CR filter / discriminator-pin equality.
36997 let mut cr = serde_yaml::Mapping::new();
36998 cr.insert_str_key(
36999 KUBE_KEY_API_VERSION,
37000 serde_yaml::Value::String(GATEWAY_API_API_VERSION.into()),
37001 );
37002 cr.insert_str_key(
37003 KUBE_KEY_KIND,
37004 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37005 );
37006 let value = serde_yaml::Value::Mapping(cr);
37007
37008 assert_eq!(
37009 kube_root_str_field(&value, KUBE_KEY_API_VERSION),
37010 Some(GATEWAY_API_API_VERSION),
37011 "kube_root_str_field must read top-level apiVersion as a \
37012 string scalar — the caixa-flux `cluster_bundle_*_uses_\
37013 lifted_flux_api_version` pins + caixa-mesh per-CR \
37014 apiVersion pins reach through this axis for discriminator \
37015 equality"
37016 );
37017 assert_eq!(
37018 kube_root_str_field(&value, KUBE_KEY_KIND),
37019 Some(GATEWAY_API_KIND_GATEWAY),
37020 "kube_root_str_field must read top-level kind as a string \
37021 scalar — the 15 caixa-mesh `gateway_routes` per-CR find \
37022 sites reach through this axis to filter the multi-doc \
37023 emission sequence by kind discriminator"
37024 );
37025 }
37026
37027 #[test]
37028 fn kube_root_str_field_returns_none_when_field_absent() {
37029 // Every K8s CR document the emit-side `kube_resource_skeleton`
37030 // renders carries `apiVersion:` + `kind:` scalars, but the
37031 // readback surface is called on arbitrary Value inputs
37032 // (multi-doc sequences under iteration, upstream ComputeUnit
37033 // YAML documents) that may legally omit either axis-key. The
37034 // prior inline two-hop chain silently short-circuits on the
37035 // outer `.get(field)` hop when the axis is absent; pin the
37036 // helper's None return so the prior no-panic contract holds.
37037 // Also verify on non-Mapping outer Value shapes an external
37038 // YAML document may parse into.
37039 let value = serde_yaml::Value::Mapping(serde_yaml::Mapping::new());
37040 assert_eq!(
37041 kube_root_str_field(&value, KUBE_KEY_API_VERSION),
37042 None,
37043 "kube_root_str_field must short-circuit to None when the \
37044 requested top-level axis-key is absent — the prior inline \
37045 `.get(field)` outer hop returned None here, and every \
37046 routed caller (test pin + filter predicate) depends on \
37047 that None-arm reaching through"
37048 );
37049 assert_eq!(
37050 kube_root_str_field(&value, KUBE_KEY_KIND),
37051 None,
37052 "kube_root_str_field must short-circuit to None on a \
37053 missing top-level kind axis-key — every routed \
37054 caixa-mesh find-predicate compares against Some(<KIND>) \
37055 and must reject None-shaped entries silently"
37056 );
37057
37058 for shape in [
37059 serde_yaml::Value::Null,
37060 serde_yaml::Value::String("scalar".into()),
37061 serde_yaml::Value::Sequence(vec![]),
37062 serde_yaml::Value::Number(0.into()),
37063 serde_yaml::Value::Bool(false),
37064 ] {
37065 assert_eq!(
37066 kube_root_str_field(&shape, KUBE_KEY_KIND),
37067 None,
37068 "kube_root_str_field({shape:?}, KUBE_KEY_KIND) must \
37069 return None on non-Mapping shapes — the prior inline \
37070 `.get(field)` hop yields None on every non-Mapping \
37071 Value, and the lift must preserve that contract"
37072 );
37073 }
37074 }
37075
37076 #[test]
37077 fn kube_root_str_field_returns_none_when_field_carries_non_string_type() {
37078 // A top-level `<field>` axis-key present but carrying a non-
37079 // string YAML type — schema-invalid per the K8s apiserver's
37080 // OpenAPI schema but tolerated here as None so the readback
37081 // stays a total function. The prior inline chain's trailing
37082 // `.and_then(|n| n.as_str())` shape gate silently short-
37083 // circuits here; pin the helper's None-arm so a future
37084 // refactor that reaches for `.as_str().unwrap()` (which would
37085 // panic on a numeric axis-value) is a test-visible break, not
37086 // a runtime regression at the first schema-invalid CR the
37087 // reader sees.
37088 for non_string in [
37089 serde_yaml::Value::Null,
37090 serde_yaml::Value::Number(42.into()),
37091 serde_yaml::Value::Bool(true),
37092 serde_yaml::Value::Sequence(vec![]),
37093 serde_yaml::Value::Mapping(serde_yaml::Mapping::new()),
37094 ] {
37095 let mut cr = serde_yaml::Mapping::new();
37096 cr.insert_str_key(KUBE_KEY_KIND, non_string.clone());
37097 let value = serde_yaml::Value::Mapping(cr);
37098 assert_eq!(
37099 kube_root_str_field(&value, KUBE_KEY_KIND),
37100 None,
37101 "kube_root_str_field must return None when top-level \
37102 kind carries a non-string YAML type ({non_string:?}) \
37103 — the prior inline `.and_then(|n| n.as_str())` shape \
37104 gate short-circuited here, and every routed caller \
37105 depends on that None-arm to keep the readback total"
37106 );
37107 }
37108 }
37109
37110 #[test]
37111 fn kube_root_str_field_matches_prior_inline_chain() {
37112 // Cross-check the helper's output byte-for-byte against the
37113 // prior inline two-hop chain both routed renderers previously
37114 // carried. A drift between the helper's return and the inline
37115 // chain would silently regress every routed test-side filter's
37116 // equality comparison + the caixa-flux production-shape
37117 // per-document apiVersion / kind pin — pin the byte-
37118 // equivalence so the helper remains a drop-in replacement for
37119 // every routed site's prior two-line block.
37120 let mut cr = serde_yaml::Mapping::new();
37121 cr.insert_str_key(
37122 KUBE_KEY_API_VERSION,
37123 serde_yaml::Value::String(FLUX_HELMRELEASE_API_VERSION.into()),
37124 );
37125 cr.insert_str_key(
37126 KUBE_KEY_KIND,
37127 serde_yaml::Value::String(FLUX_KIND_HELM_RELEASE.into()),
37128 );
37129 let value = serde_yaml::Value::Mapping(cr);
37130
37131 for field in [KUBE_KEY_API_VERSION, KUBE_KEY_KIND] {
37132 let via_helper = kube_root_str_field(&value, field);
37133 let via_inline = value.get(field).and_then(|n| n.as_str());
37134 assert_eq!(
37135 via_helper, via_inline,
37136 "kube_root_str_field(_, {field:?}) must yield the same \
37137 Option<&str> as the prior inline two-hop chain — \
37138 otherwise every routed caller's equality-filter / \
37139 discriminator-pin drifts silently at readback time"
37140 );
37141 }
37142 }
37143
37144 #[test]
37145 fn kube_root_str_field_and_kube_metadata_str_field_bracket_the_readback_surface() {
37146 // Peer-pin: the two lifted K8s-CR readback primitives cover
37147 // orthogonal axes on the same document. Given a full K8s CR
37148 // (top-level `apiVersion:` + `kind:` discriminator pair,
37149 // sub-`metadata.name:` + `metadata.namespace:` identity pair),
37150 // each helper reaches through its own axis and the two
37151 // together enumerate every documented top-level string
37152 // scalar the substrate emits + reads back. Pin the pairing so
37153 // a future refactor that collapses the two into a single
37154 // navigation primitive (or splits one further) surfaces here
37155 // as a test-visible break, not a silent regression at the
37156 // first routed caller's per-CR readback drift.
37157 let mut metadata = serde_yaml::Mapping::new();
37158 metadata.insert_str_key(
37159 KUBE_KEY_NAME,
37160 serde_yaml::Value::String("checkout-cart-to-catalog".into()),
37161 );
37162 metadata.insert_str_key(
37163 KUBE_KEY_NAMESPACE,
37164 serde_yaml::Value::String(DEFAULT_NAMESPACE.into()),
37165 );
37166 let mut cr = serde_yaml::Mapping::new();
37167 cr.insert_str_key(
37168 KUBE_KEY_API_VERSION,
37169 serde_yaml::Value::String(CILIUM_API_VERSION.into()),
37170 );
37171 cr.insert_str_key(
37172 KUBE_KEY_KIND,
37173 serde_yaml::Value::String(CILIUM_KIND_NETWORK_POLICY.into()),
37174 );
37175 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
37176 let value = serde_yaml::Value::Mapping(cr);
37177
37178 assert_eq!(
37179 kube_root_str_field(&value, KUBE_KEY_API_VERSION),
37180 Some(CILIUM_API_VERSION)
37181 );
37182 assert_eq!(
37183 kube_root_str_field(&value, KUBE_KEY_KIND),
37184 Some(CILIUM_KIND_NETWORK_POLICY)
37185 );
37186 assert_eq!(
37187 kube_metadata_str_field(&value, KUBE_KEY_NAME),
37188 Some("checkout-cart-to-catalog")
37189 );
37190 assert_eq!(
37191 kube_metadata_str_field(&value, KUBE_KEY_NAMESPACE),
37192 Some(DEFAULT_NAMESPACE)
37193 );
37194 }
37195
37196 #[test]
37197 fn kube_kind_is_matches_lifted_kube_root_str_field_equality_shape() {
37198 // Byte-equivalence pin: the lifted predicate reproduces the
37199 // three-token composition (`kube_root_str_field(v,
37200 // KUBE_KEY_KIND) == Some(<KIND>)`) the 15 caixa-mesh test-side
37201 // `.find`/`.filter` sites previously carried inline. Closes the
37202 // "did the lift accidentally rename the pinned scalar-key axis
37203 // to KUBE_KEY_API_VERSION or drop the `Some(...)` wrap" drift
37204 // class every future re-lift on the peer-axis surface (a
37205 // hypothetical `kube_api_version_is` peer, `kube_group_is` on a
37206 // multi-group router harness) would otherwise reopen.
37207 let mut cr = serde_yaml::Mapping::new();
37208 cr.insert_str_key(
37209 KUBE_KEY_KIND,
37210 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37211 );
37212 let value = serde_yaml::Value::Mapping(cr);
37213
37214 assert!(kube_kind_is(&value, GATEWAY_API_KIND_GATEWAY));
37215 assert_eq!(
37216 kube_kind_is(&value, GATEWAY_API_KIND_GATEWAY),
37217 kube_root_str_field(&value, KUBE_KEY_KIND) == Some(GATEWAY_API_KIND_GATEWAY),
37218 );
37219 }
37220
37221 #[test]
37222 fn kube_kind_is_false_on_mismatched_kind_and_missing_kind() {
37223 // Complement-side pin: the predicate returns `false` when
37224 // either the kind axis carries a different discriminator or the
37225 // top-level `kind:` scalar is absent altogether (the same
37226 // vacuous-`None` short-circuit the parent
37227 // `kube_root_str_field` closes on the underlying two-hop
37228 // navigation). Consumer sites (`docs.iter().find(|d|
37229 // kube_kind_is(d, X))`) rely on the false-on-mismatch shape to
37230 // skip the wrong CRs across the multi-doc mesh emission and
37231 // land on the intended per-kind document.
37232 let mut cr_wrong_kind = serde_yaml::Mapping::new();
37233 cr_wrong_kind.insert_str_key(
37234 KUBE_KEY_KIND,
37235 serde_yaml::Value::String(GATEWAY_API_KIND_HTTP_ROUTE.into()),
37236 );
37237 assert!(!kube_kind_is(
37238 &serde_yaml::Value::Mapping(cr_wrong_kind),
37239 GATEWAY_API_KIND_GATEWAY,
37240 ));
37241
37242 let cr_no_kind = serde_yaml::Mapping::new();
37243 assert!(!kube_kind_is(
37244 &serde_yaml::Value::Mapping(cr_no_kind),
37245 GATEWAY_API_KIND_GATEWAY,
37246 ));
37247 }
37248
37249 #[test]
37250 fn find_by_kind_matches_inline_iter_find_kube_kind_is_shape() {
37251 // Byte-equivalence pin: the lifted navigator reproduces the
37252 // three-token combinator chain (`docs.iter().find(|d|
37253 // kube_kind_is(d, <KIND>))`) the 14 caixa-mesh test-side
37254 // per-Gateway / per-HTTPRoute find-by-kind sites previously
37255 // carried inline. Closes the "did the lift accidentally
37256 // widen the receiver, drop the closure, or swap `find` for
37257 // `filter`" drift class every future re-lift on the sibling
37258 // multi-doc-navigator axis (a hypothetical
37259 // `filter_by_kind` peer that carries the same underlying
37260 // predicate but returns an iterator) would otherwise reopen.
37261 let mut gateway = serde_yaml::Mapping::new();
37262 gateway.insert_str_key(
37263 KUBE_KEY_KIND,
37264 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37265 );
37266 let mut route = serde_yaml::Mapping::new();
37267 route.insert_str_key(
37268 KUBE_KEY_KIND,
37269 serde_yaml::Value::String(GATEWAY_API_KIND_HTTP_ROUTE.into()),
37270 );
37271 let docs = vec![
37272 serde_yaml::Value::Mapping(gateway),
37273 serde_yaml::Value::Mapping(route),
37274 ];
37275
37276 // Lifted navigator agrees with the inline combinator chain
37277 // on every existing member of the multi-doc slice.
37278 assert_eq!(
37279 find_by_kind(&docs, GATEWAY_API_KIND_GATEWAY),
37280 docs.iter()
37281 .find(|d| kube_kind_is(d, GATEWAY_API_KIND_GATEWAY)),
37282 );
37283 assert_eq!(
37284 find_by_kind(&docs, GATEWAY_API_KIND_HTTP_ROUTE),
37285 docs.iter()
37286 .find(|d| kube_kind_is(d, GATEWAY_API_KIND_HTTP_ROUTE)),
37287 );
37288
37289 // And on the miss path: absent kind → None, matching the
37290 // inline `.find` short-circuit that consumer sites rely on
37291 // to distinguish "no such CR in this emission" from "wrong
37292 // shape" in their `.unwrap()` / `.expect(...)` follow-ups.
37293 assert_eq!(find_by_kind(&docs, CILIUM_KIND_NETWORK_POLICY), None);
37294 let empty: Vec<serde_yaml::Value> = Vec::new();
37295 assert_eq!(find_by_kind(&empty, GATEWAY_API_KIND_GATEWAY), None);
37296 }
37297
37298 #[test]
37299 fn find_by_kind_returns_first_match_on_duplicate_kind() {
37300 // Order-preservation pin: the lifted navigator returns the
37301 // first document of the matching kind (the same short-
37302 // circuit `Iterator::find` exposes). Multi-doc mesh
37303 // emissions never carry two documents of the same kind at
37304 // V0 (`gateway_routes` emits exactly one `Gateway` + one
37305 // `HTTPRoute` per Aplicacao), but the M4 cross-cluster
37306 // fan-out will (one `HelmRelease` per cluster). Pinning the
37307 // first-match contract keeps the M4 caller-side "the first
37308 // hit is the primary" convention aligned with the helper's
37309 // combinator half.
37310 let mut gateway_a = serde_yaml::Mapping::new();
37311 gateway_a.insert_str_key(
37312 KUBE_KEY_KIND,
37313 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37314 );
37315 let mut meta_a = serde_yaml::Mapping::new();
37316 meta_a.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("primary".into()));
37317 gateway_a.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(meta_a));
37318 let mut gateway_b = serde_yaml::Mapping::new();
37319 gateway_b.insert_str_key(
37320 KUBE_KEY_KIND,
37321 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37322 );
37323 let mut meta_b = serde_yaml::Mapping::new();
37324 meta_b.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("secondary".into()));
37325 gateway_b.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(meta_b));
37326 let docs = vec![
37327 serde_yaml::Value::Mapping(gateway_a),
37328 serde_yaml::Value::Mapping(gateway_b),
37329 ];
37330
37331 let first = find_by_kind(&docs, GATEWAY_API_KIND_GATEWAY).unwrap();
37332 assert_eq!(
37333 kube_metadata_str_field(first, KUBE_KEY_NAME),
37334 Some("primary"),
37335 );
37336 }
37337
37338 // ── contrato-edge-label + cilium-network-policy-name lifts ──────────
37339
37340 #[test]
37341 fn contrato_edge_label_separator_pin() {
37342 // Load-bearing byte-string pin: the M3 `:contratos`
37343 // edge-direction separator every caixa-mesh emitter that
37344 // encodes a typed edge as a K8s-name-shaped scalar reads from.
37345 // Any future rebrand (e.g. `-to-` → `_to_`) lands here as a
37346 // one-const edit; the peer `contrato_edge_label` /
37347 // `cilium_network_policy_name` composers pick up the new
37348 // encoding by construction. A drift on this const would silently
37349 // split the CNP `metadata.name` from its own
37350 // `metadata.labels.pleme.pleme.io/contrato` value, orphaning
37351 // every operator-side grep-by-label query far from the source
37352 // caixa.lisp.
37353 assert_eq!(CONTRATO_EDGE_LABEL_SEPARATOR, "-to-");
37354 }
37355
37356 #[test]
37357 fn contrato_edge_label_matches_inline_de_to_para_encoding() {
37358 // Byte-shape pin: the composer produces the same
37359 // `format!("{de}-to-{para}")` byte-string every caixa-mesh
37360 // per-`(:de, :para)` `CiliumNetworkPolicy` emitter previously
37361 // inlined at its `labels.insert(LABEL_CONTRATO, …)` call. So a
37362 // future rewire of the composer's internals (multi-hop typed
37363 // edges once the M4 per-edge WIT registry lands, unicode
37364 // arrow-shape rebrand for operator display) reaches every
37365 // consumer through one canonical function-pointer edit.
37366 assert_eq!(contrato_edge_label("cart", "catalog"), "cart-to-catalog");
37367 assert_eq!(contrato_edge_label("cart", "payment"), "cart-to-payment");
37368 }
37369
37370 #[test]
37371 fn contrato_edge_label_threads_separator_between_de_and_para() {
37372 // Composition pin: the composer's shape is
37373 // `de + CONTRATO_EDGE_LABEL_SEPARATOR + para`, so a future
37374 // separator rebrand at [`CONTRATO_EDGE_LABEL_SEPARATOR`]
37375 // reaches the composer through one const-edit and every
37376 // consumer picks up the new encoding by construction. Pin the
37377 // structural equation (not just the byte value) so a future
37378 // reorder of the composer's `format!` argument list (a
37379 // `format!("{para}-{sep}-{de}")` typo mid-refactor) fires here
37380 // rather than silently emitting reversed-direction CNP labels.
37381 let de = "svc-a";
37382 let para = "svc-b";
37383 assert_eq!(
37384 contrato_edge_label(de, para),
37385 format!("{de}{CONTRATO_EDGE_LABEL_SEPARATOR}{para}"),
37386 );
37387 }
37388
37389 #[test]
37390 fn cilium_network_policy_name_matches_inline_aplicacao_de_to_para_encoding() {
37391 // Byte-shape pin: the composer produces the same
37392 // `format!("{aplicacao}-{de}-to-{para}")` byte-string every
37393 // caixa-mesh `cilium_network_policies` per-`(:de, :para)`
37394 // group's `kube_resource_skeleton` `name:` argument previously
37395 // inlined. So a future rewire of the composer's internals
37396 // reaches the CNP renderer through one canonical function-
37397 // pointer edit rather than a coordinated two-site rewrite of
37398 // the [`LABEL_CONTRATO`] labels.insert(...) call and the CNP
37399 // name argument.
37400 assert_eq!(
37401 cilium_network_policy_name("checkout", "cart", "catalog"),
37402 "checkout-cart-to-catalog",
37403 );
37404 assert_eq!(
37405 cilium_network_policy_name("checkout", "cart", "payment"),
37406 "checkout-cart-to-payment",
37407 );
37408 }
37409
37410 #[test]
37411 fn cilium_network_policy_name_composes_on_contrato_edge_label() {
37412 // Composition pin: the CNP name is the parent Aplicacao's
37413 // `:nome` joined to the contrato-edge-label by a canonical `-`
37414 // separator (`format!("{aplicacao}-{edge}")`), so the two
37415 // writer-side helpers close the canonical
37416 // `(LABEL_CONTRATO-value, metadata.name)` per-CNP identity
37417 // pair on one shared edge-encoding source of truth
37418 // ([`CONTRATO_EDGE_LABEL_SEPARATOR`]). Pin the structural
37419 // equation so a future refactor of either composer's internals
37420 // that accidentally desynchronizes the two (a CNP-name
37421 // rebrand landing on `format!("{aplicacao}_{edge}")` while
37422 // the label-value composer stays on `{de}-to-{para}`, or a
37423 // label-composer rebrand landing on `->` while the CNP-name
37424 // composer stays on `-to-`) fires here rather than silently
37425 // orphaning every operator-side grep-by-label query at apply
37426 // time.
37427 let aplicacao = "checkout";
37428 let de = "cart";
37429 let para = "catalog";
37430 let edge = contrato_edge_label(de, para);
37431 assert_eq!(
37432 cilium_network_policy_name(aplicacao, de, para),
37433 format!("{aplicacao}-{edge}"),
37434 );
37435 }
37436
37437 // ── gateway-api-http-route-name lift ────────────────────────────────
37438
37439 #[test]
37440 fn gateway_api_http_route_name_matches_inline_aplicacao_para_encoding() {
37441 // Byte-shape pin: the composer produces the same
37442 // `format!("{aplicacao}-{para}")` byte-string the caixa-mesh
37443 // `gateway_routes` per-`:entrada` `kube_resource_skeleton`
37444 // `name:` argument previously inlined as
37445 // `format!("{}-{}", caixa.nome, entrada.para)`. So a future
37446 // rewire of the composer's internals reaches the HTTPRoute
37447 // renderer through one canonical function-pointer edit rather
37448 // than a hand-agreement between the emitter and every
37449 // test-side probe pinning the expected `<aplicacao>-<para>`
37450 // byte-shape at the HTTPRoute `metadata.name` axis.
37451 assert_eq!(
37452 gateway_api_http_route_name("checkout", "cart"),
37453 "checkout-cart",
37454 );
37455 assert_eq!(gateway_api_http_route_name("orders", "cart"), "orders-cart",);
37456 }
37457
37458 #[test]
37459 fn rendered_file_carries_path_and_contents_fields() {
37460 // Field-shape pin: the canonical [`RenderedFile`] every
37461 // per-target `caixa-<target>` renderer's per-artifact leaf
37462 // resolves through carries exactly the `(path, contents)` pair
37463 // the prior per-crate `BundleFile { path: PathBuf, contents:
37464 // String }` (`caixa-flux`) / `ChartFile { path: PathBuf,
37465 // contents: String }` (`caixa-helm`) clones each carried
37466 // verbatim. A future refactor that adds a per-artifact
37467 // hash / provenance / write-mode discriminator on the record
37468 // must land at the canonical struct definition (this file) —
37469 // the two type aliases at `caixa-flux::BundleFile` /
37470 // `caixa-helm::ChartFile` re-export the canonical unchanged, so
37471 // an addition here reaches both per-target renderers at once,
37472 // and a struct-literal drift that inlines the pre-lift shape
37473 // at either alias trips this pin at caixa-core build time
37474 // rather than surfacing as a divergent per-target renderer's
37475 // record shape far from the source.
37476 let f = RenderedFile {
37477 path: PathBuf::from("Chart.yaml"),
37478 contents: "apiVersion: v2\n".to_string(),
37479 };
37480 assert_eq!(f.path, PathBuf::from("Chart.yaml"));
37481 assert_eq!(f.contents, "apiVersion: v2\n");
37482 }
37483
37484 #[test]
37485 fn rendered_file_derives_pattern_pin() {
37486 // Derive-shape pin: the canonical [`RenderedFile`] carries the
37487 // `Debug + Clone + PartialEq + Eq` derive tuple the two per-
37488 // renderer clones (`caixa-flux::BundleFile` /
37489 // `caixa-helm::ChartFile`) each carried verbatim before the
37490 // lift. `Clone::clone` returns a byte-equal record + the
37491 // `PartialEq::eq` impl returns `true` on the round-trip; a
37492 // future refactor that drops one of the four derives (say,
37493 // removes `PartialEq` on a per-artifact-hash addition) trips
37494 // this pin at caixa-core build time and surfaces the
37495 // per-alias downstream `assert_eq!(bundle_file_a,
37496 // bundle_file_b)` / `assert_eq!(chart_file_a, chart_file_b)`
37497 // navigators in `caixa-flux` / `caixa-helm` — every
37498 // per-alias derive-fed navigator threads through this
37499 // canonical derive tuple by construction.
37500 let f = RenderedFile {
37501 path: PathBuf::from("values.yaml"),
37502 contents: "pleme-computeunit:\n enabled: false\n".to_string(),
37503 };
37504 let clone = f.clone();
37505 assert_eq!(f, clone);
37506 let dbg = format!("{f:?}");
37507 assert!(
37508 dbg.contains("RenderedFile"),
37509 "Debug output must name the canonical type, got: {dbg:?}",
37510 );
37511 }
37512
37513 #[test]
37514 fn rendered_file_new_matches_struct_literal_shape() {
37515 // Constructor pin: [`RenderedFile::new(FILENAME, contents)`]
37516 // (the canonical lifted `impl Into<PathBuf>` / `impl Into<String>`
37517 // inherent constructor every per-target renderer's per-artifact
37518 // leaf now routes through) produces the byte-identical record
37519 // the six prior inline struct-literal call sites (three
37520 // per-artifact leaves in
37521 // [`caixa_helm::render_chart_for_servico_with`],
37522 // three per-CR leaves in [`caixa_flux::cluster_bundle`]) each
37523 // open-coded as `<Xxx>File { path: PathBuf::from(FILENAME_CONST),
37524 // contents: <body> }`. Pin the equation on a
37525 // `HELM_VALUES_YAML_FILENAME`-shaped input so a future rebrand
37526 // of the constructor's internals (a per-artifact hash /
37527 // provenance field addition, an
37528 // [`is_sandboxed_relative_path`] check at construction time
37529 // once per-cluster-writer sandboxing lands) fires here rather
37530 // than silently splitting the per-target renderer's per-CR
37531 // record shape from the substrate-canonical `(path, contents)`
37532 // pair at the caixa-core canonical.
37533 let via_new = RenderedFile::new(HELM_VALUES_YAML_FILENAME, "pleme-computeunit:\n");
37534 let via_literal = RenderedFile {
37535 path: PathBuf::from(HELM_VALUES_YAML_FILENAME),
37536 contents: "pleme-computeunit:\n".to_string(),
37537 };
37538 assert_eq!(via_new, via_literal);
37539 // Peer path-side pin: `impl Into<PathBuf>` accepts a `PathBuf`
37540 // directly (the future per-target renderer surface where the
37541 // path is composed from author input rather than picked from a
37542 // substrate-canonical `&'static str` filename constant) —
37543 // exercised so a drift onto a stricter `&str`-only bound
37544 // trips this pin at caixa-core build time rather than at the
37545 // first per-target renderer that reaches for the wider bound.
37546 let via_new_from_pathbuf = RenderedFile::new(
37547 PathBuf::from(FLUX_HELMRELEASE_YAML_FILENAME),
37548 String::from("kind: HelmRelease\n"),
37549 );
37550 assert_eq!(
37551 via_new_from_pathbuf.path,
37552 PathBuf::from(FLUX_HELMRELEASE_YAML_FILENAME),
37553 );
37554 assert_eq!(via_new_from_pathbuf.contents, "kind: HelmRelease\n");
37555 }
37556
37557 #[test]
37558 fn gateway_api_http_route_name_composes_on_canonical_dash_separator() {
37559 // Composition pin: the HTTPRoute `metadata.name` is the parent
37560 // Aplicacao's `:nome` joined to the `:entrada :para`
37561 // destination Servico's `:nome` by a canonical `-` separator
37562 // (`format!("{aplicacao}-{para}")`) — the same
37563 // "aplicacao-prefixed sub-identity" discipline the peer
37564 // [`cilium_network_policy_name`] composer materializes on the
37565 // sibling per-CR K8s-name-shaped-identity-scalar axis
37566 // ([`format!("{aplicacao}-{edge}")`]). Pin the structural
37567 // equation so a future refactor of either composer's internals
37568 // that accidentally desynchronizes the two (an HTTPRoute-name
37569 // rebrand landing on `format!("{aplicacao}.{para}")` while
37570 // the CNP-name composer stays on `{aplicacao}-{edge}`, or a
37571 // per-Aplicacao-K8s-CR-name shared-separator rebrand landing
37572 // on the CNP-name composer without a coordinated edit here)
37573 // fires here rather than silently splitting the two per-CR
37574 // name-encoding axes across the caixa-mesh renderer.
37575 let aplicacao = "checkout";
37576 let para = "cart";
37577 assert_eq!(
37578 gateway_api_http_route_name(aplicacao, para),
37579 format!("{aplicacao}-{para}"),
37580 );
37581 }
37582}