Skip to main content

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