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 *owned-input, [`std::borrow::Cow<'static, [u8]>`] output*
2016/// byte-owned reverse projection on the second caixa-core-internal closed-set
2017/// fieldless typed enum peer ([`CaixaDialeto`]) — the [`Cow<'static, [u8]>`]
2018/// companion to the paired owned-input [`From<CaixaDialeto> for Vec<u8>`] impl
2019/// above on the same primitive, opening the `{Self, &Self} → Cow<'static, [u8]>`
2020/// byte-owned reverse-projection axis on this peer at the owned-input corner.
2021/// Routes byte-for-byte through the substrate-primitive
2022/// [`CaixaDialeto::as_str`] `pub const fn` accessor via
2023/// [`std::borrow::Cow::Borrowed`]`(dialeto.as_str().as_bytes())` — the four
2024/// `match` arms in [`Self::as_str`] resolve to `CAIXA_DIALETO_WIRE_*`
2025/// `pub const &'static str` bodies, so `.as_bytes()` returns `&'static [u8]`
2026/// by construction and the zero-alloc [`Cow::Borrowed`] arm is reachable
2027/// without a runtime allocation.
2028///
2029/// Extends the substrate-wide trait-idiomatic byte-owned reverse-projection
2030/// matrix onto the second caixa-core-internal closed-set fieldless typed enum
2031/// peer at the [`Cow<'static, [u8]>`] corner — mirroring the trajectory the
2032/// same axis walked on the structurally most fundamental peer
2033/// [`crate::CaixaKind`] (b3451c8) and the sibling M2-OTP-shape
2034/// [`crate::supervisor::RestartStrategy`] (7f81539) /
2035/// [`crate::supervisor::RestartPolicy`] (65f381b) / M3 mesh-primitive-defining
2036/// [`crate::aplicacao::PlacementStrategy`] (05e4054) /
2037/// [`crate::aplicacao::RateLimitUnit`] (ef00bea) /
2038/// [`crate::aplicacao::WitShape`] (4ae2ad4) peers. Rust's `From` trait carries
2039/// no blanket `impl<T: AsRef<[u8]>> From<T> for Cow<'static, [u8]>`, so every
2040/// closed-set fieldless typed enum peer that carries the paired [`Vec<u8>`]
2041/// axis but not the [`Cow<'static, [u8]>`] axis forces every
2042/// `Cow<'static, [u8]>`-parameterized call site through an open-coded
2043/// `Cow::Borrowed(dialeto.as_str().as_bytes())` composition whose type bounds
2044/// have no compile-time link back to the substrate primitive.
2045///
2046/// Pinned load-bearing by
2047/// [`tests::caixa_dialeto_from_into_owned_cow_bytes_routes_through_as_str_accessor`]
2048/// (byte-parity pin against [`CaixaDialeto::as_str`]`.as_bytes()` across the
2049/// four-arm [`CaixaDialeto::ALL`] accept-set on both owned and borrowed input
2050/// shapes, plus a [`std::borrow::Cow::Borrowed`] discriminator witness pinning
2051/// the zero-alloc arm, plus cross-axis witnesses against the paired [`Vec<u8>`]
2052/// byte-owned reverse-projection axis and the paired [`Cow<'static, str>`]
2053/// str-owned reverse-projection axis on the same primitive).
2054impl From<CaixaDialeto> for std::borrow::Cow<'static, [u8]> {
2055 fn from(dialeto: CaixaDialeto) -> std::borrow::Cow<'static, [u8]> {
2056 std::borrow::Cow::Borrowed(dialeto.as_str().as_bytes())
2057 }
2058}
2059
2060/// Trait-idiomatic *borrowed-input, [`std::borrow::Cow<'static, [u8]>`] output*
2061/// byte-owned reverse projection on the second caixa-core-internal closed-set
2062/// fieldless typed enum peer ([`CaixaDialeto`]) — the borrowed-input companion
2063/// to the paired owned-input [`From<CaixaDialeto> for std::borrow::Cow<'static,
2064/// [u8]>`] impl immediately above, closing the `{Self, &Self} → Cow<'static,
2065/// [u8]>` byte-owned reverse-projection family on this primitive at the
2066/// borrowed-input corner. Routes byte-for-byte through the same substrate-
2067/// primitive [`CaixaDialeto::as_str`] `pub const fn` accessor via
2068/// [`std::borrow::Cow::Borrowed`]`(dialeto.as_str().as_bytes())` — the
2069/// [`Cow::Borrowed`] arm is reachable on both input axes because
2070/// [`Self::as_str`] returns `&'static str` regardless of the input shape, so
2071/// no runtime allocation is forced on either corner.
2072///
2073/// Rust's `From` trait carries no blanket
2074/// `impl<T> From<&T> for U where U: From<T>` (nor an
2075/// `impl<T: AsRef<[u8]>> From<&T> for Cow<'static, [u8]>`), so every closed-
2076/// set fieldless typed enum peer that carries the paired owned-input axis but
2077/// not the borrowed-input axis forces every borrowed call site through a
2078/// spurious [`Copy`] deref (`Cow::<'static, [u8]>::from(*dialeto)`) or an
2079/// open-coded `Cow::Borrowed(dialeto.as_str().as_bytes())` whose type bounds
2080/// have no compile-time link to the substrate primitive. The borrowed-input
2081/// axis is the one a `CaixaDialeto::ALL.iter().map(Cow::<'static, [u8]>::from)`
2082/// pipe binds against (its iterator over `&'static [CaixaDialeto]` yields
2083/// `&CaixaDialeto`, not `CaixaDialeto`, so the owned-input axis alone forces
2084/// every such per-arm accept-set materializer through an explicit `.copied()`
2085/// restatement).
2086impl From<&CaixaDialeto> for std::borrow::Cow<'static, [u8]> {
2087 fn from(dialeto: &CaixaDialeto) -> std::borrow::Cow<'static, [u8]> {
2088 std::borrow::Cow::Borrowed(dialeto.as_str().as_bytes())
2089 }
2090}
2091
2092/// Trait-idiomatic *owned-input, [`Box<[u8]>`] output* byte-owned reverse
2093/// projection on the second caixa-core-internal closed-set fieldless typed
2094/// enum peer ([`CaixaDialeto`]) — extends the byte-owned reverse-projection
2095/// matrix onto this primitive at the [`Box<[u8]>`] corner, tracking the
2096/// trajectory the same axis walked on the structurally most fundamental
2097/// first-mover peer [`crate::CaixaKind`] (4f47901) and the M2/M3 sibling
2098/// peers [`crate::supervisor::RestartStrategy`] /
2099/// [`crate::supervisor::RestartPolicy`] (6bc74c9) /
2100/// [`crate::aplicacao::PlacementStrategy`] (fb48599) /
2101/// [`crate::aplicacao::RateLimitUnit`] (b22c283) /
2102/// [`crate::aplicacao::WitShape`] (c6fee5c). Routes byte-for-byte through
2103/// the substrate-primitive [`CaixaDialeto::as_str`] `pub const fn` accessor
2104/// via [`Box::<[u8]>::from`] on the returned `&'static str`'s
2105/// [`str::as_bytes`] — the four `match` arms in [`Self::as_str`] resolve to
2106/// `CAIXA_DIALETO_WIRE_*` `pub const &'static str` bodies, so a downstream
2107/// [`Box<[u8]>`] consumer (a future dialect-set admission-webhook rejection
2108/// body binding the four-arm accepted-dialect enumeration through the
2109/// fit-to-length `Box<[u8]>` slot, a future `bytes::Bytes::from(Box<[u8]>)`
2110/// framer that keeps the fit-to-length allocation reachable at the framer's
2111/// entry point) reaches the wire byte-string through this one trait
2112/// dispatch rather than an open-coded per-call-site
2113/// `Box::<[u8]>::from(dialeto.as_str().as_bytes())` composition whose type
2114/// bounds have no compile-time link back to the substrate primitive, or a
2115/// `Box::<[u8]>::from(Vec::<u8>::from(dialeto))` double-hop through the
2116/// sibling [`Vec<u8>`] axis.
2117///
2118/// The [`Box<[u8]>`] slot is the fit-to-length ownership corner of the
2119/// byte-owned family: unlike [`Vec<u8>`] (three-word header carrying a
2120/// heap-slack `cap ≥ len`), [`Box<[u8]>`] carries only a two-word
2121/// `(ptr, len)` fat pointer, so per-arm heap footprint on an accept-set
2122/// interner is `mem::size_of::<usize>() * 2` (16 on `x86_64`) rather than
2123/// `mem::size_of::<usize>() * 3` (24 on `x86_64`), the difference
2124/// [`Vec<u8>`]'s capacity slot forces on every allocation. Downstream
2125/// consumers that already carry `Box<[u8]>` in their public shape (a future
2126/// `bytes::Bytes::from(Box<[u8]>)` framer at the mesh-ingest boundary) then
2127/// reach this primitive without an intermediary [`Vec<u8>`] hop.
2128///
2129/// Pinned load-bearing by
2130/// [`tests::caixa_dialeto_from_into_owned_box_bytes_routes_through_as_str_accessor`]
2131/// (byte-parity pin against [`CaixaDialeto::as_str`]`.as_bytes()` across
2132/// the four-arm [`CaixaDialeto::ALL`] accept-set on both owned and borrowed
2133/// input shapes, fit-to-length length-check witness on both surfaces, plus
2134/// cross-axis witnesses against the paired [`Vec<u8>`] byte-owned axis,
2135/// the paired [`std::borrow::Cow<'static, [u8]>`] byte-owned axis, the
2136/// paired [`Box<str>`] str-owned axis, and the borrowed byte-view
2137/// [`AsRef<[u8]>`] axis on the same primitive).
2138impl From<CaixaDialeto> for Box<[u8]> {
2139 fn from(dialeto: CaixaDialeto) -> Box<[u8]> {
2140 Box::<[u8]>::from(dialeto.as_str().as_bytes())
2141 }
2142}
2143
2144/// Trait-idiomatic *borrowed-input, [`Box<[u8]>`] output* byte-owned
2145/// reverse projection on the second caixa-core-internal closed-set
2146/// fieldless typed enum peer ([`CaixaDialeto`]) — the borrowed-input
2147/// companion to the paired owned-input [`From<CaixaDialeto> for Box<[u8]>`]
2148/// impl immediately above, closing the `{Self, &Self} → Box<[u8]>`
2149/// byte-owned reverse-projection family on this primitive at the borrowed-
2150/// input corner. Routes byte-for-byte through the same substrate-primitive
2151/// [`CaixaDialeto::as_str`] `pub const fn` accessor via
2152/// [`Box::<[u8]>::from`] on the returned `&'static str`'s
2153/// [`str::as_bytes`] byte-view.
2154///
2155/// Rust's `From` trait carries no blanket `impl<T> From<&T> for U where
2156/// U: From<T>`, so every closed-set fieldless typed enum peer that carries
2157/// the paired owned-input axis but not the borrowed-input axis forces every
2158/// borrowed call site through a spurious [`Copy`] deref
2159/// (`Box::<[u8]>::from(*dialeto)`) or an open-coded
2160/// `Box::<[u8]>::from(dialeto.as_str().as_bytes())` whose type bounds have
2161/// no compile-time link to the substrate primitive. The borrowed-input axis
2162/// is the one a `CaixaDialeto::ALL.iter().map(Box::<[u8]>::from)` pipe
2163/// binds against — its iterator over `&'static [CaixaDialeto]` yields
2164/// `&CaixaDialeto`, not `CaixaDialeto`, so the owned-input axis alone
2165/// forces every per-arm accept-set materializer through an explicit
2166/// `.copied()` restatement.
2167impl From<&CaixaDialeto> for Box<[u8]> {
2168 fn from(dialeto: &CaixaDialeto) -> Box<[u8]> {
2169 Box::<[u8]>::from(dialeto.as_str().as_bytes())
2170 }
2171}
2172
2173/// Trait-idiomatic *owned-input, [`std::sync::Arc<[u8]>`] output* byte-owned
2174/// reverse projection on the second caixa-core-internal closed-set fieldless
2175/// typed enum peer ([`CaixaDialeto`]) — extends the byte-owned reverse-
2176/// projection matrix onto this primitive at the [`std::sync::Arc<[u8]>`]
2177/// corner, tracking the trajectory the same axis walked on the structurally
2178/// most fundamental first-mover peer [`crate::CaixaKind`] (d8872df), the
2179/// M2-OTP-shape [`crate::supervisor::RestartStrategy`] (98da8f6) /
2180/// [`crate::supervisor::RestartPolicy`] (bbb78ee) supervisor-slot peers, and
2181/// the M3-mesh-primitive-defining [`crate::aplicacao::PlacementStrategy`]
2182/// (64cdf90) / [`crate::aplicacao::RateLimitUnit`] (e872c77) /
2183/// [`crate::aplicacao::WitShape`] (d2976c2) peers. Routes byte-for-byte
2184/// through the substrate-primitive [`CaixaDialeto::as_str`] `pub const fn`
2185/// accessor via [`std::sync::Arc::<[u8]>::from`] on the returned
2186/// `&'static str`'s [`str::as_bytes`] — the four `match` arms in
2187/// [`Self::as_str`] resolve to `CAIXA_DIALETO_WIRE_*` `pub const &'static
2188/// str` bodies, so `.as_bytes()` returns `&'static [u8]` by construction and
2189/// the standard-library [`std::sync::Arc::<[u8]>::from(&[u8])`] impl
2190/// allocates an atomically-refcounted heap slab whose header carries the
2191/// strong + weak counters the [`std::sync::Arc<[u8]>`] layout requires in
2192/// one heap allocation without an intermediary [`Vec<u8>`] or [`Box<[u8]>`].
2193///
2194/// A future [`std::sync::Arc<[u8]>`]-typed consumer on a [`CaixaDialeto`] —
2195/// a future M4 admission-webhook per-request per-caixa `:dialect`
2196/// classification-tag byte-tail fanned out across a `tokio::spawn`ed worker
2197/// pool through pointer-width [`std::sync::Arc::clone`] handles (an atomic
2198/// refcount bump, cheaper than a fresh [`Box<[u8]>`] allocation on hot per-
2199/// reconcile-tick call sites), a future thread-safe
2200/// `HashMap::<std::sync::Arc<[u8]>, _>::from_iter` per-dialect lookup keyed
2201/// by the wire byte-tail across the caixa-build classifier's per-file fan-
2202/// out cache, a future `Send`-bound audit-report emitter that ships the
2203/// wire byte-string across a channel through the [`std::sync::Arc<[u8]>`]
2204/// slot — reaches the wire byte-string through this one dispatch, without
2205/// the pre-lift `Box::<[u8]>::from(dialeto).into()` or
2206/// `Arc::<[u8]>::from(Vec::<u8>::from(dialeto))` double-hop that would
2207/// still allocate the same [`Arc<[u8]>`] slab plus one intermediary
2208/// [`Box<[u8]>`] or [`Vec<u8>`] between the enum peer and the
2209/// [`std::sync::Arc<[u8]>`] slot.
2210///
2211/// Rust's standard library does not derive `From<Self> for Arc<[u8]>` from
2212/// `From<Self> for Box<[u8]>` (nor from `From<Self> for Vec<u8>`), so every
2213/// closed-set fieldless typed enum peer that carries the paired
2214/// [`Box<[u8]>`] axis but not the paired [`Arc<[u8]>`] axis forces every
2215/// [`Arc<[u8]>`]-typed call site through a `Box::<[u8]>::from(dialeto).into()`
2216/// / `Arc::<[u8]>::from(Vec::<u8>::from(dialeto))` intermediary allocation
2217/// whose bounds carry no compile-time link back to the substrate primitive.
2218///
2219/// Pinned load-bearing by
2220/// [`tests::caixa_dialeto_from_into_owned_arc_bytes_routes_through_as_str_accessor`]
2221/// (byte-parity pin against [`CaixaDialeto::as_str`]`.as_bytes()` across the
2222/// four-arm [`CaixaDialeto::ALL`] accept-set on both owned and borrowed
2223/// input shapes, fit-to-length length-check witness on both surfaces, plus
2224/// cross-axis witnesses against the paired [`Vec<u8>`],
2225/// [`std::borrow::Cow<'static, [u8]>`], [`Box<[u8]>`] byte-owned axes, the
2226/// paired [`std::sync::Arc<str>`] str-side axis, and the borrowed byte-view
2227/// [`AsRef<[u8]>`] axis on the same primitive).
2228impl From<CaixaDialeto> for std::sync::Arc<[u8]> {
2229 fn from(dialeto: CaixaDialeto) -> std::sync::Arc<[u8]> {
2230 std::sync::Arc::<[u8]>::from(dialeto.as_str().as_bytes())
2231 }
2232}
2233
2234/// Trait-idiomatic *borrowed-input, [`std::sync::Arc<[u8]>`] output* byte-
2235/// owned reverse projection on the second caixa-core-internal closed-set
2236/// fieldless typed enum peer ([`CaixaDialeto`]) — the borrowed-input
2237/// companion to the paired owned-input
2238/// [`From<CaixaDialeto> for std::sync::Arc<[u8]>`] impl immediately above,
2239/// closing the `{Self, &Self} → std::sync::Arc<[u8]>` byte-owned reverse-
2240/// projection family on this primitive at the borrowed-input corner in one
2241/// lift. Routes byte-for-byte through the same substrate-primitive
2242/// [`CaixaDialeto::as_str`] `pub const fn` accessor via
2243/// [`std::sync::Arc::<[u8]>::from`] on the returned `&'static str`'s
2244/// [`str::as_bytes`] — the [`std::sync::Arc<[u8]>`] allocation happens on
2245/// both input axes because [`Self::as_str`] returns `&'static str`
2246/// regardless of the input shape, so the borrowed-input peer reaches the
2247/// same wire byte-string through the same one-heap-allocation path the
2248/// owned-input peer already carries.
2249///
2250/// Rust's `From` trait carries no blanket `impl<T> From<&T> for U where
2251/// U: From<T>` (nor a `Copy`-based `impl<T: Copy, U: From<T>> From<&T>
2252/// for U`), so every closed-set fieldless typed enum peer that carries the
2253/// paired owned-input [`std::sync::Arc<[u8]>`] axis but not the borrowed-
2254/// input axis forces every borrowed call site through a spurious [`Copy`]
2255/// deref (`std::sync::Arc::<[u8]>::from(*dialeto)`) or an open-coded
2256/// `std::sync::Arc::<[u8]>::from(dialeto.as_str().as_bytes())` whose type
2257/// bounds have no compile-time link to the substrate primitive. The
2258/// borrowed-input axis is the one a
2259/// `CaixaDialeto::ALL.iter().map(std::sync::Arc::<[u8]>::from)` pipe binds
2260/// against (its iterator over `&'static [CaixaDialeto]` yields
2261/// `&CaixaDialeto`, not `CaixaDialeto`), so the owned-input axis alone
2262/// forces every such per-arm accept-set materializer through an explicit
2263/// `.copied()` restatement.
2264impl From<&CaixaDialeto> for std::sync::Arc<[u8]> {
2265 fn from(dialeto: &CaixaDialeto) -> std::sync::Arc<[u8]> {
2266 std::sync::Arc::<[u8]>::from(dialeto.as_str().as_bytes())
2267 }
2268}
2269
2270/// Trait-idiomatic *owned-input, [`std::rc::Rc<[u8]>`] output* byte-owned
2271/// reverse projection on the second caixa-core-internal closed-set
2272/// fieldless typed enum peer ([`CaixaDialeto`]) — the single-threaded-
2273/// refcounted byte-slice mirror of the paired owned-input
2274/// [`From<CaixaDialeto> for std::rc::Rc<str>`] impl on the string-side
2275/// reverse-projection matrix, and the fifth (and final) axis on the byte-
2276/// side reverse-projection matrix that already carries
2277/// [`From<CaixaDialeto> for Vec<u8>`],
2278/// [`From<CaixaDialeto> for std::borrow::Cow<'static, [u8]>`] (92a8777),
2279/// [`From<CaixaDialeto> for Box<[u8]>`] (61f5ecb), and
2280/// [`From<CaixaDialeto> for std::sync::Arc<[u8]>`] (cca8d7c). Routes byte-
2281/// for-byte through the substrate-primitive [`CaixaDialeto::as_str`] `pub
2282/// const fn` accessor via [`std::rc::Rc::<[u8]>::from`] on the returned
2283/// `&'static str`'s [`str::as_bytes`] — the four `match` arms in
2284/// [`Self::as_str`] resolve to the `CAIXA_DIALETO_WIRE_*` `pub const
2285/// &'static str` bodies, so `.as_bytes()` returns `&'static [u8]` by
2286/// construction, and the standard-library
2287/// [`std::rc::Rc::<[u8]>::from(&[u8])`] impl allocates a fresh single-
2288/// threaded-refcounted heap slab whose header carries the non-atomic
2289/// strong-and-weak counters the [`std::rc::Rc<[u8]>`] layout requires in
2290/// one heap allocation without an intermediary [`Vec<u8>`], [`Box<[u8]>`],
2291/// or [`std::sync::Arc<[u8]>`].
2292///
2293/// A future [`std::rc::Rc<[u8]>`]-typed consumer on a [`CaixaDialeto`] — a
2294/// single-threaded `feira lint` per-file per-caixa `:dialect` classification-
2295/// tag byte-tail carried through a chain of Nord-themed diagnostic emitters
2296/// via the pointer-width [`std::rc::Rc::clone`] handle (a non-atomic
2297/// refcount bump, cheaper than the paired atomic increment on the sibling
2298/// [`std::sync::Arc<[u8]>`] axis by a measurable margin on hot single-
2299/// threaded call sites), a future single-threaded
2300/// `HashMap::<std::rc::Rc<[u8]>, _>::from_iter` per-dialect lookup keyed
2301/// by the wire byte-string across the `feira build` parser's per-caixa
2302/// fan-out cache, a future non-`Send` `feira app graph` renderer that
2303/// materializes decoded dialect classification bytes as
2304/// [`std::rc::Rc<[u8]>`] slices so downstream single-threaded emitters
2305/// share the immutable byte-tail without a per-consumer
2306/// [`Vec::<u8>::clone`] — reaches the wire byte-string through this one
2307/// dispatch, without the pre-lift `Box::<[u8]>::from(dialeto).into()` or
2308/// `Rc::<[u8]>::from(Vec::<u8>::from(dialeto))` double-hop that would
2309/// still allocate the same [`Rc<[u8]>`] slab plus one intermediary
2310/// [`Box<[u8]>`] or [`Vec<u8>`] between the enum peer and the
2311/// [`std::rc::Rc<[u8]>`] slot.
2312///
2313/// Rust's standard library does not derive `From<Self> for Rc<[u8]>` from
2314/// `From<Self> for Arc<[u8]>` (the two layouts share the same on-disk
2315/// shape but the trait tables are disjoint, and no blanket
2316/// `impl<T> From<T> for Rc<[u8]> where Arc<[u8]>: From<T>` exists in
2317/// `core`), so every closed-set fieldless typed enum peer that carries
2318/// the paired [`Arc<[u8]>`] axis but not the paired [`Rc<[u8]>`] axis
2319/// forces every single-threaded [`Rc<[u8]>`]-typed call site through a
2320/// `Arc::<[u8]>::from(dialeto).into()` /
2321/// `Rc::<[u8]>::from(Vec::<u8>::from(dialeto))` double-allocation detour
2322/// whose bounds carry no compile-time link back to the substrate primitive.
2323///
2324/// Closes the trait-idiomatic *owned-input* byte-family reverse-projection
2325/// matrix on the second caixa-core-internal closed-set fieldless typed
2326/// enum peer at the [`std::rc::Rc<[u8]>`] corner — completing the full
2327/// `{Vec<u8>, Cow<'static, [u8]>, Box<[u8]>, Arc<[u8]>, Rc<[u8]>}` five-
2328/// corner partition on [`CaixaDialeto`], mirroring the trajectory the
2329/// same axis walked on the sibling third M3-mesh-primitive-defining
2330/// [`crate::aplicacao::WitShape`] peer (5569794 closed its Rc<[u8]>
2331/// corner), on the sibling second M3-mesh-primitive-defining
2332/// [`crate::aplicacao::RateLimitUnit`] peer (15d22b1 closed its Rc<[u8]>
2333/// corner), on the sibling first M3-mesh-primitive-defining
2334/// [`crate::aplicacao::PlacementStrategy`] peer (3d8170c closed its
2335/// Rc<[u8]> corner), on the sibling [`crate::CaixaKind`] structurally
2336/// most fundamental closed-set fieldless typed-enum peer (db8dcc2 closed
2337/// its Rc<[u8]> corner), and on the M2-OTP-shape
2338/// [`crate::supervisor::RestartStrategy`] (2620e42) and
2339/// [`crate::supervisor::RestartPolicy`] (6848c05) peers.
2340///
2341/// Pinned load-bearing by
2342/// [`tests::caixa_dialeto_from_into_owned_rc_bytes_routes_through_as_str_accessor`]
2343/// (byte-parity pin against [`CaixaDialeto::as_str`]`.as_bytes()` across
2344/// the four-arm [`CaixaDialeto::ALL`] accept-set on both owned and
2345/// borrowed input shapes, fit-to-length length-check witness on both
2346/// surfaces, plus cross-axis witnesses against the paired [`Vec<u8>`],
2347/// [`std::borrow::Cow<'static, [u8]>`], [`Box<[u8]>`],
2348/// [`std::sync::Arc<[u8]>`] byte-owned axes, the paired
2349/// [`std::rc::Rc<str>`] str-side axis, and the borrowed byte-view
2350/// [`AsRef<[u8]>`] axis on the same primitive).
2351impl From<CaixaDialeto> for std::rc::Rc<[u8]> {
2352 fn from(dialeto: CaixaDialeto) -> std::rc::Rc<[u8]> {
2353 std::rc::Rc::<[u8]>::from(dialeto.as_str().as_bytes())
2354 }
2355}
2356
2357/// Trait-idiomatic *borrowed-input, [`std::rc::Rc<[u8]>`] output* byte-
2358/// owned reverse projection on the second caixa-core-internal closed-set
2359/// fieldless typed enum peer ([`CaixaDialeto`]) — the borrowed-input
2360/// companion to the paired owned-input
2361/// [`From<CaixaDialeto> for std::rc::Rc<[u8]>`] impl immediately above,
2362/// closing the `{Self, &Self} → std::rc::Rc<[u8]>` byte-owned reverse-
2363/// projection family on this primitive at the borrowed-input corner in
2364/// one lift. Routes byte-for-byte through the same substrate-primitive
2365/// [`CaixaDialeto::as_str`] `pub const fn` accessor via
2366/// [`std::rc::Rc::<[u8]>::from`] on the returned `&'static str`'s
2367/// [`str::as_bytes`] — the [`std::rc::Rc<[u8]>`] allocation happens on
2368/// both input axes because [`Self::as_str`] returns `&'static str`
2369/// regardless of the input shape, so the borrowed-input peer reaches the
2370/// same wire byte-string through the same one-heap-allocation path the
2371/// owned-input peer already carries.
2372///
2373/// Rust's `From` trait carries no blanket `impl<T> From<&T> for U where
2374/// U: From<T>` (nor a `Copy`-based `impl<T: Copy, U: From<T>> From<&T>
2375/// for U`), so every closed-set fieldless typed enum peer that carries
2376/// the paired owned-input [`std::rc::Rc<[u8]>`] axis but not the
2377/// borrowed-input axis forces every borrowed call site through a spurious
2378/// [`Copy`] deref (`std::rc::Rc::<[u8]>::from(*dialeto)`) or an open-coded
2379/// `std::rc::Rc::<[u8]>::from(dialeto.as_str().as_bytes())` whose type
2380/// bounds have no compile-time link to the substrate primitive. The
2381/// borrowed-input axis is the one a
2382/// `CaixaDialeto::ALL.iter().map(std::rc::Rc::<[u8]>::from)` pipe binds
2383/// against (its iterator over `&'static [CaixaDialeto]` yields
2384/// `&CaixaDialeto`, not `CaixaDialeto`), so the owned-input axis alone
2385/// forces every such per-arm accept-set materializer through an explicit
2386/// `.copied()` restatement.
2387impl From<&CaixaDialeto> for std::rc::Rc<[u8]> {
2388 fn from(dialeto: &CaixaDialeto) -> std::rc::Rc<[u8]> {
2389 std::rc::Rc::<[u8]>::from(dialeto.as_str().as_bytes())
2390 }
2391}
2392
2393/// Trait-idiomatic *borrowed byte-slice input* reverse projection on the
2394/// second caixa-core-internal closed-set fieldless typed enum peer
2395/// ([`CaixaDialeto`]) — the byte-view mirror of the str-view reverse-
2396/// projection axis carried by the paired [`TryFrom<&str> for CaixaDialeto`]
2397/// impl (which routes through the substrate-primitive
2398/// [`CaixaDialeto::from_wire`] `Option<Self>` accessor on the four-arm
2399/// `PascalCase` accept-set the sibling [`CaixaDialeto::as_str`] emitter
2400/// returns). Routes byte-for-byte through the standard-library
2401/// [`std::str::from_utf8`] UTF-8 validator and then through
2402/// [`CaixaDialeto::from_wire`] so every consumer that holds a borrowed
2403/// [`&[u8]`] and needs to project it back into a typed [`CaixaDialeto`] —
2404/// a future `bytes::Bytes::as_ref()`-fed reader that parses a per-caixa
2405/// `:dialect` classification tag from an already-borrowed framing byte-
2406/// tail (a `tracing::field::valuable::Value::Bytes` recorder on the
2407/// caixa-build pipeline's per-file classify emission path, a future audit-
2408/// report re-loader binding a prior [`CaixaDialeto::as_str`] output from a
2409/// mmap'd byte-slice back through the typed enum for cross-run
2410/// comparison), a future admission-webhook rejection body that reads a
2411/// `spec.dialeto` field off a raw HTTP body byte-slice before UTF-8
2412/// validation commits allocation, a future generic
2413/// `<T: for<'a> TryFrom<&'a [u8]>>`-bound loader over any of the
2414/// substrate's closed-set typed enums — reaches the same four-arm
2415/// `PascalCase` wire accept-set the sibling method-named
2416/// [`CaixaDialeto::from_wire`] resolver and the paired trait-idiomatic
2417/// [`TryFrom<&str>`] axis already resolve against, rather than an open-
2418/// coded per-call-site
2419/// `std::str::from_utf8(bytes).ok().and_then(CaixaDialeto::from_wire)`
2420/// composition or a
2421/// `<CaixaDialeto as TryFrom<&str>>::try_from(std::str::from_utf8(bytes)?)`
2422/// two-hop shape whose type bounds have no compile-time link to the
2423/// substrate primitive.
2424///
2425/// Extends the substrate-wide trait-idiomatic *byte-view reverse-
2426/// projection* family — opened on the structurally most fundamental
2427/// closed-set fieldless typed enum peer ([`crate::CaixaKind`], commit
2428/// 18d1940) — onto the second caixa-core-internal closed-set fieldless
2429/// typed enum peer, tracking the "route through `from_wire` via
2430/// `std::str::from_utf8`" discipline the first-mover established. Rust's
2431/// standard library carries no blanket
2432/// `impl<T: for<'a> TryFrom<&'a str>> TryFrom<&[u8]> for T`, so a two-hop
2433/// composition through [`std::str::from_utf8`] + the paired
2434/// [`TryFrom<&str>`] axis is reachable at every call site but has no
2435/// compile-time link back to the byte-view reverse-projection axis. Every
2436/// future closed-set fieldless typed enum peer on the substrate
2437/// ([`crate::dep::DepList`], [`crate::supervisor::RestartStrategy`],
2438/// [`crate::supervisor::RestartPolicy`],
2439/// [`crate::aplicacao::PlacementStrategy`],
2440/// [`crate::aplicacao::RateLimitUnit`], [`crate::aplicacao::WitShape`],
2441/// and the outside-`caixa-core` peers `PathShapeViolation`,
2442/// `InvariantKind`, `ArchVerdict`, `Severity`, `FixSafety`, `Semantic`,
2443/// `FerriteRuntime`) is a future target of the campaign, mirroring the
2444/// trajectory the closed byte-owned reverse-projection family walked
2445/// arm-by-arm onto each peer.
2446///
2447/// `type Error = ()` matches the sibling [`CaixaDialeto::from_wire`]'s
2448/// `Option<Self>` return-shape's deliberate deferral of error typing and
2449/// the paired trait-idiomatic [`TryFrom<&str>`] axis's unit-error shape —
2450/// the caller picks the diagnostic form appropriate for its use site (a
2451/// future `feira dialeto --filter` arg-parse composes its own per-verb
2452/// "unknown dialect: <arg> — accepted: {…}" message enumerating
2453/// [`CaixaDialeto::ALL`]; a future admission-webhook rejection body wraps
2454/// the `Err(())` outcome with the accepted-set enumeration for operator
2455/// diagnostics; a `Result::map_err` at the call site lifts the unit-error
2456/// to a per-verb error type). Two rejection paths route through the
2457/// single unit-error: an invalid UTF-8 byte-sequence
2458/// ([`std::str::from_utf8`] returns `Err`) and a valid UTF-8 byte-string
2459/// that falls outside the four-arm `PascalCase` accept-set
2460/// ([`CaixaDialeto::from_wire`] returns `None`) — both collapse onto
2461/// `Err(())` so the trait signature stays consistent with the sibling
2462/// str-view reverse axis, and a caller that needs to distinguish the two
2463/// failure modes composes [`std::str::from_utf8`] +
2464/// [`CaixaDialeto::from_wire`] explicitly.
2465///
2466/// Pinned load-bearing by
2467/// [`tests::caixa_dialeto_try_from_bytes_routes_through_from_wire_accessor`]
2468/// (byte-parity pin against [`CaixaDialeto::from_wire`] across the four-
2469/// arm [`CaixaDialeto::ALL`] accept-set on the borrowed byte-slice
2470/// surface, plus a cross-axis witness that the byte-view reverse
2471/// projection agrees with the paired [`TryFrom<&str>`] str-view reverse
2472/// axis on every accepted arm) and
2473/// [`tests::caixa_dialeto_try_from_bytes_rejects_unknown_and_non_utf8_bytes`]
2474/// (rejection witness against silent accept-set widening on both the
2475/// non-UTF-8 byte-sequence rejection path and the unknown-wire-vocabulary
2476/// rejection path).
2477impl TryFrom<&[u8]> for CaixaDialeto {
2478 type Error = ();
2479
2480 fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
2481 std::str::from_utf8(bytes)
2482 .ok()
2483 .and_then(Self::from_wire)
2484 .ok_or(())
2485 }
2486}
2487
2488/// Trait-idiomatic *owned byte-vec input* reverse projection on the
2489/// second caixa-core-internal closed-set fieldless typed enum peer
2490/// ([`CaixaDialeto`]) — the owned-input peer of
2491/// [`TryFrom<&[u8]> for CaixaDialeto`], mirroring the closed
2492/// [`From<CaixaDialeto> for Vec<u8>`] + [`From<&CaixaDialeto> for Vec<u8>`]
2493/// byte-owned *forward*-projection pair on this same enum onto the
2494/// byte-owned *reverse*-projection axis. Routes byte-for-byte through
2495/// [`<Self as TryFrom<&[u8]>>::try_from`] on the [`Vec<u8>::as_slice`]
2496/// borrow, so the owned-input surface reaches the same
2497/// [`std::str::from_utf8`] + [`CaixaDialeto::from_wire`] resolution chain
2498/// the borrowed-input peer already carries — one substrate-primitive
2499/// accessor, one trait dispatch, no per-consumer detour.
2500///
2501/// Rust's standard library carries no blanket
2502/// `impl<T: for<'a> TryFrom<&'a [u8]>> TryFrom<Vec<u8>> for T`, so a
2503/// consumer that holds an owned [`Vec<u8>`] and needs a typed
2504/// [`CaixaDialeto`] otherwise picks between (a) an open-coded
2505/// `<CaixaDialeto as TryFrom<&[u8]>>::try_from(bytes.as_slice())` at
2506/// every call site (whose type bounds have no compile-time link to the
2507/// byte-owned reverse-projection axis), (b) a two-hop
2508/// `String::from_utf8(bytes)` + [`CaixaDialeto::from_wire`] composition
2509/// whose error surface leaks the standard-library [`std::string::FromUtf8Error`]
2510/// (widening the sibling [`TryFrom<&[u8]>`] axis's unit-error) and
2511/// silently allocates a [`String`] on inputs that will never make it
2512/// past the wire vocabulary, or (c) an intermediate
2513/// `<CaixaDialeto as TryFrom<&str>>::try_from(std::str::from_utf8(&bytes)?)`
2514/// three-hop shape. This impl closes the owned-byte-vec reverse-
2515/// projection axis at the substrate-primitive
2516/// [`CaixaDialeto::from_wire`] accessor so every future
2517/// `<T: TryFrom<Vec<u8>>>`-bound owned-byte-vec consumer — a future
2518/// admission-webhook body reader that hands raw request bytes off as
2519/// a [`Vec<u8>`] before UTF-8 validation commits, a future
2520/// `std::io::Read::read_to_end`-shape audit-log source whose framing
2521/// yields an owned byte-vec per frame, a future protobuf/CBOR/msgpack
2522/// per-field decoder whose bytes arm surfaces an owned [`Vec<u8>`]
2523/// before dispatch, a `bytes::Bytes::to_vec()`-shape wire-body
2524/// composer walking a prior audit's payload back to the typed enum,
2525/// an `<T: TryFrom<Vec<u8>>>`-bound generic loader over any of the
2526/// substrate's closed-set typed enums — reaches the same four-arm
2527/// `PascalCase` wire accept-set through one trait dispatch.
2528///
2529/// Extends the substrate-wide trait-idiomatic *byte-owned reverse-
2530/// projection* family onto the second caixa-core-internal closed-set
2531/// fieldless typed enum peer, tracking the trajectory the sibling
2532/// first-mover [`TryFrom<Vec<u8>> for CaixaKind`] (99c2849) opened on
2533/// the structurally most fundamental enum. Peer of the sibling closed
2534/// byte-view reverse-projection family (`TryFrom<&[u8]>`; extended
2535/// onto this enum d102cb8) and of the closed byte-owned forward-
2536/// projection family (`From<{Self, &Self}> for Vec<u8>`; extended
2537/// onto this enum on the same commit as its `TryFrom<&[u8]>` peer)
2538/// on this same enum — the {owned-input, borrowed-input} ×
2539/// {owned-output byte-vec, borrowed-output byte-slice} byte-view
2540/// reverse-projection square now closes on [`CaixaDialeto`].
2541///
2542/// `type Error = ()` matches the sibling [`TryFrom<&[u8]> for CaixaDialeto`]
2543/// unit-error shape, preserving the trait-family consistency across
2544/// the borrowed-and-owned byte-view reverse-projection pair. Both
2545/// rejection paths (invalid UTF-8, valid-UTF-8-but-unknown-wire)
2546/// collapse onto `Err(())` through the delegated borrowed axis.
2547/// The owned [`Vec<u8>`] input is dropped on the error path (the
2548/// standard-library `String::from_utf8` convention of returning the
2549/// input in the error deliberately declined — a caller that needs
2550/// the bytes back holds a clone before the call, and the closed-set-
2551/// enum use site rarely wants the raw bytes back past a "did you
2552/// mean" diagnostic that operates on the wire vocabulary rather than
2553/// the input).
2554///
2555/// Unlike the peer [`TryFrom<Vec<u8>> for crate::CaixaKind`] (which
2556/// carries a wire-vs-diagnostic two-axis split — `as_str` lowercase
2557/// Portuguese vs `wire_name` `PascalCase`), [`CaixaDialeto`] has no
2558/// such split: [`Self::as_str`] and [`Self::from_wire`] operate on
2559/// the same four-arm `PascalCase` byte-vocabulary
2560/// (`"Pacote"`, `"Molde"`, `"MoldePosicional"`, `"Desconhecido"`).
2561/// So on this enum the byte-owned reverse-projection axis *can*
2562/// round-trip against the paired byte-owned forward-projection pair
2563/// ([`From<CaixaDialeto> for Vec<u8>`], [`From<&CaixaDialeto> for
2564/// Vec<u8>`]) — a four-corner witness the pinned load-bearing test
2565/// makes explicit, and a witness the sibling
2566/// [`TryFrom<Vec<u8>> for crate::CaixaKind`] axis deliberately
2567/// declines.
2568///
2569/// Pinned load-bearing by
2570/// [`tests::caixa_dialeto_try_from_vec_bytes_routes_through_borrowed_byte_view_axis`]
2571/// (byte-parity pin against the paired borrowed [`TryFrom<&[u8]>`]
2572/// axis across the four-arm [`CaixaDialeto::ALL`] accept-set on the
2573/// owned byte-vec surface, plus a cross-axis witness that the byte-
2574/// owned reverse projection agrees with the paired str-view reverse-
2575/// projection axis ([`TryFrom<&str>`]) on every accepted arm through
2576/// the shared substrate-primitive [`CaixaDialeto::from_wire`]
2577/// accessor, plus a four-corner {owned-input, borrowed-input} ×
2578/// {owned-output byte-vec, borrowed-output byte-slice} round-trip
2579/// witness against the paired [`From<{Self, &Self}> for Vec<u8>`]
2580/// byte-owned forward-projection pair) and
2581/// [`tests::caixa_dialeto_try_from_vec_bytes_rejects_unknown_and_non_utf8_bytes`]
2582/// (rejection witness against silent accept-set widening on both the
2583/// non-UTF-8 byte-sequence rejection path and the unknown-wire-
2584/// vocabulary rejection path, plus a cross-axis witness that the
2585/// owned byte-vec reverse-projection axis agrees with the borrowed
2586/// byte-slice reverse-projection axis on every rejected input).
2587impl TryFrom<Vec<u8>> for CaixaDialeto {
2588 type Error = ();
2589
2590 fn try_from(bytes: Vec<u8>) -> Result<Self, Self::Error> {
2591 <Self as TryFrom<&[u8]>>::try_from(bytes.as_slice())
2592 }
2593}
2594
2595/// Trait-idiomatic *owned-`String` input, `Result<Self, ()>` output*
2596/// string-owned reverse projection on the second caixa-core-internal
2597/// closed-set fieldless typed enum peer ([`CaixaDialeto`]) — the owned-
2598/// input peer of the paired [`TryFrom<&str> for CaixaDialeto`] str-view
2599/// reverse-projection axis (which routes through the substrate-primitive
2600/// [`CaixaDialeto::from_wire`] `Option<Self>` accessor on the four-arm
2601/// `PascalCase` accept-set the sibling [`CaixaDialeto::as_str`] emitter
2602/// returns), and the string-owned reverse companion of the pre-existing
2603/// string-owned *forward*-projection pair ([`From<CaixaDialeto> for
2604/// String`] / [`From<&CaixaDialeto> for String`]) already lifted on this
2605/// same enum. Routes owned [`String`] input byte-for-byte through the
2606/// paired borrowed-input [`TryFrom<&str>`] axis via [`String::as_str`],
2607/// so every consumer that holds an owned [`String`] and needs a typed
2608/// [`CaixaDialeto`] — a future admission-webhook body reader that hands
2609/// a per-manifest `spec.dialeto` `PascalCase` scalar off as an owned
2610/// [`String`] after UTF-8 validation commits allocation, a
2611/// `serde_yaml::from_str` / `serde_json::from_str` de-serialize composer
2612/// that surfaces the classification scalar as an owned [`String`] typed
2613/// field, a future
2614/// `feira dialeto --filter <Pacote|Molde|MoldePosicional|Desconhecido>`
2615/// `clap`-derived arg-parse whose owned-`String` positional lands the
2616/// canonical arm at the typed dispatch, a per-caixa overlay resolver
2617/// reading an owned [`String`] out of a `ConfigMap` `data.dialeto`
2618/// scalar, a dialect-partitioned census-column loader that walks a
2619/// `Vec<String>` of prior [`CaixaDialeto::as_str`] outputs, an
2620/// `<T: TryFrom<String>>`-bound generic loader over any of the
2621/// substrate's closed-set typed enums — reaches the same four-arm
2622/// `PascalCase` wire accept-set through one trait dispatch off the
2623/// shared [`CaixaDialeto::from_wire`] substrate primitive.
2624///
2625/// Extends the substrate-wide trait-idiomatic *string-owned reverse-
2626/// projection* family — opened on the compound M3-mesh
2627/// `:politicas :rate-limit` primitive [`crate::aplicacao::RateLimit`]
2628/// (a2e6f02), lifted onto the first closed-set fieldless typed-enum
2629/// peer [`crate::aplicacao::WitShape`] (e6aac29), extended onto the
2630/// second closed-set fieldless typed-enum peer
2631/// [`crate::aplicacao::RateLimitUnit`] (94a9c5e), extended onto the
2632/// third closed-set fieldless typed-enum peer
2633/// [`crate::aplicacao::PlacementStrategy`] (d81a70a), extended onto the
2634/// first M2-OTP-shape supervisor-slot closed-set fieldless typed-enum
2635/// peer [`crate::supervisor::RestartStrategy`] (78fe8c8), closed on the
2636/// M2-OTP-shape supervisor-slot pair by
2637/// [`crate::supervisor::RestartPolicy`] (35dea5a), and extended onto
2638/// the structurally most fundamental caixa-core enum peer
2639/// [`crate::CaixaKind`] (e7df24f) — onto the second caixa-core-internal
2640/// closed-set fieldless typed-enum peer, the per-caixa dialect
2641/// discriminator every [`crate::Caixa`] carries through its parsed
2642/// manifest form. This mirrors the trajectory the byte-view (d102cb8)
2643/// / byte-owned (83a1526) / str-view reverse-projection families
2644/// already walked on this same enum. Leaves [`crate::dep::DepList`] as
2645/// the remaining `TryFrom<String>` target on the caixa-core-internal
2646/// closed-set peer census.
2647///
2648/// Rust's standard library carries no blanket
2649/// `impl<T: for<'a> TryFrom<&'a str>> TryFrom<String> for T`, so a
2650/// consumer that holds an owned [`String`] and needs a typed
2651/// [`CaixaDialeto`] otherwise picks between (a) an open-coded
2652/// `<CaixaDialeto as TryFrom<&str>>::try_from(s.as_str())` at every
2653/// call site whose type bounds have no compile-time link back to the
2654/// string-owned reverse-projection axis, (b) a `let s: &str = &s;
2655/// CaixaDialeto::try_from(s)` two-step whose borrow arithmetic leaks a
2656/// per-call-site lifetime dance rather than a single trait dispatch, or
2657/// (c) a `String::into_bytes` + [`TryFrom<Vec<u8>>`] detour that
2658/// reaches the substrate-primitive `from_wire` accessor through a
2659/// UTF-8 re-validation hop the owned-`String` axis already knows to
2660/// skip. This impl closes the string-owned reverse-projection axis at
2661/// the substrate-primitive [`CaixaDialeto::from_wire`] accessor so
2662/// every future `<T: TryFrom<String>>`-bound owned-string consumer
2663/// reaches the same four-arm `PascalCase` accept-set through one
2664/// trait dispatch.
2665///
2666/// `type Error = ()` matches the sibling [`TryFrom<&str> for CaixaDialeto`],
2667/// [`TryFrom<&[u8]> for CaixaDialeto`], and [`TryFrom<Vec<u8>> for CaixaDialeto`]
2668/// unit-error shapes, preserving the trait-family consistency across
2669/// the {str-view, byte-view, byte-owned, string-owned} reverse-
2670/// projection square. The owned [`String`] input is dropped on the
2671/// error path (the standard-library `String::from_utf8` convention of
2672/// returning the input in the error deliberately declined — a caller
2673/// that needs the string back holds a clone before the call, and the
2674/// closed-set-enum use site rarely wants the raw string back past a
2675/// "did you mean" diagnostic that operates on the wire vocabulary
2676/// rather than the input).
2677///
2678/// Unlike the peer [`crate::CaixaKind`] axis (whose paired string-owned
2679/// *forward* projection ([`From<CaixaKind> for String`]) emits
2680/// lowercase Portuguese diagnostic bytes while this reverse axis parses
2681/// `PascalCase` wire bytes — the two-axis wire/diagnostic split
2682/// forces the closed-cycle round-trip witness to cross through
2683/// [`CaixaKind::wire_name`]), [`CaixaDialeto`] carries exactly one
2684/// census-facing `PascalCase` axis (the module doc block above the
2685/// [`CaixaDialeto::as_str`] accessor names this out: "an internal
2686/// classification with no wire surface — the `PascalCase` variant name
2687/// is the census-facing form every consumer reads, so `as_str` suffices
2688/// without a paired `wire_name` axis"), so the string-owned forward and
2689/// reverse axes here round-trip directly through the shared
2690/// `PascalCase` vocabulary — a four-corner witness the pinned load-
2691/// bearing test makes explicit, and a witness the sibling
2692/// [`TryFrom<String> for crate::CaixaKind`] axis deliberately declines.
2693///
2694/// Pinned load-bearing by
2695/// [`tests::caixa_dialeto_try_from_owned_string_routes_through_borrowed_str_view_axis`]
2696/// (byte-parity pin against the paired borrowed [`TryFrom<&str>`] axis
2697/// across the four-arm [`CaixaDialeto::ALL`] accept-set on the owned-
2698/// `String` surface, cross-axis witness that the string-owned reverse
2699/// projection agrees with the sibling byte-view and byte-owned
2700/// reverse-projection axes on every accepted arm through the shared
2701/// substrate-primitive [`CaixaDialeto::from_wire`] accessor, plus a
2702/// four-corner {owned-input, borrowed-input} × {`From<Self> → String`,
2703/// `From<&Self> → String`} round-trip witness against the paired
2704/// [`From<{Self, &Self}> for String`] string-owned forward-projection
2705/// pair) and
2706/// [`tests::caixa_dialeto_try_from_owned_string_rejects_unknown_wire_strings`]
2707/// (rejection witness against silent accept-set widening — mirrors the
2708/// corpus the paired [`TryFrom<&str>`] and [`TryFrom<Vec<u8>>`]
2709/// rejection witnesses already pin, including empty / whitespace-only
2710/// inputs, case-fold variants of accepted arms, the sibling
2711/// [`CaixaDialeto::palavra_canonica`] / [`CaixaDialeto::consumidor`]
2712/// byte-shapes so a caller who confuses those distinct axes with the
2713/// census-facing wire axis trips here, whitespace-padded / trailing-
2714/// newline / quote-wrapped forms, with per-input cross-axis parity
2715/// against the borrowed [`TryFrom<&str>`] reverse-projection axis).
2716impl TryFrom<String> for CaixaDialeto {
2717 type Error = ();
2718
2719 fn try_from(s: String) -> Result<Self, Self::Error> {
2720 <Self as TryFrom<&str>>::try_from(s.as_str())
2721 }
2722}
2723
2724/// A source that is not a `(defcaixa …)` / `(defmolde …)` form at all.
2725#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
2726pub enum DialetoError {
2727 #[error("source has no top-level form")]
2728 Vazio,
2729 #[error("top-level form is not a list — a manifest is `(defcaixa …)`")]
2730 NaoEhLista,
2731 #[error(
2732 "top-level form is headed by `{encontrado}`, not `defcaixa` or `defmolde` \
2733 (a manifest's first form must be the declaration itself)"
2734 )]
2735 CabecaErrada { encontrado: String },
2736 #[error("manifest does not parse as tatara-lisp: {0}")]
2737 Leitura(String),
2738}
2739
2740impl DialetoError {
2741 /// Construct a [`DialetoError::CabecaErrada`] naming the offending
2742 /// head symbol found at the top-level form.
2743 ///
2744 /// Substrate primitive every [`classify_form`] wrong-head fallthrough
2745 /// wire-up site now routes through, folding the pre-lift uniform
2746 /// three-line `Self::CabecaErrada { encontrado: <head>.to_string() }`
2747 /// one-field struct-literal onto one substrate primitive matching the
2748 /// peer `LimitsError::unknown_byte_unit(unit: &str)` /
2749 /// `LimitsError::unknown_duration_unit(unit: &str)`
2750 /// (`limits_codec_unit_only_ctors!` — 29fac09) single-slot
2751 /// discipline on the sibling one-field `{ <field>: String }` envelope
2752 /// axis, and matching the peer `ManifestError::code_path_empty` /
2753 /// `BehaviorError::empty_path` / `UpgradeError::duplicate_from` /
2754 /// `AplicacaoError::placement_cluster_duplicate` (94dabc8 / 0e33b37 /
2755 /// 7e52aec / 92b1c92) single-slot inherent-ctor discipline every
2756 /// sibling `{ <field>: <T> }` error-envelope variant on caixa-core's
2757 /// error surface now carries.
2758 ///
2759 /// The one open-coded wire-up site — `classify_form`'s wrong-head
2760 /// fallthrough arm on the `head: &str` binding read from the
2761 /// top-level form via [`tatara_lisp::Sexp::as_symbol`] — opened the
2762 /// identical three-line
2763 /// `Self::CabecaErrada { encontrado: <head>.to_string() }` block
2764 /// against the codec-scoped `<head>: &str` binding. Now routes
2765 /// through `DialetoError::cabeca_errada(head)`, byte-equal to the
2766 /// pre-lift struct-literal on the same `&str` fixture, so any future
2767 /// widening of the diagnostic shape (e.g. carrying the source-file
2768 /// path alongside the head symbol, carrying the head symbol's
2769 /// position offset for an authoring-surface caret pointer) lands at
2770 /// exactly one dispatch on the substrate primitive rather than re-
2771 /// inlining the struct-literal at every wrong-head fallthrough
2772 /// consumer.
2773 #[must_use]
2774 pub fn cabeca_errada(encontrado: &str) -> Self {
2775 Self::CabecaErrada {
2776 encontrado: encontrado.to_string(),
2777 }
2778 }
2779
2780 /// Construct a [`DialetoError::Leitura`] carrying the offending
2781 /// tatara-lisp reader-error message `reason` verbatim in the
2782 /// variant's tuple-newtype payload.
2783 ///
2784 /// Substrate primitive every [`classify`] tatara-lisp-reader
2785 /// map-err wire-up site now routes through, folding the pre-lift
2786 /// uniform `Self::Leitura(<into-String-expr>)` tuple-newtype
2787 /// construction onto one substrate primitive matching the peer
2788 /// `LimitsError::empty_byte_size` / `LimitsError::empty_duration`
2789 /// (7a4b003 / 319216c) `(String)` single-slot tuple-newtype
2790 /// discipline on the sibling
2791 /// [`crate::limits::LimitsError`] envelope's empty-shape axis of
2792 /// the paired codec-magnitude family. Peer to the sibling
2793 /// [`DialetoError::cabeca_errada`] ctor on the same envelope's
2794 /// wrong-head axis but on the tatara-lisp-reader axis rather than
2795 /// the classifier-fallthrough axis. Closes the last un-lifted
2796 /// variant on [`DialetoError`] — every one of the sole wire-up
2797 /// sites (the [`classify`] tatara-lisp-reader `.map_err(|e|
2798 /// Self::Leitura(e.to_string()))` arm) opened the identical
2799 /// `DialetoError::Leitura(<into-String-expr>)` block against the
2800 /// codec-scoped `String` (`e.to_string()`) binding, so the fold
2801 /// routes the site through one dispatch on a uniform
2802 /// `impl Into<String>` param, byte-equal to the pre-lift
2803 /// tuple-newtype construction on the same argument.
2804 ///
2805 /// The `impl Into<String>` bound covers both wire-up shapes on
2806 /// [`classify`] — a `String` binding (`e.to_string()` on the
2807 /// [`tatara_lisp::Error`]-carrying `e` binding) and a `&str`
2808 /// binding (a future admission-webhook consumer probing a
2809 /// caller-scoped `&'static str` fixture, a future
2810 /// `feira lint --tatara-reader-round-trip` verb sweeping every
2811 /// `tatara_lisp::read` return through the same shape gate) —
2812 /// without forcing the caller to spell the conversion at the
2813 /// wire-up site. Same shape the peer
2814 /// [`crate::limits::LimitsError::empty_byte_size`] /
2815 /// [`crate::limits::LimitsError::empty_duration`] /
2816 /// [`crate::limits::LimitsError::bad_millicores`] /
2817 /// [`crate::limits::LimitsError::bad_byte_magnitude`] /
2818 /// [`crate::limits::LimitsError::bad_duration_magnitude`] folds
2819 /// carry on the peer bad-magnitude and empty-shape axes of the
2820 /// same paired `(String)` tuple-newtype codec-magnitude family.
2821 /// `#[must_use]` fires a compile warning at any wire-up that
2822 /// mistakenly discards the constructed error.
2823 ///
2824 /// Every future consumer that wants to construct this variant
2825 /// outside [`classify`] (a deferred `feira lint --tatara-reader-
2826 /// round-trip` per-caixa admission verb probing each authored
2827 /// manifest against the tatara-lisp-reader shape gate, an M4
2828 /// typed `mesh.pleme.io/v1alpha1/Servico` CR materializer's
2829 /// per-manifest admission validator re-checking one edited
2830 /// `caixa.lisp` against the reader floor, a per-`caixa.lisp`
2831 /// value-shape pre-emitter probing each declared manifest ahead
2832 /// of the operator's admit-cycle) now reaches the variant
2833 /// through one call rather than re-inlining the tuple-newtype
2834 /// block in lockstep with the pre-existing wire-up.
2835 #[must_use]
2836 pub fn leitura(reason: impl Into<String>) -> Self {
2837 Self::Leitura(reason.into())
2838 }
2839}
2840
2841/// Classify a manifest source without committing to either schema.
2842///
2843/// Deliberately reads only the head symbol and the set of top-level keywords —
2844/// enough to route, never enough to half-parse. A classifier that started
2845/// validating would grow into a third parser, which is the shape of the problem
2846/// it exists to name.
2847///
2848/// # Errors
2849/// [`DialetoError`] when the source is not a manifest declaration at all.
2850pub fn classify(src: &str) -> Result<CaixaDialeto, DialetoError> {
2851 let forms = tatara_lisp::read(src).map_err(|e| DialetoError::leitura(e.to_string()))?;
2852 let first = forms.first().ok_or(DialetoError::Vazio)?;
2853 classify_form(first)
2854}
2855
2856/// [`classify`] over an already-read form.
2857///
2858/// # Errors
2859/// [`DialetoError`] when the form is not a manifest declaration.
2860pub fn classify_form(form: &Sexp) -> Result<CaixaDialeto, DialetoError> {
2861 let list = form.as_list().ok_or(DialetoError::NaoEhLista)?;
2862 let head = list
2863 .first()
2864 .and_then(Sexp::as_symbol)
2865 .ok_or(DialetoError::NaoEhLista)?;
2866
2867 match head {
2868 // `defmolde` is unambiguous by construction — it exists precisely so a
2869 // consumer never has to infer which declaration it holds. Both arities
2870 // are the same declaration; the positional one keeps its own variant
2871 // only so a census can report the split.
2872 "defmolde" => {
2873 return Ok(if starts_with_positional_name(&list[1..]) {
2874 CaixaDialeto::MoldePosicional
2875 } else {
2876 CaixaDialeto::Molde
2877 });
2878 }
2879 "defcaixa" => {}
2880 other => {
2881 return Err(DialetoError::cabeca_errada(other));
2882 }
2883 }
2884
2885 let args = &list[1..];
2886
2887 // `(defcaixa <symbol> :kind … :ecosystem …)`. Only the Molde dialect has a
2888 // positional arity; `Caixa` is keyword-only, so a leading bare symbol
2889 // settles it without looking further.
2890 if starts_with_positional_name(args) {
2891 return Ok(CaixaDialeto::MoldePosicional);
2892 }
2893
2894 let keys = top_level_keywords(args);
2895 let has = |k: &str| keys.iter().any(|s| s == k);
2896
2897 // Order matters, and it is not arbitrary: `:nome` and `:name` are the two
2898 // required head slots and no file in the measured corpus carries both.
2899 // Checking them FIRST means the decision rests on the one slot each schema
2900 // makes mandatory, rather than on optional evidence like `:ecosystem`.
2901 if has("nome") {
2902 return Ok(CaixaDialeto::Pacote);
2903 }
2904 if has("name") || has("ecosystem") || has("package") {
2905 return Ok(CaixaDialeto::Molde);
2906 }
2907 Ok(CaixaDialeto::Desconhecido)
2908}
2909
2910/// True when the first argument is a bare symbol rather than a keyword — the
2911/// positional-name arity.
2912fn starts_with_positional_name(args: &[Sexp]) -> bool {
2913 matches!(args.first(), Some(Sexp::Atom(Atom::Symbol(_))))
2914}
2915
2916/// The top-level keyword names (without the leading `:`) of a kwarg list.
2917///
2918/// Steps in pairs so a keyword appearing as a VALUE — `:kind :Biblioteca`, or a
2919/// nested `(:nome "dep" :versao "^0.1")` inside `:deps` — is never counted as a
2920/// top-level slot. A naive scan for `:nome` anywhere in the source classifies
2921/// every Molde manifest with a `:deps` list as a Pacote.
2922fn top_level_keywords(args: &[Sexp]) -> Vec<String> {
2923 let mut out = Vec::new();
2924 let mut i = 0;
2925 while i < args.len() {
2926 if let Sexp::Atom(Atom::Keyword(k)) = &args[i] {
2927 out.push(k.clone());
2928 i += 2;
2929 } else {
2930 i += 1;
2931 }
2932 }
2933 out
2934}
2935
2936#[cfg(test)]
2937mod tests {
2938 use super::*;
2939
2940 const PACOTE: &str = r#"
2941 (defcaixa
2942 :nome "checkout"
2943 :versao "0.1.0"
2944 :kind Servico
2945 :deps ((:nome "caixa-teia" :versao "^0.1")))
2946 "#;
2947
2948 const MOLDE: &str = r#"
2949 (defcaixa
2950 :name "base64"
2951 :kind :Biblioteca
2952 :ecosystem :rust-single-crate
2953 :package {:name "base64" :version "0.22.1"}
2954 :workflows [:auto-release])
2955 "#;
2956
2957 const MOLDE_POSICIONAL: &str = r#"
2958 (defcaixa todoku-go
2959 :kind :Biblioteca
2960 :ecosystem :go
2961 :package {:name "todoku-go" :version "0.3.0"})
2962 "#;
2963
2964 #[test]
2965 fn the_package_dialect_is_recognised() {
2966 assert_eq!(classify(PACOTE), Ok(CaixaDialeto::Pacote));
2967 }
2968
2969 #[test]
2970 fn the_repo_surface_dialect_is_recognised() {
2971 assert_eq!(classify(MOLDE), Ok(CaixaDialeto::Molde));
2972 }
2973
2974 #[test]
2975 fn the_positional_arity_is_recognised() {
2976 assert_eq!(
2977 classify(MOLDE_POSICIONAL),
2978 Ok(CaixaDialeto::MoldePosicional)
2979 );
2980 }
2981
2982 #[test]
2983 fn defmolde_classifies_without_inference() {
2984 // The whole point of the new keyword: no schema sniffing required.
2985 let src = r#"(defmolde :name "x" :kind :Biblioteca :ecosystem :go)"#;
2986 assert_eq!(classify(src), Ok(CaixaDialeto::Molde));
2987 let pos = r"(defmolde todoku-go :kind :Biblioteca :ecosystem :go)";
2988 assert_eq!(classify(pos), Ok(CaixaDialeto::MoldePosicional));
2989 }
2990
2991 #[test]
2992 fn a_nested_nome_does_not_make_a_repo_surface_look_like_a_package() {
2993 // The exact failure a substring scan produces: `:deps ((:nome …))`
2994 // contains `:nome`, but not as a top-level slot.
2995 let src = r#"
2996 (defcaixa
2997 :name "x"
2998 :ecosystem :rust-single-crate
2999 :deps ((:nome "inner" :versao "^0.1")))
3000 "#;
3001 assert_eq!(classify(src), Ok(CaixaDialeto::Molde));
3002 }
3003
3004 #[test]
3005 fn a_keyword_in_value_position_is_not_a_slot() {
3006 // `:kind :Biblioteca` — the value is itself a keyword. Stepping one at
3007 // a time would read `:Biblioteca` as a top-level slot.
3008 let src = r#"(defcaixa :kind :Biblioteca :name "x")"#;
3009 assert_eq!(classify(src), Ok(CaixaDialeto::Molde));
3010 }
3011
3012 #[test]
3013 fn an_unrecognised_defcaixa_is_reported_not_guessed() {
3014 let src = r#"(defcaixa :licenca "MIT")"#;
3015 assert_eq!(classify(src), Ok(CaixaDialeto::Desconhecido));
3016 }
3017
3018 #[test]
3019 fn a_form_that_is_not_a_manifest_is_an_error_not_a_dialect() {
3020 assert_eq!(
3021 classify("(defflake :nome \"x\")"),
3022 Err(DialetoError::cabeca_errada("defflake"))
3023 );
3024 assert_eq!(classify(""), Err(DialetoError::Vazio));
3025 }
3026
3027 #[test]
3028 fn every_dialect_names_its_consumer_and_its_canonical_keyword() {
3029 // Guards the routing table itself: a new variant added without an arm
3030 // here is a compile error in the match, and a variant that claims
3031 // `defcaixa` while being read by pleme-doc-gen would re-open the
3032 // collision this module closes. Sweeps [`CaixaDialeto::ALL`] rather
3033 // than the pre-lift open-coded four-arm literal list — a future arm
3034 // addition extends the slice as one edit and this pin picks it up
3035 // by construction.
3036 for &d in CaixaDialeto::ALL {
3037 assert!(!d.descricao().is_empty(), "{d}");
3038 assert!(!d.consumidor().is_empty(), "{d}");
3039 }
3040 assert_eq!(CaixaDialeto::Pacote.palavra_canonica(), "defcaixa");
3041 assert_eq!(CaixaDialeto::Molde.palavra_canonica(), "defmolde");
3042 assert_ne!(
3043 CaixaDialeto::Pacote.palavra_canonica(),
3044 CaixaDialeto::Molde.palavra_canonica(),
3045 "the two dialects must not share a canonical keyword — that IS the defect"
3046 );
3047 }
3048
3049 #[test]
3050 fn caixa_dialeto_all_enumerates_every_variant_exactly_once() {
3051 // Three-legged exhaustiveness pin, peer of the sibling
3052 // `caixa_kind_all_enumerates_every_variant_exactly_once`
3053 // (caixa-core/src/kind.rs) /
3054 // `restart_strategy_all_enumerates_every_variant_exactly_once`
3055 // (caixa-core/src/supervisor.rs) shape.
3056 //
3057 // 1. arm-count invariant: `ALL.len()` matches the declared arm
3058 // count (four — a fifth arm added without extending `ALL`
3059 // fails this pin at caixa-core test time);
3060 // 2. pairwise-distinctness invariant: every variant appears at
3061 // most once in the slice (a duplicate arm would silently
3062 // double-count in the census consumer, so the pin rejects
3063 // duplicates outright);
3064 // 3. coverage invariant: every literal `CaixaDialeto::X` is in
3065 // the slice (the compiler-checked exhaustiveness on the peer
3066 // per-arm `match self` in the accessors keeps the enum arm
3067 // set and the `ALL` slice mutually aligned).
3068 assert_eq!(
3069 CaixaDialeto::ALL.len(),
3070 4,
3071 "ALL must list every arm exactly once; a fifth arm added \
3072 without extending ALL fails this pin — extend ALL alongside \
3073 the new variant"
3074 );
3075
3076 let mut seen: Vec<CaixaDialeto> = Vec::new();
3077 for &d in CaixaDialeto::ALL {
3078 assert!(
3079 !seen.contains(&d),
3080 "ALL contains a duplicate arm: {d}. Every variant appears \
3081 exactly once — a duplicate would double-count in every \
3082 iteration consumer"
3083 );
3084 seen.push(d);
3085 }
3086
3087 // Coverage: exhaustively assert every literal variant is somewhere
3088 // in the slice. Written as an exhaustive `match` so a future arm
3089 // addition fails to compile here (missing match arm) until the
3090 // corresponding `assert` is added — the compiler enforces the pin's
3091 // completeness rather than a hand-maintained variant list.
3092 for variant in [
3093 CaixaDialeto::Pacote,
3094 CaixaDialeto::Molde,
3095 CaixaDialeto::MoldePosicional,
3096 CaixaDialeto::Desconhecido,
3097 ] {
3098 let coverage_probe = match variant {
3099 CaixaDialeto::Pacote
3100 | CaixaDialeto::Molde
3101 | CaixaDialeto::MoldePosicional
3102 | CaixaDialeto::Desconhecido => variant,
3103 };
3104 assert!(
3105 CaixaDialeto::ALL.contains(&coverage_probe),
3106 "ALL is missing variant {coverage_probe} — extend the slice"
3107 );
3108 }
3109 }
3110
3111 #[test]
3112 fn caixa_dialeto_all_is_const_and_matches_iteration_count() {
3113 // Pins the const-ness of the slice at const-fold time. A future
3114 // change that promoted `ALL` to a non-const initializer (a lazy-
3115 // static, a runtime-computed Vec) would fail to compile here —
3116 // the pin locks in the compile-time-known iteration surface
3117 // every consumer builds against. Peer of the sibling
3118 // `caixa_kind_all_is_const_and_matches_iteration_count` (kind.rs)
3119 // / `restart_strategy_all_is_const_and_matches_iteration_count`
3120 // (supervisor.rs) shape.
3121 const ALL: &[CaixaDialeto] = CaixaDialeto::ALL;
3122 assert_eq!(ALL.len(), CaixaDialeto::ALL.len());
3123 // Sweep the iterator without collapsing to `.len()` so a future
3124 // change to `ALL`'s carrier that decouples `.len()` from the
3125 // iteration count (a lazy-computed shape, an alias `impl Iterator`
3126 // return, a wrapper newtype) still passes here iff the two agree
3127 // arm-for-arm; the `#[allow]` opts this local pin out of the
3128 // clippy `iter_count` collapse that would defeat the intent.
3129 #[allow(clippy::iter_count)]
3130 let iterated = ALL.iter().count();
3131 assert_eq!(iterated, CaixaDialeto::ALL.len());
3132 }
3133
3134 #[test]
3135 fn caixa_dialeto_all_covers_every_variant_by_display_probe() {
3136 // Fanning `Display` over the slice sweeps the paired accessors
3137 // ([`CaixaDialeto::palavra_canonica`] / [`CaixaDialeto::consumidor`]
3138 // / [`CaixaDialeto::descricao`]) at every arm — every returned
3139 // byte-string is non-empty (the accessors' contract). A future
3140 // arm added without extending its per-arm `match self` return
3141 // would compile-fail at the accessor call inside the loop;
3142 // together with the `ALL.len() == 4` pin above, this locks the
3143 // accessor arm-set and the `ALL` slice mutually.
3144 for &d in CaixaDialeto::ALL {
3145 let display_form = d.to_string();
3146 assert!(
3147 !display_form.is_empty(),
3148 "Display must render a non-empty byte-string for every \
3149 arm; empty: {d:?}"
3150 );
3151 // Consumidor / descricao / palavra-canonica must each surface
3152 // a non-empty scalar; every downstream diagnostic consumer
3153 // reaches through these accessors.
3154 assert!(!d.palavra_canonica().is_empty(), "{d}");
3155 assert!(!d.consumidor().is_empty(), "{d}");
3156 assert!(!d.descricao().is_empty(), "{d}");
3157 }
3158 }
3159
3160 #[test]
3161 fn caixa_dialeto_as_str_returns_pascal_case_variant_name() {
3162 // Fail-before-pass-after per-arm shape pin: the four
3163 // [`CaixaDialeto::as_str`] arms must return the canonical
3164 // `PascalCase` byte-string that names the variant. Pre-lift this
3165 // byte-string existed only inside the hand-rolled Display impl's
3166 // four-arm literal-string match — every consumer that wanted the
3167 // `PascalCase` name reached through `format!("{d}")`'s allocation
3168 // path. Pinning the four arms explicitly here refuses a future
3169 // regression that ever reroutes an arm to a distinct spelling
3170 // (`"pacote"` lowercase, `"MoldePositional"` English rebrand,
3171 // `"Unknown"` for `Desconhecido`) — the census output and the
3172 // typed accessor would silently disagree until a downstream
3173 // consumer surfaced the drift at census time. Peer of the sibling
3174 // [`crate::supervisor::tests::restart_strategy_variants_serialize_to_lifted_scalar_values`]
3175 // / `placement_strategy_variants_serialize_to_lifted_scalar_values`
3176 // / `caixa_kind_as_str_returns_lifted_peer_const` shape on the
3177 // sibling closed-set typed-enum discriminator axes — the seventh
3178 // (and last unlifted) closed-set typed enum on the caixa surface
3179 // to converge onto the same per-arm-shape-pin discipline.
3180 for (variant, expected) in [
3181 (CaixaDialeto::Pacote, "Pacote"),
3182 (CaixaDialeto::Molde, "Molde"),
3183 (CaixaDialeto::MoldePosicional, "MoldePosicional"),
3184 (CaixaDialeto::Desconhecido, "Desconhecido"),
3185 ] {
3186 assert_eq!(
3187 variant.as_str(),
3188 expected,
3189 "CaixaDialeto::{variant:?}.as_str() must return the \
3190 canonical `PascalCase` variant-name byte-string; drift here \
3191 splits the census-facing text from the substrate \
3192 primitive every downstream consumer will read"
3193 );
3194 }
3195 }
3196
3197 #[test]
3198 fn caixa_dialeto_wire_names_covers_every_arm() {
3199 // Load-bearing pin on the substrate-canonical
3200 // [`super::CaixaDialeto::WIRE_NAMES`] exhaustive accept-set
3201 // roster on the `PascalCase` variant-name wire-form axis: every
3202 // variant of the sibling [`super::CaixaDialeto::ALL`] exhaustive-
3203 // iteration surface must project through
3204 // [`super::CaixaDialeto::as_str`] onto an entry the
3205 // [`super::CaixaDialeto::WIRE_NAMES`] roster carries, and the
3206 // roster's length must byte-equal `super::CaixaDialeto::ALL.len()`
3207 // so a silent skew between the [`super::CaixaDialeto::as_str`]
3208 // match's arm-set and the roster's arm-set trips here at
3209 // caixa-core test time rather than at a downstream `feira dialeto
3210 // --list-dialects` per-arm listing / M4 admission-webhook
3211 // rejection-body accepted-tag enumeration miss / structured-log
3212 // accepted-wire-form emit drift.
3213 //
3214 // A future arm addition (the module doc's "third dialect"
3215 // hazard actualising as a fifth arm — a third arity variant, an
3216 // alias-declaration family `pleme-doc-gen` sharpens as its
3217 // schema evolves) extends [`super::CaixaDialeto::ALL`] as a
3218 // single edit and this pin sweeps the new arm by iteration; the
3219 // paired [`super::CaixaDialeto::WIRE_NAMES`] roster must grow in
3220 // lockstep or this assertion trips. Every entry is further
3221 // pinned to open with an uppercase ASCII byte (matching the
3222 // substrate-wide `PascalCase` convention every peer closed-set
3223 // enum whose canonical projection is a `PascalCase` census-
3224 // facing name carries), so a silent collapse of the dialect-
3225 // classification wire-form axis with any hypothetical lowercase-
3226 // kebab peer wire-form axis (an entry byte-identical to a
3227 // sibling lowercase-Portuguese label that would let a wire-axis
3228 // consumer accept the diagnostic byte-string) trips here rather
3229 // than at a downstream census-report round-trip miss.
3230 //
3231 // Peer of the sibling
3232 // [`crate::kind::tests::caixa_kind_wire_names_covers_every_arm`]
3233 // (bd708bd) /
3234 // [`crate::kind::tests::caixa_kind_labels_covers_every_arm`]
3235 // (427fe75) /
3236 // [`crate::supervisor::tests::restart_strategy_wire_names_covers_every_arm`]
3237 // (3033f45) /
3238 // [`crate::supervisor::tests::restart_policy_wire_names_covers_every_arm`]
3239 // (ce9412b) /
3240 // [`crate::aplicacao::tests::placement_strategy_wire_names_covers_every_arm`]
3241 // (3e5b194) /
3242 // [`crate::aplicacao::tests::wit_shape_labels_covers_every_arm`]
3243 // (9d9f585) /
3244 // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
3245 // (b553ec9) /
3246 // [`crate::upgrade::tests::upgrade_instruction_lisp_forms_covers_every_arm`]
3247 // (1898d77) /
3248 // [`crate::upgrade::tests::upgrade_instruction_wire_forms_covers_every_arm`]
3249 // (cc42c0e) /
3250 // [`crate::dep::tests::dep_list_author_keys_covers_every_arm`]
3251 // (af6ad3a) /
3252 // [`crate::render::tests::path_shape_violation_wire_names_covers_every_arm`]
3253 // (0330bd3) pins — the same closed-set exhaustive-roster
3254 // coverage discipline extended here onto the tatara-lisp
3255 // dialect-classification closed-set typed enum, the eleventh
3256 // substrate-side closed-set typed enum on the roster axis and
3257 // the first dialect-classification axis to converge onto the
3258 // discipline.
3259 //
3260 // Fail-before-pass-after locally verified by mutating one arm
3261 // of the paired `CAIXA_DIALETO_WIRE_*` const family (e.g.
3262 // rebranding `CAIXA_DIALETO_WIRE_MOLDE_POSICIONAL` from
3263 // `"MoldePosicional"` to `"MoldePositional"`) — the length pin
3264 // still passes but the `contains` check fires on the mutated
3265 // arm; and by shortening the roster to three entries — the
3266 // length pin fires first.
3267 assert_eq!(
3268 CaixaDialeto::WIRE_NAMES.len(),
3269 CaixaDialeto::ALL.len(),
3270 "CaixaDialeto::WIRE_NAMES.len() must byte-equal \
3271 CaixaDialeto::ALL.len() — a mismatch means the roster and \
3272 the enum's arm-set have drifted; downstream consumers that \
3273 fan through both will silently disagree on the accepted \
3274 arm-set"
3275 );
3276 for &variant in CaixaDialeto::ALL {
3277 let wire = variant.as_str();
3278 assert!(
3279 CaixaDialeto::WIRE_NAMES.contains(&wire),
3280 "CaixaDialeto::{variant:?}.as_str() = {wire:?} must be \
3281 a member of CaixaDialeto::WIRE_NAMES — the emitter and \
3282 the roster have drifted out of lockstep"
3283 );
3284 }
3285 for tag in CaixaDialeto::WIRE_NAMES {
3286 let first = tag.chars().next().unwrap_or_else(|| {
3287 panic!(
3288 "CaixaDialeto::WIRE_NAMES entry {tag:?} must be a \
3289 non-empty `PascalCase` variant-name byte-string"
3290 )
3291 });
3292 assert!(
3293 first.is_ascii_uppercase(),
3294 "CaixaDialeto::WIRE_NAMES entry {tag:?} must open with \
3295 an uppercase ASCII byte (matching the substrate-wide \
3296 `PascalCase` convention) — an entry opening with a \
3297 lowercase byte would collide the roster with any \
3298 hypothetical peer lowercase-kebab wire-form axis a \
3299 downstream consumer might disambiguate against"
3300 );
3301 }
3302 // Pin the exact four-arm roster in declaration order so a
3303 // future arm-swap on either the roster or the paired
3304 // `CAIXA_DIALETO_WIRE_*` constants (a rebrand of the arm-tag
3305 // mapping that leaves both the length pin and the membership
3306 // pin passing on their own) trips at caixa-core test time
3307 // under `assert_eq!`. Order matches variant declaration order
3308 // verbatim (`Pacote` → `Molde` → `MoldePosicional` →
3309 // `Desconhecido`) so the roster is the canonical ordering
3310 // every listing / rendering consumer defers to. Same
3311 // declaration-order pin the sibling
3312 // [`crate::render::tests::path_shape_violation_wire_names_covers_every_arm`]
3313 // (0330bd3) closes on the render-side path-shape-diagnostic
3314 // axis.
3315 assert_eq!(
3316 CaixaDialeto::WIRE_NAMES,
3317 &[
3318 CAIXA_DIALETO_WIRE_PACOTE,
3319 CAIXA_DIALETO_WIRE_MOLDE,
3320 CAIXA_DIALETO_WIRE_MOLDE_POSICIONAL,
3321 CAIXA_DIALETO_WIRE_DESCONHECIDO,
3322 ],
3323 "CaixaDialeto::WIRE_NAMES must enumerate every arm's wire-\
3324 form tag exactly once, in variant declaration order \
3325 (Pacote → Molde → MoldePosicional → Desconhecido)"
3326 );
3327 // Byte-parity pin on the paired reverse projection: every
3328 // entry in the roster must round-trip cleanly through
3329 // [`super::CaixaDialeto::from_wire`] back to the same arm the
3330 // [`super::CaixaDialeto::as_str`] emitter returned it for.
3331 // Refuses any future de-lift that swaps the four consts through
3332 // the reverse projection out of lockstep with the forward
3333 // emitter (a mid-arm rebrand touching only `as_str` but not
3334 // `from_wire`, an argument-ordering swap on one of the match
3335 // arms, a stray `to_lowercase` normalization on either side
3336 // that would silently pass the identity round-trip on the
3337 // already-PascalCase corpus but split the two projections on
3338 // any future non-PascalCase input).
3339 for (&variant, tag) in CaixaDialeto::ALL.iter().zip(CaixaDialeto::WIRE_NAMES) {
3340 assert_eq!(
3341 CaixaDialeto::from_wire(tag),
3342 Some(variant),
3343 "CaixaDialeto::from_wire({tag:?}) must round-trip back \
3344 to CaixaDialeto::{variant:?} — emitter and parser have \
3345 drifted off the paired CAIXA_DIALETO_WIRE_* const family"
3346 );
3347 }
3348 }
3349
3350 #[test]
3351 fn caixa_dialeto_display_routes_through_as_str_helper() {
3352 // Fail-before-pass-after convergence pin: for every arm in
3353 // [`CaixaDialeto::ALL`], the [`std::fmt::Display`] rendered form
3354 // must byte-equal [`CaixaDialeto::as_str`]'s return value. Pre-
3355 // lift these two paths were structurally independent — the
3356 // Display impl hand-rolled its own four-arm literal-string
3357 // match with no compile-time link back to any substrate accessor
3358 // — so a future variant rename could land at `Display` without
3359 // touching a paired accessor (or vice versa), silently splitting
3360 // the two paths on the renamed arm. Pinning the byte-equality
3361 // here makes any such split a caixa-core build-time failure at
3362 // this test rather than surfacing far from the rename commit as
3363 // a downstream census consumer emitting one spelling while the
3364 // typed accessor returned another. Peer of the sibling
3365 // [`crate::kind::tests::caixa_kind_display_routes_through_as_str_helper`]
3366 // (which pins the same convergence on the [`crate::CaixaKind`]
3367 // closed-set axis) — extends the discipline onto the seventh
3368 // (and last unlifted) closed-set fieldless typed enum on the
3369 // caixa surface.
3370 for &variant in CaixaDialeto::ALL {
3371 assert_eq!(
3372 variant.to_string(),
3373 variant.as_str(),
3374 "CaixaDialeto::{variant:?} Display must route through \
3375 CaixaDialeto::as_str (single source of truth: the \
3376 lifted per-arm `PascalCase` variant-name byte-string)"
3377 );
3378 }
3379 }
3380
3381 #[test]
3382 fn caixa_dialeto_as_ref_str_routes_through_as_str_accessor() {
3383 // Fail-before-pass-after byte-parity pin on the lifted
3384 // `impl AsRef<str> for CaixaDialeto` — asserts the standard-
3385 // library trait impl and the substrate-primitive
3386 // [`CaixaDialeto::as_str`] `pub const fn` accessor resolve to
3387 // the same `&str` per instance across the four-arm closed set,
3388 // so any future silent detour that routes the impl through a
3389 // divergent projection (a per-arm inline
3390 // `match self { CaixaDialeto::Pacote => "Pacote", … }` re-inlining
3391 // that opens a compile-time link to the un-lifted arm-literal,
3392 // a swap onto the second-axis
3393 // [`CaixaDialeto::palavra_canonica`] /
3394 // [`CaixaDialeto::consumidor`] / [`CaixaDialeto::descricao`]
3395 // accessors that carry distinct byte-shapes per axis) trips at
3396 // caixa-core test time under `PartialEq` rather than at a
3397 // downstream `impl AsRef<str>`-bound consumer's silent split.
3398 // Sweeps every one of the four arms [`CaixaDialeto::ALL`]
3399 // carries so no arm's projection is covered only by the sibling
3400 // `Display` path. Peer of the sibling
3401 // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
3402 // (d8136db) on the M3 `:politicas :rate-limit` closed-set typed
3403 // enum, and the peer
3404 // [`crate::kind::tests::caixa_kind_as_ref_str_routes_through_as_str_accessor`]
3405 // (cd2091f) pin on the top-level closed-set typed
3406 // discriminator — the pins together close the substrate
3407 // primitive's `AsRef<str>` projection axis onto the seventh
3408 // closed-set fieldless typed enum on the caixa surface.
3409 for &variant in CaixaDialeto::ALL {
3410 assert_eq!(
3411 <CaixaDialeto as AsRef<str>>::as_ref(&variant),
3412 variant.as_str(),
3413 "AsRef<str> impl on CaixaDialeto::{variant:?} must \
3414 byte-equal CaixaDialeto::as_str on the same instance \
3415 — divergence signals a silent detour off the \
3416 substrate-primitive accessor"
3417 );
3418 }
3419 }
3420
3421 #[test]
3422 fn caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor() {
3423 // Fail-before-pass-after byte-parity pin on the three-path
3424 // convergence discipline the [`CaixaDialeto`] closed-set
3425 // dialect-classification enum now carries on the `&str`-
3426 // projection axis: `<CaixaDialeto as AsRef<str>>::as_ref(&v)`
3427 // (the newly lifted impl), `format!("{v}")` (the pre-existing
3428 // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
3429 // primitive `pub const fn` accessor both trait impls delegate
3430 // through) must resolve to the same byte-string on every
3431 // instance across the four-arm closed set. Refuses any future
3432 // divergence between the two trait impls (a stray
3433 // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
3434 // rather than delegating through the shared accessor; a
3435 // hypothetical `AsRef<str>` rewrite that inlines a per-arm
3436 // literal cascade) that would silently split the two
3437 // projection paths of the same closed-set typed enum. Mirrors
3438 // the sibling three-path-convergence discipline the peer
3439 // [`crate::aplicacao::RateLimitUnit`] typed enum carries
3440 // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
3441 // d8136db), the peer [`crate::CaixaKind`] triple
3442 // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
3443 // cd2091f), and the [`crate::CaixaVersion`] typed newtype
3444 // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
3445 // 16d5c7e).
3446 for &variant in CaixaDialeto::ALL {
3447 let via_as_ref: &str = <CaixaDialeto as AsRef<str>>::as_ref(&variant);
3448 let via_display: String = format!("{variant}");
3449 let via_accessor: &str = variant.as_str();
3450 assert_eq!(via_as_ref, via_accessor);
3451 assert_eq!(via_display, via_accessor);
3452 assert_eq!(via_as_ref, via_display.as_str());
3453 }
3454 }
3455
3456 #[test]
3457 fn caixa_dialeto_is_molde_family_returns_true_on_molde_and_positional_arms() {
3458 // Fail-before-pass-after per-arm shape pin on the two `defmolde`
3459 // declaration-family arms: [`CaixaDialeto::is_molde_family`] must
3460 // return `true` for [`CaixaDialeto::Molde`] and
3461 // [`CaixaDialeto::MoldePosicional`] — the two-arity closure of
3462 // one declaration ([`CaixaDialeto::MoldePosicional`]'s docstring:
3463 // "same declaration as [`Self::Molde`], written with the package
3464 // name as a bare positional symbol … one arity of one
3465 // declaration, not a third schema"). A future accidental flip that
3466 // reversed a per-arm arm's return without touching the paired
3467 // false-arm pin would silently open the substrate primitive to
3468 // false-positive on either arm — the `feira dialeto` verb's
3469 // `--strict-palavra` gate would then silently accept
3470 // repo-surface declarations under `(defcaixa …)` on one arm and
3471 // reject them on the other. Pinning the two true arms explicitly
3472 // here refuses that split at caixa-core build time.
3473 assert!(
3474 CaixaDialeto::Molde.is_molde_family(),
3475 "CaixaDialeto::Molde.is_molde_family() must return true — \
3476 Molde is the primary `defmolde` arm"
3477 );
3478 assert!(
3479 CaixaDialeto::MoldePosicional.is_molde_family(),
3480 "CaixaDialeto::MoldePosicional.is_molde_family() must return \
3481 true — MoldePosicional is the positional-arity form of the \
3482 same `defmolde` declaration Molde carries"
3483 );
3484 }
3485
3486 #[test]
3487 fn caixa_dialeto_is_molde_family_returns_false_on_pacote_and_desconhecido_arms() {
3488 // Fail-before-pass-after per-arm shape pin on the two non-`defmolde`
3489 // arms: [`CaixaDialeto::is_molde_family`] must return `false` for
3490 // [`CaixaDialeto::Pacote`] (the sibling `defcaixa` tatara-lisp
3491 // package manifest, `palavra_canonica → "defcaixa"`) and for
3492 // [`CaixaDialeto::Desconhecido`] (the residue that names no
3493 // known declaration, `palavra_canonica → "?"`). Pinning the two
3494 // false arms explicitly here refuses a future accidental flip
3495 // that let the predicate widen to include either arm — the
3496 // `feira dialeto` verb's `--strict-palavra` gate would then
3497 // spuriously refuse every `(defcaixa …)` package manifest as if
3498 // it were a repo-surface declaration.
3499 assert!(
3500 !CaixaDialeto::Pacote.is_molde_family(),
3501 "CaixaDialeto::Pacote.is_molde_family() must return false — \
3502 Pacote is the `defcaixa` tatara-lisp package manifest, not \
3503 the `defmolde` repo-surface declaration"
3504 );
3505 assert!(
3506 !CaixaDialeto::Desconhecido.is_molde_family(),
3507 "CaixaDialeto::Desconhecido.is_molde_family() must return \
3508 false — the residue arm names no known declaration; it is \
3509 not silently promoted into the `defmolde` family"
3510 );
3511 }
3512
3513 #[test]
3514 fn caixa_dialeto_is_molde_family_agrees_with_palavra_canonica_defmolde_projection() {
3515 // Load-bearing pin: for every arm in [`CaixaDialeto::ALL`], the
3516 // typed [`CaixaDialeto::is_molde_family`] predicate must agree
3517 // byte-for-byte with the paired [`CaixaDialeto::palavra_canonica`]
3518 // projection's `== "defmolde"` classifier — i.e. the two paths
3519 // partition the four-arm discriminator set into the same
3520 // `{Molde, MoldePosicional}` and `{Pacote, Desconhecido}` halves.
3521 // Pre-lift the sibling [`CaixaDialeto::palavra_canonica`] projection
3522 // (which returns `"defmolde"` for `Molde | MoldePosicional`,
3523 // `"defcaixa"` for `Pacote`, `"?"` for `Desconhecido`) was the
3524 // only substrate-side surface carrying the two-arm collapse; the
3525 // hand-rolled `matches!(d, CaixaDialeto::Molde |
3526 // CaixaDialeto::MoldePosicional)` sites in the `feira dialeto`
3527 // verb expressed no compile-time link back to it. A future arm
3528 // addition — the module doc's "third dialect" hazard actualises
3529 // as a fifth arm belonging to the `defmolde` family — would land
3530 // one match arm at [`Self::palavra_canonica`]'s `defmolde` return
3531 // (extending the sibling projection) but silently split the
3532 // hand-rolled two-arm `matches!` predicate sites if the new arm's
3533 // `is_molde_family` return were forgotten. Pinning byte-equality
3534 // between the two paths here makes any such split a caixa-core
3535 // build-time failure at this test rather than surfacing far from
3536 // the arm-addition commit as a downstream `--strict-palavra` /
3537 // `caixa.lisp`-holds-wrong-declaration gate silently ignoring the
3538 // new arm.
3539 for &d in CaixaDialeto::ALL {
3540 let via_palavra_canonica = d.palavra_canonica() == "defmolde";
3541 let via_is_molde_family = d.is_molde_family();
3542 assert_eq!(
3543 via_is_molde_family, via_palavra_canonica,
3544 "CaixaDialeto::{d:?}.is_molde_family() ({via_is_molde_family}) \
3545 must agree with CaixaDialeto::{d:?}.palavra_canonica() == \
3546 \"defmolde\" ({via_palavra_canonica}) — a split between the \
3547 typed predicate and the sibling keyword projection would let \
3548 a future arm addition land at one path and drift at the other, \
3549 which is exactly the drift this pin refuses"
3550 );
3551 }
3552 }
3553
3554 #[test]
3555 fn caixa_dialeto_is_molde_family_is_const_fn() {
3556 // Const-context pin: [`CaixaDialeto::is_molde_family`] must remain
3557 // `const fn` (its match is a fieldless-arm literal-pattern
3558 // discriminator, so no non-const operation exists on the resolution
3559 // path). Downstream consumers reaching for the predicate from a
3560 // `const` context (a future substrate-wide const-fold-driven audit
3561 // table that materializes per-arm gate-membership at build time,
3562 // a per-arm CR-admission-webhook gate registration in a `const`
3563 // context) rely on the const-ness. A future accidental downgrade
3564 // to non-`const` (an added runtime helper reachable only from a
3565 // non-`const` context) trips at caixa-core build time rather than
3566 // surfacing as a downstream `const`-context regression far from
3567 // the predicate declaration. Peer of the sibling
3568 // [`caixa_dialeto_as_str_is_const_fn`] pin on the paired
3569 // [`CaixaDialeto::as_str`] byte-string axis.
3570 const ARMS: [(CaixaDialeto, bool); 4] = [
3571 (CaixaDialeto::Pacote, CaixaDialeto::Pacote.is_molde_family()),
3572 (CaixaDialeto::Molde, CaixaDialeto::Molde.is_molde_family()),
3573 (
3574 CaixaDialeto::MoldePosicional,
3575 CaixaDialeto::MoldePosicional.is_molde_family(),
3576 ),
3577 (
3578 CaixaDialeto::Desconhecido,
3579 CaixaDialeto::Desconhecido.is_molde_family(),
3580 ),
3581 ];
3582 // Materialize the const-fold-evaluated table into a runtime slice
3583 // assertion — carries the same `bool = const fn call` shape a raw
3584 // `assert!(const_bool)` would, without tripping the
3585 // `assertions_on_constants` clippy lint that a per-arm
3586 // `assert!(CONST)` on a `const bool` triggers when the arm-count
3587 // is enumerated flat rather than compared as a whole-table shape.
3588 assert_eq!(
3589 ARMS,
3590 [
3591 (CaixaDialeto::Pacote, false),
3592 (CaixaDialeto::Molde, true),
3593 (CaixaDialeto::MoldePosicional, true),
3594 (CaixaDialeto::Desconhecido, false),
3595 ],
3596 "CaixaDialeto::is_molde_family() must evaluate in const context \
3597 for every arm and land on the {{false, true, true, false}} \
3598 partition — a future accidental downgrade to non-`const` \
3599 would trip the const-context array-initializer here"
3600 );
3601 }
3602
3603 #[test]
3604 fn caixa_dialeto_as_str_is_const_fn() {
3605 // Const-context pin: [`CaixaDialeto::as_str`] must remain
3606 // `const fn` (its match arms return `pub const` byte-strings, so
3607 // no non-const operation exists on the resolution path).
3608 // Downstream consumers reaching for the accessor from a `const`
3609 // context (a future substrate-wide const-fold-driven audit table
3610 // that materializes every dialect's census label at build time,
3611 // a per-arm CR-admission-webhook message registration in a
3612 // `const` gate) rely on the const-ness. A future accidental
3613 // downgrade to non-`const` (an added runtime helper reachable
3614 // only from a non-`const` context, a manual hand-rolled `impl`
3615 // that shadows this method) trips at caixa-core build time
3616 // rather than surfacing as a downstream `const`-context
3617 // regression far from the accessor declaration. Peer of the
3618 // sibling [`crate::kind::tests::caixa_kind_wire_name_is_const_fn`]
3619 // pin on the paired [`crate::CaixaKind`] byte-string axis.
3620 const PACOTE: &str = CaixaDialeto::Pacote.as_str();
3621 const MOLDE: &str = CaixaDialeto::Molde.as_str();
3622 const MOLDE_POSICIONAL: &str = CaixaDialeto::MoldePosicional.as_str();
3623 const DESCONHECIDO: &str = CaixaDialeto::Desconhecido.as_str();
3624 assert_eq!(PACOTE, "Pacote");
3625 assert_eq!(MOLDE, "Molde");
3626 assert_eq!(MOLDE_POSICIONAL, "MoldePosicional");
3627 assert_eq!(DESCONHECIDO, "Desconhecido");
3628 }
3629
3630 #[test]
3631 fn caixa_dialeto_is_variant_predicates_partition_the_arm_set() {
3632 // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
3633 // derive: for each of the four variants at [`CaixaDialeto::ALL`]`[idx]`
3634 // the observed four-slot predicate row must equal a one-hot row
3635 // with the `true` at exactly `idx`. Pre-derive the closed four-arm
3636 // dialect-classification partition lived only inside the paired
3637 // per-arm projections' four-arm match resolvers ([`Self::as_str`] /
3638 // [`Self::palavra_canonica`] / [`Self::consumidor`] /
3639 // [`Self::descricao`]) plus the two-arm [`Self::is_molde_family`]
3640 // hand-rolled `matches!` (now routed through the derived
3641 // predicates); a future rebrand (an accidental
3642 // `#[is_variant(name = "…")]` drift, a manual hand-rolled `impl`
3643 // that shadows the derive-generated method, an arm rename that
3644 // reroutes one arm through the wrong predicate lane) trips this
3645 // pin at caixa-core build time rather than surfacing far from the
3646 // derive declaration as a downstream [`Self::is_molde_family`]
3647 // consumer accepting the wrong arm-set. The expected row is
3648 // generated live from the [`Self::ALL`] declaration order rather
3649 // than transcribed by hand so a copy-paste flip reroutes at the
3650 // identity-diagonal assertion.
3651 //
3652 // Peer of the sibling
3653 // [`crate::kind::tests::caixa_kind_is_variant_predicates_partition_the_arm_set`]
3654 // / [`crate::supervisor::tests::restart_strategy_is_variant_predicates_partition_the_arm_set`]
3655 // / [`crate::aplicacao::tests::placement_strategy_is_variant_predicates_partition_the_arm_set`]
3656 // / [`crate::upgrade::tests::upgrade_instruction_is_variant_predicates_partition_the_arm_set`]
3657 // pins on the sibling closed-set typed-enum discriminator axes.
3658 for (idx, &variant) in CaixaDialeto::ALL.iter().enumerate() {
3659 let observed = [
3660 variant.is_pacote(),
3661 variant.is_molde(),
3662 variant.is_molde_posicional(),
3663 variant.is_desconhecido(),
3664 ];
3665 let mut expected = [false; 4];
3666 expected[idx] = true;
3667 assert_eq!(
3668 observed, expected,
3669 "CaixaDialeto::{variant:?} at ALL[{idx}] is_* predicates \
3670 must fire only on their own arm lane (identity diagonal); \
3671 got {observed:?}",
3672 );
3673 }
3674 }
3675
3676 #[test]
3677 fn caixa_dialeto_is_variant_predicates_are_const_fn() {
3678 // The [`gen_platform::IsVariant`] derive emits `const fn`
3679 // predicates on the peer [`crate::CaixaKind`] +
3680 // [`crate::upgrade::UpgradeInstruction`] +
3681 // [`crate::supervisor::RestartStrategy`] +
3682 // [`crate::supervisor::RestartPolicy`] +
3683 // [`crate::aplicacao::PlacementStrategy`] +
3684 // [`crate::aplicacao::RateLimitUnit`] +
3685 // [`crate::dep::DepList`] closed-set typed enums — pin the same
3686 // posture on [`CaixaDialeto`] so a future accidental downgrade
3687 // to non-`const` (an added runtime helper reachable only from a
3688 // non-`const` context, a manual hand-rolled `impl` that shadows
3689 // the derive-generated method) trips at caixa-core build time
3690 // rather than surfacing as a downstream `const`-context
3691 // regression far from the derive declaration.
3692 // Use `const { assert!(…) }` (peer of the sibling
3693 // [`crate::render::PathShapeViolation`] +
3694 // [`crate::aplicacao::RateLimitUnit`] +
3695 // [`caixa_theme::style::Semantic`] const-fn pins) so the
3696 // const-context evaluation trips at const-fold time without
3697 // opening a per-`const bool` `assertions_on_constants` clippy
3698 // debt row this crate does not carry today for `dialeto.rs`.
3699 const { assert!(CaixaDialeto::Pacote.is_pacote()) };
3700 const { assert!(CaixaDialeto::Molde.is_molde()) };
3701 const { assert!(CaixaDialeto::MoldePosicional.is_molde_posicional()) };
3702 const { assert!(CaixaDialeto::Desconhecido.is_desconhecido()) };
3703 }
3704
3705 #[test]
3706 fn caixa_dialeto_from_wire_accepts_every_as_str_output() {
3707 // Fail-before-pass-after per-arm accept pin on the newly lifted
3708 // [`CaixaDialeto::from_wire`] reverse projection: every arm in
3709 // [`CaixaDialeto::ALL`] must parse back through `from_wire` when
3710 // fed its own [`CaixaDialeto::as_str`] output, landing on
3711 // `Some(same_variant)` — a regression that hand-rolled either
3712 // side's per-arm match without threading through the shared
3713 // four-string closed set would silently disagree on any future
3714 // arm rename and this pin flags it at caixa-core build time.
3715 // Peer of the sibling
3716 // [`crate::kind::tests::caixa_kind_wire_round_trips_through_from_wire`]
3717 // (2aa6d23) /
3718 // `placement_strategy_from_wire_accepts_every_lifted_constant`
3719 // (18c7342) /
3720 // `dep_list_round_trips_through_as_str_and_from_wire` (45ee563)
3721 // shape on the sibling closed-set typed-enum reverse-projection
3722 // axes.
3723 for &variant in CaixaDialeto::ALL {
3724 let wire = variant.as_str();
3725 let parsed = CaixaDialeto::from_wire(wire).unwrap_or_else(|| {
3726 panic!(
3727 "CaixaDialeto::from_wire({wire:?}) must accept every \
3728 CaixaDialeto::as_str output — got None for the \
3729 wire byte-string of {variant:?}"
3730 )
3731 });
3732 assert_eq!(
3733 parsed, variant,
3734 "CaixaDialeto::from_wire(CaixaDialeto::{variant:?}.as_str()) \
3735 must return CaixaDialeto::{variant:?} — the (as_str, \
3736 from_wire) pair must form a total round-trip on the \
3737 closed four-arm CaixaDialeto arm-set"
3738 );
3739 }
3740 }
3741
3742 #[test]
3743 fn caixa_dialeto_from_wire_rejects_unknown_byte_strings() {
3744 // Rejection pin on the parser's accept-set: any string outside
3745 // the four-arm [`CaixaDialeto::as_str`] output set must return
3746 // `None`. A future accidental widening of the accept-set (a
3747 // case-insensitive match that accepts `"pacote"` on the wire
3748 // axis, a hand-rolled Levenshtein-forgiving arm-lookup that
3749 // admits `"Pacotee"` typos, a silent acceptance of the sibling
3750 // [`Self::palavra_canonica`] `"defcaixa"` / `"defmolde"`
3751 // byte-shapes on this axis) would silently drift the parser's
3752 // accept-set from the emitter's — a downstream audit-report
3753 // re-loader that bound a prior audit's [`Self::as_str`] output
3754 // back to the typed enum through this parser would then bind a
3755 // malformed byte-string to a plausibly-wrong typed arm the
3756 // caller does not route through any fallback, silently
3757 // misclassifying the reloaded row. Also rejects the sibling
3758 // [`Self::palavra_canonica`] (`"defcaixa"` / `"defmolde"`) and
3759 // the sibling [`Self::consumidor`] (`"caixa-core / feira"`,
3760 // `"pleme-doc-gen"`, `"nobody known"`) byte-shapes, which are
3761 // the substrate's *distinct-axis* projections on the same enum
3762 // — the two-axis split the sibling
3763 // [`Self::palavra_canonica`] / [`Self::consumidor`] /
3764 // [`Self::descricao`] docstrings explicitly frame forbids
3765 // accepting one axis's byte-shapes as parseable on the other
3766 // axis. Peer of the sibling
3767 // [`crate::kind::tests::caixa_kind_from_wire_rejects_unknown_byte_strings`]
3768 // (2aa6d23) /
3769 // `placement_strategy_from_wire_rejects_unknown_byte_strings`
3770 // (18c7342) /
3771 // `dep_list_from_wire_returns_none_on_unknown_wire_scalar`
3772 // (45ee563) rejection pins on the sibling closed-set typed-enum
3773 // reverse-projection axes.
3774 for bad in [
3775 "",
3776 " ",
3777 "pacote",
3778 "PACOTE",
3779 "molde",
3780 "MoldePositional",
3781 "desconhecido",
3782 "Unknown",
3783 "defcaixa",
3784 "defmolde",
3785 "?",
3786 "caixa-core / feira",
3787 "pleme-doc-gen",
3788 "nobody known",
3789 "Pacote ",
3790 " Pacote",
3791 ] {
3792 assert!(
3793 CaixaDialeto::from_wire(bad).is_none(),
3794 "CaixaDialeto::from_wire({bad:?}) must return None — the \
3795 parser's accept-set is exactly the four CaixaDialeto::as_str \
3796 outputs; a widening would silently split the parser's \
3797 accept-set from the emitter's arm-set"
3798 );
3799 }
3800 }
3801
3802 #[test]
3803 fn cabeca_errada_ctor_matches_struct_literal_wrap() {
3804 // Fail-before-pass-after byte-identity pin: the lifted
3805 // [`DialetoError::cabeca_errada`] ctor MUST land on the exact
3806 // same struct-literal shape the pre-lift open-coded wire-up
3807 // block wrote by hand — `DialetoError::CabecaErrada {
3808 // encontrado: <head>.to_string() }`. A future accidental
3809 // divergence (`.into()` swap, per-arm constant substitution, an
3810 // added default field, an `.to_ascii_lowercase()` normalization
3811 // silently injected into the ctor body, a rebrand of the
3812 // `encontrado` field carrying a distinct byte-shape) trips this
3813 // pin at caixa-core build time rather than surfacing far from
3814 // the ctor declaration as a downstream `classify_form`
3815 // wrong-head consumer emitting one diagnostic shape while a
3816 // hand-written test peer opens another. Peer of the sibling
3817 // `unknown_byte_unit_ctor_matches_struct_literal_wrap`
3818 // (limits.rs; 29fac09) / `duplicate_from_ctor_matches_struct_
3819 // literal_wrap` (upgrade.rs; 7e52aec) shape on the sibling
3820 // single-slot `{ <field>: String }` envelope constructors.
3821 assert_eq!(
3822 DialetoError::cabeca_errada("defflake"),
3823 DialetoError::CabecaErrada {
3824 encontrado: "defflake".to_string(),
3825 },
3826 "DialetoError::cabeca_errada must byte-equal the pre-lift \
3827 open-coded struct-literal — a drift here means the ctor \
3828 stopped being a substrate primitive for the wrong-head \
3829 fallthrough site"
3830 );
3831 }
3832
3833 #[test]
3834 fn cabeca_errada_routes_encontrado_verbatim_across_boundary_inputs() {
3835 // Fail-before-pass-after boundary-sweep pin: the lifted
3836 // [`DialetoError::cabeca_errada`] ctor MUST route its
3837 // `encontrado: &str` argument verbatim into the
3838 // [`DialetoError::CabecaErrada`] `encontrado: String` field
3839 // for every boundary-covering `&str` input — empty string, a
3840 // canonical `defcaixa`-adjacent head, a non-ASCII head, a
3841 // whitespace-carrying head, a Unicode-full-width head. Any
3842 // wrapper-side truncation, silent `.trim()`, accidental
3843 // `.to_ascii_lowercase()` normalization, or `.into()` divergence
3844 // on the ctor body surfaces here as a byte-mismatch against the
3845 // input rather than at a downstream
3846 // [`DialetoError::to_string()`] diagnostic-shape drift at a
3847 // wrong-head fallthrough consumer far from the ctor declaration.
3848 // Peer of the sibling `limits_codec_unit_only_ctors_route_unit_
3849 // verbatim_across_every_variant` (limits.rs; 29fac09) shape on
3850 // the sibling single-slot `{ <field>: String }` envelope
3851 // boundary-sweep discipline.
3852 for encontrado in [
3853 "",
3854 "defflake",
3855 "def-molde",
3856 "defcaixa ",
3857 " defcaixa",
3858 "μdefcaixa",
3859 "\u{00A0}defcaixa",
3860 "\u{3000}defcaixa",
3861 "def\u{2028}caixa",
3862 ] {
3863 let via_ctor = DialetoError::cabeca_errada(encontrado);
3864 let via_literal = DialetoError::CabecaErrada {
3865 encontrado: encontrado.to_string(),
3866 };
3867 assert_eq!(
3868 via_ctor, via_literal,
3869 "DialetoError::cabeca_errada({encontrado:?}) must byte- \
3870 equal the open-coded struct-literal on the same input — \
3871 a drift here would let the ctor silently normalize / \
3872 truncate the head symbol before it reached the \
3873 CabecaErrada envelope"
3874 );
3875 let DialetoError::CabecaErrada { encontrado: routed } = via_ctor else {
3876 panic!(
3877 "DialetoError::cabeca_errada must construct the \
3878 CabecaErrada arm — got a different variant on \
3879 input {encontrado:?}"
3880 );
3881 };
3882 assert_eq!(
3883 routed, encontrado,
3884 "DialetoError::cabeca_errada must route the input \
3885 {encontrado:?} verbatim into the encontrado field — \
3886 any wrapper-side truncation / normalization surfaces \
3887 here rather than at a downstream diagnostic shape drift"
3888 );
3889 }
3890 }
3891
3892 #[test]
3893 fn classify_form_wrong_head_routes_through_cabeca_errada_ctor() {
3894 // Fail-before-pass-after routing pin: [`classify`]'s wrong-head
3895 // fallthrough site MUST construct its `Err(DialetoError::…)`
3896 // through the substrate-primitive [`DialetoError::cabeca_errada`]
3897 // ctor rather than through an open-coded struct-literal. Pre-
3898 // lift the wire-up hand-rolled a three-line
3899 // `Self::CabecaErrada { encontrado: other.to_string() }` block
3900 // with no compile-time link back to the substrate primitive; a
3901 // future accidental rebrand of the ctor body (an added
3902 // `.trim()` on `encontrado`, a per-arm constant prefix like
3903 // `"unknown-head:"`, a widening of the field into a
3904 // `(String, usize)` tuple carrying a caret offset) would then
3905 // silently split the two paths — the ctor consumers pick up
3906 // the new shape, the open-coded wire-up does not. Pinning
3907 // byte-equality between the observed `Err` and the ctor-
3908 // constructed `Err` refuses that split at caixa-core build
3909 // time rather than surfacing far from the wire-up commit as a
3910 // downstream diagnostic-consumer split.
3911 for head in ["defflake", "deffoobar", "defcaixaz", "let", "defmoldez"] {
3912 let src = format!("({head} :nome \"x\")");
3913 let observed = classify(&src);
3914 let via_ctor = Err(DialetoError::cabeca_errada(head));
3915 assert_eq!(
3916 observed, via_ctor,
3917 "classify({src:?}) must return the same Err shape as \
3918 DialetoError::cabeca_errada({head:?}) — a drift here \
3919 means the wire-up de-lifted its wrong-head fallthrough \
3920 arm off the substrate primitive"
3921 );
3922 }
3923 }
3924
3925 #[test]
3926 fn leitura_ctor_matches_tuple_literal_wrap_on_str_binding() {
3927 // Fail-before-pass-after byte-identity pin: the lifted
3928 // [`DialetoError::leitura`] ctor MUST land on the exact same
3929 // tuple-newtype wrap the pre-lift open-coded wire-up block wrote by
3930 // hand — `DialetoError::Leitura(<into-String-expr>)`. A future
3931 // accidental divergence (an added `.trim()` on the reader reason,
3932 // a per-arm constant prefix like `"tatara-lisp:"`, a widening of
3933 // the tuple carrying a caret offset, a rebrand of the payload
3934 // carrying a distinct byte-shape) trips this pin at caixa-core
3935 // build time rather than surfacing far from the ctor declaration
3936 // as a downstream [`classify`] tatara-lisp-reader consumer
3937 // emitting one diagnostic shape while a hand-written test peer
3938 // opens another. Peer of the sibling
3939 // `cabeca_errada_ctor_matches_struct_literal_wrap` pin above on
3940 // the same [`DialetoError`] envelope's wrong-head axis, and of
3941 // the peer `LimitsError::empty_byte_size` /
3942 // `LimitsError::empty_duration` (7a4b003 / 319216c) shape on the
3943 // sibling `(String)` single-slot tuple-newtype envelope
3944 // constructors.
3945 let reason: &str = "unclosed paren at 1:12";
3946 assert_eq!(
3947 DialetoError::leitura(reason),
3948 DialetoError::Leitura(reason.to_string()),
3949 "DialetoError::leitura must byte-equal the pre-lift open-coded \
3950 tuple-newtype wrap — a drift here means the ctor stopped \
3951 being a substrate primitive for the tatara-lisp-reader \
3952 fallthrough site"
3953 );
3954 }
3955
3956 #[test]
3957 fn leitura_ctor_matches_tuple_literal_wrap_on_string_binding() {
3958 // Fail-before-pass-after byte-identity pin on the `String` wire-up
3959 // shape: the lifted [`DialetoError::leitura`] ctor MUST land on
3960 // the same tuple-newtype wrap when the caller passes an owned
3961 // `String` (the actual [`classify`] wire-up shape — `e.to_string()`
3962 // on a [`tatara_lisp::Error`]-carrying binding). Pins that the
3963 // `impl Into<String>` param covers the owned-`String` path with no
3964 // silent double-allocation or intermediate `&str` reslicing. Peer
3965 // of the sibling `_on_str_binding` pin above — together they close
3966 // the `impl Into<String>` bound's two authored wire-up shapes on
3967 // the ctor's substrate primitive.
3968 let reason: String = String::from("read: unexpected EOF at 3:1");
3969 let via_ctor = DialetoError::leitura(reason.clone());
3970 let via_literal = DialetoError::Leitura(reason.clone());
3971 assert_eq!(
3972 via_ctor, via_literal,
3973 "DialetoError::leitura must byte-equal the pre-lift open-coded \
3974 tuple-newtype wrap on the same owned-String fixture — a drift \
3975 here would let the ctor silently reshape the reader reason \
3976 before it reached the Leitura envelope"
3977 );
3978 let DialetoError::Leitura(routed) = via_ctor else {
3979 panic!(
3980 "DialetoError::leitura must construct the Leitura arm — \
3981 got a different variant on input {reason:?}"
3982 );
3983 };
3984 assert_eq!(
3985 routed, reason,
3986 "DialetoError::leitura must route the input {reason:?} \
3987 verbatim into the tuple-newtype payload — any wrapper-side \
3988 truncation / normalization surfaces here rather than at a \
3989 downstream diagnostic shape drift"
3990 );
3991 }
3992
3993 #[test]
3994 fn leitura_routes_reason_verbatim_across_boundary_inputs() {
3995 // Fail-before-pass-after boundary-sweep pin: the lifted
3996 // [`DialetoError::leitura`] ctor MUST route its
3997 // `reason: impl Into<String>` argument verbatim into the
3998 // [`DialetoError::Leitura`] tuple-newtype `String` payload for
3999 // every boundary-covering input — empty string, a canonical
4000 // tatara-lisp reader error, a non-ASCII reason, a
4001 // whitespace-carrying reason, a Unicode-full-width reason. Any
4002 // wrapper-side truncation, silent `.trim()`, accidental
4003 // `.to_ascii_lowercase()` normalization, or `.into()` divergence
4004 // on the ctor body surfaces here as a byte-mismatch against the
4005 // input rather than at a downstream [`DialetoError::to_string()`]
4006 // diagnostic-shape drift at a tatara-lisp-reader fallthrough
4007 // consumer far from the ctor declaration. Peer of the sibling
4008 // `cabeca_errada_routes_encontrado_verbatim_across_boundary_inputs`
4009 // pin above on the same [`DialetoError`] envelope's wrong-head
4010 // axis.
4011 for reason in [
4012 "",
4013 "unclosed paren at 1:12",
4014 "unexpected token ')'",
4015 "read: eof",
4016 " leading whitespace",
4017 "trailing whitespace ",
4018 "μnicode reason",
4019 "\u{00A0}NBSP-prefixed reason",
4020 "\u{3000}ideographic-space reason",
4021 "reason\u{2028}with-line-separator",
4022 ] {
4023 let via_ctor = DialetoError::leitura(reason);
4024 let via_literal = DialetoError::Leitura(reason.to_string());
4025 assert_eq!(
4026 via_ctor, via_literal,
4027 "DialetoError::leitura({reason:?}) must byte-equal the \
4028 open-coded tuple-newtype wrap on the same input — a \
4029 drift here would let the ctor silently normalize / \
4030 truncate the reader reason before it reached the \
4031 Leitura envelope"
4032 );
4033 let DialetoError::Leitura(routed) = via_ctor else {
4034 panic!(
4035 "DialetoError::leitura must construct the Leitura \
4036 arm — got a different variant on input {reason:?}"
4037 );
4038 };
4039 assert_eq!(
4040 routed, reason,
4041 "DialetoError::leitura must route the input {reason:?} \
4042 verbatim into the tuple-newtype payload — any \
4043 wrapper-side truncation / normalization surfaces here \
4044 rather than at a downstream diagnostic shape drift"
4045 );
4046 }
4047 }
4048
4049 #[test]
4050 fn classify_reader_error_routes_through_leitura_ctor() {
4051 // Fail-before-pass-after routing pin: [`classify`]'s
4052 // tatara-lisp-reader map-err site MUST construct its
4053 // `Err(DialetoError::…)` through the substrate-primitive
4054 // [`DialetoError::leitura`] ctor rather than through an
4055 // open-coded tuple-newtype wrap. Pre-lift the wire-up hand-rolled
4056 // a `Self::Leitura(e.to_string())` block with no compile-time
4057 // link back to the substrate primitive; a future accidental
4058 // rebrand of the ctor body (an added `.trim()` on the reader
4059 // reason, a per-arm constant prefix like `"tatara-lisp:"`, a
4060 // widening of the payload into a `(String, usize)` tuple
4061 // carrying a caret offset) would then silently split the two
4062 // paths — the ctor consumers pick up the new shape, the
4063 // open-coded wire-up does not. Pinning byte-equality between
4064 // the observed `Err` and the ctor-constructed `Err` refuses
4065 // that split at caixa-core build time rather than surfacing far
4066 // from the wire-up commit as a downstream diagnostic-consumer
4067 // split. Peer of the sibling
4068 // `classify_form_wrong_head_routes_through_cabeca_errada_ctor`
4069 // pin above on the same [`DialetoError`] envelope's wrong-head
4070 // fallthrough axis.
4071 //
4072 // The malformed sources below each name a distinct
4073 // tatara-lisp-reader failure shape (unclosed paren, stray close
4074 // paren, unterminated string), so together they sweep the
4075 // reader's rejection surface rather than pinning against one
4076 // specific error message the reader upstream is free to reword.
4077 for src in [
4078 "(defcaixa :nome \"x\"",
4079 "defcaixa :nome \"x\")",
4080 "(defcaixa :nome \"unterminated",
4081 ] {
4082 let observed = classify(src);
4083 let Err(DialetoError::Leitura(reason)) = observed.clone() else {
4084 panic!(
4085 "classify({src:?}) must return the Leitura arm — got \
4086 {observed:?}"
4087 );
4088 };
4089 let via_ctor: Result<CaixaDialeto, DialetoError> =
4090 Err(DialetoError::leitura(reason.clone()));
4091 assert_eq!(
4092 observed, via_ctor,
4093 "classify({src:?}) must return the same Err shape as \
4094 DialetoError::leitura({reason:?}) — a drift here means \
4095 the wire-up de-lifted its tatara-lisp-reader fallthrough \
4096 arm off the substrate primitive"
4097 );
4098 }
4099 }
4100
4101 #[test]
4102 fn caixa_dialeto_try_from_str_routes_through_from_wire_accessor() {
4103 // Fail-before-pass-after byte-parity pin on the lifted
4104 // `impl TryFrom<&str> for CaixaDialeto`: for every arm in
4105 // [`CaixaDialeto::ALL`], the `.try_into()` / `TryFrom::try_from`
4106 // path must resolve to the same variant the sibling
4107 // [`CaixaDialeto::from_wire`] resolver returns on the same
4108 // [`CaixaDialeto::as_str`] wire byte-string input. Pins the
4109 // three-path convergence discipline the [`CaixaDialeto`] closed-
4110 // set typed enum now carries on the `str → Self` reverse-
4111 // projection axis: `<CaixaDialeto as TryFrom<&str>>::try_from(s)`
4112 // (the newly lifted trait-idiomatic reverse projection),
4113 // `CaixaDialeto::from_wire(s)` (the substrate-primitive method-
4114 // named `Option<Self>` accessor the trait impl delegates through),
4115 // and the round-trip identity `variant.as_str() → variant`
4116 // (the four-arm closed accept-set shared between the emitter and
4117 // both reverse-projection consumers) must resolve to the same
4118 // typed [`CaixaDialeto`] discriminator on every arm.
4119 //
4120 // A future silent detour that routes the impl through a
4121 // divergent projection (a per-arm inline
4122 // `match s { "Pacote" => …, … }` re-inlining that opens a
4123 // compile-time link to the un-lifted arm-literal, a swap onto
4124 // the second-axis [`CaixaDialeto::palavra_canonica`] /
4125 // [`CaixaDialeto::consumidor`] / [`CaixaDialeto::descricao`]
4126 // accessors that carry distinct byte-shapes per axis, an accept-
4127 // set widening that silently accepts one axis's byte-shapes as
4128 // parseable on the other axis) trips at caixa-core test time
4129 // under `assert_eq!` rather than at a downstream
4130 // `TryFrom<&str>`-bound consumer's silent split. Peer of the
4131 // sibling
4132 // [`crate::kind::tests::caixa_kind_try_from_str_routes_through_from_wire_accessor`]
4133 // (3c83606) on the top-level [`crate::CaixaKind`] closed-set
4134 // discriminator's reverse-projection axis — extends the trait-
4135 // idiomatic reverse-projection axis onto the seventh closed-set
4136 // fieldless typed enum on the caixa surface (the second one to
4137 // carry the paired `TryFrom<&str>` impl).
4138 for &variant in CaixaDialeto::ALL {
4139 let wire = variant.as_str();
4140 let via_try_from: CaixaDialeto = <CaixaDialeto as TryFrom<&str>>::try_from(wire)
4141 .unwrap_or_else(|()| {
4142 panic!(
4143 "CaixaDialeto::try_from({wire:?}) must accept every \
4144 CaixaDialeto::as_str output — got Err(()) for the \
4145 wire byte-string of {variant:?}"
4146 )
4147 });
4148 let via_from_wire: CaixaDialeto = CaixaDialeto::from_wire(wire).unwrap_or_else(|| {
4149 panic!(
4150 "CaixaDialeto::from_wire({wire:?}) must accept every \
4151 CaixaDialeto::as_str output — got None for the wire \
4152 byte-string of {variant:?}"
4153 )
4154 });
4155 assert_eq!(
4156 via_try_from, variant,
4157 "CaixaDialeto::try_from(CaixaDialeto::{variant:?}.as_str()) \
4158 must return CaixaDialeto::{variant:?} — the trait-idiomatic \
4159 reverse projection must land on the same arm the method-named \
4160 from_wire resolver does",
4161 );
4162 assert_eq!(
4163 via_try_from, via_from_wire,
4164 "CaixaDialeto::try_from({wire:?}) ({via_try_from:?}) must \
4165 byte-equal CaixaDialeto::from_wire({wire:?}) ({via_from_wire:?}) \
4166 on the same input — divergence signals a silent detour off the \
4167 shared substrate-primitive resolver",
4168 );
4169 assert_eq!(
4170 <CaixaDialeto as TryFrom<&str>>::try_from(wire).ok(),
4171 CaixaDialeto::from_wire(wire),
4172 "the Result::ok() projection of TryFrom<&str> must byte-equal \
4173 the sibling from_wire Option<Self> output on {wire:?} — the \
4174 two accessors must share the same accept-set and typed \
4175 outcome per arm",
4176 );
4177 }
4178 }
4179
4180 #[test]
4181 fn caixa_dialeto_try_from_str_rejects_unknown_byte_strings() {
4182 // Rejection witness on the trait-idiomatic reverse-projection
4183 // axis: any string outside the four-arm [`CaixaDialeto::as_str`]
4184 // output set must resolve to `Err(())` through the lifted
4185 // [`impl TryFrom<&str> for CaixaDialeto`]. A future accidental
4186 // widening of the accept-set (a case-insensitive match that
4187 // accepts `"pacote"` on the wire axis, a hand-rolled Levenshtein-
4188 // forgiving arm-lookup that admits `"Pacotee"` typos, a silent
4189 // acceptance of the sibling [`CaixaDialeto::palavra_canonica`]
4190 // `"defcaixa"` / `"defmolde"` byte-shapes on this axis, a swap
4191 // onto the [`CaixaDialeto::consumidor`] `"pleme-doc-gen"` /
4192 // `"caixa-core / feira"` / `"nobody known"` byte-shapes) would
4193 // silently drift the trait-idiomatic parser's accept-set from
4194 // the sibling [`CaixaDialeto::from_wire`] resolver's — a
4195 // downstream `TryFrom<&str>`-bound consumer binding a malformed
4196 // byte-string through this impl would then bind a plausibly-
4197 // wrong typed arm the caller does not route through any fallback,
4198 // silently misclassifying the reloaded row.
4199 //
4200 // Sweeps the same rejection set the sibling
4201 // [`caixa_dialeto_from_wire_rejects_unknown_byte_strings`] pin
4202 // walks (the shared `from_wire` resolver both accessors delegate
4203 // through) so the trait-idiomatic axis and the method-named axis
4204 // stay locked to the same accept-set by construction. Peer of the
4205 // sibling
4206 // [`crate::kind::tests::caixa_kind_try_from_str_rejects_unknown_byte_strings`]
4207 // (3c83606) on the top-level [`crate::CaixaKind`] closed-set
4208 // discriminator's trait-idiomatic reverse-projection axis.
4209 for bad in [
4210 "",
4211 " ",
4212 "pacote",
4213 "PACOTE",
4214 "molde",
4215 "MoldePositional",
4216 "desconhecido",
4217 "Unknown",
4218 "defcaixa",
4219 "defmolde",
4220 "?",
4221 "caixa-core / feira",
4222 "pleme-doc-gen",
4223 "nobody known",
4224 "Pacote ",
4225 " Pacote",
4226 ] {
4227 assert_eq!(
4228 <CaixaDialeto as TryFrom<&str>>::try_from(bad),
4229 Err(()),
4230 "CaixaDialeto::try_from({bad:?}) must return Err(()) — the \
4231 trait-idiomatic parser's accept-set is exactly the four \
4232 CaixaDialeto::as_str outputs; a widening would silently \
4233 split the trait-idiomatic reverse-projection axis from the \
4234 sibling from_wire resolver's arm-set"
4235 );
4236 }
4237 }
4238
4239 #[test]
4240 fn caixa_dialeto_from_str_routes_through_try_from_str_impl() {
4241 // Fail-before-pass-after byte-parity pin on the newly lifted
4242 // `impl std::str::FromStr for CaixaDialeto` — asserts the
4243 // standard-library `.parse()` parse-axis entry point and the
4244 // paired [`super::CaixaDialeto::try_from`] `TryFrom<&str>` impl
4245 // (which in turn routes through the substrate-primitive
4246 // [`super::CaixaDialeto::from_wire`] `Option<Self>` accessor)
4247 // resolve to the same four-arm accept-set across every arm the
4248 // exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
4249 // Extends the substrate-wide `FromStr` parse-axis campaign —
4250 // opened on [`crate::dep::DepList`] via 6167092 as first-
4251 // mover, extended onto the structurally most fundamental
4252 // closed-set typed enum via [`crate::CaixaKind`] (9867432),
4253 // then onto the first M3-mesh-primitive-defining slot enum
4254 // via [`crate::aplicacao::PlacementStrategy`] (62ef49a) —
4255 // onto the dialect-classification axis every [`crate::Caixa`]
4256 // carries through its parsed manifest form. The peer
4257 // method-named `from_wire` accessor and the paired
4258 // `TryFrom<&str>` trait impl fix the four-arm PascalCase
4259 // accept-set; this pin locks the `FromStr::from_str` trait
4260 // entry point onto the same set so any future divergence (a
4261 // stray per-arm `match s` re-inlining that opens a compile-
4262 // time link to an un-lifted arm-literal, a swap onto a hand-
4263 // rolled parser that widens the accept-set past the four
4264 // lifted [`crate::render::CAIXA_DIALETO_WIRE_*`] consts) trips
4265 // at caixa-core test time.
4266 use std::str::FromStr;
4267 for &variant in CaixaDialeto::ALL {
4268 let wire = variant.as_str();
4269 assert_eq!(
4270 <CaixaDialeto as FromStr>::from_str(wire),
4271 Ok(variant),
4272 "FromStr impl on CaixaDialeto must round-trip \
4273 CaixaDialeto::{variant:?}.as_str() = {wire:?} back to \
4274 Ok(CaixaDialeto::{variant:?}) — divergence from \
4275 CaixaDialeto::try_from signals a silent detour off the \
4276 paired reverse-projection trait impl"
4277 );
4278 assert_eq!(
4279 <CaixaDialeto as FromStr>::from_str(wire).ok(),
4280 CaixaDialeto::from_wire(wire),
4281 "FromStr ok()-projection on {wire:?} must byte-equal \
4282 CaixaDialeto::from_wire on the same input — divergence \
4283 signals the two reverse-projection trait paths have \
4284 drifted off the substrate-primitive accessor"
4285 );
4286 // `.parse::<CaixaDialeto>()` short-form witness — the
4287 // stdlib consumer surface that reaches the enum through
4288 // the `T: FromStr` bound, not through `TryFrom<&str>`.
4289 let via_parse: Result<CaixaDialeto, ()> = wire.parse();
4290 assert_eq!(
4291 via_parse,
4292 Ok(variant),
4293 "`{wire:?}`.parse::<CaixaDialeto>() must resolve to \
4294 Ok(CaixaDialeto::{variant:?}) — divergence signals \
4295 the stdlib `.parse()` short-form has drifted from the \
4296 lifted `FromStr::from_str` impl"
4297 );
4298 }
4299 }
4300
4301 #[test]
4302 fn caixa_dialeto_from_str_rejects_unknown_byte_strings() {
4303 // Rejection witness on the `impl FromStr for CaixaDialeto` —
4304 // sweeps candidate byte-strings outside the four-arm
4305 // PascalCase accept-set the sibling
4306 // [`super::CaixaDialeto::as_str`] emits and asserts every one
4307 // lands on `Err(())`, so a future accidental widening of the
4308 // trait impl's accept-set (a stray case-fold path, a silent
4309 // acceptance of the sibling [`CaixaDialeto::palavra_canonica`]
4310 // `"defcaixa"` / `"defmolde"` byte-shapes on this axis, a
4311 // swap onto the [`CaixaDialeto::consumidor`] /
4312 // [`CaixaDialeto::descricao`] axes' byte-shapes) trips at
4313 // caixa-core test time. Peer of the sibling
4314 // [`caixa_dialeto_try_from_str_rejects_unknown_byte_strings`]
4315 // rejection witness — the two pins together bracket both
4316 // reverse-projection trait impls against the same rejected
4317 // set. Peer of the sibling
4318 // [`crate::kind::tests::caixa_kind_from_str_rejects_unknown_byte_strings`]
4319 // (9867432) rejection witness on the top-level
4320 // [`crate::CaixaKind`] closed-set discriminator's trait-
4321 // idiomatic `FromStr` parse axis.
4322 use std::str::FromStr;
4323 let rejected: &[&str] = &[
4324 "",
4325 " ",
4326 "pacote",
4327 "PACOTE",
4328 "molde",
4329 "MoldePositional",
4330 "desconhecido",
4331 "Unknown",
4332 "defcaixa",
4333 "defmolde",
4334 "?",
4335 "caixa-core / feira",
4336 "pleme-doc-gen",
4337 "nobody known",
4338 "Pacote ",
4339 " Pacote",
4340 "Pacote\n",
4341 "\"Pacote\"",
4342 ];
4343 for &input in rejected {
4344 assert_eq!(
4345 <CaixaDialeto as FromStr>::from_str(input),
4346 Err(()),
4347 "FromStr impl on CaixaDialeto must reject unknown \
4348 byte-string {input:?} — divergence signals a silent \
4349 accept-set widening past the four lifted \
4350 crate::render::CAIXA_DIALETO_WIRE_* wire constants"
4351 );
4352 assert_eq!(
4353 <CaixaDialeto as FromStr>::from_str(input).ok(),
4354 CaixaDialeto::from_wire(input),
4355 "FromStr ok()-projection on {input:?} must byte-equal \
4356 CaixaDialeto::from_wire on the same input — \
4357 divergence signals the FromStr trait path has drifted \
4358 off the substrate-primitive accessor"
4359 );
4360 let via_parse: Result<CaixaDialeto, ()> = input.parse();
4361 assert_eq!(
4362 via_parse,
4363 Err(()),
4364 "`{input:?}`.parse::<CaixaDialeto>() must reject the \
4365 unknown byte-string — divergence signals the stdlib \
4366 `.parse()` short-form has drifted from the lifted \
4367 `FromStr::from_str` impl"
4368 );
4369 }
4370 }
4371
4372 #[test]
4373 fn caixa_dialeto_from_into_static_str_routes_through_as_str_accessor() {
4374 // Fail-before-pass-after byte-parity pin on the newly lifted
4375 // `impl From<CaixaDialeto> for &'static str` — asserts the
4376 // standard-library trait impl and the substrate-primitive
4377 // [`CaixaDialeto::as_str`] `pub const fn` accessor resolve to
4378 // the same four-arm emit-set across every arm the exhaustive
4379 // [`CaixaDialeto::ALL`] slice enumerates. Any future silent
4380 // detour that routes the trait impl through a divergent
4381 // projection (a per-arm inline `match dialeto { Pacote =>
4382 // "Pacote", … }` re-inlining that opens a compile-time link to
4383 // the un-lifted arm-literal, an accidental swap onto the second-
4384 // axis [`CaixaDialeto::palavra_canonica`] /
4385 // [`CaixaDialeto::consumidor`] / [`CaixaDialeto::descricao`]
4386 // accessors that carry distinct byte-shapes per axis) trips at
4387 // caixa-core test time under `assert_eq!` rather than at a
4388 // downstream `impl Into<&'static str>`-bound consumer's silent
4389 // split. Sweeps every one of the four arms [`CaixaDialeto::ALL`]
4390 // carries so no arm's projection is covered only by the sibling
4391 // method-named `as_str` / [`std::fmt::Display`] / [`AsRef<str>`]
4392 // paths. Materializes the `<&'static str as
4393 // From<CaixaDialeto>>::from` output in a `const`-shape binding
4394 // to make the `'static` lifetime promise a build-time invariant
4395 // — a future accidental downgrade of any of the four arms'
4396 // returned literals to a non-`&'static str` (a `String::leak()`-
4397 // produced return, a `Box::leak`-cast, an intermediate lifetime-
4398 // erasing helper) trips at caixa-core build time rather than at
4399 // a downstream `'static`-bound consumer. Peer of the sibling
4400 // [`crate::supervisor::tests::restart_strategy_from_into_static_str_routes_through_as_str_accessor`]
4401 // (523157d) /
4402 // [`crate::supervisor::tests::restart_policy_from_into_static_str_routes_through_as_str_accessor`]
4403 // (9fb37d0) /
4404 // [`crate::kind::tests::caixa_kind_from_into_static_str_routes_through_as_str_accessor`]
4405 // (edb827b) pins on the sibling closed-set typed-enum forward-
4406 // projection axes — extends the trait-idiomatic forward-
4407 // projection axis onto the fourth closed-set fieldless typed
4408 // enum on the caixa surface (the dialect-classification axis,
4409 // second-of-two closed-set typed enums in caixa-core outside
4410 // the OTP-shape M2 slot).
4411 const PACOTE: &str = CaixaDialeto::Pacote.as_str();
4412 const MOLDE: &str = CaixaDialeto::Molde.as_str();
4413 const MOLDE_POSICIONAL: &str = CaixaDialeto::MoldePosicional.as_str();
4414 const DESCONHECIDO: &str = CaixaDialeto::Desconhecido.as_str();
4415 for &variant in CaixaDialeto::ALL {
4416 let via_trait: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
4417 let via_method: &'static str = variant.as_str();
4418 assert_eq!(
4419 via_trait, via_method,
4420 "From<CaixaDialeto> for &'static str impl must round-trip \
4421 CaixaDialeto::{variant:?} to the same `PascalCase` byte-string \
4422 CaixaDialeto::as_str returns — divergence signals a silent \
4423 detour off the substrate-primitive accessor"
4424 );
4425 let via_into: &'static str = variant.into();
4426 assert_eq!(
4427 via_into, via_method,
4428 "Into<&'static str>::into on CaixaDialeto::{variant:?} must \
4429 byte-equal CaixaDialeto::as_str on the same input — the \
4430 blanket-derived Into shape must resolve to the same as_str \
4431 dispatch as the explicit From impl"
4432 );
4433 }
4434 assert_eq!(
4435 [PACOTE, MOLDE, MOLDE_POSICIONAL, DESCONHECIDO],
4436 ["Pacote", "Molde", "MoldePosicional", "Desconhecido"],
4437 "const-context CaixaDialeto::as_str must resolve to the four \
4438 `PascalCase` variant-name byte-strings — a future accidental \
4439 downgrade of any arm to a non-const or non-static byte-string \
4440 breaks the `&'static str`-lifetime promise the paired \
4441 From<CaixaDialeto> for &'static str impl carries by \
4442 construction"
4443 );
4444 }
4445
4446 #[test]
4447 fn caixa_dialeto_from_into_static_str_and_as_str_partition_the_emit_set() {
4448 // Cross-axis partition pin: the paired trait-idiomatic
4449 // `From<CaixaDialeto> for &'static str` forward projection and
4450 // the method-named [`CaixaDialeto::as_str`] forward projection
4451 // must resolve identically on *every* arm, not just the ones
4452 // named in the primary byte-parity pin above. Sweeps every
4453 // [`CaixaDialeto::ALL`] arm and asserts the trait's `From::from`
4454 // output byte-equals the method-named accessor's return-value on
4455 // each, locking the two forward-projection paths together by
4456 // construction so any future detour (a stray `From` special-case
4457 // that lands on a divergent per-arm literal outside the paired
4458 // `as_str` dispatch, a hypothetical rebrand touching one axis
4459 // without the other) trips at caixa-core test time. Peer of the
4460 // sibling forward-projection partition pins
4461 // [`crate::supervisor::tests::restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`]
4462 // (523157d) /
4463 // [`crate::supervisor::tests::restart_policy_from_into_static_str_and_as_str_partition_the_emit_set`]
4464 // (9fb37d0) /
4465 // [`crate::kind::tests::caixa_kind_from_into_static_str_and_as_str_partition_the_emit_set`]
4466 // (edb827b) — extends the round-trip discipline onto the fourth
4467 // closed-set typed enum on the caixa surface, closing the two-way
4468 // `Self ↔ &'static str` round-trip on the trait-idiomatic pair
4469 // (`From<Self> for &'static str` + `TryFrom<&str> for Self`) as
4470 // well as the pre-existing method-named pair (`as_str` +
4471 // `from_wire`).
4472 for &variant in CaixaDialeto::ALL {
4473 let via_trait: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
4474 let via_method: &'static str = variant.as_str();
4475 assert_eq!(
4476 via_trait, via_method,
4477 "From<CaixaDialeto> for &'static str and \
4478 CaixaDialeto::as_str must resolve identically on \
4479 CaixaDialeto::{variant:?} — divergence signals the \
4480 two forward-projection paths have drifted onto different \
4481 emit-sets"
4482 );
4483 }
4484 // Round-trip witness: every arm's forward `From` output re-parses
4485 // through the paired trait-idiomatic reverse `TryFrom<&str>` back
4486 // to the original variant. Closes the two-way `CaixaDialeto ↔
4487 // &'static str` round-trip on the trait-idiomatic axis pair
4488 // directly (no wire-vocab intermediate the peer [`CaixaKind`]
4489 // axis pair requires — the emit-side [`CaixaDialeto::as_str`]
4490 // and the parse-side [`CaixaDialeto::from_wire`] share the same
4491 // `PascalCase` byte-string vocabulary by construction), mirroring
4492 // the pre-existing method-named `as_str` + `from_wire` round-trip
4493 // on the substrate-primitive axis pair.
4494 for &variant in CaixaDialeto::ALL {
4495 let emitted: &'static str = variant.into();
4496 let re_parsed: Result<CaixaDialeto, ()> =
4497 <CaixaDialeto as TryFrom<&str>>::try_from(emitted);
4498 assert_eq!(
4499 re_parsed,
4500 Ok(variant),
4501 "trait-idiomatic axis pair must round-trip \
4502 CaixaDialeto::{variant:?} through `.into::<&'static \
4503 str>()` and back through `TryFrom<&str>` — a break signals \
4504 the forward-emit and reverse-parse axes have drifted onto \
4505 different vocabularies"
4506 );
4507 }
4508 }
4509
4510 #[test]
4511 fn caixa_dialeto_is_molde_family_routes_through_is_variant_derived_predicates() {
4512 // Byte-parity pin on the post-lift [`CaixaDialeto::is_molde_family`]
4513 // convergence: for every arm in [`CaixaDialeto::ALL`], the typed
4514 // predicate must byte-equal the direct
4515 // `self.is_molde() || self.is_molde_posicional()` composition of
4516 // the two derived per-arm predicates. Pre-lift the predicate
4517 // hand-rolled `matches!(self, Self::Molde | Self::MoldePosicional)`
4518 // with no compile-time link back to the closed-set typed dispatch;
4519 // post-lift it routes through the derived predicates so a future
4520 // arm rename or `#[is_variant(name = "…")]` override lands at
4521 // exactly one dispatch on the substrate primitive. Pinning the
4522 // byte-equality here refuses a future accidental split between
4523 // the composed predicate and the paired derived predicates
4524 // (a hand-rolled shadow `impl` that overrides one path but not
4525 // the other, an accidental rebrand of `is_molde_family`'s body
4526 // back to the pre-lift `matches!` form) at caixa-core build time.
4527 for &d in CaixaDialeto::ALL {
4528 let via_derived = d.is_molde() || d.is_molde_posicional();
4529 let via_is_molde_family = d.is_molde_family();
4530 assert_eq!(
4531 via_is_molde_family, via_derived,
4532 "CaixaDialeto::{d:?}.is_molde_family() ({via_is_molde_family}) \
4533 must byte-equal the composed derived predicates \
4534 is_molde() || is_molde_posicional() ({via_derived}) — a \
4535 split between the composed predicate and its derived \
4536 building blocks would let a future arm rename land at one \
4537 path and drift at the other, which is exactly the drift \
4538 the IsVariant lift refuses"
4539 );
4540 }
4541 }
4542
4543 #[test]
4544 fn caixa_dialeto_from_borrowed_into_static_str_routes_through_as_str_accessor() {
4545 // Fail-before-pass-after byte-parity pin on the newly lifted
4546 // `impl From<&CaixaDialeto> for &'static str` — asserts the
4547 // borrowed-input standard-library trait impl and the substrate-
4548 // primitive [`CaixaDialeto::as_str`] `pub const fn` accessor
4549 // resolve to the same four-arm emit-set across every arm the
4550 // exhaustive [`CaixaDialeto::ALL`] slice enumerates. Rust's
4551 // `From` trait does not auto-derive the borrowed-input sibling
4552 // from a paired owned-input impl (no `impl<T, U> From<&T> for U
4553 // where T: Copy, U: From<T>` blanket in `core`), so the
4554 // borrowed-input axis is a distinct trait-idiomatic surface that
4555 // a `.iter().map(Into::into)` shape over [`CaixaDialeto::ALL`]
4556 // (whose iterator yields `&CaixaDialeto`, not `CaixaDialeto`)
4557 // reaches through this impl and no other — the paired owned-
4558 // input [`From<CaixaDialeto>`] impl requires an explicit
4559 // `.copied()` / dereference before the trait fires.
4560 // Materializes the `<&'static str as From<&CaixaDialeto>>::from`
4561 // output in a `const`-shape binding to make the `'static`
4562 // lifetime promise a build-time invariant — a future accidental
4563 // downgrade of any of the four arms' returned literals to a
4564 // non-`&'static str` trips at caixa-core build time rather than
4565 // at a downstream `'static`-bound consumer. Peer of the sibling
4566 // [`crate::dep::tests::dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor`]
4567 // (64aa742) /
4568 // [`crate::kind::tests::caixa_kind_from_borrowed_into_static_str_routes_through_as_str_accessor`]
4569 // (5ab993a) pins on the sibling closed-set typed-enum borrowed-
4570 // input forward-projection axes — extends the borrowed-input
4571 // axis discipline onto the third peer on the substrate-wide
4572 // campaign, the dialect-classification axis.
4573 const PACOTE: &str = CaixaDialeto::Pacote.as_str();
4574 const MOLDE: &str = CaixaDialeto::Molde.as_str();
4575 const MOLDE_POSICIONAL: &str = CaixaDialeto::MoldePosicional.as_str();
4576 const DESCONHECIDO: &str = CaixaDialeto::Desconhecido.as_str();
4577 for variant in CaixaDialeto::ALL {
4578 let via_trait: &'static str = <&'static str as From<&CaixaDialeto>>::from(variant);
4579 let via_method: &'static str = variant.as_str();
4580 assert_eq!(
4581 via_trait, via_method,
4582 "From<&CaixaDialeto> for &'static str impl must round-trip \
4583 &CaixaDialeto::{variant:?} to the same `PascalCase` byte-\
4584 string CaixaDialeto::as_str returns — divergence signals a \
4585 silent detour off the substrate-primitive accessor"
4586 );
4587 let via_into: &'static str = variant.into();
4588 assert_eq!(
4589 via_into, via_method,
4590 "Into<&'static str>::into on &CaixaDialeto::{variant:?} must \
4591 byte-equal CaixaDialeto::as_str on the same input — the \
4592 blanket-derived Into shape must resolve to the same as_str \
4593 dispatch as the explicit From impl"
4594 );
4595 }
4596 assert_eq!(
4597 [PACOTE, MOLDE, MOLDE_POSICIONAL, DESCONHECIDO],
4598 ["Pacote", "Molde", "MoldePosicional", "Desconhecido"],
4599 "const-context CaixaDialeto::as_str must resolve to the four \
4600 `PascalCase` variant-name byte-strings — the borrowed-input \
4601 From<&CaixaDialeto> for &'static str impl inherits its \
4602 `'static` lifetime promise from the same accessor the owned-\
4603 input sibling routes through"
4604 );
4605 }
4606
4607 #[test]
4608 fn caixa_dialeto_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
4609 // Cross-axis partition pin: the paired trait-idiomatic
4610 // owned-input `From<CaixaDialeto> for &'static str` and
4611 // borrowed-input `From<&CaixaDialeto> for &'static str` (this
4612 // lift) forward projections must resolve identically on every
4613 // arm, locking the two input-shape paths together so any future
4614 // detour trips at caixa-core test time. Then a witness that a
4615 // `.iter().map(Into::into)` pipe over [`CaixaDialeto::ALL`]
4616 // (whose iterator yields `&CaixaDialeto`) materializes the four-
4617 // arm accept-set through the borrowed-input axis alone — the
4618 // exact shape a future M4 admission-webhook rejection body
4619 // composer, a future substrate-wide per-arm diagnostic column,
4620 // or a `HashMap::<&'static str, CaixaDialeto>::from_iter(
4621 // CaixaDialeto::ALL.iter().map(|d| (d.into(), *d)))`-style
4622 // per-dialect lookup reaches through — closing the two-way
4623 // owned/borrowed input-shape symmetry on the forward-projection
4624 // trait-idiomatic axis. Peer of the sibling
4625 // [`crate::dep::tests::dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
4626 // (64aa742) /
4627 // [`crate::kind::tests::caixa_kind_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
4628 // (5ab993a) partition pins — extends the borrowed-input axis
4629 // discipline onto the third peer on the substrate-wide campaign.
4630 for &variant in CaixaDialeto::ALL {
4631 let owned: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
4632 let borrowed: &'static str = <&'static str as From<&CaixaDialeto>>::from(&variant);
4633 assert_eq!(
4634 owned, borrowed,
4635 "From<CaixaDialeto> and From<&CaixaDialeto> for &'static str \
4636 must resolve identically on CaixaDialeto::{variant:?} — \
4637 divergence signals the owned-input and borrowed-input \
4638 forward-projection paths have drifted onto different \
4639 emit-sets"
4640 );
4641 }
4642 let via_iter: Vec<&'static str> = CaixaDialeto::ALL.iter().map(Into::into).collect();
4643 let via_method: Vec<&'static str> = CaixaDialeto::ALL.iter().map(|d| d.as_str()).collect();
4644 assert_eq!(
4645 via_iter, via_method,
4646 "`.iter().map(Into::into)` over CaixaDialeto::ALL must byte-\
4647 equal `.iter().map(|d| d.as_str())` on every arm — the \
4648 borrowed-input `From<&CaixaDialeto> for &'static str` axis \
4649 is what makes the `.iter().map(Into::into)` shape route \
4650 through the substrate-primitive `CaixaDialeto::as_str` \
4651 accessor rather than through a per-call-site `.copied()` / \
4652 dereference detour"
4653 );
4654 // Direct round-trip witness on the borrowed-input axis: every
4655 // arm's borrowed `From` output re-parses through the paired
4656 // trait-idiomatic reverse `TryFrom<&str>` back to the original
4657 // variant. Unlike the peer [`crate::CaixaKind`] axis pair
4658 // (whose forward `From<Self> for &'static str` emits the
4659 // lowercase Portuguese `as_str` diagnostic vocabulary while
4660 // the reverse `TryFrom<&str>` parses the `PascalCase`
4661 // `wire_name` author-surface vocabulary, forcing the round-trip
4662 // through an intermediate wire-vocab hop), [`CaixaDialeto`]'s
4663 // [`CaixaDialeto::as_str`] emit and [`CaixaDialeto::from_wire`]
4664 // parse share the same `PascalCase` vocabulary by construction,
4665 // so the borrowed-input forward axis and the reverse axis
4666 // compose directly.
4667 for &variant in CaixaDialeto::ALL {
4668 let borrowed: &'static str = <&'static str as From<&CaixaDialeto>>::from(&variant);
4669 let re_parsed: Result<CaixaDialeto, ()> =
4670 <CaixaDialeto as TryFrom<&str>>::try_from(borrowed);
4671 assert_eq!(
4672 re_parsed,
4673 Ok(variant),
4674 "trait-idiomatic borrowed-input round-trip must project \
4675 &CaixaDialeto::{variant:?} through \
4676 `<&'static str>::from(&variant)` and back through \
4677 `TryFrom<&str>` — a break signals the borrowed-input \
4678 forward-emit axis and the reverse-parse axis have \
4679 drifted onto different vocabularies"
4680 );
4681 }
4682 }
4683
4684 #[test]
4685 fn caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor() {
4686 // Fail-before-pass-after byte-parity pin on the newly lifted
4687 // `impl From<CaixaDialeto> for String` — asserts the owned-`String`
4688 // -returning standard-library trait impl and the substrate-
4689 // primitive [`CaixaDialeto::as_str`] `pub const fn` accessor
4690 // resolve to the same four-arm emit-set across every arm the
4691 // exhaustive [`CaixaDialeto::ALL`] slice enumerates. Rust's
4692 // standard library does not carry a blanket
4693 // `impl<T: AsRef<str>> From<T> for String` (nor an
4694 // `impl<T: fmt::Display> From<T> for String`), so the
4695 // owned-`String` forward-projection axis is a distinct trait-
4696 // idiomatic surface that a `let key: String = dialeto.into();`-
4697 // shaped call site reaches through this impl and no other — the
4698 // paired sibling `From<CaixaDialeto> for &'static str` impl
4699 // forces every owned-`String` call site through an explicit
4700 // `.to_owned()` / `String::from` restatement. Peer of the
4701 // first-mover
4702 // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
4703 // (7baa18a), the second-peer
4704 // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
4705 // (7851725), and the third-peer
4706 // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
4707 // (231a18c) — extends the trait-idiomatic owned-`String`
4708 // forward-projection axis onto the fourth closed-set fieldless
4709 // typed enum on the caixa surface (the dialect-classification
4710 // axis, second peer outside the M2 OTP-shape sibling axis).
4711 for &variant in CaixaDialeto::ALL {
4712 let via_trait: String = <String as From<CaixaDialeto>>::from(variant);
4713 let via_method: &'static str = variant.as_str();
4714 assert_eq!(
4715 via_trait.as_str(),
4716 via_method,
4717 "From<CaixaDialeto> for String impl must round-trip \
4718 CaixaDialeto::{variant:?} to the same `PascalCase` \
4719 arm-string CaixaDialeto::as_str returns — divergence \
4720 signals a silent detour off the substrate-primitive \
4721 accessor"
4722 );
4723 let via_into: String = variant.into();
4724 assert_eq!(
4725 via_into.as_str(),
4726 via_method,
4727 "Into<String>::into on CaixaDialeto::{variant:?} must \
4728 byte-equal CaixaDialeto::as_str on the same input — the \
4729 blanket-derived Into shape must resolve to the same \
4730 as_str dispatch as the explicit From impl"
4731 );
4732 }
4733 }
4734
4735 #[test]
4736 fn caixa_dialeto_from_into_owned_string_and_static_str_agree_on_every_arm() {
4737 // Cross-axis partition pin: the paired trait-idiomatic
4738 // owned-`String` `From<CaixaDialeto> for String` (this lift) and
4739 // owned-`&'static str` `From<CaixaDialeto> for &'static str`
4740 // (c189a6f) forward projections must resolve identically on
4741 // every arm, locking the two return-type-shape paths together
4742 // so any future detour trips at caixa-core test time. Also
4743 // byte-parity witness against the sibling
4744 // [`ToString::to_string`] surface routed through
4745 // [`std::fmt::Display`] — the three owned-heap-string paths
4746 // (`.into::<String>()`, `String::from`, `.to_string()`) must
4747 // resolve identically on every arm so a future consumer that
4748 // picks any of the three lands on the same four-arm
4749 // `PascalCase` accept-set. Then a `.iter().copied()
4750 // .map(String::from)` pipe witness over [`CaixaDialeto::ALL`]
4751 // that materializes the four-arm accept-set through the
4752 // owned-`String` axis alone — the exact shape a future M4
4753 // admission-webhook rejection body composer or a
4754 // `HashMap::<String, CaixaDialeto>::from_iter(
4755 // CaixaDialeto::ALL.iter().copied().map(|d| (d.into(), d)))`-
4756 // style owned-key per-dialect lookup reaches through — closing
4757 // the owned-`String` forward-projection axis's iterator-pipe
4758 // shape. Then a direct round-trip witness through the paired
4759 // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
4760 // owned-`String`'s [`String::as_str`] borrow that closes the
4761 // two-way `Self → String → Self` round-trip on the trait-
4762 // idiomatic owned-`String` forward + reverse axis pair.
4763 //
4764 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
4765 // `From` emit lands on the lowercase Portuguese `as_str`
4766 // diagnostic vocabulary while the reverse `TryFrom<&str>` parses
4767 // the `PascalCase` `wire_name` author-surface vocabulary,
4768 // forcing the round-trip through an intermediate
4769 // [`crate::CaixaKind::wire_name`] hop), [`CaixaDialeto`]'s
4770 // [`CaixaDialeto::as_str`] emit and [`CaixaDialeto::from_wire`]
4771 // parse share the same `PascalCase` vocabulary by construction
4772 // (there is no wire/diagnostic axis split on this enum), so
4773 // the owned-`String` forward axis and the reverse axis compose
4774 // directly — matching the peer
4775 // [`crate::supervisor::RestartStrategy`] /
4776 // [`crate::supervisor::RestartPolicy`] owned-`String` axis
4777 // pairs (whose forward emit and reverse parse also share one
4778 // `PascalCase` vocabulary by construction).
4779 for &variant in CaixaDialeto::ALL {
4780 let owned_string: String = <String as From<CaixaDialeto>>::from(variant);
4781 let owned_static: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
4782 assert_eq!(
4783 owned_string.as_str(),
4784 owned_static,
4785 "From<CaixaDialeto> for String and From<CaixaDialeto> for \
4786 &'static str must resolve identically on \
4787 CaixaDialeto::{variant:?} — divergence signals the \
4788 owned-`String` and owned-`&'static str` forward-\
4789 projection return-type-shape paths have drifted onto \
4790 different emit-sets"
4791 );
4792 let via_to_string: String = variant.to_string();
4793 assert_eq!(
4794 owned_string, via_to_string,
4795 "From<CaixaDialeto> for String must byte-equal \
4796 CaixaDialeto::to_string on CaixaDialeto::{variant:?} — \
4797 divergence signals the trait-idiomatic owned-`String` \
4798 forward-projection axis and the ToString-through-\
4799 Display axis have drifted onto different emit-sets"
4800 );
4801 }
4802 let via_iter: Vec<String> = CaixaDialeto::ALL
4803 .iter()
4804 .copied()
4805 .map(String::from)
4806 .collect();
4807 let via_method: Vec<String> = CaixaDialeto::ALL
4808 .iter()
4809 .map(|d| d.as_str().to_owned())
4810 .collect();
4811 assert_eq!(
4812 via_iter, via_method,
4813 "`.iter().copied().map(String::from)` over CaixaDialeto::ALL \
4814 must byte-equal `.iter().map(|d| d.as_str().to_owned())` on \
4815 every arm — the owned-`String` `From<CaixaDialeto> for \
4816 String` axis is what makes the `String::from` composition \
4817 route through the substrate-primitive `CaixaDialeto::as_str` \
4818 accessor rather than through a per-call-site `.to_owned()` / \
4819 `String::from(dialeto.as_str())` detour"
4820 );
4821 for &variant in CaixaDialeto::ALL {
4822 let emitted: String = variant.into();
4823 let re_parsed: Result<CaixaDialeto, ()> =
4824 <CaixaDialeto as TryFrom<&str>>::try_from(emitted.as_str());
4825 assert_eq!(
4826 re_parsed,
4827 Ok(variant),
4828 "trait-idiomatic owned-`String` forward-projection + \
4829 reverse-projection axis pair must round-trip \
4830 CaixaDialeto::{variant:?} through `.into::<String>()` \
4831 and back through `TryFrom<&str>` on the owned-`String`'s \
4832 String::as_str borrow — a break signals the owned-\
4833 `String` forward-emit and reverse-parse axes have \
4834 drifted onto different vocabularies (unlike the peer \
4835 CaixaKind axis pair, CaixaDialeto's forward emit and \
4836 reverse parse share one PascalCase vocabulary by \
4837 construction, so the round-trip composes directly)"
4838 );
4839 }
4840 }
4841
4842 #[test]
4843 fn caixa_dialeto_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
4844 // Fail-before-pass-after byte-parity pin on the newly lifted
4845 // `impl From<&CaixaDialeto> for String` — asserts the borrowed-
4846 // input owned-`String`-returning standard-library trait impl and
4847 // the substrate-primitive [`super::CaixaDialeto::as_str`]
4848 // `pub const fn` accessor resolve to the same four-arm emit-set
4849 // across every arm the exhaustive [`super::CaixaDialeto::ALL`]
4850 // slice enumerates. Rust's standard library does not carry a
4851 // blanket `impl<T: AsRef<str>> From<&T> for String` (nor an
4852 // `impl<T: fmt::Display> From<&T> for String`), so the
4853 // borrowed-input owned-`String` forward-projection axis is a
4854 // distinct trait-idiomatic surface that a
4855 // `let key: String = (&dialeto).into();`-shaped call site
4856 // reaches through this impl and no other — the paired sibling
4857 // `From<CaixaDialeto> for String` impl forces every borrowed-
4858 // input call site through an explicit `Copy` deref
4859 // (`String::from(*dialeto)`) or an `.as_str().to_owned()` /
4860 // `.to_string()` detour. Peer of the first-mover
4861 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
4862 // (579385f), the second-peer
4863 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
4864 // (8465740), the third-peer
4865 // [`crate::dep::tests::dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
4866 // (e0cb617), and the fourth-peer
4867 // [`crate::kind::tests::caixa_kind_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
4868 // (e76436d) — extends the trait-idiomatic borrowed-input owned-
4869 // `String` forward-projection axis onto the fourth closed-set
4870 // fieldless typed enum on the caixa surface (the dialect-
4871 // classification axis, second peer outside the M2 OTP-shape
4872 // sibling axis to reach the 2×2-completion corner).
4873 for &variant in CaixaDialeto::ALL {
4874 let via_trait: String = <String as From<&CaixaDialeto>>::from(&variant);
4875 let via_method: &'static str = variant.as_str();
4876 assert_eq!(
4877 via_trait.as_str(),
4878 via_method,
4879 "From<&CaixaDialeto> for String impl must round-trip \
4880 &CaixaDialeto::{variant:?} to the same `PascalCase` \
4881 arm-string CaixaDialeto::as_str returns — divergence \
4882 signals a silent detour off the substrate-primitive \
4883 accessor"
4884 );
4885 let via_into: String = (&variant).into();
4886 assert_eq!(
4887 via_into.as_str(),
4888 via_method,
4889 "Into<String>::into on &CaixaDialeto::{variant:?} must \
4890 byte-equal CaixaDialeto::as_str on the same input — \
4891 the blanket-derived Into shape must resolve to the \
4892 same as_str dispatch as the explicit From impl"
4893 );
4894 }
4895 }
4896
4897 #[test]
4898 fn caixa_dialeto_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
4899 // Cross-axis partition pin: the newly lifted trait-idiomatic
4900 // borrowed-input owned-`String` `From<&CaixaDialeto> for String`
4901 // (this lift), the paired owned-input owned-`String`
4902 // `From<CaixaDialeto> for String` (88942cd), the paired
4903 // borrowed-input owned-`&'static str`
4904 // `From<&CaixaDialeto> for &'static str` (807b0b5), and the
4905 // paired owned-input owned-`&'static str`
4906 // `From<CaixaDialeto> for &'static str` (c189a6f) — every corner
4907 // of the `{Self, &Self} × {&'static str, String}` 2×2 trait-
4908 // idiomatic projection family — must resolve identically on
4909 // every arm, locking the four return-shape × input-shape paths
4910 // together so any future detour trips at caixa-core test time.
4911 // Also byte-parity witness against the sibling
4912 // [`ToString::to_string`] surface routed through
4913 // [`std::fmt::Display`] and a direct round-trip witness through
4914 // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
4915 // the owned-`String`'s [`String::as_str`] borrow that closes
4916 // the two-way `&Self → String → Self` round-trip on the trait-
4917 // idiomatic borrowed-input owned-`String` forward + reverse
4918 // axis pair. Peer of the first-mover
4919 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
4920 // (579385f), the second-peer
4921 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
4922 // (8465740), the third-peer
4923 // [`crate::dep::tests::dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
4924 // (e0cb617), and the fourth-peer
4925 // [`crate::kind::tests::caixa_kind_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
4926 // (e76436d) — closes the whole `{Self, &Self} × {&'static str,
4927 // String}` 2×2 projection corner on the fifth substrate-wide
4928 // closed-set fieldless typed enum peer (the dialect-
4929 // classification axis, second peer outside the M2 OTP-shape
4930 // sibling pair).
4931 //
4932 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
4933 // `From` emit lands on the lowercase Portuguese `as_str`
4934 // diagnostic vocabulary while the reverse `TryFrom<&str>`
4935 // parses the `PascalCase` `wire_name` author-surface vocabulary,
4936 // forcing the round-trip through an intermediate
4937 // [`crate::CaixaKind::wire_name`] hop), [`super::CaixaDialeto`]'s
4938 // [`super::CaixaDialeto::as_str`] emit and
4939 // [`super::CaixaDialeto::from_wire`] parse share the same
4940 // `PascalCase` vocabulary by construction (there is no
4941 // wire/diagnostic axis split on this enum), so the borrowed-
4942 // input owned-`String` forward axis and the reverse axis compose
4943 // directly — matching the peer
4944 // [`crate::supervisor::RestartStrategy`] /
4945 // [`crate::supervisor::RestartPolicy`] / [`crate::dep::DepList`]
4946 // borrowed-input owned-`String` axis pairs.
4947 for &dialeto in CaixaDialeto::ALL {
4948 let borrowed_string: String = <String as From<&CaixaDialeto>>::from(&dialeto);
4949 let owned_string: String = <String as From<CaixaDialeto>>::from(dialeto);
4950 let borrowed_static: &'static str =
4951 <&'static str as From<&CaixaDialeto>>::from(&dialeto);
4952 let owned_static: &'static str = <&'static str as From<CaixaDialeto>>::from(dialeto);
4953 assert_eq!(
4954 borrowed_string, owned_string,
4955 "From<&CaixaDialeto> for String and From<CaixaDialeto> \
4956 for String must resolve identically on \
4957 CaixaDialeto::{dialeto:?} — divergence signals the \
4958 borrowed-input and owned-input owned-`String` forward-\
4959 projection input-shape paths have drifted onto \
4960 different emit-sets"
4961 );
4962 assert_eq!(
4963 borrowed_string.as_str(),
4964 borrowed_static,
4965 "From<&CaixaDialeto> for String and From<&CaixaDialeto> \
4966 for &'static str must resolve identically on \
4967 CaixaDialeto::{dialeto:?} — divergence signals the \
4968 borrowed-input `&'static str` and owned-`String` \
4969 return-shape paths have drifted onto different \
4970 emit-sets"
4971 );
4972 assert_eq!(
4973 borrowed_string.as_str(),
4974 owned_static,
4975 "From<&CaixaDialeto> for String and From<CaixaDialeto> \
4976 for &'static str must resolve identically on \
4977 CaixaDialeto::{dialeto:?} — divergence signals a break \
4978 in the diagonal corner of the {{Self, &Self}} × \
4979 {{&'static str, String}} 2×2 trait-idiomatic \
4980 projection family"
4981 );
4982 let via_to_string: String = dialeto.to_string();
4983 assert_eq!(
4984 borrowed_string, via_to_string,
4985 "From<&CaixaDialeto> for String must byte-equal \
4986 CaixaDialeto::to_string on CaixaDialeto::{dialeto:?} — \
4987 divergence signals the trait-idiomatic borrowed-input \
4988 owned-`String` forward-projection axis and the \
4989 ToString-through-Display axis have drifted onto \
4990 different emit-sets"
4991 );
4992 }
4993 let via_iter: Vec<String> = CaixaDialeto::ALL.iter().map(String::from).collect();
4994 let via_method: Vec<String> = CaixaDialeto::ALL
4995 .iter()
4996 .map(|d| d.as_str().to_owned())
4997 .collect();
4998 assert_eq!(
4999 via_iter, via_method,
5000 "`.iter().map(String::from)` over CaixaDialeto::ALL — a \
5001 call site whose iteration axis holds `&CaixaDialeto` by \
5002 construction — must byte-equal `.iter().map(|d| \
5003 d.as_str().to_owned())` on every arm — the borrowed-input \
5004 owned-`String` `From<&CaixaDialeto> for String` axis is \
5005 what makes the `String::from` composition route through \
5006 the substrate-primitive `CaixaDialeto::as_str` accessor \
5007 without a spurious `Copy` deref (which would only be \
5008 reachable through the owned-input `From<CaixaDialeto> for \
5009 String` axis by first calling `.copied()` on the iterator)"
5010 );
5011 for &variant in CaixaDialeto::ALL {
5012 let emitted: String = (&variant).into();
5013 let re_parsed: Result<CaixaDialeto, ()> =
5014 <CaixaDialeto as TryFrom<&str>>::try_from(emitted.as_str());
5015 assert_eq!(
5016 re_parsed,
5017 Ok(variant),
5018 "trait-idiomatic borrowed-input owned-`String` \
5019 forward-projection + reverse-projection axis pair \
5020 must round-trip &CaixaDialeto::{variant:?} through \
5021 `.into::<String>()` on the borrowed-input surface and \
5022 back through `TryFrom<&str>` on the owned-`String`'s \
5023 String::as_str borrow — a break signals the \
5024 borrowed-input owned-`String` forward-emit and \
5025 reverse-parse axes have drifted onto different \
5026 vocabularies (unlike the peer CaixaKind axis pair, \
5027 CaixaDialeto's forward emit and reverse parse share \
5028 one PascalCase vocabulary by construction, so the \
5029 round-trip composes directly)"
5030 );
5031 }
5032 }
5033
5034 #[test]
5035 fn caixa_dialeto_from_into_static_cow_str_routes_through_as_str_accessor() {
5036 // Fail-before-pass-after byte-parity pin on the newly lifted
5037 // `impl From<CaixaDialeto> for std::borrow::Cow<'static, str>`
5038 // — asserts the standard-library trait impl and the
5039 // substrate-primitive [`super::CaixaDialeto::as_str`]
5040 // `pub const fn` accessor resolve to the same four-arm
5041 // emit-set across every arm the exhaustive
5042 // [`super::CaixaDialeto::ALL`] slice enumerates. Rust's
5043 // standard library does not carry a blanket
5044 // `impl<T: AsRef<str>> From<T> for std::borrow::Cow<'static,
5045 // str>` (nor an `impl<T: fmt::Display> From<T> for
5046 // std::borrow::Cow<'static, str>`), so the
5047 // [`std::borrow::Cow<'static, str>`] forward-projection axis
5048 // is a distinct trait-idiomatic surface that a
5049 // `let key: std::borrow::Cow<'static, str> = dialeto.into();`-
5050 // shaped call site reaches through this impl and no other —
5051 // the paired sibling `From<CaixaDialeto> for &'static str`
5052 // and `From<CaixaDialeto> for String` impls force every
5053 // [`std::borrow::Cow<'static, str>`]-parameterized call site
5054 // through a `std::borrow::Cow::Borrowed(dialeto.as_str())` /
5055 // `std::borrow::Cow::Owned(dialeto.to_string())` /
5056 // `String::from(dialeto).into()` composition whose type
5057 // bounds have no compile-time link back to the substrate
5058 // primitive.
5059 //
5060 // Also asserts the projection lands on the zero-alloc
5061 // [`std::borrow::Cow::Borrowed`] arm (not the
5062 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
5063 // [`super::CaixaDialeto::as_str`] accessor's `&'static str`
5064 // return lifetime by construction makes the borrowed arm the
5065 // type-correct projection with no runtime allocation. Any
5066 // future silent detour that routes the impl through the
5067 // owned arm (an accidental
5068 // `std::borrow::Cow::Owned(dialeto.to_string())` rewrite that
5069 // would allocate on every call site where the `&'static str`
5070 // return of [`super::CaixaDialeto::as_str`] makes the
5071 // zero-alloc borrowed projection type-correct) trips at
5072 // caixa-core test time under the
5073 // [`std::borrow::Cow::Borrowed`] discriminator witness rather
5074 // than at a downstream
5075 // [`std::borrow::Cow<'static, str>`]-bound consumer's silent
5076 // allocation.
5077 //
5078 // Second peer on the outside-M3 caixa-core tier of the
5079 // substrate-wide trait-idiomatic
5080 // [`std::borrow::Cow<'static, str>`] forward-projection
5081 // family — extends the axis off the two-list dep-graph
5082 // [`crate::dep::DepList`] pair (6858bac / 702cdf4) that
5083 // opened + closed the tier onto the dialect-classification
5084 // [`super::CaixaDialeto`] enum (the sole remaining
5085 // internal-classification peer on the caixa-core surface).
5086 // Every future closed-set fieldless typed enum peer on the
5087 // substrate is a future target of the campaign.
5088 for &variant in CaixaDialeto::ALL {
5089 let via_trait: std::borrow::Cow<'static, str> =
5090 <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
5091 let via_method: &'static str = variant.as_str();
5092 assert_eq!(
5093 via_trait.as_ref(),
5094 via_method,
5095 "From<CaixaDialeto> for Cow<'static, str> impl must \
5096 round-trip CaixaDialeto::{variant:?} to the same \
5097 PascalCase byte-string CaixaDialeto::as_str returns \
5098 — divergence signals a silent detour off the \
5099 substrate-primitive accessor"
5100 );
5101 assert!(
5102 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
5103 "From<CaixaDialeto> for Cow<'static, str> impl must \
5104 land on the zero-alloc Cow::Borrowed arm on \
5105 CaixaDialeto::{variant:?} — a Cow::Owned outcome \
5106 signals the projection has silently allocated where \
5107 the substrate-primitive CaixaDialeto::as_str \
5108 `&'static str` return makes the borrowed arm the \
5109 type-correct projection"
5110 );
5111 let via_into: std::borrow::Cow<'static, str> = variant.into();
5112 assert_eq!(
5113 via_into.as_ref(),
5114 via_method,
5115 "Into<Cow<'static, str>>::into on \
5116 CaixaDialeto::{variant:?} must byte-equal \
5117 CaixaDialeto::as_str on the same input — the \
5118 blanket-derived Into shape must resolve to the same \
5119 as_str dispatch as the explicit From impl"
5120 );
5121 assert!(
5122 matches!(via_into, std::borrow::Cow::Borrowed(_)),
5123 "Into<Cow<'static, str>>::into on \
5124 CaixaDialeto::{variant:?} must land on the zero-alloc \
5125 Cow::Borrowed arm — the blanket-derived Into shape \
5126 must resolve to the same Cow::Borrowed dispatch as \
5127 the explicit From impl"
5128 );
5129 }
5130 }
5131
5132 #[test]
5133 fn caixa_dialeto_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
5134 // Cross-axis partition pin: the newly lifted trait-idiomatic
5135 // `From<CaixaDialeto> for std::borrow::Cow<'static, str>`
5136 // (this lift), the paired owned-input
5137 // `From<CaixaDialeto> for &'static str`, and the paired
5138 // owned-input `From<CaixaDialeto> for String` forward
5139 // projections must resolve identically on every arm, locking
5140 // the three return-shape paths together by construction so
5141 // any future detour trips at caixa-core test time. Also
5142 // byte-parity witness against the sibling
5143 // [`ToString::to_string`] surface routed through
5144 // [`std::fmt::Display`] — every owned-heap-string path (the
5145 // [`std::borrow::Cow::Owned`] promotion of this axis's
5146 // `.into_owned()`, `From<CaixaDialeto> for String`, and
5147 // `.to_string()`) resolves to the same PascalCase byte-string
5148 // per arm.
5149 //
5150 // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
5151 // witness over [`super::CaixaDialeto::ALL`] that materializes
5152 // the four-arm accept-set through the
5153 // [`std::borrow::Cow<'static, str>`] axis alone — the exact
5154 // shape a future `axum::response::IntoResponse` per-arm
5155 // rejection-body composer, a future M4
5156 // `mesh.pleme.io/v1alpha1/Manifesto` CR materializer's
5157 // admission-webhook per-arm rejection-reason emitter whose
5158 // typing rules out the sibling [`AsRef<str>`] borrowed
5159 // return, or a future substrate-wide per-arm diagnostic
5160 // surface that binds through a
5161 // [`std::borrow::Cow<'static, str>`] boundary reaches through
5162 // — closing the composable-projection axis on the dialect-
5163 // classification closed-set fieldless typed enum peer. The
5164 // pipe witness also pins the zero-alloc discipline: every
5165 // element in the collected vector satisfies the
5166 // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
5167 // accidental silent-allocation regression on the pipe's
5168 // iteration axis is a caixa-core-test-time failure.
5169 //
5170 // Then a direct round-trip witness through
5171 // [`TryFrom<&str>`] on the projection's
5172 // [`std::borrow::Cow::as_ref`] borrow — unlike the peer
5173 // [`crate::CaixaKind`] axis pair (whose forward emit lands
5174 // on the lowercase Portuguese diagnostic vocabulary while
5175 // the reverse parse lands on the `PascalCase` wire
5176 // vocabulary, forcing the round-trip through an intermediate
5177 // [`crate::CaixaKind::wire_name`] hop),
5178 // [`super::CaixaDialeto`]'s forward emit and reverse parse
5179 // share one `PascalCase` vocabulary by construction, so the
5180 // [`std::borrow::Cow<'static, str>`] projection composes
5181 // directly with the trait-idiomatic reverse [`TryFrom<&str>`]
5182 // axis without the wire-vocab intermediate hop.
5183 for &variant in CaixaDialeto::ALL {
5184 let via_cow: std::borrow::Cow<'static, str> =
5185 <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
5186 let via_static: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
5187 let via_string: String = <String as From<CaixaDialeto>>::from(variant);
5188 assert_eq!(
5189 via_cow.as_ref(),
5190 via_static,
5191 "From<CaixaDialeto> for Cow<'static, str> and \
5192 From<CaixaDialeto> for &'static str must resolve \
5193 identically on CaixaDialeto::{variant:?} — \
5194 divergence signals the Cow<'static, str> and \
5195 &'static str return-shape paths have drifted onto \
5196 different emit-sets"
5197 );
5198 assert_eq!(
5199 via_cow.as_ref(),
5200 via_string.as_str(),
5201 "From<CaixaDialeto> for Cow<'static, str> and \
5202 From<CaixaDialeto> for String must resolve \
5203 identically on CaixaDialeto::{variant:?} — \
5204 divergence signals the Cow<'static, str> and String \
5205 return-shape paths have drifted onto different \
5206 emit-sets"
5207 );
5208 let via_to_string: String = variant.to_string();
5209 assert_eq!(
5210 via_cow.as_ref(),
5211 via_to_string.as_str(),
5212 "From<CaixaDialeto> for Cow<'static, str> must \
5213 byte-equal CaixaDialeto::to_string on \
5214 CaixaDialeto::{variant:?} — divergence signals the \
5215 trait-idiomatic Cow<'static, str> forward-projection \
5216 axis and the ToString-through-Display axis have \
5217 drifted onto different emit-sets"
5218 );
5219 }
5220 let via_iter: Vec<std::borrow::Cow<'static, str>> = CaixaDialeto::ALL
5221 .iter()
5222 .copied()
5223 .map(std::borrow::Cow::from)
5224 .collect();
5225 let via_method: Vec<std::borrow::Cow<'static, str>> = CaixaDialeto::ALL
5226 .iter()
5227 .map(|d| std::borrow::Cow::Borrowed(d.as_str()))
5228 .collect();
5229 assert_eq!(
5230 via_iter, via_method,
5231 "`.iter().copied().map(Cow::from)` over \
5232 CaixaDialeto::ALL must byte-equal `.iter().map(|d| \
5233 Cow::Borrowed(d.as_str()))` on every arm — the \
5234 trait-idiomatic `From<CaixaDialeto> for Cow<'static, \
5235 str>` axis is what makes the `Cow::from` composition \
5236 route through the substrate-primitive \
5237 CaixaDialeto::as_str accessor rather than a per-call-\
5238 site open-code"
5239 );
5240 for cow in &via_iter {
5241 assert!(
5242 matches!(cow, std::borrow::Cow::Borrowed(_)),
5243 "`.iter().copied().map(Cow::from)` over \
5244 CaixaDialeto::ALL must land on the zero-alloc \
5245 Cow::Borrowed arm on every element — a Cow::Owned \
5246 outcome signals the pipe has silently allocated \
5247 where the substrate-primitive \
5248 CaixaDialeto::as_str `&'static str` return makes \
5249 the borrowed arm the type-correct projection"
5250 );
5251 }
5252 for &variant in CaixaDialeto::ALL {
5253 let via_cow: std::borrow::Cow<'static, str> =
5254 <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
5255 let re_parsed: Result<CaixaDialeto, ()> =
5256 <CaixaDialeto as TryFrom<&str>>::try_from(via_cow.as_ref());
5257 assert_eq!(
5258 re_parsed,
5259 Ok(variant),
5260 "trait-idiomatic Cow<'static, str> forward-projection \
5261 + reverse-projection axis pair must round-trip \
5262 CaixaDialeto::{variant:?} through `.into::<Cow<\
5263 'static, str>>()` on the owned-input surface and \
5264 back through `TryFrom<&str>` on the projection's \
5265 Cow::as_ref borrow — a break signals the \
5266 Cow<'static, str> forward-emit and reverse-parse \
5267 axes have drifted onto different vocabularies \
5268 (unlike the peer CaixaKind axis pair, CaixaDialeto's \
5269 forward emit and reverse parse share one PascalCase \
5270 vocabulary by construction, so the round-trip \
5271 composes directly)"
5272 );
5273 }
5274 }
5275
5276 #[test]
5277 fn caixa_dialeto_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
5278 // Fail-before-pass-after byte-parity pin on the newly lifted
5279 // `impl From<&CaixaDialeto> for std::borrow::Cow<'static,
5280 // str>` — asserts the borrowed-input standard-library trait
5281 // impl and the substrate-primitive
5282 // [`super::CaixaDialeto::as_str`] `pub const fn` accessor
5283 // resolve to the same four-arm PascalCase emit-set across
5284 // every arm the exhaustive [`super::CaixaDialeto::ALL`] slice
5285 // enumerates. Rust's standard library does not carry a blanket
5286 // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
5287 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
5288 // the borrowed-input `Cow<'static, str>` forward-projection
5289 // axis is a distinct trait-idiomatic surface that a
5290 // `let key: Cow<'static, str> = (&dialeto).into();`-shaped
5291 // call site or a `CaixaDialeto::ALL.iter().map(Cow::from)`-
5292 // shaped pipe reaches through this impl and no other — the
5293 // paired owned-input `From<CaixaDialeto> for Cow<'static, str>`
5294 // impl (8322511) forces every borrowed-input call site
5295 // through an explicit `Copy` deref (`Cow::from(*dialeto)`) or
5296 // a `Cow::Borrowed(dialeto.as_str())` open-code whose type
5297 // bounds have no compile-time link back to the substrate
5298 // primitive.
5299 //
5300 // Also asserts the projection lands on the zero-alloc
5301 // [`std::borrow::Cow::Borrowed`] arm (not the
5302 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
5303 // [`super::CaixaDialeto::as_str`] accessor's `&'static str`
5304 // return lifetime by construction makes the borrowed arm the
5305 // type-correct projection with no runtime allocation on the
5306 // borrowed-input surface just as on the paired owned-input
5307 // surface.
5308 //
5309 // Closes the `{Self, &Self}` input-shape corner on the
5310 // outside-M3 caixa-core dialect-classification
5311 // [`Cow<'static, str>`] axis on the second outside-M3
5312 // caixa-core closed-set fieldless typed enum peer on the
5313 // caixa surface, exactly as 702cdf4 closed it on the first
5314 // outside-M3 caixa-core peer ([`crate::dep::DepList`]) one
5315 // commit after the owning half (6858bac) landed, as afdf0f4
5316 // closed it on the second M3-mesh-primitive peer
5317 // ([`crate::aplicacao::PlacementStrategy`]) one commit after
5318 // the owning half (eee504d) landed, as 25690ef closed it on
5319 // the first M3-mesh-primitive peer
5320 // ([`crate::aplicacao::WitShape`]) one commit after the
5321 // owning half (8634dec) landed, as d45c409 closed it on the
5322 // top-level [`crate::CaixaKind`] one commit after the owning
5323 // half (99c1735) landed, and as 9b3e4b3 / ee577fd closed it
5324 // on the M2 OTP-shape [`crate::supervisor::RestartStrategy`]
5325 // / [`crate::supervisor::RestartPolicy`] sibling peers one
5326 // commit after (7dd28b3 / 0612398) landed.
5327 for &variant in CaixaDialeto::ALL {
5328 let via_trait: std::borrow::Cow<'static, str> =
5329 <std::borrow::Cow<'static, str> as From<&CaixaDialeto>>::from(&variant);
5330 let via_method: &'static str = variant.as_str();
5331 assert_eq!(
5332 via_trait.as_ref(),
5333 via_method,
5334 "From<&CaixaDialeto> for Cow<'static, str> impl must \
5335 round-trip &CaixaDialeto::{variant:?} to the same \
5336 PascalCase byte-string CaixaDialeto::as_str returns \
5337 — divergence signals a silent detour off the \
5338 substrate-primitive accessor"
5339 );
5340 assert!(
5341 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
5342 "From<&CaixaDialeto> for Cow<'static, str> impl must \
5343 land on the zero-alloc Cow::Borrowed arm on \
5344 &CaixaDialeto::{variant:?} — a Cow::Owned outcome \
5345 signals the projection has silently allocated where \
5346 the substrate-primitive CaixaDialeto::as_str \
5347 `&'static str` return makes the borrowed arm the \
5348 type-correct projection"
5349 );
5350 let via_into: std::borrow::Cow<'static, str> = (&variant).into();
5351 assert_eq!(
5352 via_into.as_ref(),
5353 via_method,
5354 "Into<Cow<'static, str>>::into on \
5355 &CaixaDialeto::{variant:?} must byte-equal \
5356 CaixaDialeto::as_str on the same input — the \
5357 blanket-derived Into shape on the borrowed-input \
5358 surface must resolve to the same as_str dispatch as \
5359 the explicit From impl"
5360 );
5361 assert!(
5362 matches!(via_into, std::borrow::Cow::Borrowed(_)),
5363 "Into<Cow<'static, str>>::into on \
5364 &CaixaDialeto::{variant:?} must land on the \
5365 zero-alloc Cow::Borrowed arm — the blanket-derived \
5366 Into shape on the borrowed-input surface must \
5367 resolve to the same Cow::Borrowed dispatch as the \
5368 explicit From impl"
5369 );
5370 }
5371 }
5372
5373 #[test]
5374 #[allow(
5375 clippy::too_many_lines,
5376 reason = "cross-axis partition pin folds four return-shape paths \
5377 (borrowed-input Cow<'static, str>, owned-input Cow<'static, str>, \
5378 borrowed-input &'static str, borrowed-input String) plus the \
5379 ToString-through-Display witness plus a `.iter().map(Cow::from)` \
5380 pipe witness with zero-alloc discriminator plus a direct \
5381 round-trip witness through TryFrom<&str> over four typed \
5382 variants; the linear per-axis repetition is exactly what the \
5383 fold is pinning — a helper would hide the shape it locks"
5384 )]
5385 fn caixa_dialeto_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
5386 // Cross-axis partition pin: the newly lifted trait-idiomatic
5387 // borrowed-input `From<&CaixaDialeto> for
5388 // std::borrow::Cow<'static, str>` (this lift), the paired
5389 // owned-input `From<CaixaDialeto> for
5390 // std::borrow::Cow<'static, str>`, the paired borrowed-input
5391 // `From<&CaixaDialeto> for &'static str`, and the paired
5392 // borrowed-input `From<&CaixaDialeto> for String` forward
5393 // projections must resolve identically on every arm, locking
5394 // the four return-shape paths together by construction so any
5395 // future detour trips at caixa-core test time. Also
5396 // byte-parity witness against the sibling
5397 // [`ToString::to_string`] surface routed through
5398 // [`std::fmt::Display`].
5399 //
5400 // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
5401 // over [`super::CaixaDialeto::ALL`] — whose iterator yields
5402 // `&CaixaDialeto` by construction, so the borrowed-input
5403 // [`std::borrow::Cow<'static, str>`] axis is what routes the
5404 // pipe through the substrate-primitive
5405 // [`super::CaixaDialeto::as_str`] accessor with the zero-alloc
5406 // [`std::borrow::Cow::Borrowed`] arm and without a spurious
5407 // [`Copy`] deref. Every collected element satisfies the
5408 // [`std::borrow::Cow::Borrowed`]-arm predicate so a future
5409 // accidental silent-allocation regression on the pipe's
5410 // iteration axis is a caixa-core-test-time failure.
5411 //
5412 // Then a direct round-trip witness through [`TryFrom<&str>`]
5413 // on the projection's [`std::borrow::Cow::as_ref`] borrow —
5414 // unlike the peer [`crate::CaixaKind`] axis pair (whose
5415 // forward emit lands on the lowercase Portuguese diagnostic
5416 // vocabulary while the reverse parse lands on the
5417 // `PascalCase` wire vocabulary, forcing the round-trip
5418 // through an intermediate [`crate::CaixaKind::wire_name`]
5419 // hop), [`super::CaixaDialeto`]'s forward emit and reverse
5420 // parse share one `PascalCase` vocabulary by construction, so
5421 // the borrowed-input [`std::borrow::Cow<'static, str>`]
5422 // projection composes directly with the trait-idiomatic
5423 // reverse [`TryFrom<&str>`] axis without the wire-vocab
5424 // intermediate hop.
5425 for &variant in CaixaDialeto::ALL {
5426 let via_borrowed_cow: std::borrow::Cow<'static, str> =
5427 <std::borrow::Cow<'static, str> as From<&CaixaDialeto>>::from(&variant);
5428 let via_owned_cow: std::borrow::Cow<'static, str> =
5429 <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
5430 let via_borrowed_static: &'static str =
5431 <&'static str as From<&CaixaDialeto>>::from(&variant);
5432 let via_borrowed_string: String = <String as From<&CaixaDialeto>>::from(&variant);
5433 assert_eq!(
5434 via_borrowed_cow.as_ref(),
5435 via_owned_cow.as_ref(),
5436 "From<&CaixaDialeto> for Cow<'static, str> and \
5437 From<CaixaDialeto> for Cow<'static, str> must \
5438 resolve identically on CaixaDialeto::{variant:?} — \
5439 divergence signals the borrowed-input and \
5440 owned-input Cow<'static, str> return-shape paths \
5441 have drifted onto different emit-sets"
5442 );
5443 assert_eq!(
5444 via_borrowed_cow.as_ref(),
5445 via_borrowed_static,
5446 "From<&CaixaDialeto> for Cow<'static, str> and \
5447 From<&CaixaDialeto> for &'static str must resolve \
5448 identically on CaixaDialeto::{variant:?} — \
5449 divergence signals the borrowed-input Cow<'static, \
5450 str> and borrowed-input &'static str return-shape \
5451 paths have drifted onto different emit-sets"
5452 );
5453 assert_eq!(
5454 via_borrowed_cow.as_ref(),
5455 via_borrowed_string.as_str(),
5456 "From<&CaixaDialeto> for Cow<'static, str> and \
5457 From<&CaixaDialeto> for String must resolve \
5458 identically on CaixaDialeto::{variant:?} — \
5459 divergence signals the borrowed-input Cow<'static, \
5460 str> and borrowed-input String return-shape paths \
5461 have drifted onto different emit-sets"
5462 );
5463 let via_to_string: String = variant.to_string();
5464 assert_eq!(
5465 via_borrowed_cow.as_ref(),
5466 via_to_string.as_str(),
5467 "From<&CaixaDialeto> for Cow<'static, str> must \
5468 byte-equal CaixaDialeto::to_string on \
5469 CaixaDialeto::{variant:?} — divergence signals the \
5470 borrowed-input Cow<'static, str> forward-projection \
5471 axis and the ToString-through-Display axis have \
5472 drifted onto different emit-sets"
5473 );
5474 }
5475 let via_iter: Vec<std::borrow::Cow<'static, str>> = CaixaDialeto::ALL
5476 .iter()
5477 .map(std::borrow::Cow::from)
5478 .collect();
5479 let via_method: Vec<std::borrow::Cow<'static, str>> = CaixaDialeto::ALL
5480 .iter()
5481 .map(|d| std::borrow::Cow::Borrowed(d.as_str()))
5482 .collect();
5483 assert_eq!(
5484 via_iter, via_method,
5485 "`.iter().map(Cow::from)` over CaixaDialeto::ALL must \
5486 byte-equal `.iter().map(|d| Cow::Borrowed(d.as_str()))` \
5487 on every arm — the trait-idiomatic `From<&CaixaDialeto> \
5488 for Cow<'static, str>` axis is what makes the \
5489 `Cow::from` composition on the borrowed-iteration axis \
5490 route through the substrate-primitive \
5491 CaixaDialeto::as_str accessor without a spurious Copy \
5492 deref"
5493 );
5494 for cow in &via_iter {
5495 assert!(
5496 matches!(cow, std::borrow::Cow::Borrowed(_)),
5497 "`.iter().map(Cow::from)` over CaixaDialeto::ALL \
5498 must land on the zero-alloc Cow::Borrowed arm on \
5499 every element — a Cow::Owned outcome signals the \
5500 borrowed-iteration pipe has silently allocated \
5501 where the substrate-primitive CaixaDialeto::as_str \
5502 `&'static str` return makes the borrowed arm the \
5503 type-correct projection"
5504 );
5505 }
5506 for &variant in CaixaDialeto::ALL {
5507 let via_cow: std::borrow::Cow<'static, str> =
5508 <std::borrow::Cow<'static, str> as From<&CaixaDialeto>>::from(&variant);
5509 let re_parsed: Result<CaixaDialeto, ()> =
5510 <CaixaDialeto as TryFrom<&str>>::try_from(via_cow.as_ref());
5511 assert_eq!(
5512 re_parsed,
5513 Ok(variant),
5514 "trait-idiomatic borrowed-input Cow<'static, str> \
5515 forward-projection + reverse-projection axis pair \
5516 must round-trip &CaixaDialeto::{variant:?} through \
5517 `.into::<Cow<'static, str>>()` on the borrowed-input \
5518 surface and back through `TryFrom<&str>` on the \
5519 projection's Cow::as_ref borrow — a break signals \
5520 the borrowed-input Cow<'static, str> forward-emit \
5521 and reverse-parse axes have drifted onto different \
5522 vocabularies (unlike the peer CaixaKind axis pair, \
5523 CaixaDialeto's forward emit and reverse parse share \
5524 one PascalCase vocabulary by construction, so the \
5525 round-trip composes directly)"
5526 );
5527 }
5528 }
5529
5530 #[test]
5531 fn caixa_dialeto_from_into_box_str_routes_through_as_str_accessor() {
5532 // Fail-before-pass-after byte-parity pin on the newly lifted
5533 // `impl From<CaixaDialeto> for Box<str>` — asserts the owned-
5534 // input standard-library trait impl and the substrate-primitive
5535 // [`super::CaixaDialeto::as_str`] `pub const fn` accessor
5536 // resolve to the same four-arm PascalCase emit-set across every
5537 // arm the exhaustive [`super::CaixaDialeto::ALL`] slice
5538 // enumerates. Extends the caixa-core-internal tier of the
5539 // substrate-wide [`Box<str>`] forward-projection campaign onto
5540 // the third caixa-core-internal peer, after the render-side
5541 // path-shape-diagnostic
5542 // [`super::super::render::PathShapeViolation`] pair (0d87a72,
5543 // both corners in one axis) opened the tier and the outside-M3
5544 // caixa-core two-list dep-graph [`super::super::dep::DepList`]
5545 // pair (4aada99, both corners in one axis) extended it. Rust's
5546 // standard library carries `impl From<&str> for Box<str>` and
5547 // `impl From<String> for Box<str>` but no blanket
5548 // `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a
5549 // distinct trait-idiomatic surface that a
5550 // `let key: Box<str> = dialeto.into();`-shaped call site reaches
5551 // through this impl and no other — a paired
5552 // `Box::from(dialeto.as_str())` open-code has no compile-time
5553 // link back to the substrate primitive.
5554 for &variant in CaixaDialeto::ALL {
5555 let via_trait: Box<str> = <Box<str> as From<CaixaDialeto>>::from(variant);
5556 let via_method: &'static str = variant.as_str();
5557 assert_eq!(
5558 via_trait.as_ref(),
5559 via_method,
5560 "From<CaixaDialeto> for Box<str> impl must round-trip \
5561 CaixaDialeto::{variant:?} to the same PascalCase \
5562 byte-string CaixaDialeto::as_str returns — divergence \
5563 signals a silent detour off the substrate-primitive \
5564 accessor"
5565 );
5566 let via_into: Box<str> = variant.into();
5567 assert_eq!(
5568 via_into.as_ref(),
5569 via_method,
5570 "Into<Box<str>>::into on CaixaDialeto::{variant:?} must \
5571 byte-equal CaixaDialeto::as_str on the same input — \
5572 the blanket-derived Into shape must resolve to the \
5573 same as_str dispatch as the explicit From impl"
5574 );
5575 }
5576 }
5577
5578 #[test]
5579 fn caixa_dialeto_from_borrowed_into_box_str_routes_through_as_str_accessor() {
5580 // Fail-before-pass-after byte-parity pin on the newly lifted
5581 // `impl From<&CaixaDialeto> for Box<str>` — asserts the
5582 // borrowed-input standard-library trait impl and the substrate-
5583 // primitive [`super::CaixaDialeto::as_str`] `pub const fn`
5584 // accessor resolve to the same four-arm PascalCase emit-set
5585 // across every arm the exhaustive [`super::CaixaDialeto::ALL`]
5586 // slice enumerates. Rust's standard library carries
5587 // `impl From<&str> for Box<str>` and `impl From<String> for
5588 // Box<str>` but no blanket
5589 // `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-
5590 // based `impl<T: Copy, U: From<T>> From<&T> for U`), so the
5591 // borrowed-input [`Box<str>`] forward-projection axis is a
5592 // distinct trait-idiomatic surface that a
5593 // `CaixaDialeto::ALL.iter().map(Box::<str>::from)`-shaped pipe
5594 // (whose iterator over `&'static [CaixaDialeto]` yields
5595 // `&CaixaDialeto` by construction) or a
5596 // `let key: Box<str> = (&dialeto).into();`-shaped call site
5597 // reaches through this impl and no other — the paired owned-
5598 // input `From<CaixaDialeto> for Box<str>` impl alone would
5599 // force every borrowed-input call site through an explicit
5600 // `Copy` deref (`Box::<str>::from(*dialeto)`) or a
5601 // `Box::<str>::from(dialeto.as_str())` open-code whose type
5602 // bounds have no compile-time link back to the substrate
5603 // primitive.
5604 //
5605 // Closes the `{Self, &Self}` input-shape corner on the third
5606 // caixa-core-internal closed-set fieldless typed enum peer of
5607 // the substrate-wide [`Box<str>`] forward-projection campaign,
5608 // matching the trajectory the paired render-side path-shape-
5609 // diagnostic [`super::super::render::PathShapeViolation`] pair
5610 // (0d87a72, both corners in one axis) and the paired outside-M3
5611 // caixa-core two-list dep-graph [`super::super::dep::DepList`]
5612 // pair (4aada99, both corners in one axis) walked before it.
5613 for &variant in CaixaDialeto::ALL {
5614 let via_trait: Box<str> = <Box<str> as From<&CaixaDialeto>>::from(&variant);
5615 let via_method: &'static str = variant.as_str();
5616 assert_eq!(
5617 via_trait.as_ref(),
5618 via_method,
5619 "From<&CaixaDialeto> for Box<str> impl must round-trip \
5620 &CaixaDialeto::{variant:?} to the same PascalCase \
5621 byte-string CaixaDialeto::as_str returns — divergence \
5622 signals a silent detour off the substrate-primitive \
5623 accessor"
5624 );
5625 let via_into: Box<str> = (&variant).into();
5626 assert_eq!(
5627 via_into.as_ref(),
5628 via_method,
5629 "Into<Box<str>>::into on &CaixaDialeto::{variant:?} \
5630 must byte-equal CaixaDialeto::as_str on the same \
5631 input — the blanket-derived Into shape on the \
5632 borrowed-input surface must resolve to the same \
5633 as_str dispatch as the explicit From impl"
5634 );
5635 }
5636
5637 // Pipe witness — the distinguishing shape that forces the
5638 // borrowed-input axis to be independent of the owned-input
5639 // peer. `CaixaDialeto::ALL.iter()` yields `&CaixaDialeto` by
5640 // construction, so `.map(Box::<str>::from)` resolves through
5641 // the borrowed-input `From<&CaixaDialeto> for Box<str>` impl
5642 // and no other — without this axis, the same pipe would force
5643 // an explicit `.copied()` restatement whose type bounds bypass
5644 // the substrate primitive.
5645 let via_pipe: Vec<Box<str>> = CaixaDialeto::ALL.iter().map(Box::<str>::from).collect();
5646 let via_accessor: Vec<&'static str> =
5647 CaixaDialeto::ALL.iter().map(|d| d.as_str()).collect();
5648 assert_eq!(
5649 via_pipe.len(),
5650 via_accessor.len(),
5651 "CaixaDialeto::ALL.iter().map(Box::<str>::from) pipe must \
5652 preserve arity against the paired CaixaDialeto::as_str \
5653 accessor — a length divergence signals the borrowed-input \
5654 axis has silently rejected an arm"
5655 );
5656 for (pipe_arm, accessor_arm) in via_pipe.iter().zip(via_accessor.iter()) {
5657 assert_eq!(
5658 pipe_arm.as_ref(),
5659 *accessor_arm,
5660 "CaixaDialeto::ALL.iter().map(Box::<str>::from) pipe \
5661 must byte-equal the paired \
5662 CaixaDialeto::ALL.iter().map(|d| d.as_str()) pipe on \
5663 every arm — divergence signals the borrowed-input \
5664 `From<&CaixaDialeto> for Box<str>` axis has silently \
5665 detoured off the substrate-primitive accessor"
5666 );
5667 }
5668 }
5669
5670 #[test]
5671 fn caixa_dialeto_from_into_arc_str_routes_through_as_str_accessor() {
5672 // Fail-before-pass-after byte-parity pin on the newly lifted
5673 // `impl From<CaixaDialeto> for std::sync::Arc<str>` — asserts the
5674 // owned-input standard-library trait impl and the substrate-
5675 // primitive [`super::CaixaDialeto::as_str`] `pub const fn` accessor
5676 // resolve to the same four-arm PascalCase emit-set across every
5677 // arm the exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
5678 // Extends the caixa-core-internal tier of the substrate-wide
5679 // [`std::sync::Arc<str>`] forward-projection campaign onto the
5680 // third caixa-core-internal peer, after the structurally most
5681 // fundamental [`super::super::CaixaKind`] pair (c17be64, both
5682 // corners in one axis) opened the tier and the outside-M3 two-list
5683 // dep-graph [`super::super::dep::DepList`] pair (d8a4652, both
5684 // corners in one axis) extended it. Rust's standard library
5685 // carries `impl From<&str> for std::sync::Arc<str>` and
5686 // `impl From<String> for std::sync::Arc<str>` but no blanket
5687 // `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
5688 // `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so
5689 // this axis is a distinct trait-idiomatic surface that a
5690 // `let key: std::sync::Arc<str> = dialeto.into();`-shaped call
5691 // site reaches through this impl and no other — a paired
5692 // `std::sync::Arc::<str>::from(dialeto.as_str())` open-code has no
5693 // compile-time link back to the substrate primitive, and a two-
5694 // step `std::sync::Arc::<str>::from(String::from(dialeto))`
5695 // composition through the owned-`String` axis allocates twice
5696 // where the single-step trait impl allocates once.
5697 //
5698 // Cross-axis byte-parity witness against the sibling owned-input
5699 // `{&'static str, String, Cow<'static, str>, Box<str>}` return-
5700 // shape axes — locking the five return-shape paths on the owned-
5701 // input surface together by construction so any future detour off
5702 // the substrate-primitive [`super::CaixaDialeto::as_str`] accessor
5703 // trips at caixa-core test time.
5704 for &variant in CaixaDialeto::ALL {
5705 let via_trait: std::sync::Arc<str> =
5706 <std::sync::Arc<str> as From<CaixaDialeto>>::from(variant);
5707 let via_method: &'static str = variant.as_str();
5708 assert_eq!(
5709 via_trait.as_ref(),
5710 via_method,
5711 "From<CaixaDialeto> for std::sync::Arc<str> impl must \
5712 round-trip CaixaDialeto::{variant:?} to the same \
5713 PascalCase byte-string CaixaDialeto::as_str returns — \
5714 divergence signals a silent detour off the substrate-\
5715 primitive accessor"
5716 );
5717 let via_into: std::sync::Arc<str> = variant.into();
5718 assert_eq!(
5719 via_into.as_ref(),
5720 via_method,
5721 "Into<std::sync::Arc<str>>::into on CaixaDialeto::\
5722 {variant:?} must byte-equal CaixaDialeto::as_str on the \
5723 same input — the blanket-derived Into shape must resolve \
5724 to the same as_str dispatch as the explicit From impl"
5725 );
5726 let owned_static: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
5727 assert_eq!(
5728 via_trait.as_ref(),
5729 owned_static,
5730 "From<CaixaDialeto> for std::sync::Arc<str> and \
5731 From<CaixaDialeto> for &'static str must resolve \
5732 identically on CaixaDialeto::{variant:?} — divergence \
5733 signals the owned-input std::sync::Arc<str> and \
5734 &'static str return-shape paths have drifted onto \
5735 different emit-sets"
5736 );
5737 let owned_string: String = <String as From<CaixaDialeto>>::from(variant);
5738 assert_eq!(
5739 via_trait.as_ref(),
5740 owned_string.as_str(),
5741 "From<CaixaDialeto> for std::sync::Arc<str> and \
5742 From<CaixaDialeto> for String must resolve identically \
5743 on CaixaDialeto::{variant:?} — divergence signals the \
5744 owned-input std::sync::Arc<str> and owned-`String` \
5745 return-shape paths have drifted onto different emit-sets"
5746 );
5747 let owned_cow: std::borrow::Cow<'static, str> =
5748 <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
5749 assert_eq!(
5750 via_trait.as_ref(),
5751 owned_cow.as_ref(),
5752 "From<CaixaDialeto> for std::sync::Arc<str> and \
5753 From<CaixaDialeto> for Cow<'static, str> must resolve \
5754 identically on CaixaDialeto::{variant:?} — divergence \
5755 signals the owned-input std::sync::Arc<str> and \
5756 Cow<'static, str> return-shape paths have drifted onto \
5757 different emit-sets"
5758 );
5759 let owned_box: Box<str> = <Box<str> as From<CaixaDialeto>>::from(variant);
5760 assert_eq!(
5761 via_trait.as_ref(),
5762 owned_box.as_ref(),
5763 "From<CaixaDialeto> for std::sync::Arc<str> and \
5764 From<CaixaDialeto> for Box<str> must resolve identically \
5765 on CaixaDialeto::{variant:?} — divergence signals the \
5766 owned-input std::sync::Arc<str> and Box<str> return-\
5767 shape paths have drifted onto different emit-sets"
5768 );
5769 }
5770 }
5771
5772 #[test]
5773 #[allow(
5774 clippy::too_many_lines,
5775 reason = "cross-axis partition pin folds four borrowed-input \
5776 return-shape paths (&'static str, String, Cow<'static, \
5777 str>, Box<str>) plus the paired owned-input Arc<str> \
5778 witness and the .iter().map(std::sync::Arc::<str>::from) \
5779 pipe witness into one exhaustive round-trip over \
5780 CaixaDialeto::ALL — the accepted line-count cost of \
5781 keying the whole borrowed-input Arc<str> corner to the \
5782 substrate-primitive as_str accessor at the same test-site"
5783 )]
5784 fn caixa_dialeto_from_borrowed_into_arc_str_routes_through_as_str_accessor() {
5785 // Fail-before-pass-after byte-parity pin on the newly lifted
5786 // `impl From<&CaixaDialeto> for std::sync::Arc<str>` — asserts the
5787 // borrowed-input standard-library trait impl and the substrate-
5788 // primitive [`super::CaixaDialeto::as_str`] `pub const fn` accessor
5789 // resolve to the same four-arm PascalCase emit-set across every
5790 // arm the exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
5791 // Rust's standard library does not carry a blanket
5792 // `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a
5793 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
5794 // the borrowed-input `std::sync::Arc<str>` forward-projection axis
5795 // is a distinct trait-idiomatic surface that a
5796 // `let key: std::sync::Arc<str> = (&dialeto).into();`-shaped call
5797 // site or a
5798 // `CaixaDialeto::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped
5799 // pipe reaches through this impl and no other — the paired owned-
5800 // input `From<CaixaDialeto> for std::sync::Arc<str>` impl alone
5801 // forces every borrowed-input call site through a spurious `Copy`
5802 // deref (`std::sync::Arc::<str>::from((*dialeto).as_str())`) or a
5803 // `.copied()` restatement whose type bounds have no compile-time
5804 // link back to the substrate primitive.
5805 //
5806 // Closes the `{Self, &Self}` input-shape corner on the caixa-
5807 // core-internal tier of the substrate-wide trait-idiomatic
5808 // [`std::sync::Arc<str>`] forward-projection campaign for the
5809 // third caixa-core-internal enum peer, matching the
5810 // `{Self, &Self} × {&'static str, String, Cow<'static, str>,
5811 // Box<str>}` 2×4 forward-projection matrix the peer projection
5812 // surfaces already close on this same enum.
5813 //
5814 // Cross-axis partition pin against the paired owned-input
5815 // [`From<CaixaDialeto> for std::sync::Arc<str>`] and the sibling
5816 // borrowed-input `{&'static str, String, Cow<'static, str>,
5817 // Box<str>}` return-shape axes — locking the five return-shape ×
5818 // input-shape paths on the borrowed-input surface together by
5819 // construction so any future detour off the substrate-primitive
5820 // accessor trips at caixa-core test time. Then a
5821 // `.iter().map(std::sync::Arc::<str>::from)` pipe witness over
5822 // [`super::CaixaDialeto::ALL`] — whose iterator yields
5823 // `&CaixaDialeto` by construction, so the borrowed-input
5824 // [`std::sync::Arc<str>`] axis is what routes the pipe through the
5825 // substrate-primitive [`super::CaixaDialeto::as_str`] accessor
5826 // without a spurious [`Copy`] deref (which would only be reachable
5827 // through the owned-input
5828 // [`From<CaixaDialeto> for std::sync::Arc<str>`] axis by first
5829 // calling `.copied()` on the iterator).
5830 for &variant in CaixaDialeto::ALL {
5831 let via_trait: std::sync::Arc<str> =
5832 <std::sync::Arc<str> as From<&CaixaDialeto>>::from(&variant);
5833 let via_method: &'static str = variant.as_str();
5834 assert_eq!(
5835 via_trait.as_ref(),
5836 via_method,
5837 "From<&CaixaDialeto> for std::sync::Arc<str> impl must \
5838 round-trip &CaixaDialeto::{variant:?} to the same \
5839 PascalCase byte-string CaixaDialeto::as_str returns — \
5840 divergence signals a silent detour off the substrate-\
5841 primitive accessor"
5842 );
5843 let via_into: std::sync::Arc<str> = (&variant).into();
5844 assert_eq!(
5845 via_into.as_ref(),
5846 via_method,
5847 "Into<std::sync::Arc<str>>::into on &CaixaDialeto::\
5848 {variant:?} must byte-equal CaixaDialeto::as_str on the \
5849 same input — the blanket-derived Into shape on the \
5850 borrowed-input surface must resolve to the same as_str \
5851 dispatch as the explicit From impl"
5852 );
5853 let owned_arc: std::sync::Arc<str> =
5854 <std::sync::Arc<str> as From<CaixaDialeto>>::from(variant);
5855 assert_eq!(
5856 via_trait, owned_arc,
5857 "From<&CaixaDialeto> for std::sync::Arc<str> and \
5858 From<CaixaDialeto> for std::sync::Arc<str> must resolve \
5859 identically on CaixaDialeto::{variant:?} — divergence \
5860 signals the borrowed-input and owned-input \
5861 std::sync::Arc<str> forward-projection input-shape paths \
5862 have drifted onto different emit-sets"
5863 );
5864 let borrowed_static: &'static str =
5865 <&'static str as From<&CaixaDialeto>>::from(&variant);
5866 assert_eq!(
5867 via_trait.as_ref(),
5868 borrowed_static,
5869 "From<&CaixaDialeto> for std::sync::Arc<str> and \
5870 From<&CaixaDialeto> for &'static str must resolve \
5871 identically on CaixaDialeto::{variant:?} — divergence \
5872 signals the borrowed-input std::sync::Arc<str> and \
5873 &'static str return-shape paths have drifted onto \
5874 different emit-sets"
5875 );
5876 let borrowed_string: String = <String as From<&CaixaDialeto>>::from(&variant);
5877 assert_eq!(
5878 via_trait.as_ref(),
5879 borrowed_string.as_str(),
5880 "From<&CaixaDialeto> for std::sync::Arc<str> and \
5881 From<&CaixaDialeto> for String must resolve identically \
5882 on CaixaDialeto::{variant:?} — divergence signals the \
5883 borrowed-input std::sync::Arc<str> and owned-`String` \
5884 return-shape paths have drifted onto different emit-sets"
5885 );
5886 let borrowed_cow: std::borrow::Cow<'static, str> =
5887 <std::borrow::Cow<'static, str> as From<&CaixaDialeto>>::from(&variant);
5888 assert_eq!(
5889 via_trait.as_ref(),
5890 borrowed_cow.as_ref(),
5891 "From<&CaixaDialeto> for std::sync::Arc<str> and \
5892 From<&CaixaDialeto> for Cow<'static, str> must resolve \
5893 identically on CaixaDialeto::{variant:?} — divergence \
5894 signals the borrowed-input std::sync::Arc<str> and \
5895 Cow<'static, str> return-shape paths have drifted onto \
5896 different emit-sets"
5897 );
5898 let borrowed_box: Box<str> = <Box<str> as From<&CaixaDialeto>>::from(&variant);
5899 assert_eq!(
5900 via_trait.as_ref(),
5901 borrowed_box.as_ref(),
5902 "From<&CaixaDialeto> for std::sync::Arc<str> and \
5903 From<&CaixaDialeto> for Box<str> must resolve \
5904 identically on CaixaDialeto::{variant:?} — divergence \
5905 signals the borrowed-input std::sync::Arc<str> and \
5906 Box<str> return-shape paths have drifted onto different \
5907 emit-sets"
5908 );
5909 }
5910 let via_iter: Vec<std::sync::Arc<str>> = CaixaDialeto::ALL
5911 .iter()
5912 .map(std::sync::Arc::<str>::from)
5913 .collect();
5914 let via_method: Vec<std::sync::Arc<str>> = CaixaDialeto::ALL
5915 .iter()
5916 .map(|d| std::sync::Arc::<str>::from(d.as_str()))
5917 .collect();
5918 assert_eq!(
5919 via_iter, via_method,
5920 "`.iter().map(std::sync::Arc::<str>::from)` over \
5921 CaixaDialeto::ALL — a call site whose iteration axis holds \
5922 `&CaixaDialeto` by construction — must byte-equal \
5923 `.iter().map(|d| std::sync::Arc::<str>::from(d.as_str()))` \
5924 on every arm — the borrowed-input std::sync::Arc<str> \
5925 `From<&CaixaDialeto> for std::sync::Arc<str>` axis is what \
5926 makes the `std::sync::Arc::<str>::from` composition route \
5927 through the substrate-primitive `CaixaDialeto::as_str` \
5928 accessor without a spurious `Copy` deref (which would only \
5929 be reachable through the owned-input \
5930 `From<CaixaDialeto> for std::sync::Arc<str>` axis by first \
5931 calling `.copied()` on the iterator)"
5932 );
5933 }
5934
5935 #[test]
5936 fn caixa_dialeto_from_into_rc_str_routes_through_as_str_accessor() {
5937 // Fail-before-pass-after byte-parity pin on the newly lifted
5938 // `impl From<CaixaDialeto> for std::rc::Rc<str>` — asserts the
5939 // owned-input standard-library trait impl and the substrate-
5940 // primitive [`super::CaixaDialeto::as_str`] `pub const fn` accessor
5941 // resolve to the same four-arm PascalCase emit-set across every
5942 // arm the exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
5943 // Extends the caixa-core-internal tier of the substrate-wide
5944 // [`std::rc::Rc<str>`] forward-projection campaign onto the second
5945 // caixa-core-internal peer, after the structurally most
5946 // fundamental [`super::super::CaixaKind`] pair (4fdfa37, both
5947 // corners in one axis) opened the campaign. Rust's standard
5948 // library carries `impl From<&str> for std::rc::Rc<str>` and
5949 // `impl From<String> for std::rc::Rc<str>` but no blanket
5950 // `impl<T: AsRef<str>> From<T> for std::rc::Rc<str>` (nor an
5951 // `impl<T: fmt::Display> From<T> for std::rc::Rc<str>`), and — the
5952 // `std::sync::Arc<str>` and `std::rc::Rc<str>` trait tables are
5953 // disjoint — so this axis is a distinct trait-idiomatic surface
5954 // that a `let key: std::rc::Rc<str> = dialeto.into();`-shaped
5955 // call site reaches through this impl and no other.
5956 //
5957 // Cross-axis byte-parity witness against the sibling owned-input
5958 // `{&'static str, String, Cow<'static, str>, Box<str>,
5959 // std::sync::Arc<str>}` return-shape axes — locking the six
5960 // return-shape paths on the owned-input surface together by
5961 // construction so any future detour off the substrate-primitive
5962 // [`super::CaixaDialeto::as_str`] accessor trips at caixa-core
5963 // test time.
5964 for &variant in CaixaDialeto::ALL {
5965 let via_trait: std::rc::Rc<str> =
5966 <std::rc::Rc<str> as From<CaixaDialeto>>::from(variant);
5967 let via_method: &'static str = variant.as_str();
5968 assert_eq!(
5969 via_trait.as_ref(),
5970 via_method,
5971 "From<CaixaDialeto> for std::rc::Rc<str> impl must \
5972 round-trip CaixaDialeto::{variant:?} to the same \
5973 PascalCase byte-string CaixaDialeto::as_str returns — \
5974 divergence signals a silent detour off the substrate-\
5975 primitive accessor"
5976 );
5977 let via_into: std::rc::Rc<str> = variant.into();
5978 assert_eq!(
5979 via_into.as_ref(),
5980 via_method,
5981 "Into<std::rc::Rc<str>>::into on CaixaDialeto::\
5982 {variant:?} must byte-equal CaixaDialeto::as_str on the \
5983 same input — the blanket-derived Into shape must resolve \
5984 to the same as_str dispatch as the explicit From impl"
5985 );
5986 let owned_static: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
5987 assert_eq!(
5988 via_trait.as_ref(),
5989 owned_static,
5990 "From<CaixaDialeto> for std::rc::Rc<str> and \
5991 From<CaixaDialeto> for &'static str must resolve \
5992 identically on CaixaDialeto::{variant:?} — divergence \
5993 signals the owned-input std::rc::Rc<str> and \
5994 &'static str return-shape paths have drifted onto \
5995 different emit-sets"
5996 );
5997 let owned_string: String = <String as From<CaixaDialeto>>::from(variant);
5998 assert_eq!(
5999 via_trait.as_ref(),
6000 owned_string.as_str(),
6001 "From<CaixaDialeto> for std::rc::Rc<str> and \
6002 From<CaixaDialeto> for String must resolve identically \
6003 on CaixaDialeto::{variant:?} — divergence signals the \
6004 owned-input std::rc::Rc<str> and owned-`String` \
6005 return-shape paths have drifted onto different emit-sets"
6006 );
6007 let owned_cow: std::borrow::Cow<'static, str> =
6008 <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
6009 assert_eq!(
6010 via_trait.as_ref(),
6011 owned_cow.as_ref(),
6012 "From<CaixaDialeto> for std::rc::Rc<str> and \
6013 From<CaixaDialeto> for Cow<'static, str> must resolve \
6014 identically on CaixaDialeto::{variant:?} — divergence \
6015 signals the owned-input std::rc::Rc<str> and \
6016 Cow<'static, str> return-shape paths have drifted onto \
6017 different emit-sets"
6018 );
6019 let owned_box: Box<str> = <Box<str> as From<CaixaDialeto>>::from(variant);
6020 assert_eq!(
6021 via_trait.as_ref(),
6022 owned_box.as_ref(),
6023 "From<CaixaDialeto> for std::rc::Rc<str> and \
6024 From<CaixaDialeto> for Box<str> must resolve identically \
6025 on CaixaDialeto::{variant:?} — divergence signals the \
6026 owned-input std::rc::Rc<str> and Box<str> return-\
6027 shape paths have drifted onto different emit-sets"
6028 );
6029 let owned_arc: std::sync::Arc<str> =
6030 <std::sync::Arc<str> as From<CaixaDialeto>>::from(variant);
6031 assert_eq!(
6032 via_trait.as_ref(),
6033 owned_arc.as_ref(),
6034 "From<CaixaDialeto> for std::rc::Rc<str> and \
6035 From<CaixaDialeto> for std::sync::Arc<str> must resolve \
6036 identically on CaixaDialeto::{variant:?} — divergence \
6037 signals the owned-input std::rc::Rc<str> and \
6038 std::sync::Arc<str> return-shape paths have drifted \
6039 onto different emit-sets"
6040 );
6041 }
6042 }
6043
6044 #[test]
6045 #[allow(
6046 clippy::too_many_lines,
6047 reason = "cross-axis partition pin folds five borrowed-input \
6048 return-shape paths (&'static str, String, Cow<'static, \
6049 str>, Box<str>, std::sync::Arc<str>) plus the paired \
6050 owned-input Rc<str> witness and the \
6051 .iter().map(std::rc::Rc::<str>::from) pipe witness into \
6052 one exhaustive round-trip over CaixaDialeto::ALL — the \
6053 accepted line-count cost of keying the whole borrowed-\
6054 input Rc<str> corner to the substrate-primitive as_str \
6055 accessor at the same test-site"
6056 )]
6057 fn caixa_dialeto_from_borrowed_into_rc_str_routes_through_as_str_accessor() {
6058 // Fail-before-pass-after byte-parity pin on the newly lifted
6059 // `impl From<&CaixaDialeto> for std::rc::Rc<str>` — asserts the
6060 // borrowed-input standard-library trait impl and the substrate-
6061 // primitive [`super::CaixaDialeto::as_str`] `pub const fn` accessor
6062 // resolve to the same four-arm PascalCase emit-set across every
6063 // arm the exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
6064 // Rust's standard library does not carry a blanket
6065 // `impl<T: AsRef<str>> From<&T> for std::rc::Rc<str>` (nor a
6066 // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
6067 // the borrowed-input `std::rc::Rc<str>` forward-projection axis is
6068 // a distinct trait-idiomatic surface that a
6069 // `let key: std::rc::Rc<str> = (&dialeto).into();`-shaped call
6070 // site or a
6071 // `CaixaDialeto::ALL.iter().map(std::rc::Rc::<str>::from)`-shaped
6072 // pipe reaches through this impl and no other.
6073 //
6074 // Cross-axis partition pin against the paired owned-input
6075 // [`From<CaixaDialeto> for std::rc::Rc<str>`] and the sibling
6076 // borrowed-input `{&'static str, String, Cow<'static, str>,
6077 // Box<str>, std::sync::Arc<str>}` return-shape axes — locking the
6078 // six return-shape × input-shape paths on the borrowed-input
6079 // surface together by construction so any future detour off the
6080 // substrate-primitive accessor trips at caixa-core test time.
6081 // Then a `.iter().map(std::rc::Rc::<str>::from)` pipe witness
6082 // over [`super::CaixaDialeto::ALL`] — whose iterator yields
6083 // `&CaixaDialeto` by construction, so the borrowed-input
6084 // [`std::rc::Rc<str>`] axis is what routes the pipe through the
6085 // substrate-primitive [`super::CaixaDialeto::as_str`] accessor
6086 // without a spurious [`Copy`] deref.
6087 for &variant in CaixaDialeto::ALL {
6088 let via_trait: std::rc::Rc<str> =
6089 <std::rc::Rc<str> as From<&CaixaDialeto>>::from(&variant);
6090 let via_method: &'static str = variant.as_str();
6091 assert_eq!(
6092 via_trait.as_ref(),
6093 via_method,
6094 "From<&CaixaDialeto> for std::rc::Rc<str> impl must \
6095 round-trip &CaixaDialeto::{variant:?} to the same \
6096 PascalCase byte-string CaixaDialeto::as_str returns — \
6097 divergence signals a silent detour off the substrate-\
6098 primitive accessor"
6099 );
6100 let via_into: std::rc::Rc<str> = (&variant).into();
6101 assert_eq!(
6102 via_into.as_ref(),
6103 via_method,
6104 "Into<std::rc::Rc<str>>::into on &CaixaDialeto::\
6105 {variant:?} must byte-equal CaixaDialeto::as_str on the \
6106 same input — the blanket-derived Into shape on the \
6107 borrowed-input surface must resolve to the same as_str \
6108 dispatch as the explicit From impl"
6109 );
6110 let owned_rc: std::rc::Rc<str> =
6111 <std::rc::Rc<str> as From<CaixaDialeto>>::from(variant);
6112 assert_eq!(
6113 via_trait, owned_rc,
6114 "From<&CaixaDialeto> for std::rc::Rc<str> and \
6115 From<CaixaDialeto> for std::rc::Rc<str> must resolve \
6116 identically on CaixaDialeto::{variant:?} — divergence \
6117 signals the borrowed-input and owned-input \
6118 std::rc::Rc<str> forward-projection input-shape paths \
6119 have drifted onto different emit-sets"
6120 );
6121 let borrowed_static: &'static str =
6122 <&'static str as From<&CaixaDialeto>>::from(&variant);
6123 assert_eq!(
6124 via_trait.as_ref(),
6125 borrowed_static,
6126 "From<&CaixaDialeto> for std::rc::Rc<str> and \
6127 From<&CaixaDialeto> for &'static str must resolve \
6128 identically on CaixaDialeto::{variant:?} — divergence \
6129 signals the borrowed-input std::rc::Rc<str> and \
6130 &'static str return-shape paths have drifted onto \
6131 different emit-sets"
6132 );
6133 let borrowed_string: String = <String as From<&CaixaDialeto>>::from(&variant);
6134 assert_eq!(
6135 via_trait.as_ref(),
6136 borrowed_string.as_str(),
6137 "From<&CaixaDialeto> for std::rc::Rc<str> and \
6138 From<&CaixaDialeto> for String must resolve identically \
6139 on CaixaDialeto::{variant:?} — divergence signals the \
6140 borrowed-input std::rc::Rc<str> and owned-`String` \
6141 return-shape paths have drifted onto different emit-sets"
6142 );
6143 let borrowed_cow: std::borrow::Cow<'static, str> =
6144 <std::borrow::Cow<'static, str> as From<&CaixaDialeto>>::from(&variant);
6145 assert_eq!(
6146 via_trait.as_ref(),
6147 borrowed_cow.as_ref(),
6148 "From<&CaixaDialeto> for std::rc::Rc<str> and \
6149 From<&CaixaDialeto> for Cow<'static, str> must resolve \
6150 identically on CaixaDialeto::{variant:?} — divergence \
6151 signals the borrowed-input std::rc::Rc<str> and \
6152 Cow<'static, str> return-shape paths have drifted onto \
6153 different emit-sets"
6154 );
6155 let borrowed_box: Box<str> = <Box<str> as From<&CaixaDialeto>>::from(&variant);
6156 assert_eq!(
6157 via_trait.as_ref(),
6158 borrowed_box.as_ref(),
6159 "From<&CaixaDialeto> for std::rc::Rc<str> and \
6160 From<&CaixaDialeto> for Box<str> must resolve \
6161 identically on CaixaDialeto::{variant:?} — divergence \
6162 signals the borrowed-input std::rc::Rc<str> and \
6163 Box<str> return-shape paths have drifted onto different \
6164 emit-sets"
6165 );
6166 let borrowed_arc: std::sync::Arc<str> =
6167 <std::sync::Arc<str> as From<&CaixaDialeto>>::from(&variant);
6168 assert_eq!(
6169 via_trait.as_ref(),
6170 borrowed_arc.as_ref(),
6171 "From<&CaixaDialeto> for std::rc::Rc<str> and \
6172 From<&CaixaDialeto> for std::sync::Arc<str> must \
6173 resolve identically on CaixaDialeto::{variant:?} — \
6174 divergence signals the borrowed-input std::rc::Rc<str> \
6175 and std::sync::Arc<str> return-shape paths have drifted \
6176 onto different emit-sets"
6177 );
6178 }
6179 let via_iter: Vec<std::rc::Rc<str>> = CaixaDialeto::ALL
6180 .iter()
6181 .map(std::rc::Rc::<str>::from)
6182 .collect();
6183 let via_method: Vec<std::rc::Rc<str>> = CaixaDialeto::ALL
6184 .iter()
6185 .map(|d| std::rc::Rc::<str>::from(d.as_str()))
6186 .collect();
6187 assert_eq!(
6188 via_iter, via_method,
6189 "`.iter().map(std::rc::Rc::<str>::from)` over \
6190 CaixaDialeto::ALL — a call site whose iteration axis holds \
6191 `&CaixaDialeto` by construction — must byte-equal \
6192 `.iter().map(|d| std::rc::Rc::<str>::from(d.as_str()))` \
6193 on every arm — the borrowed-input std::rc::Rc<str> \
6194 `From<&CaixaDialeto> for std::rc::Rc<str>` axis is what \
6195 makes the `std::rc::Rc::<str>::from` composition route \
6196 through the substrate-primitive `CaixaDialeto::as_str` \
6197 accessor without a spurious `Copy` deref (which would only \
6198 be reachable through the owned-input \
6199 `From<CaixaDialeto> for std::rc::Rc<str>` axis by first \
6200 calling `.copied()` on the iterator)"
6201 );
6202 }
6203
6204 #[test]
6205 #[allow(
6206 clippy::too_many_lines,
6207 reason = "cross-axis partition pin folds the substrate-primitive \
6208 as_str accessor's `.as_bytes()` byte-tail plus the \
6209 paired str-view (AsRef<str>, Display, as_str) and \
6210 reverse-projection ({&'static str, String, \
6211 Cow<'static, str>, Box<str>, std::sync::Arc<str>, \
6212 std::rc::Rc<str>}) return-shape axes' `.as_bytes()` \
6213 byte-tails plus a <T: AsRef<[u8]>>-bound-consumer \
6214 witness plus a blake3::Hasher::update-shape byte-\
6215 input surface witness into one exhaustive round-trip \
6216 over CaixaDialeto::ALL — the accepted line-count cost \
6217 of opening the byte-view axis keyed to the substrate-\
6218 primitive as_str accessor at the same test-site"
6219 )]
6220 #[allow(
6221 clippy::needless_borrows_for_generic_args,
6222 reason = "the borrowed-input surface (&variant) is exercised \
6223 deliberately: the `<T: AsRef<[u8]>>`-bound consumer \
6224 and the `blake3::Hasher::update`-shape byte-input \
6225 surface both accept either owned or borrowed input \
6226 through the standard-library blanket \
6227 `impl<T: ?Sized + AsRef<[u8]>> AsRef<[u8]> for &T`, \
6228 and this pin round-trips both input shapes to lock \
6229 the borrowed-input path load-bearing against a \
6230 future silent regression"
6231 )]
6232 fn caixa_dialeto_as_ref_bytes_routes_through_as_str_accessor() {
6233 // `<T: AsRef<[u8]>>`-bound-consumer witness helper: a generic
6234 // byte-input function accepts a [`super::CaixaDialeto`]
6235 // directly through the trait bound, without the caller open-
6236 // coding the two-hop `dialeto.as_str().as_bytes()`
6237 // composition. Lifted to the top of the function per
6238 // `clippy::items_after_statements`.
6239 fn generic_bytes_sink<T: AsRef<[u8]>>(t: T) -> Vec<u8> {
6240 t.as_ref().to_vec()
6241 }
6242 // `blake3::Hasher::update`-shape byte-input surface mock:
6243 // mirrors `blake3::Hasher::update` / `ring::digest::Context::
6244 // update` / `sha2::Sha256::update`'s `impl AsRef<[u8]>`-bound
6245 // `update` signature so a per-caixa BLAKE3 content-address
6246 // closure that composes `hasher.update(dialeto)` on the
6247 // [`crate::Lacre`] closure builder reaches the substrate-
6248 // primitive `as_str` accessor through the
6249 // [`super::CaixaDialeto`] `AsRef<[u8]>` axis and no other.
6250 // Lifted to the top of the function per
6251 // `clippy::items_after_statements`.
6252 struct MockHasher(Vec<u8>);
6253 impl MockHasher {
6254 fn new() -> Self {
6255 Self(Vec::new())
6256 }
6257 fn update(&mut self, bytes: impl AsRef<[u8]>) -> &mut Self {
6258 self.0.extend_from_slice(bytes.as_ref());
6259 self
6260 }
6261 fn finalize(self) -> Vec<u8> {
6262 self.0
6263 }
6264 }
6265
6266 // Fail-before-pass-after byte-parity pin on the newly lifted
6267 // `impl AsRef<[u8]> for CaixaDialeto` — asserts the trait-
6268 // idiomatic byte-view standard-library impl and the substrate-
6269 // primitive [`super::CaixaDialeto::as_str`] `pub const fn`
6270 // accessor's `.as_bytes()` byte-tail resolve to the same
6271 // four-arm PascalCase-byte-string emit-set across every arm
6272 // the exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
6273 // Extends the substrate-wide trait-idiomatic byte-view axis
6274 // onto the second closed-set fieldless typed enum on the
6275 // caixa-core-internal tier — matching the trajectory the
6276 // sibling [`super::CaixaKind`] first-mover
6277 // [`AsRef<[u8]>`] impl (69d8d86) walked before it.
6278 for &variant in CaixaDialeto::ALL {
6279 let via_trait: &[u8] = <CaixaDialeto as AsRef<[u8]>>::as_ref(&variant);
6280 let via_method_bytes: &[u8] = variant.as_str().as_bytes();
6281 assert_eq!(
6282 via_trait, via_method_bytes,
6283 "AsRef<[u8]> for CaixaDialeto impl must byte-equal \
6284 CaixaDialeto::as_str().as_bytes() on CaixaDialeto::\
6285 {variant:?} — divergence signals a silent detour off \
6286 the substrate-primitive accessor"
6287 );
6288 // Cross-axis witness against the paired str-view axes'
6289 // `.as_bytes()` byte-tails: [`AsRef<str>`] /
6290 // [`std::fmt::Display`] / [`super::CaixaDialeto::as_str`]
6291 // all resolve to the same lifted `CAIXA_DIALETO_WIRE_*`
6292 // const roster, and the byte-view axis must byte-equal
6293 // each of their `.as_bytes()` byte-tails by construction
6294 // — locking the str-view and byte-view axes together at
6295 // the substrate-primitive accessor.
6296 let str_view_ref: &str = <CaixaDialeto as AsRef<str>>::as_ref(&variant);
6297 assert_eq!(
6298 via_trait,
6299 str_view_ref.as_bytes(),
6300 "AsRef<[u8]> for CaixaDialeto and AsRef<str> for \
6301 CaixaDialeto must resolve to byte-equal byte-tails \
6302 on CaixaDialeto::{variant:?} — divergence signals \
6303 the byte-view and str-view axes have drifted off the \
6304 same substrate-primitive as_str accessor"
6305 );
6306 let display_bytes = variant.to_string();
6307 assert_eq!(
6308 via_trait,
6309 display_bytes.as_bytes(),
6310 "AsRef<[u8]> for CaixaDialeto and \
6311 <CaixaDialeto as std::fmt::Display>::to_string must \
6312 resolve to byte-equal byte-tails on CaixaDialeto::\
6313 {variant:?} — divergence signals the byte-view axis \
6314 and the Display formatter axis have drifted off the \
6315 same substrate-primitive as_str accessor"
6316 );
6317 // Cross-axis witness against the paired reverse-
6318 // projection axes' `.as_bytes()` byte-tails: every one of
6319 // `{&'static str, String, Cow<'static, str>, Box<str>,
6320 // std::sync::Arc<str>, std::rc::Rc<str>}` allocates (or
6321 // borrows) the same PascalCase byte-string the substrate-
6322 // primitive accessor emits, so the byte-view axis must
6323 // byte-equal each of their `.as_bytes()` byte-tails by
6324 // construction.
6325 let owned_static: &'static str = <&'static str as From<CaixaDialeto>>::from(variant);
6326 assert_eq!(
6327 via_trait,
6328 owned_static.as_bytes(),
6329 "AsRef<[u8]> for CaixaDialeto and From<CaixaDialeto> \
6330 for &'static str must resolve to byte-equal byte-\
6331 tails on CaixaDialeto::{variant:?}"
6332 );
6333 let owned_string: String = <String as From<CaixaDialeto>>::from(variant);
6334 assert_eq!(
6335 via_trait,
6336 owned_string.as_bytes(),
6337 "AsRef<[u8]> for CaixaDialeto and From<CaixaDialeto> \
6338 for String must resolve to byte-equal byte-tails on \
6339 CaixaDialeto::{variant:?}"
6340 );
6341 let owned_cow: std::borrow::Cow<'static, str> =
6342 <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
6343 assert_eq!(
6344 via_trait,
6345 owned_cow.as_bytes(),
6346 "AsRef<[u8]> for CaixaDialeto and From<CaixaDialeto> \
6347 for Cow<'static, str> must resolve to byte-equal \
6348 byte-tails on CaixaDialeto::{variant:?}"
6349 );
6350 let owned_box: Box<str> = <Box<str> as From<CaixaDialeto>>::from(variant);
6351 assert_eq!(
6352 via_trait,
6353 owned_box.as_bytes(),
6354 "AsRef<[u8]> for CaixaDialeto and From<CaixaDialeto> \
6355 for Box<str> must resolve to byte-equal byte-tails \
6356 on CaixaDialeto::{variant:?}"
6357 );
6358 let owned_arc: std::sync::Arc<str> =
6359 <std::sync::Arc<str> as From<CaixaDialeto>>::from(variant);
6360 assert_eq!(
6361 via_trait,
6362 owned_arc.as_bytes(),
6363 "AsRef<[u8]> for CaixaDialeto and From<CaixaDialeto> \
6364 for std::sync::Arc<str> must resolve to byte-equal \
6365 byte-tails on CaixaDialeto::{variant:?}"
6366 );
6367 let owned_rc_str: std::rc::Rc<str> =
6368 <std::rc::Rc<str> as From<CaixaDialeto>>::from(variant);
6369 assert_eq!(
6370 via_trait,
6371 owned_rc_str.as_bytes(),
6372 "AsRef<[u8]> for CaixaDialeto and From<CaixaDialeto> \
6373 for std::rc::Rc<str> must resolve to byte-equal \
6374 byte-tails on CaixaDialeto::{variant:?}"
6375 );
6376 }
6377 // `<T: AsRef<[u8]>>`-bound-consumer witness: the generic byte-
6378 // input function `generic_bytes_sink` (lifted above per
6379 // `clippy::items_after_statements`) accepts a
6380 // [`super::CaixaDialeto`] directly through the trait bound,
6381 // without the caller open-coding the two-hop
6382 // `dialeto.as_str().as_bytes()` composition. This is the
6383 // shape that reaches the caixa-lacre BLAKE3 content-address
6384 // closure's `blake3::Hasher::update(impl AsRef<[u8]>)` byte-
6385 // input surface through this impl and no other. Exercised on
6386 // both owned and borrowed input surfaces via the standard-
6387 // library blanket `impl<T: ?Sized + AsRef<[u8]>>
6388 // AsRef<[u8]> for &T`.
6389 for &variant in CaixaDialeto::ALL {
6390 let via_generic = generic_bytes_sink(variant);
6391 let via_borrowed_generic = generic_bytes_sink(&variant);
6392 let via_method_bytes = variant.as_str().as_bytes().to_vec();
6393 assert_eq!(
6394 via_generic, via_method_bytes,
6395 "generic `<T: AsRef<[u8]>>`-bound consumer on \
6396 CaixaDialeto::{variant:?} must yield the same byte-\
6397 tail CaixaDialeto::as_str().as_bytes() returns — \
6398 divergence signals the byte-view axis fails to \
6399 bridge a generic byte-input trait bound to the \
6400 substrate-primitive accessor"
6401 );
6402 assert_eq!(
6403 via_borrowed_generic, via_method_bytes,
6404 "generic `<T: AsRef<[u8]>>`-bound consumer on \
6405 &CaixaDialeto::{variant:?} must yield the same byte-\
6406 tail CaixaDialeto::as_str().as_bytes() returns — the \
6407 borrowed-input surface must resolve to the same \
6408 as_str dispatch"
6409 );
6410 }
6411 // `blake3::Hasher::update`-shape byte-input surface witness
6412 // on the caixa-lacre compounding target: the `MockHasher`
6413 // (lifted above per `clippy::items_after_statements`) mirrors
6414 // `blake3::Hasher::update` / `ring::digest::Context::update` /
6415 // `sha2::Sha256::update`'s `impl AsRef<[u8]>`-bound update
6416 // signature and accepts a [`super::CaixaDialeto`] directly,
6417 // routing its byte-tail through the substrate-primitive
6418 // `as_str` accessor — the shape a future per-caixa BLAKE3
6419 // content-address closure composes to fold a `:dialect`
6420 // classification byte-tag into the [`crate::Lacre`] closure
6421 // body.
6422 for &variant in CaixaDialeto::ALL {
6423 let mut owned_hasher = MockHasher::new();
6424 owned_hasher.update(variant);
6425 let owned_folded = owned_hasher.finalize();
6426 assert_eq!(
6427 owned_folded,
6428 variant.as_str().as_bytes(),
6429 "`hasher.update(dialeto)`-shape composition on \
6430 CaixaDialeto::{variant:?} must fold the same byte-\
6431 tail CaixaDialeto::as_str().as_bytes() returns — the \
6432 shape a future per-caixa BLAKE3 content-address \
6433 closure composes to fold a `:dialect` classification \
6434 byte-tag into the Lacre closure body"
6435 );
6436 let mut borrowed_hasher = MockHasher::new();
6437 borrowed_hasher.update(&variant);
6438 let borrowed_folded = borrowed_hasher.finalize();
6439 assert_eq!(
6440 borrowed_folded,
6441 variant.as_str().as_bytes(),
6442 "`hasher.update(&dialeto)`-shape composition on \
6443 &CaixaDialeto::{variant:?} must fold the same byte-\
6444 tail CaixaDialeto::as_str().as_bytes() returns — the \
6445 borrowed-input surface must resolve to the same \
6446 as_str dispatch"
6447 );
6448 }
6449 }
6450
6451 #[test]
6452 #[expect(
6453 clippy::too_many_lines,
6454 reason = "the byte-owned reverse-projection axis is extended \
6455 onto CaixaDialeto here as the second peer on the \
6456 substrate-wide byte-owned Vec<u8>-output projection \
6457 family (after the sibling first-mover CaixaKind, \
6458 b245fd6), so the pin binds the new impl against every \
6459 paired byte-view and str-view axis on the same enum \
6460 plus a generic <T: Into<Vec<u8>>>-bound consumer \
6461 witness and a std::io::Write::write_all-shape owned-\
6462 byte-sink surface witness on both owned and borrowed \
6463 input shapes to lock the whole family against a \
6464 future silent regression"
6465 )]
6466 fn caixa_dialeto_from_into_owned_vec_bytes_routes_through_as_str_accessor() {
6467 // `<T: Into<Vec<u8>>>`-bound-consumer witness helper: a generic
6468 // owned-byte-input function accepts a [`super::CaixaDialeto`]
6469 // directly through the trait bound, without the caller open-
6470 // coding the three-hop `dialeto.as_str().as_bytes().to_vec()`
6471 // composition. Lifted to the top of the function per
6472 // `clippy::items_after_statements`.
6473 fn generic_owned_bytes_sink<T: Into<Vec<u8>>>(t: T) -> Vec<u8> {
6474 t.into()
6475 }
6476 // `std::io::Write::write_all`-shape owned-byte-sink surface
6477 // mock: mirrors `std::io::Write::write_all` /
6478 // `bytes::BytesMut::extend_from_slice` / any per-arm audit-log
6479 // byte-sink that consumes a `Vec<u8>` payload via
6480 // `Into<Vec<u8>>`, so a future per-caixa per-`:dialect` audit-
6481 // log emit reaches the substrate-primitive `as_str` accessor
6482 // through the byte-owned reverse-projection axis and no other.
6483 // Lifted to the top of the function per
6484 // `clippy::items_after_statements`.
6485 struct MockOwnedByteSink(Vec<u8>);
6486 impl MockOwnedByteSink {
6487 fn new() -> Self {
6488 Self(Vec::new())
6489 }
6490 fn write_all(&mut self, bytes: impl Into<Vec<u8>>) -> &mut Self {
6491 self.0.extend_from_slice(&bytes.into());
6492 self
6493 }
6494 fn finalize(self) -> Vec<u8> {
6495 self.0
6496 }
6497 }
6498
6499 // Fail-before-pass-after byte-parity pin on the newly lifted
6500 // `impl From<CaixaDialeto> for Vec<u8>` and
6501 // `impl From<&CaixaDialeto> for Vec<u8>` — asserts the trait-
6502 // idiomatic byte-owned reverse-projection standard-library
6503 // impls and the substrate-primitive
6504 // [`super::CaixaDialeto::as_str`] `pub const fn` accessor's
6505 // `.as_bytes().to_vec()` byte-tail resolve to the same four-arm
6506 // `PascalCase`-byte-string emit-set across every arm the
6507 // exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
6508 // Extends the substrate-wide trait-idiomatic byte-owned
6509 // reverse-projection axis onto the second closed-set fieldless
6510 // typed enum on the caixa-core-internal tier — matching the
6511 // trajectory the sibling first-mover [`super::CaixaKind`]
6512 // `From<{Self, &Self}> for Vec<u8>` impls (b245fd6) walked
6513 // before it on the caixa-core tier of the byte-owned axis.
6514 for &variant in CaixaDialeto::ALL {
6515 let via_owned_from: Vec<u8> = <Vec<u8> as From<CaixaDialeto>>::from(variant);
6516 let via_borrowed_from: Vec<u8> = <Vec<u8> as From<&CaixaDialeto>>::from(&variant);
6517 let via_method_bytes: Vec<u8> = variant.as_str().as_bytes().to_vec();
6518 assert_eq!(
6519 via_owned_from, via_method_bytes,
6520 "From<CaixaDialeto> for Vec<u8> impl must byte-equal \
6521 CaixaDialeto::as_str().as_bytes().to_vec() on \
6522 CaixaDialeto::{variant:?} — divergence signals a \
6523 silent detour off the substrate-primitive accessor"
6524 );
6525 assert_eq!(
6526 via_borrowed_from, via_method_bytes,
6527 "From<&CaixaDialeto> for Vec<u8> impl must byte-equal \
6528 CaixaDialeto::as_str().as_bytes().to_vec() on \
6529 CaixaDialeto::{variant:?} — divergence signals a \
6530 silent detour off the substrate-primitive accessor"
6531 );
6532 assert_eq!(
6533 via_owned_from, via_borrowed_from,
6534 "From<CaixaDialeto> for Vec<u8> and From<&CaixaDialeto> \
6535 for Vec<u8> must byte-equal each other on \
6536 CaixaDialeto::{variant:?} — divergence signals the \
6537 owned-input and borrowed-input paths have drifted off \
6538 the same substrate-primitive as_str accessor"
6539 );
6540 // Cross-axis witness against the paired [`AsRef<[u8]>`]
6541 // borrowed byte-view axis: the byte-owned reverse-
6542 // projection axis must byte-equal the paired borrowed
6543 // byte-view axis by construction — locking the byte-view
6544 // and byte-owned axes together at the substrate-primitive
6545 // accessor.
6546 let borrowed_bytes: &[u8] = <CaixaDialeto as AsRef<[u8]>>::as_ref(&variant);
6547 assert_eq!(
6548 via_owned_from,
6549 borrowed_bytes.to_vec(),
6550 "From<CaixaDialeto> for Vec<u8> and AsRef<[u8]> for \
6551 CaixaDialeto must resolve to byte-equal byte-tails on \
6552 CaixaDialeto::{variant:?} — divergence signals the \
6553 byte-owned and byte-view axes have drifted off the \
6554 same substrate-primitive as_str accessor"
6555 );
6556 // Cross-axis witness against the str-owned reverse-
6557 // projection family's `.into_bytes()` / `.as_bytes().to_vec()`
6558 // byte-tails: every one of `{String, Cow<'static, str>,
6559 // Box<str>, std::sync::Arc<str>, std::rc::Rc<str>}`
6560 // allocates (or borrows) the same `PascalCase` byte-string
6561 // the substrate-primitive accessor emits, so the byte-
6562 // owned axis must byte-equal each of their owned byte-
6563 // tails by construction.
6564 let owned_string: String = <String as From<CaixaDialeto>>::from(variant);
6565 assert_eq!(
6566 via_owned_from,
6567 owned_string.into_bytes(),
6568 "From<CaixaDialeto> for Vec<u8> and \
6569 String::from(dialeto).into_bytes() must resolve to \
6570 byte-equal byte-tails on CaixaDialeto::{variant:?}"
6571 );
6572 let owned_cow: std::borrow::Cow<'static, str> =
6573 <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
6574 assert_eq!(
6575 via_owned_from,
6576 owned_cow.as_bytes().to_vec(),
6577 "From<CaixaDialeto> for Vec<u8> and From<CaixaDialeto> \
6578 for Cow<'static, str> must resolve to byte-equal \
6579 byte-tails on CaixaDialeto::{variant:?}"
6580 );
6581 let owned_box: Box<str> = <Box<str> as From<CaixaDialeto>>::from(variant);
6582 assert_eq!(
6583 via_owned_from,
6584 owned_box.as_bytes().to_vec(),
6585 "From<CaixaDialeto> for Vec<u8> and From<CaixaDialeto> \
6586 for Box<str> must resolve to byte-equal byte-tails on \
6587 CaixaDialeto::{variant:?}"
6588 );
6589 let owned_arc: std::sync::Arc<str> =
6590 <std::sync::Arc<str> as From<CaixaDialeto>>::from(variant);
6591 assert_eq!(
6592 via_owned_from,
6593 owned_arc.as_bytes().to_vec(),
6594 "From<CaixaDialeto> for Vec<u8> and From<CaixaDialeto> \
6595 for std::sync::Arc<str> must resolve to byte-equal \
6596 byte-tails on CaixaDialeto::{variant:?}"
6597 );
6598 let owned_rc_str: std::rc::Rc<str> =
6599 <std::rc::Rc<str> as From<CaixaDialeto>>::from(variant);
6600 assert_eq!(
6601 via_owned_from,
6602 owned_rc_str.as_bytes().to_vec(),
6603 "From<CaixaDialeto> for Vec<u8> and From<CaixaDialeto> \
6604 for std::rc::Rc<str> must resolve to byte-equal \
6605 byte-tails on CaixaDialeto::{variant:?}"
6606 );
6607 }
6608 // `<T: Into<Vec<u8>>>`-bound-consumer witness on both owned
6609 // and borrowed input shapes: the generic owned-byte-input
6610 // function `generic_owned_bytes_sink` (lifted above per
6611 // `clippy::items_after_statements`) accepts a
6612 // [`super::CaixaDialeto`] and a `&CaixaDialeto` directly
6613 // through the trait bound, without the caller open-coding the
6614 // three-hop `dialeto.as_str().as_bytes().to_vec()` composition.
6615 for &variant in CaixaDialeto::ALL {
6616 let via_generic_owned = generic_owned_bytes_sink(variant);
6617 // Bind the borrowed-input path through an explicit
6618 // `&CaixaDialeto` local so the generic-consumer witness
6619 // routes through `From<&CaixaDialeto> for Vec<u8>` (T binds
6620 // to `&CaixaDialeto`) rather than clippy-collapsing the
6621 // borrow onto the owned-input `From<CaixaDialeto> for
6622 // Vec<u8>` peer.
6623 let variant_ref: &CaixaDialeto = &variant;
6624 let via_generic_borrowed = generic_owned_bytes_sink(variant_ref);
6625 let via_method_bytes = variant.as_str().as_bytes().to_vec();
6626 assert_eq!(
6627 via_generic_owned, via_method_bytes,
6628 "generic `<T: Into<Vec<u8>>>`-bound consumer on \
6629 CaixaDialeto::{variant:?} must yield the same byte-\
6630 tail CaixaDialeto::as_str().as_bytes().to_vec() \
6631 returns — divergence signals the byte-owned axis \
6632 fails to bridge a generic owned-byte-input trait \
6633 bound to the substrate-primitive accessor"
6634 );
6635 assert_eq!(
6636 via_generic_borrowed, via_method_bytes,
6637 "generic `<T: Into<Vec<u8>>>`-bound consumer on \
6638 &CaixaDialeto::{variant:?} must yield the same byte-\
6639 tail CaixaDialeto::as_str().as_bytes().to_vec() \
6640 returns — the borrowed-input surface must resolve to \
6641 the same as_str dispatch"
6642 );
6643 }
6644 // `std::io::Write::write_all`-shape owned-byte-sink surface
6645 // witness: the `MockOwnedByteSink` (lifted above per
6646 // `clippy::items_after_statements`) mirrors
6647 // `std::io::Write::write_all` /
6648 // `bytes::BytesMut::extend_from_slice`'s `impl Into<Vec<u8>>`-
6649 // bound owned-byte input signature and accepts a
6650 // [`super::CaixaDialeto`] directly on both owned and borrowed
6651 // input shapes, routing its byte-tail through the substrate-
6652 // primitive `as_str` accessor — the shape a future per-caixa
6653 // per-`:dialect` audit-log emit composes to fold a `:dialect`
6654 // classification byte-tag into a downstream owned-byte-sink
6655 // surface.
6656 for &variant in CaixaDialeto::ALL {
6657 let mut owned_sink = MockOwnedByteSink::new();
6658 owned_sink.write_all(variant);
6659 let owned_folded = owned_sink.finalize();
6660 assert_eq!(
6661 owned_folded,
6662 variant.as_str().as_bytes(),
6663 "`sink.write_all(dialeto)`-shape composition on \
6664 CaixaDialeto::{variant:?} must fold the same byte-\
6665 tail CaixaDialeto::as_str().as_bytes() returns"
6666 );
6667 let mut borrowed_sink = MockOwnedByteSink::new();
6668 // Same explicit `&CaixaDialeto` binding as the generic-
6669 // consumer witness above: routes the owned-byte-sink
6670 // surface through `From<&CaixaDialeto> for Vec<u8>` (T
6671 // binds to `&CaixaDialeto`) rather than clippy-collapsing
6672 // the borrow onto the owned-input peer.
6673 let variant_ref: &CaixaDialeto = &variant;
6674 borrowed_sink.write_all(variant_ref);
6675 let borrowed_folded = borrowed_sink.finalize();
6676 assert_eq!(
6677 borrowed_folded,
6678 variant.as_str().as_bytes(),
6679 "`sink.write_all(&dialeto)`-shape composition on \
6680 &CaixaDialeto::{variant:?} must fold the same byte-\
6681 tail CaixaDialeto::as_str().as_bytes() returns — the \
6682 borrowed-input surface must resolve to the same \
6683 as_str dispatch"
6684 );
6685 }
6686 }
6687
6688 #[test]
6689 #[expect(
6690 clippy::too_many_lines,
6691 reason = "the byte-owned reverse-projection axis is extended \
6692 onto CaixaDialeto at the Cow<'static, [u8]> corner \
6693 here (mirroring the trajectory the same axis walked \
6694 on the first-mover CaixaKind, b3451c8), so the pin \
6695 binds both {Self, &Self}-input impls against the \
6696 substrate-primitive as_str accessor's byte-view on \
6697 every CaixaDialeto::ALL arm, discriminates the zero-\
6698 alloc Cow::Borrowed arm on both input shapes, and \
6699 cross-witnesses against the paired Vec<u8>, \
6700 Cow<'static, str>, and AsRef<[u8]> axes so the whole \
6701 byte-family stays locked to one substrate primitive — \
6702 the assertion count follows from the closed-set axis \
6703 fan-out, not from spurious repetition"
6704 )]
6705 fn caixa_dialeto_from_into_owned_cow_bytes_routes_through_as_str_accessor() {
6706 // Fail-before-pass-after byte-parity pin on the newly lifted
6707 // `impl From<CaixaDialeto> for std::borrow::Cow<'static, [u8]>` and
6708 // `impl From<&CaixaDialeto> for std::borrow::Cow<'static, [u8]>` —
6709 // asserts the trait-idiomatic byte-owned reverse-projection
6710 // standard-library impls and the substrate-primitive
6711 // [`super::CaixaDialeto::as_str`] `pub const fn` accessor's
6712 // `.as_bytes()` byte-view resolve to the same four-arm
6713 // `PascalCase` wire byte-string emit-set across every arm the
6714 // exhaustive [`super::CaixaDialeto::ALL`] slice enumerates.
6715 // Additionally asserts the returned `Cow<'static, [u8]>` binds
6716 // the zero-alloc `Cow::Borrowed` arm on both input shapes,
6717 // because `Self::as_str` returns `&'static str` and `.as_bytes()`
6718 // on it preserves the `&'static [u8]` lifetime by construction.
6719 //
6720 // Extends the substrate-wide byte-owned reverse-projection
6721 // matrix onto the second caixa-core-internal closed-set
6722 // fieldless typed enum peer at the `Cow<'static, [u8]>` corner,
6723 // mirroring the trajectory the same axis walked on the sibling
6724 // structurally most fundamental peer [`super::CaixaKind`]
6725 // (b3451c8) and the M2/M3 slot peers.
6726 fn generic_cow_bytes_sink<T: Into<std::borrow::Cow<'static, [u8]>>>(
6727 t: T,
6728 ) -> std::borrow::Cow<'static, [u8]> {
6729 t.into()
6730 }
6731 for &variant in CaixaDialeto::ALL {
6732 let via_owned_from: std::borrow::Cow<'static, [u8]> =
6733 <std::borrow::Cow<'static, [u8]> as From<CaixaDialeto>>::from(variant);
6734 let via_borrowed_from: std::borrow::Cow<'static, [u8]> =
6735 <std::borrow::Cow<'static, [u8]> as From<&CaixaDialeto>>::from(&variant);
6736 let via_method_bytes: &'static [u8] = variant.as_str().as_bytes();
6737 assert_eq!(
6738 via_owned_from.as_ref(),
6739 via_method_bytes,
6740 "From<CaixaDialeto> for Cow<'static, [u8]> impl must \
6741 byte-equal CaixaDialeto::as_str().as_bytes() on \
6742 CaixaDialeto::{variant:?} — divergence signals a silent \
6743 detour off the substrate-primitive accessor"
6744 );
6745 assert_eq!(
6746 via_borrowed_from.as_ref(),
6747 via_method_bytes,
6748 "From<&CaixaDialeto> for Cow<'static, [u8]> impl must \
6749 byte-equal CaixaDialeto::as_str().as_bytes() on \
6750 CaixaDialeto::{variant:?} — divergence signals a silent \
6751 detour off the substrate-primitive accessor"
6752 );
6753 assert!(
6754 matches!(via_owned_from, std::borrow::Cow::Borrowed(_)),
6755 "From<CaixaDialeto> for Cow<'static, [u8]> must bind the \
6756 zero-alloc Cow::Borrowed arm on CaixaDialeto::{variant:?} \
6757 — Self::as_str returns &'static str, so a Cow::Owned \
6758 arm signals a silent allocation off the substrate \
6759 primitive"
6760 );
6761 assert!(
6762 matches!(via_borrowed_from, std::borrow::Cow::Borrowed(_)),
6763 "From<&CaixaDialeto> for Cow<'static, [u8]> must bind the \
6764 zero-alloc Cow::Borrowed arm on &CaixaDialeto::{variant:?} \
6765 — Self::as_str returns &'static str, so a Cow::Owned \
6766 arm signals a silent allocation off the substrate \
6767 primitive"
6768 );
6769 let via_into_owned: std::borrow::Cow<'static, [u8]> = variant.into();
6770 let via_into_borrowed: std::borrow::Cow<'static, [u8]> = (&variant).into();
6771 assert_eq!(
6772 via_into_owned.as_ref(),
6773 via_method_bytes,
6774 "Into<Cow<'static, [u8]>>::into on \
6775 CaixaDialeto::{variant:?} must byte-equal \
6776 CaixaDialeto::as_str().as_bytes()"
6777 );
6778 assert_eq!(
6779 via_into_borrowed.as_ref(),
6780 via_method_bytes,
6781 "Into<Cow<'static, [u8]>>::into on \
6782 &CaixaDialeto::{variant:?} must byte-equal \
6783 CaixaDialeto::as_str().as_bytes()"
6784 );
6785 assert!(
6786 matches!(via_into_owned, std::borrow::Cow::Borrowed(_)),
6787 "Into<Cow<'static, [u8]>>::into on \
6788 CaixaDialeto::{variant:?} must land on the zero-alloc \
6789 Cow::Borrowed arm"
6790 );
6791 assert!(
6792 matches!(via_into_borrowed, std::borrow::Cow::Borrowed(_)),
6793 "Into<Cow<'static, [u8]>>::into on \
6794 &CaixaDialeto::{variant:?} must land on the zero-alloc \
6795 Cow::Borrowed arm"
6796 );
6797 // Cross-axis witness against the paired byte-owned
6798 // `From<CaixaDialeto> for Vec<u8>` axis on the same
6799 // primitive: both axes must byte-equal each other because
6800 // both route through `.as_str().as_bytes()` on the same
6801 // substrate-primitive accessor.
6802 let paired_vec: Vec<u8> = <Vec<u8> as From<CaixaDialeto>>::from(variant);
6803 assert_eq!(
6804 via_owned_from.as_ref(),
6805 paired_vec.as_slice(),
6806 "From<CaixaDialeto> for Cow<'static, [u8]> and \
6807 From<CaixaDialeto> for Vec<u8> must resolve to byte-\
6808 equal byte-tails on CaixaDialeto::{variant:?} — the two \
6809 byte-owned reverse-projection axes must not drift off \
6810 the same substrate-primitive as_str accessor"
6811 );
6812 // Cross-axis witness against the paired str-owned
6813 // `From<CaixaDialeto> for Cow<'static, str>` axis on the
6814 // same primitive: `.as_bytes()` on the str-side Cow must
6815 // yield the same byte-tail the byte-side Cow carries.
6816 let paired_cow_str: std::borrow::Cow<'static, str> =
6817 <std::borrow::Cow<'static, str> as From<CaixaDialeto>>::from(variant);
6818 assert_eq!(
6819 via_owned_from.as_ref(),
6820 paired_cow_str.as_bytes(),
6821 "From<CaixaDialeto> for Cow<'static, [u8]> and \
6822 From<CaixaDialeto> for Cow<'static, str> must resolve \
6823 to byte-equal byte-tails on CaixaDialeto::{variant:?} — \
6824 the byte-side and str-side reverse-projection axes must \
6825 not drift off the same substrate-primitive as_str \
6826 accessor"
6827 );
6828 // Cross-axis witness against the paired borrowed byte-view
6829 // `AsRef<[u8]>` axis on the same primitive.
6830 let borrowed_bytes: &[u8] = <CaixaDialeto as AsRef<[u8]>>::as_ref(&variant);
6831 assert_eq!(
6832 via_owned_from.as_ref(),
6833 borrowed_bytes,
6834 "From<CaixaDialeto> for Cow<'static, [u8]> and \
6835 AsRef<[u8]> for CaixaDialeto must resolve to byte-\
6836 equal byte-tails on CaixaDialeto::{variant:?}"
6837 );
6838 }
6839 for &variant in CaixaDialeto::ALL {
6840 let owned_via_generic = generic_cow_bytes_sink(variant);
6841 let variant_ref: &CaixaDialeto = &variant;
6842 let borrowed_via_generic = generic_cow_bytes_sink(variant_ref);
6843 assert_eq!(
6844 owned_via_generic.as_ref(),
6845 variant.as_str().as_bytes(),
6846 "<T: Into<Cow<'static, [u8]>>>-bound composition on \
6847 CaixaDialeto::{variant:?} must fold the same byte-tail \
6848 CaixaDialeto::as_str().as_bytes() returns"
6849 );
6850 assert_eq!(
6851 borrowed_via_generic.as_ref(),
6852 variant.as_str().as_bytes(),
6853 "<T: Into<Cow<'static, [u8]>>>-bound composition on \
6854 &CaixaDialeto::{variant:?} must fold the same byte-tail \
6855 CaixaDialeto::as_str().as_bytes() returns"
6856 );
6857 }
6858 }
6859
6860 #[test]
6861 #[expect(
6862 clippy::too_many_lines,
6863 reason = "the byte-owned reverse-projection axis is extended \
6864 onto CaixaDialeto at the Box<[u8]> corner here \
6865 (mirroring the trajectory c6fee5c walked on WitShape), \
6866 so the pin binds both {Self, &Self}-input impls against \
6867 the substrate-primitive as_str accessor's byte-view on \
6868 every CaixaDialeto::ALL arm, adds fit-to-length length-\
6869 check witnesses on both surfaces, exercises the \
6870 <T: Into<Box<[u8]>>>-bound generic sink on both input \
6871 shapes, pins the borrowed-input axis with a \
6872 `.iter().map(Box::<[u8]>::from)` pipe witness over \
6873 CaixaDialeto::ALL, and cross-witnesses against the \
6874 paired Vec<u8>, Cow<'static, [u8]>, Box<str>, and \
6875 AsRef<[u8]> axes so the whole byte-family stays locked \
6876 to one substrate primitive — the assertion count \
6877 follows from the closed-set axis fan-out, not from \
6878 spurious repetition"
6879 )]
6880 fn caixa_dialeto_from_into_owned_box_bytes_routes_through_as_str_accessor() {
6881 // Fail-before-pass-after byte-parity pin on the newly lifted
6882 // `impl From<CaixaDialeto> for Box<[u8]>` and
6883 // `impl From<&CaixaDialeto> for Box<[u8]>` — asserts the trait-
6884 // idiomatic byte-owned reverse-projection standard-library impls
6885 // and the substrate-primitive [`super::CaixaDialeto::as_str`]
6886 // `pub const fn` accessor's `.as_bytes()` byte-view resolve to
6887 // the same four-arm `PascalCase` wire byte-string emit-set
6888 // across every arm the exhaustive [`super::CaixaDialeto::ALL`]
6889 // slice enumerates. Additionally asserts the returned
6890 // `Box<[u8]>` is fit-to-length on every arm, because
6891 // `Box::<[u8]>::from(&[u8])` allocates `len` bytes exactly (no
6892 // capacity slack), the property downstream `Box<[u8]>`
6893 // consumers (a `bytes::Bytes::from(Box<[u8]>)` framer at the
6894 // mesh-ingest boundary) rely on to keep the per-arm footprint
6895 // stable across the accept-set.
6896 //
6897 // Extends the substrate-wide byte-owned reverse-projection
6898 // matrix onto the second caixa-core-internal closed-set
6899 // fieldless typed enum peer at the `Box<[u8]>` corner,
6900 // mirroring the trajectory c6fee5c walked on the third M3 peer
6901 // `WitShape`, b22c283 on the second M3 peer `RateLimitUnit`,
6902 // fb48599 on the first M3 peer `PlacementStrategy`, and 4f47901
6903 // on the first-mover `CaixaKind`.
6904 fn generic_box_bytes_sink<T: Into<Box<[u8]>>>(t: T) -> Box<[u8]> {
6905 t.into()
6906 }
6907 for &variant in CaixaDialeto::ALL {
6908 let via_owned_from: Box<[u8]> = <Box<[u8]> as From<CaixaDialeto>>::from(variant);
6909 let via_borrowed_from: Box<[u8]> = <Box<[u8]> as From<&CaixaDialeto>>::from(&variant);
6910 let via_method_bytes: &'static [u8] = variant.as_str().as_bytes();
6911 assert_eq!(
6912 via_owned_from.as_ref(),
6913 via_method_bytes,
6914 "From<CaixaDialeto> for Box<[u8]> impl must byte-equal \
6915 CaixaDialeto::as_str().as_bytes() on \
6916 CaixaDialeto::{variant:?} — divergence signals a silent \
6917 detour off the substrate-primitive accessor"
6918 );
6919 assert_eq!(
6920 via_borrowed_from.as_ref(),
6921 via_method_bytes,
6922 "From<&CaixaDialeto> for Box<[u8]> impl must byte-equal \
6923 CaixaDialeto::as_str().as_bytes() on \
6924 CaixaDialeto::{variant:?} — divergence signals a silent \
6925 detour off the substrate-primitive accessor"
6926 );
6927 assert_eq!(
6928 via_owned_from.len(),
6929 via_method_bytes.len(),
6930 "From<CaixaDialeto> for Box<[u8]> must land a fit-to-\
6931 length boxed byte slice on CaixaDialeto::{variant:?} — \
6932 a length mismatch signals a silent slab-header hop off \
6933 the substrate-primitive accessor"
6934 );
6935 assert_eq!(
6936 via_borrowed_from.len(),
6937 via_method_bytes.len(),
6938 "From<&CaixaDialeto> for Box<[u8]> must land a fit-to-\
6939 length boxed byte slice on CaixaDialeto::{variant:?}"
6940 );
6941 let via_into_owned: Box<[u8]> = variant.into();
6942 let via_into_borrowed: Box<[u8]> = (&variant).into();
6943 assert_eq!(
6944 via_into_owned.as_ref(),
6945 via_method_bytes,
6946 "Into<Box<[u8]>>::into on CaixaDialeto::{variant:?} \
6947 must byte-equal CaixaDialeto::as_str().as_bytes()"
6948 );
6949 assert_eq!(
6950 via_into_borrowed.as_ref(),
6951 via_method_bytes,
6952 "Into<Box<[u8]>>::into on &CaixaDialeto::{variant:?} \
6953 must byte-equal CaixaDialeto::as_str().as_bytes()"
6954 );
6955 // Cross-axis witness against the paired byte-owned
6956 // `From<CaixaDialeto> for Vec<u8>` axis on the same
6957 // primitive.
6958 let paired_vec: Vec<u8> = <Vec<u8> as From<CaixaDialeto>>::from(variant);
6959 assert_eq!(
6960 via_owned_from.as_ref(),
6961 paired_vec.as_slice(),
6962 "From<CaixaDialeto> for Box<[u8]> and From<CaixaDialeto> \
6963 for Vec<u8> must resolve to byte-equal byte-tails on \
6964 CaixaDialeto::{variant:?} — the two byte-owned reverse-\
6965 projection axes must not drift off the same substrate-\
6966 primitive as_str accessor"
6967 );
6968 // Cross-axis witness against the paired byte-owned
6969 // `From<CaixaDialeto> for Cow<'static, [u8]>` axis.
6970 let paired_cow_bytes: std::borrow::Cow<'static, [u8]> =
6971 <std::borrow::Cow<'static, [u8]> as From<CaixaDialeto>>::from(variant);
6972 assert_eq!(
6973 via_owned_from.as_ref(),
6974 paired_cow_bytes.as_ref(),
6975 "From<CaixaDialeto> for Box<[u8]> and From<CaixaDialeto> \
6976 for Cow<'static, [u8]> must resolve to byte-equal byte-\
6977 tails on CaixaDialeto::{variant:?} — the two byte-owned \
6978 reverse-projection axes must not drift off the same \
6979 substrate-primitive as_str accessor"
6980 );
6981 // Cross-axis witness against the paired str-owned
6982 // `From<CaixaDialeto> for Box<str>` axis on the same
6983 // primitive — the byte-side and str-side owned-heap axes
6984 // must byte-agree.
6985 let paired_box_str: Box<str> = <Box<str> as From<CaixaDialeto>>::from(variant);
6986 assert_eq!(
6987 via_owned_from.as_ref(),
6988 paired_box_str.as_bytes(),
6989 "From<CaixaDialeto> for Box<[u8]> and From<CaixaDialeto> \
6990 for Box<str> must resolve to byte-equal byte-tails on \
6991 CaixaDialeto::{variant:?} — the byte-side and str-side \
6992 owned-heap reverse-projection axes must not drift off \
6993 the same substrate-primitive as_str accessor"
6994 );
6995 // Cross-axis witness against the borrowed byte-view
6996 // `AsRef<[u8]>` axis on the same primitive.
6997 let borrowed_bytes: &[u8] = <CaixaDialeto as AsRef<[u8]>>::as_ref(&variant);
6998 assert_eq!(
6999 via_owned_from.as_ref(),
7000 borrowed_bytes,
7001 "From<CaixaDialeto> for Box<[u8]> and AsRef<[u8]> for \
7002 CaixaDialeto must resolve to byte-equal byte-tails on \
7003 CaixaDialeto::{variant:?}"
7004 );
7005 }
7006 for &variant in CaixaDialeto::ALL {
7007 let owned_via_generic = generic_box_bytes_sink(variant);
7008 let variant_ref: &CaixaDialeto = &variant;
7009 let borrowed_via_generic = generic_box_bytes_sink(variant_ref);
7010 assert_eq!(
7011 owned_via_generic.as_ref(),
7012 variant.as_str().as_bytes(),
7013 "<T: Into<Box<[u8]>>>-bound composition on \
7014 CaixaDialeto::{variant:?} must fold the same byte-tail \
7015 CaixaDialeto::as_str().as_bytes() returns"
7016 );
7017 assert_eq!(
7018 borrowed_via_generic.as_ref(),
7019 variant.as_str().as_bytes(),
7020 "<T: Into<Box<[u8]>>>-bound composition on \
7021 &CaixaDialeto::{variant:?} must fold the same byte-tail \
7022 CaixaDialeto::as_str().as_bytes() returns"
7023 );
7024 }
7025 // `.iter().map(Box::<[u8]>::from)` pipe witness over
7026 // `CaixaDialeto::ALL` — binds the borrowed-input axis, because
7027 // the iterator over `&'static [CaixaDialeto]` yields
7028 // `&CaixaDialeto`, not `CaixaDialeto`.
7029 let via_iter: Vec<Box<[u8]>> = CaixaDialeto::ALL.iter().map(Box::<[u8]>::from).collect();
7030 let via_method: Vec<Box<[u8]>> = CaixaDialeto::ALL
7031 .iter()
7032 .map(|d| Box::<[u8]>::from(d.as_str().as_bytes()))
7033 .collect();
7034 assert_eq!(
7035 via_iter, via_method,
7036 "`.iter().map(Box::<[u8]>::from)` over CaixaDialeto::ALL \
7037 must byte-equal the open-coded per-arm composition — the \
7038 borrowed-input axis is what makes the `Box::from` \
7039 composition route through the substrate-primitive \
7040 CaixaDialeto::as_str accessor without a spurious \
7041 `.copied()` restatement"
7042 );
7043 }
7044
7045 #[test]
7046 #[expect(
7047 clippy::too_many_lines,
7048 reason = "the byte-owned reverse-projection axis is extended \
7049 onto CaixaDialeto at the Arc<[u8]> corner here \
7050 (mirroring the trajectory d2976c2 walked on WitShape, \
7051 e872c77 on RateLimitUnit, 64cdf90 on \
7052 PlacementStrategy, and d8872df on CaixaKind), so the \
7053 pin binds both {Self, &Self}-input impls against the \
7054 substrate-primitive as_str accessor's byte-view on \
7055 every CaixaDialeto::ALL arm, adds fit-to-length length-\
7056 check witnesses on both surfaces, exercises the \
7057 <T: Into<Arc<[u8]>>>-bound generic sink on both input \
7058 shapes, pins the borrowed-input axis with a \
7059 `.iter().map(Arc::<[u8]>::from)` pipe witness over \
7060 CaixaDialeto::ALL, and cross-witnesses against the \
7061 paired Vec<u8>, Cow<'static, [u8]>, Box<[u8]>, \
7062 Arc<str>, and AsRef<[u8]> axes so the whole byte-\
7063 family stays locked to one substrate primitive — the \
7064 assertion count follows from the closed-set axis fan-\
7065 out, not from spurious repetition"
7066 )]
7067 fn caixa_dialeto_from_into_owned_arc_bytes_routes_through_as_str_accessor() {
7068 // Fail-before-pass-after byte-parity pin on the newly lifted
7069 // `impl From<CaixaDialeto> for std::sync::Arc<[u8]>` and
7070 // `impl From<&CaixaDialeto> for std::sync::Arc<[u8]>` — asserts the
7071 // trait-idiomatic byte-owned reverse-projection standard-library
7072 // impls and the substrate-primitive
7073 // [`super::CaixaDialeto::as_str`] `pub const fn` accessor's
7074 // `.as_bytes()` byte-view resolve to the same four-arm
7075 // `PascalCase` wire byte-string emit-set across every arm the
7076 // exhaustive [`super::CaixaDialeto::ALL`] slice enumerates, on
7077 // both the owned-input `CaixaDialeto` and borrowed-input
7078 // `&CaixaDialeto` surfaces. Additionally asserts the returned
7079 // `Arc<[u8]>` is fit-to-length on every arm, because
7080 // `std::sync::Arc::<[u8]>::from(&[u8])` allocates a slab whose
7081 // payload is `len` bytes exactly (no capacity slack), the
7082 // property downstream `Arc<[u8]>` consumers (a future thread-
7083 // safe `HashMap::<Arc<[u8]>, _>::from_iter` keyed by the wire
7084 // byte-tail) rely on to keep the per-arm footprint stable across
7085 // the accept-set.
7086 //
7087 // Extends the substrate-wide byte-owned reverse-projection
7088 // matrix onto the second caixa-core-internal closed-set
7089 // fieldless typed enum peer at the `Arc<[u8]>` corner,
7090 // mirroring the trajectory d2976c2 walked on the third M3 peer
7091 // `WitShape`, e872c77 on the second M3 peer `RateLimitUnit`,
7092 // 64cdf90 on the first M3 peer `PlacementStrategy`, and d8872df
7093 // on the first-mover `CaixaKind`.
7094 fn generic_arc_bytes_sink<T: Into<std::sync::Arc<[u8]>>>(t: T) -> std::sync::Arc<[u8]> {
7095 t.into()
7096 }
7097 for &variant in CaixaDialeto::ALL {
7098 let via_owned_from: std::sync::Arc<[u8]> =
7099 <std::sync::Arc<[u8]> as From<CaixaDialeto>>::from(variant);
7100 let via_borrowed_from: std::sync::Arc<[u8]> =
7101 <std::sync::Arc<[u8]> as From<&CaixaDialeto>>::from(&variant);
7102 let via_method_bytes: &'static [u8] = variant.as_str().as_bytes();
7103 assert_eq!(
7104 via_owned_from.as_ref(),
7105 via_method_bytes,
7106 "From<CaixaDialeto> for Arc<[u8]> impl must byte-equal \
7107 CaixaDialeto::as_str().as_bytes() on \
7108 CaixaDialeto::{variant:?} — divergence signals a silent \
7109 detour off the substrate-primitive accessor"
7110 );
7111 assert_eq!(
7112 via_borrowed_from.as_ref(),
7113 via_method_bytes,
7114 "From<&CaixaDialeto> for Arc<[u8]> impl must byte-equal \
7115 CaixaDialeto::as_str().as_bytes() on \
7116 CaixaDialeto::{variant:?} — divergence signals a silent \
7117 detour off the substrate-primitive accessor"
7118 );
7119 assert_eq!(
7120 via_owned_from.len(),
7121 via_method_bytes.len(),
7122 "From<CaixaDialeto> for Arc<[u8]> must land a fit-to-\
7123 length atomically-refcounted byte slab on \
7124 CaixaDialeto::{variant:?} — a length mismatch signals \
7125 a silent slab-header hop off the substrate-primitive \
7126 accessor"
7127 );
7128 assert_eq!(
7129 via_borrowed_from.len(),
7130 via_method_bytes.len(),
7131 "From<&CaixaDialeto> for Arc<[u8]> must land a fit-to-\
7132 length atomically-refcounted byte slab on \
7133 CaixaDialeto::{variant:?}"
7134 );
7135 let via_into_owned: std::sync::Arc<[u8]> = variant.into();
7136 let via_into_borrowed: std::sync::Arc<[u8]> = (&variant).into();
7137 assert_eq!(
7138 via_into_owned.as_ref(),
7139 via_method_bytes,
7140 "Into<Arc<[u8]>>::into on CaixaDialeto::{variant:?} \
7141 must byte-equal CaixaDialeto::as_str().as_bytes()"
7142 );
7143 assert_eq!(
7144 via_into_borrowed.as_ref(),
7145 via_method_bytes,
7146 "Into<Arc<[u8]>>::into on &CaixaDialeto::{variant:?} \
7147 must byte-equal CaixaDialeto::as_str().as_bytes()"
7148 );
7149 assert_eq!(
7150 via_borrowed_from.as_ref(),
7151 via_owned_from.as_ref(),
7152 "owned and borrowed Arc<[u8]> corners must byte-agree on \
7153 CaixaDialeto::{variant:?}"
7154 );
7155 // Cross-axis witness against the paired byte-owned
7156 // `From<CaixaDialeto> for Vec<u8>` axis on the same
7157 // primitive.
7158 let paired_vec: Vec<u8> = <Vec<u8> as From<CaixaDialeto>>::from(variant);
7159 assert_eq!(
7160 via_owned_from.as_ref(),
7161 paired_vec.as_slice(),
7162 "From<CaixaDialeto> for Arc<[u8]> and From<CaixaDialeto> \
7163 for Vec<u8> must resolve to byte-equal byte-tails on \
7164 CaixaDialeto::{variant:?} — the two byte-owned reverse-\
7165 projection axes must not drift off the same substrate-\
7166 primitive as_str accessor"
7167 );
7168 // Cross-axis witness against the paired byte-owned
7169 // `From<CaixaDialeto> for Cow<'static, [u8]>` axis.
7170 let paired_cow_bytes: std::borrow::Cow<'static, [u8]> =
7171 <std::borrow::Cow<'static, [u8]> as From<CaixaDialeto>>::from(variant);
7172 assert_eq!(
7173 via_owned_from.as_ref(),
7174 paired_cow_bytes.as_ref(),
7175 "From<CaixaDialeto> for Arc<[u8]> and From<CaixaDialeto> \
7176 for Cow<'static, [u8]> must resolve to byte-equal byte-\
7177 tails on CaixaDialeto::{variant:?} — the two byte-owned \
7178 reverse-projection axes must not drift off the same \
7179 substrate-primitive as_str accessor"
7180 );
7181 // Cross-axis witness against the paired byte-owned
7182 // `From<CaixaDialeto> for Box<[u8]>` axis on the same
7183 // primitive — the two owned byte-slab axes must byte-agree.
7184 let paired_box_bytes: Box<[u8]> = <Box<[u8]> as From<CaixaDialeto>>::from(variant);
7185 assert_eq!(
7186 via_owned_from.as_ref(),
7187 paired_box_bytes.as_ref(),
7188 "From<CaixaDialeto> for Arc<[u8]> and From<CaixaDialeto> \
7189 for Box<[u8]> must resolve to byte-equal byte-tails on \
7190 CaixaDialeto::{variant:?} — the two owned byte-slab \
7191 reverse-projection axes must not drift off the same \
7192 substrate-primitive as_str accessor"
7193 );
7194 // Cross-axis witness against the paired str-side
7195 // `From<CaixaDialeto> for std::sync::Arc<str>` axis on the
7196 // same primitive — the byte-side and str-side Arc axes
7197 // must byte-agree.
7198 let paired_arc_str: std::sync::Arc<str> =
7199 <std::sync::Arc<str> as From<CaixaDialeto>>::from(variant);
7200 assert_eq!(
7201 via_owned_from.as_ref(),
7202 paired_arc_str.as_bytes(),
7203 "From<CaixaDialeto> for Arc<[u8]> and From<CaixaDialeto> \
7204 for Arc<str> must resolve to byte-equal byte-tails on \
7205 CaixaDialeto::{variant:?} — the byte-side and str-side \
7206 Arc reverse-projection axes must not drift off the same \
7207 substrate-primitive as_str accessor"
7208 );
7209 // Cross-axis witness against the borrowed byte-view
7210 // `AsRef<[u8]>` axis on the same primitive.
7211 let borrowed_bytes: &[u8] = <CaixaDialeto as AsRef<[u8]>>::as_ref(&variant);
7212 assert_eq!(
7213 via_owned_from.as_ref(),
7214 borrowed_bytes,
7215 "From<CaixaDialeto> for Arc<[u8]> and AsRef<[u8]> for \
7216 CaixaDialeto must resolve to byte-equal byte-tails on \
7217 CaixaDialeto::{variant:?}"
7218 );
7219 }
7220 for &variant in CaixaDialeto::ALL {
7221 let owned_via_generic = generic_arc_bytes_sink(variant);
7222 let variant_ref: &CaixaDialeto = &variant;
7223 let borrowed_via_generic = generic_arc_bytes_sink(variant_ref);
7224 assert_eq!(
7225 owned_via_generic.as_ref(),
7226 variant.as_str().as_bytes(),
7227 "<T: Into<Arc<[u8]>>>-bound composition on \
7228 CaixaDialeto::{variant:?} must fold the same byte-tail \
7229 CaixaDialeto::as_str().as_bytes() returns"
7230 );
7231 assert_eq!(
7232 borrowed_via_generic.as_ref(),
7233 variant.as_str().as_bytes(),
7234 "<T: Into<Arc<[u8]>>>-bound composition on \
7235 &CaixaDialeto::{variant:?} must fold the same byte-tail \
7236 CaixaDialeto::as_str().as_bytes() returns"
7237 );
7238 }
7239 // Source-survival witness on the borrowed-input peer: the
7240 // `From<&CaixaDialeto>` impl reads through the borrow, so the
7241 // source value must remain reachable after the projection.
7242 for &variant in CaixaDialeto::ALL {
7243 let variant_ref: &CaixaDialeto = &variant;
7244 let _via_borrowed: std::sync::Arc<[u8]> = variant_ref.into();
7245 let via_str_after: &'static str = variant_ref.as_str();
7246 assert_eq!(
7247 via_str_after.as_bytes(),
7248 variant.as_str().as_bytes(),
7249 "borrowed source &CaixaDialeto::{variant:?} must remain \
7250 reachable after From<&CaixaDialeto> for Arc<[u8]> — a \
7251 silent move-out on the borrowed axis would break the \
7252 source-survival contract on the borrowed-input peer"
7253 );
7254 }
7255 // `.iter().map(std::sync::Arc::<[u8]>::from)` pipe witness over
7256 // `CaixaDialeto::ALL` — binds the borrowed-input axis, because
7257 // the iterator over `&'static [CaixaDialeto]` yields
7258 // `&CaixaDialeto`, not `CaixaDialeto`.
7259 let via_iter: Vec<std::sync::Arc<[u8]>> = CaixaDialeto::ALL
7260 .iter()
7261 .map(std::sync::Arc::<[u8]>::from)
7262 .collect();
7263 let via_method: Vec<std::sync::Arc<[u8]>> = CaixaDialeto::ALL
7264 .iter()
7265 .map(|d| std::sync::Arc::<[u8]>::from(d.as_str().as_bytes()))
7266 .collect();
7267 for (i, &variant) in CaixaDialeto::ALL.iter().enumerate() {
7268 assert_eq!(
7269 via_iter[i].as_ref(),
7270 via_method[i].as_ref(),
7271 "`.iter().map(std::sync::Arc::<[u8]>::from)` over \
7272 CaixaDialeto::ALL must byte-equal the open-coded per-\
7273 arm composition on CaixaDialeto::{variant:?} — the \
7274 borrowed-input axis is what makes the `Arc::from` \
7275 composition route through the substrate-primitive \
7276 CaixaDialeto::as_str accessor without a spurious \
7277 `.copied()` restatement"
7278 );
7279 }
7280 }
7281
7282 #[test]
7283 #[expect(
7284 clippy::too_many_lines,
7285 reason = "the byte-owned reverse-projection axis is closed \
7286 onto CaixaDialeto at the Rc<[u8]> corner here \
7287 (mirroring the trajectory 5569794 walked on WitShape, \
7288 15d22b1 on RateLimitUnit, 3d8170c on \
7289 PlacementStrategy, and db8dcc2 on CaixaKind), which \
7290 means the cross-axis reconciliation witness must \
7291 bind against the Vec<u8>, Cow<'static, [u8]>, \
7292 Box<[u8]>, Arc<[u8]>, and Rc<str> axes on every arm \
7293 the exhaustive CaixaDialeto::ALL slice enumerates — \
7294 splitting that witness across a helper would break \
7295 the fail-before-pass-after contract, because a \
7296 future silent detour on any one axis must trip at \
7297 the single pin test that closes this partition"
7298 )]
7299 fn caixa_dialeto_from_into_owned_rc_bytes_routes_through_as_str_accessor() {
7300 // Fail-before-pass-after byte-parity pin on the newly lifted
7301 // `impl From<CaixaDialeto> for std::rc::Rc<[u8]>` and
7302 // `impl From<&CaixaDialeto> for std::rc::Rc<[u8]>` — asserts the
7303 // trait-idiomatic byte-owned reverse-projection standard-library
7304 // impls and the substrate-primitive
7305 // [`super::CaixaDialeto::as_str`] `pub const fn` accessor's
7306 // `.as_bytes()` byte-view resolve to the same four-arm
7307 // `PascalCase` wire byte-string emit-set across every arm the
7308 // exhaustive [`super::CaixaDialeto::ALL`] slice enumerates, on
7309 // both the owned-input `CaixaDialeto` and borrowed-input
7310 // `&CaixaDialeto` surfaces. Additionally asserts the returned
7311 // `Rc<[u8]>` is fit-to-length on every arm, because
7312 // `std::rc::Rc::<[u8]>::from(&[u8])` allocates a slab whose
7313 // payload is `len` bytes exactly (no capacity slack), the
7314 // property downstream single-threaded `Rc<[u8]>` consumers (a
7315 // future non-`Send` `HashMap::<Rc<[u8]>, _>::from_iter` keyed
7316 // by the wire byte-tail) rely on to keep the per-arm footprint
7317 // stable across the accept-set.
7318 //
7319 // Closes the substrate-wide byte-owned reverse-projection matrix
7320 // on the second caixa-core-internal closed-set fieldless typed-
7321 // enum peer at the [`std::rc::Rc<[u8]>`] corner — completing
7322 // the full `{Vec<u8>, Cow<'static, [u8]>, Box<[u8]>, Arc<[u8]>,
7323 // Rc<[u8]>}` five-corner partition on the same wire byte-string,
7324 // mirroring the trajectory the same axis walked on the sibling
7325 // third M3-mesh-primitive-defining [`super::super::aplicacao::WitShape`]
7326 // peer (5569794), on the sibling second M3-mesh-primitive-
7327 // defining [`super::super::aplicacao::RateLimitUnit`] peer
7328 // (15d22b1), on the sibling first M3-mesh-primitive-defining
7329 // [`super::super::aplicacao::PlacementStrategy`] peer (3d8170c),
7330 // on the sibling [`super::super::CaixaKind`] structurally most
7331 // fundamental closed-set fieldless typed-enum peer (db8dcc2),
7332 // and on the M2-OTP-shape
7333 // [`super::super::supervisor::RestartStrategy`] peer (2620e42)
7334 // and [`super::super::supervisor::RestartPolicy`] peer (6848c05).
7335 fn generic_rc_bytes_sink<T: Into<std::rc::Rc<[u8]>>>(t: T) -> std::rc::Rc<[u8]> {
7336 t.into()
7337 }
7338 for &variant in CaixaDialeto::ALL {
7339 let via_owned_from: std::rc::Rc<[u8]> =
7340 <std::rc::Rc<[u8]> as From<CaixaDialeto>>::from(variant);
7341 let via_borrowed_from: std::rc::Rc<[u8]> =
7342 <std::rc::Rc<[u8]> as From<&CaixaDialeto>>::from(&variant);
7343 let via_method_bytes: &'static [u8] = variant.as_str().as_bytes();
7344 assert_eq!(
7345 via_owned_from.as_ref(),
7346 via_method_bytes,
7347 "From<CaixaDialeto> for Rc<[u8]> impl must byte-equal \
7348 CaixaDialeto::as_str().as_bytes() on \
7349 CaixaDialeto::{variant:?} — divergence signals a silent \
7350 detour off the substrate-primitive accessor"
7351 );
7352 assert_eq!(
7353 via_borrowed_from.as_ref(),
7354 via_method_bytes,
7355 "From<&CaixaDialeto> for Rc<[u8]> impl must byte-equal \
7356 CaixaDialeto::as_str().as_bytes() on \
7357 CaixaDialeto::{variant:?} — divergence signals a silent \
7358 detour off the substrate-primitive accessor"
7359 );
7360 assert_eq!(
7361 via_owned_from.len(),
7362 via_method_bytes.len(),
7363 "From<CaixaDialeto> for Rc<[u8]> must land a fit-to-\
7364 length single-threaded-refcounted byte slab on \
7365 CaixaDialeto::{variant:?} — a length mismatch against \
7366 CaixaDialeto::as_str().as_bytes().len() signals the \
7367 Rc<[u8]> allocator drifted off the substrate primitive's \
7368 byte-tail"
7369 );
7370 assert_eq!(
7371 via_borrowed_from.len(),
7372 via_method_bytes.len(),
7373 "From<&CaixaDialeto> for Rc<[u8]> must land a fit-to-\
7374 length single-threaded-refcounted byte slab on \
7375 CaixaDialeto::{variant:?}"
7376 );
7377 let via_into_owned: std::rc::Rc<[u8]> = variant.into();
7378 let via_into_borrowed: std::rc::Rc<[u8]> = (&variant).into();
7379 assert_eq!(
7380 via_into_owned.as_ref(),
7381 via_method_bytes,
7382 "Into<Rc<[u8]>>::into on CaixaDialeto::{variant:?} must \
7383 byte-equal CaixaDialeto::as_str().as_bytes()"
7384 );
7385 assert_eq!(
7386 via_into_borrowed.as_ref(),
7387 via_method_bytes,
7388 "Into<Rc<[u8]>>::into on &CaixaDialeto::{variant:?} must \
7389 byte-equal CaixaDialeto::as_str().as_bytes()"
7390 );
7391 assert_eq!(
7392 via_borrowed_from.as_ref(),
7393 via_owned_from.as_ref(),
7394 "owned and borrowed Rc<[u8]> corners must byte-agree on \
7395 CaixaDialeto::{variant:?}"
7396 );
7397 // Cross-axis witness against the paired byte-owned
7398 // `From<CaixaDialeto> for Vec<u8>` axis on the same
7399 // primitive.
7400 let paired_vec: Vec<u8> = <Vec<u8> as From<CaixaDialeto>>::from(variant);
7401 assert_eq!(
7402 via_owned_from.as_ref(),
7403 paired_vec.as_slice(),
7404 "From<CaixaDialeto> for Rc<[u8]> and From<CaixaDialeto> \
7405 for Vec<u8> must resolve to byte-equal byte-tails on \
7406 CaixaDialeto::{variant:?} — the two byte-owned reverse-\
7407 projection axes must not drift off the same substrate-\
7408 primitive as_str accessor"
7409 );
7410 // Cross-axis witness against the paired byte-owned
7411 // `From<CaixaDialeto> for Cow<'static, [u8]>` axis.
7412 let paired_cow_bytes: std::borrow::Cow<'static, [u8]> =
7413 <std::borrow::Cow<'static, [u8]> as From<CaixaDialeto>>::from(variant);
7414 assert_eq!(
7415 via_owned_from.as_ref(),
7416 paired_cow_bytes.as_ref(),
7417 "From<CaixaDialeto> for Rc<[u8]> and From<CaixaDialeto> \
7418 for Cow<'static, [u8]> must resolve to byte-equal byte-\
7419 tails on CaixaDialeto::{variant:?} — the two byte-owned \
7420 reverse-projection axes must not drift off the same \
7421 substrate-primitive as_str accessor"
7422 );
7423 // Cross-axis witness against the paired byte-owned
7424 // `From<CaixaDialeto> for Box<[u8]>` axis on the same
7425 // primitive — the two owned byte-slab axes must byte-agree.
7426 let paired_box_bytes: Box<[u8]> = <Box<[u8]> as From<CaixaDialeto>>::from(variant);
7427 assert_eq!(
7428 via_owned_from.as_ref(),
7429 paired_box_bytes.as_ref(),
7430 "From<CaixaDialeto> for Rc<[u8]> and From<CaixaDialeto> \
7431 for Box<[u8]> must resolve to byte-equal byte-tails on \
7432 CaixaDialeto::{variant:?} — the two owned byte-slab \
7433 reverse-projection axes must not drift off the same \
7434 substrate-primitive as_str accessor"
7435 );
7436 // Cross-axis witness against the paired byte-owned
7437 // `From<CaixaDialeto> for std::sync::Arc<[u8]>` axis on the
7438 // same primitive — the single-threaded and atomically-
7439 // refcounted byte-slab axes must byte-agree.
7440 let paired_atomic_arc_bytes: std::sync::Arc<[u8]> =
7441 <std::sync::Arc<[u8]> as From<CaixaDialeto>>::from(variant);
7442 assert_eq!(
7443 via_owned_from.as_ref(),
7444 paired_atomic_arc_bytes.as_ref(),
7445 "From<CaixaDialeto> for Rc<[u8]> and From<CaixaDialeto> \
7446 for Arc<[u8]> must resolve to byte-equal byte-tails on \
7447 CaixaDialeto::{variant:?} — the single-threaded and \
7448 atomically-refcounted byte-slab reverse-projection \
7449 axes must not drift off the same substrate-primitive \
7450 as_str accessor"
7451 );
7452 // Cross-axis witness against the paired str-side
7453 // `From<CaixaDialeto> for std::rc::Rc<str>` axis on the same
7454 // primitive — the byte-side and str-side Rc axes must byte-
7455 // agree.
7456 let paired_rc_str: std::rc::Rc<str> =
7457 <std::rc::Rc<str> as From<CaixaDialeto>>::from(variant);
7458 assert_eq!(
7459 via_owned_from.as_ref(),
7460 paired_rc_str.as_bytes(),
7461 "From<CaixaDialeto> for Rc<[u8]> and From<CaixaDialeto> \
7462 for Rc<str> must resolve to byte-equal byte-tails on \
7463 CaixaDialeto::{variant:?} — the byte-side and str-side \
7464 Rc reverse-projection axes must not drift off the same \
7465 substrate-primitive as_str accessor"
7466 );
7467 // Cross-axis witness against the borrowed byte-view
7468 // `AsRef<[u8]>` axis on the same primitive.
7469 let borrowed_bytes: &[u8] = <CaixaDialeto as AsRef<[u8]>>::as_ref(&variant);
7470 assert_eq!(
7471 via_owned_from.as_ref(),
7472 borrowed_bytes,
7473 "From<CaixaDialeto> for Rc<[u8]> and AsRef<[u8]> for \
7474 CaixaDialeto must resolve to byte-equal byte-tails on \
7475 CaixaDialeto::{variant:?}"
7476 );
7477 }
7478 for &variant in CaixaDialeto::ALL {
7479 let owned_via_generic = generic_rc_bytes_sink(variant);
7480 let variant_ref: &CaixaDialeto = &variant;
7481 let borrowed_via_generic = generic_rc_bytes_sink(variant_ref);
7482 assert_eq!(
7483 owned_via_generic.as_ref(),
7484 variant.as_str().as_bytes(),
7485 "<T: Into<Rc<[u8]>>>-bound composition on \
7486 CaixaDialeto::{variant:?} must fold the same byte-tail \
7487 CaixaDialeto::as_str().as_bytes() returns"
7488 );
7489 assert_eq!(
7490 borrowed_via_generic.as_ref(),
7491 variant.as_str().as_bytes(),
7492 "<T: Into<Rc<[u8]>>>-bound composition on \
7493 &CaixaDialeto::{variant:?} must fold the same byte-tail \
7494 CaixaDialeto::as_str().as_bytes() returns"
7495 );
7496 }
7497 // Source-survival witness on the borrowed-input peer: the
7498 // `From<&CaixaDialeto>` impl reads through the borrow, so the
7499 // source value must remain reachable after the projection.
7500 for &variant in CaixaDialeto::ALL {
7501 let variant_ref: &CaixaDialeto = &variant;
7502 let _via_borrowed: std::rc::Rc<[u8]> = variant_ref.into();
7503 let via_str_after: &'static str = variant_ref.as_str();
7504 assert_eq!(
7505 via_str_after.as_bytes(),
7506 variant.as_str().as_bytes(),
7507 "borrowed source &CaixaDialeto::{variant:?} must remain \
7508 reachable after From<&CaixaDialeto> for Rc<[u8]> — a \
7509 silent move-out on the borrowed axis would break the \
7510 source-survival contract on the borrowed-input peer"
7511 );
7512 }
7513 // `.iter().map(std::rc::Rc::<[u8]>::from)` pipe witness over
7514 // `CaixaDialeto::ALL` — binds the borrowed-input axis, because
7515 // the iterator over `&'static [CaixaDialeto]` yields
7516 // `&CaixaDialeto`, not `CaixaDialeto`.
7517 let via_iter: Vec<std::rc::Rc<[u8]>> = CaixaDialeto::ALL
7518 .iter()
7519 .map(std::rc::Rc::<[u8]>::from)
7520 .collect();
7521 let via_method: Vec<std::rc::Rc<[u8]>> = CaixaDialeto::ALL
7522 .iter()
7523 .map(|d| std::rc::Rc::<[u8]>::from(d.as_str().as_bytes()))
7524 .collect();
7525 for (i, &variant) in CaixaDialeto::ALL.iter().enumerate() {
7526 assert_eq!(
7527 via_iter[i].as_ref(),
7528 via_method[i].as_ref(),
7529 "`.iter().map(std::rc::Rc::<[u8]>::from)` over \
7530 CaixaDialeto::ALL must byte-equal the open-coded per-\
7531 arm composition on CaixaDialeto::{variant:?} — the \
7532 borrowed-input axis is what makes the `Rc::from` \
7533 composition route through the substrate-primitive \
7534 CaixaDialeto::as_str accessor without a spurious \
7535 `.copied()` restatement"
7536 );
7537 }
7538 }
7539
7540 #[test]
7541 fn caixa_dialeto_try_from_bytes_routes_through_from_wire_accessor() {
7542 // Fail-before-pass-after byte-parity pin on the newly lifted
7543 // `impl TryFrom<&[u8]> for CaixaDialeto` — asserts the trait-
7544 // idiomatic byte-view reverse-projection standard-library impl
7545 // and the substrate-primitive [`super::CaixaDialeto::from_wire`]
7546 // `Option<Self>` accessor resolve to the same four-arm
7547 // `PascalCase` wire accept-set across every arm the exhaustive
7548 // [`super::CaixaDialeto::ALL`] slice enumerates. Extends the
7549 // substrate-wide trait-idiomatic byte-view reverse-projection
7550 // axis onto the second caixa-core-internal closed-set fieldless
7551 // typed enum peer — mirror of the paired
7552 // [`TryFrom<&str> for CaixaDialeto`] str-view reverse-projection
7553 // axis on the same enum, and the byte-view companion of the
7554 // pre-existing byte-owned reverse-projection family
7555 // ([`AsRef<[u8]>`], [`From<CaixaDialeto> for Vec<u8>`],
7556 // [`From<&CaixaDialeto> for Vec<u8>`]) on this same enum. Peer
7557 // of the sibling
7558 // [`crate::kind::tests::caixa_kind_try_from_bytes_routes_through_from_wire_accessor`]
7559 // (18d1940) on the first-mover [`crate::CaixaKind`] closed-set
7560 // typed-enum peer — tracks the "route through `from_wire` via
7561 // `std::str::from_utf8`" discipline the first-mover established.
7562 //
7563 // Rust's standard library carries no blanket
7564 // `impl<T: for<'a> TryFrom<&'a str>> TryFrom<&[u8]> for T`, so
7565 // a two-hop composition through [`std::str::from_utf8`] + the
7566 // paired [`TryFrom<&str>`] axis is reachable through the pre-
7567 // existing str-view reverse-projection axis alone. But that
7568 // two-hop shape has no compile-time link back to the byte-view
7569 // reverse-projection axis, forces every downstream
7570 // `<T: for<'a> TryFrom<&'a [u8]>>`-bound consumer to open-code
7571 // the composition at every call site, and admits a silent split
7572 // whenever a future call site takes a sibling byte-projection
7573 // axis whose parse arm-set carries no compile-time byte-view
7574 // surface. This impl closes the byte-view reverse-projection
7575 // axis at the substrate-primitive
7576 // [`super::CaixaDialeto::from_wire`] accessor so every future
7577 // `<T: for<'a> TryFrom<&'a [u8]>>`-bound consumer reaches the
7578 // same four-arm `PascalCase` wire accept-set through one trait
7579 // dispatch.
7580 for &variant in CaixaDialeto::ALL {
7581 let wire_bytes: &[u8] = variant.as_str().as_bytes();
7582 assert_eq!(
7583 <CaixaDialeto as TryFrom<&[u8]>>::try_from(wire_bytes),
7584 Ok(variant),
7585 "TryFrom<&[u8]> impl on CaixaDialeto must round-trip \
7586 CaixaDialeto::{variant:?}.as_str().as_bytes() back to \
7587 Ok(CaixaDialeto::{variant:?}) — divergence from \
7588 CaixaDialeto::from_wire signals a silent detour off \
7589 the substrate-primitive accessor"
7590 );
7591 assert_eq!(
7592 <CaixaDialeto as TryFrom<&[u8]>>::try_from(wire_bytes).ok(),
7593 CaixaDialeto::from_wire(variant.as_str()),
7594 "TryFrom<&[u8]> ok()-projection on \
7595 CaixaDialeto::{variant:?}.as_str().as_bytes() must \
7596 byte-equal CaixaDialeto::from_wire on the paired &str \
7597 input"
7598 );
7599 // Cross-axis witness: the byte-view reverse-projection axis
7600 // must agree with the paired str-view reverse-projection
7601 // axis ([`TryFrom<&str>`]) on every accepted arm — the two
7602 // reverse paths share one `PascalCase` accept-set through
7603 // the substrate-primitive `from_wire` accessor.
7604 let via_str: Result<CaixaDialeto, ()> =
7605 <CaixaDialeto as TryFrom<&str>>::try_from(variant.as_str());
7606 let via_bytes: Result<CaixaDialeto, ()> =
7607 <CaixaDialeto as TryFrom<&[u8]>>::try_from(wire_bytes);
7608 assert_eq!(
7609 via_bytes, via_str,
7610 "TryFrom<&[u8]> and TryFrom<&str> reverse-projection \
7611 axes on CaixaDialeto must agree on \
7612 CaixaDialeto::{variant:?} — divergence signals the \
7613 byte-view and str-view reverse paths have drifted off \
7614 the same substrate-primitive from_wire accessor"
7615 );
7616 }
7617 }
7618
7619 #[test]
7620 fn caixa_dialeto_try_from_bytes_rejects_unknown_and_non_utf8_bytes() {
7621 // Rejection witness on the `impl TryFrom<&[u8]> for CaixaDialeto`
7622 // — sweeps two rejection paths the byte-view reverse-projection
7623 // axis collapses onto the single unit-error `Err(())` return:
7624 // the invalid-UTF-8 rejection path ([`std::str::from_utf8`]
7625 // returns `Err` before [`super::CaixaDialeto::from_wire`] runs)
7626 // and the valid-UTF-8-but-unknown-wire rejection path
7627 // ([`super::CaixaDialeto::from_wire`] returns `None` on a byte-
7628 // string outside the four-arm `PascalCase` accept-set). Both
7629 // must reject, so a future accidental widening of the trait
7630 // impl's accept-set (a case-fold path, a silent acceptance of
7631 // the sibling [`super::CaixaDialeto::palavra_canonica`]
7632 // `"defcaixa"` / `"defmolde"` byte-shapes on this axis, a
7633 // `#[serde(rename_all = "…")]` attribute drift that widens the
7634 // parse arm-set silently, a stray fallback that maps invalid
7635 // UTF-8 onto a default arm rather than the trait-idiomatic
7636 // `Err(())`) trips at caixa-core test time. Peer of the sibling
7637 // [`crate::kind::tests::caixa_kind_try_from_bytes_rejects_unknown_and_non_utf8_bytes`]
7638 // (18d1940) on the first-mover [`crate::CaixaKind`] closed-set
7639 // typed-enum peer.
7640 //
7641 // Non-UTF-8 candidates:
7642 // - a lone 0xFF byte (never valid as a UTF-8 leading byte)
7643 // - a lone 0x80 continuation byte with no leading byte
7644 // - a truncated multi-byte sequence (0xC3 without its continuation)
7645 // - a UTF-16 BOM-style byte pair the UTF-8 validator rejects
7646 // - a UTF-16 surrogate half rejected by UTF-8
7647 let non_utf8_rejected: &[&[u8]] = &[
7648 &[0xFF],
7649 &[0x80],
7650 &[0xC3],
7651 &[0xFF, 0xFE],
7652 &[0xED, 0xA0, 0x80],
7653 ];
7654 for &input in non_utf8_rejected {
7655 assert_eq!(
7656 <CaixaDialeto as TryFrom<&[u8]>>::try_from(input),
7657 Err(()),
7658 "TryFrom<&[u8]> impl on CaixaDialeto must reject the \
7659 non-UTF-8 byte-sequence {input:?} with Err(()) — \
7660 silent acceptance signals the UTF-8 validation path \
7661 collapsed onto a default arm rather than the trait-\
7662 idiomatic unit-error"
7663 );
7664 }
7665 // Valid-UTF-8-but-unknown-wire candidates: the empty byte-
7666 // string, case-folded variants of accepted arms, plausible
7667 // typos, the sibling [`super::CaixaDialeto::palavra_canonica`]
7668 // / [`super::CaixaDialeto::consumidor`] byte-shapes (a caller
7669 // who confuses those distinct axes with the census-facing wire
7670 // axis trips here), and whitespace-padded / quoted forms.
7671 let unknown_wire_rejected: &[&[u8]] = &[
7672 b"",
7673 b" ",
7674 b"pacote",
7675 b"PACOTE",
7676 b"molde",
7677 b"MoldePositional",
7678 b"desconhecido",
7679 b"Unknown",
7680 b"defcaixa",
7681 b"defmolde",
7682 b"?",
7683 b"caixa-core / feira",
7684 b"pleme-doc-gen",
7685 b"nobody known",
7686 b"Pacote ",
7687 b" Pacote",
7688 b"Pacote\n",
7689 b"\"Pacote\"",
7690 ];
7691 for &input in unknown_wire_rejected {
7692 assert_eq!(
7693 <CaixaDialeto as TryFrom<&[u8]>>::try_from(input),
7694 Err(()),
7695 "TryFrom<&[u8]> impl on CaixaDialeto must reject the \
7696 valid-UTF-8-but-unknown-wire byte-string {input:?} \
7697 with Err(()) — silent acceptance signals an accept-\
7698 set widening off the paired CaixaDialeto::from_wire \
7699 resolver"
7700 );
7701 // Cross-axis witness: on a byte-string that is valid UTF-8,
7702 // the byte-view reverse-projection axis must agree with the
7703 // paired str-view reverse-projection axis
7704 // ([`TryFrom<&str>`]) — both route through the same
7705 // [`super::CaixaDialeto::from_wire`] resolver, so the two
7706 // rejection paths align by construction.
7707 if let Ok(s) = std::str::from_utf8(input) {
7708 assert_eq!(
7709 <CaixaDialeto as TryFrom<&[u8]>>::try_from(input),
7710 <CaixaDialeto as TryFrom<&str>>::try_from(s),
7711 "TryFrom<&[u8]> and TryFrom<&str> reverse-\
7712 projection axes on CaixaDialeto must agree on the \
7713 valid-UTF-8 input {input:?} — divergence signals \
7714 the two reverse paths have drifted off the same \
7715 substrate-primitive from_wire accessor"
7716 );
7717 }
7718 }
7719 }
7720
7721 #[test]
7722 fn caixa_dialeto_try_from_vec_bytes_routes_through_borrowed_byte_view_axis() {
7723 // Fail-before-pass-after byte-parity pin on the newly lifted
7724 // `impl TryFrom<Vec<u8>> for CaixaDialeto` — asserts the trait-
7725 // idiomatic owned-byte-vec reverse-projection standard-library
7726 // impl and the sibling borrowed-input [`TryFrom<&[u8]>`] axis
7727 // resolve to the same four-arm `PascalCase` wire accept-set
7728 // across every arm the exhaustive [`super::CaixaDialeto::ALL`]
7729 // slice enumerates. Extends the substrate-wide trait-idiomatic
7730 // byte-owned reverse-projection axis onto the second caixa-
7731 // core-internal closed-set fieldless typed enum peer — owned-
7732 // input mirror of the paired [`TryFrom<&[u8]>`] byte-view
7733 // reverse-projection axis (d102cb8), and byte-owned reverse
7734 // companion of the pre-existing byte-owned *forward*-projection
7735 // pair ([`From<CaixaDialeto> for Vec<u8>`], [`From<&CaixaDialeto>
7736 // for Vec<u8>`]) on this same enum. Peer of the sibling
7737 // first-mover
7738 // [`crate::kind::tests::caixa_kind_try_from_vec_bytes_routes_through_borrowed_byte_view_axis`]
7739 // (99c2849) on the [`crate::CaixaKind`] closed-set typed-enum
7740 // peer — tracks the "delegate through `TryFrom<&[u8]>` on the
7741 // `Vec<u8>::as_slice` borrow" discipline the first-mover
7742 // established.
7743 //
7744 // Rust's standard library carries no blanket
7745 // `impl<T: for<'a> TryFrom<&'a [u8]>> TryFrom<Vec<u8>> for T`,
7746 // so an owned-byte-vec caller otherwise picks between an
7747 // open-coded `<T as TryFrom<&[u8]>>::try_from(bytes.as_slice())`
7748 // at every call site whose type bounds have no compile-time
7749 // link back to the byte-owned reverse-projection axis, or a
7750 // `String::from_utf8(bytes)` two-hop shape whose error surface
7751 // leaks the standard-library `FromUtf8Error` type. This impl
7752 // closes the byte-owned reverse-projection axis at the
7753 // substrate-primitive [`super::CaixaDialeto::from_wire`]
7754 // accessor so every future `<T: TryFrom<Vec<u8>>>`-bound owned-
7755 // byte-vec consumer reaches the same four-arm `PascalCase` wire
7756 // accept-set through one trait dispatch.
7757 for &variant in CaixaDialeto::ALL {
7758 let wire_bytes: Vec<u8> = variant.as_str().as_bytes().to_vec();
7759 assert_eq!(
7760 <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(wire_bytes.clone()),
7761 Ok(variant),
7762 "TryFrom<Vec<u8>> impl on CaixaDialeto must round-trip \
7763 CaixaDialeto::{variant:?}.as_str().as_bytes().to_vec() \
7764 back to Ok(CaixaDialeto::{variant:?}) — divergence from \
7765 the sibling TryFrom<&[u8]> axis signals a silent detour \
7766 off the substrate-primitive from_wire accessor"
7767 );
7768 // Cross-axis witness: the owned-byte-vec reverse-projection
7769 // axis must agree with the borrowed byte-slice reverse-
7770 // projection axis on every accepted arm — the two axes
7771 // share one `PascalCase` wire vocabulary through the
7772 // substrate-primitive `from_wire` accessor, and the owned-
7773 // input axis delegates to the borrowed peer by design.
7774 let via_owned: Result<CaixaDialeto, ()> =
7775 <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(wire_bytes.clone());
7776 let via_borrowed: Result<CaixaDialeto, ()> =
7777 <CaixaDialeto as TryFrom<&[u8]>>::try_from(wire_bytes.as_slice());
7778 assert_eq!(
7779 via_owned, via_borrowed,
7780 "TryFrom<Vec<u8>> and TryFrom<&[u8]> reverse-projection \
7781 axes on CaixaDialeto must agree on \
7782 CaixaDialeto::{variant:?} — divergence signals the \
7783 owned-input and borrowed-input byte-view reverse \
7784 paths have drifted off the same substrate-primitive \
7785 from_wire accessor"
7786 );
7787 // Cross-axis witness against the paired str-view reverse
7788 // axis ([`TryFrom<&str>`]) — the three reverse paths (str-
7789 // view, byte-view borrowed, byte-view owned) share one
7790 // substrate primitive.
7791 let via_str: Result<CaixaDialeto, ()> =
7792 <CaixaDialeto as TryFrom<&str>>::try_from(variant.as_str());
7793 assert_eq!(
7794 via_owned, via_str,
7795 "TryFrom<Vec<u8>> and TryFrom<&str> reverse-projection \
7796 axes on CaixaDialeto must agree on \
7797 CaixaDialeto::{variant:?} — divergence signals the \
7798 byte-owned and str-view reverse paths have drifted \
7799 off the same substrate-primitive from_wire accessor"
7800 );
7801 // Four-corner witness: because [`CaixaDialeto`] carries no
7802 // wire-vs-diagnostic split (as_str and from_wire share one
7803 // `PascalCase` byte-vocabulary), the byte-owned reverse-
7804 // projection axis on this enum *does* round-trip against
7805 // the paired byte-owned forward-projection pair. Pin every
7806 // corner of the {owned-input, borrowed-input} ×
7807 // {From<Self> → Vec<u8>, From<&Self> → Vec<u8>} square onto
7808 // the same Ok(variant) return so a future accident that
7809 // drops one corner off the substrate-primitive accessor
7810 // trips here.
7811 let owned_forward: Vec<u8> = <Vec<u8> as From<CaixaDialeto>>::from(variant);
7812 let borrowed_forward: Vec<u8> = <Vec<u8> as From<&CaixaDialeto>>::from(&variant);
7813 assert_eq!(
7814 owned_forward, wire_bytes,
7815 "From<CaixaDialeto> for Vec<u8> forward projection on \
7816 CaixaDialeto::{variant:?} must byte-equal \
7817 variant.as_str().as_bytes().to_vec() — divergence \
7818 signals the paired forward pair drifted off the \
7819 substrate-primitive as_str accessor"
7820 );
7821 assert_eq!(
7822 borrowed_forward, wire_bytes,
7823 "From<&CaixaDialeto> for Vec<u8> forward projection on \
7824 &CaixaDialeto::{variant:?} must byte-equal \
7825 variant.as_str().as_bytes().to_vec() — divergence \
7826 signals the paired forward pair drifted off the \
7827 substrate-primitive as_str accessor"
7828 );
7829 assert_eq!(
7830 <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(owned_forward.clone()),
7831 Ok(variant),
7832 "Four-corner round-trip on CaixaDialeto::{variant:?} \
7833 through From<CaixaDialeto> for Vec<u8> then \
7834 TryFrom<Vec<u8>> for CaixaDialeto must return \
7835 Ok(variant) — divergence signals the byte-owned \
7836 forward pair and the byte-owned reverse axis have \
7837 drifted apart"
7838 );
7839 assert_eq!(
7840 <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(borrowed_forward),
7841 Ok(variant),
7842 "Four-corner round-trip on CaixaDialeto::{variant:?} \
7843 through From<&CaixaDialeto> for Vec<u8> then \
7844 TryFrom<Vec<u8>> for CaixaDialeto must return \
7845 Ok(variant) — divergence signals the borrowed-input \
7846 forward corner and the owned-input reverse corner \
7847 have drifted apart"
7848 );
7849 }
7850 }
7851
7852 #[test]
7853 fn caixa_dialeto_try_from_vec_bytes_rejects_unknown_and_non_utf8_bytes() {
7854 // Rejection witness on the `impl TryFrom<Vec<u8>> for CaixaDialeto`
7855 // — sweeps the same two rejection paths the sibling borrowed
7856 // `TryFrom<&[u8]>` axis collapses onto the single unit-error
7857 // return: the invalid-UTF-8 rejection path (`std::str::from_utf8`
7858 // on the underlying byte-slice returns `Err` before
7859 // [`super::CaixaDialeto::from_wire`] runs) and the valid-UTF-8-
7860 // but-unknown-wire rejection path
7861 // ([`super::CaixaDialeto::from_wire`] returns `None` on a byte-
7862 // string outside the four-arm `PascalCase` accept-set). Both
7863 // must reject so a future accidental widening of the trait
7864 // impl's accept-set (a case-fold path, a silent acceptance of
7865 // the sibling [`super::CaixaDialeto::palavra_canonica`]
7866 // `"defcaixa"` / `"defmolde"` byte-shapes on this axis, a
7867 // `#[serde(rename_all = "…")]` attribute drift that widens the
7868 // parse arm-set silently, a stray `String::from_utf8_lossy`
7869 // detour that widens the input surface with the U+FFFD
7870 // replacement character, an `Option::unwrap_or_default`-shape
7871 // fallback that maps invalid UTF-8 onto a default arm rather
7872 // than the trait-idiomatic `Err(())`) trips at caixa-core test
7873 // time. Peer of the sibling first-mover
7874 // [`crate::kind::tests::caixa_kind_try_from_vec_bytes_rejects_unknown_and_non_utf8_bytes`]
7875 // (99c2849) on the [`crate::CaixaKind`] closed-set typed-enum
7876 // peer.
7877 let non_utf8_rejected: &[&[u8]] = &[
7878 &[0xFF],
7879 &[0x80],
7880 &[0xC3],
7881 &[0xFF, 0xFE],
7882 &[0xED, 0xA0, 0x80], // UTF-16 surrogate half — rejected by UTF-8
7883 ];
7884 for &input in non_utf8_rejected {
7885 let owned: Vec<u8> = input.to_vec();
7886 assert_eq!(
7887 <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(owned),
7888 Err(()),
7889 "TryFrom<Vec<u8>> impl on CaixaDialeto must reject the \
7890 non-UTF-8 byte-sequence {input:?} with Err(()) — \
7891 silent acceptance signals the UTF-8 validation path \
7892 collapsed onto a default arm rather than the trait-\
7893 idiomatic unit-error"
7894 );
7895 // Cross-axis witness: the owned-input axis must agree with
7896 // the borrowed-input axis on every rejected input.
7897 assert_eq!(
7898 <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(input.to_vec()),
7899 <CaixaDialeto as TryFrom<&[u8]>>::try_from(input),
7900 "TryFrom<Vec<u8>> and TryFrom<&[u8]> reverse-projection \
7901 axes on CaixaDialeto must agree on the non-UTF-8 \
7902 input {input:?} — divergence signals the owned-input \
7903 and borrowed-input byte-view reverse paths have \
7904 drifted off the same substrate-primitive from_wire \
7905 accessor"
7906 );
7907 }
7908 // Valid-UTF-8-but-unknown-wire candidates: the empty byte-
7909 // string, case-folded variants of accepted arms, plausible
7910 // typos, the sibling [`super::CaixaDialeto::palavra_canonica`]
7911 // / [`super::CaixaDialeto::consumidor`] byte-shapes (a caller
7912 // who confuses those distinct axes with the census-facing wire
7913 // axis trips here), and whitespace-padded / quoted forms.
7914 let unknown_wire_rejected: &[&[u8]] = &[
7915 b"",
7916 b" ",
7917 b"pacote",
7918 b"PACOTE",
7919 b"molde",
7920 b"MoldePositional",
7921 b"desconhecido",
7922 b"Unknown",
7923 b"defcaixa",
7924 b"defmolde",
7925 b"?",
7926 b"caixa-core / feira",
7927 b"pleme-doc-gen",
7928 b"nobody known",
7929 b"Pacote ",
7930 b" Pacote",
7931 b"Pacote\n",
7932 b"\"Pacote\"",
7933 ];
7934 for &input in unknown_wire_rejected {
7935 let owned: Vec<u8> = input.to_vec();
7936 assert_eq!(
7937 <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(owned),
7938 Err(()),
7939 "TryFrom<Vec<u8>> impl on CaixaDialeto must reject the \
7940 valid-UTF-8-but-unknown-wire byte-string {input:?} \
7941 with Err(()) — silent acceptance signals an accept-\
7942 set widening off the paired CaixaDialeto::from_wire \
7943 resolver"
7944 );
7945 // Cross-axis witness against the borrowed byte-view axis:
7946 // the two paths must agree by construction, since the owned
7947 // axis delegates to the borrowed peer.
7948 assert_eq!(
7949 <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(input.to_vec()),
7950 <CaixaDialeto as TryFrom<&[u8]>>::try_from(input),
7951 "TryFrom<Vec<u8>> and TryFrom<&[u8]> reverse-projection \
7952 axes on CaixaDialeto must agree on the valid-UTF-8-\
7953 but-unknown-wire input {input:?} — divergence signals \
7954 the owned-input and borrowed-input byte-view reverse \
7955 paths have drifted off the same substrate-primitive \
7956 from_wire accessor"
7957 );
7958 }
7959 }
7960
7961 #[test]
7962 fn caixa_dialeto_try_from_owned_string_routes_through_borrowed_str_view_axis() {
7963 // Fail-before-pass-after byte-parity pin on the newly lifted
7964 // `impl TryFrom<String> for CaixaDialeto` — asserts the trait-
7965 // idiomatic string-owned reverse-projection standard-library
7966 // impl and the sibling borrowed-input [`TryFrom<&str>`] axis
7967 // resolve to the same four-arm `PascalCase` wire accept-set
7968 // across every arm the exhaustive [`super::CaixaDialeto::ALL`]
7969 // slice enumerates. Extends the substrate-wide trait-idiomatic
7970 // string-owned reverse-projection axis onto the second caixa-
7971 // core-internal closed-set fieldless typed-enum peer — owned-
7972 // input mirror of the paired [`TryFrom<&str>`] str-view
7973 // reverse-projection axis, and string-owned reverse companion
7974 // of the pre-existing string-owned *forward*-projection pair
7975 // ([`From<CaixaDialeto> for String`] / [`From<&CaixaDialeto>
7976 // for String`]) on this same enum. Peer of the sibling
7977 // first-mover
7978 // [`crate::aplicacao::tests::rate_limit_try_from_owned_string_routes_through_borrowed_str_view_axis`]
7979 // (a2e6f02) on the compound [`crate::aplicacao::RateLimit`]
7980 // primitive, and the sibling
7981 // `caixa_kind_try_from_owned_string_routes_through_borrowed_str_view_axis`
7982 // (e7df24f) on the [`crate::CaixaKind`] closed-set typed-enum
7983 // peer — tracks the "delegate through `TryFrom<&str>` on the
7984 // `String::as_str` borrow" discipline the compound-primitive
7985 // opener and closed-set-peer first-mover established. This
7986 // closes the string-owned reverse-projection axis on the second
7987 // caixa-core-internal closed-set fieldless typed-enum peer,
7988 // mirroring the trajectory the byte-view (d102cb8) / byte-
7989 // owned (83a1526) / str-view reverse-projection families
7990 // already walked on this same enum.
7991 for &variant in CaixaDialeto::ALL {
7992 let wire_string: String = variant.as_str().to_string();
7993 assert_eq!(
7994 <CaixaDialeto as TryFrom<String>>::try_from(wire_string.clone()),
7995 Ok(variant),
7996 "TryFrom<String> impl on CaixaDialeto must round-trip \
7997 CaixaDialeto::{variant:?}.as_str().to_string() back \
7998 to Ok(CaixaDialeto::{variant:?}) — divergence from \
7999 the sibling TryFrom<&str> axis signals a silent detour \
8000 off the substrate-primitive from_wire accessor"
8001 );
8002 // Cross-axis witness: the string-owned reverse-projection
8003 // axis must agree with the borrowed `&str` reverse-projection
8004 // axis on every accepted arm — the two axes share one
8005 // `PascalCase` wire vocabulary through the substrate-
8006 // primitive `from_wire` accessor, and the owned-input axis
8007 // delegates to the borrowed peer by design.
8008 let via_owned: Result<CaixaDialeto, ()> =
8009 <CaixaDialeto as TryFrom<String>>::try_from(wire_string.clone());
8010 let via_borrowed: Result<CaixaDialeto, ()> =
8011 <CaixaDialeto as TryFrom<&str>>::try_from(wire_string.as_str());
8012 assert_eq!(
8013 via_owned, via_borrowed,
8014 "TryFrom<String> and TryFrom<&str> reverse-projection \
8015 axes on CaixaDialeto must agree on \
8016 CaixaDialeto::{variant:?} — divergence signals the \
8017 owned-`String` and borrowed-`&str` reverse paths have \
8018 drifted off the same substrate-primitive from_wire \
8019 accessor"
8020 );
8021 // Cross-axis witness against the paired byte-view reverse-
8022 // projection axis ([`TryFrom<&[u8]>`]) — the four reverse
8023 // paths share one substrate primitive.
8024 let via_byte_slice: Result<CaixaDialeto, ()> =
8025 <CaixaDialeto as TryFrom<&[u8]>>::try_from(wire_string.as_bytes());
8026 assert_eq!(
8027 via_owned, via_byte_slice,
8028 "TryFrom<String> and TryFrom<&[u8]> reverse-projection \
8029 axes on CaixaDialeto must agree on \
8030 CaixaDialeto::{variant:?} — divergence signals the \
8031 string-owned and byte-view borrowed reverse paths \
8032 have drifted off the same substrate-primitive \
8033 from_wire accessor"
8034 );
8035 // Cross-axis witness against the sibling byte-owned
8036 // reverse-projection axis ([`TryFrom<Vec<u8>>`]) — the
8037 // two owned-input axes share one `PascalCase` wire
8038 // vocabulary.
8039 let via_byte_vec: Result<CaixaDialeto, ()> =
8040 <CaixaDialeto as TryFrom<Vec<u8>>>::try_from(wire_string.as_bytes().to_vec());
8041 assert_eq!(
8042 via_owned, via_byte_vec,
8043 "TryFrom<String> and TryFrom<Vec<u8>> reverse-\
8044 projection axes on CaixaDialeto must agree on \
8045 CaixaDialeto::{variant:?} — divergence signals the \
8046 string-owned and byte-owned reverse paths have \
8047 drifted off the same substrate-primitive from_wire \
8048 accessor"
8049 );
8050 // Four-corner witness: because [`CaixaDialeto`] carries no
8051 // wire-vs-diagnostic split (as_str and from_wire share one
8052 // `PascalCase` byte-vocabulary), the string-owned reverse-
8053 // projection axis on this enum *does* round-trip against
8054 // the paired string-owned forward-projection pair. Pin
8055 // every corner of the {owned-input, borrowed-input} ×
8056 // {`From<Self> → String`, `From<&Self> → String`} square
8057 // onto the same Ok(variant) return so a future accident
8058 // that drops one corner off the substrate-primitive
8059 // accessor trips here. Mirror of the peer four-corner
8060 // witness the sibling
8061 // [`caixa_dialeto_try_from_vec_bytes_routes_through_borrowed_byte_view_axis`]
8062 // (83a1526) pins on the byte-owned reverse axis.
8063 let owned_forward: String = <String as From<CaixaDialeto>>::from(variant);
8064 let borrowed_forward: String = <String as From<&CaixaDialeto>>::from(&variant);
8065 assert_eq!(
8066 owned_forward, wire_string,
8067 "From<CaixaDialeto> for String forward projection on \
8068 CaixaDialeto::{variant:?} must byte-equal \
8069 variant.as_str().to_string() — divergence signals \
8070 the paired forward pair drifted off the substrate-\
8071 primitive as_str accessor"
8072 );
8073 assert_eq!(
8074 borrowed_forward, wire_string,
8075 "From<&CaixaDialeto> for String forward projection on \
8076 &CaixaDialeto::{variant:?} must byte-equal \
8077 variant.as_str().to_string() — divergence signals \
8078 the paired forward pair drifted off the substrate-\
8079 primitive as_str accessor"
8080 );
8081 assert_eq!(
8082 <CaixaDialeto as TryFrom<String>>::try_from(owned_forward.clone()),
8083 Ok(variant),
8084 "Four-corner round-trip on CaixaDialeto::{variant:?} \
8085 through From<CaixaDialeto> for String then \
8086 TryFrom<String> for CaixaDialeto must return \
8087 Ok(variant) — divergence signals the string-owned \
8088 forward pair and the string-owned reverse axis have \
8089 drifted apart"
8090 );
8091 assert_eq!(
8092 <CaixaDialeto as TryFrom<String>>::try_from(borrowed_forward),
8093 Ok(variant),
8094 "Four-corner round-trip on CaixaDialeto::{variant:?} \
8095 through From<&CaixaDialeto> for String then \
8096 TryFrom<String> for CaixaDialeto must return \
8097 Ok(variant) — divergence signals the borrowed-input \
8098 forward corner and the owned-input reverse corner \
8099 have drifted apart"
8100 );
8101 }
8102 }
8103
8104 #[test]
8105 fn caixa_dialeto_try_from_owned_string_rejects_unknown_wire_strings() {
8106 // Rejection witness on the `impl TryFrom<String> for CaixaDialeto`
8107 // — mirrors the rejection corpus the paired borrowed
8108 // [`TryFrom<&str>`] and owned [`TryFrom<Vec<u8>>`] axes already
8109 // pin on the owned-`String` surface. Every non-`PascalCase`-
8110 // wire byte-string must land on `Err(())` so a future
8111 // accidental widening of the trait impl's accept-set (a stray
8112 // `_ if s.eq_ignore_ascii_case("Pacote") => Ok(…)` case-fold
8113 // path, a silent acceptance of the sibling
8114 // [`super::CaixaDialeto::palavra_canonica`] / [`super::CaixaDialeto::consumidor`]
8115 // byte-shapes on this axis, an `Option::unwrap_or_default`-
8116 // shape fallback that maps unknown inputs onto a default arm
8117 // rather than the trait-idiomatic `Err(())`) trips at caixa-
8118 // core test time. Sweep includes the empty string, case-fold
8119 // variants of the four PascalCase arms, the sibling
8120 // [`super::CaixaDialeto::palavra_canonica`] /
8121 // [`super::CaixaDialeto::consumidor`] byte-shapes (a caller
8122 // who confuses those distinct axes with the census-facing wire
8123 // axis trips here), and whitespace-padded / trailing-newline /
8124 // quote-wrapped forms.
8125 let rejected: &[&str] = &[
8126 "",
8127 " ",
8128 "pacote",
8129 "PACOTE",
8130 "molde",
8131 "MOLDE",
8132 "moldeposicional",
8133 "MoldePositional",
8134 "desconhecido",
8135 "DESCONHECIDO",
8136 "Unknown",
8137 "defcaixa",
8138 "defmolde",
8139 "?",
8140 "caixa-core / feira",
8141 "pleme-doc-gen",
8142 "nobody known",
8143 " Pacote",
8144 "Pacote ",
8145 "Pacote\n",
8146 "\"Pacote\"",
8147 ];
8148 for &input in rejected {
8149 let owned: String = input.to_string();
8150 assert_eq!(
8151 <CaixaDialeto as TryFrom<String>>::try_from(owned),
8152 Err(()),
8153 "TryFrom<String> impl on CaixaDialeto must reject the \
8154 non-wire byte-string {input:?} with Err(()) — silent \
8155 acceptance signals an accept-set widening off the \
8156 paired CaixaDialeto::from_wire resolver"
8157 );
8158 // Cross-axis witness: the owned-`String` axis must agree
8159 // with the borrowed-`&str` axis on every rejected input —
8160 // the two paths share one substrate-primitive resolver by
8161 // construction.
8162 assert_eq!(
8163 <CaixaDialeto as TryFrom<String>>::try_from(input.to_string()),
8164 <CaixaDialeto as TryFrom<&str>>::try_from(input),
8165 "TryFrom<String> and TryFrom<&str> reverse-projection \
8166 axes on CaixaDialeto must agree on the non-wire input \
8167 {input:?} — divergence signals the owned-`String` and \
8168 borrowed-`&str` reverse paths have drifted off the \
8169 same substrate-primitive from_wire accessor"
8170 );
8171 }
8172 }
8173}