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/// Predicate: does the K8s custom resource YAML document at `value`
19038/// declare its `metadata.name` identity axis as exactly `name`?
19039///
19040/// Composes on top of [`kube_metadata_str_field`] (6809867) — same
19041/// two-hop `.get(KUBE_KEY_METADATA).and_then(get(KUBE_KEY_NAME))
19042/// .and_then(as_str)` navigation — and closes the
19043/// "metadata.name identity equality" predicate axis every multi-doc
19044/// mesh emission traversal reaches for to split the emitted sequence
19045/// by per-CR name (the CR identity axis) rather than by CRD-kind
19046/// (the CR shape axis) the sibling [`kube_kind_is`] already closes.
19047///
19048/// The canonical shape 6 test-side
19049///
19050/// ```ignore
19051/// kube_metadata_str_field(p, KUBE_KEY_NAME) == Some(<NAME>)
19052/// ```
19053///
19054/// call sites in [`caixa-mesh`][mesh]'s per-CNP-name /
19055/// per-Aplicacao-edge test harnesses previously carried inline as
19056/// the three-token composition — the readback helper call, the
19057/// `== Some(...)` equality wrap, the identity-axis pin on
19058/// [`KUBE_KEY_NAME`] — around a one-token semantic payload (the
19059/// `<NAME>` axis-value: `"checkout-cart-to-catalog"`,
19060/// `"checkout-payment-to-cart"`, `"checkout-cart-to-payment"`, each
19061/// a [`cilium_network_policy_name`]-composed byte-string). The lift
19062/// collapses the three-token composition onto one predicate the
19063/// caller reads as intent (`kube_name_is(p, <NAME>)` — "is this K8s
19064/// CR document named `<NAME>`") rather than as a
19065/// `readback → wrap → compare` chain.
19066///
19067/// The [`KUBE_KEY_NAME`] axis is pinned inside the helper (unlike
19068/// the parametric `field` axis of the underlying
19069/// [`kube_metadata_str_field`]) because the "is this CR document
19070/// named X" question is a semantically-distinct identity predicate,
19071/// not a generic scalar-readback: the K8s API-machinery pins
19072/// `metadata.name` as the load-bearing per-CR identity axis on every
19073/// `CustomResource` across every group/version (paired with
19074/// `metadata.namespace` for cluster-scoped-vs-namespaced disambiguation),
19075/// so this predicate lives one abstraction step above the generic
19076/// readback. Peer predicates for other `metadata.*` sub-axes (e.g. a
19077/// hypothetical `kube_namespace_is` on a per-namespace router harness,
19078/// a future `kube_uid_is` for ownerReference bookkeeping) land as
19079/// sibling helpers with their own pinned axis, not as
19080/// re-parameterizations of this one.
19081///
19082/// Structural peer to [`kube_kind_is`] (2902d9d) on the sibling
19083/// top-level `kind:` discriminator axis: [`kube_kind_is`] answers
19084/// "does this document match kind X" (the CR shape axis);
19085/// [`kube_name_is`] answers "does this document match name X" (the
19086/// CR identity axis). Same one-hop readback + equality-wrap shape,
19087/// different pinned scalar-key — together they bracket the two
19088/// canonical CR discriminator axes every multi-doc mesh emission
19089/// traversal reaches for.
19090///
19091/// Sites lifted:
19092///
19093/// * caixa-mesh's `cilium_network_policies` test harness — 6
19094/// `.find(|p| kube_metadata_str_field(p, KUBE_KEY_NAME) ==
19095/// Some(<NAME>))` + `.filter(|p| … == Some(<NAME>))` sites
19096/// splitting the emitted CNP multi-doc sequence by the
19097/// [`cilium_network_policy_name`]-composed `<aplicacao>-<de>-to-
19098/// <para>` byte-string for per-CR body-axis assertions.
19099///
19100/// Every future per-CR-name traversal (the M4 cross-cluster fan-out's
19101/// per-cluster `HelmRelease`-name-router; the `app-operator`'s
19102/// per-Aplicacao `mesh.pleme.io/v1alpha1/Aplicacao` CR status-name
19103/// join; the future per-`:contratos`
19104/// `CiliumClusterwideEnvoyConfig`-name filter) reaches the same
19105/// helper by construction, with no `== Some(...)` inline composition
19106/// and no drift surface on the `metadata.name` scalar-key axis.
19107///
19108/// [mesh]: https://github.com/pleme-io/caixa/tree/main/caixa-mesh
19109#[must_use]
19110pub fn kube_name_is(value: &serde_yaml::Value, name: &str) -> bool {
19111 kube_name(value) == Some(name)
19112}
19113
19114/// Read the `metadata.name` string-scalar identity axis of a K8s
19115/// custom resource YAML document as `Option<&str>` — the pinned peer
19116/// on the identity axis to the parametric [`kube_metadata_str_field`]
19117/// on the two-hop `metadata.<field>` sub-axis surface. Returns `None`
19118/// when either the enclosing `metadata:` block is absent, the sub-
19119/// `name:` scalar is absent, or the sub-`name:` scalar carries a
19120/// non-string YAML type — the same three-way vacuous-`None` short-
19121/// circuit the parent [`kube_metadata_str_field`] closes on the
19122/// underlying two-hop navigation.
19123///
19124/// The [`KUBE_KEY_NAME`] axis is pinned inside the helper (unlike
19125/// the parametric `field` axis of the underlying
19126/// [`kube_metadata_str_field`]) because the K8s API-machinery pins
19127/// `metadata.name` as the load-bearing per-CR identity axis on every
19128/// `CustomResource` across every group/version. Every readback
19129/// consumer downstream (`.unwrap()`, `.expect(...)`, `== Some(...)`
19130/// equality wraps, `.to_string()` clone, `.strip_prefix(...)` /
19131/// `.split_once(...)` decompose chains) drives off the same pinned
19132/// return; a hypothetical future K8s API-machinery rename on the
19133/// `metadata.name` axis (a Server-Side-Apply-driven identity
19134/// migration under per-field ownership annotations, an alias table
19135/// bridging a new `metadata.identity` sub-axis) reaches every
19136/// caller through one lift, not a coordinated rewrite across every
19137/// per-CR readback site.
19138///
19139/// The canonical shape 12 emit-side test-harness readback sites
19140/// across [`caixa-mesh`][mesh] (9) + [`caixa-flux`][flux] (3)
19141/// previously carried inline as the two-token composition
19142///
19143/// ```ignore
19144/// kube_metadata_str_field(<value>, KUBE_KEY_NAME)
19145/// ```
19146///
19147/// around a one-token semantic payload (the readback intent — "what
19148/// name did the emitter write into this CR?"). The lift collapses
19149/// the two-token composition — the parametric readback helper, the
19150/// pinned identity-axis scalar-key argument — onto one accessor the
19151/// caller reads as intent (`kube_name(<value>)` — "what is this K8s
19152/// CR document's `metadata.name`?") rather than a
19153/// `readback → axis-pin` two-arg call.
19154///
19155/// Structural peer to sibling [`kube_kind_is`] (predicate arity) /
19156/// [`find_by_kind`] (navigator arity) / [`kube_name_is`] (predicate
19157/// arity) / [`find_by_name`] (navigator arity) on the same canonical
19158/// K8s CR discriminator+identity axis pair: this closes the accessor
19159/// arity on the identity axis — the "what is this document's name?"
19160/// question the peer predicate answers as equality and the peer
19161/// navigator answers as filter-then-first-hit. Same axis, three
19162/// arities — the accessor (`kube_name`) reads, the predicate
19163/// (`kube_name_is`) tests, the navigator (`find_by_name`) locates —
19164/// each pinned to [`KUBE_KEY_NAME`] inside the helper so the axis-
19165/// key drift class is closed across every consumer surface.
19166///
19167/// Sites lifted:
19168///
19169/// * caixa-mesh's per-CNP `metadata.name` readback loop in the
19170/// five test bodies `cilium_network_policy_metadata_name_uses_lifted_composer`,
19171/// `cilium_network_policy_metadata_name_derives_from_caixa_nome_accessor`,
19172/// `cilium_emits_one_policy_per_de_para_pair`, and
19173/// `cilium_network_policy_l4_port_matches_dest_servico_port` —
19174/// each `p → kube_metadata_str_field(p, KUBE_KEY_NAME).expect|unwrap`
19175/// readback inside the fan-in `.iter().map(...)` or per-policy
19176/// `for` loop over the multi-doc CNP emission;
19177/// * caixa-mesh's per-Gateway / per-HTTPRoute `metadata.name`
19178/// readback across the four test bodies
19179/// `gateway_routes_httproute_metadata_name_uses_lifted_composer`,
19180/// `gateway_routes_gateway_metadata_name_routes_through_caixa_nome_accessor`,
19181/// `gateway_routes_httproute_metadata_name_routes_through_caixa_nome_accessor`,
19182/// and the per-`:entrada :para` parametric permutation harness —
19183/// each `find_by_kind(&docs, <KIND>) → kube_metadata_str_field(..,
19184/// KUBE_KEY_NAME).expect(...)` chain over the paired-Gateway/HTTPRoute
19185/// emission;
19186/// * caixa-flux's three
19187/// `cluster_bundle_{gitrepository,helmrelease,kustomization}_metadata_name_routes_through_caixa_nome_accessor`
19188/// tests — each per-emitted-file
19189/// `parsed → kube_metadata_str_field(&parsed, KUBE_KEY_NAME).expect(...)`
19190/// site on the per-Flux-CR bundle-path emission.
19191///
19192/// Every future per-CR `metadata.name` readback (the M4 cross-cluster
19193/// fan-out's per-cluster `HelmRelease` name-router, the `app-
19194/// operator`'s per-Aplicacao `mesh.pleme.io/v1alpha1/Aplicacao` CR
19195/// status-name join, MESH-COMPOSITION §III.2 #5; the future per-
19196/// `:contratos` `CiliumClusterwideEnvoyConfig`-name introspection
19197/// filter) reaches the same pinned accessor by construction, with no
19198/// axis-key argument drift and no re-inlined
19199/// `kube_metadata_str_field(_, KUBE_KEY_NAME)` two-token composition.
19200///
19201/// [mesh]: https://github.com/pleme-io/caixa/tree/main/caixa-mesh
19202/// [flux]: https://github.com/pleme-io/caixa/tree/main/caixa-flux
19203#[must_use]
19204pub fn kube_name(value: &serde_yaml::Value) -> Option<&str> {
19205 kube_metadata_str_field(value, KUBE_KEY_NAME)
19206}
19207
19208/// Locate the first K8s CR YAML document in `docs` whose
19209/// `metadata.name` identity axis equals `name`.
19210///
19211/// Composes on top of [`kube_name_is`] — same one-hop
19212/// `.get(KUBE_KEY_METADATA).and_then(get(KUBE_KEY_NAME))
19213/// .and_then(as_str) == Some(name)` predicate — and closes the
19214/// "find the one document with a given name inside a multi-doc mesh
19215/// emission" navigator axis every per-Aplicacao renderer's post-emit
19216/// test harness reaches for to split the emitted sequence by per-CR
19217/// identity before probing a per-CR body-axis.
19218///
19219/// The canonical shape 5 test-side
19220///
19221/// ```ignore
19222/// docs.iter().find(|d| kube_name_is(d, <NAME>))
19223/// ```
19224///
19225/// call sites in [`caixa-mesh`][mesh]'s `cilium_network_policies`
19226/// test harness previously threaded the three-token
19227/// `.iter().find(closure)` combinator chain around a one-token
19228/// semantic payload (the [`cilium_network_policy_name`]-composed
19229/// `<aplicacao>-<de>-to-<para>` byte-string). The lift collapses
19230/// the three-token chain — the `.iter()` receiver-widen, the
19231/// `.find(closure)` combinator, the inline closure wrap around
19232/// [`kube_name_is`] — onto one navigator function the caller reads
19233/// as intent (`find_by_name(&docs, <NAME>)` — "give me the K8s CR
19234/// document named `<NAME>`") rather than as a
19235/// receiver-widen → combinator → predicate chain.
19236///
19237/// Composition-symmetric to [`kube_name_is`]: the lifted predicate
19238/// answers "does *this* one document match name `<NAME>`?", the
19239/// lifted navigator answers "find the one document of name
19240/// `<NAME>` in *this list*?". Same axis, different arity — the two
19241/// call shapes emit-side test harnesses reach for when splitting
19242/// multi-doc CR emissions by per-CR identity. Peer of
19243/// [`find_by_kind`] (b73a13e) on the sibling `kind:` discriminator
19244/// axis: [`find_by_kind`] navigates by CR shape (there is exactly
19245/// one `Gateway` + one `HTTPRoute` per Aplicacao at V0); this navigates
19246/// by CR identity (there is one CNP per `(:de, :para)` fan-in
19247/// group, and the per-CNP identity is the
19248/// [`cilium_network_policy_name`]-composed edge label).
19249///
19250/// Every future per-CR-name multi-doc-navigator site (the future
19251/// `app-operator`'s per-Aplicacao CR-name join over emitted status
19252/// docs, MESH-COMPOSITION §III.2 #5; the M4 cross-cluster fan-out's
19253/// per-cluster `HelmRelease`-name split; the future per-`:contratos`
19254/// `CiliumClusterwideEnvoyConfig`-name filter over the sibling
19255/// L7-policy emission) reaches the same helper by construction, with
19256/// no inline `.iter().find(closure)` combinator chain and no drift
19257/// surface on the receiver-widen or combinator axes.
19258///
19259/// [mesh]: https://github.com/pleme-io/caixa/tree/main/caixa-mesh
19260#[must_use]
19261pub fn find_by_name<'a>(
19262 docs: &'a [serde_yaml::Value],
19263 name: &str,
19264) -> Option<&'a serde_yaml::Value> {
19265 docs.iter().find(|d| kube_name_is(d, name))
19266}
19267
19268/// Upsert `new_entry` into a typed sequence of programs.yaml-shaped
19269/// entries by matching on `new_entry`'s `<name_key>` scalar — the
19270/// idempotent "replace-in-place if present, else append" contract
19271/// every writer-side aggregator overlay lands the same 11-line block
19272/// in front of. Returns `Ok(true)` when the entry was appended new,
19273/// `Ok(false)` when an existing entry with the same `<name_key>`
19274/// value was replaced in place (preserving position); returns
19275/// `on_missing_name()` when `new_entry` doesn't carry `<name_key>`
19276/// as a string scalar (the caller's own typed
19277/// [`crate::RenderError`]-shaped error surface, threaded through the
19278/// closure so this helper stays crate-agnostic).
19279///
19280/// Two identical-shape call sites collapse onto this helper — the
19281/// two [`caixa-flux`] writer-side upsert paths that both land a
19282/// programs.yaml entry into a `programs:` sequence differing only
19283/// on the outer navigation:
19284///
19285/// * [`caixa_flux::upsert_into_helmrelease_programs`][helm-up] —
19286/// the aggregator-HelmRelease shape, upserting into
19287/// `spec.values.programs[]` on a `HelmRelease` document;
19288/// * [`caixa_flux::upsert_into_programs_yaml`][yaml-up] — the
19289/// bare-values.yaml shape, upserting into `programs[]` at the
19290/// values.yaml root.
19291///
19292/// Until this lift landed both call sites re-inlined the same
19293/// verbatim 11-line block — extract-name-scalar-or-error, iterate
19294/// the sequence, replace-in-place-on-match else fall through to
19295/// push — with no compile-time link between the two: a rebrand on
19296/// either side (a per-entry match key rename beyond the currently-
19297/// lifted [`crate::FLEET_PROGRAMS_KEY_NAME`], the idempotency
19298/// contract's semantic reshaping — e.g. matching on
19299/// `(name, namespace)` for the M4 multi-namespace aggregator flow
19300/// once the `lareira-fleet-programs` chart admits per-entry
19301/// `namespace:` overrides, the return-value's `bool`-shape shift
19302/// once "replace" grows a merge-semantics axis) would silently
19303/// desynchronize the two writer-side paths — one path idempotently
19304/// upserts under the new contract while the other silently keeps
19305/// the old shape, and the failure surfaces at aggregator-apply
19306/// time as a duplicated / missing / mis-merged entry far from the
19307/// rebrand commit's source. Peer of the sibling render-side lifts
19308/// ([`single_field_overlay`], [`servico_m2_overlay`],
19309/// [`insert_first_seen`]) on the same "the same shape written
19310/// verbatim ≥ 2 times becomes a typed helper" trajectory THEORY.md
19311/// §I.3.5 promotes to a build-time concern.
19312///
19313/// The `name_key` axis stays parametric (rather than pinned to
19314/// [`crate::FLEET_PROGRAMS_KEY_NAME`] inside the helper) so a
19315/// future per-entry match on a different discriminator scalar (an
19316/// M4 `id:` axis promoted alongside `name:`, the future
19317/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-entry
19318/// `spec.selector` upsert path) reaches for the same helper with a
19319/// different key rather than re-inlining the loop. The closure-
19320/// shaped error surface (rather than a bare `Result<bool,
19321/// &'static str>` or an added typed error variant in this crate)
19322/// keeps every caller's own error enum authoritative — the
19323/// diagnostic remediation for a missing-name-scalar in a programs-
19324/// yaml entry rightly names the caller's aggregator schema
19325/// (`spec.values.programs[].name` for the `HelmRelease` shape,
19326/// `programs[].name` for the bare values.yaml shape), not this
19327/// generic helper.
19328///
19329/// [helm-up]: ../../caixa_flux/fn.upsert_into_helmrelease_programs.html
19330/// [yaml-up]: ../../caixa_flux/fn.upsert_into_programs_yaml.html
19331///
19332/// # Errors
19333///
19334/// Returns `on_missing_name()` when `new_entry.get(name_key)` is
19335/// not a [`serde_yaml::Value::String`] — the closure surfaces the
19336/// caller's own typed error variant naming the offending schema
19337/// axis. On success returns `Ok(true)` for a newly-appended entry,
19338/// `Ok(false)` for an in-place replacement.
19339pub fn upsert_named_entry<E>(
19340 arr: &mut Vec<serde_yaml::Value>,
19341 new_entry: serde_yaml::Value,
19342 name_key: &'static str,
19343 on_missing_name: impl FnOnce() -> E,
19344) -> Result<bool, E> {
19345 let new_name = match new_entry.get(name_key).and_then(|n| n.as_str()) {
19346 Some(s) => s.to_string(),
19347 None => return Err(on_missing_name()),
19348 };
19349 for slot in arr.iter_mut() {
19350 if slot.get(name_key).and_then(|n| n.as_str()) == Some(&new_name) {
19351 *slot = new_entry;
19352 return Ok(false);
19353 }
19354 }
19355 arr.push(new_entry);
19356 Ok(true)
19357}
19358
19359/// Render the M2 typed-slot YAML overlay for a Caixa: the camelCase
19360/// `(key, value)` fragments every per-Servico renderer
19361/// ([`caixa-helm`]'s values block, [`caixa-flux`]'s programs.yaml
19362/// entry) merges into its target with `or_insert` semantics so explicit
19363/// `spec.*` fields from the ComputeUnit YAML take precedence over the
19364/// manifest-derived overlay.
19365///
19366/// Keys (alphabetically ordered, since the return type is
19367/// [`BTreeMap`]) match the ComputeUnit / pleme-computeunit values
19368/// schema:
19369///
19370/// * [`M2_KEY_BEHAVIOR`] — present iff `caixa.behavior` is `Some`
19371/// and `BehaviorSpec::is_empty` returns `false`.
19372/// * [`M2_KEY_LIMITS`] — present iff `caixa.limits` is `Some` and
19373/// `LimitsSpec::is_empty` returns `false`.
19374/// * [`M2_KEY_UPGRADE_FROM`] — present iff `caixa.upgrade_from` is
19375/// non-empty.
19376///
19377/// An entirely empty M2 surface returns an empty map; the renderer
19378/// merges zero fragments and emits no extra keys (the per-renderer
19379/// "empty M2 slots do not appear" tests pin this invariant —
19380/// `caixa_helm::tests::empty_m2_slots_do_not_appear` and
19381/// `caixa_flux::tests::empty_m2_slots_do_not_appear_in_programs_yaml_entry`).
19382///
19383/// # Errors
19384///
19385/// Returns [`RenderError::Yaml`] if `serde_yaml::to_value` fails for
19386/// any of the typed M2 slot values. The prior inline block silently
19387/// substituted [`serde_yaml::Value::Null`] in this case, which renders
19388/// as e.g. `limits: null` — indistinguishable from "the author omitted
19389/// the slot" once it leaves the typed surface.
19390pub fn servico_m2_overlay(
19391 caixa: &Caixa,
19392) -> Result<BTreeMap<&'static str, serde_yaml::Value>, RenderError> {
19393 let mut out = BTreeMap::new();
19394 if let Some(limits) = caixa.limits() {
19395 if !limits.is_empty() {
19396 let v = serde_yaml::to_value(limits).map_err(|source| RenderError::Yaml {
19397 slot: M2_KEY_LIMITS,
19398 source,
19399 })?;
19400 out.insert(M2_KEY_LIMITS, v);
19401 }
19402 }
19403 if let Some(behavior) = caixa.behavior() {
19404 if !behavior.is_empty() {
19405 let v = serde_yaml::to_value(behavior).map_err(|source| RenderError::Yaml {
19406 slot: M2_KEY_BEHAVIOR,
19407 source,
19408 })?;
19409 out.insert(M2_KEY_BEHAVIOR, v);
19410 }
19411 }
19412 if !caixa.upgrade_from().is_empty() {
19413 let v = serde_yaml::to_value(caixa.upgrade_from()).map_err(|source| RenderError::Yaml {
19414 slot: M2_KEY_UPGRADE_FROM,
19415 source,
19416 })?;
19417 out.insert(M2_KEY_UPGRADE_FROM, v);
19418 }
19419 Ok(out)
19420}
19421
19422/// Compose the canonical per-Servico value-block splice every per-Servico
19423/// renderer applies to the target values / entry mapping — the two-step
19424/// sequence [`caixa_helm::build_values_yaml`] and
19425/// [`caixa_flux::programs_yaml_entry`] both re-derived inline before this
19426/// lift:
19427///
19428/// 1. Splice every string-keyed entry from the `ComputeUnit` YAML's
19429/// `spec.*` sub-mapping (routed through [`string_keyed_entries`],
19430/// preserving the source Mapping's insertion order).
19431/// 2. Overlay the M2 typed slots (routed through
19432/// [`servico_m2_overlay`], `BTreeMap` key-ordered) at every M2 key
19433/// not already claimed by step 1 — the `or_insert` precedence rule
19434/// the two prior inline call sites shared, promoted here to a
19435/// filtered append so the returned `Vec` is drop-in for a target
19436/// mapping whose insertion order is load-bearing (caixa-flux's
19437/// `serde_yaml::Mapping` preserves it; caixa-helm's `BTreeMap`
19438/// re-sorts by key, so both consumer shapes stay byte-identical
19439/// to their prior inline blocks under this lift).
19440///
19441/// Returns a `Vec<(String, serde_yaml::Value)>` in insertion order —
19442/// spec.* entries first (original ordering preserved), then the M2 slots
19443/// that weren't claimed by spec.* (in [`servico_m2_overlay`]'s canonical
19444/// BTreeMap-key ordering: `behavior` → `limits` → `upgradeFrom`).
19445/// Callers extend their target mapping by iterating the `Vec` and
19446/// inserting each pair with their own map type's canonical insert.
19447///
19448/// Until this lift landed the two prior inline blocks each carried the
19449/// same three-shape composition: `for (k, v) in
19450/// caixa_core::string_keyed_entries(spec) { <insert>(k, v.clone()); }`
19451/// followed by `for (key, value) in caixa_core::servico_m2_overlay(caixa)?
19452/// { <entry-and-or-insert>(key, value); }`. A future change to the
19453/// per-Servico splice / overlay composition — the M4 typed per-edge
19454/// policy overlay slot addition (MESH-COMPOSITION §III.2 #3), a change
19455/// to the spec.* / M2 precedence rule (e.g. reversing to "M2 wins on
19456/// collision" once per-Aplicacao operator overrides land), a
19457/// canonicalization pass on the merged key set (e.g. rejecting empty
19458/// string keys, casing-normalization on DNS-1123 labels) — would have
19459/// to be threaded through both renderers in lockstep or one would
19460/// silently diverge from the other on which keys it emitted and in
19461/// what order. Peer with the lifted [`servico_m2_overlay`] on the
19462/// per-Servico M2-overlay axis (10bf310 / 0e84fb9 on the sibling
19463/// upsert-loop / test-side probe axes) — completes the
19464/// "one canonical splice / overlay composition per typed axis"
19465/// discipline the M2 overlay lift established, now on the composed
19466/// spec.*+M2 axis every per-Servico renderer entry-point navigates.
19467///
19468/// # Errors
19469///
19470/// Propagates [`RenderError::Yaml`] from [`servico_m2_overlay`] when
19471/// `serde_yaml::to_value` fails for any typed M2 slot value — the same
19472/// error surface [`servico_m2_overlay`]'s docstring names.
19473pub fn servico_spec_and_m2_overlay_entries(
19474 caixa: &Caixa,
19475 spec: &serde_yaml::Value,
19476) -> Result<Vec<(String, serde_yaml::Value)>, RenderError> {
19477 let mut seen: std::collections::HashSet<String> = std::collections::HashSet::new();
19478 let mut out: Vec<(String, serde_yaml::Value)> = Vec::new();
19479 for (k, v) in string_keyed_entries(spec) {
19480 seen.insert(k.to_string());
19481 out.push((k.to_string(), v.clone()));
19482 }
19483 for (key, value) in servico_m2_overlay(caixa)? {
19484 if !seen.contains(key) {
19485 out.push((key.to_string(), value));
19486 }
19487 }
19488 Ok(out)
19489}
19490
19491/// Bracket a typed `u32` axis with the "zero-floor + upper-cap" gate
19492/// pair every capped-`u32` `:politicas` / `:supervisor` / `:limits`
19493/// axis carries. Returns `on_zero()` when `value == 0`,
19494/// `on_cap_exceeded(value)` when `value > cap`, `Ok(())` otherwise.
19495///
19496/// The zero-floor arm strictly precedes the cap arm so a literal `0`
19497/// value surfaces the self-locating zero diagnostic (which every
19498/// per-axis error variant already documents an "omit the axis to
19499/// express no-bound" remediation for) rather than the misleading
19500/// `0 > cap` false-negative on the cap arm. Same ordering discipline
19501/// every existing per-axis inline `if value == 0 { … } if value > CAP
19502/// { … }` block already applies — this lift makes the ordering a
19503/// property of the helper, not a per-call-site convention six sites
19504/// re-derive.
19505///
19506/// Six identical-shape call sites collapse onto this helper:
19507///
19508/// * [`crate::AplicacaoSpec::validate_politicas`] on
19509/// `MeshPolicy::retries` (zero →
19510/// [`crate::AplicacaoError::PolicyRetriesZero`], cap →
19511/// [`crate::AplicacaoError::PolicyRetriesExceedsCap`],
19512/// cap = [`crate::POLICY_RETRIES_MAX`]),
19513/// `CircuitBreaker::max_failures` (zero →
19514/// [`crate::AplicacaoError::PolicyBreakerZeroFailures`], cap →
19515/// [`crate::AplicacaoError::PolicyBreakerMaxFailuresExceedsCap`],
19516/// cap = [`crate::POLICY_BREAKER_MAX_FAILURES_MAX`]), and
19517/// `RateLimit::rate` (zero →
19518/// [`crate::AplicacaoError::PolicyRateLimitZero`], cap →
19519/// [`crate::AplicacaoError::PolicyRateLimitExceedsCap`],
19520/// cap = [`crate::POLICY_RATE_LIMIT_MAX`]);
19521/// * [`crate::SupervisorSpec::validate`] on `max_restarts`
19522/// (zero → [`crate::SupervisorError::ZeroMaxRestarts`], cap →
19523/// [`crate::SupervisorError::MaxRestartsExceedsCap`],
19524/// cap = [`crate::SUPERVISOR_MAX_RESTARTS_MAX`]);
19525/// * [`crate::LimitsSpec::validate`] on `cpu`
19526/// (zero → [`crate::LimitsError::CpuZero`], cap →
19527/// [`crate::LimitsError::CpuExceedsCap`],
19528/// cap = [`crate::LIMITS_CPU_MILLICORES_MAX`]).
19529///
19530/// Peer to [`require_positive_bounded_u64`] on the `u64`-typed axes
19531/// ([`crate::LimitsSpec::fuel`]). Generic over the caller's error enum
19532/// so the same helper reaches every crate-level [`thiserror`] surface
19533/// — the six per-axis error variants remain the source of truth for
19534/// each axis's remediation prose; the helper only sequences the two
19535/// gate arms in canonical order and threads the value into the cap
19536/// arm's discriminator field.
19537///
19538/// # Errors
19539///
19540/// Returns `on_zero()` for `value == 0`; returns `on_cap_exceeded(value)`
19541/// for `value > cap`; returns `Ok(())` otherwise.
19542pub fn require_positive_bounded_u32<E>(
19543 value: u32,
19544 cap: u32,
19545 on_zero: impl FnOnce() -> E,
19546 on_cap_exceeded: impl FnOnce(u32) -> E,
19547) -> Result<(), E> {
19548 if value == 0 {
19549 return Err(on_zero());
19550 }
19551 if value > cap {
19552 return Err(on_cap_exceeded(value));
19553 }
19554 Ok(())
19555}
19556
19557/// Peer of [`require_positive_bounded_u32`] on the `u64`-typed axes.
19558/// Returns `on_zero()` when `value == 0`, `on_cap_exceeded(value)`
19559/// when `value > cap`, `Ok(())` otherwise. See
19560/// [`require_positive_bounded_u32`] for the ordering / lift rationale
19561/// (same "zero-floor arm strictly precedes cap arm so `0` surfaces
19562/// the self-locating diagnostic" discipline the peer helper documents).
19563///
19564/// The single existing call site is [`crate::LimitsSpec::validate`] on
19565/// `fuel` (zero → [`crate::LimitsError::FuelZero`], cap →
19566/// [`crate::LimitsError::FuelExceedsCap`], cap =
19567/// [`crate::LIMITS_FUEL_MAX`]). Lifted alongside its `u32` peer so
19568/// the two integer-typed axes on this discipline share one canonical
19569/// entry-point — a future `u64`-typed axis (a hypothetical
19570/// per-Aplicacao byte-budget cap, the M4 per-edge policy resolver's
19571/// byte-throughput axis) reaches for the same helper by construction.
19572///
19573/// # Errors
19574///
19575/// Returns `on_zero()` for `value == 0`; returns `on_cap_exceeded(value)`
19576/// for `value > cap`; returns `Ok(())` otherwise.
19577pub fn require_positive_bounded_u64<E>(
19578 value: u64,
19579 cap: u64,
19580 on_zero: impl FnOnce() -> E,
19581 on_cap_exceeded: impl FnOnce(u64) -> E,
19582) -> Result<(), E> {
19583 if value == 0 {
19584 return Err(on_zero());
19585 }
19586 if value > cap {
19587 return Err(on_cap_exceeded(value));
19588 }
19589 Ok(())
19590}
19591
19592/// Bracket a typed `u64` axis carrying a quantized value with the
19593/// "zero-floor + below-quantum floor + upper-cap + not-quantum-multiple"
19594/// four-arm gate every capped-and-quantized `u64` axis in the crate
19595/// carries. Returns `on_zero()` when `value == 0`,
19596/// `on_below_quantum(value)` when `value < quantum`,
19597/// `on_cap_exceeded(value)` when `value > cap`,
19598/// `on_not_quantum_multiple(value)` when `value % quantum != 0`,
19599/// `Ok(())` otherwise.
19600///
19601/// The four arms fire in canonical `zero → below-quantum → cap →
19602/// not-quantum-multiple` order, matching the discipline the pre-lift
19603/// inline block at [`crate::LimitsSpec::validate`]'s `:memory` axis
19604/// applied by hand across four sequential `if let Some(m) = self.memory()`
19605/// wrappers. Each arm strictly precedes the next: the zero-floor arm
19606/// precedes the below-quantum arm so `Some(0)` (a value the modulus arm
19607/// would silently accept because `0 % quantum == 0` and the below-quantum
19608/// arm would also flag because `0 < quantum` — two distinct diagnostics
19609/// for the same value) surfaces the self-locating zero diagnostic every
19610/// per-axis error variant already documents an "omit the axis to
19611/// express no-bound" remediation for; the below-quantum arm precedes
19612/// the cap arm so a sub-quantum value (which is *also* not a quantum
19613/// multiple by construction — the smallest positive quantum multiple
19614/// *is* `quantum`) surfaces the more actionable "raise to at least one
19615/// quantum" diagnostic first; the cap arm precedes the not-multiple
19616/// arm so a value that is both above-cap and sub-quantum-residue
19617/// surfaces the cap diagnostic first (the not-multiple remediation
19618/// would be misleading when the offending value already exceeds the
19619/// upper bracket — the canonical fix collapses both into "pin a
19620/// quantum-aligned value ≤ cap"), peer to the
19621/// [`require_positive_canonical_bounded_duration`] cap-precedes-not-
19622/// canonical ordering on the sibling typed-`Duration` axis.
19623///
19624/// One existing call site collapses onto this helper —
19625/// [`crate::LimitsSpec::validate`] on
19626/// [`crate::LimitsSpec::memory`] (zero →
19627/// [`crate::LimitsError::MemoryZero`], below-quantum →
19628/// [`crate::LimitsError::MemoryBelowWasm32Page`], cap →
19629/// [`crate::LimitsError::MemoryExceedsWasm32Cap`], not-multiple →
19630/// [`crate::LimitsError::MemoryNotPageMultiple`],
19631/// quantum = [`crate::LIMITS_MEMORY_WASM32_PAGE_BYTES`] (64 KiB),
19632/// cap = [`crate::LIMITS_MEMORY_WASM32_MAX_BYTES`] (4 GiB)) — the last
19633/// unlifted `:limits` axis on the four-axis `LimitsSpec::validate`
19634/// discipline. The three peer axes (`:fuel`, `:wall-clock`, `:cpu`)
19635/// each route through one substrate helper today
19636/// ([`require_positive_bounded_u64`],
19637/// [`require_positive_canonical_bounded_duration`],
19638/// [`require_positive_bounded_u32`]); after this lift `:memory` joins
19639/// them at the same altitude — every `LimitsSpec::validate` axis is
19640/// exactly one typed-helper dispatch, with the four-arm ordering
19641/// discipline promoted from per-site convention to structural contract
19642/// on the substrate primitive.
19643///
19644/// Peer to [`require_positive_bounded_u32`] /
19645/// [`require_positive_bounded_u64`] on the two-arm integer-typed
19646/// bracket axes and to [`require_positive_canonical_bounded_duration`]
19647/// on the three-arm typed-`Duration` bracket-and-quantize axis. Generic
19648/// over the caller's error enum so the same helper reaches every
19649/// crate-level [`thiserror`] surface — the four per-axis error variants
19650/// remain the source of truth for each axis's remediation prose; the
19651/// helper only sequences the four gate arms in canonical order and
19652/// threads the value into the below-quantum / cap / not-multiple arms'
19653/// discriminator fields.
19654///
19655/// PRIME DIRECTIVE promotion: the four-arm quantized-byte-cap cascade
19656/// is the natural u64 extension of the two-arm
19657/// [`require_positive_bounded_u64`] bracket the sibling `:fuel` axis
19658/// already routes through. Lifting it means a future quantized-byte-cap
19659/// axis reaching for the same discipline — a wasm64-target promotion
19660/// raising the wasm32 page and address-space bounds, a hypothetical
19661/// per-Aplicacao heap-max byte-cap, an operator-side page-aligned
19662/// byte-cap admitted by the M4 CR materializer's admission webhook —
19663/// lands as a thin four-closure wrapper rather than re-inlining the
19664/// same four-arm cascade with a fresh page-alignment convention.
19665///
19666/// # Errors
19667///
19668/// Returns `on_zero()` for `value == 0`; returns
19669/// `on_below_quantum(value)` for `value < quantum`; returns
19670/// `on_cap_exceeded(value)` for `value > cap`; returns
19671/// `on_not_quantum_multiple(value)` for `value % quantum != 0`;
19672/// returns `Ok(())` otherwise.
19673pub fn require_positive_quantum_multiple_bounded_u64<E>(
19674 value: u64,
19675 quantum: u64,
19676 cap: u64,
19677 on_zero: impl FnOnce() -> E,
19678 on_below_quantum: impl FnOnce(u64) -> E,
19679 on_cap_exceeded: impl FnOnce(u64) -> E,
19680 on_not_quantum_multiple: impl FnOnce(u64) -> E,
19681) -> Result<(), E> {
19682 if value == 0 {
19683 return Err(on_zero());
19684 }
19685 if value < quantum {
19686 return Err(on_below_quantum(value));
19687 }
19688 if value > cap {
19689 return Err(on_cap_exceeded(value));
19690 }
19691 if !value.is_multiple_of(quantum) {
19692 return Err(on_not_quantum_multiple(value));
19693 }
19694 Ok(())
19695}
19696
19697/// Bracket a typed `Duration` axis with the "zero-floor +
19698/// canonical-form + upper-cap" three-arm gate every typed-`Duration`
19699/// slot in the crate carries. Returns `on_zero()` when `value` is
19700/// `Duration::ZERO`, `on_not_canonical(value)` when `value` carries
19701/// sub-millisecond residue the shared
19702/// [`crate::supervisor::duration_codec`] cannot round-trip losslessly,
19703/// `on_cap_exceeded(value)` when `value > cap`, `Ok(())` otherwise.
19704///
19705/// The three arms fire in canonical `zero → not-canonical → cap` order,
19706/// matching the discipline every existing per-axis inline block already
19707/// applied by hand: the zero-floor arm precedes the canonical-form arm
19708/// so `Duration::ZERO` (whose `subsec_nanos() == 0` makes it accepted
19709/// by the canonical-form predicate) surfaces the self-locating zero
19710/// diagnostic — every per-axis zero variant already documents an
19711/// "omit the axis to express no-bound" remediation — rather than the
19712/// misleading no-op the canonical arm would return; the canonical-form
19713/// arm then precedes the cap arm so a `Duration` that is *both*
19714/// sub-millisecond and above-cap surfaces the more fundamental
19715/// round-trip-shape diagnostic first (the cap's `1ms..=<cap>`
19716/// remediation would be misleading when no integer-ms form of the
19717/// offending value exists). Same ordering discipline the peer
19718/// [`require_positive_bounded_u32`] applies on its two arms — this
19719/// lift makes the three-arm ordering a property of the helper, not a
19720/// per-call-site convention four sites re-derived by hand.
19721///
19722/// Four identical-shape call sites collapse onto this helper — one for
19723/// each typed-`Duration` slot in the crate:
19724///
19725/// * [`crate::AplicacaoSpec::validate`] on
19726/// [`crate::MeshPolicy::timeout`] (zero →
19727/// [`crate::AplicacaoError::PolicyTimeoutZero`], not-canonical →
19728/// [`crate::AplicacaoError::PolicyTimeoutNotCanonical`], cap →
19729/// [`crate::AplicacaoError::PolicyTimeoutExceedsCap`],
19730/// cap = [`crate::POLICY_TIMEOUT_MAX`]) and
19731/// [`crate::CircuitBreaker::window`] (zero →
19732/// [`crate::AplicacaoError::PolicyBreakerZeroWindow`],
19733/// not-canonical →
19734/// [`crate::AplicacaoError::PolicyBreakerWindowNotCanonical`],
19735/// cap → [`crate::AplicacaoError::PolicyBreakerWindowExceedsCap`],
19736/// cap = [`crate::POLICY_BREAKER_WINDOW_MAX`]);
19737/// * [`crate::LimitsSpec::validate`] on
19738/// [`crate::LimitsSpec::wall_clock`] (zero →
19739/// [`crate::LimitsError::WallClockZero`], not-canonical →
19740/// [`crate::LimitsError::WallClockNotCanonical`], cap →
19741/// [`crate::LimitsError::WallClockExceedsCap`],
19742/// cap = [`crate::LIMITS_WALL_CLOCK_MAX`]);
19743/// * [`crate::SupervisorSpec::validate`] on
19744/// [`crate::SupervisorSpec::restart_window`] (zero →
19745/// [`crate::SupervisorError::RestartWindowZero`], not-canonical →
19746/// [`crate::SupervisorError::RestartWindowNotCanonical`], cap →
19747/// [`crate::SupervisorError::RestartWindowExceedsCap`],
19748/// cap = [`crate::SUPERVISOR_RESTART_WINDOW_MAX`]).
19749///
19750/// Peer to [`require_positive_bounded_u32`] /
19751/// [`require_positive_bounded_u64`] on the integer-typed capped axes;
19752/// the four typed-`Duration` axes and the four typed-integer axes now
19753/// route through one helper each, so a future axis reaching for the
19754/// same discipline lands in exactly one place. Generic over the
19755/// caller's error enum so the same helper reaches every crate-level
19756/// [`thiserror`] surface — the ten per-axis error variants remain the
19757/// source of truth for each axis's remediation prose; the helper only
19758/// sequences the three gate arms in canonical order and threads the
19759/// value into the not-canonical / cap arms' discriminator fields.
19760///
19761/// # Errors
19762///
19763/// Returns `on_zero()` for `value.is_zero()`; returns
19764/// `on_not_canonical(value)` when `value` carries sub-millisecond
19765/// residue (`value.subsec_nanos() % 1_000_000 != 0`); returns
19766/// `on_cap_exceeded(value)` for `value > cap`; returns `Ok(())`
19767/// otherwise.
19768pub fn require_positive_canonical_bounded_duration<E>(
19769 value: std::time::Duration,
19770 cap: std::time::Duration,
19771 on_zero: impl FnOnce() -> E,
19772 on_not_canonical: impl FnOnce(std::time::Duration) -> E,
19773 on_cap_exceeded: impl FnOnce(std::time::Duration) -> E,
19774) -> Result<(), E> {
19775 if value.is_zero() {
19776 return Err(on_zero());
19777 }
19778 if !crate::supervisor::duration_codec::is_integer_millisecond_duration(value) {
19779 return Err(on_not_canonical(value));
19780 }
19781 if value > cap {
19782 return Err(on_cap_exceeded(value));
19783 }
19784 Ok(())
19785}
19786
19787/// Bracket a `:versao` requirement-string axis with the shared
19788/// "empty-first, then [`crate::parse_requirement`]" gate pair every
19789/// dep-shaped `:versao` slot carries. Returns `on_empty()` when
19790/// `versao.is_empty()`, `on_invalid(reason)` when
19791/// [`crate::parse_requirement`] rejects the non-empty input, `Ok(())`
19792/// otherwise.
19793///
19794/// The empty-first arm strictly precedes the parse arm so a literal
19795/// `""` value surfaces the self-locating empty diagnostic every
19796/// per-axis error variant already documents an "omit the axis to
19797/// express any-version" remediation for, rather than the misleading
19798/// parse-side no-op — [`crate::parse_requirement("")`][crate::parse_requirement]
19799/// hits `semver::VersionReq::parse("")` which returns
19800/// `Ok(VersionReq { comparators: [] })` (semantically identical to
19801/// [`semver::VersionReq::STAR`]), so without the empty-first arm an
19802/// authored blank `:versao "" ` would silently round-trip as an
19803/// implicit `"*"` — the same "silent widening" footgun the peer
19804/// [`require_positive_bounded_u32`] closes on its zero-floor arm.
19805///
19806/// The three existing call sites — [`crate::dep::Dep::validate`] on
19807/// [`crate::dep::Dep::versao`] (empty → [`crate::DepError::VersaoEmpty`],
19808/// invalid → [`crate::DepError::VersaoInvalid`]),
19809/// [`crate::AplicacaoSpec::validate_membros`] on
19810/// [`crate::aplicacao::Membro::versao`] (empty →
19811/// [`crate::AplicacaoError::MembroVersaoEmpty`], invalid →
19812/// [`crate::AplicacaoError::MembroVersaoInvalid`]), and
19813/// [`crate::SupervisorSpec::validate`] on
19814/// [`crate::supervisor::ChildSpec::versao`] (empty →
19815/// [`crate::SupervisorError::EmptyChildVersion`], invalid →
19816/// [`crate::SupervisorError::ChildVersaoInvalid`]) — each formerly
19817/// inlined this two-arm cascade verbatim. Lifting to one canonical
19818/// entry-point closes the drift footgun structurally: a future
19819/// widening of the accepted requirement-shape (a hypothetical
19820/// git-tag-prefix leniency, a per-axis strictness override, or the
19821/// M4 typed-resolver's `constraint:` axis on
19822/// [`ABSORPTION-ROADMAP.md`]'s per-resolver-step trajectory) reaches
19823/// every dep-shaped `:versao` consumer by one edit at this helper,
19824/// not a coordinated rewrite across three modules.
19825///
19826/// Peer of [`require_positive_bounded_u32`] /
19827/// [`require_positive_bounded_u64`] on the same closure-based
19828/// caller-error-variant discipline — the caller owns the enum
19829/// variant + its self-locating discriminator fields
19830/// (`nome`/`caixa`, `versao`), this helper only sequences the two
19831/// gate arms in canonical order and threads the parser's
19832/// `semver`-shaped reason into the invalid arm's `reason:` field.
19833///
19834/// # Errors
19835///
19836/// Returns `on_empty()` for `versao.is_empty()`; returns
19837/// `on_invalid(reason)` when [`crate::parse_requirement`] rejects
19838/// the non-empty input (the parser's `to_string()` output threaded
19839/// through as the invalid arm's `reason:`); returns `Ok(())`
19840/// otherwise.
19841pub fn require_valid_versao_requirement<E>(
19842 versao: &str,
19843 on_empty: impl FnOnce() -> E,
19844 on_invalid: impl FnOnce(String) -> E,
19845) -> Result<(), E> {
19846 if versao.is_empty() {
19847 return Err(on_empty());
19848 }
19849 if let Err(e) = crate::parse_requirement(versao) {
19850 return Err(on_invalid(e.to_string()));
19851 }
19852 Ok(())
19853}
19854
19855/// Bracket a K8s DNS-1123-label-shaped axis with the shared
19856/// "empty-first, then [`is_dns_1123_label`]" gate pair every Servico-
19857/// name reference slot carries. Returns `on_empty()` when
19858/// `value.is_empty()`, `on_invalid(reason)` when [`is_dns_1123_label`]
19859/// rejects the non-empty input, `Ok(())` otherwise.
19860///
19861/// The empty-first arm strictly precedes the shape arm so a literal
19862/// `""` value surfaces each per-axis error variant's narrower self-
19863/// locating `_Empty` diagnostic (`MembroCaixaEmpty`, `PlacementClusterEmpty`,
19864/// `EntradaParaEmpty`, `NomeEmpty`, `EmptyChildName`, `ModuleEmpty`, …)
19865/// rather than the shared predicate's generic "must not be empty" prose
19866/// — the same "misframed generic diagnostic" footgun the peer
19867/// [`require_valid_versao_requirement`] closes on its empty arm. The
19868/// invalid arm threads the predicate's parser-shaped reason verbatim
19869/// into the caller's `*Invalid { reason }` field so the author's
19870/// remediation prose (which specific violation — length / boundary /
19871/// character-class) flows through unchanged.
19872///
19873/// The eight existing call sites — [`crate::AplicacaoSpec`]'s five
19874/// name-shaped slots (`validate_membro_caixa` on `:membros :caixa`,
19875/// `validate_placement_cluster` on `:placement :clusters`,
19876/// `validate_placement_affinity` on `:placement :affinity`,
19877/// `validate_contrato_caixa` on `:contratos :de`/`:para`,
19878/// `validate_entrada_para` on `:entrada :para`),
19879/// [`crate::SupervisorSpec::validate`] on `:children :caixa`,
19880/// [`crate::manifest::Caixa::validate_nome`] on `:nome`, and
19881/// [`crate::upgrade::validate_module`] on `:upgrade-from :module` —
19882/// each formerly inlined this two-arm cascade verbatim. Lifting to one
19883/// canonical entry-point closes the drift footgun structurally: a
19884/// future widening of the accepted DNS-1123-label shape (a hypothetical
19885/// IDN-Punycode-accepting variant, a per-axis strictness override for
19886/// the M4 CR materializer's `spec.name` axes, or the future
19887/// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's admission
19888/// webhook floor) reaches every name-shaped consumer by one edit at
19889/// this helper, not a coordinated rewrite across three modules.
19890///
19891/// Peer of [`require_valid_versao_requirement`] on the same closure-
19892/// based caller-error-variant discipline — the caller owns the enum
19893/// variant + its self-locating discriminator fields (`caixa`, `cluster`,
19894/// `affinity`, `nome`, `slot`, `kind`, `module`, …), this helper only
19895/// sequences the two gate arms in canonical order and threads the
19896/// predicate's shape-shaped reason into the invalid arm's `reason:`
19897/// field.
19898///
19899/// # Errors
19900///
19901/// Returns `on_empty()` for `value.is_empty()`; returns
19902/// `on_invalid(reason)` when [`is_dns_1123_label`] rejects the
19903/// non-empty input (the predicate's parser-shaped reason threaded
19904/// through as the invalid arm's `reason:`); returns `Ok(())` otherwise.
19905pub fn require_valid_dns_1123_label<E>(
19906 value: &str,
19907 on_empty: impl FnOnce() -> E,
19908 on_invalid: impl FnOnce(String) -> E,
19909) -> Result<(), E> {
19910 if value.is_empty() {
19911 return Err(on_empty());
19912 }
19913 if let Err(reason) = is_dns_1123_label(value) {
19914 return Err(on_invalid(reason));
19915 }
19916 Ok(())
19917}
19918
19919/// Bracket a sandboxed-relative `.lisp`-terminating path axis with the
19920/// shared "empty → absolute → parent-escape → non-`.lisp`-extension"
19921/// four-arm gate every author-supplied M2 tatara-lisp source-path slot
19922/// on the caixa surface carries. Delegates to
19923/// [`is_sandboxed_relative_path`] for the three structural arms and to
19924/// [`is_lisp_extension`] for the extension arm; returns each arm's
19925/// caller-owned error variant via the four `FnOnce` closures.
19926///
19927/// The arm ordering (`Empty → Absolute → ParentEscape → NonLisp`) is
19928/// canonical across every existing per-axis site — a path that is
19929/// *both* sandbox-escaping and non-`.lisp` surfaces the more
19930/// fundamental sandbox-shape diagnostic first (the `.lisp` remediation
19931/// would be misleading when the offending path can never resolve under
19932/// the caixa root anyway; the canonical fix collapses both into "pin a
19933/// relative `.lisp` path under the caixa root"). Same
19934/// smallest-scope-arm-fires-last posture the peer
19935/// [`require_positive_bounded_u32`] /
19936/// [`require_positive_canonical_bounded_duration`] chains follow on the
19937/// integer / duration axes, and the same posture every per-axis inline
19938/// pre-lift block already applied by hand
19939/// ([`crate::behavior::BehaviorError`]'s `EmptyPath` → `AbsolutePath`
19940/// → `ParentEscape` → `NonLispExtension` chain,
19941/// [`crate::upgrade::UpgradeError`]'s `EmptyScript` → `AbsoluteScript`
19942/// → `ParentEscapeScript` → `NonLispExtensionScript` chain).
19943///
19944/// Two identical-shape call sites collapse onto this helper — one for
19945/// each M2 typed path-slot the wasm-engine reads through
19946/// `tatara_lisp::read`:
19947///
19948/// * [`crate::behavior::BehaviorSpec::validate`] on
19949/// `:behavior :on-*` callback paths — every arm carries the slot
19950/// name verbatim through the closure's caller-side capture (empty
19951/// → [`crate::behavior::BehaviorError::EmptyPath`], absolute →
19952/// [`crate::behavior::BehaviorError::AbsolutePath`], parent-escape
19953/// → [`crate::behavior::BehaviorError::ParentEscape`], non-`.lisp`
19954/// → [`crate::behavior::BehaviorError::NonLispExtension`]);
19955/// * [`crate::upgrade::UpgradeInstruction::validate`]'s `StateChange`
19956/// arm on `:upgrade-from :state-change :script` (empty →
19957/// [`crate::upgrade::UpgradeError::EmptyScript`], absolute →
19958/// [`crate::upgrade::UpgradeError::AbsoluteScript`], parent-escape
19959/// → [`crate::upgrade::UpgradeError::ParentEscapeScript`],
19960/// non-`.lisp` →
19961/// [`crate::upgrade::UpgradeError::NonLispExtensionScript`]).
19962///
19963/// Peer of the sibling `require_positive_bounded_u32` /
19964/// `require_positive_bounded_u64` /
19965/// `require_positive_canonical_bounded_duration` /
19966/// `require_valid_versao_requirement` / `require_valid_dns_1123_label`
19967/// helpers on the same closure-based caller-error-variant discipline —
19968/// the caller owns the enum variant + its self-locating discriminator
19969/// fields (`slot`, `path`, `script`), this helper only sequences the
19970/// four gate arms in canonical order and invokes the caller's closure
19971/// on the offending arm.
19972///
19973/// PRIME DIRECTIVE promotion: the two-consumer duplication budget
19974/// (THEORY.md §I.3.5: "every recurring shape becomes a generator
19975/// before it becomes a pattern; every pattern becomes a library before
19976/// it becomes duplicated code. The duplication budget is zero.")
19977/// promotes the four-step cascade to a typed substrate-side helper on
19978/// the same trajectory the [`is_sandboxed_relative_path`] /
19979/// [`is_lisp_extension`] primitives already follow. A future third
19980/// consumer — the `:bibliotecas` per-entry tatara-lisp source-file
19981/// axis, the `:exe` `:kind Binario` entry-point axis, the M2.5
19982/// wasm-engine pre-warm hook axis, the future `mesh.pleme.io/v1alpha1/Caixa`
19983/// CR materializer's per-path validator — lands as a thin
19984/// four-closure wrapper rather than re-inlining the same four-arm
19985/// cascade.
19986///
19987/// # Errors
19988///
19989/// Returns `on_empty()` when `path` is empty; returns `on_absolute()`
19990/// when `path` is absolute; returns `on_parent_escape()` when `path`
19991/// carries a [`std::path::Component::ParentDir`] component anywhere;
19992/// returns `on_non_lisp()` when `path`'s terminating extension is not
19993/// exactly [`LISP_SOURCE_EXTENSION`]; returns `Ok(())` otherwise.
19994pub fn require_sandboxed_lisp_path<E>(
19995 path: &Path,
19996 on_empty: impl FnOnce() -> E,
19997 on_absolute: impl FnOnce() -> E,
19998 on_parent_escape: impl FnOnce() -> E,
19999 on_non_lisp: impl FnOnce() -> E,
20000) -> Result<(), E> {
20001 match is_sandboxed_relative_path(path) {
20002 Ok(()) => {}
20003 Err(PathShapeViolation::Empty) => return Err(on_empty()),
20004 Err(PathShapeViolation::Absolute) => return Err(on_absolute()),
20005 Err(PathShapeViolation::ParentEscape) => return Err(on_parent_escape()),
20006 }
20007 if !is_lisp_extension(path) {
20008 return Err(on_non_lisp());
20009 }
20010 Ok(())
20011}
20012
20013/// Bracket a per-list uniqueness gate with the shared "insert into
20014/// `seen`; caller-shaped `Err` on the second occurrence" gate every
20015/// declaration-order-preserving `Vec`-authored slot in caixa-core
20016/// carries. Delegates to [`std::collections::HashSet::insert`] verbatim
20017/// (which returns `true` on first insertion, `false` on repeat), then
20018/// invokes the caller's `on_duplicate` closure only on the duplicate
20019/// arm — keeping the hot path (the unique case) allocation-free.
20020///
20021/// The ten existing call sites — [`crate::AplicacaoSpec::validate`]'s
20022/// four per-list uniqueness gates (`:membros :caixa` →
20023/// [`crate::AplicacaoError::MembroDuplicate`], `:placement :clusters` →
20024/// [`crate::AplicacaoError::PlacementClusterDuplicate`],
20025/// `:entrada :paths` → [`crate::AplicacaoError::EntradaPathDuplicate`],
20026/// `:contratos` on the six-tuple typed-edge identity key →
20027/// [`crate::AplicacaoError::ContratoDuplicate`]),
20028/// [`crate::SupervisorSpec::validate`] on `:children :caixa`
20029/// ([`crate::SupervisorError::DuplicateChildCaixa`]),
20030/// [`crate::manifest::Caixa`]'s four per-list uniqueness gates
20031/// ([`crate::manifest::Caixa::validate_deps`] on `:deps` and `:deps-dev`
20032/// → [`crate::DepError::DuplicateNome`],
20033/// [`crate::manifest::Caixa::validate_code_paths`] on
20034/// `:bibliotecas`/`:exe`/`:servicos` →
20035/// [`crate::ManifestError::CodePathDuplicate`],
20036/// [`crate::manifest::Caixa::validate_etiquetas`] on `:etiquetas` →
20037/// [`crate::ManifestError::EtiquetaDuplicate`],
20038/// [`crate::manifest::Caixa::validate_autores`] on `:autores` →
20039/// [`crate::ManifestError::AutorDuplicate`]), and
20040/// [`crate::dep::Dep`]'s [`crate::DepError::CaracteristicaDuplicate`]
20041/// gate on `:caracteristicas` — each formerly inlined the same three-
20042/// line
20043/// ```ignore
20044/// if !seen.insert(key) {
20045/// return Err(<Variant> { … });
20046/// }
20047/// ```
20048/// shape by hand, differing only in the seen-set key type and the
20049/// caller's [`thiserror`] variant. Lifting to one canonical entry-point
20050/// closes the drift footgun structurally: a future tightening of the
20051/// per-list uniqueness discipline (a declaration-order pin on the
20052/// reported entry index, an instrumentation hook for the operator's
20053/// audit trail, the M4 CR materializer's admission-webhook per-list
20054/// invariant) reaches every consumer by one edit at this helper, not
20055/// a coordinated rewrite across every per-list gate in the crate. The
20056/// per-axis error variants remain the source of truth for each axis's
20057/// remediation prose — this helper only sequences the insert-and-check
20058/// pair.
20059///
20060/// Same set-not-multiset discipline every peer `Duplicate*` variant
20061/// documents. The typed key `K` is generic so both `&str`-shaped
20062/// callers (nine sites) and the tuple-shaped
20063/// [`crate::AplicacaoError::ContratoDuplicate`] typed-edge identity
20064/// carrier route through one helper; the caller owns the enum variant
20065/// + its self-locating discriminator fields, this helper only sequences
20066/// the insert-and-check pair in canonical `insert → on_duplicate` order.
20067/// Sibling to the peer `require_positive_bounded_*` /
20068/// `require_positive_canonical_bounded_duration` /
20069/// `require_valid_versao_requirement` / `require_valid_dns_1123_label`
20070/// helpers on the same closure-based caller-error-variant discipline.
20071///
20072/// # Errors
20073///
20074/// Returns `on_duplicate()` when `key` was already in `seen` (the
20075/// [`std::collections::HashSet::insert`] call returns `false`); returns
20076/// `Ok(())` otherwise.
20077pub fn insert_first_seen<K, E, S>(
20078 seen: &mut std::collections::HashSet<K, S>,
20079 key: K,
20080 on_duplicate: impl FnOnce() -> E,
20081) -> Result<(), E>
20082where
20083 K: std::hash::Hash + Eq,
20084 S: std::hash::BuildHasher,
20085{
20086 if seen.insert(key) {
20087 Ok(())
20088 } else {
20089 Err(on_duplicate())
20090 }
20091}
20092
20093/// Test-side pin that asserts a renderer-crate `pub use caixa_core::X;`
20094/// re-export shares both the byte value *and* the `&'static str`
20095/// allocation of its canonical `caixa_core::X` declaration — the
20096/// stronger predicate than a plain `assert_eq!` byte-equality check.
20097///
20098/// The canonical drift footgun this closes: a renderer crate silently
20099/// carries a sibling `pub const X: &str = "…";` (or a copy-pasted
20100/// `pub const X: &str = caixa_core::X;` shape whose right-hand side
20101/// materializes a fresh promoted-static allocation with the same
20102/// bytes) instead of `pub use caixa_core::X;`. A byte-only `assert_eq!`
20103/// on the value would pass — the strings are equal — but the two
20104/// declarations point at two different `&'static` allocations, so a
20105/// future canonical-side rebrand (`caixa_core::X` migrates from
20106/// `"foo"` to `"foo-v2"`) silently drifts the two apart, with the
20107/// apply-time symptom (the cluster-side CRD schema drops the malformed
20108/// axis, the operator's dispatch loop misses the renamed key, the
20109/// Cilium data plane silently reroutes past the renamed L4/L7 rule)
20110/// far from the drift commit's source. Byte-equality misses this
20111/// class of drift; static-data identity via [`std::ptr::eq`] catches
20112/// it structurally.
20113///
20114/// Lifted from the seventy-five per-`_re_export_points_at_caixa_core_
20115/// canonical` test bodies formerly inlined verbatim across
20116/// [`caixa-mesh`][mesh] (49 tests), [`caixa-flux`][flux] (21 tests),
20117/// and [`caixa-helm`][helm] (5 tests) — each formerly carried the same
20118/// two-arm `assert_eq!(<LOCAL>, caixa_core::<LOCAL>);` + `assert!(std
20119/// ::ptr::eq(<LOCAL>.as_ptr(), caixa_core::<LOCAL>.as_ptr()), "…must
20120/// be a re-export of caixa_core::…, not a sibling `pub const`…");`
20121/// pair by hand, differing only in the local `<LOCAL>` identifier the
20122/// diagnostic names. The lifted helper puts the canonical two-arm
20123/// gate in exactly one place so the next per-renderer re-export pin
20124/// (the future [`caixa-otel`] telemetry-pipeline renderer's per-CR
20125/// axis re-exports, the M4 [`mesh.pleme.io/v1alpha1/Aplicacao`] CR
20126/// materializer's per-spec-axis re-exports, the future per-Supervisor
20127/// reconciler's per-`:children` axis re-exports) lands on this
20128/// helper by construction rather than by copying the boilerplate.
20129///
20130/// Same trajectory as the sibling [`require_kind`] /
20131/// [`require_single_servico`] cross-renderer-shared-gate lifts on the
20132/// production-side axis; this closes the peer test-side re-export-
20133/// identity-gate axis.
20134///
20135/// # Panics
20136///
20137/// Panics via [`assert_eq!`] when the two byte-strings differ; panics
20138/// via [`assert!`] on the [`std::ptr::eq`] arm when the two share
20139/// bytes but point at different `&'static str` allocations. The
20140/// `name` argument names the local re-export for the failure message
20141/// so the diagnostic reads `KUBE_KEY_SPEC must be a re-export of
20142/// caixa_core::KUBE_KEY_SPEC, …` — pointing at the offending
20143/// re-export site, not just at the assertion.
20144///
20145/// [mesh]: https://docs.rs/caixa-mesh
20146/// [flux]: https://docs.rs/caixa-flux
20147/// [helm]: https://docs.rs/caixa-helm
20148pub fn assert_str_reexport_identity(name: &str, local: &'static str, canonical: &'static str) {
20149 assert_eq!(
20150 local, canonical,
20151 "{name} must byte-equal caixa_core::{name}"
20152 );
20153 assert!(
20154 std::ptr::eq(local.as_ptr(), canonical.as_ptr()),
20155 "{name} must be a re-export of caixa_core::{name}, \
20156 not a sibling `pub const` that happens to carry the same string \
20157 — drift between the two is the canonical footgun this lift closes"
20158 );
20159}
20160
20161/// Extension methods on [`serde_yaml::Mapping`] that lift the per-key
20162/// scalar-promotion boilerplate every K8s-artifact-emitter across
20163/// `caixa-mesh`, `caixa-flux`, `caixa-helm`, and `caixa-core::render`
20164/// carries: the canonical `mapping.insert(Value::String(key.into()),
20165/// value)` three-liner the schema-key axis of every emitted YAML
20166/// document tunnels a `&'static str` key axis-name through.
20167///
20168/// Five methods form the primitive quintuple — one per non-Null
20169/// primitive [`serde_yaml::Value`] variant the K8s-artifact-emit
20170/// surface actually reaches for as a leaf payload:
20171///
20172/// * [`Self::insert_str_key`] — insert with a `&str` key and any
20173/// fully-built [`serde_yaml::Value`]. The building block every
20174/// other renderer helper (`yaml_string_mapping`, `label_selector`,
20175/// `kube_resource_skeleton`, `single_field_overlay`) composes on
20176/// top of.
20177/// * [`Self::insert_string`] — insert with a `&str` key and an
20178/// `Into<String>` value that gets auto-promoted to
20179/// [`serde_yaml::Value::String`]. The string-scalar-valued-field
20180/// shape every schema-typed `apiVersion` / `kind` /
20181/// `metadata.namespace` / `port.protocol` / `hostname` /
20182/// `path.value` axis emission uses — collapses the two-step
20183/// `insert_str_key(K, Value::String(V.into()))` boilerplate onto
20184/// one direct call.
20185/// * [`Self::insert_number`] — insert with a `&str` key and an
20186/// `Into<serde_yaml::Number>` value that gets auto-promoted to
20187/// [`serde_yaml::Value::Number`]. The integer-scalar-valued-field
20188/// shape every schema-typed `port` / `targetPort` / `attempts` /
20189/// `maxFailures` / `hostPort` axis emission uses — collapses the
20190/// two-step `insert_str_key(K, Value::Number(N.into()))`
20191/// boilerplate onto one direct call.
20192/// * [`Self::insert_mapping`] — insert with a `&str` key and a
20193/// [`serde_yaml::Mapping`] value that gets auto-promoted to
20194/// [`serde_yaml::Value::Mapping`]. The nested-Mapping-valued-field
20195/// shape every schema-typed `metadata` / `spec` / `spec.rules[].path`
20196/// / `toPorts[].rules` sub-block emission uses — collapses the
20197/// two-step `insert_str_key(K, Value::Mapping(m))` boilerplate
20198/// onto one direct call.
20199/// * [`Self::insert_sequence`] — insert with a `&str` key and a
20200/// `Vec<serde_yaml::Value>` value that gets auto-promoted to
20201/// [`serde_yaml::Value::Sequence`]. The list-shape-valued-field
20202/// shape every schema-typed `spec.ingress[].fromEndpoints` /
20203/// `spec.ingress[].toPorts` / `spec.hostnames` / `spec.rules` list
20204/// emission uses — collapses the two-step
20205/// `insert_str_key(K, Value::Sequence(v))` boilerplate onto one
20206/// direct call.
20207///
20208/// A sibling method — [`Self::entry_str_key`] — closes the entry-API
20209/// twin of [`Self::insert_str_key`] on the same `&str → Value::String`
20210/// key-promotion axis: the [`serde_yaml::Mapping::entry`] method's
20211/// `Value` parameter demands the same `Value::String(<K>.into())`
20212/// wrapping every fresh-emit site's `insert_str_key` call closes, but
20213/// on the idempotent-upsert axis (where callers compose
20214/// `.or_insert(...)` / `.or_insert_with(...)` / `.and_modify(...)` /
20215/// `.or_default()` on the returned entry handle) rather than the
20216/// fresh-emit axis. Same key-promotion contract, different downstream
20217/// API surface — so a future rebrand of the promotion (e.g. to
20218/// [`serde_yaml::Value::Tagged`] under a K8s Server-Side-Apply typed-
20219/// field-ownership axis) reaches both fresh-emit and upsert sites
20220/// through one lift.
20221///
20222/// See each method's docstring for its compounding rationale.
20223pub trait MappingExt {
20224 /// Insert `(key, value)` into `self` with `key` promoted to a
20225 /// [`serde_yaml::Value::String`]. Returns the prior value at that
20226 /// key, mirroring [`serde_yaml::Mapping::insert`].
20227 ///
20228 /// The canonical shape ~48 call sites across the caixa-side
20229 /// renderer surface (`caixa-mesh` per-`CiliumNetworkPolicy` /
20230 /// `Gateway` / `HTTPRoute` construction, `caixa-flux` per-
20231 /// `GitRepository` / `HelmRelease` / `Kustomization` construction,
20232 /// `caixa-helm` per-`Chart.yaml` / `values.yaml` construction,
20233 /// `caixa-core::render` per-skeleton construction) previously
20234 /// carried inline as the three-line block
20235 /// `mapping.insert(serde_yaml::Value::String(<KEY>.into()),
20236 /// <VALUE>)` — three per-call boilerplate axes (`serde_yaml::` path
20237 /// re-quote, `Value::String(_)` promotion, `.into()` `&str → String`
20238 /// coercion) around a two-token semantic payload (`<KEY>`, `<VALUE>`).
20239 ///
20240 /// Lifting collapses the boilerplate into one method call the
20241 /// caller reads as intent (`mapping.insert_str_key(<KEY>, <VALUE>)`
20242 /// — "insert this schema key with this rendered value") rather
20243 /// than five hand-spelled positional artifacts. The next renderer
20244 /// to land — the per-`:politicas` `CiliumClusterwideEnvoyConfig`
20245 /// emitter (MESH-COMPOSITION §III.2 #3), the `app-operator`'s
20246 /// typed `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (§III.2
20247 /// #5), the M4 cross-cluster fan-out's per-cluster `Service` /
20248 /// `HTTPRoute backendRefs` emission, the future `caixa-otel`
20249 /// OpenTelemetry-Collector pipeline emitter — gets the canonical
20250 /// key-scalar-promotion for free with one method call, instead of
20251 /// re-inlining the three-line block.
20252 ///
20253 /// Peer to the sibling render-side helpers on the
20254 /// [`serde_yaml::Value`]-construction surface:
20255 /// [`yaml_string_mapping`] (string→string mapping), [`label_selector`]
20256 /// (K8s `LabelSelector` shape), [`kube_resource_skeleton`] (K8s
20257 /// `apiVersion`+`kind`+`metadata` skeleton), [`single_field_overlay`]
20258 /// (`Option<T>` → single-key overlay). Each closes a distinct axis
20259 /// of the K8s-artifact-emit surface's "same shape, written N times"
20260 /// duplication; this one closes the per-key insert primitive the
20261 /// other four all compose on top of.
20262 fn insert_str_key(&mut self, key: &str, value: serde_yaml::Value) -> Option<serde_yaml::Value>;
20263
20264 /// Insert `(key, Value::String(value.into()))` into `self` — the
20265 /// string-scalar-valued-field emission shape that combines
20266 /// [`Self::insert_str_key`]'s `&str → Value::String` key promotion
20267 /// with an automatic `Value::String` promotion of an `Into<String>`
20268 /// value. Returns the prior value at that key, mirroring
20269 /// [`serde_yaml::Mapping::insert`].
20270 ///
20271 /// The canonical shape ~17 production call sites across the caixa-
20272 /// side renderer surface previously carried inline as the three-
20273 /// line block `mapping.insert_str_key(<KEY>,
20274 /// serde_yaml::Value::String(<VALUE>.into() | .clone() |
20275 /// .to_string()))` — the two-token semantic payload (`<KEY>`,
20276 /// `<VALUE>`) buried under three boilerplate axes (`serde_yaml::`
20277 /// path re-quote, `Value::String(_)` promotion, the
20278 /// `.into() | .clone() | .to_string()` `→ String` coercion).
20279 ///
20280 /// Sites lifted:
20281 ///
20282 /// * caixa-mesh's `programs_for_aplicacao` per-`:membros` entry
20283 /// (`FLEET_PROGRAMS_KEY_NAME` / `FLEET_PROGRAMS_KEY_VERSAO` /
20284 /// `FLEET_PROGRAMS_KEY_APLICACAO`);
20285 /// * caixa-mesh's `cilium_network_policies` per-`toPorts[]` port
20286 /// entry (`KUBE_KEY_PORT` / `KUBE_KEY_PROTOCOL`) and per-HTTP-
20287 /// rule `CILIUM_KEY_PATH` L7 predicate;
20288 /// * caixa-mesh's `gateway_routes` per-`Gateway` listener block
20289 /// (`GATEWAY_API_KEY_NAME` /
20290 /// [`crate::GATEWAY_API_KEY_HOSTNAME`] / `GATEWAY_API_KEY_PROTOCOL`)
20291 /// and `spec.gatewayClassName`;
20292 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute` `parentRefs[]`
20293 /// name, per-rule `matches[].path.{type,value}` prefix-match, and
20294 /// per-rule `backendRefs[].name` backend-target;
20295 /// * caixa-flux's `programs_yaml_entry` per-entry `name` /
20296 /// `namespace` axes;
20297 /// * caixa-core `kube_resource_skeleton`'s `apiVersion` / `kind`
20298 /// scalar heads (the two production emit sites the prior
20299 /// `Value::String(_.to_string())` inline shape sat at).
20300 ///
20301 /// Lifting collapses the boilerplate into one method call the
20302 /// caller reads as intent (`mapping.insert_string(<KEY>, <VALUE>)`
20303 /// — "insert a string-scalar-typed field named `KEY` with rendered
20304 /// value `VALUE`") rather than four hand-spelled positional
20305 /// artifacts. The next renderer to land — the per-`:politicas`
20306 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy string-
20307 /// scalar axes are `name` / `namespace` / `defaultAction`), the
20308 /// `app-operator`'s typed `mesh.pleme.io/v1alpha1/Aplicacao` CR
20309 /// materializer (per-`spec.selectors[]` `name` / per-`spec.gates[]`
20310 /// string-typed axes), the M4 cross-cluster fan-out's per-cluster
20311 /// `Service.spec.ports[].name` / `HTTPRoute.spec.rules[].filters[].
20312 /// requestHeaderModifier.set[].name` string-scalar emission, the
20313 /// future `caixa-otel` OpenTelemetry-Collector `pipelines.traces.
20314 /// receivers[].endpoint` string-scalar emission — gets the canonical
20315 /// string-scalar-valued-field shape for free with one method call,
20316 /// instead of re-inlining the three-token
20317 /// `Value::String(_.into() | .clone() | .to_string())` block.
20318 ///
20319 /// Peer to [`Self::insert_str_key`] on the sibling any-Value axis —
20320 /// the two together form the "one method call per emission axis"
20321 /// primitive pair the K8s-artifact-emit surface's "same shape,
20322 /// written N times" duplication (THEORY.md §I.3.5) collapses onto.
20323 fn insert_string<V: Into<String>>(&mut self, key: &str, value: V) -> Option<serde_yaml::Value>;
20324
20325 /// Insert `(key, Value::Number(value.into()))` into `self` — the
20326 /// integer-scalar-valued-field emission shape that combines
20327 /// [`Self::insert_str_key`]'s `&str → Value::String` key promotion
20328 /// with an automatic [`serde_yaml::Value::Number`] promotion of an
20329 /// `Into<serde_yaml::Number>` value. Returns the prior value at that
20330 /// key, mirroring [`serde_yaml::Mapping::insert`].
20331 ///
20332 /// The canonical shape 2 production call sites across `caixa-mesh`
20333 /// previously carried inline as the three-token block
20334 /// `mapping.insert_str_key(<KEY>, serde_yaml::Value::Number(<N>.into()))`
20335 /// — the two-token semantic payload (`<KEY>`, `<N>`) buried under
20336 /// three boilerplate axes (`serde_yaml::` path re-quote,
20337 /// `Value::Number(_)` promotion, the `<N>.into()` typed-integer →
20338 /// [`serde_yaml::Number`] coercion) around a numeric constant or
20339 /// typed field the caller already carries as `u16` / `u32` / `u64`.
20340 ///
20341 /// Sites lifted:
20342 ///
20343 /// * caixa-mesh's `gateway_routes` per-`Gateway` `spec.listeners[].port`
20344 /// external HTTP listener port (`KUBE_KEY_PORT` around the lifted
20345 /// [`crate::GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`] `u16` const,
20346 /// cd60fde);
20347 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute.spec.rules[].backendRefs[].port`
20348 /// backend-target Servico port (`KUBE_KEY_PORT` around the
20349 /// [`crate::AplicacaoSpec`]-side `entrada.port` `u16` field the
20350 /// `:entrada :port` typed slot flows through).
20351 ///
20352 /// Lifting collapses the boilerplate into one method call the
20353 /// caller reads as intent (`mapping.insert_number(<KEY>, <N>)` —
20354 /// "insert a numeric-scalar-typed field named `KEY` with the typed
20355 /// integer `N`") rather than three hand-spelled positional artifacts.
20356 /// The next renderer to land — the per-`:politicas`
20357 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
20358 /// integer-scalar axes are the Envoy circuit-breaker
20359 /// `maxRequests` / `maxPendingRequests` / `maxConnections` count
20360 /// fields and the Cilium ratelimit `requestPerUnit` field,
20361 /// MESH-COMPOSITION §III.2 #3), the `app-operator`'s typed
20362 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (per-`spec.
20363 /// selectors[]` integer-scored `weight` fields, §III.2 #5), the
20364 /// M4 cross-cluster fan-out's per-cluster
20365 /// `Service.spec.ports[].{port, targetPort, nodePort}` /
20366 /// `HTTPRoute.spec.rules[].backendRefs[].{port, weight}`
20367 /// integer-scalar emission, the future `caixa-otel`
20368 /// OpenTelemetry-Collector `service.pipelines.traces.receivers[].
20369 /// grpc.max_recv_msg_size_mib` integer-scalar emission — gets the
20370 /// canonical integer-scalar-valued-field shape for free with one
20371 /// method call, instead of re-inlining the three-token
20372 /// `Value::Number(_.into())` block.
20373 ///
20374 /// The `Into<serde_yaml::Number>` bound accepts every numeric
20375 /// primitive [`serde_yaml::Number`] declares `From` for
20376 /// (`i8`..=`i64`, `u8`..=`u64`, `f32`, `f64`) — the same coverage
20377 /// the two production sites reach through with their `u16` port
20378 /// fields and the same coverage every future numeric-scalar
20379 /// emission (the K8s `Service.spec.ports[].targetPort` `IntOrString`
20380 /// integer arm, the `HTTPRoute.spec.rules[].backendRefs[].weight`
20381 /// `int32` axis, the Envoy `maxRequests` `uint32` axis) reaches
20382 /// through with matching typed integer fields.
20383 ///
20384 /// Peer to [`Self::insert_string`] on the sibling string-scalar axis
20385 /// and to [`Self::insert_mapping`] / [`Self::insert_sequence`] on
20386 /// the sibling nested-Mapping / list-shape axes — the five together
20387 /// with [`Self::insert_str_key`] form the "one method call per
20388 /// emission axis" primitive quintuple the K8s-artifact-emit
20389 /// surface's "same shape, written N times" duplication (THEORY.md
20390 /// §I.3.5) collapses onto: `insert_str_key` for any-Value inserts,
20391 /// `insert_string` for the string-scalar-valued-field shape,
20392 /// `insert_number` for the integer-scalar-valued-field shape,
20393 /// `insert_mapping` for the nested-Mapping-valued-field shape,
20394 /// `insert_sequence` for the list-shape-valued-field shape.
20395 fn insert_number<N: Into<serde_yaml::Number>>(
20396 &mut self,
20397 key: &str,
20398 value: N,
20399 ) -> Option<serde_yaml::Value>;
20400
20401 /// Insert `(key, Value::Mapping(value))` into `self` — the
20402 /// nested-Mapping-valued-field emission shape that combines
20403 /// [`Self::insert_str_key`]'s `&str → Value::String` key promotion
20404 /// with an automatic [`serde_yaml::Value::Mapping`] promotion of a
20405 /// [`serde_yaml::Mapping`] value. Returns the prior value at that
20406 /// key, mirroring [`serde_yaml::Mapping::insert`].
20407 ///
20408 /// The canonical shape ~6 production call sites across the caixa-
20409 /// side renderer surface previously carried inline as the three-
20410 /// token block `mapping.insert_str_key(<KEY>,
20411 /// serde_yaml::Value::Mapping(<INNER>))` — a two-token semantic
20412 /// payload (`<KEY>`, `<INNER>`) buried under a two-axis boilerplate
20413 /// (`serde_yaml::` path re-quote, `Value::Mapping(_)` promotion)
20414 /// around a `Mapping` variable the caller already built.
20415 ///
20416 /// Sites lifted:
20417 ///
20418 /// * caixa-mesh's `cilium_network_policies` per-`toPorts[]`
20419 /// `rules:` L7-introspection sub-block (`KUBE_KEY_RULES` around
20420 /// the built `rules` Mapping);
20421 /// * caixa-mesh's `cilium_network_policies` per-`CiliumNetworkPolicy`
20422 /// `spec:` block (`KUBE_KEY_SPEC` around the built `policy_spec`
20423 /// Mapping);
20424 /// * caixa-mesh's `gateway_routes` per-`Gateway` `spec:` block
20425 /// (`KUBE_KEY_SPEC` around the built `g_spec` Mapping);
20426 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute.spec.rules[]`
20427 /// `matches[].path:` sub-block (`GATEWAY_API_KEY_PATH` around the
20428 /// built `path_match` Mapping);
20429 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute` `spec:` block
20430 /// (`KUBE_KEY_SPEC` around the built `r_spec` Mapping);
20431 /// * caixa-core's `kube_resource_skeleton` per-CR
20432 /// `metadata:` sub-block (`KUBE_KEY_METADATA` around the built
20433 /// `metadata_map` Mapping).
20434 ///
20435 /// Lifting collapses the boilerplate into one method call the
20436 /// caller reads as intent (`mapping.insert_mapping(<KEY>, <INNER>)`
20437 /// — "insert a nested-Mapping-typed sub-block named `KEY` with the
20438 /// built inner `INNER`") rather than three hand-spelled positional
20439 /// artifacts. The next renderer to land — the per-`:politicas`
20440 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
20441 /// nested-Mapping sub-blocks are `metadata:` / `spec:` /
20442 /// `spec.resources[]`), the `app-operator`'s typed
20443 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer
20444 /// (per-`spec.selectors[]` and per-`spec.gates[]` sub-blocks), the
20445 /// M4 cross-cluster fan-out's per-cluster `Service.spec` /
20446 /// `HTTPRoute.spec` sub-block emission, the future `caixa-otel`
20447 /// OpenTelemetry-Collector per-pipeline `receivers:` /
20448 /// `processors:` / `exporters:` nested-Mapping emission — gets the
20449 /// canonical nested-Mapping-valued-field shape for free with one
20450 /// method call, instead of re-inlining the three-token
20451 /// `Value::Mapping(_)` promotion.
20452 ///
20453 /// Peer to [`Self::insert_string`] on the sibling scalar-value axis
20454 /// and [`Self::insert_sequence`] on the sibling list-shape axis —
20455 /// the four together with [`Self::insert_str_key`] form the "one
20456 /// method call per emission axis" primitive quadruple the K8s-
20457 /// artifact-emit surface's "same shape, written N times" duplication
20458 /// (THEORY.md §I.3.5) collapses onto: `insert_str_key` for any-Value
20459 /// inserts, `insert_string` for the string-scalar-valued-field
20460 /// shape, `insert_mapping` for the nested-Mapping-valued-field
20461 /// shape, `insert_sequence` for the list-shape-valued-field shape.
20462 fn insert_mapping(
20463 &mut self,
20464 key: &str,
20465 value: serde_yaml::Mapping,
20466 ) -> Option<serde_yaml::Value>;
20467
20468 /// Insert `(key, Value::Sequence(value))` into `self` — the
20469 /// list-shape-valued-field emission shape that combines
20470 /// [`Self::insert_str_key`]'s `&str → Value::String` key promotion
20471 /// with an automatic [`serde_yaml::Value::Sequence`] promotion of a
20472 /// pre-built `Vec<serde_yaml::Value>` value. Returns the prior
20473 /// value at that key, mirroring [`serde_yaml::Mapping::insert`].
20474 ///
20475 /// The canonical shape 4 production call sites across `caixa-mesh`
20476 /// previously carried inline as the three-token block
20477 /// `mapping.insert_str_key(<KEY>, serde_yaml::Value::Sequence(<VEC>))`
20478 /// — a two-token semantic payload (`<KEY>`, `<VEC>`) buried under a
20479 /// two-axis boilerplate (`serde_yaml::` path re-quote,
20480 /// `Value::Sequence(_)` promotion) around a `Vec<Value>` variable
20481 /// the caller already built.
20482 ///
20483 /// Sites lifted:
20484 ///
20485 /// * caixa-mesh's `cilium_network_policies` per-`CiliumNetworkPolicy`
20486 /// `spec.ingress[].fromEndpoints:` singleton-list (`CILIUM_KEY_FROM_ENDPOINTS`
20487 /// around a `vec![from_endpoint]` selector wrapper);
20488 /// * caixa-mesh's `cilium_network_policies` per-`CiliumNetworkPolicy`
20489 /// `spec.ingress[].toPorts:` list (`CILIUM_KEY_TO_PORTS` around the
20490 /// built `to_ports_seq` per-edge port-and-L7-rule vec);
20491 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute` `spec.hostnames:`
20492 /// singleton-list (`GATEWAY_API_KEY_HOSTNAMES` around a
20493 /// `vec![Value::String(entrada.host…)]` host wrapper);
20494 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute` `spec.rules:`
20495 /// list (`KUBE_KEY_RULES` around the built `rules` per-path
20496 /// match+backend+overlay vec).
20497 ///
20498 /// Lifting collapses the boilerplate into one method call the
20499 /// caller reads as intent (`mapping.insert_sequence(<KEY>, <VEC>)`
20500 /// — "insert a list-shape-typed sub-block named `KEY` with the built
20501 /// inner `VEC`") rather than three hand-spelled positional
20502 /// artifacts. The next renderer to land — the per-`:politicas`
20503 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
20504 /// list-shape sub-blocks are `spec.resources[]` / `spec.listeners[]`
20505 /// / `spec.virtualHosts[]`, MESH-COMPOSITION §III.2 #3), the
20506 /// `app-operator`'s typed `mesh.pleme.io/v1alpha1/Aplicacao` CR
20507 /// materializer (per-`spec.selectors[]` and per-`spec.gates[]`
20508 /// list-shape sub-blocks, §III.2 #5), the M4 cross-cluster fan-out's
20509 /// per-cluster `Service.spec.ports[]` /
20510 /// `HTTPRoute.spec.rules[].backendRefs[]` list emission, the future
20511 /// `caixa-otel` OpenTelemetry-Collector per-pipeline `receivers[]`
20512 /// / `processors[]` / `exporters[]` list emission — gets the
20513 /// canonical list-shape-valued-field shape for free with one method
20514 /// call, instead of re-inlining the three-token `Value::Sequence(_)`
20515 /// promotion.
20516 ///
20517 /// Peer to [`Self::insert_mapping`] on the sibling nested-Mapping
20518 /// axis and [`Self::insert_string`] on the sibling scalar-value axis
20519 /// — the four together with [`Self::insert_str_key`] form the "one
20520 /// method call per emission axis" primitive quadruple the K8s-
20521 /// artifact-emit surface's "same shape, written N times" duplication
20522 /// (THEORY.md §I.3.5) collapses onto: `insert_str_key` for any-Value
20523 /// inserts, `insert_string` for the string-scalar-valued-field
20524 /// shape, `insert_mapping` for the nested-Mapping-valued-field
20525 /// shape, `insert_sequence` for the list-shape-valued-field shape.
20526 ///
20527 /// Complementary to [`singleton_mapping_sequence`] on the peer
20528 /// singleton-list-shape axis: `singleton_mapping_sequence(m)` builds
20529 /// the sole-Mapping-element `Value::Sequence` payload;
20530 /// `insert_sequence(K, v)` inserts an already-built `Vec<Value>`
20531 /// payload under a schema key. A caller composing the two through
20532 /// [`Self::insert_singleton_mapping_sequence`] writes
20533 /// `mapping.insert_singleton_mapping_sequence(K, m)` for the
20534 /// singleton case (the sole element is a fresh Mapping); reach for
20535 /// `mapping.insert_sequence(K, v)` for the multi-element or
20536 /// non-Mapping-element case (the vec is built up per-iteration or
20537 /// wraps a non-Mapping scalar).
20538 fn insert_sequence(
20539 &mut self,
20540 key: &str,
20541 value: Vec<serde_yaml::Value>,
20542 ) -> Option<serde_yaml::Value>;
20543
20544 /// Insert `(key, Value::Sequence(vec![Value::Mapping(value)]))` into
20545 /// `self` — the singleton-Mapping-list-shape-valued-field emission
20546 /// shape that composes [`Self::insert_str_key`]'s
20547 /// `&str → Value::String` key promotion with the
20548 /// [`singleton_mapping_sequence`] helper's singleton-list wrap of a
20549 /// [`serde_yaml::Mapping`] payload. Returns the prior value at that
20550 /// key, mirroring [`serde_yaml::Mapping::insert`].
20551 ///
20552 /// The canonical shape 7 production call sites across `caixa-mesh`
20553 /// previously carried inline as the two-token composition
20554 /// `mapping.insert_str_key(<KEY>, singleton_mapping_sequence(<M>))`
20555 /// — a two-token semantic payload (`<KEY>`, `<M>`) buried under a
20556 /// two-symbol boilerplate (`insert_str_key(_, _)` +
20557 /// `singleton_mapping_sequence(_)`) that fully covers the axis: every
20558 /// site both wraps its per-call `Mapping` as the sole-element list
20559 /// value and inserts it under a schema key on an outer `Mapping`. A
20560 /// rebrand on either half — the outer key-scalar promotion axis
20561 /// migrating to a per-key typed `Value` variant, the singleton-list
20562 /// wrap migrating to a Server-Side-Apply-typed `Value::Tagged`
20563 /// per-CRD-list shape once K8s per-field ownership annotations reach
20564 /// the K8s Gateway API / Cilium NetworkPolicy CRD list schemas —
20565 /// would silently desynchronize one site while leaving the other six
20566 /// on the old shape.
20567 ///
20568 /// Sites lifted:
20569 ///
20570 /// * caixa-mesh's `cilium_network_policies` per-`toPorts[]` port
20571 /// entry `ports:` singleton-list (`CILIUM_KEY_PORTS` around the
20572 /// built `port_entry` Mapping);
20573 /// * caixa-mesh's `cilium_network_policies` per-`toPorts[]` L7
20574 /// `rules.http:` singleton-list (`CILIUM_KEY_HTTP` around the
20575 /// built `http_rule` Mapping);
20576 /// * caixa-mesh's `cilium_network_policies` per-`CiliumNetworkPolicy`
20577 /// `spec.ingress:` singleton-list (`CILIUM_KEY_INGRESS` around the
20578 /// built `ingress_rule` Mapping);
20579 /// * caixa-mesh's `gateway_routes` per-`Gateway` `spec.listeners:`
20580 /// singleton-list (`GATEWAY_API_KEY_LISTENERS` around the built
20581 /// `listener` Mapping);
20582 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute.spec.rules[]`
20583 /// `matches:` singleton-list (`GATEWAY_API_KEY_MATCHES` around the
20584 /// built `match_entry` Mapping);
20585 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute.spec.rules[]`
20586 /// `backendRefs:` singleton-list (`GATEWAY_API_KEY_BACKEND_REFS`
20587 /// around the built `backend_ref` Mapping);
20588 /// * caixa-mesh's `gateway_routes` per-`HTTPRoute`
20589 /// `spec.parentRefs:` singleton-list (`GATEWAY_API_KEY_PARENT_REFS`
20590 /// around the built `parent_ref` Mapping).
20591 ///
20592 /// Lifting collapses the two-symbol composition into one method call
20593 /// the caller reads as intent (`mapping.insert_singleton_mapping_sequence
20594 /// (<KEY>, <M>)` — "insert a singleton-Mapping-list-shape sub-block
20595 /// named `KEY` wrapping the built inner `M`") rather than two
20596 /// nested calls. Peer to [`Self::insert_sequence`] on the sibling
20597 /// multi-element or non-Mapping-element list-shape axis — the two
20598 /// together partition the list-shape-valued-field emission surface:
20599 /// [`Self::insert_singleton_mapping_sequence`] for the sole-Mapping-
20600 /// element case, [`Self::insert_sequence`] for every other case.
20601 ///
20602 /// The next renderer to land — the per-`:politicas`
20603 /// `CiliumClusterwideEnvoyConfig` emitter (whose singleton
20604 /// `spec.resources:[]` / `spec.listeners:[]` / `spec.virtualHosts:[]`
20605 /// Mapping-element blocks, MESH-COMPOSITION §III.2 #3, are exactly the
20606 /// singleton-Mapping-list shape), the `app-operator`'s typed
20607 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (per-single-
20608 /// selector / per-single-gate emission, §III.2 #5), the M4 cross-
20609 /// cluster fan-out's per-cluster singleton `Service.spec.ports[]` /
20610 /// `HTTPRoute.spec.rules[].backendRefs[]` sole-element emission, the
20611 /// future `caixa-otel` OpenTelemetry-Collector `pipelines.traces.
20612 /// receivers[]` singleton-receiver emission — gets the canonical
20613 /// singleton-Mapping-list-shape wrap+insert for free with one method
20614 /// call, instead of re-inlining the two-symbol composition.
20615 fn insert_singleton_mapping_sequence(
20616 &mut self,
20617 key: &str,
20618 value: serde_yaml::Mapping,
20619 ) -> Option<serde_yaml::Value>;
20620
20621 /// Entry-API sibling of [`Self::insert_str_key`] — mint the
20622 /// `Value::String(<KEY>.into())` key-promotion the underlying
20623 /// [`serde_yaml::Mapping::entry`] method's `Value` parameter
20624 /// demands, and return the entry-API's
20625 /// [`serde_yaml::mapping::Entry`] handle the caller composes
20626 /// `.or_insert(<V>)` / `.or_insert_with(<F>)` /
20627 /// `.and_modify(<F>)` / `.or_default()` on.
20628 ///
20629 /// The canonical shape 4 production call sites across `caixa-flux`
20630 /// previously carried inline as the three-token composition
20631 /// `mapping.entry(serde_yaml::Value::String(<KEY>.into()))` around
20632 /// a one-token semantic payload (the schema key axis-name). Every
20633 /// site immediately composes an `.or_insert(...)` on the returned
20634 /// [`serde_yaml::mapping::Entry`] handle — the pattern is the
20635 /// entry-API twin of the [`Self::insert_str_key`] pattern the
20636 /// ~48 fresh-emit sites already collapsed onto (23506b3).
20637 ///
20638 /// Sites lifted:
20639 ///
20640 /// * caixa-flux's `programs_yaml_entry` per-`servico_m2_overlay`
20641 /// key idempotent-upsert loop (`entry.entry(Value::String(
20642 /// <key>.to_string())).or_insert(<value>)` — one
20643 /// `.or_insert(...)` per `M2_KEY_LIMITS` / `M2_KEY_BEHAVIOR` /
20644 /// `M2_KEY_UPGRADE_FROM` axis, iterating the
20645 /// [`servico_m2_overlay`] `BTreeMap`);
20646 /// * caixa-flux's `upsert_into_helmrelease_programs` per-
20647 /// `HelmRelease.spec.values` upsert-if-absent (`FLUX_KEY_VALUES`
20648 /// around a default fresh `Value::Mapping`);
20649 /// * caixa-flux's `upsert_into_helmrelease_programs` per-
20650 /// `HelmRelease.spec.values.programs` upsert-if-absent
20651 /// (`FLEET_PROGRAMS_KEY_PROGRAMS` around a default fresh
20652 /// `Value::Sequence`);
20653 /// * caixa-flux's `upsert_into_programs_yaml` per-top-level
20654 /// `programs:` upsert-if-absent (`FLEET_PROGRAMS_KEY_PROGRAMS`
20655 /// around a default fresh `Value::Sequence` — the sibling of
20656 /// the `upsert_into_helmrelease_programs` site on the same
20657 /// key, one path deep in a HelmRelease `spec.values.` sub-tree,
20658 /// one path at the values.yaml root).
20659 ///
20660 /// Lifting collapses the three-token composition into one method
20661 /// call the caller reads as intent
20662 /// (`mapping.entry_str_key(<KEY>).or_insert(<DEFAULT>)` — "get the
20663 /// entry handle for this schema key and default it if missing")
20664 /// rather than four hand-spelled positional artifacts
20665 /// (`serde_yaml::` path re-quote, `Value::String(_)` promotion,
20666 /// the `.into() | .to_string()` `&str → String` coercion, plus the
20667 /// `.entry(_)` call itself). The next renderer to land — the
20668 /// per-`:politicas` `CiliumClusterwideEnvoyConfig` emitter (which
20669 /// upserts singleton `spec.resources:[]` / `spec.listeners:[]`
20670 /// blocks under an existing per-cluster overlay CR, MESH-COMPOSITION
20671 /// §III.2 #3), the `app-operator`'s typed
20672 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (which
20673 /// upserts `status.` sub-fields on partial reconciles, §III.2 #5),
20674 /// the M4 cross-cluster fan-out's per-cluster idempotent
20675 /// HelmRelease upsert — gets the canonical entry-API key-promotion
20676 /// for free with one method call, instead of re-inlining the
20677 /// three-token block.
20678 ///
20679 /// Peer to [`Self::insert_str_key`] on the sibling fresh-emit
20680 /// axis of the same `&str → Value::String` key-promotion — the
20681 /// two together partition the `Mapping`-write surface: entry-API
20682 /// for idempotent-upsert sites where the caller cares whether the
20683 /// prior value was present (`or_insert` / `and_modify` /
20684 /// `or_default` composition), insert-API for fresh-emit sites where
20685 /// the caller unconditionally writes a value and either drops or
20686 /// pattern-matches on the returned `Option<Value>` prior value.
20687 fn entry_str_key(&mut self, key: &str) -> serde_yaml::mapping::Entry<'_>;
20688
20689 /// Arity-0-or-1 twin of [`Self::insert_str_key`] — insert
20690 /// `(key, value.clone())` iff `value` is `Some`; leave `self`
20691 /// untouched iff `value` is `None`. Returns the prior value at that
20692 /// key when the insert fires (mirroring
20693 /// [`serde_yaml::Mapping::insert`]), and `None` otherwise (no insert
20694 /// happened, so no prior value can be surfaced).
20695 ///
20696 /// The canonical shape 3 production call sites across `caixa-mesh`
20697 /// previously carried inline as the three-line block
20698 /// `if let Some(<x>) = &<overlay> { <mapping>.insert_str_key(<KEY>,
20699 /// <x>.clone()); }` around a two-token semantic payload (the schema
20700 /// key axis-name + the `Option<Value>` overlay slot). Every site
20701 /// pairs a per-`:politicas` overlay [`single_field_overlay`] `Option
20702 /// <Value>` output with the same conditional-insert conditional —
20703 /// the arity-0-or-1 twin of [`Self::insert_str_key`]'s always-1
20704 /// arity on the per-`(:de, :para)` axis.
20705 ///
20706 /// Sites lifted:
20707 ///
20708 /// * caixa-mesh's `cilium_network_policies` per-ingress-rule
20709 /// `:politicas :mtls-required` mutual-auth overlay
20710 /// ([`crate::CILIUM_KEY_AUTHENTICATION`] around the
20711 /// `mtls_overlay` [`single_field_overlay`] output — the
20712 /// tristate `{mode: required | disabled}` block or the
20713 /// None-omit arm);
20714 /// * caixa-mesh's `gateway_routes` per-HTTPRoute-rule
20715 /// `:politicas :timeout` request-deadline overlay
20716 /// ([`crate::GATEWAY_API_KEY_TIMEOUTS`] around the
20717 /// `timeout_overlay` [`single_field_overlay`] output — the
20718 /// `{request: "<duration>"}` block or the None-omit arm);
20719 /// * caixa-mesh's `gateway_routes` per-HTTPRoute-rule
20720 /// `:politicas :retries` retry-attempt-cap overlay
20721 /// ([`crate::GATEWAY_API_KEY_RETRY`] around the
20722 /// `retry_overlay` [`single_field_overlay`] output — the
20723 /// `{attempts: <N>}` block or the None-omit arm).
20724 ///
20725 /// Lifting collapses the three-line block into one method call the
20726 /// caller reads as intent (`mapping.insert_str_key_if_some(<KEY>,
20727 /// <overlay>.as_ref())` — "insert this schema key if the overlay
20728 /// carried a value; else leave the key absent") rather than four
20729 /// hand-spelled positional artifacts (the `if let Some(_) = &_`
20730 /// destructure, the per-inner `.clone()`, the trailing brace, plus
20731 /// the `.insert_str_key(_)` call itself). The absent-overlay arm —
20732 /// which every [`MeshPolicy`] axis defaults to when the author
20733 /// leaves the typed slot unset (the `None` arm of the
20734 /// `Option<Value>` [`single_field_overlay`] output) — reads as the
20735 /// method's own `Option::None` branch, not a per-call-site inverted
20736 /// `if let Some` scaffold around a per-call-site clone.
20737 ///
20738 /// The next renderer to land — the per-`:politicas`
20739 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
20740 /// `authentication:` / `rateLimit:` / `circuitBreaker:` Option
20741 /// overlays, MESH-COMPOSITION §III.2 #3, thread through the same
20742 /// [`single_field_overlay`] `Option<Value>` axis the three lifted
20743 /// sites here already reach), the `app-operator`'s typed
20744 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (whose per-
20745 /// selector `status.` sub-field overlays are the same arity-0-or-1
20746 /// shape, §III.2 #5), the M4 cross-cluster fan-out's per-cluster
20747 /// `HTTPRoute.spec.rules[].filters[]` per-filter Option overlays
20748 /// (the same shape at the per-cluster axis) — gets the canonical
20749 /// arity-0-or-1 conditional-insert for free with one method call,
20750 /// instead of re-inlining the three-line `if let Some { clone;
20751 /// insert_str_key }` block.
20752 ///
20753 /// Peer to [`Self::insert_str_key`] on the always-1 arity axis
20754 /// (fresh-emit sites where the caller unconditionally writes a
20755 /// value) — the two together partition the fresh-emit surface
20756 /// exactly on the arity axis: [`Self::insert_str_key`] for
20757 /// unconditional writes, [`Self::insert_str_key_if_some`] for
20758 /// conditional writes gated on an `Option<Value>` upstream
20759 /// producer (the per-`:politicas` overlay
20760 /// [`single_field_overlay`] axis, and every future arity-0-or-1
20761 /// axis every future renderer's optional-slot machinery reaches
20762 /// through).
20763 ///
20764 /// The `Option<&Value>` shape (as opposed to an owned
20765 /// `Option<Value>`) lets the caller pass `overlay.as_ref()` on an
20766 /// owned `Option<Value>` the caller reuses across iterations of an
20767 /// outer per-`(:de, :para)` or per-rule loop — every lifted site
20768 /// consumes the overlay from a loop-outer binding into each of N
20769 /// per-iteration `Mapping`s, so the clone happens iff the insert
20770 /// fires (the None arm skips the clone entirely) and the outer
20771 /// binding stays available for the next iteration.
20772 fn insert_str_key_if_some(
20773 &mut self,
20774 key: &str,
20775 value: Option<&serde_yaml::Value>,
20776 ) -> Option<serde_yaml::Value>;
20777
20778 /// Fetch a `&mut serde_yaml::Mapping` at `key`, defaulting an empty
20779 /// [`serde_yaml::Mapping`] into place when the entry is absent.
20780 /// Returns `Some(&mut inner)` on the absent-key (fresh empty
20781 /// Mapping) and present-Mapping arms; `None` iff `key` holds a
20782 /// different [`serde_yaml::Value`] variant — a structural
20783 /// container-type mismatch the caller surfaces as its own
20784 /// domain-specific error (`Error::MissingField("spec.values must
20785 /// be a mapping")` for the caixa-flux Flux-HelmRelease overlay
20786 /// walker).
20787 ///
20788 /// The canonical shape 1 production call site in `caixa-flux`
20789 /// (`upsert_into_helmrelease_programs`'s per-`HelmRelease.spec.values`
20790 /// container-upsert on the way down to
20791 /// `spec.values.programs[]`) previously carried inline as a
20792 /// four-line block combining [`Self::entry_str_key`]'s entry-API
20793 /// key promotion (68d035e), an
20794 /// `.or_insert(Value::Mapping(Mapping::new()))` empty-Mapping
20795 /// default, and a `let Value::Mapping(inner) = _ else { Err(...) }`
20796 /// destructure — a two-token semantic payload (the schema key +
20797 /// the domain-specific type-mismatch diagnostic) buried under
20798 /// three boilerplate axes (`Value::Mapping(_)` variant promotion,
20799 /// `Mapping::new()` empty-container construction, the outer
20800 /// `let else` destructure). Peer to
20801 /// [`Self::entry_or_default_sequence`] on the sibling `Vec<Value>`-
20802 /// valued idempotent-container-upsert axis — the two together
20803 /// partition the entry-API-container-upsert surface exactly on the
20804 /// container-variant axis: [`Self::entry_or_default_mapping`] for
20805 /// nested-Mapping sub-blocks, [`Self::entry_or_default_sequence`]
20806 /// for list-shape sub-blocks.
20807 ///
20808 /// Sites lifted:
20809 ///
20810 /// * caixa-flux's `upsert_into_helmrelease_programs` per-
20811 /// `HelmRelease.spec.values` container-upsert
20812 /// (`FLUX_KEY_VALUES` around the default fresh
20813 /// `Value::Mapping`, on the way down to the nested
20814 /// `spec.values.programs[]` sequence).
20815 ///
20816 /// Lifting collapses the four-line block into one method call the
20817 /// caller reads as intent (`mapping.entry_or_default_mapping(<KEY>)
20818 /// .ok_or(<ERR>)?` — "give me the nested Mapping at this schema
20819 /// key, defaulting empty if absent, else surface my domain
20820 /// error") rather than five hand-spelled positional artifacts
20821 /// (`serde_yaml::` path re-quote, `Value::Mapping(_)` promotion,
20822 /// `Mapping::new()` construction, the entry-API `.or_insert(...)`
20823 /// call, plus the outer `let Value::Mapping(_) = _ else {}`
20824 /// destructure). The next renderer to land — the per-`:politicas`
20825 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-cluster
20826 /// upsert walks
20827 /// `HelmRelease.spec.values.<library>.<:politicas-axis>`,
20828 /// idempotent-upserting nested-Mapping sub-blocks under each
20829 /// axis, MESH-COMPOSITION §III.2 #3), the `app-operator`'s typed
20830 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (which
20831 /// upserts `status.<axis>` nested-Mapping sub-blocks on partial
20832 /// reconciles, §III.2 #5), the M4 cross-cluster fan-out's
20833 /// per-cluster idempotent `HelmRelease.spec.values.<library>`
20834 /// container-upsert — gets the canonical entry-API-with-
20835 /// container-type-check for free with one method call, instead
20836 /// of re-inlining the four-line block.
20837 ///
20838 /// The default-empty-Mapping construction fires only on the
20839 /// absent-key arm (`.or_insert_with(...)` gates the closure on
20840 /// vacancy) — the present-key arm reuses the existing Mapping
20841 /// verbatim, so the caller's downstream writes on `&mut inner`
20842 /// compose with any prior overlay writes from earlier passes
20843 /// (the exact idempotent-upsert semantic the caixa-flux
20844 /// per-cluster `feira app deploy` write path depends on to
20845 /// preserve operator-pinned overlays across re-renders).
20846 fn entry_or_default_mapping(&mut self, key: &str) -> Option<&mut serde_yaml::Mapping>;
20847
20848 /// Fetch a `&mut Vec<serde_yaml::Value>` at `key`, defaulting an
20849 /// empty [`Vec<serde_yaml::Value>`] into place when the entry is
20850 /// absent. Returns `Some(&mut inner)` on the absent-key (fresh
20851 /// empty Sequence) and present-Sequence arms; `None` iff `key`
20852 /// holds a different [`serde_yaml::Value`] variant — a structural
20853 /// container-type mismatch the caller surfaces as its own
20854 /// domain-specific error (`Error::MissingField("programs must be
20855 /// a sequence")` for the caixa-flux fleet-programs upsert
20856 /// walkers).
20857 ///
20858 /// The canonical shape 2 production call sites in `caixa-flux`
20859 /// (`upsert_into_helmrelease_programs`'s per-
20860 /// `HelmRelease.spec.values.programs` container-upsert and
20861 /// `upsert_into_programs_yaml`'s top-level `programs:` container-
20862 /// upsert) previously carried inline as a four-line block
20863 /// combining [`Self::entry_str_key`]'s entry-API key promotion
20864 /// (68d035e), an `.or_insert(Value::Sequence(Vec::new()))`
20865 /// empty-Sequence default, and a `match _ { Value::Sequence(seq)
20866 /// => seq, _ => return Err(...) }` destructure — a two-token
20867 /// semantic payload (the schema key + the domain-specific
20868 /// type-mismatch diagnostic) buried under three boilerplate axes
20869 /// (`Value::Sequence(_)` variant promotion, `Vec::new()`
20870 /// empty-container construction, the outer `match` destructure).
20871 /// Peer to [`Self::entry_or_default_mapping`] on the sibling
20872 /// nested-Mapping-valued idempotent-container-upsert axis.
20873 ///
20874 /// Sites lifted:
20875 ///
20876 /// * caixa-flux's `upsert_into_helmrelease_programs` per-
20877 /// `HelmRelease.spec.values.programs` list-container-upsert
20878 /// (`FLEET_PROGRAMS_KEY_PROGRAMS` around the default fresh
20879 /// `Value::Sequence`, one path deep in a `HelmRelease`
20880 /// `spec.values.` sub-tree);
20881 /// * caixa-flux's `upsert_into_programs_yaml` per-top-level
20882 /// `programs:` list-container-upsert
20883 /// (`FLEET_PROGRAMS_KEY_PROGRAMS` around the default fresh
20884 /// `Value::Sequence` — the sibling of the
20885 /// `upsert_into_helmrelease_programs` site on the same key,
20886 /// one path at the values.yaml root).
20887 ///
20888 /// Lifting collapses the four-line block into one method call the
20889 /// caller reads as intent (`mapping.entry_or_default_sequence(<KEY>)
20890 /// .ok_or(<ERR>)?` — "give me the list at this schema key,
20891 /// defaulting empty if absent, else surface my domain error")
20892 /// rather than five hand-spelled positional artifacts
20893 /// (`serde_yaml::` path re-quote, `Value::Sequence(_)` promotion,
20894 /// `Vec::new()` construction, the entry-API `.or_insert(...)`
20895 /// call, plus the outer `match { Value::Sequence(_) => _, _ =>
20896 /// return Err(_) }` destructure). The next renderer to land — the
20897 /// per-`:politicas` `CiliumClusterwideEnvoyConfig` emitter
20898 /// (whose per-cluster upsert walks nested list-shape sub-blocks
20899 /// `spec.resources[]` / `spec.listeners[]` / `spec.virtualHosts[]`
20900 /// under existing operator-pinned overlay CRs, MESH-COMPOSITION
20901 /// §III.2 #3), the `app-operator`'s typed
20902 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (which
20903 /// upserts `status.selectors[]` / `status.gates[]` list-shape
20904 /// sub-blocks on partial reconciles, §III.2 #5), the M4 cross-
20905 /// cluster fan-out's per-cluster idempotent
20906 /// `HelmRelease.spec.values.programs` list-upsert — gets the
20907 /// canonical entry-API-with-container-type-check for free with
20908 /// one method call, instead of re-inlining the four-line block.
20909 ///
20910 /// The default-empty-Sequence construction fires only on the
20911 /// absent-key arm (`.or_insert_with(...)` gates the closure on
20912 /// vacancy) — the present-key arm reuses the existing Vec
20913 /// verbatim, so the caller's downstream `upsert_named_entry`
20914 /// (10bf310) call on `&mut inner` composes with any prior
20915 /// entries the emitter wrote on earlier passes (the exact
20916 /// idempotent-upsert semantic the `feira app deploy` per-cluster
20917 /// write path depends on to preserve prior `programs[]` entries
20918 /// across per-Servico rewrites).
20919 fn entry_or_default_sequence(&mut self, key: &str) -> Option<&mut Vec<serde_yaml::Value>>;
20920}
20921
20922impl MappingExt for serde_yaml::Mapping {
20923 #[inline]
20924 fn insert_str_key(&mut self, key: &str, value: serde_yaml::Value) -> Option<serde_yaml::Value> {
20925 self.insert(serde_yaml::Value::String(key.to_string()), value)
20926 }
20927
20928 #[inline]
20929 fn insert_string<V: Into<String>>(&mut self, key: &str, value: V) -> Option<serde_yaml::Value> {
20930 self.insert_str_key(key, serde_yaml::Value::String(value.into()))
20931 }
20932
20933 #[inline]
20934 fn insert_number<N: Into<serde_yaml::Number>>(
20935 &mut self,
20936 key: &str,
20937 value: N,
20938 ) -> Option<serde_yaml::Value> {
20939 self.insert_str_key(key, serde_yaml::Value::Number(value.into()))
20940 }
20941
20942 #[inline]
20943 fn insert_mapping(
20944 &mut self,
20945 key: &str,
20946 value: serde_yaml::Mapping,
20947 ) -> Option<serde_yaml::Value> {
20948 self.insert_str_key(key, serde_yaml::Value::Mapping(value))
20949 }
20950
20951 #[inline]
20952 fn insert_sequence(
20953 &mut self,
20954 key: &str,
20955 value: Vec<serde_yaml::Value>,
20956 ) -> Option<serde_yaml::Value> {
20957 self.insert_str_key(key, serde_yaml::Value::Sequence(value))
20958 }
20959
20960 #[inline]
20961 fn insert_singleton_mapping_sequence(
20962 &mut self,
20963 key: &str,
20964 value: serde_yaml::Mapping,
20965 ) -> Option<serde_yaml::Value> {
20966 self.insert_str_key(key, singleton_mapping_sequence(value))
20967 }
20968
20969 #[inline]
20970 fn entry_str_key(&mut self, key: &str) -> serde_yaml::mapping::Entry<'_> {
20971 self.entry(serde_yaml::Value::String(key.to_string()))
20972 }
20973
20974 #[inline]
20975 fn insert_str_key_if_some(
20976 &mut self,
20977 key: &str,
20978 value: Option<&serde_yaml::Value>,
20979 ) -> Option<serde_yaml::Value> {
20980 value.and_then(|v| self.insert_str_key(key, v.clone()))
20981 }
20982
20983 #[inline]
20984 fn entry_or_default_mapping(&mut self, key: &str) -> Option<&mut serde_yaml::Mapping> {
20985 match self
20986 .entry_str_key(key)
20987 .or_insert_with(|| serde_yaml::Value::Mapping(serde_yaml::Mapping::new()))
20988 {
20989 serde_yaml::Value::Mapping(m) => Some(m),
20990 _ => None,
20991 }
20992 }
20993
20994 #[inline]
20995 fn entry_or_default_sequence(&mut self, key: &str) -> Option<&mut Vec<serde_yaml::Value>> {
20996 match self
20997 .entry_str_key(key)
20998 .or_insert_with(|| serde_yaml::Value::Sequence(Vec::new()))
20999 {
21000 serde_yaml::Value::Sequence(s) => Some(s),
21001 _ => None,
21002 }
21003 }
21004}
21005
21006/// Extension methods for the [`Vec<serde_yaml::Value>`] emission
21007/// surface that the K8s-artifact-emit sites of `caixa-mesh` /
21008/// `caixa-flux` / `caixa-helm` / `caixa-core::render` build up as
21009/// `spec.ingress[]` / `spec.rules[]` / `spec.hostnames[]` / per-
21010/// programs.yaml-entry payloads before wrapping each vec as a
21011/// [`serde_yaml::Value::Sequence`] on an outer [`serde_yaml::Mapping`]
21012/// (via [`MappingExt::insert_sequence`]).
21013///
21014/// Peer to [`MappingExt`] on the sibling [`serde_yaml::Value`]-
21015/// construction surface: [`MappingExt`] closes the per-key-and-value
21016/// insert primitive every schema-key axis reaches through;
21017/// [`SequenceExt`] closes the per-list-element push primitive every
21018/// per-iteration append site reaches through when the built-up
21019/// [`serde_yaml::Value`] variant is uniform across a loop body (e.g.
21020/// every element is a fresh [`serde_yaml::Value::Mapping`], not a
21021/// heterogeneous mix of `Mapping` / `String` / `Sequence`).
21022///
21023/// Each method mints the same `Value::<Variant>(<payload>)` promotion
21024/// the caller would otherwise re-inline as
21025/// `vec.push(serde_yaml::Value::<Variant>(<payload>))` on every
21026/// iteration. Same variant-promotion contract as [`MappingExt`]'s
21027/// typed inserts, applied to the sequence-append axis instead of the
21028/// mapping-insert axis — so a future rebrand of the `Value` variant
21029/// wrapping (e.g. to a Server-Side-Apply-typed
21030/// [`serde_yaml::Value::Tagged`] per-list-element ownership axis)
21031/// reaches both `Mapping`-insert and `Vec<Value>`-push sites through
21032/// one lift.
21033pub trait SequenceExt {
21034 /// Append `Value::Mapping(value)` to `self` — the per-iteration
21035 /// append shape that combines a `Vec<serde_yaml::Value>::push`
21036 /// with an automatic [`serde_yaml::Value::Mapping`] promotion of a
21037 /// pre-built [`serde_yaml::Mapping`] element.
21038 ///
21039 /// The canonical shape 4 production call sites across `caixa-mesh`
21040 /// previously carried inline as the three-token block
21041 /// `<vec>.push(serde_yaml::Value::Mapping(<M>))` — a one-token
21042 /// semantic payload (the per-iteration `Mapping`) buried under a
21043 /// two-axis boilerplate (`serde_yaml::` path re-quote,
21044 /// `Value::Mapping(_)` promotion) around a `Mapping` variable the
21045 /// caller already built.
21046 ///
21047 /// Sites lifted:
21048 ///
21049 /// * caixa-mesh's `programs_for_aplicacao` per-`:membros`
21050 /// programs.yaml entry append (per-member entry `Mapping` →
21051 /// the fan-out `Vec<Value>`);
21052 /// * caixa-mesh's `cilium_network_policies` per-edge
21053 /// `spec.ingress[].toPorts[]` L4-and-L7 port-and-rule append
21054 /// (per-`(:de, :para)` group's per-edge `to_port` Mapping →
21055 /// the `to_ports_seq` Vec);
21056 /// * caixa-mesh's `cilium_network_policies` per-policy
21057 /// top-level CNP-document append (per-`(:de, :para)` group's
21058 /// built `policy` Mapping → the render-output `Vec<Value>`);
21059 /// * caixa-mesh's `gateway_routes` per-HTTPRoute-rule
21060 /// `spec.rules[]` append (per-path built `rule` Mapping → the
21061 /// `rules` Vec).
21062 ///
21063 /// Lifting collapses the three-token block into one method call
21064 /// the caller reads as intent (`<vec>.push_mapping(<M>)` —
21065 /// "append this built inner `M` as the next `Value::Mapping`
21066 /// element") rather than three hand-spelled positional artifacts
21067 /// (`serde_yaml::` path re-quote, `Value::Mapping(_)` promotion,
21068 /// plus the `.push(_)` call itself). Peer to
21069 /// [`MappingExt::insert_singleton_mapping_sequence`] on the
21070 /// singleton-Mapping-list-shape axis: [`Self::push_mapping`]
21071 /// builds up a multi-element `Vec<Value>` per iteration when the
21072 /// caller then calls [`MappingExt::insert_sequence`] to route the
21073 /// finished vec under a schema key;
21074 /// [`MappingExt::insert_singleton_mapping_sequence`] fuses the
21075 /// singleton wrap + the schema-key insert into one call when the
21076 /// caller has exactly one Mapping element to emit under a schema
21077 /// key.
21078 ///
21079 /// The next renderer to land — the per-`:politicas`
21080 /// `CiliumClusterwideEnvoyConfig` emitter (whose per-policy
21081 /// `spec.resources[]` / `spec.listeners[]` / `spec.virtualHosts[]`
21082 /// list-shape axes fan out multi-Mapping-element per iteration,
21083 /// MESH-COMPOSITION §III.2 #3), the `app-operator`'s typed
21084 /// `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer (per-
21085 /// `spec.selectors[]` / per-`spec.gates[]` multi-element append,
21086 /// §III.2 #5), the M4 cross-cluster fan-out's per-cluster
21087 /// multi-entry `Service.spec.ports[]` /
21088 /// `HTTPRoute.spec.rules[].backendRefs[]` list append, the future
21089 /// `caixa-otel` OpenTelemetry-Collector per-pipeline
21090 /// `receivers[]` / `processors[]` / `exporters[]` multi-element
21091 /// append — gets the canonical `Value::Mapping`-promoted append
21092 /// for free with one method call, instead of re-inlining the
21093 /// three-token `Value::Mapping(_)` promotion.
21094 fn push_mapping(&mut self, value: serde_yaml::Mapping);
21095}
21096
21097impl SequenceExt for Vec<serde_yaml::Value> {
21098 #[inline]
21099 fn push_mapping(&mut self, value: serde_yaml::Mapping) {
21100 self.push(serde_yaml::Value::Mapping(value));
21101 }
21102}
21103
21104#[cfg(test)]
21105mod tests {
21106 use super::*;
21107 use crate::{BehaviorSpec, CaixaKind, LimitsSpec, UpgradeFromEntry, UpgradeInstruction};
21108 use std::path::PathBuf;
21109 use std::time::Duration;
21110
21111 fn bare_servico() -> Caixa {
21112 Caixa {
21113 nome: "hello-rio".into(),
21114 versao: "0.1.0".into(),
21115 kind: CaixaKind::Servico,
21116 edicao: Some("2026".into()),
21117 descricao: None,
21118 repositorio: None,
21119 licenca: None,
21120 autores: vec![],
21121 etiquetas: vec![],
21122 deps: vec![],
21123 deps_dev: vec![],
21124 exe: vec![],
21125 bibliotecas: vec![],
21126 servicos: vec!["servicos/hello-rio.computeunit.yaml".into()],
21127 limits: None,
21128 behavior: None,
21129 upgrade_from: vec![],
21130 estrategia: None,
21131 max_restarts: None,
21132 restart_window: None,
21133 children: vec![],
21134 membros: vec![],
21135 contratos: vec![],
21136 politicas: None,
21137 placement: None,
21138 entrada: None,
21139 ci: None,
21140 }
21141 }
21142
21143 #[test]
21144 fn empty_caixa_returns_empty_overlay() {
21145 let overlay = servico_m2_overlay(&bare_servico()).unwrap();
21146 assert!(
21147 overlay.is_empty(),
21148 "a Caixa with no M2 slots emits zero overlay fragments"
21149 );
21150 }
21151
21152 #[test]
21153 fn empty_typed_specs_are_skipped_like_unset_ones() {
21154 // `Some(LimitsSpec::default())` (every axis None) and
21155 // `Some(BehaviorSpec::default())` (every callback None) must
21156 // round-trip identical to `None` — the is_empty()-skip
21157 // invariant the renderers' "empty M2 slots do not appear"
21158 // tests pinned inline before this lift.
21159 let mut c = bare_servico();
21160 c.limits = Some(LimitsSpec::default());
21161 c.behavior = Some(BehaviorSpec::default());
21162 let overlay = servico_m2_overlay(&c).unwrap();
21163 assert!(overlay.is_empty());
21164 }
21165
21166 #[test]
21167 fn limits_slot_appears_under_camelcase_key() {
21168 let mut c = bare_servico();
21169 c.limits = Some(LimitsSpec {
21170 memory: Some(64 * 1024 * 1024),
21171 fuel: Some(1_000_000),
21172 wall_clock: Some(Duration::from_secs(30)),
21173 cpu: Some(500),
21174 });
21175 let overlay = servico_m2_overlay(&c).unwrap();
21176 assert_eq!(overlay.len(), 1);
21177 let limits = overlay.get(M2_KEY_LIMITS).expect("limits key present");
21178 assert_eq!(
21179 limits.get(M2_LIMITS_KEY_MEMORY).and_then(|m| m.as_str()),
21180 Some("64MiB")
21181 );
21182 assert_eq!(
21183 limits
21184 .get(M2_LIMITS_KEY_WALL_CLOCK)
21185 .and_then(|m| m.as_str()),
21186 Some("30s")
21187 );
21188 }
21189
21190 #[test]
21191 fn behavior_slot_appears_under_camelcase_key() {
21192 let mut c = bare_servico();
21193 c.behavior = Some(BehaviorSpec {
21194 on_init: Some(PathBuf::from("lib/init.lisp")),
21195 on_call: Some(PathBuf::from("lib/handlers.lisp")),
21196 ..Default::default()
21197 });
21198 let overlay = servico_m2_overlay(&c).unwrap();
21199 let behavior = overlay.get(M2_KEY_BEHAVIOR).expect("behavior key present");
21200 assert_eq!(
21201 behavior
21202 .get(M2_BEHAVIOR_KEY_ON_INIT)
21203 .and_then(|v| v.as_str()),
21204 Some("lib/init.lisp")
21205 );
21206 assert_eq!(
21207 behavior
21208 .get(M2_BEHAVIOR_KEY_ON_CALL)
21209 .and_then(|v| v.as_str()),
21210 Some("lib/handlers.lisp")
21211 );
21212 }
21213
21214 #[test]
21215 fn upgrade_from_slot_appears_under_camelcase_key() {
21216 let mut c = bare_servico();
21217 c.upgrade_from = vec![UpgradeFromEntry {
21218 from: "0.0.9".into(),
21219 instructions: vec![UpgradeInstruction::LoadModule {
21220 module: "hello-rio".into(),
21221 }],
21222 }];
21223 let overlay = servico_m2_overlay(&c).unwrap();
21224 let upgrade = overlay
21225 .get(M2_KEY_UPGRADE_FROM)
21226 .expect("upgradeFrom key present");
21227 let arr = upgrade.as_sequence().expect("sequence");
21228 assert_eq!(arr.len(), 1);
21229 assert_eq!(
21230 arr[0]
21231 .get(M2_UPGRADE_FROM_KEY_FROM)
21232 .and_then(|v| v.as_str()),
21233 Some("0.0.9")
21234 );
21235 }
21236
21237 #[test]
21238 fn all_three_slots_appear_in_alphabetical_iteration_order() {
21239 // BTreeMap iteration is sorted by key — pin that the renderers
21240 // can rely on a deterministic iteration order, which feeds
21241 // into deterministic YAML output (the value-as-proof property
21242 // THEORY.md §V.2.7 "render determinism" requires).
21243 let mut c = bare_servico();
21244 c.limits = Some(LimitsSpec {
21245 memory: Some(64 * 1024 * 1024),
21246 ..Default::default()
21247 });
21248 c.behavior = Some(BehaviorSpec {
21249 on_init: Some(PathBuf::from("lib/init.lisp")),
21250 ..Default::default()
21251 });
21252 c.upgrade_from = vec![UpgradeFromEntry {
21253 from: "0.0.9".into(),
21254 instructions: vec![UpgradeInstruction::LoadModule {
21255 module: "hello-rio".into(),
21256 }],
21257 }];
21258 let overlay = servico_m2_overlay(&c).unwrap();
21259 let keys: Vec<_> = overlay.keys().copied().collect();
21260 assert_eq!(
21261 keys,
21262 vec![M2_KEY_BEHAVIOR, M2_KEY_LIMITS, M2_KEY_UPGRADE_FROM]
21263 );
21264 }
21265
21266 // ── servico_spec_and_m2_overlay_entries — composed splice ────────────
21267 //
21268 // The compound peer of `servico_m2_overlay` on the ComputeUnit-YAML
21269 // `spec.*` + M2-overlay axis: fuses the two prior inline for-loops
21270 // caixa-flux::programs_yaml_entry and caixa-helm::build_values_yaml
21271 // both carried around `string_keyed_entries` + `servico_m2_overlay`
21272 // into one canonical composition. The pins below bracket the shape
21273 // end-to-end (spec.* keys first + preserved-insertion-order, then M2
21274 // slots in BTreeMap-key order at every M2 key not already claimed by
21275 // spec.*).
21276
21277 fn cu_yaml_with_spec_fields(spec_yaml: &str) -> serde_yaml::Value {
21278 serde_yaml::from_str(&format!(
21279 "apiVersion: wasm.pleme.io/v1alpha1\nkind: ComputeUnit\nmetadata:\n name: hello-rio\nspec:\n{spec_yaml}"
21280 ))
21281 .unwrap()
21282 }
21283
21284 #[test]
21285 fn servico_spec_and_m2_overlay_entries_empty_caixa_and_empty_spec_yields_empty() {
21286 let cu = cu_yaml_with_spec_fields(" {}\n");
21287 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
21288 let out = servico_spec_and_m2_overlay_entries(&bare_servico(), spec).unwrap();
21289 assert!(
21290 out.is_empty(),
21291 "empty spec + empty M2 surface yields zero entries \
21292 (both loops short-circuit vacuously)"
21293 );
21294 }
21295
21296 #[test]
21297 fn servico_spec_and_m2_overlay_entries_splices_spec_fields_in_source_insertion_order() {
21298 // The spec.* field-splice loop preserves the source YAML
21299 // Mapping's insertion order — caixa-flux's `serde_yaml::Mapping`
21300 // target reads this back verbatim, so a rebrand of the source
21301 // ComputeUnit YAML's field ordering must not silently reorder
21302 // the emitted programs.yaml entry.
21303 let cu = cu_yaml_with_spec_fields(
21304 " module:\n source: oci://ghcr.io/pleme-io/hello-rio:v0.1.0\n \
21305 trigger:\n service: {port: 8080}\n capabilities:\n - env\n",
21306 );
21307 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
21308 let out = servico_spec_and_m2_overlay_entries(&bare_servico(), spec).unwrap();
21309 let keys: Vec<&str> = out.iter().map(|(k, _)| k.as_str()).collect();
21310 assert_eq!(
21311 keys,
21312 vec![
21313 COMPUTEUNIT_SPEC_KEY_MODULE,
21314 COMPUTEUNIT_SPEC_KEY_TRIGGER,
21315 COMPUTEUNIT_SPEC_KEY_CAPABILITIES,
21316 ],
21317 "spec.* keys must appear in source-Mapping insertion order",
21318 );
21319 }
21320
21321 #[test]
21322 fn servico_spec_and_m2_overlay_entries_appends_m2_slots_after_spec_in_canonical_key_order() {
21323 // Bracket the second-half of the composition — the M2 overlay
21324 // walk lands after the spec.* splice, in BTreeMap-key ordering
21325 // (behavior → limits → upgradeFrom).
21326 let cu = cu_yaml_with_spec_fields(
21327 " module:\n source: oci://ghcr.io/pleme-io/hello-rio:v0.1.0\n",
21328 );
21329 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
21330 let mut c = bare_servico();
21331 c.limits = Some(LimitsSpec {
21332 memory: Some(64 * 1024 * 1024),
21333 ..Default::default()
21334 });
21335 c.behavior = Some(BehaviorSpec {
21336 on_init: Some(PathBuf::from("lib/init.lisp")),
21337 ..Default::default()
21338 });
21339 c.upgrade_from = vec![UpgradeFromEntry {
21340 from: "0.0.9".into(),
21341 instructions: vec![UpgradeInstruction::LoadModule {
21342 module: "hello-rio".into(),
21343 }],
21344 }];
21345 let out = servico_spec_and_m2_overlay_entries(&c, spec).unwrap();
21346 let keys: Vec<&str> = out.iter().map(|(k, _)| k.as_str()).collect();
21347 assert_eq!(
21348 keys,
21349 vec![
21350 COMPUTEUNIT_SPEC_KEY_MODULE,
21351 M2_KEY_BEHAVIOR,
21352 M2_KEY_LIMITS,
21353 M2_KEY_UPGRADE_FROM,
21354 ],
21355 "M2 slots must land after the spec.* splice, in canonical \
21356 BTreeMap key order",
21357 );
21358 }
21359
21360 #[test]
21361 fn servico_spec_and_m2_overlay_entries_or_insert_precedence_spec_wins_on_collision() {
21362 // The or_insert precedence rule the two prior inline blocks
21363 // shared: when the ComputeUnit YAML's `spec.*` sub-mapping
21364 // already carries the M2 slot's key (an author-authored
21365 // ComputeUnit `spec.limits` overriding the manifest-derived
21366 // `caixa.limits` overlay), the spec.* value stays and the M2
21367 // overlay's value is skipped. Regression-guards against a
21368 // future reversal ("M2 wins on collision") silently changing
21369 // the composition without an explicit slot-precedence flip at
21370 // the helper.
21371 let cu = cu_yaml_with_spec_fields(
21372 " limits:\n memory: from-spec\n module:\n source: oci://x\n",
21373 );
21374 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
21375 let mut c = bare_servico();
21376 c.limits = Some(LimitsSpec {
21377 memory: Some(64 * 1024 * 1024),
21378 ..Default::default()
21379 });
21380 let out = servico_spec_and_m2_overlay_entries(&c, spec).unwrap();
21381 let limits_entries: Vec<&(String, serde_yaml::Value)> =
21382 out.iter().filter(|(k, _)| k == M2_KEY_LIMITS).collect();
21383 assert_eq!(
21384 limits_entries.len(),
21385 1,
21386 "on collision the M2 overlay's `limits` entry must be \
21387 filtered out — spec.* wins, and appears exactly once",
21388 );
21389 assert_eq!(
21390 limits_entries[0]
21391 .1
21392 .get(M2_LIMITS_KEY_MEMORY)
21393 .and_then(|v| v.as_str()),
21394 Some("from-spec"),
21395 "the surviving `limits` entry must carry the spec.* value, \
21396 not the manifest-derived M2 overlay's value",
21397 );
21398 }
21399
21400 #[test]
21401 fn servico_spec_and_m2_overlay_entries_short_circuits_on_non_mapping_spec() {
21402 // Sibling `string_keyed_entries` docstring pins the
21403 // non-Mapping short-circuit; extend it to the composed splice
21404 // — a spec that isn't a Mapping yields zero spec.* entries,
21405 // and only the M2 overlay contributes. Bracket-guard against a
21406 // future refactor that swaps `string_keyed_entries` for a
21407 // stricter parser silently dropping the M2 half too.
21408 let non_mapping_spec = serde_yaml::Value::String("not-a-mapping".into());
21409 let mut c = bare_servico();
21410 c.limits = Some(LimitsSpec {
21411 memory: Some(64 * 1024 * 1024),
21412 ..Default::default()
21413 });
21414 let out = servico_spec_and_m2_overlay_entries(&c, &non_mapping_spec).unwrap();
21415 let keys: Vec<&str> = out.iter().map(|(k, _)| k.as_str()).collect();
21416 assert_eq!(
21417 keys,
21418 vec![M2_KEY_LIMITS],
21419 "non-Mapping spec short-circuits the spec.* splice; the M2 \
21420 overlay still contributes its filled slots",
21421 );
21422 }
21423
21424 #[test]
21425 fn servico_spec_and_m2_overlay_entries_matches_hand_written_composition() {
21426 // Cross-check the lifted composition against the hand-written
21427 // two-loop shape the two prior inline blocks carried. A drift
21428 // between the helper and the inline composition would silently
21429 // emit a different key set / ordering / precedence at every
21430 // routed renderer — pin the equivalence so the helper stays a
21431 // drop-in replacement for both.
21432 let cu = cu_yaml_with_spec_fields(
21433 " module:\n source: oci://ghcr.io/pleme-io/hello-rio:v0.1.0\n \
21434 trigger:\n service: {port: 8080}\n",
21435 );
21436 let spec = cu.get(KUBE_KEY_SPEC).unwrap();
21437 let mut c = bare_servico();
21438 c.limits = Some(LimitsSpec {
21439 memory: Some(32 * 1024 * 1024),
21440 ..Default::default()
21441 });
21442 c.behavior = Some(BehaviorSpec {
21443 on_call: Some(PathBuf::from("lib/handlers.lisp")),
21444 ..Default::default()
21445 });
21446
21447 let via_helper = servico_spec_and_m2_overlay_entries(&c, spec).unwrap();
21448
21449 let mut via_inline: Vec<(String, serde_yaml::Value)> = Vec::new();
21450 let mut seen: std::collections::HashSet<String> = std::collections::HashSet::new();
21451 for (k, v) in string_keyed_entries(spec) {
21452 seen.insert(k.to_string());
21453 via_inline.push((k.to_string(), v.clone()));
21454 }
21455 for (key, value) in servico_m2_overlay(&c).unwrap() {
21456 if !seen.contains(key) {
21457 via_inline.push((key.to_string(), value));
21458 }
21459 }
21460
21461 assert_eq!(
21462 via_helper, via_inline,
21463 "servico_spec_and_m2_overlay_entries must byte-equal the \
21464 hand-written two-loop composition (spec.* splice + M2 \
21465 overlay with or_insert precedence) the two prior inline \
21466 call sites carried",
21467 );
21468 }
21469
21470 #[test]
21471 fn pleme_label_consts_share_canonical_prefix() {
21472 // Single-source-of-truth invariant: every pleme-io label key
21473 // is `<PLEME_LABEL_PREFIX>/<axis>`. A future label-namespace
21474 // rebrand is a one-line PLEME_LABEL_PREFIX edit + this test
21475 // pins the contract that no other label leaks past the lift.
21476 for k in [LABEL_APLICACAO, LABEL_PROGRAM, LABEL_CONTRATO] {
21477 assert!(
21478 k.starts_with(PLEME_LABEL_PREFIX),
21479 "label key {k:?} must share the {PLEME_LABEL_PREFIX:?} prefix"
21480 );
21481 // Each label is `<prefix>/<axis>` — the suffix is non-empty
21482 // (the `/` separator is followed by the axis name).
21483 let suffix = k.strip_prefix(PLEME_LABEL_PREFIX).unwrap();
21484 assert!(suffix.starts_with('/'));
21485 assert!(suffix.len() > 1, "axis name must be non-empty for {k:?}");
21486 }
21487 }
21488
21489 #[test]
21490 fn pleme_label_consts_have_expected_canonical_values() {
21491 // Pin the actual string values so a typo in the lift can't
21492 // silently rebrand the whole pleme-io label namespace. These
21493 // strings are part of the cluster-side contract with the
21494 // lareira-fleet-programs chart + Cilium identity layer + Hubble
21495 // flow attribution; changing any of them is a coordinated
21496 // multi-repo migration, not an incidental edit.
21497 assert_eq!(PLEME_LABEL_PREFIX, "pleme.pleme.io");
21498 assert_eq!(LABEL_APLICACAO, "pleme.pleme.io/aplicacao");
21499 assert_eq!(LABEL_PROGRAM, "pleme.pleme.io/program");
21500 assert_eq!(LABEL_CONTRATO, "pleme.pleme.io/contrato");
21501 }
21502
21503 #[test]
21504 fn default_namespace_pins_canonical_value() {
21505 // Pin the actual string so a typo in this lift can't silently
21506 // rebrand the cluster-side namespace every renderer emits
21507 // into. The string is part of the cluster-side contract with
21508 // the lareira-fleet-programs aggregator chart, the per-cluster
21509 // CiliumNetworkPolicy `endpointSelector` namespace scope, the
21510 // Gateway / HTTPRoute apply namespace, and the future M4
21511 // `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's apply
21512 // namespace; changing it is a coordinated multi-repo migration
21513 // (the per-cluster k8s repo's namespaces, every
21514 // lareira-fleet-programs HelmRelease's targetNamespace, every
21515 // ComputeUnit's `metadata.namespace`), not an incidental edit.
21516 // Peer to `pleme_label_consts_have_expected_canonical_values`
21517 // on the canonical-string-value-pin axis for the
21518 // `PLEME_LABEL_PREFIX` / `LABEL_*` constants.
21519 assert_eq!(DEFAULT_NAMESPACE, "tatara-system");
21520 }
21521
21522 #[test]
21523 fn default_flux_system_namespace_pins_canonical_value() {
21524 // Pin the actual string so a typo in this lift can't silently
21525 // rebrand the FluxCD installation namespace the rendered
21526 // `kustomization.yaml`'s `metadata.namespace` /
21527 // `spec.sourceRef.name` axes consume. The string is part of the
21528 // cluster-side contract with the `flux bootstrap` pipeline (the
21529 // bootstrap convention names the `GitRepository` after the
21530 // installation namespace, so both axes are the same load-bearing
21531 // string), the `kustomize-controller` watch-window scope (a
21532 // drifted value sits outside the controller's watch window and
21533 // is never reconciled), and the per-cluster k8s repo's flux
21534 // bootstrap manifests; changing it is a coordinated multi-repo
21535 // migration, not an incidental edit. Peer to
21536 // `default_namespace_pins_canonical_value` on the
21537 // canonical-string-value-pin axis for the workload-side
21538 // [`DEFAULT_NAMESPACE`] constant.
21539 assert_eq!(DEFAULT_FLUX_SYSTEM_NAMESPACE, "flux-system");
21540 }
21541
21542 #[test]
21543 fn default_flux_system_namespace_is_a_valid_dns_1123_label() {
21544 // Cross-axis invariant: the FluxCD installation namespace lands
21545 // as `metadata.namespace` on every emitted `Kustomization`
21546 // resource and as `spec.sourceRef.name` (a K8s resource name
21547 // under the same DNS-1123 floor), and the K8s apiserver
21548 // enforces the DNS-1123 label rule on both. Pinning this here
21549 // means a future rebrand on the canonical lift can't silently
21550 // land a value the apiserver refuses at the *first*
21551 // `kustomization.yaml` apply against a cluster, far from the
21552 // rebrand commit's source — the typed [`is_dns_1123_label`]
21553 // floor rejects it at caixa-core build time on the canonical
21554 // lift, before any renderer consumes the value. Same shape as
21555 // `default_namespace_is_a_valid_dns_1123_label` on the
21556 // workload-side [`DEFAULT_NAMESPACE`] axis.
21557 assert!(
21558 is_dns_1123_label(DEFAULT_FLUX_SYSTEM_NAMESPACE).is_ok(),
21559 "DEFAULT_FLUX_SYSTEM_NAMESPACE {DEFAULT_FLUX_SYSTEM_NAMESPACE:?} must be a valid \
21560 DNS-1123 label — every K8s apiserver-side schema enforces \
21561 this rule on `metadata.namespace`"
21562 );
21563 }
21564
21565 #[test]
21566 fn default_flux_reconcile_interval_pins_canonical_value() {
21567 // Pin the actual string so a typo in this lift can't silently
21568 // rebrand the substrate-side default Flux v2 reconcile-poll
21569 // cadence duration scalar the substrate's per-caixa
21570 // `cluster_bundle` renderer seeds into every emitted per-caixa
21571 // Flux v2 CR (GitRepository / HelmRelease / Kustomization) at
21572 // its `spec.interval` axis when the operator doesn't pin a per-
21573 // caixa override. The string is part of the cluster-side
21574 // contract with the Flux v2 source-controller / helm-controller
21575 // / kustomize-controller trio: each controller's per-CR admission
21576 // gate parses the value via `metav1.ParseDuration` before
21577 // installing the per-CR watch, and the resulting cadence pins
21578 // the per-CR reconcile-freshness / cluster-load tradeoff every
21579 // substrate-side Flux v2 pipeline runs at. Changing this value
21580 // is a coordinated substrate-side reconcile-cadence promotion
21581 // (a `10m` → `5m` migration once lower-latency-poll optimizations
21582 // ship, a `10m` → `15m` migration on cost-optimized clusters
21583 // where per-CR source-controller poll cost outweighs the
21584 // reconcile-freshness gain), not an incidental edit. Peer to
21585 // `default_namespace_pins_canonical_value` and
21586 // `default_gateway_class_name_pins_canonical_value` on the
21587 // canonical-substrate-default-load-bearing-scalar pin surface.
21588 assert_eq!(DEFAULT_FLUX_RECONCILE_INTERVAL, "10m");
21589 }
21590
21591 #[test]
21592 fn default_flux_reconcile_interval_is_a_valid_metav1_duration_scalar() {
21593 // Cross-axis grammar invariant: the Flux v2 controller-side per-
21594 // CR admission gate parses the reconcile-poll cadence scalar via
21595 // `metav1.ParseDuration` before installing the per-CR watch. The
21596 // Go-duration-format grammar is non-empty, ASCII, and structured
21597 // as `<digits><unit>[<digits><unit>...]` where each unit is one
21598 // of `{ns, us, µs, ms, s, m, h}`. Pin a floor that catches the
21599 // canonical drift footguns — an empty scalar (`""` — admission
21600 // gate rejects), a non-ASCII-alphanumeric byte (`"10 m"` — the
21601 // whitespace defeats the parser), a missing-unit scalar (`"10"`
21602 // — the parser rejects for lack of a unit suffix), or a leading-
21603 // non-digit scalar (`"m10"` — the parser rejects for lack of a
21604 // leading magnitude). A future rebrand on the canonical lift
21605 // that lands a value outside the Go-duration-format grammar
21606 // would surface here at caixa-core build time on the canonical
21607 // lift, before any renderer consumes the value. Same shape as
21608 // `default_namespace_is_a_valid_dns_1123_label` /
21609 // `default_flux_system_namespace_is_a_valid_dns_1123_label` /
21610 // `default_gateway_class_name_is_a_valid_dns_1123_label` on the
21611 // peer canonical-substrate-default-grammar-floor surface.
21612 let v = DEFAULT_FLUX_RECONCILE_INTERVAL;
21613 assert!(
21614 !v.is_empty(),
21615 "DEFAULT_FLUX_RECONCILE_INTERVAL {v:?} must be non-empty \
21616 per the Flux v2 controller-side `metav1.ParseDuration` \
21617 admission gate"
21618 );
21619 assert!(
21620 v.chars().all(|c| c.is_ascii_alphanumeric()),
21621 "DEFAULT_FLUX_RECONCILE_INTERVAL {v:?} must be ASCII-\
21622 alphanumeric throughout per the Go-duration-format grammar \
21623 — no whitespace / separator bytes the `metav1.ParseDuration` \
21624 admission gate would reject"
21625 );
21626 let first = v.chars().next().expect("non-empty");
21627 assert!(
21628 first.is_ascii_digit(),
21629 "DEFAULT_FLUX_RECONCILE_INTERVAL {v:?} first byte {first:?} \
21630 must be an ASCII digit per the Go-duration-format grammar \
21631 — the leading magnitude precedes the unit suffix; a leading \
21632 non-digit defeats `metav1.ParseDuration`"
21633 );
21634 let last = v.chars().next_back().expect("non-empty");
21635 assert!(
21636 last.is_ascii_alphabetic() && last.is_ascii_lowercase(),
21637 "DEFAULT_FLUX_RECONCILE_INTERVAL {v:?} last byte {last:?} \
21638 must be an ASCII lowercase alphabetic unit suffix per the \
21639 Go-duration-format grammar — the trailing unit follows the \
21640 magnitude; an unterminated magnitude defeats \
21641 `metav1.ParseDuration`"
21642 );
21643 }
21644
21645 #[test]
21646 fn default_flux_chart_source_subpath_pins_canonical_value() {
21647 // Pin the actual scalar so a typo in this lift can't silently
21648 // rebrand the substrate-side default Flux v2
21649 // `HelmRelease.spec.chart.spec.chart` chart-directory-in-
21650 // GitRepository-source sub-path the substrate's per-caixa
21651 // `cluster_bundle` renderer seeds into every emitted per-caixa
21652 // `helmrelease.yaml` document. The value is part of the
21653 // cluster-side contract with the Flux v2 helm-controller (the
21654 // per-CR chart-open loop uses this to locate the
21655 // `Chart.yaml` + `values.yaml` pair inside the paired
21656 // GitRepository clone root); changing it is a coordinated
21657 // substrate-side chart-directory-in-git-source promotion
21658 // (a `"chart"` → `"charts"` migration on a per-caixa multi-chart
21659 // layout landing, a `"chart"` → `"helm"` migration on a
21660 // cross-language convention alignment, a `"chart"` → `"deploy"`
21661 // migration on a per-caixa-deploy-directory naming migration),
21662 // not an incidental edit. Peer to
21663 // `default_flux_reconcile_interval_pins_canonical_value` +
21664 // `flux_helmrelease_remediation_retries_default_pins_canonical_value`
21665 // on the canonical-Flux-v2-per-CR-substrate-default-scalar pin
21666 // surface.
21667 assert_eq!(DEFAULT_FLUX_CHART_SOURCE_SUBPATH, "chart");
21668 }
21669
21670 #[test]
21671 fn default_flux_chart_source_subpath_is_a_valid_relative_directory_scalar() {
21672 // Cross-axis grammar invariant: the Flux v2 source-controller
21673 // resolves the per-CR `HelmRelease.spec.chart.spec.chart` scalar
21674 // as a directory path relative to the paired `GitRepository`
21675 // clone root. Pin a floor that catches the canonical drift
21676 // footguns — an empty scalar (`""` — the source-controller-side
21677 // per-CR chart-open loop rejects for lack of a target directory),
21678 // a leading-separator scalar (`"/chart"` — the source-controller
21679 // rejects for the absolute-path shape breaking the relative-path
21680 // composition against the per-clone-root anchor), a non-ASCII
21681 // byte (a UTF-8 multi-byte name defeating the per-clone-root
21682 // filesystem name resolution on the source-controller pod's
21683 // filesystem layer), or a leading whitespace / dot byte (`" chart"`
21684 // / `".chart"` — surface as either a "directory not found" per-
21685 // CR error or, worse, a silent match against a hidden dot-file
21686 // sibling of the intended chart directory). A future rebrand on
21687 // the canonical lift that lands a value outside the grammar
21688 // would surface here at caixa-core build time on the canonical
21689 // lift, before any renderer consumes the value. Same shape as
21690 // `default_flux_reconcile_interval_is_a_valid_metav1_duration_scalar`
21691 // on the peer canonical-substrate-default-grammar-floor surface.
21692 let v = DEFAULT_FLUX_CHART_SOURCE_SUBPATH;
21693 assert!(
21694 !v.is_empty(),
21695 "DEFAULT_FLUX_CHART_SOURCE_SUBPATH {v:?} must be non-empty \
21696 per the Flux v2 source-controller-side per-CR chart-open \
21697 loop's requirement of a target directory"
21698 );
21699 assert!(
21700 v.is_ascii(),
21701 "DEFAULT_FLUX_CHART_SOURCE_SUBPATH {v:?} must be ASCII \
21702 throughout — a non-ASCII multi-byte name defeats the per-\
21703 clone-root filesystem name resolution on the source-\
21704 controller pod's filesystem layer"
21705 );
21706 let first = v.chars().next().expect("non-empty");
21707 assert!(
21708 !matches!(first, '/' | '.' | ' ' | '\t'),
21709 "DEFAULT_FLUX_CHART_SOURCE_SUBPATH {v:?} first byte {first:?} \
21710 must not be a leading separator (`/`), leading dot (`.`), or \
21711 leading whitespace — a leading separator breaks the relative-\
21712 path composition against the per-clone-root anchor, a leading \
21713 dot risks silent matches against hidden dot-file siblings, and \
21714 leading whitespace defeats the per-clone-root filesystem name \
21715 resolution"
21716 );
21717 }
21718
21719 #[test]
21720 fn flux_helmrelease_remediation_retries_default_pins_canonical_value() {
21721 // Pin the actual scalar so a typo in this lift can't silently
21722 // rebrand the substrate-side default Flux v2
21723 // `HelmRelease.spec.{install,upgrade}.remediation.retries` retry-
21724 // count ceiling the substrate's per-caixa `cluster_bundle`
21725 // renderer seeds into every emitted per-caixa `helmrelease.yaml`
21726 // document under both the install-path and the upgrade-path
21727 // remediation blocks. The value is part of the cluster-side
21728 // contract with the Flux v2 helm-controller (the per-CR
21729 // remediation loop uses this as the ceiling on the number of
21730 // Helm-install / Helm-upgrade re-attempts before the controller
21731 // marks the `HelmRelease` `Ready: False` and stops retrying);
21732 // changing it is a coordinated substrate-side retry-ceiling
21733 // promotion (a `3` → `5` migration once per-caixa idempotency
21734 // invariants tighten and higher-retry recovery from transient
21735 // apiserver / registry / oci-source flakes becomes safe, a `3` →
21736 // `1` migration on hardened per-caixa pipelines where a failed
21737 // apply should escalate to operator-attention rather than mask
21738 // under further retries), not an incidental edit. Peer to
21739 // `default_flux_reconcile_interval_pins_canonical_value` on the
21740 // canonical-Flux-v2-per-CR-substrate-default-scalar pin surface.
21741 assert_eq!(FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT, 3);
21742 }
21743
21744 #[test]
21745 fn flux_helmrelease_remediation_retries_default_is_a_bounded_positive_scalar() {
21746 // Cross-axis invariant: the Flux v2 `HelmRelease.spec.{install,
21747 // upgrade}.remediation.retries` OpenAPI schema types the field
21748 // as a signed 64-bit integer with a documented sentinel `-1`
21749 // meaning "retry indefinitely". The substrate opts out of the
21750 // unbounded-retry sentinel by declaring the canonical default as
21751 // a positive `u32` — the type itself rules out `-1` at
21752 // caixa-core build time, so a future rebrand on this lift cannot
21753 // silently land the "retry forever" sentinel by construction
21754 // (which would let a persistently-failing per-caixa chart apply
21755 // consume Flux v2 helm-controller reconcile-loop cycles
21756 // indefinitely, masking under further retries rather than
21757 // surfacing at the `HelmRelease.status.conditions[]` axis the
21758 // substrate's downstream reconciliation-topology consumer
21759 // watches). Pin the positive-scalar floor + a substrate-side
21760 // "sane retry ceiling" upper bound (the same 100-attempt hard
21761 // cap the peer `POLICY_RETRIES_MAX` per-`:politicas :retries`
21762 // axis carries; a substrate that seeds a per-CR default above
21763 // that ceiling is structurally a footgun by the same
21764 // "unbounded-retry masks the underlying failure" argument that
21765 // motivates the mesh-policy retries cap). Same shape as
21766 // `default_flux_reconcile_interval_is_a_valid_metav1_duration_scalar`
21767 // on the peer canonical-substrate-default-grammar-floor surface.
21768 let v = FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT;
21769 assert!(
21770 v > 0,
21771 "FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT {v} must be strictly \
21772 positive per the substrate's opt-out from the Flux v2 \
21773 `retries: -1` unbounded-retry sentinel — the `u32` type rules \
21774 out the sentinel, and a zero-retries default is structurally \
21775 a `remediation:` sub-block that never fires the retry path it \
21776 is declaring"
21777 );
21778 assert!(
21779 v <= 100,
21780 "FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT {v} must be within \
21781 the substrate's canonical retry-ceiling upper bound (100) — a \
21782 per-CR default above that ceiling silently masks the underlying \
21783 chart-apply failure under further retries rather than surfacing \
21784 it at the `HelmRelease.status.conditions[]` axis the substrate's \
21785 downstream reconciliation-topology consumer watches, the same \
21786 argument that motivates the peer `POLICY_RETRIES_MAX` per-\
21787 `:politicas :retries` axis cap"
21788 );
21789 }
21790
21791 #[test]
21792 fn flux_helmrelease_key_remediation_pins_canonical_value() {
21793 // Pin the actual string so a typo in this lift can't silently
21794 // rebrand the substrate-side Flux v2
21795 // `HelmRelease.spec.{install,upgrade}.remediation` sub-container-
21796 // axis key the substrate's per-caixa `cluster_bundle` renderer
21797 // seeds into every emitted per-caixa `helmrelease.yaml` document
21798 // at both the install-path + upgrade-path per-CR remediation
21799 // sub-block-header positions. The string is part of the cluster-
21800 // side contract with the Flux v2 helm-controller (the controller's
21801 // per-CR remediation loop reaches the retry-cap scalar through
21802 // this exact sub-container axis; a drifted sub-container-key
21803 // silently strips the entire per-path remediation block from the
21804 // emitted per-CR document, leaving the helm-controller to fall
21805 // back to the Flux v2 upstream defaults for the whole remediation
21806 // surface rather than the substrate's chosen ceiling, with no
21807 // diagnostic naming the container-axis-key-drift root cause).
21808 // Changing it is a coordinated Flux v3 CRD-schema-rebrand
21809 // migration alongside the upstream `helm-controller` deprecation
21810 // cycle (candidates like `recovery` / `retryPolicy` /
21811 // `errorHandling` that upstream Flux v3 roadmap floats in the
21812 // migration prose), not an incidental edit. Peer to
21813 // `flux_helmrelease_remediation_retries_default_pins_canonical_value`
21814 // on the sibling scalar-value half + the sibling
21815 // [`FLUX_HELMRELEASE_KEY_RETRIES`] leaf-scalar-key half of the
21816 // same per-path retry-cap declaration triple.
21817 assert_eq!(FLUX_HELMRELEASE_KEY_REMEDIATION, "remediation");
21818 }
21819
21820 #[test]
21821 fn flux_helmrelease_key_remediation_is_a_valid_dns_1123_label() {
21822 // Cross-axis invariant: every Flux v2 `HelmRelease` CRD-schema
21823 // sub-block-header key resolves through the K8s apiserver's
21824 // OpenAPI-schema-side identifier grammar, whose per-field key
21825 // axis is a subset of the DNS-1123-label grammar (lowercase
21826 // alphanumerics + hyphens, non-empty, ≤63 bytes). Pinning the
21827 // canonical `remediation` value against the typed
21828 // [`is_dns_1123_label`] floor rules out grammar drift on this
21829 // lift at caixa-core build time — a future rebrand landing a
21830 // value outside the DNS-1123-label subset (a leading digit, an
21831 // underscore, an uppercase byte, a `.` byte, or empty) would
21832 // surface here on the canonical lift, before any renderer
21833 // consumes the value and before any per-caixa Flux v2 CR reaches
21834 // the apiserver's OpenAPI-schema-side per-field admission gate.
21835 // Same shape as `default_gateway_class_name_is_a_valid_dns_1123_label`
21836 // on the peer canonical-CRD-schema-grammar-floor surface.
21837 assert!(
21838 is_dns_1123_label(FLUX_HELMRELEASE_KEY_REMEDIATION).is_ok(),
21839 "FLUX_HELMRELEASE_KEY_REMEDIATION {FLUX_HELMRELEASE_KEY_REMEDIATION:?} \
21840 must be a valid DNS-1123 label — every K8s apiserver-side \
21841 OpenAPI-schema-per-field-key axis is a subset of that grammar, \
21842 and the Flux v2 `HelmRelease` CRD schema is no exception"
21843 );
21844 }
21845
21846 #[test]
21847 fn flux_helmrelease_key_install_pins_canonical_value() {
21848 // Pin the actual string so a typo in this lift can't silently
21849 // rebrand the Flux v2 `HelmRelease.spec.install` per-CR helm-
21850 // action-phase discriminator parent-container-axis-key the
21851 // rendered `helmrelease.yaml` document mounts its per-CR first-
21852 // time chart apply phase-block under. The string is part of the
21853 // cluster-side contract with the upstream Flux v2 helm-
21854 // controller — the helm-controller's per-CR phase-dispatch loop
21855 // reaches the install-path phase block through this exact parent-
21856 // container axis; a drifted parent-container-key silently strips
21857 // the entire install-path phase block from the emitted per-CR
21858 // document, leaving the helm-controller to fall back to the Flux
21859 // v2 upstream defaults for the whole install-path phase surface
21860 // rather than the substrate's chosen per-CR install-path knob-set
21861 // (the `createNamespace` seeder never fires, the per-CR retry-cap
21862 // ceiling silently drops off the emitted document), with no
21863 // diagnostic naming the phase-discriminator-drift root cause.
21864 // Changing it is a coordinated Flux v3 CRD-schema-rebrand
21865 // migration alongside the upstream `helm-controller` deprecation
21866 // cycle (candidates like `initialize` / `apply` / `create` /
21867 // `first-run` that upstream Flux v3 roadmap floats in the
21868 // migration prose), not an incidental edit. Peer to
21869 // `flux_helmrelease_key_upgrade_pins_canonical_value` on the
21870 // sibling per-CR upgrade-path phase-discriminator parent-
21871 // container-axis-key half of the same per-CR helm-action-phase
21872 // discriminator parent-container-axis-key pair + the sibling
21873 // [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-axis-key
21874 // hosted beneath both parent-container-axis-keys.
21875 assert_eq!(FLUX_HELMRELEASE_KEY_INSTALL, "install");
21876 }
21877
21878 #[test]
21879 fn flux_helmrelease_key_install_is_a_valid_dns_1123_label() {
21880 // Cross-axis invariant: every Flux v2 `HelmRelease` CRD-schema
21881 // sub-block-header key resolves through the K8s apiserver's
21882 // OpenAPI-schema-side identifier grammar, whose per-field key
21883 // axis is a subset of the DNS-1123-label grammar (lowercase
21884 // alphanumerics + hyphens, non-empty, ≤63 bytes). Pinning the
21885 // canonical `install` value against the typed
21886 // [`is_dns_1123_label`] floor rules out grammar drift on this
21887 // lift at caixa-core build time — a future rebrand landing a
21888 // value outside the DNS-1123-label subset (a leading digit, an
21889 // underscore, an uppercase byte, a `.` byte, or empty) would
21890 // surface here on the canonical lift, before any renderer
21891 // consumes the value and before any per-caixa Flux v2 CR reaches
21892 // the apiserver's OpenAPI-schema-side per-field admission gate.
21893 // Same shape as `flux_helmrelease_key_remediation_is_a_valid_
21894 // dns_1123_label` on the sibling per-CR sub-container-axis-key
21895 // grammar-floor surface.
21896 assert!(
21897 is_dns_1123_label(FLUX_HELMRELEASE_KEY_INSTALL).is_ok(),
21898 "FLUX_HELMRELEASE_KEY_INSTALL {FLUX_HELMRELEASE_KEY_INSTALL:?} \
21899 must be a valid DNS-1123 label — every K8s apiserver-side \
21900 OpenAPI-schema-per-field-key axis is a subset of that grammar, \
21901 and the Flux v2 `HelmRelease` CRD schema is no exception"
21902 );
21903 }
21904
21905 #[test]
21906 fn flux_helmrelease_key_upgrade_pins_canonical_value() {
21907 // Pin the actual string so a typo in this lift can't silently
21908 // rebrand the Flux v2 `HelmRelease.spec.upgrade` per-CR helm-
21909 // action-phase discriminator parent-container-axis-key the
21910 // rendered `helmrelease.yaml` document mounts its per-CR
21911 // subsequent-per-version chart re-apply phase-block under. The
21912 // string is part of the cluster-side contract with the upstream
21913 // Flux v2 helm-controller — the helm-controller's per-CR phase-
21914 // dispatch loop reaches the upgrade-path phase block through this
21915 // exact parent-container axis on every per-version chart re-apply
21916 // after the initial install-path phase completes; a drifted
21917 // parent-container-key silently strips the entire upgrade-path
21918 // phase block from the emitted per-CR document, leaving the
21919 // helm-controller to fall back to the Flux v2 upstream defaults
21920 // for the whole upgrade-path phase surface rather than the
21921 // substrate's chosen per-CR upgrade-path knob-set (the
21922 // `remediateLastFailure` toggle never fires, the per-CR retry-
21923 // cap ceiling silently drops off the emitted document), with no
21924 // diagnostic naming the phase-discriminator-drift root cause.
21925 // Changing it is a coordinated Flux v3 CRD-schema-rebrand
21926 // migration alongside the upstream `helm-controller` deprecation
21927 // cycle (candidates like `reapply` / `reconcile` / `update` /
21928 // `promote` that upstream Flux v3 roadmap floats in the
21929 // migration prose), not an incidental edit. Peer to
21930 // `flux_helmrelease_key_install_pins_canonical_value` on the
21931 // sibling per-CR install-path phase-discriminator parent-
21932 // container-axis-key half of the same per-CR helm-action-phase
21933 // discriminator parent-container-axis-key pair.
21934 assert_eq!(FLUX_HELMRELEASE_KEY_UPGRADE, "upgrade");
21935 }
21936
21937 #[test]
21938 fn flux_helmrelease_key_upgrade_is_a_valid_dns_1123_label() {
21939 // Cross-axis invariant: every Flux v2 `HelmRelease` CRD-schema
21940 // sub-block-header key resolves through the K8s apiserver's
21941 // OpenAPI-schema-side identifier grammar, whose per-field key
21942 // axis is a subset of the DNS-1123-label grammar. Pinning the
21943 // canonical `upgrade` value against the typed
21944 // [`is_dns_1123_label`] floor rules out grammar drift on this
21945 // lift at caixa-core build time. Peer to
21946 // `flux_helmrelease_key_install_is_a_valid_dns_1123_label` on
21947 // the sibling install-path phase-discriminator grammar-floor
21948 // surface + `flux_helmrelease_key_remediation_is_a_valid_dns_
21949 // 1123_label` on the sibling per-CR sub-container-axis-key
21950 // grammar-floor surface — same DNS-1123-label subset governs
21951 // every apiserver-side per-field-key axis, so every peer per-CR
21952 // sub-block-header lift carries the same grammar-floor pin.
21953 assert!(
21954 is_dns_1123_label(FLUX_HELMRELEASE_KEY_UPGRADE).is_ok(),
21955 "FLUX_HELMRELEASE_KEY_UPGRADE {FLUX_HELMRELEASE_KEY_UPGRADE:?} \
21956 must be a valid DNS-1123 label — every K8s apiserver-side \
21957 OpenAPI-schema-per-field-key axis is a subset of that grammar, \
21958 and the Flux v2 `HelmRelease` CRD schema is no exception"
21959 );
21960 }
21961
21962 #[test]
21963 fn flux_helmrelease_key_install_and_upgrade_stay_independent_axes() {
21964 // The two per-CR helm-action-phase discriminator parent-
21965 // container-axis-keys name distinct helm-controller-side phases
21966 // — install-path first-time chart apply vs upgrade-path per-
21967 // version chart re-apply — even though both host the same
21968 // sibling [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-
21969 // axis-key beneath them. Pin that the two consts carry distinct
21970 // byte-sequences so a future rebrand on either arm can't
21971 // silently coalesce onto the peer arm (a
21972 // `FLUX_HELMRELEASE_KEY_INSTALL = "upgrade"` typo would flip
21973 // every substrate-side per-CR first-time chart apply phase
21974 // block onto the upgrade-path phase key silently — the install-
21975 // path becomes the upgrade-path at every emit site, and the
21976 // helm-controller reconciles both phase blocks under the same
21977 // parent-container-axis-key, silently dropping either the
21978 // install-path or the upgrade-path per-CR knob-set with no
21979 // diagnostic naming the phase-discriminator-coalesce root
21980 // cause). The per-CR helm-action-phase discriminator pair must
21981 // always resolve to distinct emitted parent-container-keys.
21982 assert_ne!(
21983 FLUX_HELMRELEASE_KEY_INSTALL, FLUX_HELMRELEASE_KEY_UPGRADE,
21984 "the per-CR install-path and upgrade-path helm-action-phase \
21985 discriminator parent-container-axis-keys must remain byte-\
21986 distinct — a coalesce onto one value silently drops either \
21987 the install-path or the upgrade-path per-CR knob-set from \
21988 every emitted `HelmRelease` document"
21989 );
21990 }
21991
21992 #[test]
21993 fn flux_helmrelease_key_remediate_last_failure_pins_canonical_value() {
21994 // Pin the actual string so a typo in this lift can't silently
21995 // rebrand the Flux v2 `HelmRelease.spec.upgrade.remediation
21996 // .remediateLastFailure` upgrade-path-only per-CR remediation-
21997 // toggle leaf-scalar-key the substrate's per-caixa `cluster_bundle`
21998 // renderer seeds to `true` into every emitted per-caixa
21999 // `helmrelease.yaml` document under the sibling
22000 // [`FLUX_HELMRELEASE_KEY_UPGRADE`] per-CR upgrade-path phase-
22001 // discriminator parent-container-axis-key's nested
22002 // [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-axis-key. The
22003 // string is part of the cluster-side contract with the upstream
22004 // Flux v2 helm-controller — the controller's per-CR upgrade-path
22005 // remediation loop reaches the post-retry-exhaustion rollback
22006 // toggle through this exact leaf; a drifted leaf-scalar-key
22007 // silently strips the substrate's chosen post-retry-exhaustion
22008 // rollback semantic from every emitted per-caixa `HelmRelease`
22009 // document, leaving the helm-controller to leave every terminally-
22010 // failed upgrade in the failed state without rolling back to the
22011 // prior last-known-good release the substrate's "no chart apply
22012 // leaves a per-caixa CR in a stalled, unremediated state"
22013 // MESH-COMPOSITION.md §V guarantee mandates, with no diagnostic
22014 // naming the remediation-toggle-drift root cause. Changing it is
22015 // a coordinated Flux v3 CRD-schema-rebrand migration alongside
22016 // the upstream `helm-controller` deprecation cycle (candidates
22017 // like `rollbackOnFailure` / `remediateOnFailure` /
22018 // `recoverLastFailure` that upstream Flux v3 roadmap floats in
22019 // the migration prose), not an incidental edit. Peer to
22020 // `flux_helmrelease_key_retries_pins_canonical_value` on the
22021 // sibling per-CR retry-cap leaf-scalar-key half of the same
22022 // upgrade-path per-CR remediation block leaf-scalar-key pair.
22023 assert_eq!(
22024 FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE,
22025 "remediateLastFailure"
22026 );
22027 }
22028
22029 #[test]
22030 fn flux_helmrelease_key_remediate_last_failure_stays_independent_of_retries() {
22031 // The upgrade-path per-CR remediation block hosts two independent
22032 // leaf-scalar-key axes under the shared sibling
22033 // [`FLUX_HELMRELEASE_KEY_REMEDIATION`] sub-container-axis-key —
22034 // the per-CR retry-cap [`FLUX_HELMRELEASE_KEY_RETRIES`] (that
22035 // also sits under the install-path per-CR remediation block) and
22036 // the upgrade-path-only per-CR remediation-toggle
22037 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`]. Pin that the
22038 // two consts carry byte-distinct sequences so a future rebrand
22039 // on either arm can't silently coalesce onto the peer arm (a
22040 // `FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE = "retries"` typo
22041 // would silently rebind the post-retry-exhaustion rollback
22042 // toggle onto the retry-cap ceiling axis at every emit site —
22043 // the helm-controller then reads the substrate's `true` seed as
22044 // an integer retry-cap `1` on the retry-cap axis instead of the
22045 // rollback-on-terminal-failure boolean, silently truncating the
22046 // per-CR upgrade-path retry budget and dropping the rollback
22047 // semantic entirely with no diagnostic naming the leaf-key-
22048 // coalesce root cause). The upgrade-path per-CR remediation
22049 // leaf-scalar-key pair must always resolve to distinct emitted
22050 // leaf-keys.
22051 assert_ne!(
22052 FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE, FLUX_HELMRELEASE_KEY_RETRIES,
22053 "the upgrade-path per-CR remediation retry-cap leaf-scalar-\
22054 key and remediation-toggle leaf-scalar-key must remain \
22055 byte-distinct — a coalesce onto one value silently rebinds \
22056 the post-retry-exhaustion rollback semantic onto the retry-\
22057 cap ceiling axis at every emit site"
22058 );
22059 }
22060
22061 #[test]
22062 fn flux_helmrelease_key_create_namespace_pins_canonical_value() {
22063 // Pin the actual string so a typo in this lift can't silently
22064 // rebrand the Flux v2 `HelmRelease.spec.install.createNamespace`
22065 // install-path-only per-CR namespace-seeder-toggle leaf-scalar-key
22066 // the substrate's per-caixa `cluster_bundle` renderer seeds to
22067 // `true` into every emitted per-caixa `helmrelease.yaml` document
22068 // under the sibling [`FLUX_HELMRELEASE_KEY_INSTALL`] per-CR
22069 // install-path phase-discriminator parent-container-axis-key. The
22070 // string is part of the cluster-side contract with the upstream
22071 // Flux v2 helm-controller — the controller's per-CR install-path
22072 // pre-apply loop reaches the target-namespace-seeder toggle
22073 // through this exact leaf; a drifted leaf-scalar-key silently
22074 // strips the substrate's chosen first-apply namespace-seeder
22075 // semantic from every emitted per-caixa `HelmRelease` document,
22076 // leaving the helm-controller to refuse every first-time per-caixa
22077 // chart apply against a fresh cluster whose target namespace has
22078 // not been pre-provisioned by an out-of-band pipeline the
22079 // substrate's "no per-caixa Servico apply is blocked on manual
22080 // namespace preprovisioning" MESH-COMPOSITION.md §V install-path-
22081 // fluency guarantee mandates, with no diagnostic naming the
22082 // seeder-toggle-drift root cause. Changing it is a coordinated
22083 // Flux v3 CRD-schema-rebrand migration alongside the upstream
22084 // `helm-controller` deprecation cycle (candidates like
22085 // `createTargetNamespace` / `seedNamespace` / `provisionNamespace`
22086 // that upstream Flux v3 roadmap floats in the migration prose),
22087 // not an incidental edit. Peer to
22088 // `flux_helmrelease_key_remediate_last_failure_pins_canonical_value`
22089 // on the sibling mirror-symmetric upgrade-path-only per-CR
22090 // remediation-toggle leaf-scalar-key half of the same install/
22091 // upgrade per-CR phase-specific toggle leaf-scalar-key pair.
22092 assert_eq!(FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE, "createNamespace");
22093 }
22094
22095 #[test]
22096 fn flux_helmrelease_key_create_namespace_stays_independent_of_remediate_last_failure() {
22097 // The per-CR install/upgrade phase blocks host two mirror-symmetric
22098 // phase-specific toggle leaf-scalar-key axes: the install-path-only
22099 // per-CR namespace-seeder-toggle
22100 // [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] under the sibling
22101 // [`FLUX_HELMRELEASE_KEY_INSTALL`] parent-container-axis-key (this
22102 // lift) and the upgrade-path-only per-CR remediation-toggle
22103 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] (96581b7) under the
22104 // sibling [`FLUX_HELMRELEASE_KEY_UPGRADE`] parent-container-axis-key.
22105 // Pin that the two consts carry byte-distinct sequences so a future
22106 // rebrand on either arm can't silently coalesce onto the peer arm
22107 // (a `FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE = "remediateLastFailure"`
22108 // typo would silently rebind the install-path namespace-seeder
22109 // toggle onto the upgrade-path per-CR remediation-toggle leaf at
22110 // every emit site — the helm-controller would then read the
22111 // substrate's `true` seed as a post-retry-exhaustion rollback opt-
22112 // in on the upgrade-path per-CR remediation axis instead of the
22113 // pre-apply namespace-seeder toggle, silently dropping the first-
22114 // apply namespace-seeder semantic entirely and misrouting the
22115 // install-path opt-in onto an upgrade-path axis where it never
22116 // fires with no diagnostic naming the leaf-key-coalesce root
22117 // cause). The install/upgrade per-CR phase-specific toggle leaf-
22118 // scalar-key pair must always resolve to distinct emitted leaf-
22119 // keys under mirror-symmetric parent-container-axis-keys.
22120 assert_ne!(
22121 FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE, FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE,
22122 "the install-path per-CR namespace-seeder-toggle leaf-scalar-\
22123 key and the upgrade-path per-CR remediation-toggle leaf-\
22124 scalar-key must remain byte-distinct — a coalesce onto one \
22125 value silently rebinds one phase's opt-in toggle onto the \
22126 peer phase's opt-in-toggle axis at every emit site, dropping \
22127 the phase-specific pre-apply / post-retry-exhaustion semantic \
22128 the substrate seeds on the coalesced arm"
22129 );
22130 }
22131
22132 #[test]
22133 fn flux_kustomization_key_prune_pins_canonical_value() {
22134 // Pin the actual string so a typo in this lift can't silently
22135 // rebrand the Flux v2 `Kustomization.spec.prune` per-CR garbage-
22136 // collection-toggle leaf-scalar-key the substrate's per-caixa
22137 // `cluster_bundle` renderer seeds to `true` into every emitted
22138 // per-caixa `kustomization.yaml` document at the top-level `spec`
22139 // position. The string is part of the cluster-side contract with
22140 // the upstream Flux v2 kustomize-controller — the controller's
22141 // per-CR reconcile loop reaches the sweep-what-you-removed toggle
22142 // through this exact leaf; a drifted leaf-scalar-key silently
22143 // strips the substrate's chosen sweep-what-you-removed semantic
22144 // from every emitted per-caixa `Kustomization` document, leaving
22145 // per-caixa resources the source manifest set previously
22146 // reconciled but no longer carries dangling in the cluster the
22147 // substrate's "the cluster's per-caixa live state converges to
22148 // the caixa's tatara-lisp source-of-truth on every reconcile —
22149 // resources the source no longer carries are swept by the
22150 // kustomize-controller, not left dangling" CAIXA-SDLC.md §V
22151 // author-to-live-convergence guarantee mandates, with no
22152 // diagnostic naming the toggle-drift root cause. Changing it is
22153 // a coordinated Flux v3 CRD-schema-rebrand migration alongside
22154 // the upstream `kustomize-controller` deprecation cycle
22155 // (candidates like `garbageCollect` / `sweep` / `pruneOrphaned`
22156 // / `deleteOrphans` that upstream Flux v3 roadmap floats in the
22157 // migration prose), not an incidental edit. Peer to
22158 // `flux_helmrelease_key_create_namespace_pins_canonical_value`
22159 // on the sibling co-resident per-caixa `HelmRelease` CR install-
22160 // path per-CR namespace-seeder-toggle leaf-scalar-key half of
22161 // the same per-caixa Flux-bundle per-CR-toggle leaf-scalar-key
22162 // surface.
22163 assert_eq!(FLUX_KUSTOMIZATION_KEY_PRUNE, "prune");
22164 }
22165
22166 #[test]
22167 fn flux_kustomization_key_prune_stays_independent_of_create_namespace() {
22168 // The per-caixa Flux bundle hosts two co-resident per-CR-toggle
22169 // leaf-scalar-key axes: the per-`Kustomization`-CR garbage-
22170 // collection-toggle [`FLUX_KUSTOMIZATION_KEY_PRUNE`] at the
22171 // top-level `spec` position (this lift) and the per-`HelmRelease`-
22172 // CR install-path namespace-seeder-toggle
22173 // [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] (ba9ab8b) under the
22174 // sibling [`FLUX_HELMRELEASE_KEY_INSTALL`] parent-container-axis-
22175 // key. Pin that the two consts carry byte-distinct sequences so
22176 // a future rebrand on either arm can't silently coalesce onto
22177 // the peer arm (a `FLUX_KUSTOMIZATION_KEY_PRUNE = "createNamespace"`
22178 // typo would silently rebind the Kustomization-CR garbage-
22179 // collection-toggle onto the HelmRelease-CR install-path
22180 // namespace-seeder-toggle leaf at every emit site — the
22181 // kustomize-controller would then read the substrate's `true`
22182 // seed at the drifted leaf-key rather than the canonical `prune`
22183 // axis, silently dropping the sweep-what-you-removed semantic
22184 // entirely and leaving per-caixa resources removed from the
22185 // source manifest set dangling in the cluster with no
22186 // diagnostic naming the leaf-key-coalesce root cause). The
22187 // per-`Kustomization`-CR garbage-collection-toggle and the
22188 // per-`HelmRelease`-CR install-path namespace-seeder-toggle must
22189 // always resolve to distinct emitted leaf-keys under their
22190 // respective co-resident per-CR spec surfaces.
22191 assert_ne!(
22192 FLUX_KUSTOMIZATION_KEY_PRUNE, FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE,
22193 "the per-`Kustomization`-CR garbage-collection-toggle leaf-\
22194 scalar-key and the per-`HelmRelease`-CR install-path \
22195 namespace-seeder-toggle leaf-scalar-key must remain byte-\
22196 distinct — a coalesce onto one value silently rebinds one \
22197 CR's opt-in toggle onto the peer CR's opt-in-toggle axis at \
22198 every emit site, dropping the per-CR-specific sweep-what-\
22199 you-removed / pre-apply-namespace-seeder semantic the \
22200 substrate seeds on the coalesced arm"
22201 );
22202 }
22203
22204 #[test]
22205 fn flux_kustomization_prune_default_pins_canonical_value() {
22206 // Pin the actual boolean so a rebrand on this lift can't silently
22207 // rebrand the Flux v2 `Kustomization.spec.prune` per-CR garbage-
22208 // collection-toggle scalar-value seed the substrate's per-caixa
22209 // `cluster_bundle` renderer threads into every emitted per-caixa
22210 // `kustomization.yaml` document under the sibling
22211 // [`FLUX_KUSTOMIZATION_KEY_PRUNE`] leaf-scalar-key axis. The
22212 // scalar is part of the cluster-side contract with the upstream
22213 // Flux v2 kustomize-controller — the controller's per-CR reconcile
22214 // loop reads the scalar under the sibling leaf-scalar-key axis
22215 // to decide whether to garbage-collect resources that were
22216 // previously reconciled by the CR but no longer appear in the
22217 // CR's current desired-state manifest set. Drift from the
22218 // canonical `true` seed to `false` silently drops the substrate's
22219 // chosen sweep-what-you-removed semantic from every emitted
22220 // per-caixa `Kustomization` document, leaving per-caixa resources
22221 // the source manifest set previously reconciled but no longer
22222 // carries dangling in the cluster the substrate's "the cluster's
22223 // per-caixa live state converges to the caixa's tatara-lisp
22224 // source-of-truth on every reconcile — resources the source no
22225 // longer carries are swept by the kustomize-controller, not left
22226 // dangling" CAIXA-SDLC.md §V author-to-live-convergence guarantee
22227 // mandates, with no diagnostic naming the toggle-drift root
22228 // cause. Changing it is a substrate-side policy migration
22229 // (candidates: `true` → `false` on a per-cluster class where a
22230 // human is expected to prune orphaned resources by hand once
22231 // per-cluster policy grows an operator-driven-cleanup mode; a
22232 // per-caixa opt-out slot the ABSORPTION-ROADMAP.md M4 typed-slot
22233 // trajectory adds once the substrate grows a `:kustomization
22234 // :prune` author-side toggle), not an incidental edit. Peer to
22235 // `flux_helmrelease_remediation_retries_default_pins_lifted_value`
22236 // on the sibling per-path per-CR HelmRelease remediation retry-
22237 // cap scalar-value default axis — that default names the per-
22238 // path per-CR remediation retry ceiling, and this default names
22239 // whether the per-CR reconcile loop sweeps orphaned resources at
22240 // all. Both are substrate-side policy choices the operator
22241 // inherits when the per-caixa `ClusterBundleOpts` doesn't pin an
22242 // override.
22243 assert!(FLUX_KUSTOMIZATION_PRUNE_DEFAULT);
22244 }
22245
22246 #[test]
22247 fn flux_kustomization_prune_default_pairs_with_lifted_leaf_key() {
22248 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-CR
22249 // garbage-collection-toggle declaration lives at two lifted
22250 // `pub const` declarations —
22251 // [`FLUX_KUSTOMIZATION_KEY_PRUNE`] (8ec7917) on the key half
22252 // and [`FLUX_KUSTOMIZATION_PRUNE_DEFAULT`] on the value half.
22253 // Both halves must move together on any coordinated Flux v3
22254 // migration (a `garbageCollect: false` rename that rebrands the
22255 // leaf axis onto a new controller-side opt-in vs. the current
22256 // opt-out default; a leaf coalesce onto a peer per-CR toggle
22257 // that reroutes the substrate's canonical scalar seed onto an
22258 // unrelated axis), so a rebrand on either half without a
22259 // coordinated edit on the other would silently split the
22260 // substrate's canonical sweep-what-you-removed declaration —
22261 // the emit-site format-string would still thread the `{prune_key}`
22262 // named-arg through the lifted leaf-scalar-key but pair it with
22263 // a canonical `{prune_default}` that no longer reflects the
22264 // substrate-side semantic the leaf axis names. Pin the pair here
22265 // so a future edit that touches only the leaf-scalar-key half
22266 // or only the scalar-value default half surfaces at build time
22267 // rather than at reconcile time far from the source edit.
22268 // Confirms both consts carry their canonical wire representations
22269 // (`"prune"` byte-string on the leaf-scalar-key half; `true` on
22270 // the scalar-value default half) — the pair as-a-unit reads as
22271 // the substrate's chosen `prune: true` per-CR opt-in.
22272 assert_eq!(FLUX_KUSTOMIZATION_KEY_PRUNE, "prune");
22273 assert!(FLUX_KUSTOMIZATION_PRUNE_DEFAULT);
22274 }
22275
22276 #[test]
22277 fn flux_helmrelease_remediate_last_failure_default_pins_canonical_value() {
22278 // Pin the actual boolean so a rebrand on this lift can't silently
22279 // rebrand the Flux v2 `HelmRelease.spec.upgrade.remediation
22280 // .remediateLastFailure` upgrade-path-only per-CR remediation-toggle
22281 // scalar-value seed the substrate's per-caixa `cluster_bundle`
22282 // renderer threads into every emitted per-caixa `helmrelease.yaml`
22283 // document under the sibling
22284 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] leaf-scalar-key
22285 // axis. The scalar is part of the cluster-side contract with the
22286 // upstream Flux v2 helm-controller — the controller's per-CR
22287 // upgrade-path remediation loop reads the scalar under the sibling
22288 // leaf-scalar-key axis to decide whether to trigger the prior-
22289 // release rollback pipeline once the paired
22290 // [`FLUX_HELMRELEASE_REMEDIATION_RETRIES_DEFAULT`] retry-cap ceiling
22291 // has been exhausted. Drift from the canonical `true` seed to
22292 // `false` silently drops the substrate's chosen post-retry-
22293 // exhaustion rollback semantic from every emitted per-caixa
22294 // `HelmRelease` document, leaving every terminally-failed upgrade
22295 // parked at `Ready: False` without rolling back to the prior last-
22296 // known-good release the substrate's "no chart apply leaves a
22297 // per-caixa CR in a stalled, unremediated state" MESH-COMPOSITION
22298 // .md §V guarantee mandates, with no diagnostic naming the
22299 // remediation-toggle-drift root cause. Changing it is a substrate-
22300 // side policy migration (candidates: `true` → `false` on a per-
22301 // cluster class where terminally-failed upgrades must escalate to
22302 // operator-attention rather than mask under an auto-rollback pipe-
22303 // line; a per-caixa opt-out slot the ABSORPTION-ROADMAP.md M4
22304 // typed-slot trajectory adds once the substrate grows a `:upgrade
22305 // :remediate-last-failure` author-side toggle), not an incidental
22306 // edit. Peer to `flux_kustomization_prune_default_pins_canonical_value`
22307 // on the sibling per-`Kustomization`-CR garbage-collection-toggle
22308 // scalar-value default axis — that default names whether the
22309 // per-CR `Kustomization` reconcile loop sweeps orphaned resources
22310 // at all, and this default names whether the per-CR `HelmRelease`
22311 // upgrade-path remediation loop rolls back to the prior last-
22312 // known-good release once the retry-cap ceiling is exhausted.
22313 // Both are substrate-side policy choices the operator inherits
22314 // when the per-caixa `ClusterBundleOpts` doesn't pin an override.
22315 assert!(FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT);
22316 }
22317
22318 #[test]
22319 fn flux_helmrelease_remediate_last_failure_default_pairs_with_lifted_leaf_key() {
22320 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-CR
22321 // upgrade-path per-CR post-retry-exhaustion-rollback-toggle
22322 // declaration lives at two lifted `pub const` declarations —
22323 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] (96581b7) on the
22324 // key half and [`FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT`]
22325 // on the value half. Both halves must move together on any
22326 // coordinated Flux v3 migration (a `rollbackOnFailure: false`
22327 // rename that rebrands the leaf axis onto a new controller-side
22328 // opt-in vs. the current opt-in default; a leaf coalesce onto a
22329 // peer per-CR toggle that reroutes the substrate's canonical
22330 // scalar seed onto an unrelated axis), so a rebrand on either half
22331 // without a coordinated edit on the other would silently split the
22332 // substrate's canonical post-retry-exhaustion rollback declaration
22333 // — the emit-site format-string would still thread the
22334 // `{remediate_last_failure_key}` named-arg through the lifted
22335 // leaf-scalar-key but pair it with a canonical
22336 // `{remediate_last_failure_default}` that no longer reflects the
22337 // substrate-side semantic the leaf axis names. Pin the pair here
22338 // so a future edit that touches only the leaf-scalar-key half or
22339 // only the scalar-value default half surfaces at build time rather
22340 // than at reconcile time far from the source edit. Confirms both
22341 // consts carry their canonical wire representations
22342 // (`"remediateLastFailure"` byte-string on the leaf-scalar-key
22343 // half; `true` on the scalar-value default half) — the pair as-a-
22344 // unit reads as the substrate's chosen
22345 // `remediateLastFailure: true` per-CR opt-in.
22346 assert_eq!(
22347 FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE,
22348 "remediateLastFailure"
22349 );
22350 assert!(FLUX_HELMRELEASE_REMEDIATE_LAST_FAILURE_DEFAULT);
22351 }
22352
22353 #[test]
22354 fn flux_helmrelease_create_namespace_default_pins_canonical_value() {
22355 // Pin the actual boolean so a rebrand on this lift can't silently
22356 // rebrand the Flux v2 `HelmRelease.spec.install.createNamespace`
22357 // install-path-only per-CR namespace-seeder-toggle scalar-value
22358 // seed the substrate's per-caixa `cluster_bundle` renderer threads
22359 // into every emitted per-caixa `helmrelease.yaml` document under
22360 // the sibling [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] leaf-
22361 // scalar-key axis. The scalar is part of the cluster-side contract
22362 // with the upstream Flux v2 helm-controller — the controller's
22363 // per-CR install-path pre-apply loop reads the scalar under the
22364 // sibling leaf-scalar-key axis to decide whether to first material-
22365 // ize the target namespace before the first-time chart apply.
22366 // Drift from the canonical `true` seed to `false` silently drops
22367 // the substrate's chosen first-apply namespace-seeder semantic
22368 // from every emitted per-caixa `HelmRelease` document, leaving
22369 // every first-time per-caixa chart apply against a fresh cluster
22370 // refused by the helm-controller because the target namespace was
22371 // not pre-provisioned by an out-of-band pipeline the substrate's
22372 // "no per-caixa Servico apply is blocked on manual namespace
22373 // preprovisioning" MESH-COMPOSITION.md §V install-path-fluency
22374 // guarantee mandates, with no diagnostic naming the seeder-toggle-
22375 // drift root cause. Changing it is a substrate-side policy
22376 // migration (candidates: `true` → `false` on hardened per-cluster
22377 // classes where namespace provisioning is an out-of-band operator
22378 // gate; a per-caixa opt-out slot the ABSORPTION-ROADMAP.md M4
22379 // typed-slot trajectory adds once the substrate grows a `:install
22380 // :create-namespace` author-side toggle), not an incidental edit.
22381 // Peer to `flux_helmrelease_remediate_last_failure_default_pins_canonical_value`
22382 // on the sibling mirror-symmetric upgrade-path-only per-CR
22383 // remediation-toggle scalar-value default axis — that default
22384 // names whether the per-CR `HelmRelease` upgrade-path remediation
22385 // loop rolls back to the prior last-known-good release once the
22386 // retry-cap ceiling is exhausted, and this default names whether
22387 // the per-CR `HelmRelease` install-path pre-apply loop materializes
22388 // the target namespace before the first-time chart apply. Both
22389 // are substrate-side policy choices the operator inherits when
22390 // the per-caixa `ClusterBundleOpts` doesn't pin an override, and
22391 // both close the mirror-symmetric install/upgrade per-CR phase-
22392 // specific toggle scalar-value default pair the peer leaf-scalar-
22393 // key pair [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] (ba9ab8b) /
22394 // [`FLUX_HELMRELEASE_KEY_REMEDIATE_LAST_FAILURE`] (96581b7)
22395 // already closed on the key half.
22396 assert!(FLUX_HELMRELEASE_CREATE_NAMESPACE_DEFAULT);
22397 }
22398
22399 #[test]
22400 fn flux_helmrelease_create_namespace_default_pairs_with_lifted_leaf_key() {
22401 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-CR
22402 // install-path per-CR namespace-seeder-toggle declaration lives
22403 // at two lifted `pub const` declarations —
22404 // [`FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE`] (ba9ab8b) on the key
22405 // half and [`FLUX_HELMRELEASE_CREATE_NAMESPACE_DEFAULT`] on the
22406 // value half. Both halves must move together on any coordinated
22407 // Flux v3 migration (a `createTargetNamespace: false` rename that
22408 // rebrands the leaf axis onto a new controller-side opt-in vs.
22409 // the current opt-in default; a leaf coalesce onto a peer per-CR
22410 // toggle that reroutes the substrate's canonical scalar seed onto
22411 // an unrelated axis), so a rebrand on either half without a
22412 // coordinated edit on the other would silently split the substrate's
22413 // canonical first-apply namespace-seeder declaration — the emit-
22414 // site format-string would still thread the
22415 // `{create_namespace_key}` named-arg through the lifted leaf-
22416 // scalar-key but pair it with a canonical `{create_namespace_default}`
22417 // that no longer reflects the substrate-side semantic the leaf
22418 // axis names. Pin the pair here so a future edit that touches
22419 // only the leaf-scalar-key half or only the scalar-value default
22420 // half surfaces at build time rather than at reconcile time far
22421 // from the source edit. Confirms both consts carry their canonical
22422 // wire representations (`"createNamespace"` byte-string on the
22423 // leaf-scalar-key half; `true` on the scalar-value default half) —
22424 // the pair as-a-unit reads as the substrate's chosen
22425 // `createNamespace: true` per-CR opt-in.
22426 assert_eq!(FLUX_HELMRELEASE_KEY_CREATE_NAMESPACE, "createNamespace");
22427 assert!(FLUX_HELMRELEASE_CREATE_NAMESPACE_DEFAULT);
22428 }
22429
22430 #[test]
22431 fn cluster_bundle_lareira_enabled_default_pins_canonical_value() {
22432 // Pin the actual boolean so a rebrand on this lift can't silently
22433 // rebrand the substrate-side default for the
22434 // `HelmRelease.spec.values.<library>.enabled` child-chart-
22435 // enablement toggle scalar the substrate's per-caixa
22436 // `cluster_bundle` renderer threads into every emitted per-caixa
22437 // `helmrelease.yaml` document under the sibling
22438 // [`HELM_VALUES_KEY_ENABLED`] leaf-scalar-key axis inside the
22439 // per-`{library_name}` values-overlay wrap. The scalar is the
22440 // substrate's chosen "force-on the child chart under the
22441 // cluster_bundle composition path" default — semantically
22442 // distinct from and inverse of the standalone
22443 // [`caixa_helm::RenderOpts`]::`enabled_default = false` seed
22444 // (which renders `enabled: false` in the per-caixa `values.yaml`
22445 // so cluster operators must opt each caixa in per-cluster); the
22446 // `cluster_bundle` composition path is the substrate-side
22447 // opt-in path where the operator has already asserted per-caixa
22448 // cluster-scoped ownership by materializing a per-caixa
22449 // GitRepository + HelmRelease + Kustomization trio, so the
22450 // overlay forces the child chart on by seeding `enabled: true`
22451 // under the `values.<library>` wrap. Drift from the canonical
22452 // `true` seed to `false` silently drops the substrate's chosen
22453 // force-on-under-composition semantic from every emitted
22454 // per-caixa `HelmRelease` document, leaving the paired
22455 // [`DEFAULT_LIBRARY_NAME`] child chart's `enabled: false`
22456 // per-chart default un-overridden — the Helm rendering pipeline
22457 // then no-ops every per-caixa lareira child chart at the
22458 // per-cluster `HelmRelease` apply step, with no diagnostic
22459 // naming the toggle-drift root cause. Peer to the sibling
22460 // `flux_helmrelease_create_namespace_default_pins_canonical_value`
22461 // (be1904b) / `flux_helmrelease_remediate_last_failure_default_pins_canonical_value`
22462 // (be1904b) / `flux_kustomization_prune_default_pins_canonical_value`
22463 // (ea857d8) on the peer canonical-Flux-v2-per-CR-substrate-
22464 // default surface — all four defaults are substrate-side policy
22465 // choices the operator inherits when the per-caixa
22466 // `ClusterBundleOpts` doesn't pin an override.
22467 assert!(CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT);
22468 }
22469
22470 #[test]
22471 fn cluster_bundle_lareira_enabled_default_pairs_with_lifted_leaf_key() {
22472 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-
22473 // values-overlay child-chart-enablement-toggle declaration lives
22474 // at two lifted `pub const` declarations —
22475 // [`HELM_VALUES_KEY_ENABLED`] on the key half and
22476 // [`CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT`] on the value half.
22477 // Both halves must move together on any coordinated Helm 4
22478 // migration (an `on: true` rename that rebrands the leaf axis
22479 // onto a new controller-side opt-in vs. the current opt-in
22480 // default; a leaf coalesce onto a peer per-values-block toggle
22481 // that reroutes the substrate's canonical scalar seed onto an
22482 // unrelated axis), so a rebrand on either half without a
22483 // coordinated edit on the other would silently split the
22484 // substrate's canonical force-on-under-composition declaration —
22485 // the emit-site format-string would still thread the
22486 // `{enabled_key}` named-arg through the lifted leaf-scalar-key
22487 // but pair it with a canonical `{lareira_enabled_default}` that
22488 // no longer reflects the substrate-side semantic the leaf axis
22489 // names. Pin the pair here so a future edit that touches only
22490 // the leaf-scalar-key half or only the scalar-value default
22491 // half surfaces at build time rather than at apply time far
22492 // from the source edit. Confirms both consts carry their
22493 // canonical wire representations (`"enabled"` byte-string on
22494 // the leaf-scalar-key half; `true` on the scalar-value default
22495 // half) — the pair as-a-unit reads as the substrate's chosen
22496 // `enabled: true` per-values-overlay opt-in. Peer to
22497 // `flux_kustomization_prune_default_pairs_with_lifted_leaf_key`
22498 // (ea857d8) /
22499 // `flux_helmrelease_create_namespace_default_pairs_with_lifted_leaf_key`
22500 // (be1904b) /
22501 // `flux_helmrelease_remediate_last_failure_default_pairs_with_lifted_leaf_key`
22502 // (be1904b) on the sibling canonical-Flux-v2-per-CR-
22503 // substrate-default paired-halves surfaces.
22504 assert_eq!(HELM_VALUES_KEY_ENABLED, "enabled");
22505 assert!(CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT);
22506 }
22507
22508 #[test]
22509 fn standalone_lareira_enabled_default_pins_canonical_value() {
22510 // Pin the actual boolean so a rebrand on this lift can't silently
22511 // rebrand the substrate-side default for the
22512 // `values.<library>.enabled` child-chart-enablement toggle scalar
22513 // the substrate's per-caixa `caixa_helm::render_chart_for_servico`
22514 // renderer seeds into every emitted per-caixa `values.yaml`
22515 // document under the sibling [`HELM_VALUES_KEY_ENABLED`]
22516 // leaf-scalar-key axis inside the per-`{library_name}` wrap. The
22517 // scalar is the substrate's chosen "leave the child chart opted
22518 // out under the standalone per-chart path" default —
22519 // semantically distinct from and inverse of the composition
22520 // [`CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT`] seed (which renders
22521 // `enabled: true` in the per-cluster `HelmRelease` values-overlay
22522 // so the substrate force-ons the child chart at bundle
22523 // materialization time); the standalone per-chart path is the
22524 // substrate-side opt-out path where the operator has not yet
22525 // asserted per-caixa cluster-scoped ownership by materializing a
22526 // per-caixa GitRepository + HelmRelease + Kustomization trio, so
22527 // the per-chart `values.yaml` seeds `enabled: false` under the
22528 // `values.<library>` wrap and cluster operators must opt each
22529 // caixa in per-cluster. Drift from the canonical `false` seed to
22530 // `true` silently drops the substrate's chosen
22531 // opt-out-under-standalone semantic from every emitted per-caixa
22532 // `values.yaml` document, force-onning the paired
22533 // [`DEFAULT_LIBRARY_NAME`] child chart against the operator's
22534 // stated per-cluster opt-in convention — every rendered chart's
22535 // library-chart-side workload would come up on `helm template` /
22536 // `helm install` with no diagnostic naming the toggle-drift root
22537 // cause. Peer to `cluster_bundle_lareira_enabled_default_pins_canonical_value`
22538 // on the sibling composition-path `HelmRelease.spec.values.<library>.enabled`
22539 // scalar-value default surface — both defaults are substrate-side
22540 // policy choices the operator inherits when the per-caixa
22541 // `RenderOpts` / `ClusterBundleOpts` doesn't pin an override, and
22542 // together they close the mirror-symmetric standalone / composition
22543 // per-values-block child-chart-enablement-toggle scalar-value
22544 // default pair.
22545 assert!(!STANDALONE_LAREIRA_ENABLED_DEFAULT);
22546 }
22547
22548 #[test]
22549 fn standalone_lareira_enabled_default_pairs_with_lifted_leaf_key() {
22550 // Sibling-pair pin: the `(leaf-scalar-key, scalar-value)` per-
22551 // values-block child-chart-enablement-toggle declaration on the
22552 // standalone per-chart path lives at two lifted `pub const`
22553 // declarations — [`HELM_VALUES_KEY_ENABLED`] on the key half and
22554 // [`STANDALONE_LAREIRA_ENABLED_DEFAULT`] on the value half. Both
22555 // halves must move together on any coordinated Helm 4 migration
22556 // (an `on: false` rename that rebrands the leaf axis onto a new
22557 // controller-side opt-in vs. the current opt-out default; a leaf
22558 // coalesce onto a peer per-values-block toggle that reroutes the
22559 // substrate's canonical scalar seed onto an unrelated axis), so a
22560 // rebrand on either half without a coordinated edit on the other
22561 // would silently split the substrate's canonical
22562 // opt-out-under-standalone declaration — the emit-site block
22563 // insertion would still thread [`HELM_VALUES_KEY_ENABLED`] as the
22564 // key but pair it with a canonical `enabled_default` scalar-value
22565 // seed that no longer reflects the substrate-side semantic the
22566 // leaf axis names. Pin the pair here so a future edit that
22567 // touches only the leaf-scalar-key half or only the scalar-value
22568 // default half surfaces at build time rather than at apply time
22569 // far from the source edit. Confirms both consts carry their
22570 // canonical wire representations (`"enabled"` byte-string on the
22571 // leaf-scalar-key half; `false` on the scalar-value default half)
22572 // — the pair as-a-unit reads as the substrate's chosen
22573 // `enabled: false` per-values-block opt-out. Peer to
22574 // `cluster_bundle_lareira_enabled_default_pairs_with_lifted_leaf_key`
22575 // on the sibling composition-path
22576 // `HelmRelease.spec.values.<library>.enabled` scalar-value default
22577 // paired-halves surface — both `(key, value)` pairs share the same
22578 // [`HELM_VALUES_KEY_ENABLED`] leaf-scalar-key half but diverge on
22579 // the scalar-value half, which is exactly the mirror-symmetric
22580 // standalone / composition path-selection the two scalar-value
22581 // defaults name.
22582 assert_eq!(HELM_VALUES_KEY_ENABLED, "enabled");
22583 assert!(!STANDALONE_LAREIRA_ENABLED_DEFAULT);
22584 }
22585
22586 #[test]
22587 fn standalone_and_cluster_bundle_lareira_enabled_defaults_are_inverse_by_construction() {
22588 // Cross-const coherence pin: the two peer
22589 // per-values-block child-chart-enablement-toggle scalar-value
22590 // defaults on the standalone per-chart path
22591 // ([`STANDALONE_LAREIRA_ENABLED_DEFAULT`]) and the composition
22592 // per-cluster-`HelmRelease` values-overlay path
22593 // ([`CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT`]) name mirror-symmetric
22594 // inverse defaults on the same underlying
22595 // `values.<library>.enabled` sub-block axis: the standalone-path
22596 // default is `false` (opt-out — cluster operators must opt each
22597 // caixa in per-cluster) while the composition-path default is
22598 // `true` (opt-in — the substrate force-ons the child chart once
22599 // the operator has asserted per-caixa cluster-scoped ownership by
22600 // materializing a per-caixa GitRepository + HelmRelease +
22601 // Kustomization trio). The inversion is the substrate's chosen
22602 // author-to-live path-selection semantic — every consumer that
22603 // reads either default inherits the per-path opt-out / opt-in
22604 // decision by construction, so a future edit that accidentally
22605 // aligned the two defaults (both `false` on a substrate-wide
22606 // opt-out migration, both `true` on a substrate-wide opt-in
22607 // migration) would silently collapse the substrate's chosen
22608 // standalone-vs-composition path-selection semantic — the
22609 // per-chart `values.yaml` default and the per-cluster
22610 // `HelmRelease.spec.values.<library>.enabled` overlay default
22611 // would agree on the same enablement seed, and either the
22612 // standalone path would force-on the child chart against the
22613 // operator's per-cluster opt-in convention (both `true`) or the
22614 // composition path would leave the child chart opted-out against
22615 // the operator's per-caixa cluster-scoped ownership assertion
22616 // (both `false`). Pin the structural inversion here so a future
22617 // edit that touches only one of the two defaults surfaces at
22618 // caixa-core build time rather than at chart-apply time far from
22619 // the constant-drift source. Confirms the two `bool`s carry
22620 // distinct canonical wire representations — the pair as-a-unit
22621 // reads as the substrate's chosen mirror-symmetric author-to-live
22622 // path-selection semantic (standalone opt-out, composition
22623 // opt-in). Peer to the sibling pairwise-distinctness pins the
22624 // `M3_PLACEMENT_ESTRATEGIA_*` /
22625 // `M2_UPGRADE_INSTRUCTION_KIND_*` closed-set typed-enum
22626 // discriminator axes carry on the peer canonical-typed-enum-
22627 // discriminator distinctness surface.
22628 assert_ne!(
22629 STANDALONE_LAREIRA_ENABLED_DEFAULT, CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT,
22630 "STANDALONE_LAREIRA_ENABLED_DEFAULT and CLUSTER_BUNDLE_LAREIRA_ENABLED_DEFAULT \
22631 must remain inverse `bool`s — the standalone per-chart path defaults to \
22632 opt-out (`false`) and the composition per-cluster-HelmRelease values-overlay \
22633 path defaults to opt-in (`true`); collapsing the inversion silently \
22634 breaks the substrate's chosen mirror-symmetric author-to-live \
22635 path-selection semantic at chart-apply time far from the constant-\
22636 drift source."
22637 );
22638 }
22639
22640 #[test]
22641 fn flux_kustomization_key_path_pins_canonical_value() {
22642 // Pin the actual string so a typo in this lift can't silently
22643 // rebrand the Flux v2 `Kustomization.spec.path` per-CR source-
22644 // sub-tree leaf-scalar-key the substrate's per-caixa
22645 // `cluster_bundle` renderer seeds into every emitted per-caixa
22646 // `kustomization.yaml` document at the top-level `spec`
22647 // position. The string is part of the cluster-side contract
22648 // with the upstream Flux v2 kustomize-controller — the
22649 // controller's per-CR reconcile loop reaches the source-sub-
22650 // tree pointer through this exact leaf; a drifted leaf-scalar-
22651 // key silently unbinds every per-caixa `Kustomization` from
22652 // its paired per-caixa sub-tree of the pleme-io k8s repository
22653 // (the controller defaults to `./` when the CR omits the leaf,
22654 // pulling every unrelated cluster's manifests through the
22655 // wrong per-caixa `Kustomization`), with no diagnostic naming
22656 // the leaf-drift root cause. Changing it is a coordinated Flux
22657 // v3 CRD-schema-rebrand migration alongside the upstream
22658 // `kustomize-controller` deprecation cycle (candidates like
22659 // `sourcePath` / `manifestsPath` / `sourceRoot` upstream Flux
22660 // v3 roadmap floats), not an incidental edit. Peer to
22661 // `flux_kustomization_key_prune_pins_canonical_value` on the
22662 // sibling co-resident per-`Kustomization`-CR `spec.prune`
22663 // garbage-collection-toggle leaf-scalar-key half of the same
22664 // per-`Kustomization`-CR-spec surface.
22665 assert_eq!(FLUX_KUSTOMIZATION_KEY_PATH, "path");
22666 }
22667
22668 #[test]
22669 fn flux_kustomization_key_path_stays_independent_of_prune() {
22670 // The per-`Kustomization`-CR top-level `spec` surface hosts two
22671 // co-resident leaf-scalar-key axes: the per-CR source-sub-tree
22672 // pointer [`FLUX_KUSTOMIZATION_KEY_PATH`] (this lift) and the
22673 // per-CR garbage-collection-toggle [`FLUX_KUSTOMIZATION_KEY_PRUNE`]
22674 // (8ec7917). Pin that the two consts carry byte-distinct
22675 // sequences so a future rebrand on either arm can't silently
22676 // coalesce onto the peer arm (a
22677 // `FLUX_KUSTOMIZATION_KEY_PATH = "prune"` typo would silently
22678 // rebind the substrate's per-cluster / per-caixa sub-tree path
22679 // seed onto the garbage-collection-toggle leaf at every emit
22680 // site — the kustomize-controller would then read the
22681 // substrate's `./clusters/<cluster>/services/<name>` seed as a
22682 // boolean opt-in toggle, silently unbinding the per-caixa
22683 // `Kustomization` from its source-sub-tree entirely with no
22684 // diagnostic naming the leaf-key-coalesce root cause). The
22685 // per-`Kustomization`-CR source-sub-tree pointer and the per-
22686 // `Kustomization`-CR garbage-collection-toggle must always
22687 // resolve to distinct emitted leaf-keys under the same
22688 // top-level `spec` position.
22689 assert_ne!(
22690 FLUX_KUSTOMIZATION_KEY_PATH, FLUX_KUSTOMIZATION_KEY_PRUNE,
22691 "the per-`Kustomization`-CR source-sub-tree leaf-scalar-key \
22692 and the per-`Kustomization`-CR garbage-collection-toggle \
22693 leaf-scalar-key must remain byte-distinct — a coalesce \
22694 onto one value silently rebinds one axis onto the peer \
22695 axis at every emit site, dropping the source-sub-tree / \
22696 sweep-what-you-removed semantic the substrate seeds on the \
22697 coalesced arm"
22698 );
22699 }
22700
22701 #[test]
22702 fn flux_kustomization_key_timeout_pins_canonical_value() {
22703 // Pin the actual string so a typo in this lift can't silently
22704 // rebrand the Flux v2 `Kustomization.spec.timeout` per-CR
22705 // reconcile wall-clock cap leaf-scalar-key the substrate's per-
22706 // caixa `cluster_bundle` renderer seeds into every emitted per-
22707 // caixa `kustomization.yaml` document at the top-level `spec`
22708 // position. The string is part of the cluster-side contract
22709 // with the upstream Flux v2 kustomize-controller — the
22710 // controller's per-CR reconcile loop reaches the wall-clock cap
22711 // through this exact leaf; a drifted leaf-scalar-key silently
22712 // strips the substrate's chosen reconcile-ceiling from every
22713 // emitted per-caixa `Kustomization` document, letting the
22714 // controller fall back to the upstream Flux v2 controller-side
22715 // default cap rather than the substrate's per-caixa
22716 // idempotency-checkpoint-tuned ceiling, with no diagnostic
22717 // naming the timeout-drift root cause. Changing it is a
22718 // coordinated Flux v3 CRD-schema-rebrand migration alongside
22719 // the upstream `kustomize-controller` deprecation cycle, not
22720 // an incidental edit. Peer to
22721 // `flux_kustomization_key_path_pins_canonical_value` and
22722 // `flux_kustomization_key_prune_pins_canonical_value` on the
22723 // sibling co-resident per-`Kustomization`-CR spec surface
22724 // leaf-scalar-key axes.
22725 assert_eq!(FLUX_KUSTOMIZATION_KEY_TIMEOUT, "timeout");
22726 }
22727
22728 #[test]
22729 fn flux_kustomization_key_timeout_stays_independent_of_path_and_prune() {
22730 // The per-`Kustomization`-CR top-level `spec` surface hosts
22731 // three co-resident leaf-scalar-key axes: the per-CR reconcile
22732 // wall-clock cap [`FLUX_KUSTOMIZATION_KEY_TIMEOUT`] (this
22733 // lift), the per-CR source-sub-tree pointer
22734 // [`FLUX_KUSTOMIZATION_KEY_PATH`] (613d7ed), and the per-CR
22735 // garbage-collection-toggle [`FLUX_KUSTOMIZATION_KEY_PRUNE`]
22736 // (8ec7917). Pin that the three consts carry byte-distinct
22737 // sequences so a future rebrand on any one arm can't silently
22738 // coalesce onto a peer arm (a
22739 // `FLUX_KUSTOMIZATION_KEY_TIMEOUT = "path"` typo would silently
22740 // rebind the reconcile wall-clock cap onto the source-sub-tree
22741 // pointer leaf at every emit site — the kustomize-controller
22742 // would then parse the substrate's `./clusters/<c>/services/<n>`
22743 // seed as a `metav1.Duration` scalar and reject the per-CR
22744 // admission gate, with no diagnostic naming the leaf-key-
22745 // coalesce root cause). The per-`Kustomization`-CR reconcile
22746 // wall-clock cap, per-CR source-sub-tree pointer, and per-CR
22747 // garbage-collection-toggle must always resolve to distinct
22748 // emitted leaf-keys under the same top-level `spec` position.
22749 assert_ne!(
22750 FLUX_KUSTOMIZATION_KEY_TIMEOUT, FLUX_KUSTOMIZATION_KEY_PATH,
22751 "the per-`Kustomization`-CR reconcile wall-clock cap leaf-\
22752 scalar-key and the per-`Kustomization`-CR source-sub-tree \
22753 leaf-scalar-key must remain byte-distinct — a coalesce onto \
22754 one value silently rebinds one axis onto the peer axis at \
22755 every emit site, dropping the reconcile-ceiling / source-\
22756 sub-tree semantic the substrate seeds on the coalesced arm"
22757 );
22758 assert_ne!(
22759 FLUX_KUSTOMIZATION_KEY_TIMEOUT, FLUX_KUSTOMIZATION_KEY_PRUNE,
22760 "the per-`Kustomization`-CR reconcile wall-clock cap leaf-\
22761 scalar-key and the per-`Kustomization`-CR garbage-\
22762 collection-toggle leaf-scalar-key must remain byte-distinct \
22763 — a coalesce onto one value silently rebinds one axis onto \
22764 the peer axis at every emit site, dropping the reconcile-\
22765 ceiling / sweep-what-you-removed semantic the substrate \
22766 seeds on the coalesced arm"
22767 );
22768 }
22769
22770 #[test]
22771 fn default_flux_kustomization_timeout_pins_canonical_value() {
22772 // Pin the actual scalar so a typo in this lift can't silently
22773 // rebrand the substrate-side default Flux v2
22774 // `Kustomization.spec.timeout` reconcile wall-clock cap the
22775 // substrate's per-caixa `cluster_bundle` renderer seeds into
22776 // every emitted per-caixa `kustomization.yaml` document at the
22777 // top-level `spec` position. The value is part of the cluster-
22778 // side contract with the Flux v2 kustomize-controller (the
22779 // per-CR reconcile loop uses this as the ceiling on the wall-
22780 // clock time a single reconcile attempt is allowed to consume
22781 // before the controller marks the `Kustomization`
22782 // `Ready: False` and stops retrying); changing it is a
22783 // coordinated substrate-side reconcile-ceiling promotion (a
22784 // `5m` → `3m` migration on faster per-caixa idempotency-
22785 // checkpoint cadence, a `5m` → `10m` migration on larger per-
22786 // caixa manifest sets), not an incidental edit. Peer to
22787 // `default_flux_reconcile_interval_pins_canonical_value` and
22788 // `flux_helmrelease_remediation_retries_default_pins_canonical_value`
22789 // on the canonical-Flux-v2-per-CR-substrate-default-scalar pin
22790 // surface.
22791 assert_eq!(DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT, "5m");
22792 }
22793
22794 #[test]
22795 fn default_flux_kustomization_timeout_is_a_valid_metav1_duration_scalar() {
22796 // Cross-axis grammar invariant: the Flux v2 kustomize-
22797 // controller-side per-CR admission gate parses the reconcile
22798 // wall-clock cap scalar via `metav1.ParseDuration` before
22799 // installing the per-CR watch. The Go-duration-format grammar
22800 // is non-empty, ASCII, and structured as
22801 // `<digits><unit>[<digits><unit>...]` where each unit is one of
22802 // `{ns, us, µs, ms, s, m, h}`. Pin a floor that catches the
22803 // canonical drift footguns — an empty scalar (`""` — admission
22804 // gate rejects), a non-ASCII-alphanumeric byte (`"5 m"` — the
22805 // whitespace defeats the parser), a missing-unit scalar (`"5"`
22806 // — the parser rejects for lack of a unit suffix), or a
22807 // leading-non-digit scalar (`"m5"` — the parser rejects for
22808 // lack of a leading magnitude). A future rebrand on the
22809 // canonical lift that lands a value outside the Go-duration-
22810 // format grammar would surface here at caixa-core build time
22811 // on the canonical lift, before any renderer consumes the
22812 // value. Same shape as
22813 // `default_flux_reconcile_interval_is_a_valid_metav1_duration_scalar`
22814 // on the peer canonical-substrate-default-grammar-floor surface.
22815 let v = DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT;
22816 assert!(
22817 !v.is_empty(),
22818 "DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT {v:?} must be non-empty \
22819 per the Flux v2 controller-side `metav1.ParseDuration` \
22820 admission gate"
22821 );
22822 assert!(
22823 v.chars().all(|c| c.is_ascii_alphanumeric()),
22824 "DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT {v:?} must be ASCII-\
22825 alphanumeric throughout per the Go-duration-format grammar \
22826 — no whitespace / separator bytes the `metav1.ParseDuration` \
22827 admission gate would reject"
22828 );
22829 let first = v.chars().next().expect("non-empty");
22830 assert!(
22831 first.is_ascii_digit(),
22832 "DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT {v:?} first byte {first:?} \
22833 must be an ASCII digit per the Go-duration-format grammar \
22834 — the leading magnitude precedes the unit suffix; a leading \
22835 non-digit defeats `metav1.ParseDuration`"
22836 );
22837 let last = v.chars().next_back().expect("non-empty");
22838 assert!(
22839 last.is_ascii_alphabetic() && last.is_ascii_lowercase(),
22840 "DEFAULT_FLUX_KUSTOMIZATION_TIMEOUT {v:?} last byte {last:?} \
22841 must be an ASCII lowercase alphabetic unit suffix per the \
22842 Go-duration-format grammar — the trailing unit follows the \
22843 magnitude; an unterminated magnitude defeats \
22844 `metav1.ParseDuration`"
22845 );
22846 }
22847
22848 #[test]
22849 fn default_gateway_class_name_pins_canonical_value() {
22850 // Pin the actual string so a typo in this lift can't silently
22851 // rebrand the substrate's chosen K8s Gateway API controller the
22852 // rendered `Gateway`'s `spec.gatewayClassName` axis binds to.
22853 // The string is part of the cluster-side contract with the Cilium
22854 // Gateway API implementation (the Cilium operator watches
22855 // `GatewayClass` objects whose `spec.controllerName` names the
22856 // Cilium reconciler; a drifted `spec.gatewayClassName` on the
22857 // emitted `Gateway` refers to a `GatewayClass` no controller
22858 // reconciles, and the `Gateway` sits at `Programmed: False`
22859 // with every attached `HTTPRoute` unbound), the same eBPF-identity
22860 // data plane the sibling `CiliumNetworkPolicy` renderer emits
22861 // policies against (the mesh-composition "one identity layer,
22862 // one data plane" invariant, MESH-COMPOSITION.md §V), and the
22863 // per-cluster GatewayClass fixture the operator-side install
22864 // pipeline provisions. Changing it is a coordinated multi-repo
22865 // migration (a substrate-side Gateway controller migration to
22866 // Envoy Gateway / Istio Gateway or any per-edition variant),
22867 // not an incidental edit. Peer to
22868 // `default_namespace_pins_canonical_value` and
22869 // `default_flux_system_namespace_pins_canonical_value` on the
22870 // canonical-substrate-default-resource-name-value-pin axis.
22871 assert_eq!(DEFAULT_GATEWAY_CLASS_NAME, "cilium");
22872 }
22873
22874 #[test]
22875 fn default_gateway_class_name_is_a_valid_dns_1123_label() {
22876 // Cross-axis invariant: the Gateway API `GatewayClass` is a
22877 // cluster-scoped K8s resource, and the K8s apiserver enforces
22878 // the DNS-1123 label rule on every cluster-scoped resource's
22879 // `metadata.name`. The emitted `Gateway`'s
22880 // `spec.gatewayClassName` axis references the `GatewayClass`
22881 // resource by that name — a drift to a value the apiserver
22882 // would refuse as a `GatewayClass.metadata.name` couldn't
22883 // resolve at reconcile time either, and the `Gateway`
22884 // Programmed condition never flips true. Pinning this here
22885 // means a future rebrand on the canonical lift can't silently
22886 // land a value the apiserver refuses at the *first* `Gateway`
22887 // apply against a cluster, far from the rebrand commit's
22888 // source — the typed [`is_dns_1123_label`] floor rejects it at
22889 // caixa-core build time on the canonical lift, before any
22890 // renderer consumes the value. Same shape as
22891 // `default_namespace_is_a_valid_dns_1123_label` and
22892 // `default_flux_system_namespace_is_a_valid_dns_1123_label` on
22893 // the peer canonical-DNS-1123-label-floor axes.
22894 assert!(
22895 is_dns_1123_label(DEFAULT_GATEWAY_CLASS_NAME).is_ok(),
22896 "DEFAULT_GATEWAY_CLASS_NAME {DEFAULT_GATEWAY_CLASS_NAME:?} must be a \
22897 valid DNS-1123 label — every K8s apiserver-side schema enforces \
22898 this rule on cluster-scoped `metadata.name` axes, and the \
22899 `Gateway.spec.gatewayClassName` axis resolves by that same rule"
22900 );
22901 }
22902
22903 #[test]
22904 fn flux_helmrelease_api_version_pins_canonical_value() {
22905 // Pin the actual string so a typo in this lift can't silently
22906 // rebrand the Flux v2 `HelmRelease` CRD group/version the rendered
22907 // `helmrelease.yaml` document declares + the rendered
22908 // `kustomization.yaml` document's `healthChecks[].apiVersion`
22909 // axis transitively references. The string is part of the
22910 // cluster-side contract with the Flux v2 `helm-controller` (the
22911 // controller watches the exact `helm.toolkit.fluxcd.io/v2`
22912 // group/version; a drifted value to a stale v2beta1 / v2beta2
22913 // lands the rendered `HelmRelease` outside the controller's
22914 // `Watches` and fails at apply time with "no kind 'HelmRelease'
22915 // is registered for version 'helm.toolkit.fluxcd.io/v2beta2'");
22916 // changing it is a coordinated Flux v3 migration alongside the
22917 // upstream `helm-controller` deprecation cycle, not an
22918 // incidental edit. Peer to `default_flux_system_namespace_pins_canonical_value`
22919 // on the canonical-Flux-CRD-axis-pin axis for the sibling
22920 // [`DEFAULT_FLUX_SYSTEM_NAMESPACE`] constant.
22921 assert_eq!(FLUX_HELMRELEASE_API_VERSION, "helm.toolkit.fluxcd.io/v2");
22922 }
22923
22924 #[test]
22925 fn flux_helmrelease_api_version_carries_group_and_version_segments() {
22926 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
22927 // `<group>/<version>` pair separated by exactly one `/` byte.
22928 // The group segment is a DNS-style multi-segment hostname
22929 // (`helm.toolkit.fluxcd.io`) and the version segment is a
22930 // Kubernetes API version label (`v2`, `v2beta1`, `v1alpha1` —
22931 // peer with the K8s API versioning convention upstream
22932 // documents). Pinning this here means a future rebrand on the
22933 // canonical lift can't silently land a malformed apiVersion
22934 // (no `/`, two `/`, empty group, empty version) that every
22935 // downstream YAML-aware deserializer would reject far from the
22936 // rebrand commit's source. The single-`/` invariant is the
22937 // load-bearing K8s API typed-discovery contract: a value the
22938 // apiserver's `RESTMapper` consults to resolve the CRD's
22939 // `RESTKind`.
22940 let v = FLUX_HELMRELEASE_API_VERSION;
22941 let parts: Vec<&str> = v.split('/').collect();
22942 assert_eq!(
22943 parts.len(),
22944 2,
22945 "FLUX_HELMRELEASE_API_VERSION {v:?} must split into exactly two \
22946 `/`-delimited segments (group/version) per the K8s CRD apiVersion \
22947 grammar — every downstream YAML-aware deserializer enforces this \
22948 shape"
22949 );
22950 assert!(
22951 !parts[0].is_empty(),
22952 "FLUX_HELMRELEASE_API_VERSION {v:?} group segment must be non-empty"
22953 );
22954 assert!(
22955 !parts[1].is_empty(),
22956 "FLUX_HELMRELEASE_API_VERSION {v:?} version segment must be non-empty"
22957 );
22958 assert!(
22959 parts[0].contains('.'),
22960 "FLUX_HELMRELEASE_API_VERSION {v:?} group segment {group:?} must be a \
22961 DNS-style multi-segment hostname (the canonical CRD-group convention \
22962 every K8s controller-runtime / kube-rs-aware client expects)",
22963 group = parts[0]
22964 );
22965 }
22966
22967 #[test]
22968 fn default_flux_helmrelease_api_version_matches_caixa_flux_test_fixtures() {
22969 // Cross-file drift pin: the four caixa-flux occurrences of
22970 // `helm.toolkit.fluxcd.io/v2` all consult the same canonical
22971 // constant, but the two `upsert_into_helmrelease_programs` test
22972 // fixtures (caixa-flux/src/lib.rs:928, 970) carry the value as
22973 // a static raw-string literal inside a `serde_yaml::from_str`
22974 // input (the YAML parser is the unit-under-test there, not the
22975 // rendering — the literals are intentionally not threaded
22976 // through the lift). This pin trips at caixa-core build time
22977 // if the canonical constant ever drifts past the literal the
22978 // caixa-flux test fixtures carry, so a future Flux v3 migration
22979 // surfaces here on the canonical-string axis rather than at the
22980 // first failing test fixture far from the rebrand commit. Peer
22981 // to the [`default_flux_system_namespace_pins_canonical_value`]
22982 // pin on the sibling Flux-namespace axis: both pin the canonical
22983 // string at the lift site so a future rebrand lands the
22984 // constant + every downstream reference + every test fixture in
22985 // one coordinated edit.
22986 assert_eq!(
22987 FLUX_HELMRELEASE_API_VERSION, "helm.toolkit.fluxcd.io/v2",
22988 "drift between FLUX_HELMRELEASE_API_VERSION and the \
22989 caixa-flux/src/lib.rs:928,970 test fixtures' literal values; \
22990 coordinate the migration across the const + every fixture in \
22991 one edit"
22992 );
22993 }
22994
22995 #[test]
22996 fn flux_gitrepository_api_version_pins_canonical_value() {
22997 // Pin the actual string so a typo in this lift can't silently
22998 // rebrand the Flux v2 `GitRepository` CRD group/version the rendered
22999 // `gitrepository.yaml` document declares. The string is part of the
23000 // cluster-side contract with the Flux v2 `source-controller` (the
23001 // controller watches the exact `source.toolkit.fluxcd.io/v1`
23002 // group/version; a drifted value to a stale v1beta1 / v1beta2 lands
23003 // the rendered `GitRepository` outside the controller's `Watches`
23004 // and fails at apply time with "no kind 'GitRepository' is
23005 // registered for version 'source.toolkit.fluxcd.io/v1beta2'");
23006 // changing it is a coordinated Flux v3 migration alongside the
23007 // upstream `source-controller` deprecation cycle, not an
23008 // incidental edit. Peer to
23009 // `flux_helmrelease_api_version_pins_canonical_value` on the
23010 // canonical-Flux-CRD-axis-pin axis for the sibling
23011 // [`FLUX_HELMRELEASE_API_VERSION`] constant.
23012 assert_eq!(
23013 FLUX_GITREPOSITORY_API_VERSION,
23014 "source.toolkit.fluxcd.io/v1"
23015 );
23016 }
23017
23018 #[test]
23019 fn flux_gitrepository_api_version_carries_group_and_version_segments() {
23020 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
23021 // `<group>/<version>` pair separated by exactly one `/` byte.
23022 // The group segment is a DNS-style multi-segment hostname
23023 // (`source.toolkit.fluxcd.io`) and the version segment is a
23024 // Kubernetes API version label (`v1`, `v1beta1`, `v1alpha1` — peer
23025 // with the K8s API versioning convention upstream documents).
23026 // Pinning this here means a future rebrand on the canonical lift
23027 // can't silently land a malformed apiVersion (no `/`, two `/`,
23028 // empty group, empty version) that every downstream YAML-aware
23029 // deserializer would reject far from the rebrand commit's source.
23030 // The single-`/` invariant is the load-bearing K8s API typed-
23031 // discovery contract: a value the apiserver's `RESTMapper`
23032 // consults to resolve the CRD's `RESTKind`. Peer to
23033 // `flux_helmrelease_api_version_carries_group_and_version_segments`
23034 // on the sibling Flux-CRD-axis.
23035 let v = FLUX_GITREPOSITORY_API_VERSION;
23036 let parts: Vec<&str> = v.split('/').collect();
23037 assert_eq!(
23038 parts.len(),
23039 2,
23040 "FLUX_GITREPOSITORY_API_VERSION {v:?} must split into exactly two \
23041 `/`-delimited segments (group/version) per the K8s CRD apiVersion \
23042 grammar — every downstream YAML-aware deserializer enforces this \
23043 shape"
23044 );
23045 assert!(
23046 !parts[0].is_empty(),
23047 "FLUX_GITREPOSITORY_API_VERSION {v:?} group segment must be non-empty"
23048 );
23049 assert!(
23050 !parts[1].is_empty(),
23051 "FLUX_GITREPOSITORY_API_VERSION {v:?} version segment must be non-empty"
23052 );
23053 assert!(
23054 parts[0].contains('.'),
23055 "FLUX_GITREPOSITORY_API_VERSION {v:?} group segment {group:?} must be a \
23056 DNS-style multi-segment hostname (the canonical CRD-group convention \
23057 every K8s controller-runtime / kube-rs-aware client expects)",
23058 group = parts[0]
23059 );
23060 }
23061
23062 #[test]
23063 fn flux_gitrepository_and_helmrelease_api_versions_share_toolkit_fluxcd_io_root() {
23064 // Cross-axis invariant: every Flux v2 CRD group ends in the canonical
23065 // `.toolkit.fluxcd.io` root the upstream `fluxcd/flux2` project pins
23066 // for the source-/helm-/kustomize-/notification-controller triplet.
23067 // A future Flux v3 promotion that breaks the root suffix (forking
23068 // `source-controller` out of the toolkit group, for example) would
23069 // surface here as a coordinated cross-axis edit-point — both lifted
23070 // constants must move together to preserve the controller-triple
23071 // contract.
23072 const ROOT: &str = ".toolkit.fluxcd.io";
23073 let gr_group = FLUX_GITREPOSITORY_API_VERSION
23074 .split('/')
23075 .next()
23076 .expect("FLUX_GITREPOSITORY_API_VERSION has a group segment");
23077 let hr_group = FLUX_HELMRELEASE_API_VERSION
23078 .split('/')
23079 .next()
23080 .expect("FLUX_HELMRELEASE_API_VERSION has a group segment");
23081 assert!(
23082 gr_group.ends_with(ROOT),
23083 "FLUX_GITREPOSITORY_API_VERSION group {gr_group:?} must end with the \
23084 canonical Flux v2 `{ROOT}` root every controller in the triplet shares"
23085 );
23086 assert!(
23087 hr_group.ends_with(ROOT),
23088 "FLUX_HELMRELEASE_API_VERSION group {hr_group:?} must end with the \
23089 canonical Flux v2 `{ROOT}` root every controller in the triplet shares"
23090 );
23091 }
23092
23093 #[test]
23094 fn flux_kustomization_api_version_pins_canonical_value() {
23095 // Pin the actual string so a typo in this lift can't silently
23096 // rebrand the Flux v2 `Kustomization` CRD group/version the
23097 // rendered `kustomization.yaml` document declares. The string
23098 // is part of the cluster-side contract with the Flux v2
23099 // `kustomize-controller` (the controller watches the exact
23100 // `kustomize.toolkit.fluxcd.io/v1` group/version; a drifted
23101 // value to a stale v1beta1 / v1beta2 lands the rendered
23102 // `Kustomization` outside the controller's `Watches` and
23103 // fails at apply time with "no kind 'Kustomization' is
23104 // registered for version
23105 // 'kustomize.toolkit.fluxcd.io/v1beta2'"); changing it is a
23106 // coordinated Flux v3 migration alongside the upstream
23107 // `kustomize-controller` deprecation cycle, not an
23108 // incidental edit. Peer to
23109 // `flux_helmrelease_api_version_pins_canonical_value` /
23110 // `flux_gitrepository_api_version_pins_canonical_value` on
23111 // the canonical-Flux-CRD-axis-pin axis for the sibling
23112 // [`FLUX_HELMRELEASE_API_VERSION`] /
23113 // [`FLUX_GITREPOSITORY_API_VERSION`] constants — completes
23114 // the Flux v2 controller-triplet's per-CRD-axis pin set.
23115 assert_eq!(
23116 FLUX_KUSTOMIZATION_API_VERSION,
23117 "kustomize.toolkit.fluxcd.io/v1"
23118 );
23119 }
23120
23121 #[test]
23122 fn flux_kustomization_api_version_carries_group_and_version_segments() {
23123 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
23124 // `<group>/<version>` pair separated by exactly one `/` byte.
23125 // The group segment is a DNS-style multi-segment hostname
23126 // (`kustomize.toolkit.fluxcd.io`) and the version segment is a
23127 // Kubernetes API version label (`v1`, `v1beta1`, `v1alpha1` —
23128 // peer with the K8s API versioning convention upstream
23129 // documents). Pinning this here means a future rebrand on the
23130 // canonical lift can't silently land a malformed apiVersion
23131 // (no `/`, two `/`, empty group, empty version) that every
23132 // downstream YAML-aware deserializer would reject far from the
23133 // rebrand commit's source. The single-`/` invariant is the
23134 // load-bearing K8s API typed-discovery contract: a value the
23135 // apiserver's `RESTMapper` consults to resolve the CRD's
23136 // `RESTKind`. Peer to
23137 // `flux_helmrelease_api_version_carries_group_and_version_segments`
23138 // / `flux_gitrepository_api_version_carries_group_and_version_segments`
23139 // on the sibling Flux-CRD-axis.
23140 let v = FLUX_KUSTOMIZATION_API_VERSION;
23141 let parts: Vec<&str> = v.split('/').collect();
23142 assert_eq!(
23143 parts.len(),
23144 2,
23145 "FLUX_KUSTOMIZATION_API_VERSION {v:?} must split into exactly two \
23146 `/`-delimited segments (group/version) per the K8s CRD apiVersion \
23147 grammar — every downstream YAML-aware deserializer enforces this \
23148 shape"
23149 );
23150 assert!(
23151 !parts[0].is_empty(),
23152 "FLUX_KUSTOMIZATION_API_VERSION {v:?} group segment must be non-empty"
23153 );
23154 assert!(
23155 !parts[1].is_empty(),
23156 "FLUX_KUSTOMIZATION_API_VERSION {v:?} version segment must be non-empty"
23157 );
23158 assert!(
23159 parts[0].contains('.'),
23160 "FLUX_KUSTOMIZATION_API_VERSION {v:?} group segment {group:?} must be a \
23161 DNS-style multi-segment hostname (the canonical CRD-group convention \
23162 every K8s controller-runtime / kube-rs-aware client expects)",
23163 group = parts[0]
23164 );
23165 }
23166
23167 #[test]
23168 fn flux_controller_triplet_api_versions_share_toolkit_fluxcd_io_root() {
23169 // Cross-axis triplet invariant: the Flux v2 controller triplet
23170 // (source-controller + helm-controller + kustomize-controller)
23171 // upstream all share the canonical `.toolkit.fluxcd.io` root.
23172 // The two-axis sibling pin
23173 // [`flux_gitrepository_and_helmrelease_api_versions_share_toolkit_fluxcd_io_root`]
23174 // enforces the invariant on the source-/helm- pair; this
23175 // pin extends it onto the kustomize-controller axis so a
23176 // future Flux v3 promotion that forks any single controller
23177 // out of the toolkit group surfaces as a coordinated
23178 // cross-axis edit-point across all three constants — the
23179 // controller triplet's CRD group/versions move together
23180 // upstream, and the lift discipline preserves that
23181 // movement at the typed substrate-side `&'static str`
23182 // surface.
23183 const ROOT: &str = ".toolkit.fluxcd.io";
23184 for (name, v) in [
23185 (
23186 "FLUX_GITREPOSITORY_API_VERSION",
23187 FLUX_GITREPOSITORY_API_VERSION,
23188 ),
23189 ("FLUX_HELMRELEASE_API_VERSION", FLUX_HELMRELEASE_API_VERSION),
23190 (
23191 "FLUX_KUSTOMIZATION_API_VERSION",
23192 FLUX_KUSTOMIZATION_API_VERSION,
23193 ),
23194 ] {
23195 let group = v
23196 .split('/')
23197 .next()
23198 .expect("Flux v2 CRD apiVersion has a group segment");
23199 assert!(
23200 group.ends_with(ROOT),
23201 "{name} group {group:?} must end with the canonical Flux v2 \
23202 `{ROOT}` root every controller in the source/helm/kustomize \
23203 triplet shares"
23204 );
23205 }
23206 }
23207
23208 #[test]
23209 fn flux_kind_git_repository_pins_canonical_value() {
23210 // Pin the actual string so a typo in this lift can't silently
23211 // rebrand the Flux v2 `GitRepository` CRD `kind` discriminator
23212 // the rendered Flux bundle's three `GitRepository`-naming axes
23213 // declare (gitrepository.yaml top-level kind, helmrelease.yaml
23214 // spec.chart.spec.sourceRef.kind, kustomization.yaml
23215 // spec.sourceRef.kind). The string is part of the cluster-side
23216 // contract with the Flux v2 `source-controller` — the
23217 // apiserver-side CRD resolution contract is the
23218 // `(apiVersion, kind)` tuple keyed against the registered
23219 // `CustomResourceDefinition`, so the kind half of the tuple is
23220 // exactly as load-bearing as the sibling
23221 // [`FLUX_GITREPOSITORY_API_VERSION`] apiVersion half. A drifted
23222 // value (e.g. an upstream Flux v3 rename to `GitSource`) lands
23223 // the rendered documents outside the source-controller's CRD
23224 // registration; changing it is a coordinated Flux v3 migration
23225 // alongside the upstream `source-controller` deprecation cycle,
23226 // not an incidental edit. Peer to
23227 // `flux_gitrepository_api_version_pins_canonical_value` on the
23228 // sibling apiVersion half of the same CRD-lookup tuple.
23229 assert_eq!(FLUX_KIND_GIT_REPOSITORY, "GitRepository");
23230 }
23231
23232 #[test]
23233 fn flux_kind_git_repository_carries_upper_camel_case_shape() {
23234 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
23235 // an UpperCamelCase identifier per the K8s API conventions
23236 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
23237 // "Kinds are always UpperCamelCase"). Pinning the shape here
23238 // means a future rebrand on the canonical lift can't silently
23239 // land a malformed kind discriminator (snake_case, kebab-case,
23240 // lowercase, empty) that every downstream YAML-aware
23241 // deserializer would reject far from the rebrand commit's
23242 // source. The first-byte uppercase / rest-ASCII-alphanumeric
23243 // invariant is the load-bearing K8s API typed-discovery
23244 // contract: a value the apiserver's `RESTMapper` consults to
23245 // resolve the CRD's `RESTKind`. Peer to
23246 // `flux_gitrepository_api_version_carries_group_and_version_segments`
23247 // on the sibling apiVersion half of the same CRD-lookup tuple.
23248 let v = FLUX_KIND_GIT_REPOSITORY;
23249 assert!(
23250 !v.is_empty(),
23251 "FLUX_KIND_GIT_REPOSITORY {v:?} must be non-empty per the K8s API \
23252 UpperCamelCase kind discriminator grammar"
23253 );
23254 let first = v.chars().next().expect("non-empty");
23255 assert!(
23256 first.is_ascii_uppercase(),
23257 "FLUX_KIND_GIT_REPOSITORY {v:?} first byte {first:?} must be \
23258 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
23259 grammar (Kinds are always UpperCamelCase)"
23260 );
23261 assert!(
23262 v.chars().all(|c| c.is_ascii_alphanumeric()),
23263 "FLUX_KIND_GIT_REPOSITORY {v:?} must be ASCII-alphanumeric \
23264 throughout per the K8s API kind discriminator grammar — no \
23265 snake_case, kebab-case, or whitespace bytes the apiserver-side \
23266 RESTMapper would reject"
23267 );
23268 }
23269
23270 #[test]
23271 fn flux_kind_helm_release_pins_canonical_value() {
23272 // Pin the actual string so a typo in this lift can't silently
23273 // rebrand the Flux v2 `HelmRelease` CRD `kind` discriminator
23274 // the rendered Flux bundle's two `HelmRelease`-naming axes
23275 // declare (helmrelease.yaml top-level kind, kustomization.yaml
23276 // spec.healthChecks[].kind). The string is part of the
23277 // cluster-side contract with the Flux v2 `helm-controller` —
23278 // the apiserver-side CRD resolution contract is the
23279 // `(apiVersion, kind)` tuple keyed against the registered
23280 // `CustomResourceDefinition`, so the kind half of the tuple is
23281 // exactly as load-bearing as the sibling
23282 // [`FLUX_HELMRELEASE_API_VERSION`] apiVersion half. A drifted
23283 // value (e.g. an upstream Flux v3 rename to `ChartRelease`)
23284 // lands the rendered documents outside the helm-controller's
23285 // CRD registration; changing it is a coordinated Flux v3
23286 // migration alongside the upstream `helm-controller`
23287 // deprecation cycle, not an incidental edit. Peer to
23288 // `flux_kind_git_repository_pins_canonical_value` on the
23289 // sibling Flux v2 source-controller CRD-`kind` axis.
23290 assert_eq!(FLUX_KIND_HELM_RELEASE, "HelmRelease");
23291 }
23292
23293 #[test]
23294 fn flux_kind_helm_release_carries_upper_camel_case_shape() {
23295 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
23296 // an UpperCamelCase identifier per the K8s API conventions
23297 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
23298 // "Kinds are always UpperCamelCase"). Pinning the shape here
23299 // means a future rebrand on the canonical lift can't silently
23300 // land a malformed kind discriminator (snake_case, kebab-case,
23301 // lowercase, empty) that every downstream YAML-aware
23302 // deserializer would reject far from the rebrand commit's
23303 // source. The first-byte uppercase / rest-ASCII-alphanumeric
23304 // invariant is the load-bearing K8s API typed-discovery
23305 // contract: a value the apiserver's `RESTMapper` consults to
23306 // resolve the CRD's `RESTKind`. Peer to
23307 // `flux_kind_git_repository_carries_upper_camel_case_shape`
23308 // on the sibling Flux v2 source-controller CRD-`kind` axis.
23309 let v = FLUX_KIND_HELM_RELEASE;
23310 assert!(
23311 !v.is_empty(),
23312 "FLUX_KIND_HELM_RELEASE {v:?} must be non-empty per the K8s API \
23313 UpperCamelCase kind discriminator grammar"
23314 );
23315 let first = v.chars().next().expect("non-empty");
23316 assert!(
23317 first.is_ascii_uppercase(),
23318 "FLUX_KIND_HELM_RELEASE {v:?} first byte {first:?} must be \
23319 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
23320 grammar (Kinds are always UpperCamelCase)"
23321 );
23322 assert!(
23323 v.chars().all(|c| c.is_ascii_alphanumeric()),
23324 "FLUX_KIND_HELM_RELEASE {v:?} must be ASCII-alphanumeric \
23325 throughout per the K8s API kind discriminator grammar — no \
23326 snake_case, kebab-case, or whitespace bytes the apiserver-side \
23327 RESTMapper would reject"
23328 );
23329 }
23330
23331 #[test]
23332 fn flux_kind_kustomization_pins_canonical_value() {
23333 // Pin the actual string so a typo in this lift can't silently
23334 // rebrand the Flux v2 `Kustomization` CRD `kind` discriminator
23335 // the rendered `kustomization.yaml`'s top-level `kind` axis
23336 // declares. The string is part of the cluster-side contract
23337 // with the Flux v2 `kustomize-controller` — the apiserver-side
23338 // CRD resolution contract is the `(apiVersion, kind)` tuple
23339 // keyed against the registered `CustomResourceDefinition`, so
23340 // the kind half of the tuple is exactly as load-bearing as the
23341 // sibling [`FLUX_KUSTOMIZATION_API_VERSION`] apiVersion half. A
23342 // drifted value (e.g. an upstream Flux v3 rename to
23343 // `KustomizationSet`) lands the rendered document outside the
23344 // kustomize-controller's CRD registration; changing it is a
23345 // coordinated Flux v3 migration alongside the upstream
23346 // `kustomize-controller` deprecation cycle, not an incidental
23347 // edit. Peer to
23348 // `flux_kind_git_repository_pins_canonical_value` /
23349 // `flux_kind_helm_release_pins_canonical_value` on the sibling
23350 // Flux v2 controller-triplet `kind`-axis surface — completes
23351 // the canonical-Flux-v2-CRD-kind-discriminator pin set across
23352 // the source-controller + helm-controller + kustomize-controller
23353 // triplet.
23354 assert_eq!(FLUX_KIND_KUSTOMIZATION, "Kustomization");
23355 }
23356
23357 #[test]
23358 fn flux_key_source_ref_pins_canonical_value() {
23359 // Pin the actual string so a typo in this lift can't silently
23360 // rebrand the Flux v2 per-`HelmRelease`/`Kustomization`
23361 // source-reference container-axis key the rendered
23362 // `helmrelease.yaml` (`spec.chart.spec.sourceRef`) +
23363 // `kustomization.yaml` (`spec.sourceRef`) documents mount the
23364 // per-CR `(kind, name, namespace)` reference triple under. The
23365 // string is part of the cluster-side contract with every
23366 // Flux-v2-conformant source-controller — the per-CR reconcile
23367 // loop keys off this exact container axis to source the
23368 // `(kind, name, namespace)` reference triple; a drifted value
23369 // (`"source_ref"` / `"source"` / `"sourceReference"` /
23370 // `"gitSourceRef"`) silently dangles both the HelmRelease's
23371 // chart resolution + the parent Kustomization's source
23372 // resolution at the Flux v2 source-controller's CRD
23373 // registration. Changing this value is a coordinated Flux v3
23374 // migration alongside the upstream `fluxcd/flux2` deprecation
23375 // cycle, not an incidental edit. Peer to
23376 // `flux_kind_git_repository_pins_canonical_value` /
23377 // `flux_kind_helm_release_pins_canonical_value` /
23378 // `flux_kind_kustomization_pins_canonical_value` on the sibling
23379 // per-CRD `kind`-axis surface — extends the canonical-Flux-v2-
23380 // load-bearing-string pin discipline from the per-CRD kind
23381 // discriminators onto the sibling per-CR source-reference
23382 // container-axis key both `cluster_bundle` renderers consume.
23383 assert_eq!(FLUX_KEY_SOURCE_REF, "sourceRef");
23384 }
23385
23386 #[test]
23387 fn flux_key_source_ref_carries_lower_camel_case_shape() {
23388 // Cross-axis invariant: the Flux v2 CRD field-naming convention
23389 // (inherited from the upstream K8s API conventions) admits
23390 // lowerCamelCase per-field keys — the source-reference
23391 // container-axis conforms to this on the leading-lowercase
23392 // `sourceRef` shape. Pinning the shape here means a future
23393 // rebrand on the canonical lift can't silently land a malformed
23394 // container-axis key (snake_case, kebab-case, UpperCamelCase,
23395 // empty) that the Flux v2 source-controller's per-CR reconcile
23396 // loop would reject at apply parse time far from the rebrand
23397 // commit's source. Peer to the sibling K8s-CR-lowerCamelCase-
23398 // per-field pin trajectory the sibling `KUBE_KEY_MATCH_LABELS`
23399 // / `GATEWAY_API_KEY_BACKEND_REFS` / `CILIUM_KEY_FROM_ENDPOINTS`
23400 // / `CILIUM_KEY_TO_PORTS` pins established on the sibling per-
23401 // K8s-CR-schema-field-name axes.
23402 let v = FLUX_KEY_SOURCE_REF;
23403 assert!(
23404 !v.is_empty(),
23405 "FLUX_KEY_SOURCE_REF {v:?} must be non-empty per the Flux v2 \
23406 CRD field-naming grammar"
23407 );
23408 let mut chars = v.chars();
23409 assert!(
23410 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23411 "FLUX_KEY_SOURCE_REF {v:?} must lead with an ASCII-lowercase \
23412 byte per the Flux v2 lowerCamelCase per-CR-field-key convention"
23413 );
23414 assert!(
23415 v.chars().all(|c| c.is_ascii_alphanumeric()),
23416 "FLUX_KEY_SOURCE_REF {v:?} must be ASCII-alphanumeric throughout \
23417 per the Flux v2 lowerCamelCase per-CR-field-key convention — \
23418 no `_` / `-` / `.` / whitespace bytes the Flux v2 source-\
23419 controller's per-CR reconcile loop would reject"
23420 );
23421 }
23422
23423 #[test]
23424 fn flux_key_values_pins_canonical_value() {
23425 // Pin the actual string so a typo in this lift can't silently
23426 // rebrand the Flux v2 per-`HelmRelease` values-override block-
23427 // body-axis key the rendered `helmrelease.yaml`'s `spec.values`
23428 // block declares. The string is part of the cluster-side
23429 // contract with the Flux v2 `helm-controller` — the per-CR
23430 // reconcile loop merges the per-cluster override YAML nested
23431 // under this exact block-body axis into the referenced chart's
23432 // `values.yaml` at Helm-render time; a drifted value
23433 // (`"Values"` / `"vals"` / `"chartValues"` / `"overrides"`)
23434 // silently routes the per-cluster overrides nowhere at Helm
23435 // render, and the workload comes up with the referenced
23436 // chart's admission-time defaults. Changing this value is a
23437 // coordinated Flux v3 migration alongside the upstream
23438 // `fluxcd/flux2` deprecation cycle, not an incidental edit.
23439 // Peer to `flux_key_source_ref_pins_canonical_value` on the
23440 // sibling Flux v2 per-CR container-axis-key surface — extends
23441 // the canonical-Flux-v2-load-bearing-string pin discipline from
23442 // the per-CR source-reference container-axis onto the sibling
23443 // per-`HelmRelease` values-override block-body-axis.
23444 assert_eq!(FLUX_KEY_VALUES, "values");
23445 }
23446
23447 #[test]
23448 fn flux_key_values_carries_lower_camel_case_shape() {
23449 // Cross-axis invariant: the Flux v2 CRD field-naming convention
23450 // (inherited from the upstream K8s API conventions) admits
23451 // lowerCamelCase per-field keys — the values-override block-
23452 // body axis conforms to this on the leading-lowercase `values`
23453 // shape (a single-word lowerCamelCase reduces to all-lowercase).
23454 // Pinning the shape here means a future rebrand on the
23455 // canonical lift can't silently land a malformed block-body-
23456 // axis key (snake_case, kebab-case, UpperCamelCase, empty) that
23457 // the Flux v2 helm-controller's per-CR reconcile loop would
23458 // reject at apply parse time far from the rebrand commit's
23459 // source. Peer to `flux_key_source_ref_carries_lower_camel_case_shape`
23460 // on the sibling Flux v2 per-CR container-axis-key surface.
23461 let v = FLUX_KEY_VALUES;
23462 assert!(
23463 !v.is_empty(),
23464 "FLUX_KEY_VALUES {v:?} must be non-empty per the Flux v2 \
23465 CRD field-naming grammar"
23466 );
23467 let mut chars = v.chars();
23468 assert!(
23469 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23470 "FLUX_KEY_VALUES {v:?} must lead with an ASCII-lowercase \
23471 byte per the Flux v2 lowerCamelCase per-CR-field-key convention"
23472 );
23473 assert!(
23474 v.chars().all(|c| c.is_ascii_alphanumeric()),
23475 "FLUX_KEY_VALUES {v:?} must be ASCII-alphanumeric throughout \
23476 per the Flux v2 lowerCamelCase per-CR-field-key convention — \
23477 no `_` / `-` / `.` / whitespace bytes the Flux v2 helm-\
23478 controller's per-CR reconcile loop would reject"
23479 );
23480 }
23481
23482 #[test]
23483 fn flux_key_chart_pins_canonical_value() {
23484 // Pin the actual string so a typo in this lift can't silently
23485 // rebrand the Flux v2 per-`HelmRelease` inline-chart-template
23486 // container-axis key the rendered `helmrelease.yaml`'s
23487 // `spec.chart` block declares. The string is part of the
23488 // cluster-side contract with the Flux v2 `helm-controller` —
23489 // the per-CR reconcile loop reads the nested
23490 // `HelmChartTemplate` sub-document (chart-name string,
23491 // source-of-truth reference triple, and reconcile cadence)
23492 // under this exact container axis to source the referenced
23493 // chart at Helm-render time; a drifted value (`"Chart"` /
23494 // `"chartTemplate"` / `"helmChart"` / `"chartRef"`) silently
23495 // dangles the whole chart-template resolution at the helm-
23496 // controller's CRD registration and the referenced chart
23497 // never resolves. Changing this value is a coordinated Flux
23498 // v3 migration alongside the upstream `fluxcd/flux2`
23499 // deprecation cycle, not an incidental edit. Peer to
23500 // `flux_key_source_ref_pins_canonical_value` /
23501 // `flux_key_values_pins_canonical_value` on the sibling Flux
23502 // v2 per-`HelmRelease` body-key surfaces — extends the
23503 // canonical-Flux-v2-load-bearing-string pin discipline from
23504 // the source-reference container-axis + values-override
23505 // block-body-axis onto the sibling chart-template container-
23506 // axis, completing the triplet of Flux v2 per-`HelmRelease`
23507 // `spec.*` body-key pin tests.
23508 assert_eq!(FLUX_KEY_CHART, "chart");
23509 }
23510
23511 #[test]
23512 fn flux_key_chart_carries_lower_camel_case_shape() {
23513 // Cross-axis invariant: the Flux v2 CRD field-naming
23514 // convention (inherited from the upstream K8s API
23515 // conventions) admits lowerCamelCase per-field keys — the
23516 // chart-template container-axis conforms to this on the
23517 // leading-lowercase `chart` shape (a single-word
23518 // lowerCamelCase reduces to all-lowercase). Pinning the shape
23519 // here means a future rebrand on the canonical lift can't
23520 // silently land a malformed container-axis key (snake_case,
23521 // kebab-case, UpperCamelCase, empty) that the Flux v2 helm-
23522 // controller's per-CR reconcile loop would reject at apply
23523 // parse time far from the rebrand commit's source. Peer to
23524 // `flux_key_source_ref_carries_lower_camel_case_shape` /
23525 // `flux_key_values_carries_lower_camel_case_shape` on the
23526 // sibling Flux v2 per-`HelmRelease` body-key surfaces.
23527 let v = FLUX_KEY_CHART;
23528 assert!(
23529 !v.is_empty(),
23530 "FLUX_KEY_CHART {v:?} must be non-empty per the Flux v2 \
23531 CRD field-naming grammar"
23532 );
23533 let mut chars = v.chars();
23534 assert!(
23535 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23536 "FLUX_KEY_CHART {v:?} must lead with an ASCII-lowercase \
23537 byte per the Flux v2 lowerCamelCase per-CR-field-key convention"
23538 );
23539 assert!(
23540 v.chars().all(|c| c.is_ascii_alphanumeric()),
23541 "FLUX_KEY_CHART {v:?} must be ASCII-alphanumeric throughout \
23542 per the Flux v2 lowerCamelCase per-CR-field-key convention — \
23543 no `_` / `-` / `.` / whitespace bytes the Flux v2 helm-\
23544 controller's per-CR reconcile loop would reject"
23545 );
23546 }
23547
23548 #[test]
23549 fn flux_helmchart_template_key_chart_pins_canonical_value() {
23550 // Pin the actual string so a typo in this lift can't silently
23551 // rebrand the Flux v2 `HelmChartTemplate.spec.chart` per-CR
23552 // chart-NAME reference leaf-scalar-axis key every caixa-flux-
23553 // emitted `HelmRelease` document nests inside the parent
23554 // `spec.chart.spec` sub-document. The helm-controller's
23555 // reconcile pipeline reads the chart-artifact name from this
23556 // exact leaf on every reconcile — a drifted `spec.chart.spec.Chart`
23557 // / `spec.chart.spec.chartRef` / `spec.chart.spec.chartName`
23558 // at the emission-side leaf key would silently land as a well-
23559 // formed but ignored `HelmChartTemplate.spec.*` extra property
23560 // the apiserver's CRD OpenAPI schema permits (arbitrary spec
23561 // extras) and the helm-controller would fail to resolve any
23562 // chart-artifact through the sibling `sourceRef` triple's
23563 // source at reconcile time — a non-self-locating "chart
23564 // 'unknown' not found in <source>" error far from the rebrand
23565 // commit's source `caixa.lisp` / the renderer's format-string
23566 // template. Peer to `flux_key_chart_pins_canonical_value` on
23567 // the sibling per-CR chart-template container-axis parent
23568 // this leaf-scalar-axis lift extends by descending one level
23569 // beneath, closing the substrate-side declaration the parent
23570 // container-axis lift docstring explicitly named as future
23571 // work.
23572 assert_eq!(FLUX_HELMCHART_TEMPLATE_KEY_CHART, "chart");
23573 }
23574
23575 #[test]
23576 fn flux_helmchart_template_key_chart_carries_lower_camel_case_shape() {
23577 // Cross-axis invariant: the Flux v2 CRD field-naming
23578 // convention (inherited from the upstream K8s API conventions)
23579 // admits lowerCamelCase per-field keys — the per-`HelmChartTemplate`
23580 // chart-NAME reference leaf-scalar-axis conforms to this on the
23581 // leading-lowercase `chart` shape (a single-word lowerCamelCase
23582 // reduces to all-lowercase). Pinning the shape here means a
23583 // future rebrand on the canonical lift can't silently land a
23584 // malformed leaf-scalar-axis key (snake_case, kebab-case,
23585 // UpperCamelCase, empty) that the Flux v2 helm-controller's
23586 // per-CR reconcile loop would reject at apply parse time far
23587 // from the rebrand commit's source. Peer to
23588 // `flux_key_chart_carries_lower_camel_case_shape` on the
23589 // sibling per-CR chart-template container-axis parent, and to
23590 // the deliberate axis-independence discipline the sibling
23591 // [`CILIUM_KEY_PATH`] / [`GATEWAY_API_KEY_PATH`] two-CRD-
23592 // groups-sharing-a-string re-exports established (two consts
23593 // spelling the same underlying string at distinct schema
23594 // axes stay sibling constants at the rustc symbol-name axis).
23595 let v = FLUX_HELMCHART_TEMPLATE_KEY_CHART;
23596 assert!(
23597 !v.is_empty(),
23598 "FLUX_HELMCHART_TEMPLATE_KEY_CHART {v:?} must be non-empty per \
23599 the Flux v2 CRD field-naming grammar"
23600 );
23601 let mut chars = v.chars();
23602 assert!(
23603 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23604 "FLUX_HELMCHART_TEMPLATE_KEY_CHART {v:?} must lead with an \
23605 ASCII-lowercase byte per the Flux v2 lowerCamelCase per-CR-\
23606 field-key convention"
23607 );
23608 assert!(
23609 v.chars().all(|c| c.is_ascii_alphanumeric()),
23610 "FLUX_HELMCHART_TEMPLATE_KEY_CHART {v:?} must be ASCII-\
23611 alphanumeric throughout per the Flux v2 lowerCamelCase per-CR-\
23612 field-key convention — no `_` / `-` / `.` / whitespace bytes \
23613 the Flux v2 helm-controller's per-CR reconcile loop would reject"
23614 );
23615 }
23616
23617 #[test]
23618 fn flux_helmchart_template_key_chart_and_flux_key_chart_stay_independent_axes() {
23619 // Cross-axis independence pin: both `FLUX_HELMCHART_TEMPLATE_KEY_CHART`
23620 // (`spec.chart.spec.chart` chart-NAME reference leaf-scalar-axis)
23621 // and the sibling `FLUX_KEY_CHART` (`spec.chart` per-CR chart-
23622 // template container-axis parent) spell the same underlying
23623 // `"chart"` string today but name distinct schema axes on the
23624 // same Flux v2 `HelmRelease` CRD group (a container-axis parent
23625 // vs a leaf-scalar grandchild inside it). Pin byte-equality of
23626 // each half against its own canonical declaration so a future
23627 // Flux v3 rebrand on either axis lands independently at the
23628 // rustc symbol-name axis rather than coalescing onto one
23629 // canonical declaration through a shared `&'static str`
23630 // allocation Rust's string interner would otherwise fuse.
23631 // Same axis-independence discipline the sibling
23632 // [`CILIUM_KEY_PATH`] (ef6114f) / [`GATEWAY_API_KEY_PATH`]
23633 // (9f45aa4) two-CRD-groups-sharing-a-string re-exports
23634 // established on the peer canonical-axis-independence surface.
23635 assert_eq!(FLUX_HELMCHART_TEMPLATE_KEY_CHART, "chart");
23636 assert_eq!(FLUX_KEY_CHART, "chart");
23637 assert_eq!(FLUX_HELMCHART_TEMPLATE_KEY_CHART, FLUX_KEY_CHART);
23638 }
23639
23640 #[test]
23641 fn flux_key_health_checks_pins_canonical_value() {
23642 // Pin the actual string so a typo in this lift can't silently
23643 // rebrand the Flux v2 per-`Kustomization` health-gate reference-
23644 // list container-axis key the rendered `kustomization.yaml`'s
23645 // `spec.healthChecks` block declares. The string is part of the
23646 // cluster-side contract with the Flux v2 `kustomize-controller`
23647 // — the per-CR reconcile loop reads the nested
23648 // `[]NamespacedObjectKindReference` list under this exact
23649 // container axis to gate the parent `Kustomization`'s
23650 // `Ready=True` transition on the referenced sibling
23651 // `HelmRelease` reaching its `HelmReleaseReady=True` condition;
23652 // a drifted value (`"HealthChecks"` / `"healthchecks"` /
23653 // `"healthcheck"` / `"health_checks"` / `"probes"`) silently
23654 // dangles the parent `Kustomization` at `Reconciling` forever
23655 // at the kustomize-controller's health-gate evaluation, and the
23656 // dependent per-cluster fleet-programs upsert chain never sees
23657 // `Ready=True`. Changing this value is a coordinated Flux v3
23658 // migration alongside the upstream `fluxcd/flux2` deprecation
23659 // cycle, not an incidental edit. Peer to
23660 // `flux_key_source_ref_pins_canonical_value` /
23661 // `flux_key_chart_pins_canonical_value` /
23662 // `flux_key_values_pins_canonical_value` on the sibling Flux v2
23663 // body-key surfaces — extends the canonical-Flux-v2-load-bearing-
23664 // string pin discipline from the per-`HelmRelease` triplet
23665 // (`spec.chart` + `spec.chart.spec.sourceRef` + `spec.values`)
23666 // onto the sibling per-`Kustomization` `spec.healthChecks`
23667 // reference-list container-axis, completing the quartet of Flux
23668 // v2 `spec.*` body-key pin tests.
23669 assert_eq!(FLUX_KEY_HEALTH_CHECKS, "healthChecks");
23670 }
23671
23672 #[test]
23673 fn flux_key_health_checks_carries_lower_camel_case_shape() {
23674 // Cross-axis invariant: the Flux v2 CRD field-naming convention
23675 // (inherited from the upstream K8s API conventions) admits
23676 // lowerCamelCase per-field keys — the per-`Kustomization`
23677 // health-gate reference-list container-axis conforms to this on
23678 // the leading-lowercase `healthChecks` shape. Pinning the shape
23679 // here means a future rebrand on the canonical lift can't
23680 // silently land a malformed container-axis key (snake_case,
23681 // kebab-case, UpperCamelCase, empty) that the Flux v2 kustomize-
23682 // controller's per-CR reconcile loop would reject at apply
23683 // parse time far from the rebrand commit's source. Peer to
23684 // `flux_key_source_ref_carries_lower_camel_case_shape` /
23685 // `flux_key_chart_carries_lower_camel_case_shape` /
23686 // `flux_key_values_carries_lower_camel_case_shape` on the
23687 // sibling Flux v2 body-key surfaces.
23688 let v = FLUX_KEY_HEALTH_CHECKS;
23689 assert!(
23690 !v.is_empty(),
23691 "FLUX_KEY_HEALTH_CHECKS {v:?} must be non-empty per the Flux \
23692 v2 CRD field-naming grammar"
23693 );
23694 let mut chars = v.chars();
23695 assert!(
23696 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23697 "FLUX_KEY_HEALTH_CHECKS {v:?} must lead with an ASCII-\
23698 lowercase byte per the Flux v2 lowerCamelCase per-CR-field-\
23699 key convention"
23700 );
23701 assert!(
23702 v.chars().all(|c| c.is_ascii_alphanumeric()),
23703 "FLUX_KEY_HEALTH_CHECKS {v:?} must be ASCII-alphanumeric \
23704 throughout per the Flux v2 lowerCamelCase per-CR-field-key \
23705 convention — no `_` / `-` / `.` / whitespace bytes the Flux \
23706 v2 kustomize-controller's per-CR reconcile loop would reject"
23707 );
23708 }
23709
23710 #[test]
23711 fn flux_key_interval_pins_canonical_value() {
23712 // Pin the actual string so a typo in this lift can't silently
23713 // rebrand the Flux v2 per-CR reconcile-poll cadence scalar-axis
23714 // key the rendered Flux bundle's three `spec.interval` scalars
23715 // declare — the shared axis-key the source-controller, helm-
23716 // controller, and kustomize-controller each read to schedule
23717 // their per-CR poll cycles off the sibling per-CR `apiVersion` +
23718 // `kind` registration. A drifted value (`"Interval"` / `"period"`
23719 // / `"cadence"` / `"pollInterval"` / `"reconcileInterval"`)
23720 // silently drops the per-CR reconcile schedule from all three
23721 // Flux controllers' per-CR watch registrations simultaneously —
23722 // the referenced Git source never re-polls / the referenced
23723 // chart never re-templates / the parent Kustomization never
23724 // re-applies at upstream drift, freezing the whole cluster's
23725 // per-`caixa` per-cluster bundle at the last-applied snapshot.
23726 // Changing this value is a coordinated Flux v3 migration
23727 // alongside the upstream `fluxcd/flux2` deprecation cycle, not
23728 // an incidental edit. Peer to
23729 // `flux_key_source_ref_pins_canonical_value` /
23730 // `flux_key_chart_pins_canonical_value` /
23731 // `flux_key_values_pins_canonical_value` /
23732 // `flux_key_health_checks_pins_canonical_value` on the sibling
23733 // Flux v2 per-CR body-key surfaces — extends the canonical-Flux-
23734 // v2-load-bearing-string pin discipline from the per-CR body-key
23735 // quartet onto the sibling cross-CR-shared reconcile-poll
23736 // cadence scalar-axis every Flux v2 controller reads.
23737 assert_eq!(FLUX_KEY_INTERVAL, "interval");
23738 }
23739
23740 #[test]
23741 fn flux_key_interval_carries_lower_camel_case_shape() {
23742 // Cross-axis invariant: the Flux v2 CRD field-naming convention
23743 // (inherited from the upstream K8s API conventions) admits
23744 // lowerCamelCase per-field keys — the per-CR reconcile-poll
23745 // cadence scalar-axis conforms to this on the leading-lowercase
23746 // `interval` shape. Pinning the shape here means a future rebrand
23747 // on the canonical lift can't silently land a malformed scalar-
23748 // axis key (snake_case, kebab-case, UpperCamelCase, empty) that
23749 // any of the three Flux v2 controllers' per-CR reconcile loops
23750 // would reject at apply parse time far from the rebrand commit's
23751 // source. Peer to `flux_key_source_ref_carries_lower_camel_case_shape`
23752 // / `flux_key_chart_carries_lower_camel_case_shape` /
23753 // `flux_key_values_carries_lower_camel_case_shape` /
23754 // `flux_key_health_checks_carries_lower_camel_case_shape` on the
23755 // sibling Flux v2 per-CR body-key surfaces.
23756 let v = FLUX_KEY_INTERVAL;
23757 assert!(
23758 !v.is_empty(),
23759 "FLUX_KEY_INTERVAL {v:?} must be non-empty per the Flux \
23760 v2 CRD field-naming grammar"
23761 );
23762 let mut chars = v.chars();
23763 assert!(
23764 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23765 "FLUX_KEY_INTERVAL {v:?} must lead with an ASCII-\
23766 lowercase byte per the Flux v2 lowerCamelCase per-CR-field-\
23767 key convention"
23768 );
23769 assert!(
23770 v.chars().all(|c| c.is_ascii_alphanumeric()),
23771 "FLUX_KEY_INTERVAL {v:?} must be ASCII-alphanumeric \
23772 throughout per the Flux v2 lowerCamelCase per-CR-field-key \
23773 convention — no `_` / `-` / `.` / whitespace bytes any of \
23774 the three Flux v2 controllers' per-CR reconcile loops would \
23775 reject"
23776 );
23777 }
23778
23779 #[test]
23780 fn flux_gitrepository_ref_key_tag_pins_canonical_value() {
23781 // Pin the actual string so a typo in this lift can't silently
23782 // rebrand the Flux v2 per-`GitRepository` `spec.ref.tag`
23783 // git-tag-selector scalar-axis key the rendered
23784 // `gitrepository.yaml` document declares on the tag-arm of the
23785 // FluxCD source-controller `spec.ref` discriminated-union axis.
23786 // A drifted value (`"Tag"` / `"gitTag"` / `"tagName"`) silently
23787 // dangles the tag-arm sub-block at the FluxCD source-controller's
23788 // CRD registration; the per-Servico clone never resolves at
23789 // reconcile time. Peer to
23790 // `flux_gitrepository_ref_key_branch_pins_canonical_value` /
23791 // `flux_gitrepository_ref_key_commit_pins_canonical_value` on
23792 // the sibling per-shape arms of the same discriminated-union
23793 // axis — closes the three-arm sub-selector-key trio the
23794 // FluxCD source-controller reads to bind the per-CR git-source
23795 // clone refspec.
23796 assert_eq!(FLUX_GITREPOSITORY_REF_KEY_TAG, "tag");
23797 }
23798
23799 #[test]
23800 fn flux_gitrepository_ref_key_branch_pins_canonical_value() {
23801 // Peer of `flux_gitrepository_ref_key_tag_pins_canonical_value`
23802 // on the branch-arm of the FluxCD source-controller
23803 // `GitRepository.spec.ref` discriminated-union axis.
23804 assert_eq!(FLUX_GITREPOSITORY_REF_KEY_BRANCH, "branch");
23805 }
23806
23807 #[test]
23808 fn flux_gitrepository_ref_key_commit_pins_canonical_value() {
23809 // Peer of `flux_gitrepository_ref_key_tag_pins_canonical_value`
23810 // on the commit-arm of the FluxCD source-controller
23811 // `GitRepository.spec.ref` discriminated-union axis.
23812 assert_eq!(FLUX_GITREPOSITORY_REF_KEY_COMMIT, "commit");
23813 }
23814
23815 #[test]
23816 fn flux_gitrepository_key_ref_pins_canonical_value() {
23817 // Bridge-arm pin: [`FLUX_GITREPOSITORY_KEY_REF`] resolves to
23818 // the canonical `"ref"` byte today — the exact YAML key the
23819 // FluxCD `source-controller` reads on every rendered
23820 // `GitRepository` document's `spec.ref` container-axis to
23821 // source the per-CR git-clone refspec discriminated-union
23822 // arm (`{tag, branch, commit}`). Pin the literal here (peer
23823 // with the sibling
23824 // [`flux_gitrepository_ref_key_tag_pins_canonical_value`] /
23825 // [`flux_gitrepository_ref_key_branch_pins_canonical_value`] /
23826 // [`flux_gitrepository_ref_key_commit_pins_canonical_value`]
23827 // per-shape arm sub-selector pins on the same `spec.ref`
23828 // sub-schema) so a future Flux v3 sub-schema rebrand on the
23829 // parent container-axis surfaces here as a coordinated edit-
23830 // point at the definition site rather than a silent apply-
23831 // time split between the writer-side template composer and
23832 // the aggregator's per-CR `RESTMapper` reader.
23833 assert_eq!(FLUX_GITREPOSITORY_KEY_REF, "ref");
23834 }
23835
23836 #[test]
23837 fn flux_gitrepository_key_url_pins_canonical_value() {
23838 // Bridge-arm pin: [`FLUX_GITREPOSITORY_KEY_URL`] resolves to
23839 // the canonical `"url"` byte today — the exact YAML key the
23840 // FluxCD `source-controller` reads on every rendered
23841 // `GitRepository` document's `spec.url` leaf-scalar-axis to
23842 // source the per-CR git-remote clone target. Pin the literal
23843 // here (peer with the sibling
23844 // [`flux_gitrepository_key_ref_pins_canonical_value`] on the
23845 // per-CR `spec.ref` container-axis surface) so a future Flux
23846 // v3 sub-schema rebrand on the URL axis (e.g. an upstream
23847 // `fluxcd/flux2` rename of `spec.url` to `spec.gitUrl` /
23848 // `spec.repository`) surfaces here as a coordinated edit-
23849 // point at the definition site rather than a silent apply-
23850 // time split between the writer-side template composer and
23851 // the source-controller's per-CR `RESTMapper` reader.
23852 assert_eq!(FLUX_GITREPOSITORY_KEY_URL, "url");
23853 }
23854
23855 #[test]
23856 fn flux_gitrepository_key_url_stays_independent_of_ref_and_api_version() {
23857 // Cross-axis peer-independence pin: the per-`GitRepository`-CRD
23858 // canonical-load-bearing-string surface carries three distinct
23859 // axes on the same CRD — `apiVersion`
23860 // ([`FLUX_GITREPOSITORY_API_VERSION`], the CRD-group/version
23861 // half of the `(apiVersion, kind)` apiserver-side CRD-lookup
23862 // tuple), `spec.ref`
23863 // ([`FLUX_GITREPOSITORY_KEY_REF`], the per-CR ref-selection
23864 // container-axis), and `spec.url`
23865 // ([`FLUX_GITREPOSITORY_KEY_URL`], the per-CR remote-repo-URL
23866 // leaf-scalar-axis). These three constants spell mutually
23867 // distinct schema axes on the same Flux v2 `source-controller`
23868 // CRD; pinning distinctness here means a future rebrand on
23869 // any one axis (a Flux v3 CRD-version bump, a `spec.ref`
23870 // container-axis rename, or a `spec.url` schema promotion)
23871 // surfaces as an edit on the corresponding canonical const
23872 // alone, without silently collapsing the three axes into one
23873 // edit-point at the rustc symbol-name axis.
23874 assert_ne!(FLUX_GITREPOSITORY_KEY_URL, FLUX_GITREPOSITORY_KEY_REF);
23875 assert_ne!(FLUX_GITREPOSITORY_KEY_URL, FLUX_GITREPOSITORY_API_VERSION);
23876 }
23877
23878 #[test]
23879 fn flux_gitrepository_ref_keys_all_carry_lower_camel_case_shape() {
23880 // Cross-axis invariant on all three arms of the FluxCD
23881 // source-controller `GitRepository.spec.ref` discriminated-union
23882 // axis: the Flux v2 CRD field-naming convention (inherited from
23883 // the upstream K8s API conventions) admits lowerCamelCase
23884 // per-field keys — `tag` / `branch` / `commit` all conform.
23885 // Pinning the shape here means a future rebrand on any of the
23886 // three canonical lifts can't silently land a malformed
23887 // sub-selector key (snake_case, kebab-case, UpperCamelCase,
23888 // empty) that the Flux v2 source-controller's per-CR reconcile
23889 // loop would reject at apply parse time. Peer to
23890 // `flux_key_interval_carries_lower_camel_case_shape` on the
23891 // sibling per-CR reconcile-poll-cadence scalar-axis key surface.
23892 for v in [
23893 FLUX_GITREPOSITORY_REF_KEY_TAG,
23894 FLUX_GITREPOSITORY_REF_KEY_BRANCH,
23895 FLUX_GITREPOSITORY_REF_KEY_COMMIT,
23896 ] {
23897 assert!(
23898 !v.is_empty(),
23899 "FLUX_GITREPOSITORY_REF_KEY_* {v:?} must be non-empty \
23900 per the Flux v2 CRD field-naming grammar"
23901 );
23902 let mut chars = v.chars();
23903 assert!(
23904 chars.next().is_some_and(|c| c.is_ascii_lowercase()),
23905 "FLUX_GITREPOSITORY_REF_KEY_* {v:?} must lead with an \
23906 ASCII-lowercase byte per the Flux v2 lowerCamelCase \
23907 per-CR-field-key convention"
23908 );
23909 assert!(
23910 v.chars().all(|c| c.is_ascii_alphanumeric()),
23911 "FLUX_GITREPOSITORY_REF_KEY_* {v:?} must be ASCII-\
23912 alphanumeric throughout per the Flux v2 lowerCamelCase \
23913 per-CR-field-key convention — no `_` / `-` / `.` / \
23914 whitespace bytes the Flux v2 source-controller's per-CR \
23915 reconcile loop would reject"
23916 );
23917 }
23918 }
23919
23920 #[test]
23921 fn flux_gitrepository_ref_keys_are_pairwise_distinct() {
23922 // The three arms of the FluxCD source-controller
23923 // `GitRepository.spec.ref` discriminated-union axis must remain
23924 // pairwise distinct — a hypothetical drift that collapsed two
23925 // sub-selector keys onto the same byte-string (e.g. an
23926 // accidental copy-paste making TAG and BRANCH both spell
23927 // `"tag"`) would silently reroute the per-shape emit at
23928 // `caixa_flux::GitRefSpec::ref_field_name` dispatch time and
23929 // dangle one arm's rendered `spec.ref` sub-block at cluster-
23930 // apply time. Pin the pairwise-distinctness here so the drift
23931 // fires at test time, not at cluster-apply time far from the
23932 // drift site.
23933 let keys = [
23934 FLUX_GITREPOSITORY_REF_KEY_TAG,
23935 FLUX_GITREPOSITORY_REF_KEY_BRANCH,
23936 FLUX_GITREPOSITORY_REF_KEY_COMMIT,
23937 ];
23938 for (i, a) in keys.iter().enumerate() {
23939 for b in keys.iter().skip(i + 1) {
23940 assert_ne!(
23941 a, b,
23942 "FLUX_GITREPOSITORY_REF_KEY_* arms must be pairwise \
23943 distinct (got a duplicate: {a:?})"
23944 );
23945 }
23946 }
23947 }
23948
23949 #[test]
23950 fn flux_kind_kustomization_carries_upper_camel_case_shape() {
23951 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
23952 // an UpperCamelCase identifier per the K8s API conventions
23953 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
23954 // "Kinds are always UpperCamelCase"). Pinning the shape here
23955 // means a future rebrand on the canonical lift can't silently
23956 // land a malformed kind discriminator (snake_case, kebab-case,
23957 // lowercase, empty) that every downstream YAML-aware
23958 // deserializer would reject far from the rebrand commit's
23959 // source. The first-byte uppercase / rest-ASCII-alphanumeric
23960 // invariant is the load-bearing K8s API typed-discovery
23961 // contract: a value the apiserver's `RESTMapper` consults to
23962 // resolve the CRD's `RESTKind`. Peer to
23963 // `flux_kind_git_repository_carries_upper_camel_case_shape` /
23964 // `flux_kind_helm_release_carries_upper_camel_case_shape` on
23965 // the sibling Flux v2 controller-triplet `kind`-axis surface.
23966 let v = FLUX_KIND_KUSTOMIZATION;
23967 assert!(
23968 !v.is_empty(),
23969 "FLUX_KIND_KUSTOMIZATION {v:?} must be non-empty per the K8s API \
23970 UpperCamelCase kind discriminator grammar"
23971 );
23972 let first = v.chars().next().expect("non-empty");
23973 assert!(
23974 first.is_ascii_uppercase(),
23975 "FLUX_KIND_KUSTOMIZATION {v:?} first byte {first:?} must be \
23976 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
23977 grammar (Kinds are always UpperCamelCase)"
23978 );
23979 assert!(
23980 v.chars().all(|c| c.is_ascii_alphanumeric()),
23981 "FLUX_KIND_KUSTOMIZATION {v:?} must be ASCII-alphanumeric \
23982 throughout per the K8s API kind discriminator grammar — no \
23983 snake_case, kebab-case, or whitespace bytes the apiserver-side \
23984 RESTMapper would reject"
23985 );
23986 }
23987
23988 #[test]
23989 fn gateway_api_api_version_pins_canonical_value() {
23990 // Pin the actual string so a typo in this lift can't silently
23991 // rebrand the K8s SIG-Network Gateway API CRD group/version
23992 // the rendered `Gateway` / `HTTPRoute` documents declare. The
23993 // string is part of the cluster-side contract with the
23994 // upstream Gateway-API-conformant gateway implementation
23995 // (Cilium, Istio, Envoy Gateway, NGINX, et al.): the
23996 // apiserver-side CRD-version registration watches the exact
23997 // `gateway.networking.k8s.io/v1` group/version; a drifted
23998 // value to a stale v1beta1 / v1alpha2 lands the rendered
23999 // `Gateway` / `HTTPRoute` outside the registration and fails
24000 // at apply time with "no kind 'Gateway' is registered for
24001 // version 'gateway.networking.k8s.io/v1beta1'"; changing it
24002 // is a coordinated Gateway API GA promotion alongside the
24003 // upstream SIG-Network deprecation cycle, not an incidental
24004 // edit. Peer to `flux_kustomization_api_version_pins_canonical_value`
24005 // / `flux_helmrelease_api_version_pins_canonical_value` /
24006 // `flux_gitrepository_api_version_pins_canonical_value` on
24007 // the canonical-K8s-CRD-axis-pin axis for the sibling
24008 // Flux v2 controller-triplet constants — extends the
24009 // canonical-string-pin discipline from the cluster-side
24010 // Flux v2 reconcile contract onto the cluster-side K8s
24011 // Gateway API ingress contract.
24012 assert_eq!(GATEWAY_API_API_VERSION, "gateway.networking.k8s.io/v1");
24013 }
24014
24015 #[test]
24016 fn gateway_api_api_version_carries_group_and_version_segments() {
24017 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
24018 // `<group>/<version>` pair separated by exactly one `/` byte.
24019 // The group segment is a DNS-style multi-segment hostname
24020 // (`gateway.networking.k8s.io`) and the version segment is a
24021 // Kubernetes API version label (`v1`, `v1beta1`, `v1alpha2` —
24022 // peer with the K8s API versioning convention upstream
24023 // documents). Pinning this here means a future rebrand on the
24024 // canonical lift can't silently land a malformed apiVersion
24025 // (no `/`, two `/`, empty group, empty version) that every
24026 // downstream YAML-aware deserializer would reject far from the
24027 // rebrand commit's source. The single-`/` invariant is the
24028 // load-bearing K8s API typed-discovery contract: a value the
24029 // apiserver's `RESTMapper` consults to resolve the CRD's
24030 // `RESTKind`. Peer to
24031 // `flux_kustomization_api_version_carries_group_and_version_segments`
24032 // / `flux_helmrelease_api_version_carries_group_and_version_segments`
24033 // / `flux_gitrepository_api_version_carries_group_and_version_segments`
24034 // on the sibling Flux v2 controller-triplet CRD-axes.
24035 let v = GATEWAY_API_API_VERSION;
24036 let parts: Vec<&str> = v.split('/').collect();
24037 assert_eq!(
24038 parts.len(),
24039 2,
24040 "GATEWAY_API_API_VERSION {v:?} must split into exactly two \
24041 `/`-delimited segments (group/version) per the K8s CRD apiVersion \
24042 grammar — every downstream YAML-aware deserializer enforces this \
24043 shape"
24044 );
24045 assert!(
24046 !parts[0].is_empty(),
24047 "GATEWAY_API_API_VERSION {v:?} group segment must be non-empty"
24048 );
24049 assert!(
24050 !parts[1].is_empty(),
24051 "GATEWAY_API_API_VERSION {v:?} version segment must be non-empty"
24052 );
24053 assert!(
24054 parts[0].contains('.'),
24055 "GATEWAY_API_API_VERSION {v:?} group segment {group:?} must be a \
24056 DNS-style multi-segment hostname (the canonical CRD-group convention \
24057 every K8s controller-runtime / kube-rs-aware client expects)",
24058 group = parts[0]
24059 );
24060 }
24061
24062 #[test]
24063 fn cilium_api_version_pins_canonical_value() {
24064 // Pin the actual string so a typo in this lift can't silently
24065 // rebrand the Cilium CRD group/version the rendered
24066 // `CiliumNetworkPolicy` document declares. The string is part
24067 // of the cluster-side contract with the upstream Cilium
24068 // operator: the Cilium-operator-side CRD-version registration
24069 // watches the exact `cilium.io/v2` group/version; a drifted
24070 // value to a stale `v2alpha1` lands the rendered
24071 // `CiliumNetworkPolicy` outside the registration and fails at
24072 // apply time with "no kind 'CiliumNetworkPolicy' is registered
24073 // for version 'cilium.io/v2alpha1'"; changing it is a
24074 // coordinated Cilium-CRD promotion alongside the upstream
24075 // Cilium deprecation cycle, not an incidental edit. Peer to
24076 // `gateway_api_api_version_pins_canonical_value` /
24077 // `flux_kustomization_api_version_pins_canonical_value` /
24078 // `flux_helmrelease_api_version_pins_canonical_value` /
24079 // `flux_gitrepository_api_version_pins_canonical_value` on
24080 // the canonical-K8s-CRD-axis-pin axis for the sibling
24081 // K8s Gateway API + Flux v2 controller-triplet constants —
24082 // extends the canonical-string-pin discipline from the
24083 // cluster-side K8s Gateway API ingress + Flux v2 reconcile
24084 // contracts onto the cluster-side Cilium identity-based mesh
24085 // contract.
24086 assert_eq!(CILIUM_API_VERSION, "cilium.io/v2");
24087 }
24088
24089 #[test]
24090 fn cilium_api_version_carries_group_and_version_segments() {
24091 // Cross-axis invariant: a Kubernetes CRD `apiVersion` is a
24092 // `<group>/<version>` pair separated by exactly one `/` byte.
24093 // The group segment is a DNS-style hostname (`cilium.io`) and
24094 // the version segment is a Kubernetes API version label (`v2`,
24095 // `v2alpha1` — peer with the K8s API versioning convention
24096 // upstream documents). Pinning this here means a future rebrand
24097 // on the canonical lift can't silently land a malformed
24098 // apiVersion (no `/`, two `/`, empty group, empty version) that
24099 // every downstream YAML-aware deserializer would reject far
24100 // from the rebrand commit's source. The single-`/` invariant
24101 // is the load-bearing K8s API typed-discovery contract: a value
24102 // the apiserver's `RESTMapper` consults to resolve the CRD's
24103 // `RESTKind`. Peer to
24104 // `gateway_api_api_version_carries_group_and_version_segments`
24105 // / `flux_kustomization_api_version_carries_group_and_version_segments`
24106 // / `flux_helmrelease_api_version_carries_group_and_version_segments`
24107 // / `flux_gitrepository_api_version_carries_group_and_version_segments`
24108 // on the sibling K8s Gateway API + Flux v2 controller-triplet
24109 // CRD-axes.
24110 let v = CILIUM_API_VERSION;
24111 let parts: Vec<&str> = v.split('/').collect();
24112 assert_eq!(
24113 parts.len(),
24114 2,
24115 "CILIUM_API_VERSION {v:?} must split into exactly two \
24116 `/`-delimited segments (group/version) per the K8s CRD apiVersion \
24117 grammar — every downstream YAML-aware deserializer enforces this \
24118 shape"
24119 );
24120 assert!(
24121 !parts[0].is_empty(),
24122 "CILIUM_API_VERSION {v:?} group segment must be non-empty"
24123 );
24124 assert!(
24125 !parts[1].is_empty(),
24126 "CILIUM_API_VERSION {v:?} version segment must be non-empty"
24127 );
24128 assert!(
24129 parts[0].contains('.'),
24130 "CILIUM_API_VERSION {v:?} group segment {group:?} must be a \
24131 DNS-style hostname (the canonical CRD-group convention \
24132 every K8s controller-runtime / kube-rs-aware client expects)",
24133 group = parts[0]
24134 );
24135 }
24136
24137 #[test]
24138 fn cilium_kind_network_policy_pins_canonical_value() {
24139 // Pin the actual string so a typo in this lift can't silently
24140 // rebrand the Cilium-operator-side `CiliumNetworkPolicy` CRD
24141 // `kind` discriminator the rendered CNP document's top-level
24142 // `kind` axis declares. The string is part of the cluster-side
24143 // contract with the upstream Cilium operator — the apiserver-side
24144 // CRD resolution contract is the `(apiVersion, kind)` tuple
24145 // keyed against the registered `CustomResourceDefinition`, so
24146 // the kind half of the tuple is exactly as load-bearing as the
24147 // sibling [`CILIUM_API_VERSION`] apiVersion half. A drifted
24148 // value (e.g. an upstream rename to `CiliumNetworkPolicyV2`)
24149 // lands the rendered document outside the Cilium operator's
24150 // CRD registration; changing it is a coordinated Cilium-CRD
24151 // promotion alongside the upstream Cilium deprecation cycle,
24152 // not an incidental edit. Peer to
24153 // `flux_kind_kustomization_pins_canonical_value` /
24154 // `flux_kind_helm_release_pins_canonical_value` /
24155 // `flux_kind_git_repository_pins_canonical_value` on the
24156 // sibling cluster-side-CRD-`kind`-discriminator pin set —
24157 // extends the canonical-string-pin discipline from the Flux v2
24158 // controller-triplet `kind`-axis surface onto the Cilium-CRD
24159 // `kind`-axis surface, completing the per-Cilium-CRD
24160 // kind+apiVersion canonical-pin pair the M3 Aplicacao mesh
24161 // renderer's eBPF data-plane contract rests on.
24162 assert_eq!(CILIUM_KIND_NETWORK_POLICY, "CiliumNetworkPolicy");
24163 }
24164
24165 #[test]
24166 fn cilium_kind_network_policy_carries_upper_camel_case_shape() {
24167 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
24168 // an UpperCamelCase identifier per the K8s API conventions
24169 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
24170 // "Kinds are always UpperCamelCase"). Pinning the shape here
24171 // means a future rebrand on the canonical lift can't silently
24172 // land a malformed kind discriminator (snake_case, kebab-case,
24173 // lowercase, empty) that every downstream YAML-aware
24174 // deserializer would reject far from the rebrand commit's
24175 // source. The first-byte uppercase / rest-ASCII-alphanumeric
24176 // invariant is the load-bearing K8s API typed-discovery
24177 // contract: a value the apiserver's `RESTMapper` consults to
24178 // resolve the CRD's `RESTKind`. Peer to
24179 // `flux_kind_kustomization_carries_upper_camel_case_shape` /
24180 // `flux_kind_helm_release_carries_upper_camel_case_shape` /
24181 // `flux_kind_git_repository_carries_upper_camel_case_shape` on
24182 // the sibling cluster-side-CRD-`kind`-discriminator surface.
24183 let v = CILIUM_KIND_NETWORK_POLICY;
24184 assert!(
24185 !v.is_empty(),
24186 "CILIUM_KIND_NETWORK_POLICY {v:?} must be non-empty per the K8s API \
24187 UpperCamelCase kind discriminator grammar"
24188 );
24189 let first = v.chars().next().expect("non-empty");
24190 assert!(
24191 first.is_ascii_uppercase(),
24192 "CILIUM_KIND_NETWORK_POLICY {v:?} first byte {first:?} must be \
24193 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
24194 grammar (Kinds are always UpperCamelCase)"
24195 );
24196 assert!(
24197 v.chars().all(|c| c.is_ascii_alphanumeric()),
24198 "CILIUM_KIND_NETWORK_POLICY {v:?} must be ASCII-alphanumeric \
24199 throughout per the K8s API kind discriminator grammar — no \
24200 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24201 RESTMapper would reject"
24202 );
24203 }
24204
24205 #[test]
24206 fn cilium_key_to_ports_pins_canonical_value() {
24207 // Pin the actual string so a typo in this lift can't silently
24208 // rebrand the Cilium CNP `spec.ingress[].toPorts[]` per-ingress-
24209 // rule port-set-container-axis key the rendered CNP document
24210 // mounts its per-port-set `{ports: […], rules: {…}}` list under.
24211 // The string is part of the cluster-side contract with the
24212 // upstream Cilium operator — the Cilium-operator-side per-CNP
24213 // L4/L7-dispatch pass keys off this axis to route the per-port
24214 // set through the eBPF data-plane's L4-allow (via `ports`) /
24215 // L7-dispatch (via nested `rules`) branches; a drifted value
24216 // (`"toport"` / `"toPort"` / `"targetPorts"`) at either the
24217 // production emitter or a downstream renderer's per-ingress-rule
24218 // port-set upsert silently emits a per-ingress-rule entry whose
24219 // port-set container the Cilium CRD schema validator drops as
24220 // unknown, and every intra-mesh `:contratos` flow the affected
24221 // CNP was authored to allow drops at the eBPF data-plane's
24222 // default-deny gate. Changing this value is a coordinated
24223 // Cilium-CRD promotion alongside the upstream Cilium project's
24224 // CRD schema-migration cycle, not an incidental edit. Peer to
24225 // `kube_key_rules_pins_canonical_value` (the nested
24226 // `spec.ingress[].toPorts[].rules` axis-key pin the L7-dispatch
24227 // container nests inside this port-set container's each entry)
24228 // on the sibling per-CNP-dispatch-axis pin set — completes the
24229 // per-CNP L4/L7-dispatch-container `(toPorts, rules)` pin pair
24230 // the M3 Aplicacao mesh renderer's eBPF data-plane contract
24231 // rests on.
24232 assert_eq!(CILIUM_KEY_TO_PORTS, "toPorts");
24233 }
24234
24235 #[test]
24236 fn cilium_key_to_ports_carries_lower_camel_case_shape() {
24237 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24238 // lowerCamelCase identifier per the K8s API conventions
24239 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24240 // "Field names should be lowercase camelCase") — first byte
24241 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24242 // kebab-case or whitespace. Pinning the shape here means a
24243 // future rebrand on the canonical lift can't silently land a
24244 // malformed field-name discriminator (snake_case, kebab-case,
24245 // UpperCamelCase, empty) that the apiserver-side CRD schema
24246 // validator would reject far from the rebrand commit's source.
24247 // The first-byte lowercase / rest-ASCII-alphanumeric invariant
24248 // is the load-bearing K8s API typed-schema contract: a value
24249 // the apiserver-side OpenAPI schema validator consults to
24250 // resolve each CR-field's typed slot. Peer to the sibling
24251 // per-CNP `kind`-axis
24252 // `cilium_kind_network_policy_carries_upper_camel_case_shape`
24253 // pin — the UpperCamelCase K8s discriminator grammar governs
24254 // the top-level `kind` axis, the lowerCamelCase K8s field-name
24255 // grammar governs every nested schema-field axis (including
24256 // this per-ingress-rule port-set-container-axis key), same
24257 // convention distinct grammars.
24258 let v = CILIUM_KEY_TO_PORTS;
24259 assert!(
24260 !v.is_empty(),
24261 "CILIUM_KEY_TO_PORTS {v:?} must be non-empty per the K8s API \
24262 lowerCamelCase field-name grammar"
24263 );
24264 let first = v.chars().next().expect("non-empty");
24265 assert!(
24266 first.is_ascii_lowercase(),
24267 "CILIUM_KEY_TO_PORTS {v:?} first byte {first:?} must be \
24268 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24269 grammar (field names are always lowerCamelCase)"
24270 );
24271 assert!(
24272 v.chars().all(|c| c.is_ascii_alphanumeric()),
24273 "CILIUM_KEY_TO_PORTS {v:?} must be ASCII-alphanumeric \
24274 throughout per the K8s API field-name grammar — no \
24275 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24276 OpenAPI schema validator would reject"
24277 );
24278 }
24279
24280 #[test]
24281 fn cilium_key_endpoint_selector_pins_canonical_value() {
24282 // Pin the actual string so a typo in this lift can't silently
24283 // rebrand the Cilium CNP `spec.endpointSelector` destination-
24284 // identity-axis key the rendered CNP document mounts its
24285 // L3-target `LabelSelector` under. The string is part of the
24286 // cluster-side contract with the upstream Cilium operator —
24287 // the Cilium-operator-side per-CNP identity-resolution pass
24288 // keys off this axis to bind the emitted policy against its
24289 // destination workload identity via the K8s LabelSelector
24290 // schema; a drifted value (`"endpointselector"` /
24291 // `"endpointSelectors"` / `"endpoints"`) at either the
24292 // production emitter or a downstream renderer's per-CNP
24293 // destination-identity upsert silently emits a CNP whose
24294 // destination-identity axis the Cilium CRD schema validator
24295 // drops as unknown, and the policy binds against no
24296 // destination pods — every intra-mesh `:contratos` flow the
24297 // affected CNP was authored to allow drops at the eBPF
24298 // data-plane's default-deny gate. Changing this value is a
24299 // coordinated Cilium-CRD promotion alongside the upstream
24300 // Cilium project's CRD schema-migration cycle, not an
24301 // incidental edit. Peer to `cilium_key_to_ports_pins_\
24302 // canonical_value` (the per-ingress-rule port-set container
24303 // axis-key pin the L3-target selector pairs with under the
24304 // shared per-CNP-body schema) on the sibling per-CNP-body-axis
24305 // pin set — completes the per-CNP L3/L4/L7-triad
24306 // `(endpointSelector, ingress → toPorts → rules)` pin set the
24307 // M3 Aplicacao mesh renderer's eBPF data-plane contract rests
24308 // on.
24309 assert_eq!(CILIUM_KEY_ENDPOINT_SELECTOR, "endpointSelector");
24310 }
24311
24312 #[test]
24313 fn cilium_key_endpoint_selector_carries_lower_camel_case_shape() {
24314 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24315 // lowerCamelCase identifier per the K8s API conventions
24316 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24317 // "Field names should be lowercase camelCase") — first byte
24318 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24319 // kebab-case or whitespace. Pinning the shape here means a
24320 // future rebrand on the canonical lift can't silently land a
24321 // malformed field-name discriminator (snake_case, kebab-case,
24322 // UpperCamelCase, empty) that the apiserver-side CRD schema
24323 // validator would reject far from the rebrand commit's source.
24324 // Peer to `cilium_key_to_ports_carries_lower_camel_case_shape`
24325 // on the sibling per-CNP-body-axis grammar-pin set — the
24326 // lowerCamelCase K8s field-name grammar governs every nested
24327 // schema-field axis (including this per-CNP destination-
24328 // identity-axis key), same convention.
24329 let v = CILIUM_KEY_ENDPOINT_SELECTOR;
24330 assert!(
24331 !v.is_empty(),
24332 "CILIUM_KEY_ENDPOINT_SELECTOR {v:?} must be non-empty per the K8s API \
24333 lowerCamelCase field-name grammar"
24334 );
24335 let first = v.chars().next().expect("non-empty");
24336 assert!(
24337 first.is_ascii_lowercase(),
24338 "CILIUM_KEY_ENDPOINT_SELECTOR {v:?} first byte {first:?} must be \
24339 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24340 grammar (field names are always lowerCamelCase)"
24341 );
24342 assert!(
24343 v.chars().all(|c| c.is_ascii_alphanumeric()),
24344 "CILIUM_KEY_ENDPOINT_SELECTOR {v:?} must be ASCII-alphanumeric \
24345 throughout per the K8s API field-name grammar — no \
24346 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24347 OpenAPI schema validator would reject"
24348 );
24349 }
24350
24351 #[test]
24352 fn cilium_key_ingress_pins_canonical_value() {
24353 // Pin the actual string so a typo in this lift can't silently
24354 // rebrand the Cilium CNP `spec.ingress[]` traffic-direction
24355 // container-axis key the rendered CNP document mounts its
24356 // permitted per-`(:de, :para)` inbound-ingress-rule list under.
24357 // The string is part of the cluster-side contract with the
24358 // upstream Cilium operator — the Cilium-operator-side per-CNP
24359 // L4/L7-dispatch pass keys off this axis to route the per-CNP
24360 // ingress-rule list through the eBPF data-plane's inbound-
24361 // traffic dispatch branch; a drifted value (`"Ingress"` /
24362 // `"ingressRules"` / `"inbound"`) at either the production
24363 // emitter or a downstream renderer's per-CNP traffic-direction
24364 // upsert silently emits a CNP whose ingress-rule list the
24365 // Cilium CRD schema validator drops as unknown, and every
24366 // intra-mesh `:contratos` flow the affected CNP was authored to
24367 // allow drops at the eBPF data-plane's default-deny gate.
24368 // Changing this value is a coordinated Cilium-CRD promotion
24369 // alongside the upstream Cilium project's CRD schema-migration
24370 // cycle, not an incidental edit. Peer to
24371 // `cilium_key_endpoint_selector_pins_canonical_value` (the
24372 // destination-identity axis-key pin the traffic-direction
24373 // container axis-key sits alongside under the shared per-CNP-
24374 // body schema) + `cilium_key_to_ports_pins_canonical_value`
24375 // (the per-ingress-rule port-set container axis-key pin the
24376 // traffic-direction axis nests) on the sibling per-CNP-body-
24377 // axis pin set — completes the per-CNP L3/L4/L7-triad
24378 // `(endpointSelector, ingress → toPorts → rules)` pin set the
24379 // M3 Aplicacao mesh renderer's eBPF data-plane contract rests
24380 // on.
24381 assert_eq!(CILIUM_KEY_INGRESS, "ingress");
24382 }
24383
24384 #[test]
24385 fn cilium_key_ingress_carries_lower_camel_case_shape() {
24386 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24387 // lowerCamelCase identifier per the K8s API conventions
24388 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24389 // "Field names should be lowercase camelCase") — first byte
24390 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24391 // kebab-case or whitespace. Pinning the shape here means a
24392 // future rebrand on the canonical lift can't silently land a
24393 // malformed field-name discriminator (snake_case, kebab-case,
24394 // UpperCamelCase, empty) that the apiserver-side CRD schema
24395 // validator would reject far from the rebrand commit's source.
24396 // Peer to `cilium_key_endpoint_selector_carries_lower_camel_\
24397 // case_shape` / `cilium_key_to_ports_carries_lower_camel_case_\
24398 // shape` on the sibling per-CNP-body-axis grammar-pin set — the
24399 // lowerCamelCase K8s field-name grammar governs every nested
24400 // schema-field axis (including this per-CNP traffic-direction-
24401 // axis key), same convention.
24402 let v = CILIUM_KEY_INGRESS;
24403 assert!(
24404 !v.is_empty(),
24405 "CILIUM_KEY_INGRESS {v:?} must be non-empty per the K8s API \
24406 lowerCamelCase field-name grammar"
24407 );
24408 let first = v.chars().next().expect("non-empty");
24409 assert!(
24410 first.is_ascii_lowercase(),
24411 "CILIUM_KEY_INGRESS {v:?} first byte {first:?} must be \
24412 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24413 grammar (field names are always lowerCamelCase)"
24414 );
24415 assert!(
24416 v.chars().all(|c| c.is_ascii_alphanumeric()),
24417 "CILIUM_KEY_INGRESS {v:?} must be ASCII-alphanumeric \
24418 throughout per the K8s API field-name grammar — no \
24419 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24420 OpenAPI schema validator would reject"
24421 );
24422 }
24423
24424 #[test]
24425 fn cilium_key_from_endpoints_pins_canonical_value() {
24426 // Pin the actual string so a typo in this lift can't silently
24427 // rebrand the Cilium CNP `spec.ingress[].fromEndpoints[]`
24428 // identity-source selector-list-axis key the rendered CNP
24429 // document mounts its permitted-source `LabelSelector` list
24430 // under. The string is part of the cluster-side contract with
24431 // the upstream Cilium operator — the Cilium-operator-side per-
24432 // CNP identity-resolution pass keys off this axis to bind the
24433 // emitted ingress rule against the admitted source workload
24434 // identities via the K8s LabelSelector schema; a drifted value
24435 // (`"fromendpoints"` / `"fromEndPoint"` / `"sourceEndpoints"`)
24436 // at either the production emitter or a downstream renderer's
24437 // per-ingress-rule identity-source upsert silently emits a CNP
24438 // whose per-ingress-rule identity-source axis the Cilium CRD
24439 // schema validator drops as unknown, and the ingress rule
24440 // admits no source pods — every intra-mesh `:contratos` flow
24441 // the affected CNP was authored to allow drops at the eBPF
24442 // data-plane's default-deny gate. Changing this value is a
24443 // coordinated Cilium-CRD promotion alongside the upstream
24444 // Cilium project's CRD schema-migration cycle, not an
24445 // incidental edit. Peer to
24446 // `cilium_key_endpoint_selector_pins_canonical_value` (the
24447 // destination-identity axis-key pin the identity-source axis
24448 // structurally pairs with under the SPIFFE-identity-bound per-
24449 // CNP access-control contract) on the sibling per-CNP identity-
24450 // pair pin set — completes the per-CNP identity-pair
24451 // `(endpointSelector, fromEndpoints)` pin set the M3 Aplicacao
24452 // mesh renderer's eBPF data-plane contract rests on.
24453 assert_eq!(CILIUM_KEY_FROM_ENDPOINTS, "fromEndpoints");
24454 }
24455
24456 #[test]
24457 fn cilium_key_from_endpoints_carries_lower_camel_case_shape() {
24458 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24459 // lowerCamelCase identifier per the K8s API conventions
24460 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24461 // "Field names should be lowercase camelCase") — first byte
24462 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24463 // kebab-case or whitespace. Pinning the shape here means a
24464 // future rebrand on the canonical lift can't silently land a
24465 // malformed field-name discriminator (snake_case, kebab-case,
24466 // UpperCamelCase, empty) that the apiserver-side CRD schema
24467 // validator would reject far from the rebrand commit's source.
24468 // Peer to `cilium_key_endpoint_selector_carries_lower_camel_\
24469 // case_shape` / `cilium_key_ingress_carries_lower_camel_case_\
24470 // shape` / `cilium_key_to_ports_carries_lower_camel_case_shape`
24471 // on the sibling per-CNP-body-axis grammar-pin set — the
24472 // lowerCamelCase K8s field-name grammar governs every nested
24473 // schema-field axis (including this per-ingress-rule identity-
24474 // source-axis key), same convention.
24475 let v = CILIUM_KEY_FROM_ENDPOINTS;
24476 assert!(
24477 !v.is_empty(),
24478 "CILIUM_KEY_FROM_ENDPOINTS {v:?} must be non-empty per the K8s API \
24479 lowerCamelCase field-name grammar"
24480 );
24481 let first = v.chars().next().expect("non-empty");
24482 assert!(
24483 first.is_ascii_lowercase(),
24484 "CILIUM_KEY_FROM_ENDPOINTS {v:?} first byte {first:?} must be \
24485 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24486 grammar (field names are always lowerCamelCase)"
24487 );
24488 assert!(
24489 v.chars().all(|c| c.is_ascii_alphanumeric()),
24490 "CILIUM_KEY_FROM_ENDPOINTS {v:?} must be ASCII-alphanumeric \
24491 throughout per the K8s API field-name grammar — no \
24492 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24493 OpenAPI schema validator would reject"
24494 );
24495 }
24496
24497 #[test]
24498 fn cilium_key_ports_pins_canonical_value() {
24499 // Pin the actual string so a typo in this lift can't silently
24500 // rebrand the Cilium CNP `spec.ingress[].toPorts[].ports[]`
24501 // per-`toPorts[]`-entry L4-port-tuple-list-container-axis key
24502 // the rendered CNP document mounts its per-port-set
24503 // `[{port, protocol}]` list under. The string is part of the
24504 // cluster-side contract with the upstream Cilium operator —
24505 // the Cilium-operator-side per-CNP L4-allow eBPF-program-
24506 // generation pass keys off this axis to source the per-port-set
24507 // `(port, protocol)` tuples the emitted ingress rule admits; a
24508 // drifted value (`"port"` / `"portList"` / `"L4Ports"`) at
24509 // either the production emitter or a downstream renderer's
24510 // per-`toPorts[]`-entry L4-port-tuple-list upsert silently
24511 // emits a per-`toPorts[]` entry whose L4-port-tuple-list-
24512 // container axis the Cilium CRD schema validator drops as
24513 // unknown, and the port-set admits no `(port, protocol)`
24514 // tuple — every intra-mesh `:contratos` flow the affected CNP
24515 // was authored to allow drops at the eBPF data-plane's
24516 // default-deny gate. Changing this value is a coordinated
24517 // Cilium-CRD promotion alongside the upstream Cilium project's
24518 // CRD schema-migration cycle, not an incidental edit. Peer to
24519 // `cilium_key_to_ports_pins_canonical_value` (the outer per-
24520 // ingress-rule port-set-container axis-key pin the L4 port-
24521 // tuple-list-container axis nests inside) on the sibling per-
24522 // CNP-dispatch-axis pin set — completes the per-CNP L4-half
24523 // `(toPorts, ports)` container-pair pin the M3 Aplicacao mesh
24524 // renderer's eBPF data-plane L4-allow contract rests on.
24525 assert_eq!(CILIUM_KEY_PORTS, "ports");
24526 }
24527
24528 #[test]
24529 fn cilium_key_ports_carries_lower_camel_case_shape() {
24530 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24531 // lowerCamelCase identifier per the K8s API conventions
24532 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24533 // "Field names should be lowercase camelCase") — first byte
24534 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24535 // kebab-case or whitespace. Pinning the shape here means a
24536 // future rebrand on the canonical lift can't silently land a
24537 // malformed field-name discriminator (snake_case, kebab-case,
24538 // UpperCamelCase, empty) that the apiserver-side CRD schema
24539 // validator would reject far from the rebrand commit's source.
24540 // Peer to `cilium_key_endpoint_selector_carries_lower_camel_\
24541 // case_shape` / `cilium_key_ingress_carries_lower_camel_case_\
24542 // shape` / `cilium_key_to_ports_carries_lower_camel_case_shape`
24543 // / `cilium_key_from_endpoints_carries_lower_camel_case_shape`
24544 // on the sibling per-CNP-body-axis grammar-pin set — the
24545 // lowerCamelCase K8s field-name grammar governs every nested
24546 // schema-field axis (including this per-`toPorts[]`-entry L4-
24547 // port-tuple-list-container-axis key), same convention.
24548 let v = CILIUM_KEY_PORTS;
24549 assert!(
24550 !v.is_empty(),
24551 "CILIUM_KEY_PORTS {v:?} must be non-empty per the K8s API \
24552 lowerCamelCase field-name grammar"
24553 );
24554 let first = v.chars().next().expect("non-empty");
24555 assert!(
24556 first.is_ascii_lowercase(),
24557 "CILIUM_KEY_PORTS {v:?} first byte {first:?} must be \
24558 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24559 grammar (field names are always lowerCamelCase)"
24560 );
24561 assert!(
24562 v.chars().all(|c| c.is_ascii_alphanumeric()),
24563 "CILIUM_KEY_PORTS {v:?} must be ASCII-alphanumeric \
24564 throughout per the K8s API field-name grammar — no \
24565 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24566 OpenAPI schema validator would reject"
24567 );
24568 }
24569
24570 #[test]
24571 fn cilium_key_authentication_pins_canonical_value() {
24572 // Pin the actual string so a typo in this lift can't silently
24573 // rebrand the Cilium CNP `spec.ingress[].authentication`
24574 // per-ingress-rule mutual-auth-policy body-axis key the
24575 // rendered CNP document mounts its per-rule mTLS enforcement
24576 // block under. The string is part of the cluster-side
24577 // contract with the upstream Cilium operator — the Cilium-
24578 // operator-side per-CNP mutual-auth SPIFFE-handshake pipeline
24579 // keys off this axis to source the per-rule mTLS enforcement
24580 // mode (`required` vs `disabled`); a drifted value (`"auth"`
24581 // / `"mutualAuth"` / `"mtls"` / `"authPolicy"`) at either
24582 // the production emitter or a downstream renderer's per-
24583 // ingress-rule mutual-auth upsert silently emits a per-
24584 // `ingress[]` entry whose mutual-auth-axis the Cilium CRD
24585 // schema validator drops as unknown, and the ingress rule
24586 // falls back to the cluster-default authentication mode
24587 // (typically `"disabled"` — no mutual-auth enforcement)
24588 // silently bypassing the SPIFFE-identity-bound mTLS handshake
24589 // every intra-mesh `:contratos` flow the CNP was authored to
24590 // protect. Changing this value is a coordinated Cilium-CRD
24591 // promotion alongside the upstream Cilium project's CRD
24592 // schema-migration cycle, not an incidental edit. Peer to
24593 // `cilium_key_from_endpoints_pins_canonical_value` /
24594 // `cilium_key_to_ports_pins_canonical_value` (the sibling
24595 // per-ingress-rule-body-axis pins the mutual-auth axis pairs
24596 // with at the per-rule triple
24597 // `(fromEndpoints, toPorts, authentication)`) on the sibling
24598 // per-CNP-dispatch-axis pin set — completes the per-CNP per-
24599 // ingress-rule-body triple the M3 Aplicacao mesh renderer's
24600 // SPIFFE-identity-bound per-edge mTLS contract rests on.
24601 assert_eq!(CILIUM_KEY_AUTHENTICATION, "authentication");
24602 }
24603
24604 #[test]
24605 fn cilium_key_authentication_carries_lower_camel_case_shape() {
24606 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24607 // lowerCamelCase identifier per the K8s API conventions
24608 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24609 // "Field names should be lowercase camelCase") — first byte
24610 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24611 // kebab-case or whitespace. Pinning the shape here means a
24612 // future rebrand on the canonical lift can't silently land a
24613 // malformed field-name discriminator (snake_case, kebab-case,
24614 // UpperCamelCase, empty) that the apiserver-side CRD schema
24615 // validator would reject far from the rebrand commit's source.
24616 // Peer to `cilium_key_endpoint_selector_carries_lower_camel_\
24617 // case_shape` / `cilium_key_ingress_carries_lower_camel_case_\
24618 // shape` / `cilium_key_to_ports_carries_lower_camel_case_shape`
24619 // / `cilium_key_from_endpoints_carries_lower_camel_case_shape`
24620 // / `cilium_key_ports_carries_lower_camel_case_shape` on the
24621 // sibling per-CNP-body-axis grammar-pin set — the
24622 // lowerCamelCase K8s field-name grammar governs every nested
24623 // schema-field axis (including this per-`ingress[]`-entry
24624 // mutual-auth-policy body-axis key), same convention.
24625 let v = CILIUM_KEY_AUTHENTICATION;
24626 assert!(
24627 !v.is_empty(),
24628 "CILIUM_KEY_AUTHENTICATION {v:?} must be non-empty per the K8s API \
24629 lowerCamelCase field-name grammar"
24630 );
24631 let first = v.chars().next().expect("non-empty");
24632 assert!(
24633 first.is_ascii_lowercase(),
24634 "CILIUM_KEY_AUTHENTICATION {v:?} first byte {first:?} must be \
24635 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24636 grammar (field names are always lowerCamelCase)"
24637 );
24638 assert!(
24639 v.chars().all(|c| c.is_ascii_alphanumeric()),
24640 "CILIUM_KEY_AUTHENTICATION {v:?} must be ASCII-alphanumeric \
24641 throughout per the K8s API field-name grammar — no \
24642 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24643 OpenAPI schema validator would reject"
24644 );
24645 }
24646
24647 #[test]
24648 fn cilium_key_mode_pins_canonical_value() {
24649 // Pin the actual string so a typo in this lift can't silently
24650 // rebrand the Cilium CNP `spec.ingress[].authentication.mode`
24651 // per-ingress-rule mutual-auth-mode-discriminator leaf-scalar-
24652 // axis key the rendered CNP document mounts its per-rule mTLS
24653 // enforcement mode value under. The string is part of the
24654 // cluster-side contract with the upstream Cilium operator —
24655 // the Cilium-operator-side per-CNP mutual-auth SPIFFE-handshake
24656 // pipeline reads this leaf axis to source the per-rule mTLS
24657 // enforcement mode value (`"required"` vs `"disabled"`); a
24658 // drifted key (`"policy"` / `"authMode"` / `"handshakeMode"`)
24659 // at either the production emitter or a downstream renderer's
24660 // per-ingress-rule mutual-auth-mode-leaf upsert silently emits
24661 // a per-`ingress[]` entry whose mutual-auth block's mode-
24662 // discriminator leaf-axis the Cilium CRD schema validator
24663 // drops as unknown, and the ingress rule falls back to the
24664 // cluster-default authentication mode (typically `"disabled"`
24665 // — no mutual-auth enforcement) silently bypassing the SPIFFE-
24666 // identity-bound mTLS handshake every intra-mesh `:contratos`
24667 // flow the CNP was authored to protect. Changing this value is
24668 // a coordinated Cilium-CRD promotion alongside the upstream
24669 // Cilium project's CRD schema-migration cycle, not an
24670 // incidental edit. Peer to
24671 // `cilium_key_authentication_pins_canonical_value` on the
24672 // sibling per-ingress-rule mutual-auth body-axis pin set —
24673 // completes the per-rule mutual-auth
24674 // `(authentication → mode)` body/leaf axis pin pair the M3
24675 // Aplicacao mesh renderer's SPIFFE-identity-bound per-edge
24676 // mTLS enforcement contract rests on. Byte-identical to the
24677 // sibling `:politicas :circuit-breaker (:window)` /
24678 // `:placement :estrategia` overlay mode-like axes today, but
24679 // semantically distinct: this const names the Cilium CRD's
24680 // per-authentication-block mode-discriminator leaf-axis key
24681 // (spelled per the Cilium project's CRD schema), so a future
24682 // rebrand on the Cilium CRD's per-authentication-block mode-
24683 // leaf axis lands at its own canonical const without coupling
24684 // the Cilium schema to any peer surface that happens to carry
24685 // the same byte.
24686 assert_eq!(CILIUM_KEY_MODE, "mode");
24687 }
24688
24689 #[test]
24690 fn cilium_key_mode_carries_lower_camel_case_shape() {
24691 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24692 // lowerCamelCase identifier per the K8s API conventions
24693 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24694 // "Field names should be lowercase camelCase") — first byte
24695 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24696 // kebab-case or whitespace. Pinning the shape here means a
24697 // future rebrand on the canonical lift can't silently land a
24698 // malformed field-name discriminator (snake_case, kebab-case,
24699 // UpperCamelCase, empty) that the apiserver-side CRD schema
24700 // validator would reject far from the rebrand commit's source.
24701 // Peer to `cilium_key_authentication_carries_lower_camel_case_\
24702 // shape` on the sibling per-ingress-rule mutual-auth-body-axis
24703 // grammar-pin — the lowerCamelCase K8s field-name grammar
24704 // governs every nested schema-field axis (including this
24705 // per-authentication-block mode-discriminator leaf-axis key),
24706 // same convention.
24707 let v = CILIUM_KEY_MODE;
24708 assert!(
24709 !v.is_empty(),
24710 "CILIUM_KEY_MODE {v:?} must be non-empty per the K8s API \
24711 lowerCamelCase field-name grammar"
24712 );
24713 let first = v.chars().next().expect("non-empty");
24714 assert!(
24715 first.is_ascii_lowercase(),
24716 "CILIUM_KEY_MODE {v:?} first byte {first:?} must be \
24717 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24718 grammar (field names are always lowerCamelCase)"
24719 );
24720 assert!(
24721 v.chars().all(|c| c.is_ascii_alphanumeric()),
24722 "CILIUM_KEY_MODE {v:?} must be ASCII-alphanumeric \
24723 throughout per the K8s API field-name grammar — no \
24724 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24725 OpenAPI schema validator would reject"
24726 );
24727 }
24728
24729 #[test]
24730 fn cilium_key_http_pins_canonical_value() {
24731 // Pin the actual string so a typo in this lift can't silently
24732 // rebrand the Cilium CNP `spec.ingress[].toPorts[].rules.http`
24733 // per-`toPorts[]` L7-HTTP-rule-list-discriminator container-axis
24734 // key the rendered CNP document mounts its per-`toPorts[]` L7
24735 // URL-path-prefix predicate list under. The string is part of the
24736 // cluster-side contract with the upstream Cilium operator — the
24737 // Cilium-operator-side per-CNP L7 dispatch pipeline reads this
24738 // container axis to source the per-`toPorts[]` L7 URL-path-prefix
24739 // predicate list the ingress rule was authored to filter each
24740 // HTTP-shaped `:contratos` flow through; a drifted key (`"HTTP"` /
24741 // `"Http"` / `"httpRules"` / `"httpMatch"`) at either the
24742 // production emitter or a downstream renderer's per-`toPorts[]`
24743 // L7-rule-list-discriminator upsert silently emits a per-
24744 // `toPorts[]` entry whose L7-HTTP-rule-list-discriminator key the
24745 // Cilium CRD schema validator drops as unknown, and the per-
24746 // `toPorts[]` entry falls back to L4-only enforcement — no L7
24747 // URL-path predicate is applied — silently admitting every HTTP-
24748 // method / URL-path combination the ingress rule was authored to
24749 // filter to the exact path prefix set the typed `:contratos`
24750 // graph names at the L7 introspection axis. Changing this value
24751 // is a coordinated Cilium-CRD promotion alongside the upstream
24752 // Cilium project's CRD schema-migration cycle, not an incidental
24753 // edit. Peer to `cilium_key_mode_pins_canonical_value` /
24754 // `cilium_key_authentication_pins_canonical_value` on the
24755 // sibling per-ingress-rule mutual-auth body/leaf axis pin pair —
24756 // completes the per-`toPorts[]` L7-introspection
24757 // `(rules → http)` container/protocol-discriminator axis pin
24758 // pair the M3 Aplicacao mesh renderer's HTTP-shaped-`:contratos`
24759 // URL-path-prefix-filtering L7-enforcement contract rests on.
24760 // Byte-identical to the sibling `Gateway.spec.listeners[].name`
24761 // arbitrary-author-chosen listener-name today (`"http"` — the
24762 // author-chosen name for the substrate's V0 HTTP listener), but
24763 // semantically distinct: this const names the Cilium CRD's per-
24764 // `toPorts[]` L7-HTTP-rule-list-discriminator container-axis key
24765 // (spelled per the Cilium project's CRD schema), so a future
24766 // rebrand on the Cilium CRD's L7-HTTP-rule-list-discriminator
24767 // axis lands at its own canonical const without coupling the
24768 // Cilium schema to any peer surface that happens to carry the
24769 // same byte.
24770 assert_eq!(CILIUM_KEY_HTTP, "http");
24771 }
24772
24773 #[test]
24774 fn cilium_key_http_carries_lower_camel_case_shape() {
24775 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24776 // lowerCamelCase identifier per the K8s API conventions
24777 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24778 // "Field names should be lowercase camelCase") — first byte
24779 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24780 // kebab-case or whitespace. Pinning the shape here means a
24781 // future rebrand on the canonical lift can't silently land a
24782 // malformed field-name discriminator (snake_case, kebab-case,
24783 // UpperCamelCase, empty) that the apiserver-side CRD schema
24784 // validator would reject far from the rebrand commit's source.
24785 // Peer to `cilium_key_mode_carries_lower_camel_case_shape` /
24786 // `cilium_key_authentication_carries_lower_camel_case_shape` on
24787 // the sibling per-ingress-rule mutual-auth-body/leaf-axis
24788 // grammar-pin set — the lowerCamelCase K8s field-name grammar
24789 // governs every nested schema-field axis (including this per-
24790 // `toPorts[]` L7-HTTP-rule-list-discriminator container-axis
24791 // key), same convention.
24792 let v = CILIUM_KEY_HTTP;
24793 assert!(
24794 !v.is_empty(),
24795 "CILIUM_KEY_HTTP {v:?} must be non-empty per the K8s API \
24796 lowerCamelCase field-name grammar"
24797 );
24798 let first = v.chars().next().expect("non-empty");
24799 assert!(
24800 first.is_ascii_lowercase(),
24801 "CILIUM_KEY_HTTP {v:?} first byte {first:?} must be \
24802 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24803 grammar (field names are always lowerCamelCase)"
24804 );
24805 assert!(
24806 v.chars().all(|c| c.is_ascii_alphanumeric()),
24807 "CILIUM_KEY_HTTP {v:?} must be ASCII-alphanumeric \
24808 throughout per the K8s API field-name grammar — no \
24809 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24810 OpenAPI schema validator would reject"
24811 );
24812 }
24813
24814 #[test]
24815 fn kube_key_type_pins_canonical_value() {
24816 // Pin the actual string so a typo in this lift can't silently
24817 // rebrand the K8s discriminated-union `type` scalar-discriminator
24818 // container-axis key every rendered CR mounts its per-position
24819 // discriminated-union type-value under. The string is part of the
24820 // cluster-side contract with every K8s apiserver-side OpenAPI
24821 // schema validator — the Gateway API v1 gateway-class-controller's
24822 // per-`HTTPRouteMatch` path-selection-predicate dispatch pass
24823 // reads this scalar-key to source the path-match-strategy
24824 // discriminator (the closed `PathMatchType` OpenAPI schema enum's
24825 // `{Exact, PathPrefix, RegularExpression}` set) the per-rule L7
24826 // URL-path-filtering was authored to bind — a drifted key
24827 // (`"Type"` / `"kind"` / `"discriminator"` / `"predicate"`) at
24828 // either the production emitter or a downstream renderer's per-
24829 // `HTTPRouteMatch` path-selection-predicate discriminator upsert
24830 // silently emits a per-match entry whose discriminator scalar-key
24831 // the Gateway API v1 `HTTPPathMatch` OpenAPI schema validator
24832 // drops as unknown, and the per-match entry falls back to the
24833 // schema-side default path-match-strategy — silently admitting
24834 // every URL-path prefix the ingress rule was authored to filter
24835 // to the exact predicate the typed `:entrada :paths` slot names
24836 // at the request-path-selection axis. Changing this value is a
24837 // coordinated K8s-API-conventions promotion alongside the
24838 // upstream sig-architecture per-version deprecation cycle, not
24839 // an incidental edit. Peer to
24840 // `cilium_key_http_pins_canonical_value` /
24841 // `cilium_key_mode_pins_canonical_value` /
24842 // `cilium_key_authentication_pins_canonical_value` on the
24843 // sibling per-CRD-body-axis pin set — extends the canonical-
24844 // string-pin discipline from the per-CRD-body-axis surfaces
24845 // onto the load-bearing nested K8s-discriminated-union-type-
24846 // scalar-discriminator axis every downstream apiserver-side
24847 // OpenAPI-schema-validator / gateway-class-controller consumer
24848 // of the rendered mesh bundle keys off before it can commit to
24849 // a per-match request-path-selection predicate.
24850 assert_eq!(KUBE_KEY_TYPE, "type");
24851 }
24852
24853 #[test]
24854 fn kube_key_type_carries_lower_camel_case_shape() {
24855 // Cross-axis invariant: a Kubernetes CRD schema field name is a
24856 // lowerCamelCase identifier per the K8s API conventions
24857 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
24858 // "Field names should be lowercase camelCase") — first byte
24859 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
24860 // kebab-case or whitespace. Pinning the shape here means a
24861 // future rebrand on the canonical lift can't silently land a
24862 // malformed field-name discriminator (snake_case, kebab-case,
24863 // UpperCamelCase, empty) that the apiserver-side CRD schema
24864 // validator would reject far from the rebrand commit's source.
24865 // Peer to `cilium_key_http_carries_lower_camel_case_shape` /
24866 // `cilium_key_mode_carries_lower_camel_case_shape` /
24867 // `cilium_key_authentication_carries_lower_camel_case_shape` on
24868 // the sibling per-CRD-body-axis grammar-pin set — the
24869 // lowerCamelCase K8s field-name grammar governs every nested
24870 // schema-field axis (including this K8s-discriminated-union-
24871 // type-scalar-discriminator axis), same convention.
24872 let v = KUBE_KEY_TYPE;
24873 assert!(
24874 !v.is_empty(),
24875 "KUBE_KEY_TYPE {v:?} must be non-empty per the K8s API \
24876 lowerCamelCase field-name grammar"
24877 );
24878 let first = v.chars().next().expect("non-empty");
24879 assert!(
24880 first.is_ascii_lowercase(),
24881 "KUBE_KEY_TYPE {v:?} first byte {first:?} must be \
24882 ASCII-lowercase per the K8s API lowerCamelCase field-name \
24883 grammar (field names are always lowerCamelCase)"
24884 );
24885 assert!(
24886 v.chars().all(|c| c.is_ascii_alphanumeric()),
24887 "KUBE_KEY_TYPE {v:?} must be ASCII-alphanumeric \
24888 throughout per the K8s API field-name grammar — no \
24889 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24890 OpenAPI schema validator would reject"
24891 );
24892 }
24893
24894 #[test]
24895 fn gateway_api_kind_gateway_pins_canonical_value() {
24896 // Pin the actual string so a typo in this lift can't silently
24897 // rebrand the Gateway-API-conformant `Gateway` CRD `kind`
24898 // discriminator the rendered Gateway document's top-level
24899 // `kind` axis declares. The string is part of the cluster-side
24900 // contract with every Gateway-API-conformant gateway
24901 // implementation (Cilium, Istio, Envoy Gateway, NGINX) — the
24902 // apiserver-side CRD resolution contract is the
24903 // `(apiVersion, kind)` tuple keyed against the registered
24904 // `CustomResourceDefinition`, so the kind half of the tuple is
24905 // exactly as load-bearing as the sibling
24906 // [`GATEWAY_API_API_VERSION`] apiVersion half. A drifted value
24907 // (e.g. an upstream Gateway-API rebrand to `GatewayV1`) lands
24908 // the rendered document outside the apiserver-side CRD
24909 // registration; changing it is a coordinated Gateway-API
24910 // promotion alongside the upstream SIG-Network deprecation
24911 // cycle, not an incidental edit. Peer to
24912 // `cilium_kind_network_policy_pins_canonical_value` /
24913 // `flux_kind_kustomization_pins_canonical_value` /
24914 // `flux_kind_helm_release_pins_canonical_value` /
24915 // `flux_kind_git_repository_pins_canonical_value` on the
24916 // sibling cluster-side-CRD-`kind`-discriminator pin set —
24917 // extends the canonical-string-pin discipline from the
24918 // Cilium-CRD + Flux v2 controller-triplet `kind`-axis surfaces
24919 // onto the Gateway-API-CRD `kind`-axis surface, beginning the
24920 // per-Gateway-API-CRD kind+apiVersion canonical-pin pair the
24921 // M3 Aplicacao mesh renderer's external `:entrada` ingress
24922 // contract rests on.
24923 assert_eq!(GATEWAY_API_KIND_GATEWAY, "Gateway");
24924 }
24925
24926 #[test]
24927 fn gateway_api_kind_gateway_carries_upper_camel_case_shape() {
24928 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
24929 // an UpperCamelCase identifier per the K8s API conventions
24930 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
24931 // "Kinds are always UpperCamelCase"). Pinning the shape here
24932 // means a future rebrand on the canonical lift can't silently
24933 // land a malformed kind discriminator (snake_case, kebab-case,
24934 // lowercase, empty) that every downstream YAML-aware
24935 // deserializer would reject far from the rebrand commit's
24936 // source. The first-byte uppercase / rest-ASCII-alphanumeric
24937 // invariant is the load-bearing K8s API typed-discovery
24938 // contract: a value the apiserver's `RESTMapper` consults to
24939 // resolve the CRD's `RESTKind`. Peer to
24940 // `cilium_kind_network_policy_carries_upper_camel_case_shape` /
24941 // `flux_kind_kustomization_carries_upper_camel_case_shape` /
24942 // `flux_kind_helm_release_carries_upper_camel_case_shape` /
24943 // `flux_kind_git_repository_carries_upper_camel_case_shape` on
24944 // the sibling cluster-side-CRD-`kind`-discriminator surface.
24945 let v = GATEWAY_API_KIND_GATEWAY;
24946 assert!(
24947 !v.is_empty(),
24948 "GATEWAY_API_KIND_GATEWAY {v:?} must be non-empty per the K8s API \
24949 UpperCamelCase kind discriminator grammar"
24950 );
24951 let first = v.chars().next().expect("non-empty");
24952 assert!(
24953 first.is_ascii_uppercase(),
24954 "GATEWAY_API_KIND_GATEWAY {v:?} first byte {first:?} must be \
24955 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
24956 grammar (Kinds are always UpperCamelCase)"
24957 );
24958 assert!(
24959 v.chars().all(|c| c.is_ascii_alphanumeric()),
24960 "GATEWAY_API_KIND_GATEWAY {v:?} must be ASCII-alphanumeric \
24961 throughout per the K8s API kind discriminator grammar — no \
24962 snake_case, kebab-case, or whitespace bytes the apiserver-side \
24963 RESTMapper would reject"
24964 );
24965 }
24966
24967 #[test]
24968 fn gateway_api_kind_http_route_pins_canonical_value() {
24969 // Pin the actual string so a typo in this lift can't silently
24970 // rebrand the Gateway-API-conformant `HTTPRoute` CRD `kind`
24971 // discriminator the rendered HTTPRoute document's top-level
24972 // `kind` axis declares. The string is part of the cluster-side
24973 // contract with every Gateway-API-conformant gateway
24974 // implementation (Cilium, Istio, Envoy Gateway, NGINX) — the
24975 // apiserver-side CRD resolution contract is the
24976 // `(apiVersion, kind)` tuple keyed against the registered
24977 // `CustomResourceDefinition`, so the kind half of the tuple is
24978 // exactly as load-bearing as the sibling
24979 // [`GATEWAY_API_API_VERSION`] apiVersion half. A drifted value
24980 // (e.g. an upstream Gateway-API rebrand to `HTTPRouteV1`) lands
24981 // the rendered document outside the apiserver-side CRD
24982 // registration; changing it is a coordinated Gateway-API
24983 // promotion alongside the upstream SIG-Network deprecation
24984 // cycle, not an incidental edit. Peer to
24985 // `gateway_api_kind_gateway_pins_canonical_value` /
24986 // `cilium_kind_network_policy_pins_canonical_value` /
24987 // `flux_kind_kustomization_pins_canonical_value` /
24988 // `flux_kind_helm_release_pins_canonical_value` /
24989 // `flux_kind_git_repository_pins_canonical_value` on the
24990 // sibling cluster-side-CRD-`kind`-discriminator pin set —
24991 // completes the per-Gateway-API-CRD `kind`-axis canonical-pin
24992 // pair across the `(Gateway, HTTPRoute)` pair the renderer's
24993 // `gateway_routes` external `:entrada` ingress contract emits
24994 // together.
24995 assert_eq!(GATEWAY_API_KIND_HTTP_ROUTE, "HTTPRoute");
24996 }
24997
24998 #[test]
24999 fn gateway_api_kind_http_route_carries_upper_camel_case_shape() {
25000 // Cross-axis invariant: a Kubernetes CRD `kind` discriminator is
25001 // an UpperCamelCase identifier per the K8s API conventions
25002 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#types-kinds —
25003 // "Kinds are always UpperCamelCase"). Acronyms like HTTP stay
25004 // ASCII-uppercase across the prefix per the same convention
25005 // (the K8s API Kinds for `HTTPRoute`, `TCPRoute`, `TLSRoute`,
25006 // `GRPCRoute` carry the full-uppercase protocol acronym).
25007 // Pinning the shape here means a future rebrand on the
25008 // canonical lift can't silently land a malformed kind
25009 // discriminator (snake_case, kebab-case, lowercase, empty)
25010 // that every downstream YAML-aware deserializer would reject
25011 // far from the rebrand commit's source. The first-byte
25012 // uppercase / rest-ASCII-alphanumeric invariant is the
25013 // load-bearing K8s API typed-discovery contract: a value the
25014 // apiserver's `RESTMapper` consults to resolve the CRD's
25015 // `RESTKind`. Peer to
25016 // `gateway_api_kind_gateway_carries_upper_camel_case_shape` /
25017 // `cilium_kind_network_policy_carries_upper_camel_case_shape` /
25018 // `flux_kind_kustomization_carries_upper_camel_case_shape` /
25019 // `flux_kind_helm_release_carries_upper_camel_case_shape` /
25020 // `flux_kind_git_repository_carries_upper_camel_case_shape` on
25021 // the sibling cluster-side-CRD-`kind`-discriminator surface.
25022 let v = GATEWAY_API_KIND_HTTP_ROUTE;
25023 assert!(
25024 !v.is_empty(),
25025 "GATEWAY_API_KIND_HTTP_ROUTE {v:?} must be non-empty per the K8s API \
25026 UpperCamelCase kind discriminator grammar"
25027 );
25028 let first = v.chars().next().expect("non-empty");
25029 assert!(
25030 first.is_ascii_uppercase(),
25031 "GATEWAY_API_KIND_HTTP_ROUTE {v:?} first byte {first:?} must be \
25032 ASCII-uppercase per the K8s API UpperCamelCase kind discriminator \
25033 grammar (Kinds are always UpperCamelCase)"
25034 );
25035 assert!(
25036 v.chars().all(|c| c.is_ascii_alphanumeric()),
25037 "GATEWAY_API_KIND_HTTP_ROUTE {v:?} must be ASCII-alphanumeric \
25038 throughout per the K8s API kind discriminator grammar — no \
25039 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25040 RESTMapper would reject"
25041 );
25042 }
25043
25044 #[test]
25045 fn gateway_api_protocol_http_pins_canonical_value() {
25046 // Pin the actual string so a typo in this lift can't silently
25047 // rebrand the Gateway API v1 `ProtocolType` OpenAPI schema enum's
25048 // canonical `HTTP` listener-protocol value the rendered
25049 // `Gateway.spec.listeners[].protocol` scalar declares. The value
25050 // is part of the cluster-side contract with every Gateway-API-
25051 // conformant gateway implementation (Cilium, Istio, Envoy
25052 // Gateway, NGINX) — the gateway-class-controller's per-listener
25053 // bind loop keys off this exact byte-sequence to select the L7
25054 // parser + TLS termination strategy; the Gateway API v1
25055 // `ProtocolType` OpenAPI schema enum admits the closed set
25056 // `{"HTTP", "HTTPS", "TCP", "TLS", "UDP"}` verbatim, so a
25057 // drifted value (`"http"` / `"Http"` / `"HTTP/1.1"` / `"http/1.1"`)
25058 // lands the rendered `Gateway` outside the `ProtocolType` enum's
25059 // admitted set and every external `:entrada` HTTP flow drops at
25060 // the gateway-class-controller's admission gate. Changing this
25061 // value is a coordinated Gateway API `ProtocolType` promotion
25062 // alongside the upstream SIG-Network deprecation cycle, not an
25063 // incidental edit. Peer to
25064 // `gateway_api_kind_gateway_pins_canonical_value` /
25065 // `gateway_api_kind_http_route_pins_canonical_value` /
25066 // `default_gateway_class_name_pins_canonical_value` on the
25067 // sibling Gateway-API-CRD-`kind`-discriminator + Gateway-
25068 // controller-binding-scalar-value pin set — extends the pair
25069 // of `kind`-axis canonical-value pins across the
25070 // `(Gateway, HTTPRoute)` pair onto the sibling per-Gateway
25071 // `spec.listeners[].protocol` listener-protocol-scalar-value axis
25072 // the same `gateway_routes` external `:entrada` ingress emitter
25073 // carries.
25074 assert_eq!(GATEWAY_API_PROTOCOL_HTTP, "HTTP");
25075 }
25076
25077 #[test]
25078 fn gateway_api_protocol_http_carries_upper_case_shape() {
25079 // Cross-axis invariant: the Gateway API v1 `ProtocolType` OpenAPI
25080 // schema enum admits the closed set
25081 // `{"HTTP", "HTTPS", "TCP", "TLS", "UDP"}` — every admitted value
25082 // is ASCII-uppercase throughout per the upstream SIG-Network
25083 // Gateway API convention (see
25084 // https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.ProtocolType
25085 // — the admitted values are the transport / application-layer
25086 // protocol acronyms in their canonical uppercase form). Pinning
25087 // the shape here means a future rebrand on the canonical lift
25088 // can't silently land a malformed listener-protocol scalar
25089 // (lowercase `"http"`, mixed-case `"Http"`, dotted `"HTTP/1.1"`,
25090 // empty) that the K8s Gateway API v1 `ProtocolType` OpenAPI
25091 // schema enum would reject at admission time far from the
25092 // rebrand commit's source. The all-ASCII-uppercase invariant is
25093 // the load-bearing Gateway-API-implementation-side typed
25094 // listener-parser-selection contract: a value the gateway-
25095 // class-controller's per-listener bind loop selects the L7
25096 // parser + TLS termination strategy from.
25097 let v = GATEWAY_API_PROTOCOL_HTTP;
25098 assert!(
25099 !v.is_empty(),
25100 "GATEWAY_API_PROTOCOL_HTTP {v:?} must be non-empty per the \
25101 Gateway API v1 `ProtocolType` OpenAPI schema enum grammar"
25102 );
25103 assert!(
25104 v.chars().all(|c| c.is_ascii_uppercase()),
25105 "GATEWAY_API_PROTOCOL_HTTP {v:?} must be ASCII-uppercase \
25106 throughout per the Gateway API v1 `ProtocolType` OpenAPI \
25107 schema enum convention — no lowercase, mixed-case, dotted, \
25108 or whitespace bytes the gateway-class-controller's per-\
25109 listener bind loop would reject"
25110 );
25111 }
25112
25113 #[test]
25114 fn gateway_api_path_match_type_path_prefix_pins_canonical_value() {
25115 // Pin the actual string so a typo in this lift can't silently
25116 // rebrand the Gateway API v1 `PathMatchType` OpenAPI schema
25117 // enum's canonical `PathPrefix` per-`HTTPRouteMatch` path-
25118 // selection-predicate discriminator value the rendered
25119 // `HTTPRoute.spec.rules[].matches[].path.type` scalar declares.
25120 // The value is part of the cluster-side contract with every
25121 // Gateway-API-conformant gateway implementation (Cilium, Istio,
25122 // Envoy Gateway, NGINX) — the gateway-class-controller's
25123 // per-rule L7 dispatch loop keys off this exact byte-sequence
25124 // to select the request-path-selection predicate; the Gateway
25125 // API v1 `PathMatchType` OpenAPI schema enum admits the closed
25126 // set `{"Exact", "PathPrefix", "RegularExpression"}` verbatim,
25127 // so a drifted value (`"pathPrefix"` / `"path_prefix"` /
25128 // `"Prefix"` / `"path-prefix"`) lands the rendered `HTTPRoute`
25129 // outside the `PathMatchType` enum's admitted set and every
25130 // external `:entrada` path-filtered flow drops at the gateway-
25131 // class-controller's admission gate. Changing this value is a
25132 // coordinated Gateway API `PathMatchType` promotion alongside
25133 // the upstream SIG-Network deprecation cycle, not an incidental
25134 // edit. Peer to
25135 // `gateway_api_protocol_http_pins_canonical_value` /
25136 // `gateway_api_kind_gateway_pins_canonical_value` /
25137 // `gateway_api_kind_http_route_pins_canonical_value` /
25138 // `default_gateway_class_name_pins_canonical_value` on the
25139 // sibling Gateway-API-v1-OpenAPI-schema-enum-value +
25140 // Gateway-API-CRD-`kind`-discriminator + Gateway-controller-
25141 // binding-scalar-value pin set — extends the canonical-
25142 // Gateway-API-v1-OpenAPI-schema-enum-value single-sourcing
25143 // discipline the `ProtocolType.HTTP` pin established onto the
25144 // sibling `PathMatchType.PathPrefix` per-`HTTPRouteMatch`
25145 // path-selection-predicate discriminator the same
25146 // `gateway_routes` external `:entrada` ingress emitter carries
25147 // under the shared `HTTPRoute` body.
25148 assert_eq!(GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX, "PathPrefix");
25149 }
25150
25151 #[test]
25152 fn gateway_api_path_match_type_path_prefix_carries_upper_camel_case_shape() {
25153 // Cross-axis invariant: the Gateway API v1 `PathMatchType`
25154 // OpenAPI schema enum admits the closed set
25155 // `{"Exact", "PathPrefix", "RegularExpression"}` — every
25156 // admitted value is UpperCamelCase per the upstream SIG-Network
25157 // Gateway API convention (see
25158 // https://gateway-api.sigs.k8s.io/reference/spec/#gateway.networking.k8s.io/v1.PathMatchType
25159 // — the admitted values are the request-path-selection
25160 // predicate names in their canonical UpperCamelCase form,
25161 // matching the K8s API `Kinds are always UpperCamelCase`
25162 // convention the sibling `GATEWAY_API_KIND_*` discriminators
25163 // carry on the CRD-`kind`-axis surface). Pinning the shape
25164 // here means a future rebrand on the canonical lift can't
25165 // silently land a malformed path-match-type scalar (lowercase
25166 // `"pathprefix"`, snake_case `"path_prefix"`, kebab-case
25167 // `"path-prefix"`, empty) that the K8s Gateway API v1
25168 // `PathMatchType` OpenAPI schema enum would reject at
25169 // admission time far from the rebrand commit's source. The
25170 // first-byte uppercase / rest-ASCII-alphanumeric invariant is
25171 // the load-bearing Gateway-API-implementation-side typed
25172 // per-match request-path-selection-predicate-selection
25173 // contract: a value the gateway-class-controller's per-rule
25174 // L7 dispatch loop selects the request-path-predicate
25175 // evaluator from. Peer to
25176 // `gateway_api_kind_gateway_carries_upper_camel_case_shape` /
25177 // `gateway_api_kind_http_route_carries_upper_camel_case_shape`
25178 // on the sibling cluster-side-CRD-`kind`-discriminator
25179 // UpperCamelCase pin set — extends the canonical-K8s-API-
25180 // UpperCamelCase-typed-discriminator pin discipline the
25181 // `Kind` axis carries onto the sibling Gateway API v1
25182 // `PathMatchType` OpenAPI schema enum's per-value
25183 // UpperCamelCase surface (distinct from the sibling
25184 // Gateway API v1 `ProtocolType` OpenAPI schema enum's all-
25185 // ASCII-uppercase per-value convention the
25186 // `gateway_api_protocol_http_carries_upper_case_shape` pin
25187 // carries — the two peer Gateway-API-v1 OpenAPI schema
25188 // enum-value conventions do not collapse).
25189 let v = GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX;
25190 assert!(
25191 !v.is_empty(),
25192 "GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX {v:?} must be non-empty per \
25193 the Gateway API v1 `PathMatchType` OpenAPI schema enum grammar"
25194 );
25195 let first = v.chars().next().expect("non-empty");
25196 assert!(
25197 first.is_ascii_uppercase(),
25198 "GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX {v:?} first byte {first:?} \
25199 must be ASCII-uppercase per the Gateway API v1 `PathMatchType` \
25200 OpenAPI schema enum UpperCamelCase convention"
25201 );
25202 assert!(
25203 v.chars().all(|c| c.is_ascii_alphanumeric()),
25204 "GATEWAY_API_PATH_MATCH_TYPE_PATH_PREFIX {v:?} must be ASCII-\
25205 alphanumeric throughout per the Gateway API v1 `PathMatchType` \
25206 OpenAPI schema enum UpperCamelCase convention — no snake_case, \
25207 kebab-case, or whitespace bytes the gateway-class-controller's \
25208 per-rule L7 dispatch loop would reject"
25209 );
25210 }
25211
25212 #[test]
25213 fn kube_protocol_tcp_pins_canonical_value() {
25214 // Pin the actual string so a typo in this lift can't silently
25215 // rebrand the K8s core `Protocol` OpenAPI schema enum's
25216 // canonical `TCP` L4-transport-protocol scalar value the
25217 // rendered `CiliumNetworkPolicy.spec.ingress[].toPorts[].ports[]
25218 // .protocol` scalar declares. The value is part of the cluster-
25219 // side contract with every K8s-core-`Protocol`-conformant CNI
25220 // + kube-proxy + eBPF-data-plane implementation (Cilium,
25221 // Calico, kube-proxy iptables/ipvs) — the CNI's per-CNP L4
25222 // dispatch pass keys off this exact byte-sequence to select
25223 // the per-tuple L4-transport-protocol predicate; the K8s core
25224 // `Protocol` OpenAPI schema enum admits the closed set
25225 // `{"TCP", "UDP", "SCTP"}` verbatim (see
25226 // https://kubernetes.io/docs/reference/generated/kubernetes-api/v1/#protocol-v1-core),
25227 // so a drifted value (`"tcp"` / `"Tcp"` / `"TCP/IP"` /
25228 // `"transport-tcp"`) lands the rendered `CiliumNetworkPolicy`
25229 // outside the `Protocol` enum's admitted set and every intra-
25230 // mesh `:contratos` L4-tuple-gated flow drops at the Cilium
25231 // operator's admission gate. Changing this value is a
25232 // coordinated K8s core `Protocol` promotion alongside the
25233 // upstream SIG-Network deprecation cycle, not an incidental
25234 // edit. Peer to
25235 // `gateway_api_protocol_http_pins_canonical_value` /
25236 // `gateway_api_path_match_type_path_prefix_pins_canonical_value`
25237 // on the sibling Gateway-API-v1-OpenAPI-schema-enum-value pin
25238 // set — extends the canonical-cluster-side-OpenAPI-schema-enum-
25239 // value single-sourcing discipline the Gateway-API v1
25240 // `ProtocolType.HTTP` / `PathMatchType.PathPrefix` pins
25241 // established onto the sibling K8s-core `Protocol.TCP` per-port-
25242 // tuple L4-transport-protocol-discriminator the
25243 // `cilium_network_policies` intra-mesh L4-tuple-gating emitter
25244 // carries under the shared `CiliumNetworkPolicy` body.
25245 assert_eq!(KUBE_PROTOCOL_TCP, "TCP");
25246 }
25247
25248 #[test]
25249 fn kube_protocol_tcp_carries_upper_case_shape() {
25250 // Cross-axis invariant: the K8s core `Protocol` OpenAPI schema
25251 // enum admits the closed set `{"TCP", "UDP", "SCTP"}` — every
25252 // admitted value is ASCII-uppercase throughout per the upstream
25253 // SIG-Network convention (the admitted values are the L4-
25254 // transport-protocol acronyms in their canonical uppercase form,
25255 // matching the sibling Gateway-API v1 `ProtocolType` OpenAPI
25256 // schema enum's `{"HTTP", "HTTPS", "TCP", "TLS", "UDP"}` all-
25257 // ASCII-uppercase convention the
25258 // `gateway_api_protocol_http_carries_upper_case_shape` pin
25259 // carries on the peer per-listener L7-parser-selection scalar
25260 // axis). Pinning the shape here means a future rebrand on the
25261 // canonical lift can't silently land a malformed L4-transport-
25262 // protocol scalar (lowercase `"tcp"`, mixed-case `"Tcp"`,
25263 // dotted `"TCP/IP"`, empty) that the K8s core `Protocol`
25264 // OpenAPI schema enum would reject at admission time far from
25265 // the rebrand commit's source. The all-ASCII-uppercase
25266 // invariant is the load-bearing K8s-core-`Protocol`-enum-side
25267 // typed L4-transport-selection contract: a value the CNI's per-
25268 // CNP L4 dispatch pass selects the per-tuple L4-transport-
25269 // protocol predicate from. Peer to
25270 // `gateway_api_protocol_http_carries_upper_case_shape` on the
25271 // sibling Gateway-API v1 `ProtocolType` OpenAPI schema enum's
25272 // all-ASCII-uppercase per-value convention pin set — the two
25273 // peer canonical-cluster-side-OpenAPI-schema-enum-value
25274 // uppercase conventions collapse on the shared `TCP` transport-
25275 // protocol acronym both `Protocol` enums admit at the closed-
25276 // set intersection.
25277 let v = KUBE_PROTOCOL_TCP;
25278 assert!(
25279 !v.is_empty(),
25280 "KUBE_PROTOCOL_TCP {v:?} must be non-empty per the K8s core \
25281 `Protocol` OpenAPI schema enum grammar"
25282 );
25283 assert!(
25284 v.chars().all(|c| c.is_ascii_uppercase()),
25285 "KUBE_PROTOCOL_TCP {v:?} must be ASCII-uppercase throughout \
25286 per the K8s core `Protocol` OpenAPI schema enum convention \
25287 — no lowercase, mixed-case, dotted, or whitespace bytes the \
25288 CNI's per-CNP L4 dispatch pass would reject"
25289 );
25290 }
25291
25292 #[test]
25293 fn cilium_auth_mode_required_pins_canonical_value() {
25294 // Pin the actual string so a typo in this lift can't silently
25295 // rebrand the Cilium `CiliumNetworkPolicy` `MutualAuthenticationMode`
25296 // OpenAPI schema enum's `required` mTLS-mandatory scalar-value the
25297 // rendered CNP's `spec.ingress[].authentication.mode` leaf declares
25298 // under the `:mtls-required t` affirmative arm of the typed
25299 // `:politicas :mtls-required` tristate. The value is part of the
25300 // cluster-side contract with the Cilium-agent-side per-rule mutual-
25301 // auth-block schema validator — the agent's per-rule dispatch loop
25302 // keys off this exact byte-sequence to select the SPIFFE-identity-
25303 // handshake-mandatory enforcement policy; the Cilium CNP
25304 // `MutualAuthenticationMode` OpenAPI schema enum admits the closed
25305 // set `{"required", "disabled", "test-always-fail"}` verbatim (the
25306 // `test-always-fail` arm is a Cilium-side debugging surface, not
25307 // author-reachable), so a drifted value (`"Required"` /
25308 // `"REQUIRED"` / `"mandatory"` / `"mtls-required"`) lands the
25309 // rendered `CiliumNetworkPolicy` outside the
25310 // `MutualAuthenticationMode` enum's admitted set and every intra-
25311 // mesh `:contratos` flow the CNP was authored to protect with per-
25312 // edge SPIFFE-identity-bound mutual-auth silently bypasses the
25313 // handshake at the Cilium data-plane's default-authentication mode
25314 // (typically also "disabled" today, but environment-divergent —
25315 // take effect) with no field naming the mTLS-mandatory-scalar-value-
25316 // drift root cause. Changing this value is a coordinated Cilium
25317 // CNP `MutualAuthenticationMode` promotion alongside the Cilium
25318 // project's periodic CRD schema-migration passes, not an
25319 // incidental edit. Peer to
25320 // `gateway_api_protocol_http_pins_canonical_value` /
25321 // `gateway_api_path_match_type_path_prefix_pins_canonical_value` /
25322 // `kube_protocol_tcp_pins_canonical_value` on the sibling
25323 // canonical-cluster-side-OpenAPI-schema-enum-value pin set —
25324 // extends the canonical-cluster-side-OpenAPI-schema-enum-value
25325 // single-sourcing discipline the Gateway-API v1 `ProtocolType.HTTP`
25326 // / `PathMatchType.PathPrefix` / K8s-core `Protocol.TCP` pins
25327 // established onto the sibling Cilium-CNP-side
25328 // `MutualAuthenticationMode.required` per-rule mTLS-mandatory
25329 // scalar-value the `cilium_network_policies` per-edge SPIFFE-
25330 // identity-bound mutual-auth emitter carries under the shared
25331 // `CiliumNetworkPolicy` body.
25332 assert_eq!(CILIUM_AUTH_MODE_REQUIRED, "required");
25333 }
25334
25335 #[test]
25336 fn cilium_auth_mode_disabled_pins_canonical_value() {
25337 // Peer to `cilium_auth_mode_required_pins_canonical_value` on the
25338 // `Some(false)` opt-out arm of the same
25339 // `MutualAuthenticationMode` OpenAPI schema enum: pin the actual
25340 // string so a typo can't silently rebrand the Cilium `disabled`
25341 // mTLS-skipped scalar-value the rendered CNP's per-rule authn-
25342 // block declares under the explicit `:mtls-required nil` opt-out
25343 // (distinct from the `None` slot-absent arm the renderer maps to
25344 // omit-the-block-entirely). A drifted value (`"Disabled"` /
25345 // `"DISABLED"` / `"off"` / `"skip"`) lands outside the
25346 // `MutualAuthenticationMode` OpenAPI schema enum's admitted set;
25347 // the author's explicit-opt-out intent silently collapses onto the
25348 // cluster-default authentication mode with no field naming the
25349 // mTLS-skipped-scalar-value-drift root cause. Peer to
25350 // `cilium_auth_mode_required_pins_canonical_value` on the
25351 // affirmative arm of the same enum — completes the per-authn-block
25352 // `(mode → {required, disabled})` author-reachable-scalar-value-
25353 // pair single-sourcing the M3 Aplicacao mesh renderer's SPIFFE-
25354 // identity-bound per-edge mTLS enforcement + explicit-opt-out
25355 // contract rests on across the two arms of the `:politicas
25356 // :mtls-required` tristate.
25357 assert_eq!(CILIUM_AUTH_MODE_DISABLED, "disabled");
25358 }
25359
25360 #[test]
25361 fn cilium_auth_modes_carry_lower_case_shape() {
25362 // Cross-axis invariant: the Cilium CNP `MutualAuthenticationMode`
25363 // OpenAPI schema enum admits the closed set `{"required",
25364 // "disabled", "test-always-fail"}` — every admitted value is
25365 // ASCII-lowercase throughout per the Cilium-project convention
25366 // (distinct from the sibling K8s-core `Protocol.TCP` /
25367 // Gateway-API-v1 `ProtocolType.HTTP` all-ASCII-uppercase
25368 // convention the `kube_protocol_tcp_carries_upper_case_shape` /
25369 // `gateway_api_protocol_http_carries_upper_case_shape` pins carry
25370 // on the sibling per-listener L7-parser-selection scalar axis, and
25371 // distinct from the sibling Gateway-API-v1
25372 // `PathMatchType.PathPrefix` UpperCamelCase convention the
25373 // `gateway_api_path_match_type_path_prefix_carries_upper_camel_case_shape`
25374 // pin carries on the sibling per-match request-path-selection
25375 // scalar axis — the Cilium CNP `MutualAuthenticationMode` enum
25376 // grammar does not collapse with either sibling cluster-side
25377 // OpenAPI schema enum's per-value casing convention). Pinning the
25378 // shape here means a future rebrand on either lifted value can't
25379 // silently land a malformed mode-discriminator scalar (uppercase
25380 // `"REQUIRED"` / `"DISABLED"`, UpperCamelCase `"Required"` /
25381 // `"Disabled"`, mixed-case, whitespace) that the Cilium CNP
25382 // `MutualAuthenticationMode` OpenAPI schema enum would reject at
25383 // admission time far from the rebrand commit's source.
25384 for v in [CILIUM_AUTH_MODE_REQUIRED, CILIUM_AUTH_MODE_DISABLED] {
25385 assert!(
25386 !v.is_empty(),
25387 "{v:?} must be non-empty per the Cilium CNP \
25388 `MutualAuthenticationMode` OpenAPI schema enum grammar"
25389 );
25390 assert!(
25391 v.chars().all(|c| c.is_ascii_lowercase()),
25392 "{v:?} must be ASCII-lowercase throughout per the Cilium \
25393 CNP `MutualAuthenticationMode` OpenAPI schema enum \
25394 convention — no uppercase, UpperCamelCase, or whitespace \
25395 bytes the Cilium-agent-side per-rule mutual-auth-block \
25396 schema validator would reject"
25397 );
25398 }
25399 }
25400
25401 #[test]
25402 fn cilium_auth_modes_are_distinct() {
25403 // Pin the `MutualAuthenticationMode` enum's per-arm distinctness
25404 // at type-check time: the two author-reachable arms of the typed
25405 // `:politicas :mtls-required` tristate must not collapse onto the
25406 // same scalar-value byte-sequence. A future rebrand that landed
25407 // both lifted constants on the same string (e.g. both `"required"`
25408 // through a copy-paste typo, or both aliased through a shared
25409 // helper) would silently erase the tristate's affirmative /
25410 // explicit-opt-out distinction at the emit boundary — the
25411 // renderer would emit the same scalar under both the `Some(true)`
25412 // and `Some(false)` arms of the closure the
25413 // `single_field_overlay(spec.politicas.mtls_required,
25414 // CILIUM_KEY_MODE, |required| …)` call site carries, collapsing
25415 // the two author intents onto a single Cilium-side enforcement
25416 // policy with no field naming the collapse root cause. Peer to
25417 // the two `cilium_auth_mode_{required,disabled}_pins_canonical_
25418 // value` per-arm pins — completes the per-arm distinctness pin
25419 // set on the closed author-reachable subset of the enum.
25420 assert_ne!(
25421 CILIUM_AUTH_MODE_REQUIRED, CILIUM_AUTH_MODE_DISABLED,
25422 "the two author-reachable arms of the `:mtls-required` \
25423 tristate must land distinct `MutualAuthenticationMode` \
25424 scalar-values"
25425 );
25426 }
25427
25428 #[test]
25429 fn cilium_auth_mode_bijection_dispatches_tristate_arms_onto_scalar_values() {
25430 // Pin the `bool → &'static str` projection every consumer of the
25431 // Cilium `MutualAuthenticationMode` closed-set enum's author-
25432 // reachable scalar-value pair reaches through: `true` (the
25433 // `Some(true)` mTLS-mandatory arm of the typed `:politicas
25434 // :mtls-required` tristate) maps to [`CILIUM_AUTH_MODE_REQUIRED`],
25435 // `false` (the `Some(false)` explicit-opt-out arm) maps to
25436 // [`CILIUM_AUTH_MODE_DISABLED`]. One projection body, both arms of
25437 // the tristate's non-`None` value-space, so a future per-arm
25438 // reassignment (e.g. an upstream Cilium v3 schema swap of the
25439 // `required` ↔ `disabled` scalars, or a per-arm renaming of the
25440 // mTLS-mandatory scalar from `required` to `enforced` / `strict`
25441 // / `mandatory`) lands at the two consts + this projection body
25442 // — not at the caixa-mesh production emitter's closure body and
25443 // the caixa-core `single_field_overlay_threads_typed_value_
25444 // through_closure` generic-helper pin's closure body independently.
25445 // Pin the per-arm round-trip so a future refactor that inverts
25446 // the bool → arm mapping (or collapses one arm) surfaces here
25447 // rather than silently letting a Cilium data-plane pod either
25448 // enforce mTLS where the author asked for skip or skip it where
25449 // the author asked for enforce.
25450 assert_eq!(cilium_auth_mode(true), CILIUM_AUTH_MODE_REQUIRED);
25451 assert_eq!(cilium_auth_mode(false), CILIUM_AUTH_MODE_DISABLED);
25452 // The two arms cover distinct value-space entries — a regression
25453 // that collapses them onto the same scalar surfaces here. Peer
25454 // to `cilium_auth_modes_are_distinct` (the per-arm distinctness
25455 // pin at the const-declaration axis) — this test extends the
25456 // pin onto the projection body axis, so both the raw consts and
25457 // the projection's per-arm dispatch preserve the tristate's
25458 // author-intent distinction end-to-end.
25459 assert_ne!(
25460 cilium_auth_mode(true),
25461 cilium_auth_mode(false),
25462 "cilium_auth_mode must project the two tristate arms onto \
25463 distinct `MutualAuthenticationMode` value-space entries — \
25464 a collapsed-arm regression would silently render both \
25465 `:mtls-required t` and `:mtls-required nil` identically at \
25466 the cluster artifact",
25467 );
25468 }
25469
25470 #[test]
25471 fn gateway_api_key_parent_refs_pins_canonical_value() {
25472 // Pin the actual string so a typo in this lift can't silently
25473 // rebrand the Gateway API `HTTPRoute` parent-Gateway-binding
25474 // container-axis key the rendered HTTPRoute document mounts its
25475 // per-route `[{name}]` parent-Gateway attachment list under. The
25476 // string is part of the cluster-side contract with every
25477 // Gateway-API-conformant gateway implementation (Cilium, Istio,
25478 // Envoy Gateway, NGINX) — the Gateway-API-implementation-side
25479 // per-HTTPRoute reconcile loop keys off this axis to source the
25480 // per-route parent-Gateway attachment list the route is bound
25481 // to; a drifted value (`"parentRef"` / `"parents"` /
25482 // `"parentGateways"`) at either the production emitter or a
25483 // downstream renderer's per-HTTPRoute parent-Gateway-binding
25484 // upsert silently emits an `HTTPRoute` whose parent-Gateway-
25485 // binding axis the Gateway API CRD schema validator drops as
25486 // unknown — the route lands unattached to any Gateway, and
25487 // every external `:entrada` flow the HTTPRoute was authored to
25488 // accept drops at the Gateway API implementation's per-Gateway
25489 // HTTP-listener fan-in with no field naming the parent-Gateway-
25490 // binding-drift root cause. Changing this value is a
25491 // coordinated Gateway API promotion alongside the upstream
25492 // SIG-Network Gateway API deprecation cycle, not an incidental
25493 // edit. Peer to `cilium_key_ports_pins_canonical_value` /
25494 // `cilium_key_from_endpoints_pins_canonical_value` /
25495 // `cilium_key_endpoint_selector_pins_canonical_value` /
25496 // `cilium_key_ingress_pins_canonical_value` /
25497 // `cilium_key_to_ports_pins_canonical_value` on the sibling
25498 // per-CNP-body-axis pin set — begins the per-Gateway-API-
25499 // HTTPRoute-body-axis canonical-string-pin set (`parentRefs`,
25500 // future `hostnames`) the M3 Aplicacao mesh renderer's external
25501 // `:entrada` ingress contract rests on across the Gateway API
25502 // HTTPRoute-side per-route body-shape.
25503 assert_eq!(GATEWAY_API_KEY_PARENT_REFS, "parentRefs");
25504 }
25505
25506 #[test]
25507 fn gateway_api_key_parent_refs_carries_lower_camel_case_shape() {
25508 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25509 // lowerCamelCase identifier per the K8s API conventions
25510 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25511 // "Field names should be lowercase camelCase") — first byte
25512 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25513 // kebab-case or whitespace. Pinning the shape here means a
25514 // future rebrand on the canonical lift can't silently land a
25515 // malformed field-name discriminator (snake_case, kebab-case,
25516 // UpperCamelCase, empty) that the apiserver-side CRD schema
25517 // validator would reject far from the rebrand commit's source.
25518 // Peer to `cilium_key_ports_carries_lower_camel_case_shape` /
25519 // `cilium_key_from_endpoints_carries_lower_camel_case_shape` /
25520 // `cilium_key_endpoint_selector_carries_lower_camel_case_shape`
25521 // / `cilium_key_ingress_carries_lower_camel_case_shape` /
25522 // `cilium_key_to_ports_carries_lower_camel_case_shape` on the
25523 // sibling per-CNP-body-axis grammar-pin set — the lowerCamelCase
25524 // K8s field-name grammar governs every nested schema-field axis
25525 // (including this per-HTTPRoute parent-Gateway-binding-
25526 // container-axis key), same convention.
25527 let v = GATEWAY_API_KEY_PARENT_REFS;
25528 assert!(
25529 !v.is_empty(),
25530 "GATEWAY_API_KEY_PARENT_REFS {v:?} must be non-empty per the K8s API \
25531 lowerCamelCase field-name grammar"
25532 );
25533 let first = v.chars().next().expect("non-empty");
25534 assert!(
25535 first.is_ascii_lowercase(),
25536 "GATEWAY_API_KEY_PARENT_REFS {v:?} first byte {first:?} must be \
25537 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25538 grammar (field names are always lowerCamelCase)"
25539 );
25540 assert!(
25541 v.chars().all(|c| c.is_ascii_alphanumeric()),
25542 "GATEWAY_API_KEY_PARENT_REFS {v:?} must be ASCII-alphanumeric \
25543 throughout per the K8s API field-name grammar — no \
25544 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25545 OpenAPI schema validator would reject"
25546 );
25547 }
25548
25549 #[test]
25550 fn gateway_api_key_backend_refs_pins_canonical_value() {
25551 // Pin the actual string so a typo in this lift can't silently
25552 // rebrand the Gateway API `HTTPRoute` per-rule backend-destination
25553 // container-axis key the rendered HTTPRoute document mounts its
25554 // per-rule `[{name, port}]` backend fan-out list under. The
25555 // string is part of the cluster-side contract with every
25556 // Gateway-API-conformant gateway implementation (Cilium, Istio,
25557 // Envoy Gateway, NGINX) — the Gateway-API-implementation-side
25558 // per-rule L7 dispatch loop keys off this axis to source the
25559 // per-rule backend list the request is forwarded to; a drifted
25560 // value (`"backendRef"` / `"backends"` / `"forwardTo"`) at
25561 // either the production emitter or a downstream renderer's
25562 // per-rule backend-destination upsert silently emits an
25563 // `HTTPRoute` whose per-rule backend fan-out axis the Gateway
25564 // API CRD schema validator drops as unknown — no backend is
25565 // picked at the per-rule L7 dispatch, and every external
25566 // `:entrada` request the rule was authored to route drops at
25567 // the gateway-class-controller's per-rule reconcile with no
25568 // field naming the backend-destination-drift root cause.
25569 // Changing this value is a coordinated Gateway API promotion
25570 // alongside the upstream SIG-Network Gateway API deprecation
25571 // cycle, not an incidental edit. Peer to
25572 // `gateway_api_key_parent_refs_pins_canonical_value` on the
25573 // sibling per-HTTPRoute-body-axis canonical-string-pin surface
25574 // — extends the per-Gateway-API-HTTPRoute-body-axis pin set
25575 // (`parentRefs`, `backendRefs`, future `hostnames`) the M3
25576 // Aplicacao mesh renderer's external `:entrada` ingress
25577 // contract rests on across the Gateway API HTTPRoute-side per-
25578 // route body-shape.
25579 assert_eq!(GATEWAY_API_KEY_BACKEND_REFS, "backendRefs");
25580 }
25581
25582 #[test]
25583 fn gateway_api_key_backend_refs_carries_lower_camel_case_shape() {
25584 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25585 // lowerCamelCase identifier per the K8s API conventions
25586 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25587 // "Field names should be lowercase camelCase") — first byte
25588 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25589 // kebab-case or whitespace. Pinning the shape here means a
25590 // future rebrand on the canonical lift can't silently land a
25591 // malformed field-name discriminator (snake_case, kebab-case,
25592 // UpperCamelCase, empty) that the apiserver-side CRD schema
25593 // validator would reject far from the rebrand commit's source.
25594 // Peer to `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
25595 // on the sibling per-HTTPRoute-body-axis grammar-pin surface —
25596 // the lowerCamelCase K8s field-name grammar governs every
25597 // nested schema-field axis (including this per-rule backend-
25598 // destination-container-axis key), same convention.
25599 let v = GATEWAY_API_KEY_BACKEND_REFS;
25600 assert!(
25601 !v.is_empty(),
25602 "GATEWAY_API_KEY_BACKEND_REFS {v:?} must be non-empty per the K8s API \
25603 lowerCamelCase field-name grammar"
25604 );
25605 let first = v.chars().next().expect("non-empty");
25606 assert!(
25607 first.is_ascii_lowercase(),
25608 "GATEWAY_API_KEY_BACKEND_REFS {v:?} first byte {first:?} must be \
25609 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25610 grammar (field names are always lowerCamelCase)"
25611 );
25612 assert!(
25613 v.chars().all(|c| c.is_ascii_alphanumeric()),
25614 "GATEWAY_API_KEY_BACKEND_REFS {v:?} must be ASCII-alphanumeric \
25615 throughout per the K8s API field-name grammar — no \
25616 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25617 OpenAPI schema validator would reject"
25618 );
25619 }
25620
25621 #[test]
25622 fn gateway_api_key_matches_pins_canonical_value() {
25623 // Pin the actual string so a typo in this lift can't silently
25624 // rebrand the Gateway API `HTTPRoute` per-rule route-match
25625 // container-axis key the rendered HTTPRoute document mounts
25626 // its per-rule `[{path: {type, value}}]` route-match fan-out
25627 // list under. The string is part of the cluster-side contract
25628 // with every Gateway-API-conformant gateway implementation
25629 // (Cilium, Istio, Envoy Gateway, NGINX) — the Gateway-API-
25630 // implementation-side per-rule L7 dispatch loop keys off this
25631 // axis to source the per-rule request-selection predicate the
25632 // incoming request line + headers + query must satisfy for
25633 // the rule's backend fan-out to apply; a drifted value
25634 // (`"match"` / `"routeMatches"` / `"predicates"`) at either
25635 // the production emitter or a downstream renderer's per-rule
25636 // route-match upsert silently emits an `HTTPRoute` whose per-
25637 // rule request-selection axis the Gateway API CRD schema
25638 // validator drops as unknown — the per-rule predicate
25639 // degrades to the wildcard match at the gateway-class-
25640 // controller's per-rule reconcile, the rule matches every
25641 // request unconditionally, and every external `:entrada` path
25642 // filter the rule was authored to enforce drops with no field
25643 // naming the route-match-drift root cause. Changing this
25644 // value is a coordinated Gateway API promotion alongside the
25645 // upstream SIG-Network Gateway API deprecation cycle, not an
25646 // incidental edit. Peer to
25647 // `gateway_api_key_backend_refs_pins_canonical_value` /
25648 // `gateway_api_key_parent_refs_pins_canonical_value` on the
25649 // sibling per-HTTPRoute-body-axis canonical-string-pin
25650 // surface — completes the per-rule top-level-axis pin set
25651 // (`matches`, `backendRefs`, `timeouts`, `retry`) the M3
25652 // Aplicacao mesh renderer's external `:entrada` ingress
25653 // contract rests on across the Gateway API HTTPRoute per-rule
25654 // body-shape.
25655 assert_eq!(GATEWAY_API_KEY_MATCHES, "matches");
25656 }
25657
25658 #[test]
25659 fn gateway_api_key_matches_carries_lower_camel_case_shape() {
25660 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25661 // lowerCamelCase identifier per the K8s API conventions
25662 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25663 // "Field names should be lowercase camelCase") — first byte
25664 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25665 // kebab-case or whitespace. Pinning the shape here means a
25666 // future rebrand on the canonical lift can't silently land a
25667 // malformed field-name discriminator (snake_case, kebab-case,
25668 // UpperCamelCase, empty) that the apiserver-side CRD schema
25669 // validator would reject far from the rebrand commit's source.
25670 // Peer to `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
25671 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
25672 // on the sibling per-HTTPRoute-body-axis grammar-pin surface —
25673 // the lowerCamelCase K8s field-name grammar governs every
25674 // nested schema-field axis (including this per-rule route-
25675 // match-container-axis key), same convention.
25676 let v = GATEWAY_API_KEY_MATCHES;
25677 assert!(
25678 !v.is_empty(),
25679 "GATEWAY_API_KEY_MATCHES {v:?} must be non-empty per the K8s API \
25680 lowerCamelCase field-name grammar"
25681 );
25682 let first = v.chars().next().expect("non-empty");
25683 assert!(
25684 first.is_ascii_lowercase(),
25685 "GATEWAY_API_KEY_MATCHES {v:?} first byte {first:?} must be \
25686 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25687 grammar (field names are always lowerCamelCase)"
25688 );
25689 assert!(
25690 v.chars().all(|c| c.is_ascii_alphanumeric()),
25691 "GATEWAY_API_KEY_MATCHES {v:?} must be ASCII-alphanumeric \
25692 throughout per the K8s API field-name grammar — no \
25693 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25694 OpenAPI schema validator would reject"
25695 );
25696 }
25697
25698 #[test]
25699 fn gateway_api_key_gateway_class_name_pins_canonical_value() {
25700 // Pin the actual string so a typo in this lift can't silently
25701 // rebrand the Gateway API `Gateway` per-Gateway controller-
25702 // binding scalar-axis key the rendered Gateway document
25703 // mounts its per-Gateway `GatewayClass.metadata.name`
25704 // reference under. The string is part of the cluster-side
25705 // contract with every Gateway-API-conformant gateway
25706 // implementation (Cilium, Istio, Envoy Gateway, NGINX) —
25707 // the Gateway-API-implementation-side per-Gateway reconcile
25708 // loop keys off this axis to source the `GatewayClass`
25709 // reference the per-Gateway controller-name-lookup dispatch
25710 // resolves; a drifted value (`"gatewayClass"` /
25711 // `"className"` / `"gatewayClassRef"`) at the production
25712 // emitter silently emits a `Gateway` whose controller-binding
25713 // scalar-axis the Gateway API CRD schema validator drops as
25714 // unknown — no `GatewayClass` is resolved, no `controllerName`
25715 // is looked up, and every external `:entrada` flow the
25716 // Gateway was authored to accept drops at the gateway-class-
25717 // controller's per-Gateway reconcile with no field naming
25718 // the controller-binding-drift root cause. Changing this
25719 // value is a coordinated Gateway API promotion alongside
25720 // the upstream SIG-Network Gateway API deprecation cycle,
25721 // not an incidental edit. Peer to
25722 // `gateway_api_key_listeners_pins_canonical_value` /
25723 // `gateway_api_key_hostname_pins_canonical_value` on the
25724 // sibling per-Gateway-body-axis canonical-string-pin
25725 // surface — completes the per-Gateway-body-axis top-level-
25726 // axis pin set (`gatewayClassName`, `listeners`) the M3
25727 // Aplicacao mesh renderer's external `:entrada` ingress
25728 // contract rests on. Sibling of the peer
25729 // `default_gateway_class_name_pins_canonical_value` on the
25730 // canonical-Gateway-API-`(key, value)`-pair-lift surface
25731 // this lift closes the KEY half of.
25732 assert_eq!(GATEWAY_API_KEY_GATEWAY_CLASS_NAME, "gatewayClassName");
25733 }
25734
25735 #[test]
25736 fn gateway_api_key_gateway_class_name_carries_lower_camel_case_shape() {
25737 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25738 // lowerCamelCase identifier per the K8s API conventions
25739 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25740 // "Field names should be lowercase camelCase") — first byte
25741 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25742 // kebab-case or whitespace. Pinning the shape here means a
25743 // future rebrand on the canonical lift can't silently land a
25744 // malformed field-name discriminator (snake_case, kebab-case,
25745 // UpperCamelCase, empty) that the apiserver-side CRD schema
25746 // validator would reject far from the rebrand commit's source.
25747 // Peer to `gateway_api_key_listeners_carries_lower_camel_case_shape`
25748 // / `gateway_api_key_matches_carries_lower_camel_case_shape`
25749 // on the sibling per-Gateway / per-HTTPRoute-body-axis
25750 // grammar-pin surface — the lowerCamelCase K8s field-name
25751 // grammar governs every nested schema-field axis (including
25752 // this per-Gateway controller-binding scalar-axis key), same
25753 // convention.
25754 let v = GATEWAY_API_KEY_GATEWAY_CLASS_NAME;
25755 assert!(
25756 !v.is_empty(),
25757 "GATEWAY_API_KEY_GATEWAY_CLASS_NAME {v:?} must be non-empty per the K8s API \
25758 lowerCamelCase field-name grammar"
25759 );
25760 let first = v.chars().next().expect("non-empty");
25761 assert!(
25762 first.is_ascii_lowercase(),
25763 "GATEWAY_API_KEY_GATEWAY_CLASS_NAME {v:?} first byte {first:?} must be \
25764 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25765 grammar (field names are always lowerCamelCase)"
25766 );
25767 assert!(
25768 v.chars().all(|c| c.is_ascii_alphanumeric()),
25769 "GATEWAY_API_KEY_GATEWAY_CLASS_NAME {v:?} must be ASCII-alphanumeric \
25770 throughout per the K8s API field-name grammar — no \
25771 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25772 OpenAPI schema validator would reject"
25773 );
25774 }
25775
25776 #[test]
25777 fn gateway_api_key_path_pins_canonical_value() {
25778 // Pin the actual string so a typo in this lift can't silently
25779 // rebrand the Gateway API `HTTPRoute` per-`HTTPRouteMatch`
25780 // path-matcher container-axis key the rendered HTTPRoute
25781 // document mounts its per-match `{type, value}` path-selection
25782 // predicate under. The string is part of the cluster-side
25783 // contract with every Gateway-API-conformant gateway
25784 // implementation (Cilium, Istio, Envoy Gateway, NGINX) — the
25785 // Gateway-API-implementation-side per-rule L7 dispatch loop
25786 // keys off this axis to source the per-match request-path-
25787 // selection predicate the incoming request line's `:path`
25788 // pseudo-header must satisfy under a `type` discriminator of
25789 // `Exact | PathPrefix | RegularExpression`; a drifted value
25790 // (`"pathMatch"` / `"prefix"` / `"url"`) at the production
25791 // emitter silently emits an `HTTPRoute` whose per-match path-
25792 // selection axis the Gateway API CRD schema validator drops
25793 // as unknown — the per-match path predicate degrades to the
25794 // wildcard match at the gateway-class-controller's per-rule
25795 // reconcile, the rule matches every request path
25796 // unconditionally, and every external `:entrada` path filter
25797 // the rule was authored to enforce drops with no field
25798 // naming the path-matcher-drift root cause. Changing this
25799 // value is a coordinated Gateway API promotion alongside the
25800 // upstream SIG-Network Gateway API deprecation cycle, not an
25801 // incidental edit. Peer to
25802 // `gateway_api_key_matches_pins_canonical_value` /
25803 // `gateway_api_key_backend_refs_pins_canonical_value` on the
25804 // sibling per-HTTPRoute-body-axis canonical-string-pin
25805 // surface — nests the per-Gateway-API-HTTPRoute-per-rule-
25806 // body-axis pin set (`matches`, `backendRefs`, `timeouts`,
25807 // `retry`) one level deeper onto the per-`HTTPRouteMatch`
25808 // body-axis surface the M3 Aplicacao mesh renderer's external
25809 // `:entrada` ingress contract rests on.
25810 assert_eq!(GATEWAY_API_KEY_PATH, "path");
25811 }
25812
25813 #[test]
25814 fn gateway_api_key_path_carries_lower_camel_case_shape() {
25815 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25816 // lowerCamelCase identifier per the K8s API conventions
25817 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25818 // "Field names should be lowercase camelCase") — first byte
25819 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25820 // kebab-case or whitespace. Pinning the shape here means a
25821 // future rebrand on the canonical lift can't silently land a
25822 // malformed field-name discriminator (snake_case, kebab-case,
25823 // UpperCamelCase, empty) that the apiserver-side CRD schema
25824 // validator would reject far from the rebrand commit's source.
25825 // Peer to `gateway_api_key_matches_carries_lower_camel_case_shape`
25826 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
25827 // on the sibling per-HTTPRoute-body-axis grammar-pin surface —
25828 // the lowerCamelCase K8s field-name grammar governs every
25829 // nested schema-field axis (including this per-`HTTPRouteMatch`
25830 // path-matcher-container-axis key), same convention.
25831 let v = GATEWAY_API_KEY_PATH;
25832 assert!(
25833 !v.is_empty(),
25834 "GATEWAY_API_KEY_PATH {v:?} must be non-empty per the K8s API \
25835 lowerCamelCase field-name grammar"
25836 );
25837 let first = v.chars().next().expect("non-empty");
25838 assert!(
25839 first.is_ascii_lowercase(),
25840 "GATEWAY_API_KEY_PATH {v:?} first byte {first:?} must be \
25841 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25842 grammar (field names are always lowerCamelCase)"
25843 );
25844 assert!(
25845 v.chars().all(|c| c.is_ascii_alphanumeric()),
25846 "GATEWAY_API_KEY_PATH {v:?} must be ASCII-alphanumeric \
25847 throughout per the K8s API field-name grammar — no \
25848 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25849 OpenAPI schema validator would reject"
25850 );
25851 }
25852
25853 #[test]
25854 fn gateway_api_key_value_pins_canonical_value() {
25855 // Pin the actual string so a typo in this lift can't silently
25856 // rebrand the Gateway API `HTTPPathMatch` scalar-payload axis
25857 // key the rendered `HTTPRoute` document mounts its per-match
25858 // request-path-selection scalar payload under. The string is
25859 // part of the cluster-side contract with every Gateway-API-
25860 // conformant gateway implementation (Cilium, Istio, Envoy
25861 // Gateway, NGINX) — the Gateway-API-implementation-side per-
25862 // rule L7 dispatch loop keys off this axis to source the
25863 // per-match request-path string that the sibling `type`
25864 // discriminator (Exact | PathPrefix | RegularExpression) is
25865 // applied against; a drifted value (`"path"` / `"prefix"` /
25866 // `"pattern"` / `"expression"`) at the production emitter
25867 // silently emits an `HTTPRoute` whose per-match request-path
25868 // scalar the Gateway API CRD schema validator drops as
25869 // unknown — the per-match path predicate degrades to the
25870 // wildcard match at the gateway-class-controller's per-rule
25871 // reconcile, the rule matches every request path
25872 // unconditionally, and every external `:entrada` path filter
25873 // the rule was authored to enforce drops with no field
25874 // naming the `HTTPPathMatch`-scalar-payload-drift root cause.
25875 // Changing this value is a coordinated Gateway API promotion
25876 // alongside the upstream SIG-Network Gateway API deprecation
25877 // cycle, not an incidental edit. Peer to
25878 // `gateway_api_key_path_pins_canonical_value` on the sibling
25879 // per-`HTTPRouteMatch`-body-axis canonical-string-pin surface
25880 // — nests the per-Gateway-API-HTTPRoute-per-match-body-axis
25881 // pin set (`path` container-axis, `value` scalar-payload key)
25882 // one level deeper onto the per-`HTTPPathMatch` body-axis
25883 // surface the M3 Aplicacao mesh renderer's external `:entrada`
25884 // ingress contract rests on.
25885 assert_eq!(GATEWAY_API_KEY_VALUE, "value");
25886 }
25887
25888 #[test]
25889 fn gateway_api_key_value_carries_lower_camel_case_shape() {
25890 // Cross-axis invariant: a Kubernetes CRD schema field name is
25891 // a lowerCamelCase identifier per the K8s API conventions
25892 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
25893 // "Field names should be lowercase camelCase") — first byte
25894 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
25895 // kebab-case or whitespace. Pinning the shape here means a
25896 // future rebrand on the canonical lift can't silently land a
25897 // malformed field-name discriminator (snake_case, kebab-case,
25898 // UpperCamelCase, empty) that the apiserver-side CRD schema
25899 // validator would reject far from the rebrand commit's source.
25900 // Peer to `gateway_api_key_path_carries_lower_camel_case_shape`
25901 // on the sibling per-`HTTPRouteMatch`-body-axis grammar-pin
25902 // surface — the lowerCamelCase K8s field-name grammar governs
25903 // every nested schema-field axis (including this per-
25904 // `HTTPPathMatch` scalar-payload-axis key), same convention.
25905 let v = GATEWAY_API_KEY_VALUE;
25906 assert!(
25907 !v.is_empty(),
25908 "GATEWAY_API_KEY_VALUE {v:?} must be non-empty per the K8s API \
25909 lowerCamelCase field-name grammar"
25910 );
25911 let first = v.chars().next().expect("non-empty");
25912 assert!(
25913 first.is_ascii_lowercase(),
25914 "GATEWAY_API_KEY_VALUE {v:?} first byte {first:?} must be \
25915 ASCII-lowercase per the K8s API lowerCamelCase field-name \
25916 grammar (field names are always lowerCamelCase)"
25917 );
25918 assert!(
25919 v.chars().all(|c| c.is_ascii_alphanumeric()),
25920 "GATEWAY_API_KEY_VALUE {v:?} must be ASCII-alphanumeric \
25921 throughout per the K8s API field-name grammar — no \
25922 snake_case, kebab-case, or whitespace bytes the apiserver-side \
25923 OpenAPI schema validator would reject"
25924 );
25925 }
25926
25927 #[test]
25928 fn gateway_api_key_value_distinct_from_gateway_api_key_path() {
25929 // Cross-axis invariant: the `HTTPPathMatch` scalar-payload key
25930 // (`value`) and its parent-container-axis key (`path`) name
25931 // *distinct* Gateway-API-side schema fields — the parent is a
25932 // container that hangs off the per-`HTTPRouteMatch`
25933 // `matches[]` entry, the child is the scalar payload that
25934 // rides inside the parent's `{type, value}` two-axis body.
25935 // Under the sibling K8s API conventions grammar
25936 // (`gateway_api_key_value_carries_lower_camel_case_shape` /
25937 // `gateway_api_key_path_carries_lower_camel_case_shape`) both
25938 // are ASCII-lowerCamelCase identifiers, so a same-shape
25939 // grammar-pin alone doesn't prevent a future rebrand from
25940 // silently collapsing the two axes onto the same string —
25941 // pinning inequality here surfaces that footgun at exactly
25942 // this build-time lift instead of at apply time as an
25943 // `HTTPRoute` whose per-match `path` container-body is
25944 // structurally malformed (`{path: <str>, path: <str>}` — the
25945 // apiserver's OpenAPI schema validator drops the whole match
25946 // block, the per-match path predicate degrades to the
25947 // wildcard match at the gateway-class-controller's per-rule
25948 // reconcile, the rule matches every request path
25949 // unconditionally, and every external `:entrada` path filter
25950 // the rule was authored to enforce drops with no field
25951 // naming the container/scalar-collapse root cause).
25952 assert_ne!(
25953 GATEWAY_API_KEY_VALUE, GATEWAY_API_KEY_PATH,
25954 "GATEWAY_API_KEY_VALUE ({GATEWAY_API_KEY_VALUE:?}) must not \
25955 collapse onto GATEWAY_API_KEY_PATH ({GATEWAY_API_KEY_PATH:?}) \
25956 — the two name distinct Gateway API `HTTPPathMatch` axes \
25957 (parent container vs. inner scalar payload) that must \
25958 remain independently addressable in the emitted \
25959 `HTTPRoute` per-match body"
25960 );
25961 }
25962
25963 #[test]
25964 fn gateway_api_key_listeners_pins_canonical_value() {
25965 // Pin the actual string so a typo in this lift can't silently
25966 // rebrand the Gateway API `Gateway` per-listener-set container-
25967 // axis key the rendered Gateway document mounts its per-Gateway
25968 // `[{name, port, protocol, hostname}]` L7-listener fan-out list
25969 // under. The string is part of the cluster-side contract with
25970 // every Gateway-API-conformant gateway implementation (Cilium,
25971 // Istio, Envoy Gateway, NGINX) — the Gateway-API-implementation-
25972 // side per-Gateway reconcile loop keys off this axis to source
25973 // the per-Gateway L7-listener fan-out the external `:entrada`
25974 // flow the Gateway was authored to accept lands on; a drifted
25975 // value (`"listener"` / `"listen"` / `"servers"`) at either the
25976 // production emitter or a downstream renderer's per-Gateway L7-
25977 // listener-set upsert silently emits a `Gateway` whose L7-
25978 // listener-set axis the Gateway API CRD schema validator drops
25979 // as unknown — no listener is opened, and every external
25980 // `:entrada` flow drops at the gateway-class-controller's per-
25981 // Gateway reconcile with no field naming the L7-listener-set-
25982 // drift root cause. Changing this value is a coordinated
25983 // Gateway API promotion alongside the upstream SIG-Network
25984 // Gateway API deprecation cycle, not an incidental edit. Peer
25985 // to `gateway_api_key_parent_refs_pins_canonical_value` /
25986 // `gateway_api_key_backend_refs_pins_canonical_value` on the
25987 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
25988 // surface — extends the per-Gateway-API-CRD-body-axis pin set
25989 // (`parentRefs`, `backendRefs`, `listeners`, future
25990 // `hostnames`) the M3 Aplicacao mesh renderer's external
25991 // `:entrada` ingress contract rests on across the Gateway API
25992 // CRD-side body-shape.
25993 assert_eq!(GATEWAY_API_KEY_LISTENERS, "listeners");
25994 }
25995
25996 #[test]
25997 fn gateway_api_key_listeners_carries_lower_camel_case_shape() {
25998 // Cross-axis invariant: a Kubernetes CRD schema field name is a
25999 // lowerCamelCase identifier per the K8s API conventions
26000 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
26001 // "Field names should be lowercase camelCase") — first byte
26002 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
26003 // kebab-case or whitespace. Pinning the shape here means a
26004 // future rebrand on the canonical lift can't silently land a
26005 // malformed field-name discriminator (snake_case, kebab-case,
26006 // UpperCamelCase, empty) that the apiserver-side CRD schema
26007 // validator would reject far from the rebrand commit's source.
26008 // Peer to `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-Gateway
26013 // L7-listener-set-container-axis key), same convention.
26014 let v = GATEWAY_API_KEY_LISTENERS;
26015 assert!(
26016 !v.is_empty(),
26017 "GATEWAY_API_KEY_LISTENERS {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_LISTENERS {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_LISTENERS {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_hostname_pins_canonical_value() {
26038 // Pin the actual string so a typo in this lift can't silently
26039 // rebrand the Gateway API `Gateway` per-listener DNS-host-
26040 // discriminator axis key the rendered Gateway document mounts
26041 // each listener's virtual-host filter under. The string is part
26042 // of the cluster-side contract with every Gateway-API-conformant
26043 // gateway implementation (Cilium, Istio, Envoy Gateway, NGINX) —
26044 // the Gateway-API-implementation-side per-listener SNI /
26045 // `Host:`-header dispatch loop keys off this axis to source the
26046 // per-listener virtual-host filter each listener's inbound
26047 // traffic is scoped against; a drifted value (`"host"` /
26048 // `"vhost"` / `"serverName"`) at either the production emitter
26049 // or a downstream renderer's per-listener DNS-host-discriminator
26050 // upsert silently emits a `Gateway` whose per-listener virtual-
26051 // host filter axis the Gateway API CRD schema validator drops as
26052 // unknown — the listener accepts traffic on the wildcard host
26053 // rather than the typed `:entrada :host` the Aplicacao author
26054 // declared, and every external `:entrada` flow the listener was
26055 // authored to accept lands on the wrong virtual-host filter with
26056 // no field naming the DNS-host-discriminator-drift root cause.
26057 // Changing this value is a coordinated Gateway API promotion
26058 // alongside the upstream SIG-Network Gateway API deprecation
26059 // cycle, not an incidental edit. Peer to
26060 // `gateway_api_key_listeners_pins_canonical_value` /
26061 // `gateway_api_key_parent_refs_pins_canonical_value` /
26062 // `gateway_api_key_backend_refs_pins_canonical_value` on the
26063 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
26064 // surface — nests the per-Gateway-API-CRD-body-axis pin
26065 // discipline one level deeper onto the sibling per-listener
26066 // body-axis surface, extending the per-Gateway-API-CRD-body-
26067 // axis pin set (`parentRefs`, `backendRefs`, `listeners`,
26068 // `hostname`, future `hostnames`) the M3 Aplicacao mesh
26069 // renderer's external `:entrada` ingress contract rests on
26070 // across the Gateway API CRD-side body-shape.
26071 assert_eq!(GATEWAY_API_KEY_HOSTNAME, "hostname");
26072 }
26073
26074 #[test]
26075 fn gateway_api_key_hostname_carries_lower_camel_case_shape() {
26076 // Cross-axis invariant: a Kubernetes CRD schema field name is a
26077 // lowerCamelCase identifier per the K8s API conventions
26078 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
26079 // "Field names should be lowercase camelCase") — first byte
26080 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
26081 // kebab-case or whitespace. Pinning the shape here means a
26082 // future rebrand on the canonical lift can't silently land a
26083 // malformed field-name discriminator (snake_case, kebab-case,
26084 // UpperCamelCase, empty) that the apiserver-side CRD schema
26085 // validator would reject far from the rebrand commit's source.
26086 // Peer to `gateway_api_key_listeners_carries_lower_camel_case_shape`
26087 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
26088 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
26089 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
26090 // surface — the lowerCamelCase K8s field-name grammar governs
26091 // every nested schema-field axis (including this per-listener
26092 // DNS-host-discriminator-axis key), same convention.
26093 let v = GATEWAY_API_KEY_HOSTNAME;
26094 assert!(
26095 !v.is_empty(),
26096 "GATEWAY_API_KEY_HOSTNAME {v:?} must be non-empty per the K8s API \
26097 lowerCamelCase field-name grammar"
26098 );
26099 let first = v.chars().next().expect("non-empty");
26100 assert!(
26101 first.is_ascii_lowercase(),
26102 "GATEWAY_API_KEY_HOSTNAME {v:?} first byte {first:?} must be \
26103 ASCII-lowercase per the K8s API lowerCamelCase field-name \
26104 grammar (field names are always lowerCamelCase)"
26105 );
26106 assert!(
26107 v.chars().all(|c| c.is_ascii_alphanumeric()),
26108 "GATEWAY_API_KEY_HOSTNAME {v:?} must be ASCII-alphanumeric \
26109 throughout per the K8s API field-name grammar — no \
26110 snake_case, kebab-case, or whitespace bytes the apiserver-side \
26111 OpenAPI schema validator would reject"
26112 );
26113 }
26114
26115 #[test]
26116 fn gateway_api_key_hostnames_pins_canonical_value() {
26117 // Pin the actual string so a typo in this lift can't silently
26118 // rebrand the Gateway API `HTTPRoute` spec-level DNS-host-filter
26119 // axis key the rendered HTTPRoute document mounts each route's
26120 // per-route virtual-host filter list under. The string is part
26121 // of the cluster-side contract with every Gateway-API-conformant
26122 // gateway implementation (Cilium, Istio, Envoy Gateway, NGINX) —
26123 // the Gateway-API-implementation-side per-route SNI /
26124 // `Host:`-header dispatch loop keys off this axis to source the
26125 // per-route virtual-host filter list each route's inbound
26126 // traffic is scoped against; a drifted value (`"hosts"` /
26127 // `"vhosts"` / `"serverNames"`) at either the production emitter
26128 // or a downstream renderer's per-route DNS-host-filter upsert
26129 // silently emits an `HTTPRoute` whose per-route virtual-host
26130 // filter axis the Gateway API CRD schema validator drops as
26131 // unknown — the route accepts traffic on every host the parent
26132 // Gateway's listener accepts rather than the typed `:entrada
26133 // :host` the Aplicacao author declared, and every external
26134 // `:entrada` flow the route was authored to accept lands on the
26135 // wildcard virtual-host filter with no field naming the DNS-
26136 // host-filter-drift root cause. Changing this value is a
26137 // coordinated Gateway API promotion alongside the upstream
26138 // SIG-Network Gateway API deprecation cycle, not an incidental
26139 // edit. Peer to
26140 // `gateway_api_key_hostname_pins_canonical_value` /
26141 // `gateway_api_key_listeners_pins_canonical_value` /
26142 // `gateway_api_key_parent_refs_pins_canonical_value` /
26143 // `gateway_api_key_backend_refs_pins_canonical_value` on the
26144 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
26145 // surface — closes the per-Gateway-API-CRD `HTTPRoute` per-route
26146 // body-axis pin pair across the singular / plural DNS-host
26147 // discriminator surface (`hostname` at the parent-Gateway per-
26148 // listener discriminator + `hostnames` at the child HTTPRoute
26149 // per-route filter list), so both halves of the DNS-host-
26150 // discriminator convention across the `(Gateway, HTTPRoute)`
26151 // pair the M3 Aplicacao mesh renderer's external `:entrada`
26152 // ingress contract emits together now carry one lifted
26153 // canonical-string pin apiece.
26154 assert_eq!(GATEWAY_API_KEY_HOSTNAMES, "hostnames");
26155 }
26156
26157 #[test]
26158 fn gateway_api_key_hostnames_carries_lower_camel_case_shape() {
26159 // Cross-axis invariant: a Kubernetes CRD schema field name is a
26160 // lowerCamelCase identifier per the K8s API conventions
26161 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
26162 // "Field names should be lowercase camelCase") — first byte
26163 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
26164 // kebab-case or whitespace. Pinning the shape here means a
26165 // future rebrand on the canonical lift can't silently land a
26166 // malformed field-name discriminator (snake_case, kebab-case,
26167 // UpperCamelCase, empty) that the apiserver-side CRD schema
26168 // validator would reject far from the rebrand commit's source.
26169 // Peer to `gateway_api_key_hostname_carries_lower_camel_case_shape`
26170 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
26171 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
26172 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
26173 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
26174 // surface — the lowerCamelCase K8s field-name grammar governs
26175 // every nested schema-field axis (including this per-route DNS-
26176 // host-filter-axis key), same convention.
26177 let v = GATEWAY_API_KEY_HOSTNAMES;
26178 assert!(
26179 !v.is_empty(),
26180 "GATEWAY_API_KEY_HOSTNAMES {v:?} must be non-empty per the K8s API \
26181 lowerCamelCase field-name grammar"
26182 );
26183 let first = v.chars().next().expect("non-empty");
26184 assert!(
26185 first.is_ascii_lowercase(),
26186 "GATEWAY_API_KEY_HOSTNAMES {v:?} first byte {first:?} must be \
26187 ASCII-lowercase per the K8s API lowerCamelCase field-name \
26188 grammar (field names are always lowerCamelCase)"
26189 );
26190 assert!(
26191 v.chars().all(|c| c.is_ascii_alphanumeric()),
26192 "GATEWAY_API_KEY_HOSTNAMES {v:?} must be ASCII-alphanumeric \
26193 throughout per the K8s API field-name grammar — no \
26194 snake_case, kebab-case, or whitespace bytes the apiserver-side \
26195 OpenAPI schema validator would reject"
26196 );
26197 }
26198
26199 #[test]
26200 fn gateway_api_key_timeouts_pins_canonical_value() {
26201 // Pin the actual string so a typo in this lift can't silently
26202 // rebrand the Gateway API `HTTPRoute` per-rule request-timeout-
26203 // policy body-axis key the rendered HTTPRoute document mounts
26204 // each rule's per-rule `:politicas :timeout` overlay under. The
26205 // string is part of the cluster-side contract with every
26206 // Gateway-API-conformant gateway implementation (Cilium, Istio,
26207 // Envoy Gateway, NGINX) — the Gateway-API-implementation-side
26208 // per-rule request-dispatch loop keys off this axis to source
26209 // the per-rule wall-clock deadline each accepted request is
26210 // bounded against; a drifted value (`"timeout"` (singular) /
26211 // `"timeoutPolicy"` / `"deadlines"`) at either the production
26212 // emitter or a downstream renderer's per-rule timeout-policy
26213 // upsert silently emits an `HTTPRoute` whose per-rule request-
26214 // timeout policy axis the Gateway API CRD schema validator
26215 // drops as unknown — the route accepts every inbound request
26216 // with no per-rule wall-clock deadline (the "no infinite
26217 // blocking" guarantee MESH-COMPOSITION.md §V mandates for every
26218 // rendered per-`:politicas` mesh-composition edge silently
26219 // regresses to the pre-overlay unbounded-request semantic), and
26220 // every external `:entrada` flow the route was authored to
26221 // bound by the typed `:politicas :timeout` slot runs to
26222 // whatever backend deadline the resolved backend's downstream
26223 // infrastructure picks with no field naming the per-rule-
26224 // timeout-policy-drift root cause. Changing this value is a
26225 // coordinated Gateway API promotion alongside the upstream
26226 // SIG-Network Gateway API deprecation cycle, not an incidental
26227 // edit. Peer to
26228 // `gateway_api_key_hostnames_pins_canonical_value` /
26229 // `gateway_api_key_hostname_pins_canonical_value` /
26230 // `gateway_api_key_listeners_pins_canonical_value` /
26231 // `gateway_api_key_parent_refs_pins_canonical_value` /
26232 // `gateway_api_key_backend_refs_pins_canonical_value` on the
26233 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
26234 // surface — extends the per-Gateway-API-`HTTPRoute` per-rule
26235 // body-axis pin set (`backendRefs`, future per-rule sibling
26236 // axes) onto the load-bearing per-rule request-timeout-policy
26237 // axis the M3 Aplicacao mesh renderer's per-`:politicas
26238 // :timeout` overlay lands under.
26239 assert_eq!(GATEWAY_API_KEY_TIMEOUTS, "timeouts");
26240 }
26241
26242 #[test]
26243 fn gateway_api_key_timeouts_carries_lower_camel_case_shape() {
26244 // Cross-axis invariant: a Kubernetes CRD schema field name is a
26245 // lowerCamelCase identifier per the K8s API conventions
26246 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
26247 // "Field names should be lowercase camelCase") — first byte
26248 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
26249 // kebab-case or whitespace. Pinning the shape here means a
26250 // future rebrand on the canonical lift can't silently land a
26251 // malformed field-name discriminator (snake_case, kebab-case,
26252 // UpperCamelCase, empty) that the apiserver-side CRD schema
26253 // validator would reject far from the rebrand commit's source.
26254 // Peer to `gateway_api_key_hostnames_carries_lower_camel_case_shape`
26255 // / `gateway_api_key_hostname_carries_lower_camel_case_shape`
26256 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
26257 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
26258 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
26259 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
26260 // surface — the lowerCamelCase K8s field-name grammar governs
26261 // every nested schema-field axis (including this per-rule
26262 // request-timeout-policy-axis key), same convention.
26263 let v = GATEWAY_API_KEY_TIMEOUTS;
26264 assert!(
26265 !v.is_empty(),
26266 "GATEWAY_API_KEY_TIMEOUTS {v:?} must be non-empty per the K8s API \
26267 lowerCamelCase field-name grammar"
26268 );
26269 let first = v.chars().next().expect("non-empty");
26270 assert!(
26271 first.is_ascii_lowercase(),
26272 "GATEWAY_API_KEY_TIMEOUTS {v:?} first byte {first:?} must be \
26273 ASCII-lowercase per the K8s API lowerCamelCase field-name \
26274 grammar (field names are always lowerCamelCase)"
26275 );
26276 assert!(
26277 v.chars().all(|c| c.is_ascii_alphanumeric()),
26278 "GATEWAY_API_KEY_TIMEOUTS {v:?} must be ASCII-alphanumeric \
26279 throughout per the K8s API field-name grammar — no \
26280 snake_case, kebab-case, or whitespace bytes the apiserver-side \
26281 OpenAPI schema validator would reject"
26282 );
26283 }
26284
26285 #[test]
26286 fn gateway_api_key_retry_pins_canonical_value() {
26287 // Pin the actual string so a typo in this lift can't silently
26288 // rebrand the Gateway API `HTTPRoute` per-rule retry-policy
26289 // body-axis key the rendered HTTPRoute document mounts each
26290 // rule's per-rule `:politicas :retries` overlay under. The
26291 // string is part of the cluster-side contract with every
26292 // Gateway-API-conformant gateway implementation (Cilium, Istio,
26293 // Envoy Gateway, NGINX) — the Gateway-API-implementation-side
26294 // per-rule request-dispatch loop keys off this axis to source
26295 // the per-rule retry budget each failed backend attempt count
26296 // is bounded against; a drifted value (`"retries"` (plural) /
26297 // `"retryPolicy"` / `"budget"`) at either the production
26298 // emitter or a downstream renderer's per-rule retry-policy
26299 // upsert silently emits an `HTTPRoute` whose per-rule retry-
26300 // budget axis the Gateway API CRD schema validator drops as
26301 // unknown — the route accepts every inbound request with no
26302 // per-rule retry budget (the "no infinite retrying without
26303 // bound" guarantee MESH-COMPOSITION.md §V mandates for every
26304 // rendered per-`:politicas` mesh-composition edge silently
26305 // regresses to the pre-overlay unbounded-retry semantic), and
26306 // every external `:entrada` flow the route was authored to cap
26307 // by the typed `:politicas :retries` slot runs to whatever
26308 // retry policy the resolved backend's downstream infrastructure
26309 // picks with no field naming the per-rule-retry-policy-drift
26310 // root cause. Changing this value is a coordinated Gateway API
26311 // promotion alongside the upstream SIG-Network Gateway API
26312 // deprecation cycle, not an incidental edit. Peer to
26313 // `gateway_api_key_timeouts_pins_canonical_value` /
26314 // `gateway_api_key_hostnames_pins_canonical_value` /
26315 // `gateway_api_key_hostname_pins_canonical_value` /
26316 // `gateway_api_key_listeners_pins_canonical_value` /
26317 // `gateway_api_key_parent_refs_pins_canonical_value` /
26318 // `gateway_api_key_backend_refs_pins_canonical_value` on the
26319 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
26320 // surface — closes the per-Gateway-API-`HTTPRoute`-per-rule
26321 // `:politicas` overlay axis pair (`timeouts` for `:politicas
26322 // :timeout`, `retry` for `:politicas :retries`) both
26323 // MESH-COMPOSITION.md §V "no infinite blocking / no infinite
26324 // retrying" guarantees rest on.
26325 assert_eq!(GATEWAY_API_KEY_RETRY, "retry");
26326 }
26327
26328 #[test]
26329 fn gateway_api_key_retry_carries_lower_camel_case_shape() {
26330 // Cross-axis invariant: a Kubernetes CRD schema field name is a
26331 // lowerCamelCase identifier per the K8s API conventions
26332 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
26333 // "Field names should be lowercase camelCase") — first byte
26334 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
26335 // kebab-case or whitespace. Pinning the shape here means a
26336 // future rebrand on the canonical lift can't silently land a
26337 // malformed field-name discriminator (snake_case, kebab-case,
26338 // UpperCamelCase, empty) that the apiserver-side CRD schema
26339 // validator would reject far from the rebrand commit's source.
26340 // Peer to `gateway_api_key_timeouts_carries_lower_camel_case_shape`
26341 // / `gateway_api_key_hostnames_carries_lower_camel_case_shape`
26342 // / `gateway_api_key_hostname_carries_lower_camel_case_shape`
26343 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
26344 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
26345 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
26346 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
26347 // surface — the lowerCamelCase K8s field-name grammar governs
26348 // every nested schema-field axis (including this per-rule
26349 // retry-policy-axis key), same convention.
26350 let v = GATEWAY_API_KEY_RETRY;
26351 assert!(
26352 !v.is_empty(),
26353 "GATEWAY_API_KEY_RETRY {v:?} must be non-empty per the K8s API \
26354 lowerCamelCase field-name grammar"
26355 );
26356 let first = v.chars().next().expect("non-empty");
26357 assert!(
26358 first.is_ascii_lowercase(),
26359 "GATEWAY_API_KEY_RETRY {v:?} first byte {first:?} must be \
26360 ASCII-lowercase per the K8s API lowerCamelCase field-name \
26361 grammar (field names are always lowerCamelCase)"
26362 );
26363 assert!(
26364 v.chars().all(|c| c.is_ascii_alphanumeric()),
26365 "GATEWAY_API_KEY_RETRY {v:?} must be ASCII-alphanumeric \
26366 throughout per the K8s API field-name grammar — no \
26367 snake_case, kebab-case, or whitespace bytes the apiserver-side \
26368 OpenAPI schema validator would reject"
26369 );
26370 }
26371
26372 #[test]
26373 fn gateway_api_key_attempts_pins_canonical_value() {
26374 // Pin the actual string so a typo in this lift can't silently
26375 // rebrand the Gateway API `HTTPRoute` per-rule retry-policy
26376 // `attempts` leaf scalar-key the rendered HTTPRoute document
26377 // mounts each rule's per-rule `:politicas :retries` typed `u32`
26378 // attempt count under. The string is part of the cluster-side
26379 // contract with every Gateway-API-conformant gateway
26380 // implementation (Cilium, Istio, Envoy Gateway, NGINX) — the
26381 // Gateway-API-implementation-side per-rule request-dispatch
26382 // loop keys off this leaf to source the per-rule retry attempt
26383 // budget each failed backend attempt count is bounded against;
26384 // a drifted value (`"attempt"` (singular) / `"count"` /
26385 // `"tries"` / `"maxAttempts"`) at either the production
26386 // emitter or a downstream renderer's per-rule retry-attempts
26387 // upsert silently emits an `HTTPRoute` whose per-rule retry-
26388 // attempts leaf the Gateway API CRD schema validator drops as
26389 // unknown — the retry sub-shape parses as an empty
26390 // `HTTPRouteRetry` with the typed `u32` attempt count silently
26391 // discarded, the route accepts every inbound request with no
26392 // per-rule retry budget (the "no infinite retrying without
26393 // bound" guarantee MESH-COMPOSITION.md §V mandates for every
26394 // rendered per-`:politicas` mesh-composition edge silently
26395 // regresses to the pre-overlay unbounded-retry semantic), and
26396 // every external `:entrada` flow the route was authored to cap
26397 // by the typed `:politicas :retries` slot runs to whatever
26398 // retry policy the resolved backend's downstream infrastructure
26399 // picks with no field naming the per-rule-retry-attempts-leaf-
26400 // key-drift root cause. Changing this value is a coordinated
26401 // Gateway API promotion alongside the upstream SIG-Network
26402 // Gateway API deprecation cycle, not an incidental edit. Peer
26403 // to `gateway_api_key_retry_pins_canonical_value` /
26404 // `gateway_api_key_timeouts_pins_canonical_value` /
26405 // `gateway_api_key_hostnames_pins_canonical_value` /
26406 // `gateway_api_key_hostname_pins_canonical_value` /
26407 // `gateway_api_key_listeners_pins_canonical_value` /
26408 // `gateway_api_key_parent_refs_pins_canonical_value` /
26409 // `gateway_api_key_backend_refs_pins_canonical_value` on the
26410 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
26411 // surface — closes the parent-leaf axis pair (`retry`
26412 // container + `attempts` leaf) both MESH-COMPOSITION.md §V
26413 // "no infinite retrying" guarantees rest on, one nesting
26414 // level deeper than the parent per-rule retry-policy
26415 // container axis (`retry`).
26416 assert_eq!(GATEWAY_API_KEY_ATTEMPTS, "attempts");
26417 }
26418
26419 #[test]
26420 fn gateway_api_key_attempts_carries_lower_camel_case_shape() {
26421 // Cross-axis invariant: a Kubernetes CRD schema field name is a
26422 // lowerCamelCase identifier per the K8s API conventions
26423 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
26424 // "Field names should be lowercase camelCase") — first byte
26425 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
26426 // kebab-case or whitespace. Pinning the shape here means a
26427 // future rebrand on the canonical lift can't silently land a
26428 // malformed field-name discriminator (snake_case, kebab-case,
26429 // UpperCamelCase, empty) that the apiserver-side CRD schema
26430 // validator would reject far from the rebrand commit's source.
26431 // Peer to `gateway_api_key_retry_carries_lower_camel_case_shape`
26432 // / `gateway_api_key_timeouts_carries_lower_camel_case_shape`
26433 // / `gateway_api_key_hostnames_carries_lower_camel_case_shape`
26434 // / `gateway_api_key_hostname_carries_lower_camel_case_shape`
26435 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
26436 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
26437 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
26438 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
26439 // surface — the lowerCamelCase K8s field-name grammar governs
26440 // every nested schema-field axis (including this per-rule
26441 // retry-attempts-leaf-key), same convention.
26442 let v = GATEWAY_API_KEY_ATTEMPTS;
26443 assert!(
26444 !v.is_empty(),
26445 "GATEWAY_API_KEY_ATTEMPTS {v:?} must be non-empty per the K8s API \
26446 lowerCamelCase field-name grammar"
26447 );
26448 let first = v.chars().next().expect("non-empty");
26449 assert!(
26450 first.is_ascii_lowercase(),
26451 "GATEWAY_API_KEY_ATTEMPTS {v:?} first byte {first:?} must be \
26452 ASCII-lowercase per the K8s API lowerCamelCase field-name \
26453 grammar (field names are always lowerCamelCase)"
26454 );
26455 assert!(
26456 v.chars().all(|c| c.is_ascii_alphanumeric()),
26457 "GATEWAY_API_KEY_ATTEMPTS {v:?} must be ASCII-alphanumeric \
26458 throughout per the K8s API field-name grammar — no \
26459 snake_case, kebab-case, or whitespace bytes the apiserver-side \
26460 OpenAPI schema validator would reject"
26461 );
26462 }
26463
26464 #[test]
26465 fn gateway_api_key_request_pins_canonical_value() {
26466 // Pin the actual string so a typo in this lift can't silently
26467 // rebrand the Gateway API `HTTPRoute` per-rule request-timeout-
26468 // policy `request` leaf scalar-key the rendered HTTPRoute
26469 // document mounts each rule's per-rule `:politicas :timeout`
26470 // typed K8s-duration string under. The string is part of the
26471 // cluster-side contract with every Gateway-API-conformant
26472 // gateway implementation (Cilium, Istio, Envoy Gateway, NGINX)
26473 // — the Gateway-API-implementation-side per-rule request-
26474 // dispatch loop keys off this leaf to source the per-rule
26475 // request wall-clock deadline each inbound request is bounded
26476 // against; a drifted value (`"deadline"` / `"requestTimeout"`
26477 // / `"timeout"` / `"upstreamRequest"`) at either the production
26478 // emitter or a downstream renderer's per-rule request-deadline
26479 // upsert silently emits an `HTTPRoute` whose per-rule request-
26480 // deadline leaf the Gateway API CRD schema validator drops as
26481 // unknown — the timeouts sub-shape parses as an empty
26482 // `HTTPRouteTimeouts` with the typed duration silently
26483 // discarded, the route accepts every inbound request with no
26484 // per-rule request deadline (the "no infinite blocking"
26485 // guarantee MESH-COMPOSITION.md §V mandates for every rendered
26486 // per-`:politicas` mesh-composition edge silently regresses to
26487 // the pre-overlay unbounded-blocking semantic), and every
26488 // external `:entrada` flow the route was authored to cap by
26489 // the typed `:politicas :timeout` slot runs to whatever
26490 // request-deadline the resolved backend's downstream
26491 // infrastructure picks with no field naming the per-rule-
26492 // request-deadline-leaf-key-drift root cause. Changing this
26493 // value is a coordinated Gateway API promotion alongside the
26494 // upstream SIG-Network Gateway API deprecation cycle, not an
26495 // incidental edit. Peer to
26496 // `gateway_api_key_attempts_pins_canonical_value` /
26497 // `gateway_api_key_retry_pins_canonical_value` /
26498 // `gateway_api_key_timeouts_pins_canonical_value` /
26499 // `gateway_api_key_hostnames_pins_canonical_value` /
26500 // `gateway_api_key_hostname_pins_canonical_value` /
26501 // `gateway_api_key_listeners_pins_canonical_value` /
26502 // `gateway_api_key_parent_refs_pins_canonical_value` /
26503 // `gateway_api_key_backend_refs_pins_canonical_value` on the
26504 // sibling per-Gateway-API-CRD-body-axis canonical-string-pin
26505 // surface — closes the second parent-leaf axis pair
26506 // (`timeouts` container + `request` leaf) both
26507 // MESH-COMPOSITION.md §V "no infinite blocking / no infinite
26508 // retrying" guarantees rest on, sibling to the parent-leaf
26509 // pair (`retry` container + `attempts` leaf) closed in
26510 // e2e136b.
26511 assert_eq!(GATEWAY_API_KEY_REQUEST, "request");
26512 }
26513
26514 #[test]
26515 fn gateway_api_key_request_carries_lower_camel_case_shape() {
26516 // Cross-axis invariant: a Kubernetes CRD schema field name is a
26517 // lowerCamelCase identifier per the K8s API conventions
26518 // (https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#naming-conventions —
26519 // "Field names should be lowercase camelCase") — first byte
26520 // ASCII-lowercase, rest ASCII-alphanumeric, no snake_case or
26521 // kebab-case or whitespace. Pinning the shape here means a
26522 // future rebrand on the canonical lift can't silently land a
26523 // malformed field-name discriminator (snake_case, kebab-case,
26524 // UpperCamelCase, empty) that the apiserver-side CRD schema
26525 // validator would reject far from the rebrand commit's source.
26526 // Peer to `gateway_api_key_attempts_carries_lower_camel_case_shape`
26527 // / `gateway_api_key_retry_carries_lower_camel_case_shape`
26528 // / `gateway_api_key_timeouts_carries_lower_camel_case_shape`
26529 // / `gateway_api_key_hostnames_carries_lower_camel_case_shape`
26530 // / `gateway_api_key_hostname_carries_lower_camel_case_shape`
26531 // / `gateway_api_key_listeners_carries_lower_camel_case_shape`
26532 // / `gateway_api_key_parent_refs_carries_lower_camel_case_shape`
26533 // / `gateway_api_key_backend_refs_carries_lower_camel_case_shape`
26534 // on the sibling per-Gateway-API-CRD-body-axis grammar-pin
26535 // surface — the lowerCamelCase K8s field-name grammar governs
26536 // every nested schema-field axis (including this per-rule
26537 // request-deadline-leaf-key), same convention.
26538 let v = GATEWAY_API_KEY_REQUEST;
26539 assert!(
26540 !v.is_empty(),
26541 "GATEWAY_API_KEY_REQUEST {v:?} must be non-empty per the K8s API \
26542 lowerCamelCase field-name grammar"
26543 );
26544 let first = v.chars().next().expect("non-empty");
26545 assert!(
26546 first.is_ascii_lowercase(),
26547 "GATEWAY_API_KEY_REQUEST {v:?} first byte {first:?} must be \
26548 ASCII-lowercase per the K8s API lowerCamelCase field-name \
26549 grammar (field names are always lowerCamelCase)"
26550 );
26551 assert!(
26552 v.chars().all(|c| c.is_ascii_alphanumeric()),
26553 "GATEWAY_API_KEY_REQUEST {v:?} must be ASCII-alphanumeric \
26554 throughout per the K8s API field-name grammar — no \
26555 snake_case, kebab-case, or whitespace bytes the apiserver-side \
26556 OpenAPI schema validator would reject"
26557 );
26558 }
26559
26560 #[test]
26561 fn default_namespace_is_a_valid_dns_1123_label() {
26562 // Cross-axis invariant: the default namespace lands as
26563 // `metadata.namespace` on every emitted K8s object across every
26564 // renderer, and the K8s apiserver enforces the DNS-1123 label
26565 // rule on every `metadata.namespace`. Pinning this here means
26566 // a future rebrand on the canonical `DEFAULT_NAMESPACE`
26567 // declaration can't silently land a value the apiserver
26568 // refuses at the *first* renderer to apply against a cluster,
26569 // far from the rebrand commit's source — the typed
26570 // [`is_dns_1123_label`] floor rejects it at caixa-core build
26571 // time on the canonical lift, before any renderer consumes
26572 // the value. Same trajectory as `:membros :caixa` /
26573 // `:placement :clusters` / `:contratos :de`/`:para` /
26574 // `:entrada :para` / `:placement :affinity` (dfd4902 — the
26575 // five typed-identifier axes on the Aplicacao surface that
26576 // already land on this same `is_dns_1123_label` floor at
26577 // their respective validate gates), now extended onto the
26578 // canonical-namespace-default axis the renderers share.
26579 assert!(
26580 is_dns_1123_label(DEFAULT_NAMESPACE).is_ok(),
26581 "DEFAULT_NAMESPACE {DEFAULT_NAMESPACE:?} must be a valid \
26582 DNS-1123 label — every K8s apiserver-side schema enforces \
26583 this rule on `metadata.namespace`"
26584 );
26585 }
26586
26587 #[test]
26588 fn helm_chart_api_version_pins_canonical_value() {
26589 // Pin the actual string so a typo in this lift can't silently
26590 // rebrand the Helm 3 chart-schema apiVersion the rendered
26591 // `lareira-<nome>` `Chart.yaml` document declares at its
26592 // top-level `apiVersion` axis. The string is part of the
26593 // Helm-side contract with the Helm 3 chart-schema parser:
26594 // `helm dependency build` / `helm lint` / `helm template`
26595 // all resolve the chart under the Helm 3 v2 schema (permitting
26596 // top-level `dependencies:`); a drifted value to the legacy
26597 // Helm 2 `"v1"` schema (the pre-Helm-3 chart schema every
26598 // upstream Helm-3-migration doc names) silently reroutes the
26599 // rendered Chart.yaml through the Helm 2 parser, where the
26600 // top-level `dependencies:` block is unknown and the chart's
26601 // dep on the `pleme-computeunit` library chart never resolves
26602 // — `helm dependency build` reports "no requirements found"
26603 // and every `helm template` / `helm install` emits an empty
26604 // release (no ComputeUnit / Service / ScaledObject resources
26605 // land) far from the source caixa.lisp / the renderer's
26606 // `build_chart_yaml` call site. Changing it is a coordinated
26607 // Helm 4 chart-schema migration alongside the upstream Helm
26608 // chart-schema deprecation cycle, not an incidental edit.
26609 // Peer to `flux_helmrelease_api_version_pins_canonical_value`
26610 // / `flux_gitrepository_api_version_pins_canonical_value` /
26611 // `flux_kustomization_api_version_pins_canonical_value` /
26612 // `gateway_api_api_version_pins_canonical_value` /
26613 // `cilium_api_version_pins_canonical_value` on the sibling
26614 // cluster-side-CRD-apiVersion-pin set — those pin the K8s
26615 // apiserver-side `(apiVersion, kind)` `RESTMapper` contract,
26616 // this one pins the Helm-side chart-schema-parser contract
26617 // that gates every rendered `lareira-<nome>` chart's
26618 // dependency resolution before any K8s resource lands.
26619 assert_eq!(HELM_CHART_API_VERSION, "v2");
26620 }
26621
26622 #[test]
26623 fn helm_chart_api_version_carries_helm_3_chart_schema_shape() {
26624 // Cross-axis invariant: the Helm 3 chart-schema apiVersion is
26625 // a bare `v<digit>` version label (unlike the K8s CRD
26626 // apiVersion — `<group>/<version>` — the sibling
26627 // FLUX_HELMRELEASE_API_VERSION / GATEWAY_API_API_VERSION /
26628 // CILIUM_API_VERSION lifts pin). The Helm-side chart-schema
26629 // grammar carries no group prefix at all — the value is
26630 // parsed as a plain schema-version discriminator against the
26631 // Helm binary's built-in schema table (Helm 2 recognizes
26632 // `"v1"`, Helm 3 recognizes both `"v1"` for legacy compat
26633 // and `"v2"` for its native schema). Pinning the shape here
26634 // means a future rebrand on the canonical lift can't silently
26635 // land a K8s-CRD-shaped `group/version` value (e.g. an
26636 // accidental copy-paste from the sibling FLUX / GATEWAY /
26637 // CILIUM constants) that the Helm chart-schema parser would
26638 // fail to recognize at `helm dependency build` /
26639 // `helm lint` / `helm template` time. The `v<digit>+`
26640 // invariant is the load-bearing Helm-side chart-schema
26641 // typed-discovery contract: a value the Helm binary's
26642 // chart-schema resolver consults to select the schema
26643 // parser that reads the rest of the document. Peer to
26644 // `flux_kind_helm_release_carries_upper_camel_case_shape`
26645 // (which pins the K8s `RESTMapper` kind-grammar shape) —
26646 // both close the "the shape of the lifted schema-version
26647 // discriminator is grammatical, not just a byte-equal string"
26648 // discipline at the lift site.
26649 let v = HELM_CHART_API_VERSION;
26650 assert!(
26651 !v.is_empty(),
26652 "HELM_CHART_API_VERSION {v:?} must be non-empty per the Helm \
26653 chart-schema apiVersion grammar"
26654 );
26655 assert!(
26656 !v.contains('/'),
26657 "HELM_CHART_API_VERSION {v:?} must not contain `/` — the Helm-side \
26658 chart-schema apiVersion is a bare `v<digit>` label with no group \
26659 prefix, unlike the K8s CRD `<group>/<version>` shape the sibling \
26660 FLUX_HELMRELEASE_API_VERSION / GATEWAY_API_API_VERSION / \
26661 CILIUM_API_VERSION lifts carry"
26662 );
26663 let bytes = v.as_bytes();
26664 assert_eq!(
26665 bytes[0], b'v',
26666 "HELM_CHART_API_VERSION {v:?} must start with `v` per the Helm \
26667 chart-schema apiVersion grammar (`v1` for the legacy schema, \
26668 `v2` for the Helm 3 schema — every accepted value the Helm \
26669 binary's chart-schema resolver knows carries the `v` prefix)"
26670 );
26671 assert!(
26672 bytes.len() >= 2,
26673 "HELM_CHART_API_VERSION {v:?} must be at least 2 bytes (`v` + \
26674 at least one digit) per the Helm chart-schema apiVersion \
26675 grammar"
26676 );
26677 assert!(
26678 bytes[1..].iter().all(u8::is_ascii_digit),
26679 "HELM_CHART_API_VERSION {v:?} bytes after the leading `v` must be \
26680 ASCII digits per the Helm chart-schema apiVersion grammar — \
26681 no dots, no hyphens, no whitespace, no non-digit bytes the \
26682 Helm binary's chart-schema resolver would reject"
26683 );
26684 }
26685
26686 #[test]
26687 fn helm_chart_type_application_pins_canonical_value() {
26688 // Pin the actual string so a typo in this lift can't silently
26689 // rebrand the Helm 3 chart-schema `type` field's canonical
26690 // `application` per-chart-kind discriminator scalar-value the
26691 // rendered `lareira-<nome>` chart's Chart.yaml `type:` axis
26692 // declares. The value is part of the cluster-side contract with
26693 // Helm's per-release install-shape dispatch loop — the Helm
26694 // chart-schema pins the per-chart-kind axis to the closed set
26695 // `{"application", "library"}` (see
26696 // https://helm.sh/docs/topics/charts/#chart-types), so a drifted
26697 // value (`"Application"` / `"APPLICATION"` / `"app"` /
26698 // `"workload"`) lands the rendered `lareira-<nome>` chart outside
26699 // the schema's admitted set, and Helm's chart-schema parser
26700 // silently treats the unrecognized value as the default
26701 // `application` shape (masking the schema violation with no
26702 // process-log drift-signal); worse, an accidental collapse onto
26703 // the sibling `"library"` shape lands `lareira-<nome>` in the
26704 // dependency-only install-shape Helm refuses to install directly
26705 // ("Error: library charts cannot be installed"), dropping every
26706 // per-Servico `helm install` / `helm upgrade` release cycle with
26707 // no field naming the chart-kind-drift root cause. Changing this
26708 // value is a coordinated Helm chart-schema promotion alongside
26709 // the upstream Helm project's per-schema deprecation cycle, not
26710 // an incidental edit. Peer to
26711 // `helm_chart_api_version_pins_canonical_value` /
26712 // `kube_protocol_tcp_pins_canonical_value` /
26713 // `gateway_api_protocol_http_pins_canonical_value` /
26714 // `cilium_auth_mode_required_pins_canonical_value` on the
26715 // sibling canonical-Helm-chart-schema-axis + canonical-cluster-
26716 // side-OpenAPI-schema-enum-value pin sets — pivots the
26717 // canonical-enum-value single-sourcing discipline from the K8s-
26718 // CR-side surfaces onto the Helm-chart-schema-enum-value axis
26719 // every rendered Chart.yaml carries at its per-chart-kind
26720 // discriminator field.
26721 assert_eq!(HELM_CHART_TYPE_APPLICATION, "application");
26722 }
26723
26724 #[test]
26725 fn helm_chart_type_application_carries_lowercase_shape() {
26726 // Cross-axis invariant: the Helm 3 chart-schema `type` field
26727 // admits the closed set `{"application", "library"}` — every
26728 // admitted value is all-ASCII-lowercase throughout per the
26729 // upstream Helm project's per-enum-value naming convention
26730 // (distinct from the sibling K8s-core `Protocol` OpenAPI schema
26731 // enum's all-ASCII-uppercase per-value convention the
26732 // `kube_protocol_tcp_carries_upper_case_shape` pin carries, and
26733 // distinct from the sibling Gateway-API v1 `PathMatchType`
26734 // OpenAPI schema enum's UpperCamelCase per-value convention the
26735 // `gateway_api_path_match_type_path_prefix_carries_upper_camel_case_shape`
26736 // pin carries — the three peer canonical-cluster-side-schema-
26737 // enum-value conventions do not collapse). Same all-ASCII-
26738 // lowercase shape as the sibling Cilium `MutualAuthenticationMode`
26739 // enum-values the peer `cilium_auth_mode_required_carries_lowercase_shape`
26740 // / `cilium_auth_mode_disabled_carries_lowercase_shape` pins
26741 // enshrine — the two peer canonical-cluster-side-schema-enum-
26742 // value all-lowercase conventions collapse on the shared byte-
26743 // shape convention Helm and Cilium happen to share (independent
26744 // upstream projects, coincidental convention agreement).
26745 //
26746 // Pinning the shape here means a future rebrand on the canonical
26747 // lift can't silently land a malformed per-chart-kind scalar
26748 // (uppercase `"APPLICATION"`, mixed-case `"Application"`, empty)
26749 // that the Helm chart-schema parser would silently treat as the
26750 // default `application` shape (masking the drift with no
26751 // process-log signal).
26752 let v = HELM_CHART_TYPE_APPLICATION;
26753 assert!(
26754 !v.is_empty(),
26755 "HELM_CHART_TYPE_APPLICATION {v:?} must be non-empty per the \
26756 Helm 3 chart-schema `type` field grammar"
26757 );
26758 assert!(
26759 v.chars().all(|c| c.is_ascii_lowercase()),
26760 "HELM_CHART_TYPE_APPLICATION {v:?} must be ASCII-lowercase \
26761 throughout per the Helm 3 chart-schema per-chart-kind \
26762 discriminator naming convention — no uppercase, mixed-case, \
26763 or whitespace bytes the Helm chart-schema parser would \
26764 silently treat as the default `application` shape (masking \
26765 the drift with no process-log signal)"
26766 );
26767 }
26768
26769 #[test]
26770 fn helm_chart_type_library_pins_canonical_value() {
26771 // Pin the sibling closed-set arm of the Helm 3 chart-schema
26772 // `type` field's admitted set `{"application", "library"}` (see
26773 // https://helm.sh/docs/topics/charts/#chart-types). A drift on
26774 // this const's value (an `"Library"` / `"LIBRARY"` /
26775 // `"library-chart"` / `"lib"` typo, an accidental collapse onto
26776 // the sibling [`HELM_CHART_TYPE_APPLICATION`] shape) would land
26777 // a future per-Aplicacao library-chart emitter — the trajectory
26778 // item the [`HELM_CHART_TYPE_APPLICATION`] docstring names as
26779 // the natural next consumer of this const — outside the Helm
26780 // chart-schema's admitted set, with the same silent-collapse-
26781 // onto-`application`-default failure mode the peer
26782 // [`HELM_CHART_TYPE_APPLICATION`] pin's docstring enumerates on
26783 // the sibling closed-set arm (Helm's chart-schema parser
26784 // silently treats an unrecognized `type:` value as the default
26785 // `application` shape, so the misdeclared library chart installs
26786 // as an application chart instead of surfacing the schema
26787 // violation). Peer of
26788 // `helm_chart_type_application_pins_canonical_value` on the
26789 // sibling closed-set arm — the two pins together enshrine the
26790 // full closed set at the substrate-side canonical surface, and
26791 // the paired
26792 // `helm_chart_type_application_and_library_are_distinct` pin
26793 // (below) enforces the two arms never accidentally converge on
26794 // the same byte-shape.
26795 assert_eq!(HELM_CHART_TYPE_LIBRARY, "library");
26796 }
26797
26798 #[test]
26799 fn helm_chart_type_library_carries_lowercase_shape() {
26800 // Cross-axis invariant: the Helm 3 chart-schema `type` field
26801 // admits the closed set `{"application", "library"}` — every
26802 // admitted value is all-ASCII-lowercase throughout per the
26803 // upstream Helm project's per-enum-value naming convention.
26804 // Same all-ASCII-lowercase shape the peer
26805 // `helm_chart_type_application_carries_lowercase_shape` pin
26806 // enshrines on the sibling closed-set arm — the two pins
26807 // together enforce the shape-convention across the full
26808 // canonical-Helm-chart-schema-per-chart-kind-discriminator
26809 // closed set.
26810 //
26811 // Pinning the shape here means a future rebrand on the canonical
26812 // lift can't silently land a malformed per-chart-kind scalar
26813 // (uppercase `"LIBRARY"`, mixed-case `"Library"`, empty) that
26814 // the Helm chart-schema parser would silently treat as the
26815 // default `application` shape (masking the drift with no
26816 // process-log signal, and installing the misdeclared library
26817 // chart as an application chart instead of surfacing the
26818 // schema violation at chart-consumption time).
26819 let v = HELM_CHART_TYPE_LIBRARY;
26820 assert!(
26821 !v.is_empty(),
26822 "HELM_CHART_TYPE_LIBRARY {v:?} must be non-empty per the \
26823 Helm 3 chart-schema `type` field grammar"
26824 );
26825 assert!(
26826 v.chars().all(|c| c.is_ascii_lowercase()),
26827 "HELM_CHART_TYPE_LIBRARY {v:?} must be ASCII-lowercase \
26828 throughout per the Helm 3 chart-schema per-chart-kind \
26829 discriminator naming convention — no uppercase, mixed-case, \
26830 or whitespace bytes the Helm chart-schema parser would \
26831 silently treat as the default `application` shape (masking \
26832 the drift with no process-log signal)"
26833 );
26834 }
26835
26836 #[test]
26837 fn helm_chart_type_application_and_library_are_distinct() {
26838 // Structural distinctness invariant on the closed-set pair the
26839 // Helm 3 chart-schema `type` field admits (`{"application",
26840 // "library"}`). The two arms name distinct per-chart-kind
26841 // install shapes at the substrate-side Helm dispatch — an
26842 // `application`-typed chart installs into a namespace as a
26843 // workload while a `library`-typed chart is dependency-only
26844 // and Helm refuses to install it directly ("Error: library
26845 // charts cannot be installed") — so a future rebrand that
26846 // accidentally collapsed the two consts onto the same
26847 // byte-shape would land every consumer of one arm on the
26848 // sibling's install semantic by construction: a rendered
26849 // `lareira-<nome>` (application) chart that silently emitted
26850 // `type: library` would drop every per-Servico
26851 // `helm install` / `helm upgrade` release cycle with no field
26852 // naming the chart-kind-drift root cause, and (symmetrically)
26853 // a future per-Aplicacao library chart emitting
26854 // `type: application` would be install-able as a workload
26855 // when the substrate's install-shape dispatch expects it to
26856 // fail with the library-charts-cannot-be-installed diagnostic.
26857 // Pinning the distinctness here means a hypothetical future
26858 // edit that accidentally converges the two arms (a copy-paste
26859 // rebrand at one lift that stops at the peer const declaration,
26860 // a substrate-wide vocabulary shift that lands one arm without
26861 // its paired peer) surfaces at caixa-core build time rather
26862 // than as a chart-install-shape drift far from the source
26863 // commit. Same "closed-set arms are byte-distinct by
26864 // construction" discipline the peer
26865 // [`crate::CILIUM_AUTH_MODE_REQUIRED`] /
26866 // [`crate::CILIUM_AUTH_MODE_DISABLED`] pair carries on the
26867 // sibling two-arm Cilium `MutualAuthenticationMode` OpenAPI
26868 // enum closed set.
26869 assert_ne!(
26870 HELM_CHART_TYPE_APPLICATION, HELM_CHART_TYPE_LIBRARY,
26871 "HELM_CHART_TYPE_APPLICATION ({HELM_CHART_TYPE_APPLICATION:?}) and \
26872 HELM_CHART_TYPE_LIBRARY ({HELM_CHART_TYPE_LIBRARY:?}) must remain \
26873 byte-distinct — the two arms name the two install shapes of the \
26874 Helm 3 chart-schema `type` field's closed set {{\"application\", \
26875 \"library\"}} and every substrate-side consumer that dispatches \
26876 on the per-chart-kind axis relies on the two byte-shapes \
26877 distinguishing the workload-install-shape arm from the \
26878 dependency-only-install-shape arm"
26879 );
26880 }
26881
26882 #[test]
26883 fn helm_chart_key_api_version_pins_canonical_value() {
26884 // Pin the actual byte-string so a typo in this lift can't
26885 // silently rebrand the Helm 3 `Chart.yaml` top-level chart-
26886 // schema-apiVersion YAML axis-key the rendered `lareira-<nome>`
26887 // chart declares. The string is part of the substrate-side
26888 // contract with Helm's chart-schema parser at
26889 // `helm dependency build` / `helm lint` / `helm template` /
26890 // `helm install` time: the parser looks up the per-chart
26891 // chart-schema-apiVersion scalar under exactly this top-level
26892 // YAML key (Helm's chart-schema treats a missing `apiVersion:`
26893 // top-level scalar as an "apiVersion is required" hard error,
26894 // and Helm 3's chart-schema-version-router silently defaults
26895 // an unrecognized top-level apiVersion-carrier key to Helm 2
26896 // parsing shape). A drift on this const's value (an accidental
26897 // collapse onto `"ApiVersion"` / `"apiversion"` /
26898 // `"schemaVersion"` / the empty string) would silently reroute
26899 // the rendered `Chart.yaml` through the wrong chart-schema
26900 // parser at `helm dependency build` / `helm lint` /
26901 // `helm template` time. Peer to
26902 // `helm_chart_api_version_pins_canonical_value` on the sibling
26903 // axis-value canonical pin — completes the per-Chart.yaml
26904 // chart-schema-apiVersion axis's `(key, value)` canonical-pin
26905 // pair at the substrate.
26906 assert_eq!(HELM_CHART_KEY_API_VERSION, "apiVersion");
26907 }
26908
26909 #[test]
26910 fn helm_chart_key_api_version_matches_kube_key_api_version() {
26911 // Load-bearing byte-shape coincidence between the Helm 3
26912 // `Chart.yaml` top-level chart-schema-apiVersion YAML axis-key
26913 // ([`HELM_CHART_KEY_API_VERSION`]) and the K8s-CR top-level
26914 // per-CR schema-apiVersion YAML axis-key ([`KUBE_KEY_API_VERSION`])
26915 // — Helm inherits the K8s CR top-level shape verbatim (see
26916 // https://helm.sh/docs/topics/charts/#the-chartyaml-file), so
26917 // every consumer that navigates a Chart.yaml top-level mapping
26918 // by the schema-apiVersion key and every consumer that
26919 // navigates a K8s CR top-level mapping by the schema-apiVersion
26920 // key both read the byte-identical `"apiVersion"` key. The two
26921 // axes are structurally-independent schema surfaces (the Helm 3
26922 // chart-schema top-level shape vs. the K8s apiserver-side CR
26923 // top-level shape), so the substrate carries two distinct
26924 // `pub const` symbols; this pin makes the byte-shape
26925 // coincidence load-bearing rather than accidental so a future
26926 // K8s-side rebrand at [`KUBE_KEY_API_VERSION`] (or a Helm-side
26927 // rebrand at [`HELM_CHART_KEY_API_VERSION`]) that dropped the
26928 // byte-identity would fail the pin at substrate-build time
26929 // rather than as a silent Helm-chart-schema-parser rejection
26930 // at `helm lint` / `helm template` time far from the drift
26931 // site. Complementary to the sibling
26932 // [`helm_chart_key_type_is_byte_distinct_from_kube_key_kind`]
26933 // pin — that peer asserts the per-chart-kind discriminator key
26934 // pair is byte-distinct across the two schema surfaces (the
26935 // Chart.yaml `type:` axis vs. the K8s CR `kind:` axis), and
26936 // this pin asserts the per-schema-apiVersion axis-key pair is
26937 // byte-identical across the two schema surfaces; together the
26938 // two pins cover the full independence-map of the top-level
26939 // discriminator axes at the two schema surfaces.
26940 assert_eq!(
26941 HELM_CHART_KEY_API_VERSION, KUBE_KEY_API_VERSION,
26942 "HELM_CHART_KEY_API_VERSION ({HELM_CHART_KEY_API_VERSION:?}) \
26943 must remain byte-identical to KUBE_KEY_API_VERSION \
26944 ({KUBE_KEY_API_VERSION:?}) — Helm 3 inherits the K8s CR \
26945 top-level schema-apiVersion YAML-axis-key byte-shape \
26946 verbatim, and every downstream consumer that navigates a \
26947 `Chart.yaml` / K8s CR top-level mapping by the schema-\
26948 apiVersion key reads the byte-identical `\"apiVersion\"` \
26949 key; a drift on either side silently reroutes the \
26950 consumer through a schema-parser rejection far from the \
26951 drift site"
26952 );
26953 }
26954
26955 #[test]
26956 fn helm_chart_key_type_pins_canonical_value() {
26957 // Pin the actual byte-string so a typo in this lift can't silently
26958 // rebrand the Helm 3 `Chart.yaml` top-level per-chart-kind
26959 // discriminator YAML axis-key the rendered `lareira-<nome>` chart
26960 // declares. The string is part of the substrate-side contract with
26961 // Helm's chart-schema parser at `helm dependency build` /
26962 // `helm lint` / `helm template` / `helm install` time: the parser
26963 // looks up the per-chart-kind discriminator scalar under exactly
26964 // this top-level YAML key, and a drift on this const's value
26965 // (an accidental collapse onto `"Type"` / `"chartType"` /
26966 // `"kind"`, or the empty string) would silently reroute the
26967 // rendered `Chart.yaml` through the schema-shape-defaulting arm
26968 // of Helm's parser (unknown top-level keys default the
26969 // per-chart-kind axis to `application` with no process-log
26970 // signal). Peer to
26971 // `helm_chart_type_application_pins_canonical_value` /
26972 // `helm_chart_type_library_pins_canonical_value` on the sibling
26973 // axis-value canonical pin pair — completes the per-Chart.yaml
26974 // per-chart-kind discriminator axis's `(key, value-set)`
26975 // canonical-pin trio at the substrate.
26976 assert_eq!(HELM_CHART_KEY_TYPE, "type");
26977 }
26978
26979 #[test]
26980 fn helm_chart_key_type_is_byte_distinct_from_kube_key_kind() {
26981 // Structural distinctness invariant: the Helm 3 `Chart.yaml`
26982 // top-level per-chart-kind YAML axis-key
26983 // ([`HELM_CHART_KEY_TYPE`]) and the K8s CR top-level per-CRD
26984 // kind-discriminator YAML axis-key ([`KUBE_KEY_KIND`]) name
26985 // two structurally-independent axes at two structurally-
26986 // independent schema surfaces — the Helm-side chart-schema
26987 // top-level shape and the K8s-apiserver-side CR top-level
26988 // shape — and every substrate-side renderer that emits or
26989 // navigates a `Chart.yaml` vs. a K8s CR YAML relies on the
26990 // two byte-shapes distinguishing the two schema-surfaces at
26991 // its top-level mapping-key resolution. A hypothetical future
26992 // rebrand that accidentally aliased [`HELM_CHART_KEY_TYPE`]
26993 // at [`KUBE_KEY_KIND`]'s canonical would collapse the
26994 // per-Chart.yaml per-chart-kind discriminator axis onto the
26995 // K8s-CR per-CRD kind-discriminator axis at every consumer,
26996 // and Helm's chart-schema parser would silently drop the
26997 // rebranded key (top-level `kind:` is not part of the Helm 3
26998 // chart-schema's admitted set — the parser silently ignores
26999 // it, defaulting the per-chart-kind axis to `application`
27000 // with no process-log signal). Same "byte-distinct axis-keys
27001 // at structurally-independent schema surfaces" discipline the
27002 // peer [`CILIUM_KEY_PATH`] / [`GATEWAY_API_KEY_PATH`]
27003 // (ef6114f / 9f45aa4) pair carries on the sibling Cilium-CRD-
27004 // vs.-Gateway-API-per-HTTPRouteMatch path-matcher axis
27005 // independence — extends the discipline from the two K8s-CR-
27006 // side path-matcher schemas onto the Helm-side vs. K8s-side
27007 // top-level discriminator-key axis pair.
27008 assert_ne!(
27009 HELM_CHART_KEY_TYPE, KUBE_KEY_KIND,
27010 "HELM_CHART_KEY_TYPE ({HELM_CHART_KEY_TYPE:?}) and \
27011 KUBE_KEY_KIND ({KUBE_KEY_KIND:?}) name the top-level \
27012 discriminator keys of two structurally-independent schema \
27013 surfaces (the Helm 3 chart-schema and the K8s apiserver-side \
27014 CR schema) and must remain byte-distinct — a collapse \
27015 silently reroutes the per-Chart.yaml per-chart-kind axis \
27016 through the K8s-CR-shape-defaulting arm of Helm's parser"
27017 );
27018 }
27019
27020 #[test]
27021 fn helm_chart_key_app_version_pins_canonical_value() {
27022 // Pin the actual byte-string so a typo in this lift can't silently
27023 // rebrand the Helm 3 `Chart.yaml` top-level per-chart-app-version
27024 // YAML axis-key the rendered `lareira-<nome>` chart declares.
27025 // The string is part of the substrate-side contract with Helm's
27026 // chart-schema parser + every downstream chart-consumer that
27027 // routes the underlying-application-version display onto the
27028 // rendered chart's per-app-version field (Artifact Hub's per-
27029 // chart-search index, `helm search` / `helm show chart` operator
27030 // surfaces, the OCI-artifact-labels emitter every chart-publish
27031 // pipeline exports). A drift on this const's value (`"AppVersion"`
27032 // / `"applicationVersion"` / `"appversion"` / the empty string)
27033 // would silently drop the underlying-application-version field
27034 // from the parsed chart-metadata shape at every downstream
27035 // consumer, with no process-log signal at the substrate-side
27036 // emitter site. The `appVersion:` camelCase byte-shape is the
27037 // load-bearing Helm chart-schema per-app-version YAML axis-key
27038 // grammar the upstream Helm project pins. Peer to
27039 // `helm_chart_key_type_pins_canonical_value` on the sibling
27040 // per-Chart.yaml top-level YAML axis-key canonical pin surface —
27041 // completes the per-Chart.yaml top-level YAML axis-key
27042 // canonical-pin trio at the substrate for the three serde-
27043 // rename-literal-only axes on [`caixa_helm::ChartYaml`] (the
27044 // third top-level axis-key `apiVersion` lands under the peer
27045 // [`HELM_CHART_KEY_API_VERSION`] pin whose byte-shape coincides
27046 // with [`KUBE_KEY_API_VERSION`] by Helm's design decision to
27047 // inherit the K8s CR top-level shape verbatim — the paired
27048 // `helm_chart_key_api_version_matches_kube_key_api_version`
27049 // pin makes the coincidence load-bearing rather than
27050 // accidental).
27051 assert_eq!(HELM_CHART_KEY_APP_VERSION, "appVersion");
27052 }
27053
27054 #[test]
27055 fn helm_chart_key_app_version_is_byte_distinct_from_helm_chart_key_version() {
27056 // Structural distinctness invariant on the per-Chart.yaml top-
27057 // level version-axis-key pair. The Helm 3 chart-schema pins two
27058 // structurally-distinct version YAML axis-keys at the top-level
27059 // of every `Chart.yaml`:
27060 //
27061 // - `version:` — the chart's own SemVer (incremented per
27062 // release of the chart itself)
27063 // - `appVersion:` — the underlying application's version
27064 // (the version the containerized workload the chart
27065 // installs advertises)
27066 //
27067 // At the caixa-helm renderer both YAML axes today draw from the
27068 // caixa's `:versao` at `build_chart_yaml` (a caixa's per-caixa
27069 // BLAKE3-closure identity binds chart + wasm-binary at exactly
27070 // one release axis), but the Helm 3 chart-schema pins the two
27071 // top-level YAML keys distinctly regardless — every downstream
27072 // Helm-consumer (Artifact Hub's per-chart index, `helm search` /
27073 // `helm show chart` surfaces) routes the two version-axis
27074 // scalars onto distinct display fields. A hypothetical future
27075 // rebrand that accidentally aliased [`HELM_CHART_KEY_APP_VERSION`]
27076 // at the sibling per-Chart.yaml top-level `version:` key
27077 // (`"version"`) would collapse the two YAML axes at the
27078 // renderer's ChartYaml serialization, and Helm's chart-schema
27079 // parser would silently read the app-version scalar under the
27080 // chart-own-SemVer axis (the last `version:` key wins in
27081 // `serde_yaml`'s emitted mapping under this drift), overwriting
27082 // the chart's own SemVer at every downstream chart-consumer.
27083 // Same "byte-distinct version-axis keys at the same schema
27084 // surface" discipline the peer [`FLEET_PROGRAMS_KEY_VERSAO`] /
27085 // [`FLEET_PROGRAMS_KEY_NAME`] pair carries on the sibling
27086 // per-fleet-programs-entry axis pair — extends the discipline
27087 // from the per-fleet-programs-entry key-pair onto the per-
27088 // Chart.yaml top-level version-axis-key pair.
27089 assert_ne!(
27090 HELM_CHART_KEY_APP_VERSION, "version",
27091 "HELM_CHART_KEY_APP_VERSION ({HELM_CHART_KEY_APP_VERSION:?}) \
27092 must remain byte-distinct from the sibling per-Chart.yaml \
27093 top-level chart-own-SemVer `version:` key — a collapse \
27094 silently overwrites the chart's own SemVer at every \
27095 downstream Helm chart-consumer"
27096 );
27097 }
27098
27099 #[test]
27100 fn helm_chart_key_dependencies_pins_canonical_value() {
27101 // Pin the actual byte-string so a typo in this lift can't silently
27102 // rebrand the Helm 3 `Chart.yaml` top-level per-chart dependency-
27103 // list YAML axis-key the rendered `lareira-<nome>` chart declares.
27104 // The string is part of the substrate-side contract with Helm's
27105 // chart-schema parser — every rendered chart's `dependencies:`
27106 // list-container mounts under this exact byte-shape, and Helm's
27107 // per-dep resolver at `helm dependency build` / `helm dependency
27108 // update` time consumes the per-entry sub-mapping tetrad only if
27109 // the top-level list-container key matches this canonical shape.
27110 // A drift on this const's value (`"Dependencies"` / `"deps"` /
27111 // `"chartDependencies"` / `"depends"` / the empty string) would
27112 // silently drop the entire per-chart dep list from the parsed
27113 // chart-metadata shape, and every rendered `lareira-<nome>`
27114 // chart's install would fail with `template: no template ...
27115 // associated with template ...` far from the drift site with
27116 // no field naming the top-level-list-key-drift root cause. Peer
27117 // to [`helm_chart_key_type_pins_canonical_value`] /
27118 // [`helm_chart_key_app_version_pins_canonical_value`] /
27119 // [`helm_chart_key_api_version_pins_canonical_value`] on the
27120 // sibling per-Chart.yaml top-level YAML axis-key canonical-pin
27121 // surface — extends the per-Chart.yaml top-level YAML axis-key
27122 // canonical-pin trio those pins established onto the fourth
27123 // top-level axis-key at the substrate, the parent list-container
27124 // whose already-lifted per-`dependencies[]`-entry sub-mapping
27125 // tetrad ([`HELM_CHART_DEPENDENCY_KEY_NAME`] /
27126 // [`HELM_CHART_DEPENDENCY_KEY_VERSION`] /
27127 // [`HELM_CHART_DEPENDENCY_KEY_REPOSITORY`] /
27128 // [`HELM_CHART_DEPENDENCY_KEY_ALIAS`]) mounts one level down.
27129 assert_eq!(HELM_CHART_KEY_DEPENDENCIES, "dependencies");
27130 }
27131
27132 #[test]
27133 fn helm_chart_key_dependencies_is_byte_distinct_from_per_dep_sub_mapping_tetrad() {
27134 // Structural distinctness invariant on the per-Chart.yaml
27135 // `dependencies:` parent list-container axis-key vs. the four
27136 // already-lifted per-entry sub-mapping keys mounted one level
27137 // down. The parent+children pair spans two schema-nested YAML
27138 // levels — the top-level `dependencies:` list-container and
27139 // the per-entry sub-mapping `{name, version, repository,
27140 // alias}` — and Helm's chart-schema parser navigates them as
27141 // two structurally-independent axes: a collapse of the parent
27142 // axis-key onto any child (e.g. an accidental future rebrand
27143 // that renamed the [`HELM_CHART_KEY_DEPENDENCIES`] value to
27144 // `"name"` or `"version"`) would either drop the entire per-
27145 // chart dep list at the top-level parse (the child scalar
27146 // silently masks the parent list-container the schema expects)
27147 // or read the top-level list under a scalar-shaped axis-key
27148 // and reject the chart at `helm lint` with a shape mismatch
27149 // far from the drift site. Same "parent list-container
27150 // axis-key must remain byte-distinct from every child sub-
27151 // mapping axis-key" discipline the peer
27152 // [`SUPERVISOR_KEY_CHILDREN`] parent axis-key already carries
27153 // against the sibling [`SUPERVISOR_CHILD_KEY_CAIXA`] /
27154 // [`SUPERVISOR_CHILD_KEY_VERSAO`] / [`SUPERVISOR_CHILD_KEY_RESTART`]
27155 // per-entry sub-mapping triad on the M2 typed
27156 // `:supervisor :children` surface — extends the discipline onto
27157 // the Helm 3 `Chart.yaml` per-chart-dependency-list surface.
27158 for child in [
27159 HELM_CHART_DEPENDENCY_KEY_NAME,
27160 HELM_CHART_DEPENDENCY_KEY_VERSION,
27161 HELM_CHART_DEPENDENCY_KEY_REPOSITORY,
27162 HELM_CHART_DEPENDENCY_KEY_ALIAS,
27163 ] {
27164 assert_ne!(
27165 HELM_CHART_KEY_DEPENDENCIES, child,
27166 "HELM_CHART_KEY_DEPENDENCIES \
27167 ({HELM_CHART_KEY_DEPENDENCIES:?}) must remain \
27168 byte-distinct from every per-`dependencies[]`-entry \
27169 sub-mapping key ({child:?}) — a collapse silently \
27170 orphans the parent list-container at `helm lint` / \
27171 `helm dependency build` time"
27172 );
27173 }
27174 }
27175
27176 #[test]
27177 fn helm_chart_dependency_key_tetrad_pins_canonical_values() {
27178 // Byte-string pin on the per-`dependencies[]`-entry sub-mapping
27179 // YAML axis-key tetrad the Helm 3 chart-schema pins for every
27180 // per-dep entry the substrate emits under the top-level
27181 // `dependencies:` list at every rendered `lareira-<nome>`
27182 // Chart.yaml. The four axis-keys name the four load-bearing
27183 // per-dep sub-mapping fields Helm's per-dep resolver consumes
27184 // at `helm dependency build` / `helm dependency update` time:
27185 // `name` (the Helm-registry chart name), `version` (the SemVer-
27186 // range constraint), `repository` (the registry URL to fetch
27187 // from), and `alias` (the per-dep values wrap-key override).
27188 // A drift on any const's value (a typo on this lift, a case
27189 // flip to `"Name"` / `"Version"` / `"Repository"` / `"Alias"`,
27190 // an accidental collapse onto a sibling axis-key) would
27191 // silently rebrand the wire key at the `caixa_helm::ChartYaml`
27192 // emitter site — Helm's chart-schema parser silently drops
27193 // the drifted per-dep sub-mapping field, and the per-dep
27194 // resolver falls back to the parsed-shape defaults
27195 // (`""` / wildcard `*` / "no repository defined") at
27196 // `helm dependency build` time far from the drift site. Peer
27197 // to [`supervisor_child_key_tetrad_pins_canonical_values`] on
27198 // the sibling per-`:children` sub-mapping tetrad (ef912df) and
27199 // [`entrada_key_tetrad_pins_canonical_values`] on the sibling
27200 // per-`:entrada` sub-mapping tetrad (a3d6162).
27201 assert_eq!(HELM_CHART_DEPENDENCY_KEY_NAME, "name");
27202 assert_eq!(HELM_CHART_DEPENDENCY_KEY_VERSION, "version");
27203 assert_eq!(HELM_CHART_DEPENDENCY_KEY_REPOSITORY, "repository");
27204 assert_eq!(HELM_CHART_DEPENDENCY_KEY_ALIAS, "alias");
27205 }
27206
27207 #[test]
27208 fn helm_chart_dependency_key_name_matches_kube_key_name() {
27209 // Load-bearing byte-shape coincidence between the Helm 3
27210 // Chart.yaml per-`dependencies[]`-entry sub-mapping name key
27211 // ([`HELM_CHART_DEPENDENCY_KEY_NAME`]) and the K8s CR
27212 // per-`metadata` sub-mapping name key ([`KUBE_KEY_NAME`]) —
27213 // Helm inherits the K8s CR body-key vocabulary at every schema
27214 // surface it consumes (chart-metadata top-level, per-CR
27215 // install-payload, per-dep dependency-list). The two axes are
27216 // structurally-independent schema surfaces (the Helm 3
27217 // chart-schema per-dep entry vs. the K8s apiserver-side CR
27218 // metadata block) whose byte-shapes happen to coincide today;
27219 // this pin makes the byte-shape coincidence load-bearing
27220 // rather than accidental so a future K8s-side rebrand at
27221 // [`KUBE_KEY_NAME`] (or a Helm-side rebrand at
27222 // [`HELM_CHART_DEPENDENCY_KEY_NAME`]) that dropped the
27223 // byte-identity would fail the pin at substrate-build time
27224 // rather than as a silent Helm-per-dep-resolver drop at
27225 // `helm dependency build` time far from the drift site. Same
27226 // discipline as the peer
27227 // [`helm_chart_key_api_version_matches_kube_key_api_version`]
27228 // pin on the sibling top-level chart-schema-apiVersion axis
27229 // (cc44e4b) — extends the axis-key byte-identity coincidence
27230 // discipline from the per-Chart.yaml top-level shape onto the
27231 // per-`dependencies[]`-entry sub-mapping shape.
27232 assert_eq!(
27233 HELM_CHART_DEPENDENCY_KEY_NAME, KUBE_KEY_NAME,
27234 "HELM_CHART_DEPENDENCY_KEY_NAME ({HELM_CHART_DEPENDENCY_KEY_NAME:?}) \
27235 must remain byte-identical to KUBE_KEY_NAME ({KUBE_KEY_NAME:?}) — \
27236 Helm 3 inherits the K8s CR body-key vocabulary at every schema \
27237 surface, and every downstream consumer that navigates a per-dep \
27238 sub-mapping / a K8s CR metadata block by the `name` key reads the \
27239 byte-identical `\"name\"` key; a drift on either side silently \
27240 reroutes the consumer through a schema-parser drop far from the \
27241 drift site"
27242 );
27243 }
27244
27245 #[test]
27246 fn helm_chart_readme_filename_pins_canonical_value() {
27247 // Pin the actual byte-string so a typo on the canonical lift
27248 // can't silently rebrand the third leg of the per-`lareira-<nome>`
27249 // chart-directory `{Chart.yaml, values.yaml, README.md}`
27250 // canonical-per-chart-directory-filename axis triple. Peer to
27251 // the sibling
27252 // [`HELM_CHART_YAML_FILENAME`] / [`HELM_VALUES_YAML_FILENAME`]
27253 // canonical filename axes — the two schema-load-bearing halves
27254 // of the triple the sibling
27255 // [`HELM_VALUES_YAML_FILENAME`] docstring's closing paragraph
27256 // explicitly names as the pair that needed the third-leg
27257 // (`README.md`) filename half to close the discipline across
27258 // every `ChartFile` the [`caixa_helm::render_chart_for_servico`]
27259 // emitter's `ChartDir::files` vec carries. A drifted per-chart
27260 // readme filename value would surface downstream as GitHub /
27261 // Artifact Hub / any per-chart README-surfacing UI silently
27262 // falling back to "no README available" for the rendered
27263 // `lareira-<nome>` chart — the chart lists with no per-chart
27264 // elevator pitch or install instructions far from the drift
27265 // commit's source, with no field naming the readme-filename-
27266 // drift root cause. Same pin discipline as the peer
27267 // canonical-Helm-per-chart-directory-filename axes.
27268 assert_eq!(HELM_CHART_README_FILENAME, "README.md");
27269 }
27270
27271 #[test]
27272 fn helm_chart_readme_filename_carries_readme_dot_md_shape() {
27273 // Cross-axis invariant: the per-`lareira-<nome>`-chart-directory
27274 // human-facing readme filename carries the `.md` Markdown
27275 // extension the [`caixa_helm::build_readme`] emitter's Markdown-
27276 // shaped body targets — a drift to `.txt` / `.rst` /
27277 // extensionless / a per-fork rename would silently reroute the
27278 // rendered readme through a downstream tool that reads by
27279 // extension for its Markdown renderer (GitHub's per-repo README
27280 // surfacer, Artifact Hub's per-chart README surfacer, every
27281 // per-chart-directory `find . -name README.md` navigator any
27282 // downstream tooling might use). Peer to the sibling
27283 // [`HELM_CHART_YAML_FILENAME`] / [`HELM_VALUES_YAML_FILENAME`]
27284 // schema-load-bearing filename halves — the two YAML halves
27285 // carry the `.yaml` extension per Helm's per-chart-schema
27286 // convention; the readme half carries the `.md` extension per
27287 // the substrate's per-chart human-facing convention. Distinct
27288 // per-half schema conventions do not collapse on the shared
27289 // `<name>.<ext>` shape gate.
27290 let v = HELM_CHART_README_FILENAME;
27291 assert!(
27292 !v.is_empty(),
27293 "HELM_CHART_README_FILENAME {v:?} must be non-empty per the \
27294 per-`lareira-<nome>`-chart-directory readme-file axis"
27295 );
27296 assert!(
27297 v.ends_with(".md"),
27298 "HELM_CHART_README_FILENAME {v:?} must carry the `.md` \
27299 Markdown extension per the substrate's per-chart human-\
27300 facing readme convention — a drifted extension (`.txt` / \
27301 `.rst` / extensionless) would silently reroute downstream \
27302 tooling's Markdown renderer (GitHub's per-repo README \
27303 surfacer, Artifact Hub's per-chart README surfacer) to a \
27304 non-Markdown fallback path"
27305 );
27306 }
27307
27308 // ── lareira-<nome> chart-name prefix lift ──────────────────────
27309 //
27310 // The lift pins the substrate-wide `lareira-` chart-name prefix
27311 // as the single source of truth every per-Servico renderer
27312 // (caixa-helm, caixa-flux, caixa-tatara) reaches for, peer to the
27313 // [`DEFAULT_NAMESPACE`] (a085b26) lift on the canonical-namespace
27314 // axis. Pinning the prefix value, the helper's
27315 // construction-shape, and the DNS-1123-label round-trip for the
27316 // canonical-fixture input forms the structural floor every future
27317 // renderer consumer inherits by construction.
27318
27319 #[test]
27320 fn lareira_chart_name_prefix_pins_canonical_value() {
27321 // Pin the actual string value so a typo on the canonical lift
27322 // can't silently rebrand the substrate's per-Servico Helm chart
27323 // namespace. The string is part of the contract with the OCI
27324 // chart-publishing pipeline (`oci://<registry>/lareira-<nome>`),
27325 // the per-cluster HelmRelease `chart:` field (which Flux
27326 // resolves through the OCI ref), and the historical
27327 // `pleme-io/helmworks/charts/lareira-<name>/` source tree
27328 // layout (caixa-helm/src/lib.rs:7); changing it is a
27329 // coordinated multi-repo migration, not an incidental edit.
27330 // Peer to `default_namespace_pins_canonical_value` on the
27331 // canonical-string-value-pin axis for the
27332 // `DEFAULT_NAMESPACE` constant.
27333 assert_eq!(LAREIRA_CHART_NAME_PREFIX, "lareira-");
27334 }
27335
27336 #[test]
27337 fn lareira_chart_name_composes_prefix_and_nome() {
27338 // Pin the helper's construction shape — the chart name is the
27339 // prefix concatenated with the caixa's `:nome` verbatim, with
27340 // no intermediate hyphen, no path separator, no trimming. Pin
27341 // the canonical hello-rio fixture (the in-tree
27342 // `caixa-helm` test fixture at caixa-helm/src/lib.rs:431
27343 // already asserts `dir.name == "lareira-hello-rio"`, which
27344 // this helper now derives) and a peer fixture
27345 // (`checkout-aplicacao` member) to sweep the typical author
27346 // surface.
27347 assert_eq!(lareira_chart_name("hello-rio"), "lareira-hello-rio");
27348 assert_eq!(lareira_chart_name("cart"), "lareira-cart");
27349 assert_eq!(lareira_chart_name("worker"), "lareira-worker");
27350 }
27351
27352 #[test]
27353 fn lareira_chart_name_starts_with_prefix() {
27354 // Cross-axis invariant: every output of the helper begins with
27355 // the lifted prefix verbatim — a future refactor that
27356 // accidentally introduced a different prefix-application
27357 // shape (e.g. `format!("{nome}-lareira")` transposition, or a
27358 // `to_uppercase()` case fold) would surface here. The
27359 // structural pin holds for the empty `:nome` shape too
27360 // (a value `validate_nome` rejects upstream, but the helper
27361 // itself imposes no shape on the input).
27362 for nome in ["hello-rio", "cart", "worker", "a", ""] {
27363 let chart = lareira_chart_name(nome);
27364 assert!(
27365 chart.starts_with(LAREIRA_CHART_NAME_PREFIX),
27366 "lareira_chart_name({nome:?}) = {chart:?} must start with the lifted prefix \
27367 {LAREIRA_CHART_NAME_PREFIX:?}"
27368 );
27369 }
27370 }
27371
27372 #[test]
27373 fn lareira_chart_name_round_trips_through_dns_1123_for_validated_nome() {
27374 // Cross-axis invariant: every `:nome` past
27375 // [`Caixa::validate_nome`] (6c992f8) is a valid DNS-1123 label,
27376 // and the prepended `lareira-` segment is itself a valid
27377 // DNS-1123 label prefix (lowercase ASCII + hyphen with a
27378 // terminating-hyphen continuation). The composition therefore
27379 // round-trips through [`is_dns_1123_label`] for every
27380 // `:nome` whose joint length with the prefix stays ≤ 63 bytes
27381 // (the DNS-1123 label cap). The canonical author surface sits
27382 // far below that cap (the in-tree fixtures range from
27383 // `"a"` = 9-byte chart name to `"checkout"` = 16 bytes, with
27384 // the cap admitting up to 55-byte `:nome` values). Pin the
27385 // round-trip for the canonical-fixture set so a future renderer
27386 // that lands the helper's output verbatim as a K8s
27387 // `metadata.name` (caixa-helm's `ChartDir.name`,
27388 // caixa-flux's HelmRelease `chart:` field, caixa-tatara's
27389 // `release_name`) inherits the apiserver-valid floor by
27390 // construction.
27391 for nome in ["hello-rio", "cart", "worker", "checkout", "a"] {
27392 let chart = lareira_chart_name(nome);
27393 assert!(
27394 is_dns_1123_label(&chart).is_ok(),
27395 "lareira_chart_name({nome:?}) = {chart:?} must be a valid DNS-1123 label"
27396 );
27397 }
27398 }
27399
27400 #[test]
27401 fn lareira_chart_name_prefix_is_a_valid_dns_1123_segment_continuation() {
27402 // The lifted prefix is one substring of the rendered chart
27403 // name; pin its grammar so a future rebrand can't land a
27404 // value that would invalidate the joint DNS-1123 label
27405 // structurally. The prefix must:
27406 // - be lowercase ASCII alphanumeric + hyphen (the DNS-1123
27407 // accepted set), so its bytes don't widen the joint
27408 // accepted set;
27409 // - end with a hyphen (so the concatenation slot doesn't
27410 // accidentally merge with the leading character of the
27411 // `:nome` it precedes).
27412 assert!(
27413 LAREIRA_CHART_NAME_PREFIX
27414 .bytes()
27415 .all(|b| b.is_ascii_lowercase() || b.is_ascii_digit() || b == b'-'),
27416 "LAREIRA_CHART_NAME_PREFIX {LAREIRA_CHART_NAME_PREFIX:?} must use only DNS-1123-label \
27417 bytes (lowercase ASCII alphanumeric + hyphen)"
27418 );
27419 assert!(
27420 LAREIRA_CHART_NAME_PREFIX.ends_with('-'),
27421 "LAREIRA_CHART_NAME_PREFIX {LAREIRA_CHART_NAME_PREFIX:?} must end with `-` so \
27422 concatenation with the caixa's `:nome` produces a hyphenated joint label"
27423 );
27424 }
27425
27426 // ── is_lareira_chart_name_shape — joint-length budget on `:nome` ─────
27427 //
27428 // The canonical [`lareira_chart_name`] helper's own doc comment
27429 // (f7320d7) explicitly defers: "the M4 admission webhook will pin
27430 // the joint-length invariant when it lands". These tests land it
27431 // at the manifest-validate layer instead — the predicate consults
27432 // [`lareira_chart_name`] + [`is_dns_1123_label`] (no third primitive)
27433 // so a future rebrand of either axis re-derives the budget
27434 // mechanically and the test suite re-pins through the same lifts.
27435
27436 #[test]
27437 fn lareira_chart_name_nome_max_len_pins_arithmetic() {
27438 // Pin the arithmetic so a future shift in either input axis
27439 // surfaces here. The const is mechanically derived from
27440 // [`DNS_1123_LABEL_MAX_LEN`] (63 — the K8s apiserver cap every
27441 // chart-name-derived `metadata.name` inherits) minus
27442 // [`LAREIRA_CHART_NAME_PREFIX`].len() (8 — the canonical
27443 // chart-name prefix the lift f7320d7 made structural). The
27444 // landing value: 55 bytes the caixa's `:nome` may itself
27445 // occupy under the joint chart-name cap.
27446 assert_eq!(LAREIRA_CHART_NAME_NOME_MAX_LEN, 55);
27447 assert_eq!(
27448 LAREIRA_CHART_NAME_NOME_MAX_LEN,
27449 DNS_1123_LABEL_MAX_LEN - LAREIRA_CHART_NAME_PREFIX.len()
27450 );
27451 }
27452
27453 #[test]
27454 fn is_lareira_chart_name_shape_accepts_canonical_fixtures() {
27455 // Positive control: every in-tree fixture `:nome` (caixa-helm,
27456 // caixa-flux, caixa-mesh, caixa-tatara tests, the
27457 // checkout-aplicacao example) sits far below the cap. The
27458 // predicate must not regress this baseline shape.
27459 for nome in [
27460 "hello-rio",
27461 "cart",
27462 "worker",
27463 "checkout",
27464 "a",
27465 "akeyless-attest",
27466 ] {
27467 is_lareira_chart_name_shape(nome).unwrap_or_else(|e| {
27468 panic!("canonical :nome {nome:?} must pass chart-name budget, got {e:?}")
27469 });
27470 }
27471 }
27472
27473 #[test]
27474 fn is_lareira_chart_name_shape_accepts_nome_at_budget() {
27475 // Boundary-accepting case at the 55-byte cap — the joint
27476 // chart name is exactly 63 bytes, the DNS-1123 label cap.
27477 let at_cap = "a".repeat(LAREIRA_CHART_NAME_NOME_MAX_LEN);
27478 assert_eq!(at_cap.len(), LAREIRA_CHART_NAME_NOME_MAX_LEN);
27479 is_lareira_chart_name_shape(&at_cap).unwrap();
27480 assert_eq!(lareira_chart_name(&at_cap).len(), DNS_1123_LABEL_MAX_LEN);
27481 }
27482
27483 #[test]
27484 fn is_lareira_chart_name_shape_rejects_nome_one_over_budget() {
27485 // Fail-before-pass-after pin: 56 bytes is the smallest `:nome`
27486 // length that overflows the joint chart-name cap. The inner
27487 // [`is_dns_1123_label`] check accepts it (56 ≤ 63), so prior
27488 // to this gate it silently passed `Caixa::validate_nome` and
27489 // surfaced as a `helm lint` / apiserver rejection on the
27490 // rendered chart name far from the source caixa.lisp.
27491 let over = "a".repeat(LAREIRA_CHART_NAME_NOME_MAX_LEN + 1);
27492 let err = is_lareira_chart_name_shape(&over).unwrap_err();
27493 assert!(
27494 err.contains("63") && err.contains("64") && err.contains("55"),
27495 "diagnostic must name the DNS-1123 cap (63), the actual chart-name length (64), \
27496 and the per-`:nome` budget (55), got {err:?}"
27497 );
27498 assert!(
27499 err.contains("lareira-"),
27500 "diagnostic must name the canonical prefix verbatim, got {err:?}"
27501 );
27502 }
27503
27504 #[test]
27505 fn is_lareira_chart_name_shape_diagnostic_carries_offending_chart_name() {
27506 // The rendered chart name appears verbatim in the diagnostic
27507 // so the author sees exactly the string the apiserver would
27508 // have rejected — no re-derivation required to grep the source.
27509 let over = "x".repeat(LAREIRA_CHART_NAME_NOME_MAX_LEN + 5);
27510 let err = is_lareira_chart_name_shape(&over).unwrap_err();
27511 let expected_chart = lareira_chart_name(&over);
27512 assert!(
27513 err.contains(&expected_chart),
27514 "diagnostic must carry the rendered chart name {expected_chart:?} verbatim, \
27515 got {err:?}"
27516 );
27517 }
27518
27519 #[test]
27520 fn is_lareira_chart_name_shape_composes_through_canonical_helper() {
27521 // Cross-axis invariant: the predicate is defined exactly as
27522 // `is_dns_1123_label(lareira_chart_name(nome))` for the length
27523 // arm — no inline `format!("lareira-{nome}")` shape duplicating
27524 // the canonical lift. Pinning this composition closes the
27525 // drift footgun where a future predicate refactor re-inlines
27526 // the prefix-and-`:nome` concatenation and diverges from the
27527 // canonical helper. Sweep across the boundary so both sides
27528 // (accept + reject) consult the same helper.
27529 for delta in 0..=2usize {
27530 let nome = "z".repeat(LAREIRA_CHART_NAME_NOME_MAX_LEN.saturating_sub(delta));
27531 let predicate_ok = is_lareira_chart_name_shape(&nome).is_ok();
27532 let canonical_ok = is_dns_1123_label(&lareira_chart_name(&nome)).is_ok();
27533 assert_eq!(
27534 predicate_ok,
27535 canonical_ok,
27536 "predicate / canonical-composition divergence for :nome of len {} \
27537 (predicate_ok = {predicate_ok}, canonical_ok = {canonical_ok})",
27538 nome.len()
27539 );
27540 }
27541 }
27542
27543 // ── OCI chart-ref composer — `oci://<registry>/lareira-<nome>` ───────
27544 //
27545 // Peer to the `lareira_chart_name` composer above on the sibling
27546 // OCI-artifact-reference axis. Until this lift landed the
27547 // `caixa-tatara`'s `derive_chart_ref` carried an inline
27548 // `format!("oci://{registry}/{chart}")` — a 2-axis composition
27549 // (the `oci://` scheme prefix + the `lareira-<nome>` chart name)
27550 // whose byte-shape had no compile-time link to the historical doc
27551 // comments across `caixa-core`, `caixa-flux`, `caixa-helm`, and
27552 // `caixa-tatara` promising the same shape. Pin the const, the
27553 // composition equation, and the byte-shape against the prior
27554 // inline `format!` so a future composer-internal drift fires at
27555 // test time.
27556
27557 #[test]
27558 fn oci_scheme_prefix_pins_canonical_value() {
27559 // Pin the actual string value so a typo on the canonical lift
27560 // can't silently rebrand the substrate's OCI-artifact-reference
27561 // scheme. The string is part of the contract with the Helm 3
27562 // OCI storage protocol (`helm push chart.tgz oci://…`,
27563 // `helm registry login <registry>`, `helm install release
27564 // oci://…`) and the FluxCD `HelmRepository` `type: oci` source
27565 // (Flux source-controller keys off this literal on the OCI
27566 // path); changing it is a coordinated multi-repo migration,
27567 // not an incidental edit. Peer to
27568 // [`lareira_chart_name_prefix_pins_canonical_value`] on the
27569 // sibling canonical-string-value-pin axis.
27570 assert_eq!(OCI_SCHEME_PREFIX, "oci://");
27571 }
27572
27573 #[test]
27574 fn oci_chart_ref_pins_byte_shape_against_prior_inline_format() {
27575 // Byte-shape pin against the prior inline
27576 // `format!("oci://{registry}/{chart}")` at
27577 // caixa-tatara/src/lib.rs:202 (where `chart` was itself
27578 // `lareira_chart_name(caixa.nome.as_str())`). Any future
27579 // composer-internal drift on either axis (the `oci://` scheme
27580 // prefix, the `/` scheme-authority separator, the composition
27581 // with `lareira_chart_name`) surfaces here as a byte-shape
27582 // regression rather than at cluster-apply time far from the
27583 // drift site.
27584 assert_eq!(
27585 oci_chart_ref("ghcr.io/pleme-io/charts", "akeyless-attest"),
27586 "oci://ghcr.io/pleme-io/charts/lareira-akeyless-attest"
27587 );
27588 assert_eq!(
27589 oci_chart_ref("ghcr.io/pleme-io", "hello-rio"),
27590 "oci://ghcr.io/pleme-io/lareira-hello-rio"
27591 );
27592 }
27593
27594 #[test]
27595 fn oci_chart_ref_composes_through_canonical_helpers() {
27596 // Structural composition equation: the OCI chart-ref is
27597 // exactly `{OCI_SCHEME_PREFIX}{registry}/{lareira_chart_name(nome)}`
27598 // — no inline `"oci://"` scheme literal, no inline
27599 // `format!("lareira-{}", nome)` prefix duplication. Pinning
27600 // this composition closes the drift footgun where a future
27601 // composer refactor re-inlines either axis and diverges from
27602 // its canonical source of truth. Sweep across the canonical
27603 // fixture set so the composition holds for the same `:nome`
27604 // values every peer per-Servico renderer consults.
27605 for (registry, nome) in [
27606 ("ghcr.io/pleme-io/charts", "hello-rio"),
27607 ("ghcr.io/pleme-io", "cart"),
27608 ("registry.example.com", "worker"),
27609 ("localhost:5000", "checkout"),
27610 ] {
27611 let composed = oci_chart_ref(registry, nome);
27612 let expected = format!("{OCI_SCHEME_PREFIX}{registry}/{}", lareira_chart_name(nome));
27613 assert_eq!(
27614 composed, expected,
27615 "oci_chart_ref({registry:?}, {nome:?}) must equal the canonical composition \
27616 through OCI_SCHEME_PREFIX + lareira_chart_name"
27617 );
27618 }
27619 }
27620
27621 #[test]
27622 fn oci_chart_ref_starts_with_scheme_prefix() {
27623 // Cross-axis invariant: every output of the composer begins
27624 // with the lifted scheme prefix verbatim — a future refactor
27625 // that accidentally introduced a different scheme (e.g. a
27626 // `https://` transposition, or a scheme-authority separator
27627 // drift) would surface here. Peer to
27628 // [`lareira_chart_name_starts_with_prefix`] on the sibling
27629 // per-composer prefix-anchoring axis.
27630 for (registry, nome) in [
27631 ("ghcr.io/pleme-io/charts", "hello-rio"),
27632 ("ghcr.io/pleme-io", "cart"),
27633 ("localhost:5000", "a"),
27634 ] {
27635 let composed = oci_chart_ref(registry, nome);
27636 assert!(
27637 composed.starts_with(OCI_SCHEME_PREFIX),
27638 "oci_chart_ref({registry:?}, {nome:?}) = {composed:?} must start with the lifted \
27639 prefix {OCI_SCHEME_PREFIX:?}"
27640 );
27641 }
27642 }
27643
27644 #[test]
27645 fn oci_chart_ref_contains_lareira_chart_name_verbatim() {
27646 // Cross-axis invariant: every output of the composer contains
27647 // the canonical `lareira_chart_name(nome)` output verbatim as
27648 // its trailing segment — a future refactor that accidentally
27649 // introduced a case fold, a hyphen-collapse, or a different
27650 // prefix-application shape would surface here. Structurally
27651 // pins that the OCI chart-ref path and the peer per-Servico
27652 // renderer chart-name path (caixa-helm's `ChartDir.name`,
27653 // caixa-flux's `HelmRelease` `chart:` field) both reach for
27654 // the same canonical `lareira_chart_name` helper's output.
27655 for (registry, nome) in [
27656 ("ghcr.io/pleme-io/charts", "hello-rio"),
27657 ("ghcr.io/pleme-io", "cart"),
27658 ] {
27659 let composed = oci_chart_ref(registry, nome);
27660 let chart = lareira_chart_name(nome);
27661 assert!(
27662 composed.ends_with(&chart),
27663 "oci_chart_ref({registry:?}, {nome:?}) = {composed:?} must end with the canonical \
27664 lareira_chart_name({nome:?}) = {chart:?}"
27665 );
27666 }
27667 }
27668
27669 // ── Flux Kustomization source-sub-tree composer ───────────────────────
27670 //
27671 // Peer to the `oci_chart_ref` / `cilium_network_policy_name` /
27672 // `gateway_api_http_route_name` composers above on the sibling
27673 // canonical-load-bearing-scalar-that-consumers-key-off axis. Until
27674 // this lift landed the two-axis composition
27675 // (`./clusters/<cluster>/services/<nome>`) sat as an inline
27676 // `format!` template at the sole `caixa-flux::cluster_bundle`
27677 // `kustomization.yaml` production emit site plus a mirror-symmetric
27678 // inline `format!` at its paired test-fixture navigation site — no
27679 // compile-time link between the two sites and no compile-time link
27680 // ahead of the second production-emit occurrence the M4
27681 // `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's per-Aplicacao
27682 // `Kustomization` synthesis will surface. Pin the byte-shape, the
27683 // composition equation, and the sub-tree-scope invariants against
27684 // the prior inline `format!` so a future composer-internal drift
27685 // fires at test time.
27686
27687 #[test]
27688 fn flux_kustomization_source_subtree_pins_byte_shape_against_prior_inline_format() {
27689 // Byte-shape pin against the prior inline
27690 // `format!("./clusters/{cluster}/services/{name}")` at
27691 // caixa-flux/src/lib.rs (both the `cluster_bundle`
27692 // `kustomization.yaml` `spec.path` production emit site and the
27693 // paired `cluster_bundle_kustomization_path_pins_lifted_sub_tree`
27694 // test-fixture navigation site). Any future composer-internal
27695 // drift on either axis (the `./clusters/` per-cluster prefix,
27696 // the `/services/` per-caixa infix, the trailing per-caixa
27697 // suffix, the composition order) surfaces here as a byte-shape
27698 // regression rather than at cluster-apply time far from the
27699 // drift site.
27700 assert_eq!(
27701 flux_kustomization_source_subtree("rio", "hello-rio"),
27702 "./clusters/rio/services/hello-rio"
27703 );
27704 assert_eq!(
27705 flux_kustomization_source_subtree("paris", "cart"),
27706 "./clusters/paris/services/cart"
27707 );
27708 assert_eq!(
27709 flux_kustomization_source_subtree("tokyo", "checkout"),
27710 "./clusters/tokyo/services/checkout"
27711 );
27712 }
27713
27714 #[test]
27715 fn flux_kustomization_source_subtree_starts_with_relative_clusters_prefix() {
27716 // Structural invariant: every output starts with the canonical
27717 // `./clusters/` per-cluster-prefix half of the sub-tree seed.
27718 // The leading `./` scopes the emit to the GitRepository root
27719 // (the kustomize-controller keys the per-CR reconcile loop off
27720 // the GitRepository the paired `sourceRef` names, so the sub-
27721 // tree seed must resolve relative to the GitRepository root,
27722 // not an absolute filesystem path). The `clusters/` component
27723 // scopes the emit to the paired cluster's manifest set under
27724 // the pleme-io k8s repository's canonical directory-tree
27725 // layout.
27726 for (cluster, nome) in [
27727 ("rio", "hello-rio"),
27728 ("paris", "cart"),
27729 ("tokyo", "checkout"),
27730 ] {
27731 let sub = flux_kustomization_source_subtree(cluster, nome);
27732 assert!(
27733 sub.starts_with("./clusters/"),
27734 "flux_kustomization_source_subtree({cluster:?}, {nome:?}) = {sub:?} must start \
27735 with the canonical `./clusters/` GitRepository-root-relative per-cluster prefix"
27736 );
27737 }
27738 }
27739
27740 #[test]
27741 fn flux_kustomization_source_subtree_contains_paired_cluster_and_nome() {
27742 // Cross-axis invariant: every output contains the paired
27743 // `<cluster>` and `<nome>` scalars verbatim, at their canonical
27744 // per-cluster / per-caixa sub-tree positions. A future
27745 // composer-internal drift that accidentally case-folded, hyphen-
27746 // collapsed, or transposed either axis (`./clusters/rio/services/hello-rio`
27747 // → `./clusters/hello-rio/services/rio` under a swapped
27748 // composition, `./clusters/Rio/services/HelloRio` under an
27749 // accidental case fold) would surface here as a structural
27750 // regression rather than at cluster-apply time far from the
27751 // drift site.
27752 for (cluster, nome) in [
27753 ("rio", "hello-rio"),
27754 ("paris", "cart"),
27755 ("tokyo", "checkout"),
27756 ("us-east-1", "worker"),
27757 ] {
27758 let sub = flux_kustomization_source_subtree(cluster, nome);
27759 assert!(
27760 sub.contains(&format!("/clusters/{cluster}/")),
27761 "flux_kustomization_source_subtree({cluster:?}, {nome:?}) = {sub:?} must carry \
27762 the paired `<cluster>` scalar under its canonical per-cluster sub-tree position"
27763 );
27764 assert!(
27765 sub.ends_with(&format!("/services/{nome}")),
27766 "flux_kustomization_source_subtree({cluster:?}, {nome:?}) = {sub:?} must end with \
27767 the paired `/services/<nome>` per-caixa sub-tree suffix"
27768 );
27769 }
27770 }
27771
27772 #[test]
27773 fn flux_kustomization_source_subtree_distinct_across_clusters_and_nomes() {
27774 // Uniqueness invariant: two distinct `(cluster, nome)` inputs
27775 // resolve to two distinct `spec.path` scalars. A composer-
27776 // internal drift that accidentally coalesced either axis onto
27777 // a constant (dropping `<cluster>` or `<nome>` from the emit)
27778 // would silently collapse two per-cluster / per-caixa
27779 // `Kustomization` CRs onto the same reconcile-target sub-tree,
27780 // routing two distinct manifest sets through the same apply
27781 // loop with no diagnostic naming the coalesce root cause.
27782 let a = flux_kustomization_source_subtree("rio", "hello-rio");
27783 let b = flux_kustomization_source_subtree("paris", "hello-rio");
27784 let c = flux_kustomization_source_subtree("rio", "cart");
27785 assert_ne!(
27786 a, b,
27787 "distinct clusters (`rio` vs `paris`) hosting the same per-caixa Servico \
27788 must resolve to distinct `spec.path` scalars — coalesce would silently route \
27789 two per-cluster reconcile loops through the same manifest sub-tree"
27790 );
27791 assert_ne!(
27792 a, c,
27793 "distinct per-caixa Servicos (`hello-rio` vs `cart`) co-resident under the \
27794 same cluster must resolve to distinct `spec.path` scalars — coalesce would \
27795 silently route two per-caixa reconcile loops through the same manifest sub-tree"
27796 );
27797 }
27798
27799 #[test]
27800 fn pleme_program_selector_carries_only_program() {
27801 let sel = pleme_program_selector("cart");
27802 assert_eq!(sel.len(), 1);
27803 assert_eq!(sel.get(LABEL_PROGRAM).map(String::as_str), Some("cart"));
27804 assert!(sel.get(LABEL_APLICACAO).is_none());
27805 }
27806
27807 #[test]
27808 fn pleme_program_in_aplicacao_selector_carries_both_axes() {
27809 let sel = pleme_program_in_aplicacao_selector("cart", "checkout");
27810 assert_eq!(sel.len(), 2);
27811 assert_eq!(sel.get(LABEL_PROGRAM).map(String::as_str), Some("cart"));
27812 assert_eq!(
27813 sel.get(LABEL_APLICACAO).map(String::as_str),
27814 Some("checkout")
27815 );
27816 }
27817
27818 #[test]
27819 fn pleme_program_in_aplicacao_selector_iterates_alphabetically() {
27820 // BTreeMap iteration is sorted by key — pin that the renderer
27821 // (which translates the selector into a serde_yaml::Mapping
27822 // by iteration) gets a deterministic key order. `aplicacao`
27823 // sorts before `program`, so the rendered YAML's
27824 // `matchLabels:` block appears in that order regardless of
27825 // call-site arg order. Mirrors the M2 overlay helper's
27826 // alphabetical-iteration determinism property
27827 // (THEORY.md §V.2.7 render determinism).
27828 let sel = pleme_program_in_aplicacao_selector("cart", "checkout");
27829 let keys: Vec<_> = sel.keys().copied().collect();
27830 assert_eq!(keys, vec![LABEL_APLICACAO, LABEL_PROGRAM]);
27831 }
27832
27833 #[test]
27834 fn pleme_program_in_aplicacao_selector_arg_order_independent() {
27835 // Renaming the program vs. the aplicacao must each only affect
27836 // its own axis — pin that the helper doesn't transpose its
27837 // args silently (a footgun the prior inline-string approach
27838 // had: `program: <de>` and `aplicacao: <name>` were two
27839 // adjacent insert() calls with structurally identical arms,
27840 // trivially swappable in a refactor).
27841 let sel = pleme_program_in_aplicacao_selector("cart", "checkout");
27842 assert_eq!(sel.get(LABEL_PROGRAM).map(String::as_str), Some("cart"));
27843 assert_eq!(
27844 sel.get(LABEL_APLICACAO).map(String::as_str),
27845 Some("checkout")
27846 );
27847 let swapped = pleme_program_in_aplicacao_selector("checkout", "cart");
27848 assert_eq!(
27849 swapped.get(LABEL_PROGRAM).map(String::as_str),
27850 Some("checkout")
27851 );
27852 assert_eq!(
27853 swapped.get(LABEL_APLICACAO).map(String::as_str),
27854 Some("cart")
27855 );
27856 }
27857
27858 #[test]
27859 fn yaml_string_mapping_empty_input_returns_empty_mapping() {
27860 // Empty input → empty Mapping. Pinned because the caller's
27861 // emptiness contract (e.g. caixa-mesh's CNP labels block: the
27862 // policy's metadata.labels exists iff there are pleme-prefixed
27863 // labels to carry) depends on this being faithful.
27864 let v: serde_yaml::Value = yaml_string_mapping(BTreeMap::<&'static str, String>::new());
27865 let m = v.as_mapping().expect("mapping shape");
27866 assert!(m.is_empty());
27867 }
27868
27869 #[test]
27870 fn yaml_string_mapping_round_trips_string_values() {
27871 let mut input = BTreeMap::new();
27872 input.insert("foo", "1".to_string());
27873 input.insert("bar", "2".to_string());
27874 let v = yaml_string_mapping(input);
27875 let m = v.as_mapping().expect("mapping shape");
27876 assert_eq!(m.len(), 2);
27877 assert_eq!(m.get("foo").and_then(|x| x.as_str()), Some("1"));
27878 assert_eq!(m.get("bar").and_then(|x| x.as_str()), Some("2"));
27879 }
27880
27881 #[test]
27882 fn yaml_string_mapping_iterates_alphabetically_on_btreemap() {
27883 // Pin that BTreeMap input → alphabetical iteration → alphabetical
27884 // YAML key order. THEORY.md §V.2.7 render determinism.
27885 let mut input = BTreeMap::new();
27886 input.insert("zebra", "z".to_string());
27887 input.insert("apple", "a".to_string());
27888 input.insert("mango", "m".to_string());
27889 let v = yaml_string_mapping(input);
27890 let m = v.as_mapping().expect("mapping shape");
27891 let keys: Vec<&str> = m.iter().filter_map(|(k, _)| k.as_str()).collect();
27892 assert_eq!(keys, vec!["apple", "mango", "zebra"]);
27893 }
27894
27895 #[test]
27896 fn yaml_string_mapping_accepts_pleme_selector_helpers() {
27897 // The lift's load-bearing use case: passing the typed pleme-io
27898 // selectors directly into yaml_string_mapping yields the K8s
27899 // matchLabels surface every Cilium / Gateway selector field
27900 // expects, with the alphabetical key order the pleme helpers'
27901 // own determinism contract guarantees. Pinning end-to-end
27902 // composition so a future refactor of either helper can't
27903 // silently break the integration.
27904 let v = yaml_string_mapping(pleme_program_in_aplicacao_selector("cart", "checkout"));
27905 let m = v.as_mapping().expect("mapping shape");
27906 assert_eq!(m.len(), 2);
27907 assert_eq!(m.get(LABEL_PROGRAM).and_then(|x| x.as_str()), Some("cart"));
27908 assert_eq!(
27909 m.get(LABEL_APLICACAO).and_then(|x| x.as_str()),
27910 Some("checkout")
27911 );
27912 }
27913
27914 #[test]
27915 fn kube_key_consts_have_expected_values() {
27916 // Pin the actual string values — these are part of the K8s API
27917 // surface that every emitted artifact's apiserver-side parser
27918 // (Cilium, Gateway API, wasm-operator) depends on. Changing any
27919 // of them is a coordinated multi-renderer migration, not an
27920 // incidental edit.
27921 assert_eq!(KUBE_KEY_API_VERSION, "apiVersion");
27922 assert_eq!(KUBE_KEY_KIND, "kind");
27923 assert_eq!(KUBE_KEY_METADATA, "metadata");
27924 assert_eq!(KUBE_KEY_NAME, "name");
27925 assert_eq!(KUBE_KEY_NAMESPACE, "namespace");
27926 assert_eq!(KUBE_KEY_LABELS, "labels");
27927 assert_eq!(KUBE_KEY_MATCH_LABELS, "matchLabels");
27928 assert_eq!(KUBE_KEY_PORT, "port");
27929 assert_eq!(KUBE_KEY_PROTOCOL, "protocol");
27930 assert_eq!(KUBE_KEY_RULES, "rules");
27931 assert_eq!(KUBE_KEY_SPEC, "spec");
27932 }
27933
27934 #[test]
27935 fn fleet_programs_key_programs_pins_canonical_value() {
27936 // Bridge-arm pin: [`FLEET_PROGRAMS_KEY_PROGRAMS`] resolves to
27937 // the canonical `"programs"` byte today — the exact YAML key
27938 // the `lareira-fleet-programs` library chart's `values.yaml`
27939 // reads under `.Values.programs[]` to iterate one `ComputeUnit`
27940 // CR per entry, and the exact key both writer-side upsert paths
27941 // in [`caixa_flux`] (`upsert_into_helmrelease_programs` on the
27942 // aggregator-HelmRelease shape, `upsert_into_programs_yaml` on
27943 // the bare-values.yaml shape) navigate to walk the entry
27944 // sequence. Pin the literal here (peer with the
27945 // [`M3_KEY_PLACEMENT`] / [`M2_KEY_LIMITS`] /
27946 // [`M2_KEY_BEHAVIOR`] / [`M2_KEY_UPGRADE_FROM`] canonical-
27947 // literal pins on the sibling fleet-programs / M2 overlay
27948 // schema-key surfaces) so a future fleet-programs schema-key
27949 // rebrand surfaces here as a coordinated edit-point: the
27950 // sibling caixa-flux `fleet_programs_key_programs_re_export_
27951 // points_at_caixa_core_canonical` pinning test already pins
27952 // the equality at the re-export axis; this pin closes the
27953 // second coordinate of the triangle by anchoring the lifted
27954 // constant's current byte to the canonical fleet-programs
27955 // library chart's documented shape.
27956 assert_eq!(FLEET_PROGRAMS_KEY_PROGRAMS, "programs");
27957 }
27958
27959 #[test]
27960 fn fleet_programs_key_name_pins_canonical_value() {
27961 // Bridge-arm pin: [`FLEET_PROGRAMS_KEY_NAME`] resolves to the
27962 // canonical `"name"` byte today — the exact YAML key the
27963 // `lareira-fleet-programs` library chart's `range .Values.programs`
27964 // step reads per-entry to key each rendered `ComputeUnit` CR's
27965 // `metadata.name` off, and the exact key both writer-side upsert
27966 // paths in [`caixa_flux`] (`upsert_into_helmrelease_programs` on
27967 // the aggregator-HelmRelease shape, `upsert_into_programs_yaml`
27968 // on the bare-values.yaml shape) navigate to
27969 // match-by-name-and-replace-or-append, and the exact key both
27970 // emit-side entry builders ([`caixa_flux::programs_yaml_entry`]
27971 // per-Servico, [`caixa_mesh::programs_for_aplicacao`] per-
27972 // `:membros`) write the per-entry name-axis at. Pin the literal
27973 // here (peer with the [`fleet_programs_key_programs_pins_canonical_value`]
27974 // top-level array-key canonical-literal pin on the sibling
27975 // fleet-programs schema surface, and with the
27976 // [`M3_KEY_PLACEMENT`] / [`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`]
27977 // / [`M2_KEY_UPGRADE_FROM`] canonical-literal pins on the peer
27978 // per-entry overlay-key surfaces) so a future fleet-programs
27979 // schema-key rebrand on the per-entry name-discriminator axis
27980 // surfaces here as a coordinated edit-point at the definition
27981 // site rather than a silent apply-time split between the two
27982 // emitters and the two upsert readers.
27983 assert_eq!(FLEET_PROGRAMS_KEY_NAME, "name");
27984 }
27985
27986 #[test]
27987 fn fleet_programs_key_aplicacao_pins_canonical_value() {
27988 // Bridge-arm pin: [`FLEET_PROGRAMS_KEY_APLICACAO`] resolves
27989 // to the canonical `"aplicacao"` byte today — the exact YAML
27990 // key the substrate operator's fleet-aggregator reads to
27991 // group each rendered `programs[]` entry back onto its parent
27992 // Aplicacao graph, and the exact key the
27993 // [`caixa_mesh::programs_for_aplicacao`] per-`:membros`
27994 // entry-builder writes the parent-Aplicacao-nome annotation
27995 // at. Pin the literal here (peer with the sibling
27996 // [`fleet_programs_key_name_pins_canonical_value`] and
27997 // [`fleet_programs_key_programs_pins_canonical_value`]
27998 // canonical-literal pins on the peer fleet-programs schema
27999 // key surfaces, and with the [`M3_KEY_PLACEMENT`] /
28000 // [`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] /
28001 // [`M2_KEY_UPGRADE_FROM`] pins on the per-entry overlay-key
28002 // surfaces) so a future fleet-programs schema-key rebrand
28003 // on the per-entry parent-graph-annotation axis surfaces
28004 // here as a coordinated edit-point at the definition site
28005 // rather than a silent apply-time split between the
28006 // caixa-mesh Aplicacao-side emitter and the substrate
28007 // operator's per-graph aggregator reduce step.
28008 assert_eq!(FLEET_PROGRAMS_KEY_APLICACAO, "aplicacao");
28009 }
28010
28011 #[test]
28012 fn fleet_programs_key_versao_pins_canonical_value() {
28013 // Bridge-arm pin: [`FLEET_PROGRAMS_KEY_VERSAO`] resolves to
28014 // the canonical `"versao"` byte today — the exact YAML key
28015 // the substrate operator's per-`:membros` resolver reads to
28016 // fetch each `programs[]` entry's caixa.lisp release against
28017 // the M3 Aplicacao's declared per-member semver / range
28018 // constraint, and the exact key the
28019 // [`caixa_mesh::programs_for_aplicacao`] per-`:membros`
28020 // entry-builder writes the version-constraint at. Pin the
28021 // literal here (peer with the sibling
28022 // [`fleet_programs_key_name_pins_canonical_value`],
28023 // [`fleet_programs_key_aplicacao_pins_canonical_value`], and
28024 // [`fleet_programs_key_programs_pins_canonical_value`]
28025 // canonical-literal pins on the peer fleet-programs schema
28026 // key surfaces, and with the [`M3_KEY_PLACEMENT`] /
28027 // [`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] /
28028 // [`M2_KEY_UPGRADE_FROM`] pins on the per-entry overlay-key
28029 // surfaces) so a future fleet-programs schema-key rebrand
28030 // on the per-entry version-constraint axis surfaces here as
28031 // a coordinated edit-point at the definition site rather
28032 // than a silent apply-time split between the caixa-mesh
28033 // Aplicacao-side emitter and the substrate operator's
28034 // per-`:membros` resolver step.
28035 assert_eq!(FLEET_PROGRAMS_KEY_VERSAO, "versao");
28036 }
28037
28038 // ── label_selector — typed K8s LabelSelector wrapper ─────────────────
28039
28040 #[test]
28041 fn label_selector_wraps_in_match_labels_envelope() {
28042 // The lift's contract: input labels appear under the canonical
28043 // `matchLabels` key, and the outer Value is a Mapping with
28044 // exactly that one key. Pinning the shape so a future
28045 // refactor can't silently drop the wrapper (which would emit
28046 // bare `aplicacao: …, program: …` directly under the K8s
28047 // selector field — a structurally invalid LabelSelector that
28048 // some apiserver-side parsers tolerate by matching the empty
28049 // set, a sharp footgun).
28050 let mut labels = BTreeMap::new();
28051 labels.insert(LABEL_APLICACAO, "checkout".to_string());
28052 labels.insert(LABEL_PROGRAM, "cart".to_string());
28053 let sel = label_selector(labels);
28054 let m = sel.as_mapping().expect("mapping shape");
28055 assert_eq!(m.len(), 1);
28056 let inner = m
28057 .get(KUBE_KEY_MATCH_LABELS)
28058 .and_then(|v| v.as_mapping())
28059 .expect("matchLabels inner mapping");
28060 assert_eq!(inner.len(), 2);
28061 assert_eq!(
28062 inner.get(LABEL_APLICACAO).and_then(|x| x.as_str()),
28063 Some("checkout")
28064 );
28065 assert_eq!(
28066 inner.get(LABEL_PROGRAM).and_then(|x| x.as_str()),
28067 Some("cart")
28068 );
28069 }
28070
28071 #[test]
28072 fn label_selector_empty_input_yields_empty_match_labels() {
28073 // Empty input → `{matchLabels: {}}`. The outer wrapper is
28074 // present (the K8s LabelSelector schema requires it as a
28075 // structural anchor, and apiserver-side parsers that see a
28076 // bare `{}` selector match-everything; pinning the wrapper
28077 // means an empty pleme-io selector at the call site renders
28078 // as the canonical "no labels declared, match nothing
28079 // specific" shape rather than an outright missing key).
28080 let v: serde_yaml::Value = label_selector(BTreeMap::<&'static str, String>::new());
28081 let m = v.as_mapping().expect("mapping shape");
28082 assert_eq!(m.len(), 1);
28083 let inner = m
28084 .get(KUBE_KEY_MATCH_LABELS)
28085 .and_then(|v| v.as_mapping())
28086 .expect("matchLabels inner mapping");
28087 assert!(inner.is_empty());
28088 }
28089
28090 #[test]
28091 fn label_selector_accepts_pleme_selector_helpers() {
28092 // The lift's load-bearing use case: passing the typed pleme-io
28093 // selectors directly into `label_selector` yields the K8s
28094 // LabelSelector shape every Cilium / Gateway / future
28095 // app-operator selector field expects. Pinning end-to-end
28096 // composition so a future refactor of either helper can't
28097 // silently break the integration.
28098 let v = label_selector(pleme_program_in_aplicacao_selector("cart", "checkout"));
28099 let inner = v
28100 .as_mapping()
28101 .and_then(|m| m.get(KUBE_KEY_MATCH_LABELS))
28102 .and_then(|v| v.as_mapping())
28103 .expect("matchLabels inner mapping");
28104 assert_eq!(inner.len(), 2);
28105 assert_eq!(
28106 inner.get(LABEL_PROGRAM).and_then(|x| x.as_str()),
28107 Some("cart")
28108 );
28109 assert_eq!(
28110 inner.get(LABEL_APLICACAO).and_then(|x| x.as_str()),
28111 Some("checkout")
28112 );
28113
28114 // Single-axis variant — only LABEL_PROGRAM under matchLabels.
28115 let v = label_selector(pleme_program_selector("cart"));
28116 let inner = v
28117 .as_mapping()
28118 .and_then(|m| m.get(KUBE_KEY_MATCH_LABELS))
28119 .and_then(|v| v.as_mapping())
28120 .unwrap();
28121 assert_eq!(inner.len(), 1);
28122 assert_eq!(
28123 inner.get(LABEL_PROGRAM).and_then(|x| x.as_str()),
28124 Some("cart")
28125 );
28126 }
28127
28128 #[test]
28129 fn label_selector_inner_iterates_alphabetically_on_btreemap() {
28130 // BTreeMap input → alphabetical iteration → alphabetical YAML
28131 // key order under `matchLabels`. THEORY.md §V.2.7 render
28132 // determinism: the rendered YAML's matchLabels: block appears
28133 // in a deterministic order independent of source-code
28134 // declaration order.
28135 let mut input = BTreeMap::new();
28136 input.insert("zebra", "z".to_string());
28137 input.insert("apple", "a".to_string());
28138 input.insert("mango", "m".to_string());
28139 let v = label_selector(input);
28140 let inner = v
28141 .as_mapping()
28142 .and_then(|m| m.get(KUBE_KEY_MATCH_LABELS))
28143 .and_then(|v| v.as_mapping())
28144 .unwrap();
28145 let keys: Vec<&str> = inner.iter().filter_map(|(k, _)| k.as_str()).collect();
28146 assert_eq!(keys, vec!["apple", "mango", "zebra"]);
28147 }
28148
28149 #[test]
28150 fn label_selector_does_not_introduce_match_expressions_axis() {
28151 // V0 emits matchLabels only — pinning that the helper doesn't
28152 // pre-insert an empty `matchExpressions: []` block (which some
28153 // apiserver-side parsers tolerate but renders noisily and
28154 // shifts the per-rule diff). A future set-based selector
28155 // extension is a deliberate API change to this helper, not an
28156 // incidental shape leak.
28157 let v = label_selector(pleme_program_selector("cart"));
28158 let m = v.as_mapping().unwrap();
28159 assert!(
28160 m.get("matchExpressions").is_none(),
28161 "label_selector must not pre-insert a matchExpressions key (V0 is matchLabels-only)"
28162 );
28163 }
28164
28165 #[test]
28166 fn kube_resource_skeleton_carries_three_top_level_keys_no_spec() {
28167 // The skeleton emits exactly apiVersion + kind + metadata; the
28168 // caller adds spec (and any other top-level keys) themselves.
28169 // Pin that contract so a future caller doesn't accidentally
28170 // double-insert apiVersion / kind / metadata after the
28171 // skeleton call. Namespace fixture arg reads through the
28172 // canonical `DEFAULT_NAMESPACE` const so a future rebrand of
28173 // the substrate's default namespace reaches every fixture by
28174 // construction rather than through a per-fixture stray
28175 // "tatara-system" byte-sequence.
28176 let skel = kube_resource_skeleton(
28177 "cilium.io/v2",
28178 "CiliumNetworkPolicy",
28179 "p-1",
28180 DEFAULT_NAMESPACE,
28181 BTreeMap::new(),
28182 );
28183 assert_eq!(skel.len(), 3);
28184 assert_eq!(
28185 skel.get(KUBE_KEY_API_VERSION).and_then(|v| v.as_str()),
28186 Some("cilium.io/v2")
28187 );
28188 assert_eq!(
28189 skel.get(KUBE_KEY_KIND).and_then(|v| v.as_str()),
28190 Some("CiliumNetworkPolicy")
28191 );
28192 assert!(skel.get(KUBE_KEY_METADATA).is_some());
28193 }
28194
28195 #[test]
28196 fn kube_resource_skeleton_metadata_carries_name_and_namespace() {
28197 let skel = kube_resource_skeleton(
28198 "gateway.networking.k8s.io/v1",
28199 "Gateway",
28200 "checkout",
28201 DEFAULT_NAMESPACE,
28202 BTreeMap::new(),
28203 );
28204 let metadata = skel
28205 .get(KUBE_KEY_METADATA)
28206 .and_then(|v| v.as_mapping())
28207 .expect("metadata mapping");
28208 assert_eq!(
28209 metadata.get(KUBE_KEY_NAME).and_then(|v| v.as_str()),
28210 Some("checkout")
28211 );
28212 // Read-back probe reads through `DEFAULT_NAMESPACE` so a
28213 // future substrate-namespace rebrand routes through the
28214 // canonical const on both the emit-side fixture arg and the
28215 // probe-side readback in one edit — a drift on either side
28216 // would otherwise silently mask the round-trip pin.
28217 assert_eq!(
28218 metadata.get(KUBE_KEY_NAMESPACE).and_then(|v| v.as_str()),
28219 Some(DEFAULT_NAMESPACE)
28220 );
28221 }
28222
28223 #[test]
28224 fn kube_resource_skeleton_omits_labels_when_empty() {
28225 // Empty labels → metadata.labels key absent (NOT present-as-empty).
28226 // K8s API server treats a missing labels key as "no labels
28227 // declared"; an empty-mapping `labels: {}` serializes
28228 // differently in some YAML libraries and is a sharp tool for
28229 // label-based selectors that match the empty set silently.
28230 let skel = kube_resource_skeleton(
28231 "gateway.networking.k8s.io/v1",
28232 "HTTPRoute",
28233 "r-1",
28234 DEFAULT_NAMESPACE,
28235 BTreeMap::new(),
28236 );
28237 let metadata = skel
28238 .get(KUBE_KEY_METADATA)
28239 .and_then(|v| v.as_mapping())
28240 .unwrap();
28241 assert!(
28242 metadata.get(KUBE_KEY_LABELS).is_none(),
28243 "metadata.labels must be absent when no labels passed"
28244 );
28245 // metadata then has exactly 2 keys: name, namespace.
28246 assert_eq!(metadata.len(), 2);
28247 }
28248
28249 #[test]
28250 fn kube_resource_skeleton_includes_labels_when_present() {
28251 let mut labels = BTreeMap::new();
28252 labels.insert(LABEL_APLICACAO, "checkout".to_string());
28253 labels.insert(LABEL_CONTRATO, "cart-to-catalog".to_string());
28254 let skel = kube_resource_skeleton(
28255 "cilium.io/v2",
28256 "CiliumNetworkPolicy",
28257 "p-1",
28258 DEFAULT_NAMESPACE,
28259 labels,
28260 );
28261 let metadata = skel
28262 .get(KUBE_KEY_METADATA)
28263 .and_then(|v| v.as_mapping())
28264 .unwrap();
28265 let labels_block = metadata
28266 .get(KUBE_KEY_LABELS)
28267 .and_then(|v| v.as_mapping())
28268 .expect("metadata.labels mapping present");
28269 assert_eq!(
28270 labels_block.get(LABEL_APLICACAO).and_then(|v| v.as_str()),
28271 Some("checkout")
28272 );
28273 assert_eq!(
28274 labels_block.get(LABEL_CONTRATO).and_then(|v| v.as_str()),
28275 Some("cart-to-catalog")
28276 );
28277 }
28278
28279 #[test]
28280 fn kube_resource_skeleton_metadata_iterates_alphabetically() {
28281 // Pin that the inner BTreeMap projection makes the rendered
28282 // YAML's metadata: block alphabetical (labels, name, namespace),
28283 // regardless of insert order. THEORY.md §V.2.7 render determinism.
28284 let mut labels = BTreeMap::new();
28285 labels.insert(LABEL_APLICACAO, "checkout".to_string());
28286 let skel = kube_resource_skeleton(
28287 "cilium.io/v2",
28288 "CiliumNetworkPolicy",
28289 "p-1",
28290 DEFAULT_NAMESPACE,
28291 labels,
28292 );
28293 let metadata = skel
28294 .get(KUBE_KEY_METADATA)
28295 .and_then(|v| v.as_mapping())
28296 .unwrap();
28297 let keys: Vec<&str> = metadata.iter().filter_map(|(k, _)| k.as_str()).collect();
28298 assert_eq!(
28299 keys,
28300 vec![KUBE_KEY_LABELS, KUBE_KEY_NAME, KUBE_KEY_NAMESPACE]
28301 );
28302 }
28303
28304 #[test]
28305 fn kube_resource_skeleton_top_level_iterates_in_insert_order() {
28306 // The top-level Mapping is a plain serde_yaml::Mapping (insert-
28307 // ordered), and the skeleton inserts apiVersion → kind →
28308 // metadata in that order. Pin so a future refactor doesn't
28309 // silently shift the rendered YAML's top-level key order
28310 // (which K8s tooling tolerates but humans + diff readability
28311 // care about — apiVersion-first is the K8s convention).
28312 let skel = kube_resource_skeleton(
28313 "cilium.io/v2",
28314 "CiliumNetworkPolicy",
28315 "p-1",
28316 DEFAULT_NAMESPACE,
28317 BTreeMap::new(),
28318 );
28319 let keys: Vec<&str> = skel.iter().filter_map(|(k, _)| k.as_str()).collect();
28320 assert_eq!(
28321 keys,
28322 vec![KUBE_KEY_API_VERSION, KUBE_KEY_KIND, KUBE_KEY_METADATA]
28323 );
28324 }
28325
28326 #[test]
28327 fn kube_resource_skeleton_does_not_introduce_spec_key() {
28328 // Sanity: the skeleton is metadata-only — `spec` is the caller's
28329 // responsibility. Pinning so a future "be helpful" refactor
28330 // doesn't auto-insert an empty `spec: {}` (which would silently
28331 // shadow caller-side spec construction).
28332 let skel = kube_resource_skeleton(
28333 "cilium.io/v2",
28334 "CiliumNetworkPolicy",
28335 "p-1",
28336 DEFAULT_NAMESPACE,
28337 BTreeMap::new(),
28338 );
28339 assert!(
28340 skel.get("spec").is_none(),
28341 "skeleton must not pre-insert a spec key"
28342 );
28343 }
28344
28345 // ── require_kind / KindMismatch — typed kind-check predicate ─────
28346
28347 #[test]
28348 fn require_kind_accepts_matching_kind() {
28349 // A Servico-kind caixa passes a `require_kind(_, Servico)`
28350 // check — the happy path every renderer sees on a correctly-
28351 // authored caixa.lisp, surfaced as `Ok(())` so the renderer's
28352 // call site reads as a one-liner gate rather than a typed
28353 // pattern match.
28354 let c = bare_servico();
28355 require_kind(&c, CaixaKind::Servico).unwrap();
28356 }
28357
28358 #[test]
28359 fn require_kind_rejects_with_typed_mismatch() {
28360 // A Biblioteca-kind caixa fails a `require_kind(_, Servico)`
28361 // check with a typed [`KindMismatch`] view that names the
28362 // offending caixa's `:nome` plus both the expected and actual
28363 // kinds. Pinning the typed shape so a future Display-format
28364 // tweak can't silently drop any of the three load-bearing
28365 // fields (which would regress the "feira verb whose error
28366 // path doesn't name the offending caixa" punch-list item the
28367 // protocol calls out).
28368 let mut c = bare_servico();
28369 c.kind = CaixaKind::Biblioteca;
28370 c.servicos = vec![];
28371 let err = require_kind(&c, CaixaKind::Servico).unwrap_err();
28372 assert_eq!(err.nome, "hello-rio");
28373 assert_eq!(err.expected, CaixaKind::Servico);
28374 assert_eq!(err.actual, CaixaKind::Biblioteca);
28375 }
28376
28377 #[test]
28378 fn require_kind_routes_offending_nome_via_caixa_nome_accessor() {
28379 // Pin: the [`KindMismatch::nome`] `String` the constructor
28380 // writes must be a byte-identical copy of what the lifted
28381 // [`crate::Caixa::nome`] accessor returns for the same
28382 // [`Caixa`] input — the same discipline the sibling
28383 // [`crate::LayoutInvariants::verify`] wrap-envelope emitters
28384 // pin at 9842a4b's `expected_nome_via_accessor` line (the
28385 // routing pin the 31-site converge introduced on the substrate's
28386 // own layout-invariant verifier's per-axis diagnostic emitters).
28387 //
28388 // Guardrails a future regression that re-inlines the raw
28389 // `caixa.nome.clone()` `String::clone()` of the underlying
28390 // field at the constructor site — the accessor's borrow
28391 // return + typed `.to_string()` `String` promotion is the
28392 // one canonical shape the substrate's own [`KindMismatch`]
28393 // typed-view constructor carries onto every downstream
28394 // renderer's `Error::From<KindMismatch>` `#[from]` arm, so
28395 // any drift (a byte-non-identical shape, e.g. a future
28396 // `CaixaNome` newtype the [`crate::Caixa::nome`] accessor
28397 // upgrades to project the display byte-string of, that
28398 // `.nome.clone()` would silently ignore) surfaces here
28399 // before the drift lands on a per-renderer `#[from]` arm.
28400 let mut c = bare_servico();
28401 c.kind = CaixaKind::Biblioteca;
28402 c.servicos = vec![];
28403 c.nome = "kind-mismatch-pin".into();
28404 let expected_nome_via_accessor = c.nome().to_string();
28405 assert_eq!(
28406 expected_nome_via_accessor, "kind-mismatch-pin",
28407 "the mutated fixture's `:nome` must be observable through \
28408 the accessor before the kind-mismatch gate fires",
28409 );
28410 let err = require_kind(&c, CaixaKind::Servico).unwrap_err();
28411 assert_eq!(
28412 err.nome, expected_nome_via_accessor,
28413 "the KindMismatch's `nome` field must equal \
28414 `caixa.nome().to_string()` — the typed-view constructor \
28415 must route through the lifted [`Caixa::nome`] accessor's \
28416 `.to_string()` extension, not the raw `caixa.nome.clone()` \
28417 `String::clone()` of the underlying field",
28418 );
28419 }
28420
28421 #[test]
28422 fn kind_mismatch_display_names_offending_caixa_nome() {
28423 // The Display impl is the load-bearing surface every renderer's
28424 // `#[error("{0}")] NotAXKind(#[from] KindMismatch)` arm prints
28425 // through. Pinning the exact rendered form so a future format
28426 // change is a one-line edit + a one-line test update, not a
28427 // silent regression of the diagnostic clarity.
28428 let err = KindMismatch {
28429 nome: "checkout".into(),
28430 expected: CaixaKind::Aplicacao,
28431 actual: CaixaKind::Servico,
28432 };
28433 let msg = format!("{err}");
28434 assert!(
28435 msg.contains("checkout"),
28436 "Display must name the offending caixa nome (got: {msg:?})"
28437 );
28438 assert!(
28439 msg.contains("Aplicacao"),
28440 "Display must name the expected kind (got: {msg:?})"
28441 );
28442 assert!(
28443 msg.contains("Servico"),
28444 "Display must name the actual kind (got: {msg:?})"
28445 );
28446 }
28447
28448 #[test]
28449 fn require_kind_distinguishes_every_pair_of_kinds() {
28450 // Sanity: the predicate is kind-axis-agnostic — it works for
28451 // every kind / expected pair, not just Servico/Biblioteca.
28452 // Pinning that the caller can use `require_kind` for any of
28453 // the five typed kinds (Biblioteca, Binario, Servico,
28454 // Supervisor, Aplicacao) without a special-cased helper per
28455 // kind. Same idiom every per-target renderer key off.
28456 let mut c = bare_servico();
28457 c.kind = CaixaKind::Aplicacao;
28458 c.servicos = vec![];
28459 let err = require_kind(&c, CaixaKind::Supervisor).unwrap_err();
28460 assert_eq!(err.expected, CaixaKind::Supervisor);
28461 assert_eq!(err.actual, CaixaKind::Aplicacao);
28462 require_kind(&c, CaixaKind::Aplicacao).unwrap();
28463 }
28464
28465 // ── require_ci / MissingCiSlot — Acao `:ci`-slot-presence gate ────
28466
28467 fn bare_acao_without_ci() -> Caixa {
28468 let mut c = bare_servico();
28469 c.kind = CaixaKind::Acao;
28470 c.servicos = vec![];
28471 c.ci = None;
28472 c
28473 }
28474
28475 fn sample_ci_run() -> canteiro_types::CiRun {
28476 canteiro_types::CiRun {
28477 workspace: "pleme-io".into(),
28478 repo: "caixa".into(),
28479 nodes: vec![],
28480 }
28481 }
28482
28483 #[test]
28484 fn require_ci_accepts_present_slot_and_returns_borrowed_ci_run() {
28485 // The happy path: an Acao-kind caixa that declares its `:ci`
28486 // slot passes `require_ci`, and the borrowed
28487 // [`canteiro_types::CiRun`] projected through the successful
28488 // return is the same author-declared value the caller was about
28489 // to bind — folding the check and the bind onto one call site,
28490 // matching how every present + roadmapped per-`Acao` consumer
28491 // uses the slot.
28492 let mut c = bare_acao_without_ci();
28493 c.ci = Some(sample_ci_run());
28494 let ci = require_ci(&c).expect("Acao with declared :ci passes");
28495 assert_eq!(ci.workspace, "pleme-io");
28496 assert_eq!(ci.repo, "caixa");
28497 }
28498
28499 #[test]
28500 fn require_ci_rejects_absent_slot_with_typed_view() {
28501 // The fail-before-pass-after pin: pre-lift `caixa-actions`'
28502 // inline `.ok_or_else(|| Error::MissingCi { nome:
28503 // caixa.nome().to_string() })` gate constructed an
28504 // `Error::MissingCi { nome: String }` at exactly one crate's
28505 // call site with no compile-time link to any typed named-caixa
28506 // view the sibling per-renderer entry-gate axes carry. A future
28507 // per-`Acao` consumer (the deferred `sui-supercacheci::canteiro
28508 // ::emit_gha` workflow renderer named in the `caixa-actions`
28509 // crate docs, the future per-`Acao` CR materializer) would
28510 // re-inline the same `.ok_or_else(...)` construction on its own
28511 // call site and open a second untracked `nome: String`-carry
28512 // path — exactly the "feira verb whose error path doesn't name
28513 // the offending caixa" punch-list item the compounding-mandate
28514 // protocol calls out. Lifting the gate onto the typed
28515 // [`MissingCiSlot`] view + [`require_ci`] predicate closes the
28516 // drift potential structurally: every future per-`Acao`
28517 // consumer reaches for the same one-liner + `#[from]` and gets
28518 // the diagnostic-naming-the-offending-caixa contract for free.
28519 let c = bare_acao_without_ci();
28520 let err = require_ci(&c).unwrap_err();
28521 assert_eq!(err.nome, "hello-rio");
28522 }
28523
28524 #[test]
28525 fn require_ci_routes_offending_nome_via_caixa_nome_accessor() {
28526 // Pin: the [`MissingCiSlot::nome`] `String` the constructor
28527 // writes must be a byte-identical copy of what the lifted
28528 // [`crate::Caixa::nome`] accessor returns for the same
28529 // [`Caixa`] input — the same routing pin discipline the peer
28530 // [`require_kind`] / [`require_single_servico`] typed views
28531 // already carry, so a future regression that re-inlines a raw
28532 // `caixa.nome.clone()` `String::clone()` of the underlying
28533 // field at the constructor site (which would silently ignore
28534 // any future `CaixaNome` newtype the [`crate::Caixa::nome`]
28535 // accessor upgrades to project the display byte-string of)
28536 // trips here before the drift lands on a per-consumer `#[from]`
28537 // arm.
28538 let mut c = bare_acao_without_ci();
28539 c.nome = "missing-ci-pin".into();
28540 let expected_nome_via_accessor = c.nome().to_string();
28541 assert_eq!(
28542 expected_nome_via_accessor, "missing-ci-pin",
28543 "the mutated fixture's `:nome` must be observable through \
28544 the accessor before the `:ci` gate fires",
28545 );
28546 let err = require_ci(&c).unwrap_err();
28547 assert_eq!(
28548 err.nome, expected_nome_via_accessor,
28549 "the MissingCiSlot's `nome` field must equal \
28550 `caixa.nome().to_string()` — the typed-view constructor \
28551 must route through the lifted [`Caixa::nome`] accessor's \
28552 `.to_string()` extension, not the raw `caixa.nome.clone()` \
28553 `String::clone()` of the underlying field",
28554 );
28555 }
28556
28557 #[test]
28558 fn missing_ci_slot_display_names_offending_caixa_nome() {
28559 // The Display impl is the load-bearing surface every per-
28560 // `Acao` consumer's `#[error("{0}")] MissingCi(#[from]
28561 // MissingCiSlot)` arm prints through. Pinning the exact rendered
28562 // form so a future format change is a one-line edit + a one-line
28563 // test update, not a silent regression of the diagnostic
28564 // clarity. Same shape every peer per-axis lift carries.
28565 let err = MissingCiSlot {
28566 nome: "hello-acao".into(),
28567 };
28568 let msg = format!("{err}");
28569 assert!(
28570 msg.contains("hello-acao"),
28571 "Display must name the offending caixa nome (got: {msg:?})"
28572 );
28573 assert!(
28574 msg.contains(":ci"),
28575 "Display must name the missing `:ci` slot (got: {msg:?})"
28576 );
28577 }
28578
28579 // ── CiDecomposeFailure — per-`Acao` decompose-failure diagnostic axis ─
28580
28581 #[test]
28582 fn ci_decompose_failure_carries_offending_nome_and_source_verbatim() {
28583 // Fail-before-pass-after pin on the [`CiDecomposeFailure`] typed
28584 // view: the constructor writes the offending caixa's `:nome`
28585 // (routed through the lifted [`crate::Caixa::nome`] accessor's
28586 // `.to_string()` extension by every consumer) alongside the
28587 // borrowed [`canteiro_types::DecomposeError`] source verbatim,
28588 // so a per-`Acao` consumer that fans on the specific
28589 // decompose-failure arm reaches for `err.source` directly
28590 // rather than re-parsing the Display bytes. Peer of the sibling
28591 // [`MissingCiSlot`] typed view's `nome`-carrying pin — extends
28592 // the same "one typed view per axis, carrying the offending
28593 // caixa's `:nome` + axis-specific detail" discipline onto the
28594 // second per-`Acao` diagnostic axis after the presence-gate
28595 // axis.
28596 let err = CiDecomposeFailure {
28597 nome: "hello-acao".into(),
28598 source: canteiro_types::DecomposeError::Cycle,
28599 };
28600 assert_eq!(err.nome, "hello-acao");
28601 assert_eq!(err.source, canteiro_types::DecomposeError::Cycle);
28602 }
28603
28604 #[test]
28605 fn ci_decompose_failure_display_names_offending_caixa_nome_and_source() {
28606 // The Display impl is the load-bearing surface every per-`Acao`
28607 // consumer's `#[error("{0}")] Decompose(#[from]
28608 // CiDecomposeFailure)` arm prints through. Pinning the exact
28609 // rendered form so a future format change is a one-line edit +
28610 // a one-line test update, not a silent regression of the
28611 // diagnostic clarity — same shape every peer per-axis lift
28612 // carries.
28613 let err = CiDecomposeFailure {
28614 nome: "hello-acao".into(),
28615 source: canteiro_types::DecomposeError::Cycle,
28616 };
28617 let msg = format!("{err}");
28618 assert!(
28619 msg.contains("hello-acao"),
28620 "Display must name the offending caixa nome (got: {msg:?})"
28621 );
28622 assert!(
28623 msg.contains(":ci"),
28624 "Display must name the `:ci` slot the decompose failed on \
28625 (got: {msg:?})"
28626 );
28627 assert!(
28628 msg.contains("decompose"),
28629 "Display must name the decompose axis (got: {msg:?})"
28630 );
28631 }
28632
28633 #[test]
28634 fn ci_decompose_failure_exposes_source_via_error_trait() {
28635 // Pin: the [`CiDecomposeFailure`] type routes its
28636 // [`canteiro_types::DecomposeError`] carrier through the
28637 // `#[source]` [`thiserror::Error`] derive so downstream
28638 // `std::error::Error::source()`-consuming diagnostic frameworks
28639 // (`anyhow`'s chain formatter, `tracing`'s `error!` event
28640 // capture, the future `feira lint` sub-diagnostic emitter) see
28641 // the underlying `DecomposeError` arm through the standard
28642 // trait rather than only through the flattened Display bytes.
28643 // Peer of the sibling per-slot `#[source]` wiring the caixa-*
28644 // renderers already carry on their own typed-view error
28645 // wrappers.
28646 let err = CiDecomposeFailure {
28647 nome: "hello-acao".into(),
28648 source: canteiro_types::DecomposeError::Cycle,
28649 };
28650 let src = std::error::Error::source(&err)
28651 .expect("CiDecomposeFailure must expose its DecomposeError via Error::source()");
28652 // The `Error::source()` trait method returns a `&dyn Error`
28653 // borrow of the underlying `DecomposeError`, so its Display
28654 // bytes must equal the source arm's own Display bytes — a
28655 // future accidental collapse of the `#[source]` wiring (which
28656 // would erase the source chain and force downstream
28657 // `anyhow::Chain` consumers back onto Display re-parsing) trips
28658 // here at caixa-core build time.
28659 let src_msg = format!("{src}");
28660 let expected_msg = format!("{}", canteiro_types::DecomposeError::Cycle);
28661 assert_eq!(src_msg, expected_msg);
28662 }
28663
28664 // ── decompose_ci — per-`Acao` decompose-axis predicate ────────────
28665
28666 fn cyclic_ci_run() -> canteiro_types::CiRun {
28667 // A minimal two-node cycle: `a` depends on `b`, `b` depends on
28668 // `a`. Every failure mode `canteiro_types::decompose` refuses
28669 // (duplicate node name, missing dependency, cycle) would work as
28670 // a fixture; the cycle arm is the same one the `caixa-actions`
28671 // per-`Acao` renderer's own `validate_rejects_a_cyclic_ci_run`
28672 // test already reads for, so both the substrate primitive's own
28673 // pin and the consumer's byte-parity pin share one canonical
28674 // fixture shape.
28675 canteiro_types::CiRun {
28676 workspace: "pleme-io".into(),
28677 repo: "caixa".into(),
28678 nodes: vec![
28679 canteiro_types::CiNode::new(
28680 "a",
28681 canteiro_types::EnvClass::None,
28682 canteiro_types::ActionRef {
28683 name: "a".into(),
28684 command: "true".into(),
28685 args: vec![],
28686 },
28687 vec!["b".into()],
28688 ),
28689 canteiro_types::CiNode::new(
28690 "b",
28691 canteiro_types::EnvClass::None,
28692 canteiro_types::ActionRef {
28693 name: "b".into(),
28694 command: "true".into(),
28695 args: vec![],
28696 },
28697 vec!["a".into()],
28698 ),
28699 ],
28700 }
28701 }
28702
28703 fn linear_ci_run() -> canteiro_types::CiRun {
28704 // A minimal two-node acyclic run: `test` depends on `build`.
28705 // Same shape as the `caixa-actions` `validate_decomposes_a_two_
28706 // node_build_then_test_run` happy-path test — one shared
28707 // canonical fixture for every downstream substrate consumer.
28708 canteiro_types::CiRun {
28709 workspace: "pleme-io".into(),
28710 repo: "caixa".into(),
28711 nodes: vec![
28712 canteiro_types::CiNode::new(
28713 "build",
28714 canteiro_types::EnvClass::None,
28715 canteiro_types::ActionRef {
28716 name: "build".into(),
28717 command: "true".into(),
28718 args: vec![],
28719 },
28720 vec![],
28721 ),
28722 canteiro_types::CiNode::new(
28723 "test",
28724 canteiro_types::EnvClass::None,
28725 canteiro_types::ActionRef {
28726 name: "test".into(),
28727 command: "true".into(),
28728 args: vec![],
28729 },
28730 vec!["build".into()],
28731 ),
28732 ],
28733 }
28734 }
28735
28736 #[test]
28737 fn decompose_ci_accepts_valid_ci_run_and_returns_canteiro_dag() {
28738 // The happy path: a valid two-node acyclic run decomposes
28739 // cleanly through `decompose_ci`, returning the owned
28740 // `canteiro_types::CanteiroDag` the sibling `canteiro_types::
28741 // decompose` returns — the substrate primitive is a
28742 // pass-through on success, only wrapping the error arm in a
28743 // typed named-caixa view. Matches the peer `require_ci`
28744 // presence-axis happy path (accept-with-borrowed-CiRun) —
28745 // extends the "one primitive per axis, pass-through on success"
28746 // discipline onto the decompose axis.
28747 let c = bare_acao_without_ci();
28748 let ci = linear_ci_run();
28749 let cd = decompose_ci(&c, &ci).expect("valid acyclic CiRun decomposes cleanly");
28750 // The topo_order() call on a successful decompose is infallible
28751 // by construction (no cycles present), so a downstream consumer
28752 // reaches for the DAG's own algebra directly rather than a
28753 // second gate. Iterating the returned order (rather than
28754 // asserting on a concrete container shape) keeps the pin
28755 // agnostic to whether topo_order returns Vec<NodeId>,
28756 // SmallVec<NodeId>, or any future returned collection.
28757 let topo = cd
28758 .topo_order()
28759 .expect("acyclic CanteiroDag returns a valid topo_order");
28760 assert_eq!(
28761 topo.iter().count(),
28762 2,
28763 "topo_order on a two-node acyclic run must yield two node ids"
28764 );
28765 }
28766
28767 #[test]
28768 fn decompose_ci_rejects_cyclic_ci_run_with_typed_view() {
28769 // The fail-before-pass-after pin: pre-lift `caixa-actions`'
28770 // inline `.map_err(|source| CiDecomposeFailure { nome: nome
28771 // .clone(), source })` gate constructed a `CiDecomposeFailure`
28772 // at exactly one crate's call site with no compile-time link to
28773 // any typed named-caixa predicate the sibling per-`Acao` /
28774 // per-renderer entry-gate axes carry. A future per-`Acao`
28775 // consumer (the deferred `sui-supercacheci::canteiro::emit_gha`
28776 // workflow renderer named in the `caixa-actions` crate docs, a
28777 // future per-`Acao` CR materializer's admission webhook) would
28778 // re-inline the same `.map_err(...)` construction on its own
28779 // call site and open a second untracked
28780 // `caixa.nome().to_string()` re-projection path — exactly the
28781 // "feira verb whose error path doesn't name the offending
28782 // caixa" punch-list item the compounding-mandate protocol calls
28783 // out. Lifting the gate onto the typed `decompose_ci` predicate
28784 // closes the drift potential structurally: every future
28785 // per-`Acao` consumer reaches for the same one-liner + `#[from]`
28786 // and gets the diagnostic-naming-the-offending-caixa contract
28787 // for free.
28788 let c = bare_acao_without_ci();
28789 let ci = cyclic_ci_run();
28790 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
28791 // `canteiro_types::CanteiroDag`, which does not derive it at the
28792 // pinned sui rev — so the whole caixa-core test target failed to
28793 // COMPILE. A let-else says the same thing without borrowing a
28794 // bound from a foreign type we do not own.
28795 let Err(err) = decompose_ci(&c, &ci) else {
28796 panic!("a cyclic CiRun must fail decompose_ci");
28797 };
28798 assert_eq!(err.nome, "hello-rio");
28799 assert_eq!(err.source, canteiro_types::DecomposeError::Cycle);
28800 }
28801
28802 #[test]
28803 fn decompose_ci_routes_offending_nome_via_caixa_nome_accessor() {
28804 // Pin: the `CiDecomposeFailure::nome` `String` the constructor
28805 // writes must be a byte-identical copy of what the lifted
28806 // `crate::Caixa::nome` accessor returns for the same `Caixa`
28807 // input — the same routing pin discipline the peer
28808 // `require_kind` / `require_single_servico` / `require_ci`
28809 // typed views already carry, so a future regression that
28810 // re-inlines a raw `caixa.nome.clone()` `String::clone()` of
28811 // the underlying field at the constructor site (which would
28812 // silently ignore any future `CaixaNome` newtype the
28813 // `crate::Caixa::nome` accessor upgrades to project the display
28814 // byte-string of) trips here before the drift lands on a
28815 // per-consumer `#[from]` arm.
28816 let mut c = bare_acao_without_ci();
28817 c.nome = "decompose-ci-pin".into();
28818 let expected_nome_via_accessor = c.nome().to_string();
28819 assert_eq!(
28820 expected_nome_via_accessor, "decompose-ci-pin",
28821 "the mutated fixture's `:nome` must be observable through \
28822 the accessor before the decompose gate fires",
28823 );
28824 let ci = cyclic_ci_run();
28825 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
28826 // `canteiro_types::CanteiroDag`, which does not derive it at the
28827 // pinned sui rev — so the whole caixa-core test target failed to
28828 // COMPILE. A let-else says the same thing without borrowing a
28829 // bound from a foreign type we do not own.
28830 let Err(err) = decompose_ci(&c, &ci) else {
28831 panic!("a cyclic CiRun must fail decompose_ci");
28832 };
28833 assert_eq!(
28834 err.nome, expected_nome_via_accessor,
28835 "the CiDecomposeFailure's `nome` field must equal \
28836 `caixa.nome().to_string()` — the `decompose_ci` predicate \
28837 must route through the lifted `Caixa::nome` accessor's \
28838 `.to_string()` extension, not a raw `caixa.nome.clone()` \
28839 `String::clone()` of the underlying field",
28840 );
28841 }
28842
28843 // ── ci_declared_edge_count — per-`Acao` declared-edge-count axis ─
28844
28845 #[test]
28846 fn ci_declared_edge_count_returns_zero_for_leaf_only_run() {
28847 // The empty-edges arm: a `CiRun` whose every node carries an
28848 // empty `deps` list has zero declared edges. Pins the
28849 // `usize::sum()` accumulator's starting value on the
28850 // no-fan-out shape a `caixa-init`-scaffolded `:kind Acao` a
28851 // caixa's stub `:ci` slot lands as before the author wires
28852 // any `deps`. Fail-before-pass-after guard: pre-lift there was
28853 // no substrate primitive, so an author-scaffolded no-deps run
28854 // would have had its `edge_count = 0` re-derived at every
28855 // consumer site through the same open-coded arithmetic. This
28856 // test now anchors the projection to `ci_declared_edge_count`.
28857 let ci = canteiro_types::CiRun {
28858 workspace: "pleme-io".into(),
28859 repo: "caixa".into(),
28860 nodes: vec![
28861 canteiro_types::CiNode::new(
28862 "build",
28863 canteiro_types::EnvClass::None,
28864 canteiro_types::ActionRef {
28865 name: "build".into(),
28866 command: "true".into(),
28867 args: vec![],
28868 },
28869 vec![],
28870 ),
28871 canteiro_types::CiNode::new(
28872 "lint",
28873 canteiro_types::EnvClass::None,
28874 canteiro_types::ActionRef {
28875 name: "lint".into(),
28876 command: "true".into(),
28877 args: vec![],
28878 },
28879 vec![],
28880 ),
28881 ],
28882 };
28883 assert_eq!(
28884 ci_declared_edge_count(&ci),
28885 0,
28886 "a two-leaf-node `:ci` run with empty `deps` lists carries \
28887 zero declared edges — the substrate primitive's `usize` \
28888 accumulator must start at zero and pass through untouched",
28889 );
28890 }
28891
28892 #[test]
28893 fn ci_declared_edge_count_returns_deps_sum_across_nodes() {
28894 // The multi-arity arm: a `CiRun` whose nodes carry `deps`
28895 // lists of arities 0/1/2 has declared-edge-count 3 (0+1+2).
28896 // Pins that the substrate primitive routes the sum through
28897 // *every* node's `deps.len()` rather than only the first
28898 // node's (a future regression that collapsed the `map(...)`
28899 // + `sum()` fold onto a `first()` / `next()` shape would
28900 // silently under-count the declared edges — the arity-3
28901 // fixture surfaces it here before the drift lands on the
28902 // `caixa-actions::validate` production `edge_count` artifact).
28903 let ci = canteiro_types::CiRun {
28904 workspace: "pleme-io".into(),
28905 repo: "caixa".into(),
28906 nodes: vec![
28907 canteiro_types::CiNode::new(
28908 "build",
28909 canteiro_types::EnvClass::None,
28910 canteiro_types::ActionRef {
28911 name: "build".into(),
28912 command: "true".into(),
28913 args: vec![],
28914 },
28915 vec![],
28916 ),
28917 canteiro_types::CiNode::new(
28918 "test",
28919 canteiro_types::EnvClass::None,
28920 canteiro_types::ActionRef {
28921 name: "test".into(),
28922 command: "true".into(),
28923 args: vec![],
28924 },
28925 vec!["build".into()],
28926 ),
28927 canteiro_types::CiNode::new(
28928 "publish",
28929 canteiro_types::EnvClass::None,
28930 canteiro_types::ActionRef {
28931 name: "publish".into(),
28932 command: "true".into(),
28933 args: vec![],
28934 },
28935 vec!["build".into(), "test".into()],
28936 ),
28937 ],
28938 };
28939 assert_eq!(
28940 ci_declared_edge_count(&ci),
28941 3,
28942 "declared-edge-count on a 0/1/2-arity node list is the sum \
28943 (0 + 1 + 2 = 3) — the primitive must fold over every node, \
28944 not just the first / last / any-single-index shape",
28945 );
28946 }
28947
28948 #[test]
28949 fn ci_declared_edge_count_counts_edges_before_decompose_gate() {
28950 // The count-is-shape-only arm: an author-declared *cyclic*
28951 // `:ci` run — the exact fixture `decompose_ci` refuses at the
28952 // sibling axis — still carries its declared edge count as a
28953 // property of the *borrowed run's shape*, not of the owned
28954 // `CanteiroDag` `decompose_ci` (would have) returned. Pins
28955 // that a future consumer that wants the declared-edge summary
28956 // *before* running `decompose_ci` (a `feira lint --acao`
28957 // per-caixa pre-flight report that names the declared edge
28958 // count on both accept + reject arms of the sibling
28959 // `decompose_ci` gate) reads a stable count on both arms.
28960 // The two-node cycle `a → b → a` from `cyclic_ci_run()`
28961 // carries exactly 2 declared edges (one per node's singleton
28962 // `deps`), so the primitive returns 2 without ever routing
28963 // through `canteiro_types::decompose`.
28964 let ci = cyclic_ci_run();
28965 assert_eq!(
28966 ci_declared_edge_count(&ci),
28967 2,
28968 "the two-node cycle carries 2 declared `deps` edges (one \
28969 per node's singleton `deps`) — the primitive must read the \
28970 count off the borrowed run's node-list shape, not off the \
28971 `decompose_ci`-produced `CanteiroDag`'s edge algebra",
28972 );
28973 }
28974
28975 #[test]
28976 fn ci_declared_edge_count_matches_open_coded_sum_across_shapes() {
28977 // Byte-parity pin — the three-path convergence discipline
28978 // every peer per-`Acao` substrate primitive carries: the
28979 // primitive's return must equal the open-coded
28980 // `ci.nodes.iter().map(|n| n.deps.len()).sum::<usize>()`
28981 // expression at each of the three canonical `:ci` run shapes
28982 // this test module already carries (`linear_ci_run` — the
28983 // canonical happy-path with one edge, `cyclic_ci_run` — the
28984 // canonical rejected-by-`decompose_ci` shape with two edges,
28985 // and the empty-edges no-fan-out shape the peer
28986 // `ci_declared_edge_count_returns_zero_for_leaf_only_run`
28987 // fixture reads). Any future refactor of the primitive's fold
28988 // shape trips here before landing on the consumer's
28989 // `RenderedAcao::edge_count` artifact.
28990 for (label, ci) in [
28991 ("linear-two-node", linear_ci_run()),
28992 ("cyclic-two-node", cyclic_ci_run()),
28993 ] {
28994 let via_primitive = ci_declared_edge_count(&ci);
28995 let via_open_coded: usize = ci.nodes.iter().map(|n| n.deps.len()).sum();
28996 assert_eq!(
28997 via_primitive, via_open_coded,
28998 "{label}: `ci_declared_edge_count` must equal the \
28999 open-coded `.nodes.iter().map(|n| n.deps.len()).sum()` \
29000 the two prior `caixa-actions` open-coded sites carried \
29001 — pre-lift regression check",
29002 );
29003 }
29004 }
29005
29006 // ── require_single_servico / ServicoCountMismatch — V0 Servico-shape ─
29007
29008 #[test]
29009 fn require_single_servico_accepts_singleton_list() {
29010 // The happy path: the canonical V0 Servico carries exactly one
29011 // `:servicos` entry (the ComputeUnit YAML pointer), the same
29012 // shape every in-tree fixture + canonical example uses. Surfaced
29013 // as `Ok(())` so the renderer's call site reads as a one-liner
29014 // gate beside the peer [`require_kind`] check rather than a
29015 // typed pattern match.
29016 let c = bare_servico();
29017 assert_eq!(
29018 c.servicos.len(),
29019 1,
29020 "fixture pin: bare_servico() is singleton"
29021 );
29022 require_single_servico(&c).unwrap();
29023 }
29024
29025 #[test]
29026 fn require_single_servico_rejects_empty_list_with_typed_mismatch() {
29027 // A Servico-kind caixa with zero `:servicos` entries fails
29028 // `require_single_servico` with a typed [`ServicoCountMismatch`]
29029 // view that names the offending caixa's `:nome` + the actual
29030 // count (0). Pinning the typed shape so a future Display-format
29031 // tweak can't silently drop either of the two load-bearing
29032 // fields (which would regress the "feira verb whose error path
29033 // doesn't name the offending caixa" punch-list item the protocol
29034 // calls out — same shape every peer per-axis lift carries).
29035 let mut c = bare_servico();
29036 c.servicos = vec![];
29037 let err = require_single_servico(&c).unwrap_err();
29038 assert_eq!(err.nome, "hello-rio");
29039 assert_eq!(err.count, 0);
29040 }
29041
29042 #[test]
29043 fn require_single_servico_rejects_multi_entry_list_with_typed_mismatch() {
29044 // The peer arm on the upper-bound axis: a Servico-kind caixa
29045 // with ≥ 2 `:servicos` entries fails the same gate, with the
29046 // typed view carrying the actual count (2). Both empty and
29047 // multi-entry lists land on the same [`ServicoCountMismatch`]
29048 // arm — the V0 contract requires *exactly* one entry, not
29049 // *at-least* one — so the single helper closes both directions
29050 // of the V0 invariant in one call site.
29051 let mut c = bare_servico();
29052 c.servicos = vec![
29053 "servicos/hello-rio.computeunit.yaml".into(),
29054 "servicos/extra.computeunit.yaml".into(),
29055 ];
29056 let err = require_single_servico(&c).unwrap_err();
29057 assert_eq!(err.nome, "hello-rio");
29058 assert_eq!(err.count, 2);
29059 }
29060
29061 #[test]
29062 fn require_single_servico_routes_offending_nome_via_caixa_nome_accessor() {
29063 // Peer to the sibling
29064 // [`require_kind_routes_offending_nome_via_caixa_nome_accessor`]
29065 // pin on the V0 Servico-shape gate's `:nome`-carry axis:
29066 // the [`ServicoCountMismatch::nome`] `String` the constructor
29067 // writes must be a byte-identical copy of what the lifted
29068 // [`crate::Caixa::nome`] accessor returns. Same 9842a4b-shaped
29069 // routing pin the substrate's own [`crate::LayoutInvariants::verify`]
29070 // wrap-envelope emitters carry, extended here to the second of
29071 // the two [`crate::render`]-module typed-view constructor sites
29072 // that carried a raw `caixa.nome.clone()` `String::clone()`
29073 // field access at the pre-converge state.
29074 let mut c = bare_servico();
29075 c.servicos = vec![];
29076 c.nome = "servico-count-pin".into();
29077 let expected_nome_via_accessor = c.nome().to_string();
29078 assert_eq!(
29079 expected_nome_via_accessor, "servico-count-pin",
29080 "the mutated fixture's `:nome` must be observable through \
29081 the accessor before the servico-count gate fires",
29082 );
29083 let err = require_single_servico(&c).unwrap_err();
29084 assert_eq!(
29085 err.nome, expected_nome_via_accessor,
29086 "the ServicoCountMismatch's `nome` field must equal \
29087 `caixa.nome().to_string()` — the typed-view constructor \
29088 must route through the lifted [`Caixa::nome`] accessor's \
29089 `.to_string()` extension, not the raw `caixa.nome.clone()` \
29090 `String::clone()` of the underlying field",
29091 );
29092 }
29093
29094 #[test]
29095 fn servico_count_mismatch_display_names_offending_caixa_nome() {
29096 // The Display impl is the load-bearing surface every renderer's
29097 // `#[error("{0}")] UnsupportedServicoCount(#[from]
29098 // ServicoCountMismatch)` arm prints through. Pinning the exact
29099 // rendered form so a future format change is a one-line edit +
29100 // a one-line test update, not a silent regression of the
29101 // diagnostic clarity that motivated the lift (the prior
29102 // per-renderer `UnsupportedServicoCount(usize)` arm named only
29103 // the count). Same shape every peer [`KindMismatch`] / typed-
29104 // view Display tests pin.
29105 let err = ServicoCountMismatch {
29106 nome: "checkout".into(),
29107 count: 3,
29108 };
29109 let msg = format!("{err}");
29110 assert!(
29111 msg.contains("checkout"),
29112 "Display must name the offending caixa nome (got: {msg:?})"
29113 );
29114 assert!(
29115 msg.contains('3'),
29116 "Display must name the actual count (got: {msg:?})"
29117 );
29118 assert!(
29119 msg.contains(":servicos"),
29120 "Display must name the offending field axis (got: {msg:?})"
29121 );
29122 assert!(
29123 msg.contains("exactly one"),
29124 "Display must name the V0 invariant (got: {msg:?})"
29125 );
29126 }
29127
29128 #[test]
29129 fn overlay_kind_agnostic_for_field_projection() {
29130 // The helper projects fields, not kind — every Caixa carries
29131 // the M2 slot fields by construction. Renderer-level kind
29132 // gates (NotAServico in caixa-helm / caixa-flux) are the
29133 // shape filter; this helper is the field projector. Keeping
29134 // them separate means the same overlay can apply to any
29135 // future per-kind renderer (e.g. when M2.4 supervisor
29136 // rendering acquires its own M2-shaped overlay path).
29137 let mut c = bare_servico();
29138 c.kind = CaixaKind::Biblioteca;
29139 c.servicos = vec![];
29140 c.limits = Some(LimitsSpec {
29141 memory: Some(crate::LIMITS_MEMORY_WASM32_PAGE_BYTES),
29142 ..Default::default()
29143 });
29144 let overlay = servico_m2_overlay(&c).unwrap();
29145 assert!(overlay.contains_key(M2_KEY_LIMITS));
29146 }
29147
29148 // ── require_v0_servico_shape — compound V0-shape entry gate ──────
29149
29150 /// Local `thiserror`-shaped renderer-error stand-in that mirrors the
29151 /// three production callers' shape (`caixa-flux::Error`,
29152 /// `caixa-helm::Error`) at the two `#[from]` variants the compound
29153 /// helper's `E: From<KindMismatch> + From<ServicoCountMismatch>`
29154 /// bound targets. Pinning the shape here so the compound helper's
29155 /// type-inference contract is unit-testable inside caixa-core
29156 /// without a workspace-crate dependency (which would bloat the
29157 /// build graph).
29158 #[derive(Debug, thiserror::Error)]
29159 enum RendererStandIn {
29160 #[error("{0}")]
29161 NotAServico(#[from] KindMismatch),
29162 #[error("{0}")]
29163 UnsupportedServicoCount(#[from] ServicoCountMismatch),
29164 }
29165
29166 #[test]
29167 fn require_v0_servico_shape_accepts_v0_servico() {
29168 // Happy path: a `:kind Servico` caixa with exactly one
29169 // `:servicos` entry — the canonical V0 shape every per-Servico
29170 // renderer's entry-point sees — passes the compound gate. Same
29171 // outcome as the two-line pair the compound helper replaces:
29172 // both predicates surface `Ok(())`, and the compound helper's
29173 // return type carries the caller's `E` inferred from the `?`
29174 // context (unit test uses [`RendererStandIn`] as the stand-in
29175 // for `caixa-flux::Error` / `caixa-helm::Error`).
29176 let c = bare_servico();
29177 let r: Result<(), RendererStandIn> = require_v0_servico_shape(&c);
29178 r.expect("v0 servico shape accepted");
29179 }
29180
29181 #[test]
29182 fn require_v0_servico_shape_forwards_kind_mismatch_first() {
29183 // Order pin: the kind gate fires before the count gate, so a
29184 // `:kind Biblioteca` caixa with zero `:servicos` entries
29185 // surfaces the [`KindMismatch`] arm (the more actionable
29186 // diagnostic — the author has the wrong `:kind`), not the
29187 // [`ServicoCountMismatch`] arm (a downstream consequence of
29188 // the mis-kinded input). Both invariants are violated on this
29189 // input, so the ordering matters — reversing it would flip
29190 // every current caller's diagnostic on a mis-kinded input.
29191 let mut c = bare_servico();
29192 c.kind = CaixaKind::Biblioteca;
29193 c.servicos = vec![];
29194 let err: RendererStandIn = require_v0_servico_shape(&c).unwrap_err();
29195 match err {
29196 RendererStandIn::NotAServico(k) => {
29197 assert_eq!(k.nome, "hello-rio");
29198 assert_eq!(k.expected, CaixaKind::Servico);
29199 assert_eq!(k.actual, CaixaKind::Biblioteca);
29200 }
29201 RendererStandIn::UnsupportedServicoCount(_) => {
29202 panic!("kind gate must fire before count gate on mis-kinded input")
29203 }
29204 }
29205 }
29206
29207 #[test]
29208 fn require_v0_servico_shape_forwards_count_mismatch_on_kind_match() {
29209 // A `:kind Servico` caixa with the wrong `:servicos` count
29210 // (empty or multi-entry) passes the kind gate and lands on the
29211 // [`ServicoCountMismatch`] arm — the same typed view every
29212 // per-renderer `#[from] ServicoCountMismatch` arm already
29213 // surfaces at the two-line pair this helper replaces. Both
29214 // directions of the V0 count invariant (empty AND ≥ 2) land on
29215 // the same arm — pinning the multi-entry direction here; the
29216 // empty direction is covered by the peer
29217 // `require_single_servico_rejects_empty_list_with_typed_mismatch`
29218 // test on the single-axis primitive.
29219 let mut c = bare_servico();
29220 c.servicos = vec![
29221 "servicos/hello-rio.computeunit.yaml".into(),
29222 "servicos/extra.computeunit.yaml".into(),
29223 ];
29224 let err: RendererStandIn = require_v0_servico_shape(&c).unwrap_err();
29225 match err {
29226 RendererStandIn::UnsupportedServicoCount(c) => {
29227 assert_eq!(c.nome, "hello-rio");
29228 assert_eq!(c.count, 2);
29229 }
29230 RendererStandIn::NotAServico(_) => {
29231 panic!("count gate must fire when kind gate passes")
29232 }
29233 }
29234 }
29235
29236 #[test]
29237 fn require_v0_servico_shape_matches_two_line_pair_semantic() {
29238 // Equivalence pin: on every input, the compound helper's
29239 // Ok/Err discrimination matches the two-line pair verbatim —
29240 // the lift is a behavioral no-op at the caller boundary. Peer
29241 // to the sibling `entry_or_default_<variant>` equivalence
29242 // tests that pin the lifted primitive against the inline
29243 // block it replaces.
29244 //
29245 // Three axes covered: V0 shape (Ok/Ok), kind gate fires
29246 // (Err/Ok on the two-line pair — pair short-circuits at the
29247 // kind gate), count gate fires (Ok/Err on the two-line pair —
29248 // pair reaches the count gate).
29249 let cases: Vec<(CaixaKind, Vec<String>)> = vec![
29250 (CaixaKind::Servico, vec!["servicos/x.yaml".into()]),
29251 (CaixaKind::Biblioteca, vec![]),
29252 (CaixaKind::Servico, vec![]),
29253 (CaixaKind::Aplicacao, vec!["servicos/x.yaml".into()]),
29254 (
29255 CaixaKind::Servico,
29256 vec!["servicos/a.yaml".into(), "servicos/b.yaml".into()],
29257 ),
29258 ];
29259 for (kind, servicos) in cases {
29260 let mut c = bare_servico();
29261 c.kind = kind;
29262 c.servicos = servicos;
29263 let pair: Result<(), RendererStandIn> = (|| {
29264 require_kind(&c, CaixaKind::Servico)?;
29265 require_single_servico(&c)?;
29266 Ok(())
29267 })();
29268 let compound: Result<(), RendererStandIn> = require_v0_servico_shape(&c);
29269 assert_eq!(
29270 pair.is_ok(),
29271 compound.is_ok(),
29272 "compound helper must match two-line pair on kind={kind:?} servicos.len()={}",
29273 c.servicos.len(),
29274 );
29275 }
29276 }
29277
29278 // ── require_aplicacao_view — compound per-Aplicacao entry gate ───
29279
29280 /// Local `thiserror`-shaped renderer-error stand-in that mirrors
29281 /// `caixa-mesh::Error`'s two `#[from]` arms at the compound
29282 /// helper's `E: From<KindMismatch> + From<AplicacaoError>` bound.
29283 /// Same discipline as the sibling [`RendererStandIn`] stand-in on
29284 /// the peer per-Servico [`require_v0_servico_shape`] gate: pins
29285 /// the compound helper's type-inference contract inside caixa-core
29286 /// without a workspace-crate dependency (which would bloat the
29287 /// build graph).
29288 #[derive(Debug, thiserror::Error)]
29289 enum AplicacaoRendererStandIn {
29290 #[error("{0}")]
29291 NotAnAplicacao(#[from] KindMismatch),
29292 #[error("{0}")]
29293 InvalidAplicacao(#[from] crate::aplicacao::AplicacaoError),
29294 }
29295
29296 fn bare_aplicacao() -> Caixa {
29297 let mut c = bare_servico();
29298 c.nome = "checkout".into();
29299 c.kind = CaixaKind::Aplicacao;
29300 c.servicos = vec![];
29301 c.membros = vec![
29302 crate::aplicacao::Membro {
29303 caixa: "cart".into(),
29304 versao: "^0.1".into(),
29305 },
29306 crate::aplicacao::Membro {
29307 caixa: "catalog".into(),
29308 versao: "^0.1".into(),
29309 },
29310 ];
29311 // `:placement` needs at least one named cluster (every strategy
29312 // uses the list as a hosting/takeover/shard pool per
29313 // MESH-COMPOSITION §II.1/§II.4); the fold-through
29314 // [`Caixa::aplicacao_view`] uses `Placement::default()` which
29315 // carries an empty `:clusters` and would trip
29316 // `AplicacaoError::PlacementWithoutClusters` at
29317 // `AplicacaoSpec::validate` — the peer per-Aplicacao
29318 // renderer fixtures (`caixa-mesh::aplicacao_caixa`) pin the
29319 // same non-empty `:clusters` shape.
29320 c.placement = Some(crate::aplicacao::Placement {
29321 estrategia: crate::aplicacao::PlacementStrategy::SingleNode,
29322 clusters: vec!["default".into()],
29323 affinity: None,
29324 shard_key: None,
29325 });
29326 c
29327 }
29328
29329 #[test]
29330 fn require_aplicacao_view_accepts_valid_aplicacao() {
29331 // Happy path: a `:kind Aplicacao` caixa with a well-formed
29332 // `:membros` stanza — the canonical V0 shape every
29333 // per-Aplicacao renderer's entry-point sees — passes the
29334 // compound three-arm gate and returns a validated
29335 // [`AplicacaoSpec`]. Same outcome as the three-line cascade
29336 // the compound helper replaces: [`require_kind`] passes,
29337 // [`Caixa::aplicacao_view`] returns `Some(spec)`, and
29338 // [`AplicacaoSpec::validate`] passes. Peer to
29339 // `require_v0_servico_shape_accepts_v0_servico` on the
29340 // sibling per-Servico compound gate.
29341 let c = bare_aplicacao();
29342 let spec: crate::aplicacao::AplicacaoSpec =
29343 require_aplicacao_view::<AplicacaoRendererStandIn>(&c)
29344 .expect("valid aplicacao shape accepted");
29345 // Route the per-Aplicacao `:membros` slice-projection through
29346 // the substrate-canonical [`AplicacaoSpec::membros`] `&[Membro]`-
29347 // return accessor rather than the raw `spec.membros` `Vec<Membro>`
29348 // field access, and the per-member `:caixa` scalar-projection
29349 // through the sibling [`crate::aplicacao::Membro::nome`] `&str`-
29350 // return accessor rather than the raw `.caixa` `String`-field
29351 // borrow, so a future rebrand of either storage (a per-cluster
29352 // `:membros`-overlay the caixa-operator reconciles ahead of
29353 // dispatch, an M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR
29354 // materializer's per-member alias table, a promotion of the
29355 // per-`Membro` `caixa: String` slot to a typed `ServicoName`
29356 // newtype the accessor materializes behind the same `&str`
29357 // return contract) reaches this per-fixture happy-path
29358 // acceptance-shape probe through the one accessor edit at the
29359 // canonical caixa-core declaration rather than a coordinated
29360 // rewrite that would include this render-side test-fixture
29361 // navigation too. Peer to the sibling caixa-flux
29362 // [`sample_caixa_nome_accessor_byte_equals_raw_field`] (2ffdb44)
29363 // / caixa-crd `round_trip_preserves_core_fields` (1a160cd) /
29364 // caixa-feira load.rs (e853d45) test-side accessor
29365 // convergences on the peer per-`Caixa` scalar-axis field —
29366 // extended here onto the render-side per-`AplicacaoSpec`
29367 // `:membros` slice + per-`Membro` `:caixa` scalar axes.
29368 let membros = spec.membros();
29369 assert_eq!(membros.len(), 2);
29370 assert_eq!(membros[0].nome(), "cart");
29371 assert_eq!(membros[1].nome(), "catalog");
29372 }
29373
29374 #[test]
29375 fn require_aplicacao_view_accepts_valid_aplicacao_membros_accessor_byte_equals_raw_field() {
29376 // Byte-parity pin: [`AplicacaoSpec::membros`]'s `&[Membro]`-
29377 // return accessor must project the same slice-length and
29378 // per-entry `:caixa` bytes as the raw `spec.membros`
29379 // `Vec<Membro>` + per-`Membro` `caixa: String` field access
29380 // on the shared per-test [`bare_aplicacao`] fixture the sibling
29381 // [`require_aplicacao_view_accepts_valid_aplicacao`] happy-
29382 // path acceptance pin navigates through. Guards the paired
29383 // per-fixture convergence that just routed the three raw
29384 // `spec.membros.len()` / `spec.membros[0].caixa` /
29385 // `spec.membros[1].caixa` sites through the accessor pair: a
29386 // future implementation of [`AplicacaoSpec::membros`] that
29387 // returned a differently-shaped view (a filter over
29388 // storage-dropping optional members, a cached
29389 // `Cow<[Membro]>` materialization, an operator-side per-CR
29390 // alias-rewritten membership overlay), or a future
29391 // [`crate::aplicacao::Membro::nome`] projection that read a
29392 // canonicalized rewrite (a per-tenant namespace prefix, an
29393 // ASCII-lowered normalization) rather than the raw storage-
29394 // side `.caixa` bytes, would silently split every render-
29395 // side test-fixture navigation that routes through the
29396 // accessors from the storage-side field the peer
29397 // [`AplicacaoSpec::validate`] production membership-lookup
29398 // path still reads through the same accessor pair — this
29399 // pin surfaces the drift at caixa-core build time rather
29400 // than at a downstream per-Aplicacao renderer's
29401 // membership-lookup diagnostic on the fleet.
29402 //
29403 // Same byte-parity-pin discipline the sibling caixa-flux
29404 // `sample_caixa_nome_accessor_byte_equals_raw_field` (2ffdb44)
29405 // + caixa-crd `round_trip_preserves_core_fields` accessor
29406 // convergence (1a160cd) + caixa-feira load.rs (e853d45)
29407 // per-`Caixa` scalar-axis byte-parity pins added to lock the
29408 // peer per-`Caixa` scalar-accessor family against the raw
29409 // field-access at each crate's fixture — extended here onto
29410 // the render-side per-`AplicacaoSpec` `:membros` slice + per-
29411 // `Membro` `:caixa` scalar axes' shared test fixture.
29412 let c = bare_aplicacao();
29413 let spec: crate::aplicacao::AplicacaoSpec =
29414 require_aplicacao_view::<AplicacaoRendererStandIn>(&c)
29415 .expect("valid aplicacao shape accepted");
29416 assert_eq!(
29417 spec.membros().len(),
29418 spec.membros.len(),
29419 "AplicacaoSpec::membros() slice-length must byte-equal \
29420 the raw `membros: Vec<Membro>` field storage's `.len()`; \
29421 any implementation drift here silently splits every \
29422 render-side test-fixture navigation that routes through \
29423 the accessor from the storage-side field the peer \
29424 AplicacaoSpec::validate production membership-lookup \
29425 path still reads through the same accessor"
29426 );
29427 for (i, m) in spec.membros().iter().enumerate() {
29428 assert_eq!(
29429 m.nome(),
29430 spec.membros[i].caixa.as_str(),
29431 "Membro::nome() must borrow the same bytes as the raw \
29432 `caixa: String` field storage at member index {i}; \
29433 any implementation drift here silently splits every \
29434 render-side test-fixture navigation that routes \
29435 through the accessor from the storage-side field the \
29436 peer AplicacaoSpec::validate production membership-\
29437 lookup path still reads through the same accessor"
29438 );
29439 }
29440 }
29441
29442 #[test]
29443 fn require_aplicacao_view_forwards_kind_mismatch_first() {
29444 // Order pin: the kind gate fires before the aplicacao_view
29445 // fold-in + [`AplicacaoSpec::validate`], so a `:kind Servico`
29446 // caixa carrying a well-formed `:membros` stanza (the manifest
29447 // field's documented "silently ignored" case on a non-Aplicacao
29448 // kind) surfaces the [`KindMismatch`] arm — the more actionable
29449 // diagnostic — rather than any spec-side arm the manifest
29450 // author never intended to hit. Reversing the order would flip
29451 // every current caller's diagnostic on a mis-kinded input.
29452 // Peer to `require_v0_servico_shape_forwards_kind_mismatch_first`
29453 // on the sibling per-Servico compound gate.
29454 let mut c = bare_aplicacao();
29455 c.kind = CaixaKind::Servico;
29456 c.servicos = vec!["servicos/hello.computeunit.yaml".into()];
29457 let err: AplicacaoRendererStandIn = require_aplicacao_view(&c).unwrap_err();
29458 match err {
29459 AplicacaoRendererStandIn::NotAnAplicacao(k) => {
29460 assert_eq!(k.nome, "checkout");
29461 assert_eq!(k.expected, CaixaKind::Aplicacao);
29462 assert_eq!(k.actual, CaixaKind::Servico);
29463 }
29464 AplicacaoRendererStandIn::InvalidAplicacao(_) => {
29465 panic!("kind gate must fire before aplicacao-view fold-in on mis-kinded input")
29466 }
29467 }
29468 }
29469
29470 #[test]
29471 fn require_aplicacao_view_forwards_aplicacao_error_on_kind_match() {
29472 // A `:kind Aplicacao` caixa that passes the kind gate but
29473 // fails [`AplicacaoSpec::validate`] (empty `:membros` here —
29474 // the [`AplicacaoError::NoMembros`] arm every Aplicacao must
29475 // satisfy per MESH-COMPOSITION §III.1) lands on the
29476 // [`AplicacaoError`] arm through the compound helper's
29477 // `E: From<AplicacaoError>` bound. Same diagnostic the
29478 // three-line cascade the compound helper replaces surfaces at
29479 // `spec.validate()?`. Peer to
29480 // `require_v0_servico_shape_forwards_count_mismatch_on_kind_match`
29481 // on the sibling per-Servico compound gate.
29482 let mut c = bare_aplicacao();
29483 c.membros = vec![]; // trips AplicacaoError::NoMembros
29484 let err: AplicacaoRendererStandIn = require_aplicacao_view(&c).unwrap_err();
29485 match err {
29486 AplicacaoRendererStandIn::InvalidAplicacao(
29487 crate::aplicacao::AplicacaoError::NoMembros,
29488 ) => {}
29489 AplicacaoRendererStandIn::InvalidAplicacao(other) => {
29490 panic!("expected NoMembros arm, got {other:?}")
29491 }
29492 AplicacaoRendererStandIn::NotAnAplicacao(_) => {
29493 panic!("spec-validate arm must fire when kind gate passes")
29494 }
29495 }
29496 }
29497
29498 #[test]
29499 fn require_aplicacao_view_matches_three_line_cascade_semantic() {
29500 // Equivalence pin: on every input, the compound helper's
29501 // Ok/Err discrimination matches the three-line cascade
29502 // verbatim — the lift is a behavioral no-op at the caller
29503 // boundary. Peer to the sibling
29504 // `require_v0_servico_shape_matches_two_line_pair_semantic`
29505 // equivalence pin on the per-Servico compound gate.
29506 //
29507 // Four axes covered: Aplicacao shape (Ok/Ok), kind gate fires
29508 // (Err/Ok on the cascade — cascade short-circuits at the kind
29509 // gate), spec-validate arm fires (Ok/Err on the cascade —
29510 // cascade reaches [`AplicacaoSpec::validate`]), and a
29511 // mis-kinded caixa with a spec-invalid `:membros` stanza (both
29512 // invariants violated — the kind gate must still fire first).
29513 let cases: Vec<(CaixaKind, Vec<crate::aplicacao::Membro>)> = vec![
29514 (
29515 CaixaKind::Aplicacao,
29516 vec![
29517 crate::aplicacao::Membro {
29518 caixa: "cart".into(),
29519 versao: "^0.1".into(),
29520 },
29521 crate::aplicacao::Membro {
29522 caixa: "catalog".into(),
29523 versao: "^0.1".into(),
29524 },
29525 ],
29526 ),
29527 (CaixaKind::Servico, vec![]),
29528 (CaixaKind::Aplicacao, vec![]),
29529 (
29530 CaixaKind::Biblioteca,
29531 vec![crate::aplicacao::Membro {
29532 caixa: "cart".into(),
29533 versao: "^0.1".into(),
29534 }],
29535 ),
29536 ];
29537 for (kind, membros) in cases {
29538 let mut c = bare_aplicacao();
29539 c.kind = kind;
29540 c.membros = membros.clone();
29541 if kind == CaixaKind::Servico {
29542 c.servicos = vec!["servicos/hello.computeunit.yaml".into()];
29543 } else {
29544 c.servicos = vec![];
29545 }
29546 let cascade: Result<crate::aplicacao::AplicacaoSpec, AplicacaoRendererStandIn> =
29547 (|| {
29548 require_kind(&c, CaixaKind::Aplicacao)?;
29549 let spec = c.aplicacao_view().expect(
29550 "require_kind(Aplicacao) guarantees Caixa::aplicacao_view returns Some",
29551 );
29552 spec.validate()?;
29553 Ok(spec)
29554 })();
29555 let compound: Result<crate::aplicacao::AplicacaoSpec, AplicacaoRendererStandIn> =
29556 require_aplicacao_view(&c);
29557 assert_eq!(
29558 cascade.is_ok(),
29559 compound.is_ok(),
29560 "compound helper must match three-line cascade on kind={kind:?} membros.len()={}",
29561 membros.len(),
29562 );
29563 // Compound helper's Ok-arm return matches cascade's
29564 // Ok-arm return byte-for-byte (via serde YAML round-trip
29565 // — the `AplicacaoSpec` derives `Serialize`, so equal-
29566 // rendering values are the substrate-canonical equality
29567 // signal the peer downstream renderers key off).
29568 if let (Ok(cascade_spec), Ok(compound_spec)) = (cascade, compound) {
29569 assert_eq!(
29570 serde_yaml::to_string(&cascade_spec).expect("cascade AplicacaoSpec serializes"),
29571 serde_yaml::to_string(&compound_spec)
29572 .expect("compound AplicacaoSpec serializes"),
29573 "compound helper's Ok arm must return byte-equal AplicacaoSpec to cascade"
29574 );
29575 }
29576 }
29577 }
29578
29579 // ── require_acao_view — compound per-`Acao` entry gate ───────────
29580
29581 /// Local `thiserror`-shaped renderer-error stand-in that mirrors
29582 /// `caixa-actions::Error`'s three `#[from]` arms at the compound
29583 /// helper's `E: From<KindMismatch> + From<MissingCiSlot> +
29584 /// From<CiDecomposeFailure>` bound. Same discipline as the sibling
29585 /// [`RendererStandIn`] / [`AplicacaoRendererStandIn`] stand-ins on
29586 /// the peer per-Servico [`require_v0_servico_shape`] and
29587 /// per-Aplicacao [`require_aplicacao_view`] compound gates: pins
29588 /// the compound helper's type-inference contract inside caixa-core
29589 /// without a workspace-crate dependency (which would bloat the
29590 /// build graph).
29591 #[derive(Debug, thiserror::Error)]
29592 enum AcaoRendererStandIn {
29593 #[error("{0}")]
29594 NotAnAcao(#[from] KindMismatch),
29595 #[error("{0}")]
29596 MissingCi(#[from] MissingCiSlot),
29597 #[error("{0}")]
29598 Decompose(#[from] CiDecomposeFailure),
29599 }
29600
29601 #[test]
29602 fn require_acao_view_accepts_valid_acao() {
29603 // Happy path: a `:kind Acao` caixa with a well-formed `:ci`
29604 // stanza — the canonical V0 shape every per-`Acao` consumer's
29605 // entry-point sees — passes the compound three-arm gate and
29606 // returns the borrowed [`canteiro_types::CiRun`] paired with
29607 // the owned [`canteiro_types::CanteiroDag`] the substrate
29608 // primitive produced. Same outcome as the three-line prelude
29609 // the compound helper replaces: [`require_kind`] passes,
29610 // [`require_ci`] returns the borrowed slot, [`decompose_ci`]
29611 // accepts the run. Peer to
29612 // `require_aplicacao_view_accepts_valid_aplicacao` and
29613 // `require_v0_servico_shape_accepts_v0_servico` on the sibling
29614 // per-Aplicacao / per-Servico compound gates.
29615 let mut c = bare_acao_without_ci();
29616 c.ci = Some(linear_ci_run());
29617 let (ci, cd) = require_acao_view::<AcaoRendererStandIn>(&c)
29618 .expect("valid Acao shape accepted by compound helper");
29619 assert_eq!(ci.workspace, "pleme-io");
29620 assert_eq!(ci.nodes.len(), 2);
29621 // `topo_order()` is infallible on the DAG the compound helper
29622 // returns, mirroring the substrate-side pass-through pin at
29623 // [`decompose_ci_accepts_valid_ci_run_and_returns_canteiro_dag`].
29624 let topo = cd
29625 .topo_order()
29626 .expect("acyclic CanteiroDag returns a valid topo_order");
29627 assert_eq!(
29628 topo.iter().count(),
29629 2,
29630 "topo_order on the compound helper's returned DAG must yield \
29631 two node ids on a two-node acyclic run"
29632 );
29633 }
29634
29635 #[test]
29636 fn require_acao_view_forwards_kind_mismatch_first() {
29637 // Order pin: the kind gate fires before the presence gate + the
29638 // decompose gate, so a `:kind Servico` caixa carrying a
29639 // well-formed `:ci` stanza (the manifest field's documented
29640 // "silently ignored" case on a non-`Acao` kind) surfaces the
29641 // [`KindMismatch`] arm — the more actionable diagnostic —
29642 // rather than either downstream arm the manifest author never
29643 // intended to hit. Reversing the order would flip every
29644 // current caller's diagnostic on a mis-kinded input. Peer to
29645 // `require_aplicacao_view_forwards_kind_mismatch_first` and
29646 // `require_v0_servico_shape_forwards_kind_mismatch_first` on
29647 // the sibling per-Aplicacao / per-Servico compound gates.
29648 let mut c = bare_acao_without_ci();
29649 c.kind = CaixaKind::Servico;
29650 c.servicos = vec!["servicos/hello.computeunit.yaml".into()];
29651 c.ci = Some(linear_ci_run());
29652 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
29653 // `canteiro_types::CanteiroDag`, which does not derive it at the
29654 // pinned sui rev — so the whole caixa-core test target failed to
29655 // COMPILE. A let-else says the same thing without borrowing a
29656 // bound from a foreign type we do not own.
29657 let Err(err): Result<_, AcaoRendererStandIn> = require_acao_view(&c) else {
29658 panic!("this fixture must not produce an Acao view");
29659 };
29660 match err {
29661 AcaoRendererStandIn::NotAnAcao(k) => {
29662 assert_eq!(k.nome, "hello-rio");
29663 assert_eq!(k.expected, CaixaKind::Acao);
29664 assert_eq!(k.actual, CaixaKind::Servico);
29665 }
29666 AcaoRendererStandIn::MissingCi(_) => {
29667 panic!("kind gate must fire before presence gate on mis-kinded input")
29668 }
29669 AcaoRendererStandIn::Decompose(_) => {
29670 panic!("kind gate must fire before decompose gate on mis-kinded input")
29671 }
29672 }
29673 }
29674
29675 #[test]
29676 fn require_acao_view_forwards_missing_ci_slot_on_kind_match() {
29677 // A `:kind Acao` caixa that passes the kind gate but declares
29678 // no `:ci` slot lands on the [`MissingCiSlot`] arm through the
29679 // compound helper's `E: From<MissingCiSlot>` bound — the same
29680 // typed view the peer [`require_ci`] presence gate produces at
29681 // the single-axis primitive, propagated through the compound
29682 // gate's second arm.
29683 let c = bare_acao_without_ci();
29684 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
29685 // `canteiro_types::CanteiroDag`, which does not derive it at the
29686 // pinned sui rev — so the whole caixa-core test target failed to
29687 // COMPILE. A let-else says the same thing without borrowing a
29688 // bound from a foreign type we do not own.
29689 let Err(err): Result<_, AcaoRendererStandIn> = require_acao_view(&c) else {
29690 panic!("this fixture must not produce an Acao view");
29691 };
29692 match err {
29693 AcaoRendererStandIn::MissingCi(m) => {
29694 assert_eq!(m.nome, "hello-rio");
29695 }
29696 AcaoRendererStandIn::NotAnAcao(_) => {
29697 panic!("presence gate must fire when kind gate passes")
29698 }
29699 AcaoRendererStandIn::Decompose(_) => {
29700 panic!("presence gate must fire before decompose gate on missing `:ci` input")
29701 }
29702 }
29703 }
29704
29705 #[test]
29706 fn require_acao_view_forwards_decompose_failure_on_ci_present() {
29707 // A `:kind Acao` caixa that passes the kind + presence gates
29708 // but carries a cyclic `:ci` run lands on the
29709 // [`CiDecomposeFailure`] arm through the compound helper's
29710 // `E: From<CiDecomposeFailure>` bound — the same typed view
29711 // the peer [`decompose_ci`] gate produces at the single-axis
29712 // primitive, propagated through the compound gate's third
29713 // arm.
29714 let mut c = bare_acao_without_ci();
29715 c.ci = Some(cyclic_ci_run());
29716 // `unwrap_err()` needs `T: Debug`, and the Ok half here carries
29717 // `canteiro_types::CanteiroDag`, which does not derive it at the
29718 // pinned sui rev — so the whole caixa-core test target failed to
29719 // COMPILE. A let-else says the same thing without borrowing a
29720 // bound from a foreign type we do not own.
29721 let Err(err): Result<_, AcaoRendererStandIn> = require_acao_view(&c) else {
29722 panic!("this fixture must not produce an Acao view");
29723 };
29724 match err {
29725 AcaoRendererStandIn::Decompose(f) => {
29726 assert_eq!(f.nome, "hello-rio");
29727 assert_eq!(f.source, canteiro_types::DecomposeError::Cycle);
29728 }
29729 AcaoRendererStandIn::NotAnAcao(_) => {
29730 panic!("decompose gate must fire when kind + presence gates pass")
29731 }
29732 AcaoRendererStandIn::MissingCi(_) => {
29733 panic!("decompose gate must fire when presence gate passes")
29734 }
29735 }
29736 }
29737
29738 #[test]
29739 fn require_acao_view_matches_three_line_prelude_semantic() {
29740 // Equivalence pin: on every input, the compound helper's
29741 // Ok/Err discrimination matches the three-line prelude
29742 // verbatim — the lift is a behavioral no-op at the caller
29743 // boundary. Peer to the sibling
29744 // `require_aplicacao_view_matches_three_line_cascade_semantic`
29745 // and `require_v0_servico_shape_matches_two_line_pair_semantic`
29746 // equivalence pins on the per-Aplicacao / per-Servico compound
29747 // gates.
29748 //
29749 // Five axes covered: valid Acao (Ok/Ok), kind gate fires
29750 // (Err/Err on the prelude — prelude short-circuits at the kind
29751 // gate), presence gate fires (Ok/Err on the prelude — prelude
29752 // reaches [`require_ci`]), decompose gate fires (Ok/Err on the
29753 // prelude — prelude reaches [`decompose_ci`]), and a
29754 // mis-kinded caixa with a well-formed `:ci` (both invariants
29755 // relevant — the kind gate must still fire first).
29756 let cases: Vec<(CaixaKind, Option<canteiro_types::CiRun>)> = vec![
29757 (CaixaKind::Acao, Some(linear_ci_run())),
29758 (CaixaKind::Servico, Some(linear_ci_run())),
29759 (CaixaKind::Acao, None),
29760 (CaixaKind::Acao, Some(cyclic_ci_run())),
29761 (CaixaKind::Biblioteca, None),
29762 ];
29763 for (kind, ci) in cases {
29764 let mut c = bare_acao_without_ci();
29765 c.kind = kind;
29766 c.ci = ci.clone();
29767 if kind == CaixaKind::Servico {
29768 c.servicos = vec!["servicos/hello.computeunit.yaml".into()];
29769 } else {
29770 c.servicos = vec![];
29771 }
29772 let prelude: Result<
29773 (&canteiro_types::CiRun, canteiro_types::CanteiroDag),
29774 AcaoRendererStandIn,
29775 > = (|| {
29776 require_kind(&c, CaixaKind::Acao)?;
29777 let ci_borrowed = require_ci(&c)?;
29778 let cd = decompose_ci(&c, ci_borrowed)?;
29779 Ok((ci_borrowed, cd))
29780 })();
29781 let compound: Result<
29782 (&canteiro_types::CiRun, canteiro_types::CanteiroDag),
29783 AcaoRendererStandIn,
29784 > = require_acao_view(&c);
29785 assert_eq!(
29786 prelude.is_ok(),
29787 compound.is_ok(),
29788 "compound helper must match three-line prelude on kind={kind:?} ci.is_some()={}",
29789 ci.is_some(),
29790 );
29791 // Compound helper's Ok-arm return matches prelude's
29792 // Ok-arm return byte-for-byte on both projections: the
29793 // borrowed `&CiRun`'s node count + workspace / repo
29794 // identity, and the owned `CanteiroDag`'s
29795 // topological-order node-name projection (the substrate-
29796 // canonical equality signal every downstream per-`Acao`
29797 // consumer keys off).
29798 if let (Ok((prelude_ci, prelude_cd)), Ok((compound_ci, compound_cd))) =
29799 (prelude, compound)
29800 {
29801 assert_eq!(
29802 prelude_ci.workspace, compound_ci.workspace,
29803 "compound helper's borrowed CiRun's workspace must \
29804 equal prelude's byte-for-byte"
29805 );
29806 assert_eq!(
29807 prelude_ci.repo, compound_ci.repo,
29808 "compound helper's borrowed CiRun's repo must equal \
29809 prelude's byte-for-byte"
29810 );
29811 assert_eq!(
29812 prelude_ci.nodes.len(),
29813 compound_ci.nodes.len(),
29814 "compound helper's borrowed CiRun's node count must \
29815 equal prelude's"
29816 );
29817 let prelude_topo = prelude_cd
29818 .topo_order()
29819 .expect("prelude's DAG produces a valid topo_order");
29820 let compound_topo = compound_cd
29821 .topo_order()
29822 .expect("compound's DAG produces a valid topo_order");
29823 let prelude_names: Vec<String> = prelude_topo
29824 .iter()
29825 .filter_map(|id| prelude_cd.nodes.get(id).map(|n| n.name.clone()))
29826 .collect();
29827 let compound_names: Vec<String> = compound_topo
29828 .iter()
29829 .filter_map(|id| compound_cd.nodes.get(id).map(|n| n.name.clone()))
29830 .collect();
29831 assert_eq!(
29832 prelude_names, compound_names,
29833 "compound helper's DAG must produce byte-equal \
29834 topological-order node-name projection to prelude's"
29835 );
29836 }
29837 }
29838 }
29839
29840 // ── single_field_overlay — typed per-axis overlay primitive ──────────
29841
29842 #[test]
29843 fn single_field_overlay_none_yields_none() {
29844 // Empty-axis-skip semantic at the typed-primitive layer: a
29845 // `None` slot returns `None`, not `Some(empty Mapping)`. The
29846 // caller's `if let Some(overlay) = …` guard then becomes the
29847 // single emission gate, and a malformed `outer: {}` (the
29848 // empty-mapping form some K8s parsers reject) is structurally
29849 // impossible by construction.
29850 let v: Option<serde_yaml::Value> = single_field_overlay::<u32, _>(None, "attempts", |n| {
29851 serde_yaml::Value::Number(n.into())
29852 });
29853 assert!(v.is_none());
29854 }
29855
29856 #[test]
29857 fn single_field_overlay_some_yields_single_field_mapping() {
29858 // The Some arm builds exactly one inner key/value pair, no
29859 // more, no less. Pinning the shape so a future refactor can't
29860 // accidentally introduce a second field (which would render
29861 // as a malformed `timeouts: { request: "30s", <leak>: ... }`
29862 // overlay block).
29863 let v = single_field_overlay(Some(30u32), "attempts", |n| {
29864 serde_yaml::Value::Number(n.into())
29865 })
29866 .expect("Some arm yields Some(...)");
29867 let m = v.as_mapping().expect("mapping shape");
29868 assert_eq!(m.len(), 1);
29869 assert_eq!(m.get("attempts").and_then(|x| x.as_u64()), Some(30));
29870 }
29871
29872 #[test]
29873 fn single_field_overlay_threads_typed_value_through_closure() {
29874 // The closure receives the unwrapped typed `T` (not the
29875 // wrapping `Option<T>`), so the per-overlay value-shaping
29876 // logic stays at the call site. Three different Value shapes
29877 // pin the closure's type-flow: a `String` (for canonical
29878 // duration / enum scalars), a `Number` (for typed integer
29879 // attempt counts), and a derived `Bool` (for tristate enums).
29880 // Mirrors the three landed overlays' shapes letter-for-letter.
29881 let dur = single_field_overlay(Some("30s".to_string()), "request", |s| {
29882 serde_yaml::Value::String(s)
29883 })
29884 .unwrap();
29885 assert_eq!(dur.get("request").and_then(|v| v.as_str()), Some("30s"));
29886
29887 let num = single_field_overlay(Some(3u32), "attempts", |n| {
29888 serde_yaml::Value::Number(n.into())
29889 })
29890 .unwrap();
29891 assert_eq!(num.get("attempts").and_then(|v| v.as_u64()), Some(3));
29892
29893 // The mtls tristate's two non-None arms map to enum strings,
29894 // not raw bools (the Cilium CRD's `mode: required|disabled`
29895 // shape — pinned end-to-end at every emit site by the
29896 // `cnp_authentication_mode_serialized_as_yaml_string` test).
29897 // Both scalar-values thread through the lifted canonical
29898 // [`cilium_auth_mode`] bijection — the same `bool → &'static
29899 // str` projection the production `cilium_network_policies`
29900 // per-`(:de, :para)` overlay closure reaches for, so a future
29901 // Cilium CNP `MutualAuthenticationMode` OpenAPI schema enum
29902 // rebrand (either arm's scalar-value string, or the per-arm
29903 // dispatch) lands at the two consts + one projection body
29904 // rather than duplicated across the production emitter site
29905 // and this generic-helper pin.
29906 let mode = single_field_overlay(Some(true), CILIUM_KEY_MODE, |b| {
29907 serde_yaml::Value::String(cilium_auth_mode(b).into())
29908 })
29909 .unwrap();
29910 assert_eq!(
29911 mode.get(CILIUM_KEY_MODE).and_then(|v| v.as_str()),
29912 Some(CILIUM_AUTH_MODE_REQUIRED)
29913 );
29914 }
29915
29916 #[test]
29917 fn single_field_overlay_outer_key_is_callers_concern() {
29918 // The helper builds the *inner* (single-field) Mapping; the
29919 // *outer* key (`timeouts` / `retry` / `authentication`) is
29920 // the caller's `if let Some(overlay) = … { rule.insert(<outer>,
29921 // overlay.clone()) }` insertion. Pinning that the helper's
29922 // returned Value carries no outer-key wrapping — emitting the
29923 // outer-key-wrapped form here would silently double-wrap
29924 // every overlay (`timeouts: { timeouts: { request: "30s" } }`
29925 // post-insertion).
29926 let v = single_field_overlay(Some(30u32), "attempts", |n| {
29927 serde_yaml::Value::Number(n.into())
29928 })
29929 .unwrap();
29930 let m = v.as_mapping().unwrap();
29931 // Only the inner key — no `timeouts:` / `retry:` /
29932 // `authentication:` wrapper at this layer.
29933 for k in ["timeouts", "retry", "authentication"] {
29934 assert!(
29935 m.get(k).is_none(),
29936 "single_field_overlay must not pre-insert the outer key {k:?} \
29937 (the caller's per-rule insert is the canonical insertion site)"
29938 );
29939 }
29940 }
29941
29942 #[test]
29943 fn single_field_overlay_value_is_clonable_for_per_rule_dispatch() {
29944 // The build-once-clone-many idiom every emit-site uses: the
29945 // overlay is computed once per renderer call (so the closure
29946 // runs exactly once) and `.clone()`d into each rule of the
29947 // emitted sequence. Pin that the returned Value is in fact
29948 // cloneable (a `serde_yaml::Value` always is, but the test
29949 // pins the contract end-to-end so a future refactor that
29950 // returns a non-Cloneable wrapper surfaces here).
29951 let v = single_field_overlay(Some(30u32), "attempts", |n| {
29952 serde_yaml::Value::Number(n.into())
29953 })
29954 .unwrap();
29955 let v_clone = v.clone();
29956 assert_eq!(v, v_clone);
29957 }
29958
29959 // ── upsert_named_entry — typed sequence-upsert primitive ─────────────
29960
29961 #[test]
29962 fn upsert_named_entry_appends_when_empty() {
29963 // Empty-sequence-first arm: an initially-empty aggregator
29964 // programs.yaml carries no matching entry, so the upsert falls
29965 // through to the append-new tail and returns
29966 // `Ok(true)` (newly inserted). Pins the append-new contract
29967 // both writer-side [`caixa_flux`] upsert paths lean on when
29968 // the aggregator's `programs:` sequence is empty
29969 // (`upsert_inserts_new_entry` at the values.yaml layer,
29970 // `upsert_helmrelease_inserts_under_spec_values_programs` at
29971 // the HelmRelease layer) — the same shape at the typed-
29972 // primitive layer as the two production sites.
29973 let mut arr: Vec<serde_yaml::Value> = Vec::new();
29974 let entry: serde_yaml::Value =
29975 serde_yaml::from_str("{ name: hello-rio, module: { source: oci://x } }").unwrap();
29976 let inserted =
29977 upsert_named_entry::<()>(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || ()).unwrap();
29978 assert!(inserted, "empty sequence + new entry must append");
29979 assert_eq!(arr.len(), 1);
29980 assert_eq!(
29981 arr[0].get(FLEET_PROGRAMS_KEY_NAME).and_then(|n| n.as_str()),
29982 Some("hello-rio")
29983 );
29984 }
29985
29986 #[test]
29987 fn upsert_named_entry_appends_when_no_match() {
29988 // Non-matching-name append arm: an aggregator sequence with a
29989 // differently-named entry carries no matching name-key value,
29990 // so the upsert falls through to the append-new tail (never
29991 // replacing) and returns `Ok(true)`. Pins the append-only
29992 // semantic that keeps every unrelated entry untouched.
29993 let mut arr: Vec<serde_yaml::Value> = vec![
29994 serde_yaml::from_str("{ name: other, module: { source: github:foo/bar } }").unwrap(),
29995 ];
29996 let entry: serde_yaml::Value =
29997 serde_yaml::from_str("{ name: hello-rio, module: { source: oci://x } }").unwrap();
29998 let inserted =
29999 upsert_named_entry::<()>(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || ()).unwrap();
30000 assert!(inserted);
30001 assert_eq!(arr.len(), 2);
30002 assert_eq!(
30003 arr[0].get(FLEET_PROGRAMS_KEY_NAME).and_then(|n| n.as_str()),
30004 Some("other")
30005 );
30006 assert_eq!(
30007 arr[1].get(FLEET_PROGRAMS_KEY_NAME).and_then(|n| n.as_str()),
30008 Some("hello-rio")
30009 );
30010 }
30011
30012 #[test]
30013 fn upsert_named_entry_replaces_when_match() {
30014 // Match-and-replace arm: an aggregator sequence carrying an
30015 // entry whose `<name_key>` matches the new entry's name-scalar
30016 // gets its slot rewritten in place and the helper returns
30017 // `Ok(false)` (replaced-not-appended). Pins the idempotency
30018 // contract every writer-side upsert path lands on — the same
30019 // caixa.lisp deployed twice must upsert to the same
30020 // aggregator entry, never grow a duplicated `programs[]`
30021 // entry. Peer at the substrate layer with the two production
30022 // `upsert_replaces_existing_entry` /
30023 // `upsert_helmrelease_replaces_existing` tests
30024 // ([`caixa_flux`]).
30025 let mut arr: Vec<serde_yaml::Value> = vec![
30026 serde_yaml::from_str("{ name: hello-rio, module: { source: oci://old } }").unwrap(),
30027 ];
30028 let entry: serde_yaml::Value =
30029 serde_yaml::from_str("{ name: hello-rio, module: { source: oci://new } }").unwrap();
30030 let inserted =
30031 upsert_named_entry::<()>(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || ()).unwrap();
30032 assert!(!inserted, "matching name must replace, not append");
30033 assert_eq!(arr.len(), 1);
30034 assert_eq!(
30035 arr[0]
30036 .get(COMPUTEUNIT_SPEC_KEY_MODULE)
30037 .and_then(|m| m.get(COMPUTEUNIT_MODULE_KEY_SOURCE))
30038 .and_then(|s| s.as_str()),
30039 Some("oci://new")
30040 );
30041 }
30042
30043 #[test]
30044 fn upsert_named_entry_preserves_position_on_replace() {
30045 // Position-preserving-replace pin: when an interior entry
30046 // matches, its slot is rewritten in place and the surrounding
30047 // entries stay put (first / last / any middle position). The
30048 // aggregator's fanout consumers filter `programs[]` in
30049 // declaration order (the `lareira-fleet-programs` chart's
30050 // `.Values.programs` iteration + the future
30051 // `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
30052 // per-entry admission bind); a replace-then-move-to-tail shift
30053 // (silently promoting the just-upserted entry to end-of-list)
30054 // would silently reorder every downstream consumer's iteration
30055 // window. Same declaration-order-preservation contract the
30056 // aggregator side relies on.
30057 let mut arr: Vec<serde_yaml::Value> = vec![
30058 serde_yaml::from_str("{ name: alpha, module: { source: github:a/a } }").unwrap(),
30059 serde_yaml::from_str("{ name: beta, module: { source: github:b/old } }").unwrap(),
30060 serde_yaml::from_str("{ name: gamma, module: { source: github:g/g } }").unwrap(),
30061 ];
30062 let entry: serde_yaml::Value =
30063 serde_yaml::from_str("{ name: beta, module: { source: github:b/new } }").unwrap();
30064 let inserted =
30065 upsert_named_entry::<()>(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || ()).unwrap();
30066 assert!(!inserted);
30067 assert_eq!(arr.len(), 3);
30068 // Order pin: alpha stays at 0, beta stays at 1 (rewritten),
30069 // gamma stays at 2 — replace must preserve position.
30070 let names: Vec<&str> = arr
30071 .iter()
30072 .filter_map(|v| v.get(FLEET_PROGRAMS_KEY_NAME).and_then(|n| n.as_str()))
30073 .collect();
30074 assert_eq!(names, ["alpha", "beta", "gamma"]);
30075 assert_eq!(
30076 arr[1]
30077 .get(COMPUTEUNIT_SPEC_KEY_MODULE)
30078 .and_then(|m| m.get(COMPUTEUNIT_MODULE_KEY_SOURCE))
30079 .and_then(|s| s.as_str()),
30080 Some("github:b/new")
30081 );
30082 }
30083
30084 #[test]
30085 fn upsert_named_entry_calls_error_closure_on_missing_name_key() {
30086 // Missing-name-scalar arm: when the new entry doesn't carry
30087 // `<name_key>` as a string scalar, the helper calls the
30088 // caller's `on_missing_name` closure — the caller's own typed
30089 // [`crate::RenderError`]-shaped error surface remains
30090 // authoritative. Threaded through a closure so this crate
30091 // stays agnostic to the caller's error enum shape (the two
30092 // production sites in [`caixa_flux`] surface
30093 // `Error::MissingField(FLEET_PROGRAMS_KEY_NAME)` verbatim,
30094 // and any future upsert path — the M4
30095 // `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
30096 // per-entry upsert, the `caixa-otel` per-scrape upsert —
30097 // surfaces its own typed variant).
30098 let mut arr: Vec<serde_yaml::Value> = Vec::new();
30099 let entry: serde_yaml::Value =
30100 serde_yaml::from_str("{ module: { source: oci://x } }").unwrap();
30101 let err = upsert_named_entry(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || {
30102 "missing-name".to_string()
30103 })
30104 .unwrap_err();
30105 assert_eq!(err, "missing-name");
30106 assert!(arr.is_empty(), "missing-name entry must not land in arr");
30107 }
30108
30109 #[test]
30110 fn upsert_named_entry_calls_error_closure_on_non_string_name_scalar() {
30111 // Non-string-name-scalar arm: when the new entry's
30112 // `<name_key>` is present but not a string (a number, a
30113 // mapping, a sequence — the paste-from-binary footgun where
30114 // an author or a schema-migration script accidentally lands a
30115 // JSON-Number in the name slot), the helper takes the same
30116 // path as the missing-name arm and calls the caller's
30117 // `on_missing_name` closure. Peer arm to the
30118 // upsert_named_entry_calls_error_closure_on_missing_name_key
30119 // pin — both non-string-scalar paths route through the same
30120 // caller-owned diagnostic.
30121 let mut arr: Vec<serde_yaml::Value> = Vec::new();
30122 let entry: serde_yaml::Value =
30123 serde_yaml::from_str("{ name: 42, module: { source: oci://x } }").unwrap();
30124 let err =
30125 upsert_named_entry(&mut arr, entry, FLEET_PROGRAMS_KEY_NAME, || 7u32).unwrap_err();
30126 assert_eq!(err, 7u32);
30127 assert!(arr.is_empty());
30128 }
30129
30130 #[test]
30131 fn upsert_named_entry_uses_parametric_name_key() {
30132 // Name-key-axis-parametric pin: the helper matches on the
30133 // `name_key` parameter, not the pinned
30134 // [`FLEET_PROGRAMS_KEY_NAME`] const — a future writer-side
30135 // upsert path keying on a different discriminator scalar
30136 // (the M4 `mesh.pleme.io/v1alpha1/Aplicacao` CR materializer's
30137 // per-entry `spec.selector` axis, an in-progress rebrand
30138 // promoting `id:` alongside `name:`) reaches for the same
30139 // helper with a different key rather than re-inlining the
30140 // upsert loop.
30141 let mut arr: Vec<serde_yaml::Value> =
30142 vec![serde_yaml::from_str("{ id: alpha, payload: original }").unwrap()];
30143 let entry: serde_yaml::Value =
30144 serde_yaml::from_str("{ id: alpha, payload: replaced }").unwrap();
30145 let inserted = upsert_named_entry::<()>(&mut arr, entry, "id", || ()).unwrap();
30146 assert!(!inserted, "matching `id:` must replace, not append");
30147 assert_eq!(arr.len(), 1);
30148 assert_eq!(
30149 arr[0].get("payload").and_then(|p| p.as_str()),
30150 Some("replaced")
30151 );
30152 }
30153
30154 // ── is_dns_1123_label — shared DNS-1123 label predicate ──────────────
30155
30156 #[test]
30157 fn dns_1123_label_accepts_canonical_forms() {
30158 // Substrate-side pin: the predicate accepts the same canonical
30159 // shapes its three caller axes (`:membros :caixa`,
30160 // `:placement :clusters`, `:children :caixa`) accept at their own
30161 // gates. Drift between this list and the per-axis positive-set
30162 // sweeps surfaces here — one source of truth for the rule.
30163 for s in [
30164 "worker",
30165 "a",
30166 "0",
30167 "cache-v2",
30168 "payment-retry",
30169 "2-pool",
30170 "mar-east",
30171 ] {
30172 is_dns_1123_label(s)
30173 .unwrap_or_else(|e| panic!("canonical DNS-1123 label {s:?} must pass: {e:?}"));
30174 }
30175 }
30176
30177 #[test]
30178 fn dns_1123_label_rejects_uppercase_with_lower_suggestion() {
30179 // The diagnostic carries the lower-cased fix verbatim so every
30180 // caller's per-axis `*Invalid { reason }` wrapping the predicate's
30181 // output reads back as a one-edit-fix suggestion. Pinned at the
30182 // substrate layer so the suggestion shape lives in one place.
30183 let err = is_dns_1123_label("Rio").unwrap_err();
30184 assert!(err.contains("uppercase"), "got: {err:?}");
30185 assert!(err.contains("\"rio\""), "got: {err:?}");
30186 }
30187
30188 #[test]
30189 fn dns_1123_label_rejects_at_64_byte_boundary() {
30190 // The 63-byte cap pin — both the boundary-exceeding case and
30191 // the boundary-accepting case in one place, so a future cap
30192 // shift surfaces both arms simultaneously.
30193 let max_ok = "a".repeat(63);
30194 is_dns_1123_label(&max_ok).unwrap();
30195 let too_long = "a".repeat(64);
30196 let err = is_dns_1123_label(&too_long).unwrap_err();
30197 assert!(err.contains("63"), "got: {err:?}");
30198 assert!(err.contains("64"), "got: {err:?}");
30199 }
30200
30201 #[test]
30202 fn dns_1123_label_rejects_empty_defensively() {
30203 // Defensive re-check pin — every peer value-shape predicate in
30204 // this module (`is_gateway_api_http_path`, `is_wit_world_ref`,
30205 // `is_nats_subject`, `is_wasi_keyvalue_slot`, `is_git_ref_name`)
30206 // carries the same empty-first arm, so `is_dns_1123_label("")`
30207 // returns a clean parser-shaped `must not be empty` reason
30208 // instead of panicking at the boundary arm's `bytes[0]` access
30209 // (`bytes[0].is_ascii_alphanumeric()` on an empty slice would
30210 // index out of bounds). The per-axis narrower `*Empty` variant
30211 // (`MembroCaixaEmpty`, `PlacementClusterEmpty`, `EmptyChildName`,
30212 // `ModuleEmpty`) still fires at every current call site — this
30213 // arm exists so any future call site missing the pre-check gets
30214 // a self-locating diagnostic rather than a `panic!` far from the
30215 // source caixa.lisp, matching the "usable from any future call
30216 // site without a shape-mismatch footgun" discipline every peer
30217 // predicate's doc-comment already promises.
30218 let err = is_dns_1123_label("").unwrap_err();
30219 assert!(err.contains("empty"), "got: {err:?}");
30220 assert_eq!(err, "must not be empty");
30221 }
30222
30223 // ── is_gateway_api_http_path — shared HTTP-path predicate ────────────
30224
30225 #[test]
30226 fn gateway_api_http_path_accepts_canonical_forms() {
30227 // Substrate-side pin: the predicate accepts the same canonical
30228 // shapes both caller axes (`:entrada :paths` and `:contratos
30229 // :endpoint`) accept at their own gates. Drift between this
30230 // list and the per-axis positive-set sweeps surfaces here —
30231 // one source of truth for the rule. Includes the bare-root
30232 // `/` (the catch-all both renderers fall back to), the
30233 // `/foo..bar` interior-`..`-substring (not a `..` segment),
30234 // the `/...` and `/foo.` `.`-bearing names (not `.` segments),
30235 // and the percent-encoded form.
30236 for p in [
30237 "/",
30238 "/api/cart",
30239 "/healthz",
30240 "/api/.config",
30241 "/v1/products",
30242 "/products/:id",
30243 "/api/cart/",
30244 "/api/caf%C3%A9",
30245 "/foo..bar",
30246 "/...",
30247 "/charge",
30248 ] {
30249 is_gateway_api_http_path(p)
30250 .unwrap_or_else(|e| panic!("canonical HTTP path {p:?} must pass: {e:?}"));
30251 }
30252 }
30253
30254 #[test]
30255 fn gateway_api_http_path_rejects_each_arm_with_substring_pinned_reason() {
30256 // Substrate-side diagnostic-shape pin: each grammar arm
30257 // surfaces its own distinct reason substring. Pinned here so
30258 // a future reason-wording rephrase that drops any of these
30259 // substrings surfaces at this one place, not piecemeal across
30260 // every per-axis test sweep.
30261 for (path, needle) in [
30262 ("/api?q=1", "must not contain `?`"),
30263 ("/api#frag", "must not contain `#`"),
30264 ("/api my", "whitespace"),
30265 ("/api\x01x", "control character"),
30266 ("/api/café", "non-ASCII"),
30267 ("/api//x", "consecutive `/`"),
30268 ("/api/./x", "`.` segment"),
30269 ("/api/../x", "`..` parent-segment"),
30270 ] {
30271 let err = is_gateway_api_http_path(path)
30272 .err()
30273 .unwrap_or_else(|| panic!("path {path:?} must be rejected"));
30274 assert!(
30275 err.contains(needle),
30276 "path {path:?} reason must contain {needle:?}; got {err:?}"
30277 );
30278 }
30279 }
30280
30281 #[test]
30282 fn gateway_api_http_path_rejects_at_1025_byte_boundary() {
30283 // The 1024-byte cap pin — both the boundary-exceeding case and
30284 // the boundary-accepting case in one place, so a future cap
30285 // shift surfaces both arms simultaneously, mirroring
30286 // `dns_1123_label_rejects_at_64_byte_boundary` on the peer
30287 // predicate.
30288 let max_ok = format!("/{}", "a".repeat(1023));
30289 assert_eq!(max_ok.len(), 1024);
30290 is_gateway_api_http_path(&max_ok).unwrap();
30291 let too_long = format!("/{}", "a".repeat(1024));
30292 assert_eq!(too_long.len(), 1025);
30293 let err = is_gateway_api_http_path(&too_long).unwrap_err();
30294 assert!(err.contains("1024"), "got: {err:?}");
30295 assert!(err.contains("1025"), "got: {err:?}");
30296 }
30297
30298 #[test]
30299 fn gateway_api_http_path_rejects_empty_defensively() {
30300 // The predicate is called only after each caller's narrower
30301 // `*Empty` arm has fired; re-checking here keeps the predicate
30302 // usable from any future call site without an empty-precondition
30303 // footgun, and avoids a panic on `bytes[0]`-style indexing if
30304 // a future arm is added. Same defensive empty-check
30305 // `validate_entrada_path` carries at its call site (55410e4).
30306 let err = is_gateway_api_http_path("").unwrap_err();
30307 assert!(err.contains("empty"), "got: {err:?}");
30308 }
30309
30310 #[test]
30311 fn gateway_api_http_path_rejects_not_absolute_defensively() {
30312 // Defensive re-check of the leading-`/` invariant the per-axis
30313 // call site enforces with its own narrower `*NotAbsolute` arm;
30314 // ensures the predicate is callable from any future call site
30315 // without a shape-mismatch footgun.
30316 let err = is_gateway_api_http_path("api/cart").unwrap_err();
30317 assert!(err.contains('/'), "got: {err:?}");
30318 }
30319
30320 #[test]
30321 fn gateway_api_http_path_rejects_every_reserved_printable_ascii_byte() {
30322 // Substrate-side sweep: every one of the eleven printable-ASCII
30323 // bytes outside the K8s Gateway API HTTPPathMatch.value
30324 // apiserver-side OpenAPI regex
30325 // `^(?:[-A-Za-z0-9/._~!$&'()*+,;=:@]|[%][0-9a-fA-F]{2})+$`
30326 // accepted set surfaces a self-locating reason naming the
30327 // offending byte verbatim plus the canonical `%XX` percent-
30328 // encoding remediation. RFC 3986 §3.3's `pchar = unreserved /
30329 // pct-encoded / sub-delims / ":" / "@"` grammar excludes these
30330 // bytes from every path segment, so the apiserver rejects them
30331 // at admission time on every
30332 // `HTTPRoute.spec.rules[].matches[].path.value` landing site —
30333 // peer with the `?` / `#` / whitespace / control / non-ASCII
30334 // arms `gateway_api_http_path_rejects_each_arm_with_substring_
30335 // pinned_reason` covers.
30336 //
30337 // Each char surfaces in a path-shape that pins the canonical
30338 // authoring footgun the K8s apiserver would otherwise catch
30339 // far from the caixa.lisp: `{id}` / `[0]` / `<placeholder>`
30340 // template forms, the Windows path-separator typo, the
30341 // shell-regex character footgun, the SQL-string-literal /
30342 // YAML-flow-mapping accidents.
30343 for (path, ch) in [
30344 ("/api/cart\"path", '"'),
30345 ("/api/cart<id>", '<'),
30346 ("/api/cart/<id>", '<'),
30347 ("/api/cart[0]", '['),
30348 ("/api/cart\\path", '\\'),
30349 ("/api/cart]", ']'),
30350 ("/api/cart/^foo", '^'),
30351 ("/api/cart/`foo", '`'),
30352 ("/api/cart/{id}", '{'),
30353 ("/api/cart|alt", '|'),
30354 ("/api/cart}", '}'),
30355 ] {
30356 let err = is_gateway_api_http_path(path)
30357 .err()
30358 .unwrap_or_else(|| panic!("path {path:?} must be rejected"));
30359 assert!(
30360 err.contains("reserved character"),
30361 "path {path:?} reason must name the reserved-character axis; got {err:?}"
30362 );
30363 assert!(
30364 err.contains(&format!("{ch:?}")),
30365 "path {path:?} reason must name the offending byte {ch:?} verbatim; got {err:?}"
30366 );
30367 let hex = format!("%{:02X}", ch as u8);
30368 assert!(
30369 err.contains(&hex),
30370 "path {path:?} reason must surface the canonical {hex:?} percent-encoding \
30371 remediation; got {err:?}"
30372 );
30373 }
30374 }
30375
30376 #[test]
30377 fn gateway_api_http_path_reserved_char_arm_fires_before_consecutive_slash() {
30378 // Precedence pin: the per-byte loop runs before the post-loop
30379 // structural arms (`//`, `/./`, `/../`), so a path that is
30380 // *both* reserved-char-bearing and consecutive-`/`-bearing
30381 // surfaces the more self-locating reserved-character diagnostic
30382 // first, naming the offending byte verbatim. Mirrors the
30383 // existing `?` / `#` / whitespace / control / non-ASCII arms'
30384 // implicit precedence the
30385 // `gateway_api_http_path_rejects_each_arm_with_substring_
30386 // pinned_reason` pin already establishes for the peer per-byte
30387 // shapes.
30388 let err = is_gateway_api_http_path("/api/{id}//x").unwrap_err();
30389 assert!(
30390 err.contains("reserved character") && err.contains("'{'"),
30391 "got: {err:?}"
30392 );
30393 assert!(
30394 !err.contains("consecutive"),
30395 "the reserved-char arm must fire before the consecutive-`/` arm; got: {err:?}"
30396 );
30397 }
30398
30399 #[test]
30400 fn gateway_api_http_path_accepts_percent_encoded_reserved_chars() {
30401 // Positive-control complement to the reserved-byte rejection
30402 // sweep: every one of the eleven reserved printable-ASCII bytes
30403 // is admissible *when* properly percent-encoded, matching the
30404 // canonical Gateway API HTTPPathMatch.value apiserver-side
30405 // OpenAPI regex's `[%][0-9a-fA-F]{2}` alternative. Pins the
30406 // canonical remediation pathway the reserved-byte arm's reason
30407 // wording names — author who carries a literal `{` percent-
30408 // encodes as `%7B` and the typed slot accepts.
30409 for path in [
30410 "/api/cart%22path",
30411 "/api/cart%3Cid%3E",
30412 "/api/cart%5B0%5D",
30413 "/api/cart%5Cpath",
30414 "/api/cart/%5Efoo",
30415 "/api/cart/%60foo",
30416 "/api/cart/%7Bid%7D",
30417 "/api/cart%7Calt",
30418 ] {
30419 is_gateway_api_http_path(path)
30420 .unwrap_or_else(|e| panic!("percent-encoded path {path:?} must pass: {e:?}"));
30421 }
30422 }
30423
30424 // ── is_wit_world_ref — shared WIT world-reference predicate ──────────
30425
30426 #[test]
30427 fn wit_world_ref_accepts_canonical_forms() {
30428 // Substrate-side pin: the predicate accepts every canonical
30429 // WIT identifier the `:contratos :wit` axis already carries in
30430 // the test fixtures + the example checkout-aplicacao (each
30431 // hand-curated to match real WIT registry references). Drift
30432 // between this list and the per-axis positive-set sweep
30433 // surfaces here — one source of truth for the rule. Includes
30434 // every shape variant: HTTP-prefixed (`wasi:http/proxy`),
30435 // KV-prefixed (`wasi:keyvalue/store`), pubsub-prefixed
30436 // (`nats:pub-sub`, `kafka:topic`), capability-only
30437 // (`custom:exchange`, `pleme:cap/audit`), the optional
30438 // `@<version>` suffix (`wasi:http/proxy@0.2.0`), and the
30439 // multi-segment `/iface/iface` form the WIT IDL grammar allows.
30440 for s in [
30441 "wasi:http/proxy",
30442 "wasi:keyvalue/store",
30443 "nats:pub-sub",
30444 "kafka:topic",
30445 "custom:exchange",
30446 "pleme:cap/audit",
30447 "http:server",
30448 "kv:store",
30449 "wasi:http/proxy@0.2.0",
30450 "wasi:keyvalue/store@0.2.0-rc.1",
30451 "pleme:cap/audit/v2",
30452 // Every legal shape SemVer 2.0.0 admits in the `@<version>`
30453 // body — bare numeric core, pre-release suffix (single +
30454 // dot-separated identifiers), build-metadata suffix (single
30455 // + dot-separated identifiers), combined pre-release +
30456 // build-metadata, and leading-zero-avoiding pre-release
30457 // identifiers — pinned here so a future tightening of the
30458 // per-byte accepted set that rejects a canonical semver
30459 // shape surfaces here rather than at the M4 CR materializer's
30460 // WIT-parse boundary.
30461 "wasi:http/proxy@1.0.0",
30462 "wasi:http/proxy@0.2.0-alpha",
30463 "wasi:http/proxy@1.0.0-alpha.1",
30464 "wasi:http/proxy@2.0.0+build.42",
30465 "wasi:http/proxy@0.0.0-rc.1+abc.def",
30466 ] {
30467 is_wit_world_ref(s)
30468 .unwrap_or_else(|e| panic!("canonical WIT reference {s:?} must pass: {e:?}"));
30469 }
30470 }
30471
30472 #[test]
30473 fn wit_world_ref_rejects_each_arm_with_substring_pinned_reason() {
30474 // Substrate-side diagnostic-shape pin: each grammar arm
30475 // surfaces its own distinct reason substring. Pinned here so a
30476 // future reason-wording rephrase that drops any of these
30477 // substrings surfaces at this one place, not piecemeal across
30478 // every per-axis test sweep. Mirrors
30479 // `gateway_api_http_path_rejects_each_arm_with_substring_pinned_reason`
30480 // on the peer predicate.
30481 for (s, needle) in [
30482 // Missing `:` separator → silent capability demotion.
30483 ("wasi-http/proxy", "must contain a `:`"),
30484 // Multiple `:` → can't split into ns + pkg.
30485 ("wasi:http:proxy", "exactly one `:`"),
30486 // Uppercase → silently bypasses the lowercase dispatch.
30487 ("WASI:http/proxy", "lowercase"),
30488 ("wasi:HTTP/proxy", "lowercase"),
30489 // Empty package half → can't resolve via WIT registry.
30490 ("wasi:", "must not be empty"),
30491 // Empty namespace half.
30492 (":http/proxy", "must not be empty"),
30493 // Underscore → DNS-1123 / WIT kebab-case footgun.
30494 ("wasi:http_proxy", "_"),
30495 // Leading digit → WIT identifiers begin with a letter.
30496 ("wasi:1http/proxy", "digit"),
30497 // Consecutive hyphens → invalid kebab-case.
30498 ("wasi:pub--sub", "consecutive `-`"),
30499 // Trailing hyphen → invalid kebab-case.
30500 ("wasi:proxy-", "must not end with `-`"),
30501 // Whitespace inside the token.
30502 ("wasi:http proxy", "whitespace"),
30503 // Control characters.
30504 ("wasi:http\x01proxy", "control character"),
30505 // Non-ASCII byte (café-style un-percent-encoded literal).
30506 ("wasi:caf\u{e9}/proxy", "non-ASCII"),
30507 // Trailing `@` with no version body.
30508 ("wasi:http/proxy@", "trailing `@`"),
30509 // Version body carrying `:` or `/`.
30510 ("wasi:http/proxy@0.2:rc1", "must not contain `:` or `/`"),
30511 // Doubled `@`.
30512 ("wasi:http/proxy@0.2@beta", "at most one `@`"),
30513 // Version body carrying a byte outside the SemVer 2.0.0
30514 // accepted set `[0-9A-Za-z.\-+]` — the canonical
30515 // author-side paste footguns (`?` from URL-query-separator
30516 // paste, `#` from URL-fragment paste, `!` from
30517 // history-expansion, `(` from parenthetical doc annotation,
30518 // `~` from tilde-range npm/Cargo semver-req paste that
30519 // strayed into the version body itself). Each surfaces the
30520 // `invalid character` reason substring so the diagnostic
30521 // wording is pinned alongside every peer per-byte rejection.
30522 ("wasi:http/proxy@0.2.0?rc1", "invalid character"),
30523 ("wasi:http/proxy@0.2.0#build", "invalid character"),
30524 ("wasi:http/proxy@0.2.0!alpha", "invalid character"),
30525 ("wasi:http/proxy@0.2.0(rc1)", "invalid character"),
30526 ("wasi:http/proxy@~0.2.0", "invalid character"),
30527 // Version body byte-set-valid but *structurally* invalid
30528 // SemVer 2.0.0 — the canonical author-side paste footguns
30529 // the byte-set gate above cannot catch. Every entry passes
30530 // the accepted-set arm `[0-9A-Za-z.\-+]` verbatim and
30531 // fails only at [`semver::Version::parse`]: two-part
30532 // numeric core (`@1.0` — Node.js `"engines"` field paste),
30533 // one-part numeric core (`@1` — Docker `:v1` tag paste),
30534 // four-part numeric core (`@1.0.0.0` — Microsoft / Java
30535 // build-number convention), `v`-prefixed version body
30536 // (`@v0.2.0` — git-tag-shape paste), leading-zero major
30537 // (`@01.0.0` — mistaken zero-padded date-based version),
30538 // trailing hyphen with empty pre-release (`@1.0.0-` —
30539 // half-typed pre-release), trailing plus with empty
30540 // build-metadata (`@1.0.0+` — peer for build-metadata),
30541 // empty pre-release identifier between dots
30542 // (`@1.0.0-.rc1` — accidental leading `.`), empty build-
30543 // metadata identifier between dots (`@1.0.0+.abc` — peer
30544 // for build-metadata), numeric pre-release identifier
30545 // with leading zero (`@1.0.0-01` — SemVer 2.0.0 rule 9),
30546 // consecutive dots inside pre-release (`@1.0.0-alpha..beta`).
30547 // Each surfaces the `structurally valid SemVer 2.0.0`
30548 // reason substring so the diagnostic wording is pinned
30549 // alongside every peer structural rejection.
30550 ("wasi:http/proxy@1.0", "structurally valid SemVer 2.0.0"),
30551 ("wasi:http/proxy@1", "structurally valid SemVer 2.0.0"),
30552 ("wasi:http/proxy@1.0.0.0", "structurally valid SemVer 2.0.0"),
30553 ("wasi:http/proxy@v0.2.0", "structurally valid SemVer 2.0.0"),
30554 ("wasi:http/proxy@01.0.0", "structurally valid SemVer 2.0.0"),
30555 ("wasi:http/proxy@1.0.0-", "structurally valid SemVer 2.0.0"),
30556 ("wasi:http/proxy@1.0.0+", "structurally valid SemVer 2.0.0"),
30557 (
30558 "wasi:http/proxy@1.0.0-.rc1",
30559 "structurally valid SemVer 2.0.0",
30560 ),
30561 (
30562 "wasi:http/proxy@1.0.0+.abc",
30563 "structurally valid SemVer 2.0.0",
30564 ),
30565 (
30566 "wasi:http/proxy@1.0.0-01",
30567 "structurally valid SemVer 2.0.0",
30568 ),
30569 (
30570 "wasi:http/proxy@1.0.0-alpha..beta",
30571 "structurally valid SemVer 2.0.0",
30572 ),
30573 // Digit-immediately-after-`-` word-start rule — the WIT IDL
30574 // `word ::= [a-z][a-z0-9]*` per-word first-byte gate the
30575 // predicate's doc-comment already documented, closed at the
30576 // implementation layer. Each identifier passes the outer
30577 // `[a-z0-9-]` byte set, the leading-`-` rejection, the
30578 // consecutive-`-` rejection, and the trailing-`-` rejection,
30579 // and was silently accepted before the arm landed — surfaces
30580 // the `word after `-`` reason substring so a future
30581 // diagnostic-wording rephrase surfaces here alongside every
30582 // peer per-arm substring pin. Canonical author-side
30583 // footguns: `"pub-1sub"` (version-shape digit paste),
30584 // `"proxy-2beta"` (v2 tag paste), `"cap-9"` (numeric
30585 // suffix). Namespace-side and interface-side variants pin
30586 // the arm fires uniformly on every WIT segment (`ns:pkg`,
30587 // `ns:pkg/iface`, not just the first).
30588 ("wasi:pub-1sub", "word after `-`"),
30589 ("wasi:proxy-2beta", "word after `-`"),
30590 ("wasi:cap-9", "word after `-`"),
30591 ("pleme-1cap:audit", "word after `-`"),
30592 ("wasi:http/proxy-3rc", "word after `-`"),
30593 ] {
30594 let err = is_wit_world_ref(s)
30595 .err()
30596 .unwrap_or_else(|| panic!("WIT reference {s:?} must be rejected"));
30597 assert!(
30598 err.contains(needle),
30599 "WIT reference {s:?} reason must contain {needle:?}; got {err:?}"
30600 );
30601 }
30602 }
30603
30604 #[test]
30605 fn wit_world_ref_word_after_hyphen_digit_arm_names_offending_byte_and_word_rule() {
30606 // Pin the per-word first-byte arm's diagnostic quality: the
30607 // offending byte appears verbatim in the reason, the WIT
30608 // grammar production is named (`[a-z][a-z0-9]*`), and the
30609 // remediation suggests a lowercase-letter prefix on the
30610 // offending word. Mirrors the `wit_world_ref_leading_digit`
30611 // sibling pin on the *first-word* first-byte arm — the two
30612 // arms enforce the same rule at complementary positions
30613 // (whole-id first byte vs. per-hyphen-word first byte), so
30614 // their diagnostic shapes stay peer.
30615 let err = is_wit_world_ref("wasi:pub-1sub").unwrap_err();
30616 assert!(err.contains("'1'"), "must name offending byte: {err:?}");
30617 assert!(
30618 err.contains("[a-z][a-z0-9]*"),
30619 "must name WIT word grammar: {err:?}"
30620 );
30621 assert!(
30622 err.contains("pub-v1sub"),
30623 "must suggest the letter-prefix remediation: {err:?}"
30624 );
30625 }
30626
30627 #[test]
30628 fn wit_world_ref_word_after_hyphen_lowercase_letter_still_accepted() {
30629 // Complement-side pin: the per-word first-byte arm strictly
30630 // targets *digits* after `-`; every canonical multi-word
30631 // lowercase identifier (`pub-sub`, `pub-sub-async`,
30632 // `wasi:http/incoming-handler`, `wasi:keyvalue/atomic-batch`)
30633 // remains in the accepted set with no new false-positive.
30634 // Pinned here so a future tightening that spills the digit-
30635 // rejection arm onto the letter-after-hyphen class surfaces
30636 // as a test failure at this positive-set pin, not at the M4
30637 // CR materializer's WIT-parse boundary. Mirrors the
30638 // `wit_world_ref_accepts_canonical_forms` positive-set
30639 // sweep, extended here to the multi-word-lowercase axis.
30640 for s in [
30641 "nats:pub-sub",
30642 "wasi:http/incoming-handler",
30643 "wasi:keyvalue/atomic-batch",
30644 "pleme:cap/audit-log",
30645 "http:server-side",
30646 ] {
30647 is_wit_world_ref(s).unwrap_or_else(|e| {
30648 panic!("canonical multi-word WIT identifier {s:?} must pass: {e:?}")
30649 });
30650 }
30651 }
30652
30653 #[test]
30654 fn wit_world_ref_word_after_hyphen_digit_arm_fires_before_byte_set_arm() {
30655 // Diagnostic-precedence pin: an identifier that is *both*
30656 // digit-after-`-` and byte-set-invalid (`"pub-1$"`) surfaces
30657 // the more self-locating word-start diagnostic, not the
30658 // generic invalid-character diagnostic. The arm order in the
30659 // loop is deliberate — the per-word first-byte gate fires on
30660 // the first offending byte (position 4 = the `1`) before the
30661 // byte-set gate can reach the `$` at position 5. Pinned here
30662 // so a future arm-reordering that moves the byte-set gate
30663 // earlier surfaces the drift at this test rather than
30664 // silently value-laundering the diagnostic.
30665 let err = is_wit_world_ref("wasi:pub-1$").unwrap_err();
30666 assert!(
30667 err.contains("word after `-`"),
30668 "must surface the per-word first-byte diagnostic, not the invalid-character one: {err:?}"
30669 );
30670 // And the `$` case *without* the digit-after-`-` still lands
30671 // on the invalid-character arm — the two diagnostics don't
30672 // collide when only one applies.
30673 let err = is_wit_world_ref("wasi:pub-x$").unwrap_err();
30674 assert!(
30675 err.contains("invalid character"),
30676 "byte-set-only rejection must still name invalid character: {err:?}"
30677 );
30678 }
30679
30680 #[test]
30681 fn wit_world_ref_rejects_empty_defensively() {
30682 // The predicate is called from `WitContract::target()` only
30683 // after the per-axis `EmptyWit` arm has fired at validate
30684 // time; re-checking here keeps the predicate usable from any
30685 // future call site without an empty-precondition footgun.
30686 // Same defensive empty-check `is_dns_1123_label` /
30687 // `is_gateway_api_http_path` carry at their call sites.
30688 let err = is_wit_world_ref("").unwrap_err();
30689 assert!(err.contains("empty"), "got: {err:?}");
30690 }
30691
30692 #[test]
30693 fn wit_world_ref_rejects_at_129_byte_boundary() {
30694 // The 128-byte cap pin — both the boundary-exceeding case and
30695 // the boundary-accepting case in one place, so a future cap
30696 // shift surfaces both arms simultaneously, mirroring
30697 // `dns_1123_label_rejects_at_64_byte_boundary` and
30698 // `gateway_api_http_path_rejects_at_1025_byte_boundary` on the
30699 // peer predicates. Constructed as `wasi:<long-pkg>` so the
30700 // kebab-shape arms don't fire first and obscure the cap arm.
30701 let pad = "a".repeat(123); // 5 + 123 = 128 (`wasi:` + pad)
30702 let max_ok = format!("wasi:{pad}");
30703 assert_eq!(max_ok.len(), 128);
30704 is_wit_world_ref(&max_ok).unwrap();
30705 let pad_over = "a".repeat(124);
30706 let too_long = format!("wasi:{pad_over}");
30707 assert_eq!(too_long.len(), 129);
30708 let err = is_wit_world_ref(&too_long).unwrap_err();
30709 assert!(err.contains("128"), "got: {err:?}");
30710 assert!(err.contains("129"), "got: {err:?}");
30711 }
30712
30713 // ── is_nats_subject — shared NATS subject predicate ──────────────────
30714
30715 #[test]
30716 fn nats_subject_accepts_canonical_forms() {
30717 // Substrate-side pin: the predicate accepts every canonical
30718 // NATS subject the `:contratos :subject` axis carries in the
30719 // caixa-mesh test fixtures + the example checkout-aplicacao
30720 // (each hand-curated to match real NATS server-side admission
30721 // shapes). Drift between this list and the per-axis positive-
30722 // set sweep surfaces here — one source of truth for the rule.
30723 // Includes single-token subjects, multi-dot subjects, snake-
30724 // case + kebab-case tokens (NATS accepts both), digit-bearing
30725 // tokens, the `*` single-token wildcard at every segment
30726 // position, and the `>` multi-token wildcard at the final
30727 // position (the two NATS subscription patterns the protocol
30728 // defines). Mirrors the canonical-forms sweeps on the peer
30729 // value-shape predicates (`gateway_api_http_path_accepts_…`,
30730 // `wit_world_ref_accepts_…`).
30731 for s in [
30732 "checkout.events.charge.failed",
30733 "rio.events.order.charged",
30734 "orders",
30735 "orders.123",
30736 "snake_case.token",
30737 "kebab-case.token",
30738 "MixedCase.Token",
30739 "alpha.beta.gamma.delta.epsilon",
30740 "orders.*.charged",
30741 "*.events.*",
30742 "orders.>",
30743 "*",
30744 ">",
30745 ] {
30746 is_nats_subject(s)
30747 .unwrap_or_else(|e| panic!("canonical NATS subject {s:?} must pass: {e:?}"));
30748 }
30749 }
30750
30751 #[test]
30752 fn nats_subject_rejects_each_arm_with_substring_pinned_reason() {
30753 // Substrate-side diagnostic-shape pin: each grammar arm
30754 // surfaces its own distinct reason substring. Pinned here so
30755 // a future reason-wording rephrase that drops any of these
30756 // substrings surfaces at this one place, not piecemeal across
30757 // every per-axis test sweep. Mirrors
30758 // `gateway_api_http_path_rejects_each_arm_with_substring_pinned_reason`
30759 // and `wit_world_ref_rejects_each_arm_with_substring_pinned_reason`
30760 // on the peer predicates.
30761 for (s, needle) in [
30762 // Whitespace inside the token.
30763 ("foo bar", "whitespace"),
30764 ("foo\tbar", "whitespace"),
30765 // Control characters.
30766 ("foo\x01bar", "control character"),
30767 // Non-ASCII byte (un-percent-encoded café-style literal).
30768 ("foo.caf\u{e9}", "non-ASCII"),
30769 // Leading `.` — empty leading token.
30770 (".foo", "must not start with `.`"),
30771 // Trailing `.` — empty trailing token.
30772 ("foo.", "must not end with `.`"),
30773 // Consecutive `.` — empty token between separators.
30774 ("foo..bar", "consecutive `.`"),
30775 // Non-trailing `>` multi-token wildcard.
30776 ("foo.>.bar", "only allowed as the final segment"),
30777 // Mid-segment `*` (not a standalone wildcard token).
30778 ("foo*.bar", "`*` mid-segment"),
30779 // Mid-segment `>` (not a standalone wildcard token).
30780 ("foo>", "`>` mid-segment"),
30781 // `.` is the separator, so `,` (or any other punctuation)
30782 // surfaces as an invalid-character arm.
30783 ("foo,bar", "invalid character"),
30784 // `:` reserved-looking — distinct invalid-character arm
30785 // (pinned separately so a future relaxation that accepts
30786 // `:` mid-segment surfaces here, not in some downstream
30787 // renderer's "this passed validate but the NATS server
30788 // rejected at publish" footgun).
30789 ("foo:bar", "invalid character"),
30790 ] {
30791 let err = is_nats_subject(s)
30792 .err()
30793 .unwrap_or_else(|| panic!("NATS subject {s:?} must be rejected"));
30794 assert!(
30795 err.contains(needle),
30796 "NATS subject {s:?} reason must contain {needle:?}; got {err:?}"
30797 );
30798 }
30799 }
30800
30801 #[test]
30802 fn nats_subject_rejects_empty_defensively() {
30803 // The predicate is called from `WitContract::target()` only
30804 // after the per-axis `ContratoSubjectEmpty` arm has fired at
30805 // validate time; re-checking here keeps the predicate usable
30806 // from any future call site without an empty-precondition
30807 // footgun. Same defensive empty-check `is_dns_1123_label`,
30808 // `is_gateway_api_http_path`, and `is_wit_world_ref` carry at
30809 // their call sites.
30810 let err = is_nats_subject("").unwrap_err();
30811 assert!(err.contains("empty"), "got: {err:?}");
30812 }
30813
30814 #[test]
30815 fn nats_subject_rejects_at_257_byte_boundary() {
30816 // The 256-byte cap pin — both the boundary-exceeding case and
30817 // the boundary-accepting case in one place, so a future cap
30818 // shift surfaces both arms simultaneously, mirroring
30819 // `dns_1123_label_rejects_at_64_byte_boundary`,
30820 // `gateway_api_http_path_rejects_at_1025_byte_boundary`, and
30821 // `wit_world_ref_rejects_at_129_byte_boundary` on the peer
30822 // predicates. Constructed as a single all-`a` token (no `.`)
30823 // so the segment / wildcard arms don't fire first and obscure
30824 // the cap arm.
30825 let max_ok = "a".repeat(256);
30826 assert_eq!(max_ok.len(), 256);
30827 is_nats_subject(&max_ok).unwrap();
30828 let too_long = "a".repeat(257);
30829 assert_eq!(too_long.len(), 257);
30830 let err = is_nats_subject(&too_long).unwrap_err();
30831 assert!(err.contains("256"), "got: {err:?}");
30832 assert!(err.contains("257"), "got: {err:?}");
30833 }
30834
30835 #[test]
30836 fn nats_subject_lone_wildcard_tokens_validate() {
30837 // The two NATS wildcards stand alone as the entire subject —
30838 // a `subscribe("*")` matches any single-token publish, a
30839 // `subscribe(">")` matches every NATS message on the connection.
30840 // Both are protocol-legal; the typed substrate accepts them
30841 // structurally and leaves the "should the typed `:contratos`
30842 // edge subscribe to literally everything?" question to a
30843 // future semantic-level gate. Pinned alongside the canonical-
30844 // forms sweep so a future tighten that disallows lone wildcards
30845 // surfaces both arms simultaneously.
30846 is_nats_subject("*").unwrap();
30847 is_nats_subject(">").unwrap();
30848 }
30849
30850 #[test]
30851 fn nats_subject_trailing_multi_wildcard_validates() {
30852 // `>` at the final segment is the canonical "match all trailing
30853 // tokens" subscription pattern. Pinned alongside the non-
30854 // trailing-`>` rejection arm so the boundary between the two
30855 // is in one place — a future relaxation that allows `>` at
30856 // non-trailing positions or a tighten that disallows trailing
30857 // `>` surfaces both arms simultaneously.
30858 is_nats_subject("orders.>").unwrap();
30859 is_nats_subject("orders.events.>").unwrap();
30860 // And the `*` single-token wildcard combines freely with the
30861 // trailing `>` — the canonical "match one middle token, then
30862 // anything trailing" subscription pattern.
30863 is_nats_subject("orders.*.>").unwrap();
30864 }
30865
30866 // ── is_wasi_keyvalue_slot — shared kv slot-template predicate ────────
30867
30868 #[test]
30869 fn wasi_kv_slot_accepts_canonical_forms() {
30870 // Substrate-side pin: the predicate accepts every canonical kv
30871 // slot template the `:contratos :slot` axis carries in the
30872 // caixa-mesh test fixtures + plausible authoring patterns
30873 // (each maps to a realistic wasi:keyvalue/store key the runtime
30874 // resolves on dispatch). Drift between this list and the
30875 // per-axis positive-set sweep surfaces here — one source of
30876 // truth for the rule. Includes:
30877 // - single-token identifiers (`"checkout"`, `"events"`);
30878 // - dot-namespaced templates (`"session.tokens.<sid>"`);
30879 // - path-namespaced templates with `$`-prefixed variables
30880 // (`"checkout/$orderId"`, the canonical Akka-cluster-
30881 // sharding-style template);
30882 // - colon-namespaced templates with brace placeholders
30883 // (`"users:{tenant}/{id}"`, the canonical multi-tenant
30884 // Redis-key shape);
30885 // - angle-bracket placeholders (`"session.<sid>"`);
30886 // - underscore identifiers (`"snake_case_key"`);
30887 // - kebab identifiers (`"kebab-case-key"`);
30888 // - mixed-case (`"MixedCase"` — kv slot templates are case-
30889 // sensitive; the predicate doesn't lowercase-fold);
30890 // - digit-bearing tokens (`"shard0"`, `"v2/key"`);
30891 // - percent-encoded fragments (`"users/caf%C3%A9"`); the
30892 // encoded form is the *valid* shape, the raw `café` is
30893 // rejected on the non-ASCII arm.
30894 // Mirrors the canonical-forms sweeps on the peer value-shape
30895 // predicates (`gateway_api_http_path_accepts_…`,
30896 // `nats_subject_accepts_canonical_forms`).
30897 for s in [
30898 "checkout",
30899 "events",
30900 "checkout/$orderId",
30901 "users:{tenant}/{id}",
30902 "session.<sid>",
30903 "session.tokens.<sid>",
30904 "snake_case_key",
30905 "kebab-case-key",
30906 "MixedCase",
30907 "shard0",
30908 "v2/key",
30909 "users/caf%C3%A9",
30910 ] {
30911 is_wasi_keyvalue_slot(s)
30912 .unwrap_or_else(|e| panic!("canonical kv slot {s:?} must pass: {e:?}"));
30913 }
30914 }
30915
30916 #[test]
30917 fn wasi_kv_slot_rejects_each_arm_with_substring_pinned_reason() {
30918 // Substrate-side diagnostic-shape pin: each grammar arm
30919 // surfaces its own distinct reason substring. Pinned here so
30920 // a future reason-wording rephrase that drops any of these
30921 // substrings surfaces at this one place, not piecemeal across
30922 // every per-axis test sweep. Mirrors
30923 // `nats_subject_rejects_each_arm_with_substring_pinned_reason`
30924 // and `gateway_api_http_path_rejects_each_arm_with_substring_pinned_reason`
30925 // on the peer predicates.
30926 for (s, needle) in [
30927 // Raw space inside the template — the canonical paste-from-
30928 // doc footgun.
30929 ("check out/$order", "whitespace"),
30930 // Tab byte — distinct arm-pinned reason from the space arm.
30931 ("check\tout", "whitespace"),
30932 // Control character (SOH = 0x01) — pinned separately from
30933 // the whitespace arm so a future relaxation that admits
30934 // raw whitespace but still rejects controls surfaces here.
30935 ("checkout/\x01order", "control character"),
30936 // Newline — the canonical "the paste-from-binary slug
30937 // spans multiple lines" footgun. Distinct from the
30938 // whitespace arm because `\n` is a control character.
30939 ("checkout\norder", "control character"),
30940 // DEL byte (0x7F) — the upper boundary of the control-
30941 // character range, pinned so a future relaxation that
30942 // only checks `< 0x20` surfaces here.
30943 ("checkout\x7forder", "control character"),
30944 // Un-percent-encoded non-ASCII byte — the canonical
30945 // "I copied the key from a doc with smart quotes /
30946 // accented characters" footgun. Author must percent-
30947 // encode (the canonical-forms sweep covers
30948 // `"users/caf%C3%A9"`).
30949 ("ch\u{e9}ckout/$order", "non-ASCII"),
30950 ] {
30951 let err = is_wasi_keyvalue_slot(s)
30952 .err()
30953 .unwrap_or_else(|| panic!("kv slot {s:?} must be rejected"));
30954 assert!(
30955 err.contains(needle),
30956 "kv slot {s:?} reason must contain {needle:?}; got {err:?}"
30957 );
30958 }
30959 }
30960
30961 #[test]
30962 fn wasi_kv_slot_rejects_empty_defensively() {
30963 // The predicate is called from `WitContract::target()` only
30964 // after the per-axis `ContratoSlotEmpty` arm has fired at
30965 // validate time; re-checking here keeps the predicate usable
30966 // from any future call site without an empty-precondition
30967 // footgun. Same defensive empty-check `is_dns_1123_label`,
30968 // `is_gateway_api_http_path`, `is_wit_world_ref`, and
30969 // `is_nats_subject` carry at their call sites.
30970 let err = is_wasi_keyvalue_slot("").unwrap_err();
30971 assert!(err.contains("empty"), "got: {err:?}");
30972 }
30973
30974 #[test]
30975 fn wasi_kv_slot_rejects_at_513_byte_boundary() {
30976 // The 512-byte cap pin — both the boundary-exceeding case and
30977 // the boundary-accepting case in one place, so a future cap
30978 // shift surfaces both arms simultaneously, mirroring
30979 // `dns_1123_label_rejects_at_64_byte_boundary`,
30980 // `gateway_api_http_path_rejects_at_1025_byte_boundary`,
30981 // `wit_world_ref_rejects_at_129_byte_boundary`, and
30982 // `nats_subject_rejects_at_257_byte_boundary` on the peer
30983 // predicates. Constructed as a single all-`a` token (no
30984 // separator / template syntax) so only the cap arm fires.
30985 let max_ok = "a".repeat(512);
30986 assert_eq!(max_ok.len(), 512);
30987 is_wasi_keyvalue_slot(&max_ok).unwrap();
30988 let too_long = "a".repeat(513);
30989 assert_eq!(too_long.len(), 513);
30990 let err = is_wasi_keyvalue_slot(&too_long).unwrap_err();
30991 assert!(err.contains("512"), "got: {err:?}");
30992 assert!(err.contains("513"), "got: {err:?}");
30993 }
30994
30995 #[test]
30996 fn wasi_kv_slot_admits_full_printable_ascii_range() {
30997 // Structural pin: the predicate admits every printable ASCII
30998 // byte from `0x21` (`!`) to `0x7E` (`~`) inclusive, including
30999 // every template-variable bracket the documented authoring
31000 // patterns use (`$`, `{`, `}`, `<`, `>`) and every namespace
31001 // separator (`/`, `:`, `.`, `-`, `_`). Drift here = a future
31002 // tighten that removes any byte from the admitted set surfaces
31003 // a name-the-byte test failure, not piecemeal across per-axis
31004 // sweeps. Constructed as a single all-bytes template (`b!`,
31005 // `b"`, …, `b~`) — the predicate doesn't impose structure,
31006 // only character-class.
31007 for b in 0x21u8..=0x7E {
31008 let s = std::str::from_utf8(&[b]).unwrap().to_string();
31009 is_wasi_keyvalue_slot(&s)
31010 .unwrap_or_else(|e| panic!("printable ASCII byte 0x{b:02x} must pass: {e:?}"));
31011 }
31012 }
31013
31014 #[test]
31015 fn git_ref_name_accepts_canonical_forms() {
31016 // Substrate-side pin: the predicate accepts every canonical
31017 // refname the `:fonte :tag` / `:fonte :branch` axes carry in
31018 // realistic authoring patterns (each maps to a refname `git
31019 // fetch <remote> tag '<value>'` and `git checkout '<value>'`
31020 // resolve cleanly at clone time). Drift between this list and
31021 // any per-axis positive-set sweep surfaces here — one source
31022 // of truth for the rule. Includes:
31023 // - semver tag with `v` prefix (`"v0.1.0"`, the canonical
31024 // pleme-io release shape);
31025 // - bare semver tag (`"0.1.0"`, the npm / Cargo idiom);
31026 // - pre-release tag (`"v0.1.0-alpha.1"`);
31027 // - release-line tag with hyphens (`"release-1.0"`);
31028 // - leaf branch (`"main"` / `"master"`);
31029 // - hierarchical feature branch (`"feature/checkout"`);
31030 // - multi-component branch with hyphens and digits
31031 // (`"user-1/feat-x-v2"`);
31032 // - dot-bearing tag (`"v0.1.0.rc1"`, mid-component dot
31033 // allowed — only consecutive `..` and trailing `.` are
31034 // rejected).
31035 // Mirrors the canonical-forms sweeps on the peer value-shape
31036 // predicates (`wasi_kv_slot_accepts_canonical_forms`,
31037 // `nats_subject_accepts_canonical_forms`).
31038 for s in [
31039 "v0.1.0",
31040 "0.1.0",
31041 "v0.1.0-alpha.1",
31042 "release-1.0",
31043 "main",
31044 "master",
31045 "feature/checkout",
31046 "user-1/feat-x-v2",
31047 "v0.1.0.rc1",
31048 "stable",
31049 ] {
31050 is_git_ref_name(s)
31051 .unwrap_or_else(|e| panic!("canonical git ref {s:?} must pass: {e:?}"));
31052 }
31053 }
31054
31055 #[test]
31056 fn git_ref_name_rejects_each_arm_with_substring_pinned_reason() {
31057 // Substrate-side diagnostic-shape pin: each grammar arm
31058 // surfaces its own distinct reason substring. Pinned here so
31059 // a future reason-wording rephrase that drops any of these
31060 // substrings surfaces at this one place, not piecemeal across
31061 // every per-axis test sweep. Mirrors
31062 // `wasi_kv_slot_rejects_each_arm_with_substring_pinned_reason`
31063 // and `nats_subject_rejects_each_arm_with_substring_pinned_reason`
31064 // on the peer predicates.
31065 for (s, needle) in [
31066 // Trailing space — the canonical paste-from-doc footgun.
31067 ("v0.1.0 ", "whitespace"),
31068 // Embedded space (branch with spaces).
31069 ("feature/foo bar", "whitespace"),
31070 // Tab byte.
31071 ("v0.1.0\t", "whitespace"),
31072 // Newline — the canonical "paste-from-multiline-doc"
31073 // footgun. Distinct from the whitespace arm because `\n`
31074 // is a control character.
31075 ("v0.1.0\n", "control character"),
31076 // DEL byte (0x7F) — upper boundary of the control range.
31077 ("v0.1.0\x7f", "control character"),
31078 // Non-ASCII byte (the canonical "I copied the tag from a
31079 // doc with smart quotes" footgun).
31080 ("v0.1.0\u{e9}", "non-ASCII"),
31081 // Tilde — git's revision grammar (`HEAD~3`).
31082 ("v0.1.0~1", "`~`"),
31083 // Caret — git's revision grammar (`HEAD^`).
31084 ("v0.1.0^", "`^`"),
31085 // Colon — git's refspec separator.
31086 ("v0.1.0:rebase", "`:`"),
31087 // Question mark — git's refspec glob.
31088 ("v0.1.0?", "`?`"),
31089 // Asterisk — git's refspec glob.
31090 ("v0.1.*", "`*`"),
31091 // Open bracket — git's refspec glob.
31092 ("v0.1.0[1]", "`[`"),
31093 // Backslash — the canonical Windows-path-leak footgun.
31094 ("feature\\foo", "`\\`"),
31095 // Consecutive dots — git's `<rev1>..<rev2>` range grammar.
31096 ("v0.1..0", "`..`"),
31097 // Reflog grammar.
31098 ("main@{upstream}", "`@{`"),
31099 // The bare `@` — git aliases to `HEAD`.
31100 ("@", "bare `@`"),
31101 // Leading slash.
31102 ("/main", "begin with `/`"),
31103 // Trailing slash.
31104 ("feature/", "end with `/`"),
31105 // Consecutive slashes.
31106 ("feature//foo", "consecutive `/`"),
31107 // Trailing dot.
31108 ("v0.1.0.", "end with `.`"),
31109 // Fully-qualified branch ref — the canonical
31110 // `git show-ref`-output-leak footgun.
31111 ("refs/heads/main", "fully-qualified"),
31112 // Fully-qualified tag ref.
31113 ("refs/tags/v0.1.0", "fully-qualified"),
31114 // Component beginning with `.` (per-component rule).
31115 ("feature/.hidden", "begin with `.`"),
31116 // Component ending with `.lock` (per-component rule).
31117 ("feature/main.lock", "`.lock`"),
31118 // Leaf ref named `<x>.lock` — same per-component rule on
31119 // the single-component refname.
31120 ("main.lock", "`.lock`"),
31121 // Case-insensitive `.LOCK` — APFS / NTFS / HFS+ admit
31122 // both spellings as the same on-disk file, so a
31123 // `:tag "v1.LOCK"` collides with git's atomic-rename
31124 // guard on case-insensitive filesystems. Pinned
31125 // separately from the canonical lowercase arm so a
31126 // future relaxation that only catches lowercase
31127 // surfaces here.
31128 ("v1.LOCK", "`.lock`"),
31129 ("feature/Main.Lock", "`.lock`"),
31130 ] {
31131 let err = is_git_ref_name(s)
31132 .err()
31133 .unwrap_or_else(|| panic!("git ref {s:?} must be rejected"));
31134 assert!(
31135 err.contains(needle),
31136 "git ref {s:?} reason must contain {needle:?}; got {err:?}"
31137 );
31138 }
31139 }
31140
31141 #[test]
31142 fn git_ref_name_rejects_empty_defensively() {
31143 // The predicate is called from `DepSource::validate` only
31144 // after the per-axis `FontePinEmpty` arm has fired at
31145 // validate time; re-checking here keeps the predicate usable
31146 // from any future call site without an empty-precondition
31147 // footgun. Same defensive empty-check `is_dns_1123_label`,
31148 // `is_gateway_api_http_path`, `is_wit_world_ref`,
31149 // `is_nats_subject`, and `is_wasi_keyvalue_slot` carry at
31150 // their call sites.
31151 let err = is_git_ref_name("").unwrap_err();
31152 assert!(err.contains("empty"), "got: {err:?}");
31153 }
31154
31155 #[test]
31156 fn git_ref_name_rejects_at_256_byte_boundary() {
31157 // The 255-byte cap pin — both the boundary-exceeding case and
31158 // the boundary-accepting case in one place, so a future cap
31159 // shift surfaces both arms simultaneously, mirroring
31160 // `dns_1123_label_rejects_at_64_byte_boundary`,
31161 // `gateway_api_http_path_rejects_at_1025_byte_boundary`,
31162 // `wit_world_ref_rejects_at_129_byte_boundary`,
31163 // `nats_subject_rejects_at_257_byte_boundary`, and
31164 // `wasi_kv_slot_rejects_at_513_byte_boundary` on the peer
31165 // predicates. Constructed as a single all-`a` leaf so only
31166 // the cap arm fires.
31167 let max_ok = "a".repeat(255);
31168 assert_eq!(max_ok.len(), 255);
31169 is_git_ref_name(&max_ok).unwrap();
31170 let too_long = "a".repeat(256);
31171 assert_eq!(too_long.len(), 256);
31172 let err = is_git_ref_name(&too_long).unwrap_err();
31173 assert!(err.contains("255"), "got: {err:?}");
31174 assert!(err.contains("256"), "got: {err:?}");
31175 }
31176
31177 #[test]
31178 fn git_ref_name_qualified_prefix_diagnostic_quotes_leaf() {
31179 // Diagnostic-shape pin: the `refs/heads/` / `refs/tags/`
31180 // rejection arm enumerates the leaf the author probably
31181 // meant, so the author's grep target is the *intended*
31182 // refname literal rather than the (rejected) qualified form.
31183 // Pinned across both prefixes so a future relaxation that
31184 // drops the leaf-suggestion surfaces here.
31185 for (qualified, leaf) in [
31186 ("refs/heads/main", "main"),
31187 ("refs/tags/v0.1.0", "v0.1.0"),
31188 ("refs/heads/feature/checkout", "feature/checkout"),
31189 ] {
31190 let err = is_git_ref_name(qualified).unwrap_err();
31191 assert!(
31192 err.contains(&format!("{leaf:?}")),
31193 "qualified ref {qualified:?} diagnostic must quote the leaf \
31194 {leaf:?}; got {err:?}"
31195 );
31196 }
31197 }
31198
31199 // ── is_git_ref_name canonical-OID-shape partition arm ────────────────
31200
31201 #[test]
31202 fn git_ref_name_rejects_canonical_sha1_oid() {
31203 // The fail-before-pass-after pin on the canonical SHA-1 OID
31204 // partition arm: a 40-char lowercase-hex string is the shape
31205 // `is_git_oid` accepts, so `is_git_ref_name` must reject it.
31206 // Until this arm landed `is_git_ref_name` accepted every
31207 // 40-char lowercase-hex string (pure hex carries none of the
31208 // forbidden refname characters, no `..`/`@{`/`/`-prefix/
31209 // `/`-suffix/`.lock`-suffix/`refs/heads/`-prefix), silently
31210 // breaking the cross-axis partition the
31211 // [`DepSource::validate`] gate routes the `:fonte` axes
31212 // through and admitting `:tag "deadbeef…"` /
31213 // `:branch "deadbeef…"` as legitimate refnames — the
31214 // canonical paste-from-`git show --format=%H` mis-slot
31215 // footgun. The diagnostic names the `:rev` axis so the author
31216 // grep-fixes in one edit.
31217 for oid in [
31218 "0123456789abcdef0123456789abcdef01234567",
31219 "deadbeefcafebabe0123456789abcdef01234567",
31220 "ffffffffffffffffffffffffffffffffffffffff",
31221 "0000000000000000000000000000000000000000",
31222 ] {
31223 assert_eq!(oid.len(), GIT_OID_SHA1_LEN);
31224 let err = is_git_ref_name(oid).unwrap_err();
31225 assert!(
31226 err.contains("OID") && err.contains(":rev"),
31227 "canonical SHA-1 OID {oid:?} must surface a diagnostic \
31228 naming OID + `:rev`; got {err:?}"
31229 );
31230 assert!(
31231 err.contains("SHA-1"),
31232 "canonical SHA-1 OID {oid:?} diagnostic must name the \
31233 hash algorithm; got {err:?}"
31234 );
31235 }
31236 }
31237
31238 #[test]
31239 fn git_ref_name_rejects_canonical_sha256_oid() {
31240 // The fail-before-pass-after pin on the canonical SHA-256 OID
31241 // partition arm — Git 2.42+ `extensions.objectFormat = sha256`
31242 // mode. 64-char lowercase-hex strings are equally OID-shaped
31243 // and must surface the same `:rev`-axis diagnostic. Pinned
31244 // separately from SHA-1 so a future relaxation that only
31245 // catches one width surfaces here.
31246 let sha256_zeros = "0".repeat(GIT_OID_SHA256_LEN);
31247 let sha256_ones = "f".repeat(GIT_OID_SHA256_LEN);
31248 let sha256_mixed = format!("deadbeefcafebabe{}", "0123456789abcdef".repeat(3));
31249 for oid in [&sha256_zeros, &sha256_ones, &sha256_mixed] {
31250 assert_eq!(oid.len(), GIT_OID_SHA256_LEN);
31251 let err = is_git_ref_name(oid).unwrap_err();
31252 assert!(
31253 err.contains("OID") && err.contains(":rev"),
31254 "canonical SHA-256 OID {oid:?} must surface a \
31255 diagnostic naming OID + `:rev`; got {err:?}"
31256 );
31257 assert!(
31258 err.contains("SHA-256"),
31259 "canonical SHA-256 OID {oid:?} diagnostic must name \
31260 the hash algorithm; got {err:?}"
31261 );
31262 }
31263 }
31264
31265 #[test]
31266 fn git_ref_name_partition_excludes_off_by_one_lengths() {
31267 // Boundary pin: lengths that *aren't* exactly 40 or 64 hex
31268 // characters are NOT canonical OIDs, so the partition arm
31269 // must not fire — they remain accepted as refnames (consistent
31270 // with `is_git_oid` rejecting them on its exact-width check).
31271 // Abbreviated OIDs (`"c0ffee0"`, 7-char prefix) are ambiguous
31272 // across repository history and `is_git_oid` rejects them
31273 // separately, but they're legitimate refname shapes per `git
31274 // check-ref-format`, so `is_git_ref_name` accepts them here.
31275 // Pinned across the 39/41/63/65-char and abbreviated arms so
31276 // a future widening of the partition arm to "any hex-shaped
31277 // value" surfaces here as a regression rather than silently
31278 // rejecting valid refnames.
31279 for accept in [
31280 // 39 hex chars — one short of SHA-1 width.
31281 "0123456789abcdef0123456789abcdef0123456",
31282 // 41 hex chars — one over SHA-1 width.
31283 "0123456789abcdef0123456789abcdef012345670",
31284 // 63 hex chars — one short of SHA-256 width.
31285 &"a".repeat(63),
31286 // 65 hex chars — one over SHA-256 width.
31287 &"a".repeat(65),
31288 // Abbreviated 7-char SHA — the `git log --short` width.
31289 "c0ffee0",
31290 // Pure-numeric 8-char (looks vaguely SHA-shaped but
31291 // isn't canonical-width).
31292 "00000000",
31293 ] {
31294 is_git_ref_name(accept).unwrap_or_else(|e| {
31295 panic!(
31296 "off-canonical-width hex-shaped value {accept:?} \
31297 (len {len}) must still pass is_git_ref_name — \
31298 the partition arm is exact-width 40/64, not a \
31299 prefix or pattern: {e:?}",
31300 len = accept.len()
31301 )
31302 });
31303 }
31304 }
31305
31306 #[test]
31307 fn git_ref_name_partition_excludes_uppercase_canonical_widths() {
31308 // Boundary pin: the partition arm targets the canonical
31309 // *lowercase-hex* OID shape `git rev-parse HEAD` /
31310 // `git show --format=%H` emit. Uppercase or mixed-case
31311 // 40/64-char hex strings are legitimate refnames per
31312 // `git check-ref-format` (uppercase letters are admitted in
31313 // refnames), so `is_git_ref_name` accepts them here; the
31314 // `:rev` axis separately rejects uppercase OIDs via
31315 // [`is_git_oid`]'s lowercase-only contract — so neither
31316 // axis silently admits an uppercase-hex value cross-slot.
31317 // Pinned across both widths + both uppercase variants so a
31318 // future relaxation of either predicate surfaces here.
31319 for accept in [
31320 // Uppercase 40-char hex — passes is_git_ref_name (valid
31321 // refname), rejected by is_git_oid on lowercase contract.
31322 "DEADBEEFCAFEBABE0123456789ABCDEF01234567",
31323 // Mixed case 40-char hex.
31324 "DeadBeefCafeBabe0123456789abcdef01234567",
31325 // Uppercase 64-char hex.
31326 &"A".repeat(64),
31327 ] {
31328 is_git_ref_name(accept).unwrap_or_else(|e| {
31329 panic!(
31330 "uppercase canonical-width hex value {accept:?} \
31331 must still pass is_git_ref_name — the partition \
31332 arm targets lowercase-canonical only (uppercase \
31333 is a legitimate refname character per \
31334 git-check-ref-format); the `:rev` axis catches \
31335 uppercase via is_git_oid's lowercase contract: \
31336 {e:?}"
31337 )
31338 });
31339 // And confirm is_git_oid rejects it on the lowercase arm
31340 // (so neither axis silently admits the value).
31341 let oid_err = is_git_oid(accept).unwrap_err();
31342 assert!(
31343 oid_err.contains("lowercase") || oid_err.contains("uppercase"),
31344 "uppercase hex value {accept:?} must be rejected by \
31345 is_git_oid on its lowercase contract; got {oid_err:?}"
31346 );
31347 }
31348 }
31349
31350 #[test]
31351 fn git_ref_name_partition_arm_fires_before_per_byte_scan() {
31352 // Order pin: the partition arm runs after the length check
31353 // but before the per-byte refname-character scan, so a
31354 // canonical-OID-shaped value surfaces the `:rev`-axis
31355 // diagnostic rather than (e.g.) falling through to a generic
31356 // per-component arm. Pinned via a canonical OID — pure hex
31357 // can't violate any of the per-byte / `..` / `@{` / `/` /
31358 // `.lock` / `refs/heads/` arms (which is precisely why the
31359 // partition arm is needed), so position-wise this pin
31360 // forecloses a future refactor that splits the partition arm
31361 // across the scan (where uppercase / mixed-case canonical-
31362 // width values would silently route through one branch).
31363 let oid = "0123456789abcdef0123456789abcdef01234567";
31364 let err = is_git_ref_name(oid).unwrap_err();
31365 // The diagnostic mentions OID + `:rev`; it does NOT contain
31366 // any of the per-byte-arm needle substrings the
31367 // `git_ref_name_rejects_each_arm_with_substring_pinned_reason`
31368 // sweep pins, structurally — canonical OIDs can't violate
31369 // those arms.
31370 assert!(err.contains("OID"), "got: {err:?}");
31371 assert!(err.contains(":rev"), "got: {err:?}");
31372 }
31373
31374 #[test]
31375 fn git_ref_name_rejects_leading_hyphen_cli_arg_injection() {
31376 // The CLI-arg-injection arm pin on the `:tag` / `:branch` axis.
31377 // Git's `check-ref-format` grammar admits a leading `-` (the
31378 // byte is a legitimate kebab continuation), so every prior
31379 // shape arm passes the value through; the diagnostic moves
31380 // the gate to the subprocess-argument boundary the resolver
31381 // consumes. Pinned across the canonical CLI-arg-injection
31382 // shapes — short-flag-shaped `"-X"`, long-option-shaped
31383 // `"-stable"`, git-config-injection-shaped
31384 // `"-c=core.merge=ours"`, the canonical
31385 // `"--upload-pack=…"` long-flag form, and the
31386 // `"--config"`-shape repeat-arg form — every shape would
31387 // silently escape `git checkout --quiet --detach <ref>` (the
31388 // resolver's invocation in `caixa-resolver/src/git.rs:41`,
31389 // no `--` argument-list terminator) and get reinterpreted by
31390 // `git checkout`'s argument parser. Peer with the
31391 // `is_git_repo_url` leading-`-` arm (same vector on the
31392 // sibling `:repo` axis), `is_cargo_feature_name` leading-`-`
31393 // arm, and `is_dns_1123_label` leading-`-` arm — the
31394 // substrate-wide "no leading `-` anywhere in a typed
31395 // single-token string slot routed through a subprocess
31396 // argument" invariant is now structurally consistent across
31397 // every value-shape-gated typed surface.
31398 for s in [
31399 "-X", // short-flag-shape
31400 "-stable", // long-option-shape
31401 "-c=core.merge=ours", // git-config-injection-shape
31402 "--upload-pack=cat /etc", // long-flag with-value
31403 "--config", // repeat-arg shape
31404 "-", // degenerate single-byte
31405 ] {
31406 let err = is_git_ref_name(s)
31407 .err()
31408 .unwrap_or_else(|| panic!("git ref {s:?} must be rejected"));
31409 assert!(
31410 err.contains("`-`"),
31411 "git ref {s:?} reason must surface the leading-`-` arm: {err:?}"
31412 );
31413 assert!(
31414 err.contains("CLI-argument-injection"),
31415 "git ref {s:?} reason must name the CLI-argument-injection \
31416 vector: {err:?}"
31417 );
31418 }
31419 // Positive control: a mid-name `-` (the canonical kebab
31420 // separator) passes — `"v0-1-0"`, `"feature-x"`, `"main-2"`
31421 // — pinning that the arm only fires at the leading position,
31422 // not anywhere else.
31423 for s in ["v0-1-0", "feature-x", "main-2"] {
31424 is_git_ref_name(s).unwrap_or_else(|e| {
31425 panic!("mid-name `-` ref {s:?} must pass the leading-`-` arm: {e:?}")
31426 });
31427 }
31428 }
31429
31430 #[test]
31431 fn git_ref_name_leading_hyphen_fires_before_per_byte_scan() {
31432 // Cascade-precedence pin: a `"-flag\n"` value carries both a
31433 // leading `-` and an embedded `\n` control byte; the leading-`-`
31434 // arm fires first (the byte sits at the leading position the
31435 // arm probes, before the per-byte cascade loop's control-byte
31436 // arm). Mirrors the order pin
31437 // `git_ref_name_partition_arm_fires_before_per_byte_scan`
31438 // establishes on the canonical-OID partition arm — both
31439 // pre-loop arms structurally precede the per-byte scan.
31440 let err = is_git_ref_name("-flag\n").unwrap_err();
31441 assert!(err.contains("`-`"), "got: {err:?}");
31442 assert!(
31443 !err.contains("control character"),
31444 "leading-`-` arm must fire before the control-byte per-byte arm: {err:?}"
31445 );
31446 }
31447
31448 #[test]
31449 fn git_ref_name_leading_hyphen_fires_after_canonical_oid_partition() {
31450 // Cascade-precedence pin: the partition arm structurally
31451 // precedes the leading-`-` arm because a canonical OID shape
31452 // (40 / 64 lowercase hex bytes) cannot start with `-` — the
31453 // byte sets are disjoint, so the precedence pin is a no-op at
31454 // value level. The pin matters only at the diagnostic-shape
31455 // level — it ensures a future codec round-trip that
31456 // synthesizes a probe-as-both value (impossible today;
31457 // possible if the OID partition arm ever relaxes its byte
31458 // set) surfaces the more self-locating `:rev`-mis-slot
31459 // diagnostic rather than the broader CLI-arg-injection one.
31460 let oid = "0123456789abcdef0123456789abcdef01234567";
31461 let err = is_git_ref_name(oid).unwrap_err();
31462 assert!(err.contains("OID"), "got: {err:?}");
31463 assert!(
31464 !err.contains("CLI-argument-injection"),
31465 "OID partition arm must precede leading-`-` arm: {err:?}"
31466 );
31467 }
31468
31469 // ── is_git_oid — `:fonte :rev` value-shape predicate ────────────────
31470
31471 #[test]
31472 fn git_oid_canonical_widths_match_sha1_and_sha256() {
31473 // The single-source-of-truth pin on the two canonical widths.
31474 // Drift between the predicate's accepted widths and the const
31475 // values would surface here as a build error, not as a silent
31476 // round-trip break at the renderer layer. Mirrors
31477 // `wasm32_memory_cap_matches_parsed_4_gib` (9d49a3a) — the
31478 // constant equality pin keeps the contract one place.
31479 assert_eq!(GIT_OID_SHA1_LEN, 40);
31480 assert_eq!(GIT_OID_SHA256_LEN, 64);
31481 // Doubled width: SHA-256 is exactly twice SHA-1 in hex char
31482 // count (256 / 4 = 64; 160 / 4 = 40). Pinned so a future
31483 // hash-algorithm widening reads the relationship here.
31484 assert_eq!(GIT_OID_SHA256_LEN, GIT_OID_SHA1_LEN * 2 - 16);
31485 }
31486
31487 #[test]
31488 fn git_oid_accepts_canonical_sha1() {
31489 // Positive control on the SHA-1 OID width: 40 lowercase hex
31490 // characters — the canonical `git rev-parse HEAD` emission
31491 // shape every realistic pleme-io upstream uses today. The all-
31492 // `f` boundary is the lexicographically-largest OID (a real
31493 // commit's hash could land here, and the predicate accepts it
31494 // because it's structurally a valid OID — the null-OID
31495 // sentinel arm partitions the all-`0` boundary only, not the
31496 // all-`f` one).
31497 is_git_oid("0123456789abcdef0123456789abcdef01234567").unwrap();
31498 is_git_oid("deadbeefcafebabe0123456789abcdef01234567").unwrap();
31499 is_git_oid("ffffffffffffffffffffffffffffffffffffffff").unwrap();
31500 }
31501
31502 #[test]
31503 fn git_oid_accepts_canonical_sha256() {
31504 // Positive control on the SHA-256 OID width: 64 lowercase hex
31505 // characters — `git`'s `extensions.objectFormat = sha256`
31506 // emission (GA since Git 2.42 / Oct 2023). Doubled SHA-1 width.
31507 let sha256_one = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
31508 assert_eq!(sha256_one.len(), 64);
31509 is_git_oid(sha256_one).unwrap();
31510 let sha256_fs = "f".repeat(64);
31511 is_git_oid(&sha256_fs).unwrap();
31512 }
31513
31514 #[test]
31515 fn git_oid_rejects_null_oid_sentinel_sha1() {
31516 // Canonical "I copy-pasted the no-such-commit sentinel out of
31517 // `git update-ref --stdin` docs / pre-receive hook example"
31518 // footgun on the SHA-1 width — the all-zero 40-char hex
31519 // string is git's `null OID` sentinel (used to indicate ref
31520 // create / delete in update-ref flows) and never names a real
31521 // commit in any repo's object database. Until the null-OID
31522 // arm landed it passed every other shape arm (canonical
31523 // length, lowercase hex) and surfaced at `git fetch <remote>
31524 // 0000…0000` time with a quoting-confused "couldn't find
31525 // remote ref" error far from the source caixa.lisp, with the
31526 // lacre's content-address locked to a `git:0000…0000` closure
31527 // that never equals any upstream's actual `HEAD`. The
31528 // diagnostic carries the `40` width verbatim so a future
31529 // SHA-256 fixture surfaces the same arm at the doubled width
31530 // boundary.
31531 let null_sha1 = "0".repeat(40);
31532 let err = is_git_oid(&null_sha1).unwrap_err();
31533 assert!(
31534 err.contains("null-OID sentinel"),
31535 "reason must name the sentinel: {err}",
31536 );
31537 assert!(err.contains("40"), "reason must name the width: {err}",);
31538 assert!(
31539 err.contains("no-such-commit") || err.contains("update-ref"),
31540 "reason must reference git's null-OID semantics: {err}",
31541 );
31542 }
31543
31544 #[test]
31545 fn git_oid_rejects_null_oid_sentinel_sha256() {
31546 // Same sentinel on the SHA-256 width — `git`'s
31547 // `extensions.objectFormat = sha256` mode (GA Git 2.42 / Oct
31548 // 2023) carries the same null-OID semantics on the doubled
31549 // 64-char width. Pinned separately so a future relaxation that
31550 // only catches the SHA-1 width surfaces here, peer with the
31551 // SHA-1 / SHA-256 pair-pinning posture
31552 // `git_oid_accepts_canonical_sha1` /
31553 // `git_oid_accepts_canonical_sha256` already establishes for
31554 // the positive controls.
31555 let null_sha256 = "0".repeat(64);
31556 let err = is_git_oid(&null_sha256).unwrap_err();
31557 assert!(
31558 err.contains("null-OID sentinel"),
31559 "reason must name the sentinel: {err}",
31560 );
31561 assert!(err.contains("64"), "reason must name the width: {err}",);
31562 }
31563
31564 #[test]
31565 fn git_oid_null_oid_fires_after_length_and_hex_arms() {
31566 // Cascade-precedence pin: the null-OID arm runs *after* the
31567 // length + character-class arms, so an off-by-one-length all-
31568 // zeros value surfaces the narrower `abbreviated` diagnostic
31569 // (the length arm's own reason wording) before the structural
31570 // null-OID diagnostic, and an uppercase all-zeros value (which
31571 // can't actually exist — `0` has no case — but pinned via the
31572 // mixed-case-but-non-null fixture) routes the same way. The
31573 // null-OID arm is the *fourth* arm, structurally the
31574 // lexicographic-content-arm after length and per-byte
31575 // character-class.
31576 let off_by_one_zeros = "0".repeat(41);
31577 let err = is_git_oid(&off_by_one_zeros).unwrap_err();
31578 assert!(
31579 err.contains("abbreviated"),
31580 "off-by-one-length all-zeros surfaces length arm first: {err}",
31581 );
31582 // The all-`f` 40-char value — same boundary class as null-OID
31583 // but at the opposite hex extreme — passes the predicate,
31584 // confirming the null-OID arm doesn't over-fire on lexicographic
31585 // boundaries.
31586 is_git_oid("ffffffffffffffffffffffffffffffffffffffff").unwrap();
31587 }
31588
31589 #[test]
31590 fn git_oid_rejects_empty_defensively() {
31591 // The predicate is called from `crate::dep::DepSource::validate`
31592 // only after the per-axis `FontePinEmpty` arm has fired at
31593 // validate time; re-checking here keeps the predicate usable
31594 // from any future call site without an empty-precondition
31595 // footgun. Same defensive empty-check `is_dns_1123_label`,
31596 // `is_gateway_api_http_path`, `is_wit_world_ref`,
31597 // `is_nats_subject`, `is_wasi_keyvalue_slot`, and
31598 // `is_git_ref_name` carry at their call sites.
31599 let err = is_git_oid("").unwrap_err();
31600 assert!(err.contains("empty"), "got: {err:?}");
31601 }
31602
31603 #[test]
31604 fn git_oid_rejects_each_arm_with_substring_pinned_reason() {
31605 // Substrate-side diagnostic-shape pin: each grammar arm
31606 // surfaces its own distinct reason substring. Pinned here so a
31607 // future reason-wording rephrase that drops any of these
31608 // substrings surfaces at this one place, not piecemeal across
31609 // every per-axis test sweep. Mirrors
31610 // `git_ref_name_rejects_each_arm_with_substring_pinned_reason`,
31611 // `wasi_kv_slot_rejects_each_arm_with_substring_pinned_reason`,
31612 // and `nats_subject_rejects_each_arm_with_substring_pinned_reason`
31613 // on the peer predicates.
31614 for (s, needle) in [
31615 // Abbreviated 7-char prefix — the canonical `git log
31616 // --short` paste-from-release-notes footgun.
31617 ("c0ffee0", "abbreviated"),
31618 // Abbreviated 12-char prefix — `git log --short=12`.
31619 ("c0ffee001234", "abbreviated"),
31620 // Off-by-one above SHA-1 width.
31621 ("0123456789abcdef0123456789abcdef012345670", "abbreviated"),
31622 // Off-by-one below SHA-256 width.
31623 (
31624 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcde",
31625 "abbreviated",
31626 ),
31627 // Off-by-one above SHA-256 width.
31628 (
31629 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0",
31630 "abbreviated",
31631 ),
31632 // Uppercase SHA-1 — `git porcelain` lowercases on output.
31633 ("DEADBEEFCAFEBABE0123456789ABCDEF01234567", "uppercase"),
31634 // Mixed-case SHA-1 — same path as pure-uppercase; the first
31635 // uppercase byte fires the arm.
31636 ("deadbeefCAFEbabe0123456789abcdef01234567", "uppercase"),
31637 // Non-hex character at exact SHA-1 length — the cross-axis
31638 // mis-slot footgun (a refname-style char landing in `:rev`).
31639 // `g` is the first non-hex byte; the non-hex arm fires
31640 // ahead of any other rule. The hyphen / colon / slash arms
31641 // are the same path on the same predicate.
31642 ("g123456789abcdef0123456789abcdef01234567", "non-hex"),
31643 ("0123456789abcdef-123456789abcdef01234567", "non-hex"),
31644 ("0123456789abcdef/123456789abcdef01234567", "non-hex"),
31645 ("0123456789abcdef:123456789abcdef01234567", "non-hex"),
31646 // Whitespace inside an otherwise-SHA-shaped value (length
31647 // 41 — fails the length arm first; pinned to ensure the
31648 // diagnostic surfaces *some* parser wording).
31649 ("0123456789abcdef0123456789abcdef01234567 ", "abbreviated"),
31650 ] {
31651 let err = is_git_oid(s)
31652 .err()
31653 .unwrap_or_else(|| panic!("git OID {s:?} must be rejected"));
31654 assert!(
31655 err.contains(needle),
31656 "git OID {s:?} reason must contain {needle:?}; got {err:?}"
31657 );
31658 }
31659 }
31660
31661 #[test]
31662 fn git_oid_rejects_at_canonical_width_boundaries() {
31663 // Boundary pin on the two canonical widths simultaneously: 39
31664 // (below SHA-1), 40 (SHA-1 exactly), 41 (just above), 63 (just
31665 // below SHA-256), 64 (SHA-256 exactly), 65 (just above). Pinned
31666 // so a future relaxation that admits "close enough" widths
31667 // surfaces here. The failing-length fixtures use all-zero hex
31668 // so only the length arm fires (the null-OID sentinel arm is
31669 // structurally downstream of the length arm — a non-canonical
31670 // length fires the abbreviated diagnostic before the null
31671 // diagnostic). The passing-length fixtures use a non-null hex
31672 // value so the null-OID arm doesn't fire (the all-zero
31673 // canonical-width value is the sentinel and is rejected by its
31674 // own arm, pinned in `git_oid_rejects_null_oid_sentinel_*`).
31675 let nonzero_sha1 = "0123456789abcdef0123456789abcdef01234567";
31676 assert_eq!(nonzero_sha1.len(), 40);
31677 let nonzero_sha256 = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef";
31678 assert_eq!(nonzero_sha256.len(), 64);
31679 for (len, ok) in [
31680 (1usize, false),
31681 (7, false),
31682 (39, false),
31683 (40, true),
31684 (41, false),
31685 (63, false),
31686 (64, true),
31687 (65, false),
31688 (128, false),
31689 ] {
31690 let s = if ok && len == 40 {
31691 nonzero_sha1.to_string()
31692 } else if ok && len == 64 {
31693 nonzero_sha256.to_string()
31694 } else {
31695 "0".repeat(len)
31696 };
31697 let result = is_git_oid(&s);
31698 if ok {
31699 result.unwrap_or_else(|e| panic!("len {len} must pass: {e:?}"));
31700 } else {
31701 let err = result.expect_err(&format!("len {len} must fail"));
31702 assert!(
31703 err.contains("abbreviated") || err.contains(&len.to_string()),
31704 "len {len} reason must name the offending length or surface \
31705 the abbreviation arm, got {err:?}"
31706 );
31707 }
31708 }
31709 }
31710
31711 #[test]
31712 fn git_oid_rejection_is_disjoint_from_ref_name_acceptance() {
31713 // Structural pin: the two predicates partition the `:fonte`
31714 // pin axes — every canonical refname is rejected by
31715 // `is_git_oid`, and every canonical OID is rejected by
31716 // `is_git_ref_name`. The intersection of the two valid sets
31717 // is exactly the empty set. Drift here = a value that passes
31718 // both predicates would land at *both* axes silently, defeating
31719 // the structural "cross-axis mis-slot is a build error"
31720 // contract. Pinned with a representative cross-set so a future
31721 // predicate weakening surfaces here.
31722 let canonical_refnames = [
31723 "v0.1.0",
31724 "main",
31725 "feature/checkout",
31726 "release-1.0",
31727 "user-1/feat-x-v2",
31728 ];
31729 for refname in canonical_refnames {
31730 is_git_ref_name(refname).unwrap_or_else(|e| {
31731 panic!("setup: canonical refname {refname:?} must pass is_git_ref_name: {e:?}")
31732 });
31733 assert!(
31734 is_git_oid(refname).is_err(),
31735 "canonical refname {refname:?} must NOT pass is_git_oid \
31736 (predicate-partition pin)"
31737 );
31738 }
31739 let canonical_oids = [
31740 "0123456789abcdef0123456789abcdef01234567",
31741 "deadbeefcafebabe0123456789abcdef01234567",
31742 "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
31743 ];
31744 for oid in canonical_oids {
31745 is_git_oid(oid).unwrap_or_else(|e| {
31746 panic!("setup: canonical OID {oid:?} must pass is_git_oid: {e:?}")
31747 });
31748 assert!(
31749 is_git_ref_name(oid).is_err(),
31750 "canonical OID {oid:?} must NOT pass is_git_ref_name \
31751 (predicate-partition pin)"
31752 );
31753 }
31754 }
31755
31756 // ── is_sandboxed_relative_path — `:behavior :on-*` + `:upgrade-from ─
31757 // ── :state-change :script` value-shape predicate ────────────────────
31758
31759 #[test]
31760 fn sandboxed_relative_path_accepts_canonical_relative_paths() {
31761 // Positive controls: every documented authoring shape across
31762 // the two existing call sites (`:behavior :on-init` / `:on-call`
31763 // / `:on-cast` / `:on-info` / `:on-state-change` / `:on-terminate`
31764 // and `:upgrade-from :state-change :script`) — bare filename,
31765 // standard `lib/` subdirectory, deeply-nested migrations
31766 // subdirectory, sibling-folder-shaped path, and explicit
31767 // current-dir-relative-prefixed path. Pin every leg so a
31768 // future tightening that rejects any of these (e.g. demanding
31769 // a `lib/` prefix specifically, or forbidding the explicit
31770 // `./` segment) surfaces here as a test-failure at the predicate
31771 // boundary, not piecemeal across per-axis call sites.
31772 for relpath in [
31773 "init.lisp",
31774 "lib/init.lisp",
31775 "lib/handlers.lisp",
31776 "lib/migrations/v01-to-v02.lisp",
31777 "callbacks/on_call.lisp",
31778 "./lib/init.lisp",
31779 "a",
31780 ] {
31781 is_sandboxed_relative_path(Path::new(relpath)).unwrap_or_else(|v| {
31782 panic!("canonical relative path {relpath:?} must pass, got {v:?}")
31783 });
31784 }
31785 }
31786
31787 #[test]
31788 fn sandboxed_relative_path_rejects_empty() {
31789 // The fail-before-pass-after pin on the empty arm. Both
31790 // `PathBuf::new()` (no bytes) and `PathBuf::from("")` (empty
31791 // string) hit the `as_os_str().is_empty()` precondition; both
31792 // resolve to `root` under `root.join(p)` and silently point the
31793 // `LisleLoader` at the project directory rather than a file.
31794 assert_eq!(
31795 is_sandboxed_relative_path(Path::new("")),
31796 Err(PathShapeViolation::Empty)
31797 );
31798 let blank = PathBuf::new();
31799 assert_eq!(
31800 is_sandboxed_relative_path(&blank),
31801 Err(PathShapeViolation::Empty)
31802 );
31803 }
31804
31805 #[test]
31806 fn sandboxed_relative_path_rejects_absolute() {
31807 // The fail-before-pass-after pin on the absolute arm. Sweep
31808 // the canonical sandbox-escape paste-from-shell-prompt
31809 // footguns: an `/etc/...` Lunatic-style sandbox bypass, a
31810 // user-home leak that the renderer's `root.join(p)` would
31811 // silently replace, the project-relative-shaped `/lib/...`
31812 // typo where the author meant `lib/...` without a leading
31813 // slash, and the bare root `/`. `Path::join` replaces the
31814 // base with an absolute right-hand side, so every one of
31815 // these resolves verbatim to outside the caixa root regardless
31816 // of where the layout checker rooted itself.
31817 for abs in [
31818 "/etc/passwd",
31819 "/home/user/escape.lisp",
31820 "/lib/init.lisp",
31821 "/",
31822 ] {
31823 assert_eq!(
31824 is_sandboxed_relative_path(Path::new(abs)),
31825 Err(PathShapeViolation::Absolute),
31826 "absolute path {abs:?} must surface as PathShapeViolation::Absolute"
31827 );
31828 }
31829 }
31830
31831 #[test]
31832 fn sandboxed_relative_path_rejects_parent_escape_at_every_position() {
31833 // The fail-before-pass-after pin on the parent-escape arm.
31834 // Position sweep — `..` as a leading component (the canonical
31835 // "I meant the sibling caixa" mis-author), as a mid-path
31836 // component (the canonical "lib/../../escape" path-traversal
31837 // that's structurally identical regardless of how many `..`
31838 // segments stack), as a trailing component (lib/.., resolving
31839 // to the project root via a delayed escape), and the bare `..`
31840 // (project parent directory). Each must surface as
31841 // `PathShapeViolation::ParentEscape` regardless of position —
31842 // pinned per-position so a future relaxation that only
31843 // checks one position surfaces at this one place, not
31844 // piecemeal across per-axis call sites.
31845 for escape in [
31846 "../sibling/init.lisp",
31847 "lib/../../escaped.lisp",
31848 "lib/..",
31849 "..",
31850 "lib/handlers/../../escape.lisp",
31851 ] {
31852 assert_eq!(
31853 is_sandboxed_relative_path(Path::new(escape)),
31854 Err(PathShapeViolation::ParentEscape),
31855 "parent-escape path {escape:?} must surface as \
31856 PathShapeViolation::ParentEscape"
31857 );
31858 }
31859 }
31860
31861 #[test]
31862 fn sandboxed_relative_path_arm_ordering_is_empty_absolute_parent_escape() {
31863 // Order pin: the predicate evaluates Empty → Absolute →
31864 // ParentEscape — the same arm-ordering both inlined call sites
31865 // followed verbatim (b0c8389 `BehaviorSpec::validate`'s
31866 // `validate_callback_path`, 26da2c7
31867 // `UpgradeInstruction::StateChange::validate`). A future
31868 // reordering would silently flip which diagnostic the per-axis
31869 // wrapper surfaces (e.g. an absolute-and-empty hybrid value
31870 // would suddenly raise `Absolute` instead of `Empty`). Pinned
31871 // here so a future reorder surfaces at the predicate boundary.
31872 //
31873 // The empty case can't *also* be absolute (empty paths are
31874 // relative-by-construction) or parent-escaping, so the
31875 // empty-first ordering only matters relative to the OS-string
31876 // emptiness check vs. the absolute-prefix check. Pin the two
31877 // legs that *can* compose: an absolute path with `..` segments
31878 // must raise `Absolute` (not `ParentEscape`); an absolute-but-
31879 // not-parent-escaping path must also raise `Absolute`. The
31880 // arm-ordering pin is structural — every parent-escape case
31881 // tested above is relative, so the ParentEscape arm is reached
31882 // only when both Empty and Absolute arms have been cleared.
31883 assert_eq!(
31884 is_sandboxed_relative_path(Path::new("/etc/../passwd")),
31885 Err(PathShapeViolation::Absolute),
31886 "absolute path with `..` segments must surface as Absolute (not \
31887 ParentEscape) — Empty → Absolute → ParentEscape arm-ordering pin"
31888 );
31889 }
31890
31891 #[test]
31892 fn sandboxed_relative_path_distinguishes_curdir_from_parent_escape() {
31893 // Boundary pin: `Component::CurDir` (`.`) is NOT a sandbox
31894 // escape — `root.join("./lib/x.lisp")` resolves to
31895 // `root/lib/x.lisp`, identical to `root.join("lib/x.lisp")`,
31896 // so `./` segments must pass the predicate. The arm-ordering
31897 // check above pins that `Component::ParentDir` is the only
31898 // escape vector caught here. Pinned separately so a future
31899 // tightening that *does* reject `.` segments (e.g. requiring
31900 // canonical normalized form) lands at this one predicate.
31901 is_sandboxed_relative_path(Path::new("./lib/init.lisp")).unwrap();
31902 is_sandboxed_relative_path(Path::new("lib/./handlers.lisp")).unwrap();
31903 }
31904
31905 #[test]
31906 fn sandboxed_relative_path_violations_are_distinct_variants() {
31907 // Diagnostic-shape pin: the three `PathShapeViolation` variants
31908 // are distinct enum tags so each per-axis caller can match-and-
31909 // wrap into its own typed `*Path` / `*Script` variant without
31910 // a string-parse step (the trap [`is_dns_1123_label`] etc.
31911 // avoid by returning `Result<(), String>` — but the path-shape
31912 // callers were already split three ways across `BehaviorError`
31913 // / `UpgradeError`, so a `String` return would *regress* the
31914 // diagnostic shape rather than preserve it). The PartialEq /
31915 // Copy / Hash derives on `PathShapeViolation` are pinned here
31916 // so a future API rework reads the requirement off this test.
31917 let v1 = PathShapeViolation::Empty;
31918 let v2 = PathShapeViolation::Absolute;
31919 let v3 = PathShapeViolation::ParentEscape;
31920 assert_ne!(v1, v2);
31921 assert_ne!(v2, v3);
31922 assert_ne!(v1, v3);
31923 // Copy + Eq round-trip: predicate consumers like
31924 // `BehaviorSpec::validate` and `UpgradeInstruction::validate`
31925 // pattern-match on the variant without consuming it.
31926 let v_copy = v1;
31927 assert_eq!(v1, v_copy);
31928 }
31929
31930 #[test]
31931 fn sandboxed_relative_path_matches_inlined_call_site_semantics() {
31932 // End-to-end pin: every value the two pre-lift inline gates
31933 // (`BehaviorSpec::validate_callback_path` and
31934 // `UpgradeInstruction::StateChange::validate`'s inline arms)
31935 // accepted-or-rejected must surface from the lifted predicate
31936 // with identically-classified violation tags. Drift here would
31937 // mean a previously-accepted authoring shape would suddenly
31938 // fail (or vice versa) silently across the lift commit. Pinned
31939 // by sweeping the canonical authoring shapes both pre-lift call
31940 // sites' tests cover.
31941 // Pre-lift accepts (must still pass):
31942 for accept in [
31943 "lib/init.lisp",
31944 "lib/handlers.lisp",
31945 "lib/migrations.lisp",
31946 "lib/cleanup.lisp",
31947 "lib/migrations/v01-to-v02.lisp",
31948 "callbacks/handle_call.lisp",
31949 ] {
31950 is_sandboxed_relative_path(Path::new(accept))
31951 .unwrap_or_else(|v| panic!("pre-lift accept {accept:?} regressed, got {v:?}"));
31952 }
31953 // Pre-lift rejects (must still reject, with the same tag):
31954 let cases: &[(&str, PathShapeViolation)] = &[
31955 ("", PathShapeViolation::Empty),
31956 ("/etc/passwd", PathShapeViolation::Absolute),
31957 ("/etc/migrations.lisp", PathShapeViolation::Absolute),
31958 (
31959 "../sibling/migrations.lisp",
31960 PathShapeViolation::ParentEscape,
31961 ),
31962 ("lib/../../escaped.lisp", PathShapeViolation::ParentEscape),
31963 ];
31964 for (reject, expected) in cases {
31965 assert_eq!(
31966 is_sandboxed_relative_path(Path::new(reject)).unwrap_err(),
31967 *expected,
31968 "pre-lift reject {reject:?} must classify as {expected:?}"
31969 );
31970 }
31971 }
31972
31973 #[test]
31974 fn path_shape_violation_all_lists_every_variant_in_declaration_order() {
31975 // Fail-before-pass-after pin on the paired
31976 // [`PathShapeViolation::ALL`] exhaustive-iteration surface.
31977 // Two axes in one assertion, both must hold:
31978 //
31979 // (1) The slice enumerates every arm in the closed
31980 // three-arm discriminator set exactly once, in
31981 // declaration order (`Empty` → `Absolute` →
31982 // `ParentEscape`) — the arm-ordering the
31983 // [`is_sandboxed_relative_path`] gate + every per-axis
31984 // caller in [`crate::manifest::ManifestError`] preserve
31985 // for diagnostic-precedence continuity. A future variant
31986 // addition (a `Symlink` arm the future symlink-escape
31987 // gate would raise, a `TrailingSpace` arm a future
31988 // whitespace-hygiene gate would surface) that lands on
31989 // the enum without extending `ALL` trips this test at
31990 // build time rather than surfacing as a silent
31991 // under-coverage across every downstream sweep.
31992 //
31993 // (2) For every arm in the slice, exactly one of the
31994 // [`gen_platform::IsVariant`]-derive-generated `is_*`
31995 // predicates returns `true` and the other two return
31996 // `false` — the partition property every peer closed-set
31997 // enum's `IsVariant` derive carries
31998 // ([`crate::CaixaKind`] at kind.rs,
31999 // [`crate::supervisor::RestartStrategy`] +
32000 // [`crate::supervisor::RestartPolicy`] at supervisor.rs,
32001 // [`crate::upgrade::UpgradeInstruction`] at upgrade.rs,
32002 // [`crate::aplicacao::PlacementStrategy`] +
32003 // [`crate::aplicacao::RateLimitUnit`] at aplicacao.rs,
32004 // [`crate::dep::DepList`] at dep.rs). A future variant
32005 // addition that lands on the enum without threading a
32006 // new column into the per-arm-partition assertion table
32007 // trips here at build time.
32008 assert_eq!(
32009 PathShapeViolation::ALL,
32010 &[
32011 PathShapeViolation::Empty,
32012 PathShapeViolation::Absolute,
32013 PathShapeViolation::ParentEscape,
32014 ],
32015 "PathShapeViolation::ALL must list every arm in \
32016 declaration order (Empty → Absolute → ParentEscape) — \
32017 the arm-ordering is_sandboxed_relative_path and every \
32018 per-axis ManifestError caller preserve for \
32019 diagnostic-precedence continuity"
32020 );
32021 let rows: [(PathShapeViolation, [bool; 3]); 3] = [
32022 (PathShapeViolation::Empty, [true, false, false]),
32023 (PathShapeViolation::Absolute, [false, true, false]),
32024 (PathShapeViolation::ParentEscape, [false, false, true]),
32025 ];
32026 for (variant, expected) in rows {
32027 let observed = [
32028 variant.is_empty(),
32029 variant.is_absolute(),
32030 variant.is_parent_escape(),
32031 ];
32032 assert_eq!(
32033 observed, expected,
32034 "PathShapeViolation::{variant:?} is_* predicates must \
32035 partition the arm set (empty, absolute, parent_escape); \
32036 got {observed:?}"
32037 );
32038 }
32039 }
32040
32041 #[test]
32042 fn path_shape_violation_predicates_are_byte_equal_to_matches_family() {
32043 // Byte-equal pin on the [`gen_platform::IsVariant`]-derive-
32044 // generated per-arm predicate family. For every arm on the
32045 // closed three-arm [`PathShapeViolation`] discriminator, each
32046 // per-arm `is_*` predicate must agree byte-for-byte with the
32047 // hand-rolled `matches!(_, PathShapeViolation::…)` shape a
32048 // future consumer (a `feira lint --explain-path-shape=<axis>`
32049 // per-arm listing, a future symlink-escape / whitespace-hygiene
32050 // gate that keys off "is this a sandbox-escape arm" boolean, a
32051 // future single-arm `matches!` in a downstream renderer that
32052 // treats `Empty` distinctly from the other two) would
32053 // otherwise open-code at each caller. A future rebrand (a
32054 // `#[is_variant(name = "…")]` attribute drift on the derive,
32055 // an accidental peer predicate that shadows the derive-generated
32056 // one, a hand-rolled `impl PathShapeViolation` block that
32057 // shadows one of the derive-generated methods) trips this test
32058 // the moment the two paths' bytes diverge. Peer of the sibling
32059 // `caixa_kind_is_variant_predicates_partition_the_arm_set`
32060 // (kind.rs) and every peer closed-set-enum byte-equal pin.
32061 for &variant in PathShapeViolation::ALL {
32062 assert_eq!(
32063 variant.is_empty(),
32064 matches!(variant, PathShapeViolation::Empty),
32065 "PathShapeViolation::{variant:?}.is_empty() must agree \
32066 with matches!(_, PathShapeViolation::Empty)"
32067 );
32068 assert_eq!(
32069 variant.is_absolute(),
32070 matches!(variant, PathShapeViolation::Absolute),
32071 "PathShapeViolation::{variant:?}.is_absolute() must agree \
32072 with matches!(_, PathShapeViolation::Absolute)"
32073 );
32074 assert_eq!(
32075 variant.is_parent_escape(),
32076 matches!(variant, PathShapeViolation::ParentEscape),
32077 "PathShapeViolation::{variant:?}.is_parent_escape() must agree \
32078 with matches!(_, PathShapeViolation::ParentEscape)"
32079 );
32080 }
32081 }
32082
32083 // ── is_lisp_extension — `:behavior :on-*` + `:upgrade-from ───────────
32084 // ── :state-change :script` file-type predicate ───────────────────────
32085
32086 #[test]
32087 fn lisp_extension_accepts_canonical_shapes() {
32088 // Positive controls: every documented authoring shape across
32089 // both existing call sites — bare filename, standard `lib/`
32090 // subdirectory, deeply-nested migrations subdirectory,
32091 // explicit current-dir-relative prefix, mid-path `./`
32092 // segment, single-letter stem, and the multi-dot stem
32093 // (`lib/migrations/v.0.1.lisp`) an author might use to
32094 // encode the migration's `:from` version into the filename.
32095 // The predicate only inspects the terminating extension —
32096 // `Path::extension()` returns the substring after the final
32097 // `.` — so the multi-dot stem is structurally accepted
32098 // because the final extension is still `lisp`. Drift here =
32099 // a future tightening that rejects any of these surfaces as
32100 // a test-failure at the predicate boundary, not piecemeal
32101 // across per-axis call sites (`BehaviorSpec::validate`,
32102 // `UpgradeInstruction::StateChange::validate`).
32103 for relpath in [
32104 "init.lisp",
32105 "lib/init.lisp",
32106 "lib/handlers.lisp",
32107 "lib/migrations.lisp",
32108 "lib/migrations/v01-to-v02.lisp",
32109 "./lib/init.lisp",
32110 "lib/./handlers.lisp",
32111 "lib/migrations/v.0.1.lisp",
32112 "a.lisp",
32113 ] {
32114 assert!(
32115 is_lisp_extension(Path::new(relpath)),
32116 "canonical `.lisp` shape {relpath:?} must pass is_lisp_extension"
32117 );
32118 }
32119 }
32120
32121 #[test]
32122 fn lisp_extension_rejects_no_extension() {
32123 // The fail-before-pass-after pin on the no-extension shape.
32124 // A path with no `.` component (`Path::extension()` returns
32125 // `None`) is the canonical "I declared the slot but forgot
32126 // the `.lisp` extension" authoring footgun. The wasm-engine's
32127 // `tatara_lisp::read` consumer can't infer the file type from
32128 // the path alone, so the gate refuses the value at validate
32129 // time.
32130 for relpath in [
32131 "lib/init",
32132 "init",
32133 "lib/handlers",
32134 "lib/migrations/v01-to-v02",
32135 "a",
32136 ] {
32137 assert!(
32138 !is_lisp_extension(Path::new(relpath)),
32139 "no-extension shape {relpath:?} must fail is_lisp_extension"
32140 );
32141 }
32142 }
32143
32144 #[test]
32145 fn lisp_extension_rejects_wrong_extension() {
32146 // Wrong-extension sweep: the canonical authoring footguns
32147 // an author might drag in from the workspace tree (`.txt`,
32148 // `.md`, `.json`, `.yaml`, `.toml`), the `.rs` shape that
32149 // an IDE auto-complete might propose, the `.lisp.bak` shape
32150 // an editor might leave behind (the predicate only inspects
32151 // the *terminating* extension — `Path::extension()` returns
32152 // `bak` here, not `lisp.bak` — so the gate refuses it as a
32153 // no-`.lisp` final extension), and the `.lispx` / `.lis`
32154 // near-miss shapes that a typo would produce. Each must
32155 // fail the predicate — the wasm-engine's `tatara_lisp::read`
32156 // consumer rejects all of these at hot-upgrade migration /
32157 // instance-start time.
32158 for relpath in [
32159 "lib/init.rs",
32160 "lib/init.txt",
32161 "lib/init.md",
32162 "lib/init.json",
32163 "lib/init.yaml",
32164 "lib/init.toml",
32165 "lib/init.lisp.bak",
32166 "lib/init.lispx",
32167 "lib/init.lis",
32168 ] {
32169 assert!(
32170 !is_lisp_extension(Path::new(relpath)),
32171 "wrong-extension shape {relpath:?} must fail is_lisp_extension"
32172 );
32173 }
32174 }
32175
32176 #[test]
32177 fn lisp_extension_is_case_sensitive() {
32178 // Strict lowercase pin: every case-folded shape a
32179 // case-insensitive volume's existence check would match the
32180 // on-disk file must still fail the predicate — the
32181 // canonical-form codec emits lowercase `.lisp` verbatim, so
32182 // a case-folded shape mismatches the round-trip-stable
32183 // canonical form (THEORY.md §V.2.7 render-determinism).
32184 // Same case-sensitive discipline the byte-size / duration
32185 // codecs and every other shape-gate predicate in `render.rs`
32186 // (label / scheme / unit boundaries) carry. Pinned at the
32187 // predicate boundary so any future case-folding regression
32188 // surfaces here rather than piecemeal across per-axis call
32189 // sites.
32190 for relpath in [
32191 "lib/init.LISP",
32192 "lib/init.Lisp",
32193 "lib/init.LiSp",
32194 "lib/init.lISP",
32195 "lib/init.LISp",
32196 ] {
32197 assert!(
32198 !is_lisp_extension(Path::new(relpath)),
32199 "case-folded `.lisp` shape {relpath:?} must fail is_lisp_extension \
32200 (strict lowercase, render-determinism pin)"
32201 );
32202 }
32203 }
32204
32205 #[test]
32206 fn lisp_extension_constant_matches_predicate() {
32207 // Cross-pin: the [`LISP_SOURCE_EXTENSION`] const and the
32208 // predicate's accepted set are the same single source of
32209 // truth. Drift would let a future renderer / per-axis
32210 // wrapper emit `.<const>` while the predicate accepts only
32211 // `.lisp` (or vice versa), silently breaking the
32212 // round-trip-stable canonical form. Pinned by constructing
32213 // a path from the const and round-tripping through the
32214 // predicate.
32215 assert_eq!(LISP_SOURCE_EXTENSION, "lisp");
32216 let p = PathBuf::from(format!("lib/init.{LISP_SOURCE_EXTENSION}"));
32217 assert!(
32218 is_lisp_extension(&p),
32219 "path constructed from LISP_SOURCE_EXTENSION must pass is_lisp_extension"
32220 );
32221 }
32222
32223 #[test]
32224 fn lisp_extension_matches_inlined_call_site_semantics() {
32225 // End-to-end pin: every value the pre-lift inline gate
32226 // (`BehaviorSpec::validate_callback_path`, c97815a) accepted-
32227 // or-rejected must surface from the lifted predicate
32228 // identically. Drift here would mean a previously-accepted
32229 // authoring shape would suddenly fail (or vice versa)
32230 // silently across the lift commit. Sweeps the canonical
32231 // authoring shapes the pre-lift call site's tests covered
32232 // verbatim.
32233 // Pre-lift accepts (must still pass):
32234 for accept in [
32235 "lib/init.lisp",
32236 "lib/handlers.lisp",
32237 "lib/migrations/v01-to-v02.lisp",
32238 "init.lisp",
32239 "a.lisp",
32240 "./lib/init.lisp",
32241 "lib/./handlers.lisp",
32242 "lib/migrations/v.0.1.lisp",
32243 ] {
32244 assert!(
32245 is_lisp_extension(Path::new(accept)),
32246 "pre-lift accept {accept:?} regressed"
32247 );
32248 }
32249 // Pre-lift rejects (must still reject):
32250 for reject in [
32251 "lib/init",
32252 "init",
32253 "lib/init.rs",
32254 "lib/init.txt",
32255 "lib/init.lisp.bak",
32256 "lib/init.lispx",
32257 "lib/init.LISP",
32258 "lib/init.Lisp",
32259 ] {
32260 assert!(
32261 !is_lisp_extension(Path::new(reject)),
32262 "pre-lift reject {reject:?} regressed"
32263 );
32264 }
32265 }
32266
32267 // ── is_computeunit_yaml_extension — `:servicos` compound-suffix predicate ───
32268
32269 #[test]
32270 fn computeunit_yaml_extension_accepts_canonical_shapes() {
32271 // Positive controls: every canonical authoring shape every
32272 // in-tree fixture and the `Caixa::template` scaffold use. The
32273 // predicate inspects the final file-name component and checks
32274 // for the compound `.computeunit.yaml` suffix with at least
32275 // one byte of stem preceding it.
32276 for relpath in [
32277 "servicos/demo.computeunit.yaml",
32278 "servicos/hello-rio.computeunit.yaml",
32279 "servicos/my-service.computeunit.yaml",
32280 "servicos/a.computeunit.yaml",
32281 "./servicos/demo.computeunit.yaml",
32282 "servicos/./demo.computeunit.yaml",
32283 "servicos/sub/nested.computeunit.yaml",
32284 "servicos/v0.1.computeunit.yaml",
32285 ] {
32286 assert!(
32287 is_computeunit_yaml_extension(Path::new(relpath)),
32288 "canonical `.computeunit.yaml` shape {relpath:?} must pass \
32289 is_computeunit_yaml_extension"
32290 );
32291 }
32292 }
32293
32294 #[test]
32295 fn computeunit_yaml_extension_rejects_no_extension() {
32296 // No-extension shape — the canonical "I declared the slot
32297 // but forgot the `.computeunit.yaml` suffix" footgun. The
32298 // peer caixa-helm / caixa-flux `serde_yaml::from_str`
32299 // consumer can't infer the file type from the path alone, so
32300 // the gate refuses the value at validate time.
32301 for relpath in ["servicos/demo", "demo", "servicos/sub/nested"] {
32302 assert!(
32303 !is_computeunit_yaml_extension(Path::new(relpath)),
32304 "no-extension shape {relpath:?} must fail \
32305 is_computeunit_yaml_extension"
32306 );
32307 }
32308 }
32309
32310 #[test]
32311 fn computeunit_yaml_extension_rejects_wrong_extension() {
32312 // Wrong-extension sweep across the canonical authoring footguns
32313 // an author might drag in from the workspace tree — bare
32314 // `.yaml` (the canonical "I forgot the `.computeunit` segment"
32315 // typo), `.yml` (Helm-shorthand leak), `.json` (FluxCD
32316 // bundle leak), `.toml` (Cargo workspace leak), `.txt`
32317 // / `.md` (paste-from-doc footguns), `.yaml.bak` (editor
32318 // backup), the near-miss `.computeunit.yam` / `.computeunit.yamls`
32319 // typo, and the off-by-one-segment `computeunit-yaml`
32320 // / `computeunit_yaml` shapes. Each must fail the predicate.
32321 for relpath in [
32322 "servicos/demo.yaml",
32323 "servicos/demo.yml",
32324 "servicos/demo.json",
32325 "servicos/demo.toml",
32326 "servicos/demo.txt",
32327 "servicos/demo.md",
32328 "servicos/demo.computeunit.yaml.bak",
32329 "servicos/demo.computeunit.yam",
32330 "servicos/demo.computeunit.yamls",
32331 "servicos/demo.computeunit",
32332 "servicos/demo-computeunit.yaml",
32333 "servicos/demo_computeunit.yaml",
32334 ] {
32335 assert!(
32336 !is_computeunit_yaml_extension(Path::new(relpath)),
32337 "wrong-extension shape {relpath:?} must fail \
32338 is_computeunit_yaml_extension"
32339 );
32340 }
32341 }
32342
32343 #[test]
32344 fn computeunit_yaml_extension_is_case_sensitive() {
32345 // Strict lowercase pin: every case-folded shape a
32346 // case-insensitive volume's existence check would match the
32347 // on-disk file must still fail the predicate — the canonical-
32348 // form codec emits lowercase `.computeunit.yaml` verbatim, so
32349 // a case-folded shape mismatches the round-trip-stable
32350 // canonical form (THEORY.md §V.2.7 render-determinism). Same
32351 // case-sensitive discipline the byte-size / duration codecs
32352 // and the peer `is_lisp_extension` predicate carry.
32353 for relpath in [
32354 "servicos/demo.ComputeUnit.yaml",
32355 "servicos/demo.COMPUTEUNIT.yaml",
32356 "servicos/demo.computeunit.YAML",
32357 "servicos/demo.computeunit.Yaml",
32358 "servicos/demo.COMPUTEUNIT.YAML",
32359 ] {
32360 assert!(
32361 !is_computeunit_yaml_extension(Path::new(relpath)),
32362 "case-folded `.computeunit.yaml` shape {relpath:?} must fail \
32363 is_computeunit_yaml_extension (strict lowercase, \
32364 render-determinism pin)"
32365 );
32366 }
32367 }
32368
32369 #[test]
32370 fn computeunit_yaml_extension_rejects_empty_stem() {
32371 // Degenerate hidden-file shape: a file name exactly equal to
32372 // the suffix (`.computeunit.yaml` — no stem preceding the
32373 // suffix) is the structural "Servico declared with no
32374 // identity" footgun. The substrate identifies each ComputeUnit
32375 // by the file-stem segment that precedes `.computeunit.yaml`
32376 // (the rendered `lareira-<stem>` Helm chart, the per-Servico
32377 // `metadata.name`, the M3 `:contratos` membership lookup), so
32378 // an empty stem leaves the Servico unidentifiable. Predicate
32379 // pin: the `name.len() > SUFFIX.len()` bound rejects the
32380 // hidden-file shape at the predicate boundary.
32381 for relpath in [".computeunit.yaml", "servicos/.computeunit.yaml"] {
32382 assert!(
32383 !is_computeunit_yaml_extension(Path::new(relpath)),
32384 "empty-stem shape {relpath:?} must fail \
32385 is_computeunit_yaml_extension"
32386 );
32387 }
32388 }
32389
32390 #[test]
32391 fn computeunit_yaml_extension_constant_matches_predicate() {
32392 // Cross-pin: the [`COMPUTEUNIT_YAML_SUFFIX`] const and the
32393 // predicate's accepted set are the same single source of
32394 // truth. Drift would let a future renderer / per-axis wrapper
32395 // emit `<stem><const>` while the predicate accepts only
32396 // `.computeunit.yaml` (or vice versa), silently breaking the
32397 // round-trip-stable canonical form. Pinned by constructing a
32398 // path from the const and round-tripping through the
32399 // predicate. Mirrors the peer
32400 // `lisp_extension_constant_matches_predicate` pin.
32401 assert_eq!(COMPUTEUNIT_YAML_SUFFIX, ".computeunit.yaml");
32402 let p = PathBuf::from(format!("servicos/demo{COMPUTEUNIT_YAML_SUFFIX}"));
32403 assert!(
32404 is_computeunit_yaml_extension(&p),
32405 "path constructed from COMPUTEUNIT_YAML_SUFFIX must pass \
32406 is_computeunit_yaml_extension"
32407 );
32408 }
32409
32410 // ── is_cargo_feature_name — shared `:caracteristicas` feature-name predicate ──
32411
32412 #[test]
32413 fn cargo_feature_name_accepts_canonical_forms() {
32414 // Substrate-side pin: the predicate accepts every canonical Cargo
32415 // feature name shape `:caracteristicas` entries carry. Drift between
32416 // this list and the per-axis `dep::tests::validate_accepts_canonical_caracteristicas`
32417 // positive-set sweep surfaces here — one source of truth for the
32418 // rule. Includes single-token (`http`), kebab-case (`runtime-tokio`),
32419 // snake-case (`derive_macros`), namespaced-dot (`tokio.full`),
32420 // version-suffix (`v0.1`), `+`-separated (`http+json`), leading
32421 // underscore (`_internal`), doubled-underscore (`__private`),
32422 // and digit-starting (`v0_1`) — the canonical authoring shapes
32423 // every realistic Cargo feature in the pleme-io ecosystem uses.
32424 for s in [
32425 "http",
32426 "json",
32427 "derive",
32428 "serde",
32429 "serde_json",
32430 "runtime-tokio",
32431 "tokio.full",
32432 "v0.1",
32433 "v1",
32434 "http+json",
32435 "_internal",
32436 "__private",
32437 "default",
32438 "rt-multi-thread",
32439 "12factor",
32440 "feat.v2",
32441 "client+server",
32442 ] {
32443 is_cargo_feature_name(s)
32444 .unwrap_or_else(|e| panic!("canonical Cargo feature name {s:?} must pass: {e:?}"));
32445 }
32446 }
32447
32448 #[test]
32449 fn cargo_feature_name_rejects_each_arm_with_substring_pinned_reason() {
32450 // Substrate-side diagnostic-shape pin: each grammar arm
32451 // surfaces its own distinct reason substring. Pinned here so a
32452 // future reason-wording rephrase that drops any of these
32453 // substrings surfaces at this one place, not piecemeal across
32454 // every per-axis test sweep. Mirrors
32455 // `git_repo_url`'s and `git_ref_name`'s arm-substring sweeps
32456 // on the peer predicates.
32457 for (s, needle) in [
32458 // Leading `+` — the canonical paste-from-`+optional-feature`
32459 // activation-form-in-feature-name-slot footgun.
32460 ("+http", "`+`"),
32461 // Leading `-` — kebab-leak / CLI-arg-injection adjacent.
32462 ("-json", "`-`"),
32463 // Leading `.` — dotted-version-suffix-as-feature-name typo.
32464 (".feat", "`.`"),
32465 // Whitespace inside — multi-token blob.
32466 ("http feature", "whitespace"),
32467 // Tab inside.
32468 ("http\tjson", "whitespace"),
32469 // Leading whitespace — paste-from-aligned-doc.
32470 (" http", "whitespace"),
32471 // Comma — list-separator-belongs-to-list-grammar.
32472 ("http,json", "`,`"),
32473 // Forward slash — Cargo's `dep/feat` namespaced-dep syntax.
32474 ("http/json", "`/`"),
32475 // Question mark — URL-reserved.
32476 ("http?", "`?`"),
32477 // Hash — URL-reserved.
32478 ("http#frag", "`#`"),
32479 // Embedded control character.
32480 ("http\x01json", "control character"),
32481 // Newline — paste-from-multiline-doc.
32482 ("http\njson", "control character"),
32483 // DEL byte (0x7F).
32484 ("http\x7fjson", "control character"),
32485 // Non-ASCII byte — un-percent-encoded character.
32486 ("caf\u{e9}", "non-ASCII"),
32487 // Non-ASCII at first byte.
32488 ("\u{e9}feat", "non-ASCII"),
32489 // Forbidden punctuation in the continuation set.
32490 ("http@1", "invalid character"),
32491 ("http&json", "invalid character"),
32492 ("http=v1", "invalid character"),
32493 ] {
32494 let err = is_cargo_feature_name(s)
32495 .err()
32496 .unwrap_or_else(|| panic!("Cargo feature name {s:?} must be rejected"));
32497 assert!(
32498 err.contains(needle),
32499 "Cargo feature name {s:?} reason must contain {needle:?}; got {err:?}"
32500 );
32501 }
32502 }
32503
32504 #[test]
32505 fn cargo_feature_name_rejects_empty_defensively() {
32506 // The predicate is called from `crate::dep::Dep::validate_caracteristicas`
32507 // only after the per-axis `CaracteristicaEmpty` arm has fired
32508 // at validate time; re-checking here keeps the predicate usable
32509 // from any future call site without an empty-precondition
32510 // footgun. Same defensive empty-check `is_dns_1123_label`,
32511 // `is_gateway_api_http_path`, `is_wit_world_ref`,
32512 // `is_nats_subject`, `is_wasi_keyvalue_slot`, `is_git_ref_name`,
32513 // `is_git_oid`, and `is_git_repo_url` carry at their call sites.
32514 let err = is_cargo_feature_name("").unwrap_err();
32515 assert!(err.contains("empty"), "got: {err:?}");
32516 }
32517
32518 #[test]
32519 fn cargo_feature_name_rejects_at_65_byte_boundary() {
32520 // The 64-byte cap pin — both the boundary-exceeding case and
32521 // the boundary-accepting case in one place, so a future cap
32522 // shift surfaces both arms simultaneously, mirroring
32523 // `dns_1123_label_rejects_at_64_byte_boundary`,
32524 // `gateway_api_http_path_rejects_at_1025_byte_boundary`,
32525 // `wit_world_ref_rejects_at_129_byte_boundary`,
32526 // `nats_subject_rejects_at_257_byte_boundary`,
32527 // `wasi_kv_slot_rejects_at_513_byte_boundary`, and
32528 // `git_ref_name_rejects_at_256_byte_boundary` on the peer
32529 // predicates. Constructed as a single all-`a` token so only
32530 // the cap arm fires.
32531 let max_ok = "a".repeat(CARGO_FEATURE_NAME_MAX_LEN);
32532 assert_eq!(max_ok.len(), 64);
32533 is_cargo_feature_name(&max_ok).unwrap();
32534 let too_long = "a".repeat(CARGO_FEATURE_NAME_MAX_LEN + 1);
32535 assert_eq!(too_long.len(), 65);
32536 let err = is_cargo_feature_name(&too_long).unwrap_err();
32537 assert!(err.contains("64"), "got: {err:?}");
32538 assert!(err.contains("65"), "got: {err:?}");
32539 }
32540
32541 #[test]
32542 fn cargo_feature_name_first_byte_diagnostics_name_the_leading_char() {
32543 // Diagnostic-shape pin: the leading-character rejection arms
32544 // name the specific punctuation (`+`, `-`, `.`) verbatim so the
32545 // author's grep target is unambiguous. Pinned across the three
32546 // canonical leading-char footguns so a future relaxation that
32547 // drops any of the three surfaces here. The `+`-arm's wording
32548 // additionally points the author at the canonical Cargo
32549 // `+<feature>` activation-form-vs-feature-name discipline so
32550 // the paste-from-doc footgun lands its remediation in the
32551 // diagnostic itself.
32552 let err_plus = is_cargo_feature_name("+http").unwrap_err();
32553 assert!(err_plus.contains("`+`"), "got: {err_plus:?}");
32554 assert!(
32555 err_plus.contains("activation"),
32556 "got: {err_plus:?} (must name the Cargo +<feature> activation-form)"
32557 );
32558 let err_hyphen = is_cargo_feature_name("-json").unwrap_err();
32559 assert!(err_hyphen.contains("`-`"), "got: {err_hyphen:?}");
32560 let err_dot = is_cargo_feature_name(".feat").unwrap_err();
32561 assert!(err_dot.contains("`.`"), "got: {err_dot:?}");
32562 }
32563
32564 // ── is_spdx_expression_shape — shared `:licenca` SPDX-expression predicate ──
32565
32566 #[test]
32567 fn spdx_expression_shape_accepts_canonical_forms() {
32568 // Substrate-side pin: the predicate accepts every canonical
32569 // SPDX expression shape the `:licenca` axis carries. Drift
32570 // between this list and the per-axis
32571 // `manifest::tests::validate_licenca_accepts_canonical_expressions`
32572 // positive-set sweep surfaces here — one source of truth for
32573 // the rule. Covers single-license, `OR`/`AND`-compound,
32574 // `WITH`-exception, parenthesis-grouped, `+`-suffix, and
32575 // `LicenseRef-` / `DocumentRef-:LicenseRef-` shapes.
32576 for s in [
32577 "MIT",
32578 "Apache-2.0",
32579 "BSD-3-Clause",
32580 "MPL-2.0",
32581 "GPL-3.0-or-later",
32582 "GPL-2.0+",
32583 "Apache-2.0 OR MIT",
32584 "Apache-2.0 AND MIT",
32585 "Apache-2.0 WITH LLVM-exception",
32586 "(MIT OR Apache-2.0) AND BSD-3-Clause",
32587 "(MIT OR Apache-2.0) AND BSD-3-Clause AND ISC",
32588 "LicenseRef-MyLicense",
32589 "DocumentRef-spdx-tool:LicenseRef-MIT-Style",
32590 "x",
32591 ] {
32592 is_spdx_expression_shape(s)
32593 .unwrap_or_else(|e| panic!("canonical SPDX expression {s:?} must pass: {e:?}"));
32594 }
32595 }
32596
32597 #[test]
32598 fn spdx_expression_shape_rejects_each_arm_with_substring_pinned_reason() {
32599 // Substrate-side diagnostic-shape pin: each alphabet arm
32600 // surfaces its own distinct reason substring. Pinned here so a
32601 // future reason-wording rephrase that drops any of these
32602 // substrings surfaces at this one place, not piecemeal across
32603 // every per-axis test sweep. Mirrors
32604 // `cargo_feature_name_rejects_each_arm_with_substring_pinned_reason`
32605 // on the peer predicate.
32606 for (s, needle) in [
32607 // Leading whitespace — paste-from-aligned-doc.
32608 (" MIT", "whitespace"),
32609 // Trailing whitespace — paste-from-doc.
32610 ("MIT ", "whitespace"),
32611 // Tab inside — tab-from-aligned-doc.
32612 ("MIT\tOR Apache-2.0", "tab"),
32613 // Embedded control character.
32614 ("MIT\x01OR Apache-2.0", "control character"),
32615 // Newline — paste-from-multiline-doc.
32616 ("MIT\nOR Apache-2.0", "control character"),
32617 // CRLF — paste-from-multiline-doc.
32618 ("MIT\rApache-2.0", "control character"),
32619 // DEL byte (0x7F).
32620 ("MIT\x7fApache-2.0", "control character"),
32621 // Non-ASCII byte — smart-quote paste.
32622 ("MIT\u{a0}OR Apache-2.0", "non-ASCII"),
32623 // Non-ASCII at first byte — fullwidth letter.
32624 ("\u{ff2d}IT", "non-ASCII"),
32625 // Underscore — snake-case-instead-of-kebab-case typo.
32626 ("Apache_2.0", "`_`"),
32627 // Comma — list-separator-belongs-to-list-grammar.
32628 ("MIT, Apache-2.0", "`,`"),
32629 // Forward slash — colloquial dual-license idiom.
32630 ("MIT/Apache-2.0", "`/`"),
32631 // Semicolon — list-separator confusion.
32632 ("MIT; Apache-2.0", "`;`"),
32633 // Forbidden punctuation in the alphabet.
32634 ("MIT@1.0", "invalid character"),
32635 ("MIT&Apache-2.0", "invalid character"),
32636 ("MIT=Apache-2.0", "invalid character"),
32637 ("MIT*1.0", "invalid character"),
32638 ] {
32639 let err = is_spdx_expression_shape(s)
32640 .err()
32641 .unwrap_or_else(|| panic!("SPDX expression {s:?} must be rejected"));
32642 assert!(
32643 err.contains(needle),
32644 "SPDX expression {s:?} reason must contain {needle:?}; got {err:?}"
32645 );
32646 }
32647 }
32648
32649 #[test]
32650 fn spdx_expression_shape_rejects_empty_defensively() {
32651 // The predicate is called from `crate::Caixa::validate_licenca`
32652 // only after the per-axis `LicencaEmpty` arm has fired at
32653 // validate time; re-checking here keeps the predicate usable
32654 // from any future call site without an empty-precondition
32655 // footgun. Same defensive empty-check `is_dns_1123_label`,
32656 // `is_gateway_api_http_path`, `is_wit_world_ref`,
32657 // `is_nats_subject`, `is_wasi_keyvalue_slot`,
32658 // `is_git_ref_name`, `is_git_oid`, `is_git_repo_url`, and
32659 // `is_cargo_feature_name` carry at their call sites.
32660 let err = is_spdx_expression_shape("").unwrap_err();
32661 assert!(err.contains("empty"), "got: {err:?}");
32662 }
32663
32664 #[test]
32665 fn spdx_expression_shape_rejects_at_257_byte_boundary() {
32666 // The 256-byte cap pin — both the boundary-exceeding case and
32667 // the boundary-accepting case in one place, so a future cap
32668 // shift surfaces both arms simultaneously, mirroring the peer
32669 // cap-boundary pins. Constructed as a single all-`a` token so
32670 // only the cap arm fires (256 `a` bytes is alphabet-valid).
32671 let max_ok = "a".repeat(SPDX_EXPRESSION_MAX_LEN);
32672 assert_eq!(max_ok.len(), 256);
32673 is_spdx_expression_shape(&max_ok).unwrap();
32674 let too_long = "a".repeat(SPDX_EXPRESSION_MAX_LEN + 1);
32675 assert_eq!(too_long.len(), 257);
32676 let err = is_spdx_expression_shape(&too_long).unwrap_err();
32677 assert!(err.contains("256"), "got: {err:?}");
32678 assert!(err.contains("257"), "got: {err:?}");
32679 }
32680
32681 // ── is_chart_description_shape — shared `:descricao` chart-description predicate ──
32682
32683 #[test]
32684 fn chart_description_shape_accepts_canonical_forms() {
32685 // Substrate-side pin: the predicate accepts every canonical
32686 // chart-description shape the `:descricao` axis carries.
32687 // Drift between this list and the per-axis
32688 // `manifest::tests::validate_descricao_accepts_canonical_summary`
32689 // positive-set sweep surfaces here — one source of truth for
32690 // the rule. Covers ASCII summaries, the Unicode `→` from the
32691 // canonical Rust→wasm fixture, and the Unicode `—` em-dash
32692 // from the `Caixa::template` scaffold every `feira init`
32693 // emits.
32694 for s in [
32695 "Canonical Rust→wasm32-wasip2 caixa Servico.",
32696 "Checkout flow.",
32697 "AWS provider caixa for tatara-lisp",
32698 "FIXME — describe this caixa",
32699 "x",
32700 ] {
32701 is_chart_description_shape(s)
32702 .unwrap_or_else(|e| panic!("canonical chart description {s:?} must pass: {e:?}"));
32703 }
32704 }
32705
32706 #[test]
32707 fn chart_description_shape_rejects_each_arm_with_substring_pinned_reason() {
32708 // Substrate-side diagnostic-shape pin: each arm surfaces its
32709 // own distinct reason substring. Pinned here so a future
32710 // reason-wording rephrase that drops any of these substrings
32711 // surfaces at this one place, not piecemeal across every
32712 // per-axis test sweep. Mirrors
32713 // `spdx_expression_shape_rejects_each_arm_with_substring_pinned_reason`
32714 // on the peer predicate.
32715 for (s, needle) in [
32716 // Leading whitespace — paste-from-aligned-doc.
32717 (" Checkout flow.", "whitespace"),
32718 // Trailing whitespace — paste-from-doc.
32719 ("Checkout flow. ", "whitespace"),
32720 // Tab inside — tab-from-aligned-doc.
32721 ("Checkout\tflow.", "tab"),
32722 // Newline — paste-from-multiline-doc.
32723 ("Checkout\nflow.", "newline"),
32724 // Carriage return — paste-from-Windows-CRLF-doc.
32725 ("Checkout\rflow.", "carriage return"),
32726 // NUL byte — paste-from-binary-blob.
32727 ("Checkout\x00flow.", "control character"),
32728 // BEL byte — paste-from-binary-blob.
32729 ("Checkout\x07flow.", "control character"),
32730 // ESC byte — paste-from-binary-blob.
32731 ("Checkout\x1bflow.", "control character"),
32732 // DEL byte (0x7F).
32733 ("Checkout\x7fflow.", "control character"),
32734 ] {
32735 let err = is_chart_description_shape(s)
32736 .err()
32737 .unwrap_or_else(|| panic!("chart description {s:?} must be rejected"));
32738 assert!(
32739 err.contains(needle),
32740 "chart description {s:?} reason must contain {needle:?}; got {err:?}"
32741 );
32742 }
32743 }
32744
32745 #[test]
32746 fn chart_description_shape_accepts_unicode() {
32747 // Positive control on the non-ASCII arm: the predicate must
32748 // accept Unicode beyond the ASCII alphabet — the canonical
32749 // pleme-io descricao fixtures carry `→` (U+2192) and `—`
32750 // (U+2014), and every downstream consumer (YAML 1.2, Helm v3,
32751 // every chart-aware UI) round-trips Unicode losslessly.
32752 // Mirrors the spdx-rejects-non-ASCII arm by inverting it — a
32753 // future tightening that bans non-ASCII bytes would regress
32754 // every canonical fixture and surface here as a regression.
32755 for s in [
32756 "Canonical Rust→wasm32-wasip2",
32757 "FIXME — describe this caixa",
32758 "Caixa pour le projet tâche",
32759 "日本語の説明",
32760 "naïve",
32761 ] {
32762 is_chart_description_shape(s)
32763 .unwrap_or_else(|e| panic!("Unicode chart description {s:?} must pass: {e:?}"));
32764 }
32765 }
32766
32767 #[test]
32768 fn chart_description_shape_rejects_empty_defensively() {
32769 // The predicate is called from `crate::Caixa::validate_descricao`
32770 // only after the per-axis `DescricaoEmpty` arm has fired at
32771 // validate time; re-checking here keeps the predicate usable
32772 // from any future call site without an empty-precondition
32773 // footgun. Same defensive empty-check `is_dns_1123_label`,
32774 // `is_gateway_api_http_path`, `is_wit_world_ref`,
32775 // `is_nats_subject`, `is_wasi_keyvalue_slot`,
32776 // `is_git_ref_name`, `is_git_oid`, `is_git_repo_url`,
32777 // `is_cargo_feature_name`, and `is_spdx_expression_shape`
32778 // carry at their call sites.
32779 let err = is_chart_description_shape("").unwrap_err();
32780 assert!(err.contains("empty"), "got: {err:?}");
32781 }
32782
32783 #[test]
32784 fn chart_description_shape_rejects_at_513_byte_boundary() {
32785 // The 512-byte cap pin — both the boundary-exceeding case and
32786 // the boundary-accepting case in one place, so a future cap
32787 // shift surfaces both arms simultaneously, mirroring the peer
32788 // cap-boundary pins. Constructed as a single all-`a` token so
32789 // only the cap arm fires (512 `a` bytes is alphabet-valid).
32790 let max_ok = "a".repeat(CHART_DESCRIPTION_MAX_LEN);
32791 assert_eq!(max_ok.len(), 512);
32792 is_chart_description_shape(&max_ok).unwrap();
32793 let too_long = "a".repeat(CHART_DESCRIPTION_MAX_LEN + 1);
32794 assert_eq!(too_long.len(), 513);
32795 let err = is_chart_description_shape(&too_long).unwrap_err();
32796 assert!(err.contains("512"), "got: {err:?}");
32797 assert!(err.contains("513"), "got: {err:?}");
32798 }
32799
32800 #[test]
32801 fn chart_description_shape_rejects_each_unicode_bidi_override_codepoint() {
32802 // The Trojan Source (CVE-2021-42574) arm — pins every UAX #9
32803 // bidirectional-override / isolate format codepoint as a
32804 // structural rejection on the typed `:descricao` axis. The
32805 // per-byte non-ASCII pass deliberately admits Unicode letters
32806 // / em-dash / arrows because the canonical fixtures carry them
32807 // (`Canonical Rust→wasm32-wasip2`, `FIXME — describe this
32808 // caixa`); only the typed codepoint scan catches the nine
32809 // bidi-override codepoints that flip the rendered visual order
32810 // of every following character, so a future drop of any one
32811 // arm here surfaces as a `must be rejected` panic at this one
32812 // place rather than as a silent regression downstream. Each
32813 // case carries an alphabet-valid prefix + suffix so only the
32814 // bidi-override arm fires.
32815 for (cp, name) in [
32816 ('\u{202A}', "U+202A"),
32817 ('\u{202B}', "U+202B"),
32818 ('\u{202C}', "U+202C"),
32819 ('\u{202D}', "U+202D"),
32820 ('\u{202E}', "U+202E"),
32821 ('\u{2066}', "U+2066"),
32822 ('\u{2067}', "U+2067"),
32823 ('\u{2068}', "U+2068"),
32824 ('\u{2069}', "U+2069"),
32825 ] {
32826 let s = format!("alice{cp}bob");
32827 let err = is_chart_description_shape(&s)
32828 .err()
32829 .unwrap_or_else(|| panic!("chart description with {name} must be rejected"));
32830 assert!(
32831 err.contains(name),
32832 "chart description reason for {name} must name the codepoint verbatim; got {err:?}"
32833 );
32834 assert!(
32835 err.contains("bidirectional-override")
32836 || err.contains("Unicode bidi")
32837 || err.contains("Trojan Source"),
32838 "chart description reason for {name} must name the Trojan-Source banner; \
32839 got {err:?}"
32840 );
32841 }
32842 }
32843
32844 #[test]
32845 fn chart_description_shape_accepts_pure_rtl_text_without_bidi_override() {
32846 // Positive control on the bidi-override arm: pure visual
32847 // right-to-left scripts (Hebrew, Arabic) decode to non-bidi-
32848 // override codepoints and the predicate must accept them
32849 // natively — banning all RTL would regress every Hebrew /
32850 // Arabic-authored caixa, which the substrate explicitly
32851 // supports via the non-ASCII byte arm. The structural axis the
32852 // bidi-override arm closes is the explicit direction-mark
32853 // codepoint, not the RTL script itself.
32854 for s in [
32855 // Hebrew word (RTL script, no bidi-override codepoint).
32856 "שלום",
32857 // Arabic word (RTL script, no bidi-override codepoint).
32858 "مرحبا",
32859 // Mixed LTR / RTL caixa — the canonical multilingual
32860 // description shape every YAML 1.2 + Helm v3 + Artifact
32861 // Hub consumer round-trips losslessly.
32862 "Caixa para שלום",
32863 ] {
32864 is_chart_description_shape(s).unwrap_or_else(|e| {
32865 panic!("pure-RTL chart description {s:?} must pass without bidi override: {e:?}")
32866 });
32867 }
32868 }
32869
32870 #[test]
32871 fn chart_description_shape_rejects_each_unicode_line_break_codepoint() {
32872 // The non-ASCII Unicode line-break arm — pins each of the three
32873 // UAX #14 / YAML 1.1 §4.1 line-break codepoints outside the
32874 // ASCII `\n` / `\r` bytes already caught at the per-byte pass.
32875 // Each case carries an alphabet-valid prefix + suffix so only
32876 // the line-break arm fires; the per-byte `\n` / `\r` arms
32877 // would shadow the codepoint scan if the line-break helper
32878 // accepted single-byte ASCII line terminators. A future drop
32879 // of any one arm here surfaces as a `must be rejected` panic
32880 // at this one place rather than as a silent regression
32881 // through YAML 1.1-compat downstream consumers (go-yaml v2 /
32882 // Helm v3 / kubectl). Mirrors the peer
32883 // `chart_maintainer_name_shape_rejects_each_unicode_line_break_codepoint`
32884 // on the sibling predicate — both predicates route through the
32885 // same lifted `find_unicode_line_break` helper.
32886 for (cp, name) in [
32887 ('\u{0085}', "U+0085"),
32888 ('\u{2028}', "U+2028"),
32889 ('\u{2029}', "U+2029"),
32890 ] {
32891 let s = format!("first line{cp}second line");
32892 let err = is_chart_description_shape(&s)
32893 .err()
32894 .unwrap_or_else(|| panic!("chart description with {name} must be rejected"));
32895 assert!(
32896 err.contains(name),
32897 "chart description reason for {name} must name the codepoint verbatim; got {err:?}"
32898 );
32899 assert!(
32900 err.contains("line-break") || err.contains("UAX #14") || err.contains("YAML 1.1"),
32901 "chart description reason for {name} must name the Unicode-line-break banner; \
32902 got {err:?}"
32903 );
32904 }
32905 }
32906
32907 #[test]
32908 fn chart_description_shape_accepts_non_line_break_unicode() {
32909 // Positive control on the line-break arm: the predicate must
32910 // accept every non-line-break Unicode shape the canonical
32911 // fixtures carry. Pinned alongside the per-codepoint rejection
32912 // sweep so a future helper widening that accidentally rejects
32913 // a non-line-break codepoint (the structural-floor regression
32914 // class) surfaces here as a single-source-of-truth pin. The
32915 // canonical multilingual descriptions, RTL text, em-dash and
32916 // arrows must all pass.
32917 for s in [
32918 "Canonical Rust→wasm32-wasip2 caixa Servico.",
32919 "FIXME — describe this caixa",
32920 "Caixa para שלום",
32921 "日本語の説明テスト",
32922 // U+00A0 NO-BREAK SPACE is NOT a line-break codepoint
32923 // (UAX #14 class GL — Glue, non-breaking) — must pass.
32924 "Caixa\u{00A0}for tests",
32925 ] {
32926 is_chart_description_shape(s).unwrap_or_else(|e| {
32927 panic!(
32928 "non-line-break Unicode chart description {s:?} must pass without rejection: \
32929 {e:?}"
32930 )
32931 });
32932 }
32933 }
32934
32935 #[test]
32936 fn chart_description_shape_rejects_each_unicode_invisible_format_codepoint() {
32937 // The Unicode invisible-format arm — pins each of the eight
32938 // BMP Cf-category zero-width codepoints with no visible glyph
32939 // in any conforming font. The per-byte non-ASCII pass
32940 // deliberately admits multi-byte UTF-8 sequences (Unicode
32941 // letters / arrows / em-dash are canonical fixtures); only the
32942 // typed codepoint scan catches these eight. Each case carries
32943 // an alphabet-valid prefix + suffix so only the invisible-
32944 // format arm fires. A future drop of any one arm here surfaces
32945 // as a `must be rejected` panic at this one place rather than
32946 // as a silent regression through invisible-codepoint-homograph
32947 // downstream consumers (Artifact Hub description-search
32948 // misses, byte-level diff / grep / equality disagreement with
32949 // the visible-glyph match). Peer of
32950 // `chart_maintainer_name_shape_rejects_each_unicode_invisible_format_codepoint`
32951 // on the sibling predicate — both predicates route through the
32952 // same lifted `find_unicode_invisible_format` helper. Covers
32953 // the four paste-from-Word / paste-from-BOM-editor / paste-
32954 // from-typesetting shapes (U+00AD / U+200B / U+2060 / U+FEFF)
32955 // and the four math-formula invisible operators (U+2061
32956 // FUNCTION APPLICATION / U+2062 INVISIBLE TIMES / U+2063
32957 // INVISIBLE SEPARATOR / U+2064 INVISIBLE PLUS — the canonical
32958 // paste-from-MathJax / paste-from-LaTeX-rendered-formula
32959 // footgun where the renderer emits an invisible operator
32960 // between adjacent symbols for screen-reader operator
32961 // semantics).
32962 for (cp, name) in [
32963 ('\u{00AD}', "U+00AD"),
32964 ('\u{200B}', "U+200B"),
32965 ('\u{2060}', "U+2060"),
32966 ('\u{2061}', "U+2061"),
32967 ('\u{2062}', "U+2062"),
32968 ('\u{2063}', "U+2063"),
32969 ('\u{2064}', "U+2064"),
32970 ('\u{FEFF}', "U+FEFF"),
32971 ] {
32972 let s = format!("Canonical{cp}Servico");
32973 let err = is_chart_description_shape(&s)
32974 .err()
32975 .unwrap_or_else(|| panic!("chart description with {name} must be rejected"));
32976 assert!(
32977 err.contains(name),
32978 "chart description reason for {name} must name the codepoint verbatim; got {err:?}"
32979 );
32980 assert!(
32981 err.contains("invisible-format")
32982 || err.contains("Cf-category")
32983 || err.contains("zero-width"),
32984 "chart description reason for {name} must name the invisible-format banner; \
32985 got {err:?}"
32986 );
32987 }
32988 }
32989
32990 #[test]
32991 fn chart_description_shape_accepts_non_invisible_format_unicode() {
32992 // Positive control on the invisible-format arm: the predicate
32993 // must accept every non-invisible-format Unicode shape canonical
32994 // fixtures carry — including U+200C ZWNJ / U+200D ZWJ
32995 // (legitimate compositional load in Indic / Persian scripts and
32996 // emoji ZWJ sequences) and U+200E LRM / U+200F RLM (legitimate
32997 // single-character direction hints in mixed-script prose). A
32998 // future helper widening that accidentally rejects any of these
32999 // would regress legitimate fixture shapes and surfaces here as
33000 // a single-source-of-truth pin. Mirrors
33001 // `chart_maintainer_name_shape_accepts_non_invisible_format_unicode`
33002 // on the sibling predicate.
33003 for s in [
33004 "Canonical Rust→wasm32-wasip2 caixa Servico.",
33005 "FIXME — describe this caixa",
33006 // Emoji ZWJ sequence (U+200D) — must NOT be rejected: the
33007 // canonical multi-codepoint emoji authoring shape every
33008 // chart-aware UI renders as a single glyph.
33009 "Caixa for the 👨\u{200D}💻 family",
33010 // ZWNJ (U+200C) — legitimate Persian / Indic script
33011 // composition; the helper must NOT claim it.
33012 "Caixa for می\u{200C}باشد",
33013 // Bidi marks LRM (U+200E) and RLM (U+200F) — legitimate
33014 // single-character direction hints, separate class from
33015 // the bidi *overrides* the prior helper rejects.
33016 "Caixa for ASCII\u{200E}embedded in RTL",
33017 "Caixa for \u{200F}RTL hint",
33018 ] {
33019 is_chart_description_shape(s).unwrap_or_else(|e| {
33020 panic!(
33021 "non-invisible-format Unicode chart description {s:?} must pass without \
33022 rejection: {e:?}"
33023 )
33024 });
33025 }
33026 }
33027
33028 // ── is_chart_maintainer_name_shape — shared `:autores` chart-maintainer predicate ──
33029
33030 #[test]
33031 fn chart_maintainer_name_shape_accepts_canonical_forms() {
33032 // Substrate-side pin: the predicate accepts every canonical
33033 // chart-maintainer-name shape the `:autores` axis carries.
33034 // Drift between this list and the per-axis
33035 // `manifest::tests::validate_autores_accepts_canonical_forms`
33036 // positive-set sweep surfaces here — one source of truth for
33037 // the rule. Covers the hello-rio / checkout-aplicacao
33038 // `:autores ("pleme-io")` fixture, the multi-author
33039 // `"Pleme Contributors"` shape, and the canonical Helm
33040 // `"name <email>"` shape downstream packaging surfaces emit.
33041 for s in [
33042 "pleme-io",
33043 "Pleme Contributors",
33044 "alice <alice@example.com>",
33045 "bob <bob@example.com>",
33046 "Acme Corporation",
33047 "x",
33048 ] {
33049 is_chart_maintainer_name_shape(s).unwrap_or_else(|e| {
33050 panic!("canonical chart maintainer name {s:?} must pass: {e:?}")
33051 });
33052 }
33053 }
33054
33055 #[test]
33056 fn chart_maintainer_name_shape_rejects_each_arm_with_substring_pinned_reason() {
33057 // Substrate-side diagnostic-shape pin: each arm surfaces its
33058 // own distinct reason substring. Pinned here so a future
33059 // reason-wording rephrase that drops any of these substrings
33060 // surfaces at this one place, not piecemeal across every
33061 // per-axis test sweep. Mirrors
33062 // `chart_description_shape_rejects_each_arm_with_substring_pinned_reason`
33063 // on the peer predicate.
33064 for (s, needle) in [
33065 // Leading whitespace — paste-from-aligned-doc.
33066 (" pleme-io", "whitespace"),
33067 // Trailing whitespace — paste-from-doc.
33068 ("pleme-io ", "whitespace"),
33069 // Tab inside — tab-from-aligned-doc.
33070 ("Pleme\tContributors", "tab"),
33071 // Newline — paste-from-multiline-doc (author pasted
33072 // multi-line author block into one entry).
33073 ("alice\nbob", "newline"),
33074 // Carriage return — paste-from-Windows-CRLF-doc.
33075 ("alice\rbob", "carriage return"),
33076 // NUL byte — paste-from-binary-blob.
33077 ("alice\x00bob", "control character"),
33078 // BEL byte — paste-from-binary-blob.
33079 ("alice\x07bob", "control character"),
33080 // ESC byte — paste-from-binary-blob.
33081 ("alice\x1bbob", "control character"),
33082 // DEL byte (0x7F).
33083 ("alice\x7fbob", "control character"),
33084 ] {
33085 let err = is_chart_maintainer_name_shape(s)
33086 .err()
33087 .unwrap_or_else(|| panic!("chart maintainer name {s:?} must be rejected"));
33088 assert!(
33089 err.contains(needle),
33090 "chart maintainer name {s:?} reason must contain {needle:?}; got {err:?}"
33091 );
33092 }
33093 }
33094
33095 #[test]
33096 fn chart_maintainer_name_shape_accepts_unicode() {
33097 // Positive control on the non-ASCII arm: the predicate must
33098 // accept Unicode beyond the ASCII alphabet — realistic
33099 // maintainer names carry Unicode (`François`, `日本語`,
33100 // `naïve`), and every downstream consumer (YAML 1.2, Helm v3,
33101 // every chart-aware UI) round-trips Unicode losslessly. A
33102 // future tightening that bans non-ASCII bytes would regress
33103 // every Unicode-named maintainer and surface here as a
33104 // regression. Mirrors the peer
33105 // `chart_description_shape_accepts_unicode`.
33106 for s in [
33107 "François Dupont",
33108 "日本語の名前",
33109 "naïve <naive@example.com>",
33110 "André",
33111 ] {
33112 is_chart_maintainer_name_shape(s)
33113 .unwrap_or_else(|e| panic!("Unicode chart maintainer name {s:?} must pass: {e:?}"));
33114 }
33115 }
33116
33117 #[test]
33118 fn chart_maintainer_name_shape_rejects_empty_defensively() {
33119 // The predicate is called from `crate::Caixa::validate_autores`
33120 // only after the per-axis `AutorEmpty` arm has fired at
33121 // validate time; re-checking here keeps the predicate usable
33122 // from any future call site without an empty-precondition
33123 // footgun. Same defensive empty-check `is_dns_1123_label`,
33124 // `is_gateway_api_http_path`, `is_wit_world_ref`,
33125 // `is_nats_subject`, `is_wasi_keyvalue_slot`,
33126 // `is_git_ref_name`, `is_git_oid`, `is_git_repo_url`,
33127 // `is_cargo_feature_name`, `is_spdx_expression_shape`, and
33128 // `is_chart_description_shape` carry at their call sites.
33129 let err = is_chart_maintainer_name_shape("").unwrap_err();
33130 assert!(err.contains("empty"), "got: {err:?}");
33131 }
33132
33133 #[test]
33134 fn chart_maintainer_name_shape_rejects_at_129_byte_boundary() {
33135 // The 128-byte cap pin — both the boundary-exceeding case and
33136 // the boundary-accepting case in one place, so a future cap
33137 // shift surfaces both arms simultaneously, mirroring the peer
33138 // cap-boundary pins (`chart_description_shape_rejects_at_513_byte_boundary`
33139 // on the 512-byte sibling, `spdx_expression_shape_rejects_at_257_byte_boundary`
33140 // on the 256-byte sibling). Constructed as a single all-`a`
33141 // token so only the cap arm fires (128 `a` bytes is
33142 // alphabet-valid).
33143 let max_ok = "a".repeat(CHART_MAINTAINER_NAME_MAX_LEN);
33144 assert_eq!(max_ok.len(), 128);
33145 is_chart_maintainer_name_shape(&max_ok).unwrap();
33146 let too_long = "a".repeat(CHART_MAINTAINER_NAME_MAX_LEN + 1);
33147 assert_eq!(too_long.len(), 129);
33148 let err = is_chart_maintainer_name_shape(&too_long).unwrap_err();
33149 assert!(err.contains("128"), "got: {err:?}");
33150 assert!(err.contains("129"), "got: {err:?}");
33151 }
33152
33153 #[test]
33154 fn chart_maintainer_name_shape_rejects_each_unicode_bidi_override_codepoint() {
33155 // The Trojan Source (CVE-2021-42574) arm — pins every UAX #9
33156 // bidirectional-override / isolate format codepoint as a
33157 // structural rejection on the typed `:autores` axis. Mirrors
33158 // `chart_description_shape_rejects_each_unicode_bidi_override_codepoint`
33159 // on the peer predicate — both predicates route through the
33160 // same lifted `find_unicode_bidi_override` helper, so dropping
33161 // any one of the nine arms from the helper's match would
33162 // regress both peer test sweeps simultaneously at this one
33163 // structural floor rather than at piecemeal per-axis call
33164 // sites. The canonical attacker shape: an `:autores
33165 // "alice\u{202E}example.com<bob@"` entry renders in `helm
33166 // list`'s maintainer column / Artifact Hub as the visually-
33167 // reversed `alice<@bob>moc.elpmaxe` while riding verbatim
33168 // into the Chart.yaml `maintainers:` array — exactly the
33169 // class this arm closes.
33170 for (cp, name) in [
33171 ('\u{202A}', "U+202A"),
33172 ('\u{202B}', "U+202B"),
33173 ('\u{202C}', "U+202C"),
33174 ('\u{202D}', "U+202D"),
33175 ('\u{202E}', "U+202E"),
33176 ('\u{2066}', "U+2066"),
33177 ('\u{2067}', "U+2067"),
33178 ('\u{2068}', "U+2068"),
33179 ('\u{2069}', "U+2069"),
33180 ] {
33181 let s = format!("alice{cp}bob");
33182 let err = is_chart_maintainer_name_shape(&s)
33183 .err()
33184 .unwrap_or_else(|| panic!("chart maintainer name with {name} must be rejected"));
33185 assert!(
33186 err.contains(name),
33187 "chart maintainer name reason for {name} must name the codepoint verbatim; \
33188 got {err:?}"
33189 );
33190 assert!(
33191 err.contains("bidirectional-override")
33192 || err.contains("Unicode bidi")
33193 || err.contains("Trojan Source"),
33194 "chart maintainer name reason for {name} must name the Trojan-Source banner; \
33195 got {err:?}"
33196 );
33197 }
33198 }
33199
33200 #[test]
33201 fn chart_maintainer_name_shape_accepts_pure_rtl_text_without_bidi_override() {
33202 // Positive control on the bidi-override arm: pure visual
33203 // right-to-left scripts (Hebrew, Arabic) decode to non-bidi-
33204 // override codepoints and the predicate must accept them
33205 // natively — banning all RTL would regress every Hebrew /
33206 // Arabic-authored maintainer-name entry, which the substrate
33207 // supports via the non-ASCII byte arm. Peer of
33208 // `chart_description_shape_accepts_pure_rtl_text_without_bidi_override`
33209 // on the sibling YAML-plain-style-scalar surface.
33210 for s in [
33211 // Pure Hebrew maintainer name.
33212 "שלום",
33213 // Pure Arabic maintainer name.
33214 "مرحبا",
33215 // Mixed-script — canonical multilingual maintainer
33216 // shape every YAML 1.2 + Helm v3 round-trips losslessly.
33217 "Acme שלום",
33218 ] {
33219 is_chart_maintainer_name_shape(s).unwrap_or_else(|e| {
33220 panic!(
33221 "pure-RTL chart maintainer name {s:?} must pass without bidi override: {e:?}"
33222 )
33223 });
33224 }
33225 }
33226
33227 #[test]
33228 fn chart_maintainer_name_shape_rejects_each_unicode_line_break_codepoint() {
33229 // The non-ASCII Unicode line-break arm — pins each of the three
33230 // UAX #14 / YAML 1.1 §4.1 line-break codepoints outside the
33231 // ASCII `\n` / `\r` bytes already caught at the per-byte pass.
33232 // The canonical YAML-1.1-vs-YAML-1.2 paste-from-doc footgun: an
33233 // `:autores "alice\u{2028}bob"` entry parses as one
33234 // `maintainers:` array entry through a YAML 1.2-strict parser
33235 // and as two entries through a YAML 1.1 parser (go-yaml v2 /
33236 // Helm v3). Mirrors
33237 // `chart_description_shape_rejects_each_unicode_line_break_codepoint`
33238 // on the peer predicate — both predicates route through the
33239 // same lifted `find_unicode_line_break` helper, so dropping
33240 // any one of the three arms from the helper's match would
33241 // regress both peer test sweeps simultaneously at this one
33242 // structural floor.
33243 for (cp, name) in [
33244 ('\u{0085}', "U+0085"),
33245 ('\u{2028}', "U+2028"),
33246 ('\u{2029}', "U+2029"),
33247 ] {
33248 let s = format!("alice{cp}bob");
33249 let err = is_chart_maintainer_name_shape(&s)
33250 .err()
33251 .unwrap_or_else(|| panic!("chart maintainer name with {name} must be rejected"));
33252 assert!(
33253 err.contains(name),
33254 "chart maintainer name reason for {name} must name the codepoint verbatim; \
33255 got {err:?}"
33256 );
33257 assert!(
33258 err.contains("line-break") || err.contains("UAX #14") || err.contains("YAML 1.1"),
33259 "chart maintainer name reason for {name} must name the Unicode-line-break banner; \
33260 got {err:?}"
33261 );
33262 }
33263 }
33264
33265 #[test]
33266 fn chart_maintainer_name_shape_accepts_non_line_break_unicode() {
33267 // Positive control on the line-break arm: the predicate must
33268 // accept every non-line-break Unicode shape canonical
33269 // maintainer names carry. Pinned alongside the per-codepoint
33270 // rejection sweep so a future helper widening that
33271 // accidentally rejects a non-line-break codepoint surfaces
33272 // here as a single-source-of-truth pin. Peer of
33273 // `chart_description_shape_accepts_non_line_break_unicode`
33274 // on the sibling YAML-plain-style-scalar surface.
33275 for s in [
33276 "François Dupont",
33277 "日本語の名前",
33278 "naïve <naive@example.com>",
33279 "André",
33280 // U+00A0 NO-BREAK SPACE is NOT a line-break codepoint
33281 // (UAX #14 class GL — Glue, non-breaking) and is the
33282 // canonical authoring shape for unbreakable space inside
33283 // a multi-token maintainer name — must pass.
33284 "Acme\u{00A0}Corp",
33285 ] {
33286 is_chart_maintainer_name_shape(s).unwrap_or_else(|e| {
33287 panic!(
33288 "non-line-break Unicode chart maintainer name {s:?} must pass without \
33289 rejection: {e:?}"
33290 )
33291 });
33292 }
33293 }
33294
33295 #[test]
33296 fn chart_maintainer_name_shape_rejects_each_unicode_invisible_format_codepoint() {
33297 // The Unicode invisible-format arm — pins each of the eight
33298 // BMP Cf-category zero-width codepoints with no visible glyph.
33299 // The canonical maintainer-identity homograph footgun: an
33300 // `:autores "alice\u{200B}"` entry renders identically to
33301 // `:autores "alice"` in `helm list` / Artifact Hub's
33302 // maintainer column, but the byte sequence is distinct — the
33303 // Artifact Hub maintainer-index lookup misses the authored
33304 // `"alice"` entry, a future CLA-signer lookup matches a
33305 // visually-identical-but-byte-distinct identity. Mirrors
33306 // `chart_description_shape_rejects_each_unicode_invisible_format_codepoint`
33307 // on the peer predicate — both predicates route through the
33308 // same lifted `find_unicode_invisible_format` helper, so
33309 // dropping any one of the eight arms from the helper's match
33310 // would regress both peer test sweeps simultaneously at this
33311 // one structural floor. Covers the four paste-from-Word /
33312 // paste-from-BOM-editor / paste-from-typesetting shapes
33313 // (U+00AD / U+200B / U+2060 / U+FEFF) and the four math-
33314 // formula invisible operators (U+2061 FUNCTION APPLICATION /
33315 // U+2062 INVISIBLE TIMES / U+2063 INVISIBLE SEPARATOR /
33316 // U+2064 INVISIBLE PLUS — paste-from-MathJax / paste-from-
33317 // LaTeX-rendered-formula footgun).
33318 for (cp, name) in [
33319 ('\u{00AD}', "U+00AD"),
33320 ('\u{200B}', "U+200B"),
33321 ('\u{2060}', "U+2060"),
33322 ('\u{2061}', "U+2061"),
33323 ('\u{2062}', "U+2062"),
33324 ('\u{2063}', "U+2063"),
33325 ('\u{2064}', "U+2064"),
33326 ('\u{FEFF}', "U+FEFF"),
33327 ] {
33328 let s = format!("alice{cp}bob");
33329 let err = is_chart_maintainer_name_shape(&s)
33330 .err()
33331 .unwrap_or_else(|| panic!("chart maintainer name with {name} must be rejected"));
33332 assert!(
33333 err.contains(name),
33334 "chart maintainer name reason for {name} must name the codepoint verbatim; \
33335 got {err:?}"
33336 );
33337 assert!(
33338 err.contains("invisible-format")
33339 || err.contains("Cf-category")
33340 || err.contains("zero-width"),
33341 "chart maintainer name reason for {name} must name the invisible-format banner; \
33342 got {err:?}"
33343 );
33344 }
33345 }
33346
33347 #[test]
33348 fn chart_maintainer_name_shape_accepts_non_invisible_format_unicode() {
33349 // Positive control on the invisible-format arm: the predicate
33350 // must accept the legitimate-use codepoints the helper
33351 // deliberately excludes — U+200C ZWNJ / U+200D ZWJ (emoji ZWJ
33352 // sequences are canonical for modern maintainer-display names;
33353 // Indic / Persian script composition relies on ZWNJ to break
33354 // inappropriate ligatures) and U+200E LRM / U+200F RLM
33355 // (mixed-script direction hints are canonical for "Arabic name
33356 // with embedded ASCII email" shapes). Peer of
33357 // `chart_description_shape_accepts_non_invisible_format_unicode`
33358 // on the sibling YAML-plain-style-scalar surface.
33359 for s in [
33360 "François Dupont",
33361 "naïve <naive@example.com>",
33362 // Emoji ZWJ sequence (U+200D) — canonical multi-codepoint
33363 // emoji authoring shape.
33364 "Joe 👨\u{200D}💻 Developer",
33365 // ZWNJ (U+200C) — legitimate Persian / Indic composition.
33366 "Persian می\u{200C}باشد maintainer",
33367 // Bidi marks LRM / RLM — legitimate direction hints in
33368 // mixed-script maintainer names.
33369 "Arabic\u{200F}name <maintainer@example.com>",
33370 "ASCII\u{200E}embedded in RTL context",
33371 ] {
33372 is_chart_maintainer_name_shape(s).unwrap_or_else(|e| {
33373 panic!(
33374 "non-invisible-format Unicode chart maintainer name {s:?} must pass without \
33375 rejection: {e:?}"
33376 )
33377 });
33378 }
33379 }
33380
33381 #[test]
33382 fn find_unicode_bidi_override_pins_the_nine_codepoint_accepted_set() {
33383 // The shared helper's accepted set — pinned in one place so
33384 // every per-predicate caller (`is_chart_description_shape`,
33385 // `is_chart_maintainer_name_shape`, every future free-form-
33386 // prose surface) reads from one canonical accepted set. The
33387 // nine UAX #9 bidirectional-override / isolate format
33388 // codepoints in document order, plus negative controls on
33389 // bytes the helper must NOT reject (ASCII / non-bidi Unicode
33390 // letters / arrows / em-dash / RTL letters). A future shift
33391 // in the accepted set surfaces here as a single-source-of-
33392 // truth edit at this one test rather than across every
33393 // per-predicate per-arm sweep.
33394 for cp in [
33395 '\u{202A}', '\u{202B}', '\u{202C}', '\u{202D}', '\u{202E}', '\u{2066}', '\u{2067}',
33396 '\u{2068}', '\u{2069}',
33397 ] {
33398 let s = format!("a{cp}b");
33399 assert_eq!(
33400 find_unicode_bidi_override(&s),
33401 Some(cp),
33402 "helper must flag bidi override U+{:04X} on input {s:?}",
33403 cp as u32
33404 );
33405 }
33406 for s in [
33407 "alice",
33408 "Canonical Rust→wasm32-wasip2",
33409 "FIXME — describe this caixa",
33410 "François Dupont",
33411 "日本語の説明",
33412 "naïve",
33413 "שלום",
33414 "مرحبا",
33415 ] {
33416 assert_eq!(
33417 find_unicode_bidi_override(s),
33418 None,
33419 "helper must accept {s:?} (no bidi-override codepoint)"
33420 );
33421 }
33422 // Empty input — defensive precondition for the helper's
33423 // call-site contract on any future caller that doesn't gate
33424 // emptiness ahead of the scan.
33425 assert_eq!(find_unicode_bidi_override(""), None);
33426 }
33427
33428 #[test]
33429 fn find_unicode_line_break_pins_the_three_codepoint_accepted_set() {
33430 // The shared helper's accepted set — pinned in one place so
33431 // every per-predicate caller (`is_chart_description_shape`,
33432 // `is_chart_maintainer_name_shape`, every future free-form-
33433 // prose surface) reads from one canonical accepted set. The
33434 // three UAX #14 / YAML 1.1 §4.1 non-ASCII line-break
33435 // codepoints in document order, plus negative controls on
33436 // bytes the helper must NOT reject (ASCII text, Unicode
33437 // letters / arrows / em-dash / RTL letters, the canonical
33438 // non-line-break U+00A0 NBSP shape downstream YAML 1.2 +
33439 // Helm v3 + every chart-aware UI round-trip losslessly). A
33440 // future shift in the accepted set surfaces here as a
33441 // single-source-of-truth edit at this one test rather than
33442 // across every per-predicate per-arm sweep. Peer of
33443 // `find_unicode_bidi_override_pins_the_nine_codepoint_accepted_set`
33444 // on the sibling lifted-helper one trajectory earlier.
33445 for cp in ['\u{0085}', '\u{2028}', '\u{2029}'] {
33446 let s = format!("a{cp}b");
33447 assert_eq!(
33448 find_unicode_line_break(&s),
33449 Some(cp),
33450 "helper must flag line-break codepoint U+{:04X} on input {s:?}",
33451 cp as u32
33452 );
33453 }
33454 for s in [
33455 "alice",
33456 "Canonical Rust→wasm32-wasip2",
33457 "FIXME — describe this caixa",
33458 "François Dupont",
33459 "日本語の説明",
33460 "naïve",
33461 "שלום",
33462 "مرحبا",
33463 // U+00A0 NO-BREAK SPACE — UAX #14 class GL (Glue,
33464 // non-breaking) — must NOT be rejected: the canonical
33465 // unbreakable-space shape every typed maintainer-name
33466 // axis admits.
33467 "Acme\u{00A0}Corp",
33468 // U+0009 TAB and U+000A LF and U+000D CR — ASCII
33469 // line-break / whitespace bytes the per-byte arm on the
33470 // calling predicate already closes; the helper must NOT
33471 // claim them as its own (single-source-of-truth: ASCII
33472 // arms live in the per-byte loop, the helper closes the
33473 // non-ASCII codepoints).
33474 "alice\tbob",
33475 "alice\nbob",
33476 "alice\rbob",
33477 ] {
33478 assert_eq!(
33479 find_unicode_line_break(s),
33480 None,
33481 "helper must accept {s:?} (no non-ASCII line-break codepoint)"
33482 );
33483 }
33484 // Empty input — defensive precondition for the helper's
33485 // call-site contract on any future caller that doesn't gate
33486 // emptiness ahead of the scan.
33487 assert_eq!(find_unicode_line_break(""), None);
33488 }
33489
33490 #[test]
33491 fn find_unicode_invisible_format_pins_the_eight_codepoint_accepted_set() {
33492 // The shared helper's accepted set — pinned in one place so
33493 // every per-predicate caller (`is_chart_description_shape`,
33494 // `is_chart_maintainer_name_shape`, every future free-form-
33495 // prose surface) reads from one canonical accepted set. The
33496 // eight BMP Cf-category zero-width codepoints in document
33497 // order — the four paste-from-Word / paste-from-BOM-editor /
33498 // paste-from-typesetting-doc shapes (U+00AD SHY / U+200B ZWSP /
33499 // U+2060 WJ / U+FEFF ZWNBSP-BOM) and the four math-formula
33500 // invisible operators (U+2061 FUNCTION APPLICATION / U+2062
33501 // INVISIBLE TIMES / U+2063 INVISIBLE SEPARATOR / U+2064
33502 // INVISIBLE PLUS — paste-from-MathJax / paste-from-LaTeX-
33503 // rendered-formula / paste-from-InDesign-math-equation
33504 // shapes) — plus negative controls on codepoints the helper
33505 // must NOT reject — the deliberate exclusions: U+200C ZWNJ /
33506 // U+200D ZWJ (emoji ZWJ sequences + Indic / Persian script
33507 // composition) and U+200E LRM / U+200F RLM (mixed-script
33508 // direction hints). A future shift in the accepted set
33509 // surfaces here as a single-source-of-truth edit at this one
33510 // test rather than across every per-predicate per-arm sweep.
33511 // Third pin in the UAX-driven render-determinism trio (peer of
33512 // `find_unicode_bidi_override_pins_the_nine_codepoint_accepted_set`
33513 // on the visual-order axis and
33514 // `find_unicode_line_break_pins_the_three_codepoint_accepted_set`
33515 // on the single-line/multi-line axis).
33516 for cp in [
33517 '\u{00AD}', '\u{200B}', '\u{2060}', '\u{2061}', '\u{2062}', '\u{2063}', '\u{2064}',
33518 '\u{FEFF}',
33519 ] {
33520 let s = format!("a{cp}b");
33521 assert_eq!(
33522 find_unicode_invisible_format(&s),
33523 Some(cp),
33524 "helper must flag invisible-format codepoint U+{:04X} on input {s:?}",
33525 cp as u32
33526 );
33527 }
33528 for s in [
33529 "alice",
33530 "Canonical Rust→wasm32-wasip2",
33531 "FIXME — describe this caixa",
33532 "François Dupont",
33533 "日本語の説明",
33534 "naïve",
33535 "שלום",
33536 "مرحبا",
33537 // U+00A0 NO-BREAK SPACE — class GL (Glue), visible-width
33538 // codepoint — must NOT be claimed by the invisible-format
33539 // helper (the canonical unbreakable-space shape).
33540 "Acme\u{00A0}Corp",
33541 // U+200C ZWNJ — deliberately excluded (Indic / Persian
33542 // composition + emoji ZWJ-adjacent context).
33543 "می\u{200C}باشد",
33544 // U+200D ZWJ — deliberately excluded (emoji ZWJ
33545 // sequences are canonical: 👨💻 is MAN + ZWJ + LAPTOP).
33546 "Joe 👨\u{200D}💻 Developer",
33547 // U+200E LRM — deliberately excluded (direction-hint
33548 // mark, not a direction-override; legitimate in
33549 // mixed-script prose).
33550 "ASCII\u{200E}embedded",
33551 // U+200F RLM — deliberately excluded (mirror of LRM
33552 // on the RTL axis).
33553 "Arabic\u{200F}name",
33554 // Bidi-override codepoints (U+202A..U+202E, U+2066..U+2069)
33555 // — caught by the sibling `find_unicode_bidi_override`
33556 // helper, not this one (single-source-of-truth: each
33557 // helper closes exactly its class).
33558 "alice\u{202E}bob",
33559 // Line-break codepoints (U+0085, U+2028, U+2029) — caught
33560 // by the sibling `find_unicode_line_break` helper.
33561 "alice\u{2028}bob",
33562 ] {
33563 assert_eq!(
33564 find_unicode_invisible_format(s),
33565 None,
33566 "helper must accept {s:?} (no invisible-format codepoint in the four-codepoint set)"
33567 );
33568 }
33569 // Empty input — defensive precondition for the helper's
33570 // call-site contract on any future caller that doesn't gate
33571 // emptiness ahead of the scan.
33572 assert_eq!(find_unicode_invisible_format(""), None);
33573 }
33574
33575 // ── is_chart_keyword_shape — shared `:etiquetas` chart-keyword predicate ──
33576
33577 #[test]
33578 fn chart_keyword_shape_accepts_canonical_forms() {
33579 // Substrate-side pin: the predicate accepts every canonical
33580 // chart-keyword shape the `:etiquetas` axis carries. Drift
33581 // between this list and the per-axis
33582 // `manifest::tests::validate_etiquetas_accepts_canonical_shaped_forms`
33583 // positive-set sweep surfaces here — one source of truth for
33584 // the rule. Covers the example fixtures'
33585 // `:etiquetas` lists (`"example"`, `"aplicacao"`, `"mesh"`,
33586 // `"ecommerce"`, `"demo"`, `"infrastructure"`, `"aws"`,
33587 // `"akeyless"`, `"pangea-native"`) and the substrate-fixed
33588 // tags caixa-helm unions in at chart render (`"lareira"`,
33589 // `"wasm"`, `"tatara-lisp"`, `"caixa-servico"`).
33590 let example_fixture_tags = [
33591 "example",
33592 "aplicacao",
33593 "mesh",
33594 "ecommerce",
33595 "demo",
33596 "infrastructure",
33597 "aws",
33598 "akeyless",
33599 "pangea-native",
33600 "hello-world",
33601 "rust",
33602 "Foo",
33603 "Bar123",
33604 "x",
33605 "snake_case_tag",
33606 ];
33607 for s in example_fixture_tags
33608 .iter()
33609 .copied()
33610 .chain(LAREIRA_CHART_KEYWORDS.iter().copied())
33611 {
33612 is_chart_keyword_shape(s)
33613 .unwrap_or_else(|e| panic!("canonical chart keyword {s:?} must pass: {e:?}"));
33614 }
33615 }
33616
33617 #[test]
33618 fn lareira_chart_keywords_pins_canonical_ordered_set() {
33619 // Substrate-side canonical-set pin: byte-pins the
33620 // substrate-fixed `Chart.yaml` `keywords:` union caixa-helm's
33621 // `build_chart_yaml` folds into every rendered `lareira-<nome>`
33622 // chart on top of the caixa author's own `:etiquetas`. The
33623 // ordered array shape (`BTreeSet`-canonical ascii-alphabetical)
33624 // pins the same order the emitted `Chart.yaml` `keywords:`
33625 // sequence lists them after the intermediate
33626 // `BTreeSet<String>` fold at the caixa-helm emit site. A drift
33627 // between the canonical array and either the production emit
33628 // at `caixa-helm::build_chart_yaml` (the sole consumer) or
33629 // the peer positive-set sweep tests (this crate's
33630 // `chart_keyword_shape_accepts_canonical_forms` and
33631 // `manifest::tests::validate_etiquetas_accepts_canonical_shaped_forms`)
33632 // surfaces at this one substrate-side pin.
33633 assert_eq!(
33634 LAREIRA_CHART_KEYWORDS,
33635 &["caixa-servico", "lareira", "tatara-lisp", "wasm"],
33636 );
33637 }
33638
33639 #[test]
33640 fn lareira_chart_keywords_stays_btreeset_canonical_ordered() {
33641 // Substrate-side ordering pin: the array is
33642 // `BTreeSet`-canonical ascii-alphabetical, so its declared
33643 // order matches the shape the emitted `Chart.yaml`
33644 // `keywords:` sequence carries after
33645 // `caixa-helm::build_chart_yaml`'s intermediate
33646 // `BTreeSet<String>` fold — a future substrate-fixed keyword
33647 // addition that lands out-of-order (an `"opentelemetry"` entry
33648 // dropped before `"tatara-lisp"`, an `"lunatic"` entry dropped
33649 // after `"wasm"`) trips this pin at caixa-core build time
33650 // rather than surfacing as a byte-shape drift between the
33651 // array's declared order and the emitted `keywords:` sequence
33652 // order at chart render time downstream.
33653 let mut sorted: Vec<&str> = LAREIRA_CHART_KEYWORDS.to_vec();
33654 sorted.sort_unstable();
33655 assert_eq!(LAREIRA_CHART_KEYWORDS, sorted.as_slice());
33656 }
33657
33658 #[test]
33659 fn lareira_chart_keywords_each_entry_passes_is_chart_keyword_shape() {
33660 // Substrate-side shape-invariant pin: every substrate-fixed
33661 // chart-keyword entry must satisfy the per-`Chart.yaml`
33662 // `keywords:` entry validation predicate the substrate
33663 // enforces on the author-side `:etiquetas` axis — a future
33664 // substrate-fixed keyword addition that happens to break the
33665 // shape rule (a leading digit, an uppercase letter, a byte
33666 // over the `CHART_KEYWORD_MAX_LEN` cap, an ASCII whitespace,
33667 // a Unicode-invisible-format code point) trips this pin at
33668 // caixa-core build time rather than surfacing at
33669 // `helm lint` time on the rendered chart downstream.
33670 for keyword in LAREIRA_CHART_KEYWORDS {
33671 is_chart_keyword_shape(keyword).unwrap_or_else(|e| {
33672 panic!(
33673 "substrate-fixed chart keyword {keyword:?} must pass \
33674 is_chart_keyword_shape: {e:?}"
33675 )
33676 });
33677 }
33678 }
33679
33680 #[test]
33681 fn chart_keyword_shape_rejects_each_arm_with_substring_pinned_reason() {
33682 // Substrate-side diagnostic-shape pin: each arm surfaces its
33683 // own distinct reason substring. Pinned here so a future
33684 // reason-wording rephrase that drops any of these substrings
33685 // surfaces at this one place, not piecemeal across every
33686 // per-axis test sweep. Mirrors
33687 // `chart_maintainer_name_shape_rejects_each_arm_with_substring_pinned_reason`
33688 // on the peer predicate.
33689 for (s, needle) in [
33690 // Leading whitespace — paste-from-aligned-doc.
33691 (" mesh", "whitespace"),
33692 // Leading hyphen — kebab-leak footgun.
33693 ("-foo", "`-`"),
33694 // Leading underscore — snake-leak footgun.
33695 ("_foo", "`_`"),
33696 // Leading digit — paste-from-numbered-list footgun.
33697 ("1foo", "digit"),
33698 // Embedded whitespace — multi-tag-blob footgun.
33699 ("web service", "whitespace"),
33700 // Tab inside — tab-from-aligned-doc.
33701 ("mesh\thttp", "whitespace"),
33702 // Newline — paste-from-multiline-doc.
33703 ("mesh\nhttp", "newline"),
33704 // Carriage return — paste-from-Windows-CRLF-doc.
33705 ("mesh\rhttp", "carriage return"),
33706 // Comma — CSV-list-separator confusion.
33707 ("mesh,http", "`,`"),
33708 // Slash — path-separator confusion.
33709 ("caixa/servico", "`/`"),
33710 // Semicolon — alt-list-separator confusion.
33711 ("mesh;http", "`;`"),
33712 // Period — namespace / version-suffix confusion.
33713 ("http.1", "`.`"),
33714 // NUL byte — paste-from-binary-blob.
33715 ("mesh\x00http", "control character"),
33716 // DEL byte (0x7F).
33717 ("mesh\x7fhttp", "control character"),
33718 // Non-ASCII inside.
33719 ("café", "non-ASCII"),
33720 // Non-ASCII leading.
33721 ("éclair", "non-ASCII"),
33722 ] {
33723 let err = is_chart_keyword_shape(s)
33724 .err()
33725 .unwrap_or_else(|| panic!("chart keyword {s:?} must be rejected"));
33726 assert!(
33727 err.contains(needle),
33728 "chart keyword {s:?} reason must contain {needle:?}; got {err:?}"
33729 );
33730 }
33731 }
33732
33733 #[test]
33734 fn chart_keyword_shape_rejects_empty_defensively() {
33735 // The predicate is called from `crate::Caixa::validate_etiquetas`
33736 // only after the per-axis `EtiquetaEmpty` arm has fired at
33737 // validate time; re-checking here keeps the predicate usable
33738 // from any future call site without an empty-precondition
33739 // footgun. Same defensive empty-check `is_dns_1123_label`,
33740 // `is_gateway_api_http_path`, `is_wit_world_ref`,
33741 // `is_nats_subject`, `is_wasi_keyvalue_slot`,
33742 // `is_git_ref_name`, `is_git_oid`, `is_git_repo_url`,
33743 // `is_cargo_feature_name`, `is_spdx_expression_shape`,
33744 // `is_chart_description_shape`, and
33745 // `is_chart_maintainer_name_shape` carry at their call sites.
33746 let err = is_chart_keyword_shape("").unwrap_err();
33747 assert!(err.contains("empty"), "got: {err:?}");
33748 }
33749
33750 #[test]
33751 fn chart_keyword_shape_rejects_at_21_byte_boundary() {
33752 // The 20-byte cap pin — both the boundary-exceeding case and
33753 // the boundary-accepting case in one place, so a future cap
33754 // shift surfaces both arms simultaneously, mirroring the peer
33755 // cap-boundary pins
33756 // (`chart_maintainer_name_shape_rejects_at_129_byte_boundary`
33757 // on the 128-byte sibling,
33758 // `chart_description_shape_rejects_at_513_byte_boundary` on
33759 // the 512-byte sibling). Constructed as a single all-`a`
33760 // token so only the cap arm fires (20 `a` bytes is alphabet-
33761 // valid).
33762 let max_ok = "a".repeat(CHART_KEYWORD_MAX_LEN);
33763 assert_eq!(max_ok.len(), 20);
33764 is_chart_keyword_shape(&max_ok).unwrap();
33765 let too_long = "a".repeat(CHART_KEYWORD_MAX_LEN + 1);
33766 assert_eq!(too_long.len(), 21);
33767 let err = is_chart_keyword_shape(&too_long).unwrap_err();
33768 assert!(err.contains("20"), "got: {err:?}");
33769 assert!(err.contains("21"), "got: {err:?}");
33770 }
33771
33772 // ── shared predicate: find_ascii_whitespace_byte ──────────────────
33773 //
33774 // Pins the accepted / rejected set of the lifted ASCII byte-scan
33775 // every typed-magnitude codec in caixa-core calls (`parse_byte_size`
33776 // / `parse_duration` / `parse_millicores` / shared
33777 // `duration_codec` / `rate_limit_codec`). Peer of the non-ASCII
33778 // `find_non_ascii_whitespace_char` predicate below — together they
33779 // partition the full Unicode `White_Space` axis.
33780
33781 #[test]
33782 fn find_ascii_whitespace_byte_accepts_whitespace_free_strings() {
33783 // Complement-side pin: every whitespace-free canonical form
33784 // the renderers emit returns `None`.
33785 assert!(find_ascii_whitespace_byte("64MiB").is_none());
33786 assert!(find_ascii_whitespace_byte("30s").is_none());
33787 assert!(find_ascii_whitespace_byte("500m").is_none());
33788 assert!(find_ascii_whitespace_byte("100/s").is_none());
33789 assert!(find_ascii_whitespace_byte("").is_none());
33790 assert!(find_ascii_whitespace_byte("abcdef0123-_").is_none());
33791 // Non-whitespace ASCII bytes near the whitespace range stay
33792 // accepted (the predicate must not over-fire on peer control
33793 // bytes like VT `0x0B` which POSIX admits but WhatWG excludes).
33794 assert!(find_ascii_whitespace_byte("\u{0B}64MiB").is_none());
33795 }
33796
33797 #[test]
33798 fn find_ascii_whitespace_byte_flags_space() {
33799 // Space (`0x20`) — the canonical paste-from-shell-history /
33800 // paste-from-aligned-doc drift class.
33801 assert_eq!(find_ascii_whitespace_byte(" 64MiB"), Some(0x20));
33802 assert_eq!(find_ascii_whitespace_byte("30s "), Some(0x20));
33803 assert_eq!(find_ascii_whitespace_byte("100 /s"), Some(0x20));
33804 }
33805
33806 #[test]
33807 fn find_ascii_whitespace_byte_flags_tab_lf_ff_cr() {
33808 // Tab (`0x09`), LF (`0x0A`), FF (`0x0C`), CR (`0x0D`) —
33809 // the remaining four bytes in the WhatWG ASCII whitespace
33810 // set the predicate covers, verbatim.
33811 assert_eq!(find_ascii_whitespace_byte("\t500m"), Some(0x09));
33812 assert_eq!(find_ascii_whitespace_byte("30s\n"), Some(0x0A));
33813 assert_eq!(find_ascii_whitespace_byte("\x0c64MiB"), Some(0x0C));
33814 assert_eq!(find_ascii_whitespace_byte("100/s\r"), Some(0x0D));
33815 }
33816
33817 #[test]
33818 fn find_ascii_whitespace_byte_returns_first_match_byte_order() {
33819 // The predicate returns the *first* offending byte in scan
33820 // order — pinning this so a self-locating codec diagnostic can
33821 // report "position 0" / "position N" verbatim without the
33822 // predicate ever reordering matches.
33823 assert_eq!(find_ascii_whitespace_byte(" \t30s"), Some(0x20));
33824 assert_eq!(find_ascii_whitespace_byte("\t 30s"), Some(0x09));
33825 }
33826
33827 #[test]
33828 fn find_ascii_whitespace_byte_does_not_flag_non_ascii_whitespace() {
33829 // NBSP (`\u{00A0}`), LINE SEPARATOR (`\u{2028}`), IDEOGRAPHIC
33830 // SPACE (`\u{3000}`) — none of their UTF-8 bytes match
33831 // `u8::is_ascii_whitespace` (NBSP's `0xC2 0xA0`, LINE
33832 // SEPARATOR's `0xE2 0x80 0xA8`, IDEOGRAPHIC SPACE's `0xE3
33833 // 0x80 0x80` all sit above `0x7F` or well outside the
33834 // {`0x09`, `0x0A`, `0x0C`, `0x0D`, `0x20`} set). Pinning this
33835 // exclusion so the peer `find_non_ascii_whitespace_char`
33836 // predicate remains strictly complementary — the two together
33837 // partition the full Unicode `White_Space` axis with zero
33838 // overlap.
33839 assert!(find_ascii_whitespace_byte("\u{00A0}64MiB").is_none());
33840 assert!(find_ascii_whitespace_byte("30s\u{2028}").is_none());
33841 assert!(find_ascii_whitespace_byte("64MiB\u{3000}").is_none());
33842 }
33843
33844 // ── shared predicate: find_non_ascii_whitespace_char ──────────────────
33845 //
33846 // Pins the accepted / rejected set of the lifted predicate every
33847 // typed-magnitude codec in caixa-core calls (byte-size / duration /
33848 // shared duration / rate-limit). The predicate's job is exclusively
33849 // to name the strictly-complementary drift class the peer
33850 // `u8::is_ascii_whitespace` byte-scan cannot see — the non-ASCII
33851 // Unicode `White_Space` subset that `str::trim` silently swallows.
33852
33853 #[test]
33854 fn find_non_ascii_whitespace_char_accepts_ascii_only_strings() {
33855 // Complement-side pin: every ASCII-only string (canonical form
33856 // and ASCII whitespace alike) returns `None`. The predicate is
33857 // strictly complementary to the per-codec ASCII byte-scan; it
33858 // must not shadow its coverage.
33859 assert!(find_non_ascii_whitespace_char("64MiB").is_none());
33860 assert!(find_non_ascii_whitespace_char("30s").is_none());
33861 assert!(find_non_ascii_whitespace_char("100/s").is_none());
33862 assert!(find_non_ascii_whitespace_char(" \t\n").is_none());
33863 assert!(find_non_ascii_whitespace_char("").is_none());
33864 // Non-whitespace ASCII byte peers stay accepted too.
33865 assert!(find_non_ascii_whitespace_char("abcdef0123-_").is_none());
33866 }
33867
33868 #[test]
33869 fn find_non_ascii_whitespace_char_flags_nbsp() {
33870 // `\u{00A0}` NBSP — the canonical paste-from-typography /
33871 // paste-from-word-processor drift class.
33872 assert_eq!(
33873 find_non_ascii_whitespace_char("64\u{00A0}MiB"),
33874 Some('\u{00A0}')
33875 );
33876 assert_eq!(find_non_ascii_whitespace_char("\u{00A0}"), Some('\u{00A0}'));
33877 }
33878
33879 #[test]
33880 fn find_non_ascii_whitespace_char_flags_line_and_paragraph_separators() {
33881 // LINE SEPARATOR (`\u{2028}`) / PARAGRAPH SEPARATOR
33882 // (`\u{2029}`) — the paste-from-web-doc drift class every
33883 // RTF/HTML → plain-text conversion emits at soft-wrap
33884 // boundaries.
33885 assert_eq!(
33886 find_non_ascii_whitespace_char("30s\u{2028}"),
33887 Some('\u{2028}')
33888 );
33889 assert_eq!(
33890 find_non_ascii_whitespace_char("30s\u{2029}"),
33891 Some('\u{2029}')
33892 );
33893 }
33894
33895 #[test]
33896 fn find_non_ascii_whitespace_char_flags_ideographic_space() {
33897 // IDEOGRAPHIC SPACE (`\u{3000}`) — the CJK-typography drift
33898 // class every full-width IME auto-widens ASCII space to on
33899 // Japanese / Chinese input methods.
33900 assert_eq!(
33901 find_non_ascii_whitespace_char("64MiB\u{3000}"),
33902 Some('\u{3000}')
33903 );
33904 }
33905
33906 #[test]
33907 fn find_non_ascii_whitespace_char_does_not_flag_zwsp_or_bom() {
33908 // BOM (`\u{FEFF}`, ZERO WIDTH NO-BREAK SPACE) and ZWSP
33909 // (`\u{200B}`, ZERO WIDTH SPACE) — both have
33910 // `char::is_whitespace() == false` per the Unicode
33911 // `White_Space` property, so `str::trim` does *not* strip
33912 // either. Both currently land on the downstream
33913 // `BadByteMagnitude` / `BadDurationMagnitude` arm at parse time
33914 // with the byte-shape diagnostic intact; the render-determinism
33915 // contract is unbroken on those inputs today. This test pins
33916 // the predicate's exclusion so a future widening that starts
33917 // flagging BOM / ZWSP here surfaces as a test failure rather
33918 // than a silent over-fire on a class the downstream arm
33919 // already closes.
33920 assert!(find_non_ascii_whitespace_char("\u{FEFF}64MiB").is_none());
33921 assert!(find_non_ascii_whitespace_char("\u{200B}30s").is_none());
33922 }
33923
33924 // ── shared predicate: is_leading_zero_padded_magnitude ──────────────
33925 //
33926 // Pins the accepted / rejected set of the lifted leading-zero
33927 // predicate every typed-magnitude codec in caixa-core calls
33928 // (`parse_byte_size` / `parse_duration` / `parse_millicores` /
33929 // shared `duration_codec` / `rate_limit_codec`). Same lifted-
33930 // source-of-truth discipline the peer whitespace predicates
33931 // (`find_ascii_whitespace_byte` / `find_non_ascii_whitespace_char`)
33932 // carry — drift between any two codec sites' rejection set becomes
33933 // a single-edit fix at this predicate.
33934
33935 #[test]
33936 fn is_leading_zero_padded_magnitude_accepts_canonical_forms() {
33937 // Complement-side pin: every canonical form the typed-magnitude
33938 // `render_*` canonicalizers emit — the single-byte `"0"` case
33939 // and every non-leading-zero magnitude — returns `false`.
33940 assert!(!is_leading_zero_padded_magnitude("0"));
33941 assert!(!is_leading_zero_padded_magnitude("1"));
33942 assert!(!is_leading_zero_padded_magnitude("64"));
33943 assert!(!is_leading_zero_padded_magnitude("500"));
33944 assert!(!is_leading_zero_padded_magnitude("1024"));
33945 assert!(!is_leading_zero_padded_magnitude("999999"));
33946 // Empty magnitude is not a leading-zero shape either — the
33947 // upstream `digit_only` gate at each codec site refuses empty
33948 // magnitudes on its own arm before this predicate is consulted.
33949 assert!(!is_leading_zero_padded_magnitude(""));
33950 // Non-digit-only bodies are outside the predicate's scope — the
33951 // upstream `digit_only` gate refuses them with its own
33952 // `NonInteger*` / `Bad*` diagnostic; this predicate is invoked
33953 // only after that gate accepts.
33954 assert!(!is_leading_zero_padded_magnitude("a"));
33955 assert!(!is_leading_zero_padded_magnitude("1.5"));
33956 }
33957
33958 #[test]
33959 fn is_leading_zero_padded_magnitude_flags_two_byte_leading_zero() {
33960 // The minimal leading-zero drift shape: two-byte magnitude
33961 // starting with `'0'` — `"00"` / `"01"` / `"09"`. Every one
33962 // round-trips through the peer codecs' `render_*` to the
33963 // leading-zero-stripped form (`"0"` / `"1"` / `"9"`).
33964 assert!(is_leading_zero_padded_magnitude("00"));
33965 assert!(is_leading_zero_padded_magnitude("01"));
33966 assert!(is_leading_zero_padded_magnitude("09"));
33967 }
33968
33969 #[test]
33970 fn is_leading_zero_padded_magnitude_flags_multi_byte_leading_zero() {
33971 // The canonical paste-from-fixed-width-alignment /
33972 // paste-from-columnar-report drift class each codec's
33973 // `render_*` emits the stripped form for: `"0064"` (byte-size
33974 // magnitude), `"030"` (duration magnitude), `"0500"`
33975 // (millicores magnitude), `"0100"` (rate-limit magnitude),
33976 // `"01024"` (multi-digit byte-size magnitude).
33977 assert!(is_leading_zero_padded_magnitude("0064"));
33978 assert!(is_leading_zero_padded_magnitude("030"));
33979 assert!(is_leading_zero_padded_magnitude("0500"));
33980 assert!(is_leading_zero_padded_magnitude("0100"));
33981 assert!(is_leading_zero_padded_magnitude("01024"));
33982 // All-zeros multi-byte magnitude — `"000"` / `"0000"` — every
33983 // one round-trips to `"0"`. The single-byte `"0"` case is the
33984 // canonical zero and stays accepted; the multi-byte all-zero
33985 // shape is leading-zero drift.
33986 assert!(is_leading_zero_padded_magnitude("000"));
33987 assert!(is_leading_zero_padded_magnitude("0000"));
33988 }
33989
33990 #[test]
33991 fn is_leading_zero_padded_magnitude_pins_single_zero_boundary() {
33992 // The single-byte magnitude `"0"` is the canonical zero the
33993 // peer codecs' `render_*` canonicalizers emit for the zero
33994 // value verbatim (`render_byte_size(0)` = `"0"`,
33995 // `render_duration(Duration::ZERO)` = `"0s"` with `"0"` as
33996 // the magnitude, `render_millicores(0)` = `"0m"` with `"0"`
33997 // as the magnitude, `RateLimit::render` for rate=0 = `"0/s"`
33998 // with `"0"` as the magnitude). Pinning this boundary so a
33999 // future widening that starts flagging the single-byte `"0"`
34000 // here surfaces as a test failure rather than a silent break
34001 // of the codec-layer / typed-validate-layer partition — the
34002 // semantic-zero gates at the typed-validate layer above
34003 // (`LimitsError::MemoryZero`, `LimitsError::WallClockZero`,
34004 // `LimitsError::CpuZero`, `SupervisorError::ZeroRestartWindow`,
34005 // `AplicacaoError::PolicyTimeoutZero` /
34006 // `PolicyCircuitBreakerWindowZero` / `PolicyRateLimitZero`)
34007 // are what refuse zero-magnitude authoring, not this codec-
34008 // layer predicate.
34009 assert!(!is_leading_zero_padded_magnitude("0"));
34010 }
34011
34012 // ── shared predicate: is_digit_only_magnitude ───────────────────────
34013 //
34014 // Pins the accepted / rejected set of the lifted digit-only
34015 // predicate every typed-magnitude codec in caixa-core calls
34016 // (`parse_byte_size` / `parse_duration` / `parse_millicores` /
34017 // shared `duration_codec` / `rate_limit_codec`). Same lifted-
34018 // source-of-truth discipline the peer canonical-form predicates
34019 // (`find_ascii_whitespace_byte` / `find_non_ascii_whitespace_char`
34020 // / `is_leading_zero_padded_magnitude`) carry — drift between any
34021 // two codec sites' rejection set becomes a single-edit fix at
34022 // this predicate.
34023
34024 #[test]
34025 fn is_digit_only_magnitude_accepts_canonical_forms() {
34026 // Complement-side pin: every canonical form the typed-magnitude
34027 // `render_*` canonicalizers emit — the single-byte `"0"` case
34028 // and every non-zero non-leading-zero magnitude — returns
34029 // `true`.
34030 assert!(is_digit_only_magnitude("0"));
34031 assert!(is_digit_only_magnitude("1"));
34032 assert!(is_digit_only_magnitude("64"));
34033 assert!(is_digit_only_magnitude("500"));
34034 assert!(is_digit_only_magnitude("1024"));
34035 assert!(is_digit_only_magnitude("999999"));
34036 }
34037
34038 #[test]
34039 fn is_digit_only_magnitude_flags_empty_magnitude() {
34040 // Defense-in-depth: the empty string is non-digit-only per the
34041 // predicate's contract, so a future codec reaching for this
34042 // predicate before landing its own upstream empty-magnitude
34043 // arm still routes empty input to the non-canonical branch
34044 // rather than silently accepting it via the vacuous
34045 // `bytes().all(_)` truth on the empty byte-slice.
34046 assert!(!is_digit_only_magnitude(""));
34047 }
34048
34049 #[test]
34050 fn is_digit_only_magnitude_flags_leading_sign() {
34051 // The paste-from-signed-report drift class every codec's
34052 // `render_*` emits the unsigned form for. On current Rust
34053 // `u64::from_str` / `u32::from_str` permissively accept a
34054 // leading `+` (`"+500"` → 500), so `"+30"`, `"+500"`, `"+100"`
34055 // survive the parser and round-trip through `render_*` to the
34056 // sign-stripped form (`"30"`, `"500"`, `"100"`) — a *different*
34057 // canonical string on the next emit, breaking the THEORY.md
34058 // Part V render-determinism contract. The digit-only gate is
34059 // what closes the leading-sign class at each codec site.
34060 assert!(!is_digit_only_magnitude("+30"));
34061 assert!(!is_digit_only_magnitude("+500"));
34062 assert!(!is_digit_only_magnitude("+100"));
34063 assert!(!is_digit_only_magnitude("-30"));
34064 assert!(!is_digit_only_magnitude("-1"));
34065 }
34066
34067 #[test]
34068 fn is_digit_only_magnitude_flags_fractional_and_decimal() {
34069 // The paste-from-floating-point-source drift class every
34070 // codec's `render_*` emits the integer form for. On the peer
34071 // duration codec the parser accepts `f64`-shaped magnitudes
34072 // (`"1.5s"` → 1500ms → `"1500ms"`, `"1.0s"` → 1s → `"1s"`,
34073 // `"0.5m"` → 30s → `"30s"`) — a *different* canonical string
34074 // on the next emit, breaking the THEORY.md Part V render-
34075 // determinism contract. The digit-only gate closes the
34076 // decimal-point / fractional / exponent class at each codec
34077 // site.
34078 assert!(!is_digit_only_magnitude("1.5"));
34079 assert!(!is_digit_only_magnitude("1.0"));
34080 assert!(!is_digit_only_magnitude("0.5"));
34081 assert!(!is_digit_only_magnitude("1e3"));
34082 assert!(!is_digit_only_magnitude(".5"));
34083 assert!(!is_digit_only_magnitude("5."));
34084 }
34085
34086 #[test]
34087 fn is_digit_only_magnitude_flags_alphabetic_and_symbol_bytes() {
34088 // Complement-side pin on the "garbage" branch: alphabetic
34089 // bytes / symbol bytes / whitespace bytes each land on the
34090 // non-digit-only side. At the codec site the downstream
34091 // "non-canonical-but-numeric vs garbage" partition surfaces
34092 // these with the narrower `Bad*` diagnostic; here the
34093 // predicate simply reports `false`.
34094 assert!(!is_digit_only_magnitude("a"));
34095 assert!(!is_digit_only_magnitude("64a"));
34096 assert!(!is_digit_only_magnitude("6_4"));
34097 assert!(!is_digit_only_magnitude("64 "));
34098 assert!(!is_digit_only_magnitude(" 64"));
34099 }
34100
34101 #[test]
34102 fn is_digit_only_magnitude_pins_leading_zero_boundary() {
34103 // The leading-zero-padded magnitude shape stays inside the
34104 // digit-only accepted set at this predicate — every byte is
34105 // an ASCII digit. The peer
34106 // [`is_leading_zero_padded_magnitude`] predicate closes the
34107 // leading-zero drift class on a separate, strictly-later arm
34108 // at each codec site. Pinning this partition so a future
34109 // widening that collapses the two arms surfaces as a test
34110 // failure rather than a silent break of the two-predicate
34111 // codec-layer discipline.
34112 assert!(is_digit_only_magnitude("00"));
34113 assert!(is_digit_only_magnitude("0064"));
34114 assert!(is_digit_only_magnitude("0500"));
34115 }
34116
34117 // ── require_positive_bounded_{u32,u64} ──────────────────────────────
34118
34119 #[derive(Debug, PartialEq, Eq)]
34120 enum TestErr {
34121 Zero,
34122 Cap(u64),
34123 }
34124
34125 #[test]
34126 fn require_positive_bounded_u32_accepts_in_range() {
34127 assert_eq!(
34128 require_positive_bounded_u32::<TestErr>(
34129 1,
34130 10,
34131 || TestErr::Zero,
34132 |v| TestErr::Cap(u64::from(v))
34133 ),
34134 Ok(())
34135 );
34136 assert_eq!(
34137 require_positive_bounded_u32::<TestErr>(
34138 10,
34139 10,
34140 || TestErr::Zero,
34141 |v| TestErr::Cap(u64::from(v))
34142 ),
34143 Ok(())
34144 );
34145 assert_eq!(
34146 require_positive_bounded_u32::<TestErr>(
34147 5,
34148 10,
34149 || TestErr::Zero,
34150 |v| TestErr::Cap(u64::from(v))
34151 ),
34152 Ok(())
34153 );
34154 }
34155
34156 #[test]
34157 fn require_positive_bounded_u32_rejects_zero_with_self_locating_diagnostic() {
34158 // The zero-floor arm strictly precedes the cap arm — a value of
34159 // 0 surfaces the `on_zero` callback's discriminator (which every
34160 // per-axis error variant documents an omit-axis remediation for),
34161 // never the `on_cap_exceeded` callback (which would misframe
34162 // "0 > cap == false" as an above-cap value).
34163 assert_eq!(
34164 require_positive_bounded_u32::<TestErr>(
34165 0,
34166 10,
34167 || TestErr::Zero,
34168 |v| TestErr::Cap(u64::from(v))
34169 ),
34170 Err(TestErr::Zero)
34171 );
34172 // Pin the ordering under the degenerate cap == 0 boundary: even
34173 // when the cap itself is 0 (never valid for a positive-bounded
34174 // axis in production, but pins the ordering contract), 0 routes
34175 // through the zero arm — not the cap arm.
34176 assert_eq!(
34177 require_positive_bounded_u32::<TestErr>(
34178 0,
34179 0,
34180 || TestErr::Zero,
34181 |v| TestErr::Cap(u64::from(v))
34182 ),
34183 Err(TestErr::Zero)
34184 );
34185 }
34186
34187 #[test]
34188 fn require_positive_bounded_u32_rejects_above_cap_with_value_threaded() {
34189 assert_eq!(
34190 require_positive_bounded_u32::<TestErr>(
34191 11,
34192 10,
34193 || TestErr::Zero,
34194 |v| TestErr::Cap(u64::from(v))
34195 ),
34196 Err(TestErr::Cap(11))
34197 );
34198 assert_eq!(
34199 require_positive_bounded_u32::<TestErr>(
34200 u32::MAX,
34201 10,
34202 || TestErr::Zero,
34203 |v| TestErr::Cap(u64::from(v))
34204 ),
34205 Err(TestErr::Cap(u64::from(u32::MAX)))
34206 );
34207 }
34208
34209 #[test]
34210 fn require_positive_bounded_u64_accepts_in_range() {
34211 assert_eq!(
34212 require_positive_bounded_u64::<TestErr>(1, 10, || TestErr::Zero, TestErr::Cap),
34213 Ok(())
34214 );
34215 assert_eq!(
34216 require_positive_bounded_u64::<TestErr>(10, 10, || TestErr::Zero, TestErr::Cap),
34217 Ok(())
34218 );
34219 }
34220
34221 #[test]
34222 fn require_positive_bounded_u64_rejects_zero_and_above_cap() {
34223 assert_eq!(
34224 require_positive_bounded_u64::<TestErr>(0, 10, || TestErr::Zero, TestErr::Cap),
34225 Err(TestErr::Zero)
34226 );
34227 assert_eq!(
34228 require_positive_bounded_u64::<TestErr>(11, 10, || TestErr::Zero, TestErr::Cap),
34229 Err(TestErr::Cap(11))
34230 );
34231 assert_eq!(
34232 require_positive_bounded_u64::<TestErr>(u64::MAX, 10, || TestErr::Zero, TestErr::Cap),
34233 Err(TestErr::Cap(u64::MAX))
34234 );
34235 }
34236
34237 // ── require_positive_quantum_multiple_bounded_u64 ────────────────────
34238
34239 #[derive(Debug, PartialEq, Eq)]
34240 enum QuantumTestErr {
34241 Zero,
34242 BelowQuantum(u64),
34243 Cap(u64),
34244 NotMultiple(u64),
34245 }
34246
34247 fn q_gate(value: u64, quantum: u64, cap: u64) -> Result<(), QuantumTestErr> {
34248 require_positive_quantum_multiple_bounded_u64(
34249 value,
34250 quantum,
34251 cap,
34252 || QuantumTestErr::Zero,
34253 QuantumTestErr::BelowQuantum,
34254 QuantumTestErr::Cap,
34255 QuantumTestErr::NotMultiple,
34256 )
34257 }
34258
34259 #[test]
34260 fn require_positive_quantum_multiple_bounded_u64_accepts_in_range_multiples() {
34261 // Every canonical quantum-multiple in `quantum..=cap` — the shared
34262 // accepted set every quantized-byte-cap consumer inherits — must
34263 // pass the gate. Pin the accepted set here so a future tightening
34264 // surfaces as a test failure rather than a silent narrowing at
34265 // the single consumer site (`:limits :memory`).
34266 let quantum = 64 * 1024;
34267 let cap = 4 * 1024 * 1024 * 1024;
34268 for value in [quantum, quantum * 2, quantum * 100, quantum * 1000, cap] {
34269 assert_eq!(
34270 q_gate(value, quantum, cap),
34271 Ok(()),
34272 "quantum-multiple in-range value {value} must pass the gate",
34273 );
34274 }
34275 }
34276
34277 #[test]
34278 fn require_positive_quantum_multiple_bounded_u64_rejects_zero_before_other_arms() {
34279 // The zero-floor arm strictly precedes the below-quantum, cap,
34280 // and not-multiple arms — a value of 0 surfaces the
34281 // caller's self-locating `on_zero` diagnostic (every per-axis
34282 // error variant documents an "omit the axis to express no-bound"
34283 // remediation for) rather than the misleading below-quantum arm
34284 // (which would also fire because 0 < quantum) or the not-multiple
34285 // arm (which the modulus check `0 % quantum == 0` would silently
34286 // accept).
34287 let quantum = 64 * 1024;
34288 let cap = 4 * 1024 * 1024 * 1024;
34289 assert_eq!(q_gate(0, quantum, cap), Err(QuantumTestErr::Zero));
34290 // The degenerate `cap == 0` / `quantum == 1` boundaries: 0 still
34291 // routes through the zero arm — the ordering contract holds even
34292 // when the cap or quantum themselves take the degenerate shape
34293 // (never valid production shapes for a positive-bounded quantized
34294 // axis, but pin the arm ordering).
34295 assert_eq!(q_gate(0, 1, 0), Err(QuantumTestErr::Zero));
34296 assert_eq!(q_gate(0, quantum, 0), Err(QuantumTestErr::Zero));
34297 }
34298
34299 #[test]
34300 fn require_positive_quantum_multiple_bounded_u64_rejects_below_quantum_before_cap_and_multiple()
34301 {
34302 // The below-quantum arm strictly precedes the cap and
34303 // not-multiple arms — a sub-quantum non-zero value (which is
34304 // ALSO not a quantum-multiple by construction, since the
34305 // smallest positive quantum-multiple *is* `quantum`) surfaces
34306 // the more actionable "raise to at least one quantum" diagnostic
34307 // rather than the not-multiple no-op. Pin the ordering across
34308 // the value grid — every value in `1..quantum` must fire the
34309 // below-quantum arm with the offending byte count threaded
34310 // through the callback.
34311 let quantum = 64 * 1024;
34312 let cap = 4 * 1024 * 1024 * 1024;
34313 for value in [1u64, 2, 32 * 1024, quantum - 1] {
34314 assert_eq!(
34315 q_gate(value, quantum, cap),
34316 Err(QuantumTestErr::BelowQuantum(value)),
34317 "sub-quantum {value} must surface BelowQuantum before Cap / NotMultiple",
34318 );
34319 }
34320 }
34321
34322 #[test]
34323 fn require_positive_quantum_multiple_bounded_u64_rejects_above_cap_before_not_multiple() {
34324 // The cap arm strictly precedes the not-multiple arm — a value
34325 // that is *both* above-cap and sub-quantum-residue must surface
34326 // the more aggressive cap-shape diagnostic first (the
34327 // not-multiple remediation would be misleading when the
34328 // offending value exceeds the upper bracket anyway; the
34329 // canonical fix collapses both into "pin a quantum-aligned
34330 // value ≤ cap"). Pin the ordering across the value grid,
34331 // including the boundary case `cap + 1`.
34332 let quantum = 64 * 1024;
34333 let cap = 4 * 1024 * 1024 * 1024;
34334 for value in [
34335 cap + 1, // above-cap AND sub-quantum-residue
34336 cap + quantum, // above-cap and quantum-aligned
34337 cap + quantum * 100, // well above-cap and quantum-aligned
34338 u64::MAX, // maximally above-cap
34339 ] {
34340 assert_eq!(
34341 q_gate(value, quantum, cap),
34342 Err(QuantumTestErr::Cap(value)),
34343 "above-cap {value} must surface Cap before NotMultiple",
34344 );
34345 }
34346 }
34347
34348 #[test]
34349 fn require_positive_quantum_multiple_bounded_u64_rejects_not_multiple_with_value_threaded() {
34350 // The not-multiple arm surfaces the offending value verbatim so
34351 // the caller's `on_not_quantum_multiple` variant threads it into
34352 // its discriminator field (`bytes:`). Pin the arm across the
34353 // in-range-but-not-aligned value grid — every value in
34354 // `quantum..=cap` carrying a sub-quantum residue must fire the
34355 // not-multiple arm.
34356 let quantum = 64 * 1024;
34357 let cap = 4 * 1024 * 1024 * 1024;
34358 for value in [
34359 quantum + 1, // one page plus a 1-byte residue
34360 quantum * 2 - 1, // two pages minus one byte
34361 100_000, // ≈ 97.65 KiB — one page + 34_464-byte residue
34362 quantum * 100 + 7, // 100 pages plus a 7-byte residue
34363 ] {
34364 assert_eq!(
34365 q_gate(value, quantum, cap),
34366 Err(QuantumTestErr::NotMultiple(value)),
34367 "sub-quantum-residue {value} must surface NotMultiple",
34368 );
34369 }
34370 }
34371
34372 // ── require_positive_canonical_bounded_duration ─────────────────────
34373
34374 #[derive(Debug, PartialEq, Eq)]
34375 enum DurationTestErr {
34376 Zero,
34377 NotCanonical(Duration),
34378 Cap(Duration),
34379 }
34380
34381 #[test]
34382 fn require_positive_canonical_bounded_duration_accepts_in_range_canonical_values() {
34383 // Every canonical integer-millisecond `Duration` in
34384 // `1ms..=cap` — the shared accepted set every typed-`Duration`
34385 // consumer inherits — must pass the gate. Pin the canonical
34386 // set here so a future tightening surfaces as a test failure
34387 // rather than a silent narrowing at one of the four consumer
34388 // sites (`:politicas :timeout`, `:circuit-breaker :window`,
34389 // `:limits :wall-clock`, `:supervisor :restart-window`).
34390 let cap = Duration::from_secs(3600); // matches the 1h peer caps
34391 for value in [
34392 Duration::from_millis(1),
34393 Duration::from_millis(500),
34394 Duration::from_millis(1500),
34395 Duration::from_secs(30),
34396 Duration::from_secs(60),
34397 cap,
34398 ] {
34399 assert_eq!(
34400 require_positive_canonical_bounded_duration::<DurationTestErr>(
34401 value,
34402 cap,
34403 || DurationTestErr::Zero,
34404 DurationTestErr::NotCanonical,
34405 DurationTestErr::Cap,
34406 ),
34407 Ok(()),
34408 "canonical in-range value {value:?} must pass the gate",
34409 );
34410 }
34411 }
34412
34413 #[test]
34414 fn require_positive_canonical_bounded_duration_rejects_zero_before_canonical_and_cap() {
34415 // The zero-floor arm strictly precedes the canonical-form and
34416 // cap arms — `Duration::ZERO` (which has `subsec_nanos() == 0`
34417 // and would pass the canonical-form predicate; and would pass
34418 // the cap arm since 0 ≤ cap) routes through the zero arm so
34419 // the caller's self-locating `on_zero` diagnostic (every
34420 // per-axis error variant documents an omit-axis remediation
34421 // for) is surfaced, not the misleading no-op the two later
34422 // arms would return.
34423 let cap = Duration::from_secs(3600);
34424 assert_eq!(
34425 require_positive_canonical_bounded_duration::<DurationTestErr>(
34426 Duration::ZERO,
34427 cap,
34428 || DurationTestErr::Zero,
34429 DurationTestErr::NotCanonical,
34430 DurationTestErr::Cap,
34431 ),
34432 Err(DurationTestErr::Zero),
34433 );
34434 // The degenerate `cap == Duration::ZERO` boundary: `Duration::ZERO`
34435 // still routes through the zero arm — the ordering contract holds
34436 // even when the cap itself is zero (never a valid production cap
34437 // for a positive-bounded axis, but pins the arm ordering).
34438 assert_eq!(
34439 require_positive_canonical_bounded_duration::<DurationTestErr>(
34440 Duration::ZERO,
34441 Duration::ZERO,
34442 || DurationTestErr::Zero,
34443 DurationTestErr::NotCanonical,
34444 DurationTestErr::Cap,
34445 ),
34446 Err(DurationTestErr::Zero),
34447 );
34448 }
34449
34450 #[test]
34451 fn require_positive_canonical_bounded_duration_rejects_sub_millisecond_before_cap() {
34452 // The canonical-form arm strictly precedes the cap arm — a
34453 // `Duration` that is *both* sub-millisecond and above-cap must
34454 // surface the more fundamental round-trip-shape diagnostic
34455 // first (the cap arm's `1ms..=<cap>` remediation prose would
34456 // be misleading when no integer-ms form of the offending
34457 // value exists). Pin the ordering across the value grid.
34458 let cap = Duration::from_secs(1);
34459 for value in [
34460 Duration::from_micros(1),
34461 Duration::from_micros(500),
34462 Duration::from_micros(1500),
34463 Duration::from_nanos(1),
34464 Duration::from_nanos(999_999),
34465 Duration::from_nanos(1_000_001),
34466 // Sub-millisecond *and* above-cap: canonical-form arm wins.
34467 cap + Duration::from_nanos(1),
34468 ] {
34469 let result = require_positive_canonical_bounded_duration::<DurationTestErr>(
34470 value,
34471 cap,
34472 || DurationTestErr::Zero,
34473 DurationTestErr::NotCanonical,
34474 DurationTestErr::Cap,
34475 );
34476 assert_eq!(
34477 result,
34478 Err(DurationTestErr::NotCanonical(value)),
34479 "sub-millisecond {value:?} must surface NotCanonical before Cap",
34480 );
34481 }
34482 }
34483
34484 #[test]
34485 fn require_positive_canonical_bounded_duration_rejects_above_cap_with_value_threaded() {
34486 // The cap arm surfaces the offending value verbatim so the
34487 // caller's `on_cap_exceeded` variant threads it into its
34488 // discriminator field (`timeout` / `window` / `wall_clock`).
34489 // The value grid covers the canonical `<n>ms` / `<n>s`
34490 // integer-millisecond shape past the 1h cap so the arm ordering
34491 // (canonical-form first) doesn't intercept these values.
34492 let cap = Duration::from_secs(3600);
34493 for value in [
34494 cap + Duration::from_millis(1),
34495 cap + Duration::from_secs(1),
34496 Duration::from_secs(24 * 3600), // 24h — canonical string
34497 Duration::from_secs(7 * 24 * 3600), // 7d
34498 ] {
34499 assert_eq!(
34500 require_positive_canonical_bounded_duration::<DurationTestErr>(
34501 value,
34502 cap,
34503 || DurationTestErr::Zero,
34504 DurationTestErr::NotCanonical,
34505 DurationTestErr::Cap,
34506 ),
34507 Err(DurationTestErr::Cap(value)),
34508 "above-cap canonical value {value:?} must thread through the cap arm",
34509 );
34510 }
34511 }
34512
34513 // ── require_valid_versao_requirement ────────────────────────────────
34514
34515 #[derive(Debug, PartialEq, Eq)]
34516 enum VersaoTestErr {
34517 Empty,
34518 Invalid(String),
34519 }
34520
34521 #[test]
34522 fn require_valid_versao_requirement_accepts_canonical_forms() {
34523 // Every Cargo-shaped requirement string the substrate accepts on
34524 // any `:versao` axis (`:deps`, `:membros`, `:children`) must pass
34525 // the shared gate — pin the canonical set here so a future
34526 // tightening surfaces as a test failure rather than a silent
34527 // narrowing at one of the three consumer sites. Same accepted set
34528 // as `accepts_canonical_membro_versao_forms` /
34529 // `accepts_canonical_dep_versao_forms` on the sibling per-axis
34530 // pins.
34531 for form in [
34532 "^0.1", // caret — minor-range pin (the most common shape)
34533 "~0.1.2", // tilde — patch-range pin
34534 "0.1.0", // exact — single-version pin
34535 "*", // wildcard — explicitly any-version (VersionReq::STAR)
34536 ">=0.1, <2", // multi-range — comma-separated comparators
34537 ] {
34538 assert_eq!(
34539 require_valid_versao_requirement::<VersaoTestErr>(
34540 form,
34541 || VersaoTestErr::Empty,
34542 VersaoTestErr::Invalid,
34543 ),
34544 Ok(()),
34545 "canonical form {form:?} must pass the gate",
34546 );
34547 }
34548 }
34549
34550 #[test]
34551 fn require_valid_versao_requirement_rejects_empty_before_parse() {
34552 // The empty-first arm strictly precedes the parse arm. Without
34553 // this arm the parser silently widens `""` to
34554 // `VersionReq { comparators: [] }` (semantically `*`) — a
34555 // "silent widening" footgun the three consumer sites each
34556 // documented in their `MembroVersaoEmpty` / `EmptyChildVersion` /
34557 // `VersaoEmpty` variants and now inherit by construction.
34558 assert_eq!(
34559 require_valid_versao_requirement::<VersaoTestErr>(
34560 "",
34561 || VersaoTestErr::Empty,
34562 VersaoTestErr::Invalid,
34563 ),
34564 Err(VersaoTestErr::Empty),
34565 );
34566 }
34567
34568 #[test]
34569 fn require_valid_versao_requirement_rejects_malformed_with_reason_threaded() {
34570 // The canonical malformed-shape set the three consumer sites
34571 // formerly each re-tested inline. The gate threads the
34572 // parser's `to_string()` output through as the invalid arm's
34573 // `reason:` verbatim — the field the three sibling error
34574 // variants (`{Dep,Membro,Child}VersaoInvalid.reason`) each
34575 // carry to the author's remediation prose.
34576 for bad in [
34577 "^^0.1", // doubled-caret typo
34578 "v0.1", // git-tag-shape leaking into requirement slot
34579 "abc", // gibberish
34580 "~~", // stacked-operator gibberish
34581 ] {
34582 let result = require_valid_versao_requirement::<VersaoTestErr>(
34583 bad,
34584 || VersaoTestErr::Empty,
34585 VersaoTestErr::Invalid,
34586 );
34587 match result {
34588 Err(VersaoTestErr::Invalid(reason)) => {
34589 assert!(
34590 !reason.is_empty(),
34591 "invalid arm must thread a non-empty reason for {bad:?}",
34592 );
34593 }
34594 other => panic!("expected Invalid for {bad:?}, got {other:?}"),
34595 }
34596 }
34597 }
34598
34599 // ── require_valid_dns_1123_label ────────────────────────────────────
34600
34601 #[derive(Debug, PartialEq, Eq)]
34602 enum LabelTestErr {
34603 Empty,
34604 Invalid(String),
34605 }
34606
34607 #[test]
34608 fn require_valid_dns_1123_label_accepts_canonical_forms() {
34609 // Every DNS-1123-label-shaped Servico-name reference the substrate
34610 // accepts on any name axis (`:membros :caixa`, `:placement :clusters`,
34611 // `:placement :affinity`, `:contratos :de`/`:para`, `:entrada :para`,
34612 // `:children :caixa`, `:nome`, `:upgrade-from :module`) must pass
34613 // the shared gate — pin the canonical set here so a future
34614 // tightening surfaces as a test failure rather than a silent
34615 // narrowing at one of the eight consumer sites. Same accepted set
34616 // as the sibling per-axis DNS-1123-label pins already carry.
34617 for form in [
34618 "hello-rio", // canonical dashed
34619 "cart", // single-token
34620 "rio-1", // trailing digit
34621 "1-rio", // leading digit
34622 "a", // one byte
34623 &"a".repeat(DNS_1123_LABEL_MAX_LEN), // max length exact
34624 ] {
34625 assert_eq!(
34626 require_valid_dns_1123_label::<LabelTestErr>(
34627 form,
34628 || LabelTestErr::Empty,
34629 LabelTestErr::Invalid,
34630 ),
34631 Ok(()),
34632 "canonical form {form:?} must pass the gate",
34633 );
34634 }
34635 }
34636
34637 #[test]
34638 fn require_valid_dns_1123_label_rejects_empty_before_shape() {
34639 // The empty-first arm strictly precedes the shape arm so a
34640 // literal `""` surfaces each per-axis error variant's narrower
34641 // self-locating `_Empty` diagnostic rather than the shared
34642 // predicate's generic "must not be empty" prose the shape arm
34643 // would thread through — the same "misframed generic diagnostic"
34644 // footgun the peer [`require_valid_versao_requirement`] closes
34645 // on its empty arm. The eight consumer sites each documented
34646 // this ordering in their `MembroCaixaEmpty` / `PlacementClusterEmpty`
34647 // / `PlacementAffinityEmpty` / `ContratoCaixaEmpty` /
34648 // `EntradaParaEmpty` / `NomeEmpty` / `EmptyChildName` /
34649 // `ModuleEmpty` variants and now inherit it by construction.
34650 assert_eq!(
34651 require_valid_dns_1123_label::<LabelTestErr>(
34652 "",
34653 || LabelTestErr::Empty,
34654 LabelTestErr::Invalid,
34655 ),
34656 Err(LabelTestErr::Empty),
34657 );
34658 }
34659
34660 #[test]
34661 fn require_valid_dns_1123_label_rejects_malformed_with_reason_threaded() {
34662 // The canonical malformed-shape set the eight consumer sites
34663 // formerly each re-tested inline. The gate threads the
34664 // predicate's shape-shaped reason through as the invalid arm's
34665 // `reason:` verbatim — the field every sibling error variant
34666 // (`{MembroCaixa,PlacementCluster,PlacementAffinity,ContratoCaixa,
34667 // EntradaPara,Nome,ChildCaixa,Module}Invalid.reason`) each
34668 // carry to the author's remediation prose.
34669 for bad in [
34670 "Rio", // uppercase — the canonical TitleCase-from-an-ADR typo
34671 "my_cart", // underscore — the Python-module-name leak
34672 "team.cart", // dot — the namespace-dot-on-a-label confusion
34673 "-cart", // leading hyphen — boundary violation
34674 "cart-", // trailing hyphen — boundary violation
34675 ] {
34676 let result = require_valid_dns_1123_label::<LabelTestErr>(
34677 bad,
34678 || LabelTestErr::Empty,
34679 LabelTestErr::Invalid,
34680 );
34681 match result {
34682 Err(LabelTestErr::Invalid(reason)) => {
34683 assert!(
34684 !reason.is_empty(),
34685 "invalid arm must thread a non-empty reason for {bad:?}",
34686 );
34687 }
34688 other => panic!("expected Invalid for {bad:?}, got {other:?}"),
34689 }
34690 }
34691 }
34692
34693 // ── require_sandboxed_lisp_path ─────────────────────────────────────
34694
34695 #[derive(Debug, PartialEq, Eq)]
34696 enum LispPathTestErr {
34697 Empty,
34698 Absolute,
34699 ParentEscape,
34700 NonLisp,
34701 }
34702
34703 fn call_require_sandboxed_lisp_path(path: &Path) -> Result<(), LispPathTestErr> {
34704 require_sandboxed_lisp_path(
34705 path,
34706 || LispPathTestErr::Empty,
34707 || LispPathTestErr::Absolute,
34708 || LispPathTestErr::ParentEscape,
34709 || LispPathTestErr::NonLisp,
34710 )
34711 }
34712
34713 #[test]
34714 fn require_sandboxed_lisp_path_accepts_canonical_forms() {
34715 // Every sandboxed-relative `.lisp`-terminating path the substrate
34716 // accepts on either M2 tatara-lisp source-path axis (`:behavior :on-*`
34717 // callback paths, `:upgrade-from :state-change :script`) must pass
34718 // the shared gate. Pin the canonical set here so a future tightening
34719 // surfaces as a test failure rather than a silent narrowing at one
34720 // of the two consumer sites.
34721 for form in [
34722 "lib/init.lisp", // canonical example
34723 "lib/handlers.lisp", // multi-callback shape
34724 "lib/migrations/v01-to-v02.lisp", // nested-directory shape
34725 "a.lisp", // one-byte stem
34726 "lib/deep/nested/path/to/file.lisp", // deeply nested
34727 ] {
34728 assert_eq!(
34729 call_require_sandboxed_lisp_path(Path::new(form)),
34730 Ok(()),
34731 "canonical sandboxed `.lisp` form {form:?} must pass the gate",
34732 );
34733 }
34734 }
34735
34736 #[test]
34737 fn require_sandboxed_lisp_path_rejects_empty_before_all_later_arms() {
34738 // The empty-first arm strictly precedes every downstream arm — a
34739 // literal `""` (which the is_absolute check would return false on,
34740 // which carries no ParentDir component, and whose extension is
34741 // absent) routes through the `on_empty` closure so the caller's
34742 // narrower self-locating `_Empty` / `_EmptyScript` diagnostic fires,
34743 // not a misleading `_Absolute` / `_ParentEscape` / `_NonLisp` miss
34744 // downstream. Peer of every zero-first arm ordering the sibling
34745 // require_positive_bounded_* helpers already carry.
34746 assert_eq!(
34747 call_require_sandboxed_lisp_path(Path::new("")),
34748 Err(LispPathTestErr::Empty),
34749 );
34750 }
34751
34752 #[test]
34753 fn require_sandboxed_lisp_path_rejects_absolute_before_parent_escape_and_non_lisp() {
34754 // The absolute arm strictly precedes the parent-escape and
34755 // non-`.lisp`-extension arms — an absolute path (regardless of
34756 // whether it also carries `..` components or a non-`.lisp`
34757 // extension) routes through the `on_absolute` closure so the
34758 // caller's `_Absolute` / `_AbsoluteScript` diagnostic fires with
34759 // its "must be relative to the caixa root" remediation, not the
34760 // misleading later arms. Pin the ordering across the value grid
34761 // covering "absolute + parent-escape" and "absolute + non-`.lisp`"
34762 // compound-violation shapes so a future arm-reorder silently
34763 // narrowing the accepted set would surface at build time.
34764 for absolute in [
34765 "/etc/passwd", // canonical absolute
34766 "/lib/init.lisp", // absolute + `.lisp` (extension arm never reached)
34767 "/lib/../init.lisp", // absolute + parent-escape (later arm never reached)
34768 "/etc/init.txt", // absolute + non-`.lisp`
34769 ] {
34770 assert_eq!(
34771 call_require_sandboxed_lisp_path(Path::new(absolute)),
34772 Err(LispPathTestErr::Absolute),
34773 "absolute path {absolute:?} must route through Absolute arm",
34774 );
34775 }
34776 }
34777
34778 #[test]
34779 fn require_sandboxed_lisp_path_rejects_parent_escape_before_non_lisp() {
34780 // The parent-escape arm strictly precedes the non-`.lisp`-extension
34781 // arm — a relative path carrying any `..` component routes through
34782 // the `on_parent_escape` closure so the caller's `_ParentEscape` /
34783 // `_ParentEscapeScript` diagnostic fires with its "must not
34784 // traverse above the caixa root" remediation, not the misleading
34785 // extension-shape arm. Pin the ordering across leading / mid-path
34786 // / trailing parent-escape positions plus the compound
34787 // "parent-escape + non-`.lisp`" shape.
34788 for escape in [
34789 "../sibling/x.lisp", // leading `..`
34790 "lib/../other.lisp", // mid-path `..`
34791 "lib/handlers/../..", // trailing `..`
34792 "../sibling/x.txt", // parent-escape + non-`.lisp`
34793 ] {
34794 assert_eq!(
34795 call_require_sandboxed_lisp_path(Path::new(escape)),
34796 Err(LispPathTestErr::ParentEscape),
34797 "parent-escaping path {escape:?} must route through ParentEscape arm",
34798 );
34799 }
34800 }
34801
34802 #[test]
34803 fn require_sandboxed_lisp_path_rejects_non_lisp_only_after_all_path_shape_arms_accept() {
34804 // The non-`.lisp`-extension arm fires only when every prior arm
34805 // (empty / absolute / parent-escape) accepts the path — a
34806 // sandboxed relative path whose only violation is a non-`.lisp`
34807 // terminating extension routes through the `on_non_lisp` closure
34808 // so the caller's `_NonLispExtension` / `_NonLispExtensionScript`
34809 // diagnostic fires with its `.lisp`-remediation prose. Pin the
34810 // downstream-most-arm reachability across the canonical
34811 // `.txt`/`.rs`/no-extension/double-extension-shadow shape set the
34812 // two consumer sites' error variants each document.
34813 for bad_ext in [
34814 "lib/init.txt", // wrong extension
34815 "lib/init.rs", // Rust source leaked into caixa
34816 "lib/init.lisp.bak", // double-extension shadow
34817 "lib/init", // no extension
34818 "lib/migrations", // no extension, no dot
34819 "lib/init.LISP", // uppercase — case-sensitive gate
34820 ] {
34821 assert_eq!(
34822 call_require_sandboxed_lisp_path(Path::new(bad_ext)),
34823 Err(LispPathTestErr::NonLisp),
34824 "non-`.lisp` path {bad_ext:?} must route through NonLisp arm",
34825 );
34826 }
34827 }
34828
34829 #[test]
34830 fn require_sandboxed_lisp_path_ordering_matches_inline_pre_lift_cascade() {
34831 // Byte-for-byte the same `Empty → Absolute → ParentEscape → NonLisp`
34832 // arm-ordering the two consumer sites (`validate_callback_path` in
34833 // `caixa-core::behavior`, `UpgradeInstruction::validate`'s
34834 // `StateChange` arm in `caixa-core::upgrade`) each formerly inlined
34835 // verbatim. This pin catches any future reorder that would
34836 // silently reshape the diagnostic dispatch at either site — the
34837 // helper's ordering IS the two sites' ordering, not a re-derived
34838 // convention. Pins the same
34839 // smallest-scope-arm-fires-last three-path drift-detection
34840 // posture the peer `require_positive_bounded_*` /
34841 // `require_positive_canonical_bounded_duration` helpers already
34842 // carry on their own arm sets.
34843 assert_eq!(
34844 call_require_sandboxed_lisp_path(Path::new("")),
34845 Err(LispPathTestErr::Empty),
34846 );
34847 assert_eq!(
34848 call_require_sandboxed_lisp_path(Path::new("/abs/x.lisp")),
34849 Err(LispPathTestErr::Absolute),
34850 );
34851 assert_eq!(
34852 call_require_sandboxed_lisp_path(Path::new("../x.lisp")),
34853 Err(LispPathTestErr::ParentEscape),
34854 );
34855 assert_eq!(
34856 call_require_sandboxed_lisp_path(Path::new("lib/x.txt")),
34857 Err(LispPathTestErr::NonLisp),
34858 );
34859 assert_eq!(
34860 call_require_sandboxed_lisp_path(Path::new("lib/x.lisp")),
34861 Ok(()),
34862 );
34863 }
34864
34865 #[test]
34866 fn gateway_api_hostname_max_len_pins_canonical_value() {
34867 // Pin the actual byte count so a typo in this lift can't silently
34868 // rebrand the K8s Gateway API v1 `Listener.hostname` /
34869 // `HTTPRoute.spec.hostnames[]` admission-schema `maxLength:` cap
34870 // the `AplicacaoSpec::validate` `:entrada :host` total-length arm
34871 // reads. The value is part of the cluster-side contract with
34872 // every Gateway API v1 CRD schema validator (apiserver-side +
34873 // Cilium / Envoy Gateway / Istio / NGINX per-implementation
34874 // webhooks) — the OpenAPI schema on the Hostname type binds
34875 // `maxLength: 253` verbatim (RFC 1035 / RFC 1123 DNS name limit:
34876 // 255 wire bytes minus the trailing-dot + one length prefix), so
34877 // a drifted value at either the aplicacao-side validator or a
34878 // downstream renderer's per-host validator silently emits a
34879 // Gateway / HTTPRoute the apiserver rejects at admission time
34880 // with an opaque `field is invalid` diagnostic far from the
34881 // caixa.lisp source line. Changing this value is a coordinated
34882 // Gateway API promotion alongside the upstream SIG-Network
34883 // Hostname schema evolution, not an incidental edit. Peer to
34884 // [`GATEWAY_API_HTTP_PATH_MAX_LEN`] (1024) on the sibling
34885 // per-route path-value cap axis — both are apiserver-side
34886 // `maxLength:` bounds on Gateway API v1 landing sites, both lift
34887 // to `caixa-core::render` so the M4 CR materializer's per-axis
34888 // validators (per-host, per-path) read from one place.
34889 assert_eq!(GATEWAY_API_HOSTNAME_MAX_LEN, 253);
34890 }
34891
34892 #[test]
34893 fn gateway_api_hostname_max_len_exceeds_dns_1123_label_max_len() {
34894 // Cross-axis structural invariant: every `.`-separated label in
34895 // a Gateway API v1 Hostname is a DNS-1123 label, so the total
34896 // Hostname cap must strictly exceed the per-label cap — otherwise
34897 // even a single-label host `"foo"` couldn't reach the per-label
34898 // ceiling before hitting the total-length ceiling, and the
34899 // `AplicacaoSpec::validate` `:entrada :host` per-label arm at
34900 // `validate_entrada_host` would be structurally unreachable via
34901 // the total-length arm's own ordering. Pinning the ordering here
34902 // means a future substrate-side tightening of either bound (a
34903 // K8s SIG-Network Hostname promotion narrowing the total cap, a
34904 // DNS-1123 label promotion widening the per-label cap) that
34905 // inverted the two would fail this pin at build time rather than
34906 // silently rendering the per-label arm unreachable.
34907 assert!(
34908 GATEWAY_API_HOSTNAME_MAX_LEN > DNS_1123_LABEL_MAX_LEN,
34909 "GATEWAY_API_HOSTNAME_MAX_LEN ({GATEWAY_API_HOSTNAME_MAX_LEN}) must strictly \
34910 exceed DNS_1123_LABEL_MAX_LEN ({DNS_1123_LABEL_MAX_LEN}) — every \
34911 `.`-separated label in a Gateway API v1 Hostname is itself a DNS-1123 \
34912 label under the apiserver's OpenAPI regex, so the total-length cap \
34913 must be able to accommodate at least one per-label-max label",
34914 );
34915 }
34916
34917 #[test]
34918 fn gateway_api_hostname_max_len_matches_rfc_1035_dns_name_limit() {
34919 // Cross-axis structural invariant: the Gateway API v1 Hostname
34920 // `maxLength: 253` cap is the RFC 1035 / RFC 1123 DNS name limit
34921 // — 255 wire bytes minus one length prefix minus the implicit
34922 // trailing dot — the same cap every DNS-compliant `HostName`
34923 // primitive downstream substrate consumer (the future
34924 // per-`Certificate` SAN emitter for cert-manager, the future
34925 // multi-`:entrada` host-collision gate) will inherit by
34926 // construction. Pinning the arithmetic here rather than the
34927 // literal `253` makes the RFC derivation explicit at the const's
34928 // test site so a future migration onto a different DNS-name
34929 // ceiling (an eventual RFC-successor limit, a per-cluster
34930 // override the operator pins) surfaces at this pin, not at every
34931 // downstream renderer's admission-rejection loop.
34932 assert_eq!(
34933 GATEWAY_API_HOSTNAME_MAX_LEN,
34934 255 - 1 - 1,
34935 "GATEWAY_API_HOSTNAME_MAX_LEN must equal the RFC 1035 / RFC 1123 DNS \
34936 name limit (255 wire bytes minus one length prefix minus the trailing \
34937 dot)",
34938 );
34939 }
34940
34941 #[test]
34942 fn gateway_api_default_http_listener_port_pins_canonical_80_literal() {
34943 // The canonical-constant arm — pins
34944 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`] at the verbatim
34945 // `80` literal the sole `caixa-mesh::gateway_routes` per-
34946 // Aplicacao `Gateway` per-listener HTTP-listener-port axis
34947 // reads from. Peer with the
34948 // [`crate::DEFAULT_SERVICO_PORT`]-pins-`8080` discipline on the
34949 // sibling per-renderer canonical-K8s-port-axis typed `u16`
34950 // const: a future refactor that drifts the constant out from
34951 // under either consumer surfaces here ahead of any per-renderer
34952 // Gateway emission. The literal value is IANA's well-known
34953 // `http` service port (RFC 9110 §4.2.2), so an
34954 // `http://<entrada.host>/…` URL without a `:<port>` selector
34955 // reaches the listener by construction.
34956 assert_eq!(
34957 GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT, 80,
34958 "canonical Gateway API v1 HTTP listener port literal must remain \
34959 `80` verbatim — this is the value the caixa-mesh Gateway emitter \
34960 reads from and the IANA-registered well-known `http` service port"
34961 );
34962 }
34963
34964 #[test]
34965 fn gateway_api_default_http_listener_port_distinct_from_default_servico_port() {
34966 // Cross-axis structural invariant: the Gateway listener's
34967 // external HTTP port ([`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`],
34968 // 80) and the per-Servico in-cluster L4 port
34969 // ([`DEFAULT_SERVICO_PORT`], 8080) are two distinct axes — the
34970 // external-ingress port the K8s Gateway API controller opens on
34971 // the cluster boundary, and the internal-Servico port the
34972 // `pleme-computeunit` chart emits per Servico `Service`.
34973 // Collapsing the two would silently emit a Gateway whose
34974 // listener port matched the Servico's own port, so a stray
34975 // Servico exposing its Service directly to a cluster-external
34976 // LoadBalancer would shadow the Aplicacao's Gateway path — the
34977 // typed two-axis distinction guards against a rebrand on either
34978 // axis silently converging on the other's value. Peer with the
34979 // [`GATEWAY_API_HOSTNAME_MAX_LEN`]-strictly-exceeds-[`DNS_1123_LABEL_MAX_LEN`]
34980 // discipline on the sibling per-axis structural-ordering pin
34981 // set — both are cross-axis invariants between two lifted
34982 // constants that share a downstream renderer.
34983 assert_ne!(
34984 GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT,
34985 crate::DEFAULT_SERVICO_PORT,
34986 "GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT ({GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT}) \
34987 must remain distinct from DEFAULT_SERVICO_PORT ({}) — the two axes name \
34988 different scalars (external-Gateway listener port vs in-cluster Servico port), \
34989 collapsing them silently shadows the Aplicacao's Gateway path",
34990 crate::DEFAULT_SERVICO_PORT,
34991 );
34992 }
34993
34994 #[test]
34995 fn gateway_api_default_http_listener_name_pins_canonical_http_literal() {
34996 // The canonical-constant arm — pins
34997 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME`] at the verbatim
34998 // `"http"` literal the sole `caixa-mesh::gateway_routes` per-
34999 // Aplicacao `Gateway` per-listener name-discriminator axis
35000 // reads from. Peer with the
35001 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`]-pins-`80` discipline
35002 // on the sibling per-listener HTTP-listener-port scalar-axis:
35003 // both are the Aplicacao-side substrate-canonical scalar-value
35004 // pins the sole per-Aplicacao `Gateway` emitter reaches for, so
35005 // a future refactor that drifts either constant out from under
35006 // the emitter surfaces here ahead of any per-renderer Gateway
35007 // emission. The literal value is the substrate's V0 arbitrary-
35008 // author-chosen short listener-name (K8s Gateway API v1's
35009 // `SectionName`-typed field carries no CRD-schema-pinned value
35010 // — the substrate picks `"http"` verbatim to match the
35011 // listener's carried protocol shape at the reader's eye), so
35012 // downstream `HTTPRoute` `sectionName` selectors bind to this
35013 // exact byte-string by construction.
35014 assert_eq!(
35015 GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME, "http",
35016 "canonical Gateway API v1 HTTP listener-name literal must remain \
35017 `\"http\"` verbatim — this is the value the caixa-mesh Gateway \
35018 emitter reads from and the substrate's V0 arbitrary-author-chosen \
35019 short listener-name identifier every downstream `HTTPRoute` \
35020 `parentRefs[].sectionName` selector binds to"
35021 );
35022 }
35023
35024 #[test]
35025 fn gateway_api_default_http_listener_name_carries_dns_1123_label_shape() {
35026 // Cross-axis invariant: K8s Gateway API v1 `Listener.name` is
35027 // `SectionName`-typed — a required DNS-1123 label unique within
35028 // the parent Gateway's listener list. Pinning the shape here
35029 // means a future rebrand on the canonical lift can't silently
35030 // land a malformed listener-name identifier (empty, uppercase,
35031 // whitespace, `.` / `_` / non-alphanumeric characters, an
35032 // overlong string past the DNS-1123 label ceiling) that the
35033 // apiserver-side Gateway API CRD schema validator would reject
35034 // far from the rebrand commit's source. The predicate the
35035 // `caixa-mesh::gateway_routes` per-listener-name emitter never
35036 // consults directly (the value is a const — no author input
35037 // reaches this axis today) gets consulted here so any future
35038 // rebrand routes through the same DNS-1123-label admission
35039 // grammar every K8s CRD `name`-shaped axis carries. Peer to
35040 // `default_gateway_class_name_is_a_valid_dns_1123_label` on
35041 // the sibling per-Gateway `gatewayClassName` scalar-axis pin
35042 // and `default_namespace_is_a_valid_dns_1123_label` on the
35043 // canonical-K8s-namespace lifted scalar — every substrate-side
35044 // K8s-CRD-name-shaped lift carries the same DNS-1123 label
35045 // admission-grammar cross-axis invariant.
35046 assert!(
35047 is_dns_1123_label(GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME).is_ok(),
35048 "GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME ({GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME:?}) \
35049 must be a valid DNS-1123 label — K8s Gateway API v1 `Listener.name` is \
35050 `SectionName`-typed and the apiserver-side CRD schema validator refuses \
35051 any other shape"
35052 );
35053 }
35054
35055 #[test]
35056 fn gateway_api_default_http_route_path_pins_canonical_root_literal() {
35057 // The canonical-constant arm — pins
35058 // [`GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH`] at the verbatim `"/"`
35059 // literal the sole `caixa-mesh::gateway_routes` per-Aplicacao
35060 // `HTTPRoute` empty-`:entrada :paths` catch-all URL-path
35061 // resolver reads from. Peer with the
35062 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_NAME`]-pins-`"http"` and
35063 // [`GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT`]-pins-`80`
35064 // disciplines on the sibling per-listener substrate-canonical
35065 // scalar-value axes: all three are the Aplicacao-side
35066 // substrate-canonical scalar-value pins the sole per-Aplicacao
35067 // Gateway API v1 CRD emitter reaches for, so a future refactor
35068 // that drifts any one constant out from under the emitter
35069 // surfaces here ahead of any per-renderer HTTPRoute emission.
35070 // The literal value is the K8s Gateway API v1 canonical
35071 // catch-all shape: `PathPrefix "/"` — the upstream docs at
35072 // <https://gateway-api.sigs.k8s.io/api-types/httproute/#path-based-routing>
35073 // pin the bare-root byte-string as the "match anything the
35074 // listener admits" idiom every gateway-class controller treats
35075 // as the equivalent of "no path predicate".
35076 assert_eq!(
35077 GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH, "/",
35078 "canonical Gateway API v1 HTTPRoute catch-all path literal must remain \
35079 `\"/\"` verbatim — this is the value the caixa-mesh HTTPRoute emitter \
35080 renders whenever the typed `:entrada :paths` list is empty and every \
35081 gateway-class controller (Cilium's Envoy, Envoy Gateway, Istio Gateway) \
35082 treats as the canonical `PathPrefix` catch-all"
35083 );
35084 }
35085
35086 #[test]
35087 fn gateway_api_default_http_route_path_carries_valid_gateway_api_http_path_shape() {
35088 // Cross-axis invariant: K8s Gateway API v1
35089 // `HTTPPathMatch.value` is admitted by the apiserver-side CRD
35090 // schema regex the substrate mirrors in the shared
35091 // [`is_gateway_api_http_path`] predicate — the same admission
35092 // grammar every author-supplied [`crate::aplicacao::Entrada`]
35093 // `:paths` entry clears at typed-validate time. Pinning the
35094 // shape here means a future rebrand on the canonical lift can't
35095 // silently land a malformed catch-all URL-path scalar (empty,
35096 // no leading `/`, overlong past the K8s Gateway API v1
35097 // `HTTPPathMatch.value` ceiling, `..`-segment-bearing, ASCII-
35098 // control-bearing, non-ASCII-bearing) that the apiserver-side
35099 // Gateway API CRD schema validator would reject far from the
35100 // rebrand commit's source. The paired
35101 // [`caixa_mesh::gateway_routes`] emitter never consults the
35102 // predicate directly (the catch-all value is a const — no
35103 // author input reaches this axis today) so consulting it here
35104 // means any future rebrand routes through the same
35105 // admission-grammar the peer author-side
35106 // `:entrada :paths` slot's `AplicacaoSpec::validate` gate
35107 // carries. Peer to
35108 // `gateway_api_default_http_listener_name_carries_dns_1123_label_shape`
35109 // on the sibling per-listener name-scalar cross-axis invariant
35110 // — every substrate-side Gateway-API-scalar lift carries the
35111 // matching per-axis admission-grammar cross-axis pin.
35112 assert!(
35113 is_gateway_api_http_path(GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH).is_ok(),
35114 "GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH ({GATEWAY_API_DEFAULT_HTTP_ROUTE_PATH:?}) \
35115 must clear the shared HTTP-path admission grammar — K8s Gateway API v1 \
35116 `HTTPPathMatch.value` is CRD-schema-regex-validated and the apiserver-side \
35117 schema validator refuses any other shape at apply time"
35118 );
35119 }
35120
35121 // ── insert_first_seen ───────────────────────────────────────────────
35122
35123 #[derive(Debug, PartialEq, Eq)]
35124 enum DupTestErr {
35125 Dup(&'static str),
35126 }
35127
35128 #[test]
35129 fn insert_first_seen_accepts_distinct_keys_without_firing_closure() {
35130 // The happy path — every distinct key returns `Ok(())` and the
35131 // caller's `on_duplicate` closure is never invoked. Pins the
35132 // `HashSet::insert`-returning-`true`-on-first-insertion contract
35133 // the ten consumer sites (`:membros`, `:placement :clusters`,
35134 // `:entrada :paths`, `:contratos`, `:children`, `:deps`,
35135 // `:deps-dev`, `:etiquetas`, `:autores`, `:caracteristicas`,
35136 // code-paths) each rely on — a future refactor that flips the
35137 // sense of the delegated `insert` return would surface here
35138 // ahead of every per-consumer duplicate arm silently mis-firing
35139 // on distinct keys.
35140 let mut seen: std::collections::HashSet<&str> = std::collections::HashSet::new();
35141 for key in ["cart", "catalog", "payment"] {
35142 assert_eq!(
35143 insert_first_seen::<&str, DupTestErr, _>(&mut seen, key, || DupTestErr::Dup(
35144 "must not fire"
35145 )),
35146 Ok(()),
35147 "first insertion of {key:?} must return Ok(())",
35148 );
35149 }
35150 assert_eq!(seen.len(), 3, "every distinct key must land in the set");
35151 }
35152
35153 #[test]
35154 fn insert_first_seen_surfaces_caller_shaped_error_on_second_insertion() {
35155 // The duplicate arm — the second occurrence of any key surfaces
35156 // the caller's `on_duplicate` return verbatim. Pins the
35157 // "declaration-order-preserving first-collision" discipline every
35158 // peer `Duplicate*` variant documents: the first colliding entry
35159 // reports, not the last. Same shape the ten consumer sites'
35160 // `*_duplicate_diagnostic_names_second_collision` posture tests
35161 // pin at the caller layer; this lift makes the sequencing a
35162 // property of the helper, not a per-call-site convention.
35163 let mut seen: std::collections::HashSet<&str> = std::collections::HashSet::new();
35164 assert_eq!(
35165 insert_first_seen::<&str, DupTestErr, _>(&mut seen, "cart", || DupTestErr::Dup(
35166 "first"
35167 )),
35168 Ok(()),
35169 "first insertion must Ok",
35170 );
35171 assert_eq!(
35172 insert_first_seen::<&str, DupTestErr, _>(&mut seen, "cart", || DupTestErr::Dup(
35173 "second"
35174 )),
35175 Err(DupTestErr::Dup("second")),
35176 "second insertion must fire the caller's closure with its own tag",
35177 );
35178 }
35179
35180 #[test]
35181 fn insert_first_seen_generic_over_tuple_key_used_by_contratos_gate() {
35182 // The [`crate::AplicacaoSpec::validate`] `:contratos` gate carries
35183 // a six-tuple typed-edge identity key
35184 // (`(de, para, wit, endpoint, subject, slot)`) — the only non-
35185 // `&str` key shape in the crate's per-list uniqueness set. Pin
35186 // the generic-over-`K` contract here so a future refactor that
35187 // narrows the helper to `&str`-only keys (a hypothetical
35188 // `HashSet<&str>`-specialized rewrite) surfaces at this pin
35189 // rather than as a compile error at the sole tuple-carrying
35190 // consumer. The tuple set here mirrors the shape
35191 // `ContratoIdentity` carries.
35192 let mut seen: std::collections::HashSet<(&str, &str, &str, Option<&str>)> =
35193 std::collections::HashSet::new();
35194 let key = ("cart", "catalog", "wasi:http/proxy", Some("/products"));
35195 assert_eq!(
35196 insert_first_seen::<_, DupTestErr, _>(&mut seen, key, || DupTestErr::Dup(
35197 "must not fire"
35198 )),
35199 Ok(()),
35200 );
35201 assert_eq!(
35202 insert_first_seen::<_, DupTestErr, _>(&mut seen, key, || DupTestErr::Dup("collision")),
35203 Err(DupTestErr::Dup("collision")),
35204 "identical tuple key on second insertion must fire the duplicate arm",
35205 );
35206 }
35207
35208 // ── assert_str_reexport_identity ──────────────────────────────────
35209
35210 #[test]
35211 fn assert_str_reexport_identity_accepts_same_static_allocation() {
35212 // Positive path — passing the same `&'static str` twice (the
35213 // shape a `pub use caixa_core::X;` re-export produces at every
35214 // consumer site) must not panic. This is the ~75-caller-site
35215 // happy path that the lifted test-side pin gate collapses onto.
35216 // The compiler-interned literal `"KUBE_KEY_SPEC"` reaches this
35217 // helper twice through the same `&'static` allocation, so
35218 // `std::ptr::eq(a.as_ptr(), b.as_ptr())` returns true and the
35219 // second `assert!` arm passes without firing.
35220 const CANONICAL: &str = "canonical-value";
35221 assert_str_reexport_identity("CANONICAL_UNDER_TEST", CANONICAL, CANONICAL);
35222 }
35223
35224 #[test]
35225 #[should_panic(
35226 expected = "SIBLING_UNDER_TEST must be a re-export of caixa_core::SIBLING_UNDER_TEST"
35227 )]
35228 fn assert_str_reexport_identity_rejects_sibling_allocation_with_same_bytes() {
35229 // Negative path — passing two byte-equal `&'static str`s whose
35230 // underlying allocations differ (the shape a sibling `pub const
35231 // X: &str = "…"` at a renderer crate produces, silently carrying
35232 // the same bytes but its own `&'static` allocation) must panic
35233 // on the [`std::ptr::eq`] arm, naming the offending re-export.
35234 // Reproduces the canonical drift footgun the lift closes: byte-
35235 // equality via [`assert_eq!`] alone silently admits the drift
35236 // — the two strings are equal — but the allocation-identity
35237 // arm catches it structurally. Uses [`String::leak`] to
35238 // materialize a fresh `&'static str` allocation carrying the
35239 // same bytes as the compiler-interned canonical literal, so
35240 // the two share bytes but differ in allocation.
35241 const CANONICAL: &str = "canonical-value";
35242 let sibling: &'static str = String::from("canonical-value").leak();
35243 // Sanity — the sibling and canonical share bytes …
35244 assert_eq!(sibling, CANONICAL);
35245 // … but must live at distinct `&'static` allocations for this
35246 // negative path to fire on the identity arm rather than
35247 // silently pass on the equality arm.
35248 assert!(!std::ptr::eq(sibling.as_ptr(), CANONICAL.as_ptr()));
35249 assert_str_reexport_identity("SIBLING_UNDER_TEST", sibling, CANONICAL);
35250 }
35251
35252 #[test]
35253 #[should_panic(expected = "DRIFTED_UNDER_TEST must byte-equal caixa_core::DRIFTED_UNDER_TEST")]
35254 fn assert_str_reexport_identity_rejects_bytes_drift_before_identity_arm() {
35255 // Ordering pin — when the two byte-strings differ, the
35256 // [`assert_eq!`] arm must fire *before* the [`std::ptr::eq`]
35257 // identity arm reaches for `.as_ptr()`. Pins the arm sequencing
35258 // so a future refactor that flipped the two arms (identity
35259 // first, byte-equality second) would surface here rather than
35260 // report the wrong diagnostic against a drifted canonical
35261 // (the byte-equality diagnostic self-locates the value drift;
35262 // the identity diagnostic self-locates the allocation drift —
35263 // reporting the identity arm on a value-drifted pair points
35264 // the reader at the wrong failure class). Same discipline as
35265 // the peer `require_positive_canonical_bounded_duration`
35266 // three-arm-ordering pin above.
35267 const CANONICAL: &str = "canonical-value";
35268 const DRIFTED: &str = "drifted-value";
35269 assert_str_reexport_identity("DRIFTED_UNDER_TEST", DRIFTED, CANONICAL);
35270 }
35271
35272 #[test]
35273 fn computeunit_spec_key_module_pins_canonical_value() {
35274 // Pin the actual byte-string so a typo in this lift can't silently
35275 // rebrand the `wasm.pleme.io/v1alpha1/ComputeUnit` CRD per-CR
35276 // `spec.module` sub-block key both caixa-flux and caixa-helm
35277 // navigate to reach the per-Servico wasm-component reference the
35278 // M2.5 wasm-engine instantiator loads at Servico bring-up. The
35279 // value is part of the cluster-side contract with the
35280 // `pleme-computeunit` library chart's per-values module-source
35281 // routing + the `caixa-operator` `ComputeUnit` CR admission
35282 // webhook's per-CR module-reference resolver; changing it is a
35283 // coordinated ComputeUnit-CRD schema migration alongside the
35284 // upstream substrate release, not an incidental edit. Peer to
35285 // `default_namespace_pins_canonical_value` /
35286 // `helm_values_yaml_filename_pins_canonical_value` /
35287 // `helm_chart_yaml_filename_pins_canonical_value` on the sibling
35288 // canonical-substrate-schema-key axes.
35289 assert_eq!(COMPUTEUNIT_SPEC_KEY_MODULE, "module");
35290 }
35291
35292 #[test]
35293 fn computeunit_spec_key_trigger_pins_canonical_value() {
35294 // Peer to `computeunit_spec_key_module_pins_canonical_value` on
35295 // the same ComputeUnit-CRD per-`spec.*` sub-block axis — pins
35296 // the per-CR invocation-shape sub-block key every
35297 // `pleme-computeunit`-library-chart-driven per-Servico
35298 // `trigger.service.port` / `trigger.service.paths` /
35299 // `trigger.service.breathability` values-block route reads back.
35300 assert_eq!(COMPUTEUNIT_SPEC_KEY_TRIGGER, "trigger");
35301 }
35302
35303 #[test]
35304 fn computeunit_spec_key_capabilities_pins_canonical_value() {
35305 // Peer to `computeunit_spec_key_module_pins_canonical_value` and
35306 // `computeunit_spec_key_trigger_pins_canonical_value` on the same
35307 // ComputeUnit-CRD per-`spec.*` sub-block axis — pins the per-CR
35308 // WASI-capability-token-list sub-block key the M2.5 wasm-engine
35309 // instantiator reads to bind the per-component capability set
35310 // (WASI-preview-2 preview-interfaces per the WIT Component Model)
35311 // at Servico bring-up.
35312 assert_eq!(COMPUTEUNIT_SPEC_KEY_CAPABILITIES, "capabilities");
35313 }
35314
35315 #[test]
35316 fn computeunit_spec_keys_carry_lowercase_shape() {
35317 // Cross-axis invariant: every `wasm.pleme.io/v1alpha1/ComputeUnit`
35318 // CRD per-`spec.*` sub-block key is all-ASCII-lowercase
35319 // throughout — the ComputeUnit CRD's schema convention on the
35320 // per-`spec.*` sub-block axis. A drifted UpperCamelCase /
35321 // hyphenated variant (`"Module"` / `"module-source"` /
35322 // `"Trigger"` / `"Capabilities"` — the OpenAPI-CRD-schema
35323 // canonical-form footgun the peer `KUBE_KEY_*` axes share) would
35324 // land the emit-side key outside the CRD's admitted per-sub-
35325 // block set and the `caixa-operator` admission webhook would
35326 // silently drop the per-Servico wasm-runtime binding — the
35327 // Servico pods would come up under the library-chart defaults
35328 // (no module bound, no trigger bound, no capability set)
35329 // instead of the caixa.lisp's declared per-`:servicos` axis.
35330 // Same all-ASCII-lowercase shape gate as the peer M2 typed-slot
35331 // camelCase-key axes ([`M2_KEY_LIMITS`] / [`M2_KEY_BEHAVIOR`] —
35332 // the compound-word slot [`M2_KEY_UPGRADE_FROM`] adds a
35333 // camelHump per its `#[serde(rename_all = "camelCase")]`-derived
35334 // shape, but the leading-word gate is the same).
35335 for k in [
35336 COMPUTEUNIT_SPEC_KEY_MODULE,
35337 COMPUTEUNIT_SPEC_KEY_TRIGGER,
35338 COMPUTEUNIT_SPEC_KEY_CAPABILITIES,
35339 ] {
35340 assert!(
35341 k.bytes().all(|b| b.is_ascii_lowercase()),
35342 "ComputeUnit CRD per-`spec.*` sub-block key {k:?} must be \
35343 all-ASCII-lowercase per the CRD schema convention"
35344 );
35345 }
35346 }
35347
35348 #[test]
35349 fn computeunit_spec_keys_appear_verbatim_in_sample_computeunit_yaml() {
35350 // Round-trip pin: the exact byte-strings the three lifted
35351 // constants carry appear verbatim as the top-level `spec.*`
35352 // sub-block keys of a canonical in-tree `ComputeUnit` YAML —
35353 // the same shape [`caixa_flux::programs_yaml_entry`] and
35354 // [`caixa_helm::build_values_yaml`] consume via
35355 // `serde_yaml::from_str`. Pins the const-to-schema round-trip
35356 // so a future ComputeUnit-CRD schema rebrand (a `binary:` /
35357 // `component:` / `invoke:` / `caps:` / `spec.wasm.*` axis
35358 // rename the ABSORPTION-ROADMAP.md M4-M5 trajectory names)
35359 // surfaces here as a build error rather than as a silent
35360 // per-Servico wasm-runtime-binding drop at cluster-apply time.
35361 let cu: serde_yaml::Value = serde_yaml::from_str(
35362 r#"
35363apiVersion: wasm.pleme.io/v1alpha1
35364kind: ComputeUnit
35365metadata:
35366 name: hello-rio
35367spec:
35368 module:
35369 source: oci://ghcr.io/pleme-io/hello-rio:v0.1.0
35370 trigger:
35371 service:
35372 port: 8080
35373 paths: ["/"]
35374 capabilities:
35375 - env
35376"#,
35377 )
35378 .unwrap();
35379 let spec = cu.get(KUBE_KEY_SPEC).expect("spec key present");
35380 assert!(
35381 spec.get(COMPUTEUNIT_SPEC_KEY_MODULE).is_some(),
35382 "spec.{COMPUTEUNIT_SPEC_KEY_MODULE} sub-block must be present"
35383 );
35384 assert!(
35385 spec.get(COMPUTEUNIT_SPEC_KEY_TRIGGER).is_some(),
35386 "spec.{COMPUTEUNIT_SPEC_KEY_TRIGGER} sub-block must be present"
35387 );
35388 assert!(
35389 spec.get(COMPUTEUNIT_SPEC_KEY_CAPABILITIES).is_some(),
35390 "spec.{COMPUTEUNIT_SPEC_KEY_CAPABILITIES} sub-block must be present"
35391 );
35392 // Nested `spec.module.source` leaf-scalar sub-block: every
35393 // rendered ComputeUnit YAML declares the wasm-component
35394 // reference under this leaf, and every downstream
35395 // `programs[].module.source` readback the
35396 // [`caixa_flux::programs_yaml_entry`] round-trip pins reaches
35397 // for the same `&'static str`. Peer to the top-level
35398 // `spec.{module,trigger,capabilities}` presence assertions
35399 // above — extends the round-trip pin one level deeper onto
35400 // the module-block's leaf reference-value axis.
35401 let module = spec
35402 .get(COMPUTEUNIT_SPEC_KEY_MODULE)
35403 .expect("spec.module block present");
35404 assert!(
35405 module.get(COMPUTEUNIT_MODULE_KEY_SOURCE).is_some(),
35406 "spec.{COMPUTEUNIT_SPEC_KEY_MODULE}.{COMPUTEUNIT_MODULE_KEY_SOURCE} \
35407 leaf-scalar sub-block must be present"
35408 );
35409 assert_eq!(
35410 module
35411 .get(COMPUTEUNIT_MODULE_KEY_SOURCE)
35412 .and_then(|s| s.as_str()),
35413 Some("oci://ghcr.io/pleme-io/hello-rio:v0.1.0"),
35414 "the ComputeUnit CRD per-`module.source` axis carries the wasm-\
35415 component OCI/git reference verbatim"
35416 );
35417 }
35418
35419 #[test]
35420 fn computeunit_module_key_source_pins_canonical_value() {
35421 // Peer to `computeunit_spec_key_module_pins_canonical_value` on
35422 // the nested `spec.module.*` sub-block axis — pins the per-CR
35423 // wasm-component-reference leaf-scalar key every
35424 // [`caixa_flux::programs_yaml_entry`] round-trip navigator and
35425 // every [`caixa_flux::upsert_into_programs_yaml`] /
35426 // [`caixa_flux::upsert_into_helmrelease_programs`] cross-
35427 // upsert readback resolves under the parent
35428 // `COMPUTEUNIT_SPEC_KEY_MODULE`. Changing this value is a
35429 // coordinated ComputeUnit-CRD schema migration alongside the
35430 // `pleme-computeunit` library chart's per-values module-source
35431 // routing + the `caixa-operator` `ComputeUnit` CR admission
35432 // webhook's per-CR module-reference resolver, not an
35433 // incidental edit.
35434 assert_eq!(COMPUTEUNIT_MODULE_KEY_SOURCE, "source");
35435 }
35436
35437 #[test]
35438 fn computeunit_module_key_source_carries_lowercase_shape() {
35439 // Cross-axis invariant: the nested `spec.module.*` leaf-scalar
35440 // sub-block key is all-ASCII-lowercase throughout — the
35441 // ComputeUnit CRD's schema convention on the per-`spec.module.*`
35442 // leaf axis, same as the top-level per-`spec.*` sub-block
35443 // axis the sibling `COMPUTEUNIT_SPEC_KEY_*` peers gate.
35444 // A drifted UpperCamelCase / hyphenated variant (`"Source"` /
35445 // `"module-source"` / `"src"` — the OpenAPI-CRD-schema
35446 // canonical-form footgun the peer `KUBE_KEY_*` axes share)
35447 // would land the emit-side key outside the CRD's admitted
35448 // per-`module.*` set and the `caixa-operator` admission
35449 // webhook would silently drop the per-Servico wasm-module
35450 // reference — the Servico pods would come up under the
35451 // library-chart defaults (no module bound) instead of the
35452 // caixa.lisp's declared per-`:servicos` axis. Same all-ASCII-
35453 // lowercase shape gate as the peer `COMPUTEUNIT_SPEC_KEY_*`
35454 // top-level axes.
35455 assert!(
35456 COMPUTEUNIT_MODULE_KEY_SOURCE
35457 .bytes()
35458 .all(|b| b.is_ascii_lowercase()),
35459 "ComputeUnit CRD per-`spec.module.*` leaf-scalar sub-block key \
35460 {COMPUTEUNIT_MODULE_KEY_SOURCE:?} must be all-ASCII-lowercase \
35461 per the CRD schema convention"
35462 );
35463 }
35464
35465 #[test]
35466 fn mapping_ext_insert_str_key_promotes_key_to_yaml_string() {
35467 // The trait method promotes an arbitrary `&str` key to
35468 // `Value::String(key.to_string())` — pin the promotion so a
35469 // future refactor that reaches for a different `Value` variant
35470 // for the key (e.g. `Value::Tagged`) is a compile-visible break,
35471 // not a silent per-consumer regression at the K8s-artifact-emit
35472 // surface.
35473 let mut m = serde_yaml::Mapping::new();
35474 let prior = m.insert_str_key("spec", serde_yaml::Value::Bool(true));
35475 assert!(
35476 prior.is_none(),
35477 "insert_str_key returns None on first insertion, mirroring \
35478 serde_yaml::Mapping::insert"
35479 );
35480 // Key is exactly the `Value::String` promotion of the input.
35481 let got = m
35482 .get(serde_yaml::Value::String("spec".to_string()))
35483 .expect("inserted key is present under Value::String promotion");
35484 assert_eq!(
35485 got,
35486 &serde_yaml::Value::Bool(true),
35487 "insert_str_key routes value verbatim to the underlying \
35488 serde_yaml::Mapping::insert"
35489 );
35490 }
35491
35492 #[test]
35493 fn mapping_ext_insert_str_key_returns_prior_value_on_replace() {
35494 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35495 // return contract: the prior value at that key, or `None` if
35496 // absent. Pin the replace-returns-prior semantic so a future
35497 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35498 // silently drop the prior-value handoff downstream consumers may
35499 // reach for (the M4 per-`:politicas` overlay merger, the future
35500 // `feira app deploy` idempotent-write dry-run comparator).
35501 let mut m = serde_yaml::Mapping::new();
35502 m.insert_str_key("kind", serde_yaml::Value::String("Gateway".into()));
35503 let prior = m.insert_str_key("kind", serde_yaml::Value::String("HTTPRoute".into()));
35504 assert_eq!(
35505 prior,
35506 Some(serde_yaml::Value::String("Gateway".into())),
35507 "insert_str_key returns the prior value when replacing an existing key"
35508 );
35509 let got = m
35510 .get(serde_yaml::Value::String("kind".to_string()))
35511 .expect("key is still present after replace");
35512 assert_eq!(
35513 got,
35514 &serde_yaml::Value::String("HTTPRoute".into()),
35515 "replaced value is now the most-recently-inserted one"
35516 );
35517 }
35518
35519 #[test]
35520 fn mapping_ext_insert_str_key_matches_hand_written_promotion() {
35521 // Cross-check the trait method against the hand-written
35522 // `mapping.insert(Value::String(key.into()), value)` shape the
35523 // ~48 lifted call sites previously carried. A drift between the
35524 // trait method's promotion and the inline promotion the prior
35525 // call sites used would silently emit a different YAML mapping
35526 // (a differently-quoted key, a different `Value` variant) at
35527 // every routed consumer — pin the equivalence so the trait
35528 // remains a drop-in replacement.
35529 let mut via_trait = serde_yaml::Mapping::new();
35530 via_trait.insert_str_key(KUBE_KEY_KIND, serde_yaml::Value::String("Gateway".into()));
35531
35532 let mut via_inline = serde_yaml::Mapping::new();
35533 via_inline.insert(
35534 serde_yaml::Value::String(KUBE_KEY_KIND.into()),
35535 serde_yaml::Value::String("Gateway".into()),
35536 );
35537
35538 assert_eq!(
35539 via_trait, via_inline,
35540 "insert_str_key(KEY, V) must byte-equal \
35541 insert(Value::String(KEY.into()), V) — otherwise the \
35542 ~48 routed consumer sites drift silently at emit time"
35543 );
35544 }
35545
35546 #[test]
35547 fn mapping_get_bare_str_key_byte_equals_value_string_wrapped_form() {
35548 // The read-side twin of the `insert_str_key`-vs-hand-written pin.
35549 // `serde_yaml::Mapping::get<I: Index>` accepts any `I: Index`;
35550 // the crate ships `impl Index for str` (routing through a
35551 // no-allocation `HashLikeValue(&str)` bucket lookup) and
35552 // `impl Index for Value` (matching the `Value::String(_)`
35553 // key verbatim). The ~78 test-side probes across `caixa-mesh`,
35554 // `caixa-flux`, and `caixa-core::render` that previously spelled
35555 // out `.get(serde_yaml::Value::String(<KEY>.into()))` were
35556 // swept onto the shorter `.get(<KEY>)` form because the two
35557 // must resolve to the same bucket for the sweep to be a
35558 // drop-in. Pin the equivalence — the `HashLikeValue(&str)`
35559 // hash must byte-equal the `Value::String(String)` hash so
35560 // the two paths agree on `get`, `contains_key`, and the
35561 // absence path (`None` when the key is missing) — otherwise
35562 // a future `serde_yaml` upgrade could silently divert every
35563 // swept probe past the value the emitter inserted.
35564 let mut m = serde_yaml::Mapping::new();
35565 m.insert_str_key(KUBE_KEY_KIND, serde_yaml::Value::String("Gateway".into()));
35566 // Present-key path: both forms find the same value.
35567 assert_eq!(
35568 m.get(KUBE_KEY_KIND),
35569 m.get(serde_yaml::Value::String(KUBE_KEY_KIND.into())),
35570 "mapping.get(<KEY>) must byte-equal \
35571 mapping.get(Value::String(<KEY>.into())) — otherwise the \
35572 ~78 swept test-side probes drift silently past the value \
35573 the emitter inserted under the promoted Value::String key"
35574 );
35575 // Absent-key path: both forms return None.
35576 assert_eq!(
35577 m.get(KUBE_KEY_SPEC),
35578 m.get(serde_yaml::Value::String(KUBE_KEY_SPEC.into())),
35579 "absent-key lookup via bare-&str must byte-equal absent-key \
35580 lookup via Value::String — both must return None so the \
35581 swept `assert!(_.get(K).is_none())` shape stays load-bearing"
35582 );
35583 // contains_key parity: both forms agree on present + absent.
35584 assert_eq!(
35585 m.contains_key(KUBE_KEY_KIND),
35586 m.contains_key(serde_yaml::Value::String(KUBE_KEY_KIND.into())),
35587 "mapping.contains_key(<KEY>) must byte-equal \
35588 mapping.contains_key(Value::String(<KEY>.into())) — \
35589 otherwise the swept `assert!(_.contains_key(K))` shape \
35590 disagrees with the emitter's `insert_str_key` promotion"
35591 );
35592 assert_eq!(
35593 m.contains_key(KUBE_KEY_SPEC),
35594 m.contains_key(serde_yaml::Value::String(KUBE_KEY_SPEC.into())),
35595 "absent-key contains_key via bare-&str must byte-equal \
35596 absent-key contains_key via Value::String"
35597 );
35598 }
35599
35600 #[test]
35601 fn mapping_get_mut_bare_str_key_byte_equals_value_string_wrapped_form() {
35602 // The mutation-path twin of the read-side pin above.
35603 // `serde_yaml::Mapping::get_mut<I: Index>` accepts any
35604 // `I: Index` — the crate ships `impl Index for str` (routing
35605 // through the same no-allocation `HashLikeValue(&str)` bucket
35606 // lookup the read-side `get` / `contains_key` sweep landed on
35607 // in 0e84fb9) and `impl Index for Value` (matching the
35608 // `Value::String(_)` key verbatim). Until this pin landed the
35609 // sole production `.get_mut(serde_yaml::Value::String(<KEY>.into()))`
35610 // probe — [`caixa_flux::upsert_into_helmrelease_programs`]'s
35611 // `root.get_mut(…)` HelmRelease-side spec-mutate at
35612 // `caixa-flux/src/lib.rs:845` (which the sibling
35613 // `kube_key_spec_re_export_points_at_caixa_core_canonical`
35614 // pinning test's docstring already described in the shorter
35615 // `root.get_mut("spec")` form the 0e84fb9 read-side sweep
35616 // landed elsewhere on) — carried the verbose `Value::String`-
35617 // wrapped shape as the last stray hold-out on the `get_mut`
35618 // axis. The sweep swaps it onto the bare-`&str` form, matching
35619 // the ~78 read-side probes 0e84fb9 already swept and the
35620 // in-file `kube_key_spec_re_export_points_at_caixa_core_canonical`
35621 // docstring's canonical description. Pin the equivalence — the
35622 // `HashLikeValue(&str)` hash must byte-equal the
35623 // `Value::String(String)` hash so the two paths agree on both
35624 // the present-key path (returns `Some(&mut _)` at the same
35625 // slot) and the absent-key path (returns `None` when the key
35626 // is missing) — otherwise a future `serde_yaml` upgrade could
35627 // silently divert the writer-side upsert past the value the
35628 // emitter previously mutated. Peer to the read-side
35629 // [`mapping_get_bare_str_key_byte_equals_value_string_wrapped_form`]
35630 // pin on the sibling `get` / `contains_key` axes; together the
35631 // two pins pin every `Index`-polymorphic probe axis the
35632 // caixa-flux upsert path walks.
35633 let mut m = serde_yaml::Mapping::new();
35634 m.insert_str_key(KUBE_KEY_KIND, serde_yaml::Value::String("Gateway".into()));
35635 // Present-key path: both forms find the same slot.
35636 // Cross-check by mutating through the bare-&str path and
35637 // observing the mutation via the Value::String path (and vice
35638 // versa) — anything short of exact bucket-equality would
35639 // silently split the two probes onto different slots.
35640 {
35641 let via_bare = m
35642 .get_mut(KUBE_KEY_KIND)
35643 .expect("present key must resolve via bare-&str");
35644 *via_bare = serde_yaml::Value::String("HTTPRoute".into());
35645 }
35646 assert_eq!(
35647 m.get(serde_yaml::Value::String(KUBE_KEY_KIND.into())),
35648 Some(&serde_yaml::Value::String("HTTPRoute".into())),
35649 "mutation via mapping.get_mut(<KEY>) must be visible via \
35650 mapping.get(Value::String(<KEY>.into())) — otherwise the \
35651 swept `get_mut` writer-side probe drifts past the value \
35652 the emitter reads through the promoted Value::String key"
35653 );
35654 {
35655 let via_wrapped = m
35656 .get_mut(serde_yaml::Value::String(KUBE_KEY_KIND.into()))
35657 .expect("present key must also resolve via Value::String");
35658 *via_wrapped = serde_yaml::Value::String("Gateway".into());
35659 }
35660 assert_eq!(
35661 m.get(KUBE_KEY_KIND),
35662 Some(&serde_yaml::Value::String("Gateway".into())),
35663 "mutation via mapping.get_mut(Value::String(<KEY>.into())) \
35664 must be visible via mapping.get(<KEY>) — the two paths \
35665 address the same bucket in both directions"
35666 );
35667 // Absent-key path: both forms return None so the sole swept
35668 // `.get_mut(<KEY>).ok_or(Error::MissingField(<KEY>))` shape
35669 // stays load-bearing.
35670 assert!(
35671 m.get_mut(KUBE_KEY_SPEC).is_none(),
35672 "absent-key mapping.get_mut(<KEY>) must return None"
35673 );
35674 assert!(
35675 m.get_mut(serde_yaml::Value::String(KUBE_KEY_SPEC.into()))
35676 .is_none(),
35677 "absent-key mapping.get_mut(Value::String(<KEY>.into())) \
35678 must also return None — the two forms must agree on \
35679 absence so the swept `.ok_or(Error::MissingField(<KEY>))` \
35680 diagnostic still fires on a missing spec block"
35681 );
35682 }
35683
35684 #[test]
35685 fn mapping_ext_insert_string_promotes_value_to_yaml_string() {
35686 // The trait method promotes an arbitrary `Into<String>` value
35687 // to `Value::String(value.into())` — pin the promotion so a
35688 // future refactor that reaches for a different `Value` variant
35689 // for the string-scalar payload (e.g. `Value::Tagged` under a
35690 // K8s Server-Side-Apply typed-field-ownership axis rebrand) is
35691 // a compile-visible break, not a silent per-consumer regression
35692 // at the K8s-artifact-emit surface. Peer with
35693 // [`mapping_ext_insert_str_key_promotes_key_to_yaml_string`] on
35694 // the sibling `insert_str_key` primitive's key-promotion pin.
35695 let mut m = serde_yaml::Mapping::new();
35696 let prior = m.insert_string("kind", "Gateway");
35697 assert!(
35698 prior.is_none(),
35699 "insert_string returns None on first insertion, mirroring \
35700 serde_yaml::Mapping::insert"
35701 );
35702 let got = m
35703 .get("kind")
35704 .expect("inserted key is present under Value::String promotion");
35705 assert_eq!(
35706 got,
35707 &serde_yaml::Value::String("Gateway".into()),
35708 "insert_string routes value verbatim through Value::String \
35709 promotion"
35710 );
35711 }
35712
35713 #[test]
35714 fn mapping_ext_insert_string_returns_prior_value_on_replace() {
35715 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35716 // return contract: the prior value at that key, or `None` if
35717 // absent. Pin the replace-returns-prior semantic so a future
35718 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35719 // silently drop the prior-value handoff downstream consumers
35720 // may reach for. Peer with
35721 // [`mapping_ext_insert_str_key_returns_prior_value_on_replace`]
35722 // on the sibling `insert_str_key` primitive's replace-semantics
35723 // pin.
35724 let mut m = serde_yaml::Mapping::new();
35725 m.insert_string(KUBE_KEY_KIND, "Gateway");
35726 let prior = m.insert_string(KUBE_KEY_KIND, "HTTPRoute");
35727 assert_eq!(
35728 prior,
35729 Some(serde_yaml::Value::String("Gateway".into())),
35730 "insert_string returns the prior value when replacing an \
35731 existing key"
35732 );
35733 let got = m
35734 .get(KUBE_KEY_KIND)
35735 .expect("key is still present after replace");
35736 assert_eq!(
35737 got,
35738 &serde_yaml::Value::String("HTTPRoute".into()),
35739 "replaced value is now the most-recently-inserted one"
35740 );
35741 }
35742
35743 #[test]
35744 fn mapping_ext_insert_string_matches_hand_written_promotion() {
35745 // Cross-check the trait method against the hand-written
35746 // `mapping.insert_str_key(KEY, Value::String(V.into()))` shape
35747 // the ~17 lifted call sites previously carried. A drift between
35748 // the trait method's promotion and the inline promotion would
35749 // silently emit a different YAML mapping (a differently-quoted
35750 // scalar, a different `Value` variant) at every routed
35751 // consumer — pin the equivalence so the trait remains a drop-in
35752 // replacement. Also cross-checks that all three input shapes
35753 // (`&'static str` → `.into()`, `String` → `.clone()` /
35754 // `.to_string()`, integer → `.to_string()`) converge on the same
35755 // `Value::String` promotion, since the ~17 call sites cover all
35756 // three input flavors.
35757 let mut via_trait = serde_yaml::Mapping::new();
35758 via_trait.insert_string(KUBE_KEY_KIND, "Gateway");
35759 via_trait.insert_string(KUBE_KEY_NAME, String::from("hello"));
35760 via_trait.insert_string(KUBE_KEY_PORT, 8080u16.to_string());
35761
35762 let mut via_inline = serde_yaml::Mapping::new();
35763 via_inline.insert_str_key(KUBE_KEY_KIND, serde_yaml::Value::String("Gateway".into()));
35764 via_inline.insert_str_key(
35765 KUBE_KEY_NAME,
35766 serde_yaml::Value::String(String::from("hello")),
35767 );
35768 via_inline.insert_str_key(
35769 KUBE_KEY_PORT,
35770 serde_yaml::Value::String(8080u16.to_string()),
35771 );
35772
35773 assert_eq!(
35774 via_trait, via_inline,
35775 "insert_string(KEY, V) must byte-equal \
35776 insert_str_key(KEY, Value::String(V.into())) — otherwise \
35777 the ~17 routed consumer sites drift silently at emit time"
35778 );
35779 }
35780
35781 #[test]
35782 fn mapping_ext_insert_number_promotes_value_to_yaml_number() {
35783 // The trait method promotes an arbitrary `Into<serde_yaml::Number>`
35784 // value to `Value::Number(value.into())` — pin the promotion so a
35785 // future refactor that reaches for a different `Value` variant
35786 // for the integer-scalar payload (e.g. `Value::Tagged` under a
35787 // K8s Server-Side-Apply typed-field-ownership axis rebrand, or
35788 // the deprecated `Value::String(n.to_string())` "stringy port"
35789 // rendering some pre-Gateway-API-v1 CRDs still shipped with) is
35790 // a compile-visible break, not a silent per-consumer regression
35791 // at the K8s-artifact-emit surface. Peer with
35792 // [`mapping_ext_insert_string_promotes_value_to_yaml_string`] on
35793 // the sibling `insert_string` primitive's string-scalar
35794 // promotion pin.
35795 let mut m = serde_yaml::Mapping::new();
35796 let prior = m.insert_number(KUBE_KEY_PORT, GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT);
35797 assert!(
35798 prior.is_none(),
35799 "insert_number returns None on first insertion, mirroring \
35800 serde_yaml::Mapping::insert"
35801 );
35802 let got = m
35803 .get(KUBE_KEY_PORT)
35804 .expect("inserted key is present under Value::Number promotion");
35805 assert_eq!(
35806 got.as_u64(),
35807 Some(u64::from(GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT)),
35808 "insert_number routes value verbatim through Value::Number \
35809 promotion — the u16 payload survives round-trip as a Number \
35810 the as_u64 accessor decodes verbatim"
35811 );
35812 assert!(
35813 matches!(got, serde_yaml::Value::Number(_)),
35814 "the promoted value is Value::Number, not Value::String — a \
35815 stringy-port drift would emit `port: \"80\"` (rejected by \
35816 Gateway API v1 apiserver as a type mismatch)"
35817 );
35818 }
35819
35820 #[test]
35821 fn mapping_ext_insert_number_returns_prior_value_on_replace() {
35822 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35823 // return contract: the prior value at that key, or `None` if
35824 // absent. Pin the replace-returns-prior semantic so a future
35825 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35826 // silently drop the prior-value handoff downstream consumers
35827 // may reach for. Peer with
35828 // [`mapping_ext_insert_string_returns_prior_value_on_replace`] on
35829 // the sibling `insert_string` primitive's replace-semantics pin.
35830 let mut m = serde_yaml::Mapping::new();
35831 m.insert_number(KUBE_KEY_PORT, 80u16);
35832 let prior = m.insert_number(KUBE_KEY_PORT, 443u16);
35833 assert_eq!(
35834 prior.as_ref().and_then(serde_yaml::Value::as_u64),
35835 Some(80),
35836 "insert_number returns the prior value when replacing an \
35837 existing key — the u16 payload round-trips verbatim through \
35838 the returned Value::Number handoff"
35839 );
35840 let got = m
35841 .get(KUBE_KEY_PORT)
35842 .expect("key is still present after replace");
35843 assert_eq!(
35844 got.as_u64(),
35845 Some(443),
35846 "replaced value is now the most-recently-inserted one"
35847 );
35848 }
35849
35850 #[test]
35851 fn mapping_ext_insert_number_matches_hand_written_promotion() {
35852 // Cross-check the trait method against the hand-written
35853 // `mapping.insert_str_key(KEY, Value::Number(N.into()))` shape
35854 // the two lifted caixa-mesh call sites previously carried. A
35855 // drift between the trait method's promotion and the inline
35856 // promotion would silently emit a different YAML mapping (a
35857 // differently-typed scalar, a different `Value` variant) at
35858 // every routed consumer — pin the equivalence so the trait
35859 // remains a drop-in replacement. Two arms pin the axis end-to-
35860 // end: a `u16` typed-const arm (the lifted
35861 // `GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT` external HTTP
35862 // listener-port, cd60fde) and a `u16` typed-field arm (the
35863 // per-`entrada.port` backend-target Servico port routed through
35864 // the `AplicacaoSpec` `:entrada :port` slot).
35865 let mut via_trait = serde_yaml::Mapping::new();
35866 via_trait.insert_number(KUBE_KEY_PORT, GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT);
35867 via_trait.insert_number(GATEWAY_API_KEY_VALUE, 8443u16);
35868
35869 let mut via_inline = serde_yaml::Mapping::new();
35870 via_inline.insert_str_key(
35871 KUBE_KEY_PORT,
35872 serde_yaml::Value::Number(GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT.into()),
35873 );
35874 via_inline.insert_str_key(
35875 GATEWAY_API_KEY_VALUE,
35876 serde_yaml::Value::Number(8443u16.into()),
35877 );
35878
35879 assert_eq!(
35880 via_trait, via_inline,
35881 "insert_number(KEY, N) must byte-equal \
35882 insert_str_key(KEY, Value::Number(N.into())) — otherwise \
35883 the two routed caixa-mesh consumer sites drift silently at \
35884 emit time"
35885 );
35886 }
35887
35888 #[test]
35889 fn mapping_ext_insert_mapping_promotes_value_to_yaml_mapping() {
35890 // The trait method promotes an arbitrary `serde_yaml::Mapping`
35891 // value to `Value::Mapping(value)` — pin the promotion so a
35892 // future refactor that reaches for a different `Value` variant
35893 // for the nested-Mapping payload (e.g. `Value::Tagged` under a
35894 // K8s Server-Side-Apply typed-field-ownership axis rebrand) is
35895 // a compile-visible break, not a silent per-consumer regression
35896 // at the K8s-artifact-emit surface. Peer with
35897 // [`mapping_ext_insert_string_promotes_value_to_yaml_string`] on
35898 // the sibling `insert_string` primitive's scalar-promotion pin
35899 // and with
35900 // [`mapping_ext_insert_str_key_promotes_key_to_yaml_string`] on
35901 // the base `insert_str_key` primitive's key-promotion pin.
35902 let mut inner = serde_yaml::Mapping::new();
35903 inner.insert_string(KUBE_KEY_NAME, "hello-rio");
35904 let mut m = serde_yaml::Mapping::new();
35905 let prior = m.insert_mapping(KUBE_KEY_METADATA, inner.clone());
35906 assert!(
35907 prior.is_none(),
35908 "insert_mapping returns None on first insertion, mirroring \
35909 serde_yaml::Mapping::insert"
35910 );
35911 let got = m
35912 .get(KUBE_KEY_METADATA)
35913 .expect("inserted key is present under Value::Mapping promotion");
35914 assert_eq!(
35915 got,
35916 &serde_yaml::Value::Mapping(inner),
35917 "insert_mapping routes value verbatim through Value::Mapping \
35918 promotion"
35919 );
35920 }
35921
35922 #[test]
35923 fn mapping_ext_insert_mapping_returns_prior_value_on_replace() {
35924 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
35925 // return contract: the prior value at that key, or `None` if
35926 // absent. Pin the replace-returns-prior semantic so a future
35927 // refactor that swaps to a `HashMap::entry`-style flow doesn't
35928 // silently drop the prior-value handoff downstream consumers
35929 // may reach for. Peer with
35930 // [`mapping_ext_insert_string_returns_prior_value_on_replace`]
35931 // and
35932 // [`mapping_ext_insert_str_key_returns_prior_value_on_replace`]
35933 // on the sibling primitive-pair members' replace-semantics
35934 // pins.
35935 let mut first_inner = serde_yaml::Mapping::new();
35936 first_inner.insert_string(KUBE_KEY_NAME, "first");
35937 let mut second_inner = serde_yaml::Mapping::new();
35938 second_inner.insert_string(KUBE_KEY_NAME, "second");
35939 let mut m = serde_yaml::Mapping::new();
35940 m.insert_mapping(KUBE_KEY_METADATA, first_inner.clone());
35941 let prior = m.insert_mapping(KUBE_KEY_METADATA, second_inner.clone());
35942 assert_eq!(
35943 prior,
35944 Some(serde_yaml::Value::Mapping(first_inner)),
35945 "insert_mapping returns the prior value when replacing an \
35946 existing key"
35947 );
35948 let got = m
35949 .get(KUBE_KEY_METADATA)
35950 .expect("key is still present after replace");
35951 assert_eq!(
35952 got,
35953 &serde_yaml::Value::Mapping(second_inner),
35954 "replaced value is now the most-recently-inserted one"
35955 );
35956 }
35957
35958 #[test]
35959 fn mapping_ext_insert_mapping_matches_hand_written_promotion() {
35960 // Cross-check the trait method against the hand-written
35961 // `mapping.insert_str_key(KEY, Value::Mapping(inner))` shape the
35962 // 6 lifted call sites previously carried. A drift between the
35963 // trait method's promotion and the inline promotion would
35964 // silently emit a different YAML mapping (a differently-wrapped
35965 // outer variant, a differently-shaped inner Mapping) at every
35966 // routed consumer — pin the equivalence so the trait remains a
35967 // drop-in replacement. Two cases pin the shape end-to-end:
35968 // an empty inner Mapping (no silent is_empty short-circuit) and
35969 // a populated inner Mapping (the `metadata` / `spec` /
35970 // `spec.rules[].path` sub-block shape).
35971 let mut inner_empty = serde_yaml::Mapping::new();
35972 let _ = &mut inner_empty; // keep as mut for parity with populated arm below
35973 let mut inner_populated = serde_yaml::Mapping::new();
35974 inner_populated.insert_string(KUBE_KEY_NAME, "hello-rio");
35975 inner_populated.insert_string(KUBE_KEY_NAMESPACE, DEFAULT_NAMESPACE);
35976
35977 let mut via_trait = serde_yaml::Mapping::new();
35978 via_trait.insert_mapping(KUBE_KEY_SPEC, inner_empty.clone());
35979 via_trait.insert_mapping(KUBE_KEY_METADATA, inner_populated.clone());
35980
35981 let mut via_inline = serde_yaml::Mapping::new();
35982 via_inline.insert_str_key(KUBE_KEY_SPEC, serde_yaml::Value::Mapping(inner_empty));
35983 via_inline.insert_str_key(
35984 KUBE_KEY_METADATA,
35985 serde_yaml::Value::Mapping(inner_populated),
35986 );
35987
35988 assert_eq!(
35989 via_trait, via_inline,
35990 "insert_mapping(KEY, inner) must byte-equal \
35991 insert_str_key(KEY, Value::Mapping(inner)) — otherwise the \
35992 six routed consumer sites drift silently at emit time"
35993 );
35994 }
35995
35996 #[test]
35997 fn mapping_ext_insert_sequence_promotes_value_to_yaml_sequence() {
35998 // The trait method promotes an arbitrary `Vec<Value>` value to
35999 // `Value::Sequence(value)` — pin the promotion so a future
36000 // refactor that reaches for a different `Value` variant for the
36001 // list-shape payload (e.g. `Value::Tagged` under a K8s Server-
36002 // Side-Apply typed-field-ownership axis rebrand, a serde_yaml
36003 // successor's `Value::Array` / `Value::List` variant rename) is
36004 // a compile-visible break, not a silent per-consumer regression
36005 // at the K8s-artifact-emit surface. Peer with
36006 // [`mapping_ext_insert_mapping_promotes_value_to_yaml_mapping`]
36007 // on the sibling `insert_mapping` primitive's nested-Mapping-
36008 // promotion pin, and with
36009 // [`mapping_ext_insert_string_promotes_value_to_yaml_string`]
36010 // on the sibling `insert_string` primitive's scalar-promotion
36011 // pin.
36012 let inner = vec![
36013 serde_yaml::Value::String("hello".into()),
36014 serde_yaml::Value::String("world".into()),
36015 ];
36016 let mut m = serde_yaml::Mapping::new();
36017 let prior = m.insert_sequence(GATEWAY_API_KEY_HOSTNAMES, inner.clone());
36018 assert!(
36019 prior.is_none(),
36020 "insert_sequence returns None on first insertion, mirroring \
36021 serde_yaml::Mapping::insert"
36022 );
36023 let got = m
36024 .get(GATEWAY_API_KEY_HOSTNAMES)
36025 .expect("inserted key is present under Value::Sequence promotion");
36026 assert_eq!(
36027 got,
36028 &serde_yaml::Value::Sequence(inner),
36029 "insert_sequence routes value verbatim through Value::Sequence \
36030 promotion"
36031 );
36032 }
36033
36034 #[test]
36035 fn mapping_ext_insert_sequence_returns_prior_value_on_replace() {
36036 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
36037 // return contract: the prior value at that key, or `None` if
36038 // absent. Pin the replace-returns-prior semantic so a future
36039 // refactor that swaps to a `HashMap::entry`-style flow doesn't
36040 // silently drop the prior-value handoff downstream consumers
36041 // may reach for. Peer with
36042 // [`mapping_ext_insert_mapping_returns_prior_value_on_replace`],
36043 // [`mapping_ext_insert_string_returns_prior_value_on_replace`],
36044 // and
36045 // [`mapping_ext_insert_str_key_returns_prior_value_on_replace`]
36046 // on the sibling primitive-quadruple members' replace-semantics
36047 // pins.
36048 let first: Vec<serde_yaml::Value> = vec![serde_yaml::Value::String("a".into())];
36049 let second: Vec<serde_yaml::Value> = vec![
36050 serde_yaml::Value::String("b".into()),
36051 serde_yaml::Value::String("c".into()),
36052 ];
36053 let mut m = serde_yaml::Mapping::new();
36054 m.insert_sequence(KUBE_KEY_RULES, first.clone());
36055 let prior = m.insert_sequence(KUBE_KEY_RULES, second.clone());
36056 assert_eq!(
36057 prior,
36058 Some(serde_yaml::Value::Sequence(first)),
36059 "insert_sequence returns the prior value when replacing an \
36060 existing key"
36061 );
36062 let got = m
36063 .get(KUBE_KEY_RULES)
36064 .expect("key is still present after replace");
36065 assert_eq!(
36066 got,
36067 &serde_yaml::Value::Sequence(second),
36068 "replaced value is now the most-recently-inserted one"
36069 );
36070 }
36071
36072 #[test]
36073 fn mapping_ext_insert_sequence_matches_hand_written_promotion() {
36074 // Cross-check the trait method against the hand-written
36075 // `mapping.insert_str_key(KEY, Value::Sequence(v))` shape the 4
36076 // lifted call sites previously carried. A drift between the
36077 // trait method's promotion and the inline promotion would
36078 // silently emit a different YAML mapping (a differently-wrapped
36079 // outer variant, a differently-shaped inner sequence) at every
36080 // routed consumer — pin the equivalence so the trait remains a
36081 // drop-in replacement. Three cases pin the shape end-to-end:
36082 // an empty inner Vec (no silent is_empty short-circuit), a
36083 // singleton-Value inner Vec (the `fromEndpoints[<selector>]` /
36084 // `hostnames[<host>]` singleton shape), and a multi-Value inner
36085 // Vec (the `toPorts[…]` / `rules[…]` multi-entry shape).
36086 let inner_empty: Vec<serde_yaml::Value> = Vec::new();
36087 let inner_singleton: Vec<serde_yaml::Value> =
36088 vec![serde_yaml::Value::String("example.com".into())];
36089 let mut host_entry = serde_yaml::Mapping::new();
36090 host_entry.insert_string(KUBE_KEY_NAME, "svc-a");
36091 let mut port_entry = serde_yaml::Mapping::new();
36092 port_entry.insert_string(KUBE_KEY_NAME, "svc-b");
36093 let inner_multi: Vec<serde_yaml::Value> = vec![
36094 serde_yaml::Value::Mapping(host_entry.clone()),
36095 serde_yaml::Value::Mapping(port_entry.clone()),
36096 ];
36097
36098 let mut via_trait = serde_yaml::Mapping::new();
36099 via_trait.insert_sequence(CILIUM_KEY_TO_PORTS, inner_empty.clone());
36100 via_trait.insert_sequence(GATEWAY_API_KEY_HOSTNAMES, inner_singleton.clone());
36101 via_trait.insert_sequence(KUBE_KEY_RULES, inner_multi.clone());
36102
36103 let mut via_inline = serde_yaml::Mapping::new();
36104 via_inline.insert_str_key(
36105 CILIUM_KEY_TO_PORTS,
36106 serde_yaml::Value::Sequence(inner_empty),
36107 );
36108 via_inline.insert_str_key(
36109 GATEWAY_API_KEY_HOSTNAMES,
36110 serde_yaml::Value::Sequence(inner_singleton),
36111 );
36112 via_inline.insert_str_key(KUBE_KEY_RULES, serde_yaml::Value::Sequence(inner_multi));
36113
36114 assert_eq!(
36115 via_trait, via_inline,
36116 "insert_sequence(KEY, v) must byte-equal \
36117 insert_str_key(KEY, Value::Sequence(v)) — otherwise the \
36118 four routed consumer sites drift silently at emit time"
36119 );
36120 }
36121
36122 // ── insert_singleton_mapping_sequence — composed primitive ───────────
36123 //
36124 // The trait method composes [`Self::insert_str_key`] with
36125 // [`singleton_mapping_sequence`]: every hand-inline
36126 // `mapping.insert_str_key(K, singleton_mapping_sequence(m))` two-symbol
36127 // composition previously carried at 7 sites across caixa-mesh
36128 // collapses onto one method call. Three peer pins pin the trait
36129 // method's shape end-to-end.
36130
36131 #[test]
36132 fn mapping_ext_insert_singleton_mapping_sequence_promotes_value_to_singleton_mapping_seq() {
36133 // First-insertion returns None (mirroring [`Mapping::insert`])
36134 // and the inserted value is a `Value::Sequence` of exactly one
36135 // element, wrapping the caller's Mapping as `Value::Mapping`.
36136 // Peer with the sibling
36137 // `mapping_ext_insert_sequence_promotes_value_to_yaml_sequence`
36138 // / `mapping_ext_insert_mapping_promotes_value_to_yaml_mapping`
36139 // / `mapping_ext_insert_string_promotes_value_to_yaml_string`
36140 // first-insert pins on the sibling MappingExt primitive
36141 // members.
36142 let mut inner = serde_yaml::Mapping::new();
36143 inner.insert_str_key(
36144 GATEWAY_API_KEY_NAME,
36145 serde_yaml::Value::String("gw-listener".into()),
36146 );
36147 let mut m = serde_yaml::Mapping::new();
36148 let prior = m.insert_singleton_mapping_sequence(GATEWAY_API_KEY_LISTENERS, inner.clone());
36149 assert_eq!(
36150 prior, None,
36151 "insert_singleton_mapping_sequence returns None on first insertion, \
36152 mirroring serde_yaml::Mapping::insert"
36153 );
36154 let got = m
36155 .get(GATEWAY_API_KEY_LISTENERS)
36156 .expect("inserted key is present under Value::Sequence promotion");
36157 assert_eq!(
36158 got,
36159 &serde_yaml::Value::Sequence(vec![serde_yaml::Value::Mapping(inner)]),
36160 "insert_singleton_mapping_sequence routes value verbatim through \
36161 the singleton_mapping_sequence(_) helper wrap"
36162 );
36163 }
36164
36165 #[test]
36166 fn mapping_ext_insert_singleton_mapping_sequence_returns_prior_value_on_replace() {
36167 // The trait method mirrors [`serde_yaml::Mapping::insert`]'s
36168 // return contract: the prior value at that key, or `None` if
36169 // absent. Pin the replace-returns-prior semantic so a future
36170 // refactor that swaps to a `HashMap::entry`-style flow doesn't
36171 // silently drop the prior-value handoff downstream consumers
36172 // may reach for. Peer with the sibling
36173 // `mapping_ext_insert_sequence_returns_prior_value_on_replace`
36174 // and its siblings on the primitive-quintuple axis.
36175 let mut first = serde_yaml::Mapping::new();
36176 first.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("a".into()));
36177 let mut second = serde_yaml::Mapping::new();
36178 second.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("b".into()));
36179 let mut m = serde_yaml::Mapping::new();
36180 m.insert_singleton_mapping_sequence(GATEWAY_API_KEY_PARENT_REFS, first.clone());
36181 let prior =
36182 m.insert_singleton_mapping_sequence(GATEWAY_API_KEY_PARENT_REFS, second.clone());
36183 assert_eq!(
36184 prior,
36185 Some(serde_yaml::Value::Sequence(vec![
36186 serde_yaml::Value::Mapping(first)
36187 ])),
36188 "insert_singleton_mapping_sequence returns the prior value \
36189 when replacing an existing key"
36190 );
36191 let got = m
36192 .get(GATEWAY_API_KEY_PARENT_REFS)
36193 .expect("key is still present after replace");
36194 assert_eq!(
36195 got,
36196 &serde_yaml::Value::Sequence(vec![serde_yaml::Value::Mapping(second)]),
36197 "replaced value is now the most-recently-inserted singleton \
36198 mapping sequence"
36199 );
36200 }
36201
36202 #[test]
36203 fn mapping_ext_insert_singleton_mapping_sequence_matches_hand_written_composition() {
36204 // Cross-check the trait method against the hand-written
36205 // `mapping.insert_str_key(KEY, singleton_mapping_sequence(m))`
36206 // two-symbol composition the 7 lifted call sites previously
36207 // carried. A drift between the trait method's routing and the
36208 // inline composition would silently emit a different YAML
36209 // mapping (a differently-wrapped outer variant, a
36210 // differently-shaped inner singleton-Mapping list) at every
36211 // routed consumer — pin the equivalence so the trait remains a
36212 // drop-in replacement. Three cases pin the shape end-to-end:
36213 // an empty inner Mapping (no silent is_empty short-circuit,
36214 // matches the sibling `singleton_mapping_sequence_preserves_empty_inner_mapping`
36215 // pin), a single-key inner Mapping (the
36216 // `CILIUM_KEY_HTTP` / `CILIUM_KEY_INGRESS` singleton-rule
36217 // shape), and a multi-key inner Mapping (the
36218 // `GATEWAY_API_KEY_LISTENERS` per-listener shape).
36219 let inner_empty = serde_yaml::Mapping::new();
36220 let mut inner_single_key = serde_yaml::Mapping::new();
36221 inner_single_key
36222 .insert_str_key(CILIUM_KEY_PATH, serde_yaml::Value::String("/health".into()));
36223 let mut inner_multi_key = serde_yaml::Mapping::new();
36224 inner_multi_key.insert_str_key(
36225 GATEWAY_API_KEY_NAME,
36226 serde_yaml::Value::String("http".into()),
36227 );
36228 inner_multi_key.insert_str_key(
36229 KUBE_KEY_PORT,
36230 serde_yaml::Value::Number(GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT.into()),
36231 );
36232
36233 let mut via_trait = serde_yaml::Mapping::new();
36234 via_trait.insert_singleton_mapping_sequence(CILIUM_KEY_HTTP, inner_empty.clone());
36235 via_trait.insert_singleton_mapping_sequence(CILIUM_KEY_INGRESS, inner_single_key.clone());
36236 via_trait
36237 .insert_singleton_mapping_sequence(GATEWAY_API_KEY_LISTENERS, inner_multi_key.clone());
36238
36239 let mut via_inline = serde_yaml::Mapping::new();
36240 via_inline.insert_str_key(CILIUM_KEY_HTTP, singleton_mapping_sequence(inner_empty));
36241 via_inline.insert_str_key(
36242 CILIUM_KEY_INGRESS,
36243 singleton_mapping_sequence(inner_single_key),
36244 );
36245 via_inline.insert_str_key(
36246 GATEWAY_API_KEY_LISTENERS,
36247 singleton_mapping_sequence(inner_multi_key),
36248 );
36249
36250 assert_eq!(
36251 via_trait, via_inline,
36252 "insert_singleton_mapping_sequence(KEY, m) must byte-equal \
36253 insert_str_key(KEY, singleton_mapping_sequence(m)) — otherwise \
36254 the seven routed caixa-mesh consumer sites drift silently at \
36255 emit time"
36256 );
36257 }
36258
36259 // ── entry_str_key — entry-API twin of insert_str_key ─────────────────
36260
36261 #[test]
36262 fn mapping_ext_entry_str_key_or_inserts_default_under_yaml_string_promoted_key_when_absent() {
36263 // The trait method promotes an arbitrary `&str` key to
36264 // `Value::String(key.to_string())` on the entry-API axis — pin
36265 // the promotion + the entry-API contract so a future refactor
36266 // that reaches for a different `Value` variant for the entry
36267 // key (e.g. `Value::Tagged`) or breaks the entry-API
36268 // `.or_insert(...)` composition is a compile-visible break,
36269 // not a silent per-consumer regression at the 4 lifted
36270 // `caixa-flux` idempotent-upsert sites. Peer with the sibling
36271 // [`mapping_ext_insert_str_key_promotes_key_to_yaml_string`] on
36272 // the fresh-emit axis of the same key promotion.
36273 let mut m = serde_yaml::Mapping::new();
36274 let default_val = serde_yaml::Value::Sequence(Vec::new());
36275 let inserted = m.entry_str_key("programs").or_insert(default_val.clone());
36276 assert_eq!(
36277 inserted, &default_val,
36278 "entry_str_key(K).or_insert(D) returns &mut D on the absent-key \
36279 path, mirroring serde_yaml::mapping::Entry::or_insert"
36280 );
36281 // Key is exactly the `Value::String` promotion of the input.
36282 let got = m
36283 .get("programs")
36284 .expect("or_insert-defaulted key is present under Value::String promotion");
36285 assert_eq!(
36286 got, &default_val,
36287 "entry_str_key routes the default verbatim to the underlying \
36288 serde_yaml::Mapping::entry(...).or_insert(...) path"
36289 );
36290 }
36291
36292 #[test]
36293 fn mapping_ext_entry_str_key_leaves_prior_value_untouched_on_or_insert_when_present() {
36294 // The trait method mirrors [`serde_yaml::mapping::Entry::or_insert`]'s
36295 // present-key contract: the prior value is preserved, and the
36296 // returned `&mut Value` points at that prior value (NOT the
36297 // discarded default). Pin the leave-prior-untouched semantic so a
36298 // future refactor that swaps to an `.insert`-style overwrite
36299 // flow doesn't silently clobber every idempotent-upsert consumer
36300 // (the M4 per-`:politicas` overlay merger, the `feira app
36301 // deploy` idempotent-write dry-run comparator). Peer with the
36302 // sibling [`mapping_ext_insert_str_key_returns_prior_value_on_replace`]
36303 // pin on the fresh-emit axis (which mirrors the `insert`
36304 // replace-and-return-prior semantic, not the `entry.or_insert`
36305 // preserve-prior semantic — the two APIs partition the
36306 // `Mapping`-write surface exactly on this axis).
36307 let mut m = serde_yaml::Mapping::new();
36308 m.insert_str_key(
36309 FLEET_PROGRAMS_KEY_PROGRAMS,
36310 serde_yaml::Value::Sequence(vec![serde_yaml::Value::String("existing".into())]),
36311 );
36312 let discarded_default = serde_yaml::Value::Sequence(Vec::new());
36313 let returned = m
36314 .entry_str_key(FLEET_PROGRAMS_KEY_PROGRAMS)
36315 .or_insert(discarded_default);
36316 assert_eq!(
36317 returned,
36318 &serde_yaml::Value::Sequence(vec![serde_yaml::Value::String("existing".into())]),
36319 "entry_str_key(K).or_insert(D) returns &mut prior on the \
36320 present-key path — the discarded default must not overwrite \
36321 the emitter's prior write"
36322 );
36323 // Value at the key is still the pre-existing one, verbatim.
36324 let got = m
36325 .get(FLEET_PROGRAMS_KEY_PROGRAMS)
36326 .expect("key is still present after or_insert on the present-key path");
36327 assert_eq!(
36328 got,
36329 &serde_yaml::Value::Sequence(vec![serde_yaml::Value::String("existing".into())]),
36330 "or_insert on the present-key path preserves the prior value \
36331 verbatim — no clobber, no reshape"
36332 );
36333 }
36334
36335 #[test]
36336 fn mapping_ext_entry_str_key_matches_hand_written_composition() {
36337 // Cross-check the trait method against the hand-written
36338 // `mapping.entry(Value::String(KEY.into()))` three-token
36339 // composition the 4 lifted `caixa-flux` call sites previously
36340 // carried. A drift between the trait method's promotion and the
36341 // inline promotion the prior call sites used would silently
36342 // route every idempotent-upsert consumer past a different bucket
36343 // (a differently-promoted key on absent-key insert, a hash-key
36344 // mismatch that always fires the `or_insert` default even when
36345 // the emitter's `insert_str_key` already wrote a value under
36346 // the same key). Two cases pin the shape end-to-end: an
36347 // absent-key path (both routes take the vacant `or_insert`
36348 // branch, both end up storing the same default under the
36349 // promoted key) and a present-key path (both routes take the
36350 // occupied `or_insert` branch, both leave the prior value
36351 // untouched — the twin of the
36352 // `mapping_ext_insert_str_key_matches_hand_written_promotion`
36353 // pin on the fresh-emit axis).
36354 //
36355 // Absent-key path — the vacant `or_insert` branch.
36356 let mut via_trait_absent = serde_yaml::Mapping::new();
36357 via_trait_absent
36358 .entry_str_key(FLEET_PROGRAMS_KEY_PROGRAMS)
36359 .or_insert(serde_yaml::Value::Sequence(Vec::new()));
36360 let mut via_inline_absent = serde_yaml::Mapping::new();
36361 via_inline_absent
36362 .entry(serde_yaml::Value::String(
36363 FLEET_PROGRAMS_KEY_PROGRAMS.into(),
36364 ))
36365 .or_insert(serde_yaml::Value::Sequence(Vec::new()));
36366 assert_eq!(
36367 via_trait_absent, via_inline_absent,
36368 "entry_str_key(K).or_insert(D) must byte-equal \
36369 entry(Value::String(K.into())).or_insert(D) on the absent-key \
36370 path — otherwise the 4 routed caixa-flux consumer sites \
36371 land the default under a different bucket than the emitter's \
36372 `insert_str_key` write and the idempotent-upsert semantic \
36373 silently doubles the entry on every call"
36374 );
36375
36376 // Present-key path — the occupied `or_insert` branch. Seed both
36377 // mappings via the fresh-emit `insert_str_key` peer (which the
36378 // `matches_hand_written_promotion` pin already gates), so the
36379 // present-key path here inherits the promotion-agreement guarantee
36380 // from that peer and tests only the entry-API branch difference.
36381 let seed = serde_yaml::Value::Mapping(serde_yaml::Mapping::new());
36382 let mut via_trait_present = serde_yaml::Mapping::new();
36383 via_trait_present.insert_str_key(FLUX_KEY_VALUES, seed.clone());
36384 via_trait_present
36385 .entry_str_key(FLUX_KEY_VALUES)
36386 .or_insert(serde_yaml::Value::Sequence(Vec::new()));
36387 let mut via_inline_present = serde_yaml::Mapping::new();
36388 via_inline_present.insert_str_key(FLUX_KEY_VALUES, seed);
36389 via_inline_present
36390 .entry(serde_yaml::Value::String(FLUX_KEY_VALUES.into()))
36391 .or_insert(serde_yaml::Value::Sequence(Vec::new()));
36392 assert_eq!(
36393 via_trait_present, via_inline_present,
36394 "entry_str_key(K).or_insert(D) must byte-equal \
36395 entry(Value::String(K.into())).or_insert(D) on the \
36396 present-key path — otherwise a promoted-key mismatch would \
36397 cause the trait routing to see the seed as absent and \
36398 overwrite the emitter's prior write while the hand-written \
36399 inline routing sees it as present and preserves it (or vice \
36400 versa)"
36401 );
36402 }
36403
36404 // ── entry_or_default_{mapping,sequence} — entry-API-with-container-check ─
36405
36406 #[test]
36407 fn mapping_ext_entry_or_default_mapping_seeds_empty_inner_when_absent() {
36408 // Absent-key path — the helper mints an empty
36409 // `Value::Mapping(Mapping::new())` under the promoted key and
36410 // returns `Some(&mut inner)` pointing at the fresh empty inner.
36411 // Pin the seed shape so a future refactor that reaches for a
36412 // different empty-container variant (e.g. `Value::Null`, or a
36413 // `Mapping::with_capacity(_)` non-empty pre-allocation) or
36414 // breaks the `Option::Some` return contract is a compile-visible
36415 // break, not a silent per-consumer regression at the caixa-flux
36416 // `upsert_into_helmrelease_programs` `spec.values` container-
36417 // upsert. Peer with the sibling
36418 // [`mapping_ext_entry_or_default_sequence_seeds_empty_inner_when_absent`]
36419 // on the sibling list-container axis.
36420 let mut m = serde_yaml::Mapping::new();
36421 {
36422 let inner = m
36423 .entry_or_default_mapping(FLUX_KEY_VALUES)
36424 .expect("absent-key path seeds an empty Mapping and returns Some(&mut _)");
36425 assert!(
36426 inner.is_empty(),
36427 "the seeded default must be an EMPTY Mapping — a \
36428 non-empty pre-allocation would land a K8s CRD schema \
36429 pre-populated block the emitter never authored"
36430 );
36431 }
36432 // Key is exactly the `Value::String` promotion of the input,
36433 // and the value is the empty-Mapping seed.
36434 let got = m
36435 .get(FLUX_KEY_VALUES)
36436 .expect("or_default seeded the key under Value::String promotion");
36437 assert_eq!(
36438 got,
36439 &serde_yaml::Value::Mapping(serde_yaml::Mapping::new()),
36440 "entry_or_default_mapping seeds Value::Mapping(Mapping::new()) \
36441 verbatim on the absent-key arm — no reshape, no wrap"
36442 );
36443 }
36444
36445 #[test]
36446 fn mapping_ext_entry_or_default_mapping_preserves_prior_mapping_on_present_arm() {
36447 // Present-key path with matching variant — the helper mirrors
36448 // [`serde_yaml::mapping::Entry::or_insert_with`]'s occupied
36449 // branch: the prior value is preserved, and the returned
36450 // `&mut Mapping` points at that prior inner Mapping (NOT a
36451 // fresh empty default). Pin the leave-prior-untouched semantic
36452 // so a future refactor that reaches for an `.insert`-style
36453 // overwrite flow doesn't silently clobber every idempotent-
36454 // container-upsert consumer (the `feira app deploy` per-cluster
36455 // write path, the M4 per-cluster HelmRelease overlay merger).
36456 let mut m = serde_yaml::Mapping::new();
36457 let mut prior_inner = serde_yaml::Mapping::new();
36458 prior_inner.insert_str_key(HELM_VALUES_KEY_ENABLED, serde_yaml::Value::Bool(true));
36459 m.insert_mapping(FLUX_KEY_VALUES, prior_inner.clone());
36460 {
36461 let inner = m
36462 .entry_or_default_mapping(FLUX_KEY_VALUES)
36463 .expect("present-Mapping-variant path returns Some(&mut prior)");
36464 assert_eq!(
36465 inner, &prior_inner,
36466 "entry_or_default_mapping returns &mut prior on the \
36467 present-key path — the default empty Mapping must not \
36468 overwrite the emitter's prior write"
36469 );
36470 }
36471 // Value at the key is still the pre-existing one, verbatim.
36472 let got = m
36473 .get(FLUX_KEY_VALUES)
36474 .expect("key is still present after or_default on the present-key path");
36475 assert_eq!(
36476 got,
36477 &serde_yaml::Value::Mapping(prior_inner),
36478 "or_default on the present-key path preserves the prior \
36479 value verbatim — no clobber, no reshape"
36480 );
36481 }
36482
36483 #[test]
36484 fn mapping_ext_entry_or_default_mapping_returns_none_on_variant_mismatch() {
36485 // Present-key path with mismatched variant — the helper returns
36486 // `None`, letting the caller surface its domain-specific
36487 // "expected Mapping at this schema key" diagnostic (rather than
36488 // silently clobbering the mismatched prior value). Pin the
36489 // structural-mismatch-is-None contract so a future refactor
36490 // that reaches for a fallback-to-empty-default flow doesn't
36491 // silently overwrite user-authored non-Mapping data at the
36492 // canonical caixa-flux `Error::MissingField("spec.values must
36493 // be a mapping")` site — the mismatched-variant arm is
36494 // load-bearing for the domain-error diagnostic path, not just
36495 // a corner case.
36496 let mut m = serde_yaml::Mapping::new();
36497 m.insert_string(FLUX_KEY_VALUES, "not-a-mapping");
36498 let result = m.entry_or_default_mapping(FLUX_KEY_VALUES);
36499 assert!(
36500 result.is_none(),
36501 "entry_or_default_mapping returns None on variant \
36502 mismatch — the caller's `.ok_or(Error::MissingField(_))?` \
36503 chain surfaces the structural type-mismatch diagnostic"
36504 );
36505 let got = m
36506 .get(FLUX_KEY_VALUES)
36507 .expect("mismatched-variant prior value stays present after variant-check");
36508 assert_eq!(
36509 got,
36510 &serde_yaml::Value::String("not-a-mapping".into()),
36511 "None arm on variant mismatch leaves the prior value \
36512 untouched — the caller's domain-error path fires without \
36513 clobbering the user-authored data"
36514 );
36515 }
36516
36517 #[test]
36518 fn mapping_ext_entry_or_default_sequence_seeds_empty_inner_when_absent() {
36519 // Absent-key path — the helper mints an empty
36520 // `Value::Sequence(Vec::new())` under the promoted key and
36521 // returns `Some(&mut inner)` pointing at the fresh empty
36522 // `Vec<Value>`. Peer with
36523 // [`mapping_ext_entry_or_default_mapping_seeds_empty_inner_when_absent`]
36524 // on the nested-Mapping-container axis.
36525 let mut m = serde_yaml::Mapping::new();
36526 {
36527 let inner = m
36528 .entry_or_default_sequence(FLEET_PROGRAMS_KEY_PROGRAMS)
36529 .expect("absent-key path seeds an empty Vec and returns Some(&mut _)");
36530 assert!(
36531 inner.is_empty(),
36532 "the seeded default must be an EMPTY Vec — a non-empty \
36533 pre-allocation would land a pre-populated fleet-programs \
36534 list the emitter never authored"
36535 );
36536 }
36537 let got = m
36538 .get(FLEET_PROGRAMS_KEY_PROGRAMS)
36539 .expect("or_default seeded the key under Value::String promotion");
36540 assert_eq!(
36541 got,
36542 &serde_yaml::Value::Sequence(Vec::new()),
36543 "entry_or_default_sequence seeds Value::Sequence(Vec::new()) \
36544 verbatim on the absent-key arm — no reshape, no wrap"
36545 );
36546 }
36547
36548 #[test]
36549 fn mapping_ext_entry_or_default_sequence_preserves_prior_sequence_on_present_arm() {
36550 // Present-key path with matching variant — the helper mirrors
36551 // [`serde_yaml::mapping::Entry::or_insert_with`]'s occupied
36552 // branch: the prior `Vec` is preserved, and the returned
36553 // `&mut Vec<Value>` points at that prior inner Vec (NOT a
36554 // fresh empty default). The exact idempotent-upsert semantic
36555 // caixa-flux's `upsert_into_programs_yaml` /
36556 // `upsert_into_helmrelease_programs` depend on to preserve
36557 // prior `programs[]` entries across per-Servico rewrites.
36558 let mut m = serde_yaml::Mapping::new();
36559 let prior_inner = vec![serde_yaml::Value::String("existing".into())];
36560 m.insert_sequence(FLEET_PROGRAMS_KEY_PROGRAMS, prior_inner.clone());
36561 {
36562 let inner = m
36563 .entry_or_default_sequence(FLEET_PROGRAMS_KEY_PROGRAMS)
36564 .expect("present-Sequence-variant path returns Some(&mut prior)");
36565 assert_eq!(
36566 inner, &prior_inner,
36567 "entry_or_default_sequence returns &mut prior on the \
36568 present-key path — the default empty Vec must not \
36569 overwrite the emitter's prior write"
36570 );
36571 }
36572 let got = m
36573 .get(FLEET_PROGRAMS_KEY_PROGRAMS)
36574 .expect("key is still present after or_default on the present-key path");
36575 assert_eq!(
36576 got,
36577 &serde_yaml::Value::Sequence(prior_inner),
36578 "or_default on the present-key path preserves the prior \
36579 value verbatim — no clobber, no reshape"
36580 );
36581 }
36582
36583 #[test]
36584 fn mapping_ext_entry_or_default_sequence_returns_none_on_variant_mismatch() {
36585 // Present-key path with mismatched variant — the helper returns
36586 // `None`, letting the caller surface its domain-specific
36587 // "programs must be a sequence" diagnostic (rather than
36588 // silently clobbering the mismatched prior value). Pin the
36589 // structural-mismatch-is-None contract so a future refactor
36590 // that reaches for a fallback-to-empty-default flow doesn't
36591 // silently overwrite user-authored non-Sequence data at the
36592 // canonical caixa-flux `Error::MissingField("programs must be
36593 // a sequence")` site.
36594 let mut m = serde_yaml::Mapping::new();
36595 m.insert_string(FLEET_PROGRAMS_KEY_PROGRAMS, "not-a-sequence");
36596 let result = m.entry_or_default_sequence(FLEET_PROGRAMS_KEY_PROGRAMS);
36597 assert!(
36598 result.is_none(),
36599 "entry_or_default_sequence returns None on variant \
36600 mismatch — the caller's `.ok_or(Error::MissingField(_))?` \
36601 chain surfaces the structural type-mismatch diagnostic"
36602 );
36603 let got = m
36604 .get(FLEET_PROGRAMS_KEY_PROGRAMS)
36605 .expect("mismatched-variant prior value stays present after variant-check");
36606 assert_eq!(
36607 got,
36608 &serde_yaml::Value::String("not-a-sequence".into()),
36609 "None arm on variant mismatch leaves the prior value \
36610 untouched — the caller's domain-error path fires without \
36611 clobbering the user-authored data"
36612 );
36613 }
36614
36615 // ── insert_str_key_if_some — arity-0-or-1 twin of insert_str_key ─────
36616
36617 #[test]
36618 fn mapping_ext_insert_str_key_if_some_none_arm_leaves_mapping_untouched() {
36619 // The None arm skips the insert entirely — no clone, no
36620 // key-promotion, no bucket touch. Pin the no-op semantic so a
36621 // future refactor that reaches for an `Option::unwrap_or_default`
36622 // shape (which would emit `Value::Null` under the key on the
36623 // None arm) or an `.into_iter().for_each` scaffold (which would
36624 // still walk the bucket-lookup path) is a compile-visible break,
36625 // not a silent per-consumer regression at the 3 lifted
36626 // `caixa-mesh` overlay-insert sites (where the `None` arm is
36627 // the author's default when no `:politicas` slot is set — a
36628 // silent `Value::Null` emission would land a K8s CRD schema
36629 // rejection at every unset-slot Aplicacao).
36630 let mut m = serde_yaml::Mapping::new();
36631 let prior = m.insert_str_key_if_some(CILIUM_KEY_AUTHENTICATION, None);
36632 assert_eq!(
36633 prior, None,
36634 "insert_str_key_if_some(K, None) returns None — no insert \
36635 fires, so no prior value can be surfaced"
36636 );
36637 assert!(
36638 m.get(CILIUM_KEY_AUTHENTICATION).is_none(),
36639 "None arm must leave the key absent — a silent `Value::Null` \
36640 insertion would land a K8s CRD schema rejection at every \
36641 `:politicas`-unset Aplicacao"
36642 );
36643 assert_eq!(
36644 m.len(),
36645 0,
36646 "None arm must not touch any bucket — the Mapping stays \
36647 empty verbatim"
36648 );
36649 }
36650
36651 #[test]
36652 fn mapping_ext_insert_str_key_if_some_some_arm_promotes_key_to_yaml_string() {
36653 // The Some arm clones the borrowed inner value and delegates to
36654 // [`Self::insert_str_key`] — pin the promotion + the first-
36655 // insert-returns-None contract so a future refactor that reaches
36656 // for a different `Value` variant for the key (e.g.
36657 // `Value::Tagged`) or breaks the underlying
36658 // [`serde_yaml::Mapping::insert`] return contract is a compile-
36659 // visible break, not a silent per-consumer regression at the 3
36660 // lifted `caixa-mesh` overlay-insert sites. Peer with the sibling
36661 // [`mapping_ext_insert_str_key_promotes_key_to_yaml_string`] on
36662 // the always-1 arity axis of the same key promotion.
36663 let mut m = serde_yaml::Mapping::new();
36664 let overlay = serde_yaml::Value::Mapping({
36665 let mut inner = serde_yaml::Mapping::new();
36666 inner.insert_str_key(
36667 CILIUM_KEY_MODE,
36668 serde_yaml::Value::String("required".into()),
36669 );
36670 inner
36671 });
36672 let prior = m.insert_str_key_if_some(CILIUM_KEY_AUTHENTICATION, Some(&overlay));
36673 assert_eq!(
36674 prior, None,
36675 "insert_str_key_if_some(K, Some(&V)) returns None on first \
36676 insertion, mirroring serde_yaml::Mapping::insert"
36677 );
36678 // Key is exactly the `Value::String` promotion of the input.
36679 let got = m
36680 .get(CILIUM_KEY_AUTHENTICATION)
36681 .expect("Some arm inserts under the Value::String-promoted key");
36682 assert_eq!(
36683 got, &overlay,
36684 "insert_str_key_if_some routes the borrowed inner value \
36685 through a `.clone()` verbatim to the underlying \
36686 `insert_str_key` path — no reshape, no wrap, no unwrap"
36687 );
36688 // The borrowed input is untouched — the caller can reuse the
36689 // outer overlay binding across the next iteration of a per-
36690 // `(:de, :para)` loop (the exact reuse the three lifted
36691 // caixa-mesh sites depend on).
36692 assert!(
36693 overlay.get(CILIUM_KEY_MODE).is_some(),
36694 "insert_str_key_if_some must not move out of the borrowed \
36695 overlay — the caller-side outer binding stays available \
36696 for the next iteration of the enclosing per-`(:de, :para)` \
36697 or per-rule loop"
36698 );
36699 }
36700
36701 #[test]
36702 fn mapping_ext_insert_str_key_if_some_some_arm_returns_prior_value_on_replace() {
36703 // The Some arm mirrors [`serde_yaml::Mapping::insert`]'s return
36704 // contract on the replace-existing path: the prior value at that
36705 // key, surfaced verbatim. Pin the replace-returns-prior semantic
36706 // so a future refactor that reaches for an `entry.or_insert`-
36707 // style preserve-prior flow doesn't silently swap the axis's
36708 // semantic under the three routed caixa-mesh overlay sites (the
36709 // `:politicas` overlay is meant to override an author-provided
36710 // sub-block if one was present, not preserve it — the
36711 // replace-and-return-prior semantic is load-bearing).
36712 let mut m = serde_yaml::Mapping::new();
36713 let existing = serde_yaml::Value::String("cluster-default".into());
36714 let overlay = serde_yaml::Value::Mapping({
36715 let mut inner = serde_yaml::Mapping::new();
36716 inner.insert_str_key(
36717 GATEWAY_API_KEY_REQUEST,
36718 serde_yaml::Value::String("30s".into()),
36719 );
36720 inner
36721 });
36722 m.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36723 let prior = m.insert_str_key_if_some(GATEWAY_API_KEY_TIMEOUTS, Some(&overlay));
36724 assert_eq!(
36725 prior,
36726 Some(existing),
36727 "insert_str_key_if_some(K, Some(&V)) returns the prior value \
36728 when replacing an existing key — the overlay overrides the \
36729 author-provided sub-block; the prior value surfaces so the \
36730 caller can log/compare/roll back if needed"
36731 );
36732 // Value at the key is now the overlay, verbatim.
36733 let got = m
36734 .get(GATEWAY_API_KEY_TIMEOUTS)
36735 .expect("key is still present after replace");
36736 assert_eq!(
36737 got, &overlay,
36738 "replaced value is now the most-recently-inserted overlay — \
36739 the Some arm carries through to the underlying \
36740 `insert_str_key` replace path"
36741 );
36742 }
36743
36744 #[test]
36745 fn mapping_ext_insert_str_key_if_some_matches_hand_written_composition() {
36746 // Cross-check the trait method against the hand-written
36747 // `if let Some(x) = &overlay { m.insert_str_key(K, x.clone()); }`
36748 // three-line block the 3 lifted `caixa-mesh` overlay call sites
36749 // previously carried. A drift between the trait method's
36750 // conditional-insert routing and the inline `if let Some`
36751 // composition would silently emit a different Mapping (a
36752 // present-key `Value::Null` on the None arm, a different clone-
36753 // vs-move policy on the Some arm) at every routed consumer —
36754 // pin the equivalence so the trait remains a drop-in replacement.
36755 // Four cases pin the shape end-to-end: None arm (skip), Some
36756 // arm on absent key (fresh insert), Some arm on present key
36757 // (replace-and-return-prior), None arm on present key (no
36758 // touch — the axis's load-bearing "author's value wins when
36759 // overlay is unset" contract).
36760 let overlay = serde_yaml::Value::Mapping({
36761 let mut inner = serde_yaml::Mapping::new();
36762 inner.insert_str_key(
36763 CILIUM_KEY_MODE,
36764 serde_yaml::Value::String("required".into()),
36765 );
36766 inner
36767 });
36768
36769 // Case 1: None arm on empty mapping — both routes no-op.
36770 let mut via_trait_none = serde_yaml::Mapping::new();
36771 via_trait_none.insert_str_key_if_some(CILIUM_KEY_AUTHENTICATION, None);
36772 let via_inline_none = serde_yaml::Mapping::new();
36773 let overlay_slot_none: Option<serde_yaml::Value> = None;
36774 let mut via_inline_none_mut = via_inline_none.clone();
36775 if let Some(a) = &overlay_slot_none {
36776 via_inline_none_mut.insert_str_key(CILIUM_KEY_AUTHENTICATION, a.clone());
36777 }
36778 assert_eq!(
36779 via_trait_none, via_inline_none_mut,
36780 "insert_str_key_if_some(K, None) must byte-equal \
36781 `if let Some(_) = None {{ … }}` — the no-op arm must not \
36782 emit a stray `Value::Null` under the key"
36783 );
36784
36785 // Case 2: Some arm on empty mapping — both routes fresh-insert.
36786 let mut via_trait_some = serde_yaml::Mapping::new();
36787 via_trait_some.insert_str_key_if_some(CILIUM_KEY_AUTHENTICATION, Some(&overlay));
36788 let mut via_inline_some = serde_yaml::Mapping::new();
36789 let overlay_slot_some = Some(overlay.clone());
36790 if let Some(a) = &overlay_slot_some {
36791 via_inline_some.insert_str_key(CILIUM_KEY_AUTHENTICATION, a.clone());
36792 }
36793 assert_eq!(
36794 via_trait_some, via_inline_some,
36795 "insert_str_key_if_some(K, Some(&V)) must byte-equal \
36796 `if let Some(x) = &Some(V.clone()) {{ m.insert_str_key(K, \
36797 x.clone()); }}` on the fresh-insert path — same clone-and-\
36798 insert semantics under the same Value::String-promoted \
36799 bucket"
36800 );
36801
36802 // Case 3: Some arm on present key — both routes replace-and-
36803 // return-prior.
36804 let existing = serde_yaml::Value::String("cluster-default".into());
36805 let mut via_trait_replace = serde_yaml::Mapping::new();
36806 via_trait_replace.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36807 let trait_prior =
36808 via_trait_replace.insert_str_key_if_some(GATEWAY_API_KEY_TIMEOUTS, Some(&overlay));
36809 let mut via_inline_replace = serde_yaml::Mapping::new();
36810 via_inline_replace.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36811 let overlay_slot_replace = Some(overlay.clone());
36812 let inline_prior = if let Some(a) = &overlay_slot_replace {
36813 via_inline_replace.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, a.clone())
36814 } else {
36815 None
36816 };
36817 assert_eq!(
36818 trait_prior, inline_prior,
36819 "insert_str_key_if_some replace-and-return-prior must byte-\
36820 equal the hand-written `if let Some {{ insert_str_key }}` \
36821 composition's return"
36822 );
36823 assert_eq!(
36824 via_trait_replace, via_inline_replace,
36825 "insert_str_key_if_some replace-post-state must byte-equal \
36826 the hand-written composition's post-state — the overlay \
36827 overrode the author's value in both routes"
36828 );
36829
36830 // Case 4: None arm on present key — both routes preserve the
36831 // author's value verbatim. The load-bearing "author's value
36832 // wins when overlay is unset" contract the three lifted sites
36833 // depend on.
36834 let mut via_trait_preserve = serde_yaml::Mapping::new();
36835 via_trait_preserve.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36836 via_trait_preserve.insert_str_key_if_some(GATEWAY_API_KEY_TIMEOUTS, None);
36837 let mut via_inline_preserve = serde_yaml::Mapping::new();
36838 via_inline_preserve.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, existing.clone());
36839 let overlay_slot_preserve: Option<serde_yaml::Value> = None;
36840 if let Some(a) = &overlay_slot_preserve {
36841 via_inline_preserve.insert_str_key(GATEWAY_API_KEY_TIMEOUTS, a.clone());
36842 }
36843 assert_eq!(
36844 via_trait_preserve, via_inline_preserve,
36845 "insert_str_key_if_some(K, None) on a present key must byte-\
36846 equal the hand-written `if let Some(_) = None {{ … }}` — \
36847 the None arm must preserve the author's value verbatim, \
36848 not clobber it with `Value::Null` or drop the key"
36849 );
36850 assert_eq!(
36851 via_trait_preserve
36852 .get(GATEWAY_API_KEY_TIMEOUTS)
36853 .expect("None arm preserves the pre-existing key"),
36854 &existing,
36855 "None arm on a present key surfaces the author's prior \
36856 value verbatim — the load-bearing contract the three \
36857 lifted `:politicas` overlay sites rest on"
36858 );
36859 }
36860
36861 // ── SequenceExt::push_mapping — Vec<Value>-side sibling ──────────────
36862
36863 #[test]
36864 fn sequence_ext_push_mapping_appends_promoted_mapping_value() {
36865 // The method appends the caller's `Mapping` as a fresh
36866 // `Value::Mapping(_)` element on the tail of `self`. Pin the
36867 // per-append routing (`.push(Value::Mapping(_))`) so a future
36868 // refactor that reaches for a different outer variant (a
36869 // Server-Side-Apply-typed `Value::Tagged`, a fresh singleton-list
36870 // wrap via `singleton_mapping_sequence`) or a different
36871 // Vec-mutation shape (e.g. `.insert(0, _)` shifting the axis
36872 // from append to prepend) is a compile-visible break, not a
36873 // silent per-consumer regression at the 4 lifted `caixa-mesh`
36874 // append sites — where the emission order is load-bearing (the
36875 // Cilium `spec.ingress[].toPorts[]` per-edge order, the
36876 // Gateway API `spec.rules[]` per-path order, the top-level CNP
36877 // and programs.yaml document order all depend on the append
36878 // semantics).
36879 let mut seq: Vec<serde_yaml::Value> = Vec::new();
36880 let mut m = serde_yaml::Mapping::new();
36881 m.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("first".into()));
36882 seq.push_mapping(m.clone());
36883 assert_eq!(
36884 seq.len(),
36885 1,
36886 "push_mapping must append exactly one element — the axis's \
36887 fresh-element semantic"
36888 );
36889 assert_eq!(
36890 seq[0],
36891 serde_yaml::Value::Mapping(m),
36892 "the appended element must be the caller's Mapping wrapped \
36893 verbatim as Value::Mapping — no reshape, no clone-and-drop"
36894 );
36895 }
36896
36897 #[test]
36898 fn sequence_ext_push_mapping_preserves_prior_elements_in_insertion_order() {
36899 // Successive push_mapping calls preserve the caller's per-
36900 // iteration order — the Vec grows at the tail, prior elements
36901 // stay at their prior indices. Pin the insertion-order semantic
36902 // so a future refactor that reaches for a per-append sort /
36903 // dedup / hoist-to-front reordering is a test-visible break,
36904 // not a silent behavior shift at the 4 lifted `caixa-mesh`
36905 // append sites (where THEORY.md §V.2.7 render determinism
36906 // pins the per-iteration emission order to the source
36907 // `:contratos` / `:paths` / `:membros` declaration order).
36908 let mut seq: Vec<serde_yaml::Value> = Vec::new();
36909 let mut first = serde_yaml::Mapping::new();
36910 first.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("a".into()));
36911 let mut second = serde_yaml::Mapping::new();
36912 second.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("b".into()));
36913 let mut third = serde_yaml::Mapping::new();
36914 third.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("c".into()));
36915 seq.push_mapping(first.clone());
36916 seq.push_mapping(second.clone());
36917 seq.push_mapping(third.clone());
36918 assert_eq!(
36919 seq.len(),
36920 3,
36921 "three push_mapping calls append three elements"
36922 );
36923 assert_eq!(
36924 seq,
36925 vec![
36926 serde_yaml::Value::Mapping(first),
36927 serde_yaml::Value::Mapping(second),
36928 serde_yaml::Value::Mapping(third),
36929 ],
36930 "push_mapping preserves per-iteration insertion order — the \
36931 axis's render-determinism contract at the 4 lifted \
36932 `caixa-mesh` append sites"
36933 );
36934 }
36935
36936 #[test]
36937 fn sequence_ext_push_mapping_matches_hand_written_composition() {
36938 // Cross-check the trait method against the hand-written
36939 // `<vec>.push(serde_yaml::Value::Mapping(<M>))` three-token
36940 // block the 4 lifted `caixa-mesh` append call sites previously
36941 // carried. A drift between the trait method's routing and the
36942 // inline `Value::Mapping(_)` promotion would silently emit a
36943 // different `Vec<Value>` (a different outer variant on the
36944 // appended element, a different length, a different order) at
36945 // every routed consumer — pin the equivalence so the trait
36946 // remains a drop-in replacement across the fresh-empty, prior-
36947 // populated, and empty-payload cases.
36948
36949 // Case 1: fresh-empty Vec + non-empty Mapping payload.
36950 let mut inner = serde_yaml::Mapping::new();
36951 inner.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("policy-a".into()));
36952 let mut via_trait: Vec<serde_yaml::Value> = Vec::new();
36953 via_trait.push_mapping(inner.clone());
36954 let mut via_inline: Vec<serde_yaml::Value> = Vec::new();
36955 via_inline.push(serde_yaml::Value::Mapping(inner.clone()));
36956 assert_eq!(
36957 via_trait, via_inline,
36958 "push_mapping(M) on empty Vec must byte-equal \
36959 `.push(Value::Mapping(M))` — same variant-promotion, same \
36960 append semantics"
36961 );
36962
36963 // Case 2: prior-populated Vec + non-empty Mapping payload — pin
36964 // that the append fires at the tail, not at the head or the
36965 // middle.
36966 let seed = serde_yaml::Value::String("seed".into());
36967 let mut via_trait_populated: Vec<serde_yaml::Value> = vec![seed.clone()];
36968 via_trait_populated.push_mapping(inner.clone());
36969 let mut via_inline_populated: Vec<serde_yaml::Value> = vec![seed];
36970 via_inline_populated.push(serde_yaml::Value::Mapping(inner.clone()));
36971 assert_eq!(
36972 via_trait_populated, via_inline_populated,
36973 "push_mapping(M) on populated Vec must byte-equal \
36974 `.push(Value::Mapping(M))` — the append fires at the tail, \
36975 prior elements stay at their prior indices"
36976 );
36977
36978 // Case 3: empty Mapping payload — the axis's "empty-vs-absent"
36979 // distinction the 4 lifted sites rest on. An empty inner
36980 // `Mapping` still round-trips as a `Value::Mapping(<empty>)`
36981 // element, not as a skipped no-op, because some K8s CRD schemas
36982 // (Cilium CNP `spec.ingress[].toPorts[].rules.http[]` with an
36983 // empty match set) require an empty inner object to distinguish
36984 // "explicitly-empty" from "absent".
36985 let mut via_trait_empty: Vec<serde_yaml::Value> = Vec::new();
36986 via_trait_empty.push_mapping(serde_yaml::Mapping::new());
36987 let mut via_inline_empty: Vec<serde_yaml::Value> = Vec::new();
36988 via_inline_empty.push(serde_yaml::Value::Mapping(serde_yaml::Mapping::new()));
36989 assert_eq!(
36990 via_trait_empty, via_inline_empty,
36991 "push_mapping(empty Mapping) must byte-equal \
36992 `.push(Value::Mapping(empty))` — no is_empty()-guarded \
36993 short-circuit, no skip"
36994 );
36995 assert_eq!(
36996 via_trait_empty.len(),
36997 1,
36998 "push_mapping on an empty Mapping still appends one element \
36999 — the axis carries no is_empty() short-circuit"
37000 );
37001 }
37002
37003 #[test]
37004 fn singleton_mapping_sequence_wraps_input_as_sole_element() {
37005 // The helper wraps its input `Mapping` as the single element of
37006 // a `Value::Sequence`. Pin the outer variant shape and the
37007 // exactly-one-element length so a future refactor that reaches
37008 // for a different container (e.g. `Value::Tagged`, a
37009 // 0-or-1-element `Option`-shaped emission axis) is a
37010 // compile-visible break, not a silent per-caller regression at
37011 // every K8s-CRD-list-shape-required emit site.
37012 let mut inner = serde_yaml::Mapping::new();
37013 inner.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("hello".into()));
37014 let out = singleton_mapping_sequence(inner.clone());
37015 match out {
37016 serde_yaml::Value::Sequence(seq) => {
37017 assert_eq!(
37018 seq.len(),
37019 1,
37020 "singleton_mapping_sequence emits exactly one element — \
37021 the K8s-CRD-list-shape-required singleton axis"
37022 );
37023 assert_eq!(
37024 seq[0],
37025 serde_yaml::Value::Mapping(inner),
37026 "the sole element must be the caller's Mapping wrapped \
37027 verbatim as Value::Mapping — no reshape, no clone-and-drop"
37028 );
37029 }
37030 other => panic!(
37031 "singleton_mapping_sequence must return Value::Sequence, got {other:?} — \
37032 an outer-variant drift breaks every K8s-CRD-list-shape consumer"
37033 ),
37034 }
37035 }
37036
37037 #[test]
37038 fn singleton_mapping_sequence_preserves_empty_inner_mapping() {
37039 // An empty inner `Mapping` still round-trips through the helper
37040 // as a `Value::Sequence(vec![Value::Mapping(<empty>)])` — the
37041 // helper carries no "skip-empty" short-circuit (empty-vs-absent
37042 // is the caller's decision; some K8s CRD schemas require an
37043 // empty inner object to distinguish "explicitly-empty" from
37044 // "absent"). Pin the shape so a future refactor that reaches
37045 // for an is_empty()-guarded short-circuit is a test-visible
37046 // break, not a silent behavior shift.
37047 let out = singleton_mapping_sequence(serde_yaml::Mapping::new());
37048 let seq = match out {
37049 serde_yaml::Value::Sequence(s) => s,
37050 other => panic!("expected Value::Sequence, got {other:?}"),
37051 };
37052 assert_eq!(seq.len(), 1, "empty inner still wraps as a 1-element seq");
37053 assert_eq!(
37054 seq[0],
37055 serde_yaml::Value::Mapping(serde_yaml::Mapping::new()),
37056 "the sole element is an empty Value::Mapping, verbatim"
37057 );
37058 }
37059
37060 #[test]
37061 fn singleton_mapping_sequence_byte_equals_hand_written_inline_shape() {
37062 // Cross-check the helper against the hand-written
37063 // `Value::Sequence(vec![Value::Mapping(m)])` three-token shape
37064 // the seven lifted call sites previously carried. A drift
37065 // between the helper's wrapping and the inline shape would
37066 // silently emit a different YAML sequence (a differently-shaped
37067 // outer variant, a differently-wrapped inner Mapping) at every
37068 // routed consumer — pin the byte-equivalence so the helper
37069 // remains a drop-in replacement.
37070 let mut inner = serde_yaml::Mapping::new();
37071 inner.insert_str_key(
37072 GATEWAY_API_KEY_NAME,
37073 serde_yaml::Value::String("gw-listener".into()),
37074 );
37075 inner.insert_str_key(
37076 KUBE_KEY_PORT,
37077 serde_yaml::Value::Number(GATEWAY_API_DEFAULT_HTTP_LISTENER_PORT.into()),
37078 );
37079
37080 let via_helper = singleton_mapping_sequence(inner.clone());
37081 let via_inline = serde_yaml::Value::Sequence(vec![serde_yaml::Value::Mapping(inner)]);
37082
37083 assert_eq!(
37084 via_helper, via_inline,
37085 "singleton_mapping_sequence(m) must byte-equal \
37086 Value::Sequence(vec![Value::Mapping(m)]) — otherwise the \
37087 seven routed caixa-mesh call sites drift silently at emit time"
37088 );
37089 }
37090
37091 #[test]
37092 fn string_keyed_entries_yields_each_string_key_and_value_ref() {
37093 // The lift's load-bearing contract: given a Value::Mapping with
37094 // string keys, yield each `(&str, &Value)` pair in insertion
37095 // order. Both routed renderers (caixa-flux::programs_yaml_entry
37096 // and caixa-helm::build_values_yaml) depend on the yielded pair
37097 // shape to drive their per-destination insert — a drift in
37098 // yielded item type is a compile-visible break, not a silent
37099 // shape shift.
37100 let mut spec = serde_yaml::Mapping::new();
37101 spec.insert_str_key(
37102 COMPUTEUNIT_SPEC_KEY_MODULE,
37103 serde_yaml::Value::String("oci://…".into()),
37104 );
37105 spec.insert_str_key(
37106 COMPUTEUNIT_SPEC_KEY_TRIGGER,
37107 serde_yaml::Value::String("http".into()),
37108 );
37109 spec.insert_str_key(
37110 COMPUTEUNIT_SPEC_KEY_CAPABILITIES,
37111 serde_yaml::Value::Sequence(vec![]),
37112 );
37113 let v = serde_yaml::Value::Mapping(spec);
37114 let keys: Vec<&str> = string_keyed_entries(&v).map(|(k, _)| k).collect();
37115 assert_eq!(
37116 keys,
37117 vec![
37118 COMPUTEUNIT_SPEC_KEY_MODULE,
37119 COMPUTEUNIT_SPEC_KEY_TRIGGER,
37120 COMPUTEUNIT_SPEC_KEY_CAPABILITIES,
37121 ],
37122 "string_keyed_entries must yield every string-keyed entry in \
37123 the underlying Mapping's insertion order — both routed \
37124 renderers depend on `spec.module` reaching the destination \
37125 ahead of `spec.trigger` ahead of `spec.capabilities` so the \
37126 emitted values.yaml / programs.yaml entry's key order tracks \
37127 the upstream ComputeUnit YAML author's order"
37128 );
37129 // The paired &Value ref also reaches through — sanity-check on
37130 // the second axis of the yielded tuple.
37131 let module = string_keyed_entries(&v)
37132 .find(|(k, _)| *k == COMPUTEUNIT_SPEC_KEY_MODULE)
37133 .map(|(_, v)| v.clone())
37134 .expect("module entry present");
37135 assert_eq!(module, serde_yaml::Value::String("oci://…".into()));
37136 }
37137
37138 #[test]
37139 fn string_keyed_entries_short_circuits_on_non_mapping_shapes() {
37140 // The prior inline `if let Value::Mapping(_) = spec { … }` arm
37141 // silently no-oped on every non-Mapping shape (Null / String /
37142 // Sequence / Number / Bool). The lift's iterator surface pins
37143 // the same contract: a non-Mapping Value contributes zero
37144 // yielded entries. Pinned because both routed renderers'
37145 // "always splice `spec.*` if it's a Mapping, otherwise skip"
37146 // contract is upstream-schema-validated at the ComputeUnit CRD
37147 // parser but not at the renderer entry point — so a legally-
37148 // authored `spec: null` short-circuits without raising.
37149 for shape in [
37150 serde_yaml::Value::Null,
37151 serde_yaml::Value::String("scalar".into()),
37152 serde_yaml::Value::Sequence(vec![]),
37153 serde_yaml::Value::Number(0.into()),
37154 serde_yaml::Value::Bool(false),
37155 ] {
37156 let count = string_keyed_entries(&shape).count();
37157 assert_eq!(
37158 count, 0,
37159 "string_keyed_entries({shape:?}) must yield zero entries — \
37160 the prior `if let Value::Mapping(_)` arm silently \
37161 short-circuited on this shape, so the lift must preserve \
37162 that no-op contract or every routed renderer regresses on \
37163 the legally-authored non-Mapping `spec:` axis"
37164 );
37165 }
37166 }
37167
37168 #[test]
37169 fn string_keyed_entries_drops_non_string_keys() {
37170 // serde_yaml permits arbitrary `Value` keys — numeric, boolean,
37171 // sub-mapping — that don't round-trip through the downstream
37172 // K8s YAML-key surface (which requires string keys). Both
37173 // routed renderers previously carried an inline `if let Some(s)
37174 // = k.as_str()` filter to silently drop these; pin the lift's
37175 // filter contract so a future refactor that reaches for
37176 // `.as_str().unwrap()` (which would panic on a numeric key) is
37177 // a test-visible break, not a runtime regression at the first
37178 // ComputeUnit YAML that carries one.
37179 let mut spec = serde_yaml::Mapping::new();
37180 spec.insert(
37181 serde_yaml::Value::String(COMPUTEUNIT_SPEC_KEY_MODULE.into()),
37182 serde_yaml::Value::String("oci://…".into()),
37183 );
37184 spec.insert(
37185 serde_yaml::Value::Number(42.into()),
37186 serde_yaml::Value::String("dropped".into()),
37187 );
37188 spec.insert(
37189 serde_yaml::Value::Bool(true),
37190 serde_yaml::Value::String("also-dropped".into()),
37191 );
37192 spec.insert(
37193 serde_yaml::Value::String(COMPUTEUNIT_SPEC_KEY_TRIGGER.into()),
37194 serde_yaml::Value::String("http".into()),
37195 );
37196 let v = serde_yaml::Value::Mapping(spec);
37197 let keys: Vec<&str> = string_keyed_entries(&v).map(|(k, _)| k).collect();
37198 assert_eq!(
37199 keys,
37200 vec![COMPUTEUNIT_SPEC_KEY_MODULE, COMPUTEUNIT_SPEC_KEY_TRIGGER],
37201 "string_keyed_entries must silently drop non-string-keyed \
37202 entries (Value::Number, Value::Bool, Value::Mapping keys) \
37203 — the K8s YAML-key surface downstream requires string keys, \
37204 and every routed renderer's inline `k.as_str()` filter \
37205 expected exactly this drop-not-panic contract"
37206 );
37207 }
37208
37209 #[test]
37210 fn string_keyed_entries_matches_prior_inline_walk() {
37211 // Cross-check the helper's yielded sequence against the prior
37212 // inline `if let Value::Mapping(_) = spec { for (k, v) in _ {
37213 // if let Some(s) = k.as_str() { <collect (s, v.clone())> } } }`
37214 // walk both renderers previously carried. A drift between the
37215 // helper's yielded sequence and the inline walk would silently
37216 // emit a different destination map at every routed consumer —
37217 // pin the byte-equivalence so the helper remains a drop-in
37218 // replacement for both renderers' prior five-line block.
37219 let mut spec = serde_yaml::Mapping::new();
37220 spec.insert_str_key(
37221 COMPUTEUNIT_SPEC_KEY_MODULE,
37222 serde_yaml::Value::String("oci://ghcr.io/pleme-io/hello-rio:0.1.0".into()),
37223 );
37224 spec.insert(
37225 serde_yaml::Value::Number(1.into()),
37226 serde_yaml::Value::String("silently-dropped".into()),
37227 );
37228 spec.insert_str_key(
37229 COMPUTEUNIT_SPEC_KEY_TRIGGER,
37230 serde_yaml::Value::String("http".into()),
37231 );
37232 let v = serde_yaml::Value::Mapping(spec);
37233
37234 let via_helper: Vec<(String, serde_yaml::Value)> = string_keyed_entries(&v)
37235 .map(|(k, v)| (k.to_string(), v.clone()))
37236 .collect();
37237
37238 let mut via_inline: Vec<(String, serde_yaml::Value)> = Vec::new();
37239 if let serde_yaml::Value::Mapping(map) = &v {
37240 for (k, v) in map {
37241 if let Some(s) = k.as_str() {
37242 via_inline.push((s.to_string(), v.clone()));
37243 }
37244 }
37245 }
37246
37247 assert_eq!(
37248 via_helper, via_inline,
37249 "string_keyed_entries must yield the same (String, Value) \
37250 sequence as the prior inline `if let Value::Mapping + for + \
37251 if let Some(k.as_str())` walk — otherwise the two routed \
37252 renderers drift silently at ComputeUnit-YAML-`spec.*`-splice \
37253 time"
37254 );
37255 }
37256
37257 #[test]
37258 fn kube_metadata_str_field_reads_metadata_name_and_namespace_string_scalars() {
37259 // The lift's load-bearing contract: given a Value carrying a
37260 // top-level `metadata: { name: <str>, namespace: <str> }` block
37261 // (every K8s CR document the emit-side `kube_resource_skeleton`
37262 // renders), the helper returns Some(<str>) borrowing into the
37263 // input Value. Pinned because every routed test-side site (the
37264 // six caixa-mesh CNP filters + the caixa-flux kustomization.yaml
37265 // pin) reaches through this exact string-scalar readback, and a
37266 // drift in the borrowed-string contract would silently regress
37267 // every routed site's per-CR filter equality.
37268 let mut metadata = serde_yaml::Mapping::new();
37269 metadata.insert_str_key(
37270 KUBE_KEY_NAME,
37271 serde_yaml::Value::String("checkout-cart-to-catalog".into()),
37272 );
37273 metadata.insert_str_key(
37274 KUBE_KEY_NAMESPACE,
37275 serde_yaml::Value::String(DEFAULT_NAMESPACE.into()),
37276 );
37277 let mut cr = serde_yaml::Mapping::new();
37278 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
37279 let value = serde_yaml::Value::Mapping(cr);
37280
37281 assert_eq!(
37282 kube_metadata_str_field(&value, KUBE_KEY_NAME),
37283 Some("checkout-cart-to-catalog"),
37284 "kube_metadata_str_field must read metadata.name as a string \
37285 scalar — the six caixa-mesh CNP per-`(:de, :para)` filter \
37286 sites reach through this axis for policy-identity equality"
37287 );
37288 assert_eq!(
37289 kube_metadata_str_field(&value, KUBE_KEY_NAMESPACE),
37290 Some(DEFAULT_NAMESPACE),
37291 "kube_metadata_str_field must read metadata.namespace as a \
37292 string scalar — the caixa-flux programs_yaml_entry \
37293 production readback + the cluster_bundle kustomization.yaml \
37294 test pin both reach through this axis"
37295 );
37296 }
37297
37298 #[test]
37299 fn kube_metadata_str_field_returns_none_when_metadata_block_absent() {
37300 // Every K8s CR document the emit-side `kube_resource_skeleton`
37301 // renders carries a `metadata:` block, but the readback surface
37302 // is called on arbitrary Value inputs (upstream ComputeUnit
37303 // YAML documents, external YAML documents parsed by tests) that
37304 // may legally omit the block. The prior inline three-hop chain
37305 // silently short-circuits on the first `.get(KUBE_KEY_METADATA)`
37306 // hop when the block is absent; pin the helper's None return so
37307 // the prior no-panic contract holds. The two production-shape
37308 // paths — caixa-flux's `programs_yaml_entry` production
37309 // readback with `.unwrap_or(DEFAULT_NAMESPACE)` fallback, the
37310 // caixa-mesh test-side `.unwrap()` after equality-filter —
37311 // both depend on this None-arm for their fallback / test-harness
37312 // semantics.
37313 let value = serde_yaml::Value::Mapping(serde_yaml::Mapping::new());
37314 assert_eq!(
37315 kube_metadata_str_field(&value, KUBE_KEY_NAME),
37316 None,
37317 "kube_metadata_str_field must short-circuit to None when the \
37318 top-level `metadata:` block is absent — the prior inline \
37319 chain's `.get(KUBE_KEY_METADATA)` outer hop returned None \
37320 here, and every routed caller (production fallback + test \
37321 expect) depends on the None-arm reaching through"
37322 );
37323
37324 // Also verify the shape on a non-Mapping outer Value — the K8s
37325 // CR readback surface accepts arbitrary Value inputs, including
37326 // the Value::Null / Value::Sequence / Value::String shapes an
37327 // external YAML document may parse into.
37328 for shape in [
37329 serde_yaml::Value::Null,
37330 serde_yaml::Value::String("scalar".into()),
37331 serde_yaml::Value::Sequence(vec![]),
37332 serde_yaml::Value::Number(0.into()),
37333 serde_yaml::Value::Bool(false),
37334 ] {
37335 assert_eq!(
37336 kube_metadata_str_field(&shape, KUBE_KEY_NAME),
37337 None,
37338 "kube_metadata_str_field({shape:?}, KUBE_KEY_NAME) must \
37339 return None on non-Mapping shapes — the prior inline \
37340 `.get(KUBE_KEY_METADATA)` hop yields None on every \
37341 non-Mapping Value, and the lift must preserve that \
37342 contract"
37343 );
37344 }
37345 }
37346
37347 #[test]
37348 fn kube_metadata_str_field_returns_none_when_requested_field_absent() {
37349 // A `metadata:` block present but missing the requested axis-key
37350 // — a well-formed K8s CR that legally omits the requested field
37351 // (a Cluster-scoped CR omits `metadata.namespace`, a
37352 // Server-Side-Apply-authored CR omits `metadata.name` in favor
37353 // of `metadata.generateName`). Every routed caller expects the
37354 // three-hop chain to short-circuit through here to None; pin
37355 // the middle-hop None-arm so a future refactor that reaches for
37356 // `.get(field).unwrap()` (which would panic on a legally-omitted
37357 // axis-key) is a test-visible break.
37358 let mut metadata = serde_yaml::Mapping::new();
37359 metadata.insert_str_key(
37360 KUBE_KEY_NAME,
37361 serde_yaml::Value::String("cluster-scoped-cr".into()),
37362 );
37363 let mut cr = serde_yaml::Mapping::new();
37364 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
37365 let value = serde_yaml::Value::Mapping(cr);
37366 assert_eq!(
37367 kube_metadata_str_field(&value, KUBE_KEY_NAMESPACE),
37368 None,
37369 "kube_metadata_str_field must return None when the requested \
37370 `metadata.<field>` axis-key is absent — the prior inline \
37371 chain's middle `.and_then(|m| m.get(<FIELD>))` hop short- \
37372 circuited here, and the lift must preserve that None-arm \
37373 for every legally-omitted axis-key"
37374 );
37375 }
37376
37377 #[test]
37378 fn kube_metadata_str_field_returns_none_when_field_carries_non_string_type() {
37379 // A `metadata.<field>` axis-key present but carrying a non-
37380 // string YAML type — schema-invalid per the K8s apiserver's
37381 // OpenAPI schema but tolerated here as None so the readback
37382 // stays a total function. The prior inline chain's trailing
37383 // `.and_then(|n| n.as_str())` shape gate silently short-
37384 // circuits here; pin the helper's None-arm so a future refactor
37385 // that reaches for `.as_str().unwrap()` (which would panic on
37386 // a numeric axis-value) is a test-visible break, not a runtime
37387 // regression at the first schema-invalid CR the reader sees.
37388 for non_string in [
37389 serde_yaml::Value::Null,
37390 serde_yaml::Value::Number(42.into()),
37391 serde_yaml::Value::Bool(true),
37392 serde_yaml::Value::Sequence(vec![]),
37393 serde_yaml::Value::Mapping(serde_yaml::Mapping::new()),
37394 ] {
37395 let mut metadata = serde_yaml::Mapping::new();
37396 metadata.insert_str_key(KUBE_KEY_NAME, non_string.clone());
37397 let mut cr = serde_yaml::Mapping::new();
37398 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
37399 let value = serde_yaml::Value::Mapping(cr);
37400 assert_eq!(
37401 kube_metadata_str_field(&value, KUBE_KEY_NAME),
37402 None,
37403 "kube_metadata_str_field must return None when \
37404 metadata.name carries a non-string YAML type ({non_string:?}) \
37405 — the prior inline chain's `.and_then(|n| n.as_str())` \
37406 shape gate short-circuited here, and every routed caller \
37407 depends on that None-arm to keep the readback total"
37408 );
37409 }
37410 }
37411
37412 #[test]
37413 fn kube_metadata_str_field_matches_prior_inline_chain() {
37414 // Cross-check the helper's output byte-for-byte against the
37415 // prior inline three-hop chain both routed callers previously
37416 // carried. A drift between the helper's return and the inline
37417 // chain would silently regress every routed test-side filter's
37418 // equality comparison + the caixa-flux production readback's
37419 // fallback semantics — pin the byte-equivalence so the helper
37420 // remains a drop-in replacement for every routed site's prior
37421 // three-line block.
37422 let mut metadata = serde_yaml::Mapping::new();
37423 metadata.insert_str_key(
37424 KUBE_KEY_NAME,
37425 serde_yaml::Value::String("checkout-payment-to-cart".into()),
37426 );
37427 metadata.insert_str_key(
37428 KUBE_KEY_NAMESPACE,
37429 serde_yaml::Value::String(DEFAULT_NAMESPACE.into()),
37430 );
37431 let mut cr = serde_yaml::Mapping::new();
37432 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
37433 let value = serde_yaml::Value::Mapping(cr);
37434
37435 for field in [KUBE_KEY_NAME, KUBE_KEY_NAMESPACE] {
37436 let via_helper = kube_metadata_str_field(&value, field);
37437 let via_inline = value
37438 .get(KUBE_KEY_METADATA)
37439 .and_then(|m| m.get(field))
37440 .and_then(|n| n.as_str());
37441 assert_eq!(
37442 via_helper, via_inline,
37443 "kube_metadata_str_field(_, {field:?}) must yield the same \
37444 Option<&str> as the prior inline three-hop chain — \
37445 otherwise every routed caller's equality-filter / \
37446 production-fallback drifts silently at readback time"
37447 );
37448 }
37449 }
37450
37451 #[test]
37452 fn kube_root_str_field_reads_api_version_and_kind_string_scalars() {
37453 // The lift's load-bearing contract: given a Value carrying
37454 // top-level `apiVersion:` + `kind:` string scalars (every K8s
37455 // CR document the emit-side `kube_resource_skeleton` renders
37456 // spells the pair by construction), the helper returns
37457 // Some(<str>) borrowing into the input Value on both axes.
37458 // Pinned because every routed test-side site — the
37459 // caixa-flux `cluster_bundle_*_uses_lifted_flux_api_version`
37460 // per-document apiVersion pins + the caixa-mesh
37461 // `gateway_routes` per-`(Gateway, HTTPRoute)` kind-filter
37462 // + the sibling caixa-mesh
37463 // `cilium_authentication_mode_serialized_as_yaml_string`
37464 // CNP-kind filter — reaches through this exact top-level
37465 // string-scalar readback, and a drift in the borrowed-string
37466 // contract would silently regress every routed site's
37467 // per-CR filter / discriminator-pin equality.
37468 let mut cr = serde_yaml::Mapping::new();
37469 cr.insert_str_key(
37470 KUBE_KEY_API_VERSION,
37471 serde_yaml::Value::String(GATEWAY_API_API_VERSION.into()),
37472 );
37473 cr.insert_str_key(
37474 KUBE_KEY_KIND,
37475 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37476 );
37477 let value = serde_yaml::Value::Mapping(cr);
37478
37479 assert_eq!(
37480 kube_root_str_field(&value, KUBE_KEY_API_VERSION),
37481 Some(GATEWAY_API_API_VERSION),
37482 "kube_root_str_field must read top-level apiVersion as a \
37483 string scalar — the caixa-flux `cluster_bundle_*_uses_\
37484 lifted_flux_api_version` pins + caixa-mesh per-CR \
37485 apiVersion pins reach through this axis for discriminator \
37486 equality"
37487 );
37488 assert_eq!(
37489 kube_root_str_field(&value, KUBE_KEY_KIND),
37490 Some(GATEWAY_API_KIND_GATEWAY),
37491 "kube_root_str_field must read top-level kind as a string \
37492 scalar — the 15 caixa-mesh `gateway_routes` per-CR find \
37493 sites reach through this axis to filter the multi-doc \
37494 emission sequence by kind discriminator"
37495 );
37496 }
37497
37498 #[test]
37499 fn kube_root_str_field_returns_none_when_field_absent() {
37500 // Every K8s CR document the emit-side `kube_resource_skeleton`
37501 // renders carries `apiVersion:` + `kind:` scalars, but the
37502 // readback surface is called on arbitrary Value inputs
37503 // (multi-doc sequences under iteration, upstream ComputeUnit
37504 // YAML documents) that may legally omit either axis-key. The
37505 // prior inline two-hop chain silently short-circuits on the
37506 // outer `.get(field)` hop when the axis is absent; pin the
37507 // helper's None return so the prior no-panic contract holds.
37508 // Also verify on non-Mapping outer Value shapes an external
37509 // YAML document may parse into.
37510 let value = serde_yaml::Value::Mapping(serde_yaml::Mapping::new());
37511 assert_eq!(
37512 kube_root_str_field(&value, KUBE_KEY_API_VERSION),
37513 None,
37514 "kube_root_str_field must short-circuit to None when the \
37515 requested top-level axis-key is absent — the prior inline \
37516 `.get(field)` outer hop returned None here, and every \
37517 routed caller (test pin + filter predicate) depends on \
37518 that None-arm reaching through"
37519 );
37520 assert_eq!(
37521 kube_root_str_field(&value, KUBE_KEY_KIND),
37522 None,
37523 "kube_root_str_field must short-circuit to None on a \
37524 missing top-level kind axis-key — every routed \
37525 caixa-mesh find-predicate compares against Some(<KIND>) \
37526 and must reject None-shaped entries silently"
37527 );
37528
37529 for shape in [
37530 serde_yaml::Value::Null,
37531 serde_yaml::Value::String("scalar".into()),
37532 serde_yaml::Value::Sequence(vec![]),
37533 serde_yaml::Value::Number(0.into()),
37534 serde_yaml::Value::Bool(false),
37535 ] {
37536 assert_eq!(
37537 kube_root_str_field(&shape, KUBE_KEY_KIND),
37538 None,
37539 "kube_root_str_field({shape:?}, KUBE_KEY_KIND) must \
37540 return None on non-Mapping shapes — the prior inline \
37541 `.get(field)` hop yields None on every non-Mapping \
37542 Value, and the lift must preserve that contract"
37543 );
37544 }
37545 }
37546
37547 #[test]
37548 fn kube_root_str_field_returns_none_when_field_carries_non_string_type() {
37549 // A top-level `<field>` axis-key present but carrying a non-
37550 // string YAML type — schema-invalid per the K8s apiserver's
37551 // OpenAPI schema but tolerated here as None so the readback
37552 // stays a total function. The prior inline chain's trailing
37553 // `.and_then(|n| n.as_str())` shape gate silently short-
37554 // circuits here; pin the helper's None-arm so a future
37555 // refactor that reaches for `.as_str().unwrap()` (which would
37556 // panic on a numeric axis-value) is a test-visible break, not
37557 // a runtime regression at the first schema-invalid CR the
37558 // reader sees.
37559 for non_string in [
37560 serde_yaml::Value::Null,
37561 serde_yaml::Value::Number(42.into()),
37562 serde_yaml::Value::Bool(true),
37563 serde_yaml::Value::Sequence(vec![]),
37564 serde_yaml::Value::Mapping(serde_yaml::Mapping::new()),
37565 ] {
37566 let mut cr = serde_yaml::Mapping::new();
37567 cr.insert_str_key(KUBE_KEY_KIND, non_string.clone());
37568 let value = serde_yaml::Value::Mapping(cr);
37569 assert_eq!(
37570 kube_root_str_field(&value, KUBE_KEY_KIND),
37571 None,
37572 "kube_root_str_field must return None when top-level \
37573 kind carries a non-string YAML type ({non_string:?}) \
37574 — the prior inline `.and_then(|n| n.as_str())` shape \
37575 gate short-circuited here, and every routed caller \
37576 depends on that None-arm to keep the readback total"
37577 );
37578 }
37579 }
37580
37581 #[test]
37582 fn kube_root_str_field_matches_prior_inline_chain() {
37583 // Cross-check the helper's output byte-for-byte against the
37584 // prior inline two-hop chain both routed renderers previously
37585 // carried. A drift between the helper's return and the inline
37586 // chain would silently regress every routed test-side filter's
37587 // equality comparison + the caixa-flux production-shape
37588 // per-document apiVersion / kind pin — pin the byte-
37589 // equivalence so the helper remains a drop-in replacement for
37590 // every routed site's prior two-line block.
37591 let mut cr = serde_yaml::Mapping::new();
37592 cr.insert_str_key(
37593 KUBE_KEY_API_VERSION,
37594 serde_yaml::Value::String(FLUX_HELMRELEASE_API_VERSION.into()),
37595 );
37596 cr.insert_str_key(
37597 KUBE_KEY_KIND,
37598 serde_yaml::Value::String(FLUX_KIND_HELM_RELEASE.into()),
37599 );
37600 let value = serde_yaml::Value::Mapping(cr);
37601
37602 for field in [KUBE_KEY_API_VERSION, KUBE_KEY_KIND] {
37603 let via_helper = kube_root_str_field(&value, field);
37604 let via_inline = value.get(field).and_then(|n| n.as_str());
37605 assert_eq!(
37606 via_helper, via_inline,
37607 "kube_root_str_field(_, {field:?}) must yield the same \
37608 Option<&str> as the prior inline two-hop chain — \
37609 otherwise every routed caller's equality-filter / \
37610 discriminator-pin drifts silently at readback time"
37611 );
37612 }
37613 }
37614
37615 #[test]
37616 fn kube_root_str_field_and_kube_metadata_str_field_bracket_the_readback_surface() {
37617 // Peer-pin: the two lifted K8s-CR readback primitives cover
37618 // orthogonal axes on the same document. Given a full K8s CR
37619 // (top-level `apiVersion:` + `kind:` discriminator pair,
37620 // sub-`metadata.name:` + `metadata.namespace:` identity pair),
37621 // each helper reaches through its own axis and the two
37622 // together enumerate every documented top-level string
37623 // scalar the substrate emits + reads back. Pin the pairing so
37624 // a future refactor that collapses the two into a single
37625 // navigation primitive (or splits one further) surfaces here
37626 // as a test-visible break, not a silent regression at the
37627 // first routed caller's per-CR readback drift.
37628 let mut metadata = serde_yaml::Mapping::new();
37629 metadata.insert_str_key(
37630 KUBE_KEY_NAME,
37631 serde_yaml::Value::String("checkout-cart-to-catalog".into()),
37632 );
37633 metadata.insert_str_key(
37634 KUBE_KEY_NAMESPACE,
37635 serde_yaml::Value::String(DEFAULT_NAMESPACE.into()),
37636 );
37637 let mut cr = serde_yaml::Mapping::new();
37638 cr.insert_str_key(
37639 KUBE_KEY_API_VERSION,
37640 serde_yaml::Value::String(CILIUM_API_VERSION.into()),
37641 );
37642 cr.insert_str_key(
37643 KUBE_KEY_KIND,
37644 serde_yaml::Value::String(CILIUM_KIND_NETWORK_POLICY.into()),
37645 );
37646 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
37647 let value = serde_yaml::Value::Mapping(cr);
37648
37649 assert_eq!(
37650 kube_root_str_field(&value, KUBE_KEY_API_VERSION),
37651 Some(CILIUM_API_VERSION)
37652 );
37653 assert_eq!(
37654 kube_root_str_field(&value, KUBE_KEY_KIND),
37655 Some(CILIUM_KIND_NETWORK_POLICY)
37656 );
37657 assert_eq!(
37658 kube_metadata_str_field(&value, KUBE_KEY_NAME),
37659 Some("checkout-cart-to-catalog")
37660 );
37661 assert_eq!(
37662 kube_metadata_str_field(&value, KUBE_KEY_NAMESPACE),
37663 Some(DEFAULT_NAMESPACE)
37664 );
37665 }
37666
37667 #[test]
37668 fn kube_kind_is_matches_lifted_kube_root_str_field_equality_shape() {
37669 // Byte-equivalence pin: the lifted predicate reproduces the
37670 // three-token composition (`kube_root_str_field(v,
37671 // KUBE_KEY_KIND) == Some(<KIND>)`) the 15 caixa-mesh test-side
37672 // `.find`/`.filter` sites previously carried inline. Closes the
37673 // "did the lift accidentally rename the pinned scalar-key axis
37674 // to KUBE_KEY_API_VERSION or drop the `Some(...)` wrap" drift
37675 // class every future re-lift on the peer-axis surface (a
37676 // hypothetical `kube_api_version_is` peer, `kube_group_is` on a
37677 // multi-group router harness) would otherwise reopen.
37678 let mut cr = serde_yaml::Mapping::new();
37679 cr.insert_str_key(
37680 KUBE_KEY_KIND,
37681 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37682 );
37683 let value = serde_yaml::Value::Mapping(cr);
37684
37685 assert!(kube_kind_is(&value, GATEWAY_API_KIND_GATEWAY));
37686 assert_eq!(
37687 kube_kind_is(&value, GATEWAY_API_KIND_GATEWAY),
37688 kube_root_str_field(&value, KUBE_KEY_KIND) == Some(GATEWAY_API_KIND_GATEWAY),
37689 );
37690 }
37691
37692 #[test]
37693 fn kube_kind_is_false_on_mismatched_kind_and_missing_kind() {
37694 // Complement-side pin: the predicate returns `false` when
37695 // either the kind axis carries a different discriminator or the
37696 // top-level `kind:` scalar is absent altogether (the same
37697 // vacuous-`None` short-circuit the parent
37698 // `kube_root_str_field` closes on the underlying two-hop
37699 // navigation). Consumer sites (`docs.iter().find(|d|
37700 // kube_kind_is(d, X))`) rely on the false-on-mismatch shape to
37701 // skip the wrong CRs across the multi-doc mesh emission and
37702 // land on the intended per-kind document.
37703 let mut cr_wrong_kind = serde_yaml::Mapping::new();
37704 cr_wrong_kind.insert_str_key(
37705 KUBE_KEY_KIND,
37706 serde_yaml::Value::String(GATEWAY_API_KIND_HTTP_ROUTE.into()),
37707 );
37708 assert!(!kube_kind_is(
37709 &serde_yaml::Value::Mapping(cr_wrong_kind),
37710 GATEWAY_API_KIND_GATEWAY,
37711 ));
37712
37713 let cr_no_kind = serde_yaml::Mapping::new();
37714 assert!(!kube_kind_is(
37715 &serde_yaml::Value::Mapping(cr_no_kind),
37716 GATEWAY_API_KIND_GATEWAY,
37717 ));
37718 }
37719
37720 #[test]
37721 fn find_by_kind_matches_inline_iter_find_kube_kind_is_shape() {
37722 // Byte-equivalence pin: the lifted navigator reproduces the
37723 // three-token combinator chain (`docs.iter().find(|d|
37724 // kube_kind_is(d, <KIND>))`) the 14 caixa-mesh test-side
37725 // per-Gateway / per-HTTPRoute find-by-kind sites previously
37726 // carried inline. Closes the "did the lift accidentally
37727 // widen the receiver, drop the closure, or swap `find` for
37728 // `filter`" drift class every future re-lift on the sibling
37729 // multi-doc-navigator axis (a hypothetical
37730 // `filter_by_kind` peer that carries the same underlying
37731 // predicate but returns an iterator) would otherwise reopen.
37732 let mut gateway = serde_yaml::Mapping::new();
37733 gateway.insert_str_key(
37734 KUBE_KEY_KIND,
37735 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37736 );
37737 let mut route = serde_yaml::Mapping::new();
37738 route.insert_str_key(
37739 KUBE_KEY_KIND,
37740 serde_yaml::Value::String(GATEWAY_API_KIND_HTTP_ROUTE.into()),
37741 );
37742 let docs = vec![
37743 serde_yaml::Value::Mapping(gateway),
37744 serde_yaml::Value::Mapping(route),
37745 ];
37746
37747 // Lifted navigator agrees with the inline combinator chain
37748 // on every existing member of the multi-doc slice.
37749 assert_eq!(
37750 find_by_kind(&docs, GATEWAY_API_KIND_GATEWAY),
37751 docs.iter()
37752 .find(|d| kube_kind_is(d, GATEWAY_API_KIND_GATEWAY)),
37753 );
37754 assert_eq!(
37755 find_by_kind(&docs, GATEWAY_API_KIND_HTTP_ROUTE),
37756 docs.iter()
37757 .find(|d| kube_kind_is(d, GATEWAY_API_KIND_HTTP_ROUTE)),
37758 );
37759
37760 // And on the miss path: absent kind → None, matching the
37761 // inline `.find` short-circuit that consumer sites rely on
37762 // to distinguish "no such CR in this emission" from "wrong
37763 // shape" in their `.unwrap()` / `.expect(...)` follow-ups.
37764 assert_eq!(find_by_kind(&docs, CILIUM_KIND_NETWORK_POLICY), None);
37765 let empty: Vec<serde_yaml::Value> = Vec::new();
37766 assert_eq!(find_by_kind(&empty, GATEWAY_API_KIND_GATEWAY), None);
37767 }
37768
37769 #[test]
37770 fn find_by_kind_returns_first_match_on_duplicate_kind() {
37771 // Order-preservation pin: the lifted navigator returns the
37772 // first document of the matching kind (the same short-
37773 // circuit `Iterator::find` exposes). Multi-doc mesh
37774 // emissions never carry two documents of the same kind at
37775 // V0 (`gateway_routes` emits exactly one `Gateway` + one
37776 // `HTTPRoute` per Aplicacao), but the M4 cross-cluster
37777 // fan-out will (one `HelmRelease` per cluster). Pinning the
37778 // first-match contract keeps the M4 caller-side "the first
37779 // hit is the primary" convention aligned with the helper's
37780 // combinator half.
37781 let mut gateway_a = serde_yaml::Mapping::new();
37782 gateway_a.insert_str_key(
37783 KUBE_KEY_KIND,
37784 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37785 );
37786 let mut meta_a = serde_yaml::Mapping::new();
37787 meta_a.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("primary".into()));
37788 gateway_a.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(meta_a));
37789 let mut gateway_b = serde_yaml::Mapping::new();
37790 gateway_b.insert_str_key(
37791 KUBE_KEY_KIND,
37792 serde_yaml::Value::String(GATEWAY_API_KIND_GATEWAY.into()),
37793 );
37794 let mut meta_b = serde_yaml::Mapping::new();
37795 meta_b.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::String("secondary".into()));
37796 gateway_b.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(meta_b));
37797 let docs = vec![
37798 serde_yaml::Value::Mapping(gateway_a),
37799 serde_yaml::Value::Mapping(gateway_b),
37800 ];
37801
37802 let first = find_by_kind(&docs, GATEWAY_API_KIND_GATEWAY).unwrap();
37803 assert_eq!(
37804 kube_metadata_str_field(first, KUBE_KEY_NAME),
37805 Some("primary"),
37806 );
37807 }
37808
37809 #[test]
37810 fn kube_name_matches_lifted_kube_metadata_str_field_readback_shape() {
37811 // Byte-equivalence pin: the lifted accessor reproduces the
37812 // two-token composition (`kube_metadata_str_field(v,
37813 // KUBE_KEY_NAME)`) the 12 caixa-mesh (9) + caixa-flux (3)
37814 // test-side per-CR readback sites previously carried inline
37815 // around the readback intent "what name did the emitter write
37816 // into this CR?". Closes the "did the lift accidentally
37817 // rename the pinned scalar-key axis to KUBE_KEY_NAMESPACE
37818 // (silently pulling the peer identity coordinate instead of
37819 // the primary), drop the axis-key argument, or widen the
37820 // return type" drift class every future re-lift on the peer-
37821 // axis surface (a hypothetical `kube_namespace` peer on the
37822 // per-CR namespace-scoping coordinate, a `kube_uid` peer for
37823 // ownerReference bookkeeping) would otherwise reopen. Peer of
37824 // the sibling `kube_name_is_matches_lifted_kube_metadata_str_field_equality_shape`
37825 // pin on the predicate-arity half of the same axis: the
37826 // accessor pin asserts the readback intent, the predicate pin
37827 // asserts the equality-wrap intent, together bracketing the
37828 // two-arity closure the identity axis carries at V0.
37829 let mut metadata = serde_yaml::Mapping::new();
37830 metadata.insert_str_key(
37831 KUBE_KEY_NAME,
37832 serde_yaml::Value::String("checkout-cart-to-catalog".into()),
37833 );
37834 let mut cr = serde_yaml::Mapping::new();
37835 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
37836 let value = serde_yaml::Value::Mapping(cr);
37837
37838 assert_eq!(kube_name(&value), Some("checkout-cart-to-catalog"));
37839 assert_eq!(
37840 kube_name(&value),
37841 kube_metadata_str_field(&value, KUBE_KEY_NAME),
37842 "kube_name must byte-agree with the parametric \
37843 `kube_metadata_str_field(v, KUBE_KEY_NAME)` composition \
37844 it replaces at every consumer site — drift on either \
37845 half silently opens a per-CR identity readback that no \
37846 longer routes through the pinned KUBE_KEY_NAME axis-key",
37847 );
37848 }
37849
37850 #[test]
37851 fn kube_name_none_when_metadata_block_absent_or_name_absent() {
37852 // Complement-side pin: the accessor returns `None` when
37853 // either the enclosing `metadata:` block is absent (root-
37854 // level CR with no metadata mapping at all — the vacuous
37855 // shape the operator-side "not-yet-materialized" CR readback
37856 // might momentarily observe under a partial apply) or the
37857 // sub-`name:` scalar is absent inside a present `metadata:`
37858 // block (a partially-authored CR the K8s API-server would
37859 // reject at admission but that this readback tolerates as
37860 // `None` so the accessor stays a total function). Consumer
37861 // sites (`.expect(...)`, `.unwrap()`, `Some(...) == expected`
37862 // equality wraps) rely on the None-on-absence short-circuit
37863 // to distinguish "no such name on this doc" from "wrong
37864 // shape" in the follow-up. Peer of the sibling
37865 // `kube_name_is_false_on_mismatched_name_and_missing_name`
37866 // pin on the predicate-arity half — the accessor short-
37867 // circuits to `None`, the predicate short-circuits through it
37868 // to `false` — same underlying vacuous-`None` gate.
37869 let cr_no_metadata = serde_yaml::Mapping::new();
37870 assert_eq!(
37871 kube_name(&serde_yaml::Value::Mapping(cr_no_metadata)),
37872 None,
37873 "kube_name must return None when the enclosing metadata: \
37874 block is absent",
37875 );
37876
37877 let empty_meta = serde_yaml::Mapping::new();
37878 let mut cr_no_name = serde_yaml::Mapping::new();
37879 cr_no_name.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(empty_meta));
37880 assert_eq!(
37881 kube_name(&serde_yaml::Value::Mapping(cr_no_name)),
37882 None,
37883 "kube_name must return None when the sub-name: scalar is \
37884 absent inside a present metadata: block",
37885 );
37886 }
37887
37888 #[test]
37889 fn kube_name_none_when_metadata_name_carries_non_string_type() {
37890 // Type-gate pin: the accessor returns `None` when the sub-
37891 // `metadata.name:` scalar is present but carries a non-string
37892 // YAML type (a numeric, boolean, or nested mapping — invalid
37893 // K8s CR shape per the K8s API-machinery OpenAPI schema, but
37894 // tolerated here as `None` so the readback stays a total
37895 // function and defers the diagnostic to the caller's own
37896 // `.expect(...)` / `.unwrap()` follow-up which names the
37897 // caller's schema axis). Pins the type-gate half of the
37898 // accessor's contract — the axis-key pin is asserted by the
37899 // sibling byte-agreement test — so a hypothetical future
37900 // widening (accepting numeric `metadata.name: 42` as the
37901 // stringified `"42"`, an aliased YAML integer under a fresh
37902 // `Value::from` conversion) is caught before it lands.
37903 let mut metadata_int = serde_yaml::Mapping::new();
37904 metadata_int.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::from(42u64));
37905 let mut cr_int = serde_yaml::Mapping::new();
37906 cr_int.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata_int));
37907 assert_eq!(
37908 kube_name(&serde_yaml::Value::Mapping(cr_int)),
37909 None,
37910 "kube_name must return None when metadata.name carries a \
37911 non-string YAML type (numeric here)",
37912 );
37913
37914 let mut inner = serde_yaml::Mapping::new();
37915 inner.insert_str_key("nested", serde_yaml::Value::String("value".into()));
37916 let mut metadata_map = serde_yaml::Mapping::new();
37917 metadata_map.insert_str_key(KUBE_KEY_NAME, serde_yaml::Value::Mapping(inner));
37918 let mut cr_map = serde_yaml::Mapping::new();
37919 cr_map.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata_map));
37920 assert_eq!(
37921 kube_name(&serde_yaml::Value::Mapping(cr_map)),
37922 None,
37923 "kube_name must return None when metadata.name carries a \
37924 nested mapping (invalid CR shape per K8s API-machinery)",
37925 );
37926 }
37927
37928 #[test]
37929 fn kube_name_is_composes_on_lifted_kube_name_accessor() {
37930 // Composition pin: after the accessor lift, the peer
37931 // predicate `kube_name_is(v, n)` must resolve exactly as
37932 // `kube_name(v) == Some(n)` — i.e. the predicate no longer
37933 // carries an inline `kube_metadata_str_field(v,
37934 // KUBE_KEY_NAME) == Some(n)` composition but composes on the
37935 // sibling accessor. Pins the structural link between the
37936 // three-arity closure (accessor / predicate / navigator) on
37937 // the identity axis: a future re-implementation of `kube_name`
37938 // (e.g. a caching short-circuit for repeated readback on the
37939 // same document, a hypothetical alias-table dispatch on a
37940 // `metadata.identity` sub-axis) reaches the predicate through
37941 // one lift, not a second co-ordinated inline rewrite. Peer of
37942 // the sibling `find_by_name_matches_inline_iter_find_kube_name_is_shape`
37943 // pin on the navigator arity — the navigator composes on the
37944 // predicate, the predicate composes on the accessor.
37945 let mut metadata = serde_yaml::Mapping::new();
37946 metadata.insert_str_key(
37947 KUBE_KEY_NAME,
37948 serde_yaml::Value::String("checkout-cart-to-payment".into()),
37949 );
37950 let mut cr = serde_yaml::Mapping::new();
37951 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
37952 let value = serde_yaml::Value::Mapping(cr);
37953
37954 assert_eq!(
37955 kube_name_is(&value, "checkout-cart-to-payment"),
37956 kube_name(&value) == Some("checkout-cart-to-payment"),
37957 "kube_name_is must byte-agree with the peer \
37958 `kube_name(v) == Some(n)` composition it now delegates \
37959 to — the predicate carries no more inline navigation, \
37960 only the equality-wrap semantic distinct from the \
37961 sibling accessor arity",
37962 );
37963 assert!(kube_name_is(&value, "checkout-cart-to-payment"));
37964 assert!(!kube_name_is(&value, "checkout-cart-to-catalog"));
37965 }
37966
37967 #[test]
37968 fn kube_name_is_matches_lifted_kube_metadata_str_field_equality_shape() {
37969 // Byte-equivalence pin: the lifted predicate reproduces the
37970 // three-token composition (`kube_metadata_str_field(v,
37971 // KUBE_KEY_NAME) == Some(<NAME>)`) the 6 caixa-mesh test-side
37972 // `.find`/`.filter` sites previously carried inline. Closes the
37973 // "did the lift accidentally rename the pinned scalar-key axis
37974 // to KUBE_KEY_NAMESPACE or drop the `Some(...)` wrap" drift
37975 // class every future re-lift on the peer-axis surface (a
37976 // hypothetical `kube_namespace_is` peer on a per-namespace
37977 // router harness, a `kube_uid_is` for ownerReference
37978 // bookkeeping) would otherwise reopen. Peer of the sibling
37979 // `kube_kind_is_matches_lifted_kube_root_str_field_equality_shape`
37980 // pin on the `kind:` discriminator axis.
37981 let mut metadata = serde_yaml::Mapping::new();
37982 metadata.insert_str_key(
37983 KUBE_KEY_NAME,
37984 serde_yaml::Value::String("checkout-cart-to-catalog".into()),
37985 );
37986 let mut cr = serde_yaml::Mapping::new();
37987 cr.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(metadata));
37988 let value = serde_yaml::Value::Mapping(cr);
37989
37990 assert!(kube_name_is(&value, "checkout-cart-to-catalog"));
37991 assert_eq!(
37992 kube_name_is(&value, "checkout-cart-to-catalog"),
37993 kube_metadata_str_field(&value, KUBE_KEY_NAME) == Some("checkout-cart-to-catalog"),
37994 );
37995 }
37996
37997 #[test]
37998 fn kube_name_is_false_on_mismatched_name_and_missing_name() {
37999 // Complement-side pin: the predicate returns `false` when
38000 // either the name axis carries a different identity or the
38001 // sub-`metadata.name:` scalar (or the enclosing `metadata:`
38002 // block) is absent altogether (the same vacuous-`None`
38003 // short-circuit the parent `kube_metadata_str_field` closes on
38004 // the underlying two-hop navigation). Consumer sites
38005 // (`docs.iter().find(|d| kube_name_is(d, X))`) rely on the
38006 // false-on-mismatch shape to skip the wrong CRs across the
38007 // multi-doc mesh emission and land on the intended per-name
38008 // document. Peer of the sibling
38009 // `kube_kind_is_false_on_mismatched_kind_and_missing_kind` pin
38010 // on the `kind:` discriminator axis.
38011 let mut wrong_meta = serde_yaml::Mapping::new();
38012 wrong_meta.insert_str_key(
38013 KUBE_KEY_NAME,
38014 serde_yaml::Value::String("checkout-payment-to-cart".into()),
38015 );
38016 let mut cr_wrong_name = serde_yaml::Mapping::new();
38017 cr_wrong_name.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(wrong_meta));
38018 assert!(!kube_name_is(
38019 &serde_yaml::Value::Mapping(cr_wrong_name),
38020 "checkout-cart-to-catalog",
38021 ));
38022
38023 let cr_no_metadata = serde_yaml::Mapping::new();
38024 assert!(!kube_name_is(
38025 &serde_yaml::Value::Mapping(cr_no_metadata),
38026 "checkout-cart-to-catalog",
38027 ));
38028
38029 let empty_meta = serde_yaml::Mapping::new();
38030 let mut cr_no_name = serde_yaml::Mapping::new();
38031 cr_no_name.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(empty_meta));
38032 assert!(!kube_name_is(
38033 &serde_yaml::Value::Mapping(cr_no_name),
38034 "checkout-cart-to-catalog",
38035 ));
38036 }
38037
38038 #[test]
38039 fn find_by_name_matches_inline_iter_find_kube_name_is_shape() {
38040 // Byte-equivalence pin: the lifted navigator reproduces the
38041 // three-token combinator chain (`docs.iter().find(|d|
38042 // kube_name_is(d, <NAME>))`) the 5 caixa-mesh test-side
38043 // per-CNP-name find-by-name sites previously carried inline.
38044 // Closes the "did the lift accidentally widen the receiver,
38045 // drop the closure, or swap `find` for `filter`" drift class
38046 // every future re-lift on the sibling multi-doc-navigator axis
38047 // (a hypothetical `filter_by_name` peer that carries the same
38048 // underlying predicate but returns an iterator) would otherwise
38049 // reopen. Peer of the sibling
38050 // `find_by_kind_matches_inline_iter_find_kube_kind_is_shape`
38051 // pin on the `kind:` discriminator axis.
38052 let mut meta_a = serde_yaml::Mapping::new();
38053 meta_a.insert_str_key(
38054 KUBE_KEY_NAME,
38055 serde_yaml::Value::String("checkout-cart-to-catalog".into()),
38056 );
38057 let mut policy_a = serde_yaml::Mapping::new();
38058 policy_a.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(meta_a));
38059 let mut meta_b = serde_yaml::Mapping::new();
38060 meta_b.insert_str_key(
38061 KUBE_KEY_NAME,
38062 serde_yaml::Value::String("checkout-payment-to-cart".into()),
38063 );
38064 let mut policy_b = serde_yaml::Mapping::new();
38065 policy_b.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(meta_b));
38066 let docs = vec![
38067 serde_yaml::Value::Mapping(policy_a),
38068 serde_yaml::Value::Mapping(policy_b),
38069 ];
38070
38071 assert_eq!(
38072 find_by_name(&docs, "checkout-cart-to-catalog"),
38073 docs.iter()
38074 .find(|d| kube_name_is(d, "checkout-cart-to-catalog")),
38075 );
38076 assert_eq!(
38077 find_by_name(&docs, "checkout-payment-to-cart"),
38078 docs.iter()
38079 .find(|d| kube_name_is(d, "checkout-payment-to-cart")),
38080 );
38081
38082 // Miss path: absent name → None, matching the inline `.find`
38083 // short-circuit that consumer sites rely on to distinguish
38084 // "no such CR in this emission" from "wrong shape" in their
38085 // `.unwrap()` / `.expect(...)` follow-ups.
38086 assert_eq!(find_by_name(&docs, "checkout-cart-to-payment"), None);
38087 let empty: Vec<serde_yaml::Value> = Vec::new();
38088 assert_eq!(find_by_name(&empty, "checkout-cart-to-catalog"), None);
38089 }
38090
38091 #[test]
38092 fn find_by_name_returns_first_match_on_duplicate_name() {
38093 // Order-preservation pin: the lifted navigator returns the
38094 // first document of the matching name (the same short-circuit
38095 // `Iterator::find` exposes). Multi-doc mesh emissions never
38096 // carry two documents with identical `metadata.name` at V0
38097 // (`cilium_network_policies` fans distinct `(:de, :para)`
38098 // pairs into distinct CNP names — see the sibling
38099 // `cilium_http_contracts_fan_multiple_edges_into_one_policy`
38100 // fan-in pin), but the M4 cross-cluster fan-out will produce
38101 // per-cluster CR duplicates on the identity axis (one
38102 // `HelmRelease` per cluster carrying the same base name). Pin
38103 // the first-match contract keeps the M4 caller-side "the
38104 // first hit is the primary" convention aligned with the
38105 // helper's combinator half. Peer of the sibling
38106 // `find_by_kind_returns_first_match_on_duplicate_kind` pin on
38107 // the `kind:` discriminator axis.
38108 let mut meta_a = serde_yaml::Mapping::new();
38109 meta_a.insert_str_key(
38110 KUBE_KEY_NAME,
38111 serde_yaml::Value::String("checkout-cart-to-catalog".into()),
38112 );
38113 meta_a.insert_str_key(
38114 KUBE_KEY_NAMESPACE,
38115 serde_yaml::Value::String("cluster-a".into()),
38116 );
38117 let mut policy_a = serde_yaml::Mapping::new();
38118 policy_a.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(meta_a));
38119 let mut meta_b = serde_yaml::Mapping::new();
38120 meta_b.insert_str_key(
38121 KUBE_KEY_NAME,
38122 serde_yaml::Value::String("checkout-cart-to-catalog".into()),
38123 );
38124 meta_b.insert_str_key(
38125 KUBE_KEY_NAMESPACE,
38126 serde_yaml::Value::String("cluster-b".into()),
38127 );
38128 let mut policy_b = serde_yaml::Mapping::new();
38129 policy_b.insert_str_key(KUBE_KEY_METADATA, serde_yaml::Value::Mapping(meta_b));
38130 let docs = vec![
38131 serde_yaml::Value::Mapping(policy_a),
38132 serde_yaml::Value::Mapping(policy_b),
38133 ];
38134
38135 let first = find_by_name(&docs, "checkout-cart-to-catalog").unwrap();
38136 assert_eq!(
38137 kube_metadata_str_field(first, KUBE_KEY_NAMESPACE),
38138 Some("cluster-a"),
38139 );
38140 }
38141
38142 // ── contrato-edge-label + cilium-network-policy-name lifts ──────────
38143
38144 #[test]
38145 fn contrato_edge_label_separator_pin() {
38146 // Load-bearing byte-string pin: the M3 `:contratos`
38147 // edge-direction separator every caixa-mesh emitter that
38148 // encodes a typed edge as a K8s-name-shaped scalar reads from.
38149 // Any future rebrand (e.g. `-to-` → `_to_`) lands here as a
38150 // one-const edit; the peer `contrato_edge_label` /
38151 // `cilium_network_policy_name` composers pick up the new
38152 // encoding by construction. A drift on this const would silently
38153 // split the CNP `metadata.name` from its own
38154 // `metadata.labels.pleme.pleme.io/contrato` value, orphaning
38155 // every operator-side grep-by-label query far from the source
38156 // caixa.lisp.
38157 assert_eq!(CONTRATO_EDGE_LABEL_SEPARATOR, "-to-");
38158 }
38159
38160 #[test]
38161 fn contrato_edge_label_matches_inline_de_to_para_encoding() {
38162 // Byte-shape pin: the composer produces the same
38163 // `format!("{de}-to-{para}")` byte-string every caixa-mesh
38164 // per-`(:de, :para)` `CiliumNetworkPolicy` emitter previously
38165 // inlined at its `labels.insert(LABEL_CONTRATO, …)` call. So a
38166 // future rewire of the composer's internals (multi-hop typed
38167 // edges once the M4 per-edge WIT registry lands, unicode
38168 // arrow-shape rebrand for operator display) reaches every
38169 // consumer through one canonical function-pointer edit.
38170 assert_eq!(contrato_edge_label("cart", "catalog"), "cart-to-catalog");
38171 assert_eq!(contrato_edge_label("cart", "payment"), "cart-to-payment");
38172 }
38173
38174 #[test]
38175 fn contrato_edge_label_threads_separator_between_de_and_para() {
38176 // Composition pin: the composer's shape is
38177 // `de + CONTRATO_EDGE_LABEL_SEPARATOR + para`, so a future
38178 // separator rebrand at [`CONTRATO_EDGE_LABEL_SEPARATOR`]
38179 // reaches the composer through one const-edit and every
38180 // consumer picks up the new encoding by construction. Pin the
38181 // structural equation (not just the byte value) so a future
38182 // reorder of the composer's `format!` argument list (a
38183 // `format!("{para}-{sep}-{de}")` typo mid-refactor) fires here
38184 // rather than silently emitting reversed-direction CNP labels.
38185 let de = "svc-a";
38186 let para = "svc-b";
38187 assert_eq!(
38188 contrato_edge_label(de, para),
38189 format!("{de}{CONTRATO_EDGE_LABEL_SEPARATOR}{para}"),
38190 );
38191 }
38192
38193 #[test]
38194 fn cilium_network_policy_name_matches_inline_aplicacao_de_to_para_encoding() {
38195 // Byte-shape pin: the composer produces the same
38196 // `format!("{aplicacao}-{de}-to-{para}")` byte-string every
38197 // caixa-mesh `cilium_network_policies` per-`(:de, :para)`
38198 // group's `kube_resource_skeleton` `name:` argument previously
38199 // inlined. So a future rewire of the composer's internals
38200 // reaches the CNP renderer through one canonical function-
38201 // pointer edit rather than a coordinated two-site rewrite of
38202 // the [`LABEL_CONTRATO`] labels.insert(...) call and the CNP
38203 // name argument.
38204 assert_eq!(
38205 cilium_network_policy_name("checkout", "cart", "catalog"),
38206 "checkout-cart-to-catalog",
38207 );
38208 assert_eq!(
38209 cilium_network_policy_name("checkout", "cart", "payment"),
38210 "checkout-cart-to-payment",
38211 );
38212 }
38213
38214 #[test]
38215 fn cilium_network_policy_name_composes_on_contrato_edge_label() {
38216 // Composition pin: the CNP name is the parent Aplicacao's
38217 // `:nome` joined to the contrato-edge-label by a canonical `-`
38218 // separator (`format!("{aplicacao}-{edge}")`), so the two
38219 // writer-side helpers close the canonical
38220 // `(LABEL_CONTRATO-value, metadata.name)` per-CNP identity
38221 // pair on one shared edge-encoding source of truth
38222 // ([`CONTRATO_EDGE_LABEL_SEPARATOR`]). Pin the structural
38223 // equation so a future refactor of either composer's internals
38224 // that accidentally desynchronizes the two (a CNP-name
38225 // rebrand landing on `format!("{aplicacao}_{edge}")` while
38226 // the label-value composer stays on `{de}-to-{para}`, or a
38227 // label-composer rebrand landing on `->` while the CNP-name
38228 // composer stays on `-to-`) fires here rather than silently
38229 // orphaning every operator-side grep-by-label query at apply
38230 // time.
38231 let aplicacao = "checkout";
38232 let de = "cart";
38233 let para = "catalog";
38234 let edge = contrato_edge_label(de, para);
38235 assert_eq!(
38236 cilium_network_policy_name(aplicacao, de, para),
38237 format!("{aplicacao}-{edge}"),
38238 );
38239 }
38240
38241 // ── gateway-api-http-route-name lift ────────────────────────────────
38242
38243 #[test]
38244 fn gateway_api_http_route_name_matches_inline_aplicacao_para_encoding() {
38245 // Byte-shape pin: the composer produces the same
38246 // `format!("{aplicacao}-{para}")` byte-string the caixa-mesh
38247 // `gateway_routes` per-`:entrada` `kube_resource_skeleton`
38248 // `name:` argument previously inlined as
38249 // `format!("{}-{}", caixa.nome, entrada.para)`. So a future
38250 // rewire of the composer's internals reaches the HTTPRoute
38251 // renderer through one canonical function-pointer edit rather
38252 // than a hand-agreement between the emitter and every
38253 // test-side probe pinning the expected `<aplicacao>-<para>`
38254 // byte-shape at the HTTPRoute `metadata.name` axis.
38255 assert_eq!(
38256 gateway_api_http_route_name("checkout", "cart"),
38257 "checkout-cart",
38258 );
38259 assert_eq!(gateway_api_http_route_name("orders", "cart"), "orders-cart",);
38260 }
38261
38262 #[test]
38263 fn rendered_file_carries_path_and_contents_fields() {
38264 // Field-shape pin: the canonical [`RenderedFile`] every
38265 // per-target `caixa-<target>` renderer's per-artifact leaf
38266 // resolves through carries exactly the `(path, contents)` pair
38267 // the prior per-crate `BundleFile { path: PathBuf, contents:
38268 // String }` (`caixa-flux`) / `ChartFile { path: PathBuf,
38269 // contents: String }` (`caixa-helm`) clones each carried
38270 // verbatim. A future refactor that adds a per-artifact
38271 // hash / provenance / write-mode discriminator on the record
38272 // must land at the canonical struct definition (this file) —
38273 // the two type aliases at `caixa-flux::BundleFile` /
38274 // `caixa-helm::ChartFile` re-export the canonical unchanged, so
38275 // an addition here reaches both per-target renderers at once,
38276 // and a struct-literal drift that inlines the pre-lift shape
38277 // at either alias trips this pin at caixa-core build time
38278 // rather than surfacing as a divergent per-target renderer's
38279 // record shape far from the source.
38280 let f = RenderedFile {
38281 path: PathBuf::from("Chart.yaml"),
38282 contents: "apiVersion: v2\n".to_string(),
38283 };
38284 assert_eq!(f.path, PathBuf::from("Chart.yaml"));
38285 assert_eq!(f.contents, "apiVersion: v2\n");
38286 }
38287
38288 #[test]
38289 fn rendered_file_derives_pattern_pin() {
38290 // Derive-shape pin: the canonical [`RenderedFile`] carries the
38291 // `Debug + Clone + PartialEq + Eq` derive tuple the two per-
38292 // renderer clones (`caixa-flux::BundleFile` /
38293 // `caixa-helm::ChartFile`) each carried verbatim before the
38294 // lift. `Clone::clone` returns a byte-equal record + the
38295 // `PartialEq::eq` impl returns `true` on the round-trip; a
38296 // future refactor that drops one of the four derives (say,
38297 // removes `PartialEq` on a per-artifact-hash addition) trips
38298 // this pin at caixa-core build time and surfaces the
38299 // per-alias downstream `assert_eq!(bundle_file_a,
38300 // bundle_file_b)` / `assert_eq!(chart_file_a, chart_file_b)`
38301 // navigators in `caixa-flux` / `caixa-helm` — every
38302 // per-alias derive-fed navigator threads through this
38303 // canonical derive tuple by construction.
38304 let f = RenderedFile {
38305 path: PathBuf::from("values.yaml"),
38306 contents: "pleme-computeunit:\n enabled: false\n".to_string(),
38307 };
38308 let clone = f.clone();
38309 assert_eq!(f, clone);
38310 let dbg = format!("{f:?}");
38311 assert!(
38312 dbg.contains("RenderedFile"),
38313 "Debug output must name the canonical type, got: {dbg:?}",
38314 );
38315 }
38316
38317 #[test]
38318 fn rendered_file_new_matches_struct_literal_shape() {
38319 // Constructor pin: [`RenderedFile::new(FILENAME, contents)`]
38320 // (the canonical lifted `impl Into<PathBuf>` / `impl Into<String>`
38321 // inherent constructor every per-target renderer's per-artifact
38322 // leaf now routes through) produces the byte-identical record
38323 // the six prior inline struct-literal call sites (three
38324 // per-artifact leaves in
38325 // [`caixa_helm::render_chart_for_servico_with`],
38326 // three per-CR leaves in [`caixa_flux::cluster_bundle`]) each
38327 // open-coded as `<Xxx>File { path: PathBuf::from(FILENAME_CONST),
38328 // contents: <body> }`. Pin the equation on a
38329 // `HELM_VALUES_YAML_FILENAME`-shaped input so a future rebrand
38330 // of the constructor's internals (a per-artifact hash /
38331 // provenance field addition, an
38332 // [`is_sandboxed_relative_path`] check at construction time
38333 // once per-cluster-writer sandboxing lands) fires here rather
38334 // than silently splitting the per-target renderer's per-CR
38335 // record shape from the substrate-canonical `(path, contents)`
38336 // pair at the caixa-core canonical.
38337 let via_new = RenderedFile::new(HELM_VALUES_YAML_FILENAME, "pleme-computeunit:\n");
38338 let via_literal = RenderedFile {
38339 path: PathBuf::from(HELM_VALUES_YAML_FILENAME),
38340 contents: "pleme-computeunit:\n".to_string(),
38341 };
38342 assert_eq!(via_new, via_literal);
38343 // Peer path-side pin: `impl Into<PathBuf>` accepts a `PathBuf`
38344 // directly (the future per-target renderer surface where the
38345 // path is composed from author input rather than picked from a
38346 // substrate-canonical `&'static str` filename constant) —
38347 // exercised so a drift onto a stricter `&str`-only bound
38348 // trips this pin at caixa-core build time rather than at the
38349 // first per-target renderer that reaches for the wider bound.
38350 let via_new_from_pathbuf = RenderedFile::new(
38351 PathBuf::from(FLUX_HELMRELEASE_YAML_FILENAME),
38352 String::from("kind: HelmRelease\n"),
38353 );
38354 assert_eq!(
38355 via_new_from_pathbuf.path,
38356 PathBuf::from(FLUX_HELMRELEASE_YAML_FILENAME),
38357 );
38358 assert_eq!(via_new_from_pathbuf.contents, "kind: HelmRelease\n");
38359 }
38360
38361 #[test]
38362 fn gateway_api_http_route_name_composes_on_canonical_dash_separator() {
38363 // Composition pin: the HTTPRoute `metadata.name` is the parent
38364 // Aplicacao's `:nome` joined to the `:entrada :para`
38365 // destination Servico's `:nome` by a canonical `-` separator
38366 // (`format!("{aplicacao}-{para}")`) — the same
38367 // "aplicacao-prefixed sub-identity" discipline the peer
38368 // [`cilium_network_policy_name`] composer materializes on the
38369 // sibling per-CR K8s-name-shaped-identity-scalar axis
38370 // ([`format!("{aplicacao}-{edge}")`]). Pin the structural
38371 // equation so a future refactor of either composer's internals
38372 // that accidentally desynchronizes the two (an HTTPRoute-name
38373 // rebrand landing on `format!("{aplicacao}.{para}")` while
38374 // the CNP-name composer stays on `{aplicacao}-{edge}`, or a
38375 // per-Aplicacao-K8s-CR-name shared-separator rebrand landing
38376 // on the CNP-name composer without a coordinated edit here)
38377 // fires here rather than silently splitting the two per-CR
38378 // name-encoding axes across the caixa-mesh renderer.
38379 let aplicacao = "checkout";
38380 let para = "cart";
38381 assert_eq!(
38382 gateway_api_http_route_name(aplicacao, para),
38383 format!("{aplicacao}-{para}"),
38384 );
38385 }
38386}