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/// Trait-idiomatic *owned-input, [`std::rc::Rc<str>`] output* forward
1642/// projection on the outside-M3 caixa-core dialect-classification
1643/// [`CaixaDialeto`] closed-set fieldless typed enum — the single-threaded
1644/// shared-ownership companion to the paired atomically-refcounted
1645/// [`From<CaixaDialeto> for std::sync::Arc<str>`] impl one commit above.
1646/// Routes byte-for-byte through the substrate-primitive
1647/// [`CaixaDialeto::as_str`] `pub const fn` accessor via
1648/// [`std::rc::Rc::<str>::from`] on the returned `&'static str`, so every
1649/// consumer that binds a `let key: std::rc::Rc<str> = dialeto.into();`-
1650/// shaped call site reaches the same four `"Pacote"` / `"Molde"` /
1651/// `"MoldePosicional"` / `"Desconhecido"` byte-strings the sibling
1652/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>,
1653/// std::sync::Arc<str>}` forward-projection corner already returns.
1654///
1655/// Rust's standard library carries `impl From<&str> for std::rc::Rc<str>`
1656/// and `impl From<String> for std::rc::Rc<str>` but no blanket
1657/// `impl<T: AsRef<str>> From<T> for std::rc::Rc<str>` (nor an
1658/// `impl<T: fmt::Display> From<T> for std::rc::Rc<str>`), and — critically
1659/// — the [`std::sync::Arc<str>`] and [`std::rc::Rc<str>`] layouts share
1660/// the same on-disk shape but the trait tables are disjoint (no blanket
1661/// `impl<T> From<T> for std::rc::Rc<str> where std::sync::Arc<str>: From<T>`
1662/// exists in `core`), so a closed-set enum that carries the paired
1663/// [`std::sync::Arc<str>`] axis but not the paired [`std::rc::Rc<str>`]
1664/// axis forces every single-threaded [`std::rc::Rc<str>`]-typed call site
1665/// through an [`std::rc::Rc::<str>::from`]`(dialeto.as_str())` open-code
1666/// (no compile-time link back to the substrate primitive) or a
1667/// [`std::rc::Rc::<str>::from`]`(String::from(dialeto))` two-step
1668/// composition through the owned-`String` axis that allocates twice
1669/// (once into the intermediate [`String`], once into the
1670/// [`std::rc::Rc<str>`] on the `From<String>` conversion) where the
1671/// single-step trait impl allocates once. The single-threaded shared-
1672/// ownership contract [`std::rc::Rc<str>`] provides — the non-atomic
1673/// strong-and-weak refcount header, cheaper `Clone` than the paired
1674/// atomically-refcounted [`std::sync::Arc<str>`] axis by a measurable
1675/// margin on hot single-threaded call sites — is the distinct value the
1676/// sibling [`std::sync::Arc<str>`] axis's [`Send`] and [`Sync`] return-
1677/// shape cannot provide without paying the atomic-increment cost on
1678/// every clone: a single-threaded `feira dialeto` census pipeline whose
1679/// per-file classify path composes a [`std::rc::Rc<str>`] label into a
1680/// per-arm counter reaches through this axis and not the atomic sibling;
1681/// a single-threaded `HashMap::<std::rc::Rc<str>, _>::from_iter` per-
1682/// dialect lookup where the map's key type is [`std::rc::Rc<str>`] so
1683/// the same dialect-label pointer can key both the map and the payload
1684/// without a second heap allocation reaches through this axis.
1685///
1686/// Extends the caixa-core-internal tier of the substrate-wide trait-
1687/// idiomatic [`std::rc::Rc<str>`] forward-projection campaign onto the
1688/// second caixa-core-internal peer, after the structurally most
1689/// fundamental [`crate::CaixaKind`] pair (4fdfa37, both corners in one
1690/// axis) opened the campaign on the closed-set fieldless typed-enum
1691/// family. Same `{Self, &Self} × {&'static str, String, Cow<'static, str>,
1692/// Box<str>, std::sync::Arc<str>, std::rc::Rc<str>}` 2×6 forward-
1693/// projection matrix the sibling projection surfaces already carry —
1694/// this impl extends the sixth column onto the dialect-classification
1695/// enum's owned-input row.
1696///
1697/// A future arm addition (the module doc's "third dialect" hazard
1698/// actualising as a fifth arm) reaches the paired [`std::rc::Rc<str>`]
1699/// output axis through one match-arm edit on the [`CaixaDialeto::as_str`]
1700/// `pub const fn` accessor, not a coordinated rewrite of every downstream
1701/// `std::rc::Rc::<str>::from(dialeto.as_str())` open-code.
1702///
1703/// Pinned load-bearing by
1704/// [`tests::caixa_dialeto_from_into_rc_str_routes_through_as_str_accessor`]
1705/// (byte-parity pin against [`CaixaDialeto::as_str`] across the four-arm
1706/// [`CaixaDialeto::ALL`] emit-set on the owned-input surface, plus a
1707/// blanket-derived [`Into`] shape witness and cross-axis byte-parity pins
1708/// against the sibling owned-input `{&'static str, String,
1709/// Cow<'static, str>, Box<str>, std::sync::Arc<str>}` return-shape axes).
1710impl From<CaixaDialeto> for std::rc::Rc<str> {
1711    fn from(dialeto: CaixaDialeto) -> std::rc::Rc<str> {
1712        std::rc::Rc::<str>::from(dialeto.as_str())
1713    }
1714}
1715
1716/// Trait-idiomatic *borrowed-input, [`std::rc::Rc<str>`] output* forward
1717/// projection on the outside-M3 caixa-core dialect-classification
1718/// [`CaixaDialeto`] closed-set fieldless typed enum — the borrowed-input
1719/// companion to the paired owned-input
1720/// [`From<CaixaDialeto> for std::rc::Rc<str>`] impl immediately above.
1721/// Routes byte-for-byte through the substrate-primitive
1722/// [`CaixaDialeto::as_str`] `pub const fn` accessor via
1723/// [`std::rc::Rc::<str>::from`] on the returned `&'static str`, so a
1724/// `CaixaDialeto::ALL.iter().map(std::rc::Rc::<str>::from)`-shaped pipe
1725/// (whose iterator over `&'static [CaixaDialeto]` yields `&CaixaDialeto`
1726/// by construction) reaches the same four `"Pacote"` / `"Molde"` /
1727/// `"MoldePosicional"` / `"Desconhecido"` byte-strings the paired owned-
1728/// input axis and the sibling `{Self, &Self} × {&'static str, String,
1729/// Cow<'static, str>, Box<str>, std::sync::Arc<str>}` forward-projection
1730/// corner already return.
1731///
1732/// Rust's standard library carries no blanket
1733/// `impl<T: AsRef<str>> From<&T> for std::rc::Rc<str>` (nor a `Copy`-
1734/// based `impl<T: Copy, U: From<T>> From<&T> for U`), so this borrowed-
1735/// input axis is a distinct trait-idiomatic surface that the pipe shape
1736/// [`CaixaDialeto::ALL`]`.iter().map(std::rc::Rc::<str>::from)` reaches
1737/// through this impl and no other — without it, the same pipe would
1738/// force a spurious [`Copy`] deref
1739/// (`std::rc::Rc::<str>::from((*dialeto).as_str())`) or a `.copied()`
1740/// restatement whose type bounds have no compile-time link back to the
1741/// substrate primitive.
1742///
1743/// Closes the `{Self, &Self}` input-shape corner on the second caixa-
1744/// core-internal closed-set fieldless typed enum peer of the substrate-
1745/// wide trait-idiomatic [`std::rc::Rc<str>`] forward-projection campaign,
1746/// matching the trajectory the paired structurally most fundamental
1747/// [`crate::CaixaKind`] pair (4fdfa37, both corners in one axis) walked
1748/// before it on the caixa-core-internal tier of the same axis. Same
1749/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>,
1750/// std::sync::Arc<str>, std::rc::Rc<str>}` 2×6 forward-projection matrix
1751/// the peer projection surfaces already close on this same enum.
1752///
1753/// Pinned load-bearing by
1754/// [`tests::caixa_dialeto_from_borrowed_into_rc_str_routes_through_as_str_accessor`]
1755/// (byte-parity pin against [`CaixaDialeto::as_str`] across the four-arm
1756/// [`CaixaDialeto::ALL`] emit-set on the borrowed-input surface, plus a
1757/// blanket-derived [`Into`] shape witness, a cross-axis partition pin
1758/// against the paired owned-input
1759/// [`From<CaixaDialeto> for std::rc::Rc<str>`] and the sibling borrowed-
1760/// input `{&'static str, String, Cow<'static, str>, Box<str>,
1761/// std::sync::Arc<str>}` return-shape axes, and a
1762/// `.iter().map(std::rc::Rc::<str>::from)` pipe witness over
1763/// [`CaixaDialeto::ALL`] that resolves through the borrowed-input axis
1764/// without a spurious [`Copy`] deref).
1765impl From<&CaixaDialeto> for std::rc::Rc<str> {
1766    fn from(dialeto: &CaixaDialeto) -> std::rc::Rc<str> {
1767        std::rc::Rc::<str>::from(dialeto.as_str())
1768    }
1769}
1770
1771/// Substrate-canonical [`AsRef<[u8]>`] byte-view projection on the
1772/// caixa-core-internal dialect-classification [`CaixaDialeto`] closed-set
1773/// fieldless typed enum — routes byte-for-byte through the substrate-
1774/// primitive [`CaixaDialeto::as_str`] `pub const fn` accessor via
1775/// [`str::as_bytes`] on the returned `&'static str`, so any future
1776/// consumer that binds a [`CaixaDialeto`] through a standard-library
1777/// `<T: AsRef<[u8]>>` trait bound reaches the same lifted
1778/// [`CAIXA_DIALETO_WIRE_PACOTE`] / [`CAIXA_DIALETO_WIRE_MOLDE`] /
1779/// [`CAIXA_DIALETO_WIRE_MOLDE_POSICIONAL`] /
1780/// [`CAIXA_DIALETO_WIRE_DESCONHECIDO`] `pub const &str` roster the paired
1781/// sibling [`AsRef<str>`] / [`std::fmt::Display`] /
1782/// [`CaixaDialeto::as_str`] / `{Self, &Self} × {&'static str, String,
1783/// Cow<'static, str>, Box<str>, std::sync::Arc<str>, std::rc::Rc<str>}`
1784/// str-view + reverse-projection surfaces already return — through the
1785/// byte-view axis, which the str-view axes cannot express.
1786///
1787/// Unlike the sibling top-level [`crate::CaixaKind`] enum — which
1788/// carries a two-axis split ([`crate::CaixaKind::as_str`] returning
1789/// lowercase-Portuguese diagnostic form vs
1790/// [`crate::CaixaKind::wire_name`] returning `PascalCase` tatara-lisp
1791/// author-surface bytes) — [`CaixaDialeto`] is an internal
1792/// classification with no wire-surface split (see the
1793/// [`CaixaDialeto::as_str`] docstring: "the `PascalCase` variant name
1794/// is the census-facing form every consumer reads, so `as_str`
1795/// suffices without a paired `wire_name` axis"). The byte-view axis
1796/// therefore lands on the same `PascalCase` census-facing byte-string
1797/// every str-view and reverse-projection axis on this enum already
1798/// returns, and no wire-axis cross-witness applies.
1799///
1800/// The primary compounding target is the same [`crate`]-adjacent
1801/// [`caixa-lacre`](../../caixa-lacre/) BLAKE3 content-address closure
1802/// the peer [`crate::CaixaKind`] `AsRef<[u8]>` impl (69d8d86) opens
1803/// onto: [`blake3::hash`] and [`blake3::Hasher::update`] both bind
1804/// their input through `impl AsRef<[u8]>`, so any future per-caixa
1805/// content-address tag that folds a `:dialect` classification-byte
1806/// into the [`crate::Lacre`] closure (a hypothetical
1807/// `hasher.update(dialeto);`-shape composition on the per-caixa
1808/// BLAKE3 closure builder that keys off the caixa source's dialect
1809/// classification) reaches the substrate-primitive
1810/// [`CaixaDialeto::as_str`] accessor through this impl and no other —
1811/// without it, every such call site opens the two-hop composition
1812/// `dialeto.as_str().as_bytes()` whose byte-tail has no compile-time
1813/// link back to the byte-projection axis. Peer consumer paths on the
1814/// byte-view axis: any future [`std::io::Write::write_all`]-bound
1815/// structured-log dialect-column emitter (whose input binds through
1816/// `impl AsRef<[u8]>`), any future byte-keyed
1817/// [`std::collections::HashMap`] `<K: AsRef<[u8]>, V>` per-dialect
1818/// tally lookup whose entry-key trait bound rules out the sibling
1819/// [`AsRef<str>`] str-view projection, and any future
1820/// `ring::digest::Context::update` / `sha2::Sha256::update` /
1821/// `blake3::Hasher::update` byte-input surface on any future per-
1822/// dialect content-address digest.
1823///
1824/// Rust's standard library carries `impl AsRef<[u8]> for str` and
1825/// `impl AsRef<[u8]> for String`, so the two-hop composition
1826/// `dialeto.as_str().as_bytes()` (or, equivalently,
1827/// `AsRef::<str>::as_ref(&dialeto).as_bytes()`) is reachable through
1828/// the pre-existing str-view axis alone. But that two-hop shape has
1829/// no compile-time link back to the byte-projection axis, forces
1830/// every downstream `<T: AsRef<[u8]>>`-bound consumer to open-code
1831/// the two-hop composition at every call site rather than pass a
1832/// [`CaixaDialeto`] through the trait bound directly, and admits a
1833/// silent split whenever a future call site takes the sibling
1834/// [`std::fmt::Display`] or [`From<Self> for String`] axis (whose
1835/// `.as_bytes()` byte-tails byte-equal `as_str`'s by construction
1836/// but carry no compile-time byte-view surface, since `Display`
1837/// returns a formatter and `String` allocates). The lifted single-
1838/// hop impl closes the byte-view axis so every future
1839/// `<T: AsRef<[u8]>>`-bound consumer reaches the substrate primitive
1840/// through one trait dispatch, and every future arm addition (the
1841/// module doc's "third dialect" hazard actualising as a fifth arm)
1842/// grows the byte-view axis through one edit on the substrate-
1843/// primitive `as_str` accessor, not a coordinated rewrite across
1844/// every future `<T: AsRef<[u8]>>`-bound consumer's arm-set.
1845///
1846/// Extends the trait-idiomatic *byte-view* axis onto the second
1847/// closed-set fieldless typed-enum peer on the substrate — the
1848/// caixa-core-internal dialect-classification enum — matching the
1849/// trajectory the sibling [`crate::CaixaKind`] first-mover
1850/// [`AsRef<[u8]>`] impl (69d8d86) walked before it on the caixa-core
1851/// tier of the byte-view axis, and matching the discipline the
1852/// paired sibling closed-set fieldless typed enums already carry on
1853/// the peer str-view ([`AsRef<str>`]), parse
1854/// ([`std::str::FromStr`]), and reverse-projection
1855/// (`{Self, &Self} × {&'static str, String, Cow<'static, str>,
1856/// Box<str>, std::sync::Arc<str>, std::rc::Rc<str>}`) axes on this
1857/// same enum.
1858///
1859/// Pinned load-bearing by
1860/// [`tests::caixa_dialeto_as_ref_bytes_routes_through_as_str_accessor`]
1861/// (fail-before-pass-after byte-parity pin against
1862/// [`CaixaDialeto::as_str`] `.as_bytes()` across the four-arm
1863/// [`CaixaDialeto::ALL`] emit-set, cross-axis witness against the
1864/// paired str-view [`AsRef<str>`] / [`std::fmt::Display`] /
1865/// [`CaixaDialeto::as_str`] axes' `.as_bytes()` byte-tails, cross-
1866/// axis witness against the paired reverse-projection
1867/// `{&'static str, String, Cow<'static, str>, Box<str>,
1868/// std::sync::Arc<str>, std::rc::Rc<str>}` return-shape axes'
1869/// `.as_bytes()` byte-tails, a `<T: AsRef<[u8]>>`-bound-consumer
1870/// witness that a generic byte-input function accepts a
1871/// [`CaixaDialeto`] directly through the trait bound on both owned
1872/// and borrowed input shapes, and a `blake3::Hasher::update`-shape
1873/// byte-input surface witness routed through the
1874/// `<T: AsRef<[u8]>>`-bound consumer axis to reach the caixa-lacre
1875/// compounding target on both owned and borrowed input shapes). Any
1876/// future silent detour that routes the byte-view impl off the
1877/// substrate-primitive [`CaixaDialeto::as_str`] accessor (a per-arm
1878/// inline `b"Pacote".as_slice()`-shaped re-inlining that opens a
1879/// compile-time link to the un-lifted arm-literal, a swap onto the
1880/// sibling [`CaixaDialeto::palavra_canonica`] /
1881/// [`CaixaDialeto::consumidor`] / [`CaixaDialeto::descricao`]
1882/// accessors that carry distinct byte-shapes per axis) trips at
1883/// caixa-core test time rather than at a downstream byte-consumer's
1884/// silent split.
1885impl AsRef<[u8]> for CaixaDialeto {
1886    fn as_ref(&self) -> &[u8] {
1887        self.as_str().as_bytes()
1888    }
1889}
1890
1891/// Trait-idiomatic *owned-input, owned-`Vec<u8>` output* byte-owned
1892/// reverse projection on the second caixa-core-internal closed-set
1893/// fieldless typed enum peer ([`CaixaDialeto`]) — the byte-mirror of
1894/// the [`From<CaixaDialeto> for String`] str-owned reverse-projection
1895/// axis and the owned-`Vec<u8>` reverse-projection sibling of the
1896/// paired [`AsRef<[u8]>`] borrowed byte-view axis lifted on this same
1897/// enum. Routes byte-for-byte through the substrate-primitive
1898/// [`CaixaDialeto::as_str`] `pub const fn` accessor via
1899/// [`str::as_bytes`] + [`slice::to_vec`] so every consumer that binds
1900/// a [`CaixaDialeto`] through the standard-library
1901/// `impl From<CaixaDialeto> for Vec<u8>` axis (equivalently
1902/// `<T: Into<Vec<u8>>>`) — a future
1903/// [`std::io::Write::write_all`]-shape per-dialect audit-log byte-sink
1904/// whose input parameter is an owned [`Vec<u8>`] payload, a future
1905/// `bytes::Bytes::from(Vec::<u8>::from(dialeto))` composer folding the
1906/// per-arm classification byte-tag into the [`bytes::Bytes`] framing
1907/// surface, a future `hasher.update(&Vec::<u8>::from(dialeto))`-shape
1908/// BLAKE3 content-address closure that needs the owned byte-tail
1909/// buffered before folding into the [`crate::Lacre`] closure body, a
1910/// future per-dialect protobuf/CBOR/msgpack payload composer whose
1911/// framer takes an owned [`Vec<u8>`] rather than a borrowed byte-slice
1912/// — reaches the same four-arm lifted [`CAIXA_DIALETO_WIRE_PACOTE`] /
1913/// [`CAIXA_DIALETO_WIRE_MOLDE`] / [`CAIXA_DIALETO_WIRE_MOLDE_POSICIONAL`]
1914/// / [`CAIXA_DIALETO_WIRE_DESCONHECIDO`] const roster the paired
1915/// [`AsRef<[u8]>`] borrowed byte-view axis, the four `{Self, &Self} ×
1916/// {&'static str, String}` 2×2 str-view forward-projection corners,
1917/// the [`std::borrow::Cow<'static, str>`] / [`Box<str>`] /
1918/// [`std::sync::Arc<str>`] / [`std::rc::Rc<str>`] str-owned reverse-
1919/// projection quartet, and the substrate-primitive
1920/// [`CaixaDialeto::as_str`] accessor already return, rather than an
1921/// open-coded per-call-site `dialeto.as_str().as_bytes().to_vec()` /
1922/// `<CaixaDialeto as AsRef<[u8]>>::as_ref(&dialeto).to_vec()` /
1923/// `String::from(dialeto).into_bytes()` composition whose type bounds
1924/// have no compile-time link back to the substrate primitive.
1925///
1926/// Second peer on the substrate-wide trait-idiomatic *byte-owned
1927/// reverse-projection* family opened on the sibling top-level
1928/// [`crate::CaixaKind`] enum (b245fd6 first-mover) — Rust's standard
1929/// library carries `impl From<&[u8]> for Vec<u8>` and
1930/// `impl From<String> for Vec<u8>`, so a two-hop composition
1931/// `dialeto.as_str().as_bytes().to_vec()` (or
1932/// `String::from(dialeto).into_bytes()`, or
1933/// `<CaixaDialeto as AsRef<[u8]>>::as_ref(&dialeto).to_vec()`) is
1934/// reachable through the pre-existing str-view axes and the paired
1935/// [`AsRef<[u8]>`] borrowed byte-view axis alone. But that two-hop
1936/// shape has no compile-time link back to the byte-owned reverse-
1937/// projection axis, forces every downstream `<T: Into<Vec<u8>>>`-
1938/// bound consumer to open-code the composition at every call site,
1939/// and admits a silent split whenever a future call site takes a
1940/// sibling projection axis whose `into_bytes()` / `to_vec()` byte-
1941/// tail carries no compile-time byte-owned surface. The lifted
1942/// single-hop impl closes the byte-owned reverse-projection axis so
1943/// every future `Vec<u8>`-parameterized consumer reaches the
1944/// substrate primitive through one trait dispatch, and every future
1945/// arm addition (the module doc's "third dialect" hazard actualising
1946/// as a fifth arm landing on a new `CAIXA_DIALETO_WIRE_*` const)
1947/// grows the byte-owned axis through one edit on the substrate-
1948/// primitive [`CaixaDialeto::as_str`] accessor.
1949///
1950/// Unlike the sibling first-mover [`crate::CaixaKind`] enum — which
1951/// carries a two-axis split (lowercase-Portuguese diagnostic form vs
1952/// `PascalCase` tatara-lisp author-surface bytes) so its byte-owned
1953/// axis pins a wire-axis rejection witness — [`CaixaDialeto`] is an
1954/// internal classification with no wire-surface split (see the
1955/// [`CaixaDialeto::as_str`] docstring: "the `PascalCase` variant name
1956/// is the census-facing form every consumer reads, so `as_str`
1957/// suffices without a paired `wire_name` axis"). The byte-owned axis
1958/// therefore lands on the same `PascalCase` census-facing byte-string
1959/// every str-view / reverse-projection / byte-view axis on this enum
1960/// already returns, and no wire-axis cross-witness applies.
1961///
1962/// Extends the byte-owned reverse-projection axis onto the second
1963/// closed-set fieldless typed enum peer on the caixa-core-internal
1964/// tier — every future closed-set fieldless typed enum peer on the
1965/// substrate ([`crate::supervisor::RestartStrategy`],
1966/// [`crate::supervisor::RestartPolicy`],
1967/// [`crate::aplicacao::PlacementStrategy`],
1968/// [`crate::aplicacao::RateLimitUnit`], [`crate::dep::DepList`], and
1969/// the outside-`caixa-core` peers `WitShape`, `PathShapeViolation`,
1970/// `InvariantKind`, `ArchVerdict`, `Severity`, `FixSafety`,
1971/// `Semantic`, `FerriteRuntime`) is a future target of the campaign,
1972/// mirroring the discipline the paired [`AsRef<[u8]>`] borrowed byte-
1973/// view axis campaign already tracked.
1974///
1975/// Pinned load-bearing by
1976/// [`tests::caixa_dialeto_from_into_owned_vec_bytes_routes_through_as_str_accessor`]
1977/// (byte-parity pin against [`CaixaDialeto::as_str`] across the four-
1978/// arm emit-set binding the byte-owned reverse-projection axis
1979/// against the paired [`AsRef<[u8]>`] borrowed byte-view axis and the
1980/// str-view family's `.as_bytes().to_vec()` byte-tails, plus a
1981/// `<T: Into<Vec<u8>>>`-bound generic-consumer witness and a
1982/// `std::io::Write::write_all`-shape owned-byte-sink surface witness
1983/// on both owned and borrowed input shapes).
1984impl From<CaixaDialeto> for Vec<u8> {
1985    fn from(dialeto: CaixaDialeto) -> Vec<u8> {
1986        dialeto.as_str().as_bytes().to_vec()
1987    }
1988}
1989
1990/// Trait-idiomatic *borrowed-input, owned-`Vec<u8>` output* byte-
1991/// owned reverse projection on the second caixa-core-internal closed-
1992/// set fieldless typed enum peer ([`CaixaDialeto`]) — the borrowed-
1993/// input peer of [`From<CaixaDialeto> for Vec<u8>`], closing the
1994/// `{Self, &Self} → Vec<u8>` pair on the byte-owned reverse-
1995/// projection axis in one lift. Routes byte-for-byte through the
1996/// substrate-primitive [`CaixaDialeto::as_str`] `pub const fn`
1997/// accessor so every consumer that holds a borrowed [`&CaixaDialeto`]
1998/// and needs an owned [`Vec<u8>`] — a future
1999/// `.iter().map(Vec::<u8>::from).collect()` pipe over
2000/// `&[CaixaDialeto]` (whose iterator yields `&CaixaDialeto`, not
2001/// `CaixaDialeto`, so the owned-input axis alone forces every call
2002/// site through an explicit `.copied()` / spurious [`Copy`] deref
2003/// restatement rather than the direct trait-idiomatic projection), a
2004/// future census-report body composer that walks
2005/// [`CaixaDialeto::ALL`] through an `Into<Vec<u8>>`-bound per-arm
2006/// byte-writer to surface the accepted dialect set — reaches the same
2007/// four-arm lifted `CAIXA_DIALETO_WIRE_*` const roster the paired
2008/// owned-input peer already returns.
2009impl From<&CaixaDialeto> for Vec<u8> {
2010    fn from(dialeto: &CaixaDialeto) -> Vec<u8> {
2011        dialeto.as_str().as_bytes().to_vec()
2012    }
2013}
2014
2015/// Trait-idiomatic *borrowed byte-slice input* reverse projection on the
2016/// second caixa-core-internal closed-set fieldless typed enum peer
2017/// ([`CaixaDialeto`]) — the byte-view mirror of the str-view reverse-
2018/// projection axis carried by the paired [`TryFrom<&str> for CaixaDialeto`]
2019/// impl (which routes through the substrate-primitive
2020/// [`CaixaDialeto::from_wire`] `Option<Self>` accessor on the four-arm
2021/// `PascalCase` accept-set the sibling [`CaixaDialeto::as_str`] emitter
2022/// returns). Routes byte-for-byte through the standard-library
2023/// [`std::str::from_utf8`] UTF-8 validator and then through
2024/// [`CaixaDialeto::from_wire`] so every consumer that holds a borrowed
2025/// [`&[u8]`] and needs to project it back into a typed [`CaixaDialeto`] —
2026/// a future `bytes::Bytes::as_ref()`-fed reader that parses a per-caixa
2027/// `:dialect` classification tag from an already-borrowed framing byte-
2028/// tail (a `tracing::field::valuable::Value::Bytes` recorder on the
2029/// caixa-build pipeline's per-file classify emission path, a future audit-
2030/// report re-loader binding a prior [`CaixaDialeto::as_str`] output from a
2031/// mmap'd byte-slice back through the typed enum for cross-run
2032/// comparison), a future admission-webhook rejection body that reads a
2033/// `spec.dialeto` field off a raw HTTP body byte-slice before UTF-8
2034/// validation commits allocation, a future generic
2035/// `<T: for<'a> TryFrom<&'a [u8]>>`-bound loader over any of the
2036/// substrate's closed-set typed enums — reaches the same four-arm
2037/// `PascalCase` wire accept-set the sibling method-named
2038/// [`CaixaDialeto::from_wire`] resolver and the paired trait-idiomatic
2039/// [`TryFrom<&str>`] axis already resolve against, rather than an open-
2040/// coded per-call-site
2041/// `std::str::from_utf8(bytes).ok().and_then(CaixaDialeto::from_wire)`
2042/// composition or a
2043/// `<CaixaDialeto as TryFrom<&str>>::try_from(std::str::from_utf8(bytes)?)`
2044/// two-hop shape whose type bounds have no compile-time link to the
2045/// substrate primitive.
2046///
2047/// Extends the substrate-wide trait-idiomatic *byte-view reverse-
2048/// projection* family — opened on the structurally most fundamental
2049/// closed-set fieldless typed enum peer ([`crate::CaixaKind`], commit
2050/// 18d1940) — onto the second caixa-core-internal closed-set fieldless
2051/// typed enum peer, tracking the "route through `from_wire` via
2052/// `std::str::from_utf8`" discipline the first-mover established. Rust's
2053/// standard library carries no blanket
2054/// `impl<T: for<'a> TryFrom<&'a str>> TryFrom<&[u8]> for T`, so a two-hop
2055/// composition through [`std::str::from_utf8`] + the paired
2056/// [`TryFrom<&str>`] axis is reachable at every call site but has no
2057/// compile-time link back to the byte-view reverse-projection axis. Every
2058/// future closed-set fieldless typed enum peer on the substrate
2059/// ([`crate::dep::DepList`], [`crate::supervisor::RestartStrategy`],
2060/// [`crate::supervisor::RestartPolicy`],
2061/// [`crate::aplicacao::PlacementStrategy`],
2062/// [`crate::aplicacao::RateLimitUnit`], [`crate::aplicacao::WitShape`],
2063/// and the outside-`caixa-core` peers `PathShapeViolation`,
2064/// `InvariantKind`, `ArchVerdict`, `Severity`, `FixSafety`, `Semantic`,
2065/// `FerriteRuntime`) is a future target of the campaign, mirroring the
2066/// trajectory the closed byte-owned reverse-projection family walked
2067/// arm-by-arm onto each peer.
2068///
2069/// `type Error = ()` matches the sibling [`CaixaDialeto::from_wire`]'s
2070/// `Option<Self>` return-shape's deliberate deferral of error typing and
2071/// the paired trait-idiomatic [`TryFrom<&str>`] axis's unit-error shape —
2072/// the caller picks the diagnostic form appropriate for its use site (a
2073/// future `feira dialeto --filter` arg-parse composes its own per-verb
2074/// "unknown dialect: <arg> — accepted: {…}" message enumerating
2075/// [`CaixaDialeto::ALL`]; a future admission-webhook rejection body wraps
2076/// the `Err(())` outcome with the accepted-set enumeration for operator
2077/// diagnostics; a `Result::map_err` at the call site lifts the unit-error
2078/// to a per-verb error type). Two rejection paths route through the
2079/// single unit-error: an invalid UTF-8 byte-sequence
2080/// ([`std::str::from_utf8`] returns `Err`) and a valid UTF-8 byte-string
2081/// that falls outside the four-arm `PascalCase` accept-set
2082/// ([`CaixaDialeto::from_wire`] returns `None`) — both collapse onto
2083/// `Err(())` so the trait signature stays consistent with the sibling
2084/// str-view reverse axis, and a caller that needs to distinguish the two
2085/// failure modes composes [`std::str::from_utf8`] +
2086/// [`CaixaDialeto::from_wire`] explicitly.
2087///
2088/// Pinned load-bearing by
2089/// [`tests::caixa_dialeto_try_from_bytes_routes_through_from_wire_accessor`]
2090/// (byte-parity pin against [`CaixaDialeto::from_wire`] across the four-
2091/// arm [`CaixaDialeto::ALL`] accept-set on the borrowed byte-slice
2092/// surface, plus a cross-axis witness that the byte-view reverse
2093/// projection agrees with the paired [`TryFrom<&str>`] str-view reverse
2094/// axis on every accepted arm) and
2095/// [`tests::caixa_dialeto_try_from_bytes_rejects_unknown_and_non_utf8_bytes`]
2096/// (rejection witness against silent accept-set widening on both the
2097/// non-UTF-8 byte-sequence rejection path and the unknown-wire-vocabulary
2098/// rejection path).
2099impl TryFrom<&[u8]> for CaixaDialeto {
2100    type Error = ();
2101
2102    fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
2103        std::str::from_utf8(bytes)
2104            .ok()
2105            .and_then(Self::from_wire)
2106            .ok_or(())
2107    }
2108}
2109
2110/// Trait-idiomatic *owned byte-vec input* reverse projection on the
2111/// second caixa-core-internal closed-set fieldless typed enum peer
2112/// ([`CaixaDialeto`]) — the owned-input peer of
2113/// [`TryFrom<&[u8]> for CaixaDialeto`], mirroring the closed
2114/// [`From<CaixaDialeto> for Vec<u8>`] + [`From<&CaixaDialeto> for Vec<u8>`]
2115/// byte-owned *forward*-projection pair on this same enum onto the
2116/// byte-owned *reverse*-projection axis. Routes byte-for-byte through
2117/// [`<Self as TryFrom<&[u8]>>::try_from`] on the [`Vec<u8>::as_slice`]
2118/// borrow, so the owned-input surface reaches the same
2119/// [`std::str::from_utf8`] + [`CaixaDialeto::from_wire`] resolution chain
2120/// the borrowed-input peer already carries — one substrate-primitive
2121/// accessor, one trait dispatch, no per-consumer detour.
2122///
2123/// Rust's standard library carries no blanket
2124/// `impl<T: for<'a> TryFrom<&'a [u8]>> TryFrom<Vec<u8>> for T`, so a
2125/// consumer that holds an owned [`Vec<u8>`] and needs a typed
2126/// [`CaixaDialeto`] otherwise picks between (a) an open-coded
2127/// `<CaixaDialeto as TryFrom<&[u8]>>::try_from(bytes.as_slice())` at
2128/// every call site (whose type bounds have no compile-time link to the
2129/// byte-owned reverse-projection axis), (b) a two-hop
2130/// `String::from_utf8(bytes)` + [`CaixaDialeto::from_wire`] composition
2131/// whose error surface leaks the standard-library [`std::string::FromUtf8Error`]
2132/// (widening the sibling [`TryFrom<&[u8]>`] axis's unit-error) and
2133/// silently allocates a [`String`] on inputs that will never make it
2134/// past the wire vocabulary, or (c) an intermediate
2135/// `<CaixaDialeto as TryFrom<&str>>::try_from(std::str::from_utf8(&bytes)?)`
2136/// three-hop shape. This impl closes the owned-byte-vec reverse-
2137/// projection axis at the substrate-primitive
2138/// [`CaixaDialeto::from_wire`] accessor so every future
2139/// `<T: TryFrom<Vec<u8>>>`-bound owned-byte-vec consumer — a future
2140/// admission-webhook body reader that hands raw request bytes off as
2141/// a [`Vec<u8>`] before UTF-8 validation commits, a future
2142/// `std::io::Read::read_to_end`-shape audit-log source whose framing
2143/// yields an owned byte-vec per frame, a future protobuf/CBOR/msgpack
2144/// per-field decoder whose bytes arm surfaces an owned [`Vec<u8>`]
2145/// before dispatch, a `bytes::Bytes::to_vec()`-shape wire-body
2146/// composer walking a prior audit's payload back to the typed enum,
2147/// an `<T: TryFrom<Vec<u8>>>`-bound generic loader over any of the
2148/// substrate's closed-set typed enums — reaches the same four-arm
2149/// `PascalCase` wire accept-set through one trait dispatch.
2150///
2151/// Extends the substrate-wide trait-idiomatic *byte-owned reverse-
2152/// projection* family onto the second caixa-core-internal closed-set
2153/// fieldless typed enum peer, tracking the trajectory the sibling
2154/// first-mover [`TryFrom<Vec<u8>> for CaixaKind`] (99c2849) opened on
2155/// the structurally most fundamental enum. Peer of the sibling closed
2156/// byte-view reverse-projection family (`TryFrom<&[u8]>`; extended
2157/// onto this enum d102cb8) and of the closed byte-owned forward-
2158/// projection family (`From<{Self, &Self}> for Vec<u8>`; extended
2159/// onto this enum on the same commit as its `TryFrom<&[u8]>` peer)
2160/// on this same enum — the {owned-input, borrowed-input} ×
2161/// {owned-output byte-vec, borrowed-output byte-slice} byte-view
2162/// reverse-projection square now closes on [`CaixaDialeto`].
2163///
2164/// `type Error = ()` matches the sibling [`TryFrom<&[u8]> for CaixaDialeto`]
2165/// unit-error shape, preserving the trait-family consistency across
2166/// the borrowed-and-owned byte-view reverse-projection pair. Both
2167/// rejection paths (invalid UTF-8, valid-UTF-8-but-unknown-wire)
2168/// collapse onto `Err(())` through the delegated borrowed axis.
2169/// The owned [`Vec<u8>`] input is dropped on the error path (the
2170/// standard-library `String::from_utf8` convention of returning the
2171/// input in the error deliberately declined — a caller that needs
2172/// the bytes back holds a clone before the call, and the closed-set-
2173/// enum use site rarely wants the raw bytes back past a "did you
2174/// mean" diagnostic that operates on the wire vocabulary rather than
2175/// the input).
2176///
2177/// Unlike the peer [`TryFrom<Vec<u8>> for crate::CaixaKind`] (which
2178/// carries a wire-vs-diagnostic two-axis split — `as_str` lowercase
2179/// Portuguese vs `wire_name` `PascalCase`), [`CaixaDialeto`] has no
2180/// such split: [`Self::as_str`] and [`Self::from_wire`] operate on
2181/// the same four-arm `PascalCase` byte-vocabulary
2182/// (`"Pacote"`, `"Molde"`, `"MoldePosicional"`, `"Desconhecido"`).
2183/// So on this enum the byte-owned reverse-projection axis *can*
2184/// round-trip against the paired byte-owned forward-projection pair
2185/// ([`From<CaixaDialeto> for Vec<u8>`], [`From<&CaixaDialeto> for
2186/// Vec<u8>`]) — a four-corner witness the pinned load-bearing test
2187/// makes explicit, and a witness the sibling
2188/// [`TryFrom<Vec<u8>> for crate::CaixaKind`] axis deliberately
2189/// declines.
2190///
2191/// Pinned load-bearing by
2192/// [`tests::caixa_dialeto_try_from_vec_bytes_routes_through_borrowed_byte_view_axis`]
2193/// (byte-parity pin against the paired borrowed [`TryFrom<&[u8]>`]
2194/// axis across the four-arm [`CaixaDialeto::ALL`] accept-set on the
2195/// owned byte-vec surface, plus a cross-axis witness that the byte-
2196/// owned reverse projection agrees with the paired str-view reverse-
2197/// projection axis ([`TryFrom<&str>`]) on every accepted arm through
2198/// the shared substrate-primitive [`CaixaDialeto::from_wire`]
2199/// accessor, plus a four-corner {owned-input, borrowed-input} ×
2200/// {owned-output byte-vec, borrowed-output byte-slice} round-trip
2201/// witness against the paired [`From<{Self, &Self}> for Vec<u8>`]
2202/// byte-owned forward-projection pair) and
2203/// [`tests::caixa_dialeto_try_from_vec_bytes_rejects_unknown_and_non_utf8_bytes`]
2204/// (rejection witness against silent accept-set widening on both the
2205/// non-UTF-8 byte-sequence rejection path and the unknown-wire-
2206/// vocabulary rejection path, plus a cross-axis witness that the
2207/// owned byte-vec reverse-projection axis agrees with the borrowed
2208/// byte-slice reverse-projection axis on every rejected input).
2209impl TryFrom<Vec<u8>> for CaixaDialeto {
2210    type Error = ();
2211
2212    fn try_from(bytes: Vec<u8>) -> Result<Self, Self::Error> {
2213        <Self as TryFrom<&[u8]>>::try_from(bytes.as_slice())
2214    }
2215}
2216
2217/// Trait-idiomatic *owned-`String` input, `Result<Self, ()>` output*
2218/// string-owned reverse projection on the second caixa-core-internal
2219/// closed-set fieldless typed enum peer ([`CaixaDialeto`]) — the owned-
2220/// input peer of the paired [`TryFrom<&str> for CaixaDialeto`] str-view
2221/// reverse-projection axis (which routes through the substrate-primitive
2222/// [`CaixaDialeto::from_wire`] `Option<Self>` accessor on the four-arm
2223/// `PascalCase` accept-set the sibling [`CaixaDialeto::as_str`] emitter
2224/// returns), and the string-owned reverse companion of the pre-existing
2225/// string-owned *forward*-projection pair ([`From<CaixaDialeto> for
2226/// String`] / [`From<&CaixaDialeto> for String`]) already lifted on this
2227/// same enum. Routes owned [`String`] input byte-for-byte through the
2228/// paired borrowed-input [`TryFrom<&str>`] axis via [`String::as_str`],
2229/// so every consumer that holds an owned [`String`] and needs a typed
2230/// [`CaixaDialeto`] — a future admission-webhook body reader that hands
2231/// a per-manifest `spec.dialeto` `PascalCase` scalar off as an owned
2232/// [`String`] after UTF-8 validation commits allocation, a
2233/// `serde_yaml::from_str` / `serde_json::from_str` de-serialize composer
2234/// that surfaces the classification scalar as an owned [`String`] typed
2235/// field, a future
2236/// `feira dialeto --filter <Pacote|Molde|MoldePosicional|Desconhecido>`
2237/// `clap`-derived arg-parse whose owned-`String` positional lands the
2238/// canonical arm at the typed dispatch, a per-caixa overlay resolver
2239/// reading an owned [`String`] out of a `ConfigMap` `data.dialeto`
2240/// scalar, a dialect-partitioned census-column loader that walks a
2241/// `Vec<String>` of prior [`CaixaDialeto::as_str`] outputs, an
2242/// `<T: TryFrom<String>>`-bound generic loader over any of the
2243/// substrate's closed-set typed enums — reaches the same four-arm
2244/// `PascalCase` wire accept-set through one trait dispatch off the
2245/// shared [`CaixaDialeto::from_wire`] substrate primitive.
2246///
2247/// Extends the substrate-wide trait-idiomatic *string-owned reverse-
2248/// projection* family — opened on the compound M3-mesh
2249/// `:politicas :rate-limit` primitive [`crate::aplicacao::RateLimit`]
2250/// (a2e6f02), lifted onto the first closed-set fieldless typed-enum
2251/// peer [`crate::aplicacao::WitShape`] (e6aac29), extended onto the
2252/// second closed-set fieldless typed-enum peer
2253/// [`crate::aplicacao::RateLimitUnit`] (94a9c5e), extended onto the
2254/// third closed-set fieldless typed-enum peer
2255/// [`crate::aplicacao::PlacementStrategy`] (d81a70a), extended onto the
2256/// first M2-OTP-shape supervisor-slot closed-set fieldless typed-enum
2257/// peer [`crate::supervisor::RestartStrategy`] (78fe8c8), closed on the
2258/// M2-OTP-shape supervisor-slot pair by
2259/// [`crate::supervisor::RestartPolicy`] (35dea5a), and extended onto
2260/// the structurally most fundamental caixa-core enum peer
2261/// [`crate::CaixaKind`] (e7df24f) — onto the second caixa-core-internal
2262/// closed-set fieldless typed-enum peer, the per-caixa dialect
2263/// discriminator every [`crate::Caixa`] carries through its parsed
2264/// manifest form. This mirrors the trajectory the byte-view (d102cb8)
2265/// / byte-owned (83a1526) / str-view reverse-projection families
2266/// already walked on this same enum. Leaves [`crate::dep::DepList`] as
2267/// the remaining `TryFrom<String>` target on the caixa-core-internal
2268/// closed-set peer census.
2269///
2270/// Rust's standard library carries no blanket
2271/// `impl<T: for<'a> TryFrom<&'a str>> TryFrom<String> for T`, so a
2272/// consumer that holds an owned [`String`] and needs a typed
2273/// [`CaixaDialeto`] otherwise picks between (a) an open-coded
2274/// `<CaixaDialeto as TryFrom<&str>>::try_from(s.as_str())` at every
2275/// call site whose type bounds have no compile-time link back to the
2276/// string-owned reverse-projection axis, (b) a `let s: &str = &s;
2277/// CaixaDialeto::try_from(s)` two-step whose borrow arithmetic leaks a
2278/// per-call-site lifetime dance rather than a single trait dispatch, or
2279/// (c) a `String::into_bytes` + [`TryFrom<Vec<u8>>`] detour that
2280/// reaches the substrate-primitive `from_wire` accessor through a
2281/// UTF-8 re-validation hop the owned-`String` axis already knows to
2282/// skip. This impl closes the string-owned reverse-projection axis at
2283/// the substrate-primitive [`CaixaDialeto::from_wire`] accessor so
2284/// every future `<T: TryFrom<String>>`-bound owned-string consumer
2285/// reaches the same four-arm `PascalCase` accept-set through one
2286/// trait dispatch.
2287///
2288/// `type Error = ()` matches the sibling [`TryFrom<&str> for CaixaDialeto`],
2289/// [`TryFrom<&[u8]> for CaixaDialeto`], and [`TryFrom<Vec<u8>> for CaixaDialeto`]
2290/// unit-error shapes, preserving the trait-family consistency across
2291/// the {str-view, byte-view, byte-owned, string-owned} reverse-
2292/// projection square. The owned [`String`] input is dropped on the
2293/// error path (the standard-library `String::from_utf8` convention of
2294/// returning the input in the error deliberately declined — a caller
2295/// that needs the string back holds a clone before the call, and the
2296/// closed-set-enum use site rarely wants the raw string back past a
2297/// "did you mean" diagnostic that operates on the wire vocabulary
2298/// rather than the input).
2299///
2300/// Unlike the peer [`crate::CaixaKind`] axis (whose paired string-owned
2301/// *forward* projection ([`From<CaixaKind> for String`]) emits
2302/// lowercase Portuguese diagnostic bytes while this reverse axis parses
2303/// `PascalCase` wire bytes — the two-axis wire/diagnostic split
2304/// forces the closed-cycle round-trip witness to cross through
2305/// [`CaixaKind::wire_name`]), [`CaixaDialeto`] carries exactly one
2306/// census-facing `PascalCase` axis (the module doc block above the
2307/// [`CaixaDialeto::as_str`] accessor names this out: "an internal
2308/// classification with no wire surface — the `PascalCase` variant name
2309/// is the census-facing form every consumer reads, so `as_str` suffices
2310/// without a paired `wire_name` axis"), so the string-owned forward and
2311/// reverse axes here round-trip directly through the shared
2312/// `PascalCase` vocabulary — a four-corner witness the pinned load-
2313/// bearing test makes explicit, and a witness the sibling
2314/// [`TryFrom<String> for crate::CaixaKind`] axis deliberately declines.
2315///
2316/// Pinned load-bearing by
2317/// [`tests::caixa_dialeto_try_from_owned_string_routes_through_borrowed_str_view_axis`]
2318/// (byte-parity pin against the paired borrowed [`TryFrom<&str>`] axis
2319/// across the four-arm [`CaixaDialeto::ALL`] accept-set on the owned-
2320/// `String` surface, cross-axis witness that the string-owned reverse
2321/// projection agrees with the sibling byte-view and byte-owned
2322/// reverse-projection axes on every accepted arm through the shared
2323/// substrate-primitive [`CaixaDialeto::from_wire`] accessor, plus a
2324/// four-corner {owned-input, borrowed-input} × {`From<Self> → String`,
2325/// `From<&Self> → String`} round-trip witness against the paired
2326/// [`From<{Self, &Self}> for String`] string-owned forward-projection
2327/// pair) and
2328/// [`tests::caixa_dialeto_try_from_owned_string_rejects_unknown_wire_strings`]
2329/// (rejection witness against silent accept-set widening — mirrors the
2330/// corpus the paired [`TryFrom<&str>`] and [`TryFrom<Vec<u8>>`]
2331/// rejection witnesses already pin, including empty / whitespace-only
2332/// inputs, case-fold variants of accepted arms, the sibling
2333/// [`CaixaDialeto::palavra_canonica`] / [`CaixaDialeto::consumidor`]
2334/// byte-shapes so a caller who confuses those distinct axes with the
2335/// census-facing wire axis trips here, whitespace-padded / trailing-
2336/// newline / quote-wrapped forms, with per-input cross-axis parity
2337/// against the borrowed [`TryFrom<&str>`] reverse-projection axis).
2338impl TryFrom<String> for CaixaDialeto {
2339    type Error = ();
2340
2341    fn try_from(s: String) -> Result<Self, Self::Error> {
2342        <Self as TryFrom<&str>>::try_from(s.as_str())
2343    }
2344}
2345
2346/// A source that is not a `(defcaixa …)` / `(defmolde …)` form at all.
2347#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
2348pub enum DialetoError {
2349    #[error("source has no top-level form")]
2350    Vazio,
2351    #[error("top-level form is not a list — a manifest is `(defcaixa …)`")]
2352    NaoEhLista,
2353    #[error(
2354        "top-level form is headed by `{encontrado}`, not `defcaixa` or `defmolde` \
2355         (a manifest's first form must be the declaration itself)"
2356    )]
2357    CabecaErrada { encontrado: String },
2358    #[error("manifest does not parse as tatara-lisp: {0}")]
2359    Leitura(String),
2360}
2361
2362impl DialetoError {
2363    /// Construct a [`DialetoError::CabecaErrada`] naming the offending
2364    /// head symbol found at the top-level form.
2365    ///
2366    /// Substrate primitive every [`classify_form`] wrong-head fallthrough
2367    /// wire-up site now routes through, folding the pre-lift uniform
2368    /// three-line `Self::CabecaErrada { encontrado: <head>.to_string() }`
2369    /// one-field struct-literal onto one substrate primitive matching the
2370    /// peer `LimitsError::unknown_byte_unit(unit: &str)` /
2371    /// `LimitsError::unknown_duration_unit(unit: &str)`
2372    /// (`limits_codec_unit_only_ctors!` — 29fac09) single-slot
2373    /// discipline on the sibling one-field `{ <field>: String }` envelope
2374    /// axis, and matching the peer `ManifestError::code_path_empty` /
2375    /// `BehaviorError::empty_path` / `UpgradeError::duplicate_from` /
2376    /// `AplicacaoError::placement_cluster_duplicate` (94dabc8 / 0e33b37 /
2377    /// 7e52aec / 92b1c92) single-slot inherent-ctor discipline every
2378    /// sibling `{ <field>: <T> }` error-envelope variant on caixa-core's
2379    /// error surface now carries.
2380    ///
2381    /// The one open-coded wire-up site — `classify_form`'s wrong-head
2382    /// fallthrough arm on the `head: &str` binding read from the
2383    /// top-level form via [`tatara_lisp::Sexp::as_symbol`] — opened the
2384    /// identical three-line
2385    /// `Self::CabecaErrada { encontrado: <head>.to_string() }` block
2386    /// against the codec-scoped `<head>: &str` binding. Now routes
2387    /// through `DialetoError::cabeca_errada(head)`, byte-equal to the
2388    /// pre-lift struct-literal on the same `&str` fixture, so any future
2389    /// widening of the diagnostic shape (e.g. carrying the source-file
2390    /// path alongside the head symbol, carrying the head symbol's
2391    /// position offset for an authoring-surface caret pointer) lands at
2392    /// exactly one dispatch on the substrate primitive rather than re-
2393    /// inlining the struct-literal at every wrong-head fallthrough
2394    /// consumer.
2395    #[must_use]
2396    pub fn cabeca_errada(encontrado: &str) -> Self {
2397        Self::CabecaErrada {
2398            encontrado: encontrado.to_string(),
2399        }
2400    }
2401
2402    /// Construct a [`DialetoError::Leitura`] carrying the offending
2403    /// tatara-lisp reader-error message `reason` verbatim in the
2404    /// variant's tuple-newtype payload.
2405    ///
2406    /// Substrate primitive every [`classify`] tatara-lisp-reader
2407    /// map-err wire-up site now routes through, folding the pre-lift
2408    /// uniform `Self::Leitura(<into-String-expr>)` tuple-newtype
2409    /// construction onto one substrate primitive matching the peer
2410    /// `LimitsError::empty_byte_size` / `LimitsError::empty_duration`
2411    /// (7a4b003 / 319216c) `(String)` single-slot tuple-newtype
2412    /// discipline on the sibling
2413    /// [`crate::limits::LimitsError`] envelope's empty-shape axis of
2414    /// the paired codec-magnitude family. Peer to the sibling
2415    /// [`DialetoError::cabeca_errada`] ctor on the same envelope's
2416    /// wrong-head axis but on the tatara-lisp-reader axis rather than
2417    /// the classifier-fallthrough axis. Closes the last un-lifted
2418    /// variant on [`DialetoError`] — every one of the sole wire-up
2419    /// sites (the [`classify`] tatara-lisp-reader `.map_err(|e|
2420    /// Self::Leitura(e.to_string()))` arm) opened the identical
2421    /// `DialetoError::Leitura(<into-String-expr>)` block against the
2422    /// codec-scoped `String` (`e.to_string()`) binding, so the fold
2423    /// routes the site through one dispatch on a uniform
2424    /// `impl Into<String>` param, byte-equal to the pre-lift
2425    /// tuple-newtype construction on the same argument.
2426    ///
2427    /// The `impl Into<String>` bound covers both wire-up shapes on
2428    /// [`classify`] — a `String` binding (`e.to_string()` on the
2429    /// [`tatara_lisp::Error`]-carrying `e` binding) and a `&str`
2430    /// binding (a future admission-webhook consumer probing a
2431    /// caller-scoped `&'static str` fixture, a future
2432    /// `feira lint --tatara-reader-round-trip` verb sweeping every
2433    /// `tatara_lisp::read` return through the same shape gate) —
2434    /// without forcing the caller to spell the conversion at the
2435    /// wire-up site. Same shape the peer
2436    /// [`crate::limits::LimitsError::empty_byte_size`] /
2437    /// [`crate::limits::LimitsError::empty_duration`] /
2438    /// [`crate::limits::LimitsError::bad_millicores`] /
2439    /// [`crate::limits::LimitsError::bad_byte_magnitude`] /
2440    /// [`crate::limits::LimitsError::bad_duration_magnitude`] folds
2441    /// carry on the peer bad-magnitude and empty-shape axes of the
2442    /// same paired `(String)` tuple-newtype codec-magnitude family.
2443    /// `#[must_use]` fires a compile warning at any wire-up that
2444    /// mistakenly discards the constructed error.
2445    ///
2446    /// Every future consumer that wants to construct this variant
2447    /// outside [`classify`] (a deferred `feira lint --tatara-reader-
2448    /// round-trip` per-caixa admission verb probing each authored
2449    /// manifest against the tatara-lisp-reader shape gate, an M4
2450    /// typed `mesh.pleme.io/v1alpha1/Servico` CR materializer's
2451    /// per-manifest admission validator re-checking one edited
2452    /// `caixa.lisp` against the reader floor, a per-`caixa.lisp`
2453    /// value-shape pre-emitter probing each declared manifest ahead
2454    /// of the operator's admit-cycle) now reaches the variant
2455    /// through one call rather than re-inlining the tuple-newtype
2456    /// block in lockstep with the pre-existing wire-up.
2457    #[must_use]
2458    pub fn leitura(reason: impl Into<String>) -> Self {
2459        Self::Leitura(reason.into())
2460    }
2461}
2462
2463/// Classify a manifest source without committing to either schema.
2464///
2465/// Deliberately reads only the head symbol and the set of top-level keywords —
2466/// enough to route, never enough to half-parse. A classifier that started
2467/// validating would grow into a third parser, which is the shape of the problem
2468/// it exists to name.
2469///
2470/// # Errors
2471/// [`DialetoError`] when the source is not a manifest declaration at all.
2472pub fn classify(src: &str) -> Result<CaixaDialeto, DialetoError> {
2473    let forms = tatara_lisp::read(src).map_err(|e| DialetoError::leitura(e.to_string()))?;
2474    let first = forms.first().ok_or(DialetoError::Vazio)?;
2475    classify_form(first)
2476}
2477
2478/// [`classify`] over an already-read form.
2479///
2480/// # Errors
2481/// [`DialetoError`] when the form is not a manifest declaration.
2482pub fn classify_form(form: &Sexp) -> Result<CaixaDialeto, DialetoError> {
2483    let list = form.as_list().ok_or(DialetoError::NaoEhLista)?;
2484    let head = list
2485        .first()
2486        .and_then(Sexp::as_symbol)
2487        .ok_or(DialetoError::NaoEhLista)?;
2488
2489    match head {
2490        // `defmolde` is unambiguous by construction — it exists precisely so a
2491        // consumer never has to infer which declaration it holds. Both arities
2492        // are the same declaration; the positional one keeps its own variant
2493        // only so a census can report the split.
2494        "defmolde" => {
2495            return Ok(if starts_with_positional_name(&list[1..]) {
2496                CaixaDialeto::MoldePosicional
2497            } else {
2498                CaixaDialeto::Molde
2499            });
2500        }
2501        "defcaixa" => {}
2502        other => {
2503            return Err(DialetoError::cabeca_errada(other));
2504        }
2505    }
2506
2507    let args = &list[1..];
2508
2509    // `(defcaixa <symbol> :kind … :ecosystem …)`. Only the Molde dialect has a
2510    // positional arity; `Caixa` is keyword-only, so a leading bare symbol
2511    // settles it without looking further.
2512    if starts_with_positional_name(args) {
2513        return Ok(CaixaDialeto::MoldePosicional);
2514    }
2515
2516    let keys = top_level_keywords(args);
2517    let has = |k: &str| keys.iter().any(|s| s == k);
2518
2519    // Order matters, and it is not arbitrary: `:nome` and `:name` are the two
2520    // required head slots and no file in the measured corpus carries both.
2521    // Checking them FIRST means the decision rests on the one slot each schema
2522    // makes mandatory, rather than on optional evidence like `:ecosystem`.
2523    if has("nome") {
2524        return Ok(CaixaDialeto::Pacote);
2525    }
2526    if has("name") || has("ecosystem") || has("package") {
2527        return Ok(CaixaDialeto::Molde);
2528    }
2529    Ok(CaixaDialeto::Desconhecido)
2530}
2531
2532/// True when the first argument is a bare symbol rather than a keyword — the
2533/// positional-name arity.
2534fn starts_with_positional_name(args: &[Sexp]) -> bool {
2535    matches!(args.first(), Some(Sexp::Atom(Atom::Symbol(_))))
2536}
2537
2538/// The top-level keyword names (without the leading `:`) of a kwarg list.
2539///
2540/// Steps in pairs so a keyword appearing as a VALUE — `:kind :Biblioteca`, or a
2541/// nested `(:nome "dep" :versao "^0.1")` inside `:deps` — is never counted as a
2542/// top-level slot. A naive scan for `:nome` anywhere in the source classifies
2543/// every Molde manifest with a `:deps` list as a Pacote.
2544fn top_level_keywords(args: &[Sexp]) -> Vec<String> {
2545    let mut out = Vec::new();
2546    let mut i = 0;
2547    while i < args.len() {
2548        if let Sexp::Atom(Atom::Keyword(k)) = &args[i] {
2549            out.push(k.clone());
2550            i += 2;
2551        } else {
2552            i += 1;
2553        }
2554    }
2555    out
2556}
2557
2558#[cfg(test)]
2559mod tests {
2560    use super::*;
2561
2562    const PACOTE: &str = r#"
2563      (defcaixa
2564        :nome   "checkout"
2565        :versao "0.1.0"
2566        :kind   Servico
2567        :deps   ((:nome "caixa-teia" :versao "^0.1")))
2568    "#;
2569
2570    const MOLDE: &str = r#"
2571      (defcaixa
2572        :name "base64"
2573        :kind :Biblioteca
2574        :ecosystem :rust-single-crate
2575        :package {:name "base64" :version "0.22.1"}
2576        :workflows [:auto-release])
2577    "#;
2578
2579    const MOLDE_POSICIONAL: &str = r#"
2580      (defcaixa todoku-go
2581        :kind :Biblioteca
2582        :ecosystem :go
2583        :package {:name "todoku-go" :version "0.3.0"})
2584    "#;
2585
2586    #[test]
2587    fn the_package_dialect_is_recognised() {
2588        assert_eq!(classify(PACOTE), Ok(CaixaDialeto::Pacote));
2589    }
2590
2591    #[test]
2592    fn the_repo_surface_dialect_is_recognised() {
2593        assert_eq!(classify(MOLDE), Ok(CaixaDialeto::Molde));
2594    }
2595
2596    #[test]
2597    fn the_positional_arity_is_recognised() {
2598        assert_eq!(
2599            classify(MOLDE_POSICIONAL),
2600            Ok(CaixaDialeto::MoldePosicional)
2601        );
2602    }
2603
2604    #[test]
2605    fn defmolde_classifies_without_inference() {
2606        // The whole point of the new keyword: no schema sniffing required.
2607        let src = r#"(defmolde :name "x" :kind :Biblioteca :ecosystem :go)"#;
2608        assert_eq!(classify(src), Ok(CaixaDialeto::Molde));
2609        let pos = r"(defmolde todoku-go :kind :Biblioteca :ecosystem :go)";
2610        assert_eq!(classify(pos), Ok(CaixaDialeto::MoldePosicional));
2611    }
2612
2613    #[test]
2614    fn a_nested_nome_does_not_make_a_repo_surface_look_like_a_package() {
2615        // The exact failure a substring scan produces: `:deps ((:nome …))`
2616        // contains `:nome`, but not as a top-level slot.
2617        let src = r#"
2618          (defcaixa
2619            :name "x"
2620            :ecosystem :rust-single-crate
2621            :deps ((:nome "inner" :versao "^0.1")))
2622        "#;
2623        assert_eq!(classify(src), Ok(CaixaDialeto::Molde));
2624    }
2625
2626    #[test]
2627    fn a_keyword_in_value_position_is_not_a_slot() {
2628        // `:kind :Biblioteca` — the value is itself a keyword. Stepping one at
2629        // a time would read `:Biblioteca` as a top-level slot.
2630        let src = r#"(defcaixa :kind :Biblioteca :name "x")"#;
2631        assert_eq!(classify(src), Ok(CaixaDialeto::Molde));
2632    }
2633
2634    #[test]
2635    fn an_unrecognised_defcaixa_is_reported_not_guessed() {
2636        let src = r#"(defcaixa :licenca "MIT")"#;
2637        assert_eq!(classify(src), Ok(CaixaDialeto::Desconhecido));
2638    }
2639
2640    #[test]
2641    fn a_form_that_is_not_a_manifest_is_an_error_not_a_dialect() {
2642        assert_eq!(
2643            classify("(defflake :nome \"x\")"),
2644            Err(DialetoError::cabeca_errada("defflake"))
2645        );
2646        assert_eq!(classify(""), Err(DialetoError::Vazio));
2647    }
2648
2649    #[test]
2650    fn every_dialect_names_its_consumer_and_its_canonical_keyword() {
2651        // Guards the routing table itself: a new variant added without an arm
2652        // here is a compile error in the match, and a variant that claims
2653        // `defcaixa` while being read by pleme-doc-gen would re-open the
2654        // collision this module closes. Sweeps [`CaixaDialeto::ALL`] rather
2655        // than the pre-lift open-coded four-arm literal list — a future arm
2656        // addition extends the slice as one edit and this pin picks it up
2657        // by construction.
2658        for &d in CaixaDialeto::ALL {
2659            assert!(!d.descricao().is_empty(), "{d}");
2660            assert!(!d.consumidor().is_empty(), "{d}");
2661        }
2662        assert_eq!(CaixaDialeto::Pacote.palavra_canonica(), "defcaixa");
2663        assert_eq!(CaixaDialeto::Molde.palavra_canonica(), "defmolde");
2664        assert_ne!(
2665            CaixaDialeto::Pacote.palavra_canonica(),
2666            CaixaDialeto::Molde.palavra_canonica(),
2667            "the two dialects must not share a canonical keyword — that IS the defect"
2668        );
2669    }
2670
2671    #[test]
2672    fn caixa_dialeto_all_enumerates_every_variant_exactly_once() {
2673        // Three-legged exhaustiveness pin, peer of the sibling
2674        // `caixa_kind_all_enumerates_every_variant_exactly_once`
2675        // (caixa-core/src/kind.rs) /
2676        // `restart_strategy_all_enumerates_every_variant_exactly_once`
2677        // (caixa-core/src/supervisor.rs) shape.
2678        //
2679        // 1. arm-count invariant: `ALL.len()` matches the declared arm
2680        //    count (four — a fifth arm added without extending `ALL`
2681        //    fails this pin at caixa-core test time);
2682        // 2. pairwise-distinctness invariant: every variant appears at
2683        //    most once in the slice (a duplicate arm would silently
2684        //    double-count in the census consumer, so the pin rejects
2685        //    duplicates outright);
2686        // 3. coverage invariant: every literal `CaixaDialeto::X` is in
2687        //    the slice (the compiler-checked exhaustiveness on the peer
2688        //    per-arm `match self` in the accessors keeps the enum arm
2689        //    set and the `ALL` slice mutually aligned).
2690        assert_eq!(
2691            CaixaDialeto::ALL.len(),
2692            4,
2693            "ALL must list every arm exactly once; a fifth arm added \
2694             without extending ALL fails this pin — extend ALL alongside \
2695             the new variant"
2696        );
2697
2698        let mut seen: Vec<CaixaDialeto> = Vec::new();
2699        for &d in CaixaDialeto::ALL {
2700            assert!(
2701                !seen.contains(&d),
2702                "ALL contains a duplicate arm: {d}. Every variant appears \
2703                 exactly once — a duplicate would double-count in every \
2704                 iteration consumer"
2705            );
2706            seen.push(d);
2707        }
2708
2709        // Coverage: exhaustively assert every literal variant is somewhere
2710        // in the slice. Written as an exhaustive `match` so a future arm
2711        // addition fails to compile here (missing match arm) until the
2712        // corresponding `assert` is added — the compiler enforces the pin's
2713        // completeness rather than a hand-maintained variant list.
2714        for variant in [
2715            CaixaDialeto::Pacote,
2716            CaixaDialeto::Molde,
2717            CaixaDialeto::MoldePosicional,
2718            CaixaDialeto::Desconhecido,
2719        ] {
2720            let coverage_probe = match variant {
2721                CaixaDialeto::Pacote
2722                | CaixaDialeto::Molde
2723                | CaixaDialeto::MoldePosicional
2724                | CaixaDialeto::Desconhecido => variant,
2725            };
2726            assert!(
2727                CaixaDialeto::ALL.contains(&coverage_probe),
2728                "ALL is missing variant {coverage_probe} — extend the slice"
2729            );
2730        }
2731    }
2732
2733    #[test]
2734    fn caixa_dialeto_all_is_const_and_matches_iteration_count() {
2735        // Pins the const-ness of the slice at const-fold time. A future
2736        // change that promoted `ALL` to a non-const initializer (a lazy-
2737        // static, a runtime-computed Vec) would fail to compile here —
2738        // the pin locks in the compile-time-known iteration surface
2739        // every consumer builds against. Peer of the sibling
2740        // `caixa_kind_all_is_const_and_matches_iteration_count` (kind.rs)
2741        // / `restart_strategy_all_is_const_and_matches_iteration_count`
2742        // (supervisor.rs) shape.
2743        const ALL: &[CaixaDialeto] = CaixaDialeto::ALL;
2744        assert_eq!(ALL.len(), CaixaDialeto::ALL.len());
2745        // Sweep the iterator without collapsing to `.len()` so a future
2746        // change to `ALL`'s carrier that decouples `.len()` from the
2747        // iteration count (a lazy-computed shape, an alias `impl Iterator`
2748        // return, a wrapper newtype) still passes here iff the two agree
2749        // arm-for-arm; the `#[allow]` opts this local pin out of the
2750        // clippy `iter_count` collapse that would defeat the intent.
2751        #[allow(clippy::iter_count)]
2752        let iterated = ALL.iter().count();
2753        assert_eq!(iterated, CaixaDialeto::ALL.len());
2754    }
2755
2756    #[test]
2757    fn caixa_dialeto_all_covers_every_variant_by_display_probe() {
2758        // Fanning `Display` over the slice sweeps the paired accessors
2759        // ([`CaixaDialeto::palavra_canonica`] / [`CaixaDialeto::consumidor`]
2760        // / [`CaixaDialeto::descricao`]) at every arm — every returned
2761        // byte-string is non-empty (the accessors' contract). A future
2762        // arm added without extending its per-arm `match self` return
2763        // would compile-fail at the accessor call inside the loop;
2764        // together with the `ALL.len() == 4` pin above, this locks the
2765        // accessor arm-set and the `ALL` slice mutually.
2766        for &d in CaixaDialeto::ALL {
2767            let display_form = d.to_string();
2768            assert!(
2769                !display_form.is_empty(),
2770                "Display must render a non-empty byte-string for every \
2771                 arm; empty: {d:?}"
2772            );
2773            // Consumidor / descricao / palavra-canonica must each surface
2774            // a non-empty scalar; every downstream diagnostic consumer
2775            // reaches through these accessors.
2776            assert!(!d.palavra_canonica().is_empty(), "{d}");
2777            assert!(!d.consumidor().is_empty(), "{d}");
2778            assert!(!d.descricao().is_empty(), "{d}");
2779        }
2780    }
2781
2782    #[test]
2783    fn caixa_dialeto_as_str_returns_pascal_case_variant_name() {
2784        // Fail-before-pass-after per-arm shape pin: the four
2785        // [`CaixaDialeto::as_str`] arms must return the canonical
2786        // `PascalCase` byte-string that names the variant. Pre-lift this
2787        // byte-string existed only inside the hand-rolled Display impl's
2788        // four-arm literal-string match — every consumer that wanted the
2789        // `PascalCase` name reached through `format!("{d}")`'s allocation
2790        // path. Pinning the four arms explicitly here refuses a future
2791        // regression that ever reroutes an arm to a distinct spelling
2792        // (`"pacote"` lowercase, `"MoldePositional"` English rebrand,
2793        // `"Unknown"` for `Desconhecido`) — the census output and the
2794        // typed accessor would silently disagree until a downstream
2795        // consumer surfaced the drift at census time. Peer of the sibling
2796        // [`crate::supervisor::tests::restart_strategy_variants_serialize_to_lifted_scalar_values`]
2797        // / `placement_strategy_variants_serialize_to_lifted_scalar_values`
2798        // / `caixa_kind_as_str_returns_lifted_peer_const` shape on the
2799        // sibling closed-set typed-enum discriminator axes — the seventh
2800        // (and last unlifted) closed-set typed enum on the caixa surface
2801        // to converge onto the same per-arm-shape-pin discipline.
2802        for (variant, expected) in [
2803            (CaixaDialeto::Pacote, "Pacote"),
2804            (CaixaDialeto::Molde, "Molde"),
2805            (CaixaDialeto::MoldePosicional, "MoldePosicional"),
2806            (CaixaDialeto::Desconhecido, "Desconhecido"),
2807        ] {
2808            assert_eq!(
2809                variant.as_str(),
2810                expected,
2811                "CaixaDialeto::{variant:?}.as_str() must return the \
2812                 canonical `PascalCase` variant-name byte-string; drift here \
2813                 splits the census-facing text from the substrate \
2814                 primitive every downstream consumer will read"
2815            );
2816        }
2817    }
2818
2819    #[test]
2820    fn caixa_dialeto_wire_names_covers_every_arm() {
2821        // Load-bearing pin on the substrate-canonical
2822        // [`super::CaixaDialeto::WIRE_NAMES`] exhaustive accept-set
2823        // roster on the `PascalCase` variant-name wire-form axis: every
2824        // variant of the sibling [`super::CaixaDialeto::ALL`] exhaustive-
2825        // iteration surface must project through
2826        // [`super::CaixaDialeto::as_str`] onto an entry the
2827        // [`super::CaixaDialeto::WIRE_NAMES`] roster carries, and the
2828        // roster's length must byte-equal `super::CaixaDialeto::ALL.len()`
2829        // so a silent skew between the [`super::CaixaDialeto::as_str`]
2830        // match's arm-set and the roster's arm-set trips here at
2831        // caixa-core test time rather than at a downstream `feira dialeto
2832        // --list-dialects` per-arm listing / M4 admission-webhook
2833        // rejection-body accepted-tag enumeration miss / structured-log
2834        // accepted-wire-form emit drift.
2835        //
2836        // A future arm addition (the module doc's "third dialect"
2837        // hazard actualising as a fifth arm — a third arity variant, an
2838        // alias-declaration family `pleme-doc-gen` sharpens as its
2839        // schema evolves) extends [`super::CaixaDialeto::ALL`] as a
2840        // single edit and this pin sweeps the new arm by iteration; the
2841        // paired [`super::CaixaDialeto::WIRE_NAMES`] roster must grow in
2842        // lockstep or this assertion trips. Every entry is further
2843        // pinned to open with an uppercase ASCII byte (matching the
2844        // substrate-wide `PascalCase` convention every peer closed-set
2845        // enum whose canonical projection is a `PascalCase` census-
2846        // facing name carries), so a silent collapse of the dialect-
2847        // classification wire-form axis with any hypothetical lowercase-
2848        // kebab peer wire-form axis (an entry byte-identical to a
2849        // sibling lowercase-Portuguese label that would let a wire-axis
2850        // consumer accept the diagnostic byte-string) trips here rather
2851        // than at a downstream census-report round-trip miss.
2852        //
2853        // Peer of the sibling
2854        // [`crate::kind::tests::caixa_kind_wire_names_covers_every_arm`]
2855        // (bd708bd) /
2856        // [`crate::kind::tests::caixa_kind_labels_covers_every_arm`]
2857        // (427fe75) /
2858        // [`crate::supervisor::tests::restart_strategy_wire_names_covers_every_arm`]
2859        // (3033f45) /
2860        // [`crate::supervisor::tests::restart_policy_wire_names_covers_every_arm`]
2861        // (ce9412b) /
2862        // [`crate::aplicacao::tests::placement_strategy_wire_names_covers_every_arm`]
2863        // (3e5b194) /
2864        // [`crate::aplicacao::tests::wit_shape_labels_covers_every_arm`]
2865        // (9d9f585) /
2866        // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
2867        // (b553ec9) /
2868        // [`crate::upgrade::tests::upgrade_instruction_lisp_forms_covers_every_arm`]
2869        // (1898d77) /
2870        // [`crate::upgrade::tests::upgrade_instruction_wire_forms_covers_every_arm`]
2871        // (cc42c0e) /
2872        // [`crate::dep::tests::dep_list_author_keys_covers_every_arm`]
2873        // (af6ad3a) /
2874        // [`crate::render::tests::path_shape_violation_wire_names_covers_every_arm`]
2875        // (0330bd3) pins — the same closed-set exhaustive-roster
2876        // coverage discipline extended here onto the tatara-lisp
2877        // dialect-classification closed-set typed enum, the eleventh
2878        // substrate-side closed-set typed enum on the roster axis and
2879        // the first dialect-classification axis to converge onto the
2880        // discipline.
2881        //
2882        // Fail-before-pass-after locally verified by mutating one arm
2883        // of the paired `CAIXA_DIALETO_WIRE_*` const family (e.g.
2884        // rebranding `CAIXA_DIALETO_WIRE_MOLDE_POSICIONAL` from
2885        // `"MoldePosicional"` to `"MoldePositional"`) — the length pin
2886        // still passes but the `contains` check fires on the mutated
2887        // arm; and by shortening the roster to three entries — the
2888        // length pin fires first.
2889        assert_eq!(
2890            CaixaDialeto::WIRE_NAMES.len(),
2891            CaixaDialeto::ALL.len(),
2892            "CaixaDialeto::WIRE_NAMES.len() must byte-equal \
2893             CaixaDialeto::ALL.len() — a mismatch means the roster and \
2894             the enum's arm-set have drifted; downstream consumers that \
2895             fan through both will silently disagree on the accepted \
2896             arm-set"
2897        );
2898        for &variant in CaixaDialeto::ALL {
2899            let wire = variant.as_str();
2900            assert!(
2901                CaixaDialeto::WIRE_NAMES.contains(&wire),
2902                "CaixaDialeto::{variant:?}.as_str() = {wire:?} must be \
2903                 a member of CaixaDialeto::WIRE_NAMES — the emitter and \
2904                 the roster have drifted out of lockstep"
2905            );
2906        }
2907        for tag in CaixaDialeto::WIRE_NAMES {
2908            let first = tag.chars().next().unwrap_or_else(|| {
2909                panic!(
2910                    "CaixaDialeto::WIRE_NAMES entry {tag:?} must be a \
2911                     non-empty `PascalCase` variant-name byte-string"
2912                )
2913            });
2914            assert!(
2915                first.is_ascii_uppercase(),
2916                "CaixaDialeto::WIRE_NAMES entry {tag:?} must open with \
2917                 an uppercase ASCII byte (matching the substrate-wide \
2918                 `PascalCase` convention) — an entry opening with a \
2919                 lowercase byte would collide the roster with any \
2920                 hypothetical peer lowercase-kebab wire-form axis a \
2921                 downstream consumer might disambiguate against"
2922            );
2923        }
2924        // Pin the exact four-arm roster in declaration order so a
2925        // future arm-swap on either the roster or the paired
2926        // `CAIXA_DIALETO_WIRE_*` constants (a rebrand of the arm-tag
2927        // mapping that leaves both the length pin and the membership
2928        // pin passing on their own) trips at caixa-core test time
2929        // under `assert_eq!`. Order matches variant declaration order
2930        // verbatim (`Pacote` → `Molde` → `MoldePosicional` →
2931        // `Desconhecido`) so the roster is the canonical ordering
2932        // every listing / rendering consumer defers to. Same
2933        // declaration-order pin the sibling
2934        // [`crate::render::tests::path_shape_violation_wire_names_covers_every_arm`]
2935        // (0330bd3) closes on the render-side path-shape-diagnostic
2936        // axis.
2937        assert_eq!(
2938            CaixaDialeto::WIRE_NAMES,
2939            &[
2940                CAIXA_DIALETO_WIRE_PACOTE,
2941                CAIXA_DIALETO_WIRE_MOLDE,
2942                CAIXA_DIALETO_WIRE_MOLDE_POSICIONAL,
2943                CAIXA_DIALETO_WIRE_DESCONHECIDO,
2944            ],
2945            "CaixaDialeto::WIRE_NAMES must enumerate every arm's wire-\
2946             form tag exactly once, in variant declaration order \
2947             (Pacote → Molde → MoldePosicional → Desconhecido)"
2948        );
2949        // Byte-parity pin on the paired reverse projection: every
2950        // entry in the roster must round-trip cleanly through
2951        // [`super::CaixaDialeto::from_wire`] back to the same arm the
2952        // [`super::CaixaDialeto::as_str`] emitter returned it for.
2953        // Refuses any future de-lift that swaps the four consts through
2954        // the reverse projection out of lockstep with the forward
2955        // emitter (a mid-arm rebrand touching only `as_str` but not
2956        // `from_wire`, an argument-ordering swap on one of the match
2957        // arms, a stray `to_lowercase` normalization on either side
2958        // that would silently pass the identity round-trip on the
2959        // already-PascalCase corpus but split the two projections on
2960        // any future non-PascalCase input).
2961        for (&variant, tag) in CaixaDialeto::ALL.iter().zip(CaixaDialeto::WIRE_NAMES) {
2962            assert_eq!(
2963                CaixaDialeto::from_wire(tag),
2964                Some(variant),
2965                "CaixaDialeto::from_wire({tag:?}) must round-trip back \
2966                 to CaixaDialeto::{variant:?} — emitter and parser have \
2967                 drifted off the paired CAIXA_DIALETO_WIRE_* const family"
2968            );
2969        }
2970    }
2971
2972    #[test]
2973    fn caixa_dialeto_display_routes_through_as_str_helper() {
2974        // Fail-before-pass-after convergence pin: for every arm in
2975        // [`CaixaDialeto::ALL`], the [`std::fmt::Display`] rendered form
2976        // must byte-equal [`CaixaDialeto::as_str`]'s return value. Pre-
2977        // lift these two paths were structurally independent — the
2978        // Display impl hand-rolled its own four-arm literal-string
2979        // match with no compile-time link back to any substrate accessor
2980        // — so a future variant rename could land at `Display` without
2981        // touching a paired accessor (or vice versa), silently splitting
2982        // the two paths on the renamed arm. Pinning the byte-equality
2983        // here makes any such split a caixa-core build-time failure at
2984        // this test rather than surfacing far from the rename commit as
2985        // a downstream census consumer emitting one spelling while the
2986        // typed accessor returned another. Peer of the sibling
2987        // [`crate::kind::tests::caixa_kind_display_routes_through_as_str_helper`]
2988        // (which pins the same convergence on the [`crate::CaixaKind`]
2989        // closed-set axis) — extends the discipline onto the seventh
2990        // (and last unlifted) closed-set fieldless typed enum on the
2991        // caixa surface.
2992        for &variant in CaixaDialeto::ALL {
2993            assert_eq!(
2994                variant.to_string(),
2995                variant.as_str(),
2996                "CaixaDialeto::{variant:?} Display must route through \
2997                 CaixaDialeto::as_str (single source of truth: the \
2998                 lifted per-arm `PascalCase` variant-name byte-string)"
2999            );
3000        }
3001    }
3002
3003    #[test]
3004    fn caixa_dialeto_as_ref_str_routes_through_as_str_accessor() {
3005        // Fail-before-pass-after byte-parity pin on the lifted
3006        // `impl AsRef<str> for CaixaDialeto` — asserts the standard-
3007        // library trait impl and the substrate-primitive
3008        // [`CaixaDialeto::as_str`] `pub const fn` accessor resolve to
3009        // the same `&str` per instance across the four-arm closed set,
3010        // so any future silent detour that routes the impl through a
3011        // divergent projection (a per-arm inline
3012        // `match self { CaixaDialeto::Pacote => "Pacote", … }` re-inlining
3013        // that opens a compile-time link to the un-lifted arm-literal,
3014        // a swap onto the second-axis
3015        // [`CaixaDialeto::palavra_canonica`] /
3016        // [`CaixaDialeto::consumidor`] / [`CaixaDialeto::descricao`]
3017        // accessors that carry distinct byte-shapes per axis) trips at
3018        // caixa-core test time under `PartialEq` rather than at a
3019        // downstream `impl AsRef<str>`-bound consumer's silent split.
3020        // Sweeps every one of the four arms [`CaixaDialeto::ALL`]
3021        // carries so no arm's projection is covered only by the sibling
3022        // `Display` path. Peer of the sibling
3023        // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
3024        // (d8136db) on the M3 `:politicas :rate-limit` closed-set typed
3025        // enum, and the peer
3026        // [`crate::kind::tests::caixa_kind_as_ref_str_routes_through_as_str_accessor`]
3027        // (cd2091f) pin on the top-level closed-set typed
3028        // discriminator — the pins together close the substrate
3029        // primitive's `AsRef<str>` projection axis onto the seventh
3030        // closed-set fieldless typed enum on the caixa surface.
3031        for &variant in CaixaDialeto::ALL {
3032            assert_eq!(
3033                <CaixaDialeto as AsRef<str>>::as_ref(&variant),
3034                variant.as_str(),
3035                "AsRef<str> impl on CaixaDialeto::{variant:?} must \
3036                 byte-equal CaixaDialeto::as_str on the same instance \
3037                 — divergence signals a silent detour off the \
3038                 substrate-primitive accessor"
3039            );
3040        }
3041    }
3042
3043    #[test]
3044    fn caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor() {
3045        // Fail-before-pass-after byte-parity pin on the three-path
3046        // convergence discipline the [`CaixaDialeto`] closed-set
3047        // dialect-classification enum now carries on the `&str`-
3048        // projection axis: `<CaixaDialeto as AsRef<str>>::as_ref(&v)`
3049        // (the newly lifted impl), `format!("{v}")` (the pre-existing
3050        // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
3051        // primitive `pub const fn` accessor both trait impls delegate
3052        // through) must resolve to the same byte-string on every
3053        // instance across the four-arm closed set. Refuses any future
3054        // divergence between the two trait impls (a stray
3055        // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
3056        // rather than delegating through the shared accessor; a
3057        // hypothetical `AsRef<str>` rewrite that inlines a per-arm
3058        // literal cascade) that would silently split the two
3059        // projection paths of the same closed-set typed enum. Mirrors
3060        // the sibling three-path-convergence discipline the peer
3061        // [`crate::aplicacao::RateLimitUnit`] typed enum carries
3062        // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
3063        // d8136db), the peer [`crate::CaixaKind`] triple
3064        // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
3065        // cd2091f), and the [`crate::CaixaVersion`] typed newtype
3066        // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
3067        // 16d5c7e).
3068        for &variant in CaixaDialeto::ALL {
3069            let via_as_ref: &str = <CaixaDialeto as AsRef<str>>::as_ref(&variant);
3070            let via_display: String = format!("{variant}");
3071            let via_accessor: &str = variant.as_str();
3072            assert_eq!(via_as_ref, via_accessor);
3073            assert_eq!(via_display, via_accessor);
3074            assert_eq!(via_as_ref, via_display.as_str());
3075        }
3076    }
3077
3078    #[test]
3079    fn caixa_dialeto_is_molde_family_returns_true_on_molde_and_positional_arms() {
3080        // Fail-before-pass-after per-arm shape pin on the two `defmolde`
3081        // declaration-family arms: [`CaixaDialeto::is_molde_family`] must
3082        // return `true` for [`CaixaDialeto::Molde`] and
3083        // [`CaixaDialeto::MoldePosicional`] — the two-arity closure of
3084        // one declaration ([`CaixaDialeto::MoldePosicional`]'s docstring:
3085        // "same declaration as [`Self::Molde`], written with the package
3086        // name as a bare positional symbol … one arity of one
3087        // declaration, not a third schema"). A future accidental flip that
3088        // reversed a per-arm arm's return without touching the paired
3089        // false-arm pin would silently open the substrate primitive to
3090        // false-positive on either arm — the `feira dialeto` verb's
3091        // `--strict-palavra` gate would then silently accept
3092        // repo-surface declarations under `(defcaixa …)` on one arm and
3093        // reject them on the other. Pinning the two true arms explicitly
3094        // here refuses that split at caixa-core build time.
3095        assert!(
3096            CaixaDialeto::Molde.is_molde_family(),
3097            "CaixaDialeto::Molde.is_molde_family() must return true — \
3098             Molde is the primary `defmolde` arm"
3099        );
3100        assert!(
3101            CaixaDialeto::MoldePosicional.is_molde_family(),
3102            "CaixaDialeto::MoldePosicional.is_molde_family() must return \
3103             true — MoldePosicional is the positional-arity form of the \
3104             same `defmolde` declaration Molde carries"
3105        );
3106    }
3107
3108    #[test]
3109    fn caixa_dialeto_is_molde_family_returns_false_on_pacote_and_desconhecido_arms() {
3110        // Fail-before-pass-after per-arm shape pin on the two non-`defmolde`
3111        // arms: [`CaixaDialeto::is_molde_family`] must return `false` for
3112        // [`CaixaDialeto::Pacote`] (the sibling `defcaixa` tatara-lisp
3113        // package manifest, `palavra_canonica → "defcaixa"`) and for
3114        // [`CaixaDialeto::Desconhecido`] (the residue that names no
3115        // known declaration, `palavra_canonica → "?"`). Pinning the two
3116        // false arms explicitly here refuses a future accidental flip
3117        // that let the predicate widen to include either arm — the
3118        // `feira dialeto` verb's `--strict-palavra` gate would then
3119        // spuriously refuse every `(defcaixa …)` package manifest as if
3120        // it were a repo-surface declaration.
3121        assert!(
3122            !CaixaDialeto::Pacote.is_molde_family(),
3123            "CaixaDialeto::Pacote.is_molde_family() must return false — \
3124             Pacote is the `defcaixa` tatara-lisp package manifest, not \
3125             the `defmolde` repo-surface declaration"
3126        );
3127        assert!(
3128            !CaixaDialeto::Desconhecido.is_molde_family(),
3129            "CaixaDialeto::Desconhecido.is_molde_family() must return \
3130             false — the residue arm names no known declaration; it is \
3131             not silently promoted into the `defmolde` family"
3132        );
3133    }
3134
3135    #[test]
3136    fn caixa_dialeto_is_molde_family_agrees_with_palavra_canonica_defmolde_projection() {
3137        // Load-bearing pin: for every arm in [`CaixaDialeto::ALL`], the
3138        // typed [`CaixaDialeto::is_molde_family`] predicate must agree
3139        // byte-for-byte with the paired [`CaixaDialeto::palavra_canonica`]
3140        // projection's `== "defmolde"` classifier — i.e. the two paths
3141        // partition the four-arm discriminator set into the same
3142        // `{Molde, MoldePosicional}` and `{Pacote, Desconhecido}` halves.
3143        // Pre-lift the sibling [`CaixaDialeto::palavra_canonica`] projection
3144        // (which returns `"defmolde"` for `Molde | MoldePosicional`,
3145        // `"defcaixa"` for `Pacote`, `"?"` for `Desconhecido`) was the
3146        // only substrate-side surface carrying the two-arm collapse; the
3147        // hand-rolled `matches!(d, CaixaDialeto::Molde |
3148        // CaixaDialeto::MoldePosicional)` sites in the `feira dialeto`
3149        // verb expressed no compile-time link back to it. A future arm
3150        // addition — the module doc's "third dialect" hazard actualises
3151        // as a fifth arm belonging to the `defmolde` family — would land
3152        // one match arm at [`Self::palavra_canonica`]'s `defmolde` return
3153        // (extending the sibling projection) but silently split the
3154        // hand-rolled two-arm `matches!` predicate sites if the new arm's
3155        // `is_molde_family` return were forgotten. Pinning byte-equality
3156        // between the two paths here makes any such split a caixa-core
3157        // build-time failure at this test rather than surfacing far from
3158        // the arm-addition commit as a downstream `--strict-palavra` /
3159        // `caixa.lisp`-holds-wrong-declaration gate silently ignoring the
3160        // new arm.
3161        for &d in CaixaDialeto::ALL {
3162            let via_palavra_canonica = d.palavra_canonica() == "defmolde";
3163            let via_is_molde_family = d.is_molde_family();
3164            assert_eq!(
3165                via_is_molde_family, via_palavra_canonica,
3166                "CaixaDialeto::{d:?}.is_molde_family() ({via_is_molde_family}) \
3167                 must agree with CaixaDialeto::{d:?}.palavra_canonica() == \
3168                 \"defmolde\" ({via_palavra_canonica}) — a split between the \
3169                 typed predicate and the sibling keyword projection would let \
3170                 a future arm addition land at one path and drift at the other, \
3171                 which is exactly the drift this pin refuses"
3172            );
3173        }
3174    }
3175
3176    #[test]
3177    fn caixa_dialeto_is_molde_family_is_const_fn() {
3178        // Const-context pin: [`CaixaDialeto::is_molde_family`] must remain
3179        // `const fn` (its match is a fieldless-arm literal-pattern
3180        // discriminator, so no non-const operation exists on the resolution
3181        // path). Downstream consumers reaching for the predicate from a
3182        // `const` context (a future substrate-wide const-fold-driven audit
3183        // table that materializes per-arm gate-membership at build time,
3184        // a per-arm CR-admission-webhook gate registration in a `const`
3185        // context) rely on the const-ness. A future accidental downgrade
3186        // to non-`const` (an added runtime helper reachable only from a
3187        // non-`const` context) trips at caixa-core build time rather than
3188        // surfacing as a downstream `const`-context regression far from
3189        // the predicate declaration. Peer of the sibling
3190        // [`caixa_dialeto_as_str_is_const_fn`] pin on the paired
3191        // [`CaixaDialeto::as_str`] byte-string axis.
3192        const ARMS: [(CaixaDialeto, bool); 4] = [
3193            (CaixaDialeto::Pacote, CaixaDialeto::Pacote.is_molde_family()),
3194            (CaixaDialeto::Molde, CaixaDialeto::Molde.is_molde_family()),
3195            (
3196                CaixaDialeto::MoldePosicional,
3197                CaixaDialeto::MoldePosicional.is_molde_family(),
3198            ),
3199            (
3200                CaixaDialeto::Desconhecido,
3201                CaixaDialeto::Desconhecido.is_molde_family(),
3202            ),
3203        ];
3204        // Materialize the const-fold-evaluated table into a runtime slice
3205        // assertion — carries the same `bool = const fn call` shape a raw
3206        // `assert!(const_bool)` would, without tripping the
3207        // `assertions_on_constants` clippy lint that a per-arm
3208        // `assert!(CONST)` on a `const bool` triggers when the arm-count
3209        // is enumerated flat rather than compared as a whole-table shape.
3210        assert_eq!(
3211            ARMS,
3212            [
3213                (CaixaDialeto::Pacote, false),
3214                (CaixaDialeto::Molde, true),
3215                (CaixaDialeto::MoldePosicional, true),
3216                (CaixaDialeto::Desconhecido, false),
3217            ],
3218            "CaixaDialeto::is_molde_family() must evaluate in const context \
3219             for every arm and land on the {{false, true, true, false}} \
3220             partition — a future accidental downgrade to non-`const` \
3221             would trip the const-context array-initializer here"
3222        );
3223    }
3224
3225    #[test]
3226    fn caixa_dialeto_as_str_is_const_fn() {
3227        // Const-context pin: [`CaixaDialeto::as_str`] must remain
3228        // `const fn` (its match arms return `pub const` byte-strings, so
3229        // no non-const operation exists on the resolution path).
3230        // Downstream consumers reaching for the accessor from a `const`
3231        // context (a future substrate-wide const-fold-driven audit table
3232        // that materializes every dialect's census label at build time,
3233        // a per-arm CR-admission-webhook message registration in a
3234        // `const` gate) rely on the const-ness. A future accidental
3235        // downgrade to non-`const` (an added runtime helper reachable
3236        // only from a non-`const` context, a manual hand-rolled `impl`
3237        // that shadows this method) trips at caixa-core build time
3238        // rather than surfacing as a downstream `const`-context
3239        // regression far from the accessor declaration. Peer of the
3240        // sibling [`crate::kind::tests::caixa_kind_wire_name_is_const_fn`]
3241        // pin on the paired [`crate::CaixaKind`] byte-string axis.
3242        const PACOTE: &str = CaixaDialeto::Pacote.as_str();
3243        const MOLDE: &str = CaixaDialeto::Molde.as_str();
3244        const MOLDE_POSICIONAL: &str = CaixaDialeto::MoldePosicional.as_str();
3245        const DESCONHECIDO: &str = CaixaDialeto::Desconhecido.as_str();
3246        assert_eq!(PACOTE, "Pacote");
3247        assert_eq!(MOLDE, "Molde");
3248        assert_eq!(MOLDE_POSICIONAL, "MoldePosicional");
3249        assert_eq!(DESCONHECIDO, "Desconhecido");
3250    }
3251
3252    #[test]
3253    fn caixa_dialeto_is_variant_predicates_partition_the_arm_set() {
3254        // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
3255        // derive: for each of the four variants at [`CaixaDialeto::ALL`]`[idx]`
3256        // the observed four-slot predicate row must equal a one-hot row
3257        // with the `true` at exactly `idx`. Pre-derive the closed four-arm
3258        // dialect-classification partition lived only inside the paired
3259        // per-arm projections' four-arm match resolvers ([`Self::as_str`] /
3260        // [`Self::palavra_canonica`] / [`Self::consumidor`] /
3261        // [`Self::descricao`]) plus the two-arm [`Self::is_molde_family`]
3262        // hand-rolled `matches!` (now routed through the derived
3263        // predicates); a future rebrand (an accidental
3264        // `#[is_variant(name = "…")]` drift, a manual hand-rolled `impl`
3265        // that shadows the derive-generated method, an arm rename that
3266        // reroutes one arm through the wrong predicate lane) trips this
3267        // pin at caixa-core build time rather than surfacing far from the
3268        // derive declaration as a downstream [`Self::is_molde_family`]
3269        // consumer accepting the wrong arm-set. The expected row is
3270        // generated live from the [`Self::ALL`] declaration order rather
3271        // than transcribed by hand so a copy-paste flip reroutes at the
3272        // identity-diagonal assertion.
3273        //
3274        // Peer of the sibling
3275        // [`crate::kind::tests::caixa_kind_is_variant_predicates_partition_the_arm_set`]
3276        // / [`crate::supervisor::tests::restart_strategy_is_variant_predicates_partition_the_arm_set`]
3277        // / [`crate::aplicacao::tests::placement_strategy_is_variant_predicates_partition_the_arm_set`]
3278        // / [`crate::upgrade::tests::upgrade_instruction_is_variant_predicates_partition_the_arm_set`]
3279        // pins on the sibling closed-set typed-enum discriminator axes.
3280        for (idx, &variant) in CaixaDialeto::ALL.iter().enumerate() {
3281            let observed = [
3282                variant.is_pacote(),
3283                variant.is_molde(),
3284                variant.is_molde_posicional(),
3285                variant.is_desconhecido(),
3286            ];
3287            let mut expected = [false; 4];
3288            expected[idx] = true;
3289            assert_eq!(
3290                observed, expected,
3291                "CaixaDialeto::{variant:?} at ALL[{idx}] is_* predicates \
3292                 must fire only on their own arm lane (identity diagonal); \
3293                 got {observed:?}",
3294            );
3295        }
3296    }
3297
3298    #[test]
3299    fn caixa_dialeto_is_variant_predicates_are_const_fn() {
3300        // The [`gen_platform::IsVariant`] derive emits `const fn`
3301        // predicates on the peer [`crate::CaixaKind`] +
3302        // [`crate::upgrade::UpgradeInstruction`] +
3303        // [`crate::supervisor::RestartStrategy`] +
3304        // [`crate::supervisor::RestartPolicy`] +
3305        // [`crate::aplicacao::PlacementStrategy`] +
3306        // [`crate::aplicacao::RateLimitUnit`] +
3307        // [`crate::dep::DepList`] closed-set typed enums — pin the same
3308        // posture on [`CaixaDialeto`] so a future accidental downgrade
3309        // to non-`const` (an added runtime helper reachable only from a
3310        // non-`const` context, a manual hand-rolled `impl` that shadows
3311        // the derive-generated method) trips at caixa-core build time
3312        // rather than surfacing as a downstream `const`-context
3313        // regression far from the derive declaration.
3314        // Use `const { assert!(…) }` (peer of the sibling
3315        // [`crate::render::PathShapeViolation`] +
3316        // [`crate::aplicacao::RateLimitUnit`] +
3317        // [`caixa_theme::style::Semantic`] const-fn pins) so the
3318        // const-context evaluation trips at const-fold time without
3319        // opening a per-`const bool` `assertions_on_constants` clippy
3320        // debt row this crate does not carry today for `dialeto.rs`.
3321        const { assert!(CaixaDialeto::Pacote.is_pacote()) };
3322        const { assert!(CaixaDialeto::Molde.is_molde()) };
3323        const { assert!(CaixaDialeto::MoldePosicional.is_molde_posicional()) };
3324        const { assert!(CaixaDialeto::Desconhecido.is_desconhecido()) };
3325    }
3326
3327    #[test]
3328    fn caixa_dialeto_from_wire_accepts_every_as_str_output() {
3329        // Fail-before-pass-after per-arm accept pin on the newly lifted
3330        // [`CaixaDialeto::from_wire`] reverse projection: every arm in
3331        // [`CaixaDialeto::ALL`] must parse back through `from_wire` when
3332        // fed its own [`CaixaDialeto::as_str`] output, landing on
3333        // `Some(same_variant)` — a regression that hand-rolled either
3334        // side's per-arm match without threading through the shared
3335        // four-string closed set would silently disagree on any future
3336        // arm rename and this pin flags it at caixa-core build time.
3337        // Peer of the sibling
3338        // [`crate::kind::tests::caixa_kind_wire_round_trips_through_from_wire`]
3339        // (2aa6d23) /
3340        // `placement_strategy_from_wire_accepts_every_lifted_constant`
3341        // (18c7342) /
3342        // `dep_list_round_trips_through_as_str_and_from_wire` (45ee563)
3343        // shape on the sibling closed-set typed-enum reverse-projection
3344        // axes.
3345        for &variant in CaixaDialeto::ALL {
3346            let wire = variant.as_str();
3347            let parsed = CaixaDialeto::from_wire(wire).unwrap_or_else(|| {
3348                panic!(
3349                    "CaixaDialeto::from_wire({wire:?}) must accept every \
3350                     CaixaDialeto::as_str output — got None for the \
3351                     wire byte-string of {variant:?}"
3352                )
3353            });
3354            assert_eq!(
3355                parsed, variant,
3356                "CaixaDialeto::from_wire(CaixaDialeto::{variant:?}.as_str()) \
3357                 must return CaixaDialeto::{variant:?} — the (as_str, \
3358                 from_wire) pair must form a total round-trip on the \
3359                 closed four-arm CaixaDialeto arm-set"
3360            );
3361        }
3362    }
3363
3364    #[test]
3365    fn caixa_dialeto_from_wire_rejects_unknown_byte_strings() {
3366        // Rejection pin on the parser's accept-set: any string outside
3367        // the four-arm [`CaixaDialeto::as_str`] output set must return
3368        // `None`. A future accidental widening of the accept-set (a
3369        // case-insensitive match that accepts `"pacote"` on the wire
3370        // axis, a hand-rolled Levenshtein-forgiving arm-lookup that
3371        // admits `"Pacotee"` typos, a silent acceptance of the sibling
3372        // [`Self::palavra_canonica`] `"defcaixa"` / `"defmolde"`
3373        // byte-shapes on this axis) would silently drift the parser's
3374        // accept-set from the emitter's — a downstream audit-report
3375        // re-loader that bound a prior audit's [`Self::as_str`] output
3376        // back to the typed enum through this parser would then bind a
3377        // malformed byte-string to a plausibly-wrong typed arm the
3378        // caller does not route through any fallback, silently
3379        // misclassifying the reloaded row. Also rejects the sibling
3380        // [`Self::palavra_canonica`] (`"defcaixa"` / `"defmolde"`) and
3381        // the sibling [`Self::consumidor`] (`"caixa-core / feira"`,
3382        // `"pleme-doc-gen"`, `"nobody known"`) byte-shapes, which are
3383        // the substrate's *distinct-axis* projections on the same enum
3384        // — the two-axis split the sibling
3385        // [`Self::palavra_canonica`] / [`Self::consumidor`] /
3386        // [`Self::descricao`] docstrings explicitly frame forbids
3387        // accepting one axis's byte-shapes as parseable on the other
3388        // axis. Peer of the sibling
3389        // [`crate::kind::tests::caixa_kind_from_wire_rejects_unknown_byte_strings`]
3390        // (2aa6d23) /
3391        // `placement_strategy_from_wire_rejects_unknown_byte_strings`
3392        // (18c7342) /
3393        // `dep_list_from_wire_returns_none_on_unknown_wire_scalar`
3394        // (45ee563) rejection pins on the sibling closed-set typed-enum
3395        // reverse-projection axes.
3396        for bad in [
3397            "",
3398            " ",
3399            "pacote",
3400            "PACOTE",
3401            "molde",
3402            "MoldePositional",
3403            "desconhecido",
3404            "Unknown",
3405            "defcaixa",
3406            "defmolde",
3407            "?",
3408            "caixa-core / feira",
3409            "pleme-doc-gen",
3410            "nobody known",
3411            "Pacote ",
3412            " Pacote",
3413        ] {
3414            assert!(
3415                CaixaDialeto::from_wire(bad).is_none(),
3416                "CaixaDialeto::from_wire({bad:?}) must return None — the \
3417                 parser's accept-set is exactly the four CaixaDialeto::as_str \
3418                 outputs; a widening would silently split the parser's \
3419                 accept-set from the emitter's arm-set"
3420            );
3421        }
3422    }
3423
3424    #[test]
3425    fn cabeca_errada_ctor_matches_struct_literal_wrap() {
3426        // Fail-before-pass-after byte-identity pin: the lifted
3427        // [`DialetoError::cabeca_errada`] ctor MUST land on the exact
3428        // same struct-literal shape the pre-lift open-coded wire-up
3429        // block wrote by hand — `DialetoError::CabecaErrada {
3430        // encontrado: <head>.to_string() }`. A future accidental
3431        // divergence (`.into()` swap, per-arm constant substitution, an
3432        // added default field, an `.to_ascii_lowercase()` normalization
3433        // silently injected into the ctor body, a rebrand of the
3434        // `encontrado` field carrying a distinct byte-shape) trips this
3435        // pin at caixa-core build time rather than surfacing far from
3436        // the ctor declaration as a downstream `classify_form`
3437        // wrong-head consumer emitting one diagnostic shape while a
3438        // hand-written test peer opens another. Peer of the sibling
3439        // `unknown_byte_unit_ctor_matches_struct_literal_wrap`
3440        // (limits.rs; 29fac09) / `duplicate_from_ctor_matches_struct_
3441        // literal_wrap` (upgrade.rs; 7e52aec) shape on the sibling
3442        // single-slot `{ <field>: String }` envelope constructors.
3443        assert_eq!(
3444            DialetoError::cabeca_errada("defflake"),
3445            DialetoError::CabecaErrada {
3446                encontrado: "defflake".to_string(),
3447            },
3448            "DialetoError::cabeca_errada must byte-equal the pre-lift \
3449             open-coded struct-literal — a drift here means the ctor \
3450             stopped being a substrate primitive for the wrong-head \
3451             fallthrough site"
3452        );
3453    }
3454
3455    #[test]
3456    fn cabeca_errada_routes_encontrado_verbatim_across_boundary_inputs() {
3457        // Fail-before-pass-after boundary-sweep pin: the lifted
3458        // [`DialetoError::cabeca_errada`] ctor MUST route its
3459        // `encontrado: &str` argument verbatim into the
3460        // [`DialetoError::CabecaErrada`] `encontrado: String` field
3461        // for every boundary-covering `&str` input — empty string, a
3462        // canonical `defcaixa`-adjacent head, a non-ASCII head, a
3463        // whitespace-carrying head, a Unicode-full-width head. Any
3464        // wrapper-side truncation, silent `.trim()`, accidental
3465        // `.to_ascii_lowercase()` normalization, or `.into()` divergence
3466        // on the ctor body surfaces here as a byte-mismatch against the
3467        // input rather than at a downstream
3468        // [`DialetoError::to_string()`] diagnostic-shape drift at a
3469        // wrong-head fallthrough consumer far from the ctor declaration.
3470        // Peer of the sibling `limits_codec_unit_only_ctors_route_unit_
3471        // verbatim_across_every_variant` (limits.rs; 29fac09) shape on
3472        // the sibling single-slot `{ <field>: String }` envelope
3473        // boundary-sweep discipline.
3474        for encontrado in [
3475            "",
3476            "defflake",
3477            "def-molde",
3478            "defcaixa ",
3479            " defcaixa",
3480            "μdefcaixa",
3481            "\u{00A0}defcaixa",
3482            "\u{3000}defcaixa",
3483            "def\u{2028}caixa",
3484        ] {
3485            let via_ctor = DialetoError::cabeca_errada(encontrado);
3486            let via_literal = DialetoError::CabecaErrada {
3487                encontrado: encontrado.to_string(),
3488            };
3489            assert_eq!(
3490                via_ctor, via_literal,
3491                "DialetoError::cabeca_errada({encontrado:?}) must byte- \
3492                 equal the open-coded struct-literal on the same input — \
3493                 a drift here would let the ctor silently normalize / \
3494                 truncate the head symbol before it reached the \
3495                 CabecaErrada envelope"
3496            );
3497            let DialetoError::CabecaErrada { encontrado: routed } = via_ctor else {
3498                panic!(
3499                    "DialetoError::cabeca_errada must construct the \
3500                     CabecaErrada arm — got a different variant on \
3501                     input {encontrado:?}"
3502                );
3503            };
3504            assert_eq!(
3505                routed, encontrado,
3506                "DialetoError::cabeca_errada must route the input \
3507                 {encontrado:?} verbatim into the encontrado field — \
3508                 any wrapper-side truncation / normalization surfaces \
3509                 here rather than at a downstream diagnostic shape drift"
3510            );
3511        }
3512    }
3513
3514    #[test]
3515    fn classify_form_wrong_head_routes_through_cabeca_errada_ctor() {
3516        // Fail-before-pass-after routing pin: [`classify`]'s wrong-head
3517        // fallthrough site MUST construct its `Err(DialetoError::…)`
3518        // through the substrate-primitive [`DialetoError::cabeca_errada`]
3519        // ctor rather than through an open-coded struct-literal. Pre-
3520        // lift the wire-up hand-rolled a three-line
3521        // `Self::CabecaErrada { encontrado: other.to_string() }` block
3522        // with no compile-time link back to the substrate primitive; a
3523        // future accidental rebrand of the ctor body (an added
3524        // `.trim()` on `encontrado`, a per-arm constant prefix like
3525        // `"unknown-head:"`, a widening of the field into a
3526        // `(String, usize)` tuple carrying a caret offset) would then
3527        // silently split the two paths — the ctor consumers pick up
3528        // the new shape, the open-coded wire-up does not. Pinning
3529        // byte-equality between the observed `Err` and the ctor-
3530        // constructed `Err` refuses that split at caixa-core build
3531        // time rather than surfacing far from the wire-up commit as a
3532        // downstream diagnostic-consumer split.
3533        for head in ["defflake", "deffoobar", "defcaixaz", "let", "defmoldez"] {
3534            let src = format!("({head} :nome \"x\")");
3535            let observed = classify(&src);
3536            let via_ctor = Err(DialetoError::cabeca_errada(head));
3537            assert_eq!(
3538                observed, via_ctor,
3539                "classify({src:?}) must return the same Err shape as \
3540                 DialetoError::cabeca_errada({head:?}) — a drift here \
3541                 means the wire-up de-lifted its wrong-head fallthrough \
3542                 arm off the substrate primitive"
3543            );
3544        }
3545    }
3546
3547    #[test]
3548    fn leitura_ctor_matches_tuple_literal_wrap_on_str_binding() {
3549        // Fail-before-pass-after byte-identity pin: the lifted
3550        // [`DialetoError::leitura`] ctor MUST land on the exact same
3551        // tuple-newtype wrap the pre-lift open-coded wire-up block wrote by
3552        // hand — `DialetoError::Leitura(<into-String-expr>)`. A future
3553        // accidental divergence (an added `.trim()` on the reader reason,
3554        // a per-arm constant prefix like `"tatara-lisp:"`, a widening of
3555        // the tuple carrying a caret offset, a rebrand of the payload
3556        // carrying a distinct byte-shape) trips this pin at caixa-core
3557        // build time rather than surfacing far from the ctor declaration
3558        // as a downstream [`classify`] tatara-lisp-reader consumer
3559        // emitting one diagnostic shape while a hand-written test peer
3560        // opens another. Peer of the sibling
3561        // `cabeca_errada_ctor_matches_struct_literal_wrap` pin above on
3562        // the same [`DialetoError`] envelope's wrong-head axis, and of
3563        // the peer `LimitsError::empty_byte_size` /
3564        // `LimitsError::empty_duration` (7a4b003 / 319216c) shape on the
3565        // sibling `(String)` single-slot tuple-newtype envelope
3566        // constructors.
3567        let reason: &str = "unclosed paren at 1:12";
3568        assert_eq!(
3569            DialetoError::leitura(reason),
3570            DialetoError::Leitura(reason.to_string()),
3571            "DialetoError::leitura must byte-equal the pre-lift open-coded \
3572             tuple-newtype wrap — a drift here means the ctor stopped \
3573             being a substrate primitive for the tatara-lisp-reader \
3574             fallthrough site"
3575        );
3576    }
3577
3578    #[test]
3579    fn leitura_ctor_matches_tuple_literal_wrap_on_string_binding() {
3580        // Fail-before-pass-after byte-identity pin on the `String` wire-up
3581        // shape: the lifted [`DialetoError::leitura`] ctor MUST land on
3582        // the same tuple-newtype wrap when the caller passes an owned
3583        // `String` (the actual [`classify`] wire-up shape — `e.to_string()`
3584        // on a [`tatara_lisp::Error`]-carrying binding). Pins that the
3585        // `impl Into<String>` param covers the owned-`String` path with no
3586        // silent double-allocation or intermediate `&str` reslicing. Peer
3587        // of the sibling `_on_str_binding` pin above — together they close
3588        // the `impl Into<String>` bound's two authored wire-up shapes on
3589        // the ctor's substrate primitive.
3590        let reason: String = String::from("read: unexpected EOF at 3:1");
3591        let via_ctor = DialetoError::leitura(reason.clone());
3592        let via_literal = DialetoError::Leitura(reason.clone());
3593        assert_eq!(
3594            via_ctor, via_literal,
3595            "DialetoError::leitura must byte-equal the pre-lift open-coded \
3596             tuple-newtype wrap on the same owned-String fixture — a drift \
3597             here would let the ctor silently reshape the reader reason \
3598             before it reached the Leitura envelope"
3599        );
3600        let DialetoError::Leitura(routed) = via_ctor else {
3601            panic!(
3602                "DialetoError::leitura must construct the Leitura arm — \
3603                 got a different variant on input {reason:?}"
3604            );
3605        };
3606        assert_eq!(
3607            routed, reason,
3608            "DialetoError::leitura must route the input {reason:?} \
3609             verbatim into the tuple-newtype payload — any wrapper-side \
3610             truncation / normalization surfaces here rather than at a \
3611             downstream diagnostic shape drift"
3612        );
3613    }
3614
3615    #[test]
3616    fn leitura_routes_reason_verbatim_across_boundary_inputs() {
3617        // Fail-before-pass-after boundary-sweep pin: the lifted
3618        // [`DialetoError::leitura`] ctor MUST route its
3619        // `reason: impl Into<String>` argument verbatim into the
3620        // [`DialetoError::Leitura`] tuple-newtype `String` payload for
3621        // every boundary-covering input — empty string, a canonical
3622        // tatara-lisp reader error, a non-ASCII reason, a
3623        // whitespace-carrying reason, a Unicode-full-width reason. Any
3624        // wrapper-side truncation, silent `.trim()`, accidental
3625        // `.to_ascii_lowercase()` normalization, or `.into()` divergence
3626        // on the ctor body surfaces here as a byte-mismatch against the
3627        // input rather than at a downstream [`DialetoError::to_string()`]
3628        // diagnostic-shape drift at a tatara-lisp-reader fallthrough
3629        // consumer far from the ctor declaration. Peer of the sibling
3630        // `cabeca_errada_routes_encontrado_verbatim_across_boundary_inputs`
3631        // pin above on the same [`DialetoError`] envelope's wrong-head
3632        // axis.
3633        for reason in [
3634            "",
3635            "unclosed paren at 1:12",
3636            "unexpected token ')'",
3637            "read: eof",
3638            " leading whitespace",
3639            "trailing whitespace ",
3640            "μnicode reason",
3641            "\u{00A0}NBSP-prefixed reason",
3642            "\u{3000}ideographic-space reason",
3643            "reason\u{2028}with-line-separator",
3644        ] {
3645            let via_ctor = DialetoError::leitura(reason);
3646            let via_literal = DialetoError::Leitura(reason.to_string());
3647            assert_eq!(
3648                via_ctor, via_literal,
3649                "DialetoError::leitura({reason:?}) must byte-equal the \
3650                 open-coded tuple-newtype wrap on the same input — a \
3651                 drift here would let the ctor silently normalize / \
3652                 truncate the reader reason before it reached the \
3653                 Leitura envelope"
3654            );
3655            let DialetoError::Leitura(routed) = via_ctor else {
3656                panic!(
3657                    "DialetoError::leitura must construct the Leitura \
3658                     arm — got a different variant on input {reason:?}"
3659                );
3660            };
3661            assert_eq!(
3662                routed, reason,
3663                "DialetoError::leitura must route the input {reason:?} \
3664                 verbatim into the tuple-newtype payload — any \
3665                 wrapper-side truncation / normalization surfaces here \
3666                 rather than at a downstream diagnostic shape drift"
3667            );
3668        }
3669    }
3670
3671    #[test]
3672    fn classify_reader_error_routes_through_leitura_ctor() {
3673        // Fail-before-pass-after routing pin: [`classify`]'s
3674        // tatara-lisp-reader map-err site MUST construct its
3675        // `Err(DialetoError::…)` through the substrate-primitive
3676        // [`DialetoError::leitura`] ctor rather than through an
3677        // open-coded tuple-newtype wrap. Pre-lift the wire-up hand-rolled
3678        // a `Self::Leitura(e.to_string())` block with no compile-time
3679        // link back to the substrate primitive; a future accidental
3680        // rebrand of the ctor body (an added `.trim()` on the reader
3681        // reason, a per-arm constant prefix like `"tatara-lisp:"`, a
3682        // widening of the payload into a `(String, usize)` tuple
3683        // carrying a caret offset) would then silently split the two
3684        // paths — the ctor consumers pick up the new shape, the
3685        // open-coded wire-up does not. Pinning byte-equality between
3686        // the observed `Err` and the ctor-constructed `Err` refuses
3687        // that split at caixa-core build time rather than surfacing far
3688        // from the wire-up commit as a downstream diagnostic-consumer
3689        // split. Peer of the sibling
3690        // `classify_form_wrong_head_routes_through_cabeca_errada_ctor`
3691        // pin above on the same [`DialetoError`] envelope's wrong-head
3692        // fallthrough axis.
3693        //
3694        // The malformed sources below each name a distinct
3695        // tatara-lisp-reader failure shape (unclosed paren, stray close
3696        // paren, unterminated string), so together they sweep the
3697        // reader's rejection surface rather than pinning against one
3698        // specific error message the reader upstream is free to reword.
3699        for src in [
3700            "(defcaixa :nome \"x\"",
3701            "defcaixa :nome \"x\")",
3702            "(defcaixa :nome \"unterminated",
3703        ] {
3704            let observed = classify(src);
3705            let Err(DialetoError::Leitura(reason)) = observed.clone() else {
3706                panic!(
3707                    "classify({src:?}) must return the Leitura arm — got \
3708                     {observed:?}"
3709                );
3710            };
3711            let via_ctor: Result<CaixaDialeto, DialetoError> =
3712                Err(DialetoError::leitura(reason.clone()));
3713            assert_eq!(
3714                observed, via_ctor,
3715                "classify({src:?}) must return the same Err shape as \
3716                 DialetoError::leitura({reason:?}) — a drift here means \
3717                 the wire-up de-lifted its tatara-lisp-reader fallthrough \
3718                 arm off the substrate primitive"
3719            );
3720        }
3721    }
3722
3723    #[test]
3724    fn caixa_dialeto_try_from_str_routes_through_from_wire_accessor() {
3725        // Fail-before-pass-after byte-parity pin on the lifted
3726        // `impl TryFrom<&str> for CaixaDialeto`: for every arm in
3727        // [`CaixaDialeto::ALL`], the `.try_into()` / `TryFrom::try_from`
3728        // path must resolve to the same variant the sibling
3729        // [`CaixaDialeto::from_wire`] resolver returns on the same
3730        // [`CaixaDialeto::as_str`] wire byte-string input. Pins the
3731        // three-path convergence discipline the [`CaixaDialeto`] closed-
3732        // set typed enum now carries on the `str → Self` reverse-
3733        // projection axis: `<CaixaDialeto as TryFrom<&str>>::try_from(s)`
3734        // (the newly lifted trait-idiomatic reverse projection),
3735        // `CaixaDialeto::from_wire(s)` (the substrate-primitive method-
3736        // named `Option<Self>` accessor the trait impl delegates through),
3737        // and the round-trip identity `variant.as_str() → variant`
3738        // (the four-arm closed accept-set shared between the emitter and
3739        // both reverse-projection consumers) must resolve to the same
3740        // typed [`CaixaDialeto`] discriminator on every arm.
3741        //
3742        // A future silent detour that routes the impl through a
3743        // divergent projection (a per-arm inline
3744        // `match s { "Pacote" => …, … }` re-inlining that opens a
3745        // compile-time link to the un-lifted arm-literal, a swap onto
3746        // the second-axis [`CaixaDialeto::palavra_canonica`] /
3747        // [`CaixaDialeto::consumidor`] / [`CaixaDialeto::descricao`]
3748        // accessors that carry distinct byte-shapes per axis, an accept-
3749        // set widening that silently accepts one axis's byte-shapes as
3750        // parseable on the other axis) trips at caixa-core test time
3751        // under `assert_eq!` rather than at a downstream
3752        // `TryFrom<&str>`-bound consumer's silent split. Peer of the
3753        // sibling
3754        // [`crate::kind::tests::caixa_kind_try_from_str_routes_through_from_wire_accessor`]
3755        // (3c83606) on the top-level [`crate::CaixaKind`] closed-set
3756        // discriminator's reverse-projection axis — extends the trait-
3757        // idiomatic reverse-projection axis onto the seventh closed-set
3758        // fieldless typed enum on the caixa surface (the second one to
3759        // carry the paired `TryFrom<&str>` impl).
3760        for &variant in CaixaDialeto::ALL {
3761            let wire = variant.as_str();
3762            let via_try_from: CaixaDialeto = <CaixaDialeto as TryFrom<&str>>::try_from(wire)
3763                .unwrap_or_else(|()| {
3764                    panic!(
3765                        "CaixaDialeto::try_from({wire:?}) must accept every \
3766                         CaixaDialeto::as_str output — got Err(()) for the \
3767                         wire byte-string of {variant:?}"
3768                    )
3769                });
3770            let via_from_wire: CaixaDialeto = CaixaDialeto::from_wire(wire).unwrap_or_else(|| {
3771                panic!(
3772                    "CaixaDialeto::from_wire({wire:?}) must accept every \
3773                     CaixaDialeto::as_str output — got None for the wire \
3774                     byte-string of {variant:?}"
3775                )
3776            });
3777            assert_eq!(
3778                via_try_from, variant,
3779                "CaixaDialeto::try_from(CaixaDialeto::{variant:?}.as_str()) \
3780                 must return CaixaDialeto::{variant:?} — the trait-idiomatic \
3781                 reverse projection must land on the same arm the method-named \
3782                 from_wire resolver does",
3783            );
3784            assert_eq!(
3785                via_try_from, via_from_wire,
3786                "CaixaDialeto::try_from({wire:?}) ({via_try_from:?}) must \
3787                 byte-equal CaixaDialeto::from_wire({wire:?}) ({via_from_wire:?}) \
3788                 on the same input — divergence signals a silent detour off the \
3789                 shared substrate-primitive resolver",
3790            );
3791            assert_eq!(
3792                <CaixaDialeto as TryFrom<&str>>::try_from(wire).ok(),
3793                CaixaDialeto::from_wire(wire),
3794                "the Result::ok() projection of TryFrom<&str> must byte-equal \
3795                 the sibling from_wire Option<Self> output on {wire:?} — the \
3796                 two accessors must share the same accept-set and typed \
3797                 outcome per arm",
3798            );
3799        }
3800    }
3801
3802    #[test]
3803    fn caixa_dialeto_try_from_str_rejects_unknown_byte_strings() {
3804        // Rejection witness on the trait-idiomatic reverse-projection
3805        // axis: any string outside the four-arm [`CaixaDialeto::as_str`]
3806        // output set must resolve to `Err(())` through the lifted
3807        // [`impl TryFrom<&str> for CaixaDialeto`]. A future accidental
3808        // widening of the accept-set (a case-insensitive match that
3809        // accepts `"pacote"` on the wire axis, a hand-rolled Levenshtein-
3810        // forgiving arm-lookup that admits `"Pacotee"` typos, a silent
3811        // acceptance of the sibling [`CaixaDialeto::palavra_canonica`]
3812        // `"defcaixa"` / `"defmolde"` byte-shapes on this axis, a swap
3813        // onto the [`CaixaDialeto::consumidor`] `"pleme-doc-gen"` /
3814        // `"caixa-core / feira"` / `"nobody known"` byte-shapes) would
3815        // silently drift the trait-idiomatic parser's accept-set from
3816        // the sibling [`CaixaDialeto::from_wire`] resolver's — a
3817        // downstream `TryFrom<&str>`-bound consumer binding a malformed
3818        // byte-string through this impl would then bind a plausibly-
3819        // wrong typed arm the caller does not route through any fallback,
3820        // silently misclassifying the reloaded row.
3821        //
3822        // Sweeps the same rejection set the sibling
3823        // [`caixa_dialeto_from_wire_rejects_unknown_byte_strings`] pin
3824        // walks (the shared `from_wire` resolver both accessors delegate
3825        // through) so the trait-idiomatic axis and the method-named axis
3826        // stay locked to the same accept-set by construction. Peer of the
3827        // sibling
3828        // [`crate::kind::tests::caixa_kind_try_from_str_rejects_unknown_byte_strings`]
3829        // (3c83606) on the top-level [`crate::CaixaKind`] closed-set
3830        // discriminator's trait-idiomatic reverse-projection axis.
3831        for bad in [
3832            "",
3833            " ",
3834            "pacote",
3835            "PACOTE",
3836            "molde",
3837            "MoldePositional",
3838            "desconhecido",
3839            "Unknown",
3840            "defcaixa",
3841            "defmolde",
3842            "?",
3843            "caixa-core / feira",
3844            "pleme-doc-gen",
3845            "nobody known",
3846            "Pacote ",
3847            " Pacote",
3848        ] {
3849            assert_eq!(
3850                <CaixaDialeto as TryFrom<&str>>::try_from(bad),
3851                Err(()),
3852                "CaixaDialeto::try_from({bad:?}) must return Err(()) — the \
3853                 trait-idiomatic parser's accept-set is exactly the four \
3854                 CaixaDialeto::as_str outputs; a widening would silently \
3855                 split the trait-idiomatic reverse-projection axis from the \
3856                 sibling from_wire resolver's arm-set"
3857            );
3858        }
3859    }
3860
3861    #[test]
3862    fn caixa_dialeto_from_str_routes_through_try_from_str_impl() {
3863        // Fail-before-pass-after byte-parity pin on the newly lifted
3864        // `impl std::str::FromStr for CaixaDialeto` — asserts the
3865        // standard-library `.parse()` parse-axis entry point and the
3866        // paired [`super::CaixaDialeto::try_from`] `TryFrom<&str>` impl
3867        // (which in turn routes through the substrate-primitive
3868        // [`super::CaixaDialeto::from_wire`] `Option<Self>` accessor)
3869        // resolve to the same four-arm accept-set across every arm the
3870        // exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
3871        // Extends the substrate-wide `FromStr` parse-axis campaign —
3872        // opened on [`crate::dep::DepList`] via 6167092 as first-
3873        // mover, extended onto the structurally most fundamental
3874        // closed-set typed enum via [`crate::CaixaKind`] (9867432),
3875        // then onto the first M3-mesh-primitive-defining slot enum
3876        // via [`crate::aplicacao::PlacementStrategy`] (62ef49a) —
3877        // onto the dialect-classification axis every [`crate::Caixa`]
3878        // carries through its parsed manifest form. The peer
3879        // method-named `from_wire` accessor and the paired
3880        // `TryFrom<&str>` trait impl fix the four-arm PascalCase
3881        // accept-set; this pin locks the `FromStr::from_str` trait
3882        // entry point onto the same set so any future divergence (a
3883        // stray per-arm `match s` re-inlining that opens a compile-
3884        // time link to an un-lifted arm-literal, a swap onto a hand-
3885        // rolled parser that widens the accept-set past the four
3886        // lifted [`crate::render::CAIXA_DIALETO_WIRE_*`] consts) trips
3887        // at caixa-core test time.
3888        use std::str::FromStr;
3889        for &variant in CaixaDialeto::ALL {
3890            let wire = variant.as_str();
3891            assert_eq!(
3892                <CaixaDialeto as FromStr>::from_str(wire),
3893                Ok(variant),
3894                "FromStr impl on CaixaDialeto must round-trip \
3895                 CaixaDialeto::{variant:?}.as_str() = {wire:?} back to \
3896                 Ok(CaixaDialeto::{variant:?}) — divergence from \
3897                 CaixaDialeto::try_from signals a silent detour off the \
3898                 paired reverse-projection trait impl"
3899            );
3900            assert_eq!(
3901                <CaixaDialeto as FromStr>::from_str(wire).ok(),
3902                CaixaDialeto::from_wire(wire),
3903                "FromStr ok()-projection on {wire:?} must byte-equal \
3904                 CaixaDialeto::from_wire on the same input — divergence \
3905                 signals the two reverse-projection trait paths have \
3906                 drifted off the substrate-primitive accessor"
3907            );
3908            // `.parse::<CaixaDialeto>()` short-form witness — the
3909            // stdlib consumer surface that reaches the enum through
3910            // the `T: FromStr` bound, not through `TryFrom<&str>`.
3911            let via_parse: Result<CaixaDialeto, ()> = wire.parse();
3912            assert_eq!(
3913                via_parse,
3914                Ok(variant),
3915                "`{wire:?}`.parse::<CaixaDialeto>() must resolve to \
3916                 Ok(CaixaDialeto::{variant:?}) — divergence signals \
3917                 the stdlib `.parse()` short-form has drifted from the \
3918                 lifted `FromStr::from_str` impl"
3919            );
3920        }
3921    }
3922
3923    #[test]
3924    fn caixa_dialeto_from_str_rejects_unknown_byte_strings() {
3925        // Rejection witness on the `impl FromStr for CaixaDialeto` —
3926        // sweeps candidate byte-strings outside the four-arm
3927        // PascalCase accept-set the sibling
3928        // [`super::CaixaDialeto::as_str`] emits and asserts every one
3929        // lands on `Err(())`, so a future accidental widening of the
3930        // trait impl's accept-set (a stray case-fold path, a silent
3931        // acceptance of the sibling [`CaixaDialeto::palavra_canonica`]
3932        // `"defcaixa"` / `"defmolde"` byte-shapes on this axis, a
3933        // swap onto the [`CaixaDialeto::consumidor`] /
3934        // [`CaixaDialeto::descricao`] axes' byte-shapes) trips at
3935        // caixa-core test time. Peer of the sibling
3936        // [`caixa_dialeto_try_from_str_rejects_unknown_byte_strings`]
3937        // rejection witness — the two pins together bracket both
3938        // reverse-projection trait impls against the same rejected
3939        // set. Peer of the sibling
3940        // [`crate::kind::tests::caixa_kind_from_str_rejects_unknown_byte_strings`]
3941        // (9867432) rejection witness on the top-level
3942        // [`crate::CaixaKind`] closed-set discriminator's trait-
3943        // idiomatic `FromStr` parse axis.
3944        use std::str::FromStr;
3945        let rejected: &[&str] = &[
3946            "",
3947            " ",
3948            "pacote",
3949            "PACOTE",
3950            "molde",
3951            "MoldePositional",
3952            "desconhecido",
3953            "Unknown",
3954            "defcaixa",
3955            "defmolde",
3956            "?",
3957            "caixa-core / feira",
3958            "pleme-doc-gen",
3959            "nobody known",
3960            "Pacote ",
3961            " Pacote",
3962            "Pacote\n",
3963            "\"Pacote\"",
3964        ];
3965        for &input in rejected {
3966            assert_eq!(
3967                <CaixaDialeto as FromStr>::from_str(input),
3968                Err(()),
3969                "FromStr impl on CaixaDialeto must reject unknown \
3970                 byte-string {input:?} — divergence signals a silent \
3971                 accept-set widening past the four lifted \
3972                 crate::render::CAIXA_DIALETO_WIRE_* wire constants"
3973            );
3974            assert_eq!(
3975                <CaixaDialeto as FromStr>::from_str(input).ok(),
3976                CaixaDialeto::from_wire(input),
3977                "FromStr ok()-projection on {input:?} must byte-equal \
3978                 CaixaDialeto::from_wire on the same input — \
3979                 divergence signals the FromStr trait path has drifted \
3980                 off the substrate-primitive accessor"
3981            );
3982            let via_parse: Result<CaixaDialeto, ()> = input.parse();
3983            assert_eq!(
3984                via_parse,
3985                Err(()),
3986                "`{input:?}`.parse::<CaixaDialeto>() must reject the \
3987                 unknown byte-string — divergence signals the stdlib \
3988                 `.parse()` short-form has drifted from the lifted \
3989                 `FromStr::from_str` impl"
3990            );
3991        }
3992    }
3993
3994    #[test]
3995    fn caixa_dialeto_from_into_static_str_routes_through_as_str_accessor() {
3996        // Fail-before-pass-after byte-parity pin on the newly lifted
3997        // `impl From<CaixaDialeto> for &'static str` — asserts the
3998        // standard-library trait impl and the substrate-primitive
3999        // [`CaixaDialeto::as_str`] `pub const fn` accessor resolve to
4000        // the same four-arm emit-set across every arm the exhaustive
4001        // [`CaixaDialeto::ALL`] slice enumerates. Any future silent
4002        // detour that routes the trait impl through a divergent
4003        // projection (a per-arm inline `match dialeto { Pacote =>
4004        // "Pacote", … }` re-inlining that opens a compile-time link to
4005        // the un-lifted arm-literal, an accidental swap onto the second-
4006        // axis [`CaixaDialeto::palavra_canonica`] /
4007        // [`CaixaDialeto::consumidor`] / [`CaixaDialeto::descricao`]
4008        // accessors that carry distinct byte-shapes per axis) trips at
4009        // caixa-core test time under `assert_eq!` rather than at a
4010        // downstream `impl Into<&'static str>`-bound consumer's silent
4011        // split. Sweeps every one of the four arms [`CaixaDialeto::ALL`]
4012        // carries so no arm's projection is covered only by the sibling
4013        // method-named `as_str` / [`std::fmt::Display`] / [`AsRef<str>`]
4014        // paths. Materializes the `<&'static str as
4015        // From<CaixaDialeto>>::from` output in a `const`-shape binding
4016        // to make the `'static` lifetime promise a build-time invariant
4017        // — a future accidental downgrade of any of the four arms'
4018        // returned literals to a non-`&'static str` (a `String::leak()`-
4019        // produced return, a `Box::leak`-cast, an intermediate lifetime-
4020        // erasing helper) trips at caixa-core build time rather than at
4021        // a downstream `'static`-bound consumer. Peer of the sibling
4022        // [`crate::supervisor::tests::restart_strategy_from_into_static_str_routes_through_as_str_accessor`]
4023        // (523157d) /
4024        // [`crate::supervisor::tests::restart_policy_from_into_static_str_routes_through_as_str_accessor`]
4025        // (9fb37d0) /
4026        // [`crate::kind::tests::caixa_kind_from_into_static_str_routes_through_as_str_accessor`]
4027        // (edb827b) pins on the sibling closed-set typed-enum forward-
4028        // projection axes — extends the trait-idiomatic forward-
4029        // projection axis onto the fourth closed-set fieldless typed
4030        // enum on the caixa surface (the dialect-classification axis,
4031        // second-of-two closed-set typed enums in caixa-core outside
4032        // the OTP-shape M2 slot).
4033        const PACOTE: &str = CaixaDialeto::Pacote.as_str();
4034        const MOLDE: &str = CaixaDialeto::Molde.as_str();
4035        const MOLDE_POSICIONAL: &str = CaixaDialeto::MoldePosicional.as_str();
4036        const DESCONHECIDO: &str = CaixaDialeto::Desconhecido.as_str();
4037        for &variant in CaixaDialeto::ALL {
4038            let via_trait: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
4039            let via_method: &'static str = variant.as_str();
4040            assert_eq!(
4041                via_trait, via_method,
4042                "From<CaixaDialeto> for &'static str impl must round-trip \
4043                 CaixaDialeto::{variant:?} to the same `PascalCase` byte-string \
4044                 CaixaDialeto::as_str returns — divergence signals a silent \
4045                 detour off the substrate-primitive accessor"
4046            );
4047            let via_into: &'static str = variant.into();
4048            assert_eq!(
4049                via_into, via_method,
4050                "Into<&'static str>::into on CaixaDialeto::{variant:?} must \
4051                 byte-equal CaixaDialeto::as_str on the same input — the \
4052                 blanket-derived Into shape must resolve to the same as_str \
4053                 dispatch as the explicit From impl"
4054            );
4055        }
4056        assert_eq!(
4057            [PACOTE, MOLDE, MOLDE_POSICIONAL, DESCONHECIDO],
4058            ["Pacote", "Molde", "MoldePosicional", "Desconhecido"],
4059            "const-context CaixaDialeto::as_str must resolve to the four \
4060             `PascalCase` variant-name byte-strings — a future accidental \
4061             downgrade of any arm to a non-const or non-static byte-string \
4062             breaks the `&'static str`-lifetime promise the paired \
4063             From<CaixaDialeto> for &'static str impl carries by \
4064             construction"
4065        );
4066    }
4067
4068    #[test]
4069    fn caixa_dialeto_from_into_static_str_and_as_str_partition_the_emit_set() {
4070        // Cross-axis partition pin: the paired trait-idiomatic
4071        // `From<CaixaDialeto> for &'static str` forward projection and
4072        // the method-named [`CaixaDialeto::as_str`] forward projection
4073        // must resolve identically on *every* arm, not just the ones
4074        // named in the primary byte-parity pin above. Sweeps every
4075        // [`CaixaDialeto::ALL`] arm and asserts the trait's `From::from`
4076        // output byte-equals the method-named accessor's return-value on
4077        // each, locking the two forward-projection paths together by
4078        // construction so any future detour (a stray `From` special-case
4079        // that lands on a divergent per-arm literal outside the paired
4080        // `as_str` dispatch, a hypothetical rebrand touching one axis
4081        // without the other) trips at caixa-core test time. Peer of the
4082        // sibling forward-projection partition pins
4083        // [`crate::supervisor::tests::restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`]
4084        // (523157d) /
4085        // [`crate::supervisor::tests::restart_policy_from_into_static_str_and_as_str_partition_the_emit_set`]
4086        // (9fb37d0) /
4087        // [`crate::kind::tests::caixa_kind_from_into_static_str_and_as_str_partition_the_emit_set`]
4088        // (edb827b) — extends the round-trip discipline onto the fourth
4089        // closed-set typed enum on the caixa surface, closing the two-way
4090        // `Self ↔ &'static str` round-trip on the trait-idiomatic pair
4091        // (`From<Self> for &'static str` + `TryFrom<&str> for Self`) as
4092        // well as the pre-existing method-named pair (`as_str` +
4093        // `from_wire`).
4094        for &variant in CaixaDialeto::ALL {
4095            let via_trait: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
4096            let via_method: &'static str = variant.as_str();
4097            assert_eq!(
4098                via_trait, via_method,
4099                "From<CaixaDialeto> for &'static str and \
4100                 CaixaDialeto::as_str must resolve identically on \
4101                 CaixaDialeto::{variant:?} — divergence signals the \
4102                 two forward-projection paths have drifted onto different \
4103                 emit-sets"
4104            );
4105        }
4106        // Round-trip witness: every arm's forward `From` output re-parses
4107        // through the paired trait-idiomatic reverse `TryFrom<&str>` back
4108        // to the original variant. Closes the two-way `CaixaDialeto ↔
4109        // &'static str` round-trip on the trait-idiomatic axis pair
4110        // directly (no wire-vocab intermediate the peer [`CaixaKind`]
4111        // axis pair requires — the emit-side [`CaixaDialeto::as_str`]
4112        // and the parse-side [`CaixaDialeto::from_wire`] share the same
4113        // `PascalCase` byte-string vocabulary by construction), mirroring
4114        // the pre-existing method-named `as_str` + `from_wire` round-trip
4115        // on the substrate-primitive axis pair.
4116        for &variant in CaixaDialeto::ALL {
4117            let emitted: &'static str = variant.into();
4118            let re_parsed: Result<CaixaDialeto, ()> =
4119                <CaixaDialeto as TryFrom<&str>>::try_from(emitted);
4120            assert_eq!(
4121                re_parsed,
4122                Ok(variant),
4123                "trait-idiomatic axis pair must round-trip \
4124                 CaixaDialeto::{variant:?} through `.into::<&'static \
4125                 str>()` and back through `TryFrom<&str>` — a break signals \
4126                 the forward-emit and reverse-parse axes have drifted onto \
4127                 different vocabularies"
4128            );
4129        }
4130    }
4131
4132    #[test]
4133    fn caixa_dialeto_is_molde_family_routes_through_is_variant_derived_predicates() {
4134        // Byte-parity pin on the post-lift [`CaixaDialeto::is_molde_family`]
4135        // convergence: for every arm in [`CaixaDialeto::ALL`], the typed
4136        // predicate must byte-equal the direct
4137        // `self.is_molde() || self.is_molde_posicional()` composition of
4138        // the two derived per-arm predicates. Pre-lift the predicate
4139        // hand-rolled `matches!(self, Self::Molde | Self::MoldePosicional)`
4140        // with no compile-time link back to the closed-set typed dispatch;
4141        // post-lift it routes through the derived predicates so a future
4142        // arm rename or `#[is_variant(name = "…")]` override lands at
4143        // exactly one dispatch on the substrate primitive. Pinning the
4144        // byte-equality here refuses a future accidental split between
4145        // the composed predicate and the paired derived predicates
4146        // (a hand-rolled shadow `impl` that overrides one path but not
4147        // the other, an accidental rebrand of `is_molde_family`'s body
4148        // back to the pre-lift `matches!` form) at caixa-core build time.
4149        for &d in CaixaDialeto::ALL {
4150            let via_derived = d.is_molde() || d.is_molde_posicional();
4151            let via_is_molde_family = d.is_molde_family();
4152            assert_eq!(
4153                via_is_molde_family, via_derived,
4154                "CaixaDialeto::{d:?}.is_molde_family() ({via_is_molde_family}) \
4155                 must byte-equal the composed derived predicates \
4156                 is_molde() || is_molde_posicional() ({via_derived}) — a \
4157                 split between the composed predicate and its derived \
4158                 building blocks would let a future arm rename land at one \
4159                 path and drift at the other, which is exactly the drift \
4160                 the IsVariant lift refuses"
4161            );
4162        }
4163    }
4164
4165    #[test]
4166    fn caixa_dialeto_from_borrowed_into_static_str_routes_through_as_str_accessor() {
4167        // Fail-before-pass-after byte-parity pin on the newly lifted
4168        // `impl From<&CaixaDialeto> for &'static str` — asserts the
4169        // borrowed-input standard-library trait impl and the substrate-
4170        // primitive [`CaixaDialeto::as_str`] `pub const fn` accessor
4171        // resolve to the same four-arm emit-set across every arm the
4172        // exhaustive [`CaixaDialeto::ALL`] slice enumerates. Rust's
4173        // `From` trait does not auto-derive the borrowed-input sibling
4174        // from a paired owned-input impl (no `impl<T, U> From<&T> for U
4175        // where T: Copy, U: From<T>` blanket in `core`), so the
4176        // borrowed-input axis is a distinct trait-idiomatic surface that
4177        // a `.iter().map(Into::into)` shape over [`CaixaDialeto::ALL`]
4178        // (whose iterator yields `&CaixaDialeto`, not `CaixaDialeto`)
4179        // reaches through this impl and no other — the paired owned-
4180        // input [`From<CaixaDialeto>`] impl requires an explicit
4181        // `.copied()` / dereference before the trait fires.
4182        // Materializes the `<&'static str as From<&CaixaDialeto>>::from`
4183        // output in a `const`-shape binding to make the `'static`
4184        // lifetime promise a build-time invariant — a future accidental
4185        // downgrade of any of the four arms' returned literals to a
4186        // non-`&'static str` trips at caixa-core build time rather than
4187        // at a downstream `'static`-bound consumer. Peer of the sibling
4188        // [`crate::dep::tests::dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor`]
4189        // (64aa742) /
4190        // [`crate::kind::tests::caixa_kind_from_borrowed_into_static_str_routes_through_as_str_accessor`]
4191        // (5ab993a) pins on the sibling closed-set typed-enum borrowed-
4192        // input forward-projection axes — extends the borrowed-input
4193        // axis discipline onto the third peer on the substrate-wide
4194        // campaign, the dialect-classification axis.
4195        const PACOTE: &str = CaixaDialeto::Pacote.as_str();
4196        const MOLDE: &str = CaixaDialeto::Molde.as_str();
4197        const MOLDE_POSICIONAL: &str = CaixaDialeto::MoldePosicional.as_str();
4198        const DESCONHECIDO: &str = CaixaDialeto::Desconhecido.as_str();
4199        for variant in CaixaDialeto::ALL {
4200            let via_trait: &'static str = <&'static str as From<&CaixaDialeto>>::from(variant);
4201            let via_method: &'static str = variant.as_str();
4202            assert_eq!(
4203                via_trait, via_method,
4204                "From<&CaixaDialeto> for &'static str impl must round-trip \
4205                 &CaixaDialeto::{variant:?} to the same `PascalCase` byte-\
4206                 string CaixaDialeto::as_str returns — divergence signals a \
4207                 silent detour off the substrate-primitive accessor"
4208            );
4209            let via_into: &'static str = variant.into();
4210            assert_eq!(
4211                via_into, via_method,
4212                "Into<&'static str>::into on &CaixaDialeto::{variant:?} must \
4213                 byte-equal CaixaDialeto::as_str on the same input — the \
4214                 blanket-derived Into shape must resolve to the same as_str \
4215                 dispatch as the explicit From impl"
4216            );
4217        }
4218        assert_eq!(
4219            [PACOTE, MOLDE, MOLDE_POSICIONAL, DESCONHECIDO],
4220            ["Pacote", "Molde", "MoldePosicional", "Desconhecido"],
4221            "const-context CaixaDialeto::as_str must resolve to the four \
4222             `PascalCase` variant-name byte-strings — the borrowed-input \
4223             From<&CaixaDialeto> for &'static str impl inherits its \
4224             `'static` lifetime promise from the same accessor the owned-\
4225             input sibling routes through"
4226        );
4227    }
4228
4229    #[test]
4230    fn caixa_dialeto_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
4231        // Cross-axis partition pin: the paired trait-idiomatic
4232        // owned-input `From<CaixaDialeto> for &'static str` and
4233        // borrowed-input `From<&CaixaDialeto> for &'static str` (this
4234        // lift) forward projections must resolve identically on every
4235        // arm, locking the two input-shape paths together so any future
4236        // detour trips at caixa-core test time. Then a witness that a
4237        // `.iter().map(Into::into)` pipe over [`CaixaDialeto::ALL`]
4238        // (whose iterator yields `&CaixaDialeto`) materializes the four-
4239        // arm accept-set through the borrowed-input axis alone — the
4240        // exact shape a future M4 admission-webhook rejection body
4241        // composer, a future substrate-wide per-arm diagnostic column,
4242        // or a `HashMap::<&'static str, CaixaDialeto>::from_iter(
4243        //     CaixaDialeto::ALL.iter().map(|d| (d.into(), *d)))`-style
4244        // per-dialect lookup reaches through — closing the two-way
4245        // owned/borrowed input-shape symmetry on the forward-projection
4246        // trait-idiomatic axis. Peer of the sibling
4247        // [`crate::dep::tests::dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
4248        // (64aa742) /
4249        // [`crate::kind::tests::caixa_kind_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
4250        // (5ab993a) partition pins — extends the borrowed-input axis
4251        // discipline onto the third peer on the substrate-wide campaign.
4252        for &variant in CaixaDialeto::ALL {
4253            let owned: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
4254            let borrowed: &'static str = <&'static str as From<&CaixaDialeto>>::from(&variant);
4255            assert_eq!(
4256                owned, borrowed,
4257                "From<CaixaDialeto> and From<&CaixaDialeto> for &'static str \
4258                 must resolve identically on CaixaDialeto::{variant:?} — \
4259                 divergence signals the owned-input and borrowed-input \
4260                 forward-projection paths have drifted onto different \
4261                 emit-sets"
4262            );
4263        }
4264        let via_iter: Vec<&'static str> = CaixaDialeto::ALL.iter().map(Into::into).collect();
4265        let via_method: Vec<&'static str> = CaixaDialeto::ALL.iter().map(|d| d.as_str()).collect();
4266        assert_eq!(
4267            via_iter, via_method,
4268            "`.iter().map(Into::into)` over CaixaDialeto::ALL must byte-\
4269             equal `.iter().map(|d| d.as_str())` on every arm — the \
4270             borrowed-input `From<&CaixaDialeto> for &'static str` axis \
4271             is what makes the `.iter().map(Into::into)` shape route \
4272             through the substrate-primitive `CaixaDialeto::as_str` \
4273             accessor rather than through a per-call-site `.copied()` / \
4274             dereference detour"
4275        );
4276        // Direct round-trip witness on the borrowed-input axis: every
4277        // arm's borrowed `From` output re-parses through the paired
4278        // trait-idiomatic reverse `TryFrom<&str>` back to the original
4279        // variant. Unlike the peer [`crate::CaixaKind`] axis pair
4280        // (whose forward `From<Self> for &'static str` emits the
4281        // lowercase Portuguese `as_str` diagnostic vocabulary while
4282        // the reverse `TryFrom<&str>` parses the `PascalCase`
4283        // `wire_name` author-surface vocabulary, forcing the round-trip
4284        // through an intermediate wire-vocab hop), [`CaixaDialeto`]'s
4285        // [`CaixaDialeto::as_str`] emit and [`CaixaDialeto::from_wire`]
4286        // parse share the same `PascalCase` vocabulary by construction,
4287        // so the borrowed-input forward axis and the reverse axis
4288        // compose directly.
4289        for &variant in CaixaDialeto::ALL {
4290            let borrowed: &'static str = <&'static str as From<&CaixaDialeto>>::from(&variant);
4291            let re_parsed: Result<CaixaDialeto, ()> =
4292                <CaixaDialeto as TryFrom<&str>>::try_from(borrowed);
4293            assert_eq!(
4294                re_parsed,
4295                Ok(variant),
4296                "trait-idiomatic borrowed-input round-trip must project \
4297                 &CaixaDialeto::{variant:?} through \
4298                 `<&'static str>::from(&variant)` and back through \
4299                 `TryFrom<&str>` — a break signals the borrowed-input \
4300                 forward-emit axis and the reverse-parse axis have \
4301                 drifted onto different vocabularies"
4302            );
4303        }
4304    }
4305
4306    #[test]
4307    fn caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor() {
4308        // Fail-before-pass-after byte-parity pin on the newly lifted
4309        // `impl From<CaixaDialeto> for String` — asserts the owned-`String`
4310        // -returning standard-library trait impl and the substrate-
4311        // primitive [`CaixaDialeto::as_str`] `pub const fn` accessor
4312        // resolve to the same four-arm emit-set across every arm the
4313        // exhaustive [`CaixaDialeto::ALL`] slice enumerates. Rust's
4314        // standard library does not carry a blanket
4315        // `impl<T: AsRef<str>> From<T> for String` (nor an
4316        // `impl<T: fmt::Display> From<T> for String`), so the
4317        // owned-`String` forward-projection axis is a distinct trait-
4318        // idiomatic surface that a `let key: String = dialeto.into();`-
4319        // shaped call site reaches through this impl and no other — the
4320        // paired sibling `From<CaixaDialeto> for &'static str` impl
4321        // forces every owned-`String` call site through an explicit
4322        // `.to_owned()` / `String::from` restatement. Peer of the
4323        // first-mover
4324        // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
4325        // (7baa18a), the second-peer
4326        // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
4327        // (7851725), and the third-peer
4328        // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
4329        // (231a18c) — extends the trait-idiomatic owned-`String`
4330        // forward-projection axis onto the fourth closed-set fieldless
4331        // typed enum on the caixa surface (the dialect-classification
4332        // axis, second peer outside the M2 OTP-shape sibling axis).
4333        for &variant in CaixaDialeto::ALL {
4334            let via_trait: String = <String as From<CaixaDialeto>>::from(variant);
4335            let via_method: &'static str = variant.as_str();
4336            assert_eq!(
4337                via_trait.as_str(),
4338                via_method,
4339                "From<CaixaDialeto> for String impl must round-trip \
4340                 CaixaDialeto::{variant:?} to the same `PascalCase` \
4341                 arm-string CaixaDialeto::as_str returns — divergence \
4342                 signals a silent detour off the substrate-primitive \
4343                 accessor"
4344            );
4345            let via_into: String = variant.into();
4346            assert_eq!(
4347                via_into.as_str(),
4348                via_method,
4349                "Into<String>::into on CaixaDialeto::{variant:?} must \
4350                 byte-equal CaixaDialeto::as_str on the same input — the \
4351                 blanket-derived Into shape must resolve to the same \
4352                 as_str dispatch as the explicit From impl"
4353            );
4354        }
4355    }
4356
4357    #[test]
4358    fn caixa_dialeto_from_into_owned_string_and_static_str_agree_on_every_arm() {
4359        // Cross-axis partition pin: the paired trait-idiomatic
4360        // owned-`String` `From<CaixaDialeto> for String` (this lift) and
4361        // owned-`&'static str` `From<CaixaDialeto> for &'static str`
4362        // (c189a6f) forward projections must resolve identically on
4363        // every arm, locking the two return-type-shape paths together
4364        // so any future detour trips at caixa-core test time. Also
4365        // byte-parity witness against the sibling
4366        // [`ToString::to_string`] surface routed through
4367        // [`std::fmt::Display`] — the three owned-heap-string paths
4368        // (`.into::<String>()`, `String::from`, `.to_string()`) must
4369        // resolve identically on every arm so a future consumer that
4370        // picks any of the three lands on the same four-arm
4371        // `PascalCase` accept-set. Then a `.iter().copied()
4372        // .map(String::from)` pipe witness over [`CaixaDialeto::ALL`]
4373        // that materializes the four-arm accept-set through the
4374        // owned-`String` axis alone — the exact shape a future M4
4375        // admission-webhook rejection body composer or a
4376        // `HashMap::<String, CaixaDialeto>::from_iter(
4377        //     CaixaDialeto::ALL.iter().copied().map(|d| (d.into(), d)))`-
4378        // style owned-key per-dialect lookup reaches through — closing
4379        // the owned-`String` forward-projection axis's iterator-pipe
4380        // shape. Then a direct round-trip witness through the paired
4381        // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
4382        // owned-`String`'s [`String::as_str`] borrow that closes the
4383        // two-way `Self → String → Self` round-trip on the trait-
4384        // idiomatic owned-`String` forward + reverse axis pair.
4385        //
4386        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
4387        // `From` emit lands on the lowercase Portuguese `as_str`
4388        // diagnostic vocabulary while the reverse `TryFrom<&str>` parses
4389        // the `PascalCase` `wire_name` author-surface vocabulary,
4390        // forcing the round-trip through an intermediate
4391        // [`crate::CaixaKind::wire_name`] hop), [`CaixaDialeto`]'s
4392        // [`CaixaDialeto::as_str`] emit and [`CaixaDialeto::from_wire`]
4393        // parse share the same `PascalCase` vocabulary by construction
4394        // (there is no wire/diagnostic axis split on this enum), so
4395        // the owned-`String` forward axis and the reverse axis compose
4396        // directly — matching the peer
4397        // [`crate::supervisor::RestartStrategy`] /
4398        // [`crate::supervisor::RestartPolicy`] owned-`String` axis
4399        // pairs (whose forward emit and reverse parse also share one
4400        // `PascalCase` vocabulary by construction).
4401        for &variant in CaixaDialeto::ALL {
4402            let owned_string: String = <String as From<CaixaDialeto>>::from(variant);
4403            let owned_static: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
4404            assert_eq!(
4405                owned_string.as_str(),
4406                owned_static,
4407                "From<CaixaDialeto> for String and From<CaixaDialeto> for \
4408                 &'static str must resolve identically on \
4409                 CaixaDialeto::{variant:?} — divergence signals the \
4410                 owned-`String` and owned-`&'static str` forward-\
4411                 projection return-type-shape paths have drifted onto \
4412                 different emit-sets"
4413            );
4414            let via_to_string: String = variant.to_string();
4415            assert_eq!(
4416                owned_string, via_to_string,
4417                "From<CaixaDialeto> for String must byte-equal \
4418                 CaixaDialeto::to_string on CaixaDialeto::{variant:?} — \
4419                 divergence signals the trait-idiomatic owned-`String` \
4420                 forward-projection axis and the ToString-through-\
4421                 Display axis have drifted onto different emit-sets"
4422            );
4423        }
4424        let via_iter: Vec<String> = CaixaDialeto::ALL
4425            .iter()
4426            .copied()
4427            .map(String::from)
4428            .collect();
4429        let via_method: Vec<String> = CaixaDialeto::ALL
4430            .iter()
4431            .map(|d| d.as_str().to_owned())
4432            .collect();
4433        assert_eq!(
4434            via_iter, via_method,
4435            "`.iter().copied().map(String::from)` over CaixaDialeto::ALL \
4436             must byte-equal `.iter().map(|d| d.as_str().to_owned())` on \
4437             every arm — the owned-`String` `From<CaixaDialeto> for \
4438             String` axis is what makes the `String::from` composition \
4439             route through the substrate-primitive `CaixaDialeto::as_str` \
4440             accessor rather than through a per-call-site `.to_owned()` / \
4441             `String::from(dialeto.as_str())` detour"
4442        );
4443        for &variant in CaixaDialeto::ALL {
4444            let emitted: String = variant.into();
4445            let re_parsed: Result<CaixaDialeto, ()> =
4446                <CaixaDialeto as TryFrom<&str>>::try_from(emitted.as_str());
4447            assert_eq!(
4448                re_parsed,
4449                Ok(variant),
4450                "trait-idiomatic owned-`String` forward-projection + \
4451                 reverse-projection axis pair must round-trip \
4452                 CaixaDialeto::{variant:?} through `.into::<String>()` \
4453                 and back through `TryFrom<&str>` on the owned-`String`'s \
4454                 String::as_str borrow — a break signals the owned-\
4455                 `String` forward-emit and reverse-parse axes have \
4456                 drifted onto different vocabularies (unlike the peer \
4457                 CaixaKind axis pair, CaixaDialeto's forward emit and \
4458                 reverse parse share one PascalCase vocabulary by \
4459                 construction, so the round-trip composes directly)"
4460            );
4461        }
4462    }
4463
4464    #[test]
4465    fn caixa_dialeto_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
4466        // Fail-before-pass-after byte-parity pin on the newly lifted
4467        // `impl From<&CaixaDialeto> for String` — asserts the borrowed-
4468        // input owned-`String`-returning standard-library trait impl and
4469        // the substrate-primitive [`super::CaixaDialeto::as_str`]
4470        // `pub const fn` accessor resolve to the same four-arm emit-set
4471        // across every arm the exhaustive [`super::CaixaDialeto::ALL`]
4472        // slice enumerates. Rust's standard library does not carry a
4473        // blanket `impl<T: AsRef<str>> From<&T> for String` (nor an
4474        // `impl<T: fmt::Display> From<&T> for String`), so the
4475        // borrowed-input owned-`String` forward-projection axis is a
4476        // distinct trait-idiomatic surface that a
4477        // `let key: String = (&dialeto).into();`-shaped call site
4478        // reaches through this impl and no other — the paired sibling
4479        // `From<CaixaDialeto> for String` impl forces every borrowed-
4480        // input call site through an explicit `Copy` deref
4481        // (`String::from(*dialeto)`) or an `.as_str().to_owned()` /
4482        // `.to_string()` detour. Peer of the first-mover
4483        // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
4484        // (579385f), the second-peer
4485        // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
4486        // (8465740), the third-peer
4487        // [`crate::dep::tests::dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
4488        // (e0cb617), and the fourth-peer
4489        // [`crate::kind::tests::caixa_kind_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
4490        // (e76436d) — extends the trait-idiomatic borrowed-input owned-
4491        // `String` forward-projection axis onto the fourth closed-set
4492        // fieldless typed enum on the caixa surface (the dialect-
4493        // classification axis, second peer outside the M2 OTP-shape
4494        // sibling axis to reach the 2×2-completion corner).
4495        for &variant in CaixaDialeto::ALL {
4496            let via_trait: String = <String as From<&CaixaDialeto>>::from(&variant);
4497            let via_method: &'static str = variant.as_str();
4498            assert_eq!(
4499                via_trait.as_str(),
4500                via_method,
4501                "From<&CaixaDialeto> for String impl must round-trip \
4502                 &CaixaDialeto::{variant:?} to the same `PascalCase` \
4503                 arm-string CaixaDialeto::as_str returns — divergence \
4504                 signals a silent detour off the substrate-primitive \
4505                 accessor"
4506            );
4507            let via_into: String = (&variant).into();
4508            assert_eq!(
4509                via_into.as_str(),
4510                via_method,
4511                "Into<String>::into on &CaixaDialeto::{variant:?} must \
4512                 byte-equal CaixaDialeto::as_str on the same input — \
4513                 the blanket-derived Into shape must resolve to the \
4514                 same as_str dispatch as the explicit From impl"
4515            );
4516        }
4517    }
4518
4519    #[test]
4520    fn caixa_dialeto_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
4521        // Cross-axis partition pin: the newly lifted trait-idiomatic
4522        // borrowed-input owned-`String` `From<&CaixaDialeto> for String`
4523        // (this lift), the paired owned-input owned-`String`
4524        // `From<CaixaDialeto> for String` (88942cd), the paired
4525        // borrowed-input owned-`&'static str`
4526        // `From<&CaixaDialeto> for &'static str` (807b0b5), and the
4527        // paired owned-input owned-`&'static str`
4528        // `From<CaixaDialeto> for &'static str` (c189a6f) — every corner
4529        // of the `{Self, &Self} × {&'static str, String}` 2×2 trait-
4530        // idiomatic projection family — must resolve identically on
4531        // every arm, locking the four return-shape × input-shape paths
4532        // together so any future detour trips at caixa-core test time.
4533        // Also byte-parity witness against the sibling
4534        // [`ToString::to_string`] surface routed through
4535        // [`std::fmt::Display`] and a direct round-trip witness through
4536        // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
4537        // the owned-`String`'s [`String::as_str`] borrow that closes
4538        // the two-way `&Self → String → Self` round-trip on the trait-
4539        // idiomatic borrowed-input owned-`String` forward + reverse
4540        // axis pair. Peer of the first-mover
4541        // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
4542        // (579385f), the second-peer
4543        // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
4544        // (8465740), the third-peer
4545        // [`crate::dep::tests::dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
4546        // (e0cb617), and the fourth-peer
4547        // [`crate::kind::tests::caixa_kind_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
4548        // (e76436d) — closes the whole `{Self, &Self} × {&'static str,
4549        // String}` 2×2 projection corner on the fifth substrate-wide
4550        // closed-set fieldless typed enum peer (the dialect-
4551        // classification axis, second peer outside the M2 OTP-shape
4552        // sibling pair).
4553        //
4554        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
4555        // `From` emit lands on the lowercase Portuguese `as_str`
4556        // diagnostic vocabulary while the reverse `TryFrom<&str>`
4557        // parses the `PascalCase` `wire_name` author-surface vocabulary,
4558        // forcing the round-trip through an intermediate
4559        // [`crate::CaixaKind::wire_name`] hop), [`super::CaixaDialeto`]'s
4560        // [`super::CaixaDialeto::as_str`] emit and
4561        // [`super::CaixaDialeto::from_wire`] parse share the same
4562        // `PascalCase` vocabulary by construction (there is no
4563        // wire/diagnostic axis split on this enum), so the borrowed-
4564        // input owned-`String` forward axis and the reverse axis compose
4565        // directly — matching the peer
4566        // [`crate::supervisor::RestartStrategy`] /
4567        // [`crate::supervisor::RestartPolicy`] / [`crate::dep::DepList`]
4568        // borrowed-input owned-`String` axis pairs.
4569        for &dialeto in CaixaDialeto::ALL {
4570            let borrowed_string: String = <String as From<&CaixaDialeto>>::from(&dialeto);
4571            let owned_string: String = <String as From<CaixaDialeto>>::from(dialeto);
4572            let borrowed_static: &'static str =
4573                <&'static str as From<&CaixaDialeto>>::from(&dialeto);
4574            let owned_static: &'static str = <&'static str as From<CaixaDialeto>>::from(dialeto);
4575            assert_eq!(
4576                borrowed_string, owned_string,
4577                "From<&CaixaDialeto> for String and From<CaixaDialeto> \
4578                 for String must resolve identically on \
4579                 CaixaDialeto::{dialeto:?} — divergence signals the \
4580                 borrowed-input and owned-input owned-`String` forward-\
4581                 projection input-shape paths have drifted onto \
4582                 different emit-sets"
4583            );
4584            assert_eq!(
4585                borrowed_string.as_str(),
4586                borrowed_static,
4587                "From<&CaixaDialeto> for String and From<&CaixaDialeto> \
4588                 for &'static str must resolve identically on \
4589                 CaixaDialeto::{dialeto:?} — divergence signals the \
4590                 borrowed-input `&'static str` and owned-`String` \
4591                 return-shape paths have drifted onto different \
4592                 emit-sets"
4593            );
4594            assert_eq!(
4595                borrowed_string.as_str(),
4596                owned_static,
4597                "From<&CaixaDialeto> for String and From<CaixaDialeto> \
4598                 for &'static str must resolve identically on \
4599                 CaixaDialeto::{dialeto:?} — divergence signals a break \
4600                 in the diagonal corner of the {{Self, &Self}} × \
4601                 {{&'static str, String}} 2×2 trait-idiomatic \
4602                 projection family"
4603            );
4604            let via_to_string: String = dialeto.to_string();
4605            assert_eq!(
4606                borrowed_string, via_to_string,
4607                "From<&CaixaDialeto> for String must byte-equal \
4608                 CaixaDialeto::to_string on CaixaDialeto::{dialeto:?} — \
4609                 divergence signals the trait-idiomatic borrowed-input \
4610                 owned-`String` forward-projection axis and the \
4611                 ToString-through-Display axis have drifted onto \
4612                 different emit-sets"
4613            );
4614        }
4615        let via_iter: Vec<String> = CaixaDialeto::ALL.iter().map(String::from).collect();
4616        let via_method: Vec<String> = CaixaDialeto::ALL
4617            .iter()
4618            .map(|d| d.as_str().to_owned())
4619            .collect();
4620        assert_eq!(
4621            via_iter, via_method,
4622            "`.iter().map(String::from)` over CaixaDialeto::ALL — a \
4623             call site whose iteration axis holds `&CaixaDialeto` by \
4624             construction — must byte-equal `.iter().map(|d| \
4625             d.as_str().to_owned())` on every arm — the borrowed-input \
4626             owned-`String` `From<&CaixaDialeto> for String` axis is \
4627             what makes the `String::from` composition route through \
4628             the substrate-primitive `CaixaDialeto::as_str` accessor \
4629             without a spurious `Copy` deref (which would only be \
4630             reachable through the owned-input `From<CaixaDialeto> for \
4631             String` axis by first calling `.copied()` on the iterator)"
4632        );
4633        for &variant in CaixaDialeto::ALL {
4634            let emitted: String = (&variant).into();
4635            let re_parsed: Result<CaixaDialeto, ()> =
4636                <CaixaDialeto as TryFrom<&str>>::try_from(emitted.as_str());
4637            assert_eq!(
4638                re_parsed,
4639                Ok(variant),
4640                "trait-idiomatic borrowed-input owned-`String` \
4641                 forward-projection + reverse-projection axis pair \
4642                 must round-trip &CaixaDialeto::{variant:?} through \
4643                 `.into::<String>()` on the borrowed-input surface and \
4644                 back through `TryFrom<&str>` on the owned-`String`'s \
4645                 String::as_str borrow — a break signals the \
4646                 borrowed-input owned-`String` forward-emit and \
4647                 reverse-parse axes have drifted onto different \
4648                 vocabularies (unlike the peer CaixaKind axis pair, \
4649                 CaixaDialeto's forward emit and reverse parse share \
4650                 one PascalCase vocabulary by construction, so the \
4651                 round-trip composes directly)"
4652            );
4653        }
4654    }
4655
4656    #[test]
4657    fn caixa_dialeto_from_into_static_cow_str_routes_through_as_str_accessor() {
4658        // Fail-before-pass-after byte-parity pin on the newly lifted
4659        // `impl From<CaixaDialeto> for std::borrow::Cow<'static, str>`
4660        // — asserts the standard-library trait impl and the
4661        // substrate-primitive [`super::CaixaDialeto::as_str`]
4662        // `pub const fn` accessor resolve to the same four-arm
4663        // emit-set across every arm the exhaustive
4664        // [`super::CaixaDialeto::ALL`] slice enumerates. Rust's
4665        // standard library does not carry a blanket
4666        // `impl<T: AsRef<str>> From<T> for std::borrow::Cow<'static,
4667        // str>` (nor an `impl<T: fmt::Display> From<T> for
4668        // std::borrow::Cow<'static, str>`), so the
4669        // [`std::borrow::Cow<'static, str>`] forward-projection axis
4670        // is a distinct trait-idiomatic surface that a
4671        // `let key: std::borrow::Cow<'static, str> = dialeto.into();`-
4672        // shaped call site reaches through this impl and no other —
4673        // the paired sibling `From<CaixaDialeto> for &'static str`
4674        // and `From<CaixaDialeto> for String` impls force every
4675        // [`std::borrow::Cow<'static, str>`]-parameterized call site
4676        // through a `std::borrow::Cow::Borrowed(dialeto.as_str())` /
4677        // `std::borrow::Cow::Owned(dialeto.to_string())` /
4678        // `String::from(dialeto).into()` composition whose type
4679        // bounds have no compile-time link back to the substrate
4680        // primitive.
4681        //
4682        // Also asserts the projection lands on the zero-alloc
4683        // [`std::borrow::Cow::Borrowed`] arm (not the
4684        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
4685        // [`super::CaixaDialeto::as_str`] accessor's `&'static str`
4686        // return lifetime by construction makes the borrowed arm the
4687        // type-correct projection with no runtime allocation. Any
4688        // future silent detour that routes the impl through the
4689        // owned arm (an accidental
4690        // `std::borrow::Cow::Owned(dialeto.to_string())` rewrite that
4691        // would allocate on every call site where the `&'static str`
4692        // return of [`super::CaixaDialeto::as_str`] makes the
4693        // zero-alloc borrowed projection type-correct) trips at
4694        // caixa-core test time under the
4695        // [`std::borrow::Cow::Borrowed`] discriminator witness rather
4696        // than at a downstream
4697        // [`std::borrow::Cow<'static, str>`]-bound consumer's silent
4698        // allocation.
4699        //
4700        // Second peer on the outside-M3 caixa-core tier of the
4701        // substrate-wide trait-idiomatic
4702        // [`std::borrow::Cow<'static, str>`] forward-projection
4703        // family — extends the axis off the two-list dep-graph
4704        // [`crate::dep::DepList`] pair (6858bac / 702cdf4) that
4705        // opened + closed the tier onto the dialect-classification
4706        // [`super::CaixaDialeto`] enum (the sole remaining
4707        // internal-classification peer on the caixa-core surface).
4708        // Every future closed-set fieldless typed enum peer on the
4709        // substrate is a future target of the campaign.
4710        for &variant in CaixaDialeto::ALL {
4711            let via_trait: std::borrow::Cow<'static, str> =
4712                <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
4713            let via_method: &'static str = variant.as_str();
4714            assert_eq!(
4715                via_trait.as_ref(),
4716                via_method,
4717                "From<CaixaDialeto> for Cow<'static, str> impl must \
4718                 round-trip CaixaDialeto::{variant:?} to the same \
4719                 PascalCase byte-string CaixaDialeto::as_str returns \
4720                 — divergence signals a silent detour off the \
4721                 substrate-primitive accessor"
4722            );
4723            assert!(
4724                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
4725                "From<CaixaDialeto> for Cow<'static, str> impl must \
4726                 land on the zero-alloc Cow::Borrowed arm on \
4727                 CaixaDialeto::{variant:?} — a Cow::Owned outcome \
4728                 signals the projection has silently allocated where \
4729                 the substrate-primitive CaixaDialeto::as_str \
4730                 `&'static str` return makes the borrowed arm the \
4731                 type-correct projection"
4732            );
4733            let via_into: std::borrow::Cow<'static, str> = variant.into();
4734            assert_eq!(
4735                via_into.as_ref(),
4736                via_method,
4737                "Into<Cow<'static, str>>::into on \
4738                 CaixaDialeto::{variant:?} must byte-equal \
4739                 CaixaDialeto::as_str on the same input — the \
4740                 blanket-derived Into shape must resolve to the same \
4741                 as_str dispatch as the explicit From impl"
4742            );
4743            assert!(
4744                matches!(via_into, std::borrow::Cow::Borrowed(_)),
4745                "Into<Cow<'static, str>>::into on \
4746                 CaixaDialeto::{variant:?} must land on the zero-alloc \
4747                 Cow::Borrowed arm — the blanket-derived Into shape \
4748                 must resolve to the same Cow::Borrowed dispatch as \
4749                 the explicit From impl"
4750            );
4751        }
4752    }
4753
4754    #[test]
4755    fn caixa_dialeto_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
4756        // Cross-axis partition pin: the newly lifted trait-idiomatic
4757        // `From<CaixaDialeto> for std::borrow::Cow<'static, str>`
4758        // (this lift), the paired owned-input
4759        // `From<CaixaDialeto> for &'static str`, and the paired
4760        // owned-input `From<CaixaDialeto> for String` forward
4761        // projections must resolve identically on every arm, locking
4762        // the three return-shape paths together by construction so
4763        // any future detour trips at caixa-core test time. Also
4764        // byte-parity witness against the sibling
4765        // [`ToString::to_string`] surface routed through
4766        // [`std::fmt::Display`] — every owned-heap-string path (the
4767        // [`std::borrow::Cow::Owned`] promotion of this axis's
4768        // `.into_owned()`, `From<CaixaDialeto> for String`, and
4769        // `.to_string()`) resolves to the same PascalCase byte-string
4770        // per arm.
4771        //
4772        // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
4773        // witness over [`super::CaixaDialeto::ALL`] that materializes
4774        // the four-arm accept-set through the
4775        // [`std::borrow::Cow<'static, str>`] axis alone — the exact
4776        // shape a future `axum::response::IntoResponse` per-arm
4777        // rejection-body composer, a future M4
4778        // `mesh.pleme.io/v1alpha1/Manifesto` CR materializer's
4779        // admission-webhook per-arm rejection-reason emitter whose
4780        // typing rules out the sibling [`AsRef<str>`] borrowed
4781        // return, or a future substrate-wide per-arm diagnostic
4782        // surface that binds through a
4783        // [`std::borrow::Cow<'static, str>`] boundary reaches through
4784        // — closing the composable-projection axis on the dialect-
4785        // classification closed-set fieldless typed enum peer. The
4786        // pipe witness also pins the zero-alloc discipline: every
4787        // element in the collected vector satisfies the
4788        // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
4789        // accidental silent-allocation regression on the pipe's
4790        // iteration axis is a caixa-core-test-time failure.
4791        //
4792        // Then a direct round-trip witness through
4793        // [`TryFrom<&str>`] on the projection's
4794        // [`std::borrow::Cow::as_ref`] borrow — unlike the peer
4795        // [`crate::CaixaKind`] axis pair (whose forward emit lands
4796        // on the lowercase Portuguese diagnostic vocabulary while
4797        // the reverse parse lands on the `PascalCase` wire
4798        // vocabulary, forcing the round-trip through an intermediate
4799        // [`crate::CaixaKind::wire_name`] hop),
4800        // [`super::CaixaDialeto`]'s forward emit and reverse parse
4801        // share one `PascalCase` vocabulary by construction, so the
4802        // [`std::borrow::Cow<'static, str>`] projection composes
4803        // directly with the trait-idiomatic reverse [`TryFrom<&str>`]
4804        // axis without the wire-vocab intermediate hop.
4805        for &variant in CaixaDialeto::ALL {
4806            let via_cow: std::borrow::Cow<'static, str> =
4807                <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
4808            let via_static: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
4809            let via_string: String = <String as From<CaixaDialeto>>::from(variant);
4810            assert_eq!(
4811                via_cow.as_ref(),
4812                via_static,
4813                "From<CaixaDialeto> for Cow<'static, str> and \
4814                 From<CaixaDialeto> for &'static str must resolve \
4815                 identically on CaixaDialeto::{variant:?} — \
4816                 divergence signals the Cow<'static, str> and \
4817                 &'static str return-shape paths have drifted onto \
4818                 different emit-sets"
4819            );
4820            assert_eq!(
4821                via_cow.as_ref(),
4822                via_string.as_str(),
4823                "From<CaixaDialeto> for Cow<'static, str> and \
4824                 From<CaixaDialeto> for String must resolve \
4825                 identically on CaixaDialeto::{variant:?} — \
4826                 divergence signals the Cow<'static, str> and String \
4827                 return-shape paths have drifted onto different \
4828                 emit-sets"
4829            );
4830            let via_to_string: String = variant.to_string();
4831            assert_eq!(
4832                via_cow.as_ref(),
4833                via_to_string.as_str(),
4834                "From<CaixaDialeto> for Cow<'static, str> must \
4835                 byte-equal CaixaDialeto::to_string on \
4836                 CaixaDialeto::{variant:?} — divergence signals the \
4837                 trait-idiomatic Cow<'static, str> forward-projection \
4838                 axis and the ToString-through-Display axis have \
4839                 drifted onto different emit-sets"
4840            );
4841        }
4842        let via_iter: Vec<std::borrow::Cow<'static, str>> = CaixaDialeto::ALL
4843            .iter()
4844            .copied()
4845            .map(std::borrow::Cow::from)
4846            .collect();
4847        let via_method: Vec<std::borrow::Cow<'static, str>> = CaixaDialeto::ALL
4848            .iter()
4849            .map(|d| std::borrow::Cow::Borrowed(d.as_str()))
4850            .collect();
4851        assert_eq!(
4852            via_iter, via_method,
4853            "`.iter().copied().map(Cow::from)` over \
4854             CaixaDialeto::ALL must byte-equal `.iter().map(|d| \
4855             Cow::Borrowed(d.as_str()))` on every arm — the \
4856             trait-idiomatic `From<CaixaDialeto> for Cow<'static, \
4857             str>` axis is what makes the `Cow::from` composition \
4858             route through the substrate-primitive \
4859             CaixaDialeto::as_str accessor rather than a per-call-\
4860             site open-code"
4861        );
4862        for cow in &via_iter {
4863            assert!(
4864                matches!(cow, std::borrow::Cow::Borrowed(_)),
4865                "`.iter().copied().map(Cow::from)` over \
4866                 CaixaDialeto::ALL must land on the zero-alloc \
4867                 Cow::Borrowed arm on every element — a Cow::Owned \
4868                 outcome signals the pipe has silently allocated \
4869                 where the substrate-primitive \
4870                 CaixaDialeto::as_str `&'static str` return makes \
4871                 the borrowed arm the type-correct projection"
4872            );
4873        }
4874        for &variant in CaixaDialeto::ALL {
4875            let via_cow: std::borrow::Cow<'static, str> =
4876                <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
4877            let re_parsed: Result<CaixaDialeto, ()> =
4878                <CaixaDialeto as TryFrom<&str>>::try_from(via_cow.as_ref());
4879            assert_eq!(
4880                re_parsed,
4881                Ok(variant),
4882                "trait-idiomatic Cow<'static, str> forward-projection \
4883                 + reverse-projection axis pair must round-trip \
4884                 CaixaDialeto::{variant:?} through `.into::<Cow<\
4885                 'static, str>>()` on the owned-input surface and \
4886                 back through `TryFrom<&str>` on the projection's \
4887                 Cow::as_ref borrow — a break signals the \
4888                 Cow<'static, str> forward-emit and reverse-parse \
4889                 axes have drifted onto different vocabularies \
4890                 (unlike the peer CaixaKind axis pair, CaixaDialeto's \
4891                 forward emit and reverse parse share one PascalCase \
4892                 vocabulary by construction, so the round-trip \
4893                 composes directly)"
4894            );
4895        }
4896    }
4897
4898    #[test]
4899    fn caixa_dialeto_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
4900        // Fail-before-pass-after byte-parity pin on the newly lifted
4901        // `impl From<&CaixaDialeto> for std::borrow::Cow<'static,
4902        // str>` — asserts the borrowed-input standard-library trait
4903        // impl and the substrate-primitive
4904        // [`super::CaixaDialeto::as_str`] `pub const fn` accessor
4905        // resolve to the same four-arm PascalCase emit-set across
4906        // every arm the exhaustive [`super::CaixaDialeto::ALL`] slice
4907        // enumerates. Rust's standard library does not carry a blanket
4908        // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
4909        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
4910        // the borrowed-input `Cow<'static, str>` forward-projection
4911        // axis is a distinct trait-idiomatic surface that a
4912        // `let key: Cow<'static, str> = (&dialeto).into();`-shaped
4913        // call site or a `CaixaDialeto::ALL.iter().map(Cow::from)`-
4914        // shaped pipe reaches through this impl and no other — the
4915        // paired owned-input `From<CaixaDialeto> for Cow<'static, str>`
4916        // impl (8322511) forces every borrowed-input call site
4917        // through an explicit `Copy` deref (`Cow::from(*dialeto)`) or
4918        // a `Cow::Borrowed(dialeto.as_str())` open-code whose type
4919        // bounds have no compile-time link back to the substrate
4920        // primitive.
4921        //
4922        // Also asserts the projection lands on the zero-alloc
4923        // [`std::borrow::Cow::Borrowed`] arm (not the
4924        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
4925        // [`super::CaixaDialeto::as_str`] accessor's `&'static str`
4926        // return lifetime by construction makes the borrowed arm the
4927        // type-correct projection with no runtime allocation on the
4928        // borrowed-input surface just as on the paired owned-input
4929        // surface.
4930        //
4931        // Closes the `{Self, &Self}` input-shape corner on the
4932        // outside-M3 caixa-core dialect-classification
4933        // [`Cow<'static, str>`] axis on the second outside-M3
4934        // caixa-core closed-set fieldless typed enum peer on the
4935        // caixa surface, exactly as 702cdf4 closed it on the first
4936        // outside-M3 caixa-core peer ([`crate::dep::DepList`]) one
4937        // commit after the owning half (6858bac) landed, as afdf0f4
4938        // closed it on the second M3-mesh-primitive peer
4939        // ([`crate::aplicacao::PlacementStrategy`]) one commit after
4940        // the owning half (eee504d) landed, as 25690ef closed it on
4941        // the first M3-mesh-primitive peer
4942        // ([`crate::aplicacao::WitShape`]) one commit after the
4943        // owning half (8634dec) landed, as d45c409 closed it on the
4944        // top-level [`crate::CaixaKind`] one commit after the owning
4945        // half (99c1735) landed, and as 9b3e4b3 / ee577fd closed it
4946        // on the M2 OTP-shape [`crate::supervisor::RestartStrategy`]
4947        // / [`crate::supervisor::RestartPolicy`] sibling peers one
4948        // commit after (7dd28b3 / 0612398) landed.
4949        for &variant in CaixaDialeto::ALL {
4950            let via_trait: std::borrow::Cow<'static, str> =
4951                <std::borrow::Cow<'static, str> as From<&CaixaDialeto>>::from(&variant);
4952            let via_method: &'static str = variant.as_str();
4953            assert_eq!(
4954                via_trait.as_ref(),
4955                via_method,
4956                "From<&CaixaDialeto> for Cow<'static, str> impl must \
4957                 round-trip &CaixaDialeto::{variant:?} to the same \
4958                 PascalCase byte-string CaixaDialeto::as_str returns \
4959                 — divergence signals a silent detour off the \
4960                 substrate-primitive accessor"
4961            );
4962            assert!(
4963                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
4964                "From<&CaixaDialeto> for Cow<'static, str> impl must \
4965                 land on the zero-alloc Cow::Borrowed arm on \
4966                 &CaixaDialeto::{variant:?} — a Cow::Owned outcome \
4967                 signals the projection has silently allocated where \
4968                 the substrate-primitive CaixaDialeto::as_str \
4969                 `&'static str` return makes the borrowed arm the \
4970                 type-correct projection"
4971            );
4972            let via_into: std::borrow::Cow<'static, str> = (&variant).into();
4973            assert_eq!(
4974                via_into.as_ref(),
4975                via_method,
4976                "Into<Cow<'static, str>>::into on \
4977                 &CaixaDialeto::{variant:?} must byte-equal \
4978                 CaixaDialeto::as_str on the same input — the \
4979                 blanket-derived Into shape on the borrowed-input \
4980                 surface must resolve to the same as_str dispatch as \
4981                 the explicit From impl"
4982            );
4983            assert!(
4984                matches!(via_into, std::borrow::Cow::Borrowed(_)),
4985                "Into<Cow<'static, str>>::into on \
4986                 &CaixaDialeto::{variant:?} must land on the \
4987                 zero-alloc Cow::Borrowed arm — the blanket-derived \
4988                 Into shape on the borrowed-input surface must \
4989                 resolve to the same Cow::Borrowed dispatch as the \
4990                 explicit From impl"
4991            );
4992        }
4993    }
4994
4995    #[test]
4996    #[allow(
4997        clippy::too_many_lines,
4998        reason = "cross-axis partition pin folds four return-shape paths \
4999                  (borrowed-input Cow<'static, str>, owned-input Cow<'static, str>, \
5000                  borrowed-input &'static str, borrowed-input String) plus the \
5001                  ToString-through-Display witness plus a `.iter().map(Cow::from)` \
5002                  pipe witness with zero-alloc discriminator plus a direct \
5003                  round-trip witness through TryFrom<&str> over four typed \
5004                  variants; the linear per-axis repetition is exactly what the \
5005                  fold is pinning — a helper would hide the shape it locks"
5006    )]
5007    fn caixa_dialeto_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
5008        // Cross-axis partition pin: the newly lifted trait-idiomatic
5009        // borrowed-input `From<&CaixaDialeto> for
5010        // std::borrow::Cow<'static, str>` (this lift), the paired
5011        // owned-input `From<CaixaDialeto> for
5012        // std::borrow::Cow<'static, str>`, the paired borrowed-input
5013        // `From<&CaixaDialeto> for &'static str`, and the paired
5014        // borrowed-input `From<&CaixaDialeto> for String` forward
5015        // projections must resolve identically on every arm, locking
5016        // the four return-shape paths together by construction so any
5017        // future detour trips at caixa-core test time. Also
5018        // byte-parity witness against the sibling
5019        // [`ToString::to_string`] surface routed through
5020        // [`std::fmt::Display`].
5021        //
5022        // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
5023        // over [`super::CaixaDialeto::ALL`] — whose iterator yields
5024        // `&CaixaDialeto` by construction, so the borrowed-input
5025        // [`std::borrow::Cow<'static, str>`] axis is what routes the
5026        // pipe through the substrate-primitive
5027        // [`super::CaixaDialeto::as_str`] accessor with the zero-alloc
5028        // [`std::borrow::Cow::Borrowed`] arm and without a spurious
5029        // [`Copy`] deref. Every collected element satisfies the
5030        // [`std::borrow::Cow::Borrowed`]-arm predicate so a future
5031        // accidental silent-allocation regression on the pipe's
5032        // iteration axis is a caixa-core-test-time failure.
5033        //
5034        // Then a direct round-trip witness through [`TryFrom<&str>`]
5035        // on the projection's [`std::borrow::Cow::as_ref`] borrow —
5036        // unlike the peer [`crate::CaixaKind`] axis pair (whose
5037        // forward emit lands on the lowercase Portuguese diagnostic
5038        // vocabulary while the reverse parse lands on the
5039        // `PascalCase` wire vocabulary, forcing the round-trip
5040        // through an intermediate [`crate::CaixaKind::wire_name`]
5041        // hop), [`super::CaixaDialeto`]'s forward emit and reverse
5042        // parse share one `PascalCase` vocabulary by construction, so
5043        // the borrowed-input [`std::borrow::Cow<'static, str>`]
5044        // projection composes directly with the trait-idiomatic
5045        // reverse [`TryFrom<&str>`] axis without the wire-vocab
5046        // intermediate hop.
5047        for &variant in CaixaDialeto::ALL {
5048            let via_borrowed_cow: std::borrow::Cow<'static, str> =
5049                <std::borrow::Cow<'static, str> as From<&CaixaDialeto>>::from(&variant);
5050            let via_owned_cow: std::borrow::Cow<'static, str> =
5051                <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
5052            let via_borrowed_static: &'static str =
5053                <&'static str as From<&CaixaDialeto>>::from(&variant);
5054            let via_borrowed_string: String = <String as From<&CaixaDialeto>>::from(&variant);
5055            assert_eq!(
5056                via_borrowed_cow.as_ref(),
5057                via_owned_cow.as_ref(),
5058                "From<&CaixaDialeto> for Cow<'static, str> and \
5059                 From<CaixaDialeto> for Cow<'static, str> must \
5060                 resolve identically on CaixaDialeto::{variant:?} — \
5061                 divergence signals the borrowed-input and \
5062                 owned-input Cow<'static, str> return-shape paths \
5063                 have drifted onto different emit-sets"
5064            );
5065            assert_eq!(
5066                via_borrowed_cow.as_ref(),
5067                via_borrowed_static,
5068                "From<&CaixaDialeto> for Cow<'static, str> and \
5069                 From<&CaixaDialeto> for &'static str must resolve \
5070                 identically on CaixaDialeto::{variant:?} — \
5071                 divergence signals the borrowed-input Cow<'static, \
5072                 str> and borrowed-input &'static str return-shape \
5073                 paths have drifted onto different emit-sets"
5074            );
5075            assert_eq!(
5076                via_borrowed_cow.as_ref(),
5077                via_borrowed_string.as_str(),
5078                "From<&CaixaDialeto> for Cow<'static, str> and \
5079                 From<&CaixaDialeto> for String must resolve \
5080                 identically on CaixaDialeto::{variant:?} — \
5081                 divergence signals the borrowed-input Cow<'static, \
5082                 str> and borrowed-input String return-shape paths \
5083                 have drifted onto different emit-sets"
5084            );
5085            let via_to_string: String = variant.to_string();
5086            assert_eq!(
5087                via_borrowed_cow.as_ref(),
5088                via_to_string.as_str(),
5089                "From<&CaixaDialeto> for Cow<'static, str> must \
5090                 byte-equal CaixaDialeto::to_string on \
5091                 CaixaDialeto::{variant:?} — divergence signals the \
5092                 borrowed-input Cow<'static, str> forward-projection \
5093                 axis and the ToString-through-Display axis have \
5094                 drifted onto different emit-sets"
5095            );
5096        }
5097        let via_iter: Vec<std::borrow::Cow<'static, str>> = CaixaDialeto::ALL
5098            .iter()
5099            .map(std::borrow::Cow::from)
5100            .collect();
5101        let via_method: Vec<std::borrow::Cow<'static, str>> = CaixaDialeto::ALL
5102            .iter()
5103            .map(|d| std::borrow::Cow::Borrowed(d.as_str()))
5104            .collect();
5105        assert_eq!(
5106            via_iter, via_method,
5107            "`.iter().map(Cow::from)` over CaixaDialeto::ALL must \
5108             byte-equal `.iter().map(|d| Cow::Borrowed(d.as_str()))` \
5109             on every arm — the trait-idiomatic `From<&CaixaDialeto> \
5110             for Cow<'static, str>` axis is what makes the \
5111             `Cow::from` composition on the borrowed-iteration axis \
5112             route through the substrate-primitive \
5113             CaixaDialeto::as_str accessor without a spurious Copy \
5114             deref"
5115        );
5116        for cow in &via_iter {
5117            assert!(
5118                matches!(cow, std::borrow::Cow::Borrowed(_)),
5119                "`.iter().map(Cow::from)` over CaixaDialeto::ALL \
5120                 must land on the zero-alloc Cow::Borrowed arm on \
5121                 every element — a Cow::Owned outcome signals the \
5122                 borrowed-iteration pipe has silently allocated \
5123                 where the substrate-primitive CaixaDialeto::as_str \
5124                 `&'static str` return makes the borrowed arm the \
5125                 type-correct projection"
5126            );
5127        }
5128        for &variant in CaixaDialeto::ALL {
5129            let via_cow: std::borrow::Cow<'static, str> =
5130                <std::borrow::Cow<'static, str> as From<&CaixaDialeto>>::from(&variant);
5131            let re_parsed: Result<CaixaDialeto, ()> =
5132                <CaixaDialeto as TryFrom<&str>>::try_from(via_cow.as_ref());
5133            assert_eq!(
5134                re_parsed,
5135                Ok(variant),
5136                "trait-idiomatic borrowed-input Cow<'static, str> \
5137                 forward-projection + reverse-projection axis pair \
5138                 must round-trip &CaixaDialeto::{variant:?} through \
5139                 `.into::<Cow<'static, str>>()` on the borrowed-input \
5140                 surface and back through `TryFrom<&str>` on the \
5141                 projection's Cow::as_ref borrow — a break signals \
5142                 the borrowed-input Cow<'static, str> forward-emit \
5143                 and reverse-parse axes have drifted onto different \
5144                 vocabularies (unlike the peer CaixaKind axis pair, \
5145                 CaixaDialeto's forward emit and reverse parse share \
5146                 one PascalCase vocabulary by construction, so the \
5147                 round-trip composes directly)"
5148            );
5149        }
5150    }
5151
5152    #[test]
5153    fn caixa_dialeto_from_into_box_str_routes_through_as_str_accessor() {
5154        // Fail-before-pass-after byte-parity pin on the newly lifted
5155        // `impl From<CaixaDialeto> for Box<str>` — asserts the owned-
5156        // input standard-library trait impl and the substrate-primitive
5157        // [`super::CaixaDialeto::as_str`] `pub const fn` accessor
5158        // resolve to the same four-arm PascalCase emit-set across every
5159        // arm the exhaustive [`super::CaixaDialeto::ALL`] slice
5160        // enumerates. Extends the caixa-core-internal tier of the
5161        // substrate-wide [`Box<str>`] forward-projection campaign onto
5162        // the third caixa-core-internal peer, after the render-side
5163        // path-shape-diagnostic
5164        // [`super::super::render::PathShapeViolation`] pair (0d87a72,
5165        // both corners in one axis) opened the tier and the outside-M3
5166        // caixa-core two-list dep-graph [`super::super::dep::DepList`]
5167        // pair (4aada99, both corners in one axis) extended it. Rust's
5168        // standard library carries `impl From<&str> for Box<str>` and
5169        // `impl From<String> for Box<str>` but no blanket
5170        // `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a
5171        // distinct trait-idiomatic surface that a
5172        // `let key: Box<str> = dialeto.into();`-shaped call site reaches
5173        // through this impl and no other — a paired
5174        // `Box::from(dialeto.as_str())` open-code has no compile-time
5175        // link back to the substrate primitive.
5176        for &variant in CaixaDialeto::ALL {
5177            let via_trait: Box<str> = <Box<str> as From<CaixaDialeto>>::from(variant);
5178            let via_method: &'static str = variant.as_str();
5179            assert_eq!(
5180                via_trait.as_ref(),
5181                via_method,
5182                "From<CaixaDialeto> for Box<str> impl must round-trip \
5183                 CaixaDialeto::{variant:?} to the same PascalCase \
5184                 byte-string CaixaDialeto::as_str returns — divergence \
5185                 signals a silent detour off the substrate-primitive \
5186                 accessor"
5187            );
5188            let via_into: Box<str> = variant.into();
5189            assert_eq!(
5190                via_into.as_ref(),
5191                via_method,
5192                "Into<Box<str>>::into on CaixaDialeto::{variant:?} must \
5193                 byte-equal CaixaDialeto::as_str on the same input — \
5194                 the blanket-derived Into shape must resolve to the \
5195                 same as_str dispatch as the explicit From impl"
5196            );
5197        }
5198    }
5199
5200    #[test]
5201    fn caixa_dialeto_from_borrowed_into_box_str_routes_through_as_str_accessor() {
5202        // Fail-before-pass-after byte-parity pin on the newly lifted
5203        // `impl From<&CaixaDialeto> for Box<str>` — asserts the
5204        // borrowed-input standard-library trait impl and the substrate-
5205        // primitive [`super::CaixaDialeto::as_str`] `pub const fn`
5206        // accessor resolve to the same four-arm PascalCase emit-set
5207        // across every arm the exhaustive [`super::CaixaDialeto::ALL`]
5208        // slice enumerates. Rust's standard library carries
5209        // `impl From<&str> for Box<str>` and `impl From<String> for
5210        // Box<str>` but no blanket
5211        // `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-
5212        // based `impl<T: Copy, U: From<T>> From<&T> for U`), so the
5213        // borrowed-input [`Box<str>`] forward-projection axis is a
5214        // distinct trait-idiomatic surface that a
5215        // `CaixaDialeto::ALL.iter().map(Box::<str>::from)`-shaped pipe
5216        // (whose iterator over `&'static [CaixaDialeto]` yields
5217        // `&CaixaDialeto` by construction) or a
5218        // `let key: Box<str> = (&dialeto).into();`-shaped call site
5219        // reaches through this impl and no other — the paired owned-
5220        // input `From<CaixaDialeto> for Box<str>` impl alone would
5221        // force every borrowed-input call site through an explicit
5222        // `Copy` deref (`Box::<str>::from(*dialeto)`) or a
5223        // `Box::<str>::from(dialeto.as_str())` open-code whose type
5224        // bounds have no compile-time link back to the substrate
5225        // primitive.
5226        //
5227        // Closes the `{Self, &Self}` input-shape corner on the third
5228        // caixa-core-internal closed-set fieldless typed enum peer of
5229        // the substrate-wide [`Box<str>`] forward-projection campaign,
5230        // matching the trajectory the paired render-side path-shape-
5231        // diagnostic [`super::super::render::PathShapeViolation`] pair
5232        // (0d87a72, both corners in one axis) and the paired outside-M3
5233        // caixa-core two-list dep-graph [`super::super::dep::DepList`]
5234        // pair (4aada99, both corners in one axis) walked before it.
5235        for &variant in CaixaDialeto::ALL {
5236            let via_trait: Box<str> = <Box<str> as From<&CaixaDialeto>>::from(&variant);
5237            let via_method: &'static str = variant.as_str();
5238            assert_eq!(
5239                via_trait.as_ref(),
5240                via_method,
5241                "From<&CaixaDialeto> for Box<str> impl must round-trip \
5242                 &CaixaDialeto::{variant:?} to the same PascalCase \
5243                 byte-string CaixaDialeto::as_str returns — divergence \
5244                 signals a silent detour off the substrate-primitive \
5245                 accessor"
5246            );
5247            let via_into: Box<str> = (&variant).into();
5248            assert_eq!(
5249                via_into.as_ref(),
5250                via_method,
5251                "Into<Box<str>>::into on &CaixaDialeto::{variant:?} \
5252                 must byte-equal CaixaDialeto::as_str on the same \
5253                 input — the blanket-derived Into shape on the \
5254                 borrowed-input surface must resolve to the same \
5255                 as_str dispatch as the explicit From impl"
5256            );
5257        }
5258
5259        // Pipe witness — the distinguishing shape that forces the
5260        // borrowed-input axis to be independent of the owned-input
5261        // peer. `CaixaDialeto::ALL.iter()` yields `&CaixaDialeto` by
5262        // construction, so `.map(Box::<str>::from)` resolves through
5263        // the borrowed-input `From<&CaixaDialeto> for Box<str>` impl
5264        // and no other — without this axis, the same pipe would force
5265        // an explicit `.copied()` restatement whose type bounds bypass
5266        // the substrate primitive.
5267        let via_pipe: Vec<Box<str>> = CaixaDialeto::ALL.iter().map(Box::<str>::from).collect();
5268        let via_accessor: Vec<&'static str> =
5269            CaixaDialeto::ALL.iter().map(|d| d.as_str()).collect();
5270        assert_eq!(
5271            via_pipe.len(),
5272            via_accessor.len(),
5273            "CaixaDialeto::ALL.iter().map(Box::<str>::from) pipe must \
5274             preserve arity against the paired CaixaDialeto::as_str \
5275             accessor — a length divergence signals the borrowed-input \
5276             axis has silently rejected an arm"
5277        );
5278        for (pipe_arm, accessor_arm) in via_pipe.iter().zip(via_accessor.iter()) {
5279            assert_eq!(
5280                pipe_arm.as_ref(),
5281                *accessor_arm,
5282                "CaixaDialeto::ALL.iter().map(Box::<str>::from) pipe \
5283                 must byte-equal the paired \
5284                 CaixaDialeto::ALL.iter().map(|d| d.as_str()) pipe on \
5285                 every arm — divergence signals the borrowed-input \
5286                 `From<&CaixaDialeto> for Box<str>` axis has silently \
5287                 detoured off the substrate-primitive accessor"
5288            );
5289        }
5290    }
5291
5292    #[test]
5293    fn caixa_dialeto_from_into_arc_str_routes_through_as_str_accessor() {
5294        // Fail-before-pass-after byte-parity pin on the newly lifted
5295        // `impl From<CaixaDialeto> for std::sync::Arc<str>` — asserts the
5296        // owned-input standard-library trait impl and the substrate-
5297        // primitive [`super::CaixaDialeto::as_str`] `pub const fn` accessor
5298        // resolve to the same four-arm PascalCase emit-set across every
5299        // arm the exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
5300        // Extends the caixa-core-internal tier of the substrate-wide
5301        // [`std::sync::Arc<str>`] forward-projection campaign onto the
5302        // third caixa-core-internal peer, after the structurally most
5303        // fundamental [`super::super::CaixaKind`] pair (c17be64, both
5304        // corners in one axis) opened the tier and the outside-M3 two-list
5305        // dep-graph [`super::super::dep::DepList`] pair (d8a4652, both
5306        // corners in one axis) extended it. Rust's standard library
5307        // carries `impl From<&str> for std::sync::Arc<str>` and
5308        // `impl From<String> for std::sync::Arc<str>` but no blanket
5309        // `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
5310        // `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so
5311        // this axis is a distinct trait-idiomatic surface that a
5312        // `let key: std::sync::Arc<str> = dialeto.into();`-shaped call
5313        // site reaches through this impl and no other — a paired
5314        // `std::sync::Arc::<str>::from(dialeto.as_str())` open-code has no
5315        // compile-time link back to the substrate primitive, and a two-
5316        // step `std::sync::Arc::<str>::from(String::from(dialeto))`
5317        // composition through the owned-`String` axis allocates twice
5318        // where the single-step trait impl allocates once.
5319        //
5320        // Cross-axis byte-parity witness against the sibling owned-input
5321        // `{&'static str, String, Cow<'static, str>, Box<str>}` return-
5322        // shape axes — locking the five return-shape paths on the owned-
5323        // input surface together by construction so any future detour off
5324        // the substrate-primitive [`super::CaixaDialeto::as_str`] accessor
5325        // trips at caixa-core test time.
5326        for &variant in CaixaDialeto::ALL {
5327            let via_trait: std::sync::Arc<str> =
5328                <std::sync::Arc<str> as From<CaixaDialeto>>::from(variant);
5329            let via_method: &'static str = variant.as_str();
5330            assert_eq!(
5331                via_trait.as_ref(),
5332                via_method,
5333                "From<CaixaDialeto> for std::sync::Arc<str> impl must \
5334                 round-trip CaixaDialeto::{variant:?} to the same \
5335                 PascalCase byte-string CaixaDialeto::as_str returns — \
5336                 divergence signals a silent detour off the substrate-\
5337                 primitive accessor"
5338            );
5339            let via_into: std::sync::Arc<str> = variant.into();
5340            assert_eq!(
5341                via_into.as_ref(),
5342                via_method,
5343                "Into<std::sync::Arc<str>>::into on CaixaDialeto::\
5344                 {variant:?} must byte-equal CaixaDialeto::as_str on the \
5345                 same input — the blanket-derived Into shape must resolve \
5346                 to the same as_str dispatch as the explicit From impl"
5347            );
5348            let owned_static: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
5349            assert_eq!(
5350                via_trait.as_ref(),
5351                owned_static,
5352                "From<CaixaDialeto> for std::sync::Arc<str> and \
5353                 From<CaixaDialeto> for &'static str must resolve \
5354                 identically on CaixaDialeto::{variant:?} — divergence \
5355                 signals the owned-input std::sync::Arc<str> and \
5356                 &'static str return-shape paths have drifted onto \
5357                 different emit-sets"
5358            );
5359            let owned_string: String = <String as From<CaixaDialeto>>::from(variant);
5360            assert_eq!(
5361                via_trait.as_ref(),
5362                owned_string.as_str(),
5363                "From<CaixaDialeto> for std::sync::Arc<str> and \
5364                 From<CaixaDialeto> for String must resolve identically \
5365                 on CaixaDialeto::{variant:?} — divergence signals the \
5366                 owned-input std::sync::Arc<str> and owned-`String` \
5367                 return-shape paths have drifted onto different emit-sets"
5368            );
5369            let owned_cow: std::borrow::Cow<'static, str> =
5370                <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
5371            assert_eq!(
5372                via_trait.as_ref(),
5373                owned_cow.as_ref(),
5374                "From<CaixaDialeto> for std::sync::Arc<str> and \
5375                 From<CaixaDialeto> for Cow<'static, str> must resolve \
5376                 identically on CaixaDialeto::{variant:?} — divergence \
5377                 signals the owned-input std::sync::Arc<str> and \
5378                 Cow<'static, str> return-shape paths have drifted onto \
5379                 different emit-sets"
5380            );
5381            let owned_box: Box<str> = <Box<str> as From<CaixaDialeto>>::from(variant);
5382            assert_eq!(
5383                via_trait.as_ref(),
5384                owned_box.as_ref(),
5385                "From<CaixaDialeto> for std::sync::Arc<str> and \
5386                 From<CaixaDialeto> for Box<str> must resolve identically \
5387                 on CaixaDialeto::{variant:?} — divergence signals the \
5388                 owned-input std::sync::Arc<str> and Box<str> return-\
5389                 shape paths have drifted onto different emit-sets"
5390            );
5391        }
5392    }
5393
5394    #[test]
5395    #[allow(
5396        clippy::too_many_lines,
5397        reason = "cross-axis partition pin folds four borrowed-input \
5398                  return-shape paths (&'static str, String, Cow<'static, \
5399                  str>, Box<str>) plus the paired owned-input Arc<str> \
5400                  witness and the .iter().map(std::sync::Arc::<str>::from) \
5401                  pipe witness into one exhaustive round-trip over \
5402                  CaixaDialeto::ALL — the accepted line-count cost of \
5403                  keying the whole borrowed-input Arc<str> corner to the \
5404                  substrate-primitive as_str accessor at the same test-site"
5405    )]
5406    fn caixa_dialeto_from_borrowed_into_arc_str_routes_through_as_str_accessor() {
5407        // Fail-before-pass-after byte-parity pin on the newly lifted
5408        // `impl From<&CaixaDialeto> for std::sync::Arc<str>` — asserts the
5409        // borrowed-input standard-library trait impl and the substrate-
5410        // primitive [`super::CaixaDialeto::as_str`] `pub const fn` accessor
5411        // resolve to the same four-arm PascalCase emit-set across every
5412        // arm the exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
5413        // Rust's standard library does not carry a blanket
5414        // `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a
5415        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
5416        // the borrowed-input `std::sync::Arc<str>` forward-projection axis
5417        // is a distinct trait-idiomatic surface that a
5418        // `let key: std::sync::Arc<str> = (&dialeto).into();`-shaped call
5419        // site or a
5420        // `CaixaDialeto::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped
5421        // pipe reaches through this impl and no other — the paired owned-
5422        // input `From<CaixaDialeto> for std::sync::Arc<str>` impl alone
5423        // forces every borrowed-input call site through a spurious `Copy`
5424        // deref (`std::sync::Arc::<str>::from((*dialeto).as_str())`) or a
5425        // `.copied()` restatement whose type bounds have no compile-time
5426        // link back to the substrate primitive.
5427        //
5428        // Closes the `{Self, &Self}` input-shape corner on the caixa-
5429        // core-internal tier of the substrate-wide trait-idiomatic
5430        // [`std::sync::Arc<str>`] forward-projection campaign for the
5431        // third caixa-core-internal enum peer, matching the
5432        // `{Self, &Self} × {&'static str, String, Cow<'static, str>,
5433        // Box<str>}` 2×4 forward-projection matrix the peer projection
5434        // surfaces already close on this same enum.
5435        //
5436        // Cross-axis partition pin against the paired owned-input
5437        // [`From<CaixaDialeto> for std::sync::Arc<str>`] and the sibling
5438        // borrowed-input `{&'static str, String, Cow<'static, str>,
5439        // Box<str>}` return-shape axes — locking the five return-shape ×
5440        // input-shape paths on the borrowed-input surface together by
5441        // construction so any future detour off the substrate-primitive
5442        // accessor trips at caixa-core test time. Then a
5443        // `.iter().map(std::sync::Arc::<str>::from)` pipe witness over
5444        // [`super::CaixaDialeto::ALL`] — whose iterator yields
5445        // `&CaixaDialeto` by construction, so the borrowed-input
5446        // [`std::sync::Arc<str>`] axis is what routes the pipe through the
5447        // substrate-primitive [`super::CaixaDialeto::as_str`] accessor
5448        // without a spurious [`Copy`] deref (which would only be reachable
5449        // through the owned-input
5450        // [`From<CaixaDialeto> for std::sync::Arc<str>`] axis by first
5451        // calling `.copied()` on the iterator).
5452        for &variant in CaixaDialeto::ALL {
5453            let via_trait: std::sync::Arc<str> =
5454                <std::sync::Arc<str> as From<&CaixaDialeto>>::from(&variant);
5455            let via_method: &'static str = variant.as_str();
5456            assert_eq!(
5457                via_trait.as_ref(),
5458                via_method,
5459                "From<&CaixaDialeto> for std::sync::Arc<str> impl must \
5460                 round-trip &CaixaDialeto::{variant:?} to the same \
5461                 PascalCase byte-string CaixaDialeto::as_str returns — \
5462                 divergence signals a silent detour off the substrate-\
5463                 primitive accessor"
5464            );
5465            let via_into: std::sync::Arc<str> = (&variant).into();
5466            assert_eq!(
5467                via_into.as_ref(),
5468                via_method,
5469                "Into<std::sync::Arc<str>>::into on &CaixaDialeto::\
5470                 {variant:?} must byte-equal CaixaDialeto::as_str on the \
5471                 same input — the blanket-derived Into shape on the \
5472                 borrowed-input surface must resolve to the same as_str \
5473                 dispatch as the explicit From impl"
5474            );
5475            let owned_arc: std::sync::Arc<str> =
5476                <std::sync::Arc<str> as From<CaixaDialeto>>::from(variant);
5477            assert_eq!(
5478                via_trait, owned_arc,
5479                "From<&CaixaDialeto> for std::sync::Arc<str> and \
5480                 From<CaixaDialeto> for std::sync::Arc<str> must resolve \
5481                 identically on CaixaDialeto::{variant:?} — divergence \
5482                 signals the borrowed-input and owned-input \
5483                 std::sync::Arc<str> forward-projection input-shape paths \
5484                 have drifted onto different emit-sets"
5485            );
5486            let borrowed_static: &'static str =
5487                <&'static str as From<&CaixaDialeto>>::from(&variant);
5488            assert_eq!(
5489                via_trait.as_ref(),
5490                borrowed_static,
5491                "From<&CaixaDialeto> for std::sync::Arc<str> and \
5492                 From<&CaixaDialeto> for &'static str must resolve \
5493                 identically on CaixaDialeto::{variant:?} — divergence \
5494                 signals the borrowed-input std::sync::Arc<str> and \
5495                 &'static str return-shape paths have drifted onto \
5496                 different emit-sets"
5497            );
5498            let borrowed_string: String = <String as From<&CaixaDialeto>>::from(&variant);
5499            assert_eq!(
5500                via_trait.as_ref(),
5501                borrowed_string.as_str(),
5502                "From<&CaixaDialeto> for std::sync::Arc<str> and \
5503                 From<&CaixaDialeto> for String must resolve identically \
5504                 on CaixaDialeto::{variant:?} — divergence signals the \
5505                 borrowed-input std::sync::Arc<str> and owned-`String` \
5506                 return-shape paths have drifted onto different emit-sets"
5507            );
5508            let borrowed_cow: std::borrow::Cow<'static, str> =
5509                <std::borrow::Cow<'static, str> as From<&CaixaDialeto>>::from(&variant);
5510            assert_eq!(
5511                via_trait.as_ref(),
5512                borrowed_cow.as_ref(),
5513                "From<&CaixaDialeto> for std::sync::Arc<str> and \
5514                 From<&CaixaDialeto> for Cow<'static, str> must resolve \
5515                 identically on CaixaDialeto::{variant:?} — divergence \
5516                 signals the borrowed-input std::sync::Arc<str> and \
5517                 Cow<'static, str> return-shape paths have drifted onto \
5518                 different emit-sets"
5519            );
5520            let borrowed_box: Box<str> = <Box<str> as From<&CaixaDialeto>>::from(&variant);
5521            assert_eq!(
5522                via_trait.as_ref(),
5523                borrowed_box.as_ref(),
5524                "From<&CaixaDialeto> for std::sync::Arc<str> and \
5525                 From<&CaixaDialeto> for Box<str> must resolve \
5526                 identically on CaixaDialeto::{variant:?} — divergence \
5527                 signals the borrowed-input std::sync::Arc<str> and \
5528                 Box<str> return-shape paths have drifted onto different \
5529                 emit-sets"
5530            );
5531        }
5532        let via_iter: Vec<std::sync::Arc<str>> = CaixaDialeto::ALL
5533            .iter()
5534            .map(std::sync::Arc::<str>::from)
5535            .collect();
5536        let via_method: Vec<std::sync::Arc<str>> = CaixaDialeto::ALL
5537            .iter()
5538            .map(|d| std::sync::Arc::<str>::from(d.as_str()))
5539            .collect();
5540        assert_eq!(
5541            via_iter, via_method,
5542            "`.iter().map(std::sync::Arc::<str>::from)` over \
5543             CaixaDialeto::ALL — a call site whose iteration axis holds \
5544             `&CaixaDialeto` by construction — must byte-equal \
5545             `.iter().map(|d| std::sync::Arc::<str>::from(d.as_str()))` \
5546             on every arm — the borrowed-input std::sync::Arc<str> \
5547             `From<&CaixaDialeto> for std::sync::Arc<str>` axis is what \
5548             makes the `std::sync::Arc::<str>::from` composition route \
5549             through the substrate-primitive `CaixaDialeto::as_str` \
5550             accessor without a spurious `Copy` deref (which would only \
5551             be reachable through the owned-input \
5552             `From<CaixaDialeto> for std::sync::Arc<str>` axis by first \
5553             calling `.copied()` on the iterator)"
5554        );
5555    }
5556
5557    #[test]
5558    fn caixa_dialeto_from_into_rc_str_routes_through_as_str_accessor() {
5559        // Fail-before-pass-after byte-parity pin on the newly lifted
5560        // `impl From<CaixaDialeto> for std::rc::Rc<str>` — asserts the
5561        // owned-input standard-library trait impl and the substrate-
5562        // primitive [`super::CaixaDialeto::as_str`] `pub const fn` accessor
5563        // resolve to the same four-arm PascalCase emit-set across every
5564        // arm the exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
5565        // Extends the caixa-core-internal tier of the substrate-wide
5566        // [`std::rc::Rc<str>`] forward-projection campaign onto the second
5567        // caixa-core-internal peer, after the structurally most
5568        // fundamental [`super::super::CaixaKind`] pair (4fdfa37, both
5569        // corners in one axis) opened the campaign. Rust's standard
5570        // library carries `impl From<&str> for std::rc::Rc<str>` and
5571        // `impl From<String> for std::rc::Rc<str>` but no blanket
5572        // `impl<T: AsRef<str>> From<T> for std::rc::Rc<str>` (nor an
5573        // `impl<T: fmt::Display> From<T> for std::rc::Rc<str>`), and — the
5574        // `std::sync::Arc<str>` and `std::rc::Rc<str>` trait tables are
5575        // disjoint — so this axis is a distinct trait-idiomatic surface
5576        // that a `let key: std::rc::Rc<str> = dialeto.into();`-shaped
5577        // call site reaches through this impl and no other.
5578        //
5579        // Cross-axis byte-parity witness against the sibling owned-input
5580        // `{&'static str, String, Cow<'static, str>, Box<str>,
5581        // std::sync::Arc<str>}` return-shape axes — locking the six
5582        // return-shape paths on the owned-input surface together by
5583        // construction so any future detour off the substrate-primitive
5584        // [`super::CaixaDialeto::as_str`] accessor trips at caixa-core
5585        // test time.
5586        for &variant in CaixaDialeto::ALL {
5587            let via_trait: std::rc::Rc<str> =
5588                <std::rc::Rc<str> as From<CaixaDialeto>>::from(variant);
5589            let via_method: &'static str = variant.as_str();
5590            assert_eq!(
5591                via_trait.as_ref(),
5592                via_method,
5593                "From<CaixaDialeto> for std::rc::Rc<str> impl must \
5594                 round-trip CaixaDialeto::{variant:?} to the same \
5595                 PascalCase byte-string CaixaDialeto::as_str returns — \
5596                 divergence signals a silent detour off the substrate-\
5597                 primitive accessor"
5598            );
5599            let via_into: std::rc::Rc<str> = variant.into();
5600            assert_eq!(
5601                via_into.as_ref(),
5602                via_method,
5603                "Into<std::rc::Rc<str>>::into on CaixaDialeto::\
5604                 {variant:?} must byte-equal CaixaDialeto::as_str on the \
5605                 same input — the blanket-derived Into shape must resolve \
5606                 to the same as_str dispatch as the explicit From impl"
5607            );
5608            let owned_static: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
5609            assert_eq!(
5610                via_trait.as_ref(),
5611                owned_static,
5612                "From<CaixaDialeto> for std::rc::Rc<str> and \
5613                 From<CaixaDialeto> for &'static str must resolve \
5614                 identically on CaixaDialeto::{variant:?} — divergence \
5615                 signals the owned-input std::rc::Rc<str> and \
5616                 &'static str return-shape paths have drifted onto \
5617                 different emit-sets"
5618            );
5619            let owned_string: String = <String as From<CaixaDialeto>>::from(variant);
5620            assert_eq!(
5621                via_trait.as_ref(),
5622                owned_string.as_str(),
5623                "From<CaixaDialeto> for std::rc::Rc<str> and \
5624                 From<CaixaDialeto> for String must resolve identically \
5625                 on CaixaDialeto::{variant:?} — divergence signals the \
5626                 owned-input std::rc::Rc<str> and owned-`String` \
5627                 return-shape paths have drifted onto different emit-sets"
5628            );
5629            let owned_cow: std::borrow::Cow<'static, str> =
5630                <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
5631            assert_eq!(
5632                via_trait.as_ref(),
5633                owned_cow.as_ref(),
5634                "From<CaixaDialeto> for std::rc::Rc<str> and \
5635                 From<CaixaDialeto> for Cow<'static, str> must resolve \
5636                 identically on CaixaDialeto::{variant:?} — divergence \
5637                 signals the owned-input std::rc::Rc<str> and \
5638                 Cow<'static, str> return-shape paths have drifted onto \
5639                 different emit-sets"
5640            );
5641            let owned_box: Box<str> = <Box<str> as From<CaixaDialeto>>::from(variant);
5642            assert_eq!(
5643                via_trait.as_ref(),
5644                owned_box.as_ref(),
5645                "From<CaixaDialeto> for std::rc::Rc<str> and \
5646                 From<CaixaDialeto> for Box<str> must resolve identically \
5647                 on CaixaDialeto::{variant:?} — divergence signals the \
5648                 owned-input std::rc::Rc<str> and Box<str> return-\
5649                 shape paths have drifted onto different emit-sets"
5650            );
5651            let owned_arc: std::sync::Arc<str> =
5652                <std::sync::Arc<str> as From<CaixaDialeto>>::from(variant);
5653            assert_eq!(
5654                via_trait.as_ref(),
5655                owned_arc.as_ref(),
5656                "From<CaixaDialeto> for std::rc::Rc<str> and \
5657                 From<CaixaDialeto> for std::sync::Arc<str> must resolve \
5658                 identically on CaixaDialeto::{variant:?} — divergence \
5659                 signals the owned-input std::rc::Rc<str> and \
5660                 std::sync::Arc<str> return-shape paths have drifted \
5661                 onto different emit-sets"
5662            );
5663        }
5664    }
5665
5666    #[test]
5667    #[allow(
5668        clippy::too_many_lines,
5669        reason = "cross-axis partition pin folds five borrowed-input \
5670                  return-shape paths (&'static str, String, Cow<'static, \
5671                  str>, Box<str>, std::sync::Arc<str>) plus the paired \
5672                  owned-input Rc<str> witness and the \
5673                  .iter().map(std::rc::Rc::<str>::from) pipe witness into \
5674                  one exhaustive round-trip over CaixaDialeto::ALL — the \
5675                  accepted line-count cost of keying the whole borrowed-\
5676                  input Rc<str> corner to the substrate-primitive as_str \
5677                  accessor at the same test-site"
5678    )]
5679    fn caixa_dialeto_from_borrowed_into_rc_str_routes_through_as_str_accessor() {
5680        // Fail-before-pass-after byte-parity pin on the newly lifted
5681        // `impl From<&CaixaDialeto> for std::rc::Rc<str>` — asserts the
5682        // borrowed-input standard-library trait impl and the substrate-
5683        // primitive [`super::CaixaDialeto::as_str`] `pub const fn` accessor
5684        // resolve to the same four-arm PascalCase emit-set across every
5685        // arm the exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
5686        // Rust's standard library does not carry a blanket
5687        // `impl<T: AsRef<str>> From<&T> for std::rc::Rc<str>` (nor a
5688        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
5689        // the borrowed-input `std::rc::Rc<str>` forward-projection axis is
5690        // a distinct trait-idiomatic surface that a
5691        // `let key: std::rc::Rc<str> = (&dialeto).into();`-shaped call
5692        // site or a
5693        // `CaixaDialeto::ALL.iter().map(std::rc::Rc::<str>::from)`-shaped
5694        // pipe reaches through this impl and no other.
5695        //
5696        // Cross-axis partition pin against the paired owned-input
5697        // [`From<CaixaDialeto> for std::rc::Rc<str>`] and the sibling
5698        // borrowed-input `{&'static str, String, Cow<'static, str>,
5699        // Box<str>, std::sync::Arc<str>}` return-shape axes — locking the
5700        // six return-shape × input-shape paths on the borrowed-input
5701        // surface together by construction so any future detour off the
5702        // substrate-primitive accessor trips at caixa-core test time.
5703        // Then a `.iter().map(std::rc::Rc::<str>::from)` pipe witness
5704        // over [`super::CaixaDialeto::ALL`] — whose iterator yields
5705        // `&CaixaDialeto` by construction, so the borrowed-input
5706        // [`std::rc::Rc<str>`] axis is what routes the pipe through the
5707        // substrate-primitive [`super::CaixaDialeto::as_str`] accessor
5708        // without a spurious [`Copy`] deref.
5709        for &variant in CaixaDialeto::ALL {
5710            let via_trait: std::rc::Rc<str> =
5711                <std::rc::Rc<str> as From<&CaixaDialeto>>::from(&variant);
5712            let via_method: &'static str = variant.as_str();
5713            assert_eq!(
5714                via_trait.as_ref(),
5715                via_method,
5716                "From<&CaixaDialeto> for std::rc::Rc<str> impl must \
5717                 round-trip &CaixaDialeto::{variant:?} to the same \
5718                 PascalCase byte-string CaixaDialeto::as_str returns — \
5719                 divergence signals a silent detour off the substrate-\
5720                 primitive accessor"
5721            );
5722            let via_into: std::rc::Rc<str> = (&variant).into();
5723            assert_eq!(
5724                via_into.as_ref(),
5725                via_method,
5726                "Into<std::rc::Rc<str>>::into on &CaixaDialeto::\
5727                 {variant:?} must byte-equal CaixaDialeto::as_str on the \
5728                 same input — the blanket-derived Into shape on the \
5729                 borrowed-input surface must resolve to the same as_str \
5730                 dispatch as the explicit From impl"
5731            );
5732            let owned_rc: std::rc::Rc<str> =
5733                <std::rc::Rc<str> as From<CaixaDialeto>>::from(variant);
5734            assert_eq!(
5735                via_trait, owned_rc,
5736                "From<&CaixaDialeto> for std::rc::Rc<str> and \
5737                 From<CaixaDialeto> for std::rc::Rc<str> must resolve \
5738                 identically on CaixaDialeto::{variant:?} — divergence \
5739                 signals the borrowed-input and owned-input \
5740                 std::rc::Rc<str> forward-projection input-shape paths \
5741                 have drifted onto different emit-sets"
5742            );
5743            let borrowed_static: &'static str =
5744                <&'static str as From<&CaixaDialeto>>::from(&variant);
5745            assert_eq!(
5746                via_trait.as_ref(),
5747                borrowed_static,
5748                "From<&CaixaDialeto> for std::rc::Rc<str> and \
5749                 From<&CaixaDialeto> for &'static str must resolve \
5750                 identically on CaixaDialeto::{variant:?} — divergence \
5751                 signals the borrowed-input std::rc::Rc<str> and \
5752                 &'static str return-shape paths have drifted onto \
5753                 different emit-sets"
5754            );
5755            let borrowed_string: String = <String as From<&CaixaDialeto>>::from(&variant);
5756            assert_eq!(
5757                via_trait.as_ref(),
5758                borrowed_string.as_str(),
5759                "From<&CaixaDialeto> for std::rc::Rc<str> and \
5760                 From<&CaixaDialeto> for String must resolve identically \
5761                 on CaixaDialeto::{variant:?} — divergence signals the \
5762                 borrowed-input std::rc::Rc<str> and owned-`String` \
5763                 return-shape paths have drifted onto different emit-sets"
5764            );
5765            let borrowed_cow: std::borrow::Cow<'static, str> =
5766                <std::borrow::Cow<'static, str> as From<&CaixaDialeto>>::from(&variant);
5767            assert_eq!(
5768                via_trait.as_ref(),
5769                borrowed_cow.as_ref(),
5770                "From<&CaixaDialeto> for std::rc::Rc<str> and \
5771                 From<&CaixaDialeto> for Cow<'static, str> must resolve \
5772                 identically on CaixaDialeto::{variant:?} — divergence \
5773                 signals the borrowed-input std::rc::Rc<str> and \
5774                 Cow<'static, str> return-shape paths have drifted onto \
5775                 different emit-sets"
5776            );
5777            let borrowed_box: Box<str> = <Box<str> as From<&CaixaDialeto>>::from(&variant);
5778            assert_eq!(
5779                via_trait.as_ref(),
5780                borrowed_box.as_ref(),
5781                "From<&CaixaDialeto> for std::rc::Rc<str> and \
5782                 From<&CaixaDialeto> for Box<str> must resolve \
5783                 identically on CaixaDialeto::{variant:?} — divergence \
5784                 signals the borrowed-input std::rc::Rc<str> and \
5785                 Box<str> return-shape paths have drifted onto different \
5786                 emit-sets"
5787            );
5788            let borrowed_arc: std::sync::Arc<str> =
5789                <std::sync::Arc<str> as From<&CaixaDialeto>>::from(&variant);
5790            assert_eq!(
5791                via_trait.as_ref(),
5792                borrowed_arc.as_ref(),
5793                "From<&CaixaDialeto> for std::rc::Rc<str> and \
5794                 From<&CaixaDialeto> for std::sync::Arc<str> must \
5795                 resolve identically on CaixaDialeto::{variant:?} — \
5796                 divergence signals the borrowed-input std::rc::Rc<str> \
5797                 and std::sync::Arc<str> return-shape paths have drifted \
5798                 onto different emit-sets"
5799            );
5800        }
5801        let via_iter: Vec<std::rc::Rc<str>> = CaixaDialeto::ALL
5802            .iter()
5803            .map(std::rc::Rc::<str>::from)
5804            .collect();
5805        let via_method: Vec<std::rc::Rc<str>> = CaixaDialeto::ALL
5806            .iter()
5807            .map(|d| std::rc::Rc::<str>::from(d.as_str()))
5808            .collect();
5809        assert_eq!(
5810            via_iter, via_method,
5811            "`.iter().map(std::rc::Rc::<str>::from)` over \
5812             CaixaDialeto::ALL — a call site whose iteration axis holds \
5813             `&CaixaDialeto` by construction — must byte-equal \
5814             `.iter().map(|d| std::rc::Rc::<str>::from(d.as_str()))` \
5815             on every arm — the borrowed-input std::rc::Rc<str> \
5816             `From<&CaixaDialeto> for std::rc::Rc<str>` axis is what \
5817             makes the `std::rc::Rc::<str>::from` composition route \
5818             through the substrate-primitive `CaixaDialeto::as_str` \
5819             accessor without a spurious `Copy` deref (which would only \
5820             be reachable through the owned-input \
5821             `From<CaixaDialeto> for std::rc::Rc<str>` axis by first \
5822             calling `.copied()` on the iterator)"
5823        );
5824    }
5825
5826    #[test]
5827    #[allow(
5828        clippy::too_many_lines,
5829        reason = "cross-axis partition pin folds the substrate-primitive \
5830                  as_str accessor's `.as_bytes()` byte-tail plus the \
5831                  paired str-view (AsRef<str>, Display, as_str) and \
5832                  reverse-projection ({&'static str, String, \
5833                  Cow<'static, str>, Box<str>, std::sync::Arc<str>, \
5834                  std::rc::Rc<str>}) return-shape axes' `.as_bytes()` \
5835                  byte-tails plus a <T: AsRef<[u8]>>-bound-consumer \
5836                  witness plus a blake3::Hasher::update-shape byte-\
5837                  input surface witness into one exhaustive round-trip \
5838                  over CaixaDialeto::ALL — the accepted line-count cost \
5839                  of opening the byte-view axis keyed to the substrate-\
5840                  primitive as_str accessor at the same test-site"
5841    )]
5842    #[allow(
5843        clippy::needless_borrows_for_generic_args,
5844        reason = "the borrowed-input surface (&variant) is exercised \
5845                  deliberately: the `<T: AsRef<[u8]>>`-bound consumer \
5846                  and the `blake3::Hasher::update`-shape byte-input \
5847                  surface both accept either owned or borrowed input \
5848                  through the standard-library blanket \
5849                  `impl<T: ?Sized + AsRef<[u8]>> AsRef<[u8]> for &T`, \
5850                  and this pin round-trips both input shapes to lock \
5851                  the borrowed-input path load-bearing against a \
5852                  future silent regression"
5853    )]
5854    fn caixa_dialeto_as_ref_bytes_routes_through_as_str_accessor() {
5855        // `<T: AsRef<[u8]>>`-bound-consumer witness helper: a generic
5856        // byte-input function accepts a [`super::CaixaDialeto`]
5857        // directly through the trait bound, without the caller open-
5858        // coding the two-hop `dialeto.as_str().as_bytes()`
5859        // composition. Lifted to the top of the function per
5860        // `clippy::items_after_statements`.
5861        fn generic_bytes_sink<T: AsRef<[u8]>>(t: T) -> Vec<u8> {
5862            t.as_ref().to_vec()
5863        }
5864        // `blake3::Hasher::update`-shape byte-input surface mock:
5865        // mirrors `blake3::Hasher::update` / `ring::digest::Context::
5866        // update` / `sha2::Sha256::update`'s `impl AsRef<[u8]>`-bound
5867        // `update` signature so a per-caixa BLAKE3 content-address
5868        // closure that composes `hasher.update(dialeto)` on the
5869        // [`crate::Lacre`] closure builder reaches the substrate-
5870        // primitive `as_str` accessor through the
5871        // [`super::CaixaDialeto`] `AsRef<[u8]>` axis and no other.
5872        // Lifted to the top of the function per
5873        // `clippy::items_after_statements`.
5874        struct MockHasher(Vec<u8>);
5875        impl MockHasher {
5876            fn new() -> Self {
5877                Self(Vec::new())
5878            }
5879            fn update(&mut self, bytes: impl AsRef<[u8]>) -> &mut Self {
5880                self.0.extend_from_slice(bytes.as_ref());
5881                self
5882            }
5883            fn finalize(self) -> Vec<u8> {
5884                self.0
5885            }
5886        }
5887
5888        // Fail-before-pass-after byte-parity pin on the newly lifted
5889        // `impl AsRef<[u8]> for CaixaDialeto` — asserts the trait-
5890        // idiomatic byte-view standard-library impl and the substrate-
5891        // primitive [`super::CaixaDialeto::as_str`] `pub const fn`
5892        // accessor's `.as_bytes()` byte-tail resolve to the same
5893        // four-arm PascalCase-byte-string emit-set across every arm
5894        // the exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
5895        // Extends the substrate-wide trait-idiomatic byte-view axis
5896        // onto the second closed-set fieldless typed enum on the
5897        // caixa-core-internal tier — matching the trajectory the
5898        // sibling [`super::CaixaKind`] first-mover
5899        // [`AsRef<[u8]>`] impl (69d8d86) walked before it.
5900        for &variant in CaixaDialeto::ALL {
5901            let via_trait: &[u8] = <CaixaDialeto as AsRef<[u8]>>::as_ref(&variant);
5902            let via_method_bytes: &[u8] = variant.as_str().as_bytes();
5903            assert_eq!(
5904                via_trait, via_method_bytes,
5905                "AsRef<[u8]> for CaixaDialeto impl must byte-equal \
5906                 CaixaDialeto::as_str().as_bytes() on CaixaDialeto::\
5907                 {variant:?} — divergence signals a silent detour off \
5908                 the substrate-primitive accessor"
5909            );
5910            // Cross-axis witness against the paired str-view axes'
5911            // `.as_bytes()` byte-tails: [`AsRef<str>`] /
5912            // [`std::fmt::Display`] / [`super::CaixaDialeto::as_str`]
5913            // all resolve to the same lifted `CAIXA_DIALETO_WIRE_*`
5914            // const roster, and the byte-view axis must byte-equal
5915            // each of their `.as_bytes()` byte-tails by construction
5916            // — locking the str-view and byte-view axes together at
5917            // the substrate-primitive accessor.
5918            let str_view_ref: &str = <CaixaDialeto as AsRef<str>>::as_ref(&variant);
5919            assert_eq!(
5920                via_trait,
5921                str_view_ref.as_bytes(),
5922                "AsRef<[u8]> for CaixaDialeto and AsRef<str> for \
5923                 CaixaDialeto must resolve to byte-equal byte-tails \
5924                 on CaixaDialeto::{variant:?} — divergence signals \
5925                 the byte-view and str-view axes have drifted off the \
5926                 same substrate-primitive as_str accessor"
5927            );
5928            let display_bytes = variant.to_string();
5929            assert_eq!(
5930                via_trait,
5931                display_bytes.as_bytes(),
5932                "AsRef<[u8]> for CaixaDialeto and \
5933                 <CaixaDialeto as std::fmt::Display>::to_string must \
5934                 resolve to byte-equal byte-tails on CaixaDialeto::\
5935                 {variant:?} — divergence signals the byte-view axis \
5936                 and the Display formatter axis have drifted off the \
5937                 same substrate-primitive as_str accessor"
5938            );
5939            // Cross-axis witness against the paired reverse-
5940            // projection axes' `.as_bytes()` byte-tails: every one of
5941            // `{&'static str, String, Cow<'static, str>, Box<str>,
5942            // std::sync::Arc<str>, std::rc::Rc<str>}` allocates (or
5943            // borrows) the same PascalCase byte-string the substrate-
5944            // primitive accessor emits, so the byte-view axis must
5945            // byte-equal each of their `.as_bytes()` byte-tails by
5946            // construction.
5947            let owned_static: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
5948            assert_eq!(
5949                via_trait,
5950                owned_static.as_bytes(),
5951                "AsRef<[u8]> for CaixaDialeto and From<CaixaDialeto> \
5952                 for &'static str must resolve to byte-equal byte-\
5953                 tails on CaixaDialeto::{variant:?}"
5954            );
5955            let owned_string: String = <String as From<CaixaDialeto>>::from(variant);
5956            assert_eq!(
5957                via_trait,
5958                owned_string.as_bytes(),
5959                "AsRef<[u8]> for CaixaDialeto and From<CaixaDialeto> \
5960                 for String must resolve to byte-equal byte-tails on \
5961                 CaixaDialeto::{variant:?}"
5962            );
5963            let owned_cow: std::borrow::Cow<'static, str> =
5964                <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
5965            assert_eq!(
5966                via_trait,
5967                owned_cow.as_bytes(),
5968                "AsRef<[u8]> for CaixaDialeto and From<CaixaDialeto> \
5969                 for Cow<'static, str> must resolve to byte-equal \
5970                 byte-tails on CaixaDialeto::{variant:?}"
5971            );
5972            let owned_box: Box<str> = <Box<str> as From<CaixaDialeto>>::from(variant);
5973            assert_eq!(
5974                via_trait,
5975                owned_box.as_bytes(),
5976                "AsRef<[u8]> for CaixaDialeto and From<CaixaDialeto> \
5977                 for Box<str> must resolve to byte-equal byte-tails \
5978                 on CaixaDialeto::{variant:?}"
5979            );
5980            let owned_arc: std::sync::Arc<str> =
5981                <std::sync::Arc<str> as From<CaixaDialeto>>::from(variant);
5982            assert_eq!(
5983                via_trait,
5984                owned_arc.as_bytes(),
5985                "AsRef<[u8]> for CaixaDialeto and From<CaixaDialeto> \
5986                 for std::sync::Arc<str> must resolve to byte-equal \
5987                 byte-tails on CaixaDialeto::{variant:?}"
5988            );
5989            let owned_rc_str: std::rc::Rc<str> =
5990                <std::rc::Rc<str> as From<CaixaDialeto>>::from(variant);
5991            assert_eq!(
5992                via_trait,
5993                owned_rc_str.as_bytes(),
5994                "AsRef<[u8]> for CaixaDialeto and From<CaixaDialeto> \
5995                 for std::rc::Rc<str> must resolve to byte-equal \
5996                 byte-tails on CaixaDialeto::{variant:?}"
5997            );
5998        }
5999        // `<T: AsRef<[u8]>>`-bound-consumer witness: the generic byte-
6000        // input function `generic_bytes_sink` (lifted above per
6001        // `clippy::items_after_statements`) accepts a
6002        // [`super::CaixaDialeto`] directly through the trait bound,
6003        // without the caller open-coding the two-hop
6004        // `dialeto.as_str().as_bytes()` composition. This is the
6005        // shape that reaches the caixa-lacre BLAKE3 content-address
6006        // closure's `blake3::Hasher::update(impl AsRef<[u8]>)` byte-
6007        // input surface through this impl and no other. Exercised on
6008        // both owned and borrowed input surfaces via the standard-
6009        // library blanket `impl<T: ?Sized + AsRef<[u8]>>
6010        // AsRef<[u8]> for &T`.
6011        for &variant in CaixaDialeto::ALL {
6012            let via_generic = generic_bytes_sink(variant);
6013            let via_borrowed_generic = generic_bytes_sink(&variant);
6014            let via_method_bytes = variant.as_str().as_bytes().to_vec();
6015            assert_eq!(
6016                via_generic, via_method_bytes,
6017                "generic `<T: AsRef<[u8]>>`-bound consumer on \
6018                 CaixaDialeto::{variant:?} must yield the same byte-\
6019                 tail CaixaDialeto::as_str().as_bytes() returns — \
6020                 divergence signals the byte-view axis fails to \
6021                 bridge a generic byte-input trait bound to the \
6022                 substrate-primitive accessor"
6023            );
6024            assert_eq!(
6025                via_borrowed_generic, via_method_bytes,
6026                "generic `<T: AsRef<[u8]>>`-bound consumer on \
6027                 &CaixaDialeto::{variant:?} must yield the same byte-\
6028                 tail CaixaDialeto::as_str().as_bytes() returns — the \
6029                 borrowed-input surface must resolve to the same \
6030                 as_str dispatch"
6031            );
6032        }
6033        // `blake3::Hasher::update`-shape byte-input surface witness
6034        // on the caixa-lacre compounding target: the `MockHasher`
6035        // (lifted above per `clippy::items_after_statements`) mirrors
6036        // `blake3::Hasher::update` / `ring::digest::Context::update` /
6037        // `sha2::Sha256::update`'s `impl AsRef<[u8]>`-bound update
6038        // signature and accepts a [`super::CaixaDialeto`] directly,
6039        // routing its byte-tail through the substrate-primitive
6040        // `as_str` accessor — the shape a future per-caixa BLAKE3
6041        // content-address closure composes to fold a `:dialect`
6042        // classification byte-tag into the [`crate::Lacre`] closure
6043        // body.
6044        for &variant in CaixaDialeto::ALL {
6045            let mut owned_hasher = MockHasher::new();
6046            owned_hasher.update(variant);
6047            let owned_folded = owned_hasher.finalize();
6048            assert_eq!(
6049                owned_folded,
6050                variant.as_str().as_bytes(),
6051                "`hasher.update(dialeto)`-shape composition on \
6052                 CaixaDialeto::{variant:?} must fold the same byte-\
6053                 tail CaixaDialeto::as_str().as_bytes() returns — the \
6054                 shape a future per-caixa BLAKE3 content-address \
6055                 closure composes to fold a `:dialect` classification \
6056                 byte-tag into the Lacre closure body"
6057            );
6058            let mut borrowed_hasher = MockHasher::new();
6059            borrowed_hasher.update(&variant);
6060            let borrowed_folded = borrowed_hasher.finalize();
6061            assert_eq!(
6062                borrowed_folded,
6063                variant.as_str().as_bytes(),
6064                "`hasher.update(&dialeto)`-shape composition on \
6065                 &CaixaDialeto::{variant:?} must fold the same byte-\
6066                 tail CaixaDialeto::as_str().as_bytes() returns — the \
6067                 borrowed-input surface must resolve to the same \
6068                 as_str dispatch"
6069            );
6070        }
6071    }
6072
6073    #[test]
6074    #[expect(
6075        clippy::too_many_lines,
6076        reason = "the byte-owned reverse-projection axis is extended \
6077                  onto CaixaDialeto here as the second peer on the \
6078                  substrate-wide byte-owned Vec<u8>-output projection \
6079                  family (after the sibling first-mover CaixaKind, \
6080                  b245fd6), so the pin binds the new impl against every \
6081                  paired byte-view and str-view axis on the same enum \
6082                  plus a generic <T: Into<Vec<u8>>>-bound consumer \
6083                  witness and a std::io::Write::write_all-shape owned-\
6084                  byte-sink surface witness on both owned and borrowed \
6085                  input shapes to lock the whole family against a \
6086                  future silent regression"
6087    )]
6088    fn caixa_dialeto_from_into_owned_vec_bytes_routes_through_as_str_accessor() {
6089        // `<T: Into<Vec<u8>>>`-bound-consumer witness helper: a generic
6090        // owned-byte-input function accepts a [`super::CaixaDialeto`]
6091        // directly through the trait bound, without the caller open-
6092        // coding the three-hop `dialeto.as_str().as_bytes().to_vec()`
6093        // composition. Lifted to the top of the function per
6094        // `clippy::items_after_statements`.
6095        fn generic_owned_bytes_sink<T: Into<Vec<u8>>>(t: T) -> Vec<u8> {
6096            t.into()
6097        }
6098        // `std::io::Write::write_all`-shape owned-byte-sink surface
6099        // mock: mirrors `std::io::Write::write_all` /
6100        // `bytes::BytesMut::extend_from_slice` / any per-arm audit-log
6101        // byte-sink that consumes a `Vec<u8>` payload via
6102        // `Into<Vec<u8>>`, so a future per-caixa per-`:dialect` audit-
6103        // log emit reaches the substrate-primitive `as_str` accessor
6104        // through the byte-owned reverse-projection axis and no other.
6105        // Lifted to the top of the function per
6106        // `clippy::items_after_statements`.
6107        struct MockOwnedByteSink(Vec<u8>);
6108        impl MockOwnedByteSink {
6109            fn new() -> Self {
6110                Self(Vec::new())
6111            }
6112            fn write_all(&mut self, bytes: impl Into<Vec<u8>>) -> &mut Self {
6113                self.0.extend_from_slice(&bytes.into());
6114                self
6115            }
6116            fn finalize(self) -> Vec<u8> {
6117                self.0
6118            }
6119        }
6120
6121        // Fail-before-pass-after byte-parity pin on the newly lifted
6122        // `impl From<CaixaDialeto> for Vec<u8>` and
6123        // `impl From<&CaixaDialeto> for Vec<u8>` — asserts the trait-
6124        // idiomatic byte-owned reverse-projection standard-library
6125        // impls and the substrate-primitive
6126        // [`super::CaixaDialeto::as_str`] `pub const fn` accessor's
6127        // `.as_bytes().to_vec()` byte-tail resolve to the same four-arm
6128        // `PascalCase`-byte-string emit-set across every arm the
6129        // exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
6130        // Extends the substrate-wide trait-idiomatic byte-owned
6131        // reverse-projection axis onto the second closed-set fieldless
6132        // typed enum on the caixa-core-internal tier — matching the
6133        // trajectory the sibling first-mover [`super::CaixaKind`]
6134        // `From<{Self, &Self}> for Vec<u8>` impls (b245fd6) walked
6135        // before it on the caixa-core tier of the byte-owned axis.
6136        for &variant in CaixaDialeto::ALL {
6137            let via_owned_from: Vec<u8> = <Vec<u8> as From<CaixaDialeto>>::from(variant);
6138            let via_borrowed_from: Vec<u8> = <Vec<u8> as From<&CaixaDialeto>>::from(&variant);
6139            let via_method_bytes: Vec<u8> = variant.as_str().as_bytes().to_vec();
6140            assert_eq!(
6141                via_owned_from, via_method_bytes,
6142                "From<CaixaDialeto> for Vec<u8> impl must byte-equal \
6143                 CaixaDialeto::as_str().as_bytes().to_vec() on \
6144                 CaixaDialeto::{variant:?} — divergence signals a \
6145                 silent detour off the substrate-primitive accessor"
6146            );
6147            assert_eq!(
6148                via_borrowed_from, via_method_bytes,
6149                "From<&CaixaDialeto> for Vec<u8> impl must byte-equal \
6150                 CaixaDialeto::as_str().as_bytes().to_vec() on \
6151                 CaixaDialeto::{variant:?} — divergence signals a \
6152                 silent detour off the substrate-primitive accessor"
6153            );
6154            assert_eq!(
6155                via_owned_from, via_borrowed_from,
6156                "From<CaixaDialeto> for Vec<u8> and From<&CaixaDialeto> \
6157                 for Vec<u8> must byte-equal each other on \
6158                 CaixaDialeto::{variant:?} — divergence signals the \
6159                 owned-input and borrowed-input paths have drifted off \
6160                 the same substrate-primitive as_str accessor"
6161            );
6162            // Cross-axis witness against the paired [`AsRef<[u8]>`]
6163            // borrowed byte-view axis: the byte-owned reverse-
6164            // projection axis must byte-equal the paired borrowed
6165            // byte-view axis by construction — locking the byte-view
6166            // and byte-owned axes together at the substrate-primitive
6167            // accessor.
6168            let borrowed_bytes: &[u8] = <CaixaDialeto as AsRef<[u8]>>::as_ref(&variant);
6169            assert_eq!(
6170                via_owned_from,
6171                borrowed_bytes.to_vec(),
6172                "From<CaixaDialeto> for Vec<u8> and AsRef<[u8]> for \
6173                 CaixaDialeto must resolve to byte-equal byte-tails on \
6174                 CaixaDialeto::{variant:?} — divergence signals the \
6175                 byte-owned and byte-view axes have drifted off the \
6176                 same substrate-primitive as_str accessor"
6177            );
6178            // Cross-axis witness against the str-owned reverse-
6179            // projection family's `.into_bytes()` / `.as_bytes().to_vec()`
6180            // byte-tails: every one of `{String, Cow<'static, str>,
6181            // Box<str>, std::sync::Arc<str>, std::rc::Rc<str>}`
6182            // allocates (or borrows) the same `PascalCase` byte-string
6183            // the substrate-primitive accessor emits, so the byte-
6184            // owned axis must byte-equal each of their owned byte-
6185            // tails by construction.
6186            let owned_string: String = <String as From<CaixaDialeto>>::from(variant);
6187            assert_eq!(
6188                via_owned_from,
6189                owned_string.into_bytes(),
6190                "From<CaixaDialeto> for Vec<u8> and \
6191                 String::from(dialeto).into_bytes() must resolve to \
6192                 byte-equal byte-tails on CaixaDialeto::{variant:?}"
6193            );
6194            let owned_cow: std::borrow::Cow<'static, str> =
6195                <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
6196            assert_eq!(
6197                via_owned_from,
6198                owned_cow.as_bytes().to_vec(),
6199                "From<CaixaDialeto> for Vec<u8> and From<CaixaDialeto> \
6200                 for Cow<'static, str> must resolve to byte-equal \
6201                 byte-tails on CaixaDialeto::{variant:?}"
6202            );
6203            let owned_box: Box<str> = <Box<str> as From<CaixaDialeto>>::from(variant);
6204            assert_eq!(
6205                via_owned_from,
6206                owned_box.as_bytes().to_vec(),
6207                "From<CaixaDialeto> for Vec<u8> and From<CaixaDialeto> \
6208                 for Box<str> must resolve to byte-equal byte-tails on \
6209                 CaixaDialeto::{variant:?}"
6210            );
6211            let owned_arc: std::sync::Arc<str> =
6212                <std::sync::Arc<str> as From<CaixaDialeto>>::from(variant);
6213            assert_eq!(
6214                via_owned_from,
6215                owned_arc.as_bytes().to_vec(),
6216                "From<CaixaDialeto> for Vec<u8> and From<CaixaDialeto> \
6217                 for std::sync::Arc<str> must resolve to byte-equal \
6218                 byte-tails on CaixaDialeto::{variant:?}"
6219            );
6220            let owned_rc_str: std::rc::Rc<str> =
6221                <std::rc::Rc<str> as From<CaixaDialeto>>::from(variant);
6222            assert_eq!(
6223                via_owned_from,
6224                owned_rc_str.as_bytes().to_vec(),
6225                "From<CaixaDialeto> for Vec<u8> and From<CaixaDialeto> \
6226                 for std::rc::Rc<str> must resolve to byte-equal \
6227                 byte-tails on CaixaDialeto::{variant:?}"
6228            );
6229        }
6230        // `<T: Into<Vec<u8>>>`-bound-consumer witness on both owned
6231        // and borrowed input shapes: the generic owned-byte-input
6232        // function `generic_owned_bytes_sink` (lifted above per
6233        // `clippy::items_after_statements`) accepts a
6234        // [`super::CaixaDialeto`] and a `&CaixaDialeto` directly
6235        // through the trait bound, without the caller open-coding the
6236        // three-hop `dialeto.as_str().as_bytes().to_vec()` composition.
6237        for &variant in CaixaDialeto::ALL {
6238            let via_generic_owned = generic_owned_bytes_sink(variant);
6239            // Bind the borrowed-input path through an explicit
6240            // `&CaixaDialeto` local so the generic-consumer witness
6241            // routes through `From<&CaixaDialeto> for Vec<u8>` (T binds
6242            // to `&CaixaDialeto`) rather than clippy-collapsing the
6243            // borrow onto the owned-input `From<CaixaDialeto> for
6244            // Vec<u8>` peer.
6245            let variant_ref: &CaixaDialeto = &variant;
6246            let via_generic_borrowed = generic_owned_bytes_sink(variant_ref);
6247            let via_method_bytes = variant.as_str().as_bytes().to_vec();
6248            assert_eq!(
6249                via_generic_owned, via_method_bytes,
6250                "generic `<T: Into<Vec<u8>>>`-bound consumer on \
6251                 CaixaDialeto::{variant:?} must yield the same byte-\
6252                 tail CaixaDialeto::as_str().as_bytes().to_vec() \
6253                 returns — divergence signals the byte-owned axis \
6254                 fails to bridge a generic owned-byte-input trait \
6255                 bound to the substrate-primitive accessor"
6256            );
6257            assert_eq!(
6258                via_generic_borrowed, via_method_bytes,
6259                "generic `<T: Into<Vec<u8>>>`-bound consumer on \
6260                 &CaixaDialeto::{variant:?} must yield the same byte-\
6261                 tail CaixaDialeto::as_str().as_bytes().to_vec() \
6262                 returns — the borrowed-input surface must resolve to \
6263                 the same as_str dispatch"
6264            );
6265        }
6266        // `std::io::Write::write_all`-shape owned-byte-sink surface
6267        // witness: the `MockOwnedByteSink` (lifted above per
6268        // `clippy::items_after_statements`) mirrors
6269        // `std::io::Write::write_all` /
6270        // `bytes::BytesMut::extend_from_slice`'s `impl Into<Vec<u8>>`-
6271        // bound owned-byte input signature and accepts a
6272        // [`super::CaixaDialeto`] directly on both owned and borrowed
6273        // input shapes, routing its byte-tail through the substrate-
6274        // primitive `as_str` accessor — the shape a future per-caixa
6275        // per-`:dialect` audit-log emit composes to fold a `:dialect`
6276        // classification byte-tag into a downstream owned-byte-sink
6277        // surface.
6278        for &variant in CaixaDialeto::ALL {
6279            let mut owned_sink = MockOwnedByteSink::new();
6280            owned_sink.write_all(variant);
6281            let owned_folded = owned_sink.finalize();
6282            assert_eq!(
6283                owned_folded,
6284                variant.as_str().as_bytes(),
6285                "`sink.write_all(dialeto)`-shape composition on \
6286                 CaixaDialeto::{variant:?} must fold the same byte-\
6287                 tail CaixaDialeto::as_str().as_bytes() returns"
6288            );
6289            let mut borrowed_sink = MockOwnedByteSink::new();
6290            // Same explicit `&CaixaDialeto` binding as the generic-
6291            // consumer witness above: routes the owned-byte-sink
6292            // surface through `From<&CaixaDialeto> for Vec<u8>` (T
6293            // binds to `&CaixaDialeto`) rather than clippy-collapsing
6294            // the borrow onto the owned-input peer.
6295            let variant_ref: &CaixaDialeto = &variant;
6296            borrowed_sink.write_all(variant_ref);
6297            let borrowed_folded = borrowed_sink.finalize();
6298            assert_eq!(
6299                borrowed_folded,
6300                variant.as_str().as_bytes(),
6301                "`sink.write_all(&dialeto)`-shape composition on \
6302                 &CaixaDialeto::{variant:?} must fold the same byte-\
6303                 tail CaixaDialeto::as_str().as_bytes() returns — the \
6304                 borrowed-input surface must resolve to the same \
6305                 as_str dispatch"
6306            );
6307        }
6308    }
6309
6310    #[test]
6311    fn caixa_dialeto_try_from_bytes_routes_through_from_wire_accessor() {
6312        // Fail-before-pass-after byte-parity pin on the newly lifted
6313        // `impl TryFrom<&[u8]> for CaixaDialeto` — asserts the trait-
6314        // idiomatic byte-view reverse-projection standard-library impl
6315        // and the substrate-primitive [`super::CaixaDialeto::from_wire`]
6316        // `Option<Self>` accessor resolve to the same four-arm
6317        // `PascalCase` wire accept-set across every arm the exhaustive
6318        // [`super::CaixaDialeto::ALL`] slice enumerates. Extends the
6319        // substrate-wide trait-idiomatic byte-view reverse-projection
6320        // axis onto the second caixa-core-internal closed-set fieldless
6321        // typed enum peer — mirror of the paired
6322        // [`TryFrom<&str> for CaixaDialeto`] str-view reverse-projection
6323        // axis on the same enum, and the byte-view companion of the
6324        // pre-existing byte-owned reverse-projection family
6325        // ([`AsRef<[u8]>`], [`From<CaixaDialeto> for Vec<u8>`],
6326        // [`From<&CaixaDialeto> for Vec<u8>`]) on this same enum. Peer
6327        // of the sibling
6328        // [`crate::kind::tests::caixa_kind_try_from_bytes_routes_through_from_wire_accessor`]
6329        // (18d1940) on the first-mover [`crate::CaixaKind`] closed-set
6330        // typed-enum peer — tracks the "route through `from_wire` via
6331        // `std::str::from_utf8`" discipline the first-mover established.
6332        //
6333        // Rust's standard library carries no blanket
6334        // `impl<T: for<'a> TryFrom<&'a str>> TryFrom<&[u8]> for T`, so
6335        // a two-hop composition through [`std::str::from_utf8`] + the
6336        // paired [`TryFrom<&str>`] axis is reachable through the pre-
6337        // existing str-view reverse-projection axis alone. But that
6338        // two-hop shape has no compile-time link back to the byte-view
6339        // reverse-projection axis, forces every downstream
6340        // `<T: for<'a> TryFrom<&'a [u8]>>`-bound consumer to open-code
6341        // the composition at every call site, and admits a silent split
6342        // whenever a future call site takes a sibling byte-projection
6343        // axis whose parse arm-set carries no compile-time byte-view
6344        // surface. This impl closes the byte-view reverse-projection
6345        // axis at the substrate-primitive
6346        // [`super::CaixaDialeto::from_wire`] accessor so every future
6347        // `<T: for<'a> TryFrom<&'a [u8]>>`-bound consumer reaches the
6348        // same four-arm `PascalCase` wire accept-set through one trait
6349        // dispatch.
6350        for &variant in CaixaDialeto::ALL {
6351            let wire_bytes: &[u8] = variant.as_str().as_bytes();
6352            assert_eq!(
6353                <CaixaDialeto as TryFrom<&[u8]>>::try_from(wire_bytes),
6354                Ok(variant),
6355                "TryFrom<&[u8]> impl on CaixaDialeto must round-trip \
6356                 CaixaDialeto::{variant:?}.as_str().as_bytes() back to \
6357                 Ok(CaixaDialeto::{variant:?}) — divergence from \
6358                 CaixaDialeto::from_wire signals a silent detour off \
6359                 the substrate-primitive accessor"
6360            );
6361            assert_eq!(
6362                <CaixaDialeto as TryFrom<&[u8]>>::try_from(wire_bytes).ok(),
6363                CaixaDialeto::from_wire(variant.as_str()),
6364                "TryFrom<&[u8]> ok()-projection on \
6365                 CaixaDialeto::{variant:?}.as_str().as_bytes() must \
6366                 byte-equal CaixaDialeto::from_wire on the paired &str \
6367                 input"
6368            );
6369            // Cross-axis witness: the byte-view reverse-projection axis
6370            // must agree with the paired str-view reverse-projection
6371            // axis ([`TryFrom<&str>`]) on every accepted arm — the two
6372            // reverse paths share one `PascalCase` accept-set through
6373            // the substrate-primitive `from_wire` accessor.
6374            let via_str: Result<CaixaDialeto, ()> =
6375                <CaixaDialeto as TryFrom<&str>>::try_from(variant.as_str());
6376            let via_bytes: Result<CaixaDialeto, ()> =
6377                <CaixaDialeto as TryFrom<&[u8]>>::try_from(wire_bytes);
6378            assert_eq!(
6379                via_bytes, via_str,
6380                "TryFrom<&[u8]> and TryFrom<&str> reverse-projection \
6381                 axes on CaixaDialeto must agree on \
6382                 CaixaDialeto::{variant:?} — divergence signals the \
6383                 byte-view and str-view reverse paths have drifted off \
6384                 the same substrate-primitive from_wire accessor"
6385            );
6386        }
6387    }
6388
6389    #[test]
6390    fn caixa_dialeto_try_from_bytes_rejects_unknown_and_non_utf8_bytes() {
6391        // Rejection witness on the `impl TryFrom<&[u8]> for CaixaDialeto`
6392        // — sweeps two rejection paths the byte-view reverse-projection
6393        // axis collapses onto the single unit-error `Err(())` return:
6394        // the invalid-UTF-8 rejection path ([`std::str::from_utf8`]
6395        // returns `Err` before [`super::CaixaDialeto::from_wire`] runs)
6396        // and the valid-UTF-8-but-unknown-wire rejection path
6397        // ([`super::CaixaDialeto::from_wire`] returns `None` on a byte-
6398        // string outside the four-arm `PascalCase` accept-set). Both
6399        // must reject, so a future accidental widening of the trait
6400        // impl's accept-set (a case-fold path, a silent acceptance of
6401        // the sibling [`super::CaixaDialeto::palavra_canonica`]
6402        // `"defcaixa"` / `"defmolde"` byte-shapes on this axis, a
6403        // `#[serde(rename_all = "…")]` attribute drift that widens the
6404        // parse arm-set silently, a stray fallback that maps invalid
6405        // UTF-8 onto a default arm rather than the trait-idiomatic
6406        // `Err(())`) trips at caixa-core test time. Peer of the sibling
6407        // [`crate::kind::tests::caixa_kind_try_from_bytes_rejects_unknown_and_non_utf8_bytes`]
6408        // (18d1940) on the first-mover [`crate::CaixaKind`] closed-set
6409        // typed-enum peer.
6410        //
6411        // Non-UTF-8 candidates:
6412        //   - a lone 0xFF byte (never valid as a UTF-8 leading byte)
6413        //   - a lone 0x80 continuation byte with no leading byte
6414        //   - a truncated multi-byte sequence (0xC3 without its continuation)
6415        //   - a UTF-16 BOM-style byte pair the UTF-8 validator rejects
6416        //   - a UTF-16 surrogate half rejected by UTF-8
6417        let non_utf8_rejected: &[&[u8]] = &[
6418            &[0xFF],
6419            &[0x80],
6420            &[0xC3],
6421            &[0xFF, 0xFE],
6422            &[0xED, 0xA0, 0x80],
6423        ];
6424        for &input in non_utf8_rejected {
6425            assert_eq!(
6426                <CaixaDialeto as TryFrom<&[u8]>>::try_from(input),
6427                Err(()),
6428                "TryFrom<&[u8]> impl on CaixaDialeto must reject the \
6429                 non-UTF-8 byte-sequence {input:?} with Err(()) — \
6430                 silent acceptance signals the UTF-8 validation path \
6431                 collapsed onto a default arm rather than the trait-\
6432                 idiomatic unit-error"
6433            );
6434        }
6435        // Valid-UTF-8-but-unknown-wire candidates: the empty byte-
6436        // string, case-folded variants of accepted arms, plausible
6437        // typos, the sibling [`super::CaixaDialeto::palavra_canonica`]
6438        // / [`super::CaixaDialeto::consumidor`] byte-shapes (a caller
6439        // who confuses those distinct axes with the census-facing wire
6440        // axis trips here), and whitespace-padded / quoted forms.
6441        let unknown_wire_rejected: &[&[u8]] = &[
6442            b"",
6443            b" ",
6444            b"pacote",
6445            b"PACOTE",
6446            b"molde",
6447            b"MoldePositional",
6448            b"desconhecido",
6449            b"Unknown",
6450            b"defcaixa",
6451            b"defmolde",
6452            b"?",
6453            b"caixa-core / feira",
6454            b"pleme-doc-gen",
6455            b"nobody known",
6456            b"Pacote ",
6457            b" Pacote",
6458            b"Pacote\n",
6459            b"\"Pacote\"",
6460        ];
6461        for &input in unknown_wire_rejected {
6462            assert_eq!(
6463                <CaixaDialeto as TryFrom<&[u8]>>::try_from(input),
6464                Err(()),
6465                "TryFrom<&[u8]> impl on CaixaDialeto must reject the \
6466                 valid-UTF-8-but-unknown-wire byte-string {input:?} \
6467                 with Err(()) — silent acceptance signals an accept-\
6468                 set widening off the paired CaixaDialeto::from_wire \
6469                 resolver"
6470            );
6471            // Cross-axis witness: on a byte-string that is valid UTF-8,
6472            // the byte-view reverse-projection axis must agree with the
6473            // paired str-view reverse-projection axis
6474            // ([`TryFrom<&str>`]) — both route through the same
6475            // [`super::CaixaDialeto::from_wire`] resolver, so the two
6476            // rejection paths align by construction.
6477            if let Ok(s) = std::str::from_utf8(input) {
6478                assert_eq!(
6479                    <CaixaDialeto as TryFrom<&[u8]>>::try_from(input),
6480                    <CaixaDialeto as TryFrom<&str>>::try_from(s),
6481                    "TryFrom<&[u8]> and TryFrom<&str> reverse-\
6482                     projection axes on CaixaDialeto must agree on the \
6483                     valid-UTF-8 input {input:?} — divergence signals \
6484                     the two reverse paths have drifted off the same \
6485                     substrate-primitive from_wire accessor"
6486                );
6487            }
6488        }
6489    }
6490
6491    #[test]
6492    fn caixa_dialeto_try_from_vec_bytes_routes_through_borrowed_byte_view_axis() {
6493        // Fail-before-pass-after byte-parity pin on the newly lifted
6494        // `impl TryFrom<Vec<u8>> for CaixaDialeto` — asserts the trait-
6495        // idiomatic owned-byte-vec reverse-projection standard-library
6496        // impl and the sibling borrowed-input [`TryFrom<&[u8]>`] axis
6497        // resolve to the same four-arm `PascalCase` wire accept-set
6498        // across every arm the exhaustive [`super::CaixaDialeto::ALL`]
6499        // slice enumerates. Extends the substrate-wide trait-idiomatic
6500        // byte-owned reverse-projection axis onto the second caixa-
6501        // core-internal closed-set fieldless typed enum peer — owned-
6502        // input mirror of the paired [`TryFrom<&[u8]>`] byte-view
6503        // reverse-projection axis (d102cb8), and byte-owned reverse
6504        // companion of the pre-existing byte-owned *forward*-projection
6505        // pair ([`From<CaixaDialeto> for Vec<u8>`], [`From<&CaixaDialeto>
6506        // for Vec<u8>`]) on this same enum. Peer of the sibling
6507        // first-mover
6508        // [`crate::kind::tests::caixa_kind_try_from_vec_bytes_routes_through_borrowed_byte_view_axis`]
6509        // (99c2849) on the [`crate::CaixaKind`] closed-set typed-enum
6510        // peer — tracks the "delegate through `TryFrom<&[u8]>` on the
6511        // `Vec<u8>::as_slice` borrow" discipline the first-mover
6512        // established.
6513        //
6514        // Rust's standard library carries no blanket
6515        // `impl<T: for<'a> TryFrom<&'a [u8]>> TryFrom<Vec<u8>> for T`,
6516        // so an owned-byte-vec caller otherwise picks between an
6517        // open-coded `<T as TryFrom<&[u8]>>::try_from(bytes.as_slice())`
6518        // at every call site whose type bounds have no compile-time
6519        // link back to the byte-owned reverse-projection axis, or a
6520        // `String::from_utf8(bytes)` two-hop shape whose error surface
6521        // leaks the standard-library `FromUtf8Error` type. This impl
6522        // closes the byte-owned reverse-projection axis at the
6523        // substrate-primitive [`super::CaixaDialeto::from_wire`]
6524        // accessor so every future `<T: TryFrom<Vec<u8>>>`-bound owned-
6525        // byte-vec consumer reaches the same four-arm `PascalCase` wire
6526        // accept-set through one trait dispatch.
6527        for &variant in CaixaDialeto::ALL {
6528            let wire_bytes: Vec<u8> = variant.as_str().as_bytes().to_vec();
6529            assert_eq!(
6530                <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(wire_bytes.clone()),
6531                Ok(variant),
6532                "TryFrom<Vec<u8>> impl on CaixaDialeto must round-trip \
6533                 CaixaDialeto::{variant:?}.as_str().as_bytes().to_vec() \
6534                 back to Ok(CaixaDialeto::{variant:?}) — divergence from \
6535                 the sibling TryFrom<&[u8]> axis signals a silent detour \
6536                 off the substrate-primitive from_wire accessor"
6537            );
6538            // Cross-axis witness: the owned-byte-vec reverse-projection
6539            // axis must agree with the borrowed byte-slice reverse-
6540            // projection axis on every accepted arm — the two axes
6541            // share one `PascalCase` wire vocabulary through the
6542            // substrate-primitive `from_wire` accessor, and the owned-
6543            // input axis delegates to the borrowed peer by design.
6544            let via_owned: Result<CaixaDialeto, ()> =
6545                <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(wire_bytes.clone());
6546            let via_borrowed: Result<CaixaDialeto, ()> =
6547                <CaixaDialeto as TryFrom<&[u8]>>::try_from(wire_bytes.as_slice());
6548            assert_eq!(
6549                via_owned, via_borrowed,
6550                "TryFrom<Vec<u8>> and TryFrom<&[u8]> reverse-projection \
6551                 axes on CaixaDialeto must agree on \
6552                 CaixaDialeto::{variant:?} — divergence signals the \
6553                 owned-input and borrowed-input byte-view reverse \
6554                 paths have drifted off the same substrate-primitive \
6555                 from_wire accessor"
6556            );
6557            // Cross-axis witness against the paired str-view reverse
6558            // axis ([`TryFrom<&str>`]) — the three reverse paths (str-
6559            // view, byte-view borrowed, byte-view owned) share one
6560            // substrate primitive.
6561            let via_str: Result<CaixaDialeto, ()> =
6562                <CaixaDialeto as TryFrom<&str>>::try_from(variant.as_str());
6563            assert_eq!(
6564                via_owned, via_str,
6565                "TryFrom<Vec<u8>> and TryFrom<&str> reverse-projection \
6566                 axes on CaixaDialeto must agree on \
6567                 CaixaDialeto::{variant:?} — divergence signals the \
6568                 byte-owned and str-view reverse paths have drifted \
6569                 off the same substrate-primitive from_wire accessor"
6570            );
6571            // Four-corner witness: because [`CaixaDialeto`] carries no
6572            // wire-vs-diagnostic split (as_str and from_wire share one
6573            // `PascalCase` byte-vocabulary), the byte-owned reverse-
6574            // projection axis on this enum *does* round-trip against
6575            // the paired byte-owned forward-projection pair. Pin every
6576            // corner of the {owned-input, borrowed-input} ×
6577            // {From<Self> → Vec<u8>, From<&Self> → Vec<u8>} square onto
6578            // the same Ok(variant) return so a future accident that
6579            // drops one corner off the substrate-primitive accessor
6580            // trips here.
6581            let owned_forward: Vec<u8> = <Vec<u8> as From<CaixaDialeto>>::from(variant);
6582            let borrowed_forward: Vec<u8> = <Vec<u8> as From<&CaixaDialeto>>::from(&variant);
6583            assert_eq!(
6584                owned_forward, wire_bytes,
6585                "From<CaixaDialeto> for Vec<u8> forward projection on \
6586                 CaixaDialeto::{variant:?} must byte-equal \
6587                 variant.as_str().as_bytes().to_vec() — divergence \
6588                 signals the paired forward pair drifted off the \
6589                 substrate-primitive as_str accessor"
6590            );
6591            assert_eq!(
6592                borrowed_forward, wire_bytes,
6593                "From<&CaixaDialeto> for Vec<u8> forward projection on \
6594                 &CaixaDialeto::{variant:?} must byte-equal \
6595                 variant.as_str().as_bytes().to_vec() — divergence \
6596                 signals the paired forward pair drifted off the \
6597                 substrate-primitive as_str accessor"
6598            );
6599            assert_eq!(
6600                <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(owned_forward.clone()),
6601                Ok(variant),
6602                "Four-corner round-trip on CaixaDialeto::{variant:?} \
6603                 through From<CaixaDialeto> for Vec<u8> then \
6604                 TryFrom<Vec<u8>> for CaixaDialeto must return \
6605                 Ok(variant) — divergence signals the byte-owned \
6606                 forward pair and the byte-owned reverse axis have \
6607                 drifted apart"
6608            );
6609            assert_eq!(
6610                <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(borrowed_forward),
6611                Ok(variant),
6612                "Four-corner round-trip on CaixaDialeto::{variant:?} \
6613                 through From<&CaixaDialeto> for Vec<u8> then \
6614                 TryFrom<Vec<u8>> for CaixaDialeto must return \
6615                 Ok(variant) — divergence signals the borrowed-input \
6616                 forward corner and the owned-input reverse corner \
6617                 have drifted apart"
6618            );
6619        }
6620    }
6621
6622    #[test]
6623    fn caixa_dialeto_try_from_vec_bytes_rejects_unknown_and_non_utf8_bytes() {
6624        // Rejection witness on the `impl TryFrom<Vec<u8>> for CaixaDialeto`
6625        // — sweeps the same two rejection paths the sibling borrowed
6626        // `TryFrom<&[u8]>` axis collapses onto the single unit-error
6627        // return: the invalid-UTF-8 rejection path (`std::str::from_utf8`
6628        // on the underlying byte-slice returns `Err` before
6629        // [`super::CaixaDialeto::from_wire`] runs) and the valid-UTF-8-
6630        // but-unknown-wire rejection path
6631        // ([`super::CaixaDialeto::from_wire`] returns `None` on a byte-
6632        // string outside the four-arm `PascalCase` accept-set). Both
6633        // must reject so a future accidental widening of the trait
6634        // impl's accept-set (a case-fold path, a silent acceptance of
6635        // the sibling [`super::CaixaDialeto::palavra_canonica`]
6636        // `"defcaixa"` / `"defmolde"` byte-shapes on this axis, a
6637        // `#[serde(rename_all = "…")]` attribute drift that widens the
6638        // parse arm-set silently, a stray `String::from_utf8_lossy`
6639        // detour that widens the input surface with the U+FFFD
6640        // replacement character, an `Option::unwrap_or_default`-shape
6641        // fallback that maps invalid UTF-8 onto a default arm rather
6642        // than the trait-idiomatic `Err(())`) trips at caixa-core test
6643        // time. Peer of the sibling first-mover
6644        // [`crate::kind::tests::caixa_kind_try_from_vec_bytes_rejects_unknown_and_non_utf8_bytes`]
6645        // (99c2849) on the [`crate::CaixaKind`] closed-set typed-enum
6646        // peer.
6647        let non_utf8_rejected: &[&[u8]] = &[
6648            &[0xFF],
6649            &[0x80],
6650            &[0xC3],
6651            &[0xFF, 0xFE],
6652            &[0xED, 0xA0, 0x80], // UTF-16 surrogate half — rejected by UTF-8
6653        ];
6654        for &input in non_utf8_rejected {
6655            let owned: Vec<u8> = input.to_vec();
6656            assert_eq!(
6657                <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(owned),
6658                Err(()),
6659                "TryFrom<Vec<u8>> impl on CaixaDialeto must reject the \
6660                 non-UTF-8 byte-sequence {input:?} with Err(()) — \
6661                 silent acceptance signals the UTF-8 validation path \
6662                 collapsed onto a default arm rather than the trait-\
6663                 idiomatic unit-error"
6664            );
6665            // Cross-axis witness: the owned-input axis must agree with
6666            // the borrowed-input axis on every rejected input.
6667            assert_eq!(
6668                <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(input.to_vec()),
6669                <CaixaDialeto as TryFrom<&[u8]>>::try_from(input),
6670                "TryFrom<Vec<u8>> and TryFrom<&[u8]> reverse-projection \
6671                 axes on CaixaDialeto must agree on the non-UTF-8 \
6672                 input {input:?} — divergence signals the owned-input \
6673                 and borrowed-input byte-view reverse paths have \
6674                 drifted off the same substrate-primitive from_wire \
6675                 accessor"
6676            );
6677        }
6678        // Valid-UTF-8-but-unknown-wire candidates: the empty byte-
6679        // string, case-folded variants of accepted arms, plausible
6680        // typos, the sibling [`super::CaixaDialeto::palavra_canonica`]
6681        // / [`super::CaixaDialeto::consumidor`] byte-shapes (a caller
6682        // who confuses those distinct axes with the census-facing wire
6683        // axis trips here), and whitespace-padded / quoted forms.
6684        let unknown_wire_rejected: &[&[u8]] = &[
6685            b"",
6686            b" ",
6687            b"pacote",
6688            b"PACOTE",
6689            b"molde",
6690            b"MoldePositional",
6691            b"desconhecido",
6692            b"Unknown",
6693            b"defcaixa",
6694            b"defmolde",
6695            b"?",
6696            b"caixa-core / feira",
6697            b"pleme-doc-gen",
6698            b"nobody known",
6699            b"Pacote ",
6700            b" Pacote",
6701            b"Pacote\n",
6702            b"\"Pacote\"",
6703        ];
6704        for &input in unknown_wire_rejected {
6705            let owned: Vec<u8> = input.to_vec();
6706            assert_eq!(
6707                <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(owned),
6708                Err(()),
6709                "TryFrom<Vec<u8>> impl on CaixaDialeto must reject the \
6710                 valid-UTF-8-but-unknown-wire byte-string {input:?} \
6711                 with Err(()) — silent acceptance signals an accept-\
6712                 set widening off the paired CaixaDialeto::from_wire \
6713                 resolver"
6714            );
6715            // Cross-axis witness against the borrowed byte-view axis:
6716            // the two paths must agree by construction, since the owned
6717            // axis delegates to the borrowed peer.
6718            assert_eq!(
6719                <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(input.to_vec()),
6720                <CaixaDialeto as TryFrom<&[u8]>>::try_from(input),
6721                "TryFrom<Vec<u8>> and TryFrom<&[u8]> reverse-projection \
6722                 axes on CaixaDialeto must agree on the valid-UTF-8-\
6723                 but-unknown-wire input {input:?} — divergence signals \
6724                 the owned-input and borrowed-input byte-view reverse \
6725                 paths have drifted off the same substrate-primitive \
6726                 from_wire accessor"
6727            );
6728        }
6729    }
6730
6731    #[test]
6732    fn caixa_dialeto_try_from_owned_string_routes_through_borrowed_str_view_axis() {
6733        // Fail-before-pass-after byte-parity pin on the newly lifted
6734        // `impl TryFrom<String> for CaixaDialeto` — asserts the trait-
6735        // idiomatic string-owned reverse-projection standard-library
6736        // impl and the sibling borrowed-input [`TryFrom<&str>`] axis
6737        // resolve to the same four-arm `PascalCase` wire accept-set
6738        // across every arm the exhaustive [`super::CaixaDialeto::ALL`]
6739        // slice enumerates. Extends the substrate-wide trait-idiomatic
6740        // string-owned reverse-projection axis onto the second caixa-
6741        // core-internal closed-set fieldless typed-enum peer — owned-
6742        // input mirror of the paired [`TryFrom<&str>`] str-view
6743        // reverse-projection axis, and string-owned reverse companion
6744        // of the pre-existing string-owned *forward*-projection pair
6745        // ([`From<CaixaDialeto> for String`] / [`From<&CaixaDialeto>
6746        // for String`]) on this same enum. Peer of the sibling
6747        // first-mover
6748        // [`crate::aplicacao::tests::rate_limit_try_from_owned_string_routes_through_borrowed_str_view_axis`]
6749        // (a2e6f02) on the compound [`crate::aplicacao::RateLimit`]
6750        // primitive, and the sibling
6751        // `caixa_kind_try_from_owned_string_routes_through_borrowed_str_view_axis`
6752        // (e7df24f) on the [`crate::CaixaKind`] closed-set typed-enum
6753        // peer — tracks the "delegate through `TryFrom<&str>` on the
6754        // `String::as_str` borrow" discipline the compound-primitive
6755        // opener and closed-set-peer first-mover established. This
6756        // closes the string-owned reverse-projection axis on the second
6757        // caixa-core-internal closed-set fieldless typed-enum peer,
6758        // mirroring the trajectory the byte-view (d102cb8) / byte-
6759        // owned (83a1526) / str-view reverse-projection families
6760        // already walked on this same enum.
6761        for &variant in CaixaDialeto::ALL {
6762            let wire_string: String = variant.as_str().to_string();
6763            assert_eq!(
6764                <CaixaDialeto as TryFrom<String>>::try_from(wire_string.clone()),
6765                Ok(variant),
6766                "TryFrom<String> impl on CaixaDialeto must round-trip \
6767                 CaixaDialeto::{variant:?}.as_str().to_string() back \
6768                 to Ok(CaixaDialeto::{variant:?}) — divergence from \
6769                 the sibling TryFrom<&str> axis signals a silent detour \
6770                 off the substrate-primitive from_wire accessor"
6771            );
6772            // Cross-axis witness: the string-owned reverse-projection
6773            // axis must agree with the borrowed `&str` reverse-projection
6774            // axis on every accepted arm — the two axes share one
6775            // `PascalCase` wire vocabulary through the substrate-
6776            // primitive `from_wire` accessor, and the owned-input axis
6777            // delegates to the borrowed peer by design.
6778            let via_owned: Result<CaixaDialeto, ()> =
6779                <CaixaDialeto as TryFrom<String>>::try_from(wire_string.clone());
6780            let via_borrowed: Result<CaixaDialeto, ()> =
6781                <CaixaDialeto as TryFrom<&str>>::try_from(wire_string.as_str());
6782            assert_eq!(
6783                via_owned, via_borrowed,
6784                "TryFrom<String> and TryFrom<&str> reverse-projection \
6785                 axes on CaixaDialeto must agree on \
6786                 CaixaDialeto::{variant:?} — divergence signals the \
6787                 owned-`String` and borrowed-`&str` reverse paths have \
6788                 drifted off the same substrate-primitive from_wire \
6789                 accessor"
6790            );
6791            // Cross-axis witness against the paired byte-view reverse-
6792            // projection axis ([`TryFrom<&[u8]>`]) — the four reverse
6793            // paths share one substrate primitive.
6794            let via_byte_slice: Result<CaixaDialeto, ()> =
6795                <CaixaDialeto as TryFrom<&[u8]>>::try_from(wire_string.as_bytes());
6796            assert_eq!(
6797                via_owned, via_byte_slice,
6798                "TryFrom<String> and TryFrom<&[u8]> reverse-projection \
6799                 axes on CaixaDialeto must agree on \
6800                 CaixaDialeto::{variant:?} — divergence signals the \
6801                 string-owned and byte-view borrowed reverse paths \
6802                 have drifted off the same substrate-primitive \
6803                 from_wire accessor"
6804            );
6805            // Cross-axis witness against the sibling byte-owned
6806            // reverse-projection axis ([`TryFrom<Vec<u8>>`]) — the
6807            // two owned-input axes share one `PascalCase` wire
6808            // vocabulary.
6809            let via_byte_vec: Result<CaixaDialeto, ()> =
6810                <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(wire_string.as_bytes().to_vec());
6811            assert_eq!(
6812                via_owned, via_byte_vec,
6813                "TryFrom<String> and TryFrom<Vec<u8>> reverse-\
6814                 projection axes on CaixaDialeto must agree on \
6815                 CaixaDialeto::{variant:?} — divergence signals the \
6816                 string-owned and byte-owned reverse paths have \
6817                 drifted off the same substrate-primitive from_wire \
6818                 accessor"
6819            );
6820            // Four-corner witness: because [`CaixaDialeto`] carries no
6821            // wire-vs-diagnostic split (as_str and from_wire share one
6822            // `PascalCase` byte-vocabulary), the string-owned reverse-
6823            // projection axis on this enum *does* round-trip against
6824            // the paired string-owned forward-projection pair. Pin
6825            // every corner of the {owned-input, borrowed-input} ×
6826            // {`From<Self> → String`, `From<&Self> → String`} square
6827            // onto the same Ok(variant) return so a future accident
6828            // that drops one corner off the substrate-primitive
6829            // accessor trips here. Mirror of the peer four-corner
6830            // witness the sibling
6831            // [`caixa_dialeto_try_from_vec_bytes_routes_through_borrowed_byte_view_axis`]
6832            // (83a1526) pins on the byte-owned reverse axis.
6833            let owned_forward: String = <String as From<CaixaDialeto>>::from(variant);
6834            let borrowed_forward: String = <String as From<&CaixaDialeto>>::from(&variant);
6835            assert_eq!(
6836                owned_forward, wire_string,
6837                "From<CaixaDialeto> for String forward projection on \
6838                 CaixaDialeto::{variant:?} must byte-equal \
6839                 variant.as_str().to_string() — divergence signals \
6840                 the paired forward pair drifted off the substrate-\
6841                 primitive as_str accessor"
6842            );
6843            assert_eq!(
6844                borrowed_forward, wire_string,
6845                "From<&CaixaDialeto> for String forward projection on \
6846                 &CaixaDialeto::{variant:?} must byte-equal \
6847                 variant.as_str().to_string() — divergence signals \
6848                 the paired forward pair drifted off the substrate-\
6849                 primitive as_str accessor"
6850            );
6851            assert_eq!(
6852                <CaixaDialeto as TryFrom<String>>::try_from(owned_forward.clone()),
6853                Ok(variant),
6854                "Four-corner round-trip on CaixaDialeto::{variant:?} \
6855                 through From<CaixaDialeto> for String then \
6856                 TryFrom<String> for CaixaDialeto must return \
6857                 Ok(variant) — divergence signals the string-owned \
6858                 forward pair and the string-owned reverse axis have \
6859                 drifted apart"
6860            );
6861            assert_eq!(
6862                <CaixaDialeto as TryFrom<String>>::try_from(borrowed_forward),
6863                Ok(variant),
6864                "Four-corner round-trip on CaixaDialeto::{variant:?} \
6865                 through From<&CaixaDialeto> for String then \
6866                 TryFrom<String> for CaixaDialeto must return \
6867                 Ok(variant) — divergence signals the borrowed-input \
6868                 forward corner and the owned-input reverse corner \
6869                 have drifted apart"
6870            );
6871        }
6872    }
6873
6874    #[test]
6875    fn caixa_dialeto_try_from_owned_string_rejects_unknown_wire_strings() {
6876        // Rejection witness on the `impl TryFrom<String> for CaixaDialeto`
6877        // — mirrors the rejection corpus the paired borrowed
6878        // [`TryFrom<&str>`] and owned [`TryFrom<Vec<u8>>`] axes already
6879        // pin on the owned-`String` surface. Every non-`PascalCase`-
6880        // wire byte-string must land on `Err(())` so a future
6881        // accidental widening of the trait impl's accept-set (a stray
6882        // `_ if s.eq_ignore_ascii_case("Pacote") => Ok(…)` case-fold
6883        // path, a silent acceptance of the sibling
6884        // [`super::CaixaDialeto::palavra_canonica`] / [`super::CaixaDialeto::consumidor`]
6885        // byte-shapes on this axis, an `Option::unwrap_or_default`-
6886        // shape fallback that maps unknown inputs onto a default arm
6887        // rather than the trait-idiomatic `Err(())`) trips at caixa-
6888        // core test time. Sweep includes the empty string, case-fold
6889        // variants of the four PascalCase arms, the sibling
6890        // [`super::CaixaDialeto::palavra_canonica`] /
6891        // [`super::CaixaDialeto::consumidor`] byte-shapes (a caller
6892        // who confuses those distinct axes with the census-facing wire
6893        // axis trips here), and whitespace-padded / trailing-newline /
6894        // quote-wrapped forms.
6895        let rejected: &[&str] = &[
6896            "",
6897            " ",
6898            "pacote",
6899            "PACOTE",
6900            "molde",
6901            "MOLDE",
6902            "moldeposicional",
6903            "MoldePositional",
6904            "desconhecido",
6905            "DESCONHECIDO",
6906            "Unknown",
6907            "defcaixa",
6908            "defmolde",
6909            "?",
6910            "caixa-core / feira",
6911            "pleme-doc-gen",
6912            "nobody known",
6913            " Pacote",
6914            "Pacote ",
6915            "Pacote\n",
6916            "\"Pacote\"",
6917        ];
6918        for &input in rejected {
6919            let owned: String = input.to_string();
6920            assert_eq!(
6921                <CaixaDialeto as TryFrom<String>>::try_from(owned),
6922                Err(()),
6923                "TryFrom<String> impl on CaixaDialeto must reject the \
6924                 non-wire byte-string {input:?} with Err(()) — silent \
6925                 acceptance signals an accept-set widening off the \
6926                 paired CaixaDialeto::from_wire resolver"
6927            );
6928            // Cross-axis witness: the owned-`String` axis must agree
6929            // with the borrowed-`&str` axis on every rejected input —
6930            // the two paths share one substrate-primitive resolver by
6931            // construction.
6932            assert_eq!(
6933                <CaixaDialeto as TryFrom<String>>::try_from(input.to_string()),
6934                <CaixaDialeto as TryFrom<&str>>::try_from(input),
6935                "TryFrom<String> and TryFrom<&str> reverse-projection \
6936                 axes on CaixaDialeto must agree on the non-wire input \
6937                 {input:?} — divergence signals the owned-`String` and \
6938                 borrowed-`&str` reverse paths have drifted off the \
6939                 same substrate-primitive from_wire accessor"
6940            );
6941        }
6942    }
6943}