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#[cfg(test)]
1094mod tests {
1095    use super::*;
1096
1097    #[test]
1098    fn semantic_all_enumerates_every_variant_in_declaration_order() {
1099        // Fail-before-pass-after pin on the [`Semantic::ALL`] slice:
1100        // the slice must list every one of the 15 variants in
1101        // declaration order (Keyword → Symbol → KeywordArg → String →
1102        // Number → Literal → Comment → Accent → Muted → Error →
1103        // Warning → Info → Hint → Added → Removed → Unchanged). Peer
1104        // of the sibling ALL slices on the closed-set typed-enum
1105        // discriminator axes ([`caixa_core::CaixaKind::ALL`],
1106        // [`caixa_core::supervisor::RestartStrategy::ALL`],
1107        // [`caixa_core::supervisor::RestartPolicy::ALL`],
1108        // [`caixa_core::aplicacao::PlacementStrategy::ALL`],
1109        // [`caixa_core::upgrade::UpgradeInstruction::ALL`]). A future
1110        // arm addition (a `Namespace` tier between `Symbol` and
1111        // `KeywordArg` for the M4 tatara-lisp module system's
1112        // qualified-name semantic-token dispatch, a `Deleted` tier
1113        // for a hard-delete-mark distinct from `Removed` the future
1114        // 3-way diff surface grows) that lands the arm on the enum
1115        // but forgets to extend `ALL` must trip this pin rather than
1116        // surface as a downstream consumer's silently-partial
1117        // iteration.
1118        assert_eq!(
1119            Semantic::ALL,
1120            &[
1121                Semantic::Keyword,
1122                Semantic::Symbol,
1123                Semantic::KeywordArg,
1124                Semantic::String,
1125                Semantic::Number,
1126                Semantic::Literal,
1127                Semantic::Comment,
1128                Semantic::Accent,
1129                Semantic::Muted,
1130                Semantic::Error,
1131                Semantic::Warning,
1132                Semantic::Info,
1133                Semantic::Hint,
1134                Semantic::Added,
1135                Semantic::Removed,
1136                Semantic::Unchanged,
1137            ],
1138        );
1139        // Also pin the per-arm `IsVariant`-derived partition: every
1140        // arm in `ALL` must satisfy exactly one of the 15 generated
1141        // arm-discriminator predicates.
1142        for variant in Semantic::ALL {
1143            let row = [
1144                variant.is_keyword(),
1145                variant.is_symbol(),
1146                variant.is_keyword_arg(),
1147                variant.is_string(),
1148                variant.is_number(),
1149                variant.is_literal(),
1150                variant.is_comment(),
1151                variant.is_accent(),
1152                variant.is_muted(),
1153                variant.is_error(),
1154                variant.is_warning(),
1155                variant.is_info(),
1156                variant.is_hint(),
1157                variant.is_added(),
1158                variant.is_removed(),
1159                variant.is_unchanged(),
1160            ];
1161            let hits = row.iter().filter(|b| **b).count();
1162            assert_eq!(
1163                hits, 1,
1164                "Semantic::{variant:?} must satisfy exactly one of the \
1165                 15 is_* arm-discriminator predicates; got {row:?}",
1166            );
1167        }
1168    }
1169
1170    #[test]
1171    fn semantic_is_variant_predicates_partition_the_arm_set() {
1172        // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
1173        // derive: for each of the 15 variants, exactly one of the
1174        // generated is_* predicates returns `true` and the other 14
1175        // return `false`. Pre-derive the closed 15-arm partition
1176        // lived only inside the two theme overlays' 15-arm match
1177        // resolvers; a future rebrand (a `#[is_variant(name = "…")]`
1178        // drift, a manual hand-rolled `impl` that shadows the
1179        // derive-generated method, an arm rename) trips this pin at
1180        // caixa-theme build time rather than surfacing far from the
1181        // derive declaration. Peer of the sibling
1182        // [`caixa_core::CaixaKind`] `IsVariant` partition pin.
1183        // A copy-paste flip that reroutes one arm through the wrong
1184        // predicate lane trips at the identity-diagonal assertion,
1185        // since each variant's row is generated live from `ALL`'s
1186        // declaration order rather than transcribed by hand.
1187        for (idx, variant) in Semantic::ALL.iter().enumerate() {
1188            let observed: [bool; 16] = [
1189                variant.is_keyword(),
1190                variant.is_symbol(),
1191                variant.is_keyword_arg(),
1192                variant.is_string(),
1193                variant.is_number(),
1194                variant.is_literal(),
1195                variant.is_comment(),
1196                variant.is_accent(),
1197                variant.is_muted(),
1198                variant.is_error(),
1199                variant.is_warning(),
1200                variant.is_info(),
1201                variant.is_hint(),
1202                variant.is_added(),
1203                variant.is_removed(),
1204                variant.is_unchanged(),
1205            ];
1206            let mut expected = [false; 16];
1207            expected[idx] = true;
1208            assert_eq!(
1209                observed, expected,
1210                "Semantic::{variant:?} at ALL[{idx}] is_* predicates \
1211                 must fire only on their own arm lane (identity \
1212                 diagonal); got {observed:?}",
1213            );
1214        }
1215    }
1216
1217    #[test]
1218    fn semantic_as_str_returns_canonical_kebab_case_per_arm() {
1219        // Fail-before-pass-after per-arm byte-string pin on
1220        // [`Semantic::as_str`] — the substrate-canonical `&'static str`
1221        // projection every downstream consumer of the closed 16-arm
1222        // partition reaches through. A future arm rename (a `Symbol` →
1223        // `Identifier` rebrand tracking a hypothetical LSP-side
1224        // `SemanticTokenType` reshuffle, an `Accent` → `Highlight`
1225        // rebrand tracking a `blackmatter-shell` classname rework) that
1226        // touches the enum arm but forgets to update the paired
1227        // `as_str` arm — or vice versa — trips this pin at caixa-theme
1228        // build time rather than surfacing as a downstream
1229        // `feira lint --list-styles` operator-facing enumeration verb's
1230        // silently-renamed row far from the two-declaration site.
1231        //
1232        // Kebab-case matches the peer [`gen_platform::IsVariant`]-
1233        // derived kebab discriminant convention the sibling closed-set
1234        // typed enums already emit on their canonical byte-string
1235        // projection axis.
1236        assert_eq!(Semantic::Keyword.as_str(), "keyword");
1237        assert_eq!(Semantic::Symbol.as_str(), "symbol");
1238        assert_eq!(Semantic::KeywordArg.as_str(), "keyword-arg");
1239        assert_eq!(Semantic::String.as_str(), "string");
1240        assert_eq!(Semantic::Number.as_str(), "number");
1241        assert_eq!(Semantic::Literal.as_str(), "literal");
1242        assert_eq!(Semantic::Comment.as_str(), "comment");
1243        assert_eq!(Semantic::Accent.as_str(), "accent");
1244        assert_eq!(Semantic::Muted.as_str(), "muted");
1245        assert_eq!(Semantic::Error.as_str(), "error");
1246        assert_eq!(Semantic::Warning.as_str(), "warning");
1247        assert_eq!(Semantic::Info.as_str(), "info");
1248        assert_eq!(Semantic::Hint.as_str(), "hint");
1249        assert_eq!(Semantic::Added.as_str(), "added");
1250        assert_eq!(Semantic::Removed.as_str(), "removed");
1251        assert_eq!(Semantic::Unchanged.as_str(), "unchanged");
1252    }
1253
1254    #[test]
1255    fn semantic_as_str_projections_are_all_distinct_across_arms() {
1256        // Fail-before-pass-after pin on the injectivity of
1257        // [`Semantic::as_str`]'s projection — no two arms may share
1258        // their canonical kebab byte-string, since a future consumer
1259        // that keys a per-arm dispatch table off the projection (a
1260        // `HashMap::<&str, _>::from_iter(Semantic::ALL.iter().map(|s|
1261        // (s.as_str(), …)))` style-lookup, a future `caixa-lsp`
1262        // `SemanticTokenType::new(sem.as_ref())` registration table
1263        // keyed by kebab identifier, a future `feira lint --list-styles`
1264        // one-row-per-arm enumeration table) would silently collapse
1265        // the two colliding arms onto one entry, dropping the second
1266        // insertion. A future arm addition (a `Namespace` tier between
1267        // `Symbol` and `KeywordArg` for the M4 tatara-lisp module
1268        // system's qualified-name semantic-token dispatch, a `Deleted`
1269        // tier for a hard-delete-mark distinct from `Removed` a future
1270        // 3-way diff surface grows) that lands the arm on the enum and
1271        // reuses a peer arm's kebab identifier (a copy-paste-derived
1272        // `"removed"` on the new `Deleted` arm) trips this pin rather
1273        // than surfacing far from the arm addition site.
1274        let mut projections: Vec<&'static str> = Semantic::ALL.iter().map(|s| s.as_str()).collect();
1275        let before = projections.len();
1276        projections.sort_unstable();
1277        projections.dedup();
1278        assert_eq!(
1279            projections.len(),
1280            before,
1281            "Semantic::as_str must be injective across ALL — collisions: \
1282             {projections:?}",
1283        );
1284    }
1285
1286    #[test]
1287    fn semantic_display_and_as_ref_str_route_through_as_str_accessor() {
1288        // Fail-before-pass-after three-path convergence pin on the
1289        // substrate-wide `(as_str, AsRef<str>, Display)` canonical-
1290        // projection triple for the caixa-theme [`Semantic`] closed-set
1291        // fieldless typed enum. For every arm in [`Semantic::ALL`], the
1292        // paired [`std::fmt::Display`] impl + [`AsRef<str>`] impl + the
1293        // substrate-canonical [`Semantic::as_str`] `pub const fn`
1294        // scalar accessor must resolve to the same `&'static str`
1295        // per arm. Peer of the sibling three-path-convergence pins the
1296        // substrate carries on the closed-set typed enums the prior
1297        // lifts converged onto
1298        // (`restart_strategy_display_routes_through_as_str_helper` /
1299        // `restart_strategy_as_ref_str_routes_through_as_str_accessor`
1300        // on [`caixa_core::supervisor::RestartStrategy`],
1301        // `ferrite_runtime_display_and_as_ref_str_route_through_variant_slug_accessor`
1302        // on `caixa_provedor::FerriteRuntime`, and the analogous pins
1303        // on `caixa_lint::Severity` / `caixa_lint::FixSafety` /
1304        // `caixa_arch::InvariantKind` / `caixa_arch::ArchVerdict`).
1305        //
1306        // A future accidental split (a hand-rolled `impl fmt::Display`
1307        // that shadows this route through a divergent per-arm match, an
1308        // `impl AsRef<str>` that returns the compiler-derived `Debug`
1309        // string via `format!("{:?}", self)` — allocating and diverging
1310        // on every arm — or a `#[serde(rename_all = "…")]` attribute
1311        // drift that quietly forks the projection) trips this pin at
1312        // caixa-theme build time rather than surfacing as a downstream
1313        // consumer's silently-forked per-Semantic dispatch far from the
1314        // trait-impl declaration site.
1315        for &sem in Semantic::ALL {
1316            let via_as_str: &str = sem.as_str();
1317            let via_display: String = format!("{sem}");
1318            let via_as_ref: &str = <Semantic as AsRef<str>>::as_ref(&sem);
1319            assert_eq!(
1320                via_display, via_as_str,
1321                "Semantic::{sem:?} — Display routes off `as_str`; got \
1322                 Display={via_display:?} vs as_str={via_as_str:?}",
1323            );
1324            assert_eq!(
1325                via_as_ref, via_as_str,
1326                "Semantic::{sem:?} — AsRef<str> routes off `as_str`; got \
1327                 AsRef={via_as_ref:?} vs as_str={via_as_str:?}",
1328            );
1329        }
1330    }
1331
1332    #[test]
1333    fn semantic_as_str_is_usable_in_const_context() {
1334        // The [`Semantic::as_str`] accessor is declared `pub const fn`,
1335        // matching the peer closed-set typed enums' canonical
1336        // `&'static str` projection accessors
1337        // ([`caixa_core::CaixaKind::as_str`],
1338        // [`caixa_core::supervisor::RestartStrategy::as_str`],
1339        // [`caixa_core::aplicacao::PlacementStrategy::as_str`],
1340        // `caixa_provedor::FerriteRuntime::variant_slug`). Pin the
1341        // same posture with a `const {}` assertion block so a future
1342        // accidental downgrade to non-`const` (an added runtime helper
1343        // reachable only from a non-`const` context) trips at
1344        // caixa-theme build time rather than surfacing as a downstream
1345        // `const`-context regression far from the accessor
1346        // declaration.
1347        const KEYWORD: &str = Semantic::Keyword.as_str();
1348        const ERROR: &str = Semantic::Error.as_str();
1349        const UNCHANGED: &str = Semantic::Unchanged.as_str();
1350        const { assert!(KEYWORD.as_bytes()[0] == b'k') };
1351        const { assert!(ERROR.as_bytes()[0] == b'e') };
1352        const { assert!(UNCHANGED.as_bytes()[0] == b'u') };
1353    }
1354
1355    #[test]
1356    fn semantic_from_wire_accepts_every_as_str_output() {
1357        // Fail-before-pass-after per-arm accept pin on the newly lifted
1358        // [`Semantic::from_wire`] reverse projection: every arm in
1359        // [`Semantic::ALL`] must parse back through `from_wire` when fed
1360        // its own [`Semantic::as_str`] output, landing on
1361        // `Some(same_variant)`. A regression that hand-rolled either
1362        // side's per-arm match without threading through the shared
1363        // 16-string closed set would silently disagree on any future
1364        // arm rename (a `Symbol` → `Identifier` rebrand tracking a
1365        // hypothetical LSP-side `SemanticTokenType` reshuffle, an
1366        // `Accent` → `Highlight` rebrand tracking a `blackmatter-shell`
1367        // classname rework) or new arm the theme grows (a `Namespace`
1368        // tier between `Symbol` and `KeywordArg` for the M4 tatara-lisp
1369        // module system's qualified-name semantic-token dispatch, a
1370        // `Deleted` tier for a hard-delete-mark distinct from `Removed`
1371        // the future 3-way diff surface grows) and this pin flags it at
1372        // caixa-theme build time rather than at a downstream
1373        // `feira lint --list-styles` operator-facing enumeration verb's
1374        // silent tag misclassification.
1375        //
1376        // Peer of the sibling
1377        // `caixa_lint::diagnostic::tests::severity_from_wire_accepts_every_as_str_output`
1378        // (5afff0e) /
1379        // `caixa_lint::diagnostic::tests::fix_safety_from_wire_accepts_every_as_str_output`
1380        // (bd505a1) /
1381        // `caixa_arch::report::tests::arch_verdict_from_wire_accepts_every_as_str_output`
1382        // (6afe564) /
1383        // `caixa_arch::invariants::tests::invariant_kind_from_wire_accepts_every_as_str_output`
1384        // (b9e4e61) round-trip pins on the peer caixa-lint / caixa-arch
1385        // closed-set-enum reverse-projection axes, and of the sibling
1386        // `caixa_core::kind::tests::caixa_kind_wire_round_trips_through_from_wire`
1387        // (2aa6d23) /
1388        // `caixa_core::dialeto::tests::caixa_dialeto_from_wire_accepts_every_as_str_output`
1389        // (d0e65ea) /
1390        // `caixa_core::aplicacao::tests::placement_strategy_from_wire_accepts_every_lifted_constant`
1391        // (18c7342) /
1392        // `caixa_core::dep::tests::dep_list_round_trips_through_as_str_and_from_wire`
1393        // (45ee563) /
1394        // `caixa_core::render::tests::path_shape_violation_from_wire_accepts_every_as_str_output`
1395        // (aebd9c6) round-trip pins on the sibling caixa-core closed-
1396        // set typed-enum reverse-projection axes.
1397        for &variant in Semantic::ALL {
1398            let wire = variant.as_str();
1399            let parsed = Semantic::from_wire(wire).unwrap_or_else(|| {
1400                panic!(
1401                    "Semantic::from_wire({wire:?}) must accept every \
1402                     Semantic::as_str output — got None for the wire \
1403                     byte-string of {variant:?}"
1404                )
1405            });
1406            assert_eq!(
1407                parsed, variant,
1408                "Semantic::from_wire(Semantic::{variant:?}.as_str()) \
1409                 must return Semantic::{variant:?} — the (as_str, \
1410                 from_wire) pair must form a total round-trip on the \
1411                 closed 16-arm Semantic arm-set",
1412            );
1413        }
1414    }
1415
1416    #[test]
1417    fn semantic_from_wire_rejects_unknown_byte_strings() {
1418        // Rejection pin on the [`Semantic::from_wire`] parser's accept-
1419        // set: any string outside the 16-arm [`Semantic::as_str`] output
1420        // set must return `None`. A future accidental widening of the
1421        // accept-set (a case-insensitive match that accepts `"KEYWORD"`
1422        // / `"Keyword"`, a silent acceptance of the pre-lift PascalCase
1423        // Debug-derived shapes `"Keyword"` / `"KeywordArg"` /
1424        // `"Unchanged"` on the wire axis, a snake_case drift accepting
1425        // `"keyword_arg"` beside the canonical kebab-case
1426        // `"keyword-arg"`, a Levenshtein-forgiving arm-lookup that
1427        // admits `"kewyord"` typos, a silent absorption of a hypothetical
1428        // future `Namespace` / `Deleted` arm before it lands on the enum
1429        // and its paired [`Semantic::as_str`] emitter arm) would
1430        // silently drift the parser's accept-set from the emitter's — a
1431        // downstream style-report re-loader that bound a prior report's
1432        // [`Self::as_str`] output back to the typed enum through this
1433        // parser would then bind a malformed byte-string to a plausibly-
1434        // wrong typed arm the caller does not route through any
1435        // fallback, silently misclassifying the reloaded row.
1436        //
1437        // Peer of the sibling
1438        // `caixa_lint::diagnostic::tests::severity_from_wire_rejects_unknown_byte_strings`
1439        // (5afff0e) /
1440        // `caixa_lint::diagnostic::tests::fix_safety_from_wire_rejects_unknown_byte_strings`
1441        // (bd505a1) /
1442        // `caixa_arch::report::tests::arch_verdict_from_wire_rejects_unknown_byte_strings`
1443        // (6afe564) /
1444        // `caixa_arch::invariants::tests::invariant_kind_from_wire_rejects_unknown_byte_strings`
1445        // (b9e4e61) rejection pins on the peer caixa-lint / caixa-arch
1446        // axes, and of the sibling
1447        // `caixa_kind_from_wire_rejects_unknown_byte_strings` (2aa6d23),
1448        // `caixa_dialeto_from_wire_rejects_unknown_byte_strings`
1449        // (d0e65ea),
1450        // `placement_strategy_from_wire_rejects_unknown_byte_strings`
1451        // (18c7342),
1452        // `dep_list_from_wire_returns_none_on_unknown_wire_scalar`
1453        // (45ee563), and
1454        // `path_shape_violation_from_wire_rejects_unknown_byte_strings`
1455        // (aebd9c6) rejection pins on the sibling caixa-core axes.
1456        //
1457        // The rejection set also covers overlapping-byte-string tags
1458        // from peer axes: caixa-lint `Severity::as_str` outputs
1459        // `"error"`/`"warning"`/`"info"`/`"hint"` and caixa-arch
1460        // `InvariantKind::as_str` outputs `"safety"`/`"compliance"`
1461        // share zero canonical byte-strings with the widened 16-arm
1462        // Semantic set here — a widened parser that admitted the peer's
1463        // arm on the sibling axis would still not admit an arm foreign
1464        // to the caixa-theme semantic-style discriminator's own accept-
1465        // set. Yet four peer-axis strings DO overlap with the
1466        // caixa-theme set here (`Severity`'s
1467        // `"error"`/`"warning"`/`"info"`/`"hint"` map identically onto
1468        // the caixa-theme diagnostic-severity sub-region
1469        // `Semantic::Error`/`Warning`/`Info`/`Hint`) — a widened parser
1470        // that admitted them under a different arm would collapse the
1471        // two axes and silently mislabel; the pin excludes those four
1472        // from the rejection set precisely because they must accept.
1473        for bad in [
1474            "",
1475            " ",
1476            "Keyword",
1477            "KEYWORD",
1478            "Symbol",
1479            "SYMBOL",
1480            "KeywordArg",
1481            "keyword_arg",
1482            "keywordarg",
1483            "String",
1484            "STRING",
1485            "Number",
1486            "Literal",
1487            "Comment",
1488            "Accent",
1489            "Muted",
1490            "Error",
1491            "ERROR",
1492            "Warning",
1493            "WARNING",
1494            "Info",
1495            "INFO",
1496            "Hint",
1497            "HINT",
1498            "Added",
1499            "ADDED",
1500            "Removed",
1501            "REMOVED",
1502            "Unchanged",
1503            "UNCHANGED",
1504            "kewyord",
1505            "sym",
1506            "kw",
1507            "str",
1508            "num",
1509            "lit",
1510            "cmt",
1511            "safe",
1512            "unsafe",
1513            "safety",
1514            "compliance",
1515            "proven",
1516            "rejected",
1517            "namespace",
1518            "deleted",
1519            "highlight",
1520            "identifier",
1521            "keyword ",
1522            " keyword",
1523            "keyword\n",
1524            "keyword\t",
1525            "keyword-arg ",
1526            " keyword-arg",
1527            "added ",
1528            " added",
1529            "unchanged ",
1530            " unchanged",
1531        ] {
1532            assert!(
1533                Semantic::from_wire(bad).is_none(),
1534                "Semantic::from_wire({bad:?}) must return None — the \
1535                 parser's accept-set is exactly the 16 Semantic::as_str \
1536                 outputs; a widening would silently split the parser's \
1537                 accept-set from the emitter's arm-set",
1538            );
1539        }
1540    }
1541
1542    #[test]
1543    fn semantic_is_variant_predicates_are_const_fn() {
1544        // The [`gen_platform::IsVariant`] derive emits `const fn`
1545        // predicates on the peer [`caixa_core::CaixaKind`] /
1546        // [`caixa_core::upgrade::UpgradeInstruction`] /
1547        // [`caixa_core::supervisor::RestartStrategy`] /
1548        // [`caixa_core::supervisor::RestartPolicy`] closed-set typed
1549        // enums — pin the same posture on [`Semantic`] so a future
1550        // accidental downgrade to non-`const` (an added runtime helper
1551        // reachable only from a non-`const` context, a manual hand-
1552        // rolled `impl` that shadows the derive-generated method)
1553        // trips at caixa-theme build time rather than surfacing as a
1554        // downstream `const`-context regression far from the derive
1555        // declaration.
1556        const { assert!(Semantic::Keyword.is_keyword()) };
1557        const { assert!(Semantic::Error.is_error()) };
1558        const { assert!(Semantic::Added.is_added()) };
1559        const { assert!(Semantic::Unchanged.is_unchanged()) };
1560    }
1561
1562    #[test]
1563    fn semantic_try_from_str_routes_through_from_wire_accessor() {
1564        // Fail-before-pass-after byte-parity pin on the newly lifted
1565        // `impl TryFrom<&str> for Semantic` — asserts the standard-
1566        // library trait impl and the substrate-primitive
1567        // [`super::Semantic::from_wire`] `Option<Self>` accessor
1568        // resolve to the same 16-arm accept-set across every arm the
1569        // exhaustive [`super::Semantic::ALL`] slice enumerates. Any
1570        // future silent detour that routes the trait impl through a
1571        // divergent projection (a per-arm inline `match s { "keyword"
1572        // => Ok(Self::Keyword), … }` re-inlining that opens a
1573        // compile-time link to the un-lifted arm-literal, a silent
1574        // case-fold that admits `"Keyword"` / `"KEYWORD"` and would
1575        // collide the canonical-lowercase accept-set the emitter
1576        // dispatches on) trips at caixa-theme test time under
1577        // `assert_eq!` rather than at a downstream
1578        // `impl TryFrom<&str>`-bound consumer's silent split. Sweeps
1579        // every one of the 16 arms [`super::Semantic::ALL`] carries so
1580        // no arm's projection is covered only by the sibling method-
1581        // named `from_wire` path.
1582        //
1583        // Peer of the sibling
1584        // [`caixa_core::kind::tests::caixa_kind_try_from_str_routes_through_from_wire_accessor`]
1585        // (3c83606),
1586        // [`caixa_core::dialeto::tests::caixa_dialeto_try_from_str_routes_through_from_wire_accessor`]
1587        // (bf33136),
1588        // `placement_strategy_try_from_str_routes_through_from_wire_accessor`
1589        // (6fd00cd),
1590        // `rate_limit_unit_try_from_str_routes_through_from_suffix_accessor`
1591        // (bf78400),
1592        // `path_shape_violation_try_from_str_routes_through_from_wire_accessor`
1593        // (e67e48a),
1594        // `caixa_arch::invariants::tests::invariant_kind_try_from_str_routes_through_from_wire_accessor`
1595        // (e21a857),
1596        // `caixa_arch::report::tests::arch_verdict_try_from_str_routes_through_from_wire_accessor`
1597        // (0a4cc45),
1598        // `caixa_lint::diagnostic::tests::severity_try_from_str_routes_through_from_wire_accessor`
1599        // (a7bf74c), and
1600        // `caixa_lint::diagnostic::tests::fix_safety_try_from_str_routes_through_from_wire_accessor`
1601        // (df86c94) — extends the trait-idiomatic reverse-projection
1602        // axis onto the first closed-set fieldless typed enum on the
1603        // caixa-theme surface (the semantic-style axis).
1604        for &variant in Semantic::ALL {
1605            let wire = variant.as_str();
1606            assert_eq!(
1607                <Semantic as TryFrom<&str>>::try_from(wire),
1608                Ok(variant),
1609                "TryFrom<&str> impl on Semantic must round-trip \
1610                 Semantic::{variant:?}.as_str() = {wire:?} back to \
1611                 Ok(Semantic::{variant:?}) — divergence from \
1612                 Semantic::from_wire signals a silent detour off the \
1613                 substrate-primitive accessor",
1614            );
1615            assert_eq!(
1616                <Semantic as TryFrom<&str>>::try_from(wire).ok(),
1617                Semantic::from_wire(wire),
1618                "TryFrom<&str> ok()-projection on {wire:?} must \
1619                 byte-equal Semantic::from_wire on the same input",
1620            );
1621        }
1622    }
1623
1624    #[test]
1625    fn semantic_try_from_str_rejects_unknown_byte_strings() {
1626        // Rejection witness on the `impl TryFrom<&str> for Semantic` —
1627        // sweeps a candidate set of byte-strings outside the 16-arm
1628        // canonical-lowercase kebab wire accept-set the sibling
1629        // [`super::Semantic::as_str`] emits and asserts every one
1630        // lands on `Err(())`, so a future accidental widening of the
1631        // trait impl's accept-set (a stray additional
1632        // `_ if s.eq_ignore_ascii_case("keyword") => Ok(…)` case-fold
1633        // path, a silent acceptance of the pre-lift PascalCase Debug-
1634        // derived shapes `"Keyword"` / `"Symbol"` / `"KeywordArg"` on
1635        // the wire axis, a Levenshtein-forgiving arm-lookup that
1636        // admits `"kwd"` / `"sym"` / `"kw"` typos — the exact form a
1637        // `format!("{:?}", …).to_lowercase()` round-trip on the paired
1638        // [`std::fmt::Debug`] derive would otherwise land on) trips at
1639        // caixa-theme test time. The candidate set includes the empty
1640        // string, whitespace-only padding, uppercase / PascalCase
1641        // rebrand candidates, Levenshtein-neighbor typos, sibling
1642        // closed-set-enum canonical tags not shared with this axis
1643        // (peer `caixa_lint::diagnostic::FixSafety::as_str` two-arm
1644        // `"safe"` / `"unsafe"`, peer `caixa_arch::InvariantKind::as_str`
1645        // three-arm `"safety"` / `"compliance"`, peer
1646        // `caixa_arch::ArchVerdict::as_str` two-arm `"proven"` /
1647        // `"rejected"`), the trajectory-item candidates
1648        // (`"namespace"`, `"deleted"`) the sibling [`Semantic::ALL`]
1649        // doc block already names, whitespace-padded canonical tags,
1650        // and CamelCase spellings of the multi-word `KeywordArg`
1651        // variant (`"KeywordArg"`, `"keywordarg"`, `"keyword_arg"`,
1652        // `"keyword.arg"`) that would silently admit
1653        // if the accept-set widened to a case-fold or separator-
1654        // normalization rule.
1655        //
1656        // Peer of the sibling
1657        // `caixa_kind_try_from_str_rejects_unknown_byte_strings`
1658        // (3c83606),
1659        // `caixa_dialeto_try_from_str_rejects_unknown_byte_strings`
1660        // (bf33136),
1661        // `rate_limit_unit_try_from_str_rejects_unknown_byte_strings`
1662        // (bf78400),
1663        // `path_shape_violation_try_from_str_rejects_unknown_byte_strings`
1664        // (e67e48a),
1665        // `invariant_kind_try_from_str_rejects_unknown_byte_strings`
1666        // (e21a857),
1667        // `arch_verdict_try_from_str_rejects_unknown_byte_strings`
1668        // (0a4cc45),
1669        // `severity_try_from_str_rejects_unknown_byte_strings`
1670        // (a7bf74c), and
1671        // `fix_safety_try_from_str_rejects_unknown_byte_strings`
1672        // (df86c94) rejection pins on the sibling closed-set typed-
1673        // enum trait-idiomatic reverse-projection axes.
1674        for bad in [
1675            "",
1676            " ",
1677            "Keyword",
1678            "KEYWORD",
1679            "Symbol",
1680            "KeywordArg",
1681            "keywordarg",
1682            "keyword_arg",
1683            "keyword.arg",
1684            "String",
1685            "Number",
1686            "Literal",
1687            "Comment",
1688            "Accent",
1689            "Muted",
1690            "Error",
1691            "ERROR",
1692            "Warning",
1693            "Info",
1694            "Hint",
1695            "Added",
1696            "Removed",
1697            "Unchanged",
1698            "kwd",
1699            "sym",
1700            "kw",
1701            "str",
1702            "num",
1703            "lit",
1704            "cmt",
1705            "safe",
1706            "unsafe",
1707            "safety",
1708            "compliance",
1709            "proven",
1710            "rejected",
1711            "namespace",
1712            "deleted",
1713            "highlight",
1714            "identifier",
1715            "keyword ",
1716            " keyword",
1717            "keyword\n",
1718            "keyword\t",
1719            "keyword-arg ",
1720            " keyword-arg",
1721            "added ",
1722            " added",
1723            "unchanged ",
1724            " unchanged",
1725        ] {
1726            assert_eq!(
1727                <Semantic as TryFrom<&str>>::try_from(bad),
1728                Err(()),
1729                "TryFrom<&str> for Semantic({bad:?}) must return \
1730                 Err(()) — the trait impl's accept-set is exactly the \
1731                 16 Semantic::as_str outputs; a widening would \
1732                 silently split the trait impl's accept-set from the \
1733                 emitter's arm-set",
1734            );
1735        }
1736    }
1737
1738    #[test]
1739    fn semantic_try_from_str_and_from_wire_partition_the_accept_set() {
1740        // Cross-axis partition pin: the trait-idiomatic
1741        // [`TryFrom<&str>`] and the method-named
1742        // [`super::Semantic::from_wire`] projections must return
1743        // equivalent decisions on every input — the trait impl's
1744        // `.ok()` project-out from `Result<Self, ()>` and the method's
1745        // `Option<Self>` return must byte-equal each other on both
1746        // accepts and rejects. A future silent bifurcation (the trait
1747        // impl gaining a case-fold path the method does not carry, the
1748        // method gaining a synonym alias the trait impl does not
1749        // honor) trips at caixa-theme test time under a single pin
1750        // rather than at a downstream generic-bound consumer that
1751        // dispatches through one axis while a peer dispatches through
1752        // the other. Sweeps both the 16-arm accept-set (via
1753        // [`super::Semantic::ALL`] threaded through
1754        // [`super::Semantic::as_str`]) and a canonical rejection
1755        // sample so both halves of the partition are covered. Peer of
1756        // the sibling
1757        // `severity_try_from_str_and_from_wire_partition_the_accept_set`
1758        // (a7bf74c) and
1759        // `fix_safety_try_from_str_and_from_wire_partition_the_accept_set`
1760        // (df86c94) partition pins.
1761        for &variant in Semantic::ALL {
1762            let wire = variant.as_str();
1763            assert_eq!(
1764                <Semantic as TryFrom<&str>>::try_from(wire).ok(),
1765                Semantic::from_wire(wire),
1766                "TryFrom<&str>::ok() and from_wire must agree on \
1767                 Semantic::{variant:?}.as_str() = {wire:?}",
1768            );
1769        }
1770        for bad in [
1771            "",
1772            "Keyword",
1773            "unknown",
1774            "safety",
1775            "safe",
1776            "proven",
1777            "namespace",
1778            "keywordarg",
1779        ] {
1780            assert_eq!(
1781                <Semantic as TryFrom<&str>>::try_from(bad).ok(),
1782                Semantic::from_wire(bad),
1783                "TryFrom<&str>::ok() and from_wire must agree on the \
1784                 rejection outcome for {bad:?}",
1785            );
1786        }
1787    }
1788
1789    #[test]
1790    fn semantic_from_into_static_str_routes_through_as_str_accessor() {
1791        // Fail-before-pass-after byte-parity pin on the newly lifted
1792        // `impl From<Semantic> for &'static str` — asserts the standard-
1793        // library trait impl and the substrate-primitive
1794        // [`super::Semantic::as_str`] `pub const fn` accessor resolve to
1795        // the same 16-arm canonical-lowercase kebab emit-set across every
1796        // arm the exhaustive [`super::Semantic::ALL`] slice enumerates.
1797        // Any future silent detour that routes the trait impl through a
1798        // divergent projection (a per-arm inline `match sem { Keyword =>
1799        // "keyword", … }` re-inlining that opens a compile-time link to
1800        // the un-lifted arm-literal outside the paired
1801        // [`super::Semantic::as_str`] dispatch, a swap onto a
1802        // `format!("{:?}", …).to_lowercase()` round-trip through the
1803        // `#[derive(Debug)]` output whose stability is *not* guaranteed
1804        // and would silently reroute the semantic-style tag through a
1805        // stale byte-string with no downstream signal until an operator
1806        // scrolled the theme-paint terminal, a `#[serde(rename_all = "…")]`
1807        // attribute drift that quietly forks one axis) trips at
1808        // caixa-theme test time under `assert_eq!` rather than at a
1809        // downstream `impl Into<&'static str>`-bound consumer's silent
1810        // split. Sweeps every one of the 16 arms
1811        // [`super::Semantic::ALL`] carries so no arm's projection is
1812        // covered only by the sibling method-named `as_str` /
1813        // [`std::fmt::Display`] / [`AsRef<str>`] paths. Materializes
1814        // three `<&'static str as From<Semantic>>::from` outputs in
1815        // `const`-shape bindings against the paired
1816        // [`super::Semantic::as_str`] `pub const fn` accessor to make
1817        // the `'static` lifetime promise a build-time invariant — a
1818        // future accidental downgrade of any arm's inline canonical-
1819        // lowercase kebab byte-string to a non-`&'static str` (a
1820        // `String::leak()`-produced return, a `Box::leak`-cast, an
1821        // intermediate lifetime-erasing helper) trips at caixa-theme
1822        // build time rather than at a downstream `'static`-bound
1823        // consumer.
1824        //
1825        // Peer of the sibling
1826        // [`caixa_core::supervisor::tests::restart_strategy_from_into_static_str_routes_through_as_str_accessor`]
1827        // (523157d),
1828        // [`caixa_core::supervisor::tests::restart_policy_from_into_static_str_routes_through_as_str_accessor`]
1829        // (9fb37d0),
1830        // [`caixa_core::kind::tests::caixa_kind_from_into_static_str_routes_through_as_str_accessor`]
1831        // (edb827b),
1832        // [`caixa_core::dialeto::tests::caixa_dialeto_from_into_static_str_routes_through_as_str_accessor`]
1833        // (c189a6f),
1834        // [`caixa_core::aplicacao::tests::placement_strategy_from_into_static_str_routes_through_as_str_accessor`]
1835        // (afa3562),
1836        // [`caixa_core::aplicacao::tests::wit_shape_from_into_static_str_routes_through_as_str_accessor`]
1837        // (56998ec),
1838        // [`caixa_core::aplicacao::tests::rate_limit_unit_from_into_static_str_routes_through_as_suffix_accessor`]
1839        // (7fdfbf4),
1840        // [`caixa_core::render::tests::path_shape_violation_from_into_static_str_routes_through_as_str_accessor`]
1841        // (070a6de),
1842        // `caixa_arch::invariants::tests::invariant_kind_from_into_static_str_routes_through_as_str_accessor`
1843        // (f2ca7bc),
1844        // `caixa_arch::report::tests::arch_verdict_from_into_static_str_routes_through_as_str_accessor`
1845        // (d4559cb),
1846        // `caixa_lint::diagnostic::tests::severity_from_into_static_str_routes_through_as_str_accessor`
1847        // (5cc3b8b), and
1848        // `caixa_lint::diagnostic::tests::fix_safety_from_into_static_str_routes_through_as_str_accessor`
1849        // (2a56127) pins on the sibling closed-set typed-enum forward-
1850        // projection axes — extends the trait-idiomatic forward-
1851        // projection axis onto the first closed-set fieldless typed
1852        // enum on the caixa-theme surface (the semantic-style axis),
1853        // leaving `caixa_provedor::FerriteRuntime` as the last outside-
1854        // caixa-core closed-set fieldless typed enum whose trait-
1855        // idiomatic forward axis is still open.
1856        const KEYWORD: &str = Semantic::Keyword.as_str();
1857        const KEYWORD_ARG: &str = Semantic::KeywordArg.as_str();
1858        const UNCHANGED: &str = Semantic::Unchanged.as_str();
1859        for &variant in Semantic::ALL {
1860            let via_trait: &'static str = <&'static str as From<Semantic>>::from(variant);
1861            let via_method: &'static str = variant.as_str();
1862            assert_eq!(
1863                via_trait, via_method,
1864                "From<Semantic> for &'static str impl must round-trip \
1865                 Semantic::{variant:?} to the same canonical-lowercase \
1866                 kebab byte-string Semantic::as_str returns — divergence \
1867                 signals a silent detour off the substrate-primitive \
1868                 accessor"
1869            );
1870            let via_into: &'static str = variant.into();
1871            assert_eq!(
1872                via_into, via_method,
1873                "Into<&'static str>::into on Semantic::{variant:?} must \
1874                 byte-equal Semantic::as_str on the same input — the \
1875                 blanket-derived Into shape must resolve to the same \
1876                 as_str dispatch as the explicit From impl"
1877            );
1878        }
1879        assert_eq!(
1880            [KEYWORD, KEYWORD_ARG, UNCHANGED],
1881            ["keyword", "keyword-arg", "unchanged"],
1882            "const-context Semantic::as_str must resolve to the \
1883             canonical-lowercase kebab byte-strings — a future \
1884             accidental downgrade of any arm to a non-const or non-\
1885             static byte-string breaks the `&'static str`-lifetime \
1886             promise the paired From<Semantic> for &'static str impl \
1887             carries by construction"
1888        );
1889    }
1890
1891    #[test]
1892    fn semantic_from_into_static_str_and_as_str_partition_the_emit_set() {
1893        // Cross-axis partition pin: the paired trait-idiomatic
1894        // `From<Semantic> for &'static str` forward projection and the
1895        // method-named [`super::Semantic::as_str`] forward projection
1896        // must resolve identically on *every* arm, not just the ones
1897        // named in the primary byte-parity pin above. Sweeps every
1898        // [`super::Semantic::ALL`] arm and asserts the trait's
1899        // `From::from` output byte-equals the method-named accessor's
1900        // return-value on each, locking the two forward-projection paths
1901        // together by construction so any future detour (a stray `From`
1902        // special-case that lands on a divergent per-arm literal outside
1903        // the paired `as_str` dispatch, a hypothetical rebrand touching
1904        // one axis without the other) trips at caixa-theme test time.
1905        //
1906        // Peer of the sibling forward-projection partition pins
1907        // [`caixa_core::supervisor::tests::restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`]
1908        // (523157d),
1909        // [`caixa_core::supervisor::tests::restart_policy_from_into_static_str_and_as_str_partition_the_emit_set`]
1910        // (9fb37d0),
1911        // [`caixa_core::kind::tests::caixa_kind_from_into_static_str_and_as_str_partition_the_emit_set`]
1912        // (edb827b),
1913        // [`caixa_core::dialeto::tests::caixa_dialeto_from_into_static_str_and_as_str_partition_the_emit_set`]
1914        // (c189a6f),
1915        // [`caixa_core::aplicacao::tests::placement_strategy_from_into_static_str_and_as_str_partition_the_emit_set`]
1916        // (afa3562),
1917        // [`caixa_core::aplicacao::tests::wit_shape_from_into_static_str_and_as_str_partition_the_emit_set`]
1918        // (56998ec),
1919        // [`caixa_core::aplicacao::tests::rate_limit_unit_from_into_static_str_and_as_suffix_partition_the_emit_set`]
1920        // (7fdfbf4),
1921        // [`caixa_core::render::tests::path_shape_violation_from_into_static_str_and_as_str_partition_the_emit_set`]
1922        // (070a6de),
1923        // `caixa_arch::invariants::tests::invariant_kind_from_into_static_str_and_as_str_partition_the_emit_set`
1924        // (f2ca7bc),
1925        // `caixa_arch::report::tests::arch_verdict_from_into_static_str_and_as_str_partition_the_emit_set`
1926        // (d4559cb),
1927        // `caixa_lint::diagnostic::tests::severity_from_into_static_str_and_as_str_partition_the_emit_set`
1928        // (5cc3b8b), and
1929        // `caixa_lint::diagnostic::tests::fix_safety_from_into_static_str_and_as_str_partition_the_emit_set`
1930        // (2a56127) — extends the round-trip discipline onto the first
1931        // closed-set fieldless typed enum on the caixa-theme surface,
1932        // closing the two-way `Self ↔ &'static str` round-trip on the
1933        // trait-idiomatic pair (`From<Self> for &'static str` +
1934        // `TryFrom<&str> for Self`) as well as the pre-existing method-
1935        // named pair (`as_str` + `from_wire`).
1936        for &variant in Semantic::ALL {
1937            let via_trait: &'static str = <&'static str as From<Semantic>>::from(variant);
1938            let via_method: &'static str = variant.as_str();
1939            assert_eq!(
1940                via_trait, via_method,
1941                "From<Semantic> for &'static str and Semantic::as_str \
1942                 must resolve identically on Semantic::{variant:?} — \
1943                 divergence signals the two forward-projection paths \
1944                 have drifted onto different emit-sets"
1945            );
1946        }
1947        // Round-trip witness: every arm's forward `From` output re-parses
1948        // through the paired trait-idiomatic `TryFrom<&str>` back to the
1949        // original variant. Closes the two-way `Semantic ↔ &'static str`
1950        // round-trip on the trait-idiomatic axis pair directly (no wire-
1951        // vocab intermediate — the emit-side [`super::Semantic::as_str`]
1952        // and the parse-side [`super::Semantic::from_wire`] dispatch on
1953        // the same 16 inline canonical-lowercase kebab byte-strings by
1954        // construction, so round-tripping through the paired
1955        // `From<Self> for &'static str` + `TryFrom<&str> for Self` trait
1956        // impls composes to the identity on `Semantic::ALL`).
1957        for &variant in Semantic::ALL {
1958            let emitted: &'static str = <&'static str as From<Semantic>>::from(variant);
1959            let reparsed = <Semantic as TryFrom<&str>>::try_from(emitted).unwrap_or_else(|()| {
1960                panic!(
1961                    "TryFrom<&str> for Semantic must accept every \
1962                     From<Semantic> for &'static str output — got \
1963                     Err(()) for Semantic::{variant:?}'s emit \
1964                     byte-string {emitted:?}"
1965                )
1966            });
1967            assert_eq!(
1968                reparsed, variant,
1969                "trait-idiomatic Semantic ↔ &'static str round-trip \
1970                 must be the identity on Semantic::{variant:?} — the \
1971                 From<Self> for &'static str + TryFrom<&str> for Self \
1972                 pair must compose to the identity on the closed 16-arm \
1973                 accept-set"
1974            );
1975        }
1976    }
1977
1978    #[test]
1979    fn semantic_from_borrowed_into_static_str_routes_through_as_str_accessor() {
1980        // Fail-before-pass-after byte-parity pin on the newly lifted
1981        // `impl From<&Semantic> for &'static str` — asserts the
1982        // borrowed-input standard-library trait impl and the substrate-
1983        // primitive [`super::Semantic::as_str`] `pub const fn` accessor
1984        // resolve to the same 16-arm canonical-lowercase kebab emit-set
1985        // across every arm the exhaustive [`super::Semantic::ALL`]
1986        // slice enumerates. Rust's `From` trait does not auto-derive
1987        // the borrowed-input sibling from a paired owned-input impl
1988        // (no `impl<T, U> From<&T> for U where T: Copy, U: From<T>`
1989        // blanket in `core`), so the borrowed-input axis is a distinct
1990        // trait-idiomatic surface that a `.iter().map(Into::into)`
1991        // shape over [`super::Semantic::ALL`] (whose iterator yields
1992        // `&Semantic`, not `Semantic`) reaches through this impl and
1993        // no other — the paired owned-input [`From<Semantic>`] impl
1994        // requires an explicit `.copied()` / dereference before the
1995        // trait fires. Materializes three
1996        // `<&'static str as From<&Semantic>>::from` outputs in
1997        // `const`-shape bindings against the paired
1998        // [`super::Semantic::as_str`] `pub const fn` accessor to make
1999        // the `'static` lifetime promise a build-time invariant — a
2000        // future accidental downgrade of any arm's inline canonical-
2001        // lowercase kebab byte-string to a non-`&'static str` (a
2002        // `String::leak()`-produced return, a `Box::leak`-cast, an
2003        // intermediate lifetime-erasing helper) trips at caixa-theme
2004        // build time rather than at a downstream `'static`-bound
2005        // consumer.
2006        //
2007        // Peer of the sibling
2008        // `caixa_provedor::ferrite::tests::ferrite_runtime_from_borrowed_into_static_str_routes_through_variant_slug_accessor`
2009        // (676d693) pin on the outside-`caixa-core` closed-set-enum
2010        // borrowed-input axis — extends the trait-idiomatic borrowed-
2011        // input forward-projection axis onto the last remaining
2012        // closed-set fieldless typed enum on the substrate surface
2013        // (the caixa-theme semantic-style 16-arm axis), closing the
2014        // substrate-wide 2×2-completion campaign's borrowed-input
2015        // `&'static str`-returning corner.
2016        const KEYWORD: &str = Semantic::Keyword.as_str();
2017        const KEYWORD_ARG: &str = Semantic::KeywordArg.as_str();
2018        const UNCHANGED: &str = Semantic::Unchanged.as_str();
2019        for variant in Semantic::ALL {
2020            let via_trait: &'static str = <&'static str as From<&Semantic>>::from(variant);
2021            let via_method: &'static str = variant.as_str();
2022            assert_eq!(
2023                via_trait, via_method,
2024                "From<&Semantic> for &'static str impl must round-trip \
2025                 &Semantic::{variant:?} to the same canonical-lowercase \
2026                 kebab byte-string Semantic::as_str returns — divergence \
2027                 signals a silent detour off the substrate-primitive \
2028                 accessor"
2029            );
2030            let via_into: &'static str = variant.into();
2031            assert_eq!(
2032                via_into, via_method,
2033                "Into<&'static str>::into on &Semantic::{variant:?} must \
2034                 byte-equal Semantic::as_str on the same input — the \
2035                 blanket-derived Into shape on the borrowed-input axis \
2036                 must resolve to the same as_str dispatch as the \
2037                 explicit From impl"
2038            );
2039        }
2040        assert_eq!(
2041            [KEYWORD, KEYWORD_ARG, UNCHANGED],
2042            ["keyword", "keyword-arg", "unchanged"],
2043            "const-context Semantic::as_str must resolve to the \
2044             canonical-lowercase kebab byte-strings — a future \
2045             accidental downgrade of any arm to a non-const or non-\
2046             static byte-string breaks the `&'static str`-lifetime \
2047             promise the paired From<&Semantic> for &'static str impl \
2048             carries by construction"
2049        );
2050    }
2051
2052    #[test]
2053    fn semantic_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
2054        // Cross-axis partition pin: the paired trait-idiomatic
2055        // `From<Semantic> for &'static str` owned-input forward
2056        // projection and the newly lifted
2057        // `From<&Semantic> for &'static str` borrowed-input forward
2058        // projection must resolve identically on *every* arm the
2059        // exhaustive [`super::Semantic::ALL`] slice enumerates. Locks
2060        // the two trait-idiomatic forward-projection paths together by
2061        // construction so any future detour (a stray borrowed-input
2062        // `From` special-case that lands on a divergent per-arm literal
2063        // outside the paired `as_str` dispatch, a hypothetical rebrand
2064        // touching one axis without the other) trips at caixa-theme
2065        // test time under `assert_eq!` rather than at a downstream
2066        // consumer split. Witnesses the borrowed-input axis with a
2067        // `.iter().map(Into::into)` pipe over `Semantic::ALL` (whose
2068        // iterator yields `&Semantic`, not `Semantic`, so the pipe
2069        // fires through the borrowed-input axis alone).
2070        //
2071        // Peer of the sibling
2072        // `caixa_provedor::ferrite::tests::ferrite_runtime_from_owned_and_borrowed_into_static_str_agree_on_every_arm`
2073        // (676d693) — extends the owned/borrowed-cross-axis partition
2074        // discipline onto the last remaining substrate-wide closed-set
2075        // fieldless typed enum whose borrowed-input axis was still
2076        // open.
2077        for &variant in Semantic::ALL {
2078            let via_owned: &'static str = <&'static str as From<Semantic>>::from(variant);
2079            let via_borrowed: &'static str = <&'static str as From<&Semantic>>::from(&variant);
2080            assert_eq!(
2081                via_owned, via_borrowed,
2082                "From<Semantic> for &'static str and From<&Semantic> \
2083                 for &'static str must agree on Semantic::{variant:?} \
2084                 — divergence signals the owned-input and borrowed-\
2085                 input forward-projection paths have drifted onto \
2086                 different emit-sets"
2087            );
2088        }
2089        let via_pipe: Vec<&'static str> = Semantic::ALL.iter().map(Into::into).collect();
2090        let via_method: Vec<&'static str> = Semantic::ALL.iter().map(|s| s.as_str()).collect();
2091        assert_eq!(
2092            via_pipe, via_method,
2093            "Semantic::ALL.iter().map(Into::into) must resolve to the \
2094             same per-arm canonical-lowercase kebab byte-string \
2095             sequence Semantic::as_str returns across every arm — the \
2096             iterator yields &Semantic, so this pipe fires through the \
2097             borrowed-input From<&Semantic> for &'static str axis and \
2098             witnesses the newly lifted impl's arm-set matches the \
2099             substrate-primitive accessor without a spurious Copy deref"
2100        );
2101    }
2102
2103    #[test]
2104    fn semantic_from_into_owned_string_routes_through_as_str_accessor() {
2105        // Fail-before-pass-after byte-parity pin on the newly lifted
2106        // `impl From<Semantic> for String` — asserts the owned-
2107        // `String`-returning standard-library trait impl and the
2108        // substrate-primitive [`super::Semantic::as_str`] `pub const
2109        // fn` accessor resolve to the same 16-arm canonical-lowercase
2110        // kebab emit-set across every arm the exhaustive
2111        // [`super::Semantic::ALL`] slice enumerates. Rust's standard
2112        // library does not carry a blanket
2113        // `impl<T: AsRef<str>> From<T> for String`, so the owned-
2114        // `String` axis is a distinct trait-idiomatic surface that a
2115        // `let key: String = sem.into();`-shaped downstream call site
2116        // reaches through this impl and no other — the sibling
2117        // `&'static str`-returning axes force an explicit
2118        // `.to_owned()` / [`String::from`] restatement whose type
2119        // bounds have no compile-time link to the substrate primitive.
2120        // Sweeps every one of the 16 arms
2121        // [`super::Semantic::ALL`] carries so no arm's projection is
2122        // covered only by the sibling method-named `as_str` /
2123        // [`std::fmt::Display`] / [`AsRef<str>`] / owned-input
2124        // `&'static str`-returning paths.
2125        //
2126        // Peer of the sibling
2127        // `caixa_provedor::ferrite::tests::ferrite_runtime_from_into_owned_string_routes_through_variant_slug_accessor`
2128        // (1e14fde) and
2129        // `caixa_arch::report::tests::arch_verdict_from_into_owned_string_routes_through_as_str_accessor`
2130        // (cc80a53) pins on the peer outside-`caixa-core` closed-set-
2131        // enum owned-`String`-returning axes — extends the trait-
2132        // idiomatic owned-`String`-returning forward-projection family
2133        // onto the sole closed-set fieldless typed enum on the caixa-
2134        // theme surface (the semantic-style 16-arm axis), extending
2135        // the substrate-wide 2×2-completion campaign onto the sixth
2136        // outside-`caixa-core` closed-set fieldless typed enum on the
2137        // caixa surface.
2138        for &variant in Semantic::ALL {
2139            let via_trait: String = <String as From<Semantic>>::from(variant);
2140            let via_method: &'static str = variant.as_str();
2141            assert_eq!(
2142                via_trait.as_str(),
2143                via_method,
2144                "From<Semantic> for String impl must round-trip \
2145                 Semantic::{variant:?} to the same canonical-lowercase \
2146                 kebab byte-string Semantic::as_str returns — \
2147                 divergence signals a silent detour off the substrate-\
2148                 primitive accessor"
2149            );
2150            let via_into: String = variant.into();
2151            assert_eq!(
2152                via_into.as_str(),
2153                via_method,
2154                "Into<String>::into on Semantic::{variant:?} must \
2155                 byte-equal Semantic::as_str on the same input — the \
2156                 blanket-derived Into shape must resolve to the same \
2157                 as_str dispatch as the explicit From impl"
2158            );
2159        }
2160    }
2161
2162    #[test]
2163    fn semantic_from_into_owned_string_and_static_str_agree_on_every_arm() {
2164        // Cross-axis partition pin: the paired trait-idiomatic
2165        // owned-input `&'static str`-returning
2166        // `From<Semantic> for &'static str` and owned-`String`-
2167        // returning `From<Semantic> for String` (this lift) forward
2168        // projections must resolve identically on every arm, locking
2169        // the two output-shape paths together so any future detour (a
2170        // stray owned-`String` special-case that lands on a divergent
2171        // per-arm literal outside the paired `as_str` dispatch, a
2172        // hypothetical rebrand touching one axis without the other, a
2173        // silent swap onto a hand-rolled per-arm literal that shadows
2174        // the paired [`super::Semantic::as_str`] dispatch) trips at
2175        // caixa-theme test time. Then a witness that the
2176        // `ToString::to_string`-through-[`std::fmt::Display`] surface
2177        // (`variant.to_string()`) byte-equals the trait-idiomatic
2178        // owned-`String` axis (`String::from(variant)`) on every arm,
2179        // so a future consumer that reaches for `.to_string()` and
2180        // one that reaches for `.into::<String>()` land on the same
2181        // substrate-primitive vocabulary. Plus a
2182        // `.iter().copied().map(String::from)` pipe witness over
2183        // [`super::Semantic::ALL`] — the exact shape a future per-
2184        // Semantic histogram key materializer or `caixa-lsp` per-
2185        // `SemanticTokenType` registration walk reaches through —
2186        // materializes the 16-arm accept-set through the owned-
2187        // `String` axis alone. Plus a direct `Self → String → Self`
2188        // round-trip witness through the paired [`TryFrom<&str>`]
2189        // axis on the owned-`String`'s [`String::as_str`] borrow,
2190        // closing the two-way round-trip on the owned-`String` axis
2191        // directly (no wire-vocab intermediate — the emit-side
2192        // [`super::Semantic::as_str`] and the parse-side
2193        // [`super::Semantic::from_wire`] dispatch on the same 16
2194        // inline canonical-lowercase kebab byte-strings by
2195        // construction).
2196        //
2197        // Peer of the sibling
2198        // `caixa_provedor::ferrite::tests::ferrite_runtime_from_into_owned_string_and_static_str_agree_on_every_arm`
2199        // (1e14fde) partition pin on the peer outside-`caixa-core`
2200        // closed-set-enum owned-`String`-returning axis.
2201        for &variant in Semantic::ALL {
2202            let owned_string: String = <String as From<Semantic>>::from(variant);
2203            let owned_static: &'static str = <&'static str as From<Semantic>>::from(variant);
2204            assert_eq!(
2205                owned_string.as_str(),
2206                owned_static,
2207                "From<Semantic> for String and From<Semantic> for \
2208                 &'static str must resolve identically on \
2209                 Semantic::{variant:?} — divergence signals the two \
2210                 output-shape forward-projection paths have drifted \
2211                 onto different emit-sets"
2212            );
2213            let via_display: String = variant.to_string();
2214            assert_eq!(
2215                owned_string, via_display,
2216                "From<Semantic> for String and ToString::to_string \
2217                 via Display must resolve identically on \
2218                 Semantic::{variant:?} — divergence signals the \
2219                 trait-idiomatic owned-`String` axis and the Display-\
2220                 routed ToString axis have drifted onto different \
2221                 vocabularies"
2222            );
2223        }
2224        let via_iter: Vec<String> = Semantic::ALL.iter().copied().map(String::from).collect();
2225        let via_method: Vec<String> = Semantic::ALL
2226            .iter()
2227            .map(|s| s.as_str().to_owned())
2228            .collect();
2229        assert_eq!(
2230            via_iter, via_method,
2231            "`.iter().copied().map(String::from)` over Semantic::ALL \
2232             must byte-equal `.iter().map(|s| s.as_str().to_owned())` \
2233             on every arm — the owned-`String` `From<Semantic> for \
2234             String` axis is what makes the `.map(String::from)` \
2235             shape route through the substrate-primitive \
2236             Semantic::as_str accessor rather than through a per-\
2237             call-site `.to_owned()` / `String::from(sem.as_str())` \
2238             detour"
2239        );
2240        for &variant in Semantic::ALL {
2241            let emitted: String = variant.into();
2242            let re_parsed: Result<Semantic, ()> =
2243                <Semantic as TryFrom<&str>>::try_from(emitted.as_str());
2244            assert_eq!(
2245                re_parsed,
2246                Ok(variant),
2247                "trait-idiomatic owned-`String` axis pair must round-\
2248                 trip Semantic::{variant:?} through \
2249                 `.into::<String>()` and back through `TryFrom<&str>` \
2250                 on the owned-`String`'s `String::as_str` borrow — a \
2251                 break signals the forward-emit owned-`String` axis \
2252                 and the reverse-parse `TryFrom<&str>` axis have \
2253                 drifted onto different vocabularies"
2254            );
2255        }
2256    }
2257
2258    #[test]
2259    fn semantic_from_borrowed_into_owned_string_routes_through_as_str_accessor() {
2260        // Fail-before-pass-after byte-parity pin on the newly lifted
2261        // `impl From<&Semantic> for String` — asserts the borrowed-
2262        // input owned-`String`-returning standard-library trait impl
2263        // and the substrate-primitive [`super::Semantic::as_str`]
2264        // `pub const fn` accessor resolve to the same 16-arm
2265        // canonical-lowercase kebab emit-set across every arm the
2266        // exhaustive [`super::Semantic::ALL`] slice enumerates.
2267        // Rust's standard library does not carry a blanket
2268        // `impl<T: AsRef<str>> From<&T> for String` (nor an
2269        // `impl<T: fmt::Display> From<&T> for String`), so the
2270        // borrowed-input owned-`String` forward-projection axis is a
2271        // distinct trait-idiomatic surface that a
2272        // `let key: String = (&sem).into();`-shaped call site
2273        // reaches through this impl and no other — the paired
2274        // sibling `From<Semantic> for String` impl (5ea146c) forces
2275        // every borrowed-input call site through an explicit `Copy`
2276        // deref (`String::from(*sem)`) or a `.as_str().to_owned()` /
2277        // `.to_string()` detour whose type bounds have no compile-
2278        // time link to the substrate primitive. Sweeps every one of
2279        // the 16 arms [`super::Semantic::ALL`] carries so no arm's
2280        // borrowed-input owned-`String` projection is covered only
2281        // by the sibling method-named `as_str` / [`std::fmt::Display`]
2282        // / [`AsRef<str>`] / owned-input `&'static str`-returning /
2283        // owned-input owned-`String`-returning paths.
2284        //
2285        // Peer of the sibling
2286        // `caixa_provedor::ferrite::tests::ferrite_runtime_from_borrowed_into_owned_string_routes_through_variant_slug_accessor`
2287        // (0caedec — fifth outside-`caixa-core` arm on this axis,
2288        // the paired ferrite-runtime two-arm axis on the sole caixa-
2289        // provedor closed-set enum) and
2290        // `caixa_lint::diagnostic::tests::fix_safety_from_borrowed_into_owned_string_routes_through_as_str_accessor`
2291        // (807f67d — fourth outside-`caixa-core` arm on this axis)
2292        // pins on the peer outside-`caixa-core` closed-set-enum
2293        // borrowed-input owned-`String`-returning axes — closes the
2294        // whole `{Self, &Self} × {&'static str, String}` 2×2 trait-
2295        // idiomatic projection corner on the sixth-and-last outside-
2296        // `caixa-core` closed-set fieldless typed enum on the caixa
2297        // surface (the caixa-theme semantic-style 16-arm axis every
2298        // per-Semantic paint dispatch, every future `caixa-lsp` per-
2299        // `SemanticTokenType` wire-up, every future `caixa.nvim`
2300        // per-highlight-group re-loader, and every future
2301        // `blackmatter-shell` per-arm `data-semantic="<kebab>"` DOM
2302        // emission keys off), and closes the substrate-wide 2×2-
2303        // completion campaign across every closed-set fieldless
2304        // typed enum on the caixa surface.
2305        for &variant in Semantic::ALL {
2306            let via_trait: String = <String as From<&Semantic>>::from(&variant);
2307            let via_method: &'static str = variant.as_str();
2308            assert_eq!(
2309                via_trait.as_str(),
2310                via_method,
2311                "From<&Semantic> for String impl must round-trip \
2312                 &Semantic::{variant:?} to the same canonical-\
2313                 lowercase kebab byte-string Semantic::as_str \
2314                 returns — divergence signals a silent detour off \
2315                 the substrate-primitive accessor"
2316            );
2317            let via_into: String = (&variant).into();
2318            assert_eq!(
2319                via_into.as_str(),
2320                via_method,
2321                "Into<String>::into on &Semantic::{variant:?} must \
2322                 byte-equal Semantic::as_str on the same input — \
2323                 the blanket-derived Into shape must resolve to the \
2324                 same as_str dispatch as the explicit From impl"
2325            );
2326        }
2327    }
2328
2329    #[test]
2330    fn semantic_from_borrowed_into_owned_string_agrees_with_paired_axes_on_every_arm() {
2331        // Cross-axis partition pin: the newly lifted trait-
2332        // idiomatic borrowed-input owned-`String`
2333        // `From<&Semantic> for String` (this lift), the paired
2334        // owned-input owned-`String` `From<Semantic> for String`
2335        // (5ea146c), the paired borrowed-input owned-`&'static str`
2336        // `From<&Semantic> for &'static str` (ffc0f26), and the
2337        // paired owned-input owned-`&'static str`
2338        // `From<Semantic> for &'static str` — every corner of the
2339        // `{Self, &Self} × {&'static str, String}` 2×2 trait-
2340        // idiomatic projection family — must resolve identically on
2341        // every arm, locking the four return-shape × input-shape
2342        // paths together so any future detour trips at caixa-theme
2343        // test time. Also byte-parity witness against the sibling
2344        // [`ToString::to_string`] surface routed through
2345        // [`std::fmt::Display`] and a direct round-trip witness
2346        // through the paired trait-idiomatic reverse
2347        // [`TryFrom<&str>`] axis on the owned-`String`'s
2348        // [`String::as_str`] borrow that closes the two-way
2349        // `&Self → String → Self` round-trip on the trait-idiomatic
2350        // borrowed-input owned-`String` forward + reverse axis pair.
2351        //
2352        // The `.iter().map(String::from)` pipe witness over
2353        // [`super::Semantic::ALL`] materializes the exact shape a
2354        // future per-Semantic histogram key materializer or
2355        // `caixa-lsp` per-`SemanticTokenType` registration walk
2356        // reaches through — [`super::Semantic::ALL`]'s iterator
2357        // yields `&Semantic` by construction, so the borrowed-input
2358        // owned-`String` axis is what routes the pipe through the
2359        // substrate-primitive [`super::Semantic::as_str`] accessor
2360        // without a spurious `.copied()` / `Copy` deref (the paired
2361        // owned-input pipe witness on the sibling
2362        // `semantic_from_into_owned_string_and_static_str_agree_on_every_arm`
2363        // uses `.iter().copied().map(String::from)` for exactly this
2364        // reason — the owned-input axis alone cannot route the pipe
2365        // through the substrate primitive without the extra deref).
2366        //
2367        // Peer of the sibling
2368        // `caixa_provedor::ferrite::tests::ferrite_runtime_from_borrowed_into_owned_string_agrees_with_paired_axes_on_every_arm`
2369        // (0caedec — fifth outside-`caixa-core` arm on this axis)
2370        // partition pin on the peer outside-`caixa-core` closed-
2371        // set-enum borrowed-input owned-`String` axis — closes the
2372        // substrate-wide 2×2-completion campaign on the sixth-and-
2373        // last outside-`caixa-core` closed-set fieldless typed enum
2374        // on the caixa surface.
2375        for &variant in Semantic::ALL {
2376            let borrowed_string: String = <String as From<&Semantic>>::from(&variant);
2377            let owned_string: String = <String as From<Semantic>>::from(variant);
2378            let borrowed_static: &'static str = <&'static str as From<&Semantic>>::from(&variant);
2379            let owned_static: &'static str = <&'static str as From<Semantic>>::from(variant);
2380            assert_eq!(
2381                borrowed_string, owned_string,
2382                "From<&Semantic> for String and From<Semantic> for \
2383                 String must resolve identically on \
2384                 Semantic::{variant:?} — divergence signals the \
2385                 owned-`String` axis pair's borrowed-input and \
2386                 owned-input arms have drifted onto different emit-\
2387                 sets"
2388            );
2389            assert_eq!(
2390                borrowed_string.as_str(),
2391                borrowed_static,
2392                "From<&Semantic> for String and From<&Semantic> for \
2393                 &'static str must resolve identically on \
2394                 Semantic::{variant:?} — divergence signals the \
2395                 borrowed-input axis pair's owned-`String`-returning \
2396                 and `&'static str`-returning arms have drifted \
2397                 onto different emit-sets"
2398            );
2399            assert_eq!(
2400                borrowed_string.as_str(),
2401                owned_static,
2402                "From<&Semantic> for String and From<Semantic> for \
2403                 &'static str must resolve identically on \
2404                 Semantic::{variant:?} — the cross-diagonal corner \
2405                 of the 2×2 must agree, or the four projections \
2406                 have split into two vocabularies"
2407            );
2408            let via_display: String = variant.to_string();
2409            assert_eq!(
2410                borrowed_string, via_display,
2411                "From<&Semantic> for String and ToString::to_string \
2412                 via Display must resolve identically on \
2413                 Semantic::{variant:?} — divergence signals the \
2414                 trait-idiomatic borrowed-input owned-`String` axis \
2415                 and the Display-routed ToString axis have drifted \
2416                 onto different vocabularies"
2417            );
2418        }
2419        let via_iter: Vec<String> = Semantic::ALL.iter().map(String::from).collect();
2420        let via_method: Vec<String> = Semantic::ALL
2421            .iter()
2422            .map(|sem| sem.as_str().to_owned())
2423            .collect();
2424        assert_eq!(
2425            via_iter, via_method,
2426            "`.iter().map(String::from)` over Semantic::ALL must \
2427             byte-equal `.iter().map(|sem| sem.as_str().to_owned())` \
2428             on every arm — the borrowed-input owned-`String` \
2429             `From<&Semantic> for String` axis is what makes the \
2430             `.map(String::from)` shape route through the substrate-\
2431             primitive Semantic::as_str accessor without a spurious \
2432             `.copied()` / `Copy` deref"
2433        );
2434        for &variant in Semantic::ALL {
2435            let emitted: String = (&variant).into();
2436            let re_parsed: Result<Semantic, ()> =
2437                <Semantic as TryFrom<&str>>::try_from(emitted.as_str());
2438            assert_eq!(
2439                re_parsed,
2440                Ok(variant),
2441                "trait-idiomatic borrowed-input owned-`String` axis \
2442                 pair must round-trip Semantic::{variant:?} through \
2443                 `(&variant).into::<String>()` and back through \
2444                 `TryFrom<&str>` on the owned-`String`'s \
2445                 `String::as_str` borrow — a break signals the \
2446                 borrowed-input forward-emit owned-`String` axis \
2447                 and the reverse-parse `TryFrom<&str>` axis have \
2448                 drifted onto different vocabularies"
2449            );
2450        }
2451    }
2452
2453    #[test]
2454    fn semantic_from_into_static_cow_str_routes_through_as_str_accessor() {
2455        // Fail-before-pass-after byte-parity pin on the newly lifted
2456        // `impl From<Semantic> for std::borrow::Cow<'static, str>` —
2457        // asserts the standard-library trait impl and the substrate-
2458        // primitive [`super::Semantic::as_str`] `pub const fn`
2459        // accessor resolve to the same sixteen-arm canonical-
2460        // lowercase kebab emit-set (`"keyword"` / `"symbol"` /
2461        // `"keyword-arg"` / `"string"` / `"number"` / `"literal"` /
2462        // `"comment"` / `"accent"` / `"muted"` / `"error"` /
2463        // `"warning"` / `"info"` / `"hint"` / `"added"` /
2464        // `"removed"` / `"unchanged"`) across every arm the
2465        // exhaustive [`super::Semantic::ALL`] slice enumerates.
2466        // Rust's standard library does not carry a blanket
2467        // `impl<T: AsRef<str>> From<T> for std::borrow::Cow<'static, str>`
2468        // (nor an `impl<T: fmt::Display> From<T> for std::borrow::Cow<'static, str>`),
2469        // so the [`std::borrow::Cow<'static, str>`] forward-projection
2470        // axis is a distinct trait-idiomatic surface that a
2471        // `let key: std::borrow::Cow<'static, str> = sem.into();`-
2472        // shaped call site reaches through this impl and no other —
2473        // the paired sibling `From<Semantic> for &'static str` and
2474        // `From<Semantic> for String` impls force every
2475        // [`std::borrow::Cow<'static, str>`]-parameterized call site
2476        // through a `std::borrow::Cow::Borrowed(sem.as_str())` /
2477        // `std::borrow::Cow::Owned(sem.to_string())` /
2478        // `String::from(sem).into()` composition whose type bounds
2479        // have no compile-time link back to the substrate primitive.
2480        //
2481        // Also asserts the projection lands on the zero-alloc
2482        // [`std::borrow::Cow::Borrowed`] arm (not the
2483        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
2484        // [`super::Semantic::as_str`] accessor's `&'static str`
2485        // return lifetime by construction makes the borrowed arm the
2486        // type-correct projection with no runtime allocation. Any
2487        // future silent detour that routes the impl through the
2488        // owned arm (an accidental
2489        // `std::borrow::Cow::Owned(sem.to_string())` rewrite that
2490        // would allocate on every call site where the `&'static str`
2491        // return of [`super::Semantic::as_str`] makes the zero-alloc
2492        // borrowed projection type-correct) trips at caixa-theme
2493        // test time under the [`std::borrow::Cow::Borrowed`]
2494        // discriminator witness rather than at a downstream
2495        // [`std::borrow::Cow<'static, str>`]-bound consumer's silent
2496        // allocation.
2497        //
2498        // Fifth outside-`caixa-core` peer (and sole peer on the
2499        // caixa-theme surface) on the substrate-wide trait-idiomatic
2500        // [`std::borrow::Cow<'static, str>`] forward-projection
2501        // family — extends the axis off the paired caixa-lint fix-
2502        // safety-tier axis on the sibling two-arm closed-set enum
2503        // ([`caixa_lint::diagnostic::FixSafety`], 79010c5 / 9a6539f
2504        // — fourth outside-`caixa-core` peer, closed the 2×3 corner)
2505        // onto the semantic-style sixteen-arm axis, continuing the
2506        // outside-`caixa-core` tier of the campaign.
2507        for &variant in Semantic::ALL {
2508            let via_trait: std::borrow::Cow<'static, str> =
2509                <std::borrow::Cow<'static, str> as From<Semantic>>::from(variant);
2510            let via_method: &'static str = variant.as_str();
2511            assert_eq!(
2512                via_trait.as_ref(),
2513                via_method,
2514                "From<Semantic> for Cow<'static, str> impl must round-\
2515                 trip Semantic::{variant:?} to the same canonical-\
2516                 lowercase kebab byte-string Semantic::as_str returns \
2517                 — divergence signals a silent detour off the \
2518                 substrate-primitive accessor"
2519            );
2520            assert!(
2521                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
2522                "From<Semantic> for Cow<'static, str> impl must land \
2523                 on the zero-alloc Cow::Borrowed arm on \
2524                 Semantic::{variant:?} — a Cow::Owned outcome \
2525                 signals the projection has silently allocated where \
2526                 the substrate-primitive Semantic::as_str \
2527                 `&'static str` return makes the borrowed arm the \
2528                 type-correct projection"
2529            );
2530            let via_into: std::borrow::Cow<'static, str> = variant.into();
2531            assert_eq!(
2532                via_into.as_ref(),
2533                via_method,
2534                "Into<Cow<'static, str>>::into on \
2535                 Semantic::{variant:?} must byte-equal \
2536                 Semantic::as_str on the same input — the blanket-\
2537                 derived Into shape must resolve to the same as_str \
2538                 dispatch as the explicit From impl"
2539            );
2540            assert!(
2541                matches!(via_into, std::borrow::Cow::Borrowed(_)),
2542                "Into<Cow<'static, str>>::into on \
2543                 Semantic::{variant:?} must land on the zero-alloc \
2544                 Cow::Borrowed arm — the blanket-derived Into shape \
2545                 must resolve to the same Cow::Borrowed dispatch as \
2546                 the explicit From impl"
2547            );
2548        }
2549    }
2550
2551    #[test]
2552    fn semantic_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
2553        // Cross-axis partition pin: the newly lifted trait-idiomatic
2554        // `From<Semantic> for std::borrow::Cow<'static, str>` (this
2555        // lift), the paired owned-input
2556        // `From<Semantic> for &'static str`, and the paired owned-
2557        // input `From<Semantic> for String` forward projections must
2558        // resolve identically on every arm, locking the three return-
2559        // shape paths together by construction so any future detour
2560        // trips at caixa-theme test time. Also byte-parity witness
2561        // against the sibling [`ToString::to_string`] surface routed
2562        // through [`std::fmt::Display`] — every owned-heap-string
2563        // path (the [`std::borrow::Cow::Owned`] promotion of this
2564        // axis's `.into_owned()`, `From<Semantic> for String`, and
2565        // `.to_string()`) resolves to the same canonical-lowercase
2566        // kebab byte-string per arm.
2567        //
2568        // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
2569        // witness over [`super::Semantic::ALL`] that materializes
2570        // the sixteen-arm accept-set through the
2571        // [`std::borrow::Cow<'static, str>`] axis alone — the exact
2572        // shape a future `feira lint --list-styles` operator-facing
2573        // enumeration, a future `caixa-lsp`-side per-
2574        // `SemanticTokenType` registration table whose typing rules
2575        // out the sibling [`AsRef<str>`] borrowed return, or a
2576        // future `caixa.nvim` per-highlight-group re-loader table
2577        // reaches through — closing the composable-projection axis
2578        // on the caixa-theme semantic-style sixteen-arm closed-set
2579        // fieldless typed enum peer. The pipe witness also pins the
2580        // zero-alloc discipline: every element in the collected
2581        // vector satisfies the [`std::borrow::Cow::Borrowed`] arm
2582        // predicate, so a future accidental silent-allocation
2583        // regression on the pipe's iteration axis is a caixa-theme-
2584        // test-time failure.
2585        //
2586        // Then a direct round-trip witness through [`TryFrom<&str>`]
2587        // on the projection's [`std::borrow::Cow::as_ref`] borrow —
2588        // like the sibling [`caixa_lint::diagnostic::FixSafety`]
2589        // and [`caixa_lint::diagnostic::Severity`] pairs (whose
2590        // canonical-lowercase byte-strings are round-trip-stable),
2591        // and unlike the peer [`caixa_core::CaixaKind`] pair (whose
2592        // forward emit lands on the lowercase Portuguese diagnostic
2593        // vocabulary while the reverse parse lands on the
2594        // `PascalCase` wire vocabulary), [`super::Semantic`]'s
2595        // forward emit and reverse parse share the same sixteen
2596        // inline canonical-lowercase kebab byte-strings by
2597        // construction, so the [`std::borrow::Cow<'static, str>`]
2598        // projection composes directly with the trait-idiomatic
2599        // reverse [`TryFrom<&str>`] axis without the wire-vocab
2600        // intermediate hop.
2601        for &variant in Semantic::ALL {
2602            let via_cow: std::borrow::Cow<'static, str> =
2603                <std::borrow::Cow<'static, str> as From<Semantic>>::from(variant);
2604            let via_static: &'static str = <&'static str as From<Semantic>>::from(variant);
2605            let via_string: String = <String as From<Semantic>>::from(variant);
2606            assert_eq!(
2607                via_cow.as_ref(),
2608                via_static,
2609                "From<Semantic> for Cow<'static, str> and \
2610                 From<Semantic> for &'static str must resolve \
2611                 identically on Semantic::{variant:?} — divergence \
2612                 signals the Cow<'static, str> and &'static str \
2613                 return-shape paths have drifted onto different \
2614                 emit-sets"
2615            );
2616            assert_eq!(
2617                via_cow.as_ref(),
2618                via_string.as_str(),
2619                "From<Semantic> for Cow<'static, str> and \
2620                 From<Semantic> for String must resolve identically \
2621                 on Semantic::{variant:?} — divergence signals the \
2622                 Cow<'static, str> and String return-shape paths \
2623                 have drifted onto different emit-sets"
2624            );
2625            let via_to_string: String = variant.to_string();
2626            assert_eq!(
2627                via_cow.as_ref(),
2628                via_to_string.as_str(),
2629                "From<Semantic> for Cow<'static, str> must byte-\
2630                 equal Semantic::to_string on Semantic::{variant:?} \
2631                 — divergence signals the trait-idiomatic \
2632                 Cow<'static, str> forward-projection axis and the \
2633                 ToString-through-Display axis have drifted onto \
2634                 different emit-sets"
2635            );
2636        }
2637        let via_iter: Vec<std::borrow::Cow<'static, str>> = Semantic::ALL
2638            .iter()
2639            .copied()
2640            .map(std::borrow::Cow::from)
2641            .collect();
2642        let via_method: Vec<std::borrow::Cow<'static, str>> = Semantic::ALL
2643            .iter()
2644            .map(|sem| std::borrow::Cow::Borrowed(sem.as_str()))
2645            .collect();
2646        assert_eq!(
2647            via_iter, via_method,
2648            "`.iter().copied().map(Cow::from)` over Semantic::ALL \
2649             must byte-equal `.iter().map(|sem| \
2650             Cow::Borrowed(sem.as_str()))` on every arm — the trait-\
2651             idiomatic `From<Semantic> for Cow<'static, str>` axis \
2652             is what makes the `Cow::from` composition route through \
2653             the substrate-primitive Semantic::as_str accessor \
2654             rather than a per-call-site open-code"
2655        );
2656        for cow in &via_iter {
2657            assert!(
2658                matches!(cow, std::borrow::Cow::Borrowed(_)),
2659                "`.iter().copied().map(Cow::from)` over \
2660                 Semantic::ALL must land on the zero-alloc \
2661                 Cow::Borrowed arm on every element — a Cow::Owned \
2662                 outcome signals the pipe has silently allocated \
2663                 where the substrate-primitive Semantic::as_str \
2664                 `&'static str` return makes the borrowed arm the \
2665                 type-correct projection"
2666            );
2667        }
2668        for &variant in Semantic::ALL {
2669            let via_cow: std::borrow::Cow<'static, str> =
2670                <std::borrow::Cow<'static, str> as From<Semantic>>::from(variant);
2671            let re_parsed: Result<Semantic, ()> =
2672                <Semantic as TryFrom<&str>>::try_from(via_cow.as_ref());
2673            assert_eq!(
2674                re_parsed,
2675                Ok(variant),
2676                "trait-idiomatic Cow<'static, str> forward-projection \
2677                 + reverse-projection axis pair must round-trip \
2678                 Semantic::{variant:?} through \
2679                 `.into::<Cow<'static, str>>()` on the owned-input \
2680                 surface and back through `TryFrom<&str>` on the \
2681                 projection's Cow::as_ref borrow — a break signals \
2682                 the Cow<'static, str> forward-emit and reverse-\
2683                 parse axes have drifted onto different vocabularies \
2684                 (like the sibling FixSafety and Severity pairs, \
2685                 Semantic's forward emit and reverse parse share \
2686                 the same sixteen inline canonical-lowercase kebab \
2687                 byte-strings by construction, so the round-trip \
2688                 composes directly)"
2689            );
2690        }
2691    }
2692
2693    #[test]
2694    fn semantic_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
2695        // Fail-before-pass-after byte-parity pin on the newly lifted
2696        // `impl From<&Semantic> for std::borrow::Cow<'static, str>` —
2697        // asserts the borrowed-input standard-library trait impl and
2698        // the substrate-primitive [`super::Semantic::as_str`]
2699        // `pub const fn` accessor resolve to the same sixteen-arm
2700        // canonical-lowercase kebab emit-set (`"keyword"` / `"symbol"` /
2701        // `"keyword-arg"` / `"string"` / `"number"` / `"literal"` /
2702        // `"comment"` / `"accent"` / `"muted"` / `"error"` /
2703        // `"warning"` / `"info"` / `"hint"` / `"added"` / `"removed"` /
2704        // `"unchanged"`) across every arm the exhaustive
2705        // [`super::Semantic::ALL`] slice enumerates. Rust's standard
2706        // library does not carry a blanket
2707        // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
2708        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
2709        // the borrowed-input `Cow<'static, str>` forward-projection
2710        // axis is a distinct trait-idiomatic surface that a
2711        // `let key: Cow<'static, str> = (&sem).into();`-shaped call
2712        // site or a `Semantic::ALL.iter().map(Cow::from)`-shaped pipe
2713        // reaches through this impl and no other — the paired owned-
2714        // input `From<Semantic> for Cow<'static, str>` impl (0253688)
2715        // forces every borrowed-input call site through an explicit
2716        // `Copy` deref (`Cow::from(*sem)`) or a
2717        // `Cow::Borrowed(sem.as_str())` open-code whose type bounds
2718        // have no compile-time link back to the substrate primitive.
2719        //
2720        // Also asserts the projection lands on the zero-alloc
2721        // [`std::borrow::Cow::Borrowed`] arm (not the
2722        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
2723        // [`super::Semantic::as_str`] accessor's `&'static str` return
2724        // lifetime by construction makes the borrowed arm the type-
2725        // correct projection with no runtime allocation on the
2726        // borrowed-input surface just as on the paired owned-input
2727        // surface.
2728        //
2729        // Closes the `{Self, &Self}` input-shape corner on the fifth
2730        // outside-`caixa-core` closed-set fieldless typed enum peer
2731        // of the substrate-wide [`std::borrow::Cow<'static, str>`]
2732        // forward-projection campaign, exactly as
2733        // `fix_safety_from_borrowed_into_static_cow_str_routes_through_as_str_accessor`
2734        // (9a6539f) closed it on the sibling caixa-lint
2735        // [`caixa_lint::diagnostic::FixSafety`] one commit after
2736        // (79010c5) closing the whole 2×3 corner,
2737        // `severity_from_borrowed_into_static_cow_str_routes_through_as_str_accessor`
2738        // (1819087) on [`caixa_lint::diagnostic::Severity`] one commit
2739        // after (700a95e) closing the whole 2×3 corner, and every
2740        // peer closer that preceded it on the campaign.
2741        for &variant in Semantic::ALL {
2742            let via_trait: std::borrow::Cow<'static, str> =
2743                <std::borrow::Cow<'static, str> as From<&Semantic>>::from(&variant);
2744            let via_method: &'static str = variant.as_str();
2745            assert_eq!(
2746                via_trait.as_ref(),
2747                via_method,
2748                "From<&Semantic> for Cow<'static, str> impl must \
2749                 round-trip &Semantic::{variant:?} to the same \
2750                 canonical-lowercase kebab byte-string \
2751                 Semantic::as_str returns — divergence signals a \
2752                 silent detour off the substrate-primitive accessor"
2753            );
2754            assert!(
2755                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
2756                "From<&Semantic> for Cow<'static, str> impl must \
2757                 land on the zero-alloc Cow::Borrowed arm on \
2758                 &Semantic::{variant:?} — a Cow::Owned outcome \
2759                 signals the projection has silently allocated where \
2760                 the substrate-primitive Semantic::as_str \
2761                 `&'static str` return makes the borrowed arm the \
2762                 type-correct projection"
2763            );
2764            let via_into: std::borrow::Cow<'static, str> = (&variant).into();
2765            assert_eq!(
2766                via_into.as_ref(),
2767                via_method,
2768                "Into<Cow<'static, str>>::into on \
2769                 &Semantic::{variant:?} must byte-equal \
2770                 Semantic::as_str on the same input — the blanket-\
2771                 derived Into shape on the borrowed-input surface \
2772                 must resolve to the same as_str dispatch as the \
2773                 explicit From impl"
2774            );
2775            assert!(
2776                matches!(via_into, std::borrow::Cow::Borrowed(_)),
2777                "Into<Cow<'static, str>>::into on \
2778                 &Semantic::{variant:?} must land on the zero-alloc \
2779                 Cow::Borrowed arm — the blanket-derived Into shape \
2780                 on the borrowed-input surface must resolve to the \
2781                 same Cow::Borrowed dispatch as the explicit From \
2782                 impl"
2783            );
2784        }
2785    }
2786
2787    #[test]
2788    #[allow(
2789        clippy::too_many_lines,
2790        reason = "cross-axis partition pin folds four return-shape paths \
2791                  (borrowed-input Cow<'static, str>, owned-input Cow<'static, str>, \
2792                  borrowed-input &'static str, borrowed-input String) plus the \
2793                  ToString-through-Display witness plus a `.iter().map(Cow::from)` \
2794                  pipe witness with zero-alloc discriminator plus a direct \
2795                  round-trip witness through TryFrom<&str> over sixteen typed \
2796                  variants; the linear per-axis repetition is exactly what the \
2797                  fold is pinning — a helper would hide the shape it locks"
2798    )]
2799    fn semantic_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
2800        // Cross-axis partition pin: the newly lifted trait-idiomatic
2801        // borrowed-input `From<&Semantic> for
2802        // std::borrow::Cow<'static, str>` (this lift), the paired
2803        // owned-input `From<Semantic> for
2804        // std::borrow::Cow<'static, str>` (0253688), the paired
2805        // borrowed-input `From<&Semantic> for &'static str`, and the
2806        // paired borrowed-input `From<&Semantic> for String` forward
2807        // projections must resolve identically on every arm, locking
2808        // the four return-shape paths together by construction so any
2809        // future detour trips at caixa-theme test time. Also byte-
2810        // parity witness against the sibling [`ToString::to_string`]
2811        // surface routed through [`std::fmt::Display`].
2812        //
2813        // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
2814        // over [`super::Semantic::ALL`] — whose iterator yields
2815        // `&Semantic` by construction, so the borrowed-input
2816        // [`std::borrow::Cow<'static, str>`] axis is what routes the
2817        // pipe through the substrate-primitive
2818        // [`super::Semantic::as_str`] accessor with the zero-alloc
2819        // [`std::borrow::Cow::Borrowed`] arm and without a spurious
2820        // [`Copy`] deref. Every collected element satisfies the
2821        // [`std::borrow::Cow::Borrowed`]-arm predicate so a future
2822        // accidental silent-allocation regression on the pipe's
2823        // iteration axis is a caixa-theme-test-time failure.
2824        //
2825        // Then a direct round-trip witness through [`TryFrom<&str>`]
2826        // on the projection's [`std::borrow::Cow::as_ref`] borrow —
2827        // unlike the peer [`caixa_core::CaixaKind`] axis pair (whose
2828        // forward emit lands on the lowercase Portuguese diagnostic
2829        // vocabulary while the reverse parse lands on the
2830        // `PascalCase` wire vocabulary, forcing the round-trip
2831        // through an intermediate [`caixa_core::CaixaKind::wire_name`]
2832        // hop), [`super::Semantic`]'s forward emit and reverse parse
2833        // share the same sixteen inline canonical-lowercase kebab
2834        // byte-strings by construction, so the borrowed-input
2835        // [`std::borrow::Cow<'static, str>`] projection composes
2836        // directly with the trait-idiomatic reverse [`TryFrom<&str>`]
2837        // axis without the wire-vocab intermediate hop.
2838        for &variant in Semantic::ALL {
2839            let via_borrowed_cow: std::borrow::Cow<'static, str> =
2840                <std::borrow::Cow<'static, str> as From<&Semantic>>::from(&variant);
2841            let via_owned_cow: std::borrow::Cow<'static, str> =
2842                <std::borrow::Cow<'static, str> as From<Semantic>>::from(variant);
2843            let via_borrowed_static: &'static str =
2844                <&'static str as From<&Semantic>>::from(&variant);
2845            let via_borrowed_string: String = <String as From<&Semantic>>::from(&variant);
2846            assert_eq!(
2847                via_borrowed_cow.as_ref(),
2848                via_owned_cow.as_ref(),
2849                "From<&Semantic> for Cow<'static, str> and \
2850                 From<Semantic> for Cow<'static, str> must resolve \
2851                 identically on Semantic::{variant:?} — divergence \
2852                 signals the borrowed-input and owned-input \
2853                 Cow<'static, str> forward-projection input-shape \
2854                 paths have drifted onto different emit-sets"
2855            );
2856            assert_eq!(
2857                via_borrowed_cow.as_ref(),
2858                via_borrowed_static,
2859                "From<&Semantic> for Cow<'static, str> and \
2860                 From<&Semantic> for &'static str must resolve \
2861                 identically on Semantic::{variant:?} — divergence \
2862                 signals the borrowed-input Cow<'static, str> and \
2863                 borrowed-input `&'static str` return-shape paths \
2864                 have drifted onto different emit-sets"
2865            );
2866            assert_eq!(
2867                via_borrowed_cow.as_ref(),
2868                via_borrowed_string.as_str(),
2869                "From<&Semantic> for Cow<'static, str> and \
2870                 From<&Semantic> for String must resolve identically \
2871                 on Semantic::{variant:?} — divergence signals the \
2872                 borrowed-input Cow<'static, str> and borrowed-input \
2873                 owned-`String` return-shape paths have drifted onto \
2874                 different emit-sets"
2875            );
2876            let via_to_string: String = variant.to_string();
2877            assert_eq!(
2878                via_borrowed_cow.as_ref(),
2879                via_to_string.as_str(),
2880                "From<&Semantic> for Cow<'static, str> must byte-\
2881                 equal Semantic::to_string on Semantic::{variant:?} \
2882                 — divergence signals the trait-idiomatic borrowed-\
2883                 input Cow<'static, str> forward-projection axis and \
2884                 the ToString-through-Display axis have drifted onto \
2885                 different emit-sets"
2886            );
2887            assert!(
2888                matches!(via_borrowed_cow, std::borrow::Cow::Borrowed(_)),
2889                "From<&Semantic> for Cow<'static, str> must land on \
2890                 the zero-alloc Cow::Borrowed arm on \
2891                 &Semantic::{variant:?} — a Cow::Owned outcome \
2892                 signals the borrowed-input surface has silently \
2893                 allocated where the substrate-primitive \
2894                 Semantic::as_str `&'static str` return makes the \
2895                 borrowed arm the type-correct projection"
2896            );
2897        }
2898        let via_iter: Vec<std::borrow::Cow<'static, str>> =
2899            Semantic::ALL.iter().map(std::borrow::Cow::from).collect();
2900        let via_method: Vec<std::borrow::Cow<'static, str>> = Semantic::ALL
2901            .iter()
2902            .map(|sem| std::borrow::Cow::Borrowed(sem.as_str()))
2903            .collect();
2904        assert_eq!(
2905            via_iter, via_method,
2906            "`.iter().map(Cow::from)` over Semantic::ALL — a call \
2907             site whose iteration axis holds `&Semantic` by \
2908             construction — must byte-equal `.iter().map(|sem| \
2909             Cow::Borrowed(sem.as_str()))` on every arm — the \
2910             borrowed-input `From<&Semantic> for Cow<'static, str>` \
2911             axis is what makes the `Cow::from` composition route \
2912             through the substrate-primitive `Semantic::as_str` \
2913             accessor without a spurious `Copy` deref (which would \
2914             only be reachable through the owned-input \
2915             `From<Semantic> for Cow<'static, str>` axis by first \
2916             calling `.copied()` on the iterator)"
2917        );
2918        for cow in &via_iter {
2919            assert!(
2920                matches!(cow, std::borrow::Cow::Borrowed(_)),
2921                "`.iter().map(Cow::from)` over Semantic::ALL must \
2922                 land on the zero-alloc Cow::Borrowed arm on every \
2923                 element — a Cow::Owned outcome signals the pipe has \
2924                 silently allocated through the borrowed-input axis \
2925                 where the substrate-primitive Semantic::as_str \
2926                 `&'static str` return makes the borrowed arm the \
2927                 type-correct projection"
2928            );
2929        }
2930        for &variant in Semantic::ALL {
2931            let via_cow: std::borrow::Cow<'static, str> =
2932                <std::borrow::Cow<'static, str> as From<&Semantic>>::from(&variant);
2933            let re_parsed: Result<Semantic, ()> =
2934                <Semantic as TryFrom<&str>>::try_from(via_cow.as_ref());
2935            assert_eq!(
2936                re_parsed,
2937                Ok(variant),
2938                "trait-idiomatic borrowed-input Cow<'static, str> \
2939                 forward-projection + reverse-projection axis pair \
2940                 must round-trip &Semantic::{variant:?} through \
2941                 `(&variant).into::<Cow<'static, str>>()` on the \
2942                 borrowed-input surface and back through \
2943                 `TryFrom<&str>` on the projection's Cow::as_ref \
2944                 borrow — a break signals the borrowed-input \
2945                 Cow<'static, str> forward-emit and reverse-parse \
2946                 axes have drifted onto different vocabularies \
2947                 (unlike the peer CaixaKind axis pair, Semantic's \
2948                 forward emit and reverse parse share the same \
2949                 sixteen inline canonical-lowercase kebab byte-\
2950                 strings by construction, so the round-trip composes \
2951                 directly)"
2952            );
2953        }
2954    }
2955}