caixa_core/dialeto.rs
1//! `defcaixa` is spoken by two unrelated declarations. This module makes that
2//! a **typed fact** instead of an anonymous parse failure.
3//!
4//! # The finding
5//!
6//! Measured 2026-07-31 over the pleme-io org checkout (270 `caixa.lisp` /
7//! `*.caixa.lisp` files found with `rg --no-ignore`; a bare `rg` from the org
8//! root returns 0, which is how this stayed invisible), the corpus splits into
9//! two schemas that share zero required slots:
10//!
11//! * [`CaixaDialeto::Pacote`] — this crate's [`crate::Caixa`]. `:nome
12//! :versao :kind :deps :bibliotecas :exe :servicos` + the supervisor/mesh
13//! slots. It declares a **tatara-lisp package**: the thing `feira` resolves,
14//! builds, links and publishes.
15//! * [`CaixaDialeto::Molde`] — `:name :kind :ecosystem :package {…} :workflows
16//! […] :ci-config {…} :files […]`. It declares a **repo's generated
17//! surface**: which foreign ecosystem (rust / go / python / …), that
18//! ecosystem's own package metadata, the CI shims to emit, and byte-captured
19//! file bodies. Read by `pleme-doc-gen`, never by `feira`.
20//!
21//! `:package`, `:ecosystem`, `:supports` and `:profile` have no counterpart in
22//! [`crate::Caixa`] at all — the theory doc's own D4 note records the same
23//! thing: those manifests "are authored against a schema that does not exist in
24//! Rust". They are not two spellings of one declaration. They are two domains
25//! that collided on one word, because *caixa* names a box and both are boxes.
26//!
27//! # Why this is not a bug report about broken files
28//!
29//! The Molde-dialect files are not malformed. They are correct inputs to their
30//! own consumer, and nothing in the shipped `feira` reads them, so nothing is
31//! failing today. The hazard is **latent and certain**: any new declarative
32//! surface written against "a `.caixa.lisp` is a [`crate::Caixa`]" meets a
33//! corpus where that is false for the large majority of files, and gets a flat
34//! unknown-keyword rejection that reads as "this manifest is broken" rather
35//! than "this manifest is not yours".
36//!
37//! # What this module does about it
38//!
39//! [`classify`] is total: every `(defcaixa …)` form lands in exactly one
40//! [`CaixaDialeto`], including [`CaixaDialeto::Desconhecido`] for one that
41//! matches neither. [`crate::Caixa::from_lisp`] runs it first, so a foreign
42//! dialect is [`crate::ManifestError::DialetoEstrangeiro`] — an error that
43//! names the dialect it found and the consumer that speaks it — rather than an
44//! unknown-kwarg error indistinguishable from a typo.
45//!
46//! Tier-honest: this is **parse-time rejection with a named cause**, not
47//! unrepresentability. A caller that ignores the `Err` still gets nothing
48//! useful; what it can no longer do is mistake "wrong dialect" for "bad file".
49
50use tatara_lisp::{Atom, Sexp};
51
52/// Canonical `PascalCase` variant-name byte-string the internal-
53/// classification [`CaixaDialeto::Pacote`] arm surfaces under — the
54/// per-arm `&'static str` payload every consumer that formats the
55/// dialect axis as census-facing text (the `feira dialeto` census
56/// counter output line, future `feira dialeto --list-dialects` /
57/// `--filter <Pacote|Molde|MoldePosicional|Desconhecido>` CLI-side
58/// enumerations, a future M4 `mesh.pleme.io/v1alpha1/Manifesto` CR
59/// materializer's admission-webhook rejection body naming the
60/// accepted-dialect set, structured-log `tracing::field::Value::Str`
61/// per-dialect emits on the caixa-build pipeline's per-file classify
62/// path) converges onto verbatim through the paired
63/// [`CaixaDialeto::as_str`] `pub const fn` accessor and the sibling
64/// [`CaixaDialeto::from_wire`] reverse-projection parser. Peer of
65/// [`CAIXA_DIALETO_WIRE_MOLDE`] / [`CAIXA_DIALETO_WIRE_MOLDE_POSICIONAL`]
66/// / [`CAIXA_DIALETO_WIRE_DESCONHECIDO`] on the four-arm dialect-
67/// classification wire-form axis.
68///
69/// Same "one canonical byte-string per typed axis" discipline the
70/// peer [`crate::render::RENDER_PATH_SHAPE_VIOLATION_WIRE_EMPTY`]
71/// (0330bd3) / [`crate::render::CAIXA_KIND_WIRE_BIBLIOTECA`] /
72/// [`crate::render::M2_UPGRADE_INSTRUCTION_WIRE_LOAD_MODULE`]
73/// (36ffe65) / [`crate::render::SUPERVISOR_ESTRATEGIA_ONE_FOR_ONE`]
74/// (be40492) / [`crate::render::M3_PLACEMENT_ESTRATEGIA_SINGLE_NODE`]
75/// families established for the sibling render-side path-shape-
76/// diagnostic / M2 OTP-shape / supervisor / M3 mesh-shape closed-set
77/// typed-enum wire-form axes — extends the discipline onto the
78/// tatara-lisp dialect-classification axis, the eleventh substrate-
79/// side closed-set typed enum to converge onto it and the first
80/// dialect-classification axis (as distinct from the top-level
81/// manifest surface or a render-side path-shape-diagnostic surface)
82/// to reach it. Until this lift landed the byte-string sat twice
83/// inline in [`CaixaDialeto::as_str`] and [`CaixaDialeto::from_wire`]
84/// with no compile-time link between the emit and parse arms nor to
85/// any downstream roster; a future rebrand (a per-arm variant
86/// rename under an M4 vocabulary shift, an operator-vocabulary
87/// migration for a `feira dialeto --list-dialects` per-arm listing)
88/// would have desynchronized the paired arm-set until a downstream
89/// consumer surfaced the drift at runtime. Routing all halves
90/// (`as_str` + `from_wire` + the paired
91/// [`CaixaDialeto::WIRE_NAMES`] roster) through this const closes
92/// the drift structurally by construction. Pinned load-bearing by
93/// [`tests::caixa_dialeto_wire_names_covers_every_arm`] (paired
94/// roster / emitter round-trip).
95pub const CAIXA_DIALETO_WIRE_PACOTE: &str = "Pacote";
96
97/// Canonical `PascalCase` variant-name byte-string the internal-
98/// classification [`CaixaDialeto::Molde`] arm surfaces under. Peer of
99/// [`CAIXA_DIALETO_WIRE_PACOTE`] on the four-arm dialect-classification
100/// wire-form axis; see [`CAIXA_DIALETO_WIRE_PACOTE`] for the full lift
101/// rationale.
102pub const CAIXA_DIALETO_WIRE_MOLDE: &str = "Molde";
103
104/// Canonical `PascalCase` variant-name byte-string the internal-
105/// classification [`CaixaDialeto::MoldePosicional`] arm surfaces under.
106/// Peer of [`CAIXA_DIALETO_WIRE_PACOTE`] on the four-arm dialect-
107/// classification wire-form axis; see [`CAIXA_DIALETO_WIRE_PACOTE`] for
108/// the full lift rationale. The full-word (rather than abbreviated)
109/// spelling here is load-bearing — a `format!("{:?}", …).to_lowercase()`
110/// round-trip on the source-side `Debug` derive would collapse the
111/// multi-word arm to `"moldeposicional"` and desynchronize the tag
112/// from every peer substrate-side census-facing `PascalCase` axis.
113pub const CAIXA_DIALETO_WIRE_MOLDE_POSICIONAL: &str = "MoldePosicional";
114
115/// Canonical `PascalCase` variant-name byte-string the internal-
116/// classification [`CaixaDialeto::Desconhecido`] arm surfaces under.
117/// Peer of [`CAIXA_DIALETO_WIRE_PACOTE`] on the four-arm dialect-
118/// classification wire-form axis; see [`CAIXA_DIALETO_WIRE_PACOTE`] for
119/// the full lift rationale.
120pub const CAIXA_DIALETO_WIRE_DESCONHECIDO: &str = "Desconhecido";
121
122/// Which `(defcaixa …)` declaration a source speaks.
123///
124/// The [`gen_platform::IsVariant`] derive emits per-arm arm-discriminator
125/// predicates (`is_pacote` / `is_molde` / `is_molde_posicional` /
126/// `is_desconhecido`) as substrate-side typed dispatches on the closed
127/// four-arm dialect-classification discriminator. Peer of the sibling
128/// closed-set fieldless typed enums' [`crate::CaixaKind`] /
129/// [`crate::supervisor::RestartStrategy`] /
130/// [`crate::supervisor::RestartPolicy`] /
131/// [`crate::aplicacao::PlacementStrategy`] /
132/// [`crate::aplicacao::RateLimitUnit`] /
133/// [`crate::dep::DepList`] `IsVariant` derives on the sibling
134/// closed-set typed-enum discriminator axes.
135///
136/// The pre-lift `is_molde_family` predicate hand-rolled its own
137/// `matches!(self, Self::Molde | Self::MoldePosicional)` two-arm literal
138/// with no compile-time link back to the closed set — post-lift it routes
139/// through `self.is_molde() || self.is_molde_posicional()` so a future
140/// arm rename (e.g. `Molde → MoldeKW` under an M4 vocabulary shift) trips
141/// exhaustively at every derive-generated predicate site rather than
142/// leaving the hand-rolled `matches!` silently drifting.
143#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
144pub enum CaixaDialeto {
145 /// This crate's [`crate::Caixa`] — a tatara-lisp package manifest.
146 /// Keyword-argument form headed by `:nome`.
147 Pacote,
148 /// `pleme-doc-gen`'s repo-surface declaration, keyword-argument form
149 /// headed by `:name` (plus `:ecosystem` / `:package`).
150 Molde,
151 /// The same declaration as [`Self::Molde`], written with the package name
152 /// as a bare positional symbol — `(defcaixa todoku-go :kind :Biblioteca
153 /// :ecosystem :go …)`. `pleme-doc-gen`'s parser reads the first token
154 /// after the head as the name, so this is one arity of one declaration,
155 /// not a third schema.
156 MoldePosicional,
157 /// A `(defcaixa …)` form matching neither. Kept as a variant rather than
158 /// an error so [`classify`] is total and a census can COUNT the residue —
159 /// a classifier that threw here would report "0 unknown" by construction.
160 Desconhecido,
161}
162
163impl CaixaDialeto {
164 /// Exhaustive iteration surface for every consumer that walks the
165 /// closed four-arm [`CaixaDialeto`] discriminator set — the
166 /// [`feira dialeto`](../../caixa_feira/cmd/dialeto/index.html)
167 /// census counter's per-arm accept-set, a future
168 /// `feira dialeto --list-dialects` CLI listing of the accepted
169 /// classifications, a future M4 `mesh.pleme.io/v1alpha1/Manifesto`
170 /// CR materializer's admission-webhook rejection body naming the
171 /// accepted-dialect set, any future census-report shape probe that
172 /// sweeps every arm to compute per-arm coverage. A future arm
173 /// addition (a fifth dialect the [`crate::dialeto`] module doc's
174 /// "third dialect" hazard actualises — the module explicitly frames
175 /// its purpose as "what stops a third dialect appearing", and this
176 /// slice is the substrate-side answer: the arm-set is one edit and
177 /// every consumer picks up the new entry by construction) extends
178 /// this slice as one edit and every downstream consumer picks up
179 /// the new entry through the shared iteration; the compiler-checked
180 /// exhaustiveness on the sibling method `match` arms
181 /// ([`Self::palavra_canonica`] / [`Self::consumidor`] /
182 /// [`Self::descricao`] / [`std::fmt::Display`]) is the build-time
183 /// guarantee that no arm forgets to grow.
184 ///
185 /// Peer of the sibling closed-set typed enums'
186 /// [`crate::CaixaKind::ALL`] (6b1f4fb) /
187 /// [`crate::aplicacao::PlacementStrategy::ALL`] (18c7342) /
188 /// [`crate::aplicacao::RateLimitUnit::ALL`] (6bce03d) /
189 /// [`crate::dep::DepList::ALL`] (45ee563) /
190 /// [`crate::supervisor::RestartStrategy::ALL`] (4eec29c) /
191 /// [`crate::supervisor::RestartPolicy::ALL`] (dd32ccf)
192 /// exhaustive-iteration surfaces — the seventh closed-set typed
193 /// enum on the caixa surface to converge onto the same
194 /// one-canonical-arm-list-per-enum discipline, and the first
195 /// dialect-classification axis (as distinct from an OTP-shape M2
196 /// slot or an M3 mesh slot) to reach it. Order matches variant
197 /// declaration order verbatim (`Pacote` → `Molde` →
198 /// `MoldePosicional` → `Desconhecido`) so the slice is the
199 /// canonical ordering every listing / rendering consumer defers to.
200 pub const ALL: &'static [Self] = &[
201 Self::Pacote,
202 Self::Molde,
203 Self::MoldePosicional,
204 Self::Desconhecido,
205 ];
206
207 /// Substrate-canonical `PascalCase` variant-name byte-string every consumer
208 /// that formats the dialect as census-facing text lands on. Returns the
209 /// per-arm `PascalCase` name of the variant (`"Pacote"` / `"Molde"` /
210 /// `"MoldePosicional"` / `"Desconhecido"`) — the one canonical
211 /// byte-string the paired [`std::fmt::Display`] impl routes through so
212 /// every downstream consumer (the `feira dialeto` census counter output
213 /// line, a future `feira dialeto --list-dialects` CLI enumeration, a
214 /// future M4 `mesh.pleme.io/v1alpha1/Manifesto` CR materializer's
215 /// admission-webhook rejection body naming the accepted-dialect set)
216 /// reaches for the same substrate primitive rather than the pre-lift
217 /// hand-rolled four-arm literal-string match every [`std::fmt::Display`]
218 /// call previously routed through in place.
219 ///
220 /// Peer of the sibling closed-set typed enums'
221 /// [`crate::CaixaKind::as_str`] / [`crate::supervisor::RestartStrategy::as_str`]
222 /// / [`crate::supervisor::RestartPolicy::as_str`] /
223 /// [`crate::aplicacao::PlacementStrategy::as_str`] /
224 /// [`crate::dep::DepList::as_str`] projections on the sibling closed-set
225 /// typed-enum discriminator axes — the seventh (and last unlifted)
226 /// closed-set fieldless typed enum on the caixa surface to converge
227 /// onto the same one-canonical-byte-string-per-arm-through-`as_str`
228 /// discipline the six siblings already carry. Unlike [`crate::CaixaKind`]
229 /// (which carries two axes: `as_str` returning lowercase Portuguese
230 /// diagnostic form vs `wire_name` returning `PascalCase` tatara-lisp
231 /// author-surface bytes), [`CaixaDialeto`] is an internal
232 /// classification with no wire surface — the `PascalCase` variant name
233 /// is the census-facing form every consumer reads, so `as_str`
234 /// suffices without a paired `wire_name` axis.
235 #[must_use]
236 pub const fn as_str(self) -> &'static str {
237 match self {
238 Self::Pacote => CAIXA_DIALETO_WIRE_PACOTE,
239 Self::Molde => CAIXA_DIALETO_WIRE_MOLDE,
240 Self::MoldePosicional => CAIXA_DIALETO_WIRE_MOLDE_POSICIONAL,
241 Self::Desconhecido => CAIXA_DIALETO_WIRE_DESCONHECIDO,
242 }
243 }
244
245 /// Substrate-canonical exhaustive accept-set on the
246 /// [`CaixaDialeto`] `PascalCase` variant-name wire-form byte-string
247 /// axis — the closed four-arm roster of every byte-string
248 /// [`Self::as_str`] returns, routed byte-for-byte through the paired
249 /// [`CAIXA_DIALETO_WIRE_PACOTE`] / [`CAIXA_DIALETO_WIRE_MOLDE`] /
250 /// [`CAIXA_DIALETO_WIRE_MOLDE_POSICIONAL`] /
251 /// [`CAIXA_DIALETO_WIRE_DESCONHECIDO`] lifted `pub const` scalars the
252 /// [`Self::as_str`] emitter (and the [`std::fmt::Display`] /
253 /// [`AsRef<str>`] / `From<{Self,&Self}> for {&'static str, String,
254 /// Cow<'static, str>, Box<str>, Arc<str>}` trait triple + quintuple
255 /// routed through it) walks — and byte-for-byte the same four strings
256 /// the paired [`Self::from_wire`] and [`TryFrom<&str>`] reverse
257 /// projections accept.
258 ///
259 /// Peer of the sibling [`crate::CaixaKind::WIRE_NAMES`] (bd708bd) /
260 /// [`crate::supervisor::RestartStrategy::WIRE_NAMES`] (3033f45) /
261 /// [`crate::supervisor::RestartPolicy::WIRE_NAMES`] (ce9412b) /
262 /// [`crate::aplicacao::PlacementStrategy::WIRE_NAMES`] (3e5b194) /
263 /// [`crate::render::PathShapeViolation::WIRE_NAMES`] (0330bd3)
264 /// rosters on the `PascalCase` / lowercase-kebab wire-form axes, the
265 /// sibling [`crate::CaixaKind::LABELS`] (427fe75) /
266 /// [`crate::aplicacao::WitShape::LABELS`] (9d9f585) rosters on the
267 /// lowercase-kebab census-label axis, the sibling
268 /// [`crate::aplicacao::RateLimitUnit::SUFFIXES`] (b553ec9) roster on
269 /// the single-char canonical-suffix axis, the sibling
270 /// [`crate::upgrade::UpgradeInstruction::LISP_FORMS`] (1898d77) /
271 /// [`crate::upgrade::UpgradeInstruction::WIRE_FORMS`] (cc42c0e)
272 /// rosters on the OTP-appup two-axis roster split, and the sibling
273 /// [`crate::dep::DepList::AUTHOR_KEYS`] (af6ad3a) roster on the
274 /// two-list dep-graph axis — the same closed-set exhaustive-accept-
275 /// set roster discipline extended here onto the tatara-lisp dialect-
276 /// classification closed-set typed enum, the eleventh substrate-side
277 /// closed-set typed enum on the roster axis and the first
278 /// dialect-classification axis (as distinct from the top-level
279 /// manifest surface or a render-side path-shape-diagnostic surface)
280 /// to converge onto the discipline. The sibling
281 /// [`crate::render::PathShapeViolation::WIRE_NAMES`] doc block's
282 /// closing sentence names this enum ("The sibling
283 /// [`crate::dialeto::CaixaDialeto`] closed-set typed enum on the
284 /// tatara-lisp dialect axis remains the next natural peer, still
285 /// carrying only [`crate::dialeto::CaixaDialeto::ALL`]") as the next
286 /// natural peer — this lift closes the naming.
287 ///
288 /// Downstream consumers of the closed accepted-wire-form set — a
289 /// future `feira dialeto --list-dialects` CLI-side enumeration of
290 /// the accepted dialect classifications whose candidate-list must
291 /// byte-match the wire byte-string [`Self::as_str`] emits (rather
292 /// than the source-side variant identifier), a future `feira dialeto
293 /// --filter <Pacote|Molde|MoldePosicional|Desconhecido>` CLI arg-
294 /// parse's "did you mean" hint that scans this slice rather than
295 /// open-coding the four literal `PascalCase` strings, a future M4
296 /// `mesh.pleme.io/v1alpha1/Manifesto` CR admission-webhook rejection
297 /// body enumerating accepted per-dialect wire-form slugs on an
298 /// unknown-tag miss, a future `feira dialeto` per-arm histogram
299 /// column that walks the roster to render every arm's tally
300 /// (including zero-count arms — a hand-rolled projection off
301 /// [`Self::ALL`] alone would need a companion per-variant-to-tag
302 /// map at every consumer; this roster closes the two-axis walk in
303 /// one lifted const), a future `tracing::field::valuable::Value::List`
304 /// structured-log accepted-dialect emit on the caixa-build
305 /// pipeline's per-file classify emission path — now reach for one
306 /// lifted substrate-primitive roster rather than open-coding a
307 /// `["Pacote", "Molde", "MoldePosicional", "Desconhecido"]` four-
308 /// string array literal whose arm-set has no compile-time link back
309 /// to the typed [`CaixaDialeto`] enum. A future arm addition (the
310 /// module doc's "third dialect" hazard actualising as a fifth arm —
311 /// a third arity variant, an alias-declaration family pleme-doc-gen
312 /// sharpens as its schema evolves) extends this roster as a single
313 /// edit — paired with the [`Self::as_str`] match's compiler-checked
314 /// exhaustiveness on the new arm — and every consumer picks up the
315 /// new wire form by construction.
316 ///
317 /// Length is pinned load-bearing at `CaixaDialeto::ALL.len()`
318 /// (four) by
319 /// [`tests::caixa_dialeto_wire_names_covers_every_arm`], every
320 /// variant's [`Self::as_str`] projection is pinned to a member of
321 /// the roster so a silent skew between the emitter's arm-set and
322 /// this const's arm-set trips at caixa-core test time rather than at
323 /// a downstream consumer's accepted-set enumeration miss, every
324 /// entry is pinned to open with an uppercase ASCII byte (matching
325 /// the substrate-wide `PascalCase` convention every peer closed-set
326 /// enum whose canonical projection is a `PascalCase` census-facing
327 /// name carries), and the roster's declaration order is pinned
328 /// byte-for-byte against the variant declaration order (`Pacote` →
329 /// `Molde` → `MoldePosicional` → `Desconhecido`) so a future arm-
330 /// swap on the roster or the paired `CAIXA_DIALETO_WIRE_*` constants
331 /// trips at caixa-core test time under `assert_eq!` rather than at
332 /// a downstream per-dialect ordering table's miss.
333 pub const WIRE_NAMES: &'static [&'static str] = &[
334 CAIXA_DIALETO_WIRE_PACOTE,
335 CAIXA_DIALETO_WIRE_MOLDE,
336 CAIXA_DIALETO_WIRE_MOLDE_POSICIONAL,
337 CAIXA_DIALETO_WIRE_DESCONHECIDO,
338 ];
339
340 /// Substrate-canonical reverse projection on the [`CaixaDialeto`]
341 /// closed-set dialect-classification axis — parses the `PascalCase`
342 /// variant-name byte-string back to the typed variant, or `None` when
343 /// `s` is outside the closed-set arm-string set [`Self::as_str`]
344 /// emits. Walks the same four `"Pacote"` / `"Molde"` /
345 /// `"MoldePosicional"` / `"Desconhecido"` byte-strings the sibling
346 /// [`Self::as_str`] emitter returns, so the parse and emit halves of
347 /// the round-trip migrate through one caixa-core edit on any future
348 /// arm addition (the module doc's "third dialect" hazard actualising
349 /// as a fifth arm) — the compiler-checked exhaustiveness on
350 /// [`Self::as_str`]'s `match self` arms and the round-trip pin
351 /// [`tests::caixa_dialeto_round_trips_through_as_str_and_from_wire`]
352 /// together lock the two halves mutually.
353 ///
354 /// Prior to this lift the substrate carried only the forward
355 /// `Self → &str` projection on the dialect-classification axis (the
356 /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
357 /// through it, the [`AsRef<str>`] impl routed through it) — every
358 /// future consumer that wanted to promote the census-facing text back
359 /// to the typed enum (a future `feira dialeto --filter
360 /// <Pacote|Molde|MoldePosicional|Desconhecido>` CLI arg-parse that
361 /// binds the wire form into the typed enum before dispatching to the
362 /// per-arm counter, a future M4 `mesh.pleme.io/v1alpha1/Manifesto`
363 /// CR materializer's admission-time re-parse of the per-dialect
364 /// audit body, a future audit-report re-loader that binds a prior
365 /// [`Self::as_str`] output back to the typed enum for cross-run
366 /// comparison) would have had to re-inline a four-arm `match s`
367 /// cascade that expressed no compile-time link back to the typed
368 /// [`CaixaDialeto`] enum.
369 ///
370 /// Same closed-set-reverse-projection discipline the sibling
371 /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
372 /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
373 /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
374 /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
375 /// [`crate::dep::DepList::from_wire`] (45ee563) typed enums carry on
376 /// the peer wire-side `str → Self` axes — extends the family onto
377 /// the seventh closed-set fieldless typed enum on the caixa surface
378 /// (the dialect-classification axis), matching the same
379 /// two-way `str ↔ Self` round-trip every sibling closed-set enum
380 /// already carries. Method-named `from_wire` (not `from_str`) to
381 /// match the peer shapes verbatim and side-step the derived
382 /// [`std::str::FromStr`] impls the sibling
383 /// [`gen_platform::FromStrKind`]-carrying axes install on their
384 /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
385 /// (rather than `Result<Self, _>`) to match the peer shapes: the
386 /// caller picks the diagnostic form appropriate for its use site.
387 #[must_use]
388 pub fn from_wire(s: &str) -> Option<Self> {
389 match s {
390 CAIXA_DIALETO_WIRE_PACOTE => Some(Self::Pacote),
391 CAIXA_DIALETO_WIRE_MOLDE => Some(Self::Molde),
392 CAIXA_DIALETO_WIRE_MOLDE_POSICIONAL => Some(Self::MoldePosicional),
393 CAIXA_DIALETO_WIRE_DESCONHECIDO => Some(Self::Desconhecido),
394 _ => None,
395 }
396 }
397
398 /// The keyword an author should write for this dialect, once the
399 /// migration named in [`Self::consumidor`] completes.
400 #[must_use]
401 pub const fn palavra_canonica(self) -> &'static str {
402 match self {
403 Self::Pacote => "defcaixa",
404 Self::Molde | Self::MoldePosicional => "defmolde",
405 Self::Desconhecido => "?",
406 }
407 }
408
409 /// Who reads this dialect.
410 #[must_use]
411 pub const fn consumidor(self) -> &'static str {
412 match self {
413 Self::Pacote => "caixa-core / feira",
414 Self::Molde | Self::MoldePosicional => "pleme-doc-gen",
415 Self::Desconhecido => "nobody known",
416 }
417 }
418
419 /// A one-line description for a census row or an error message.
420 #[must_use]
421 pub const fn descricao(self) -> &'static str {
422 match self {
423 Self::Pacote => "tatara-lisp package manifest (:nome :versao :kind :deps …)",
424 Self::Molde => "repo-surface declaration (:name :ecosystem :package {…} …)",
425 Self::MoldePosicional => {
426 "repo-surface declaration, positional name (defcaixa <nome> :kind …)"
427 }
428 Self::Desconhecido => "unrecognised — matches no known defcaixa schema",
429 }
430 }
431
432 /// True when this arm belongs to the `defmolde` declaration family —
433 /// the two-arity closure of [`Self::Molde`] and [`Self::MoldePosicional`]
434 /// under the shared `defmolde` head keyword the sibling
435 /// [`Self::palavra_canonica`] projection already collapses onto
436 /// `"defmolde"` for both arms (and the sibling [`Self::consumidor`]
437 /// projection collapses onto `"pleme-doc-gen"` for the same two arms).
438 /// False on [`Self::Pacote`] (the sibling `defcaixa` tatara-lisp
439 /// package manifest, [`Self::palavra_canonica`] `→ "defcaixa"`) and
440 /// on [`Self::Desconhecido`] (the residue that names no known
441 /// declaration, [`Self::palavra_canonica`] `→ "?"`).
442 ///
443 /// The [`Self::Molde`] / [`Self::MoldePosicional`] split is one
444 /// declaration written two ways ([`Self::MoldePosicional`]'s
445 /// variant-declaration docstring at [`Self::MoldePosicional`] frames
446 /// it exactly: "the same declaration as [`Self::Molde`], written with
447 /// the package name as a bare positional symbol … this is one arity
448 /// of one declaration, not a third schema"). Every downstream gate
449 /// that keys off "does this dialect belong to the `defmolde` family"
450 /// (as distinct from the four-arm-per-arm census-counter axis the
451 /// sibling `feira dialeto` verb already fans on separately at
452 /// `caixa-feira/src/cmd/dialeto.rs:110-127`) previously hand-rolled
453 /// the two-arm collapse inline as `matches!(d, CaixaDialeto::Molde |
454 /// CaixaDialeto::MoldePosicional)` — a compile-time-anonymous
455 /// two-arm literal set with no link back to the [`CaixaDialeto`]
456 /// variant declaration nor to the sibling
457 /// [`Self::palavra_canonica`] / [`Self::consumidor`] projections
458 /// that already carry the same two-arm collapse under the shared
459 /// `defmolde` / `pleme-doc-gen` axis. The `feira dialeto` verb's
460 /// [`caixa-feira/src/cmd/dialeto.rs`] carried the same
461 /// `matches!` twice — once in the `--strict-palavra` gate that
462 /// refuses a repo-surface declaration still written as
463 /// `(defcaixa …)`, once in the wrong-declaration-under-`caixa.lisp`
464 /// gate that refuses a repo-surface declaration under the filename
465 /// `feira` loads as a package manifest — with no compile-time link
466 /// between the two hand-rolled arm sets. A future arm addition (the
467 /// module doc's "third dialect" hazard actualises as a fifth arm
468 /// [`CaixaDialeto`] that belongs to the `defmolde` declaration
469 /// family — a third arity variant, an alias-declaration family
470 /// pleme-doc-gen sharpens as its schema evolves) would silently
471 /// split the two hand-rolled `matches!` arm-sets from each other
472 /// and from the paired [`Self::palavra_canonica`] projection: one
473 /// call site picks up the new arm, one does not, and the disagreement
474 /// surfaces far from the arm-addition commit as a `feira dialeto`
475 /// consumer reporting a repo-surface declaration under one gate but
476 /// not the other. Routing every "belongs to the `defmolde` family"
477 /// predicate through this one substrate primitive closes the axis:
478 /// a future arm addition lands one match arm here (a compile-time
479 /// exhaustiveness error otherwise), not a coordinated per-`matches!`
480 /// rewrite across every caller.
481 ///
482 /// Peer of the sibling [`crate::CaixaKind::requires_lib`] (0421c22)
483 /// per-arm-set predicate on the [`crate::CaixaKind`] closed-set
484 /// discriminator's "kind requires a `lib/` surface" axis — extends
485 /// the same "one canonical typed predicate per per-arm-set gate,
486 /// one dispatch on the substrate primitive" discipline onto the
487 /// [`CaixaDialeto`] closed-set discriminator's "belongs to the
488 /// `defmolde` declaration family" axis. The dialect-classification
489 /// axis's second per-arm-set predicate (first being the implicit
490 /// palavra_canonica-through-consumidor-through-descricao arm-set
491 /// collapse already carried on the sibling projections) — the first
492 /// explicitly-typed per-arm-set predicate on the axis, matching the
493 /// discipline the sibling M2 [`crate::CaixaKind`] closed-set
494 /// discriminator already carries with `requires_lib`.
495 ///
496 /// Three consumers now route through this one typed dispatch: the
497 /// [`caixa-feira`](../../caixa_feira/cmd/dialeto/index.html) verb's
498 /// `--strict-palavra` gate (refusing a repo-surface declaration
499 /// still written as `(defcaixa …)`), the same verb's wrong-
500 /// declaration-under-`caixa.lisp` gate (refusing a repo-surface
501 /// declaration under the filename `feira` loads as a package
502 /// manifest), and [`crate::Caixa::from_lisp`]'s foreign-dialect
503 /// gate (raising [`crate::ManifestError::DialetoEstrangeiro`] before
504 /// the derive's `parse_kwargs_strict` walk on any `defmolde`-family
505 /// classification — the pre-lift hand-rolled three-arm
506 /// `match { Pacote => {}, Desconhecido => {}, foreign => Err(…) }`
507 /// literal whose `foreign =>` wildcard silently absorbed anything
508 /// non-Pacote-non-Desconhecido, now the third external consumer of
509 /// the `defmolde`-family partition).
510 #[must_use]
511 pub const fn is_molde_family(self) -> bool {
512 // Routed through the derive-generated per-arm predicates
513 // [`Self::is_molde`] + [`Self::is_molde_posicional`] so the
514 // two-arm collapse links compile-time back to the closed-set
515 // typed dispatch every peer arm-set predicate on the caixa
516 // surface (e.g. [`crate::CaixaKind::requires_lib`] on the
517 // sibling `:kind` axis) now carries. Byte-equivalent to the
518 // pre-lift `matches!(self, Self::Molde | Self::MoldePosicional)`
519 // form (the derived `is_*` predicates each expand to the same
520 // `matches!(self, Self::X)` shape by construction), but a
521 // future arm rename or IsVariant `#[is_variant(name = "…")]`
522 // override lands at exactly one dispatch on the substrate
523 // primitive rather than a hand-rolled two-arm literal.
524 self.is_molde() || self.is_molde_posicional()
525 }
526}
527
528/// [`std::fmt::Display`] routed through [`CaixaDialeto::as_str`], so the
529/// pretty-printed byte-string every consumer that formats the dialect as
530/// user-facing / census text lands on (the `feira dialeto` per-manifest
531/// `--list` row, the `feira dialeto` census summary line's per-arm
532/// counters, a future M4 admission-webhook's rejection body naming the
533/// accepted-dialect set) reaches for the same `PascalCase` per-arm
534/// byte-string the [`CaixaDialeto::as_str`] helper returns.
535///
536/// Prior to this lift the [`std::fmt::Display`] impl hand-rolled its own
537/// four-arm literal-string match — the one hand-rolled per-arm dispatch
538/// on the closed [`CaixaDialeto`] discriminator that had NO substrate
539/// primitive accessor to defer to (the sibling [`CaixaDialeto::palavra_canonica`] /
540/// [`CaixaDialeto::consumidor`] / [`CaixaDialeto::descricao`] projections
541/// carry distinct byte-shapes per axis, so none of them could serve as
542/// the Display source). A future variant addition (a fifth dialect the
543/// module doc's "third dialect" hazard actualises) would land one arm at
544/// the enum and per-arm returns at the paired accessors, but a hand-rolled
545/// [`std::fmt::Display`] match would silently drop the new arm to compile-
546/// fail-at-the-match-arm-site rather than through the shared substrate
547/// primitive. Routing [`std::fmt::Display`] through [`CaixaDialeto::as_str`]
548/// closes the last unlifted per-arm `PascalCase`-name projection on the
549/// caixa surface — the seventh (and last unlifted) closed-set fieldless
550/// typed enum on the caixa surface to converge onto the same
551/// `Display`-through-`as_str` discipline the six siblings
552/// ([`crate::CaixaKind`] / [`crate::supervisor::RestartStrategy`] /
553/// [`crate::supervisor::RestartPolicy`] /
554/// [`crate::aplicacao::PlacementStrategy`] / [`crate::aplicacao::RateLimitUnit`]
555/// / [`crate::dep::DepList`]) already carry.
556impl std::fmt::Display for CaixaDialeto {
557 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
558 f.write_str(self.as_str())
559 }
560}
561
562/// Substrate-canonical [`AsRef<str>`] projection on the [`CaixaDialeto`]
563/// closed-set fieldless typed dialect-classification enum — routes through
564/// the same [`CaixaDialeto::as_str`] `pub const fn` scalar accessor the
565/// paired [`std::fmt::Display`] impl already delegates through, so any
566/// future consumer that binds a [`CaixaDialeto`] through the standard-
567/// library `impl AsRef<str>` bound (a [`std::process::Command::arg`]
568/// shell-out that composes the canonical `PascalCase` variant-name into a
569/// `feira dialeto --strict-palavra <Pacote|Molde|MoldePosicional|Desconhecido>`
570/// diagnostic overlay, a `tracing::field::Value::Str`-arm structured-log
571/// recorder on the [`crate::Caixa::from_lisp`] foreign-dialect
572/// [`crate::ManifestError::DialetoEstrangeiro`] refusal path, a
573/// [`std::collections::HashMap`] lookup keyed on the canonical name
574/// through `map.get::<str>(dialeto.as_ref())` on a future M4 admission-
575/// webhook's per-dialect rejection-body composition table) reaches the
576/// paired `"Pacote"` / `"Molde"` / `"MoldePosicional"` / `"Desconhecido"`
577/// byte-string through one substrate-primitive dispatch rather than an
578/// open-coded `.as_str()` re-inlining at every wire-up.
579///
580/// Same "route the trait impl through the substrate-primitive accessor"
581/// discipline the sibling [`crate::CaixaVersion`] [`AsRef<str>`] impl
582/// (16d5c7e), the paired M2 [`crate::supervisor::RestartStrategy`]
583/// [`AsRef<str>`] impl (63eb1a4), the paired M2
584/// [`crate::supervisor::RestartPolicy`] [`AsRef<str>`] impl (419ea81),
585/// the M3 [`crate::aplicacao::PlacementStrategy`] [`AsRef<str>`] impl
586/// (d86edd2), the M3 [`crate::aplicacao::RateLimitUnit`] [`AsRef<str>`]
587/// impl (d8136db), and the top-level [`crate::CaixaKind`] [`AsRef<str>`]
588/// impl (cd2091f) carry — extends the substrate primitive's
589/// [`AsRef<str>`] projection axis onto the seventh closed-set typed enum
590/// on the caixa surface: the dialect-classification axis previously
591/// carried [`fmt::Display`]-through-`as_str` but not yet the paired
592/// [`AsRef<str>`] impl, so a downstream consumer that bound the enum
593/// through the standard-library `AsRef<str>` trait had to reach the
594/// canonical byte-string through an open-coded `.as_str()` call rather
595/// than the trait-idiomatic `.as_ref()` the peer closed-set typed enums
596/// already admit.
597///
598/// Pinned load-bearing by
599/// [`tests::caixa_dialeto_as_ref_str_routes_through_as_str_accessor`]
600/// (byte-parity pin against [`CaixaDialeto::as_str`] across the four-arm
601/// closed set) and
602/// [`tests::caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`]
603/// (three-path convergence: `AsRef<str>` + `Display` + `as_str` all
604/// resolve to the same byte-string per arm) — any future silent detour
605/// that routes the impl through a divergent projection (a per-arm inline
606/// `match self { CaixaDialeto::Pacote => "Pacote", … }` re-inlining that
607/// opens a compile-time link to the un-lifted arm-literal, a swap onto
608/// the second-axis [`CaixaDialeto::palavra_canonica`] /
609/// [`CaixaDialeto::consumidor`] / [`CaixaDialeto::descricao`] accessors
610/// that carry distinct byte-shapes per axis) trips at caixa-core test
611/// time under `assert_eq!` rather than at a downstream
612/// `impl AsRef<str>`-bound consumer's silent split.
613impl AsRef<str> for CaixaDialeto {
614 fn as_ref(&self) -> &str {
615 self.as_str()
616 }
617}
618
619/// Trait-idiomatic reverse projection on the [`CaixaDialeto`] closed-set
620/// dialect-classification typed enum — routes byte-for-byte through the
621/// paired substrate-primitive [`CaixaDialeto::from_wire`] `Option<Self>`
622/// accessor so every future consumer that binds a `PascalCase` variant-
623/// name byte-string through the standard-library `.try_into()` /
624/// [`TryFrom`] axis (a future `feira dialeto --filter
625/// <Pacote|Molde|MoldePosicional|Desconhecido>` CLI arg-parse that
626/// composes into `let d: CaixaDialeto = s.try_into()?`, a future audit-
627/// report re-loader binding a prior [`CaixaDialeto::as_str`] output
628/// through `CaixaDialeto::try_from(&s)?`, a generic
629/// `<T: TryFrom<&str>>`-bound loader over any of the substrate's closed-
630/// set typed enums) reaches the same four-arm accept-set the sibling
631/// [`CaixaDialeto::from_wire`] parses through and the sibling
632/// [`CaixaDialeto::as_str`] emits, rather than an open-coded per-arm
633/// `match s { "Pacote" => …, … }` cascade whose arm-set has no
634/// compile-time link back to the substrate primitive.
635///
636/// Complements the pre-existing forward-projection triple
637/// ([`std::fmt::Display`], [`AsRef<str>`], [`CaixaDialeto::as_str`]) with
638/// the paired trait-idiomatic reverse-projection axis: Rust-side
639/// newtype/typed-enum convention pairs [`AsRef<str>`] with either
640/// [`std::str::FromStr`] or [`TryFrom<&str>`] on the same primitive so a
641/// caller who can project *out to* a `&str` can also project *in from*
642/// one. The [`TryFrom<&str>`] axis is deliberately chosen over
643/// [`std::str::FromStr`] to sidestep the `clippy::should_implement_trait`
644/// lint that the sibling method-named `from_wire` would trigger under a
645/// `FromStr` impl (the same design tradeoff the peer
646/// [`crate::CaixaKind`] `TryFrom<&str>` impl (3c83606) and the peer
647/// [`crate::provedor::ferrite::FerriteRuntime::from_wire`] block note)
648/// — this impl closes the trait-idiomatic reverse axis without disturbing
649/// the method-named `from_wire` shape every sibling closed-set typed
650/// enum on the substrate already carries.
651///
652/// `type Error = ()` matches the sibling [`CaixaDialeto::from_wire`]'s
653/// `Option<Self>` return-shape's deliberate deferral of error typing:
654/// the caller picks the diagnostic form appropriate for its use site
655/// (a future `feira dialeto --filter` arg-parse composes its own per-verb
656/// "unknown dialect: <arg> — accepted: {…}" message enumerating
657/// [`CaixaDialeto::ALL`], a future admission-webhook rejection body
658/// wraps the `Err(())` outcome with the accepted-set enumeration for
659/// operator diagnostics, a `Result::map_err` at the call site lifts the
660/// unit-error to a per-verb error type). Same shape the peer
661/// [`crate::CaixaKind`] `TryFrom<&str>` impl (3c83606) and the peer
662/// [`FerriteRuntime::from_wire`] doc block motivate on the sibling
663/// closed-set typed enums' reverse projections.
664///
665/// The paired [`TryFrom<&str>`] impl reaches the same four-arm accept-
666/// set the [`CaixaDialeto::from_wire`] resolver dispatches through, so
667/// any future arm addition (the module doc's "third dialect" hazard
668/// actualises as a fifth arm belonging to the `defmolde` family or a
669/// wholly new declaration) grows the trait-idiomatic axis by
670/// construction — one caixa-core edit on [`CaixaDialeto::from_wire`]
671/// extends both the method-named reverse projection every existing
672/// consumer keys off and the trait-idiomatic reverse projection this
673/// impl exposes, without a coordinated rewrite across every future
674/// `TryFrom<&str>`-bound consumer's arm-set.
675///
676/// Pinned load-bearing by
677/// [`tests::caixa_dialeto_try_from_str_routes_through_from_wire_accessor`]
678/// (byte-parity pin against [`CaixaDialeto::from_wire`] across the four-
679/// arm accept-set) and
680/// [`tests::caixa_dialeto_try_from_str_rejects_unknown_byte_strings`]
681/// (rejection witness against silent accept-set widening).
682impl TryFrom<&str> for CaixaDialeto {
683 type Error = ();
684
685 fn try_from(s: &str) -> Result<Self, Self::Error> {
686 Self::from_wire(s).ok_or(())
687 }
688}
689
690/// Trait-idiomatic forward projection on the [`CaixaDialeto`] closed-set
691/// dialect-classification typed enum — routes byte-for-byte through the
692/// sibling substrate-primitive [`CaixaDialeto::as_str`] `pub const fn`
693/// accessor so every future consumer that needs `&'static str` lifetime
694/// bytes on the dialect-classification axis (a
695/// `tracing::field::valuable::Value::Str` recording where the `Str` arm's
696/// typing demands `&'static str`, a
697/// `Cow::Borrowed::<'static, str>(dialeto.into())` composer on the future
698/// M4 admission-webhook rejection body where the `Cow<'static, str>`
699/// typing rules out the sibling [`AsRef<str>`] borrowed return, a generic
700/// `<T: Into<&'static str>>`-bound serializer or error formatter that
701/// requires the `'static` bound) reaches the same four `"Pacote"` /
702/// `"Molde"` / `"MoldePosicional"` / `"Desconhecido"` byte-strings the
703/// sibling [`CaixaDialeto::as_str`] emitter returns, rather than an
704/// open-coded per-arm literal cascade whose arm-set has no compile-time
705/// link back to the substrate primitive.
706///
707/// Return type is `&'static str` by construction — every
708/// [`CaixaDialeto::as_str`] arm resolves to a compile-time `pub const fn`
709/// return of a `&'static str` literal, so the trait's return-type promise
710/// is upheld structurally without a `String::leak()` cast or a per-arm
711/// inline literal.
712///
713/// Complements the pre-existing reverse-projection axis pair
714/// ([`TryFrom<&str>`] above + method-named [`CaixaDialeto::from_wire`])
715/// with the trait-idiomatic forward-projection axis: Rust-side
716/// newtype/typed-enum convention pairs [`TryFrom<&str>`] with the mirror-
717/// image [`From<Self> for &'static str`] on the same primitive so a
718/// caller who can project *in from* a `&str` can also project *out to*
719/// one under a `'static`-lifetime bound. The
720/// [`AsRef<str>`] impl already carries the same emit-set on the borrowed
721/// return path; this impl closes the trait-idiomatic axis pair with the
722/// stricter `&'static str` lifetime the sibling `AsRef<str>` cannot
723/// promise (its return borrows from `&self`, not from the
724/// [`CaixaDialeto::as_str`] `pub const fn`'s static-string result).
725///
726/// Same "route the trait impl through the substrate-primitive accessor"
727/// discipline the sibling [`crate::supervisor::RestartStrategy`]
728/// `From<Self> for &'static str` impl (523157d — first-mover on this
729/// forward-projection family), [`crate::supervisor::RestartPolicy`]
730/// `From<Self> for &'static str` impl (9fb37d0 — second peer, closing
731/// the M2 OTP-shape sibling pair), and [`crate::CaixaKind`]
732/// `From<Self> for &'static str` impl (edb827b — third peer, opening
733/// the campaign onto the top-level caixa surface) carry — extends the
734/// substrate primitive's trait-idiomatic forward-projection axis onto
735/// the fourth closed-set fieldless typed enum on the caixa surface: the
736/// dialect-classification axis, previously carrying the paired
737/// [`std::fmt::Display`] / [`AsRef<str>`] / [`CaixaDialeto::as_str`] /
738/// [`TryFrom<&str>`] / [`CaixaDialeto::from_wire`] forward+reverse
739/// projections but not yet the trait-idiomatic forward projection with
740/// the `&'static str` lifetime bound.
741///
742/// Unlike the peer [`crate::CaixaKind`] impl (which carries a two-axis
743/// split between the lowercase Portuguese `as_str` diagnostic axis and
744/// the `PascalCase` `wire_name` author-surface axis, so the trait's
745/// round-trip witness must cross through the wire axis rather than
746/// composing the two trait impls directly), [`CaixaDialeto`] is an
747/// internal classification whose [`CaixaDialeto::as_str`] output and
748/// [`CaixaDialeto::from_wire`] input share the same `PascalCase`
749/// vocabulary by construction — the trait-idiomatic axis pair
750/// ([`From<Self> for &'static str`] + [`TryFrom<&str> for Self`])
751/// therefore round-trips directly, without an intermediate wire-vocab
752/// hop.
753///
754/// The paired [`CaixaDialeto::as_str`] accessor's four-arm emit-set is
755/// the single source of truth — every future arm addition (the module
756/// doc's "third dialect" hazard actualises as a fifth arm belonging to
757/// the `defmolde` family or a wholly new declaration) grows the trait-
758/// idiomatic forward axis by construction: one caixa-core edit on
759/// [`CaixaDialeto::as_str`] extends every one of the sibling forward-
760/// projection paths ([`std::fmt::Display`], [`AsRef<str>`],
761/// [`CaixaDialeto::as_str`] itself, and this
762/// [`From<Self> for &'static str`]) without a coordinated rewrite across
763/// every future `Into<&'static str>`-bound consumer's arm-set. This lift
764/// closes the fourth peer on the trait-idiomatic forward-projection
765/// campaign the recently-landed peer commits opened; the remaining ten
766/// closed-set typed enums on the caixa substrate surface
767/// (`PlacementStrategy`, `WitShape`, `RateLimitUnit`,
768/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
769/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets
770/// of this campaign.
771///
772/// Pinned load-bearing by
773/// [`tests::caixa_dialeto_from_into_static_str_routes_through_as_str_accessor`]
774/// (byte-parity pin against [`CaixaDialeto::as_str`] across the four-arm
775/// emit-set, plus a `const`-context materialization witness for the
776/// `&'static str` lifetime promise, plus a paired `.into()` shape
777/// assertion covering the blanket-derived `Into<&'static str>` shape)
778/// and
779/// [`tests::caixa_dialeto_from_into_static_str_and_as_str_partition_the_emit_set`]
780/// (partition pin asserting `<&'static str as From<CaixaDialeto>>::from`
781/// and [`CaixaDialeto::as_str`] agree on every arm, plus a two-way
782/// direct round-trip witness through the paired trait-idiomatic
783/// [`TryFrom<&str>`] axis that closes the two-way `Self ↔ &'static str`
784/// round-trip on the trait-idiomatic axis pair without the wire-vocab
785/// intermediate the peer [`crate::CaixaKind`] axis pair requires).
786impl From<CaixaDialeto> for &'static str {
787 fn from(dialeto: CaixaDialeto) -> &'static str {
788 dialeto.as_str()
789 }
790}
791
792/// Trait-idiomatic *forward* projection on [`CaixaDialeto`] from a
793/// *borrowed* input onto the `&'static str` axis — the borrowed-input
794/// companion to the paired owned-input [`From<CaixaDialeto> for &'static
795/// str`] impl immediately above. Routes byte-for-byte through the same
796/// substrate-primitive [`CaixaDialeto::as_str`] `pub const fn` accessor so
797/// every consumer that binds a `&CaixaDialeto` through the standard-
798/// library `.into()` / [`From<&Self> for &'static str`] axis (a
799/// `CaixaDialeto::ALL.iter().map(<&'static str>::from).collect::<Vec<_>>()`
800/// per-arm accept-set materializer — whose iterator over
801/// `&'static [CaixaDialeto]` yields `&CaixaDialeto`, not `CaixaDialeto`,
802/// so the owned-input [`From<CaixaDialeto>`] axis alone forces every call
803/// site through an explicit `.copied()` / dereference / [`Copy`]-bound
804/// restatement rather than the direct trait-idiomatic projection; a
805/// future generic `<T: Copy + for<'a> Into<&'static str>>`-bound
806/// diagnostic column that walks the `iter().map(Into::into)` shape
807/// verbatim over any of the substrate's closed-set typed enums; the
808/// future M4 admission-webhook rejection body composer's per-dialect
809/// accepted-set enumeration built from an iterated
810/// `CaixaDialeto::ALL.iter().map(|d| d.into())` pipe rather than a
811/// per-arm `match d { … }` cascade; a
812/// `HashMap::<&'static str, CaixaDialeto>::from_iter(
813/// CaixaDialeto::ALL.iter().map(|d| (d.into(), *d)))`-style
814/// per-dialect reverse-lookup table the sibling [`TryFrom<&str>`] impl
815/// cannot compose without this borrowed-input axis in place) reaches the
816/// same four `"Pacote"` / `"Molde"` / `"MoldePosicional"` /
817/// `"Desconhecido"` byte-strings the paired owned-input
818/// [`From<CaixaDialeto> for &'static str`], the sibling
819/// [`std::fmt::Display`], [`AsRef<str>`], and [`CaixaDialeto::as_str`]
820/// surfaces already return.
821///
822/// Third peer on the substrate-wide trait-idiomatic *borrowed-input*
823/// forward-projection family opened on
824/// [`crate::dep::DepList`] (64aa742) and extended onto
825/// [`crate::CaixaKind`] (5ab993a). Rust's `From` trait does not
826/// auto-derive the `From<&Self>` sibling from a `From<Self>` impl (the
827/// blanket `impl<T, U> From<&T> for U where T: Copy, U: From<T>` does
828/// not exist in `core`), so every closed-set typed enum that carries
829/// the owned-input axis but not the borrowed-input axis forces every
830/// borrowed-input call site through a `.copied()` /
831/// `<&'static str>::from(*dialeto)` / `dialeto.as_str()` detour whose
832/// type bounds have no compile-time link to the substrate primitive.
833///
834/// Unlike the peer [`crate::CaixaKind`] impl (which carries a two-axis
835/// split between the lowercase Portuguese `as_str` diagnostic axis and
836/// the `PascalCase` `wire_name` author-surface axis, so a `.into()`
837/// pipe over `CaixaKind::ALL` yields the diagnostic vocabulary rather
838/// than the wire vocabulary), [`CaixaDialeto`]'s [`CaixaDialeto::as_str`]
839/// and [`CaixaDialeto::from_wire`] share the same `PascalCase`
840/// vocabulary by construction — the borrowed-input projection this impl
841/// exposes therefore composes directly with the sibling
842/// [`TryFrom<&str>`] axis to build reverse-lookup tables without the
843/// wire-vocab intermediate hop the peer axis pair requires.
844///
845/// Pinned load-bearing by
846/// [`tests::caixa_dialeto_from_borrowed_into_static_str_routes_through_as_str_accessor`]
847/// (byte-parity pin against [`CaixaDialeto::as_str`] across the four-arm
848/// emit-set via a borrowed input, plus a `const`-context materialization
849/// witness for the `&'static str` lifetime promise, plus a blanket
850/// `.into()` shape assertion) and
851/// [`tests::caixa_dialeto_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
852/// (cross-axis partition pin against the paired owned-input
853/// [`From<CaixaDialeto> for &'static str`] impl, plus a
854/// `.iter().map(Into::into)` pipe witness over [`CaixaDialeto::ALL`]
855/// that materializes the four-arm accept-set through the borrowed-input
856/// axis alone, plus a direct round-trip witness through the paired
857/// trait-idiomatic [`TryFrom<&str>`] axis that closes the two-way
858/// `&Self → &'static str → Self` round-trip on the borrowed-input axis
859/// without the wire-vocab intermediate the peer [`crate::CaixaKind`]
860/// axis pair requires).
861impl From<&CaixaDialeto> for &'static str {
862 fn from(dialeto: &CaixaDialeto) -> &'static str {
863 dialeto.as_str()
864 }
865}
866
867/// Trait-idiomatic *forward* projection on [`CaixaDialeto`] from an *owned*
868/// input onto the owned-[`String`] axis — routes byte-for-byte through the
869/// substrate-primitive [`CaixaDialeto::as_str`] `pub const fn` accessor so
870/// every consumer that binds a [`CaixaDialeto`] through the standard-library
871/// `.into()` / [`From<Self> for String`] (equivalently [`Into<String>`]) axis
872/// reaches the same four `"Pacote"` / `"Molde"` / `"MoldePosicional"` /
873/// `"Desconhecido"` byte-strings the paired owned-input
874/// [`From<CaixaDialeto> for &'static str`], the borrowed-input
875/// [`From<&CaixaDialeto> for &'static str`], the sibling [`std::fmt::Display`],
876/// [`AsRef<str>`], and [`CaixaDialeto::as_str`] surfaces already return.
877///
878/// Extends the trait-idiomatic *owned-[`String`]* forward-projection family
879/// (opened on [`crate::supervisor::RestartStrategy`] — 7baa18a — the first-
880/// mover on the M2 OTP-shape sibling-restart-strategy axis, extended onto
881/// [`crate::supervisor::RestartPolicy`] — 7851725 — the second-of-two-in-M2
882/// per-child restart-decision axis, then onto [`crate::CaixaKind`] — 231a18c
883/// — the structurally most fundamental closed-set fieldless typed enum on
884/// the caixa surface) onto the fourth peer: the dialect-classification axis
885/// [`CaixaDialeto`] carries. Rust's standard library does not carry a blanket
886/// `impl<T: AsRef<str>> From<T> for String` (nor an
887/// `impl<T: fmt::Display> From<T> for String`), so every closed-set typed
888/// enum that carries the paired `AsRef<str>` / `Display` /
889/// `From<Self> for &'static str` triple but not the owned-[`String`] axis
890/// forces every owned-string call site through a `.to_string()` /
891/// `.as_str().to_owned()` / `String::from(dialeto.as_str())` detour whose
892/// type bounds have no compile-time link to the substrate primitive.
893///
894/// Unlike the peer [`crate::CaixaKind`] enum (which carries a two-axis split
895/// between the lowercase Portuguese [`crate::CaixaKind::as_str`] diagnostic
896/// axis and the `PascalCase` [`crate::CaixaKind::wire_name`] author-surface
897/// axis, so the owned-[`String`] forward emit and the reverse
898/// [`TryFrom<&str>`] parse land on disjoint vocabularies and the round-trip
899/// crosses through [`crate::CaixaKind::wire_name`] as the reverse-axis
900/// vocabulary rather than composing the owned-[`String`] emit directly),
901/// [`CaixaDialeto`]'s [`CaixaDialeto::as_str`] emit and
902/// [`CaixaDialeto::from_wire`] parse share the same `PascalCase` vocabulary
903/// by construction (there is no wire/diagnostic axis split on this enum —
904/// it is an internal classification with no wire surface), so the
905/// owned-[`String`] forward projection this impl exposes composes directly
906/// with the sibling [`TryFrom<&str>`] axis on the owned-[`String`]'s
907/// [`String::as_str`] borrow, byte-identically to the peer
908/// [`crate::supervisor::RestartStrategy`] /
909/// [`crate::supervisor::RestartPolicy`] owned-[`String`] axis pairs
910/// (whose forward emit and reverse parse also share one `PascalCase`
911/// vocabulary by construction).
912///
913/// The remaining ten closed-set typed enums on the caixa substrate surface
914/// (`DepList`, `PlacementStrategy`, `WitShape`, `RateLimitUnit`,
915/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
916/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets of
917/// this campaign — each carries the same paired `AsRef<str>` / `Display` /
918/// `From<Self> for &'static str` / `From<&Self> for &'static str` quadruple
919/// that this owned-[`String`] axis extends onto.
920///
921/// Pinned load-bearing by
922/// [`tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
923/// (byte-parity pin against [`CaixaDialeto::as_str`] across the four-arm
924/// emit-set, plus a blanket `.into::<String>()` shape witness) and
925/// [`tests::caixa_dialeto_from_into_owned_string_and_static_str_agree_on_every_arm`]
926/// (cross-axis partition pin against the paired owned-input
927/// [`From<CaixaDialeto> for &'static str`] impl and the sibling
928/// [`ToString::to_string`] surface routed through [`std::fmt::Display`],
929/// plus a `.iter().copied().map(String::from)` pipe witness over
930/// [`CaixaDialeto::ALL`], plus a direct round-trip witness through
931/// [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`] borrow
932/// that closes the two-way `Self → String → Self` round-trip on the
933/// trait-idiomatic owned-[`String`] forward + reverse axis pair without
934/// the wire-vocab intermediate hop the peer [`crate::CaixaKind`] axis pair
935/// requires).
936impl From<CaixaDialeto> for String {
937 fn from(dialeto: CaixaDialeto) -> String {
938 dialeto.as_str().to_owned()
939 }
940}
941
942/// Trait-idiomatic *borrowed-input, owned-`String` output* forward
943/// projection on the dialect-classification [`CaixaDialeto`] closed-set
944/// typed enum — the fourth (and closing) corner of the
945/// `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
946/// projection family on this enum, mirror of the peer M2 OTP-shape
947/// [`From<&crate::supervisor::RestartStrategy> for String`] (579385f) /
948/// [`From<&crate::supervisor::RestartPolicy> for String`] (8465740),
949/// the two-list dep-graph [`From<&crate::dep::DepList> for String`]
950/// (e0cb617), and the top-level [`From<&crate::CaixaKind> for String`]
951/// (e76436d) that opened and extended the corner off the M2 OTP-shape
952/// sibling axis pair onto the sibling closed-set fieldless typed enum
953/// peers. Routes byte-for-byte through the substrate-primitive
954/// [`CaixaDialeto::as_str`] `pub const fn` accessor (via
955/// [`str::to_owned`]) so every consumer that holds a borrowed
956/// [`&CaixaDialeto`] and needs an owned [`String`] — a future
957/// `serde_json::Value::String(String::from(&dialeto))` structured-
958/// payload composer over a borrowed field, a future `Iterator::map`
959/// over `&[CaixaDialeto]` that projects to owned keys through
960/// `.iter().map(String::from)` (whose iterator yields `&CaixaDialeto`,
961/// not `CaixaDialeto`, so the owned-input
962/// [`From<CaixaDialeto> for String`] axis alone forces every call site
963/// through an explicit `.copied()` / spurious [`Copy`] deref restatement
964/// rather than the direct trait-idiomatic projection), a future
965/// `HashMap::<String, CaixaDialeto>::from_iter` that keys off a
966/// borrowed-iteration axis where dereferencing the dialect would force
967/// an unnecessary [`Copy`] at every step, the future
968/// `feira dialeto --list-dialects` CLI enumeration that walks
969/// [`CaixaDialeto::ALL`] through the borrowed-iteration axis by
970/// construction, the future M4
971/// `mesh.pleme.io/v1alpha1/Manifesto` CR materializer's admission-
972/// webhook rejection body composer that names the accepted-dialect
973/// set through an iterated `.iter().map(String::from).collect()`
974/// pipe rather than a per-arm cascade — reaches the same four
975/// `"Pacote"` / `"Molde"` / `"MoldePosicional"` / `"Desconhecido"`
976/// byte-strings the paired [`std::fmt::Display`], [`AsRef<str>`],
977/// [`CaixaDialeto::as_str`], and the three other trait-idiomatic
978/// forward-projection impls ([`From<CaixaDialeto> for &'static str`],
979/// [`From<&CaixaDialeto> for &'static str`],
980/// [`From<CaixaDialeto> for String`]) already return.
981///
982/// Fifth peer on the substrate-wide trait-idiomatic *borrowed-input,
983/// owned-`String` output* forward-projection family opened on
984/// [`crate::supervisor::RestartStrategy`] (579385f), closed on the M2
985/// OTP-shape sibling axis pair by
986/// [`crate::supervisor::RestartPolicy`] (8465740), extended onto the
987/// two-list dep-graph peer by [`crate::dep::DepList`] (e0cb617) and
988/// onto the top-level [`crate::CaixaKind`] (e76436d) — extends the
989/// `{Self, &Self} × {&'static str, String}` 2×2 projection corner off
990/// the top-level `:kind` axis onto the dialect-classification axis
991/// (the fourth closed-set fieldless typed enum on the caixa surface;
992/// second peer outside the M2 OTP-shape sibling pair to reach the
993/// 2×2-completion corner). Rust's standard library does not carry a
994/// blanket `impl<T: AsRef<str>> From<&T> for String` (nor an
995/// `impl<T: fmt::Display> From<&T> for String`), so every closed-set
996/// typed enum that carries the paired `AsRef<str>` / `Display` /
997/// `From<Self> for &'static str` / `From<&Self> for &'static str` /
998/// `From<Self> for String` quintuple but not the borrowed-input
999/// owned-[`String`] axis forces every borrowed-input owned-string call
1000/// site through a `dialeto.as_str().to_owned()` /
1001/// `String::from(*dialeto)` (with a spurious [`Copy`]) /
1002/// `dialeto.to_string()` (through [`std::fmt::Display`]) detour whose
1003/// type bounds have no compile-time link to the substrate primitive.
1004///
1005/// Same as the peer [`crate::supervisor::RestartStrategy`] /
1006/// [`crate::supervisor::RestartPolicy`] / [`crate::dep::DepList`]
1007/// borrowed-input owned-[`String`] axis pairs (whose forward emit and
1008/// reverse parse share one vocabulary by construction — `PascalCase`
1009/// on the M2 OTP-shape peers, the lifted
1010/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
1011/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts on the two-list
1012/// dep-graph peer) and unlike the peer [`crate::CaixaKind`] pair
1013/// (whose forward emit lands on the lowercase Portuguese
1014/// diagnostic vocabulary while the reverse parse lands on the
1015/// `PascalCase` wire vocabulary, forcing the round-trip through an
1016/// intermediate [`crate::CaixaKind::wire_name`] hop), [`CaixaDialeto`]
1017/// is an internal classification with no wire surface — the
1018/// [`CaixaDialeto::as_str`] emit and [`CaixaDialeto::from_wire`] parse
1019/// share the same `PascalCase` vocabulary by construction (there is
1020/// no wire/diagnostic axis split on this enum), so the borrowed-
1021/// input owned-[`String`] projection this impl exposes composes
1022/// directly with the paired trait-idiomatic reverse [`TryFrom<&str>`]
1023/// axis on the owned-[`String`]'s [`String::as_str`] borrow — no
1024/// intermediate wire-vocab hop required.
1025///
1026/// The remaining nine closed-set typed enums on the caixa substrate
1027/// surface (`PlacementStrategy`, `WitShape`, `RateLimitUnit`,
1028/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
1029/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets
1030/// of this 2×2-completion campaign — each carries the same paired
1031/// quintuple that this borrowed-input owned-[`String`] axis extends
1032/// onto.
1033///
1034/// Pinned load-bearing by
1035/// [`tests::caixa_dialeto_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
1036/// (byte-parity pin against [`CaixaDialeto::as_str`] across the
1037/// four-arm emit-set through the borrowed-input surface) and
1038/// [`tests::caixa_dialeto_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
1039/// (cross-axis partition pin against the paired owned-input owned-
1040/// [`String`] [`From<CaixaDialeto> for String`] impl, the paired
1041/// borrowed-input owned-[`&'static str`]
1042/// [`From<&CaixaDialeto> for &'static str`] impl, the paired owned-
1043/// input owned-[`&'static str`] [`From<CaixaDialeto> for &'static str`]
1044/// impl, and the sibling [`ToString::to_string`] surface routed
1045/// through [`std::fmt::Display`], plus a `.iter().map(String::from)`
1046/// pipe witness over [`CaixaDialeto::ALL`] (whose iterator yields
1047/// `&CaixaDialeto` by construction, so the borrowed-input owned-
1048/// [`String`] axis is what routes the pipe through the substrate-
1049/// primitive [`CaixaDialeto::as_str`] accessor without a spurious
1050/// [`Copy`] deref), plus a direct round-trip witness through
1051/// [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`]
1052/// borrow that closes the two-way `&Self → String → Self` round-trip
1053/// on the trait-idiomatic borrowed-input owned-[`String`] forward +
1054/// reverse axis pair — no intermediate wire-vocab hop like the peer
1055/// [`crate::CaixaKind`] axis pair requires).
1056impl From<&CaixaDialeto> for String {
1057 fn from(dialeto: &CaixaDialeto) -> String {
1058 dialeto.as_str().to_owned()
1059 }
1060}
1061
1062/// Trait-idiomatic *owned-input, [`std::borrow::Cow<'static, str>`]
1063/// output* forward projection on the dialect-classification
1064/// [`CaixaDialeto`] closed-set typed enum — routes byte-for-byte
1065/// through the substrate-primitive [`CaixaDialeto::as_str`]
1066/// `pub const fn` accessor (via [`std::borrow::Cow::Borrowed`]) so
1067/// every consumer that binds a [`CaixaDialeto`] through the
1068/// standard-library `.into()` /
1069/// [`From<Self> for std::borrow::Cow<'static, str>`] (equivalently
1070/// [`Into<std::borrow::Cow<'static, str>>`]) axis — a future
1071/// `axum::response::IntoResponse` body composer whose typing folds a
1072/// per-arm rejection line into a [`std::borrow::Cow<'static, str>`]
1073/// boundary, a future M4 `mesh.pleme.io/v1alpha1/Manifesto` CR
1074/// materializer's admission-webhook rejection body composer whose
1075/// typing rules out the sibling [`AsRef<str>`] borrowed return and
1076/// the sibling [`From<Self> for &'static str`] axis's non-
1077/// [`std::borrow::Cow`]-parameterized shape, a future substrate-wide
1078/// per-arm diagnostic surface that folds either the zero-alloc
1079/// [`std::borrow::Cow::Borrowed`] arm (for the closed-set arms whose
1080/// byte-string is build-time-lifted) or the [`std::borrow::Cow::Owned`]
1081/// arm (for a caller that mutates the projection) through one uniform
1082/// trait dispatch, a future generic
1083/// `<T: Into<std::borrow::Cow<'static, str>>>`-bound emitter on a
1084/// per-dialect structured-log or admission-webhook rejection body —
1085/// reaches the same four `"Pacote"` / `"Molde"` / `"MoldePosicional"` /
1086/// `"Desconhecido"` byte-strings the paired [`std::fmt::Display`],
1087/// [`AsRef<str>`], [`CaixaDialeto::as_str`], and the four
1088/// `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
1089/// forward-projection corners
1090/// ([`From<CaixaDialeto> for &'static str`],
1091/// [`From<&CaixaDialeto> for &'static str`],
1092/// [`From<CaixaDialeto> for String`],
1093/// [`From<&CaixaDialeto> for String`]) already return, rather than an
1094/// open-coded per-call-site
1095/// `std::borrow::Cow::Borrowed(dialeto.as_str())` /
1096/// `std::borrow::Cow::Owned(dialeto.to_string())` /
1097/// `String::from(dialeto).into()` composition whose type bounds have
1098/// no compile-time link back to the substrate primitive.
1099///
1100/// Deliberately returns [`std::borrow::Cow::Borrowed`] rather than
1101/// [`std::borrow::Cow::Owned`] — the substrate-primitive
1102/// [`CaixaDialeto::as_str`] accessor's return carries the
1103/// `&'static str` lifetime by construction (each `match` arm resolves
1104/// to a `pub const &'static str` literal with static lifetime), so the
1105/// zero-alloc borrowed arm is the type-correct projection with no
1106/// runtime allocation. The paired [`std::borrow::Cow::Owned`] arm
1107/// stays reachable at the call site through the existing
1108/// [`From<CaixaDialeto> for String`] axis composed with
1109/// [`std::borrow::Cow::from`] on the resulting owned [`String`] — a
1110/// caller who chose to mutate the projection lands on the owned arm
1111/// by their own composition, not by the substrate-primitive
1112/// projection silently allocating on their behalf.
1113///
1114/// Same as the sibling [`crate::CaixaKind`] /
1115/// [`crate::supervisor::RestartStrategy`] /
1116/// [`crate::supervisor::RestartPolicy`] /
1117/// [`crate::aplicacao::WitShape`] /
1118/// [`crate::aplicacao::PlacementStrategy`] /
1119/// [`crate::aplicacao::RateLimitUnit`] /
1120/// [`crate::dep::DepList`] peers on the substrate-wide trait-idiomatic
1121/// [`std::borrow::Cow<'static, str>`] forward-projection campaign,
1122/// unlike the peer [`crate::CaixaKind`] pair (whose forward emit
1123/// lands on the lowercase Portuguese diagnostic vocabulary while the
1124/// reverse parse lands on the `PascalCase` wire vocabulary, forcing
1125/// the round-trip through an intermediate
1126/// [`crate::CaixaKind::wire_name`] hop), [`CaixaDialeto`] is an
1127/// internal classification with no wire surface — the
1128/// [`CaixaDialeto::as_str`] emit and [`CaixaDialeto::from_wire`]
1129/// parse share the same `PascalCase` vocabulary by construction (no
1130/// wire/diagnostic axis split on this enum), so the
1131/// [`std::borrow::Cow<'static, str>`] projection this impl exposes
1132/// composes directly with the paired trait-idiomatic reverse
1133/// [`TryFrom<&str>`] axis on the projection's
1134/// [`std::borrow::Cow::as_ref`] borrow — no intermediate wire-vocab
1135/// hop required.
1136///
1137/// Eighth peer on the substrate-wide trait-idiomatic
1138/// [`std::borrow::Cow<'static, str>`] forward-projection family
1139/// opened on the top-level [`crate::CaixaKind`] by 99c1735 (extended
1140/// off the closed `{Self, &Self} × {&'static str, String}` 2×2
1141/// corner closed on the last outside-caixa-core enum peer by
1142/// 29f8af3), closed on the `{Self, &Self}` input-shape corner on
1143/// [`crate::CaixaKind`] by d45c409, extended onto the M2 OTP-shape
1144/// tier by 7dd28b3 / 9b3e4b3 (opens/closes on
1145/// [`crate::supervisor::RestartStrategy`]) and 0612398 / ee577fd
1146/// (opens/closes on [`crate::supervisor::RestartPolicy`], closing the
1147/// M2 OTP-shape tier), extended onto the M3 mesh-shape tier by
1148/// 8634dec / 25690ef (opens/closes on [`crate::aplicacao::WitShape`])
1149/// and eee504d / afdf0f4 (opens/closes on
1150/// [`crate::aplicacao::PlacementStrategy`]) and 1d59925 (closes M3
1151/// mesh-shape tier on [`crate::aplicacao::RateLimitUnit`]), extended
1152/// onto the outside-M3 caixa-core tier by 6858bac / 702cdf4
1153/// (opens/closes on [`crate::dep::DepList`]) — extends the axis onto
1154/// the dialect-classification [`CaixaDialeto`] closed-set fieldless
1155/// typed enum (the second outside-M3 caixa-core peer, and the sole
1156/// remaining internal-classification enum on the caixa-core surface).
1157/// Rust's standard library does not carry a blanket
1158/// `impl<T: AsRef<str>> From<T> for std::borrow::Cow<'static, str>`
1159/// (nor an `impl<T: fmt::Display> From<T> for
1160/// std::borrow::Cow<'static, str>`), so every closed-set fieldless
1161/// typed enum peer on the substrate that carries the paired
1162/// [`AsRef<str>`] / [`std::fmt::Display`] /
1163/// [`From<Self> for &'static str`] / [`From<&Self> for &'static str`]
1164/// / [`From<Self> for String`] / [`From<&Self> for String`] sextet but
1165/// not the [`std::borrow::Cow<'static, str>`] axis forces every
1166/// [`std::borrow::Cow<'static, str>`]-parameterized call site through
1167/// a `std::borrow::Cow::Borrowed(dialeto.as_str())` /
1168/// `std::borrow::Cow::Owned(dialeto.to_string())` /
1169/// `String::from(dialeto).into()` detour whose type bounds have no
1170/// compile-time link to the substrate primitive.
1171///
1172/// The remaining outside-`caixa-core` closed-set fieldless typed
1173/// enum peers on the substrate surface (`PathShapeViolation`,
1174/// `InvariantKind`, `ArchVerdict`, `Severity`, `FixSafety`,
1175/// `Semantic`, `FerriteRuntime`) are the future targets of this
1176/// campaign — each carries the same paired sextet that this axis
1177/// extends onto.
1178///
1179/// Pinned load-bearing by
1180/// [`tests::caixa_dialeto_from_into_static_cow_str_routes_through_as_str_accessor`]
1181/// (byte-parity pin against [`CaixaDialeto::as_str`] across the
1182/// four-arm emit-set through the [`std::borrow::Cow<'static, str>`]
1183/// surface, plus a [`std::borrow::Cow::Borrowed`] discriminator
1184/// witness that the projection lands on the zero-alloc arm rather
1185/// than silently allocating through [`std::borrow::Cow::Owned`],
1186/// plus a blanket-derived [`Into<std::borrow::Cow<'static, str>>`]
1187/// shape witness that also lands on [`std::borrow::Cow::Borrowed`])
1188/// and
1189/// [`tests::caixa_dialeto_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
1190/// (cross-axis partition pin against the paired owned-input
1191/// [`From<CaixaDialeto> for &'static str`] and
1192/// [`From<CaixaDialeto> for String`] forward-projection corners plus
1193/// the sibling [`ToString::to_string`]-through-[`std::fmt::Display`]
1194/// surface, plus a `.iter().copied().map(std::borrow::Cow::from)`
1195/// pipe witness over [`CaixaDialeto::ALL`] whose zero-alloc
1196/// [`std::borrow::Cow::Borrowed`] outcome is load-bearing on every
1197/// arm, plus a direct round-trip witness through [`TryFrom<&str>`]
1198/// on the projection's [`std::borrow::Cow::as_ref`] borrow that
1199/// closes the two-way `Self → Cow<'static, str> → Self` round-trip
1200/// on the trait-idiomatic [`std::borrow::Cow<'static, str>`]
1201/// forward + reverse axis pair without the wire-vocab intermediate
1202/// hop the peer [`crate::CaixaKind`] axis pair requires).
1203impl From<CaixaDialeto> for std::borrow::Cow<'static, str> {
1204 fn from(dialeto: CaixaDialeto) -> std::borrow::Cow<'static, str> {
1205 std::borrow::Cow::Borrowed(dialeto.as_str())
1206 }
1207}
1208
1209/// Trait-idiomatic *borrowed-input, [`std::borrow::Cow<'static, str>`]
1210/// output* forward projection on the dialect-classification
1211/// [`CaixaDialeto`] closed-set typed enum — the borrowed-input companion
1212/// to the paired owned-input [`From<CaixaDialeto> for
1213/// std::borrow::Cow<'static, str>`] impl immediately above (8322511).
1214/// Routes byte-for-byte through the same substrate-primitive
1215/// [`CaixaDialeto::as_str`] `pub const fn` accessor (via
1216/// [`std::borrow::Cow::Borrowed`]) so every consumer that holds a
1217/// [`&CaixaDialeto`] and needs a [`std::borrow::Cow<'static, str>`] — a
1218/// `CaixaDialeto::ALL.iter().map(std::borrow::Cow::from).collect::<Vec<_>>()`
1219/// per-arm accept-set materializer whose iterator over
1220/// `&'static [CaixaDialeto]` yields `&CaixaDialeto` (not
1221/// [`CaixaDialeto`], so the paired owned-input
1222/// [`From<CaixaDialeto> for std::borrow::Cow<'static, str>`] axis alone
1223/// forces every call site through an explicit `.copied()` / dereference
1224/// / [`Copy`]-bound restatement rather than the direct trait-idiomatic
1225/// projection), a future generic
1226/// `<T: for<'a> Into<std::borrow::Cow<'static, str>>>`-bound emitter on
1227/// a per-dialect diagnostic column that walks the
1228/// `iter().map(Into::into)` shape verbatim, the future M4
1229/// `mesh.pleme.io/v1alpha1/Manifesto` CR admission-webhook rejection
1230/// body that composes the accepted-dialect enumeration from an iterated
1231/// `CaixaDialeto::ALL.iter().map(|d| d.into())` pipe rather than a
1232/// per-arm `match d { … }` cascade — reaches the same four `"Pacote"` /
1233/// `"Molde"` / `"MoldePosicional"` / `"Desconhecido"` byte-strings the
1234/// paired [`std::fmt::Display`], [`AsRef<str>`], [`CaixaDialeto::as_str`],
1235/// the four `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
1236/// forward-projection corners, and the paired owned-input
1237/// [`From<CaixaDialeto> for std::borrow::Cow<'static, str>`] impl
1238/// already return.
1239///
1240/// Deliberately returns [`std::borrow::Cow::Borrowed`] rather than
1241/// [`std::borrow::Cow::Owned`] — the substrate-primitive
1242/// [`CaixaDialeto::as_str`] accessor's return carries the `&'static str`
1243/// lifetime by construction (each `match` arm resolves to a `pub const
1244/// &'static str` literal), so the zero-alloc borrowed arm is the
1245/// type-correct projection with no runtime allocation on the
1246/// borrowed-input surface just as on the paired owned-input surface.
1247///
1248/// Closes the `{Self, &Self}` input-shape corner on the second
1249/// outside-M3 caixa-core peer of the substrate-wide
1250/// [`std::borrow::Cow<'static, str>`] forward-projection campaign,
1251/// opened one commit prior (8322511) on the paired owned-input impl.
1252/// Rust's standard library does not carry a blanket
1253/// `impl<T: AsRef<str>> From<&T> for std::borrow::Cow<'static, str>`
1254/// (nor an `impl<T: fmt::Display> From<&T> for
1255/// std::borrow::Cow<'static, str>`, nor a `Copy`-based
1256/// `impl<T: Copy, U: From<T>> From<&T> for U`), so every closed-set
1257/// fieldless typed enum peer on the substrate that carries the paired
1258/// owned-input [`Cow<'static, str>`] axis but not the borrowed-input
1259/// axis forces every borrowed-input [`Cow<'static, str>`]-parameterized
1260/// call site through a spurious [`Copy`] deref
1261/// (`std::borrow::Cow::from(*dialeto)`) or a
1262/// `std::borrow::Cow::Borrowed(dialeto.as_str())` open-code whose type
1263/// bounds have no compile-time link to the substrate primitive.
1264///
1265/// Matches the closure discipline afdf0f4 landed on the M3-mesh-shape
1266/// [`crate::aplicacao::PlacementStrategy`] axis one commit after eee504d,
1267/// 25690ef on [`crate::aplicacao::WitShape`] one commit after 8634dec,
1268/// d45c409 on the top-level [`crate::CaixaKind`] one commit after
1269/// 99c1735, 9b3e4b3 / ee577fd on the M2 OTP-shape
1270/// [`crate::supervisor::RestartStrategy`] /
1271/// [`crate::supervisor::RestartPolicy`] sibling peers one commit after
1272/// 7dd28b3 / 0612398, and 702cdf4 on the two-list dep-graph
1273/// [`crate::dep::DepList`] axis one commit after 6858bac. The remaining
1274/// outside-M3 caixa-core peer ([`crate::render::PathShapeViolation`])
1275/// and the outside-`caixa-core` peers (`InvariantKind`, `ArchVerdict`,
1276/// `Severity`, `FixSafety`, `Semantic`, `FerriteRuntime`) are the
1277/// remaining future targets on the axis.
1278///
1279/// Unlike the peer [`crate::CaixaKind`] pair (whose forward emit lands
1280/// on the lowercase Portuguese diagnostic vocabulary while the reverse
1281/// parse lands on the `PascalCase` wire vocabulary, forcing the
1282/// round-trip through an intermediate [`crate::CaixaKind::wire_name`]
1283/// hop), [`CaixaDialeto`] is an internal classification with no wire
1284/// surface — the [`CaixaDialeto::as_str`] emit and
1285/// [`CaixaDialeto::from_wire`] parse share the same `PascalCase`
1286/// vocabulary by construction (no wire/diagnostic axis split on this
1287/// enum), so the borrowed-input [`std::borrow::Cow<'static, str>`]
1288/// projection this impl exposes composes directly with the paired
1289/// trait-idiomatic reverse [`TryFrom<&str>`] axis on the projection's
1290/// [`std::borrow::Cow::as_ref`] borrow — no intermediate wire-vocab hop
1291/// required.
1292///
1293/// Pinned load-bearing by
1294/// [`tests::caixa_dialeto_from_borrowed_into_static_cow_str_routes_through_as_str_accessor`]
1295/// (byte-parity + zero-alloc [`std::borrow::Cow::Borrowed`]-arm pin
1296/// against [`CaixaDialeto::as_str`] across the four-arm
1297/// [`CaixaDialeto::ALL`] through the borrowed-input surface, plus a
1298/// blanket-derived [`Into<std::borrow::Cow<'static, str>>`] shape
1299/// witness that also lands on [`std::borrow::Cow::Borrowed`]) and
1300/// [`tests::caixa_dialeto_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
1301/// (cross-axis partition pin against the paired owned-input
1302/// [`From<CaixaDialeto> for std::borrow::Cow<'static, str>`], the paired
1303/// borrowed-input owned-`&'static str`
1304/// [`From<&CaixaDialeto> for &'static str`], and the paired
1305/// borrowed-input owned-`String` [`From<&CaixaDialeto> for String`]
1306/// impls plus [`ToString::to_string`]-through-[`std::fmt::Display`], a
1307/// `.iter().map(std::borrow::Cow::from)` pipe witness over
1308/// [`CaixaDialeto::ALL`] — whose iterator yields `&CaixaDialeto` by
1309/// construction, so the borrowed-input axis is what routes the pipe
1310/// without a spurious [`Copy`] deref and every collected element
1311/// satisfies the zero-alloc [`std::borrow::Cow::Borrowed`]-arm
1312/// predicate — plus a direct round-trip witness through
1313/// [`TryFrom<&str>`] on the projection's [`std::borrow::Cow::as_ref`]
1314/// borrow that closes the two-way `&Self → Cow<'static, str> → Self`
1315/// round-trip on the borrowed-input axis without the wire-vocab
1316/// intermediate hop the peer [`crate::CaixaKind`] axis pair requires).
1317impl From<&CaixaDialeto> for std::borrow::Cow<'static, str> {
1318 fn from(dialeto: &CaixaDialeto) -> std::borrow::Cow<'static, str> {
1319 std::borrow::Cow::Borrowed(dialeto.as_str())
1320 }
1321}
1322
1323/// Trait-idiomatic *owned-input, [`Box<str>`] output* forward projection on
1324/// the outside-M3 caixa-core dialect-classification [`CaixaDialeto`]
1325/// closed-set fieldless typed enum. Routes byte-for-byte through the
1326/// substrate-primitive [`CaixaDialeto::as_str`] `pub const fn` accessor
1327/// via [`Box::<str>::from`] on the returned `&'static str`, so every
1328/// consumer that binds a `let key: Box<str> = dialeto.into();`-shaped
1329/// call site reaches the same four `"Pacote"` / `"Molde"` /
1330/// `"MoldePosicional"` / `"Desconhecido"` byte-strings the sibling
1331/// `{Self, &Self} × {&'static str, String, Cow<'static, str>}` forward-
1332/// projection corner already returns.
1333///
1334/// Rust's standard library carries `impl From<&str> for Box<str>` and
1335/// `impl From<String> for Box<str>` but no blanket
1336/// `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a distinct
1337/// trait-idiomatic surface that a downstream `CaixaDialeto → Box<str>`
1338/// `.into()` reaches through this impl and no other — without a
1339/// `Box::from(dialeto.as_str())` open-code whose type bounds have no
1340/// compile-time link back to the substrate primitive.
1341///
1342/// Extends the caixa-core-internal tier of the substrate-wide trait-
1343/// idiomatic [`Box<str>`] forward-projection campaign onto the third
1344/// caixa-core-internal peer, after the render-side path-shape-diagnostic
1345/// [`crate::render::PathShapeViolation`] pair (0d87a72, both corners in
1346/// one axis) opened the tier and the outside-M3 caixa-core two-list
1347/// dep-graph [`crate::dep::DepList`] pair (4aada99, both corners in one
1348/// axis) extended it. Follows the M2 OTP-shape
1349/// [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
1350/// pair (59ae5dc + cb1d068), the M3 mesh-shape
1351/// [`crate::aplicacao::PlacementStrategy`] / [`crate::aplicacao::WitShape`] /
1352/// [`crate::aplicacao::RateLimitUnit`] triple (6d73e84 → df7040c) that
1353/// closed the M3 mesh-shape tier, and the outside-`caixa-core` tier
1354/// (`InvariantKind` 10613a7 + 5901887, `ArchVerdict` 3e08f5a + c4319a8,
1355/// `Severity` 5116c95, `FixSafety` cf0174b, `Semantic` 0cd7dc3,
1356/// `FerriteRuntime` 14886a8) that closed one tier prior. Same discipline
1357/// as those peers: forward emit (this impl, the sibling `{&'static str,
1358/// String, Cow<'static, str>}` forward-projection corner,
1359/// [`std::fmt::Display`], [`AsRef<str>`], [`CaixaDialeto::as_str`]) and
1360/// reverse parse ([`CaixaDialeto::from_wire`], [`TryFrom<&str>`]) route
1361/// through the same four `PascalCase` byte-strings by construction, so
1362/// the round-trip composes directly without the wire-vocab intermediate
1363/// hop the peer [`crate::CaixaKind`] axis pair requires.
1364///
1365/// A future arm addition (the module doc's "third dialect" hazard
1366/// actualising as a fifth arm) reaches the paired [`Box<str>`] output
1367/// axis through one match-arm edit on the [`CaixaDialeto::as_str`]
1368/// `pub const fn` accessor, not a coordinated rewrite of every
1369/// downstream `Box::from(dialeto.as_str())` open-code.
1370///
1371/// Pinned load-bearing by
1372/// [`tests::caixa_dialeto_from_into_box_str_routes_through_as_str_accessor`]
1373/// (byte-parity pin against [`CaixaDialeto::as_str`] across the four-arm
1374/// [`CaixaDialeto::ALL`] emit-set on the owned-input surface, plus a
1375/// blanket-derived [`Into`] shape witness).
1376impl From<CaixaDialeto> for Box<str> {
1377 fn from(dialeto: CaixaDialeto) -> Box<str> {
1378 Box::<str>::from(dialeto.as_str())
1379 }
1380}
1381
1382/// Trait-idiomatic *borrowed-input, [`Box<str>`] output* forward projection
1383/// on the outside-M3 caixa-core dialect-classification [`CaixaDialeto`]
1384/// closed-set fieldless typed enum. Routes byte-for-byte through the
1385/// substrate-primitive [`CaixaDialeto::as_str`] `pub const fn` accessor
1386/// via [`Box::<str>::from`] on the returned `&'static str`, so every
1387/// consumer that binds a `let key: Box<str> = (&dialeto).into();`-shaped
1388/// call site or a `CaixaDialeto::ALL.iter().map(Box::<str>::from)`-shaped
1389/// pipe (whose iterator over `&'static [CaixaDialeto]` yields
1390/// `&CaixaDialeto` by construction) reaches the same four `"Pacote"` /
1391/// `"Molde"` / `"MoldePosicional"` / `"Desconhecido"` byte-strings the
1392/// sibling `{Self, &Self} × {&'static str, String, Cow<'static, str>}`
1393/// forward-projection corner and the paired owned-input
1394/// [`From<CaixaDialeto> for Box<str>`] already return.
1395///
1396/// Rust's standard library carries `impl From<&str> for Box<str>` and
1397/// `impl From<String> for Box<str>` but no blanket
1398/// `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
1399/// `impl<T: Copy, U: From<T>> From<&T> for U`), so this borrowed-input
1400/// axis is a distinct trait-idiomatic surface that the pipe shape
1401/// [`CaixaDialeto::ALL`]`.iter().map(Box::<str>::from)` reaches through
1402/// this impl and no other — without it, the same pipe would force an
1403/// explicit `.copied()` restatement whose type bounds have no compile-
1404/// time link back to the substrate primitive, and a
1405/// `let key: Box<str> = (&dialeto).into();`-shaped call site would force
1406/// an explicit `Copy` deref (`Box::<str>::from(*dialeto)`) or a
1407/// `Box::<str>::from(dialeto.as_str())` open-code with the same defect.
1408///
1409/// Closes the `{Self, &Self}` input-shape corner on the third caixa-
1410/// core-internal closed-set fieldless typed enum peer of the substrate-
1411/// wide trait-idiomatic [`Box<str>`] forward-projection campaign,
1412/// matching the trajectory the paired render-side path-shape-diagnostic
1413/// [`crate::render::PathShapeViolation`] pair (0d87a72, both corners in
1414/// one axis) and the paired outside-M3 caixa-core two-list dep-graph
1415/// [`crate::dep::DepList`] pair (4aada99, both corners in one axis)
1416/// walked before it.
1417///
1418/// Pinned load-bearing by
1419/// [`tests::caixa_dialeto_from_borrowed_into_box_str_routes_through_as_str_accessor`]
1420/// (byte-parity pin against [`CaixaDialeto::as_str`] across the four-arm
1421/// [`CaixaDialeto::ALL`] emit-set on the borrowed-input surface, plus a
1422/// blanket-derived [`Into`] shape witness, plus a
1423/// `.iter().map(Box::<str>::from)` pipe witness over
1424/// [`CaixaDialeto::ALL`] — whose iterator yields `&CaixaDialeto` by
1425/// construction, so the borrowed-input [`Box<str>`] axis is what routes
1426/// the pipe through the substrate-primitive [`CaixaDialeto::as_str`]
1427/// accessor without a spurious [`Copy`] deref).
1428impl From<&CaixaDialeto> for Box<str> {
1429 fn from(dialeto: &CaixaDialeto) -> Box<str> {
1430 Box::<str>::from(dialeto.as_str())
1431 }
1432}
1433
1434/// Trait-idiomatic *owned-input, [`std::sync::Arc<str>`] output* forward
1435/// projection on the outside-M3 caixa-core dialect-classification
1436/// [`CaixaDialeto`] closed-set fieldless typed enum. Routes byte-for-byte
1437/// through the substrate-primitive [`CaixaDialeto::as_str`] `pub const fn`
1438/// accessor via [`std::sync::Arc::<str>::from`] on the returned
1439/// `&'static str`, so every consumer that binds a
1440/// `let key: std::sync::Arc<str> = dialeto.into();`-shaped call site
1441/// reaches the same four `"Pacote"` / `"Molde"` / `"MoldePosicional"` /
1442/// `"Desconhecido"` byte-strings the sibling
1443/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>}`
1444/// forward-projection corner already returns.
1445///
1446/// Rust's standard library carries `impl From<&str> for std::sync::Arc<str>`
1447/// and `impl From<String> for std::sync::Arc<str>` but no blanket
1448/// `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
1449/// `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so this axis is
1450/// a distinct trait-idiomatic surface that a downstream
1451/// `CaixaDialeto → std::sync::Arc<str>` `.into()` reaches through this impl
1452/// and no other — a paired `std::sync::Arc::<str>::from(dialeto.as_str())`
1453/// open-code has no compile-time link back to the substrate primitive, and
1454/// a two-step `std::sync::Arc::<str>::from(String::from(dialeto))`
1455/// composition through the owned-`String` axis allocates twice (once into
1456/// the intermediate `String`, once into the [`std::sync::Arc<str>`] on the
1457/// `From<String>` conversion) where the single-step trait impl allocates
1458/// once.
1459///
1460/// Extends the caixa-core-internal tier of the substrate-wide trait-
1461/// idiomatic [`std::sync::Arc<str>`] forward-projection campaign onto the
1462/// third caixa-core-internal peer, after the structurally most fundamental
1463/// [`crate::CaixaKind`] pair (c17be64, both corners in one axis) opened the
1464/// tier and the outside-M3 two-list dep-graph [`crate::dep::DepList`] pair
1465/// (d8a4652, both corners in one axis) extended it. Follows the M2
1466/// OTP-shape [`crate::supervisor::RestartStrategy`] /
1467/// [`crate::supervisor::RestartPolicy`] pair (bca2ec8 → ea91551), the M3
1468/// mesh-shape [`crate::aplicacao::PlacementStrategy`] /
1469/// [`crate::aplicacao::WitShape`] / [`crate::aplicacao::RateLimitUnit`]
1470/// triple (977d577 → dae722f) that closed the M3 mesh-shape tier, and the
1471/// outside-`caixa-core` tier (`InvariantKind` 4e923c1 + 03c043f,
1472/// `ArchVerdict` 1682f8b + 92ddfb2, `Severity` a7a9a6d + 4f041e1,
1473/// `FixSafety` fb73edb + 822138e, `Semantic` 65dbcff + f3a55c7,
1474/// `FerriteRuntime` 938d915 + 0afef4b) that closed one tier prior. The
1475/// shared-ownership + [`Sync`] + [`Send`] contract [`std::sync::Arc<str>`]
1476/// provides is what makes the per-arm canonical dialect-classification
1477/// label safely reachable off both input-shape axes without a `.clone()`-
1478/// per-task materialization, distinct from the sibling [`Box<str>`] axis's
1479/// owned-move-only contract.
1480///
1481/// A future arm addition (the module doc's "third dialect" hazard
1482/// actualising as a fifth arm) reaches the paired [`std::sync::Arc<str>`]
1483/// output axis through one match-arm edit on the [`CaixaDialeto::as_str`]
1484/// `pub const fn` accessor, not a coordinated rewrite of every downstream
1485/// `std::sync::Arc::<str>::from(dialeto.as_str())` open-code.
1486///
1487/// Pinned load-bearing by
1488/// [`tests::caixa_dialeto_from_into_arc_str_routes_through_as_str_accessor`]
1489/// (byte-parity pin against [`CaixaDialeto::as_str`] across the four-arm
1490/// [`CaixaDialeto::ALL`] emit-set on the owned-input surface, plus a
1491/// blanket-derived [`Into`] shape witness and cross-axis byte-parity pins
1492/// against the sibling owned-input
1493/// `{&'static str, String, Cow<'static, str>, Box<str>}` return-shape axes).
1494impl From<CaixaDialeto> for std::sync::Arc<str> {
1495 fn from(dialeto: CaixaDialeto) -> std::sync::Arc<str> {
1496 std::sync::Arc::<str>::from(dialeto.as_str())
1497 }
1498}
1499
1500/// Trait-idiomatic *borrowed-input, [`std::sync::Arc<str>`] output* forward
1501/// projection on the outside-M3 caixa-core dialect-classification
1502/// [`CaixaDialeto`] closed-set fieldless typed enum — the borrowed-input
1503/// companion to the paired owned-input
1504/// [`From<CaixaDialeto> for std::sync::Arc<str>`] impl one commit above
1505/// that extends the caixa-core-internal tier of the substrate-wide trait-
1506/// idiomatic [`std::sync::Arc<str>`] forward-projection campaign onto the
1507/// third caixa-core-internal peer. Routes byte-for-byte through the
1508/// substrate-primitive [`CaixaDialeto::as_str`] `pub const fn` accessor via
1509/// [`std::sync::Arc::<str>::from`] on the returned `&'static str`, so every
1510/// consumer that binds a `let key: std::sync::Arc<str> = (&dialeto).into();`
1511/// -shaped call site or a
1512/// `CaixaDialeto::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped pipe
1513/// (whose iterator over `&'static [CaixaDialeto]` yields `&CaixaDialeto` by
1514/// construction) reaches the same four `"Pacote"` / `"Molde"` /
1515/// `"MoldePosicional"` / `"Desconhecido"` byte-strings the sibling
1516/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>}`
1517/// forward-projection corner and the paired owned-input
1518/// [`From<CaixaDialeto> for std::sync::Arc<str>`] already return.
1519///
1520/// Rust's standard library carries `impl From<&str> for std::sync::Arc<str>`
1521/// and `impl From<String> for std::sync::Arc<str>` but no blanket
1522/// `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a `Copy`-
1523/// based `impl<T: Copy, U: From<T>> From<&T> for U`), so this borrowed-
1524/// input axis is a distinct trait-idiomatic surface that the pipe shape
1525/// [`CaixaDialeto::ALL`]`.iter().map(std::sync::Arc::<str>::from)` reaches
1526/// through this impl and no other — without it, the same pipe would force
1527/// a spurious [`Copy`] deref
1528/// (`std::sync::Arc::<str>::from((*dialeto).as_str())`) or a `.copied()`
1529/// restatement whose type bounds have no compile-time link back to the
1530/// substrate primitive.
1531///
1532/// Closes the `{Self, &Self}` input-shape corner on the third caixa-core-
1533/// internal closed-set fieldless typed enum peer of the substrate-wide
1534/// trait-idiomatic [`std::sync::Arc<str>`] forward-projection campaign,
1535/// matching the trajectory the paired structurally most fundamental
1536/// [`crate::CaixaKind`] pair (c17be64, both corners in one axis) and the
1537/// paired outside-M3 caixa-core two-list dep-graph [`crate::dep::DepList`]
1538/// pair (d8a4652, both corners in one axis) walked before it on the
1539/// caixa-core-internal tier of the same axis. Same
1540/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>,
1541/// std::sync::Arc<str>}` 2×5 forward-projection matrix the peer projection
1542/// surfaces already close on this same enum.
1543///
1544/// Pinned load-bearing by
1545/// [`tests::caixa_dialeto_from_borrowed_into_arc_str_routes_through_as_str_accessor`]
1546/// (byte-parity pin against [`CaixaDialeto::as_str`] across the four-arm
1547/// [`CaixaDialeto::ALL`] emit-set on the borrowed-input surface, plus a
1548/// blanket-derived [`Into`] shape witness, a cross-axis partition pin
1549/// against the paired owned-input
1550/// [`From<CaixaDialeto> for std::sync::Arc<str>`] and the sibling borrowed-
1551/// input `{&'static str, String, Cow<'static, str>, Box<str>}` return-shape
1552/// axes, and a `.iter().map(std::sync::Arc::<str>::from)` pipe witness over
1553/// [`CaixaDialeto::ALL`] that resolves through the borrowed-input axis
1554/// without a spurious [`Copy`] deref).
1555impl From<&CaixaDialeto> for std::sync::Arc<str> {
1556 fn from(dialeto: &CaixaDialeto) -> std::sync::Arc<str> {
1557 std::sync::Arc::<str>::from(dialeto.as_str())
1558 }
1559}
1560
1561/// A source that is not a `(defcaixa …)` / `(defmolde …)` form at all.
1562#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
1563pub enum DialetoError {
1564 #[error("source has no top-level form")]
1565 Vazio,
1566 #[error("top-level form is not a list — a manifest is `(defcaixa …)`")]
1567 NaoEhLista,
1568 #[error(
1569 "top-level form is headed by `{encontrado}`, not `defcaixa` or `defmolde` \
1570 (a manifest's first form must be the declaration itself)"
1571 )]
1572 CabecaErrada { encontrado: String },
1573 #[error("manifest does not parse as tatara-lisp: {0}")]
1574 Leitura(String),
1575}
1576
1577impl DialetoError {
1578 /// Construct a [`DialetoError::CabecaErrada`] naming the offending
1579 /// head symbol found at the top-level form.
1580 ///
1581 /// Substrate primitive every [`classify_form`] wrong-head fallthrough
1582 /// wire-up site now routes through, folding the pre-lift uniform
1583 /// three-line `Self::CabecaErrada { encontrado: <head>.to_string() }`
1584 /// one-field struct-literal onto one substrate primitive matching the
1585 /// peer `LimitsError::unknown_byte_unit(unit: &str)` /
1586 /// `LimitsError::unknown_duration_unit(unit: &str)`
1587 /// (`limits_codec_unit_only_ctors!` — 29fac09) single-slot
1588 /// discipline on the sibling one-field `{ <field>: String }` envelope
1589 /// axis, and matching the peer `ManifestError::code_path_empty` /
1590 /// `BehaviorError::empty_path` / `UpgradeError::duplicate_from` /
1591 /// `AplicacaoError::placement_cluster_duplicate` (94dabc8 / 0e33b37 /
1592 /// 7e52aec / 92b1c92) single-slot inherent-ctor discipline every
1593 /// sibling `{ <field>: <T> }` error-envelope variant on caixa-core's
1594 /// error surface now carries.
1595 ///
1596 /// The one open-coded wire-up site — `classify_form`'s wrong-head
1597 /// fallthrough arm on the `head: &str` binding read from the
1598 /// top-level form via [`tatara_lisp::Sexp::as_symbol`] — opened the
1599 /// identical three-line
1600 /// `Self::CabecaErrada { encontrado: <head>.to_string() }` block
1601 /// against the codec-scoped `<head>: &str` binding. Now routes
1602 /// through `DialetoError::cabeca_errada(head)`, byte-equal to the
1603 /// pre-lift struct-literal on the same `&str` fixture, so any future
1604 /// widening of the diagnostic shape (e.g. carrying the source-file
1605 /// path alongside the head symbol, carrying the head symbol's
1606 /// position offset for an authoring-surface caret pointer) lands at
1607 /// exactly one dispatch on the substrate primitive rather than re-
1608 /// inlining the struct-literal at every wrong-head fallthrough
1609 /// consumer.
1610 #[must_use]
1611 pub fn cabeca_errada(encontrado: &str) -> Self {
1612 Self::CabecaErrada {
1613 encontrado: encontrado.to_string(),
1614 }
1615 }
1616
1617 /// Construct a [`DialetoError::Leitura`] carrying the offending
1618 /// tatara-lisp reader-error message `reason` verbatim in the
1619 /// variant's tuple-newtype payload.
1620 ///
1621 /// Substrate primitive every [`classify`] tatara-lisp-reader
1622 /// map-err wire-up site now routes through, folding the pre-lift
1623 /// uniform `Self::Leitura(<into-String-expr>)` tuple-newtype
1624 /// construction onto one substrate primitive matching the peer
1625 /// `LimitsError::empty_byte_size` / `LimitsError::empty_duration`
1626 /// (7a4b003 / 319216c) `(String)` single-slot tuple-newtype
1627 /// discipline on the sibling
1628 /// [`crate::limits::LimitsError`] envelope's empty-shape axis of
1629 /// the paired codec-magnitude family. Peer to the sibling
1630 /// [`DialetoError::cabeca_errada`] ctor on the same envelope's
1631 /// wrong-head axis but on the tatara-lisp-reader axis rather than
1632 /// the classifier-fallthrough axis. Closes the last un-lifted
1633 /// variant on [`DialetoError`] — every one of the sole wire-up
1634 /// sites (the [`classify`] tatara-lisp-reader `.map_err(|e|
1635 /// Self::Leitura(e.to_string()))` arm) opened the identical
1636 /// `DialetoError::Leitura(<into-String-expr>)` block against the
1637 /// codec-scoped `String` (`e.to_string()`) binding, so the fold
1638 /// routes the site through one dispatch on a uniform
1639 /// `impl Into<String>` param, byte-equal to the pre-lift
1640 /// tuple-newtype construction on the same argument.
1641 ///
1642 /// The `impl Into<String>` bound covers both wire-up shapes on
1643 /// [`classify`] — a `String` binding (`e.to_string()` on the
1644 /// [`tatara_lisp::Error`]-carrying `e` binding) and a `&str`
1645 /// binding (a future admission-webhook consumer probing a
1646 /// caller-scoped `&'static str` fixture, a future
1647 /// `feira lint --tatara-reader-round-trip` verb sweeping every
1648 /// `tatara_lisp::read` return through the same shape gate) —
1649 /// without forcing the caller to spell the conversion at the
1650 /// wire-up site. Same shape the peer
1651 /// [`crate::limits::LimitsError::empty_byte_size`] /
1652 /// [`crate::limits::LimitsError::empty_duration`] /
1653 /// [`crate::limits::LimitsError::bad_millicores`] /
1654 /// [`crate::limits::LimitsError::bad_byte_magnitude`] /
1655 /// [`crate::limits::LimitsError::bad_duration_magnitude`] folds
1656 /// carry on the peer bad-magnitude and empty-shape axes of the
1657 /// same paired `(String)` tuple-newtype codec-magnitude family.
1658 /// `#[must_use]` fires a compile warning at any wire-up that
1659 /// mistakenly discards the constructed error.
1660 ///
1661 /// Every future consumer that wants to construct this variant
1662 /// outside [`classify`] (a deferred `feira lint --tatara-reader-
1663 /// round-trip` per-caixa admission verb probing each authored
1664 /// manifest against the tatara-lisp-reader shape gate, an M4
1665 /// typed `mesh.pleme.io/v1alpha1/Servico` CR materializer's
1666 /// per-manifest admission validator re-checking one edited
1667 /// `caixa.lisp` against the reader floor, a per-`caixa.lisp`
1668 /// value-shape pre-emitter probing each declared manifest ahead
1669 /// of the operator's admit-cycle) now reaches the variant
1670 /// through one call rather than re-inlining the tuple-newtype
1671 /// block in lockstep with the pre-existing wire-up.
1672 #[must_use]
1673 pub fn leitura(reason: impl Into<String>) -> Self {
1674 Self::Leitura(reason.into())
1675 }
1676}
1677
1678/// Classify a manifest source without committing to either schema.
1679///
1680/// Deliberately reads only the head symbol and the set of top-level keywords —
1681/// enough to route, never enough to half-parse. A classifier that started
1682/// validating would grow into a third parser, which is the shape of the problem
1683/// it exists to name.
1684///
1685/// # Errors
1686/// [`DialetoError`] when the source is not a manifest declaration at all.
1687pub fn classify(src: &str) -> Result<CaixaDialeto, DialetoError> {
1688 let forms = tatara_lisp::read(src).map_err(|e| DialetoError::leitura(e.to_string()))?;
1689 let first = forms.first().ok_or(DialetoError::Vazio)?;
1690 classify_form(first)
1691}
1692
1693/// [`classify`] over an already-read form.
1694///
1695/// # Errors
1696/// [`DialetoError`] when the form is not a manifest declaration.
1697pub fn classify_form(form: &Sexp) -> Result<CaixaDialeto, DialetoError> {
1698 let list = form.as_list().ok_or(DialetoError::NaoEhLista)?;
1699 let head = list
1700 .first()
1701 .and_then(Sexp::as_symbol)
1702 .ok_or(DialetoError::NaoEhLista)?;
1703
1704 match head {
1705 // `defmolde` is unambiguous by construction — it exists precisely so a
1706 // consumer never has to infer which declaration it holds. Both arities
1707 // are the same declaration; the positional one keeps its own variant
1708 // only so a census can report the split.
1709 "defmolde" => {
1710 return Ok(if starts_with_positional_name(&list[1..]) {
1711 CaixaDialeto::MoldePosicional
1712 } else {
1713 CaixaDialeto::Molde
1714 });
1715 }
1716 "defcaixa" => {}
1717 other => {
1718 return Err(DialetoError::cabeca_errada(other));
1719 }
1720 }
1721
1722 let args = &list[1..];
1723
1724 // `(defcaixa <symbol> :kind … :ecosystem …)`. Only the Molde dialect has a
1725 // positional arity; `Caixa` is keyword-only, so a leading bare symbol
1726 // settles it without looking further.
1727 if starts_with_positional_name(args) {
1728 return Ok(CaixaDialeto::MoldePosicional);
1729 }
1730
1731 let keys = top_level_keywords(args);
1732 let has = |k: &str| keys.iter().any(|s| s == k);
1733
1734 // Order matters, and it is not arbitrary: `:nome` and `:name` are the two
1735 // required head slots and no file in the measured corpus carries both.
1736 // Checking them FIRST means the decision rests on the one slot each schema
1737 // makes mandatory, rather than on optional evidence like `:ecosystem`.
1738 if has("nome") {
1739 return Ok(CaixaDialeto::Pacote);
1740 }
1741 if has("name") || has("ecosystem") || has("package") {
1742 return Ok(CaixaDialeto::Molde);
1743 }
1744 Ok(CaixaDialeto::Desconhecido)
1745}
1746
1747/// True when the first argument is a bare symbol rather than a keyword — the
1748/// positional-name arity.
1749fn starts_with_positional_name(args: &[Sexp]) -> bool {
1750 matches!(args.first(), Some(Sexp::Atom(Atom::Symbol(_))))
1751}
1752
1753/// The top-level keyword names (without the leading `:`) of a kwarg list.
1754///
1755/// Steps in pairs so a keyword appearing as a VALUE — `:kind :Biblioteca`, or a
1756/// nested `(:nome "dep" :versao "^0.1")` inside `:deps` — is never counted as a
1757/// top-level slot. A naive scan for `:nome` anywhere in the source classifies
1758/// every Molde manifest with a `:deps` list as a Pacote.
1759fn top_level_keywords(args: &[Sexp]) -> Vec<String> {
1760 let mut out = Vec::new();
1761 let mut i = 0;
1762 while i < args.len() {
1763 if let Sexp::Atom(Atom::Keyword(k)) = &args[i] {
1764 out.push(k.clone());
1765 i += 2;
1766 } else {
1767 i += 1;
1768 }
1769 }
1770 out
1771}
1772
1773#[cfg(test)]
1774mod tests {
1775 use super::*;
1776
1777 const PACOTE: &str = r#"
1778 (defcaixa
1779 :nome "checkout"
1780 :versao "0.1.0"
1781 :kind Servico
1782 :deps ((:nome "caixa-teia" :versao "^0.1")))
1783 "#;
1784
1785 const MOLDE: &str = r#"
1786 (defcaixa
1787 :name "base64"
1788 :kind :Biblioteca
1789 :ecosystem :rust-single-crate
1790 :package {:name "base64" :version "0.22.1"}
1791 :workflows [:auto-release])
1792 "#;
1793
1794 const MOLDE_POSICIONAL: &str = r#"
1795 (defcaixa todoku-go
1796 :kind :Biblioteca
1797 :ecosystem :go
1798 :package {:name "todoku-go" :version "0.3.0"})
1799 "#;
1800
1801 #[test]
1802 fn the_package_dialect_is_recognised() {
1803 assert_eq!(classify(PACOTE), Ok(CaixaDialeto::Pacote));
1804 }
1805
1806 #[test]
1807 fn the_repo_surface_dialect_is_recognised() {
1808 assert_eq!(classify(MOLDE), Ok(CaixaDialeto::Molde));
1809 }
1810
1811 #[test]
1812 fn the_positional_arity_is_recognised() {
1813 assert_eq!(
1814 classify(MOLDE_POSICIONAL),
1815 Ok(CaixaDialeto::MoldePosicional)
1816 );
1817 }
1818
1819 #[test]
1820 fn defmolde_classifies_without_inference() {
1821 // The whole point of the new keyword: no schema sniffing required.
1822 let src = r#"(defmolde :name "x" :kind :Biblioteca :ecosystem :go)"#;
1823 assert_eq!(classify(src), Ok(CaixaDialeto::Molde));
1824 let pos = r"(defmolde todoku-go :kind :Biblioteca :ecosystem :go)";
1825 assert_eq!(classify(pos), Ok(CaixaDialeto::MoldePosicional));
1826 }
1827
1828 #[test]
1829 fn a_nested_nome_does_not_make_a_repo_surface_look_like_a_package() {
1830 // The exact failure a substring scan produces: `:deps ((:nome …))`
1831 // contains `:nome`, but not as a top-level slot.
1832 let src = r#"
1833 (defcaixa
1834 :name "x"
1835 :ecosystem :rust-single-crate
1836 :deps ((:nome "inner" :versao "^0.1")))
1837 "#;
1838 assert_eq!(classify(src), Ok(CaixaDialeto::Molde));
1839 }
1840
1841 #[test]
1842 fn a_keyword_in_value_position_is_not_a_slot() {
1843 // `:kind :Biblioteca` — the value is itself a keyword. Stepping one at
1844 // a time would read `:Biblioteca` as a top-level slot.
1845 let src = r#"(defcaixa :kind :Biblioteca :name "x")"#;
1846 assert_eq!(classify(src), Ok(CaixaDialeto::Molde));
1847 }
1848
1849 #[test]
1850 fn an_unrecognised_defcaixa_is_reported_not_guessed() {
1851 let src = r#"(defcaixa :licenca "MIT")"#;
1852 assert_eq!(classify(src), Ok(CaixaDialeto::Desconhecido));
1853 }
1854
1855 #[test]
1856 fn a_form_that_is_not_a_manifest_is_an_error_not_a_dialect() {
1857 assert_eq!(
1858 classify("(defflake :nome \"x\")"),
1859 Err(DialetoError::cabeca_errada("defflake"))
1860 );
1861 assert_eq!(classify(""), Err(DialetoError::Vazio));
1862 }
1863
1864 #[test]
1865 fn every_dialect_names_its_consumer_and_its_canonical_keyword() {
1866 // Guards the routing table itself: a new variant added without an arm
1867 // here is a compile error in the match, and a variant that claims
1868 // `defcaixa` while being read by pleme-doc-gen would re-open the
1869 // collision this module closes. Sweeps [`CaixaDialeto::ALL`] rather
1870 // than the pre-lift open-coded four-arm literal list — a future arm
1871 // addition extends the slice as one edit and this pin picks it up
1872 // by construction.
1873 for &d in CaixaDialeto::ALL {
1874 assert!(!d.descricao().is_empty(), "{d}");
1875 assert!(!d.consumidor().is_empty(), "{d}");
1876 }
1877 assert_eq!(CaixaDialeto::Pacote.palavra_canonica(), "defcaixa");
1878 assert_eq!(CaixaDialeto::Molde.palavra_canonica(), "defmolde");
1879 assert_ne!(
1880 CaixaDialeto::Pacote.palavra_canonica(),
1881 CaixaDialeto::Molde.palavra_canonica(),
1882 "the two dialects must not share a canonical keyword — that IS the defect"
1883 );
1884 }
1885
1886 #[test]
1887 fn caixa_dialeto_all_enumerates_every_variant_exactly_once() {
1888 // Three-legged exhaustiveness pin, peer of the sibling
1889 // `caixa_kind_all_enumerates_every_variant_exactly_once`
1890 // (caixa-core/src/kind.rs) /
1891 // `restart_strategy_all_enumerates_every_variant_exactly_once`
1892 // (caixa-core/src/supervisor.rs) shape.
1893 //
1894 // 1. arm-count invariant: `ALL.len()` matches the declared arm
1895 // count (four — a fifth arm added without extending `ALL`
1896 // fails this pin at caixa-core test time);
1897 // 2. pairwise-distinctness invariant: every variant appears at
1898 // most once in the slice (a duplicate arm would silently
1899 // double-count in the census consumer, so the pin rejects
1900 // duplicates outright);
1901 // 3. coverage invariant: every literal `CaixaDialeto::X` is in
1902 // the slice (the compiler-checked exhaustiveness on the peer
1903 // per-arm `match self` in the accessors keeps the enum arm
1904 // set and the `ALL` slice mutually aligned).
1905 assert_eq!(
1906 CaixaDialeto::ALL.len(),
1907 4,
1908 "ALL must list every arm exactly once; a fifth arm added \
1909 without extending ALL fails this pin — extend ALL alongside \
1910 the new variant"
1911 );
1912
1913 let mut seen: Vec<CaixaDialeto> = Vec::new();
1914 for &d in CaixaDialeto::ALL {
1915 assert!(
1916 !seen.contains(&d),
1917 "ALL contains a duplicate arm: {d}. Every variant appears \
1918 exactly once — a duplicate would double-count in every \
1919 iteration consumer"
1920 );
1921 seen.push(d);
1922 }
1923
1924 // Coverage: exhaustively assert every literal variant is somewhere
1925 // in the slice. Written as an exhaustive `match` so a future arm
1926 // addition fails to compile here (missing match arm) until the
1927 // corresponding `assert` is added — the compiler enforces the pin's
1928 // completeness rather than a hand-maintained variant list.
1929 for variant in [
1930 CaixaDialeto::Pacote,
1931 CaixaDialeto::Molde,
1932 CaixaDialeto::MoldePosicional,
1933 CaixaDialeto::Desconhecido,
1934 ] {
1935 let coverage_probe = match variant {
1936 CaixaDialeto::Pacote
1937 | CaixaDialeto::Molde
1938 | CaixaDialeto::MoldePosicional
1939 | CaixaDialeto::Desconhecido => variant,
1940 };
1941 assert!(
1942 CaixaDialeto::ALL.contains(&coverage_probe),
1943 "ALL is missing variant {coverage_probe} — extend the slice"
1944 );
1945 }
1946 }
1947
1948 #[test]
1949 fn caixa_dialeto_all_is_const_and_matches_iteration_count() {
1950 // Pins the const-ness of the slice at const-fold time. A future
1951 // change that promoted `ALL` to a non-const initializer (a lazy-
1952 // static, a runtime-computed Vec) would fail to compile here —
1953 // the pin locks in the compile-time-known iteration surface
1954 // every consumer builds against. Peer of the sibling
1955 // `caixa_kind_all_is_const_and_matches_iteration_count` (kind.rs)
1956 // / `restart_strategy_all_is_const_and_matches_iteration_count`
1957 // (supervisor.rs) shape.
1958 const ALL: &[CaixaDialeto] = CaixaDialeto::ALL;
1959 assert_eq!(ALL.len(), CaixaDialeto::ALL.len());
1960 // Sweep the iterator without collapsing to `.len()` so a future
1961 // change to `ALL`'s carrier that decouples `.len()` from the
1962 // iteration count (a lazy-computed shape, an alias `impl Iterator`
1963 // return, a wrapper newtype) still passes here iff the two agree
1964 // arm-for-arm; the `#[allow]` opts this local pin out of the
1965 // clippy `iter_count` collapse that would defeat the intent.
1966 #[allow(clippy::iter_count)]
1967 let iterated = ALL.iter().count();
1968 assert_eq!(iterated, CaixaDialeto::ALL.len());
1969 }
1970
1971 #[test]
1972 fn caixa_dialeto_all_covers_every_variant_by_display_probe() {
1973 // Fanning `Display` over the slice sweeps the paired accessors
1974 // ([`CaixaDialeto::palavra_canonica`] / [`CaixaDialeto::consumidor`]
1975 // / [`CaixaDialeto::descricao`]) at every arm — every returned
1976 // byte-string is non-empty (the accessors' contract). A future
1977 // arm added without extending its per-arm `match self` return
1978 // would compile-fail at the accessor call inside the loop;
1979 // together with the `ALL.len() == 4` pin above, this locks the
1980 // accessor arm-set and the `ALL` slice mutually.
1981 for &d in CaixaDialeto::ALL {
1982 let display_form = d.to_string();
1983 assert!(
1984 !display_form.is_empty(),
1985 "Display must render a non-empty byte-string for every \
1986 arm; empty: {d:?}"
1987 );
1988 // Consumidor / descricao / palavra-canonica must each surface
1989 // a non-empty scalar; every downstream diagnostic consumer
1990 // reaches through these accessors.
1991 assert!(!d.palavra_canonica().is_empty(), "{d}");
1992 assert!(!d.consumidor().is_empty(), "{d}");
1993 assert!(!d.descricao().is_empty(), "{d}");
1994 }
1995 }
1996
1997 #[test]
1998 fn caixa_dialeto_as_str_returns_pascal_case_variant_name() {
1999 // Fail-before-pass-after per-arm shape pin: the four
2000 // [`CaixaDialeto::as_str`] arms must return the canonical
2001 // `PascalCase` byte-string that names the variant. Pre-lift this
2002 // byte-string existed only inside the hand-rolled Display impl's
2003 // four-arm literal-string match — every consumer that wanted the
2004 // `PascalCase` name reached through `format!("{d}")`'s allocation
2005 // path. Pinning the four arms explicitly here refuses a future
2006 // regression that ever reroutes an arm to a distinct spelling
2007 // (`"pacote"` lowercase, `"MoldePositional"` English rebrand,
2008 // `"Unknown"` for `Desconhecido`) — the census output and the
2009 // typed accessor would silently disagree until a downstream
2010 // consumer surfaced the drift at census time. Peer of the sibling
2011 // [`crate::supervisor::tests::restart_strategy_variants_serialize_to_lifted_scalar_values`]
2012 // / `placement_strategy_variants_serialize_to_lifted_scalar_values`
2013 // / `caixa_kind_as_str_returns_lifted_peer_const` shape on the
2014 // sibling closed-set typed-enum discriminator axes — the seventh
2015 // (and last unlifted) closed-set typed enum on the caixa surface
2016 // to converge onto the same per-arm-shape-pin discipline.
2017 for (variant, expected) in [
2018 (CaixaDialeto::Pacote, "Pacote"),
2019 (CaixaDialeto::Molde, "Molde"),
2020 (CaixaDialeto::MoldePosicional, "MoldePosicional"),
2021 (CaixaDialeto::Desconhecido, "Desconhecido"),
2022 ] {
2023 assert_eq!(
2024 variant.as_str(),
2025 expected,
2026 "CaixaDialeto::{variant:?}.as_str() must return the \
2027 canonical `PascalCase` variant-name byte-string; drift here \
2028 splits the census-facing text from the substrate \
2029 primitive every downstream consumer will read"
2030 );
2031 }
2032 }
2033
2034 #[test]
2035 fn caixa_dialeto_wire_names_covers_every_arm() {
2036 // Load-bearing pin on the substrate-canonical
2037 // [`super::CaixaDialeto::WIRE_NAMES`] exhaustive accept-set
2038 // roster on the `PascalCase` variant-name wire-form axis: every
2039 // variant of the sibling [`super::CaixaDialeto::ALL`] exhaustive-
2040 // iteration surface must project through
2041 // [`super::CaixaDialeto::as_str`] onto an entry the
2042 // [`super::CaixaDialeto::WIRE_NAMES`] roster carries, and the
2043 // roster's length must byte-equal `super::CaixaDialeto::ALL.len()`
2044 // so a silent skew between the [`super::CaixaDialeto::as_str`]
2045 // match's arm-set and the roster's arm-set trips here at
2046 // caixa-core test time rather than at a downstream `feira dialeto
2047 // --list-dialects` per-arm listing / M4 admission-webhook
2048 // rejection-body accepted-tag enumeration miss / structured-log
2049 // accepted-wire-form emit drift.
2050 //
2051 // A future arm addition (the module doc's "third dialect"
2052 // hazard actualising as a fifth arm — a third arity variant, an
2053 // alias-declaration family `pleme-doc-gen` sharpens as its
2054 // schema evolves) extends [`super::CaixaDialeto::ALL`] as a
2055 // single edit and this pin sweeps the new arm by iteration; the
2056 // paired [`super::CaixaDialeto::WIRE_NAMES`] roster must grow in
2057 // lockstep or this assertion trips. Every entry is further
2058 // pinned to open with an uppercase ASCII byte (matching the
2059 // substrate-wide `PascalCase` convention every peer closed-set
2060 // enum whose canonical projection is a `PascalCase` census-
2061 // facing name carries), so a silent collapse of the dialect-
2062 // classification wire-form axis with any hypothetical lowercase-
2063 // kebab peer wire-form axis (an entry byte-identical to a
2064 // sibling lowercase-Portuguese label that would let a wire-axis
2065 // consumer accept the diagnostic byte-string) trips here rather
2066 // than at a downstream census-report round-trip miss.
2067 //
2068 // Peer of the sibling
2069 // [`crate::kind::tests::caixa_kind_wire_names_covers_every_arm`]
2070 // (bd708bd) /
2071 // [`crate::kind::tests::caixa_kind_labels_covers_every_arm`]
2072 // (427fe75) /
2073 // [`crate::supervisor::tests::restart_strategy_wire_names_covers_every_arm`]
2074 // (3033f45) /
2075 // [`crate::supervisor::tests::restart_policy_wire_names_covers_every_arm`]
2076 // (ce9412b) /
2077 // [`crate::aplicacao::tests::placement_strategy_wire_names_covers_every_arm`]
2078 // (3e5b194) /
2079 // [`crate::aplicacao::tests::wit_shape_labels_covers_every_arm`]
2080 // (9d9f585) /
2081 // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
2082 // (b553ec9) /
2083 // [`crate::upgrade::tests::upgrade_instruction_lisp_forms_covers_every_arm`]
2084 // (1898d77) /
2085 // [`crate::upgrade::tests::upgrade_instruction_wire_forms_covers_every_arm`]
2086 // (cc42c0e) /
2087 // [`crate::dep::tests::dep_list_author_keys_covers_every_arm`]
2088 // (af6ad3a) /
2089 // [`crate::render::tests::path_shape_violation_wire_names_covers_every_arm`]
2090 // (0330bd3) pins — the same closed-set exhaustive-roster
2091 // coverage discipline extended here onto the tatara-lisp
2092 // dialect-classification closed-set typed enum, the eleventh
2093 // substrate-side closed-set typed enum on the roster axis and
2094 // the first dialect-classification axis to converge onto the
2095 // discipline.
2096 //
2097 // Fail-before-pass-after locally verified by mutating one arm
2098 // of the paired `CAIXA_DIALETO_WIRE_*` const family (e.g.
2099 // rebranding `CAIXA_DIALETO_WIRE_MOLDE_POSICIONAL` from
2100 // `"MoldePosicional"` to `"MoldePositional"`) — the length pin
2101 // still passes but the `contains` check fires on the mutated
2102 // arm; and by shortening the roster to three entries — the
2103 // length pin fires first.
2104 assert_eq!(
2105 CaixaDialeto::WIRE_NAMES.len(),
2106 CaixaDialeto::ALL.len(),
2107 "CaixaDialeto::WIRE_NAMES.len() must byte-equal \
2108 CaixaDialeto::ALL.len() — a mismatch means the roster and \
2109 the enum's arm-set have drifted; downstream consumers that \
2110 fan through both will silently disagree on the accepted \
2111 arm-set"
2112 );
2113 for &variant in CaixaDialeto::ALL {
2114 let wire = variant.as_str();
2115 assert!(
2116 CaixaDialeto::WIRE_NAMES.contains(&wire),
2117 "CaixaDialeto::{variant:?}.as_str() = {wire:?} must be \
2118 a member of CaixaDialeto::WIRE_NAMES — the emitter and \
2119 the roster have drifted out of lockstep"
2120 );
2121 }
2122 for tag in CaixaDialeto::WIRE_NAMES {
2123 let first = tag.chars().next().unwrap_or_else(|| {
2124 panic!(
2125 "CaixaDialeto::WIRE_NAMES entry {tag:?} must be a \
2126 non-empty `PascalCase` variant-name byte-string"
2127 )
2128 });
2129 assert!(
2130 first.is_ascii_uppercase(),
2131 "CaixaDialeto::WIRE_NAMES entry {tag:?} must open with \
2132 an uppercase ASCII byte (matching the substrate-wide \
2133 `PascalCase` convention) — an entry opening with a \
2134 lowercase byte would collide the roster with any \
2135 hypothetical peer lowercase-kebab wire-form axis a \
2136 downstream consumer might disambiguate against"
2137 );
2138 }
2139 // Pin the exact four-arm roster in declaration order so a
2140 // future arm-swap on either the roster or the paired
2141 // `CAIXA_DIALETO_WIRE_*` constants (a rebrand of the arm-tag
2142 // mapping that leaves both the length pin and the membership
2143 // pin passing on their own) trips at caixa-core test time
2144 // under `assert_eq!`. Order matches variant declaration order
2145 // verbatim (`Pacote` → `Molde` → `MoldePosicional` →
2146 // `Desconhecido`) so the roster is the canonical ordering
2147 // every listing / rendering consumer defers to. Same
2148 // declaration-order pin the sibling
2149 // [`crate::render::tests::path_shape_violation_wire_names_covers_every_arm`]
2150 // (0330bd3) closes on the render-side path-shape-diagnostic
2151 // axis.
2152 assert_eq!(
2153 CaixaDialeto::WIRE_NAMES,
2154 &[
2155 CAIXA_DIALETO_WIRE_PACOTE,
2156 CAIXA_DIALETO_WIRE_MOLDE,
2157 CAIXA_DIALETO_WIRE_MOLDE_POSICIONAL,
2158 CAIXA_DIALETO_WIRE_DESCONHECIDO,
2159 ],
2160 "CaixaDialeto::WIRE_NAMES must enumerate every arm's wire-\
2161 form tag exactly once, in variant declaration order \
2162 (Pacote → Molde → MoldePosicional → Desconhecido)"
2163 );
2164 // Byte-parity pin on the paired reverse projection: every
2165 // entry in the roster must round-trip cleanly through
2166 // [`super::CaixaDialeto::from_wire`] back to the same arm the
2167 // [`super::CaixaDialeto::as_str`] emitter returned it for.
2168 // Refuses any future de-lift that swaps the four consts through
2169 // the reverse projection out of lockstep with the forward
2170 // emitter (a mid-arm rebrand touching only `as_str` but not
2171 // `from_wire`, an argument-ordering swap on one of the match
2172 // arms, a stray `to_lowercase` normalization on either side
2173 // that would silently pass the identity round-trip on the
2174 // already-PascalCase corpus but split the two projections on
2175 // any future non-PascalCase input).
2176 for (&variant, tag) in CaixaDialeto::ALL.iter().zip(CaixaDialeto::WIRE_NAMES) {
2177 assert_eq!(
2178 CaixaDialeto::from_wire(tag),
2179 Some(variant),
2180 "CaixaDialeto::from_wire({tag:?}) must round-trip back \
2181 to CaixaDialeto::{variant:?} — emitter and parser have \
2182 drifted off the paired CAIXA_DIALETO_WIRE_* const family"
2183 );
2184 }
2185 }
2186
2187 #[test]
2188 fn caixa_dialeto_display_routes_through_as_str_helper() {
2189 // Fail-before-pass-after convergence pin: for every arm in
2190 // [`CaixaDialeto::ALL`], the [`std::fmt::Display`] rendered form
2191 // must byte-equal [`CaixaDialeto::as_str`]'s return value. Pre-
2192 // lift these two paths were structurally independent — the
2193 // Display impl hand-rolled its own four-arm literal-string
2194 // match with no compile-time link back to any substrate accessor
2195 // — so a future variant rename could land at `Display` without
2196 // touching a paired accessor (or vice versa), silently splitting
2197 // the two paths on the renamed arm. Pinning the byte-equality
2198 // here makes any such split a caixa-core build-time failure at
2199 // this test rather than surfacing far from the rename commit as
2200 // a downstream census consumer emitting one spelling while the
2201 // typed accessor returned another. Peer of the sibling
2202 // [`crate::kind::tests::caixa_kind_display_routes_through_as_str_helper`]
2203 // (which pins the same convergence on the [`crate::CaixaKind`]
2204 // closed-set axis) — extends the discipline onto the seventh
2205 // (and last unlifted) closed-set fieldless typed enum on the
2206 // caixa surface.
2207 for &variant in CaixaDialeto::ALL {
2208 assert_eq!(
2209 variant.to_string(),
2210 variant.as_str(),
2211 "CaixaDialeto::{variant:?} Display must route through \
2212 CaixaDialeto::as_str (single source of truth: the \
2213 lifted per-arm `PascalCase` variant-name byte-string)"
2214 );
2215 }
2216 }
2217
2218 #[test]
2219 fn caixa_dialeto_as_ref_str_routes_through_as_str_accessor() {
2220 // Fail-before-pass-after byte-parity pin on the lifted
2221 // `impl AsRef<str> for CaixaDialeto` — asserts the standard-
2222 // library trait impl and the substrate-primitive
2223 // [`CaixaDialeto::as_str`] `pub const fn` accessor resolve to
2224 // the same `&str` per instance across the four-arm closed set,
2225 // so any future silent detour that routes the impl through a
2226 // divergent projection (a per-arm inline
2227 // `match self { CaixaDialeto::Pacote => "Pacote", … }` re-inlining
2228 // that opens a compile-time link to the un-lifted arm-literal,
2229 // a swap onto the second-axis
2230 // [`CaixaDialeto::palavra_canonica`] /
2231 // [`CaixaDialeto::consumidor`] / [`CaixaDialeto::descricao`]
2232 // accessors that carry distinct byte-shapes per axis) trips at
2233 // caixa-core test time under `PartialEq` rather than at a
2234 // downstream `impl AsRef<str>`-bound consumer's silent split.
2235 // Sweeps every one of the four arms [`CaixaDialeto::ALL`]
2236 // carries so no arm's projection is covered only by the sibling
2237 // `Display` path. Peer of the sibling
2238 // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
2239 // (d8136db) on the M3 `:politicas :rate-limit` closed-set typed
2240 // enum, and the peer
2241 // [`crate::kind::tests::caixa_kind_as_ref_str_routes_through_as_str_accessor`]
2242 // (cd2091f) pin on the top-level closed-set typed
2243 // discriminator — the pins together close the substrate
2244 // primitive's `AsRef<str>` projection axis onto the seventh
2245 // closed-set fieldless typed enum on the caixa surface.
2246 for &variant in CaixaDialeto::ALL {
2247 assert_eq!(
2248 <CaixaDialeto as AsRef<str>>::as_ref(&variant),
2249 variant.as_str(),
2250 "AsRef<str> impl on CaixaDialeto::{variant:?} must \
2251 byte-equal CaixaDialeto::as_str on the same instance \
2252 — divergence signals a silent detour off the \
2253 substrate-primitive accessor"
2254 );
2255 }
2256 }
2257
2258 #[test]
2259 fn caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor() {
2260 // Fail-before-pass-after byte-parity pin on the three-path
2261 // convergence discipline the [`CaixaDialeto`] closed-set
2262 // dialect-classification enum now carries on the `&str`-
2263 // projection axis: `<CaixaDialeto as AsRef<str>>::as_ref(&v)`
2264 // (the newly lifted impl), `format!("{v}")` (the pre-existing
2265 // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
2266 // primitive `pub const fn` accessor both trait impls delegate
2267 // through) must resolve to the same byte-string on every
2268 // instance across the four-arm closed set. Refuses any future
2269 // divergence between the two trait impls (a stray
2270 // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
2271 // rather than delegating through the shared accessor; a
2272 // hypothetical `AsRef<str>` rewrite that inlines a per-arm
2273 // literal cascade) that would silently split the two
2274 // projection paths of the same closed-set typed enum. Mirrors
2275 // the sibling three-path-convergence discipline the peer
2276 // [`crate::aplicacao::RateLimitUnit`] typed enum carries
2277 // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
2278 // d8136db), the peer [`crate::CaixaKind`] triple
2279 // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
2280 // cd2091f), and the [`crate::CaixaVersion`] typed newtype
2281 // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
2282 // 16d5c7e).
2283 for &variant in CaixaDialeto::ALL {
2284 let via_as_ref: &str = <CaixaDialeto as AsRef<str>>::as_ref(&variant);
2285 let via_display: String = format!("{variant}");
2286 let via_accessor: &str = variant.as_str();
2287 assert_eq!(via_as_ref, via_accessor);
2288 assert_eq!(via_display, via_accessor);
2289 assert_eq!(via_as_ref, via_display.as_str());
2290 }
2291 }
2292
2293 #[test]
2294 fn caixa_dialeto_is_molde_family_returns_true_on_molde_and_positional_arms() {
2295 // Fail-before-pass-after per-arm shape pin on the two `defmolde`
2296 // declaration-family arms: [`CaixaDialeto::is_molde_family`] must
2297 // return `true` for [`CaixaDialeto::Molde`] and
2298 // [`CaixaDialeto::MoldePosicional`] — the two-arity closure of
2299 // one declaration ([`CaixaDialeto::MoldePosicional`]'s docstring:
2300 // "same declaration as [`Self::Molde`], written with the package
2301 // name as a bare positional symbol … one arity of one
2302 // declaration, not a third schema"). A future accidental flip that
2303 // reversed a per-arm arm's return without touching the paired
2304 // false-arm pin would silently open the substrate primitive to
2305 // false-positive on either arm — the `feira dialeto` verb's
2306 // `--strict-palavra` gate would then silently accept
2307 // repo-surface declarations under `(defcaixa …)` on one arm and
2308 // reject them on the other. Pinning the two true arms explicitly
2309 // here refuses that split at caixa-core build time.
2310 assert!(
2311 CaixaDialeto::Molde.is_molde_family(),
2312 "CaixaDialeto::Molde.is_molde_family() must return true — \
2313 Molde is the primary `defmolde` arm"
2314 );
2315 assert!(
2316 CaixaDialeto::MoldePosicional.is_molde_family(),
2317 "CaixaDialeto::MoldePosicional.is_molde_family() must return \
2318 true — MoldePosicional is the positional-arity form of the \
2319 same `defmolde` declaration Molde carries"
2320 );
2321 }
2322
2323 #[test]
2324 fn caixa_dialeto_is_molde_family_returns_false_on_pacote_and_desconhecido_arms() {
2325 // Fail-before-pass-after per-arm shape pin on the two non-`defmolde`
2326 // arms: [`CaixaDialeto::is_molde_family`] must return `false` for
2327 // [`CaixaDialeto::Pacote`] (the sibling `defcaixa` tatara-lisp
2328 // package manifest, `palavra_canonica → "defcaixa"`) and for
2329 // [`CaixaDialeto::Desconhecido`] (the residue that names no
2330 // known declaration, `palavra_canonica → "?"`). Pinning the two
2331 // false arms explicitly here refuses a future accidental flip
2332 // that let the predicate widen to include either arm — the
2333 // `feira dialeto` verb's `--strict-palavra` gate would then
2334 // spuriously refuse every `(defcaixa …)` package manifest as if
2335 // it were a repo-surface declaration.
2336 assert!(
2337 !CaixaDialeto::Pacote.is_molde_family(),
2338 "CaixaDialeto::Pacote.is_molde_family() must return false — \
2339 Pacote is the `defcaixa` tatara-lisp package manifest, not \
2340 the `defmolde` repo-surface declaration"
2341 );
2342 assert!(
2343 !CaixaDialeto::Desconhecido.is_molde_family(),
2344 "CaixaDialeto::Desconhecido.is_molde_family() must return \
2345 false — the residue arm names no known declaration; it is \
2346 not silently promoted into the `defmolde` family"
2347 );
2348 }
2349
2350 #[test]
2351 fn caixa_dialeto_is_molde_family_agrees_with_palavra_canonica_defmolde_projection() {
2352 // Load-bearing pin: for every arm in [`CaixaDialeto::ALL`], the
2353 // typed [`CaixaDialeto::is_molde_family`] predicate must agree
2354 // byte-for-byte with the paired [`CaixaDialeto::palavra_canonica`]
2355 // projection's `== "defmolde"` classifier — i.e. the two paths
2356 // partition the four-arm discriminator set into the same
2357 // `{Molde, MoldePosicional}` and `{Pacote, Desconhecido}` halves.
2358 // Pre-lift the sibling [`CaixaDialeto::palavra_canonica`] projection
2359 // (which returns `"defmolde"` for `Molde | MoldePosicional`,
2360 // `"defcaixa"` for `Pacote`, `"?"` for `Desconhecido`) was the
2361 // only substrate-side surface carrying the two-arm collapse; the
2362 // hand-rolled `matches!(d, CaixaDialeto::Molde |
2363 // CaixaDialeto::MoldePosicional)` sites in the `feira dialeto`
2364 // verb expressed no compile-time link back to it. A future arm
2365 // addition — the module doc's "third dialect" hazard actualises
2366 // as a fifth arm belonging to the `defmolde` family — would land
2367 // one match arm at [`Self::palavra_canonica`]'s `defmolde` return
2368 // (extending the sibling projection) but silently split the
2369 // hand-rolled two-arm `matches!` predicate sites if the new arm's
2370 // `is_molde_family` return were forgotten. Pinning byte-equality
2371 // between the two paths here makes any such split a caixa-core
2372 // build-time failure at this test rather than surfacing far from
2373 // the arm-addition commit as a downstream `--strict-palavra` /
2374 // `caixa.lisp`-holds-wrong-declaration gate silently ignoring the
2375 // new arm.
2376 for &d in CaixaDialeto::ALL {
2377 let via_palavra_canonica = d.palavra_canonica() == "defmolde";
2378 let via_is_molde_family = d.is_molde_family();
2379 assert_eq!(
2380 via_is_molde_family, via_palavra_canonica,
2381 "CaixaDialeto::{d:?}.is_molde_family() ({via_is_molde_family}) \
2382 must agree with CaixaDialeto::{d:?}.palavra_canonica() == \
2383 \"defmolde\" ({via_palavra_canonica}) — a split between the \
2384 typed predicate and the sibling keyword projection would let \
2385 a future arm addition land at one path and drift at the other, \
2386 which is exactly the drift this pin refuses"
2387 );
2388 }
2389 }
2390
2391 #[test]
2392 fn caixa_dialeto_is_molde_family_is_const_fn() {
2393 // Const-context pin: [`CaixaDialeto::is_molde_family`] must remain
2394 // `const fn` (its match is a fieldless-arm literal-pattern
2395 // discriminator, so no non-const operation exists on the resolution
2396 // path). Downstream consumers reaching for the predicate from a
2397 // `const` context (a future substrate-wide const-fold-driven audit
2398 // table that materializes per-arm gate-membership at build time,
2399 // a per-arm CR-admission-webhook gate registration in a `const`
2400 // context) rely on the const-ness. A future accidental downgrade
2401 // to non-`const` (an added runtime helper reachable only from a
2402 // non-`const` context) trips at caixa-core build time rather than
2403 // surfacing as a downstream `const`-context regression far from
2404 // the predicate declaration. Peer of the sibling
2405 // [`caixa_dialeto_as_str_is_const_fn`] pin on the paired
2406 // [`CaixaDialeto::as_str`] byte-string axis.
2407 const ARMS: [(CaixaDialeto, bool); 4] = [
2408 (CaixaDialeto::Pacote, CaixaDialeto::Pacote.is_molde_family()),
2409 (CaixaDialeto::Molde, CaixaDialeto::Molde.is_molde_family()),
2410 (
2411 CaixaDialeto::MoldePosicional,
2412 CaixaDialeto::MoldePosicional.is_molde_family(),
2413 ),
2414 (
2415 CaixaDialeto::Desconhecido,
2416 CaixaDialeto::Desconhecido.is_molde_family(),
2417 ),
2418 ];
2419 // Materialize the const-fold-evaluated table into a runtime slice
2420 // assertion — carries the same `bool = const fn call` shape a raw
2421 // `assert!(const_bool)` would, without tripping the
2422 // `assertions_on_constants` clippy lint that a per-arm
2423 // `assert!(CONST)` on a `const bool` triggers when the arm-count
2424 // is enumerated flat rather than compared as a whole-table shape.
2425 assert_eq!(
2426 ARMS,
2427 [
2428 (CaixaDialeto::Pacote, false),
2429 (CaixaDialeto::Molde, true),
2430 (CaixaDialeto::MoldePosicional, true),
2431 (CaixaDialeto::Desconhecido, false),
2432 ],
2433 "CaixaDialeto::is_molde_family() must evaluate in const context \
2434 for every arm and land on the {{false, true, true, false}} \
2435 partition — a future accidental downgrade to non-`const` \
2436 would trip the const-context array-initializer here"
2437 );
2438 }
2439
2440 #[test]
2441 fn caixa_dialeto_as_str_is_const_fn() {
2442 // Const-context pin: [`CaixaDialeto::as_str`] must remain
2443 // `const fn` (its match arms return `pub const` byte-strings, so
2444 // no non-const operation exists on the resolution path).
2445 // Downstream consumers reaching for the accessor from a `const`
2446 // context (a future substrate-wide const-fold-driven audit table
2447 // that materializes every dialect's census label at build time,
2448 // a per-arm CR-admission-webhook message registration in a
2449 // `const` gate) rely on the const-ness. A future accidental
2450 // downgrade to non-`const` (an added runtime helper reachable
2451 // only from a non-`const` context, a manual hand-rolled `impl`
2452 // that shadows this method) trips at caixa-core build time
2453 // rather than surfacing as a downstream `const`-context
2454 // regression far from the accessor declaration. Peer of the
2455 // sibling [`crate::kind::tests::caixa_kind_wire_name_is_const_fn`]
2456 // pin on the paired [`crate::CaixaKind`] byte-string axis.
2457 const PACOTE: &str = CaixaDialeto::Pacote.as_str();
2458 const MOLDE: &str = CaixaDialeto::Molde.as_str();
2459 const MOLDE_POSICIONAL: &str = CaixaDialeto::MoldePosicional.as_str();
2460 const DESCONHECIDO: &str = CaixaDialeto::Desconhecido.as_str();
2461 assert_eq!(PACOTE, "Pacote");
2462 assert_eq!(MOLDE, "Molde");
2463 assert_eq!(MOLDE_POSICIONAL, "MoldePosicional");
2464 assert_eq!(DESCONHECIDO, "Desconhecido");
2465 }
2466
2467 #[test]
2468 fn caixa_dialeto_is_variant_predicates_partition_the_arm_set() {
2469 // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
2470 // derive: for each of the four variants at [`CaixaDialeto::ALL`]`[idx]`
2471 // the observed four-slot predicate row must equal a one-hot row
2472 // with the `true` at exactly `idx`. Pre-derive the closed four-arm
2473 // dialect-classification partition lived only inside the paired
2474 // per-arm projections' four-arm match resolvers ([`Self::as_str`] /
2475 // [`Self::palavra_canonica`] / [`Self::consumidor`] /
2476 // [`Self::descricao`]) plus the two-arm [`Self::is_molde_family`]
2477 // hand-rolled `matches!` (now routed through the derived
2478 // predicates); a future rebrand (an accidental
2479 // `#[is_variant(name = "…")]` drift, a manual hand-rolled `impl`
2480 // that shadows the derive-generated method, an arm rename that
2481 // reroutes one arm through the wrong predicate lane) trips this
2482 // pin at caixa-core build time rather than surfacing far from the
2483 // derive declaration as a downstream [`Self::is_molde_family`]
2484 // consumer accepting the wrong arm-set. The expected row is
2485 // generated live from the [`Self::ALL`] declaration order rather
2486 // than transcribed by hand so a copy-paste flip reroutes at the
2487 // identity-diagonal assertion.
2488 //
2489 // Peer of the sibling
2490 // [`crate::kind::tests::caixa_kind_is_variant_predicates_partition_the_arm_set`]
2491 // / [`crate::supervisor::tests::restart_strategy_is_variant_predicates_partition_the_arm_set`]
2492 // / [`crate::aplicacao::tests::placement_strategy_is_variant_predicates_partition_the_arm_set`]
2493 // / [`crate::upgrade::tests::upgrade_instruction_is_variant_predicates_partition_the_arm_set`]
2494 // pins on the sibling closed-set typed-enum discriminator axes.
2495 for (idx, &variant) in CaixaDialeto::ALL.iter().enumerate() {
2496 let observed = [
2497 variant.is_pacote(),
2498 variant.is_molde(),
2499 variant.is_molde_posicional(),
2500 variant.is_desconhecido(),
2501 ];
2502 let mut expected = [false; 4];
2503 expected[idx] = true;
2504 assert_eq!(
2505 observed, expected,
2506 "CaixaDialeto::{variant:?} at ALL[{idx}] is_* predicates \
2507 must fire only on their own arm lane (identity diagonal); \
2508 got {observed:?}",
2509 );
2510 }
2511 }
2512
2513 #[test]
2514 fn caixa_dialeto_is_variant_predicates_are_const_fn() {
2515 // The [`gen_platform::IsVariant`] derive emits `const fn`
2516 // predicates on the peer [`crate::CaixaKind`] +
2517 // [`crate::upgrade::UpgradeInstruction`] +
2518 // [`crate::supervisor::RestartStrategy`] +
2519 // [`crate::supervisor::RestartPolicy`] +
2520 // [`crate::aplicacao::PlacementStrategy`] +
2521 // [`crate::aplicacao::RateLimitUnit`] +
2522 // [`crate::dep::DepList`] closed-set typed enums — pin the same
2523 // posture on [`CaixaDialeto`] so a future accidental downgrade
2524 // to non-`const` (an added runtime helper reachable only from a
2525 // non-`const` context, a manual hand-rolled `impl` that shadows
2526 // the derive-generated method) trips at caixa-core build time
2527 // rather than surfacing as a downstream `const`-context
2528 // regression far from the derive declaration.
2529 // Use `const { assert!(…) }` (peer of the sibling
2530 // [`crate::render::PathShapeViolation`] +
2531 // [`crate::aplicacao::RateLimitUnit`] +
2532 // [`caixa_theme::style::Semantic`] const-fn pins) so the
2533 // const-context evaluation trips at const-fold time without
2534 // opening a per-`const bool` `assertions_on_constants` clippy
2535 // debt row this crate does not carry today for `dialeto.rs`.
2536 const { assert!(CaixaDialeto::Pacote.is_pacote()) };
2537 const { assert!(CaixaDialeto::Molde.is_molde()) };
2538 const { assert!(CaixaDialeto::MoldePosicional.is_molde_posicional()) };
2539 const { assert!(CaixaDialeto::Desconhecido.is_desconhecido()) };
2540 }
2541
2542 #[test]
2543 fn caixa_dialeto_from_wire_accepts_every_as_str_output() {
2544 // Fail-before-pass-after per-arm accept pin on the newly lifted
2545 // [`CaixaDialeto::from_wire`] reverse projection: every arm in
2546 // [`CaixaDialeto::ALL`] must parse back through `from_wire` when
2547 // fed its own [`CaixaDialeto::as_str`] output, landing on
2548 // `Some(same_variant)` — a regression that hand-rolled either
2549 // side's per-arm match without threading through the shared
2550 // four-string closed set would silently disagree on any future
2551 // arm rename and this pin flags it at caixa-core build time.
2552 // Peer of the sibling
2553 // [`crate::kind::tests::caixa_kind_wire_round_trips_through_from_wire`]
2554 // (2aa6d23) /
2555 // `placement_strategy_from_wire_accepts_every_lifted_constant`
2556 // (18c7342) /
2557 // `dep_list_round_trips_through_as_str_and_from_wire` (45ee563)
2558 // shape on the sibling closed-set typed-enum reverse-projection
2559 // axes.
2560 for &variant in CaixaDialeto::ALL {
2561 let wire = variant.as_str();
2562 let parsed = CaixaDialeto::from_wire(wire).unwrap_or_else(|| {
2563 panic!(
2564 "CaixaDialeto::from_wire({wire:?}) must accept every \
2565 CaixaDialeto::as_str output — got None for the \
2566 wire byte-string of {variant:?}"
2567 )
2568 });
2569 assert_eq!(
2570 parsed, variant,
2571 "CaixaDialeto::from_wire(CaixaDialeto::{variant:?}.as_str()) \
2572 must return CaixaDialeto::{variant:?} — the (as_str, \
2573 from_wire) pair must form a total round-trip on the \
2574 closed four-arm CaixaDialeto arm-set"
2575 );
2576 }
2577 }
2578
2579 #[test]
2580 fn caixa_dialeto_from_wire_rejects_unknown_byte_strings() {
2581 // Rejection pin on the parser's accept-set: any string outside
2582 // the four-arm [`CaixaDialeto::as_str`] output set must return
2583 // `None`. A future accidental widening of the accept-set (a
2584 // case-insensitive match that accepts `"pacote"` on the wire
2585 // axis, a hand-rolled Levenshtein-forgiving arm-lookup that
2586 // admits `"Pacotee"` typos, a silent acceptance of the sibling
2587 // [`Self::palavra_canonica`] `"defcaixa"` / `"defmolde"`
2588 // byte-shapes on this axis) would silently drift the parser's
2589 // accept-set from the emitter's — a downstream audit-report
2590 // re-loader that bound a prior audit's [`Self::as_str`] output
2591 // back to the typed enum through this parser would then bind a
2592 // malformed byte-string to a plausibly-wrong typed arm the
2593 // caller does not route through any fallback, silently
2594 // misclassifying the reloaded row. Also rejects the sibling
2595 // [`Self::palavra_canonica`] (`"defcaixa"` / `"defmolde"`) and
2596 // the sibling [`Self::consumidor`] (`"caixa-core / feira"`,
2597 // `"pleme-doc-gen"`, `"nobody known"`) byte-shapes, which are
2598 // the substrate's *distinct-axis* projections on the same enum
2599 // — the two-axis split the sibling
2600 // [`Self::palavra_canonica`] / [`Self::consumidor`] /
2601 // [`Self::descricao`] docstrings explicitly frame forbids
2602 // accepting one axis's byte-shapes as parseable on the other
2603 // axis. Peer of the sibling
2604 // [`crate::kind::tests::caixa_kind_from_wire_rejects_unknown_byte_strings`]
2605 // (2aa6d23) /
2606 // `placement_strategy_from_wire_rejects_unknown_byte_strings`
2607 // (18c7342) /
2608 // `dep_list_from_wire_returns_none_on_unknown_wire_scalar`
2609 // (45ee563) rejection pins on the sibling closed-set typed-enum
2610 // reverse-projection axes.
2611 for bad in [
2612 "",
2613 " ",
2614 "pacote",
2615 "PACOTE",
2616 "molde",
2617 "MoldePositional",
2618 "desconhecido",
2619 "Unknown",
2620 "defcaixa",
2621 "defmolde",
2622 "?",
2623 "caixa-core / feira",
2624 "pleme-doc-gen",
2625 "nobody known",
2626 "Pacote ",
2627 " Pacote",
2628 ] {
2629 assert!(
2630 CaixaDialeto::from_wire(bad).is_none(),
2631 "CaixaDialeto::from_wire({bad:?}) must return None — the \
2632 parser's accept-set is exactly the four CaixaDialeto::as_str \
2633 outputs; a widening would silently split the parser's \
2634 accept-set from the emitter's arm-set"
2635 );
2636 }
2637 }
2638
2639 #[test]
2640 fn cabeca_errada_ctor_matches_struct_literal_wrap() {
2641 // Fail-before-pass-after byte-identity pin: the lifted
2642 // [`DialetoError::cabeca_errada`] ctor MUST land on the exact
2643 // same struct-literal shape the pre-lift open-coded wire-up
2644 // block wrote by hand — `DialetoError::CabecaErrada {
2645 // encontrado: <head>.to_string() }`. A future accidental
2646 // divergence (`.into()` swap, per-arm constant substitution, an
2647 // added default field, an `.to_ascii_lowercase()` normalization
2648 // silently injected into the ctor body, a rebrand of the
2649 // `encontrado` field carrying a distinct byte-shape) trips this
2650 // pin at caixa-core build time rather than surfacing far from
2651 // the ctor declaration as a downstream `classify_form`
2652 // wrong-head consumer emitting one diagnostic shape while a
2653 // hand-written test peer opens another. Peer of the sibling
2654 // `unknown_byte_unit_ctor_matches_struct_literal_wrap`
2655 // (limits.rs; 29fac09) / `duplicate_from_ctor_matches_struct_
2656 // literal_wrap` (upgrade.rs; 7e52aec) shape on the sibling
2657 // single-slot `{ <field>: String }` envelope constructors.
2658 assert_eq!(
2659 DialetoError::cabeca_errada("defflake"),
2660 DialetoError::CabecaErrada {
2661 encontrado: "defflake".to_string(),
2662 },
2663 "DialetoError::cabeca_errada must byte-equal the pre-lift \
2664 open-coded struct-literal — a drift here means the ctor \
2665 stopped being a substrate primitive for the wrong-head \
2666 fallthrough site"
2667 );
2668 }
2669
2670 #[test]
2671 fn cabeca_errada_routes_encontrado_verbatim_across_boundary_inputs() {
2672 // Fail-before-pass-after boundary-sweep pin: the lifted
2673 // [`DialetoError::cabeca_errada`] ctor MUST route its
2674 // `encontrado: &str` argument verbatim into the
2675 // [`DialetoError::CabecaErrada`] `encontrado: String` field
2676 // for every boundary-covering `&str` input — empty string, a
2677 // canonical `defcaixa`-adjacent head, a non-ASCII head, a
2678 // whitespace-carrying head, a Unicode-full-width head. Any
2679 // wrapper-side truncation, silent `.trim()`, accidental
2680 // `.to_ascii_lowercase()` normalization, or `.into()` divergence
2681 // on the ctor body surfaces here as a byte-mismatch against the
2682 // input rather than at a downstream
2683 // [`DialetoError::to_string()`] diagnostic-shape drift at a
2684 // wrong-head fallthrough consumer far from the ctor declaration.
2685 // Peer of the sibling `limits_codec_unit_only_ctors_route_unit_
2686 // verbatim_across_every_variant` (limits.rs; 29fac09) shape on
2687 // the sibling single-slot `{ <field>: String }` envelope
2688 // boundary-sweep discipline.
2689 for encontrado in [
2690 "",
2691 "defflake",
2692 "def-molde",
2693 "defcaixa ",
2694 " defcaixa",
2695 "μdefcaixa",
2696 "\u{00A0}defcaixa",
2697 "\u{3000}defcaixa",
2698 "def\u{2028}caixa",
2699 ] {
2700 let via_ctor = DialetoError::cabeca_errada(encontrado);
2701 let via_literal = DialetoError::CabecaErrada {
2702 encontrado: encontrado.to_string(),
2703 };
2704 assert_eq!(
2705 via_ctor, via_literal,
2706 "DialetoError::cabeca_errada({encontrado:?}) must byte- \
2707 equal the open-coded struct-literal on the same input — \
2708 a drift here would let the ctor silently normalize / \
2709 truncate the head symbol before it reached the \
2710 CabecaErrada envelope"
2711 );
2712 let DialetoError::CabecaErrada { encontrado: routed } = via_ctor else {
2713 panic!(
2714 "DialetoError::cabeca_errada must construct the \
2715 CabecaErrada arm — got a different variant on \
2716 input {encontrado:?}"
2717 );
2718 };
2719 assert_eq!(
2720 routed, encontrado,
2721 "DialetoError::cabeca_errada must route the input \
2722 {encontrado:?} verbatim into the encontrado field — \
2723 any wrapper-side truncation / normalization surfaces \
2724 here rather than at a downstream diagnostic shape drift"
2725 );
2726 }
2727 }
2728
2729 #[test]
2730 fn classify_form_wrong_head_routes_through_cabeca_errada_ctor() {
2731 // Fail-before-pass-after routing pin: [`classify`]'s wrong-head
2732 // fallthrough site MUST construct its `Err(DialetoError::…)`
2733 // through the substrate-primitive [`DialetoError::cabeca_errada`]
2734 // ctor rather than through an open-coded struct-literal. Pre-
2735 // lift the wire-up hand-rolled a three-line
2736 // `Self::CabecaErrada { encontrado: other.to_string() }` block
2737 // with no compile-time link back to the substrate primitive; a
2738 // future accidental rebrand of the ctor body (an added
2739 // `.trim()` on `encontrado`, a per-arm constant prefix like
2740 // `"unknown-head:"`, a widening of the field into a
2741 // `(String, usize)` tuple carrying a caret offset) would then
2742 // silently split the two paths — the ctor consumers pick up
2743 // the new shape, the open-coded wire-up does not. Pinning
2744 // byte-equality between the observed `Err` and the ctor-
2745 // constructed `Err` refuses that split at caixa-core build
2746 // time rather than surfacing far from the wire-up commit as a
2747 // downstream diagnostic-consumer split.
2748 for head in ["defflake", "deffoobar", "defcaixaz", "let", "defmoldez"] {
2749 let src = format!("({head} :nome \"x\")");
2750 let observed = classify(&src);
2751 let via_ctor = Err(DialetoError::cabeca_errada(head));
2752 assert_eq!(
2753 observed, via_ctor,
2754 "classify({src:?}) must return the same Err shape as \
2755 DialetoError::cabeca_errada({head:?}) — a drift here \
2756 means the wire-up de-lifted its wrong-head fallthrough \
2757 arm off the substrate primitive"
2758 );
2759 }
2760 }
2761
2762 #[test]
2763 fn leitura_ctor_matches_tuple_literal_wrap_on_str_binding() {
2764 // Fail-before-pass-after byte-identity pin: the lifted
2765 // [`DialetoError::leitura`] ctor MUST land on the exact same
2766 // tuple-newtype wrap the pre-lift open-coded wire-up block wrote by
2767 // hand — `DialetoError::Leitura(<into-String-expr>)`. A future
2768 // accidental divergence (an added `.trim()` on the reader reason,
2769 // a per-arm constant prefix like `"tatara-lisp:"`, a widening of
2770 // the tuple carrying a caret offset, a rebrand of the payload
2771 // carrying a distinct byte-shape) trips this pin at caixa-core
2772 // build time rather than surfacing far from the ctor declaration
2773 // as a downstream [`classify`] tatara-lisp-reader consumer
2774 // emitting one diagnostic shape while a hand-written test peer
2775 // opens another. Peer of the sibling
2776 // `cabeca_errada_ctor_matches_struct_literal_wrap` pin above on
2777 // the same [`DialetoError`] envelope's wrong-head axis, and of
2778 // the peer `LimitsError::empty_byte_size` /
2779 // `LimitsError::empty_duration` (7a4b003 / 319216c) shape on the
2780 // sibling `(String)` single-slot tuple-newtype envelope
2781 // constructors.
2782 let reason: &str = "unclosed paren at 1:12";
2783 assert_eq!(
2784 DialetoError::leitura(reason),
2785 DialetoError::Leitura(reason.to_string()),
2786 "DialetoError::leitura must byte-equal the pre-lift open-coded \
2787 tuple-newtype wrap — a drift here means the ctor stopped \
2788 being a substrate primitive for the tatara-lisp-reader \
2789 fallthrough site"
2790 );
2791 }
2792
2793 #[test]
2794 fn leitura_ctor_matches_tuple_literal_wrap_on_string_binding() {
2795 // Fail-before-pass-after byte-identity pin on the `String` wire-up
2796 // shape: the lifted [`DialetoError::leitura`] ctor MUST land on
2797 // the same tuple-newtype wrap when the caller passes an owned
2798 // `String` (the actual [`classify`] wire-up shape — `e.to_string()`
2799 // on a [`tatara_lisp::Error`]-carrying binding). Pins that the
2800 // `impl Into<String>` param covers the owned-`String` path with no
2801 // silent double-allocation or intermediate `&str` reslicing. Peer
2802 // of the sibling `_on_str_binding` pin above — together they close
2803 // the `impl Into<String>` bound's two authored wire-up shapes on
2804 // the ctor's substrate primitive.
2805 let reason: String = String::from("read: unexpected EOF at 3:1");
2806 let via_ctor = DialetoError::leitura(reason.clone());
2807 let via_literal = DialetoError::Leitura(reason.clone());
2808 assert_eq!(
2809 via_ctor, via_literal,
2810 "DialetoError::leitura must byte-equal the pre-lift open-coded \
2811 tuple-newtype wrap on the same owned-String fixture — a drift \
2812 here would let the ctor silently reshape the reader reason \
2813 before it reached the Leitura envelope"
2814 );
2815 let DialetoError::Leitura(routed) = via_ctor else {
2816 panic!(
2817 "DialetoError::leitura must construct the Leitura arm — \
2818 got a different variant on input {reason:?}"
2819 );
2820 };
2821 assert_eq!(
2822 routed, reason,
2823 "DialetoError::leitura must route the input {reason:?} \
2824 verbatim into the tuple-newtype payload — any wrapper-side \
2825 truncation / normalization surfaces here rather than at a \
2826 downstream diagnostic shape drift"
2827 );
2828 }
2829
2830 #[test]
2831 fn leitura_routes_reason_verbatim_across_boundary_inputs() {
2832 // Fail-before-pass-after boundary-sweep pin: the lifted
2833 // [`DialetoError::leitura`] ctor MUST route its
2834 // `reason: impl Into<String>` argument verbatim into the
2835 // [`DialetoError::Leitura`] tuple-newtype `String` payload for
2836 // every boundary-covering input — empty string, a canonical
2837 // tatara-lisp reader error, a non-ASCII reason, a
2838 // whitespace-carrying reason, a Unicode-full-width reason. Any
2839 // wrapper-side truncation, silent `.trim()`, accidental
2840 // `.to_ascii_lowercase()` normalization, or `.into()` divergence
2841 // on the ctor body surfaces here as a byte-mismatch against the
2842 // input rather than at a downstream [`DialetoError::to_string()`]
2843 // diagnostic-shape drift at a tatara-lisp-reader fallthrough
2844 // consumer far from the ctor declaration. Peer of the sibling
2845 // `cabeca_errada_routes_encontrado_verbatim_across_boundary_inputs`
2846 // pin above on the same [`DialetoError`] envelope's wrong-head
2847 // axis.
2848 for reason in [
2849 "",
2850 "unclosed paren at 1:12",
2851 "unexpected token ')'",
2852 "read: eof",
2853 " leading whitespace",
2854 "trailing whitespace ",
2855 "μnicode reason",
2856 "\u{00A0}NBSP-prefixed reason",
2857 "\u{3000}ideographic-space reason",
2858 "reason\u{2028}with-line-separator",
2859 ] {
2860 let via_ctor = DialetoError::leitura(reason);
2861 let via_literal = DialetoError::Leitura(reason.to_string());
2862 assert_eq!(
2863 via_ctor, via_literal,
2864 "DialetoError::leitura({reason:?}) must byte-equal the \
2865 open-coded tuple-newtype wrap on the same input — a \
2866 drift here would let the ctor silently normalize / \
2867 truncate the reader reason before it reached the \
2868 Leitura envelope"
2869 );
2870 let DialetoError::Leitura(routed) = via_ctor else {
2871 panic!(
2872 "DialetoError::leitura must construct the Leitura \
2873 arm — got a different variant on input {reason:?}"
2874 );
2875 };
2876 assert_eq!(
2877 routed, reason,
2878 "DialetoError::leitura must route the input {reason:?} \
2879 verbatim into the tuple-newtype payload — any \
2880 wrapper-side truncation / normalization surfaces here \
2881 rather than at a downstream diagnostic shape drift"
2882 );
2883 }
2884 }
2885
2886 #[test]
2887 fn classify_reader_error_routes_through_leitura_ctor() {
2888 // Fail-before-pass-after routing pin: [`classify`]'s
2889 // tatara-lisp-reader map-err site MUST construct its
2890 // `Err(DialetoError::…)` through the substrate-primitive
2891 // [`DialetoError::leitura`] ctor rather than through an
2892 // open-coded tuple-newtype wrap. Pre-lift the wire-up hand-rolled
2893 // a `Self::Leitura(e.to_string())` block with no compile-time
2894 // link back to the substrate primitive; a future accidental
2895 // rebrand of the ctor body (an added `.trim()` on the reader
2896 // reason, a per-arm constant prefix like `"tatara-lisp:"`, a
2897 // widening of the payload into a `(String, usize)` tuple
2898 // carrying a caret offset) would then silently split the two
2899 // paths — the ctor consumers pick up the new shape, the
2900 // open-coded wire-up does not. Pinning byte-equality between
2901 // the observed `Err` and the ctor-constructed `Err` refuses
2902 // that split at caixa-core build time rather than surfacing far
2903 // from the wire-up commit as a downstream diagnostic-consumer
2904 // split. Peer of the sibling
2905 // `classify_form_wrong_head_routes_through_cabeca_errada_ctor`
2906 // pin above on the same [`DialetoError`] envelope's wrong-head
2907 // fallthrough axis.
2908 //
2909 // The malformed sources below each name a distinct
2910 // tatara-lisp-reader failure shape (unclosed paren, stray close
2911 // paren, unterminated string), so together they sweep the
2912 // reader's rejection surface rather than pinning against one
2913 // specific error message the reader upstream is free to reword.
2914 for src in [
2915 "(defcaixa :nome \"x\"",
2916 "defcaixa :nome \"x\")",
2917 "(defcaixa :nome \"unterminated",
2918 ] {
2919 let observed = classify(src);
2920 let Err(DialetoError::Leitura(reason)) = observed.clone() else {
2921 panic!(
2922 "classify({src:?}) must return the Leitura arm — got \
2923 {observed:?}"
2924 );
2925 };
2926 let via_ctor: Result<CaixaDialeto, DialetoError> =
2927 Err(DialetoError::leitura(reason.clone()));
2928 assert_eq!(
2929 observed, via_ctor,
2930 "classify({src:?}) must return the same Err shape as \
2931 DialetoError::leitura({reason:?}) — a drift here means \
2932 the wire-up de-lifted its tatara-lisp-reader fallthrough \
2933 arm off the substrate primitive"
2934 );
2935 }
2936 }
2937
2938 #[test]
2939 fn caixa_dialeto_try_from_str_routes_through_from_wire_accessor() {
2940 // Fail-before-pass-after byte-parity pin on the lifted
2941 // `impl TryFrom<&str> for CaixaDialeto`: for every arm in
2942 // [`CaixaDialeto::ALL`], the `.try_into()` / `TryFrom::try_from`
2943 // path must resolve to the same variant the sibling
2944 // [`CaixaDialeto::from_wire`] resolver returns on the same
2945 // [`CaixaDialeto::as_str`] wire byte-string input. Pins the
2946 // three-path convergence discipline the [`CaixaDialeto`] closed-
2947 // set typed enum now carries on the `str → Self` reverse-
2948 // projection axis: `<CaixaDialeto as TryFrom<&str>>::try_from(s)`
2949 // (the newly lifted trait-idiomatic reverse projection),
2950 // `CaixaDialeto::from_wire(s)` (the substrate-primitive method-
2951 // named `Option<Self>` accessor the trait impl delegates through),
2952 // and the round-trip identity `variant.as_str() → variant`
2953 // (the four-arm closed accept-set shared between the emitter and
2954 // both reverse-projection consumers) must resolve to the same
2955 // typed [`CaixaDialeto`] discriminator on every arm.
2956 //
2957 // A future silent detour that routes the impl through a
2958 // divergent projection (a per-arm inline
2959 // `match s { "Pacote" => …, … }` re-inlining that opens a
2960 // compile-time link to the un-lifted arm-literal, a swap onto
2961 // the second-axis [`CaixaDialeto::palavra_canonica`] /
2962 // [`CaixaDialeto::consumidor`] / [`CaixaDialeto::descricao`]
2963 // accessors that carry distinct byte-shapes per axis, an accept-
2964 // set widening that silently accepts one axis's byte-shapes as
2965 // parseable on the other axis) trips at caixa-core test time
2966 // under `assert_eq!` rather than at a downstream
2967 // `TryFrom<&str>`-bound consumer's silent split. Peer of the
2968 // sibling
2969 // [`crate::kind::tests::caixa_kind_try_from_str_routes_through_from_wire_accessor`]
2970 // (3c83606) on the top-level [`crate::CaixaKind`] closed-set
2971 // discriminator's reverse-projection axis — extends the trait-
2972 // idiomatic reverse-projection axis onto the seventh closed-set
2973 // fieldless typed enum on the caixa surface (the second one to
2974 // carry the paired `TryFrom<&str>` impl).
2975 for &variant in CaixaDialeto::ALL {
2976 let wire = variant.as_str();
2977 let via_try_from: CaixaDialeto = <CaixaDialeto as TryFrom<&str>>::try_from(wire)
2978 .unwrap_or_else(|()| {
2979 panic!(
2980 "CaixaDialeto::try_from({wire:?}) must accept every \
2981 CaixaDialeto::as_str output — got Err(()) for the \
2982 wire byte-string of {variant:?}"
2983 )
2984 });
2985 let via_from_wire: CaixaDialeto = CaixaDialeto::from_wire(wire).unwrap_or_else(|| {
2986 panic!(
2987 "CaixaDialeto::from_wire({wire:?}) must accept every \
2988 CaixaDialeto::as_str output — got None for the wire \
2989 byte-string of {variant:?}"
2990 )
2991 });
2992 assert_eq!(
2993 via_try_from, variant,
2994 "CaixaDialeto::try_from(CaixaDialeto::{variant:?}.as_str()) \
2995 must return CaixaDialeto::{variant:?} — the trait-idiomatic \
2996 reverse projection must land on the same arm the method-named \
2997 from_wire resolver does",
2998 );
2999 assert_eq!(
3000 via_try_from, via_from_wire,
3001 "CaixaDialeto::try_from({wire:?}) ({via_try_from:?}) must \
3002 byte-equal CaixaDialeto::from_wire({wire:?}) ({via_from_wire:?}) \
3003 on the same input — divergence signals a silent detour off the \
3004 shared substrate-primitive resolver",
3005 );
3006 assert_eq!(
3007 <CaixaDialeto as TryFrom<&str>>::try_from(wire).ok(),
3008 CaixaDialeto::from_wire(wire),
3009 "the Result::ok() projection of TryFrom<&str> must byte-equal \
3010 the sibling from_wire Option<Self> output on {wire:?} — the \
3011 two accessors must share the same accept-set and typed \
3012 outcome per arm",
3013 );
3014 }
3015 }
3016
3017 #[test]
3018 fn caixa_dialeto_try_from_str_rejects_unknown_byte_strings() {
3019 // Rejection witness on the trait-idiomatic reverse-projection
3020 // axis: any string outside the four-arm [`CaixaDialeto::as_str`]
3021 // output set must resolve to `Err(())` through the lifted
3022 // [`impl TryFrom<&str> for CaixaDialeto`]. A future accidental
3023 // widening of the accept-set (a case-insensitive match that
3024 // accepts `"pacote"` on the wire axis, a hand-rolled Levenshtein-
3025 // forgiving arm-lookup that admits `"Pacotee"` typos, a silent
3026 // acceptance of the sibling [`CaixaDialeto::palavra_canonica`]
3027 // `"defcaixa"` / `"defmolde"` byte-shapes on this axis, a swap
3028 // onto the [`CaixaDialeto::consumidor`] `"pleme-doc-gen"` /
3029 // `"caixa-core / feira"` / `"nobody known"` byte-shapes) would
3030 // silently drift the trait-idiomatic parser's accept-set from
3031 // the sibling [`CaixaDialeto::from_wire`] resolver's — a
3032 // downstream `TryFrom<&str>`-bound consumer binding a malformed
3033 // byte-string through this impl would then bind a plausibly-
3034 // wrong typed arm the caller does not route through any fallback,
3035 // silently misclassifying the reloaded row.
3036 //
3037 // Sweeps the same rejection set the sibling
3038 // [`caixa_dialeto_from_wire_rejects_unknown_byte_strings`] pin
3039 // walks (the shared `from_wire` resolver both accessors delegate
3040 // through) so the trait-idiomatic axis and the method-named axis
3041 // stay locked to the same accept-set by construction. Peer of the
3042 // sibling
3043 // [`crate::kind::tests::caixa_kind_try_from_str_rejects_unknown_byte_strings`]
3044 // (3c83606) on the top-level [`crate::CaixaKind`] closed-set
3045 // discriminator's trait-idiomatic reverse-projection axis.
3046 for bad in [
3047 "",
3048 " ",
3049 "pacote",
3050 "PACOTE",
3051 "molde",
3052 "MoldePositional",
3053 "desconhecido",
3054 "Unknown",
3055 "defcaixa",
3056 "defmolde",
3057 "?",
3058 "caixa-core / feira",
3059 "pleme-doc-gen",
3060 "nobody known",
3061 "Pacote ",
3062 " Pacote",
3063 ] {
3064 assert_eq!(
3065 <CaixaDialeto as TryFrom<&str>>::try_from(bad),
3066 Err(()),
3067 "CaixaDialeto::try_from({bad:?}) must return Err(()) — the \
3068 trait-idiomatic parser's accept-set is exactly the four \
3069 CaixaDialeto::as_str outputs; a widening would silently \
3070 split the trait-idiomatic reverse-projection axis from the \
3071 sibling from_wire resolver's arm-set"
3072 );
3073 }
3074 }
3075
3076 #[test]
3077 fn caixa_dialeto_from_into_static_str_routes_through_as_str_accessor() {
3078 // Fail-before-pass-after byte-parity pin on the newly lifted
3079 // `impl From<CaixaDialeto> for &'static str` — asserts the
3080 // standard-library trait impl and the substrate-primitive
3081 // [`CaixaDialeto::as_str`] `pub const fn` accessor resolve to
3082 // the same four-arm emit-set across every arm the exhaustive
3083 // [`CaixaDialeto::ALL`] slice enumerates. Any future silent
3084 // detour that routes the trait impl through a divergent
3085 // projection (a per-arm inline `match dialeto { Pacote =>
3086 // "Pacote", … }` re-inlining that opens a compile-time link to
3087 // the un-lifted arm-literal, an accidental swap onto the second-
3088 // axis [`CaixaDialeto::palavra_canonica`] /
3089 // [`CaixaDialeto::consumidor`] / [`CaixaDialeto::descricao`]
3090 // accessors that carry distinct byte-shapes per axis) trips at
3091 // caixa-core test time under `assert_eq!` rather than at a
3092 // downstream `impl Into<&'static str>`-bound consumer's silent
3093 // split. Sweeps every one of the four arms [`CaixaDialeto::ALL`]
3094 // carries so no arm's projection is covered only by the sibling
3095 // method-named `as_str` / [`std::fmt::Display`] / [`AsRef<str>`]
3096 // paths. Materializes the `<&'static str as
3097 // From<CaixaDialeto>>::from` output in a `const`-shape binding
3098 // to make the `'static` lifetime promise a build-time invariant
3099 // — a future accidental downgrade of any of the four arms'
3100 // returned literals to a non-`&'static str` (a `String::leak()`-
3101 // produced return, a `Box::leak`-cast, an intermediate lifetime-
3102 // erasing helper) trips at caixa-core build time rather than at
3103 // a downstream `'static`-bound consumer. Peer of the sibling
3104 // [`crate::supervisor::tests::restart_strategy_from_into_static_str_routes_through_as_str_accessor`]
3105 // (523157d) /
3106 // [`crate::supervisor::tests::restart_policy_from_into_static_str_routes_through_as_str_accessor`]
3107 // (9fb37d0) /
3108 // [`crate::kind::tests::caixa_kind_from_into_static_str_routes_through_as_str_accessor`]
3109 // (edb827b) pins on the sibling closed-set typed-enum forward-
3110 // projection axes — extends the trait-idiomatic forward-
3111 // projection axis onto the fourth closed-set fieldless typed
3112 // enum on the caixa surface (the dialect-classification axis,
3113 // second-of-two closed-set typed enums in caixa-core outside
3114 // the OTP-shape M2 slot).
3115 const PACOTE: &str = CaixaDialeto::Pacote.as_str();
3116 const MOLDE: &str = CaixaDialeto::Molde.as_str();
3117 const MOLDE_POSICIONAL: &str = CaixaDialeto::MoldePosicional.as_str();
3118 const DESCONHECIDO: &str = CaixaDialeto::Desconhecido.as_str();
3119 for &variant in CaixaDialeto::ALL {
3120 let via_trait: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
3121 let via_method: &'static str = variant.as_str();
3122 assert_eq!(
3123 via_trait, via_method,
3124 "From<CaixaDialeto> for &'static str impl must round-trip \
3125 CaixaDialeto::{variant:?} to the same `PascalCase` byte-string \
3126 CaixaDialeto::as_str returns — divergence signals a silent \
3127 detour off the substrate-primitive accessor"
3128 );
3129 let via_into: &'static str = variant.into();
3130 assert_eq!(
3131 via_into, via_method,
3132 "Into<&'static str>::into on CaixaDialeto::{variant:?} must \
3133 byte-equal CaixaDialeto::as_str on the same input — the \
3134 blanket-derived Into shape must resolve to the same as_str \
3135 dispatch as the explicit From impl"
3136 );
3137 }
3138 assert_eq!(
3139 [PACOTE, MOLDE, MOLDE_POSICIONAL, DESCONHECIDO],
3140 ["Pacote", "Molde", "MoldePosicional", "Desconhecido"],
3141 "const-context CaixaDialeto::as_str must resolve to the four \
3142 `PascalCase` variant-name byte-strings — a future accidental \
3143 downgrade of any arm to a non-const or non-static byte-string \
3144 breaks the `&'static str`-lifetime promise the paired \
3145 From<CaixaDialeto> for &'static str impl carries by \
3146 construction"
3147 );
3148 }
3149
3150 #[test]
3151 fn caixa_dialeto_from_into_static_str_and_as_str_partition_the_emit_set() {
3152 // Cross-axis partition pin: the paired trait-idiomatic
3153 // `From<CaixaDialeto> for &'static str` forward projection and
3154 // the method-named [`CaixaDialeto::as_str`] forward projection
3155 // must resolve identically on *every* arm, not just the ones
3156 // named in the primary byte-parity pin above. Sweeps every
3157 // [`CaixaDialeto::ALL`] arm and asserts the trait's `From::from`
3158 // output byte-equals the method-named accessor's return-value on
3159 // each, locking the two forward-projection paths together by
3160 // construction so any future detour (a stray `From` special-case
3161 // that lands on a divergent per-arm literal outside the paired
3162 // `as_str` dispatch, a hypothetical rebrand touching one axis
3163 // without the other) trips at caixa-core test time. Peer of the
3164 // sibling forward-projection partition pins
3165 // [`crate::supervisor::tests::restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`]
3166 // (523157d) /
3167 // [`crate::supervisor::tests::restart_policy_from_into_static_str_and_as_str_partition_the_emit_set`]
3168 // (9fb37d0) /
3169 // [`crate::kind::tests::caixa_kind_from_into_static_str_and_as_str_partition_the_emit_set`]
3170 // (edb827b) — extends the round-trip discipline onto the fourth
3171 // closed-set typed enum on the caixa surface, closing the two-way
3172 // `Self ↔ &'static str` round-trip on the trait-idiomatic pair
3173 // (`From<Self> for &'static str` + `TryFrom<&str> for Self`) as
3174 // well as the pre-existing method-named pair (`as_str` +
3175 // `from_wire`).
3176 for &variant in CaixaDialeto::ALL {
3177 let via_trait: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
3178 let via_method: &'static str = variant.as_str();
3179 assert_eq!(
3180 via_trait, via_method,
3181 "From<CaixaDialeto> for &'static str and \
3182 CaixaDialeto::as_str must resolve identically on \
3183 CaixaDialeto::{variant:?} — divergence signals the \
3184 two forward-projection paths have drifted onto different \
3185 emit-sets"
3186 );
3187 }
3188 // Round-trip witness: every arm's forward `From` output re-parses
3189 // through the paired trait-idiomatic reverse `TryFrom<&str>` back
3190 // to the original variant. Closes the two-way `CaixaDialeto ↔
3191 // &'static str` round-trip on the trait-idiomatic axis pair
3192 // directly (no wire-vocab intermediate the peer [`CaixaKind`]
3193 // axis pair requires — the emit-side [`CaixaDialeto::as_str`]
3194 // and the parse-side [`CaixaDialeto::from_wire`] share the same
3195 // `PascalCase` byte-string vocabulary by construction), mirroring
3196 // the pre-existing method-named `as_str` + `from_wire` round-trip
3197 // on the substrate-primitive axis pair.
3198 for &variant in CaixaDialeto::ALL {
3199 let emitted: &'static str = variant.into();
3200 let re_parsed: Result<CaixaDialeto, ()> =
3201 <CaixaDialeto as TryFrom<&str>>::try_from(emitted);
3202 assert_eq!(
3203 re_parsed,
3204 Ok(variant),
3205 "trait-idiomatic axis pair must round-trip \
3206 CaixaDialeto::{variant:?} through `.into::<&'static \
3207 str>()` and back through `TryFrom<&str>` — a break signals \
3208 the forward-emit and reverse-parse axes have drifted onto \
3209 different vocabularies"
3210 );
3211 }
3212 }
3213
3214 #[test]
3215 fn caixa_dialeto_is_molde_family_routes_through_is_variant_derived_predicates() {
3216 // Byte-parity pin on the post-lift [`CaixaDialeto::is_molde_family`]
3217 // convergence: for every arm in [`CaixaDialeto::ALL`], the typed
3218 // predicate must byte-equal the direct
3219 // `self.is_molde() || self.is_molde_posicional()` composition of
3220 // the two derived per-arm predicates. Pre-lift the predicate
3221 // hand-rolled `matches!(self, Self::Molde | Self::MoldePosicional)`
3222 // with no compile-time link back to the closed-set typed dispatch;
3223 // post-lift it routes through the derived predicates so a future
3224 // arm rename or `#[is_variant(name = "…")]` override lands at
3225 // exactly one dispatch on the substrate primitive. Pinning the
3226 // byte-equality here refuses a future accidental split between
3227 // the composed predicate and the paired derived predicates
3228 // (a hand-rolled shadow `impl` that overrides one path but not
3229 // the other, an accidental rebrand of `is_molde_family`'s body
3230 // back to the pre-lift `matches!` form) at caixa-core build time.
3231 for &d in CaixaDialeto::ALL {
3232 let via_derived = d.is_molde() || d.is_molde_posicional();
3233 let via_is_molde_family = d.is_molde_family();
3234 assert_eq!(
3235 via_is_molde_family, via_derived,
3236 "CaixaDialeto::{d:?}.is_molde_family() ({via_is_molde_family}) \
3237 must byte-equal the composed derived predicates \
3238 is_molde() || is_molde_posicional() ({via_derived}) — a \
3239 split between the composed predicate and its derived \
3240 building blocks would let a future arm rename land at one \
3241 path and drift at the other, which is exactly the drift \
3242 the IsVariant lift refuses"
3243 );
3244 }
3245 }
3246
3247 #[test]
3248 fn caixa_dialeto_from_borrowed_into_static_str_routes_through_as_str_accessor() {
3249 // Fail-before-pass-after byte-parity pin on the newly lifted
3250 // `impl From<&CaixaDialeto> for &'static str` — asserts the
3251 // borrowed-input standard-library trait impl and the substrate-
3252 // primitive [`CaixaDialeto::as_str`] `pub const fn` accessor
3253 // resolve to the same four-arm emit-set across every arm the
3254 // exhaustive [`CaixaDialeto::ALL`] slice enumerates. Rust's
3255 // `From` trait does not auto-derive the borrowed-input sibling
3256 // from a paired owned-input impl (no `impl<T, U> From<&T> for U
3257 // where T: Copy, U: From<T>` blanket in `core`), so the
3258 // borrowed-input axis is a distinct trait-idiomatic surface that
3259 // a `.iter().map(Into::into)` shape over [`CaixaDialeto::ALL`]
3260 // (whose iterator yields `&CaixaDialeto`, not `CaixaDialeto`)
3261 // reaches through this impl and no other — the paired owned-
3262 // input [`From<CaixaDialeto>`] impl requires an explicit
3263 // `.copied()` / dereference before the trait fires.
3264 // Materializes the `<&'static str as From<&CaixaDialeto>>::from`
3265 // output in a `const`-shape binding to make the `'static`
3266 // lifetime promise a build-time invariant — a future accidental
3267 // downgrade of any of the four arms' returned literals to a
3268 // non-`&'static str` trips at caixa-core build time rather than
3269 // at a downstream `'static`-bound consumer. Peer of the sibling
3270 // [`crate::dep::tests::dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor`]
3271 // (64aa742) /
3272 // [`crate::kind::tests::caixa_kind_from_borrowed_into_static_str_routes_through_as_str_accessor`]
3273 // (5ab993a) pins on the sibling closed-set typed-enum borrowed-
3274 // input forward-projection axes — extends the borrowed-input
3275 // axis discipline onto the third peer on the substrate-wide
3276 // campaign, the dialect-classification axis.
3277 const PACOTE: &str = CaixaDialeto::Pacote.as_str();
3278 const MOLDE: &str = CaixaDialeto::Molde.as_str();
3279 const MOLDE_POSICIONAL: &str = CaixaDialeto::MoldePosicional.as_str();
3280 const DESCONHECIDO: &str = CaixaDialeto::Desconhecido.as_str();
3281 for variant in CaixaDialeto::ALL {
3282 let via_trait: &'static str = <&'static str as From<&CaixaDialeto>>::from(variant);
3283 let via_method: &'static str = variant.as_str();
3284 assert_eq!(
3285 via_trait, via_method,
3286 "From<&CaixaDialeto> for &'static str impl must round-trip \
3287 &CaixaDialeto::{variant:?} to the same `PascalCase` byte-\
3288 string CaixaDialeto::as_str returns — divergence signals a \
3289 silent detour off the substrate-primitive accessor"
3290 );
3291 let via_into: &'static str = variant.into();
3292 assert_eq!(
3293 via_into, via_method,
3294 "Into<&'static str>::into on &CaixaDialeto::{variant:?} must \
3295 byte-equal CaixaDialeto::as_str on the same input — the \
3296 blanket-derived Into shape must resolve to the same as_str \
3297 dispatch as the explicit From impl"
3298 );
3299 }
3300 assert_eq!(
3301 [PACOTE, MOLDE, MOLDE_POSICIONAL, DESCONHECIDO],
3302 ["Pacote", "Molde", "MoldePosicional", "Desconhecido"],
3303 "const-context CaixaDialeto::as_str must resolve to the four \
3304 `PascalCase` variant-name byte-strings — the borrowed-input \
3305 From<&CaixaDialeto> for &'static str impl inherits its \
3306 `'static` lifetime promise from the same accessor the owned-\
3307 input sibling routes through"
3308 );
3309 }
3310
3311 #[test]
3312 fn caixa_dialeto_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
3313 // Cross-axis partition pin: the paired trait-idiomatic
3314 // owned-input `From<CaixaDialeto> for &'static str` and
3315 // borrowed-input `From<&CaixaDialeto> for &'static str` (this
3316 // lift) forward projections must resolve identically on every
3317 // arm, locking the two input-shape paths together so any future
3318 // detour trips at caixa-core test time. Then a witness that a
3319 // `.iter().map(Into::into)` pipe over [`CaixaDialeto::ALL`]
3320 // (whose iterator yields `&CaixaDialeto`) materializes the four-
3321 // arm accept-set through the borrowed-input axis alone — the
3322 // exact shape a future M4 admission-webhook rejection body
3323 // composer, a future substrate-wide per-arm diagnostic column,
3324 // or a `HashMap::<&'static str, CaixaDialeto>::from_iter(
3325 // CaixaDialeto::ALL.iter().map(|d| (d.into(), *d)))`-style
3326 // per-dialect lookup reaches through — closing the two-way
3327 // owned/borrowed input-shape symmetry on the forward-projection
3328 // trait-idiomatic axis. Peer of the sibling
3329 // [`crate::dep::tests::dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
3330 // (64aa742) /
3331 // [`crate::kind::tests::caixa_kind_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
3332 // (5ab993a) partition pins — extends the borrowed-input axis
3333 // discipline onto the third peer on the substrate-wide campaign.
3334 for &variant in CaixaDialeto::ALL {
3335 let owned: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
3336 let borrowed: &'static str = <&'static str as From<&CaixaDialeto>>::from(&variant);
3337 assert_eq!(
3338 owned, borrowed,
3339 "From<CaixaDialeto> and From<&CaixaDialeto> for &'static str \
3340 must resolve identically on CaixaDialeto::{variant:?} — \
3341 divergence signals the owned-input and borrowed-input \
3342 forward-projection paths have drifted onto different \
3343 emit-sets"
3344 );
3345 }
3346 let via_iter: Vec<&'static str> = CaixaDialeto::ALL.iter().map(Into::into).collect();
3347 let via_method: Vec<&'static str> = CaixaDialeto::ALL.iter().map(|d| d.as_str()).collect();
3348 assert_eq!(
3349 via_iter, via_method,
3350 "`.iter().map(Into::into)` over CaixaDialeto::ALL must byte-\
3351 equal `.iter().map(|d| d.as_str())` on every arm — the \
3352 borrowed-input `From<&CaixaDialeto> for &'static str` axis \
3353 is what makes the `.iter().map(Into::into)` shape route \
3354 through the substrate-primitive `CaixaDialeto::as_str` \
3355 accessor rather than through a per-call-site `.copied()` / \
3356 dereference detour"
3357 );
3358 // Direct round-trip witness on the borrowed-input axis: every
3359 // arm's borrowed `From` output re-parses through the paired
3360 // trait-idiomatic reverse `TryFrom<&str>` back to the original
3361 // variant. Unlike the peer [`crate::CaixaKind`] axis pair
3362 // (whose forward `From<Self> for &'static str` emits the
3363 // lowercase Portuguese `as_str` diagnostic vocabulary while
3364 // the reverse `TryFrom<&str>` parses the `PascalCase`
3365 // `wire_name` author-surface vocabulary, forcing the round-trip
3366 // through an intermediate wire-vocab hop), [`CaixaDialeto`]'s
3367 // [`CaixaDialeto::as_str`] emit and [`CaixaDialeto::from_wire`]
3368 // parse share the same `PascalCase` vocabulary by construction,
3369 // so the borrowed-input forward axis and the reverse axis
3370 // compose directly.
3371 for &variant in CaixaDialeto::ALL {
3372 let borrowed: &'static str = <&'static str as From<&CaixaDialeto>>::from(&variant);
3373 let re_parsed: Result<CaixaDialeto, ()> =
3374 <CaixaDialeto as TryFrom<&str>>::try_from(borrowed);
3375 assert_eq!(
3376 re_parsed,
3377 Ok(variant),
3378 "trait-idiomatic borrowed-input round-trip must project \
3379 &CaixaDialeto::{variant:?} through \
3380 `<&'static str>::from(&variant)` and back through \
3381 `TryFrom<&str>` — a break signals the borrowed-input \
3382 forward-emit axis and the reverse-parse axis have \
3383 drifted onto different vocabularies"
3384 );
3385 }
3386 }
3387
3388 #[test]
3389 fn caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor() {
3390 // Fail-before-pass-after byte-parity pin on the newly lifted
3391 // `impl From<CaixaDialeto> for String` — asserts the owned-`String`
3392 // -returning standard-library trait impl and the substrate-
3393 // primitive [`CaixaDialeto::as_str`] `pub const fn` accessor
3394 // resolve to the same four-arm emit-set across every arm the
3395 // exhaustive [`CaixaDialeto::ALL`] slice enumerates. Rust's
3396 // standard library does not carry a blanket
3397 // `impl<T: AsRef<str>> From<T> for String` (nor an
3398 // `impl<T: fmt::Display> From<T> for String`), so the
3399 // owned-`String` forward-projection axis is a distinct trait-
3400 // idiomatic surface that a `let key: String = dialeto.into();`-
3401 // shaped call site reaches through this impl and no other — the
3402 // paired sibling `From<CaixaDialeto> for &'static str` impl
3403 // forces every owned-`String` call site through an explicit
3404 // `.to_owned()` / `String::from` restatement. Peer of the
3405 // first-mover
3406 // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
3407 // (7baa18a), the second-peer
3408 // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
3409 // (7851725), and the third-peer
3410 // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
3411 // (231a18c) — extends the trait-idiomatic owned-`String`
3412 // forward-projection axis onto the fourth closed-set fieldless
3413 // typed enum on the caixa surface (the dialect-classification
3414 // axis, second peer outside the M2 OTP-shape sibling axis).
3415 for &variant in CaixaDialeto::ALL {
3416 let via_trait: String = <String as From<CaixaDialeto>>::from(variant);
3417 let via_method: &'static str = variant.as_str();
3418 assert_eq!(
3419 via_trait.as_str(),
3420 via_method,
3421 "From<CaixaDialeto> for String impl must round-trip \
3422 CaixaDialeto::{variant:?} to the same `PascalCase` \
3423 arm-string CaixaDialeto::as_str returns — divergence \
3424 signals a silent detour off the substrate-primitive \
3425 accessor"
3426 );
3427 let via_into: String = variant.into();
3428 assert_eq!(
3429 via_into.as_str(),
3430 via_method,
3431 "Into<String>::into on CaixaDialeto::{variant:?} must \
3432 byte-equal CaixaDialeto::as_str on the same input — the \
3433 blanket-derived Into shape must resolve to the same \
3434 as_str dispatch as the explicit From impl"
3435 );
3436 }
3437 }
3438
3439 #[test]
3440 fn caixa_dialeto_from_into_owned_string_and_static_str_agree_on_every_arm() {
3441 // Cross-axis partition pin: the paired trait-idiomatic
3442 // owned-`String` `From<CaixaDialeto> for String` (this lift) and
3443 // owned-`&'static str` `From<CaixaDialeto> for &'static str`
3444 // (c189a6f) forward projections must resolve identically on
3445 // every arm, locking the two return-type-shape paths together
3446 // so any future detour trips at caixa-core test time. Also
3447 // byte-parity witness against the sibling
3448 // [`ToString::to_string`] surface routed through
3449 // [`std::fmt::Display`] — the three owned-heap-string paths
3450 // (`.into::<String>()`, `String::from`, `.to_string()`) must
3451 // resolve identically on every arm so a future consumer that
3452 // picks any of the three lands on the same four-arm
3453 // `PascalCase` accept-set. Then a `.iter().copied()
3454 // .map(String::from)` pipe witness over [`CaixaDialeto::ALL`]
3455 // that materializes the four-arm accept-set through the
3456 // owned-`String` axis alone — the exact shape a future M4
3457 // admission-webhook rejection body composer or a
3458 // `HashMap::<String, CaixaDialeto>::from_iter(
3459 // CaixaDialeto::ALL.iter().copied().map(|d| (d.into(), d)))`-
3460 // style owned-key per-dialect lookup reaches through — closing
3461 // the owned-`String` forward-projection axis's iterator-pipe
3462 // shape. Then a direct round-trip witness through the paired
3463 // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
3464 // owned-`String`'s [`String::as_str`] borrow that closes the
3465 // two-way `Self → String → Self` round-trip on the trait-
3466 // idiomatic owned-`String` forward + reverse axis pair.
3467 //
3468 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
3469 // `From` emit lands on the lowercase Portuguese `as_str`
3470 // diagnostic vocabulary while the reverse `TryFrom<&str>` parses
3471 // the `PascalCase` `wire_name` author-surface vocabulary,
3472 // forcing the round-trip through an intermediate
3473 // [`crate::CaixaKind::wire_name`] hop), [`CaixaDialeto`]'s
3474 // [`CaixaDialeto::as_str`] emit and [`CaixaDialeto::from_wire`]
3475 // parse share the same `PascalCase` vocabulary by construction
3476 // (there is no wire/diagnostic axis split on this enum), so
3477 // the owned-`String` forward axis and the reverse axis compose
3478 // directly — matching the peer
3479 // [`crate::supervisor::RestartStrategy`] /
3480 // [`crate::supervisor::RestartPolicy`] owned-`String` axis
3481 // pairs (whose forward emit and reverse parse also share one
3482 // `PascalCase` vocabulary by construction).
3483 for &variant in CaixaDialeto::ALL {
3484 let owned_string: String = <String as From<CaixaDialeto>>::from(variant);
3485 let owned_static: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
3486 assert_eq!(
3487 owned_string.as_str(),
3488 owned_static,
3489 "From<CaixaDialeto> for String and From<CaixaDialeto> for \
3490 &'static str must resolve identically on \
3491 CaixaDialeto::{variant:?} — divergence signals the \
3492 owned-`String` and owned-`&'static str` forward-\
3493 projection return-type-shape paths have drifted onto \
3494 different emit-sets"
3495 );
3496 let via_to_string: String = variant.to_string();
3497 assert_eq!(
3498 owned_string, via_to_string,
3499 "From<CaixaDialeto> for String must byte-equal \
3500 CaixaDialeto::to_string on CaixaDialeto::{variant:?} — \
3501 divergence signals the trait-idiomatic owned-`String` \
3502 forward-projection axis and the ToString-through-\
3503 Display axis have drifted onto different emit-sets"
3504 );
3505 }
3506 let via_iter: Vec<String> = CaixaDialeto::ALL
3507 .iter()
3508 .copied()
3509 .map(String::from)
3510 .collect();
3511 let via_method: Vec<String> = CaixaDialeto::ALL
3512 .iter()
3513 .map(|d| d.as_str().to_owned())
3514 .collect();
3515 assert_eq!(
3516 via_iter, via_method,
3517 "`.iter().copied().map(String::from)` over CaixaDialeto::ALL \
3518 must byte-equal `.iter().map(|d| d.as_str().to_owned())` on \
3519 every arm — the owned-`String` `From<CaixaDialeto> for \
3520 String` axis is what makes the `String::from` composition \
3521 route through the substrate-primitive `CaixaDialeto::as_str` \
3522 accessor rather than through a per-call-site `.to_owned()` / \
3523 `String::from(dialeto.as_str())` detour"
3524 );
3525 for &variant in CaixaDialeto::ALL {
3526 let emitted: String = variant.into();
3527 let re_parsed: Result<CaixaDialeto, ()> =
3528 <CaixaDialeto as TryFrom<&str>>::try_from(emitted.as_str());
3529 assert_eq!(
3530 re_parsed,
3531 Ok(variant),
3532 "trait-idiomatic owned-`String` forward-projection + \
3533 reverse-projection axis pair must round-trip \
3534 CaixaDialeto::{variant:?} through `.into::<String>()` \
3535 and back through `TryFrom<&str>` on the owned-`String`'s \
3536 String::as_str borrow — a break signals the owned-\
3537 `String` forward-emit and reverse-parse axes have \
3538 drifted onto different vocabularies (unlike the peer \
3539 CaixaKind axis pair, CaixaDialeto's forward emit and \
3540 reverse parse share one PascalCase vocabulary by \
3541 construction, so the round-trip composes directly)"
3542 );
3543 }
3544 }
3545
3546 #[test]
3547 fn caixa_dialeto_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
3548 // Fail-before-pass-after byte-parity pin on the newly lifted
3549 // `impl From<&CaixaDialeto> for String` — asserts the borrowed-
3550 // input owned-`String`-returning standard-library trait impl and
3551 // the substrate-primitive [`super::CaixaDialeto::as_str`]
3552 // `pub const fn` accessor resolve to the same four-arm emit-set
3553 // across every arm the exhaustive [`super::CaixaDialeto::ALL`]
3554 // slice enumerates. Rust's standard library does not carry a
3555 // blanket `impl<T: AsRef<str>> From<&T> for String` (nor an
3556 // `impl<T: fmt::Display> From<&T> for String`), so the
3557 // borrowed-input owned-`String` forward-projection axis is a
3558 // distinct trait-idiomatic surface that a
3559 // `let key: String = (&dialeto).into();`-shaped call site
3560 // reaches through this impl and no other — the paired sibling
3561 // `From<CaixaDialeto> for String` impl forces every borrowed-
3562 // input call site through an explicit `Copy` deref
3563 // (`String::from(*dialeto)`) or an `.as_str().to_owned()` /
3564 // `.to_string()` detour. Peer of the first-mover
3565 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
3566 // (579385f), the second-peer
3567 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
3568 // (8465740), the third-peer
3569 // [`crate::dep::tests::dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
3570 // (e0cb617), and the fourth-peer
3571 // [`crate::kind::tests::caixa_kind_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
3572 // (e76436d) — extends the trait-idiomatic borrowed-input owned-
3573 // `String` forward-projection axis onto the fourth closed-set
3574 // fieldless typed enum on the caixa surface (the dialect-
3575 // classification axis, second peer outside the M2 OTP-shape
3576 // sibling axis to reach the 2×2-completion corner).
3577 for &variant in CaixaDialeto::ALL {
3578 let via_trait: String = <String as From<&CaixaDialeto>>::from(&variant);
3579 let via_method: &'static str = variant.as_str();
3580 assert_eq!(
3581 via_trait.as_str(),
3582 via_method,
3583 "From<&CaixaDialeto> for String impl must round-trip \
3584 &CaixaDialeto::{variant:?} to the same `PascalCase` \
3585 arm-string CaixaDialeto::as_str returns — divergence \
3586 signals a silent detour off the substrate-primitive \
3587 accessor"
3588 );
3589 let via_into: String = (&variant).into();
3590 assert_eq!(
3591 via_into.as_str(),
3592 via_method,
3593 "Into<String>::into on &CaixaDialeto::{variant:?} must \
3594 byte-equal CaixaDialeto::as_str on the same input — \
3595 the blanket-derived Into shape must resolve to the \
3596 same as_str dispatch as the explicit From impl"
3597 );
3598 }
3599 }
3600
3601 #[test]
3602 fn caixa_dialeto_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
3603 // Cross-axis partition pin: the newly lifted trait-idiomatic
3604 // borrowed-input owned-`String` `From<&CaixaDialeto> for String`
3605 // (this lift), the paired owned-input owned-`String`
3606 // `From<CaixaDialeto> for String` (88942cd), the paired
3607 // borrowed-input owned-`&'static str`
3608 // `From<&CaixaDialeto> for &'static str` (807b0b5), and the
3609 // paired owned-input owned-`&'static str`
3610 // `From<CaixaDialeto> for &'static str` (c189a6f) — every corner
3611 // of the `{Self, &Self} × {&'static str, String}` 2×2 trait-
3612 // idiomatic projection family — must resolve identically on
3613 // every arm, locking the four return-shape × input-shape paths
3614 // together so any future detour trips at caixa-core test time.
3615 // Also byte-parity witness against the sibling
3616 // [`ToString::to_string`] surface routed through
3617 // [`std::fmt::Display`] and a direct round-trip witness through
3618 // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
3619 // the owned-`String`'s [`String::as_str`] borrow that closes
3620 // the two-way `&Self → String → Self` round-trip on the trait-
3621 // idiomatic borrowed-input owned-`String` forward + reverse
3622 // axis pair. Peer of the first-mover
3623 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
3624 // (579385f), the second-peer
3625 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
3626 // (8465740), the third-peer
3627 // [`crate::dep::tests::dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
3628 // (e0cb617), and the fourth-peer
3629 // [`crate::kind::tests::caixa_kind_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
3630 // (e76436d) — closes the whole `{Self, &Self} × {&'static str,
3631 // String}` 2×2 projection corner on the fifth substrate-wide
3632 // closed-set fieldless typed enum peer (the dialect-
3633 // classification axis, second peer outside the M2 OTP-shape
3634 // sibling pair).
3635 //
3636 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
3637 // `From` emit lands on the lowercase Portuguese `as_str`
3638 // diagnostic vocabulary while the reverse `TryFrom<&str>`
3639 // parses the `PascalCase` `wire_name` author-surface vocabulary,
3640 // forcing the round-trip through an intermediate
3641 // [`crate::CaixaKind::wire_name`] hop), [`super::CaixaDialeto`]'s
3642 // [`super::CaixaDialeto::as_str`] emit and
3643 // [`super::CaixaDialeto::from_wire`] parse share the same
3644 // `PascalCase` vocabulary by construction (there is no
3645 // wire/diagnostic axis split on this enum), so the borrowed-
3646 // input owned-`String` forward axis and the reverse axis compose
3647 // directly — matching the peer
3648 // [`crate::supervisor::RestartStrategy`] /
3649 // [`crate::supervisor::RestartPolicy`] / [`crate::dep::DepList`]
3650 // borrowed-input owned-`String` axis pairs.
3651 for &dialeto in CaixaDialeto::ALL {
3652 let borrowed_string: String = <String as From<&CaixaDialeto>>::from(&dialeto);
3653 let owned_string: String = <String as From<CaixaDialeto>>::from(dialeto);
3654 let borrowed_static: &'static str =
3655 <&'static str as From<&CaixaDialeto>>::from(&dialeto);
3656 let owned_static: &'static str = <&'static str as From<CaixaDialeto>>::from(dialeto);
3657 assert_eq!(
3658 borrowed_string, owned_string,
3659 "From<&CaixaDialeto> for String and From<CaixaDialeto> \
3660 for String must resolve identically on \
3661 CaixaDialeto::{dialeto:?} — divergence signals the \
3662 borrowed-input and owned-input owned-`String` forward-\
3663 projection input-shape paths have drifted onto \
3664 different emit-sets"
3665 );
3666 assert_eq!(
3667 borrowed_string.as_str(),
3668 borrowed_static,
3669 "From<&CaixaDialeto> for String and From<&CaixaDialeto> \
3670 for &'static str must resolve identically on \
3671 CaixaDialeto::{dialeto:?} — divergence signals the \
3672 borrowed-input `&'static str` and owned-`String` \
3673 return-shape paths have drifted onto different \
3674 emit-sets"
3675 );
3676 assert_eq!(
3677 borrowed_string.as_str(),
3678 owned_static,
3679 "From<&CaixaDialeto> for String and From<CaixaDialeto> \
3680 for &'static str must resolve identically on \
3681 CaixaDialeto::{dialeto:?} — divergence signals a break \
3682 in the diagonal corner of the {{Self, &Self}} × \
3683 {{&'static str, String}} 2×2 trait-idiomatic \
3684 projection family"
3685 );
3686 let via_to_string: String = dialeto.to_string();
3687 assert_eq!(
3688 borrowed_string, via_to_string,
3689 "From<&CaixaDialeto> for String must byte-equal \
3690 CaixaDialeto::to_string on CaixaDialeto::{dialeto:?} — \
3691 divergence signals the trait-idiomatic borrowed-input \
3692 owned-`String` forward-projection axis and the \
3693 ToString-through-Display axis have drifted onto \
3694 different emit-sets"
3695 );
3696 }
3697 let via_iter: Vec<String> = CaixaDialeto::ALL.iter().map(String::from).collect();
3698 let via_method: Vec<String> = CaixaDialeto::ALL
3699 .iter()
3700 .map(|d| d.as_str().to_owned())
3701 .collect();
3702 assert_eq!(
3703 via_iter, via_method,
3704 "`.iter().map(String::from)` over CaixaDialeto::ALL — a \
3705 call site whose iteration axis holds `&CaixaDialeto` by \
3706 construction — must byte-equal `.iter().map(|d| \
3707 d.as_str().to_owned())` on every arm — the borrowed-input \
3708 owned-`String` `From<&CaixaDialeto> for String` axis is \
3709 what makes the `String::from` composition route through \
3710 the substrate-primitive `CaixaDialeto::as_str` accessor \
3711 without a spurious `Copy` deref (which would only be \
3712 reachable through the owned-input `From<CaixaDialeto> for \
3713 String` axis by first calling `.copied()` on the iterator)"
3714 );
3715 for &variant in CaixaDialeto::ALL {
3716 let emitted: String = (&variant).into();
3717 let re_parsed: Result<CaixaDialeto, ()> =
3718 <CaixaDialeto as TryFrom<&str>>::try_from(emitted.as_str());
3719 assert_eq!(
3720 re_parsed,
3721 Ok(variant),
3722 "trait-idiomatic borrowed-input owned-`String` \
3723 forward-projection + reverse-projection axis pair \
3724 must round-trip &CaixaDialeto::{variant:?} through \
3725 `.into::<String>()` on the borrowed-input surface and \
3726 back through `TryFrom<&str>` on the owned-`String`'s \
3727 String::as_str borrow — a break signals the \
3728 borrowed-input owned-`String` forward-emit and \
3729 reverse-parse axes have drifted onto different \
3730 vocabularies (unlike the peer CaixaKind axis pair, \
3731 CaixaDialeto's forward emit and reverse parse share \
3732 one PascalCase vocabulary by construction, so the \
3733 round-trip composes directly)"
3734 );
3735 }
3736 }
3737
3738 #[test]
3739 fn caixa_dialeto_from_into_static_cow_str_routes_through_as_str_accessor() {
3740 // Fail-before-pass-after byte-parity pin on the newly lifted
3741 // `impl From<CaixaDialeto> for std::borrow::Cow<'static, str>`
3742 // — asserts the standard-library trait impl and the
3743 // substrate-primitive [`super::CaixaDialeto::as_str`]
3744 // `pub const fn` accessor resolve to the same four-arm
3745 // emit-set across every arm the exhaustive
3746 // [`super::CaixaDialeto::ALL`] slice enumerates. Rust's
3747 // standard library does not carry a blanket
3748 // `impl<T: AsRef<str>> From<T> for std::borrow::Cow<'static,
3749 // str>` (nor an `impl<T: fmt::Display> From<T> for
3750 // std::borrow::Cow<'static, str>`), so the
3751 // [`std::borrow::Cow<'static, str>`] forward-projection axis
3752 // is a distinct trait-idiomatic surface that a
3753 // `let key: std::borrow::Cow<'static, str> = dialeto.into();`-
3754 // shaped call site reaches through this impl and no other —
3755 // the paired sibling `From<CaixaDialeto> for &'static str`
3756 // and `From<CaixaDialeto> for String` impls force every
3757 // [`std::borrow::Cow<'static, str>`]-parameterized call site
3758 // through a `std::borrow::Cow::Borrowed(dialeto.as_str())` /
3759 // `std::borrow::Cow::Owned(dialeto.to_string())` /
3760 // `String::from(dialeto).into()` composition whose type
3761 // bounds have no compile-time link back to the substrate
3762 // primitive.
3763 //
3764 // Also asserts the projection lands on the zero-alloc
3765 // [`std::borrow::Cow::Borrowed`] arm (not the
3766 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
3767 // [`super::CaixaDialeto::as_str`] accessor's `&'static str`
3768 // return lifetime by construction makes the borrowed arm the
3769 // type-correct projection with no runtime allocation. Any
3770 // future silent detour that routes the impl through the
3771 // owned arm (an accidental
3772 // `std::borrow::Cow::Owned(dialeto.to_string())` rewrite that
3773 // would allocate on every call site where the `&'static str`
3774 // return of [`super::CaixaDialeto::as_str`] makes the
3775 // zero-alloc borrowed projection type-correct) trips at
3776 // caixa-core test time under the
3777 // [`std::borrow::Cow::Borrowed`] discriminator witness rather
3778 // than at a downstream
3779 // [`std::borrow::Cow<'static, str>`]-bound consumer's silent
3780 // allocation.
3781 //
3782 // Second peer on the outside-M3 caixa-core tier of the
3783 // substrate-wide trait-idiomatic
3784 // [`std::borrow::Cow<'static, str>`] forward-projection
3785 // family — extends the axis off the two-list dep-graph
3786 // [`crate::dep::DepList`] pair (6858bac / 702cdf4) that
3787 // opened + closed the tier onto the dialect-classification
3788 // [`super::CaixaDialeto`] enum (the sole remaining
3789 // internal-classification peer on the caixa-core surface).
3790 // Every future closed-set fieldless typed enum peer on the
3791 // substrate is a future target of the campaign.
3792 for &variant in CaixaDialeto::ALL {
3793 let via_trait: std::borrow::Cow<'static, str> =
3794 <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
3795 let via_method: &'static str = variant.as_str();
3796 assert_eq!(
3797 via_trait.as_ref(),
3798 via_method,
3799 "From<CaixaDialeto> for Cow<'static, str> impl must \
3800 round-trip CaixaDialeto::{variant:?} to the same \
3801 PascalCase byte-string CaixaDialeto::as_str returns \
3802 — divergence signals a silent detour off the \
3803 substrate-primitive accessor"
3804 );
3805 assert!(
3806 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
3807 "From<CaixaDialeto> for Cow<'static, str> impl must \
3808 land on the zero-alloc Cow::Borrowed arm on \
3809 CaixaDialeto::{variant:?} — a Cow::Owned outcome \
3810 signals the projection has silently allocated where \
3811 the substrate-primitive CaixaDialeto::as_str \
3812 `&'static str` return makes the borrowed arm the \
3813 type-correct projection"
3814 );
3815 let via_into: std::borrow::Cow<'static, str> = variant.into();
3816 assert_eq!(
3817 via_into.as_ref(),
3818 via_method,
3819 "Into<Cow<'static, str>>::into on \
3820 CaixaDialeto::{variant:?} must byte-equal \
3821 CaixaDialeto::as_str on the same input — the \
3822 blanket-derived Into shape must resolve to the same \
3823 as_str dispatch as the explicit From impl"
3824 );
3825 assert!(
3826 matches!(via_into, std::borrow::Cow::Borrowed(_)),
3827 "Into<Cow<'static, str>>::into on \
3828 CaixaDialeto::{variant:?} must land on the zero-alloc \
3829 Cow::Borrowed arm — the blanket-derived Into shape \
3830 must resolve to the same Cow::Borrowed dispatch as \
3831 the explicit From impl"
3832 );
3833 }
3834 }
3835
3836 #[test]
3837 fn caixa_dialeto_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
3838 // Cross-axis partition pin: the newly lifted trait-idiomatic
3839 // `From<CaixaDialeto> for std::borrow::Cow<'static, str>`
3840 // (this lift), the paired owned-input
3841 // `From<CaixaDialeto> for &'static str`, and the paired
3842 // owned-input `From<CaixaDialeto> for String` forward
3843 // projections must resolve identically on every arm, locking
3844 // the three return-shape paths together by construction so
3845 // any future detour trips at caixa-core test time. Also
3846 // byte-parity witness against the sibling
3847 // [`ToString::to_string`] surface routed through
3848 // [`std::fmt::Display`] — every owned-heap-string path (the
3849 // [`std::borrow::Cow::Owned`] promotion of this axis's
3850 // `.into_owned()`, `From<CaixaDialeto> for String`, and
3851 // `.to_string()`) resolves to the same PascalCase byte-string
3852 // per arm.
3853 //
3854 // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
3855 // witness over [`super::CaixaDialeto::ALL`] that materializes
3856 // the four-arm accept-set through the
3857 // [`std::borrow::Cow<'static, str>`] axis alone — the exact
3858 // shape a future `axum::response::IntoResponse` per-arm
3859 // rejection-body composer, a future M4
3860 // `mesh.pleme.io/v1alpha1/Manifesto` CR materializer's
3861 // admission-webhook per-arm rejection-reason emitter whose
3862 // typing rules out the sibling [`AsRef<str>`] borrowed
3863 // return, or a future substrate-wide per-arm diagnostic
3864 // surface that binds through a
3865 // [`std::borrow::Cow<'static, str>`] boundary reaches through
3866 // — closing the composable-projection axis on the dialect-
3867 // classification closed-set fieldless typed enum peer. The
3868 // pipe witness also pins the zero-alloc discipline: every
3869 // element in the collected vector satisfies the
3870 // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
3871 // accidental silent-allocation regression on the pipe's
3872 // iteration axis is a caixa-core-test-time failure.
3873 //
3874 // Then a direct round-trip witness through
3875 // [`TryFrom<&str>`] on the projection's
3876 // [`std::borrow::Cow::as_ref`] borrow — unlike the peer
3877 // [`crate::CaixaKind`] axis pair (whose forward emit lands
3878 // on the lowercase Portuguese diagnostic vocabulary while
3879 // the reverse parse lands on the `PascalCase` wire
3880 // vocabulary, forcing the round-trip through an intermediate
3881 // [`crate::CaixaKind::wire_name`] hop),
3882 // [`super::CaixaDialeto`]'s forward emit and reverse parse
3883 // share one `PascalCase` vocabulary by construction, so the
3884 // [`std::borrow::Cow<'static, str>`] projection composes
3885 // directly with the trait-idiomatic reverse [`TryFrom<&str>`]
3886 // axis without the wire-vocab intermediate hop.
3887 for &variant in CaixaDialeto::ALL {
3888 let via_cow: std::borrow::Cow<'static, str> =
3889 <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
3890 let via_static: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
3891 let via_string: String = <String as From<CaixaDialeto>>::from(variant);
3892 assert_eq!(
3893 via_cow.as_ref(),
3894 via_static,
3895 "From<CaixaDialeto> for Cow<'static, str> and \
3896 From<CaixaDialeto> for &'static str must resolve \
3897 identically on CaixaDialeto::{variant:?} — \
3898 divergence signals the Cow<'static, str> and \
3899 &'static str return-shape paths have drifted onto \
3900 different emit-sets"
3901 );
3902 assert_eq!(
3903 via_cow.as_ref(),
3904 via_string.as_str(),
3905 "From<CaixaDialeto> for Cow<'static, str> and \
3906 From<CaixaDialeto> for String must resolve \
3907 identically on CaixaDialeto::{variant:?} — \
3908 divergence signals the Cow<'static, str> and String \
3909 return-shape paths have drifted onto different \
3910 emit-sets"
3911 );
3912 let via_to_string: String = variant.to_string();
3913 assert_eq!(
3914 via_cow.as_ref(),
3915 via_to_string.as_str(),
3916 "From<CaixaDialeto> for Cow<'static, str> must \
3917 byte-equal CaixaDialeto::to_string on \
3918 CaixaDialeto::{variant:?} — divergence signals the \
3919 trait-idiomatic Cow<'static, str> forward-projection \
3920 axis and the ToString-through-Display axis have \
3921 drifted onto different emit-sets"
3922 );
3923 }
3924 let via_iter: Vec<std::borrow::Cow<'static, str>> = CaixaDialeto::ALL
3925 .iter()
3926 .copied()
3927 .map(std::borrow::Cow::from)
3928 .collect();
3929 let via_method: Vec<std::borrow::Cow<'static, str>> = CaixaDialeto::ALL
3930 .iter()
3931 .map(|d| std::borrow::Cow::Borrowed(d.as_str()))
3932 .collect();
3933 assert_eq!(
3934 via_iter, via_method,
3935 "`.iter().copied().map(Cow::from)` over \
3936 CaixaDialeto::ALL must byte-equal `.iter().map(|d| \
3937 Cow::Borrowed(d.as_str()))` on every arm — the \
3938 trait-idiomatic `From<CaixaDialeto> for Cow<'static, \
3939 str>` axis is what makes the `Cow::from` composition \
3940 route through the substrate-primitive \
3941 CaixaDialeto::as_str accessor rather than a per-call-\
3942 site open-code"
3943 );
3944 for cow in &via_iter {
3945 assert!(
3946 matches!(cow, std::borrow::Cow::Borrowed(_)),
3947 "`.iter().copied().map(Cow::from)` over \
3948 CaixaDialeto::ALL must land on the zero-alloc \
3949 Cow::Borrowed arm on every element — a Cow::Owned \
3950 outcome signals the pipe has silently allocated \
3951 where the substrate-primitive \
3952 CaixaDialeto::as_str `&'static str` return makes \
3953 the borrowed arm the type-correct projection"
3954 );
3955 }
3956 for &variant in CaixaDialeto::ALL {
3957 let via_cow: std::borrow::Cow<'static, str> =
3958 <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
3959 let re_parsed: Result<CaixaDialeto, ()> =
3960 <CaixaDialeto as TryFrom<&str>>::try_from(via_cow.as_ref());
3961 assert_eq!(
3962 re_parsed,
3963 Ok(variant),
3964 "trait-idiomatic Cow<'static, str> forward-projection \
3965 + reverse-projection axis pair must round-trip \
3966 CaixaDialeto::{variant:?} through `.into::<Cow<\
3967 'static, str>>()` on the owned-input surface and \
3968 back through `TryFrom<&str>` on the projection's \
3969 Cow::as_ref borrow — a break signals the \
3970 Cow<'static, str> forward-emit and reverse-parse \
3971 axes have drifted onto different vocabularies \
3972 (unlike the peer CaixaKind axis pair, CaixaDialeto's \
3973 forward emit and reverse parse share one PascalCase \
3974 vocabulary by construction, so the round-trip \
3975 composes directly)"
3976 );
3977 }
3978 }
3979
3980 #[test]
3981 fn caixa_dialeto_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
3982 // Fail-before-pass-after byte-parity pin on the newly lifted
3983 // `impl From<&CaixaDialeto> for std::borrow::Cow<'static,
3984 // str>` — asserts the borrowed-input standard-library trait
3985 // impl and the substrate-primitive
3986 // [`super::CaixaDialeto::as_str`] `pub const fn` accessor
3987 // resolve to the same four-arm PascalCase emit-set across
3988 // every arm the exhaustive [`super::CaixaDialeto::ALL`] slice
3989 // enumerates. Rust's standard library does not carry a blanket
3990 // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
3991 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
3992 // the borrowed-input `Cow<'static, str>` forward-projection
3993 // axis is a distinct trait-idiomatic surface that a
3994 // `let key: Cow<'static, str> = (&dialeto).into();`-shaped
3995 // call site or a `CaixaDialeto::ALL.iter().map(Cow::from)`-
3996 // shaped pipe reaches through this impl and no other — the
3997 // paired owned-input `From<CaixaDialeto> for Cow<'static, str>`
3998 // impl (8322511) forces every borrowed-input call site
3999 // through an explicit `Copy` deref (`Cow::from(*dialeto)`) or
4000 // a `Cow::Borrowed(dialeto.as_str())` open-code whose type
4001 // bounds have no compile-time link back to the substrate
4002 // primitive.
4003 //
4004 // Also asserts the projection lands on the zero-alloc
4005 // [`std::borrow::Cow::Borrowed`] arm (not the
4006 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
4007 // [`super::CaixaDialeto::as_str`] accessor's `&'static str`
4008 // return lifetime by construction makes the borrowed arm the
4009 // type-correct projection with no runtime allocation on the
4010 // borrowed-input surface just as on the paired owned-input
4011 // surface.
4012 //
4013 // Closes the `{Self, &Self}` input-shape corner on the
4014 // outside-M3 caixa-core dialect-classification
4015 // [`Cow<'static, str>`] axis on the second outside-M3
4016 // caixa-core closed-set fieldless typed enum peer on the
4017 // caixa surface, exactly as 702cdf4 closed it on the first
4018 // outside-M3 caixa-core peer ([`crate::dep::DepList`]) one
4019 // commit after the owning half (6858bac) landed, as afdf0f4
4020 // closed it on the second M3-mesh-primitive peer
4021 // ([`crate::aplicacao::PlacementStrategy`]) one commit after
4022 // the owning half (eee504d) landed, as 25690ef closed it on
4023 // the first M3-mesh-primitive peer
4024 // ([`crate::aplicacao::WitShape`]) one commit after the
4025 // owning half (8634dec) landed, as d45c409 closed it on the
4026 // top-level [`crate::CaixaKind`] one commit after the owning
4027 // half (99c1735) landed, and as 9b3e4b3 / ee577fd closed it
4028 // on the M2 OTP-shape [`crate::supervisor::RestartStrategy`]
4029 // / [`crate::supervisor::RestartPolicy`] sibling peers one
4030 // commit after (7dd28b3 / 0612398) landed.
4031 for &variant in CaixaDialeto::ALL {
4032 let via_trait: std::borrow::Cow<'static, str> =
4033 <std::borrow::Cow<'static, str> as From<&CaixaDialeto>>::from(&variant);
4034 let via_method: &'static str = variant.as_str();
4035 assert_eq!(
4036 via_trait.as_ref(),
4037 via_method,
4038 "From<&CaixaDialeto> for Cow<'static, str> impl must \
4039 round-trip &CaixaDialeto::{variant:?} to the same \
4040 PascalCase byte-string CaixaDialeto::as_str returns \
4041 — divergence signals a silent detour off the \
4042 substrate-primitive accessor"
4043 );
4044 assert!(
4045 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
4046 "From<&CaixaDialeto> for Cow<'static, str> impl must \
4047 land on the zero-alloc Cow::Borrowed arm on \
4048 &CaixaDialeto::{variant:?} — a Cow::Owned outcome \
4049 signals the projection has silently allocated where \
4050 the substrate-primitive CaixaDialeto::as_str \
4051 `&'static str` return makes the borrowed arm the \
4052 type-correct projection"
4053 );
4054 let via_into: std::borrow::Cow<'static, str> = (&variant).into();
4055 assert_eq!(
4056 via_into.as_ref(),
4057 via_method,
4058 "Into<Cow<'static, str>>::into on \
4059 &CaixaDialeto::{variant:?} must byte-equal \
4060 CaixaDialeto::as_str on the same input — the \
4061 blanket-derived Into shape on the borrowed-input \
4062 surface must resolve to the same as_str dispatch as \
4063 the explicit From impl"
4064 );
4065 assert!(
4066 matches!(via_into, std::borrow::Cow::Borrowed(_)),
4067 "Into<Cow<'static, str>>::into on \
4068 &CaixaDialeto::{variant:?} must land on the \
4069 zero-alloc Cow::Borrowed arm — the blanket-derived \
4070 Into shape on the borrowed-input surface must \
4071 resolve to the same Cow::Borrowed dispatch as the \
4072 explicit From impl"
4073 );
4074 }
4075 }
4076
4077 #[test]
4078 #[allow(
4079 clippy::too_many_lines,
4080 reason = "cross-axis partition pin folds four return-shape paths \
4081 (borrowed-input Cow<'static, str>, owned-input Cow<'static, str>, \
4082 borrowed-input &'static str, borrowed-input String) plus the \
4083 ToString-through-Display witness plus a `.iter().map(Cow::from)` \
4084 pipe witness with zero-alloc discriminator plus a direct \
4085 round-trip witness through TryFrom<&str> over four typed \
4086 variants; the linear per-axis repetition is exactly what the \
4087 fold is pinning — a helper would hide the shape it locks"
4088 )]
4089 fn caixa_dialeto_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
4090 // Cross-axis partition pin: the newly lifted trait-idiomatic
4091 // borrowed-input `From<&CaixaDialeto> for
4092 // std::borrow::Cow<'static, str>` (this lift), the paired
4093 // owned-input `From<CaixaDialeto> for
4094 // std::borrow::Cow<'static, str>`, the paired borrowed-input
4095 // `From<&CaixaDialeto> for &'static str`, and the paired
4096 // borrowed-input `From<&CaixaDialeto> for String` forward
4097 // projections must resolve identically on every arm, locking
4098 // the four return-shape paths together by construction so any
4099 // future detour trips at caixa-core test time. Also
4100 // byte-parity witness against the sibling
4101 // [`ToString::to_string`] surface routed through
4102 // [`std::fmt::Display`].
4103 //
4104 // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
4105 // over [`super::CaixaDialeto::ALL`] — whose iterator yields
4106 // `&CaixaDialeto` by construction, so the borrowed-input
4107 // [`std::borrow::Cow<'static, str>`] axis is what routes the
4108 // pipe through the substrate-primitive
4109 // [`super::CaixaDialeto::as_str`] accessor with the zero-alloc
4110 // [`std::borrow::Cow::Borrowed`] arm and without a spurious
4111 // [`Copy`] deref. Every collected element satisfies the
4112 // [`std::borrow::Cow::Borrowed`]-arm predicate so a future
4113 // accidental silent-allocation regression on the pipe's
4114 // iteration axis is a caixa-core-test-time failure.
4115 //
4116 // Then a direct round-trip witness through [`TryFrom<&str>`]
4117 // on the projection's [`std::borrow::Cow::as_ref`] borrow —
4118 // unlike the peer [`crate::CaixaKind`] axis pair (whose
4119 // forward emit lands on the lowercase Portuguese diagnostic
4120 // vocabulary while the reverse parse lands on the
4121 // `PascalCase` wire vocabulary, forcing the round-trip
4122 // through an intermediate [`crate::CaixaKind::wire_name`]
4123 // hop), [`super::CaixaDialeto`]'s forward emit and reverse
4124 // parse share one `PascalCase` vocabulary by construction, so
4125 // the borrowed-input [`std::borrow::Cow<'static, str>`]
4126 // projection composes directly with the trait-idiomatic
4127 // reverse [`TryFrom<&str>`] axis without the wire-vocab
4128 // intermediate hop.
4129 for &variant in CaixaDialeto::ALL {
4130 let via_borrowed_cow: std::borrow::Cow<'static, str> =
4131 <std::borrow::Cow<'static, str> as From<&CaixaDialeto>>::from(&variant);
4132 let via_owned_cow: std::borrow::Cow<'static, str> =
4133 <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
4134 let via_borrowed_static: &'static str =
4135 <&'static str as From<&CaixaDialeto>>::from(&variant);
4136 let via_borrowed_string: String = <String as From<&CaixaDialeto>>::from(&variant);
4137 assert_eq!(
4138 via_borrowed_cow.as_ref(),
4139 via_owned_cow.as_ref(),
4140 "From<&CaixaDialeto> for Cow<'static, str> and \
4141 From<CaixaDialeto> for Cow<'static, str> must \
4142 resolve identically on CaixaDialeto::{variant:?} — \
4143 divergence signals the borrowed-input and \
4144 owned-input Cow<'static, str> return-shape paths \
4145 have drifted onto different emit-sets"
4146 );
4147 assert_eq!(
4148 via_borrowed_cow.as_ref(),
4149 via_borrowed_static,
4150 "From<&CaixaDialeto> for Cow<'static, str> and \
4151 From<&CaixaDialeto> for &'static str must resolve \
4152 identically on CaixaDialeto::{variant:?} — \
4153 divergence signals the borrowed-input Cow<'static, \
4154 str> and borrowed-input &'static str return-shape \
4155 paths have drifted onto different emit-sets"
4156 );
4157 assert_eq!(
4158 via_borrowed_cow.as_ref(),
4159 via_borrowed_string.as_str(),
4160 "From<&CaixaDialeto> for Cow<'static, str> and \
4161 From<&CaixaDialeto> for String must resolve \
4162 identically on CaixaDialeto::{variant:?} — \
4163 divergence signals the borrowed-input Cow<'static, \
4164 str> and borrowed-input String return-shape paths \
4165 have drifted onto different emit-sets"
4166 );
4167 let via_to_string: String = variant.to_string();
4168 assert_eq!(
4169 via_borrowed_cow.as_ref(),
4170 via_to_string.as_str(),
4171 "From<&CaixaDialeto> for Cow<'static, str> must \
4172 byte-equal CaixaDialeto::to_string on \
4173 CaixaDialeto::{variant:?} — divergence signals the \
4174 borrowed-input Cow<'static, str> forward-projection \
4175 axis and the ToString-through-Display axis have \
4176 drifted onto different emit-sets"
4177 );
4178 }
4179 let via_iter: Vec<std::borrow::Cow<'static, str>> = CaixaDialeto::ALL
4180 .iter()
4181 .map(std::borrow::Cow::from)
4182 .collect();
4183 let via_method: Vec<std::borrow::Cow<'static, str>> = CaixaDialeto::ALL
4184 .iter()
4185 .map(|d| std::borrow::Cow::Borrowed(d.as_str()))
4186 .collect();
4187 assert_eq!(
4188 via_iter, via_method,
4189 "`.iter().map(Cow::from)` over CaixaDialeto::ALL must \
4190 byte-equal `.iter().map(|d| Cow::Borrowed(d.as_str()))` \
4191 on every arm — the trait-idiomatic `From<&CaixaDialeto> \
4192 for Cow<'static, str>` axis is what makes the \
4193 `Cow::from` composition on the borrowed-iteration axis \
4194 route through the substrate-primitive \
4195 CaixaDialeto::as_str accessor without a spurious Copy \
4196 deref"
4197 );
4198 for cow in &via_iter {
4199 assert!(
4200 matches!(cow, std::borrow::Cow::Borrowed(_)),
4201 "`.iter().map(Cow::from)` over CaixaDialeto::ALL \
4202 must land on the zero-alloc Cow::Borrowed arm on \
4203 every element — a Cow::Owned outcome signals the \
4204 borrowed-iteration pipe has silently allocated \
4205 where the substrate-primitive CaixaDialeto::as_str \
4206 `&'static str` return makes the borrowed arm the \
4207 type-correct projection"
4208 );
4209 }
4210 for &variant in CaixaDialeto::ALL {
4211 let via_cow: std::borrow::Cow<'static, str> =
4212 <std::borrow::Cow<'static, str> as From<&CaixaDialeto>>::from(&variant);
4213 let re_parsed: Result<CaixaDialeto, ()> =
4214 <CaixaDialeto as TryFrom<&str>>::try_from(via_cow.as_ref());
4215 assert_eq!(
4216 re_parsed,
4217 Ok(variant),
4218 "trait-idiomatic borrowed-input Cow<'static, str> \
4219 forward-projection + reverse-projection axis pair \
4220 must round-trip &CaixaDialeto::{variant:?} through \
4221 `.into::<Cow<'static, str>>()` on the borrowed-input \
4222 surface and back through `TryFrom<&str>` on the \
4223 projection's Cow::as_ref borrow — a break signals \
4224 the borrowed-input Cow<'static, str> forward-emit \
4225 and reverse-parse axes have drifted onto different \
4226 vocabularies (unlike the peer CaixaKind axis pair, \
4227 CaixaDialeto's forward emit and reverse parse share \
4228 one PascalCase vocabulary by construction, so the \
4229 round-trip composes directly)"
4230 );
4231 }
4232 }
4233
4234 #[test]
4235 fn caixa_dialeto_from_into_box_str_routes_through_as_str_accessor() {
4236 // Fail-before-pass-after byte-parity pin on the newly lifted
4237 // `impl From<CaixaDialeto> for Box<str>` — asserts the owned-
4238 // input standard-library trait impl and the substrate-primitive
4239 // [`super::CaixaDialeto::as_str`] `pub const fn` accessor
4240 // resolve to the same four-arm PascalCase emit-set across every
4241 // arm the exhaustive [`super::CaixaDialeto::ALL`] slice
4242 // enumerates. Extends the caixa-core-internal tier of the
4243 // substrate-wide [`Box<str>`] forward-projection campaign onto
4244 // the third caixa-core-internal peer, after the render-side
4245 // path-shape-diagnostic
4246 // [`super::super::render::PathShapeViolation`] pair (0d87a72,
4247 // both corners in one axis) opened the tier and the outside-M3
4248 // caixa-core two-list dep-graph [`super::super::dep::DepList`]
4249 // pair (4aada99, both corners in one axis) extended it. Rust's
4250 // standard library carries `impl From<&str> for Box<str>` and
4251 // `impl From<String> for Box<str>` but no blanket
4252 // `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a
4253 // distinct trait-idiomatic surface that a
4254 // `let key: Box<str> = dialeto.into();`-shaped call site reaches
4255 // through this impl and no other — a paired
4256 // `Box::from(dialeto.as_str())` open-code has no compile-time
4257 // link back to the substrate primitive.
4258 for &variant in CaixaDialeto::ALL {
4259 let via_trait: Box<str> = <Box<str> as From<CaixaDialeto>>::from(variant);
4260 let via_method: &'static str = variant.as_str();
4261 assert_eq!(
4262 via_trait.as_ref(),
4263 via_method,
4264 "From<CaixaDialeto> for Box<str> impl must round-trip \
4265 CaixaDialeto::{variant:?} to the same PascalCase \
4266 byte-string CaixaDialeto::as_str returns — divergence \
4267 signals a silent detour off the substrate-primitive \
4268 accessor"
4269 );
4270 let via_into: Box<str> = variant.into();
4271 assert_eq!(
4272 via_into.as_ref(),
4273 via_method,
4274 "Into<Box<str>>::into on CaixaDialeto::{variant:?} must \
4275 byte-equal CaixaDialeto::as_str on the same input — \
4276 the blanket-derived Into shape must resolve to the \
4277 same as_str dispatch as the explicit From impl"
4278 );
4279 }
4280 }
4281
4282 #[test]
4283 fn caixa_dialeto_from_borrowed_into_box_str_routes_through_as_str_accessor() {
4284 // Fail-before-pass-after byte-parity pin on the newly lifted
4285 // `impl From<&CaixaDialeto> for Box<str>` — asserts the
4286 // borrowed-input standard-library trait impl and the substrate-
4287 // primitive [`super::CaixaDialeto::as_str`] `pub const fn`
4288 // accessor resolve to the same four-arm PascalCase emit-set
4289 // across every arm the exhaustive [`super::CaixaDialeto::ALL`]
4290 // slice enumerates. Rust's standard library carries
4291 // `impl From<&str> for Box<str>` and `impl From<String> for
4292 // Box<str>` but no blanket
4293 // `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-
4294 // based `impl<T: Copy, U: From<T>> From<&T> for U`), so the
4295 // borrowed-input [`Box<str>`] forward-projection axis is a
4296 // distinct trait-idiomatic surface that a
4297 // `CaixaDialeto::ALL.iter().map(Box::<str>::from)`-shaped pipe
4298 // (whose iterator over `&'static [CaixaDialeto]` yields
4299 // `&CaixaDialeto` by construction) or a
4300 // `let key: Box<str> = (&dialeto).into();`-shaped call site
4301 // reaches through this impl and no other — the paired owned-
4302 // input `From<CaixaDialeto> for Box<str>` impl alone would
4303 // force every borrowed-input call site through an explicit
4304 // `Copy` deref (`Box::<str>::from(*dialeto)`) or a
4305 // `Box::<str>::from(dialeto.as_str())` open-code whose type
4306 // bounds have no compile-time link back to the substrate
4307 // primitive.
4308 //
4309 // Closes the `{Self, &Self}` input-shape corner on the third
4310 // caixa-core-internal closed-set fieldless typed enum peer of
4311 // the substrate-wide [`Box<str>`] forward-projection campaign,
4312 // matching the trajectory the paired render-side path-shape-
4313 // diagnostic [`super::super::render::PathShapeViolation`] pair
4314 // (0d87a72, both corners in one axis) and the paired outside-M3
4315 // caixa-core two-list dep-graph [`super::super::dep::DepList`]
4316 // pair (4aada99, both corners in one axis) walked before it.
4317 for &variant in CaixaDialeto::ALL {
4318 let via_trait: Box<str> = <Box<str> as From<&CaixaDialeto>>::from(&variant);
4319 let via_method: &'static str = variant.as_str();
4320 assert_eq!(
4321 via_trait.as_ref(),
4322 via_method,
4323 "From<&CaixaDialeto> for Box<str> impl must round-trip \
4324 &CaixaDialeto::{variant:?} to the same PascalCase \
4325 byte-string CaixaDialeto::as_str returns — divergence \
4326 signals a silent detour off the substrate-primitive \
4327 accessor"
4328 );
4329 let via_into: Box<str> = (&variant).into();
4330 assert_eq!(
4331 via_into.as_ref(),
4332 via_method,
4333 "Into<Box<str>>::into on &CaixaDialeto::{variant:?} \
4334 must byte-equal CaixaDialeto::as_str on the same \
4335 input — the blanket-derived Into shape on the \
4336 borrowed-input surface must resolve to the same \
4337 as_str dispatch as the explicit From impl"
4338 );
4339 }
4340
4341 // Pipe witness — the distinguishing shape that forces the
4342 // borrowed-input axis to be independent of the owned-input
4343 // peer. `CaixaDialeto::ALL.iter()` yields `&CaixaDialeto` by
4344 // construction, so `.map(Box::<str>::from)` resolves through
4345 // the borrowed-input `From<&CaixaDialeto> for Box<str>` impl
4346 // and no other — without this axis, the same pipe would force
4347 // an explicit `.copied()` restatement whose type bounds bypass
4348 // the substrate primitive.
4349 let via_pipe: Vec<Box<str>> = CaixaDialeto::ALL.iter().map(Box::<str>::from).collect();
4350 let via_accessor: Vec<&'static str> =
4351 CaixaDialeto::ALL.iter().map(|d| d.as_str()).collect();
4352 assert_eq!(
4353 via_pipe.len(),
4354 via_accessor.len(),
4355 "CaixaDialeto::ALL.iter().map(Box::<str>::from) pipe must \
4356 preserve arity against the paired CaixaDialeto::as_str \
4357 accessor — a length divergence signals the borrowed-input \
4358 axis has silently rejected an arm"
4359 );
4360 for (pipe_arm, accessor_arm) in via_pipe.iter().zip(via_accessor.iter()) {
4361 assert_eq!(
4362 pipe_arm.as_ref(),
4363 *accessor_arm,
4364 "CaixaDialeto::ALL.iter().map(Box::<str>::from) pipe \
4365 must byte-equal the paired \
4366 CaixaDialeto::ALL.iter().map(|d| d.as_str()) pipe on \
4367 every arm — divergence signals the borrowed-input \
4368 `From<&CaixaDialeto> for Box<str>` axis has silently \
4369 detoured off the substrate-primitive accessor"
4370 );
4371 }
4372 }
4373
4374 #[test]
4375 fn caixa_dialeto_from_into_arc_str_routes_through_as_str_accessor() {
4376 // Fail-before-pass-after byte-parity pin on the newly lifted
4377 // `impl From<CaixaDialeto> for std::sync::Arc<str>` — asserts the
4378 // owned-input standard-library trait impl and the substrate-
4379 // primitive [`super::CaixaDialeto::as_str`] `pub const fn` accessor
4380 // resolve to the same four-arm PascalCase emit-set across every
4381 // arm the exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
4382 // Extends the caixa-core-internal tier of the substrate-wide
4383 // [`std::sync::Arc<str>`] forward-projection campaign onto the
4384 // third caixa-core-internal peer, after the structurally most
4385 // fundamental [`super::super::CaixaKind`] pair (c17be64, both
4386 // corners in one axis) opened the tier and the outside-M3 two-list
4387 // dep-graph [`super::super::dep::DepList`] pair (d8a4652, both
4388 // corners in one axis) extended it. Rust's standard library
4389 // carries `impl From<&str> for std::sync::Arc<str>` and
4390 // `impl From<String> for std::sync::Arc<str>` but no blanket
4391 // `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
4392 // `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so
4393 // this axis is a distinct trait-idiomatic surface that a
4394 // `let key: std::sync::Arc<str> = dialeto.into();`-shaped call
4395 // site reaches through this impl and no other — a paired
4396 // `std::sync::Arc::<str>::from(dialeto.as_str())` open-code has no
4397 // compile-time link back to the substrate primitive, and a two-
4398 // step `std::sync::Arc::<str>::from(String::from(dialeto))`
4399 // composition through the owned-`String` axis allocates twice
4400 // where the single-step trait impl allocates once.
4401 //
4402 // Cross-axis byte-parity witness against the sibling owned-input
4403 // `{&'static str, String, Cow<'static, str>, Box<str>}` return-
4404 // shape axes — locking the five return-shape paths on the owned-
4405 // input surface together by construction so any future detour off
4406 // the substrate-primitive [`super::CaixaDialeto::as_str`] accessor
4407 // trips at caixa-core test time.
4408 for &variant in CaixaDialeto::ALL {
4409 let via_trait: std::sync::Arc<str> =
4410 <std::sync::Arc<str> as From<CaixaDialeto>>::from(variant);
4411 let via_method: &'static str = variant.as_str();
4412 assert_eq!(
4413 via_trait.as_ref(),
4414 via_method,
4415 "From<CaixaDialeto> for std::sync::Arc<str> impl must \
4416 round-trip CaixaDialeto::{variant:?} to the same \
4417 PascalCase byte-string CaixaDialeto::as_str returns — \
4418 divergence signals a silent detour off the substrate-\
4419 primitive accessor"
4420 );
4421 let via_into: std::sync::Arc<str> = variant.into();
4422 assert_eq!(
4423 via_into.as_ref(),
4424 via_method,
4425 "Into<std::sync::Arc<str>>::into on CaixaDialeto::\
4426 {variant:?} must byte-equal CaixaDialeto::as_str on the \
4427 same input — the blanket-derived Into shape must resolve \
4428 to the same as_str dispatch as the explicit From impl"
4429 );
4430 let owned_static: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
4431 assert_eq!(
4432 via_trait.as_ref(),
4433 owned_static,
4434 "From<CaixaDialeto> for std::sync::Arc<str> and \
4435 From<CaixaDialeto> for &'static str must resolve \
4436 identically on CaixaDialeto::{variant:?} — divergence \
4437 signals the owned-input std::sync::Arc<str> and \
4438 &'static str return-shape paths have drifted onto \
4439 different emit-sets"
4440 );
4441 let owned_string: String = <String as From<CaixaDialeto>>::from(variant);
4442 assert_eq!(
4443 via_trait.as_ref(),
4444 owned_string.as_str(),
4445 "From<CaixaDialeto> for std::sync::Arc<str> and \
4446 From<CaixaDialeto> for String must resolve identically \
4447 on CaixaDialeto::{variant:?} — divergence signals the \
4448 owned-input std::sync::Arc<str> and owned-`String` \
4449 return-shape paths have drifted onto different emit-sets"
4450 );
4451 let owned_cow: std::borrow::Cow<'static, str> =
4452 <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
4453 assert_eq!(
4454 via_trait.as_ref(),
4455 owned_cow.as_ref(),
4456 "From<CaixaDialeto> for std::sync::Arc<str> and \
4457 From<CaixaDialeto> for Cow<'static, str> must resolve \
4458 identically on CaixaDialeto::{variant:?} — divergence \
4459 signals the owned-input std::sync::Arc<str> and \
4460 Cow<'static, str> return-shape paths have drifted onto \
4461 different emit-sets"
4462 );
4463 let owned_box: Box<str> = <Box<str> as From<CaixaDialeto>>::from(variant);
4464 assert_eq!(
4465 via_trait.as_ref(),
4466 owned_box.as_ref(),
4467 "From<CaixaDialeto> for std::sync::Arc<str> and \
4468 From<CaixaDialeto> for Box<str> must resolve identically \
4469 on CaixaDialeto::{variant:?} — divergence signals the \
4470 owned-input std::sync::Arc<str> and Box<str> return-\
4471 shape paths have drifted onto different emit-sets"
4472 );
4473 }
4474 }
4475
4476 #[test]
4477 #[allow(
4478 clippy::too_many_lines,
4479 reason = "cross-axis partition pin folds four borrowed-input \
4480 return-shape paths (&'static str, String, Cow<'static, \
4481 str>, Box<str>) plus the paired owned-input Arc<str> \
4482 witness and the .iter().map(std::sync::Arc::<str>::from) \
4483 pipe witness into one exhaustive round-trip over \
4484 CaixaDialeto::ALL — the accepted line-count cost of \
4485 keying the whole borrowed-input Arc<str> corner to the \
4486 substrate-primitive as_str accessor at the same test-site"
4487 )]
4488 fn caixa_dialeto_from_borrowed_into_arc_str_routes_through_as_str_accessor() {
4489 // Fail-before-pass-after byte-parity pin on the newly lifted
4490 // `impl From<&CaixaDialeto> for std::sync::Arc<str>` — asserts the
4491 // borrowed-input standard-library trait impl and the substrate-
4492 // primitive [`super::CaixaDialeto::as_str`] `pub const fn` accessor
4493 // resolve to the same four-arm PascalCase emit-set across every
4494 // arm the exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
4495 // Rust's standard library does not carry a blanket
4496 // `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a
4497 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
4498 // the borrowed-input `std::sync::Arc<str>` forward-projection axis
4499 // is a distinct trait-idiomatic surface that a
4500 // `let key: std::sync::Arc<str> = (&dialeto).into();`-shaped call
4501 // site or a
4502 // `CaixaDialeto::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped
4503 // pipe reaches through this impl and no other — the paired owned-
4504 // input `From<CaixaDialeto> for std::sync::Arc<str>` impl alone
4505 // forces every borrowed-input call site through a spurious `Copy`
4506 // deref (`std::sync::Arc::<str>::from((*dialeto).as_str())`) or a
4507 // `.copied()` restatement whose type bounds have no compile-time
4508 // link back to the substrate primitive.
4509 //
4510 // Closes the `{Self, &Self}` input-shape corner on the caixa-
4511 // core-internal tier of the substrate-wide trait-idiomatic
4512 // [`std::sync::Arc<str>`] forward-projection campaign for the
4513 // third caixa-core-internal enum peer, matching the
4514 // `{Self, &Self} × {&'static str, String, Cow<'static, str>,
4515 // Box<str>}` 2×4 forward-projection matrix the peer projection
4516 // surfaces already close on this same enum.
4517 //
4518 // Cross-axis partition pin against the paired owned-input
4519 // [`From<CaixaDialeto> for std::sync::Arc<str>`] and the sibling
4520 // borrowed-input `{&'static str, String, Cow<'static, str>,
4521 // Box<str>}` return-shape axes — locking the five return-shape ×
4522 // input-shape paths on the borrowed-input surface together by
4523 // construction so any future detour off the substrate-primitive
4524 // accessor trips at caixa-core test time. Then a
4525 // `.iter().map(std::sync::Arc::<str>::from)` pipe witness over
4526 // [`super::CaixaDialeto::ALL`] — whose iterator yields
4527 // `&CaixaDialeto` by construction, so the borrowed-input
4528 // [`std::sync::Arc<str>`] axis is what routes the pipe through the
4529 // substrate-primitive [`super::CaixaDialeto::as_str`] accessor
4530 // without a spurious [`Copy`] deref (which would only be reachable
4531 // through the owned-input
4532 // [`From<CaixaDialeto> for std::sync::Arc<str>`] axis by first
4533 // calling `.copied()` on the iterator).
4534 for &variant in CaixaDialeto::ALL {
4535 let via_trait: std::sync::Arc<str> =
4536 <std::sync::Arc<str> as From<&CaixaDialeto>>::from(&variant);
4537 let via_method: &'static str = variant.as_str();
4538 assert_eq!(
4539 via_trait.as_ref(),
4540 via_method,
4541 "From<&CaixaDialeto> for std::sync::Arc<str> impl must \
4542 round-trip &CaixaDialeto::{variant:?} to the same \
4543 PascalCase byte-string CaixaDialeto::as_str returns — \
4544 divergence signals a silent detour off the substrate-\
4545 primitive accessor"
4546 );
4547 let via_into: std::sync::Arc<str> = (&variant).into();
4548 assert_eq!(
4549 via_into.as_ref(),
4550 via_method,
4551 "Into<std::sync::Arc<str>>::into on &CaixaDialeto::\
4552 {variant:?} must byte-equal CaixaDialeto::as_str on the \
4553 same input — the blanket-derived Into shape on the \
4554 borrowed-input surface must resolve to the same as_str \
4555 dispatch as the explicit From impl"
4556 );
4557 let owned_arc: std::sync::Arc<str> =
4558 <std::sync::Arc<str> as From<CaixaDialeto>>::from(variant);
4559 assert_eq!(
4560 via_trait, owned_arc,
4561 "From<&CaixaDialeto> for std::sync::Arc<str> and \
4562 From<CaixaDialeto> for std::sync::Arc<str> must resolve \
4563 identically on CaixaDialeto::{variant:?} — divergence \
4564 signals the borrowed-input and owned-input \
4565 std::sync::Arc<str> forward-projection input-shape paths \
4566 have drifted onto different emit-sets"
4567 );
4568 let borrowed_static: &'static str =
4569 <&'static str as From<&CaixaDialeto>>::from(&variant);
4570 assert_eq!(
4571 via_trait.as_ref(),
4572 borrowed_static,
4573 "From<&CaixaDialeto> for std::sync::Arc<str> and \
4574 From<&CaixaDialeto> for &'static str must resolve \
4575 identically on CaixaDialeto::{variant:?} — divergence \
4576 signals the borrowed-input std::sync::Arc<str> and \
4577 &'static str return-shape paths have drifted onto \
4578 different emit-sets"
4579 );
4580 let borrowed_string: String = <String as From<&CaixaDialeto>>::from(&variant);
4581 assert_eq!(
4582 via_trait.as_ref(),
4583 borrowed_string.as_str(),
4584 "From<&CaixaDialeto> for std::sync::Arc<str> and \
4585 From<&CaixaDialeto> for String must resolve identically \
4586 on CaixaDialeto::{variant:?} — divergence signals the \
4587 borrowed-input std::sync::Arc<str> and owned-`String` \
4588 return-shape paths have drifted onto different emit-sets"
4589 );
4590 let borrowed_cow: std::borrow::Cow<'static, str> =
4591 <std::borrow::Cow<'static, str> as From<&CaixaDialeto>>::from(&variant);
4592 assert_eq!(
4593 via_trait.as_ref(),
4594 borrowed_cow.as_ref(),
4595 "From<&CaixaDialeto> for std::sync::Arc<str> and \
4596 From<&CaixaDialeto> for Cow<'static, str> must resolve \
4597 identically on CaixaDialeto::{variant:?} — divergence \
4598 signals the borrowed-input std::sync::Arc<str> and \
4599 Cow<'static, str> return-shape paths have drifted onto \
4600 different emit-sets"
4601 );
4602 let borrowed_box: Box<str> = <Box<str> as From<&CaixaDialeto>>::from(&variant);
4603 assert_eq!(
4604 via_trait.as_ref(),
4605 borrowed_box.as_ref(),
4606 "From<&CaixaDialeto> for std::sync::Arc<str> and \
4607 From<&CaixaDialeto> for Box<str> must resolve \
4608 identically on CaixaDialeto::{variant:?} — divergence \
4609 signals the borrowed-input std::sync::Arc<str> and \
4610 Box<str> return-shape paths have drifted onto different \
4611 emit-sets"
4612 );
4613 }
4614 let via_iter: Vec<std::sync::Arc<str>> = CaixaDialeto::ALL
4615 .iter()
4616 .map(std::sync::Arc::<str>::from)
4617 .collect();
4618 let via_method: Vec<std::sync::Arc<str>> = CaixaDialeto::ALL
4619 .iter()
4620 .map(|d| std::sync::Arc::<str>::from(d.as_str()))
4621 .collect();
4622 assert_eq!(
4623 via_iter, via_method,
4624 "`.iter().map(std::sync::Arc::<str>::from)` over \
4625 CaixaDialeto::ALL — a call site whose iteration axis holds \
4626 `&CaixaDialeto` by construction — must byte-equal \
4627 `.iter().map(|d| std::sync::Arc::<str>::from(d.as_str()))` \
4628 on every arm — the borrowed-input std::sync::Arc<str> \
4629 `From<&CaixaDialeto> for std::sync::Arc<str>` axis is what \
4630 makes the `std::sync::Arc::<str>::from` composition route \
4631 through the substrate-primitive `CaixaDialeto::as_str` \
4632 accessor without a spurious `Copy` deref (which would only \
4633 be reachable through the owned-input \
4634 `From<CaixaDialeto> for std::sync::Arc<str>` axis by first \
4635 calling `.copied()` on the iterator)"
4636 );
4637 }
4638}