Skip to main content

caixa_theme/
style.rs

1//! The small semantic-style enum every caixa tool agrees on.
2
3use serde::{Deserialize, Serialize};
4
5#[derive(
6    Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, gen_platform::IsVariant,
7)]
8pub enum Semantic {
9    /// Language keywords — `defcaixa`, `defteia`, `let`, `lambda`, etc.
10    Keyword,
11    /// Non-keyword symbols — identifiers, function names, variant names.
12    Symbol,
13    /// `:keyword-positioned` atoms.
14    KeywordArg,
15    /// `"string literals"`.
16    String,
17    /// `42`, `3.14`.
18    Number,
19    /// `#t`, `#f`, `nil`.
20    Literal,
21    /// `; comments`.
22    Comment,
23    /// Primary accent — useful for highlights, carets, focused tokens.
24    Accent,
25    /// Dim text — metadata, line numbers, help text.
26    Muted,
27
28    // Diagnostic severities.
29    Error,
30    Warning,
31    Info,
32    Hint,
33
34    // Diff decorations — used by formatter preview and lint output.
35    Added,
36    Removed,
37    Unchanged,
38}
39
40impl Semantic {
41    /// Every variant of [`Semantic`] in declaration order.
42    ///
43    /// The single canonical arm-list every substrate consumer that has
44    /// to walk the closed 15-arm semantic-style partition (the two
45    /// theme overlays' exhaustive-match resolver functions
46    /// `blackmatter_dark_color` / `blackmatter_light_color` in
47    /// [`crate::blackmatter`], the future LSP-side per-Semantic
48    /// `SemanticTokenType` dispatch at
49    /// `caixa-lsp/src/main.rs`, a future
50    /// `feira lint --list-styles` operator-facing enumeration verb)
51    /// reads for. Peer of the sibling closed-set fieldless typed
52    /// enums' `ALL` slices already carried by
53    /// [`caixa_core::CaixaKind`] /
54    /// [`caixa_core::supervisor::RestartStrategy`] /
55    /// [`caixa_core::supervisor::RestartPolicy`] /
56    /// [`caixa_core::aplicacao::PlacementStrategy`] /
57    /// [`caixa_core::upgrade::UpgradeInstruction`] /
58    /// `caixa_lint::diagnostic::Severity` /
59    /// `caixa_lint::diagnostic::FixSafety` /
60    /// `caixa_arch::InvariantKind` / `caixa_arch::ArchVerdict` /
61    /// `caixa_provedor::FerriteRuntime` closed-set typed-enum
62    /// discriminator axes.
63    pub const ALL: &'static [Self] = &[
64        Self::Keyword,
65        Self::Symbol,
66        Self::KeywordArg,
67        Self::String,
68        Self::Number,
69        Self::Literal,
70        Self::Comment,
71        Self::Accent,
72        Self::Muted,
73        Self::Error,
74        Self::Warning,
75        Self::Info,
76        Self::Hint,
77        Self::Added,
78        Self::Removed,
79        Self::Unchanged,
80    ];
81
82    /// Canonical kebab-case discriminator scalar for this variant — the
83    /// single substrate-primitive `&'static str` projection every
84    /// downstream consumer of the closed 16-arm [`Semantic`] partition
85    /// (a future LSP-side per-Semantic `SemanticTokenType` name-mapping
86    /// dispatch at `caixa-lsp/src/main.rs`, a future
87    /// `feira lint --list-styles` operator-facing enumeration verb, a
88    /// future `caixa.nvim` per-Semantic highlight-group name resolver
89    /// that reaches for a stable kebab identifier per arm, a future
90    /// `blackmatter-shell` per-arm classname the terminal emitter
91    /// composes into a `data-semantic="<kebab>"` attribute) reaches
92    /// through. Kebab-case matches the peer
93    /// [`gen_platform::IsVariant`]-derived kebab discriminant convention
94    /// the sibling closed-set typed enums
95    /// ([`caixa_core::CaixaKind::as_str`],
96    /// [`caixa_core::supervisor::RestartStrategy::as_str`],
97    /// [`caixa_core::supervisor::RestartPolicy::as_str`],
98    /// [`caixa_core::aplicacao::PlacementStrategy::as_str`],
99    /// [`caixa_core::upgrade::UpgradeInstruction::as_str`],
100    /// `caixa_lint::diagnostic::Severity::as_str`,
101    /// `caixa_lint::diagnostic::FixSafety::as_str`,
102    /// `caixa_arch::InvariantKind::as_str`,
103    /// `caixa_arch::ArchVerdict::as_str`,
104    /// `caixa_provedor::FerriteRuntime::variant_slug`) already emit
105    /// on their canonical `&'static str` projection axis.
106    ///
107    /// The 16 arms return the kebab-case forms of their `PascalCase`
108    /// variant names (`Keyword` → `"keyword"`, `KeywordArg` →
109    /// `"keyword-arg"`, `Unchanged` → `"unchanged"`, etc.), matching
110    /// the peer closed-set typed-enum canonical byte-string conventions.
111    ///
112    /// Peer of the [`std::fmt::Display`] and [`AsRef<str>`] impls on
113    /// this enum, which both route through this accessor so
114    /// `format!("{s}")`, `s.as_str()`, and
115    /// `<Semantic as AsRef<str>>::as_ref(&s)` resolve to the same
116    /// per-arm byte-string.
117    #[must_use]
118    pub const fn as_str(self) -> &'static str {
119        match self {
120            Self::Keyword => "keyword",
121            Self::Symbol => "symbol",
122            Self::KeywordArg => "keyword-arg",
123            Self::String => "string",
124            Self::Number => "number",
125            Self::Literal => "literal",
126            Self::Comment => "comment",
127            Self::Accent => "accent",
128            Self::Muted => "muted",
129            Self::Error => "error",
130            Self::Warning => "warning",
131            Self::Info => "info",
132            Self::Hint => "hint",
133            Self::Added => "added",
134            Self::Removed => "removed",
135            Self::Unchanged => "unchanged",
136        }
137    }
138
139    /// Reverse projection on the [`Semantic`] closed 16-arm enum's
140    /// canonical kebab-tag axis — parses a `"keyword"` / `"symbol"` /
141    /// `"keyword-arg"` / `"string"` / `"number"` / `"literal"` /
142    /// `"comment"` / `"accent"` / `"muted"` / `"error"` / `"warning"` /
143    /// `"info"` / `"hint"` / `"added"` / `"removed"` / `"unchanged"` wire
144    /// byte-string back to the typed enum, or returns `None` when `s`
145    /// lies outside the 16-arm accept-set [`Self::as_str`] emits. The
146    /// single `&str → Self` projection every future re-entry point on
147    /// the caixa-theme semantic-style axis dispatches through (a future
148    /// `feira lint --list-styles` operator-facing enumeration verb
149    /// hydrating a per-arm row from a stored kebab identifier back to
150    /// the typed enum before rendering, a future `caixa-lsp`-side
151    /// per-`SemanticTokenType` re-parse binding a prior
152    /// [`Self::as_str`] output back to the typed enum for
153    /// per-Semantic-highlight dispatch, a future `caixa.nvim` per-
154    /// Semantic highlight-group resolver re-loading a stored kebab
155    /// identifier back to the typed enum, a future `blackmatter-shell`
156    /// per-arm classname reverse-lookup binding a
157    /// `data-semantic="<kebab>"` DOM attribute back to the typed enum
158    /// for per-arm style dispatch, a `tracing::field::Value::Str`-arm
159    /// structured-log re-loader binding a prior emission's
160    /// [`Self::as_str`] output back to the typed enum for cross-run
161    /// per-Semantic-paint-histogram diff) would have had to re-inline a
162    /// 16-arm `match s` cascade that expressed no compile-time link back
163    /// to the substrate primitive.
164    ///
165    /// Same closed-set-reverse-projection discipline the sibling
166    /// [`caixa_core::CaixaKind::from_wire`] (2aa6d23),
167    /// [`caixa_core::CaixaDialeto::from_wire`] (d0e65ea),
168    /// [`caixa_core::supervisor::RestartStrategy::from_wire`] (4eec29c),
169    /// [`caixa_core::supervisor::RestartPolicy::from_wire`] (dd32ccf),
170    /// [`caixa_core::aplicacao::PlacementStrategy::from_wire`] (18c7342),
171    /// [`caixa_core::dep::DepList::from_wire`] (45ee563),
172    /// [`caixa_core::render::PathShapeViolation::from_wire`] (aebd9c6),
173    /// `caixa_arch::invariants::InvariantKind::from_wire` (b9e4e61),
174    /// `caixa_arch::report::ArchVerdict::from_wire` (6afe564),
175    /// `caixa_lint::diagnostic::Severity::from_wire` (5afff0e), and
176    /// `caixa_lint::diagnostic::FixSafety::from_wire` (bd505a1) typed
177    /// enums carry on the peer wire-side `str → Self` axes — extends
178    /// the substrate-wide `(as_str, from_wire)` round-trip family onto
179    /// the caixa-theme closed-set fieldless typed-enum axis (the first
180    /// closed-set fieldless typed enum on `caixa-theme` to converge on
181    /// the reverse-projection discipline), matching the same two-way
182    /// `str ↔ Self` round-trip every sibling closed-set enum already
183    /// carries. Method-named `from_wire` (not `from_str`) to match the
184    /// peer shapes verbatim and side-step a
185    /// `clippy::should_implement_trait` lint that a plain `from_str`
186    /// name would otherwise trigger without paired
187    /// [`std::str::FromStr`] impl scaffolding this axis does not carry
188    /// today. Returns `Option<Self>` (rather than `Result<Self, _>`) to
189    /// match the peer shapes: the caller picks the diagnostic form
190    /// appropriate for its use site (a `feira lint --list-styles` CLI
191    /// arg-parse renders its own per-verb error message; a future
192    /// admission-webhook rejection body wraps the `None` outcome with
193    /// the accepted-set enumeration `Semantic::ALL.iter().map(…)` for
194    /// operator diagnostics).
195    ///
196    /// Pinned load-bearing at the substrate-primitive level by
197    /// [`tests::semantic_from_wire_accepts_every_as_str_output`]
198    /// (round-trip witness against the peer [`Self::as_str`] axis) and
199    /// [`tests::semantic_from_wire_rejects_unknown_byte_strings`]
200    /// (rejection witness against silent accept-set widening).
201    #[must_use]
202    pub fn from_wire(s: &str) -> Option<Self> {
203        match s {
204            "keyword" => Some(Self::Keyword),
205            "symbol" => Some(Self::Symbol),
206            "keyword-arg" => Some(Self::KeywordArg),
207            "string" => Some(Self::String),
208            "number" => Some(Self::Number),
209            "literal" => Some(Self::Literal),
210            "comment" => Some(Self::Comment),
211            "accent" => Some(Self::Accent),
212            "muted" => Some(Self::Muted),
213            "error" => Some(Self::Error),
214            "warning" => Some(Self::Warning),
215            "info" => Some(Self::Info),
216            "hint" => Some(Self::Hint),
217            "added" => Some(Self::Added),
218            "removed" => Some(Self::Removed),
219            "unchanged" => Some(Self::Unchanged),
220            _ => None,
221        }
222    }
223}
224
225/// [`std::fmt::Display`] routed through [`Semantic::as_str`], so the
226/// pretty-printed byte-string every consumer that formats the semantic
227/// style as user-facing text lands on (a future `feira lint --list-styles`
228/// operator-facing enumeration verb's per-arm line, a future
229/// `caixa-lsp` diagnostic-source line naming the offending semantic,
230/// a future `caixa.nvim` per-Semantic highlight-group name emitter,
231/// a `tracing::field::display(&sem)` structured-log recorder on the
232/// paint-side emit path) reaches for the same lifted kebab-case
233/// per-arm byte-string [`Semantic::as_str`] returns.
234///
235/// Peer of the sibling [`std::fmt::Display`] impls on the closed-set
236/// typed enums the substrate carries — [`caixa_core::CaixaKind`],
237/// [`caixa_core::supervisor::RestartStrategy`],
238/// [`caixa_core::supervisor::RestartPolicy`],
239/// [`caixa_core::aplicacao::PlacementStrategy`],
240/// [`caixa_core::upgrade::UpgradeInstruction`],
241/// `caixa_lint::diagnostic::Severity`,
242/// `caixa_lint::diagnostic::FixSafety`,
243/// `caixa_arch::InvariantKind`, `caixa_arch::ArchVerdict`,
244/// `caixa_provedor::FerriteRuntime` — extended to the second-to-last
245/// un-lifted `caixa-theme` closed-set fieldless typed enum on the
246/// substrate-wide `(as_str, AsRef<str>, Display)` canonical-projection
247/// triple ratchet the prior lifts converged onto.
248impl std::fmt::Display for Semantic {
249    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
250        f.write_str(self.as_str())
251    }
252}
253
254/// Substrate-canonical [`AsRef<str>`] projection on the caixa-theme
255/// [`Semantic`] closed-set fieldless typed enum — routes through the
256/// same [`Semantic::as_str`] `pub const fn` scalar accessor the paired
257/// [`std::fmt::Display`] impl already reaches for.
258///
259/// Peer of the sibling [`AsRef<str>`] impls the substrate carries on
260/// [`caixa_core::CaixaKind`], [`caixa_core::CaixaVersion`],
261/// [`caixa_core::CaixaDialeto`], [`caixa_core::dep::DepList`],
262/// [`caixa_core::supervisor::RestartStrategy`],
263/// [`caixa_core::supervisor::RestartPolicy`],
264/// [`caixa_core::aplicacao::PlacementStrategy`],
265/// [`caixa_core::aplicacao::RateLimitUnit`],
266/// `caixa_lint::diagnostic::Severity`,
267/// `caixa_arch::InvariantKind`, `caixa_arch::ArchVerdict`,
268/// `caixa_provedor::FerriteRuntime` — extends the substrate-wide
269/// `(as_str, AsRef<str>, Display)` canonical-projection triple onto
270/// the caixa-theme closed-set typed-enum axis, so a future consumer
271/// bound through the trait-idiomatic `.as_ref()` (a
272/// `HashMap::get::<str>(sem.as_ref())` per-Semantic style-lookup, a
273/// future `caixa-lsp` `SemanticTokenType::new(sem.as_ref())`
274/// registration site, any `impl AsRef<str>`-bound generic function)
275/// reaches the same kebab byte-string [`Semantic::as_str`] returns
276/// rather than an open-coded `.as_str()` projection at every
277/// wire-up.
278impl AsRef<str> for Semantic {
279    fn as_ref(&self) -> &str {
280        self.as_str()
281    }
282}
283
284/// Trait-idiomatic reverse projection on the [`Semantic`] closed 16-arm
285/// caixa-theme semantic-style axis — routes byte-for-byte through the
286/// paired substrate-primitive [`Semantic::from_wire`] `Option<Self>`
287/// accessor so every future consumer that binds a canonical semantic
288/// tag through the standard-library `.try_into()` / [`TryFrom`] axis
289/// (a future `feira lint --semantic=<kebab>` CLI arg-parse that
290/// composes into `let sem: Semantic = s.try_into()?`, a future
291/// `caixa-lsp` per-token re-parse hydrating a prior
292/// [`Semantic::as_str`] output back to the typed enum for
293/// `SemanticTokenType` dispatch, a future `caixa.nvim` per-highlight-
294/// group re-loader binding a stored kebab byte-string back through the
295/// typed enum, a generic `<T: TryFrom<&str>>`-bound theme-overlay
296/// re-loader over any of the substrate's closed-set typed enums)
297/// reaches the same 16-arm accept-set the sibling
298/// [`Semantic::from_wire`] resolver parses through and the sibling
299/// [`Semantic::as_str`] emits, rather than an open-coded per-arm
300/// `match s { "keyword" => …, "symbol" => …, … _ => … }` cascade whose
301/// arm-set has no compile-time link back to the substrate primitive.
302///
303/// Complements the pre-existing forward-projection triple
304/// ([`std::fmt::Display`], [`AsRef<str>`], [`Semantic::as_str`]) with
305/// the paired trait-idiomatic reverse-projection axis: Rust-side
306/// newtype/typed-enum convention pairs [`AsRef<str>`] with either
307/// [`std::str::FromStr`] or [`TryFrom<&str>`] on the same primitive so
308/// a caller who can project *out to* a `&str` can also project *in
309/// from* one. The [`TryFrom<&str>`] axis is deliberately chosen over
310/// [`std::str::FromStr`] to sidestep the `clippy::should_implement_trait`
311/// lint the sibling method-named [`Semantic::from_wire`] would trigger
312/// under a `FromStr` impl (the same design tradeoff the peer
313/// [`caixa_core::CaixaKind`] (3c83606),
314/// [`caixa_core::CaixaDialeto`] (bf33136),
315/// [`caixa_core::aplicacao::PlacementStrategy`] (6fd00cd),
316/// [`caixa_core::supervisor::RestartStrategy`] (5b828ed),
317/// [`caixa_core::supervisor::RestartPolicy`] (6fdd0d9),
318/// [`caixa_core::aplicacao::WitShape`] (5472902),
319/// [`caixa_core::aplicacao::RateLimitUnit`] (bf78400),
320/// [`caixa_core::render::PathShapeViolation`] (e67e48a),
321/// `caixa_arch::invariants::InvariantKind` (e21a857),
322/// `caixa_arch::report::ArchVerdict` (0a4cc45),
323/// `caixa_lint::diagnostic::Severity` (a7bf74c), and
324/// `caixa_lint::diagnostic::FixSafety` (df86c94) blocks note) — this
325/// impl closes the trait-idiomatic reverse axis without disturbing the
326/// method-named `from_wire` shape every peer closed-set typed enum
327/// already carries.
328///
329/// `type Error = ()` matches the sibling [`Semantic::from_wire`]'s
330/// `Option<Self>` return-shape's deliberate deferral of error typing:
331/// the caller picks the diagnostic form appropriate for its use site
332/// (a future `feira lint --semantic` CLI arg-parse composes its own
333/// per-verb "unknown semantic-style tag: <arg> — accepted: {…}"
334/// message enumerating [`Semantic::ALL`], a future admission-webhook
335/// rejection body wraps the `Err(())` outcome with the accepted-set
336/// enumeration for operator diagnostics, a `Result::map_err` at the
337/// call site lifts the axis-error to a per-verb error type). Same
338/// shape the peer sibling reverse-projection axes carry. The return-
339/// shape uses fully-qualified `<Self as TryFrom<&str>>::Error` because
340/// the associated-type name would otherwise collide with the
341/// [`Self::Error`] variant on the same primitive (the identical
342/// ambiguous-associated-item defect the sibling
343/// `impl TryFrom<&str> for Severity` (a7bf74c) already threads around
344/// under `#[deny(future_incompatible)]`).
345///
346/// The paired [`TryFrom<&str>`] impl reaches the same 16-arm accept-
347/// set the [`Semantic::from_wire`] resolver dispatches through, so any
348/// future arm addition (a `Namespace` tier between [`Self::Symbol`]
349/// and [`Self::KeywordArg`] for the M4 tatara-lisp module system's
350/// qualified-name semantic-token dispatch, a `Deleted` tier for a
351/// hard-delete-mark distinct from [`Self::Removed`] the future 3-way
352/// diff surface grows — both trajectory items the sibling
353/// [`Semantic::ALL`] doc block already names) grows the trait-
354/// idiomatic axis by construction: one caixa-theme edit on
355/// [`Semantic::from_wire`] extends both the method-named reverse
356/// projection every existing consumer keys off and the trait-
357/// idiomatic reverse projection this impl exposes, without a
358/// coordinated rewrite across every future `TryFrom<&str>`-bound
359/// consumer's arm-set.
360///
361/// Extends the substrate-wide closed-set-enum trait-idiomatic
362/// reverse-projection family ([`caixa_core::CaixaKind`] via 3c83606,
363/// [`caixa_core::CaixaDialeto`] via bf33136,
364/// [`caixa_core::aplicacao::PlacementStrategy`] via 6fd00cd,
365/// [`caixa_core::supervisor::RestartStrategy`] via 5b828ed,
366/// [`caixa_core::supervisor::RestartPolicy`] via 6fdd0d9,
367/// [`caixa_core::aplicacao::WitShape`] via 5472902,
368/// [`caixa_core::aplicacao::RateLimitUnit`] via bf78400,
369/// [`caixa_core::render::PathShapeViolation`] via e67e48a,
370/// `caixa_arch::invariants::InvariantKind` via e21a857,
371/// `caixa_arch::report::ArchVerdict` via 0a4cc45,
372/// `caixa_lint::diagnostic::Severity` via a7bf74c, and
373/// `caixa_lint::diagnostic::FixSafety` via df86c94) onto the first
374/// closed-set fieldless typed enum on the caixa-theme surface — the
375/// semantic-style 16-arm accept-set every per-Semantic paint dispatch,
376/// every future `caixa-lsp` per-SemanticTokenType wire-up, and every
377/// future `caixa.nvim` per-highlight-group re-loader keys off. The
378/// thirteenth peer on the substrate surface, and the first inside
379/// `caixa-theme`; with `caixa_provedor::FerriteRuntime` remaining as
380/// the only outside-caixa-core closed-set fieldless typed enum whose
381/// trait-idiomatic axis is still open.
382///
383/// Pinned load-bearing by
384/// [`tests::semantic_try_from_str_routes_through_from_wire_accessor`]
385/// (byte-parity pin against [`Semantic::from_wire`] across the 16-arm
386/// accept-set) and
387/// [`tests::semantic_try_from_str_rejects_unknown_byte_strings`]
388/// (rejection witness against silent accept-set widening).
389impl TryFrom<&str> for Semantic {
390    type Error = ();
391
392    fn try_from(s: &str) -> Result<Self, <Self as TryFrom<&str>>::Error> {
393        Self::from_wire(s).ok_or(())
394    }
395}
396
397/// Standard-library trait-idiomatic forward projection on the
398/// [`Semantic`] closed 16-arm caixa-theme semantic-style axis. Routes
399/// byte-for-byte through the paired substrate-primitive
400/// [`Semantic::as_str`] `pub const fn` accessor so
401/// `<&'static str>::from(sem)` / `sem.into::<&'static str>()` reaches
402/// the same 16-arm canonical-lowercase kebab emit-set the sibling
403/// method-named accessor dispatches through and the sibling
404/// [`std::fmt::Display for Semantic`] / [`AsRef<str> for Semantic`]
405/// impls also route through.
406///
407/// Extends the substrate-wide closed-set-enum trait-idiomatic
408/// forward-projection family
409/// ([`caixa_core::supervisor::RestartStrategy`] via 523157d,
410/// [`caixa_core::supervisor::RestartPolicy`] via 9fb37d0,
411/// [`caixa_core::CaixaKind`] via edb827b,
412/// [`caixa_core::CaixaDialeto`] via c189a6f,
413/// [`caixa_core::aplicacao::PlacementStrategy`] via afa3562,
414/// [`caixa_core::aplicacao::WitShape`] via 56998ec,
415/// [`caixa_core::aplicacao::RateLimitUnit`] via 7fdfbf4,
416/// [`caixa_core::render::PathShapeViolation`] via 070a6de,
417/// [`caixa_arch::invariants::InvariantKind`] via f2ca7bc,
418/// [`caixa_arch::report::ArchVerdict`] via d4559cb,
419/// `caixa_lint::diagnostic::Severity` via 5cc3b8b, and
420/// `caixa_lint::diagnostic::FixSafety` via 2a56127) onto the first
421/// closed-set fieldless typed enum on the caixa-theme surface — the
422/// semantic-style 16-arm accept-set every per-Semantic paint dispatch,
423/// every future `caixa-lsp` per-`SemanticTokenType` wire-up, every
424/// future `caixa.nvim` per-highlight-group re-loader, and every future
425/// `blackmatter-shell` per-arm `data-semantic="<kebab>"` DOM emission
426/// keys off. The thirteenth peer on the substrate surface, closing the
427/// caixa-theme closed-set fieldless typed-enum axis onto the trait-
428/// idiomatic forward-projection axis and matching the paired trait-
429/// idiomatic reverse-projection axis (already closed via bd7da69 on
430/// this enum), with only `caixa_provedor::FerriteRuntime` remaining as
431/// the last outside-caixa-core closed-set fieldless typed enum whose
432/// trait-idiomatic forward axis is still open.
433///
434/// Pairs with the sibling [`TryFrom<&str> for Semantic`] impl (bd7da69)
435/// to close the two-way `Self ↔ &'static str` round-trip on the
436/// trait-idiomatic axis pair, mirroring the pre-existing method-named
437/// [`Semantic::as_str`] + [`Semantic::from_wire`] pair on the
438/// substrate-primitive axis pair.
439///
440/// Return type is `&'static str` by construction — every
441/// [`Semantic::as_str`] arm resolves to an inline `"keyword"` /
442/// `"symbol"` / `"keyword-arg"` / `"string"` / `"number"` /
443/// `"literal"` / `"comment"` / `"accent"` / `"muted"` / `"error"` /
444/// `"warning"` / `"info"` / `"hint"` / `"added"` / `"removed"` /
445/// `"unchanged"` `&'static str` literal, so the trait's return-type
446/// promise is upheld structurally without a [`String::leak`] cast or a
447/// per-arm inline literal outside the paired [`Semantic::as_str`]
448/// dispatch.
449///
450/// The paired [`Semantic::as_str`] accessor's 16-arm emit-set is the
451/// single source of truth — every future arm addition (a `Namespace`
452/// tier between [`Self::Symbol`] and [`Self::KeywordArg`] for the M4
453/// tatara-lisp module system's qualified-name semantic-token dispatch,
454/// a `Deleted` tier for a hard-delete-mark distinct from
455/// [`Self::Removed`] the future 3-way diff surface grows — both
456/// trajectory items the sibling [`Semantic::ALL`] doc block already
457/// names) grows the trait-idiomatic forward axis by construction: one
458/// caixa-theme edit on [`Semantic::as_str`] extends every one of the
459/// sibling forward-projection paths ([`std::fmt::Display`],
460/// [`AsRef<str>`], [`Semantic::as_str`] itself, and this
461/// [`From<Self> for &'static str`]) without a coordinated rewrite
462/// across every future `Into<&'static str>`-bound consumer's arm-set.
463///
464/// Pinned load-bearing by
465/// [`tests::semantic_from_into_static_str_routes_through_as_str_accessor`]
466/// (byte-parity pin against [`Semantic::as_str`] across the 16-arm
467/// emit-set, plus a `const`-context materialization witness for the
468/// `&'static str` lifetime promise routed through the paired
469/// [`Semantic::as_str`] `pub const fn` accessor, plus a paired
470/// `.into()` shape assertion covering the blanket-derived
471/// `Into<&'static str>` shape) and
472/// [`tests::semantic_from_into_static_str_and_as_str_partition_the_emit_set`]
473/// (partition pin asserting `<&'static str as From<Semantic>>::from`
474/// and [`Semantic::as_str`] agree on every arm, plus a two-way direct
475/// round-trip witness through the paired trait-idiomatic
476/// [`TryFrom<&str>`] axis that closes the two-way
477/// `Self ↔ &'static str` round-trip on the trait-idiomatic axis pair
478/// — the emit-side [`Semantic::as_str`] and the parse-side
479/// [`Semantic::from_wire`] dispatch on the same 16 inline canonical-
480/// lowercase kebab byte-strings by construction, so round-tripping
481/// composes the two trait impls directly).
482impl From<Semantic> for &'static str {
483    fn from(sem: Semantic) -> &'static str {
484        sem.as_str()
485    }
486}
487
488/// Trait-idiomatic *borrowed-input* forward projection on the
489/// [`Semantic`] closed 16-arm caixa-theme semantic-style axis onto the
490/// `&'static str` axis — the borrowed-input companion to the paired
491/// owned-input [`From<Semantic> for &'static str`] impl immediately
492/// above. Routes byte-for-byte through the same substrate-primitive
493/// [`Semantic::as_str`] `pub const fn` accessor so every consumer that
494/// binds a `&Semantic` through the standard-library `.into()` /
495/// [`From<&Self> for &'static str`] axis (a
496/// `Semantic::ALL.iter().map(<&'static str>::from).collect::<Vec<_>>()`
497/// per-arm accept-set materializer — whose iterator over
498/// `&'static [Semantic]` yields `&Semantic`, not `Semantic`, so the
499/// owned-input [`From<Semantic>`] axis alone forces every call site
500/// through an explicit `.copied()` / dereference / [`Copy`]-bound
501/// restatement rather than the direct trait-idiomatic projection; a
502/// future `feira lint --list-styles` operator-facing enumeration verb
503/// composed via `Semantic::ALL.iter().map(Into::into)`; a future
504/// `caixa-lsp` per-`SemanticTokenType` registration walk that borrows
505/// `&Semantic` off a stored per-style row; a future `caixa.nvim` per-
506/// highlight-group re-loader that borrows `&Semantic` off the loaded
507/// theme-overlay table; a future
508/// `HashMap::<&'static str, _>::from_iter(Semantic::ALL.iter().map(
509///     |sem| (<&'static str>::from(sem), 0)))` per-Semantic-paint
510/// histogram seed a future `blackmatter-shell` per-arm
511/// `data-semantic="<kebab>"` DOM-attribute emit path composes) reaches
512/// the same 16-arm `"keyword"` / `"symbol"` / `"keyword-arg"` /
513/// `"string"` / `"number"` / `"literal"` / `"comment"` / `"accent"` /
514/// `"muted"` / `"error"` / `"warning"` / `"info"` / `"hint"` /
515/// `"added"` / `"removed"` / `"unchanged"` canonical-lowercase kebab
516/// emit-set the paired owned-input [`From<Semantic> for &'static str`],
517/// the sibling [`std::fmt::Display`], [`AsRef<str>`], and
518/// [`Semantic::as_str`] surfaces already return.
519///
520/// Fifteenth and final peer on the substrate-wide trait-idiomatic
521/// *borrowed-input* `&'static str`-returning forward-projection family
522/// already carried by [`caixa_core::dep::DepList`] (64aa742,
523/// first-mover), [`caixa_core::CaixaKind`],
524/// [`caixa_core::CaixaDialeto`],
525/// [`caixa_core::supervisor::RestartStrategy`],
526/// [`caixa_core::supervisor::RestartPolicy`],
527/// [`caixa_core::aplicacao::PlacementStrategy`],
528/// [`caixa_core::aplicacao::WitShape`],
529/// [`caixa_core::aplicacao::RateLimitUnit`],
530/// [`caixa_core::render::PathShapeViolation`] (cdf4e95, first render-
531/// side arm), [`caixa_arch::invariants::InvariantKind`] (238d886,
532/// first outside-`caixa-core` arm), [`caixa_arch::report::ArchVerdict`]
533/// (73bda50), `caixa_lint::diagnostic::Severity` (2b9003f),
534/// `caixa_lint::diagnostic::FixSafety` (d8769ab), and
535/// `caixa_provedor::FerriteRuntime` (676d693). Rust's `From` trait does
536/// not auto-derive the `From<&Self>` sibling from a `From<Self>` impl
537/// (the blanket `impl<T, U> From<&T> for U where T: Copy, U: From<T>`
538/// does not exist in `core`), so every closed-set typed enum that
539/// carries the owned-input axis but not the borrowed-input axis forces
540/// every borrowed-input call site through a `.copied()` /
541/// `<&'static str>::from(*sem)` / `sem.as_str()` detour whose type
542/// bounds have no compile-time link to the substrate primitive.
543/// Lifting the borrowed-input axis on the caixa-theme semantic-style
544/// 16-arm closed-set fieldless typed enum closes that gap on the same
545/// trajectory the paired owned-input axis
546/// ([`impl From<Semantic> for &'static str`] immediately above) already
547/// opened, and closes the trait-idiomatic *borrowed-input*
548/// `&'static str`-returning axis on the last remaining substrate-wide
549/// closed-set fieldless typed enum whose borrowed-input axis was still
550/// open — the substrate-wide 2×2-completion campaign now covers every
551/// closed-set fieldless typed enum on the caixa surface on the
552/// borrowed-input `&'static str`-returning axis.
553///
554/// Pinned load-bearing by
555/// [`tests::semantic_from_borrowed_into_static_str_routes_through_as_str_accessor`]
556/// (byte-parity pin against [`Semantic::as_str`] across the 16-arm
557/// emit-set via a borrowed input, plus a `const`-context
558/// materialization witness for the `&'static str` lifetime promise)
559/// and
560/// [`tests::semantic_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
561/// (cross-axis partition pin against the paired owned-input
562/// [`From<Semantic> for &'static str`] impl, plus a
563/// `.iter().map(Into::into)` pipe witness over [`Semantic::ALL`] whose
564/// iterator yields `&Semantic` by construction so this borrowed-input
565/// axis is what routes the pipe through the substrate-primitive
566/// accessor without a spurious `Copy` deref).
567impl From<&Semantic> for &'static str {
568    fn from(sem: &Semantic) -> &'static str {
569        sem.as_str()
570    }
571}
572
573/// Trait-idiomatic *owned-input, owned-`String` output* forward
574/// projection on the [`Semantic`] closed 16-arm caixa-theme
575/// semantic-style axis — the owned-`String` companion to the paired
576/// [`From<Semantic> for &'static str`] and
577/// [`From<&Semantic> for &'static str`] siblings immediately above.
578/// Routes byte-for-byte through the substrate-primitive
579/// [`Semantic::as_str`] `pub const fn` accessor via
580/// [`str::to_owned`] so every consumer that binds a [`Semantic`]
581/// through the standard-library `.into()` / [`From<Self> for String`]
582/// axis (a `let key: String = sem.into();`-shaped downstream call
583/// site; a future `serde_json::Value::String(sem.into())` structured-
584/// payload composer where the `Value::String` arm typing demands an
585/// owned [`String`] and the sibling `&'static str`-returning axes
586/// force an explicit `.to_owned()` / [`String::from`] restatement at
587/// every call site; a future
588/// `HashMap::<String, Semantic>::from_iter` per-semantic lookup on
589/// a future `caixa-lsp` per-`SemanticTokenType` registration path
590/// where the map's key type is owned [`String`] rather than
591/// `&'static str`; a future
592/// [`std::borrow::Cow::<'static, str>::Owned(sem.into())`] composer
593/// on a future `feira lint --list-styles` operator-facing enumeration
594/// verb's per-arm row where an owned [`Cow`] arm typing rules;
595/// a future `caixa.nvim` per-highlight-group re-loader that stores
596/// the per-Semantic kebab identifier as an owned [`String`] on the
597/// theme-overlay table; a future `blackmatter-shell` per-arm
598/// `data-semantic="<kebab>"` DOM emission whose serializer's
599/// [`Serialize`] impl on [`String`] owns the emit-path) reaches the
600/// same 16-arm `"keyword"` / `"symbol"` / `"keyword-arg"` /
601/// `"string"` / `"number"` / `"literal"` / `"comment"` / `"accent"` /
602/// `"muted"` / `"error"` / `"warning"` / `"info"` / `"hint"` /
603/// `"added"` / `"removed"` / `"unchanged"` canonical-lowercase kebab
604/// emit-set the paired `&'static str`-returning axes, the sibling
605/// [`std::fmt::Display`], [`AsRef<str>`], and [`Semantic::as_str`]
606/// surfaces already return — no `.to_owned()` /
607/// `String::from(sem.as_str())` detour whose type bounds have no
608/// compile-time link to the substrate primitive.
609///
610/// Rust's standard library does not carry a blanket
611/// `impl<T: AsRef<str>> From<T> for String` (nor an
612/// `impl<T: fmt::Display> From<T> for String`), so every closed-set
613/// typed enum that carries the paired [`AsRef<str>`] /
614/// [`std::fmt::Display`] / [`From<Self> for &'static str`] /
615/// [`From<&Self> for &'static str`] quadruple but not the owned-
616/// `String` axis forces every owned-string call site through the
617/// detour above. This lift closes that axis on the sole closed-set
618/// fieldless typed enum on the caixa-theme surface (the semantic-
619/// style 16-arm axis), extending the substrate-wide
620/// `{Self, &Self} × {&'static str, String}` 2×2-completion campaign
621/// onto the sixth outside-`caixa-core` closed-set fieldless typed
622/// enum on the caixa surface — matching the trajectory each of the
623/// twelve prior peer enums —
624/// [`caixa_core::supervisor::RestartStrategy`] (7baa18a, first-mover
625/// on this axis), [`caixa_core::supervisor::RestartPolicy`] (7851725),
626/// [`caixa_core::CaixaKind`] (231a18c),
627/// [`caixa_core::CaixaDialeto`] (88942cd),
628/// [`caixa_core::dep::DepList`] (32b0ee8),
629/// [`caixa_core::aplicacao::PlacementStrategy`] (1154c2f),
630/// [`caixa_core::aplicacao::WitShape`] (79a8723),
631/// [`caixa_core::aplicacao::RateLimitUnit`] (c7d687d),
632/// [`caixa_core::render::PathShapeViolation`] (6e0479a, first render-
633/// side arm), [`caixa_arch::invariants::InvariantKind`] (1afd8d5,
634/// first outside-`caixa-core` arm — the paired severity-classification
635/// axis on the caixa-arch invariant-kind closed-set enum),
636/// [`caixa_arch::report::ArchVerdict`] (cc80a53, the paired verdict-
637/// outcome axis on the sibling caixa-arch closed-set enum),
638/// `caixa_lint::diagnostic::Severity` (4635d4e),
639/// `caixa_lint::diagnostic::FixSafety` (e4d73c6), and
640/// `caixa_provedor::FerriteRuntime` (1e14fde, the paired ferrite-
641/// runtime axis on the sole caixa-provedor closed-set enum) —
642/// followed on the same 2×2-completion campaign.
643///
644/// Pinned load-bearing by
645/// [`tests::semantic_from_into_owned_string_routes_through_as_str_accessor`]
646/// (byte-parity pin against [`Semantic::as_str`] across the 16-arm
647/// emit-set via the owned-`String` surface, plus a blanket-derived
648/// `Into<String>` shape witness) and
649/// [`tests::semantic_from_into_owned_string_and_static_str_agree_on_every_arm`]
650/// (cross-axis partition pin against the paired owned-input
651/// `&'static str`-returning [`From<Semantic> for &'static str`] impl
652/// and the [`ToString::to_string`]-through-[`std::fmt::Display`]
653/// surface, plus a `.iter().copied().map(String::from)` pipe witness
654/// over [`Semantic::ALL`], plus a direct `Self → String → Self`
655/// round-trip witness through the paired [`TryFrom<&str>`] axis on
656/// the owned-[`String`]'s [`String::as_str`] borrow).
657impl From<Semantic> for String {
658    fn from(sem: Semantic) -> String {
659        sem.as_str().to_owned()
660    }
661}
662
663/// Trait-idiomatic *borrowed-input, owned-`String` output* forward
664/// projection on the [`Semantic`] closed 16-arm caixa-theme semantic-
665/// style axis — the borrowed-input companion to the paired owned-
666/// input [`From<Semantic> for String`] (5ea146c) immediately above,
667/// the paired borrowed-input [`From<&Semantic> for &'static str`]
668/// (ffc0f26), and the paired owned-input
669/// [`From<Semantic> for &'static str`] siblings above. Routes byte-
670/// for-byte through the substrate-primitive [`Semantic::as_str`]
671/// `pub const fn` accessor via [`str::to_owned`] so every consumer
672/// that binds a [`Semantic`] through the standard-library `.into()` /
673/// [`From<&Self> for String`] axis reaches the same 16-arm
674/// `"keyword"` / `"symbol"` / `"keyword-arg"` / `"string"` /
675/// `"number"` / `"literal"` / `"comment"` / `"accent"` / `"muted"` /
676/// `"error"` / `"warning"` / `"info"` / `"hint"` / `"added"` /
677/// `"removed"` / `"unchanged"` canonical-lowercase kebab emit-set
678/// the paired [`std::fmt::Display`], [`AsRef<str>`],
679/// [`Semantic::as_str`], and the three other trait-idiomatic
680/// forward-projection impls already return — no
681/// `sem.as_str().to_owned()` / `String::from(*sem)` (with a spurious
682/// [`Copy`] deref) / `sem.to_string()` (through
683/// [`std::fmt::Display`]) detour whose type bounds have no compile-
684/// time link to the substrate primitive.
685///
686/// Fills the *last* remaining corner of the substrate-wide
687/// `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
688/// projection family on the sole closed-set fieldless typed enum on
689/// the caixa-theme surface — and, by construction, the *final*
690/// corner on the *entire* substrate-wide closed-set fieldless typed-
691/// enum roster on the caixa surface, closing the substrate-wide
692/// 2×2-completion campaign that opened on
693/// [`caixa_core::supervisor::RestartStrategy`] (579385f, first-mover
694/// on the borrowed-input owned-[`String`] axis). Rust's standard
695/// library carries no blanket
696/// `impl<T: AsRef<str>> From<&T> for String` (nor an
697/// `impl<T: fmt::Display> From<&T> for String`), so every borrowed-
698/// input owned-string call site — a future
699/// `serde_json::Value::String(String::from(&sem))` structured-payload
700/// composer over a borrowed per-style row where the
701/// [`serde_json::Value::String`] arm typing demands an owned
702/// [`String`] and the sibling `&'static str`-returning axes force an
703/// explicit `.to_owned()` / [`String::from`] restatement, a future
704/// `Semantic::ALL.iter().map(String::from).collect::<Vec<_>>()` per-
705/// arm accept-set materializer on a future `feira lint --list-styles`
706/// operator-facing enumeration verb whose iterator yields `&Semantic`
707/// by construction (so the borrowed-input owned-[`String`] axis is
708/// what routes the pipe through the substrate-primitive
709/// [`Semantic::as_str`] accessor without a spurious `.copied()` /
710/// [`Copy`]-bound dereference), a future
711/// `HashMap::<String, usize>::from_iter(Semantic::ALL.iter().map(|sem| (String::from(sem), 0)))`
712/// per-Semantic-paint histogram seed a future `blackmatter-shell`
713/// per-arm `data-semantic="<kebab>"` DOM-attribute emit path
714/// composes off a borrowed `&Semantic` off the loaded theme-overlay
715/// table, a future `caixa-lsp` per-`SemanticTokenType` registration
716/// walk borrowing off a stored per-style row, a future `caixa.nvim`
717/// per-highlight-group re-loader borrowing off the loaded theme-
718/// overlay table where the runtime stores the owned kebab identifier
719/// as [`String`] — otherwise resolves through the detour above.
720///
721/// Closing this corner locks the caixa-theme semantic-style enum's
722/// whole 2×2 trait-idiomatic projection family onto a single
723/// [`Semantic::as_str`]-routed emit-set — any future arm addition (a
724/// `Namespace` tier between [`Self::Symbol`] and [`Self::KeywordArg`]
725/// for the M4 tatara-lisp module system's qualified-name semantic-
726/// token dispatch, a `Deleted` tier for a hard-delete-mark distinct
727/// from [`Self::Removed`] the future 3-way diff surface grows — both
728/// trajectory items the sibling [`Semantic::ALL`] doc block already
729/// names) reaches every projection path through exactly one caixa-
730/// theme edit on the [`Semantic::as_str`] `pub const fn` accessor,
731/// and the partition pin trips at test time on the first detour
732/// that drifts a corner off.
733///
734/// Sixteenth and *final* peer on the substrate-wide trait-idiomatic
735/// *borrowed-input, owned-`String` output* forward-projection family,
736/// closing the substrate-wide 2×2-completion campaign across every
737/// closed-set fieldless typed enum on the caixa surface — opened on
738/// [`caixa_core::supervisor::RestartStrategy`] (579385f), extended
739/// through [`caixa_core::supervisor::RestartPolicy`] (8465740),
740/// [`caixa_core::dep::DepList`] (e0cb617),
741/// [`caixa_core::CaixaKind`] (e76436d),
742/// [`caixa_core::CaixaDialeto`] (d3c0d1d),
743/// [`caixa_core::aplicacao::PlacementStrategy`] (d3dc000),
744/// [`caixa_core::aplicacao::WitShape`] (d638fd3),
745/// [`caixa_core::aplicacao::RateLimitUnit`] (6424e45 — closing the
746/// whole M3 mesh-primitive triple's 2×2 corner),
747/// [`caixa_core::render::PathShapeViolation`] (b90e193 — first
748/// outside-manifest-surface arm on this axis),
749/// [`caixa_arch::invariants::InvariantKind`] (3c3f66f — first
750/// outside-`caixa-core` arm),
751/// [`caixa_arch::report::ArchVerdict`] (3cfb3b5 — second outside-
752/// `caixa-core` arm), `caixa_lint::diagnostic::Severity` (9518ab9 —
753/// third outside-`caixa-core` arm),
754/// `caixa_lint::diagnostic::FixSafety` (807f67d — fourth outside-
755/// `caixa-core` arm), and `caixa_provedor::FerriteRuntime` (0caedec
756/// — fifth outside-`caixa-core` arm), and now this lift on the
757/// sixth-and-last outside-`caixa-core` closed-set enum — the caixa-
758/// theme semantic-style 16-arm axis every per-Semantic paint
759/// dispatch, every future `caixa-lsp` per-`SemanticTokenType` wire-
760/// up, every future `caixa.nvim` per-highlight-group re-loader, and
761/// every future `blackmatter-shell` per-arm `data-semantic="<kebab>"`
762/// DOM emission keys off. Every future closed-set fieldless typed
763/// enum lifted onto the caixa surface picks up the same 2×2 trait-
764/// idiomatic projection family by construction as the substrate
765/// discipline.
766///
767/// Same three-path convergence discipline as the paired owned-input
768/// impl (this borrowed-input axis, the paired owned-input
769/// [`From<Semantic> for String`], and [`Semantic::as_str`] all
770/// route through the same 16-arm inline canonical-lowercase kebab
771/// byte-strings), so a future arm addition reaches every one of the
772/// paired forward-projection paths through exactly one caixa-theme
773/// edit on the [`Semantic::as_str`] `pub const fn` accessor.
774///
775/// The [`Semantic::as_str`] emit and [`Semantic::from_wire`] parse
776/// share the same 16 inline canonical-lowercase kebab byte-strings
777/// by construction — so the borrowed-input owned-[`String`] forward
778/// axis and the reverse [`TryFrom<&str>`] axis compose directly (via
779/// the owned-[`String`]'s [`String::as_str`] borrow) without an
780/// intermediate wire-vocab hop. The round-trip witness pin below
781/// locks this direct composition on the caixa-theme semantic-style
782/// enum's borrowed-input owned-[`String`] axis pair.
783///
784/// Pinned load-bearing by
785/// [`tests::semantic_from_borrowed_into_owned_string_routes_through_as_str_accessor`]
786/// (byte-parity pin against [`Semantic::as_str`] across the 16-arm
787/// emit-set through the borrowed-input surface, plus a blanket-
788/// derived `Into<String>` shape witness) and
789/// [`tests::semantic_from_borrowed_into_owned_string_agrees_with_paired_axes_on_every_arm`]
790/// (cross-axis partition pin against every one of the four 2×2
791/// corners — the paired owned-input owned-[`String`]
792/// [`From<Semantic> for String`] impl (5ea146c), the paired
793/// borrowed-input owned-[`&'static str`]
794/// [`From<&Semantic> for &'static str`] impl (ffc0f26), and the
795/// paired owned-input owned-[`&'static str`]
796/// [`From<Semantic> for &'static str`] impl — plus a
797/// [`ToString::to_string`]-through-[`std::fmt::Display`] byte-parity
798/// witness, plus a `.iter().map(String::from)` pipe witness over
799/// [`Semantic::ALL`] (whose iterator yields `&Semantic` by
800/// construction, so the borrowed-input owned-[`String`] axis is
801/// what routes the pipe through the substrate-primitive
802/// [`Semantic::as_str`] accessor without a spurious [`Copy`] deref),
803/// plus a direct round-trip witness through [`TryFrom<&str>`] on the
804/// owned-[`String`]'s [`String::as_str`] borrow that closes the two-
805/// way `&Self → String → Self` round-trip on the trait-idiomatic
806/// borrowed-input owned-[`String`] forward + reverse axis pair).
807impl From<&Semantic> for String {
808    fn from(sem: &Semantic) -> String {
809        sem.as_str().to_owned()
810    }
811}
812
813/// Trait-idiomatic *owned-input* forward projection on the sixteen-arm
814/// semantic-style [`Semantic`] closed-set fieldless typed enum onto the
815/// [`std::borrow::Cow<'static, str>`] axis — the
816/// [`std::borrow::Cow<'static, str>`] companion to the paired owned-
817/// input [`From<Semantic> for &'static str`] and paired owned-input
818/// [`From<Semantic> for String`] forward-projection corners already
819/// lifted above. Routes through the substrate-primitive
820/// [`Semantic::as_str`] `pub const fn` accessor via
821/// [`std::borrow::Cow::Borrowed`] so every consumer that binds a
822/// [`Semantic`] through the substrate's
823/// [`std::borrow::Cow<'static, str>`] axis (a `let key:
824/// std::borrow::Cow<'static, str> = sem.into();`-shaped downstream
825/// call site; a future `feira lint --list-styles` operator-facing
826/// enumeration verb whose per-style row typing binds through a
827/// [`std::borrow::Cow<'static, str>`] boundary the sibling
828/// `&'static str`-returning and owned-[`String`]-returning axes
829/// force through a `std::borrow::Cow::Borrowed(sem.as_str())` /
830/// `std::borrow::Cow::Owned(sem.to_string())` /
831/// `String::from(sem).into()` composition; a future
832/// `caixa-lsp`-side per-`SemanticTokenType` registration walk where
833/// the LSP wire schema binds the kebab tag as
834/// [`std::borrow::Cow<'static, str>`] so static semantic-style
835/// strings avoid the runtime allocation the owned-[`String`] axis
836/// would force; a future `caixa.nvim` per-highlight-group re-loader
837/// whose per-Semantic kebab identifier is bound through a
838/// [`std::borrow::Cow<'static, str>`] field so a theme-overlay row
839/// can carry either a static kebab or a per-scheme override without
840/// duplicating the enum-parameterized field type; a future
841/// `blackmatter-shell` per-arm `data-semantic="<kebab>"` DOM
842/// emission whose attribute value binds through a
843/// [`std::borrow::Cow<'static, str>`] so the emitter can compose
844/// static kebab strings with an occasional runtime-computed variant;
845/// a future `HashMap::<std::borrow::Cow<'static, str>,
846/// usize>::from_iter(Semantic::ALL.iter().copied().map(|sem|
847///     (sem.into(), 0)))` per-Semantic-paint histogram seed on a
848/// future per-file paint audit where the key type is
849/// [`std::borrow::Cow<'static, str>`] rather than `&'static str` or
850/// owned [`String`]) reaches the same 16-arm `"keyword"` /
851/// `"symbol"` / `"keyword-arg"` / `"string"` / `"number"` /
852/// `"literal"` / `"comment"` / `"accent"` / `"muted"` / `"error"` /
853/// `"warning"` / `"info"` / `"hint"` / `"added"` / `"removed"` /
854/// `"unchanged"` canonical-lowercase kebab emit-set the paired
855/// [`std::fmt::Display`], [`AsRef<str>`], [`Semantic::as_str`], and
856/// the four `{Self, &Self} × {&'static str, String}` 2×2 trait-
857/// idiomatic forward-projection corners already return.
858///
859/// Deliberately returns [`std::borrow::Cow::Borrowed`] rather than
860/// [`std::borrow::Cow::Owned`] — the substrate-primitive
861/// [`Semantic::as_str`] accessor's return carries the `&'static str`
862/// lifetime by construction (each `match` arm resolves to an inline
863/// `&'static str` literal), so the zero-alloc borrowed arm is the
864/// type-correct projection with no runtime allocation. Any future
865/// silent detour that routes the impl through the
866/// [`std::borrow::Cow::Owned`] arm (an accidental
867/// `std::borrow::Cow::Owned(sem.to_string())` rewrite that would
868/// allocate on every call site where the `&'static str` return of
869/// [`Semantic::as_str`] makes the zero-alloc borrowed projection
870/// type-correct) trips at caixa-theme test time under the
871/// [`std::borrow::Cow::Borrowed`] discriminator witness rather than
872/// at a downstream [`std::borrow::Cow<'static, str>`]-bound
873/// consumer's silent allocation.
874///
875/// *Fifth outside-`caixa-core` peer* (and *sole peer on the caixa-
876/// theme surface*) on the substrate-wide trait-idiomatic
877/// [`std::borrow::Cow<'static, str>`] forward-projection family —
878/// extends the outside-`caixa-core` tier of the campaign off the
879/// paired caixa-lint fix-safety-tier axis on the sibling two-arm
880/// closed-set enum ([`caixa_lint::diagnostic::FixSafety`], 79010c5 /
881/// 9a6539f — fourth outside-`caixa-core` peer, closed the 2×3
882/// corner) onto the semantic-style sixteen-arm axis every per-
883/// Semantic paint dispatch, every future `caixa-lsp`
884/// per-`SemanticTokenType` wire-up, every future `caixa.nvim`
885/// per-highlight-group re-loader, and every future
886/// `blackmatter-shell` per-arm `data-semantic="<kebab>"` DOM
887/// emission dispatches through. Fourteenth peer on the axis; leaves
888/// the remaining outside-`caixa-core` peer
889/// (`caixa_provedor::FerriteRuntime`) as the future target. The
890/// paired `{Self, &Self}` borrowed-input closer on `&Semantic` is
891/// the next commit on this axis, matching the closure discipline
892/// every prior peer landed one commit after its opener.
893///
894/// Rust's standard library does not carry a blanket
895/// `impl<T: AsRef<str>> From<T> for std::borrow::Cow<'static, str>`
896/// (nor an `impl<T: fmt::Display> From<T> for
897/// std::borrow::Cow<'static, str>`), so every closed-set fieldless
898/// typed enum peer on the substrate that carries the paired
899/// [`AsRef<str>`] / [`std::fmt::Display`] / [`From<Self> for &'static
900/// str`] / [`From<&Self> for &'static str`] / [`From<Self> for
901/// String`] / [`From<&Self> for String`] sextet but not the
902/// [`std::borrow::Cow<'static, str>`] axis forces every
903/// [`std::borrow::Cow<'static, str>`]-parameterized call site
904/// through a `std::borrow::Cow::Borrowed(sem.as_str())` /
905/// `std::borrow::Cow::Owned(sem.to_string())` /
906/// `String::from(sem).into()` detour whose type bounds have no
907/// compile-time link to the substrate primitive.
908///
909/// The [`Semantic::as_str`] emit and [`Semantic::from_wire`] parse
910/// share the same 16 inline canonical-lowercase kebab byte-strings
911/// by construction — so the [`std::borrow::Cow<'static, str>`]
912/// projection this impl exposes composes directly with the paired
913/// trait-idiomatic reverse [`TryFrom<&str>`] axis on the
914/// projection's [`std::borrow::Cow::as_ref`] borrow, no intermediate
915/// wire-vocab hop required (matching the sibling
916/// [`caixa_lint::diagnostic::FixSafety`] and
917/// [`caixa_lint::diagnostic::Severity`] pairs — round-trip-stable —
918/// unlike the peer [`caixa_core::CaixaKind`] pair whose forward
919/// emit and reverse parse land on distinct vocabularies).
920///
921/// Pinned load-bearing by
922/// [`tests::semantic_from_into_static_cow_str_routes_through_as_str_accessor`]
923/// (byte-parity pin against [`Semantic::as_str`] across the sixteen-
924/// arm emit-set through the [`std::borrow::Cow<'static, str>`]
925/// surface, plus a [`std::borrow::Cow::Borrowed`] discriminator
926/// witness that the projection lands on the zero-alloc arm rather
927/// than silently allocating through [`std::borrow::Cow::Owned`],
928/// plus a blanket-derived [`Into<std::borrow::Cow<'static, str>>`]
929/// shape witness that also lands on [`std::borrow::Cow::Borrowed`])
930/// and
931/// [`tests::semantic_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
932/// (cross-axis partition pin against the paired owned-input
933/// [`From<Semantic> for &'static str`] and
934/// [`From<Semantic> for String`] forward-projection corners plus
935/// the sibling [`ToString::to_string`]-through-[`std::fmt::Display`]
936/// surface, plus a `.iter().copied().map(std::borrow::Cow::from)`
937/// pipe witness over [`Semantic::ALL`] with zero-alloc
938/// [`std::borrow::Cow::Borrowed`] discriminator on every element,
939/// plus a direct round-trip witness through [`TryFrom<&str>`] on
940/// the projection's [`std::borrow::Cow::as_ref`] borrow).
941impl From<Semantic> for std::borrow::Cow<'static, str> {
942    fn from(sem: Semantic) -> std::borrow::Cow<'static, str> {
943        std::borrow::Cow::Borrowed(sem.as_str())
944    }
945}
946
947/// Trait-idiomatic *borrowed-input* forward projection on the sixteen-
948/// arm semantic-style [`Semantic`] closed-set fieldless typed enum onto
949/// the [`std::borrow::Cow<'static, str>`] axis — the borrowed-input
950/// companion to the paired owned-input
951/// [`From<Semantic> for std::borrow::Cow<'static, str>`] impl (0253688)
952/// immediately above, and the corner that closes the whole substrate-
953/// wide `{Self, &Self} × {&'static str, String, Cow<'static, str>}`
954/// 2×3 trait-idiomatic forward-projection family on the caixa-theme
955/// semantic-style sixteen-arm closed-set fieldless typed enum. Routes
956/// byte-for-byte through the substrate-primitive [`Semantic::as_str`]
957/// `pub const fn` accessor via [`std::borrow::Cow::Borrowed`] so every
958/// consumer that binds a `&Semantic` through the standard-library
959/// `.into()` / [`From<&Self> for std::borrow::Cow<'static, str>`] axis
960/// — the exact `Semantic::ALL.iter().map(std::borrow::Cow::from).collect()`
961/// pipe shape a future `feira lint --list-styles` CLI enumeration
962/// whose iterator yields `&Semantic` by construction, a future
963/// `.iter().map(|tok| std::borrow::Cow::from(&tok.semantic)).collect()`
964/// per-token fan-out over `&[SemanticToken]` in a future `caixa-lsp`-
965/// side per-`SemanticTokenType` registration walk whose borrowed access
966/// off `&SemanticToken.semantic` avoids a spurious [`Copy`]-bound
967/// dereference on the semantic-style field, a future `caixa.nvim` per-
968/// highlight-group re-loader whose per-`&Semantic` kebab identifier is
969/// bound through a [`std::borrow::Cow<'static, str>`] field so a theme-
970/// overlay row can carry either a static kebab or a per-scheme override
971/// without duplicating the enum-parameterized field type, a future
972/// `blackmatter-shell` per-arm `data-semantic="<kebab>"` DOM emission
973/// composer over an iterator-yielded `&Semantic`, or a future
974/// `axum::response::IntoResponse` per-semantic paint audit column over
975/// an iterator-yielded `&Semantic` reaches — resolves to the same 16-arm
976/// `"keyword"` / `"symbol"` / `"keyword-arg"` / `"string"` / `"number"` /
977/// `"literal"` / `"comment"` / `"accent"` / `"muted"` / `"error"` /
978/// `"warning"` / `"info"` / `"hint"` / `"added"` / `"removed"` /
979/// `"unchanged"` canonical-lowercase kebab byte-strings the paired
980/// [`std::fmt::Display`], [`AsRef<str>`], [`Semantic::as_str`], the
981/// four `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
982/// forward-projection corners, and the paired owned-input
983/// [`From<Semantic> for std::borrow::Cow<'static, str>`] impl already
984/// return.
985///
986/// Deliberately returns [`std::borrow::Cow::Borrowed`] rather than
987/// [`std::borrow::Cow::Owned`] — the substrate-primitive
988/// [`Semantic::as_str`] accessor's return carries the `&'static str`
989/// lifetime by construction (each `match` arm resolves to an inline
990/// `&'static str` literal), so the zero-alloc borrowed arm is the
991/// type-correct projection with no runtime allocation on the borrowed-
992/// input surface just as on the paired owned-input surface.
993///
994/// Closes the `{Self, &Self}` input-shape corner on the fifth outside-
995/// `caixa-core` peer of the substrate-wide
996/// [`std::borrow::Cow<'static, str>`] forward-projection campaign,
997/// opened one commit prior (0253688) on the paired owned-input impl.
998/// Rust's standard library does not carry a blanket
999/// `impl<T: AsRef<str>> From<&T> for std::borrow::Cow<'static, str>`
1000/// (nor an `impl<T: fmt::Display> From<&T> for
1001/// std::borrow::Cow<'static, str>`, nor a [`Copy`]-based
1002/// `impl<T: Copy, U: From<T>> From<&T> for U`), so every closed-set
1003/// fieldless typed enum peer on the substrate that carries the paired
1004/// owned-input [`std::borrow::Cow<'static, str>`] axis but not the
1005/// borrowed-input axis forces every borrowed-input
1006/// [`std::borrow::Cow<'static, str>`]-parameterized call site through
1007/// a spurious [`Copy`] deref (`std::borrow::Cow::from(*sem)`) or a
1008/// `std::borrow::Cow::Borrowed(sem.as_str())` open-code whose type
1009/// bounds have no compile-time link to the substrate primitive.
1010///
1011/// Matches the closure discipline the sibling
1012/// [`caixa_lint::diagnostic::FixSafety`] (9a6539f) landed one commit
1013/// after (79010c5) closing the whole caixa-lint fix-safety-tier 2×3
1014/// corner on the fourth outside-`caixa-core` peer,
1015/// [`caixa_lint::diagnostic::Severity`] (1819087) one commit after
1016/// (700a95e) closing the whole caixa-lint diagnostic-severity 2×3
1017/// corner on the third outside-`caixa-core` peer,
1018/// [`caixa_arch::report::ArchVerdict`] (1adb287) one commit after
1019/// (b492d5f) closing the whole caixa-arch verdict-outcome 2×3 corner
1020/// on the second outside-`caixa-core` peer, d7f3039 on the sibling
1021/// caixa-arch [`caixa_arch::invariants::InvariantKind`] one commit
1022/// after (9361e96), f80fbd6 on the render-side
1023/// [`caixa_core::render::PathShapeViolation`] one commit after
1024/// (7342c32), ebeb9e0 on the outside-M3
1025/// [`caixa_core::CaixaDialeto`] one commit after 8322511, 702cdf4 on
1026/// the two-list dep-graph [`caixa_core::dep::DepList`] one commit
1027/// after 6858bac, afdf0f4 on the M3-mesh-shape
1028/// [`caixa_core::aplicacao::PlacementStrategy`] one commit after
1029/// eee504d, 25690ef on [`caixa_core::aplicacao::WitShape`] one commit
1030/// after 8634dec, 53346fb on
1031/// [`caixa_core::aplicacao::RateLimitUnit`] one commit after 1d59925
1032/// (closing the whole M3 mesh-shape tier), d45c409 on the top-level
1033/// [`caixa_core::CaixaKind`] one commit after 99c1735, and 9b3e4b3 /
1034/// ee577fd on the M2 OTP-shape
1035/// [`caixa_core::supervisor::RestartStrategy`] /
1036/// [`caixa_core::supervisor::RestartPolicy`] sibling peers one commit
1037/// after 7dd28b3 / 0612398. Closes the whole caixa-theme semantic-
1038/// style sixteen-arm 2×3 corner
1039/// (`{Self, &Self} × {&'static str, String, Cow<'static, str>}`); the
1040/// remaining outside-`caixa-core` peer (`caixa_provedor::FerriteRuntime`)
1041/// is the only future target left on the axis.
1042///
1043/// Like the sibling [`caixa_lint::diagnostic::FixSafety`] and
1044/// [`caixa_lint::diagnostic::Severity`] pairs (whose canonical-
1045/// lowercase byte-strings are round-trip-stable), and unlike the peer
1046/// [`caixa_core::CaixaKind`] pair (whose forward emit lands on the
1047/// lowercase Portuguese diagnostic vocabulary while the reverse parse
1048/// lands on the `PascalCase` wire vocabulary, forcing the round-trip
1049/// through an intermediate [`caixa_core::CaixaKind::wire_name`] hop),
1050/// [`Semantic`] is a caixa-theme semantic-style axis with no
1051/// wire/diagnostic vocabulary split — the [`Semantic::as_str`] emit
1052/// and [`Semantic::from_wire`] parse share the same sixteen inline
1053/// canonical-lowercase kebab byte-strings by construction, so the
1054/// borrowed-input [`std::borrow::Cow<'static, str>`] projection this
1055/// impl exposes composes directly with the paired trait-idiomatic
1056/// reverse [`TryFrom<&str>`] axis on the projection's
1057/// [`std::borrow::Cow::as_ref`] borrow — no intermediate wire-vocab
1058/// hop required.
1059///
1060/// Pinned load-bearing by
1061/// [`tests::semantic_from_borrowed_into_static_cow_str_routes_through_as_str_accessor`]
1062/// (byte-parity pin against [`Semantic::as_str`] across the sixteen-
1063/// arm emit-set through the borrowed-input
1064/// [`std::borrow::Cow<'static, str>`] surface, plus a
1065/// [`std::borrow::Cow::Borrowed`] discriminator witness that the
1066/// borrowed-input projection lands on the zero-alloc arm rather than
1067/// silently allocating through [`std::borrow::Cow::Owned`], plus a
1068/// blanket-derived [`Into<std::borrow::Cow<'static, str>>`] shape
1069/// witness on the borrowed-input surface that also lands on
1070/// [`std::borrow::Cow::Borrowed`]) and
1071/// [`tests::semantic_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
1072/// (cross-axis partition pin against the paired owned-input
1073/// [`From<Semantic> for std::borrow::Cow<'static, str>`] impl
1074/// (0253688), the paired borrowed-input
1075/// [`From<&Semantic> for &'static str`], and
1076/// [`From<&Semantic> for String`] impls plus
1077/// [`ToString::to_string`]-through-[`std::fmt::Display`], plus a
1078/// `.iter().map(std::borrow::Cow::from)` pipe witness over
1079/// [`Semantic::ALL`] whose iterator yields `&Semantic` by construction
1080/// — so the borrowed-input axis is what routes the pipe without a
1081/// spurious [`Copy`] deref — pinning zero-alloc
1082/// [`std::borrow::Cow::Borrowed`] on every element, plus a direct
1083/// round-trip witness through [`TryFrom<&str>`] on the projection's
1084/// [`std::borrow::Cow::as_ref`] borrow that closes the two-way
1085/// `&Self → Cow<'static, str> → Self` round-trip on the borrowed-
1086/// input axis).
1087impl From<&Semantic> for std::borrow::Cow<'static, str> {
1088    fn from(sem: &Semantic) -> std::borrow::Cow<'static, str> {
1089        std::borrow::Cow::Borrowed(sem.as_str())
1090    }
1091}
1092
1093/// Trait-idiomatic *owned-input, [`Box<str>`] output* forward projection
1094/// on the caixa-theme semantic-style sixteen-arm closed-set fieldless
1095/// typed enum [`Semantic`]. Routes byte-for-byte through the substrate-
1096/// primitive [`Semantic::as_str`] `pub const fn` accessor via
1097/// [`Box::<str>::from`] on the returned `&'static str`, so every consumer
1098/// that binds a `let key: Box<str> = sem.into();`-shaped call site — a
1099/// per-semantic-style census-key materializer that stashes the
1100/// semantic-style discriminator in a [`Box<str>`]-typed heap-owned
1101/// scalar for cheap clone (a future per-semantic-style token-coloring
1102/// legend the LSP-side rich-diagnostics surface keys off), a future M4
1103/// admission-webhook rejection body whose per-arm [`Box<str>`] field
1104/// composes from an owned [`Semantic`] handle naming the accepted
1105/// semantic-style tier list, a future `feira lint --by-semantic`
1106/// histogram-column emitter that stashes each arm as an owned
1107/// [`Box<str>`] label — reaches the same sixteen canonical-lowercase
1108/// kebab byte-strings the sibling
1109/// `{Self, &Self} × {&'static str, String, Cow<'static, str>}` forward-
1110/// projection corner already returns.
1111///
1112/// Rust's standard library carries `impl From<&str> for Box<str>` and
1113/// `impl From<String> for Box<str>` but no blanket
1114/// `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a
1115/// distinct trait-idiomatic surface that a downstream
1116/// `Semantic → Box<str>` `.into()` reaches through this impl and no
1117/// other — without a `Box::from(sem.as_str())` open-code whose type
1118/// bounds have no compile-time link back to the substrate primitive.
1119///
1120/// Extends the outside-`caixa-core` tier of the substrate-wide trait-
1121/// idiomatic [`Box<str>`] forward-projection campaign onto the fifth
1122/// peer — the caixa-theme semantic-style sixteen-arm closed-set
1123/// fieldless typed enum — following the first-mover
1124/// [`caixa_arch::invariants::InvariantKind`] pair (10613a7 owned +
1125/// 5901887 borrowed) that opened the tier, the second-peer
1126/// [`caixa_arch::report::ArchVerdict`] pair (3e08f5a owned + c4319a8
1127/// borrowed), the third-peer [`Severity`] pair (5116c95), and the
1128/// fourth-peer [`FixSafety`] pair (cf0174b) that landed one axis prior.
1129/// Same discipline as the paired
1130/// [`caixa_core::supervisor::RestartStrategy`] /
1131/// [`caixa_core::supervisor::RestartPolicy`] M2-OTP-shape and
1132/// [`caixa_core::aplicacao::PlacementStrategy`] /
1133/// [`caixa_core::aplicacao::WitShape`] /
1134/// [`caixa_core::aplicacao::RateLimitUnit`] M3-mesh-shape [`Box<str>`]
1135/// axes: forward emit (this impl, the sibling
1136/// `{&'static str, String, Cow<'static, str>}` forward-projection
1137/// corner, [`std::fmt::Display`], [`AsRef<str>`], [`Semantic::as_str`])
1138/// and reverse parse ([`Semantic::from_wire`], [`TryFrom<&str>`]) route
1139/// through the same sixteen inline canonical-lowercase kebab byte-
1140/// strings [`Semantic::as_str`] returns by construction, so the round-
1141/// trip composes directly without the wire-vocab intermediate hop the
1142/// peer [`caixa_core::CaixaKind`] axis pair requires.
1143///
1144/// Leaves the remaining outside-`caixa-core` peer
1145/// ([`caixa_provedor::FerriteRuntime`]) whose [`Box<str>`] axis closure
1146/// remains the last future target on this tier of the campaign, and
1147/// leaves the paired borrowed-input [`From<&Semantic> for Box<str>`]
1148/// `{Self, &Self}`-closer as the direct next target on this axis.
1149///
1150/// Pinned load-bearing by
1151/// [`tests::semantic_from_into_box_str_routes_through_as_str_accessor`]
1152/// (byte-parity pin against [`Semantic::as_str`] across the sixteen-
1153/// arm [`Semantic::ALL`] emit-set on the owned-input surface, plus a
1154/// blanket-derived [`Into`] shape witness).
1155impl From<Semantic> for Box<str> {
1156    fn from(sem: Semantic) -> Box<str> {
1157        Box::<str>::from(sem.as_str())
1158    }
1159}
1160
1161/// Trait-idiomatic *borrowed-input, [`Box<str>`] output* forward
1162/// projection on the caixa-theme semantic-style sixteen-arm closed-set
1163/// fieldless typed enum [`Semantic`]. Routes byte-for-byte through the
1164/// substrate-primitive [`Semantic::as_str`] `pub const fn` accessor via
1165/// [`Box::<str>::from`] on the returned `&'static str`, so every consumer
1166/// that binds a `let key: Box<str> = (&sem).into();`-shaped call site or
1167/// a `Semantic::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
1168/// iterator over `&'static [Semantic]` yields `&Semantic` by
1169/// construction) — a per-semantic-style census-key materializer that
1170/// stashes the semantic-style discriminator in a [`Box<str>`]-typed
1171/// heap-owned scalar for cheap clone off a borrowed handle, a future M4
1172/// admission-webhook rejection body whose per-arm [`Box<str>`] field
1173/// composes from a borrowed [`Semantic`] handle off a `&Semantic`
1174/// borrow, a future `feira lint --by-semantic` histogram-column emitter
1175/// that iterates [`Semantic::ALL`] into per-arm owned [`Box<str>`]
1176/// labels — reaches the same sixteen canonical-lowercase kebab byte-
1177/// strings the sibling `{Self, &Self} × {&'static str, String,
1178/// Cow<'static, str>}` forward-projection corner and the paired owned-
1179/// input [`From<Semantic> for Box<str>`] already return.
1180///
1181/// Rust's standard library carries `impl From<&str> for Box<str>` and
1182/// `impl From<String> for Box<str>` but no blanket
1183/// `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
1184/// `impl<T: Copy, U: From<T>> From<&T> for U`), so this borrowed-input
1185/// axis is a distinct trait-idiomatic surface that the pipe shape
1186/// [`Semantic::ALL`]`.iter().map(Box::<str>::from)` reaches through
1187/// this impl and no other — without it, the same pipe would force an
1188/// explicit `.copied()` restatement (`.iter().copied()
1189/// .map(Box::<str>::from)`) whose type bounds have no compile-time link
1190/// back to the substrate primitive, and a `let key: Box<str> =
1191/// (&sem).into();`-shaped call site would force an explicit `Copy`
1192/// deref (`Box::<str>::from(*sem)`) or a
1193/// `Box::<str>::from(sem.as_str())` open-code with the same defect.
1194///
1195/// Closes the `{Self, &Self}` input-shape corner on the fifth outside-
1196/// `caixa-core` closed-set fieldless typed enum peer of the substrate-
1197/// wide trait-idiomatic [`Box<str>`] forward-projection campaign,
1198/// exactly as 5901887 closed the paired first-mover `InvariantKind`
1199/// axis one commit after (10613a7) landed, c4319a8 closed the paired
1200/// second-peer `ArchVerdict` axis one commit after (3e08f5a) landed,
1201/// 5116c95 landed the paired third-peer `Severity` pair one axis prior,
1202/// cf0174b landed the paired fourth-peer `FixSafety` pair one axis
1203/// prior, cb1d068 closed the paired M2-OTP-shape `RestartPolicy` axis
1204/// one commit after (0a1b313) landed, and 3c971b2 closed the paired M3-
1205/// mesh-shape `PlacementStrategy` axis one commit after (6d73e84)
1206/// landed. The remaining outside-`caixa-core` peer
1207/// ([`caixa_provedor::FerriteRuntime`]) remains the last future target
1208/// on this tier of the axis.
1209///
1210/// Same discipline as the paired
1211/// [`caixa_core::supervisor::RestartStrategy`] /
1212/// [`caixa_core::supervisor::RestartPolicy`] M2-OTP-shape and
1213/// [`caixa_core::aplicacao::PlacementStrategy`] /
1214/// [`caixa_core::aplicacao::WitShape`] /
1215/// [`caixa_core::aplicacao::RateLimitUnit`] M3-mesh-shape [`Box<str>`]
1216/// `{Self, &Self}`-closers: forward emit (this impl, the paired owned-
1217/// input [`From<Semantic> for Box<str>`] impl, the sibling
1218/// `{&'static str, String, Cow<'static, str>}` forward-projection
1219/// corner, [`std::fmt::Display`], [`AsRef<str>`], [`Semantic::as_str`])
1220/// and reverse parse ([`Semantic::from_wire`], [`TryFrom<&str>`]) route
1221/// through the same sixteen inline canonical-lowercase kebab byte-
1222/// strings [`Semantic::as_str`] returns by construction, so the round-
1223/// trip composes directly without the wire-vocab intermediate hop the
1224/// peer [`caixa_core::CaixaKind`] axis pair requires.
1225///
1226/// Pinned load-bearing by
1227/// [`tests::semantic_from_borrowed_into_box_str_routes_through_as_str_accessor`]
1228/// (byte-parity pin against [`Semantic::as_str`] across the sixteen-
1229/// arm [`Semantic::ALL`] emit-set on the borrowed-input surface, plus a
1230/// blanket-derived [`Into`] shape witness, plus a
1231/// `.iter().map(Box::<str>::from)` pipe witness over [`Semantic::ALL`]
1232/// — whose iterator yields `&Semantic` by construction, so the
1233/// borrowed-input [`Box<str>`] axis is what routes the pipe through the
1234/// substrate-primitive [`Semantic::as_str`] accessor without a spurious
1235/// [`Copy`] deref).
1236impl From<&Semantic> for Box<str> {
1237    fn from(sem: &Semantic) -> Box<str> {
1238        Box::<str>::from(sem.as_str())
1239    }
1240}
1241
1242#[cfg(test)]
1243mod tests {
1244    use super::*;
1245
1246    #[test]
1247    fn semantic_all_enumerates_every_variant_in_declaration_order() {
1248        // Fail-before-pass-after pin on the [`Semantic::ALL`] slice:
1249        // the slice must list every one of the 15 variants in
1250        // declaration order (Keyword → Symbol → KeywordArg → String →
1251        // Number → Literal → Comment → Accent → Muted → Error →
1252        // Warning → Info → Hint → Added → Removed → Unchanged). Peer
1253        // of the sibling ALL slices on the closed-set typed-enum
1254        // discriminator axes ([`caixa_core::CaixaKind::ALL`],
1255        // [`caixa_core::supervisor::RestartStrategy::ALL`],
1256        // [`caixa_core::supervisor::RestartPolicy::ALL`],
1257        // [`caixa_core::aplicacao::PlacementStrategy::ALL`],
1258        // [`caixa_core::upgrade::UpgradeInstruction::ALL`]). A future
1259        // arm addition (a `Namespace` tier between `Symbol` and
1260        // `KeywordArg` for the M4 tatara-lisp module system's
1261        // qualified-name semantic-token dispatch, a `Deleted` tier
1262        // for a hard-delete-mark distinct from `Removed` the future
1263        // 3-way diff surface grows) that lands the arm on the enum
1264        // but forgets to extend `ALL` must trip this pin rather than
1265        // surface as a downstream consumer's silently-partial
1266        // iteration.
1267        assert_eq!(
1268            Semantic::ALL,
1269            &[
1270                Semantic::Keyword,
1271                Semantic::Symbol,
1272                Semantic::KeywordArg,
1273                Semantic::String,
1274                Semantic::Number,
1275                Semantic::Literal,
1276                Semantic::Comment,
1277                Semantic::Accent,
1278                Semantic::Muted,
1279                Semantic::Error,
1280                Semantic::Warning,
1281                Semantic::Info,
1282                Semantic::Hint,
1283                Semantic::Added,
1284                Semantic::Removed,
1285                Semantic::Unchanged,
1286            ],
1287        );
1288        // Also pin the per-arm `IsVariant`-derived partition: every
1289        // arm in `ALL` must satisfy exactly one of the 15 generated
1290        // arm-discriminator predicates.
1291        for variant in Semantic::ALL {
1292            let row = [
1293                variant.is_keyword(),
1294                variant.is_symbol(),
1295                variant.is_keyword_arg(),
1296                variant.is_string(),
1297                variant.is_number(),
1298                variant.is_literal(),
1299                variant.is_comment(),
1300                variant.is_accent(),
1301                variant.is_muted(),
1302                variant.is_error(),
1303                variant.is_warning(),
1304                variant.is_info(),
1305                variant.is_hint(),
1306                variant.is_added(),
1307                variant.is_removed(),
1308                variant.is_unchanged(),
1309            ];
1310            let hits = row.iter().filter(|b| **b).count();
1311            assert_eq!(
1312                hits, 1,
1313                "Semantic::{variant:?} must satisfy exactly one of the \
1314                 15 is_* arm-discriminator predicates; got {row:?}",
1315            );
1316        }
1317    }
1318
1319    #[test]
1320    fn semantic_is_variant_predicates_partition_the_arm_set() {
1321        // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
1322        // derive: for each of the 15 variants, exactly one of the
1323        // generated is_* predicates returns `true` and the other 14
1324        // return `false`. Pre-derive the closed 15-arm partition
1325        // lived only inside the two theme overlays' 15-arm match
1326        // resolvers; a future rebrand (a `#[is_variant(name = "…")]`
1327        // drift, a manual hand-rolled `impl` that shadows the
1328        // derive-generated method, an arm rename) trips this pin at
1329        // caixa-theme build time rather than surfacing far from the
1330        // derive declaration. Peer of the sibling
1331        // [`caixa_core::CaixaKind`] `IsVariant` partition pin.
1332        // A copy-paste flip that reroutes one arm through the wrong
1333        // predicate lane trips at the identity-diagonal assertion,
1334        // since each variant's row is generated live from `ALL`'s
1335        // declaration order rather than transcribed by hand.
1336        for (idx, variant) in Semantic::ALL.iter().enumerate() {
1337            let observed: [bool; 16] = [
1338                variant.is_keyword(),
1339                variant.is_symbol(),
1340                variant.is_keyword_arg(),
1341                variant.is_string(),
1342                variant.is_number(),
1343                variant.is_literal(),
1344                variant.is_comment(),
1345                variant.is_accent(),
1346                variant.is_muted(),
1347                variant.is_error(),
1348                variant.is_warning(),
1349                variant.is_info(),
1350                variant.is_hint(),
1351                variant.is_added(),
1352                variant.is_removed(),
1353                variant.is_unchanged(),
1354            ];
1355            let mut expected = [false; 16];
1356            expected[idx] = true;
1357            assert_eq!(
1358                observed, expected,
1359                "Semantic::{variant:?} at ALL[{idx}] is_* predicates \
1360                 must fire only on their own arm lane (identity \
1361                 diagonal); got {observed:?}",
1362            );
1363        }
1364    }
1365
1366    #[test]
1367    fn semantic_as_str_returns_canonical_kebab_case_per_arm() {
1368        // Fail-before-pass-after per-arm byte-string pin on
1369        // [`Semantic::as_str`] — the substrate-canonical `&'static str`
1370        // projection every downstream consumer of the closed 16-arm
1371        // partition reaches through. A future arm rename (a `Symbol` →
1372        // `Identifier` rebrand tracking a hypothetical LSP-side
1373        // `SemanticTokenType` reshuffle, an `Accent` → `Highlight`
1374        // rebrand tracking a `blackmatter-shell` classname rework) that
1375        // touches the enum arm but forgets to update the paired
1376        // `as_str` arm — or vice versa — trips this pin at caixa-theme
1377        // build time rather than surfacing as a downstream
1378        // `feira lint --list-styles` operator-facing enumeration verb's
1379        // silently-renamed row far from the two-declaration site.
1380        //
1381        // Kebab-case matches the peer [`gen_platform::IsVariant`]-
1382        // derived kebab discriminant convention the sibling closed-set
1383        // typed enums already emit on their canonical byte-string
1384        // projection axis.
1385        assert_eq!(Semantic::Keyword.as_str(), "keyword");
1386        assert_eq!(Semantic::Symbol.as_str(), "symbol");
1387        assert_eq!(Semantic::KeywordArg.as_str(), "keyword-arg");
1388        assert_eq!(Semantic::String.as_str(), "string");
1389        assert_eq!(Semantic::Number.as_str(), "number");
1390        assert_eq!(Semantic::Literal.as_str(), "literal");
1391        assert_eq!(Semantic::Comment.as_str(), "comment");
1392        assert_eq!(Semantic::Accent.as_str(), "accent");
1393        assert_eq!(Semantic::Muted.as_str(), "muted");
1394        assert_eq!(Semantic::Error.as_str(), "error");
1395        assert_eq!(Semantic::Warning.as_str(), "warning");
1396        assert_eq!(Semantic::Info.as_str(), "info");
1397        assert_eq!(Semantic::Hint.as_str(), "hint");
1398        assert_eq!(Semantic::Added.as_str(), "added");
1399        assert_eq!(Semantic::Removed.as_str(), "removed");
1400        assert_eq!(Semantic::Unchanged.as_str(), "unchanged");
1401    }
1402
1403    #[test]
1404    fn semantic_as_str_projections_are_all_distinct_across_arms() {
1405        // Fail-before-pass-after pin on the injectivity of
1406        // [`Semantic::as_str`]'s projection — no two arms may share
1407        // their canonical kebab byte-string, since a future consumer
1408        // that keys a per-arm dispatch table off the projection (a
1409        // `HashMap::<&str, _>::from_iter(Semantic::ALL.iter().map(|s|
1410        // (s.as_str(), …)))` style-lookup, a future `caixa-lsp`
1411        // `SemanticTokenType::new(sem.as_ref())` registration table
1412        // keyed by kebab identifier, a future `feira lint --list-styles`
1413        // one-row-per-arm enumeration table) would silently collapse
1414        // the two colliding arms onto one entry, dropping the second
1415        // insertion. A future arm addition (a `Namespace` tier between
1416        // `Symbol` and `KeywordArg` for the M4 tatara-lisp module
1417        // system's qualified-name semantic-token dispatch, a `Deleted`
1418        // tier for a hard-delete-mark distinct from `Removed` a future
1419        // 3-way diff surface grows) that lands the arm on the enum and
1420        // reuses a peer arm's kebab identifier (a copy-paste-derived
1421        // `"removed"` on the new `Deleted` arm) trips this pin rather
1422        // than surfacing far from the arm addition site.
1423        let mut projections: Vec<&'static str> = Semantic::ALL.iter().map(|s| s.as_str()).collect();
1424        let before = projections.len();
1425        projections.sort_unstable();
1426        projections.dedup();
1427        assert_eq!(
1428            projections.len(),
1429            before,
1430            "Semantic::as_str must be injective across ALL — collisions: \
1431             {projections:?}",
1432        );
1433    }
1434
1435    #[test]
1436    fn semantic_display_and_as_ref_str_route_through_as_str_accessor() {
1437        // Fail-before-pass-after three-path convergence pin on the
1438        // substrate-wide `(as_str, AsRef<str>, Display)` canonical-
1439        // projection triple for the caixa-theme [`Semantic`] closed-set
1440        // fieldless typed enum. For every arm in [`Semantic::ALL`], the
1441        // paired [`std::fmt::Display`] impl + [`AsRef<str>`] impl + the
1442        // substrate-canonical [`Semantic::as_str`] `pub const fn`
1443        // scalar accessor must resolve to the same `&'static str`
1444        // per arm. Peer of the sibling three-path-convergence pins the
1445        // substrate carries on the closed-set typed enums the prior
1446        // lifts converged onto
1447        // (`restart_strategy_display_routes_through_as_str_helper` /
1448        // `restart_strategy_as_ref_str_routes_through_as_str_accessor`
1449        // on [`caixa_core::supervisor::RestartStrategy`],
1450        // `ferrite_runtime_display_and_as_ref_str_route_through_variant_slug_accessor`
1451        // on `caixa_provedor::FerriteRuntime`, and the analogous pins
1452        // on `caixa_lint::Severity` / `caixa_lint::FixSafety` /
1453        // `caixa_arch::InvariantKind` / `caixa_arch::ArchVerdict`).
1454        //
1455        // A future accidental split (a hand-rolled `impl fmt::Display`
1456        // that shadows this route through a divergent per-arm match, an
1457        // `impl AsRef<str>` that returns the compiler-derived `Debug`
1458        // string via `format!("{:?}", self)` — allocating and diverging
1459        // on every arm — or a `#[serde(rename_all = "…")]` attribute
1460        // drift that quietly forks the projection) trips this pin at
1461        // caixa-theme build time rather than surfacing as a downstream
1462        // consumer's silently-forked per-Semantic dispatch far from the
1463        // trait-impl declaration site.
1464        for &sem in Semantic::ALL {
1465            let via_as_str: &str = sem.as_str();
1466            let via_display: String = format!("{sem}");
1467            let via_as_ref: &str = <Semantic as AsRef<str>>::as_ref(&sem);
1468            assert_eq!(
1469                via_display, via_as_str,
1470                "Semantic::{sem:?} — Display routes off `as_str`; got \
1471                 Display={via_display:?} vs as_str={via_as_str:?}",
1472            );
1473            assert_eq!(
1474                via_as_ref, via_as_str,
1475                "Semantic::{sem:?} — AsRef<str> routes off `as_str`; got \
1476                 AsRef={via_as_ref:?} vs as_str={via_as_str:?}",
1477            );
1478        }
1479    }
1480
1481    #[test]
1482    fn semantic_as_str_is_usable_in_const_context() {
1483        // The [`Semantic::as_str`] accessor is declared `pub const fn`,
1484        // matching the peer closed-set typed enums' canonical
1485        // `&'static str` projection accessors
1486        // ([`caixa_core::CaixaKind::as_str`],
1487        // [`caixa_core::supervisor::RestartStrategy::as_str`],
1488        // [`caixa_core::aplicacao::PlacementStrategy::as_str`],
1489        // `caixa_provedor::FerriteRuntime::variant_slug`). Pin the
1490        // same posture with a `const {}` assertion block so a future
1491        // accidental downgrade to non-`const` (an added runtime helper
1492        // reachable only from a non-`const` context) trips at
1493        // caixa-theme build time rather than surfacing as a downstream
1494        // `const`-context regression far from the accessor
1495        // declaration.
1496        const KEYWORD: &str = Semantic::Keyword.as_str();
1497        const ERROR: &str = Semantic::Error.as_str();
1498        const UNCHANGED: &str = Semantic::Unchanged.as_str();
1499        const { assert!(KEYWORD.as_bytes()[0] == b'k') };
1500        const { assert!(ERROR.as_bytes()[0] == b'e') };
1501        const { assert!(UNCHANGED.as_bytes()[0] == b'u') };
1502    }
1503
1504    #[test]
1505    fn semantic_from_wire_accepts_every_as_str_output() {
1506        // Fail-before-pass-after per-arm accept pin on the newly lifted
1507        // [`Semantic::from_wire`] reverse projection: every arm in
1508        // [`Semantic::ALL`] must parse back through `from_wire` when fed
1509        // its own [`Semantic::as_str`] output, landing on
1510        // `Some(same_variant)`. A regression that hand-rolled either
1511        // side's per-arm match without threading through the shared
1512        // 16-string closed set would silently disagree on any future
1513        // arm rename (a `Symbol` → `Identifier` rebrand tracking a
1514        // hypothetical LSP-side `SemanticTokenType` reshuffle, an
1515        // `Accent` → `Highlight` rebrand tracking a `blackmatter-shell`
1516        // classname rework) or new arm the theme grows (a `Namespace`
1517        // tier between `Symbol` and `KeywordArg` for the M4 tatara-lisp
1518        // module system's qualified-name semantic-token dispatch, a
1519        // `Deleted` tier for a hard-delete-mark distinct from `Removed`
1520        // the future 3-way diff surface grows) and this pin flags it at
1521        // caixa-theme build time rather than at a downstream
1522        // `feira lint --list-styles` operator-facing enumeration verb's
1523        // silent tag misclassification.
1524        //
1525        // Peer of the sibling
1526        // `caixa_lint::diagnostic::tests::severity_from_wire_accepts_every_as_str_output`
1527        // (5afff0e) /
1528        // `caixa_lint::diagnostic::tests::fix_safety_from_wire_accepts_every_as_str_output`
1529        // (bd505a1) /
1530        // `caixa_arch::report::tests::arch_verdict_from_wire_accepts_every_as_str_output`
1531        // (6afe564) /
1532        // `caixa_arch::invariants::tests::invariant_kind_from_wire_accepts_every_as_str_output`
1533        // (b9e4e61) round-trip pins on the peer caixa-lint / caixa-arch
1534        // closed-set-enum reverse-projection axes, and of the sibling
1535        // `caixa_core::kind::tests::caixa_kind_wire_round_trips_through_from_wire`
1536        // (2aa6d23) /
1537        // `caixa_core::dialeto::tests::caixa_dialeto_from_wire_accepts_every_as_str_output`
1538        // (d0e65ea) /
1539        // `caixa_core::aplicacao::tests::placement_strategy_from_wire_accepts_every_lifted_constant`
1540        // (18c7342) /
1541        // `caixa_core::dep::tests::dep_list_round_trips_through_as_str_and_from_wire`
1542        // (45ee563) /
1543        // `caixa_core::render::tests::path_shape_violation_from_wire_accepts_every_as_str_output`
1544        // (aebd9c6) round-trip pins on the sibling caixa-core closed-
1545        // set typed-enum reverse-projection axes.
1546        for &variant in Semantic::ALL {
1547            let wire = variant.as_str();
1548            let parsed = Semantic::from_wire(wire).unwrap_or_else(|| {
1549                panic!(
1550                    "Semantic::from_wire({wire:?}) must accept every \
1551                     Semantic::as_str output — got None for the wire \
1552                     byte-string of {variant:?}"
1553                )
1554            });
1555            assert_eq!(
1556                parsed, variant,
1557                "Semantic::from_wire(Semantic::{variant:?}.as_str()) \
1558                 must return Semantic::{variant:?} — the (as_str, \
1559                 from_wire) pair must form a total round-trip on the \
1560                 closed 16-arm Semantic arm-set",
1561            );
1562        }
1563    }
1564
1565    #[test]
1566    fn semantic_from_wire_rejects_unknown_byte_strings() {
1567        // Rejection pin on the [`Semantic::from_wire`] parser's accept-
1568        // set: any string outside the 16-arm [`Semantic::as_str`] output
1569        // set must return `None`. A future accidental widening of the
1570        // accept-set (a case-insensitive match that accepts `"KEYWORD"`
1571        // / `"Keyword"`, a silent acceptance of the pre-lift PascalCase
1572        // Debug-derived shapes `"Keyword"` / `"KeywordArg"` /
1573        // `"Unchanged"` on the wire axis, a snake_case drift accepting
1574        // `"keyword_arg"` beside the canonical kebab-case
1575        // `"keyword-arg"`, a Levenshtein-forgiving arm-lookup that
1576        // admits `"kewyord"` typos, a silent absorption of a hypothetical
1577        // future `Namespace` / `Deleted` arm before it lands on the enum
1578        // and its paired [`Semantic::as_str`] emitter arm) would
1579        // silently drift the parser's accept-set from the emitter's — a
1580        // downstream style-report re-loader that bound a prior report's
1581        // [`Self::as_str`] output back to the typed enum through this
1582        // parser would then bind a malformed byte-string to a plausibly-
1583        // wrong typed arm the caller does not route through any
1584        // fallback, silently misclassifying the reloaded row.
1585        //
1586        // Peer of the sibling
1587        // `caixa_lint::diagnostic::tests::severity_from_wire_rejects_unknown_byte_strings`
1588        // (5afff0e) /
1589        // `caixa_lint::diagnostic::tests::fix_safety_from_wire_rejects_unknown_byte_strings`
1590        // (bd505a1) /
1591        // `caixa_arch::report::tests::arch_verdict_from_wire_rejects_unknown_byte_strings`
1592        // (6afe564) /
1593        // `caixa_arch::invariants::tests::invariant_kind_from_wire_rejects_unknown_byte_strings`
1594        // (b9e4e61) rejection pins on the peer caixa-lint / caixa-arch
1595        // axes, and of the sibling
1596        // `caixa_kind_from_wire_rejects_unknown_byte_strings` (2aa6d23),
1597        // `caixa_dialeto_from_wire_rejects_unknown_byte_strings`
1598        // (d0e65ea),
1599        // `placement_strategy_from_wire_rejects_unknown_byte_strings`
1600        // (18c7342),
1601        // `dep_list_from_wire_returns_none_on_unknown_wire_scalar`
1602        // (45ee563), and
1603        // `path_shape_violation_from_wire_rejects_unknown_byte_strings`
1604        // (aebd9c6) rejection pins on the sibling caixa-core axes.
1605        //
1606        // The rejection set also covers overlapping-byte-string tags
1607        // from peer axes: caixa-lint `Severity::as_str` outputs
1608        // `"error"`/`"warning"`/`"info"`/`"hint"` and caixa-arch
1609        // `InvariantKind::as_str` outputs `"safety"`/`"compliance"`
1610        // share zero canonical byte-strings with the widened 16-arm
1611        // Semantic set here — a widened parser that admitted the peer's
1612        // arm on the sibling axis would still not admit an arm foreign
1613        // to the caixa-theme semantic-style discriminator's own accept-
1614        // set. Yet four peer-axis strings DO overlap with the
1615        // caixa-theme set here (`Severity`'s
1616        // `"error"`/`"warning"`/`"info"`/`"hint"` map identically onto
1617        // the caixa-theme diagnostic-severity sub-region
1618        // `Semantic::Error`/`Warning`/`Info`/`Hint`) — a widened parser
1619        // that admitted them under a different arm would collapse the
1620        // two axes and silently mislabel; the pin excludes those four
1621        // from the rejection set precisely because they must accept.
1622        for bad in [
1623            "",
1624            " ",
1625            "Keyword",
1626            "KEYWORD",
1627            "Symbol",
1628            "SYMBOL",
1629            "KeywordArg",
1630            "keyword_arg",
1631            "keywordarg",
1632            "String",
1633            "STRING",
1634            "Number",
1635            "Literal",
1636            "Comment",
1637            "Accent",
1638            "Muted",
1639            "Error",
1640            "ERROR",
1641            "Warning",
1642            "WARNING",
1643            "Info",
1644            "INFO",
1645            "Hint",
1646            "HINT",
1647            "Added",
1648            "ADDED",
1649            "Removed",
1650            "REMOVED",
1651            "Unchanged",
1652            "UNCHANGED",
1653            "kewyord",
1654            "sym",
1655            "kw",
1656            "str",
1657            "num",
1658            "lit",
1659            "cmt",
1660            "safe",
1661            "unsafe",
1662            "safety",
1663            "compliance",
1664            "proven",
1665            "rejected",
1666            "namespace",
1667            "deleted",
1668            "highlight",
1669            "identifier",
1670            "keyword ",
1671            " keyword",
1672            "keyword\n",
1673            "keyword\t",
1674            "keyword-arg ",
1675            " keyword-arg",
1676            "added ",
1677            " added",
1678            "unchanged ",
1679            " unchanged",
1680        ] {
1681            assert!(
1682                Semantic::from_wire(bad).is_none(),
1683                "Semantic::from_wire({bad:?}) must return None — the \
1684                 parser's accept-set is exactly the 16 Semantic::as_str \
1685                 outputs; a widening would silently split the parser's \
1686                 accept-set from the emitter's arm-set",
1687            );
1688        }
1689    }
1690
1691    #[test]
1692    fn semantic_is_variant_predicates_are_const_fn() {
1693        // The [`gen_platform::IsVariant`] derive emits `const fn`
1694        // predicates on the peer [`caixa_core::CaixaKind`] /
1695        // [`caixa_core::upgrade::UpgradeInstruction`] /
1696        // [`caixa_core::supervisor::RestartStrategy`] /
1697        // [`caixa_core::supervisor::RestartPolicy`] closed-set typed
1698        // enums — pin the same posture on [`Semantic`] so a future
1699        // accidental downgrade to non-`const` (an added runtime helper
1700        // reachable only from a non-`const` context, a manual hand-
1701        // rolled `impl` that shadows the derive-generated method)
1702        // trips at caixa-theme build time rather than surfacing as a
1703        // downstream `const`-context regression far from the derive
1704        // declaration.
1705        const { assert!(Semantic::Keyword.is_keyword()) };
1706        const { assert!(Semantic::Error.is_error()) };
1707        const { assert!(Semantic::Added.is_added()) };
1708        const { assert!(Semantic::Unchanged.is_unchanged()) };
1709    }
1710
1711    #[test]
1712    fn semantic_try_from_str_routes_through_from_wire_accessor() {
1713        // Fail-before-pass-after byte-parity pin on the newly lifted
1714        // `impl TryFrom<&str> for Semantic` — asserts the standard-
1715        // library trait impl and the substrate-primitive
1716        // [`super::Semantic::from_wire`] `Option<Self>` accessor
1717        // resolve to the same 16-arm accept-set across every arm the
1718        // exhaustive [`super::Semantic::ALL`] slice enumerates. Any
1719        // future silent detour that routes the trait impl through a
1720        // divergent projection (a per-arm inline `match s { "keyword"
1721        // => Ok(Self::Keyword), … }` re-inlining that opens a
1722        // compile-time link to the un-lifted arm-literal, a silent
1723        // case-fold that admits `"Keyword"` / `"KEYWORD"` and would
1724        // collide the canonical-lowercase accept-set the emitter
1725        // dispatches on) trips at caixa-theme test time under
1726        // `assert_eq!` rather than at a downstream
1727        // `impl TryFrom<&str>`-bound consumer's silent split. Sweeps
1728        // every one of the 16 arms [`super::Semantic::ALL`] carries so
1729        // no arm's projection is covered only by the sibling method-
1730        // named `from_wire` path.
1731        //
1732        // Peer of the sibling
1733        // [`caixa_core::kind::tests::caixa_kind_try_from_str_routes_through_from_wire_accessor`]
1734        // (3c83606),
1735        // [`caixa_core::dialeto::tests::caixa_dialeto_try_from_str_routes_through_from_wire_accessor`]
1736        // (bf33136),
1737        // `placement_strategy_try_from_str_routes_through_from_wire_accessor`
1738        // (6fd00cd),
1739        // `rate_limit_unit_try_from_str_routes_through_from_suffix_accessor`
1740        // (bf78400),
1741        // `path_shape_violation_try_from_str_routes_through_from_wire_accessor`
1742        // (e67e48a),
1743        // `caixa_arch::invariants::tests::invariant_kind_try_from_str_routes_through_from_wire_accessor`
1744        // (e21a857),
1745        // `caixa_arch::report::tests::arch_verdict_try_from_str_routes_through_from_wire_accessor`
1746        // (0a4cc45),
1747        // `caixa_lint::diagnostic::tests::severity_try_from_str_routes_through_from_wire_accessor`
1748        // (a7bf74c), and
1749        // `caixa_lint::diagnostic::tests::fix_safety_try_from_str_routes_through_from_wire_accessor`
1750        // (df86c94) — extends the trait-idiomatic reverse-projection
1751        // axis onto the first closed-set fieldless typed enum on the
1752        // caixa-theme surface (the semantic-style axis).
1753        for &variant in Semantic::ALL {
1754            let wire = variant.as_str();
1755            assert_eq!(
1756                <Semantic as TryFrom<&str>>::try_from(wire),
1757                Ok(variant),
1758                "TryFrom<&str> impl on Semantic must round-trip \
1759                 Semantic::{variant:?}.as_str() = {wire:?} back to \
1760                 Ok(Semantic::{variant:?}) — divergence from \
1761                 Semantic::from_wire signals a silent detour off the \
1762                 substrate-primitive accessor",
1763            );
1764            assert_eq!(
1765                <Semantic as TryFrom<&str>>::try_from(wire).ok(),
1766                Semantic::from_wire(wire),
1767                "TryFrom<&str> ok()-projection on {wire:?} must \
1768                 byte-equal Semantic::from_wire on the same input",
1769            );
1770        }
1771    }
1772
1773    #[test]
1774    fn semantic_try_from_str_rejects_unknown_byte_strings() {
1775        // Rejection witness on the `impl TryFrom<&str> for Semantic` —
1776        // sweeps a candidate set of byte-strings outside the 16-arm
1777        // canonical-lowercase kebab wire accept-set the sibling
1778        // [`super::Semantic::as_str`] emits and asserts every one
1779        // lands on `Err(())`, so a future accidental widening of the
1780        // trait impl's accept-set (a stray additional
1781        // `_ if s.eq_ignore_ascii_case("keyword") => Ok(…)` case-fold
1782        // path, a silent acceptance of the pre-lift PascalCase Debug-
1783        // derived shapes `"Keyword"` / `"Symbol"` / `"KeywordArg"` on
1784        // the wire axis, a Levenshtein-forgiving arm-lookup that
1785        // admits `"kwd"` / `"sym"` / `"kw"` typos — the exact form a
1786        // `format!("{:?}", …).to_lowercase()` round-trip on the paired
1787        // [`std::fmt::Debug`] derive would otherwise land on) trips at
1788        // caixa-theme test time. The candidate set includes the empty
1789        // string, whitespace-only padding, uppercase / PascalCase
1790        // rebrand candidates, Levenshtein-neighbor typos, sibling
1791        // closed-set-enum canonical tags not shared with this axis
1792        // (peer `caixa_lint::diagnostic::FixSafety::as_str` two-arm
1793        // `"safe"` / `"unsafe"`, peer `caixa_arch::InvariantKind::as_str`
1794        // three-arm `"safety"` / `"compliance"`, peer
1795        // `caixa_arch::ArchVerdict::as_str` two-arm `"proven"` /
1796        // `"rejected"`), the trajectory-item candidates
1797        // (`"namespace"`, `"deleted"`) the sibling [`Semantic::ALL`]
1798        // doc block already names, whitespace-padded canonical tags,
1799        // and CamelCase spellings of the multi-word `KeywordArg`
1800        // variant (`"KeywordArg"`, `"keywordarg"`, `"keyword_arg"`,
1801        // `"keyword.arg"`) that would silently admit
1802        // if the accept-set widened to a case-fold or separator-
1803        // normalization rule.
1804        //
1805        // Peer of the sibling
1806        // `caixa_kind_try_from_str_rejects_unknown_byte_strings`
1807        // (3c83606),
1808        // `caixa_dialeto_try_from_str_rejects_unknown_byte_strings`
1809        // (bf33136),
1810        // `rate_limit_unit_try_from_str_rejects_unknown_byte_strings`
1811        // (bf78400),
1812        // `path_shape_violation_try_from_str_rejects_unknown_byte_strings`
1813        // (e67e48a),
1814        // `invariant_kind_try_from_str_rejects_unknown_byte_strings`
1815        // (e21a857),
1816        // `arch_verdict_try_from_str_rejects_unknown_byte_strings`
1817        // (0a4cc45),
1818        // `severity_try_from_str_rejects_unknown_byte_strings`
1819        // (a7bf74c), and
1820        // `fix_safety_try_from_str_rejects_unknown_byte_strings`
1821        // (df86c94) rejection pins on the sibling closed-set typed-
1822        // enum trait-idiomatic reverse-projection axes.
1823        for bad in [
1824            "",
1825            " ",
1826            "Keyword",
1827            "KEYWORD",
1828            "Symbol",
1829            "KeywordArg",
1830            "keywordarg",
1831            "keyword_arg",
1832            "keyword.arg",
1833            "String",
1834            "Number",
1835            "Literal",
1836            "Comment",
1837            "Accent",
1838            "Muted",
1839            "Error",
1840            "ERROR",
1841            "Warning",
1842            "Info",
1843            "Hint",
1844            "Added",
1845            "Removed",
1846            "Unchanged",
1847            "kwd",
1848            "sym",
1849            "kw",
1850            "str",
1851            "num",
1852            "lit",
1853            "cmt",
1854            "safe",
1855            "unsafe",
1856            "safety",
1857            "compliance",
1858            "proven",
1859            "rejected",
1860            "namespace",
1861            "deleted",
1862            "highlight",
1863            "identifier",
1864            "keyword ",
1865            " keyword",
1866            "keyword\n",
1867            "keyword\t",
1868            "keyword-arg ",
1869            " keyword-arg",
1870            "added ",
1871            " added",
1872            "unchanged ",
1873            " unchanged",
1874        ] {
1875            assert_eq!(
1876                <Semantic as TryFrom<&str>>::try_from(bad),
1877                Err(()),
1878                "TryFrom<&str> for Semantic({bad:?}) must return \
1879                 Err(()) — the trait impl's accept-set is exactly the \
1880                 16 Semantic::as_str outputs; a widening would \
1881                 silently split the trait impl's accept-set from the \
1882                 emitter's arm-set",
1883            );
1884        }
1885    }
1886
1887    #[test]
1888    fn semantic_try_from_str_and_from_wire_partition_the_accept_set() {
1889        // Cross-axis partition pin: the trait-idiomatic
1890        // [`TryFrom<&str>`] and the method-named
1891        // [`super::Semantic::from_wire`] projections must return
1892        // equivalent decisions on every input — the trait impl's
1893        // `.ok()` project-out from `Result<Self, ()>` and the method's
1894        // `Option<Self>` return must byte-equal each other on both
1895        // accepts and rejects. A future silent bifurcation (the trait
1896        // impl gaining a case-fold path the method does not carry, the
1897        // method gaining a synonym alias the trait impl does not
1898        // honor) trips at caixa-theme test time under a single pin
1899        // rather than at a downstream generic-bound consumer that
1900        // dispatches through one axis while a peer dispatches through
1901        // the other. Sweeps both the 16-arm accept-set (via
1902        // [`super::Semantic::ALL`] threaded through
1903        // [`super::Semantic::as_str`]) and a canonical rejection
1904        // sample so both halves of the partition are covered. Peer of
1905        // the sibling
1906        // `severity_try_from_str_and_from_wire_partition_the_accept_set`
1907        // (a7bf74c) and
1908        // `fix_safety_try_from_str_and_from_wire_partition_the_accept_set`
1909        // (df86c94) partition pins.
1910        for &variant in Semantic::ALL {
1911            let wire = variant.as_str();
1912            assert_eq!(
1913                <Semantic as TryFrom<&str>>::try_from(wire).ok(),
1914                Semantic::from_wire(wire),
1915                "TryFrom<&str>::ok() and from_wire must agree on \
1916                 Semantic::{variant:?}.as_str() = {wire:?}",
1917            );
1918        }
1919        for bad in [
1920            "",
1921            "Keyword",
1922            "unknown",
1923            "safety",
1924            "safe",
1925            "proven",
1926            "namespace",
1927            "keywordarg",
1928        ] {
1929            assert_eq!(
1930                <Semantic as TryFrom<&str>>::try_from(bad).ok(),
1931                Semantic::from_wire(bad),
1932                "TryFrom<&str>::ok() and from_wire must agree on the \
1933                 rejection outcome for {bad:?}",
1934            );
1935        }
1936    }
1937
1938    #[test]
1939    fn semantic_from_into_static_str_routes_through_as_str_accessor() {
1940        // Fail-before-pass-after byte-parity pin on the newly lifted
1941        // `impl From<Semantic> for &'static str` — asserts the standard-
1942        // library trait impl and the substrate-primitive
1943        // [`super::Semantic::as_str`] `pub const fn` accessor resolve to
1944        // the same 16-arm canonical-lowercase kebab emit-set across every
1945        // arm the exhaustive [`super::Semantic::ALL`] slice enumerates.
1946        // Any future silent detour that routes the trait impl through a
1947        // divergent projection (a per-arm inline `match sem { Keyword =>
1948        // "keyword", … }` re-inlining that opens a compile-time link to
1949        // the un-lifted arm-literal outside the paired
1950        // [`super::Semantic::as_str`] dispatch, a swap onto a
1951        // `format!("{:?}", …).to_lowercase()` round-trip through the
1952        // `#[derive(Debug)]` output whose stability is *not* guaranteed
1953        // and would silently reroute the semantic-style tag through a
1954        // stale byte-string with no downstream signal until an operator
1955        // scrolled the theme-paint terminal, a `#[serde(rename_all = "…")]`
1956        // attribute drift that quietly forks one axis) trips at
1957        // caixa-theme test time under `assert_eq!` rather than at a
1958        // downstream `impl Into<&'static str>`-bound consumer's silent
1959        // split. Sweeps every one of the 16 arms
1960        // [`super::Semantic::ALL`] carries so no arm's projection is
1961        // covered only by the sibling method-named `as_str` /
1962        // [`std::fmt::Display`] / [`AsRef<str>`] paths. Materializes
1963        // three `<&'static str as From<Semantic>>::from` outputs in
1964        // `const`-shape bindings against the paired
1965        // [`super::Semantic::as_str`] `pub const fn` accessor to make
1966        // the `'static` lifetime promise a build-time invariant — a
1967        // future accidental downgrade of any arm's inline canonical-
1968        // lowercase kebab byte-string to a non-`&'static str` (a
1969        // `String::leak()`-produced return, a `Box::leak`-cast, an
1970        // intermediate lifetime-erasing helper) trips at caixa-theme
1971        // build time rather than at a downstream `'static`-bound
1972        // consumer.
1973        //
1974        // Peer of the sibling
1975        // [`caixa_core::supervisor::tests::restart_strategy_from_into_static_str_routes_through_as_str_accessor`]
1976        // (523157d),
1977        // [`caixa_core::supervisor::tests::restart_policy_from_into_static_str_routes_through_as_str_accessor`]
1978        // (9fb37d0),
1979        // [`caixa_core::kind::tests::caixa_kind_from_into_static_str_routes_through_as_str_accessor`]
1980        // (edb827b),
1981        // [`caixa_core::dialeto::tests::caixa_dialeto_from_into_static_str_routes_through_as_str_accessor`]
1982        // (c189a6f),
1983        // [`caixa_core::aplicacao::tests::placement_strategy_from_into_static_str_routes_through_as_str_accessor`]
1984        // (afa3562),
1985        // [`caixa_core::aplicacao::tests::wit_shape_from_into_static_str_routes_through_as_str_accessor`]
1986        // (56998ec),
1987        // [`caixa_core::aplicacao::tests::rate_limit_unit_from_into_static_str_routes_through_as_suffix_accessor`]
1988        // (7fdfbf4),
1989        // [`caixa_core::render::tests::path_shape_violation_from_into_static_str_routes_through_as_str_accessor`]
1990        // (070a6de),
1991        // `caixa_arch::invariants::tests::invariant_kind_from_into_static_str_routes_through_as_str_accessor`
1992        // (f2ca7bc),
1993        // `caixa_arch::report::tests::arch_verdict_from_into_static_str_routes_through_as_str_accessor`
1994        // (d4559cb),
1995        // `caixa_lint::diagnostic::tests::severity_from_into_static_str_routes_through_as_str_accessor`
1996        // (5cc3b8b), and
1997        // `caixa_lint::diagnostic::tests::fix_safety_from_into_static_str_routes_through_as_str_accessor`
1998        // (2a56127) pins on the sibling closed-set typed-enum forward-
1999        // projection axes — extends the trait-idiomatic forward-
2000        // projection axis onto the first closed-set fieldless typed
2001        // enum on the caixa-theme surface (the semantic-style axis),
2002        // leaving `caixa_provedor::FerriteRuntime` as the last outside-
2003        // caixa-core closed-set fieldless typed enum whose trait-
2004        // idiomatic forward axis is still open.
2005        const KEYWORD: &str = Semantic::Keyword.as_str();
2006        const KEYWORD_ARG: &str = Semantic::KeywordArg.as_str();
2007        const UNCHANGED: &str = Semantic::Unchanged.as_str();
2008        for &variant in Semantic::ALL {
2009            let via_trait: &'static str = <&'static str as From<Semantic>>::from(variant);
2010            let via_method: &'static str = variant.as_str();
2011            assert_eq!(
2012                via_trait, via_method,
2013                "From<Semantic> for &'static str impl must round-trip \
2014                 Semantic::{variant:?} to the same canonical-lowercase \
2015                 kebab byte-string Semantic::as_str returns — divergence \
2016                 signals a silent detour off the substrate-primitive \
2017                 accessor"
2018            );
2019            let via_into: &'static str = variant.into();
2020            assert_eq!(
2021                via_into, via_method,
2022                "Into<&'static str>::into on Semantic::{variant:?} must \
2023                 byte-equal Semantic::as_str on the same input — the \
2024                 blanket-derived Into shape must resolve to the same \
2025                 as_str dispatch as the explicit From impl"
2026            );
2027        }
2028        assert_eq!(
2029            [KEYWORD, KEYWORD_ARG, UNCHANGED],
2030            ["keyword", "keyword-arg", "unchanged"],
2031            "const-context Semantic::as_str must resolve to the \
2032             canonical-lowercase kebab byte-strings — a future \
2033             accidental downgrade of any arm to a non-const or non-\
2034             static byte-string breaks the `&'static str`-lifetime \
2035             promise the paired From<Semantic> for &'static str impl \
2036             carries by construction"
2037        );
2038    }
2039
2040    #[test]
2041    fn semantic_from_into_static_str_and_as_str_partition_the_emit_set() {
2042        // Cross-axis partition pin: the paired trait-idiomatic
2043        // `From<Semantic> for &'static str` forward projection and the
2044        // method-named [`super::Semantic::as_str`] forward projection
2045        // must resolve identically on *every* arm, not just the ones
2046        // named in the primary byte-parity pin above. Sweeps every
2047        // [`super::Semantic::ALL`] arm and asserts the trait's
2048        // `From::from` output byte-equals the method-named accessor's
2049        // return-value on each, locking the two forward-projection paths
2050        // together by construction so any future detour (a stray `From`
2051        // special-case that lands on a divergent per-arm literal outside
2052        // the paired `as_str` dispatch, a hypothetical rebrand touching
2053        // one axis without the other) trips at caixa-theme test time.
2054        //
2055        // Peer of the sibling forward-projection partition pins
2056        // [`caixa_core::supervisor::tests::restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`]
2057        // (523157d),
2058        // [`caixa_core::supervisor::tests::restart_policy_from_into_static_str_and_as_str_partition_the_emit_set`]
2059        // (9fb37d0),
2060        // [`caixa_core::kind::tests::caixa_kind_from_into_static_str_and_as_str_partition_the_emit_set`]
2061        // (edb827b),
2062        // [`caixa_core::dialeto::tests::caixa_dialeto_from_into_static_str_and_as_str_partition_the_emit_set`]
2063        // (c189a6f),
2064        // [`caixa_core::aplicacao::tests::placement_strategy_from_into_static_str_and_as_str_partition_the_emit_set`]
2065        // (afa3562),
2066        // [`caixa_core::aplicacao::tests::wit_shape_from_into_static_str_and_as_str_partition_the_emit_set`]
2067        // (56998ec),
2068        // [`caixa_core::aplicacao::tests::rate_limit_unit_from_into_static_str_and_as_suffix_partition_the_emit_set`]
2069        // (7fdfbf4),
2070        // [`caixa_core::render::tests::path_shape_violation_from_into_static_str_and_as_str_partition_the_emit_set`]
2071        // (070a6de),
2072        // `caixa_arch::invariants::tests::invariant_kind_from_into_static_str_and_as_str_partition_the_emit_set`
2073        // (f2ca7bc),
2074        // `caixa_arch::report::tests::arch_verdict_from_into_static_str_and_as_str_partition_the_emit_set`
2075        // (d4559cb),
2076        // `caixa_lint::diagnostic::tests::severity_from_into_static_str_and_as_str_partition_the_emit_set`
2077        // (5cc3b8b), and
2078        // `caixa_lint::diagnostic::tests::fix_safety_from_into_static_str_and_as_str_partition_the_emit_set`
2079        // (2a56127) — extends the round-trip discipline onto the first
2080        // closed-set fieldless typed enum on the caixa-theme surface,
2081        // closing the two-way `Self ↔ &'static str` round-trip on the
2082        // trait-idiomatic pair (`From<Self> for &'static str` +
2083        // `TryFrom<&str> for Self`) as well as the pre-existing method-
2084        // named pair (`as_str` + `from_wire`).
2085        for &variant in Semantic::ALL {
2086            let via_trait: &'static str = <&'static str as From<Semantic>>::from(variant);
2087            let via_method: &'static str = variant.as_str();
2088            assert_eq!(
2089                via_trait, via_method,
2090                "From<Semantic> for &'static str and Semantic::as_str \
2091                 must resolve identically on Semantic::{variant:?} — \
2092                 divergence signals the two forward-projection paths \
2093                 have drifted onto different emit-sets"
2094            );
2095        }
2096        // Round-trip witness: every arm's forward `From` output re-parses
2097        // through the paired trait-idiomatic `TryFrom<&str>` back to the
2098        // original variant. Closes the two-way `Semantic ↔ &'static str`
2099        // round-trip on the trait-idiomatic axis pair directly (no wire-
2100        // vocab intermediate — the emit-side [`super::Semantic::as_str`]
2101        // and the parse-side [`super::Semantic::from_wire`] dispatch on
2102        // the same 16 inline canonical-lowercase kebab byte-strings by
2103        // construction, so round-tripping through the paired
2104        // `From<Self> for &'static str` + `TryFrom<&str> for Self` trait
2105        // impls composes to the identity on `Semantic::ALL`).
2106        for &variant in Semantic::ALL {
2107            let emitted: &'static str = <&'static str as From<Semantic>>::from(variant);
2108            let reparsed = <Semantic as TryFrom<&str>>::try_from(emitted).unwrap_or_else(|()| {
2109                panic!(
2110                    "TryFrom<&str> for Semantic must accept every \
2111                     From<Semantic> for &'static str output — got \
2112                     Err(()) for Semantic::{variant:?}'s emit \
2113                     byte-string {emitted:?}"
2114                )
2115            });
2116            assert_eq!(
2117                reparsed, variant,
2118                "trait-idiomatic Semantic ↔ &'static str round-trip \
2119                 must be the identity on Semantic::{variant:?} — the \
2120                 From<Self> for &'static str + TryFrom<&str> for Self \
2121                 pair must compose to the identity on the closed 16-arm \
2122                 accept-set"
2123            );
2124        }
2125    }
2126
2127    #[test]
2128    fn semantic_from_borrowed_into_static_str_routes_through_as_str_accessor() {
2129        // Fail-before-pass-after byte-parity pin on the newly lifted
2130        // `impl From<&Semantic> for &'static str` — asserts the
2131        // borrowed-input standard-library trait impl and the substrate-
2132        // primitive [`super::Semantic::as_str`] `pub const fn` accessor
2133        // resolve to the same 16-arm canonical-lowercase kebab emit-set
2134        // across every arm the exhaustive [`super::Semantic::ALL`]
2135        // slice enumerates. Rust's `From` trait does not auto-derive
2136        // the borrowed-input sibling from a paired owned-input impl
2137        // (no `impl<T, U> From<&T> for U where T: Copy, U: From<T>`
2138        // blanket in `core`), so the borrowed-input axis is a distinct
2139        // trait-idiomatic surface that a `.iter().map(Into::into)`
2140        // shape over [`super::Semantic::ALL`] (whose iterator yields
2141        // `&Semantic`, not `Semantic`) reaches through this impl and
2142        // no other — the paired owned-input [`From<Semantic>`] impl
2143        // requires an explicit `.copied()` / dereference before the
2144        // trait fires. Materializes three
2145        // `<&'static str as From<&Semantic>>::from` outputs in
2146        // `const`-shape bindings against the paired
2147        // [`super::Semantic::as_str`] `pub const fn` accessor to make
2148        // the `'static` lifetime promise a build-time invariant — a
2149        // future accidental downgrade of any arm's inline canonical-
2150        // lowercase kebab byte-string to a non-`&'static str` (a
2151        // `String::leak()`-produced return, a `Box::leak`-cast, an
2152        // intermediate lifetime-erasing helper) trips at caixa-theme
2153        // build time rather than at a downstream `'static`-bound
2154        // consumer.
2155        //
2156        // Peer of the sibling
2157        // `caixa_provedor::ferrite::tests::ferrite_runtime_from_borrowed_into_static_str_routes_through_variant_slug_accessor`
2158        // (676d693) pin on the outside-`caixa-core` closed-set-enum
2159        // borrowed-input axis — extends the trait-idiomatic borrowed-
2160        // input forward-projection axis onto the last remaining
2161        // closed-set fieldless typed enum on the substrate surface
2162        // (the caixa-theme semantic-style 16-arm axis), closing the
2163        // substrate-wide 2×2-completion campaign's borrowed-input
2164        // `&'static str`-returning corner.
2165        const KEYWORD: &str = Semantic::Keyword.as_str();
2166        const KEYWORD_ARG: &str = Semantic::KeywordArg.as_str();
2167        const UNCHANGED: &str = Semantic::Unchanged.as_str();
2168        for variant in Semantic::ALL {
2169            let via_trait: &'static str = <&'static str as From<&Semantic>>::from(variant);
2170            let via_method: &'static str = variant.as_str();
2171            assert_eq!(
2172                via_trait, via_method,
2173                "From<&Semantic> for &'static str impl must round-trip \
2174                 &Semantic::{variant:?} to the same canonical-lowercase \
2175                 kebab byte-string Semantic::as_str returns — divergence \
2176                 signals a silent detour off the substrate-primitive \
2177                 accessor"
2178            );
2179            let via_into: &'static str = variant.into();
2180            assert_eq!(
2181                via_into, via_method,
2182                "Into<&'static str>::into on &Semantic::{variant:?} must \
2183                 byte-equal Semantic::as_str on the same input — the \
2184                 blanket-derived Into shape on the borrowed-input axis \
2185                 must resolve to the same as_str dispatch as the \
2186                 explicit From impl"
2187            );
2188        }
2189        assert_eq!(
2190            [KEYWORD, KEYWORD_ARG, UNCHANGED],
2191            ["keyword", "keyword-arg", "unchanged"],
2192            "const-context Semantic::as_str must resolve to the \
2193             canonical-lowercase kebab byte-strings — a future \
2194             accidental downgrade of any arm to a non-const or non-\
2195             static byte-string breaks the `&'static str`-lifetime \
2196             promise the paired From<&Semantic> for &'static str impl \
2197             carries by construction"
2198        );
2199    }
2200
2201    #[test]
2202    fn semantic_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
2203        // Cross-axis partition pin: the paired trait-idiomatic
2204        // `From<Semantic> for &'static str` owned-input forward
2205        // projection and the newly lifted
2206        // `From<&Semantic> for &'static str` borrowed-input forward
2207        // projection must resolve identically on *every* arm the
2208        // exhaustive [`super::Semantic::ALL`] slice enumerates. Locks
2209        // the two trait-idiomatic forward-projection paths together by
2210        // construction so any future detour (a stray borrowed-input
2211        // `From` special-case that lands on a divergent per-arm literal
2212        // outside the paired `as_str` dispatch, a hypothetical rebrand
2213        // touching one axis without the other) trips at caixa-theme
2214        // test time under `assert_eq!` rather than at a downstream
2215        // consumer split. Witnesses the borrowed-input axis with a
2216        // `.iter().map(Into::into)` pipe over `Semantic::ALL` (whose
2217        // iterator yields `&Semantic`, not `Semantic`, so the pipe
2218        // fires through the borrowed-input axis alone).
2219        //
2220        // Peer of the sibling
2221        // `caixa_provedor::ferrite::tests::ferrite_runtime_from_owned_and_borrowed_into_static_str_agree_on_every_arm`
2222        // (676d693) — extends the owned/borrowed-cross-axis partition
2223        // discipline onto the last remaining substrate-wide closed-set
2224        // fieldless typed enum whose borrowed-input axis was still
2225        // open.
2226        for &variant in Semantic::ALL {
2227            let via_owned: &'static str = <&'static str as From<Semantic>>::from(variant);
2228            let via_borrowed: &'static str = <&'static str as From<&Semantic>>::from(&variant);
2229            assert_eq!(
2230                via_owned, via_borrowed,
2231                "From<Semantic> for &'static str and From<&Semantic> \
2232                 for &'static str must agree on Semantic::{variant:?} \
2233                 — divergence signals the owned-input and borrowed-\
2234                 input forward-projection paths have drifted onto \
2235                 different emit-sets"
2236            );
2237        }
2238        let via_pipe: Vec<&'static str> = Semantic::ALL.iter().map(Into::into).collect();
2239        let via_method: Vec<&'static str> = Semantic::ALL.iter().map(|s| s.as_str()).collect();
2240        assert_eq!(
2241            via_pipe, via_method,
2242            "Semantic::ALL.iter().map(Into::into) must resolve to the \
2243             same per-arm canonical-lowercase kebab byte-string \
2244             sequence Semantic::as_str returns across every arm — the \
2245             iterator yields &Semantic, so this pipe fires through the \
2246             borrowed-input From<&Semantic> for &'static str axis and \
2247             witnesses the newly lifted impl's arm-set matches the \
2248             substrate-primitive accessor without a spurious Copy deref"
2249        );
2250    }
2251
2252    #[test]
2253    fn semantic_from_into_owned_string_routes_through_as_str_accessor() {
2254        // Fail-before-pass-after byte-parity pin on the newly lifted
2255        // `impl From<Semantic> for String` — asserts the owned-
2256        // `String`-returning standard-library trait impl and the
2257        // substrate-primitive [`super::Semantic::as_str`] `pub const
2258        // fn` accessor resolve to the same 16-arm canonical-lowercase
2259        // kebab emit-set across every arm the exhaustive
2260        // [`super::Semantic::ALL`] slice enumerates. Rust's standard
2261        // library does not carry a blanket
2262        // `impl<T: AsRef<str>> From<T> for String`, so the owned-
2263        // `String` axis is a distinct trait-idiomatic surface that a
2264        // `let key: String = sem.into();`-shaped downstream call site
2265        // reaches through this impl and no other — the sibling
2266        // `&'static str`-returning axes force an explicit
2267        // `.to_owned()` / [`String::from`] restatement whose type
2268        // bounds have no compile-time link to the substrate primitive.
2269        // Sweeps every one of the 16 arms
2270        // [`super::Semantic::ALL`] carries so no arm's projection is
2271        // covered only by the sibling method-named `as_str` /
2272        // [`std::fmt::Display`] / [`AsRef<str>`] / owned-input
2273        // `&'static str`-returning paths.
2274        //
2275        // Peer of the sibling
2276        // `caixa_provedor::ferrite::tests::ferrite_runtime_from_into_owned_string_routes_through_variant_slug_accessor`
2277        // (1e14fde) and
2278        // `caixa_arch::report::tests::arch_verdict_from_into_owned_string_routes_through_as_str_accessor`
2279        // (cc80a53) pins on the peer outside-`caixa-core` closed-set-
2280        // enum owned-`String`-returning axes — extends the trait-
2281        // idiomatic owned-`String`-returning forward-projection family
2282        // onto the sole closed-set fieldless typed enum on the caixa-
2283        // theme surface (the semantic-style 16-arm axis), extending
2284        // the substrate-wide 2×2-completion campaign onto the sixth
2285        // outside-`caixa-core` closed-set fieldless typed enum on the
2286        // caixa surface.
2287        for &variant in Semantic::ALL {
2288            let via_trait: String = <String as From<Semantic>>::from(variant);
2289            let via_method: &'static str = variant.as_str();
2290            assert_eq!(
2291                via_trait.as_str(),
2292                via_method,
2293                "From<Semantic> for String impl must round-trip \
2294                 Semantic::{variant:?} to the same canonical-lowercase \
2295                 kebab byte-string Semantic::as_str returns — \
2296                 divergence signals a silent detour off the substrate-\
2297                 primitive accessor"
2298            );
2299            let via_into: String = variant.into();
2300            assert_eq!(
2301                via_into.as_str(),
2302                via_method,
2303                "Into<String>::into on Semantic::{variant:?} must \
2304                 byte-equal Semantic::as_str on the same input — the \
2305                 blanket-derived Into shape must resolve to the same \
2306                 as_str dispatch as the explicit From impl"
2307            );
2308        }
2309    }
2310
2311    #[test]
2312    fn semantic_from_into_owned_string_and_static_str_agree_on_every_arm() {
2313        // Cross-axis partition pin: the paired trait-idiomatic
2314        // owned-input `&'static str`-returning
2315        // `From<Semantic> for &'static str` and owned-`String`-
2316        // returning `From<Semantic> for String` (this lift) forward
2317        // projections must resolve identically on every arm, locking
2318        // the two output-shape paths together so any future detour (a
2319        // stray owned-`String` special-case that lands on a divergent
2320        // per-arm literal outside the paired `as_str` dispatch, a
2321        // hypothetical rebrand touching one axis without the other, a
2322        // silent swap onto a hand-rolled per-arm literal that shadows
2323        // the paired [`super::Semantic::as_str`] dispatch) trips at
2324        // caixa-theme test time. Then a witness that the
2325        // `ToString::to_string`-through-[`std::fmt::Display`] surface
2326        // (`variant.to_string()`) byte-equals the trait-idiomatic
2327        // owned-`String` axis (`String::from(variant)`) on every arm,
2328        // so a future consumer that reaches for `.to_string()` and
2329        // one that reaches for `.into::<String>()` land on the same
2330        // substrate-primitive vocabulary. Plus a
2331        // `.iter().copied().map(String::from)` pipe witness over
2332        // [`super::Semantic::ALL`] — the exact shape a future per-
2333        // Semantic histogram key materializer or `caixa-lsp` per-
2334        // `SemanticTokenType` registration walk reaches through —
2335        // materializes the 16-arm accept-set through the owned-
2336        // `String` axis alone. Plus a direct `Self → String → Self`
2337        // round-trip witness through the paired [`TryFrom<&str>`]
2338        // axis on the owned-`String`'s [`String::as_str`] borrow,
2339        // closing the two-way round-trip on the owned-`String` axis
2340        // directly (no wire-vocab intermediate — the emit-side
2341        // [`super::Semantic::as_str`] and the parse-side
2342        // [`super::Semantic::from_wire`] dispatch on the same 16
2343        // inline canonical-lowercase kebab byte-strings by
2344        // construction).
2345        //
2346        // Peer of the sibling
2347        // `caixa_provedor::ferrite::tests::ferrite_runtime_from_into_owned_string_and_static_str_agree_on_every_arm`
2348        // (1e14fde) partition pin on the peer outside-`caixa-core`
2349        // closed-set-enum owned-`String`-returning axis.
2350        for &variant in Semantic::ALL {
2351            let owned_string: String = <String as From<Semantic>>::from(variant);
2352            let owned_static: &'static str = <&'static str as From<Semantic>>::from(variant);
2353            assert_eq!(
2354                owned_string.as_str(),
2355                owned_static,
2356                "From<Semantic> for String and From<Semantic> for \
2357                 &'static str must resolve identically on \
2358                 Semantic::{variant:?} — divergence signals the two \
2359                 output-shape forward-projection paths have drifted \
2360                 onto different emit-sets"
2361            );
2362            let via_display: String = variant.to_string();
2363            assert_eq!(
2364                owned_string, via_display,
2365                "From<Semantic> for String and ToString::to_string \
2366                 via Display must resolve identically on \
2367                 Semantic::{variant:?} — divergence signals the \
2368                 trait-idiomatic owned-`String` axis and the Display-\
2369                 routed ToString axis have drifted onto different \
2370                 vocabularies"
2371            );
2372        }
2373        let via_iter: Vec<String> = Semantic::ALL.iter().copied().map(String::from).collect();
2374        let via_method: Vec<String> = Semantic::ALL
2375            .iter()
2376            .map(|s| s.as_str().to_owned())
2377            .collect();
2378        assert_eq!(
2379            via_iter, via_method,
2380            "`.iter().copied().map(String::from)` over Semantic::ALL \
2381             must byte-equal `.iter().map(|s| s.as_str().to_owned())` \
2382             on every arm — the owned-`String` `From<Semantic> for \
2383             String` axis is what makes the `.map(String::from)` \
2384             shape route through the substrate-primitive \
2385             Semantic::as_str accessor rather than through a per-\
2386             call-site `.to_owned()` / `String::from(sem.as_str())` \
2387             detour"
2388        );
2389        for &variant in Semantic::ALL {
2390            let emitted: String = variant.into();
2391            let re_parsed: Result<Semantic, ()> =
2392                <Semantic as TryFrom<&str>>::try_from(emitted.as_str());
2393            assert_eq!(
2394                re_parsed,
2395                Ok(variant),
2396                "trait-idiomatic owned-`String` axis pair must round-\
2397                 trip Semantic::{variant:?} through \
2398                 `.into::<String>()` and back through `TryFrom<&str>` \
2399                 on the owned-`String`'s `String::as_str` borrow — a \
2400                 break signals the forward-emit owned-`String` axis \
2401                 and the reverse-parse `TryFrom<&str>` axis have \
2402                 drifted onto different vocabularies"
2403            );
2404        }
2405    }
2406
2407    #[test]
2408    fn semantic_from_borrowed_into_owned_string_routes_through_as_str_accessor() {
2409        // Fail-before-pass-after byte-parity pin on the newly lifted
2410        // `impl From<&Semantic> for String` — asserts the borrowed-
2411        // input owned-`String`-returning standard-library trait impl
2412        // and the substrate-primitive [`super::Semantic::as_str`]
2413        // `pub const fn` accessor resolve to the same 16-arm
2414        // canonical-lowercase kebab emit-set across every arm the
2415        // exhaustive [`super::Semantic::ALL`] slice enumerates.
2416        // Rust's standard library does not carry a blanket
2417        // `impl<T: AsRef<str>> From<&T> for String` (nor an
2418        // `impl<T: fmt::Display> From<&T> for String`), so the
2419        // borrowed-input owned-`String` forward-projection axis is a
2420        // distinct trait-idiomatic surface that a
2421        // `let key: String = (&sem).into();`-shaped call site
2422        // reaches through this impl and no other — the paired
2423        // sibling `From<Semantic> for String` impl (5ea146c) forces
2424        // every borrowed-input call site through an explicit `Copy`
2425        // deref (`String::from(*sem)`) or a `.as_str().to_owned()` /
2426        // `.to_string()` detour whose type bounds have no compile-
2427        // time link to the substrate primitive. Sweeps every one of
2428        // the 16 arms [`super::Semantic::ALL`] carries so no arm's
2429        // borrowed-input owned-`String` projection is covered only
2430        // by the sibling method-named `as_str` / [`std::fmt::Display`]
2431        // / [`AsRef<str>`] / owned-input `&'static str`-returning /
2432        // owned-input owned-`String`-returning paths.
2433        //
2434        // Peer of the sibling
2435        // `caixa_provedor::ferrite::tests::ferrite_runtime_from_borrowed_into_owned_string_routes_through_variant_slug_accessor`
2436        // (0caedec — fifth outside-`caixa-core` arm on this axis,
2437        // the paired ferrite-runtime two-arm axis on the sole caixa-
2438        // provedor closed-set enum) and
2439        // `caixa_lint::diagnostic::tests::fix_safety_from_borrowed_into_owned_string_routes_through_as_str_accessor`
2440        // (807f67d — fourth outside-`caixa-core` arm on this axis)
2441        // pins on the peer outside-`caixa-core` closed-set-enum
2442        // borrowed-input owned-`String`-returning axes — closes the
2443        // whole `{Self, &Self} × {&'static str, String}` 2×2 trait-
2444        // idiomatic projection corner on the sixth-and-last outside-
2445        // `caixa-core` closed-set fieldless typed enum on the caixa
2446        // surface (the caixa-theme semantic-style 16-arm axis every
2447        // per-Semantic paint dispatch, every future `caixa-lsp` per-
2448        // `SemanticTokenType` wire-up, every future `caixa.nvim`
2449        // per-highlight-group re-loader, and every future
2450        // `blackmatter-shell` per-arm `data-semantic="<kebab>"` DOM
2451        // emission keys off), and closes the substrate-wide 2×2-
2452        // completion campaign across every closed-set fieldless
2453        // typed enum on the caixa surface.
2454        for &variant in Semantic::ALL {
2455            let via_trait: String = <String as From<&Semantic>>::from(&variant);
2456            let via_method: &'static str = variant.as_str();
2457            assert_eq!(
2458                via_trait.as_str(),
2459                via_method,
2460                "From<&Semantic> for String impl must round-trip \
2461                 &Semantic::{variant:?} to the same canonical-\
2462                 lowercase kebab byte-string Semantic::as_str \
2463                 returns — divergence signals a silent detour off \
2464                 the substrate-primitive accessor"
2465            );
2466            let via_into: String = (&variant).into();
2467            assert_eq!(
2468                via_into.as_str(),
2469                via_method,
2470                "Into<String>::into on &Semantic::{variant:?} must \
2471                 byte-equal Semantic::as_str on the same input — \
2472                 the blanket-derived Into shape must resolve to the \
2473                 same as_str dispatch as the explicit From impl"
2474            );
2475        }
2476    }
2477
2478    #[test]
2479    fn semantic_from_borrowed_into_owned_string_agrees_with_paired_axes_on_every_arm() {
2480        // Cross-axis partition pin: the newly lifted trait-
2481        // idiomatic borrowed-input owned-`String`
2482        // `From<&Semantic> for String` (this lift), the paired
2483        // owned-input owned-`String` `From<Semantic> for String`
2484        // (5ea146c), the paired borrowed-input owned-`&'static str`
2485        // `From<&Semantic> for &'static str` (ffc0f26), and the
2486        // paired owned-input owned-`&'static str`
2487        // `From<Semantic> for &'static str` — every corner of the
2488        // `{Self, &Self} × {&'static str, String}` 2×2 trait-
2489        // idiomatic projection family — must resolve identically on
2490        // every arm, locking the four return-shape × input-shape
2491        // paths together so any future detour trips at caixa-theme
2492        // test time. Also byte-parity witness against the sibling
2493        // [`ToString::to_string`] surface routed through
2494        // [`std::fmt::Display`] and a direct round-trip witness
2495        // through the paired trait-idiomatic reverse
2496        // [`TryFrom<&str>`] axis on the owned-`String`'s
2497        // [`String::as_str`] borrow that closes the two-way
2498        // `&Self → String → Self` round-trip on the trait-idiomatic
2499        // borrowed-input owned-`String` forward + reverse axis pair.
2500        //
2501        // The `.iter().map(String::from)` pipe witness over
2502        // [`super::Semantic::ALL`] materializes the exact shape a
2503        // future per-Semantic histogram key materializer or
2504        // `caixa-lsp` per-`SemanticTokenType` registration walk
2505        // reaches through — [`super::Semantic::ALL`]'s iterator
2506        // yields `&Semantic` by construction, so the borrowed-input
2507        // owned-`String` axis is what routes the pipe through the
2508        // substrate-primitive [`super::Semantic::as_str`] accessor
2509        // without a spurious `.copied()` / `Copy` deref (the paired
2510        // owned-input pipe witness on the sibling
2511        // `semantic_from_into_owned_string_and_static_str_agree_on_every_arm`
2512        // uses `.iter().copied().map(String::from)` for exactly this
2513        // reason — the owned-input axis alone cannot route the pipe
2514        // through the substrate primitive without the extra deref).
2515        //
2516        // Peer of the sibling
2517        // `caixa_provedor::ferrite::tests::ferrite_runtime_from_borrowed_into_owned_string_agrees_with_paired_axes_on_every_arm`
2518        // (0caedec — fifth outside-`caixa-core` arm on this axis)
2519        // partition pin on the peer outside-`caixa-core` closed-
2520        // set-enum borrowed-input owned-`String` axis — closes the
2521        // substrate-wide 2×2-completion campaign on the sixth-and-
2522        // last outside-`caixa-core` closed-set fieldless typed enum
2523        // on the caixa surface.
2524        for &variant in Semantic::ALL {
2525            let borrowed_string: String = <String as From<&Semantic>>::from(&variant);
2526            let owned_string: String = <String as From<Semantic>>::from(variant);
2527            let borrowed_static: &'static str = <&'static str as From<&Semantic>>::from(&variant);
2528            let owned_static: &'static str = <&'static str as From<Semantic>>::from(variant);
2529            assert_eq!(
2530                borrowed_string, owned_string,
2531                "From<&Semantic> for String and From<Semantic> for \
2532                 String must resolve identically on \
2533                 Semantic::{variant:?} — divergence signals the \
2534                 owned-`String` axis pair's borrowed-input and \
2535                 owned-input arms have drifted onto different emit-\
2536                 sets"
2537            );
2538            assert_eq!(
2539                borrowed_string.as_str(),
2540                borrowed_static,
2541                "From<&Semantic> for String and From<&Semantic> for \
2542                 &'static str must resolve identically on \
2543                 Semantic::{variant:?} — divergence signals the \
2544                 borrowed-input axis pair's owned-`String`-returning \
2545                 and `&'static str`-returning arms have drifted \
2546                 onto different emit-sets"
2547            );
2548            assert_eq!(
2549                borrowed_string.as_str(),
2550                owned_static,
2551                "From<&Semantic> for String and From<Semantic> for \
2552                 &'static str must resolve identically on \
2553                 Semantic::{variant:?} — the cross-diagonal corner \
2554                 of the 2×2 must agree, or the four projections \
2555                 have split into two vocabularies"
2556            );
2557            let via_display: String = variant.to_string();
2558            assert_eq!(
2559                borrowed_string, via_display,
2560                "From<&Semantic> for String and ToString::to_string \
2561                 via Display must resolve identically on \
2562                 Semantic::{variant:?} — divergence signals the \
2563                 trait-idiomatic borrowed-input owned-`String` axis \
2564                 and the Display-routed ToString axis have drifted \
2565                 onto different vocabularies"
2566            );
2567        }
2568        let via_iter: Vec<String> = Semantic::ALL.iter().map(String::from).collect();
2569        let via_method: Vec<String> = Semantic::ALL
2570            .iter()
2571            .map(|sem| sem.as_str().to_owned())
2572            .collect();
2573        assert_eq!(
2574            via_iter, via_method,
2575            "`.iter().map(String::from)` over Semantic::ALL must \
2576             byte-equal `.iter().map(|sem| sem.as_str().to_owned())` \
2577             on every arm — the borrowed-input owned-`String` \
2578             `From<&Semantic> for String` axis is what makes the \
2579             `.map(String::from)` shape route through the substrate-\
2580             primitive Semantic::as_str accessor without a spurious \
2581             `.copied()` / `Copy` deref"
2582        );
2583        for &variant in Semantic::ALL {
2584            let emitted: String = (&variant).into();
2585            let re_parsed: Result<Semantic, ()> =
2586                <Semantic as TryFrom<&str>>::try_from(emitted.as_str());
2587            assert_eq!(
2588                re_parsed,
2589                Ok(variant),
2590                "trait-idiomatic borrowed-input owned-`String` axis \
2591                 pair must round-trip Semantic::{variant:?} through \
2592                 `(&variant).into::<String>()` and back through \
2593                 `TryFrom<&str>` on the owned-`String`'s \
2594                 `String::as_str` borrow — a break signals the \
2595                 borrowed-input forward-emit owned-`String` axis \
2596                 and the reverse-parse `TryFrom<&str>` axis have \
2597                 drifted onto different vocabularies"
2598            );
2599        }
2600    }
2601
2602    #[test]
2603    fn semantic_from_into_static_cow_str_routes_through_as_str_accessor() {
2604        // Fail-before-pass-after byte-parity pin on the newly lifted
2605        // `impl From<Semantic> for std::borrow::Cow<'static, str>` —
2606        // asserts the standard-library trait impl and the substrate-
2607        // primitive [`super::Semantic::as_str`] `pub const fn`
2608        // accessor resolve to the same sixteen-arm canonical-
2609        // lowercase kebab emit-set (`"keyword"` / `"symbol"` /
2610        // `"keyword-arg"` / `"string"` / `"number"` / `"literal"` /
2611        // `"comment"` / `"accent"` / `"muted"` / `"error"` /
2612        // `"warning"` / `"info"` / `"hint"` / `"added"` /
2613        // `"removed"` / `"unchanged"`) across every arm the
2614        // exhaustive [`super::Semantic::ALL`] slice enumerates.
2615        // Rust's standard library does not carry a blanket
2616        // `impl<T: AsRef<str>> From<T> for std::borrow::Cow<'static, str>`
2617        // (nor an `impl<T: fmt::Display> From<T> for std::borrow::Cow<'static, str>`),
2618        // so the [`std::borrow::Cow<'static, str>`] forward-projection
2619        // axis is a distinct trait-idiomatic surface that a
2620        // `let key: std::borrow::Cow<'static, str> = sem.into();`-
2621        // shaped call site reaches through this impl and no other —
2622        // the paired sibling `From<Semantic> for &'static str` and
2623        // `From<Semantic> for String` impls force every
2624        // [`std::borrow::Cow<'static, str>`]-parameterized call site
2625        // through a `std::borrow::Cow::Borrowed(sem.as_str())` /
2626        // `std::borrow::Cow::Owned(sem.to_string())` /
2627        // `String::from(sem).into()` composition whose type bounds
2628        // have no compile-time link back to the substrate primitive.
2629        //
2630        // Also asserts the projection lands on the zero-alloc
2631        // [`std::borrow::Cow::Borrowed`] arm (not the
2632        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
2633        // [`super::Semantic::as_str`] accessor's `&'static str`
2634        // return lifetime by construction makes the borrowed arm the
2635        // type-correct projection with no runtime allocation. Any
2636        // future silent detour that routes the impl through the
2637        // owned arm (an accidental
2638        // `std::borrow::Cow::Owned(sem.to_string())` rewrite that
2639        // would allocate on every call site where the `&'static str`
2640        // return of [`super::Semantic::as_str`] makes the zero-alloc
2641        // borrowed projection type-correct) trips at caixa-theme
2642        // test time under the [`std::borrow::Cow::Borrowed`]
2643        // discriminator witness rather than at a downstream
2644        // [`std::borrow::Cow<'static, str>`]-bound consumer's silent
2645        // allocation.
2646        //
2647        // Fifth outside-`caixa-core` peer (and sole peer on the
2648        // caixa-theme surface) on the substrate-wide trait-idiomatic
2649        // [`std::borrow::Cow<'static, str>`] forward-projection
2650        // family — extends the axis off the paired caixa-lint fix-
2651        // safety-tier axis on the sibling two-arm closed-set enum
2652        // ([`caixa_lint::diagnostic::FixSafety`], 79010c5 / 9a6539f
2653        // — fourth outside-`caixa-core` peer, closed the 2×3 corner)
2654        // onto the semantic-style sixteen-arm axis, continuing the
2655        // outside-`caixa-core` tier of the campaign.
2656        for &variant in Semantic::ALL {
2657            let via_trait: std::borrow::Cow<'static, str> =
2658                <std::borrow::Cow<'static, str> as From<Semantic>>::from(variant);
2659            let via_method: &'static str = variant.as_str();
2660            assert_eq!(
2661                via_trait.as_ref(),
2662                via_method,
2663                "From<Semantic> for Cow<'static, str> impl must round-\
2664                 trip Semantic::{variant:?} to the same canonical-\
2665                 lowercase kebab byte-string Semantic::as_str returns \
2666                 — divergence signals a silent detour off the \
2667                 substrate-primitive accessor"
2668            );
2669            assert!(
2670                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
2671                "From<Semantic> for Cow<'static, str> impl must land \
2672                 on the zero-alloc Cow::Borrowed arm on \
2673                 Semantic::{variant:?} — a Cow::Owned outcome \
2674                 signals the projection has silently allocated where \
2675                 the substrate-primitive Semantic::as_str \
2676                 `&'static str` return makes the borrowed arm the \
2677                 type-correct projection"
2678            );
2679            let via_into: std::borrow::Cow<'static, str> = variant.into();
2680            assert_eq!(
2681                via_into.as_ref(),
2682                via_method,
2683                "Into<Cow<'static, str>>::into on \
2684                 Semantic::{variant:?} must byte-equal \
2685                 Semantic::as_str on the same input — the blanket-\
2686                 derived Into shape must resolve to the same as_str \
2687                 dispatch as the explicit From impl"
2688            );
2689            assert!(
2690                matches!(via_into, std::borrow::Cow::Borrowed(_)),
2691                "Into<Cow<'static, str>>::into on \
2692                 Semantic::{variant:?} must land on the zero-alloc \
2693                 Cow::Borrowed arm — the blanket-derived Into shape \
2694                 must resolve to the same Cow::Borrowed dispatch as \
2695                 the explicit From impl"
2696            );
2697        }
2698    }
2699
2700    #[test]
2701    fn semantic_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
2702        // Cross-axis partition pin: the newly lifted trait-idiomatic
2703        // `From<Semantic> for std::borrow::Cow<'static, str>` (this
2704        // lift), the paired owned-input
2705        // `From<Semantic> for &'static str`, and the paired owned-
2706        // input `From<Semantic> for String` forward projections must
2707        // resolve identically on every arm, locking the three return-
2708        // shape paths together by construction so any future detour
2709        // trips at caixa-theme test time. Also byte-parity witness
2710        // against the sibling [`ToString::to_string`] surface routed
2711        // through [`std::fmt::Display`] — every owned-heap-string
2712        // path (the [`std::borrow::Cow::Owned`] promotion of this
2713        // axis's `.into_owned()`, `From<Semantic> for String`, and
2714        // `.to_string()`) resolves to the same canonical-lowercase
2715        // kebab byte-string per arm.
2716        //
2717        // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
2718        // witness over [`super::Semantic::ALL`] that materializes
2719        // the sixteen-arm accept-set through the
2720        // [`std::borrow::Cow<'static, str>`] axis alone — the exact
2721        // shape a future `feira lint --list-styles` operator-facing
2722        // enumeration, a future `caixa-lsp`-side per-
2723        // `SemanticTokenType` registration table whose typing rules
2724        // out the sibling [`AsRef<str>`] borrowed return, or a
2725        // future `caixa.nvim` per-highlight-group re-loader table
2726        // reaches through — closing the composable-projection axis
2727        // on the caixa-theme semantic-style sixteen-arm closed-set
2728        // fieldless typed enum peer. The pipe witness also pins the
2729        // zero-alloc discipline: every element in the collected
2730        // vector satisfies the [`std::borrow::Cow::Borrowed`] arm
2731        // predicate, so a future accidental silent-allocation
2732        // regression on the pipe's iteration axis is a caixa-theme-
2733        // test-time failure.
2734        //
2735        // Then a direct round-trip witness through [`TryFrom<&str>`]
2736        // on the projection's [`std::borrow::Cow::as_ref`] borrow —
2737        // like the sibling [`caixa_lint::diagnostic::FixSafety`]
2738        // and [`caixa_lint::diagnostic::Severity`] pairs (whose
2739        // canonical-lowercase byte-strings are round-trip-stable),
2740        // and unlike the peer [`caixa_core::CaixaKind`] pair (whose
2741        // forward emit lands on the lowercase Portuguese diagnostic
2742        // vocabulary while the reverse parse lands on the
2743        // `PascalCase` wire vocabulary), [`super::Semantic`]'s
2744        // forward emit and reverse parse share the same sixteen
2745        // inline canonical-lowercase kebab byte-strings by
2746        // construction, so the [`std::borrow::Cow<'static, str>`]
2747        // projection composes directly with the trait-idiomatic
2748        // reverse [`TryFrom<&str>`] axis without the wire-vocab
2749        // intermediate hop.
2750        for &variant in Semantic::ALL {
2751            let via_cow: std::borrow::Cow<'static, str> =
2752                <std::borrow::Cow<'static, str> as From<Semantic>>::from(variant);
2753            let via_static: &'static str = <&'static str as From<Semantic>>::from(variant);
2754            let via_string: String = <String as From<Semantic>>::from(variant);
2755            assert_eq!(
2756                via_cow.as_ref(),
2757                via_static,
2758                "From<Semantic> for Cow<'static, str> and \
2759                 From<Semantic> for &'static str must resolve \
2760                 identically on Semantic::{variant:?} — divergence \
2761                 signals the Cow<'static, str> and &'static str \
2762                 return-shape paths have drifted onto different \
2763                 emit-sets"
2764            );
2765            assert_eq!(
2766                via_cow.as_ref(),
2767                via_string.as_str(),
2768                "From<Semantic> for Cow<'static, str> and \
2769                 From<Semantic> for String must resolve identically \
2770                 on Semantic::{variant:?} — divergence signals the \
2771                 Cow<'static, str> and String return-shape paths \
2772                 have drifted onto different emit-sets"
2773            );
2774            let via_to_string: String = variant.to_string();
2775            assert_eq!(
2776                via_cow.as_ref(),
2777                via_to_string.as_str(),
2778                "From<Semantic> for Cow<'static, str> must byte-\
2779                 equal Semantic::to_string on Semantic::{variant:?} \
2780                 — divergence signals the trait-idiomatic \
2781                 Cow<'static, str> forward-projection axis and the \
2782                 ToString-through-Display axis have drifted onto \
2783                 different emit-sets"
2784            );
2785        }
2786        let via_iter: Vec<std::borrow::Cow<'static, str>> = Semantic::ALL
2787            .iter()
2788            .copied()
2789            .map(std::borrow::Cow::from)
2790            .collect();
2791        let via_method: Vec<std::borrow::Cow<'static, str>> = Semantic::ALL
2792            .iter()
2793            .map(|sem| std::borrow::Cow::Borrowed(sem.as_str()))
2794            .collect();
2795        assert_eq!(
2796            via_iter, via_method,
2797            "`.iter().copied().map(Cow::from)` over Semantic::ALL \
2798             must byte-equal `.iter().map(|sem| \
2799             Cow::Borrowed(sem.as_str()))` on every arm — the trait-\
2800             idiomatic `From<Semantic> for Cow<'static, str>` axis \
2801             is what makes the `Cow::from` composition route through \
2802             the substrate-primitive Semantic::as_str accessor \
2803             rather than a per-call-site open-code"
2804        );
2805        for cow in &via_iter {
2806            assert!(
2807                matches!(cow, std::borrow::Cow::Borrowed(_)),
2808                "`.iter().copied().map(Cow::from)` over \
2809                 Semantic::ALL must land on the zero-alloc \
2810                 Cow::Borrowed arm on every element — a Cow::Owned \
2811                 outcome signals the pipe has silently allocated \
2812                 where the substrate-primitive Semantic::as_str \
2813                 `&'static str` return makes the borrowed arm the \
2814                 type-correct projection"
2815            );
2816        }
2817        for &variant in Semantic::ALL {
2818            let via_cow: std::borrow::Cow<'static, str> =
2819                <std::borrow::Cow<'static, str> as From<Semantic>>::from(variant);
2820            let re_parsed: Result<Semantic, ()> =
2821                <Semantic as TryFrom<&str>>::try_from(via_cow.as_ref());
2822            assert_eq!(
2823                re_parsed,
2824                Ok(variant),
2825                "trait-idiomatic Cow<'static, str> forward-projection \
2826                 + reverse-projection axis pair must round-trip \
2827                 Semantic::{variant:?} through \
2828                 `.into::<Cow<'static, str>>()` on the owned-input \
2829                 surface and back through `TryFrom<&str>` on the \
2830                 projection's Cow::as_ref borrow — a break signals \
2831                 the Cow<'static, str> forward-emit and reverse-\
2832                 parse axes have drifted onto different vocabularies \
2833                 (like the sibling FixSafety and Severity pairs, \
2834                 Semantic's forward emit and reverse parse share \
2835                 the same sixteen inline canonical-lowercase kebab \
2836                 byte-strings by construction, so the round-trip \
2837                 composes directly)"
2838            );
2839        }
2840    }
2841
2842    #[test]
2843    fn semantic_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
2844        // Fail-before-pass-after byte-parity pin on the newly lifted
2845        // `impl From<&Semantic> for std::borrow::Cow<'static, str>` —
2846        // asserts the borrowed-input standard-library trait impl and
2847        // the substrate-primitive [`super::Semantic::as_str`]
2848        // `pub const fn` accessor resolve to the same sixteen-arm
2849        // canonical-lowercase kebab emit-set (`"keyword"` / `"symbol"` /
2850        // `"keyword-arg"` / `"string"` / `"number"` / `"literal"` /
2851        // `"comment"` / `"accent"` / `"muted"` / `"error"` /
2852        // `"warning"` / `"info"` / `"hint"` / `"added"` / `"removed"` /
2853        // `"unchanged"`) across every arm the exhaustive
2854        // [`super::Semantic::ALL`] slice enumerates. Rust's standard
2855        // library does not carry a blanket
2856        // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
2857        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
2858        // the borrowed-input `Cow<'static, str>` forward-projection
2859        // axis is a distinct trait-idiomatic surface that a
2860        // `let key: Cow<'static, str> = (&sem).into();`-shaped call
2861        // site or a `Semantic::ALL.iter().map(Cow::from)`-shaped pipe
2862        // reaches through this impl and no other — the paired owned-
2863        // input `From<Semantic> for Cow<'static, str>` impl (0253688)
2864        // forces every borrowed-input call site through an explicit
2865        // `Copy` deref (`Cow::from(*sem)`) or a
2866        // `Cow::Borrowed(sem.as_str())` open-code whose type bounds
2867        // have no compile-time link back to the substrate primitive.
2868        //
2869        // Also asserts the projection lands on the zero-alloc
2870        // [`std::borrow::Cow::Borrowed`] arm (not the
2871        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
2872        // [`super::Semantic::as_str`] accessor's `&'static str` return
2873        // lifetime by construction makes the borrowed arm the type-
2874        // correct projection with no runtime allocation on the
2875        // borrowed-input surface just as on the paired owned-input
2876        // surface.
2877        //
2878        // Closes the `{Self, &Self}` input-shape corner on the fifth
2879        // outside-`caixa-core` closed-set fieldless typed enum peer
2880        // of the substrate-wide [`std::borrow::Cow<'static, str>`]
2881        // forward-projection campaign, exactly as
2882        // `fix_safety_from_borrowed_into_static_cow_str_routes_through_as_str_accessor`
2883        // (9a6539f) closed it on the sibling caixa-lint
2884        // [`caixa_lint::diagnostic::FixSafety`] one commit after
2885        // (79010c5) closing the whole 2×3 corner,
2886        // `severity_from_borrowed_into_static_cow_str_routes_through_as_str_accessor`
2887        // (1819087) on [`caixa_lint::diagnostic::Severity`] one commit
2888        // after (700a95e) closing the whole 2×3 corner, and every
2889        // peer closer that preceded it on the campaign.
2890        for &variant in Semantic::ALL {
2891            let via_trait: std::borrow::Cow<'static, str> =
2892                <std::borrow::Cow<'static, str> as From<&Semantic>>::from(&variant);
2893            let via_method: &'static str = variant.as_str();
2894            assert_eq!(
2895                via_trait.as_ref(),
2896                via_method,
2897                "From<&Semantic> for Cow<'static, str> impl must \
2898                 round-trip &Semantic::{variant:?} to the same \
2899                 canonical-lowercase kebab byte-string \
2900                 Semantic::as_str returns — divergence signals a \
2901                 silent detour off the substrate-primitive accessor"
2902            );
2903            assert!(
2904                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
2905                "From<&Semantic> for Cow<'static, str> impl must \
2906                 land on the zero-alloc Cow::Borrowed arm on \
2907                 &Semantic::{variant:?} — a Cow::Owned outcome \
2908                 signals the projection has silently allocated where \
2909                 the substrate-primitive Semantic::as_str \
2910                 `&'static str` return makes the borrowed arm the \
2911                 type-correct projection"
2912            );
2913            let via_into: std::borrow::Cow<'static, str> = (&variant).into();
2914            assert_eq!(
2915                via_into.as_ref(),
2916                via_method,
2917                "Into<Cow<'static, str>>::into on \
2918                 &Semantic::{variant:?} must byte-equal \
2919                 Semantic::as_str on the same input — the blanket-\
2920                 derived Into shape on the borrowed-input surface \
2921                 must resolve to the same as_str dispatch as the \
2922                 explicit From impl"
2923            );
2924            assert!(
2925                matches!(via_into, std::borrow::Cow::Borrowed(_)),
2926                "Into<Cow<'static, str>>::into on \
2927                 &Semantic::{variant:?} must land on the zero-alloc \
2928                 Cow::Borrowed arm — the blanket-derived Into shape \
2929                 on the borrowed-input surface must resolve to the \
2930                 same Cow::Borrowed dispatch as the explicit From \
2931                 impl"
2932            );
2933        }
2934    }
2935
2936    #[test]
2937    #[allow(
2938        clippy::too_many_lines,
2939        reason = "cross-axis partition pin folds four return-shape paths \
2940                  (borrowed-input Cow<'static, str>, owned-input Cow<'static, str>, \
2941                  borrowed-input &'static str, borrowed-input String) plus the \
2942                  ToString-through-Display witness plus a `.iter().map(Cow::from)` \
2943                  pipe witness with zero-alloc discriminator plus a direct \
2944                  round-trip witness through TryFrom<&str> over sixteen typed \
2945                  variants; the linear per-axis repetition is exactly what the \
2946                  fold is pinning — a helper would hide the shape it locks"
2947    )]
2948    fn semantic_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
2949        // Cross-axis partition pin: the newly lifted trait-idiomatic
2950        // borrowed-input `From<&Semantic> for
2951        // std::borrow::Cow<'static, str>` (this lift), the paired
2952        // owned-input `From<Semantic> for
2953        // std::borrow::Cow<'static, str>` (0253688), the paired
2954        // borrowed-input `From<&Semantic> for &'static str`, and the
2955        // paired borrowed-input `From<&Semantic> for String` forward
2956        // projections must resolve identically on every arm, locking
2957        // the four return-shape paths together by construction so any
2958        // future detour trips at caixa-theme test time. Also byte-
2959        // parity witness against the sibling [`ToString::to_string`]
2960        // surface routed through [`std::fmt::Display`].
2961        //
2962        // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
2963        // over [`super::Semantic::ALL`] — whose iterator yields
2964        // `&Semantic` by construction, so the borrowed-input
2965        // [`std::borrow::Cow<'static, str>`] axis is what routes the
2966        // pipe through the substrate-primitive
2967        // [`super::Semantic::as_str`] accessor with the zero-alloc
2968        // [`std::borrow::Cow::Borrowed`] arm and without a spurious
2969        // [`Copy`] deref. Every collected element satisfies the
2970        // [`std::borrow::Cow::Borrowed`]-arm predicate so a future
2971        // accidental silent-allocation regression on the pipe's
2972        // iteration axis is a caixa-theme-test-time failure.
2973        //
2974        // Then a direct round-trip witness through [`TryFrom<&str>`]
2975        // on the projection's [`std::borrow::Cow::as_ref`] borrow —
2976        // unlike the peer [`caixa_core::CaixaKind`] axis pair (whose
2977        // forward emit lands on the lowercase Portuguese diagnostic
2978        // vocabulary while the reverse parse lands on the
2979        // `PascalCase` wire vocabulary, forcing the round-trip
2980        // through an intermediate [`caixa_core::CaixaKind::wire_name`]
2981        // hop), [`super::Semantic`]'s forward emit and reverse parse
2982        // share the same sixteen inline canonical-lowercase kebab
2983        // byte-strings by construction, so the borrowed-input
2984        // [`std::borrow::Cow<'static, str>`] projection composes
2985        // directly with the trait-idiomatic reverse [`TryFrom<&str>`]
2986        // axis without the wire-vocab intermediate hop.
2987        for &variant in Semantic::ALL {
2988            let via_borrowed_cow: std::borrow::Cow<'static, str> =
2989                <std::borrow::Cow<'static, str> as From<&Semantic>>::from(&variant);
2990            let via_owned_cow: std::borrow::Cow<'static, str> =
2991                <std::borrow::Cow<'static, str> as From<Semantic>>::from(variant);
2992            let via_borrowed_static: &'static str =
2993                <&'static str as From<&Semantic>>::from(&variant);
2994            let via_borrowed_string: String = <String as From<&Semantic>>::from(&variant);
2995            assert_eq!(
2996                via_borrowed_cow.as_ref(),
2997                via_owned_cow.as_ref(),
2998                "From<&Semantic> for Cow<'static, str> and \
2999                 From<Semantic> for Cow<'static, str> must resolve \
3000                 identically on Semantic::{variant:?} — divergence \
3001                 signals the borrowed-input and owned-input \
3002                 Cow<'static, str> forward-projection input-shape \
3003                 paths have drifted onto different emit-sets"
3004            );
3005            assert_eq!(
3006                via_borrowed_cow.as_ref(),
3007                via_borrowed_static,
3008                "From<&Semantic> for Cow<'static, str> and \
3009                 From<&Semantic> for &'static str must resolve \
3010                 identically on Semantic::{variant:?} — divergence \
3011                 signals the borrowed-input Cow<'static, str> and \
3012                 borrowed-input `&'static str` return-shape paths \
3013                 have drifted onto different emit-sets"
3014            );
3015            assert_eq!(
3016                via_borrowed_cow.as_ref(),
3017                via_borrowed_string.as_str(),
3018                "From<&Semantic> for Cow<'static, str> and \
3019                 From<&Semantic> for String must resolve identically \
3020                 on Semantic::{variant:?} — divergence signals the \
3021                 borrowed-input Cow<'static, str> and borrowed-input \
3022                 owned-`String` return-shape paths have drifted onto \
3023                 different emit-sets"
3024            );
3025            let via_to_string: String = variant.to_string();
3026            assert_eq!(
3027                via_borrowed_cow.as_ref(),
3028                via_to_string.as_str(),
3029                "From<&Semantic> for Cow<'static, str> must byte-\
3030                 equal Semantic::to_string on Semantic::{variant:?} \
3031                 — divergence signals the trait-idiomatic borrowed-\
3032                 input Cow<'static, str> forward-projection axis and \
3033                 the ToString-through-Display axis have drifted onto \
3034                 different emit-sets"
3035            );
3036            assert!(
3037                matches!(via_borrowed_cow, std::borrow::Cow::Borrowed(_)),
3038                "From<&Semantic> for Cow<'static, str> must land on \
3039                 the zero-alloc Cow::Borrowed arm on \
3040                 &Semantic::{variant:?} — a Cow::Owned outcome \
3041                 signals the borrowed-input surface has silently \
3042                 allocated where the substrate-primitive \
3043                 Semantic::as_str `&'static str` return makes the \
3044                 borrowed arm the type-correct projection"
3045            );
3046        }
3047        let via_iter: Vec<std::borrow::Cow<'static, str>> =
3048            Semantic::ALL.iter().map(std::borrow::Cow::from).collect();
3049        let via_method: Vec<std::borrow::Cow<'static, str>> = Semantic::ALL
3050            .iter()
3051            .map(|sem| std::borrow::Cow::Borrowed(sem.as_str()))
3052            .collect();
3053        assert_eq!(
3054            via_iter, via_method,
3055            "`.iter().map(Cow::from)` over Semantic::ALL — a call \
3056             site whose iteration axis holds `&Semantic` by \
3057             construction — must byte-equal `.iter().map(|sem| \
3058             Cow::Borrowed(sem.as_str()))` on every arm — the \
3059             borrowed-input `From<&Semantic> for Cow<'static, str>` \
3060             axis is what makes the `Cow::from` composition route \
3061             through the substrate-primitive `Semantic::as_str` \
3062             accessor without a spurious `Copy` deref (which would \
3063             only be reachable through the owned-input \
3064             `From<Semantic> for Cow<'static, str>` axis by first \
3065             calling `.copied()` on the iterator)"
3066        );
3067        for cow in &via_iter {
3068            assert!(
3069                matches!(cow, std::borrow::Cow::Borrowed(_)),
3070                "`.iter().map(Cow::from)` over Semantic::ALL must \
3071                 land on the zero-alloc Cow::Borrowed arm on every \
3072                 element — a Cow::Owned outcome signals the pipe has \
3073                 silently allocated through the borrowed-input axis \
3074                 where the substrate-primitive Semantic::as_str \
3075                 `&'static str` return makes the borrowed arm the \
3076                 type-correct projection"
3077            );
3078        }
3079        for &variant in Semantic::ALL {
3080            let via_cow: std::borrow::Cow<'static, str> =
3081                <std::borrow::Cow<'static, str> as From<&Semantic>>::from(&variant);
3082            let re_parsed: Result<Semantic, ()> =
3083                <Semantic as TryFrom<&str>>::try_from(via_cow.as_ref());
3084            assert_eq!(
3085                re_parsed,
3086                Ok(variant),
3087                "trait-idiomatic borrowed-input Cow<'static, str> \
3088                 forward-projection + reverse-projection axis pair \
3089                 must round-trip &Semantic::{variant:?} through \
3090                 `(&variant).into::<Cow<'static, str>>()` on the \
3091                 borrowed-input surface and back through \
3092                 `TryFrom<&str>` on the projection's Cow::as_ref \
3093                 borrow — a break signals the borrowed-input \
3094                 Cow<'static, str> forward-emit and reverse-parse \
3095                 axes have drifted onto different vocabularies \
3096                 (unlike the peer CaixaKind axis pair, Semantic's \
3097                 forward emit and reverse parse share the same \
3098                 sixteen inline canonical-lowercase kebab byte-\
3099                 strings by construction, so the round-trip composes \
3100                 directly)"
3101            );
3102        }
3103    }
3104
3105    #[test]
3106    fn semantic_from_into_box_str_routes_through_as_str_accessor() {
3107        // Fail-before-pass-after byte-parity pin on the newly lifted
3108        // `impl From<Semantic> for Box<str>` — asserts the owned-input
3109        // standard-library trait impl and the substrate-primitive
3110        // [`super::Semantic::as_str`] `pub const fn` accessor resolve
3111        // to the same sixteen-arm canonical-lowercase kebab emit-set
3112        // across every arm the exhaustive [`super::Semantic::ALL`]
3113        // slice enumerates. Extends the outside-`caixa-core` tier of
3114        // the substrate-wide [`Box<str>`] forward-projection campaign
3115        // onto the fifth peer — the caixa-theme semantic-style
3116        // sixteen-arm closed-set fieldless typed enum — following the
3117        // first-mover [`caixa_arch::invariants::InvariantKind`] pair
3118        // (10613a7 owned + 5901887 borrowed), second-peer
3119        // [`caixa_arch::report::ArchVerdict`] pair (3e08f5a owned +
3120        // c4319a8 borrowed), third-peer [`super::Severity`] pair
3121        // (5116c95), and fourth-peer [`super::FixSafety`] pair
3122        // (cf0174b) that landed the tier one axis prior. Rust's
3123        // standard library carries `impl From<&str> for Box<str>` and
3124        // `impl From<String> for Box<str>` but no blanket
3125        // `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is
3126        // a distinct trait-idiomatic surface that a
3127        // `let key: Box<str> = sem.into();`-shaped call site reaches
3128        // through this impl and no other — a paired
3129        // `Box::from(sem.as_str())` open-code has no compile-time link
3130        // back to the substrate primitive.
3131        for &variant in Semantic::ALL {
3132            let via_trait: Box<str> = <Box<str> as From<Semantic>>::from(variant);
3133            let via_method: &'static str = variant.as_str();
3134            assert_eq!(
3135                via_trait.as_ref(),
3136                via_method,
3137                "From<Semantic> for Box<str> impl must round-trip \
3138                 Semantic::{variant:?} to the same canonical-lowercase \
3139                 kebab byte-string Semantic::as_str returns — \
3140                 divergence signals a silent detour off the substrate-\
3141                 primitive accessor"
3142            );
3143            let via_into: Box<str> = variant.into();
3144            assert_eq!(
3145                via_into.as_ref(),
3146                via_method,
3147                "Into<Box<str>>::into on Semantic::{variant:?} must \
3148                 byte-equal Semantic::as_str on the same input — the \
3149                 blanket-derived Into shape must resolve to the same \
3150                 as_str dispatch as the explicit From impl"
3151            );
3152        }
3153    }
3154
3155    #[test]
3156    fn semantic_from_borrowed_into_box_str_routes_through_as_str_accessor() {
3157        // Fail-before-pass-after byte-parity pin on the newly lifted
3158        // `impl From<&Semantic> for Box<str>` — asserts the borrowed-
3159        // input standard-library trait impl and the substrate-
3160        // primitive [`super::Semantic::as_str`] `pub const fn`
3161        // accessor resolve to the same sixteen-arm canonical-lowercase
3162        // kebab emit-set across every arm the exhaustive
3163        // [`super::Semantic::ALL`] slice enumerates. Rust's standard
3164        // library carries `impl From<&str> for Box<str>` and
3165        // `impl From<String> for Box<str>` but no blanket
3166        // `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-
3167        // based `impl<T: Copy, U: From<T>> From<&T> for U`), so the
3168        // borrowed-input [`Box<str>`] forward-projection axis is a
3169        // distinct trait-idiomatic surface that a
3170        // `Semantic::ALL.iter().map(Box::<str>::from)`-shaped pipe
3171        // (whose iterator over `&'static [Semantic]` yields
3172        // `&Semantic` by construction) or a `let key: Box<str> =
3173        // (&sem).into();`-shaped call site reaches through this impl
3174        // and no other — the paired owned-input
3175        // `From<Semantic> for Box<str>` impl alone would force every
3176        // borrowed-input call site through an explicit `Copy` deref
3177        // (`Box::<str>::from(*sem)`) or a
3178        // `Box::<str>::from(sem.as_str())` open-code whose type bounds
3179        // have no compile-time link back to the substrate primitive.
3180        //
3181        // Closes the `{Self, &Self}` input-shape corner on the fifth
3182        // outside-`caixa-core` closed-set fieldless typed enum peer of
3183        // the substrate-wide [`Box<str>`] forward-projection campaign,
3184        // exactly as 5901887 closed the paired first-mover
3185        // `InvariantKind` axis one commit after (10613a7) landed,
3186        // c4319a8 closed the paired second-peer `ArchVerdict` axis one
3187        // commit after (3e08f5a) landed, 5116c95 landed the paired
3188        // third-peer `Severity` pair one axis prior, cf0174b landed
3189        // the paired fourth-peer `FixSafety` pair one axis prior,
3190        // cb1d068 closed the paired M2-OTP-shape `RestartPolicy` axis
3191        // one commit after (0a1b313) landed, and 3c971b2 closed the
3192        // paired M3-mesh-shape `PlacementStrategy` axis one commit
3193        // after (6d73e84) landed.
3194        for &variant in Semantic::ALL {
3195            let via_trait: Box<str> = <Box<str> as From<&Semantic>>::from(&variant);
3196            let via_method: &'static str = variant.as_str();
3197            assert_eq!(
3198                via_trait.as_ref(),
3199                via_method,
3200                "From<&Semantic> for Box<str> impl must round-trip \
3201                 &Semantic::{variant:?} to the same canonical-\
3202                 lowercase kebab byte-string Semantic::as_str returns \
3203                 — divergence signals a silent detour off the \
3204                 substrate-primitive accessor"
3205            );
3206            let via_into: Box<str> = (&variant).into();
3207            assert_eq!(
3208                via_into.as_ref(),
3209                via_method,
3210                "Into<Box<str>>::into on &Semantic::{variant:?} must \
3211                 byte-equal Semantic::as_str on the same input — the \
3212                 blanket-derived Into shape on the borrowed-input \
3213                 surface must resolve to the same as_str dispatch as \
3214                 the explicit From impl"
3215            );
3216        }
3217
3218        // Pipe witness — the distinguishing shape that forces the
3219        // borrowed-input axis to be independent of the owned-input
3220        // peer. `Semantic::ALL.iter()` yields `&Semantic` by
3221        // construction, so `.map(Box::<str>::from)` resolves through
3222        // the borrowed-input `From<&Semantic> for Box<str>` impl and
3223        // no other — without this axis, the same pipe would force an
3224        // explicit `.copied()` restatement whose type bounds bypass
3225        // the substrate primitive.
3226        let via_pipe: Vec<Box<str>> = Semantic::ALL.iter().map(Box::<str>::from).collect();
3227        let via_accessor: Vec<&'static str> = Semantic::ALL.iter().map(|s| s.as_str()).collect();
3228        assert_eq!(
3229            via_pipe.len(),
3230            via_accessor.len(),
3231            "Semantic::ALL.iter().map(Box::<str>::from) pipe must \
3232             preserve arity against the paired Semantic::as_str \
3233             accessor — a length divergence signals the borrowed-input \
3234             axis has silently rejected an arm"
3235        );
3236        for (pipe_arm, accessor_arm) in via_pipe.iter().zip(via_accessor.iter()) {
3237            assert_eq!(
3238                pipe_arm.as_ref(),
3239                *accessor_arm,
3240                "Semantic::ALL.iter().map(Box::<str>::from) pipe must \
3241                 byte-equal the paired Semantic::ALL.iter().map(|s| \
3242                 s.as_str()) pipe on every arm — divergence signals \
3243                 the borrowed-input `From<&Semantic> for Box<str>` \
3244                 axis has silently detoured off the substrate-\
3245                 primitive accessor"
3246            );
3247        }
3248    }
3249}