Skip to main content

caixa_core/
dep.rs

1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4/// A single dependency declaration in a `caixa.lisp` manifest.
5///
6/// **Store model = Git, like Zig.** There is no central registry; a caixa is
7/// just a Git repo with a `caixa.lisp` at its root. When `:fonte` is omitted,
8/// the resolver falls back to `github:<default-org>/<nome>` (org defaults to
9/// `pleme-io`, override via `~/.config/caixa/config.yaml`).
10///
11/// ```lisp
12/// ;; Shorthand — resolves to github:pleme-io/caixa-teia (or your default org):
13/// (:nome "caixa-teia" :versao "^0.1")
14///
15/// ;; Explicit git source:
16/// (:nome "caixa-teia"
17///  :versao "^0.1"
18///  :fonte (:tipo git :repo "github:pleme-io/caixa-teia" :tag "v0.1.0"))
19///
20/// ;; Arbitrary git URL (not limited to GitHub):
21/// (:nome "private-caixa"
22///  :versao "*"
23///  :fonte (:tipo git :repo "ssh://git@git.example/team/priv-caixa.git" :branch "main"))
24///
25/// ;; Local path (dev only; not publishable):
26/// (:nome "caixa-teia"
27///  :versao "0.1.0"
28///  :fonte (:tipo path :caminho "../caixa-teia"))
29/// ```
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
31#[serde(rename_all = "camelCase")]
32pub struct Dep {
33    /// Caixa name — must match the target caixa's `:nome`.
34    pub nome: String,
35
36    /// Semver constraint string (`"^0.1"`, `"~0.1.2"`, `"0.1.0"`, `"*"`).
37    pub versao: String,
38
39    /// Where to fetch the caixa from. Defaults to the feira registry.
40    #[serde(default, skip_serializing_if = "Option::is_none")]
41    pub fonte: Option<DepSource>,
42
43    /// If true, a missing `:fonte` is not a build failure.
44    #[serde(default, skip_serializing_if = "is_false")]
45    pub opcional: bool,
46
47    /// Feature flags to enable on the target caixa.
48    #[serde(default, skip_serializing_if = "Vec::is_empty")]
49    pub caracteristicas: Vec<String>,
50}
51
52/// Where a dep is fetched from. Tagged via `:tipo` in Lisp.
53///
54/// Only two shapes — Git and local Path. No central registry variant: a caixa
55/// is just a Git repo. Omitting `:fonte` means *"use the default resolver
56/// convention"*, which is `github:<default-org>/<nome>`; the resolver fills
57/// that in when computing the lacre.
58///
59/// The [`gen_platform::IsVariant`] derive emits per-arm arm-discriminator
60/// predicates — [`Self::is_git`], [`Self::is_path`] — so every downstream
61/// consumer that only needs the arm-discriminator projection (not the
62/// borrowed field value) reaches for one typed dispatch on the substrate
63/// primitive rather than a hand-rolled `matches!(s, DepSource::X { .. })`
64/// literal. Extends the closed-set-typed-enum discipline the sibling
65/// caixa-core enums ([`crate::CaixaKind`], [`crate::CaixaDialeto`],
66/// [`crate::supervisor::RestartStrategy`], [`crate::supervisor::RestartPolicy`],
67/// [`crate::upgrade::UpgradeInstruction`], [`crate::aplicacao::PlacementStrategy`],
68/// [`crate::aplicacao::RateLimitUnit`], [`crate::aplicacao::WitTarget`],
69/// [`crate::render::PathShapeViolation`], [`DepList`]) and the sibling
70/// out-of-crate enums (caixa-arch's `InvariantKind` + `ArchVerdict`,
71/// caixa-lint's `Severity` + `FixSafety`, caixa-provedor's
72/// `FerriteRuntime`, caixa-theme's `Semantic`, caixa-flux's `GitRefSpec`,
73/// caixa-ast's `NodeKind` + `TriviaKind`) already carry onto the
74/// two-arm `:fonte` dep-source axis — the 17th closed-set typed enum
75/// on the caixa surface, and the first on the outer-`Dep` `:fonte`-slot
76/// axis every git-fetching consumer runs after the outer `:fonte` slot
77/// resolves to a shape.
78#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, gen_platform::IsVariant)]
79#[serde(tag = "tipo", rename_all = "lowercase")]
80pub enum DepSource {
81    /// Clone from Git. One of `:tag`, `:rev`, or `:branch` may be set.
82    /// `repo` can be a `github:org/repo` shorthand, a full `https://…` URL,
83    /// or any git-ssh URL.
84    Git {
85        repo: String,
86        #[serde(default, skip_serializing_if = "Option::is_none")]
87        tag: Option<String>,
88        #[serde(default, skip_serializing_if = "Option::is_none")]
89        rev: Option<String>,
90        #[serde(default, skip_serializing_if = "Option::is_none")]
91        branch: Option<String>,
92    },
93    /// Local filesystem path — dev only; cannot be published.
94    Path { caminho: String },
95}
96
97impl DepSource {
98    /// Build a registry-shorthand git source (`github:<org>/<nome>`).
99    ///
100    /// This is the resolver-side fallback for `dep.fonte: None`, not an
101    /// author-surface value — it carries no pin (`:tag`/`:rev`/`:branch`
102    /// all `None`) and is therefore rejected by [`Self::validate`]. The
103    /// resolver fills the pin in at fetch time from the resolved commit;
104    /// authors never serialize this shape as a `Dep::fonte` value.
105    #[must_use]
106    pub fn default_github(org: &str, nome: &str) -> Self {
107        Self::Git {
108            repo: format!("github:{org}/{nome}"),
109            tag: None,
110            rev: None,
111            branch: None,
112        }
113    }
114
115    /// Substrate-canonical per-`:fonte` sole-set git-pin scalar accessor
116    /// every consumer that reads "which single git ref does this source
117    /// resolve to?" keys off — returns the author-declared `:tag` /
118    /// `:rev` / `:branch` byte-string verbatim as an `Option<&str>`,
119    /// borrowed from the typed slot's own `Option<String>` storage; `None`
120    /// on [`Self::Path`] (a path source carries no git-ref) and on a
121    /// [`Self::Git`] variant whose `tag`, `rev`, and `branch` are all
122    /// `None` (the [`Self::default_github`] shorthand shape the resolver
123    /// materializes when the author omits `:fonte` — rejected by
124    /// [`Self::validate`], but the accessor's return is defined on this
125    /// arm too so pre-validate consumers reach for the same typed dispatch
126    /// as post-validate ones).
127    ///
128    /// **Precedence: rev > tag > branch.** The canonical precedence every
129    /// per-`:fonte` git-ref consumer already applies: caixa-resolver's
130    /// per-fetch `git checkout <ref>` reads through the same
131    /// `rev.or(tag).or(branch)` cascade at caixa-resolver/src/resolve.rs,
132    /// and caixa-crd's `dep_into_ref` `CaixaSource.git_ref` fill reads
133    /// through the same cascade at caixa-crd/src/conversion.rs. The
134    /// [`Self::validate`] gate enforces "exactly one pin set" — under
135    /// that invariant every accepted [`Self::Git`] carries exactly one
136    /// non-`None` pin and the precedence is unobservable, but the
137    /// precedence remains defined for pre-validate consumers (the
138    /// resolver's `MissingPin` diagnostic path, the caixa-crd
139    /// round-trip's default `"main"` fallback the author never sees a
140    /// diagnostic on) and defense-in-depth for a hypothetical future
141    /// state where multiple pins survive the gate. The precedence is
142    /// **rev before tag** because `:rev` (a git commit OID) is the
143    /// reproducibility-strongest identifier — an OID resolves to exactly
144    /// one commit regardless of which refname points at it, whereas
145    /// `:tag` and `:branch` are refnames the remote can silently move
146    /// (a tag re-push, a branch head advance); the resolver's freeze
147    /// step at fetch time promotes the resolved commit to `:rev` for
148    /// exactly this reason. **Tag before branch** because `:tag` is
149    /// conventionally immutable (a release tag) whereas `:branch` is
150    /// conventionally mutable (a tracking ref) — a caixa carrying both
151    /// a release tag and a tracking branch reads as "prefer the release
152    /// pin, fall through to the tracking pin only if the release is
153    /// missing". The cascade order also matches the byte-order every
154    /// per-`:tag`/`:rev`/`:branch` diagnostic tuple this crate emits
155    /// (`(":tag", tag), (":rev", rev), (":branch", branch)` — see
156    /// [`Self::validate`]'s `pins` array).
157    ///
158    /// Prior to this lift the "sole set pin" projection sat twice in the
159    /// workspace — inline at caixa-resolver's `fetch_git` (`let gitref =
160    /// rev.or(tag).or(branch).ok_or_else(|| ResolveError::MissingPin
161    /// { … })?;`) and at caixa-crd's `dep_into_ref`
162    /// (`git_ref: rev.clone().or(tag.clone()).or(branch.clone())
163    /// .unwrap_or_else(|| "main".to_string())`) — two open-coded copies
164    /// of the same precedence cascade with no compile-time link back to
165    /// the typed slot. A future extension of the pin axis to a richer
166    /// author surface (a `:commit` pin peer of `:rev` once the substrate
167    /// grows a signed-commit-verification pin, a `:ref` pin the M4
168    /// substrate operator resolves per-cluster ahead of fetch, a
169    /// promotion of the plain `Option<String>` pins to a typed
170    /// `GitPin::{Rev(Oid), Tag(RefName), Branch(RefName)}` newtype
171    /// once the sibling [`crate::render::is_git_oid`] /
172    /// [`crate::render::is_git_ref_name`] gates land as typed
173    /// constructors) would have had to be threaded through both
174    /// open-coded copies in lockstep or the resolver's `git checkout`
175    /// target would silently disagree with the CRD's `git_ref` fill —
176    /// an author's `(:fonte (:tipo git :repo "…" :rev "deadbeef" :tag
177    /// "v1"))` would ship with the resolver checking out `deadbeef`
178    /// while the CRD round-trip re-emitted a Dep pointing at `v1`, one
179    /// lacre closure disagreeing with the emitted K8s CR the operator
180    /// reads. Lifting the resolution to a typed method on the substrate
181    /// primitive means both downstream consumers reach for exactly one
182    /// typed dispatch — the resolver's accept-set migrates as a unit on
183    /// any future pin-axis addition.
184    ///
185    /// Peer of the sibling outer-`Dep` [`Dep::fonte`] (d65d1bf)
186    /// `Option<&DepSource>` composite-reference accessor on the outer-
187    /// `Dep` `:fonte`-slot axis — extended one nesting level down onto
188    /// the per-[`Self::Git`]-variant sole-set-pin projection axis every
189    /// git-fetching consumer runs after the outer `:fonte` slot resolves
190    /// to a [`Self::Git`] shape. Same "one typed dispatch on the
191    /// substrate primitive, thin projections at each consumer" discipline
192    /// the outer accessor family already carries.
193    #[must_use]
194    pub fn sole_pin(&self) -> Option<&str> {
195        match self {
196            Self::Git {
197                tag, rev, branch, ..
198            } => rev.as_deref().or(tag.as_deref()).or(branch.as_deref()),
199            Self::Path { .. } => None,
200        }
201    }
202
203    /// Validate the `:fonte` value-shape: every author-surface
204    /// `:fonte (:tipo git …)` must carry a non-empty `:repo` and
205    /// exactly one of `:tag` / `:rev` / `:branch` set to a non-empty
206    /// value; every `:fonte (:tipo path …)` must carry a non-empty
207    /// `:caminho`.
208    ///
209    /// Called from [`Dep::validate`] with the dep's `:nome` so every
210    /// diagnostic carries the offending entry verbatim — same
211    /// self-locating shape the `:deps :versao` (2420c44),
212    /// `:membros :versao` (9888b13), `:children :versao` (b38ff3a),
213    /// `:placement :clusters` (6cbb900), and `:membros :caixa`
214    /// (3f9d7a0) gates already expose.
215    ///
216    /// Until this gate landed `:fonte` was the only `:deps`-related
217    /// typed surface still untyped past `Caixa::from_lisp`:
218    /// - Empty `:repo` (`(:tipo git :repo "" :tag "v1")`) silently
219    ///   passed parse and surfaced as a git-clone failure at
220    ///   lacre-resolve time, far from the source caixa.lisp.
221    /// - A bare `(:tipo git :repo "…")` with no `:tag`/`:rev`/`:branch`
222    ///   passed parse and surfaced as the resolver's
223    ///   [`ResolveError::MissingPin`](../../caixa-resolver/src/resolve.rs)
224    ///   at fetch time, again far from the source caixa.lisp; lifting
225    ///   to validate-time gives the author the same diagnostic at the
226    ///   edit site.
227    /// - `(:tipo git :repo "…" :tag "v1" :branch "main")` — multiple
228    ///   pins set — passed parse and the resolver silently picked
229    ///   `:rev > :tag > :branch`, ignoring the other pins with no
230    ///   diagnostic; the author had no way to know their `:branch`
231    ///   was dropped. This is the canonical "pin drift" footgun.
232    /// - An empty pin value (`(:tipo git :repo "…" :tag "")`) silently
233    ///   passed parse and surfaced as `git checkout ""` at fetch time.
234    /// - Empty `:caminho` (`(:tipo path :caminho "")`) silently passed
235    ///   parse and surfaced as
236    ///   [`ResolveError::MissingPath`](../../caixa-resolver/src/resolve.rs)
237    ///   with `path: PathBuf("")` — not actionable.
238    ///
239    /// Each rejected shape maps to a typed
240    /// [`DepError::Fonte*`] variant that names the offending
241    /// dep's `:nome` and the specific axis, so the author can grep
242    /// their caixa.lisp for the `:nome "<nome>"` block and fix it in
243    /// one edit.
244    pub fn validate(&self, nome: &str) -> Result<(), DepError> {
245        match self {
246            Self::Git {
247                repo,
248                tag,
249                rev,
250                branch,
251            } => {
252                if repo.is_empty() {
253                    return Err(DepError::fonte_repo_empty(nome));
254                }
255                // The `:repo` value flows verbatim into the caixa-resolver's
256                // `git clone <repo>` subprocess invocation. Until this gate
257                // landed `:repo` was the last untyped `:fonte`-related axis
258                // past the empty arm: a malformed-but-non-empty repo URL
259                // (`":repo "github:p/x ""` trailing space, paste-from-doc;
260                // `":repo "-upload-pack=evil""` leading `-` — the canonical
261                // CLI-argument-injection vector at the `git clone` boundary;
262                // `":repo "pleme-io/caixa-teia""` missing scheme — `git clone`
263                // reads as a relative filesystem path rather than the
264                // GitHub-shorthand expansion; `":repo "github:p/x\n""`
265                // embedded newline; `":repo "github:café/x""` raw non-ASCII)
266                // silently passed validate and the failure surfaced at
267                // lacre-resolve time with a porcelain-quoting-confused error
268                // far from the source caixa.lisp. The lifted predicate makes
269                // the git-porcelain-URL intersection-floor a substrate-level
270                // invariant at validate time, peer with the three pin axes
271                // (`:tag` + `:branch` via [`crate::render::is_git_ref_name`],
272                // e70d213; `:rev` via [`crate::render::is_git_oid`], be07fd5)
273                // — every `:fonte (:tipo git …)` past validate is now
274                // structurally accept-shaped on every axis the resolver
275                // consumes (the `:repo` URL the `git clone` invokes against,
276                // the `:tag`/`:branch` refname `git fetch`/`git checkout`
277                // accepts, the `:rev` commit OID the lacre's content-
278                // addressing equality probe resolves), closing the
279                // `:fonte` slot's value-shape trajectory end-to-end.
280                if let Err(reason) = crate::render::is_git_repo_url(repo) {
281                    return Err(DepError::fonte_repo_shape(nome, repo, reason));
282                }
283                let pins: [(&'static str, Option<&String>); 3] = [
284                    (":tag", tag.as_ref()),
285                    (":rev", rev.as_ref()),
286                    (":branch", branch.as_ref()),
287                ];
288                let set: Vec<&'static str> =
289                    pins.iter().filter_map(|(n, v)| v.map(|_| *n)).collect();
290                match set.len() {
291                    0 => {
292                        return Err(DepError::fonte_pin_missing(nome));
293                    }
294                    1 => {
295                        for (pin, value) in pins {
296                            if value.is_some_and(String::is_empty) {
297                                return Err(DepError::fonte_pin_empty(nome, pin));
298                            }
299                        }
300                    }
301                    _ => {
302                        return Err(DepError::fonte_pin_ambiguous(nome, &set.join(", ")));
303                    }
304                }
305                // Per-pin value-shape gate. The refname-shaped axes
306                // (`:tag` + `:branch`) route through
307                // [`crate::render::is_git_ref_name`]; the hex-OID-shaped
308                // `:rev` axis routes through
309                // [`crate::render::is_git_oid`]. The two predicates
310                // partition the `:fonte` pin axes structurally — refname
311                // vs. hex commit — so a cross-axis mis-slot (the
312                // canonical "I conflated `:rev` and `:branch`" footgun:
313                // `:rev "main"` defeating the reproducibility contract,
314                // `:tag "deadbeef…"` mis-slotting a SHA into the
315                // refname-shaped axis) lands at the offending axis's
316                // predicate, not at lacre-resolve `git fetch` /
317                // `git checkout` time. Their valid sets intersect at
318                // the empty set: every refname is rejected by
319                // `is_git_oid`, every OID is rejected by
320                // `is_git_ref_name`, structurally.
321                //
322                // Until this gate landed `:tag` / `:branch` were the
323                // refname-shaped axes still untyped past the empty-pin
324                // arm: a malformed-but-non-empty refname
325                // (`:tag "v0.1.0 "` trailing space — the canonical
326                // paste-from-doc footgun; `:tag "v0.1.0.lock"` colliding
327                // with git's atomic-rename guard suffix; `:tag "../escape"`
328                // path-traversal via consecutive dots; `:branch "main "`
329                // trailing space; `:branch "feature/foo bar"` embedded
330                // space; `:branch "@"` the literal HEAD alias;
331                // `:branch "refs/heads/main"` the fully-qualified ref
332                // copied from `git show-ref` output that resolves to
333                // a literal ref named `refs/heads/refs/heads/main` on
334                // disk) silently passed validate; the `:rev` axis was
335                // the last `:fonte`-related axis still untyped past the
336                // empty-pin arm: a malformed-but-non-empty hex-OID
337                // (`:rev "main"` conflating with `:branch` — the
338                // reproducibility-contract leak; `:rev "v0.1.0"`
339                // conflating with `:tag` — the same mis-slot on the
340                // refname/OID boundary; `:rev "c0ffee"` an abbreviated
341                // 6-char prefix that's ambiguous across repo history;
342                // `:rev "DEADBEEF…"` an uppercase OID that round-trips
343                // inconsistently against `git rev-parse HEAD`'s
344                // lowercase emission) silently passed validate and the
345                // failure surfaced at lacre-resolve `git fetch` /
346                // `git checkout` time with a quoting-confused error
347                // far from the source caixa.lisp, with no field naming
348                // which `:deps` entry carried the typo. Lifting both
349                // gates to caixa-build time matches the value-shape
350                // trajectory the peer typed axes already follow
351                // (c4213a4 typed WitContract endpoint/subject/slot;
352                // eb3456d :entrada :paths; c7d05ec :entrada :host;
353                // 4f0390b :contratos :endpoint; 6226bf4 :contratos :wit;
354                // 63e18a0 :contratos :subject; 2f4316e :contratos
355                // :slot; e70d213 :fonte :tag + :branch) — the typed
356                // slot's valid set matches its downstream consumer's
357                // accepted set (here, the git porcelain's refname /
358                // commit-OID grammars at `git fetch` / `git checkout`
359                // time), structurally. Same diagnostic shape every
360                // per-axis value-shape lift already exposes
361                // (`*Invalid { axis, reason }`); the `value:` field
362                // carries the offending refname / OID verbatim so the
363                // author can grep their caixa.lisp for the
364                // `:tag "<value>"` / `:branch "<value>"` /
365                // `:rev "<value>"` literal and fix it in one edit.
366                for (pin, value) in [(":tag", tag.as_ref()), (":branch", branch.as_ref())] {
367                    if let Some(v) = value
368                        && let Err(reason) = crate::render::is_git_ref_name(v)
369                    {
370                        return Err(DepError::fonte_pin_shape(nome, pin, v, reason));
371                    }
372                }
373                if let Some(v) = rev.as_ref()
374                    && let Err(reason) = crate::render::is_git_oid(v)
375                {
376                    return Err(DepError::fonte_pin_shape(nome, ":rev", v, reason));
377                }
378                Ok(())
379            }
380            Self::Path { caminho } => Self::validate_caminho(nome, caminho),
381        }
382    }
383
384    /// Reproducibility + path-API gate on the `:fonte (:tipo path …)`
385    /// `:caminho` axis. Walks the leading-byte cascade closed by the
386    /// b94fd83 (`/`), a5c248e (`~`), and f4efe9c (`$`) arms; the
387    /// orthogonal embedded-control-byte arm (d624c8d) covering
388    /// `0x00..=0x1F` plus `0x7F` anywhere in the value; and the
389    /// embedded-`\` Windows-path-separator arm closing the
390    /// cross-host-OS-separator divergence vector on the same
391    /// THEORY.md §V.2 render-determinism axis.
392    ///
393    /// Extracted from [`Self::validate`]'s `Self::Path` arm because the
394    /// per-arm cascade now spans nine diagnostic shapes — every new
395    /// `:caminho` arm (a future `&` / `;` / `|` shell-metachar arm,
396    /// a future glob-metachar `*` / `?` arm) lands here rather than
397    /// re-inflating `Self::validate`. The
398    /// function stays a thin per-arm linear walk for one reason: each
399    /// arm's diagnostic carries a distinct typed [`DepError`] variant
400    /// rather than a parser-shaped `reason` string, so collapsing the
401    /// cascade onto a generic [`crate::render`] predicate would regress
402    /// the per-arm self-locating diagnostic that `feira lint` consumers
403    /// depend on. The wrapped predicate trajectory ([`crate::render::is_dns_1123_label`],
404    /// [`crate::render::is_git_repo_url`], etc.) lives on the
405    /// reason-string-shaped axes; the `:caminho` axis keeps its
406    /// per-arm variant shape.
407    #[allow(
408        clippy::too_many_lines,
409        reason = "the per-arm cascade is structurally flat by design — every \
410                  `:caminho` arm carries its own typed [`DepError`] variant + \
411                  per-arm Why comment, so collapsing the cascade onto a generic \
412                  [`crate::render`] predicate would regress the per-arm self-locating \
413                  diagnostic the `feira lint` consumer surface depends on"
414    )]
415    fn validate_caminho(nome: &str, caminho: &str) -> Result<(), DepError> {
416        if caminho.is_empty() {
417            return Err(DepError::fonte_caminho_empty(nome));
418        }
419        // Reproducibility gate on the `:fonte (:tipo path …)`
420        // `:caminho` axis. The lacre pipeline embeds the value
421        // verbatim in its per-dep content-address
422        // (`conteudo: format!("path:{caminho}")`,
423        // caixa-resolver/src/resolve.rs:189) and that string
424        // folds into the BLAKE3 closure the lacre keys every
425        // downstream consumer (the substrate's reproducibility
426        // contract, CAIXA-SDLC §III.2 — the lacre is the
427        // build's content-addressed identity, peer of the Nix
428        // store path) against. Until this gate landed an
429        // absolute `:caminho` (`/home/me/work/caixa-teia` — the
430        // canonical "I dragged the folder out of Finder into
431        // my editor" footgun; `/Users/alice/dev/caixa-teia` on
432        // the macOS path-layout peer; the
433        // `${WORKSPACE}/caixa-teia` shell-expanded literal
434        // pasted from a CI manifest) silently passed validate
435        // and the failure surfaced *as a successful build with
436        // a divergent lacre*: the BLAKE3 closure on Alice's
437        // workstation differed from the closure on Bob's
438        // workstation, two CI runners with different
439        // `${HOME}` layouts emitted two distinct
440        // content-addresses for the byte-identical caixa, and
441        // the substrate's "the lacre is the build's identity"
442        // contract silently broke far from the source
443        // caixa.lisp — the most insidious failure mode the
444        // typed slot can carry (no error surfaces; the
445        // divergence is invisible until two machines compare
446        // lacres). The same THEORY.md §V.2 render-determinism
447        // discipline `is_sandboxed_relative_path` already
448        // applies on the M2 typed path-slots
449        // (`:behavior :on-*`, `:upgrade-from :state-change
450        // :script`, `:bibliotecas`, `:exe`, `:servicos`), here
451        // narrowed to the absolute-vs-relative axis only:
452        // `:fonte :caminho`'s canonical author-surface form is
453        // the `..`-traversing sibling-workspace path
454        // (`"../caixa-teia"`, the in-tree dev-dep frame), so a
455        // full `is_sandboxed_relative_path` lift would
456        // structurally reject every legitimate path-fonte
457        // dep. The narrower
458        // `std::path::Path::is_absolute` cut admits the
459        // sibling-workspace form while still rejecting the
460        // host-layout-leaking absolute shape — the
461        // reproducibility contract bites at exactly the
462        // absolute boundary, and that's the axis the
463        // substrate-level invariant is meant to hold. Same
464        // diagnostic shape every per-axis value-shape lift on
465        // the surrounding [`DepError::Fonte*`] cluster carries
466        // (the offending `:nome` + offending `:caminho`
467        // quoted verbatim so the author can grep their
468        // caixa.lisp for the `:caminho "<value>"` literal and
469        // fix it in one edit). The empty arm strictly
470        // precedes this arm so the blank-string footgun
471        // surfaces the more self-locating
472        // `FonteCaminhoEmpty` diagnostic (the empty string
473        // is not absolute under `Path::new("").is_absolute()`
474        // so the precedence is a no-op at value level — the
475        // pin matters only at the diagnostic-shape level if
476        // a future codec round-trip ever produces an empty
477        // string that probes as absolute).
478        if std::path::Path::new(caminho).is_absolute() {
479            return Err(DepError::fonte_caminho_absolute(nome, caminho));
480        }
481        // Reproducibility gate's tilde-expansion arm. The b94fd83
482        // `FonteCaminhoAbsolute` closes the leading-`/`
483        // host-layout-leak; a `:caminho "~/work/caixa-teia"` (the
484        // canonical paste-from-shell-prompt / paste-from-`cd ~`-
485        // doc footgun) silently passed both the empty arm and
486        // the absolute arm because `Path::new("~").is_absolute()`
487        // returns `false` — `~` is a shell-expansion convention,
488        // not a POSIX path component, so `std::path::Path` treats
489        // it as a literal directory-name segment. The lacre
490        // pipeline then embedded the value verbatim
491        // (`conteudo: format!("path:~/work/caixa-teia")`) and the
492        // failure mode forked per consumer:
493        //
494        //   - The caixa-resolver's `Path` arm folds `:caminho`
495        //     through `Path::new(caminho).join(<file>)` without
496        //     `~`-expansion, so the build looked for a literal
497        //     `./~/work/caixa-teia` subdirectory and failed at
498        //     resolve time with a `No such file or directory`
499        //     error far from the source caixa.lisp (the lacre
500        //     itself, though, was already byte-identical across
501        //     machines — every machine emitted the same
502        //     `path:~/work/caixa-teia` content-address).
503        //   - A future caixa-resolver pass that *does* expand `~`
504        //     (the canonical shell-convention idiom every
505        //     resolver eventually reaches for once an author
506        //     reports the literal-`~`-directory bug) would re-
507        //     introduce the host-layout-leak the b94fd83 absolute
508        //     gate closes: Alice's `~` expands to `/home/alice`,
509        //     Bob's to `/home/bob`, two CI runners with different
510        //     `$HOME` layouts resolve to two distinct paths for
511        //     the byte-identical caixa, and the substrate's
512        //     "the lacre is the build's identity" contract
513        //     silently breaks far from the source caixa.lisp.
514        //
515        // Closing the gate at `DepSource::validate` (here at the
516        // canonical caixa-build-time boundary, peer with the
517        // absolute arm above) refuses both failure modes
518        // structurally: the typed accepted set excludes every
519        // `~`-prefixed authoring shape, so the resolver is
520        // free to grow `~`-expansion (or any other convention-
521        // expansion the substrate adopts) without re-opening
522        // the host-layout-leak at the typed boundary. Same
523        // diagnostic shape every per-axis value-shape gate on
524        // the surrounding [`DepError::Fonte*`] cluster carries
525        // (the offending `:nome` + offending `:caminho` quoted
526        // verbatim so the author can grep their caixa.lisp for
527        // the `:caminho "<value>"` literal and fix it in one
528        // edit).
529        //
530        // The cascade preserves narrower-diagnostic-first
531        // ordering: `FonteCaminhoEmpty` → `FonteCaminhoAbsolute`
532        // → `FonteCaminhoTildeExpansion`. The empty arm
533        // structurally precedes both (the bytes "" / "~" don't
534        // overlap), and the absolute arm structurally precedes
535        // the tilde arm (an absolute path can't start with `~`
536        // since absolute paths start with `/`; the bytes "/" /
537        // "~" don't overlap either). Both arms are
538        // value-disjoint, so the precedence is a no-op at value
539        // level — the pin matters only at the diagnostic-shape
540        // level if a future codec round-trip ever produces a
541        // value that probes as both absolute and tilde-prefixed.
542        if caminho.starts_with('~') {
543            return Err(DepError::fonte_caminho_tilde_expansion(nome, caminho));
544        }
545        // Reproducibility gate's shell-variable-expansion arm.
546        // The b94fd83 `FonteCaminhoAbsolute` closes the leading-`/`
547        // host-layout-leak; the a5c248e `FonteCaminhoTildeExpansion`
548        // closes the leading-`~` shell-home-expansion shape; the
549        // leading-`$` is the sibling shell-variable-expansion shape
550        // — same host-layout-leaking semantic, different syntactic
551        // surface. A `:caminho "$HOME/work/caixa-teia"` (the
552        // canonical paste-from-`echo $HOME`-doc footgun) and the
553        // `${VAR}`-braced variant (`"${WORKSPACE}/caixa-teia"` —
554        // the canonical paste-from-CI-manifest footgun every
555        // GitHub Actions / GitLab CI / Drone manifest carries)
556        // silently passed every prior arm because
557        // `Path::is_absolute` returns false on `$` (the `$` is a
558        // shell convention, not a POSIX path component, so
559        // `std::path::Path` treats it as a literal directory-name
560        // segment) and the tilde arm's `starts_with('~')` doesn't
561        // fire.
562        //
563        // Same per-consumer failure-fork the tilde arm closes:
564        //
565        //   - The caixa-resolver's `Path` arm folds `:caminho`
566        //     through `Path::new(caminho).join(<file>)` without
567        //     `$`-expansion, so the build looks for a literal
568        //     `./$HOME/work/caixa-teia` subdirectory and fails at
569        //     resolve time with a `No such file or directory`
570        //     error far from the source caixa.lisp.
571        //   - A future caixa-resolver pass that *does* expand
572        //     `$VAR` (the shell-convention idiom every resolver
573        //     eventually reaches for once an author reports the
574        //     literal-`$HOME`-directory bug, especially for CI's
575        //     `${WORKSPACE}` idiom) would re-introduce the host-
576        //     layout-leak the b94fd83 absolute gate closes:
577        //     Alice's `$HOME` expands to `/home/alice`, Bob's to
578        //     `/home/bob`, two CI runners with different
579        //     `${WORKSPACE}` layouts resolve to two distinct
580        //     paths for the byte-identical caixa, and the
581        //     substrate's "the lacre is the build's identity"
582        //     contract silently breaks far from the source
583        //     caixa.lisp.
584        //
585        // Closing the gate at `DepSource::validate` (here at the
586        // canonical caixa-build-time boundary, peer with the
587        // absolute + tilde arms above) refuses both failure modes
588        // structurally. Same diagnostic shape every per-axis
589        // value-shape gate on the surrounding [`DepError::Fonte*`]
590        // cluster carries (the offending `:nome` + offending
591        // `:caminho` quoted verbatim).
592        //
593        // The cascade preserves narrower-diagnostic-first ordering:
594        // `FonteCaminhoEmpty` → `FonteCaminhoAbsolute` →
595        // `FonteCaminhoTildeExpansion` → `FonteCaminhoVarExpansion`.
596        // The empty arm structurally precedes all three subsequent
597        // arms; the absolute arm structurally precedes both the
598        // tilde and the var arms (absolute paths start with `/`,
599        // the bytes `/` / `~` / `$` don't overlap at the leading
600        // position); the tilde arm structurally precedes the var
601        // arm (`~` and `$` don't overlap at the leading position).
602        // Every pair is value-disjoint, so the precedence is a
603        // no-op at value level — the pin matters only at the
604        // diagnostic-shape level if a future codec round-trip ever
605        // produces a probe-as-both value.
606        //
607        // The gate covers every leading-`$` shape: the canonical
608        // `"$HOME/work/caixa-teia"` (POSIX shell), the braced
609        // `"${HOME}/work/caixa-teia"` (POSIX shell braces), the
610        // CI-manifest idiom `"${WORKSPACE}/caixa-teia"` (the
611        // GitHub Actions / GitLab CI / Drone paste footgun), the
612        // XDG idiom `"$XDG_CONFIG_HOME/caixa"`, and the bare `$`
613        // (degenerate "I meant `$HOME` and forgot the rest"). All
614        // shapes route through the same `caminho.starts_with('$')`
615        // byte check.
616        if caminho.starts_with('$') {
617            return Err(DepError::fonte_caminho_var_expansion(nome, caminho));
618        }
619        // Reproducibility gate's leading-space arm. The b94fd83 / a5c248e /
620        // f4efe9c arms closed the leading-byte host-layout-leak shapes
621        // (`/` / `~` / `$`); the embedded-control-byte arm below closes
622        // every byte in `0x00..=0x1F` plus `0x7F` (which already includes
623        // tab `0x09`, LF `0x0A`, CR `0x0D` — every ASCII whitespace
624        // *except* the ASCII space byte `0x20`). The bare ASCII space at
625        // the leading position is the orthogonal paste-from-aligned-doc
626        // shape that silently passed every prior arm: `Path::is_absolute`
627        // returns false on `" ../caixa-teia"` (the leading byte is `0x20`
628        // not `0x2F`), `0x20` is not `~` / `$` / `\` / a control byte, and
629        // the value's last byte is not `/`, so the canonical
630        // paste-from-aligned-`caixa.lisp`-doc footgun (every `:fonte`
631        // form in a multi-entry `:deps` block sits at the same column —
632        // an author selecting `"<sp><sp><sp>../caixa-teia"` and pasting
633        // it from the rendered alignment into a fresh entry preserves the
634        // leading whitespace verbatim) silently rendered as a path with
635        // a leading-space directory component the resolver folds through
636        // `Path::join` looking for a literal `./ ../caixa-teia`
637        // subdirectory that fails at resolve time with a non-self-
638        // locating `No such file or directory` error.
639        //
640        // The lacre pipeline's reproducibility contract bites
641        // strictly at this byte: `path:" ../caixa-teia"` and
642        // `path:"../caixa-teia"` yield distinct BLAKE3 closures
643        // (`conteudo: format!("path:{caminho}")`,
644        // caixa-resolver/src/resolve.rs:189) for the byte-divergent /
645        // semantic-identical caixa, and the substrate's "the lacre is
646        // the build's identity" contract (CAIXA-SDLC §III.2) silently
647        // breaks across two workstations whose authors differ only in
648        // paste-from-aligned-doc whitespace habits — the most insidious
649        // failure mode the typed slot can carry (no error surfaces; the
650        // divergence is invisible until two machines compare lacres).
651        //
652        // The arm fires AFTER the absolute / tilde / var leading-byte
653        // arms (each names the more self-locating shell-convention
654        // diagnostic on values that probe as that arm's leading-byte
655        // sentinel followed by a leading space — e.g.
656        // `:caminho "/  /foo"` surfaces `FonteCaminhoAbsolute` because
657        // the leading byte is `/`, not space) and BEFORE the
658        // embedded-control-byte arm (a leading-space value with an
659        // embedded control byte surfaces the broader leading-space
660        // diagnostic because the cascade walks leading-byte arms first
661        // — peer with how `FonteCaminhoAbsolute` precedes
662        // `FonteCaminhoControlChar` on `"/etc/passwd\n"`).
663        //
664        // The peer single-token-shaped axes already reject leading
665        // whitespace on the same paste-from-aligned-doc contract:
666        // [`crate::render::is_git_repo_url`] rejects leading whitespace
667        // on `:fonte :repo`, [`crate::render::is_git_ref_name`] rejects
668        // leading whitespace on `:fonte :tag`/`:branch`,
669        // [`crate::render::is_chart_description_shape`] rejects leading
670        // whitespace on `:descricao`,
671        // [`crate::render::is_spdx_expression_shape`] rejects leading
672        // whitespace on `:licenca`. Closing the same byte on
673        // `:fonte :caminho` makes the substrate-wide "no leading ASCII
674        // space anywhere in a typed string slot" invariant structurally
675        // consistent across every value-shape-gated typed surface (the
676        // `:caminho` axis was the last typed string surface still
677        // admitting a leading space byte).
678        if caminho.starts_with(' ') {
679            return Err(DepError::fonte_caminho_leading_whitespace(nome, caminho));
680        }
681        // Reproducibility gate's leading-`-` CLI-argument-injection arm.
682        // The b94fd83 + a5c248e + f4efe9c + LeadingWhitespace arms closed
683        // the four prior leading-byte shapes (`/` / `~` / `$` / space);
684        // this arm closes the orthogonal leading-`-` axis on the same
685        // subprocess-argument-boundary the peer `is_git_repo_url` arm
686        // (render.rs:2037, `-upload-pack=…` on `:fonte :repo`) and
687        // `is_git_ref_name` arm (render.rs:1381, 5a28454, `-stable` on
688        // `:fonte :tag` / `:branch`) already reject.
689        //
690        // The lacre pipeline embeds `:caminho` verbatim in its per-dep
691        // content-address (`conteudo: format!("path:{caminho}")`,
692        // caixa-resolver/src/resolve.rs:189) and the resolver folds the
693        // value through `Path::join` looking for a literal `./{caminho}`
694        // subdirectory. Every downstream subprocess that consumes the
695        // resolved path — a `git -C {caminho} <verb>` invocation, a
696        // future `feira tofu` `terraform -chdir={caminho}` shell-out, a
697        // future operator-side `nix build --path {caminho}` spawn, an
698        // `xargs` / `find {caminho}` / `stat {caminho}` /
699        // `rm -rf {caminho}` cleanup — reinterprets a leading-`-` value
700        // as a CLI flag rather than a positional path when the
701        // subprocess invocation does not carry a `--` argument-list
702        // terminator between the flag block and the path argument. The
703        // canonical footguns:
704        //
705        //   - `:caminho "-rf"` — bare short-flag paste (`rm -rf` /
706        //     `find -rf` reinterpretation; the byte the peer
707        //     `FonteCaminhoShellSemicolon` arm's `; rm -rf build`
708        //     example paste-idiom carries as its first token).
709        //   - `:caminho "-C"` — `git -C` config-injection paste
710        //     (`git -C -C` reinterprets the second `-C` as another
711        //     `--change-directory` flag rather than the path
712        //     argument; the canonical `git -C <path>` porcelain
713        //     idiom every multi-repo workspace tool carries).
714        //   - `:caminho "--upload-pack=cat /etc/passwd"` — the
715        //     canonical long-flag CLI-arg-injection vector at every
716        //     git porcelain entry point (`git clone`, `git fetch`,
717        //     `git ls-remote`) that consumes a path or URL
718        //     argument; peer with `is_git_repo_url`'s leading-`-`
719        //     arm (render.rs:2037) on the sibling `:fonte :repo`
720        //     axis, which the arm's diagnostic explicitly cites.
721        //   - `:caminho "--config=…"` / `:caminho "-c"` — git-config
722        //     override paste-idiom (paste-from-`git -c foo=bar`
723        //     shell-history footgun that reinterprets the value as
724        //     a `[foo] bar` config injection on every git porcelain
725        //     entry point).
726        //
727        // POSIX `std::path::Path` treats a leading `-` as a literal
728        // filename byte, so the resolver folds `-rf` through `Path::join`
729        // and looks for a literal `./-rf` subdirectory — the failure
730        // surfaces at resolve time with a non-self-locating `No such
731        // file or directory` error far from the source caixa.lisp, and
732        // the value rides through the lacre content-address into every
733        // downstream shell-spawned subprocess. On any consumer that
734        // shells out without the `--` terminator (the common case at
735        // every porcelain entry-point) the reinterpretation is silent
736        // and the failure mode is arbitrary-argument-injection.
737        //
738        // The arm fires AFTER the absolute / tilde / var / leading-space
739        // leading-byte arms (each names the more self-locating shell-
740        // convention diagnostic on values that probe as that arm's
741        // leading-byte sentinel — the byte sets are pairwise disjoint at
742        // the leading position, so the precedence pin is a no-op at
743        // value level, but the ordering keeps every leading-byte arm's
744        // diagnostic-shape stable) and BEFORE the embedded-control-byte
745        // arm (a leading-`-` value with an embedded control byte
746        // surfaces the narrower leading-`-` diagnostic because the
747        // cascade walks leading-byte arms first — peer with how
748        // `FonteCaminhoAbsolute` precedes `FonteCaminhoControlChar` on
749        // `"/etc/passwd\n"`, and how `FonteCaminhoLeadingWhitespace`
750        // precedes `FonteCaminhoControlChar` on `" ../foo\n"`).
751        //
752        // The peer single-token-shaped axes already reject leading `-`
753        // on the same CLI-arg-injection contract:
754        // [`crate::render::is_git_repo_url`] rejects it on `:fonte :repo`
755        // (render.rs:2037), [`crate::render::is_git_ref_name`] rejects
756        // it on `:fonte :tag` / `:fonte :branch` (render.rs:1381,
757        // 5a28454), [`crate::render::is_dns_1123_label`] rejects it on
758        // every DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros
759        // :caixa`, `:children :caixa`, `:deps :nome`, cluster names),
760        // [`crate::render::is_cargo_feature_name`] rejects it on
761        // `:caracteristicas`, and the feira `init` / `add <nome>`
762        // positional gate (868c191) rejects it on the CLI positional
763        // itself. Closing the same byte on `:fonte :caminho` makes the
764        // substrate-wide "no leading `-` anywhere in a typed single-
765        // token string slot routed through a subprocess argument"
766        // invariant structurally consistent across every value-shape-
767        // gated typed surface (the `:caminho` axis was the last typed
768        // string surface still admitting a leading `-` byte).
769        if caminho.starts_with('-') {
770            return Err(DepError::fonte_caminho_leading_hyphen(nome, caminho));
771        }
772        // Reproducibility gate's embedded-control-byte arm. The
773        // b94fd83 + a5c248e + f4efe9c arms closed the three
774        // leading-byte host-layout-leak shapes (`/` / `~` / `$`);
775        // this arm closes the orthogonal embedded-control-byte
776        // axis — any ASCII control byte (`0x00..=0x1F` plus
777        // `0x7F` DEL) appearing anywhere in `:caminho`. Same
778        // shape every peer single-token-typed-slot value-shape
779        // predicate the surrounding [`crate::render`] cluster
780        // gates against (the lifted `is_git_repo_url` arm on
781        // `:fonte :repo`, the `is_git_ref_name` arm on
782        // `:tag`/`:branch`, the `is_chart_description_shape` /
783        // `is_chart_maintainer_name_shape` /
784        // `is_chart_keyword_shape` arms on the
785        // Helm-chart-shaped axes); now consistent on the
786        // `:caminho` axis too.
787        //
788        // Until this gate landed any embedded control byte
789        // silently passed validate, the lacre pipeline embedded
790        // the value verbatim in its per-dep content-address
791        // (`conteudo: format!("path:{caminho}")`,
792        // caixa-resolver/src/resolve.rs:189), and the failure
793        // forked per byte and per consumer:
794        //
795        //   - NUL (`0x00`) the canonical "POSIX paths cannot
796        //     contain a NUL byte" shape: every `std::fs` syscall
797        //     routes the path through `CString::new`, which
798        //     fails with `NulError` on the first NUL byte; the
799        //     build would surface a `NulError` at resolve time
800        //     far from the source caixa.lisp.
801        //   - LF (`0x0A`) / CR (`0x0D`) the canonical paste-from-
802        //     multiline-doc footgun: a `:caminho
803        //     "../caixa-teia\nrm -rf /"` value (paste landed mid-
804        //     `:caminho` block from a multi-line code-fence)
805        //     silently round-trips through `Path::join` but the
806        //     embedded newline class is a sibling of the CRLF-at-
807        //     subprocess-argument injection vector
808        //     `is_git_repo_url` already closes on `:repo`.
809        //   - Tab (`0x09`) the canonical paste-from-aligned-table
810        //     footgun: the tab is invisible in most editors, and
811        //     the lacre embeds the value verbatim so two
812        //     paste-from-distinct-tables yield divergent lacres
813        //     across host editors that strip vs preserve tabs.
814        //   - DEL (`0x7F`) + every other `0x00..=0x1F` byte: the
815        //     paste-from-binary-blob shape every peer single-
816        //     token-shaped slot rejects under the same
817        //     `b < 0x20 || b == 0x7F` predicate.
818        //
819        // Mirrors the cascade discipline every prior `:caminho`
820        // arm establishes: `FonteCaminhoEmpty` →
821        // `FonteCaminhoAbsolute` → `FonteCaminhoTildeExpansion`
822        // → `FonteCaminhoVarExpansion` →
823        // `FonteCaminhoLeadingWhitespace` →
824        // `FonteCaminhoLeadingHyphen` → `FonteCaminhoControlChar`.
825        // The six leading-byte arms structurally precede the
826        // embedded-byte arm because the leading-byte shapes are
827        // the more self-locating diagnostic on values that probe
828        // as both (e.g. `:caminho "/etc/passwd\n"` surfaces the
829        // narrower `FonteCaminhoAbsolute` rather than the broader
830        // embedded-control-byte arm); the precedence pin matters
831        // at the diagnostic-shape level even though the empty /
832        // absolute / tilde / var arms are value-disjoint from a
833        // bare control byte (which would itself be a leading
834        // byte under the empty / absolute / tilde / var arms'
835        // leading-position semantics, but those arms guard the
836        // specific shell-convention characters `/` / `~` / `$`
837        // — a leading `0x01` byte falls through to this arm).
838        for &b in caminho.as_bytes() {
839            if b < 0x20 || b == 0x7F {
840                return Err(DepError::fonte_caminho_control_char(nome, caminho, b));
841            }
842        }
843        // Reproducibility gate's Windows-path-separator arm. The four
844        // leading-byte arms (`/` / `~` / `$`) and the embedded-
845        // control-byte arm close the host-layout-leaking + paste-from-
846        // multiline-doc shapes; the leading-`\` / embedded-`\` byte is
847        // the orthogonal cross-host-OS-separator shape — same render-
848        // determinism axis, different semantic mechanism. POSIX
849        // [`std::path::Path`] treats `\` (0x5C) as a literal byte
850        // inside a single path component (so `..\caixa-teia` is one
851        // directory named literally `..\caixa-teia`, sibling of `.`
852        // and `..`); Windows [`std::path::Path`] treats `\` as a
853        // primary path separator equal to `/` (so `..\caixa-teia` is
854        // the parent's sibling directory `caixa-teia`). The lacre
855        // pipeline embeds the value verbatim in its per-dep content-
856        // address (`conteudo: format!("path:{caminho}")`, caixa-
857        // resolver/src/resolve.rs:189), so byte-identical caixa.lisp
858        // values resolve to two distinct directories across runner
859        // OSes — the same THEORY.md §V.2 render-determinism contract
860        // the absolute / tilde / var arms protect, here against the
861        // cross-host-OS-separator divergence vector. Even on POSIX-
862        // only resolvers (the canonical pleme-io substrate posture),
863        // a `..\caixa-teia` (the Windows-Explorer "copy as path" /
864        // PowerShell `Get-Location` paste-idiom footgun) silently
865        // passes every prior arm because `Path::is_absolute` returns
866        // false on `..` and `\` is neither a leading-byte sentinel
867        // nor a control byte, then the resolver folds the value
868        // through `Path::new(caminho).join(<file>)` looking for a
869        // literal `./..\caixa-teia` subdirectory and fails at
870        // resolve time with a non-self-locating `No such file or
871        // directory` error far from the source caixa.lisp.
872        //
873        // The peer single-token-shaped axes on the same git-CLI /
874        // path-CLI consumer cluster already reject `\` under the same
875        // Windows-path-leak banner: [`crate::render::is_git_ref_name`]
876        // line 1441 (`"must not contain \\ … the canonical Windows-
877        // path-leak footgun; use / for hierarchical refs"`) gates
878        // `:fonte :tag` / `:fonte :branch` against the same byte,
879        // and [`crate::render::is_gateway_api_http_path`] line 506
880        // includes `\` in the eleven-byte RFC-3986-reserved rejection
881        // set on `:entrada :paths`. Closing the same byte on `:fonte
882        // :caminho` makes the substrate-wide "no Windows path
883        // separator anywhere in a typed string slot" invariant
884        // structurally consistent across every path-shaped typed
885        // surface (the `:caminho` axis was the last typed string
886        // surface still admitting `\`).
887        //
888        // The arm fires AFTER the control-char arm because the
889        // control-char diagnostic is the more self-locating axis on
890        // values that probe as both (`"..\caixa\0teia"` carries both
891        // a `\` and a NUL — NUL is the load-bearing POSIX-syscall-
892        // rejected byte, so `FonteCaminhoControlChar` wins). Same
893        // narrower-diagnostic-first cascade discipline every prior
894        // arm establishes. A pure-`\` value
895        // (`"..\caixa-teia"` with no control bytes) falls through
896        // every prior arm and lands here.
897        for &b in caminho.as_bytes() {
898            if b == b'\\' {
899                return Err(DepError::fonte_caminho_backslash(nome, caminho));
900            }
901        }
902        // Reproducibility gate's shell-redirection arm. The 3a4e1d7 backslash
903        // arm closes the cross-host-OS-separator vector; `<` (`0x3C`) and `>`
904        // (`0x3E`) are the orthogonal shell-redirection sentinels — same
905        // paste-from-shell-prompt footgun class, different syntactic surface.
906        // POSIX `std::path::Path` treats `<` / `>` as literal bytes inside a
907        // single path component (so `../caixa-teia>output` is one directory
908        // named literally `../caixa-teia>output`, sibling of `.` and `..`),
909        // but every interactive shell (bash / zsh / fish / nushell) lexes
910        // `<` / `>` as input / output redirection operators — a `:caminho
911        // "../caixa-teia>build.log"` (the canonical "I pasted a shell
912        // pipeline that wrote build output and forgot to trim the redirect"
913        // footgun) or `:caminho "../<input.lisp"` (the symmetric input-
914        // redirection paste idiom) silently passes every prior arm because
915        // `Path::is_absolute` returns false, `<` / `>` are neither leading-
916        // byte sentinels nor control bytes nor `\`, and the value's last byte
917        // isn't `/`. The resolver folds the value through
918        // `Path::new(caminho).join(<file>)` looking for a literal
919        // `./..\caixa-teia>build.log` subdirectory and fails at resolve time
920        // with a non-self-locating `No such file or directory` error far
921        // from the source caixa.lisp.
922        //
923        // The lacre pipeline embeds the value verbatim in its per-dep
924        // content-address (`conteudo: format!("path:{caminho}")`,
925        // caixa-resolver/src/resolve.rs:189), so a `<` / `>` byte lands in
926        // the BLAKE3 closure and rides downstream as part of the build's
927        // identity. The bytes carry a second class of hazard the prior
928        // separator-shaped arms don't: every typed-string slot whose value
929        // ever flows verbatim into a shell-spawned subprocess (the caixa-
930        // resolver's `git clone` invocation, a future `feira tofu` shell-
931        // out, a future operator-side `nix flake check` spawn) is the
932        // canonical CRLF-at-subprocess-argument / shell-metachar injection
933        // surface that every peer single-token-shaped typed slot already
934        // closes. The peer path-shaped axis `[crate::render::is_gateway_api_http_path]`
935        // (caixa-core/src/render.rs:506) rejects `<` / `>` as part of its
936        // eleven-byte RFC-3986-reserved set on `:entrada :paths`, and the
937        // peer git-ref-shaped axis `[crate::render::is_git_ref_name]` rejects
938        // `<` / `>` on `:fonte :tag` / `:fonte :branch` under the same
939        // shell-metachar-injection banner. The `:caminho` axis was the last
940        // typed string surface still admitting these two bytes; this arm
941        // closes the gap so the substrate-wide "no shell-redirection
942        // metacharacter anywhere in a typed string slot" invariant is now
943        // structurally consistent across every path-shaped typed surface.
944        //
945        // The arm fires AFTER the control-char arm + backslash arm because
946        // both prior arms carry more self-locating diagnostics on values
947        // that probe as both (`"..\foo<bar"` carries both `\` and `<` — the
948        // cross-OS-separator divergence is the load-bearing axis, so the
949        // backslash arm wins; `"../foo\n<bar"` carries both LF and `<` —
950        // the POSIX-syscall-rejected byte is the load-bearing axis, so the
951        // control-char arm wins). The arm fires BEFORE the trailing-`/` arm
952        // because the embedded redirection byte is the more semantic-
953        // locating axis on probe-as-both values (`"../foo</"` ends in `/`
954        // but the load-bearing diagnostic is the embedded `<` shell-
955        // redirection — the trailing `/` is the secondary observation, and
956        // an author who removes the `<` is likely to also tab-strip the
957        // trailing separator).
958        for &b in caminho.as_bytes() {
959            if b == b'<' || b == b'>' {
960                return Err(DepError::fonte_caminho_shell_redirection(nome, caminho, b));
961            }
962        }
963        // Reproducibility gate's shell-pipe arm. The e457141 shell-redirection
964        // arm closes the `<` / `>` input/output redirection sentinels; `|`
965        // (`0x7C`) is the orthogonal shell-pipe sentinel — same paste-from-
966        // shell-prompt footgun class, different syntactic surface. POSIX
967        // `std::path::Path` treats `|` as a literal path-component byte (so
968        // `../caixa-teia|tee` is one directory named literally
969        // `../caixa-teia|tee`, sibling of `.` and `..`), but every interactive
970        // shell (bash / zsh / fish / nushell) lexes `|` as the pipe operator
971        // — a `:caminho "../caixa-teia | grep foo"` (the canonical "I copied a
972        // `ls ../caixa-teia | grep` line out of a shell-history block and
973        // forgot to trim the pipeline tail" footgun) or `:caminho
974        // "../foo||bar"` (the symmetric "I copied a `cmd-a || cmd-b` short-
975        // circuit OR line" idiom) silently passes every prior arm because
976        // `Path::is_absolute` returns false on `..`, `|` is neither a leading-
977        // byte sentinel nor a control byte nor `\` nor `<` / `>`, and the
978        // value's last byte isn't `/`. The resolver folds the value through
979        // `Path::new(caminho).join(<file>)` looking for a literal
980        // `./../caixa-teia | grep foo` subdirectory and fails at resolve time
981        // with a non-self-locating `No such file or directory` error far
982        // from the source caixa.lisp.
983        //
984        // The lacre pipeline embeds the value verbatim in its per-dep
985        // content-address (`conteudo: format!("path:{caminho}")`,
986        // caixa-resolver/src/resolve.rs:189), so a `|` byte lands in the
987        // BLAKE3 closure and rides downstream as part of the build's identity
988        // into every shell-spawned subprocess (the caixa-resolver's `git
989        // clone` invocation, a future `feira tofu` shell-out, a future
990        // operator-side `nix flake check` spawn) as the canonical CRLF-at-
991        // subprocess-argument / shell-metachar injection surface every peer
992        // single-token-shaped typed slot already closes. The peer path-shaped
993        // axis [`crate::render::is_gateway_api_http_path`]
994        // (caixa-core/src/render.rs:506) rejects `|` as part of its eleven-
995        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
996        // axis was the last typed path-string surface still admitting this
997        // byte; this arm closes the gap so the substrate-wide "no shell-
998        // composition metacharacter anywhere in a typed string slot that
999        // flows verbatim into a shell-spawned subprocess" invariant extends
1000        // from shell-redirection (`<` / `>`) to shell-pipe (`|`) on the
1001        // `:caminho` axis.
1002        //
1003        // The arm fires AFTER the shell-redirection arm because the prior
1004        // arm's two-byte `byte: u8` payload is the more self-locating axis on
1005        // values that probe as both (`"../caixa-teia<input|tee"` carries both
1006        // `<` and `|` — the input-redirection-paste idiom is the load-bearing
1007        // root-cause edit, so `FonteCaminhoShellRedirection` wins; same
1008        // cascade discipline every prior `:caminho` arm establishes). The arm
1009        // fires BEFORE the trailing-`/` arm because the embedded pipe byte is
1010        // the more semantic-locating axis on probe-as-both values
1011        // (`"../foo|tee/"` ends in `/` but the load-bearing diagnostic is the
1012        // embedded `|` shell-pipe — the trailing `/` is the secondary
1013        // observation, and an author who removes the `|` is likely to also
1014        // tab-strip the trailing separator).
1015        for &b in caminho.as_bytes() {
1016            if b == b'|' {
1017                return Err(DepError::fonte_caminho_shell_pipe(nome, caminho));
1018            }
1019        }
1020        // Reproducibility gate's shell-command-separator arm. The 124106f
1021        // shell-pipe arm closes the `|` byte; `;` (`0x3B`) is the orthogonal
1022        // shell-command-separator sentinel — same paste-from-shell-prompt
1023        // footgun class, different syntactic surface. POSIX `std::path::Path`
1024        // treats `;` as a literal path-component byte (so
1025        // `../caixa-teia;rm -rf /` is one directory named literally
1026        // `../caixa-teia;rm -rf /`, sibling of `.` and `..`), but every
1027        // interactive shell (bash / zsh / fish / nushell) lexes `;` as the
1028        // sequential-command terminator that fires the next command
1029        // regardless of the prior command's exit status — a `:caminho
1030        // "../caixa-teia; rm -rf build"` (the canonical "I pasted a shell
1031        // one-liner that chained a cleanup tail after the directory name"
1032        // footgun) or `:caminho "../foo;;bar"` (the symmetric "I copied a
1033        // POSIX `case` arm's `;;` terminator into the middle of a path"
1034        // idiom) silently passes every prior arm because `Path::is_absolute`
1035        // returns false on `..`, `;` is neither a leading-byte sentinel nor a
1036        // control byte nor `\` nor `<` / `>` nor `|`, and the value's last
1037        // byte isn't `/`. The resolver folds the value through
1038        // `Path::new(caminho).join(<file>)` looking for a literal
1039        // `./../caixa-teia; rm -rf build` subdirectory and fails at resolve
1040        // time with a non-self-locating `No such file or directory` error far
1041        // from the source caixa.lisp.
1042        //
1043        // The lacre pipeline embeds the value verbatim in its per-dep
1044        // content-address (`conteudo: format!("path:{caminho}")`,
1045        // caixa-resolver/src/resolve.rs:189), so a `;` byte lands in the
1046        // BLAKE3 closure and rides downstream as part of the build's identity
1047        // into every shell-spawned subprocess (the caixa-resolver's `git
1048        // clone` invocation, a future `feira tofu` shell-out, a future
1049        // operator-side `nix flake check` spawn) as the canonical
1050        // shell-metachar injection surface every peer single-token-shaped
1051        // typed slot already closes. The peer path-shaped axis
1052        // [`crate::render::is_gateway_api_http_path`]
1053        // (caixa-core/src/render.rs:506) rejects `;` as part of its eleven-
1054        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1055        // axis was the last typed path-string surface still admitting this
1056        // byte; this arm closes the gap so the substrate-wide "no shell-
1057        // composition metacharacter anywhere in a typed string slot that
1058        // flows verbatim into a shell-spawned subprocess" invariant extends
1059        // from shell-pipe (`|`) to shell-command-separator (`;`) on the
1060        // `:caminho` axis.
1061        //
1062        // The arm fires AFTER the shell-pipe arm because the prior arm's
1063        // canonical-cmd-a-|-cmd-b shape is the more common shell-history
1064        // paste idiom on values that probe as both (`"../caixa-teia | tee;
1065        // rm"` carries both `|` and `;` — the pipeline-tail paste is the
1066        // load-bearing root-cause edit, so `FonteCaminhoShellPipe` wins; same
1067        // cascade discipline every prior `:caminho` arm establishes). The arm
1068        // fires BEFORE the trailing-`/` arm because the embedded
1069        // command-separator byte is the more semantic-locating axis on
1070        // probe-as-both values (`"../foo;rm/"` ends in `/` but the
1071        // load-bearing diagnostic is the embedded `;` shell-command-
1072        // separator — the trailing `/` is the secondary observation, and an
1073        // author who removes the `;` is likely to also tab-strip the trailing
1074        // separator).
1075        for &b in caminho.as_bytes() {
1076            if b == b';' {
1077                return Err(DepError::fonte_caminho_shell_semicolon(nome, caminho));
1078            }
1079        }
1080        // Reproducibility gate's shell-background / logical-AND arm. The
1081        // 05c358e shell-command-separator arm closes the `;` byte; `&`
1082        // (`0x26`) is the orthogonal shell-background / list-AND sentinel
1083        // — same paste-from-shell-prompt footgun class, different
1084        // syntactic surface. POSIX `std::path::Path` treats `&` as a
1085        // literal path-component byte (so `../caixa-teia & sleep 1` is
1086        // one directory named literally `../caixa-teia & sleep 1`,
1087        // sibling of `.` and `..`), but every interactive shell
1088        // (bash / zsh / fish / nushell) lexes `&` two ways:
1089        //
1090        //   - Single `&` as the background-task terminator that detaches
1091        //     the prior command into the background and returns control
1092        //     to the prompt immediately (the canonical `cmd &` idiom
1093        //     every long-running pipeline uses);
1094        //   - Double `&&` as the logical-AND list operator that fires
1095        //     the next command only if the prior command succeeded (the
1096        //     canonical `make && make install` idiom every build script
1097        //     carries).
1098        //
1099        // A `:caminho "../caixa-teia & sleep 1"` (the canonical "I
1100        // pasted a `cd path & sleep 1` background-launch into the
1101        // `:caminho` slot" footgun) or `:caminho "../caixa-teia && make"`
1102        // (the symmetric "I copied a `cd path && make` build chain"
1103        // idiom) silently passes every prior arm because
1104        // `Path::is_absolute` returns false on `..`, `&` is neither a
1105        // leading-byte sentinel nor a control byte nor `\` nor
1106        // `<` / `>` nor `|` nor `;`, and the value's last byte isn't `/`.
1107        // The resolver folds the value through
1108        // `Path::new(caminho).join(<file>)` looking for a literal
1109        // `./../caixa-teia & sleep 1` subdirectory and fails at resolve
1110        // time with a non-self-locating `No such file or directory`
1111        // error far from the source caixa.lisp.
1112        //
1113        // The lacre pipeline embeds the value verbatim in its per-dep
1114        // content-address (`conteudo: format!("path:{caminho}")`,
1115        // caixa-resolver/src/resolve.rs:189), so an `&` byte lands in
1116        // the BLAKE3 closure and rides downstream as part of the build's
1117        // identity into every shell-spawned subprocess (the
1118        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1119        // shell-out, a future operator-side `nix flake check` spawn) as
1120        // the canonical shell-metachar injection surface every peer
1121        // single-token-shaped typed slot already closes. The peer
1122        // path-shaped axis [`crate::render::is_gateway_api_http_path`]
1123        // (caixa-core/src/render.rs:506) rejects `&` as part of its
1124        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1125        // `:caminho` axis was the last typed path-string surface still
1126        // admitting this byte; this arm closes the gap so the
1127        // substrate-wide "no shell-composition metacharacter anywhere
1128        // in a typed string slot that flows verbatim into a
1129        // shell-spawned subprocess" invariant extends from
1130        // shell-command-separator (`;`) to shell-background /
1131        // logical-AND (`&`) on the `:caminho` axis.
1132        //
1133        // The arm fires AFTER the shell-command-separator arm because
1134        // the prior arm's `cmd-a; cmd-b` shape is the more common
1135        // shell-history paste idiom on values that probe as both
1136        // (`"../caixa-teia; rm & sleep"` carries both `;` and `&` — the
1137        // command-separator-tail paste is the load-bearing root-cause
1138        // edit, so `FonteCaminhoShellSemicolon` wins; same cascade
1139        // discipline every prior `:caminho` arm establishes). The arm
1140        // fires BEFORE the trailing-`/` arm because the embedded
1141        // background / list-AND byte is the more semantic-locating axis
1142        // on probe-as-both values (`"../foo&bar/"` ends in `/` but the
1143        // load-bearing diagnostic is the embedded `&` shell-background
1144        // / logical-AND metachar — the trailing `/` is the secondary
1145        // observation, and an author who removes the `&` is likely to
1146        // also tab-strip the trailing separator).
1147        for &b in caminho.as_bytes() {
1148            if b == b'&' {
1149                return Err(DepError::fonte_caminho_shell_background(nome, caminho));
1150            }
1151        }
1152        // Reproducibility gate's shell-command-substitution arm. The
1153        // e12e4f3 shell-background / logical-AND arm closes the `&`
1154        // byte; the backtick (`0x60`) is the orthogonal POSIX legacy
1155        // command-substitution sentinel — every POSIX shell (sh /
1156        // bash / zsh / dash / ksh / fish / nushell) lexes the byte as
1157        // the canonical legacy wrapper that runs the enclosed command
1158        // and substitutes its standard-output verbatim into the
1159        // surrounding word (a `whoami` wrapped in backticks expands
1160        // to the current user's name; a `cat /etc/passwd` wrapped in
1161        // backticks expands to the file's contents — the canonical
1162        // CWE-78 shell-command-injection vector every shell-side
1163        // hardening guide enumerates first). POSIX
1164        // `std::path::Path` treats backtick as a literal path-
1165        // component byte (so `../caixa-teia/<backtick>whoami<backtick>`
1166        // is one directory named literally that, sibling of `.` and
1167        // `..`).
1168        //
1169        // A `:caminho "../caixa-teia/<backtick>whoami<backtick>"` (the
1170        // canonical "I pasted a shell one-liner carrying a backticked
1171        // `whoami` command-substitution expansion into the `:caminho`
1172        // slot" footgun) or `:caminho "<backtick>pwd<backtick>/caixa-
1173        // teia"` (the symmetric "I copied a `<backtick>pwd<backtick>/
1174        // path` working-directory expansion") silently passes every
1175        // prior arm because `Path::is_absolute` returns false on
1176        // `..`, the backtick byte is neither a leading-byte sentinel
1177        // (the f4efe9c `FonteCaminhoVarExpansion` arm catches the
1178        // modern `$()` form at leading position only; backtick is
1179        // the orthogonal legacy form) nor a control byte nor `\` nor
1180        // `<` / `>` nor `|` nor `;` nor `&`, and the value's last
1181        // byte isn't `/`. The resolver folds the value through
1182        // `Path::new(caminho).join(<file>)` looking for a literal
1183        // subdirectory whose name embeds the backticked token and
1184        // fails at resolve time with a non-self-locating `No such
1185        // file or directory` error far from the source caixa.lisp.
1186        //
1187        // The lacre pipeline embeds the value verbatim in its per-
1188        // dep content-address (`conteudo: format!("path:{caminho}")`,
1189        // caixa-resolver/src/resolve.rs:189), so a backtick byte
1190        // lands in the BLAKE3 closure and rides downstream as part
1191        // of the build's identity into every shell-spawned
1192        // subprocess (the caixa-resolver's `git clone` invocation, a
1193        // future `feira tofu` shell-out, a future operator-side
1194        // `nix flake check` spawn) as the canonical shell-metachar
1195        // injection surface every peer single-token-shaped typed
1196        // slot already closes. The peer path-shaped axis
1197        // [`crate::render::is_gateway_api_http_path`]
1198        // (caixa-core/src/render.rs:506) rejects backtick as part of
1199        // its eleven-byte RFC-3986-reserved set on `:entrada
1200        // :paths`. The `:caminho` axis was the last typed path-
1201        // string surface still admitting this byte; this arm closes
1202        // the gap so the substrate-wide "no shell-composition
1203        // metacharacter anywhere in a typed string slot that flows
1204        // verbatim into a shell-spawned subprocess" invariant
1205        // extends from shell-background / logical-AND (`&`) to
1206        // shell-command-substitution (backtick) on the `:caminho`
1207        // axis.
1208        //
1209        // The arm fires AFTER the shell-background arm because the
1210        // prior arm's `cmd & sleep` shape is the more common shell-
1211        // history paste idiom on values that probe as both (a
1212        // `"../caixa-teia & <backtick>whoami<backtick>"` carries
1213        // both `&` and a backtick — the background-launch tail is
1214        // the load-bearing root-cause edit, so
1215        // `FonteCaminhoShellBackground` wins; same cascade
1216        // discipline every prior `:caminho` arm establishes). The
1217        // arm fires BEFORE the trailing-`/` arm because the
1218        // embedded command-substitution byte is the more semantic-
1219        // locating axis on probe-as-both values (a
1220        // `"../<backtick>whoami<backtick>/"` ends in `/` but the
1221        // load-bearing diagnostic is the embedded backtick shell-
1222        // command-substitution metachar — the trailing `/` is the
1223        // secondary observation, and an author who removes the
1224        // backtick is likely to also tab-strip the trailing
1225        // separator).
1226        for &b in caminho.as_bytes() {
1227            if b == b'`' {
1228                return Err(DepError::fonte_caminho_shell_command_substitution(
1229                    nome, caminho,
1230                ));
1231            }
1232        }
1233        // Reproducibility gate's shell-glob arm. The c4d62b3 shell-command-
1234        // substitution arm closes the backtick byte; `*` (`0x2A`) and `?`
1235        // (`0x3F`) are the orthogonal POSIX glob-expansion sentinels — same
1236        // paste-from-shell-prompt footgun class, different syntactic surface.
1237        // Every POSIX shell (sh / bash / zsh / dash / ksh / fish / nushell)
1238        // lexes `*` and `?` as pathname-expansion wildcards: `*` matches any
1239        // sequence of characters in a path component (including the empty
1240        // sequence), `?` matches exactly one character. POSIX
1241        // `std::path::Path` treats both bytes as literal path-component bytes
1242        // (so `../caixa-teia/*.lisp` is one directory named literally
1243        // `../caixa-teia/*.lisp`, sibling of `.` and `..`).
1244        //
1245        // A `:caminho "../caixa-teia/*"` (the canonical "I pasted a
1246        // `ls ../caixa-teia/*` shell-listing one-liner into the `:caminho`
1247        // slot" footgun) or `:caminho "../foo?"` (the symmetric "I copied a
1248        // `rm foo?` single-char-wildcard removal idiom") silently passes
1249        // every prior arm because `Path::is_absolute` returns false on `..`,
1250        // `*` / `?` are neither leading-byte sentinels nor control bytes nor
1251        // `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick, and the
1252        // value's last byte isn't `/`. The resolver folds the value through
1253        // `Path::new(caminho).join(<file>)` looking for a literal
1254        // `./../caixa-teia/*` subdirectory and fails at resolve time with a
1255        // non-self-locating `No such file or directory` error far from the
1256        // source caixa.lisp.
1257        //
1258        // The lacre pipeline embeds the value verbatim in its per-dep
1259        // content-address (`conteudo: format!("path:{caminho}")`,
1260        // caixa-resolver/src/resolve.rs:189), so a `*` or `?` byte lands in
1261        // the BLAKE3 closure and rides downstream as part of the build's
1262        // identity into every shell-spawned subprocess (the caixa-resolver's
1263        // `git clone` invocation, a future `feira tofu` shell-out, a future
1264        // operator-side `nix flake check` spawn) as the canonical
1265        // shell-metachar / pathname-expansion surface every peer
1266        // single-token-shaped typed slot already closes. The peer path-shaped
1267        // axis [`crate::render::is_gateway_api_http_path`]
1268        // (caixa-core/src/render.rs:506) rejects `*` and `?` as part of its
1269        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1270        // `:caminho` axis was the last typed path-string surface still
1271        // admitting these two bytes; this arm closes the gap so the
1272        // substrate-wide "no shell-composition / glob-expansion
1273        // metacharacter anywhere in a typed string slot that flows verbatim
1274        // into a shell-spawned subprocess" invariant extends from
1275        // shell-command-substitution (backtick) to glob-expansion
1276        // (`*` / `?`) on the `:caminho` axis.
1277        //
1278        // The arm fires AFTER the backtick arm because the prior arm's
1279        // CWE-78 shell-command-injection vector is the load-bearing
1280        // diagnostic on values that probe as both (a `"../`whoami`/*"`
1281        // carries both backtick and `*` — the command-substitution paste
1282        // is the load-bearing root-cause edit, so
1283        // `FonteCaminhoShellCommandSubstitution` wins; same cascade
1284        // discipline every prior `:caminho` arm establishes). The arm
1285        // fires BEFORE the trailing-`/` arm because the embedded glob
1286        // byte is the more semantic-locating axis on probe-as-both values
1287        // (`"../foo*/"` ends in `/` but the load-bearing diagnostic is the
1288        // embedded `*` glob metachar — the trailing `/` is the secondary
1289        // observation, and an author who removes the `*` is likely to
1290        // also tab-strip the trailing separator).
1291        for &b in caminho.as_bytes() {
1292            if b == b'*' || b == b'?' {
1293                return Err(DepError::fonte_caminho_shell_glob(nome, caminho, b));
1294            }
1295        }
1296        // Reproducibility gate's shell-subshell-grouping arm. The cf9034b
1297        // shell-glob arm closes the `*` / `?` pathname-expansion sentinels;
1298        // `(` (`0x28`) and `)` (`0x29`) are the orthogonal POSIX subshell-
1299        // grouping sentinels — same paste-from-shell-prompt footgun class,
1300        // different syntactic surface. Every POSIX shell (sh / bash / zsh /
1301        // dash / ksh / fish / nushell) lexes the parenthesis pair as the
1302        // subshell-grouping operator: `(<cmd>)` runs `<cmd>` in a child
1303        // shell with a fresh environment scope (the canonical sandboxing
1304        // idiom every shell-history `(cd <path> && <cmd>)` one-liner uses
1305        // to scope a `cd` to one subshell without disturbing the parent's
1306        // working directory), and `$(<cmd>)` is the modern Bourne
1307        // command-substitution shape the upstream f4efe9c
1308        // `FonteCaminhoVarExpansion` arm closes the leading `$` byte of —
1309        // the closing `)` byte completes that substitution shape and must
1310        // be refused on the same axis (peer with the
1311        // [`crate::render::is_git_repo_url`] 3b99147 arm that closes the
1312        // same byte-pair on the sibling `:fonte :repo` axis under the
1313        // same shell-subshell-grouping + RFC-3986-sub-delims banner).
1314        // POSIX `std::path::Path` treats both bytes as literal path-
1315        // component bytes (so `../caixa-teia/(date)` is one directory
1316        // named literally `../caixa-teia/(date)`, sibling of `.` and
1317        // `..`).
1318        //
1319        // A `:caminho "../caixa-teia/$(date)/build"` (the canonical "I
1320        // pasted a `cd ../caixa-teia/$(date)/build` shell-history one-
1321        // liner whose modern command-substitution expansion lands the
1322        // current date as a subdirectory name" footgun) or `:caminho
1323        // "../(cd foo && pwd)/caixa-teia"` (the symmetric "I copied a
1324        // `(cd foo && pwd)` subshell-grouping working-directory probe
1325        // idiom") silently passes every prior arm because
1326        // `Path::is_absolute` returns false on `..`, `(` / `)` are
1327        // neither leading-byte sentinels nor control bytes nor `\` nor
1328        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` / `?`,
1329        // and the value's last byte isn't `/`. The resolver folds the
1330        // value through `Path::new(caminho).join(<file>)` looking for a
1331        // literal `./../caixa-teia/$(date)/build` subdirectory and fails
1332        // at resolve time with a non-self-locating `No such file or
1333        // directory` error far from the source caixa.lisp.
1334        //
1335        // The lacre pipeline embeds the value verbatim in its per-dep
1336        // content-address (`conteudo: format!("path:{caminho}")`,
1337        // caixa-resolver/src/resolve.rs:189), so a `(` or `)` byte lands
1338        // in the BLAKE3 closure and rides downstream as part of the
1339        // build's identity into every shell-spawned subprocess (the
1340        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1341        // shell-out, a future operator-side `nix flake check` spawn) as
1342        // the canonical shell-metachar / subshell-grouping surface every
1343        // peer single-token-shaped typed slot already closes. The peer
1344        // git-source axis [`crate::render::is_git_repo_url`] (3b99147)
1345        // rejects the same byte pair on `:fonte :repo` under the same
1346        // shell-subshell-grouping / RFC-3986-sub-delims banner. The
1347        // `:caminho` axis was the last typed path-string surface still
1348        // admitting these two bytes;
1349        // this arm closes the gap so the substrate-wide "no shell-
1350        // composition metacharacter anywhere in a typed string slot that
1351        // flows verbatim into a shell-spawned subprocess" invariant
1352        // extends from shell-glob (`*` / `?`) to shell-subshell-grouping
1353        // (`(` / `)`) on the `:caminho` axis. Together with the f4efe9c
1354        // leading-`$` arm, the typed `:caminho` accepted set now
1355        // structurally excludes the entire modern Bourne
1356        // command-substitution surface — leading `$` closes the
1357        // leading byte of every `$(<cmd>)` shape, this arm closes the
1358        // trailing `)` boundary.
1359        //
1360        // The arm fires AFTER the shell-glob arm because the prior arm's
1361        // `*` / `?` pathname-expansion shape is the more common shell-
1362        // history paste idiom on values that probe as both
1363        // (`"../caixa-teia/*(date)"` carries both `*` and `(` — the
1364        // glob-paste-tail is the load-bearing root-cause edit, so
1365        // `FonteCaminhoShellGlob` wins; same cascade discipline every
1366        // prior `:caminho` arm establishes). The arm fires BEFORE the
1367        // trailing-`/` arm because the embedded subshell-grouping byte
1368        // is the more semantic-locating axis on probe-as-both values
1369        // (`"../foo(date)/"` ends in `/` but the load-bearing diagnostic
1370        // is the embedded `(` shell-subshell-grouping metachar — the
1371        // trailing `/` is the secondary observation, and an author who
1372        // removes the `(` is likely to also tab-strip the trailing
1373        // separator).
1374        for &b in caminho.as_bytes() {
1375            if b == b'(' || b == b')' {
1376                return Err(DepError::fonte_caminho_shell_subshell_grouping(
1377                    nome, caminho, b,
1378                ));
1379            }
1380        }
1381        // Reproducibility gate's shell-brace-expansion arm. The 0633c91
1382        // shell-subshell-grouping arm closes `(` / `)`; `{` (`0x7b`) and
1383        // `}` (`0x7d`) are the orthogonal shell-brace-expansion /
1384        // URI-Template-placeholder byte pair — same paste-from-shell-
1385        // prompt + paste-from-templated-doc footgun class, different
1386        // syntactic surface. Every POSIX-derived shell that implements
1387        // brace expansion (bash / zsh / ksh / fish; the canonical
1388        // `mkdir -p ../{caixa-teia,caixa-helm,caixa-flux}` /
1389        // `cp file{,.bak}` idiom every shell-history block carries)
1390        // expands `{a,b,c}` to the cross-product of its comma-separated
1391        // members and `{1..10}` to the integer range; RFC 6570 reserves
1392        // the matched pair for URI Template placeholders (the canonical
1393        // `https://{host}/{org}/{repo}` substitution shape every
1394        // OpenAPI / Swagger / Postman / GitHub Octokit client /
1395        // Helm chart-URL fragment / Mustache `{{org}}` doubled-brace
1396        // form carries), and Tera / Jinja2 / Handlebars / Go html/template
1397        // every IaC tool (Helm, Kustomize, Terraform's `${var}` cousin
1398        // shape) emit. POSIX `std::path::Path` treats both bytes as
1399        // literal path-component bytes (so `../{caixa-teia,caixa-helm}`
1400        // is one directory named literally `../{caixa-teia,caixa-helm}`,
1401        // sibling of `.` and `..`).
1402        //
1403        // A `:caminho "../{caixa-teia,caixa-helm}/build"` (the canonical
1404        // "I pasted a `cd ../{caixa-teia,caixa-helm}` shell brace-
1405        // expansion one-liner that fans across two siblings" footgun)
1406        // or `:caminho "../{{org}}/caixa-teia"` (the symmetric "I copied
1407        // a `{{org}}` Mustache / Helm template placeholder out of a
1408        // README quick-start and forgot to substitute") silently passes
1409        // every prior arm because `Path::is_absolute` returns false on
1410        // `..`, `{` / `}` are neither leading-byte sentinels nor control
1411        // bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor
1412        // backtick nor `*` / `?` nor `(` / `)`, and the value's last
1413        // byte isn't `/`. The resolver folds the value through
1414        // `Path::new(caminho).join(<file>)` looking for a literal
1415        // `./../{caixa-teia,caixa-helm}/build` subdirectory and fails
1416        // at resolve time with a non-self-locating `No such file or
1417        // directory` error far from the source caixa.lisp.
1418        //
1419        // The lacre pipeline embeds the value verbatim in its per-dep
1420        // content-address (`conteudo: format!("path:{caminho}")`,
1421        // caixa-resolver/src/resolve.rs:189), so a `{` or `}` byte
1422        // lands in the BLAKE3 closure and rides downstream as part of
1423        // the build's identity into every shell-spawned subprocess
1424        // (the caixa-resolver's `git clone` invocation, a future
1425        // `feira tofu` shell-out, a future operator-side `nix flake
1426        // check` spawn) as the canonical shell-metachar / brace-
1427        // expansion surface every peer single-token-shaped typed
1428        // slot already closes. The peer git-source axis
1429        // [`crate::render::is_git_repo_url`] (42d8f9d — the URI Template
1430        // placeholder arm) rejects the same byte pair on `:fonte :repo`
1431        // under the same RFC-3986-'delims' / RFC-6570-URI-Template /
1432        // shell-brace-expansion banner. The `:caminho` axis was the last
1433        // typed path-string surface still admitting these two bytes;
1434        // this arm closes the gap so the substrate-wide "no shell-
1435        // composition metacharacter anywhere in a typed string slot
1436        // that flows verbatim into a shell-spawned subprocess"
1437        // invariant extends from shell-subshell-grouping (`(` / `)`)
1438        // to shell-brace-expansion (`{` / `}`) on the `:caminho` axis,
1439        // and the typed `:caminho` accepted set now also structurally
1440        // excludes the URI Template / templating-engine placeholder
1441        // surface that would silently round-trip through any
1442        // downstream IaC templating-engine layer.
1443        //
1444        // The arm fires AFTER the shell-subshell-grouping arm because
1445        // the prior arm's `(` / `)` shape is the more semantic-locating
1446        // axis on values that probe as both (`"../{cd foo}(date)"`
1447        // carries both `{` and `(` — the parenthesis-pair is the
1448        // load-bearing modern-Bourne-command-substitution surface the
1449        // prior arm closes; same cascade discipline every prior
1450        // `:caminho` arm establishes). The arm fires BEFORE the
1451        // trailing-`/` arm because the embedded brace-expansion byte
1452        // is the more semantic-locating axis on probe-as-both values
1453        // (`"../{caixa-teia,caixa-helm}/"` ends in `/` but the
1454        // load-bearing diagnostic is the embedded `{` brace-expansion
1455        // metachar — the trailing `/` is the secondary observation,
1456        // and an author who removes the `{` is likely to also tab-
1457        // strip the trailing separator).
1458        for &b in caminho.as_bytes() {
1459            if b == b'{' || b == b'}' {
1460                return Err(DepError::fonte_caminho_shell_brace_expansion(
1461                    nome, caminho, b,
1462                ));
1463            }
1464        }
1465        // Reproducibility gate's shell-bracket-expansion arm. The 598b770
1466        // shell-brace-expansion arm closes `{` / `}`; `[` (`0x5b`) and
1467        // `]` (`0x5d`) are the orthogonal POSIX glob-character-class /
1468        // shell-`test`-builtin byte pair — same paste-from-shell-prompt
1469        // footgun class, different syntactic surface. Every POSIX shell
1470        // (sh / bash / zsh / dash / ksh / fish / nushell) lexes the
1471        // bracket pair as the glob character-class operator: `[abc]`
1472        // matches one of `a`, `b`, `c`; `[a-z]` matches any lowercase
1473        // ASCII letter; `[^x]` negates (the canonical
1474        // `ls *.[ch]` C-source-file glob and the `cd ../[a-z]*`
1475        // lowercase-sibling glob every shell-history block carries —
1476        // the orthogonal axis to the cf9034b `*` / `?` shell-glob arm
1477        // closing the unbounded pathname-expansion sentinels). The
1478        // bracket pair additionally carries the POSIX `test` /
1479        // `[` builtin command (`[ -d ../caixa-teia ] && cd ...` —
1480        // the canonical idiom every shell-script conditional uses) and
1481        // bash's `[[ ... ]]` extended-test grammar. Beyond shell, the
1482        // bracket pair is the TOML inline-array delimiter
1483        // (`features = ["a", "b"]` — the canonical paste-from-Cargo-
1484        // manifest cross-idiom-leak vector), the YAML flow-sequence
1485        // delimiter (`paths: [/a, /b]` — the canonical paste-from-
1486        // values.yaml cross-idiom leak), the JSON array delimiter,
1487        // and the POSIX-ERE / PCRE bracket-expression / character-
1488        // class anchor (the canonical paste-from-regex-doc shape).
1489        // POSIX `std::path::Path` treats both bytes as literal path-
1490        // component bytes (so `../[caixa-teia]` is one directory
1491        // named literally `../[caixa-teia]`, sibling of `.` and
1492        // `..`).
1493        //
1494        // A `:caminho "../caixa-[a-z]/build"` (the canonical "I
1495        // pasted a `cd ../caixa-[a-z]/build` glob-character-class
1496        // one-liner that matches every lowercase-sibling-suffix
1497        // sibling directory" footgun), `:caminho "../[caixa-teia]/
1498        // build"` (the symmetric "I pasted a TOML inline-array /
1499        // YAML flow-sequence shape out of an aligned manifest"
1500        // idiom), or `:caminho "../caixa-[ch]"` (the canonical
1501        // `*.[ch]` C-source character-class paste-from-shell-history
1502        // shape) silently passes every prior arm because
1503        // `Path::is_absolute` returns false on `..`, `[` / `]` are
1504        // neither leading-byte sentinels nor control bytes nor `\`
1505        // nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1506        // `*` / `?` nor `(` / `)` nor `{` / `}`, and the value's
1507        // last byte isn't `/`. The resolver folds the value through
1508        // `Path::new(caminho).join(<file>)` looking for a literal
1509        // `./../caixa-[a-z]/build` subdirectory and fails at resolve
1510        // time with a non-self-locating `No such file or directory`
1511        // error far from the source caixa.lisp.
1512        //
1513        // The lacre pipeline embeds the value verbatim in its per-dep
1514        // content-address (`conteudo: format!("path:{caminho}")`,
1515        // caixa-resolver/src/resolve.rs:189), so a `[` or `]` byte
1516        // lands in the BLAKE3 closure and rides downstream as part of
1517        // the build's identity into every shell-spawned subprocess
1518        // (the caixa-resolver's `git clone` invocation, a future
1519        // `feira tofu` shell-out, a future operator-side `nix flake
1520        // check` spawn) as the canonical shell-metachar / glob-
1521        // character-class / TOML-array surface every peer single-
1522        // token-shaped typed slot already closes. The `:caminho` axis
1523        // was the last typed path-string surface still admitting
1524        // these two bytes; this arm closes the gap so the substrate-
1525        // wide "no shell-composition metacharacter anywhere in a
1526        // typed string slot that flows verbatim into a shell-spawned
1527        // subprocess" invariant extends from shell-brace-expansion
1528        // (`{` / `}`) to shell-bracket-expansion (`[` / `]`) on the
1529        // `:caminho` axis. Together with the cf9034b `*` / `?` arm,
1530        // the typed `:caminho` accepted set now structurally excludes
1531        // the entire POSIX pathname-expansion / glob surface —
1532        // unbounded glob (`*` / `?`) AND bounded character-class
1533        // (`[abc]` / `[a-z]`).
1534        //
1535        // The arm fires AFTER the shell-brace-expansion arm because
1536        // the prior arm's `{` / `}` shape is the more semantic-
1537        // locating axis on values that probe as both
1538        // (`"../{a,b}[ch]"` carries both `{` and `[` — the brace-
1539        // expansion fan is the load-bearing root-cause edit, so
1540        // `FonteCaminhoShellBraceExpansion` wins; same cascade
1541        // discipline every prior `:caminho` arm establishes). The arm
1542        // fires BEFORE the trailing-`/` arm because the embedded
1543        // bracket-expansion byte is the more semantic-locating axis
1544        // on probe-as-both values (`"../[a-z]/"` ends in `/` but the
1545        // load-bearing diagnostic is the embedded `[` glob-character-
1546        // class metachar — the trailing `/` is the secondary
1547        // observation, and an author who removes the `[` is likely
1548        // to also tab-strip the trailing separator).
1549        for &b in caminho.as_bytes() {
1550            if b == b'[' || b == b']' {
1551                return Err(DepError::fonte_caminho_shell_bracket_expansion(
1552                    nome, caminho, b,
1553                ));
1554            }
1555        }
1556        // Reproducibility gate's shell-quote-grouping arm. The 986963b
1557        // shell-bracket-expansion arm closes `[` / `]`; `'` (`0x27`) and
1558        // `"` (`0x22`) are the orthogonal POSIX shell-string-literal
1559        // delimiter pair — same paste-from-shell-prompt footgun class,
1560        // different syntactic surface. Every POSIX shell (sh / bash /
1561        // zsh / dash / ksh / fish / nushell) lexes the pair as the
1562        // string-literal quoting operator: `'…'` is the strong
1563        // (no-expansion) single-quoted string and `"…"` is the weak
1564        // (variable-/command-substitution-preserving) double-quoted
1565        // string — the canonical `cd '../caixa-teia'` shell-history
1566        // idiom every path-with-embedded-whitespace paste block carries,
1567        // and the symmetric `git clone "$REPO"` weak-quoted CI-manifest
1568        // shape. Beyond shell, the two bytes carry the JSON string-literal
1569        // delimiter (`"key": "value"` — the canonical paste-from-JSON-
1570        // config cross-idiom-leak vector), the YAML double-quoted +
1571        // single-quoted flow-scalar delimiters (`path: "../caixa-teia"`
1572        // — the canonical paste-from-values.yaml / paste-from-K8s-YAML-
1573        // manifest cross-idiom leak), the TOML basic + literal string
1574        // delimiters (`path = "../caixa-teia"` — the canonical paste-
1575        // from-Cargo-manifest cross-idiom-leak vector), the tatara-lisp
1576        // string-literal delimiter itself (`(:caminho "../caixa-teia")`
1577        // — the canonical "I copied the entire `:caminho "..."` slot
1578        // rather than just the string body" author-surface footgun),
1579        // and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which
1580        // excludes both bytes from the `unreserved / pct-encoded /
1581        // sub-delims / ":" / "@"` `pchar` production. POSIX
1582        // `std::path::Path` treats both bytes as literal path-component
1583        // bytes (so `../"caixa-teia"` is one directory named literally
1584        // `../"caixa-teia"`, sibling of `.` and `..`).
1585        //
1586        // A `:caminho "'../caixa-teia'"` (the canonical "I pasted a
1587        // `cd '../caixa-teia'` shell-history one-liner whose strong-
1588        // quoting preserved the sibling-workspace path verbatim across
1589        // the whitespace paste boundary" footgun), `:caminho
1590        // "\"../caixa-teia\""` (the symmetric weak-quoted paste-from-
1591        // JSON / paste-from-YAML flow-scalar / paste-from-TOML basic-
1592        // string / paste-from-tatara-lisp string-literal cross-idiom-
1593        // leak shape), or `:caminho "../\"caixa-teia\""` (the embedded-
1594        // quote "I pasted a JSON key-value pair fragment into the
1595        // middle of the path" idiom) silently passes every prior arm
1596        // because `Path::is_absolute` returns false on `..` / `'` /
1597        // `"`, `'` / `"` are neither leading-byte sentinels nor
1598        // control bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&`
1599        // nor backtick nor `*` / `?` nor `(` / `)` nor `{` / `}` nor
1600        // `[` / `]`, and the value's last byte isn't `/`. The resolver
1601        // folds the value through `Path::new(caminho).join(<file>)`
1602        // looking for a literal `./'../caixa-teia'` subdirectory and
1603        // fails at resolve time with a non-self-locating `No such file
1604        // or directory` error far from the source caixa.lisp.
1605        //
1606        // The lacre pipeline embeds the value verbatim in its per-dep
1607        // content-address (`conteudo: format!("path:{caminho}")`,
1608        // caixa-resolver/src/resolve.rs:189), so a `'` or `"` byte
1609        // lands in the BLAKE3 closure and rides downstream as part of
1610        // the build's identity into every shell-spawned subprocess
1611        // (the caixa-resolver's `git clone` invocation, a future
1612        // `feira tofu` shell-out, a future operator-side `nix flake
1613        // check` spawn) as the canonical shell-metachar / string-
1614        // literal-delimiter surface every peer single-token-shaped
1615        // typed slot already closes. The peer `:fonte :repo` axis
1616        // closes both bytes under the same shell-quote-grouping /
1617        // RFC-3986-sub-delims banner (e7a109f `'` shell-single-quote
1618        // + 4267d8b `"` shell-double-quote on `is_git_repo_url`). The
1619        // `:caminho` axis was the last typed path-string surface
1620        // still admitting these two bytes; this arm closes the gap
1621        // so the substrate-wide "no shell-composition metacharacter
1622        // anywhere in a typed string slot that flows verbatim into a
1623        // shell-spawned subprocess" invariant extends from shell-
1624        // bracket-expansion (`[` / `]`) to shell-quote-grouping (`'`
1625        // / `"`) on the `:caminho` axis. Together with the peer
1626        // JSON / YAML / TOML string-literal delimiters closing at
1627        // this arm and the 598b770 `{` / `}` brace-expansion arm
1628        // closing the templating-engine-placeholder boundary, the
1629        // typed `:caminho` accepted set now structurally excludes
1630        // the entire cross-config-DSL string-literal / templating
1631        // paste-from-aligned-manifest cross-idiom-leak surface that
1632        // would silently round-trip through any downstream JSON /
1633        // YAML / TOML / HCL / tatara-lisp parsing layer.
1634        //
1635        // The arm fires AFTER the shell-bracket-expansion arm because
1636        // the prior arm's `[` / `]` shape is the more semantic-
1637        // locating axis on values that probe as both (`"../[a-z]'x'"`
1638        // carries both `[` and `'` — the glob-character-class
1639        // expansion is the load-bearing root-cause edit, so
1640        // `FonteCaminhoShellBracketExpansion` wins; same cascade
1641        // discipline every prior `:caminho` arm establishes). The arm
1642        // fires BEFORE the trailing-`/` arm because the embedded
1643        // quote-grouping byte is the more semantic-locating axis on
1644        // probe-as-both values (`"../'caixa-teia'/"` ends in `/` but
1645        // the load-bearing diagnostic is the embedded `'` shell-
1646        // string-literal metachar — the trailing `/` is the secondary
1647        // observation, and an author who removes the `'` is likely to
1648        // also tab-strip the trailing separator).
1649        for &b in caminho.as_bytes() {
1650            if b == b'\'' || b == b'"' {
1651                return Err(DepError::fonte_caminho_shell_quote_grouping(
1652                    nome, caminho, b,
1653                ));
1654            }
1655        }
1656        // Reproducibility gate's shell-comment / URL-fragment / YAML-comment arm.
1657        // The d14cbc5 shell-quote-grouping arm closes `'` / `"`; `#` (`0x23`) is
1658        // the orthogonal "byte at which four distinct downstream parsers all
1659        // truncate the value at the first occurrence" surface, and no prior arm
1660        // has covered it on the `:caminho` axis. Every POSIX shell (sh / bash /
1661        // zsh / dash / ksh / fish / nushell) lexes an unquoted `#` at the head
1662        // of a word (or after unquoted whitespace) as the comment-lead: from
1663        // that byte to the end of the physical line is a comment discarded
1664        // before command parsing (`cd ../caixa-teia  # legacy sibling` — the
1665        // canonical paste-from-shell-history-with-trailing-annotation shape
1666        // every operator-notebook and CI-manifest carries; POSIX.1-2017 §2.3
1667        // Token Recognition step 6). YAML 1.2 §6.6 makes `#` the comment lead
1668        // at any position preceded by whitespace or at line-start (`path:
1669        // ../caixa-teia  # pin` — the canonical paste-from-values.yaml /
1670        // paste-from-K8s-manifest cross-idiom-leak shape). tatara-lisp itself
1671        // treats `;` as the comment-lead but a growing number of consumer
1672        // config-DSL layers (HCL, Terraform, Nix flake attributes, .env
1673        // dotenv-style files, gitconfig / .gitignore, ini / TOML) use `#` as
1674        // the comment-lead too — the pair extends the cross-config-DSL
1675        // paste-idiom surface the d14cbc5 quote-grouping arm and the 598b770
1676        // brace-expansion arm already cover on adjacent axes. RFC 3986 §3.5
1677        // reserves `#` as the URL fragment-identifier delimiter (the canonical
1678        // paste-from-browser-address-bar `github.com/foo/bar#readme` /
1679        // `github.com/foo/bar#L42` permalink shape, and the symmetric
1680        // Nix-flake-ref cross-idiom leak `github:foo/bar#packageName` where
1681        // `#` selects a flake output — the same axis the peer
1682        // [`crate::render::is_git_repo_url`] closes on the `:fonte :repo`
1683        // surface at a68f818 with the same downstream-drops-the-tail
1684        // rationale).
1685        //
1686        // POSIX `std::path::Path` treats `#` as a literal path-component byte,
1687        // so a `:caminho "../caixa-teia # legacy sibling"` (the canonical
1688        // paste-from-shell-history-with-trailing-annotation footgun),
1689        // `:caminho "../caixa-teia  # pin"` (the symmetric YAML flow-scalar
1690        // paste-with-trailing-comment shape), or `:caminho "../caixa-teia
1691        // #readme"` (the URL fragment paste-from-browser-address-bar shape)
1692        // silently passes every prior arm because `Path::is_absolute` returns
1693        // false on `..`, `#` is neither a leading-byte sentinel nor a control
1694        // byte nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1695        // `*` / `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` / `"`,
1696        // and the value's last byte isn't `/`. The resolver folds the value
1697        // through `Path::new(caminho).join(<file>)` looking for a literal
1698        // subdirectory named `../caixa-teia # legacy sibling` and fails at
1699        // resolve time with a non-self-locating `No such file or directory`
1700        // error far from the source caixa.lisp — while every downstream
1701        // shell / YAML / URL parser silently truncates the value at the `#`
1702        // byte to `../caixa-teia`, so a `feira tofu` shell-out to a
1703        // `cd '{caminho}'` command line and a `nix flake check` invocation on
1704        // an emitted YAML `path:` scalar disagree with the resolver on which
1705        // directory the value names. Two workstations whose downstream
1706        // shell / YAML / URL parsing layers differ in unquoted-`#`
1707        // recognition emit divergent build artifacts for the byte-identical
1708        // caixa.lisp value.
1709        //
1710        // The lacre pipeline embeds the value verbatim in its per-dep
1711        // content-address (`conteudo: format!("path:{caminho}")`,
1712        // caixa-resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1713        // closure and rides downstream as part of the build's identity into
1714        // every shell-spawned subprocess (the caixa-resolver's `git clone`
1715        // invocation, a future `feira tofu` shell-out, a future operator-side
1716        // `nix flake check` spawn) as the canonical shell-metachar /
1717        // comment-lead / URL-fragment-delimiter surface every peer
1718        // single-token-shaped typed slot already closes. The peer `:fonte
1719        // :repo` axis closes the byte under the URL-fragment-identifier
1720        // banner (a68f818 `#` on `is_git_repo_url`); the `:caminho` axis was
1721        // the last typed path-string surface still admitting the byte. This
1722        // arm closes the gap so the substrate-wide "no shell-composition
1723        // metacharacter / comment-lead / URL-fragment-delimiter anywhere in a
1724        // typed string slot that flows verbatim into a shell-spawned
1725        // subprocess or downstream YAML / URL parser" invariant extends from
1726        // shell-quote-grouping (`'` / `"`) to shell-comment / URL-fragment
1727        // (`#`) on the `:caminho` axis. Together with the peer JSON / YAML /
1728        // TOML string-literal delimiters the d14cbc5 quote-grouping arm
1729        // closes and the 598b770 `{` / `}` brace-expansion arm closes on the
1730        // templating-engine-placeholder boundary, the typed `:caminho`
1731        // accepted set now structurally excludes the entire
1732        // paste-with-trailing-annotation / paste-from-URL-permalink /
1733        // paste-from-YAML-comment cross-idiom-leak surface that would
1734        // silently round-trip through any downstream shell / YAML / URL /
1735        // dotenv / gitconfig / HCL parsing layer to a different value than
1736        // the resolver's `Path::join` sees.
1737        //
1738        // The arm fires AFTER the shell-quote-grouping arm because the prior
1739        // arm's `'` / `"` shape is the more semantic-locating axis on values
1740        // that probe as both (`"../'x'#pin"` carries both `'` and `#` — the
1741        // shell-string-literal-delimiter is the load-bearing root-cause edit,
1742        // so `FonteCaminhoShellQuoteGrouping` wins; same cascade discipline
1743        // every prior `:caminho` arm establishes). The arm fires BEFORE the
1744        // trailing-`/` arm because the embedded comment-lead / fragment-
1745        // delimiter byte is the more semantic-locating axis on probe-as-both
1746        // values (`"../caixa-teia#pin/"` ends in `/` but the load-bearing
1747        // diagnostic is the embedded `#` — the trailing `/` is the secondary
1748        // observation, and an author who removes the `#pin` fragment is
1749        // likely to also tab-strip the trailing separator).
1750        for &b in caminho.as_bytes() {
1751            if b == b'#' {
1752                return Err(DepError::fonte_caminho_shell_comment(nome, caminho, b));
1753            }
1754        }
1755        // Reproducibility gate's URL-percent-encoding-escape arm. The 6622063
1756        // shell-comment arm closes the `#` URL-fragment-identifier byte; `%`
1757        // (`0x25`) is the orthogonal RFC 3986 §2.1 URL percent-encoding-escape
1758        // byte — the mandatory encoding mechanism for every byte outside the
1759        // `unreserved` alphanumeric / `-` / `.` / `_` / `~` set, and `%`
1760        // itself must be percent-encoded as `%25` to appear literally inside
1761        // a URL value. The byte carries three distinct render-determinism
1762        // hazards on the `:caminho` axis, no prior arm has covered it, and
1763        // the peer `:fonte :repo` axis (a323db8 `%` on `is_git_repo_url`)
1764        // already closes the same byte under the same URL-percent-encoding
1765        // banner — the `:caminho` axis was the last typed path-string surface
1766        // still admitting the byte.
1767        //
1768        // First, the paste-from-browser-address-bar percent-encoded-space
1769        // footgun: an author copies `../caixa%20teia` out of a URL-encoded
1770        // README hyperlink / a browser address bar / a percent-encoded
1771        // permalink expecting `%20` to decode to a literal space at the
1772        // filesystem layer. POSIX `std::path::Path` treats the byte as a
1773        // literal path-component byte, so `Path::join` looks for a literal
1774        // `./../caixa%20teia` subdirectory and fails at resolve time with a
1775        // non-self-locating `No such file or directory` error far from the
1776        // source caixa.lisp — while the author's mental model was
1777        // `../caixa teia`, the decoded shape. Two authors whose only
1778        // difference is percent-encoding presence resolve to two distinct
1779        // BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`)
1780        // for what they intended as the byte-identical sibling-workspace
1781        // dep. The lacre pipeline embeds the value verbatim in its per-dep
1782        // content-address (`conteudo: format!("path:{caminho}")`,
1783        // caixa-resolver/src/resolve.rs:189), so the divergence rides
1784        // downstream into the BLAKE3 closure and locks the substrate's
1785        // "the lacre is the build's identity" contract (CAIXA-SDLC §III.2)
1786        // to the wrong encoding — the same THEORY.md §V.2 render-
1787        // determinism vector every prior `:caminho` arm protects.
1788        //
1789        // Second, the printf-format-specifier lead footgun: `%` is the C /
1790        // POSIX printf format-directive lead-in (`%s`, `%d`, `%02x`, the
1791        // canonical `printf "path=%s\n" ../caixa-teia` invocation every
1792        // shell-diagnostic one-liner carries) and the printf builtin is
1793        // wired into every POSIX shell (bash / zsh / dash / ksh / busybox
1794        // ash) as the format-string lead. A `:caminho "../caixa-%s-teia"`
1795        // value flowing into any future `feira` verb that shells out with a
1796        // printf-formatted path template silently gets reinterpreted as a
1797        // format-directive rather than a literal byte — the canonical
1798        // CWE-134 format-string-injection vector.
1799        //
1800        // Third, the bash-job-control-specifier lead footgun: bash / zsh /
1801        // ksh reserve `%N` at word-start as the job-control specifier —
1802        // `%1` names "job 1", `%%` names "the current job", `%foo` names
1803        // "the most recent job whose command started with `foo`". A future
1804        // `feira` verb that invokes `kill %1` on a caminho-scoped
1805        // subprocess would silently redirect the signal to a wrong target.
1806        //
1807        // Beyond the three shell-side hazards, `%` is a first-class parser
1808        // byte in three cross-config-DSL layers the substrate's paste-idiom
1809        // surface routinely crosses: YAML 1.2 §6.8.1 lexes `%` at
1810        // line-start as the directive lead (`%YAML 1.2` / `%TAG` — a
1811        // `:caminho "%YAML/1.2/../caixa-teia"` paste from a top-of-doc
1812        // YAML directive block silently trips the YAML directive parser on
1813        // any downstream emitted YAML manifest); Prometheus / Grafana
1814        // template syntax uses `%(var)s` as the substitution lead; and Nix
1815        // interpolation uses `${var}` (not `%`) but Envsubst /
1816        // Kubernetes / OpenShift template layers use `%VAR%` as the
1817        // Windows-shell env-var-reference lead — the paste-from-`.bat` /
1818        // paste-from-PowerShell-`%env:PATH%` cross-idiom leak.
1819        //
1820        // The three malformed-`%HH` classes documented on the peer
1821        // `is_git_repo_url` `%` arm (a323db8) apply here too:
1822        //
1823        //   - The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
1824        //     where `%` isn't followed by two hex digits) — every WHATWG-
1825        //     conformant URL parser rejects the value at parse time per
1826        //     RFC 3986 §2.1, but the byte rides into the lacre before
1827        //     the resolver subprocess crosses the URL-parser boundary.
1828        //   - The over-encoded path-separator shape (`"../caixa%2Fteia"`
1829        //     intending the `%2F` as the URL encoding of `/`) locks a
1830        //     `path:../caixa%2Fteia` BLAKE3 closure that diverges from
1831        //     the byte-identical `path:../caixa/teia` form.
1832        //   - The double-encoded shape (`"../caixa%2520teia"` — the `%25`
1833        //     already itself an encoded `%`, so the intent was likely a
1834        //     literal `%20` that survived one round-trip through a
1835        //     URL-encoder that shouldn't have run) locks a triply-
1836        //     divergent closure across the encoded / once-decoded /
1837        //     twice-decoded chain.
1838        //
1839        // POSIX `std::path::Path` treats the byte as a literal path-
1840        // component byte, so a `:caminho "../caixa%20teia"` (the canonical
1841        // paste-from-browser-address-bar percent-encoded-space footgun),
1842        // `:caminho "%YAML/../caixa-teia"` (the symmetric paste-from-YAML-
1843        // directive-block cross-idiom leak), or `:caminho
1844        // "../caixa-%s-teia"` (the printf-format-specifier paste-from-
1845        // shell-diagnostic-one-liner shape) silently passes every prior arm
1846        // because `Path::is_absolute` returns false on `..`, `%` is neither
1847        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
1848        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
1849        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`, and the
1850        // value's last byte isn't `/`. The resolver folds the value through
1851        // `Path::new(caminho).join(<file>)` looking for a literal
1852        // subdirectory named `../caixa%20teia` and fails at resolve time
1853        // with a non-self-locating `No such file or directory` error far
1854        // from the source caixa.lisp — while every downstream URL parser /
1855        // shell printf builtin / YAML directive parser silently
1856        // reinterprets the byte to a different value than the resolver's
1857        // `Path::join` sees. Two workstations whose downstream URL / shell
1858        // / YAML layers differ in `%HH` recognition emit divergent build
1859        // artifacts for the byte-identical caixa.lisp value.
1860        //
1861        // The lacre pipeline embeds the value verbatim in its per-dep
1862        // content-address (`conteudo: format!("path:{caminho}")`, caixa-
1863        // resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1864        // closure and rides into every shell-spawned subprocess (the
1865        // resolver's `git clone`, a future `feira tofu` shell-out, a
1866        // future operator-side `nix flake check` spawn) as the canonical
1867        // URL-percent-encoding-escape / printf-format-specifier / bash-
1868        // job-control-specifier surface every peer single-token-shaped
1869        // typed slot already closes. This arm closes the gap so the
1870        // substrate-wide "no URL-percent-encoding-escape / printf-format-
1871        // specifier / job-control-specifier / YAML-directive-lead byte
1872        // anywhere in a typed string slot that flows verbatim into a
1873        // shell-spawned subprocess or downstream URL / printf / YAML
1874        // parser" invariant extends from shell-comment / URL-fragment
1875        // (`#` — 6622063) to URL-percent-encoding-escape (`%`) on the
1876        // `:caminho` axis.
1877        //
1878        // The arm fires AFTER the shell-comment arm because the prior
1879        // arm's `#` shape is the more semantic-locating axis on values
1880        // that probe as both (`"../caixa%20teia#pin"` carries both `%`
1881        // and `#` — the URL-fragment-identifier is the load-bearing
1882        // downstream-truncation edit, so `FonteCaminhoShellComment` wins;
1883        // same cascade discipline every prior `:caminho` arm establishes).
1884        // The arm fires BEFORE the trailing-`/` arm because the embedded
1885        // percent-encoding-escape byte is the more semantic-locating axis
1886        // on probe-as-both values (`"../caixa%20teia/"` ends in `/` but
1887        // the load-bearing diagnostic is the embedded `%` percent-
1888        // encoding-escape — the trailing `/` is the secondary observation,
1889        // and an author who decodes the `%20` to a literal space is
1890        // likely to also tab-strip the trailing separator).
1891        for &b in caminho.as_bytes() {
1892            if b == b'%' {
1893                return Err(DepError::fonte_caminho_url_percent_encoding(
1894                    nome, caminho, b,
1895                ));
1896            }
1897        }
1898        // Reproducibility gate's embedded-`$` shell-variable-expansion /
1899        // command-substitution / arithmetic-expansion arm. The f4efe9c
1900        // leading-`$` arm at line 540 routes `caminho.starts_with('$')`
1901        // through `FonteCaminhoVarExpansion` under the leading-byte-
1902        // sentinel host-layout-leak banner (peer with the b94fd83
1903        // absolute / a5c248e tilde leading-byte arms), but the arm
1904        // fires only at position 0 — a `:caminho "../foo$HOME/bar"`
1905        // (embedded `$HOME` in a nested path segment — the canonical
1906        // paste-from-`ls ../foo$HOME/bar`-shell-one-liner footgun where
1907        // an author copies a partially-substituted shell one-liner and
1908        // the leading segment is a literal `../foo` while the mid
1909        // segment carries the un-substituted `$HOME` template), a
1910        // `:caminho "../foo${WORKSPACE}/bar"` (the symmetric braced-CI-
1911        // manifest paste-from-`.gitlab-ci.yml` / paste-from-GitHub-
1912        // Actions-workflow shape), a `:caminho "../foo$(whoami)/bar"`
1913        // (the paste-from-shell-prompt command-substitution idiom), or
1914        // a `:caminho "../foo$((1+2))/bar"` (the arithmetic-expansion
1915        // idiom) silently passes every prior arm because
1916        // `Path::is_absolute` returns false on `..`, `$` is neither a
1917        // leading-byte sentinel (the f4efe9c arm fires only at position
1918        // 0) nor a control byte nor `\` nor `<` / `>` nor `|` nor `;`
1919        // nor `&` nor backtick nor `*` / `?` nor `(` / `)` nor `{` /
1920        // `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%`, and the
1921        // value's last byte isn't `/`. Note that `$(...)` command-
1922        // substitution and `$((...))` arithmetic-expansion each carry
1923        // an embedded `(` byte that the 0633c91 shell-subshell-grouping
1924        // arm catches structurally at the earlier `(` position — but
1925        // an author who reaches for the sh-brace-substitution
1926        // `${VAR}` or the bare `$VAR` shape carries only the `$` byte,
1927        // which no prior arm covers. This arm closes the last
1928        // positional gap on the `$` byte on the `:caminho` axis so
1929        // every position — leading (`FonteCaminhoVarExpansion`) and
1930        // embedded (`FonteCaminhoShellVariableExpansion`) — is
1931        // structurally rejected.
1932        //
1933        // Every POSIX shell (sh / bash / zsh / dash / ksh / busybox
1934        // ash / fish / nushell) lexes `$` as the variable-expansion /
1935        // command-substitution / arithmetic-expansion operator per
1936        // POSIX.1-2017 §2.6 (Word Expansions): `$<name>` (Parameter
1937        // Expansion) expands a named variable, `${<name>}` (Parameter
1938        // Expansion braced form) does the same with an explicit token
1939        // boundary, `$(<cmd>)` (Command Substitution modern form,
1940        // `` `<cmd>` `` legacy form which the c370458 backtick arm
1941        // already closes) runs a subshell and substitutes its stdout,
1942        // and `$((<expr>))` (Arithmetic Expansion) evaluates an
1943        // arithmetic expression. Every form is a host-layout /
1944        // environment-state / shell-subprocess-side-effect leak when
1945        // the byte lands in a value the resolver passes to a shell-
1946        // spawned subprocess. Beyond the POSIX shell layer, `$` is
1947        // the Nix `${var}` string-interpolation lead (the paste-from-
1948        // `flake.nix` / paste-from-`.nix`-attribute cross-idiom leak
1949        // where an author copies `"${pkgs.hello}/bin/hello"` out of a
1950        // nix expression), the Make `$(var)` / `$@` / `$<` automatic-
1951        // variable lead (the paste-from-`Makefile` shape), the
1952        // JavaScript / TypeScript template-literal `${expr}` interp
1953        // lead (the paste-from-JS-template-string idiom in a
1954        // multi-lang-monorepo where a `path` attribute gets copied out
1955        // of a `package.json` script or a Vite config), the envsubst /
1956        // Kubernetes / OpenShift template `${VAR}` interp lead (the
1957        // paste-from-Helm-values / paste-from-K8s-manifest cross-idiom
1958        // leak), the PHP variable lead (`$_GET`, `$_ENV` — the paste-
1959        // from-`.php`-config footgun), the Perl scalar-variable lead
1960        // (`$foo`), the SASS / SCSS variable lead (`$primary-color`),
1961        // and the SQL bind-parameter lead in PostgreSQL / SQLite
1962        // (`$1`, `$2` — the paste-from-`.sql`-migration idiom). The
1963        // cross-idiom paste-footgun surface is broader than any single
1964        // shell layer — `$` is a first-class parser byte in nearly
1965        // every config / templating / build-system DSL the substrate's
1966        // paste-idiom surface routinely crosses. The peer `:fonte
1967        // :repo` axis closes the byte under the shell-variable-
1968        // expansion / URL-sub-delim banner (b9d187c `$` on
1969        // `is_git_repo_url`), the peer `:fonte :tag` / `:fonte :branch`
1970        // axes close `$` as part of `is_git_ref_name`'s printable-
1971        // ASCII-restricted grammar (`git check-ref-format` rejects the
1972        // byte outright), and the peer `:entrada :paths` axis closes
1973        // `$` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-
1974        // reserved set. The `:caminho` axis was the last typed path-
1975        // string surface still admitting `$` at positions other than 0.
1976        //
1977        // POSIX `std::path::Path` treats `$` as a literal path-
1978        // component byte, so `:caminho "../foo$HOME/bar"` silently
1979        // routes through `Path::new(caminho).join(<file>)` looking for
1980        // a literal `./{caminho}` subdirectory that fails at resolve
1981        // time with a non-self-locating `No such file or directory`
1982        // error far from the source caixa.lisp. But every downstream
1983        // shell / envsubst / Nix / Make / K8s-template parser silently
1984        // reinterprets the byte to a different value than the
1985        // resolver's `Path::join` sees — so a `feira tofu` shell-out
1986        // to a `cd '{caminho}'` command line, a `nix flake check`
1987        // invocation on an emitted YAML `path:` scalar folded through
1988        // envsubst, or a `helm template` invocation with a
1989        // `values.yaml` `path: {caminho}` embedded in a `{{`-quoted
1990        // template all disagree with the resolver on which directory
1991        // the value names. Two workstations whose downstream shell /
1992        // envsubst / Nix / Make / K8s-template parsing layers differ
1993        // in `$VAR` recognition (or, worse, expand the byte against
1994        // divergent environments — Alice's `$HOME=/home/alice`, Bob's
1995        // `$HOME=/home/bob`) emit divergent build artifacts for the
1996        // byte-identical caixa.lisp value. Even in the case where the
1997        // resolver strictly does NOT expand `$VAR` (the current
1998        // implementation) the divergence still bites at the lacre-
1999        // identity axis: the lacre pipeline embeds the value verbatim
2000        // in its per-dep content-address (`conteudo:
2001        // format!("path:{caminho}")`, caixa-resolver/src/resolve.rs:189),
2002        // so `path:../foo$HOME/bar` locks a BLAKE3 closure distinct
2003        // from the byte-identical-semantic `path:../foo/home/alice/bar`
2004        // one author would have produced by substituting the literal
2005        // value at author time, defeating the THEORY.md §V.2 render-
2006        // determinism contract on the same axis every prior `:caminho`
2007        // arm protects.
2008        //
2009        // Beyond the render-determinism / host-layout-leak vectors,
2010        // `$` at any position in a value flowing verbatim into a
2011        // shell-spawned subprocess is the canonical CWE-78 shell-
2012        // command-injection surface every peer single-token-shaped
2013        // typed slot already closes. A `:caminho "../foo$(whoami)/bar"`
2014        // that rides into a future `feira tofu` shell-out as `cd
2015        // '../foo$(whoami)/bar'` gets substituted by the shell at
2016        // subprocess-argument-expansion time even inside single quotes
2017        // in fewer positions than one might expect (the substitution
2018        // fires only outside single-quoting per POSIX §2.2.2, but
2019        // eval-style wrappers and `sh -c` layers that route the value
2020        // through re-parsing round-trip the substitution — the same
2021        // vector the c370458 backtick arm closes at the sibling
2022        // command-substitution-legacy-form surface). Every future
2023        // `feira` verb that shells out with a `caminho`-formatted
2024        // subprocess argument silently inherits this substitution
2025        // vector unless the typed slot's accepted set structurally
2026        // excludes the byte.
2027        //
2028        // Frontier inspiration: OTP's `gen_server` return-value grammar
2029        // rejects mid-tuple shell-metachar bytes by construction —
2030        // `{noreply, State}` never carries a raw `$` because the
2031        // Erlang term type system has no notion of "string that gets
2032        // shelled out"; caixa's typed slots inherit the same
2033        // structural discipline (types-are-theorems, the compounding
2034        // mandate's leverage-point-1) by refusing values that would
2035        // silently reinterpret at any downstream layer. Peer with
2036        // Unison's content-addressed code (no ambient environment —
2037        // every reference is a hash, no `$VAR` substitution possible)
2038        // and Pony's capabilities (a path capability that carries a
2039        // `$` would be ill-typed at the reference layer).
2040        //
2041        // The arm fires AFTER the URL-percent-encoding-escape arm (the
2042        // e3558fa `%` arm) because a value carrying both `%` and `$`
2043        // (`"../foo%20$HOME/bar"` — the canonical "I pasted a percent-
2044        // encoded space next to a `$HOME` template") surfaces the
2045        // narrower URL-encoding diagnostic first — the paste-from-
2046        // browser-address-bar shape is the load-bearing self-locating
2047        // edit on every probe-as-both value; same cascade discipline
2048        // every prior `:caminho` arm establishes (a323db8 %  before
2049        // this arm, this arm before trailing-`/`). The arm fires
2050        // BEFORE the trailing-`/` arm because the embedded shell-
2051        // variable-expansion byte is the more semantic-locating axis
2052        // on probe-as-both values (`"../foo$HOME/bar/"` ends in `/`
2053        // but the load-bearing diagnostic is the embedded `$` — the
2054        // trailing `/` is the secondary observation, and an author
2055        // who substitutes the `$HOME` template with a literal value is
2056        // likely to also tab-strip the trailing separator).
2057        for &b in caminho.as_bytes() {
2058            if b == b'$' {
2059                return Err(DepError::fonte_caminho_shell_variable_expansion(
2060                    nome, caminho, b,
2061                ));
2062            }
2063        }
2064        // Reproducibility gate's shell-history-expansion / RFC-3986-sub-delims
2065        // arm. The immediate-predecessor `$` embedded arm closes the shell-
2066        // variable-expansion / command-substitution byte; `!` (`0x21`) is the
2067        // orthogonal POSIX shell-history-expansion sentinel every interactive
2068        // shell with history enabled (bash / ksh / zsh's `bashcompat` /
2069        // csh / tcsh) lexes as the history-expansion prefix: `!command`
2070        // re-runs the most recent history entry beginning with `command`,
2071        // `!!` re-runs the prior command verbatim, `!$` substitutes the
2072        // last word of the prior command, `!:N` substitutes the Nth word,
2073        // `^old^new` rewrites the prior command's `old` to `new` (the
2074        // canonical set of `set -o histexpand` operators bash's default
2075        // interactive session enables). Beyond the shell-history layer,
2076        // RFC 3986 §2.2 lists `!` in the `sub-delims` set (the URL grammar
2077        // admits the byte inside a path segment, but every WHATWG-conformant
2078        // special-scheme URL parser percent-encodes it inside a query
2079        // component via the 'special-query percent-encode set' the peer
2080        // `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte
2081        // is also the C / C++ / Rust / JavaScript / Python bang-operator
2082        // (logical-negation prefix — the paste-from-source-code idiom where
2083        // an author copies `!path.exists()` out of a Rust snippet and the
2084        // trailing punctuation crosses the string-literal boundary); the
2085        // canonical English-typography emphasis / exclamation mark (the
2086        // paste-from-prose enthusiasm-form idiom where an author writes
2087        // `:caminho "../caixa-teia!"` expecting the substrate to coerce it
2088        // to a kebab-case slug); and the Nix flake-ref import-attribute
2089        // `import ./foo.nix { … }` sibling operator surface.
2090        //
2091        // POSIX `std::path::Path` treats `!` as a literal path-component
2092        // byte, so a `:caminho "../caixa-teia!sudo"` (the canonical paste-
2093        // from-shell-history footgun where the author copies a `cd
2094        // ../caixa-teia && !sudo make install` one-liner from a quick-
2095        // start README and the trailing `!sudo` rides in verbatim as a
2096        // history-expansion reference), a `:caminho "../foo!!/bar"` (the
2097        // `!!` repeat-prior-command paste idiom), a `:caminho
2098        // "../caixa-teia!"` (the English-typography enthusiasm-form
2099        // paste-from-prose footgun), or a `:caminho "../foo!$"` (the
2100        // last-word-substitution shape) silently pass every prior arm
2101        // because `Path::is_absolute` returns false on `..`, `!` is neither
2102        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
2103        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
2104        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%` nor `$`,
2105        // and the value's last byte isn't `/`. The resolver folds the value
2106        // through `Path::new(caminho).join(<file>)` looking for a literal
2107        // `./../caixa-teia!sudo` subdirectory and fails at resolve time
2108        // with a non-self-locating `No such file or directory` error far
2109        // from the source caixa.lisp — while every downstream interactive
2110        // shell with `set -o histexpand` reinterprets the byte as the
2111        // history-expansion prefix, and the failure mode forks per
2112        // consumer: a `feira tofu` shell-out to a `cd '{caminho}'` command
2113        // line executed under `bash -i` (the operator-notebook interactive
2114        // shell) substitutes the `!sudo` reference to the most recent
2115        // history entry starting with `sudo`, silently invoking whatever
2116        // privileged command that entry named.
2117        //
2118        // The lacre pipeline embeds the value verbatim in its per-dep
2119        // content-address (`conteudo: format!("path:{caminho}")`,
2120        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2121        // BLAKE3 closure and rides into every shell-spawned subprocess
2122        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2123        // a future operator-side `nix flake check` spawn) as the
2124        // canonical shell-history-expansion / RFC-3986-sub-delims surface
2125        // every peer single-token-shaped typed slot already closes. The
2126        // peer `:fonte :repo` axis closes the byte under the same shell-
2127        // history-expansion / RFC-3986-sub-delims banner (7d53c68 `!` on
2128        // `is_git_repo_url`); the `:caminho` axis was the last typed
2129        // path-string surface still admitting the byte. This arm closes
2130        // the gap so the substrate-wide "no shell-composition
2131        // metacharacter / history-expansion sentinel anywhere in a typed
2132        // string slot that flows verbatim into a shell-spawned subprocess"
2133        // invariant extends from shell-variable-expansion (`$`) to shell-
2134        // history-expansion (`!`) on the `:caminho` axis. Together with
2135        // the peer c370458 backtick command-substitution-legacy-form arm
2136        // and the b9d187c-`$`-embedded-variable-expansion arm on the
2137        // sibling `:repo` axis, the typed `:caminho` accepted set now
2138        // structurally excludes every byte the POSIX shell §2.6 Word
2139        // Expansions section, §2.3 Token Recognition step 6, and every
2140        // history-expansion / brace-expansion / pathname-expansion /
2141        // parameter-expansion / command-substitution / arithmetic-
2142        // expansion operator lexes as a first-class parser byte.
2143        //
2144        // Frontier inspiration: Unison's content-addressed code (no
2145        // ambient environment — every reference is a hash, no `!<num>`
2146        // history-index substitution possible; the caixa substrate's
2147        // lacre discipline arrives at the same guarantee by refusing
2148        // bytes at manifest-parse time that would reinterpret against
2149        // ambient shell history state); Pony's capabilities (a path
2150        // capability that carries a `!` would be ill-typed at the
2151        // reference layer).
2152        //
2153        // The arm fires AFTER the shell-variable-expansion arm because a
2154        // value carrying both `$` and `!` (`"../foo$HOME/bar!sudo"` — the
2155        // canonical "I pasted a `$HOME`-templated path adjacent to a
2156        // trailing `!sudo` history-expansion") surfaces the narrower
2157        // shell-variable-expansion diagnostic first — the paste-from-CI-
2158        // manifest-with-`$VAR`-template shape is the load-bearing self-
2159        // locating edit on every probe-as-both value; same cascade
2160        // discipline every prior `:caminho` arm establishes. The arm
2161        // fires BEFORE the trailing-`/` arm because the embedded shell-
2162        // history-expansion byte is the more semantic-locating axis on
2163        // probe-as-both values (`"../foo!sudo/"` ends in `/` but the
2164        // load-bearing diagnostic is the embedded `!` — the trailing `/`
2165        // is the secondary observation, and an author who removes the
2166        // `!sudo` history reference is likely to also tab-strip the
2167        // trailing separator).
2168        for &b in caminho.as_bytes() {
2169            if b == b'!' {
2170                return Err(DepError::fonte_caminho_shell_history_expansion(
2171                    nome, caminho, b,
2172                ));
2173            }
2174        }
2175        // Reproducibility gate's shell-history-substitution / RFC-3986-unwise
2176        // / regex-anchor arm. The immediate-predecessor `!` arm closes the
2177        // POSIX `!command` / `!!` / `!$` history-expansion prefix; `^`
2178        // (`0x5E`) is the paired-operator half of the same bash-reference
2179        // §9.3 histexpand feature — the `^old^new^` "quick substitution"
2180        // form (POSIX bash rewrites the prior command's `old` string to
2181        // `new` and re-executes it, the canonical typo-correction one-
2182        // liner idiom `git clone <bad-url>` → `^bad^good` that pastes the
2183        // trailing substitution fragment verbatim into a `:caminho` value
2184        // when the author trims only the leading `git clone` prefix). The
2185        // peer `:fonte :repo` axis closes the byte under the same
2186        // shell-history-substitution / RFC-3986-unwise banner (49e142f `^`
2187        // on `is_git_repo_url`); the `:caminho` axis was the last typed
2188        // path-string surface still admitting the byte after 6a04767
2189        // landed the `!` arm.
2190        //
2191        // Beyond bash history-substitution, `^` carries five distinct
2192        // downstream-reinterpretation surfaces the typed slot's accepted
2193        // set must structurally exclude:
2194        //
2195        // 1. **RFC 3986 §2 'unwise' set** — the four-byte cross-transport
2196        //    layer set (`{`, `}`, `|`, `\`) plus `^` every URL parser is
2197        //    required to percent-encode-or-refuse at the wire boundary.
2198        //    The WHATWG URL spec's 'fragment percent-encode set' maps
2199        //    `^` → `%5E` at the query / fragment component transition;
2200        //    libcurl silently percent-encodes the byte on the wire, so a
2201        //    `:caminho "../foo^bar"` value the resolver's `Path::join`
2202        //    sees as a literal `./../foo^bar` subdirectory diverges from
2203        //    the byte-transformed `%5E` shape any downstream `feira tofu`
2204        //    curl-invocation or artifact-registry-fetch would emit — the
2205        //    canonical wire-boundary divergence vector the peer
2206        //    `{`, `}`, `|`, `\` `:caminho` arms already close (
2207        //    `FonteCaminhoShellBraceExpansion` at 598b770,
2208        //    `FonteCaminhoShellPipe` at the pipe arm,
2209        //    `FonteCaminhoBackslash` at the backslash arm).
2210        // 2. **Regex character-class negation prefix `[^abc]`** — the
2211        //    canonical paste-from-doc-regex-pipeline footgun where an
2212        //    author copies a `grep '[^abc]'` idiom from a docs quick-
2213        //    listing and the character-class negation byte rides in
2214        //    verbatim.
2215        // 3. **Bitwise XOR operator** in C / C++ / Rust / Python /
2216        //    JavaScript / Nix / Go — the paste-from-source-code idiom
2217        //    where an author copies an `x ^ y`-shaped expression out of
2218        //    a source snippet and the operator crosses the string-
2219        //    literal boundary.
2220        // 4. **Windows `cmd.exe` escape metacharacter** — the byte
2221        //    escapes the next character in a `cmd.exe` batch context (a
2222        //    peer of the backslash arm's Windows-separator-leak vector).
2223        //    A `:caminho "..^&whoami"` cross-platform paste-from-batch-
2224        //    file footgun reinterprets at every `cmd.exe`-spawned
2225        //    subprocess (the resolver's future Windows-runner shell-out,
2226        //    the operator's WinRM path, a future PowerShell-embedded
2227        //    invocation).
2228        // 5. **LaTeX / Markdown / BibTeX superscript operator** — the
2229        //    paste-from-typeset-doc footgun where a mathematical
2230        //    superscript notation (`x^2` / `M^T`) leaks from prose.
2231        //
2232        // POSIX `std::path::Path` treats `^` as a literal path-component
2233        // byte, so `:caminho "../foo^bar/baz"` (embedded quick-
2234        // substitution), `:caminho "../foo^"` (trailing history-
2235        // substitution-open shape), `:caminho "../[^a-z]/foo"` (regex-
2236        // negation-prefix paste from a grep pipeline; note the `[` / `]`
2237        // arm at 986963b fires first on this shape), or `:caminho
2238        // "../x^y"` (XOR-expression paste-from-source) all silently pass
2239        // every prior arm (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` /
2240        // backtick / `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'`
2241        // / `"` / `#` / `%` / `$` / `!`) and route through
2242        // `Path::new(caminho).join(<file>)` looking for a literal
2243        // `./{caminho}` subdirectory that fails at resolve time with a
2244        // non-self-locating `No such file or directory` error far from
2245        // the source caixa.lisp — while every downstream shell / curl /
2246        // regex / `cmd.exe` layer reinterprets the byte to its own
2247        // semantic.
2248        //
2249        // The lacre pipeline embeds the value verbatim in its per-dep
2250        // content-address (`conteudo: format!("path:{caminho}")`,
2251        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2252        // BLAKE3 closure and rides into every shell-spawned subprocess
2253        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2254        // a future operator-side `nix flake check` spawn) as the
2255        // canonical shell-history-substitution / RFC-3986-unwise /
2256        // regex-negation surface every peer single-token-shaped typed
2257        // slot already closes. This arm together with the immediate-
2258        // predecessor `!` arm (6a04767) closes the full `set -o
2259        // histexpand` operator surface on the `:caminho` axis — the
2260        // `!command` / `!!` / `!$` prefix form via `!`, the `^old^new^`
2261        // quick-substitution form via `^` — so the substrate-wide "no
2262        // shell-history operator anywhere in a typed string slot that
2263        // flows verbatim into a shell-spawned subprocess" invariant
2264        // extends from the `!` prefix half to the `^` quick-substitution
2265        // half. Every peer bash-history operator now fails at manifest-
2266        // parse time with a self-locating diagnostic naming the offending
2267        // caixa.lisp rather than at resolve-time as a `Path::join`-
2268        // derived `No such file or directory` (harmless but non-self-
2269        // locating) or worse riding into a downstream `bash -i` context
2270        // that reinterprets the byte-pair against ambient history state.
2271        //
2272        // Frontier inspiration: bash reference §9.3 HISTORY EXPANSION
2273        // "Quick substitution. Repeat the previous command, replacing
2274        // string1 with string2." + RFC 3986 §2 'unwise' set
2275        // ("characters that gateways and other transport agents are
2276        // known to sometimes modify") + Pony's capabilities (a path
2277        // capability that carries a `^` would be ill-typed at the
2278        // reference layer, matching the same structural discipline the
2279        // sibling `!` history-expansion arm inherits from Unison's
2280        // content-addressed no-ambient-history discipline).
2281        //
2282        // The arm fires AFTER the shell-history-expansion `!` arm because
2283        // a value carrying both `!` and `^` (`"../foo!sudo^bad^good"` —
2284        // the canonical "I pasted a `!sudo` history-reference next to a
2285        // `^bad^good` quick-substitution") surfaces the narrower prefix-
2286        // form `!` diagnostic first — the `!` form is the load-bearing
2287        // self-locating edit on every probe-as-both value (an author who
2288        // removes the `!sudo` reference is likely to also strip the
2289        // paired `^` substitution fragment); same cascade discipline
2290        // every prior `:caminho` arm establishes. The arm fires BEFORE
2291        // the trailing-`/` arm because the embedded shell-history-
2292        // substitution byte is the more semantic-locating axis on
2293        // probe-as-both values (`"../foo^bar/"` ends in `/` but the
2294        // load-bearing diagnostic is the embedded `^` — the trailing `/`
2295        // is the secondary observation, and an author who removes the
2296        // `^bar` substitution fragment is likely to also tab-strip the
2297        // trailing separator).
2298        for &b in caminho.as_bytes() {
2299            if b == b'^' {
2300                return Err(DepError::fonte_caminho_shell_history_substitution(
2301                    nome, caminho, b,
2302                ));
2303            }
2304        }
2305        // Reproducibility gate's trailing-`/` arm. The b94fd83 absolute arm
2306        // closes the leading-`/` host-layout-leak; the embedded-control-byte
2307        // arm closes any byte-in-the-`0x00..=0x1F` / `0x7F` range; the
2308        // backslash arm closes the cross-host-OS-separator vector. The
2309        // trailing-`/` is the orthogonal shell-tab-completion-on-a-directory
2310        // footgun — `Path::join("../caixa-teia")` and
2311        // `Path::join("../caixa-teia/")` resolve to the same directory
2312        // (POSIX path-component-walk treats trailing `/` as a no-op for
2313        // directory targets, which `:caminho` always names — the sibling-
2314        // workspace dep root is structurally a directory). The lacre
2315        // pipeline embeds the value verbatim in its per-dep content-address
2316        // (`conteudo: format!("path:{caminho}")`,
2317        // caixa-resolver/src/resolve.rs:189), so byte-identical caixa
2318        // semantic-meaning yields two distinct BLAKE3 closures depending on
2319        // whether the author shell-tab-completed the path (every interactive
2320        // shell appends `/` on tab-completing a directory, idiomatic in
2321        // bash / zsh / fish / nushell), pasted from `pwd` (which on most
2322        // shells emits without trailing `/`, but `realpath -e -m` on a
2323        // directory with trailing `/` preserves it), or copied a Cargo
2324        // `path = "../caixa-teia/"` entry from cross-substrate documentation
2325        // (Cargo accepts both shapes and folds them the same way). Two
2326        // workstations whose authors differ only in tab-completion habits
2327        // emit byte-divergent lacres for the byte-identical-semantic caixa,
2328        // and the substrate's "the lacre is the build's identity" contract
2329        // (CAIXA-SDLC §III.2) silently breaks far from the source caixa.lisp.
2330        //
2331        // Same THEORY.md §V.2 render-determinism axis every prior `:caminho`
2332        // arm protects, here against the trailing-separator divergence
2333        // vector: every typed slot's accepted set excludes byte-divergent
2334        // values that round-trip to the same downstream semantic. The peer
2335        // path-shaped axes already reject trailing separators on the same
2336        // contract: [`crate::render::is_gateway_api_http_path`] gates
2337        // `:entrada :paths` against any non-canonical normalization, and
2338        // [`crate::render::is_sandboxed_relative_path`] gates the M2 typed
2339        // path-slots (`:behavior :on-*`, `:upgrade-from :state-change
2340        // :script`, `:bibliotecas`, `:exe`, `:servicos`) against shapes
2341        // whose canonical form would re-introduce determinism divergence.
2342        //
2343        // The arm fires last in the cascade because every prior arm carries
2344        // a more self-locating diagnostic on values that probe as both
2345        // (e.g. `:caminho "../foo/\0/"` ends in `/` but the load-bearing
2346        // diagnostic is the NUL byte's POSIX-syscall-rejection — the
2347        // control-char arm wins; `:caminho "/etc/passwd/"` ends in `/` but
2348        // the load-bearing diagnostic is the absolute host-layout-leak —
2349        // the absolute arm wins; `:caminho "..\caixa-teia/"` ends in `/`
2350        // but the load-bearing diagnostic is the Windows-separator cross-
2351        // OS divergence — the backslash arm wins). The arm covers every
2352        // shape where the last byte is `/` regardless of length, including
2353        // the degenerate single-`/` (which the absolute arm catches first)
2354        // and the consecutive-`//` (where every prior arm passes on the
2355        // bytes other than the trailing `/`).
2356        if caminho.as_bytes().last() == Some(&b'/') {
2357            return Err(DepError::fonte_caminho_trailing_slash(nome, caminho));
2358        }
2359        Ok(())
2360    }
2361}
2362
2363impl Dep {
2364    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:nome` scalar
2365    /// accessor every consumer of the dep-graph identity axis keys off —
2366    /// returns the author-declared `:nome` byte-string verbatim as a
2367    /// `&str`, borrowed from the typed slot's own [`String`] storage.
2368    ///
2369    /// The `:deps :nome` / `:deps-dev :nome` slot carries the DNS-1123
2370    /// label that names the target caixa (validated by [`Self::validate`]
2371    /// through the shared [`crate::render::is_dns_1123_label`] predicate,
2372    /// same accept-set the peer caixa-identifier axes carry — top-level
2373    /// [`crate::Caixa::nome`], per-`:membros` [`crate::Membro::nome`],
2374    /// per-`:children` [`crate::supervisor::ChildSpec::nome`]). Every
2375    /// downstream consumer that fans on the dep's name-identity keys off
2376    /// this scalar: the [`crate::Caixa::validate_deps`] per-list
2377    /// [`crate::render::insert_first_seen`] dedup key + the paired
2378    /// [`DepError::DuplicateNome`] carrier the walk raises on collision,
2379    /// the cross-list [`validate_no_self_dep`] parent-name equality gate
2380    /// on both `:deps` and `:deps-dev` traversals, the `caixa-resolver`
2381    /// pipeline's `HashSet<String>` seen-set the closure walker gates
2382    /// requeueing off (`caixa-resolver/src/resolve.rs:55`), the resolver's
2383    /// per-transitive-target requeue path (`resolve.rs:63,66`), the
2384    /// [`crate::DepSource::default_github`]-shaped resolver-side shorthand
2385    /// fill-in that folds `:nome` into the fetched-git-URL (`resolve.rs:147`),
2386    /// every `caixa-resolver` `ResolveError::MissingPath` /
2387    /// `ResolveError::MissingPin` carrier that names the offending dep
2388    /// (`resolve.rs:177,206`), each resolved
2389    /// `caixa-lacre::LacreEntry` `nome:` field the closure hash keys off
2390    /// (`resolve.rs:108,113`), and the peer `feira lock` stub-resolver's
2391    /// `LacreEntry` emitter (`caixa-feira/src/cmd/lock.rs:59,61,64`).
2392    ///
2393    /// Prior to this lift the `.nome` byte-string was read inline at every
2394    /// production site — the [`crate::Caixa::validate_deps`] paired
2395    /// `dep.nome.as_str()` / `dep.nome.clone()` accesses on both `:deps`
2396    /// and `:deps-dev` traversals, the [`validate_no_self_dep`] pair of
2397    /// parent-equality checks, and every caixa-resolver / caixa-feira
2398    /// site enumerated above — open-coded field-accesses that expressed
2399    /// no compile-time link back to the typed slot. A future extension of
2400    /// the `:deps :nome` axis to a richer author surface (a per-scope
2401    /// alias table the resolver folds through the `~/.config/caixa/config.yaml`
2402    /// entry the [`crate::dep::Dep`] docstring already acknowledges, a
2403    /// namespace-qualified rewrite the future M4 lacre-federation layer
2404    /// applies per-cluster, a promotion of the plain [`String`] byte-string
2405    /// to a richer scoped-identifier newtype once cross-registry federation
2406    /// lands) would have had to be threaded through every open-coded copy
2407    /// in lockstep or two consumers would silently disagree on which caixa
2408    /// a given dep resolves to — the [`crate::Caixa::validate_deps`] dedup
2409    /// set treating the name as `"caixa-teia"` while the caixa-resolver
2410    /// closure walker treated it as `"tenant-a/caixa-teia"` would silently
2411    /// split the [`DepError::DuplicateNome`] refusal from the resolver's
2412    /// requeue-suppression seen-set, one build-time diagnostic
2413    /// disagreeing with the run-time closure the substrate's lacre
2414    /// pipeline actually materializes. Lifting the resolution rule to a
2415    /// typed method on the substrate primitive means every downstream
2416    /// consumer of the caixa's per-`:deps` identity surface reaches for
2417    /// exactly one typed dispatch — the resolver's accept-set migrates as
2418    /// a unit on any future axis addition.
2419    ///
2420    /// First accessor on the outer `Dep` type — opens the outer-`Dep`
2421    /// `&str`-return required-scalar projection pattern the sibling
2422    /// per-`Dep` `:versao` future lift folds on. Peer of the sibling
2423    /// per-`:membros` [`crate::Membro::nome`] (4a32abf) /
2424    /// per-`:children` [`crate::supervisor::ChildSpec::nome`] (dfb4a81)
2425    /// / top-level [`crate::Caixa::nome`] (e6b7d97) caixa-identity scalar
2426    /// accessors — same "one typed dispatch on the substrate primitive,
2427    /// thin projections at each consumer" discipline extended onto the
2428    /// third named-caixa-referencing axis (`:deps` / `:deps-dev`), the
2429    /// remaining unlifted caixa-name-referencing accessor family in the
2430    /// substrate. Named `nome()` to match the tatara-lisp author-surface
2431    /// term the field's docstring already reaches for ("Caixa name — must
2432    /// match the target caixa's `:nome`") and the peer caixa-identity
2433    /// accessor family the substrate already carries.
2434    #[must_use]
2435    pub const fn nome(&self) -> &str {
2436        self.nome.as_str()
2437    }
2438
2439    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:versao`
2440    /// Cargo-shaped semver-requirement scalar accessor every consumer of
2441    /// the dep-graph version-pin axis keys off — returns the author-
2442    /// declared `:versao` requirement byte-string verbatim as a `&str`,
2443    /// borrowed from the typed slot's own [`String`] storage.
2444    ///
2445    /// The `:deps :versao` / `:deps-dev :versao` slot carries the
2446    /// Cargo-shaped semver requirement string (`"^0.1"`, `"~0.1.2"`,
2447    /// `"0.1.0"`, `"*"`) the shared [`crate::version::parse_requirement`]
2448    /// entry-point consumes — same accept-set the peer requirement-
2449    /// carrying axes carry (per-`:membros`
2450    /// [`crate::Membro::versao_requirement`], per-`:children`
2451    /// [`crate::supervisor::ChildSpec::versao_requirement`]), validated
2452    /// through the shared
2453    /// [`crate::render::require_valid_versao_requirement`] cascade in
2454    /// [`Self::validate`]. Every downstream consumer that fans on the
2455    /// dep's version-pin keys off this scalar: the [`Self::validate`]
2456    /// `require_valid_versao_requirement` gate + the paired
2457    /// [`DepError::VersaoInvalid`] carrier the cascade raises on
2458    /// requirement-shape rejection, the `feira lock` stub-resolver's
2459    /// `format!("{}@{}", dep.nome(), dep.versao_requirement())`
2460    /// `conteudo` hash-input interpolation and the paired
2461    /// `LacreEntry.versao:` `String`-carry fill (`caixa-feira/src/cmd/lock.rs`),
2462    /// and the peer `feira lock` end-to-end fixture in `caixa-feira/tests/feira_e2e.rs`.
2463    ///
2464    /// Prior to this lift the `.versao` byte-string was read inline at
2465    /// every production site — the [`Self::validate`] paired
2466    /// `&self.versao` requirement-gate reference and `self.versao.clone()`
2467    /// error-body carrier, the `caixa-feira/src/cmd/lock.rs` paired
2468    /// `format!("{}@{}", dep.nome(), dep.versao)` `conteudo` interpolation
2469    /// and `versao: dep.versao.clone()` `LacreEntry` fill, and the
2470    /// `caixa-feira/tests/feira_e2e.rs` end-to-end fixture's pair of the
2471    /// same shapes — open-coded field-accesses that expressed no
2472    /// compile-time link back to the typed slot. A future extension of
2473    /// the `:deps :versao` axis to a richer author surface (a per-scope
2474    /// version-lock overlay the resolver folds through the
2475    /// `~/.config/caixa/config.yaml` entry the [`crate::dep::Dep`]
2476    /// docstring already acknowledges, a per-cluster canary-version
2477    /// overlay per MESH-COMPOSITION §III.2, a promotion of the plain
2478    /// [`String`] requirement to a richer parsed-`VersionReq` newtype
2479    /// once cross-registry federation lands) would have had to be
2480    /// threaded through every open-coded copy in lockstep or two
2481    /// consumers would silently disagree on which release constraint a
2482    /// given dep resolves to — the [`Self::validate`] requirement-gate
2483    /// call reading `"^0.1"` while the `feira lock` stub-resolver's
2484    /// `conteudo` hash-input read `"tenant-a-pin/^0.1"` would silently
2485    /// split the [`DepError::VersaoInvalid`] refusal from the lacre's
2486    /// content-addressed hash the substrate's fetch pipeline actually
2487    /// materializes, one build-time diagnostic disagreeing with the
2488    /// run-time closure. Lifting the resolution rule to a typed method
2489    /// on the substrate primitive means every downstream consumer of
2490    /// the caixa's per-`:deps` version-pin surface reaches for exactly
2491    /// one typed dispatch — the resolver's accept-set migrates as a
2492    /// unit on any future axis addition.
2493    ///
2494    /// Second accessor on the outer `Dep` type — folds on the outer-
2495    /// `Dep` `&str`-return required-scalar projection pattern the
2496    /// sibling per-`Dep` [`Self::nome`] (eba2cde) accessor opened. Peer
2497    /// of the per-`:membros` [`crate::Membro::versao_requirement`]
2498    /// (a40b0e3) / per-`:children`
2499    /// [`crate::supervisor::ChildSpec::versao_requirement`] (7844f4e
2500    /// family) member/child version-pin accessors — the three
2501    /// requirement-carrying axes (`Dep::versao_requirement` on the
2502    /// per-caixa dep-graph edge, `Membro::versao_requirement` on the M3
2503    /// Aplicacao side, `ChildSpec::versao_requirement` on the M2
2504    /// Supervisor side) now share one accessor discipline for the
2505    /// shared substrate concept "another caixa referenced by a
2506    /// Cargo-shaped semver requirement". The pair
2507    /// `(nome(), versao_requirement())` jointly projects the
2508    /// `(nome, versao)` field pair every dep-graph consumer that fans
2509    /// on per-dep identity + version pin keys off. Named
2510    /// `versao_requirement()` rather than `versao()` because the field's
2511    /// storage-side `.versao` label is already the author-surface term
2512    /// (`:versao`); the accessor's name carries the semantic role — the
2513    /// semver *requirement* string the shared
2514    /// [`crate::version::parse_requirement`] entry-point consumes — so a
2515    /// raw field access and a typed dispatch read differently at every
2516    /// consumer site. Matches the peer
2517    /// [`crate::Membro::versao_requirement`] /
2518    /// [`crate::supervisor::ChildSpec::versao_requirement`] naming
2519    /// discipline verbatim.
2520    #[must_use]
2521    pub const fn versao_requirement(&self) -> &str {
2522        self.versao.as_str()
2523    }
2524
2525    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:fonte`
2526    /// Zig-store-model per-dep source-tuple optional-composite-reference
2527    /// accessor every consumer of the dep-graph fetch-source axis keys
2528    /// off — returns the author-declared `:fonte` typed [`DepSource`]
2529    /// verbatim as an `Option<&DepSource>` borrowed from the typed slot's
2530    /// own `Option<DepSource>` storage, with `None` naming the "author
2531    /// omitted `:fonte`" shorthand every resolver-side default-fill
2532    /// (`caixa-feira/src/cmd/lock.rs`'s stub, `caixa-resolver/src/resolve.rs`'s
2533    /// canonical fetcher, per the [`DepSource::default_github`] fallback
2534    /// the [`Dep::fonte`] field docstring already documents) treats as
2535    /// the "resolve through the configured default host / org
2536    /// (`github:<default-org>/<nome>`)" partition.
2537    ///
2538    /// The `:deps :fonte` / `:deps-dev :fonte` slot carries the two-
2539    /// arm typed [`DepSource`] the `Zig-style git-only store model` the
2540    /// enclosing [`Dep`] docstring names — `DepSource::Git { repo, tag,
2541    /// rev, branch }` for the git-clone arm every published caixa
2542    /// resolves through, `DepSource::Path { caminho }` for the dev-only
2543    /// local-filesystem arm every unpublishable in-tree checkout
2544    /// resolves through. Every downstream consumer that fans on the
2545    /// dep's fetch-source keys off this accessor: [`Self::validate`]'s
2546    /// per-`:fonte` [`DepSource::validate`] delegation (which raises
2547    /// the empty-`:repo` / missing-pin / multiple-pin / empty-`:caminho`
2548    /// diagnostics through the [`DepError::Fonte*`] carrier family
2549    /// naming the offending `Dep::nome`), the caixa-crd conversion
2550    /// crate's `dep_into_ref` two-arm projection into the `CaixaSource`
2551    /// `{repo, git_ref}` pair the K8s-CR side consumes
2552    /// (`caixa-crd/src/conversion.rs`), and — through the paired
2553    /// resolver-side default-fill's `Option::unwrap_or_else` — every
2554    /// `caixa-feira` / `caixa-resolver` fetch site that requires a
2555    /// concrete `DepSource` at run time.
2556    ///
2557    /// Prior to this lift the `.fonte` typed slot was read inline at
2558    /// every production site — the [`Self::validate`]
2559    /// `if let Some(ref fonte) = self.fonte` bracket the per-`:fonte`
2560    /// gate delegates through, the caixa-crd `dep_into_ref`
2561    /// `d.fonte.as_ref().and_then(...)` two-arm `CaixaSource` projector,
2562    /// the resolver-side `caixa-feira/src/cmd/lock.rs` / `caixa-resolver/src/resolve.rs`
2563    /// `dep.fonte.clone().unwrap_or_else(...)` default-fill pair — open-
2564    /// coded field-accesses that expressed no compile-time link back to
2565    /// the typed slot. A future extension of the `:deps :fonte` axis
2566    /// to a richer author surface (a per-scope source-override table
2567    /// the resolver folds through the `~/.config/caixa/config.yaml`
2568    /// entry the [`Dep`] docstring already acknowledges, a per-org
2569    /// mirror-fallback list the future M4 lacre-federation resolver
2570    /// consults ahead of the `default_github` fallback, a promotion of
2571    /// the plain `Option<DepSource>` to a richer
2572    /// `{primary, mirrors, integrity}` triple once cross-registry
2573    /// federation lands, a per-dep `sri:sha256-…` integrity slot the
2574    /// M4 lacre gate binds against ahead of the git-fetch) would have
2575    /// had to be threaded through every open-coded copy in lockstep or
2576    /// two consumers would silently disagree on which fetch source a
2577    /// given dep resolves to — the [`Self::validate`] per-`:fonte`
2578    /// gate reading the author-declared source while the caixa-crd
2579    /// projector read a per-scope-override-resolved source would
2580    /// silently split the build-time refusal from the CR the
2581    /// substrate's admission pipeline actually materializes, one
2582    /// build-time diagnostic disagreeing with the run-time closure.
2583    /// Lifting the resolution rule to a typed method on the substrate
2584    /// primitive means every downstream consumer of the caixa's per-
2585    /// `:deps` fetch-source surface reaches for exactly one typed
2586    /// dispatch — the resolver's accept-set migrates as a unit on any
2587    /// future axis addition.
2588    ///
2589    /// First outer-`Dep` `Option<&Composite>`-return composite-reference
2590    /// accessor — opens the outer-`Dep` `Option<&Composite>` composite-
2591    /// reference projection pattern the sibling per-`Dep` `:opcional`
2592    /// (`Option<Copy>` — the plain-bool axis) / `:caracteristicas`
2593    /// (`&[String]` — the feature-flag list) future outer scalar / slice
2594    /// lifts fold on. Peer of the outer-top-level [`crate::Caixa`]
2595    /// `Option<&Composite>` composite-reference sub-family the
2596    /// [`crate::Caixa::limits`] (b2bd9d7) / [`crate::Caixa::behavior`]
2597    /// (35d8b52) / [`crate::Caixa::politicas`] (5d23d29) /
2598    /// [`crate::Caixa::placement`] (4fb8074) / [`crate::Caixa::entrada`]
2599    /// (e4128e4) accessors already close on the outer [`crate::Caixa`]
2600    /// altitude, and of the outer M3 mesh-slot [`crate::AplicacaoSpec`]
2601    /// altitude the sibling [`crate::AplicacaoSpec::entrada`] (d32111c)
2602    /// accessor already carries — extends that "one typed dispatch on
2603    /// the substrate primitive, thin projections at each consumer"
2604    /// discipline onto the third outer typed-slot altitude that carries
2605    /// an `Option<Composite>` axis (`Dep`, the outer per-dep-list-entry
2606    /// slot). Returns `Option<&DepSource>` (not the owning composite by
2607    /// copy or clone) because every downstream consumer of the fonte
2608    /// composite treats it as a read-only per-arm dispatch source — the
2609    /// reference-view is the narrowest borrow that supports every
2610    /// present + roadmapped consumer (per-arm match projection at the
2611    /// caixa-crd `CaixaSource` two-arm emitter, presence-probe early
2612    /// return on the "author-omitted `:fonte` ⇒ resolver-side
2613    /// `default_github` fill applies" partition every resolver
2614    /// consults, `.cloned()`-on-demand for the two resolver-side
2615    /// default-fill call sites that require an owned `DepSource` for
2616    /// `Option::unwrap_or_else`) without cloning the composite through
2617    /// every consumer's fast path. The `Option` half of the return-type
2618    /// preserves the load-bearing "author-omitted `:fonte` ⇒ resolver-
2619    /// side default applies" partition (not a default composite the
2620    /// downstream must reject on emptiness) — the accessor projects the
2621    /// raw `Option<DepSource>` slot's presence bit through the
2622    /// reference-return unchanged. Named `fonte()` to match the storage
2623    /// field's name verbatim and the tatara-lisp author-surface term
2624    /// (`:fonte`) the field's own docstring already carries.
2625    ///
2626    /// Declared `pub const fn` — the body projects through
2627    /// `Option::<DepSource>::as_ref`, const-stable since Rust 1.83 and
2628    /// well within the workspace MSRV, so every downstream `const`-
2629    /// context consumer of the per-`Dep` `:fonte` composite-reference
2630    /// accessor reaches through the same typed dispatch on the
2631    /// substrate primitive at const-eval time as at runtime. The
2632    /// paired [`dep_outer_accessor_family_is_const_fn`][pin] pin
2633    /// (a `const fn <name>_via_const_fn(d: &Dep) -> …` wrapper family
2634    /// that forwards through each lifted accessor) locks the posture
2635    /// load-bearing at caixa-core build time — any future accidental
2636    /// downgrade to non-`const` fails the wrapper with E0015
2637    /// (`cannot call non-const method`), strictly stronger than a
2638    /// runtime `assert!` and side-stepping the destructor-in-const
2639    /// restriction the `Dep` fixture's `String` / `Option<DepSource>`
2640    /// / `Vec<String>` carriers rule out. Peer of the sibling per-
2641    /// `WitContract` pre-projection accessor family's `const`-eval-
2642    /// surface pass (279823b) and of the outer-`Caixa` slice-return
2643    /// accessor family's parallel pass (231a968) — same "one canonical
2644    /// dispatch per axis, `const`-eval posture pinned at the substrate
2645    /// primitive, thin projections at each consumer" discipline
2646    /// extended onto the outer per-dep-list-entry [`Dep`] altitude.
2647    ///
2648    /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2649    #[must_use]
2650    pub const fn fonte(&self) -> Option<&DepSource> {
2651        self.fonte.as_ref()
2652    }
2653
2654    /// Substrate-canonical per-`:deps` / `:deps-dev` entry
2655    /// `:caracteristicas` Cargo-shaped feature-toggle-set slice accessor
2656    /// every consumer of the dep-graph feature-flag axis keys off —
2657    /// returns the author-declared `:caracteristicas` feature-name list
2658    /// verbatim as a `&[String]` slice-view over the same backing buffer
2659    /// the raw `self.caracteristicas.as_slice()` field access borrows
2660    /// from. Empty-list-carrying (`:caracteristicas` is a default-empty
2661    /// axis every `Dep` supplies with `Vec::new()` when the author omits
2662    /// the slot; the [`crate::Caixa::from_lisp`] derive folds an omitted
2663    /// `:caracteristicas` through `#[serde(default)]` to `Vec::new()`,
2664    /// so a `Dep` past parse definitionally carries a `Vec<String>` slot
2665    /// — possibly empty — and the returned `&[String]` degenerates to
2666    /// an empty slice on that arm without any silent `None` collapse).
2667    ///
2668    /// The `:deps :caracteristicas` / `:deps-dev :caracteristicas` slot
2669    /// carries the set-shaped feature-toggle list the substrate walks
2670    /// through the [`Self::validate_caracteristicas`] per-entry shape +
2671    /// duplicate cascade — same Cargo `[dependencies.<dep>.features]`
2672    /// accept-set (per-entry Cargo-feature-name grammar via the shared
2673    /// [`crate::render::is_cargo_feature_name`] predicate, cross-entry
2674    /// uniqueness via the shared [`crate::render::insert_first_seen`]
2675    /// walk, empty-first / value-shape-second / duplicate-third
2676    /// precedence via the peer per-axis two-arm cascade discipline every
2677    /// substrate-blessed Vec-keyed-by-name slot already follows).
2678    /// Every downstream consumer that fans on the dep's feature-toggle
2679    /// keys off this accessor: [`Self::validate_caracteristicas`]'s
2680    /// per-entry linear walk that gates each feature-name byte-string
2681    /// through the empty / value-shape / duplicate arms (raising the
2682    /// [`DepError::CaracteristicaEmpty`] / [`DepError::CaracteristicaInvalid`]
2683    /// / [`DepError::CaracteristicaDuplicate`] carrier family naming the
2684    /// offending `Dep::nome`), and every future
2685    /// per-`Caixa`-manifest / caixa-resolver / caixa-crd feature-toggle-
2686    /// facing consumer the CAIXA-SDLC §I roadmap acknowledges (the
2687    /// future caixa-resolver per-dep feature-projection walk that folds
2688    /// the toggle set into the resolved [`crate::Caixa`]'s activated
2689    /// [`crate::render::CARGO_FEATURE_NAME_MAX_LEN`]-bounded feature
2690    /// closure ahead of the lacre hash, the future caixa-crd per-`spec.deps`
2691    /// features slice the K8s-CR admission gate consumes, the future
2692    /// per-cluster feature-overlay the M4 lacre-federation resolver
2693    /// composes ahead of the substrate-wide feature-name accept-set).
2694    ///
2695    /// Prior to this lift the `.caracteristicas` byte-string list was
2696    /// read inline at the [`Self::validate_caracteristicas`] `for c in
2697    /// &self.caracteristicas` walk — the only in-crate consumer of the
2698    /// raw field beyond the per-`Dep` constructor pair
2699    /// ([`Self::simple`] / [`Self::git`]) and the paired serde
2700    /// round-trip / per-test fixture-mutation paths — an open-coded
2701    /// field-access that expressed no compile-time link back to the
2702    /// typed slot. A future extension of the `:caracteristicas` axis to
2703    /// a richer author surface (a per-scope feature-overlay the resolver
2704    /// folds through the `~/.config/caixa/config.yaml` entry the
2705    /// [`Dep`] docstring already acknowledges, a per-cluster feature-
2706    /// activation overlay the future M4 lacre-federation layer applies
2707    /// per-CR, a promotion of the plain `Vec<String>` byte-string list
2708    /// to a richer parsed-feature-set newtype once the Cargo-shaped
2709    /// namespaced-dep `dep/feat` syntax the value-shape gate's
2710    /// docstring anticipates lands) would have had to be threaded
2711    /// through every open-coded copy in lockstep or two consumers
2712    /// would silently disagree on which feature closure a given dep
2713    /// activates — the [`Self::validate_caracteristicas`] gate walking
2714    /// the author-declared list while a downstream caixa-resolver
2715    /// consumer walked a per-scope-override-resolved list would
2716    /// silently split the build-time refusal from the lacre closure
2717    /// the substrate's fetch pipeline actually materializes, one
2718    /// build-time diagnostic disagreeing with the run-time closure.
2719    /// Lifting the resolution rule to a typed method on the substrate
2720    /// primitive means every downstream consumer of the caixa's per-
2721    /// `:deps` feature-toggle surface reaches for exactly one typed
2722    /// dispatch — the resolver's accept-set migrates as a unit on any
2723    /// future axis addition.
2724    ///
2725    /// First outer-`Dep` `&[T]`-return slice accessor — opens the
2726    /// outer-`Dep` `&[String]` slice projection pattern the sibling
2727    /// per-`Dep` `:opcional` (`bool` — the plain-`Copy`-scalar axis)
2728    /// future outer scalar lift folds on and closes the outer-`Dep`
2729    /// slot-family the sibling [`Self::nome`] (eba2cde) /
2730    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2731    /// accessors already open, leaving the `:opcional` `Copy`-scalar arm
2732    /// as the sole remaining unlifted outer-`Dep` slot. Peer of the
2733    /// outer top-level [`crate::Caixa`] `&[String]`-return foreign-code-
2734    /// slot sub-family ([`crate::Caixa::bibliotecas`] 8a36c23,
2735    /// [`crate::Caixa::exe`] 65d9527, [`crate::Caixa::servicos`]
2736    /// 611f78b) and the outer top-level [`crate::Caixa`] universal-axis
2737    /// text-tag family ([`crate::Caixa::autores`] b5d813f,
2738    /// [`crate::Caixa::etiquetas`] 78c7d3c) that already carry the
2739    /// `&[String]` slice-projection discipline on the outer-`Caixa`
2740    /// altitude — extends the "one typed dispatch on the substrate
2741    /// primitive, thin projections at each consumer" discipline onto the
2742    /// outer per-dep-list-entry [`Dep`] altitude's set-shaped byte-
2743    /// string list slot. Returns `&[String]` (not `&Vec<String>`)
2744    /// because every downstream consumer of the feature-toggle list
2745    /// treats it as a read-only sequence — the slice-view is the
2746    /// narrowest borrow that supports every present + roadmapped
2747    /// consumer (`.iter()`, `.len()`, `.is_empty()`) without leaking
2748    /// the backing `Vec`'s grow/push/reserve surface no consumer of
2749    /// the typed view reaches for (the storage-side `Vec` remains
2750    /// reachable through the `pub caracteristicas` field for the
2751    /// mutation-carrying serde round-trip and per-test fixture-mutation
2752    /// paths). Named `caracteristicas()` to match the storage field's
2753    /// name verbatim and the tatara-lisp author-surface term
2754    /// (`:caracteristicas`) the field's own docstring already carries.
2755    ///
2756    /// Declared `pub const fn` — the body projects through
2757    /// `Vec::<String>::as_slice`, const-stable since Rust 1.83 and
2758    /// well within the workspace MSRV, so every downstream `const`-
2759    /// context consumer of the per-`Dep` `:caracteristicas` slice-
2760    /// accessor reaches through the same typed dispatch on the
2761    /// substrate primitive at const-eval time as at runtime. Pinned
2762    /// load-bearing by the paired
2763    /// [`dep_outer_accessor_family_is_const_fn`][pin] wrapper family
2764    /// alongside its sibling [`Self::fonte`] — see [`Self::fonte`] for
2765    /// the full pin-shape rationale.
2766    ///
2767    /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2768    #[must_use]
2769    pub const fn caracteristicas(&self) -> &[String] {
2770        self.caracteristicas.as_slice()
2771    }
2772
2773    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:opcional`
2774    /// missing-source-tolerance flag scalar accessor every consumer of
2775    /// the dep-graph opt-in-fetch axis keys off — returns the author-
2776    /// declared `:opcional` `bool` verbatim, `Copy`-projected from the
2777    /// typed slot's own `bool` storage (no borrow of `&self` past the
2778    /// call; the `Copy`-return arm matches the peer
2779    /// [`crate::Caixa::max_restarts`] (eba5211) `Option<u32>` `Copy`-
2780    /// projected sibling discipline the outer flat-spread family
2781    /// already carries). Default-`false` (`#[serde(default,
2782    /// skip_serializing_if = "is_false")]` on the storage slot, so a
2783    /// `Dep` past parse definitionally carries a `bool` — `false` when
2784    /// the author omits `:opcional` — and the returned value degenerates
2785    /// to `false` on that arm without any silent `None` collapse).
2786    ///
2787    /// The `:deps :opcional` / `:deps-dev :opcional` slot carries the
2788    /// per-entry "if this dep's `:fonte` cannot be resolved, treat the
2789    /// missing-source arm as a soft-fail rather than a build refusal"
2790    /// bit — the same Cargo-shaped `[dependencies.<dep>.optional = true]`
2791    /// accept-set (an opcional dep whose `:fonte` fails to resolve is
2792    /// dropped from the resolved dep-graph rather than tripping the
2793    /// build-refusal edge that a mandatory `:opcional false` entry
2794    /// would). Every downstream consumer that fans on the dep's
2795    /// missing-source-tolerance keys off this accessor: the future
2796    /// caixa-resolver's per-`:fonte` resolve-fail arm (drop-vs-error
2797    /// dispatch on the opcional bit ahead of the lacre closure
2798    /// materialization), the future caixa-crd per-`spec.deps`
2799    /// `optional` boolean the K8s-CR admission gate consumes on the
2800    /// per-dep partition, and the future feira / caixa-resolver /
2801    /// caixa-crd feature-projection walk that folds the opcional bit
2802    /// into the resolved feature-closure the future M4 lacre-federation
2803    /// layer emits.
2804    ///
2805    /// Prior to this lift the `.opcional` `bool` slot was read inline
2806    /// at the sole in-crate consumer site — the tests-module
2807    /// `registry_dep_is_minimal` fixture's `assert!(!d.opcional)` gate
2808    /// pinning the [`Self::simple`] constructor's default-`false` fill
2809    /// (the only in-crate read of the raw field beyond the per-`Dep`
2810    /// constructor pair [`Self::simple`] / [`Self::git`] and the paired
2811    /// serde round-trip / per-test fixture-mutation paths) — an open-
2812    /// coded field-access that expressed no compile-time link back to
2813    /// the typed slot. A future extension of the `:opcional` axis to a
2814    /// richer author surface (a per-scope opcional-override the resolver
2815    /// folds through the `~/.config/caixa/config.yaml` entry the [`Dep`]
2816    /// docstring already acknowledges, a per-cluster opcional-override
2817    /// the future M4 lacre-federation layer applies per-CR, a promotion
2818    /// of the plain `bool` to a richer `OpcionalPolicy { drop, warn,
2819    /// error }` tri-state once the CAIXA-SDLC §II opcional-policy
2820    /// roadmap lands) would have had to be threaded through every open-
2821    /// coded copy in lockstep or two consumers would silently disagree
2822    /// on which missing-source arm a given dep resolves to — the
2823    /// [`Self::simple`] constructor's default-`false` fill reading
2824    /// verbatim while a downstream caixa-resolver consumer read a per-
2825    /// scope-override-resolved bit would silently split the build-time
2826    /// arm from the lacre closure the substrate's fetch pipeline
2827    /// actually materializes, one build-time diagnostic disagreeing
2828    /// with the run-time closure. Lifting the resolution rule to a
2829    /// typed method on the substrate primitive means every downstream
2830    /// consumer of the caixa's per-`:deps` opcional-tolerance surface
2831    /// reaches for exactly one typed dispatch — the resolver's accept-
2832    /// set migrates as a unit on any future axis addition.
2833    ///
2834    /// Fifth and final outer-`Dep` accessor — closes the outer-`Dep`
2835    /// slot-family the sibling per-`Dep` [`Self::nome`] (eba2cde) /
2836    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2837    /// / [`Self::caracteristicas`] (9197944) accessors opened, so every
2838    /// outer-`Dep` slot (`:nome`, `:versao`, `:fonte`, `:opcional`,
2839    /// `:caracteristicas`) now routes through exactly one typed
2840    /// dispatch on the substrate primitive. First outer-`Dep`
2841    /// `bool`-return / plain-`Copy`-scalar accessor — opens the
2842    /// outer-`Dep` `Copy`-scalar projection pattern that folds on the
2843    /// peer outer-top-level [`crate::Caixa`] `Option<Copy>`
2844    /// flat-spread sub-family ([`crate::Caixa::max_restarts`] eba5211,
2845    /// [`crate::Caixa::estrategia`] ed04d3c) the outer-`Caixa` altitude
2846    /// already carries — extends the "one typed dispatch on the
2847    /// substrate primitive, thin projections at each consumer"
2848    /// discipline onto the outer per-dep-list-entry [`Dep`] altitude's
2849    /// bool-shaped missing-source-tolerance slot. Returns `bool` by
2850    /// `Copy` (not by `&bool` reference) because `bool` is `Copy` and
2851    /// every downstream consumer treats it as a plain discriminant
2852    /// value — the by-value return is the narrowest return-shape that
2853    /// supports every present + roadmapped consumer (`.then(…)` early
2854    /// return on the resolver-side drop-vs-error partition, direct
2855    /// bool composition with a per-scope-override projector, plain
2856    /// `if dep.opcional() { … }` early return at every future admission
2857    /// gate) without leaking the storage field's `bool`-in-`&self`
2858    /// lifetime the by-value return elides. Marked `pub const fn` so
2859    /// the accessor is `const`-callable — same discipline the peer
2860    /// [`crate::Caixa::max_restarts`] `Option<u32>` `Copy`-return
2861    /// accessor carries. Named `opcional()` to match the storage
2862    /// field's name verbatim and the tatara-lisp author-surface term
2863    /// (`:opcional`) the field's own docstring already carries.
2864    #[must_use]
2865    pub const fn opcional(&self) -> bool {
2866        self.opcional
2867    }
2868
2869    /// Build a minimal registry-sourced dep.
2870    #[must_use]
2871    pub fn simple(nome: impl Into<String>, versao: impl Into<String>) -> Self {
2872        Self {
2873            nome: nome.into(),
2874            versao: versao.into(),
2875            fonte: None,
2876            opcional: false,
2877            caracteristicas: Vec::new(),
2878        }
2879    }
2880
2881    /// Build a Git-sourced dep (tag-based).
2882    #[must_use]
2883    pub fn git(
2884        nome: impl Into<String>,
2885        versao: impl Into<String>,
2886        repo: impl Into<String>,
2887        tag: impl Into<String>,
2888    ) -> Self {
2889        Self {
2890            nome: nome.into(),
2891            versao: versao.into(),
2892            fonte: Some(DepSource::Git {
2893                repo: repo.into(),
2894                tag: Some(tag.into()),
2895                rev: None,
2896                branch: None,
2897            }),
2898            opcional: false,
2899            caracteristicas: Vec::new(),
2900        }
2901    }
2902
2903    /// Reject dependency entries whose `:nome` or `:versao` are empty,
2904    /// whose `:nome` is non-empty but not a valid DNS-1123 label,
2905    /// or whose `:versao` is non-empty but not a valid Cargo-shaped
2906    /// semver requirement.
2907    ///
2908    /// The author surface for `:deps :versao` (and `:deps-dev :versao`)
2909    /// is the same Cargo-shaped requirement string `:membros :versao`
2910    /// (validated at [`crate::AplicacaoSpec::validate`] since 9888b13)
2911    /// and `:children :versao` (validated at
2912    /// [`crate::SupervisorSpec::validate`] since b38ff3a) carry — and
2913    /// the lacre pipeline resolves all three axes through the same
2914    /// [`crate::parse_requirement`] entry-point. Until 2420c44 landed
2915    /// `:deps :versao` was the last `:versao` axis untyped past
2916    /// `Caixa::from_lisp`: a malformed-but-non-empty requirement
2917    /// (`"^bad-version"`, `"^^0.1"`, the canonical git-tag-shape-
2918    /// leaking-into-:versao `"v0.1"` typo, the accidental
2919    /// `"not-a-req"`) silently passed parse and the `semver::Error`
2920    /// surfaced at lacre-resolve time, far from the source
2921    /// caixa.lisp, with no field naming which `:deps` entry carried
2922    /// the typo. The diagnostic [`DepError::VersaoInvalid`] carries
2923    /// the offending entry's `:nome` + the offending `:versao`
2924    /// verbatim + the parser's own wording in `reason`, so the
2925    /// author's grep target is unambiguous.
2926    ///
2927    /// The author surface for `:deps :nome` is the same DNS-1123 label
2928    /// the peer caixa-identifier axes carry — top-level Caixa `:nome`
2929    /// (validated at [`crate::Caixa::validate_nome`] since 6c992f8),
2930    /// `:membros :caixa` (validated at
2931    /// [`crate::AplicacaoSpec::validate_membros`] since 3f9d7a0),
2932    /// `:children :caixa` (validated at
2933    /// [`crate::SupervisorSpec::validate`] since 31bfa43). A `:deps
2934    /// :nome` value flows verbatim through the lacre pipeline as the
2935    /// target caixa's `:nome` (which the gate at the *target* side now
2936    /// rejects if non-DNS-1123) and lands as the rendered caixa's
2937    /// `lareira-<nome>` Helm chart name segment, the per-dep
2938    /// `LABEL_PROGRAM` label value, and the `caixa-resolver`'s
2939    /// `~/.cache/caixa/<org>/<nome>` checkout-directory leaf. Until
2940    /// this gate landed `:deps :nome` was the fourth and last
2941    /// DNS-1123-shaped caixa-identifier axis still untyped past
2942    /// `Caixa::from_lisp`: a syntactically wrong dep name (`"Caixa-
2943    /// Teia"` uppercase — the canonical "I copied the README header"
2944    /// typo; `"caixa_teia"` underscore — the Go module / Python
2945    /// identifier leak; `"caixa-teia."` trailing dot — the FQDN
2946    /// confusion; `"-caixa-teia"` leading hyphen; a 64-byte slug)
2947    /// silently passed parse and surfaced at lacre-resolve time when
2948    /// the resolved target caixa's `:nome` failed *its* DNS-1123 gate
2949    /// — far from the source `:deps` entry, with a diagnostic naming
2950    /// the *target's* `:nome` rather than the dep entry that referenced
2951    /// it. Mirroring the 3f9d7a0 / 31bfa43 / 6c992f8 trajectory through
2952    /// the lifted [`crate::render::is_dns_1123_label`] predicate (the
2953    /// "before its third occurrence" PRIME DIRECTIVE boundary, THEORY.md
2954    /// §I.3.5): every `Dep::nome` past validate is DNS-1123-label-shaped,
2955    /// so every downstream consumer (caixa-resolver's lacre fetch,
2956    /// caixa-helm's `lareira-<nome>` chart name, the future M4 per-dep
2957    /// fan-out emitter) reaches for the name knowing the value is
2958    /// apiserver-valid without re-validating.
2959    ///
2960    /// Empty checks fire first (narrower diagnostic), parse last —
2961    /// same ordering discipline as
2962    /// [`crate::AplicacaoSpec::validate_membros`] and
2963    /// [`crate::SupervisorSpec::validate`]. `parse_requirement("")`
2964    /// returns `Ok(VersionReq::STAR)`, so the empty-`:versao` arm is
2965    /// structurally necessary even with the parse arm in place. The
2966    /// `:nome` shape gate runs after the `:nome` empty gate and before
2967    /// the `:versao` checks so a one-entry caixa.lisp with both wrong
2968    /// sees the name-side diagnostic first (the name is the
2969    /// self-locating axis — without it, the parse diagnostic can't
2970    /// quote `:nome "<bad>"`).
2971    pub fn validate(&self) -> Result<(), DepError> {
2972        if self.nome.is_empty() {
2973            return Err(DepError::NomeEmpty);
2974        }
2975        if let Err(reason) = crate::render::is_dns_1123_label(&self.nome) {
2976            return Err(DepError::nome_invalid(&self.nome, reason));
2977        }
2978        // Delegate the empty-first + `parse_requirement` cascade to the
2979        // shared [`crate::render::require_valid_versao_requirement`]
2980        // helper — same two-arm shape the peer
2981        // [`crate::AplicacaoSpec::validate_membros`] on `:membros
2982        // :versao` and [`crate::SupervisorSpec::validate`] on `:children
2983        // :versao` route through, so drift between the three axes'
2984        // accepted requirement sets is structurally impossible and the
2985        // parse-side no-op the empty-first arm closes (semver's empty
2986        // parse yields an implicit `*`) lives in exactly one predicate.
2987        crate::render::require_valid_versao_requirement(
2988            self.versao_requirement(),
2989            || DepError::versao_empty(&self.nome),
2990            |reason| DepError::versao_invalid(&self.nome, self.versao_requirement(), reason),
2991        )?;
2992        if let Some(fonte) = self.fonte() {
2993            fonte.validate(&self.nome)?;
2994        }
2995        self.validate_caracteristicas()?;
2996        Ok(())
2997    }
2998
2999    /// Reject per-entry `:caracteristicas` (feature-flag) values that
3000    /// are operationally meaningless. The `:caracteristicas` slot is
3001    /// a set of feature toggles to enable on the target caixa — same
3002    /// shape as Cargo's `[dependencies.<dep>.features]` list — and
3003    /// two structural footguns close here:
3004    ///
3005    ///   - empty-string entry (`(:caracteristicas (""))`): the future
3006    ///     caixa-resolver lacre pipeline would consume the empty
3007    ///     identifier as a no-op feature enable, silently dropping the
3008    ///     author's intent far from the source `caixa.lisp`;
3009    ///   - duplicate entry within one dep (`(:caracteristicas ("http"
3010    ///     "http"))`): the feature-toggle slot is set-shaped (enabling
3011    ///     a feature twice has no additional semantic — there is no
3012    ///     `feature × 2`), so two entries naming the same feature are
3013    ///     a silent miscount, the same set-not-multiset distinction
3014    ///     every peer Vec-keyed-by-name axis already closes
3015    ///     ([`crate::SupervisorError::DuplicateChildCaixa`] on
3016    ///     `:children :caixa`, [`crate::AplicacaoError::MembroDuplicate`]
3017    ///     on `:membros :caixa`, [`crate::AplicacaoError::ContratoDuplicate`]
3018    ///     on `:contratos`, [`crate::AplicacaoError::PlacementClusterDuplicate`]
3019    ///     on `:placement :clusters`, [`crate::AplicacaoError::EntradaPathDuplicate`]
3020    ///     on `:entrada :paths`, [`crate::UpgradeError::DuplicateFrom`]
3021    ///     on `:upgrade-from :from`, [`crate::UpgradeError::DuplicateLoadModule`]
3022    ///     / [`crate::UpgradeError::DuplicateStateChange`] /
3023    ///     [`crate::UpgradeError::DuplicateCleanup`] on the within-
3024    ///     entry `:upgrade-from` axes, and [`DepError::DuplicateNome`]
3025    ///     on the cross-entry `:deps`/`:deps-dev` `:nome` axis the
3026    ///     immediate-predecessor 359fba5 closed).
3027    ///
3028    /// Same linear-walk + `HashSet` + first-collision diagnostic shape
3029    /// every peer set-not-multiset gate uses; the empty arm fires
3030    /// before the duplicate arm so an entry with both an empty feature
3031    /// *and* a duplicate of some later feature surfaces the empty-
3032    /// shape diagnostic first (the empty-feature axis is the
3033    /// more-actionable defect since the missing-name renders the
3034    /// duplicate-key arm ambiguous: two `""` entries would both report
3035    /// `caracteristica: ""` with no way to distinguish the offending
3036    /// site). Empty-first cascade discipline mirrors every peer per-
3037    /// entry shape + duplicate gate
3038    /// (`SupervisorSpec::validate`'s `EmptyChildName` before
3039    /// `DuplicateChildCaixa`; `validate_membros`'s `MembroCaixaEmpty`
3040    /// before `MembroDuplicate`).
3041    ///
3042    /// The per-entry value-shape gate (Cargo-feature-name grammar via
3043    /// the lifted [`crate::render::is_cargo_feature_name`] predicate)
3044    /// fires between the empty arm and the duplicate arm — the
3045    /// canonical per-entry-shape-before-cross-entry-uniqueness
3046    /// precedence every peer two-arm + value-shape gate establishes
3047    /// ([`crate::SupervisorSpec::validate`]'s `EmptyChildName` →
3048    /// `ChildCaixaInvalid` → `DuplicateChildCaixa`,
3049    /// [`crate::AplicacaoSpec::validate_membros`]'s `MembroCaixaEmpty`
3050    /// → `MembroCaixaInvalid` → `MembroDuplicate`, [`Dep::validate`]'s
3051    /// `NomeEmpty` → `NomeInvalid` → cross-list `DuplicateNome`).
3052    /// Until the value-shape arm landed `:caracteristicas` accepted
3053    /// every non-empty distinct string — a structurally invalid
3054    /// feature name (`"http feature"` whitespace, `"+http"` the
3055    /// canonical paste-from-`+optional-feature` doc activation-form
3056    /// footgun, `"-flag"` leading hyphen, `".feat"` leading dot,
3057    /// `"http/json"` Cargo's `dep/feat` namespaced-dep syntax that
3058    /// only applies inside list-grammar contexts, `"http,json"`
3059    /// list-separator-belongs-to-the-list-grammar miscomprehension,
3060    /// `"café"` un-percent-encoded non-ASCII silently round-tripping
3061    /// inconsistently across NFC/NFD normalization, the 65-byte
3062    /// paste-from-binary slug) silently passed validate and the
3063    /// failure surfaced at `cargo metadata` time as the
3064    /// `restricted_names::validate_feature_name` parser's rejection,
3065    /// far from the source `caixa.lisp`, with no field naming which
3066    /// `:deps` entry's `:caracteristicas` carried the typo. The
3067    /// lifted predicate makes the Cargo-feature-name-grammar
3068    /// intersection-floor a substrate-level invariant at validate
3069    /// time — same trajectory as the eight peer
3070    /// [`crate::render`] value-shape predicates each typed surface
3071    /// downstream of a structured grammar already follows
3072    /// ([`is_dns_1123_label`](crate::render::is_dns_1123_label),
3073    /// [`is_gateway_api_http_path`](crate::render::is_gateway_api_http_path),
3074    /// [`is_wit_world_ref`](crate::render::is_wit_world_ref),
3075    /// [`is_nats_subject`](crate::render::is_nats_subject),
3076    /// [`is_wasi_keyvalue_slot`](crate::render::is_wasi_keyvalue_slot),
3077    /// [`is_git_ref_name`](crate::render::is_git_ref_name),
3078    /// [`is_git_oid`](crate::render::is_git_oid),
3079    /// [`is_git_repo_url`](crate::render::is_git_repo_url)).
3080    fn validate_caracteristicas(&self) -> Result<(), DepError> {
3081        let mut seen = std::collections::HashSet::new();
3082        for c in self.caracteristicas() {
3083            if c.is_empty() {
3084                return Err(DepError::caracteristica_empty(&self.nome));
3085            }
3086            if let Err(reason) = crate::render::is_cargo_feature_name(c) {
3087                return Err(DepError::caracteristica_invalid(&self.nome, c, reason));
3088            }
3089            crate::render::insert_first_seen(&mut seen, c.as_str(), || {
3090                DepError::caracteristica_duplicate(&self.nome, c)
3091            })?;
3092        }
3093        Ok(())
3094    }
3095}
3096
3097/// Cross-slot coherence gate on the dep-graph axis: no `:deps` or
3098/// `:deps-dev` entry may name the caixa's own `:nome`.
3099///
3100/// A caixa that lists itself as a dep is a degenerate self-edge in the
3101/// lacre closure's dep-graph — the closure is a DAG rooted at the
3102/// caixa's `:nome`, and the caixa-resolver's lacre pipeline traverses
3103/// every `:deps` / `:deps-dev` entry's target by name. A self-dep
3104/// hands the resolver a node that is its own parent: a one-node cycle
3105/// it either rejects mid-traversal far from the source `caixa.lisp`
3106/// (the resolver detecting infinite recursion on the closure walk) or,
3107/// worse, recurses on until it exhausts its stack. Because every
3108/// `:nome` is a globally-unique substrate identity (DNS-1123 label +
3109/// lacre closure root), a dep entry whose `:nome` equals the caixa's
3110/// own `:nome` *is* the caixa itself, not a coincidentally-named peer.
3111///
3112/// Lives outside [`Caixa::validate_deps`] because the dep-list view
3113/// carries the entries but not the parent `:nome`; mirrors the
3114/// cross-slot self-edge gates [`crate::supervisor::validate_no_self_supervision`]
3115/// (ad4abf1) on the `:children :caixa` axis and
3116/// [`crate::aplicacao::validate_no_self_membership`] on the
3117/// `:membros :caixa` axis — the same "an edge from a graph node to
3118/// itself is structurally not a tree/graph edge" discipline, here on
3119/// the third typed-name-graph axis (the dep closure; the supervision
3120/// tree and the Aplicacao membership set were the prior two).
3121///
3122/// Walks `:deps` first then `:deps-dev` so the diagnostic for a caixa
3123/// that self-references on both axes surfaces the `:deps` arm first —
3124/// the load-bearing axis the lacre closure resolves at every build,
3125/// peer with the canonical [`Caixa::validate_deps`] walk order
3126/// (`:deps` → `:deps-dev`).
3127///
3128/// Carries the offending list tag (`":deps"` or `":deps-dev"`)
3129/// verbatim into the diagnostic so the author can grep their
3130/// `caixa.lisp` for the offending block in one edit — same
3131/// `list: &'static str` shape [`DepError::DuplicateNome`] (359fba5)
3132/// uses on the cross-list duplicate-name axis.
3133///
3134/// `Code paths` (`:bibliotecas` / `:exe` / `:servicos`) are the
3135/// substrate-blessed shape for referencing the caixa's *own* code, so
3136/// the diagnostic names them as the corrective surface — every
3137/// legitimate "I want to use code from this caixa" authoring intent
3138/// routes through one of those three slots, not a self-dep.
3139pub fn validate_no_self_dep(
3140    deps: &[Dep],
3141    deps_dev: &[Dep],
3142    parent_nome: &str,
3143) -> Result<(), DepError> {
3144    for dep in deps {
3145        if dep.nome() == parent_nome {
3146            return Err(DepError::dep_is_self(
3147                parent_nome,
3148                crate::render::DEP_AUTHOR_KEY_DEPS,
3149            ));
3150        }
3151    }
3152    for dep in deps_dev {
3153        if dep.nome() == parent_nome {
3154            return Err(DepError::dep_is_self(
3155                parent_nome,
3156                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3157            ));
3158        }
3159    }
3160    Ok(())
3161}
3162
3163/// Closed-set typed enum for the two dep-list author-surface axes every
3164/// top-level [`crate::Caixa`] carries — the runtime-closure `:deps` slot
3165/// (`Prod`) and the dev-only-closure `:deps-dev` slot (`Dev`). Every
3166/// substrate consumer that dispatches on "which of the two dep-lists"
3167/// (the `feira add` mutation head, the future per-cluster dev-closure-
3168/// audit overlay the M4 CR materializer resolves per-CR, the future
3169/// `caixa app graph` per-list dep summary, every future
3170/// `Caixa::push_dep` / `Caixa::deps_by_list` typed-method dispatch a
3171/// caller reaches for) reads through this enum rather than through a
3172/// bare `&'static str` — the closed-set is expressed at the type layer,
3173/// so a future third dep-list axis (a `:deps-build` build-only closure
3174/// once the substrate grows cross-artifact heterogeneous dep-graphs,
3175/// per CAIXA-SDLC §I) is one variant plus one arm per method and the
3176/// compiler enforces exhaustiveness on every consumer's `match` arms.
3177///
3178/// The wire byte-string [`Self::as_str`] returns is the same author-
3179/// surface tag the sibling [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3180/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry — the
3181/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] `list:
3182/// &'static str` payload family the substrate already emits routes
3183/// through the same source of truth (an author reading a
3184/// [`DepError::DuplicateNome`] refusal can grep their `caixa.lisp`
3185/// for the offending `:deps` / `:deps-dev` block in one edit whether
3186/// the diagnostic came from a `Caixa::validate_deps` walk or a
3187/// `Caixa::push_dep` mutation).
3188///
3189/// Same "closed-set typed-enum discriminator with canonical
3190/// projections per axis" discipline the sibling closed-set typed enums
3191/// on the caixa typed surface carry
3192/// ([`crate::aplicacao::PlacementStrategy`] cc8f749,
3193/// [`crate::aplicacao::RateLimitUnit`] 6bce03d,
3194/// [`crate::supervisor::RestartStrategy`],
3195/// [`crate::supervisor::RestartPolicy`],
3196/// [`crate::upgrade::UpgradeInstruction`], [`crate::CaixaKind`])
3197/// — extended onto the outer-`Caixa` two-list dep-graph axis, the
3198/// substrate's last unlifted closed-set-shaped `&'static str`-carrying
3199/// axis on the top-level manifest surface.
3200#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
3201pub enum DepList {
3202    /// Runtime-closure `:deps` axis — the load-bearing dep-list the
3203    /// lacre closure resolves at every build. Wire-format
3204    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`].
3205    Prod,
3206    /// Dev-only-closure `:deps-dev` axis — Cargo's `[dev-dependencies]`
3207    /// table's dev-time-only visibility contract per CAIXA-SDLC §I.
3208    /// Wire-format [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`].
3209    Dev,
3210}
3211
3212impl DepList {
3213    /// Exhaustive iteration surface for every consumer that reads the
3214    /// full closed-set (the future M4 admission webhook's per-list
3215    /// summary rejection body, any future round-trip pin harness). A
3216    /// future variant addition extends this slice as a single edit and
3217    /// every consumer picks up the new entry by construction — the
3218    /// compiler-checked exhaustiveness on the sibling method `match`
3219    /// arms is the build-time guarantee that no arm forgets to grow.
3220    pub const ALL: &'static [Self] = &[Self::Prod, Self::Dev];
3221
3222    /// Substrate-canonical exhaustive accept-set on the [`DepList`]
3223    /// `:`-prefixed kebab-case tatara-lisp author-surface key axis —
3224    /// the closed two-arm roster of every byte-string [`Self::as_str`]
3225    /// returns, routed byte-for-byte through the paired
3226    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3227    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] lifted `pub const`
3228    /// scalars the [`Self::as_str`] emitter (and the
3229    /// [`std::fmt::Display`] / [`AsRef<str>`] / `From<{Self,&Self}> for
3230    /// {&'static str, String, Cow<'static, str>, Box<str>, Arc<str>}`
3231    /// trait triple + quintuple routed through it) walks, and the same
3232    /// two strings the paired [`Self::from_wire`] reverse projection
3233    /// accepts.
3234    ///
3235    /// Peer of the sibling [`crate::CaixaKind::WIRE_NAMES`] (bd708bd) /
3236    /// [`crate::supervisor::RestartStrategy::WIRE_NAMES`] (3033f45) /
3237    /// [`crate::supervisor::RestartPolicy::WIRE_NAMES`] (ce9412b) /
3238    /// [`crate::aplicacao::PlacementStrategy::WIRE_NAMES`] (3e5b194)
3239    /// rosters on the `PascalCase` wire byte-string axis, the sibling
3240    /// [`crate::CaixaKind::LABELS`] (427fe75) /
3241    /// [`crate::aplicacao::WitShape::LABELS`] (9d9f585) rosters on the
3242    /// lowercase kebab census-label byte-string axis, the sibling
3243    /// [`crate::aplicacao::RateLimitUnit::SUFFIXES`] (b553ec9) roster
3244    /// on the single-char canonical-suffix axis, and the sibling
3245    /// [`crate::upgrade::UpgradeInstruction::LISP_FORMS`] (1898d77) /
3246    /// [`crate::upgrade::UpgradeInstruction::WIRE_FORMS`] (cc42c0e)
3247    /// rosters on the OTP-appup discriminator's two-axis roster split
3248    /// — the same closed-set exhaustive-accept-set roster discipline
3249    /// extended here onto the outer-`Caixa` two-list dep-graph
3250    /// closed-set typed enum, the ninth substrate-side closed-set
3251    /// typed enum on the roster-discipline axis and the last unlifted
3252    /// `&'static str`-carrying closed-set typed enum on the top-level
3253    /// manifest surface (the sibling `AsRef<str>` doc block at
3254    /// [`AsRef<str>`] already names the two-list dep-graph as "the
3255    /// seventh (and last unlifted) closed-set typed enum on the caixa
3256    /// surface" for the trait-idiomatic projection family — the same
3257    /// closure applies here on the exhaustive-roster family).
3258    ///
3259    /// Downstream consumers of the closed accepted-key set — a future
3260    /// `feira dep --list <deps|deps-dev>` CLI arg-parse's "did you
3261    /// mean" hint that scans this slice rather than open-coding a
3262    /// two-string array literal, a future M4
3263    /// `mesh.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection
3264    /// body enumerating the accepted `:deps` / `:deps-dev` author-
3265    /// surface keys verbatim on an unknown-key miss, a future
3266    /// `feira dep census` per-Caixa `:deps` / `:deps-dev` histogram
3267    /// column that walks the roster to render every arm's tally
3268    /// (including zero-count arms — a hand-rolled projection off
3269    /// [`Self::ALL`] alone would need a companion per-variant-to-key
3270    /// map at every consumer; this roster closes the two-axis walk in
3271    /// one lifted const), any future K8s CRD generation tool that
3272    /// emits the accepted-key enum on the Caixa CR schema, a future
3273    /// [`DepError`] widening that promotes the two `list: &'static
3274    /// str` fields to a typed `list: DepList` carry so downstream
3275    /// consumers dispatch on the enum rather than string-comparing
3276    /// the wire scalar — every consumer that wants to enumerate the
3277    /// closed dep-list author-key set outside caixa-core now reaches
3278    /// for one lifted substrate-primitive roster rather than open-
3279    /// coding a `[":deps", ":deps-dev"]` array-literal whose arm-set
3280    /// has no compile-time link back to the typed [`DepList`] enum.
3281    /// A future arm addition (a `:build-dep` third list once the
3282    /// substrate grows Cargo-style split-graphs, a `:tool-dep` for
3283    /// build-time-only tooling per the peer Cargo
3284    /// `[build-dependencies]` / `[target.<cfg>.dev-dependencies]`
3285    /// future admission surface — both trajectory items the sibling
3286    /// [`Self::from_wire`] doc block already names) extends this
3287    /// roster as a single edit — paired with the [`Self::as_str`]
3288    /// match's compiler-checked exhaustiveness on the new arm — and
3289    /// every consumer picks up the new key by construction rather
3290    /// than a coordinated array-literal rewrite across every
3291    /// downstream site.
3292    ///
3293    /// Length is pinned load-bearing at `DepList::ALL.len()` (two) by
3294    /// [`tests::dep_list_author_keys_covers_every_arm`], every
3295    /// variant's [`Self::as_str`] projection is pinned to a member of
3296    /// the roster on every arm so a silent skew between the emitter's
3297    /// arm-set and this const's arm-set trips at caixa-core test time
3298    /// rather than at a downstream consumer's accepted-set enumeration
3299    /// miss, and every entry is further pinned to open with the ASCII
3300    /// `:` byte (the tatara-lisp author-surface keyword marker) so a
3301    /// silent collapse with any hypothetical peer un-prefixed wire-form
3302    /// axis (an entry byte-identical to a sibling `deps` / `deps-dev`
3303    /// bare-kebab byte-string that would let an author-key-axis
3304    /// consumer accept the un-prefixed vocabulary) trips here rather
3305    /// than at a downstream K8s-CR round-trip miss.
3306    pub const AUTHOR_KEYS: &'static [&'static str] = &[
3307        crate::render::DEP_AUTHOR_KEY_DEPS,
3308        crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3309    ];
3310
3311    /// Canonical author-surface tag every substrate consumer that
3312    /// names the offending dep-list in a diagnostic reaches for —
3313    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3314    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3315    /// the same `&'static str` payload the sibling
3316    /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3317    /// already carry. Routing every dep-list diagnostic through the
3318    /// closed-set enum's `as_str` closes the last `&'static str`-shape
3319    /// literal-carry axis on the two-list dep-graph surface — a
3320    /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3321    /// wire-format promotion (a distinct diagnostic form for the
3322    /// `Dev` arm) reaches every consumer through one edit on the
3323    /// canonical constant, not a coordinated rewrite across the
3324    /// substrate's dep-graph consumers.
3325    #[must_use]
3326    pub const fn as_str(self) -> &'static str {
3327        match self {
3328            Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3329            Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3330        }
3331    }
3332
3333    /// Substrate-canonical reverse projection on the two-list dep-graph
3334    /// axis — parses the author-surface wire tag back to the typed
3335    /// variant, or `None` when `s` is outside the closed-set arm-string
3336    /// set [`Self::as_str`] emits. Dispatches on the same lifted
3337    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3338    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3339    /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3340    /// the round-trip migrate through one caixa-core edit on any future
3341    /// list-axis addition.
3342    ///
3343    /// Prior to this lift the substrate carried only the forward
3344    /// `Self → &str` projection on the two-list dep-graph axis (the
3345    /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3346    /// through it, the two [`DepError::DuplicateNome`] /
3347    /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3348    /// as a `&'static str` `list:` field). Every future consumer that
3349    /// wanted to promote the wire tag back to the typed enum (a future
3350    /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3351    /// wire form into the typed enum before dispatching to
3352    /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3353    /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3354    /// wire re-parse of the per-list diagnostic body, a future
3355    /// [`DepError`] widening that promotes the two `list: &'static str`
3356    /// fields to a typed `list: DepList` carry so downstream consumers
3357    /// dispatch on the enum rather than string-comparing the wire
3358    /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3359    /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3360    /// compile-time link back to the typed [`DepList`] enum. A future
3361    /// variant addition (a `:build-dep` or `:test-dep` third list once
3362    /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3363    /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3364    /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3365    /// would silently split the wire byte-string the emitter walks from
3366    /// the parser's arm-set — the round-trip would carry the new list
3367    /// through the forward projection but land on the fallback silently
3368    /// at every non-updated reverse parser, far from the arm-addition
3369    /// commit that caused the drift. Lifting the resolver to a typed
3370    /// method on the substrate primitive closes the drift footgun by
3371    /// construction: the parser's accept-set is the same set the
3372    /// [`Self::as_str`] emitter walks (routed through the same lifted
3373    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3374    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3375    /// of the round-trip migrate through one caixa-core edit on any
3376    /// future list-axis addition.
3377    ///
3378    /// Same closed-set-reverse-projection discipline the sibling
3379    /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3380    /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3381    /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3382    /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3383    /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3384    /// carry on the peer wire-side `str → Self` axes — extended onto
3385    /// the two-list dep-graph closed-set axis, the sixth substrate-side
3386    /// closed-set typed enum on the caixa surface to converge on the
3387    /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3388    /// `from_str`) to match the peer shapes verbatim and side-step the
3389    /// derived [`std::str::FromStr`] impls the sibling
3390    /// [`gen_platform::FromStrKind`]-carrying axes install on their
3391    /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3392    /// (rather than `Result<Self, _>`) to match the peer shapes: the
3393    /// caller picks the diagnostic form appropriate for its use site —
3394    /// a future `feira dep --list …` arg-parse that surfaces
3395    /// `unknown list: <arg>` at the CLI builds one on top by iterating
3396    /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3397    /// path folds `None` onto its per-CR structured refusal body.
3398    #[must_use]
3399    pub fn from_wire(s: &str) -> Option<Self> {
3400        match s {
3401            crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3402            crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3403            _ => None,
3404        }
3405    }
3406}
3407
3408/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3409/// consumer that formats the axis as user-facing text (a future
3410/// `feira app graph` per-list summary, a future M4 admission-webhook
3411/// rejection body naming the offending list, this crate's own
3412/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3413/// typed [`DepList`]) lands on the same author-surface tag the
3414/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3415/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3416/// as-str-through-Display convergence discipline the sibling
3417/// [`crate::aplicacao::PlacementStrategy`],
3418/// [`crate::aplicacao::RateLimitUnit`],
3419/// [`crate::supervisor::RestartStrategy`],
3420/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3421/// closed-set typed enums carry.
3422impl std::fmt::Display for DepList {
3423    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3424        f.write_str(self.as_str())
3425    }
3426}
3427
3428/// Substrate-canonical [`AsRef<str>`] projection on the two-list
3429/// dep-graph closed-set typed enum — routes through the same
3430/// [`DepList::as_str`] `pub const fn` scalar accessor the paired
3431/// [`std::fmt::Display`] impl already delegates through, so any future
3432/// consumer that binds a [`DepList`] through the standard-library
3433/// `impl AsRef<str>` bound (a [`std::process::Command::arg`] shell-out
3434/// that composes the canonical author-surface tag into a
3435/// `feira dep --list <deps|deps-dev>` diagnostic overlay, a
3436/// `tracing::field::Value::Str`-arm structured-log recorder on the
3437/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] refusal paths,
3438/// a [`std::collections::HashMap`] lookup keyed on the canonical tag
3439/// through `map.get::<str>(list.as_ref())` on a future M4 admission-
3440/// webhook's per-list rejection-body composition table) reaches the
3441/// paired [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3442/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string through one
3443/// substrate-primitive dispatch rather than an open-coded `.as_str()`
3444/// re-inlining at every wire-up.
3445///
3446/// Same "route the trait impl through the substrate-primitive
3447/// accessor" discipline the sibling [`crate::CaixaDialeto`]
3448/// [`AsRef<str>`] impl (1723611), the [`crate::aplicacao::RateLimitUnit`]
3449/// [`AsRef<str>`] impl (d8136db), the [`crate::CaixaKind`]
3450/// [`AsRef<str>`] impl (cd2091f), the M3
3451/// [`crate::aplicacao::PlacementStrategy`] [`AsRef<str>`] impl
3452/// (d86edd2), the M2 [`crate::supervisor::RestartPolicy`]
3453/// [`AsRef<str>`] impl (419ea81), the M2
3454/// [`crate::supervisor::RestartStrategy`] [`AsRef<str>`] impl
3455/// (63eb1a4), and the [`crate::CaixaVersion`] [`AsRef<str>`] impl
3456/// (16d5c7e) carry — closes the substrate primitive's
3457/// [`AsRef<str>`] projection axis on the seventh (and last unlifted)
3458/// closed-set typed enum on the caixa surface: the two-list dep-graph
3459/// axis previously carried [`fmt::Display`]-through-`as_str` but not
3460/// yet the paired [`AsRef<str>`] impl, so a downstream consumer that
3461/// bound the enum through the standard-library `AsRef<str>` trait had
3462/// to reach the canonical byte-string through an open-coded
3463/// `.as_str()` call rather than the trait-idiomatic `.as_ref()` the
3464/// peer closed-set typed enums already admit.
3465///
3466/// Pinned load-bearing by
3467/// [`tests::dep_list_as_ref_str_routes_through_as_str_accessor`]
3468/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3469/// closed set) and
3470/// [`tests::dep_list_as_ref_str_routes_through_display_via_shared_accessor`]
3471/// (three-path convergence: `AsRef<str>` + `Display` + `as_str` all
3472/// resolve to the same byte-string per arm) — any future silent detour
3473/// that routes the impl through a divergent projection (a per-arm
3474/// inline `match self { DepList::Prod => ":deps", … }` re-inlining
3475/// that opens a compile-time link to the un-lifted arm-literal, a
3476/// swap onto a second projection axis) trips at caixa-core test time
3477/// under `assert_eq!` rather than at a downstream
3478/// `impl AsRef<str>`-bound consumer's silent split.
3479impl AsRef<str> for DepList {
3480    fn as_ref(&self) -> &str {
3481        self.as_str()
3482    }
3483}
3484
3485/// Trait-idiomatic *reverse* projection on the two-list dep-graph
3486/// [`DepList`] closed-set typed enum — routes through the paired
3487/// substrate-primitive [`DepList::from_wire`] `Option<Self>` accessor
3488/// so `<DepList>::try_from(":deps")` reaches the same two-arm
3489/// accept-set the sibling [`DepList::from_wire`] resolver dispatches
3490/// through, rather than an open-coded per-arm
3491/// `match s { ":deps" => Ok(Self::Prod), … }` cascade whose arm-set
3492/// has no compile-time link back to the substrate primitive.
3493///
3494/// Corrects a completeness gap in the substrate-wide trait-idiomatic
3495/// reverse-projection campaign (opened by [`crate::CaixaKind`] via
3496/// 3c83606, closed onto 14 sibling closed-set fieldless typed enums
3497/// across the caixa surface — 5b828ed, 6fdd0d9, 5472902, bf78400,
3498/// e67e48a, e21a857, 0a4cc45, a7bf74c, df86c94, bd7da69, 42ab951 —
3499/// which silently omitted [`DepList`] despite this enum being listed
3500/// as a sibling closed-set fieldless typed enum in every peer's
3501/// docstring). Every sibling closed-set fieldless typed enum on the
3502/// caixa surface now carries both trait-idiomatic axes
3503/// (`TryFrom<&str> for Self` + `From<Self> for &'static str`) paired
3504/// against the substrate-primitive canonical projection accessors
3505/// (`as_str`/`variant_slug` + `from_wire`) — the two-list dep-graph
3506/// closed-set is the fifteenth and true-final peer.
3507///
3508/// `type Error = ()` matches the sibling [`DepList::from_wire`]'s
3509/// `Option<Self>` return-shape's deliberate deferral of error typing:
3510/// the caller picks the diagnostic form appropriate for its use site
3511/// (a future `feira dep --list <deps|deps-dev>` arg-parse composes
3512/// `unknown list: <arg> — accepted: {…}` enumerating [`DepList::ALL`];
3513/// the M4 admission-webhook rejection body wraps `Err(())` with the
3514/// accepted-set enumeration).
3515///
3516/// Pinned load-bearing by
3517/// [`tests::dep_list_try_from_str_routes_through_from_wire_accessor`]
3518/// (byte-parity pin against [`DepList::from_wire`] across the two-arm
3519/// accept-set) and
3520/// [`tests::dep_list_try_from_str_rejects_unknown_byte_strings`]
3521/// (rejection witness against silent accept-set widening).
3522impl TryFrom<&str> for DepList {
3523    type Error = ();
3524
3525    fn try_from(s: &str) -> Result<Self, Self::Error> {
3526        Self::from_wire(s).ok_or(())
3527    }
3528}
3529
3530/// Trait-idiomatic *forward* projection on the two-list dep-graph
3531/// [`DepList`] closed-set typed enum onto the `&'static str` axis —
3532/// routes byte-for-byte through the paired substrate-primitive
3533/// [`DepList::as_str`] `pub const fn` accessor so
3534/// `<&'static str>::from(list)` / `list.into::<&'static str>()`
3535/// reaches the same two-arm lifted
3536/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3537/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the sibling
3538/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3539/// surfaces already return.
3540///
3541/// Closes the substrate-wide trait-idiomatic forward-projection
3542/// campaign for real — the campaign opened on [`crate::supervisor::RestartStrategy`]
3543/// via 523157d and traced through the 13 sibling closed-set typed
3544/// enums (9fb37d0, edb827b, c189a6f, afa3562, 56998ec, 7fdfbf4,
3545/// 070a6de, f2ca7bc, d4559cb, 5cc3b8b, 2a56127, 07f36bb, 85d0443)
3546/// silently omitted [`DepList`] on both trait-idiomatic axes despite
3547/// every peer's docstring naming it as a sibling. Paired with the
3548/// [`TryFrom<&str> for DepList`] impl immediately above, this closes
3549/// the two-way `DepList ↔ &'static str` round-trip on the trait-
3550/// idiomatic axis pair, mirroring the pre-existing method-named
3551/// [`DepList::as_str`] + [`DepList::from_wire`] pair on the
3552/// substrate-primitive axis pair.
3553///
3554/// The paired [`DepList::as_str`] returns `&'static str` by
3555/// construction — each arm resolves to a
3556/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3557/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` with
3558/// static lifetime — so the trait's return-type promise is upheld
3559/// structurally.
3560///
3561/// Pinned load-bearing by
3562/// [`tests::dep_list_from_into_static_str_routes_through_as_str_accessor`]
3563/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3564/// emit-set, plus a `const`-context materialization witness for the
3565/// `&'static str` lifetime promise) and
3566/// [`tests::dep_list_from_into_static_str_and_as_str_partition_the_emit_set`]
3567/// (partition pin + two-way round-trip through the paired
3568/// [`TryFrom<&str>`] axis).
3569impl From<DepList> for &'static str {
3570    fn from(list: DepList) -> &'static str {
3571        list.as_str()
3572    }
3573}
3574
3575/// Trait-idiomatic *forward* projection on the two-list dep-graph
3576/// [`DepList`] closed-set typed enum from a *borrowed* input onto the
3577/// `&'static str` axis — the borrowed-input companion to the paired
3578/// owned-input [`From<DepList> for &'static str`] impl immediately
3579/// above. Routes byte-for-byte through the same substrate-primitive
3580/// [`DepList::as_str`] `pub const fn` accessor so every consumer that
3581/// binds a `&DepList` through the standard-library `.into()` /
3582/// [`From<&Self> for &'static str`] axis (a
3583/// `DepList::ALL.iter().map(<&'static str>::from).collect::<Vec<_>>()`
3584/// per-arm accept-set materializer that iterates the substrate-
3585/// canonical [`DepList::ALL`] slice — whose iterator yields `&DepList`,
3586/// not `DepList`, so the owned-input [`From<DepList>`] axis alone
3587/// forces every call site through an explicit `.copied()` /
3588/// dereference / [`Copy`]-bound restatement rather than the direct
3589/// trait-idiomatic projection; a future generic
3590/// `<T: Copy + for<'a> Into<&'static str>>`-bound diagnostic column
3591/// that walks the `iter().map(Into::into)` shape verbatim; the future
3592/// M4 admission-webhook rejection body that composes the accepted-set
3593/// enumeration from an iterated `DepList::ALL.iter().map(|l| l.into())`
3594/// pipe rather than a per-arm `match l { … }` cascade) reaches the same
3595/// two-arm lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3596/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the paired
3597/// owned-input [`From<DepList> for &'static str`], the sibling
3598/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3599/// surfaces already return.
3600///
3601/// Opens the substrate-wide trait-idiomatic *borrowed-input*
3602/// forward-projection family on the last-touched closed-set fieldless
3603/// typed enum — first-mover on the borrowed-input axis, mirroring the
3604/// role [`crate::supervisor::RestartStrategy`] played on the owned-
3605/// input axis (523157d). Rust's `From` trait does not auto-derive the
3606/// `From<&Self>` sibling from a `From<Self>` impl (the blanket
3607/// `impl<T, U> From<&T> for U where T: Copy, U: From<T>` does not exist
3608/// in `core`), so every closed-set typed enum that carries the
3609/// owned-input axis but not the borrowed-input axis forces every
3610/// borrowed-input call site through a `.copied()` /
3611/// `<&'static str>::from(*list)` / `list.as_str()` detour whose type
3612/// bounds have no compile-time link to the substrate primitive. The
3613/// remaining fourteen substrate-wide closed-set fieldless typed enum
3614/// peers (`CaixaKind`, `CaixaDialeto`, `RestartStrategy`,
3615/// `RestartPolicy`, `WitShape`, `RateLimitUnit`, `PlacementStrategy`,
3616/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3617/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets
3618/// of this campaign.
3619///
3620/// Pinned load-bearing by
3621/// [`tests::dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor`]
3622/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3623/// emit-set via a borrowed input, plus a `const`-context materialization
3624/// witness) and
3625/// [`tests::dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
3626/// (cross-axis partition pin against the paired owned-input
3627/// [`From<DepList> for &'static str`] impl).
3628impl From<&DepList> for &'static str {
3629    fn from(list: &DepList) -> &'static str {
3630        list.as_str()
3631    }
3632}
3633
3634/// Trait-idiomatic *forward* projection on the two-list dep-graph
3635/// [`DepList`] closed-set typed enum from an *owned* input onto the
3636/// owned-[`String`] axis — routes byte-for-byte through the
3637/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor so
3638/// every consumer that binds a [`DepList`] through the standard-library
3639/// `.into()` / [`From<Self> for String`] (equivalently [`Into<String>`])
3640/// axis reaches the same two-arm lifted
3641/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3642/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string the paired
3643/// owned-input [`From<DepList> for &'static str`], the borrowed-input
3644/// [`From<&DepList> for &'static str`], the sibling [`std::fmt::Display`],
3645/// [`AsRef<str>`], and [`DepList::as_str`] surfaces already return.
3646///
3647/// Extends the trait-idiomatic *owned-[`String`]* forward-projection
3648/// family (opened on [`crate::supervisor::RestartStrategy`] — 7baa18a —
3649/// the first-mover on the M2 OTP-shape sibling-restart-strategy axis,
3650/// extended onto [`crate::supervisor::RestartPolicy`] — 7851725 — the
3651/// second-of-two-in-M2 per-child restart-decision axis, then onto
3652/// [`crate::CaixaKind`] — 231a18c — the structurally most fundamental
3653/// closed-set fieldless typed enum on the caixa surface, then onto
3654/// [`crate::CaixaDialeto`] — 88942cd — the dialect-classification axis)
3655/// onto the fifth peer: the two-list dep-graph axis [`DepList`] carries.
3656/// Rust's standard library does not carry a blanket
3657/// `impl<T: AsRef<str>> From<T> for String` (nor an
3658/// `impl<T: fmt::Display> From<T> for String`), so every closed-set
3659/// typed enum that carries the paired [`AsRef<str>`] / [`std::fmt::Display`] /
3660/// [`From<Self> for &'static str`] / [`From<&Self> for &'static str`]
3661/// quadruple but not the owned-[`String`] axis forces every owned-string
3662/// call site through a `.to_string()` / `.as_str().to_owned()` /
3663/// `String::from(list.as_str())` detour whose type bounds have no
3664/// compile-time link to the substrate primitive.
3665///
3666/// Same as the peer [`crate::supervisor::RestartStrategy`] /
3667/// [`crate::supervisor::RestartPolicy`] / [`crate::CaixaDialeto`]
3668/// owned-[`String`] axis pairs (whose forward emit and reverse parse
3669/// share one vocabulary by construction — `PascalCase` on the three
3670/// prior peers, the `":deps"` / `":deps-dev"` leading-colon lispy
3671/// author-surface tags on this one), [`DepList`]'s [`DepList::as_str`]
3672/// emit and [`DepList::from_wire`] parse resolve through the same
3673/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3674/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by construction
3675/// (there is no wire/diagnostic axis split on this enum — both halves
3676/// of the round-trip route through the same two `pub const &str` values),
3677/// so the owned-[`String`] forward projection this impl exposes composes
3678/// directly with the paired trait-idiomatic reverse
3679/// [`TryFrom<&str>`] axis on the owned-[`String`]'s [`String::as_str`]
3680/// borrow — no intermediate wire-vocab hop like the peer
3681/// [`crate::CaixaKind`] axis pair requires.
3682///
3683/// The remaining ten closed-set typed enums on the caixa substrate
3684/// surface (`PlacementStrategy`, `WitShape`, `RateLimitUnit`,
3685/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3686/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets of
3687/// this campaign — each carries the same paired [`AsRef<str>`] /
3688/// [`std::fmt::Display`] / [`From<Self> for &'static str`] /
3689/// [`From<&Self> for &'static str`] quadruple that this owned-[`String`]
3690/// axis extends onto.
3691///
3692/// Pinned load-bearing by
3693/// [`tests::dep_list_from_into_owned_string_routes_through_as_str_accessor`]
3694/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3695/// [`DepList::ALL`] emit-set plus a blanket `.into::<String>()` shape
3696/// witness) and
3697/// [`tests::dep_list_from_into_owned_string_and_static_str_agree_on_every_arm`]
3698/// (cross-axis partition against the sibling owned-`&'static str` axis
3699/// and the [`ToString::to_string`] surface, a
3700/// `.iter().copied().map(String::from)` pipe witness over
3701/// [`DepList::ALL`], plus a direct `Self → String → Self` round-trip
3702/// via [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`]
3703/// borrow — composes directly without the wire-vocab intermediate hop
3704/// the peer [`crate::CaixaKind`] axis pair requires).
3705impl From<DepList> for String {
3706    fn from(list: DepList) -> String {
3707        list.as_str().to_owned()
3708    }
3709}
3710
3711/// Trait-idiomatic *borrowed-input, owned-`String` output* forward
3712/// projection on the two-list dep-graph [`DepList`] closed-set typed
3713/// enum — the fourth (and closing) corner of the
3714/// `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
3715/// projection family on this enum, mirror of the peer M2 OTP-shape
3716/// [`From<&RestartStrategy> for String`] (579385f) and
3717/// [`From<&RestartPolicy> for String`] (8465740) that opened and
3718/// closed the corner on the sibling supervisor-level restart-strategy
3719/// and per-child restart-decision enums. Routes byte-for-byte through
3720/// the substrate-primitive [`DepList::as_str`] `pub const fn` accessor
3721/// (via [`str::to_owned`]) so every consumer that holds a borrowed
3722/// [`&DepList`] and needs an owned [`String`] — a future
3723/// `serde_json::Value::String(String::from(&list))` structured-payload
3724/// composer over a borrowed field, a future `Iterator::map` over
3725/// `&[DepList]` that projects to owned keys through
3726/// `.iter().map(String::from)` (whose iterator yields `&DepList`, not
3727/// `DepList`, so the owned-input [`From<DepList> for String`] axis
3728/// alone forces every call site through an explicit `.copied()` /
3729/// spurious [`Copy`] deref restatement rather than the direct trait-
3730/// idiomatic projection), a future `HashMap::<String, DepList>::from_iter`
3731/// that keys off a borrowed-iteration axis where dereferencing the list
3732/// would force an unnecessary `Copy` at every step, the future
3733/// wasm-operator's per-manifest `list_axes.iter().map(String::from).collect()`
3734/// per-list author-surface-tag diagnostic emit whose iteration axis is
3735/// borrowed by construction — reaches the same two-arm lifted
3736/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3737/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the paired
3738/// [`std::fmt::Display`], [`AsRef<str>`], [`DepList::as_str`], and the
3739/// three other trait-idiomatic forward-projection impls
3740/// ([`From<DepList> for &'static str`],
3741/// [`From<&DepList> for &'static str`],
3742/// [`From<DepList> for String`]) already return.
3743///
3744/// Third peer on the substrate-wide trait-idiomatic *borrowed-input,
3745/// owned-`String` output* forward-projection family opened on
3746/// [`crate::supervisor::RestartStrategy`] (579385f) and closed on
3747/// [`crate::supervisor::RestartPolicy`] (8465740) — extends the
3748/// `{Self, &Self} × {&'static str, String}` 2×2 projection corner off
3749/// the M2 OTP-shape axis pair onto the first non-M2 closed-set
3750/// fieldless typed enum peer (the two-list dep-graph axis). Rust's
3751/// standard library does not carry a blanket
3752/// `impl<T: AsRef<str>> From<&T> for String` (nor an
3753/// `impl<T: fmt::Display> From<&T> for String`), so every closed-set
3754/// typed enum that carries the paired `AsRef<str>` / `Display` /
3755/// `From<Self> for &'static str` / `From<&Self> for &'static str` /
3756/// `From<Self> for String` quintuple but not the borrowed-input owned-
3757/// [`String`] axis forces every borrowed-input owned-string call site
3758/// through a `list.as_str().to_owned()` / `String::from(*list)` (with a
3759/// spurious `Copy`) / `list.to_string()` (through `Display`) detour
3760/// whose type bounds have no compile-time link to the substrate
3761/// primitive.
3762///
3763/// Same as the peer [`crate::supervisor::RestartStrategy`] /
3764/// [`crate::supervisor::RestartPolicy`] borrowed-input owned-[`String`]
3765/// axis pairs (whose forward emit and reverse parse share one
3766/// vocabulary by construction — `PascalCase` on the M2 OTP-shape
3767/// peers), [`DepList`]'s [`DepList::as_str`] emit and
3768/// [`DepList::from_wire`] parse resolve through the same lifted
3769/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3770/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by construction
3771/// (the `":deps"` / `":deps-dev"` leading-colon lispy author-surface
3772/// tags — there is no wire/diagnostic axis split on this enum), so the
3773/// borrowed-input owned-[`String`] projection this impl exposes
3774/// composes directly with the paired trait-idiomatic reverse
3775/// [`TryFrom<&str>`] axis on the owned-[`String`]'s [`String::as_str`]
3776/// borrow — no intermediate wire-vocab hop like the peer
3777/// [`crate::CaixaKind`] axis pair requires.
3778///
3779/// The remaining ten closed-set typed enums on the caixa substrate
3780/// surface (`CaixaKind`, `CaixaDialeto`, `PlacementStrategy`,
3781/// `WitShape`, `RateLimitUnit`, `PathShapeViolation`, `InvariantKind`,
3782/// `ArchVerdict`, `Severity`, `FixSafety`, `Semantic`, `FerriteRuntime`)
3783/// are the future targets of this 2×2-completion campaign — each
3784/// carries the same paired quintuple that this borrowed-input owned-
3785/// [`String`] axis extends onto.
3786///
3787/// Pinned load-bearing by
3788/// [`tests::dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
3789/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3790/// emit-set through the borrowed-input surface) and
3791/// [`tests::dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
3792/// (cross-axis partition pin against the paired owned-input owned-
3793/// [`String`] [`From<DepList> for String`] impl, the paired borrowed-
3794/// input owned-[`&'static str`] [`From<&DepList> for &'static str`]
3795/// impl, and the sibling [`ToString::to_string`] surface routed through
3796/// [`std::fmt::Display`], plus a direct round-trip witness through
3797/// [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`]
3798/// borrow that closes the two-way `&Self → String → Self` round-trip
3799/// on the trait-idiomatic borrowed-input owned-[`String`] forward +
3800/// reverse axis pair).
3801impl From<&DepList> for String {
3802    fn from(list: &DepList) -> String {
3803        list.as_str().to_owned()
3804    }
3805}
3806
3807/// Trait-idiomatic *forward* projection on the two-list dep-graph
3808/// [`DepList`] closed-set typed enum from an *owned* input onto the
3809/// borrowed-heap-string [`std::borrow::Cow<'static, str>`] axis —
3810/// routes byte-for-byte through the substrate-primitive
3811/// [`DepList::as_str`] `pub const fn` accessor (via
3812/// [`std::borrow::Cow::Borrowed`]) so every consumer that binds a
3813/// [`DepList`] through the standard-library `.into()` /
3814/// [`From<Self> for std::borrow::Cow<'static, str>`] (equivalently
3815/// [`Into<std::borrow::Cow<'static, str>>`]) axis reaches the same
3816/// two-arm lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3817/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] canonical `pub const
3818/// &str` values the paired [`From<DepList> for &'static str`],
3819/// [`From<&DepList> for &'static str`], [`From<DepList> for String`],
3820/// and [`From<&DepList> for String`] 2×2 trait-idiomatic forward-
3821/// projection corners, the sibling [`std::fmt::Display`],
3822/// [`AsRef<str>`], and [`DepList::as_str`] surfaces already return,
3823/// rather than an open-coded per-call-site
3824/// `std::borrow::Cow::Borrowed(list.as_str())` /
3825/// `std::borrow::Cow::Owned(list.to_string())` composition whose
3826/// type bounds have no compile-time link back to the substrate
3827/// primitive.
3828///
3829/// Deliberately returns [`std::borrow::Cow::Borrowed`] rather than
3830/// [`std::borrow::Cow::Owned`] — the substrate-primitive
3831/// [`DepList::as_str`] accessor's return carries the `&'static str`
3832/// lifetime by construction (each `match` arm resolves to one of
3833/// the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3834/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
3835/// values with static lifetime), so the zero-alloc borrowed arm is
3836/// the type-correct projection with no runtime allocation. The
3837/// paired [`std::borrow::Cow::Owned`] arm stays reachable at the
3838/// call site through the existing [`From<DepList> for String`] axis
3839/// composed with [`std::borrow::Cow::from`] on the resulting owned
3840/// [`String`] — a caller who chose to mutate the projection lands
3841/// on the owned arm by their own composition, not by the substrate-
3842/// primitive projection silently allocating on their behalf.
3843///
3844/// Rust's standard library carries no blanket `impl<T: AsRef<str>>
3845/// From<T> for Cow<'static, str>` (nor an `impl<T: fmt::Display>
3846/// From<T> for Cow<'static, str>`), so the paired sibling
3847/// [`From<DepList> for &'static str`], [`From<DepList> for String`],
3848/// [`AsRef<str>`], and [`std::fmt::Display`] surfaces do not
3849/// implicitly extend to a [`std::borrow::Cow<'static, str>`]-bound
3850/// call site — every such site is forced through a
3851/// `Cow::Borrowed(list.as_str())` / `Cow::Owned(list.to_string())`
3852/// open-code whose type bounds have no compile-time link back to
3853/// the substrate primitive until this lift.
3854///
3855/// First-mover on the outside-M3 substrate-wide tier of the
3856/// substrate-wide trait-idiomatic [`std::borrow::Cow<'static, str>`]
3857/// forward-projection campaign, opening the tier on the first
3858/// caixa-core-internal closed-set fieldless typed enum peer outside
3859/// the M2 OTP-shape and M3 mesh-shape tiers. The
3860/// [`crate::CaixaKind`] top-level first-mover
3861/// (99c1735 owned-input, d45c409 borrowed-input) opened the axis on
3862/// the structurally most fundamental closed-set fieldless typed
3863/// enum; the paired M2 OTP-shape
3864/// [`crate::supervisor::RestartStrategy`] (7dd28b3, 9b3e4b3) and
3865/// [`crate::supervisor::RestartPolicy`] (0612398, ee577fd) closed
3866/// the M2 OTP-shape tier; the paired M3-mesh-shape
3867/// [`crate::aplicacao::WitShape`] `:contratos :wit` census-label
3868/// (8634dec, 25690ef), [`crate::aplicacao::PlacementStrategy`]
3869/// `:placement :estrategia` distribution-strategy (eee504d,
3870/// afdf0f4), and [`crate::aplicacao::RateLimitUnit`] `:politicas
3871/// :rate-limit` canonical-suffix (1d59925, `From<&RateLimitUnit>`
3872/// Cow closer) closed the M3-mesh-shape tier. The remaining
3873/// outside-M3 caixa-core peers ([`crate::CaixaDialeto`],
3874/// [`crate::render::PathShapeViolation`]) and the outside-
3875/// `caixa-core` peers (`InvariantKind`, `ArchVerdict`, `Severity`,
3876/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the remaining
3877/// future targets of this campaign; the paired borrowed-input
3878/// [`From<&DepList> for std::borrow::Cow<'static, str>`]
3879/// `{Self, &Self}`-closer on this outside-M3-tier-opening peer is
3880/// the next commit's target.
3881///
3882/// Same three-path convergence discipline as the paired sibling
3883/// [`From<DepList> for &'static str`] / [`From<DepList> for String`]
3884/// / [`std::fmt::Display`] / [`AsRef<str>`] surfaces (this
3885/// [`std::borrow::Cow<'static, str>`] axis, the paired sibling
3886/// surfaces, and [`DepList::as_str`] all route through the same two
3887/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3888/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
3889/// values by construction), so a future variant addition, rename,
3890/// or per-arm wire-tag drift reaches every forward-projection path
3891/// through exactly one caixa-core edit at the [`DepList::as_str`]
3892/// `match` head.
3893///
3894/// Pinned load-bearing by
3895/// [`tests::dep_list_from_into_static_cow_str_routes_through_as_str_accessor`]
3896/// (byte-parity + zero-alloc [`std::borrow::Cow::Borrowed`]-arm pin
3897/// against [`DepList::as_str`] across the two-arm [`DepList::ALL`])
3898/// and
3899/// [`tests::dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
3900/// (cross-axis partition pin against the paired
3901/// [`From<DepList> for &'static str`], [`From<DepList> for String`],
3902/// and [`ToString`]-through-[`std::fmt::Display`] axes, plus a
3903/// `.iter().copied().map(Cow::from)` pipe witness over
3904/// [`DepList::ALL`] that materializes the two-arm accept-set through
3905/// the [`std::borrow::Cow<'static, str>`] axis alone and pins the
3906/// zero-alloc discipline on every element).
3907impl From<DepList> for std::borrow::Cow<'static, str> {
3908    fn from(list: DepList) -> std::borrow::Cow<'static, str> {
3909        std::borrow::Cow::Borrowed(list.as_str())
3910    }
3911}
3912
3913/// Trait-idiomatic *borrowed-input, [`std::borrow::Cow<'static, str>`]
3914/// output* forward projection on the two-list dep-graph [`DepList`]
3915/// closed-set typed enum — the borrowed-input companion to the paired
3916/// owned-input [`From<DepList> for std::borrow::Cow<'static, str>`] impl
3917/// immediately above (6858bac). Routes byte-for-byte through the same
3918/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor (via
3919/// [`std::borrow::Cow::Borrowed`]) so every consumer that holds a
3920/// `&DepList` and needs a [`std::borrow::Cow<'static, str>`] — a
3921/// `DepList::ALL.iter().map(std::borrow::Cow::from).collect::<Vec<_>>()`
3922/// per-arm accept-set materializer whose iterator over
3923/// `&'static [DepList]` yields `&DepList` (not `DepList`, so the paired
3924/// owned-input [`From<DepList> for std::borrow::Cow<'static, str>`] axis
3925/// alone forces every call site through an explicit `.copied()` /
3926/// dereference / [`Copy`]-bound restatement rather than the direct
3927/// trait-idiomatic projection), a future generic
3928/// `<T: for<'a> Into<std::borrow::Cow<'static, str>>>`-bound emitter on
3929/// a per-`:deps` / `:deps-dev` diagnostic column that walks the
3930/// `iter().map(Into::into)` shape verbatim, the future M4
3931/// `caixa.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection body
3932/// that composes the accepted-`:deps` / `:deps-dev` list-key enumeration
3933/// from an iterated `DepList::ALL.iter().map(|l| l.into())` pipe rather
3934/// than a per-arm `match l { … }` cascade — reaches the same two-arm
3935/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3936/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string the paired
3937/// [`std::fmt::Display`], [`AsRef<str>`], [`DepList::as_str`], the four
3938/// `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
3939/// forward-projection corners, and the paired owned-input
3940/// [`From<DepList> for std::borrow::Cow<'static, str>`] impl already
3941/// return.
3942///
3943/// Deliberately returns [`std::borrow::Cow::Borrowed`] rather than
3944/// [`std::borrow::Cow::Owned`] — the substrate-primitive
3945/// [`DepList::as_str`] accessor's return carries the `&'static str`
3946/// lifetime by construction (each `match` arm resolves to one of the
3947/// two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3948/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
3949/// byte-strings with static lifetime), so the zero-alloc borrowed arm
3950/// is the type-correct projection with no runtime allocation on the
3951/// borrowed-input surface just as on the paired owned-input surface.
3952///
3953/// Closes the `{Self, &Self}` input-shape corner on the outside-M3
3954/// caixa-core two-list dep-graph [`std::borrow::Cow<'static, str>`]
3955/// axis opened one commit prior (6858bac) on the paired owned-input
3956/// [`From<DepList> for std::borrow::Cow<'static, str>`] impl — first
3957/// outside-M3 caixa-core peer on the axis, one commit after the paired
3958/// M3-mesh-shape [`crate::aplicacao::RateLimitUnit`] `:politicas
3959/// :rate-limit` canonical-suffix (1d59925), the paired M3-mesh-shape
3960/// [`crate::aplicacao::PlacementStrategy`] `:placement :estrategia`
3961/// distribution-strategy (eee504d + afdf0f4), the paired M3-mesh-shape
3962/// [`crate::aplicacao::WitShape`] `:contratos :wit` census-label
3963/// (8634dec + 25690ef), the paired M2 OTP-shape
3964/// [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3) and
3965/// [`crate::supervisor::RestartPolicy`] (0612398 + ee577fd), and the
3966/// paired top-level [`crate::CaixaKind`] (99c1735 + d45c409) peers
3967/// closed the M3-mesh-shape, M2-OTP-shape, and top-level tiers.
3968/// Rust's standard library does not carry a blanket
3969/// `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor an
3970/// `impl<T: fmt::Display> From<&T> for Cow<'static, str>`), so every
3971/// closed-set fieldless typed enum peer on the substrate that carries
3972/// the paired owned-input [`Cow<'static, str>`] axis but not the
3973/// borrowed-input axis forces every borrowed-input
3974/// [`Cow<'static, str>`]-parameterized call site through a spurious
3975/// [`Copy`] deref (`std::borrow::Cow::from(*list)`) or a
3976/// `std::borrow::Cow::Borrowed(list.as_str())` open-code whose type
3977/// bounds have no compile-time link to the substrate primitive.
3978///
3979/// The remaining outside-M3 caixa-core peers ([`crate::CaixaDialeto`],
3980/// [`crate::render::PathShapeViolation`]) and the outside-`caixa-core`
3981/// peers (`InvariantKind`, `ArchVerdict`, `Severity`, `FixSafety`,
3982/// `Semantic`, `FerriteRuntime`) are the remaining future targets of
3983/// the campaign; closing this borrowed-input corner on [`DepList`]
3984/// leaves [`crate::CaixaDialeto`] as the next outside-M3 caixa-core
3985/// closed-set fieldless typed enum peer target on the
3986/// [`std::borrow::Cow<'static, str>`] axis.
3987///
3988/// Same three-path convergence discipline as the paired sibling
3989/// [`From<&DepList> for &'static str`], [`From<&DepList> for String`],
3990/// [`std::fmt::Display`], and [`AsRef<str>`] surfaces (this borrowed-
3991/// input [`std::borrow::Cow<'static, str>`] axis, the paired owned-
3992/// input [`From<DepList> for std::borrow::Cow<'static, str>`] axis, the
3993/// paired sibling `{Self, &Self} × {&'static str, String}` 2×2 corners,
3994/// and [`DepList::as_str`] all route through the same two lifted
3995/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3996/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` values
3997/// by construction), so a future variant addition, rename, or per-arm
3998/// wire-tag drift reaches every forward-projection path through
3999/// exactly one caixa-core edit at the [`DepList::as_str`] `match` head.
4000///
4001/// Pinned load-bearing by
4002/// [`tests::dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor`]
4003/// (byte-parity + zero-alloc [`std::borrow::Cow::Borrowed`]-arm pin
4004/// against [`DepList::as_str`] across the two-arm [`DepList::ALL`]
4005/// through the borrowed-input surface) and
4006/// [`tests::dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
4007/// (cross-axis partition pin against the paired owned-input
4008/// [`From<DepList> for std::borrow::Cow<'static, str>`], the paired
4009/// borrowed-input owned-`&'static str` [`From<&DepList> for &'static
4010/// str`], and the paired borrowed-input owned-`String` [`From<&DepList>
4011/// for String`] impls, plus a `.iter().map(std::borrow::Cow::from)`
4012/// pipe witness over [`DepList::ALL`] — whose iterator yields
4013/// `&DepList` by construction, so the borrowed-input
4014/// [`std::borrow::Cow<'static, str>`] axis is what routes the pipe
4015/// through the substrate-primitive [`DepList::as_str`] accessor with
4016/// the zero-alloc [`std::borrow::Cow::Borrowed`] arm by construction
4017/// and without a spurious [`Copy`] deref).
4018impl From<&DepList> for std::borrow::Cow<'static, str> {
4019    fn from(list: &DepList) -> std::borrow::Cow<'static, str> {
4020        std::borrow::Cow::Borrowed(list.as_str())
4021    }
4022}
4023
4024/// Trait-idiomatic *owned-input, [`Box<str>`] output* forward projection on
4025/// the outside-M3 caixa-core two-list dep-graph [`DepList`] closed-set
4026/// fieldless typed enum. Routes byte-for-byte through the substrate-
4027/// primitive [`DepList::as_str`] `pub const fn` accessor via
4028/// [`Box::<str>::from`] on the returned `&'static str`, so every consumer
4029/// that binds a `let key: Box<str> = list.into();`-shaped call site — a
4030/// per-`:deps` / `:deps-dev` census-key materializer that stashes the
4031/// dep-list discriminator in a [`Box<str>`]-typed heap-owned scalar for
4032/// cheap clone off an owned handle, a future M4
4033/// [`caixa.pleme.io/v1alpha1/Caixa`] CR materializer's per-list admission-
4034/// webhook rejection body whose per-arm [`Box<str>`] field composes from
4035/// an owned [`DepList`] handle naming the accepted-list-tag list, a future
4036/// `feira lint --explain-dep-list=<axis>` per-arm listing that stashes
4037/// each arm as an owned [`Box<str>`] label — reaches the same two lifted
4038/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4039/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4040/// the sibling `{Self, &Self} × {&'static str, String, Cow<'static, str>}`
4041/// forward-projection corner already returns.
4042///
4043/// Rust's standard library carries `impl From<&str> for Box<str>` and
4044/// `impl From<String> for Box<str>` but no blanket
4045/// `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a distinct
4046/// trait-idiomatic surface that a downstream `DepList → Box<str>`
4047/// `.into()` reaches through this impl and no other — without a
4048/// `Box::from(list.as_str())` open-code whose type bounds have no
4049/// compile-time link back to the substrate primitive.
4050///
4051/// Extends the caixa-core-internal tier of the substrate-wide trait-
4052/// idiomatic [`Box<str>`] forward-projection campaign onto the second
4053/// caixa-core-internal peer, after the render-side path-shape-diagnostic
4054/// [`crate::render::PathShapeViolation`] pair (0d87a72, both corners in
4055/// one axis) opened the tier. Follows the M2 OTP-shape
4056/// [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
4057/// pair (59ae5dc + cb1d068), the M3 mesh-shape
4058/// [`crate::aplicacao::PlacementStrategy`] / [`crate::aplicacao::WitShape`] /
4059/// [`crate::aplicacao::RateLimitUnit`] triple (6d73e84 → df7040c) that
4060/// closed the M3 mesh-shape tier, and the outside-`caixa-core` tier
4061/// (`InvariantKind` 10613a7 + 5901887, `ArchVerdict` 3e08f5a + c4319a8,
4062/// `Severity` 5116c95, `FixSafety` cf0174b, `Semantic` 0cd7dc3,
4063/// `FerriteRuntime` 14886a8) that closed one tier prior. Same discipline
4064/// as those peers: forward emit (this impl, the sibling `{&'static str,
4065/// String, Cow<'static, str>}` forward-projection corner, [`std::fmt::Display`],
4066/// [`AsRef<str>`], [`DepList::as_str`]) and reverse parse
4067/// ([`DepList::from_wire`], [`TryFrom<&str>`]) route through the same two
4068/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4069/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4070/// by construction, so the round-trip composes directly without the
4071/// wire-vocab intermediate hop the peer [`crate::CaixaKind`] axis pair
4072/// requires.
4073///
4074/// A future variant addition (a `Build` build-time-only dep-list axis the
4075/// CAIXA-SDLC hints name as a trajectory item once the Cargo
4076/// `[build-dependencies]` table gains substrate visibility) reaches the
4077/// paired [`Box<str>`] output axis through one match-arm edit on the
4078/// [`DepList::as_str`] `pub const fn` accessor, not a coordinated rewrite
4079/// of every downstream `Box::from(list.as_str())` open-code.
4080///
4081/// Pinned load-bearing by
4082/// [`tests::dep_list_from_into_box_str_routes_through_as_str_accessor`]
4083/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4084/// [`DepList::ALL`] emit-set on the owned-input surface, plus a blanket-
4085/// derived [`Into`] shape witness).
4086impl From<DepList> for Box<str> {
4087    fn from(list: DepList) -> Box<str> {
4088        Box::<str>::from(list.as_str())
4089    }
4090}
4091
4092/// Trait-idiomatic *borrowed-input, [`Box<str>`] output* forward projection
4093/// on the outside-M3 caixa-core two-list dep-graph [`DepList`] closed-set
4094/// fieldless typed enum. Routes byte-for-byte through the substrate-
4095/// primitive [`DepList::as_str`] `pub const fn` accessor via
4096/// [`Box::<str>::from`] on the returned `&'static str`, so every consumer
4097/// that binds a `let key: Box<str> = (&list).into();`-shaped call site or
4098/// a `DepList::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
4099/// iterator over `&'static [DepList]` yields `&DepList` by construction)
4100/// — a per-`:deps` / `:deps-dev` census-key materializer that stashes the
4101/// dep-list discriminator in a [`Box<str>`]-typed heap-owned scalar for
4102/// cheap clone off a borrowed handle, a future M4 admission-webhook
4103/// rejection body whose per-arm [`Box<str>`] field composes from a
4104/// borrowed [`DepList`] handle off a `&DepList` borrow, a future
4105/// `feira lint --explain-dep-list` per-axis listing that iterates
4106/// [`DepList::ALL`] into per-arm owned [`Box<str>`] labels — reaches the
4107/// same two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4108/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4109/// the sibling `{Self, &Self} × {&'static str, String, Cow<'static, str>}`
4110/// forward-projection corner and the paired owned-input
4111/// [`From<DepList> for Box<str>`] already return.
4112///
4113/// Rust's standard library carries `impl From<&str> for Box<str>` and
4114/// `impl From<String> for Box<str>` but no blanket
4115/// `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
4116/// `impl<T: Copy, U: From<T>> From<&T> for U`), so this borrowed-input
4117/// axis is a distinct trait-idiomatic surface that the pipe shape
4118/// [`DepList::ALL`]`.iter().map(Box::<str>::from)` reaches through this
4119/// impl and no other — without it, the same pipe would force an explicit
4120/// `.copied()` restatement (`.iter().copied().map(Box::<str>::from)`)
4121/// whose type bounds have no compile-time link back to the substrate
4122/// primitive, and a `let key: Box<str> = (&list).into();`-shaped call
4123/// site would force an explicit `Copy` deref (`Box::<str>::from(*list)`)
4124/// or a `Box::<str>::from(list.as_str())` open-code with the same defect.
4125///
4126/// Closes the `{Self, &Self}` input-shape corner on the second caixa-
4127/// core-internal closed-set fieldless typed enum peer of the substrate-
4128/// wide trait-idiomatic [`Box<str>`] forward-projection campaign — one
4129/// commit after the paired render-side path-shape-diagnostic
4130/// [`crate::render::PathShapeViolation`] pair (0d87a72) opened the caixa-
4131/// core-internal tier — matching the trajectory the paired caixa-theme
4132/// [`caixa_theme::style::Semantic`] pair (0cd7dc3, both corners in one
4133/// axis), the caixa-provedor [`caixa_provedor::FerriteRuntime`] pair
4134/// (14886a8, both corners in one axis), and the render-side
4135/// [`crate::render::PathShapeViolation`] pair (0d87a72, both corners in
4136/// one axis) walked before it.
4137///
4138/// Same discipline as the paired outside-`caixa-core`,
4139/// [`crate::supervisor`], [`crate::aplicacao`], and [`crate::render`]
4140/// [`Box<str>`] `{Self, &Self}`-closers: forward emit (this impl, the
4141/// paired owned-input [`From<DepList> for Box<str>`] impl, the sibling
4142/// `{&'static str, String, Cow<'static, str>}` forward-projection corner,
4143/// [`std::fmt::Display`], [`AsRef<str>`], [`DepList::as_str`]) and reverse
4144/// parse ([`DepList::from_wire`], [`TryFrom<&str>`]) route through the
4145/// same two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4146/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4147/// by construction, so the round-trip composes directly without the
4148/// wire-vocab intermediate hop the peer [`crate::CaixaKind`] axis pair
4149/// requires.
4150///
4151/// Pinned load-bearing by
4152/// [`tests::dep_list_from_borrowed_into_box_str_routes_through_as_str_accessor`]
4153/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4154/// [`DepList::ALL`] emit-set on the borrowed-input surface, plus a
4155/// blanket-derived [`Into`] shape witness, plus a
4156/// `.iter().map(Box::<str>::from)` pipe witness over [`DepList::ALL`] —
4157/// whose iterator yields `&DepList` by construction, so the borrowed-
4158/// input [`Box<str>`] axis is what routes the pipe through the substrate-
4159/// primitive [`DepList::as_str`] accessor without a spurious [`Copy`]
4160/// deref).
4161impl From<&DepList> for Box<str> {
4162    fn from(list: &DepList) -> Box<str> {
4163        Box::<str>::from(list.as_str())
4164    }
4165}
4166
4167/// Trait-idiomatic *owned-input, [`std::sync::Arc<str>`] output* forward
4168/// projection on the outside-M3 caixa-core two-list dep-graph [`DepList`]
4169/// closed-set fieldless typed enum. Routes byte-for-byte through the
4170/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor via
4171/// [`std::sync::Arc::<str>::from`] on the returned `&'static str`, so
4172/// every consumer that binds a
4173/// `let key: std::sync::Arc<str> = list.into();`-shaped call site reaches
4174/// the same two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4175/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4176/// the sibling
4177/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>}`
4178/// forward-projection corner already returns.
4179///
4180/// Rust's standard library carries `impl From<&str> for std::sync::Arc<str>`
4181/// and `impl From<String> for std::sync::Arc<str>` but no blanket
4182/// `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
4183/// `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so this axis
4184/// is a distinct trait-idiomatic surface that a
4185/// `let key: std::sync::Arc<str> = list.into();`-shaped call site reaches
4186/// through this impl and no other — a paired
4187/// `std::sync::Arc::<str>::from(list.as_str())` open-code has no compile-
4188/// time link back to the substrate primitive, and a two-step
4189/// `std::sync::Arc::<str>::from(String::from(list))` composition through
4190/// the owned-`String` axis allocates twice (once into the intermediate
4191/// `String`, once into the [`std::sync::Arc<str>`] on the `From<String>`
4192/// conversion) where the single-step trait impl allocates once. The
4193/// shared-ownership + [`Sync`] + [`Send`] contract [`std::sync::Arc<str>`]
4194/// provides is the distinct value the sibling [`Box<str>`] axis's owned-
4195/// move return-shape cannot provide — a per-`:deps` / `:deps-dev` census
4196/// key reachable from multiple concurrent per-Caixa reconcile / per-lint
4197/// tasks through the same two lifted
4198/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4199/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-strings, without a
4200/// `.clone()`-per-task materialization the owned-move [`Box<str>`] axis
4201/// would force.
4202///
4203/// Extends the caixa-core-internal tier of the substrate-wide trait-
4204/// idiomatic [`std::sync::Arc<str>`] forward-projection campaign onto the
4205/// second caixa-core-internal peer, after the top-level
4206/// [`crate::CaixaKind`] pair (c17be64, both corners in one axis) opened
4207/// the tier. Follows the M2 OTP-shape
4208/// [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
4209/// pair (bca2ec8 + b3e72d7 / b05724e + ea91551), the M3 mesh-shape
4210/// [`crate::aplicacao::PlacementStrategy`] / [`crate::aplicacao::WitShape`] /
4211/// [`crate::aplicacao::RateLimitUnit`] triple (977d577 → dae722f), and
4212/// the outside-`caixa-core` tier (`InvariantKind` 4e923c1 + 03c043f,
4213/// `ArchVerdict` 1682f8b + 92ddfb2, `Severity` a7a9a6d + 4f041e1,
4214/// `FixSafety` fb73edb + 822138e, `Semantic` 65dbcff + f3a55c7,
4215/// `FerriteRuntime` 938d915 + 0afef4b) that closed prior tiers on this
4216/// same Arc<str> axis. Same discipline as those peers: forward emit
4217/// (this impl, the sibling
4218/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>}`
4219/// forward-projection corner, [`std::fmt::Display`], [`AsRef<str>`],
4220/// [`DepList::as_str`]) and reverse parse ([`DepList::from_wire`],
4221/// [`TryFrom<&str>`]) route through the same two lifted
4222/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4223/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-
4224/// strings by construction, so the round-trip composes directly without
4225/// the wire-vocab intermediate hop the peer [`crate::CaixaKind`] axis
4226/// pair requires.
4227///
4228/// A future variant addition (a `Build` build-time-only dep-list axis the
4229/// CAIXA-SDLC hints name as a trajectory item once the Cargo
4230/// `[build-dependencies]` table gains substrate visibility) reaches the
4231/// paired [`std::sync::Arc<str>`] output axis through one match-arm edit
4232/// on the [`DepList::as_str`] `pub const fn` accessor, not a coordinated
4233/// rewrite of every downstream
4234/// `std::sync::Arc::<str>::from(list.as_str())` open-code.
4235///
4236/// Pinned load-bearing by
4237/// [`tests::dep_list_from_into_arc_str_routes_through_as_str_accessor`]
4238/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4239/// [`DepList::ALL`] emit-set on the owned-input surface, plus a blanket-
4240/// derived [`Into`] shape witness and cross-axis byte-parity pins against
4241/// the sibling owned-input
4242/// `{&'static str, String, Cow<'static, str>, Box<str>}` return-shape
4243/// axes).
4244impl From<DepList> for std::sync::Arc<str> {
4245    fn from(list: DepList) -> std::sync::Arc<str> {
4246        std::sync::Arc::<str>::from(list.as_str())
4247    }
4248}
4249
4250/// Trait-idiomatic *borrowed-input, [`std::sync::Arc<str>`] output*
4251/// forward projection on the outside-M3 caixa-core two-list dep-graph
4252/// [`DepList`] closed-set fieldless typed enum — the borrowed-input
4253/// companion to the paired owned-input
4254/// [`From<DepList> for std::sync::Arc<str>`] impl immediately above.
4255/// Routes byte-for-byte through the substrate-primitive
4256/// [`DepList::as_str`] `pub const fn` accessor via
4257/// [`std::sync::Arc::<str>::from`] on the returned `&'static str`, so
4258/// every consumer that binds a
4259/// `let key: std::sync::Arc<str> = (&list).into();`-shaped call site or a
4260/// `DepList::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped pipe
4261/// (whose iterator over `&'static [DepList]` yields `&DepList` by
4262/// construction) reaches the same two lifted
4263/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4264/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-
4265/// strings the paired owned-input
4266/// [`From<DepList> for std::sync::Arc<str>`] and the sibling
4267/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>}`
4268/// forward-projection corner already return.
4269///
4270/// Rust's standard library carries `impl From<&str> for std::sync::Arc<str>`
4271/// and `impl From<String> for std::sync::Arc<str>` but no blanket
4272/// `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a `Copy`-
4273/// based `impl<T: Copy, U: From<T>> From<&T> for U`), so this borrowed-
4274/// input axis is a distinct trait-idiomatic surface that the pipe shape
4275/// [`DepList::ALL`]`.iter().map(std::sync::Arc::<str>::from)` reaches
4276/// through this impl and no other — without it, the same pipe would
4277/// force a spurious [`Copy`] deref
4278/// (`std::sync::Arc::<str>::from((*list).as_str())`) or a `.copied()`
4279/// restatement whose type bounds have no compile-time link back to the
4280/// substrate primitive.
4281///
4282/// Closes the `{Self, &Self}` input-shape corner on the second caixa-
4283/// core-internal closed-set fieldless typed enum peer of the substrate-
4284/// wide trait-idiomatic [`std::sync::Arc<str>`] forward-projection
4285/// campaign — one commit after the paired top-level [`crate::CaixaKind`]
4286/// pair (c17be64) opened the caixa-core-internal Arc<str> tier — matching
4287/// the trajectory the paired top-level [`crate::CaixaKind`] pair
4288/// (c17be64, both corners in one axis) walked before it. Leaves the
4289/// remaining caixa-core-internal closed-set fieldless typed enum peers
4290/// ([`crate::dialeto::CaixaDialeto`],
4291/// [`crate::render::PathShapeViolation`]) as the campaign's next multi-
4292/// peer targets on the caixa-core-internal tier of the Arc<str> axis.
4293///
4294/// Pinned load-bearing by
4295/// [`tests::dep_list_from_borrowed_into_arc_str_routes_through_as_str_accessor`]
4296/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4297/// [`DepList::ALL`] emit-set on the borrowed-input surface, plus a
4298/// blanket-derived [`Into`] shape witness, a cross-axis partition pin
4299/// against the paired owned-input
4300/// [`From<DepList> for std::sync::Arc<str>`] and the sibling borrowed-
4301/// input `{&'static str, String, Cow<'static, str>, Box<str>}` return-
4302/// shape axes, and a `.iter().map(std::sync::Arc::<str>::from)` pipe
4303/// witness over [`DepList::ALL`] that resolves through the borrowed-
4304/// input axis without a spurious [`Copy`] deref).
4305impl From<&DepList> for std::sync::Arc<str> {
4306    fn from(list: &DepList) -> std::sync::Arc<str> {
4307        std::sync::Arc::<str>::from(list.as_str())
4308    }
4309}
4310
4311/// Trait-idiomatic *owned-input, [`std::rc::Rc<str>`] output* forward
4312/// projection on the outside-M3 caixa-core two-list dep-graph
4313/// [`DepList`] closed-set fieldless typed enum — routes byte-for-byte
4314/// through the substrate-primitive [`DepList::as_str`] `pub const fn`
4315/// accessor via [`std::rc::Rc::<str>::from`] on the returned
4316/// `&'static str`, so every consumer that binds a [`DepList`] through
4317/// the standard-library `.into()` / `From::from` surfaces onto the
4318/// non-atomic single-threaded-reference-counted `std::rc::Rc<str>` axis
4319/// reaches the same two lifted
4320/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4321/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-
4322/// strings the sibling `{&'static str, String, Cow<'static, str>,
4323/// Box<str>, std::sync::Arc<str>}` return-shape axes already return.
4324///
4325/// Rust's standard library carries `impl From<&str> for
4326/// std::rc::Rc<str>` and `impl From<String> for std::rc::Rc<str>` but
4327/// no blanket `impl<T: AsRef<str>> From<T> for std::rc::Rc<str>`, and
4328/// the [`std::sync::Arc<str>`] and [`std::rc::Rc<str>`] trait tables
4329/// are disjoint — so a single-threaded caixa-core dep-graph pass whose
4330/// per-list `:deps` / `:deps-dev` bucket key is cloned across intra-
4331/// pass tree nodes through the cheaper non-atomic [`std::rc::Rc<str>`]
4332/// refcount (the atomically-reference-counted [`std::sync::Arc<str>`]
4333/// axis cannot elide the CAS-fence cost within a single-threaded
4334/// caixa-core pass), a future `feira dep --list <deps|deps-dev>`-
4335/// side per-list histogram-column emitter keyed on a shared-ownership
4336/// per-arm bucket key, a future `caixa-lsp`-side dep-graph quick-fix
4337/// panel composer holding a shared per-list canonical `:`-prefixed
4338/// kebab tag across intra-file dep tree nodes without atomic contention
4339/// — reaches the substrate primitive through this impl and no other.
4340/// A paired `std::rc::Rc::<str>::from(list.as_str())` open-code has no
4341/// compile-time link back to the substrate primitive, and a two-step
4342/// `std::rc::Rc::<str>::from(String::from(list))` composition through
4343/// the owned-`String` axis allocates twice (once into the intermediate
4344/// `String`, once into the [`std::rc::Rc<str>`] on the `From<String>`
4345/// conversion) where the single-step trait impl allocates once.
4346///
4347/// Opens the caixa-core-internal tier of the [`std::rc::Rc<str>`]
4348/// forward-projection campaign onto the caixa-core two-list dep-graph
4349/// peer, following the trajectory the paired top-level
4350/// [`crate::CaixaKind`] pair (e04aff0), the second caixa-core-internal
4351/// peer [`crate::dialeto::CaixaDialeto`] pair (c5595e5), the render-
4352/// side path-shape-diagnostic peer [`crate::render::PathShapeViolation`]
4353/// pair (31fc43e), the M3-mesh-primitive-defining
4354/// [`crate::aplicacao::PlacementStrategy`] pair (91b4c92), and the
4355/// outside-`caixa-core` peers (`InvariantKind` c71818b, `ArchVerdict`
4356/// cc759ef, `Severity` d7c58b6, `FixSafety` 046cc5f) walked before it
4357/// on the same axis — closes the caixa-core-internal tier's third-peer
4358/// slot after the render-side [`crate::render::PathShapeViolation`]
4359/// second-peer pair. Leaves the outside-`caixa-core` peers
4360/// (`caixa_theme::Semantic`, `caixa_provedor::FerriteRuntime`) as the
4361/// campaign's next multi-peer targets on the [`std::rc::Rc<str>`] axis.
4362///
4363/// Pinned load-bearing by
4364/// [`tests::dep_list_from_into_rc_str_routes_through_as_str_accessor`]
4365/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4366/// [`DepList::ALL`] emit-set on the owned-input surface, plus a
4367/// blanket-derived [`Into`] shape witness and cross-axis byte-parity
4368/// pins against the sibling owned-input `{&'static str, String,
4369/// Cow<'static, str>, Box<str>, std::sync::Arc<str>}` return-shape
4370/// axes).
4371impl From<DepList> for std::rc::Rc<str> {
4372    fn from(list: DepList) -> std::rc::Rc<str> {
4373        std::rc::Rc::<str>::from(list.as_str())
4374    }
4375}
4376
4377/// Trait-idiomatic *borrowed-input, [`std::rc::Rc<str>`] output*
4378/// forward projection on the outside-M3 caixa-core two-list dep-graph
4379/// [`DepList`] closed-set fieldless typed enum — the borrowed-input
4380/// companion to the paired owned-input
4381/// [`From<DepList> for std::rc::Rc<str>`] impl immediately above,
4382/// closing the `{Self, &Self}` input-shape corner of the caixa-core-
4383/// internal tier of the [`std::rc::Rc<str>`] axis on the two-list
4384/// dep-graph peer. Routes byte-for-byte through the substrate-primitive
4385/// [`DepList::as_str`] `pub const fn` accessor via
4386/// [`std::rc::Rc::<str>::from`] on the returned `&'static str`, so a
4387/// `DepList::ALL.iter().map(std::rc::Rc::<str>::from)`-shaped pipe
4388/// (whose iterator over `&'static [DepList]` yields `&DepList` by
4389/// construction) reaches the same two lifted
4390/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4391/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-
4392/// strings the paired owned-input axis and the sibling
4393/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>,
4394/// std::sync::Arc<str>}` forward-projection corner already return.
4395///
4396/// Rust's standard library carries no blanket
4397/// `impl<T: AsRef<str>> From<&T> for std::rc::Rc<str>` (nor a `Copy`-
4398/// based `impl<T: Copy, U: From<T>> From<&T> for U`), so this borrowed-
4399/// input axis is a distinct trait-idiomatic surface that the pipe
4400/// shape [`DepList::ALL`]`.iter().map(std::rc::Rc::<str>::from)`
4401/// reaches through this impl and no other — without it, the same pipe
4402/// would force a spurious [`Copy`] deref
4403/// (`std::rc::Rc::<str>::from((*list).as_str())`) or a `.copied()`
4404/// restatement whose type bounds have no compile-time link back to
4405/// the substrate primitive, and a `let key: std::rc::Rc<str> =
4406/// (&list).into();`-shaped call site would force an explicit [`Copy`]
4407/// deref (`std::rc::Rc::<str>::from(*list)`) or a
4408/// `std::rc::Rc::<str>::from(list.as_str())` open-code with the same
4409/// defect.
4410///
4411/// Closes the `{Self, &Self}` input-shape corner on the third caixa-
4412/// core-internal closed-set fieldless typed enum peer of the
4413/// substrate-wide trait-idiomatic [`std::rc::Rc<str>`] forward-
4414/// projection campaign, matching the trajectory the paired
4415/// [`crate::CaixaKind`] (e04aff0),
4416/// [`crate::dialeto::CaixaDialeto`] (c5595e5), and
4417/// [`crate::render::PathShapeViolation`] (31fc43e) pairs walked before
4418/// it on the caixa-core-internal tier of the same axis. Leaves the
4419/// outside-`caixa-core` peers ([`caixa_theme::Semantic`],
4420/// [`caixa_provedor::FerriteRuntime`]) as the campaign's next multi-
4421/// peer targets on the [`std::rc::Rc<str>`] axis — this commit gives
4422/// them a fifth-peer `{Self, &Self}` caixa-core-internal-tier template
4423/// to converge onto.
4424///
4425/// Pinned load-bearing by
4426/// [`tests::dep_list_from_borrowed_into_rc_str_routes_through_as_str_accessor`]
4427/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4428/// [`DepList::ALL`] emit-set on the borrowed-input surface, plus a
4429/// blanket-derived [`Into`] shape witness, a cross-axis partition pin
4430/// against the paired owned-input
4431/// [`From<DepList> for std::rc::Rc<str>`] and the sibling borrowed-
4432/// input `{&'static str, String, Cow<'static, str>, Box<str>,
4433/// std::sync::Arc<str>}` return-shape axes, and a
4434/// `.iter().map(std::rc::Rc::<str>::from)` pipe witness over
4435/// [`DepList::ALL`] that resolves through the borrowed-input axis
4436/// without a spurious [`Copy`] deref).
4437impl From<&DepList> for std::rc::Rc<str> {
4438    fn from(list: &DepList) -> std::rc::Rc<str> {
4439        std::rc::Rc::<str>::from(list.as_str())
4440    }
4441}
4442
4443/// Trait-idiomatic [`std::str::FromStr`] parse axis on the two-list
4444/// dep-graph [`DepList`] closed-set typed enum — routes byte-for-byte
4445/// through the paired [`TryFrom<&str> for DepList`] impl (which in
4446/// turn routes through the substrate-primitive [`DepList::from_wire`]
4447/// `Option<Self>` accessor), so `"...".parse::<DepList>()` /
4448/// `<DepList as FromStr>::from_str(…)` reaches the same two-arm
4449/// accept-set the sibling method-named [`DepList::from_wire`]
4450/// resolver and the paired [`TryFrom<&str>`] impl already resolve
4451/// against.
4452///
4453/// Opens the trait-idiomatic `str::parse`-axis campaign on the
4454/// substrate-wide closed-set fieldless typed-enum surface. The
4455/// substrate already carries three peers per enum on the projection
4456/// star: the method-named substrate-primitive pair
4457/// ([`DepList::as_str`] `pub const fn` accessor + [`DepList::from_wire`]
4458/// `Option<Self>` resolver), the emit-set trait pair
4459/// ([`std::fmt::Display`], [`AsRef<str>`], the owned-input +
4460/// borrowed-input `{&'static str, String, Cow<'static, str>, Box<str>,
4461/// std::sync::Arc<str>}` `From<{Self,&Self}>` return-shape matrix),
4462/// and the parse-set `TryFrom<&str>` reverse trait. [`FromStr`] is the
4463/// canonical Rust-idiomatic parse-set entry point every stdlib-shaped
4464/// consumer reaches for — [`str::parse::<T>()`] is a
4465/// `T: FromStr`-bounded generic, not a `T: for<'a> TryFrom<&'a str>`-
4466/// bounded one — so lifting [`FromStr`] onto the closed-set enum
4467/// unlocks the `.parse::<DepList>()` short-form on every consumer
4468/// (a future `feira dep --list <deps|deps-dev>` clap-style arg-parse
4469/// composes `arg.parse::<DepList>()`; a `serde` string-tagged
4470/// deserializer routes through the same `FromStr` bound; the future
4471/// M4 admission webhook's `Deserialize` derive reaches the enum
4472/// through its `FromStr` impl via `serde_with::DisplayFromStr`).
4473///
4474/// The impl trivially delegates to the paired [`TryFrom<&str>`] —
4475/// same `type Err = ()` deliberate-deferral shape the sibling
4476/// reverse-projection trait carries — so both trait-idiomatic
4477/// parse-axis paths (`TryFrom<&str>` and `FromStr::from_str`) resolve
4478/// to the same two-arm accept-set by construction. A future accept-set
4479/// widening (a `":packages"` rebrand, a `":dev-deps"` alias) reaches
4480/// every parse path through one edit on the substrate-primitive
4481/// [`DepList::from_wire`] accessor, not a coordinated rewrite across
4482/// the two reverse-projection trait impls.
4483///
4484/// Pinned load-bearing by
4485/// [`tests::dep_list_from_str_routes_through_try_from_str_impl`]
4486/// (byte-parity pin across the two-arm accept-set + delegated-
4487/// `.parse()`-projection witness) and
4488/// [`tests::dep_list_from_str_rejects_unknown_byte_strings`]
4489/// (rejection witness against silent accept-set widening).
4490impl std::str::FromStr for DepList {
4491    type Err = ();
4492
4493    fn from_str(s: &str) -> Result<Self, Self::Err> {
4494        <Self as TryFrom<&str>>::try_from(s)
4495    }
4496}
4497
4498/// Substrate-canonical [`AsRef<[u8]>`] byte-view projection on the
4499/// caixa-core-internal two-list dep-graph [`DepList`] closed-set
4500/// fieldless typed enum — routes byte-for-byte through the substrate-
4501/// primitive [`DepList::as_str`] `pub const fn` accessor via
4502/// [`str::as_bytes`] on the returned `&'static str`, so any future
4503/// consumer that binds a [`DepList`] through a standard-library
4504/// `<T: AsRef<[u8]>>` trait bound reaches the same lifted
4505/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4506/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` roster
4507/// the paired sibling [`AsRef<str>`] / [`std::fmt::Display`] /
4508/// [`DepList::as_str`] / `{Self, &Self} × {&'static str, String,
4509/// Cow<'static, str>, Box<str>, std::sync::Arc<str>, std::rc::Rc<str>}`
4510/// str-view + reverse-projection surfaces already return — through the
4511/// byte-view axis, which the str-view axes cannot express.
4512///
4513/// The primary compounding target is the same [`crate`]-adjacent
4514/// [`caixa-lacre`](../../caixa-lacre/) BLAKE3 content-address closure
4515/// the peer [`crate::CaixaKind`] (69d8d86) and
4516/// [`crate::dialeto::CaixaDialeto`] (8151347) `AsRef<[u8]>` impls open
4517/// onto: [`blake3::hash`] and [`blake3::Hasher::update`] both bind
4518/// their input through `impl AsRef<[u8]>`, so any future per-caixa
4519/// content-address tag that folds a dep-list discriminator byte-tag
4520/// into the [`crate::Lacre`] closure (a hypothetical
4521/// `hasher.update(list);`-shape composition on the per-caixa BLAKE3
4522/// closure builder that partitions the runtime-closure `:deps` closure
4523/// from the dev-only-closure `:deps-dev` closure at content-address
4524/// time so a downstream `Lacre` consumer can key its per-list build
4525/// cache off the typed discriminator directly rather than the sibling
4526/// `&'static str` wire scalar) reaches the substrate-primitive
4527/// [`DepList::as_str`] accessor through this impl and no other —
4528/// without it, every such call site opens the two-hop composition
4529/// `list.as_str().as_bytes()` whose byte-tail has no compile-time link
4530/// back to the byte-projection axis. Peer consumer paths on the byte-
4531/// view axis: any future [`std::io::Write::write_all`]-bound
4532/// `feira dep census` per-list histogram-column emitter (whose input
4533/// binds through `impl AsRef<[u8]>`), any future byte-keyed
4534/// [`std::collections::HashMap`] `<K: AsRef<[u8]>, V>` per-list tally
4535/// lookup whose entry-key trait bound rules out the sibling
4536/// [`AsRef<str>`] str-view projection, and any future
4537/// `ring::digest::Context::update` / `sha2::Sha256::update` /
4538/// `blake3::Hasher::update` byte-input surface on any future per-list
4539/// content-address digest.
4540///
4541/// Rust's standard library carries `impl AsRef<[u8]> for str` and
4542/// `impl AsRef<[u8]> for String`, so the two-hop composition
4543/// `list.as_str().as_bytes()` (or, equivalently,
4544/// `AsRef::<str>::as_ref(&list).as_bytes()`) is reachable through the
4545/// pre-existing str-view axis alone. But that two-hop shape has no
4546/// compile-time link back to the byte-projection axis, forces every
4547/// downstream `<T: AsRef<[u8]>>`-bound consumer to open-code the two-
4548/// hop composition at every call site rather than pass a [`DepList`]
4549/// through the trait bound directly, and admits a silent split
4550/// whenever a future call site takes the sibling [`std::fmt::Display`]
4551/// or [`From<Self> for String`] axis (whose `.as_bytes()` byte-tails
4552/// byte-equal `as_str`'s by construction but carry no compile-time
4553/// byte-view surface, since `Display` returns a formatter and `String`
4554/// allocates). The lifted single-hop impl closes the byte-view axis so
4555/// every future `<T: AsRef<[u8]>>`-bound consumer reaches the
4556/// substrate primitive through one trait dispatch, and every future
4557/// arm addition (a `:build-dep` third list once the substrate grows
4558/// Cargo-style split-graphs, a `:tool-dep` for build-time-only tooling
4559/// per the peer Cargo `[build-dependencies]` /
4560/// `[target.<cfg>.dev-dependencies]` future admission surface — both
4561/// trajectory items the sibling [`DepList::from_wire`] doc block
4562/// already names) grows the byte-view axis through one edit on the
4563/// substrate-primitive `as_str` accessor, not a coordinated rewrite
4564/// across every future `<T: AsRef<[u8]>>`-bound consumer's arm-set.
4565///
4566/// Extends the trait-idiomatic *byte-view* axis onto the third
4567/// caixa-core-internal closed-set fieldless typed-enum peer on the
4568/// substrate — the two-list dep-graph enum — matching the trajectory
4569/// the sibling [`crate::CaixaKind`] first-mover [`AsRef<[u8]>`] impl
4570/// (69d8d86) and [`crate::dialeto::CaixaDialeto`] second-mover impl
4571/// (8151347) walked before it on the caixa-core tier of the byte-view
4572/// axis, and matching the discipline the paired sibling closed-set
4573/// fieldless typed enums already carry on the peer str-view
4574/// ([`AsRef<str>`]), parse ([`std::str::FromStr`]), and reverse-
4575/// projection (`{Self, &Self} × {&'static str, String,
4576/// Cow<'static, str>, Box<str>, std::sync::Arc<str>, std::rc::Rc<str>}`)
4577/// axes on this same enum. Unlike [`crate::CaixaKind`] — which carries
4578/// a two-axis split ([`crate::CaixaKind::as_str`] returning
4579/// lowercase-Portuguese diagnostic form vs
4580/// [`crate::CaixaKind::wire_name`] returning `PascalCase` tatara-lisp
4581/// author-surface bytes) — [`DepList`] carries a single canonical
4582/// axis: [`DepList::as_str`] returns the `:`-prefixed kebab-case
4583/// tatara-lisp author-surface key ([`crate::render::DEP_AUTHOR_KEY_DEPS`]
4584/// / [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`]), which is
4585/// simultaneously the wire form the paired [`DepList::from_wire`]
4586/// resolver reads back. The byte-view axis therefore lands on the
4587/// same `:`-prefixed kebab byte-string every str-view and reverse-
4588/// projection axis on this enum already returns, and no wire-axis
4589/// cross-witness applies.
4590///
4591/// Pinned load-bearing by
4592/// [`tests::dep_list_as_ref_bytes_routes_through_as_str_accessor`]
4593/// (fail-before-pass-after byte-parity pin against
4594/// [`DepList::as_str`] `.as_bytes()` across the two-arm
4595/// [`DepList::ALL`] emit-set, cross-axis witness against the paired
4596/// str-view [`AsRef<str>`] / [`std::fmt::Display`] /
4597/// [`DepList::as_str`] axes' `.as_bytes()` byte-tails, cross-axis
4598/// witness against the paired reverse-projection
4599/// `{&'static str, String, Cow<'static, str>, Box<str>,
4600/// std::sync::Arc<str>, std::rc::Rc<str>}` return-shape axes'
4601/// `.as_bytes()` byte-tails, a `<T: AsRef<[u8]>>`-bound-consumer
4602/// witness that a generic byte-input function accepts a [`DepList`]
4603/// directly through the trait bound on both owned and borrowed input
4604/// shapes, and a `blake3::Hasher::update`-shape byte-input surface
4605/// witness routed through the `<T: AsRef<[u8]>>`-bound consumer axis
4606/// to reach the caixa-lacre compounding target on both owned and
4607/// borrowed input shapes). Any future silent detour that routes the
4608/// byte-view impl off the substrate-primitive [`DepList::as_str`]
4609/// accessor (a per-arm inline `b":deps".as_slice()`-shaped re-inlining
4610/// that opens a compile-time link to the un-lifted arm-literal, a
4611/// hypothetical un-prefixed bare-kebab byte-string swap that would
4612/// silently collapse the `:`-prefixed tatara-lisp author-surface
4613/// discipline the sibling [`DepList::AUTHOR_KEYS`] doc block
4614/// explicitly pins) trips at caixa-core test time rather than at a
4615/// downstream byte-consumer's silent split.
4616impl AsRef<[u8]> for DepList {
4617    fn as_ref(&self) -> &[u8] {
4618        self.as_str().as_bytes()
4619    }
4620}
4621
4622/// Errors raised by [`Dep::validate`].
4623///
4624/// Mirrors the per-axis error families the other `:versao`-carrying
4625/// typed surfaces expose
4626/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
4627/// [`crate::AplicacaoError::MembroVersaoInvalid`],
4628/// [`crate::SupervisorError::EmptyChildVersion`] /
4629/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
4630/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
4631#[derive(Debug, Error, PartialEq, Eq)]
4632pub enum DepError {
4633    #[error(
4634        ":deps entry has empty :nome (every dep must name a target caixa; \
4635         omit the entry instead of carrying an empty name)"
4636    )]
4637    NomeEmpty,
4638    #[error(
4639        ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
4640         (the value flows verbatim as the target caixa's `:nome`, the rendered \
4641         `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
4642         value, and the resolver's checkout-directory leaf — each apiserver-side \
4643         schema rejects non-DNS-1123 names at admission time; use a lowercase \
4644         RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
4645         pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
4646    )]
4647    NomeInvalid { nome: String, reason: String },
4648    #[error(
4649        ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
4650         constraint that resolves through the lacre pipeline)"
4651    )]
4652    VersaoEmpty { nome: String },
4653    #[error(
4654        ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
4655         requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
4656         `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
4657         and `:children :versao` carry; the lacre pipeline resolves all three \
4658         through the same parser)"
4659    )]
4660    VersaoInvalid {
4661        nome: String,
4662        versao: String,
4663        reason: String,
4664    },
4665    #[error(
4666        ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
4667         (every git source must name a repo — use a `github:org/repo` \
4668         shorthand, an `https://…` URL, or an ssh-git URL; omit the \
4669         entire :fonte block to fall back to the default-host resolver \
4670         convention)"
4671    )]
4672    FonteRepoEmpty { nome: String },
4673    #[error(
4674        ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
4675         invalid value-shape: {reason} (the value flows verbatim into the \
4676         caixa-resolver's `git clone <repo>` subprocess invocation; every \
4677         documented form carries a `:` separator and no whitespace / \
4678         control / non-ASCII bytes — use a `github:org/repo` shorthand, \
4679         an `https://host/path` / `ssh://[user@]host/path` / \
4680         `git://host/path` / `file:///path` URL, or the `git@host:path` \
4681         scp-style SSH form)"
4682    )]
4683    FonteRepoShape {
4684        nome: String,
4685        repo: String,
4686        reason: String,
4687    },
4688    #[error(
4689        ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
4690         (set exactly one of :tag, :rev, or :branch so the resolver \
4691         can pick a reproducible commit; omit the entire :fonte block \
4692         to fall back to the default-host resolver convention, which \
4693         resolves the latest tag matching :versao)"
4694    )]
4695    FontePinMissing { nome: String },
4696    #[error(
4697        ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
4698         set ({pins}); exactly one of :tag, :rev, or :branch must be \
4699         set so the resolver's checkout target is unambiguous (the \
4700         resolver's silent precedence is :rev > :tag > :branch — if \
4701         you intended one specifically, drop the others)"
4702    )]
4703    FontePinAmbiguous { nome: String, pins: String },
4704    #[error(
4705        ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
4706         (a set pin must name a non-empty git ref; drop the {pin} key \
4707         entirely to fall through to another pin axis)"
4708    )]
4709    FontePinEmpty { nome: String, pin: String },
4710    #[error(
4711        ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
4712         value-shape: {reason} (the git porcelain enforces the same shape at \
4713         `git fetch` / `git checkout` time on every pin; use a leaf refname \
4714         like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
4715         `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
4716         drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
4717         prepends at clone time, and avoid abbreviated SHAs which are \
4718         ambiguous across repository history)"
4719    )]
4720    FontePinShape {
4721        nome: String,
4722        pin: String,
4723        value: String,
4724        reason: String,
4725    },
4726    #[error(
4727        ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
4728         (every path source must name a non-empty filesystem path; \
4729         omit the entire :fonte block to fall back to the default-host \
4730         resolver convention)"
4731    )]
4732    FonteCaminhoEmpty { nome: String },
4733    #[error(
4734        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
4735         absolute (the lacre pipeline embeds the value verbatim in its \
4736         per-dep content-address `path:{caminho}` at \
4737         caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
4738         BLAKE3 closure differ across machines — defeating the \
4739         reproducibility contract that's load-bearing for CSE; express \
4740         the path relative to the caixa.lisp location, e.g. \
4741         \"../caixa-teia\" for a sibling workspace dep)"
4742    )]
4743    FonteCaminhoAbsolute { nome: String, caminho: String },
4744    #[error(
4745        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4746         with `~` (the leading-tilde is a shell-expansion convention, not a \
4747         POSIX path component — `Path::is_absolute` returns false on it, so \
4748         the b94fd83 absolute-path gate doesn't catch it, but the lacre \
4749         pipeline embeds the value verbatim in its per-dep content-address \
4750         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4751         caixa-resolver folds it through `Path::join` without `~`-expansion, \
4752         so the build looks for a literal `./{caminho}` subdirectory and \
4753         fails at resolve time far from the source caixa.lisp; even worse, a \
4754         future caixa-resolver pass that *does* expand `~` would silently \
4755         re-open the host-layout-leak the b94fd83 absolute gate closes — \
4756         Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
4757         runners with different `$HOME` layouts resolve to two distinct paths \
4758         for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
4759         determinism contract; express the path relative to the caixa.lisp \
4760         location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
4761         spell out the full relative path explicitly if a workstation-rooted \
4762         dep is genuinely intended)"
4763    )]
4764    FonteCaminhoTildeExpansion { nome: String, caminho: String },
4765    #[error(
4766        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4767         with `$` (the leading-`$` is a shell-variable-expansion convention, \
4768         not a POSIX path component — `Path::is_absolute` returns false on it \
4769         and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
4770         embeds the value verbatim in its per-dep content-address \
4771         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4772         caixa-resolver folds it through `Path::join` without `$`-expansion, \
4773         so the build looks for a literal `./{caminho}` subdirectory and \
4774         fails at resolve time far from the source caixa.lisp; even worse, a \
4775         future caixa-resolver pass that *does* expand `$VAR` (the canonical \
4776         shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
4777         invites) would silently re-open the host-layout-leak the b94fd83 \
4778         absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
4779         Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
4780         layouts resolve to two distinct paths for the byte-identical caixa, \
4781         defeating the THEORY.md §V.2 render-determinism contract; express \
4782         the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
4783         for a sibling workspace dep, or spell out the full relative path \
4784         explicitly if a workstation-rooted dep is genuinely intended)"
4785    )]
4786    FonteCaminhoVarExpansion { nome: String, caminho: String },
4787    #[error(
4788        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4789         with a space (the leading ASCII space `0x20` is the orthogonal \
4790         paste-from-aligned-doc footgun that silently passes \
4791         `Path::is_absolute` and every prior leading-byte arm — \
4792         `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
4793         `./ ../caixa-teia` subdirectory the resolver fails to find at \
4794         resolve time with a non-self-locating `No such file or directory` \
4795         error far from the source caixa.lisp; the lacre pipeline embeds \
4796         the value verbatim in its per-dep content-address `path:{caminho}` \
4797         at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
4798         semantic-identical caixa values (` ../caixa-teia` vs \
4799         `../caixa-teia`) yield two distinct BLAKE3 closures across two \
4800         workstations whose authors differ only in paste-from-aligned- \
4801         caixa.lisp-doc whitespace habits — the most insidious failure \
4802         mode the typed slot can carry (no error surfaces; the divergence \
4803         is invisible until two machines compare lacres), defeating the \
4804         THEORY.md §V.2 render-determinism contract. The canonical \
4805         paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
4806         a multi-entry `:deps` block sits at the same column — an author \
4807         selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
4808         the rendered alignment into a fresh entry preserves the leading \
4809         whitespace verbatim); peer `:fonte :repo` axis already rejects \
4810         leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
4811         `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
4812         `is_chart_description_shape`, `:licenca` via \
4813         `is_spdx_expression_shape`. Drop the leading space; express the \
4814         path as a bare relative single-token like \"../caixa-teia\")"
4815    )]
4816    FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
4817    #[error(
4818        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4819         with `-` (the canonical CLI-argument-injection footgun on the \
4820         `:caminho` axis — the lacre pipeline embeds the value verbatim in \
4821         its per-dep content-address `path:{caminho}` at \
4822         caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
4823         through `Path::join` looking for a literal `./{caminho}` \
4824         subdirectory. Every downstream subprocess that consumes the resolved \
4825         path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
4826         `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
4827         `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
4828         value as a CLI flag rather than a positional path when the invocation \
4829         does not carry a `--` argument-list terminator between the flag block \
4830         and the path (the common case at every porcelain entry point). The \
4831         canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
4832         `:caminho \"-C\"` (`git -C -C` config-injection paste), \
4833         `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
4834         CLI-arg-injection vector at every git porcelain entry point that \
4835         consumes a path or URL argument, peer with is_git_repo_url's \
4836         leading-`-` arm on the sibling `:fonte :repo` axis), \
4837         `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
4838         POSIX `std::path::Path` treats a leading `-` as a literal filename \
4839         byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
4840         for a literal `./-rf` subdirectory that fails at resolve time with a \
4841         non-self-locating `No such file or directory` error far from the \
4842         source caixa.lisp — but on any downstream shell-out without `--` the \
4843         reinterpretation is silent and the failure mode is arbitrary-\
4844         argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
4845         rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
4846         arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
4847         leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
4848         CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
4849         DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
4850         `:children :caixa`, `:deps :nome`, cluster names); \
4851         `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
4852         the feira `init` / `add <nome>` positional gate (868c191) rejects \
4853         leading `-` on the CLI positional itself. Express the path as a bare \
4854         relative single-token like \"../caixa-teia\" — the sibling-workspace \
4855         directory name carries no leading-hyphen semantic, and `./` / `../` \
4856         prefixes structurally partition the leading-byte set to safe values.)"
4857    )]
4858    FonteCaminhoLeadingHyphen { nome: String, caminho: String },
4859    #[error(
4860        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
4861         ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
4862         every `std::fs` syscall routes the path through `CString::new` which \
4863         fails with `NulError` at resolve time; the lacre pipeline embeds the \
4864         value verbatim in its per-dep content-address `path:{caminho}` at \
4865         caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
4866         value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
4867         determinism contract — the canonical paste-from-multiline-doc \
4868         (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
4869         blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
4870         (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
4871         already gates against. Express the path as a relative single-line ASCII \
4872         string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
4873    )]
4874    FonteCaminhoControlChar {
4875        nome: String,
4876        caminho: String,
4877        byte: u8,
4878    },
4879    #[error(
4880        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
4881         (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
4882         component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
4883         not the parent's sibling — and the caixa-resolver folds the value through \
4884         `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
4885         resolve time with a non-self-locating `No such file or directory` error far \
4886         from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
4887         primary path separator equal to `/`, so byte-identical caixa.lisp values \
4888         resolve to two distinct directories across runner OSes — the lacre pipeline \
4889         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4890         caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
4891         determinism contract via the cross-host-OS-separator divergence vector. The \
4892         canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
4893         paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
4894         rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
4895         and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
4896         byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
4897         \"../caixa-teia\" for a sibling workspace dep)"
4898    )]
4899    FonteCaminhoBackslash { nome: String, caminho: String },
4900    #[error(
4901        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4902         redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
4903         zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
4904         operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
4905         paste-from-shell-pipeline footgun where an author copies a `command > log` \
4906         tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
4907         as literal path-component bytes, so the resolver folds the value through \
4908         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4909         subdirectory and fails at resolve time with a non-self-locating `No such \
4910         file or directory` error far from the source caixa.lisp. The lacre pipeline \
4911         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4912         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
4913         and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4914         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4915         canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
4916         peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
4917         `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
4918         `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
4919         RFC-3986-reserved set. Express the path as a bare relative single-token like \
4920         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4921         redirection semantic.",
4922        ch = *byte as char
4923    )]
4924    FonteCaminhoShellRedirection {
4925        nome: String,
4926        caminho: String,
4927        byte: u8,
4928    },
4929    #[error(
4930        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
4931         metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
4932         `|` as the pipe operator that wires one command's stdout to the next command's \
4933         stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
4934         shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
4935         without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
4936         symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
4937         treats `|` as a literal path-component byte, so the resolver folds the value \
4938         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4939         subdirectory and fails at resolve time with a non-self-locating `No such file or \
4940         directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
4941         value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
4942         src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
4943         shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
4944         shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
4945         subprocess-argument / shell-metachar injection surface every peer single-token-\
4946         shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
4947         via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4948         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4949         workspace directory name carries no shell-pipe semantic."
4950    )]
4951    FonteCaminhoShellPipe { nome: String, caminho: String },
4952    #[error(
4953        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4954         command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
4955         / nushell — lexes `;` as the sequential-command terminator that fires the next \
4956         command regardless of the prior command's exit status, so `:caminho \
4957         \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
4958         footgun where an author copies a `cd path; do-thing` chain without trimming \
4959         the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
4960         arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
4961         literal path-component byte, so the resolver folds the value through \
4962         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4963         subdirectory and fails at resolve time with a non-self-locating `No such file \
4964         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4965         the value verbatim in its per-dep content-address `path:{caminho}` at \
4966         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4967         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4968         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4969         canonical shell-metachar injection surface every peer single-token-shaped \
4970         typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
4971         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4972         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4973         workspace directory name carries no shell-command-separator semantic."
4974    )]
4975    FonteCaminhoShellSemicolon { nome: String, caminho: String },
4976    #[error(
4977        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4978         background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
4979         / fish / nushell — lexes `&` two ways: single `&` as the background-task \
4980         terminator detaching the prior command and returning control immediately to \
4981         the prompt, double `&&` as the logical-AND list operator firing the next \
4982         command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
4983         literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
4984         sleep 1` background-launch one-liner or a `cd path && make install` build-\
4985         chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
4986         05c358e closed the sequential-command-separator vector, this arm closes the \
4987         orthogonal background-task / logical-AND vector on the same paste-from-shell-\
4988         prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
4989         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4990         byte lands in the BLAKE3 closure and rides into every shell-spawned \
4991         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4992         future operator-side `nix` spawn) as the canonical shell-metachar injection \
4993         surface every peer single-token-shaped typed slot already closes. The peer \
4994         `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
4995         byte RFC-3986-reserved set. Express the path as a bare relative single-token \
4996         like \"../caixa-teia\" — the sibling-workspace directory name carries no \
4997         shell-background / logical-AND semantic."
4998    )]
4999    FonteCaminhoShellBackground { nome: String, caminho: String },
5000    #[error(
5001        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5002         command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
5003         dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
5004         wrapper that runs the enclosed command and substitutes its standard-output \
5005         verbatim into the surrounding word, so a backticked `whoami` expands to the \
5006         current user's name and a backticked `cat /etc/passwd` expands to the file's \
5007         contents — the canonical CWE-78 shell-command-injection vector; POSIX \
5008         `std::path::Path` treats the byte as a literal path-component byte. The canonical \
5009         paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
5010         one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
5011         into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
5012         background / logical-AND vector, this arm closes the orthogonal command-\
5013         substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
5014         form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
5015         the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
5016         value verbatim in its per-dep content-address `path:{caminho}` at \
5017         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5018         rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
5019         `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
5020         shell-metachar injection surface every peer single-token-shaped typed slot \
5021         already closes. The peer `:entrada :paths` axis rejects the byte via \
5022         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
5023         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5024         directory name carries no shell-command-substitution semantic."
5025    )]
5026    FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
5027    #[error(
5028        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5029         glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
5030         sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
5031         expansion wildcards: `*` matches any sequence of characters in a path component \
5032         and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
5033         canonical paste-from-shell-listing footgun where an author copies a \
5034         `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
5035         \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
5036         `std::path::Path` treats both bytes as literal path-component bytes, so the \
5037         resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
5038         a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
5039         locating `No such file or directory` error far from the source caixa.lisp. The \
5040         lacre pipeline embeds the value verbatim in its per-dep content-address \
5041         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
5042         BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
5043         `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
5044         spawn) as the canonical shell-metachar / glob-expansion surface every peer \
5045         single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
5046         rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
5047         reserved set. Express the path as a bare relative single-token like \
5048         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
5049         / pathname-expansion semantic.",
5050        ch = *byte as char
5051    )]
5052    FonteCaminhoShellGlob {
5053        nome: String,
5054        caminho: String,
5055        byte: u8,
5056    },
5057    #[error(
5058        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5059         subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
5060         zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
5061         operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
5062         (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
5063         subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
5064         modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
5065         arm closes the leading byte of — together the two arms now structurally exclude the \
5066         entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
5067         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
5068         `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
5069         modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
5070         (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
5071         every prior arm and the resolver folds the value through `Path::new(caminho).join(\
5072         <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
5073         self-locating `No such file or directory` error far from the source caixa.lisp. The \
5074         lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
5075         {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
5076         closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5077         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
5078         shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
5079         already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
5080         same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
5081         together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
5082         of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
5083         like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5084         subshell-grouping semantic.",
5085        ch = *byte as char
5086    )]
5087    FonteCaminhoShellSubshellGrouping {
5088        nome: String,
5089        caminho: String,
5090        byte: u8,
5091    },
5092    #[error(
5093        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5094         brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
5095         (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
5096         `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
5097         comma-separated members and `{{1..10}}` expands to the integer range — the \
5098         canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
5099         idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
5100         URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
5101         substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
5102         library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
5103         Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
5104         templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
5105         `std::path::Path` treats the byte as a literal path-component byte, so a \
5106         `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
5107         shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
5108         caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
5109         idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
5110         silently passes every prior arm and the resolver folds the value through \
5111         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5112         resolve time with a non-self-locating `No such file or directory` error far from \
5113         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
5114         per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
5115         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
5116         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
5117         future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
5118         expansion / URI-Template-placeholder surface every peer single-token-shaped \
5119         typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
5120         same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
5121         RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
5122         bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5123         directory name carries no shell-brace-expansion / URI-Template-placeholder \
5124         semantic; if two siblings actually need pinning, author two separate `:deps` \
5125         entries rather than one brace-expanded `:caminho` value.",
5126        ch = *byte as char
5127    )]
5128    FonteCaminhoShellBraceExpansion {
5129        nome: String,
5130        caminho: String,
5131        byte: u8,
5132    },
5133    #[error(
5134        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5135         bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
5136         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
5137         — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
5138         `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
5139         canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
5140         glob every shell-history block carries; the bracket pair additionally carries the \
5141         POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
5142         script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
5143         the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
5144         canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
5145         delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
5146         leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
5147         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
5148         `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
5149         character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
5150         (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
5151         leak) silently passes every prior arm and the resolver folds the value through \
5152         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5153         resolve time with a non-self-locating `No such file or directory` error far from \
5154         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
5155         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
5156         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5157         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
5158         `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
5159         surface every peer single-token-shaped typed slot already closes. Express the path \
5160         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5161         directory name carries no shell-bracket-expansion / glob-character-class / array-\
5162         literal semantic; if a family of sibling caixas actually needs pinning, author \
5163         separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
5164        ch = *byte as char
5165    )]
5166    FonteCaminhoShellBracketExpansion {
5167        nome: String,
5168        caminho: String,
5169        byte: u8,
5170    },
5171    #[error(
5172        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5173         quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
5174         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
5175         nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
5176         and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
5177         substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
5178         every path-with-embedded-whitespace paste block carries and the symmetric \
5179         `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
5180         Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
5181         the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
5182         and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
5183         paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
5184         basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
5185         paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
5186         delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
5187         entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
5188         footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
5189         both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
5190         production. POSIX `std::path::Path` treats the byte as a literal path-component \
5191         byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
5192         strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
5193         (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
5194         from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
5195         shape) silently passes every prior arm and the resolver folds the value through \
5196         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
5197         resolve time with a non-self-locating `No such file or directory` error far from \
5198         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
5199         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
5200         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5201         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
5202         `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
5203         every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5204         axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
5205         banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
5206         `is_git_repo_url`). Express the path as a bare relative single-token like \
5207         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
5208         grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
5209         paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
5210         quoting on the outer syntactic layer, so an inner quote pair would nest and \
5211         desugar to a broken layer).",
5212        ch = *byte as char
5213    )]
5214    FonteCaminhoShellQuoteGrouping {
5215        nome: String,
5216        caminho: String,
5217        byte: u8,
5218    },
5219    #[error(
5220        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5221         comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
5222         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
5223         nushell — lexes an unquoted `#` at the head of a word or after unquoted \
5224         whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
5225         discarding the byte and everything after it to the end of the physical line \
5226         before command parsing (`cd ../caixa-teia  # legacy sibling` — the canonical \
5227         paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
5228         and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
5229         position preceded by whitespace or at line-start (`path: ../caixa-teia  # pin` \
5230         — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
5231         leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
5232         canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
5233         `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
5234         cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
5235         output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
5236         flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
5237         `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
5238         literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
5239         (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
5240         `:caminho \"../caixa-teia  # pin\"` (the symmetric YAML flow-scalar paste-with-\
5241         trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
5242         fragment paste-from-browser-address-bar shape) silently passes every prior arm \
5243         and the resolver folds the value through `Path::new(caminho).join(<file>)` \
5244         looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
5245         fails at resolve time with a non-self-locating `No such file or directory` \
5246         error far from the source caixa.lisp — while every downstream shell / YAML / \
5247         URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
5248         a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
5249         scalar disagree with the resolver on which directory the value names. The \
5250         lacre pipeline embeds the value verbatim in its per-dep content-address \
5251         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
5252         the BLAKE3 closure and rides into every shell-spawned subprocess (the \
5253         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
5254         side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
5255         fragment-delimiter surface every peer single-token-shaped typed slot already \
5256         closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
5257         fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
5258         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5259         workspace directory name carries no shell-comment / URL-fragment / YAML-\
5260         comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
5261         on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
5262         and drop any `#fragment` tail entirely (fragment identifiers select \
5263         renderings, not directories, and `:caminho` names a directory).",
5264        ch = *byte as char
5265    )]
5266    FonteCaminhoShellComment {
5267        nome: String,
5268        caminho: String,
5269        byte: u8,
5270    },
5271    #[error(
5272        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
5273         percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
5274         / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
5275         `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
5276         mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
5277         `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
5278         literally inside a URL value. The canonical paste-from-browser-address-bar \
5279         percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
5280         encoded README hyperlink / browser address bar / percent-encoded permalink \
5281         expecting `%20` to decode to a literal space at the filesystem layer) locks two \
5282         distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
5283         what the author intended as the byte-identical sibling-workspace dep. POSIX \
5284         `std::path::Path` treats the byte as a literal path-component byte, so \
5285         `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
5286         resolve time with a non-self-locating `No such file or directory` error far \
5287         from the source caixa.lisp — while every downstream URL parser / shell printf \
5288         builtin / YAML directive parser silently reinterprets the byte to a different \
5289         value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
5290         `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
5291         wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
5292         string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
5293         (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
5294         recent job whose command started with `foo`\" — a future `kill %1` invocation \
5295         silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
5296         directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
5297         directive block cross-idiom leak); and the Windows-shell env-var-reference \
5298         lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
5299         cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
5300         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
5301         byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
5302         (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5303         operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
5304         printf-format-specifier / job-control-specifier surface every peer single-\
5305         token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
5306         the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
5307         `is_git_repo_url`). Express the path as a bare relative single-token like \
5308         \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
5309         percent-encoding-escape / format-specifier / job-control semantic; substitute \
5310         any `%20` percent-encoded-space with a literal space then reject the whole \
5311         value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
5312         directory name never carries an embedded space in practice); drop any \
5313         `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
5314         `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
5315        ch = *byte as char
5316    )]
5317    FonteCaminhoUrlPercentEncoding {
5318        nome: String,
5319        caminho: String,
5320        byte: u8,
5321    },
5322    #[error(
5323        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5324         variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
5325         DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
5326         bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
5327         POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
5328         / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
5329         Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
5330         / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
5331         literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
5332         templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
5333         superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
5334         for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
5335         the byte is a first-class parser byte in nearly every config / templating / \
5336         build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
5337         `std::path::Path` treats the byte as a literal path-component byte, so the \
5338         canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
5339         from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
5340         prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
5341         cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
5342         `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
5343         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5344         subdirectory that fails at resolve time with a non-self-locating `No such file \
5345         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5346         the value verbatim in its per-dep content-address `path:{caminho}` at \
5347         caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
5348         only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
5349         time lock to two distinct BLAKE3 closures across two workstations whose \
5350         downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
5351         recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
5352         same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
5353         `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
5354         is the canonical CWE-78 shell-command-injection surface every peer single-\
5355         token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
5356         under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
5357         (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
5358         `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
5359         rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
5360         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
5361         position on the same axis routes through `FonteCaminhoVarExpansion` at the \
5362         f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
5363         so every position — leading and embedded — is structurally rejected. Substitute \
5364         the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
5365         time, or express the path as a bare relative single-token like \
5366         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5367         variable-expansion / command-substitution / arithmetic-expansion semantic.",
5368        ch = *byte as char
5369    )]
5370    FonteCaminhoShellVariableExpansion {
5371        nome: String,
5372        caminho: String,
5373        byte: u8,
5374    },
5375    #[error(
5376        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5377         history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
5378         `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
5379         `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
5380         reference §9.3: `!command` re-runs the most recent history entry beginning with \
5381         `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
5382         word of the prior command, `!:N` substitutes the Nth word of the prior command, \
5383         and the substitution fires at every history-expansion-enabled shell context — \
5384         `set -o histexpand` is bash's default for interactive sessions and the layer \
5385         every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
5386         invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
5387         §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
5388         a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
5389         encodes it inside a query component via the 'special-query percent-encode set' \
5390         the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
5391         also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
5392         prefix — the paste-from-source-code idiom where an author copies \
5393         `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
5394         the string-literal boundary); the canonical English-typography emphasis / \
5395         exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
5396         writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
5397         kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
5398         POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
5399         canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
5400         (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
5401         quick-start README and the trailing `!sudo` rides in verbatim as a history-\
5402         expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
5403         repeat-prior-command paste idiom), the English-typography `:caminho \
5404         \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
5405         substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
5406         arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
5407         / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
5408         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5409         subdirectory that fails at resolve time with a non-self-locating `No such file \
5410         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5411         the value verbatim in its per-dep content-address `path:{caminho}` at \
5412         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5413         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5414         future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
5415         as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
5416         peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5417         axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
5418         delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
5419         relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
5420         name carries no shell-history-expansion / bang-operator semantic; drop any \
5421         `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
5422         idiom; and drop any trailing English-typography exclamation mark that pasted \
5423         from prose.",
5424        ch = *byte as char
5425    )]
5426    FonteCaminhoShellHistoryExpansion {
5427        nome: String,
5428        caminho: String,
5429        byte: u8,
5430    },
5431    #[error(
5432        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5433         history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
5434         `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
5435         session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
5436         `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
5437         substitution' history operator that rewrites the prior command's `old` string to \
5438         `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
5439         (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
5440         history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
5441         `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
5442         the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
5443         `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
5444         literal value diverges from every downstream `feira tofu` curl-invocation / \
5445         artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
5446         the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
5447         C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
5448         metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
5449         `std::path::Path` treats `^` as a literal path-component byte, so \
5450         `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
5451         \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
5452         (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
5453         isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
5454         / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
5455         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
5456         that fails at resolve time with a non-self-locating `No such file or directory` \
5457         error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
5458         in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
5459         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
5460         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5461         operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
5462         / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
5463         The peer `:fonte :repo` axis closes the byte under the same shell-history-\
5464         substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
5465         with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
5466         histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
5467         prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
5468         path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5469         directory name carries no shell-history-substitution / regex-negation / XOR-operator \
5470         semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
5471         drop any trailing `^` history-substitution-open fragment.",
5472        ch = *byte as char
5473    )]
5474    FonteCaminhoShellHistorySubstitution {
5475        nome: String,
5476        caminho: String,
5477        byte: u8,
5478    },
5479    #[error(
5480        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
5481         `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
5482         `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
5483         value verbatim in its per-dep content-address `path:{caminho}` at \
5484         caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
5485         shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
5486         defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
5487         separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
5488         `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
5489         \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
5490         trailing `/`; every `:caminho` value names a sibling-workspace directory \
5491         already, so the trailing separator carries no information. Use \
5492         `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
5493    )]
5494    FonteCaminhoTrailingSlash { nome: String, caminho: String },
5495    #[error(
5496        "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
5497         entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
5498         apply the same set-not-multiset discipline; one package per table), and \
5499         two entries naming the same caixa carry two version constraints / source \
5500         pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
5501         consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
5502         silently overwrites the first at the resolver-side `concrete_versao` step, \
5503         and the dropped entry's pin / features never reach the closure — far from \
5504         the source caixa.lisp, with no field naming which `:deps` entry was the \
5505         silent loser. If two version constraints are genuinely needed (the rare \
5506         multi-version closure case the lacre pipeline doesn't yet support), the \
5507         author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
5508         `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
5509    )]
5510    DuplicateNome { nome: String, list: &'static str },
5511    #[error(
5512        ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
5513         name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
5514         applies the same per-entry non-empty discipline). An empty feature flag reaches the \
5515         caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
5516         author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
5517         with the canonical kebab-case feature name the target caixa declares."
5518    )]
5519    CaracteristicaEmpty { nome: String },
5520    #[error(
5521        ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
5522         feature name: {reason} (the value flows verbatim into Cargo's \
5523         [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
5524         parser enforces the same shape at `cargo metadata` time; use a single-token \
5525         identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
5526         alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
5527         an ASCII alphanumeric or `_`)"
5528    )]
5529    CaracteristicaInvalid {
5530        nome: String,
5531        caracteristica: String,
5532        reason: String,
5533    },
5534    #[error(
5535        ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
5536         every feature-flag list keys its entries by name (Cargo's \
5537         [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
5538         per feature per dep), and two entries naming the same feature are a redundant \
5539         set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
5540         enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
5541         pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
5542         feature once regardless of declaration count, so the duplicate's pin / position never \
5543         reaches the closure with no field naming the silent loser. One entry per feature per \
5544         dep; if two distinct features are intended, name each verbatim."
5545    )]
5546    CaracteristicaDuplicate {
5547        nome: String,
5548        caracteristica: String,
5549    },
5550    #[error(
5551        "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
5552         on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
5553         :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
5554         rejects mid-traversal far from the source caixa.lisp or recurses on until \
5555         it exhausts its stack). Every :nome is globally-unique substrate identity, \
5556         so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
5557         *is* the parent itself, not a coincidentally-named peer. Drop the \
5558         self-referential dep entry — to reference code from this caixa, use \
5559         :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
5560         referencing the caixa's own code surface) instead."
5561    )]
5562    DepIsSelf { nome: String, list: &'static str },
5563}
5564
5565// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5566// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
5567// [`DepSource::validate_caminho`] onto one substrate primitive per typed
5568// variant — the paired `{ nome: String, caminho: String }` two-slot family
5569// on [`DepError`], sibling of the peer
5570// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5571// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
5572// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
5573// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
5574// (981060b, 7 variants on `{ <field>: String, reason: String }`),
5575// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
5576// `{ de, para, wit, expected }`), and
5577// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
5578// variants on `{ de, para, <field>: String, reason: String }`) on the
5579// `AplicacaoError` envelopes, the peer
5580// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
5581// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
5582// (0419438, 4 variants on `{ caixa, kind, slots }`),
5583// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
5584// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
5585// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
5586// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
5587// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
5588// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
5589// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
5590// `UpgradeError` envelope. First fold family on this `DepError` envelope.
5591//
5592// Each of the eleven wire-up sites on this shape (the leading-byte cascade
5593// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
5594// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
5595// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
5596// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
5597// CommandSubstitution}` on the four single-byte shell operators; and the
5598// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
5599// opened the identical `DepError::FonteCaminho<Variant> { nome:
5600// nome.to_string(), caminho: caminho.to_string() }` four-line
5601// struct-literal against the same `(nome: &str, caminho: &str)` local pair
5602// — the exact "same block re-inlined at every consumer" shape the PRIME
5603// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
5604// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
5605// families each closed on their sibling envelopes. The eleven variants
5606// share one `{ nome: String, caminho: String }` shape, so the fold routes
5607// each wire-up site through one dispatch per typed variant.
5608//
5609// The macro below generates one `#[must_use]` inherent constructor per
5610// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
5611// wire-up site collapses onto one dispatch:
5612// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
5613// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
5614// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
5615// once — inside the macro — rather than at every wire-up site.
5616//
5617// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
5618// shapes at the per-byte-classification arms — the
5619// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
5620// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
5621// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
5622// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
5623// cluster — carry an additional `byte: u8` naming the offending byte and
5624// so would break the uniform-two-field routing this macro promises. They
5625// instead fold onto the sibling three-field envelope through
5626// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
5627// `{ nome, caminho, byte }` shape), whose sole additional axis over this
5628// two-slot family is the `byte: u8` classification the arms carry. The
5629// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
5630// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
5631// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
5632// envelope.
5633//
5634// Every future consumer that wants to construct one of these eleven
5635// variants outside the current in-crate [`DepSource::validate_caminho`]
5636// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5637// at lacre-resolve time re-checking the same value-shape axes the resolver
5638// consumes, a future `feira validate --deps` per-caixa admission verb
5639// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
5640// rejecting a `:caminho` value against a cluster-local snapshot) now
5641// reaches each variant through one call rather than re-inlining the
5642// four-line struct-literal in lockstep with the eleven in-crate wire-up
5643// sites.
5644macro_rules! fonte_caminho_ctors {
5645    ($($ctor:ident => $variant:ident),* $(,)?) => {
5646        impl DepError {
5647            $(
5648                #[doc = concat!(
5649                    "Construct a [`DepError::",
5650                    stringify!($variant),
5651                    "`] naming the offending `:deps :nome` + `:fonte ",
5652                    "(:tipo path …) :caminho` pair. Folds the uniform ",
5653                    "`Self::",
5654                    stringify!($variant),
5655                    " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
5656                    "two-slot struct-literal onto one substrate primitive so ",
5657                    "every [`DepSource::validate_caminho`] wire-up on this ",
5658                    "variant reads through one dispatch rather than the ",
5659                    "pre-lift four-line open-coded block."
5660                )]
5661                #[must_use]
5662                pub fn $ctor(nome: &str, caminho: &str) -> Self {
5663                    Self::$variant {
5664                        nome: nome.to_string(),
5665                        caminho: caminho.to_string(),
5666                    }
5667                }
5668            )*
5669        }
5670    };
5671}
5672
5673fonte_caminho_ctors! {
5674    fonte_caminho_absolute => FonteCaminhoAbsolute,
5675    fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
5676    fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
5677    fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
5678    fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
5679    fonte_caminho_backslash => FonteCaminhoBackslash,
5680    fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
5681    fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
5682    fonte_caminho_shell_background => FonteCaminhoShellBackground,
5683    fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
5684    fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
5685}
5686
5687// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5688// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
5689// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
5690// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
5691// three-slot family on [`DepError`], strict sibling of the peer
5692// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
5693// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
5694// that fold onto the `byte`-classifying arms whose additional `byte: u8`
5695// axis broke its uniform-two-field routing — the exact "future compounding
5696// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
5697// here. Third fold family on this `DepError` envelope, sibling of the peer
5698// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
5699// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
5700// same enum.
5701//
5702// Each of the twelve wire-up sites on this shape (the control-byte arm
5703// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
5704// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
5705// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
5706// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
5707// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
5708// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
5709// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
5710// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
5711// `FonteCaminhoShellHistoryExpansion` on `!`, and
5712// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
5713// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5714// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
5715// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
5716// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
5717// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
5718// closed on the sibling two-field envelope of this same enum. The twelve
5719// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
5720// the fold routes each wire-up site through one dispatch per typed variant.
5721//
5722// The macro below generates one `#[must_use]` inherent constructor per
5723// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
5724// so every wire-up site collapses onto one dispatch:
5725// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
5726// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
5727// three-field construction (`nome.to_string()` / `caminho.to_string()` /
5728// `byte`) is spelled once — inside the macro — rather than at every wire-up
5729// site.
5730//
5731// Every future consumer that wants to construct one of these twelve
5732// variants outside the current in-crate [`DepSource::validate_caminho`]
5733// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5734// at lacre-resolve time re-checking the same value-shape axes the resolver
5735// consumes, a future `feira validate --deps` per-caixa admission verb
5736// re-checking the `:fonte :caminho` axis against the shell-metachar
5737// classification bytes this cluster catches, a per-lacre overlay resolver
5738// rejecting a `:caminho` value against a cluster-local snapshot) now
5739// reaches each variant through one call rather than re-inlining the
5740// five-line struct-literal in lockstep with the twelve in-crate wire-up
5741// sites.
5742macro_rules! fonte_caminho_byte_ctors {
5743    ($($ctor:ident => $variant:ident),* $(,)?) => {
5744        impl DepError {
5745            $(
5746                #[doc = concat!(
5747                    "Construct a [`DepError::",
5748                    stringify!($variant),
5749                    "`] naming the offending `:deps :nome` + `:fonte ",
5750                    "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
5751                    "classification. Folds the uniform `Self::",
5752                    stringify!($variant),
5753                    " { nome: nome.to_string(), caminho: caminho.to_string(), ",
5754                    "byte }` three-slot struct-literal onto one substrate ",
5755                    "primitive so every [`DepSource::validate_caminho`] wire-up ",
5756                    "on this variant reads through one dispatch rather than ",
5757                    "the pre-lift five-line open-coded block."
5758                )]
5759                #[must_use]
5760                pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
5761                    Self::$variant {
5762                        nome: nome.to_string(),
5763                        caminho: caminho.to_string(),
5764                        byte,
5765                    }
5766                }
5767            )*
5768        }
5769    };
5770}
5771
5772fonte_caminho_byte_ctors! {
5773    fonte_caminho_control_char => FonteCaminhoControlChar,
5774    fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
5775    fonte_caminho_shell_glob => FonteCaminhoShellGlob,
5776    fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
5777    fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
5778    fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
5779    fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
5780    fonte_caminho_shell_comment => FonteCaminhoShellComment,
5781    fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
5782    fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
5783    fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
5784    fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
5785}
5786
5787// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
5788// single-slot struct-variant wire-up sites scattered across
5789// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
5790// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
5791// substrate primitive per typed variant — the paired `{ nome: String }`
5792// single-slot family on [`DepError`], sibling of the peer
5793// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
5794// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
5795// the same enum, and of the peer
5796// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5797// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
5798// axis. Second fold family on this `DepError` envelope, and the first on
5799// the single-`{ nome }` shape.
5800//
5801// The five wire-up sites this fold closes each opened the identical
5802// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
5803// struct-literal against the same `nome: &str` (or `self.nome: &String`)
5804// local — the exact "same block re-inlined at every consumer" shape the
5805// PRIME DIRECTIVE names as a bug. The five variants share one
5806// `{ nome: String }` shape, so the fold routes each wire-up site through
5807// one dispatch per typed variant.
5808//
5809// The macro below generates one `#[must_use]` inherent constructor per
5810// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
5811// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
5812// pre-lift struct-literal on the same `&str` fixture. The uniform
5813// one-field construction (`nome.to_string()`) is spelled once — inside
5814// the macro — rather than at every wire-up site. Callers that hold a
5815// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
5816// and lets the macro-owned `.to_string()` produce the fresh owning copy
5817// the enum variant needs; the semantics collapse onto the same
5818// `.clone()`-equivalent one this fold replaces at every site.
5819//
5820// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
5821// on the same envelope stays on its pre-lift open-coded wire-up shape —
5822// it carries no `nome` field (the offending `:nome` value *is* the empty
5823// string this variant catches) so the uniform `fn(nome: &str) -> Self`
5824// signature this macro promises does not apply. Every future consumer
5825// that wants to construct one of these five variants outside the current
5826// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
5827// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
5828// re-validator at lacre-resolve time, a future `feira validate --deps`
5829// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
5830// these empty-value shapes against a cluster-local snapshot) now reaches
5831// each variant through one call rather than re-inlining the three-line
5832// struct-literal in lockstep with the five in-crate wire-up sites.
5833macro_rules! dep_nome_only_ctors {
5834    ($($ctor:ident => $variant:ident),* $(,)?) => {
5835        impl DepError {
5836            $(
5837                #[doc = concat!(
5838                    "Construct a [`DepError::",
5839                    stringify!($variant),
5840                    "`] naming the offending `:deps :nome`. Folds the ",
5841                    "uniform `Self::",
5842                    stringify!($variant),
5843                    " { nome: nome.to_string() }` one-field ",
5844                    "struct-literal onto one substrate primitive so every ",
5845                    "in-crate wire-up on this variant reads through one ",
5846                    "dispatch rather than the pre-lift three-line ",
5847                    "open-coded block."
5848                )]
5849                #[must_use]
5850                pub fn $ctor(nome: &str) -> Self {
5851                    Self::$variant { nome: nome.to_string() }
5852                }
5853            )*
5854        }
5855    };
5856}
5857
5858dep_nome_only_ctors! {
5859    versao_empty => VersaoEmpty,
5860    fonte_repo_empty => FonteRepoEmpty,
5861    fonte_pin_missing => FontePinMissing,
5862    fonte_caminho_empty => FonteCaminhoEmpty,
5863    caracteristica_empty => CaracteristicaEmpty,
5864}
5865
5866// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
5867// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
5868// [`crate::manifest::Caixa::validate_deps`] +
5869// [`validate_no_self_dep`] onto one substrate-primitive family per
5870// typed variant — the `DepError`-side siblings of the peer
5871// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
5872// on the `SupervisorError { caixa: String }` one-slot envelope and of
5873// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
5874// `DepError { nome: String }` one-slot envelope. The two variants
5875// carry the same `{ nome: String, list: &'static str }` two-slot
5876// shape: the `nome` field names the offending dep the diagnostic
5877// points the author back at, and the `list` field carries the
5878// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
5879// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
5880// [`validate_deps`] arms, and via the paired
5881// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
5882// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
5883// canonicals on the [`validate_no_self_dep`] arm) so the author can
5884// grep their caixa.lisp for the offending list block in one edit.
5885//
5886// Each of the four wire-up sites opened the same struct-literal
5887// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
5888// two-line block — the exact "same block re-inlined at every
5889// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
5890// altitude the peer `DepError` / `SupervisorError` /
5891// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
5892// already closed on their sibling envelopes. The two `#[must_use]`
5893// inherent constructors below fold each wire-up onto one dispatch:
5894// `DepError::duplicate_nome(<nome>, <list>)` and
5895// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
5896// pre-lift struct-literal on the same scalar fixtures. The `list:
5897// &'static str` parameter (not `impl Into<String>`) preserves the
5898// exact wire tag every consumer already passes verbatim — no
5899// downstream diagnostic reshaping at the lift, matching the peer
5900// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
5901// contract each wire-up site already keys off.
5902macro_rules! dep_nome_list_ctors {
5903    ($($ctor:ident => $variant:ident),* $(,)?) => {
5904        impl DepError {
5905            $(
5906                #[doc = concat!(
5907                    "Construct a [`DepError::",
5908                    stringify!($variant),
5909                    "`] naming the offending `:deps :nome` and the ",
5910                    "author-surface list tag (`:deps` vs. `:deps-dev`) ",
5911                    "the diagnostic points the author back at. Folds ",
5912                    "the uniform `Self::",
5913                    stringify!($variant),
5914                    " { nome: nome.to_string(), list }` two-field ",
5915                    "struct-literal onto one substrate primitive so ",
5916                    "every in-crate wire-up on this variant reads ",
5917                    "through one dispatch rather than the pre-lift ",
5918                    "open-coded struct-literal block."
5919                )]
5920                #[must_use]
5921                pub fn $ctor(nome: &str, list: &'static str) -> Self {
5922                    Self::$variant { nome: nome.to_string(), list }
5923                }
5924            )*
5925        }
5926    };
5927}
5928
5929dep_nome_list_ctors! {
5930    duplicate_nome => DuplicateNome,
5931    dep_is_self => DepIsSelf,
5932}
5933
5934// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
5935// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
5936// <value>.to_string(), reason }` struct-variant wire-up sites at
5937// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
5938// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
5939// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
5940// primitive family per typed variant — the `DepError`-side siblings of the
5941// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
5942// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
5943// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
5944// the two-slot `{ nome, caminho }` envelope, and
5945// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
5946// caminho, byte }` envelope. The three variants share the same
5947// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
5948// the `nome` field names the offending dep the diagnostic points the
5949// author back at, the middle `<axis>: String` field carries the offending
5950// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
5951// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
5952// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
5953// field carries the parser-shaped rejection sentence the paired
5954// [`crate::render::require_valid_versao_requirement`] /
5955// [`crate::render::is_git_repo_url`] /
5956// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
5957// axis-field name differs across variants (`versao` / `repo` /
5958// `caracteristica`) so the ctor family below takes the axis field name as
5959// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
5960// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
5961// -> Self` inherent constructor per typed variant that spells the uniform
5962// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
5963// `reason` forwarded owned) exactly once. Peer of the sibling
5964// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
5965// family on the `AplicacaoError` envelope's mirror-symmetric
5966// `{ <field>: String, reason: String }` two-slot shape — same
5967// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
5968// one `nome`-axis added at the per-dep-owned altitude the `DepError`
5969// envelope keys off (every `DepError` variant carries the offending
5970// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
5971// offending block in one edit).
5972//
5973// The three wire-up sites this fold closes are:
5974// - [`DepSource::validate`]'s `:repo` value-shape arm
5975//   (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
5976//   repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
5977//   rejects the offending URL);
5978// - [`Dep::validate`]'s `:versao` requirement-shape arm
5979//   (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
5980//   self.versao_requirement().to_string(), reason }` inside the
5981//   [`crate::render::require_valid_versao_requirement`] callback pair);
5982// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
5983//   (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
5984//   caracteristica: c.clone(), reason })` after
5985//   [`crate::render::is_cargo_feature_name`] rejects the offending
5986//   feature-name).
5987//
5988// Each opened the identical five-line struct-literal against the same
5989// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
5990// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5991// same altitude the peer four already-lifted `DepError` ctor families
5992// closed on their sibling shape-envelopes. The three variant / axis-field
5993// discriminators are the only things that vary between them; the rest of
5994// the struct-literal is a byte-for-byte re-inline.
5995//
5996// Every future consumer wanting to raise one of these three diagnostics
5997// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
5998// time re-checking each declared dep against the same requirement +
5999// git-URL + feature-name value-shape cascade, a future `feira validate
6000// --deps` per-caixa admission verb re-running the shape gates on demand,
6001// a per-lacre overlay resolver rejecting an author-supplied dep against a
6002// cluster-local snapshot) now reaches one dispatch rather than re-inlining
6003// the five-line struct-literal in lockstep with the three in-crate
6004// wire-up sites.
6005macro_rules! dep_nome_axis_reason_ctors {
6006    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
6007        impl DepError {
6008            $(
6009                #[doc = concat!(
6010                    "Construct a [`DepError::",
6011                    stringify!($variant),
6012                    "`] naming the offending `:deps :nome`, the offending ",
6013                    "`:", stringify!($axis), "` axis value, and the ",
6014                    "parser-shaped rejection `reason`. Folds the uniform ",
6015                    "`Self::",
6016                    stringify!($variant),
6017                    " { nome: nome.to_string(), ",
6018                    stringify!($axis),
6019                    ": ",
6020                    stringify!($axis),
6021                    ".to_string(), reason }` three-field struct-literal ",
6022                    "onto one substrate primitive so every in-crate ",
6023                    "wire-up on this variant reads through one dispatch ",
6024                    "rather than the pre-lift five-line open-coded block. ",
6025                    "The `nome: &str` and `",
6026                    stringify!($axis),
6027                    ": &str` parameters accept `&str` literals and ",
6028                    "`&String` (via Deref coercion) so every existing ",
6029                    "wire-up threads through the ctor without a ",
6030                    "pre-conversion; the `reason: String` parameter takes ",
6031                    "an owned `String` (not `impl Into<String>`) matching ",
6032                    "the paired `crate::render::*` predicate's ",
6033                    "`Result<(), String>` return shape every wire-up ",
6034                    "already holds owned at the call site."
6035                )]
6036                #[must_use]
6037                pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
6038                    Self::$variant {
6039                        nome: nome.to_string(),
6040                        $axis: $axis.to_string(),
6041                        reason,
6042                    }
6043                }
6044            )*
6045        }
6046    };
6047}
6048
6049dep_nome_axis_reason_ctors! {
6050    versao_invalid => VersaoInvalid { versao },
6051    fonte_repo_shape => FonteRepoShape { repo },
6052    caracteristica_invalid => CaracteristicaInvalid { caracteristica },
6053}
6054
6055// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
6056// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
6057// <value>.to_string() }` struct-variant wire-up sites at
6058// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
6059// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
6060// per-entry set-not-multiset dedup closure onto one substrate-primitive
6061// family per typed variant — the missing two-slot rung on the
6062// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
6063// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
6064// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
6065// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
6066// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
6067// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
6068// symmetric sibling of the peer
6069// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
6070// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
6071// envelope — same `<axis>: <value>.to_string()` owned-forward payload
6072// shape, `reason` axis removed and `nome`-axis added at the per-dep-
6073// owned altitude the `DepError` envelope keys off (every `DepError`
6074// variant carries the offending `:deps :nome` verbatim so the author
6075// can grep their caixa.lisp for the offending block in one edit). The
6076// three variants share the same `{ nome: String, <axis>: String }`
6077// two-slot shape: the `nome` field names the offending dep the
6078// diagnostic points the author back at, and the middle `<axis>:
6079// String` field carries the offending per-envelope axis value verbatim
6080// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
6081// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
6082// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
6083// The middle axis-field name differs across variants (`pin` / `pins` /
6084// `caracteristica`) so the ctor family below takes the axis field name
6085// as a macro parameter (`$axis:ident`) alongside the ctor + variant
6086// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
6087// Self` inherent constructor per typed variant that spells the
6088// uniform two-field construction (`nome.to_string()` /
6089// `<axis>.to_string()`) exactly once.
6090//
6091// The three wire-up sites this fold closes are:
6092// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
6093//   (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
6094//   pin.to_string() });` inside the `set.len() == 1` branch after the
6095//   `is_some_and(String::is_empty)` iterator);
6096// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
6097//   ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
6098//   nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
6099// - [`Dep::validate_caracteristicas`]'s per-entry
6100//   set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
6101//   { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
6102//   [`crate::render::insert_first_seen`]).
6103//
6104// Each opened the identical four-line struct-literal against the same
6105// `(nome, <axis>)` local pair — the exact "same block re-inlined at
6106// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
6107// same altitude the peer four already-lifted `DepError` ctor families
6108// closed on their sibling shape-envelopes. The three variant / axis-
6109// field discriminators are the only things that vary between them;
6110// the rest of the struct-literal is a byte-for-byte re-inline.
6111//
6112// Every future consumer wanting to raise one of these three
6113// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
6114// at lacre-resolve time re-checking each declared dep against the
6115// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
6116// set-not-multiset cascade, a future `feira validate --deps` per-
6117// caixa admission verb re-running the shape gates on demand, a
6118// per-lacre overlay resolver rejecting an author-supplied dep against
6119// a cluster-local snapshot the M4 CR materializer projects) now
6120// reaches one dispatch rather than re-inlining the four-line struct-
6121// literal in lockstep with the three in-crate wire-up sites.
6122macro_rules! dep_nome_axis_ctors {
6123    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
6124        impl DepError {
6125            $(
6126                #[doc = concat!(
6127                    "Construct a [`DepError::",
6128                    stringify!($variant),
6129                    "`] naming the offending `:deps :nome` and the ",
6130                    "offending `:", stringify!($axis), "` axis value. ",
6131                    "Folds the uniform `Self::",
6132                    stringify!($variant),
6133                    " { nome: nome.to_string(), ",
6134                    stringify!($axis),
6135                    ": ",
6136                    stringify!($axis),
6137                    ".to_string() }` two-field struct-literal onto one ",
6138                    "substrate primitive so every in-crate wire-up on ",
6139                    "this variant reads through one dispatch rather than ",
6140                    "the pre-lift four-line open-coded block. Both `nome: ",
6141                    "&str` and `",
6142                    stringify!($axis),
6143                    ": &str` parameters accept `&str` literals and ",
6144                    "`&String` (via Deref coercion) so every existing ",
6145                    "wire-up threads through the ctor without a pre-",
6146                    "conversion."
6147                )]
6148                #[must_use]
6149                pub fn $ctor(nome: &str, $axis: &str) -> Self {
6150                    Self::$variant {
6151                        nome: nome.to_string(),
6152                        $axis: $axis.to_string(),
6153                    }
6154                }
6155            )*
6156        }
6157    };
6158}
6159
6160dep_nome_axis_ctors! {
6161    fonte_pin_empty => FontePinEmpty { pin },
6162    fonte_pin_ambiguous => FontePinAmbiguous { pins },
6163    caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
6164}
6165
6166// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
6167// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
6168// struct-variant wire-up sites at [`DepSource::validate`]'s
6169// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
6170// the `DepError` envelope — the last open-coded ctor site remaining on
6171// the `:fonte (:tipo git …)` value-shape trajectory this envelope
6172// carries, and the single-variant sibling of the peer four already-
6173// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
6174// on the two-slot `{ nome, caminho }` envelope,
6175// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
6176// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
6177// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
6178// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
6179// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
6180// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
6181// `{ …, value: String, reason: String }` payload shape, one axis
6182// removed at the `nome`-only-owner altitude the `DepError` envelope
6183// keys off (no `edge_pair()` de/para pair).
6184//
6185// The two wire-up sites this fold closes are the paired refname-pin
6186// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
6187// pin: pin.to_string(), value: v.clone(), reason }` inside the
6188// `[(":tag", tag), (":branch", branch)]` iterator against
6189// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
6190// (`|| DepError::FontePinShape { nome: nome.to_string(),
6191// pin: ":rev".to_string(), value: v.clone(), reason }` against
6192// [`crate::render::is_git_oid`]) — each opened the identical
6193// `DepError::FontePinShape { … }` six-line struct-literal against the
6194// same `(nome: &str, pin: &str, v: &String, reason: String)` local
6195// tuple, the exact "same block re-inlined at every consumer" shape
6196// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
6197// the only thing that varies between them (`":tag"`/`":branch"` on
6198// the refname arm, `":rev"` on the hex-OID arm); the rest of the
6199// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
6200// route through the same ctor because their `pin` field carries the
6201// author-surface tag verbatim (matching the `FontePinEmpty` /
6202// `FontePinAmbiguous` sibling variants' `pin: String` axis
6203// convention), so the offending author can grep their caixa.lisp for
6204// the offending `:tag "<value>"` / `:branch "<value>"` /
6205// `:rev "<value>"` literal in one edit.
6206//
6207// The single ctor below folds each wire-up onto one dispatch:
6208// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
6209// the pre-lift struct-literal on the same `(&str, &str, &str,
6210// String)` fixture. The uniform four-field construction
6211// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
6212// `reason` forwarded owned) is spelled once here rather than at every
6213// wire-up site. The `reason: String` field takes an owned `String`
6214// (not `impl Into<String>`) matching the two call sites' pre-existing
6215// `let Err(reason) = crate::render::is_git_ref_name(v)` /
6216// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
6217// predicates return `Result<(), String>`, so the caller always holds
6218// an owned `String` at the wire-up site and threading it through the
6219// ctor without a `.into()` shim keeps the routing shape byte-equal to
6220// the pre-lift block. The `value: &str` parameter accepts both `&str`
6221// literals (unused today) and `&String` (from the caller-held
6222// `v: &String` on each arm, via Deref coercion), so every existing
6223// wire-up threads through the ctor without a pre-conversion.
6224//
6225// Every future consumer that wants to construct this variant outside
6226// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
6227// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
6228// re-checking the same value-shape axes the resolver consumes, a
6229// future `feira validate --deps` per-caixa admission verb re-checking
6230// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
6231// resolver rejecting a git-pin value against a cluster-local
6232// snapshot) now reaches this variant through one call rather than
6233// re-inlining the six-line struct-literal in lockstep with the two
6234// in-crate wire-up sites.
6235impl DepError {
6236    /// Construct a [`DepError::FontePinShape`] naming the offending
6237    /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
6238    /// axis tag, the offending value, and the parser-shaped `reason`.
6239    /// Folds the uniform
6240    /// `Self::FontePinShape { nome: nome.to_string(),
6241    /// pin: pin.to_string(), value: value.to_string(), reason }`
6242    /// four-field struct-literal onto one substrate primitive so
6243    /// every [`DepSource::validate`] wire-up on this variant reads
6244    /// through one dispatch rather than the pre-lift six-line
6245    /// open-coded block. The `nome` string threads verbatim from
6246    /// [`Dep::nome`] at the call site; the `pin` string carries the
6247    /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
6248    /// `value` string carries the offending refname / hex-OID
6249    /// verbatim; and `reason` forwards the owned `String` returned
6250    /// by [`crate::render::is_git_ref_name`] /
6251    /// [`crate::render::is_git_oid`] without a `.into()` shim.
6252    #[must_use]
6253    pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
6254        Self::FontePinShape {
6255            nome: nome.to_string(),
6256            pin: pin.to_string(),
6257            value: value.to_string(),
6258            reason,
6259        }
6260    }
6261
6262    /// Construct a [`DepError::NomeInvalid`] naming the offending
6263    /// `:deps :nome` byte-string and the parser-shaped rejection
6264    /// `reason` returned by [`crate::render::is_dns_1123_label`].
6265    ///
6266    /// Folds the uniform
6267    /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
6268    /// struct-literal onto one substrate primitive so every wire-up on
6269    /// this variant reads through one dispatch rather than the pre-lift
6270    /// four-line open-coded `DepError::NomeInvalid { nome:
6271    /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
6272    /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
6273    /// ctor-family ladder (`{ nome }` one-slot →
6274    /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
6275    /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
6276    /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
6277    /// `{ nome, <axis>: String, reason: String }` three-slot →
6278    /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
6279    /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
6280    /// — the sole variant on the envelope carrying the
6281    /// `{ nome: String, reason: String }` two-slot shape without a
6282    /// middle axis, matching the peer
6283    /// [`crate::manifest::ManifestError::NomeInvalid`] +
6284    /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
6285    /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
6286    /// four-axis DNS-1123 caixa-identifier diagnostic family the
6287    /// existing `nome_invalid_diagnostic_carries_offending_name` test
6288    /// pins on this envelope.
6289    ///
6290    /// The `nome: &str` parameter accepts `&str` literals and `&String`
6291    /// (via Deref coercion) so the sole in-crate wire-up threads through
6292    /// the ctor without a pre-conversion; the `reason: String`
6293    /// parameter takes an owned `String` (not `impl Into<String>`)
6294    /// matching the [`crate::render::is_dns_1123_label`] predicate's
6295    /// `Result<(), String>` return shape the sole wire-up site already
6296    /// holds owned at the call site, keeping the routing byte-equal to
6297    /// the pre-lift block. Same owned-`String`-forward `reason` payload
6298    /// discipline as the sibling three-slot family
6299    /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
6300    /// and the four-slot [`DepError::fonte_pin_shape`] on
6301    /// `{ nome, pin, value, reason }`.
6302    ///
6303    /// Every future consumer that raises the same diagnostic outside
6304    /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
6305    /// re-validator at lacre-resolve time re-checking each declared
6306    /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
6307    /// side schema uses (the `:nome` value flows verbatim as the target
6308    /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
6309    /// segment, the `LABEL_PROGRAM` label value, and the resolver's
6310    /// checkout-directory leaf), a future `feira validate --deps`
6311    /// per-caixa admission verb re-running the shape gate on demand, a
6312    /// per-lacre overlay resolver rejecting an author-supplied dep's
6313    /// `:nome` against a cluster-local snapshot the M4 CR materializer
6314    /// projects, a future authoring-surface widening the field into a
6315    /// `(String, Vec<Suggestion>)` pair carrying a
6316    /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
6317    /// variant through one call rather than re-inlining the four-line
6318    /// struct-literal in lockstep with the one in-crate wire-up site.
6319    #[must_use]
6320    pub fn nome_invalid(nome: &str, reason: String) -> Self {
6321        Self::NomeInvalid {
6322            nome: nome.to_string(),
6323            reason,
6324        }
6325    }
6326}
6327
6328#[allow(clippy::trivially_copy_pass_by_ref)]
6329fn is_false(b: &bool) -> bool {
6330    !*b
6331}
6332
6333#[cfg(test)]
6334mod tests {
6335    use super::*;
6336
6337    #[test]
6338    fn registry_dep_is_minimal() {
6339        let d = Dep::simple("caixa-teia", "^0.1");
6340        assert_eq!(d.nome, "caixa-teia");
6341        assert_eq!(d.versao, "^0.1");
6342        assert!(d.fonte.is_none());
6343        assert!(!d.opcional());
6344        assert!(d.caracteristicas().is_empty());
6345    }
6346
6347    #[test]
6348    fn dep_string_scalar_accessor_pair_is_const_fn() {
6349        // Fail-before-pass-after pin on [`Dep::nome`] +
6350        // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
6351        // Each accessor projects the per-`:deps` / per-`:deps-dev`
6352        // entry's [`String`] storage through the `pub const fn`
6353        // [`String::as_str`] (const-stable since Rust 1.87, well
6354        // within the workspace MSRV) — any future accidental
6355        // downgrade to non-`const` fails the corresponding
6356        // `<name>_via_const_fn` wrapper at caixa-core build time with
6357        // E0015 (`cannot call non-const method`), strictly stronger
6358        // than a runtime `assert!`. Sibling of the peer
6359        // per-M2/M3/universal-axis `String → &str` scalar-accessor
6360        // family pins on the sibling `const`-eval-surface passes
6361        // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
6362        // top-level manifest, [`crate::CaixaVersion::as_str`] at the
6363        // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
6364        // [`crate::aplicacao::Membro::versao_requirement`] at the M3
6365        // membership axis, [`crate::aplicacao::Entrada::hostname`] /
6366        // [`crate::aplicacao::Entrada::destination`] at the M3
6367        // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
6368        // [`crate::supervisor::ChildSpec::versao_requirement`] at the
6369        // M2 supervisor-tree axis,
6370        // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
6371        // M2 upgrade axis, and the per-`:contratos`
6372        // [`crate::aplicacao::WitContract::source`] /
6373        // [`crate::aplicacao::WitContract::destination`] /
6374        // [`crate::aplicacao::WitContract::world_ref`] trio the
6375        // sibling pin at 279823b already anchors).
6376        const fn nome_via_const_fn(d: &Dep) -> &str {
6377            d.nome()
6378        }
6379        const fn versao_via_const_fn(d: &Dep) -> &str {
6380            d.versao_requirement()
6381        }
6382        for (nome, versao) in [
6383            ("caixa-teia", "^0.1"),
6384            ("caixa-mesh", "~0.2.3"),
6385            ("caixa-helm", "*"),
6386        ] {
6387            let d = Dep::simple(nome, versao);
6388            assert_eq!(nome_via_const_fn(&d), d.nome());
6389            assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
6390            assert_eq!(d.nome(), nome);
6391            assert_eq!(d.versao_requirement(), versao);
6392        }
6393    }
6394
6395    #[test]
6396    fn dep_outer_accessor_family_is_const_fn() {
6397        // Fail-before-pass-after pin on [`Dep::fonte`] +
6398        // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
6399        // Each accessor projects the per-`:deps` / per-`:deps-dev`
6400        // entry's composite / list storage through a `pub const fn`
6401        // stdlib method (`Option::<DepSource>::as_ref` /
6402        // `Vec::<String>::as_slice`, both const-stable since Rust
6403        // 1.83, well within the workspace MSRV). Any future
6404        // accidental downgrade to non-`const` fails the corresponding
6405        // `<name>_via_const_fn` wrapper at caixa-core build time with
6406        // E0015 (`cannot call non-const method`), strictly stronger
6407        // than a runtime `assert!` and side-stepping the destructor-
6408        // in-const restriction the `Dep` fixture's `String` /
6409        // `Option<DepSource>` / `Vec<String>` carriers rule out on the
6410        // direct-`const _: () = assert!(...)` residence.
6411        //
6412        // Peer of the sibling per-`Dep` scalar-accessor pair pin
6413        // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
6414        // outer per-dep-list-entry [`Dep`] altitude — this pin extends
6415        // the `const`-eval-surface discipline onto the composite-
6416        // reference and slice-return arms of the outer-`Dep` accessor
6417        // family, closing the four-slot outer surface (`:nome` +
6418        // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
6419        // posture. The `:opcional` `bool` arm already carries the
6420        // posture through [`Dep::opcional`]'s prior `pub const fn`
6421        // declaration, so this pin lands the last two unlifted
6422        // outer-`Dep` accessors and closes the family.
6423        const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
6424            d.fonte()
6425        }
6426        const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
6427            d.caracteristicas()
6428        }
6429        // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
6430        let empty = Dep::simple("caixa-teia", "^0.1");
6431        assert!(fonte_via_const_fn(&empty).is_none());
6432        assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
6433        assert!(caracteristicas_via_const_fn(&empty).is_empty());
6434        assert_eq!(
6435            caracteristicas_via_const_fn(&empty),
6436            empty.caracteristicas()
6437        );
6438        // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
6439        // still empty.
6440        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
6441        assert!(fonte_via_const_fn(&git).is_some());
6442        assert_eq!(fonte_via_const_fn(&git), git.fonte());
6443        assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
6444        // Populated `:caracteristicas` — exercise the non-empty
6445        // slice-view arm to pin the accessor's borrow shape against
6446        // both a `Vec::new()` empty backing buffer and a populated one.
6447        let mut with_features = Dep::simple("caixa-teia", "^0.1");
6448        with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
6449        assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
6450        assert_eq!(
6451            caracteristicas_via_const_fn(&with_features),
6452            with_features.caracteristicas()
6453        );
6454    }
6455
6456    #[test]
6457    fn git_dep_carries_tag() {
6458        let d = Dep::git("t", "*", "github:o/r", "v1");
6459        match d.fonte {
6460            Some(DepSource::Git {
6461                ref repo, ref tag, ..
6462            }) => {
6463                assert_eq!(repo, "github:o/r");
6464                assert_eq!(tag.as_deref(), Some("v1"));
6465            }
6466            _ => panic!("expected Git source"),
6467        }
6468    }
6469
6470    #[test]
6471    fn validate_accepts_simple_dep() {
6472        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
6473    }
6474
6475    #[test]
6476    fn validate_rejects_empty_nome() {
6477        // The fail-before-pass-after pin for `:nome ""`: the empty-name
6478        // arm fires first so the per-entry parse-side diagnostic doesn't
6479        // emit a useless `nome: ""` reference.
6480        let mut d = Dep::simple("placeholder", "^0.1");
6481        d.nome = String::new();
6482        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6483    }
6484
6485    #[test]
6486    fn validate_rejects_empty_versao() {
6487        // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
6488        // semver crate accepts the empty string as a wildcard match),
6489        // so the empty-`:versao` arm is structurally necessary even
6490        // with the parse arm in place — mirrors `MembroVersaoEmpty` /
6491        // `EmptyChildVersion` ordering on the other two `:versao` axes.
6492        let mut d = Dep::simple("caixa-teia", "ignored");
6493        d.versao = String::new();
6494        let err = d.validate().unwrap_err();
6495        assert!(
6496            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6497            "got {err:?}"
6498        );
6499    }
6500
6501    // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
6502
6503    #[test]
6504    fn validate_rejects_nome_with_uppercase() {
6505        // The fail-before-pass-after pin: a non-empty but uppercase
6506        // `:nome` silently passed `validate()` on every pre-gate
6507        // codebase because the prior shape only refused the empty
6508        // string. The DNS-1123 violation surfaced far downstream at
6509        // lacre-resolve time when the *target* caixa's `:nome` failed
6510        // its own gate — far from the `:deps` entry, with a diagnostic
6511        // naming the target rather than the dep entry that referenced
6512        // it. Same fail-before-pass-after fixture pinned for
6513        // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
6514        // and Caixa `:nome` (6c992f8).
6515        let d = Dep::simple("Caixa-Teia", "^0.1");
6516        let err = d.validate().unwrap_err();
6517        assert!(
6518            matches!(
6519                err,
6520                DepError::NomeInvalid { ref nome, ref reason }
6521                    if nome == "Caixa-Teia" && reason.contains("uppercase")
6522            ),
6523            "got {err:?}"
6524        );
6525    }
6526
6527    #[test]
6528    fn validate_rejects_nome_with_underscore() {
6529        // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
6530        // "I'm thinking of Go module names / Python identifiers" leak.
6531        // Same fixture pinned for the peer caixa-identifier axes.
6532        let d = Dep::simple("caixa_teia", "^0.1");
6533        let err = d.validate().unwrap_err();
6534        assert!(
6535            matches!(
6536                err,
6537                DepError::NomeInvalid { ref nome, ref reason }
6538                    if nome == "caixa_teia" && reason.contains('_')
6539            ),
6540            "got {err:?}"
6541        );
6542    }
6543
6544    #[test]
6545    fn validate_rejects_nome_with_dot() {
6546        // A `:deps :nome` is a single DNS-1123 *label*, not a
6547        // subdomain — dots are rejected. The `"caixa.teia"` shape is
6548        // the canonical "I confused the dep name with the FQDN /
6549        // namespace" footgun, distinct from the legitimate
6550        // `:fonte :repo "github:org/caixa-teia"` axis.
6551        let d = Dep::simple("caixa.teia", "^0.1");
6552        let err = d.validate().unwrap_err();
6553        assert!(
6554            matches!(
6555                err,
6556                DepError::NomeInvalid { ref nome, ref reason }
6557                    if nome == "caixa.teia" && reason.contains('.')
6558            ),
6559            "got {err:?}"
6560        );
6561    }
6562
6563    #[test]
6564    fn validate_rejects_nome_with_leading_hyphen() {
6565        // RFC 1123 requires alphanumeric at both label boundaries.
6566        // Pinned in parity with the peer DNS-1123 fixtures.
6567        let d = Dep::simple("-caixa-teia", "^0.1");
6568        let err = d.validate().unwrap_err();
6569        assert!(
6570            matches!(
6571                err,
6572                DepError::NomeInvalid { ref nome, ref reason }
6573                    if nome == "-caixa-teia" && reason.contains("alphanumeric")
6574            ),
6575            "got {err:?}"
6576        );
6577    }
6578
6579    #[test]
6580    fn validate_rejects_nome_with_trailing_hyphen() {
6581        let d = Dep::simple("caixa-teia-", "^0.1");
6582        let err = d.validate().unwrap_err();
6583        assert!(
6584            matches!(
6585                err,
6586                DepError::NomeInvalid { ref nome, ref reason }
6587                    if nome == "caixa-teia-" && reason.contains("alphanumeric")
6588            ),
6589            "got {err:?}"
6590        );
6591    }
6592
6593    #[test]
6594    fn validate_rejects_nome_with_slash() {
6595        // The canonical "I copied the GitHub repo path into `:nome`
6596        // instead of `:fonte :repo`" typo. A `/` in the name leaks the
6597        // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
6598        // the local-name slot. Same fixture pinned for `:membros
6599        // :caixa` (3f9d7a0).
6600        let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
6601        let err = d.validate().unwrap_err();
6602        assert!(
6603            matches!(
6604                err,
6605                DepError::NomeInvalid { ref nome, ref reason }
6606                    if nome == "pleme-io/caixa-teia" && reason.contains('/')
6607            ),
6608            "got {err:?}"
6609        );
6610    }
6611
6612    #[test]
6613    fn validate_rejects_nome_too_long() {
6614        // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
6615        // Built from a valid character set so the length-bound
6616        // diagnostic surfaces before any per-character check (the
6617        // order pin parallel to the per-character predicates inside
6618        // [`crate::render::is_dns_1123_label`]).
6619        let long = "a".repeat(64);
6620        let d = Dep::simple(&long, "^0.1");
6621        let err = d.validate().unwrap_err();
6622        assert!(
6623            matches!(
6624                err,
6625                DepError::NomeInvalid { ref nome, ref reason }
6626                    if nome.len() == 64 && reason.contains("max length of 63")
6627            ),
6628            "got {err:?}"
6629        );
6630    }
6631
6632    #[test]
6633    fn validate_accepts_canonical_nome_labels() {
6634        // Positive-control sweep — every form the K8s apiserver
6635        // accepts as a DNS-1123 label must round-trip through
6636        // validate. Covers a hyphen-bearing label, a numeric-suffix
6637        // label, a leading-digit label, a single-character label, and
6638        // a 63-byte (exactly the cap) label — the same fixture set
6639        // the peer `:membros :caixa` / `:children :caixa` positive
6640        // controls pin.
6641        for nome in [
6642            "caixa-teia",
6643            "caixa-resolver2",
6644            "2nd-tier-cache",
6645            "x",
6646            "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
6647        ] {
6648            Dep::simple(nome, "^0.1")
6649                .validate()
6650                .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
6651        }
6652    }
6653
6654    #[test]
6655    fn nome_empty_takes_precedence_over_nome_invalid() {
6656        // Ordering pin: `NomeEmpty` is the more self-locating
6657        // diagnostic on `""` and must lead — `is_dns_1123_label` is
6658        // only reached after the empty-check fires at the call site.
6659        // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
6660        // (3f9d7a0) on the peer caixa-identifier axis.
6661        let mut d = Dep::simple("placeholder", "^0.1");
6662        d.nome = String::new();
6663        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6664    }
6665
6666    #[test]
6667    fn nome_invalid_fires_before_versao_empty() {
6668        // Ordering pin: a malformed `:nome` fires before any `:versao`
6669        // axis check on the *same* entry — the per-entry shape gates
6670        // run top-to-bottom (nome empty → nome shape → versao empty →
6671        // versao parse → fonte shape), so a one-entry caixa.lisp with
6672        // both wrong sees the name-side diagnostic first (the name is
6673        // the self-locating axis — without a valid name, the parse
6674        // diagnostic can't quote `:nome "<bad>"`). Same ordering
6675        // discipline as `membro_caixa_invalid_fires_before_versao_check`
6676        // (3f9d7a0).
6677        let mut d = Dep::simple("Caixa-Teia", "^0.1");
6678        d.versao = String::new();
6679        let err = d.validate().unwrap_err();
6680        assert!(
6681            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6682            "got {err:?}"
6683        );
6684    }
6685
6686    #[test]
6687    fn nome_invalid_fires_before_versao_invalid() {
6688        // Ordering pin: a malformed `:nome` fires before the `:versao`
6689        // parse-side check on the *same* entry. Pin separately from
6690        // the empty-versao ordering so a future re-ordering surfaces
6691        // here, parallel to the b0c8389 / c4213a4 trajectory.
6692        let d = Dep::simple("Caixa-Teia", "^^0.1");
6693        let err = d.validate().unwrap_err();
6694        assert!(
6695            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6696            "got {err:?}"
6697        );
6698    }
6699
6700    #[test]
6701    fn nome_invalid_fires_before_fonte_invalid() {
6702        // Ordering pin: a malformed `:nome` fires before the `:fonte`
6703        // shape check on the *same* entry. The `:fonte` diagnostic
6704        // names the offending dep's `:nome` verbatim (via
6705        // `DepSource::validate(&self.nome)`), so a non-self-locating
6706        // name would taint the downstream diagnostic too — the gate
6707        // ordering keeps both diagnostics individually self-locating.
6708        let mut d = Dep::simple("Caixa-Teia", "^0.1");
6709        d.fonte = Some(DepSource::Git {
6710            repo: String::new(),
6711            tag: None,
6712            rev: None,
6713            branch: None,
6714        });
6715        let err = d.validate().unwrap_err();
6716        assert!(
6717            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6718            "got {err:?}"
6719        );
6720    }
6721
6722    #[test]
6723    fn nome_invalid_diagnostic_carries_offending_name() {
6724        // The diagnostic-shape pin: the error names the offending
6725        // `:nome` value verbatim so the author can grep their
6726        // caixa.lisp without re-running the build, and carries a
6727        // non-empty `reason` from `is_dns_1123_label` so the
6728        // predicate's own wording flows through to the diagnostic.
6729        // Same shape as `MembroCaixaInvalid` (3f9d7a0),
6730        // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
6731        // (6c992f8) — the four DNS-1123 caixa-identifier axes now
6732        // share a structurally-equivalent diagnostic family.
6733        let d = Dep::simple("Caixa_Teia", "^0.1");
6734        let err = d.validate().unwrap_err();
6735        let DepError::NomeInvalid { nome, reason } = err else {
6736            panic!("expected NomeInvalid, got other variant");
6737        };
6738        assert_eq!(nome, "Caixa_Teia");
6739        assert!(
6740            !reason.is_empty(),
6741            "NomeInvalid `reason` must carry the predicate's wording verbatim"
6742        );
6743    }
6744
6745    #[test]
6746    fn validate_rejects_invalid_versao_requirement() {
6747        // The fail-before-pass-after pin: a non-empty but malformed
6748        // requirement (`"^bad-version"`) silently passed every pre-gate
6749        // codebase because `:deps :versao` wasn't validated. The parse
6750        // failure surfaced far downstream at lacre-resolve time with a
6751        // `semver::Error` that didn't name which `:deps` entry carried
6752        // the typo. The new gate moves the check to caixa-build time
6753        // at the source caixa.lisp.
6754        let d = Dep::simple("caixa-teia", "^bad-version");
6755        let err = d.validate().unwrap_err();
6756        assert!(
6757            matches!(
6758                err,
6759                DepError::VersaoInvalid { ref nome, ref versao, .. }
6760                    if nome == "caixa-teia" && versao == "^bad-version"
6761            ),
6762            "got {err:?}"
6763        );
6764    }
6765
6766    #[test]
6767    fn validate_rejects_versao_with_double_caret_typo() {
6768        // `"^^0.1"` is the canonical doubled-caret typo — looks like a
6769        // Cargo-shaped requirement on first glance but fails the parser
6770        // because semver doesn't accept stacked operators. Pin this
6771        // adjacent-shape footgun explicitly so a future relaxation that
6772        // accepts "looks-canonical-but-isn't" forms surfaces here, in
6773        // parity with the `:membros` / `:children` fixtures.
6774        let d = Dep::simple("caixa-teia", "^^0.1");
6775        let err = d.validate().unwrap_err();
6776        assert!(
6777            matches!(
6778                err,
6779                DepError::VersaoInvalid { ref nome, ref versao, .. }
6780                    if nome == "caixa-teia" && versao == "^^0.1"
6781            ),
6782            "got {err:?}"
6783        );
6784    }
6785
6786    #[test]
6787    fn validate_rejects_versao_with_v_prefixed_tag() {
6788        // `"v0.1"` is the canonical "git-tag-shape leaking into the
6789        // semver requirement slot" typo — an author copies the
6790        // publish-side git-tag string verbatim into `:versao`, but
6791        // Cargo's semver parser rejects the leading `v`. Same fixture
6792        // pinned for `:membros :versao` (9888b13) and `:children
6793        // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
6794        // are *accepted* by the semver crate as an `*` wildcard on the
6795        // patch axis — they're a Cargo-side valid shape, not a typo.)
6796        let d = Dep::simple("caixa-teia", "v0.1");
6797        let err = d.validate().unwrap_err();
6798        assert!(
6799            matches!(
6800                err,
6801                DepError::VersaoInvalid { ref nome, ref versao, .. }
6802                    if nome == "caixa-teia" && versao == "v0.1"
6803            ),
6804            "got {err:?}"
6805        );
6806    }
6807
6808    #[test]
6809    fn validate_accepts_canonical_versao_forms() {
6810        // The five Cargo-shaped requirement forms `:membros :versao`
6811        // and `:children :versao` already accept via
6812        // `crate::parse_requirement` must pass the deps gate without
6813        // re-validating at the resolver layer. Pin every leg so a
6814        // future tightening of the canonical set surfaces here as a
6815        // test failure.
6816        for form in [
6817            "^0.1",      // caret — minor-range pin (the most common shape)
6818            "~0.1.2",    // tilde — patch-range pin
6819            "0.1.0",     // exact — single-version pin
6820            "*",         // wildcard — explicitly any-version
6821            ">=0.1, <2", // multi-range — comma-separated comparators
6822        ] {
6823            Dep::simple("caixa-teia", form)
6824                .validate()
6825                .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
6826        }
6827    }
6828
6829    #[test]
6830    fn versao_empty_takes_precedence_over_invalid() {
6831        // Order pin: the existing `VersaoEmpty` diagnostic (which
6832        // doesn't try to parse) fires before the new `VersaoInvalid`
6833        // parse-side diagnostic, so an empty `:versao` keeps its
6834        // narrower error message — `parse_requirement("")` would
6835        // otherwise return `Ok(STAR)` and silently pass, but the empty
6836        // arm catches it first.
6837        let mut d = Dep::simple("caixa-teia", "ignored");
6838        d.versao = String::new();
6839        let err = d.validate().unwrap_err();
6840        assert!(
6841            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6842            "got {err:?}"
6843        );
6844    }
6845
6846    #[test]
6847    fn nome_empty_takes_precedence_over_versao_invalid() {
6848        // Order pin: even when `:versao` is malformed and would raise
6849        // its own diagnostic, `:nome ""` fires first because the
6850        // per-entry parse diagnostic needs a non-empty name to be
6851        // self-locating. Mirrors the
6852        // `membros_validation_runs_before_contratos_membership_check`
6853        // ordering on the typed-graph layer.
6854        let mut d = Dep::simple("placeholder", "^bad");
6855        d.nome = String::new();
6856        let err = d.validate().unwrap_err();
6857        assert_eq!(err, DepError::NomeEmpty);
6858    }
6859
6860    #[test]
6861    fn versao_invalid_diagnostic_carries_offending_versao() {
6862        // The diagnostic-shape pin: the error names the offending
6863        // `:versao` value verbatim so the author can grep their
6864        // caixa.lisp without re-running the build, and carries a
6865        // non-empty `reason` from `semver::VersionReq::parse` so the
6866        // parser's own wording flows through to the diagnostic.
6867        let d = Dep::simple("caixa-teia", "not-a-req");
6868        let err = d.validate().unwrap_err();
6869        let DepError::VersaoInvalid {
6870            nome,
6871            versao,
6872            reason,
6873        } = err
6874        else {
6875            panic!("expected VersaoInvalid, got other variant");
6876        };
6877        assert_eq!(nome, "caixa-teia");
6878        assert_eq!(versao, "not-a-req");
6879        assert!(
6880            !reason.is_empty(),
6881            "VersaoInvalid `reason` must carry the parser's wording verbatim"
6882        );
6883    }
6884
6885    // -- :fonte value-shape gate ------------------------------------------
6886
6887    fn dep_with_fonte(fonte: DepSource) -> Dep {
6888        let mut d = Dep::simple("caixa-teia", "^0.1");
6889        d.fonte = Some(fonte);
6890        d
6891    }
6892
6893    #[test]
6894    fn validate_accepts_git_fonte_with_tag() {
6895        // The positive-control pin on the canonical git source — exactly
6896        // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
6897        // shape every existing caixa-resolver integration test uses.
6898        let d = dep_with_fonte(DepSource::Git {
6899            repo: "github:pleme-io/caixa-teia".into(),
6900            tag: Some("v0.1.0".into()),
6901            rev: None,
6902            branch: None,
6903        });
6904        d.validate().unwrap();
6905    }
6906
6907    #[test]
6908    fn validate_accepts_git_fonte_with_rev() {
6909        // Each of the three pin axes is independently a valid single-pin
6910        // shape; pin the :rev arm so a future relaxation that only
6911        // accepts :tag surfaces here. The value is a full 40-hex SHA-1
6912        // OID — the canonical `git rev-parse HEAD` emission shape the
6913        // `crate::render::is_git_oid` value-shape gate now requires;
6914        // abbreviated OIDs are ambiguous across repo history and
6915        // rejected at this gate (pinned separately by
6916        // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
6917        let d = dep_with_fonte(DepSource::Git {
6918            repo: "github:pleme-io/caixa-teia".into(),
6919            tag: None,
6920            rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
6921            branch: None,
6922        });
6923        d.validate().unwrap();
6924    }
6925
6926    #[test]
6927    fn validate_accepts_git_fonte_with_branch() {
6928        // The :branch arm is the third valid single-pin shape — pinned
6929        // separately so the gate-accepts-all-three-pin-axes contract is
6930        // a build-error to relax.
6931        let d = dep_with_fonte(DepSource::Git {
6932            repo: "github:pleme-io/caixa-teia".into(),
6933            tag: None,
6934            rev: None,
6935            branch: Some("main".into()),
6936        });
6937        d.validate().unwrap();
6938    }
6939
6940    #[test]
6941    fn validate_accepts_path_fonte() {
6942        // The positive-control pin on the path source — non-empty
6943        // :caminho, no pin axes (paths have no commit identity). Pinned
6944        // so a future "paths must also pin a rev" tightening surfaces
6945        // here as a structural decision, not a silent break.
6946        let d = dep_with_fonte(DepSource::Path {
6947            caminho: "../caixa-teia".into(),
6948        });
6949        d.validate().unwrap();
6950    }
6951
6952    #[test]
6953    fn validate_rejects_git_fonte_with_empty_repo() {
6954        // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
6955        // "v1")`: the empty-repo shape silently passed every pre-gate
6956        // codebase because `:fonte` wasn't validated. The git-clone
6957        // failure surfaced far downstream at lacre-resolve time with no
6958        // field naming which `:deps` entry carried the typo. The new
6959        // gate moves the check to caixa-build time at the source
6960        // caixa.lisp.
6961        let d = dep_with_fonte(DepSource::Git {
6962            repo: String::new(),
6963            tag: Some("v0.1.0".into()),
6964            rev: None,
6965            branch: None,
6966        });
6967        let err = d.validate().unwrap_err();
6968        assert!(
6969            matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
6970            "got {err:?}"
6971        );
6972    }
6973
6974    // -- :repo value-shape gate -------------------------------------------
6975    //
6976    // The `:fonte (:tipo git :repo …)` value flows verbatim into the
6977    // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
6978    // codebase admitted any non-empty string; the new
6979    // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
6980    // URL intersection-floor at validate time, peer with the three pin
6981    // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
6982    // `is_git_oid`). Every test in this section is a fail-before /
6983    // pass-after pin on a specific authoring footgun.
6984
6985    #[test]
6986    fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
6987        // The canonical paste-from-doc footgun on `:repo` — an author
6988        // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
6989        // a doc paragraph. Until this gate landed the empty-repo arm
6990        // passed (the string isn't empty), the resolver issued
6991        // `git clone 'github:pleme-io/caixa-teia '`, and the failure
6992        // surfaced at clone time with a quoting-confused error far from
6993        // the source caixa.lisp. Same paste-from-doc footgun the
6994        // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
6995        // axis — now closed on the `:repo` URL axis too.
6996        let d = dep_with_fonte(DepSource::Git {
6997            repo: "github:pleme-io/caixa-teia ".into(),
6998            tag: Some("v0.1.0".into()),
6999            rev: None,
7000            branch: None,
7001        });
7002        let err = d.validate().unwrap_err();
7003        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7004            panic!("expected FonteRepoShape, got other variant");
7005        };
7006        assert_eq!(nome, "caixa-teia");
7007        assert_eq!(repo, "github:pleme-io/caixa-teia ");
7008        assert!(
7009            reason.contains("whitespace"),
7010            "reason must surface the whitespace arm, got {reason:?}"
7011        );
7012    }
7013
7014    #[test]
7015    fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
7016        // The canonical CLI-argument-injection footgun at the `git clone`
7017        // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
7018        // argv parser read the value as a CLI flag, escaping the
7019        // subprocess argument boundary. The `--` separator workaround
7020        // does not fix the typed slot's accepted set; the gate rejects
7021        // the shape upstream at validate time so the resolver never
7022        // invokes a `git clone -…` subprocess.
7023        let d = dep_with_fonte(DepSource::Git {
7024            repo: "-upload-pack=evil".into(),
7025            tag: Some("v0.1.0".into()),
7026            rev: None,
7027            branch: None,
7028        });
7029        let err = d.validate().unwrap_err();
7030        let DepError::FonteRepoShape { repo, reason, .. } = err else {
7031            panic!("expected FonteRepoShape, got other variant");
7032        };
7033        assert_eq!(repo, "-upload-pack=evil");
7034        assert!(
7035            reason.contains("must not start with `-`"),
7036            "reason must surface the leading-`-` arm, got {reason:?}"
7037        );
7038    }
7039
7040    #[test]
7041    fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
7042        // The canonical paste-from-multiline-doc footgun — a `:repo`
7043        // string with an embedded `\n` silently breaks git's URL parser
7044        // and is a class of CRLF-injection at the subprocess-argument
7045        // boundary. Caught by the control-char arm (0x0A < 0x20).
7046        let d = dep_with_fonte(DepSource::Git {
7047            repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
7048            tag: Some("v0.1.0".into()),
7049            rev: None,
7050            branch: None,
7051        });
7052        let err = d.validate().unwrap_err();
7053        let DepError::FonteRepoShape { reason, .. } = err else {
7054            panic!("expected FonteRepoShape, got other variant");
7055        };
7056        assert!(
7057            reason.contains("control character"),
7058            "reason must surface the control-char arm, got {reason:?}"
7059        );
7060    }
7061
7062    #[test]
7063    fn validate_rejects_git_fonte_with_repo_carrying_tab() {
7064        // Tab is the sibling whitespace footgun (the canonical
7065        // copy-from-aligned-table paste); pinned separately from the
7066        // space arm so a future relaxation that only catches one
7067        // surfaces here.
7068        let d = dep_with_fonte(DepSource::Git {
7069            repo: "github:pleme-io/caixa-teia\t".into(),
7070            tag: Some("v0.1.0".into()),
7071            rev: None,
7072            branch: None,
7073        });
7074        let err = d.validate().unwrap_err();
7075        assert!(
7076            matches!(
7077                err,
7078                DepError::FonteRepoShape { ref reason, .. }
7079                    if reason.contains("whitespace")
7080            ),
7081            "got {err:?}"
7082        );
7083    }
7084
7085    #[test]
7086    fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
7087        // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
7088        // non-ASCII silently breaks at git's URL parser and round-trips
7089        // inconsistently across NFC/NFD normalization on APFS /
7090        // case-folding filesystems. Same intersection-floor
7091        // [`is_git_ref_name`] enforces on the refname axes.
7092        let d = dep_with_fonte(DepSource::Git {
7093            repo: "https://github.com/pleme-io/café".into(),
7094            tag: Some("v0.1.0".into()),
7095            rev: None,
7096            branch: None,
7097        });
7098        let err = d.validate().unwrap_err();
7099        assert!(
7100            matches!(
7101                err,
7102                DepError::FonteRepoShape { ref reason, .. }
7103                    if reason.contains("non-ASCII")
7104            ),
7105            "got {err:?}"
7106        );
7107    }
7108
7109    #[test]
7110    fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
7111        // The fail-before-pass-after pin for the canonical paste-from-
7112        // browser-address-bar footgun on `:repo`: an author copies a
7113        // GitHub permalink to a README anchor / line-permalink and
7114        // forgets to trim the `#fragment` tail. Until this arm landed
7115        // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
7116        // silently passed every prior arm (no whitespace, no control
7117        // chars, no non-ASCII, contains a `:`, doesn't start with `-`
7118        // or `:`), libcurl's URL parser stripped the `#readme` tail
7119        // before opening the HTTPS transport, and the lacre embedded
7120        // the value verbatim in its per-dep BLAKE3 closure — two
7121        // authors whose values differ only in their fragment anchor
7122        // (`#readme` vs `#L42`) resolve to the byte-identical upstream
7123        // `git clone` but lock to two distinct lacres, defeating the
7124        // THEORY.md §V.2 render-determinism contract. Same value-shape
7125        // axis-floor every peer typed surface enforces; peer `:fonte
7126        // :tag` / `:fonte :branch` already reject the byte-class through
7127        // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
7128        // URL grammar admitted) and `:entrada :paths` rejects `#` as
7129        // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
7130        let d = dep_with_fonte(DepSource::Git {
7131            repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
7132            tag: Some("v0.1.0".into()),
7133            rev: None,
7134            branch: None,
7135        });
7136        let err = d.validate().unwrap_err();
7137        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7138            panic!("expected FonteRepoShape, got other variant");
7139        };
7140        assert_eq!(nome, "caixa-teia");
7141        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
7142        assert!(
7143            reason.contains("must not contain `#`"),
7144            "reason must surface the fragment-`#` arm, got {reason:?}"
7145        );
7146        assert!(
7147            reason.contains("fragment"),
7148            "reason must name the URL fragment grammar, got {reason:?}"
7149        );
7150    }
7151
7152    #[test]
7153    fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
7154        // The symmetric paste-from-Nix-flake-ref footgun — an author
7155        // confuses the Nix flake-reference idiom (`github:foo/
7156        // bar#packageName`, where `#packageName` selects a flake
7157        // output) with the bare git `:repo` shape. The pleme-io
7158        // substrate authors compose flakes downstream of caixa
7159        // (caixa-flake renders a flake.nix), so the cross-idiom leak
7160        // is the canonical near-miss: the author writes the
7161        // flake-ref shape into a git `:repo` slot. Pinned separately
7162        // from the HTTPS-anchor arm so a future relaxation that
7163        // narrows to one URL scheme surfaces here.
7164        let d = dep_with_fonte(DepSource::Git {
7165            repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
7166            tag: Some("v0.1.0".into()),
7167            rev: None,
7168            branch: None,
7169        });
7170        let err = d.validate().unwrap_err();
7171        let DepError::FonteRepoShape { reason, .. } = err else {
7172            panic!("expected FonteRepoShape, got other variant");
7173        };
7174        assert!(
7175            reason.contains("must not contain `#`"),
7176            "reason must surface the fragment-`#` arm, got {reason:?}"
7177        );
7178        assert!(
7179            reason.contains("Nix flake"),
7180            "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
7181        );
7182    }
7183
7184    #[test]
7185    fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
7186        // The fail-before-pass-after pin for the canonical paste-from-
7187        // browser-address-bar footgun on `:repo` (peer with the
7188        // a68f818 fragment-`#` arm on the same axis). An author
7189        // copies a GitHub tab deep-link out of the address bar and
7190        // forgets to trim the `?tab=…` query tail. Until this arm
7191        // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
7192        // silently passed every prior arm (no whitespace, no control
7193        // chars, no non-ASCII, no `#` fragment, contains a `:`,
7194        // doesn't start with `-` or `:`); GitHub silently ignored
7195        // the `?query` tail and served the same repo regardless;
7196        // the lacre embedded the value verbatim in its per-dep
7197        // BLAKE3 closure — two authors whose values differ only in
7198        // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
7199        // `?utm_source=twitter`) resolve to the byte-identical
7200        // upstream `git clone` but lock to two distinct lacres,
7201        // defeating the THEORY.md §V.2 render-determinism contract
7202        // on the same axis the `#` fragment arm closes. Same value-
7203        // shape axis-floor every peer typed surface enforces; peer
7204        // `:fonte :tag` / `:fonte :branch` already reject the byte-
7205        // class through `is_git_ref_name`'s alphabet (refspec glob
7206        // wildcards, caixa-core/src/render.rs:1426) and `:entrada
7207        // :paths` rejects `?` as the query separator in
7208        // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
7209        let d = dep_with_fonte(DepSource::Git {
7210            repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
7211            tag: Some("v0.1.0".into()),
7212            rev: None,
7213            branch: None,
7214        });
7215        let err = d.validate().unwrap_err();
7216        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7217            panic!("expected FonteRepoShape, got other variant");
7218        };
7219        assert_eq!(nome, "caixa-teia");
7220        assert_eq!(
7221            repo,
7222            "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
7223        );
7224        assert!(
7225            reason.contains("must not contain `?`"),
7226            "reason must surface the query-`?` arm, got {reason:?}"
7227        );
7228        assert!(
7229            reason.contains("query"),
7230            "reason must name the URL query grammar, got {reason:?}"
7231        );
7232    }
7233
7234    #[test]
7235    fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
7236        // The symmetric paste-from-social-share footgun — an author
7237        // copies a repo URL out of a Slack unfurl / Twitter share /
7238        // newsletter link / Discord embed and forgets to trim the
7239        // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
7240        // campaign-tracker tail. Every major social-share / unfurl /
7241        // newsletter platform appends these UTM parameters; the
7242        // canonical near-miss on the `:repo` axis. Pinned separately
7243        // from the GitHub-tab-deep-link arm so a future relaxation
7244        // that narrows to one query-parameter class surfaces here.
7245        let d = dep_with_fonte(DepSource::Git {
7246            repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
7247                .into(),
7248            tag: Some("v0.1.0".into()),
7249            rev: None,
7250            branch: None,
7251        });
7252        let err = d.validate().unwrap_err();
7253        let DepError::FonteRepoShape { reason, .. } = err else {
7254            panic!("expected FonteRepoShape, got other variant");
7255        };
7256        assert!(
7257            reason.contains("must not contain `?`"),
7258            "reason must surface the query-`?` arm, got {reason:?}"
7259        );
7260        assert!(
7261            reason.contains("campaign-tracker"),
7262            "reason must name the campaign-tracker paste footgun, got {reason:?}"
7263        );
7264    }
7265
7266    #[test]
7267    fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
7268        // Cascade pin: the fragment-`#` arm and the query-`?` arm are
7269        // both per-byte arms inside the same `for &b in s.as_bytes()`
7270        // loop, so the byte that appears first in the value's byte
7271        // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
7272        // (fragment before query — unusual URL-grammar but value-
7273        // disjoint at byte level) carries both `#` and `?`; the `#`
7274        // byte appears first, so the fragment-`#` arm fires, surfacing
7275        // the more self-locating diagnostic on the byte the author
7276        // pasted earliest in the URL. Mirrors the peer cascade
7277        // discipline `fonte_repo_control_char_fires_before_fragment`
7278        // pins on the prior `:repo` byte-class arm.
7279        let d = dep_with_fonte(DepSource::Git {
7280            repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
7281            tag: Some("v0.1.0".into()),
7282            rev: None,
7283            branch: None,
7284        });
7285        let err = d.validate().unwrap_err();
7286        let DepError::FonteRepoShape { reason, .. } = err else {
7287            panic!("expected FonteRepoShape, got other variant");
7288        };
7289        assert!(
7290            reason.contains("must not contain `#`"),
7291            "reason must surface the fragment-`#` arm (fires before query-`?` when \
7292             `#` byte appears first in value), got {reason:?}"
7293        );
7294    }
7295
7296    #[test]
7297    fn fonte_repo_control_char_fires_before_fragment() {
7298        // Cascade pin: the control-char arm structurally precedes the
7299        // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
7300        // positive on both arms (contains LF and `#`), but the narrower
7301        // POSIX-syscall-rejected / CRLF-injection-class diagnostic
7302        // (`control character`) wins so the author sees the more
7303        // self-locating arm first. Mirrors the peer cascade discipline
7304        // every prior `:repo` byte-class arm establishes.
7305        let d = dep_with_fonte(DepSource::Git {
7306            repo: "github:pleme-io/caixa-teia\n#readme".into(),
7307            tag: Some("v0.1.0".into()),
7308            rev: None,
7309            branch: None,
7310        });
7311        let err = d.validate().unwrap_err();
7312        let DepError::FonteRepoShape { reason, .. } = err else {
7313            panic!("expected FonteRepoShape, got other variant");
7314        };
7315        assert!(
7316            reason.contains("control character"),
7317            "reason must surface the control-char arm, got {reason:?}"
7318        );
7319    }
7320
7321    #[test]
7322    fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
7323        // The fail-before-pass-after pin for the canonical Windows-
7324        // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
7325        // backslash arm on the sibling `:caminho` path-fonte axis).
7326        // An author pastes a Windows Explorer address-bar / PowerShell
7327        // `Get-Location` output into a `file://` URL slot, producing
7328        // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
7329        // value silently passed every prior arm (no whitespace, no
7330        // control chars, no non-ASCII, no `#`, no `?`, doesn't start
7331        // with `-` or `:`); libcurl's URL parser silently translates
7332        // `\` → `/` on some platforms and refuses it on others, so
7333        // the byte rides verbatim into the lacre's per-dep content-
7334        // address but is silently rewritten / rejected at the wire —
7335        // two authors whose `:repo` values differ only in backslash-
7336        // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
7337        // resolve to the byte-identical local clone but lock to two
7338        // distinct BLAKE3 closures, defeating the THEORY.md §V.2
7339        // render-determinism contract on the same axis the `#`
7340        // fragment and `?` query arms close. Same value-shape axis-
7341        // floor every peer typed surface enforces; the `:caminho`
7342        // 3a4e1d7 arm closes the same byte on the path-fonte axis.
7343        let d = dep_with_fonte(DepSource::Git {
7344            repo: "file:///C:\\Users\\me\\caixa-teia".into(),
7345            tag: Some("v0.1.0".into()),
7346            rev: None,
7347            branch: None,
7348        });
7349        let err = d.validate().unwrap_err();
7350        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7351            panic!("expected FonteRepoShape, got other variant");
7352        };
7353        assert_eq!(nome, "caixa-teia");
7354        assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
7355        assert!(
7356            reason.contains("must not contain `\\`"),
7357            "reason must surface the backslash-`\\` arm, got {reason:?}"
7358        );
7359        assert!(
7360            reason.contains("Windows"),
7361            "reason must name the Windows-path-confusion footgun, got {reason:?}"
7362        );
7363    }
7364
7365    #[test]
7366    fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
7367        // The symmetric Win32-shell-mangled-slashes footgun — an author
7368        // copies `https://github.com/foo/bar` into a Win32 shell that
7369        // rewrites every `/` to `\` (the canonical `cmd.exe` path-
7370        // separator-coercion bug), pastes the result into a `:repo`
7371        // slot, and produces `https:\\github.com\foo\bar`. Pinned
7372        // separately from the `file://` Explorer-paste arm so a future
7373        // relaxation that narrows to one URL scheme surfaces here.
7374        let d = dep_with_fonte(DepSource::Git {
7375            repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
7376            tag: Some("v0.1.0".into()),
7377            rev: None,
7378            branch: None,
7379        });
7380        let err = d.validate().unwrap_err();
7381        let DepError::FonteRepoShape { reason, .. } = err else {
7382            panic!("expected FonteRepoShape, got other variant");
7383        };
7384        assert!(
7385            reason.contains("must not contain `\\`"),
7386            "reason must surface the backslash-`\\` arm, got {reason:?}"
7387        );
7388        assert!(
7389            reason.contains("path separator") || reason.contains("path-segment separator"),
7390            "reason must name the URL path-segment separator grammar, got {reason:?}"
7391        );
7392    }
7393
7394    #[test]
7395    fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
7396        // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
7397        // are both per-byte arms inside the same `for &b in s.as_bytes()`
7398        // loop, so the byte that appears first in the value's byte order
7399        // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
7400        // both `#` and `\`; the `#` byte appears first, so the fragment-
7401        // `#` arm fires, surfacing the more self-locating diagnostic on
7402        // the byte the author pasted earliest in the URL. Mirrors the
7403        // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
7404        // pins on the prior `:repo` byte-class arm.
7405        let d = dep_with_fonte(DepSource::Git {
7406            repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
7407            tag: Some("v0.1.0".into()),
7408            rev: None,
7409            branch: None,
7410        });
7411        let err = d.validate().unwrap_err();
7412        let DepError::FonteRepoShape { reason, .. } = err else {
7413            panic!("expected FonteRepoShape, got other variant");
7414        };
7415        assert!(
7416            reason.contains("must not contain `#`"),
7417            "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
7418             `#` byte appears first in value), got {reason:?}"
7419        );
7420    }
7421
7422    #[test]
7423    fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
7424        // The fail-before-pass-after pin for the canonical URI Template
7425        // (RFC 6570) placeholder footgun on `:repo`. An author copies a
7426        // README quick-start snippet / OpenAPI `servers:` URL / Helm
7427        // chart `home:` template that carries unresolved
7428        // `{org}` / `{repo}` placeholders and pastes the raw template
7429        // into the `:repo` slot, expecting the substrate to resolve the
7430        // placeholder downstream. Until this arm landed the value
7431        // silently passed every prior arm (no whitespace, no control
7432        // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
7433        // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
7434        // / `%7D` on the wire, so the byte rides verbatim into the
7435        // lacre's per-dep content-address but round-trips inconsistently
7436        // between the lacre's per-dep content-address and the
7437        // resolver's `git clone <repo>` invocation, defeating the
7438        // THEORY.md §V.2 render-determinism contract on the same axis
7439        // the `#` fragment, `?` query, and `\` backslash arms close;
7440        // every git porcelain entry-point additionally fetches a
7441        // nonexistent literal-`{placeholder}`-named path far from the
7442        // source caixa.lisp.
7443        let d = dep_with_fonte(DepSource::Git {
7444            repo: "https://github.com/{org}/caixa-teia".into(),
7445            tag: Some("v0.1.0".into()),
7446            rev: None,
7447            branch: None,
7448        });
7449        let err = d.validate().unwrap_err();
7450        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7451            panic!("expected FonteRepoShape, got other variant");
7452        };
7453        assert_eq!(nome, "caixa-teia");
7454        assert_eq!(repo, "https://github.com/{org}/caixa-teia");
7455        assert!(
7456            reason.contains("must not contain `{`"),
7457            "reason must surface the open-brace `{{` arm, got {reason:?}"
7458        );
7459        assert!(
7460            reason.contains("URI Template") || reason.contains("RFC 6570"),
7461            "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
7462        );
7463    }
7464
7465    #[test]
7466    fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
7467        // The symmetric Mustache / Handlebars doubled-brace
7468        // substitution-form footgun every CI / IaC templating engine
7469        // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
7470        // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
7471        // chart README quick-start snippet emits. Pinned separately
7472        // from the single-`{` `{org}` arm so a future relaxation that
7473        // narrows to one substitution-form surfaces here.
7474        let d = dep_with_fonte(DepSource::Git {
7475            repo: "https://github.com/{{org}}/caixa-teia".into(),
7476            tag: Some("v0.1.0".into()),
7477            rev: None,
7478            branch: None,
7479        });
7480        let err = d.validate().unwrap_err();
7481        let DepError::FonteRepoShape { reason, .. } = err else {
7482            panic!("expected FonteRepoShape, got other variant");
7483        };
7484        assert!(
7485            reason.contains("must not contain `{`"),
7486            "reason must surface the open-brace `{{` arm, got {reason:?}"
7487        );
7488    }
7489
7490    #[test]
7491    fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
7492        // Asymmetric `}`-only shape — covers the closing-brace-by-
7493        // itself footgun (an author truncated `{org}/{repo}` mid-edit
7494        // and left a trailing `}` from the prior template fragment,
7495        // or pasted a value that included a closing brace from a
7496        // surrounding shell context). Pinned to ensure the predicate
7497        // refuses each brace independently rather than only when both
7498        // appear — a future regression that ANDs the two byte tests
7499        // surfaces here.
7500        let d = dep_with_fonte(DepSource::Git {
7501            repo: "https://github.com/pleme-io/caixa-teia}".into(),
7502            tag: Some("v0.1.0".into()),
7503            rev: None,
7504            branch: None,
7505        });
7506        let err = d.validate().unwrap_err();
7507        let DepError::FonteRepoShape { reason, .. } = err else {
7508            panic!("expected FonteRepoShape, got other variant");
7509        };
7510        assert!(
7511            reason.contains("must not contain `}`"),
7512            "reason must surface the close-brace `}}` arm, got {reason:?}"
7513        );
7514    }
7515
7516    #[test]
7517    fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
7518        // Cascade pin: the fragment-`#` arm and the template-`{` /
7519        // `}` arm are both per-byte arms inside the same
7520        // `for &b in s.as_bytes()` loop, so the byte that appears
7521        // first in the value's byte order wins. A `:repo
7522        // "https://github.com/p/x#readme{org}"` carries both `#` and
7523        // `{`; the `#` byte appears first, so the fragment-`#` arm
7524        // fires, surfacing the more self-locating diagnostic on the
7525        // byte the author pasted earliest in the URL. Mirrors the
7526        // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
7527        // pins on the prior `:repo` byte-class arm.
7528        let d = dep_with_fonte(DepSource::Git {
7529            repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
7530            tag: Some("v0.1.0".into()),
7531            rev: None,
7532            branch: None,
7533        });
7534        let err = d.validate().unwrap_err();
7535        let DepError::FonteRepoShape { reason, .. } = err else {
7536            panic!("expected FonteRepoShape, got other variant");
7537        };
7538        assert!(
7539            reason.contains("must not contain `#`"),
7540            "reason must surface the fragment-`#` arm (fires before template-`{{` when \
7541             `#` byte appears first in value), got {reason:?}"
7542        );
7543    }
7544
7545    #[test]
7546    fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
7547        // The fail-before-pass-after pin for the canonical
7548        // shell-output-redirection footgun on `:repo`: an author
7549        // pastes a shell-pipeline tail (`git clone <repo> > build.log`
7550        // / `… >output.txt`) into the `:repo` slot without trimming
7551        // the redirect. Until this arm landed the value silently
7552        // passed every prior arm (no whitespace, no control chars,
7553        // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
7554        // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
7555        // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
7556        // percent-encode set maps `>` → `%3E` on the wire, so the
7557        // byte rides verbatim into the lacre's per-dep BLAKE3 closure
7558        // but is silently rewritten or rejected at libcurl's URL-
7559        // parser layer — two authors whose values differ only in
7560        // their redirect tail (`>build.log` vs nothing) resolve to
7561        // the byte-identical upstream `git clone` but lock to two
7562        // distinct lacres, defeating the THEORY.md §V.2 render-
7563        // determinism contract. Peer with the `:caminho` axis's
7564        // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
7565        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7566        // byte RFC-3986-reserved set on `:entrada :paths`.
7567        let d = dep_with_fonte(DepSource::Git {
7568            repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
7569            tag: Some("v0.1.0".into()),
7570            rev: None,
7571            branch: None,
7572        });
7573        let err = d.validate().unwrap_err();
7574        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7575            panic!("expected FonteRepoShape, got other variant");
7576        };
7577        assert_eq!(nome, "caixa-teia");
7578        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
7579        assert!(
7580            reason.contains("must not contain `>`"),
7581            "reason must surface the output-redirection `>` arm, got {reason:?}"
7582        );
7583        assert!(
7584            reason.contains("redirection") || reason.contains("'delims'"),
7585            "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
7586        );
7587    }
7588
7589    #[test]
7590    fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
7591        // The symmetric shell-input-redirection footgun — an author
7592        // pastes a shell-pipeline head (`git clone <input.url` /
7593        // `cat <README.md`) into the `:repo` slot. Pinned separately
7594        // from the `>`-output arm so a future relaxation that only
7595        // catches one of the two redirect bytes surfaces here. Peer
7596        // with the `:caminho` axis's `FonteCaminhoShellRedirection`
7597        // arm which closes both `<` and `>` under the same banner.
7598        let d = dep_with_fonte(DepSource::Git {
7599            repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
7600            tag: Some("v0.1.0".into()),
7601            rev: None,
7602            branch: None,
7603        });
7604        let err = d.validate().unwrap_err();
7605        let DepError::FonteRepoShape { reason, .. } = err else {
7606            panic!("expected FonteRepoShape, got other variant");
7607        };
7608        assert!(
7609            reason.contains("must not contain `<`"),
7610            "reason must surface the input-redirection `<` arm, got {reason:?}"
7611        );
7612        assert!(
7613            reason.contains("RFC 3986") || reason.contains("'unwise'"),
7614            "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
7615        );
7616    }
7617
7618    #[test]
7619    fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
7620        // The fail-before-pass-after pin for the canonical
7621        // paste-from-shell-prompt-with-backticked-substitution footgun
7622        // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
7623        // `:caminho` path-fonte axis). An author pastes a URL whose
7624        // segment carries a backticked command-substitution wrapper
7625        // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
7626        // from a doc / README quick-start snippet that expected the
7627        // substrate to substitute the value downstream. Until this arm
7628        // landed the value silently passed every prior arm (no
7629        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7630        // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
7631        // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
7632        // 'unwise' set and the WHATWG URL spec's fragment percent-
7633        // encode set maps `` ` `` → `%60` on the wire, so the byte
7634        // rides verbatim into the lacre's per-dep BLAKE3 closure but
7635        // is silently rewritten or rejected at libcurl's URL-parser
7636        // layer — two authors whose values differ only in their
7637        // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
7638        // byte-identical upstream `git clone` but lock to two distinct
7639        // lacres, defeating the THEORY.md §V.2 render-determinism
7640        // contract. Peer with the `:caminho` axis's
7641        // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
7642        // sibling path-fonte axis, and `is_gateway_api_http_path`'s
7643        // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
7644        let d = dep_with_fonte(DepSource::Git {
7645            repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
7646            tag: Some("v0.1.0".into()),
7647            rev: None,
7648            branch: None,
7649        });
7650        let err = d.validate().unwrap_err();
7651        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7652            panic!("expected FonteRepoShape, got other variant");
7653        };
7654        assert_eq!(nome, "caixa-teia");
7655        assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
7656        assert!(
7657            reason.contains("must not contain `` ` ``"),
7658            "reason must surface the backtick command-substitution arm, got {reason:?}"
7659        );
7660        assert!(
7661            reason.contains("command-substitution") || reason.contains("'unwise'"),
7662            "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
7663             got {reason:?}"
7664        );
7665    }
7666
7667    #[test]
7668    fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
7669        // Cascade pin: the fragment-`#` arm and the backtick command-
7670        // substitution arm are both per-byte arms inside the same
7671        // `for &b in s.as_bytes()` loop, so the byte that appears first
7672        // in the value's byte order wins. A `:repo
7673        // "https://github.com/p/x#readme/`whoami`"` carries both `#`
7674        // and backtick; the `#` byte appears first, so the fragment-
7675        // `#` arm fires, surfacing the more self-locating diagnostic
7676        // on the byte the author pasted earliest in the URL. Mirrors
7677        // the peer cascade discipline
7678        // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
7679        // pins on the prior `:repo` byte-class arm.
7680        let d = dep_with_fonte(DepSource::Git {
7681            repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
7682            tag: Some("v0.1.0".into()),
7683            rev: None,
7684            branch: None,
7685        });
7686        let err = d.validate().unwrap_err();
7687        let DepError::FonteRepoShape { reason, .. } = err else {
7688            panic!("expected FonteRepoShape, got other variant");
7689        };
7690        assert!(
7691            reason.contains("must not contain `#`"),
7692            "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
7693             appears first in value), got {reason:?}"
7694        );
7695    }
7696
7697    #[test]
7698    fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
7699        // Cascade pin: the shell-redirection `<` / `>` arm and the
7700        // backtick command-substitution arm are both per-byte arms
7701        // inside the same `for &b in s.as_bytes()` loop, so the byte
7702        // that appears first in the value's byte order wins. A `:repo
7703        // "https://github.com/p/x>build.log/`whoami`"` carries both
7704        // `>` and backtick; the `>` byte appears first, so the
7705        // shell-redirection arm fires, surfacing the more self-
7706        // locating diagnostic on the byte the author pasted earliest
7707        // in the URL. Pins the natural-order cascade so a future
7708        // reorder of the per-byte arms surfaces here.
7709        let d = dep_with_fonte(DepSource::Git {
7710            repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
7711            tag: Some("v0.1.0".into()),
7712            rev: None,
7713            branch: None,
7714        });
7715        let err = d.validate().unwrap_err();
7716        let DepError::FonteRepoShape { reason, .. } = err else {
7717            panic!("expected FonteRepoShape, got other variant");
7718        };
7719        assert!(
7720            reason.contains("must not contain `>`"),
7721            "reason must surface the shell-redirection `>` arm (fires before backtick when \
7722             `>` byte appears first in value), got {reason:?}"
7723        );
7724    }
7725
7726    #[test]
7727    fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
7728        // Cascade pin: the fragment-`#` arm and the shell-redirection
7729        // `<` / `>` arm are both per-byte arms inside the same
7730        // `for &b in s.as_bytes()` loop, so the byte that appears
7731        // first in the value's byte order wins. A `:repo
7732        // "https://github.com/p/x#readme>build.log"` carries both
7733        // `#` and `>`; the `#` byte appears first, so the fragment-
7734        // `#` arm fires, surfacing the more self-locating diagnostic
7735        // on the byte the author pasted earliest in the URL. Mirrors
7736        // the peer cascade discipline
7737        // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
7738        // pins on the prior `:repo` byte-class arm.
7739        let d = dep_with_fonte(DepSource::Git {
7740            repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
7741            tag: Some("v0.1.0".into()),
7742            rev: None,
7743            branch: None,
7744        });
7745        let err = d.validate().unwrap_err();
7746        let DepError::FonteRepoShape { reason, .. } = err else {
7747            panic!("expected FonteRepoShape, got other variant");
7748        };
7749        assert!(
7750            reason.contains("must not contain `#`"),
7751            "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
7752             `#` byte appears first in value), got {reason:?}"
7753        );
7754    }
7755
7756    #[test]
7757    fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
7758        // The fail-before-pass-after pin for the canonical
7759        // paste-from-shell-prompt-with-piped-pipeline footgun on
7760        // `:repo` (peer with the 124106f pipe arm on the sibling
7761        // `:caminho` path-fonte axis). An author pastes a shell
7762        // pipeline (`git clone <url> | tee build.log`,
7763        // `git ls-remote <url> | head`) into the `:repo` slot,
7764        // forgetting to trim the `| <consumer>` tail. Until this arm
7765        // landed the value silently passed every prior arm (no
7766        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7767        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
7768        // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
7769        // 'unwise' set and the WHATWG URL spec's fragment percent-
7770        // encode set maps `|` → `%7C` on the wire, so the byte rides
7771        // verbatim into the lacre's per-dep BLAKE3 closure but is
7772        // silently rewritten or rejected at libcurl's URL-parser
7773        // layer — two authors whose values differ only in their pipe
7774        // tail (`|tee build.log` vs nothing) resolve to the byte-
7775        // identical upstream `git clone` but lock to two distinct
7776        // lacres, defeating the THEORY.md §V.2 render-determinism
7777        // contract. Peer with the `:caminho` axis's
7778        // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
7779        // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
7780        // RFC-3986-reserved set on `:entrada :paths`.
7781        let d = dep_with_fonte(DepSource::Git {
7782            repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
7783            tag: Some("v0.1.0".into()),
7784            rev: None,
7785            branch: None,
7786        });
7787        let err = d.validate().unwrap_err();
7788        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7789            panic!("expected FonteRepoShape, got other variant");
7790        };
7791        assert_eq!(nome, "caixa-teia");
7792        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
7793        assert!(
7794            reason.contains("must not contain `|`"),
7795            "reason must surface the shell-pipe arm, got {reason:?}"
7796        );
7797        assert!(
7798            reason.contains("pipe") || reason.contains("'unwise'"),
7799            "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
7800        );
7801    }
7802
7803    #[test]
7804    fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
7805        // Cascade pin: the fragment-`#` arm and the pipe arm are both
7806        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7807        // so the byte that appears first in the value's byte order
7808        // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
7809        // both `#` and `|`; the `#` byte appears first, so the
7810        // fragment-`#` arm fires, surfacing the more self-locating
7811        // diagnostic on the byte the author pasted earliest in the
7812        // URL. Mirrors the peer cascade discipline
7813        // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
7814        // pins on the prior `:repo` byte-class arm.
7815        let d = dep_with_fonte(DepSource::Git {
7816            repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
7817            tag: Some("v0.1.0".into()),
7818            rev: None,
7819            branch: None,
7820        });
7821        let err = d.validate().unwrap_err();
7822        let DepError::FonteRepoShape { reason, .. } = err else {
7823            panic!("expected FonteRepoShape, got other variant");
7824        };
7825        assert!(
7826            reason.contains("must not contain `#`"),
7827            "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
7828             appears first in value), got {reason:?}"
7829        );
7830    }
7831
7832    #[test]
7833    fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
7834        // Cascade pin: the backtick arm and the pipe arm are both per-
7835        // byte arms inside the same `for &b in s.as_bytes()` loop, so
7836        // the byte that appears first in the value's byte order wins.
7837        // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
7838        // `` ` `` and `|`; the backtick byte appears first, so the
7839        // backtick arm fires, surfacing the more self-locating
7840        // diagnostic on the byte the author pasted earliest in the
7841        // URL. Pins the natural-order cascade so a future reorder of
7842        // the per-byte arms surfaces here.
7843        let d = dep_with_fonte(DepSource::Git {
7844            repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
7845            tag: Some("v0.1.0".into()),
7846            rev: None,
7847            branch: None,
7848        });
7849        let err = d.validate().unwrap_err();
7850        let DepError::FonteRepoShape { reason, .. } = err else {
7851            panic!("expected FonteRepoShape, got other variant");
7852        };
7853        assert!(
7854            reason.contains("must not contain `` ` ``"),
7855            "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
7856             appears first in value), got {reason:?}"
7857        );
7858    }
7859
7860    #[test]
7861    fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
7862        // The fail-before-pass-after pin for the canonical
7863        // paste-from-shell-prompt-with-sequential-command-tail footgun
7864        // on `:repo` (peer with the 05c358e `;` arm on the sibling
7865        // `:caminho` path-fonte axis). An author pastes a shell
7866        // one-liner that chained a cleanup tail after the URL
7867        // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
7868        // echo done`) into the `:repo` slot, forgetting to trim the
7869        // `; <cmd>` tail. Until this arm landed the value silently
7870        // passed every prior `is_git_repo_url` arm (no whitespace, no
7871        // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
7872        // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
7873        // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
7874        // reserved set and the WHATWG URL spec's fragment percent-
7875        // encode set maps `;` → `%3B` on the wire, so the byte rides
7876        // verbatim into the lacre's per-dep BLAKE3 closure but is
7877        // silently rewritten at libcurl's URL-parser layer — two
7878        // authors whose values differ only in their sequential-command
7879        // tail (`; rm -rf build` vs nothing) resolve to the byte-
7880        // identical upstream `git clone` but lock to two distinct
7881        // lacres, defeating the THEORY.md §V.2 render-determinism
7882        // contract. Peer with the `:caminho` axis's
7883        // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
7884        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7885        // byte RFC-3986-reserved set on `:entrada :paths`.
7886        let d = dep_with_fonte(DepSource::Git {
7887            repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
7888            tag: Some("v0.1.0".into()),
7889            rev: None,
7890            branch: None,
7891        });
7892        let err = d.validate().unwrap_err();
7893        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7894            panic!("expected FonteRepoShape, got other variant");
7895        };
7896        assert_eq!(nome, "caixa-teia");
7897        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
7898        assert!(
7899            reason.contains("must not contain `;`"),
7900            "reason must surface the shell-command-separator arm, got {reason:?}"
7901        );
7902        assert!(
7903            reason.contains("sequential-command") || reason.contains("'sub-delims'"),
7904            "reason must name the shell-command-separator / RFC-3986-sub-delims \
7905             rationale, got {reason:?}"
7906        );
7907    }
7908
7909    #[test]
7910    fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
7911        // Cascade pin: the fragment-`#` arm and the semicolon arm are
7912        // both per-byte arms inside the same `for &b in s.as_bytes()`
7913        // loop, so the byte that appears first in the value's byte
7914        // order wins. A `:repo "https://github.com/p/x#readme; rm"`
7915        // carries both `#` and `;`; the `#` byte appears first, so the
7916        // fragment-`#` arm fires, surfacing the more self-locating
7917        // diagnostic on the byte the author pasted earliest in the URL.
7918        // Mirrors the peer cascade discipline
7919        // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
7920        // pins on the prior `:repo` byte-class arm.
7921        let d = dep_with_fonte(DepSource::Git {
7922            repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
7923            tag: Some("v0.1.0".into()),
7924            rev: None,
7925            branch: None,
7926        });
7927        let err = d.validate().unwrap_err();
7928        let DepError::FonteRepoShape { reason, .. } = err else {
7929            panic!("expected FonteRepoShape, got other variant");
7930        };
7931        assert!(
7932            reason.contains("must not contain `#`"),
7933            "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
7934             byte appears first in value), got {reason:?}"
7935        );
7936    }
7937
7938    #[test]
7939    fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
7940        // Cascade pin: the pipe arm and the semicolon arm are both
7941        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7942        // so the byte that appears first in the value's byte order
7943        // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
7944        // both `|` and `;`; the `|` byte appears first, so the
7945        // pipe arm fires, surfacing the more self-locating diagnostic
7946        // on the byte the author pasted earliest in the URL. Pins the
7947        // natural-order cascade so a future reorder of the per-byte
7948        // arms surfaces here.
7949        let d = dep_with_fonte(DepSource::Git {
7950            repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
7951            tag: Some("v0.1.0".into()),
7952            rev: None,
7953            branch: None,
7954        });
7955        let err = d.validate().unwrap_err();
7956        let DepError::FonteRepoShape { reason, .. } = err else {
7957            panic!("expected FonteRepoShape, got other variant");
7958        };
7959        assert!(
7960            reason.contains("must not contain `|`"),
7961            "reason must surface the pipe arm (fires before semicolon when `|` byte \
7962             appears first in value), got {reason:?}"
7963        );
7964    }
7965
7966    #[test]
7967    fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
7968        // The fail-before-pass-after pin for the canonical
7969        // paste-from-shell-prompt-with-background-launch-tail footgun
7970        // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
7971        // `:caminho` path-fonte axis). An author pastes a shell one-
7972        // liner that detached the clone into the background
7973        // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
7974        // into the `:repo` slot, forgetting to trim the `& <cmd>` /
7975        // `&& <cmd>` tail. Until this arm landed the value silently
7976        // passed every prior `is_git_repo_url` arm (no whitespace,
7977        // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
7978        // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7979        // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
7980        // the 'sub-delims' / reserved set and the WHATWG URL spec's
7981        // fragment percent-encode set maps `&` → `%26` on the wire,
7982        // so the byte rides verbatim into the lacre's per-dep
7983        // BLAKE3 closure but is silently rewritten at libcurl's
7984        // URL-parser layer — two authors whose values differ only
7985        // in their background-launch tail (`& sleep 1` vs nothing)
7986        // resolve to the byte-identical upstream `git clone` but
7987        // lock to two distinct lacres, defeating the THEORY.md
7988        // §V.2 render-determinism contract. Peer with the
7989        // `:caminho` axis's `FonteCaminhoShellBackground` arm
7990        // (e12e4f3) on the sibling path-fonte axis, and
7991        // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
7992        // reserved set on `:entrada :paths`.
7993        let d = dep_with_fonte(DepSource::Git {
7994            repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
7995            tag: Some("v0.1.0".into()),
7996            rev: None,
7997            branch: None,
7998        });
7999        let err = d.validate().unwrap_err();
8000        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8001            panic!("expected FonteRepoShape, got other variant");
8002        };
8003        assert_eq!(nome, "caixa-teia");
8004        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
8005        assert!(
8006            reason.contains("must not contain `&`"),
8007            "reason must surface the shell-background / logical-AND arm, got {reason:?}"
8008        );
8009        assert!(
8010            reason.contains("background-task") || reason.contains("'sub-delims'"),
8011            "reason must name the shell-background / RFC-3986-sub-delims rationale, \
8012             got {reason:?}"
8013        );
8014    }
8015
8016    #[test]
8017    fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
8018        // The fail-before-pass-after pin for the symmetric `&&`
8019        // logical-AND build-chain paste footgun: an author pastes
8020        // a `git clone <url> && cd <repo>` build-chain one-liner
8021        // and forgets to trim the `&& <cmd>` tail. The `&&` shape
8022        // is the same `&` byte twice in a row; the per-byte arm
8023        // fires on the first `&` it sees. Pinned separately from
8024        // the single-`&` background-launch shape so a future
8025        // diagnostic-surface change that special-cased the
8026        // doubled-byte form surfaces here.
8027        let d = dep_with_fonte(DepSource::Git {
8028            repo: "github:pleme-io/caixa-teia&&echo".into(),
8029            tag: Some("v0.1.0".into()),
8030            rev: None,
8031            branch: None,
8032        });
8033        let err = d.validate().unwrap_err();
8034        let DepError::FonteRepoShape { reason, .. } = err else {
8035            panic!("expected FonteRepoShape, got other variant");
8036        };
8037        assert!(
8038            reason.contains("must not contain `&`"),
8039            "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
8040             shape too, got {reason:?}"
8041        );
8042    }
8043
8044    #[test]
8045    fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
8046        // Cascade pin: the fragment-`#` arm and the background-`&`
8047        // arm are both per-byte arms inside the same `for &b in
8048        // s.as_bytes()` loop, so the byte that appears first in the
8049        // value's byte order wins. A `:repo
8050        // "https://github.com/p/x#readme & sleep"` carries both `#`
8051        // and `&`; the `#` byte appears first, so the fragment-`#`
8052        // arm fires, surfacing the more self-locating diagnostic on
8053        // the byte the author pasted earliest in the URL. Mirrors
8054        // the peer cascade discipline
8055        // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
8056        // on the prior `:repo` byte-class arm.
8057        let d = dep_with_fonte(DepSource::Git {
8058            repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
8059            tag: Some("v0.1.0".into()),
8060            rev: None,
8061            branch: None,
8062        });
8063        let err = d.validate().unwrap_err();
8064        let DepError::FonteRepoShape { reason, .. } = err else {
8065            panic!("expected FonteRepoShape, got other variant");
8066        };
8067        assert!(
8068            reason.contains("must not contain `#`"),
8069            "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
8070             byte appears first in value), got {reason:?}"
8071        );
8072    }
8073
8074    #[test]
8075    fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
8076        // Cascade pin: the semicolon arm and the background-`&` arm
8077        // are both per-byte arms inside the same `for &b in
8078        // s.as_bytes()` loop, so the byte that appears first in the
8079        // value's byte order wins. A `:repo
8080        // "https://github.com/p/x; rm & sleep"` carries both `;` and
8081        // `&`; the `;` byte appears first, so the semicolon arm
8082        // fires, surfacing the more self-locating diagnostic on the
8083        // byte the author pasted earliest in the URL. Pins the
8084        // natural-order cascade so a future reorder of the per-byte
8085        // arms surfaces here.
8086        let d = dep_with_fonte(DepSource::Git {
8087            repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
8088            tag: Some("v0.1.0".into()),
8089            rev: None,
8090            branch: None,
8091        });
8092        let err = d.validate().unwrap_err();
8093        let DepError::FonteRepoShape { reason, .. } = err else {
8094            panic!("expected FonteRepoShape, got other variant");
8095        };
8096        assert!(
8097            reason.contains("must not contain `;`"),
8098            "reason must surface the semicolon arm (fires before background-`&` when `;` \
8099             byte appears first in value), got {reason:?}"
8100        );
8101    }
8102
8103    #[test]
8104    fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
8105        // The fail-before-pass-after pin for the canonical
8106        // paste-from-shell-prompt-with-unsubstituted-variable footgun
8107        // on `:repo` (peer with the f4efe9c `$` arm on the sibling
8108        // `:caminho` path-fonte axis). An author pastes a shell one-
8109        // liner that referenced an environment variable
8110        // (`git clone https://github.com/$ORG/x`, `git clone
8111        // github:$USER/repo`) into the `:repo` slot, forgetting to
8112        // substitute the literal value at author time. Until this arm
8113        // landed the value silently passed every prior
8114        // `is_git_repo_url` arm (no whitespace, no control chars, no
8115        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
8116        // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
8117        // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
8118        // reserved set and the WHATWG URL spec's fragment percent-
8119        // encode set maps `$` → `%24` on the wire, so the byte rides
8120        // verbatim into the lacre's per-dep BLAKE3 closure but is
8121        // silently rewritten at libcurl's URL-parser layer — two
8122        // authors whose values differ only in their `$VAR` /
8123        // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
8124        // identical upstream `git clone` but lock to two distinct
8125        // lacres, defeating the THEORY.md §V.2 render-determinism
8126        // contract. Beyond determinism, the value is a structural
8127        // host-layout leak: two authors with the same `:repo` slot
8128        // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
8129        // different upstreams. Peer with the `:caminho` axis's
8130        // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
8131        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
8132        // byte RFC-3986-reserved set on `:entrada :paths`.
8133        let d = dep_with_fonte(DepSource::Git {
8134            repo: "https://github.com/$ORG/caixa-teia".into(),
8135            tag: Some("v0.1.0".into()),
8136            rev: None,
8137            branch: None,
8138        });
8139        let err = d.validate().unwrap_err();
8140        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8141            panic!("expected FonteRepoShape, got other variant");
8142        };
8143        assert_eq!(nome, "caixa-teia");
8144        assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
8145        assert!(
8146            reason.contains("must not contain `$`"),
8147            "reason must surface the shell-variable-expansion arm, got {reason:?}"
8148        );
8149        assert!(
8150            reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
8151            "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
8152             rationale, got {reason:?}"
8153        );
8154    }
8155
8156    #[test]
8157    fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
8158        // The fail-before-pass-after pin for the symmetric POSIX-
8159        // shell braced `${VAR}` expansion paste footgun: an author
8160        // pastes a CI-manifest line `git clone
8161        // https://github.com/${WORKSPACE}/x` (the canonical GitHub
8162        // Actions / GitLab CI / Drone shape) and forgets to
8163        // substitute the literal value. The `${...}` shape is the
8164        // same `$` byte at the leading position of the expansion;
8165        // the per-byte arm fires on the `$`. Pinned separately from
8166        // the bare-`$VAR` shape so a future diagnostic-surface
8167        // change that special-cased the braced form surfaces here.
8168        let d = dep_with_fonte(DepSource::Git {
8169            repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
8170            tag: Some("v0.1.0".into()),
8171            rev: None,
8172            branch: None,
8173        });
8174        let err = d.validate().unwrap_err();
8175        let DepError::FonteRepoShape { reason, .. } = err else {
8176            panic!("expected FonteRepoShape, got other variant");
8177        };
8178        assert!(
8179            reason.contains("must not contain `$`"),
8180            "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
8181             shape too, got {reason:?}"
8182        );
8183    }
8184
8185    #[test]
8186    fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
8187        // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
8188        // arm are both per-byte arms inside the same `for &b in
8189        // s.as_bytes()` loop, so the byte that appears first in the
8190        // value's byte order wins. A `:repo
8191        // "https://github.com/p/x#readme$HOME"` carries both `#` and
8192        // `$`; the `#` byte appears first, so the fragment-`#` arm
8193        // fires, surfacing the more self-locating diagnostic on the
8194        // byte the author pasted earliest in the URL. Mirrors the
8195        // peer cascade discipline
8196        // `fonte_repo_fragment_fires_before_background_when_fragment_first`
8197        // on the prior `:repo` byte-class arm.
8198        let d = dep_with_fonte(DepSource::Git {
8199            repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
8200            tag: Some("v0.1.0".into()),
8201            rev: None,
8202            branch: None,
8203        });
8204        let err = d.validate().unwrap_err();
8205        let DepError::FonteRepoShape { reason, .. } = err else {
8206            panic!("expected FonteRepoShape, got other variant");
8207        };
8208        assert!(
8209            reason.contains("must not contain `#`"),
8210            "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
8211             `#` byte appears first in value), got {reason:?}"
8212        );
8213    }
8214
8215    #[test]
8216    fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
8217        // Cascade pin: the background-`&` arm and the
8218        // var-expansion-`$` arm are both per-byte arms inside the
8219        // same `for &b in s.as_bytes()` loop, so the byte that
8220        // appears first in the value's byte order wins. A `:repo
8221        // "https://github.com/p/x&sleep$HOME"` carries both `&` and
8222        // `$`; the `&` byte appears first, so the background arm
8223        // fires, surfacing the more self-locating diagnostic on the
8224        // byte the author pasted earliest in the URL. Pins the
8225        // natural-order cascade so a future reorder of the per-byte
8226        // arms surfaces here — `$` is the most recent byte-class arm,
8227        // so the cascade-pin sweep extends to cover every immediately
8228        // prior byte arm (`#`, `&`) firing first when ordered ahead
8229        // of `$` in the value.
8230        let d = dep_with_fonte(DepSource::Git {
8231            repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
8232            tag: Some("v0.1.0".into()),
8233            rev: None,
8234            branch: None,
8235        });
8236        let err = d.validate().unwrap_err();
8237        let DepError::FonteRepoShape { reason, .. } = err else {
8238            panic!("expected FonteRepoShape, got other variant");
8239        };
8240        assert!(
8241            reason.contains("must not contain `&`"),
8242            "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
8243             `&` byte appears first in value), got {reason:?}"
8244        );
8245    }
8246
8247    #[test]
8248    fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
8249        // The fail-before-pass-after pin for the canonical
8250        // paste-from-shell-prompt glob footgun on `:repo` (peer with
8251        // the cf9034b `*` / `?` arm on the sibling `:caminho`
8252        // path-fonte axis). An author pastes a shell one-liner that
8253        // referenced a glob expansion (`ls
8254        // github.com/pleme-io/caixa-*`, `git clone
8255        // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
8256        // to substitute the literal repo name. Until this arm landed
8257        // the `*` byte silently passed every prior `is_git_repo_url`
8258        // arm (no whitespace, no control chars, no non-ASCII, no `#`,
8259        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
8260        // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
8261        // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
8262        // the WHATWG URL spec's special-query percent-encode set maps
8263        // `*` → `%2A` on the wire, so the byte rides verbatim into
8264        // the lacre's per-dep BLAKE3 closure but is silently
8265        // rewritten at libcurl's URL-parser layer — two authors
8266        // whose values differ only in their asterisk presence
8267        // resolve to the byte-identical upstream `git clone` but
8268        // lock to two distinct lacres, defeating the THEORY.md §V.2
8269        // render-determinism contract. Peer with the `:caminho`
8270        // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
8271        // sibling path-fonte axis, and the `is_git_ref_name`
8272        // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
8273        // axes.
8274        let d = dep_with_fonte(DepSource::Git {
8275            repo: "https://github.com/pleme-io/caixa-*".into(),
8276            tag: Some("v0.1.0".into()),
8277            rev: None,
8278            branch: None,
8279        });
8280        let err = d.validate().unwrap_err();
8281        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8282            panic!("expected FonteRepoShape, got other variant");
8283        };
8284        assert_eq!(nome, "caixa-teia");
8285        assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
8286        assert!(
8287            reason.contains("must not contain `*`"),
8288            "reason must surface the shell-glob arm, got {reason:?}"
8289        );
8290        assert!(
8291            reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
8292            "reason must name the shell-glob / pathname-expansion / \
8293             RFC-3986-sub-delims rationale, got {reason:?}"
8294        );
8295    }
8296
8297    #[test]
8298    fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
8299        // The fail-before-pass-after pin for the symmetric bash
8300        // `globstar` recursive-glob paste footgun: an author pastes
8301        // a `ls github.com/pleme-io/**/x` (the canonical
8302        // `globstar`-shopt-enabled recursive-listing tail) into the
8303        // `:repo` slot. The `**` shape is two `*` bytes adjacent;
8304        // the per-byte arm fires on the first `*`. Pinned
8305        // separately from the single-`*` shape so a future
8306        // diagnostic-surface change that special-cased the
8307        // double-`*` form surfaces here.
8308        let d = dep_with_fonte(DepSource::Git {
8309            repo: "https://github.com/pleme-io/**/caixa-teia".into(),
8310            tag: Some("v0.1.0".into()),
8311            rev: None,
8312            branch: None,
8313        });
8314        let err = d.validate().unwrap_err();
8315        let DepError::FonteRepoShape { reason, .. } = err else {
8316            panic!("expected FonteRepoShape, got other variant");
8317        };
8318        assert!(
8319            reason.contains("must not contain `*`"),
8320            "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
8321             got {reason:?}"
8322        );
8323    }
8324
8325    #[test]
8326    fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
8327        // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
8328        // both per-byte arms inside the same `for &b in s.as_bytes()`
8329        // loop, so the byte that appears first in the value's byte
8330        // order wins. A `:repo
8331        // "https://github.com/p/x#readme*tail"` carries both `#` and
8332        // `*`; the `#` byte appears first, so the fragment-`#` arm
8333        // fires, surfacing the more self-locating diagnostic on the
8334        // byte the author pasted earliest in the URL. Mirrors the
8335        // peer cascade discipline
8336        // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
8337        // on the prior `:repo` byte-class arm.
8338        let d = dep_with_fonte(DepSource::Git {
8339            repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
8340            tag: Some("v0.1.0".into()),
8341            rev: None,
8342            branch: None,
8343        });
8344        let err = d.validate().unwrap_err();
8345        let DepError::FonteRepoShape { reason, .. } = err else {
8346            panic!("expected FonteRepoShape, got other variant");
8347        };
8348        assert!(
8349            reason.contains("must not contain `#`"),
8350            "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
8351             appears first in value), got {reason:?}"
8352        );
8353    }
8354
8355    #[test]
8356    fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
8357        // Cascade pin: the var-expansion-`$` arm and the glob-`*`
8358        // arm are both per-byte arms inside the same `for &b in
8359        // s.as_bytes()` loop, so the byte that appears first in the
8360        // value's byte order wins. A `:repo
8361        // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
8362        // the `$` byte appears first, so the var-expansion arm
8363        // fires, surfacing the more self-locating diagnostic on the
8364        // byte the author pasted earliest in the URL. Pins the
8365        // natural-order cascade so a future reorder of the per-byte
8366        // arms surfaces here — `*` is the most recent byte-class
8367        // arm, so the cascade-pin sweep extends to cover the
8368        // immediately prior `$` byte arm firing first when ordered
8369        // ahead of `*` in the value.
8370        let d = dep_with_fonte(DepSource::Git {
8371            repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
8372            tag: Some("v0.1.0".into()),
8373            rev: None,
8374            branch: None,
8375        });
8376        let err = d.validate().unwrap_err();
8377        let DepError::FonteRepoShape { reason, .. } = err else {
8378            panic!("expected FonteRepoShape, got other variant");
8379        };
8380        assert!(
8381            reason.contains("must not contain `$`"),
8382            "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
8383             byte appears first in value), got {reason:?}"
8384        );
8385    }
8386
8387    #[test]
8388    fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
8389        // The fail-before-pass-after pin for the canonical paste-from-
8390        // shell-prompt subshell-grouping footgun on `:repo`. An author
8391        // pastes a doc / README snippet carrying a regex-alternation
8392        // grouping shape (`https://github.com/(foo|bar)/repo`) or a
8393        // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
8394        // `:repo` slot, forgetting to substitute one literal org name.
8395        // Until this arm landed the `(` byte silently passed every
8396        // prior `is_git_repo_url` arm (no whitespace, no control
8397        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8398        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
8399        // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
8400        // / `)` in the 'sub-delims' / reserved set, and the WHATWG
8401        // URL spec's special-query percent-encode set maps `(` →
8402        // `%28` and `)` → `%29` on the wire, so the byte rides
8403        // verbatim into the lacre's per-dep BLAKE3 closure but is
8404        // silently rewritten at libcurl's URL-parser layer —
8405        // defeating the THEORY.md §V.2 render-determinism contract on
8406        // the same axis the prior twelve byte-class arms close.
8407        let d = dep_with_fonte(DepSource::Git {
8408            repo: "https://github.com/(foo|bar)/caixa-teia".into(),
8409            tag: Some("v0.1.0".into()),
8410            rev: None,
8411            branch: None,
8412        });
8413        let err = d.validate().unwrap_err();
8414        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8415            panic!("expected FonteRepoShape, got other variant");
8416        };
8417        assert_eq!(nome, "caixa-teia");
8418        assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
8419        assert!(
8420            reason.contains("must not contain `(`"),
8421            "reason must surface the subshell-open-paren arm, got {reason:?}"
8422        );
8423        assert!(
8424            reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
8425            "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
8426             got {reason:?}"
8427        );
8428    }
8429
8430    #[test]
8431    fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
8432        // The symmetric arm pin on the closing `)` byte: an author
8433        // pastes a `$(date)` command-substitution wrapper or a
8434        // regex-alternation `(foo|bar)` tail into the `:repo` slot.
8435        // Pinned separately from the opening `(` shape so a future
8436        // diagnostic-surface change that only checked one boundary
8437        // surfaces here. The `(` byte appears earlier in the
8438        // canonical regex / subshell wrapper so the per-byte loop
8439        // fires on `(` first; this test exercises a `:repo` value
8440        // carrying only the closing `)` byte (no opening paren) so
8441        // the `)` arm fires directly — pinning the byte-class arm
8442        // independent of order.
8443        let d = dep_with_fonte(DepSource::Git {
8444            repo: "github:pleme-io/caixa-teia)tail".into(),
8445            tag: Some("v0.1.0".into()),
8446            rev: None,
8447            branch: None,
8448        });
8449        let err = d.validate().unwrap_err();
8450        let DepError::FonteRepoShape { reason, .. } = err else {
8451            panic!("expected FonteRepoShape, got other variant");
8452        };
8453        assert!(
8454            reason.contains("must not contain `)`"),
8455            "reason must surface the subshell-close-paren arm on the bare `)` shape, \
8456             got {reason:?}"
8457        );
8458    }
8459
8460    #[test]
8461    fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
8462        // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
8463        // are both per-byte arms inside the same `for &b in
8464        // s.as_bytes()` loop, so the byte that appears first in the
8465        // value's byte order wins. A `:repo
8466        // "https://github.com/p/x#readme(tail)"` carries both `#` and
8467        // `(`; the `#` byte appears first, so the fragment-`#` arm
8468        // fires, surfacing the more self-locating diagnostic on the
8469        // byte the author pasted earliest in the URL. Mirrors the
8470        // peer cascade discipline
8471        // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
8472        // on the prior `:repo` byte-class arm.
8473        let d = dep_with_fonte(DepSource::Git {
8474            repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
8475            tag: Some("v0.1.0".into()),
8476            rev: None,
8477            branch: None,
8478        });
8479        let err = d.validate().unwrap_err();
8480        let DepError::FonteRepoShape { reason, .. } = err else {
8481            panic!("expected FonteRepoShape, got other variant");
8482        };
8483        assert!(
8484            reason.contains("must not contain `#`"),
8485            "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
8486             byte appears first in value), got {reason:?}"
8487        );
8488    }
8489
8490    #[test]
8491    fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
8492        // Cascade pin: the glob-`*` arm (the immediate-predecessor
8493        // byte-class arm, 3902a9a) and the subshell-`(` arm are both
8494        // per-byte arms inside the same `for &b in s.as_bytes()`
8495        // loop, so the byte that appears first in the value's byte
8496        // order wins. A `:repo
8497        // "https://github.com/p/x-*-(date)"` carries both `*` and
8498        // `(`; the `*` byte appears first, so the glob arm fires,
8499        // surfacing the more self-locating diagnostic on the byte
8500        // the author pasted earliest in the URL. Pins the natural-
8501        // order cascade so a future reorder of the per-byte arms
8502        // surfaces here — `(` is the most recent byte-class arm,
8503        // so the cascade-pin sweep extends to cover the immediately
8504        // prior `*` byte arm firing first when ordered ahead of `(`
8505        // in the value.
8506        let d = dep_with_fonte(DepSource::Git {
8507            repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
8508            tag: Some("v0.1.0".into()),
8509            rev: None,
8510            branch: None,
8511        });
8512        let err = d.validate().unwrap_err();
8513        let DepError::FonteRepoShape { reason, .. } = err else {
8514            panic!("expected FonteRepoShape, got other variant");
8515        };
8516        assert!(
8517            reason.contains("must not contain `*`"),
8518            "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
8519             appears first in value), got {reason:?}"
8520        );
8521    }
8522
8523    #[test]
8524    fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
8525        // The fail-before-pass-after pin for the canonical paste-from-
8526        // doc-shell-quoting footgun on `:repo`. An author copies a
8527        // README quick-start snippet (`$ git clone "https://github.com/
8528        // foo/bar"`) and keeps the surrounding double-quote bytes when
8529        // pasting into the `:repo` slot — the doc wraps the URL in
8530        // double quotes so the shell doesn't re-lex metachars inside,
8531        // but the typed slot is itself a byte-level string parser, not
8532        // a shell context, so the quote bytes ride into the value
8533        // verbatim. Until this arm landed the `"` byte silently passed
8534        // every prior `is_git_repo_url` arm (no whitespace, no control
8535        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8536        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
8537        // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
8538        // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
8539        // `` ` ``) every URL parser is required to refuse or percent-
8540        // encode, and the WHATWG URL spec's 'C0 control percent-encode
8541        // set' maps `"` → `%22` on the wire, so the byte rides verbatim
8542        // into the lacre's per-dep BLAKE3 closure but is silently
8543        // rewritten at libcurl's URL-parser layer, defeating the
8544        // THEORY.md §V.2 render-determinism contract.
8545        let d = dep_with_fonte(DepSource::Git {
8546            repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
8547            tag: Some("v0.1.0".into()),
8548            rev: None,
8549            branch: None,
8550        });
8551        let err = d.validate().unwrap_err();
8552        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8553            panic!("expected FonteRepoShape, got other variant");
8554        };
8555        assert_eq!(nome, "caixa-teia");
8556        assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
8557        assert!(
8558            reason.contains("must not contain `\"`"),
8559            "reason must surface the shell-double-quote arm, got {reason:?}"
8560        );
8561        assert!(
8562            reason.contains("double-quote") || reason.contains("'delims'"),
8563            "reason must name the shell-double-quote / RFC-3986-delims rationale, \
8564             got {reason:?}"
8565        );
8566    }
8567
8568    #[test]
8569    fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
8570        // The symmetric stray-quote tail pin: an author pastes only a
8571        // closing `"` from a shell-history line like `git clone
8572        // "https://github.com/foo/bar" && cd …` (the trim went too
8573        // far in one direction but not the other) into the `:repo`
8574        // slot. Pinned separately from the wrapped-quote shape so a
8575        // future diagnostic-surface change that only checked one
8576        // boundary (only leading, only trailing, only paired) surfaces
8577        // here — the per-byte arm fires anywhere `"` appears.
8578        let d = dep_with_fonte(DepSource::Git {
8579            repo: "github:pleme-io/caixa-teia\"".into(),
8580            tag: Some("v0.1.0".into()),
8581            rev: None,
8582            branch: None,
8583        });
8584        let err = d.validate().unwrap_err();
8585        let DepError::FonteRepoShape { reason, .. } = err else {
8586            panic!("expected FonteRepoShape, got other variant");
8587        };
8588        assert!(
8589            reason.contains("must not contain `\"`"),
8590            "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
8591             got {reason:?}"
8592        );
8593    }
8594
8595    #[test]
8596    fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
8597        // Cascade pin: the fragment-`#` arm and the double-quote arm
8598        // are both per-byte arms inside the same `for &b in
8599        // s.as_bytes()` loop, so the byte that appears first in the
8600        // value's byte order wins. A `:repo
8601        // "https://github.com/p/x#readme\"tail"` carries both `#` and
8602        // `"`; the `#` byte appears first, so the fragment-`#` arm
8603        // fires, surfacing the more self-locating diagnostic on the
8604        // byte the author pasted earliest in the URL.
8605        let d = dep_with_fonte(DepSource::Git {
8606            repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
8607            tag: Some("v0.1.0".into()),
8608            rev: None,
8609            branch: None,
8610        });
8611        let err = d.validate().unwrap_err();
8612        let DepError::FonteRepoShape { reason, .. } = err else {
8613            panic!("expected FonteRepoShape, got other variant");
8614        };
8615        assert!(
8616            reason.contains("must not contain `#`"),
8617            "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
8618             byte appears first in value), got {reason:?}"
8619        );
8620    }
8621
8622    #[test]
8623    fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
8624        // Cascade pin: the subshell-`(` arm (the immediate-predecessor
8625        // byte-class arm, 3b99147) and the double-quote arm are both
8626        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8627        // so the byte that appears first in the value's byte order
8628        // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
8629        // and `"`; the `(` byte appears first, so the subshell arm
8630        // fires, surfacing the more self-locating diagnostic on the
8631        // byte the author pasted earliest in the URL. Pins the natural-
8632        // order cascade so a future reorder of the per-byte arms
8633        // surfaces here — `"` is the most recent byte-class arm, so
8634        // the cascade-pin sweep extends to cover the immediately prior
8635        // `(` byte arm firing first when ordered ahead of `"` in the
8636        // value.
8637        let d = dep_with_fonte(DepSource::Git {
8638            repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
8639            tag: Some("v0.1.0".into()),
8640            rev: None,
8641            branch: None,
8642        });
8643        let err = d.validate().unwrap_err();
8644        let DepError::FonteRepoShape { reason, .. } = err else {
8645            panic!("expected FonteRepoShape, got other variant");
8646        };
8647        assert!(
8648            reason.contains("must not contain `(`"),
8649            "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
8650             byte appears first in value), got {reason:?}"
8651        );
8652    }
8653
8654    #[test]
8655    fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
8656        // The fail-before-pass-after pin for the canonical paste-from-
8657        // doc-strong-quoting footgun on `:repo`. An author copies a
8658        // security-conscious README quick-start snippet (`$ git clone
8659        // 'https://github.com/foo/bar'`) and keeps the surrounding
8660        // single-quote bytes when pasting into the `:repo` slot — the
8661        // doc strong-quotes the URL so the shell suppresses every form
8662        // of expansion on the bytes inside (no `$`, no backtick, no
8663        // glob, no word-splitting), but the typed slot is itself a
8664        // byte-level string parser, not a shell context, so the quote
8665        // bytes ride into the value verbatim. Until this arm landed the
8666        // `'` byte silently passed every prior `is_git_repo_url` arm
8667        // (no whitespace, no control chars, no non-ASCII, no `#`, no
8668        // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
8669        // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
8670        // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
8671        // set, peer with the `\"` 'delims' double-quote arm and the
8672        // partner ASCII shell-string-delimiter byte every byte-level
8673        // string parser sharing a value-shape with a shell argument
8674        // must refuse on a URL-shaped slot.
8675        let d = dep_with_fonte(DepSource::Git {
8676            repo: "'https://github.com/pleme-io/caixa-teia'".into(),
8677            tag: Some("v0.1.0".into()),
8678            rev: None,
8679            branch: None,
8680        });
8681        let err = d.validate().unwrap_err();
8682        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8683            panic!("expected FonteRepoShape, got other variant");
8684        };
8685        assert_eq!(nome, "caixa-teia");
8686        assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
8687        assert!(
8688            reason.contains("must not contain `'`"),
8689            "reason must surface the shell-single-quote arm, got {reason:?}"
8690        );
8691        assert!(
8692            reason.contains("single-quote") || reason.contains("strong-quote"),
8693            "reason must name the shell-single-quote / strong-quote rationale, \
8694             got {reason:?}"
8695        );
8696    }
8697
8698    #[test]
8699    fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
8700        // The symmetric English-typography pin: an author writes
8701        // `:repo "github:p/repo's-fork"` (the possessive-form paste-
8702        // from-prose idiom every README / commit-message / chat-thread
8703        // reference to a repo carries) expecting the substrate to
8704        // coerce it to a kebab-case slug — but the byte rides into the
8705        // lacre verbatim. Pinned separately from the wrapped-quote
8706        // shape so a future diagnostic-surface change that only checked
8707        // the boundary positions (only leading, only trailing, only
8708        // paired) surfaces here — the per-byte arm fires anywhere `'`
8709        // appears in the value.
8710        let d = dep_with_fonte(DepSource::Git {
8711            repo: "github:pleme-io/repo's-fork".into(),
8712            tag: Some("v0.1.0".into()),
8713            rev: None,
8714            branch: None,
8715        });
8716        let err = d.validate().unwrap_err();
8717        let DepError::FonteRepoShape { reason, .. } = err else {
8718            panic!("expected FonteRepoShape, got other variant");
8719        };
8720        assert!(
8721            reason.contains("must not contain `'`"),
8722            "reason must surface the shell-single-quote arm on the mid-string \
8723             apostrophe shape, got {reason:?}"
8724        );
8725    }
8726
8727    #[test]
8728    fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
8729        // Cascade pin: the fragment-`#` arm and the single-quote arm
8730        // are both per-byte arms inside the same `for &b in
8731        // s.as_bytes()` loop, so the byte that appears first in the
8732        // value's byte order wins. A `:repo
8733        // "https://github.com/p/x#readme'tail"` carries both `#` and
8734        // `'`; the `#` byte appears first, so the fragment-`#` arm
8735        // fires, surfacing the more self-locating diagnostic on the
8736        // byte the author pasted earliest in the URL.
8737        let d = dep_with_fonte(DepSource::Git {
8738            repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
8739            tag: Some("v0.1.0".into()),
8740            rev: None,
8741            branch: None,
8742        });
8743        let err = d.validate().unwrap_err();
8744        let DepError::FonteRepoShape { reason, .. } = err else {
8745            panic!("expected FonteRepoShape, got other variant");
8746        };
8747        assert!(
8748            reason.contains("must not contain `#`"),
8749            "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
8750             byte appears first in value), got {reason:?}"
8751        );
8752    }
8753
8754    #[test]
8755    fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
8756        // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
8757        // byte-class arm, 4267d8b) and the single-quote arm are both
8758        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8759        // so the byte that appears first in the value's byte order
8760        // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
8761        // `'`; the `"` byte appears first, so the double-quote arm
8762        // fires, surfacing the more self-locating diagnostic on the
8763        // byte the author pasted earliest in the URL. Pins the natural-
8764        // order cascade so a future reorder of the per-byte arms
8765        // surfaces here — `'` is the most recent byte-class arm, so
8766        // the cascade-pin sweep extends to cover the immediately prior
8767        // `"` byte arm firing first when ordered ahead of `'` in the
8768        // value.
8769        let d = dep_with_fonte(DepSource::Git {
8770            repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
8771            tag: Some("v0.1.0".into()),
8772            rev: None,
8773            branch: None,
8774        });
8775        let err = d.validate().unwrap_err();
8776        let DepError::FonteRepoShape { reason, .. } = err else {
8777            panic!("expected FonteRepoShape, got other variant");
8778        };
8779        assert!(
8780            reason.contains("must not contain `\"`"),
8781            "reason must surface the double-quote arm (fires before single-quote when `\"` \
8782             byte appears first in value), got {reason:?}"
8783        );
8784    }
8785
8786    #[test]
8787    fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
8788        // The fail-before-pass-after pin for the canonical paste-from-
8789        // shell-history footgun on `:repo`. An author copies a `git
8790        // clone <url>!sudo make install` one-liner from a README's
8791        // quick-start snippet, intending the trailing `!sudo` as a
8792        // shell-history-expansion reference but the typed slot is itself
8793        // a byte-level string parser, not a shell context, so the byte
8794        // rides into the value verbatim. Until this arm landed the `!`
8795        // byte silently passed every prior `is_git_repo_url` arm (no
8796        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
8797        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
8798        // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
8799        // start with `-` or `:`); bash with the default `histexpand`
8800        // mode rewrites `!command` to the most recent history entry
8801        // beginning with `command`, the canonical RCE-class injection
8802        // vector when the byte rides into a shell argument.
8803        let d = dep_with_fonte(DepSource::Git {
8804            repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
8805            tag: Some("v0.1.0".into()),
8806            rev: None,
8807            branch: None,
8808        });
8809        let err = d.validate().unwrap_err();
8810        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8811            panic!("expected FonteRepoShape, got other variant");
8812        };
8813        assert_eq!(nome, "caixa-teia");
8814        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
8815        assert!(
8816            reason.contains("must not contain `!`"),
8817            "reason must surface the shell-history-expansion arm, got {reason:?}"
8818        );
8819        assert!(
8820            reason.contains("history-expansion") || reason.contains("bang"),
8821            "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
8822        );
8823    }
8824
8825    #[test]
8826    fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
8827        // The symmetric `!!` repeat-prior-command pin: an author paste-
8828        // trims a `git clone <url>` retry idiom from shell history that
8829        // expands to the previous command via `!!`. Pinned separately
8830        // from the wrapped `!command` shape so a future diagnostic-
8831        // surface change that only checked the leading or paired-bang
8832        // position surfaces here — the per-byte arm fires anywhere `!`
8833        // appears in the value.
8834        let d = dep_with_fonte(DepSource::Git {
8835            repo: "github:pleme-io/caixa-teia!!".into(),
8836            tag: Some("v0.1.0".into()),
8837            rev: None,
8838            branch: None,
8839        });
8840        let err = d.validate().unwrap_err();
8841        let DepError::FonteRepoShape { reason, .. } = err else {
8842            panic!("expected FonteRepoShape, got other variant");
8843        };
8844        assert!(
8845            reason.contains("must not contain `!`"),
8846            "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
8847             got {reason:?}"
8848        );
8849    }
8850
8851    #[test]
8852    fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
8853        // Cascade pin: the fragment-`#` arm and the bang arm are both
8854        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8855        // so the byte that appears first in the value's byte order
8856        // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
8857        // both `#` and `!`; the `#` byte appears first, so the
8858        // fragment-`#` arm fires, surfacing the more self-locating
8859        // diagnostic on the byte the author pasted earliest in the URL.
8860        let d = dep_with_fonte(DepSource::Git {
8861            repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
8862            tag: Some("v0.1.0".into()),
8863            rev: None,
8864            branch: None,
8865        });
8866        let err = d.validate().unwrap_err();
8867        let DepError::FonteRepoShape { reason, .. } = err else {
8868            panic!("expected FonteRepoShape, got other variant");
8869        };
8870        assert!(
8871            reason.contains("must not contain `#`"),
8872            "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
8873             appears first in value), got {reason:?}"
8874        );
8875    }
8876
8877    #[test]
8878    fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
8879        // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
8880        // byte-class arm, e7a109f) and the bang arm are both per-byte
8881        // arms inside the same `for &b in s.as_bytes()` loop, so the
8882        // byte that appears first in the value's byte order wins. A
8883        // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
8884        // `'` byte appears first, so the single-quote arm fires,
8885        // surfacing the more self-locating diagnostic on the byte the
8886        // author pasted earliest in the URL. Pins the natural-order
8887        // cascade so a future reorder of the per-byte arms surfaces
8888        // here — `!` is the most recent byte-class arm, so the
8889        // cascade-pin sweep extends to cover the immediately prior `'`
8890        // byte arm firing first when ordered ahead of `!` in the value.
8891        let d = dep_with_fonte(DepSource::Git {
8892            repo: "github:pleme-io/caixa-teia'mid!tail".into(),
8893            tag: Some("v0.1.0".into()),
8894            rev: None,
8895            branch: None,
8896        });
8897        let err = d.validate().unwrap_err();
8898        let DepError::FonteRepoShape { reason, .. } = err else {
8899            panic!("expected FonteRepoShape, got other variant");
8900        };
8901        assert!(
8902            reason.contains("must not contain `'`"),
8903            "reason must surface the single-quote arm (fires before bang when `'` byte \
8904             appears first in value), got {reason:?}"
8905        );
8906    }
8907
8908    #[test]
8909    fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
8910        // The fail-before-pass-after pin for the canonical
8911        // list-separator-belongs-to-list-grammar footgun on `:repo`.
8912        // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
8913        // one-liner from a multi-repo bootstrap doc, intending the
8914        // comma to separate multiple repo entries but the typed
8915        // `:repo` slot names *one* repo (the list-separator belongs
8916        // to the `:deps` list grammar, not to the value). Until this
8917        // arm landed the `,` byte silently passed every prior
8918        // `is_git_repo_url` arm (no whitespace, no control chars, no
8919        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
8920        // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
8921        // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
8922        // `:`); the byte rode into the lacre's per-dep content-
8923        // address and the resolver's `git clone <repo>` subprocess
8924        // invocation, where no host's repo registry resolved the
8925        // comma-bearing slug.
8926        let d = dep_with_fonte(DepSource::Git {
8927            repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
8928            tag: Some("v0.1.0".into()),
8929            rev: None,
8930            branch: None,
8931        });
8932        let err = d.validate().unwrap_err();
8933        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8934            panic!("expected FonteRepoShape, got other variant");
8935        };
8936        assert_eq!(nome, "caixa-teia");
8937        assert_eq!(
8938            repo,
8939            "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
8940        );
8941        assert!(
8942            reason.contains("must not contain `,`"),
8943            "reason must surface the list-separator-comma arm, got {reason:?}"
8944        );
8945        assert!(
8946            reason.contains("list-separator") || reason.contains("sub-delims"),
8947            "reason must name the list-separator / RFC-3986-sub-delims rationale, \
8948             got {reason:?}"
8949        );
8950    }
8951
8952    #[test]
8953    fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
8954        // The symmetric trailing-`,` paste-from-prose pin: an author
8955        // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
8956        // comma every README-prose list-of-projects sentence carries,
8957        // mistakenly retained when the slug is pasted mid-sentence)
8958        // expecting the substrate to coerce it to a kebab-case slug.
8959        // Pinned separately from the wrapped mid-token shape so a
8960        // future diagnostic-surface change that only checked the
8961        // leading or paired-comma position surfaces here — the
8962        // per-byte arm fires anywhere `,` appears in the value.
8963        let d = dep_with_fonte(DepSource::Git {
8964            repo: "github:pleme-io/caixa-feira,".into(),
8965            tag: Some("v0.1.0".into()),
8966            rev: None,
8967            branch: None,
8968        });
8969        let err = d.validate().unwrap_err();
8970        let DepError::FonteRepoShape { reason, .. } = err else {
8971            panic!("expected FonteRepoShape, got other variant");
8972        };
8973        assert!(
8974            reason.contains("must not contain `,`"),
8975            "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
8976             got {reason:?}"
8977        );
8978    }
8979
8980    #[test]
8981    fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
8982        // Cascade pin: the fragment-`#` arm and the comma arm are
8983        // both per-byte arms inside the same `for &b in s.as_bytes()`
8984        // loop, so the byte that appears first in the value's byte
8985        // order wins. A `:repo "https://github.com/p/x#readme,tail"`
8986        // carries both `#` and `,`; the `#` byte appears first, so
8987        // the fragment-`#` arm fires, surfacing the more self-
8988        // locating diagnostic on the byte the author pasted earliest
8989        // in the URL.
8990        let d = dep_with_fonte(DepSource::Git {
8991            repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
8992            tag: Some("v0.1.0".into()),
8993            rev: None,
8994            branch: None,
8995        });
8996        let err = d.validate().unwrap_err();
8997        let DepError::FonteRepoShape { reason, .. } = err else {
8998            panic!("expected FonteRepoShape, got other variant");
8999        };
9000        assert!(
9001            reason.contains("must not contain `#`"),
9002            "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
9003             appears first in value), got {reason:?}"
9004        );
9005    }
9006
9007    #[test]
9008    fn fonte_repo_bang_fires_before_comma_when_bang_first() {
9009        // Cascade pin: the bang-`!` arm (the immediate-predecessor
9010        // byte-class arm, 7d53c68) and the comma arm are both
9011        // per-byte arms inside the same `for &b in s.as_bytes()`
9012        // loop, so the byte that appears first in the value's byte
9013        // order wins. A `:repo "github:p/x!mid,tail"` carries both
9014        // `!` and `,`; the `!` byte appears first, so the bang arm
9015        // fires, surfacing the more self-locating diagnostic on the
9016        // byte the author pasted earliest in the URL. Pins the
9017        // natural-order cascade so a future reorder of the per-byte
9018        // arms surfaces here — `,` is the most recent byte-class
9019        // arm, so the cascade-pin sweep extends to cover the
9020        // immediately prior `!` byte arm firing first when ordered
9021        // ahead of `,` in the value.
9022        let d = dep_with_fonte(DepSource::Git {
9023            repo: "github:pleme-io/caixa-teia!mid,tail".into(),
9024            tag: Some("v0.1.0".into()),
9025            rev: None,
9026            branch: None,
9027        });
9028        let err = d.validate().unwrap_err();
9029        let DepError::FonteRepoShape { reason, .. } = err else {
9030            panic!("expected FonteRepoShape, got other variant");
9031        };
9032        assert!(
9033            reason.contains("must not contain `!`"),
9034            "reason must surface the bang arm (fires before comma when `!` byte \
9035             appears first in value), got {reason:?}"
9036        );
9037    }
9038
9039    #[test]
9040    fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
9041        // The fail-before-pass-after pin for the canonical
9042        // shell-env-var-assignment-belongs-to-shell-grammar footgun
9043        // on `:repo`. An author copies
9044        // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
9045        // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
9046        // git clone <url>`, etc. — the canonical
9047        // git-troubleshooting README idiom for a one-shot env-var
9048        // scoped to the `git clone` invocation) from a shell-prompt
9049        // one-liner, intending the `KEY=VALUE` prefix as a shell-
9050        // grammar env-var assignment but the typed `:repo` slot is
9051        // a value parser, not a shell context, so the bytes ride
9052        // into the value verbatim. Until this arm landed the `=`
9053        // byte silently passed every prior `is_git_repo_url` arm
9054        // (no whitespace, no control chars, no non-ASCII, no `#`,
9055        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
9056        // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
9057        // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
9058        // the byte rode into the lacre's per-dep content-address
9059        // and the resolver's `git clone <repo>` subprocess
9060        // invocation, where the upstream host's git porcelain
9061        // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
9062        // path that no host's repo registry resolves.
9063        let d = dep_with_fonte(DepSource::Git {
9064            repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
9065            tag: Some("v0.1.0".into()),
9066            rev: None,
9067            branch: None,
9068        });
9069        let err = d.validate().unwrap_err();
9070        let DepError::FonteRepoShape { nome, repo, reason } = err else {
9071            panic!("expected FonteRepoShape, got other variant");
9072        };
9073        assert_eq!(nome, "caixa-teia");
9074        assert_eq!(
9075            repo,
9076            "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
9077        );
9078        // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
9079        // appears before the ` ` byte at position 21, so the `=`
9080        // arm fires (not the whitespace arm) — both arms guard
9081        // the slot, but the per-byte for-loop scans left-to-right
9082        // and the first matching byte wins.
9083        assert!(
9084            reason.contains("must not contain `=`"),
9085            "reason must surface the equals-`=` arm on the env-var-assignment \
9086             paste shape, got {reason:?}"
9087        );
9088        assert!(
9089            reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
9090            "reason must name the shell-env-var-assignment rationale, got {reason:?}"
9091        );
9092    }
9093
9094    #[test]
9095    fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
9096        // The symmetric paste-from-gitconfig pin: an author copies
9097        // `url=https://github.com/p/x` from `git config --get-all
9098        // remote.origin.url` output, a `.gitconfig` `[remote
9099        // "origin"] url = https://…` ini-stanza paste, or a
9100        // `git config remote.origin.url <value>` doc snippet,
9101        // intending the `url=` prefix as the ini-key but the typed
9102        // `:repo` slot is a URL value parser, not a gitconfig
9103        // grammar. With no leading whitespace and no earlier-arm
9104        // bytes in the value, the `=` arm itself fires (rather
9105        // than cascading to the whitespace arm as in the env-var
9106        // paste shape). Pinned separately so a future diagnostic-
9107        // surface change that only checked the whitespace-leading
9108        // shape surfaces here — the per-byte arm fires anywhere
9109        // `=` appears in the value.
9110        let d = dep_with_fonte(DepSource::Git {
9111            repo: "url=https://github.com/pleme-io/caixa-feira".into(),
9112            tag: Some("v0.1.0".into()),
9113            rev: None,
9114            branch: None,
9115        });
9116        let err = d.validate().unwrap_err();
9117        let DepError::FonteRepoShape { reason, .. } = err else {
9118            panic!("expected FonteRepoShape, got other variant");
9119        };
9120        assert!(
9121            reason.contains("must not contain `=`"),
9122            "reason must surface the equals-`=` arm on the `url=…` gitconfig \
9123             paste shape, got {reason:?}"
9124        );
9125        assert!(
9126            reason.contains("key-value-separator") || reason.contains("sub-delims"),
9127            "reason must name the key-value-separator / RFC-3986-sub-delims \
9128             rationale, got {reason:?}"
9129        );
9130    }
9131
9132    #[test]
9133    fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
9134        // Cascade pin: the fragment-`#` arm and the `=` arm are
9135        // both per-byte arms inside the same `for &b in s.as_bytes()`
9136        // loop, so the byte that appears first in the value's byte
9137        // order wins. A `:repo "https://github.com/p/x#readme=tail"`
9138        // carries both `#` and `=`; the `#` byte appears first, so
9139        // the fragment-`#` arm fires, surfacing the more self-
9140        // locating diagnostic on the byte the author pasted earliest
9141        // in the URL.
9142        let d = dep_with_fonte(DepSource::Git {
9143            repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
9144            tag: Some("v0.1.0".into()),
9145            rev: None,
9146            branch: None,
9147        });
9148        let err = d.validate().unwrap_err();
9149        let DepError::FonteRepoShape { reason, .. } = err else {
9150            panic!("expected FonteRepoShape, got other variant");
9151        };
9152        assert!(
9153            reason.contains("must not contain `#`"),
9154            "reason must surface the fragment-`#` arm (fires before equals when \
9155             `#` byte appears first in value), got {reason:?}"
9156        );
9157    }
9158
9159    #[test]
9160    fn fonte_repo_comma_fires_before_equals_when_comma_first() {
9161        // Cascade pin: the comma-`,` arm (the immediate-predecessor
9162        // byte-class arm, 775b80e) and the `=` arm are both per-byte
9163        // arms inside the same `for &b in s.as_bytes()` loop, so
9164        // the byte that appears first in the value's byte order
9165        // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
9166        // and `=`; the `,` byte appears first, so the comma arm
9167        // fires, surfacing the more self-locating diagnostic on
9168        // the byte the author pasted earliest in the URL. Pins the
9169        // natural-order cascade so a future reorder of the per-byte
9170        // arms surfaces here — `=` is the most recent byte-class
9171        // arm, so the cascade-pin sweep extends to cover the
9172        // immediately prior `,` byte arm firing first when ordered
9173        // ahead of `=` in the value.
9174        let d = dep_with_fonte(DepSource::Git {
9175            repo: "github:pleme-io/caixa-teia,mid=tail".into(),
9176            tag: Some("v0.1.0".into()),
9177            rev: None,
9178            branch: None,
9179        });
9180        let err = d.validate().unwrap_err();
9181        let DepError::FonteRepoShape { reason, .. } = err else {
9182            panic!("expected FonteRepoShape, got other variant");
9183        };
9184        assert!(
9185            reason.contains("must not contain `,`"),
9186            "reason must surface the comma arm (fires before equals when `,` byte \
9187             appears first in value), got {reason:?}"
9188        );
9189    }
9190
9191    #[test]
9192    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
9193        // The fail-before-pass-after pin for the canonical paste-from-
9194        // browser-address-bar percent-encoded-space footgun on `:repo`.
9195        // An author copies `https://github.com/p/x%20test` from a
9196        // browser address bar (or a percent-encoded README hyperlink,
9197        // or a `curl --data-urlencode` shell-pipeline output)
9198        // intending `%20` as the URL encoding of a literal space; the
9199        // typed `:repo` slot already rejects the literal space byte
9200        // (the whitespace arm at the top of `is_git_repo_url`), so an
9201        // author trying to express "I really meant a space" reaches
9202        // for percent-encoding. Until this arm landed the `%` byte
9203        // silently passed every prior `is_git_repo_url` arm and rode
9204        // verbatim into the lacre's per-dep content-address — but
9205        // libcurl re-percent-encodes `%` to `%25` on the wire (since
9206        // `%` is reserved as the escape-sequence lead-in), so the
9207        // wire request becomes `https://github.com/p/x%2520test`, a
9208        // path the lacre's content-address never names. The classic
9209        // render-determinism violation on the encoding-mechanism axis
9210        // itself.
9211        let d = dep_with_fonte(DepSource::Git {
9212            repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
9213            tag: Some("v0.1.0".into()),
9214            rev: None,
9215            branch: None,
9216        });
9217        let err = d.validate().unwrap_err();
9218        let DepError::FonteRepoShape { nome, repo, reason } = err else {
9219            panic!("expected FonteRepoShape, got other variant");
9220        };
9221        assert_eq!(nome, "caixa-teia");
9222        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
9223        assert!(
9224            reason.contains("must not contain `%`"),
9225            "reason must surface the percent-`%` arm on the percent-encoded-space \
9226             paste shape, got {reason:?}"
9227        );
9228        assert!(
9229            reason.contains("percent-encoding") || reason.contains("%25"),
9230            "reason must name the percent-encoding / `%25` re-encoding rationale, \
9231             got {reason:?}"
9232        );
9233    }
9234
9235    #[test]
9236    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
9237        // The symmetric over-encoded-path-separator pin: an author
9238        // writes `:repo "https://github.com/p%2Fx"` intending the
9239        // `%2F` as the URL encoding of `/` (the canonical
9240        // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
9241        // footgun every API client library and OAuth redirect-URI
9242        // documentation surfaces — the `/` is the URL-path-separator
9243        // and some templates percent-encode it to escape interpretation
9244        // as a path separator). The GitHub Smart-HTTP transport
9245        // resolves the URL's path-segment grammar before the
9246        // percent-decoding pass, so the value identifies a different
9247        // resource on the wire than the literal-`/` form the lacre's
9248        // content-address must agree with — two authors whose `:repo`
9249        // values differ only in their `/` vs `%2F` presence lock to
9250        // two distinct BLAKE3 closures for the byte-identical upstream
9251        // `git clone`. Pinned separately so a future diagnostic
9252        // surface that only catches the `%20` shape surfaces here too.
9253        let d = dep_with_fonte(DepSource::Git {
9254            repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
9255            tag: Some("v0.1.0".into()),
9256            rev: None,
9257            branch: None,
9258        });
9259        let err = d.validate().unwrap_err();
9260        let DepError::FonteRepoShape { reason, .. } = err else {
9261            panic!("expected FonteRepoShape, got other variant");
9262        };
9263        assert!(
9264            reason.contains("must not contain `%`"),
9265            "reason must surface the percent-`%` arm on the over-encoded-path \
9266             shape, got {reason:?}"
9267        );
9268        assert!(
9269            reason.contains("render-determinism") || reason.contains("BLAKE3"),
9270            "reason must name the render-determinism / BLAKE3-closure rationale, \
9271             got {reason:?}"
9272        );
9273    }
9274
9275    #[test]
9276    fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
9277        // Cascade pin: the fragment-`#` arm and the `%` arm are both
9278        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
9279        // so the byte that appears first in the value's byte order
9280        // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
9281        // both `#` and `%`; the `#` byte appears first, so the
9282        // fragment-`#` arm fires, surfacing the more self-locating
9283        // diagnostic on the byte the author pasted earliest in the URL.
9284        let d = dep_with_fonte(DepSource::Git {
9285            repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
9286            tag: Some("v0.1.0".into()),
9287            rev: None,
9288            branch: None,
9289        });
9290        let err = d.validate().unwrap_err();
9291        let DepError::FonteRepoShape { reason, .. } = err else {
9292            panic!("expected FonteRepoShape, got other variant");
9293        };
9294        assert!(
9295            reason.contains("must not contain `#`"),
9296            "reason must surface the fragment-`#` arm (fires before percent when \
9297             `#` byte appears first in value), got {reason:?}"
9298        );
9299    }
9300
9301    #[test]
9302    fn fonte_repo_equals_fires_before_percent_when_equals_first() {
9303        // Cascade pin: the equals-`=` arm (the immediate-predecessor
9304        // byte-class arm, acf99af) and the `%` arm are both per-byte
9305        // arms inside the same `for &b in s.as_bytes()` loop, so the
9306        // byte that appears first in the value's byte order wins.
9307        // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
9308        // the `=` byte appears first, so the equals arm fires,
9309        // surfacing the more self-locating diagnostic on the byte the
9310        // author pasted earliest in the URL. Pins the natural-order
9311        // cascade so a future reorder of the per-byte arms surfaces
9312        // here — `%` is the most recent byte-class arm, so the
9313        // cascade-pin sweep extends to cover the immediately prior
9314        // `=` byte arm firing first when ordered ahead of `%` in the
9315        // value.
9316        let d = dep_with_fonte(DepSource::Git {
9317            repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
9318            tag: Some("v0.1.0".into()),
9319            rev: None,
9320            branch: None,
9321        });
9322        let err = d.validate().unwrap_err();
9323        let DepError::FonteRepoShape { reason, .. } = err else {
9324            panic!("expected FonteRepoShape, got other variant");
9325        };
9326        assert!(
9327            reason.contains("must not contain `=`"),
9328            "reason must surface the equals arm (fires before percent when `=` byte \
9329             appears first in value), got {reason:?}"
9330        );
9331    }
9332
9333    #[test]
9334    fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
9335        // The fail-before-pass-after pin for the canonical paste-from-
9336        // shell-history footgun on `:repo`. An author copies a
9337        // `git clone <url>` line from their terminal followed by a
9338        // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
9339        // history shorthand (the `^old^new^` form re-runs the prior
9340        // history entry with the first `old` substituted by `new`,
9341        // bash's default behavior on interactive sessions with
9342        // `set -o histexpand`), forgetting to trim the trailing
9343        // `^...^...` shell-history fragment from the URL value. The
9344        // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
9345        // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
9346        // classes), the WHATWG URL spec's 'fragment percent-encode
9347        // set' maps `^` → `%5E` on the wire, so the byte rides
9348        // verbatim into the lacre's per-dep content-address but
9349        // libcurl re-encodes it to `%5E` at `git clone` time — the
9350        // classic render-determinism violation on the same axis the
9351        // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
9352        // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
9353        // `#` arms close.
9354        let d = dep_with_fonte(DepSource::Git {
9355            repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
9356            tag: Some("v0.1.0".into()),
9357            rev: None,
9358            branch: None,
9359        });
9360        let err = d.validate().unwrap_err();
9361        let DepError::FonteRepoShape { nome, repo, reason } = err else {
9362            panic!("expected FonteRepoShape, got other variant");
9363        };
9364        assert_eq!(nome, "caixa-teia");
9365        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
9366        assert!(
9367            reason.contains("must not contain `^`"),
9368            "reason must surface the caret-`^` arm on the paste-from-shell-history \
9369             shape, got {reason:?}"
9370        );
9371        assert!(
9372            reason.contains("history-substitution") || reason.contains("%5E"),
9373            "reason must name the shell-history-substitution / `%5E` wire-encoding \
9374             rationale, got {reason:?}"
9375        );
9376    }
9377
9378    #[test]
9379    fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
9380        // The symmetric paste-from-doc-grep-pipeline footgun: an
9381        // author writes `:repo "github:p/^archived"` after copying a
9382        // `grep '^archived'` regex-anchor / negation idiom from a
9383        // doc / README quick-listing snippet, expecting the substrate
9384        // to coerce it to a literal repo name. The byte rides
9385        // verbatim into the lacre's per-dep content-address and
9386        // diverges from the byte-identical literal `archived` form
9387        // every other author authored — the canonical render-
9388        // determinism violation pin on the second footgun shape the
9389        // caret-`^` arm closes.
9390        let d = dep_with_fonte(DepSource::Git {
9391            repo: "github:pleme-io/^archived".into(),
9392            tag: Some("v0.1.0".into()),
9393            rev: None,
9394            branch: None,
9395        });
9396        let err = d.validate().unwrap_err();
9397        let DepError::FonteRepoShape { reason, .. } = err else {
9398            panic!("expected FonteRepoShape, got other variant");
9399        };
9400        assert!(
9401            reason.contains("must not contain `^`"),
9402            "reason must surface the caret-`^` arm on the regex-anchor shape, \
9403             got {reason:?}"
9404        );
9405        assert!(
9406            reason.contains("render-determinism") || reason.contains("BLAKE3"),
9407            "reason must name the render-determinism / BLAKE3-closure rationale, \
9408             got {reason:?}"
9409        );
9410    }
9411
9412    #[test]
9413    fn fonte_repo_percent_fires_before_caret_when_percent_first() {
9414        // Cascade pin: the `%` arm (the immediate-predecessor byte-
9415        // class arm, a323db8) and the `^` arm are both per-byte arms
9416        // inside the same `for &b in s.as_bytes()` loop, so the byte
9417        // that appears first in the value's byte order wins. A
9418        // `:repo "https://github.com/p/x%20mid^tail"` carries both
9419        // `%` and `^`; the `%` byte appears first, so the percent
9420        // arm fires, surfacing the more self-locating diagnostic on
9421        // the byte the author pasted earliest in the URL. Pins the
9422        // natural-order cascade so a future reorder of the per-byte
9423        // arms surfaces here — `^` is the most recent byte-class arm,
9424        // so the cascade-pin sweep extends to cover the immediately
9425        // prior `%` byte arm firing first when ordered ahead of `^`
9426        // in the value.
9427        let d = dep_with_fonte(DepSource::Git {
9428            repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
9429            tag: Some("v0.1.0".into()),
9430            rev: None,
9431            branch: None,
9432        });
9433        let err = d.validate().unwrap_err();
9434        let DepError::FonteRepoShape { reason, .. } = err else {
9435            panic!("expected FonteRepoShape, got other variant");
9436        };
9437        assert!(
9438            reason.contains("must not contain `%`"),
9439            "reason must surface the percent arm (fires before caret when `%` byte \
9440             appears first in value), got {reason:?}"
9441        );
9442    }
9443
9444    #[test]
9445    fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
9446        // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
9447        // (no `github:` prefix, no scheme). Every documented form
9448        // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
9449        // `file://`, or `git@host:path`); a bare `org/repo` is
9450        // ambiguous (`git clone` reads as a relative filesystem path
9451        // rather than the GitHub-shorthand expansion the author
9452        // probably intended) and the gate rejects the shape upstream.
9453        let d = dep_with_fonte(DepSource::Git {
9454            repo: "pleme-io/caixa-teia".into(),
9455            tag: Some("v0.1.0".into()),
9456            rev: None,
9457            branch: None,
9458        });
9459        let err = d.validate().unwrap_err();
9460        let DepError::FonteRepoShape { reason, .. } = err else {
9461            panic!("expected FonteRepoShape, got other variant");
9462        };
9463        assert!(
9464            reason.contains("must contain a `:`"),
9465            "reason must surface the missing-`:` arm, got {reason:?}"
9466        );
9467        assert!(
9468            reason.contains("github:"),
9469            "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
9470        );
9471    }
9472
9473    #[test]
9474    fn validate_rejects_git_fonte_with_repo_leading_colon() {
9475        // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
9476        // scheme that no git porcelain entry-point accepts. Pinned
9477        // separately from the missing-`:` arm because a value with a
9478        // leading `:` does technically contain a `:` separator; the
9479        // shape gate rejects on a dedicated arm so the diagnostic
9480        // names the specific footgun.
9481        let d = dep_with_fonte(DepSource::Git {
9482            repo: ":pleme-io/caixa-teia".into(),
9483            tag: Some("v0.1.0".into()),
9484            rev: None,
9485            branch: None,
9486        });
9487        let err = d.validate().unwrap_err();
9488        let DepError::FonteRepoShape { reason, .. } = err else {
9489            panic!("expected FonteRepoShape, got other variant");
9490        };
9491        assert!(
9492            reason.contains("must not start with `:`"),
9493            "reason must surface the leading-`:` arm, got {reason:?}"
9494        );
9495    }
9496
9497    #[test]
9498    fn validate_rejects_git_fonte_with_repo_too_long() {
9499        // The cap arm — a `:repo` value longer than
9500        // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
9501        // structurally untenable on every realistic landing site (the
9502        // resolver's `git clone` invocation, the future M4 CR
9503        // materializer's per-dep `repo:` axis); a value of that length
9504        // is almost certainly a paste-from-binary slug.
9505        let too_long = format!(
9506            "github:pleme-io/{}",
9507            "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
9508        );
9509        let d = dep_with_fonte(DepSource::Git {
9510            repo: too_long.clone(),
9511            tag: Some("v0.1.0".into()),
9512            rev: None,
9513            branch: None,
9514        });
9515        let err = d.validate().unwrap_err();
9516        let DepError::FonteRepoShape { reason, .. } = err else {
9517            panic!("expected FonteRepoShape, got other variant");
9518        };
9519        assert!(
9520            reason.contains("2048"),
9521            "reason must name the cap, got {reason:?}"
9522        );
9523    }
9524
9525    #[test]
9526    fn validate_accepts_canonical_git_fonte_repo_shapes() {
9527        // The positive-control sweep: every documented author shape on
9528        // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
9529        // must pass the value-shape gate. Pinned so a future tightening
9530        // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
9531        // here as a structural decision. Each form is exercised with the
9532        // same canonical `:tag` pin so only the `:repo` axis varies.
9533        for repo in [
9534            // The pleme-io registry-shorthand convention — `github:org/repo`.
9535            "github:pleme-io/caixa-teia",
9536            // Other host-aliased shorthands (the resolver's pluggable
9537            // host-prefix table).
9538            "gitlab:pleme-io/caixa-teia",
9539            "codeberg:pleme-io/caixa-teia",
9540            "sourcehut:~pleme-io/caixa-teia",
9541            // Full HTTPS URL with and without `.git` suffix.
9542            "https://github.com/pleme-io/caixa-teia",
9543            "https://github.com/pleme-io/caixa-teia.git",
9544            // HTTP (rare; dev / mirror).
9545            "http://example.com/pleme-io/caixa-teia.git",
9546            // SSH URL.
9547            "ssh://git@github.com/pleme-io/caixa-teia.git",
9548            "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
9549            // Scp-style SSH — the canonical `git@host:path` short form.
9550            "git@github.com:pleme-io/caixa-teia.git",
9551            "git@git.example.com:team/private.git",
9552            // Anonymous git protocol.
9553            "git://git.example.com/pleme-io/caixa-teia.git",
9554            // Local file URL (dev path).
9555            "file:///tmp/caixa-teia",
9556        ] {
9557            let d = dep_with_fonte(DepSource::Git {
9558                repo: repo.into(),
9559                tag: Some("v0.1.0".into()),
9560                rev: None,
9561                branch: None,
9562            });
9563            d.validate()
9564                .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
9565        }
9566    }
9567
9568    #[test]
9569    fn fonte_repo_empty_takes_precedence_over_shape() {
9570        // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
9571        // diagnostic; doesn't try to parse the URL shape) fires before
9572        // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
9573        // keeps its narrower error message. Mirrors
9574        // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
9575        // on the ordering layer.
9576        let d = dep_with_fonte(DepSource::Git {
9577            repo: String::new(),
9578            tag: Some("v0.1.0".into()),
9579            rev: None,
9580            branch: None,
9581        });
9582        let err = d.validate().unwrap_err();
9583        assert!(
9584            matches!(err, DepError::FonteRepoEmpty { .. }),
9585            "got {err:?}"
9586        );
9587    }
9588
9589    #[test]
9590    fn fonte_repo_shape_fires_before_pin_missing() {
9591        // Order pin: a malformed `:repo` value on a dep with no pin set
9592        // surfaces the `:repo` shape diagnostic (the more self-locating
9593        // axis — the `:repo` is the load-bearing identity of the source;
9594        // a missing pin is downstream from "do we even know the repo")
9595        // rather than collapsing onto the pin-missing diagnostic. The
9596        // shape gate runs inline before the pin enumeration in
9597        // `DepSource::validate`.
9598        let d = dep_with_fonte(DepSource::Git {
9599            repo: "pleme-io/caixa-teia".into(), // missing `:` separator
9600            tag: None,
9601            rev: None,
9602            branch: None,
9603        });
9604        let err = d.validate().unwrap_err();
9605        assert!(
9606            matches!(err, DepError::FonteRepoShape { .. }),
9607            "got {err:?}"
9608        );
9609    }
9610
9611    #[test]
9612    fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
9613        // The diagnostic-shape pin: the error names the offending
9614        // `:repo` value verbatim plus a non-empty parser-shaped `reason`
9615        // so the author can grep their caixa.lisp without re-running
9616        // the build. Mirrors the diagnostic-shape sweep on every prior
9617        // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
9618        let d = dep_with_fonte(DepSource::Git {
9619            repo: "pleme-io/caixa-teia".into(),
9620            tag: Some("v0.1.0".into()),
9621            rev: None,
9622            branch: None,
9623        });
9624        let err = d.validate().unwrap_err();
9625        let DepError::FonteRepoShape { nome, repo, reason } = err else {
9626            panic!("expected FonteRepoShape, got other variant");
9627        };
9628        assert_eq!(nome, "caixa-teia");
9629        assert_eq!(repo, "pleme-io/caixa-teia");
9630        assert!(
9631            !reason.is_empty(),
9632            "FonteRepoShape `reason` must carry the predicate's wording verbatim"
9633        );
9634    }
9635
9636    #[test]
9637    fn validate_rejects_git_fonte_with_no_pin() {
9638        // The fail-before-pass-after pin for the canonical
9639        // `(:tipo git :repo "github:pleme-io/x")` shape with no
9640        // :tag/:rev/:branch — until this gate landed the resolver's
9641        // ResolveError::MissingPin surfaced at fetch time, far from the
9642        // source caixa.lisp. The new gate moves the check to validate
9643        // time and names the offending dep.
9644        let d = dep_with_fonte(DepSource::Git {
9645            repo: "github:pleme-io/caixa-teia".into(),
9646            tag: None,
9647            rev: None,
9648            branch: None,
9649        });
9650        let err = d.validate().unwrap_err();
9651        assert!(
9652            matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
9653            "got {err:?}"
9654        );
9655    }
9656
9657    #[test]
9658    fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
9659        // The canonical "pin drift" footgun: an author writes
9660        // `:tag "v1"` and later adds `:branch "main"` without removing
9661        // the :tag, and the resolver silently picks :tag (precedence
9662        // :rev > :tag > :branch). The :branch was dropped with no
9663        // diagnostic. The gate now rejects multi-pin shapes so the
9664        // author makes the precedence explicit at the source.
9665        let d = dep_with_fonte(DepSource::Git {
9666            repo: "github:pleme-io/caixa-teia".into(),
9667            tag: Some("v0.1.0".into()),
9668            rev: None,
9669            branch: Some("main".into()),
9670        });
9671        let err = d.validate().unwrap_err();
9672        let DepError::FontePinAmbiguous { nome, pins } = err else {
9673            panic!("expected FontePinAmbiguous");
9674        };
9675        assert_eq!(nome, "caixa-teia");
9676        assert!(pins.contains(":tag"));
9677        assert!(pins.contains(":branch"));
9678        assert!(!pins.contains(":rev"));
9679    }
9680
9681    #[test]
9682    fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
9683        // Sibling arm of the pin-drift footgun: :tag + :rev set
9684        // simultaneously. Pinned separately so a future relaxation
9685        // that only catches the (:tag, :branch) pair surfaces here.
9686        let d = dep_with_fonte(DepSource::Git {
9687            repo: "github:pleme-io/caixa-teia".into(),
9688            tag: Some("v0.1.0".into()),
9689            rev: Some("c0ffee".into()),
9690            branch: None,
9691        });
9692        let err = d.validate().unwrap_err();
9693        let DepError::FontePinAmbiguous { nome, pins } = err else {
9694            panic!("expected FontePinAmbiguous");
9695        };
9696        assert_eq!(nome, "caixa-teia");
9697        assert!(pins.contains(":tag"));
9698        assert!(pins.contains(":rev"));
9699    }
9700
9701    #[test]
9702    fn validate_rejects_git_fonte_with_all_three_pins() {
9703        // The maximal ambiguity case — every pin axis set. Pinned so a
9704        // future relaxation that only catches pairs surfaces here. The
9705        // diagnostic must enumerate every offending axis so the author
9706        // sees the full set, not just the first match.
9707        let d = dep_with_fonte(DepSource::Git {
9708            repo: "github:pleme-io/caixa-teia".into(),
9709            tag: Some("v0.1.0".into()),
9710            rev: Some("c0ffee".into()),
9711            branch: Some("main".into()),
9712        });
9713        let err = d.validate().unwrap_err();
9714        let DepError::FontePinAmbiguous { nome, pins } = err else {
9715            panic!("expected FontePinAmbiguous");
9716        };
9717        assert_eq!(nome, "caixa-teia");
9718        assert!(pins.contains(":tag"));
9719        assert!(pins.contains(":rev"));
9720        assert!(pins.contains(":branch"));
9721    }
9722
9723    #[test]
9724    fn validate_rejects_git_fonte_with_empty_tag_pin() {
9725        // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
9726        // inner string is empty. Distinct from FontePinMissing (where
9727        // every axis is None) — pinned separately so a future
9728        // tightening collapsing them surfaces here as a structural
9729        // decision.
9730        let d = dep_with_fonte(DepSource::Git {
9731            repo: "github:pleme-io/caixa-teia".into(),
9732            tag: Some(String::new()),
9733            rev: None,
9734            branch: None,
9735        });
9736        let err = d.validate().unwrap_err();
9737        let DepError::FontePinEmpty { nome, pin } = err else {
9738            panic!("expected FontePinEmpty");
9739        };
9740        assert_eq!(nome, "caixa-teia");
9741        assert_eq!(pin, ":tag");
9742    }
9743
9744    #[test]
9745    fn validate_rejects_git_fonte_with_empty_rev_pin() {
9746        // Sibling arm — the empty-pin diagnostic names which axis
9747        // carries the empty value, so the author's grep target is
9748        // unambiguous.
9749        let d = dep_with_fonte(DepSource::Git {
9750            repo: "github:pleme-io/caixa-teia".into(),
9751            tag: None,
9752            rev: Some(String::new()),
9753            branch: None,
9754        });
9755        let err = d.validate().unwrap_err();
9756        let DepError::FontePinEmpty { nome, pin } = err else {
9757            panic!("expected FontePinEmpty");
9758        };
9759        assert_eq!(nome, "caixa-teia");
9760        assert_eq!(pin, ":rev");
9761    }
9762
9763    #[test]
9764    fn validate_rejects_path_fonte_with_empty_caminho() {
9765        // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
9766        // until this gate landed the resolver's
9767        // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
9768        // fetch time — not actionable. The new gate moves the check to
9769        // validate time and names the offending dep.
9770        let d = dep_with_fonte(DepSource::Path {
9771            caminho: String::new(),
9772        });
9773        let err = d.validate().unwrap_err();
9774        assert!(
9775            matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
9776            "got {err:?}"
9777        );
9778    }
9779
9780    #[test]
9781    fn validate_rejects_path_fonte_with_absolute_caminho() {
9782        // The fail-before-pass-after pin for the absolute-`:caminho`
9783        // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
9784        // Until this gate landed an absolute `:caminho` silently
9785        // passed validate; the lacre pipeline embedded the
9786        // host-specific filesystem path verbatim in its
9787        // content-address (`conteudo: format!("path:{caminho}")`,
9788        // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
9789        // differed per machine — the build succeeded but two CI
9790        // runners with different `${HOME}` layouts emitted two
9791        // distinct lacres for the byte-identical caixa, silently
9792        // breaking the THEORY.md §V.2 render-determinism contract
9793        // far from the source caixa.lisp. The new gate moves the
9794        // check to validate time and names the offending dep +
9795        // caminho verbatim.
9796        let d = dep_with_fonte(DepSource::Path {
9797            caminho: "/home/me/work/caixa-teia".into(),
9798        });
9799        let err = d.validate().unwrap_err();
9800        let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
9801            panic!("expected FonteCaminhoAbsolute, got other variant");
9802        };
9803        assert_eq!(nome, "caixa-teia");
9804        assert_eq!(caminho, "/home/me/work/caixa-teia");
9805    }
9806
9807    #[test]
9808    fn validate_accepts_path_fonte_with_parent_escape_caminho() {
9809        // The canonical sibling-workspace dep form
9810        // (`:caminho "../caixa-teia"`) remains accepted. The
9811        // absolute-path gate above is specifically narrower than the
9812        // shared [`crate::render::is_sandboxed_relative_path`]
9813        // predicate (which additionally forbids `..` traversal): a
9814        // local-path dep's canonical author surface is the in-tree
9815        // sibling-workspace path, so a full sandboxed-relative-path
9816        // lift would structurally reject every legitimate path-fonte
9817        // dep. Pinned so a future tightening to the full predicate
9818        // surfaces here as a structural decision, not a silent break.
9819        let d = dep_with_fonte(DepSource::Path {
9820            caminho: "../caixa-teia".into(),
9821        });
9822        d.validate().unwrap();
9823    }
9824
9825    #[test]
9826    fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
9827        // A multi-segment relative `:caminho`
9828        // (`"vendor/forks/caixa-teia"`) remains accepted — the
9829        // absolute-path gate brackets the host-layout-leaking shape
9830        // at the leading-`/` boundary only; every relative shape past
9831        // the empty arm continues to pass. Pinned alongside the
9832        // `..`-traversal positive control so a future tightening
9833        // surfaces the full set of legitimate relative forms here
9834        // rather than at a downstream consumer.
9835        let d = dep_with_fonte(DepSource::Path {
9836            caminho: "vendor/forks/caixa-teia".into(),
9837        });
9838        d.validate().unwrap();
9839    }
9840
9841    #[test]
9842    fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
9843        // The fail-before-pass-after pin for the tilde-expansion
9844        // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
9845        // Until this gate landed the b94fd83 absolute arm let `~/foo`
9846        // through (`Path::is_absolute` returns false on a leading `~`
9847        // — the tilde is a shell-expansion convention, not a POSIX
9848        // path component), so the lacre embedded the value verbatim
9849        // and the resolver folded it through `Path::join` without
9850        // expansion, looking for a literal `./~/work/caixa-teia`
9851        // subdirectory and failing at resolve time with a
9852        // `No such file or directory` error far from the source
9853        // caixa.lisp. The new gate moves the check to validate time
9854        // and names the offending dep + caminho verbatim.
9855        let d = dep_with_fonte(DepSource::Path {
9856            caminho: "~/work/caixa-teia".into(),
9857        });
9858        let err = d.validate().unwrap_err();
9859        let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
9860            panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
9861        };
9862        assert_eq!(nome, "caixa-teia");
9863        assert_eq!(caminho, "~/work/caixa-teia");
9864    }
9865
9866    #[test]
9867    fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
9868        // The bare `~` form (canonical "I meant `$HOME` and forgot
9869        // the rest"): both the leading-tilde arm catches it and the
9870        // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
9871        // sweeps through the same arm. Pinned both to ensure the
9872        // gate doesn't narrow to `~/` only.
9873        for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
9874            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9875            let err = d.validate().unwrap_err();
9876            assert!(
9877                matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9878                "{s:?} → {err:?}",
9879            );
9880        }
9881    }
9882
9883    #[test]
9884    fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
9885        // The leading-`~` is the canonical shell-expansion footgun —
9886        // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
9887        // backup-file-suffix idiom) is a legitimate POSIX path byte
9888        // with no shell-expansion semantic at the leading position.
9889        // Pinned so the gate doesn't widen to a full no-tilde-anywhere
9890        // sweep that would break every legitimate-shape backup-file
9891        // path.
9892        let d = dep_with_fonte(DepSource::Path {
9893            caminho: "../foo~bar/caixa-teia".into(),
9894        });
9895        d.validate().unwrap();
9896    }
9897
9898    #[test]
9899    fn fonte_caminho_empty_fires_before_tilde_expansion() {
9900        // Cascade pin: the empty arm structurally precedes the
9901        // tilde arm (the bytes `""` and `"~"` don't overlap), but the
9902        // pin establishes the precedence at the diagnostic-shape
9903        // level should a future codec round-trip ever produce a
9904        // probe-as-both value. Mirrors the peer
9905        // `fonte_repo_empty_fires_before_pin_missing` cascade
9906        // discipline.
9907        let d = dep_with_fonte(DepSource::Path {
9908            caminho: String::new(),
9909        });
9910        let err = d.validate().unwrap_err();
9911        assert!(
9912            matches!(err, DepError::FonteCaminhoEmpty { .. }),
9913            "got {err:?}",
9914        );
9915    }
9916
9917    #[test]
9918    fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
9919        // Diagnostic-shape pin (peer with
9920        // `validate_rejects_path_fonte_with_absolute_caminho`'s
9921        // payload assertion): the error's Display surfaces both the
9922        // offending `:nome` and the offending `:caminho` verbatim
9923        // so a `feira lint` run can render the diagnostic without
9924        // re-parsing.
9925        let d = dep_with_fonte(DepSource::Path {
9926            caminho: "~alice/dev/caixa-teia".into(),
9927        });
9928        let rendered = d.validate().unwrap_err().to_string();
9929        assert!(
9930            rendered.contains("caixa-teia"),
9931            "diagnostic must name the offending dep: {rendered}",
9932        );
9933        assert!(
9934            rendered.contains("~alice/dev/caixa-teia"),
9935            "diagnostic must quote the offending caminho: {rendered}",
9936        );
9937        assert!(
9938            rendered.contains('~'),
9939            "diagnostic must reference the tilde footgun: {rendered}",
9940        );
9941    }
9942
9943    #[test]
9944    fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
9945        // The fail-before-pass-after pin for the shell-variable-
9946        // expansion `:caminho` shape: `(:tipo path :caminho
9947        // "$HOME/work/caixa-teia")`. Until this gate landed the
9948        // b94fd83 absolute arm + the a5c248e tilde arm both let
9949        // `$HOME/foo` through (`Path::is_absolute` returns false on
9950        // a leading `$` — the `$` is a shell convention, not a POSIX
9951        // path component; `starts_with('~')` returns false too), so
9952        // the lacre embedded the value verbatim and the resolver
9953        // folded it through `Path::join` without `$`-expansion,
9954        // looking for a literal `./$HOME/work/caixa-teia`
9955        // subdirectory and failing at resolve time with a
9956        // `No such file or directory` error far from the source
9957        // caixa.lisp. The new gate moves the check to validate time
9958        // and names the offending dep + caminho verbatim.
9959        let d = dep_with_fonte(DepSource::Path {
9960            caminho: "$HOME/work/caixa-teia".into(),
9961        });
9962        let err = d.validate().unwrap_err();
9963        let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
9964            panic!("expected FonteCaminhoVarExpansion, got {err:?}");
9965        };
9966        assert_eq!(nome, "caixa-teia");
9967        assert_eq!(caminho, "$HOME/work/caixa-teia");
9968    }
9969
9970    #[test]
9971    fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
9972        // Sweep over every leading-`$` shape: the `${VAR}`-braced
9973        // form (canonical "paste-from-CI-manifest" footgun every
9974        // GitHub Actions / GitLab CI / Drone manifest carries on
9975        // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
9976        // canonical "I'm referencing a per-user config dir"),
9977        // and the bare `$` (canonical "I meant `$HOME` and forgot
9978        // the rest"). All shapes route through the same gate's
9979        // byte check. Pinned so the gate doesn't narrow to a
9980        // single shape (e.g. `$HOME/` only).
9981        for s in [
9982            "${HOME}/work/caixa-teia",
9983            "${WORKSPACE}/caixa-teia",
9984            "$XDG_CONFIG_HOME/caixa",
9985            "$",
9986        ] {
9987            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9988            let err = d.validate().unwrap_err();
9989            assert!(
9990                matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9991                "{s:?} → {err:?}",
9992            );
9993        }
9994    }
9995
9996    #[test]
9997    fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
9998        // The `$` byte is the canonical shell-variable-expansion /
9999        // command-substitution / arithmetic-expansion sentinel and
10000        // is rejected at *every* position on the `:caminho` axis: the
10001        // leading arm surfaces `FonteCaminhoVarExpansion`, the
10002        // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
10003        // (6620f39). Pinned so a future arm doesn't narrow the gate
10004        // back to the leading position and re-open the paste-from-
10005        // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
10006        // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
10007        // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
10008        // the lacre content-address (`path:{caminho}`,
10009        // caixa-resolver/src/resolve.rs:189).
10010        let d = dep_with_fonte(DepSource::Path {
10011            caminho: "../foo$bar/caixa-teia".into(),
10012        });
10013        let err = d.validate().unwrap_err();
10014        assert!(
10015            matches!(
10016                err,
10017                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
10018            ),
10019            "got {err:?}",
10020        );
10021    }
10022
10023    #[test]
10024    fn fonte_caminho_tilde_fires_before_var_expansion() {
10025        // Cascade pin: the tilde arm structurally precedes the var
10026        // arm (the bytes `~` and `$` don't overlap at the leading
10027        // position), but the pin establishes the precedence at the
10028        // diagnostic-shape level should a future codec round-trip
10029        // ever produce a probe-as-both value. Mirrors the peer
10030        // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
10031        // discipline on the immediate-predecessor arm.
10032        let d = dep_with_fonte(DepSource::Path {
10033            caminho: "~/work/caixa-teia".into(),
10034        });
10035        let err = d.validate().unwrap_err();
10036        assert!(
10037            matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
10038            "got {err:?}",
10039        );
10040    }
10041
10042    #[test]
10043    fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
10044        // Diagnostic-shape pin (peer with
10045        // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
10046        // payload assertion on the immediate-predecessor arm): the
10047        // error's Display surfaces both the offending `:nome` and
10048        // the offending `:caminho` verbatim plus the `$` footgun
10049        // character itself so a `feira lint` run can render the
10050        // diagnostic without re-parsing.
10051        let d = dep_with_fonte(DepSource::Path {
10052            caminho: "${WORKSPACE}/caixa-teia".into(),
10053        });
10054        let rendered = d.validate().unwrap_err().to_string();
10055        assert!(
10056            rendered.contains("caixa-teia"),
10057            "diagnostic must name the offending dep: {rendered}",
10058        );
10059        assert!(
10060            rendered.contains("${WORKSPACE}/caixa-teia"),
10061            "diagnostic must quote the offending caminho: {rendered}",
10062        );
10063        assert!(
10064            rendered.contains('$'),
10065            "diagnostic must reference the dollar footgun: {rendered}",
10066        );
10067    }
10068
10069    #[test]
10070    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
10071        // The fail-before-pass-after pin for the load-bearing NUL byte:
10072        // POSIX paths cannot contain `0x00` (every `std::fs` syscall
10073        // routes the path through `CString::new` which fails with
10074        // `NulError`); until this gate landed a `:caminho
10075        // "../caixa\0teia"` silently passed validate, the lacre
10076        // pipeline embedded the value verbatim, and the failure
10077        // surfaced at the resolver's `Path::join` → `CString::new`
10078        // boundary with a non-self-locating `NulError` far from the
10079        // source caixa.lisp. The new gate moves the check to validate
10080        // time and names the offending dep + caminho + offending byte
10081        // verbatim.
10082        let d = dep_with_fonte(DepSource::Path {
10083            caminho: "../caixa\0teia".into(),
10084        });
10085        let err = d.validate().unwrap_err();
10086        let DepError::FonteCaminhoControlChar {
10087            nome,
10088            caminho,
10089            byte,
10090        } = err
10091        else {
10092            panic!("expected FonteCaminhoControlChar, got {err:?}");
10093        };
10094        assert_eq!(nome, "caixa-teia");
10095        assert_eq!(caminho, "../caixa\0teia");
10096        assert_eq!(byte, 0x00);
10097    }
10098
10099    #[test]
10100    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
10101        // The canonical paste-from-multiline-doc footgun on `:caminho`
10102        // — author copies `"../caixa-teia\n"` (trailing newline) out
10103        // of a multi-line code-fence or, worse, a `:caminho
10104        // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
10105        // injection sibling on the path axis the `is_git_repo_url`
10106        // control-char arm already closes on `:repo`). Pinned
10107        // separately from the NUL arm so a future relaxation that
10108        // catches one but not the other surfaces here.
10109        let d = dep_with_fonte(DepSource::Path {
10110            caminho: "../caixa-teia\n".into(),
10111        });
10112        let err = d.validate().unwrap_err();
10113        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10114            panic!("expected FonteCaminhoControlChar, got {err:?}");
10115        };
10116        assert_eq!(byte, 0x0A);
10117    }
10118
10119    #[test]
10120    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
10121        // The CRLF sibling of the LF arm — Windows-line-ending
10122        // paste-from-multiline-doc on a `\r\n`-terminated buffer
10123        // leaves a stray `\r` mid-string after the LF strip. Pinned
10124        // separately from the LF arm so a future relaxation that
10125        // only catches LF surfaces here.
10126        let d = dep_with_fonte(DepSource::Path {
10127            caminho: "../caixa-teia\r".into(),
10128        });
10129        let err = d.validate().unwrap_err();
10130        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10131            panic!("expected FonteCaminhoControlChar, got {err:?}");
10132        };
10133        assert_eq!(byte, 0x0D);
10134    }
10135
10136    #[test]
10137    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
10138        // The canonical paste-from-aligned-table footgun — a `\t`
10139        // mid-`:caminho` is invisible in most editors but rides
10140        // through the lacre's content-address verbatim, so two
10141        // paste-from-distinct-tables (one editor strips tabs, one
10142        // preserves them) yield divergent lacres for the byte-
10143        // identical-looking caixa. Pinned separately from the
10144        // whitespace-shaped LF/CR arms so a future relaxation that
10145        // narrows to line-terminator-only surfaces here.
10146        let d = dep_with_fonte(DepSource::Path {
10147            caminho: "../caixa\tteia".into(),
10148        });
10149        let err = d.validate().unwrap_err();
10150        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10151            panic!("expected FonteCaminhoControlChar, got {err:?}");
10152        };
10153        assert_eq!(byte, 0x09);
10154    }
10155
10156    #[test]
10157    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
10158        // The DEL byte (`0x7F`) closes the upper-end paste-from-
10159        // binary-blob footgun — the gate's contract is `b < 0x20 ||
10160        // b == 0x7F`, matching the `is_git_repo_url` /
10161        // `is_git_ref_name` predicates' control-char arms. Pinned
10162        // separately from the lower-range arms so a future narrowing
10163        // to `< 0x20` only surfaces here.
10164        let d = dep_with_fonte(DepSource::Path {
10165            caminho: "../caixa\x7fteia".into(),
10166        });
10167        let err = d.validate().unwrap_err();
10168        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
10169            panic!("expected FonteCaminhoControlChar, got {err:?}");
10170        };
10171        assert_eq!(byte, 0x7F);
10172    }
10173
10174    #[test]
10175    fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
10176        // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
10177        // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
10178        // are opaque byte sequences and UTF-8 multi-byte sequences
10179        // are a legitimate filename shape (the `café-teia/foo` idiom).
10180        // Pinned so the gate doesn't widen to a full ASCII-only sweep
10181        // that would break every legitimate-shape UTF-8 path.
10182        let d = dep_with_fonte(DepSource::Path {
10183            caminho: "../café-teia/foo".into(),
10184        });
10185        d.validate().unwrap();
10186    }
10187
10188    #[test]
10189    fn fonte_caminho_var_fires_before_control_char() {
10190        // Cascade pin: the var-expansion arm structurally precedes the
10191        // control-char arm. A value like `"$\n"` probes positive on
10192        // both arms (`starts_with('$')` and contains LF), but the
10193        // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
10194        // wins so the author sees the more self-locating shell-
10195        // expansion arm first. Mirrors the
10196        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
10197        // discipline on the immediate-predecessor arm.
10198        let d = dep_with_fonte(DepSource::Path {
10199            caminho: "$HOME\n".into(),
10200        });
10201        let err = d.validate().unwrap_err();
10202        assert!(
10203            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10204            "got {err:?}",
10205        );
10206    }
10207
10208    #[test]
10209    fn validate_rejects_path_fonte_with_leading_space_caminho() {
10210        // The fail-before-pass-after pin for the leading ASCII space
10211        // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
10212        // Until this gate landed the b94fd83 absolute arm + the a5c248e
10213        // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
10214        // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
10215        // false on a leading space (the leading byte is `0x20`, not `0x2F`),
10216        // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
10217        // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
10218        // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
10219        // are caught, but the most common whitespace `0x20` space is
10220        // not). The lacre embedded the value verbatim and the resolver
10221        // folded it through `Path::join` looking for a literal `./ ../
10222        // caixa-teia` subdirectory and failing at resolve time with a
10223        // non-self-locating `No such file or directory` error far from
10224        // the source caixa.lisp. The new gate moves the check to
10225        // validate time and names the offending dep + caminho verbatim.
10226        let d = dep_with_fonte(DepSource::Path {
10227            caminho: " ../caixa-teia".into(),
10228        });
10229        let err = d.validate().unwrap_err();
10230        let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
10231            panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
10232        };
10233        assert_eq!(nome, "caixa-teia");
10234        assert_eq!(caminho, " ../caixa-teia");
10235    }
10236
10237    #[test]
10238    fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
10239        // The aligned-doc paste footgun sweep: more than one leading
10240        // space (`"   ../caixa-teia"` — the canonical "I selected the
10241        // aligned column from a four-`:fonte`-entry `:deps` block"
10242        // paste) routes through the same gate's `starts_with(' ')`
10243        // byte check. Pinned so the gate doesn't narrow to a
10244        // single-space prefix.
10245        let d = dep_with_fonte(DepSource::Path {
10246            caminho: "   ../caixa-teia".into(),
10247        });
10248        let err = d.validate().unwrap_err();
10249        assert!(
10250            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10251            "got {err:?}",
10252        );
10253    }
10254
10255    #[test]
10256    fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
10257        // The leading-space is the canonical paste-from-aligned-doc
10258        // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
10259        // canonical "I have a directory with a space in its name"
10260        // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
10261        // legitimate path with no whitespace-leak semantic at the
10262        // non-leading position. Pinned so the gate doesn't widen to a
10263        // full no-space-anywhere sweep that would break every
10264        // legitimate-shape space-in-filename path.
10265        let d = dep_with_fonte(DepSource::Path {
10266            caminho: "../my dir/caixa-teia".into(),
10267        });
10268        d.validate().unwrap();
10269    }
10270
10271    #[test]
10272    fn fonte_caminho_var_fires_before_leading_whitespace() {
10273        // Cascade pin: the var-expansion arm structurally precedes the
10274        // leading-whitespace arm. A value like `"$ "` would probe positive
10275        // on var (`starts_with('$')`) but the leading-byte arms walk
10276        // left-to-right so the var arm fires on the leading `$` before
10277        // the leading-whitespace arm probes. Mirrors the
10278        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
10279        // discipline on the immediate-predecessor arms.
10280        let d = dep_with_fonte(DepSource::Path {
10281            caminho: "$VAR".into(),
10282        });
10283        let err = d.validate().unwrap_err();
10284        assert!(
10285            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10286            "got {err:?}",
10287        );
10288    }
10289
10290    #[test]
10291    fn fonte_caminho_leading_whitespace_fires_before_control_char() {
10292        // Cascade pin: the leading-whitespace arm structurally precedes
10293        // the control-char arm. A value like `" ../foo\n"` probes
10294        // positive on both (starts with space AND contains LF), but
10295        // the narrower leading-byte diagnostic
10296        // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
10297        // more self-locating paste-from-aligned-doc arm first. Mirrors
10298        // the `fonte_caminho_var_fires_before_control_char` cascade
10299        // discipline on the immediate-predecessor arm.
10300        let d = dep_with_fonte(DepSource::Path {
10301            caminho: " ../foo\n".into(),
10302        });
10303        let err = d.validate().unwrap_err();
10304        assert!(
10305            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10306            "got {err:?}",
10307        );
10308    }
10309
10310    #[test]
10311    fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
10312        // Diagnostic-shape pin (peer with
10313        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10314        // payload assertion on the immediate-predecessor arm): the
10315        // error's Display surfaces both the offending `:nome` and the
10316        // offending `:caminho` verbatim, so a `feira lint` run can
10317        // render the diagnostic without re-parsing and the author can
10318        // grep their caixa.lisp for `:caminho "<value>"` and fix it in
10319        // one edit.
10320        let d = dep_with_fonte(DepSource::Path {
10321            caminho: " ../caixa-teia".into(),
10322        });
10323        let rendered = d.validate().unwrap_err().to_string();
10324        assert!(
10325            rendered.contains("caixa-teia"),
10326            "diagnostic must name the offending dep: {rendered}",
10327        );
10328        assert!(
10329            rendered.contains(" ../caixa-teia"),
10330            "diagnostic must quote the offending caminho: {rendered}",
10331        );
10332        assert!(
10333            rendered.contains("space"),
10334            "diagnostic must name the space footgun: {rendered}",
10335        );
10336    }
10337
10338    #[test]
10339    fn fonte_caminho_absolute_fires_before_control_char() {
10340        // Cascade pin on the sibling leading-byte arm: a leading `/`
10341        // value with embedded control byte (`"/etc/passwd\n"`) routes
10342        // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
10343        // — the host-layout-leak diagnostic is the load-bearing axis,
10344        // the control byte is the secondary observation. Same precedence
10345        // logic on every prior leading-byte arm.
10346        let d = dep_with_fonte(DepSource::Path {
10347            caminho: "/etc/passwd\n".into(),
10348        });
10349        let err = d.validate().unwrap_err();
10350        assert!(
10351            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10352            "got {err:?}",
10353        );
10354    }
10355
10356    #[test]
10357    fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
10358        // The fail-before-pass-after pin for the leading-`-` CLI-arg-
10359        // injection `:caminho` shape sweep. Until this gate landed
10360        // every prior leading-byte arm passed a leading-`-` value
10361        // through: `Path::is_absolute` returns false on `-` (the
10362        // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
10363        // `starts_with('$')` / `starts_with(' ')` all return false,
10364        // and `0x2D` sits outside the control-byte set. The lacre
10365        // embedded the value verbatim and the resolver folded it
10366        // through `Path::join` looking for a literal `./-rf` /
10367        // `./-C` / `./--upload-pack=…` subdirectory; the failure at
10368        // `Path::join` time is non-self-locating but harmless, while
10369        // the failure at every downstream `git -C {caminho}` /
10370        // `terraform -chdir={caminho}` / `find {caminho}` shell-out
10371        // is arbitrary-CLI-arg-injection because none of those
10372        // porcelains carry a `--` argument-list terminator between
10373        // the flag block and the path argument. The new arm moves the
10374        // rejection to `Caixa::from_lisp` boundary time and names
10375        // the offending dep + caminho verbatim.
10376        //
10377        // Sweep spans the canonical CLI-arg-injection shapes matching
10378        // the peer sweep on the sibling `is_git_ref_name` /
10379        // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
10380        // `find -rf` reinterpretation vector), `-C` (the `git -C`
10381        // change-directory-config-injection paste), long-flag
10382        // `--upload-pack=cat /etc/passwd` (the canonical
10383        // arbitrary-command-execution vector on every git porcelain
10384        // entry point), git-config-injection `--config=core.merge=ours`,
10385        // and the degenerate single-byte `-` value.
10386        for caminho in [
10387            "-rf",
10388            "-C",
10389            "--upload-pack=cat /etc/passwd",
10390            "--config=core.merge=ours",
10391            "-",
10392        ] {
10393            let d = dep_with_fonte(DepSource::Path {
10394                caminho: caminho.into(),
10395            });
10396            let err = d.validate().unwrap_err();
10397            let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
10398                panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
10399            };
10400            assert_eq!(nome, "caixa-teia");
10401            assert_eq!(got, caminho);
10402        }
10403    }
10404
10405    #[test]
10406    fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
10407        // The leading-`-` is the canonical CLI-arg-injection footgun
10408        // — a `-` anywhere else in the path (`"../caixa-teia"` — the
10409        // canonical kebab-separator-between-alphanumeric-segments
10410        // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
10411        // — a mid-path segment starting with `-`, still a legitimate
10412        // POSIX filename byte at that non-leading position because the
10413        // subprocess reads the whole `{caminho}` value as one positional
10414        // argument, so only the very first byte of the composite path
10415        // string is at the CLI-arg-injection boundary) is a legitimate
10416        // path with no CLI-flag-reinterpretation semantic at the non-
10417        // leading position of the top-level value. Pinned so the gate
10418        // doesn't widen to a full no-`-`-anywhere sweep that would
10419        // break every legitimate-shape kebab-in-filename path (i.e.
10420        // essentially every sibling-workspace caixa dep).
10421        for caminho in [
10422            "../caixa-teia",
10423            "../caixa-teia/-hidden",
10424            "./my-lib",
10425            "../foo-bar/baz",
10426        ] {
10427            let d = dep_with_fonte(DepSource::Path {
10428                caminho: caminho.into(),
10429            });
10430            d.validate()
10431                .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
10432        }
10433    }
10434
10435    #[test]
10436    fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
10437        // Cascade pin: the leading-whitespace arm structurally precedes
10438        // the leading-hyphen arm. A value like `" -rf"` probes positive
10439        // on both (leading space AND, one byte in, a `-` — though the
10440        // leading-hyphen arm probes only the very first byte so it
10441        // wouldn't fire on this value; the pin instead documents the
10442        // arm order on the more common "leading space then a hyphen"
10443        // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
10444        // The narrower leading-space diagnostic (the paste-from-aligned-
10445        // doc footgun) wins so the author sees the more self-locating
10446        // whitespace arm first. Mirrors the
10447        // `fonte_caminho_var_fires_before_leading_whitespace` cascade
10448        // discipline on the immediate-predecessor arm.
10449        let d = dep_with_fonte(DepSource::Path {
10450            caminho: " -rf".into(),
10451        });
10452        let err = d.validate().unwrap_err();
10453        assert!(
10454            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10455            "got {err:?}",
10456        );
10457    }
10458
10459    #[test]
10460    fn fonte_caminho_leading_hyphen_fires_before_control_char() {
10461        // Cascade pin: the leading-hyphen arm structurally precedes
10462        // the control-char arm. A value like `"-rf\n"` probes positive
10463        // on both (starts with `-` AND contains LF), but the narrower
10464        // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
10465        // the author sees the more self-locating CLI-arg-injection arm
10466        // first. Mirrors the
10467        // `fonte_caminho_leading_whitespace_fires_before_control_char`
10468        // cascade discipline on the immediate-predecessor arm.
10469        let d = dep_with_fonte(DepSource::Path {
10470            caminho: "-rf\n".into(),
10471        });
10472        let err = d.validate().unwrap_err();
10473        assert!(
10474            matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
10475            "got {err:?}",
10476        );
10477    }
10478
10479    #[test]
10480    fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
10481        // Diagnostic-shape pin (peer with
10482        // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
10483        // payload assertion on the immediate-predecessor arm): the
10484        // error's Display surfaces both the offending `:nome` and the
10485        // offending `:caminho` verbatim plus the CLI-argument-injection
10486        // vocabulary, so a `feira lint` run can render the diagnostic
10487        // without re-parsing and the author can grep their caixa.lisp
10488        // for `:caminho "<value>"` and fix it in one edit.
10489        let d = dep_with_fonte(DepSource::Path {
10490            caminho: "--upload-pack=cat /etc/passwd".into(),
10491        });
10492        let rendered = d.validate().unwrap_err().to_string();
10493        assert!(
10494            rendered.contains("caixa-teia"),
10495            "diagnostic must name the offending dep: {rendered}",
10496        );
10497        assert!(
10498            rendered.contains("--upload-pack=cat /etc/passwd"),
10499            "diagnostic must quote the offending caminho: {rendered}",
10500        );
10501        assert!(
10502            rendered.contains("CLI-argument-injection"),
10503            "diagnostic must name the CLI-argument-injection vector: {rendered}",
10504        );
10505        assert!(
10506            rendered.contains("`-`"),
10507            "diagnostic must name the offending byte: {rendered}",
10508        );
10509    }
10510
10511    #[test]
10512    fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
10513        // Diagnostic-shape pin (peer with
10514        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10515        // payload assertion on the immediate-predecessor arm): the
10516        // error's Display surfaces the offending `:nome`, the
10517        // offending `:caminho` verbatim, and the offending byte in
10518        // hex form (`0x09` for tab) so a `feira lint` run can render
10519        // the diagnostic without re-parsing.
10520        let d = dep_with_fonte(DepSource::Path {
10521            caminho: "../caixa\tteia".into(),
10522        });
10523        let rendered = d.validate().unwrap_err().to_string();
10524        assert!(
10525            rendered.contains("caixa-teia"),
10526            "diagnostic must name the offending dep: {rendered}",
10527        );
10528        assert!(
10529            rendered.contains("../caixa\tteia"),
10530            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10531        );
10532        assert!(
10533            rendered.contains("0x09"),
10534            "diagnostic must name the offending byte in hex: {rendered:?}",
10535        );
10536    }
10537
10538    #[test]
10539    fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
10540        // The fail-before-pass-after pin for the canonical Windows-
10541        // path-separator paste footgun: an author who pastes a path
10542        // from Windows-Explorer's `Copy as path`, PowerShell's
10543        // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
10544        // produces `..\caixa-teia`-shape values that silently passed
10545        // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
10546        // false; `\` is neither a leading-byte sentinel nor a
10547        // control byte). On POSIX resolvers the value rides through
10548        // `Path::join` as a literal directory name and fails at
10549        // resolve time with `No such file or directory`; on Windows
10550        // resolvers the value resolves to the parent's sibling — two
10551        // distinct directories for the byte-identical caixa.lisp.
10552        // The new arm moves the rejection to validate time and names
10553        // the offending dep + caminho verbatim.
10554        let d = dep_with_fonte(DepSource::Path {
10555            caminho: "..\\caixa-teia".into(),
10556        });
10557        let err = d.validate().unwrap_err();
10558        let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
10559            panic!("expected FonteCaminhoBackslash, got {err:?}");
10560        };
10561        assert_eq!(nome, "caixa-teia");
10562        assert_eq!(caminho, "..\\caixa-teia");
10563    }
10564
10565    #[test]
10566    fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
10567        // The Windows drive-letter paste shape (`C:\work\caixa-teia`
10568        // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
10569        // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
10570        // false (POSIX absolute paths start with `/`, drive letters
10571        // are not a POSIX concept), so the b94fd83 absolute arm
10572        // doesn't fire; the value contains `\` bytes that this arm
10573        // now catches with the more self-locating Windows-path-
10574        // separator diagnostic. Pinned separately from the bare
10575        // `..\caixa-teia` shape so a future arm that targets only
10576        // leading-`..\` doesn't regress the drive-letter coverage.
10577        let d = dep_with_fonte(DepSource::Path {
10578            caminho: "C:\\work\\caixa-teia".into(),
10579        });
10580        let err = d.validate().unwrap_err();
10581        assert!(
10582            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10583            "got {err:?}",
10584        );
10585    }
10586
10587    #[test]
10588    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
10589        // The trailing-`\` shape (`..\caixa-teia\` — the canonical
10590        // PowerShell tab-completion-on-a-directory append). Pinned
10591        // separately from the embedded-`\` shape so the gate's
10592        // contract is "any `\` anywhere", not "any `\` not at end".
10593        let d = dep_with_fonte(DepSource::Path {
10594            caminho: "..\\caixa-teia\\".into(),
10595        });
10596        let err = d.validate().unwrap_err();
10597        assert!(
10598            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10599            "got {err:?}",
10600        );
10601    }
10602
10603    #[test]
10604    fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
10605        // The positive-control pin: the gate targets `\` only,
10606        // never `/`. The canonical relative POSIX path
10607        // (`../caixa-teia/foo/bar`) must continue to validate cleanly
10608        // so legitimate nested-directory deps aren't broken. Pinned
10609        // so the gate doesn't accidentally widen to a "no path
10610        // separators at all" sweep.
10611        let d = dep_with_fonte(DepSource::Path {
10612            caminho: "../caixa-teia/foo/bar".into(),
10613        });
10614        d.validate().unwrap();
10615    }
10616
10617    #[test]
10618    fn fonte_caminho_control_char_fires_before_backslash() {
10619        // Cascade pin: the control-char arm structurally precedes the
10620        // backslash arm. A value like `"..\caixa\0teia"` probes
10621        // positive on both (`\` byte + NUL byte), but the control-
10622        // char diagnostic wins so the author sees the more self-
10623        // locating POSIX-syscall-rejected-byte diagnostic first
10624        // (NUL outright breaks `CString::new` at every `std::fs`
10625        // syscall boundary; the `\` divergence is the cross-OS-
10626        // separator axis). Mirrors the
10627        // `fonte_caminho_var_fires_before_control_char` cascade
10628        // discipline on the immediate-predecessor arm.
10629        let d = dep_with_fonte(DepSource::Path {
10630            caminho: "..\\caixa\0teia".into(),
10631        });
10632        let err = d.validate().unwrap_err();
10633        assert!(
10634            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10635            "got {err:?}",
10636        );
10637    }
10638
10639    #[test]
10640    fn fonte_caminho_absolute_fires_before_backslash() {
10641        // Cascade pin on the load-bearing leading-byte arm: a leading
10642        // `/` value with embedded `\` (`/etc/passwd\foo`) routes
10643        // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
10644        // — the host-layout-leak diagnostic is the load-bearing
10645        // axis, the `\` byte is the secondary observation. Same
10646        // precedence logic as every prior leading-byte arm.
10647        let d = dep_with_fonte(DepSource::Path {
10648            caminho: "/etc/passwd\\foo".into(),
10649        });
10650        let err = d.validate().unwrap_err();
10651        assert!(
10652            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10653            "got {err:?}",
10654        );
10655    }
10656
10657    #[test]
10658    fn fonte_caminho_var_fires_before_backslash() {
10659        // Cascade pin on the var-expansion arm: a leading-`$` value
10660        // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
10661        // PowerShell-env-var paste-from-CI-manifest footgun) routes
10662        // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
10663        // The shell-expansion diagnostic is the more self-locating
10664        // axis since both the leading `$` and the embedded `\`
10665        // are Windows-shell artifacts but the `$` is the root-cause
10666        // surface (an author who removes the `$` is likely to leave
10667        // the `\` too).
10668        let d = dep_with_fonte(DepSource::Path {
10669            caminho: "$WORKSPACE\\caixa-teia".into(),
10670        });
10671        let err = d.validate().unwrap_err();
10672        assert!(
10673            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10674            "got {err:?}",
10675        );
10676    }
10677
10678    #[test]
10679    fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
10680        // Diagnostic-shape pin (peer with the prior
10681        // `fonte_caminho_*_diagnostic_carries_*` payload assertions
10682        // on every preceding arm): the error's Display surfaces the
10683        // offending `:nome` and the offending `:caminho` verbatim
10684        // so a `feira lint` run can render the diagnostic without
10685        // re-parsing.
10686        let d = dep_with_fonte(DepSource::Path {
10687            caminho: "..\\caixa-teia".into(),
10688        });
10689        let rendered = d.validate().unwrap_err().to_string();
10690        assert!(
10691            rendered.contains("caixa-teia"),
10692            "diagnostic must name the offending dep: {rendered}",
10693        );
10694        assert!(
10695            rendered.contains("..\\caixa-teia"),
10696            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10697        );
10698        assert!(
10699            rendered.contains('\\'),
10700            "diagnostic must reference the backslash footgun: {rendered:?}",
10701        );
10702    }
10703
10704    #[test]
10705    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
10706        // The fail-before-pass-after pin for the canonical trailing-`/`
10707        // paste footgun: an author who shell-tab-completes a sibling
10708        // directory (every interactive shell — bash/zsh/fish/nushell —
10709        // appends `/` on tab-completing a directory) produces
10710        // `"../caixa-teia/"`-shape values that silently passed every
10711        // prior arm (the leading byte is `.`, no control bytes, no
10712        // backslash). `Path::join` resolves both shapes to the same
10713        // directory at the resolver, but the lacre embeds the value
10714        // verbatim and the BLAKE3 closures diverge across two
10715        // workstations whose authors differ only in tab-completion
10716        // habits.
10717        let d = dep_with_fonte(DepSource::Path {
10718            caminho: "../caixa-teia/".into(),
10719        });
10720        let err = d.validate().unwrap_err();
10721        let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
10722            panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
10723        };
10724        assert_eq!(nome, "caixa-teia");
10725        assert_eq!(caminho, "../caixa-teia/");
10726    }
10727
10728    #[test]
10729    fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
10730        // The `"./"` shape (the canonical "I meant the caixa.lisp's own
10731        // directory and tab-completed it" footgun). Pinned separately
10732        // from the canonical `"../caixa-teia/"` shape so the gate's
10733        // contract is "any trailing `/`", not "trailing `/` after a leaf
10734        // name".
10735        let d = dep_with_fonte(DepSource::Path {
10736            caminho: "./".into(),
10737        });
10738        let err = d.validate().unwrap_err();
10739        assert!(
10740            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10741            "got {err:?}",
10742        );
10743    }
10744
10745    #[test]
10746    fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
10747        // The `"foo//"` shape (the canonical "I pasted from a CI manifest
10748        // that double-templated `${VAR}/` over an already-`/`-suffixed
10749        // path" footgun). The gate fires on the last byte being `/`
10750        // regardless of how many `/` precede it; the arm contract is
10751        // "the value ends with `/`", structurally.
10752        let d = dep_with_fonte(DepSource::Path {
10753            caminho: "../caixa-teia//".into(),
10754        });
10755        let err = d.validate().unwrap_err();
10756        assert!(
10757            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10758            "got {err:?}",
10759        );
10760    }
10761
10762    #[test]
10763    fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
10764        // The `"../"` shape (the canonical "I want the parent" tab-
10765        // completion footgun on a bare `..` path). Pinned separately so
10766        // the gate doesn't accidentally narrow to "trailing `/` only on
10767        // multi-segment paths".
10768        let d = dep_with_fonte(DepSource::Path {
10769            caminho: "../".into(),
10770        });
10771        let err = d.validate().unwrap_err();
10772        assert!(
10773            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10774            "got {err:?}",
10775        );
10776    }
10777
10778    #[test]
10779    fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
10780        // The positive-control pin: the gate targets the trailing byte
10781        // only, never internal `/` separators. The canonical nested
10782        // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
10783        // to validate cleanly so legitimate deeply-nested deps aren't
10784        // broken. Pinned so the gate doesn't accidentally widen to a
10785        // "no `/` separators anywhere" sweep that would defeat the
10786        // entire path-fonte author surface.
10787        let d = dep_with_fonte(DepSource::Path {
10788            caminho: "../caixa-teia/foo/bar".into(),
10789        });
10790        d.validate().unwrap();
10791    }
10792
10793    #[test]
10794    fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
10795        // The positive-control pin on the degenerate single-`.` shape
10796        // (the canonical "the caixa.lisp's own directory" idiom). The
10797        // gate fires on the trailing byte being `/`, not on the path
10798        // being short, so `"."` (one byte, not `/`) must continue to
10799        // validate cleanly.
10800        let d = dep_with_fonte(DepSource::Path {
10801            caminho: ".".into(),
10802        });
10803        d.validate().unwrap();
10804    }
10805
10806    #[test]
10807    fn fonte_caminho_control_char_fires_before_trailing_slash() {
10808        // Cascade pin: the control-char arm structurally precedes the
10809        // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
10810        // but the embedded LF (`0x0A`) is the load-bearing diagnostic
10811        // (control bytes are the paste-from-multiline-doc footgun the
10812        // d624c8d arm already closes). Mirrors the
10813        // `fonte_caminho_control_char_fires_before_backslash` cascade
10814        // discipline on the immediate-predecessor arm.
10815        let d = dep_with_fonte(DepSource::Path {
10816            caminho: "../foo\n/".into(),
10817        });
10818        let err = d.validate().unwrap_err();
10819        assert!(
10820            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10821            "got {err:?}",
10822        );
10823    }
10824
10825    #[test]
10826    fn fonte_caminho_backslash_fires_before_trailing_slash() {
10827        // Cascade pin on the backslash arm: a value like `"..\foo/"`
10828        // ends in `/` but the embedded `\` is the load-bearing
10829        // diagnostic (the cross-host-OS-separator divergence vector
10830        // the 3a4e1d7 arm closes). Same precedence logic as the prior
10831        // narrower-diagnostic-first cascade.
10832        let d = dep_with_fonte(DepSource::Path {
10833            caminho: "..\\caixa-teia/".into(),
10834        });
10835        let err = d.validate().unwrap_err();
10836        assert!(
10837            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10838            "got {err:?}",
10839        );
10840    }
10841
10842    #[test]
10843    fn fonte_caminho_absolute_fires_before_trailing_slash() {
10844        // Cascade pin on the load-bearing leading-byte arm: a leading
10845        // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
10846        // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
10847        // — the host-layout-leak diagnostic is the load-bearing axis,
10848        // the trailing `/` is the secondary observation. Same
10849        // precedence logic as every prior leading-byte arm.
10850        let d = dep_with_fonte(DepSource::Path {
10851            caminho: "/etc/passwd/".into(),
10852        });
10853        let err = d.validate().unwrap_err();
10854        assert!(
10855            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10856            "got {err:?}",
10857        );
10858    }
10859
10860    #[test]
10861    fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
10862        // Diagnostic-shape pin (peer with the prior
10863        // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
10864        // every preceding arm): the error's Display surfaces the
10865        // offending `:nome` and the offending `:caminho` verbatim so a
10866        // `feira lint` run can render the diagnostic without re-parsing.
10867        let d = dep_with_fonte(DepSource::Path {
10868            caminho: "../caixa-teia/".into(),
10869        });
10870        let rendered = d.validate().unwrap_err().to_string();
10871        assert!(
10872            rendered.contains("caixa-teia"),
10873            "diagnostic must name the offending dep: {rendered}",
10874        );
10875        assert!(
10876            rendered.contains("../caixa-teia/"),
10877            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10878        );
10879        assert!(
10880            rendered.contains("trailing"),
10881            "diagnostic must reference the trailing-slash footgun: {rendered:?}",
10882        );
10883    }
10884
10885    // -- :caminho shell-redirection metacharacter arm -----------------------
10886
10887    #[test]
10888    fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
10889        // The fail-before-pass-after pin for the canonical output-redirection
10890        // paste footgun: an author copies a shell pipeline tail
10891        // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
10892        // line including the `> build.log` redirect" idiom) and silently
10893        // passed every prior arm (`Path::is_absolute` false on `..`, no
10894        // control bytes, no backslash, doesn't end in `/`). The lacre
10895        // embedded the value verbatim, the resolver folded it through
10896        // `Path::join` looking for a literal `./../caixa-teia>build.log`
10897        // subdirectory, and the failure surfaced at resolve time with a
10898        // non-self-locating `No such file or directory` error. The new arm
10899        // moves the rejection to validate time and names the offending dep
10900        // + caminho + byte verbatim.
10901        let d = dep_with_fonte(DepSource::Path {
10902            caminho: "../caixa-teia>build.log".into(),
10903        });
10904        let err = d.validate().unwrap_err();
10905        let DepError::FonteCaminhoShellRedirection {
10906            nome,
10907            caminho,
10908            byte,
10909        } = err
10910        else {
10911            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10912        };
10913        assert_eq!(nome, "caixa-teia");
10914        assert_eq!(caminho, "../caixa-teia>build.log");
10915        assert_eq!(byte, b'>');
10916    }
10917
10918    #[test]
10919    fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
10920        // The symmetric input-redirection paste shape
10921        // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
10922        // `command < input.lisp` line from a tatara-lisp REPL log"
10923        // idiom). Pinned separately from the `>` shape so the gate's
10924        // contract is "any `<` or `>` anywhere", not single-byte coverage.
10925        let d = dep_with_fonte(DepSource::Path {
10926            caminho: "../caixa-teia<input.lisp".into(),
10927        });
10928        let err = d.validate().unwrap_err();
10929        let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
10930            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10931        };
10932        assert_eq!(byte, b'<');
10933    }
10934
10935    #[test]
10936    fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
10937        // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
10938        // "I forgot the source side of the redirect" idiom). Pinned
10939        // separately from the embedded-byte shapes so the gate covers
10940        // every position, not only mid-path.
10941        let d = dep_with_fonte(DepSource::Path {
10942            caminho: ">../caixa-teia".into(),
10943        });
10944        let err = d.validate().unwrap_err();
10945        assert!(
10946            matches!(
10947                err,
10948                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10949            ),
10950            "got {err:?}",
10951        );
10952    }
10953
10954    #[test]
10955    fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
10956        // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
10957        // the canonical "I copied a `>>` append redirect" idiom). The arm
10958        // fires on the first `>` encountered; pinned so a future arm that
10959        // tries to distinguish `>` from `>>` doesn't break the broader
10960        // contract.
10961        let d = dep_with_fonte(DepSource::Path {
10962            caminho: "../caixa-teia>>build.log".into(),
10963        });
10964        let err = d.validate().unwrap_err();
10965        assert!(
10966            matches!(
10967                err,
10968                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10969            ),
10970            "got {err:?}",
10971        );
10972    }
10973
10974    #[test]
10975    fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
10976        // The positive-control pin: the gate targets only `<` / `>`,
10977        // never adjacent printable ASCII or POSIX-valid bytes. The
10978        // canonical relative POSIX path (`"../caixa-teia"`) and a
10979        // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
10980        // continue to validate cleanly so the gate doesn't widen to a
10981        // "no printable punctuation anywhere" sweep that would defeat
10982        // the entire path-fonte author surface.
10983        let d = dep_with_fonte(DepSource::Path {
10984            caminho: "../caixa-teia/foo/bar".into(),
10985        });
10986        d.validate().unwrap();
10987    }
10988
10989    #[test]
10990    fn fonte_caminho_backslash_fires_before_shell_redirection() {
10991        // Cascade pin on the immediate-predecessor arm: a value carrying
10992        // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
10993        // canonical "I pasted a Windows-shell command with output
10994        // redirect" footgun) routes through `FonteCaminhoBackslash` not
10995        // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
10996        // divergence is the load-bearing axis (an author who removes
10997        // the `\` is the root-cause edit; the `>` falls away in the
10998        // same edit since it's downstream of the Windows-shell
10999        // convention).
11000        let d = dep_with_fonte(DepSource::Path {
11001            caminho: "..\\caixa-teia>build.log".into(),
11002        });
11003        let err = d.validate().unwrap_err();
11004        assert!(
11005            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11006            "got {err:?}",
11007        );
11008    }
11009
11010    #[test]
11011    fn fonte_caminho_control_char_fires_before_shell_redirection() {
11012        // Cascade pin on the embedded-control-byte arm: a value carrying
11013        // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
11014        // canonical paste-from-multiline-doc footgun where a newline
11015        // landed mid-caminho) routes through `FonteCaminhoControlChar`
11016        // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
11017        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11018        // load-bearing axis on every value that probes positive for
11019        // both — mirrors the cascade discipline on every prior arm.
11020        let d = dep_with_fonte(DepSource::Path {
11021            caminho: "../foo\n>bar".into(),
11022        });
11023        let err = d.validate().unwrap_err();
11024        assert!(
11025            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11026            "got {err:?}",
11027        );
11028    }
11029
11030    #[test]
11031    fn fonte_caminho_absolute_fires_before_shell_redirection() {
11032        // Cascade pin on the load-bearing leading-byte arm: a leading
11033        // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
11034        // routes through `FonteCaminhoAbsolute` not
11035        // `FonteCaminhoShellRedirection` — the host-layout-leak
11036        // diagnostic is the load-bearing axis, the `>` byte is the
11037        // secondary observation. Same precedence logic as every prior
11038        // leading-byte arm.
11039        let d = dep_with_fonte(DepSource::Path {
11040            caminho: "/etc/passwd>out".into(),
11041        });
11042        let err = d.validate().unwrap_err();
11043        assert!(
11044            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11045            "got {err:?}",
11046        );
11047    }
11048
11049    #[test]
11050    fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
11051        // Cascade pin on the immediate-successor arm: a value carrying
11052        // both `<` / `>` and a trailing `/` (`"../foo></"` — the
11053        // canonical "I tab-completed a path that already had a
11054        // redirect" footgun) routes through `FonteCaminhoShellRedirection`
11055        // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11056        // the more semantic-locating axis (an author who removes the
11057        // `<` / `>` typically also drops the trailing separator since
11058        // both are paste-from-shell artifacts).
11059        let d = dep_with_fonte(DepSource::Path {
11060            caminho: "../foo></".into(),
11061        });
11062        let err = d.validate().unwrap_err();
11063        assert!(
11064            matches!(
11065                err,
11066                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11067            ),
11068            "got {err:?}",
11069        );
11070    }
11071
11072    #[test]
11073    fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
11074        // Diagnostic-shape pin (peer with
11075        // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
11076        // payload assertion on the closest peer arm that also carries a
11077        // `byte` field): the error's Display surfaces the offending
11078        // `:nome`, the offending `:caminho` verbatim, and the offending
11079        // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
11080        // run can render the diagnostic without re-parsing.
11081        let d = dep_with_fonte(DepSource::Path {
11082            caminho: "../caixa-teia>build.log".into(),
11083        });
11084        let rendered = d.validate().unwrap_err().to_string();
11085        assert!(
11086            rendered.contains("caixa-teia"),
11087            "diagnostic must name the offending dep: {rendered}",
11088        );
11089        assert!(
11090            rendered.contains("../caixa-teia>build.log"),
11091            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11092        );
11093        assert!(
11094            rendered.contains("0x3e"),
11095            "diagnostic must name the offending byte in hex: {rendered:?}",
11096        );
11097        assert!(
11098            rendered.contains("redirection"),
11099            "diagnostic must name the shell-redirection footgun: {rendered:?}",
11100        );
11101    }
11102
11103    // -- :caminho shell-pipe metacharacter arm ----------------------------
11104
11105    #[test]
11106    fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
11107        // The fail-before-pass-after pin for the canonical shell-pipe
11108        // paste footgun: an author copies a shell-history line
11109        // (`"../caixa-teia | grep foo"` — the canonical "I selected
11110        // the whole `ls dir | grep` line out of zsh history") and
11111        // silently passed every prior arm (`Path::is_absolute` false
11112        // on `..`, no control bytes, no backslash, no `<` / `>`,
11113        // doesn't end in `/`). The lacre embedded the value verbatim,
11114        // the resolver folded it through `Path::join` looking for a
11115        // literal `./../caixa-teia | grep foo` subdirectory, and the
11116        // failure surfaced at resolve time with a non-self-locating
11117        // `No such file or directory` error. The new arm moves the
11118        // rejection to validate time and names the offending dep +
11119        // caminho verbatim.
11120        let d = dep_with_fonte(DepSource::Path {
11121            caminho: "../caixa-teia | grep foo".into(),
11122        });
11123        let err = d.validate().unwrap_err();
11124        let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
11125            panic!("expected FonteCaminhoShellPipe, got {err:?}");
11126        };
11127        assert_eq!(nome, "caixa-teia");
11128        assert_eq!(caminho, "../caixa-teia | grep foo");
11129    }
11130
11131    #[test]
11132    fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
11133        // Leading-position `|` shape (`"|../caixa-teia"` — the
11134        // degenerate "I forgot the source side of the pipe" idiom).
11135        // Pinned separately from the embedded-byte shape so the gate
11136        // covers every position, not only mid-path.
11137        let d = dep_with_fonte(DepSource::Path {
11138            caminho: "|../caixa-teia".into(),
11139        });
11140        let err = d.validate().unwrap_err();
11141        assert!(
11142            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11143            "got {err:?}",
11144        );
11145    }
11146
11147    #[test]
11148    fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
11149        // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
11150        // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
11151        // idiom). The arm fires on the first `|` encountered; pinned
11152        // so a future arm that tries to distinguish `|` from `||`
11153        // doesn't break the broader contract.
11154        let d = dep_with_fonte(DepSource::Path {
11155            caminho: "../caixa-teia||fallback".into(),
11156        });
11157        let err = d.validate().unwrap_err();
11158        assert!(
11159            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11160            "got {err:?}",
11161        );
11162    }
11163
11164    #[test]
11165    fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
11166        // The positive-control pin: the gate targets only `|`, never
11167        // adjacent printable ASCII or POSIX-valid bytes. The canonical
11168        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11169        // pathed variant with adjacent printable punctuation
11170        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11171        // cleanly so the gate doesn't widen to a "no printable
11172        // punctuation anywhere" sweep that would defeat the entire
11173        // path-fonte author surface.
11174        let d = dep_with_fonte(DepSource::Path {
11175            caminho: "../caixa-teia/sub-dir.v2".into(),
11176        });
11177        d.validate().unwrap();
11178    }
11179
11180    #[test]
11181    fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
11182        // Cascade pin on the immediate-predecessor arm: a value carrying
11183        // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
11184        // canonical "I pasted a `cmd < input | tee` pipeline tail"
11185        // footgun) routes through `FonteCaminhoShellRedirection` not
11186        // `FonteCaminhoShellPipe`. The input/output redirection
11187        // metachar carries the more self-locating `byte: u8` payload
11188        // (it names which of `<` or `>` triggered), so the prior arm
11189        // wins on every probe-as-both value — same cascade discipline
11190        // every prior `:caminho` arm establishes.
11191        let d = dep_with_fonte(DepSource::Path {
11192            caminho: "../caixa-teia<input|tee".into(),
11193        });
11194        let err = d.validate().unwrap_err();
11195        assert!(
11196            matches!(
11197                err,
11198                DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
11199            ),
11200            "got {err:?}",
11201        );
11202    }
11203
11204    #[test]
11205    fn fonte_caminho_backslash_fires_before_shell_pipe() {
11206        // Cascade pin on the upstream backslash arm: a value carrying
11207        // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
11208        // "I pasted a Windows-shell command with pipe to tee"
11209        // footgun) routes through `FonteCaminhoBackslash` not
11210        // `FonteCaminhoShellPipe`. The cross-host-OS-separator
11211        // divergence is the load-bearing axis on every probe-as-both
11212        // value (an author who removes the `\` is the root-cause edit;
11213        // the `|` falls away in the same edit since it's downstream of
11214        // the Windows-shell convention).
11215        let d = dep_with_fonte(DepSource::Path {
11216            caminho: "..\\caixa-teia|tee".into(),
11217        });
11218        let err = d.validate().unwrap_err();
11219        assert!(
11220            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11221            "got {err:?}",
11222        );
11223    }
11224
11225    #[test]
11226    fn fonte_caminho_control_char_fires_before_shell_pipe() {
11227        // Cascade pin on the embedded-control-byte arm: a value
11228        // carrying both a control byte and `|` (`"../foo\n|bar"` —
11229        // the canonical paste-from-multiline-doc footgun where a
11230        // newline landed mid-caminho) routes through
11231        // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
11232        // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11233        // diagnostic is the load-bearing axis on every value that
11234        // probes positive for both — mirrors the cascade discipline
11235        // on every prior arm.
11236        let d = dep_with_fonte(DepSource::Path {
11237            caminho: "../foo\n|bar".into(),
11238        });
11239        let err = d.validate().unwrap_err();
11240        assert!(
11241            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11242            "got {err:?}",
11243        );
11244    }
11245
11246    #[test]
11247    fn fonte_caminho_absolute_fires_before_shell_pipe() {
11248        // Cascade pin on the load-bearing leading-byte arm: a leading
11249        // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
11250        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
11251        // — the host-layout-leak diagnostic is the load-bearing axis,
11252        // the `|` byte is the secondary observation. Same precedence
11253        // logic as every prior leading-byte arm.
11254        let d = dep_with_fonte(DepSource::Path {
11255            caminho: "/etc/passwd|tee".into(),
11256        });
11257        let err = d.validate().unwrap_err();
11258        assert!(
11259            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11260            "got {err:?}",
11261        );
11262    }
11263
11264    #[test]
11265    fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
11266        // Cascade pin on the immediate-successor arm: a value carrying
11267        // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
11268        // "I tab-completed a path that already had a pipeline tail"
11269        // footgun) routes through `FonteCaminhoShellPipe` not
11270        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11271        // the more semantic-locating axis (an author who removes the
11272        // `|` typically also drops the trailing separator since both
11273        // are paste-from-shell artifacts).
11274        let d = dep_with_fonte(DepSource::Path {
11275            caminho: "../foo|tee/".into(),
11276        });
11277        let err = d.validate().unwrap_err();
11278        assert!(
11279            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11280            "got {err:?}",
11281        );
11282    }
11283
11284    #[test]
11285    fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
11286        // Diagnostic-shape pin (peer with
11287        // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
11288        // on the closest single-byte peer arm): the error's Display
11289        // surfaces the offending `:nome` and the offending `:caminho`
11290        // verbatim, and names the shell-pipe footgun explicitly so a
11291        // `feira lint` run can render the diagnostic without
11292        // re-parsing.
11293        let d = dep_with_fonte(DepSource::Path {
11294            caminho: "../caixa-teia | grep foo".into(),
11295        });
11296        let rendered = d.validate().unwrap_err().to_string();
11297        assert!(
11298            rendered.contains("caixa-teia"),
11299            "diagnostic must name the offending dep: {rendered}",
11300        );
11301        assert!(
11302            rendered.contains("../caixa-teia | grep foo"),
11303            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11304        );
11305        assert!(
11306            rendered.contains('|'),
11307            "diagnostic must reference the pipe footgun: {rendered:?}",
11308        );
11309        assert!(
11310            rendered.contains("pipe"),
11311            "diagnostic must name the shell-pipe footgun: {rendered:?}",
11312        );
11313    }
11314
11315    // -- :caminho shell-command-separator metacharacter arm ---------------
11316
11317    #[test]
11318    fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
11319        // The fail-before-pass-after pin for the canonical shell-command-
11320        // separator paste footgun: an author copies a shell one-liner
11321        // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
11322        // whole `cd path; do-thing` chain out of a shell-history block")
11323        // and silently passed every prior arm (`Path::is_absolute` false
11324        // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
11325        // doesn't end in `/`). The lacre embedded the value verbatim, the
11326        // resolver folded it through `Path::join` looking for a literal
11327        // `./../caixa-teia; rm -rf build` subdirectory, and the failure
11328        // surfaced at resolve time with a non-self-locating `No such file
11329        // or directory` error. The new arm moves the rejection to validate
11330        // time and names the offending dep + caminho verbatim.
11331        let d = dep_with_fonte(DepSource::Path {
11332            caminho: "../caixa-teia; rm -rf build".into(),
11333        });
11334        let err = d.validate().unwrap_err();
11335        let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
11336            panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
11337        };
11338        assert_eq!(nome, "caixa-teia");
11339        assert_eq!(caminho, "../caixa-teia; rm -rf build");
11340    }
11341
11342    #[test]
11343    fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
11344        // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
11345        // "I forgot the prior command side of the separator" idiom).
11346        // Pinned separately from the embedded-byte shape so the gate
11347        // covers every position, not only mid-path.
11348        let d = dep_with_fonte(DepSource::Path {
11349            caminho: ";../caixa-teia".into(),
11350        });
11351        let err = d.validate().unwrap_err();
11352        assert!(
11353            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11354            "got {err:?}",
11355        );
11356    }
11357
11358    #[test]
11359    fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
11360        // The POSIX `case` arm `;;` terminator shape
11361        // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
11362        // arm tail" idiom). The arm fires on the first `;` encountered;
11363        // pinned so a future arm that tries to distinguish `;` from `;;`
11364        // doesn't break the broader contract.
11365        let d = dep_with_fonte(DepSource::Path {
11366            caminho: "../caixa-teia;;next".into(),
11367        });
11368        let err = d.validate().unwrap_err();
11369        assert!(
11370            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11371            "got {err:?}",
11372        );
11373    }
11374
11375    #[test]
11376    fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
11377        // The positive-control pin: the gate targets only `;`, never
11378        // adjacent printable ASCII or POSIX-valid bytes. The canonical
11379        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11380        // pathed variant with adjacent printable punctuation
11381        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11382        // cleanly so the gate doesn't widen to a "no printable
11383        // punctuation anywhere" sweep that would defeat the entire
11384        // path-fonte author surface.
11385        let d = dep_with_fonte(DepSource::Path {
11386            caminho: "../caixa-teia/sub-dir.v2".into(),
11387        });
11388        d.validate().unwrap();
11389    }
11390
11391    #[test]
11392    fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
11393        // Cascade pin on the immediate-predecessor arm: a value carrying
11394        // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
11395        // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
11396        // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
11397        // pipeline-tail paste is the load-bearing root-cause edit on
11398        // every probe-as-both value (an author who removes the `|`
11399        // typically also drops the trailing `; cleanup` since both are
11400        // the same paste-from-shell-history artifact) — same cascade
11401        // discipline every prior `:caminho` arm establishes.
11402        let d = dep_with_fonte(DepSource::Path {
11403            caminho: "../caixa-teia | tee; rm".into(),
11404        });
11405        let err = d.validate().unwrap_err();
11406        assert!(
11407            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11408            "got {err:?}",
11409        );
11410    }
11411
11412    #[test]
11413    fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
11414        // Cascade pin on the upstream shell-redirection arm: a value
11415        // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
11416        // the canonical "I pasted a `cmd > log; cleanup` chain"
11417        // footgun) routes through `FonteCaminhoShellRedirection` not
11418        // `FonteCaminhoShellSemicolon`. The input/output redirection
11419        // metachar carries the more self-locating `byte: u8` payload
11420        // (it names which of `<` or `>` triggered), so the prior arm
11421        // wins on every probe-as-both value.
11422        let d = dep_with_fonte(DepSource::Path {
11423            caminho: "../caixa-teia>log; rm".into(),
11424        });
11425        let err = d.validate().unwrap_err();
11426        assert!(
11427            matches!(
11428                err,
11429                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11430            ),
11431            "got {err:?}",
11432        );
11433    }
11434
11435    #[test]
11436    fn fonte_caminho_backslash_fires_before_shell_semicolon() {
11437        // Cascade pin on the upstream backslash arm: a value carrying
11438        // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
11439        // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
11440        // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
11441        // The cross-host-OS-separator divergence is the load-bearing axis
11442        // on every probe-as-both value (an author who removes the `\` is
11443        // the root-cause edit; the `;` falls away in the same edit since
11444        // it's downstream of the Windows-shell convention).
11445        let d = dep_with_fonte(DepSource::Path {
11446            caminho: "..\\caixa-teia;rm".into(),
11447        });
11448        let err = d.validate().unwrap_err();
11449        assert!(
11450            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11451            "got {err:?}",
11452        );
11453    }
11454
11455    #[test]
11456    fn fonte_caminho_control_char_fires_before_shell_semicolon() {
11457        // Cascade pin on the embedded-control-byte arm: a value carrying
11458        // both a control byte and `;` (`"../foo\n;bar"` — the canonical
11459        // paste-from-multiline-doc footgun where a newline landed mid-
11460        // caminho) routes through `FonteCaminhoControlChar` not
11461        // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
11462        // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
11463        // on every value that probes positive for both — mirrors the
11464        // cascade discipline on every prior arm.
11465        let d = dep_with_fonte(DepSource::Path {
11466            caminho: "../foo\n;bar".into(),
11467        });
11468        let err = d.validate().unwrap_err();
11469        assert!(
11470            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11471            "got {err:?}",
11472        );
11473    }
11474
11475    #[test]
11476    fn fonte_caminho_absolute_fires_before_shell_semicolon() {
11477        // Cascade pin on the load-bearing leading-byte arm: a leading
11478        // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
11479        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
11480        // — the host-layout-leak diagnostic is the load-bearing axis,
11481        // the `;` byte is the secondary observation. Same precedence
11482        // logic as every prior leading-byte arm.
11483        let d = dep_with_fonte(DepSource::Path {
11484            caminho: "/etc/passwd;rm".into(),
11485        });
11486        let err = d.validate().unwrap_err();
11487        assert!(
11488            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11489            "got {err:?}",
11490        );
11491    }
11492
11493    #[test]
11494    fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
11495        // Cascade pin on the immediate-successor arm: a value carrying
11496        // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
11497        // "I tab-completed a path that already had a `; cleanup` tail"
11498        // footgun) routes through `FonteCaminhoShellSemicolon` not
11499        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11500        // the more semantic-locating axis (an author who removes the
11501        // `;` typically also drops the trailing separator since both
11502        // are paste-from-shell artifacts).
11503        let d = dep_with_fonte(DepSource::Path {
11504            caminho: "../foo;rm/".into(),
11505        });
11506        let err = d.validate().unwrap_err();
11507        assert!(
11508            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11509            "got {err:?}",
11510        );
11511    }
11512
11513    #[test]
11514    fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
11515        // Diagnostic-shape pin (peer with
11516        // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
11517        // on the closest single-byte peer arm): the error's Display
11518        // surfaces the offending `:nome` and the offending `:caminho`
11519        // verbatim, and names the shell-command-separator footgun
11520        // explicitly so a `feira lint` run can render the diagnostic
11521        // without re-parsing.
11522        let d = dep_with_fonte(DepSource::Path {
11523            caminho: "../caixa-teia; rm -rf build".into(),
11524        });
11525        let rendered = d.validate().unwrap_err().to_string();
11526        assert!(
11527            rendered.contains("caixa-teia"),
11528            "diagnostic must name the offending dep: {rendered}",
11529        );
11530        assert!(
11531            rendered.contains("../caixa-teia; rm -rf build"),
11532            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11533        );
11534        assert!(
11535            rendered.contains(';'),
11536            "diagnostic must reference the semicolon footgun: {rendered:?}",
11537        );
11538        assert!(
11539            rendered.contains("command-separator"),
11540            "diagnostic must name the shell-command-separator footgun: {rendered:?}",
11541        );
11542    }
11543
11544    #[test]
11545    fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
11546        // The fail-before-pass-after pin for the canonical shell-
11547        // background-task paste footgun: an author copies a shell one-
11548        // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
11549        // the whole `cd path & sleep 1` background-launch out of a
11550        // shell-history block") and silently passed every prior arm
11551        // (`Path::is_absolute` false on `..`, no control bytes, no
11552        // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
11553        // The lacre embedded the value verbatim, the resolver folded it
11554        // through `Path::join` looking for a literal `./../caixa-teia &
11555        // sleep 1` subdirectory, and the failure surfaced at resolve
11556        // time with a non-self-locating `No such file or directory`
11557        // error. The new arm moves the rejection to validate time and
11558        // names the offending dep + caminho verbatim.
11559        let d = dep_with_fonte(DepSource::Path {
11560            caminho: "../caixa-teia & sleep 1".into(),
11561        });
11562        let err = d.validate().unwrap_err();
11563        let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
11564            panic!("expected FonteCaminhoShellBackground, got {err:?}");
11565        };
11566        assert_eq!(nome, "caixa-teia");
11567        assert_eq!(caminho, "../caixa-teia & sleep 1");
11568    }
11569
11570    #[test]
11571    fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
11572        // Leading-position `&` shape (`"&../caixa-teia"` — the
11573        // degenerate "I forgot the prior command side of the
11574        // background terminator" idiom). Pinned separately from the
11575        // embedded-byte shape so the gate covers every position, not
11576        // only mid-path.
11577        let d = dep_with_fonte(DepSource::Path {
11578            caminho: "&../caixa-teia".into(),
11579        });
11580        let err = d.validate().unwrap_err();
11581        assert!(
11582            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11583            "got {err:?}",
11584        );
11585    }
11586
11587    #[test]
11588    fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
11589        // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
11590        // canonical "I copied a `cd path && make` build chain" idiom
11591        // every Makefile / shell-script wraps). The arm fires on the
11592        // first `&` encountered; pinned so a future arm that tries to
11593        // distinguish `&` from `&&` doesn't break the broader contract.
11594        let d = dep_with_fonte(DepSource::Path {
11595            caminho: "../caixa-teia && make".into(),
11596        });
11597        let err = d.validate().unwrap_err();
11598        assert!(
11599            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11600            "got {err:?}",
11601        );
11602    }
11603
11604    #[test]
11605    fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
11606        // The positive-control pin: the gate targets only `&`, never
11607        // adjacent printable ASCII or POSIX-valid bytes. The canonical
11608        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11609        // pathed variant with adjacent printable punctuation
11610        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11611        // cleanly so the gate doesn't widen to a "no printable
11612        // punctuation anywhere" sweep that would defeat the entire
11613        // path-fonte author surface.
11614        let d = dep_with_fonte(DepSource::Path {
11615            caminho: "../caixa-teia/sub-dir.v2".into(),
11616        });
11617        d.validate().unwrap();
11618    }
11619
11620    #[test]
11621    fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
11622        // Cascade pin on the immediate-predecessor arm: a value carrying
11623        // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
11624        // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
11625        // routes through `FonteCaminhoShellSemicolon` not
11626        // `FonteCaminhoShellBackground`. The sequential-command-
11627        // separator paste is the more common shell-history paste idiom
11628        // on every probe-as-both value (an author who removes the `;`
11629        // typically also drops the trailing `& sleep` since both are
11630        // paste-from-shell-history artifacts) — same cascade discipline
11631        // every prior `:caminho` arm establishes.
11632        let d = dep_with_fonte(DepSource::Path {
11633            caminho: "../caixa-teia; rm & sleep".into(),
11634        });
11635        let err = d.validate().unwrap_err();
11636        assert!(
11637            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11638            "got {err:?}",
11639        );
11640    }
11641
11642    #[test]
11643    fn fonte_caminho_shell_pipe_fires_before_shell_background() {
11644        // Cascade pin on the upstream shell-pipe arm: a value carrying
11645        // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
11646        // canonical "I pasted a `cmd | tee & sleep` background-pipeline
11647        // chain" footgun) routes through `FonteCaminhoShellPipe` not
11648        // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
11649        // load-bearing root-cause edit on every probe-as-both value.
11650        let d = dep_with_fonte(DepSource::Path {
11651            caminho: "../caixa-teia | tee & sleep".into(),
11652        });
11653        let err = d.validate().unwrap_err();
11654        assert!(
11655            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11656            "got {err:?}",
11657        );
11658    }
11659
11660    #[test]
11661    fn fonte_caminho_shell_redirection_fires_before_shell_background() {
11662        // Cascade pin on the upstream shell-redirection arm: a value
11663        // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
11664        // the canonical "I pasted a `cmd > log & sleep` background-
11665        // redirect chain" footgun) routes through
11666        // `FonteCaminhoShellRedirection` not
11667        // `FonteCaminhoShellBackground`. The input/output redirection
11668        // metachar carries the more self-locating `byte: u8` payload
11669        // (it names which of `<` or `>` triggered), so the prior arm
11670        // wins on every probe-as-both value.
11671        let d = dep_with_fonte(DepSource::Path {
11672            caminho: "../caixa-teia>log & sleep".into(),
11673        });
11674        let err = d.validate().unwrap_err();
11675        assert!(
11676            matches!(
11677                err,
11678                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11679            ),
11680            "got {err:?}",
11681        );
11682    }
11683
11684    #[test]
11685    fn fonte_caminho_backslash_fires_before_shell_background() {
11686        // Cascade pin on the upstream backslash arm: a value carrying
11687        // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
11688        // "I pasted a Windows-shell `cd ..\path & sleep` background-
11689        // launch chain") routes through `FonteCaminhoBackslash` not
11690        // `FonteCaminhoShellBackground`. The cross-host-OS-separator
11691        // divergence is the load-bearing axis on every probe-as-both
11692        // value (an author who removes the `\` is the root-cause edit;
11693        // the `&` falls away in the same edit since it's downstream of
11694        // the Windows-shell convention).
11695        let d = dep_with_fonte(DepSource::Path {
11696            caminho: "..\\caixa-teia & sleep".into(),
11697        });
11698        let err = d.validate().unwrap_err();
11699        assert!(
11700            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11701            "got {err:?}",
11702        );
11703    }
11704
11705    #[test]
11706    fn fonte_caminho_control_char_fires_before_shell_background() {
11707        // Cascade pin on the embedded-control-byte arm: a value
11708        // carrying both a control byte and `&` (`"../foo\n&sleep"` —
11709        // the canonical paste-from-multiline-doc footgun where a
11710        // newline landed mid-caminho) routes through
11711        // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
11712        // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11713        // diagnostic is the load-bearing axis on every value that
11714        // probes positive for both — mirrors the cascade discipline on
11715        // every prior arm.
11716        let d = dep_with_fonte(DepSource::Path {
11717            caminho: "../foo\n&sleep".into(),
11718        });
11719        let err = d.validate().unwrap_err();
11720        assert!(
11721            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11722            "got {err:?}",
11723        );
11724    }
11725
11726    #[test]
11727    fn fonte_caminho_absolute_fires_before_shell_background() {
11728        // Cascade pin on the load-bearing leading-byte arm: a leading
11729        // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
11730        // through `FonteCaminhoAbsolute` not
11731        // `FonteCaminhoShellBackground` — the host-layout-leak
11732        // diagnostic is the load-bearing axis, the `&` byte is the
11733        // secondary observation. Same precedence logic as every prior
11734        // leading-byte arm.
11735        let d = dep_with_fonte(DepSource::Path {
11736            caminho: "/etc/passwd & sleep".into(),
11737        });
11738        let err = d.validate().unwrap_err();
11739        assert!(
11740            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11741            "got {err:?}",
11742        );
11743    }
11744
11745    #[test]
11746    fn fonte_caminho_shell_background_fires_before_trailing_slash() {
11747        // Cascade pin on the immediate-successor arm: a value carrying
11748        // both `&` and a trailing `/` (`"../foo&sleep/"` — the
11749        // canonical "I tab-completed a path that already had a `&
11750        // sleep` background-launch tail" footgun) routes through
11751        // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
11752        // The embedded shell-metachar is the more semantic-locating
11753        // axis (an author who removes the `&` typically also drops
11754        // the trailing separator since both are paste-from-shell
11755        // artifacts).
11756        let d = dep_with_fonte(DepSource::Path {
11757            caminho: "../foo&sleep/".into(),
11758        });
11759        let err = d.validate().unwrap_err();
11760        assert!(
11761            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11762            "got {err:?}",
11763        );
11764    }
11765
11766    #[test]
11767    fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
11768        // Diagnostic-shape pin (peer with
11769        // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
11770        // on the closest single-byte peer arm): the error's Display
11771        // surfaces the offending `:nome` and the offending `:caminho`
11772        // verbatim, and names the shell-background / logical-AND
11773        // footgun explicitly so a `feira lint` run can render the
11774        // diagnostic without re-parsing.
11775        let d = dep_with_fonte(DepSource::Path {
11776            caminho: "../caixa-teia & sleep 1".into(),
11777        });
11778        let rendered = d.validate().unwrap_err().to_string();
11779        assert!(
11780            rendered.contains("caixa-teia"),
11781            "diagnostic must name the offending dep: {rendered}",
11782        );
11783        assert!(
11784            rendered.contains("../caixa-teia & sleep 1"),
11785            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11786        );
11787        assert!(
11788            rendered.contains('&'),
11789            "diagnostic must reference the ampersand footgun: {rendered:?}",
11790        );
11791        assert!(
11792            rendered.contains("background") || rendered.contains("list-AND"),
11793            "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
11794        );
11795    }
11796
11797    #[test]
11798    fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
11799        // The fail-before-pass-after pin for the canonical shell-
11800        // command-substitution paste footgun: an author copies a
11801        // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
11802        // — the canonical "I pasted a path that included a `pwd`
11803        // / `whoami` / `date` legacy command-substitution expansion
11804        // out of a shell-history block") and silently passed every
11805        // prior arm (`Path::is_absolute` false on `..`, no control
11806        // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
11807        // end in `/`). The lacre embedded the value verbatim, the
11808        // resolver folded it through `Path::join` looking for a
11809        // literal `./../caixa-teia/`whoami`` subdirectory, and the
11810        // failure surfaced at resolve time with a non-self-locating
11811        // `No such file or directory` error. The new arm moves the
11812        // rejection to validate time and names the offending dep +
11813        // caminho verbatim.
11814        let d = dep_with_fonte(DepSource::Path {
11815            caminho: "../caixa-teia/`whoami`".into(),
11816        });
11817        let err = d.validate().unwrap_err();
11818        let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
11819            panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
11820        };
11821        assert_eq!(nome, "caixa-teia");
11822        assert_eq!(caminho, "../caixa-teia/`whoami`");
11823    }
11824
11825    #[test]
11826    fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
11827        // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
11828        // the canonical `<backtick>pwd<backtick>/path` working-
11829        // directory expansion shape every shell-side path-composition
11830        // idiom carries). Pinned separately from the embedded-byte
11831        // shape so the gate covers every position, not only mid-path.
11832        let d = dep_with_fonte(DepSource::Path {
11833            caminho: "`pwd`/caixa-teia".into(),
11834        });
11835        let err = d.validate().unwrap_err();
11836        assert!(
11837            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11838            "got {err:?}",
11839        );
11840    }
11841
11842    #[test]
11843    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
11844        // Trailing-position backtick shape (`"../caixa-teia`"` — the
11845        // degenerate "I selected an unbalanced backtick out of a
11846        // shell-history block" idiom that probes for the cascade's
11847        // last-byte handling). The trailing-`/` arm fires only on
11848        // last-byte `/`; an unbalanced trailing backtick must route
11849        // through this arm regardless of position.
11850        let d = dep_with_fonte(DepSource::Path {
11851            caminho: "../caixa-teia`".into(),
11852        });
11853        let err = d.validate().unwrap_err();
11854        assert!(
11855            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11856            "got {err:?}",
11857        );
11858    }
11859
11860    #[test]
11861    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
11862        // The canonical balanced-pair shape (``"../<backtick>cat
11863        // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
11864        // command-injection paste idiom every shell-side hardening
11865        // guide enumerates first). The arm fires on the first
11866        // backtick encountered; pinned so a future arm that tries to
11867        // distinguish the opening from the closing byte doesn't break
11868        // the broader contract.
11869        let d = dep_with_fonte(DepSource::Path {
11870            caminho: "../`cat /etc/passwd`".into(),
11871        });
11872        let err = d.validate().unwrap_err();
11873        assert!(
11874            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11875            "got {err:?}",
11876        );
11877    }
11878
11879    #[test]
11880    fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
11881        // The positive-control pin: the gate targets only the
11882        // backtick byte, never adjacent printable ASCII or POSIX-
11883        // valid bytes. The canonical relative POSIX path
11884        // (`"../caixa-teia"`) and a nested deeply-pathed variant with
11885        // adjacent printable punctuation
11886        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11887        // cleanly so the gate doesn't widen to a "no printable
11888        // punctuation anywhere" sweep that would defeat the entire
11889        // path-fonte author surface.
11890        let d = dep_with_fonte(DepSource::Path {
11891            caminho: "../caixa-teia/sub-dir.v2".into(),
11892        });
11893        d.validate().unwrap();
11894    }
11895
11896    #[test]
11897    fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
11898        // Cascade pin on the immediate-predecessor arm: a value
11899        // carrying both `&` and a backtick (``"../caixa-teia &
11900        // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
11901        // `cmd & <backtick>sleep N<backtick>` background-launch +
11902        // command-substitution chain" footgun) routes through
11903        // `FonteCaminhoShellBackground` not
11904        // `FonteCaminhoShellCommandSubstitution`. The background-
11905        // launch tail is the more common shell-history paste idiom
11906        // on every probe-as-both value — same cascade discipline
11907        // every prior `:caminho` arm establishes.
11908        let d = dep_with_fonte(DepSource::Path {
11909            caminho: "../caixa-teia & `sleep 1`".into(),
11910        });
11911        let err = d.validate().unwrap_err();
11912        assert!(
11913            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11914            "got {err:?}",
11915        );
11916    }
11917
11918    #[test]
11919    fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
11920        // Cascade pin on the upstream shell-semicolon arm: a value
11921        // carrying both `;` and a backtick (``"../caixa-teia;
11922        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11923        // `cmd; <backtick>follow-up<backtick>` sequential-chain
11924        // footgun) routes through `FonteCaminhoShellSemicolon` not
11925        // `FonteCaminhoShellCommandSubstitution`. The sequential-
11926        // command-separator paste is the load-bearing root-cause
11927        // edit on every probe-as-both value.
11928        let d = dep_with_fonte(DepSource::Path {
11929            caminho: "../caixa-teia; `whoami`".into(),
11930        });
11931        let err = d.validate().unwrap_err();
11932        assert!(
11933            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11934            "got {err:?}",
11935        );
11936    }
11937
11938    #[test]
11939    fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
11940        // Cascade pin on the upstream shell-pipe arm: a value
11941        // carrying both `|` and a backtick (``"../caixa-teia |
11942        // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
11943        // command-substitution paste idiom) routes through
11944        // `FonteCaminhoShellPipe` not
11945        // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
11946        // paste is the load-bearing root-cause edit on every
11947        // probe-as-both value.
11948        let d = dep_with_fonte(DepSource::Path {
11949            caminho: "../caixa-teia | `tee log`".into(),
11950        });
11951        let err = d.validate().unwrap_err();
11952        assert!(
11953            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11954            "got {err:?}",
11955        );
11956    }
11957
11958    #[test]
11959    fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
11960        // Cascade pin on the upstream shell-redirection arm: a value
11961        // carrying both `>` and a backtick (``"../caixa-teia>log
11962        // <backtick>date<backtick>"`` — the canonical "I pasted a
11963        // `cmd > log <backtick>date<backtick>` redirect-plus-
11964        // substitution chain" footgun) routes through
11965        // `FonteCaminhoShellRedirection` not
11966        // `FonteCaminhoShellCommandSubstitution`. The input/output
11967        // redirection metachar carries the more self-locating `byte`
11968        // payload (it names which of `<` or `>` triggered), so the
11969        // prior arm wins on every probe-as-both value.
11970        let d = dep_with_fonte(DepSource::Path {
11971            caminho: "../caixa-teia>log `date`".into(),
11972        });
11973        let err = d.validate().unwrap_err();
11974        assert!(
11975            matches!(
11976                err,
11977                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11978            ),
11979            "got {err:?}",
11980        );
11981    }
11982
11983    #[test]
11984    fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
11985        // Cascade pin on the upstream backslash arm: a value
11986        // carrying both `\` and a backtick (``"..\caixa-teia
11987        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11988        // Windows-shell `cd ..\path <backtick>whoami<backtick>`
11989        // chain") routes through `FonteCaminhoBackslash` not
11990        // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
11991        // separator divergence is the load-bearing axis on every
11992        // probe-as-both value (an author who removes the `\` is the
11993        // root-cause edit; the backtick falls away in the same edit
11994        // since it's downstream of the Windows-shell convention).
11995        let d = dep_with_fonte(DepSource::Path {
11996            caminho: "..\\caixa-teia `whoami`".into(),
11997        });
11998        let err = d.validate().unwrap_err();
11999        assert!(
12000            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12001            "got {err:?}",
12002        );
12003    }
12004
12005    #[test]
12006    fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
12007        // Cascade pin on the embedded-control-byte arm: a value
12008        // carrying both a control byte and a backtick (`"../foo\n
12009        // `whoami`"` — the canonical paste-from-multiline-doc
12010        // footgun where a newline landed mid-caminho between two
12011        // paste fragments) routes through `FonteCaminhoControlChar`
12012        // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
12013        // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
12014        // is the load-bearing axis on every value that probes
12015        // positive for both — mirrors the cascade discipline on
12016        // every prior arm.
12017        let d = dep_with_fonte(DepSource::Path {
12018            caminho: "../foo\n`whoami`".into(),
12019        });
12020        let err = d.validate().unwrap_err();
12021        assert!(
12022            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12023            "got {err:?}",
12024        );
12025    }
12026
12027    #[test]
12028    fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
12029        // Cascade pin on the load-bearing leading-byte arm: a
12030        // leading `/` value with embedded backtick (``"/etc/passwd
12031        // <backtick>whoami<backtick>"``) routes through
12032        // `FonteCaminhoAbsolute` not
12033        // `FonteCaminhoShellCommandSubstitution` — the host-layout-
12034        // leak diagnostic is the load-bearing axis, the backtick
12035        // byte is the secondary observation. Same precedence logic
12036        // as every prior leading-byte arm.
12037        let d = dep_with_fonte(DepSource::Path {
12038            caminho: "/etc/passwd `whoami`".into(),
12039        });
12040        let err = d.validate().unwrap_err();
12041        assert!(
12042            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12043            "got {err:?}",
12044        );
12045    }
12046
12047    #[test]
12048    fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
12049        // Cascade pin on the immediate-successor arm: a value
12050        // carrying both a backtick and a trailing `/`
12051        // (``"../`whoami`/"`` — the canonical "I tab-completed a
12052        // path that already had a backticked `whoami` substitution
12053        // tail" footgun) routes through
12054        // `FonteCaminhoShellCommandSubstitution` not
12055        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12056        // is the more semantic-locating axis (an author who removes
12057        // the backtick typically also drops the trailing separator
12058        // since both are paste-from-shell artifacts).
12059        let d = dep_with_fonte(DepSource::Path {
12060            caminho: "../`whoami`/".into(),
12061        });
12062        let err = d.validate().unwrap_err();
12063        assert!(
12064            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12065            "got {err:?}",
12066        );
12067    }
12068
12069    #[test]
12070    fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
12071        // Diagnostic-shape pin (peer with
12072        // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
12073        // on the closest single-byte peer arm): the error's Display
12074        // surfaces the offending `:nome` and the offending `:caminho`
12075        // verbatim, and names the shell-command-substitution footgun
12076        // explicitly so a `feira lint` run can render the diagnostic
12077        // without re-parsing.
12078        let d = dep_with_fonte(DepSource::Path {
12079            caminho: "../caixa-teia/`whoami`".into(),
12080        });
12081        let rendered = d.validate().unwrap_err().to_string();
12082        assert!(
12083            rendered.contains("caixa-teia"),
12084            "diagnostic must name the offending dep: {rendered}",
12085        );
12086        assert!(
12087            rendered.contains("../caixa-teia/`whoami`"),
12088            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12089        );
12090        assert!(
12091            rendered.contains('`'),
12092            "diagnostic must reference the backtick footgun: {rendered:?}",
12093        );
12094        assert!(
12095            rendered.contains("command-substitution"),
12096            "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
12097        );
12098    }
12099
12100    #[test]
12101    fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
12102        // The fail-before-pass-after pin for the canonical pathname-
12103        // expansion paste footgun: an author copies an `ls
12104        // ../caixa-teia/*` shell-listing tail into the `:caminho`
12105        // slot and silently passes every prior arm
12106        // (`Path::is_absolute` false on `..`, no control bytes, no
12107        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
12108        // doesn't end in `/`). The lacre embedded the value
12109        // verbatim, the resolver folded it through `Path::join`
12110        // looking for a literal `./../caixa-teia/*` subdirectory,
12111        // and the failure surfaced at resolve time with a non-self-
12112        // locating `No such file or directory` error. The new arm
12113        // moves the rejection to validate time and names the
12114        // offending dep + caminho + byte verbatim.
12115        let d = dep_with_fonte(DepSource::Path {
12116            caminho: "../caixa-teia/*".into(),
12117        });
12118        let err = d.validate().unwrap_err();
12119        let DepError::FonteCaminhoShellGlob {
12120            nome,
12121            caminho,
12122            byte,
12123        } = err
12124        else {
12125            panic!("expected FonteCaminhoShellGlob, got {err:?}");
12126        };
12127        assert_eq!(nome, "caixa-teia");
12128        assert_eq!(caminho, "../caixa-teia/*");
12129        assert_eq!(byte, b'*');
12130    }
12131
12132    #[test]
12133    fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
12134        // The symmetric single-char-wildcard paste shape
12135        // (`"../foo?"` — the canonical "I copied a `rm foo?` line
12136        // out of shell history" idiom). Pinned separately from the
12137        // `*` shape so the gate's contract is "any `*` or `?`
12138        // anywhere", not single-byte coverage.
12139        let d = dep_with_fonte(DepSource::Path {
12140            caminho: "../foo?".into(),
12141        });
12142        let err = d.validate().unwrap_err();
12143        let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
12144            panic!("expected FonteCaminhoShellGlob, got {err:?}");
12145        };
12146        assert_eq!(byte, b'?');
12147    }
12148
12149    #[test]
12150    fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
12151        // Leading-position `*` shape (`"*/caixa-teia"` — the
12152        // degenerate "I selected only the wildcard prefix out of a
12153        // shell-glob expression" idiom). Pinned separately from the
12154        // embedded-byte shapes so the gate covers every position,
12155        // not only mid-path.
12156        let d = dep_with_fonte(DepSource::Path {
12157            caminho: "*/caixa-teia".into(),
12158        });
12159        let err = d.validate().unwrap_err();
12160        assert!(
12161            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12162            "got {err:?}",
12163        );
12164    }
12165
12166    #[test]
12167    fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
12168        // The bash/zsh `globstar` recursive-glob shape
12169        // (`"../caixa-teia/**/foo"` — the canonical "I copied a
12170        // `find ../caixa-teia/**/foo` recursive expansion" idiom).
12171        // The arm fires on the first `*` encountered; pinned so a
12172        // future arm that tries to distinguish single `*` from
12173        // double `**` doesn't break the broader contract.
12174        let d = dep_with_fonte(DepSource::Path {
12175            caminho: "../caixa-teia/**/foo".into(),
12176        });
12177        let err = d.validate().unwrap_err();
12178        assert!(
12179            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12180            "got {err:?}",
12181        );
12182    }
12183
12184    #[test]
12185    fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
12186        // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
12187        // — the "I selected `*.lisp` to mean every Lisp source file
12188        // in the dep root" footgun the prior arms structurally
12189        // cannot catch since `.` is a POSIX-valid path-component
12190        // byte). Pinned so the gate's contract covers the most
12191        // idiomatic glob-paste shape every author meets first.
12192        let d = dep_with_fonte(DepSource::Path {
12193            caminho: "../caixa-teia/*.lisp".into(),
12194        });
12195        let err = d.validate().unwrap_err();
12196        assert!(
12197            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12198            "got {err:?}",
12199        );
12200    }
12201
12202    #[test]
12203    fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
12204        // The positive-control pin: the gate targets only `*` /
12205        // `?`, never adjacent printable ASCII or POSIX-valid bytes.
12206        // The canonical relative POSIX path (`"../caixa-teia"`) and
12207        // a nested deeply-pathed variant with adjacent printable
12208        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12209        // to validate cleanly so the gate doesn't widen to a "no
12210        // printable punctuation anywhere" sweep that would defeat
12211        // the entire path-fonte author surface.
12212        let d = dep_with_fonte(DepSource::Path {
12213            caminho: "../caixa-teia/sub-dir.v2".into(),
12214        });
12215        d.validate().unwrap();
12216    }
12217
12218    #[test]
12219    fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
12220        // Cascade pin on the immediate-predecessor arm: a value
12221        // carrying both a backtick and `*` (``"../`whoami`/*"`` —
12222        // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
12223        // command-substitution + glob chain") routes through
12224        // `FonteCaminhoShellCommandSubstitution` not
12225        // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
12226        // injection vector is the load-bearing root-cause edit on
12227        // every probe-as-both value — same cascade discipline every
12228        // prior `:caminho` arm establishes.
12229        let d = dep_with_fonte(DepSource::Path {
12230            caminho: "../`whoami`/*".into(),
12231        });
12232        let err = d.validate().unwrap_err();
12233        assert!(
12234            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12235            "got {err:?}",
12236        );
12237    }
12238
12239    #[test]
12240    fn fonte_caminho_shell_background_fires_before_shell_glob() {
12241        // Cascade pin on the upstream shell-background arm: a value
12242        // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
12243        // canonical "I pasted a `cmd & ls /*` background + glob
12244        // chain" footgun) routes through `FonteCaminhoShellBackground`
12245        // not `FonteCaminhoShellGlob`. The background-launch tail is
12246        // the load-bearing root-cause edit on every probe-as-both
12247        // value.
12248        let d = dep_with_fonte(DepSource::Path {
12249            caminho: "../caixa-teia & ls /*".into(),
12250        });
12251        let err = d.validate().unwrap_err();
12252        assert!(
12253            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12254            "got {err:?}",
12255        );
12256    }
12257
12258    #[test]
12259    fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
12260        // Cascade pin on the upstream shell-semicolon arm: a value
12261        // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
12262        // canonical sequential-cleanup + glob paste idiom) routes
12263        // through `FonteCaminhoShellSemicolon` not
12264        // `FonteCaminhoShellGlob`. The sequential-command-separator
12265        // paste is the load-bearing root-cause edit on every
12266        // probe-as-both value.
12267        let d = dep_with_fonte(DepSource::Path {
12268            caminho: "../caixa-teia; rm *".into(),
12269        });
12270        let err = d.validate().unwrap_err();
12271        assert!(
12272            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12273            "got {err:?}",
12274        );
12275    }
12276
12277    #[test]
12278    fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
12279        // Cascade pin on the upstream shell-pipe arm: a value
12280        // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
12281        // canonical pipeline-to-glob paste idiom) routes through
12282        // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
12283        // pipeline-tail paste is the load-bearing root-cause edit
12284        // on every probe-as-both value.
12285        let d = dep_with_fonte(DepSource::Path {
12286            caminho: "../caixa-teia | ls *".into(),
12287        });
12288        let err = d.validate().unwrap_err();
12289        assert!(
12290            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12291            "got {err:?}",
12292        );
12293    }
12294
12295    #[test]
12296    fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
12297        // Cascade pin on the upstream shell-redirection arm: a value
12298        // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
12299        // canonical "I pasted a `cmd > log *` redirect-plus-glob
12300        // chain" footgun) routes through
12301        // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
12302        // The input/output redirection metachar carries the more
12303        // self-locating `byte` payload (it names which of `<` or `>`
12304        // triggered), so the prior arm wins on every probe-as-both
12305        // value.
12306        let d = dep_with_fonte(DepSource::Path {
12307            caminho: "../caixa-teia>log *".into(),
12308        });
12309        let err = d.validate().unwrap_err();
12310        assert!(
12311            matches!(
12312                err,
12313                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12314            ),
12315            "got {err:?}",
12316        );
12317    }
12318
12319    #[test]
12320    fn fonte_caminho_backslash_fires_before_shell_glob() {
12321        // Cascade pin on the upstream backslash arm: a value
12322        // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
12323        // canonical "I pasted a Windows-shell `cd ..\path\*` glob
12324        // expression" footgun) routes through
12325        // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
12326        // cross-host-OS-separator divergence is the load-bearing
12327        // axis on every probe-as-both value (an author who removes
12328        // the `\` is the root-cause edit; the `*` falls away in the
12329        // same edit since it's downstream of the Windows-shell
12330        // convention).
12331        let d = dep_with_fonte(DepSource::Path {
12332            caminho: "..\\caixa-teia\\*".into(),
12333        });
12334        let err = d.validate().unwrap_err();
12335        assert!(
12336            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12337            "got {err:?}",
12338        );
12339    }
12340
12341    #[test]
12342    fn fonte_caminho_control_char_fires_before_shell_glob() {
12343        // Cascade pin on the embedded-control-byte arm: a value
12344        // carrying both a control byte and `*` (`"../foo\n*"` — the
12345        // canonical paste-from-multiline-doc footgun where a
12346        // newline landed mid-caminho between two paste fragments)
12347        // routes through `FonteCaminhoControlChar` not
12348        // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
12349        // NUL-`CString::new`-fail diagnostic is the load-bearing
12350        // axis on every value that probes positive for both —
12351        // mirrors the cascade discipline on every prior arm.
12352        let d = dep_with_fonte(DepSource::Path {
12353            caminho: "../foo\n*".into(),
12354        });
12355        let err = d.validate().unwrap_err();
12356        assert!(
12357            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12358            "got {err:?}",
12359        );
12360    }
12361
12362    #[test]
12363    fn fonte_caminho_absolute_fires_before_shell_glob() {
12364        // Cascade pin on the load-bearing leading-byte arm: a
12365        // leading `/` value with embedded `*` (`"/etc/*"`) routes
12366        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
12367        // — the host-layout-leak diagnostic is the load-bearing
12368        // axis, the glob byte is the secondary observation. Same
12369        // precedence logic as every prior leading-byte arm.
12370        let d = dep_with_fonte(DepSource::Path {
12371            caminho: "/etc/*".into(),
12372        });
12373        let err = d.validate().unwrap_err();
12374        assert!(
12375            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12376            "got {err:?}",
12377        );
12378    }
12379
12380    #[test]
12381    fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
12382        // Cascade pin on the immediate-successor arm: a value
12383        // carrying both `*` and a trailing `/` (`"../foo*/"` — the
12384        // canonical "I tab-completed a path that already had a
12385        // glob-expansion tail" footgun) routes through
12386        // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
12387        // The embedded shell-metachar is the more semantic-locating
12388        // axis (an author who removes the `*` typically also drops
12389        // the trailing separator since both are paste-from-shell
12390        // artifacts).
12391        let d = dep_with_fonte(DepSource::Path {
12392            caminho: "../foo*/".into(),
12393        });
12394        let err = d.validate().unwrap_err();
12395        assert!(
12396            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12397            "got {err:?}",
12398        );
12399    }
12400
12401    #[test]
12402    fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
12403        // Diagnostic-shape pin (peer with
12404        // `fonte_caminho_shell_redirection_diagnostic_*` on the
12405        // closest two-byte peer arm): the error's Display surfaces
12406        // the offending `:nome`, the offending `:caminho` verbatim,
12407        // the offending byte's hex / character form, and names the
12408        // shell-glob / pathname-expansion footgun explicitly so a
12409        // `feira lint` run can render the diagnostic without
12410        // re-parsing.
12411        let d = dep_with_fonte(DepSource::Path {
12412            caminho: "../caixa-teia/*.lisp".into(),
12413        });
12414        let rendered = d.validate().unwrap_err().to_string();
12415        assert!(
12416            rendered.contains("caixa-teia"),
12417            "diagnostic must name the offending dep: {rendered}",
12418        );
12419        assert!(
12420            rendered.contains("../caixa-teia/*.lisp"),
12421            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12422        );
12423        assert!(
12424            rendered.contains("0x2a"),
12425            "diagnostic must surface the offending byte hex: {rendered:?}",
12426        );
12427        assert!(
12428            rendered.contains("glob"),
12429            "diagnostic must name the shell-glob footgun: {rendered:?}",
12430        );
12431        assert!(
12432            rendered.contains("pathname-expansion"),
12433            "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
12434        );
12435    }
12436
12437    #[test]
12438    fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
12439        // The fail-before-pass-after pin for the canonical modern-Bourne
12440        // command-substitution paste footgun: an author copies a
12441        // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
12442        // `$(<cmd>)` expansion would land the current date as a
12443        // subdirectory name and silently passed every prior arm
12444        // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
12445        // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
12446        // `?`, doesn't end in `/`; the leading-`$` f4efe9c
12447        // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
12448        // sits mid-path). The lacre embedded the value verbatim, the
12449        // resolver folded it through `Path::join` looking for a literal
12450        // `./../caixa-teia/$(date)/build` subdirectory, and the failure
12451        // surfaced at resolve time with a non-self-locating `No such
12452        // file or directory` error. The new arm moves the rejection to
12453        // validate time and names the offending dep + caminho + byte
12454        // verbatim. The arm fires on the first `(` encountered (the
12455        // opening byte of `$(date)`).
12456        let d = dep_with_fonte(DepSource::Path {
12457            caminho: "../caixa-teia/$(date)/build".into(),
12458        });
12459        let err = d.validate().unwrap_err();
12460        let DepError::FonteCaminhoShellSubshellGrouping {
12461            nome,
12462            caminho,
12463            byte,
12464        } = err
12465        else {
12466            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12467        };
12468        assert_eq!(nome, "caixa-teia");
12469        assert_eq!(caminho, "../caixa-teia/$(date)/build");
12470        assert_eq!(byte, b'(');
12471    }
12472
12473    #[test]
12474    fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
12475        // The symmetric close-paren paste shape (`"../caixa-teia)"` —
12476        // the degenerate "I selected an unbalanced closing paren out of
12477        // a shell-history block" idiom that probes for the cascade's
12478        // last-byte handling on a value carrying only the closing byte).
12479        // Pinned separately from the open-paren shape so the gate's
12480        // contract is "any `(` or `)` anywhere", not single-byte
12481        // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
12482        // caminho_carrying_question_glob` shape on the immediate-
12483        // predecessor `FonteCaminhoShellGlob` arm.
12484        let d = dep_with_fonte(DepSource::Path {
12485            caminho: "../caixa-teia)".into(),
12486        });
12487        let err = d.validate().unwrap_err();
12488        let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
12489            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12490        };
12491        assert_eq!(byte, b')');
12492    }
12493
12494    #[test]
12495    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
12496        // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
12497        // canonical "I selected a `(cd foo)` subshell-grouping prefix
12498        // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
12499        // Pinned separately from the embedded-byte shape so the gate
12500        // covers every position, not only mid-path.
12501        let d = dep_with_fonte(DepSource::Path {
12502            caminho: "(cd foo)/caixa-teia".into(),
12503        });
12504        let err = d.validate().unwrap_err();
12505        assert!(
12506            matches!(
12507                err,
12508                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12509            ),
12510            "got {err:?}",
12511        );
12512    }
12513
12514    #[test]
12515    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
12516        // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
12517        // — the canonical "I copied a `(pwd)` working-directory-probe
12518        // subshell-grouping idiom every shell-history block carries"
12519        // footgun). The value carries no other cascade-preceding
12520        // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
12521        // `*` / `?`) so the arm fires on the first `(` encountered;
12522        // pinned so a future arm that tries to distinguish the
12523        // opening from the closing byte doesn't break the broader
12524        // contract. Mirrors the peer
12525        // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
12526        // backtick_pair` shape on the upstream `FonteCaminhoShell\
12527        // CommandSubstitution` arm.
12528        let d = dep_with_fonte(DepSource::Path {
12529            caminho: "../(pwd)/caixa-teia".into(),
12530        });
12531        let err = d.validate().unwrap_err();
12532        assert!(
12533            matches!(
12534                err,
12535                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12536            ),
12537            "got {err:?}",
12538        );
12539    }
12540
12541    #[test]
12542    fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
12543        // The positive-control pin: the gate targets only `(` / `)`,
12544        // never adjacent printable ASCII or POSIX-valid bytes. The
12545        // canonical relative POSIX path (`"../caixa-teia"`) and a
12546        // nested deeply-pathed variant with adjacent printable
12547        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12548        // validate cleanly so the gate doesn't widen to a "no printable
12549        // punctuation anywhere" sweep that would defeat the entire
12550        // path-fonte author surface.
12551        let d = dep_with_fonte(DepSource::Path {
12552            caminho: "../caixa-teia/sub-dir.v2".into(),
12553        });
12554        d.validate().unwrap();
12555    }
12556
12557    #[test]
12558    fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
12559        // Cascade pin on the immediate-predecessor arm: a value
12560        // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
12561        // canonical "I pasted a glob expansion followed by a
12562        // subshell-grouping tail" footgun) routes through
12563        // `FonteCaminhoShellGlob` not
12564        // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
12565        // shape is the more common shell-history paste idiom on every
12566        // probe-as-both value — same cascade discipline every prior
12567        // `:caminho` arm establishes.
12568        let d = dep_with_fonte(DepSource::Path {
12569            caminho: "../caixa-teia/*(date)".into(),
12570        });
12571        let err = d.validate().unwrap_err();
12572        assert!(
12573            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12574            "got {err:?}",
12575        );
12576    }
12577
12578    #[test]
12579    fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
12580        // Cascade pin on the upstream shell-command-substitution arm: a
12581        // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
12582        // — the canonical "I pasted a legacy-backtick + modern-paren
12583        // command-substitution chain" footgun) routes through
12584        // `FonteCaminhoShellCommandSubstitution` not
12585        // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
12586        // command-injection vector is the load-bearing root-cause edit
12587        // on every probe-as-both value.
12588        let d = dep_with_fonte(DepSource::Path {
12589            caminho: "../`whoami`/$(date)".into(),
12590        });
12591        let err = d.validate().unwrap_err();
12592        assert!(
12593            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12594            "got {err:?}",
12595        );
12596    }
12597
12598    #[test]
12599    fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
12600        // Cascade pin on the upstream shell-background arm: a value
12601        // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
12602        // the canonical "I pasted a `cmd & (cd foo)` background-launch
12603        // + subshell-grouping chain" footgun) routes through
12604        // `FonteCaminhoShellBackground` not
12605        // `FonteCaminhoShellSubshellGrouping`. The background-launch
12606        // tail is the load-bearing root-cause edit on every probe-as-
12607        // both value.
12608        let d = dep_with_fonte(DepSource::Path {
12609            caminho: "../caixa-teia & (cd foo)".into(),
12610        });
12611        let err = d.validate().unwrap_err();
12612        assert!(
12613            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12614            "got {err:?}",
12615        );
12616    }
12617
12618    #[test]
12619    fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
12620        // Cascade pin on the upstream shell-semicolon arm: a value
12621        // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
12622        // the canonical sequential-cleanup + subshell-grouping paste
12623        // idiom) routes through `FonteCaminhoShellSemicolon` not
12624        // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
12625        // separator paste is the load-bearing root-cause edit on
12626        // every probe-as-both value.
12627        let d = dep_with_fonte(DepSource::Path {
12628            caminho: "../caixa-teia; (cd foo)".into(),
12629        });
12630        let err = d.validate().unwrap_err();
12631        assert!(
12632            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12633            "got {err:?}",
12634        );
12635    }
12636
12637    #[test]
12638    fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
12639        // Cascade pin on the upstream shell-pipe arm: a value carrying
12640        // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
12641        // canonical pipeline-to-subshell-grouping paste idiom) routes
12642        // through `FonteCaminhoShellPipe` not
12643        // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
12644        // is the load-bearing root-cause edit on every probe-as-both
12645        // value.
12646        let d = dep_with_fonte(DepSource::Path {
12647            caminho: "../caixa-teia | (tee log)".into(),
12648        });
12649        let err = d.validate().unwrap_err();
12650        assert!(
12651            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12652            "got {err:?}",
12653        );
12654    }
12655
12656    #[test]
12657    fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
12658        // Cascade pin on the upstream shell-redirection arm: a value
12659        // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
12660        // the canonical "I pasted a `cmd > log (cd foo)` redirect-
12661        // plus-subshell-grouping chain" footgun) routes through
12662        // `FonteCaminhoShellRedirection` not
12663        // `FonteCaminhoShellSubshellGrouping`. The input/output
12664        // redirection metachar carries the more self-locating `byte`
12665        // payload (it names which of `<` or `>` triggered), so the
12666        // prior arm wins on every probe-as-both value.
12667        let d = dep_with_fonte(DepSource::Path {
12668            caminho: "../caixa-teia>log (cd foo)".into(),
12669        });
12670        let err = d.validate().unwrap_err();
12671        assert!(
12672            matches!(
12673                err,
12674                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12675            ),
12676            "got {err:?}",
12677        );
12678    }
12679
12680    #[test]
12681    fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
12682        // Cascade pin on the upstream backslash arm: a value carrying
12683        // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
12684        // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
12685        // through `FonteCaminhoBackslash` not
12686        // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
12687        // separator divergence is the load-bearing axis on every
12688        // probe-as-both value (an author who removes the `\` is the
12689        // root-cause edit; the `(` falls away in the same edit since
12690        // it's downstream of the Windows-shell convention).
12691        let d = dep_with_fonte(DepSource::Path {
12692            caminho: "..\\caixa-teia\\(cd foo)".into(),
12693        });
12694        let err = d.validate().unwrap_err();
12695        assert!(
12696            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12697            "got {err:?}",
12698        );
12699    }
12700
12701    #[test]
12702    fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
12703        // Cascade pin on the embedded-control-byte arm: a value
12704        // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
12705        // the canonical paste-from-multiline-doc footgun where a
12706        // newline landed mid-caminho between two paste fragments)
12707        // routes through `FonteCaminhoControlChar` not
12708        // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
12709        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12710        // load-bearing axis on every value that probes positive for
12711        // both — mirrors the cascade discipline on every prior arm.
12712        let d = dep_with_fonte(DepSource::Path {
12713            caminho: "../foo\n(cd bar)".into(),
12714        });
12715        let err = d.validate().unwrap_err();
12716        assert!(
12717            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12718            "got {err:?}",
12719        );
12720    }
12721
12722    #[test]
12723    fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
12724        // Cascade pin on the load-bearing leading-byte arm: a leading
12725        // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
12726        // through `FonteCaminhoAbsolute` not
12727        // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
12728        // diagnostic is the load-bearing axis, the subshell-grouping
12729        // byte is the secondary observation. Same precedence logic as
12730        // every prior leading-byte arm.
12731        let d = dep_with_fonte(DepSource::Path {
12732            caminho: "/etc/(cd foo)".into(),
12733        });
12734        let err = d.validate().unwrap_err();
12735        assert!(
12736            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12737            "got {err:?}",
12738        );
12739    }
12740
12741    #[test]
12742    fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
12743        // Cascade pin on the upstream leading-`$` var-expansion arm: a
12744        // value carrying both a leading `$` and a `(` (`"$(date)/\
12745        // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
12746        // command-substitution at the head of a sibling-workspace
12747        // path" footgun) routes through `FonteCaminhoVarExpansion` not
12748        // `FonteCaminhoShellSubshellGrouping`. The leading-byte
12749        // shell-variable-expansion is the more self-locating diagnostic
12750        // on values that probe as both — same load-bearing-leading-
12751        // byte cascade discipline every prior `:caminho` arm
12752        // establishes. Closing both halves of `$(<cmd>)` structurally
12753        // (leading `$` here, trailing `)` on the new arm) excludes the
12754        // entire modern Bourne command-substitution surface from the
12755        // typed `:caminho` accepted set; the cascade preserves the
12756        // narrower leading-byte diagnostic on values that probe both
12757        // halves at the canonical leading position.
12758        let d = dep_with_fonte(DepSource::Path {
12759            caminho: "$(date)/caixa-teia".into(),
12760        });
12761        let err = d.validate().unwrap_err();
12762        assert!(
12763            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12764            "got {err:?}",
12765        );
12766    }
12767
12768    #[test]
12769    fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
12770        // Cascade pin on the immediate-successor arm: a value carrying
12771        // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
12772        // "I tab-completed a path that already had a subshell-grouping
12773        // expansion tail" footgun) routes through
12774        // `FonteCaminhoShellSubshellGrouping` not
12775        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
12776        // the more semantic-locating axis (an author who removes the
12777        // `(` typically also drops the trailing separator since both
12778        // are paste-from-shell artifacts).
12779        let d = dep_with_fonte(DepSource::Path {
12780            caminho: "../(cd foo)/".into(),
12781        });
12782        let err = d.validate().unwrap_err();
12783        assert!(
12784            matches!(
12785                err,
12786                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12787            ),
12788            "got {err:?}",
12789        );
12790    }
12791
12792    #[test]
12793    fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12794        // Diagnostic-shape pin (peer with
12795        // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
12796        // on the closest two-byte peer arm): the error's Display
12797        // surfaces the offending `:nome`, the offending `:caminho`
12798        // verbatim, the offending byte's hex / character form, and
12799        // names the shell-subshell-grouping footgun explicitly so a
12800        // `feira lint` run can render the diagnostic without re-
12801        // parsing.
12802        let d = dep_with_fonte(DepSource::Path {
12803            caminho: "../caixa-teia/$(date)/build".into(),
12804        });
12805        let rendered = d.validate().unwrap_err().to_string();
12806        assert!(
12807            rendered.contains("caixa-teia"),
12808            "diagnostic must name the offending dep: {rendered}",
12809        );
12810        assert!(
12811            rendered.contains("../caixa-teia/$(date)/build"),
12812            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12813        );
12814        assert!(
12815            rendered.contains("0x28"),
12816            "diagnostic must surface the offending byte hex: {rendered:?}",
12817        );
12818        assert!(
12819            rendered.contains("subshell-grouping"),
12820            "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
12821        );
12822        assert!(
12823            rendered.contains("command-substitution"),
12824            "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
12825             {rendered:?}",
12826        );
12827    }
12828
12829    // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
12830    //
12831    // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
12832    // `)`) byte-pair arm: the same per-byte cascade with the same
12833    // self-locating `byte: u8` diagnostic on the orthogonal `{` /
12834    // `}` brace-expansion / URI-Template placeholder axis. The peer
12835    // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
12836    // byte pair on the sibling `:fonte :repo` axis under the same
12837    // banner.
12838
12839    #[test]
12840    fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
12841        // The fail-before-pass-after pin for the canonical paste-from-
12842        // shell-history brace-expansion footgun: an author copies a
12843        // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
12844        // liner whose `{a,b}` brace expansion fans across two siblings
12845        // and silently passed every prior arm (`Path::is_absolute`
12846        // false on `..`, no control bytes, no `\`, no `<` / `>`, no
12847        // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
12848        // `)`, doesn't end in `/`; the leading-`$` f4efe9c
12849        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12850        // value starts with `..` not `$`). The lacre embedded the
12851        // value verbatim, the resolver folded it through `Path::join`
12852        // looking for a literal `./../{caixa-teia,caixa-helm}/build`
12853        // subdirectory, and the failure surfaced at resolve time with
12854        // a non-self-locating `No such file or directory` error. The
12855        // new arm moves the rejection to validate time and names the
12856        // offending dep + caminho + byte verbatim. The arm fires on
12857        // the first `{` encountered.
12858        let d = dep_with_fonte(DepSource::Path {
12859            caminho: "../{caixa-teia,caixa-helm}/build".into(),
12860        });
12861        let err = d.validate().unwrap_err();
12862        let DepError::FonteCaminhoShellBraceExpansion {
12863            nome,
12864            caminho,
12865            byte,
12866        } = err
12867        else {
12868            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12869        };
12870        assert_eq!(nome, "caixa-teia");
12871        assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
12872        assert_eq!(byte, b'{');
12873    }
12874
12875    #[test]
12876    fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
12877        // The symmetric close-brace paste shape (`"../caixa-teia}"` —
12878        // the degenerate "I selected an unbalanced closing brace out
12879        // of a shell-history block" idiom that probes for the
12880        // cascade's last-byte handling on a value carrying only the
12881        // closing byte). Pinned separately from the open-brace shape
12882        // so the gate's contract is "any `{` or `}` anywhere", not
12883        // single-byte coverage. Mirrors the peer
12884        // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
12885        // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
12886        // arm.
12887        let d = dep_with_fonte(DepSource::Path {
12888            caminho: "../caixa-teia}".into(),
12889        });
12890        let err = d.validate().unwrap_err();
12891        let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
12892            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12893        };
12894        assert_eq!(byte, b'}');
12895    }
12896
12897    #[test]
12898    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
12899        // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
12900        // — the canonical "I selected a `{a,b}` brace-expansion prefix
12901        // out of a shell-history one-liner" idiom). Pinned separately
12902        // from the embedded-byte shape so the gate covers every
12903        // position, not only mid-path.
12904        let d = dep_with_fonte(DepSource::Path {
12905            caminho: "{caixa-teia,caixa-helm}/build".into(),
12906        });
12907        let err = d.validate().unwrap_err();
12908        assert!(
12909            matches!(
12910                err,
12911                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12912            ),
12913            "got {err:?}",
12914        );
12915    }
12916
12917    #[test]
12918    fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
12919        // The canonical URI-Template / Mustache / Helm doubled-brace
12920        // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
12921        // "I copied a `https://github.com/{{org}}/caixa-teia` README
12922        // quick-start / OpenAPI spec / Helm chart `home:` template
12923        // and forgot to substitute the placeholder" footgun). The arm
12924        // fires on the first `{` encountered; pinned so the gate's
12925        // coverage extends from the bare-brace shell-history shape to
12926        // the doubled-brace URI-Template / templating-engine shape.
12927        // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
12928        // sibling `:fonte :repo` axis.
12929        let d = dep_with_fonte(DepSource::Path {
12930            caminho: "../{{org}}/caixa-teia".into(),
12931        });
12932        let err = d.validate().unwrap_err();
12933        assert!(
12934            matches!(
12935                err,
12936                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12937            ),
12938            "got {err:?}",
12939        );
12940    }
12941
12942    #[test]
12943    fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
12944        // The canonical bash brace-range-expansion shape (`"../caixa-
12945        // v{1..10}"` — the `{1..10}` sequence expansion every bash /
12946        // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
12947        // sequence-range form to the `{a,b,c}` comma-separated form).
12948        // The arm fires on the first `{` encountered; pinned so the
12949        // gate's coverage extends from the comma-separated form to
12950        // the integer-range form.
12951        let d = dep_with_fonte(DepSource::Path {
12952            caminho: "../caixa-v{1..10}".into(),
12953        });
12954        let err = d.validate().unwrap_err();
12955        assert!(
12956            matches!(
12957                err,
12958                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12959            ),
12960            "got {err:?}",
12961        );
12962    }
12963
12964    #[test]
12965    fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
12966        // The positive-control pin: the gate targets only `{` / `}`,
12967        // never adjacent printable ASCII or POSIX-valid bytes. The
12968        // canonical relative POSIX path (`"../caixa-teia"`) and a
12969        // nested deeply-pathed variant with adjacent printable
12970        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12971        // validate cleanly so the gate doesn't widen to a "no
12972        // printable punctuation anywhere" sweep that would defeat
12973        // the entire path-fonte author surface. Peer with
12974        // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
12975        // on the immediate-predecessor arm.
12976        let d = dep_with_fonte(DepSource::Path {
12977            caminho: "../caixa-teia/sub-dir.v2".into(),
12978        });
12979        d.validate().unwrap();
12980    }
12981
12982    #[test]
12983    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
12984        // Cascade pin on the immediate-predecessor arm: a value
12985        // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
12986        // canonical "I pasted a subshell-grouping followed by a
12987        // brace-expansion tail" footgun) routes through
12988        // `FonteCaminhoShellSubshellGrouping` not
12989        // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
12990        // shape is the more semantic-locating axis on every probe-
12991        // as-both value because it closes both halves of the modern
12992        // Bourne `$(<cmd>)` command-substitution surface — same
12993        // cascade discipline every prior `:caminho` arm establishes.
12994        let d = dep_with_fonte(DepSource::Path {
12995            caminho: "../(cd foo)/{a,b}".into(),
12996        });
12997        let err = d.validate().unwrap_err();
12998        assert!(
12999            matches!(
13000                err,
13001                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13002            ),
13003            "got {err:?}",
13004        );
13005    }
13006
13007    #[test]
13008    fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
13009        // Cascade pin on the upstream shell-glob arm: a value carrying
13010        // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
13011        // "I pasted a glob expansion followed by a brace-expansion
13012        // tail" footgun) routes through `FonteCaminhoShellGlob` not
13013        // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
13014        // shape is the load-bearing root-cause edit on every
13015        // probe-as-both value.
13016        let d = dep_with_fonte(DepSource::Path {
13017            caminho: "../caixa-teia/*{a,b}".into(),
13018        });
13019        let err = d.validate().unwrap_err();
13020        assert!(
13021            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13022            "got {err:?}",
13023        );
13024    }
13025
13026    #[test]
13027    fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
13028        // Cascade pin on the upstream shell-command-substitution arm:
13029        // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
13030        // — the canonical "I pasted a legacy-backtick command-
13031        // substitution followed by a brace-expansion fan-out" footgun)
13032        // routes through `FonteCaminhoShellCommandSubstitution` not
13033        // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
13034        // command-injection vector is the load-bearing root-cause
13035        // edit on every probe-as-both value.
13036        let d = dep_with_fonte(DepSource::Path {
13037            caminho: "../`whoami`/{a,b}".into(),
13038        });
13039        let err = d.validate().unwrap_err();
13040        assert!(
13041            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13042            "got {err:?}",
13043        );
13044    }
13045
13046    #[test]
13047    fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
13048        // Cascade pin on the upstream shell-background arm: a value
13049        // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
13050        // canonical "I pasted a `cmd & {fork-fan}` background-launch
13051        // + brace-expansion chain" footgun) routes through
13052        // `FonteCaminhoShellBackground` not
13053        // `FonteCaminhoShellBraceExpansion`. The background-launch
13054        // tail is the load-bearing root-cause edit on every
13055        // probe-as-both value.
13056        let d = dep_with_fonte(DepSource::Path {
13057            caminho: "../caixa-teia & {a,b}".into(),
13058        });
13059        let err = d.validate().unwrap_err();
13060        assert!(
13061            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13062            "got {err:?}",
13063        );
13064    }
13065
13066    #[test]
13067    fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
13068        // Cascade pin on the upstream shell-semicolon arm: a value
13069        // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
13070        // canonical sequential-cleanup + brace-expansion paste
13071        // idiom) routes through `FonteCaminhoShellSemicolon` not
13072        // `FonteCaminhoShellBraceExpansion`. The sequential-command-
13073        // separator paste is the load-bearing root-cause edit on
13074        // every probe-as-both value.
13075        let d = dep_with_fonte(DepSource::Path {
13076            caminho: "../caixa-teia; {a,b}".into(),
13077        });
13078        let err = d.validate().unwrap_err();
13079        assert!(
13080            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13081            "got {err:?}",
13082        );
13083    }
13084
13085    #[test]
13086    fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
13087        // Cascade pin on the upstream shell-pipe arm: a value
13088        // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
13089        // — the canonical pipeline-to-brace-expansion paste idiom)
13090        // routes through `FonteCaminhoShellPipe` not
13091        // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
13092        // is the load-bearing root-cause edit on every probe-as-
13093        // both value.
13094        let d = dep_with_fonte(DepSource::Path {
13095            caminho: "../caixa-teia | {tee,cat}".into(),
13096        });
13097        let err = d.validate().unwrap_err();
13098        assert!(
13099            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13100            "got {err:?}",
13101        );
13102    }
13103
13104    #[test]
13105    fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
13106        // Cascade pin on the upstream shell-redirection arm: a value
13107        // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
13108        // the canonical "I pasted a `cmd > log {a,b}` redirect-
13109        // plus-brace-expansion chain" footgun) routes through
13110        // `FonteCaminhoShellRedirection` not
13111        // `FonteCaminhoShellBraceExpansion`. The input/output
13112        // redirection metachar carries the more self-locating
13113        // `byte` payload, so the prior arm wins on every probe-
13114        // as-both value.
13115        let d = dep_with_fonte(DepSource::Path {
13116            caminho: "../caixa-teia>log {a,b}".into(),
13117        });
13118        let err = d.validate().unwrap_err();
13119        assert!(
13120            matches!(
13121                err,
13122                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13123            ),
13124            "got {err:?}",
13125        );
13126    }
13127
13128    #[test]
13129    fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
13130        // Cascade pin on the upstream backslash arm: a value
13131        // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
13132        // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
13133        // chain") routes through `FonteCaminhoBackslash` not
13134        // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
13135        // separator divergence is the load-bearing axis on every
13136        // probe-as-both value.
13137        let d = dep_with_fonte(DepSource::Path {
13138            caminho: "..\\caixa-teia\\{a,b}".into(),
13139        });
13140        let err = d.validate().unwrap_err();
13141        assert!(
13142            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13143            "got {err:?}",
13144        );
13145    }
13146
13147    #[test]
13148    fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
13149        // Cascade pin on the embedded-control-byte arm: a value
13150        // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
13151        // the canonical paste-from-multiline-doc footgun where a
13152        // newline landed mid-caminho between two paste fragments)
13153        // routes through `FonteCaminhoControlChar` not
13154        // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
13155        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
13156        // load-bearing axis on every value that probes positive for
13157        // both — mirrors the cascade discipline on every prior arm.
13158        let d = dep_with_fonte(DepSource::Path {
13159            caminho: "../foo\n{a,b}".into(),
13160        });
13161        let err = d.validate().unwrap_err();
13162        assert!(
13163            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13164            "got {err:?}",
13165        );
13166    }
13167
13168    #[test]
13169    fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
13170        // Cascade pin on the load-bearing leading-byte arm: a
13171        // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
13172        // routes through `FonteCaminhoAbsolute` not
13173        // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
13174        // diagnostic is the load-bearing axis, the brace-expansion
13175        // byte is the secondary observation. Same precedence logic
13176        // as every prior leading-byte arm.
13177        let d = dep_with_fonte(DepSource::Path {
13178            caminho: "/etc/{a,b}".into(),
13179        });
13180        let err = d.validate().unwrap_err();
13181        assert!(
13182            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13183            "got {err:?}",
13184        );
13185    }
13186
13187    #[test]
13188    fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
13189        // Cascade pin on the upstream leading-`$` var-expansion
13190        // arm: a value carrying both a leading `$` and a `{`
13191        // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
13192        // `${ORG}` shell-variable + curly-brace expansion at the
13193        // head of a sibling-workspace path" footgun) routes through
13194        // `FonteCaminhoVarExpansion` not
13195        // `FonteCaminhoShellBraceExpansion`. The leading-byte
13196        // shell-variable-expansion is the more self-locating
13197        // diagnostic on values that probe as both — same
13198        // load-bearing-leading-byte cascade discipline every prior
13199        // `:caminho` arm establishes.
13200        let d = dep_with_fonte(DepSource::Path {
13201            caminho: "${ORG}/caixa-teia".into(),
13202        });
13203        let err = d.validate().unwrap_err();
13204        assert!(
13205            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13206            "got {err:?}",
13207        );
13208    }
13209
13210    #[test]
13211    fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
13212        // Cascade pin on the immediate-successor arm: a value
13213        // carrying both `{` and a trailing `/`
13214        // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
13215        // tab-completed a path that already had a brace-expansion
13216        // expansion tail" footgun) routes through
13217        // `FonteCaminhoShellBraceExpansion` not
13218        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13219        // is the more semantic-locating axis (an author who removes
13220        // the `{` typically also drops the trailing separator since
13221        // both are paste-from-shell artifacts).
13222        let d = dep_with_fonte(DepSource::Path {
13223            caminho: "../{caixa-teia,caixa-helm}/".into(),
13224        });
13225        let err = d.validate().unwrap_err();
13226        assert!(
13227            matches!(
13228                err,
13229                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13230            ),
13231            "got {err:?}",
13232        );
13233    }
13234
13235    #[test]
13236    fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13237        // Diagnostic-shape pin (peer with
13238        // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13239        // on the closest two-byte peer arm): the error's Display
13240        // surfaces the offending `:nome`, the offending `:caminho`
13241        // verbatim, the offending byte's hex / character form, and
13242        // names the shell-brace-expansion / URI-Template footgun
13243        // explicitly so a `feira lint` run can render the diagnostic
13244        // without re-parsing.
13245        let d = dep_with_fonte(DepSource::Path {
13246            caminho: "../{caixa-teia,caixa-helm}/build".into(),
13247        });
13248        let rendered = d.validate().unwrap_err().to_string();
13249        assert!(
13250            rendered.contains("caixa-teia"),
13251            "diagnostic must name the offending dep: {rendered}",
13252        );
13253        assert!(
13254            rendered.contains("../{caixa-teia,caixa-helm}/build"),
13255            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13256        );
13257        assert!(
13258            rendered.contains("0x7b"),
13259            "diagnostic must surface the offending byte hex: {rendered:?}",
13260        );
13261        assert!(
13262            rendered.contains("brace-expansion"),
13263            "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
13264        );
13265        assert!(
13266            rendered.contains("URI Template"),
13267            "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
13268             {rendered:?}",
13269        );
13270    }
13271
13272    #[test]
13273    fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
13274        // The canonical paste-from-shell-history bracket-glob /
13275        // character-class footgun: an author copies a
13276        // `cd ../caixa-[a-z]/build` shell-history one-liner whose
13277        // `[a-z]` POSIX glob character-class matches every lowercase-
13278        // ASCII-suffix sibling caixa directory and silently passed
13279        // every prior arm (`Path::is_absolute` false on `..`, no
13280        // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
13281        // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
13282        // `}`, doesn't end in `/`; the leading-`$` f4efe9c
13283        // `FonteCaminhoVarExpansion` arm doesn't fire because the
13284        // value starts with `..` not `$`). The lacre embedded the
13285        // value verbatim, the resolver folded it through
13286        // `Path::join` looking for a literal `./../caixa-[a-z]/
13287        // build` subdirectory, and the failure surfaced at resolve
13288        // time with a non-self-locating `No such file or directory`
13289        // error. The new arm moves the rejection to validate time
13290        // and names the offending dep + caminho + byte verbatim.
13291        // The arm fires on the first `[` encountered.
13292        let d = dep_with_fonte(DepSource::Path {
13293            caminho: "../caixa-[a-z]/build".into(),
13294        });
13295        let err = d.validate().unwrap_err();
13296        let DepError::FonteCaminhoShellBracketExpansion {
13297            nome,
13298            caminho,
13299            byte,
13300        } = err
13301        else {
13302            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13303        };
13304        assert_eq!(nome, "caixa-teia");
13305        assert_eq!(caminho, "../caixa-[a-z]/build");
13306        assert_eq!(byte, b'[');
13307    }
13308
13309    #[test]
13310    fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
13311        // The symmetric close-bracket paste shape (`"../caixa-teia]"`
13312        // — the degenerate "I selected an unbalanced closing bracket
13313        // out of a glob character-class block" idiom that probes for
13314        // the cascade's last-byte handling on a value carrying only
13315        // the closing byte). Pinned separately from the open-bracket
13316        // shape so the gate's contract is "any `[` or `]` anywhere",
13317        // not single-byte coverage. Mirrors the peer
13318        // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
13319        // shape on the immediate-predecessor
13320        // `FonteCaminhoShellBraceExpansion` arm.
13321        let d = dep_with_fonte(DepSource::Path {
13322            caminho: "../caixa-teia]".into(),
13323        });
13324        let err = d.validate().unwrap_err();
13325        let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
13326            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13327        };
13328        assert_eq!(byte, b']');
13329    }
13330
13331    #[test]
13332    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
13333        // Leading-position `[` shape (`"[caixa-teia]/build"` — the
13334        // canonical "I selected a `[caixa-teia]` TOML-table-header /
13335        // glob-character-class prefix out of an aligned config /
13336        // shell-history one-liner" idiom). Pinned separately from
13337        // the embedded-byte shape so the gate covers every position,
13338        // not only mid-path.
13339        let d = dep_with_fonte(DepSource::Path {
13340            caminho: "[caixa-teia]/build".into(),
13341        });
13342        let err = d.validate().unwrap_err();
13343        assert!(
13344            matches!(
13345                err,
13346                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13347            ),
13348            "got {err:?}",
13349        );
13350    }
13351
13352    #[test]
13353    fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
13354        // The canonical TOML inline-array / YAML flow-sequence
13355        // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
13356        // canonical "I copied a `features = [\"a\", \"b\"]` TOML
13357        // inline-array out of a sibling-Cargo manifest" cross-idiom
13358        // leak; the symmetric YAML flow-sequence form `paths: [/a,
13359        // /b]` paste-from-values.yaml shape carries the same
13360        // bracket pair). The arm fires on the first `[` encountered;
13361        // pinned so the gate's coverage extends from the bare-
13362        // bracket glob-character-class shape to the TOML / YAML /
13363        // JSON array-literal shape.
13364        let d = dep_with_fonte(DepSource::Path {
13365            caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
13366        });
13367        let err = d.validate().unwrap_err();
13368        assert!(
13369            matches!(
13370                err,
13371                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13372            ),
13373            "got {err:?}",
13374        );
13375    }
13376
13377    #[test]
13378    fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
13379        // The canonical POSIX `test` / `[` builtin command paste
13380        // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
13381        // script conditional every paste-from-shell-script idiom
13382        // carries; bash's `[[ <expr> ]]` extended-test grammar
13383        // would surface the same byte pair). The arm fires on the
13384        // first `[` encountered; pinned so the gate's coverage
13385        // extends from the embedded-glob-character-class shape to
13386        // the leading-`test`-builtin / extended-test form.
13387        let d = dep_with_fonte(DepSource::Path {
13388            caminho: "../[ -d caixa-teia ]".into(),
13389        });
13390        let err = d.validate().unwrap_err();
13391        assert!(
13392            matches!(
13393                err,
13394                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13395            ),
13396            "got {err:?}",
13397        );
13398    }
13399
13400    #[test]
13401    fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
13402        // The positive-control pin: the gate targets only `[` /
13403        // `]`, never adjacent printable ASCII or POSIX-valid bytes.
13404        // The canonical relative POSIX path (`"../caixa-teia"`) and
13405        // a nested deeply-pathed variant with adjacent printable
13406        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13407        // to validate cleanly so the gate doesn't widen to a "no
13408        // printable punctuation anywhere" sweep that would defeat
13409        // the entire path-fonte author surface. Peer with
13410        // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
13411        // on the immediate-predecessor arm.
13412        let d = dep_with_fonte(DepSource::Path {
13413            caminho: "../caixa-teia/sub-dir.v2".into(),
13414        });
13415        d.validate().unwrap();
13416    }
13417
13418    #[test]
13419    fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
13420        // Cascade pin on the immediate-predecessor arm: a value
13421        // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
13422        // canonical "I pasted a brace-expansion fan followed by a
13423        // glob-character-class tail" footgun) routes through
13424        // `FonteCaminhoShellBraceExpansion` not
13425        // `FonteCaminhoShellBracketExpansion`. The brace-expansion
13426        // fan is the load-bearing root-cause edit on every
13427        // probe-as-both value because the bracket-class tail
13428        // typically rides on a prior brace-expansion expansion;
13429        // same cascade discipline every prior `:caminho` arm
13430        // establishes.
13431        let d = dep_with_fonte(DepSource::Path {
13432            caminho: "../{a,b}[ch]".into(),
13433        });
13434        let err = d.validate().unwrap_err();
13435        assert!(
13436            matches!(
13437                err,
13438                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13439            ),
13440            "got {err:?}",
13441        );
13442    }
13443
13444    #[test]
13445    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
13446        // Cascade pin on the upstream shell-subshell-grouping arm:
13447        // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
13448        // the canonical "I pasted a subshell-grouping followed by
13449        // a glob-character-class tail" footgun) routes through
13450        // `FonteCaminhoShellSubshellGrouping` not
13451        // `FonteCaminhoShellBracketExpansion`. The modern Bourne
13452        // `$(<cmd>)` command-substitution boundary is the load-
13453        // bearing axis on every probe-as-both value.
13454        let d = dep_with_fonte(DepSource::Path {
13455            caminho: "../(cd foo)/[ch]".into(),
13456        });
13457        let err = d.validate().unwrap_err();
13458        assert!(
13459            matches!(
13460                err,
13461                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13462            ),
13463            "got {err:?}",
13464        );
13465    }
13466
13467    #[test]
13468    fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
13469        // Cascade pin on the upstream shell-glob arm: a value
13470        // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
13471        // canonical "I pasted a `*.[ch]` C-source-file glob whose
13472        // unbounded `*` precedes the bracket character-class"
13473        // footgun) routes through `FonteCaminhoShellGlob` not
13474        // `FonteCaminhoShellBracketExpansion`. The unbounded
13475        // pathname-expansion sentinel is the load-bearing root-
13476        // cause edit on every probe-as-both value — the unbounded
13477        // `*` carries the more aggressive expansion vector than
13478        // the bounded `[ch]` class, so the prior arm wins.
13479        let d = dep_with_fonte(DepSource::Path {
13480            caminho: "../caixa-teia/*[ch]".into(),
13481        });
13482        let err = d.validate().unwrap_err();
13483        assert!(
13484            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13485            "got {err:?}",
13486        );
13487    }
13488
13489    #[test]
13490    fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
13491        // Cascade pin on the upstream shell-command-substitution
13492        // arm: a value carrying both a backtick and `[`
13493        // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
13494        // legacy-backtick command-substitution followed by a
13495        // glob-character-class tail" footgun) routes through
13496        // `FonteCaminhoShellCommandSubstitution` not
13497        // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
13498        // command-injection vector is the load-bearing root-cause
13499        // edit on every probe-as-both value.
13500        let d = dep_with_fonte(DepSource::Path {
13501            caminho: "../`whoami`/[ch]".into(),
13502        });
13503        let err = d.validate().unwrap_err();
13504        assert!(
13505            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13506            "got {err:?}",
13507        );
13508    }
13509
13510    #[test]
13511    fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
13512        // Cascade pin on the upstream shell-background arm: a
13513        // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
13514        // — the canonical "I pasted a `cmd & [glob]` background-
13515        // launch + bracket-class chain" footgun) routes through
13516        // `FonteCaminhoShellBackground` not
13517        // `FonteCaminhoShellBracketExpansion`. The background-
13518        // launch tail is the load-bearing root-cause edit on
13519        // every probe-as-both value.
13520        let d = dep_with_fonte(DepSource::Path {
13521            caminho: "../caixa-teia & [ch]".into(),
13522        });
13523        let err = d.validate().unwrap_err();
13524        assert!(
13525            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13526            "got {err:?}",
13527        );
13528    }
13529
13530    #[test]
13531    fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
13532        // Cascade pin on the upstream shell-semicolon arm: a value
13533        // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
13534        // canonical sequential-cleanup + bracket-class paste
13535        // idiom) routes through `FonteCaminhoShellSemicolon` not
13536        // `FonteCaminhoShellBracketExpansion`. The sequential-
13537        // command-separator paste is the load-bearing root-cause
13538        // edit on every probe-as-both value.
13539        let d = dep_with_fonte(DepSource::Path {
13540            caminho: "../caixa-teia; [ch]".into(),
13541        });
13542        let err = d.validate().unwrap_err();
13543        assert!(
13544            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13545            "got {err:?}",
13546        );
13547    }
13548
13549    #[test]
13550    fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
13551        // Cascade pin on the upstream shell-pipe arm: a value
13552        // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
13553        // the canonical pipeline-to-bracket-class paste idiom)
13554        // routes through `FonteCaminhoShellPipe` not
13555        // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
13556        // paste is the load-bearing root-cause edit on every
13557        // probe-as-both value.
13558        let d = dep_with_fonte(DepSource::Path {
13559            caminho: "../caixa-teia | [tee]".into(),
13560        });
13561        let err = d.validate().unwrap_err();
13562        assert!(
13563            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13564            "got {err:?}",
13565        );
13566    }
13567
13568    #[test]
13569    fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
13570        // Cascade pin on the upstream shell-redirection arm: a
13571        // value carrying both `>` and `[` (`"../caixa-teia>log
13572        // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
13573        // redirect-plus-bracket chain" footgun) routes through
13574        // `FonteCaminhoShellRedirection` not
13575        // `FonteCaminhoShellBracketExpansion`. The input/output
13576        // redirection metachar carries the more self-locating
13577        // `byte` payload, so the prior arm wins on every
13578        // probe-as-both value.
13579        let d = dep_with_fonte(DepSource::Path {
13580            caminho: "../caixa-teia>log [ch]".into(),
13581        });
13582        let err = d.validate().unwrap_err();
13583        assert!(
13584            matches!(
13585                err,
13586                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13587            ),
13588            "got {err:?}",
13589        );
13590    }
13591
13592    #[test]
13593    fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
13594        // Cascade pin on the upstream backslash arm: a value
13595        // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
13596        // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
13597        // chain") routes through `FonteCaminhoBackslash` not
13598        // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
13599        // separator divergence is the load-bearing axis on every
13600        // probe-as-both value.
13601        let d = dep_with_fonte(DepSource::Path {
13602            caminho: "..\\caixa-teia\\[ch]".into(),
13603        });
13604        let err = d.validate().unwrap_err();
13605        assert!(
13606            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13607            "got {err:?}",
13608        );
13609    }
13610
13611    #[test]
13612    fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
13613        // Cascade pin on the embedded-control-byte arm: a value
13614        // carrying both a control byte and `[` (`"../foo\n[ch]"` —
13615        // the canonical paste-from-multiline-doc footgun where a
13616        // newline landed mid-caminho between two paste fragments)
13617        // routes through `FonteCaminhoControlChar` not
13618        // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
13619        // rejected-byte / NUL-`CString::new`-fail diagnostic is
13620        // the load-bearing axis on every value that probes
13621        // positive for both — mirrors the cascade discipline on
13622        // every prior arm.
13623        let d = dep_with_fonte(DepSource::Path {
13624            caminho: "../foo\n[ch]".into(),
13625        });
13626        let err = d.validate().unwrap_err();
13627        assert!(
13628            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13629            "got {err:?}",
13630        );
13631    }
13632
13633    #[test]
13634    fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
13635        // Cascade pin on the load-bearing leading-byte arm: a
13636        // leading `/` value with embedded `[` (`"/etc/[ch]"`)
13637        // routes through `FonteCaminhoAbsolute` not
13638        // `FonteCaminhoShellBracketExpansion` — the host-layout-
13639        // leak diagnostic is the load-bearing axis, the bracket-
13640        // expansion byte is the secondary observation. Same
13641        // precedence logic as every prior leading-byte arm.
13642        let d = dep_with_fonte(DepSource::Path {
13643            caminho: "/etc/[ch]".into(),
13644        });
13645        let err = d.validate().unwrap_err();
13646        assert!(
13647            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13648            "got {err:?}",
13649        );
13650    }
13651
13652    #[test]
13653    fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
13654        // Cascade pin on the upstream leading-`$` var-expansion
13655        // arm: a value carrying both a leading `$` and a `[`
13656        // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
13657        // variable + bracket-class at the head of a sibling-
13658        // workspace path" footgun) routes through
13659        // `FonteCaminhoVarExpansion` not
13660        // `FonteCaminhoShellBracketExpansion`. The leading-byte
13661        // shell-variable-expansion is the more self-locating
13662        // diagnostic on values that probe as both — same
13663        // load-bearing-leading-byte cascade discipline every
13664        // prior `:caminho` arm establishes.
13665        let d = dep_with_fonte(DepSource::Path {
13666            caminho: "$DIR/[ch]".into(),
13667        });
13668        let err = d.validate().unwrap_err();
13669        assert!(
13670            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13671            "got {err:?}",
13672        );
13673    }
13674
13675    #[test]
13676    fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
13677        // Cascade pin on the immediate-successor arm: a value
13678        // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
13679        // the canonical "I tab-completed a path that already had
13680        // a bracket-glob-character-class expansion tail" footgun)
13681        // routes through `FonteCaminhoShellBracketExpansion` not
13682        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13683        // is the more semantic-locating axis (an author who
13684        // removes the `[` typically also drops the trailing
13685        // separator since both are paste-from-shell artifacts).
13686        let d = dep_with_fonte(DepSource::Path {
13687            caminho: "../[a-z]/".into(),
13688        });
13689        let err = d.validate().unwrap_err();
13690        assert!(
13691            matches!(
13692                err,
13693                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13694            ),
13695            "got {err:?}",
13696        );
13697    }
13698
13699    #[test]
13700    fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13701        // Diagnostic-shape pin (peer with
13702        // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13703        // on the closest two-byte peer arm): the error's Display
13704        // surfaces the offending `:nome`, the offending `:caminho`
13705        // verbatim, the offending byte's hex / character form, and
13706        // names the shell-bracket-expansion / glob-character-class
13707        // footgun explicitly so a `feira lint` run can render the
13708        // diagnostic without re-parsing.
13709        let d = dep_with_fonte(DepSource::Path {
13710            caminho: "../caixa-[a-z]/build".into(),
13711        });
13712        let rendered = d.validate().unwrap_err().to_string();
13713        assert!(
13714            rendered.contains("caixa-teia"),
13715            "diagnostic must name the offending dep: {rendered}",
13716        );
13717        assert!(
13718            rendered.contains("../caixa-[a-z]/build"),
13719            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13720        );
13721        assert!(
13722            rendered.contains("0x5b"),
13723            "diagnostic must surface the offending byte hex: {rendered:?}",
13724        );
13725        assert!(
13726            rendered.contains("bracket-expansion"),
13727            "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
13728        );
13729        assert!(
13730            rendered.contains("glob-character-class"),
13731            "diagnostic must reference the POSIX glob-character-class vocabulary: \
13732             {rendered:?}",
13733        );
13734    }
13735
13736    #[test]
13737    fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
13738        // The canonical paste-from-shell-history strong-quoted
13739        // sibling-workspace-path footgun: an author copies a
13740        // `cd '../caixa-teia'` shell-history one-liner whose strong-
13741        // quoting preserved the path across a whitespace paste
13742        // boundary and silently passed every prior arm
13743        // (`Path::is_absolute` false on `'..`, no control bytes, no
13744        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
13745        // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
13746        // doesn't end in `/`; the leading-`$` f4efe9c
13747        // `FonteCaminhoVarExpansion` arm doesn't fire because the
13748        // value starts with `'` not `$`). The lacre embedded the
13749        // value verbatim, the resolver folded it through
13750        // `Path::join` looking for a literal `./'../caixa-teia'`
13751        // subdirectory, and the failure surfaced at resolve time
13752        // with a non-self-locating `No such file or directory`
13753        // error. The new arm moves the rejection to validate time
13754        // and names the offending dep + caminho + byte verbatim.
13755        // The arm fires on the first `'` encountered.
13756        let d = dep_with_fonte(DepSource::Path {
13757            caminho: "'../caixa-teia'".into(),
13758        });
13759        let err = d.validate().unwrap_err();
13760        let DepError::FonteCaminhoShellQuoteGrouping {
13761            nome,
13762            caminho,
13763            byte,
13764        } = err
13765        else {
13766            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13767        };
13768        assert_eq!(nome, "caixa-teia");
13769        assert_eq!(caminho, "'../caixa-teia'");
13770        assert_eq!(byte, b'\'');
13771    }
13772
13773    #[test]
13774    fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
13775        // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
13776        // — the canonical paste-from-JSON-config / paste-from-YAML-
13777        // flow-scalar / paste-from-TOML-basic-string / paste-from-
13778        // tatara-lisp-string-literal cross-idiom leak). Pinned
13779        // separately from the single-quote shape so the gate's
13780        // contract is "any `'` or `\"` anywhere", not single-byte
13781        // coverage. Mirrors the peer
13782        // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
13783        // shape on the immediate-predecessor
13784        // `FonteCaminhoShellBracketExpansion` arm.
13785        let d = dep_with_fonte(DepSource::Path {
13786            caminho: "\"../caixa-teia\"".into(),
13787        });
13788        let err = d.validate().unwrap_err();
13789        let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
13790            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13791        };
13792        assert_eq!(byte, b'"');
13793    }
13794
13795    #[test]
13796    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
13797        // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
13798        // canonical "I pasted a JSON key-value pair fragment into
13799        // the middle of the path" idiom). Pinned separately from
13800        // the leading-byte shape so the gate covers every position,
13801        // not only leading.
13802        let d = dep_with_fonte(DepSource::Path {
13803            caminho: "../\"caixa-teia\"".into(),
13804        });
13805        let err = d.validate().unwrap_err();
13806        assert!(
13807            matches!(
13808                err,
13809                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13810            ),
13811            "got {err:?}",
13812        );
13813    }
13814
13815    #[test]
13816    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
13817        // The canonical YAML double-quoted flow-scalar cross-idiom
13818        // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
13819        // `path: \"...\"` YAML flow-scalar entry out of an aligned
13820        // values.yaml / K8s manifest and dropped it verbatim into
13821        // the `:caminho` slot including the `path: ` key prefix"
13822        // paste-idiom). The arm fires on the first `"` encountered;
13823        // pinned so the gate's coverage extends from the bare-quote
13824        // paste shape to the aligned-YAML-manifest cross-idiom-leak
13825        // shape.
13826        let d = dep_with_fonte(DepSource::Path {
13827            caminho: "path: \"../caixa-teia\"".into(),
13828        });
13829        let err = d.validate().unwrap_err();
13830        assert!(
13831            matches!(
13832                err,
13833                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13834            ),
13835            "got {err:?}",
13836        );
13837    }
13838
13839    #[test]
13840    fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
13841        // The positive-control pin: the gate targets only `'` /
13842        // `"`, never adjacent printable ASCII or POSIX-valid bytes.
13843        // The canonical relative POSIX path (`"../caixa-teia"`) and
13844        // a nested deeply-pathed variant with adjacent printable
13845        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13846        // to validate cleanly so the gate doesn't widen to a "no
13847        // printable punctuation anywhere" sweep that would defeat
13848        // the entire path-fonte author surface. Peer with
13849        // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
13850        // on the immediate-predecessor arm.
13851        let d = dep_with_fonte(DepSource::Path {
13852            caminho: "../caixa-teia/sub-dir.v2".into(),
13853        });
13854        d.validate().unwrap();
13855    }
13856
13857    #[test]
13858    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
13859        // Cascade pin on the immediate-predecessor arm: a value
13860        // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
13861        // "I pasted a glob-character-class followed by a strong-
13862        // quoted literal tail" footgun) routes through
13863        // `FonteCaminhoShellBracketExpansion` not
13864        // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
13865        // expansion is the load-bearing root-cause edit on every
13866        // probe-as-both value; same cascade discipline every prior
13867        // `:caminho` arm establishes.
13868        let d = dep_with_fonte(DepSource::Path {
13869            caminho: "../[a-z]'x'".into(),
13870        });
13871        let err = d.validate().unwrap_err();
13872        assert!(
13873            matches!(
13874                err,
13875                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13876            ),
13877            "got {err:?}",
13878        );
13879    }
13880
13881    #[test]
13882    fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
13883        // Cascade pin on the upstream shell-brace-expansion arm: a
13884        // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
13885        // canonical "I pasted a brace-expansion fan followed by a
13886        // strong-quoted literal tail" footgun) routes through
13887        // `FonteCaminhoShellBraceExpansion` not
13888        // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
13889        // is the load-bearing root-cause edit on every probe-as-
13890        // both value.
13891        let d = dep_with_fonte(DepSource::Path {
13892            caminho: "../{a,b}'x'".into(),
13893        });
13894        let err = d.validate().unwrap_err();
13895        assert!(
13896            matches!(
13897                err,
13898                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13899            ),
13900            "got {err:?}",
13901        );
13902    }
13903
13904    #[test]
13905    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
13906        // Cascade pin on the upstream shell-subshell-grouping arm:
13907        // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
13908        // the canonical "I pasted a subshell-grouping followed by
13909        // a strong-quoted literal tail" footgun) routes through
13910        // `FonteCaminhoShellSubshellGrouping` not
13911        // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
13912        // `$(<cmd>)` command-substitution boundary is the load-
13913        // bearing axis on every probe-as-both value.
13914        let d = dep_with_fonte(DepSource::Path {
13915            caminho: "../(cd foo)/'x'".into(),
13916        });
13917        let err = d.validate().unwrap_err();
13918        assert!(
13919            matches!(
13920                err,
13921                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13922            ),
13923            "got {err:?}",
13924        );
13925    }
13926
13927    #[test]
13928    fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
13929        // Cascade pin on the upstream shell-glob arm: a value
13930        // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
13931        // canonical "I pasted a `*` unbounded pathname-expansion
13932        // followed by a strong-quoted literal tail" footgun) routes
13933        // through `FonteCaminhoShellGlob` not
13934        // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
13935        // expansion sentinel is the load-bearing root-cause edit
13936        // on every probe-as-both value.
13937        let d = dep_with_fonte(DepSource::Path {
13938            caminho: "../caixa-teia/*'x'".into(),
13939        });
13940        let err = d.validate().unwrap_err();
13941        assert!(
13942            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13943            "got {err:?}",
13944        );
13945    }
13946
13947    #[test]
13948    fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
13949        // Cascade pin on the upstream shell-command-substitution
13950        // arm: a value carrying both a backtick and `'`
13951        // (``"../`whoami`/'x'"`` — the canonical "I pasted a
13952        // legacy-backtick command-substitution followed by a
13953        // strong-quoted literal tail" footgun) routes through
13954        // `FonteCaminhoShellCommandSubstitution` not
13955        // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
13956        // command-injection vector is the load-bearing root-cause
13957        // edit on every probe-as-both value.
13958        let d = dep_with_fonte(DepSource::Path {
13959            caminho: "../`whoami`/'x'".into(),
13960        });
13961        let err = d.validate().unwrap_err();
13962        assert!(
13963            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13964            "got {err:?}",
13965        );
13966    }
13967
13968    #[test]
13969    fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
13970        // Cascade pin on the upstream shell-background arm: a value
13971        // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
13972        // canonical "I pasted a `cmd & 'literal'` background-launch
13973        // + quote chain" footgun) routes through
13974        // `FonteCaminhoShellBackground` not
13975        // `FonteCaminhoShellQuoteGrouping`. The background-launch
13976        // tail is the load-bearing root-cause edit on every
13977        // probe-as-both value.
13978        let d = dep_with_fonte(DepSource::Path {
13979            caminho: "../caixa-teia & 'x'".into(),
13980        });
13981        let err = d.validate().unwrap_err();
13982        assert!(
13983            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13984            "got {err:?}",
13985        );
13986    }
13987
13988    #[test]
13989    fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
13990        // Cascade pin on the upstream shell-semicolon arm: a value
13991        // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
13992        // canonical sequential-cleanup + quote paste idiom) routes
13993        // through `FonteCaminhoShellSemicolon` not
13994        // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
13995        // separator paste is the load-bearing root-cause edit on
13996        // every probe-as-both value.
13997        let d = dep_with_fonte(DepSource::Path {
13998            caminho: "../caixa-teia; 'x'".into(),
13999        });
14000        let err = d.validate().unwrap_err();
14001        assert!(
14002            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14003            "got {err:?}",
14004        );
14005    }
14006
14007    #[test]
14008    fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
14009        // Cascade pin on the upstream shell-pipe arm: a value
14010        // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
14011        // canonical pipeline-to-quoted-literal paste idiom) routes
14012        // through `FonteCaminhoShellPipe` not
14013        // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
14014        // is the load-bearing root-cause edit on every probe-as-
14015        // both value.
14016        let d = dep_with_fonte(DepSource::Path {
14017            caminho: "../caixa-teia | 'x'".into(),
14018        });
14019        let err = d.validate().unwrap_err();
14020        assert!(
14021            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14022            "got {err:?}",
14023        );
14024    }
14025
14026    #[test]
14027    fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
14028        // Cascade pin on the upstream shell-redirection arm: a
14029        // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
14030        // — the canonical "I pasted a `cmd > log 'literal'`
14031        // redirect-plus-quote chain" footgun) routes through
14032        // `FonteCaminhoShellRedirection` not
14033        // `FonteCaminhoShellQuoteGrouping`. The input/output
14034        // redirection metachar carries the more self-locating
14035        // `byte` payload, so the prior arm wins on every probe-as-
14036        // both value.
14037        let d = dep_with_fonte(DepSource::Path {
14038            caminho: "../caixa-teia>log 'x'".into(),
14039        });
14040        let err = d.validate().unwrap_err();
14041        assert!(
14042            matches!(
14043                err,
14044                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14045            ),
14046            "got {err:?}",
14047        );
14048    }
14049
14050    #[test]
14051    fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
14052        // Cascade pin on the upstream backslash arm: a value
14053        // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
14054        // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
14055        // chain" footgun) routes through `FonteCaminhoBackslash`
14056        // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
14057        // separator divergence is the load-bearing axis on every
14058        // probe-as-both value.
14059        let d = dep_with_fonte(DepSource::Path {
14060            caminho: "..\\caixa-teia\\'x'".into(),
14061        });
14062        let err = d.validate().unwrap_err();
14063        assert!(
14064            matches!(err, DepError::FonteCaminhoBackslash { .. }),
14065            "got {err:?}",
14066        );
14067    }
14068
14069    #[test]
14070    fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
14071        // Cascade pin on the embedded-control-byte arm: a value
14072        // carrying both a control byte and `'` (`"../foo\n'x'"` —
14073        // the canonical paste-from-multiline-doc footgun where a
14074        // newline landed mid-caminho between two paste fragments)
14075        // routes through `FonteCaminhoControlChar` not
14076        // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
14077        // rejected-byte / NUL-`CString::new`-fail diagnostic is
14078        // the load-bearing axis on every value that probes
14079        // positive for both — mirrors the cascade discipline on
14080        // every prior arm.
14081        let d = dep_with_fonte(DepSource::Path {
14082            caminho: "../foo\n'x'".into(),
14083        });
14084        let err = d.validate().unwrap_err();
14085        assert!(
14086            matches!(err, DepError::FonteCaminhoControlChar { .. }),
14087            "got {err:?}",
14088        );
14089    }
14090
14091    #[test]
14092    fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
14093        // Cascade pin on the load-bearing leading-byte arm: a
14094        // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
14095        // through `FonteCaminhoAbsolute` not
14096        // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
14097        // diagnostic is the load-bearing axis, the quote byte is
14098        // the secondary observation. Same precedence logic as every
14099        // prior leading-byte arm.
14100        let d = dep_with_fonte(DepSource::Path {
14101            caminho: "/etc/'x'".into(),
14102        });
14103        let err = d.validate().unwrap_err();
14104        assert!(
14105            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14106            "got {err:?}",
14107        );
14108    }
14109
14110    #[test]
14111    fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
14112        // Cascade pin on the upstream leading-`$` var-expansion
14113        // arm: a value carrying both a leading `$` and a `'`
14114        // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
14115        // variable + quoted literal at the head of a sibling-
14116        // workspace path" footgun) routes through
14117        // `FonteCaminhoVarExpansion` not
14118        // `FonteCaminhoShellQuoteGrouping`. The leading-byte
14119        // shell-variable-expansion is the more self-locating
14120        // diagnostic on values that probe as both — same
14121        // load-bearing-leading-byte cascade discipline every
14122        // prior `:caminho` arm establishes.
14123        let d = dep_with_fonte(DepSource::Path {
14124            caminho: "$DIR/'x'".into(),
14125        });
14126        let err = d.validate().unwrap_err();
14127        assert!(
14128            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14129            "got {err:?}",
14130        );
14131    }
14132
14133    #[test]
14134    fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
14135        // Cascade pin on the immediate-successor arm: a value
14136        // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
14137        // — the canonical "I tab-completed a path whose strong-
14138        // quoted body already carried the quoting from a shell-
14139        // history paste" footgun) routes through
14140        // `FonteCaminhoShellQuoteGrouping` not
14141        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
14142        // is the more semantic-locating axis (an author who removes
14143        // the `'` typically also drops the trailing separator since
14144        // both are paste-from-shell artifacts).
14145        let d = dep_with_fonte(DepSource::Path {
14146            caminho: "../'caixa-teia'/".into(),
14147        });
14148        let err = d.validate().unwrap_err();
14149        assert!(
14150            matches!(
14151                err,
14152                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14153            ),
14154            "got {err:?}",
14155        );
14156    }
14157
14158    #[test]
14159    fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
14160        // Diagnostic-shape pin (peer with
14161        // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14162        // on the closest two-byte peer arm): the error's Display
14163        // surfaces the offending `:nome`, the offending `:caminho`
14164        // verbatim, the offending byte's hex / character form, and
14165        // names the shell-quote-grouping / cross-config-DSL-string-
14166        // literal-delimiter footgun explicitly so a `feira lint`
14167        // run can render the diagnostic without re-parsing.
14168        let d = dep_with_fonte(DepSource::Path {
14169            caminho: "'../caixa-teia'".into(),
14170        });
14171        let rendered = d.validate().unwrap_err().to_string();
14172        assert!(
14173            rendered.contains("caixa-teia"),
14174            "diagnostic must name the offending dep: {rendered}",
14175        );
14176        assert!(
14177            rendered.contains("'../caixa-teia'"),
14178            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14179        );
14180        assert!(
14181            rendered.contains("0x27"),
14182            "diagnostic must surface the offending byte hex: {rendered:?}",
14183        );
14184        assert!(
14185            rendered.contains("quote-grouping"),
14186            "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
14187        );
14188        assert!(
14189            rendered.contains("string-literal"),
14190            "diagnostic must reference the cross-config-DSL string-literal-delimiter \
14191             vocabulary: {rendered:?}",
14192        );
14193    }
14194
14195    #[test]
14196    fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
14197        // The canonical paste-from-shell-history-with-trailing-
14198        // annotation footgun: an author pastes a `cd ../caixa-teia
14199        // # legacy sibling` shell-history one-liner whose unquoted `#`
14200        // comment-lead separates the path from an inline annotation.
14201        // The POSIX shell trims the annotation to `../caixa-teia`
14202        // (POSIX.1-2017 §2.3 Token Recognition step 6), but
14203        // `Path::is_absolute` returns false on `..`, `#` is neither
14204        // a leading-byte sentinel nor a control byte nor `\` nor
14205        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
14206        // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
14207        // `"`, and the value's last byte isn't `/` — so the value
14208        // silently passed every prior arm. The resolver folded the
14209        // value through `Path::join` looking for a literal
14210        // `./../caixa-teia # legacy sibling` subdirectory and the
14211        // failure surfaced at resolve time with a non-self-locating
14212        // `No such file or directory` error. The new arm moves the
14213        // rejection to validate time and names the offending dep +
14214        // caminho + byte verbatim.
14215        let d = dep_with_fonte(DepSource::Path {
14216            caminho: "../caixa-teia # legacy sibling".into(),
14217        });
14218        let err = d.validate().unwrap_err();
14219        let DepError::FonteCaminhoShellComment {
14220            nome,
14221            caminho,
14222            byte,
14223        } = err
14224        else {
14225            panic!("expected FonteCaminhoShellComment, got {err:?}");
14226        };
14227        assert_eq!(nome, "caixa-teia");
14228        assert_eq!(caminho, "../caixa-teia # legacy sibling");
14229        assert_eq!(byte, b'#');
14230    }
14231
14232    #[test]
14233    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
14234        // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
14235        // cross-idiom-leak shape (`"../caixa-teia  # pin"` — the
14236        // canonical "I copied a `path: ../caixa-teia  # pin` YAML
14237        // scalar-plus-comment entry out of an aligned values.yaml and
14238        // dropped it verbatim into the `:caminho` slot" paste-idiom).
14239        // Pinned separately from the shell-history shape so the
14240        // gate's coverage extends from the single-space `#` shape to
14241        // the YAML-canonical double-space `  #` shape. YAML 1.2 §6.6
14242        // requires the `#` to be preceded by whitespace to lex as a
14243        // comment (bare `foo#bar` is a single scalar); the double-
14244        // space paste from an aligned manifest is the canonical
14245        // shape.
14246        let d = dep_with_fonte(DepSource::Path {
14247            caminho: "../caixa-teia  # pin".into(),
14248        });
14249        let err = d.validate().unwrap_err();
14250        assert!(
14251            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14252            "got {err:?}",
14253        );
14254    }
14255
14256    #[test]
14257    fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
14258        // The URL-fragment-identifier paste shape
14259        // (`"../caixa-teia#readme"` — the canonical
14260        // paste-from-browser-address-bar permalink shape where the
14261        // browser preserved the `#anchor` tail on the copy). Pinned
14262        // separately from the whitespace-separated shell / YAML
14263        // comment shapes so the gate covers the unpadded RFC 3986
14264        // §3.5 fragment-delimiter position too, not only positions
14265        // preceded by unquoted whitespace. Peer with the immediate-
14266        // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
14267        // (a68f818) which closes the same byte under the same URL-
14268        // fragment-identifier banner.
14269        let d = dep_with_fonte(DepSource::Path {
14270            caminho: "../caixa-teia#readme".into(),
14271        });
14272        let err = d.validate().unwrap_err();
14273        assert!(
14274            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14275            "got {err:?}",
14276        );
14277    }
14278
14279    #[test]
14280    fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
14281        // Leading-position `#` shape (`"#../caixa-teia"` — the
14282        // "I copied a shell-comment-out entry from a commented-out
14283        // dep row" footgun). Pinned separately from the embedded
14284        // shapes so the gate covers every position, not only
14285        // whitespace-preceded / mid-value.
14286        let d = dep_with_fonte(DepSource::Path {
14287            caminho: "#../caixa-teia".into(),
14288        });
14289        let err = d.validate().unwrap_err();
14290        assert!(
14291            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14292            "got {err:?}",
14293        );
14294    }
14295
14296    #[test]
14297    fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
14298        // The positive-control pin: the gate targets only `#`,
14299        // never adjacent printable ASCII or POSIX-valid bytes. The
14300        // canonical relative POSIX path (`"../caixa-teia"`) and a
14301        // nested deeply-pathed variant with adjacent printable
14302        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14303        // to validate cleanly so the gate doesn't widen to a "no
14304        // printable punctuation anywhere" sweep that would defeat
14305        // the entire path-fonte author surface. Peer with
14306        // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
14307        // on the immediate-predecessor arm.
14308        let d = dep_with_fonte(DepSource::Path {
14309            caminho: "../caixa-teia/sub-dir.v2".into(),
14310        });
14311        d.validate().unwrap();
14312    }
14313
14314    #[test]
14315    fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
14316        // Cascade pin on the immediate-predecessor arm: a value
14317        // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
14318        // "I pasted a strong-quoted literal followed by a URL-
14319        // fragment permalink tail" footgun) routes through
14320        // `FonteCaminhoShellQuoteGrouping` not
14321        // `FonteCaminhoShellComment`. The shell-string-literal-
14322        // delimiter is the load-bearing root-cause edit on every
14323        // probe-as-both value; same cascade discipline every prior
14324        // `:caminho` arm establishes.
14325        let d = dep_with_fonte(DepSource::Path {
14326            caminho: "../'x'#pin".into(),
14327        });
14328        let err = d.validate().unwrap_err();
14329        assert!(
14330            matches!(
14331                err,
14332                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14333            ),
14334            "got {err:?}",
14335        );
14336    }
14337
14338    #[test]
14339    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
14340        // Cascade pin on the upstream shell-bracket-expansion arm:
14341        // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
14342        // canonical "I pasted a glob-character-class followed by a
14343        // URL-fragment tail" footgun) routes through
14344        // `FonteCaminhoShellBracketExpansion` not
14345        // `FonteCaminhoShellComment`. The glob-character-class
14346        // expansion is the load-bearing root-cause edit on every
14347        // probe-as-both value.
14348        let d = dep_with_fonte(DepSource::Path {
14349            caminho: "../[a-z]#pin".into(),
14350        });
14351        let err = d.validate().unwrap_err();
14352        assert!(
14353            matches!(
14354                err,
14355                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
14356            ),
14357            "got {err:?}",
14358        );
14359    }
14360
14361    #[test]
14362    fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
14363        // Cascade pin on the upstream shell-brace-expansion arm: a
14364        // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
14365        // canonical "I pasted a brace-expansion fan followed by a
14366        // URL-fragment tail" footgun) routes through
14367        // `FonteCaminhoShellBraceExpansion` not
14368        // `FonteCaminhoShellComment`. The brace-expansion fan is the
14369        // load-bearing root-cause edit on every probe-as-both value.
14370        let d = dep_with_fonte(DepSource::Path {
14371            caminho: "../{a,b}#pin".into(),
14372        });
14373        let err = d.validate().unwrap_err();
14374        assert!(
14375            matches!(
14376                err,
14377                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
14378            ),
14379            "got {err:?}",
14380        );
14381    }
14382
14383    #[test]
14384    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
14385        // Cascade pin on the upstream shell-subshell-grouping arm:
14386        // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
14387        // the canonical "I pasted a subshell-grouping followed by a
14388        // URL-fragment tail" footgun) routes through
14389        // `FonteCaminhoShellSubshellGrouping` not
14390        // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
14391        // command-substitution boundary is the load-bearing axis on
14392        // every probe-as-both value.
14393        let d = dep_with_fonte(DepSource::Path {
14394            caminho: "../(cd foo)#pin".into(),
14395        });
14396        let err = d.validate().unwrap_err();
14397        assert!(
14398            matches!(
14399                err,
14400                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
14401            ),
14402            "got {err:?}",
14403        );
14404    }
14405
14406    #[test]
14407    fn fonte_caminho_shell_glob_fires_before_shell_comment() {
14408        // Cascade pin on the upstream shell-glob arm: a value
14409        // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
14410        // canonical "I pasted a `*` unbounded pathname-expansion
14411        // followed by a URL-fragment tail" footgun) routes through
14412        // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
14413        // The unbounded pathname-expansion sentinel is the load-
14414        // bearing root-cause edit on every probe-as-both value.
14415        let d = dep_with_fonte(DepSource::Path {
14416            caminho: "../caixa-teia/*#pin".into(),
14417        });
14418        let err = d.validate().unwrap_err();
14419        assert!(
14420            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
14421            "got {err:?}",
14422        );
14423    }
14424
14425    #[test]
14426    fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
14427        // Cascade pin on the upstream shell-command-substitution
14428        // arm: a value carrying both a backtick and `#`
14429        // (``"../`whoami`#pin"`` — the canonical "I pasted a
14430        // legacy-backtick command-substitution followed by a URL-
14431        // fragment tail" footgun) routes through
14432        // `FonteCaminhoShellCommandSubstitution` not
14433        // `FonteCaminhoShellComment`. The CWE-78 shell-command-
14434        // injection vector is the load-bearing root-cause edit on
14435        // every probe-as-both value.
14436        let d = dep_with_fonte(DepSource::Path {
14437            caminho: "../`whoami`#pin".into(),
14438        });
14439        let err = d.validate().unwrap_err();
14440        assert!(
14441            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
14442            "got {err:?}",
14443        );
14444    }
14445
14446    #[test]
14447    fn fonte_caminho_shell_background_fires_before_shell_comment() {
14448        // Cascade pin on the upstream shell-background arm: a value
14449        // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
14450        // the canonical "I pasted a `cmd &` background-launch
14451        // followed by a URL-fragment tail" footgun) routes through
14452        // `FonteCaminhoShellBackground` not
14453        // `FonteCaminhoShellComment`. The background-launch tail is
14454        // the load-bearing root-cause edit on every probe-as-both
14455        // value.
14456        let d = dep_with_fonte(DepSource::Path {
14457            caminho: "../caixa-teia&pin#tail".into(),
14458        });
14459        let err = d.validate().unwrap_err();
14460        assert!(
14461            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
14462            "got {err:?}",
14463        );
14464    }
14465
14466    #[test]
14467    fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
14468        // Cascade pin on the upstream shell-semicolon arm: a value
14469        // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
14470        // the canonical sequential-cleanup + URL-fragment paste
14471        // idiom) routes through `FonteCaminhoShellSemicolon` not
14472        // `FonteCaminhoShellComment`. The sequential-command-
14473        // separator paste is the load-bearing root-cause edit on
14474        // every probe-as-both value.
14475        let d = dep_with_fonte(DepSource::Path {
14476            caminho: "../caixa-teia;pin#tail".into(),
14477        });
14478        let err = d.validate().unwrap_err();
14479        assert!(
14480            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14481            "got {err:?}",
14482        );
14483    }
14484
14485    #[test]
14486    fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
14487        // Cascade pin on the upstream shell-pipe arm: a value
14488        // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
14489        // the canonical pipeline-to-URL-fragment paste idiom) routes
14490        // through `FonteCaminhoShellPipe` not
14491        // `FonteCaminhoShellComment`. The pipeline-tail paste is
14492        // the load-bearing root-cause edit on every probe-as-both
14493        // value.
14494        let d = dep_with_fonte(DepSource::Path {
14495            caminho: "../caixa-teia|pin#tail".into(),
14496        });
14497        let err = d.validate().unwrap_err();
14498        assert!(
14499            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14500            "got {err:?}",
14501        );
14502    }
14503
14504    #[test]
14505    fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
14506        // Cascade pin on the upstream shell-redirection arm: a
14507        // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
14508        // — the canonical "I pasted a `cmd > log` redirect followed
14509        // by a URL-fragment tail" footgun) routes through
14510        // `FonteCaminhoShellRedirection` not
14511        // `FonteCaminhoShellComment`. The input/output redirection
14512        // metachar carries the more self-locating `byte` payload,
14513        // so the prior arm wins on every probe-as-both value.
14514        let d = dep_with_fonte(DepSource::Path {
14515            caminho: "../caixa-teia>log#pin".into(),
14516        });
14517        let err = d.validate().unwrap_err();
14518        assert!(
14519            matches!(
14520                err,
14521                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14522            ),
14523            "got {err:?}",
14524        );
14525    }
14526
14527    #[test]
14528    fn fonte_caminho_backslash_fires_before_shell_comment() {
14529        // Cascade pin on the upstream backslash arm: a value
14530        // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
14531        // canonical "I pasted a Windows-shell path followed by a
14532        // URL-fragment tail" footgun) routes through
14533        // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
14534        // The cross-host-OS-separator divergence is the load-
14535        // bearing axis on every probe-as-both value.
14536        let d = dep_with_fonte(DepSource::Path {
14537            caminho: "..\\caixa-teia#pin".into(),
14538        });
14539        let err = d.validate().unwrap_err();
14540        assert!(
14541            matches!(err, DepError::FonteCaminhoBackslash { .. }),
14542            "got {err:?}",
14543        );
14544    }
14545
14546    #[test]
14547    fn fonte_caminho_control_char_fires_before_shell_comment() {
14548        // Cascade pin on the embedded-control-byte arm: a value
14549        // carrying both a control byte and `#` (`"../foo\n#pin"` —
14550        // the canonical paste-from-multiline-doc footgun where a
14551        // newline landed mid-caminho between the path and an
14552        // annotation) routes through `FonteCaminhoControlChar` not
14553        // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
14554        // byte diagnostic is the load-bearing axis on every value
14555        // that probes positive for both — mirrors the cascade
14556        // discipline on every prior arm.
14557        let d = dep_with_fonte(DepSource::Path {
14558            caminho: "../foo\n#pin".into(),
14559        });
14560        let err = d.validate().unwrap_err();
14561        assert!(
14562            matches!(err, DepError::FonteCaminhoControlChar { .. }),
14563            "got {err:?}",
14564        );
14565    }
14566
14567    #[test]
14568    fn fonte_caminho_absolute_fires_before_shell_comment() {
14569        // Cascade pin on the load-bearing leading-byte arm: a
14570        // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
14571        // routes through `FonteCaminhoAbsolute` not
14572        // `FonteCaminhoShellComment` — the host-layout-leak
14573        // diagnostic is the load-bearing axis, the fragment byte is
14574        // the secondary observation. Same precedence logic as every
14575        // prior leading-byte arm.
14576        let d = dep_with_fonte(DepSource::Path {
14577            caminho: "/etc/foo#pin".into(),
14578        });
14579        let err = d.validate().unwrap_err();
14580        assert!(
14581            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14582            "got {err:?}",
14583        );
14584    }
14585
14586    #[test]
14587    fn fonte_caminho_var_expansion_fires_before_shell_comment() {
14588        // Cascade pin on the upstream leading-`$` var-expansion
14589        // arm: a value carrying both a leading `$` and a `#`
14590        // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
14591        // shell-variable at the head of a sibling-workspace path
14592        // followed by a URL-fragment tail" footgun) routes through
14593        // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
14594        // The leading-byte shell-variable-expansion is the more
14595        // self-locating diagnostic on values that probe as both.
14596        let d = dep_with_fonte(DepSource::Path {
14597            caminho: "$DIR/foo#pin".into(),
14598        });
14599        let err = d.validate().unwrap_err();
14600        assert!(
14601            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14602            "got {err:?}",
14603        );
14604    }
14605
14606    #[test]
14607    fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
14608        // Cascade pin on the immediate-successor arm: a value
14609        // carrying both `#` and a trailing `/`
14610        // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
14611        // a URL-fragment-carrying path" footgun) routes through
14612        // `FonteCaminhoShellComment` not
14613        // `FonteCaminhoTrailingSlash`. The embedded fragment /
14614        // comment-lead byte is the more semantic-locating axis (an
14615        // author who removes the `#pin` fragment typically also
14616        // drops the trailing separator since both are paste-from-
14617        // URL / paste-from-shell-tab-completion artifacts).
14618        let d = dep_with_fonte(DepSource::Path {
14619            caminho: "../caixa-teia#pin/".into(),
14620        });
14621        let err = d.validate().unwrap_err();
14622        assert!(
14623            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
14624            "got {err:?}",
14625        );
14626    }
14627
14628    #[test]
14629    fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
14630        // Diagnostic-shape pin (peer with
14631        // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
14632        // on the immediate-predecessor arm): the error's Display
14633        // surfaces the offending `:nome`, the offending `:caminho`
14634        // verbatim, the offending byte's hex / character form, and
14635        // names the shell-comment / URL-fragment-identifier /
14636        // YAML-comment cross-config-DSL footgun explicitly so a
14637        // `feira lint` run can render the diagnostic without
14638        // re-parsing.
14639        let d = dep_with_fonte(DepSource::Path {
14640            caminho: "../caixa-teia#readme".into(),
14641        });
14642        let rendered = d.validate().unwrap_err().to_string();
14643        assert!(
14644            rendered.contains("caixa-teia"),
14645            "diagnostic must name the offending dep: {rendered}",
14646        );
14647        assert!(
14648            rendered.contains("../caixa-teia#readme"),
14649            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14650        );
14651        assert!(
14652            rendered.contains("0x23"),
14653            "diagnostic must surface the offending byte hex: {rendered:?}",
14654        );
14655        assert!(
14656            rendered.contains("shell-comment") || rendered.contains("comment-lead"),
14657            "diagnostic must name the shell-comment footgun: {rendered:?}",
14658        );
14659        assert!(
14660            rendered.contains("fragment") || rendered.contains("URL-fragment"),
14661            "diagnostic must reference the URL-fragment-identifier vocabulary: \
14662             {rendered:?}",
14663        );
14664    }
14665
14666    #[test]
14667    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
14668        // The canonical paste-from-browser-address-bar percent-
14669        // encoded-space footgun: an author copies `../caixa%20teia`
14670        // out of a URL-encoded README hyperlink / browser address
14671        // bar / percent-encoded permalink expecting `%20` to decode
14672        // to a literal space at the filesystem layer. POSIX
14673        // `std::path::Path` treats `%` as a literal path-component
14674        // byte, so `Path::join` looks for a literal
14675        // `./../caixa%20teia` subdirectory. `Path::is_absolute`
14676        // returns false on `..`, `%` is neither a leading-byte
14677        // sentinel nor a control byte nor `\` nor `<` / `>` nor
14678        // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
14679        // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
14680        // and the value's last byte isn't `/` — so the value
14681        // silently passed every prior arm. The new arm moves the
14682        // rejection to validate time and names the offending dep +
14683        // caminho + byte verbatim.
14684        let d = dep_with_fonte(DepSource::Path {
14685            caminho: "../caixa%20teia".into(),
14686        });
14687        let err = d.validate().unwrap_err();
14688        let DepError::FonteCaminhoUrlPercentEncoding {
14689            nome,
14690            caminho,
14691            byte,
14692        } = err
14693        else {
14694            panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
14695        };
14696        assert_eq!(nome, "caixa-teia");
14697        assert_eq!(caminho, "../caixa%20teia");
14698        assert_eq!(byte, b'%');
14699    }
14700
14701    #[test]
14702    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
14703        // The over-encoded path-separator shape (`"../caixa%2Fteia"`
14704        // intending the `%2F` as the URL encoding of `/`) locks a
14705        // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
14706        // the byte-identical `path:../caixa/teia` form. Pinned
14707        // separately from the space-encoded shape so the gate's
14708        // coverage extends past the single canonical `%20` example
14709        // to any two-hex-digit percent-encoded sequence.
14710        let d = dep_with_fonte(DepSource::Path {
14711            caminho: "../caixa%2Fteia".into(),
14712        });
14713        let err = d.validate().unwrap_err();
14714        assert!(
14715            matches!(
14716                err,
14717                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14718            ),
14719            "got {err:?}",
14720        );
14721    }
14722
14723    #[test]
14724    fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
14725        // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
14726        // where `%` isn't followed by two hex digits) — every
14727        // WHATWG-conformant URL parser rejects the value at parse
14728        // time per RFC 3986 §2.1, but the byte would silently ride
14729        // into the lacre before the resolver subprocess crosses the
14730        // URL-parser boundary. Pinned separately from the well-
14731        // formed `%HH` shapes so the gate covers every percent-
14732        // occurrence, not only strictly-conformant escapes.
14733        let d = dep_with_fonte(DepSource::Path {
14734            caminho: "../caixa-teia%foo".into(),
14735        });
14736        let err = d.validate().unwrap_err();
14737        assert!(
14738            matches!(
14739                err,
14740                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14741            ),
14742            "got {err:?}",
14743        );
14744    }
14745
14746    #[test]
14747    fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
14748        // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
14749        // — the canonical paste-from-top-of-doc YAML directive
14750        // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
14751        // separately from embedded shapes so the gate covers the
14752        // leading-position `%` too, not only mid-value occurrences.
14753        let d = dep_with_fonte(DepSource::Path {
14754            caminho: "%YAML/../caixa-teia".into(),
14755        });
14756        let err = d.validate().unwrap_err();
14757        assert!(
14758            matches!(
14759                err,
14760                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14761            ),
14762            "got {err:?}",
14763        );
14764    }
14765
14766    #[test]
14767    fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
14768        // The printf-format-specifier paste shape
14769        // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
14770        // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
14771        // 134 format-string-injection vector). Pinned separately
14772        // from the URL-encoding shapes so the gate's rationale
14773        // extends past the RFC 3986 axis to the C / POSIX printf
14774        // format-directive-lead axis.
14775        let d = dep_with_fonte(DepSource::Path {
14776            caminho: "../caixa-%s-teia".into(),
14777        });
14778        let err = d.validate().unwrap_err();
14779        assert!(
14780            matches!(
14781                err,
14782                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14783            ),
14784            "got {err:?}",
14785        );
14786    }
14787
14788    #[test]
14789    fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
14790        // The positive-control pin: the gate targets only `%`,
14791        // never adjacent printable ASCII or POSIX-valid bytes. The
14792        // canonical relative POSIX path (`"../caixa-teia"`) and a
14793        // nested deeply-pathed variant with adjacent printable
14794        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14795        // to validate cleanly so the gate doesn't widen to a "no
14796        // printable punctuation anywhere" sweep that would defeat
14797        // the entire path-fonte author surface. Peer with
14798        // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
14799        // on the immediate-predecessor arm.
14800        let d = dep_with_fonte(DepSource::Path {
14801            caminho: "../caixa-teia/sub-dir.v2".into(),
14802        });
14803        d.validate().unwrap();
14804    }
14805
14806    #[test]
14807    fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
14808        // Cascade pin on the immediate-predecessor arm: a value
14809        // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
14810        // canonical "I pasted a URL-fragment permalink followed by a
14811        // percent-encoded space tail" footgun) routes through
14812        // `FonteCaminhoShellComment` not
14813        // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
14814        // identifier is the load-bearing downstream-truncation edit
14815        // on every probe-as-both value; same cascade discipline
14816        // every prior `:caminho` arm establishes.
14817        let d = dep_with_fonte(DepSource::Path {
14818            caminho: "../caixa-teia#pin%20".into(),
14819        });
14820        let err = d.validate().unwrap_err();
14821        assert!(
14822            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14823            "got {err:?}",
14824        );
14825    }
14826
14827    #[test]
14828    fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
14829        // Cascade pin on the upstream shell-quote-grouping arm: a
14830        // value carrying both `'` and `%` (`"../'x'%20teia"` — the
14831        // canonical "I pasted a strong-quoted literal followed by
14832        // a percent-encoded space" footgun) routes through
14833        // `FonteCaminhoShellQuoteGrouping` not
14834        // `FonteCaminhoUrlPercentEncoding`. The shell-string-
14835        // literal-delimiter is the load-bearing root-cause edit on
14836        // every probe-as-both value.
14837        let d = dep_with_fonte(DepSource::Path {
14838            caminho: "../'x'%20teia".into(),
14839        });
14840        let err = d.validate().unwrap_err();
14841        assert!(
14842            matches!(
14843                err,
14844                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14845            ),
14846            "got {err:?}",
14847        );
14848    }
14849
14850    #[test]
14851    fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
14852        // Cascade pin on the upstream backslash arm: a value
14853        // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
14854        // canonical "I pasted a Windows-shell path followed by a
14855        // percent-encoded space" footgun) routes through
14856        // `FonteCaminhoBackslash` not
14857        // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
14858        // separator divergence is the load-bearing root-cause edit
14859        // on every probe-as-both value.
14860        let d = dep_with_fonte(DepSource::Path {
14861            caminho: "..\\caixa%20teia".into(),
14862        });
14863        let err = d.validate().unwrap_err();
14864        assert!(
14865            matches!(err, DepError::FonteCaminhoBackslash { .. }),
14866            "got {err:?}",
14867        );
14868    }
14869
14870    #[test]
14871    fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
14872        // Cascade pin on the upstream control-char arm: a value
14873        // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
14874        // the canonical "I pasted a paste-from-binary-blob path
14875        // followed by a percent-encoded space" footgun) routes
14876        // through `FonteCaminhoControlChar` not
14877        // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
14878        // rejected byte is the load-bearing root-cause edit on
14879        // every probe-as-both value.
14880        let d = dep_with_fonte(DepSource::Path {
14881            caminho: "../caixa\0%20teia".into(),
14882        });
14883        let err = d.validate().unwrap_err();
14884        assert!(
14885            matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
14886            "got {err:?}",
14887        );
14888    }
14889
14890    #[test]
14891    fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
14892        // Cascade pin on the upstream absolute-path arm: a value
14893        // that's both absolute and carries `%` (`"/etc/passwd%20"`
14894        // — the canonical "I pasted an absolute path with a
14895        // percent-encoded space tail" footgun) routes through
14896        // `FonteCaminhoAbsolute` not
14897        // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
14898        // the load-bearing root-cause edit on every probe-as-both
14899        // value.
14900        let d = dep_with_fonte(DepSource::Path {
14901            caminho: "/etc/passwd%20".into(),
14902        });
14903        let err = d.validate().unwrap_err();
14904        assert!(
14905            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14906            "got {err:?}",
14907        );
14908    }
14909
14910    #[test]
14911    fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
14912        // Cascade pin on the upstream var-expansion arm: a value
14913        // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
14914        // — the canonical "I pasted a `$HOME`-rooted path with a
14915        // percent-encoded space" footgun) routes through
14916        // `FonteCaminhoVarExpansion` not
14917        // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
14918        // expansion is the load-bearing root-cause edit on every
14919        // probe-as-both value.
14920        let d = dep_with_fonte(DepSource::Path {
14921            caminho: "$HOME/caixa%20teia".into(),
14922        });
14923        let err = d.validate().unwrap_err();
14924        assert!(
14925            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14926            "got {err:?}",
14927        );
14928    }
14929
14930    #[test]
14931    fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
14932        // Cascade pin on the immediate-successor arm: a value
14933        // carrying both `%` and a trailing `/`
14934        // (`"../caixa%20teia/"` — the canonical "I tab-completed a
14935        // percent-encoded-space-carrying path" footgun) routes
14936        // through `FonteCaminhoUrlPercentEncoding` not
14937        // `FonteCaminhoTrailingSlash`. The embedded percent-
14938        // encoding-escape byte is the more semantic-locating axis
14939        // (an author who decodes the `%20` to a literal space is
14940        // likely to also tab-strip the trailing separator since
14941        // both are paste-from-URL / paste-from-shell-tab-completion
14942        // artifacts).
14943        let d = dep_with_fonte(DepSource::Path {
14944            caminho: "../caixa%20teia/".into(),
14945        });
14946        let err = d.validate().unwrap_err();
14947        assert!(
14948            matches!(
14949                err,
14950                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14951            ),
14952            "got {err:?}",
14953        );
14954    }
14955
14956    #[test]
14957    fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
14958        // Diagnostic-shape pin (peer with
14959        // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
14960        // on the immediate-predecessor arm): the error's Display
14961        // surfaces the offending `:nome`, the offending `:caminho`
14962        // verbatim, the offending byte's hex / character form, and
14963        // names the URL-percent-encoding-escape / printf-format-
14964        // specifier footgun explicitly so a `feira lint` run can
14965        // render the diagnostic without re-parsing.
14966        let d = dep_with_fonte(DepSource::Path {
14967            caminho: "../caixa%20teia".into(),
14968        });
14969        let rendered = d.validate().unwrap_err().to_string();
14970        assert!(
14971            rendered.contains("caixa-teia"),
14972            "diagnostic must name the offending dep: {rendered}",
14973        );
14974        assert!(
14975            rendered.contains("../caixa%20teia"),
14976            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14977        );
14978        assert!(
14979            rendered.contains("0x25"),
14980            "diagnostic must surface the offending byte hex: {rendered:?}",
14981        );
14982        assert!(
14983            rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
14984            "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
14985        );
14986        assert!(
14987            rendered.contains("printf") || rendered.contains("format-specifier"),
14988            "diagnostic must reference the printf-format-specifier vocabulary: \
14989             {rendered:?}",
14990        );
14991    }
14992
14993    #[test]
14994    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
14995        // The canonical embedded-`$` shell-variable-expansion paste
14996        // shape (`"../foo$HOME/bar"` — an author copies a partially-
14997        // substituted shell one-liner where the leading segment is a
14998        // literal `../foo` while the mid segment carries the un-
14999        // substituted `$HOME` template). The leading-`$` position is
15000        // already gated by the f4efe9c leading-byte arm which routes
15001        // through `FonteCaminhoVarExpansion`; this arm closes the
15002        // last positional gap on `$` — every position on the axis is
15003        // structurally rejected.
15004        let d = dep_with_fonte(DepSource::Path {
15005            caminho: "../foo$HOME/bar".into(),
15006        });
15007        let err = d.validate().unwrap_err();
15008        let DepError::FonteCaminhoShellVariableExpansion {
15009            nome,
15010            caminho,
15011            byte,
15012        } = err
15013        else {
15014            panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
15015        };
15016        assert_eq!(nome, "caixa-teia");
15017        assert_eq!(caminho, "../foo$HOME/bar");
15018        assert_eq!(byte, b'$');
15019    }
15020
15021    #[test]
15022    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
15023        // The symmetric braced-CI-manifest paste shape
15024        // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
15025        // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
15026        // footgun). Pinned separately from the bare-`$VAR` shape so
15027        // the gate covers both POSIX shell §2.6 Parameter Expansion
15028        // syntactic forms, not only the unbraced variant. The
15029        // embedded `{` byte in `${...}` is also caught by the 598b770
15030        // shell-brace-expansion arm but that arm fires earlier in
15031        // the cascade — the `$` arm's coverage extends to `${...}`
15032        // structurally, so the diagnostic asserted here is the
15033        // brace-expansion one (which is a valid outcome; the point
15034        // of the pin is that the value never survives validation).
15035        let d = dep_with_fonte(DepSource::Path {
15036            caminho: "../foo${WORKSPACE}/bar".into(),
15037        });
15038        let err = d.validate().unwrap_err();
15039        assert!(
15040            matches!(
15041                err,
15042                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
15043                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15044            ),
15045            "got {err:?}",
15046        );
15047    }
15048
15049    #[test]
15050    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
15051        // The paste-from-shell-prompt command-substitution idiom
15052        // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
15053        // `$VAR` shape so the gate's rationale extends to POSIX shell
15054        // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
15055        // legacy `` `<cmd>` `` form is already closed by the c370458
15056        // backtick arm). The embedded `(` byte in `$(...)` is also
15057        // caught structurally by the 0633c91 shell-subshell-grouping
15058        // arm which fires earlier in the cascade — the diagnostic
15059        // asserted here is either outcome, since both structurally
15060        // reject the value; the point of the pin is that the value
15061        // never survives validation.
15062        let d = dep_with_fonte(DepSource::Path {
15063            caminho: "../foo$(whoami)/bar".into(),
15064        });
15065        let err = d.validate().unwrap_err();
15066        assert!(
15067            matches!(
15068                err,
15069                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
15070                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15071            ),
15072            "got {err:?}",
15073        );
15074    }
15075
15076    #[test]
15077    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
15078        // The paste-from-`Makefile` / paste-from-SQL-migration bare-
15079        // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
15080        // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
15081        // idiom copied into a caminho template). None of the prior
15082        // shell-metachar arms cover this shape (`1` is a bare digit;
15083        // no `(` / `{` / letter follows the `$`), so the arm is the
15084        // sole gate on the shape.
15085        let d = dep_with_fonte(DepSource::Path {
15086            caminho: "../foo$1/bar".into(),
15087        });
15088        let err = d.validate().unwrap_err();
15089        assert!(
15090            matches!(
15091                err,
15092                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15093            ),
15094            "got {err:?}",
15095        );
15096    }
15097
15098    #[test]
15099    fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
15100        // The positive-control pin (peer with
15101        // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
15102        // on the immediate-predecessor arm): the gate targets only
15103        // `$`, never adjacent printable ASCII or POSIX-valid bytes.
15104        // A relative POSIX path carrying dashes / dots / slashes /
15105        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
15106        // validate cleanly so the gate doesn't widen to a "no
15107        // printable punctuation anywhere" sweep that would defeat
15108        // the entire path-fonte author surface.
15109        let d = dep_with_fonte(DepSource::Path {
15110            caminho: "../caixa-teia/sub-dir.v2".into(),
15111        });
15112        d.validate().unwrap();
15113    }
15114
15115    #[test]
15116    fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
15117        // Cascade pin on the leading-`$` sibling arm at line 540: a
15118        // value starting with `$` and carrying an embedded `$` too
15119        // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
15120        // fully-templated CI path with two un-substituted variables")
15121        // routes through `FonteCaminhoVarExpansion` not
15122        // `FonteCaminhoShellVariableExpansion`. The leading-byte
15123        // host-layout-leak is the load-bearing self-locating axis
15124        // (the leading position dominates the semantic-locating
15125        // rationale on every probe-as-both value); the embedded
15126        // arm's positional-agnostic sweep catches only values whose
15127        // leading byte doesn't route through the earlier leading-
15128        // byte arms.
15129        let d = dep_with_fonte(DepSource::Path {
15130            caminho: "$HOME/foo$WORKSPACE/bar".into(),
15131        });
15132        let err = d.validate().unwrap_err();
15133        assert!(
15134            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
15135            "got {err:?}",
15136        );
15137    }
15138
15139    #[test]
15140    fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
15141        // Cascade pin on the immediate-predecessor arm: a value
15142        // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
15143        // — the canonical "I pasted a percent-encoded space adjacent
15144        // to a `$HOME` template") routes through
15145        // `FonteCaminhoUrlPercentEncoding` not
15146        // `FonteCaminhoShellVariableExpansion`. The URL-percent-
15147        // encoding-escape byte is the more semantic-locating axis
15148        // (the paste-from-browser-address-bar shape is the load-
15149        // bearing self-locating edit); same cascade discipline every
15150        // prior `:caminho` arm establishes.
15151        let d = dep_with_fonte(DepSource::Path {
15152            caminho: "../foo%20$HOME/bar".into(),
15153        });
15154        let err = d.validate().unwrap_err();
15155        assert!(
15156            matches!(
15157                err,
15158                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
15159            ),
15160            "got {err:?}",
15161        );
15162    }
15163
15164    #[test]
15165    fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
15166        // Cascade pin on the immediate-successor arm: a value
15167        // carrying both embedded `$` and a trailing `/`
15168        // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
15169        // `$HOME`-template-carrying path") routes through
15170        // `FonteCaminhoShellVariableExpansion` not
15171        // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
15172        // expansion byte is the more semantic-locating axis on
15173        // probe-as-both values (an author who substitutes the
15174        // `$HOME` template with a literal value is likely to also
15175        // tab-strip the trailing separator).
15176        let d = dep_with_fonte(DepSource::Path {
15177            caminho: "../foo$HOME/bar/".into(),
15178        });
15179        let err = d.validate().unwrap_err();
15180        assert!(
15181            matches!(
15182                err,
15183                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15184            ),
15185            "got {err:?}",
15186        );
15187    }
15188
15189    #[test]
15190    fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
15191        // Diagnostic-shape pin (peer with
15192        // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
15193        // on the immediate-predecessor arm): the error's Display
15194        // surfaces the offending `:nome`, the offending `:caminho`
15195        // verbatim, the offending byte's hex / character form, and
15196        // names the shell-variable-expansion / command-substitution
15197        // footgun explicitly so a `feira lint` run can render the
15198        // diagnostic without re-parsing.
15199        let d = dep_with_fonte(DepSource::Path {
15200            caminho: "../foo$HOME/bar".into(),
15201        });
15202        let rendered = d.validate().unwrap_err().to_string();
15203        assert!(
15204            rendered.contains("caixa-teia"),
15205            "diagnostic must name the offending dep: {rendered}",
15206        );
15207        assert!(
15208            rendered.contains("../foo$HOME/bar"),
15209            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15210        );
15211        assert!(
15212            rendered.contains("0x24"),
15213            "diagnostic must surface the offending byte hex: {rendered:?}",
15214        );
15215        assert!(
15216            rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
15217            "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
15218        );
15219        assert!(
15220            rendered.contains("command-substitution") || rendered.contains("command substitution"),
15221            "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
15222        );
15223    }
15224
15225    #[test]
15226    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
15227        // The fail-before-pass-after pin for the canonical paste-from-
15228        // shell-history footgun on `:caminho`. An author copies a `cd
15229        // ../caixa-teia && !sudo make install` one-liner from a quick-
15230        // start README, intending the trailing `!sudo` as a shell-
15231        // history-expansion reference but the typed slot is itself a
15232        // byte-level string parser, not a shell context, so the byte
15233        // rides into the value verbatim. Until this arm landed the `!`
15234        // byte silently passed every prior `:caminho` cascade arm
15235        // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
15236        // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
15237        // `#` / `%` / `$`); bash with the default `histexpand` mode
15238        // rewrites `!command` to the most recent history entry
15239        // beginning with `command`, the canonical RCE-class injection
15240        // vector when the byte rides into a shell argument executed
15241        // under `bash -i` (the operator-notebook interactive shell).
15242        let d = dep_with_fonte(DepSource::Path {
15243            caminho: "../caixa-teia!sudo".into(),
15244        });
15245        let err = d.validate().unwrap_err();
15246        let DepError::FonteCaminhoShellHistoryExpansion {
15247            nome,
15248            caminho,
15249            byte,
15250        } = err
15251        else {
15252            panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
15253        };
15254        assert_eq!(nome, "caixa-teia");
15255        assert_eq!(caminho, "../caixa-teia!sudo");
15256        assert_eq!(byte, b'!');
15257    }
15258
15259    #[test]
15260    fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
15261        // The symmetric `!!` repeat-prior-command paste idiom (peer with
15262        // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
15263        // on `is_git_repo_url`). Pinned separately from the wrapped
15264        // `!command` shape so a future diagnostic-surface change that
15265        // only checked the leading or paired-bang position surfaces
15266        // here — the per-byte arm fires anywhere `!` appears in the
15267        // value, including at consecutive positions in the middle.
15268        let d = dep_with_fonte(DepSource::Path {
15269            caminho: "../foo!!/bar".into(),
15270        });
15271        let err = d.validate().unwrap_err();
15272        assert!(
15273            matches!(
15274                err,
15275                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15276            ),
15277            "got {err:?}",
15278        );
15279    }
15280
15281    #[test]
15282    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
15283        // The English-typography enthusiasm-form paste-from-prose
15284        // idiom: an author writes `:caminho "../caixa-teia!"`
15285        // expecting the substrate to coerce it to a kebab-case slug.
15286        // Pinned separately from the `!<word>` shell-history shape so
15287        // the gate's rationale extends to the paste-from-prose surface
15288        // (the same rationale the peer `is_git_repo_url` bang arm at
15289        // 7d53c68 covers). None of the prior shell-metachar arms cover
15290        // this shape (no `!<word>` reference and no `!!` repeat), so
15291        // the arm is the sole gate on the shape.
15292        let d = dep_with_fonte(DepSource::Path {
15293            caminho: "../caixa-teia!".into(),
15294        });
15295        let err = d.validate().unwrap_err();
15296        assert!(
15297            matches!(
15298                err,
15299                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15300            ),
15301            "got {err:?}",
15302        );
15303    }
15304
15305    #[test]
15306    fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
15307        // The positive-control pin (peer with
15308        // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
15309        // on the immediate-predecessor arm): the gate targets only
15310        // `!`, never adjacent printable ASCII or POSIX-valid bytes.
15311        // A relative POSIX path carrying dashes / dots / slashes /
15312        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
15313        // validate cleanly so the gate doesn't widen to a "no
15314        // printable punctuation anywhere" sweep that would defeat
15315        // the entire path-fonte author surface.
15316        let d = dep_with_fonte(DepSource::Path {
15317            caminho: "../caixa-teia/sub-dir.v2".into(),
15318        });
15319        d.validate().unwrap();
15320    }
15321
15322    #[test]
15323    fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
15324        // Cascade pin on the immediate-predecessor arm: a value
15325        // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
15326        // — the canonical "I pasted a `$HOME`-templated path adjacent
15327        // to a trailing `!sudo` history-expansion") routes through
15328        // `FonteCaminhoShellVariableExpansion` not
15329        // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
15330        // expansion byte is the more semantic-locating axis on
15331        // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
15332        // template shape is the load-bearing self-locating edit);
15333        // same cascade discipline every prior `:caminho` arm
15334        // establishes.
15335        let d = dep_with_fonte(DepSource::Path {
15336            caminho: "../foo$HOME/bar!sudo".into(),
15337        });
15338        let err = d.validate().unwrap_err();
15339        assert!(
15340            matches!(
15341                err,
15342                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15343            ),
15344            "got {err:?}",
15345        );
15346    }
15347
15348    #[test]
15349    fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
15350        // Cascade pin on the immediate-successor arm: a value carrying
15351        // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
15352        // — the canonical "I tab-completed a `!sudo`-carrying path")
15353        // routes through `FonteCaminhoShellHistoryExpansion` not
15354        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15355        // expansion byte is the more semantic-locating axis on probe-
15356        // as-both values (an author who removes the `!sudo` history
15357        // reference is likely to also tab-strip the trailing separator).
15358        let d = dep_with_fonte(DepSource::Path {
15359            caminho: "../caixa-teia!sudo/".into(),
15360        });
15361        let err = d.validate().unwrap_err();
15362        assert!(
15363            matches!(
15364                err,
15365                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15366            ),
15367            "got {err:?}",
15368        );
15369    }
15370
15371    #[test]
15372    fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
15373        // Diagnostic-shape pin (peer with
15374        // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15375        // on the immediate-predecessor arm): the error's Display
15376        // surfaces the offending `:nome`, the offending `:caminho`
15377        // verbatim, the offending byte's hex / character form, and
15378        // names the shell-history-expansion / bang-operator footgun
15379        // explicitly so a `feira lint` run can render the diagnostic
15380        // without re-parsing.
15381        let d = dep_with_fonte(DepSource::Path {
15382            caminho: "../caixa-teia!sudo".into(),
15383        });
15384        let rendered = d.validate().unwrap_err().to_string();
15385        assert!(
15386            rendered.contains("caixa-teia"),
15387            "diagnostic must name the offending dep: {rendered}",
15388        );
15389        assert!(
15390            rendered.contains("../caixa-teia!sudo"),
15391            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15392        );
15393        assert!(
15394            rendered.contains("0x21"),
15395            "diagnostic must surface the offending byte hex: {rendered:?}",
15396        );
15397        assert!(
15398            rendered.contains("history-expansion") || rendered.contains("history expansion"),
15399            "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
15400        );
15401        assert!(
15402            rendered.contains("bang"),
15403            "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
15404        );
15405    }
15406
15407    #[test]
15408    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
15409        // The fail-before-pass-after pin for the canonical paste-from-
15410        // shell-history-quick-substitution footgun on `:caminho`. An
15411        // author copies a `git clone <bad-url>` line from their terminal,
15412        // corrects it via bash's `^bad^good` quick-substitution history
15413        // operator (bash reference §9.3, `set -o histexpand` mode's
15414        // default for interactive sessions), and pastes the trailing
15415        // `^bad^good` substitution fragment into a `:caminho` value
15416        // without trimming the leading `git clone` prefix — the byte
15417        // rides into the manifest verbatim. Until this arm landed the
15418        // `^` byte silently passed every prior `:caminho` cascade arm
15419        // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
15420        // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
15421        // `%` / `$` / `!`); bash with the default `histexpand` mode
15422        // rewrites the prior command's `bad` string to `good` and re-
15423        // executes it, the paired-operator half of the `set -o
15424        // histexpand` feature the peer `!` arm already closes the prefix
15425        // half of. The peer `is_git_repo_url` axis rejects the byte at
15426        // 49e142f under the same shell-history-substitution / RFC-3986-
15427        // unwise banner.
15428        let d = dep_with_fonte(DepSource::Path {
15429            caminho: "../foo^bad^good".into(),
15430        });
15431        let err = d.validate().unwrap_err();
15432        let DepError::FonteCaminhoShellHistorySubstitution {
15433            nome,
15434            caminho,
15435            byte,
15436        } = err
15437        else {
15438            panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
15439        };
15440        assert_eq!(nome, "caixa-teia");
15441        assert_eq!(caminho, "../foo^bad^good");
15442        assert_eq!(byte, b'^');
15443    }
15444
15445    #[test]
15446    fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
15447        // The symmetric paste-from-doc-grep-pipeline footgun (peer with
15448        // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
15449        // on `is_git_repo_url`). An author copies a `grep '^archived'`
15450        // regex-anchor / negation idiom from a doc snippet and the byte
15451        // rides in verbatim. Pinned separately from the `^old^new^`
15452        // quick-substitution shape so a future diagnostic-surface change
15453        // that only checked the paired-caret history-substitution
15454        // position surfaces here — the per-byte arm fires anywhere `^`
15455        // appears in the value, including at a solitary leading-of-
15456        // segment position.
15457        let d = dep_with_fonte(DepSource::Path {
15458            caminho: "../foo/^archived".into(),
15459        });
15460        let err = d.validate().unwrap_err();
15461        assert!(
15462            matches!(
15463                err,
15464                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15465            ),
15466            "got {err:?}",
15467        );
15468    }
15469
15470    #[test]
15471    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
15472        // The trailing-`^` history-substitution-open shape — an author
15473        // starts typing a `^bad^good` quick-substitution but pastes only
15474        // the leading `^` sentinel before context-switching (a bash-
15475        // reference §9.3 valid histexpand prefix on its own — even a
15476        // solitary `^` on the prior command's whole re-execution shape).
15477        // Pinned separately from the `^old^new^` full-form and the leading-
15478        // of-segment `^archived` regex-anchor shape so the gate's
15479        // rationale extends to the paste-from-shell-history-with-only-
15480        // the-first-byte-selected surface. None of the prior shell-
15481        // metachar arms cover this shape.
15482        let d = dep_with_fonte(DepSource::Path {
15483            caminho: "../caixa-teia^".into(),
15484        });
15485        let err = d.validate().unwrap_err();
15486        assert!(
15487            matches!(
15488                err,
15489                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15490            ),
15491            "got {err:?}",
15492        );
15493    }
15494
15495    #[test]
15496    fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
15497        // The positive-control pin (peer with
15498        // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
15499        // on the immediate-predecessor arm): the gate targets only
15500        // `^`, never adjacent printable ASCII or POSIX-valid bytes.
15501        // A relative POSIX path carrying dashes / dots / slashes /
15502        // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
15503        // continue to validate cleanly so the gate doesn't widen to
15504        // a "no printable punctuation anywhere" sweep that would
15505        // defeat the entire path-fonte author surface.
15506        let d = dep_with_fonte(DepSource::Path {
15507            caminho: "../caixa-teia/sub_v2.rc".into(),
15508        });
15509        d.validate().unwrap();
15510    }
15511
15512    #[test]
15513    fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
15514        // Cascade pin on the immediate-predecessor arm: a value carrying
15515        // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
15516        // canonical "I pasted a `!sudo` history-reference next to a
15517        // `^bad^good` quick-substitution") routes through
15518        // `FonteCaminhoShellHistoryExpansion` not
15519        // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
15520        // the more semantic-locating axis on probe-as-both values (an
15521        // author who removes the `!sudo` reference is likely to also
15522        // strip the paired `^` substitution fragment); same cascade
15523        // discipline every prior `:caminho` arm establishes.
15524        let d = dep_with_fonte(DepSource::Path {
15525            caminho: "../foo!sudo^bad^good".into(),
15526        });
15527        let err = d.validate().unwrap_err();
15528        assert!(
15529            matches!(
15530                err,
15531                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15532            ),
15533            "got {err:?}",
15534        );
15535    }
15536
15537    #[test]
15538    fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
15539        // Cascade pin on the immediate-successor arm: a value carrying
15540        // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
15541        // the canonical "I tab-completed a `^bad^good`-carrying path")
15542        // routes through `FonteCaminhoShellHistorySubstitution` not
15543        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15544        // substitution byte is the more semantic-locating axis on probe-
15545        // as-both values (an author who removes the `^bad^good`
15546        // substitution fragment is likely to also tab-strip the trailing
15547        // separator).
15548        let d = dep_with_fonte(DepSource::Path {
15549            caminho: "../foo^bad^good/".into(),
15550        });
15551        let err = d.validate().unwrap_err();
15552        assert!(
15553            matches!(
15554                err,
15555                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15556            ),
15557            "got {err:?}",
15558        );
15559    }
15560
15561    #[test]
15562    fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
15563    {
15564        // Diagnostic-shape pin (peer with
15565        // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15566        // on the immediate-predecessor arm): the error's Display
15567        // surfaces the offending `:nome`, the offending `:caminho`
15568        // verbatim, the offending byte's hex form, and names the
15569        // shell-history-substitution / RFC-3986-'unwise' / regex-
15570        // negation footgun explicitly so a `feira lint` run can render
15571        // the diagnostic without re-parsing.
15572        let d = dep_with_fonte(DepSource::Path {
15573            caminho: "../foo^bad^good".into(),
15574        });
15575        let rendered = d.validate().unwrap_err().to_string();
15576        assert!(
15577            rendered.contains("caixa-teia"),
15578            "diagnostic must name the offending dep: {rendered}",
15579        );
15580        assert!(
15581            rendered.contains("../foo^bad^good"),
15582            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15583        );
15584        assert!(
15585            rendered.contains("0x5e") || rendered.contains("0x5E"),
15586            "diagnostic must surface the offending byte hex: {rendered:?}",
15587        );
15588        assert!(
15589            rendered.contains("history-substitution") || rendered.contains("history substitution"),
15590            "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
15591        );
15592        assert!(
15593            rendered.contains("unwise"),
15594            "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
15595        );
15596    }
15597
15598    #[test]
15599    fn fonte_repo_empty_fires_before_pin_missing() {
15600        // Order pin: empty `:repo` is the more self-locating diagnostic
15601        // (every git source needs a repo; the pin discussion is
15602        // secondary), so it fires before the pin-missing arm even when
15603        // both are violated. Mirrors the
15604        // `nome_empty_takes_precedence_over_versao_invalid` ordering
15605        // discipline on the per-entry layer.
15606        let d = dep_with_fonte(DepSource::Git {
15607            repo: String::new(),
15608            tag: None,
15609            rev: None,
15610            branch: None,
15611        });
15612        let err = d.validate().unwrap_err();
15613        assert!(
15614            matches!(err, DepError::FonteRepoEmpty { .. }),
15615            "got {err:?}"
15616        );
15617    }
15618
15619    #[test]
15620    fn fonte_pin_missing_fires_before_pin_empty() {
15621        // Order pin: a fully-None pin set is structurally distinct from
15622        // a Some(empty) pin — the first surfaces as FontePinMissing
15623        // (no axis chosen), the second as FontePinEmpty (axis chosen
15624        // but value blank). Pin the disjoint relationship so a future
15625        // unification collapses to one variant only as a structural
15626        // decision.
15627        let d = dep_with_fonte(DepSource::Git {
15628            repo: "github:pleme-io/caixa-teia".into(),
15629            tag: None,
15630            rev: None,
15631            branch: None,
15632        });
15633        assert!(matches!(
15634            d.validate().unwrap_err(),
15635            DepError::FontePinMissing { .. }
15636        ));
15637    }
15638
15639    #[test]
15640    fn nome_empty_takes_precedence_over_fonte_invalid() {
15641        // Order pin: a per-entry diagnostic without a non-empty :nome
15642        // can't be self-locating, so :nome "" fires first even when
15643        // :fonte is also malformed. Mirrors
15644        // `nome_empty_takes_precedence_over_versao_invalid` on the
15645        // adjacent axis.
15646        let mut d = dep_with_fonte(DepSource::Git {
15647            repo: String::new(),
15648            tag: None,
15649            rev: None,
15650            branch: None,
15651        });
15652        d.nome = String::new();
15653        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
15654    }
15655
15656    #[test]
15657    fn versao_invalid_takes_precedence_over_fonte_invalid() {
15658        // Order pin: the :versao parse-side diagnostic is narrower than
15659        // the :fonte shape diagnostic — a malformed :versao always names
15660        // the parser's reason, which is more actionable than the
15661        // :fonte gate's "the pins are wrong" wording. Pin the ordering
15662        // so a re-ordering surfaces here.
15663        let mut d = dep_with_fonte(DepSource::Git {
15664            repo: String::new(),
15665            tag: None,
15666            rev: None,
15667            branch: None,
15668        });
15669        d.versao = "v0.1".into();
15670        let err = d.validate().unwrap_err();
15671        assert!(
15672            matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
15673            "got {err:?}"
15674        );
15675    }
15676
15677    #[test]
15678    fn fonte_invalid_diagnostic_carries_offending_nome() {
15679        // The diagnostic-shape pin: every :fonte error variant names
15680        // the offending dep's :nome verbatim, so the author can grep
15681        // caixa.lisp for the `:nome "<n>"` block and fix it in one
15682        // edit. Cover all seven variants so a future variant addition
15683        // forces a parallel diagnostic-shape decision.
15684        for (case, fonte) in [
15685            (
15686                "repo-empty",
15687                DepSource::Git {
15688                    repo: String::new(),
15689                    tag: Some("v1".into()),
15690                    rev: None,
15691                    branch: None,
15692                },
15693            ),
15694            (
15695                "repo-shape",
15696                DepSource::Git {
15697                    repo: "github:p/x ".into(),
15698                    tag: Some("v1".into()),
15699                    rev: None,
15700                    branch: None,
15701                },
15702            ),
15703            (
15704                "pin-missing",
15705                DepSource::Git {
15706                    repo: "github:p/x".into(),
15707                    tag: None,
15708                    rev: None,
15709                    branch: None,
15710                },
15711            ),
15712            (
15713                "pin-ambiguous",
15714                DepSource::Git {
15715                    repo: "github:p/x".into(),
15716                    tag: Some("v1".into()),
15717                    rev: None,
15718                    branch: Some("main".into()),
15719                },
15720            ),
15721            (
15722                "pin-empty",
15723                DepSource::Git {
15724                    repo: "github:p/x".into(),
15725                    tag: Some(String::new()),
15726                    rev: None,
15727                    branch: None,
15728                },
15729            ),
15730            (
15731                "caminho-empty",
15732                DepSource::Path {
15733                    caminho: String::new(),
15734                },
15735            ),
15736            (
15737                "caminho-absolute",
15738                DepSource::Path {
15739                    caminho: "/home/me/work/caixa-teia".into(),
15740                },
15741            ),
15742        ] {
15743            let d = dep_with_fonte(fonte);
15744            let msg = d
15745                .validate()
15746                .expect_err(&format!("{case}: expected fonte error"))
15747                .to_string();
15748            assert!(
15749                msg.contains("\"caixa-teia\""),
15750                "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15751            );
15752        }
15753    }
15754
15755    // -- :tag / :branch value-shape gate ----------------------------------
15756
15757    #[test]
15758    fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
15759        // The canonical paste-from-doc footgun on `:tag` — author
15760        // copies `"v0.1.0 "` (trailing space) out of a release-notes
15761        // paragraph. Until this gate landed the empty-pin arm passed
15762        // (the string isn't empty), the resolver issued
15763        // `git fetch <remote> tag 'v0.1.0 '`, and the failure
15764        // surfaced at clone time with a quoting-confused git error
15765        // far from the source caixa.lisp. The new gate moves the
15766        // check to caixa-build time and names the offending dep +
15767        // pin + value verbatim.
15768        let d = dep_with_fonte(DepSource::Git {
15769            repo: "github:pleme-io/caixa-teia".into(),
15770            tag: Some("v0.1.0 ".into()),
15771            rev: None,
15772            branch: None,
15773        });
15774        let err = d.validate().unwrap_err();
15775        let DepError::FontePinShape {
15776            nome,
15777            pin,
15778            value,
15779            reason,
15780        } = err
15781        else {
15782            panic!("expected FontePinShape, got other variant");
15783        };
15784        assert_eq!(nome, "caixa-teia");
15785        assert_eq!(pin, ":tag");
15786        assert_eq!(value, "v0.1.0 ");
15787        assert!(
15788            reason.contains("whitespace"),
15789            "reason must surface the whitespace arm, got {reason:?}"
15790        );
15791    }
15792
15793    #[test]
15794    fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
15795        // The `.lock` suffix is git's atomic-rename guard for
15796        // in-flight ref updates — a refname ending in `.lock` is
15797        // unwritable on disk. Pinned separately from the whitespace
15798        // arm so a future relaxation that admits one but not the
15799        // other surfaces here.
15800        let d = dep_with_fonte(DepSource::Git {
15801            repo: "github:pleme-io/caixa-teia".into(),
15802            tag: Some("v0.1.0.lock".into()),
15803            rev: None,
15804            branch: None,
15805        });
15806        let err = d.validate().unwrap_err();
15807        let DepError::FontePinShape {
15808            pin, value, reason, ..
15809        } = err
15810        else {
15811            panic!("expected FontePinShape, got other variant");
15812        };
15813        assert_eq!(pin, ":tag");
15814        assert_eq!(value, "v0.1.0.lock");
15815        assert!(
15816            reason.contains(".lock"),
15817            "reason must surface the .lock arm, got {reason:?}"
15818        );
15819    }
15820
15821    #[test]
15822    fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
15823        // The canonical "branch name with spaces" footgun (`feature
15824        // foo`, `release branch`) — git's refname parser rejects raw
15825        // whitespace, and the failure surfaces at `git checkout
15826        // 'feature foo'` time with a quoting-confused error far from
15827        // the source caixa.lisp. Pinned on the `:branch` axis so the
15828        // gate-applies-to-both-:tag-and-:branch contract is a build-
15829        // error to relax.
15830        let d = dep_with_fonte(DepSource::Git {
15831            repo: "github:pleme-io/caixa-teia".into(),
15832            tag: None,
15833            rev: None,
15834            branch: Some("feature/foo bar".into()),
15835        });
15836        let err = d.validate().unwrap_err();
15837        let DepError::FontePinShape {
15838            pin, value, reason, ..
15839        } = err
15840        else {
15841            panic!("expected FontePinShape, got other variant");
15842        };
15843        assert_eq!(pin, ":branch");
15844        assert_eq!(value, "feature/foo bar");
15845        assert!(
15846            reason.contains("whitespace"),
15847            "reason must surface the whitespace arm, got {reason:?}"
15848        );
15849    }
15850
15851    #[test]
15852    fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
15853        // The `refs/heads/main` shape — the canonical "I copied the
15854        // fully-qualified ref out of `git show-ref` instead of the
15855        // leaf" footgun. The caixa-resolver prepends `refs/heads/`
15856        // at clone time, so this resolves to a literal ref named
15857        // `refs/heads/refs/heads/main` on disk; the silent double-
15858        // prefix is the load-bearing reason to gate at validate.
15859        // The diagnostic must enumerate the leaf the author probably
15860        // meant (`"main"`) so the fix is one edit.
15861        let d = dep_with_fonte(DepSource::Git {
15862            repo: "github:pleme-io/caixa-teia".into(),
15863            tag: None,
15864            rev: None,
15865            branch: Some("refs/heads/main".into()),
15866        });
15867        let err = d.validate().unwrap_err();
15868        let DepError::FontePinShape {
15869            pin, value, reason, ..
15870        } = err
15871        else {
15872            panic!("expected FontePinShape, got other variant");
15873        };
15874        assert_eq!(pin, ":branch");
15875        assert_eq!(value, "refs/heads/main");
15876        assert!(
15877            reason.contains("fully-qualified"),
15878            "reason must surface the qualified-prefix arm, got {reason:?}"
15879        );
15880        assert!(
15881            reason.contains("\"main\""),
15882            "reason must quote the leaf the author probably meant, got {reason:?}"
15883        );
15884    }
15885
15886    #[test]
15887    fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
15888        // Sibling arm of the qualified-prefix gate on the `:tag`
15889        // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
15890        // footgun). Pinned separately so a future relaxation that
15891        // only catches the `:branch` arm surfaces here.
15892        let d = dep_with_fonte(DepSource::Git {
15893            repo: "github:pleme-io/caixa-teia".into(),
15894            tag: Some("refs/tags/v0.1.0".into()),
15895            rev: None,
15896            branch: None,
15897        });
15898        let err = d.validate().unwrap_err();
15899        let DepError::FontePinShape {
15900            pin, value, reason, ..
15901        } = err
15902        else {
15903            panic!("expected FontePinShape, got other variant");
15904        };
15905        assert_eq!(pin, ":tag");
15906        assert_eq!(value, "refs/tags/v0.1.0");
15907        assert!(
15908            reason.contains("fully-qualified"),
15909            "reason must surface the qualified-prefix arm, got {reason:?}"
15910        );
15911        assert!(
15912            reason.contains("\"v0.1.0\""),
15913            "reason must quote the leaf the author probably meant, got {reason:?}"
15914        );
15915    }
15916
15917    #[test]
15918    fn validate_rejects_git_fonte_with_branch_named_at() {
15919        // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
15920        // unsourceable. Pinned so a future relaxation that admits
15921        // any single-character refname surfaces here.
15922        let d = dep_with_fonte(DepSource::Git {
15923            repo: "github:pleme-io/caixa-teia".into(),
15924            tag: None,
15925            rev: None,
15926            branch: Some("@".into()),
15927        });
15928        let err = d.validate().unwrap_err();
15929        let DepError::FontePinShape { pin, value, .. } = err else {
15930            panic!("expected FontePinShape, got other variant");
15931        };
15932        assert_eq!(pin, ":branch");
15933        assert_eq!(value, "@");
15934    }
15935
15936    #[test]
15937    fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
15938        // Git's `<rev1>..<rev2>` range grammar reserves `..` —
15939        // a `:tag "../escape"` (path-traversal-shaped slug) silently
15940        // passes parse and surfaces as a refname-parse error or, on
15941        // older git, a literal `../escape` checkout that escapes the
15942        // refs/ directory tree. Pinned separately from the
15943        // qualified-prefix arm so a future relaxation that catches
15944        // one but not the other surfaces here.
15945        let d = dep_with_fonte(DepSource::Git {
15946            repo: "github:pleme-io/caixa-teia".into(),
15947            tag: Some("../escape".into()),
15948            rev: None,
15949            branch: None,
15950        });
15951        let err = d.validate().unwrap_err();
15952        let DepError::FontePinShape { pin, value, .. } = err else {
15953            panic!("expected FontePinShape, got other variant");
15954        };
15955        assert_eq!(pin, ":tag");
15956        assert_eq!(value, "../escape");
15957    }
15958
15959    #[test]
15960    fn validate_accepts_git_fonte_with_hierarchical_branch() {
15961        // The positive-control pin: hierarchical refnames with one or
15962        // more `/` separators (the `feature/foo` / `user/jdoe/feat`
15963        // canonical idiom) round-trip through the gate. Pinned
15964        // separately from the leaf-`"main"` positive control so a
15965        // future tightening that rejects all multi-component refnames
15966        // surfaces here.
15967        let d = dep_with_fonte(DepSource::Git {
15968            repo: "github:pleme-io/caixa-teia".into(),
15969            tag: None,
15970            rev: None,
15971            branch: Some("feature/checkout-rewrite".into()),
15972        });
15973        d.validate().unwrap();
15974    }
15975
15976    #[test]
15977    fn validate_accepts_git_fonte_with_prerelease_tag() {
15978        // The positive-control pin: semver pre-release shape
15979        // (`v0.1.0-alpha.1`) — the in-component dot is allowed
15980        // (only consecutive `..` and trailing `.` are rejected), the
15981        // mid-component hyphen is allowed. Pinned separately from
15982        // the bare-`"v0.1.0"` positive control so a future tightening
15983        // that rejects pre-release tags surfaces here.
15984        let d = dep_with_fonte(DepSource::Git {
15985            repo: "github:pleme-io/caixa-teia".into(),
15986            tag: Some("v0.1.0-alpha.1".into()),
15987            rev: None,
15988            branch: None,
15989        });
15990        d.validate().unwrap();
15991    }
15992
15993    #[test]
15994    fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
15995        // The `:rev` axis is routed through `crate::render::is_git_oid`
15996        // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
15997        // value with refname-shape punctuation (here, a `:` mid-string
15998        // — would be a refname violation under `is_git_ref_name` too)
15999        // is rejected at the OID-shape gate. The two predicates
16000        // partition the `:fonte` pin axes structurally: an `:rev` value
16001        // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
16002        // *still* rejected here because every refname character outside
16003        // `[0-9a-f]` fails the OID gate. Same shape as
16004        // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
16005        // on the refname-shaped axes — the diagnostic names the
16006        // offending dep + pin + value verbatim. The flip-from-accept
16007        // case the prior `:tag`/`:branch` gate left as a "future axis"
16008        // (e70d213) — now landed.
16009        let d = dep_with_fonte(DepSource::Git {
16010            repo: "github:pleme-io/caixa-teia".into(),
16011            tag: None,
16012            rev: Some("c0ffee:notarefname".into()),
16013            branch: None,
16014        });
16015        let err = d.validate().unwrap_err();
16016        let DepError::FontePinShape {
16017            nome,
16018            pin,
16019            value,
16020            reason,
16021        } = err
16022        else {
16023            panic!("expected FontePinShape, got other variant");
16024        };
16025        assert_eq!(nome, "caixa-teia");
16026        assert_eq!(pin, ":rev");
16027        assert_eq!(value, "c0ffee:notarefname");
16028        assert!(
16029            !reason.is_empty(),
16030            "FontePinShape `reason` must carry the predicate's wording verbatim"
16031        );
16032    }
16033
16034    #[test]
16035    fn validate_accepts_git_fonte_with_rev_full_sha1() {
16036        // The positive-control pin on the SHA-1 OID width: exactly 40
16037        // lowercase hex characters — the canonical `git rev-parse HEAD`
16038        // emission on a SHA-1-hashed repository (the default on every
16039        // pre-2.42 git and the canonical pleme-io substrate hash).
16040        // Pinned separately from the SHA-256 positive control so a
16041        // future tightening that only admits one width surfaces here.
16042        let d = dep_with_fonte(DepSource::Git {
16043            repo: "github:pleme-io/caixa-teia".into(),
16044            tag: None,
16045            rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
16046            branch: None,
16047        });
16048        d.validate().unwrap();
16049    }
16050
16051    #[test]
16052    fn validate_accepts_git_fonte_with_rev_full_sha256() {
16053        // The positive-control pin on the SHA-256 OID width: exactly
16054        // 64 lowercase hex characters — `git`'s
16055        // `extensions.objectFormat = sha256` emission (GA since Git
16056        // 2.42 / Oct 2023). The substrate admits either canonical
16057        // width so an `:rev` authored against a SHA-256-hashed
16058        // upstream round-trips through the gate without per-repo
16059        // configuration. Pinned separately from the SHA-1 positive
16060        // control so a future tightening that drops one width surfaces
16061        // here as a structural decision.
16062        let d = dep_with_fonte(DepSource::Git {
16063            repo: "github:pleme-io/caixa-teia".into(),
16064            tag: None,
16065            rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
16066            branch: None,
16067        });
16068        d.validate().unwrap();
16069    }
16070
16071    #[test]
16072    fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
16073        // The canonical `git log --short` / `git rev-parse --short HEAD`
16074        // paste-from-release-notes footgun: a 7-char prefix (git's
16075        // default `core.abbrev`) silently passes string emptiness
16076        // checks and resolves to one commit today, but becomes ambiguous
16077        // tomorrow as the repo grows. Until this gate landed the empty-
16078        // pin arm passed (the string isn't empty) and the resolver
16079        // accepted the prefix through git's separate prefix-lookup pass
16080        // — defeating the reproducibility contract `:rev` carries vs.
16081        // `:tag` / `:branch`. The new gate moves the check to caixa-
16082        // build time and names the offending dep + pin + value verbatim.
16083        let d = dep_with_fonte(DepSource::Git {
16084            repo: "github:pleme-io/caixa-teia".into(),
16085            tag: None,
16086            rev: Some("c0ffee0".into()),
16087            branch: None,
16088        });
16089        let err = d.validate().unwrap_err();
16090        let DepError::FontePinShape {
16091            pin, value, reason, ..
16092        } = err
16093        else {
16094            panic!("expected FontePinShape, got other variant");
16095        };
16096        assert_eq!(pin, ":rev");
16097        assert_eq!(value, "c0ffee0");
16098        assert!(
16099            reason.contains("abbreviated") || reason.contains("ambiguous"),
16100            "reason must surface the abbreviation arm, got {reason:?}"
16101        );
16102    }
16103
16104    #[test]
16105    fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
16106        // The canonical "I pasted the SHA in uppercase" footgun: `git
16107        // porcelain` emits OIDs lowercase exclusively, so an uppercase-
16108        // bearing `:rev` round-trips inconsistently across the
16109        // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
16110        // equality-check pipeline and fails the lacre's content-
16111        // addressing probe with a confusing case-only diff. Pinned
16112        // separately from the non-hex arm so a future relaxation that
16113        // admits one but not the other surfaces here.
16114        let d = dep_with_fonte(DepSource::Git {
16115            repo: "github:pleme-io/caixa-teia".into(),
16116            tag: None,
16117            rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
16118            branch: None,
16119        });
16120        let err = d.validate().unwrap_err();
16121        let DepError::FontePinShape {
16122            pin, value, reason, ..
16123        } = err
16124        else {
16125            panic!("expected FontePinShape, got other variant");
16126        };
16127        assert_eq!(pin, ":rev");
16128        assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
16129        assert!(
16130            reason.contains("uppercase"),
16131            "reason must surface the uppercase arm, got {reason:?}"
16132        );
16133    }
16134
16135    #[test]
16136    fn validate_rejects_git_fonte_with_rev_refname_value() {
16137        // The cross-axis mis-slot footgun: `:rev "main"` — the author
16138        // conflated `:rev` (hex commit ID, immutable) and `:branch`
16139        // (mutable ref pointing at whatever HEAD is today). Until this
16140        // gate landed the resolver silently dispatched on the value
16141        // shape ("`main` doesn't look like a SHA, fall back to
16142        // refname"), defeating the `:rev` reproducibility contract.
16143        // The new gate rejects every non-hex value on the `:rev` axis,
16144        // so the `:rev`/`:branch` boundary is structurally enforced —
16145        // a refname in the `:rev` slot is a build error, not a
16146        // resolver-time silent reinterpretation.
16147        let d = dep_with_fonte(DepSource::Git {
16148            repo: "github:pleme-io/caixa-teia".into(),
16149            tag: None,
16150            rev: Some("main".into()),
16151            branch: None,
16152        });
16153        let err = d.validate().unwrap_err();
16154        let DepError::FontePinShape {
16155            pin, value, reason, ..
16156        } = err
16157        else {
16158            panic!("expected FontePinShape, got other variant");
16159        };
16160        assert_eq!(pin, ":rev");
16161        assert_eq!(value, "main");
16162        // 4 chars `main` fails the length arm before the character arm,
16163        // so the diagnostic surfaces the abbreviation wording (same
16164        // path the `c0ffee0` 7-char fixture lands on); the structural
16165        // assertion is just that the `:rev "main"` value is rejected.
16166        assert!(
16167            !reason.is_empty(),
16168            "FontePinShape reason must be non-empty for refname-shaped :rev"
16169        );
16170    }
16171
16172    #[test]
16173    fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
16174        // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
16175        // conflated `:rev` and `:tag`. Pinned separately from the
16176        // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
16177        // that catches one but not the other surfaces here. The
16178        // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
16179        // assertion is just that the cross-axis mis-slot is a build
16180        // error, regardless of which sub-arm surfaces the diagnostic
16181        // (`is_git_oid` rejects at the first violation; longer
16182        // tag-shape values would hit the non-hex arm instead).
16183        let d = dep_with_fonte(DepSource::Git {
16184            repo: "github:pleme-io/caixa-teia".into(),
16185            tag: None,
16186            rev: Some("v0.1.0".into()),
16187            branch: None,
16188        });
16189        let err = d.validate().unwrap_err();
16190        let DepError::FontePinShape {
16191            pin, value, reason, ..
16192        } = err
16193        else {
16194            panic!("expected FontePinShape, got other variant");
16195        };
16196        assert_eq!(pin, ":rev");
16197        assert_eq!(value, "v0.1.0");
16198        assert!(
16199            !reason.is_empty(),
16200            "FontePinShape reason must be non-empty for tag-shaped :rev"
16201        );
16202    }
16203
16204    #[test]
16205    fn validate_rejects_git_fonte_with_rev_too_long() {
16206        // Boundary case on the upper end: 41 hex chars — one past the
16207        // SHA-1 width, well below the SHA-256 width. Pin so a future
16208        // relaxation that admits "long enough to be a SHA" without
16209        // matching either canonical width surfaces here. The diagnostic
16210        // names the offending length verbatim so the author's grep
16211        // target is unambiguous (either trim one char or paste the
16212        // full SHA-256).
16213        let too_long: String = "0".repeat(41);
16214        let d = dep_with_fonte(DepSource::Git {
16215            repo: "github:pleme-io/caixa-teia".into(),
16216            tag: None,
16217            rev: Some(too_long.clone()),
16218            branch: None,
16219        });
16220        let err = d.validate().unwrap_err();
16221        let DepError::FontePinShape {
16222            pin, value, reason, ..
16223        } = err
16224        else {
16225            panic!("expected FontePinShape, got other variant");
16226        };
16227        assert_eq!(pin, ":rev");
16228        assert_eq!(value, too_long);
16229        assert!(
16230            reason.contains("41"),
16231            "reason must surface the offending length verbatim, got {reason:?}"
16232        );
16233    }
16234
16235    #[test]
16236    fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
16237        // The canonical paste-from-doc footgun on `:rev` — author
16238        // copies `"deadbeefcafe…0123 "` (trailing space) out of a
16239        // commit-message paragraph. Until this gate landed the empty-
16240        // pin arm passed (the string isn't empty), the resolver issued
16241        // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
16242        // clone time with a quoting-confused git error far from the
16243        // source caixa.lisp. The new gate moves the check to caixa-
16244        // build time. Length is 41 (40 hex + space) so the length arm
16245        // fires first — pinned separately from the pure-length arm to
16246        // ensure the diagnostic surfaces *some* parser wording, not
16247        // silently pass through.
16248        let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
16249        let d = dep_with_fonte(DepSource::Git {
16250            repo: "github:pleme-io/caixa-teia".into(),
16251            tag: None,
16252            rev: Some(with_space.clone()),
16253            branch: None,
16254        });
16255        let err = d.validate().unwrap_err();
16256        let DepError::FontePinShape {
16257            pin, value, reason, ..
16258        } = err
16259        else {
16260            panic!("expected FontePinShape, got other variant");
16261        };
16262        assert_eq!(pin, ":rev");
16263        assert_eq!(value, with_space);
16264        assert!(
16265            !reason.is_empty(),
16266            "FontePinShape reason must be non-empty for whitespace-bearing :rev"
16267        );
16268    }
16269
16270    #[test]
16271    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
16272        // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
16273        // variant on this axis names the offending dep's `:nome` + the
16274        // `:rev` axis + the offending value verbatim, so the author's
16275        // grep target is the literal `:rev "<value>"` block in
16276        // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
16277        // carries_offending_nome_pin_value` test on the refname-shaped
16278        // (`:tag` / `:branch`) axes.
16279        let d = dep_with_fonte(DepSource::Git {
16280            repo: "github:p/x".into(),
16281            tag: None,
16282            rev: Some("not-a-sha".into()),
16283            branch: None,
16284        });
16285        let msg = d
16286            .validate()
16287            .expect_err(":rev: expected FontePinShape")
16288            .to_string();
16289        assert!(
16290            msg.contains("\"caixa-teia\""),
16291            ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16292        );
16293        assert!(
16294            msg.contains(":rev"),
16295            ":rev: diagnostic must name the offending pin axis, got {msg:?}"
16296        );
16297        assert!(
16298            msg.contains("not-a-sha"),
16299            ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
16300        );
16301    }
16302
16303    #[test]
16304    fn fonte_pin_empty_fires_before_pin_shape() {
16305        // Order pin: a `Some("")` `:tag` is the more self-locating
16306        // diagnostic (the author chose an axis but left it blank;
16307        // grep is unambiguous), so it fires before the shape gate
16308        // even when both arms would match. Pinned so a future
16309        // reordering surfaces here. Mirrors the
16310        // `fonte_repo_empty_fires_before_pin_missing` ordering
16311        // discipline on the peer per-axis arms.
16312        let d = dep_with_fonte(DepSource::Git {
16313            repo: "github:pleme-io/caixa-teia".into(),
16314            tag: Some(String::new()),
16315            rev: None,
16316            branch: None,
16317        });
16318        assert!(matches!(
16319            d.validate().unwrap_err(),
16320            DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
16321        ));
16322    }
16323
16324    #[test]
16325    fn fonte_pin_shape_fires_after_repo_empty() {
16326        // Order pin: `:repo ""` is the more self-locating axis
16327        // (every git source needs a repo; the per-pin shape gate is
16328        // secondary), so the repo-empty arm fires before the
16329        // per-pin shape arm even when both are violated. Pinned so
16330        // a future reordering surfaces here. Mirrors
16331        // `fonte_repo_empty_fires_before_pin_missing` on the
16332        // adjacent axis pair.
16333        let d = dep_with_fonte(DepSource::Git {
16334            repo: String::new(),
16335            tag: Some("v0.1.0 ".into()),
16336            rev: None,
16337            branch: None,
16338        });
16339        assert!(matches!(
16340            d.validate().unwrap_err(),
16341            DepError::FonteRepoEmpty { .. }
16342        ));
16343    }
16344
16345    #[test]
16346    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
16347        // Diagnostic-shape pin across both refname-shaped axes
16348        // (`:tag` + `:branch`): every `FontePinShape` variant names
16349        // the offending dep's `:nome` + the offending pin axis + the
16350        // offending value verbatim, so the author's grep target is
16351        // unambiguous (the literal `:tag "<value>"` / `:branch
16352        // "<value>"` lands in caixa.lisp with quotes). Cover both
16353        // pin axes so a future variant addition forces a parallel
16354        // diagnostic-shape decision.
16355        for (pin_label, fonte) in [
16356            (
16357                ":tag",
16358                DepSource::Git {
16359                    repo: "github:p/x".into(),
16360                    tag: Some("v0.1.0~1".into()),
16361                    rev: None,
16362                    branch: None,
16363                },
16364            ),
16365            (
16366                ":branch",
16367                DepSource::Git {
16368                    repo: "github:p/x".into(),
16369                    tag: None,
16370                    rev: None,
16371                    branch: Some("feature/foo*".into()),
16372                },
16373            ),
16374        ] {
16375            let d = dep_with_fonte(fonte);
16376            let msg = d
16377                .validate()
16378                .expect_err(&format!("{pin_label}: expected FontePinShape"))
16379                .to_string();
16380            assert!(
16381                msg.contains("\"caixa-teia\""),
16382                "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16383            );
16384            assert!(
16385                msg.contains(pin_label),
16386                "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
16387            );
16388        }
16389    }
16390
16391    #[test]
16392    fn git_source_json_round_trip() {
16393        let src = DepSource::Git {
16394            repo: "github:pleme-io/caixa-teia".into(),
16395            tag: Some("v0.1.0".into()),
16396            rev: None,
16397            branch: None,
16398        };
16399        let s = serde_json::to_string(&src).unwrap();
16400        assert!(s.contains(&format!(
16401            r#""{tipo}":"{git}""#,
16402            tipo = crate::render::DEP_SOURCE_KEY_TIPO,
16403            git = crate::render::DEP_SOURCE_TIPO_GIT,
16404        )));
16405        assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
16406        assert!(s.contains(r#""tag":"v0.1.0""#));
16407        assert!(!s.contains("rev"));
16408        assert!(!s.contains("branch"));
16409        let round: DepSource = serde_json::from_str(&s).unwrap();
16410        assert_eq!(round, src);
16411    }
16412
16413    // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
16414    //
16415    // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
16416    // attribute on [`DepSource`] pins three load-bearing byte-sequences
16417    // that flow into every serialized `Dep.fonte` block: the outer
16418    // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
16419    // the two admitted variant-tag values `"git"` / `"path"` the
16420    // `rename_all = "lowercase"` attribute pins as the discriminator's
16421    // closed-set arms. The three pin tests below round-trip a
16422    // fully-populated variant of each arm through
16423    // [`serde_json::to_value`] and assert each canonical byte-sequence
16424    // appears at its axis — pins a hypothetical future
16425    // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
16426    // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
16427    // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
16428    // at build time rather than at fetch time when the resolver's
16429    // `Dep.fonte` dispatch silently fails to match on the drifted
16430    // discriminator. Same "serialize-and-check" discipline the peer
16431    // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
16432    // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
16433    // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
16434    // family in caixa-core lacking a lifted peer.
16435
16436    #[test]
16437    fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
16438        // Fail-before-pass-after: a future `tag = "type"` at the derive
16439        // attribute would serialize under `"type":"git"`, and this test
16440        // would trip because `"tipo"` no longer appears at the emitted
16441        // discriminator key. A future `rename_all = "kebab-case"` /
16442        // `"snake_case"` (both no-ops on `Git` since it lacks internal
16443        // word boundaries) is caught by the sibling
16444        // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
16445        // pin below (Path has no internal boundary either but the pair
16446        // catches any per-arm inconsistency). A future variant rename
16447        // `Git` → `Repository` would emit `"tipo":"repository"` and
16448        // trip this pin.
16449        let src = DepSource::Git {
16450            repo: "github:pleme-io/caixa-teia".into(),
16451            tag: Some("v0.1.0".into()),
16452            rev: None,
16453            branch: None,
16454        };
16455        let json = serde_json::to_value(&src).unwrap();
16456        let obj = json.as_object().expect("Git serializes as a JSON object");
16457        assert_eq!(
16458            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16459                .and_then(serde_json::Value::as_str),
16460            Some(crate::render::DEP_SOURCE_TIPO_GIT),
16461            "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16462             with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
16463             detected in {json}"
16464        );
16465    }
16466
16467    #[test]
16468    fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
16469        // Fail-before-pass-after: a future variant rename `Path` →
16470        // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
16471        // this pin. A per-consumer disambiguation as the `defcaixa`
16472        // macro stabilizes ("caminho" → "path" for English-uniformity)
16473        // is scoped to the inner field key, not the discriminator; this
16474        // pin is orthogonal to that and catches only the outer
16475        // discriminator drift.
16476        let src = DepSource::Path {
16477            caminho: "../caixa-teia".into(),
16478        };
16479        let json = serde_json::to_value(&src).unwrap();
16480        let obj = json.as_object().expect("Path serializes as a JSON object");
16481        assert_eq!(
16482            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16483                .and_then(serde_json::Value::as_str),
16484            Some(crate::render::DEP_SOURCE_TIPO_PATH),
16485            "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16486             with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
16487             detected in {json}"
16488        );
16489    }
16490
16491    #[test]
16492    fn dep_source_key_consts_are_pairwise_distinct() {
16493        // Cross-axis collapse detector: a hypothetical future edit that
16494        // accidentally set two of the three consts to the same byte
16495        // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
16496        // pass every per-arm serialize pin above but silently collapse
16497        // the discriminator's closed-set arms onto one another; this pin
16498        // catches the collapse at build time.
16499        assert_ne!(
16500            crate::render::DEP_SOURCE_KEY_TIPO,
16501            crate::render::DEP_SOURCE_TIPO_GIT,
16502        );
16503        assert_ne!(
16504            crate::render::DEP_SOURCE_KEY_TIPO,
16505            crate::render::DEP_SOURCE_TIPO_PATH,
16506        );
16507        assert_ne!(
16508            crate::render::DEP_SOURCE_TIPO_GIT,
16509            crate::render::DEP_SOURCE_TIPO_PATH,
16510        );
16511    }
16512
16513    #[test]
16514    fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
16515        // Shape pin against `rename_all` drift: the two variant-tag
16516        // consts must be ASCII-lowercase-only to match the
16517        // `rename_all = "lowercase"` attribute the derive uses; a future
16518        // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
16519        // would emit `"GIT"` / `"Git"` instead and trip this pin.
16520        for (label, s) in [
16521            ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
16522            ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
16523        ] {
16524            assert!(!s.is_empty(), "{label} must not be empty");
16525            assert!(
16526                s.bytes().all(|b| b.is_ascii_lowercase()),
16527                "{label} must be ASCII-lowercase-only (matching \
16528                 rename_all = \"lowercase\"), got {s:?}",
16529            );
16530        }
16531    }
16532
16533    // ── per-entry :caracteristicas set-not-multiset gate ────────────
16534    //
16535    // Every Vec-keyed-by-name authoring surface on the typed Caixa
16536    // surface that identifies its entries by a name field now uniformly
16537    // closes the set-not-multiset discipline at build time (cite
16538    // `validate_caracteristicas`'s peer-axis enumeration). The
16539    // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
16540    // set-shaped (a feature is either enabled or not — there is no
16541    // `feature × 2` semantic), so two entries naming the same feature
16542    // are a redundant declaration the caixa-resolver's lacre pipeline
16543    // would silently dedup at resolve time. The empty-feature arm
16544    // closes the parallel "operationally-meaningless value" axis on
16545    // the same slot. Same linear-walk + `HashSet` + first-collision
16546    // shape every peer set gate uses; same empty-first cascade every
16547    // peer per-entry shape + duplicate gate uses (the empty-feature
16548    // axis is the more-actionable defect since two `""` entries would
16549    // both report `caracteristica: ""` under a duplicate-first
16550    // ordering, with no way to distinguish the offending site).
16551
16552    fn dep_with_features(features: &[&str]) -> Dep {
16553        Dep {
16554            nome: "caixa-teia".into(),
16555            versao: "^0.1".into(),
16556            fonte: None,
16557            opcional: false,
16558            caracteristicas: features.iter().map(|s| (*s).into()).collect(),
16559        }
16560    }
16561
16562    #[test]
16563    fn validate_rejects_empty_caracteristica() {
16564        // Fail-before-pass-after pin: every pre-gate codebase accepted
16565        // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
16566        // imposed no per-entry shape contract), the dep validated, and
16567        // the empty feature would have reached the future caixa-resolver
16568        // lacre pipeline as a no-op feature enable — silently dropping
16569        // the author's intent far from the source `caixa.lisp`. The new
16570        // gate surfaces the structural defect at the typed-validate
16571        // surface with a self-locating diagnostic naming the offending
16572        // dep's `:nome`.
16573        let d = dep_with_features(&[""]);
16574        assert!(
16575            matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
16576            "expected CaracteristicaEmpty, got {:?}",
16577            d.validate(),
16578        );
16579    }
16580
16581    #[test]
16582    fn validate_rejects_duplicate_caracteristica() {
16583        // Fail-before-pass-after pin on the set-not-multiset arm: the
16584        // feature-toggle slot is set-shaped, so `(:caracteristicas
16585        // ("http" "http"))` is a redundant declaration the lacre
16586        // pipeline dedupes silently at resolve time. The diagnostic
16587        // names the offending dep + the colliding feature verbatim so
16588        // the author can grep their caixa.lisp for `:caracteristicas`
16589        // and fix it in one edit. First-collision determinism is
16590        // pinned separately below.
16591        let d = dep_with_features(&["http", "http"]);
16592        assert!(
16593            matches!(
16594                d.validate().unwrap_err(),
16595                DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
16596                    if nome == "caixa-teia" && caracteristica == "http"
16597            ),
16598            "expected CaracteristicaDuplicate, got {:?}",
16599            d.validate(),
16600        );
16601    }
16602
16603    #[test]
16604    fn validate_accepts_distinct_caracteristicas() {
16605        // The canonical authoring shape — every feature distinct — must
16606        // remain a clean pass (positive control sweep). Covers the
16607        // canonical kebab-case feature names a target caixa typically
16608        // declares.
16609        dep_with_features(&["http", "json", "tls"])
16610            .validate()
16611            .unwrap();
16612    }
16613
16614    #[test]
16615    fn validate_accepts_single_caracteristica() {
16616        // Single-element list is the minimum non-empty shape; passes
16617        // the gate as the identity of the duplicate check (no second
16618        // entry to collide with).
16619        dep_with_features(&["http"]).validate().unwrap();
16620    }
16621
16622    #[test]
16623    fn validate_accepts_empty_caracteristicas_list() {
16624        // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
16625        // produces `caracteristicas: Vec::new()`; the empty list is
16626        // the gate's empty-set identity and passes vacuously. Pin
16627        // this so a future tightening that requires ≥1 feature
16628        // surfaces here as a test failure rather than a silent
16629        // contract narrowing.
16630        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16631        assert!(dep_with_features(&[]).validate().is_ok());
16632    }
16633
16634    #[test]
16635    fn validate_caracteristica_empty_fires_before_duplicate() {
16636        // Empty-first cascade: an entry with an empty feature *and*
16637        // duplicate entries surfaces the empty diagnostic first. The
16638        // empty-feature axis is the more-actionable defect since
16639        // `caracteristica: ""` is unambiguous; under duplicate-first
16640        // ordering the diagnostic could report the empty string from
16641        // either of two empty entries with no way to distinguish.
16642        // Mirrors the peer empty-before-duplicate ordering
16643        // discipline every per-entry shape + duplicate gate establishes
16644        // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
16645        // `DuplicateChildCaixa`, `validate_membros`'s
16646        // `MembroCaixaEmpty` arm before `MembroDuplicate`).
16647        let d = dep_with_features(&["", "http", "http"]);
16648        assert!(matches!(
16649            d.validate().unwrap_err(),
16650            DepError::CaracteristicaEmpty { .. }
16651        ));
16652    }
16653
16654    #[test]
16655    fn validate_caracteristica_duplicate_first_collision_determinism() {
16656        // Three matching entries: the second occurrence surfaces the
16657        // diagnostic (the second is the first *collision* — the first
16658        // entry is the establishing one, not a duplicate). Mirrors
16659        // every peer first-collision posture
16660        // (`SupervisorError::DuplicateChildCaixa` reports the second
16661        // collision, `AplicacaoError::MembroDuplicate` reports the
16662        // second, `DepError::DuplicateNome` reports the second).
16663        // Pinning this so a future shortcut that flips to last-
16664        // collision (or non-deterministic) surfaces here.
16665        let d = dep_with_features(&["http", "http", "http"]);
16666        assert!(matches!(
16667            d.validate().unwrap_err(),
16668            DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
16669        ));
16670    }
16671
16672    #[test]
16673    fn validate_per_entry_shape_fires_before_caracteristicas() {
16674        // Per-entry shape precedence: a dep with a malformed `:nome`
16675        // (uppercase) AND duplicate `:caracteristicas` surfaces the
16676        // narrower `NomeInvalid` diagnostic first, not the set-gate
16677        // diagnostic. The `:nome` is the self-locating axis (every
16678        // diagnostic from the caracteristicas gate quotes the
16679        // offending dep's `:nome` to anchor the grep target —
16680        // surfacing the malformed name first keeps that anchor
16681        // valid). Same precedence shape every peer per-entry-shape
16682        // arm establishes against its peer set-gate
16683        // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
16684        // on the cross-entry `:nome` axis).
16685        let d = Dep {
16686            nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
16687            versao: "^0.1".into(),
16688            fonte: None,
16689            opcional: false,
16690            caracteristicas: vec!["http".into(), "http".into()],
16691        };
16692        assert!(matches!(
16693            d.validate().unwrap_err(),
16694            DepError::NomeInvalid { .. }
16695        ));
16696    }
16697
16698    // ── per-entry :caracteristicas value-shape gate ──────────────────
16699    //
16700    // Until this gate landed `:caracteristicas` only refused the empty
16701    // string and cross-entry duplicates: a non-empty distinct but
16702    // structurally invalid feature name silently passed validate and the
16703    // failure surfaced at `cargo metadata` time as Cargo's
16704    // `restricted_names::validate_feature_name` parser rejection, far from
16705    // the source `caixa.lisp` with no field naming which `:deps` entry's
16706    // `:caracteristicas` carried the typo. The lifted predicate makes the
16707    // Cargo-feature-name-grammar intersection-floor a substrate-level
16708    // invariant at validate time. Same trajectory as the eight peer
16709    // value-shape predicates each typed surface downstream of a structured
16710    // grammar already follows.
16711
16712    #[test]
16713    fn validate_rejects_caracteristica_with_leading_plus() {
16714        // Fail-before-pass-after pin on the canonical Cargo
16715        // `+<feature>` activation-form-in-feature-name-slot footgun.
16716        // Cargo's `[dependencies.<dep>.features]` list grammar accepts
16717        // `+optional-feature` as an enablement of a previously-disabled
16718        // feature; pasting that activation form into `:caracteristicas`
16719        // (which names the feature itself) silently passed pre-gate and
16720        // failed at `cargo metadata` parse time.
16721        let d = dep_with_features(&["+http"]);
16722        let err = d.validate().unwrap_err();
16723        assert!(
16724            matches!(
16725                err,
16726                DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
16727                    if nome == "caixa-teia" && caracteristica == "+http"
16728            ),
16729            "expected CaracteristicaInvalid, got {err:?}"
16730        );
16731    }
16732
16733    #[test]
16734    fn validate_rejects_caracteristica_with_leading_hyphen() {
16735        // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
16736        // is a legitimate continuation character (kebab-case feature
16737        // names like `runtime-tokio` pass) but Cargo rejects it at the
16738        // start; the structural defect — and its CLI-argument-injection
16739        // adjacency at any downstream Cargo subprocess invocation — is
16740        // closed at validate time, not at `cargo metadata` time.
16741        let d = dep_with_features(&["-json"]);
16742        let err = d.validate().unwrap_err();
16743        assert!(
16744            matches!(
16745                err,
16746                DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
16747            ),
16748            "expected CaracteristicaInvalid, got {err:?}"
16749        );
16750    }
16751
16752    #[test]
16753    fn validate_rejects_caracteristica_with_leading_dot() {
16754        // Fail-before-pass-after pin on the leading-dot footgun. `.` is
16755        // a legitimate continuation character (version-suffix shapes
16756        // like `feat.v2` pass) but the leading-dot form is the
16757        // canonical dotted-version-suffix-as-feature-name confusion.
16758        let d = dep_with_features(&[".feat"]);
16759        let err = d.validate().unwrap_err();
16760        assert!(matches!(
16761            err,
16762            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
16763        ));
16764    }
16765
16766    #[test]
16767    fn validate_rejects_caracteristica_with_whitespace() {
16768        // Fail-before-pass-after pin on the embedded-whitespace footgun:
16769        // a feature name with a space inside is structurally a multi-
16770        // token blob (the canonical paste-from-doc footgun, or an
16771        // accidental `"http server"` where the author meant
16772        // `"http-server"`).
16773        let d = dep_with_features(&["http feature"]);
16774        let err = d.validate().unwrap_err();
16775        assert!(matches!(
16776            err,
16777            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
16778        ));
16779    }
16780
16781    #[test]
16782    fn validate_rejects_caracteristica_with_comma() {
16783        // Fail-before-pass-after pin on the embedded-comma footgun:
16784        // the list-separator-belongs-to-the-list-grammar
16785        // miscomprehension where the author writes
16786        // `:caracteristicas ("http,json")` intending two features but
16787        // the `Vec<String>` field consumes the bare token as one entry.
16788        let d = dep_with_features(&["http,json"]);
16789        let err = d.validate().unwrap_err();
16790        assert!(matches!(
16791            err,
16792            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
16793        ));
16794    }
16795
16796    #[test]
16797    fn validate_rejects_caracteristica_with_slash() {
16798        // Fail-before-pass-after pin on the embedded-slash footgun:
16799        // Cargo's `dep/feat` namespaced-dep syntax applies inside
16800        // `[dependencies.<dep>.features]` list entries that already
16801        // name the parent dep (so the syntax says "enable feature
16802        // `feat` on a transitive dep `dep`"); `:caracteristicas` is
16803        // per-dep already (a sibling slot on the `Dep` itself), so the
16804        // segment separator within an entry must be `-`, `_`, `+`,
16805        // or `.`. The diagnostic remediation points at the canonical
16806        // Cargo namespaced-dep discipline.
16807        let d = dep_with_features(&["http/json"]);
16808        let err = d.validate().unwrap_err();
16809        assert!(matches!(
16810            err,
16811            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
16812        ));
16813    }
16814
16815    #[test]
16816    fn validate_rejects_caracteristica_with_non_ascii() {
16817        // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
16818        // byte footgun: NFC-vs-NFD normalization across filesystems
16819        // silently rewrites the feature-key, breaking the lacre's
16820        // content-addressing invariant. Pinned at a canonical
16821        // smart-quote-paste shape (`café`) where the raw `é` byte is the
16822        // documented APFS round-trip break.
16823        let d = dep_with_features(&["caf\u{e9}"]);
16824        let err = d.validate().unwrap_err();
16825        assert!(matches!(
16826            err,
16827            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
16828        ));
16829    }
16830
16831    #[test]
16832    fn validate_rejects_caracteristica_with_control_character() {
16833        // Fail-before-pass-after pin on the embedded-control-character
16834        // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
16835        // feature name is the canonical paste-from-multiline-doc
16836        // footgun the predicate's reason wording specifically calls out.
16837        let d = dep_with_features(&["http\njson"]);
16838        let err = d.validate().unwrap_err();
16839        assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
16840    }
16841
16842    #[test]
16843    fn validate_accepts_canonical_caracteristicas_shapes() {
16844        // Positive control sweep: every canonical Cargo feature name
16845        // shape the pleme-io ecosystem uses must still pass. Mirrors
16846        // the substrate-side `cargo_feature_name_accepts_canonical_forms`
16847        // sweep — drift between either landing site and the predicate's
16848        // accepted set is a build error visible at this pair of tests,
16849        // not a per-renderer "this passed validate but failed at
16850        // cargo metadata time" surprise on the next acceptance.
16851        for s in [
16852            "http",
16853            "json",
16854            "derive",
16855            "serde_json",
16856            "runtime-tokio",
16857            "tokio.full",
16858            "v0.1",
16859            "http+json",
16860            "_internal",
16861            "__private",
16862            "default",
16863            "rt-multi-thread",
16864            "feat.v2",
16865        ] {
16866            let d = dep_with_features(&[s]);
16867            d.validate().unwrap_or_else(|e| {
16868                panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
16869            });
16870        }
16871    }
16872
16873    #[test]
16874    fn validate_caracteristica_empty_fires_before_invalid() {
16875        // Cascade precedence pin: an entry list with both an empty
16876        // feature AND an invalid-shape feature surfaces the
16877        // `CaracteristicaEmpty` arm first (the empty value carries no
16878        // self-locating data — `caracteristica: ""` is the diagnostic
16879        // with no way to anchor a grep target — so closing the empty
16880        // axis first preserves the per-entry-shape diagnostic's
16881        // self-locating discipline). Same empty-first cascade every
16882        // peer per-entry shape gate establishes
16883        // (`SupervisorSpec::validate`'s `EmptyChildName` before
16884        // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
16885        // before `MembroCaixaInvalid`).
16886        let d = dep_with_features(&["", "+http"]);
16887        assert!(matches!(
16888            d.validate().unwrap_err(),
16889            DepError::CaracteristicaEmpty { .. }
16890        ));
16891    }
16892
16893    #[test]
16894    fn validate_caracteristica_invalid_fires_before_duplicate() {
16895        // Per-entry-shape precedence pin: an entry list with the same
16896        // invalid feature shape declared twice surfaces the
16897        // `CaracteristicaInvalid` diagnostic on the first entry, not
16898        // the `CaracteristicaDuplicate` on the second collision. The
16899        // per-entry shape gate fires before the cross-entry set gate
16900        // — same precedence shape every peer two-arm-plus-set gate
16901        // establishes (`SupervisorSpec::validate`'s
16902        // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
16903        // `validate_membros`'s `MembroCaixaInvalid` before
16904        // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
16905        // cross-list `DuplicateNome`).
16906        let d = dep_with_features(&["+http", "+http"]);
16907        assert!(matches!(
16908            d.validate().unwrap_err(),
16909            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
16910        ));
16911    }
16912
16913    #[test]
16914    fn validate_rejects_caracteristica_at_65_byte_boundary() {
16915        // Boundary pin on the 64-byte cap — both the boundary-accepting
16916        // case and the boundary-exceeding case in one place, so a
16917        // future cap shift surfaces both arms simultaneously, mirroring
16918        // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
16919        // predicate-level pin at the dep-axis landing site.
16920        let max_ok = "a".repeat(64);
16921        dep_with_features(&[&max_ok])
16922            .validate()
16923            .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
16924        let too_long = "a".repeat(65);
16925        let d = dep_with_features(&[&too_long]);
16926        assert!(matches!(
16927            d.validate().unwrap_err(),
16928            DepError::CaracteristicaInvalid { .. }
16929        ));
16930    }
16931
16932    // ── self-dep cross-slot gate ─────────────────────────────────────
16933
16934    #[test]
16935    fn validate_no_self_dep_rejects_self_in_deps() {
16936        // A caixa whose `:deps` lists its own `:nome` is a one-node
16937        // cycle in the lacre closure's dep-graph traversal — rejected,
16938        // naming the parent and the offending list tag.
16939        let deps = vec![
16940            Dep::simple("caixa-teia", "^0.1"),
16941            Dep::simple("orquestra", "^0.1"),
16942        ];
16943        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16944        assert!(
16945            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16946            "got {err:?}"
16947        );
16948    }
16949
16950    #[test]
16951    fn validate_no_self_dep_rejects_self_in_deps_dev() {
16952        // Same gate on the `:deps-dev` axis — neither dep list is a
16953        // second-class citizen on the self-edge invariant.
16954        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16955        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16956        assert!(
16957            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16958            "got {err:?}"
16959        );
16960    }
16961
16962    #[test]
16963    fn validate_no_self_dep_deps_fires_before_deps_dev() {
16964        // Walk order pin: a caixa that self-references on both lists
16965        // surfaces the `:deps` arm first — the load-bearing axis the
16966        // lacre closure resolves at every build. Mirrors the canonical
16967        // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
16968        let deps = vec![Dep::simple("orquestra", "^0.1")];
16969        let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
16970        let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
16971        assert!(
16972            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16973            "got {err:?}"
16974        );
16975    }
16976
16977    #[test]
16978    fn validate_no_self_dep_accepts_distinct_names() {
16979        // Positive control: every dep names a distinct caixa. The
16980        // canonical author surface — peer of
16981        // [`validate_no_self_supervision_accepts_distinct_children`].
16982        let deps = vec![
16983            Dep::simple("caixa-teia", "^0.1"),
16984            Dep::simple("caixa-arch", "^0.1"),
16985        ];
16986        let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
16987        validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
16988    }
16989
16990    #[test]
16991    fn validate_no_self_dep_empty_lists_pass() {
16992        // A caixa with no declared deps has nothing to self-reference —
16993        // the gate is vacuously satisfied. Peer of
16994        // [`validate_no_self_supervision_empty_children_is_ok`].
16995        validate_no_self_dep(&[], &[], "orquestra").unwrap();
16996    }
16997
16998    #[test]
16999    fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
17000        // Diagnostic-shape pin (peer with
17001        // [`validate_no_self_supervision`]'s diagnostic): the error's
17002        // Display surfaces both the offending list tag and the
17003        // parent's `:nome` verbatim, so the author can grep their
17004        // caixa.lisp for the offending block in one edit. Names
17005        // `:bibliotecas` / `:exe` / `:servicos` as the corrective
17006        // surface — every legitimate "I want to use code from this
17007        // caixa" intent routes through one of those three slots.
17008        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17009        let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
17010            .unwrap_err()
17011            .to_string();
17012        assert!(
17013            rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17014            "diagnostic must name the offending list tag: {rendered}",
17015        );
17016        assert!(
17017            rendered.contains("orquestra"),
17018            "diagnostic must quote the parent caixa name: {rendered}",
17019        );
17020        assert!(
17021            rendered.contains(":bibliotecas"),
17022            "diagnostic must point at the corrective code-surface slot: {rendered}",
17023        );
17024    }
17025
17026    #[test]
17027    fn validate_no_self_dep_accepts_coincidental_substring_match() {
17028        // Identity is exact-string equality, not substring — a dep
17029        // named `"orquestra-helper"` is a distinct caixa even when the
17030        // parent is `"orquestra"`. Pin the exact-match discipline so a
17031        // future relaxation that uses `contains` surfaces here, peer
17032        // with the supervision-tree and Aplicacao-membership gates
17033        // which all use exact-string equality on the typed identity.
17034        let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
17035        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
17036    }
17037
17038    // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
17039
17040    #[test]
17041    fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
17042        // Scalar-value pin: the two author-facing kebab-case labels the
17043        // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
17044        // the two-list dep-graph slot axis, one arm per typed slot.
17045        // Mirrors the peer scalar-value pin the sibling
17046        // [`crate::M2_AUTHOR_KEY_LIMITS`] /
17047        // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
17048        // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
17049        // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
17050        // (882f498) M3 top-level author-labels, and
17051        // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
17052        // Supervisor top-level author-labels carry, so every kind-scoped
17053        // typed-slot-family axis routes through one canonical per-arm
17054        // declaration.
17055        //
17056        // A future rebrand (`:deps` → `:dependencies` matching Cargo's
17057        // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
17058        // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
17059        // for symmetry) lands as an edit to exactly one const, and
17060        // every consumer that reaches for the label picks it up at
17061        // build time rather than at runtime as a downstream mismatch on
17062        // a `DepError::DuplicateNome { list: … }` diagnostic far from
17063        // the rename's commit.
17064        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
17065        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
17066    }
17067
17068    #[test]
17069    fn dep_author_key_consts_are_pairwise_distinct() {
17070        // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
17071        // must not collapse onto one byte-string. A future copy-paste
17072        // slip that renamed both consts to the same value (or a rebrand
17073        // that dropped the `-dev` suffix from one but not the other)
17074        // would leave every `DepError::DuplicateNome { list: … }`
17075        // diagnostic naming an unattributable list — the linter would
17076        // route the author to the wrong caixa.lisp block, or the
17077        // cross-list precedence gate
17078        // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
17079        // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
17080        // duplicate. Peer of the sibling
17081        // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
17082        // other top-level kind-scoped slot-family axes carry
17083        // (implicitly held by their different byte-values today).
17084        assert_ne!(
17085            crate::render::DEP_AUTHOR_KEY_DEPS,
17086            crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17087            "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
17088             so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
17089             self-locates the offending block in the author's caixa.lisp",
17090        );
17091    }
17092
17093    #[test]
17094    fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
17095        // Production-through-const pin: the two per-arm list tags
17096        // [`validate_no_self_dep`] threads onto the `list:` field of a
17097        // returned [`DepError::DepIsSelf`] route through the lifted
17098        // [`crate::DEP_AUTHOR_KEY_DEPS`] /
17099        // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
17100        // the walker (a rename that reaches one arm but not the const,
17101        // or vice versa) surfaces here at build time rather than at
17102        // runtime as a `feira lint` diagnostic naming the wrong list
17103        // tag. Mirror of the peer
17104        // [`crate::Caixa::declared_servico_slots`] production tagger
17105        // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
17106        // onto the two-list dep-graph gate.
17107        let deps = vec![Dep::simple("orquestra", "^0.1")];
17108        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17109        let DepError::DepIsSelf { list, .. } = err else {
17110            panic!("expected DepIsSelf from :deps walk");
17111        };
17112        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
17113
17114        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17115        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17116        let DepError::DepIsSelf { list, .. } = err else {
17117            panic!("expected DepIsSelf from :deps-dev walk");
17118        };
17119        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
17120    }
17121
17122    // ── Dep::nome accessor pins ───────────────────────────────────────
17123    //
17124    // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
17125    // projection over the plain-shorthand / explicit-git / explicit-path
17126    // fixture triad the [`Dep`] docstring lists (so the accessor's
17127    // accept-set is exercised across every author-surface `:fonte`
17128    // shape); by-borrow pointer identity so the projection stays
17129    // zero-copy at every consumer site; and validate-composition through
17130    // the [`validate_no_self_dep`] cross-slot gate reading its
17131    // parent-name equality check through the lifted accessor rather than
17132    // the raw field.
17133
17134    #[test]
17135    fn dep_nome_returns_declared_nome_across_fonte_shapes() {
17136        // Plain-shorthand form (`:fonte None`).
17137        assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
17138        // Explicit git-source form with a tag pin — same accessor path.
17139        assert_eq!(
17140            Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
17141            "caixa-teia",
17142        );
17143        // Explicit path-source form.
17144        assert_eq!(
17145            Dep {
17146                nome: "caixa-teia".to_string(),
17147                versao: "0.1.0".to_string(),
17148                fonte: Some(DepSource::Path {
17149                    caminho: "../caixa-teia".to_string(),
17150                }),
17151                opcional: false,
17152                caracteristicas: Vec::new(),
17153            }
17154            .nome(),
17155            "caixa-teia",
17156        );
17157        // The empty-string `:nome` sentinel (which [`Dep::validate`]
17158        // refuses through the [`DepError::NomeEmpty`] arm) still round-
17159        // trips as an empty `&str` through the accessor — the accessor is
17160        // a projection, not a gate; the gate is [`Dep::validate`].
17161        assert_eq!(Dep::simple("", "^0.1").nome(), "");
17162    }
17163
17164    #[test]
17165    fn dep_nome_is_by_borrow_pointer_identity() {
17166        // Zero-copy pin: the accessor must borrow into the field's own
17167        // storage, not clone. If a future rewrite regresses to
17168        // `self.nome.clone().leak()` or an owned-buffer shape, the two
17169        // pointers diverge and this pin fails at build time.
17170        let d = Dep::simple("caixa-teia", "^0.1");
17171        assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
17172    }
17173
17174    // ── Dep::versao_requirement accessor pins ─────────────────────────
17175    //
17176    // Three coherence pins on the lifted `Dep::versao_requirement`
17177    // accessor: byte-equal projection over the plain-shorthand /
17178    // explicit-git / explicit-path fixture triad the [`Dep`] docstring
17179    // lists plus the empty-sentinel that round-trips as `""` (the accessor
17180    // is a projection, not a gate; the gate is [`Dep::validate`]); by-
17181    // borrow pointer identity so the projection stays zero-copy at every
17182    // consumer site; and validate-composition through the
17183    // [`crate::render::require_valid_versao_requirement`] cascade reading
17184    // its requirement-shape check through the lifted accessor rather than
17185    // the raw field.
17186    #[test]
17187    fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
17188        // Plain-shorthand form (`:fonte None`).
17189        assert_eq!(
17190            Dep::simple("caixa-teia", "^0.1").versao_requirement(),
17191            "^0.1",
17192        );
17193        // Explicit git-source form with a tag pin — same accessor path.
17194        assert_eq!(
17195            Dep::git(
17196                "caixa-teia",
17197                "~0.1.2",
17198                "github:pleme-io/caixa-teia",
17199                "v0.1.0"
17200            )
17201            .versao_requirement(),
17202            "~0.1.2",
17203        );
17204        // Explicit path-source form.
17205        assert_eq!(
17206            Dep {
17207                nome: "caixa-teia".to_string(),
17208                versao: "0.1.0".to_string(),
17209                fonte: Some(DepSource::Path {
17210                    caminho: "../caixa-teia".to_string(),
17211                }),
17212                opcional: false,
17213                caracteristicas: Vec::new(),
17214            }
17215            .versao_requirement(),
17216            "0.1.0",
17217        );
17218        // The wildcard requirement (`"*"`) — the shorthand
17219        // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
17220        // verbatim through the accessor as `"*"`, same byte-shape the
17221        // author wrote.
17222        assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
17223        // The empty-string `:versao` sentinel (which [`Dep::validate`]
17224        // refuses through the [`DepError::VersaoEmpty`] arm) still round-
17225        // trips as an empty `&str` through the accessor — the accessor is
17226        // a projection, not a gate; the gate is [`Dep::validate`]. Peer
17227        // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
17228        assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
17229    }
17230
17231    #[test]
17232    fn dep_versao_requirement_is_by_borrow_pointer_identity() {
17233        // Zero-copy pin: the accessor must borrow into the field's own
17234        // storage, not clone. If a future rewrite regresses to
17235        // `self.versao.clone().leak()` or an owned-buffer shape, the two
17236        // pointers diverge and this pin fails at build time. Peer of the
17237        // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
17238        // discipline extended onto the requirement-carrying axis.
17239        let d = Dep::simple("caixa-teia", "^0.1");
17240        assert!(std::ptr::eq(
17241            d.versao_requirement().as_ptr(),
17242            d.versao.as_ptr(),
17243        ));
17244    }
17245
17246    #[test]
17247    fn dep_validate_reads_requirement_through_accessor() {
17248        // Composition pin: the [`Dep::validate`]
17249        // [`crate::render::require_valid_versao_requirement`] cascade
17250        // consumes the requirement string through the lifted accessor —
17251        // both the requirement-gate input and the
17252        // [`DepError::VersaoInvalid`] error-body carrier route through
17253        // `self.versao_requirement()`. A valid requirement passes
17254        // (positive control); a malformed-but-non-empty requirement fails
17255        // and the diagnostic quotes the offending byte-string verbatim
17256        // (same shape the accessor projects), so a future regression that
17257        // detoured the requirement carrier through a different byte-
17258        // string (say the parsed `VersionReq`'s `Display`, or a
17259        // normalized rewrite) would surface here at build time. The
17260        // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
17261        // ahead of the parse arm, pinning the empty-first cascade the
17262        // accessor's `""` sentinel round-trip acknowledges.
17263        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17264        let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
17265        assert!(
17266            matches!(
17267                &err,
17268                DepError::VersaoInvalid {
17269                    nome,
17270                    versao,
17271                    ..
17272                } if nome == "caixa-teia" && versao == "v0.1",
17273            ),
17274            "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
17275        );
17276        let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
17277        assert!(
17278            matches!(
17279                &err,
17280                DepError::VersaoEmpty { nome } if nome == "caixa-teia",
17281            ),
17282            "expected VersaoEmpty from the empty-first arm, got {err:?}",
17283        );
17284    }
17285
17286    // ── Dep::fonte accessor pins ──────────────────────────────────────
17287    //
17288    // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
17289    // equal projection over the plain-shorthand (`:fonte None`) /
17290    // explicit-git-tag / explicit-path fixture triad the [`Dep`]
17291    // docstring lists (so the accessor's accept-set is exercised across
17292    // every author-surface `:fonte` shape and both `DepSource` variants);
17293    // pointer identity so the borrowed reference points into the field's
17294    // own `Option<DepSource>` storage (not a cloned side-buffer); and
17295    // validate-composition through the [`Dep::validate`] gate reading
17296    // its per-`:fonte` [`DepSource::validate`] delegation through the
17297    // lifted accessor rather than the raw `if let Some(ref fonte) =
17298    // self.fonte` bracket.
17299
17300    #[test]
17301    fn dep_fonte_returns_declared_source_across_shapes() {
17302        // Plain-shorthand form — `:fonte` omitted, accessor projects
17303        // the `None` partition the resolver-side default-fill treats
17304        // as "resolve through `github:<default-org>/<nome>`".
17305        assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
17306        // Explicit git-source form with a tag pin — same accessor path.
17307        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17308        match git.fonte() {
17309            Some(DepSource::Git {
17310                repo,
17311                tag,
17312                rev,
17313                branch,
17314            }) => {
17315                assert_eq!(repo, "github:pleme-io/caixa-teia");
17316                assert_eq!(tag.as_deref(), Some("v0.1.0"));
17317                assert!(rev.is_none());
17318                assert!(branch.is_none());
17319            }
17320            other => panic!("expected explicit git :fonte, got {other:?}"),
17321        }
17322        // Explicit path-source form — the dev-only local-filesystem
17323        // arm the [`Dep`] docstring's third fixture carries.
17324        let path = Dep {
17325            nome: "caixa-teia".to_string(),
17326            versao: "0.1.0".to_string(),
17327            fonte: Some(DepSource::Path {
17328                caminho: "../caixa-teia".to_string(),
17329            }),
17330            opcional: false,
17331            caracteristicas: Vec::new(),
17332        };
17333        match path.fonte() {
17334            Some(DepSource::Path { caminho }) => {
17335                assert_eq!(caminho, "../caixa-teia");
17336            }
17337            other => panic!("expected explicit path :fonte, got {other:?}"),
17338        }
17339    }
17340
17341    #[test]
17342    fn dep_fonte_is_by_borrow_pointer_identity() {
17343        // Zero-copy pin: the accessor must borrow into the field's own
17344        // `Option<DepSource>` storage, not clone into a side buffer. If
17345        // a future rewrite regresses to `self.fonte.clone()` or an
17346        // owned-buffer shape, the two pointers diverge and this pin
17347        // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
17348        // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
17349        // identity pins — same by-borrow discipline extended onto the
17350        // outer-`Dep` `Option<&Composite>` composite-reference axis.
17351        let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17352        let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
17353        let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
17354        assert!(std::ptr::eq(accessed, raw));
17355    }
17356
17357    #[test]
17358    fn dep_validate_reads_fonte_through_accessor() {
17359        // Composition pin: [`Dep::validate`]'s per-`:fonte`
17360        // [`DepSource::validate`] delegation consumes the typed slot
17361        // through the lifted accessor — an author-omitted `:fonte`
17362        // still passes the outer gate (positive control), an explicit
17363        // well-formed git source with exactly one pin passes, and a
17364        // malformed git source (empty `:repo`) surfaces the
17365        // [`DepError::FonteRepoEmpty`] variant quoting the offending
17366        // dep's `:nome` verbatim so a future regression that detoured
17367        // the `:fonte` delegation through a different path (say a
17368        // per-scope override projector) would surface here at build
17369        // time. Peer of the sibling
17370        // `dep_validate_reads_requirement_through_accessor` composition
17371        // pin on the `:versao` axis.
17372        // Positive control 1: no `:fonte` at all.
17373        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17374        // Positive control 2: well-formed git source.
17375        Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
17376            .validate()
17377            .unwrap();
17378        // Negative control: empty `:repo` — the accessor still returns
17379        // `Some(&DepSource::Git { repo: "", … })` and the delegated
17380        // `DepSource::validate` gate raises the typed carrier.
17381        let bad = Dep {
17382            nome: "caixa-teia".to_string(),
17383            versao: "^0.1".to_string(),
17384            fonte: Some(DepSource::Git {
17385                repo: String::new(),
17386                tag: Some("v0.1.0".to_string()),
17387                rev: None,
17388                branch: None,
17389            }),
17390            opcional: false,
17391            caracteristicas: Vec::new(),
17392        };
17393        let err = bad.validate().unwrap_err();
17394        assert!(
17395            matches!(
17396                &err,
17397                DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
17398            ),
17399            "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
17400        );
17401    }
17402
17403    #[test]
17404    fn validate_no_self_dep_reads_parent_equality_through_accessor() {
17405        // Composition pin: the cross-slot [`validate_no_self_dep`] gate
17406        // rejects a `:deps` entry whose `:nome` equals the parent caixa's
17407        // own `:nome` through the lifted accessor rather than the raw
17408        // field. Fails-before-passes-after: with the accessor lifted the
17409        // gate reads its equality check through `dep.nome() ==
17410        // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
17411        // the diagnostic still names the offending list tag as expected.
17412        let deps = vec![Dep::simple("orquestra", "^0.1")];
17413        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17414        assert!(matches!(
17415            err,
17416            DepError::DepIsSelf {
17417                ref nome,
17418                list,
17419            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
17420        ));
17421        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17422        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17423        assert!(matches!(
17424            err,
17425            DepError::DepIsSelf {
17426                ref nome,
17427                list,
17428            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17429        ));
17430        // A non-matching `:nome` passes through the accessor gate.
17431        let deps = vec![Dep::simple("caixa-teia", "^0.1")];
17432        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
17433    }
17434
17435    // ── Dep::caracteristicas accessor pins ────────────────────────────
17436    //
17437    // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
17438    // byte-equal projection over the default-empty / single-entry /
17439    // multi-entry fixture triad (so the accessor's accept-set is
17440    // exercised across every author-surface `:caracteristicas` shape,
17441    // matching the peer sibling family's fixture-triad discipline); by-
17442    // borrow pointer identity so the projection stays zero-copy at every
17443    // consumer site; and validate-composition through the
17444    // [`Dep::validate_caracteristicas`] gate reading its per-entry
17445    // linear walk through the lifted accessor rather than the raw
17446    // `for c in &self.caracteristicas` bracket.
17447
17448    #[test]
17449    fn dep_caracteristicas_returns_declared_features_across_shapes() {
17450        // Default-empty form — the [`Dep::simple`] constructor's
17451        // `Vec::new()` fill; the accessor projects the empty slice
17452        // verbatim (no `None` collapse).
17453        assert!(
17454            Dep::simple("caixa-teia", "^0.1")
17455                .caracteristicas()
17456                .is_empty(),
17457        );
17458        // Single-entry form — the canonical Cargo-shaped one-feature
17459        // enable ([`crate::render::is_cargo_feature_name`] accepts the
17460        // `"http"` byte-string as a valid feature name).
17461        let one = Dep {
17462            nome: "caixa-teia".to_string(),
17463            versao: "^0.1".to_string(),
17464            fonte: None,
17465            opcional: false,
17466            caracteristicas: vec!["http".to_string()],
17467        };
17468        assert_eq!(one.caracteristicas(), &["http".to_string()]);
17469        // Multi-entry form — the substrate's set-shaped multi-feature
17470        // enable, exercising the accessor over a length-two slice with
17471        // no duplicate collapse.
17472        let two = Dep {
17473            nome: "caixa-teia".to_string(),
17474            versao: "^0.1".to_string(),
17475            fonte: None,
17476            opcional: false,
17477            caracteristicas: vec!["http".to_string(), "json".to_string()],
17478        };
17479        assert_eq!(
17480            two.caracteristicas(),
17481            &["http".to_string(), "json".to_string()],
17482        );
17483    }
17484
17485    #[test]
17486    fn dep_caracteristicas_is_by_borrow_pointer_identity() {
17487        // Zero-copy pin: the accessor must borrow into the field's own
17488        // `Vec<String>` storage, not clone into a side buffer. If a
17489        // future rewrite regresses to `self.caracteristicas.clone()` or
17490        // an owned-buffer shape, the two pointers diverge and this pin
17491        // fails at build time. Peer of the sibling per-`Dep`
17492        // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
17493        // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
17494        // borrow discipline extended onto the outer-`Dep` `&[String]`
17495        // slice-projection axis.
17496        let d = Dep {
17497            nome: "caixa-teia".to_string(),
17498            versao: "^0.1".to_string(),
17499            fonte: None,
17500            opcional: false,
17501            caracteristicas: vec!["http".to_string(), "json".to_string()],
17502        };
17503        assert!(std::ptr::eq(
17504            d.caracteristicas().as_ptr(),
17505            d.caracteristicas.as_ptr(),
17506        ));
17507    }
17508
17509    #[test]
17510    fn dep_validate_reads_caracteristicas_through_accessor() {
17511        // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
17512        // linear walk consumes the feature-toggle list through the
17513        // lifted accessor — a well-formed `:caracteristicas` set passes
17514        // (positive control), an empty-string entry surfaces the
17515        // [`DepError::CaracteristicaEmpty`] variant quoting the offending
17516        // `Dep::nome`, and a within-list duplicate surfaces the
17517        // [`DepError::CaracteristicaDuplicate`] variant so a future
17518        // regression that detoured the walk through a different byte-
17519        // string list (say a per-scope override projector) would surface
17520        // here at build time. Peer of the sibling
17521        // `dep_validate_reads_fonte_through_accessor` /
17522        // `dep_validate_reads_requirement_through_accessor` composition
17523        // pins on the `:fonte` / `:versao` axes.
17524        // Positive control: two distinct well-formed feature names pass.
17525        Dep {
17526            nome: "caixa-teia".to_string(),
17527            versao: "^0.1".to_string(),
17528            fonte: None,
17529            opcional: false,
17530            caracteristicas: vec!["http".to_string(), "json".to_string()],
17531        }
17532        .validate()
17533        .unwrap();
17534        // Negative control 1: empty-string feature-name entry — the
17535        // accessor still returns `&[""]` and the walk raises the typed
17536        // empty-first carrier.
17537        let err = Dep {
17538            nome: "caixa-teia".to_string(),
17539            versao: "^0.1".to_string(),
17540            fonte: None,
17541            opcional: false,
17542            caracteristicas: vec![String::new()],
17543        }
17544        .validate()
17545        .unwrap_err();
17546        assert!(
17547            matches!(
17548                &err,
17549                DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
17550            ),
17551            "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
17552        );
17553        // Negative control 2: within-list duplicate — the accessor's
17554        // slice view carries both entries, and the walk's dedup arm
17555        // raises the typed duplicate carrier quoting the offending
17556        // feature name verbatim.
17557        let err = Dep {
17558            nome: "caixa-teia".to_string(),
17559            versao: "^0.1".to_string(),
17560            fonte: None,
17561            opcional: false,
17562            caracteristicas: vec!["http".to_string(), "http".to_string()],
17563        }
17564        .validate()
17565        .unwrap_err();
17566        assert!(
17567            matches!(
17568                &err,
17569                DepError::CaracteristicaDuplicate {
17570                    nome,
17571                    caracteristica,
17572                } if nome == "caixa-teia" && caracteristica == "http",
17573            ),
17574            "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
17575        );
17576    }
17577
17578    // ── Dep::opcional accessor pins ───────────────────────────────────
17579    //
17580    // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
17581    // equal projection over the default-`false` / explicit-`true`
17582    // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
17583    // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
17584    // exercising the accessor's accept-set over every author-surface
17585    // `:fonte` shape × every author-surface `:opcional` shape; and by-
17586    // `Copy` idempotency so the projection stays value-return (no
17587    // silent detour to a fresh `&bool` borrow that would introduce a
17588    // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
17589    // shape elides). No composition pin — `:opcional` does not
17590    // participate in [`Dep::validate`] (an opcional dep with any bool
17591    // value is validate-accepted; the missing-source arm is a resolver-
17592    // side runtime dispatch, not a build-time refusal), so the axis
17593    // reduces to the value-shape + `Copy` pin pair the peer
17594    // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
17595    // outer-`Option<Copy>` accessor pins already carry.
17596
17597    #[test]
17598    fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
17599        // Default-`false` form via the [`Dep::simple`] constructor —
17600        // the accessor projects the `false` bit the default-fill sets.
17601        assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
17602        // Default-`false` form via the [`Dep::git`] constructor — same
17603        // default fill; the accessor projects `false` regardless of the
17604        // `:fonte` arm.
17605        assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
17606        // Explicit-`true` form × plain-shorthand `:fonte` — the
17607        // canonical author-surface "this dep may be missing" shape.
17608        let plain_true = Dep {
17609            nome: "caixa-teia".to_string(),
17610            versao: "^0.1".to_string(),
17611            fonte: None,
17612            opcional: true,
17613            caracteristicas: Vec::new(),
17614        };
17615        assert!(plain_true.opcional());
17616        // Explicit-`true` form × explicit git-source — the accessor
17617        // projects the bit verbatim regardless of the `:fonte` arm.
17618        let git_true = Dep {
17619            nome: "caixa-teia".to_string(),
17620            versao: "^0.1".to_string(),
17621            fonte: Some(DepSource::Git {
17622                repo: "github:pleme-io/caixa-teia".to_string(),
17623                tag: Some("v0.1.0".to_string()),
17624                rev: None,
17625                branch: None,
17626            }),
17627            opcional: true,
17628            caracteristicas: Vec::new(),
17629        };
17630        assert!(git_true.opcional());
17631        // Explicit-`true` form × explicit path-source — the dev-only
17632        // local-filesystem arm the [`Dep`] docstring's third fixture
17633        // carries.
17634        let path_true = Dep {
17635            nome: "caixa-teia".to_string(),
17636            versao: "0.1.0".to_string(),
17637            fonte: Some(DepSource::Path {
17638                caminho: "../caixa-teia".to_string(),
17639            }),
17640            opcional: true,
17641            caracteristicas: Vec::new(),
17642        };
17643        assert!(path_true.opcional());
17644    }
17645
17646    #[test]
17647    fn dep_opcional_projects_bool_by_copy() {
17648        // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
17649        // (`bool: Copy`) — the accessor does not borrow `&self` past
17650        // the call (no lifetime on the return type), and calling the
17651        // accessor twice on the same [`Dep`] must yield discriminant-
17652        // equal values (idempotent, no side effects on `&self`). Peer
17653        // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
17654        // `max_restarts_projects_option_by_copy` (eba5211) /
17655        // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
17656        // outer-`Caixa` altitude — extended here to the outer-`Dep`
17657        // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
17658        // replaces the pointer-equality claim the sibling per-`Dep`
17659        // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
17660        // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
17661        // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
17662        // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
17663        // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
17664        // the same discriminant, so the axis reduces to discriminant
17665        // equality).
17666        //
17667        // Pins against a future silent detour that returned a fresh
17668        // `&bool` reference (which would type-check but silently
17669        // introduce a borrow of `&self` past the call, collapsing the
17670        // load-bearing "no lifetime on the return type" `Copy`
17671        // projection the plain-`Copy`-scalar axis's `bool` shape
17672        // carries) or a stale-read side effect that flipped the outer
17673        // discriminant on successive calls.
17674        for opcional in [false, true] {
17675            let d = Dep {
17676                nome: "caixa-teia".to_string(),
17677                versao: "^0.1".to_string(),
17678                fonte: None,
17679                opcional,
17680                caracteristicas: Vec::new(),
17681            };
17682            let first = d.opcional();
17683            let second = d.opcional();
17684            assert_eq!(
17685                first, second,
17686                "Dep::opcional must be idempotent — two successive calls \
17687                 on the same &self must return the same bool",
17688            );
17689            assert_eq!(
17690                first, opcional,
17691                "Dep::opcional must return :opcional verbatim by Copy — \
17692                 got {first}, expected {opcional}",
17693            );
17694            assert_eq!(
17695                d.opcional(),
17696                d.opcional,
17697                "Dep::opcional accessor and self.opcional field access \
17698                 must byte-equal — a bit-flip drift would silently split \
17699                 the paired resolver-side drop-vs-error dispatch from \
17700                 the storage-side default-fill the [`Dep::simple`] / \
17701                 [`Dep::git`] constructor pair carries",
17702            );
17703        }
17704    }
17705
17706    // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
17707
17708    #[test]
17709    fn sole_pin_returns_none_for_path_source() {
17710        // A path source carries no git-ref, so `sole_pin()` returns
17711        // `None` structurally — the sibling arm every git-fetching
17712        // consumer partitions off before reaching for a git-ref. Pins
17713        // the Path-arm branch of the accessor against a future silent
17714        // detour that treats a `Self::Path` as an unpinned-git source
17715        // and returns the wrong "no pin" signal (e.g. the empty string,
17716        // or a hard-coded `Some("HEAD")` matching the caixa-crd
17717        // path-arm `git_ref` fill).
17718        let s = DepSource::Path {
17719            caminho: "../local-caixa".to_string(),
17720        };
17721        assert_eq!(s.sole_pin(), None);
17722    }
17723
17724    #[test]
17725    fn sole_pin_returns_none_for_unpinned_git_source() {
17726        // The [`DepSource::default_github`] shorthand shape carries no
17727        // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
17728        // returns `None`. This is the shape caixa-resolver's `fetch_dep`
17729        // materializes when the author omits `:fonte` entirely, then
17730        // hands to `fetch_git` which raises `ResolveError::MissingPin`
17731        // on the `None` arm — the accessor's return matches the arm
17732        // the resolver's diagnostic keys off.
17733        let s = DepSource::default_github("pleme-io", "caixa-teia");
17734        assert_eq!(s.sole_pin(), None);
17735    }
17736
17737    #[test]
17738    fn sole_pin_returns_rev_when_only_rev_is_set() {
17739        let s = DepSource::Git {
17740            repo: "github:o/x".into(),
17741            tag: None,
17742            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17743            branch: None,
17744        };
17745        assert_eq!(
17746            s.sole_pin(),
17747            Some("deadbeefcafebabe1234567890abcdef12345678")
17748        );
17749    }
17750
17751    #[test]
17752    fn sole_pin_returns_tag_when_only_tag_is_set() {
17753        let s = DepSource::Git {
17754            repo: "github:o/x".into(),
17755            tag: Some("v0.1.0".into()),
17756            rev: None,
17757            branch: None,
17758        };
17759        assert_eq!(s.sole_pin(), Some("v0.1.0"));
17760    }
17761
17762    #[test]
17763    fn sole_pin_returns_branch_when_only_branch_is_set() {
17764        let s = DepSource::Git {
17765            repo: "github:o/x".into(),
17766            tag: None,
17767            rev: None,
17768            branch: Some("main".into()),
17769        };
17770        assert_eq!(s.sole_pin(), Some("main"));
17771    }
17772
17773    #[test]
17774    fn sole_pin_precedence_rev_beats_tag_and_branch() {
17775        // Precedence: rev > tag > branch. Validate() rejects
17776        // multiple-pin shapes, but the accessor's precedence is defined
17777        // for pre-validate consumers (the resolver's `MissingPin`
17778        // diagnostic path, the caixa-crd round-trip's default `"main"`
17779        // fallback) and as defense-in-depth if the gate is ever
17780        // bypassed. Pins the same precedence caixa-resolver's
17781        // `fetch_git` and caixa-crd's `dep_into_ref` already apply
17782        // inline.
17783        let s = DepSource::Git {
17784            repo: "github:o/x".into(),
17785            tag: Some("v1".into()),
17786            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17787            branch: Some("main".into()),
17788        };
17789        assert_eq!(
17790            s.sole_pin(),
17791            Some("deadbeefcafebabe1234567890abcdef12345678")
17792        );
17793    }
17794
17795    #[test]
17796    fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
17797        let s = DepSource::Git {
17798            repo: "github:o/x".into(),
17799            tag: Some("v1".into()),
17800            rev: None,
17801            branch: Some("main".into()),
17802        };
17803        assert_eq!(s.sole_pin(), Some("v1"));
17804    }
17805
17806    #[test]
17807    fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
17808        // Fail-before-pass-after byte-parity pin: the substrate accessor
17809        // must return byte-identical to the inline
17810        // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
17811        // cascade both caixa-resolver's `fetch_git` and caixa-crd's
17812        // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
17813        // time if the accessor's precedence silently drifts from the
17814        // consumer-side cascade — the exact drift this lift converges
17815        // to one substrate primitive to close structurally.
17816        //
17817        // Iterates through the 2^3 = 8 combinations of (tag, rev,
17818        // branch) each-either-`None`-or-`Some`, so every arm of the
17819        // precedence cascade lands under the pin. `validate()` refuses
17820        // the 4 multi-pin combinations, but the accessor's return is
17821        // defined on all 8.
17822        let vals = [Some("R".to_string()), None];
17823        for tag in &vals {
17824            for rev in &vals {
17825                for branch in &vals {
17826                    let s = DepSource::Git {
17827                        repo: "github:o/x".into(),
17828                        tag: tag.clone(),
17829                        rev: rev.clone(),
17830                        branch: branch.clone(),
17831                    };
17832                    // The exact inline cascade the two pre-lift
17833                    // consumer sites hand-rolled, byte-for-byte.
17834                    let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
17835                    assert_eq!(
17836                        s.sole_pin(),
17837                        expected,
17838                        "sole_pin() must byte-equal \
17839                         rev.or(tag).or(branch) for \
17840                         (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
17841                         a drift would silently split caixa-resolver's \
17842                         fetch_git checkout target from caixa-crd's \
17843                         dep_into_ref git_ref fill",
17844                    );
17845                }
17846            }
17847        }
17848    }
17849
17850    // Fail-before-pass-after pins on the eleven
17851    // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
17852    // constructors folded from the [`DepSource::validate_caminho`]
17853    // wire-up sites. Each pins the generated ctor's output to the
17854    // pre-lift struct-literal on the same `(&str, &str)` fixture, so
17855    // any wrapper-side lowercase / trim / re-order / silent-field-swap
17856    // regression on the two-field `{ nome: nome.to_string(), caminho:
17857    // caminho.to_string() }` construction surfaces here rather than at
17858    // a downstream diagnostic-shape mismatch. Peer of the sibling
17859    // `empty_child_version_ctor_matches_struct_literal_wrap` /
17860    // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
17861    // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
17862    // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
17863    // pins on the peer `SupervisorError` / `AplicacaoError` /
17864    // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
17865
17866    #[test]
17867    fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
17868        assert_eq!(
17869            DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
17870            DepError::FonteCaminhoAbsolute {
17871                nome: "caixa-teia".to_string(),
17872                caminho: "/home/me/work/caixa-teia".to_string(),
17873            },
17874            "generated fonte_caminho_absolute ctor must produce byte-equal \
17875             DepError to the open-coded struct-literal wrap on the same \
17876             (&str, &str) fixture",
17877        );
17878    }
17879
17880    #[test]
17881    fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
17882        assert_eq!(
17883            DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
17884            DepError::FonteCaminhoTildeExpansion {
17885                nome: "caixa-teia".to_string(),
17886                caminho: "~/work/caixa-teia".to_string(),
17887            },
17888        );
17889    }
17890
17891    #[test]
17892    fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
17893        assert_eq!(
17894            DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
17895            DepError::FonteCaminhoVarExpansion {
17896                nome: "caixa-teia".to_string(),
17897                caminho: "$HOME/work/caixa-teia".to_string(),
17898            },
17899        );
17900    }
17901
17902    #[test]
17903    fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
17904        assert_eq!(
17905            DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
17906            DepError::FonteCaminhoLeadingWhitespace {
17907                nome: "caixa-teia".to_string(),
17908                caminho: " ../caixa-teia".to_string(),
17909            },
17910        );
17911    }
17912
17913    #[test]
17914    fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
17915        assert_eq!(
17916            DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
17917            DepError::FonteCaminhoLeadingHyphen {
17918                nome: "caixa-teia".to_string(),
17919                caminho: "-rf".to_string(),
17920            },
17921        );
17922    }
17923
17924    #[test]
17925    fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
17926        assert_eq!(
17927            DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
17928            DepError::FonteCaminhoBackslash {
17929                nome: "caixa-teia".to_string(),
17930                caminho: "..\\caixa-teia".to_string(),
17931            },
17932        );
17933    }
17934
17935    #[test]
17936    fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
17937        assert_eq!(
17938            DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
17939            DepError::FonteCaminhoShellPipe {
17940                nome: "caixa-teia".to_string(),
17941                caminho: "../caixa-teia|evil".to_string(),
17942            },
17943        );
17944    }
17945
17946    #[test]
17947    fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
17948        assert_eq!(
17949            DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
17950            DepError::FonteCaminhoShellSemicolon {
17951                nome: "caixa-teia".to_string(),
17952                caminho: "../caixa-teia;evil".to_string(),
17953            },
17954        );
17955    }
17956
17957    #[test]
17958    fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
17959        assert_eq!(
17960            DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
17961            DepError::FonteCaminhoShellBackground {
17962                nome: "caixa-teia".to_string(),
17963                caminho: "../caixa-teia&".to_string(),
17964            },
17965        );
17966    }
17967
17968    #[test]
17969    fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
17970        assert_eq!(
17971            DepError::fonte_caminho_shell_command_substitution(
17972                "caixa-teia",
17973                "../caixa-teia`whoami`",
17974            ),
17975            DepError::FonteCaminhoShellCommandSubstitution {
17976                nome: "caixa-teia".to_string(),
17977                caminho: "../caixa-teia`whoami`".to_string(),
17978            },
17979        );
17980    }
17981
17982    #[test]
17983    fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
17984        assert_eq!(
17985            DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
17986            DepError::FonteCaminhoTrailingSlash {
17987                nome: "caixa-teia".to_string(),
17988                caminho: "../caixa-teia/".to_string(),
17989            },
17990        );
17991    }
17992
17993    #[test]
17994    fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
17995        // Cross-axis pin: sweep the two constructor input axes
17996        // (`nome: &str`, `caminho: &str`) through a non-default fixture
17997        // pair against every generated arm in the
17998        // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
17999        // / trim / truncate / re-order on the two-field
18000        // `{ nome, caminho }` construction — or a silent field swap
18001        // between the two axes at codegen time — surfaces here rather
18002        // than at a downstream diagnostic-shape mismatch. Peer of the
18003        // sibling `supervisor_caixa_only_ctors_route_caixa_through_
18004        // to_string` cross-axis routing pin on the peer
18005        // `SupervisorError` envelope, extended here onto the
18006        // `DepError` `{ nome: String, caminho: String }` envelope so
18007        // every substrate-primitive ctor family in caixa-core
18008        // guarantees each `&str`-field construction routes the
18009        // caller's `&str` verbatim through `.to_string()`.
18010        let nome = "sibling-teia";
18011        let caminho = "../workspace/sibling";
18012        let cases: [(DepError, DepError); 11] = [
18013            (
18014                DepError::fonte_caminho_absolute(nome, caminho),
18015                DepError::FonteCaminhoAbsolute {
18016                    nome: nome.to_string(),
18017                    caminho: caminho.to_string(),
18018                },
18019            ),
18020            (
18021                DepError::fonte_caminho_tilde_expansion(nome, caminho),
18022                DepError::FonteCaminhoTildeExpansion {
18023                    nome: nome.to_string(),
18024                    caminho: caminho.to_string(),
18025                },
18026            ),
18027            (
18028                DepError::fonte_caminho_var_expansion(nome, caminho),
18029                DepError::FonteCaminhoVarExpansion {
18030                    nome: nome.to_string(),
18031                    caminho: caminho.to_string(),
18032                },
18033            ),
18034            (
18035                DepError::fonte_caminho_leading_whitespace(nome, caminho),
18036                DepError::FonteCaminhoLeadingWhitespace {
18037                    nome: nome.to_string(),
18038                    caminho: caminho.to_string(),
18039                },
18040            ),
18041            (
18042                DepError::fonte_caminho_leading_hyphen(nome, caminho),
18043                DepError::FonteCaminhoLeadingHyphen {
18044                    nome: nome.to_string(),
18045                    caminho: caminho.to_string(),
18046                },
18047            ),
18048            (
18049                DepError::fonte_caminho_backslash(nome, caminho),
18050                DepError::FonteCaminhoBackslash {
18051                    nome: nome.to_string(),
18052                    caminho: caminho.to_string(),
18053                },
18054            ),
18055            (
18056                DepError::fonte_caminho_shell_pipe(nome, caminho),
18057                DepError::FonteCaminhoShellPipe {
18058                    nome: nome.to_string(),
18059                    caminho: caminho.to_string(),
18060                },
18061            ),
18062            (
18063                DepError::fonte_caminho_shell_semicolon(nome, caminho),
18064                DepError::FonteCaminhoShellSemicolon {
18065                    nome: nome.to_string(),
18066                    caminho: caminho.to_string(),
18067                },
18068            ),
18069            (
18070                DepError::fonte_caminho_shell_background(nome, caminho),
18071                DepError::FonteCaminhoShellBackground {
18072                    nome: nome.to_string(),
18073                    caminho: caminho.to_string(),
18074                },
18075            ),
18076            (
18077                DepError::fonte_caminho_shell_command_substitution(nome, caminho),
18078                DepError::FonteCaminhoShellCommandSubstitution {
18079                    nome: nome.to_string(),
18080                    caminho: caminho.to_string(),
18081                },
18082            ),
18083            (
18084                DepError::fonte_caminho_trailing_slash(nome, caminho),
18085                DepError::FonteCaminhoTrailingSlash {
18086                    nome: nome.to_string(),
18087                    caminho: caminho.to_string(),
18088                },
18089            ),
18090        ];
18091        for (via_ctor, via_struct_literal) in cases {
18092            assert_eq!(
18093                via_ctor, via_struct_literal,
18094                "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
18095                 through `.to_string()` in declared field order — a field-swap or \
18096                 silent-conversion regression surfaces here rather than at a \
18097                 downstream diagnostic-shape mismatch",
18098            );
18099        }
18100    }
18101
18102    // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
18103    //    envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
18104    //    (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
18105    //    enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
18106    //    `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
18107
18108    #[test]
18109    fn versao_empty_ctor_matches_struct_literal_wrap() {
18110        assert_eq!(
18111            DepError::versao_empty("caixa-teia"),
18112            DepError::VersaoEmpty {
18113                nome: "caixa-teia".to_string(),
18114            },
18115        );
18116    }
18117
18118    #[test]
18119    fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
18120        assert_eq!(
18121            DepError::fonte_repo_empty("caixa-teia"),
18122            DepError::FonteRepoEmpty {
18123                nome: "caixa-teia".to_string(),
18124            },
18125        );
18126    }
18127
18128    #[test]
18129    fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
18130        assert_eq!(
18131            DepError::fonte_pin_missing("caixa-teia"),
18132            DepError::FontePinMissing {
18133                nome: "caixa-teia".to_string(),
18134            },
18135        );
18136    }
18137
18138    #[test]
18139    fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
18140        assert_eq!(
18141            DepError::fonte_caminho_empty("caixa-teia"),
18142            DepError::FonteCaminhoEmpty {
18143                nome: "caixa-teia".to_string(),
18144            },
18145        );
18146    }
18147
18148    #[test]
18149    fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
18150        assert_eq!(
18151            DepError::caracteristica_empty("caixa-teia"),
18152            DepError::CaracteristicaEmpty {
18153                nome: "caixa-teia".to_string(),
18154            },
18155        );
18156    }
18157
18158    #[test]
18159    fn dep_nome_only_ctors_route_nome_through_to_string() {
18160        // Cross-axis routing pin: sweep the single constructor input
18161        // axis (`nome: &str`) through a non-default fixture against
18162        // every generated arm in the [`dep_nome_only_ctors!`] macro, so
18163        // any wrapper-side lowercase / trim / truncate at codegen time
18164        // — or a silent field re-name away from the canonical `nome`
18165        // axis on any one variant — surfaces here rather than at a
18166        // downstream diagnostic-shape mismatch. Peer of the sibling
18167        // `fonte_caminho_ctors_route_nome_and_caminho_through_
18168        // to_string` cross-axis routing pin on the same envelope's
18169        // two-slot family (f85f145) and of the peer
18170        // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
18171        // pin on the `SupervisorError` single-slot family (db09650).
18172        let nome = "sibling-teia";
18173        let cases: [(DepError, DepError); 5] = [
18174            (
18175                DepError::versao_empty(nome),
18176                DepError::VersaoEmpty {
18177                    nome: nome.to_string(),
18178                },
18179            ),
18180            (
18181                DepError::fonte_repo_empty(nome),
18182                DepError::FonteRepoEmpty {
18183                    nome: nome.to_string(),
18184                },
18185            ),
18186            (
18187                DepError::fonte_pin_missing(nome),
18188                DepError::FontePinMissing {
18189                    nome: nome.to_string(),
18190                },
18191            ),
18192            (
18193                DepError::fonte_caminho_empty(nome),
18194                DepError::FonteCaminhoEmpty {
18195                    nome: nome.to_string(),
18196                },
18197            ),
18198            (
18199                DepError::caracteristica_empty(nome),
18200                DepError::CaracteristicaEmpty {
18201                    nome: nome.to_string(),
18202                },
18203            ),
18204        ];
18205        for (via_ctor, via_struct_literal) in cases {
18206            assert_eq!(
18207                via_ctor, via_struct_literal,
18208                "dep_nome_only_ctors!-generated ctor must route `nome` \
18209                 through `.to_string()` onto the canonical `nome` field \
18210                 — a field-rename or silent-conversion regression surfaces \
18211                 here rather than at a downstream diagnostic-shape mismatch",
18212            );
18213        }
18214    }
18215
18216    // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
18217    //    &'static str }` two-slot envelope on `DepError`, strict
18218    //    sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
18219    //    same envelope's `{ nome: String }` one-slot shape and of the
18220    //    peer `supervisor_caixa_only_ctors!` (db09650) on the
18221    //    `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
18222
18223    #[test]
18224    fn duplicate_nome_ctor_matches_struct_literal_wrap() {
18225        assert_eq!(
18226            DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
18227            DepError::DuplicateNome {
18228                nome: "caixa-teia".to_string(),
18229                list: crate::render::DEP_AUTHOR_KEY_DEPS,
18230            },
18231            "generated duplicate_nome ctor must produce byte-equal \
18232             `DepError::DuplicateNome` to the pre-lift struct-literal \
18233             wrap on the same scalar fixtures",
18234        );
18235    }
18236
18237    #[test]
18238    fn dep_is_self_ctor_matches_struct_literal_wrap() {
18239        assert_eq!(
18240            DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18241            DepError::DepIsSelf {
18242                nome: "orquestra".to_string(),
18243                list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18244            },
18245            "generated dep_is_self ctor must produce byte-equal \
18246             `DepError::DepIsSelf` to the pre-lift struct-literal \
18247             wrap on the same scalar fixtures",
18248        );
18249    }
18250
18251    #[test]
18252    fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
18253        // Cross-axis routing pin: sweep the two constructor input axes
18254        // (`nome: &str`, `list: &'static str`) through non-default
18255        // fixtures against every generated arm in the
18256        // [`dep_nome_list_ctors!`] macro, so any wrapper-side
18257        // lowercase / trim / truncate at codegen time — or a silent
18258        // field re-name away from the canonical `nome` / `list` axes
18259        // on any one variant, or a `list` axis silently rerouted
18260        // through `.to_string()` instead of passed as `&'static str`
18261        // verbatim — surfaces here rather than at a downstream
18262        // diagnostic-shape mismatch. Peer of the sibling
18263        // `dep_nome_only_ctors_route_nome_through_to_string` pin
18264        // (792aa92) on the same envelope's one-slot family, and of the
18265        // peer
18266        // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
18267        // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
18268        // two-slot `{ caixa: String, reason: String }` shape.
18269        let nome = "sibling-teia";
18270        let cases: [(DepError, DepError); 4] = [
18271            (
18272                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
18273                DepError::DuplicateNome {
18274                    nome: nome.to_string(),
18275                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
18276                },
18277            ),
18278            (
18279                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18280                DepError::DuplicateNome {
18281                    nome: nome.to_string(),
18282                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18283                },
18284            ),
18285            (
18286                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
18287                DepError::DepIsSelf {
18288                    nome: nome.to_string(),
18289                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
18290                },
18291            ),
18292            (
18293                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18294                DepError::DepIsSelf {
18295                    nome: nome.to_string(),
18296                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18297                },
18298            ),
18299        ];
18300        for (via_ctor, via_struct_literal) in cases {
18301            assert_eq!(
18302                via_ctor, via_struct_literal,
18303                "dep_nome_list_ctors!-generated ctor must route `nome` \
18304                 through `.to_string()` onto the canonical `nome` field \
18305                 and pass `list` verbatim onto the canonical `&'static str` \
18306                 `list` field — a field-rename, silent-conversion, or \
18307                 axis-swap regression surfaces here rather than at a \
18308                 downstream diagnostic-shape mismatch",
18309            );
18310        }
18311    }
18312
18313    // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
18314    //    value: String, reason: String }` four-slot envelope on
18315    //    `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
18316    //    `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
18317    //    and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
18318    //    envelope, and of the peer `contrato_pair_value_reason_ctors!`
18319    //    (14e13f1) four-slot fold on the sibling `AplicacaoError`
18320    //    envelope. Single-variant lift closing the last open-coded ctor
18321    //    site on the `:fonte (:tipo git …)` value-shape trajectory.
18322
18323    #[test]
18324    fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
18325        // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
18326        // ctor: sweep both wire-up-shape arms (the refname-pin arm
18327        // routing `":tag"` / `":branch"` value through
18328        // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
18329        // routing `":rev"` through [`crate::render::is_git_oid`]) and
18330        // assert byte-equal `PartialEq` against the pre-lift
18331        // struct-literal, so any wrapper-side field-rename /
18332        // silent-conversion regression surfaces here rather than at a
18333        // downstream diagnostic-shape mismatch. Peer of the sibling
18334        // per-envelope byte-equal ctor pins
18335        // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
18336        // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
18337        // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
18338        assert_eq!(
18339            DepError::fonte_pin_shape(
18340                "caixa-teia",
18341                ":tag",
18342                "v0.1.0 ",
18343                "trailing whitespace".to_string(),
18344            ),
18345            DepError::FontePinShape {
18346                nome: "caixa-teia".to_string(),
18347                pin: ":tag".to_string(),
18348                value: "v0.1.0 ".to_string(),
18349                reason: "trailing whitespace".to_string(),
18350            },
18351            "fonte_pin_shape ctor must produce byte-equal \
18352             `DepError::FontePinShape` to the pre-lift struct-literal \
18353             wrap on a refname-pin (`:tag` / `:branch`) fixture",
18354        );
18355        assert_eq!(
18356            DepError::fonte_pin_shape(
18357                "caixa-teia",
18358                ":rev",
18359                "DEADBEEF",
18360                "abbreviated OID rejected".to_string(),
18361            ),
18362            DepError::FontePinShape {
18363                nome: "caixa-teia".to_string(),
18364                pin: ":rev".to_string(),
18365                value: "DEADBEEF".to_string(),
18366                reason: "abbreviated OID rejected".to_string(),
18367            },
18368            "fonte_pin_shape ctor must produce byte-equal \
18369             `DepError::FontePinShape` to the pre-lift struct-literal \
18370             wrap on a hex-OID-pin (`:rev`) fixture",
18371        );
18372    }
18373
18374    #[test]
18375    fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
18376        // Cross-axis routing pin: sweep every one of the four
18377        // constructor input axes (`nome: &str`, `pin: &str`,
18378        // `value: &str`, `reason: String`) through non-default
18379        // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
18380        // any wrapper-side lowercase / trim / truncate at codegen time
18381        // — or a silent field re-name / axis-swap on any one of the
18382        // four fields, or a `reason` axis silently routed through
18383        // `.to_string()` instead of forwarded owned — surfaces here
18384        // rather than at a downstream diagnostic-shape mismatch. Peer
18385        // of the sibling
18386        // `dep_nome_only_ctors_route_nome_through_to_string` pin
18387        // (792aa92) and
18388        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
18389        // pin (6f5e0cd) on the same envelope's one- and two-slot
18390        // families. Distinct-per-axis fixtures rule out any two-axis
18391        // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
18392        // etc.) that would still pass a same-fixture-per-axis pin.
18393        let nome = "sibling-teia";
18394        let pin = ":branch";
18395        let value = "feature/bar";
18396        let reason = "embedded space".to_string();
18397        let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
18398        let via_struct_literal = DepError::FontePinShape {
18399            nome: nome.to_string(),
18400            pin: pin.to_string(),
18401            value: value.to_string(),
18402            reason: reason.clone(),
18403        };
18404        assert_eq!(
18405            via_ctor, via_struct_literal,
18406            "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
18407             through `.to_string()` onto their canonical fields and \
18408             forward `reason` owned onto the canonical `reason` field \
18409             — a field-rename, silent-conversion, or axis-swap \
18410             regression surfaces here rather than at a downstream \
18411             diagnostic-shape mismatch",
18412        );
18413        let DepError::FontePinShape {
18414            nome: n,
18415            pin: p,
18416            value: v,
18417            reason: r,
18418        } = via_ctor
18419        else {
18420            panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
18421        };
18422        assert_eq!(n, nome);
18423        assert_eq!(p, pin);
18424        assert_eq!(v, value);
18425        assert_eq!(r, reason);
18426    }
18427
18428    // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
18429    //    caminho: String, byte: u8 }` three-slot envelope on `DepError`,
18430    //    strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
18431    //    the same envelope's `{ nome: String, caminho: String }` two-slot
18432    //    shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
18433    //    same envelope's `{ nome: String }` one-slot shape.
18434
18435    #[test]
18436    fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
18437        assert_eq!(
18438            DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
18439            DepError::FonteCaminhoControlChar {
18440                nome: "caixa-teia".to_string(),
18441                caminho: "../caixa-teia\x00foo".to_string(),
18442                byte: 0x00,
18443            },
18444        );
18445    }
18446
18447    #[test]
18448    fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
18449        assert_eq!(
18450            DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
18451            DepError::FonteCaminhoShellRedirection {
18452                nome: "caixa-teia".to_string(),
18453                caminho: "../caixa-teia>log".to_string(),
18454                byte: b'>',
18455            },
18456        );
18457    }
18458
18459    #[test]
18460    #[allow(
18461        clippy::too_many_lines,
18462        reason = "cross-axis routing pin sweeps twelve typed variants, one per \
18463                  byte-classification arm on the {nome,caminho,byte} envelope; \
18464                  the linear per-variant repetition is exactly what the sweep \
18465                  is pinning — a helper macro would hide the shape the fold is \
18466                  keying on"
18467    )]
18468    fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
18469        // Cross-axis routing pin: sweep the three constructor input axes
18470        // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
18471        // non-default fixture triple against every generated arm in the
18472        // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
18473        // lowercase / trim / truncate on the two `&str` axes — a silent
18474        // field swap between `nome` and `caminho`, or a silent
18475        // re-classification of the offending byte — surfaces here rather
18476        // than at a downstream diagnostic-shape mismatch. Peer of the
18477        // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
18478        // to_string` cross-axis routing pin on the same envelope's
18479        // two-slot family (f85f145) and of the sibling
18480        // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
18481        // same envelope's one-slot family (792aa92), extended here onto
18482        // the `{ nome: String, caminho: String, byte: u8 }` three-slot
18483        // envelope so every substrate-primitive ctor family in
18484        // caixa-core's `DepError` envelope guarantees each field routes
18485        // the caller's value verbatim through `.to_string()` (or byte-
18486        // identity for `byte: u8`) in declared field order.
18487        let nome = "sibling-teia";
18488        let caminho = "../workspace/sibling";
18489        let byte = 0x2A_u8;
18490        let cases: [(DepError, DepError); 12] = [
18491            (
18492                DepError::fonte_caminho_control_char(nome, caminho, byte),
18493                DepError::FonteCaminhoControlChar {
18494                    nome: nome.to_string(),
18495                    caminho: caminho.to_string(),
18496                    byte,
18497                },
18498            ),
18499            (
18500                DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
18501                DepError::FonteCaminhoShellRedirection {
18502                    nome: nome.to_string(),
18503                    caminho: caminho.to_string(),
18504                    byte,
18505                },
18506            ),
18507            (
18508                DepError::fonte_caminho_shell_glob(nome, caminho, byte),
18509                DepError::FonteCaminhoShellGlob {
18510                    nome: nome.to_string(),
18511                    caminho: caminho.to_string(),
18512                    byte,
18513                },
18514            ),
18515            (
18516                DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
18517                DepError::FonteCaminhoShellSubshellGrouping {
18518                    nome: nome.to_string(),
18519                    caminho: caminho.to_string(),
18520                    byte,
18521                },
18522            ),
18523            (
18524                DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
18525                DepError::FonteCaminhoShellBraceExpansion {
18526                    nome: nome.to_string(),
18527                    caminho: caminho.to_string(),
18528                    byte,
18529                },
18530            ),
18531            (
18532                DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
18533                DepError::FonteCaminhoShellBracketExpansion {
18534                    nome: nome.to_string(),
18535                    caminho: caminho.to_string(),
18536                    byte,
18537                },
18538            ),
18539            (
18540                DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
18541                DepError::FonteCaminhoShellQuoteGrouping {
18542                    nome: nome.to_string(),
18543                    caminho: caminho.to_string(),
18544                    byte,
18545                },
18546            ),
18547            (
18548                DepError::fonte_caminho_shell_comment(nome, caminho, byte),
18549                DepError::FonteCaminhoShellComment {
18550                    nome: nome.to_string(),
18551                    caminho: caminho.to_string(),
18552                    byte,
18553                },
18554            ),
18555            (
18556                DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
18557                DepError::FonteCaminhoUrlPercentEncoding {
18558                    nome: nome.to_string(),
18559                    caminho: caminho.to_string(),
18560                    byte,
18561                },
18562            ),
18563            (
18564                DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
18565                DepError::FonteCaminhoShellVariableExpansion {
18566                    nome: nome.to_string(),
18567                    caminho: caminho.to_string(),
18568                    byte,
18569                },
18570            ),
18571            (
18572                DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
18573                DepError::FonteCaminhoShellHistoryExpansion {
18574                    nome: nome.to_string(),
18575                    caminho: caminho.to_string(),
18576                    byte,
18577                },
18578            ),
18579            (
18580                DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
18581                DepError::FonteCaminhoShellHistorySubstitution {
18582                    nome: nome.to_string(),
18583                    caminho: caminho.to_string(),
18584                    byte,
18585                },
18586            ),
18587        ];
18588        for (via_ctor, via_struct_literal) in cases {
18589            assert_eq!(
18590                via_ctor, via_struct_literal,
18591                "fonte_caminho_byte_ctors!-generated ctor must route \
18592                 (nome, caminho, byte) through `.to_string()` / byte-\
18593                 identity in declared field order — a field-swap or \
18594                 silent-conversion regression surfaces here rather than \
18595                 at a downstream diagnostic-shape mismatch",
18596            );
18597        }
18598    }
18599
18600    #[test]
18601    fn dep_list_as_ref_str_routes_through_as_str_accessor() {
18602        // Fail-before-pass-after byte-parity pin on the lifted
18603        // `impl AsRef<str> for DepList` — asserts the standard-
18604        // library trait impl and the substrate-primitive
18605        // [`super::DepList::as_str`] `pub const fn` accessor resolve
18606        // to the same `&str` per instance across the two-arm closed
18607        // set, so any future silent detour that routes the impl
18608        // through a divergent projection (a per-arm inline
18609        // `match self { DepList::Prod => ":deps", … }` re-inlining
18610        // that opens a compile-time link to the un-lifted arm-literal,
18611        // a swap onto a second projection axis) trips at caixa-core
18612        // test time under `PartialEq` rather than at a downstream
18613        // `impl AsRef<str>`-bound consumer's silent split. Sweeps
18614        // every one of the two arms [`super::DepList::ALL`] carries
18615        // so no arm's projection is covered only by the sibling
18616        // `Display` path. Peer of the sibling
18617        // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
18618        // (1723611) on the top-level dialect-classification closed-
18619        // set typed enum, and the peer
18620        // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
18621        // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
18622        // typed enum — the pins together close the substrate
18623        // primitive's `AsRef<str>` projection axis onto the seventh
18624        // (and last unlifted) closed-set typed enum on the caixa
18625        // surface.
18626        for &list in super::DepList::ALL {
18627            assert_eq!(
18628                <super::DepList as AsRef<str>>::as_ref(&list),
18629                list.as_str(),
18630                "AsRef<str> impl on DepList::{list:?} must byte-equal \
18631                 DepList::as_str on the same instance — divergence \
18632                 signals a silent detour off the substrate-primitive \
18633                 accessor"
18634            );
18635        }
18636    }
18637
18638    #[test]
18639    fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
18640        // Fail-before-pass-after byte-parity pin on the three-path
18641        // convergence discipline the [`super::DepList`] two-list
18642        // dep-graph closed-set typed enum now carries on the `&str`-
18643        // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
18644        // newly lifted impl), `format!("{v}")` (the pre-existing
18645        // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
18646        // primitive `pub const fn` accessor both trait impls delegate
18647        // through) must resolve to the same byte-string on every
18648        // instance across the two-arm closed set. Refuses any future
18649        // divergence between the two trait impls (a stray
18650        // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
18651        // rather than delegating through the shared accessor; a
18652        // hypothetical `AsRef<str>` rewrite that inlines a per-arm
18653        // literal cascade) that would silently split the two
18654        // projection paths of the same closed-set typed enum. Mirrors
18655        // the sibling three-path-convergence discipline the peer
18656        // [`crate::CaixaDialeto`] typed enum carries
18657        // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
18658        // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
18659        // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
18660        // d8136db), the peer [`crate::CaixaKind`] triple
18661        // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
18662        // cd2091f), and the [`crate::CaixaVersion`] typed newtype
18663        // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
18664        // 16d5c7e).
18665        for &list in super::DepList::ALL {
18666            let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
18667            let via_display: String = format!("{list}");
18668            let via_accessor: &str = list.as_str();
18669            assert_eq!(via_as_ref, via_accessor);
18670            assert_eq!(via_display, via_accessor);
18671            assert_eq!(via_as_ref, via_display.as_str());
18672        }
18673    }
18674
18675    #[test]
18676    fn dep_list_try_from_str_routes_through_from_wire_accessor() {
18677        // Fail-before-pass-after byte-parity pin on the newly lifted
18678        // `impl TryFrom<&str> for DepList` — asserts the standard-
18679        // library trait impl and the substrate-primitive
18680        // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
18681        // to the same two-arm accept-set across every arm the
18682        // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
18683        // the sibling
18684        // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
18685        // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
18686        // and the 12 other substrate-wide trait-idiomatic reverse-
18687        // projection routes-through pins — closes the campaign's
18688        // completeness gap on the two-list dep-graph closed-set enum.
18689        for &list in super::DepList::ALL {
18690            let wire = list.as_str();
18691            assert_eq!(
18692                <super::DepList as TryFrom<&str>>::try_from(wire),
18693                Ok(list),
18694                "TryFrom<&str> impl on DepList must round-trip \
18695                 DepList::{list:?}.as_str() = {wire:?} back to \
18696                 Ok(DepList::{list:?}) — divergence from \
18697                 DepList::from_wire signals a silent detour off the \
18698                 substrate-primitive accessor"
18699            );
18700            assert_eq!(
18701                <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
18702                super::DepList::from_wire(wire),
18703                "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
18704                 DepList::from_wire on the same input"
18705            );
18706        }
18707    }
18708
18709    #[test]
18710    fn dep_list_try_from_str_rejects_unknown_byte_strings() {
18711        // Rejection witness on the `impl TryFrom<&str> for DepList` —
18712        // sweeps candidate byte-strings outside the two-arm accept-set
18713        // the sibling [`super::DepList::as_str`] emits (`:deps` /
18714        // `:deps-dev`) and asserts every one lands on `Err(())`, so a
18715        // future accidental widening of the trait impl's accept-set (a
18716        // stray case-fold path, a silent inclusion of a rebrand alias
18717        // like `":packages"`, an English rebrand `":dev-deps"` in
18718        // reverse arm-order that would silently swap the two arms) trips
18719        // at caixa-core test time. Peer of the sibling
18720        // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
18721        // (5b828ed) rejection witness.
18722        let rejected: &[&str] = &[
18723            "",
18724            " ",
18725            "\t",
18726            "\n",
18727            ":deps ",
18728            " :deps",
18729            ":DEPS",
18730            ":Deps",
18731            ":Deps-Dev",
18732            ":deps_dev",
18733            ":deps-development",
18734            ":dev-deps",
18735            ":packages",
18736            ":packages-dev",
18737            "deps",
18738            "deps-dev",
18739            "Prod",
18740            "Dev",
18741            "prod",
18742            "dev",
18743            "\":deps\"",
18744            "\":deps-dev\"",
18745            ":deps\n",
18746            ":deps-dev\n",
18747        ];
18748        for &input in rejected {
18749            assert_eq!(
18750                <super::DepList as TryFrom<&str>>::try_from(input),
18751                Err(()),
18752                "TryFrom<&str> impl on DepList must reject unknown \
18753                 byte-string {input:?} — divergence from \
18754                 DepList::from_wire on the same input signals a silent \
18755                 accept-set widening past the two lifted \
18756                 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
18757            );
18758            assert_eq!(
18759                <super::DepList as TryFrom<&str>>::try_from(input).ok(),
18760                super::DepList::from_wire(input),
18761                "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
18762                 DepList::from_wire on the same input — divergence signals \
18763                 the two reverse-projection paths have drifted onto \
18764                 different accept-sets"
18765            );
18766        }
18767    }
18768
18769    #[test]
18770    fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
18771        // Fail-before-pass-after byte-parity pin on the newly lifted
18772        // `impl From<DepList> for &'static str` — asserts the standard-
18773        // library trait impl and the substrate-primitive
18774        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18775        // the same two-arm emit-set across every arm the exhaustive
18776        // [`super::DepList::ALL`] slice enumerates. Materializes the
18777        // `<&'static str as From<DepList>>::from` output in a
18778        // `const`-shape binding to make the `'static` lifetime promise
18779        // a build-time invariant — a future accidental downgrade of
18780        // either arm to a non-`&'static str` (a `String::leak()`-
18781        // produced return, a `Box::leak`-cast) trips at caixa-core
18782        // build time rather than at a downstream `'static`-bound
18783        // consumer. Peer of the sibling
18784        // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
18785        // (523157d) and the 13 other substrate-wide forward-projection
18786        // routes-through pins.
18787        const PROD: &str = super::DepList::Prod.as_str();
18788        const DEV: &str = super::DepList::Dev.as_str();
18789        for &list in super::DepList::ALL {
18790            let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18791            let via_method: &'static str = list.as_str();
18792            assert_eq!(
18793                via_trait, via_method,
18794                "From<DepList> for &'static str impl must round-trip \
18795                 DepList::{list:?} to the same lifted \
18796                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18797                 DepList::as_str returns — divergence signals a silent \
18798                 detour off the substrate-primitive accessor"
18799            );
18800            let via_into: &'static str = list.into();
18801            assert_eq!(
18802                via_into, via_method,
18803                "Into<&'static str>::into on DepList::{list:?} must \
18804                 byte-equal DepList::as_str on the same input — the \
18805                 blanket-derived Into shape must resolve to the same \
18806                 as_str dispatch as the explicit From impl"
18807            );
18808        }
18809        assert_eq!(
18810            [PROD, DEV],
18811            [
18812                crate::render::DEP_AUTHOR_KEY_DEPS,
18813                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18814            ],
18815            "const-context DepList::as_str must resolve to the two lifted \
18816             DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
18817             of either arm to a non-const or non-static byte-string breaks \
18818             the `&'static str`-lifetime promise the paired \
18819             From<DepList> for &'static str impl carries by construction"
18820        );
18821    }
18822
18823    #[test]
18824    fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
18825        // Cross-axis partition pin: the paired trait-idiomatic
18826        // `From<DepList> for &'static str` forward projection and the
18827        // method-named [`super::DepList::as_str`] forward projection
18828        // must resolve identically on every arm, locking the two paths
18829        // together so any future detour trips at caixa-core test time.
18830        // Then a round-trip witness: every arm's forward `From` output
18831        // re-parses through the paired trait-idiomatic reverse
18832        // `TryFrom<&str>` back to the original variant, closing the
18833        // two-way `DepList ↔ &'static str` round-trip on the trait-
18834        // idiomatic axis pair, mirroring the pre-existing method-named
18835        // `as_str` + `from_wire` round-trip. Peer of the sibling
18836        // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
18837        // (523157d).
18838        for &list in super::DepList::ALL {
18839            let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18840            let via_method: &'static str = list.as_str();
18841            assert_eq!(
18842                via_trait, via_method,
18843                "From<DepList> for &'static str and DepList::as_str must \
18844                 resolve identically on DepList::{list:?} — divergence \
18845                 signals the two forward-projection paths have drifted \
18846                 onto different emit-sets"
18847            );
18848        }
18849        for &list in super::DepList::ALL {
18850            let emitted: &'static str = list.into();
18851            let re_parsed: Result<super::DepList, ()> =
18852                <super::DepList as TryFrom<&str>>::try_from(emitted);
18853            assert_eq!(
18854                re_parsed,
18855                Ok(list),
18856                "trait-idiomatic axis pair must round-trip \
18857                 DepList::{list:?} through `.into::<&'static str>()` and \
18858                 back through `TryFrom<&str>` — a break signals the \
18859                 forward-emit and reverse-parse axes have drifted onto \
18860                 different vocabularies"
18861            );
18862        }
18863    }
18864
18865    #[test]
18866    fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
18867        // Fail-before-pass-after byte-parity pin on the newly lifted
18868        // `impl From<&DepList> for &'static str` — asserts the borrowed-
18869        // input standard-library trait impl and the substrate-primitive
18870        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18871        // the same two-arm emit-set across every arm the exhaustive
18872        // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
18873        // does not auto-derive the borrowed-input sibling from a paired
18874        // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
18875        // U: From<T>` blanket in `core`), so the borrowed-input axis is
18876        // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
18877        // shape over [`super::DepList::ALL`] (whose iterator yields
18878        // `&DepList`, not `DepList`) reaches through this impl and no
18879        // other — the paired owned-input [`From<DepList>`] impl requires
18880        // an explicit `.copied()` / dereference before the trait fires.
18881        // Materializes the `<&'static str as From<&DepList>>::from`
18882        // output in a `const`-shape binding to make the `'static`
18883        // lifetime promise a build-time invariant.
18884        const PROD: &str = super::DepList::Prod.as_str();
18885        const DEV: &str = super::DepList::Dev.as_str();
18886        for list in super::DepList::ALL {
18887            let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
18888            let via_method: &'static str = list.as_str();
18889            assert_eq!(
18890                via_trait, via_method,
18891                "From<&DepList> for &'static str impl must round-trip \
18892                 &DepList::{list:?} to the same lifted \
18893                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18894                 DepList::as_str returns — divergence signals a silent \
18895                 detour off the substrate-primitive accessor"
18896            );
18897            let via_into: &'static str = list.into();
18898            assert_eq!(
18899                via_into, via_method,
18900                "Into<&'static str>::into on &DepList::{list:?} must \
18901                 byte-equal DepList::as_str on the same input — the \
18902                 blanket-derived Into shape must resolve to the same \
18903                 as_str dispatch as the explicit From impl"
18904            );
18905        }
18906        assert_eq!(
18907            [PROD, DEV],
18908            [
18909                crate::render::DEP_AUTHOR_KEY_DEPS,
18910                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18911            ],
18912            "const-context DepList::as_str must resolve to the two lifted \
18913             DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
18914             From<&DepList> for &'static str impl inherits its `'static` \
18915             lifetime promise from the same accessor the owned-input \
18916             sibling routes through"
18917        );
18918    }
18919
18920    #[test]
18921    fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
18922        // Cross-axis partition pin: the paired trait-idiomatic
18923        // owned-input `From<DepList> for &'static str` (523157d
18924        // campaign-shape) and borrowed-input `From<&DepList> for
18925        // &'static str` (this lift) forward projections must resolve
18926        // identically on every arm, locking the two input-shape paths
18927        // together so any future detour trips at caixa-core test time.
18928        // Then a witness that a `.iter().map(Into::into)` pipe over
18929        // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
18930        // materializes the two-arm accept-set through the borrowed-
18931        // input axis alone — the exact shape a future M4 admission-
18932        // webhook rejection body composer, a future substrate-wide
18933        // per-arm diagnostic column, or a
18934        // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
18935        //     .map(|l| (l.into(), *l)))`-style per-list lookup reaches
18936        // through — closing the two-way owned/borrowed input-shape
18937        // symmetry on the forward-projection trait-idiomatic axis.
18938        for &list in super::DepList::ALL {
18939            let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
18940            let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
18941            assert_eq!(
18942                owned, borrowed,
18943                "From<DepList> and From<&DepList> for &'static str must \
18944                 resolve identically on DepList::{list:?} — divergence \
18945                 signals the owned-input and borrowed-input forward-\
18946                 projection paths have drifted onto different emit-sets"
18947            );
18948        }
18949        let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
18950        let via_method: Vec<&'static str> =
18951            super::DepList::ALL.iter().map(|l| l.as_str()).collect();
18952        assert_eq!(
18953            via_iter, via_method,
18954            "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
18955             `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
18956             input `From<&DepList> for &'static str` axis is what makes \
18957             the `.iter().map(Into::into)` shape route through the \
18958             substrate-primitive `DepList::as_str` accessor rather than \
18959             through a per-call-site `.copied()` / dereference detour"
18960        );
18961    }
18962
18963    #[test]
18964    fn dep_list_from_into_owned_string_routes_through_as_str_accessor() {
18965        // Fail-before-pass-after byte-parity pin on the newly lifted
18966        // `impl From<DepList> for String` — asserts the owned-`String`
18967        // -returning standard-library trait impl and the substrate-
18968        // primitive [`super::DepList::as_str`] `pub const fn` accessor
18969        // resolve to the same two-arm emit-set across every arm the
18970        // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
18971        // standard library does not carry a blanket
18972        // `impl<T: AsRef<str>> From<T> for String` (nor an
18973        // `impl<T: fmt::Display> From<T> for String`), so the
18974        // owned-`String` forward-projection axis is a distinct trait-
18975        // idiomatic surface that a `let key: String = list.into();`-
18976        // shaped call site reaches through this impl and no other — the
18977        // paired sibling `From<DepList> for &'static str` impl forces
18978        // every owned-`String` call site through an explicit
18979        // `.to_owned()` / `String::from` restatement. Peer of the
18980        // first-mover
18981        // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
18982        // (7baa18a), the second-peer
18983        // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
18984        // (7851725), the third-peer
18985        // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
18986        // (231a18c), and the fourth-peer
18987        // [`crate::dialeto::tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
18988        // (88942cd) — extends the trait-idiomatic owned-`String`
18989        // forward-projection axis onto the fifth closed-set fieldless
18990        // typed enum on the caixa surface (the two-list dep-graph axis).
18991        for &variant in super::DepList::ALL {
18992            let via_trait: String = <String as From<super::DepList>>::from(variant);
18993            let via_method: &'static str = variant.as_str();
18994            assert_eq!(
18995                via_trait.as_str(),
18996                via_method,
18997                "From<DepList> for String impl must round-trip \
18998                 DepList::{variant:?} to the same lifted \
18999                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19000                 DepList::as_str returns — divergence signals a silent \
19001                 detour off the substrate-primitive accessor"
19002            );
19003            let via_into: String = variant.into();
19004            assert_eq!(
19005                via_into.as_str(),
19006                via_method,
19007                "Into<String>::into on DepList::{variant:?} must \
19008                 byte-equal DepList::as_str on the same input — the \
19009                 blanket-derived Into shape must resolve to the same \
19010                 as_str dispatch as the explicit From impl"
19011            );
19012        }
19013    }
19014
19015    #[test]
19016    fn dep_list_from_into_owned_string_and_static_str_agree_on_every_arm() {
19017        // Cross-axis partition pin: the paired trait-idiomatic
19018        // owned-`String` `From<DepList> for String` (this lift) and
19019        // owned-`&'static str` `From<DepList> for &'static str`
19020        // (523157d campaign-shape) forward projections must resolve
19021        // identically on every arm, locking the two return-type-shape
19022        // paths together so any future detour trips at caixa-core test
19023        // time. Also byte-parity witness against the sibling
19024        // [`ToString::to_string`] surface routed through
19025        // [`std::fmt::Display`] — the three owned-heap-string paths
19026        // (`.into::<String>()`, `String::from`, `.to_string()`) must
19027        // resolve identically on every arm so a future consumer that
19028        // picks any of the three lands on the same two-arm lifted
19029        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19030        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] accept-set.
19031        // Then a `.iter().copied().map(String::from)` pipe witness
19032        // over [`super::DepList::ALL`] that materializes the two-arm
19033        // accept-set through the owned-`String` axis alone — the exact
19034        // shape a future M4 admission-webhook rejection body composer
19035        // or a
19036        // `HashMap::<String, DepList>::from_iter(
19037        //     DepList::ALL.iter().copied().map(|l| (l.into(), l)))`-
19038        // style owned-key per-list lookup reaches through — closing the
19039        // owned-`String` forward-projection axis's iterator-pipe shape.
19040        // Then a direct round-trip witness through the paired
19041        // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
19042        // owned-`String`'s [`String::as_str`] borrow that closes the
19043        // two-way `Self → String → Self` round-trip on the trait-
19044        // idiomatic owned-`String` forward + reverse axis pair.
19045        //
19046        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
19047        // `From` emit lands on the lowercase Portuguese `as_str`
19048        // diagnostic vocabulary while the reverse `TryFrom<&str>`
19049        // parses the `PascalCase` `wire_name` author-surface vocabulary,
19050        // forcing the round-trip through an intermediate
19051        // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
19052        // [`super::DepList::as_str`] emit and [`super::DepList::from_wire`]
19053        // parse resolve through the same lifted
19054        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19055        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
19056        // construction (there is no wire/diagnostic axis split on this
19057        // enum), so the owned-`String` forward axis and the reverse
19058        // axis compose directly — matching the peer
19059        // [`crate::supervisor::RestartStrategy`] /
19060        // [`crate::supervisor::RestartPolicy`] /
19061        // [`crate::CaixaDialeto`] owned-`String` axis pairs.
19062        for &list in super::DepList::ALL {
19063            let owned_string: String = <String as From<super::DepList>>::from(list);
19064            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
19065            assert_eq!(
19066                owned_string.as_str(),
19067                owned_static,
19068                "From<DepList> for String and From<DepList> for \
19069                 &'static str must resolve identically on \
19070                 DepList::{list:?} — divergence signals the owned-\
19071                 `String` and owned-`&'static str` forward-projection \
19072                 return-type-shape paths have drifted onto different \
19073                 emit-sets"
19074            );
19075            let via_to_string: String = list.to_string();
19076            assert_eq!(
19077                owned_string, via_to_string,
19078                "From<DepList> for String must byte-equal \
19079                 DepList::to_string on DepList::{list:?} — divergence \
19080                 signals the trait-idiomatic owned-`String` forward-\
19081                 projection axis and the ToString-through-Display axis \
19082                 have drifted onto different emit-sets"
19083            );
19084        }
19085        let via_iter: Vec<String> = super::DepList::ALL
19086            .iter()
19087            .copied()
19088            .map(String::from)
19089            .collect();
19090        let via_method: Vec<String> = super::DepList::ALL
19091            .iter()
19092            .map(|l| l.as_str().to_owned())
19093            .collect();
19094        assert_eq!(
19095            via_iter, via_method,
19096            "`.iter().copied().map(String::from)` over DepList::ALL must \
19097             byte-equal `.iter().map(|l| l.as_str().to_owned())` on \
19098             every arm — the owned-`String` `From<DepList> for String` \
19099             axis is what makes the `String::from` composition route \
19100             through the substrate-primitive `DepList::as_str` accessor \
19101             rather than through a per-call-site `.to_owned()` / \
19102             `String::from(list.as_str())` detour"
19103        );
19104        for &variant in super::DepList::ALL {
19105            let emitted: String = variant.into();
19106            let re_parsed: Result<super::DepList, ()> =
19107                <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
19108            assert_eq!(
19109                re_parsed,
19110                Ok(variant),
19111                "trait-idiomatic owned-`String` forward-projection + \
19112                 reverse-projection axis pair must round-trip \
19113                 DepList::{variant:?} through `.into::<String>()` and \
19114                 back through `TryFrom<&str>` on the owned-`String`'s \
19115                 String::as_str borrow — a break signals the owned-\
19116                 `String` forward-emit and reverse-parse axes have \
19117                 drifted onto different vocabularies (unlike the peer \
19118                 CaixaKind axis pair, DepList's forward emit and \
19119                 reverse parse share the same lifted \
19120                 DEP_AUTHOR_KEY_DEPS* consts by construction, so the \
19121                 round-trip composes directly)"
19122            );
19123        }
19124    }
19125
19126    #[test]
19127    fn dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
19128        // Fail-before-pass-after byte-parity pin on the newly lifted
19129        // `impl From<&DepList> for String` — asserts the borrowed-input
19130        // owned-`String`-returning standard-library trait impl and the
19131        // substrate-primitive [`super::DepList::as_str`] `pub const fn`
19132        // accessor resolve to the same two-arm emit-set across every
19133        // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
19134        // Rust's standard library does not carry a blanket
19135        // `impl<T: AsRef<str>> From<&T> for String` (nor an
19136        // `impl<T: fmt::Display> From<&T> for String`), so the
19137        // borrowed-input owned-`String` forward-projection axis is a
19138        // distinct trait-idiomatic surface that a
19139        // `let key: String = (&list).into();`-shaped call site reaches
19140        // through this impl and no other — the paired sibling
19141        // `From<DepList> for String` impl forces every borrowed-input
19142        // call site through an explicit `Copy` deref
19143        // (`String::from(*list)`) or an `.as_str().to_owned()` /
19144        // `.to_string()` detour. Peer of the first-mover
19145        // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
19146        // (579385f) and the second-peer
19147        // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
19148        // (8465740) — extends the trait-idiomatic borrowed-input owned-
19149        // `String` forward-projection axis off the M2 OTP-shape sibling
19150        // axis pair onto the first non-M2 closed-set fieldless typed
19151        // enum peer (the two-list dep-graph axis).
19152        for &variant in super::DepList::ALL {
19153            let via_trait: String = <String as From<&super::DepList>>::from(&variant);
19154            let via_method: &'static str = variant.as_str();
19155            assert_eq!(
19156                via_trait.as_str(),
19157                via_method,
19158                "From<&DepList> for String impl must round-trip \
19159                 &DepList::{variant:?} to the same lifted \
19160                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19161                 DepList::as_str returns — divergence signals a silent \
19162                 detour off the substrate-primitive accessor"
19163            );
19164            let via_into: String = (&variant).into();
19165            assert_eq!(
19166                via_into.as_str(),
19167                via_method,
19168                "Into<String>::into on &DepList::{variant:?} must \
19169                 byte-equal DepList::as_str on the same input — the \
19170                 blanket-derived Into shape must resolve to the same \
19171                 as_str dispatch as the explicit From impl"
19172            );
19173        }
19174    }
19175
19176    #[test]
19177    fn dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
19178        // Cross-axis partition pin: the newly lifted trait-idiomatic
19179        // borrowed-input owned-`String` `From<&DepList> for String`
19180        // (this lift), the paired owned-input owned-`String`
19181        // `From<DepList> for String` (32b0ee8), the paired borrowed-
19182        // input owned-`&'static str` `From<&DepList> for &'static str`
19183        // (64aa742), and the paired owned-input owned-`&'static str`
19184        // `From<DepList> for &'static str` (3455cbf) — every corner of
19185        // the `{Self, &Self} × {&'static str, String}` 2×2 trait-
19186        // idiomatic projection family — must resolve identically on
19187        // every arm, locking the four return-shape × input-shape paths
19188        // together so any future detour trips at caixa-core test time.
19189        // Also byte-parity witness against the sibling
19190        // [`ToString::to_string`] surface routed through
19191        // [`std::fmt::Display`] and a direct round-trip witness through
19192        // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
19193        // the owned-`String`'s [`String::as_str`] borrow that closes
19194        // the two-way `&Self → String → Self` round-trip on the trait-
19195        // idiomatic borrowed-input owned-`String` forward + reverse
19196        // axis pair. Peer of the first-mover
19197        // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
19198        // (579385f) and the second-peer
19199        // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
19200        // (8465740) — closes the whole `{Self, &Self} × {&'static str,
19201        // String}` 2×2 projection corner on the third substrate-wide
19202        // closed-set fieldless typed enum peer (the two-list dep-graph
19203        // axis, first outside the M2 OTP-shape sibling pair).
19204        //
19205        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
19206        // `From` emit lands on the lowercase Portuguese `as_str`
19207        // diagnostic vocabulary while the reverse `TryFrom<&str>`
19208        // parses the `PascalCase` `wire_name` author-surface vocabulary,
19209        // forcing the round-trip through an intermediate
19210        // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
19211        // [`super::DepList::as_str`] emit and
19212        // [`super::DepList::from_wire`] parse resolve through the same
19213        // lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19214        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
19215        // construction (there is no wire/diagnostic axis split on this
19216        // enum), so the borrowed-input owned-`String` forward axis and
19217        // the reverse axis compose directly — matching the peer
19218        // [`crate::supervisor::RestartStrategy`] /
19219        // [`crate::supervisor::RestartPolicy`] borrowed-input owned-
19220        // `String` axis pairs.
19221        for &list in super::DepList::ALL {
19222            let borrowed_string: String = <String as From<&super::DepList>>::from(&list);
19223            let owned_string: String = <String as From<super::DepList>>::from(list);
19224            let borrowed_static: &'static str =
19225                <&'static str as From<&super::DepList>>::from(&list);
19226            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
19227            assert_eq!(
19228                borrowed_string, owned_string,
19229                "From<&DepList> for String and From<DepList> for String \
19230                 must resolve identically on DepList::{list:?} — \
19231                 divergence signals the borrowed-input and owned-input \
19232                 owned-`String` forward-projection input-shape paths \
19233                 have drifted onto different emit-sets"
19234            );
19235            assert_eq!(
19236                borrowed_string.as_str(),
19237                borrowed_static,
19238                "From<&DepList> for String and From<&DepList> for \
19239                 &'static str must resolve identically on \
19240                 DepList::{list:?} — divergence signals the borrowed-\
19241                 input `&'static str` and owned-`String` return-shape \
19242                 paths have drifted onto different emit-sets"
19243            );
19244            assert_eq!(
19245                borrowed_string.as_str(),
19246                owned_static,
19247                "From<&DepList> for String and From<DepList> for \
19248                 &'static str must resolve identically on \
19249                 DepList::{list:?} — divergence signals a break in the \
19250                 diagonal corner of the {{Self, &Self}} × {{&'static \
19251                 str, String}} 2×2 trait-idiomatic projection family"
19252            );
19253            let via_to_string: String = list.to_string();
19254            assert_eq!(
19255                borrowed_string, via_to_string,
19256                "From<&DepList> for String must byte-equal \
19257                 DepList::to_string on DepList::{list:?} — divergence \
19258                 signals the trait-idiomatic borrowed-input owned-\
19259                 `String` forward-projection axis and the ToString-\
19260                 through-Display axis have drifted onto different \
19261                 emit-sets"
19262            );
19263        }
19264        let via_iter: Vec<String> = super::DepList::ALL.iter().map(String::from).collect();
19265        let via_method: Vec<String> = super::DepList::ALL
19266            .iter()
19267            .map(|l| l.as_str().to_owned())
19268            .collect();
19269        assert_eq!(
19270            via_iter, via_method,
19271            "`.iter().map(String::from)` over DepList::ALL — a call \
19272             site whose iteration axis holds `&DepList` by construction \
19273             — must byte-equal `.iter().map(|l| l.as_str().to_owned())` \
19274             on every arm — the borrowed-input owned-`String` \
19275             `From<&DepList> for String` axis is what makes the \
19276             `String::from` composition route through the substrate-\
19277             primitive `DepList::as_str` accessor without a spurious \
19278             `Copy` deref (which would only be reachable through the \
19279             owned-input `From<DepList> for String` axis by first \
19280             calling `.copied()` on the iterator)"
19281        );
19282        for &variant in super::DepList::ALL {
19283            let emitted: String = (&variant).into();
19284            let re_parsed: Result<super::DepList, ()> =
19285                <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
19286            assert_eq!(
19287                re_parsed,
19288                Ok(variant),
19289                "trait-idiomatic borrowed-input owned-`String` \
19290                 forward-projection + reverse-projection axis pair must \
19291                 round-trip &DepList::{variant:?} through \
19292                 `.into::<String>()` on the borrowed-input surface and \
19293                 back through `TryFrom<&str>` on the owned-`String`'s \
19294                 String::as_str borrow — a break signals the \
19295                 borrowed-input owned-`String` forward-emit and \
19296                 reverse-parse axes have drifted onto different \
19297                 vocabularies (unlike the peer CaixaKind axis pair, \
19298                 DepList's forward emit and reverse parse share the \
19299                 same lifted DEP_AUTHOR_KEY_DEPS* consts by \
19300                 construction, so the round-trip composes directly)"
19301            );
19302        }
19303    }
19304
19305    #[test]
19306    fn dep_list_from_into_static_cow_str_routes_through_as_str_accessor() {
19307        // Fail-before-pass-after byte-parity pin on the newly lifted
19308        // `impl From<DepList> for std::borrow::Cow<'static, str>` —
19309        // asserts the standard-library trait impl and the substrate-
19310        // primitive [`super::DepList::as_str`] `pub const fn`
19311        // accessor resolve to the same two-arm emit-set across every
19312        // arm the exhaustive [`super::DepList::ALL`] slice
19313        // enumerates. Rust's standard library does not carry a
19314        // blanket `impl<T: AsRef<str>> From<T> for Cow<'static, str>`
19315        // (nor an `impl<T: fmt::Display> From<T> for
19316        // Cow<'static, str>`), so the `Cow<'static, str>` forward-
19317        // projection axis is a distinct trait-idiomatic surface that
19318        // a `let key: Cow<'static, str> = list.into();`-shaped call
19319        // site reaches through this impl and no other — the paired
19320        // sibling `From<DepList> for &'static str` and
19321        // `From<DepList> for String` impls force every
19322        // `Cow<'static, str>`-parameterized call site through a
19323        // `Cow::Borrowed(list.as_str())` /
19324        // `Cow::Owned(list.to_string())` composition whose type
19325        // bounds have no compile-time link back to the substrate
19326        // primitive.
19327        //
19328        // Also asserts the projection lands on the zero-alloc
19329        // [`std::borrow::Cow::Borrowed`] arm (not the
19330        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19331        // [`super::DepList::as_str`] accessor's `&'static str`
19332        // return lifetime by construction (each match arm resolves
19333        // to one of the two lifted
19334        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19335        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const
19336        // &str` values) makes the borrowed arm the type-correct
19337        // projection with no runtime allocation. Any future silent
19338        // detour that routes the impl through the owned arm trips
19339        // at caixa-core test time under the
19340        // [`std::borrow::Cow::Borrowed`] discriminator witness
19341        // rather than at a downstream `Cow<'static, str>`-bound
19342        // consumer's silent allocation.
19343        //
19344        // First-mover on the outside-M3 substrate-wide tier of the
19345        // substrate-wide trait-idiomatic
19346        // [`std::borrow::Cow<'static, str>`] forward-projection
19347        // campaign — extends the axis off the paired
19348        // [`crate::CaixaKind`] top-level opener (99c1735 + d45c409),
19349        // the paired M2 OTP-shape
19350        // [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3)
19351        // and [`crate::supervisor::RestartPolicy`] (0612398 +
19352        // ee577fd), and the paired M3-mesh-shape
19353        // [`crate::aplicacao::WitShape`] (8634dec + 25690ef),
19354        // [`crate::aplicacao::PlacementStrategy`] (eee504d +
19355        // afdf0f4), and [`crate::aplicacao::RateLimitUnit`] (1d59925)
19356        // peers onto the first outside-M3 caixa-core peer (the two-
19357        // list dep-graph axis), opening the outside-M3 caixa-core
19358        // tier of the substrate-wide Cow<'static, str> forward-
19359        // projection campaign's owned-input corner.
19360        for &variant in super::DepList::ALL {
19361            let via_trait: std::borrow::Cow<'static, str> =
19362                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19363            let via_method: &'static str = variant.as_str();
19364            assert_eq!(
19365                via_trait.as_ref(),
19366                via_method,
19367                "From<DepList> for Cow<'static, str> impl must \
19368                 round-trip DepList::{variant:?} to the same lifted \
19369                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19370                 DepList::as_str returns — divergence signals a \
19371                 silent detour off the substrate-primitive accessor"
19372            );
19373            assert!(
19374                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19375                "From<DepList> for Cow<'static, str> impl must land \
19376                 on the zero-alloc Cow::Borrowed arm on \
19377                 DepList::{variant:?} — a Cow::Owned outcome signals \
19378                 the projection has silently allocated where the \
19379                 substrate-primitive DepList::as_str `&'static str` \
19380                 return makes the borrowed arm the type-correct \
19381                 projection"
19382            );
19383            let via_into: std::borrow::Cow<'static, str> = variant.into();
19384            assert_eq!(
19385                via_into.as_ref(),
19386                via_method,
19387                "Into<Cow<'static, str>>::into on DepList::\
19388                 {variant:?} must byte-equal DepList::as_str on the \
19389                 same input — the blanket-derived Into shape must \
19390                 resolve to the same as_str dispatch as the explicit \
19391                 From impl"
19392            );
19393            assert!(
19394                matches!(via_into, std::borrow::Cow::Borrowed(_)),
19395                "Into<Cow<'static, str>>::into on DepList::\
19396                 {variant:?} must land on the zero-alloc \
19397                 Cow::Borrowed arm — the blanket-derived Into shape \
19398                 must resolve to the same Cow::Borrowed dispatch as \
19399                 the explicit From impl"
19400            );
19401        }
19402    }
19403
19404    #[test]
19405    fn dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19406        // Cross-axis partition pin: the newly lifted trait-idiomatic
19407        // `From<DepList> for std::borrow::Cow<'static, str>` (this
19408        // lift), the paired owned-input `From<DepList> for
19409        // &'static str` (3455cbf), and the paired owned-input
19410        // `From<DepList> for String` (32b0ee8) forward projections
19411        // must resolve identically on every arm, locking the three
19412        // return-shape paths together by construction so any future
19413        // detour trips at caixa-core test time. Also byte-parity
19414        // witness against the sibling [`ToString::to_string`]
19415        // surface routed through [`std::fmt::Display`] — every
19416        // owned-heap-string path (the `Cow::Owned` promotion of
19417        // this axis's `.into_owned()`, `From<DepList> for String`,
19418        // and `.to_string()`) resolves to the same two-arm lifted
19419        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19420        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19421        // arm.
19422        //
19423        // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
19424        // witness over [`super::DepList::ALL`] that materializes the
19425        // two-arm accept-set through the
19426        // [`std::borrow::Cow<'static, str>`] axis alone — the exact
19427        // shape a future M4 admission-webhook rejection body's
19428        // accepted-`:deps` / `:deps-dev` list-key enumeration, a
19429        // future substrate-wide per-arm diagnostic surface whose
19430        // typing rules out the sibling [`AsRef<str>`] borrowed
19431        // return, or a future per-arm dep-list emitter that binds
19432        // through a [`std::borrow::Cow<'static, str>`] boundary
19433        // reaches through — opening the composable-projection axis
19434        // on the first outside-M3 caixa-core closed-set fieldless
19435        // typed enum peer on the caixa surface. The pipe witness
19436        // also pins the zero-alloc discipline: every element in the
19437        // collected vector satisfies the
19438        // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
19439        // accidental silent-allocation regression on the pipe's
19440        // iteration axis is a caixa-core-test-time failure.
19441        for &variant in super::DepList::ALL {
19442            let via_cow: std::borrow::Cow<'static, str> =
19443                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19444            let via_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
19445            let via_string: String = <String as From<super::DepList>>::from(variant);
19446            assert_eq!(
19447                via_cow.as_ref(),
19448                via_static,
19449                "From<DepList> for Cow<'static, str> and \
19450                 From<DepList> for &'static str must resolve \
19451                 identically on DepList::{variant:?} — divergence \
19452                 signals the Cow<'static, str> and &'static str \
19453                 return-shape paths have drifted onto different \
19454                 emit-sets"
19455            );
19456            assert_eq!(
19457                via_cow.as_ref(),
19458                via_string.as_str(),
19459                "From<DepList> for Cow<'static, str> and \
19460                 From<DepList> for String must resolve identically \
19461                 on DepList::{variant:?} — divergence signals the \
19462                 Cow<'static, str> and String return-shape paths \
19463                 have drifted onto different emit-sets"
19464            );
19465            let via_to_string: String = variant.to_string();
19466            assert_eq!(
19467                via_cow.as_ref(),
19468                via_to_string.as_str(),
19469                "From<DepList> for Cow<'static, str> must byte-equal \
19470                 DepList::to_string on DepList::{variant:?} — \
19471                 divergence signals the trait-idiomatic \
19472                 Cow<'static, str> forward-projection axis and the \
19473                 ToString-through-Display axis have drifted onto \
19474                 different emit-sets"
19475            );
19476        }
19477        let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19478            .iter()
19479            .copied()
19480            .map(std::borrow::Cow::from)
19481            .collect();
19482        let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19483            .iter()
19484            .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19485            .collect();
19486        assert_eq!(
19487            via_iter, via_method,
19488            "`.iter().copied().map(Cow::from)` over DepList::ALL \
19489             must byte-equal `.iter().map(|l| \
19490             Cow::Borrowed(l.as_str()))` on every arm — the trait-\
19491             idiomatic `From<DepList> for Cow<'static, str>` axis is \
19492             what makes the `Cow::from` composition route through \
19493             the substrate-primitive `DepList::as_str` accessor with \
19494             the zero-alloc Cow::Borrowed arm by construction, \
19495             rather than a per-call-site `Cow::Owned(list.to_string())` \
19496             allocation"
19497        );
19498        for cow in &via_iter {
19499            assert!(
19500                matches!(cow, std::borrow::Cow::Borrowed(_)),
19501                "every element of the .iter().copied().map(Cow::from) \
19502                 pipe over DepList::ALL must land on the zero-alloc \
19503                 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19504                 signals the pipe's iteration axis has silently \
19505                 allocated where the substrate-primitive \
19506                 DepList::as_str `&'static str` return makes the \
19507                 borrowed arm the type-correct projection"
19508            );
19509        }
19510    }
19511
19512    #[test]
19513    fn dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
19514        // Fail-before-pass-after byte-parity pin on the newly lifted
19515        // `impl From<&DepList> for std::borrow::Cow<'static, str>` —
19516        // asserts the borrowed-input standard-library trait impl and
19517        // the substrate-primitive [`super::DepList::as_str`] `pub const
19518        // fn` accessor resolve to the same two-arm emit-set across
19519        // every arm the exhaustive [`super::DepList::ALL`] slice
19520        // enumerates. Rust's standard library does not carry a blanket
19521        // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
19522        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
19523        // the borrowed-input `Cow<'static, str>` forward-projection
19524        // axis is a distinct trait-idiomatic surface that a
19525        // `let key: Cow<'static, str> = (&list).into();`-shaped call
19526        // site or a `DepList::ALL.iter().map(Cow::from)`-shaped pipe
19527        // reaches through this impl and no other — the paired owned-
19528        // input `From<DepList> for Cow<'static, str>` impl (6858bac)
19529        // forces every borrowed-input call site through an explicit
19530        // `Copy` deref (`Cow::from(*list)`) or a
19531        // `Cow::Borrowed(list.as_str())` open-code whose type bounds
19532        // have no compile-time link back to the substrate primitive.
19533        //
19534        // Also asserts the projection lands on the zero-alloc
19535        // [`std::borrow::Cow::Borrowed`] arm (not the
19536        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19537        // [`super::DepList::as_str`] accessor's `&'static str` return
19538        // lifetime by construction (each match arm resolves to one of
19539        // the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19540        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19541        // values) makes the borrowed arm the type-correct projection
19542        // with no runtime allocation on the borrowed-input surface
19543        // just as on the paired owned-input surface.
19544        //
19545        // Closes the `{Self, &Self}` input-shape corner on the outside-
19546        // M3 caixa-core two-list dep-graph [`Cow<'static, str>`] axis
19547        // on the first outside-M3 caixa-core closed-set fieldless typed
19548        // enum peer on the caixa surface, exactly as afdf0f4 closed it
19549        // on the second M3-mesh-primitive peer
19550        // ([`crate::aplicacao::PlacementStrategy`]) one commit after
19551        // the owning half (eee504d) landed, as 25690ef closed it on
19552        // the first M3-mesh-primitive peer
19553        // ([`crate::aplicacao::WitShape`]) one commit after the owning
19554        // half (8634dec) landed, as d45c409 closed it on the top-level
19555        // [`crate::CaixaKind`] one commit after the owning half
19556        // (99c1735) landed, and as 9b3e4b3 / ee577fd closed it on the
19557        // M2 OTP-shape [`crate::supervisor::RestartStrategy`] /
19558        // [`crate::supervisor::RestartPolicy`] sibling peers one
19559        // commit after (7dd28b3 / 0612398) landed.
19560        for &variant in super::DepList::ALL {
19561            let via_trait: std::borrow::Cow<'static, str> =
19562                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19563            let via_method: &'static str = variant.as_str();
19564            assert_eq!(
19565                via_trait.as_ref(),
19566                via_method,
19567                "From<&DepList> for Cow<'static, str> impl must \
19568                 round-trip &DepList::{variant:?} to the same lifted \
19569                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19570                 DepList::as_str returns — divergence signals a silent \
19571                 detour off the substrate-primitive accessor"
19572            );
19573            assert!(
19574                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19575                "From<&DepList> for Cow<'static, str> impl must land \
19576                 on the zero-alloc Cow::Borrowed arm on \
19577                 &DepList::{variant:?} — a Cow::Owned outcome signals \
19578                 the projection has silently allocated where the \
19579                 substrate-primitive DepList::as_str `&'static str` \
19580                 return makes the borrowed arm the type-correct \
19581                 projection"
19582            );
19583            let via_into: std::borrow::Cow<'static, str> = (&variant).into();
19584            assert_eq!(
19585                via_into.as_ref(),
19586                via_method,
19587                "Into<Cow<'static, str>>::into on &DepList::\
19588                 {variant:?} must byte-equal DepList::as_str on the \
19589                 same input — the blanket-derived Into shape must \
19590                 resolve to the same as_str dispatch as the explicit \
19591                 From impl"
19592            );
19593            assert!(
19594                matches!(via_into, std::borrow::Cow::Borrowed(_)),
19595                "Into<Cow<'static, str>>::into on &DepList::\
19596                 {variant:?} must land on the zero-alloc \
19597                 Cow::Borrowed arm — the blanket-derived Into shape \
19598                 must resolve to the same Cow::Borrowed dispatch as \
19599                 the explicit From impl"
19600            );
19601        }
19602    }
19603
19604    #[test]
19605    fn dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19606        // Cross-axis partition pin: the newly lifted trait-idiomatic
19607        // borrowed-input `From<&DepList> for std::borrow::Cow<'static,
19608        // str>` (this lift), the paired owned-input `From<DepList> for
19609        // std::borrow::Cow<'static, str>` (6858bac), the paired
19610        // borrowed-input owned-`&'static str` `From<&DepList> for
19611        // &'static str` (3455cbf), and the paired borrowed-input
19612        // owned-`String` `From<&DepList> for String` must resolve
19613        // identically on every arm, locking the four return-shape ×
19614        // input-shape paths together by construction so any future
19615        // detour trips at caixa-core test time. Also byte-parity
19616        // witness against the sibling [`ToString::to_string`] surface
19617        // routed through [`std::fmt::Display`] — every owned-heap-
19618        // string path (this axis's `.into_owned()` promotion, the
19619        // paired [`From<&DepList> for String`], and `.to_string()`)
19620        // resolves to the same two-arm lifted
19621        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19622        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19623        // arm.
19624        //
19625        // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
19626        // over [`super::DepList::ALL`] — whose iterator yields
19627        // `&DepList` by construction, so the borrowed-input
19628        // [`Cow<'static, str>`] axis is what routes the pipe through
19629        // the substrate-primitive [`super::DepList::as_str`] accessor
19630        // without a spurious [`Copy`] deref (which would only be
19631        // reachable through the owned-input [`From<DepList> for
19632        // Cow<'static, str>`] axis by first calling `.copied()` on the
19633        // iterator). The pipe witness also pins the zero-alloc
19634        // discipline: every element in the collected vector satisfies
19635        // the [`std::borrow::Cow::Borrowed`] arm predicate, so a
19636        // future accidental silent-allocation regression on the pipe's
19637        // iteration axis is a caixa-core-test-time failure. Peer of
19638        // the sibling
19639        // [`placement_strategy_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
19640        // (afdf0f4) on the M3 mesh-shape `:placement :estrategia`
19641        // axis — extends the whole borrowed-input `Cow<'static, str>`
19642        // + paired `{&'static str, String}` cross-axis-parity corner
19643        // onto the first outside-M3 caixa-core closed-set fieldless
19644        // typed enum peer on the caixa surface.
19645        for &variant in super::DepList::ALL {
19646            let borrowed_cow: std::borrow::Cow<'static, str> =
19647                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19648            let owned_cow: std::borrow::Cow<'static, str> =
19649                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19650            let borrowed_static: &'static str =
19651                <&'static str as From<&super::DepList>>::from(&variant);
19652            let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
19653            assert_eq!(
19654                borrowed_cow, owned_cow,
19655                "From<&DepList> for Cow<'static, str> and \
19656                 From<DepList> for Cow<'static, str> must resolve \
19657                 identically on DepList::{variant:?} — divergence \
19658                 signals the borrowed-input and owned-input \
19659                 Cow<'static, str> forward-projection input-shape \
19660                 paths have drifted onto different emit-sets"
19661            );
19662            assert_eq!(
19663                borrowed_cow.as_ref(),
19664                borrowed_static,
19665                "From<&DepList> for Cow<'static, str> and \
19666                 From<&DepList> for &'static str must resolve \
19667                 identically on DepList::{variant:?} — divergence \
19668                 signals the borrowed-input Cow<'static, str> and \
19669                 &'static str return-shape paths have drifted onto \
19670                 different emit-sets"
19671            );
19672            assert_eq!(
19673                borrowed_cow.as_ref(),
19674                borrowed_string.as_str(),
19675                "From<&DepList> for Cow<'static, str> and \
19676                 From<&DepList> for String must resolve identically \
19677                 on DepList::{variant:?} — divergence signals the \
19678                 borrowed-input Cow<'static, str> and owned-`String` \
19679                 return-shape paths have drifted onto different \
19680                 emit-sets"
19681            );
19682            let via_to_string: String = variant.to_string();
19683            assert_eq!(
19684                borrowed_cow.as_ref(),
19685                via_to_string.as_str(),
19686                "From<&DepList> for Cow<'static, str> must byte-equal \
19687                 DepList::to_string on DepList::{variant:?} — \
19688                 divergence signals the trait-idiomatic borrowed-input \
19689                 Cow<'static, str> forward-projection axis and the \
19690                 ToString-through-Display axis have drifted onto \
19691                 different emit-sets"
19692            );
19693        }
19694        let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19695            .iter()
19696            .map(std::borrow::Cow::from)
19697            .collect();
19698        let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19699            .iter()
19700            .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19701            .collect();
19702        assert_eq!(
19703            via_iter, via_method,
19704            "`.iter().map(Cow::from)` over DepList::ALL — a call site \
19705             whose iteration axis holds &DepList by construction — \
19706             must byte-equal `.iter().map(|l| \
19707             Cow::Borrowed(l.as_str()))` on every arm — the borrowed-\
19708             input Cow<'static, str> `From<&DepList> for Cow<'static, \
19709             str>` axis is what makes the `Cow::from` composition \
19710             route through the substrate-primitive `DepList::as_str` \
19711             accessor with the zero-alloc Cow::Borrowed arm by \
19712             construction and without a spurious `Copy` deref (which \
19713             would only be reachable through the owned-input \
19714             `From<DepList> for Cow<'static, str>` axis by first \
19715             calling `.copied()` on the iterator)"
19716        );
19717        for cow in &via_iter {
19718            assert!(
19719                matches!(cow, std::borrow::Cow::Borrowed(_)),
19720                "every element of the .iter().map(Cow::from) pipe \
19721                 over DepList::ALL must land on the zero-alloc \
19722                 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19723                 signals the pipe's iteration axis has silently \
19724                 allocated where the substrate-primitive \
19725                 DepList::as_str `&'static str` return makes the \
19726                 borrowed arm the type-correct projection"
19727            );
19728        }
19729    }
19730
19731    #[test]
19732    fn dep_list_from_into_box_str_routes_through_as_str_accessor() {
19733        // Fail-before-pass-after byte-parity pin on the newly lifted
19734        // `impl From<DepList> for Box<str>` — asserts the owned-input
19735        // standard-library trait impl and the substrate-primitive
19736        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19737        // the same two-arm emit-set (the paired
19738        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19739        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19740        // byte-strings) across every arm the exhaustive
19741        // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
19742        // core-internal tier of the substrate-wide [`Box<str>`] forward-
19743        // projection campaign onto the second caixa-core-internal peer,
19744        // after the render-side path-shape-diagnostic
19745        // [`super::super::render::PathShapeViolation`] pair (0d87a72,
19746        // both corners in one axis) opened the tier. Rust's standard
19747        // library carries `impl From<&str> for Box<str>` and
19748        // `impl From<String> for Box<str>` but no blanket
19749        // `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a
19750        // distinct trait-idiomatic surface that a
19751        // `let key: Box<str> = list.into();`-shaped call site reaches
19752        // through this impl and no other — a paired
19753        // `Box::from(list.as_str())` open-code has no compile-time link
19754        // back to the substrate primitive.
19755        for &variant in super::DepList::ALL {
19756            let via_trait: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
19757            let via_method: &'static str = variant.as_str();
19758            assert_eq!(
19759                via_trait.as_ref(),
19760                via_method,
19761                "From<DepList> for Box<str> impl must round-trip \
19762                 DepList::{variant:?} to the same lifted \
19763                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19764                 DepList::as_str returns — divergence signals a silent \
19765                 detour off the substrate-primitive accessor"
19766            );
19767            let via_into: Box<str> = variant.into();
19768            assert_eq!(
19769                via_into.as_ref(),
19770                via_method,
19771                "Into<Box<str>>::into on DepList::{variant:?} must \
19772                 byte-equal DepList::as_str on the same input — the \
19773                 blanket-derived Into shape must resolve to the same \
19774                 as_str dispatch as the explicit From impl"
19775            );
19776        }
19777    }
19778
19779    #[test]
19780    fn dep_list_from_borrowed_into_box_str_routes_through_as_str_accessor() {
19781        // Fail-before-pass-after byte-parity pin on the newly lifted
19782        // `impl From<&DepList> for Box<str>` — asserts the borrowed-input
19783        // standard-library trait impl and the substrate-primitive
19784        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19785        // the same two-arm emit-set (the paired
19786        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19787        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19788        // byte-strings) across every arm the exhaustive
19789        // [`super::DepList::ALL`] slice enumerates. Rust's standard
19790        // library carries `impl From<&str> for Box<str>` and
19791        // `impl From<String> for Box<str>` but no blanket
19792        // `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
19793        // `impl<T: Copy, U: From<T>> From<&T> for U`), so the borrowed-
19794        // input [`Box<str>`] forward-projection axis is a distinct
19795        // trait-idiomatic surface that a
19796        // `DepList::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
19797        // iterator over `&'static [DepList]` yields `&DepList` by
19798        // construction) or a `let key: Box<str> = (&list).into();`-shaped
19799        // call site reaches through this impl and no other — the paired
19800        // owned-input `From<DepList> for Box<str>` impl alone would force
19801        // every borrowed-input call site through an explicit `Copy` deref
19802        // (`Box::<str>::from(*list)`) or a
19803        // `Box::<str>::from(list.as_str())` open-code whose type bounds
19804        // have no compile-time link back to the substrate primitive.
19805        //
19806        // Closes the `{Self, &Self}` input-shape corner on the second
19807        // caixa-core-internal closed-set fieldless typed enum peer of
19808        // the substrate-wide [`Box<str>`] forward-projection campaign —
19809        // one commit after the paired render-side path-shape-diagnostic
19810        // [`super::super::render::PathShapeViolation`] pair (0d87a72)
19811        // opened the caixa-core-internal tier — matching the trajectory
19812        // the paired caixa-theme `Semantic` pair (0cd7dc3, both corners
19813        // in one axis), the caixa-provedor `FerriteRuntime` pair
19814        // (14886a8, both corners in one axis), and the render-side
19815        // `PathShapeViolation` pair (0d87a72, both corners in one axis)
19816        // walked before it.
19817        for &variant in super::DepList::ALL {
19818            let via_trait: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
19819            let via_method: &'static str = variant.as_str();
19820            assert_eq!(
19821                via_trait.as_ref(),
19822                via_method,
19823                "From<&DepList> for Box<str> impl must round-trip \
19824                 &DepList::{variant:?} to the same lifted \
19825                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19826                 DepList::as_str returns — divergence signals a silent \
19827                 detour off the substrate-primitive accessor"
19828            );
19829            let via_into: Box<str> = (&variant).into();
19830            assert_eq!(
19831                via_into.as_ref(),
19832                via_method,
19833                "Into<Box<str>>::into on &DepList::{variant:?} must \
19834                 byte-equal DepList::as_str on the same input — the \
19835                 blanket-derived Into shape on the borrowed-input \
19836                 surface must resolve to the same as_str dispatch as \
19837                 the explicit From impl"
19838            );
19839        }
19840
19841        // Pipe witness — the distinguishing shape that forces the
19842        // borrowed-input axis to be independent of the owned-input
19843        // peer. `DepList::ALL.iter()` yields `&DepList` by
19844        // construction, so `.map(Box::<str>::from)` resolves through
19845        // the borrowed-input `From<&DepList> for Box<str>` impl and
19846        // no other — without this axis, the same pipe would force an
19847        // explicit `.copied()` restatement whose type bounds bypass
19848        // the substrate primitive.
19849        let via_pipe: Vec<Box<str>> = super::DepList::ALL.iter().map(Box::<str>::from).collect();
19850        let via_accessor: Vec<&'static str> =
19851            super::DepList::ALL.iter().map(|l| l.as_str()).collect();
19852        assert_eq!(
19853            via_pipe.len(),
19854            via_accessor.len(),
19855            "DepList::ALL.iter().map(Box::<str>::from) pipe must \
19856             preserve arity against the paired DepList::as_str \
19857             accessor — a length divergence signals the borrowed-input \
19858             axis has silently rejected an arm"
19859        );
19860        for (pipe_arm, accessor_arm) in via_pipe.iter().zip(via_accessor.iter()) {
19861            assert_eq!(
19862                pipe_arm.as_ref(),
19863                *accessor_arm,
19864                "DepList::ALL.iter().map(Box::<str>::from) pipe must \
19865                 byte-equal the paired \
19866                 DepList::ALL.iter().map(|l| l.as_str()) pipe on every \
19867                 arm — divergence signals the borrowed-input \
19868                 `From<&DepList> for Box<str>` axis has silently \
19869                 detoured off the substrate-primitive accessor"
19870            );
19871        }
19872    }
19873
19874    #[test]
19875    fn dep_list_from_into_arc_str_routes_through_as_str_accessor() {
19876        // Fail-before-pass-after byte-parity pin on the newly lifted
19877        // `impl From<DepList> for std::sync::Arc<str>` — asserts the
19878        // owned-input standard-library trait impl and the substrate-
19879        // primitive [`super::DepList::as_str`] `pub const fn` accessor
19880        // resolve to the same two-arm emit-set (the paired
19881        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19882        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19883        // byte-strings) across every arm the exhaustive
19884        // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
19885        // core-internal tier of the substrate-wide
19886        // [`std::sync::Arc<str>`] forward-projection campaign onto the
19887        // second caixa-core-internal peer, after the top-level
19888        // [`crate::CaixaKind`] pair (c17be64, both corners in one axis)
19889        // opened the tier. Rust's standard library carries
19890        // `impl From<&str> for std::sync::Arc<str>` and
19891        // `impl From<String> for std::sync::Arc<str>` but no blanket
19892        // `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
19893        // `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so
19894        // this axis is a distinct trait-idiomatic surface that a
19895        // `let key: std::sync::Arc<str> = list.into();`-shaped call site
19896        // reaches through this impl and no other — a paired
19897        // `std::sync::Arc::<str>::from(list.as_str())` open-code has no
19898        // compile-time link back to the substrate primitive, and a two-
19899        // step `std::sync::Arc::<str>::from(String::from(list))`
19900        // composition through the owned-`String` axis allocates twice
19901        // (once into the intermediate `String`, once into the
19902        // [`std::sync::Arc<str>`] on the `From<String>` conversion)
19903        // where the single-step trait impl allocates once.
19904        //
19905        // Cross-axis byte-parity witness against the sibling owned-input
19906        // `{&'static str, String, Cow<'static, str>, Box<str>}` return-
19907        // shape axes — locking the five return-shape paths on the owned-
19908        // input surface together by construction so any future detour
19909        // off the substrate-primitive [`super::DepList::as_str`] accessor
19910        // trips at caixa-core test time.
19911        for &variant in super::DepList::ALL {
19912            let via_trait: std::sync::Arc<str> =
19913                <std::sync::Arc<str> as From<super::DepList>>::from(variant);
19914            let via_method: &'static str = variant.as_str();
19915            assert_eq!(
19916                via_trait.as_ref(),
19917                via_method,
19918                "From<DepList> for std::sync::Arc<str> impl must round-\
19919                 trip DepList::{variant:?} to the same lifted \
19920                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19921                 DepList::as_str returns — divergence signals a silent \
19922                 detour off the substrate-primitive accessor"
19923            );
19924            let via_into: std::sync::Arc<str> = variant.into();
19925            assert_eq!(
19926                via_into.as_ref(),
19927                via_method,
19928                "Into<std::sync::Arc<str>>::into on DepList::{variant:?} \
19929                 must byte-equal DepList::as_str on the same input — \
19930                 the blanket-derived Into shape must resolve to the same \
19931                 as_str dispatch as the explicit From impl"
19932            );
19933            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
19934            assert_eq!(
19935                via_trait.as_ref(),
19936                owned_static,
19937                "From<DepList> for std::sync::Arc<str> and \
19938                 From<DepList> for &'static str must resolve identically \
19939                 on DepList::{variant:?} — divergence signals the owned-\
19940                 input std::sync::Arc<str> and &'static str return-shape \
19941                 paths have drifted onto different emit-sets"
19942            );
19943            let owned_string: String = <String as From<super::DepList>>::from(variant);
19944            assert_eq!(
19945                via_trait.as_ref(),
19946                owned_string.as_str(),
19947                "From<DepList> for std::sync::Arc<str> and \
19948                 From<DepList> for String must resolve identically on \
19949                 DepList::{variant:?} — divergence signals the owned-\
19950                 input std::sync::Arc<str> and owned-`String` return-shape \
19951                 paths have drifted onto different emit-sets"
19952            );
19953            let owned_cow: std::borrow::Cow<'static, str> =
19954                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19955            assert_eq!(
19956                via_trait.as_ref(),
19957                owned_cow.as_ref(),
19958                "From<DepList> for std::sync::Arc<str> and \
19959                 From<DepList> for Cow<'static, str> must resolve \
19960                 identically on DepList::{variant:?} — divergence signals \
19961                 the owned-input std::sync::Arc<str> and \
19962                 Cow<'static, str> return-shape paths have drifted onto \
19963                 different emit-sets"
19964            );
19965            let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
19966            assert_eq!(
19967                via_trait.as_ref(),
19968                owned_box.as_ref(),
19969                "From<DepList> for std::sync::Arc<str> and \
19970                 From<DepList> for Box<str> must resolve identically on \
19971                 DepList::{variant:?} — divergence signals the owned-\
19972                 input std::sync::Arc<str> and Box<str> return-shape \
19973                 paths have drifted onto different emit-sets"
19974            );
19975        }
19976    }
19977
19978    #[test]
19979    #[allow(
19980        clippy::too_many_lines,
19981        reason = "cross-axis partition pin folds four borrowed-input \
19982                  return-shape paths (&'static str, String, Cow<'static, \
19983                  str>, Box<str>) plus the paired owned-input Arc<str> \
19984                  witness and the .iter().map(std::sync::Arc::<str>::from) \
19985                  pipe witness into one exhaustive round-trip over \
19986                  DepList::ALL — the accepted line-count cost of keying \
19987                  the whole borrowed-input Arc<str> corner to the \
19988                  substrate-primitive as_str accessor at the same test-site"
19989    )]
19990    fn dep_list_from_borrowed_into_arc_str_routes_through_as_str_accessor() {
19991        // Fail-before-pass-after byte-parity pin on the newly lifted
19992        // `impl From<&DepList> for std::sync::Arc<str>` — asserts the
19993        // borrowed-input standard-library trait impl and the substrate-
19994        // primitive [`super::DepList::as_str`] `pub const fn` accessor
19995        // resolve to the same two-arm emit-set across every arm the
19996        // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
19997        // standard library does not carry a blanket
19998        // `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a
19999        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
20000        // the borrowed-input `std::sync::Arc<str>` forward-projection
20001        // axis is a distinct trait-idiomatic surface that a
20002        // `let key: std::sync::Arc<str> = (&list).into();`-shaped call
20003        // site or a
20004        // `DepList::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped
20005        // pipe reaches through this impl and no other — the paired
20006        // owned-input `From<DepList> for std::sync::Arc<str>` impl alone
20007        // forces every borrowed-input call site through a spurious
20008        // `Copy` deref
20009        // (`std::sync::Arc::<str>::from((*list).as_str())`) or a
20010        // `.copied()` restatement whose type bounds have no compile-time
20011        // link back to the substrate primitive.
20012        //
20013        // Closes the `{Self, &Self}` input-shape corner on the second
20014        // caixa-core-internal closed-set fieldless typed enum peer of
20015        // the substrate-wide trait-idiomatic [`std::sync::Arc<str>`]
20016        // forward-projection campaign — one commit after the paired
20017        // top-level [`crate::CaixaKind`] pair (c17be64) opened the
20018        // caixa-core-internal tier — matching the
20019        // `{Self, &Self} × {&'static str, String, Cow<'static, str>,
20020        // Box<str>}` 2×4 forward-projection matrix the peer projection
20021        // surfaces already close on this same enum.
20022        //
20023        // Cross-axis partition pin against the paired owned-input
20024        // [`From<DepList> for std::sync::Arc<str>`] and the sibling
20025        // borrowed-input `{&'static str, String, Cow<'static, str>,
20026        // Box<str>}` return-shape axes — locking the five return-shape
20027        // × input-shape paths on the borrowed-input surface together by
20028        // construction so any future detour off the substrate-primitive
20029        // accessor trips at caixa-core test time. Then a
20030        // `.iter().map(std::sync::Arc::<str>::from)` pipe witness over
20031        // [`super::DepList::ALL`] — whose iterator yields `&DepList` by
20032        // construction, so the borrowed-input
20033        // [`std::sync::Arc<str>`] axis is what routes the pipe through
20034        // the substrate-primitive [`super::DepList::as_str`] accessor
20035        // without a spurious [`Copy`] deref (which would only be
20036        // reachable through the owned-input
20037        // [`From<DepList> for std::sync::Arc<str>`] axis by first
20038        // calling `.copied()` on the iterator).
20039        for &variant in super::DepList::ALL {
20040            let via_trait: std::sync::Arc<str> =
20041                <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
20042            let via_method: &'static str = variant.as_str();
20043            assert_eq!(
20044                via_trait.as_ref(),
20045                via_method,
20046                "From<&DepList> for std::sync::Arc<str> impl must round-\
20047                 trip &DepList::{variant:?} to the same lifted \
20048                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20049                 DepList::as_str returns — divergence signals a silent \
20050                 detour off the substrate-primitive accessor"
20051            );
20052            let via_into: std::sync::Arc<str> = (&variant).into();
20053            assert_eq!(
20054                via_into.as_ref(),
20055                via_method,
20056                "Into<std::sync::Arc<str>>::into on &DepList::\
20057                 {variant:?} must byte-equal DepList::as_str on the \
20058                 same input — the blanket-derived Into shape on the \
20059                 borrowed-input surface must resolve to the same as_str \
20060                 dispatch as the explicit From impl"
20061            );
20062            let owned_arc: std::sync::Arc<str> =
20063                <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20064            assert_eq!(
20065                via_trait, owned_arc,
20066                "From<&DepList> for std::sync::Arc<str> and \
20067                 From<DepList> for std::sync::Arc<str> must resolve \
20068                 identically on DepList::{variant:?} — divergence \
20069                 signals the borrowed-input and owned-input \
20070                 std::sync::Arc<str> forward-projection input-shape \
20071                 paths have drifted onto different emit-sets"
20072            );
20073            let borrowed_static: &'static str =
20074                <&'static str as From<&super::DepList>>::from(&variant);
20075            assert_eq!(
20076                via_trait.as_ref(),
20077                borrowed_static,
20078                "From<&DepList> for std::sync::Arc<str> and \
20079                 From<&DepList> for &'static str must resolve \
20080                 identically on DepList::{variant:?} — divergence \
20081                 signals the borrowed-input std::sync::Arc<str> and \
20082                 &'static str return-shape paths have drifted onto \
20083                 different emit-sets"
20084            );
20085            let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
20086            assert_eq!(
20087                via_trait.as_ref(),
20088                borrowed_string.as_str(),
20089                "From<&DepList> for std::sync::Arc<str> and \
20090                 From<&DepList> for String must resolve identically on \
20091                 DepList::{variant:?} — divergence signals the \
20092                 borrowed-input std::sync::Arc<str> and owned-`String` \
20093                 return-shape paths have drifted onto different emit-\
20094                 sets"
20095            );
20096            let borrowed_cow: std::borrow::Cow<'static, str> =
20097                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
20098            assert_eq!(
20099                via_trait.as_ref(),
20100                borrowed_cow.as_ref(),
20101                "From<&DepList> for std::sync::Arc<str> and \
20102                 From<&DepList> for Cow<'static, str> must resolve \
20103                 identically on DepList::{variant:?} — divergence \
20104                 signals the borrowed-input std::sync::Arc<str> and \
20105                 Cow<'static, str> return-shape paths have drifted onto \
20106                 different emit-sets"
20107            );
20108            let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
20109            assert_eq!(
20110                via_trait.as_ref(),
20111                borrowed_box.as_ref(),
20112                "From<&DepList> for std::sync::Arc<str> and \
20113                 From<&DepList> for Box<str> must resolve identically \
20114                 on DepList::{variant:?} — divergence signals the \
20115                 borrowed-input std::sync::Arc<str> and Box<str> \
20116                 return-shape paths have drifted onto different emit-sets"
20117            );
20118        }
20119        let via_iter: Vec<std::sync::Arc<str>> = super::DepList::ALL
20120            .iter()
20121            .map(std::sync::Arc::<str>::from)
20122            .collect();
20123        let via_method: Vec<std::sync::Arc<str>> = super::DepList::ALL
20124            .iter()
20125            .map(|l| std::sync::Arc::<str>::from(l.as_str()))
20126            .collect();
20127        assert_eq!(
20128            via_iter, via_method,
20129            "`.iter().map(std::sync::Arc::<str>::from)` over \
20130             DepList::ALL — a call site whose iteration axis holds \
20131             `&DepList` by construction — must byte-equal \
20132             `.iter().map(|l| std::sync::Arc::<str>::from(l.as_str()))` \
20133             on every arm — the borrowed-input std::sync::Arc<str> \
20134             `From<&DepList> for std::sync::Arc<str>` axis is what \
20135             makes the `std::sync::Arc::<str>::from` composition route \
20136             through the substrate-primitive `DepList::as_str` \
20137             accessor without a spurious `Copy` deref (which would \
20138             only be reachable through the owned-input \
20139             `From<DepList> for std::sync::Arc<str>` axis by first \
20140             calling `.copied()` on the iterator)"
20141        );
20142    }
20143
20144    #[test]
20145    fn dep_list_from_into_rc_str_routes_through_as_str_accessor() {
20146        // Fail-before-pass-after byte-parity pin on the newly lifted
20147        // `impl From<DepList> for std::rc::Rc<str>` — asserts the
20148        // owned-input standard-library trait impl and the substrate-
20149        // primitive [`super::DepList::as_str`] `pub const fn` accessor
20150        // resolve to the same two-arm emit-set (the paired
20151        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
20152        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
20153        // byte-strings) across every arm the exhaustive
20154        // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
20155        // core-internal tier of the substrate-wide
20156        // [`std::rc::Rc<str>`] forward-projection campaign onto the
20157        // third caixa-core-internal peer, after the top-level
20158        // [`crate::CaixaKind`] (e04aff0), the second-peer
20159        // [`crate::dialeto::CaixaDialeto`] (c5595e5), and the render-
20160        // side [`crate::render::PathShapeViolation`] (31fc43e) pairs
20161        // opened the tier. Rust's standard library carries
20162        // `impl From<&str> for std::rc::Rc<str>` and
20163        // `impl From<String> for std::rc::Rc<str>` but no blanket
20164        // `impl<T: AsRef<str>> From<T> for std::rc::Rc<str>`, and the
20165        // [`std::sync::Arc<str>`] and [`std::rc::Rc<str>`] trait
20166        // tables are disjoint, so this axis is a distinct trait-
20167        // idiomatic surface that a
20168        // `let key: std::rc::Rc<str> = list.into();`-shaped call site
20169        // reaches through this impl and no other — a paired
20170        // `std::rc::Rc::<str>::from(list.as_str())` open-code has no
20171        // compile-time link back to the substrate primitive, and a
20172        // two-step `std::rc::Rc::<str>::from(String::from(list))`
20173        // composition through the owned-`String` axis allocates twice
20174        // (once into the intermediate `String`, once into the
20175        // [`std::rc::Rc<str>`] on the `From<String>` conversion) where
20176        // the single-step trait impl allocates once.
20177        //
20178        // Cross-axis byte-parity witness against the sibling owned-
20179        // input `{&'static str, String, Cow<'static, str>, Box<str>,
20180        // std::sync::Arc<str>}` return-shape axes — locking the six
20181        // return-shape paths on the owned-input surface together by
20182        // construction so any future detour off the substrate-
20183        // primitive [`super::DepList::as_str`] accessor trips at
20184        // caixa-core test time.
20185        for &variant in super::DepList::ALL {
20186            let via_trait: std::rc::Rc<str> =
20187                <std::rc::Rc<str> as From<super::DepList>>::from(variant);
20188            let via_method: &'static str = variant.as_str();
20189            assert_eq!(
20190                via_trait.as_ref(),
20191                via_method,
20192                "From<DepList> for std::rc::Rc<str> impl must round-\
20193                 trip DepList::{variant:?} to the same lifted \
20194                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20195                 DepList::as_str returns — divergence signals a silent \
20196                 detour off the substrate-primitive accessor"
20197            );
20198            let via_into: std::rc::Rc<str> = variant.into();
20199            assert_eq!(
20200                via_into.as_ref(),
20201                via_method,
20202                "Into<std::rc::Rc<str>>::into on DepList::{variant:?} \
20203                 must byte-equal DepList::as_str on the same input — \
20204                 the blanket-derived Into shape must resolve to the \
20205                 same as_str dispatch as the explicit From impl"
20206            );
20207            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
20208            assert_eq!(
20209                via_trait.as_ref(),
20210                owned_static,
20211                "From<DepList> for std::rc::Rc<str> and \
20212                 From<DepList> for &'static str must resolve identically \
20213                 on DepList::{variant:?} — divergence signals the owned-\
20214                 input std::rc::Rc<str> and &'static str return-shape \
20215                 paths have drifted onto different emit-sets"
20216            );
20217            let owned_string: String = <String as From<super::DepList>>::from(variant);
20218            assert_eq!(
20219                via_trait.as_ref(),
20220                owned_string.as_str(),
20221                "From<DepList> for std::rc::Rc<str> and \
20222                 From<DepList> for String must resolve identically on \
20223                 DepList::{variant:?} — divergence signals the owned-\
20224                 input std::rc::Rc<str> and owned-`String` return-shape \
20225                 paths have drifted onto different emit-sets"
20226            );
20227            let owned_cow: std::borrow::Cow<'static, str> =
20228                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
20229            assert_eq!(
20230                via_trait.as_ref(),
20231                owned_cow.as_ref(),
20232                "From<DepList> for std::rc::Rc<str> and \
20233                 From<DepList> for Cow<'static, str> must resolve \
20234                 identically on DepList::{variant:?} — divergence signals \
20235                 the owned-input std::rc::Rc<str> and Cow<'static, str> \
20236                 return-shape paths have drifted onto different emit-sets"
20237            );
20238            let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
20239            assert_eq!(
20240                via_trait.as_ref(),
20241                owned_box.as_ref(),
20242                "From<DepList> for std::rc::Rc<str> and \
20243                 From<DepList> for Box<str> must resolve identically on \
20244                 DepList::{variant:?} — divergence signals the owned-\
20245                 input std::rc::Rc<str> and Box<str> return-shape paths \
20246                 have drifted onto different emit-sets"
20247            );
20248            let owned_arc: std::sync::Arc<str> =
20249                <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20250            assert_eq!(
20251                via_trait.as_ref(),
20252                owned_arc.as_ref(),
20253                "From<DepList> for std::rc::Rc<str> and \
20254                 From<DepList> for std::sync::Arc<str> must resolve \
20255                 identically on DepList::{variant:?} — divergence signals \
20256                 the owned-input std::rc::Rc<str> and std::sync::Arc<str> \
20257                 return-shape paths have drifted onto different emit-sets \
20258                 (the two disjoint reference-counted trait tables have \
20259                 desynchronized on the caixa-core two-list dep-graph axis)"
20260            );
20261        }
20262    }
20263
20264    #[test]
20265    #[allow(
20266        clippy::too_many_lines,
20267        reason = "cross-axis partition pin folds five borrowed-input \
20268                  return-shape paths (&'static str, String, Cow<'static, \
20269                  str>, Box<str>, std::sync::Arc<str>) plus the paired \
20270                  owned-input Rc<str> witness and the \
20271                  .iter().map(std::rc::Rc::<str>::from) pipe witness into \
20272                  one exhaustive round-trip over DepList::ALL — the \
20273                  accepted line-count cost of keying the whole borrowed-\
20274                  input Rc<str> corner to the substrate-primitive as_str \
20275                  accessor at the same test-site"
20276    )]
20277    fn dep_list_from_borrowed_into_rc_str_routes_through_as_str_accessor() {
20278        // Fail-before-pass-after byte-parity pin on the newly lifted
20279        // `impl From<&DepList> for std::rc::Rc<str>` — asserts the
20280        // borrowed-input standard-library trait impl and the substrate-
20281        // primitive [`super::DepList::as_str`] `pub const fn` accessor
20282        // resolve to the same two-arm emit-set across every arm the
20283        // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
20284        // standard library does not carry a blanket
20285        // `impl<T: AsRef<str>> From<&T> for std::rc::Rc<str>` (nor a
20286        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
20287        // the borrowed-input `std::rc::Rc<str>` forward-projection axis
20288        // is a distinct trait-idiomatic surface that a
20289        // `let key: std::rc::Rc<str> = (&list).into();`-shaped call
20290        // site or a
20291        // `DepList::ALL.iter().map(std::rc::Rc::<str>::from)`-shaped
20292        // pipe reaches through this impl and no other — the paired
20293        // owned-input `From<DepList> for std::rc::Rc<str>` impl alone
20294        // would force every borrowed-input call site through a spurious
20295        // `Copy` deref
20296        // (`std::rc::Rc::<str>::from((*list).as_str())`) or a
20297        // `.copied()` restatement whose type bounds have no compile-
20298        // time link back to the substrate primitive.
20299        //
20300        // Closes the `{Self, &Self}` input-shape corner on the third
20301        // caixa-core-internal closed-set fieldless typed enum peer of
20302        // the substrate-wide trait-idiomatic [`std::rc::Rc<str>`]
20303        // forward-projection campaign, matching the trajectory the
20304        // paired [`crate::CaixaKind`] (e04aff0),
20305        // [`crate::dialeto::CaixaDialeto`] (c5595e5), and
20306        // [`crate::render::PathShapeViolation`] (31fc43e) pairs walked
20307        // before it on the same tier of the same axis.
20308        //
20309        // Cross-axis partition pin against the paired owned-input
20310        // [`From<DepList> for std::rc::Rc<str>`] and the sibling
20311        // borrowed-input `{&'static str, String, Cow<'static, str>,
20312        // Box<str>, std::sync::Arc<str>}` return-shape axes — locking
20313        // the six return-shape × input-shape paths on the borrowed-
20314        // input surface together by construction so any future detour
20315        // off the substrate-primitive accessor trips at caixa-core
20316        // test time. Then a `.iter().map(std::rc::Rc::<str>::from)`
20317        // pipe witness over [`super::DepList::ALL`] — whose iterator
20318        // yields `&DepList` by construction, so the borrowed-input
20319        // [`std::rc::Rc<str>`] axis is what routes the pipe through
20320        // the substrate-primitive [`super::DepList::as_str`] accessor
20321        // without a spurious [`Copy`] deref (which would only be
20322        // reachable through the owned-input
20323        // [`From<DepList> for std::rc::Rc<str>`] axis by first calling
20324        // `.copied()` on the iterator).
20325        for &variant in super::DepList::ALL {
20326            let via_trait: std::rc::Rc<str> =
20327                <std::rc::Rc<str> as From<&super::DepList>>::from(&variant);
20328            let via_method: &'static str = variant.as_str();
20329            assert_eq!(
20330                via_trait.as_ref(),
20331                via_method,
20332                "From<&DepList> for std::rc::Rc<str> impl must round-\
20333                 trip &DepList::{variant:?} to the same lifted \
20334                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
20335                 DepList::as_str returns — divergence signals a silent \
20336                 detour off the substrate-primitive accessor"
20337            );
20338            let via_into: std::rc::Rc<str> = (&variant).into();
20339            assert_eq!(
20340                via_into.as_ref(),
20341                via_method,
20342                "Into<std::rc::Rc<str>>::into on &DepList::\
20343                 {variant:?} must byte-equal DepList::as_str on the \
20344                 same input — the blanket-derived Into shape on the \
20345                 borrowed-input surface must resolve to the same \
20346                 as_str dispatch as the explicit From impl"
20347            );
20348            let owned_rc: std::rc::Rc<str> =
20349                <std::rc::Rc<str> as From<super::DepList>>::from(variant);
20350            assert_eq!(
20351                via_trait, owned_rc,
20352                "From<&DepList> for std::rc::Rc<str> and \
20353                 From<DepList> for std::rc::Rc<str> must resolve \
20354                 identically on DepList::{variant:?} — divergence \
20355                 signals the borrowed-input and owned-input \
20356                 std::rc::Rc<str> forward-projection input-shape \
20357                 paths have drifted onto different emit-sets"
20358            );
20359            let borrowed_static: &'static str =
20360                <&'static str as From<&super::DepList>>::from(&variant);
20361            assert_eq!(
20362                via_trait.as_ref(),
20363                borrowed_static,
20364                "From<&DepList> for std::rc::Rc<str> and \
20365                 From<&DepList> for &'static str must resolve \
20366                 identically on DepList::{variant:?} — divergence \
20367                 signals the borrowed-input std::rc::Rc<str> and \
20368                 &'static str return-shape paths have drifted onto \
20369                 different emit-sets"
20370            );
20371            let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
20372            assert_eq!(
20373                via_trait.as_ref(),
20374                borrowed_string.as_str(),
20375                "From<&DepList> for std::rc::Rc<str> and \
20376                 From<&DepList> for String must resolve identically on \
20377                 DepList::{variant:?} — divergence signals the \
20378                 borrowed-input std::rc::Rc<str> and owned-`String` \
20379                 return-shape paths have drifted onto different emit-\
20380                 sets"
20381            );
20382            let borrowed_cow: std::borrow::Cow<'static, str> =
20383                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
20384            assert_eq!(
20385                via_trait.as_ref(),
20386                borrowed_cow.as_ref(),
20387                "From<&DepList> for std::rc::Rc<str> and \
20388                 From<&DepList> for Cow<'static, str> must resolve \
20389                 identically on DepList::{variant:?} — divergence \
20390                 signals the borrowed-input std::rc::Rc<str> and \
20391                 Cow<'static, str> return-shape paths have drifted onto \
20392                 different emit-sets"
20393            );
20394            let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
20395            assert_eq!(
20396                via_trait.as_ref(),
20397                borrowed_box.as_ref(),
20398                "From<&DepList> for std::rc::Rc<str> and \
20399                 From<&DepList> for Box<str> must resolve identically \
20400                 on DepList::{variant:?} — divergence signals the \
20401                 borrowed-input std::rc::Rc<str> and Box<str> \
20402                 return-shape paths have drifted onto different emit-sets"
20403            );
20404            let borrowed_arc: std::sync::Arc<str> =
20405                <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
20406            assert_eq!(
20407                via_trait.as_ref(),
20408                borrowed_arc.as_ref(),
20409                "From<&DepList> for std::rc::Rc<str> and \
20410                 From<&DepList> for std::sync::Arc<str> must resolve \
20411                 identically on DepList::{variant:?} — divergence \
20412                 signals the borrowed-input std::rc::Rc<str> and \
20413                 std::sync::Arc<str> return-shape paths have drifted \
20414                 onto different emit-sets (the two disjoint reference-\
20415                 counted trait tables have desynchronized on the \
20416                 caixa-core two-list dep-graph axis)"
20417            );
20418        }
20419        let via_iter: Vec<std::rc::Rc<str>> = super::DepList::ALL
20420            .iter()
20421            .map(std::rc::Rc::<str>::from)
20422            .collect();
20423        let via_method: Vec<std::rc::Rc<str>> = super::DepList::ALL
20424            .iter()
20425            .map(|l| std::rc::Rc::<str>::from(l.as_str()))
20426            .collect();
20427        assert_eq!(
20428            via_iter, via_method,
20429            "`.iter().map(std::rc::Rc::<str>::from)` over \
20430             DepList::ALL — a call site whose iteration axis holds \
20431             `&DepList` by construction — must byte-equal \
20432             `.iter().map(|l| std::rc::Rc::<str>::from(l.as_str()))` \
20433             on every arm — the borrowed-input std::rc::Rc<str> \
20434             `From<&DepList> for std::rc::Rc<str>` axis is what makes \
20435             the `std::rc::Rc::<str>::from` composition route through \
20436             the substrate-primitive `DepList::as_str` accessor \
20437             without a spurious `Copy` deref (which would only be \
20438             reachable through the owned-input \
20439             `From<DepList> for std::rc::Rc<str>` axis by first \
20440             calling `.copied()` on the iterator)"
20441        );
20442    }
20443
20444    #[test]
20445    fn dep_list_author_keys_covers_every_arm() {
20446        // Load-bearing pin on the substrate-canonical
20447        // [`super::DepList::AUTHOR_KEYS`] exhaustive accept-set roster
20448        // on the `:`-prefixed kebab-case tatara-lisp author-surface
20449        // key axis: every variant of the sibling
20450        // [`super::DepList::ALL`] exhaustive-iteration surface must
20451        // project through [`super::DepList::as_str`] onto an entry the
20452        // [`super::DepList::AUTHOR_KEYS`] roster carries, and the
20453        // roster's length must byte-equal `super::DepList::ALL.len()`
20454        // so a silent skew between the [`super::DepList::as_str`]
20455        // match's arm-set and the roster's arm-set trips here at
20456        // caixa-core test time rather than at a downstream M4
20457        // `mesh.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection
20458        // body's `:deps` / `:deps-dev` accepted-key enumeration miss /
20459        // a `feira dep --list …` "did you mean" hint drift / a
20460        // downstream [`super::DepError`] widening's typed `list:
20461        // DepList` carry that fans on the enum through a stale
20462        // accepted-set. A future arm addition (a `:build-dep` or
20463        // `:tool-dep` third list once the substrate grows Cargo-style
20464        // split-graphs — both trajectory items the sibling
20465        // [`super::DepList::from_wire`] doc block already names)
20466        // extends [`super::DepList::ALL`] as a single edit and this
20467        // pin sweeps the new arm by iteration; the paired
20468        // [`super::DepList::AUTHOR_KEYS`] roster must grow in lockstep
20469        // or this assertion trips. Every entry is further pinned to
20470        // open with the ASCII `:` byte (the tatara-lisp author-surface
20471        // keyword marker) so a silent collapse of the author-key axis
20472        // with any hypothetical peer un-prefixed wire-form axis (an
20473        // entry byte-identical to a sibling `deps` / `deps-dev`
20474        // bare-kebab byte-string that would let an author-key-axis
20475        // consumer accept the un-prefixed vocabulary) trips here
20476        // rather than at a downstream consumer's
20477        // vocabulary-collision miss.
20478        //
20479        // Peer of the sibling
20480        // [`crate::kind::tests::caixa_kind_wire_names_covers_every_arm`]
20481        // (bd708bd) /
20482        // [`crate::kind::tests::caixa_kind_labels_covers_every_arm`]
20483        // (427fe75) /
20484        // [`crate::supervisor::tests::restart_strategy_wire_names_covers_every_arm`]
20485        // (3033f45) /
20486        // [`crate::supervisor::tests::restart_policy_wire_names_covers_every_arm`]
20487        // (ce9412b) /
20488        // [`crate::aplicacao::tests::placement_strategy_wire_names_covers_every_arm`]
20489        // (3e5b194) /
20490        // [`crate::aplicacao::tests::wit_shape_labels_covers_every_arm`]
20491        // (9d9f585) /
20492        // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
20493        // (b553ec9) /
20494        // [`crate::upgrade::tests::upgrade_instruction_lisp_forms_covers_every_arm`]
20495        // (1898d77) /
20496        // [`crate::upgrade::tests::upgrade_instruction_wire_forms_covers_every_arm`]
20497        // (cc42c0e) pins — the same closed-set exhaustive-roster
20498        // coverage discipline extended here onto the two-list dep-graph
20499        // closed-set typed enum, the ninth substrate-side closed-set
20500        // typed enum on the roster axis and the last unlifted
20501        // `&'static str`-carrying closed-set typed enum on the top-
20502        // level manifest surface to converge onto the discipline.
20503        //
20504        // Fail-before-pass-after locally verified by mutating one arm
20505        // of the paired [`crate::render::DEP_AUTHOR_KEY_*`] const
20506        // family (e.g. rebranding `DEP_AUTHOR_KEY_DEPS_DEV` from
20507        // `":deps-dev"` to `":deps_dev"`) — the length pin still
20508        // passes but the `contains` check fires on the mutated arm;
20509        // and by shortening the roster to one entry — the length pin
20510        // fires first.
20511        assert_eq!(
20512            super::DepList::AUTHOR_KEYS.len(),
20513            super::DepList::ALL.len(),
20514            "DepList::AUTHOR_KEYS.len() must byte-equal \
20515             DepList::ALL.len() — a mismatch means the roster and \
20516             the enum's arm-set have drifted; downstream consumers \
20517             that fan through both will silently disagree on the \
20518             accepted arm-set"
20519        );
20520        for &variant in super::DepList::ALL {
20521            let key = variant.as_str();
20522            assert!(
20523                super::DepList::AUTHOR_KEYS.contains(&key),
20524                "DepList::{variant:?}.as_str() = {key:?} must be a \
20525                 member of DepList::AUTHOR_KEYS — the emitter and the \
20526                 roster have drifted out of lockstep"
20527            );
20528        }
20529        for tag in super::DepList::AUTHOR_KEYS {
20530            let first = tag.chars().next().unwrap_or_else(|| {
20531                panic!(
20532                    "DepList::AUTHOR_KEYS entry {tag:?} must be a \
20533                     non-empty `:`-prefixed kebab-case tatara-lisp \
20534                     author-surface key byte-string"
20535                )
20536            });
20537            assert_eq!(
20538                first, ':',
20539                "DepList::AUTHOR_KEYS entry {tag:?} must open with \
20540                 the ASCII `:` byte (tatara-lisp author-surface \
20541                 keyword marker) — an un-prefixed entry would \
20542                 collide the roster with any hypothetical peer bare-\
20543                 kebab wire-form axis a downstream consumer might \
20544                 disambiguate against"
20545            );
20546        }
20547        // Pin the exact two-arm roster in declaration order so a
20548        // future arm-swap on either the roster or the paired
20549        // `render::DEP_AUTHOR_KEY_*` constants (a rebrand of the
20550        // arm-key mapping that leaves both the length pin and the
20551        // membership pin passing on their own) trips at caixa-core
20552        // test time under `assert_eq!`. Order matches variant
20553        // declaration order verbatim (`Prod` → `Dev`) so the roster
20554        // is the canonical ordering every listing / rendering
20555        // consumer defers to. Same declaration-order pin the sibling
20556        // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
20557        // (b553ec9) closes on the M3 `:politicas :rate-limit`
20558        // canonical-suffix axis.
20559        assert_eq!(
20560            super::DepList::AUTHOR_KEYS,
20561            &[
20562                crate::render::DEP_AUTHOR_KEY_DEPS,
20563                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
20564            ],
20565            "DepList::AUTHOR_KEYS must enumerate every arm's \
20566             author-surface key exactly once, in variant declaration \
20567             order (Prod → Dev)"
20568        );
20569    }
20570
20571    #[test]
20572    fn dep_list_from_str_routes_through_try_from_str_impl() {
20573        // Fail-before-pass-after byte-parity pin on the newly lifted
20574        // `impl std::str::FromStr for DepList` — asserts the standard-
20575        // library `.parse()` parse-axis entry point and the paired
20576        // [`super::DepList::try_from`] `TryFrom<&str>` impl (which in
20577        // turn routes through the substrate-primitive
20578        // [`super::DepList::from_wire`] `Option<Self>` accessor)
20579        // resolve to the same two-arm accept-set across every arm the
20580        // exhaustive [`super::DepList::ALL`] slice enumerates. First-
20581        // mover on the substrate-wide `FromStr` parse-axis campaign —
20582        // the peer method-named `from_wire` accessor and the paired
20583        // `TryFrom<&str>` trait impl fix the two-arm accept set; this
20584        // pin locks the `FromStr::from_str` trait entry point onto the
20585        // same set so any future divergence (a stray per-arm `match s`
20586        // re-inlining that opens a compile-time link to an un-lifted
20587        // arm-literal, a swap onto a hand-rolled parser that widens
20588        // the accept-set past the two wire-format consts) trips at
20589        // caixa-core test time.
20590        use std::str::FromStr;
20591        for &list in super::DepList::ALL {
20592            let wire = list.as_str();
20593            assert_eq!(
20594                <super::DepList as FromStr>::from_str(wire),
20595                Ok(list),
20596                "FromStr impl on DepList must round-trip \
20597                 DepList::{list:?}.as_str() = {wire:?} back to \
20598                 Ok(DepList::{list:?}) — divergence from \
20599                 DepList::try_from signals a silent detour off the \
20600                 paired reverse-projection trait impl"
20601            );
20602            assert_eq!(
20603                <super::DepList as FromStr>::from_str(wire).ok(),
20604                super::DepList::from_wire(wire),
20605                "FromStr ok()-projection on {wire:?} must byte-equal \
20606                 DepList::from_wire on the same input — divergence \
20607                 signals the two reverse-projection trait paths have \
20608                 drifted off the substrate-primitive accessor"
20609            );
20610            // `.parse::<DepList>()` short-form witness — the stdlib
20611            // consumer surface that reaches the enum through the
20612            // `T: FromStr` bound, not through `TryFrom<&str>`.
20613            let via_parse: Result<super::DepList, ()> = wire.parse();
20614            assert_eq!(
20615                via_parse,
20616                Ok(list),
20617                "`{wire:?}`.parse::<DepList>() must resolve to \
20618                 Ok(DepList::{list:?}) — divergence signals the \
20619                 stdlib `.parse()` short-form has drifted from the \
20620                 lifted `FromStr::from_str` impl"
20621            );
20622        }
20623    }
20624
20625    #[test]
20626    fn dep_list_from_str_rejects_unknown_byte_strings() {
20627        // Rejection witness on the `impl FromStr for DepList` —
20628        // sweeps candidate byte-strings outside the two-arm accept-set
20629        // the sibling [`super::DepList::as_str`] emits (`:deps` /
20630        // `:deps-dev`) and asserts every one lands on `Err(())`, so a
20631        // future accidental widening of the trait impl's accept-set (a
20632        // stray case-fold path, a silent inclusion of a rebrand alias
20633        // like `":packages"`, an English rebrand `":dev-deps"` in
20634        // reverse arm-order that would silently swap the two arms) trips
20635        // at caixa-core test time. Peer of the sibling
20636        // `dep_list_try_from_str_rejects_unknown_byte_strings` rejection
20637        // witness — the two pins together bracket both reverse-projection
20638        // trait impls against the same rejected set.
20639        use std::str::FromStr;
20640        let rejected: &[&str] = &[
20641            "",
20642            " ",
20643            "\t",
20644            "\n",
20645            ":deps ",
20646            " :deps",
20647            ":DEPS",
20648            ":Deps",
20649            ":Deps-Dev",
20650            ":deps_dev",
20651            ":deps-development",
20652            ":dev-deps",
20653            ":packages",
20654            ":packages-dev",
20655            "deps",
20656            "deps-dev",
20657            "Prod",
20658            "Dev",
20659            "prod",
20660            "dev",
20661            "\":deps\"",
20662            "\":deps-dev\"",
20663            ":deps\n",
20664            ":deps-dev\n",
20665        ];
20666        for &input in rejected {
20667            assert_eq!(
20668                <super::DepList as FromStr>::from_str(input),
20669                Err(()),
20670                "FromStr impl on DepList must reject unknown \
20671                 byte-string {input:?} — divergence from \
20672                 DepList::from_wire on the same input signals a silent \
20673                 accept-set widening past the two lifted \
20674                 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
20675            );
20676            assert_eq!(
20677                <super::DepList as FromStr>::from_str(input).ok(),
20678                super::DepList::from_wire(input),
20679                "FromStr ok()-projection on {input:?} must byte-equal \
20680                 DepList::from_wire on the same input — divergence \
20681                 signals the FromStr trait path has drifted off the \
20682                 substrate-primitive accessor"
20683            );
20684            let via_parse: Result<super::DepList, ()> = input.parse();
20685            assert_eq!(
20686                via_parse,
20687                Err(()),
20688                "`{input:?}`.parse::<DepList>() must reject the \
20689                 unknown byte-string — divergence signals the stdlib \
20690                 `.parse()` short-form has drifted from the lifted \
20691                 `FromStr::from_str` impl"
20692            );
20693        }
20694    }
20695
20696    #[test]
20697    #[allow(
20698        clippy::too_many_lines,
20699        reason = "cross-axis partition pin folds the substrate-primitive \
20700                  as_str accessor's `.as_bytes()` byte-tail plus the \
20701                  paired str-view (AsRef<str>, Display, as_str) and \
20702                  reverse-projection ({&'static str, String, \
20703                  Cow<'static, str>, Box<str>, std::sync::Arc<str>, \
20704                  std::rc::Rc<str>}) return-shape axes' `.as_bytes()` \
20705                  byte-tails plus a <T: AsRef<[u8]>>-bound-consumer \
20706                  witness plus a blake3::Hasher::update-shape byte-\
20707                  input surface witness into one exhaustive round-trip \
20708                  over DepList::ALL — the accepted line-count cost of \
20709                  opening the byte-view axis keyed to the substrate-\
20710                  primitive as_str accessor at the same test-site"
20711    )]
20712    #[allow(
20713        clippy::needless_borrows_for_generic_args,
20714        reason = "the borrowed-input surface (&variant) is exercised \
20715                  deliberately: the `<T: AsRef<[u8]>>`-bound consumer \
20716                  and the `blake3::Hasher::update`-shape byte-input \
20717                  surface both accept either owned or borrowed input \
20718                  through the standard-library blanket \
20719                  `impl<T: ?Sized + AsRef<[u8]>> AsRef<[u8]> for &T`, \
20720                  and this pin round-trips both input shapes to lock \
20721                  the borrowed-input path load-bearing against a \
20722                  future silent regression"
20723    )]
20724    fn dep_list_as_ref_bytes_routes_through_as_str_accessor() {
20725        // `<T: AsRef<[u8]>>`-bound-consumer witness helper: a generic
20726        // byte-input function accepts a [`super::DepList`] directly
20727        // through the trait bound, without the caller open-coding the
20728        // two-hop `list.as_str().as_bytes()` composition. Lifted to
20729        // the top of the function per `clippy::items_after_statements`.
20730        fn generic_bytes_sink<T: AsRef<[u8]>>(t: T) -> Vec<u8> {
20731            t.as_ref().to_vec()
20732        }
20733        // `blake3::Hasher::update`-shape byte-input surface mock:
20734        // mirrors `blake3::Hasher::update` / `ring::digest::Context::
20735        // update` / `sha2::Sha256::update`'s `impl AsRef<[u8]>`-bound
20736        // `update` signature so a per-caixa BLAKE3 content-address
20737        // closure that composes `hasher.update(list)` on the
20738        // [`crate::Lacre`] closure builder reaches the substrate-
20739        // primitive `as_str` accessor through the [`super::DepList`]
20740        // `AsRef<[u8]>` axis and no other. Lifted to the top of the
20741        // function per `clippy::items_after_statements`.
20742        struct MockHasher(Vec<u8>);
20743        impl MockHasher {
20744            fn new() -> Self {
20745                Self(Vec::new())
20746            }
20747            fn update(&mut self, bytes: impl AsRef<[u8]>) -> &mut Self {
20748                self.0.extend_from_slice(bytes.as_ref());
20749                self
20750            }
20751            fn finalize(self) -> Vec<u8> {
20752                self.0
20753            }
20754        }
20755
20756        // Fail-before-pass-after byte-parity pin on the newly lifted
20757        // `impl AsRef<[u8]> for DepList` — asserts the trait-idiomatic
20758        // byte-view standard-library impl and the substrate-primitive
20759        // [`super::DepList::as_str`] `pub const fn` accessor's
20760        // `.as_bytes()` byte-tail resolve to the same two-arm
20761        // `:`-prefixed kebab-case byte-string emit-set across every
20762        // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
20763        // Extends the substrate-wide trait-idiomatic byte-view axis
20764        // onto the third closed-set fieldless typed enum on the
20765        // caixa-core-internal tier — matching the trajectory the
20766        // sibling [`super::CaixaKind`] first-mover [`AsRef<[u8]>`]
20767        // impl (69d8d86) and [`super::CaixaDialeto`] second-mover
20768        // impl (8151347) walked before it.
20769        for &variant in super::DepList::ALL {
20770            let via_trait: &[u8] = <super::DepList as AsRef<[u8]>>::as_ref(&variant);
20771            let via_method_bytes: &[u8] = variant.as_str().as_bytes();
20772            assert_eq!(
20773                via_trait, via_method_bytes,
20774                "AsRef<[u8]> for DepList impl must byte-equal \
20775                 DepList::as_str().as_bytes() on DepList::\
20776                 {variant:?} — divergence signals a silent detour off \
20777                 the substrate-primitive accessor"
20778            );
20779            // Cross-axis witness against the paired str-view axes'
20780            // `.as_bytes()` byte-tails: [`AsRef<str>`] /
20781            // [`std::fmt::Display`] / [`super::DepList::as_str`] all
20782            // resolve to the same lifted `render::DEP_AUTHOR_KEY_*`
20783            // const roster, and the byte-view axis must byte-equal
20784            // each of their `.as_bytes()` byte-tails by construction
20785            // — locking the str-view and byte-view axes together at
20786            // the substrate-primitive accessor.
20787            let str_view_ref: &str = <super::DepList as AsRef<str>>::as_ref(&variant);
20788            assert_eq!(
20789                via_trait,
20790                str_view_ref.as_bytes(),
20791                "AsRef<[u8]> for DepList and AsRef<str> for DepList \
20792                 must resolve to byte-equal byte-tails on DepList::\
20793                 {variant:?} — divergence signals the byte-view and \
20794                 str-view axes have drifted off the same substrate-\
20795                 primitive as_str accessor"
20796            );
20797            let display_bytes = variant.to_string();
20798            assert_eq!(
20799                via_trait,
20800                display_bytes.as_bytes(),
20801                "AsRef<[u8]> for DepList and \
20802                 <DepList as std::fmt::Display>::to_string must \
20803                 resolve to byte-equal byte-tails on DepList::\
20804                 {variant:?} — divergence signals the byte-view axis \
20805                 and the Display formatter axis have drifted off the \
20806                 same substrate-primitive as_str accessor"
20807            );
20808            // Cross-axis witness against the paired reverse-
20809            // projection axes' `.as_bytes()` byte-tails: every one of
20810            // `{&'static str, String, Cow<'static, str>, Box<str>,
20811            // std::sync::Arc<str>, std::rc::Rc<str>}` allocates (or
20812            // borrows) the same `:`-prefixed kebab byte-string the
20813            // substrate-primitive accessor emits, so the byte-view
20814            // axis must byte-equal each of their `.as_bytes()` byte-
20815            // tails by construction.
20816            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
20817            assert_eq!(
20818                via_trait,
20819                owned_static.as_bytes(),
20820                "AsRef<[u8]> for DepList and From<DepList> for \
20821                 &'static str must resolve to byte-equal byte-tails on \
20822                 DepList::{variant:?}"
20823            );
20824            let owned_string: String = <String as From<super::DepList>>::from(variant);
20825            assert_eq!(
20826                via_trait,
20827                owned_string.as_bytes(),
20828                "AsRef<[u8]> for DepList and From<DepList> for \
20829                 String must resolve to byte-equal byte-tails on \
20830                 DepList::{variant:?}"
20831            );
20832            let owned_cow: std::borrow::Cow<'static, str> =
20833                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
20834            assert_eq!(
20835                via_trait,
20836                owned_cow.as_bytes(),
20837                "AsRef<[u8]> for DepList and From<DepList> for \
20838                 Cow<'static, str> must resolve to byte-equal byte-\
20839                 tails on DepList::{variant:?}"
20840            );
20841            let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
20842            assert_eq!(
20843                via_trait,
20844                owned_box.as_bytes(),
20845                "AsRef<[u8]> for DepList and From<DepList> for \
20846                 Box<str> must resolve to byte-equal byte-tails on \
20847                 DepList::{variant:?}"
20848            );
20849            let owned_arc: std::sync::Arc<str> =
20850                <std::sync::Arc<str> as From<super::DepList>>::from(variant);
20851            assert_eq!(
20852                via_trait,
20853                owned_arc.as_bytes(),
20854                "AsRef<[u8]> for DepList and From<DepList> for \
20855                 std::sync::Arc<str> must resolve to byte-equal byte-\
20856                 tails on DepList::{variant:?}"
20857            );
20858            let owned_rc_str: std::rc::Rc<str> =
20859                <std::rc::Rc<str> as From<super::DepList>>::from(variant);
20860            assert_eq!(
20861                via_trait,
20862                owned_rc_str.as_bytes(),
20863                "AsRef<[u8]> for DepList and From<DepList> for \
20864                 std::rc::Rc<str> must resolve to byte-equal byte-\
20865                 tails on DepList::{variant:?}"
20866            );
20867        }
20868        // `<T: AsRef<[u8]>>`-bound-consumer witness: the generic byte-
20869        // input function `generic_bytes_sink` (lifted above per
20870        // `clippy::items_after_statements`) accepts a [`super::DepList`]
20871        // directly through the trait bound, without the caller open-
20872        // coding the two-hop `list.as_str().as_bytes()` composition.
20873        // This is the shape that reaches the caixa-lacre BLAKE3
20874        // content-address closure's
20875        // `blake3::Hasher::update(impl AsRef<[u8]>)` byte-input surface
20876        // through this impl and no other. Exercised on both owned and
20877        // borrowed input surfaces via the standard-library blanket
20878        // `impl<T: ?Sized + AsRef<[u8]>> AsRef<[u8]> for &T`.
20879        for &variant in super::DepList::ALL {
20880            let via_generic = generic_bytes_sink(variant);
20881            let via_borrowed_generic = generic_bytes_sink(&variant);
20882            let via_method_bytes = variant.as_str().as_bytes().to_vec();
20883            assert_eq!(
20884                via_generic, via_method_bytes,
20885                "generic `<T: AsRef<[u8]>>`-bound consumer on \
20886                 DepList::{variant:?} must yield the same byte-tail \
20887                 DepList::as_str().as_bytes() returns — divergence \
20888                 signals the byte-view axis fails to bridge a generic \
20889                 byte-input trait bound to the substrate-primitive \
20890                 accessor"
20891            );
20892            assert_eq!(
20893                via_borrowed_generic, via_method_bytes,
20894                "generic `<T: AsRef<[u8]>>`-bound consumer on \
20895                 &DepList::{variant:?} must yield the same byte-tail \
20896                 DepList::as_str().as_bytes() returns — the borrowed-\
20897                 input surface must resolve to the same as_str dispatch"
20898            );
20899        }
20900        // `blake3::Hasher::update`-shape byte-input surface witness
20901        // on the caixa-lacre compounding target: the `MockHasher`
20902        // (lifted above per `clippy::items_after_statements`) mirrors
20903        // `blake3::Hasher::update` / `ring::digest::Context::update` /
20904        // `sha2::Sha256::update`'s `impl AsRef<[u8]>`-bound update
20905        // signature and accepts a [`super::DepList`] directly, routing
20906        // its byte-tail through the substrate-primitive `as_str`
20907        // accessor — the shape a future per-caixa BLAKE3 content-
20908        // address closure composes to fold a dep-list discriminator
20909        // byte-tag into the [`crate::Lacre`] closure body so a
20910        // downstream `Lacre` consumer can partition the runtime-
20911        // closure `:deps` from the dev-only-closure `:deps-dev` at
20912        // content-address time.
20913        for &variant in super::DepList::ALL {
20914            let mut owned_hasher = MockHasher::new();
20915            owned_hasher.update(variant);
20916            let owned_folded = owned_hasher.finalize();
20917            assert_eq!(
20918                owned_folded,
20919                variant.as_str().as_bytes(),
20920                "`hasher.update(list)`-shape composition on DepList::\
20921                 {variant:?} must fold the same byte-tail DepList::\
20922                 as_str().as_bytes() returns — the shape a future \
20923                 per-caixa BLAKE3 content-address closure composes to \
20924                 fold a dep-list discriminator byte-tag into the Lacre \
20925                 closure body"
20926            );
20927            let mut borrowed_hasher = MockHasher::new();
20928            borrowed_hasher.update(&variant);
20929            let borrowed_folded = borrowed_hasher.finalize();
20930            assert_eq!(
20931                borrowed_folded,
20932                variant.as_str().as_bytes(),
20933                "`hasher.update(&list)`-shape composition on \
20934                 &DepList::{variant:?} must fold the same byte-tail \
20935                 DepList::as_str().as_bytes() returns — the borrowed-\
20936                 input surface must resolve to the same as_str dispatch"
20937            );
20938        }
20939    }
20940}
20941
20942#[cfg(test)]
20943mod dep_source_is_variant_tests {
20944    use super::*;
20945
20946    fn all_variants() -> Vec<(DepSource, &'static str)> {
20947        vec![
20948            (
20949                DepSource::Git {
20950                    repo: "github:pleme-io/caixa-teia".into(),
20951                    tag: Some("v0.1.0".into()),
20952                    rev: None,
20953                    branch: None,
20954                },
20955                "Git",
20956            ),
20957            (
20958                DepSource::Path {
20959                    caminho: "../caixa-teia".into(),
20960                },
20961                "Path",
20962            ),
20963        ]
20964    }
20965
20966    fn predicate_row(s: &DepSource) -> [bool; 2] {
20967        [s.is_git(), s.is_path()]
20968    }
20969
20970    // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
20971    // derive-generated per-arm predicate partition — for every variant
20972    // in `all_variants()`, the observed 2-slot predicate row must equal
20973    // a one-hot row with the `true` at exactly the same index as the
20974    // variant's declaration order. Expected rows are generated live
20975    // from the enumeration rather than transcribed by hand, so a
20976    // copy-paste flip that reroutes one arm through the wrong predicate
20977    // lane trips at the identity-diagonal assertion the way every peer
20978    // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
20979    // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
20980    // / [`crate::upgrade::UpgradeInstruction`] /
20981    // [`crate::aplicacao::PlacementStrategy`] /
20982    // [`crate::aplicacao::RateLimitUnit`] /
20983    // [`crate::aplicacao::WitTarget`] /
20984    // [`crate::render::PathShapeViolation`] partition pin already does.
20985    #[test]
20986    fn dep_source_is_variant_predicates_partition_the_arm_set() {
20987        let variants = all_variants();
20988        for (idx, (variant, name)) in variants.iter().enumerate() {
20989            let observed = predicate_row(variant);
20990            let mut expected = [false; 2];
20991            expected[idx] = true;
20992            assert_eq!(
20993                observed, expected,
20994                "DepSource::{name} at declaration-order slot {idx} must \
20995                 satisfy exactly one is_* predicate (its own); observed \
20996                 row must equal the one-hot expected row — a drift \
20997                 would silently reroute one `:fonte`-arm consumer \
20998                 through the wrong predicate lane"
20999            );
21000        }
21001    }
21002
21003    // Byte-parity pin on the two field-agnostic `matches!` shapes the
21004    // per-arm arm-discriminator predicates replace at any future
21005    // consumer site (a `:fonte`-shape-only lint rule that flags path
21006    // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
21007    // a future admission-webhook that rejects `:fonte` shapes outside
21008    // the `is_git()` accept-set, a caixa-lacre indexing pass that
21009    // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
21010    // Refuses a future accidental split between the derived predicate
21011    // and its `matches!` shape — a hand-rolled shadow impl that
21012    // overrides one path, an accidental rebrand that leaves one
21013    // consumer on the raw `matches!` form — on the two load-bearing
21014    // `:fonte`-arm-discriminator axes every downstream substrate
21015    // consumer of the dep-source axis keys off.
21016    #[test]
21017    fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
21018        for (variant, name) in all_variants() {
21019            let via_matches_git = matches!(variant, DepSource::Git { .. });
21020            let via_predicate_git = variant.is_git();
21021            assert_eq!(
21022                via_predicate_git, via_matches_git,
21023                "DepSource::{name}.is_git() must byte-equal \
21024                 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
21025                 future converged consumer site would silently \
21026                 disagree with its pre-lift shape"
21027            );
21028            let via_matches_path = matches!(variant, DepSource::Path { .. });
21029            let via_predicate_path = variant.is_path();
21030            assert_eq!(
21031                via_predicate_path, via_matches_path,
21032                "DepSource::{name}.is_path() must byte-equal \
21033                 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
21034                 future converged consumer site would silently \
21035                 disagree with its pre-lift shape"
21036            );
21037        }
21038    }
21039
21040    // Cross-pin against every constructor path that materializes a
21041    // [`DepSource`] shape today (the [`DepSource::default_github`]
21042    // resolver-side fallback that materializes an unpinned
21043    // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
21044    // surface constructor that materializes a pinned `:tag`-carrying
21045    // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
21046    // fixture family builds inline). Every constructor's return must
21047    // satisfy the arm-discriminator predicate the constructor's
21048    // variant name matches — a future constructor addition (an
21049    // in-tree registry-fetch pin, a `DepSource::Feira` variant the
21050    // enclosing docstring already names as a trajectory item) surfaces
21051    // as a build-time failure that names the offending drift when its
21052    // return arm doesn't route through the paired predicate.
21053    #[test]
21054    fn dep_source_constructors_route_through_paired_is_variant_predicate() {
21055        let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
21056        assert!(
21057            via_default_github.is_git(),
21058            "DepSource::default_github must materialize a Git-arm shape — \
21059             a future constructor that routed through a non-Git arm \
21060             (a registry-fetch pin, a `DepSource::Feira` promotion) \
21061             would silently split the resolver's unpinned-shorthand \
21062             materializer from the sole_pin() precedence cascade"
21063        );
21064        assert!(
21065            !via_default_github.is_path(),
21066            "DepSource::default_github must NOT materialize a Path-arm \
21067             shape — the paired negation pin"
21068        );
21069
21070        let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
21071            .fonte
21072            .expect("Dep::git materializes a Some(fonte)");
21073        assert!(
21074            via_dep_git.is_git(),
21075            "Dep::git's `:fonte` materialization must land on the Git \
21076             arm — the author-surface pinned-git constructor's return \
21077             must route through the paired predicate"
21078        );
21079        assert!(!via_dep_git.is_path(), "paired negation pin");
21080
21081        let via_path = DepSource::Path {
21082            caminho: "../caixa-teia".into(),
21083        };
21084        assert!(
21085            via_path.is_path(),
21086            "the dev-mode Path-arm materialization must satisfy is_path()"
21087        );
21088        assert!(!via_path.is_git(), "paired negation pin");
21089    }
21090
21091    // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
21092    //    String, reason: String }` three-slot envelope on `DepError`,
21093    //    strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
21094    //    the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
21095    //    (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
21096    //    envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
21097    //    `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
21098    //    (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
21099
21100    #[test]
21101    fn versao_invalid_ctor_matches_struct_literal_wrap() {
21102        assert_eq!(
21103            DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
21104            DepError::VersaoInvalid {
21105                nome: "caixa-teia".to_string(),
21106                versao: "^0..1".to_string(),
21107                reason: "invalid comparator".to_string(),
21108            },
21109            "versao_invalid ctor must produce byte-equal \
21110             `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
21111        );
21112    }
21113
21114    #[test]
21115    fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
21116        assert_eq!(
21117            DepError::fonte_repo_shape(
21118                "caixa-teia",
21119                "-upload-pack=evil",
21120                "leading dash rejected".to_string(),
21121            ),
21122            DepError::FonteRepoShape {
21123                nome: "caixa-teia".to_string(),
21124                repo: "-upload-pack=evil".to_string(),
21125                reason: "leading dash rejected".to_string(),
21126            },
21127            "fonte_repo_shape ctor must produce byte-equal \
21128             `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
21129        );
21130    }
21131
21132    #[test]
21133    fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
21134        assert_eq!(
21135            DepError::caracteristica_invalid(
21136                "caixa-teia",
21137                "bad feature!",
21138                "embedded space rejected".to_string(),
21139            ),
21140            DepError::CaracteristicaInvalid {
21141                nome: "caixa-teia".to_string(),
21142                caracteristica: "bad feature!".to_string(),
21143                reason: "embedded space rejected".to_string(),
21144            },
21145            "caracteristica_invalid ctor must produce byte-equal \
21146             `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
21147        );
21148    }
21149
21150    #[test]
21151    fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
21152        // Cross-axis routing pin: sweep the three constructor input axes
21153        // (`nome: &str`, `<axis>: &str`, `reason: String`) through
21154        // distinct-per-axis fixtures against every generated arm in the
21155        // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
21156        // lowercase / trim / truncate on the two `&str` axes — a silent
21157        // field swap between `nome`, the middle `<axis>` field, and
21158        // `reason`, or a `reason` axis silently rerouted through
21159        // `.to_string()` instead of forwarded owned — surfaces here rather
21160        // than at a downstream diagnostic-shape mismatch. Peer of the
21161        // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
21162        // through_to_string` (0e35793) cross-axis routing pin on the same
21163        // envelope's `{ nome, caminho, byte }` three-slot family and of
21164        // the peer `dep_nome_list_ctors_route_nome_and_list_through_
21165        // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
21166        // — extended here onto the `{ nome, <axis>: String, reason:
21167        // String }` three-slot envelope so every substrate-primitive ctor
21168        // family in caixa-core's `DepError` envelope guarantees each field
21169        // routes the caller's value verbatim through `.to_string()` (or
21170        // owned-forward for `reason: String`) in declared field order.
21171        // Distinct-per-axis fixtures rule out any two-axis swap
21172        // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
21173        // same-fixture-per-axis pin.
21174        let nome = "sibling-teia";
21175        let axis = "distinct-axis-value";
21176        let reason = "distinct rejection sentence".to_string();
21177        assert_eq!(
21178            DepError::versao_invalid(nome, axis, reason.clone()),
21179            DepError::VersaoInvalid {
21180                nome: nome.to_string(),
21181                versao: axis.to_string(),
21182                reason: reason.clone(),
21183            },
21184            "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
21185             `reason` → `reason` in declared field order",
21186        );
21187        assert_eq!(
21188            DepError::fonte_repo_shape(nome, axis, reason.clone()),
21189            DepError::FonteRepoShape {
21190                nome: nome.to_string(),
21191                repo: axis.to_string(),
21192                reason: reason.clone(),
21193            },
21194            "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
21195             `reason` → `reason` in declared field order",
21196        );
21197        assert_eq!(
21198            DepError::caracteristica_invalid(nome, axis, reason.clone()),
21199            DepError::CaracteristicaInvalid {
21200                nome: nome.to_string(),
21201                caracteristica: axis.to_string(),
21202                reason: reason.clone(),
21203            },
21204            "caracteristica_invalid must route `nome` → `nome`, \
21205             `axis` → `caracteristica`, `reason` → `reason` in declared \
21206             field order",
21207        );
21208    }
21209
21210    // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
21211    //    two-slot envelope on `DepError`, missing rung between
21212    //    `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
21213    //    envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
21214    //    three-slot `{ nome, <axis>: String, reason: String }` envelope.
21215    //    Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
21216    //    two-slot `{ nome, list: &'static str }` envelope (same slot
21217    //    count, `&'static str` axis instead of owned `String` axis).
21218
21219    #[test]
21220    fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
21221        assert_eq!(
21222            DepError::fonte_pin_empty("caixa-teia", ":tag"),
21223            DepError::FontePinEmpty {
21224                nome: "caixa-teia".to_string(),
21225                pin: ":tag".to_string(),
21226            },
21227            "fonte_pin_empty ctor must produce byte-equal \
21228             `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
21229             on the same `(&str, &str)` fixture",
21230        );
21231    }
21232
21233    #[test]
21234    fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
21235        assert_eq!(
21236            DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
21237            DepError::FontePinAmbiguous {
21238                nome: "caixa-teia".to_string(),
21239                pins: ":tag, :rev".to_string(),
21240            },
21241            "fonte_pin_ambiguous ctor must produce byte-equal \
21242             `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
21243             wrap on the same `(&str, &str)` fixture",
21244        );
21245    }
21246
21247    #[test]
21248    fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
21249        assert_eq!(
21250            DepError::caracteristica_duplicate("caixa-teia", "http"),
21251            DepError::CaracteristicaDuplicate {
21252                nome: "caixa-teia".to_string(),
21253                caracteristica: "http".to_string(),
21254            },
21255            "caracteristica_duplicate ctor must produce byte-equal \
21256             `DepError::CaracteristicaDuplicate` to the pre-lift \
21257             struct-literal wrap on the same `(&str, &str)` fixture",
21258        );
21259    }
21260
21261    #[test]
21262    fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
21263        // Owned-`String` routing pin: thread the real
21264        // `set.join(", ")` `String` carrier through the ctor's
21265        // `&str`-parameter Deref coercion, so the ambiguity-arm
21266        // wire-up site's actual `&set.join(", ")` shape stays
21267        // byte-equal to a direct `":tag, :rev"` literal. A future
21268        // parameter-shape change silently dropping the Deref
21269        // coercion route (e.g., a switch to `impl Into<String>`)
21270        // surfaces here rather than at the wire-up's compile
21271        // error far from the ctor definition.
21272        let set: Vec<&'static str> = vec![":tag", ":rev"];
21273        let joined: String = set.join(", ");
21274        assert_eq!(
21275            DepError::fonte_pin_ambiguous("caixa-teia", &joined),
21276            DepError::FontePinAmbiguous {
21277                nome: "caixa-teia".to_string(),
21278                pins: ":tag, :rev".to_string(),
21279            },
21280            "fonte_pin_ambiguous ctor must accept an owned-`String` \
21281             `&set.join(\", \")` carrier via Deref coercion — the exact \
21282             shape the ambiguity-arm wire-up site passes into it",
21283        );
21284    }
21285
21286    #[test]
21287    fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
21288        // Cross-axis routing pin: sweep the two constructor input axes
21289        // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
21290        // fixtures against every generated arm in the
21291        // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
21292        // trim / truncate at codegen time — a silent field swap between
21293        // `nome` and the middle `<axis>` field, or a `<axis>` axis
21294        // silently rerouted through the wrong field on any one variant
21295        // — surfaces here rather than at a downstream diagnostic-shape
21296        // mismatch. Peer of the sibling
21297        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
21298        // (6f5e0cd) pin on the same envelope's peer two-slot family
21299        // (`{ nome, list: &'static str }`) and of the sibling
21300        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
21301        // (5621f8a) pin on the same envelope's three-slot `{ nome,
21302        // <axis>: String, reason: String }` family — extended here onto
21303        // the `{ nome, <axis>: String }` two-slot envelope so the last
21304        // per-`DepError`-two-slot-owned-axis rung on the ctor-family
21305        // ladder guarantees each field routes the caller's value
21306        // verbatim through `.to_string()` in declared field order.
21307        // Distinct-per-axis fixtures rule out any two-axis swap
21308        // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
21309        // per-axis pin.
21310        let nome = "sibling-teia";
21311        let axis = "distinct-axis-value";
21312        assert_eq!(
21313            DepError::fonte_pin_empty(nome, axis),
21314            DepError::FontePinEmpty {
21315                nome: nome.to_string(),
21316                pin: axis.to_string(),
21317            },
21318            "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
21319             in declared field order",
21320        );
21321        assert_eq!(
21322            DepError::fonte_pin_ambiguous(nome, axis),
21323            DepError::FontePinAmbiguous {
21324                nome: nome.to_string(),
21325                pins: axis.to_string(),
21326            },
21327            "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
21328             in declared field order",
21329        );
21330        assert_eq!(
21331            DepError::caracteristica_duplicate(nome, axis),
21332            DepError::CaracteristicaDuplicate {
21333                nome: nome.to_string(),
21334                caracteristica: axis.to_string(),
21335            },
21336            "caracteristica_duplicate must route `nome` → `nome`, \
21337             `axis` → `caracteristica` in declared field order",
21338        );
21339    }
21340
21341    #[test]
21342    fn nome_invalid_ctor_matches_struct_literal_wrap() {
21343        // Equivalence pin: the ctor produces byte-equal
21344        // `DepError::NomeInvalid` to the pre-lift open-coded struct-
21345        // literal that cloned the offending `:deps :nome` verbatim and
21346        // forwarded the [`crate::render::is_dns_1123_label`]-shaped
21347        // owned `reason` payload at the caller site inside
21348        // [`Dep::validate`]. Guards any future field-addition /
21349        // reordering / accessor-return tweak on the variant. Sibling of
21350        // the peer four-slot `fonte_pin_shape` ctor equivalence pins
21351        // (below) and the sibling three-slot
21352        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
21353        // pin on the same envelope's three-slot `{ nome, <axis>: String,
21354        // reason: String }` family.
21355        let nome = "Caixa-Teia";
21356        let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
21357        let via_ctor = DepError::nome_invalid(nome, reason.clone());
21358        let via_literal = DepError::NomeInvalid {
21359            nome: nome.to_string(),
21360            reason,
21361        };
21362        assert_eq!(
21363            via_ctor, via_literal,
21364            "nome_invalid(nome, reason) must byte-equal the open-coded \
21365             NomeInvalid struct-literal on the same `(nome, reason)` fixture"
21366        );
21367        assert_eq!(
21368            via_ctor.to_string(),
21369            via_literal.to_string(),
21370            "Display byte-string must byte-equal the open-coded struct-literal"
21371        );
21372    }
21373
21374    #[test]
21375    fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
21376        // Boundary-sweep pin on the ctor's two-slot projection: sweep
21377        // the two ctor input axes (`nome: &str`, `reason: String`)
21378        // through distinct-per-axis fixtures against a representative
21379        // set of DNS-1123-refused `:deps :nome` byte-strings, so any
21380        // wrapper-side silent lowercase / trim / truncate at codegen
21381        // time — a silent field swap between `nome` and `reason`, an
21382        // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
21383        // divergence on the `reason` axis — surfaces at caixa-core
21384        // build time rather than at a downstream diagnostic consumer
21385        // that reads `err.nome` / `err.reason` back and gets a different
21386        // value than the one it stored. Peer of the sibling
21387        // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
21388        // (7f7c950) pin on the same envelope's peer two-slot family
21389        // (`{ nome, <axis>: String }`) — extended here onto the
21390        // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
21391        // variant carries. Distinct-per-axis fixtures rule out any
21392        // two-axis swap (`nome` ↔ `reason`) that would still pass a
21393        // same-fixture-per-axis pin. The sweep list carries a mixed
21394        // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
21395        // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
21396        // over-63-byte) so a future silent per-input normalization
21397        // surfaces on the arm that diverges.
21398        for nome in [
21399            "Caixa-Teia",
21400            "caixa_teia",
21401            "caixa.teia",
21402            "-caixa-teia",
21403            "caixa-teia-",
21404            "caixa/teia",
21405            &"a".repeat(64),
21406        ] {
21407            let reason = crate::render::is_dns_1123_label(nome)
21408                .expect_err("fixture must be a DNS-1123-refused label");
21409            let via_ctor = DepError::nome_invalid(nome, reason.clone());
21410            let DepError::NomeInvalid {
21411                nome: stored_nome,
21412                reason: stored_reason,
21413            } = via_ctor
21414            else {
21415                panic!("nome_invalid must construct NomeInvalid for {nome:?}");
21416            };
21417            assert_eq!(
21418                stored_nome, nome,
21419                "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
21420            );
21421            assert_eq!(
21422                stored_reason, reason,
21423                "reason slot must forward the owned `String` verbatim for {nome:?}"
21424            );
21425        }
21426    }
21427
21428    #[test]
21429    fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
21430        // End-to-end pin: the sole in-crate wire-up site
21431        // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
21432        // [`DepError::nome_invalid`] and the observed `Err` byte-equals
21433        // the ctor's output on the same DNS-1123-refused `:deps :nome`
21434        // fixture, with identical `Display` rendering. A future silent
21435        // de-lift of the wire-up back to the open-coded struct-literal
21436        // trips this test at caixa-core build time rather than at a
21437        // downstream diagnostic consumer far from the wire-up commit.
21438        // Sibling of the peer
21439        // `nome_invalid_diagnostic_carries_offending_name` pattern-match
21440        // pin on the same wire-up — extended here from a `matches!`
21441        // shape check to a byte-identity + Display parity route through
21442        // the ctor.
21443        let d = Dep::simple("Caixa_Teia", "^0.1");
21444        let observed = d.validate().unwrap_err();
21445        let reason = crate::render::is_dns_1123_label("Caixa_Teia")
21446            .expect_err("fixture must be DNS-1123-refused");
21447        let expected = DepError::nome_invalid("Caixa_Teia", reason);
21448        assert_eq!(
21449            observed, expected,
21450            "Dep::validate's DNS-1123 refusal arm must byte-equal \
21451             nome_invalid(nome, reason)"
21452        );
21453        assert_eq!(
21454            observed.to_string(),
21455            expected.to_string(),
21456            "Display byte-string parity"
21457        );
21458    }
21459}